Bug 494035. Never enable tracks we don't use. r=roc

--HG--
extra : rebase_source : ceffc78e6473273893fd1ad000799b32023f5c76
This commit is contained in:
Chris Double 2009-05-25 12:45:47 +12:00
Родитель 1c5f53bc8c
Коммит 1783235e16
1 изменённых файлов: 20 добавлений и 9 удалений

Просмотреть файл

@ -432,6 +432,10 @@ protected:
// media stream.
nsresult Seek(float aTime, nsChannelReader* aReader);
// Sets the current video and audio track to active in liboggplay.
// Called from the decoder thread only.
void SetTracksActive();
private:
// *****
// The follow fields are only accessed by the decoder thread
@ -1494,11 +1498,7 @@ nsresult nsOggDecodeStateMachine::Run()
// Reactivate all tracks. Liboggplay deactivates tracks when it
// reads to the end of stream, but they must be reactivated in order
// to start reading from them again.
for (int i = 0; i < oggplay_get_num_tracks(mPlayer); ++i) {
if (oggplay_set_track_active(mPlayer, i) < 0) {
LOG(PR_LOG_ERROR, ("Could not set track %d active", i));
}
}
SetTracksActive();
mon.Enter();
mDecoder->StartProgressUpdates();
@ -1714,12 +1714,10 @@ void nsOggDecodeStateMachine::LoadOggHeaders(nsChannelReader* aReader)
oggplay_get_audio_channels(mPlayer, i, &mAudioChannels);
LOG(PR_LOG_DEBUG, ("samplerate: %d, channels: %d", mAudioRate, mAudioChannels));
}
if (oggplay_set_track_active(mPlayer, i) < 0) {
LOG(PR_LOG_ERROR, ("Could not set track %d active", i));
}
}
SetTracksActive();
if (mVideoTrack == -1) {
oggplay_set_callback_num_frames(mPlayer, mAudioTrack, OGGPLAY_FRAMES_PER_CALLBACK);
mCallbackPeriod = 1.0 / (float(mAudioRate) / OGGPLAY_FRAMES_PER_CALLBACK);
@ -1758,6 +1756,19 @@ void nsOggDecodeStateMachine::LoadOggHeaders(nsChannelReader* aReader)
}
}
void nsOggDecodeStateMachine::SetTracksActive()
{
if (mVideoTrack != -1 &&
oggplay_set_track_active(mPlayer, mVideoTrack) < 0) {
LOG(PR_LOG_ERROR, ("Could not set track %d active", mVideoTrack));
}
if (mAudioTrack != -1 &&
oggplay_set_track_active(mPlayer, mAudioTrack) < 0) {
LOG(PR_LOG_ERROR, ("Could not set track %d active", mAudioTrack));
}
}
NS_IMPL_THREADSAFE_ISUPPORTS1(nsOggDecoder, nsIObserver)
void nsOggDecoder::Pause()