@samitouri / QOSamiQemu / commits / 67af2055d8

audio: replace vm_running with runstate_is_running()

AudioBackend had a vm_running field which was set in audio_vm_change_state_handler(). The state change handler "bool running" argument is true when vm_prepare_start() calls it, and the VM runstate is either SUSPENDED or RUNNING. Audio hw voices shouldn't be running when the VM is suspended, but only when running. Thus replacing the vm_running field with a call to runstate_is_running() is both simpler and more correct. Reviewed-by: Mark Cave-Ayland <mark.caveayland@nutanix.com> Reviewed-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>

Marc-André Lureau committed Jan 19, 2026 at 15:08 UTC 67af2055d85fd5f219c14cedf939e41ecc23c567
2 files changed +2 -4
audio/audio.c
+2 -3
@@ -933,7 +933,7 @@ void AUD_set_active_out(SWVoiceOut *sw, bool on)
933 hw->pending_disable = 0;
934 if (!hw->enabled) {
935 hw->enabled = true;
936 - if (s->vm_running) {
936 + if (runstate_is_running()) {
937 if (hw->pcm_ops->enable_out) {
938 hw->pcm_ops->enable_out(hw, true);
939 }
@@ -979,7 +979,7 @@ void AUD_set_active_in(SWVoiceIn *sw, bool on)
979 if (on) {
980 if (!hw->enabled) {
981 hw->enabled = true;
982 - if (s->vm_running) {
982 + if (runstate_is_running()) {
983 if (hw->pcm_ops->enable_in) {
984 hw->pcm_ops->enable_in(hw, true);
985 }
@@ -1598,7 +1598,6 @@ static void audio_vm_change_state_handler (void *opaque, bool running,
1598 HWVoiceOut *hwo = NULL;
1599 HWVoiceIn *hwi = NULL;
1600
1601 - s->vm_running = running;
1601 while ((hwo = audio_pcm_hw_find_any_enabled_out(s, hwo))) {
1602 if (hwo->pcm_ops->enable_out) {
1603 hwo->pcm_ops->enable_out(hwo, running);
audio/audio_int.h
-1
@@ -252,7 +252,6 @@ typedef struct AudioBackend {
252 QLIST_HEAD (cap_listhead, CaptureVoiceOut) cap_head;
253 int nb_hw_voices_out;
254 int nb_hw_voices_in;
255 - int vm_running;
255 int64_t period_ticks;
256
257 bool timer_running;