11diff --git a/modules/audio_device/mac/audio_device_mac.cc b/modules/audio_device/mac/audio_device_mac.cc
2- index 0a371737b3..e3a902270d 100644
2+ index 0a371737b3..eb6061a5d9 100644
33--- a/modules/audio_device/mac/audio_device_mac.cc
44+++ b/modules/audio_device/mac/audio_device_mac.cc
5+ @@ -1043,13 +1043,6 @@ int32_t AudioDeviceMac::InitPlayout() {
6+ RTC_LOG(LS_VERBOSE) << "mFormatFlags = " << _outStreamFormat.mFormatFlags;
7+ logCAMsg(rtc::LS_VERBOSE, "mFormatID",
8+ (const char*)&_outStreamFormat.mFormatID);
9+ -
10+ - // Our preferred format to work with.
11+ - if (_outStreamFormat.mChannelsPerFrame < 2) {
12+ - // Disable stereo playout when we only have one channel on the device.
13+ - _playChannels = 1;
14+ - RTC_LOG(LS_VERBOSE) << "Stereo playout unavailable on this device";
15+ - }
16+ WEBRTC_CA_RETURN_ON_ERR(SetDesiredPlayoutFormat());
17+
18+ // Listen for format changes.
19+ @@ -1790,12 +1783,19 @@ int32_t AudioDeviceMac::InitDevice(const uint16_t userDeviceIndex,
20+ OSStatus AudioDeviceMac::SetDesiredPlayoutFormat() {
21+ // Our preferred format to work with.
22+ _outDesiredFormat.mSampleRate = N_PLAY_SAMPLES_PER_SEC;
23+ - _outDesiredFormat.mChannelsPerFrame = _playChannels;
24+ + _outDesiredFormat.mChannelsPerFrame = _outStreamFormat.mChannelsPerFrame;
25+ + if (_playChannels > 1 && _outDesiredFormat.mChannelsPerFrame < 2) {
26+ + RTC_LOG(LS_VERBOSE) << "Stereo playout unavailable on this device";
27+ + }
28+ + if (_outDesiredFormat.mChannelsPerFrame > _playChannels)
29+ + {
30+ + _outDesiredFormat.mChannelsPerFrame = _playChannels;
31+ + }
32+
33+ if (_ptrAudioBuffer) {
34+ // Update audio buffer with the selected parameters.
35+ _ptrAudioBuffer->SetPlayoutSampleRate(N_PLAY_SAMPLES_PER_SEC);
36+ - _ptrAudioBuffer->SetPlayoutChannels((uint8_t)_playChannels);
37+ + _ptrAudioBuffer->SetPlayoutChannels((uint8_t)_outDesiredFormat.mChannelsPerFrame);
38+ }
39+
40+ _renderDelayOffsetSamples =
541@@ -2096,12 +2096,6 @@ int32_t AudioDeviceMac::HandleStreamFormatChange(
642 return -1;
743 }
@@ -28,3 +64,34 @@ index 0a371737b3..e3a902270d 100644
2864 const int io_block_size_samples = streamFormat.mChannelsPerFrame *
2965 streamFormat.mSampleRate / 100 *
3066 N_BLOCKS_IO;
67+ @@ -2144,12 +2144,6 @@ int32_t AudioDeviceMac::HandleStreamFormatChange(
68+ &_captureConverter));
69+ } else {
70+ memcpy(&_outStreamFormat, &streamFormat, sizeof(streamFormat));
71+ -
72+ - // Our preferred format to work with
73+ - if (_outStreamFormat.mChannelsPerFrame < 2) {
74+ - _playChannels = 1;
75+ - RTC_LOG(LS_VERBOSE) << "Stereo playout unavailable on this device";
76+ - }
77+ WEBRTC_CA_RETURN_ON_ERR(SetDesiredPlayoutFormat());
78+ }
79+ return 0;
80+ @@ -2262,7 +2256,7 @@ OSStatus AudioDeviceMac::implDeviceIOProc(const AudioBufferList* inputData,
81+ if (_twoDevices || (!_recording && !_playing)) {
82+ // In the case of a shared device, the single driving ioProc
83+ // is stopped here
84+ - WEBRTC_CA_LOG_ERR(AudioDeviceStop(_outputDeviceID, _deviceIOProcID));
85+ + WEBRTC_CA_LOG_WARN(AudioDeviceStop(_outputDeviceID, _deviceIOProcID));
86+ WEBRTC_CA_LOG_WARN(
87+ AudioDeviceDestroyIOProcID(_outputDeviceID, _deviceIOProcID));
88+ if (err == noErr) {
89+ @@ -2353,7 +2347,7 @@ OSStatus AudioDeviceMac::implInDeviceIOProc(const AudioBufferList* inputData,
90+ MutexLock lock(&mutex_);
91+ if (_doStopRec) {
92+ // This will be signalled only when a shared device is not in use.
93+ - WEBRTC_CA_LOG_ERR(AudioDeviceStop(_inputDeviceID, _inDeviceIOProcID));
94+ + WEBRTC_CA_LOG_WARN(AudioDeviceStop(_inputDeviceID, _inDeviceIOProcID));
95+ WEBRTC_CA_LOG_WARN(
96+ AudioDeviceDestroyIOProcID(_inputDeviceID, _inDeviceIOProcID));
97+ if (err == noErr) {
0 commit comments