diff options
author | Luiz Augusto von Dentz <luiz.dentz@openbossa.org> | 2008-11-25 11:42:25 -0300 |
---|---|---|
committer | Luiz Augusto von Dentz <luiz.dentz@openbossa.org> | 2008-11-25 11:42:25 -0300 |
commit | c3a264a57a6e61c22280b52dd01f2677600a04f2 (patch) | |
tree | 0ee2658bfd373798003568d9b3f6fdbcefa0ef1b /audio | |
parent | 0b6b1da0dd654d32873aacf81791c58316b377e3 (diff) |
Fix headset_request_stream to check for stream locks.
A stream should only be configured if there is no other application
holding the lock.
Diffstat (limited to 'audio')
-rw-r--r-- | audio/headset.c | 7 | ||||
-rw-r--r-- | audio/headset.h | 4 | ||||
-rw-r--r-- | audio/unix.c | 40 |
3 files changed, 32 insertions, 19 deletions
diff --git a/audio/headset.c b/audio/headset.c index 3600e269..75affd37 100644 --- a/audio/headset.c +++ b/audio/headset.c @@ -2105,12 +2105,17 @@ static gboolean dummy_connect_complete(struct audio_device *dev) return FALSE; } -unsigned int headset_request_stream(struct audio_device *dev, headset_stream_cb_t cb, +unsigned int headset_request_stream(struct audio_device *dev, + headset_stream_cb_t cb, + headset_lock_t lock, void *user_data) { struct headset *hs = dev->headset; unsigned int id; + if (hs->lock & lock) + return 0; + if (hs->rfcomm && hs->sco) { id = connect_cb_new(hs, HEADSET_STATE_PLAYING, cb, user_data); g_idle_add((GSourceFunc) dummy_connect_complete, dev); diff --git a/audio/headset.h b/audio/headset.h index c8d63b9b..18205c4d 100644 --- a/audio/headset.h +++ b/audio/headset.h @@ -53,7 +53,9 @@ void headset_update(struct audio_device *dev, uint16_t svc, const char *uuidstr); unsigned int headset_request_stream(struct audio_device *dev, - headset_stream_cb_t cb, void *user_data); + headset_stream_cb_t cb, + headset_lock_t lock, + void *user_data); gboolean headset_cancel_stream(struct audio_device *dev, unsigned int id); gboolean get_hfp_active(struct audio_device *dev); diff --git a/audio/unix.c b/audio/unix.c index 141a2b10..e40aa418 100644 --- a/audio/unix.c +++ b/audio/unix.c @@ -259,21 +259,6 @@ static void headset_setup_complete(struct audio_device *dev, void *user_data) if (!dev) goto failed; - switch (client->access_mode) { - case BT_CAPABILITIES_ACCESS_MODE_READ: - hs->lock = HEADSET_LOCK_READ; - break; - case BT_CAPABILITIES_ACCESS_MODE_WRITE: - hs->lock = HEADSET_LOCK_WRITE; - break; - case BT_CAPABILITIES_ACCESS_MODE_READWRITE: - hs->lock = HEADSET_LOCK_READ | HEADSET_LOCK_WRITE; - break; - default: - hs->lock = 0; - break; - } - if (!headset_lock(dev, hs->lock)) { error("Unable to lock headset"); goto failed; @@ -606,6 +591,7 @@ static void start_config(struct audio_device *dev, struct unix_client *client) { struct a2dp_data *a2dp; unsigned int id; + struct headset_data *hs; client->type = select_service(dev, client->interface); @@ -627,7 +613,23 @@ static void start_config(struct audio_device *dev, struct unix_client *client) break; case TYPE_HEADSET: - id = headset_request_stream(dev, headset_setup_complete, client); + hs = &client->d.hs; + switch (client->access_mode) { + case BT_CAPABILITIES_ACCESS_MODE_READ: + hs->lock = HEADSET_LOCK_READ; + break; + case BT_CAPABILITIES_ACCESS_MODE_WRITE: + hs->lock = HEADSET_LOCK_WRITE; + break; + case BT_CAPABILITIES_ACCESS_MODE_READWRITE: + hs->lock = HEADSET_LOCK_READ | HEADSET_LOCK_WRITE; + break; + default: + hs->lock = 0; + break; + } + id = headset_request_stream(dev, headset_setup_complete, + hs->lock, client); client->cancel = headset_cancel_stream; break; @@ -703,6 +705,7 @@ failed: static void start_suspend(struct audio_device *dev, struct unix_client *client) { struct a2dp_data *a2dp; + struct headset_data *hs; unsigned int id; client->type = select_service(dev, client->interface); @@ -730,7 +733,10 @@ static void start_suspend(struct audio_device *dev, struct unix_client *client) break; case TYPE_HEADSET: - id = headset_request_stream(dev, headset_setup_complete, client); + hs = &client->d.hs; + + id = headset_request_stream(dev, headset_setup_complete, + hs->lock, client); client->cancel = headset_cancel_stream; break; |