diff -Nru pulseaudio-15.99.1+dfsg1/debian/changelog pulseaudio-15.99.1+dfsg1/debian/changelog --- pulseaudio-15.99.1+dfsg1/debian/changelog 2022-09-07 14:09:58.000000000 +0000 +++ pulseaudio-15.99.1+dfsg1/debian/changelog 2023-02-16 02:19:55.000000000 +0000 @@ -1,3 +1,11 @@ +pulseaudio (1:15.99.1+dfsg1-1ubuntu2.1) jammy; urgency=medium + + [ Kai-Heng Feng ] + * d/p/0018-bluetooth-Amend-writeout-to-send-more-initial-frames.patch + (LP: #2007331) + + -- Kai-Heng Feng Thu, 16 Feb 2023 10:19:55 +0800 + pulseaudio (1:15.99.1+dfsg1-1ubuntu2) jammy; urgency=medium * debian/patches/git_sbc_limit.patch, debian/patches/git_sbc_frame.patch: diff -Nru pulseaudio-15.99.1+dfsg1/debian/patches/0018-bluetooth-Amend-writeout-to-send-more-initial-frames.patch pulseaudio-15.99.1+dfsg1/debian/patches/0018-bluetooth-Amend-writeout-to-send-more-initial-frames.patch --- pulseaudio-15.99.1+dfsg1/debian/patches/0018-bluetooth-Amend-writeout-to-send-more-initial-frames.patch 1970-01-01 00:00:00.000000000 +0000 +++ pulseaudio-15.99.1+dfsg1/debian/patches/0018-bluetooth-Amend-writeout-to-send-more-initial-frames.patch 2023-02-16 02:19:55.000000000 +0000 @@ -0,0 +1,51 @@ +From: "Igor V. Kovalenko" +Date: Mon, 6 Feb 2023 09:38:45 +0300 +Subject: bluetooth: Amend writeout to send more initial frames + +When bluetooth transport has both both sink and source, pulseaudio would +synchronize writing out frames with reading frames from peer to make fair +schedule of reads and writes. Pulseaudio allows two blocks of data to be sent to +peer before synchronizing writes with reads just in case that peer implements +similar write schedule. + +It could happen that first blocks are still missed by peer, which would cause +pulseaudio writes to stall waiting for first frames from peer. + +Fix this by allowing more data frames out until data from peer is actually +received. + +Closes: https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/issues/1424 +Part-of: +Signed-off-by: Kai-Heng Feng +--- + src/modules/bluetooth/module-bluez5-device.c | 10 ++++++++-- + 1 file changed, 8 insertions(+), 2 deletions(-) + +diff --git a/src/modules/bluetooth/module-bluez5-device.c b/src/modules/bluetooth/module-bluez5-device.c +index 767482e..a30372e 100644 +--- a/src/modules/bluetooth/module-bluez5-device.c ++++ b/src/modules/bluetooth/module-bluez5-device.c +@@ -1523,8 +1523,8 @@ static void thread_func(void *userdata) { + writable = true; + + /* If we have a source, we let the source determine the timing +- * for the sink */ +- if (have_source) { ++ * for the sink unless peer has not sent any data yet */ ++ if (have_source && u->read_index > 0) { + + /* If the stream is writable, send some data if necessary */ + if (writable) { +@@ -1635,6 +1635,12 @@ static void thread_func(void *userdata) { + goto fail; + + if (result) { ++ if (have_source && u->read_index <= 0) { ++ /* We have a source but peer has not sent any data yet, log this */ ++ if (pa_log_ratelimit(PA_LOG_DEBUG)) ++ pa_log_debug("Still no data received from source, sent one more block to sink"); ++ } ++ + writable = false; + have_written = true; + } diff -Nru pulseaudio-15.99.1+dfsg1/debian/patches/series pulseaudio-15.99.1+dfsg1/debian/patches/series --- pulseaudio-15.99.1+dfsg1/debian/patches/series 2022-09-07 14:09:49.000000000 +0000 +++ pulseaudio-15.99.1+dfsg1/debian/patches/series 2023-02-16 02:19:55.000000000 +0000 @@ -21,3 +21,4 @@ 0702-add-snappy-policy-module.patch 0016-check_off_profile_when_switching_profile.patch 0001-card-restore-setting-preferred-ports-in-entry_from_c.patch +0018-bluetooth-Amend-writeout-to-send-more-initial-frames.patch