Getting around initial sample loss with intel HDMI
At Sat, 25 Jul 2009 13:35:18 -0700,
Quoted 13 lines · Shane W
Hi,
It's a known issue that Intel HDMI audio loses the first half second or so of audio when opening the device. Using the dmix interface, I've been able to get around that by writing a quick app to hold the device open so the HDMI stays live. However, with the recent asound.conf posted here which uses the route plugin to fix the multichannel order, I can't do that as dmix isn't in the picture. I'd rather not use dmix anyway since it can bugger with the sample rate so I am wondering if there's another way to get around this.
It's possible to combine with dmix.
You set up dmix with 8 channels, put route plugin over it.
Takashi
At Sun, 26 Jul 2009 10:32:10 -0700,
Quoted 13 lines · Shane W
Quoted 11 lines · Takashi Iwai
Quoted 10 lines
It's a known issue that Intel HDMI audio loses the first half second or so of audio when opening the device. Using the dmix interface, I've been able to get around that by writing a quick app to hold the device open so the HDMI stays live. However, with the recent asound.conf posted here which uses the route plugin to fix the multichannel order, I can't do that as dmix isn't in the picture. I'd rather not use dmix anyway since it can bugger with the sample rate so I am wondering if there's another way to get around this.
Quoted 7 lines
Quoted 2 lines
It's possible to combine with dmix.
You set up dmix with 8 channels, put route plugin over it.This has a few problems.
It doesn't seem to handle varying sample rates. IE if I play a 96khz stream at 6 channels, sound is terrible.
This is rather a problem of Nvidia HDMI codec driver...
Quoted 3 lines
Also,
streaming DTS or AC3 no longer works since the streams are being upmixed to 6ch.
This has to be sent anyway exclusively without dmix, so you'll need another PCM definition.
Quoted 9 lines
I did some digging in the drivers to try and find the source of this problem. Note that I am really not familiar with this stuff. It appears to be here:
hda_codec.c
voidsnd_hda_codec_setup_stream(...)
...
snd_hda_codec_write(codec, nid, 0,AC_VERB_SET_CHANNEL_STREAMID,
Quoted 5 lines
Introducing a delay after this point fixes the issue but it's around a full second so that's obviously not a solution. Could we not cache the current format and only do this when the format changes rather than on every device open?
The format itself is kept. But the stream tag and channel assignment are assigned dynamically at each open. Thus, this call has to be reset at each open, at least.
Quoted 4 lines
For testing, I tried doing this though and disabling the
set_streamid, 0 call insnd_codec_cleanup()but it still missed those first samples. Is there somewhere else I need to be looking?
Does it happen without dmix, too?
The reset part can be a bit more optimized. But, this is really a sensitive part, which can easily break the I/O status without knowing...
Takashi
At Sun, 26 Jul 2009 23:21:50 -0700,
Quoted 23 lines · Shane W
Quoted 21 lines · Takashi Iwai
At Sun, 26 Jul 2009 10:32:10 -0700,
Quoted 9 lines · Shane W
I did some digging in the drivers to try and find the source of this problem. Note that I am really not familiar with this stuff. It appears to be here:
hda_codec.c
voidsnd_hda_codec_setup_stream(...)
...
snd_hda_codec_write(codec, nid, 0,AC_VERB_SET_CHANNEL_STREAMID,Quoted 5 lines
Introducing a delay after this point fixes the issue but it's around a full second so that's obviously not a solution. Could we not cache the current format and only do this when the format changes rather than on every device open?
The format itself is kept. But the stream tag and channel assignment are assigned dynamically at each open. Thus, this call has to be reset at each open, at least.
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
For testing, I tried doing this though and disabling the
set_streamid, 0 call insnd_codec_cleanup()but it still missed those first samples. Is there somewhere else I need to be looking?Does it happen without dmix, too?
Yeah, with and without dmix it still misses the first bit.
OK. I just thought of a possibility of dmix bug. Good to know that it's not :)
Quoted 4 lines
The only way it doesn't is if I have another program open the device and sleep, then have the samples play. Actually, an open isn't sufficient, it has to go and set the playback parameters as well.
It's logical since the stream and format ids are assigned dynamically first after the stream is set up.
One another problem is that we currently call azx_stream_reset() in each prepare callback in hda_intel.c. This was newly added because keeping the format id without resetting caused some other serious errors. Maybe this can be optimized for specific hardwares, e.g. skipping the unneeded reset for HDMI/SPDIF.
Takashi