summaryrefslogtreecommitdiffstats
path: root/audio
diff options
context:
space:
mode:
authorLuiz Augusto von Dentz <luiz.dentz@openbossa.org>2008-11-25 16:11:24 -0300
committerLuiz Augusto von Dentz <luiz.dentz@openbossa.org>2008-11-25 16:11:24 -0300
commitc6ca785eb241e6e93bcc6ef1ef430cf09ae362b3 (patch)
tree666c45cfd8e2ad75aa1309e26242b3163f9fcd6e /audio
parentc3a264a57a6e61c22280b52dd01f2677600a04f2 (diff)
Make hfp/hsp to suspend properly.
Diffstat (limited to 'audio')
-rw-r--r--audio/headset.c31
-rw-r--r--audio/headset.h4
-rw-r--r--audio/unix.c24
3 files changed, 58 insertions, 1 deletions
diff --git a/audio/headset.c b/audio/headset.c
index 75affd37..27580c5d 100644
--- a/audio/headset.c
+++ b/audio/headset.c
@@ -2144,6 +2144,37 @@ unsigned int headset_request_stream(struct audio_device *dev,
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)
+ return 0;
+
+ if (!hs->rfcomm)
+ return 0;
+
+ if (hs->dc_timer) {
+ g_source_remove(hs->dc_timer);
+ hs->dc_timer = 0;
+ }
+
+ if (hs->state == HEADSET_STATE_CONNECT_IN_PROGRESS ||
+ hs->state == HEADSET_STATE_PLAY_IN_PROGRESS)
+ return connect_cb_new(hs, HEADSET_STATE_CONNECTED, cb,
+ user_data);
+
+ 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 18205c4d..25c7acf2 100644
--- a/audio/headset.h
+++ b/audio/headset.h
@@ -56,6 +56,10 @@ unsigned int headset_request_stream(struct audio_device *dev,
headset_stream_cb_t cb,
headset_lock_t lock,
void *user_data);
+unsigned int headset_suspend_stream(struct audio_device *dev,
+ 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 e40aa418..ea5e3b8a 100644
--- a/audio/unix.c
+++ b/audio/unix.c
@@ -320,6 +320,28 @@ failed:
client->dev = NULL;
}
+static void headset_suspend_complete(struct audio_device *dev, void *user_data)
+{
+ struct unix_client *client = user_data;
+ char buf[BT_AUDIO_IPC_PACKET_SIZE];
+ struct bt_streamstart_rsp *rsp = (void *) buf;
+
+ if (!dev)
+ goto failed;
+
+ memset(buf, 0, sizeof(buf));
+ rsp->rsp_h.msg_h.msg_type = BT_STREAMSTOP_RSP;
+ rsp->rsp_h.posix_errno = 0;
+ unix_ipc_sendmsg(client, &rsp->rsp_h.msg_h);
+
+ return;
+
+failed:
+ error("suspend failed");
+ unix_ipc_error(client, BT_STREAMSTOP_RSP, EIO);
+ client->dev = NULL;
+}
+
static void a2dp_discovery_complete(struct avdtp *session, GSList *seps,
struct avdtp_error *err,
void *user_data)
@@ -735,7 +757,7 @@ static void start_suspend(struct audio_device *dev, struct unix_client *client)
case TYPE_HEADSET:
hs = &client->d.hs;
- id = headset_request_stream(dev, headset_setup_complete,
+ id = headset_suspend_stream(dev, headset_suspend_complete,
hs->lock, client);
client->cancel = headset_cancel_stream;
break;