Skip to content

Commit

Permalink
small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jmelas committed Nov 27, 2020
1 parent 54573d9 commit d760059
Showing 1 changed file with 29 additions and 33 deletions.
62 changes: 29 additions & 33 deletions src/hostapi/coreaudio/pa_mac_core_utilities.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* Olivier Tristan for feedback and testing
* Glenn Zelniker and Z-Systems engineering for sponsoring the Blocking I/O
* interface.
*
*
*
* Based on the Open Source API proposed by Ross Bencina
* Copyright (c) 1999-2002 Ross Bencina, Phil Burk
Expand All @@ -41,13 +41,13 @@
*/

/*
* The text above constitutes the entire PortAudio license; however,
* The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
* they can be incorporated into the canonical version. It is also
* requested that these non-binding requests be included along with the
* they can be incorporated into the canonical version. It is also
* requested that these non-binding requests be included along with the
* license above.
*/

Expand All @@ -72,7 +72,7 @@ OSStatus pa_AudioHardwareGetProperty(
AudioObjectPropertyAddress address = { inPropertyID, kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyElementMaster };
return AudioObjectGetPropertyData(kAudioObjectSystemObject, &address, 0, NULL, ioPropertyDataSize, outPropertyData);
#else
macErr = AudioHardwareGetProperty(inPropertyID, ioPropertyDataSize, outPropertyData);
return AudioHardwareGetProperty(inPropertyID, ioPropertyDataSize, outPropertyData);
#endif
}

Expand All @@ -84,7 +84,7 @@ OSStatus pa_AudioHardwareGetPropertySize(
AudioObjectPropertyAddress address = { inPropertyID, kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyElementMaster };
return AudioObjectGetPropertyDataSize(kAudioObjectSystemObject, &address, 0, NULL, outSize);
#else
macErr = AudioHardwareGetPropertyInfo(inPropertyID, outSize, NULL);
return AudioHardwareGetPropertyInfo(inPropertyID, outSize, NULL);
#endif
}

Expand All @@ -101,7 +101,7 @@ OSStatus pa_AudioDeviceGetProperty(
AudioObjectPropertyAddress address = { inPropertyID, scope, inChannel };
return AudioObjectGetPropertyData(inDevice, &address, 0, NULL, ioPropertyDataSize, outPropertyData);
#else
macErr = AudioDeviceGetProperty(inDevice, inChannel, isInput, inPropertyID, ioPropertyDataSize, outPropertyData);
return AudioDeviceGetProperty(inDevice, inChannel, isInput, inPropertyID, ioPropertyDataSize, outPropertyData);
#endif
}

Expand Down Expand Up @@ -222,16 +222,16 @@ PaError PaMacCore_SetError(OSStatus error, int line, int isError)
/*FIXME: still need to handle possible ComponentResult values.*/
/* unfortunately, they don't seem to be documented anywhere.*/
PaError result;
const char *errorType;
const char *errorType;
const char *errorText;

