Bug 1166760 - Query audio sampling rate & channel number from codec. r=sotaro
authorMunro Chiang <mchiang@mozilla.com>
Fri, 05 Jun 2015 09:42:33 +0800
changeset 247802 56cb10f6dc1380dc395fd2bbe3558ff19d0c6a46
parent 247801 f5226b854bf4571d0116fc0f22314fcd120d6b22
child 247803 3def91c9ff2408e3c42278386b860a5968eacebd
push id60814
push userkwierso@gmail.com
push dateWed, 10 Jun 2015 02:29:27 +0000
treeherdermozilla-inbound@bc32a90612e5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssotaro
bugs1166760
milestone41.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1166760 - Query audio sampling rate & channel number from codec. r=sotaro
dom/media/platforms/gonk/GonkAudioDecoderManager.cpp
dom/media/platforms/gonk/GonkAudioDecoderManager.h
--- a/dom/media/platforms/gonk/GonkAudioDecoderManager.cpp
+++ b/dom/media/platforms/gonk/GonkAudioDecoderManager.cpp
@@ -252,16 +252,35 @@ GonkAudioDecoderManager::Output(int64_t 
       }
       aOutData = data;
       return NS_OK;
     }
     case android::INFO_FORMAT_CHANGED:
     {
       // If the format changed, update our cached info.
       GADM_LOG("Decoder format changed");
+      sp<AMessage> audioCodecFormat;
+
+      if (mDecoder->getOutputFormat(&audioCodecFormat) != OK ||
+        audioCodecFormat == nullptr) {
+        return NS_ERROR_UNEXPECTED;
+      }
+
+      int32_t codec_channel_count = 0;
+      int32_t codec_sample_rate = 0;
+
+      if (!audioCodecFormat->findInt32("channel-count", &codec_channel_count) ||
+        !audioCodecFormat->findInt32("sample-rate", &codec_sample_rate)) {
+        return NS_ERROR_UNEXPECTED;
+      }
+
+      // Update AudioInfo
+      mAudioChannels = codec_channel_count;
+      mAudioRate = codec_sample_rate;
+
       return Output(aStreamOffset, aOutData);
     }
     case android::INFO_OUTPUT_BUFFERS_CHANGED:
     {
       GADM_LOG("Info Output Buffers Changed");
       if (mDecoder->UpdateOutputBuffers()) {
         return Output(aStreamOffset, aOutData);
       }
--- a/dom/media/platforms/gonk/GonkAudioDecoderManager.h
+++ b/dom/media/platforms/gonk/GonkAudioDecoderManager.h
@@ -40,18 +40,18 @@ public:
 private:
   bool PerformFormatSpecificProcess(MediaRawData* aSample);
 
   nsresult CreateAudioData(int64_t aStreamOffset,
                               AudioData** aOutData);
 
   void ReleaseAudioBuffer();
 
-  const uint32_t mAudioChannels;
-  const uint32_t mAudioRate;
+  uint32_t mAudioChannels;
+  uint32_t mAudioRate;
   const uint32_t mAudioProfile;
   bool mUseAdts;
 
   MediaDataDecoderCallback*  mReaderCallback;
   android::MediaBuffer* mAudioBuffer;
   android::sp<ALooper> mLooper;
 
   // MediaCodedc's wrapper that performs the decoding.