VuoAudio implementation.
Definition in file VuoAudio.cc.
Go to the source code of this file.
Classes | |
struct | _VuoAudio_internal |
Private data for a VuoAudio instance. More... | |
Macros | |
#define | setRealizedDevice(newDevice) |
Helper for VuoAudioInputDevice_realize. More... | |
Typedefs | |
typedef std::map< void *, std::queue< VuoList_VuoAudioSamples > > | pendingOutputType |
For each unique audio source (identified by void * ), a queue of buffers to output. More... | |
typedef std::map< void *, std::map< VuoInteger, VuoReal > > | lastOutputSampleType |
For each unique audio source (identified by void * ), the last sample value that was output on each channel. More... | |
typedef struct _VuoAudio_internal * | VuoAudio_internal |
Private data for a VuoAudio instance. More... | |
Functions | |
static void | __attribute__ ((constructor)) VuoAudio_init() |
Ensure we're listening for the system's device notifications. More... | |
VuoList_VuoAudioInputDevice | VuoAudio_getInputDevices (void) |
Returns a list of the available audio input devices. More... | |
VuoList_VuoAudioOutputDevice | VuoAudio_getOutputDevices (void) |
Returns a list of the available audio output devices. More... | |
static OSStatus | VuoAudio_reconfigurationCallback (AudioObjectID inObjectID, UInt32 inNumberAddresses, const AudioObjectPropertyAddress *inAddresses, void *inClientData) |
Invoked by Core Audio. More... | |
void | VuoAudio_use (void) |
Indicates that the caller needs to get notifications about audio devices. More... | |
void | VuoAudio_disuse (void) |
Indicates that the caller no longer needs notifications about audio devices. More... | |
void | VuoAudio_addDevicesChangedTriggers (VuoOutputTrigger(inputDevices, VuoList_VuoAudioInputDevice), VuoOutputTrigger(outputDevices, VuoList_VuoAudioOutputDevice)) |
Adds a trigger callback, to be invoked whenever the list of known audio devices changes. More... | |
void | VuoAudio_removeDevicesChangedTriggers (VuoOutputTrigger(inputDevices, VuoList_VuoAudioInputDevice), VuoOutputTrigger(outputDevices, VuoList_VuoAudioOutputDevice)) |
Removes a trigger callback previously added by VuoAudio_addDevicesChangedTriggers. More... | |
int | VuoAudio_receivedEvent (void *outputBuffer, void *inputBuffer, unsigned int nBufferFrames, double streamTime, RtAudioStreamStatus status, void *userData) |
RtAudio calls this function when a new sample buffer is ready or needed. More... | |
VuoAudioIn | VuoAudioIn_getShared (VuoAudioInputDevice aid) |
Returns the reference-counted object for the specified audio input device. More... | |
VuoAudioOut | VuoAudioOut_getShared (VuoAudioOutputDevice aod) |
Returns the reference-counted object for the specified audio output device. More... | |
void | VuoAudioIn_addTrigger (VuoAudioIn ai, VuoOutputTrigger(receivedChannels, VuoList_VuoAudioSamples)) |
Sets up the audio input device to call the trigger functions when it receives an event. More... | |
void | VuoAudioOut_addTrigger (VuoAudioOut ao, VuoOutputTrigger(requestedChannels, VuoReal)) |
Sets up the audio output device to call the trigger functions when it receives an event. More... | |
void | VuoAudioIn_removeTrigger (VuoAudioIn ai, VuoOutputTrigger(receivedChannels, VuoList_VuoAudioSamples)) |
Stops the audio input device from calling trigger functions when it receives an event. More... | |
void | VuoAudioOut_removeTrigger (VuoAudioOut ao, VuoOutputTrigger(requestedChannels, VuoReal)) |
Stops the audio output device from calling trigger functions when it receives an event. More... | |
void | VuoAudioOut_sendChannels (VuoAudioOut ao, VuoList_VuoAudioSamples channels, void *id) |
Enqueues channels for eventual playback. More... | |
bool | VuoAudioInputDevice_realize (VuoAudioInputDevice device, VuoAudioInputDevice *realizedDevice) |
If device 's channel count is unknown (zero): More... | |
bool | VuoAudioOutputDevice_realize (VuoAudioOutputDevice device, VuoAudioOutputDevice *realizedDevice) |
If device 's channel count is unknown (zero): More... | |
VUOKEYEDPOOL (unsigned int, VuoAudio_internal) | |
static void | VuoAudio_destroy (VuoAudio_internal ai) |
VuoAudio_internal | VuoAudio_make (unsigned int deviceId) |
VUOKEYEDPOOL_DEFINE (unsigned int, VuoAudio_internal, VuoAudio_make) | |
Variables | |
const VuoInteger | VuoAudio_queueSize = 8 |
The number of buffers that must be enqueued before starting playback. More... | |
static VuoTriggerSet< VuoList_VuoAudioInputDevice > | VuoAudio_inputDeviceCallbacks |
Trigger functions to call when the list of audio input devices changes. More... | |
static VuoTriggerSet< VuoList_VuoAudioOutputDevice > | VuoAudio_outputDeviceCallbacks |
Trigger functions to call when the list of audio output devices changes. More... | |
unsigned int | VuoAudio_useCount = 0 |
Process-wide count of callers (typically node instances) interested in notifications about audio devices. More... | |
struct _VuoAudio_internal |
Class Members | ||
---|---|---|
VuoAudioInputDevice | inputDevice | The device's id must be nonnegative, and channelCount must be set. |
VuoTriggerSet< VuoList_VuoAudioSamples > | inputTriggers | Trigger methods to call when an audio buffer is received. |
lastOutputSampleType | lastOutputSample | The last sample value sent on each channel (to smoothly move back to 0 DC when there's a dropout). Not present means no buffer was sent to the channel during the last frame. |
VuoAudioOutputDevice | outputDevice | The device's id must be nonnegative, and channelCount must be set. |
VuoTriggerSet< VuoReal > | outputTriggers | Trigger methods to call when an audio buffer is needed. |
pendingOutputType | pendingOutput | Sample buffers waiting to be output. |
dispatch_queue_t | pendingOutputQueue | Serializes access to the following set of buffers. |
VuoReal | priorStreamTime | The time at which the prior VuoAudio_receivedEvent() happened, to track stream overflows. |
RtAudio * | rta | RtAudio's device pointer. |
#define setRealizedDevice | ( | newDevice | ) |
Helper for VuoAudioInputDevice_realize.
Definition at line 608 of file VuoAudio.cc.
typedef std::map<void *, std::map<VuoInteger, VuoReal> > lastOutputSampleType |
For each unique audio source (identified by void *
), the last sample value that was output on each channel.
Definition at line 205 of file VuoAudio.cc.
typedef std::map<void *, std::queue<VuoList_VuoAudioSamples> > pendingOutputType |
For each unique audio source (identified by void *
), a queue of buffers to output.
Definition at line 200 of file VuoAudio.cc.
typedef struct _VuoAudio_internal * VuoAudio_internal |
Private data for a VuoAudio instance.
|
static |
Ensure we're listening for the system's device notifications.
https://b33p.net/kosada/node/12551 http://lists.apple.com/archives/Coreaudio-api/2010/Aug//msg00304.html
Definition at line 59 of file VuoAudio.cc.
void VuoAudio_addDevicesChangedTriggers | ( | VuoOutputTrigger(inputDevices, VuoList_VuoAudioInputDevice) | , |
VuoOutputTrigger(outputDevices, VuoList_VuoAudioOutputDevice) | |||
) |
Adds a trigger callback, to be invoked whenever the list of known audio devices changes.
Call VuoAudio_use()
before calling this.
This function may be called from any thread.
Definition at line 177 of file VuoAudio.cc.
|
static |
Definition at line 445 of file VuoAudio.cc.
void VuoAudio_disuse | ( | void | ) |
Indicates that the caller no longer needs notifications about audio devices.
This function may be called from any thread.
Definition at line 145 of file VuoAudio.cc.
VuoList_VuoAudioInputDevice VuoAudio_getInputDevices | ( | void | ) |
Returns a list of the available audio input devices.
Definition at line 74 of file VuoAudio.cc.
VuoList_VuoAudioOutputDevice VuoAudio_getOutputDevices | ( | void | ) |
Returns a list of the available audio output devices.
Definition at line 91 of file VuoAudio.cc.
VuoAudio_internal VuoAudio_make | ( | unsigned int | deviceId | ) |
Definition at line 363 of file VuoAudio.cc.
int VuoAudio_receivedEvent | ( | void * | outputBuffer, |
void * | inputBuffer, | ||
unsigned int | nBufferFrames, | ||
double | streamTime, | ||
RtAudioStreamStatus | status, | ||
void * | userData | ||
) |
RtAudio calls this function when a new sample buffer is ready or needed.
Definition at line 230 of file VuoAudio.cc.
|
static |
Invoked by Core Audio.
Definition at line 108 of file VuoAudio.cc.
void VuoAudio_removeDevicesChangedTriggers | ( | VuoOutputTrigger(inputDevices, VuoList_VuoAudioInputDevice) | , |
VuoOutputTrigger(outputDevices, VuoList_VuoAudioOutputDevice) | |||
) |
Removes a trigger callback previously added by VuoAudio_addDevicesChangedTriggers.
This function may be called from any thread.
Definition at line 191 of file VuoAudio.cc.
void VuoAudio_use | ( | void | ) |
Indicates that the caller needs to get notifications about audio devices.
This function may be called from any thread.
Definition at line 121 of file VuoAudio.cc.
void VuoAudioIn_addTrigger | ( | VuoAudioIn | ai, |
VuoOutputTrigger(receivedChannels, VuoList_VuoAudioSamples) | |||
) |
Sets up the audio input device to call the trigger functions when it receives an event.
This function may be called from any thread.
Definition at line 519 of file VuoAudio.cc.
VuoAudioIn VuoAudioIn_getShared | ( | VuoAudioInputDevice | aid | ) |
Returns the reference-counted object for the specified audio input device.
Definition at line 484 of file VuoAudio.cc.
void VuoAudioIn_removeTrigger | ( | VuoAudioIn | ai, |
VuoOutputTrigger(receivedChannels, VuoList_VuoAudioSamples) | |||
) |
Stops the audio input device from calling trigger functions when it receives an event.
This function may be called from any thread.
Definition at line 555 of file VuoAudio.cc.
bool VuoAudioInputDevice_realize | ( | VuoAudioInputDevice | device, |
VuoAudioInputDevice * | realizedDevice | ||
) |
If device
's channel count is unknown (zero):
realizedDevice
to that device, and returns true.realizedDevice
unset.If device
's channel count is already known (presumably from the List Audio Devices
node), sets realizedDevice
to a copy of device
, and returns true. (Doesn't bother checking whether the device is currently present.)
This function may be called from any thread.
Definition at line 626 of file VuoAudio.cc.
void VuoAudioOut_addTrigger | ( | VuoAudioOut | ao, |
VuoOutputTrigger(requestedChannels, VuoReal) | |||
) |
Sets up the audio output device to call the trigger functions when it receives an event.
This function may be called from any thread.
Definition at line 537 of file VuoAudio.cc.
VuoAudioOut VuoAudioOut_getShared | ( | VuoAudioOutputDevice | aod | ) |
Returns the reference-counted object for the specified audio output device.
Definition at line 500 of file VuoAudio.cc.
void VuoAudioOut_removeTrigger | ( | VuoAudioOut | ao, |
VuoOutputTrigger(requestedChannels, VuoReal) | |||
) |
Stops the audio output device from calling trigger functions when it receives an event.
This function may be called from any thread.
Definition at line 573 of file VuoAudio.cc.
void VuoAudioOut_sendChannels | ( | VuoAudioOut | ao, |
VuoList_VuoAudioSamples | channels, | ||
void * | id | ||
) |
Enqueues channels
for eventual playback.
id
should be a unique identifier for the audio stream (e.g., a pointer to the node's instance data).
When multiple sources are simultaneously sending to the same audio device, each is buffered independently — each unique id
gets its own queue, and at output time a single buffer from each source's queue is mixed to form the final output stream.
Definition at line 595 of file VuoAudio.cc.
bool VuoAudioOutputDevice_realize | ( | VuoAudioOutputDevice | device, |
VuoAudioOutputDevice * | realizedDevice | ||
) |
If device
's channel count is unknown (zero):
realizedDevice
to that device, and returns true.realizedDevice
unset.If device
's channel count is already known (presumably from the List Audio Devices
node), sets realizedDevice
to a copy of device
, and returns true. (Doesn't bother checking whether the device is currently present.)
This function may be called from any thread.
Definition at line 735 of file VuoAudio.cc.
VUOKEYEDPOOL | ( | unsigned int | , |
VuoAudio_internal | |||
) |
VUOKEYEDPOOL_DEFINE | ( | unsigned int | , |
VuoAudio_internal | , | ||
VuoAudio_make | |||
) |
|
static |
Trigger functions to call when the list of audio input devices changes.
Definition at line 50 of file VuoAudio.cc.
|
static |
Trigger functions to call when the list of audio output devices changes.
Definition at line 51 of file VuoAudio.cc.
const VuoInteger VuoAudio_queueSize = 8 |
The number of buffers that must be enqueued before starting playback.
Definition at line 48 of file VuoAudio.cc.
unsigned int VuoAudio_useCount = 0 |
Process-wide count of callers (typically node instances) interested in notifications about audio devices.
Definition at line 52 of file VuoAudio.cc.