Bug 1706811 - explicitly restart the media sink in 'UpdateOutputCaptured()' if it was playing before. r=bryce.

When updating the output capture in MDSM, we didn't restart the sink after recreating it. The sink would actually get started later by `MaybeStartPlayback()` that would be checked periodly in the decoding and completed state.

However, we should make it explicitly start if the sink was playing before we recreate it, like what we did for `SetSink()` [1]

[1] https://searchfox.org/mozilla-central/rev/08013752b4638f01d41d2a38ca7bd741bc572c86/dom/media/MediaDecoderStateMachine.cpp#3803-3814

Differential Revision: https://phabricator.services.mozilla.com/D113046
This commit is contained in:
alwu 2021-04-26 18:45:01 +00:00
Родитель 18962da886
Коммит d54e623362
1 изменённых файлов: 5 добавлений и 0 удалений

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

@ -3737,12 +3737,17 @@ void MediaDecoderStateMachine::UpdateOutputCaptured() {
// Don't create a new media sink if we're still suspending media sink.
if (!mIsMediaSinkSuspended) {
const bool wasPlaying = IsPlaying();
// Stop and shut down the existing sink.
StopMediaSink();
mMediaSink->Shutdown();
// Create a new sink according to whether output is captured.
mMediaSink = CreateMediaSink();
if (wasPlaying) {
DebugOnly<nsresult> rv = StartMediaSink();
MOZ_ASSERT(NS_SUCCEEDED(rv));
}
}
// Don't buffer as much when audio is captured because we don't need to worry