* [Qemu-devel] [PATCH v2] audio: disable timer when idle.
@ 2010-11-18 11:11 Gerd Hoffmann
0 siblings, 0 replies; only message in thread
From: Gerd Hoffmann @ 2010-11-18 11:11 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann
This patch makes sure the audio timer gets disabled when no voice is
active by adding a call to audio_timer_reset() to the output voice
disable code path.
That alone isn't enouth though as this might be called via audio_timer()
and audio_timer() unconditionally re-arms the timer before exiting. Fix
that by adding a flag to the global audio state which is updated by
audio_timer_reset() and checked by audio_timer().
[ v2: codestyle fix, improve changelog ]
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
audio/audio.c | 7 ++++++-
audio/audio_int.h | 1 +
2 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/audio/audio.c b/audio/audio.c
index ade342e..500b142 100644
--- a/audio/audio.c
+++ b/audio/audio.c
@@ -1101,7 +1101,9 @@ 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);
+ if (s->need_timer) {
+ qemu_mod_timer (s->ts, qemu_get_clock (vm_clock) + conf.period.ticks);
+ }
}
@@ -1124,9 +1126,11 @@ static void audio_reset_timer (void)
AudioState *s = &glob_audio_state;
if (audio_is_timer_needed ()) {
+ s->need_timer = 1;
qemu_mod_timer (s->ts, qemu_get_clock (vm_clock) + 1);
}
else {
+ s->need_timer = 0;
qemu_del_timer (s->ts);
}
}
@@ -1380,6 +1384,7 @@ static void audio_run_out (AudioState *s)
sc->sw.active = 0;
audio_recalc_and_notify_capture (sc->cap);
}
+ audio_reset_timer ();
continue;
}
diff --git a/audio/audio_int.h b/audio/audio_int.h
index d66f2c3..df060a9 100644
--- a/audio/audio_int.h
+++ b/audio/audio_int.h
@@ -190,6 +190,7 @@ struct AudioState {
void *drv_opaque;
QEMUTimer *ts;
+ int need_timer;
QLIST_HEAD (card_listhead, QEMUSoundCard) card_head;
QLIST_HEAD (hw_in_listhead, HWVoiceIn) hw_head_in;
QLIST_HEAD (hw_out_listhead, HWVoiceOut) hw_head_out;
--
1.7.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2010-11-18 11:11 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-18 11:11 [Qemu-devel] [PATCH v2] audio: disable timer when idle Gerd Hoffmann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).