Adds stereo support to FineAudioBuffer for mobile platforms.
...continuation of review in https://webrtc-review.googlesource.com/c/src/+/70781 This CL ensures that the FineAudioBuffer can support stereo and also adapts all classes which uses the FineAudioBuffer. Note that, this CL does NOT enable stereo on mobile platforms by default. All it does is to ensure that we *can*. As is, the only functional change is that all clients will now use a FineAudioBuffer implementation which supports stereo (see separate unittest). The FineAudioBuffer constructor has been modified since it is better to utilize the information provided in the injected AudioDeviceBuffer pointer instead of forcing the user to supply redundant parameters. The capacity parameter was also removed since it adds no value now when the more flexible rtc::BufferT is used. I have also done local changes (not included in the CL) where I switch all affected audio backends to stereo and verified that it works in real-time on all affected platforms (Androiod:OpenSL ES, Android:AAudio and iOS). Also note that, changes in: sdk/android/src/jni/audio_device/aaudio_player.cc sdk/android/src/jni/audio_device/aaudio_recorder.cc sdk/android/src/jni/audio_device/opensles_player.cc sdk/android/src/jni/audio_device/opensles_recorder.cc are simply copies of the changes done under modules/audio_device/android since we currently have two versions of the ADM for Android. Bug: webrtc:9172 Change-Id: I1ed3798bd1925381d68f0f9492af921f515b9053 Reviewed-on: https://webrtc-review.googlesource.com/71201 Commit-Queue: Henrik Andreassson <henrika@webrtc.org> Reviewed-by: Karl Wiberg <kwiberg@webrtc.org> Cr-Commit-Position: refs/heads/master@{#22998}
This commit is contained in:
@ -356,9 +356,17 @@ int32_t AudioDeviceBuffer::GetPlayoutData(void* audio_buffer) {
|
||||
const double phase_increment =
|
||||
k2Pi * 440.0 / static_cast<double>(play_sample_rate_);
|
||||
int16_t* destination_r = reinterpret_cast<int16_t*>(audio_buffer);
|
||||
for (size_t i = 0; i < play_buffer_.size(); ++i) {
|
||||
destination_r[i] = static_cast<int16_t>((sin(phase_) * (1 << 14)));
|
||||
phase_ += phase_increment;
|
||||
if (play_channels_ == 1) {
|
||||
for (size_t i = 0; i < play_buffer_.size(); ++i) {
|
||||
destination_r[i] = static_cast<int16_t>((sin(phase_) * (1 << 14)));
|
||||
phase_ += phase_increment;
|
||||
}
|
||||
} else if (play_channels_ == 2) {
|
||||
for (size_t i = 0; i < play_buffer_.size() / 2; ++i) {
|
||||
destination_r[2 * i] = destination_r[2 * i + 1] =
|
||||
static_cast<int16_t>((sin(phase_) * (1 << 14)));
|
||||
phase_ += phase_increment;
|
||||
}
|
||||
}
|
||||
#else
|
||||
memcpy(audio_buffer, play_buffer_.data(),
|
||||
|
||||
Reference in New Issue
Block a user