Bug 1567389 - change OpusDataDecoder to check for CreateDecoderParams::Option::DefaultPlaybackDeviceMono instead of calling IsDefaultPlaybackDeviceMono(). r=bryce

Differential Revision: https://phabricator.services.mozilla.com/D41113

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Michael Froman 2019-08-08 19:17:27 +00:00
Родитель 17a829aba4
Коммит ec71e08cf2
5 изменённых файлов: 27 добавлений и 5 удалений

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

@ -19,6 +19,7 @@
#include "RemoteMediaDataDecoder.h"
#include "RemoteVideoDecoder.h"
#include "OpusDecoder.h"
#include "VideoUtils.h"
#include "VorbisDecoder.h"
#include "WAVDecoder.h"
@ -105,6 +106,16 @@ already_AddRefed<MediaDataDecoder> RemoteDecoderModule::CreateAudioDecoder(
return nullptr;
}
// OpusDataDecoder will check this option to provide the same info
// that IsDefaultPlaybackDeviceMono provides. We want to avoid calls
// to IsDefaultPlaybackDeviceMono on RDD because initializing audio
// backends on RDD will be blocked by the sandbox.
CreateDecoderParams::OptionSet options(aParams.mOptions);
if (OpusDataDecoder::IsOpus(aParams.mConfig.mMimeType) &&
IsDefaultPlaybackDeviceMono()) {
options += CreateDecoderParams::Option::DefaultPlaybackDeviceMono;
}
RefPtr<RemoteAudioDecoderChild> child = new RemoteAudioDecoderChild();
MediaResult result(NS_OK);
// We can use child as a ref here because this is a sync dispatch. In
@ -116,7 +127,7 @@ already_AddRefed<MediaDataDecoder> RemoteDecoderModule::CreateAudioDecoder(
// thread during this single dispatch.
RefPtr<Runnable> task =
NS_NewRunnableFunction("RemoteDecoderModule::CreateAudioDecoder", [&]() {
result = child->InitIPDL(aParams.AudioConfig(), aParams.mOptions);
result = child->InitIPDL(aParams.AudioConfig(), options);
if (NS_FAILED(result)) {
// Release RemoteAudioDecoderChild here, while we're on
// manager thread. Don't just let the RefPtr go out of scope.

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

@ -53,6 +53,8 @@ struct MOZ_STACK_CLASS CreateDecoderParams final {
// initialization data are dropped. Pass this
// option to raise an error if frames are
// delivered before initialization data.
DefaultPlaybackDeviceMono, // Currently only used by Opus on RDD to avoid
// initialization of audio backends on RDD
SENTINEL // one past the last valid value
};

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

@ -88,7 +88,14 @@ already_AddRefed<MediaDataDecoder> AgnosticDecoderModule::CreateAudioDecoder(
if (VorbisDataDecoder::IsVorbis(config.mMimeType)) {
m = new VorbisDataDecoder(aParams);
} else if (OpusDataDecoder::IsOpus(config.mMimeType)) {
m = new OpusDataDecoder(aParams);
CreateDecoderParams params(aParams);
// Check IsDefaultPlaybackDeviceMono here and set the option in
// mOptions so OpusDataDecoder doesn't have to do it later (in case
// it is running on RDD).
if (IsDefaultPlaybackDeviceMono()) {
params.mOptions += CreateDecoderParams::Option::DefaultPlaybackDeviceMono;
}
m = new OpusDataDecoder(params);
} else if (WaveDataDecoder::IsWave(config.mMimeType)) {
m = new WaveDataDecoder(aParams);
}

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

@ -35,7 +35,9 @@ OpusDataDecoder::OpusDataDecoder(const CreateDecoderParams& aParams)
mDecodedHeader(false),
mPaddingDiscarded(false),
mFrames(0),
mChannelMap(AudioConfig::ChannelLayout::UNKNOWN_MAP) {}
mChannelMap(AudioConfig::ChannelLayout::UNKNOWN_MAP),
mDefaultPlaybackDeviceMono(aParams.mOptions.contains(
CreateDecoderParams::Option::DefaultPlaybackDeviceMono)) {}
OpusDataDecoder::~OpusDataDecoder() {
if (mOpusDecoder) {
@ -99,8 +101,7 @@ RefPtr<MediaDataDecoder::InitPromise> OpusDataDecoder::Init() {
// needs to be disabled when the output is downmixed to mono. Playback number
// of channels are set in AudioSink, using the same method
// `DecideAudioPlaybackChannels()`, and triggers downmix if needed.
if (IsDefaultPlaybackDeviceMono() ||
DecideAudioPlaybackChannels(mInfo) == 1) {
if (mDefaultPlaybackDeviceMono || DecideAudioPlaybackChannels(mInfo) == 1) {
opus_multistream_decoder_ctl(mOpusDecoder,
OPUS_SET_PHASE_INVERSION_DISABLED(1));
}

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

@ -68,6 +68,7 @@ class OpusDataDecoder : public MediaDataDecoder,
Maybe<int64_t> mLastFrameTime;
AutoTArray<uint8_t, 8> mMappingTable;
AudioConfig::ChannelLayout::ChannelMap mChannelMap;
bool mDefaultPlaybackDeviceMono;
};
} // namespace mozilla