/* First try with CFString */
UInt32 size = sizeof(nameRef);
- error = pa_AudioDeviceGetProperty( hostApiDevice,
+ error = PaMacCore_AudioDeviceGetProperty( hostApiDevice,
channelIndex + 1,
input,
kAudioDevicePropertyChannelNameCFString,
{
/* try the C String */
size = 0;
- error = pa_AudioDeviceGetPropertySize( hostApiDevice,
+ error = PaMacCore_AudioDeviceGetPropertySize( hostApiDevice,
channelIndex + 1,
input,
kAudioDevicePropertyChannelName,
if( !ensureChannelNameSize( size ) )
return NULL;
- error = pa_AudioDeviceGetProperty( hostApiDevice,
+ error = PaMacCore_AudioDeviceGetProperty( hostApiDevice,
channelIndex + 1,
input,
kAudioDevicePropertyChannelName,
if( macCoreHostApi->inheritedHostApiRep.deviceInfos[hostApiDeviceIndex]->maxOutputChannels == 0 )
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;
*maxBufferSizeFrames = audioRange.mMaximum;
auhalHostApi->devIds = NULL;
/* -- figure out how many devices there are -- */
- pa_AudioHardwareGetPropertySize( kAudioHardwarePropertyDevices,
+ PaMacCore_AudioHardwareGetPropertySize( kAudioHardwarePropertyDevices,
&propsize);
auhalHostApi->devCount = propsize / sizeof( AudioDeviceID );
propsize );
if( !auhalHostApi->devIds )
return paInsufficientMemory;
- pa_AudioHardwareGetProperty( kAudioHardwarePropertyDevices,
+ PaMacCore_AudioHardwareGetProperty( kAudioHardwarePropertyDevices,
&propsize,
auhalHostApi->devIds );
#ifdef MAC_CORE_VERBOSE_DEBUG
/* I am not sure how these calls to AudioHardwareGetProperty()
could fail, but in case they do, we use the first available
device as the default. */
- if( 0 != pa_AudioHardwareGetProperty(kAudioHardwarePropertyDefaultInputDevice,
+ if( 0 != PaMacCore_AudioHardwareGetProperty(kAudioHardwarePropertyDefaultInputDevice,
&size,
&auhalHostApi->defaultIn) ) {
int i;
}
}
}
- if( 0 != pa_AudioHardwareGetProperty(kAudioHardwarePropertyDefaultOutputDevice,
+ if( 0 != PaMacCore_AudioHardwareGetProperty(kAudioHardwarePropertyDefaultOutputDevice,
&size,
&auhalHostApi->defaultOut) ) {
int i;
UInt32 resultSize = desiredSize;
AudioValueRange 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 = MIN( resultSize, audioRange.mMaximum );
*allowedSize = resultSize;
printf("Stream #%d = %d---------------------- \n", i, streamIDs[i] );
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 );
}
}
// 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.
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( propSize == sizeof(AudioStreamID) )
{
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);
- 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;
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;
*fixedLatencyPtr = deviceLatency + streamLatency + safetyOffset;
// For high latency use the default device buffer size.
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;
*lowLatencyFramesPtr = fixedLatency + clippedMinBufferSize;
/* Get the number of channels from the stream configuration.
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)
return err;
buflist = PaUtil_AllocateMemory(propSize);
if( !buflist )
return paInsufficientMemory;
- err = ERR(pa_AudioDeviceGetProperty(macCoreDeviceId, 0, isInput, kAudioDevicePropertyStreamConfiguration, &propSize, buflist));
+ err = ERR(PaMacCore_AudioDeviceGetProperty(macCoreDeviceId, 0, isInput, kAudioDevicePropertyStreamConfiguration, &propSize, buflist));
if (err)
goto error;
/* Get the device name using CFString */
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)
{
/* 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)
return err;
name = PaUtil_GroupAllocateMemory(auhalHostApi->allocations,propSize+1);
if ( !name )
return paInsufficientMemory;
- err = ERR(pa_AudioDeviceGetProperty(macCoreDeviceId, 0, 0, kAudioDevicePropertyDeviceName, &propSize, name));
+ err = ERR(PaMacCore_AudioDeviceGetProperty(macCoreDeviceId, 0, 0, kAudioDevicePropertyDeviceName, &propSize, name));
if (err)
return err;
}
/* Try to get the default sample rate. Don't fail if we can't get this. */
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)
deviceInfo->defaultSampleRate = 0.0;
else
Float64 sampleRate = 0.0;
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 */
{
deviceProperties->sampleRate = sampleRate;
return osErr;
}
-#if PA_NEW_HAL
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;
- // 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!
assert( stream->streamRepresentation.magic == PA_STREAM_MAGIC );
- OSStatus osErr = UpdateSampleRateFromDeviceProperty( stream, inDevice, isInput, kAudioDevicePropertyActualSampleRate );
+ OSStatus osErr = UpdateSampleRateFromDeviceProperty( stream, inDevice, isInput, kAudioDevicePropertyActualSampleRate );
if( osErr == noErr )
{
UpdateTimeStampOffsets( stream );
}
return osErr;
}
-#endif /* PA_NEW_HAL */
/* ================================================================================= */
static OSStatus QueryUInt32DeviceProperty( AudioDeviceID deviceID, Boolean isInput, AudioDevicePropertyID propertyID, UInt32 *outValue )
{
UInt32 propertyValue = 0;
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 )
{
*outValue = propertyValue;
return osErr;
}
-#if PA_NEW_HAL
static OSStatus AudioDevicePropertyGenericListenerProc(AudioObjectID inDevice, UInt32 inNumberAddresses, const AudioObjectPropertyAddress * inAddresses, void * inClientData)
{
OSStatus osErr = noErr;
- PaMacCoreStream * stream = (PaMacCoreStream *) inClientData;
+ PaMacCoreStream *stream = (PaMacCoreStream*)inClientData;
bool isInput = inAddresses->mScope == kAudioDevicePropertyScopeInput;
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!
assert( stream->streamRepresentation.magic == PA_STREAM_MAGIC );
}
return osErr;
}
-#endif /* PA_NEW_HAL */
/* ================================================================================= */
/*
if( (osErr = QueryUInt32DeviceProperty( deviceID, isInput,
kAudioDevicePropertySafetyOffset, &deviceProperties->safetyOffset )) != noErr ) return osErr;
- pa_AudioDeviceAddPropertyListener( deviceID, 0, isInput, kAudioDevicePropertyActualSampleRate,
+ PaMacCore_AudioDeviceAddPropertyListener( deviceID, 0, isInput, kAudioDevicePropertyActualSampleRate,
AudioDevicePropertyActualSampleRateListenerProc, stream );
- pa_AudioDeviceAddPropertyListener( deviceID, 0, isInput, kAudioStreamPropertyLatency,
+ PaMacCore_AudioDeviceAddPropertyListener( deviceID, 0, isInput, kAudioStreamPropertyLatency,
AudioDevicePropertyGenericListenerProc, stream );
- pa_AudioDeviceAddPropertyListener( deviceID, 0, isInput, kAudioDevicePropertyBufferFrameSize,
+ PaMacCore_AudioDeviceAddPropertyListener( deviceID, 0, isInput, kAudioDevicePropertyBufferFrameSize,
AudioDevicePropertyGenericListenerProc, stream );
- pa_AudioDeviceAddPropertyListener( deviceID, 0, isInput, kAudioDevicePropertySafetyOffset,
+ PaMacCore_AudioDeviceAddPropertyListener( deviceID, 0, isInput, kAudioDevicePropertySafetyOffset,
AudioDevicePropertyGenericListenerProc, stream );
return osErr;
static void CleanupDevicePropertyListeners( PaMacCoreStream *stream, AudioDeviceID deviceID, Boolean isInput )
{
- pa_AudioDeviceRemovePropertyListener( deviceID, 0, isInput, kAudioDevicePropertyActualSampleRate,
+ PaMacCore_AudioDeviceRemovePropertyListener( deviceID, 0, isInput, kAudioDevicePropertyActualSampleRate,
AudioDevicePropertyActualSampleRateListenerProc, stream );
- pa_AudioDeviceRemovePropertyListener( deviceID, 0, isInput, kAudioDevicePropertyLatency,
+ PaMacCore_AudioDeviceRemovePropertyListener( deviceID, 0, isInput, kAudioDevicePropertyLatency,
AudioDevicePropertyGenericListenerProc, stream );
- pa_AudioDeviceRemovePropertyListener( deviceID, 0, isInput, kAudioDevicePropertyBufferFrameSize,
+ PaMacCore_AudioDeviceRemovePropertyListener( deviceID, 0, isInput, kAudioDevicePropertyBufferFrameSize,
AudioDevicePropertyGenericListenerProc, stream );
- pa_AudioDeviceRemovePropertyListener( deviceID, 0, isInput, kAudioDevicePropertySafetyOffset,
+ PaMacCore_AudioDeviceRemovePropertyListener( deviceID, 0, isInput, kAudioDevicePropertySafetyOffset,
AudioDevicePropertyGenericListenerProc, stream );
}
sizeof(AudioDeviceID) ) );
}
/* -- add listener for dropouts -- */
- result = pa_AudioDeviceAddPropertyListener( *audioDevice,
+ result = PaMacCore_AudioDeviceAddPropertyListener( *audioDevice,
0,
outStreamParams ? false : true,
kAudioDeviceProcessorOverload,
#define RING_BUFFER_EMPTY (1000)
-#if PA_NEW_HAL
static OSStatus ringBufferIOProc(
AudioConverterRef inAudioConverter,
UInt32* ioNumberDataPackets,
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 ) {
*outData = NULL;
*ioDataSize = 0;
return noErr;
}
-#endif /* PA_NEW_HAL */
/*
* Called by the AudioUnit API to process audio from the sound card.
UInt32 size;
float data[ inChan * frames ];
size = sizeof( data );
-#if PA_NEW_HAL
AudioBufferList bufferList;
bufferList.mNumberBuffers = 1;
bufferList.mBuffers[0].mNumberChannels = inChan;
&size,
&bufferList,
NULL);
-#else
- err = AudioConverterFillBuffer(
- stream->inputSRConverter,
- ringBufferIOProc,
- &stream->inputRingBuffer,
- &size,
- (void *)&data );
-#endif /* PA_NEW_HAL */
if( err == RING_BUFFER_EMPTY )
{ /* the ring buffer callback underflowed */
err = 0;
long f;
size = sizeof( data );
-#if PA_NEW_HAL
- AudioBufferList bufferList;
- bufferList.mNumberBuffers = 1;
- bufferList.mBuffers[0].mNumberChannels = chan;
- bufferList.mBuffers[0].mDataByteSize = size;
- bufferList.mBuffers[0].mData = data;
- err = AudioConverterFillComplexBuffer(
- stream->inputSRConverter,
- ringBufferIOProc,
- &stream->inputRingBuffer,
- &size,
- &bufferList,
- NULL);
-#else
- err = AudioConverterFillBuffer(
- stream->inputSRConverter,
- ringBufferIOProc,
- &stream->inputRingBuffer,
- &size,
- (void *)data );
-#endif /* PA_NEW_HAL */
+ AudioBufferList bufferList;
+ bufferList.mNumberBuffers = 1;
+ bufferList.mBuffers[0].mNumberChannels = chan;
+ bufferList.mBuffers[0].mDataByteSize = size;
+ bufferList.mBuffers[0].mData = data;
+ err = AudioConverterFillComplexBuffer(
+ stream->inputSRConverter,
+ ringBufferIOProc,
+ &stream->inputRingBuffer,
+ &size,
+ &bufferList,
+ NULL);
if( err != RING_BUFFER_EMPTY )
ERR( err );
if( err != noErr && err != RING_BUFFER_EMPTY )
goto stop_stream;
}
-
f = size / ( chan * sizeof(float) );
PaUtil_SetInputFrameCount( &(stream->bufferProcessor), f );
if( f )
if( stream->outputUnit ) {
int count = removeFromXRunListenerList( stream );
if( count == 0 )
- pa_AudioDeviceRemovePropertyListener( stream->outputDevice,
+ PaMacCore_AudioDeviceRemovePropertyListener( stream->outputDevice,
0,
false,
kAudioDeviceProcessorOverload,
if( stream->inputUnit && stream->outputUnit != stream->inputUnit ) {
int count = removeFromXRunListenerList( stream );
if( count == 0 )
- pa_AudioDeviceRemovePropertyListener( stream->inputDevice,
+ PaMacCore_AudioDeviceRemovePropertyListener( stream->inputDevice,
0,
true,
kAudioDeviceProcessorOverload,
#include <pthread.h>
#include <sys/time.h>
-OSStatus pa_AudioHardwareGetProperty(
+OSStatus PaMacCore_AudioHardwareGetProperty(
AudioHardwarePropertyID inPropertyID,
UInt32* ioPropertyDataSize,
void* outPropertyData)
{
-#if PA_NEW_HAL
AudioObjectPropertyAddress address = { inPropertyID, kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyElementMaster };
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,
UInt32* outSize)
{
-#if PA_NEW_HAL
AudioObjectPropertyAddress address = { inPropertyID, kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyElementMaster };
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,
UInt32 inChannel,
Boolean isInput,
UInt32* ioPropertyDataSize,
void* outPropertyData)
{
-#if PA_NEW_HAL
AudioObjectPropertyScope scope = isInput ? kAudioDevicePropertyScopeInput : kAudioDevicePropertyScopeOutput;
AudioObjectPropertyAddress address = { inPropertyID, scope, inChannel };
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,
const AudioTimeStamp* inWhen,
UInt32 inChannel,
UInt32 inPropertyDataSize,
const void* inPropertyData)
{
-#if PA_NEW_HAL
AudioObjectPropertyScope scope = isInput ? kAudioDevicePropertyScopeInput : kAudioDevicePropertyScopeOutput;
AudioObjectPropertyAddress address = { inPropertyID, scope, inChannel };
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,
UInt32 inChannel,
Boolean isInput,
AudioDevicePropertyID inPropertyID,
UInt32* outSize)
{
-#if PA_NEW_HAL
AudioObjectPropertyScope scope = isInput ? kAudioDevicePropertyScopeInput : kAudioDevicePropertyScopeOutput;
AudioObjectPropertyAddress address = { inPropertyID, scope, inChannel };
return AudioObjectGetPropertyDataSize(inDevice, &address, 0, NULL, outSize);
-#else
- return AudioDeviceGetPropertyInfo(inDevice, inChannel, isInput, inPropertyID, outSize, NULL);
-#endif /* PA_NEW_HAL */
}
-OSStatus pa_AudioDeviceAddPropertyListener(
- AudioDeviceID inDevice,
- UInt32 inChannel,
- Boolean isInput,
- AudioDevicePropertyID inPropertyID,
- pa_AudioDevicePropertyListenerProc inProc,
- void* inClientData)
+OSStatus PaMacCore_AudioDeviceAddPropertyListener(
+ AudioDeviceID inDevice,
+ UInt32 inChannel,
+ Boolean isInput,
+ AudioDevicePropertyID inPropertyID,
+ AudioObjectPropertyListenerProc inProc,
+ void* inClientData)
{
-#if PA_NEW_HAL
AudioObjectPropertyScope scope = isInput ? kAudioDevicePropertyScopeInput : kAudioDevicePropertyScopeOutput;
AudioObjectPropertyAddress address = { inPropertyID, scope, inChannel };
return AudioObjectAddPropertyListener(inDevice, &address, inProc, inClientData);
-#else
- return AudioDeviceAddPropertyListener(inDevice, inChannel, isInput, inPropertyID, inProc, inClientData);
-#endif /* PA_NEW_HAL */
}
-OSStatus pa_AudioDeviceRemovePropertyListener(
- AudioDeviceID inDevice,
- UInt32 inChannel,
- Boolean isInput,
- AudioDevicePropertyID inPropertyID,
- pa_AudioDevicePropertyListenerProc inProc,
- void* inClientData)
+OSStatus PaMacCore_AudioDeviceRemovePropertyListener(
+ AudioDeviceID inDevice,
+ UInt32 inChannel,
+ Boolean isInput,
+ AudioDevicePropertyID inPropertyID,
+ AudioObjectPropertyListenerProc inProc,
+ void* inClientData)
{
-#if PA_NEW_HAL
AudioObjectPropertyScope scope = isInput ? kAudioDevicePropertyScopeInput : kAudioDevicePropertyScopeOutput;
AudioObjectPropertyAddress address = { inPropertyID, scope, inChannel };
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,
UInt32 inChannel,
AudioDevicePropertyID inPropertyID,
UInt32* ioPropertyDataSize,
void* outPropertyData)
{
-#if PA_NEW_HAL
AudioObjectPropertyAddress address = { inPropertyID, kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyElementMaster };
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 )
case kAudioUnitErr_TooManyFramesToProcess:
errorText = "Audio Unit: Too Many Frames";
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:
errorText = "Audio Unit: Invalid File";
result = paInternalError; break;
* since it represents a theoretically better implementation.
*/
-#if PA_NEW_HAL
OSStatus propertyProc(
AudioObjectID inObjectID,
UInt32 inNumberAddresses,
// this is where we would set the condition variable
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
be acknowledged, and returns the final value, which is not guaranteed
UInt32 outPropertyDataSize = inPropertyDataSize;
/* First, see if it already has that value. If so, return. */
- macErr = pa_AudioDeviceGetProperty( inDevice, inChannel,
+ macErr = PaMacCore_AudioDeviceGetProperty( inDevice, inChannel,
isInput, inPropertyID,
&outPropertyDataSize, outPropertyData );
if( macErr ) {
/* If we were using a cond variable, we'd do something useful here,
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,
NULL );
if( macErr )
goto failMac;
/* set property */
- macErr = pa_AudioDeviceSetProperty( inDevice, NULL, inChannel,
+ macErr = PaMacCore_AudioDeviceSetProperty( inDevice, NULL, inChannel,
isInput, inPropertyID,
inPropertyDataSize, inPropertyData );
if( macErr )
memcpy( &tv2, &tv1, sizeof( struct timeval ) );
while( tv2.tv_sec - tv1.tv_sec < 30 ) {
/* now read the property back out */
- macErr = pa_AudioDeviceGetProperty( inDevice, inChannel,
+ macErr = PaMacCore_AudioDeviceGetProperty( inDevice, inChannel,
isInput, inPropertyID,
&outPropertyDataSize, outPropertyData );
if( macErr ) {
}
/* and compare... */
if( 0==memcmp( outPropertyData, inPropertyData, outPropertyDataSize ) ) {
- pa_AudioDeviceRemovePropertyListener( inDevice, inChannel, isInput, inPropertyID, propertyProc, NULL);
+ PaMacCore_AudioDeviceRemovePropertyListener( inDevice, inChannel, isInput, inPropertyID, propertyProc, NULL);
return paNoError;
}
/* No match yet, so let's sleep and try again. */
}
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;
failMac:
- pa_AudioDeviceRemovePropertyListener( inDevice, inChannel, isInput, inPropertyID, propertyProc, NULL );
+ PaMacCore_AudioDeviceRemovePropertyListener( inDevice, inChannel, isInput, inPropertyID, propertyProc, NULL );
return ERR( macErr );
}
return paInvalidSampleRate;
/* -- generate a list of available sample rates -- */
- err = pa_AudioDeviceGetPropertySize( device, 0, isInput,
+ err = PaMacCore_AudioDeviceGetPropertySize( device, 0, isInput,
kAudioDevicePropertyAvailableNominalSampleRates,
&propsize );
if( err )
ranges = (AudioValueRange *)calloc( 1, propsize );
if( !ranges )
return paInsufficientMemory;
- err = pa_AudioDeviceGetProperty( device, 0, isInput,
+ err = PaMacCore_AudioDeviceGetProperty( device, 0, isInput,
kAudioDevicePropertyAvailableNominalSampleRates,
&propsize, ranges );
if( err )
}
/* -- try and set exact FPB -- */
- err = pa_AudioDeviceSetProperty( device, NULL, 0, isInput,
+ err = PaMacCore_AudioDeviceSetProperty( device, NULL, 0, isInput,
kAudioDevicePropertyBufferFrameSize,
propsize, &requestedFramesPerBuffer);
- err = pa_AudioDeviceGetProperty( device, 0, isInput,
+ err = PaMacCore_AudioDeviceGetProperty( device, 0, isInput,
kAudioDevicePropertyBufferFrameSize,
&propsize, actualFramesPerBuffer);
if( err )
// Clip requested value against legal range for the device.
propsize = sizeof(AudioValueRange);
- err = pa_AudioDeviceGetProperty( device, 0, isInput,
+ err = PaMacCore_AudioDeviceGetProperty( device, 0, isInput,
kAudioDevicePropertyBufferFrameSizeRange,
&propsize, &range );
if( err )
/* --- set the buffer size (ignore errors) -- */
propsize = sizeof( UInt32 );
- err = pa_AudioDeviceSetProperty( device, NULL, 0, isInput,
+ err = PaMacCore_AudioDeviceSetProperty( device, NULL, 0, isInput,
kAudioDevicePropertyBufferFrameSize,
propsize, &requestedFramesPerBuffer );
/* --- read the property to check that it was set -- */
- err = pa_AudioDeviceGetProperty( device, 0, isInput,
+ err = PaMacCore_AudioDeviceGetProperty( device, 0, isInput,
kAudioDevicePropertyBufferFrameSize,
&propsize, actualFramesPerBuffer );
static int xRunListSize;
static pthread_mutex_t xrunMutex;
-#if PA_NEW_HAL
OSStatus xrunCallback(
AudioObjectID inDevice,
UInt32 inNumberAddresses,
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 ) {
node = node->next ; //skip the first node
return 0;
}
-#endif /* PA_NEW_HAL */
int initializeXRunListenerList( void )
{