Chromium Code Reviews| Index: media/base/android/java/src/org/chromium/media/WebAudioMediaCodecBridge.java |
| diff --git a/media/base/android/java/src/org/chromium/media/WebAudioMediaCodecBridge.java b/media/base/android/java/src/org/chromium/media/WebAudioMediaCodecBridge.java |
| index ac752d4d06b2e9c7a2e034bf0997fb5ffdeaed01..5d5e00df3329c4555289ad51ec4c1d63db5c7bfb 100644 |
| --- a/media/base/android/java/src/org/chromium/media/WebAudioMediaCodecBridge.java |
| +++ b/media/base/android/java/src/org/chromium/media/WebAudioMediaCodecBridge.java |
| @@ -61,7 +61,14 @@ class WebAudioMediaCodecBridge { |
| MediaFormat format = extractor.getTrackFormat(0); |
| - int channelCount = format.getInteger(MediaFormat.KEY_CHANNEL_COUNT); |
| + // Number of channels specified in the file |
| + int fileChannelCount = format.getInteger(MediaFormat.KEY_CHANNEL_COUNT); |
|
qinmin
2013/08/09 00:31:55
nit: use inputChannelCount
|
| + |
| + // Number of channels the decoder will provide. (Not |
| + // necessarily the same as fileChannelCount. See |
| + // crbug.com/266006.) |
| + int decoderChannelCount = fileChannelCount; |
|
qinmin
2013/08/09 00:31:55
nit: outputChannelCount
|
| + |
| int sampleRate = format.getInteger(MediaFormat.KEY_SAMPLE_RATE); |
| String mime = format.getString(MediaFormat.KEY_MIME); |
| @@ -77,13 +84,13 @@ class WebAudioMediaCodecBridge { |
| if (DEBUG) { |
| Log.d(LOG_TAG, "Tracks: " + extractor.getTrackCount() |
| + " Rate: " + sampleRate |
| - + " Channels: " + channelCount |
| + + " Channels: " + fileChannelCount |
| + " Mime: " + mime |
| + " Duration: " + durationMicroseconds + " microsec"); |
| } |
| nativeInitializeDestination(nativeMediaCodecBridge, |
| - channelCount, |
| + fileChannelCount, |
| sampleRate, |
| durationMicroseconds); |
| @@ -139,7 +146,8 @@ class WebAudioMediaCodecBridge { |
| ByteBuffer buf = codecOutputBuffers[outputBufIndex]; |
| if (info.size > 0) { |
| - nativeOnChunkDecoded(nativeMediaCodecBridge, buf, info.size); |
| + nativeOnChunkDecoded(nativeMediaCodecBridge, buf, info.size, |
| + fileChannelCount, decoderChannelCount); |
| } |
| buf.clear(); |
| @@ -150,6 +158,10 @@ class WebAudioMediaCodecBridge { |
| } |
| } else if (outputBufIndex == MediaCodec.INFO_OUTPUT_BUFFERS_CHANGED) { |
| codecOutputBuffers = codec.getOutputBuffers(); |
| + } else if (outputBufIndex == MediaCodec.INFO_OUTPUT_FORMAT_CHANGED) { |
| + MediaFormat newFormat = codec.getOutputFormat(); |
| + decoderChannelCount = newFormat.getInteger(MediaFormat.KEY_CHANNEL_COUNT); |
| + Log.d(LOG_TAG, "output format changed to " + newFormat); |
| } |
| } |
| @@ -163,11 +175,12 @@ class WebAudioMediaCodecBridge { |
| } |
| private static native void nativeOnChunkDecoded( |
| - int nativeWebAudioMediaCodecBridge, ByteBuffer buf, int size); |
| + int nativeWebAudioMediaCodecBridge, ByteBuffer buf, int size, |
| + int fileChannelCount, int decoderChannelCount); |
| private static native void nativeInitializeDestination( |
| int nativeWebAudioMediaCodecBridge, |
| - int channelCount, |
| + int fileChannelCount, |
| int sampleRate, |
| long durationMicroseconds); |
| } |