Skip to contentSkip to conversation

Digital sound card conventions

DISCUSSION Anders Torger 3 participants 5 messages Jan 3, 2003

lore
Share & tools
lore
#0 lore raw

I'm doing a maintenance update on the rme96 driver, and I wonder if there are any conventions to follow in the driver concerning digital sound cards.

The specific questions are how to handle sample rates and sound formats on the input.

The sound card supports several sample rates and formats. What should happen if the user tries to open the input with 48000 kHz ADAT, but the format is actually 44100 kHz and SPDIF? I can allow it if I want to, the user will get data, but at 48000 kHz of course.

What should happen when there is no input signal at all? The hardware supports opening the input, but should I do so in the driver?

The signal can of course change in runtime as well...

I'm thinking of allowing it all, but I don't know if that is the right way to go.

/Anders Torger

-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf

#1 lore raw
Quoted 12 lines · Anders Torger

I'm doing a maintenance update on the rme96 driver, and I wonder if there are any conventions to follow in the driver concerning digital sound cards.

The specific questions are how to handle sample rates and sound formats on the input.

The sound card supports several sample rates and formats. What should happen if the user tries to open the input with 48000 kHz ADAT, but the format is actually 44100 kHz and SPDIF? I can allow it if I want to, the user will get data, but at 48000 kHz of course.

Quoted 7 lines

What should happen when there is no input signal at all? The hardware supports opening the input, but should I do so in the driver?

The signal can of course change in runtime as well...

I'm thinking of allowing it all, but I don't know if that is the right way to go.

This part of PCM API has not been discussed. I think that we should follow the most easy way: It is - allow only sample rate given by application, if the master clock is using another sample rate - in trigger() callback - driver will fail. Also it will fail, when sample rate is changed during operation. We probably need to add a new PCM state - SNDRV_PCM_STATE_STREAM_CHANGED (equal to DRAINING, but informative for applications). The notification of master clock / sample rate (or other parameter) changes should be implemented using the control API.

Jaroslav

-----
Jaroslav Kysela <[email protected]>
Linux Kernel Sound Maintainer
ALSA Project, SuSE Labs

-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf

#2 lore raw
Quoted 23 lines · Jaroslav Kysela
Quoted 13 lines · Anders Torger

I'm doing a maintenance update on the rme96 driver, and I wonder if there are any conventions to follow in the driver concerning digital sound cards.

The specific questions are how to handle sample rates and sound formats on the input.

The sound card supports several sample rates and formats. What should happen if the user tries to open the input with 48000 kHz ADAT, but the format is actually 44100 kHz and SPDIF? I can allow it if I want to, the user will get data, but at 48000 kHz of course.

Quoted 8 lines

What should happen when there is no input signal at all? The hardware supports opening the input, but should I do so in the driver?

The signal can of course change in runtime as well...

I'm thinking of allowing it all, but I don't know if that is the right way to go.

Quoted 9 lines

This part of PCM API has not been discussed. I think that we should follow the most easy way: It is - allow only sample rate given by application, if the master clock is using another sample rate - in trigger() callback - driver will fail. Also it will fail, when sample rate is changed during operation. We probably need to add a new PCM state -
SNDRV_PCM_STATE_STREAM_CHANGED (equal to DRAINING, but informative for applications). The notification of master clock / sample rate (or other parameter) changes should be implemented using the control API.

So what you are saying is, for now, do what is correct at the moment. Is this ok:

If no signal on the input - allow to open with any setting the hardware supports. The current rme96 driver will return -EIO, but that sucks if you're just opening the card to check some parameters, so I plan to change that.

If there is a signal on the input, limit the reported sound card capabilities to only those currently available on the input, so when the sound card is opened for capture, it seems only capable of 48kHz if that is the current sample rate.

/Anders Torger

-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf

#3 lore raw
In reply to Jaroslav Kysela
Quoted 5 lines

This part of PCM API has not been discussed. I think that we should follow the most easy way: It is - allow only sample rate given by application, if the master clock is using another sample rate - in trigger() callback - driver will fail.

this seems wrong to me. what should fail is an attempt to set the sample rate unless the hardware is its own clock Master. if no attempt is made to set it, then the application gets whatever the hardware is running at, whether that is externally controlled or some h/w specific default.

Quoted 2 lines

Also it will fail, when sample rate is changed during
operation.

the hammerfall driver used to contain stubs for doing this. every read/write operation would check that the (possibly externally controlled) SR was the same as "last time". i never did any more on this.

Quoted 4 lines

We probably need to add a new PCM state -
SNDRV_PCM_STATE_STREAM_CHANGED (equal to DRAINING, but informative for applications). The notification of master clock / sample rate (or other parameter) changes should be implemented using the control API.

and already is for some cards (and some parameters).

--p

-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf

#4 lore raw
Quoted 10 lines · Paul Davis
Quoted 4 lines

This part of PCM API has not been discussed. I think that we should follow the most easy way: It is - allow only sample rate given by application, if the master clock is using another sample rate - in trigger() callback - driver will fail.

this seems wrong to me. what should fail is an attempt to set the sample rate unless the hardware is its own clock Master. if no attempt is made to set it, then the application gets whatever the hardware is running at, whether that is externally controlled or some h/w specific default.

An attempt to set it to the sample rate that happens be the correct one should be ok, at least I think so.

So, your suggestion is, that for capture, always state the full hardware capability (in hwparams), but fail if incorrect the settings are made? I think that is ok too, but currently I'm narrowing down the hwparams to fit what is available at the input when the sound card is opened (of course, that could have changed until the sound card is started, but it is quite unlikely).

I think both approaches are ok, but narrowing down the alternatives I think is more nice to the applications. My guess is that the common use of a digital sound card is that the input signal is not changed too often, and then it is nice if the software gets the correct capabilities, so those applications that think that all sound cards are analog will work in the expected way anyway.

Quoted 7 lines
Quoted 2 lines

Also it will fail, when sample rate is changed during
operation.

the hammerfall driver used to contain stubs for doing this. every read/write operation would check that the (possibly externally controlled) SR was the same as "last time". i never did any more on this.

Uhmm... I don't think I will include changed sample rate / format callback stuff for now, because I don't know how to implement it. However, if there is a good example which I could imitate, let me know.

/Anders Torger

-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf