diff --git a/dom/media/mediasink/AudioDecoderInputTrack.cpp b/dom/media/mediasink/AudioDecoderInputTrack.cpp index 1031d47b0ce1..1ec1c0695978 100644 --- a/dom/media/mediasink/AudioDecoderInputTrack.cpp +++ b/dom/media/mediasink/AudioDecoderInputTrack.cpp @@ -353,6 +353,9 @@ void AudioDecoderInputTrack::HandleSPSCData(SPSCData& aData) { if (aData.IsClearFutureData()) { LOG("Clear future data"); mBufferedData.Clear(); + if (mTimeStretcher) { + mTimeStretcher->clear(); + } if (!Ended()) { LOG("Clear EOS"); mReceivedEOS = false; diff --git a/media/libsoundtouch/src/RLBoxSoundTouch.cpp b/media/libsoundtouch/src/RLBoxSoundTouch.cpp index ac4d5e5f6b48..7a7ccfecc2ab 100644 --- a/media/libsoundtouch/src/RLBoxSoundTouch.cpp +++ b/media/libsoundtouch/src/RLBoxSoundTouch.cpp @@ -151,6 +151,10 @@ uint RLBoxSoundTouch::receiveSamples(AudioDataValue* aOutput, return numWrittenSamples; } +void RLBoxSoundTouch::clear() { + return mSandbox.invoke_sandbox_function(Clear, mTimeStretcher); +} + void RLBoxSoundTouch::flush() { return mSandbox.invoke_sandbox_function(Flush, mTimeStretcher); } diff --git a/media/libsoundtouch/src/RLBoxSoundTouch.h b/media/libsoundtouch/src/RLBoxSoundTouch.h index 4ecf54be1f59..ec9152a25bbd 100644 --- a/media/libsoundtouch/src/RLBoxSoundTouch.h +++ b/media/libsoundtouch/src/RLBoxSoundTouch.h @@ -74,6 +74,8 @@ class RLBoxSoundTouch { RLBOX_SOUNDTOUCH_API uint receiveSamples(mozilla::AudioDataValue* aOutput, uint aMaxSamples); RLBOX_SOUNDTOUCH_API + void clear(); + RLBOX_SOUNDTOUCH_API void flush(); RLBOX_SOUNDTOUCH_API diff --git a/media/libsoundtouch/src/RLBoxSoundTouchFactory.cpp b/media/libsoundtouch/src/RLBoxSoundTouchFactory.cpp index 2e3d559641e7..3ebaff9c281a 100644 --- a/media/libsoundtouch/src/RLBoxSoundTouchFactory.cpp +++ b/media/libsoundtouch/src/RLBoxSoundTouchFactory.cpp @@ -56,5 +56,7 @@ uint ReceiveSamples(SoundTouch* mTimeStretcher, SAMPLETYPE* output, return mTimeStretcher->receiveSamples(output, maxSamples); } +void Clear(SoundTouch* mTimeStretcher) { mTimeStretcher->clear(); } + void Flush(SoundTouch* mTimeStretcher) { return mTimeStretcher->flush(); } } diff --git a/media/libsoundtouch/src/RLBoxSoundTouchFactory.h b/media/libsoundtouch/src/RLBoxSoundTouchFactory.h index fe1332e01fa4..a98c45197153 100644 --- a/media/libsoundtouch/src/RLBoxSoundTouchFactory.h +++ b/media/libsoundtouch/src/RLBoxSoundTouchFactory.h @@ -22,5 +22,6 @@ void PutSamples(soundtouch::SoundTouch* mTimeStretcher, const soundtouch::SAMPLETYPE* samples, uint numSamples); uint ReceiveSamples(soundtouch::SoundTouch* mTimeStretcher, soundtouch::SAMPLETYPE* output, uint maxSamples); +void Clear(soundtouch::SoundTouch* mTimeStretcher); void Flush(soundtouch::SoundTouch* mTimeStretcher); }