| OLD | NEW |
| 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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_(rtc::ScopedToUnique(JVM::GetInstance()->environment())), | 72 : j_environment_(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_ = rtc::ScopedToUnique(j_environment_->RegisterNatives( | 89 j_native_registration_ = j_environment_->RegisterNatives( |
| 90 "org/webrtc/voiceengine/WebRtcAudioTrack", | 90 "org/webrtc/voiceengine/WebRtcAudioTrack", native_methods, |
| 91 native_methods, arraysize(native_methods))); | 91 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 rtc::ScopedToUnique(j_native_registration_->NewObject( | 94 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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 return; | 254 return; |
| 255 } | 255 } |
| 256 RTC_DCHECK_EQ(static_cast<size_t>(samples), frames_per_buffer_); | 256 RTC_DCHECK_EQ(static_cast<size_t>(samples), frames_per_buffer_); |
| 257 // Copy decoded data into common byte buffer to ensure that it can be | 257 // Copy decoded data into common byte buffer to ensure that it can be |
| 258 // written to the Java based audio track. | 258 // written to the Java based audio track. |
| 259 samples = audio_device_buffer_->GetPlayoutData(direct_buffer_address_); | 259 samples = audio_device_buffer_->GetPlayoutData(direct_buffer_address_); |
| 260 RTC_DCHECK_EQ(length, kBytesPerFrame * samples); | 260 RTC_DCHECK_EQ(length, kBytesPerFrame * samples); |
| 261 } | 261 } |
| 262 | 262 |
| 263 } // namespace webrtc | 263 } // namespace webrtc |
| OLD | NEW |