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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/base/android/media_codec_bridge.h" 5 #include "media/base/android/media_codec_bridge.h"
6 6
7 #include <algorithm>
7 8
8 #include "base/android/build_info.h" 9 #include "base/android/build_info.h"
9 #include "base/android/jni_android.h" 10 #include "base/android/jni_android.h"
10 #include "base/android/jni_array.h" 11 #include "base/android/jni_array.h"
11 #include "base/android/jni_string.h" 12 #include "base/android/jni_string.h"
12 #include "base/basictypes.h" 13 #include "base/basictypes.h"
13 #include "base/lazy_instance.h" 14 #include "base/lazy_instance.h"
14 #include "base/logging.h" 15 #include "base/logging.h"
15 #include "base/numerics/safe_conversions.h" 16 #include "base/numerics/safe_conversions.h"
16 #include "base/strings/string_util.h" 17 #include "base/strings/string_util.h"
(...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after
690 break; 691 break;
691 } 692 }
692 default: 693 default:
693 LOG(ERROR) << "Invalid header encountered for codec: " 694 LOG(ERROR) << "Invalid header encountered for codec: "
694 << AudioCodecToAndroidMimeType(codec); 695 << AudioCodecToAndroidMimeType(codec);
695 return false; 696 return false;
696 } 697 }
697 return true; 698 return true;
698 } 699 }
699 700
700 int64 AudioCodecBridge::PlayOutputBuffer(int index, size_t size) { 701 int64 AudioCodecBridge::PlayOutputBuffer(
702 int index, size_t size, size_t offset) {
701 DCHECK_LE(0, index); 703 DCHECK_LE(0, index);
702 int numBytes = base::checked_cast<int>(size); 704 int numBytes = base::checked_cast<int>(size);
703 JNIEnv* env = AttachCurrentThread(); 705 JNIEnv* env = AttachCurrentThread();
704 ScopedJavaLocalRef<jobject> buf = 706 ScopedJavaLocalRef<jobject> buf =
705 Java_MediaCodecBridge_getOutputBuffer(env, media_codec(), index); 707 Java_MediaCodecBridge_getOutputBuffer(env, media_codec(), index);
706 uint8* buffer = static_cast<uint8*>(env->GetDirectBufferAddress(buf.obj())); 708 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.
709 static_cast<uint8*>(env->GetDirectBufferAddress(buf.obj())) + offset;
710
711 int capacity = env->GetDirectBufferCapacity(buf.obj()) - offset;
712 numBytes = std::min(capacity, numBytes);
713 CHECK_LE(numBytes, 0);
707 714
708 ScopedJavaLocalRef<jbyteArray> byte_array = 715 ScopedJavaLocalRef<jbyteArray> byte_array =
709 base::android::ToJavaByteArray(env, buffer, numBytes); 716 base::android::ToJavaByteArray(env, buffer, numBytes);
710 return Java_MediaCodecBridge_playOutputBuffer( 717 return Java_MediaCodecBridge_playOutputBuffer(
711 env, media_codec(), byte_array.obj()); 718 env, media_codec(), byte_array.obj());
712 } 719 }
713 720
714 void AudioCodecBridge::SetVolume(double volume) { 721 void AudioCodecBridge::SetVolume(double volume) {
715 JNIEnv* env = AttachCurrentThread(); 722 JNIEnv* env = AttachCurrentThread();
716 Java_MediaCodecBridge_setVolume(env, media_codec(), volume); 723 Java_MediaCodecBridge_setVolume(env, media_codec(), volume);
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
841 JNIEnv* env = AttachCurrentThread(); 848 JNIEnv* env = AttachCurrentThread();
842 return Java_MediaCodecBridge_isAdaptivePlaybackSupported( 849 return Java_MediaCodecBridge_isAdaptivePlaybackSupported(
843 env, media_codec(), width, height); 850 env, media_codec(), width, height);
844 } 851 }
845 852
846 bool MediaCodecBridge::RegisterMediaCodecBridge(JNIEnv* env) { 853 bool MediaCodecBridge::RegisterMediaCodecBridge(JNIEnv* env) {
847 return RegisterNativesImpl(env); 854 return RegisterNativesImpl(env);
848 } 855 }
849 856
850 } // namespace media 857 } // namespace media
OLDNEW
« 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