Bug 1368490 - Make sure number of channels is correctly set for opus encoder. r=jesup
☠☠ backed out by 15e32469eb04 ☠ ☠
authorBryce Van Dyk <bvandyk@mozilla.com>
Tue, 30 May 2017 21:01:02 +1200
changeset 412321 26e9faf36fc093367053243daf9ff3a1663dcdd9
parent 412320 58553590b6f2cab6e98011cad5df539a82edc266
child 412322 c52cd79ee39d895b4bd607b1c28b94a3d5b8d70b
push id1490
push usermtabara@mozilla.com
push dateMon, 31 Jul 2017 14:08:16 +0000
treeherdermozilla-release@70e32e6bf15e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjesup
bugs1368490
milestone55.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 1368490 - Make sure number of channels is correctly set for opus encoder. r=jesup
dom/media/encoder/TrackEncoder.cpp
--- a/dom/media/encoder/TrackEncoder.cpp
+++ b/dom/media/encoder/TrackEncoder.cpp
@@ -138,29 +138,31 @@ AudioTrackEncoder::AppendAudioSegment(co
 
 /*static*/
 void
 AudioTrackEncoder::InterleaveTrackData(AudioChunk& aChunk,
                                        int32_t aDuration,
                                        uint32_t aOutputChannels,
                                        AudioDataValue* aOutput)
 {
+  uint32_t numChannelsToCopy = std::min(aOutputChannels,
+                                        aChunk.mChannelData.Length());
   switch(aChunk.mBufferFormat) {
     case AUDIO_FORMAT_S16: {
       AutoTArray<const int16_t*, 2> array;
-      array.SetLength(aOutputChannels);
+      array.SetLength(numChannelsToCopy);
       for (uint32_t i = 0; i < array.Length(); i++) {
         array[i] = static_cast<const int16_t*>(aChunk.mChannelData[i]);
       }
       InterleaveTrackData(array, aDuration, aOutputChannels, aOutput, aChunk.mVolume);
       break;
     }
     case AUDIO_FORMAT_FLOAT32: {
       AutoTArray<const float*, 2> array;
-      array.SetLength(aOutputChannels);
+      array.SetLength(numChannelsToCopy);
       for (uint32_t i = 0; i < array.Length(); i++) {
         array[i] = static_cast<const float*>(aChunk.mChannelData[i]);
       }
       InterleaveTrackData(array, aDuration, aOutputChannels, aOutput, aChunk.mVolume);
       break;
    }
    case AUDIO_FORMAT_SILENCE: {
       MOZ_ASSERT(false, "To implement.");