| 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 15 matching lines...) Expand all Loading... |
| 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 std::unique_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)Z")), |
| 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() {} |
| 45 | 45 |
| 46 void AudioTrackJni::JavaAudioTrack::InitPlayout(int sample_rate, int channels) { | 46 bool AudioTrackJni::JavaAudioTrack::InitPlayout(int sample_rate, int channels) { |
| 47 audio_track_->CallVoidMethod(init_playout_, sample_rate, channels); | 47 return audio_track_->CallBooleanMethod(init_playout_, sample_rate, channels); |
| 48 } | 48 } |
| 49 | 49 |
| 50 bool AudioTrackJni::JavaAudioTrack::StartPlayout() { | 50 bool AudioTrackJni::JavaAudioTrack::StartPlayout() { |
| 51 return audio_track_->CallBooleanMethod(start_playout_); | 51 return audio_track_->CallBooleanMethod(start_playout_); |
| 52 } | 52 } |
| 53 | 53 |
| 54 bool AudioTrackJni::JavaAudioTrack::StopPlayout() { | 54 bool AudioTrackJni::JavaAudioTrack::StopPlayout() { |
| 55 return audio_track_->CallBooleanMethod(stop_playout_); | 55 return audio_track_->CallBooleanMethod(stop_playout_); |
| 56 } | 56 } |
| 57 | 57 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 116 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 117 StopPlayout(); | 117 StopPlayout(); |
| 118 return 0; | 118 return 0; |
| 119 } | 119 } |
| 120 | 120 |
| 121 int32_t AudioTrackJni::InitPlayout() { | 121 int32_t AudioTrackJni::InitPlayout() { |
| 122 ALOGD("InitPlayout%s", GetThreadInfo().c_str()); | 122 ALOGD("InitPlayout%s", GetThreadInfo().c_str()); |
| 123 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 123 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 124 RTC_DCHECK(!initialized_); | 124 RTC_DCHECK(!initialized_); |
| 125 RTC_DCHECK(!playing_); | 125 RTC_DCHECK(!playing_); |
| 126 j_audio_track_->InitPlayout( | 126 if (!j_audio_track_->InitPlayout( |
| 127 audio_parameters_.sample_rate(), audio_parameters_.channels()); | 127 audio_parameters_.sample_rate(), audio_parameters_.channels())) { |
| 128 ALOGE("InitPlayout failed!"); |
| 129 return -1; |
| 130 } |
| 128 initialized_ = true; | 131 initialized_ = true; |
| 129 return 0; | 132 return 0; |
| 130 } | 133 } |
| 131 | 134 |
| 132 int32_t AudioTrackJni::StartPlayout() { | 135 int32_t AudioTrackJni::StartPlayout() { |
| 133 ALOGD("StartPlayout%s", GetThreadInfo().c_str()); | 136 ALOGD("StartPlayout%s", GetThreadInfo().c_str()); |
| 134 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 137 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 135 RTC_DCHECK(initialized_); | 138 RTC_DCHECK(initialized_); |
| 136 RTC_DCHECK(!playing_); | 139 RTC_DCHECK(!playing_); |
| 137 if (!j_audio_track_->StartPlayout()) { | 140 if (!j_audio_track_->StartPlayout()) { |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 return; | 254 return; |
| 252 } | 255 } |
| 253 RTC_DCHECK_EQ(static_cast<size_t>(samples), frames_per_buffer_); | 256 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 | 257 // Copy decoded data into common byte buffer to ensure that it can be |
| 255 // written to the Java based audio track. | 258 // written to the Java based audio track. |
| 256 samples = audio_device_buffer_->GetPlayoutData(direct_buffer_address_); | 259 samples = audio_device_buffer_->GetPlayoutData(direct_buffer_address_); |
| 257 RTC_DCHECK_EQ(length, kBytesPerFrame * samples); | 260 RTC_DCHECK_EQ(length, kBytesPerFrame * samples); |
| 258 } | 261 } |
| 259 | 262 |
| 260 } // namespace webrtc | 263 } // namespace webrtc |
| OLD | NEW |