From: Marc-André Lureau <marcandre.lureau@redhat.com>
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.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
audio/audio_int.h | 1 -
audio/audio.c | 5 ++---
2 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/audio/audio_int.h b/audio/audio_int.h
index 20b4c87b0b6..25de0e3f9cf 100644
--- a/audio/audio_int.h
+++ b/audio/audio_int.h
@@ -252,7 +252,6 @@ typedef struct AudioBackend {
QLIST_HEAD (cap_listhead, CaptureVoiceOut) cap_head;
int nb_hw_voices_out;
int nb_hw_voices_in;
- int vm_running;
int64_t period_ticks;
bool timer_running;
diff --git a/audio/audio.c b/audio/audio.c
index 80e4ba83712..5b9d352f325 100644
--- a/audio/audio.c
+++ b/audio/audio.c
@@ -932,7 +932,7 @@ void AUD_set_active_out(SWVoiceOut *sw, bool on)
hw->pending_disable = 0;
if (!hw->enabled) {
hw->enabled = true;
- if (s->vm_running) {
+ if (runstate_is_running()) {
if (hw->pcm_ops->enable_out) {
hw->pcm_ops->enable_out(hw, true);
}
@@ -978,7 +978,7 @@ void AUD_set_active_in(SWVoiceIn *sw, bool on)
if (on) {
if (!hw->enabled) {
hw->enabled = true;
- if (s->vm_running) {
+ if (runstate_is_running()) {
if (hw->pcm_ops->enable_in) {
hw->pcm_ops->enable_in(hw, true);
}
@@ -1597,7 +1597,6 @@ static void audio_vm_change_state_handler (void *opaque, bool running,
HWVoiceOut *hwo = NULL;
HWVoiceIn *hwi = NULL;
- s->vm_running = running;
while ((hwo = audio_pcm_hw_find_any_enabled_out(s, hwo))) {
if (hwo->pcm_ops->enable_out) {
hwo->pcm_ops->enable_out(hwo, running);
--
2.52.0