diff --git a/modules/audio_device/mac/audio_device_mac.cc b/modules/audio_device/mac/audio_device_mac.cc index fdeaaf13a2..c0287c979e 100644 --- a/modules/audio_device/mac/audio_device_mac.cc +++ b/modules/audio_device/mac/audio_device_mac.cc @@ -2035,6 +2035,12 @@ int32_t AudioDeviceMac::HandleStreamFormatChange( return -1; } + if (_ptrAudioBuffer && streamFormat.mChannelsPerFrame != _recChannels) { + LOG(LS_ERROR) << "Changing channels not supported (mChannelsPerFrame = " + << streamFormat.mChannelsPerFrame << ")"; + return -1; + } + LOG(LS_VERBOSE) << "Stream format:"; LOG(LS_VERBOSE) << "mSampleRate = " << streamFormat.mSampleRate << ", mChannelsPerFrame = " << streamFormat.mChannelsPerFrame; @@ -2068,12 +2074,6 @@ int32_t AudioDeviceMac::HandleStreamFormatChange( LOG(LS_VERBOSE) << "Stereo recording unavailable on this device"; } - if (_ptrAudioBuffer) { - // Update audio buffer with the selected parameters - _ptrAudioBuffer->SetRecordingSampleRate(N_REC_SAMPLES_PER_SEC); - _ptrAudioBuffer->SetRecordingChannels((uint8_t)_recChannels); - } - // Recreate the converter with the new format // TODO(xians): make this thread safe WEBRTC_CA_RETURN_ON_ERR(AudioConverterDispose(_captureConverter));