Bug 784329 - Part 1: Add some OmxPlugin error logging. r=doublec
authorChris Peterson <cpeterson@mozilla.com>
Wed, 22 Aug 2012 18:29:58 -0700
changeset 105412 542e9ac22e76fc3d462add927c788063b940cd9d
parent 105411 3d75661e7e210ac0d83bc7acc30ec870786f87ff
child 105413 d7fb23a822dd7ce3d641dcaa7ca485ee96fafb0e
push id55
push usershu@rfrn.org
push dateThu, 30 Aug 2012 01:33:09 +0000
reviewersdoublec
bugs784329
milestone17.0a1
Bug 784329 - Part 1: Add some OmxPlugin error logging. r=doublec
media/omx-plugin/OmxPlugin.cpp
--- a/media/omx-plugin/OmxPlugin.cpp
+++ b/media/omx-plugin/OmxPlugin.cpp
@@ -12,16 +12,17 @@
 #else
 #include <stagefright/OMXClient.h>
 #endif
 #include "mozilla/Types.h"
 #include "MPAPI.h"
 
 #include "android/log.h"
 
+#undef LOG
 #define LOG(args...)  __android_log_print(ANDROID_LOG_INFO, "OmxPlugin" , ## args)
 
 using namespace MPAPI;
 
 namespace android {
 
 // MediaStreamSource is a DataSource that reads from a MPAPI media stream.
 
@@ -243,31 +244,33 @@ bool OmxDecoder::Init() {
   sp<MediaExtractor> extractor = MediaExtractor::Create(dataSource);
   if (extractor == NULL) {
     return false;
   }
 
   ssize_t audioTrackIndex = -1;
   ssize_t videoTrackIndex = -1;
   const char *audioMime = NULL;
+  const char *videoMime = NULL;
 
   for (size_t i = 0; i < extractor->countTracks(); ++i) {
     sp<MetaData> meta = extractor->getTrackMetaData(i);
 
     int32_t bitRate;
     if (!meta->findInt32(kKeyBitRate, &bitRate))
       bitRate = 0;
 
     const char *mime;
     if (!meta->findCString(kKeyMIMEType, &mime)) {
       continue;
     }
 
     if (videoTrackIndex == -1 && !strncasecmp(mime, "video/", 6)) {
       videoTrackIndex = i;
+      videoMime = mime;
     } else if (audioTrackIndex == -1 && !strncasecmp(mime, "audio/", 6)) {
       audioTrackIndex = i;
       audioMime = mime;
     }
   }
 
   if (videoTrackIndex == -1 && audioTrackIndex == -1) {
     return false;
@@ -297,20 +300,23 @@ bool OmxDecoder::Init() {
   if (videoTrackIndex != -1 && (videoTrack = extractor->getTrack(videoTrackIndex)) != NULL) {
     videoSource = OMXCodec::Create(omx,
                                    videoTrack->getFormat(),
                                    false, // decoder
                                    videoTrack,
                                    NULL,
                                    flags);
     if (videoSource == NULL) {
+      LOG("OMXCodec failed to initialize video decoder for \"%s\"", videoMime);
       return false;
     }
 
-    if (videoSource->start() != OK) {
+    status_t status = videoSource->start();
+    if (status != OK) {
+      LOG("videoSource->start() failed with status %#x", status);
       return false;
     }
 
     int64_t durationUs;
     if (videoTrack->getFormat()->findInt64(kKeyDuration, &durationUs)) {
       if (durationUs > totalDurationUs)
         totalDurationUs = durationUs;
     }
@@ -323,20 +329,25 @@ bool OmxDecoder::Init() {
     if (!strcasecmp(audioMime, "audio/raw")) {
       audioSource = audioTrack;
     } else {
       audioSource = OMXCodec::Create(omx,
                                      audioTrack->getFormat(),
                                      false, // decoder
                                      audioTrack);
     }
+
     if (audioSource == NULL) {
+      LOG("OMXCodec failed to initialize audio decoder for \"%s\"", audioMime);
       return false;
     }
-    if (audioSource->start() != OK) {
+
+    status_t status = audioSource->start();
+    if (status != OK) {
+      LOG("audioSource->start() failed with status %#x", status);
       return false;
     }
 
     int64_t durationUs;
     if (audioTrack->getFormat()->findInt64(kKeyDuration, &durationUs)) {
       if (durationUs > totalDurationUs)
         totalDurationUs = durationUs;
     }
@@ -494,17 +505,17 @@ bool OmxDecoder::ToVideoFrame(VideoFrame
     break;
   case OMX_QCOM_COLOR_FormatYVU420SemiPlanar:
     SemiPlanarYVU420Frame(aFrame, aTimeUs, aData, aSize, aKeyFrame);
     break;
   case OMX_QCOM_COLOR_FormatYVU420PackedSemiPlanar32m4ka:
     SemiPlanarYVU420Packed32m4ka(aFrame, aTimeUs, aData, aSize, aKeyFrame);
     break;
   default:
-    LOG("Unknown video color format: %x", mVideoColorFormat);
+    LOG("Unknown video color format: %#x", mVideoColorFormat);
     return false;
   }
   return true;
 }
 
 bool OmxDecoder::ToAudioFrame(AudioFrame *aFrame, int64_t aTimeUs, void *aData, size_t aDataOffset, size_t aSize, int32_t aAudioChannels, int32_t aAudioSampleRate)
 {
   aFrame->Set(aTimeUs, reinterpret_cast<char *>(aData) + aDataOffset, aSize, aAudioChannels, aAudioSampleRate);