зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1159974 - Mirror mVolume. r=jww
This commit is contained in:
Родитель
a56c0c760e
Коммит
49578f1914
|
@ -290,10 +290,7 @@ void MediaDecoder::Pause()
|
||||||
void MediaDecoder::SetVolume(double aVolume)
|
void MediaDecoder::SetVolume(double aVolume)
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(NS_IsMainThread());
|
MOZ_ASSERT(NS_IsMainThread());
|
||||||
mInitialVolume = aVolume;
|
mVolume = aVolume;
|
||||||
if (mDecoderStateMachine) {
|
|
||||||
mDecoderStateMachine->SetVolume(aVolume);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MediaDecoder::ConnectDecodedStreamToOutputStream(OutputStreamData* aStream)
|
void MediaDecoder::ConnectDecodedStreamToOutputStream(OutputStreamData* aStream)
|
||||||
|
@ -602,7 +599,7 @@ MediaDecoder::MediaDecoder() :
|
||||||
mDecoderPosition(0),
|
mDecoderPosition(0),
|
||||||
mPlaybackPosition(0),
|
mPlaybackPosition(0),
|
||||||
mCurrentTime(0.0),
|
mCurrentTime(0.0),
|
||||||
mInitialVolume(0.0),
|
mVolume(AbstractThread::MainThread(), 0.0, "MediaDecoder::mVolume (Canonical)"),
|
||||||
mInitialPlaybackRate(1.0),
|
mInitialPlaybackRate(1.0),
|
||||||
mInitialPreservesPitch(true),
|
mInitialPreservesPitch(true),
|
||||||
mDuration(-1),
|
mDuration(-1),
|
||||||
|
@ -750,7 +747,6 @@ void MediaDecoder::SetStateMachineParameters()
|
||||||
{
|
{
|
||||||
ReentrantMonitorAutoEnter mon(GetReentrantMonitor());
|
ReentrantMonitorAutoEnter mon(GetReentrantMonitor());
|
||||||
mDecoderStateMachine->SetDuration(mDuration);
|
mDecoderStateMachine->SetDuration(mDuration);
|
||||||
mDecoderStateMachine->SetVolume(mInitialVolume);
|
|
||||||
if (GetDecodedStream()) {
|
if (GetDecodedStream()) {
|
||||||
mDecoderStateMachine->SetAudioCaptured();
|
mDecoderStateMachine->SetAudioCaptured();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1079,9 +1079,11 @@ protected:
|
||||||
// It is read and written from the main thread only.
|
// It is read and written from the main thread only.
|
||||||
double mCurrentTime;
|
double mCurrentTime;
|
||||||
|
|
||||||
// Volume that playback should start at. 0.0 = muted. 1.0 = full
|
// Volume of playback. 0.0 = muted. 1.0 = full volume.
|
||||||
// volume. Readable/Writeable from the main thread.
|
Canonical<double> mVolume;
|
||||||
double mInitialVolume;
|
public:
|
||||||
|
AbstractCanonical<double>* CanonicalVolume() { return &mVolume; }
|
||||||
|
protected:
|
||||||
|
|
||||||
// PlaybackRate and pitch preservation status we should start at.
|
// PlaybackRate and pitch preservation status we should start at.
|
||||||
// Readable/Writeable from the main thread.
|
// Readable/Writeable from the main thread.
|
||||||
|
|
|
@ -226,7 +226,7 @@ MediaDecoderStateMachine::MediaDecoderStateMachine(MediaDecoder* aDecoder,
|
||||||
mDecodedAudioEndTime(-1),
|
mDecodedAudioEndTime(-1),
|
||||||
mVideoFrameEndTime(-1),
|
mVideoFrameEndTime(-1),
|
||||||
mDecodedVideoEndTime(-1),
|
mDecodedVideoEndTime(-1),
|
||||||
mVolume(1.0),
|
mVolume(mTaskQueue, 1.0, "MediaDecoderStateMachine::mVolume (Mirror)"),
|
||||||
mPlaybackRate(1.0),
|
mPlaybackRate(1.0),
|
||||||
mPreservesPitch(true),
|
mPreservesPitch(true),
|
||||||
mLowAudioThresholdUsecs(detail::LOW_AUDIO_USECS),
|
mLowAudioThresholdUsecs(detail::LOW_AUDIO_USECS),
|
||||||
|
@ -307,10 +307,13 @@ MediaDecoderStateMachine::InitializationTask()
|
||||||
// Connect mirrors.
|
// Connect mirrors.
|
||||||
mPlayState.Connect(mDecoder->CanonicalPlayState());
|
mPlayState.Connect(mDecoder->CanonicalPlayState());
|
||||||
mNextPlayState.Connect(mDecoder->CanonicalNextPlayState());
|
mNextPlayState.Connect(mDecoder->CanonicalNextPlayState());
|
||||||
|
mVolume.Connect(mDecoder->CanonicalVolume());
|
||||||
|
|
||||||
// Initialize watchers.
|
// Initialize watchers.
|
||||||
mWatchManager.Watch(mState, &MediaDecoderStateMachine::UpdateNextFrameStatus);
|
mWatchManager.Watch(mState, &MediaDecoderStateMachine::UpdateNextFrameStatus);
|
||||||
mWatchManager.Watch(mAudioCompleted, &MediaDecoderStateMachine::UpdateNextFrameStatus);
|
mWatchManager.Watch(mAudioCompleted, &MediaDecoderStateMachine::UpdateNextFrameStatus);
|
||||||
|
mWatchManager.Watch(mVolume, &MediaDecoderStateMachine::VolumeChanged);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MediaDecoderStateMachine::HasFutureAudio() {
|
bool MediaDecoderStateMachine::HasFutureAudio() {
|
||||||
|
@ -1355,11 +1358,10 @@ void MediaDecoderStateMachine::SetState(State aState)
|
||||||
mSentPlaybackEndedEvent = false;
|
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());
|
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
|
||||||
mVolume = volume;
|
|
||||||
if (mAudioSink) {
|
if (mAudioSink) {
|
||||||
mAudioSink->SetVolume(mVolume);
|
mAudioSink->SetVolume(mVolume);
|
||||||
}
|
}
|
||||||
|
@ -2545,6 +2547,7 @@ MediaDecoderStateMachine::FinishShutdown()
|
||||||
// Disconnect canonicals and mirrors before shutting down our task queue.
|
// Disconnect canonicals and mirrors before shutting down our task queue.
|
||||||
mPlayState.DisconnectIfConnected();
|
mPlayState.DisconnectIfConnected();
|
||||||
mNextPlayState.DisconnectIfConnected();
|
mNextPlayState.DisconnectIfConnected();
|
||||||
|
mVolume.DisconnectIfConnected();
|
||||||
mNextFrameStatus.DisconnectAll();
|
mNextFrameStatus.DisconnectAll();
|
||||||
|
|
||||||
// Shut down the watch manager before shutting down our task queue.
|
// Shut down the watch manager before shutting down our task queue.
|
||||||
|
|
|
@ -152,9 +152,6 @@ public:
|
||||||
return mState;
|
return mState;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the audio volume. The decoder monitor must be obtained before
|
|
||||||
// calling this.
|
|
||||||
void SetVolume(double aVolume);
|
|
||||||
void SetAudioCaptured();
|
void SetAudioCaptured();
|
||||||
|
|
||||||
// Check if the decoder needs to become dormant state.
|
// Check if the decoder needs to become dormant state.
|
||||||
|
@ -447,6 +444,7 @@ protected:
|
||||||
already_AddRefed<AudioData> PopAudio();
|
already_AddRefed<AudioData> PopAudio();
|
||||||
already_AddRefed<VideoData> PopVideo();
|
already_AddRefed<VideoData> PopVideo();
|
||||||
|
|
||||||
|
void VolumeChanged();
|
||||||
|
|
||||||
class WakeDecoderRunnable : public nsRunnable {
|
class WakeDecoderRunnable : public nsRunnable {
|
||||||
public:
|
public:
|
||||||
|
@ -1009,10 +1007,8 @@ protected:
|
||||||
// on decoded video data.
|
// on decoded video data.
|
||||||
int64_t mDecodedVideoEndTime;
|
int64_t mDecodedVideoEndTime;
|
||||||
|
|
||||||
// Volume of playback. 0.0 = muted. 1.0 = full volume. Read/Written
|
// Volume of playback. 0.0 = muted. 1.0 = full volume.
|
||||||
// from the state machine and main threads. Synchronised via decoder
|
Mirror<double> mVolume;
|
||||||
// monitor.
|
|
||||||
double mVolume;
|
|
||||||
|
|
||||||
// Playback rate. 1.0 : normal speed, 0.5 : two times slower. Synchronized via
|
// Playback rate. 1.0 : normal speed, 0.5 : two times slower. Synchronized via
|
||||||
// decoder monitor.
|
// decoder monitor.
|
||||||
|
|
Загрузка…
Ссылка в новой задаче