diff options
author | Luiz Augusto von Dentz <luiz.dentz@openbossa.org> | 2008-11-26 14:50:16 -0300 |
---|---|---|
committer | Luiz Augusto von Dentz <luiz.dentz@openbossa.org> | 2008-11-26 14:50:16 -0300 |
commit | 09d691ffa7e3d873c140aa05a4c2d6c888e1d769 (patch) | |
tree | 128d7d2c79625b587abc30c92f046dbe06b6e4a6 /audio/headset.c | |
parent | 4a7ef16ea61752ccb2ea7cd1db965b900417cfa0 (diff) |
Fix proble with concurrent clients connecting audio socket.
Concurrent connections is needed in order to support clients holding
different access locks of the headset, eg. arecord | aplay.
Diffstat (limited to 'audio/headset.c')
-rw-r--r-- | audio/headset.c | 33 |
1 files changed, 27 insertions, 6 deletions
diff --git a/audio/headset.c b/audio/headset.c index a7a0a969..be07e424 100644 --- a/audio/headset.c +++ b/audio/headset.c @@ -2124,7 +2124,8 @@ unsigned int headset_request_stream(struct audio_device *dev, hs->dc_timer = 0; } - if (hs->state == HEADSET_STATE_CONNECT_IN_PROGRESS) + if (hs->state == HEADSET_STATE_CONNECT_IN_PROGRESS || + hs->state == HEADSET_STATE_PLAY_IN_PROGRESS) return connect_cb_new(hs, HEADSET_STATE_PLAYING, cb, user_data); if (hs->rfcomm == NULL) { @@ -2141,7 +2142,7 @@ unsigned int headset_request_stream(struct audio_device *dev, return id; } -unsigned int headset_suspend_stream(struct audio_device *dev, +unsigned int headset_config_stream(struct audio_device *dev, headset_stream_cb_t cb, headset_lock_t lock, void *user_data) @@ -2161,10 +2162,7 @@ unsigned int headset_suspend_stream(struct audio_device *dev, return connect_cb_new(hs, HEADSET_STATE_CONNECTED, cb, user_data); - if (hs->sco) { - close_sco(dev); - goto done; - } else if (hs->rfcomm) + if (hs->rfcomm) goto done; if (rfcomm_connect(dev, cb, user_data, &id) < 0) @@ -2181,6 +2179,29 @@ done: return id; } +unsigned int headset_suspend_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 || !hs->rfcomm || !hs->sco) + return 0; + + if (hs->dc_timer) { + g_source_remove(hs->dc_timer); + hs->dc_timer = 0; + } + + close_sco(dev); + + id = connect_cb_new(hs, HEADSET_STATE_CONNECTED, cb, user_data); + g_idle_add((GSourceFunc) dummy_connect_complete, dev); + return id; +} + gboolean get_hfp_active(struct audio_device *dev) { struct headset *hs = dev->headset; |