@samitouri / QOSamiQemu / commits / 924b0be88d

audio/mixeng: fix sw/hw mixup in audio_pcm_sw_init_

Commit 42061a14358 ("audio/mixeng: replace redundant pcm_info fields with AudioFormat") accidentally changed the conv/clip function selection in audio_pcm_sw_init_ to use hw->info.af (the hardware voice format) instead of sw->info.af (the software voice format). This causes audio distortion when the software and hardware voices use different formats, as the wrong conversion functions are applied to the audio data. Fix by using sw->info.af, restoring the original behavior. Fixes: 42061a14358c ("audio/mixeng: replace redundant pcm_info fields with AudioFormat") Reported-by: Dmitry Osipenko <dmitry.osipenko@collabora.com> Reviewed-by: Christian Schoenebeck <qemu_oss@crudebyte.com> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>

Marc-André Lureau committed Mar 17, 2026 at 19:02 UTC 924b0be88d5488d1e7b918e005e72cfaaaef87b6
1 file changed +3 -3
audio/audio_template.h
+3 -3
@@ -172,7 +172,7 @@ static int glue (audio_pcm_sw_init_, TYPE) (
172 sw->empty = true;
173 #endif
174
175 - if (audio_format_is_float(hw->info.af)) {
175 + if (audio_format_is_float(sw->info.af)) {
176 #ifdef DAC
177 sw->conv = mixeng_conv_float[sw->info.nchannels == 2]
178 [sw->info.swap_endianness];
@@ -187,9 +187,9 @@ static int glue (audio_pcm_sw_init_, TYPE) (
187 sw->clip = mixeng_clip
188 #endif
189 [sw->info.nchannels == 2]
190 - [audio_format_is_signed(hw->info.af)]
190 + [audio_format_is_signed(sw->info.af)]
191 [sw->info.swap_endianness]
192 - [audio_format_to_index(hw->info.af)];
192 + [audio_format_to_index(sw->info.af)];
193 }
194
195 sw->name = g_strdup (name);