From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JpBJk-0001Hm-3n for qemu-devel@nongnu.org; Thu, 24 Apr 2008 19:57:32 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JpBJi-0001G3-Lm for qemu-devel@nongnu.org; Thu, 24 Apr 2008 19:57:31 -0400 Received: from [199.232.76.173] (port=47166 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JpBJi-0001FE-8a for qemu-devel@nongnu.org; Thu, 24 Apr 2008 19:57:30 -0400 Received: from fmmailgate02.web.de ([217.72.192.227]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1JpBJf-0003AJ-NP for qemu-devel@nongnu.org; Thu, 24 Apr 2008 19:57:29 -0400 Received: from smtp07.web.de (fmsmtp07.dlan.cinetic.de [172.20.5.215]) by fmmailgate02.web.de (Postfix) with ESMTP id 29F71DA1F576 for ; Fri, 25 Apr 2008 01:57:26 +0200 (CEST) Received: from [88.65.242.3] (helo=[192.168.1.198]) by smtp07.web.de with asmtp (TLSv1:AES256-SHA:256) (WEB.DE 4.109 #226) id 1JpBJe-0007ON-00 for qemu-devel@nongnu.org; Fri, 25 Apr 2008 01:57:26 +0200 Message-ID: <48111E61.9050002@web.de> Date: Fri, 25 Apr 2008 01:57:21 +0200 From: Jan Kiszka MIME-Version: 1.0 Subject: Re: [Qemu-devel] [4249] Improve audio api use in WM8750. References: <4810FBF9.1040308@web.de> In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enigD863FEA1080BFEA3366514F8" Sender: jan.kiszka@web.de Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enigD863FEA1080BFEA3366514F8 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable andrzej zaborowski wrote: > On 24/04/2008, Jan Kiszka wrote: >> Hi Andrzej, >> >> Andrzej Zaborowski wrote: >> > Revision: 4249 >> ... >> > static void wm8750_audio_out_cb(void *opaque, int free_b) >> > { >> > struct wm8750_s *s =3D (struct wm8750_s *) opaque; >> > >> > - s->req_out =3D free_b; >> > - s->data_req(s->opaque, free_b >> 2, s->req_in >> 2); >> > - wm8750_out_flush(s); >> > + if (s->idx_out >=3D free_b) { >> > + s->idx_out =3D free_b; >> > + s->req_out =3D 0; >> > + wm8750_out_flush(s); >> > + } else >> > + s->req_out =3D free_b - s->idx_out; >> > + >> > + s->data_req(s->opaque, s->req_out >> 2, s->req_in >> 2); >> >> Please make sure that the callback is always issued _before_ the flus= h >> (keep in mind: it may increase the amount of data that has to be flus= hed >> ASAP!). And this change also leaves the MusicPal broken. >=20 > The idea is to output free_b bytes immediately if we have that many in > the buffer (it could happen assuming that free_b value can change Wrong ordering: If there has been a _relevant_ amount of data (not a few 10 bytes) hanging around in our internal buffer between the guest has filled it during the last callbacks and the host reports demand via the new callback, that data was missing in the host's audio buffer! That's what I saw (heard) with the old version (the current one even causes total silence). > between callbacks). I'm not sure how this can break something: if > *inside* the data_req() callback we receive enough bytes to fill the > the whole buffer then dac_dat() will call out_flush(). >=20 > Without that all buffering becomes useless because we flush every > sample we receive and we start to crawl. Nothing is crawling here, just use a reasonable threshold for flushing _after_ the callback. Need to check, but maybe we can even wait the a full buffer. Jan --------------enigD863FEA1080BFEA3366514F8 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 iD8DBQFIER5lniDOoMHTA+kRAr16AJ90g4+U4N0Qq9NzHPxoZBFCPveb1wCfazy/ 14CHyq3BwWFpa0AE42BRxMk= =ZiGW -----END PGP SIGNATURE----- --------------enigD863FEA1080BFEA3366514F8--