From patchwork Thu May 24 15:05:15 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kiszka X-Patchwork-Id: 161149 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 88930B6FD3 for ; Fri, 25 May 2012 01:05:49 +1000 (EST) Received: from localhost ([::1]:52939 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SXZbm-00065q-Jz for incoming@patchwork.ozlabs.org; Thu, 24 May 2012 11:05:46 -0400 Received: from eggs.gnu.org ([208.118.235.92]:43577) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SXZbY-00064z-31 for qemu-devel@nongnu.org; Thu, 24 May 2012 11:05:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SXZbR-0005pr-CI for qemu-devel@nongnu.org; Thu, 24 May 2012 11:05:31 -0400 Received: from david.siemens.de ([192.35.17.14]:25213) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SXZbR-0005oL-2w for qemu-devel@nongnu.org; Thu, 24 May 2012 11:05:25 -0400 Received: from mail1.siemens.de (localhost [127.0.0.1]) by david.siemens.de (8.13.6/8.13.6) with ESMTP id q4OF5JR3028385; Thu, 24 May 2012 17:05:19 +0200 Received: from mchn199C.mchp.siemens.de ([139.22.33.170]) by mail1.siemens.de (8.13.6/8.13.6) with SMTP id q4OF5HnG021656; Thu, 24 May 2012 17:05:18 +0200 Message-ID: <4FBE4E2B.7070902@siemens.com> Date: Thu, 24 May 2012 12:05:15 -0300 From: Jan Kiszka User-Agent: Mozilla/5.0 (X11; U; Linux i686 (x86_64); de; rv:1.8.1.12) Gecko/20080226 SUSE/2.0.0.12-1.1 Thunderbird/2.0.0.12 Mnenhy/0.7.5.666 MIME-Version: 1.0 To: qemu-devel , malc X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-Received-From: 192.35.17.14 Cc: Anthony Liguori , Gerd Hoffmann Subject: [Qemu-devel] [PATCH v2] audio: Always call fini on exit X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Not only clean up enabled voices but any registered one. Backends like pulsaudio rely on unconditional fini handler invocations. This fixes "Memory pool destroyed but not all memory blocks freed!" warnings on VM shutdowns when pa is used and lockups of QEMU on shutdown as it got stuck on some pa-internal synchronization point. Signed-off-by: Jan Kiszka --- Changes in v2: - only disable ports that are enabled audio/audio.c | 12 ++++++++---- 1 files changed, 8 insertions(+), 4 deletions(-) diff --git a/audio/audio.c b/audio/audio.c index bd9237e..583ee51 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -1775,10 +1775,12 @@ static void audio_atexit (void) HWVoiceOut *hwo = NULL; HWVoiceIn *hwi = NULL; - while ((hwo = audio_pcm_hw_find_any_enabled_out (hwo))) { + while ((hwo = audio_pcm_hw_find_any_out (hwo))) { SWVoiceCap *sc; - hwo->pcm_ops->ctl_out (hwo, VOICE_DISABLE); + if (hwo->enabled) { + hwo->pcm_ops->ctl_out (hwo, VOICE_DISABLE); + } hwo->pcm_ops->fini_out (hwo); for (sc = hwo->cap_head.lh_first; sc; sc = sc->entries.le_next) { @@ -1791,8 +1793,10 @@ static void audio_atexit (void) } } - while ((hwi = audio_pcm_hw_find_any_enabled_in (hwi))) { - hwi->pcm_ops->ctl_in (hwi, VOICE_DISABLE); + while ((hwi = audio_pcm_hw_find_any_in (hwi))) { + if (hwi->enabled) { + hwi->pcm_ops->ctl_in (hwi, VOICE_DISABLE); + } hwi->pcm_ops->fini_in (hwi); }