summaryrefslogtreecommitdiffstats
path: root/src/modules/bluetooth/module-bluetooth-device.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2009-03-19 17:46:13 +0100
committerLennart Poettering <lennart@poettering.net>2009-03-19 17:46:13 +0100
commit4a983124e1ca76f05050e149d6333ec6b6940886 (patch)
tree6e4030f08323764cd6b638022244255427de11cb /src/modules/bluetooth/module-bluetooth-device.c
parent291d21c4bab6970b70b08cc301c5287b4a11b20e (diff)
parente83621724d7939b97b4f01f0d7e965d61ef8e55e (diff)
Merge commit 'elmarco/bluetooth-fixes'
Diffstat (limited to 'src/modules/bluetooth/module-bluetooth-device.c')
-rw-r--r--src/modules/bluetooth/module-bluetooth-device.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/modules/bluetooth/module-bluetooth-device.c b/src/modules/bluetooth/module-bluetooth-device.c
index 2ae6e111..1b61a6fc 100644
--- a/src/modules/bluetooth/module-bluetooth-device.c
+++ b/src/modules/bluetooth/module-bluetooth-device.c
@@ -161,6 +161,8 @@ struct userdata {
int service_write_type, service_read_type;
};
+#define USE_SCO_OVER_PCM(u) (u->profile == PROFILE_HSP && (u->hsp.sco_sink && u->hsp.sco_source))
+
static int init_bt(struct userdata *u);
static int init_profile(struct userdata *u);
@@ -654,7 +656,7 @@ static int set_conf(struct userdata *u) {
return 0;
}
-/* from IO thread */
+/* from IO thread, except in SCO over PCM */
static int start_stream_fd(struct userdata *u) {
union {
bt_audio_msg_header_t rsp;
@@ -1358,8 +1360,6 @@ static char *get_name(const char *type, pa_modargs *ma, const char *device_id, p
return pa_sprintf_malloc("bluez_%s.%s", type, n);
}
-#define USE_SCO_OVER_PCM(u) (u->profile == PROFILE_HSP && (u->hsp.sco_sink && u->hsp.sco_source))
-
static void sco_over_pcm_state_update(struct userdata *u) {
pa_assert(u);
pa_assert(USE_SCO_OVER_PCM(u));
@@ -1374,11 +1374,14 @@ static void sco_over_pcm_state_update(struct userdata *u) {
if ((init_bt(u) < 0) || (init_profile(u) < 0))
pa_log("Can't resume SCO over PCM");
+ start_stream_fd(u);
} else {
if (u->service_fd < 0)
return;
+ stop_stream_fd(u);
+
pa_log_debug("Closing SCO over PCM");
pa_close(u->service_fd);
u->service_fd = -1;
@@ -1628,15 +1631,19 @@ static int start_thread(struct userdata *u) {
pa_assert(!u->rtpoll);
pa_assert(!u->rtpoll_item);
+ u->rtpoll = pa_rtpoll_new();
+ pa_thread_mq_init(&u->thread_mq, u->core->mainloop, u->rtpoll);
+
if (USE_SCO_OVER_PCM(u)) {
+ if (start_stream_fd(u) < 0)
+ return -1;
+
pa_sink_ref(u->sink);
pa_source_ref(u->source);
+ /* FIXME: monitor stream_fd error */
return 0;
}
- u->rtpoll = pa_rtpoll_new();
- pa_thread_mq_init(&u->thread_mq, u->core->mainloop, u->rtpoll);
-
if (!(u->thread = pa_thread_new(thread_func, u))) {
pa_log_error("Failed to create IO thread");
stop_thread(u);