Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(679)

Unified Diff: media/base/android/java/src/org/chromium/media/WebAudioMediaCodecBridge.java

Issue 21618002: Fix slow playback of 1-channel MP3 and AAC files for WebAudio on Android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: New implementation Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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);
}
« no previous file with comments | « no previous file | media/base/android/webaudio_media_codec_bridge.h » ('j') | media/base/android/webaudio_media_codec_bridge.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698