Bug 1199562. Part 1 - rename mAudioSink to mMediaSink as well as related member names. r=roc.

This commit is contained in:
JW Wang 2015-09-09 10:12:23 +08:00
parent 0e168b5d74
commit 6261cd2cdc
2 changed files with 51 additions and 51 deletions

View File

@ -298,7 +298,7 @@ MediaDecoderStateMachine::MediaDecoderStateMachine(MediaDecoder* aDecoder,
self->mAudioQueue, self->GetMediaTime(),
self->mInfo.mAudio, self->mDecoder->GetAudioChannel());
};
mAudioSink = new AudioSinkWrapper(mTaskQueue, audioSinkCreator);
mMediaSink = new AudioSinkWrapper(mTaskQueue, audioSinkCreator);
}
MediaDecoderStateMachine::~MediaDecoderStateMachine()
@ -377,7 +377,7 @@ int64_t MediaDecoderStateMachine::GetDecodedAudioDuration()
MOZ_ASSERT(OnTaskQueue());
AssertCurrentThreadInMonitor();
int64_t audioDecoded = AudioQueue().Duration();
if (mAudioSink->IsStarted()) {
if (mMediaSink->IsStarted()) {
audioDecoded += AudioEndTime() - GetMediaTime();
}
return audioDecoded;
@ -387,7 +387,7 @@ void MediaDecoderStateMachine::DiscardStreamData()
{
MOZ_ASSERT(OnTaskQueue());
AssertCurrentThreadInMonitor();
MOZ_ASSERT(!mAudioSink->IsStarted(), "Should've been stopped in RunStateMachine()");
MOZ_ASSERT(!mMediaSink->IsStarted(), "Should've been stopped in RunStateMachine()");
const auto clockTime = GetClock();
while (true) {
@ -1077,7 +1077,7 @@ void MediaDecoderStateMachine::MaybeStartPlayback()
SetPlayStartTime(TimeStamp::Now());
MOZ_ASSERT(IsPlaying());
StartAudioSink();
StartMediaSink();
StartDecodedStream();
DispatchDecodeTasksIfNeeded();
@ -1152,7 +1152,7 @@ void MediaDecoderStateMachine::VolumeChanged()
{
MOZ_ASSERT(OnTaskQueue());
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
mAudioSink->SetVolume(mVolume);
mMediaSink->SetVolume(mVolume);
mStreamSink->SetVolume(mVolume);
}
@ -1273,7 +1273,7 @@ void MediaDecoderStateMachine::Shutdown()
Reset();
mAudioSink->Shutdown();
mMediaSink->Shutdown();
// Shut down our start time rendezvous.
if (mStartTimeRendezvous) {
@ -1466,15 +1466,15 @@ MediaDecoderStateMachine::Seek(SeekTarget aTarget)
return mPendingSeek.mPromise.Ensure(__func__);
}
void MediaDecoderStateMachine::StopAudioSink()
void MediaDecoderStateMachine::StopMediaSink()
{
MOZ_ASSERT(OnTaskQueue());
AssertCurrentThreadInMonitor();
if (mAudioSink->IsStarted()) {
DECODER_LOG("Stop AudioSink");
mAudioSink->Stop();
mAudioSinkPromise.DisconnectIfExists();
if (mMediaSink->IsStarted()) {
DECODER_LOG("Stop MediaSink");
mMediaSink->Stop();
mMediaSinkPromise.DisconnectIfExists();
}
}
@ -1752,25 +1752,25 @@ MediaDecoderStateMachine::RequestVideoData()
}
void
MediaDecoderStateMachine::StartAudioSink()
MediaDecoderStateMachine::StartMediaSink()
{
MOZ_ASSERT(OnTaskQueue());
AssertCurrentThreadInMonitor();
if (mAudioCaptured) {
MOZ_ASSERT(!mAudioSink->IsStarted());
MOZ_ASSERT(!mMediaSink->IsStarted());
return;
}
if (!mAudioSink->IsStarted()) {
if (!mMediaSink->IsStarted()) {
mAudioCompleted = false;
mAudioSink->Start(GetMediaTime(), mInfo);
mMediaSink->Start(GetMediaTime(), mInfo);
auto promise = mAudioSink->OnEnded(TrackInfo::kAudioTrack);
auto promise = mMediaSink->OnEnded(TrackInfo::kAudioTrack);
if (promise) {
mAudioSinkPromise.Begin(promise->Then(
mMediaSinkPromise.Begin(promise->Then(
OwnerThread(), __func__, this,
&MediaDecoderStateMachine::OnAudioSinkComplete,
&MediaDecoderStateMachine::OnAudioSinkError));
&MediaDecoderStateMachine::OnMediaSinkComplete,
&MediaDecoderStateMachine::OnMediaSinkError));
}
}
}
@ -1813,7 +1813,7 @@ int64_t MediaDecoderStateMachine::AudioDecodedUsecs()
// The amount of audio we have decoded is the amount of audio data we've
// already decoded and pushed to the hardware, plus the amount of audio
// data waiting to be pushed to the hardware.
int64_t pushed = mAudioSink->IsStarted() ? (AudioEndTime() - GetMediaTime()) : 0;
int64_t pushed = mMediaSink->IsStarted() ? (AudioEndTime() - GetMediaTime()) : 0;
// Currently for real time streams, AudioQueue().Duration() produce
// wrong values (Bug 1114434), so we use frame counts to calculate duration.
@ -1842,7 +1842,7 @@ bool MediaDecoderStateMachine::OutOfDecodedAudio()
MOZ_ASSERT(OnTaskQueue());
return IsAudioDecoding() && !AudioQueue().IsFinished() &&
AudioQueue().GetSize() == 0 &&
!mAudioSink->HasUnplayedFrames(TrackInfo::kAudioTrack);
!mMediaSink->HasUnplayedFrames(TrackInfo::kAudioTrack);
}
bool MediaDecoderStateMachine::HasLowUndecodedData()
@ -2416,7 +2416,7 @@ nsresult MediaDecoderStateMachine::RunStateMachine()
mSentPlaybackEndedEvent = true;
// MediaSink::GetEndTime() must be called before stopping playback.
StopAudioSink();
StopMediaSink();
StopDecodedStream();
}
@ -2443,10 +2443,10 @@ MediaDecoderStateMachine::Reset()
mState == DECODER_STATE_DORMANT ||
mState == DECODER_STATE_DECODING_NONE);
// Stop the audio thread. Otherwise, AudioSink might be accessing AudioQueue
// Stop the audio thread. Otherwise, MediaSink might be accessing AudioQueue
// outside of the decoder monitor while we are clearing the queue and causes
// crash for no samples to be popped.
StopAudioSink();
StopMediaSink();
StopDecodedStream();
mVideoFrameEndTime = -1;
@ -2588,7 +2588,7 @@ int64_t MediaDecoderStateMachine::GetClock(TimeStamp* aTimeStamp) const
if (mAudioCaptured) {
clock_time = mStreamSink->GetPosition(&t);
} else {
clock_time = mAudioSink->GetPosition(&t);
clock_time = mMediaSink->GetPosition(&t);
}
NS_ASSERTION(GetMediaTime() <= clock_time, "Clock should go forwards.");
}
@ -2880,7 +2880,7 @@ void MediaDecoderStateMachine::SetPlayStartTime(const TimeStamp& aTimeStamp)
AssertCurrentThreadInMonitor();
mPlayStartTime = aTimeStamp;
mAudioSink->SetPlaying(!mPlayStartTime.IsNull());
mMediaSink->SetPlaying(!mPlayStartTime.IsNull());
mStreamSink->SetPlaying(!mPlayStartTime.IsNull());
}
@ -2959,7 +2959,7 @@ MediaDecoderStateMachine::LogicalPlaybackRateChanged()
}
mPlaybackRate = mLogicalPlaybackRate;
mAudioSink->SetPlaybackRate(mPlaybackRate);
mMediaSink->SetPlaybackRate(mPlaybackRate);
ScheduleStateMachine();
}
@ -2968,7 +2968,7 @@ void MediaDecoderStateMachine::PreservesPitchChanged()
{
MOZ_ASSERT(OnTaskQueue());
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
mAudioSink->SetPreservesPitch(mPreservesPitch);
mMediaSink->SetPreservesPitch(mPreservesPitch);
}
bool MediaDecoderStateMachine::IsShutdown()
@ -2982,8 +2982,8 @@ MediaDecoderStateMachine::AudioEndTime() const
{
MOZ_ASSERT(OnTaskQueue());
AssertCurrentThreadInMonitor();
if (mAudioSink->IsStarted()) {
return mAudioSink->GetEndTime(TrackInfo::kAudioTrack);
if (mMediaSink->IsStarted()) {
return mMediaSink->GetEndTime(TrackInfo::kAudioTrack);
} else if (mAudioCaptured) {
return mStreamSink->GetEndTime(TrackInfo::kAudioTrack);
}
@ -2991,23 +2991,23 @@ MediaDecoderStateMachine::AudioEndTime() const
return -1;
}
void MediaDecoderStateMachine::OnAudioSinkComplete()
void MediaDecoderStateMachine::OnMediaSinkComplete()
{
MOZ_ASSERT(OnTaskQueue());
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
MOZ_ASSERT(!mAudioCaptured, "Should be disconnected when capturing audio.");
mAudioSinkPromise.Complete();
mMediaSinkPromise.Complete();
mAudioCompleted = true;
}
void MediaDecoderStateMachine::OnAudioSinkError()
void MediaDecoderStateMachine::OnMediaSinkError()
{
MOZ_ASSERT(OnTaskQueue());
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
MOZ_ASSERT(!mAudioCaptured, "Should be disconnected when capturing audio.");
mAudioSinkPromise.Complete();
mMediaSinkPromise.Complete();
mAudioCompleted = true;
// Make the best effort to continue playback when there is video.
@ -3063,8 +3063,8 @@ void MediaDecoderStateMachine::DispatchAudioCaptured()
MOZ_ASSERT(self->OnTaskQueue());
ReentrantMonitorAutoEnter mon(self->mDecoder->GetReentrantMonitor());
if (!self->mAudioCaptured) {
// Stop the audio sink if it's running.
self->StopAudioSink();
// Stop the media sink if it's running.
self->StopMediaSink();
self->mAudioCaptured = true;
// Start DecodedStream if we are already playing. Otherwise it will be
// handled in MaybeStartPlayback().
@ -3086,10 +3086,10 @@ void MediaDecoderStateMachine::DispatchAudioUncaptured()
ReentrantMonitorAutoEnter mon(self->mDecoder->GetReentrantMonitor());
if (self->mAudioCaptured) {
self->StopDecodedStream();
// Start again the audio sink.
// Start again the media sink.
self->mAudioCaptured = false;
if (self->IsPlaying()) {
self->StartAudioSink();
self->StartMediaSink();
}
self->ScheduleStateMachine();
}

View File

@ -489,15 +489,15 @@ protected:
// state machine thread.
void UpdateRenderedVideoFrames();
// Stops the audio sink and shut it down.
// Stops the media sink and shut it down.
// The decoder monitor must be held with exactly one lock count.
// Called on the state machine thread.
void StopAudioSink();
void StopMediaSink();
// Create and start the audio sink.
// Create and start the media sink.
// The decoder monitor must be held with exactly one lock count.
// Called on the state machine thread.
void StartAudioSink();
void StartMediaSink();
void StopDecodedStream();
@ -648,12 +648,12 @@ protected:
void SetPlayStartTime(const TimeStamp& aTimeStamp);
private:
// Resolved by the AudioSink to signal that all outstanding work is complete
// Resolved by the MediaSink to signal that all outstanding work is complete
// and the sink is shutting down.
void OnAudioSinkComplete();
void OnMediaSinkComplete();
// Rejected by the AudioSink to signal errors.
void OnAudioSinkError();
// Rejected by the MediaSink to signal errors.
void OnMediaSinkError();
void OnDecodedStreamFinish();
@ -977,15 +977,15 @@ private:
// Media Fragment end time in microseconds. Access controlled by decoder monitor.
int64_t mFragmentEndTime;
// The audio sink resource. Used on the state machine thread.
nsRefPtr<media::MediaSink> mAudioSink;
// The media sink resource. Used on the state machine thread.
nsRefPtr<media::MediaSink> mMediaSink;
// The reader, don't call its methods with the decoder monitor held.
// This is created in the state machine's constructor.
nsRefPtr<MediaDecoderReader> mReader;
// The end time of the last audio frame that's been pushed onto the audio sink
// or DecodedStream in microseconds. This will approximately be the end time
// The end time of the last audio frame that's been pushed onto the media sink
// in microseconds. This will approximately be the end time
// of the audio stream, unless another frame is pushed to the hardware.
int64_t AudioEndTime() const;
@ -1270,7 +1270,7 @@ private:
// Media data resource from the decoder.
nsRefPtr<MediaResource> mResource;
MozPromiseRequestHolder<GenericPromise> mAudioSinkPromise;
MozPromiseRequestHolder<GenericPromise> mMediaSinkPromise;
MozPromiseRequestHolder<GenericPromise> mDecodedStreamPromise;
MediaEventListener mAudioQueueListener;