summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuiz Augusto von Dentz <luiz.dentz@openbossa.org>2008-11-26 14:50:16 -0300
committerLuiz Augusto von Dentz <luiz.dentz@openbossa.org>2008-11-26 14:50:16 -0300
commit09d691ffa7e3d873c140aa05a4c2d6c888e1d769 (patch)
tree128d7d2c79625b587abc30c92f046dbe06b6e4a6
parent4a7ef16ea61752ccb2ea7cd1db965b900417cfa0 (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.
-rw-r--r--audio/headset.c33
-rw-r--r--audio/headset.h4
-rw-r--r--audio/unix.c4
3 files changed, 33 insertions, 8 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;
diff --git a/audio/headset.h b/audio/headset.h
index 25c7acf2..c7b00e02 100644
--- a/audio/headset.h
+++ b/audio/headset.h
@@ -52,6 +52,10 @@ uint32_t headset_config_init(GKeyFile *config);
void headset_update(struct audio_device *dev, uint16_t svc,
const char *uuidstr);
+unsigned int headset_config_stream(struct audio_device *dev,
+ headset_stream_cb_t cb,
+ headset_lock_t lock,
+ void *user_data);
unsigned int headset_request_stream(struct audio_device *dev,
headset_stream_cb_t cb,
headset_lock_t lock,
diff --git a/audio/unix.c b/audio/unix.c
index eeb4a5d6..921e15ef 100644
--- a/audio/unix.c
+++ b/audio/unix.c
@@ -650,7 +650,7 @@ static void start_config(struct audio_device *dev, struct unix_client *client)
break;
}
- id = headset_suspend_stream(dev, headset_setup_complete,
+ id = headset_config_stream(dev, headset_setup_complete,
hs->lock, client);
client->cancel = headset_cancel_stream;
break;
@@ -763,7 +763,7 @@ static void start_suspend(struct audio_device *dev, struct unix_client *client)
hs = &client->d.hs;
id = headset_suspend_stream(dev, headset_suspend_complete,
- ~hs->lock, client);
+ hs->lock, client);
client->cancel = headset_cancel_stream;
break;