]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
audio: fix size calculation in AUD_get_buffer_size_out()
authorVolker Rümelin <vr_qemu@t-online.de>
Thu, 15 May 2025 05:44:25 +0000 (07:44 +0200)
committerMarc-André Lureau <marcandre.lureau@redhat.com>
Sun, 25 May 2025 09:28:28 +0000 (11:28 +0200)
The buffer size calculated by AUD_get_buffer_size_out() is often
incorrect. sw->hw->samples * sw->hw->info.bytes_per_frame is the
size of the mixing engine buffer in audio frames multiplied by
the size of one frame of the audio backend. Due to resampling or
format conversion, the size of the frontend buffer can differ
significantly.

Return the correct buffer size when the mixing engine is used.

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Volker Rümelin <vr_qemu@t-online.de>
Message-Id: <20250515054429.7385-3-vr_qemu@t-online.de>

audio/audio.c

index 70ef22b1a4787e32bd3a45bc693513ea99973a0b..3f5baf0cc65601e6f0d76ec01034ed63829a3a59 100644 (file)
@@ -909,6 +909,10 @@ int AUD_get_buffer_size_out(SWVoiceOut *sw)
         return 0;
     }
 
+    if (audio_get_pdo_out(sw->s->dev)->mixing_engine) {
+        return sw->resample_buf.size * sw->info.bytes_per_frame;
+    }
+
     return sw->hw->samples * sw->hw->info.bytes_per_frame;
 }