[pulseaudio-commits] Branch 'next' - src/modules
Tanu Kaskinen
tanuk at kemper.freedesktop.org
Thu Jul 27 19:37:55 UTC 2017
src/modules/bluetooth/module-bluez5-device.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
New commits:
commit 47d128587846c2dd4d33d56fc031e367b610ce4e
Author: Georg Chini <georg at chini.tk>
Date: Sat Jul 22 10:47:07 2017 +0200
bluez5-device: Set transport state correctly for AG role
When connecting a headset via the native backend, the transport state was
not updated correctly.
This patch sets the state to PLAYING in transport_acquire() if necessary.
diff --git a/src/modules/bluetooth/module-bluez5-device.c b/src/modules/bluetooth/module-bluez5-device.c
index ccab10ac..617aac90 100644
--- a/src/modules/bluetooth/module-bluez5-device.c
+++ b/src/modules/bluetooth/module-bluez5-device.c
@@ -77,6 +77,7 @@ static const char* const valid_modargs[] = {
enum {
BLUETOOTH_MESSAGE_IO_THREAD_FAILED,
BLUETOOTH_MESSAGE_STREAM_FD_HUP,
+ BLUETOOTH_MESSAGE_SET_TRANSPORT_PLAYING,
BLUETOOTH_MESSAGE_MAX
};
@@ -745,9 +746,18 @@ static int transport_acquire(struct userdata *u, bool optional) {
if (u->stream_fd < 0)
return -1;
+ /* transport_acquired must be set before calling
+ * pa_bluetooth_transport_set_state() */
u->transport_acquired = true;
pa_log_info("Transport %s acquired: fd %d", u->transport->path, u->stream_fd);
+ if (u->transport->state == PA_BLUETOOTH_TRANSPORT_STATE_IDLE) {
+ if (pa_thread_mq_get() != NULL)
+ pa_asyncmsgq_post(pa_thread_mq_get()->outq, PA_MSGOBJECT(u->msg), BLUETOOTH_MESSAGE_SET_TRANSPORT_PLAYING, NULL, 0, NULL, NULL);
+ else
+ pa_bluetooth_transport_set_state(u->transport, PA_BLUETOOTH_TRANSPORT_STATE_PLAYING);
+ }
+
return 0;
}
@@ -2138,6 +2148,16 @@ static int device_process_msg(pa_msgobject *obj, int code, void *data, int64_t o
if (u->transport->state > PA_BLUETOOTH_TRANSPORT_STATE_IDLE)
pa_bluetooth_transport_set_state(u->transport, PA_BLUETOOTH_TRANSPORT_STATE_IDLE);
break;
+ case BLUETOOTH_MESSAGE_SET_TRANSPORT_PLAYING:
+ /* transport_acquired needs to be checked here, because a message could have been
+ * pending when the profile was switched. If the new transport has been acquired
+ * correctly, the call below will have no effect because the transport state is
+ * already PLAYING. If transport_acquire() failed for the new profile, the transport
+ * state should not be changed. If the transport has been released for other reasons
+ * (I/O thread shutdown), transport_acquired will also be false. */
+ if (u->transport_acquired)
+ pa_bluetooth_transport_set_state(u->transport, PA_BLUETOOTH_TRANSPORT_STATE_PLAYING);
+ break;
}
return 0;
More information about the pulseaudio-commits
mailing list