diff options
author | malc <av1474@comtv.ru> | 2010-11-18 14:30:12 +0300 |
---|---|---|
committer | malc <av1474@comtv.ru> | 2010-11-18 14:30:31 +0300 |
commit | 8280b501229cd12d55acb3fe1e2ca411ec543185 (patch) | |
tree | a55fb6283c022d683e0d8acc9264240a08178ce9 /audio/audio.c | |
parent | 44d39e282b3b9ed1c336a5cb6512a57418990daa (diff) | |
download | qemu-8280b501229cd12d55acb3fe1e2ca411ec543185.tar.gz qemu-8280b501229cd12d55acb3fe1e2ca411ec543185.tar.bz2 qemu-8280b501229cd12d55acb3fe1e2ca411ec543185.zip |
audio: Only use audio timer when necessary
Originally proposed by Gerd Hoffmann.
Signed-off-by: malc <av1474@comtv.ru>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Diffstat (limited to 'audio/audio.c')
-rw-r--r-- | audio/audio.c | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/audio/audio.c b/audio/audio.c index ade342e856..17074469b2 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -1096,15 +1096,6 @@ static void audio_pcm_print_info (const char *cap, struct audio_pcm_info *info) /* * Timer */ -static void audio_timer (void *opaque) -{ - AudioState *s = opaque; - - audio_run ("timer"); - qemu_mod_timer (s->ts, qemu_get_clock (vm_clock) + conf.period.ticks); -} - - static int audio_is_timer_needed (void) { HWVoiceIn *hwi = NULL; @@ -1119,10 +1110,8 @@ static int audio_is_timer_needed (void) return 0; } -static void audio_reset_timer (void) +static void audio_reset_timer (AudioState *s) { - AudioState *s = &glob_audio_state; - if (audio_is_timer_needed ()) { qemu_mod_timer (s->ts, qemu_get_clock (vm_clock) + 1); } @@ -1131,6 +1120,12 @@ static void audio_reset_timer (void) } } +static void audio_timer (void *opaque) +{ + audio_run ("timer"); + audio_reset_timer (opaque); +} + /* * Public API */ @@ -1195,7 +1190,7 @@ void AUD_set_active_out (SWVoiceOut *sw, int on) hw->enabled = 1; if (s->vm_running) { hw->pcm_ops->ctl_out (hw, VOICE_ENABLE, conf.try_poll_out); - audio_reset_timer (); + audio_reset_timer (s); } } } @@ -1240,6 +1235,7 @@ void AUD_set_active_in (SWVoiceIn *sw, int on) hw->enabled = 1; if (s->vm_running) { hw->pcm_ops->ctl_in (hw, VOICE_ENABLE, conf.try_poll_in); + audio_reset_timer (s); } } sw->total_hw_samples_acquired = hw->total_samples_captured; @@ -1761,7 +1757,7 @@ static void audio_vm_change_state_handler (void *opaque, int running, while ((hwi = audio_pcm_hw_find_any_enabled_in (hwi))) { hwi->pcm_ops->ctl_in (hwi, op, conf.try_poll_in); } - audio_reset_timer (); + audio_reset_timer (s); } static void audio_atexit (void) |