From: Daniel Mack <zonque-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: Daniel Griscom <griscom-yI/1Hl18UA1Wk0Htik3J/w@public.gmane.org>
Cc: Alsa Developer
<alsa-devel-K7yf7f+aM1XWsZ/bQMPhNw@public.gmane.org>,
linux-usb <linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Subject: Re: [alsa-devel] Missing exactly 3 of 8 audio packets?
Date: Tue, 27 Nov 2012 12:48:00 +0100 [thread overview]
Message-ID: <50B4A870.7040201@gmail.com> (raw)
In-Reply-To: <p06240804ccd98cef996c@[192.168.1.8]>
On 26.11.2012 22:23, Daniel Griscom wrote:
> 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?
Yes.
> And, what should I look at next?
As Clemens said, check the error fields in the isochronous frames when
the urb is given back to the driver. For isochronous data, there's
nothing the driver can do about failed transmissions, hence there's no
code to handle such conditions. But it might help understand what's
going on.
In any case, this now certainly looks more like a strange USB problem,
rather than a bug in snd-usb. I copied the USB list. The thread starts here:
http://mailman.alsa-project.org/pipermail/alsa-devel/2012-November/057259.html
Daniel
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2012-11-27 11:48 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-21 20:13 Missing exactly 3 of 8 audio packets? Daniel Griscom
2012-11-22 21:01 ` Daniel Mack
2012-11-22 21:32 ` Daniel Mack
2012-11-25 3:33 ` Daniel Griscom
2012-11-25 12:43 ` Daniel Mack
2012-11-25 16:39 ` Clemens Ladisch
2012-11-26 3:14 ` Daniel Griscom
2012-11-26 21:32 ` Clemens Ladisch
2012-11-25 22:23 ` Daniel Griscom
2012-11-26 7:19 ` Daniel Mack
2012-11-26 21:23 ` Daniel Griscom
2012-11-27 11:48 ` Daniel Mack [this message]
2012-11-27 17:01 ` Daniel Griscom
2012-11-27 17:21 ` Clemens Ladisch
2012-11-27 18:40 ` Daniel Griscom
2012-11-27 19:46 ` Clemens Ladisch
2012-11-27 20:10 ` Daniel Griscom
[not found] ` <50B4A870.7040201-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2012-11-27 17:20 ` [alsa-devel] " Alan Stern
[not found] ` <Pine.LNX.4.44L0.1211271213580.1489-100000-IYeN2dnnYyZXsRXLowluHWD2FQJk+8+b@public.gmane.org>
2012-12-03 21:04 ` Sarah Sharp
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=50B4A870.7040201@gmail.com \
--to=zonque-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
--cc=alsa-devel-K7yf7f+aM1XWsZ/bQMPhNw@public.gmane.org \
--cc=griscom-yI/1Hl18UA1Wk0Htik3J/w@public.gmane.org \
--cc=linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.