PortAudio  2.0
Macros | Functions
pa_mac_core.c File Reference
#include "pa_mac_core_internal.h"
#include <string.h>
#include <libkern/OSAtomic.h>
#include "pa_mac_core.h"
#include "pa_mac_core_utilities.h"
#include "pa_mac_core_blocking.h"

Macros

#define PA_MAC_SMALL_BUFFER_SIZE   (64)
 
#define RING_BUFFER_ADVANCE_DENOMINATOR   (4)
 
#define PA_AUHAL_SET_LAST_HOST_ERROR(errorCode, errorText)   PaUtil_SetLastHostErrorInfo( paCoreAudio, errorCode, errorText )
 
#define ERR_WRAP(mac_err)   do { result = mac_err ; line = __LINE__ ; if ( result != noErr ) goto error ; } while(0)
 
#define HOST_TIME_TO_PA_TIME(x)   ( AudioConvertHostTimeToNanos( (x) ) * 1.0E-09) /* convert to nanoseconds and then to seconds */
 
#define RING_BUFFER_EMPTY   (1000)
 
#define ERR_WRAP(mac_err)   do { result = mac_err ; if ( result != noErr ) return ERR(result) ; } while(0)
 
#define ERR_WRAP(mac_err)   do { result = mac_err ; if ( result != noErr ) return ERR(result) ; } while(0)
 

Functions

PaError PaMacCore_Initialize (PaUtilHostApiRepresentation **hostApi, PaHostApiIndex index)
 
void PaMacCore_SetupStreamInfo (PaMacCoreStreamInfo *data, const unsigned long flags)
 
void PaMacCore_SetupChannelMap (PaMacCoreStreamInfo *data, const SInt32 *const channelMap, const unsigned long channelMapSize)
 
const char * PaMacCore_GetChannelName (int device, int channelIndex, bool input)
 
PaError PaMacCore_GetBufferSizeRange (PaDeviceIndex device, long *minBufferSizeFrames, long *maxBufferSizeFrames)
 
AudioDeviceID PaMacCore_GetStreamInputDevice (PaStream *s)
 
AudioDeviceID PaMacCore_GetStreamOutputDevice (PaStream *s)
 

Macro Definition Documentation

#define ERR_WRAP (   mac_err)    do { result = mac_err ; line = __LINE__ ; if ( result != noErr ) goto error ; } while(0)
#define ERR_WRAP (   mac_err)    do { result = mac_err ; if ( result != noErr ) return ERR(result) ; } while(0)
#define ERR_WRAP (   mac_err)    do { result = mac_err ; if ( result != noErr ) return ERR(result) ; } while(0)
#define HOST_TIME_TO_PA_TIME (   x)    ( AudioConvertHostTimeToNanos( (x) ) * 1.0E-09) /* convert to nanoseconds and then to seconds */
#define PA_AUHAL_SET_LAST_HOST_ERROR (   errorCode,
  errorText 
)    PaUtil_SetLastHostErrorInfo( paCoreAudio, errorCode, errorText )
#define PA_MAC_SMALL_BUFFER_SIZE   (64)
#define RING_BUFFER_ADVANCE_DENOMINATOR   (4)
#define RING_BUFFER_EMPTY   (1000)

Function Documentation

PaError PaMacCore_GetBufferSizeRange ( PaDeviceIndex  device,
long *  minBufferSizeFrames,
long *  maxBufferSizeFrames 
)

Retrieve the range of legal native buffer sizes for the specified device, in sample frames.

Parameters
deviceThe global index of the PortAudio device about which the query is being made.
minBufferSizeFramesA pointer to the location which will receive the minimum buffer size value.
maxBufferSizeFramesA pointer to the location which will receive the maximum buffer size value.
See Also
kAudioDevicePropertyBufferFrameSizeRange in the CoreAudio SDK.

References PaUtilHostApiRepresentation::deviceInfos, PaMacAUHAL::devIds, PaMacAUHAL::inheritedHostApiRep, PaDeviceInfo::maxOutputChannels, paCoreAudio, PaMacCore_AudioDeviceGetProperty(), paNoError, PaUtil_DeviceIndexToHostApiDeviceIndex(), PaUtil_GetHostApiRepresentation(), and WARNING.

const char* PaMacCore_GetChannelName ( int  device,
int  channelIndex,
bool  input 
)

Returns a statically allocated string with the device's name for the given channel. NULL will be returned on failure.

This function's implementation is not complete!

Parameters
deviceThe PortAudio device index.
channelThe channel number who's name is requested.
Returns
a statically allocated string with the name of the device. Because this string is statically allocated, it must be copied if it is to be saved and used by the user after another call to this function.

References PaUtilHostApiRepresentation::deviceInfos, PaMacAUHAL::devIds, PaDeviceInfo::name, paCoreAudio, PaMacCore_AudioDeviceGetProperty(), PaMacCore_AudioDeviceGetPropertySize(), paNoError, and PaUtil_GetHostApiRepresentation().

AudioDeviceID PaMacCore_GetStreamInputDevice ( PaStream s)

Retrieve the AudioDeviceID of the input device assigned to an open stream

Parameters
sThe stream to query.
Returns
A valid AudioDeviceID, or NULL if an error occurred.

References PaMacCoreStream::inputDevice, and VVDBUG.

AudioDeviceID PaMacCore_GetStreamOutputDevice ( PaStream s)

Retrieve the AudioDeviceID of the output device assigned to an open stream

Parameters
sThe stream to query.
Returns
A valid AudioDeviceID, or NULL if an error occurred.

References PaMacCoreStream::outputDevice, and VVDBUG.

PaError PaMacCore_Initialize ( PaUtilHostApiRepresentation **  hostApi,
PaHostApiIndex  index 
)
void PaMacCore_SetupChannelMap ( PaMacCoreStreamInfo data,
const SInt32 *const  channelMap,
unsigned long  channelMapSize 
)

call this after pa_SetupMacCoreStreamInfo to use channel mapping as described in notes.txt.

Parameters
dataThe stream info structure to assign a channel mapping to
channelMapThe channel map array, as described in notes.txt. This array pointer will be used directly (ie the underlying data will not be copied), so the caller should not free the array until after the stream has been opened.
channelMapSizeThe size of the channel map array.

References PaMacCoreStreamInfo::channelMap, and PaMacCoreStreamInfo::channelMapSize.

void PaMacCore_SetupStreamInfo ( PaMacCoreStreamInfo data,
unsigned long  flags 
)

Functions Use this function to initialize a paMacCoreStreamInfo struct using the requested flags. Note that channel mapping is turned off after a call to this function.

Parameters
dataThe datastructure to initialize
flagsThe flags to initialize the datastructure with.

References PaMacCoreStreamInfo::channelMap, PaMacCoreStreamInfo::channelMapSize, PaMacCoreStreamInfo::flags, PaMacCoreStreamInfo::hostApiType, paCoreAudio, PaMacCoreStreamInfo::size, and PaMacCoreStreamInfo::version.