Re: S/PDIF Capture Details

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

 



Paul Braman wrote:
> I'm writing a program to open an ALSA device (USB S/PDIF) and capture
> the bitstream. Aside from having to tackle the bits about deciding
> whether the stream is PCM versus something else,

PCM streams are marked with the "valid" bit.

> So, assuming I can find the card and open it using snd_pcm_open I need
> to then configure the hardware parameters.
>
> snd_pcm_hw_params_set_access(..., ..., SND_PCM_ACCESS_RW_INTERLEAVED)
> snd_pcm_hw_params_set_format(..., ..., SND_PCM_FORMAT_S16)
> snd_pcm_hw_params_set_channels(..., ..., 2)
> snd_pcm_hw_params_set_rate_near(..., ..., 48000, 0)

This is correct.  (Although "_near" does not make sense with S/PDIF).

> However, I'm not entirely clear what I'll get from this device.

You'll get PCM samples.  (Or in the case of non-PCM streams, compressed
data that pretends to be PCM samples.)

> The S/PDIF standard talks about 32-bit words that can be parsed to get
> the headers and payload.

This parsing is done by the device.  The information in the headers is
made available with a special mixer control, but not for USB devices.

> Also, what if the device to which I am connected is a CD player
> outputting data at 44.1 KHz?

If you had an analog-to-digital converter, configuring it for a specific
sample rate would control how often it generates a new sample.

In the case of an S/PDIF receiver, you _cannot_ control this; how often
you get a new sample is determined by the sender.  The sample rate you
set is either ignored or used to drop data that arrives with the wrong
rate.  (And because the USB Audio spec doesn't have a mechanism to
access the header bits, you have to guess.)


Regards,
Clemens

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Alsa-user mailing list
Alsa-user@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/alsa-user


[Index of Archives]     [ALSA Devel]     [Linux Audio Users]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]

  Powered by Linux