summaryrefslogtreecommitdiffstats
path: root/audio/headset.c
diff options
context:
space:
mode:
authorLuiz Augusto von Dentz <luiz.dentz@openbossa.org>2008-11-25 19:22:35 -0300
committerLuiz Augusto von Dentz <luiz.dentz@openbossa.org>2008-11-25 19:22:35 -0300
commitd63872f77146dbe3bd005409ba21abc8aa07dd74 (patch)
treed57668d40a049535b87f197b40730eb35481352c /audio/headset.c
parent4cd5a2c0dc111aa55f08b2585fcdaeabe48e6cf3 (diff)
Fix headset configuration and start.
Diffstat (limited to 'audio/headset.c')
-rw-r--r--audio/headset.c28
1 files changed, 17 insertions, 11 deletions
diff --git a/audio/headset.c b/audio/headset.c
index 27580c5d..a7a0a969 100644
--- a/audio/headset.c
+++ b/audio/headset.c
@@ -2113,9 +2113,6 @@ unsigned int headset_request_stream(struct audio_device *dev,
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);
@@ -2152,10 +2149,7 @@ unsigned int headset_suspend_stream(struct audio_device *dev,
struct headset *hs = dev->headset;
unsigned int id;
- if (hs->lock & ~lock)
- return 0;
-
- if (!hs->rfcomm)
+ if (hs->lock & lock)
return 0;
if (hs->dc_timer) {
@@ -2163,15 +2157,27 @@ unsigned int headset_suspend_stream(struct audio_device *dev,
hs->dc_timer = 0;
}
- if (hs->state == HEADSET_STATE_CONNECT_IN_PROGRESS ||
- hs->state == HEADSET_STATE_PLAY_IN_PROGRESS)
+ if (hs->state == HEADSET_STATE_CONNECT_IN_PROGRESS)
return connect_cb_new(hs, HEADSET_STATE_CONNECTED, cb,
user_data);
- close_sco(dev);
+ if (hs->sco) {
+ close_sco(dev);
+ goto done;
+ } else if (hs->rfcomm)
+ goto done;
+
+ if (rfcomm_connect(dev, cb, user_data, &id) < 0)
+ return 0;
+
+ hs->auto_dc = TRUE;
+ hs->pending->target_state = HEADSET_STATE_CONNECTED;
+
+ return id;
+
+done:
id = connect_cb_new(hs, HEADSET_STATE_CONNECTED, cb, user_data);
g_idle_add((GSourceFunc) dummy_connect_complete, dev);
-
return id;
}