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

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: nit Created 5 years, 3 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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 if (!j_audio_track_->StopPlayout()) { 149 if (!j_audio_track_->StopPlayout()) {
150 ALOGE("StopPlayout failed!"); 150 ALOGE("StopPlayout failed!");
151 return -1; 151 return -1;
152 } 152 }
153 // If we don't detach here, we will hit a RTC_DCHECK in OnDataIsRecorded() 153 // 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 154 // next time StartRecording() is called since it will create a new Java
155 // thread. 155 // thread.
156 thread_checker_java_.DetachFromThread(); 156 thread_checker_java_.DetachFromThread();
157 initialized_ = false; 157 initialized_ = false;
158 playing_ = false; 158 playing_ = false;
159 direct_buffer_address_ = nullptr;
159 return 0; 160 return 0;
160 } 161 }
161 162
162 int AudioTrackJni::SpeakerVolumeIsAvailable(bool& available) { 163 int AudioTrackJni::SpeakerVolumeIsAvailable(bool& available) {
163 available = true; 164 available = true;
164 return 0; 165 return 0;
165 } 166 }
166 167
167 int AudioTrackJni::SetSpeakerVolume(uint32_t volume) { 168 int AudioTrackJni::SetSpeakerVolume(uint32_t volume) {
168 ALOGD("SetSpeakerVolume(%d)%s", volume, GetThreadInfo().c_str()); 169 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) { 209 JNIEnv* env, jobject obj, jobject byte_buffer, jlong nativeAudioTrack) {
209 webrtc::AudioTrackJni* this_object = 210 webrtc::AudioTrackJni* this_object =
210 reinterpret_cast<webrtc::AudioTrackJni*> (nativeAudioTrack); 211 reinterpret_cast<webrtc::AudioTrackJni*> (nativeAudioTrack);
211 this_object->OnCacheDirectBufferAddress(env, byte_buffer); 212 this_object->OnCacheDirectBufferAddress(env, byte_buffer);
212 } 213 }
213 214
214 void AudioTrackJni::OnCacheDirectBufferAddress( 215 void AudioTrackJni::OnCacheDirectBufferAddress(
215 JNIEnv* env, jobject byte_buffer) { 216 JNIEnv* env, jobject byte_buffer) {
216 ALOGD("OnCacheDirectBufferAddress"); 217 ALOGD("OnCacheDirectBufferAddress");
217 RTC_DCHECK(thread_checker_.CalledOnValidThread()); 218 RTC_DCHECK(thread_checker_.CalledOnValidThread());
219 RTC_DCHECK(!direct_buffer_address_);
218 direct_buffer_address_ = 220 direct_buffer_address_ =
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(
(...skipping 19 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