From: Sangchul Lee Date: Thu, 13 Aug 2020 04:06:32 +0000 (+0900) Subject: bluez5-device: Update the port latency offset according to the delay change X-Git-Tag: accepted/tizen/unified/20200824.134510~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F46%2F240946%2F1;p=platform%2Fupstream%2Fpulseaudio.git bluez5-device: Update the port latency offset according to the delay change 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 --- diff --git a/packaging/pulseaudio.spec b/packaging/pulseaudio.spec index f9777d7..02f4bbe 100644 --- a/packaging/pulseaudio.spec +++ b/packaging/pulseaudio.spec @@ -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 diff --git a/src/modules/bluetooth/module-bluez5-device.c b/src/modules/bluetooth/module-bluez5-device.c index 393989d..01ec67f 100644 --- a/src/modules/bluetooth/module-bluez5-device.c +++ b/src/modules/bluetooth/module-bluez5-device.c @@ -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