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

Unified Diff: media/base/android/media_codec_bridge.cc

Issue 1285733002: Pass buffer offset to PlayOutputBuffer() call (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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 | « media/base/android/media_codec_bridge.h ('k') | media/base/android/media_codec_decoder.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/base/android/media_codec_bridge.cc
diff --git a/media/base/android/media_codec_bridge.cc b/media/base/android/media_codec_bridge.cc
index f076b218e1a6f3baf45eac97276dc656f4b7f0dd..58ada83bdc058dc8e7dd4ef53483d5d3da61547a 100644
--- a/media/base/android/media_codec_bridge.cc
+++ b/media/base/android/media_codec_bridge.cc
@@ -4,6 +4,7 @@
#include "media/base/android/media_codec_bridge.h"
+#include <algorithm>
#include "base/android/build_info.h"
#include "base/android/jni_android.h"
@@ -697,13 +698,19 @@ bool AudioCodecBridge::ConfigureMediaFormat(jobject j_format,
return true;
}
-int64 AudioCodecBridge::PlayOutputBuffer(int index, size_t size) {
+int64 AudioCodecBridge::PlayOutputBuffer(
+ int index, size_t size, size_t offset) {
DCHECK_LE(0, index);
int numBytes = base::checked_cast<int>(size);
JNIEnv* env = AttachCurrentThread();
ScopedJavaLocalRef<jobject> buf =
Java_MediaCodecBridge_getOutputBuffer(env, media_codec(), index);
- uint8* buffer = static_cast<uint8*>(env->GetDirectBufferAddress(buf.obj()));
+ uint8* buffer =
Tima Vaisburd 2015/08/11 19:25:40 nit: This code is almost the same as in CopyFromOu
qinmin 2015/08/20 18:34:21 Done.
+ static_cast<uint8*>(env->GetDirectBufferAddress(buf.obj())) + offset;
+
+ int capacity = env->GetDirectBufferCapacity(buf.obj()) - offset;
+ numBytes = std::min(capacity, numBytes);
+ CHECK_LE(numBytes, 0);
ScopedJavaLocalRef<jbyteArray> byte_array =
base::android::ToJavaByteArray(env, buffer, numBytes);
« no previous file with comments | « media/base/android/media_codec_bridge.h ('k') | media/base/android/media_codec_decoder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698