From: Daniel Griscom Subject: Re: Missing exactly 3 of 8 audio packets? Date: Mon, 26 Nov 2012 16:23:18 -0500 Message-ID: References: <50AE99E7.6080008@gmail.com> <50B21255.8080202@gmail.com> <50B31800.2000000@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; Format="flowed" Content-Transfer-Encoding: 7bit Return-path: Received: from gateway13.websitewelcome.com (gateway13.websitewelcome.com [67.18.68.4]) by alsa0.perex.cz (Postfix) with ESMTP id B18692651C2 for ; Mon, 26 Nov 2012 22:23:23 +0100 (CET) Received: from gator683.hostgator.com (gator683.hostgator.com [174.132.158.226]) by gateway13.websitewelcome.com (Postfix) with ESMTP id 3D7ED870E1964 for ; Mon, 26 Nov 2012 15:23:22 -0600 (CST) In-Reply-To: <50B31800.2000000@gmail.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org To: Daniel Mack Cc: Alsa Developer List-Id: alsa-devel@alsa-project.org At 8:19 AM +0100 11/26/12, Daniel Mack wrote: >On 25.11.2012 23:23, Daniel Griscom wrote: >> At 1:43 PM +0100 11/25/12, Daniel Mack wrote: >>> Please do another test and change prepare_outbound_urb() so that instead >>> of calling ep->prepare_data_urb() to fill the URB, fill it directly with >>> some sort of easily recognizable test pattern (you can take the code >>>from "silence" case to access the buffers). Some kind of 16-bit counter >>> should do. And then check the payload with the Beagle and see whether >>> the pattern has gaps. >>> >>> This test will tell us whether data is in fact lost before it hits the >>> usb audio driver, or if it's dropped by the USB HCD. >> >> I did the test, and expected to either a) see the incrementing data >> be contiguous even though the USB packet transmission was stuttering, >> or b) see the incrementing data have gaps where the "missing" packets > > were. However, what I saw was c): the USB packets never misbehaved. >Note that this is a potential difference between your two cases. > >prepare_playback_urb() from pcm.c will not always set >urb->number_of_packets to the maximum value but cut packets short at PCM >period boundaries. > >Could you move your pattern generating code down to that function? Just >look for the memcpy() calls there. OK, this time I got some real results. I can still get the USB packet stream to misbehave, and indeed the synthesized data is being lost. The output data present on the USB bus smoothly increments during each packet, continuing smoothly in adjacent packets. But, when one or two packets are missed, the next output data is numbered as if the packets (6 stereo frames each) had been generated but lost. Here's my code in linux-3.6.6/sound/usb/pcm.c, prepare_playback_urb(): > static short left = 0; > static short right = 0x0404; > short *sp; ... > bytes = frames * stride; >#define FAKE_DATA >#ifdef FAKE_DATA > for (i = 0, sp = (short *)(urb->transfer_buffer); > i < bytes; /* no increment */) { > *sp++ = left++; > i += sizeof(*sp); > *sp++ = right++; > i += sizeof(*sp); > } >#else > if (subs->hwptr_done + bytes > runtime->buffer_size * stride) { > /* err, the transferred area goes over buffer boundary. */ > unsigned int bytes1 = > runtime->buffer_size * stride - subs->hwptr_done; > memcpy(urb->transfer_buffer, > runtime->dma_area + subs->hwptr_done, bytes1); > memcpy(urb->transfer_buffer + bytes1, > runtime->dma_area, bytes - bytes1); > } else { > memcpy(urb->transfer_buffer, > runtime->dma_area + subs->hwptr_done, bytes); > } >#endif > subs->hwptr_done += bytes; Did I place the generation code in the correct location? And, what should I look at next? Thanks again, Dan -- Daniel T. Griscom griscom@suitable.com Suitable Systems http://www.suitable.com/ 1 Centre Street, Suite 204 (781) 665-0053 Wakefield, MA 01880-2400