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

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

Issue 1945273002: Revert of Use actual audio channel count in Spitzer audio decoder (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bug607024
Patch Set: Created 4 years, 7 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/sdk_media_codec_bridge.h ('k') | media/filters/android/media_codec_audio_decoder.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/base/android/sdk_media_codec_bridge.cc
diff --git a/media/base/android/sdk_media_codec_bridge.cc b/media/base/android/sdk_media_codec_bridge.cc
index 6a04a34eceaf8b428c39dbe7c792a782893ba900..5dd7d539244b68046f5dd14085592e9d764d8682 100644
--- a/media/base/android/sdk_media_codec_bridge.cc
+++ b/media/base/android/sdk_media_codec_bridge.cc
@@ -314,11 +314,25 @@
return MEDIA_CODEC_OK;
}
-MediaCodecStatus SdkMediaCodecBridge::GetOutputBufferAddress(
- int index,
- size_t offset,
- const uint8_t** addr,
- size_t* capacity) {
+MediaCodecStatus SdkMediaCodecBridge::CopyFromOutputBuffer(int index,
+ size_t offset,
+ void* dst,
+ size_t num) {
+ void* src_data = nullptr;
+ size_t src_capacity = 0;
+ MediaCodecStatus status =
+ GetOutputBufferAddress(index, offset, &src_data, &src_capacity);
+ if (status == MEDIA_CODEC_OK) {
+ CHECK_GE(src_capacity, num);
+ memcpy(dst, src_data, num);
+ }
+ return status;
+}
+
+MediaCodecStatus SdkMediaCodecBridge::GetOutputBufferAddress(int index,
+ size_t offset,
+ void** addr,
+ size_t* capacity) {
JNIEnv* env = AttachCurrentThread();
ScopedJavaLocalRef<jobject> j_buffer(
Java_MediaCodecBridge_getOutputBuffer(env, j_media_codec_.obj(), index));
@@ -326,9 +340,9 @@
return MEDIA_CODEC_ERROR;
const size_t total_capacity = env->GetDirectBufferCapacity(j_buffer.obj());
CHECK_GE(total_capacity, offset);
- *addr = reinterpret_cast<const uint8_t*>(
- env->GetDirectBufferAddress(j_buffer.obj())) +
- offset;
+ *addr =
+ reinterpret_cast<uint8_t*>(env->GetDirectBufferAddress(j_buffer.obj())) +
+ offset;
*capacity = total_capacity - offset;
return MEDIA_CODEC_OK;
}
@@ -565,7 +579,7 @@
DCHECK_LE(0, index);
int numBytes = base::checked_cast<int>(size);
- const uint8_t* buffer = nullptr;
+ void* buffer = nullptr;
size_t capacity = 0;
MediaCodecStatus status =
GetOutputBufferAddress(index, offset, &buffer, &capacity);
@@ -576,8 +590,8 @@
CHECK_GE(numBytes, 0);
JNIEnv* env = AttachCurrentThread();
- ScopedJavaLocalRef<jbyteArray> byte_array =
- base::android::ToJavaByteArray(env, buffer, numBytes);
+ ScopedJavaLocalRef<jbyteArray> byte_array = base::android::ToJavaByteArray(
+ env, static_cast<uint8_t*>(buffer), numBytes);
*playback_pos = Java_MediaCodecBridge_playOutputBuffer(
env, media_codec(), byte_array.obj(), postpone);
return status;
« no previous file with comments | « media/base/android/sdk_media_codec_bridge.h ('k') | media/filters/android/media_codec_audio_decoder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698