From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Jsjzp-0002Ep-LW for qemu-devel@nongnu.org; Sun, 04 May 2008 15:35:41 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Jsjzo-0002EN-9e for qemu-devel@nongnu.org; Sun, 04 May 2008 15:35:41 -0400 Received: from [199.232.76.173] (port=45458 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Jsjzo-0002EI-0I for qemu-devel@nongnu.org; Sun, 04 May 2008 15:35:40 -0400 Received: from fmmailgate03.web.de ([217.72.192.234]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Jsjzo-0007uV-6T for qemu-devel@nongnu.org; Sun, 04 May 2008 15:35:40 -0400 Message-ID: <481E1001.3010703@web.de> Date: Sun, 04 May 2008 21:35:29 +0200 From: Jan Kiszka MIME-Version: 1.0 References: <481B6626.7010603@web.de> <481B80F0.8050705@web.de> <481D670D.6070602@web.de> <481DF561.4050709@web.de> In-Reply-To: <481DF561.4050709@web.de> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enigA178C55943F657BD65A91254" Sender: jan.kiszka@web.de Subject: [Qemu-devel] Re: [PATCH] alsaaudio: increase default buffer sizes Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: malc Cc: qemu-devel@nongnu.org This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enigA178C55943F657BD65A91254 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Jan Kiszka wrote: > malc wrote: >> On Sun, 4 May 2008, Jan Kiszka wrote: >> >>> malc wrote: >>>> On Fri, 2 May 2008, Jan Kiszka wrote: >>>> >>>>> malc wrote: >>>>>> On Fri, 2 May 2008, Jan Kiszka wrote: >>>>>> >>>>>>> Sound though the ALSA driver is skipping here unless I increase t= he >>>>>>> buffer size. OSS seems to use 16K as well, and 1K was obviously t= o >>>>>>> small >>>>>>> for recording anyway. >>>>>>> >>>>>>> [ PS: Can someone explain to me why I also have to override the >>>>>>> DAC/ADC_FIXED_FREQ to 48000 to make ALSA work? Suboptimal... ] >>>>>> How exactly it doesn't work if you don't override it? Do you get a= ny >>>>>> messages prefixed with "alsa:"? As for the defaults they were set = to >>>>>> 1024/256 because that's what was needed to make it sound on par >>>>>> with OSS >>>>>> on the two machines i had at the time. >> [..snip..] >> >>>> >>>> Could you give it a whirl please? >>> No difference - except that it now complains about the 16384 byte buf= fer >>> size. >> Okay more of the same... >> >> diff --git a/audio/alsaaudio.c b/audio/alsaaudio.c >> index 43cfa25..59c091d 100644 >> --- a/audio/alsaaudio.c >> +++ b/audio/alsaaudio.c >> @@ -428,15 +428,15 @@ static int alsa_open (int in, struct >> alsa_params_req *req, >> } >> } >> >> - err =3D snd_pcm_hw_params_set_period_size ( >> + err =3D snd_pcm_hw_params_set_period_size_near ( >> handle, >> hw_params, >> - period_size, >> + &period_size, >> 0 >> ); >> if (err < 0) { >> alsa_logerr2 (err, typ, "Failed to set period siz= e >> %d\n", >> - req->period_size); >> + period_size); >> goto err; >> } >> } >> @@ -466,14 +466,14 @@ static int alsa_open (int in, struct >> alsa_params_req *req, >> } >> } >> >> - err =3D snd_pcm_hw_params_set_buffer_size ( >> + err =3D snd_pcm_hw_params_set_buffer_size_near ( >> handle, >> hw_params, >> - buffer_size >> + &buffer_size >> ); >> if (err < 0) { >> alsa_logerr2 (err, typ, "Failed to set buffer size %d= \n", >> - req->buffer_size); >> + buffer_size); >> goto err; >> } >> } >=20 > Yeah, great, that was the key! Find below the version that works for me= > (on 64 bit 8) ). It even obsoletes my buffer size patch. Please merge! Declaring the buffer size tweak obsolete was too quick. I still need more under certain guest load, but now I'm already fine with DEFAULT_BUFFER_SIZE=3D4096. Or all in one: Index: qemu/audio/alsaaudio.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- qemu/audio/alsaaudio.c (Revision 4332) +++ qemu/audio/alsaaudio.c (Arbeitskopie) @@ -58,7 +58,7 @@ static struct { int period_size_out_overridden; int verbose; } conf =3D { -#define DEFAULT_BUFFER_SIZE 1024 +#define DEFAULT_BUFFER_SIZE 4096 #define DEFAULT_PERIOD_SIZE 256 #ifdef HIGH_LATENCY .size_in_usec_in =3D 1, @@ -72,8 +72,8 @@ static struct { .buffer_size_out =3D 400000, .period_size_out =3D 400000 / 4, #else - .buffer_size_in =3D DEFAULT_BUFFER_SIZE * 4, - .period_size_in =3D DEFAULT_PERIOD_SIZE * 4, + .buffer_size_in =3D DEFAULT_BUFFER_SIZE, + .period_size_in =3D DEFAULT_PERIOD_SIZE, .buffer_size_out =3D DEFAULT_BUFFER_SIZE, .period_size_out =3D DEFAULT_PERIOD_SIZE, .buffer_size_in_overridden =3D 0, @@ -396,7 +396,7 @@ static int alsa_open (int in, struct als } else { int dir; - snd_pcm_uframes_t minval; + snd_pcm_uframes_t minval, val; =20 if (period_size) { minval =3D period_size; @@ -428,15 +428,16 @@ static int alsa_open (int in, struct als } } =20 - err =3D snd_pcm_hw_params_set_period_size ( + val =3D period_size; + err =3D snd_pcm_hw_params_set_period_size_near ( handle, hw_params, - period_size, + &val, 0 ); if (err < 0) { alsa_logerr2 (err, typ, "Failed to set period size %= d\n", - req->period_size); + period_size); goto err; } } @@ -466,14 +467,15 @@ static int alsa_open (int in, struct als } } =20 - err =3D snd_pcm_hw_params_set_buffer_size ( + val =3D buffer_size; + err =3D snd_pcm_hw_params_set_buffer_size_near ( handle, hw_params, - buffer_size + &val ); if (err < 0) { alsa_logerr2 (err, typ, "Failed to set buffer size %d\n"= , - req->buffer_size); + buffer_size); goto err; } } --------------enigA178C55943F657BD65A91254 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.4-svn0 (GNU/Linux) Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org iD8DBQFIHhAHniDOoMHTA+kRAhDxAJ40Nz15ZIXiXnx5+fIzCuB6fX7QBwCfc4kZ 239lvBMxdEXiXo1kBeRDtPw= =RokX -----END PGP SIGNATURE----- --------------enigA178C55943F657BD65A91254--