Audio I/O parameters

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Clemens:

I'm working with James Stone on a bug report, and maybe you can help.  
The main problem seems to be connected with how snd-usb-audio decides
to package its USB transfers.  The details are all available at

	https://bugs.launchpad.net/bugs/1191603

Here's the quick summary.

James is using JACK to do audio I/O.  The data values are 24 bits
(transmitted across the USB bus as 4-byte values).  The audio-in stream
has two data values per sample (stereo), the audio-out stream has four,
and the sampling rate is 44100 Hz.

I'm not at all familiar with JACK, but James explained that it uses two
parameters to control the data flow: frames/period and periods/buffer.  
In case you don't already know what these mean, as far as I can tell a
"frame" is a sample, and frames/period is the number of samples that
JACK sends to/from the kernel in each system call.  Periods/buffer
evidently describes the total size of JACK's ring buffer.

James has frames/period set to 256 and periods/buffer set to 2.  This 
means the duration of a period is:

   256 samples/period / (44100 samples/second) * 8000 microframes/second
	= 46.44 microframes/period.

The bInterval values for the isochronous OUT and IN endpoints are both
1 (this is a high-speed device, so the intervals are in microframes).  
Therefore I would expect to see snd-usb-audio submitting isochronous
URBs with 46 or 47 packets, with a pipeline depth of 2 URBs.  This
would yield an output latency of 11.6 ms, which is perhaps larger than
James would like, but could be adjusted.

However, that's not what actually happens.  The audio-out stream uses 8
URBs each containing about 7 packets on average, for a latency of 7 ms.  
The audio-in stream uses 8 URBs each containing 1 packet, for a latency
of 0.125 ms and a pipeline duration of 1 ms -- which is too small for
the current version of ehci-hcd to accept.

Why is there such a large discrepancy between the expected URB 
characteristics and the actual ones?

Why are the audio-out URBs so different from the audio-in (7 packets
per URB vs. 1 packet)?

How can James adjust his settings to get something more reasonable?  
For example, URBs containing 11 or 12 packets (64 samples on average)  
would yield an input latency of 1.5 ms, and a pipeline depth of 4 URBs 
would yield an output latency of 5.8 ms.  These numbers would be 
equivalent to 64 frames/period and 4 periods/buffer in JACK's 
terminology.

Alan Stern

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux