diff options
author | Johan Hedberg <johan.hedberg@nokia.com> | 2007-08-31 11:51:43 +0000 |
---|---|---|
committer | Johan Hedberg <johan.hedberg@nokia.com> | 2007-08-31 11:51:43 +0000 |
commit | ec384afacde8614306abe32cf40c55b795783f0e (patch) | |
tree | 64becc3deee3b735acddd15157fa428ccfbf2b22 /audio/headset.c | |
parent | fc0d501d82773718d0f2d040f786136332c39813 (diff) |
Implement proper locking for headsets
Diffstat (limited to 'audio/headset.c')
-rw-r--r-- | audio/headset.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/audio/headset.c b/audio/headset.c index 25a5ebc6..0f2732e3 100644 --- a/audio/headset.c +++ b/audio/headset.c @@ -102,7 +102,7 @@ struct headset { int sp_gain; int mic_gain; - gboolean locked; + headset_lock_t lock; }; static int rfcomm_connect(struct device *device, struct pending_connect *c); @@ -1450,7 +1450,7 @@ unsigned int headset_request_stream(struct device *dev, headset_stream_cb_t cb, if (hs->rfcomm && hs->sco) { hs->pending = g_slist_append(hs->pending, c); - g_idle_add((GSourceFunc) finalize_stream_setup, hs); + g_idle_add((GSourceFunc) finalize_stream_setup, dev); return c->id; } @@ -1604,28 +1604,28 @@ gboolean headset_is_active(struct device *dev) return FALSE; } -gboolean headset_lock(struct device *dev) +gboolean headset_lock(struct device *dev, headset_lock_t lock) { struct headset *hs = dev->headset; - if (hs->locked) + if (hs->lock & lock) return FALSE; - hs->locked = TRUE; + hs->lock |= lock; return TRUE; } -gboolean headset_unlock(struct device *dev) +gboolean headset_unlock(struct device *dev, headset_lock_t lock) { struct headset *hs = dev->headset; - if (!hs->locked) + if (!(hs->lock & lock)) return FALSE; - hs->locked = FALSE; + hs->lock &= ~lock; - if (hs->state > HEADSET_STATE_DISCONNECTED) + if (!hs->lock && hs->state > HEADSET_STATE_DISCONNECTED) headset_set_state(dev, HEADSET_STATE_DISCONNECTED); return TRUE; |