From b88084fa57f80ebd5baa762e224b181dc1ec1636 Mon Sep 17 00:00:00 2001 From: caszuu <109808097+caszuu@users.noreply.github.com> Date: Thu, 8 Aug 2024 22:41:07 +0200 Subject: [PATCH] fix audio thread exiting before reconnect --- server/audio/audio_pulse.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/server/audio/audio_pulse.cpp b/server/audio/audio_pulse.cpp index e1ffbf29..aa53f0fe 100644 --- a/server/audio/audio_pulse.cpp +++ b/server/audio/audio_pulse.cpp @@ -337,7 +337,16 @@ struct pulse_device : public audio_device size -= remainder; // size of data to send packet.payload = std::span(buffer.begin(), size); packet.timestamp = session.get_offset().to_headset(os_monotonic_get_ns()); - session.send_stream(packet); + + try + { + session.send_control(packet); + } + catch (std::exception & e) + { + U_LOG_D("Failed to send audio data: %s", e.what()); + } + // put the remaining data at the beginning of the buffer memmove(buffer.data(), buffer.data() + size, remainder); }