@@ -119,8 +119,6 @@ AudioDeviceMac::AudioDeviceMac()
119119 _twoDevices(true ),
120120 _doStop(false ),
121121 _doStopRec(false ),
122- _macBookPro(false ),
123- _macBookProPanRight(false ),
124122 _captureLatencyUs(0 ),
125123 _renderLatencyUs(0 ),
126124 _captureDelayUs(0 ),
@@ -294,23 +292,6 @@ AudioDeviceGeneric::InitStatus AudioDeviceMac::Init() {
294292 WEBRTC_CA_LOG_ERR (AudioObjectAddPropertyListener (
295293 kAudioObjectSystemObject , &propertyAddress, &objectListenerProc, this ));
296294
297- // Determine if this is a MacBook Pro
298- _macBookPro = false ;
299- _macBookProPanRight = false ;
300- char buf[128 ];
301- size_t length = sizeof (buf);
302- memset (buf, 0 , length);
303-
304- int intErr = sysctlbyname (" hw.model" , buf, &length, NULL , 0 );
305- if (intErr != 0 ) {
306- RTC_LOG (LS_ERROR) << " Error in sysctlbyname(): " << err;
307- } else {
308- RTC_LOG (LS_VERBOSE) << " Hardware model: " << buf;
309- if (strncmp (buf, " MacBookPro" , 10 ) == 0 ) {
310- _macBookPro = true ;
311- }
312- }
313-
314295 _initialized = true ;
315296
316297 return InitStatus::OK;
@@ -979,34 +960,8 @@ int32_t AudioDeviceMac::InitPlayout() {
979960 _renderDeviceIsAlive = 1 ;
980961 _doStop = false ;
981962
982- // The internal microphone of a MacBook Pro is located under the left speaker
983- // grille. When the internal speakers are in use, we want to fully stereo
984- // pan to the right.
985963 AudioObjectPropertyAddress propertyAddress = {
986964 kAudioDevicePropertyDataSource , kAudioDevicePropertyScopeOutput , 0 };
987- if (_macBookPro) {
988- _macBookProPanRight = false ;
989- Boolean hasProperty =
990- AudioObjectHasProperty (_outputDeviceID, &propertyAddress);
991- if (hasProperty) {
992- UInt32 dataSource = 0 ;
993- size = sizeof (dataSource);
994- WEBRTC_CA_LOG_WARN (AudioObjectGetPropertyData (
995- _outputDeviceID, &propertyAddress, 0 , NULL , &size, &dataSource));
996-
997- if (dataSource == ' ispk' ) {
998- _macBookProPanRight = true ;
999- RTC_LOG (LS_VERBOSE)
1000- << " MacBook Pro using internal speakers; stereo panning right" ;
1001- } else {
1002- RTC_LOG (LS_VERBOSE) << " MacBook Pro not using internal speakers" ;
1003- }
1004-
1005- // Add a listener to determine if the status changes.
1006- WEBRTC_CA_LOG_WARN (AudioObjectAddPropertyListener (
1007- _outputDeviceID, &propertyAddress, &objectListenerProc, this ));
1008- }
1009- }
1010965
1011966 // Get current stream description
1012967 propertyAddress.mSelector = kAudioDevicePropertyStreamFormat ;
@@ -1511,16 +1466,6 @@ int32_t AudioDeviceMac::StopPlayout() {
15111466 WEBRTC_CA_LOG_WARN (AudioObjectRemovePropertyListener (
15121467 _outputDeviceID, &propertyAddress, &objectListenerProc, this ));
15131468
1514- if (_macBookPro) {
1515- Boolean hasProperty =
1516- AudioObjectHasProperty (_outputDeviceID, &propertyAddress);
1517- if (hasProperty) {
1518- propertyAddress.mSelector = kAudioDevicePropertyDataSource ;
1519- WEBRTC_CA_LOG_WARN (AudioObjectRemovePropertyListener (
1520- _outputDeviceID, &propertyAddress, &objectListenerProc, this ));
1521- }
1522- }
1523-
15241469 _playIsInitialized = false ;
15251470 _playing = false ;
15261471
@@ -2061,28 +2006,10 @@ int32_t AudioDeviceMac::HandleStreamFormatChange(
20612006int32_t AudioDeviceMac::HandleDataSourceChange (
20622007 const AudioObjectID objectId,
20632008 const AudioObjectPropertyAddress propertyAddress) {
2064- OSStatus err = noErr;
2065-
2066- if (_macBookPro &&
2067- propertyAddress.mScope == kAudioDevicePropertyScopeOutput ) {
2068- RTC_LOG (LS_VERBOSE) << " Data source changed" ;
2069-
2070- _macBookProPanRight = false ;
2071- UInt32 dataSource = 0 ;
2072- UInt32 size = sizeof (UInt32);
2073- WEBRTC_CA_RETURN_ON_ERR (AudioObjectGetPropertyData (
2074- objectId, &propertyAddress, 0 , NULL , &size, &dataSource));
2075- if (dataSource == ' ispk' ) {
2076- _macBookProPanRight = true ;
2077- RTC_LOG (LS_VERBOSE)
2078- << " MacBook Pro using internal speakers; stereo panning right" ;
2079- } else {
2080- RTC_LOG (LS_VERBOSE) << " MacBook Pro not using internal speakers" ;
2081- }
2082- }
20832009
20842010 return 0 ;
20852011}
2012+
20862013int32_t AudioDeviceMac::HandleProcessorOverload (
20872014 const AudioObjectPropertyAddress propertyAddress) {
20882015 // TODO(xians): we probably want to notify the user in some way of the
@@ -2400,24 +2327,6 @@ bool AudioDeviceMac::RenderWorkerThread() {
24002327 uint32_t nOutSamples = nSamples * _outDesiredFormat.mChannelsPerFrame ;
24012328
24022329 SInt16* pPlayBuffer = (SInt16*)&playBuffer;
2403- if (_macBookProPanRight && (_playChannels == 2 )) {
2404- // Mix entirely into the right channel and zero the left channel.
2405- SInt32 sampleInt32 = 0 ;
2406- for (uint32_t sampleIdx = 0 ; sampleIdx < nOutSamples; sampleIdx += 2 ) {
2407- sampleInt32 = pPlayBuffer[sampleIdx];
2408- sampleInt32 += pPlayBuffer[sampleIdx + 1 ];
2409- sampleInt32 /= 2 ;
2410-
2411- if (sampleInt32 > 32767 ) {
2412- sampleInt32 = 32767 ;
2413- } else if (sampleInt32 < -32768 ) {
2414- sampleInt32 = -32768 ;
2415- }
2416-
2417- pPlayBuffer[sampleIdx] = 0 ;
2418- pPlayBuffer[sampleIdx + 1 ] = static_cast <SInt16>(sampleInt32);
2419- }
2420- }
24212330
24222331 PaUtil_WriteRingBuffer (_paRenderBuffer, pPlayBuffer, nOutSamples);
24232332
0 commit comments