Received: from [140.186.70.92] (port=33183 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Phf4g-00040j-1L for qemu-devel@nongnu.org; Tue, 25 Jan 2011 04:20:32 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Phf4e-0006Pw-3b for qemu-devel@nongnu.org; Tue, 25 Jan 2011 04:20:29 -0500 Received: from mx1.redhat.com ([209.132.183.28]:17393) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Phf4d-0006Pk-Sp for qemu-devel@nongnu.org; Tue, 25 Jan 2011 04:20:28 -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 p0P9KRqB015277 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 25 Jan 2011 04:20:27 -0500 Date: Tue, 25 Jan 2011 11:20:21 +0200 From: Alon Levy Subject: Re: [Qemu-devel] [RESEND PATCH 2/3] pulseaudio: setup buffer attrs Message-ID: <20110125092020.GB5940@playa.tlv.redhat.com> References: <1295903266-6458-1-git-send-email-kraxel@redhat.com> <1295903266-6458-2-git-send-email-kraxel@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1295903266-6458-2-git-send-email-kraxel@redhat.com> List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Gerd Hoffmann Cc: qemu-devel@nongnu.org On Mon, Jan 24, 2011 at 10:07:45PM +0100, Gerd Hoffmann wrote: > 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 858ca81..75e3ea0 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; > + What's the default buffer size? Is there any reason to query this on startup somewhere instead of hard coding it? > 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) { > -- > 1.7.1 > >