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

Side by Side Diff: webrtc/modules/audio_device/android/audio_track_jni.cc

Issue 1722083002: Replace scoped_ptr with unique_ptr in webrtc/modules/audio_device/ (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 10 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
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 13 matching lines...) Expand all
24 #define ALOGD(...) __android_log_print(ANDROID_LOG_DEBUG, TAG, __VA_ARGS__) 24 #define ALOGD(...) __android_log_print(ANDROID_LOG_DEBUG, TAG, __VA_ARGS__)
25 #define ALOGE(...) __android_log_print(ANDROID_LOG_ERROR, TAG, __VA_ARGS__) 25 #define ALOGE(...) __android_log_print(ANDROID_LOG_ERROR, TAG, __VA_ARGS__)
26 #define ALOGW(...) __android_log_print(ANDROID_LOG_WARN, TAG, __VA_ARGS__) 26 #define ALOGW(...) __android_log_print(ANDROID_LOG_WARN, TAG, __VA_ARGS__)
27 #define ALOGI(...) __android_log_print(ANDROID_LOG_INFO, TAG, __VA_ARGS__) 27 #define ALOGI(...) __android_log_print(ANDROID_LOG_INFO, TAG, __VA_ARGS__)
28 28
29 namespace webrtc { 29 namespace webrtc {
30 30
31 // AudioTrackJni::JavaAudioTrack implementation. 31 // AudioTrackJni::JavaAudioTrack implementation.
32 AudioTrackJni::JavaAudioTrack::JavaAudioTrack( 32 AudioTrackJni::JavaAudioTrack::JavaAudioTrack(
33 NativeRegistration* native_reg, 33 NativeRegistration* native_reg,
34 rtc::scoped_ptr<GlobalRef> audio_track) 34 std::unique_ptr<GlobalRef> audio_track)
35 : audio_track_(std::move(audio_track)), 35 : audio_track_(std::move(audio_track)),
36 init_playout_(native_reg->GetMethodId("initPlayout", "(II)V")), 36 init_playout_(native_reg->GetMethodId("initPlayout", "(II)V")),
37 start_playout_(native_reg->GetMethodId("startPlayout", "()Z")), 37 start_playout_(native_reg->GetMethodId("startPlayout", "()Z")),
38 stop_playout_(native_reg->GetMethodId("stopPlayout", "()Z")), 38 stop_playout_(native_reg->GetMethodId("stopPlayout", "()Z")),
39 set_stream_volume_(native_reg->GetMethodId("setStreamVolume", "(I)Z")), 39 set_stream_volume_(native_reg->GetMethodId("setStreamVolume", "(I)Z")),
40 get_stream_max_volume_( 40 get_stream_max_volume_(
41 native_reg->GetMethodId("getStreamMaxVolume", "()I")), 41 native_reg->GetMethodId("getStreamMaxVolume", "()I")),
42 get_stream_volume_(native_reg->GetMethodId("getStreamVolume", "()I")) {} 42 get_stream_volume_(native_reg->GetMethodId("getStreamVolume", "()I")) {}
43 43
44 AudioTrackJni::JavaAudioTrack::~JavaAudioTrack() {} 44 AudioTrackJni::JavaAudioTrack::~JavaAudioTrack() {}
(...skipping 17 matching lines...) Expand all
62 int AudioTrackJni::JavaAudioTrack::GetStreamMaxVolume() { 62 int AudioTrackJni::JavaAudioTrack::GetStreamMaxVolume() {
63 return audio_track_->CallIntMethod(get_stream_max_volume_); 63 return audio_track_->CallIntMethod(get_stream_max_volume_);
64 } 64 }
65 65
66 int AudioTrackJni::JavaAudioTrack::GetStreamVolume() { 66 int AudioTrackJni::JavaAudioTrack::GetStreamVolume() {
67 return audio_track_->CallIntMethod(get_stream_volume_); 67 return audio_track_->CallIntMethod(get_stream_volume_);
68 } 68 }
69 69
70 // TODO(henrika): possible extend usage of AudioManager and add it as member. 70 // TODO(henrika): possible extend usage of AudioManager and add it as member.
71 AudioTrackJni::AudioTrackJni(AudioManager* audio_manager) 71 AudioTrackJni::AudioTrackJni(AudioManager* audio_manager)
72 : j_environment_(JVM::GetInstance()->environment()), 72 : j_environment_(rtc::ScopedToUnique(JVM::GetInstance()->environment())),
73 audio_parameters_(audio_manager->GetPlayoutAudioParameters()), 73 audio_parameters_(audio_manager->GetPlayoutAudioParameters()),
74 direct_buffer_address_(nullptr), 74 direct_buffer_address_(nullptr),
75 direct_buffer_capacity_in_bytes_(0), 75 direct_buffer_capacity_in_bytes_(0),
76 frames_per_buffer_(0), 76 frames_per_buffer_(0),
77 initialized_(false), 77 initialized_(false),
78 playing_(false), 78 playing_(false),
79 audio_device_buffer_(nullptr) { 79 audio_device_buffer_(nullptr) {
80 ALOGD("ctor%s", GetThreadInfo().c_str()); 80 ALOGD("ctor%s", GetThreadInfo().c_str());
81 RTC_DCHECK(audio_parameters_.is_valid()); 81 RTC_DCHECK(audio_parameters_.is_valid());
82 RTC_CHECK(j_environment_); 82 RTC_CHECK(j_environment_);
83 JNINativeMethod native_methods[] = { 83 JNINativeMethod native_methods[] = {
84 {"nativeCacheDirectBufferAddress", "(Ljava/nio/ByteBuffer;J)V", 84 {"nativeCacheDirectBufferAddress", "(Ljava/nio/ByteBuffer;J)V",
85 reinterpret_cast<void*>( 85 reinterpret_cast<void*>(
86 &webrtc::AudioTrackJni::CacheDirectBufferAddress)}, 86 &webrtc::AudioTrackJni::CacheDirectBufferAddress)},
87 {"nativeGetPlayoutData", "(IJ)V", 87 {"nativeGetPlayoutData", "(IJ)V",
88 reinterpret_cast<void*>(&webrtc::AudioTrackJni::GetPlayoutData)}}; 88 reinterpret_cast<void*>(&webrtc::AudioTrackJni::GetPlayoutData)}};
89 j_native_registration_ = j_environment_->RegisterNatives( 89 j_native_registration_ = rtc::ScopedToUnique(j_environment_->RegisterNatives(
90 "org/webrtc/voiceengine/WebRtcAudioTrack", 90 "org/webrtc/voiceengine/WebRtcAudioTrack",
91 native_methods, arraysize(native_methods)); 91 native_methods, arraysize(native_methods)));
92 j_audio_track_.reset(new JavaAudioTrack( 92 j_audio_track_.reset(new JavaAudioTrack(
93 j_native_registration_.get(), 93 j_native_registration_.get(),
94 j_native_registration_->NewObject( 94 rtc::ScopedToUnique(j_native_registration_->NewObject(
95 "<init>", "(Landroid/content/Context;J)V", 95 "<init>", "(Landroid/content/Context;J)V",
96 JVM::GetInstance()->context(), PointerTojlong(this)))); 96 JVM::GetInstance()->context(), PointerTojlong(this)))));
97 // Detach from this thread since we want to use the checker to verify calls 97 // Detach from this thread since we want to use the checker to verify calls
98 // from the Java based audio thread. 98 // from the Java based audio thread.
99 thread_checker_java_.DetachFromThread(); 99 thread_checker_java_.DetachFromThread();
100 } 100 }
101 101
102 AudioTrackJni::~AudioTrackJni() { 102 AudioTrackJni::~AudioTrackJni() {
103 ALOGD("~dtor%s", GetThreadInfo().c_str()); 103 ALOGD("~dtor%s", GetThreadInfo().c_str());
104 RTC_DCHECK(thread_checker_.CalledOnValidThread()); 104 RTC_DCHECK(thread_checker_.CalledOnValidThread());
105 Terminate(); 105 Terminate();
106 } 106 }
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 return; 251 return;
252 } 252 }
253 RTC_DCHECK_EQ(static_cast<size_t>(samples), frames_per_buffer_); 253 RTC_DCHECK_EQ(static_cast<size_t>(samples), frames_per_buffer_);
254 // Copy decoded data into common byte buffer to ensure that it can be 254 // Copy decoded data into common byte buffer to ensure that it can be
255 // written to the Java based audio track. 255 // written to the Java based audio track.
256 samples = audio_device_buffer_->GetPlayoutData(direct_buffer_address_); 256 samples = audio_device_buffer_->GetPlayoutData(direct_buffer_address_);
257 RTC_DCHECK_EQ(length, kBytesPerFrame * samples); 257 RTC_DCHECK_EQ(length, kBytesPerFrame * samples);
258 } 258 }
259 259
260 } // namespace webrtc 260 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/audio_device/android/audio_track_jni.h ('k') | webrtc/modules/audio_device/android/build_info.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698