diff --git a/content/media/omx/OmxDecoder.cpp b/content/media/omx/OmxDecoder.cpp index b76ab494238..62b2793b1c9 100644 --- a/content/media/omx/OmxDecoder.cpp +++ b/content/media/omx/OmxDecoder.cpp @@ -8,11 +8,10 @@ #include "base/basictypes.h" #include -#include #include #include +#include #include -#include #include "mozilla/Preferences.h" #include "mozilla/Types.h" @@ -170,14 +169,6 @@ 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) { @@ -237,6 +228,13 @@ bool OmxDecoder::Init() { mNativeWindow = new GonkNativeWindow(); + // OMXClient::connect() always returns OK and abort's fatally if + // it can't connect. + OMXClient client; + status_t err = client.connect(); + NS_ASSERTION(err == OK, "Failed to connect to OMX in mediaserver."); + sp omx = client.interface(); + sp videoTrack; sp videoSource; if (videoTrackIndex != -1 && (videoTrack = extractor->getTrack(videoTrackIndex)) != nullptr) { @@ -246,7 +244,7 @@ bool OmxDecoder::Init() { // for (h.264). So if we don't get a hardware decoder, just give // up. int flags = kHardwareCodecsOnly; - videoSource = OMXCodec::Create(GetOMX(), + videoSource = OMXCodec::Create(omx, videoTrack->getFormat(), false, // decoder videoTrack, @@ -296,7 +294,7 @@ bool OmxDecoder::Init() { if (!strcasecmp(audioMime, "audio/raw")) { audioSource = audioTrack; } else { - audioSource = OMXCodec::Create(GetOMX(), + audioSource = OMXCodec::Create(omx, audioTrack->getFormat(), false, // decoder audioTrack); diff --git a/content/media/omx/OmxDecoder.h b/content/media/omx/OmxDecoder.h index 29105c525ff..fd4a57fb971 100644 --- a/content/media/omx/OmxDecoder.h +++ b/content/media/omx/OmxDecoder.h @@ -1,7 +1,5 @@ -#include -#include #include - +#include #include #include "GonkNativeWindow.h"