Bug 1159974 - Mirror mVolume. r=jww

This commit is contained in:
Bobby Holley 2015-04-29 17:27:32 -07:00
Родитель a56c0c760e
Коммит 49578f1914
4 изменённых файлов: 17 добавлений и 20 удалений

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

@ -290,10 +290,7 @@ void MediaDecoder::Pause()
void MediaDecoder::SetVolume(double aVolume)
{
MOZ_ASSERT(NS_IsMainThread());
mInitialVolume = aVolume;
if (mDecoderStateMachine) {
mDecoderStateMachine->SetVolume(aVolume);
}
mVolume = aVolume;
}
void MediaDecoder::ConnectDecodedStreamToOutputStream(OutputStreamData* aStream)
@ -602,7 +599,7 @@ MediaDecoder::MediaDecoder() :
mDecoderPosition(0),
mPlaybackPosition(0),
mCurrentTime(0.0),
mInitialVolume(0.0),
mVolume(AbstractThread::MainThread(), 0.0, "MediaDecoder::mVolume (Canonical)"),
mInitialPlaybackRate(1.0),
mInitialPreservesPitch(true),
mDuration(-1),
@ -750,7 +747,6 @@ void MediaDecoder::SetStateMachineParameters()
{
ReentrantMonitorAutoEnter mon(GetReentrantMonitor());
mDecoderStateMachine->SetDuration(mDuration);
mDecoderStateMachine->SetVolume(mInitialVolume);
if (GetDecodedStream()) {
mDecoderStateMachine->SetAudioCaptured();
}

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

@ -1079,9 +1079,11 @@ protected:
// It is read and written from the main thread only.
double mCurrentTime;
// Volume that playback should start at. 0.0 = muted. 1.0 = full
// volume. Readable/Writeable from the main thread.
double mInitialVolume;
// Volume of playback. 0.0 = muted. 1.0 = full volume.
Canonical<double> mVolume;
public:
AbstractCanonical<double>* CanonicalVolume() { return &mVolume; }
protected:
// PlaybackRate and pitch preservation status we should start at.
// Readable/Writeable from the main thread.

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

@ -226,7 +226,7 @@ MediaDecoderStateMachine::MediaDecoderStateMachine(MediaDecoder* aDecoder,
mDecodedAudioEndTime(-1),
mVideoFrameEndTime(-1),
mDecodedVideoEndTime(-1),
mVolume(1.0),
mVolume(mTaskQueue, 1.0, "MediaDecoderStateMachine::mVolume (Mirror)"),
mPlaybackRate(1.0),
mPreservesPitch(true),
mLowAudioThresholdUsecs(detail::LOW_AUDIO_USECS),
@ -307,10 +307,13 @@ MediaDecoderStateMachine::InitializationTask()
// Connect mirrors.
mPlayState.Connect(mDecoder->CanonicalPlayState());
mNextPlayState.Connect(mDecoder->CanonicalNextPlayState());
mVolume.Connect(mDecoder->CanonicalVolume());
// Initialize watchers.
mWatchManager.Watch(mState, &MediaDecoderStateMachine::UpdateNextFrameStatus);
mWatchManager.Watch(mAudioCompleted, &MediaDecoderStateMachine::UpdateNextFrameStatus);
mWatchManager.Watch(mVolume, &MediaDecoderStateMachine::VolumeChanged);
}
bool MediaDecoderStateMachine::HasFutureAudio() {
@ -1355,11 +1358,10 @@ void MediaDecoderStateMachine::SetState(State aState)
mSentPlaybackEndedEvent = false;
}
void MediaDecoderStateMachine::SetVolume(double volume)
void MediaDecoderStateMachine::VolumeChanged()
{
NS_ASSERTION(NS_IsMainThread(), "Should be on main thread.");
MOZ_ASSERT(OnTaskQueue());
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
mVolume = volume;
if (mAudioSink) {
mAudioSink->SetVolume(mVolume);
}
@ -2545,6 +2547,7 @@ MediaDecoderStateMachine::FinishShutdown()
// Disconnect canonicals and mirrors before shutting down our task queue.
mPlayState.DisconnectIfConnected();
mNextPlayState.DisconnectIfConnected();
mVolume.DisconnectIfConnected();
mNextFrameStatus.DisconnectAll();
// Shut down the watch manager before shutting down our task queue.

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

@ -152,9 +152,6 @@ public:
return mState;
}
// Set the audio volume. The decoder monitor must be obtained before
// calling this.
void SetVolume(double aVolume);
void SetAudioCaptured();
// Check if the decoder needs to become dormant state.
@ -447,6 +444,7 @@ protected:
already_AddRefed<AudioData> PopAudio();
already_AddRefed<VideoData> PopVideo();
void VolumeChanged();
class WakeDecoderRunnable : public nsRunnable {
public:
@ -1009,10 +1007,8 @@ protected:
// on decoded video data.
int64_t mDecodedVideoEndTime;
// Volume of playback. 0.0 = muted. 1.0 = full volume. Read/Written
// from the state machine and main threads. Synchronised via decoder
// monitor.
double mVolume;
// Volume of playback. 0.0 = muted. 1.0 = full volume.
Mirror<double> mVolume;
// Playback rate. 1.0 : normal speed, 0.5 : two times slower. Synchronized via
// decoder monitor.