From aeeac1a8b17ff508ab508eaaf9da2e64654a69e9 Mon Sep 17 00:00:00 2001 From: Sotaro Ikeda Date: Mon, 6 May 2013 08:43:18 -0400 Subject: [PATCH] Bug 864180 - Move audio software decoder to app's process. r=doublec --- content/media/omx/OmxDecoder.cpp | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/content/media/omx/OmxDecoder.cpp b/content/media/omx/OmxDecoder.cpp index e2b2a5a929a..924a345e84c 100644 --- a/content/media/omx/OmxDecoder.cpp +++ b/content/media/omx/OmxDecoder.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include "mozilla/Preferences.h" #include "mozilla/Types.h" @@ -171,6 +172,14 @@ public: } }; +static sp sOMX = nullptr; +static sp GetOMX() { + if(sOMX.get() == nullptr) { + sOMX = new OMX; + } + return sOMX; +} + bool OmxDecoder::Init() { #ifdef PR_LOGGING if (!gOmxDecoderLog) { @@ -297,14 +306,28 @@ bool OmxDecoder::Init() { if (!strcasecmp(audioMime, "audio/raw")) { audioSource = audioTrack; } else { + // try to load hardware codec in mediaserver process. + int flags = kHardwareCodecsOnly; audioSource = OMXCodec::Create(omx, audioTrack->getFormat(), false, // decoder - audioTrack); + audioTrack, + nullptr, + flags); } if (audioSource == nullptr) { - NS_WARNING("Couldn't create OMX audio source"); - return false; + // try to load software codec in this process. + int flags = kSoftwareCodecsOnly; + audioSource = OMXCodec::Create(GetOMX(), + audioTrack->getFormat(), + false, // decoder + audioTrack, + nullptr, + flags); + if (audioSource == nullptr) { + NS_WARNING("Couldn't create OMX audio source"); + return false; + } } if (audioSource->start() != OK) { NS_WARNING("Couldn't start OMX audio source");