From: Clemens Ladisch <clemens-P6GI/4k7KOmELgA04lAiVw@public.gmane.org>
To: Laurent Pinchart
<laurent.pinchart-AgBVmzD5pcezQB+pC5nmwQ@public.gmane.org>
Cc: alsa-devel-K7yf7f+aM1XWsZ/bQMPhNw@public.gmane.org,
Steve Calfee
<stevecalfee-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
Hal Murray <hmurray-8cQiHa/C+6Go9G/jEpaUCQ@public.gmane.org>,
linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [RFC] ALSA vs. dedicated char device for a USB Audio Class gadget driver
Date: Fri, 15 May 2009 17:07:30 +0200 [thread overview]
Message-ID: <4A0D8532.4070104@ladisch.de> (raw)
In-Reply-To: <200905151136.52995.laurent.pinchart-AgBVmzD5pcezQB+pC5nmwQ@public.gmane.org>
Laurent Pinchart wrote:
> I know that ALSA is designed for asynchronous operation. This is fine for
> devices that provide an audio clock (all sound cards do), but leads to a few
> issues for devices that don't, like this one.
>
> When streaming audio data from a file to USB, there is simply no audio clock
> in the system.
In this case, you can use the USB frame clock as audio clock, i.e.,
whenever one frame has been completed, you also submit audio data for
one USB frame (one millisecond).
This would be a synchronous endpoint.
> When streaming audio data from a real audio device to USB, the audio
> clock comes from the real audio device and is beyond control of the
> USB Audio Class gadget driver.
In this case, you have _two_ clocks, the clock of the actual audio
device, and the USB SOF clock. What you need to know is the relative
speed of these clocks, because that determines the number of samples per
USB frame.
> I can see two ways around this.
>
> 1. Use an asynchronous isochronous endpoint to stream data. The USB Audio
> Class gadget driver will either have to be provided with a clock from
> userspace, or stream data as fast as it can,
The latter is not allowed by the USB specification; the data rate must
change only gradually, i.e., the difference in successive frames must be
no more than +/- one sample.
> needing a way to check the amount of data present in the buffer (as
> explained in my previous e-mail).
The _current_ amount of valid data does not help because applications
can write data irregularly. You do not want to measure how fast the
application writes data into your buffer, but the actual speed of the
actual audio device.
I'd guess that your gadget driver does not have access to the real audio
device, so it is the application that must do the measurement.
The ALSA API has no mechanism to tell the driver how fast to play, so it
looks as if you have to write you own device driver.
Best regards,
Clemens
--
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:[~2009-05-15 15:07 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <laurent.pinchart@skynet.be>
[not found] ` <200905141545.01798.laurent.pinchart-AgBVmzD5pcezQB+pC5nmwQ@public.gmane.org>
2009-05-14 18:18 ` [RFC] ALSA vs. dedicated char device for a USB Audio Class gadget driver Hal Murray
2009-05-14 20:58 ` Laurent Pinchart
[not found] ` <200905142258.42935.laurent.pinchart-AgBVmzD5pcezQB+pC5nmwQ@public.gmane.org>
2009-05-14 21:12 ` Steve Calfee
[not found] ` <4a5ff6bc0905141412t5ab4f0f5x6c50b4e38af0790f-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2009-05-14 21:25 ` Laurent Pinchart
[not found] ` <200905142325.24408.laurent.pinchart-AgBVmzD5pcezQB+pC5nmwQ@public.gmane.org>
2009-05-15 7:01 ` [alsa-devel] " Clemens Ladisch
[not found] ` <4A0D135C.7090806-P6GI/4k7KOmELgA04lAiVw@public.gmane.org>
2009-05-15 9:36 ` Laurent Pinchart
[not found] ` <200905151136.52995.laurent.pinchart-AgBVmzD5pcezQB+pC5nmwQ@public.gmane.org>
2009-05-15 15:07 ` Clemens Ladisch [this message]
[not found] ` <4A0D8532.4070104-P6GI/4k7KOmELgA04lAiVw@public.gmane.org>
2009-05-15 15:52 ` Laurent Pinchart
[not found] ` <200905151752.58040.laurent.pinchart-AgBVmzD5pcezQB+pC5nmwQ@public.gmane.org>
2009-05-15 17:04 ` Clemens Ladisch
2009-05-17 16:49 ` Laurent Pinchart
2009-05-15 20:15 ` Hal Murray
[not found] ` <20090515201519.7C347BCE6-1EH7ZSm6cX1tFMQ1DeeEjrzXk6sypdOaHzxsA6J8rrk@public.gmane.org>
2009-05-17 17:25 ` Laurent Pinchart
[not found] ` <200905171925.23956.laurent.pinchart-AgBVmzD5pcezQB+pC5nmwQ@public.gmane.org>
2009-05-17 21:28 ` Alan Stern
[not found] ` <Pine.LNX.4.44L0.0905171654500.20300-100000-pYrvlCTfrz9XsRXLowluHWD2FQJk+8+b@public.gmane.org>
2009-05-18 14:36 ` Laurent Pinchart
2009-05-18 8:39 ` Clemens Ladisch
[not found] ` <4A111EBC.2010606-P6GI/4k7KOmELgA04lAiVw@public.gmane.org>
2009-05-18 14:47 ` Laurent Pinchart
[not found] ` <200905181647.41771.laurent.pinchart-AgBVmzD5pcezQB+pC5nmwQ@public.gmane.org>
2009-05-19 11:01 ` Clemens Ladisch
2009-05-14 13:45 Laurent Pinchart
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=4A0D8532.4070104@ladisch.de \
--to=clemens-p6gi/4k7komelga04laivw@public.gmane.org \
--cc=alsa-devel-K7yf7f+aM1XWsZ/bQMPhNw@public.gmane.org \
--cc=hmurray-8cQiHa/C+6Go9G/jEpaUCQ@public.gmane.org \
--cc=laurent.pinchart-AgBVmzD5pcezQB+pC5nmwQ@public.gmane.org \
--cc=linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=stevecalfee-Re5JQEeQqe8AvxtiuMwx3w@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.