Commit 978dd63540b380768a03be400e703f6e67f47e8f

Authored by malc
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
audio/audio.c
... ... @@ -1127,6 +1127,7 @@ void AUD_set_active_out (SWVoiceOut *sw, int on)
1127 1127  
1128 1128 hw = sw->hw;
1129 1129 if (sw->active != on) {
  1130 + AudioState *s = &glob_audio_state;
1130 1131 SWVoiceOut *temp_sw;
1131 1132 SWVoiceCap *sc;
1132 1133  
... ... @@ -1134,7 +1135,9 @@ void AUD_set_active_out (SWVoiceOut *sw, int on)
1134 1135 hw->pending_disable = 0;
1135 1136 if (!hw->enabled) {
1136 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 1143 else {
... ... @@ -1170,12 +1173,15 @@ void AUD_set_active_in (SWVoiceIn *sw, int on)
1170 1173  
1171 1174 hw = sw->hw;
1172 1175 if (sw->active != on) {
  1176 + AudioState *s = &glob_audio_state;
1173 1177 SWVoiceIn *temp_sw;
1174 1178  
1175 1179 if (on) {
1176 1180 if (!hw->enabled) {
1177 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 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 1629 HWVoiceIn *hwi = NULL;
1624 1630 int op = running ? VOICE_ENABLE : VOICE_DISABLE;
1625 1631  
  1632 + s->vm_running = running;
1626 1633 while ((hwo = audio_pcm_hw_find_any_enabled_out (s, hwo))) {
1627 1634 hwo->pcm_ops->ctl_out (hwo, op);
1628 1635 }
... ...
audio/audio_int.h
... ... @@ -192,6 +192,7 @@ struct AudioState {
192 192 LIST_HEAD (cap_listhead, CaptureVoiceOut) cap_head;
193 193 int nb_hw_voices_out;
194 194 int nb_hw_voices_in;
  195 + int vm_running;
195 196 };
196 197  
197 198 extern struct audio_driver no_audio_driver;
... ...