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

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: 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
« no previous file with comments | « no previous file | media/base/android/webaudio_media_codec_bridge.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..1de7e42b8d274baabc6a3e73cf1de28638d21292 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 inputChannelCount = format.getInteger(MediaFormat.KEY_CHANNEL_COUNT);
+
+ // Number of channels the decoder will provide. (Not
+ // necessarily the same as inputChannelCount. See
+ // crbug.com/266006.)
+ int outputChannelCount = inputChannelCount;
+
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: " + inputChannelCount
+ " Mime: " + mime
+ " Duration: " + durationMicroseconds + " microsec");
}
nativeInitializeDestination(nativeMediaCodecBridge,
- channelCount,
+ inputChannelCount,
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,
+ inputChannelCount, outputChannelCount);
}
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();
+ outputChannelCount = 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 inputChannelCount, int outputChannelCount);
private static native void nativeInitializeDestination(
int nativeWebAudioMediaCodecBridge,
- int channelCount,
+ int inputChannelCount,
int sampleRate,
long durationMicroseconds);
}
« no previous file with comments | « no previous file | media/base/android/webaudio_media_codec_bridge.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698