Commit 978dd63540b380768a03be400e703f6e67f47e8f
1 parent
c6ba7bbc
Avoid running audio ctl's when vm is not running
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6627 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
2 changed files
with
10 additions
and
2 deletions
audio/audio.c
@@ -1127,6 +1127,7 @@ void AUD_set_active_out (SWVoiceOut *sw, int on) | @@ -1127,6 +1127,7 @@ void AUD_set_active_out (SWVoiceOut *sw, int on) | ||
1127 | 1127 | ||
1128 | hw = sw->hw; | 1128 | hw = sw->hw; |
1129 | if (sw->active != on) { | 1129 | if (sw->active != on) { |
1130 | + AudioState *s = &glob_audio_state; | ||
1130 | SWVoiceOut *temp_sw; | 1131 | SWVoiceOut *temp_sw; |
1131 | SWVoiceCap *sc; | 1132 | SWVoiceCap *sc; |
1132 | 1133 | ||
@@ -1134,7 +1135,9 @@ void AUD_set_active_out (SWVoiceOut *sw, int on) | @@ -1134,7 +1135,9 @@ void AUD_set_active_out (SWVoiceOut *sw, int on) | ||
1134 | hw->pending_disable = 0; | 1135 | hw->pending_disable = 0; |
1135 | if (!hw->enabled) { | 1136 | if (!hw->enabled) { |
1136 | hw->enabled = 1; | 1137 | hw->enabled = 1; |
1137 | - hw->pcm_ops->ctl_out (hw, VOICE_ENABLE); | 1138 | + if (s->vm_running) { |
1139 | + hw->pcm_ops->ctl_out (hw, VOICE_ENABLE); | ||
1140 | + } | ||
1138 | } | 1141 | } |
1139 | } | 1142 | } |
1140 | else { | 1143 | else { |
@@ -1170,12 +1173,15 @@ void AUD_set_active_in (SWVoiceIn *sw, int on) | @@ -1170,12 +1173,15 @@ void AUD_set_active_in (SWVoiceIn *sw, int on) | ||
1170 | 1173 | ||
1171 | hw = sw->hw; | 1174 | hw = sw->hw; |
1172 | if (sw->active != on) { | 1175 | if (sw->active != on) { |
1176 | + AudioState *s = &glob_audio_state; | ||
1173 | SWVoiceIn *temp_sw; | 1177 | SWVoiceIn *temp_sw; |
1174 | 1178 | ||
1175 | if (on) { | 1179 | if (on) { |
1176 | if (!hw->enabled) { | 1180 | if (!hw->enabled) { |
1177 | hw->enabled = 1; | 1181 | hw->enabled = 1; |
1178 | - hw->pcm_ops->ctl_in (hw, VOICE_ENABLE); | 1182 | + if (s->vm_running) { |
1183 | + hw->pcm_ops->ctl_in (hw, VOICE_ENABLE); | ||
1184 | + } | ||
1179 | } | 1185 | } |
1180 | sw->total_hw_samples_acquired = hw->total_samples_captured; | 1186 | sw->total_hw_samples_acquired = hw->total_samples_captured; |
1181 | } | 1187 | } |
@@ -1623,6 +1629,7 @@ static void audio_vm_change_state_handler (void *opaque, int running, | @@ -1623,6 +1629,7 @@ static void audio_vm_change_state_handler (void *opaque, int running, | ||
1623 | HWVoiceIn *hwi = NULL; | 1629 | HWVoiceIn *hwi = NULL; |
1624 | int op = running ? VOICE_ENABLE : VOICE_DISABLE; | 1630 | int op = running ? VOICE_ENABLE : VOICE_DISABLE; |
1625 | 1631 | ||
1632 | + s->vm_running = running; | ||
1626 | while ((hwo = audio_pcm_hw_find_any_enabled_out (s, hwo))) { | 1633 | while ((hwo = audio_pcm_hw_find_any_enabled_out (s, hwo))) { |
1627 | hwo->pcm_ops->ctl_out (hwo, op); | 1634 | hwo->pcm_ops->ctl_out (hwo, op); |
1628 | } | 1635 | } |
audio/audio_int.h
@@ -192,6 +192,7 @@ struct AudioState { | @@ -192,6 +192,7 @@ struct AudioState { | ||
192 | LIST_HEAD (cap_listhead, CaptureVoiceOut) cap_head; | 192 | LIST_HEAD (cap_listhead, CaptureVoiceOut) cap_head; |
193 | int nb_hw_voices_out; | 193 | int nb_hw_voices_out; |
194 | int nb_hw_voices_in; | 194 | int nb_hw_voices_in; |
195 | + int vm_running; | ||
195 | }; | 196 | }; |
196 | 197 | ||
197 | extern struct audio_driver no_audio_driver; | 198 | extern struct audio_driver no_audio_driver; |