void MediaSourceReader::MaybeNotifyHaveData() { ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor()); bool haveAudio = false, haveVideo = false; bool ended = IsEnded(); // If we are in ended mode, we will resolve any pending wait promises. // The next Request*Data will handle END_OF_STREAM or going back into waiting // mode. if (!IsSeeking() && mAudioTrack) { if (!mLastAudioTime) { nsRefPtr<SourceBufferDecoder> d = FirstDecoder(MediaData::AUDIO_DATA); haveAudio = !!d; } else { haveAudio = HaveData(mLastAudioTime, MediaData::AUDIO_DATA); } if (ended || haveAudio) { WaitPromise(MediaData::AUDIO_DATA).ResolveIfExists(MediaData::AUDIO_DATA, __func__); } } if (!IsSeeking() && mVideoTrack) { if (!mLastVideoTime) { nsRefPtr<SourceBufferDecoder> d = FirstDecoder(MediaData::VIDEO_DATA); haveVideo = !!d; } else { haveVideo = HaveData(mLastVideoTime, MediaData::VIDEO_DATA); } if (ended || haveVideo) { WaitPromise(MediaData::VIDEO_DATA).ResolveIfExists(MediaData::VIDEO_DATA, __func__); } } MSE_DEBUG("isSeeking=%d haveAudio=%d, haveVideo=%d ended=%d", IsSeeking(), haveAudio, haveVideo, ended); }
void MediaSourceReader::MaybeNotifyHaveData() { ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor()); bool haveAudio = false, haveVideo = false; if (!mAudioIsSeeking && mAudioTrack && HaveData(mLastAudioTime, MediaData::AUDIO_DATA)) { haveAudio = true; WaitPromise(MediaData::AUDIO_DATA).ResolveIfExists(MediaData::AUDIO_DATA, __func__); } if (!mVideoIsSeeking && mVideoTrack && HaveData(mLastVideoTime, MediaData::VIDEO_DATA)) { haveVideo = true; WaitPromise(MediaData::VIDEO_DATA).ResolveIfExists(MediaData::VIDEO_DATA, __func__); } MSE_DEBUG("MediaSourceReader(%p)::MaybeNotifyHaveData haveAudio=%d, haveVideo=%d", this, haveAudio, haveVideo); }
nsRefPtr<MediaDecoderReader::WaitForDataPromise> MediaSourceReader::WaitForData(MediaData::Type aType) { ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor()); nsRefPtr<WaitForDataPromise> p = WaitPromise(aType).Ensure(__func__); MaybeNotifyHaveData(); return p; }