qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Cc: malc@redhat.com, Gerd Hoffmann <kraxel@redhat.com>
Subject: [Qemu-devel] [PATCH] audio: disable timer when idle.
Date: Mon, 15 Nov 2010 13:24:24 +0100	[thread overview]
Message-ID: <1289823864-12107-1-git-send-email-kraxel@redhat.com> (raw)

This patch makes sure the audio timer gets disabled when no voice is
active.  It adds a variable to track whenever the timer is needed or
not to the global audio state.  audio_timer_reset() will set that
variable.  audio_timer() will check that variable and only re-arm
the timer when needed.  One additional call to audio_timer_reset() has
been added to the output voice disable code path.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 audio/audio.c     |    6 +++++-
 audio/audio_int.h |    1 +
 2 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/audio/audio.c b/audio/audio.c
index ade342e..9cf91ae 100644
--- a/audio/audio.c
+++ b/audio/audio.c
@@ -1101,7 +1101,8 @@ 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 +1125,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 +1383,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

                 reply	other threads:[~2010-11-15 12:24 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1289823864-12107-1-git-send-email-kraxel@redhat.com \
    --to=kraxel@redhat.com \
    --cc=malc@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).