From patchwork Wed Oct 27 16:04:32 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 69377 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 72127B70CC for ; Thu, 28 Oct 2010 03:47:39 +1100 (EST) Received: from localhost ([127.0.0.1]:42730 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PB9A0-00037K-EY for incoming@patchwork.ozlabs.org; Wed, 27 Oct 2010 12:47:36 -0400 Received: from [140.186.70.92] (port=42360 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PB8UT-0005LL-1Y for qemu-devel@nongnu.org; Wed, 27 Oct 2010 12:04:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PB8UR-0007HI-Sw for qemu-devel@nongnu.org; Wed, 27 Oct 2010 12:04:40 -0400 Received: from mx1.redhat.com ([209.132.183.28]:1026) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PB8UR-0007Gv-M5 for qemu-devel@nongnu.org; Wed, 27 Oct 2010 12:04:39 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o9RG4cRr004558 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 27 Oct 2010 12:04:38 -0400 Received: from rincewind.home.kraxel.org (vpn1-7-151.ams2.redhat.com [10.36.7.151]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o9RG4b7k025255; Wed, 27 Oct 2010 12:04:37 -0400 Received: by rincewind.home.kraxel.org (Postfix, from userid 500) id 392FC45807; Wed, 27 Oct 2010 18:04:36 +0200 (CEST) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Wed, 27 Oct 2010 18:04:32 +0200 Message-Id: <1288195475-3807-4-git-send-email-kraxel@redhat.com> In-Reply-To: <1288195475-3807-1-git-send-email-kraxel@redhat.com> References: <1288195475-3807-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: Gerd Hoffmann Subject: [Qemu-devel] [PATCH 3/6] pa: setup buffer attrs 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 Request reasonable buffer sizes from pulseaudio. Without this pa_simple_write() can block quite long and lead to dropouts, especially with guests which use small audio ring buffers. Signed-off-by: Gerd Hoffmann --- audio/paaudio.c | 12 +++++++++++- 1 files changed, 11 insertions(+), 1 deletions(-) diff --git a/audio/paaudio.c b/audio/paaudio.c index f99ca73..d019978 100644 --- a/audio/paaudio.c +++ b/audio/paaudio.c @@ -289,6 +289,7 @@ static int qpa_init_out (HWVoiceOut *hw, struct audsettings *as) { int error; static pa_sample_spec ss; + static pa_buffer_attr ba; struct audsettings obt_as = *as; PAVoiceOut *pa = (PAVoiceOut *) hw; @@ -296,6 +297,15 @@ static int qpa_init_out (HWVoiceOut *hw, struct audsettings *as) ss.channels = as->nchannels; ss.rate = as->freq; + /* + * qemu audio tick runs at 250 Hz (by default), so processing + * data chunks worth 4 ms of sound should be a good fit. + */ + ba.tlength = pa_usec_to_bytes(4 * 1000, &ss); + ba.minreq = pa_usec_to_bytes(2 * 1000, &ss); + ba.maxlength = -1; + ba.prebuf = -1; + obt_as.fmt = pa_to_audfmt (ss.format, &obt_as.endianness); pa->s = pa_simple_new ( @@ -306,7 +316,7 @@ static int qpa_init_out (HWVoiceOut *hw, struct audsettings *as) "pcm.playback", &ss, NULL, /* channel map */ - NULL, /* buffering attributes */ + &ba, /* buffering attributes */ &error ); if (!pa->s) {