mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-03 09:01:50 -05:00
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.
This commit is contained in:
parent
539abc365f
commit
b35ae7f531
1 changed files with 14 additions and 12 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue