Chromium Code Reviews| 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 3f1506113848f1cecd9dd045f6def102e8b2d946..cbfccfd2f80d1b099afa442e62b4d69ab2df9045 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(); |
| @@ -521,7 +523,7 @@ class MediaCodecBridge { |
| } |
| @CalledByNative |
| - private void playOutputBuffer(byte[] buf) { |
| + private long playOutputBuffer(byte[] buf) { |
|
wolenetz
2014/04/03 18:14:40
nit: I'm less familiar with Chromium java coding s
qinmin
2014/04/03 21:59:45
Done. Java doc added.
On 2014/04/03 18:14:40, wol
|
| if (mAudioTrack != null) { |
| if (AudioTrack.PLAYSTATE_PLAYING != mAudioTrack.getPlayState()) { |
| mAudioTrack.play(); |
| @@ -531,7 +533,17 @@ class MediaCodecBridge { |
| Log.i(TAG, "Failed to send all data to audio output, expected size: " + |
| buf.length + ", actual size: " + size); |
| } |
| + // TODO(qinmin): Returning the head position allows us to estimate |
| + // 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. |
| + // If the stream runs too long, getPlaybackHeadPosition() could |
| + // overflow. AudioTimestampHelper in MediaSourcePlayer has the same |
| + // issue. See crbug.com/358801. |
|
wolenetz
2014/04/03 18:14:40
nit: s/crbug.com/http:\/\/crbug.com/
qinmin
2014/04/03 21:59:45
Done.
|
| + return mAudioTrack.getPlaybackHeadPosition(); |
| } |
| + return 0; |
|
wolenetz
2014/04/03 18:14:40
Might we ever call this method when |mAudioTrack|
qinmin
2014/04/03 21:59:45
This should never happen in our code. The if state
|
| } |
| @CalledByNative |