[mythtv] frontend not handling audio sample rate changes
Jim Westfall
jwestfall at surrealistic.net
Sun Feb 13 04:19:34 UTC 2005
Hi
I finally got a frontend box fast enough to handle HD mpeg2 via firewire
and have notice that the frontend isnt handling audio sample rate changes.
When I switch from HD -> SD the sample rate usually goes from 48000Hz to
32000Hz on the mpeg stream. When this change happens its detected by the
decoder, but the information is never passed back up to the
nuppelvideoplayer to reinit the audio. I end up with everyone sounding
like mice and frame drops from the player trying to keep audio/video in
sync.
I think I know what the issue is but am not sure how to go about fixing
it.
GetFrame() {
if currentAudioTrack == -1
autoSelectAudioTrack()
get block of data from backend
while data in block {
stuff
CheckAudioParams(stream->sample_rate,stream->channel)
}
}
CheckAudioParams(new_rate,new_channel) {
compare new_rate/rate and new_channel/channel
if changed {
SetupAudioStream();
m_parent->ReinitAudio();
}
}
SetupAudioStream() {
if currentAudioTrack == -1
return
update local rate/channels
m_parent->SetAudioParams(16, audio_channels, audio_sampling_rate);
}
autoSelectAudioTrack() {
pick a track
SetupAudioStream();
}
In the while loop of GetFrame the audio sample rate changes, which will
trigger a callback function (HandleStreamChange), which in turn sets
currentAudioTrack = -1.
CheckAudioParams() will register the changed audio format, and calls
SetupAudioStream() and m_parent->ReinitAudio(). SetupAudioStream()
short circuits because currentAudioTrack is -1 and never tells m_parent
the new audio params. This happens over and over, until that
block of data from the backend has been used.
Next time GetFrame is called currentAudioTrack is -1 so autoSelectAudioTrack()
is called and picks a track for us. autoSelectAudioTrack() calls
SetupAudioStream() which wont short circuit and updates we locally think
the rate/channels is. It also tells m_parent the new audio params
(never told to reinit).
Now we are back to the while loop in GetFrame(), when CheckAudioParams()
is called stream->sample_rate and stream->channels match what we know
locally. We end up being stuck with a sample rate mismatch between
decoder and player.
jim
More information about the mythtv-dev
mailing list