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

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

Issue 215783002: Fix an issue that audio and video may run out of sync (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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/MediaCodecBridge.java
diff --git a/media/base/android/java/src/org/chromium/media/MediaCodecBridge.java b/media/base/android/java/src/org/chromium/media/MediaCodecBridge.java
index 29181ff69bcb52b1968fbd506119f26ca50a1ebb..25dad12d0fc035a2fa082df8117e3676f10e8c01 100644
--- a/media/base/android/java/src/org/chromium/media/MediaCodecBridge.java
+++ b/media/base/android/java/src/org/chromium/media/MediaCodecBridge.java
@@ -280,6 +280,8 @@ class MediaCodecBridge {
try {
mFlushed = true;
if (mAudioTrack != null) {
+ // Need to call pause() here, or otherwise flush() is a no-op.
+ mAudioTrack.pause();
mAudioTrack.flush();
}
mMediaCodec.flush();
@@ -516,7 +518,7 @@ class MediaCodecBridge {
}
@CalledByNative
- private void playOutputBuffer(byte[] buf) {
+ private long playOutputBuffer(byte[] buf) {
if (mAudioTrack != null) {
if (AudioTrack.PLAYSTATE_PLAYING != mAudioTrack.getPlayState()) {
mAudioTrack.play();
@@ -526,7 +528,14 @@ class MediaCodecBridge {
Log.i(TAG, "Failed to send all data to audio output, expected size: " +
buf.length + ", actual size: " + size);
}
+ // TODO(qinmin): return the head position allows us to estimate
wolenetz 2014/04/01 18:15:47 nit:s/return/Returning/
qinmin 2014/04/01 20:42:34 Done.
+ // the current presentation time in native code. However, it is
+ // better to use AudioTrack.getCurrentTimestamp() to get the last
+ // known time when a frame is played. However, we will need to
+ // convert the java nano time to C++ timestamp.
wolenetz 2014/04/01 18:15:47 Why don't we do this? Also, we should account for
qinmin 2014/04/01 20:42:34 This CL fixes the general AV sync issue in both JB
+ return mAudioTrack.getPlaybackHeadPosition();
}
+ return 0;
}
@CalledByNative

Powered by Google App Engine
This is Rietveld 408576698