зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1706747 - make AudioSink's start time exactly same as the start time of AudioSinkWrapper. r=bryce.
AudioSink's`mStartTime` [1] represents the time when the MediaSink starts. Currently that is initialized by calling `GetMediaTime()` [2], but we should better let the time explicitly equal to the start time of the media sink [3] (they're currently equal, but not easy to notice that by just looking the code). So we should let AudioSinkWrapper to pass the start time to AudioSink in order to make the invariant clearer, which is that AudioSinkWrapper and AudioSink should be guaranteed having the same start time. [1] https://searchfox.org/mozilla-central/rev/08013752b4638f01d41d2a38ca7bd741bc572c86/dom/media/mediasink/AudioSink.h#93 [2] https://searchfox.org/mozilla-central/rev/08013752b4638f01d41d2a38ca7bd741bc572c86/dom/media/MediaDecoderStateMachine.cpp#2831 [3] https://searchfox.org/mozilla-central/rev/08013752b4638f01d41d2a38ca7bd741bc572c86/dom/media/MediaDecoderStateMachine.cpp#3388 Differential Revision: https://phabricator.services.mozilla.com/D113016
This commit is contained in:
Родитель
fa71ff1b81
Коммит
18962da886
|
@ -2825,10 +2825,10 @@ MediaSink* MediaDecoderStateMachine::CreateAudioSink() {
|
|||
}
|
||||
|
||||
RefPtr<MediaDecoderStateMachine> self = this;
|
||||
auto audioSinkCreator = [self]() {
|
||||
auto audioSinkCreator = [self](const media::TimeUnit& aStartTime) {
|
||||
MOZ_ASSERT(self->OnTaskQueue());
|
||||
AudioSink* audioSink =
|
||||
new AudioSink(self->mTaskQueue, self->mAudioQueue, self->GetMediaTime(),
|
||||
new AudioSink(self->mTaskQueue, self->mAudioQueue, aStartTime,
|
||||
self->Info().mAudio, self->mSinkDevice.Ref());
|
||||
self->mAudibleListener.DisconnectIfExists();
|
||||
self->mAudibleListener = audioSink->AudibleEvent().Connect(
|
||||
|
|
|
@ -171,7 +171,7 @@ nsresult AudioSinkWrapper::Start(const TimeUnit& aStartTime,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
mAudioSink.reset(mCreator->Create());
|
||||
mAudioSink.reset(mCreator->Create(aStartTime));
|
||||
Result<already_AddRefed<MediaSink::EndedPromise>, nsresult> rv =
|
||||
mAudioSink->Start(mParams);
|
||||
if (rv.isErr()) {
|
||||
|
|
|
@ -30,7 +30,7 @@ class AudioSinkWrapper : public MediaSink {
|
|||
class Creator {
|
||||
public:
|
||||
virtual ~Creator() = default;
|
||||
virtual AudioSink* Create() = 0;
|
||||
virtual AudioSink* Create(const media::TimeUnit& aStartTime) = 0;
|
||||
};
|
||||
|
||||
// Wrap around a function object which creates AudioSinks.
|
||||
|
@ -38,7 +38,9 @@ class AudioSinkWrapper : public MediaSink {
|
|||
class CreatorImpl : public Creator {
|
||||
public:
|
||||
explicit CreatorImpl(const Function& aFunc) : mFunction(aFunc) {}
|
||||
AudioSink* Create() override { return mFunction(); }
|
||||
AudioSink* Create(const media::TimeUnit& aStartTime) override {
|
||||
return mFunction(aStartTime);
|
||||
}
|
||||
|
||||
private:
|
||||
Function mFunction;
|
||||
|
|
Загрузка…
Ссылка в новой задаче