Wave Arts VQE  1.00
Voice Quality Enhancement
Public Member Functions | Protected Attributes
WadMacHAL Class Reference

WaAudioDev implemented with Mac Core Audio. More...

#include <WadMacHAL.h>

Inheritance diagram for WadMacHAL:
WaAudioDev WaAudioDevPort WadResMacHAL

List of all members.

Public Member Functions

 WadMacHAL ()
 Constructor.
 ~WadMacHAL ()
 Destructor.
int Init ()
 initialize the OS API and discover all devices
virtual int GetNumDevices (int *pNumDev)
 Get the count of devices discovered.
virtual int GetDevInfo (int devId, WadDevInfo *pInfo)
 Get device information.
virtual int GetDefaultInDevId (int *pId)
 Get the default input device.
virtual int GetDefaultOutDevId (int *pId)
 Get the default output device.
virtual int Open (WadParam *param, WadCallbackFn *inFn, WadCallbackFn *outFn, void *arg)
 Open devices for streaming.
virtual int Start ()
 Start streaming.
virtual int Stop ()
 Stop streaming.
virtual void Close ()
 Close devices and release memory.
virtual void Wait ()
 Wait for stream to complete.
virtual int SetVol (int devId, bool outputFlag, float vol)
 Set volume.
virtual int GetVol (int devId, bool outputFlag, float *pVol)
 Get volume.
virtual bool IsRunning ()
 Test if stream I/O thread is running.
virtual int GetBufTime (bool isOutput, int *pBufTimeMsec)
 Get buffer time.
virtual WadAPI GetAPI ()
 return API enum
OSStatus Init (AudioDeviceID input, AudioDeviceID output)
 Initialize.
void Cleanup ()
 Cleanup.
OSStatus SetInputDeviceAsCurrent (AudioDeviceID in)
 Set input device.
OSStatus SetOutputDeviceAsCurrent (AudioDeviceID out)
 Set output device.

Protected Attributes

WaACDevInfom_Devs
 device table

Detailed Description

WaAudioDev implemented with Mac Core Audio.

WaAudioDev C++ wrapper around Mac Core Audio using AUHAL and output audio units.


Member Function Documentation

void WadMacHAL::Close ( ) [virtual]

Close devices and release memory.

Close the devices and release all memory associated with streaming. Different devices can be re-opened with different parameters without having to recreate the WaAudioDev object.

Implements WaAudioDevPort.

Reimplemented in WadResMacHAL.

WadAPI WadMacHAL::GetAPI ( ) [virtual]

return API enum

Return enum specifying the low level API in use.

Implements WaAudioDev.

int WadMacHAL::GetBufTime ( bool  isOutput,
int *  pBufTimeMsec 
) [virtual]

Get buffer time.

Parameters:
[in]isOutputtrue if get output buffer time, else get input buffer time
[out]pBufTimeMsecpointer to buffer time in milliseconds

Return total buffer times in msec for the currently open devices. This is useful in case we want to increase the buffering because we're getting dropouts.

Reimplemented from WaAudioDev.

int WadMacHAL::GetDefaultInDevId ( int *  pId) [virtual]

Get the default input device.

Parameters:
[out]pIdpointer to default input device ID

Implements WaAudioDev.

int WadMacHAL::GetDefaultOutDevId ( int *  pId) [virtual]

Get the default output device.

Parameters:
[out]pIdpointer to default output device ID

Implements WaAudioDev.

int WadMacHAL::GetDevInfo ( int  devId,
WadDevInfo pInfo 
) [virtual]

Get device information.

Parameters:
[in]devIdthe device ID, 0 to numDev-1
[out]pInfopointer to device info

Implements WaAudioDev.

int WadMacHAL::GetNumDevices ( int *  pNumDev) [virtual]

Get the count of devices discovered.

Parameters:
[out]pNumDevpointer to number of devices

Implements WaAudioDev.

int WadMacHAL::GetVol ( int  devId,
bool  isOutput,
float *  pVol 
) [virtual]

Get volume.

Parameters:
[in]devIddevice ID
[in]isOutputtrue if get output volume, else get input volume
[out]volpointer to volume, 0.0 (min) to 1.0 (max)

Get volume of device. Any discovered device can be specified and the device does not need to be open for streaming.

Reimplemented from WaAudioDev.

int WadMacHAL::Init ( ) [virtual]

initialize the OS API and discover all devices

Initialize, which means do device discovery. The idea is that the devices are enumerated at Init time, and from then on only this device set can be used. Any dynamic changes to the device set can be caught via messages and then this WaAudioDev object must be recreated to discover the new devices updating the device table.

Implements WaAudioDev.

virtual bool WadMacHAL::IsRunning ( ) [inline, virtual]

Test if stream I/O thread is running.

Implement this to return false if the I/O thread has exited perhaps because a callback has returned false. This is a non-blocking alternative to Wait(). But why can't we just use IsOpen()? Ah, because the thread terminating doesn't automatically close the device, that's why.

Implements WaAudioDev.

int WadMacHAL::Open ( WadParam param,
WadCallbackFn inFn,
WadCallbackFn outFn,
void *  arg 
) [virtual]

Open devices for streaming.

Open devices for streaming with provided parameters. Asynchronous callbacks fetch and deliver sample buffers: inFn delivers input sample buffers and outFn fetches output sample buffers. Streaming directions are determined by valid device IDs in parameter structure, at least one direction must be enabled. Pass NULL for callback if that direction is not enabled.

Parameters:
[in]paramStream parameters
[in]inFnInput callback function, or NULL
[in]outFnOutput callback function, or NULL
[in]argArgument to callbacks

Implements WaAudioDevPort.

Reimplemented in WadResMacHAL.

int WadMacHAL::SetVol ( int  devId,
bool  isOutput,
float  vol 
) [virtual]

Set volume.

Parameters:
[in]devIddevice ID
[in]isOutputtrue if set output volume, else set input volume
[in]volvolume, 0.0 (min) to 1.0 (max)

Set volume of device. Any discovered device can be specified and the device does not need to be open for streaming.

Reimplemented from WaAudioDev.

int WadMacHAL::Start ( ) [virtual]

Start streaming.

Start streaming audio. This must be called after Open to actually start stream.

Implements WaAudioDevPort.

int WadMacHAL::Stop ( ) [virtual]

Stop streaming.

Stop streaming audio. Stream can be restarted by calling Start().

Implements WaAudioDevPort.

void WadMacHAL::Wait ( ) [virtual]

Wait for stream to complete.

Wait for streaming I/O thread to terminate. This call blocks and should only be called if the callbacks will return false status to stop streaming and terminate I/O thread.

Implements WaAudioDevPort.


The documentation for this class was generated from the following files:
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Defines