switch (error) {
case kAudioHardwareNoError:
return paNoError;
case kAudioHardwareNotRunningError:
errorText = "Audio Hardware Not Running";
result = paInternalError; break;
case kAudioHardwareUnspecifiedError:
case kAudioHardwareUnspecifiedError:
errorText = "Unspecified Audio Hardware Error";
result = paInternalError; break;
case kAudioHardwareUnknownPropertyError:
Expand All @@ -240,7 +240,7 @@ PaError PaMacCore_SetError(OSStatus error, int line, int isError)
case kAudioHardwareBadPropertySizeError:
errorText = "Audio Hardware: Bad Property Size";
result = paInternalError; break;
case kAudioHardwareIllegalOperationError:
case kAudioHardwareIllegalOperationError:
errorText = "Audio Hardware: Illegal Operation";
result = paInternalError; break;
case kAudioHardwareBadDeviceError:
Expand Down Expand Up @@ -384,7 +384,7 @@ long computeRingBufferSize( const PaStreamParameters *inputParameters,
{
latency = MAX( inputParameters->suggestedLatency, outputParameters->suggestedLatency );
framesPerBuffer = MAX( inputFramesPerBuffer, outputFramesPerBuffer );
}
}
else if( outputParameters )
{
latency = outputParameters->suggestedLatency;
Expand Down Expand Up @@ -421,7 +421,6 @@ long computeRingBufferSize( const PaStreamParameters *inputParameters,
return ringSize;
}


/*
* Durring testing of core audio, I found that serious crashes could occur
* if properties such as sample rate were changed multiple times in rapid
Expand All @@ -446,18 +445,18 @@ OSStatus propertyProc(
}
#else
OSStatus propertyProc(
AudioDeviceID inDevice,
UInt32 inChannel,
Boolean isInput,
AudioDevicePropertyID inPropertyID,
AudioDeviceID inDevice,
UInt32 inChannel,
Boolean isInput,
AudioDevicePropertyID inPropertyID,
void* inClientData )
{
// this is where we would set the condition variable
return noErr;
}
#endif

/* sets the value of the given property and waits for the change to
/* sets the value of the given property and waits for the change to
be acknowledged, and returns the final value, which is not guaranteed
by this function to be the same as the desired value. Obviously, this
function can only be used for data whose input and output are the
Expand All @@ -468,10 +467,10 @@ OSStatus propertyProc(
determining if the property was read. */
PaError AudioDeviceSetPropertyNowAndWaitForChange(
AudioDeviceID inDevice,
UInt32 inChannel,
Boolean isInput,
UInt32 inChannel,
Boolean isInput,
AudioDevicePropertyID inPropertyID,
UInt32 inPropertyDataSize,
UInt32 inPropertyDataSize,
const void *inPropertyData,
void *outPropertyData )
{
Expand All @@ -498,7 +497,7 @@ PaError AudioDeviceSetPropertyNowAndWaitForChange(
but for now, this is just to make 10.6 happy. */
macErr = pa_AudioDeviceAddPropertyListener( inDevice, inChannel, isInput,
inPropertyID, propertyProc,
NULL );
NULL );
if( macErr )
/* we couldn't add a listener. */
goto failMac;
Expand Down Expand Up @@ -612,7 +611,7 @@ PaError setBestSampleRateForDevice( const AudioDeviceID device,
(float) ranges[i].mMaximum ) );
#endif
VDBUG(("-----\n"));

/* -- now pick the best available sample rate -- */
for( i=0; i<propsize/sizeof(AudioValueRange); ++i )
{
Expand Down Expand Up @@ -648,7 +647,6 @@ PaError setBestSampleRateForDevice( const AudioDeviceID device,
return paInternalError;
}


/*
Attempts to set the requestedFramesPerBuffer. If it can't set the exact
value, it settles for something smaller if available. If nothing smaller
Expand All @@ -660,7 +658,7 @@ PaError setBestSampleRateForDevice( const AudioDeviceID device,
*/
PaError setBestFramesPerBuffer( const AudioDeviceID device,
const bool isOutput,
UInt32 requestedFramesPerBuffer,
UInt32 requestedFramesPerBuffer,
UInt32 *actualFramesPerBuffer )
{
UInt32 afpb;
Expand Down Expand Up @@ -690,7 +688,7 @@ PaError setBestFramesPerBuffer( const AudioDeviceID device,
{
return paNoError; /* we are done */
}

// Clip requested value against legal range for the device.
propsize = sizeof(AudioValueRange);
err = pa_AudioDeviceGetProperty( device, 0, isInput,
Expand All @@ -708,7 +706,7 @@ PaError setBestFramesPerBuffer( const AudioDeviceID device,
{
requestedFramesPerBuffer = range.mMaximum;
}

/* --- set the buffer size (ignore errors) -- */
propsize = sizeof( UInt32 );
err = pa_AudioDeviceSetProperty( device, NULL, 0, isInput,
Expand Down Expand Up @@ -781,18 +779,17 @@ OSStatus xrunCallback(
}
#else
OSStatus xrunCallback(
AudioDeviceID inDevice,
UInt32 inChannel,
Boolean isInput,
AudioDevicePropertyID inPropertyID,
AudioDeviceID inDevice,
UInt32 inChannel,
Boolean isInput,
AudioDevicePropertyID inPropertyID,
void* inClientData)
{
PaMacXRunListNode *node = (PaMacXRunListNode *) inClientData;

int ret = pthread_mutex_trylock( &xrunMutex ) ;

if( ret == 0 ) {

node = node->next ; //skip the first node

for( ; node; node=node->next ) {
Expand Down Expand Up @@ -874,4 +871,3 @@ int removeFromXRunListenerList( void *stream )
// failure
return xRunListSize;
}

0 comments on commit d760059

Please sign in to comment.