From 33e97fa5d72bf0e991f462205e28cdeac746bc4a Mon Sep 17 00:00:00 2001 From: Zaggy1024 Date: Thu, 4 Sep 2025 12:11:33 -0500 Subject: [PATCH] LibMedia: Note that PlaybackStream callbacks cannot run simultaneously This is a requirement of implementations of PlaybackStream, so we should have a little comment about it. Otherwise, we may encounter data races later. --- Libraries/LibMedia/Audio/PlaybackStream.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Libraries/LibMedia/Audio/PlaybackStream.h b/Libraries/LibMedia/Audio/PlaybackStream.h index 0419ed171f1..d84a253a0cf 100644 --- a/Libraries/LibMedia/Audio/PlaybackStream.h +++ b/Libraries/LibMedia/Audio/PlaybackStream.h @@ -34,8 +34,9 @@ public: // // The initial_output_state parameter determines whether it will begin playback immediately. // - // The AudioDataRequestCallback will be called when the Output needs more audio data to fill - // its buffers and continue playback. + // The AudioDataRequestCallback will be called when the Output needs more audio data to fill its buffers and + // continue playback. This callback will only be allowed to run on one thread at a time, to prevent any data + // race on the resource used by the callback. static ErrorOr> create(OutputState initial_output_state, u32 sample_rate, u8 channels, u32 target_latency_ms, AudioDataRequestCallback&&); virtual ~PlaybackStream() = default;