Bug 847779 - Abort playback if OMX audio init fails. r=doublec, r=cpearce, a=leo+
authorDiego Wilson <dwilson@codeaurora.org>
Thu, 04 Apr 2013 15:33:45 -0700
changeset 119022 d2d8ae22d88a0dd40c0289025ce3dcd4095fe91f
parent 119021 cb21c4153afa03f822a095dc56da8c1fc8d78f8b
child 119023 47f8fdf13d2b6c2366042091e4f4e601b54dfbcd
push id647
push userryanvm@gmail.com
push dateTue, 09 Apr 2013 21:01:59 +0000
reviewersdoublec, cpearce, leo
bugs847779
milestone18.0
Bug 847779 - Abort playback if OMX audio init fails. r=doublec, r=cpearce, a=leo+
content/media/omx/OmxDecoder.cpp
content/media/omx/nsMediaOmxReader.cpp
--- a/content/media/omx/OmxDecoder.cpp
+++ b/content/media/omx/OmxDecoder.cpp
@@ -326,17 +326,22 @@ bool OmxDecoder::Init() {
   if (mVideoSource.get() && !SetVideoFormat()) {
     NS_WARNING("Couldn't set OMX video format");
     return false;
   }
 
   // To reliably get the channel and sample rate data we need to read from the
   // audio source until we get a INFO_FORMAT_CHANGE status
   if (mAudioSource.get()) {
-    if (mAudioSource->read(&mAudioBuffer) != INFO_FORMAT_CHANGED) {
+    status_t err = mAudioSource->read(&mAudioBuffer);
+    if (err != INFO_FORMAT_CHANGED) {
+      if (err != OK) {
+        NS_WARNING("Couldn't read audio buffer from OMX decoder");
+        return false;
+      }
       sp<MetaData> meta = mAudioSource->getFormat();
       if (!meta->findInt32(kKeyChannelCount, &mAudioChannels) ||
           !meta->findInt32(kKeySampleRate, &mAudioSampleRate)) {
         NS_WARNING("Couldn't get audio metadata from OMX decoder");
         return false;
       }
       mAudioMetadataRead = true;
     }
--- a/content/media/omx/nsMediaOmxReader.cpp
+++ b/content/media/omx/nsMediaOmxReader.cpp
@@ -41,17 +41,19 @@ nsresult nsMediaOmxReader::ReadMetadata(
                                         nsHTMLMediaElement::MetadataTags** aTags)
 {
   NS_ASSERTION(mDecoder->OnDecodeThread(), "Should be on decode thread.");
 
   *aTags = nullptr;
 
   if (!mOmxDecoder.get()) {
     mOmxDecoder = new OmxDecoder(mDecoder->GetResource(), mDecoder);
-    mOmxDecoder->Init();
+    if (!mOmxDecoder->Init()) {
+      return NS_ERROR_FAILURE;
+    }
   }
 
   // Set the total duration (the max of the audio and video track).
   int64_t durationUs;
   mOmxDecoder->GetDuration(&durationUs);
   if (durationUs) {
     ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
     mDecoder->GetStateMachine()->SetDuration(durationUs);