From patchwork Thu Nov 18 11:11:33 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 72082 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 45470B71B1 for ; Thu, 18 Nov 2010 22:19:23 +1100 (EST) Received: from localhost ([127.0.0.1]:42220 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PJ2WK-0005nA-DA for incoming@patchwork.ozlabs.org; Thu, 18 Nov 2010 06:19:16 -0500 Received: from [140.186.70.92] (port=43310 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PJ2P0-0002e6-Mh for qemu-devel@nongnu.org; Thu, 18 Nov 2010 06:11:43 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PJ2Oz-0004Dx-BH for qemu-devel@nongnu.org; Thu, 18 Nov 2010 06:11:42 -0500 Received: from mx1.redhat.com ([209.132.183.28]:32950) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PJ2Oz-0004Da-3M for qemu-devel@nongnu.org; Thu, 18 Nov 2010 06:11:41 -0500 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id oAIBBaS7011717 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 18 Nov 2010 06:11:36 -0500 Received: from rincewind.home.kraxel.org (vpn2-11-75.ams2.redhat.com [10.36.11.75]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id oAIBBYTl003858; Thu, 18 Nov 2010 06:11:35 -0500 Received: by rincewind.home.kraxel.org (Postfix, from userid 500) id 9A2684580C; Thu, 18 Nov 2010 12:11:33 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Thu, 18 Nov 2010 12:11:33 +0100 Message-Id: <1290078693-18222-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: Gerd Hoffmann Subject: [Qemu-devel] [PATCH v2] audio: disable timer when idle. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 --- 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;