Skip to content

Commit 73c1527

Browse files
pm215mdroth
authored andcommitted
audio: Don't free hw resources until after hw backend is stopped
When stopping an audio voice, call the audio backend's fini method before calling audio_pcm_hw_free_resources_ rather than afterwards. This allows backends which use helper threads (like pulseaudio) to terminate those threads before the conv_buf or mix_buf are freed and avoids race conditions where the helper may access a NULL pointer or freed memory. Cc: [email protected] Reviewed-by: Gerd Hoffmann <[email protected]> Signed-off-by: Peter Maydell <[email protected]> Message-id: [email protected] (cherry picked from commit b28fb27) Signed-off-by: Michael Roth <[email protected]>
1 parent b466e17 commit 73c1527

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

audio/audio_template.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,9 +191,9 @@ static void glue (audio_pcm_hw_gc_, TYPE) (HW **hwp)
191191
audio_detach_capture (hw);
192192
#endif
193193
QLIST_REMOVE (hw, entries);
194+
glue (hw->pcm_ops->fini_, TYPE) (hw);
194195
glue (s->nb_hw_voices_, TYPE) += 1;
195196
glue (audio_pcm_hw_free_resources_ ,TYPE) (hw);
196-
glue (hw->pcm_ops->fini_, TYPE) (hw);
197197
g_free (hw);
198198
*hwp = NULL;
199199
}

0 commit comments

Comments
 (0)