[alsa-devel] How to set idle S/PDIF sample rate?
Matt Whitlock
matt at whitlock.name
Mon Feb 25 20:03:21 CET 2008
On Monday, 25 February 2008 6:16:11 am Takashi Iwai wrote:
> At Fri, 22 Feb 2008 22:34:22 -0500,
> Matt Whitlock wrote:
> >
> > When no programs have the sound hardware open, ALSA drives my Intel HDA's S/PDIF output with silence at 48000 Hz. How would I change this default so that the idle sample rate is 44100 Hz?
>
> You can use iecset utility to set the default SPDIF setting.
> But, in the case of HD-audio, the sample rate isn't included in the
> status bits verb but rather set dynamically via the normal PCM rate
> stting. So, I don't think this would fix your problem.
Correct. Executing 'iecset rate 44100' while the sound card is idle prints a text block that says "Rate: 44100 Hz", but my receiver still shows that it is receiving PCM at 48000 Hz. If I then play a 44100-Hz stream, the receiver switches to 44100 Hz (takes a moment, during which audio is dropped), and then when I stop the playback, the receiver switches back to 48000 Hz (takes another moment, although it's imperceptible because there's no audio to drop at this point). Interestingly, running 'iecset' with no arguments at this point still shows "Rate: 44100 Hz" even though the card is outputting 48000-Hz silence.
> > I've tried everything, including replacing /usr/share/alsa/alsa.conf with a single PCM definition that outputs straight to hardware with "rate 44100", but still, whenever nothing is accessing the sound hardware, ALSA reverts to 48000-Hz silence. There must be a way to influence that, right?
> >
> > Alternatively, if ALSA would simply not output anything over S/PDIF when idle, my receiver could just stay at 44100 Hz, albeit unlocked since there would be no data stream at all. So this is also an acceptable solution to me, but I cannot find any way to make ALSA totally shut up when idle. It always wants to output silence. Interestingly, if I mute the IEC958 playback channel and then unmute it, my receiver reports no signal at all until I play a sound, and then after the sound finishes, my receiver reports that it is locked onto PCM at 48000 Hz. Seems kind of like a bug, doesn't it?
>
> Hm, what happens if you mute IEC958 playback switch before the end of
> the playback stream?
There are some interesting and complex behaviors going on here. I will record my steps and results exactly.
Precondition: iec958 channel muted; iecset shows "Rate: 48000 Hz"; no signal at receiver
1. begin playback of 44100-Hz stream with 'aplay' (default device)
Result: no change at receiver (no signal)
2. interrupt aplay
Result: no change
3. begin playback of 44100-Hz stream with 'aplay -D spdif'
Result: iec958 channel becomes unmuted; receiver shows PCM at 44100 Hz; sound audible after momentary delay
4. interrupt aplay
Result: iec958 channel becomes muted again; receiver shows no signal after ~2-second delay
5. unmute iec958 channel in alsamixer
Result: receiver display blips momentarily but goes back to no signal
6. mute iec958 channel in alsamixer
Result: no change (no signal)
7. unmute iec958 channel in alsamixer again
Result: no change (no signal; no blip on receiver display this time)
8. begin playback of 44100-Hz stream with 'aplay' (default device)
Result: receiver shows PCM at 48000 Hz; sound audible immediately
9. interrupt aplay
Result: no change (receiver still shows PCM at 48000 Hz; no blip on receiver display)
10. begin playback of 44100-Hz stream with 'aplay -D spdif'
Result: receiver switches to 44100-Hz PCM; sound becomes audible after momentary switching delay
11. interrupt aplay
Result: receiver switches back to 48000-Hz PCM
12. begin playback of 44100-Hz stream with 'aplay' (default device)
Result: no change on receiver display (still shows PCM at 48000 Hz); sound audible immediately
13. attempt to mute iec958 channel in alsamixer
Result: iec958 channel becomes muted; receiver shows no signal after ~2-second delay
14. attempt to unmute iec958 channel in alsamixer
Result: iec958 channel becomes unmuted; receiver shows PCM at 48000 Hz; sound audible again
15. interrupt aplay
Result: no change at receiver (still shows PCM at 48000 Hz)
16. begin playback of 44100-Hz stream with 'aplay -D spdif'
Result: receiver switches to 44100-Hz PCM; sound becomes audible after momentary switching delay
17. attempt to mute iec958 channel in alsamixer
Result: no change (iec958 does not become muted; receiver still shows PCM at 44100 Hz; sound still audible)
I just ran through this list of steps a second time to be sure they are completely correct, and they are.
To sum up what I'm seeing:
iec958 channel muted
--------------------
playback to default device: no signal
playback to spdif device: PCM at 44100 Hz
idle: no signal
iec958 channel unmuted
----------------------
playback to default device: PCM at 48000 Hz
playback to spdif device: PCM at 44100 Hz
idle: no signal immediately after unmute; PCM at 48000 Hz after any audio stream
If I could just get that last state (iec958 unmuted; idle after any audio stream) to be 44100 Hz instead of 48000 Hz, I would be happy.
More information about the Alsa-devel
mailing list