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

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

Issue 1373443003: Modifies invalid DCHECK in AudioRecordJni::OnCacheDirectBufferAddress() (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Feedback from magjed@ Created 5 years, 2 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 | « webrtc/modules/audio_device/android/audio_record_jni.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 ALOGD("Terminate%s", GetThreadInfo().c_str()); 113 ALOGD("Terminate%s", GetThreadInfo().c_str());
114 RTC_DCHECK(thread_checker_.CalledOnValidThread()); 114 RTC_DCHECK(thread_checker_.CalledOnValidThread());
115 StopPlayout(); 115 StopPlayout();
116 return 0; 116 return 0;
117 } 117 }
118 118
119 int32_t AudioTrackJni::InitPlayout() { 119 int32_t AudioTrackJni::InitPlayout() {
120 ALOGD("InitPlayout%s", GetThreadInfo().c_str()); 120 ALOGD("InitPlayout%s", GetThreadInfo().c_str());
121 RTC_DCHECK(thread_checker_.CalledOnValidThread()); 121 RTC_DCHECK(thread_checker_.CalledOnValidThread());
122 RTC_DCHECK(!initialized_); 122 RTC_DCHECK(!initialized_);
123 RTC_DCHECK(!direct_buffer_address_);
123 RTC_DCHECK(!playing_); 124 RTC_DCHECK(!playing_);
124 j_audio_track_->InitPlayout( 125 j_audio_track_->InitPlayout(
125 audio_parameters_.sample_rate(), audio_parameters_.channels()); 126 audio_parameters_.sample_rate(), audio_parameters_.channels());
126 initialized_ = true; 127 initialized_ = true;
127 return 0; 128 return 0;
128 } 129 }
129 130
130 int32_t AudioTrackJni::StartPlayout() { 131 int32_t AudioTrackJni::StartPlayout() {
131 ALOGD("StartPlayout%s", GetThreadInfo().c_str()); 132 ALOGD("StartPlayout%s", GetThreadInfo().c_str());
132 RTC_DCHECK(thread_checker_.CalledOnValidThread()); 133 RTC_DCHECK(thread_checker_.CalledOnValidThread());
(...skipping 16 matching lines...) Expand all
149 if (!j_audio_track_->StopPlayout()) { 150 if (!j_audio_track_->StopPlayout()) {
150 ALOGE("StopPlayout failed!"); 151 ALOGE("StopPlayout failed!");
151 return -1; 152 return -1;
152 } 153 }
153 // If we don't detach here, we will hit a RTC_DCHECK in OnDataIsRecorded() 154 // If we don't detach here, we will hit a RTC_DCHECK in OnDataIsRecorded()
154 // next time StartRecording() is called since it will create a new Java 155 // next time StartRecording() is called since it will create a new Java
155 // thread. 156 // thread.
156 thread_checker_java_.DetachFromThread(); 157 thread_checker_java_.DetachFromThread();
157 initialized_ = false; 158 initialized_ = false;
158 playing_ = false; 159 playing_ = false;
160 direct_buffer_address_ = nullptr;
159 return 0; 161 return 0;
160 } 162 }
161 163
162 int AudioTrackJni::SpeakerVolumeIsAvailable(bool& available) { 164 int AudioTrackJni::SpeakerVolumeIsAvailable(bool& available) {
163 available = true; 165 available = true;
164 return 0; 166 return 0;
165 } 167 }
166 168
167 int AudioTrackJni::SetSpeakerVolume(uint32_t volume) { 169 int AudioTrackJni::SetSpeakerVolume(uint32_t volume) {
168 ALOGD("SetSpeakerVolume(%d)%s", volume, GetThreadInfo().c_str()); 170 ALOGD("SetSpeakerVolume(%d)%s", volume, GetThreadInfo().c_str());
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 JNIEnv* env, jobject obj, jobject byte_buffer, jlong nativeAudioTrack) { 210 JNIEnv* env, jobject obj, jobject byte_buffer, jlong nativeAudioTrack) {
209 webrtc::AudioTrackJni* this_object = 211 webrtc::AudioTrackJni* this_object =
210 reinterpret_cast<webrtc::AudioTrackJni*> (nativeAudioTrack); 212 reinterpret_cast<webrtc::AudioTrackJni*> (nativeAudioTrack);
211 this_object->OnCacheDirectBufferAddress(env, byte_buffer); 213 this_object->OnCacheDirectBufferAddress(env, byte_buffer);
212 } 214 }
213 215
214 void AudioTrackJni::OnCacheDirectBufferAddress( 216 void AudioTrackJni::OnCacheDirectBufferAddress(
215 JNIEnv* env, jobject byte_buffer) { 217 JNIEnv* env, jobject byte_buffer) {
216 ALOGD("OnCacheDirectBufferAddress"); 218 ALOGD("OnCacheDirectBufferAddress");
217 RTC_DCHECK(thread_checker_.CalledOnValidThread()); 219 RTC_DCHECK(thread_checker_.CalledOnValidThread());
218 direct_buffer_address_ = 220 direct_buffer_address_ =
magjed_webrtc 2015/09/25 09:54:07 Add a check here as well?
henrika_webrtc 2015/09/25 10:38:43 Done.
219 env->GetDirectBufferAddress(byte_buffer); 221 env->GetDirectBufferAddress(byte_buffer);
220 jlong capacity = env->GetDirectBufferCapacity(byte_buffer); 222 jlong capacity = env->GetDirectBufferCapacity(byte_buffer);
221 ALOGD("direct buffer capacity: %lld", capacity); 223 ALOGD("direct buffer capacity: %lld", capacity);
222 direct_buffer_capacity_in_bytes_ = static_cast<size_t>(capacity); 224 direct_buffer_capacity_in_bytes_ = static_cast<size_t>(capacity);
223 frames_per_buffer_ = direct_buffer_capacity_in_bytes_ / kBytesPerFrame; 225 frames_per_buffer_ = direct_buffer_capacity_in_bytes_ / kBytesPerFrame;
224 ALOGD("frames_per_buffer: %" PRIuS, frames_per_buffer_); 226 ALOGD("frames_per_buffer: %" PRIuS, frames_per_buffer_);
225 } 227 }
226 228
227 void JNICALL AudioTrackJni::GetPlayoutData( 229 void JNICALL AudioTrackJni::GetPlayoutData(
228 JNIEnv* env, jobject obj, jint length, jlong nativeAudioTrack) { 230 JNIEnv* env, jobject obj, jint length, jlong nativeAudioTrack) {
(...skipping 18 matching lines...) Expand all
247 return; 249 return;
248 } 250 }
249 RTC_DCHECK_EQ(static_cast<size_t>(samples), frames_per_buffer_); 251 RTC_DCHECK_EQ(static_cast<size_t>(samples), frames_per_buffer_);
250 // Copy decoded data into common byte buffer to ensure that it can be 252 // Copy decoded data into common byte buffer to ensure that it can be
251 // written to the Java based audio track. 253 // written to the Java based audio track.
252 samples = audio_device_buffer_->GetPlayoutData(direct_buffer_address_); 254 samples = audio_device_buffer_->GetPlayoutData(direct_buffer_address_);
253 RTC_DCHECK_EQ(length, kBytesPerFrame * samples); 255 RTC_DCHECK_EQ(length, kBytesPerFrame * samples);
254 } 256 }
255 257
256 } // namespace webrtc 258 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/audio_device/android/audio_record_jni.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698