remove support for OS X 10.4, rename functions pa_ -> PaMacCore_

This commit is contained in:
John Melas 2020-12-16 12:45:30 +02:00 committed by Phil Burk
commit 1d3a239fd0
3 changed files with 105 additions and 328 deletions

View file

@ -138,7 +138,7 @@ const char *PaMacCore_GetChannelName( int device, int channelIndex, bool input )
/* First try with CFString */ /* First try with CFString */
UInt32 size = sizeof(nameRef); UInt32 size = sizeof(nameRef);
error = pa_AudioDeviceGetProperty( hostApiDevice, error = PaMacCore_AudioDeviceGetProperty( hostApiDevice,
channelIndex + 1, channelIndex + 1,
input, input,
kAudioDevicePropertyChannelNameCFString, kAudioDevicePropertyChannelNameCFString,
@ -148,7 +148,7 @@ const char *PaMacCore_GetChannelName( int device, int channelIndex, bool input )
{ {
/* try the C String */ /* try the C String */
size = 0; size = 0;
error = pa_AudioDeviceGetPropertySize( hostApiDevice, error = PaMacCore_AudioDeviceGetPropertySize( hostApiDevice,
channelIndex + 1, channelIndex + 1,
input, input,
kAudioDevicePropertyChannelName, kAudioDevicePropertyChannelName,
@ -158,7 +158,7 @@ const char *PaMacCore_GetChannelName( int device, int channelIndex, bool input )
if( !ensureChannelNameSize( size ) ) if( !ensureChannelNameSize( size ) )
return NULL; return NULL;
error = pa_AudioDeviceGetProperty( hostApiDevice, error = PaMacCore_AudioDeviceGetProperty( hostApiDevice,
channelIndex + 1, channelIndex + 1,
input, input,
kAudioDevicePropertyChannelName, kAudioDevicePropertyChannelName,
@ -223,7 +223,7 @@ PaError PaMacCore_GetBufferSizeRange( PaDeviceIndex device,
if( macCoreHostApi->inheritedHostApiRep.deviceInfos[hostApiDeviceIndex]->maxOutputChannels == 0 ) if( macCoreHostApi->inheritedHostApiRep.deviceInfos[hostApiDeviceIndex]->maxOutputChannels == 0 )
isInput = 1; isInput = 1;
result = WARNING(pa_AudioDeviceGetProperty( macCoreDeviceId, 0, isInput, kAudioDevicePropertyBufferFrameSizeRange, &propSize, &audioRange ) ); result = WARNING(PaMacCore_AudioDeviceGetProperty( macCoreDeviceId, 0, isInput, kAudioDevicePropertyBufferFrameSizeRange, &propSize, &audioRange ) );
*minBufferSizeFrames = audioRange.mMinimum; *minBufferSizeFrames = audioRange.mMinimum;
*maxBufferSizeFrames = audioRange.mMaximum; *maxBufferSizeFrames = audioRange.mMaximum;
@ -352,7 +352,7 @@ static PaError gatherDeviceInfo(PaMacAUHAL *auhalHostApi)
auhalHostApi->devIds = NULL; auhalHostApi->devIds = NULL;
/* -- figure out how many devices there are -- */ /* -- figure out how many devices there are -- */
pa_AudioHardwareGetPropertySize( kAudioHardwarePropertyDevices, PaMacCore_AudioHardwareGetPropertySize( kAudioHardwarePropertyDevices,
&propsize); &propsize);
auhalHostApi->devCount = propsize / sizeof( AudioDeviceID ); auhalHostApi->devCount = propsize / sizeof( AudioDeviceID );
@ -364,7 +364,7 @@ static PaError gatherDeviceInfo(PaMacAUHAL *auhalHostApi)
propsize ); propsize );
if( !auhalHostApi->devIds ) if( !auhalHostApi->devIds )
return paInsufficientMemory; return paInsufficientMemory;
pa_AudioHardwareGetProperty( kAudioHardwarePropertyDevices, PaMacCore_AudioHardwareGetProperty( kAudioHardwarePropertyDevices,
&propsize, &propsize,
auhalHostApi->devIds ); auhalHostApi->devIds );
#ifdef MAC_CORE_VERBOSE_DEBUG #ifdef MAC_CORE_VERBOSE_DEBUG
@ -383,7 +383,7 @@ static PaError gatherDeviceInfo(PaMacAUHAL *auhalHostApi)
/* I am not sure how these calls to AudioHardwareGetProperty() /* I am not sure how these calls to AudioHardwareGetProperty()
could fail, but in case they do, we use the first available could fail, but in case they do, we use the first available
device as the default. */ device as the default. */
if( 0 != pa_AudioHardwareGetProperty(kAudioHardwarePropertyDefaultInputDevice, if( 0 != PaMacCore_AudioHardwareGetProperty(kAudioHardwarePropertyDefaultInputDevice,
&size, &size,
&auhalHostApi->defaultIn) ) { &auhalHostApi->defaultIn) ) {
int i; int i;
@ -400,7 +400,7 @@ static PaError gatherDeviceInfo(PaMacAUHAL *auhalHostApi)
} }
} }
} }
if( 0 != pa_AudioHardwareGetProperty(kAudioHardwarePropertyDefaultOutputDevice, if( 0 != PaMacCore_AudioHardwareGetProperty(kAudioHardwarePropertyDefaultOutputDevice,
&size, &size,
&auhalHostApi->defaultOut) ) { &auhalHostApi->defaultOut) ) {
int i; int i;
@ -435,7 +435,7 @@ static PaError ClipToDeviceBufferSize( AudioDeviceID macCoreDeviceId,
UInt32 resultSize = desiredSize; UInt32 resultSize = desiredSize;
AudioValueRange audioRange; AudioValueRange audioRange;
UInt32 propSize = sizeof( audioRange ); UInt32 propSize = sizeof( audioRange );
PaError err = WARNING(pa_AudioDeviceGetProperty( macCoreDeviceId, 0, isInput, kAudioDevicePropertyBufferFrameSizeRange, &propSize, &audioRange ) ); PaError err = WARNING(PaMacCore_AudioDeviceGetProperty( macCoreDeviceId, 0, isInput, kAudioDevicePropertyBufferFrameSizeRange, &propSize, &audioRange ) );
resultSize = MAX( resultSize, audioRange.mMinimum ); resultSize = MAX( resultSize, audioRange.mMinimum );
resultSize = MIN( resultSize, audioRange.mMaximum ); resultSize = MIN( resultSize, audioRange.mMaximum );
*allowedSize = resultSize; *allowedSize = resultSize;
@ -485,7 +485,7 @@ static void DumpDeviceProperties( AudioDeviceID macCoreDeviceId,
printf("Stream #%d = %d---------------------- \n", i, streamIDs[i] ); printf("Stream #%d = %d---------------------- \n", i, streamIDs[i] );
propSize = sizeof(UInt32); propSize = sizeof(UInt32);
err = WARNING(p_AudioStreamGetProperty(streamIDs[i], 0, kAudioStreamPropertyLatency, &propSize, &streamLatency)); err = WARNING(PaMacCore_AudioStreamGetProperty(streamIDs[i], 0, kAudioStreamPropertyLatency, &propSize, &streamLatency));
printf(" kAudioStreamPropertyLatency: err = %d, propSize = %d, value = %d\n", err, propSize, streamLatency ); printf(" kAudioStreamPropertyLatency: err = %d, propSize = %d, value = %d\n", err, propSize, streamLatency );
} }
} }
@ -515,20 +515,20 @@ static PaError CalculateFixedDeviceLatency( AudioDeviceID macCoreDeviceId, int i
// To get stream latency we have to get a streamID from the device. // To get stream latency we have to get a streamID from the device.
// We are only going to look at the first stream so only fetch one stream. // We are only going to look at the first stream so only fetch one stream.
propSize = sizeof(streamIDs); propSize = sizeof(streamIDs);
err = WARNING(pa_AudioDeviceGetProperty(macCoreDeviceId, 0, isInput, kAudioDevicePropertyStreams, &propSize, &streamIDs[0])); err = WARNING(PaMacCore_AudioDeviceGetProperty(macCoreDeviceId, 0, isInput, kAudioDevicePropertyStreams, &propSize, &streamIDs[0]));
if( err != paNoError ) goto error; if( err != paNoError ) goto error;
if( propSize == sizeof(AudioStreamID) ) if( propSize == sizeof(AudioStreamID) )
{ {
propSize = sizeof(UInt32); propSize = sizeof(UInt32);
err = WARNING(pa_AudioStreamGetProperty(streamIDs[0], 0, kAudioStreamPropertyLatency, &propSize, &streamLatency)); err = WARNING(PaMacCore_AudioStreamGetProperty(streamIDs[0], 0, kAudioStreamPropertyLatency, &propSize, &streamLatency));
} }
propSize = sizeof(UInt32); propSize = sizeof(UInt32);
err = WARNING(pa_AudioDeviceGetProperty(macCoreDeviceId, 0, isInput, kAudioDevicePropertySafetyOffset, &propSize, &safetyOffset)); err = WARNING(PaMacCore_AudioDeviceGetProperty(macCoreDeviceId, 0, isInput, kAudioDevicePropertySafetyOffset, &propSize, &safetyOffset));
if( err != paNoError ) goto error; if( err != paNoError ) goto error;
propSize = sizeof(UInt32); propSize = sizeof(UInt32);
err = WARNING(pa_AudioDeviceGetProperty(macCoreDeviceId, 0, isInput, kAudioDevicePropertyLatency, &propSize, &deviceLatency)); err = WARNING(PaMacCore_AudioDeviceGetProperty(macCoreDeviceId, 0, isInput, kAudioDevicePropertyLatency, &propSize, &deviceLatency));
if( err != paNoError ) goto error; if( err != paNoError ) goto error;
*fixedLatencyPtr = deviceLatency + streamLatency + safetyOffset; *fixedLatencyPtr = deviceLatency + streamLatency + safetyOffset;
@ -558,7 +558,7 @@ static PaError CalculateDefaultDeviceLatencies( AudioDeviceID macCoreDeviceId,
// For high latency use the default device buffer size. // For high latency use the default device buffer size.
propSize = sizeof(UInt32); propSize = sizeof(UInt32);
err = WARNING(pa_AudioDeviceGetProperty(macCoreDeviceId, 0, isInput, kAudioDevicePropertyBufferFrameSize, &propSize, &bufferFrames)); err = WARNING(PaMacCore_AudioDeviceGetProperty(macCoreDeviceId, 0, isInput, kAudioDevicePropertyBufferFrameSize, &propSize, &bufferFrames));
if( err != paNoError ) goto error; if( err != paNoError ) goto error;
*lowLatencyFramesPtr = fixedLatency + clippedMinBufferSize; *lowLatencyFramesPtr = fixedLatency + clippedMinBufferSize;
@ -587,14 +587,14 @@ static PaError GetChannelInfo( PaMacAUHAL *auhalHostApi,
/* Get the number of channels from the stream configuration. /* Get the number of channels from the stream configuration.
Fail if we can't get this. */ Fail if we can't get this. */
err = ERR(pa_AudioDeviceGetPropertySize(macCoreDeviceId, 0, isInput, kAudioDevicePropertyStreamConfiguration, &propSize)); err = ERR(PaMacCore_AudioDeviceGetPropertySize(macCoreDeviceId, 0, isInput, kAudioDevicePropertyStreamConfiguration, &propSize));
if (err) if (err)
return err; return err;
buflist = PaUtil_AllocateMemory(propSize); buflist = PaUtil_AllocateMemory(propSize);
if( !buflist ) if( !buflist )
return paInsufficientMemory; return paInsufficientMemory;
err = ERR(pa_AudioDeviceGetProperty(macCoreDeviceId, 0, isInput, kAudioDevicePropertyStreamConfiguration, &propSize, buflist)); err = ERR(PaMacCore_AudioDeviceGetProperty(macCoreDeviceId, 0, isInput, kAudioDevicePropertyStreamConfiguration, &propSize, buflist));
if (err) if (err)
goto error; goto error;
@ -662,18 +662,18 @@ static PaError InitializeDeviceInfo( PaMacAUHAL *auhalHostApi,
/* Get the device name using CFString */ /* Get the device name using CFString */
propSize = sizeof(nameRef); propSize = sizeof(nameRef);
err = ERR(pa_AudioDeviceGetProperty(macCoreDeviceId, 0, 0, kAudioDevicePropertyDeviceNameCFString, &propSize, &nameRef)); err = ERR(PaMacCore_AudioDeviceGetProperty(macCoreDeviceId, 0, 0, kAudioDevicePropertyDeviceNameCFString, &propSize, &nameRef));
if (err) if (err)
{ {
/* Get the device name using c string. Fail if we can't get it. */ /* Get the device name using c string. Fail if we can't get it. */
err = ERR(pa_AudioDeviceGetPropertySize(macCoreDeviceId, 0, 0, kAudioDevicePropertyDeviceName, &propSize)); err = ERR(PaMacCore_AudioDeviceGetPropertySize(macCoreDeviceId, 0, 0, kAudioDevicePropertyDeviceName, &propSize));
if (err) if (err)
return err; return err;
name = PaUtil_GroupAllocateMemory(auhalHostApi->allocations,propSize+1); name = PaUtil_GroupAllocateMemory(auhalHostApi->allocations,propSize+1);
if ( !name ) if ( !name )
return paInsufficientMemory; return paInsufficientMemory;
err = ERR(pa_AudioDeviceGetProperty(macCoreDeviceId, 0, 0, kAudioDevicePropertyDeviceName, &propSize, name)); err = ERR(PaMacCore_AudioDeviceGetProperty(macCoreDeviceId, 0, 0, kAudioDevicePropertyDeviceName, &propSize, name));
if (err) if (err)
return err; return err;
} }
@ -694,7 +694,7 @@ static PaError InitializeDeviceInfo( PaMacAUHAL *auhalHostApi,
/* Try to get the default sample rate. Don't fail if we can't get this. */ /* Try to get the default sample rate. Don't fail if we can't get this. */
propSize = sizeof(Float64); propSize = sizeof(Float64);
err = ERR(pa_AudioDeviceGetProperty(macCoreDeviceId, 0, 0, kAudioDevicePropertyNominalSampleRate, &propSize, &sampleRate)); err = ERR(PaMacCore_AudioDeviceGetProperty(macCoreDeviceId, 0, 0, kAudioDevicePropertyNominalSampleRate, &propSize, &sampleRate));
if (err) if (err)
deviceInfo->defaultSampleRate = 0.0; deviceInfo->defaultSampleRate = 0.0;
else else
@ -1043,7 +1043,7 @@ static OSStatus UpdateSampleRateFromDeviceProperty( PaMacCoreStream *stream, Aud
Float64 sampleRate = 0.0; Float64 sampleRate = 0.0;
UInt32 propSize = sizeof(Float64); UInt32 propSize = sizeof(Float64);
OSStatus osErr = pa_AudioDeviceGetProperty( deviceID, 0, isInput, sampleRatePropertyID, &propSize, &sampleRate); OSStatus osErr = PaMacCore_AudioDeviceGetProperty( deviceID, 0, isInput, sampleRatePropertyID, &propSize, &sampleRate);
if( (osErr == noErr) && (sampleRate > 1000.0) ) /* avoid divide by zero if there's an error */ if( (osErr == noErr) && (sampleRate > 1000.0) ) /* avoid divide by zero if there's an error */
{ {
deviceProperties->sampleRate = sampleRate; deviceProperties->sampleRate = sampleRate;
@ -1052,45 +1052,28 @@ static OSStatus UpdateSampleRateFromDeviceProperty( PaMacCoreStream *stream, Aud
return osErr; return osErr;
} }
#if PA_NEW_HAL
static OSStatus AudioDevicePropertyActualSampleRateListenerProc(AudioObjectID inDevice, UInt32 inNumberAddresses, const AudioObjectPropertyAddress * inAddresses, void * inClientData) static OSStatus AudioDevicePropertyActualSampleRateListenerProc(AudioObjectID inDevice, UInt32 inNumberAddresses, const AudioObjectPropertyAddress * inAddresses, void * inClientData)
{ {
PaMacCoreStream * stream = (PaMacCoreStream *) inClientData; PaMacCoreStream *stream = (PaMacCoreStream*)inClientData;
bool isInput = inAddresses->mScope == kAudioDevicePropertyScopeInput; bool isInput = inAddresses->mScope == kAudioDevicePropertyScopeInput;
// Make sure the callback is operating on a stream that is still valid!
assert(stream->streamRepresentation.magic == PA_STREAM_MAGIC);
OSStatus osErr = UpdateSampleRateFromDeviceProperty(stream, inDevice, isInput, kAudioDevicePropertyActualSampleRate);
if (osErr == noErr)
{
UpdateTimeStampOffsets(stream);
}
return osErr;
}
#else
static OSStatus AudioDevicePropertyActualSampleRateListenerProc( AudioDeviceID inDevice, UInt32 inChannel, Boolean isInput, AudioDevicePropertyID inPropertyID, void *inClientData )
{
PaMacCoreStream *stream = (PaMacCoreStream*)inClientData;
// Make sure the callback is operating on a stream that is still valid! // Make sure the callback is operating on a stream that is still valid!
assert( stream->streamRepresentation.magic == PA_STREAM_MAGIC ); assert( stream->streamRepresentation.magic == PA_STREAM_MAGIC );
OSStatus osErr = UpdateSampleRateFromDeviceProperty( stream, inDevice, isInput, kAudioDevicePropertyActualSampleRate ); OSStatus osErr = UpdateSampleRateFromDeviceProperty( stream, inDevice, isInput, kAudioDevicePropertyActualSampleRate );
if( osErr == noErr ) if( osErr == noErr )
{ {
UpdateTimeStampOffsets( stream ); UpdateTimeStampOffsets( stream );
} }
return osErr; return osErr;
} }
#endif /* PA_NEW_HAL */
/* ================================================================================= */ /* ================================================================================= */
static OSStatus QueryUInt32DeviceProperty( AudioDeviceID deviceID, Boolean isInput, AudioDevicePropertyID propertyID, UInt32 *outValue ) static OSStatus QueryUInt32DeviceProperty( AudioDeviceID deviceID, Boolean isInput, AudioDevicePropertyID propertyID, UInt32 *outValue )
{ {
UInt32 propertyValue = 0; UInt32 propertyValue = 0;
UInt32 propertySize = sizeof(UInt32); UInt32 propertySize = sizeof(UInt32);
OSStatus osErr = pa_AudioDeviceGetProperty( deviceID, 0, isInput, propertyID, &propertySize, &propertyValue); OSStatus osErr = PaMacCore_AudioDeviceGetProperty( deviceID, 0, isInput, propertyID, &propertySize, &propertyValue);
if( osErr == noErr ) if( osErr == noErr )
{ {
*outValue = propertyValue; *outValue = propertyValue;
@ -1098,49 +1081,13 @@ static OSStatus QueryUInt32DeviceProperty( AudioDeviceID deviceID, Boolean isInp
return osErr; return osErr;
} }
#if PA_NEW_HAL
static OSStatus AudioDevicePropertyGenericListenerProc(AudioObjectID inDevice, UInt32 inNumberAddresses, const AudioObjectPropertyAddress * inAddresses, void * inClientData) static OSStatus AudioDevicePropertyGenericListenerProc(AudioObjectID inDevice, UInt32 inNumberAddresses, const AudioObjectPropertyAddress * inAddresses, void * inClientData)
{ {
OSStatus osErr = noErr; OSStatus osErr = noErr;
PaMacCoreStream * stream = (PaMacCoreStream *) inClientData; PaMacCoreStream *stream = (PaMacCoreStream*)inClientData;
bool isInput = inAddresses->mScope == kAudioDevicePropertyScopeInput; bool isInput = inAddresses->mScope == kAudioDevicePropertyScopeInput;
AudioDevicePropertyID inPropertyID = inAddresses->mSelector; AudioDevicePropertyID inPropertyID = inAddresses->mSelector;
// Make sure the callback is operating on a stream that is still valid!
assert(stream->streamRepresentation.magic == PA_STREAM_MAGIC);
PaMacCoreDeviceProperties * deviceProperties = isInput ? &stream->inputProperties : &stream->outputProperties;
UInt32 * valuePtr = NULL;
switch (inPropertyID)
{
case kAudioDevicePropertySafetyOffset:
valuePtr = &deviceProperties->safetyOffset;
break;
case kAudioDevicePropertyLatency:
valuePtr = &deviceProperties->deviceLatency;
break;
case kAudioDevicePropertyBufferFrameSize:
valuePtr = &deviceProperties->bufferFrameSize;
break;
}
if (valuePtr != NULL)
{
osErr = QueryUInt32DeviceProperty(inDevice, isInput, inPropertyID, valuePtr);
if (osErr == noErr)
{
UpdateTimeStampOffsets(stream);
}
}
return osErr;
}
#else
static OSStatus AudioDevicePropertyGenericListenerProc( AudioDeviceID inDevice, UInt32 inChannel, Boolean isInput, AudioDevicePropertyID inPropertyID, void *inClientData )
{
OSStatus osErr = noErr;
PaMacCoreStream *stream = (PaMacCoreStream*)inClientData;
// Make sure the callback is operating on a stream that is still valid! // Make sure the callback is operating on a stream that is still valid!
assert( stream->streamRepresentation.magic == PA_STREAM_MAGIC ); assert( stream->streamRepresentation.magic == PA_STREAM_MAGIC );
@ -1170,7 +1117,6 @@ static OSStatus AudioDevicePropertyGenericListenerProc( AudioDeviceID inDevice,
} }
return osErr; return osErr;
} }
#endif /* PA_NEW_HAL */
/* ================================================================================= */ /* ================================================================================= */
/* /*
@ -1187,14 +1133,14 @@ static OSStatus SetupDevicePropertyListeners( PaMacCoreStream *stream, AudioDevi
if( (osErr = QueryUInt32DeviceProperty( deviceID, isInput, if( (osErr = QueryUInt32DeviceProperty( deviceID, isInput,
kAudioDevicePropertySafetyOffset, &deviceProperties->safetyOffset )) != noErr ) return osErr; kAudioDevicePropertySafetyOffset, &deviceProperties->safetyOffset )) != noErr ) return osErr;
pa_AudioDeviceAddPropertyListener( deviceID, 0, isInput, kAudioDevicePropertyActualSampleRate, PaMacCore_AudioDeviceAddPropertyListener( deviceID, 0, isInput, kAudioDevicePropertyActualSampleRate,
AudioDevicePropertyActualSampleRateListenerProc, stream ); AudioDevicePropertyActualSampleRateListenerProc, stream );
pa_AudioDeviceAddPropertyListener( deviceID, 0, isInput, kAudioStreamPropertyLatency, PaMacCore_AudioDeviceAddPropertyListener( deviceID, 0, isInput, kAudioStreamPropertyLatency,
AudioDevicePropertyGenericListenerProc, stream ); AudioDevicePropertyGenericListenerProc, stream );
pa_AudioDeviceAddPropertyListener( deviceID, 0, isInput, kAudioDevicePropertyBufferFrameSize, PaMacCore_AudioDeviceAddPropertyListener( deviceID, 0, isInput, kAudioDevicePropertyBufferFrameSize,
AudioDevicePropertyGenericListenerProc, stream ); AudioDevicePropertyGenericListenerProc, stream );
pa_AudioDeviceAddPropertyListener( deviceID, 0, isInput, kAudioDevicePropertySafetyOffset, PaMacCore_AudioDeviceAddPropertyListener( deviceID, 0, isInput, kAudioDevicePropertySafetyOffset,
AudioDevicePropertyGenericListenerProc, stream ); AudioDevicePropertyGenericListenerProc, stream );
return osErr; return osErr;
@ -1202,14 +1148,14 @@ static OSStatus SetupDevicePropertyListeners( PaMacCoreStream *stream, AudioDevi
static void CleanupDevicePropertyListeners( PaMacCoreStream *stream, AudioDeviceID deviceID, Boolean isInput ) static void CleanupDevicePropertyListeners( PaMacCoreStream *stream, AudioDeviceID deviceID, Boolean isInput )
{ {
pa_AudioDeviceRemovePropertyListener( deviceID, 0, isInput, kAudioDevicePropertyActualSampleRate, PaMacCore_AudioDeviceRemovePropertyListener( deviceID, 0, isInput, kAudioDevicePropertyActualSampleRate,
AudioDevicePropertyActualSampleRateListenerProc, stream ); AudioDevicePropertyActualSampleRateListenerProc, stream );
pa_AudioDeviceRemovePropertyListener( deviceID, 0, isInput, kAudioDevicePropertyLatency, PaMacCore_AudioDeviceRemovePropertyListener( deviceID, 0, isInput, kAudioDevicePropertyLatency,
AudioDevicePropertyGenericListenerProc, stream ); AudioDevicePropertyGenericListenerProc, stream );
pa_AudioDeviceRemovePropertyListener( deviceID, 0, isInput, kAudioDevicePropertyBufferFrameSize, PaMacCore_AudioDeviceRemovePropertyListener( deviceID, 0, isInput, kAudioDevicePropertyBufferFrameSize,
AudioDevicePropertyGenericListenerProc, stream ); AudioDevicePropertyGenericListenerProc, stream );
pa_AudioDeviceRemovePropertyListener( deviceID, 0, isInput, kAudioDevicePropertySafetyOffset, PaMacCore_AudioDeviceRemovePropertyListener( deviceID, 0, isInput, kAudioDevicePropertySafetyOffset,
AudioDevicePropertyGenericListenerProc, stream ); AudioDevicePropertyGenericListenerProc, stream );
} }
@ -1384,7 +1330,7 @@ static PaError OpenAndSetupOneAudioUnit(
sizeof(AudioDeviceID) ) ); sizeof(AudioDeviceID) ) );
} }
/* -- add listener for dropouts -- */ /* -- add listener for dropouts -- */
result = pa_AudioDeviceAddPropertyListener( *audioDevice, result = PaMacCore_AudioDeviceAddPropertyListener( *audioDevice,
0, 0,
outStreamParams ? false : true, outStreamParams ? false : true,
kAudioDeviceProcessorOverload, kAudioDeviceProcessorOverload,
@ -2183,7 +2129,6 @@ PaTime GetStreamTime( PaStream *s )
#define RING_BUFFER_EMPTY (1000) #define RING_BUFFER_EMPTY (1000)
#if PA_NEW_HAL
static OSStatus ringBufferIOProc( static OSStatus ringBufferIOProc(
AudioConverterRef inAudioConverter, AudioConverterRef inAudioConverter,
UInt32* ioNumberDataPackets, UInt32* ioNumberDataPackets,
@ -2200,34 +2145,6 @@ static OSStatus ringBufferIOProc(
VVDBUG(("ringBufferIOProc()\n")); VVDBUG(("ringBufferIOProc()\n"));
if( PaUtil_GetRingBufferReadAvailable( rb ) == 0 ) {
*outData = NULL;
*ioDataSize = 0;
return RING_BUFFER_EMPTY;
}
assert(sizeof(UInt32) == sizeof(ring_buffer_size_t));
assert( ( (*ioDataSize) / rb->elementSizeBytes ) * rb->elementSizeBytes == (*ioDataSize) ) ;
(*ioDataSize) /= rb->elementSizeBytes ;
PaUtil_GetRingBufferReadRegions( rb, *ioDataSize,
outData, (ring_buffer_size_t *)ioDataSize,
&dummyData, &dummySize );
assert( *ioDataSize );
PaUtil_AdvanceRingBufferReadIndex( rb, *ioDataSize );
(*ioDataSize) *= rb->elementSizeBytes ;
return noErr;
}
#else
static OSStatus ringBufferIOProc( AudioConverterRef inAudioConverter,
UInt32*ioDataSize,
void** outData,
void*inUserData )
{
void *dummyData;
ring_buffer_size_t dummySize;
PaUtilRingBuffer *rb = (PaUtilRingBuffer *) inUserData;
VVDBUG(("ringBufferIOProc()\n"));
if( PaUtil_GetRingBufferReadAvailable( rb ) == 0 ) { if( PaUtil_GetRingBufferReadAvailable( rb ) == 0 ) {
*outData = NULL; *outData = NULL;
*ioDataSize = 0; *ioDataSize = 0;
@ -2245,7 +2162,6 @@ static OSStatus ringBufferIOProc( AudioConverterRef inAudioConverter,
return noErr; return noErr;
} }
#endif /* PA_NEW_HAL */
/* /*
* Called by the AudioUnit API to process audio from the sound card. * Called by the AudioUnit API to process audio from the sound card.
@ -2467,7 +2383,6 @@ static OSStatus AudioIOProc( void *inRefCon,
UInt32 size; UInt32 size;
float data[ inChan * frames ]; float data[ inChan * frames ];
size = sizeof( data ); size = sizeof( data );
#if PA_NEW_HAL
AudioBufferList bufferList; AudioBufferList bufferList;
bufferList.mNumberBuffers = 1; bufferList.mNumberBuffers = 1;
bufferList.mBuffers[0].mNumberChannels = inChan; bufferList.mBuffers[0].mNumberChannels = inChan;
@ -2480,14 +2395,6 @@ static OSStatus AudioIOProc( void *inRefCon,
&size, &size,
&bufferList, &bufferList,
NULL); NULL);
#else
err = AudioConverterFillBuffer(
stream->inputSRConverter,
ringBufferIOProc,
&stream->inputRingBuffer,
&size,
(void *)&data );
#endif /* PA_NEW_HAL */
if( err == RING_BUFFER_EMPTY ) if( err == RING_BUFFER_EMPTY )
{ /* the ring buffer callback underflowed */ { /* the ring buffer callback underflowed */
err = 0; err = 0;
@ -2667,27 +2574,18 @@ static OSStatus AudioIOProc( void *inRefCon,
long f; long f;
size = sizeof( data ); size = sizeof( data );
#if PA_NEW_HAL AudioBufferList bufferList;
AudioBufferList bufferList; bufferList.mNumberBuffers = 1;
bufferList.mNumberBuffers = 1; bufferList.mBuffers[0].mNumberChannels = chan;
bufferList.mBuffers[0].mNumberChannels = chan; bufferList.mBuffers[0].mDataByteSize = size;
bufferList.mBuffers[0].mDataByteSize = size; bufferList.mBuffers[0].mData = data;
bufferList.mBuffers[0].mData = data; err = AudioConverterFillComplexBuffer(
err = AudioConverterFillComplexBuffer( stream->inputSRConverter,
stream->inputSRConverter, ringBufferIOProc,
ringBufferIOProc, &stream->inputRingBuffer,
&stream->inputRingBuffer, &size,
&size, &bufferList,
&bufferList, NULL);
NULL);
#else
err = AudioConverterFillBuffer(
stream->inputSRConverter,
ringBufferIOProc,
&stream->inputRingBuffer,
&size,
(void *)data );
#endif /* PA_NEW_HAL */
if( err != RING_BUFFER_EMPTY ) if( err != RING_BUFFER_EMPTY )
ERR( err ); ERR( err );
if( err != noErr && err != RING_BUFFER_EMPTY ) if( err != noErr && err != RING_BUFFER_EMPTY )
@ -2695,7 +2593,6 @@ static OSStatus AudioIOProc( void *inRefCon,
goto stop_stream; goto stop_stream;
} }
f = size / ( chan * sizeof(float) ); f = size / ( chan * sizeof(float) );
PaUtil_SetInputFrameCount( &(stream->bufferProcessor), f ); PaUtil_SetInputFrameCount( &(stream->bufferProcessor), f );
if( f ) if( f )
@ -2766,7 +2663,7 @@ static PaError CloseStream( PaStream* s )
if( stream->outputUnit ) { if( stream->outputUnit ) {
int count = removeFromXRunListenerList( stream ); int count = removeFromXRunListenerList( stream );
if( count == 0 ) if( count == 0 )
pa_AudioDeviceRemovePropertyListener( stream->outputDevice, PaMacCore_AudioDeviceRemovePropertyListener( stream->outputDevice,
0, 0,
false, false,
kAudioDeviceProcessorOverload, kAudioDeviceProcessorOverload,
@ -2775,7 +2672,7 @@ static PaError CloseStream( PaStream* s )
if( stream->inputUnit && stream->outputUnit != stream->inputUnit ) { if( stream->inputUnit && stream->outputUnit != stream->inputUnit ) {
int count = removeFromXRunListenerList( stream ); int count = removeFromXRunListenerList( stream );
if( count == 0 ) if( count == 0 )
pa_AudioDeviceRemovePropertyListener( stream->inputDevice, PaMacCore_AudioDeviceRemovePropertyListener( stream->inputDevice,
0, 0,
true, true,
kAudioDeviceProcessorOverload, kAudioDeviceProcessorOverload,

View file

@ -63,32 +63,24 @@
#include <pthread.h> #include <pthread.h>
#include <sys/time.h> #include <sys/time.h>
OSStatus pa_AudioHardwareGetProperty( OSStatus PaMacCore_AudioHardwareGetProperty(
AudioHardwarePropertyID inPropertyID, AudioHardwarePropertyID inPropertyID,
UInt32* ioPropertyDataSize, UInt32* ioPropertyDataSize,
void* outPropertyData) void* outPropertyData)
{ {
#if PA_NEW_HAL
AudioObjectPropertyAddress address = { inPropertyID, kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyElementMaster }; AudioObjectPropertyAddress address = { inPropertyID, kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyElementMaster };
return AudioObjectGetPropertyData(kAudioObjectSystemObject, &address, 0, NULL, ioPropertyDataSize, outPropertyData); return AudioObjectGetPropertyData(kAudioObjectSystemObject, &address, 0, NULL, ioPropertyDataSize, outPropertyData);
#else
return AudioHardwareGetProperty(inPropertyID, ioPropertyDataSize, outPropertyData);
#endif /* PA_NEW_HAL */
} }
OSStatus pa_AudioHardwareGetPropertySize( OSStatus PaMacCore_AudioHardwareGetPropertySize(
AudioHardwarePropertyID inPropertyID, AudioHardwarePropertyID inPropertyID,
UInt32* outSize) UInt32* outSize)
{ {
#if PA_NEW_HAL
AudioObjectPropertyAddress address = { inPropertyID, kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyElementMaster }; AudioObjectPropertyAddress address = { inPropertyID, kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyElementMaster };
return AudioObjectGetPropertyDataSize(kAudioObjectSystemObject, &address, 0, NULL, outSize); return AudioObjectGetPropertyDataSize(kAudioObjectSystemObject, &address, 0, NULL, outSize);
#else
return AudioHardwareGetPropertyInfo(inPropertyID, outSize, NULL);
#endif /* PA_NEW_HAL */
} }
OSStatus pa_AudioDeviceGetProperty( OSStatus PaMacCore_AudioDeviceGetProperty(
AudioDeviceID inDevice, AudioDeviceID inDevice,
UInt32 inChannel, UInt32 inChannel,
Boolean isInput, Boolean isInput,
@ -96,16 +88,12 @@ OSStatus pa_AudioDeviceGetProperty(
UInt32* ioPropertyDataSize, UInt32* ioPropertyDataSize,
void* outPropertyData) void* outPropertyData)
{ {
#if PA_NEW_HAL
AudioObjectPropertyScope scope = isInput ? kAudioDevicePropertyScopeInput : kAudioDevicePropertyScopeOutput; AudioObjectPropertyScope scope = isInput ? kAudioDevicePropertyScopeInput : kAudioDevicePropertyScopeOutput;
AudioObjectPropertyAddress address = { inPropertyID, scope, inChannel }; AudioObjectPropertyAddress address = { inPropertyID, scope, inChannel };
return AudioObjectGetPropertyData(inDevice, &address, 0, NULL, ioPropertyDataSize, outPropertyData); return AudioObjectGetPropertyData(inDevice, &address, 0, NULL, ioPropertyDataSize, outPropertyData);
#else
return AudioDeviceGetProperty(inDevice, inChannel, isInput, inPropertyID, ioPropertyDataSize, outPropertyData);
#endif /* PA_NEW_HAL */
} }
OSStatus pa_AudioDeviceSetProperty( OSStatus PaMacCore_AudioDeviceSetProperty(
AudioDeviceID inDevice, AudioDeviceID inDevice,
const AudioTimeStamp* inWhen, const AudioTimeStamp* inWhen,
UInt32 inChannel, UInt32 inChannel,
@ -114,78 +102,58 @@ OSStatus pa_AudioDeviceSetProperty(
UInt32 inPropertyDataSize, UInt32 inPropertyDataSize,
const void* inPropertyData) const void* inPropertyData)
{ {
#if PA_NEW_HAL
AudioObjectPropertyScope scope = isInput ? kAudioDevicePropertyScopeInput : kAudioDevicePropertyScopeOutput; AudioObjectPropertyScope scope = isInput ? kAudioDevicePropertyScopeInput : kAudioDevicePropertyScopeOutput;
AudioObjectPropertyAddress address = { inPropertyID, scope, inChannel }; AudioObjectPropertyAddress address = { inPropertyID, scope, inChannel };
return AudioObjectSetPropertyData(inDevice, &address, 0, NULL, inPropertyDataSize, inPropertyData); return AudioObjectSetPropertyData(inDevice, &address, 0, NULL, inPropertyDataSize, inPropertyData);
#else
return AudioDeviceSetProperty(inDevice, inWhen, inChannel, isInput, inPropertyID, inPropertyDataSize, inPropertyData);
#endif /* PA_NEW_HAL */
} }
OSStatus pa_AudioDeviceGetPropertySize( OSStatus PaMacCore_AudioDeviceGetPropertySize(
AudioDeviceID inDevice, AudioDeviceID inDevice,
UInt32 inChannel, UInt32 inChannel,
Boolean isInput, Boolean isInput,
AudioDevicePropertyID inPropertyID, AudioDevicePropertyID inPropertyID,
UInt32* outSize) UInt32* outSize)
{ {
#if PA_NEW_HAL
AudioObjectPropertyScope scope = isInput ? kAudioDevicePropertyScopeInput : kAudioDevicePropertyScopeOutput; AudioObjectPropertyScope scope = isInput ? kAudioDevicePropertyScopeInput : kAudioDevicePropertyScopeOutput;
AudioObjectPropertyAddress address = { inPropertyID, scope, inChannel }; AudioObjectPropertyAddress address = { inPropertyID, scope, inChannel };
return AudioObjectGetPropertyDataSize(inDevice, &address, 0, NULL, outSize); return AudioObjectGetPropertyDataSize(inDevice, &address, 0, NULL, outSize);
#else
return AudioDeviceGetPropertyInfo(inDevice, inChannel, isInput, inPropertyID, outSize, NULL);
#endif /* PA_NEW_HAL */
} }
OSStatus pa_AudioDeviceAddPropertyListener( OSStatus PaMacCore_AudioDeviceAddPropertyListener(
AudioDeviceID inDevice, AudioDeviceID inDevice,
UInt32 inChannel, UInt32 inChannel,
Boolean isInput, Boolean isInput,
AudioDevicePropertyID inPropertyID, AudioDevicePropertyID inPropertyID,
pa_AudioDevicePropertyListenerProc inProc, AudioObjectPropertyListenerProc inProc,
void* inClientData) void* inClientData)
{ {
#if PA_NEW_HAL
AudioObjectPropertyScope scope = isInput ? kAudioDevicePropertyScopeInput : kAudioDevicePropertyScopeOutput; AudioObjectPropertyScope scope = isInput ? kAudioDevicePropertyScopeInput : kAudioDevicePropertyScopeOutput;
AudioObjectPropertyAddress address = { inPropertyID, scope, inChannel }; AudioObjectPropertyAddress address = { inPropertyID, scope, inChannel };
return AudioObjectAddPropertyListener(inDevice, &address, inProc, inClientData); return AudioObjectAddPropertyListener(inDevice, &address, inProc, inClientData);
#else
return AudioDeviceAddPropertyListener(inDevice, inChannel, isInput, inPropertyID, inProc, inClientData);
#endif /* PA_NEW_HAL */
} }
OSStatus pa_AudioDeviceRemovePropertyListener( OSStatus PaMacCore_AudioDeviceRemovePropertyListener(
AudioDeviceID inDevice, AudioDeviceID inDevice,
UInt32 inChannel, UInt32 inChannel,
Boolean isInput, Boolean isInput,
AudioDevicePropertyID inPropertyID, AudioDevicePropertyID inPropertyID,
pa_AudioDevicePropertyListenerProc inProc, AudioObjectPropertyListenerProc inProc,
void* inClientData) void* inClientData)
{ {
#if PA_NEW_HAL
AudioObjectPropertyScope scope = isInput ? kAudioDevicePropertyScopeInput : kAudioDevicePropertyScopeOutput; AudioObjectPropertyScope scope = isInput ? kAudioDevicePropertyScopeInput : kAudioDevicePropertyScopeOutput;
AudioObjectPropertyAddress address = { inPropertyID, scope, inChannel }; AudioObjectPropertyAddress address = { inPropertyID, scope, inChannel };
return AudioObjectRemovePropertyListener(inDevice, &address, inProc, inClientData); return AudioObjectRemovePropertyListener(inDevice, &address, inProc, inClientData);
#else
return AudioDeviceRemovePropertyListener(inDevice, inChannel, isInput, inPropertyID, inProc);
#endif /* PA_NEW_HAL */
} }
OSStatus pa_AudioStreamGetProperty( OSStatus PaMacCore_AudioStreamGetProperty(
AudioStreamID inStream, AudioStreamID inStream,
UInt32 inChannel, UInt32 inChannel,
AudioDevicePropertyID inPropertyID, AudioDevicePropertyID inPropertyID,
UInt32* ioPropertyDataSize, UInt32* ioPropertyDataSize,
void* outPropertyData) void* outPropertyData)
{ {
#if PA_NEW_HAL
AudioObjectPropertyAddress address = { inPropertyID, kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyElementMaster }; AudioObjectPropertyAddress address = { inPropertyID, kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyElementMaster };
return AudioObjectGetPropertyData(inStream, &address, 0, NULL, ioPropertyDataSize, outPropertyData); return AudioObjectGetPropertyData(inStream, &address, 0, NULL, ioPropertyDataSize, outPropertyData);
#else
return AudioStreamGetProperty(inStream, inChannel, inPropertyID, ioPropertyDataSize, outPropertyData);
#endif /* PA_NEW_HAL */
} }
PaError PaMacCore_SetUnixError( int err, int line ) PaError PaMacCore_SetUnixError( int err, int line )
@ -274,14 +242,6 @@ PaError PaMacCore_SetError(OSStatus error, int line, int isError)
case kAudioUnitErr_TooManyFramesToProcess: case kAudioUnitErr_TooManyFramesToProcess:
errorText = "Audio Unit: Too Many Frames"; errorText = "Audio Unit: Too Many Frames";
result = paInternalError; break; result = paInternalError; break;
#if ! PA_NEW_HAL
case kAudioUnitErr_IllegalInstrument:
errorText = "Audio Unit: Illegal Instrument";
result = paInternalError; break;
case kAudioUnitErr_InstrumentTypeNotFound:
errorText = "Audio Unit: Instrument Type Not Found";
result = paInternalError; break;
#endif
case kAudioUnitErr_InvalidFile: case kAudioUnitErr_InvalidFile:
errorText = "Audio Unit: Invalid File"; errorText = "Audio Unit: Invalid File";
result = paInternalError; break; result = paInternalError; break;
@ -434,7 +394,6 @@ long computeRingBufferSize( const PaStreamParameters *inputParameters,
* since it represents a theoretically better implementation. * since it represents a theoretically better implementation.
*/ */
#if PA_NEW_HAL
OSStatus propertyProc( OSStatus propertyProc(
AudioObjectID inObjectID, AudioObjectID inObjectID,
UInt32 inNumberAddresses, UInt32 inNumberAddresses,
@ -444,18 +403,6 @@ OSStatus propertyProc(
// this is where we would set the condition variable // this is where we would set the condition variable
return noErr; return noErr;
} }
#else
OSStatus propertyProc(
AudioDeviceID inDevice,
UInt32 inChannel,
Boolean isInput,
AudioDevicePropertyID inPropertyID,
void* inClientData )
{
// this is where we would set the condition variable
return noErr;
}
#endif /* PA_NEW_HAL */
/* 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 be acknowledged, and returns the final value, which is not guaranteed
@ -479,7 +426,7 @@ PaError AudioDeviceSetPropertyNowAndWaitForChange(
UInt32 outPropertyDataSize = inPropertyDataSize; UInt32 outPropertyDataSize = inPropertyDataSize;
/* First, see if it already has that value. If so, return. */ /* First, see if it already has that value. If so, return. */
macErr = pa_AudioDeviceGetProperty( inDevice, inChannel, macErr = PaMacCore_AudioDeviceGetProperty( inDevice, inChannel,
isInput, inPropertyID, isInput, inPropertyID,
&outPropertyDataSize, outPropertyData ); &outPropertyDataSize, outPropertyData );
if( macErr ) { if( macErr ) {
@ -496,7 +443,7 @@ PaError AudioDeviceSetPropertyNowAndWaitForChange(
/* If we were using a cond variable, we'd do something useful here, /* If we were using a cond variable, we'd do something useful here,
but for now, this is just to make 10.6 happy. */ but for now, this is just to make 10.6 happy. */
macErr = pa_AudioDeviceAddPropertyListener( inDevice, inChannel, isInput, macErr = PaMacCore_AudioDeviceAddPropertyListener( inDevice, inChannel, isInput,
inPropertyID, propertyProc, inPropertyID, propertyProc,
NULL ); NULL );
if( macErr ) if( macErr )
@ -504,7 +451,7 @@ PaError AudioDeviceSetPropertyNowAndWaitForChange(
goto failMac; goto failMac;
/* set property */ /* set property */
macErr = pa_AudioDeviceSetProperty( inDevice, NULL, inChannel, macErr = PaMacCore_AudioDeviceSetProperty( inDevice, NULL, inChannel,
isInput, inPropertyID, isInput, inPropertyID,
inPropertyDataSize, inPropertyData ); inPropertyDataSize, inPropertyData );
if( macErr ) if( macErr )
@ -519,7 +466,7 @@ PaError AudioDeviceSetPropertyNowAndWaitForChange(
memcpy( &tv2, &tv1, sizeof( struct timeval ) ); memcpy( &tv2, &tv1, sizeof( struct timeval ) );
while( tv2.tv_sec - tv1.tv_sec < 30 ) { while( tv2.tv_sec - tv1.tv_sec < 30 ) {
/* now read the property back out */ /* now read the property back out */
macErr = pa_AudioDeviceGetProperty( inDevice, inChannel, macErr = PaMacCore_AudioDeviceGetProperty( inDevice, inChannel,
isInput, inPropertyID, isInput, inPropertyID,
&outPropertyDataSize, outPropertyData ); &outPropertyDataSize, outPropertyData );
if( macErr ) { if( macErr ) {
@ -528,7 +475,7 @@ PaError AudioDeviceSetPropertyNowAndWaitForChange(
} }
/* and compare... */ /* and compare... */
if( 0==memcmp( outPropertyData, inPropertyData, outPropertyDataSize ) ) { if( 0==memcmp( outPropertyData, inPropertyData, outPropertyDataSize ) ) {
pa_AudioDeviceRemovePropertyListener( inDevice, inChannel, isInput, inPropertyID, propertyProc, NULL); PaMacCore_AudioDeviceRemovePropertyListener( inDevice, inChannel, isInput, inPropertyID, propertyProc, NULL);
return paNoError; return paNoError;
} }
/* No match yet, so let's sleep and try again. */ /* No match yet, so let's sleep and try again. */
@ -537,11 +484,11 @@ PaError AudioDeviceSetPropertyNowAndWaitForChange(
} }
DBUG( ("Timeout waiting for device setting.\n" ) ); DBUG( ("Timeout waiting for device setting.\n" ) );
pa_AudioDeviceRemovePropertyListener( inDevice, inChannel, isInput, inPropertyID, propertyProc, NULL ); PaMacCore_AudioDeviceRemovePropertyListener( inDevice, inChannel, isInput, inPropertyID, propertyProc, NULL );
return paNoError; return paNoError;
failMac: failMac:
pa_AudioDeviceRemovePropertyListener( inDevice, inChannel, isInput, inPropertyID, propertyProc, NULL ); PaMacCore_AudioDeviceRemovePropertyListener( inDevice, inChannel, isInput, inPropertyID, propertyProc, NULL );
return ERR( macErr ); return ERR( macErr );
} }
@ -587,7 +534,7 @@ PaError setBestSampleRateForDevice( const AudioDeviceID device,
return paInvalidSampleRate; return paInvalidSampleRate;
/* -- generate a list of available sample rates -- */ /* -- generate a list of available sample rates -- */
err = pa_AudioDeviceGetPropertySize( device, 0, isInput, err = PaMacCore_AudioDeviceGetPropertySize( device, 0, isInput,
kAudioDevicePropertyAvailableNominalSampleRates, kAudioDevicePropertyAvailableNominalSampleRates,
&propsize ); &propsize );
if( err ) if( err )
@ -595,7 +542,7 @@ PaError setBestSampleRateForDevice( const AudioDeviceID device,
ranges = (AudioValueRange *)calloc( 1, propsize ); ranges = (AudioValueRange *)calloc( 1, propsize );
if( !ranges ) if( !ranges )
return paInsufficientMemory; return paInsufficientMemory;
err = pa_AudioDeviceGetProperty( device, 0, isInput, err = PaMacCore_AudioDeviceGetProperty( device, 0, isInput,
kAudioDevicePropertyAvailableNominalSampleRates, kAudioDevicePropertyAvailableNominalSampleRates,
&propsize, ranges ); &propsize, ranges );
if( err ) if( err )
@ -675,10 +622,10 @@ PaError setBestFramesPerBuffer( const AudioDeviceID device,
} }
/* -- try and set exact FPB -- */ /* -- try and set exact FPB -- */
err = pa_AudioDeviceSetProperty( device, NULL, 0, isInput, err = PaMacCore_AudioDeviceSetProperty( device, NULL, 0, isInput,
kAudioDevicePropertyBufferFrameSize, kAudioDevicePropertyBufferFrameSize,
propsize, &requestedFramesPerBuffer); propsize, &requestedFramesPerBuffer);
err = pa_AudioDeviceGetProperty( device, 0, isInput, err = PaMacCore_AudioDeviceGetProperty( device, 0, isInput,
kAudioDevicePropertyBufferFrameSize, kAudioDevicePropertyBufferFrameSize,
&propsize, actualFramesPerBuffer); &propsize, actualFramesPerBuffer);
if( err ) if( err )
@ -693,7 +640,7 @@ PaError setBestFramesPerBuffer( const AudioDeviceID device,
// Clip requested value against legal range for the device. // Clip requested value against legal range for the device.
propsize = sizeof(AudioValueRange); propsize = sizeof(AudioValueRange);
err = pa_AudioDeviceGetProperty( device, 0, isInput, err = PaMacCore_AudioDeviceGetProperty( device, 0, isInput,
kAudioDevicePropertyBufferFrameSizeRange, kAudioDevicePropertyBufferFrameSizeRange,
&propsize, &range ); &propsize, &range );
if( err ) if( err )
@ -711,11 +658,11 @@ PaError setBestFramesPerBuffer( const AudioDeviceID device,
/* --- set the buffer size (ignore errors) -- */ /* --- set the buffer size (ignore errors) -- */
propsize = sizeof( UInt32 ); propsize = sizeof( UInt32 );
err = pa_AudioDeviceSetProperty( device, NULL, 0, isInput, err = PaMacCore_AudioDeviceSetProperty( device, NULL, 0, isInput,
kAudioDevicePropertyBufferFrameSize, kAudioDevicePropertyBufferFrameSize,
propsize, &requestedFramesPerBuffer ); propsize, &requestedFramesPerBuffer );
/* --- read the property to check that it was set -- */ /* --- read the property to check that it was set -- */
err = pa_AudioDeviceGetProperty( device, 0, isInput, err = PaMacCore_AudioDeviceGetProperty( device, 0, isInput,
kAudioDevicePropertyBufferFrameSize, kAudioDevicePropertyBufferFrameSize,
&propsize, actualFramesPerBuffer ); &propsize, actualFramesPerBuffer );
@ -744,7 +691,6 @@ static PaMacXRunListNode firstXRunListNode;
static int xRunListSize; static int xRunListSize;
static pthread_mutex_t xrunMutex; static pthread_mutex_t xrunMutex;
#if PA_NEW_HAL
OSStatus xrunCallback( OSStatus xrunCallback(
AudioObjectID inDevice, AudioObjectID inDevice,
UInt32 inNumberAddresses, UInt32 inNumberAddresses,
@ -756,41 +702,6 @@ OSStatus xrunCallback(
int ret = pthread_mutex_trylock( &xrunMutex ) ; int ret = pthread_mutex_trylock( &xrunMutex ) ;
if( ret == 0 ) {
node = node->next ; //skip the first node
for( ; node; node=node->next ) {
PaMacCoreStream *stream = node->stream;
if( stream->state != ACTIVE )
continue; //if the stream isn't active, we don't care if the device is dropping
if( isInput ) {
if( stream->inputDevice == inDevice )
OSAtomicOr32( paInputOverflow, &stream->xrunFlags );
} else {
if( stream->outputDevice == inDevice )
OSAtomicOr32( paOutputUnderflow, &stream->xrunFlags );
}
}
pthread_mutex_unlock( &xrunMutex );
}
return 0;
}
#else
OSStatus xrunCallback(
AudioDeviceID inDevice,
UInt32 inChannel,
Boolean isInput,
AudioDevicePropertyID inPropertyID,
void* inClientData)
{
PaMacXRunListNode *node = (PaMacXRunListNode *) inClientData;
int ret = pthread_mutex_trylock( &xrunMutex ) ;
if( ret == 0 ) { if( ret == 0 ) {
node = node->next ; //skip the first node node = node->next ; //skip the first node
@ -815,7 +726,6 @@ OSStatus xrunCallback(
return 0; return 0;
} }
#endif /* PA_NEW_HAL */
int initializeXRunListenerList( void ) int initializeXRunListenerList( void )
{ {

View file

@ -111,28 +111,16 @@
# define VVDBUG(MSG) # define VVDBUG(MSG)
#endif #endif
#if (MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5) OSStatus PaMacCore_AudioHardwareGetProperty(
#define PA_NEW_HAL 1
#else
#define PA_NEW_HAL 0
#endif
#if PA_NEW_HAL
typedef AudioObjectPropertyListenerProc pa_AudioDevicePropertyListenerProc;
#else
typedef AudioDevicePropertyListenerProc pa_AudioDevicePropertyListenerProc;
#endif /* PA_NEW_HAL */
OSStatus pa_AudioHardwareGetProperty(
AudioHardwarePropertyID inPropertyID, AudioHardwarePropertyID inPropertyID,
UInt32* ioPropertyDataSize, UInt32* ioPropertyDataSize,
void* outPropertyData); void* outPropertyData);
OSStatus pa_AudioHardwareGetPropertySize( OSStatus PaMacCore_AudioHardwareGetPropertySize(
AudioHardwarePropertyID inPropertyID, AudioHardwarePropertyID inPropertyID,
UInt32* outSize); UInt32* outSize);
OSStatus pa_AudioDeviceGetProperty( OSStatus PaMacCore_AudioDeviceGetProperty(
AudioDeviceID inDevice, AudioDeviceID inDevice,
UInt32 inChannel, UInt32 inChannel,
Boolean isInput, Boolean isInput,
@ -140,7 +128,7 @@ OSStatus pa_AudioDeviceGetProperty(
UInt32* ioPropertyDataSize, UInt32* ioPropertyDataSize,
void* outPropertyData); void* outPropertyData);
OSStatus pa_AudioDeviceSetProperty( OSStatus PaMacCore_AudioDeviceSetProperty(
AudioDeviceID inDevice, AudioDeviceID inDevice,
const AudioTimeStamp* inWhen, const AudioTimeStamp* inWhen,
UInt32 inChannel, UInt32 inChannel,
@ -149,30 +137,30 @@ OSStatus pa_AudioDeviceSetProperty(
UInt32 inPropertyDataSize, UInt32 inPropertyDataSize,
const void* inPropertyData); const void* inPropertyData);
OSStatus pa_AudioDeviceGetPropertySize( OSStatus PaMacCore_AudioDeviceGetPropertySize(
AudioDeviceID inDevice, AudioDeviceID inDevice,
UInt32 inChannel, UInt32 inChannel,
Boolean isInput, Boolean isInput,
AudioDevicePropertyID inPropertyID, AudioDevicePropertyID inPropertyID,
UInt32* outSize); UInt32* outSize);
OSStatus pa_AudioDeviceAddPropertyListener( OSStatus PaMacCore_AudioDeviceAddPropertyListener(
AudioDeviceID inDevice, AudioDeviceID inDevice,
UInt32 inChannel, UInt32 inChannel,
Boolean isInput, Boolean isInput,
AudioDevicePropertyID inPropertyID, AudioDevicePropertyID inPropertyID,
pa_AudioDevicePropertyListenerProc inProc, AudioObjectPropertyListenerProc inProc,
void* inClientData); void* inClientData);
OSStatus pa_AudioDeviceRemovePropertyListener( OSStatus PaMacCore_AudioDeviceRemovePropertyListener(
AudioDeviceID inDevice, AudioDeviceID inDevice,
UInt32 inChannel, UInt32 inChannel,
Boolean isInput, Boolean isInput,
AudioDevicePropertyID inPropertyID, AudioDevicePropertyID inPropertyID,
pa_AudioDevicePropertyListenerProc inProc, AudioObjectPropertyListenerProc inProc,
void* inClientData); void* inClientData);
OSStatus pa_AudioStreamGetProperty( OSStatus PaMacCore_AudioStreamGetProperty(
AudioStreamID inStream, AudioStreamID inStream,
UInt32 inChannel, UInt32 inChannel,
AudioDevicePropertyID inPropertyID, AudioDevicePropertyID inPropertyID,
@ -207,20 +195,11 @@ long computeRingBufferSize( const PaStreamParameters *inputParameters,
long outputFramesPerBuffer, long outputFramesPerBuffer,
double sampleRate ); double sampleRate );
#if PA_NEW_HAL
OSStatus propertyProc( OSStatus propertyProc(
AudioObjectID inObjectID, AudioObjectID inObjectID,
UInt32 inNumberAddresses, UInt32 inNumberAddresses,
const AudioObjectPropertyAddress* inAddresses, const AudioObjectPropertyAddress* inAddresses,
void* inClientData); void* inClientData);
#else
OSStatus propertyProc(
AudioDeviceID inDevice,
UInt32 inChannel,
Boolean isInput,
AudioDevicePropertyID inPropertyID,
void* inClientData );
#endif /* PA_NEW_HAL */
/* 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 be acknowledged, and returns the final value, which is not guaranteed
@ -270,20 +249,11 @@ PaError setBestFramesPerBuffer( const AudioDeviceID device,
* *
*********************/ *********************/
#if PA_NEW_HAL
OSStatus xrunCallback( OSStatus xrunCallback(
AudioObjectID inObjectID, AudioObjectID inObjectID,
UInt32 inNumberAddresses, UInt32 inNumberAddresses,
const AudioObjectPropertyAddress* inAddresses, const AudioObjectPropertyAddress* inAddresses,
void * inClientData ); void * inClientData );
#else
OSStatus xrunCallback(
AudioDeviceID inDevice,
UInt32 inChannel,
Boolean isInput,
AudioDevicePropertyID inPropertyID,
void* inClientData ) ;
#endif /* PA_NEW_HAL */
/** returns zero on success or a unix style error code. */ /** returns zero on success or a unix style error code. */
int initializeXRunListenerList( void ); int initializeXRunListenerList( void );