Skip to contentSkip to conversation

Digital sound card conventions

DISCUSSION Jaroslav Kysela 3 participants 4 messages Jan 5, 2003 – Jan 7, 2003 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 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.

I think that it's wrong when application receives stream with another parameters than requested. Imagine that you're doing a software sample rate conversion and we really need to know the exact rate for this job.

So my suggestion is:

1) offer all available sample rates in open() or reduce them as suggested by Anders
2) in trigger(START)
- check if current sample rate match with hw_params - if not - fail
3) in interrupt callback
- same job as trigger does

Note that we have to implement this algorithm also for playback, because it can use external timing as well.

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.

Quoted 6 lines
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).

Yes, I know.

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 8 lines
Quoted 5 lines

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.

I think that it's wrong when application receives stream with another parameters than requested.

how would that happen?

if it asks for a specific rate via hw_params, it will either get it, or fail. if it doesn't ask for a specific rate, it will get whatever the h/w is using (some default and/or the value set by an external clock).

Quoted 2 lines

Imagine that you're doing a software sample
rate conversion and we really need to know the exact rate for this job.

you can get it by just asking the device what rate its using, or by knowing that your hw_params request completed successfully.

Quoted 6 lines

1) offer all available sample rates in open() or reduce them as suggested by Anders
2) in trigger(START)
- check if current sample rate match with hw_params - if not - fail
3) in interrupt callback
- same job as trigger does

what about checking in read/write operations, in case the external clock has changed?

--p

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

#3 lore raw
Quoted 15 lines · Paul Davis
Quoted 8 lines
Quoted 5 lines

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.

I think that it's wrong when application receives stream with another parameters than requested.

how would that happen?

if it asks for a specific rate via hw_params, it will either get it, or fail. if it doesn't ask for a specific rate, it will get whatever the h/w is using (some default and/or the value set by an external clock).

Quoted 5 lines
Quoted 2 lines

Imagine that you're doing a software sample
rate conversion and we really need to know the exact rate for this job.

you can get it by just asking the device what rate its using, or by knowing that your hw_params request completed successfully.

Ok, we speak about same things. It's ok when hw_params request returns an error code when rate doesn't match.

Quoted 9 lines
Quoted 6 lines

1) offer all available sample rates in open() or reduce them as suggested by Anders
2) in trigger(START)
- check if current sample rate match with hw_params - if not - fail
3) in interrupt callback
- same job as trigger does

what about checking in read/write operations, in case the external clock has changed?

Yes, the check might be in copy/silence/pointer callbacks, too.

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

#4 lore raw
In reply to Paul Davis

At Mon, 06 Jan 2003 11:28:41 -0500,

Quoted 10 lines · Paul Davis
Quoted 7 lines

1) offer all available sample rates in open() or reduce them as suggested by Anders
2) in trigger(START)
- check if current sample rate match with hw_params - if not - fail
3) in interrupt callback
- same job as trigger does

what about checking in read/write operations, in case the external clock has changed?

iiuc, read/write are not called when the buffer is mmapped, so this might not work in every case...

if interrupts are really generated, we can send some notification in the interrupt handler (just like snd_ctl_notify() does), and check it in the next (or sleeping) read/write/poll operation.

Takashi

-------------------------------------------------------
This SF.NET email is sponsored by:
SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
http://www.vasoftware.com