From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JpBb4-0006ga-Im for qemu-devel@nongnu.org; Thu, 24 Apr 2008 20:15:26 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JpBb3-0006gM-0b for qemu-devel@nongnu.org; Thu, 24 Apr 2008 20:15:26 -0400 Received: from [199.232.76.173] (port=59558 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JpBb2-0006gI-TR for qemu-devel@nongnu.org; Thu, 24 Apr 2008 20:15:24 -0400 Received: from ug-out-1314.google.com ([66.249.92.174]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1JpBb1-0008Ph-Vk for qemu-devel@nongnu.org; Thu, 24 Apr 2008 20:15:24 -0400 Received: by ug-out-1314.google.com with SMTP id m2so903146uge.4 for ; Thu, 24 Apr 2008 17:15:23 -0700 (PDT) Message-ID: Date: Fri, 25 Apr 2008 02:15:23 +0200 From: "andrzej zaborowski" Subject: Re: [Qemu-devel] [4249] Improve audio api use in WM8750. In-Reply-To: <48111E61.9050002@web.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <4810FBF9.1040308@web.de> <48111E61.9050002@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 On 25/04/2008, Jan Kiszka wrote: > 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 = (struct wm8750_s *) opaque; > >> > > >> > - s->req_out = free_b; > >> > - s->data_req(s->opaque, free_b >> 2, s->req_in >> 2); > >> > - wm8750_out_flush(s); > >> > + if (s->idx_out >= free_b) { > >> > + s->idx_out = free_b; > >> > + s->req_out = 0; > >> > + wm8750_out_flush(s); > >> > + } else > >> > + s->req_out = 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 flush > >> (keep in mind: it may increase the amount of data that has to be flushed > >> ASAP!). And this change also leaves the MusicPal broken. > > > > 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). Not sure I understand what you mean by missing data. The host reports that it can accept a write of free_b bytes. If we have free_b bytes in s->data_out then we write it. Then we tell the guest how many more samples we need (if any). When the guest provides us with that many samples then we write the whole buffer to host (no matter if that happened inside the callback or whenever that data became ready). > > > > 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(). > > > > 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. We don't really care what happened in the callback. We need to write when we reach the threshold, and this is what is implemented. -- Please do not print this email unless absolutely necessary. Spread environmental awareness.