[pulseaudio-discuss] [PATCH] bluez5-device: Set transport state correctly for AG role
Georg Chini
georg at chini.tk
Thu May 11 13:54:43 UTC 2017
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.
---
src/modules/bluetooth/module-bluez5-device.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/src/modules/bluetooth/module-bluez5-device.c b/src/modules/bluetooth/module-bluez5-device.c
index 867def74..3ec83198 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
};
@@ -755,9 +756,18 @@ static int transport_acquire(struct userdata *u, bool optional) {
if (u->stream_fd < 0)
return u->stream_fd;
+ /* 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;
}
@@ -2210,6 +2220,9 @@ 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:
+ pa_bluetooth_transport_set_state(u->transport, PA_BLUETOOTH_TRANSPORT_STATE_PLAYING);
+ break;
}
return 0;
--
2.11.0
More information about the pulseaudio-discuss
mailing list