Skip to contentSkip to conversation

Stereo or mono - how to tell, what to do?

DISCUSSION Adrian McMenamin 2 participants 2 messages Mar 12, 2006

lore
Share & tools
lore
#0 lore raw

I want to add the capacity to play stereo samples to my Dreamcast sound driver.

The hardware does not support interleaved samples and in the OSS driver I simply separated out the input stream into two different buffers and transferred them separately into the hardware's memory. Can I do the same with ALSA or is there some middle layer magic I should be aware of?

And how can my driver tell if the incoming samples are stereo or not. In OSS this was all done through the SNDCTL_DSP_STEREO and SNDCTL_DSP_CHANNELS ioctls, how do I do it in ALSA (I need to inform the hardware to expect two channels and not one).

Adrian

-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642

#1 lore raw
Quoted 8 lines · Adrian McMenamin

I want to add the capacity to play stereo samples to my Dreamcast sound driver.

The hardware does not support interleaved samples and in the OSS driver I simply separated out the input stream into two different buffers and transferred them separately into the hardware's memory. Can I do the same with ALSA or is there some middle layer magic I should be aware of?

You can get alsa-lib to send either interleaved or non-interleaved samples to your driver.
You just tell alsa-lib which format you like, and set the snd_pcm_hardware .info parameter.
I have not looked into how alsa-lib informs the driver of the non-interleaved nature of the samples. You might have to look into that yourself. Probably something in the snd_pcm_runtime structure.

Quoted 8 lines

And how can my driver tell if the incoming samples are stereo or not. In OSS this was all done through the SNDCTL_DSP_STEREO and SNDCTL_DSP_CHANNELS ioctls, how do I do it in ALSA (I need to inform the hardware to expect two channels and not one).

Adrian

You get all that information from the prepare() callback. The parameter passed is struct snd_pcm_substream *substream. substream->runtime->rate substream->runtime->format substream->runtime->channels substream->runtime->buffer_size substream->runtime->period_size substream->runtime->periods

-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642