mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-04 13:29:59 -05:00
bluetooth: fix resume error handling
When resuming a sink or source, pa_sink/source_process_msg() should be called only if resuming is successful. pa_sink/source_process_msg() updates thread_info.state and notifies streams about the new state, but if resuming fails, there's no state change.
This commit is contained in:
parent
64eef3cf29
commit
f6fe411b32
2 changed files with 14 additions and 26 deletions
|
|
@ -380,8 +380,6 @@ static int bt_transport_acquire(struct userdata *u, bool optional) {
|
||||||
/* Run from IO thread */
|
/* Run from IO thread */
|
||||||
static int sink_process_msg(pa_msgobject *o, int code, void *data, int64_t offset, pa_memchunk *chunk) {
|
static int sink_process_msg(pa_msgobject *o, int code, void *data, int64_t offset, pa_memchunk *chunk) {
|
||||||
struct userdata *u = PA_SINK(o)->userdata;
|
struct userdata *u = PA_SINK(o)->userdata;
|
||||||
bool failed = false;
|
|
||||||
int r;
|
|
||||||
|
|
||||||
pa_assert(u->sink == PA_SINK(o));
|
pa_assert(u->sink == PA_SINK(o));
|
||||||
pa_assert(u->transport);
|
pa_assert(u->transport);
|
||||||
|
|
@ -414,7 +412,7 @@ static int sink_process_msg(pa_msgobject *o, int code, void *data, int64_t offse
|
||||||
/* Resume the device if the source was suspended as well */
|
/* Resume the device if the source was suspended as well */
|
||||||
if (!u->source || !PA_SOURCE_IS_OPENED(u->source->thread_info.state)) {
|
if (!u->source || !PA_SOURCE_IS_OPENED(u->source->thread_info.state)) {
|
||||||
if (bt_transport_acquire(u, false) < 0)
|
if (bt_transport_acquire(u, false) < 0)
|
||||||
failed = true;
|
return -1;
|
||||||
else
|
else
|
||||||
setup_stream(u);
|
setup_stream(u);
|
||||||
}
|
}
|
||||||
|
|
@ -450,16 +448,12 @@ static int sink_process_msg(pa_msgobject *o, int code, void *data, int64_t offse
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
r = pa_sink_process_msg(o, code, data, offset, chunk);
|
return pa_sink_process_msg(o, code, data, offset, chunk);
|
||||||
|
|
||||||
return (r < 0 || !failed) ? r : -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Run from IO thread */
|
/* Run from IO thread */
|
||||||
static int source_process_msg(pa_msgobject *o, int code, void *data, int64_t offset, pa_memchunk *chunk) {
|
static int source_process_msg(pa_msgobject *o, int code, void *data, int64_t offset, pa_memchunk *chunk) {
|
||||||
struct userdata *u = PA_SOURCE(o)->userdata;
|
struct userdata *u = PA_SOURCE(o)->userdata;
|
||||||
bool failed = false;
|
|
||||||
int r;
|
|
||||||
|
|
||||||
pa_assert(u->source == PA_SOURCE(o));
|
pa_assert(u->source == PA_SOURCE(o));
|
||||||
pa_assert(u->transport);
|
pa_assert(u->transport);
|
||||||
|
|
@ -491,7 +485,7 @@ static int source_process_msg(pa_msgobject *o, int code, void *data, int64_t off
|
||||||
/* Resume the device if the sink was suspended as well */
|
/* Resume the device if the sink was suspended as well */
|
||||||
if (!u->sink || !PA_SINK_IS_OPENED(u->sink->thread_info.state)) {
|
if (!u->sink || !PA_SINK_IS_OPENED(u->sink->thread_info.state)) {
|
||||||
if (bt_transport_acquire(u, false) < 0)
|
if (bt_transport_acquire(u, false) < 0)
|
||||||
failed = true;
|
return -1;
|
||||||
else
|
else
|
||||||
setup_stream(u);
|
setup_stream(u);
|
||||||
}
|
}
|
||||||
|
|
@ -522,9 +516,7 @@ static int source_process_msg(pa_msgobject *o, int code, void *data, int64_t off
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
r = pa_source_process_msg(o, code, data, offset, chunk);
|
return pa_source_process_msg(o, code, data, offset, chunk);
|
||||||
|
|
||||||
return (r < 0 || !failed) ? r : -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Called from main thread context */
|
/* Called from main thread context */
|
||||||
|
|
|
||||||
|
|
@ -885,8 +885,6 @@ static bool setup_transport_and_stream(struct userdata *u) {
|
||||||
/* Run from IO thread */
|
/* Run from IO thread */
|
||||||
static int source_process_msg(pa_msgobject *o, int code, void *data, int64_t offset, pa_memchunk *chunk) {
|
static int source_process_msg(pa_msgobject *o, int code, void *data, int64_t offset, pa_memchunk *chunk) {
|
||||||
struct userdata *u = PA_SOURCE(o)->userdata;
|
struct userdata *u = PA_SOURCE(o)->userdata;
|
||||||
bool failed = false;
|
|
||||||
int r;
|
|
||||||
|
|
||||||
pa_assert(u->source == PA_SOURCE(o));
|
pa_assert(u->source == PA_SOURCE(o));
|
||||||
pa_assert(u->transport);
|
pa_assert(u->transport);
|
||||||
|
|
@ -917,8 +915,10 @@ static int source_process_msg(pa_msgobject *o, int code, void *data, int64_t off
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* Resume the device if the sink was suspended as well */
|
/* Resume the device if the sink was suspended as well */
|
||||||
if (!u->sink || !PA_SINK_IS_OPENED(u->sink->thread_info.state))
|
if (!u->sink || !PA_SINK_IS_OPENED(u->sink->thread_info.state)) {
|
||||||
failed = !setup_transport_and_stream(u);
|
if (!setup_transport_and_stream(u))
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
/* We don't resume the smoother here. Instead we
|
/* We don't resume the smoother here. Instead we
|
||||||
* wait until the first packet arrives */
|
* wait until the first packet arrives */
|
||||||
|
|
@ -953,9 +953,7 @@ static int source_process_msg(pa_msgobject *o, int code, void *data, int64_t off
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
r = pa_source_process_msg(o, code, data, offset, chunk);
|
return pa_source_process_msg(o, code, data, offset, chunk);
|
||||||
|
|
||||||
return (r < 0 || !failed) ? r : -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Run from main thread */
|
/* Run from main thread */
|
||||||
|
|
@ -1057,8 +1055,6 @@ static int add_source(struct userdata *u) {
|
||||||
/* Run from IO thread */
|
/* Run from IO thread */
|
||||||
static int sink_process_msg(pa_msgobject *o, int code, void *data, int64_t offset, pa_memchunk *chunk) {
|
static int sink_process_msg(pa_msgobject *o, int code, void *data, int64_t offset, pa_memchunk *chunk) {
|
||||||
struct userdata *u = PA_SINK(o)->userdata;
|
struct userdata *u = PA_SINK(o)->userdata;
|
||||||
bool failed = false;
|
|
||||||
int r;
|
|
||||||
|
|
||||||
pa_assert(u->sink == PA_SINK(o));
|
pa_assert(u->sink == PA_SINK(o));
|
||||||
pa_assert(u->transport);
|
pa_assert(u->transport);
|
||||||
|
|
@ -1089,8 +1085,10 @@ static int sink_process_msg(pa_msgobject *o, int code, void *data, int64_t offse
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* Resume the device if the source was suspended as well */
|
/* Resume the device if the source was suspended as well */
|
||||||
if (!u->source || !PA_SOURCE_IS_OPENED(u->source->thread_info.state))
|
if (!u->source || !PA_SOURCE_IS_OPENED(u->source->thread_info.state)) {
|
||||||
failed = !setup_transport_and_stream(u);
|
if (!setup_transport_and_stream(u))
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
@ -1123,9 +1121,7 @@ static int sink_process_msg(pa_msgobject *o, int code, void *data, int64_t offse
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
r = pa_sink_process_msg(o, code, data, offset, chunk);
|
return pa_sink_process_msg(o, code, data, offset, chunk);
|
||||||
|
|
||||||
return (r < 0 || !failed) ? r : -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Run from main thread */
|
/* Run from main thread */
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue