зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1894110 - Graceful failure path for soundtouch sandbox creation failure r=glandium,media-playback-reviewers,padenot
Differential Revision: https://phabricator.services.mozilla.com/D208947
This commit is contained in:
Родитель
ded46257b8
Коммит
c16c8e0871
|
@ -7,6 +7,7 @@ _ZN7mozilla15RLBoxSoundTouch13setSampleRateEj
|
|||
_ZN7mozilla15RLBoxSoundTouch14receiveSamplesEPfj
|
||||
_ZN7mozilla15RLBoxSoundTouch18resizeSampleBufferEj
|
||||
_ZN7mozilla15RLBoxSoundTouch21numUnprocessedSamplesEv
|
||||
_ZN7mozilla15RLBoxSoundTouch4InitEv
|
||||
_ZN7mozilla15RLBoxSoundTouch5flushEv
|
||||
_ZN7mozilla15RLBoxSoundTouch7setRateEd
|
||||
_ZN7mozilla15RLBoxSoundTouch8setPitchEd
|
||||
|
|
|
@ -168,7 +168,12 @@ size_t AudioStream::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const {
|
|||
nsresult AudioStream::EnsureTimeStretcherInitialized() {
|
||||
AssertIsOnAudioThread();
|
||||
if (!mTimeStretcher) {
|
||||
mTimeStretcher = new RLBoxSoundTouch();
|
||||
auto timestretcher = MakeUnique<RLBoxSoundTouch>();
|
||||
if (!timestretcher || !timestretcher->Init()) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
mTimeStretcher = timestretcher.release();
|
||||
|
||||
mTimeStretcher->setSampleRate(mAudioClock.GetInputRate());
|
||||
mTimeStretcher->setChannels(mOutChannels);
|
||||
mTimeStretcher->setPitch(1.0);
|
||||
|
|
|
@ -621,6 +621,9 @@ void AudioDecoderInputTrack::EnsureTimeStretcher() {
|
|||
AssertOnGraphThread();
|
||||
if (!mTimeStretcher) {
|
||||
mTimeStretcher = new RLBoxSoundTouch();
|
||||
MOZ_RELEASE_ASSERT(mTimeStretcher);
|
||||
MOZ_RELEASE_ASSERT(mTimeStretcher->Init());
|
||||
|
||||
mTimeStretcher->setSampleRate(Graph()->GraphRate());
|
||||
mTimeStretcher->setChannels(GetChannelCountForTimeStretcher());
|
||||
mTimeStretcher->setPitch(1.0);
|
||||
|
|
|
@ -10,24 +10,36 @@ using namespace rlbox;
|
|||
using namespace mozilla;
|
||||
using namespace soundtouch;
|
||||
|
||||
RLBoxSoundTouch::RLBoxSoundTouch() {
|
||||
RLBoxSoundTouch::RLBoxSoundTouch() {}
|
||||
|
||||
bool RLBoxSoundTouch::Init() {
|
||||
#ifdef MOZ_WASM_SANDBOXING_SOUNDTOUCH
|
||||
mSandbox.create_sandbox(true /* infallible */);
|
||||
const bool success = mSandbox.create_sandbox(false /* infallible */);
|
||||
#else
|
||||
const bool success = true;
|
||||
mSandbox.create_sandbox();
|
||||
#endif
|
||||
|
||||
if (!success){
|
||||
return false;
|
||||
}
|
||||
|
||||
mTimeStretcher = mSandbox.invoke_sandbox_function(createSoundTouchObj);
|
||||
|
||||
// Allocate buffer in sandbox to receive samples.
|
||||
mSampleBuffer = mSandbox.malloc_in_sandbox<AudioDataValue>(mSampleBufferSize);
|
||||
MOZ_RELEASE_ASSERT(mSampleBuffer);
|
||||
mCreated = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
RLBoxSoundTouch::~RLBoxSoundTouch() {
|
||||
mSandbox.free_in_sandbox(mSampleBuffer);
|
||||
mSandbox.invoke_sandbox_function(destroySoundTouchObj, mTimeStretcher);
|
||||
mTimeStretcher = nullptr;
|
||||
mSandbox.destroy_sandbox();
|
||||
if (mCreated) {
|
||||
mSandbox.free_in_sandbox(mSampleBuffer);
|
||||
mSandbox.invoke_sandbox_function(destroySoundTouchObj, mTimeStretcher);
|
||||
mTimeStretcher = nullptr;
|
||||
mSandbox.destroy_sandbox();
|
||||
}
|
||||
}
|
||||
|
||||
void RLBoxSoundTouch::setSampleRate(uint aRate) {
|
||||
|
|
|
@ -48,6 +48,8 @@ class RLBoxSoundTouch {
|
|||
RLBOX_SOUNDTOUCH_API
|
||||
RLBoxSoundTouch();
|
||||
RLBOX_SOUNDTOUCH_API
|
||||
bool Init();
|
||||
RLBOX_SOUNDTOUCH_API
|
||||
~RLBoxSoundTouch();
|
||||
|
||||
RLBOX_SOUNDTOUCH_API
|
||||
|
@ -76,6 +78,7 @@ class RLBoxSoundTouch {
|
|||
void flush();
|
||||
|
||||
private:
|
||||
bool mCreated{false};
|
||||
uint mChannels{0};
|
||||
rlbox_sandbox_soundtouch mSandbox;
|
||||
tainted_soundtouch<mozilla::AudioDataValue*> mSampleBuffer{nullptr};
|
||||
|
|
Загрузка…
Ссылка в новой задаче