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

Unified Diff: webrtc/modules/audio_device/android/audio_track_jni.cc

Issue 2499613002: Adds stereo support for Java-based input and output audio on Android (Closed)
Patch Set: Adds support for separate settings for input and output Created 4 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/audio_device/android/audio_track_jni.cc
diff --git a/webrtc/modules/audio_device/android/audio_track_jni.cc b/webrtc/modules/audio_device/android/audio_track_jni.cc
index fc77e32e23321236e3ce1a5295f8136840008c89..805ce0c364710822ab55a4898aa98db8b204c7e2 100644
--- a/webrtc/modules/audio_device/android/audio_track_jni.cc
+++ b/webrtc/modules/audio_device/android/audio_track_jni.cc
@@ -74,6 +74,7 @@ AudioTrackJni::AudioTrackJni(AudioManager* audio_manager)
direct_buffer_address_(nullptr),
direct_buffer_capacity_in_bytes_(0),
frames_per_buffer_(0),
+ bytes_per_frame_(0),
initialized_(false),
playing_(false),
audio_device_buffer_(nullptr) {
@@ -227,7 +228,8 @@ void AudioTrackJni::OnCacheDirectBufferAddress(
jlong capacity = env->GetDirectBufferCapacity(byte_buffer);
ALOGD("direct buffer capacity: %lld", capacity);
direct_buffer_capacity_in_bytes_ = static_cast<size_t>(capacity);
- frames_per_buffer_ = direct_buffer_capacity_in_bytes_ / kBytesPerFrame;
+ bytes_per_frame_ = audio_parameters_.channels() * sizeof(int16_t);
+ frames_per_buffer_ = direct_buffer_capacity_in_bytes_ / bytes_per_frame_;
ALOGD("frames_per_buffer: %" PRIuS, frames_per_buffer_);
}
@@ -242,7 +244,7 @@ void JNICALL AudioTrackJni::GetPlayoutData(
// the thread is 'AudioRecordTrack'.
void AudioTrackJni::OnGetPlayoutData(size_t length) {
RTC_DCHECK(thread_checker_java_.CalledOnValidThread());
- RTC_DCHECK_EQ(frames_per_buffer_, length / kBytesPerFrame);
+ RTC_DCHECK_EQ(frames_per_buffer_, length / bytes_per_frame_);
if (!audio_device_buffer_) {
ALOGE("AttachAudioBuffer has not been called!");
return;
@@ -257,7 +259,7 @@ void AudioTrackJni::OnGetPlayoutData(size_t length) {
// Copy decoded data into common byte buffer to ensure that it can be
// written to the Java based audio track.
samples = audio_device_buffer_->GetPlayoutData(direct_buffer_address_);
- RTC_DCHECK_EQ(length, kBytesPerFrame * samples);
+ RTC_DCHECK_EQ(length, bytes_per_frame_ * samples);
}
} // namespace webrtc

Powered by Google App Engine
This is Rietveld 408576698