bluez5-device: Update the port latency offset according to the delay change 46/240946/1
authorSangchul Lee <sc11.lee@samsung.com>
Thu, 13 Aug 2020 04:06:32 +0000 (13:06 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Thu, 13 Aug 2020 05:23:14 +0000 (14:23 +0900)
This patch applies the delay to the sink of the device. It will affect
the current latency of the sink.

[Version] 13.0-13
[Issue Type] New feature

Change-Id: I33dcc030876236d66bd074a5789f79febe0626ea
Signed-off-by: Sangchul Lee <sc11.lee@samsung.com>
packaging/pulseaudio.spec
src/modules/bluetooth/module-bluez5-device.c

index f9777d7..02f4bbe 100644 (file)
@@ -3,7 +3,7 @@
 Name:             pulseaudio
 Summary:          Improved Linux sound server
 Version:          13.0
-Release:          12
+Release:          13
 Group:            Multimedia/Audio
 License:          LGPL-2.1
 URL:              http://pulseaudio.org
index 393989d..01ec67f 100644 (file)
@@ -142,6 +142,7 @@ struct userdata {
     pa_hook_slot *device_connection_changed_slot;
     pa_hook_slot *transport_state_changed_slot;
 #ifdef __TIZEN_BT__
+    pa_hook_slot *transport_delay_changed_slot;
     pa_hook_slot *sco_state_changed_slot;
 #endif
     pa_hook_slot *transport_speaker_gain_changed_slot;
@@ -1854,6 +1855,10 @@ static int add_sink(struct userdata *u) {
         pa_sink_set_set_volume_callback(u->sink, sink_set_volume_cb);
         u->sink->n_volume_steps = 16;
     }
+#ifdef __TIZEN__
+    pa_device_port_set_latency_offset(u->sink->active_port, u->transport->delay);
+    pa_log_info("transport[%s], sink[%s], delay[%" PRIu64 "us]", u->transport->path, u->sink->name, u->transport->delay);
+#endif
     return 0;
 }
 
@@ -3187,6 +3192,19 @@ static pa_hook_result_t sco_state_changed_cb(pa_bluetooth_discovery *y, pa_bluet
 
     return PA_HOOK_OK;
 }
+
+/* Run from main thread */
+static pa_hook_result_t transport_delay_changed_cb(pa_bluetooth_discovery *y, pa_bluetooth_transport *t, struct userdata *u) {
+    pa_assert(t);
+    pa_assert(u);
+
+    if (t == u->transport && t->device == u->device && u->sink) {
+        pa_device_port_set_latency_offset(u->sink->active_port, u->transport->delay);
+        pa_log_info("transport[%s], sink[%s], delay[%" PRIu64 "us]", u->transport->path, u->sink->name, u->transport->delay);
+    }
+
+    return PA_HOOK_OK;
+}
 #endif
 
 
@@ -3421,6 +3439,10 @@ int pa__init(pa_module* m) {
         pa_hook_connect(pa_bluetooth_discovery_hook(u->discovery, PA_BLUETOOTH_HOOK_TRANSPORT_MICROPHONE_GAIN_CHANGED), PA_HOOK_NORMAL, (pa_hook_cb_t) transport_microphone_gain_changed_cb, u);
 
 #ifdef __TIZEN_BT__
+    u->transport_delay_changed_slot =
+        pa_hook_connect(pa_bluetooth_discovery_hook(u->discovery, PA_BLUETOOTH_HOOK_TRANSPORT_DELAY_CHANGED),
+                        PA_HOOK_NORMAL, (pa_hook_cb_t) transport_delay_changed_cb, u);
+
     u->sco_state_changed_slot =
         pa_hook_connect(pa_bluetooth_discovery_hook(u->discovery, PA_BLUETOOTH_HOOK_SCO_STATE_CHANGED),
                         PA_HOOK_NORMAL, (pa_hook_cb_t) sco_state_changed_cb, u);
@@ -3500,6 +3522,9 @@ void pa__done(pa_module *m) {
         pa_hook_slot_free(u->transport_speaker_gain_changed_slot);
 
 #ifdef __TIZEN_BT__
+    if (u->transport_delay_changed_slot)
+        pa_hook_slot_free(u->transport_delay_changed_slot);
+
     if (u->sco_state_changed_slot)
         pa_hook_slot_free(u->sco_state_changed_slot);
 #endif