bluetooth: Call setup_stream() manually

Do not call setup_stream() automatically inside bt_transport_acquire().
Instead, the caller is responsible to use both functions as necessary.

As a first trivial step, setup_stream() is now called manually after
all calls to bt_transport_acquire(u, TRUE), with the exception of
setup_transport() where the thread is still about to start and thus
setup_stream() will be called later on from thread_func().
This commit is contained in:
Mikel Astiz 2012-12-14 15:14:39 +01:00 committed by Tanu Kaskinen
parent 0fc6aa5034
commit 04d60ae2a0

View file

@ -354,11 +354,8 @@ static void bt_transport_release(struct userdata *u) {
static int bt_transport_acquire(struct userdata *u, pa_bool_t start) { static int bt_transport_acquire(struct userdata *u, pa_bool_t start) {
pa_assert(u->transport); pa_assert(u->transport);
if (u->transport_acquired) { if (u->transport_acquired)
if (start)
goto done;
return 0; return 0;
}
pa_log_debug("Acquiring transport %s", u->transport->path); pa_log_debug("Acquiring transport %s", u->transport->path);
@ -375,16 +372,6 @@ static int bt_transport_acquire(struct userdata *u, pa_bool_t start) {
u->transport_acquired = true; u->transport_acquired = true;
pa_log_info("Transport %s acquired: fd %d", u->transport->path, u->stream_fd); pa_log_info("Transport %s acquired: fd %d", u->transport->path, u->stream_fd);
if (!start)
return 0;
done:
/* If thread is still about to start, the stream will be set up in the beginning of thread_func() */
if (u->thread == NULL)
return 0;
setup_stream(u);
return 0; return 0;
} }
@ -426,6 +413,8 @@ static int sink_process_msg(pa_msgobject *o, int code, void *data, int64_t offse
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, TRUE) < 0) if (bt_transport_acquire(u, TRUE) < 0)
failed = TRUE; failed = TRUE;
else
setup_stream(u);
} }
break; break;
@ -501,6 +490,8 @@ static int source_process_msg(pa_msgobject *o, int code, void *data, int64_t off
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, TRUE) < 0) if (bt_transport_acquire(u, TRUE) < 0)
failed = TRUE; failed = TRUE;
else
setup_stream(u);
} }
/* 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 */
@ -1425,7 +1416,12 @@ static int sco_over_pcm_state_update(struct userdata *u, pa_bool_t changed) {
return -1; return -1;
} }
return bt_transport_acquire(u, TRUE); if (bt_transport_acquire(u, TRUE) < 0)
return -1;
setup_stream(u);
return 0;
} }
if (changed) { if (changed) {