diff options
author | Marc-André Lureau <marcandre.lureau@gmail.com> | 2009-02-09 22:11:46 +0200 |
---|---|---|
committer | Marc-André Lureau <marcandre.lureau@gmail.com> | 2009-02-09 22:13:46 +0200 |
commit | b35ae7f53116949d0cf5d991883e3b54f2c48aa5 (patch) | |
tree | fe62d1ae3d12b14d42a0110c2ccd6c554148915a /src/modules/bluetooth | |
parent | 539abc365f8e12a5241694920a2e09e0bfe05710 (diff) |
bluetooth: reconnect to audio service when switching profile
Currently, Bluez audio service crash when reusing the same control
socket to switch to different profiles. This typically happen when
first switching from HSP to A2DP on dual headsets.
Diffstat (limited to 'src/modules/bluetooth')
-rw-r--r-- | src/modules/bluetooth/module-bluetooth-device.c | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/src/modules/bluetooth/module-bluetooth-device.c b/src/modules/bluetooth/module-bluetooth-device.c index de6bded2..0067d91d 100644 --- a/src/modules/bluetooth/module-bluetooth-device.c +++ b/src/modules/bluetooth/module-bluetooth-device.c @@ -1282,6 +1282,19 @@ static int add_source(struct userdata *u) { static int init_bt(struct userdata *u) { pa_assert(u); + /* shutdown bt */ + if (u->stream_fd >= 0) { + pa_close(u->stream_fd); + u->stream_fd = -1; + } + + if (u->service_fd >= 0) { + pa_close(u->service_fd); + u->service_fd = -1; + } + + u->write_type = u->read_type = 0; + /* connect to the bluez audio service */ if ((u->service_fd = bt_audio_service_open()) < 0) { pa_log_error("Couldn't connect to bluetooth audio service"); @@ -1292,17 +1305,6 @@ static int init_bt(struct userdata *u) { return 0; } -static void shutdown_bt(struct userdata *u) { - pa_assert(u); - - if (u->stream_fd <= 0) { - pa_close(u->stream_fd); - u->stream_fd = -1; - } - - u->write_type = u->read_type = 0; -} - static int setup_bt(struct userdata *u) { pa_assert(u); @@ -1417,7 +1419,7 @@ static int card_set_profile(pa_card *c, pa_card_profile *new_profile) { } stop_thread(u); - shutdown_bt(u); + init_bt(u); if (u->write_memchunk.memblock) { pa_memblock_unref(u->write_memchunk.memblock); |