зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1183007. Part 2 - remove dependency on MDSM::OnAudioEndTimeUpdate from AudioSink. r=kinetik.
This commit is contained in:
Родитель
0f6631a522
Коммит
b9ea1d076e
|
@ -16,39 +16,6 @@ extern PRLogModuleInfo* gMediaDecoderLog;
|
|||
#define SINK_LOG_V(msg, ...) \
|
||||
MOZ_LOG(gMediaDecoderLog, LogLevel::Verbose, ("AudioSink=%p " msg, this, ##__VA_ARGS__))
|
||||
|
||||
AudioSink::OnAudioEndTimeUpdateTask::OnAudioEndTimeUpdateTask(
|
||||
MediaDecoderStateMachine* aStateMachine)
|
||||
: mMutex("OnAudioEndTimeUpdateTask")
|
||||
, mEndTime(0)
|
||||
, mStateMachine(aStateMachine)
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
AudioSink::OnAudioEndTimeUpdateTask::Run() {
|
||||
MutexAutoLock lock(mMutex);
|
||||
if (mStateMachine) {
|
||||
mStateMachine->OnAudioEndTimeUpdate(mEndTime);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
AudioSink::OnAudioEndTimeUpdateTask::Dispatch(int64_t aEndTime) {
|
||||
MutexAutoLock lock(mMutex);
|
||||
if (mStateMachine) {
|
||||
mEndTime = aEndTime;
|
||||
nsRefPtr<AudioSink::OnAudioEndTimeUpdateTask> runnable(this);
|
||||
mStateMachine->TaskQueue()->Dispatch(runnable.forget());
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
AudioSink::OnAudioEndTimeUpdateTask::Cancel() {
|
||||
MutexAutoLock lock(mMutex);
|
||||
mStateMachine = nullptr;
|
||||
}
|
||||
|
||||
// The amount of audio frames that is used to fuzz rounding errors.
|
||||
static const int64_t AUDIO_FUZZ_FRAMES = 1;
|
||||
|
||||
|
@ -68,7 +35,6 @@ AudioSink::AudioSink(MediaDecoderStateMachine* aStateMachine,
|
|||
, mSetPlaybackRate(false)
|
||||
, mSetPreservesPitch(false)
|
||||
, mPlaying(true)
|
||||
, mOnAudioEndTimeUpdateTask(new OnAudioEndTimeUpdateTask(aStateMachine))
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -132,7 +98,6 @@ AudioSink::PrepareToShutdown()
|
|||
void
|
||||
AudioSink::Shutdown()
|
||||
{
|
||||
mOnAudioEndTimeUpdateTask->Cancel();
|
||||
mThread->Shutdown();
|
||||
mThread = nullptr;
|
||||
MOZ_ASSERT(!mAudioStream);
|
||||
|
@ -218,10 +183,6 @@ AudioSink::AudioLoop()
|
|||
} else {
|
||||
mWritten += PlayFromAudioQueue();
|
||||
}
|
||||
int64_t endTime = GetEndTime();
|
||||
if (endTime != -1) {
|
||||
mOnAudioEndTimeUpdateTask->Dispatch(endTime);
|
||||
}
|
||||
}
|
||||
ReentrantMonitorAutoEnter mon(GetReentrantMonitor());
|
||||
MOZ_ASSERT(mStopAudioThread || AudioQueue().AtEndOfStream());
|
||||
|
@ -427,7 +388,7 @@ AudioSink::WriteSilence(uint32_t aFrames)
|
|||
}
|
||||
|
||||
int64_t
|
||||
AudioSink::GetEndTime()
|
||||
AudioSink::GetEndTime() const
|
||||
{
|
||||
CheckedInt64 playedUsecs = FramesToUsecs(mWritten, mInfo.mRate) + mStartTime;
|
||||
if (!playedUsecs.isValid()) {
|
||||
|
|
|
@ -27,6 +27,9 @@ public:
|
|||
|
||||
int64_t GetPosition();
|
||||
|
||||
// Thread-safe. Can be called on any thread.
|
||||
int64_t GetEndTime() const;
|
||||
|
||||
// Check whether we've pushed more frames to the audio hardware than it has
|
||||
// played.
|
||||
bool HasUnplayedFrames();
|
||||
|
@ -90,8 +93,6 @@ private:
|
|||
void StartAudioStreamPlaybackIfNeeded();
|
||||
void WriteSilence(uint32_t aFrames);
|
||||
|
||||
int64_t GetEndTime();
|
||||
|
||||
MediaQueue<AudioData>& AudioQueue();
|
||||
|
||||
ReentrantMonitor& GetReentrantMonitor();
|
||||
|
@ -124,7 +125,7 @@ private:
|
|||
// stream error.
|
||||
int64_t mLastGoodPosition;
|
||||
|
||||
AudioInfo mInfo;
|
||||
const AudioInfo mInfo;
|
||||
|
||||
dom::AudioChannel mChannel;
|
||||
|
||||
|
@ -139,23 +140,6 @@ private:
|
|||
bool mSetPreservesPitch;
|
||||
|
||||
bool mPlaying;
|
||||
|
||||
class OnAudioEndTimeUpdateTask : public nsRunnable {
|
||||
public:
|
||||
explicit OnAudioEndTimeUpdateTask(MediaDecoderStateMachine* aStateMachine);
|
||||
|
||||
NS_IMETHOD Run() override;
|
||||
|
||||
void Dispatch(int64_t aEndTime);
|
||||
void Cancel();
|
||||
|
||||
private:
|
||||
Mutex mMutex;
|
||||
int64_t mEndTime;
|
||||
nsRefPtr<MediaDecoderStateMachine> mStateMachine;
|
||||
};
|
||||
|
||||
nsRefPtr<OnAudioEndTimeUpdateTask> mOnAudioEndTimeUpdateTask;
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -3075,6 +3075,9 @@ MediaDecoderStateMachine::AudioEndTime() const
|
|||
{
|
||||
MOZ_ASSERT(OnTaskQueue());
|
||||
AssertCurrentThreadInMonitor();
|
||||
if (mAudioSink) {
|
||||
return mAudioSink->GetEndTime();
|
||||
}
|
||||
return mAudioEndTime;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче