|
Wave Arts VQE
1.00
Voice Quality Enhancement
|
Abstract interface to an audio device. More...
#include <WaAudioDev.h>
Public Member Functions | |
| virtual int | Open (WadParam *param, WadCallbackFn *inFn, WadCallbackFn *outFn, void *arg)=0 |
| Open devices for streaming. | |
| virtual int | Start ()=0 |
| Start streaming. | |
| virtual int | Stop ()=0 |
| Stop streaming. | |
| virtual void | Wait ()=0 |
| Wait for stream to complete. | |
| virtual void | Close ()=0 |
| Close devices and release memory. | |
| virtual bool | IsOpen ()=0 |
| Test if streaming. | |
| virtual WaAudioDev * | GetDevice ()=0 |
| Get audio device. | |
Abstract interface to an audio device.
The device port is an abstract interface to a device. Opening a device port creates a I/O stream with the device. The stream can be input, output, or input & output. Only one stream is supported per device instance, so you have to create a WaAudioDev for each stream. Derived ports can be used to connect processing objects to an actual device port. So this interface can be used for the audio device itself, or to implement a resampled port, a format conversion port, or an echo-cancelled port.
Implementation specific options are passed to the object constructor, which is not part of this interface. This way the Open call is the same for all device implementations.
Processing chaining is supported via the callback functions passed to Open(). Open can open a downstream port passing callbacks to its own processing functions which in turn call the original callbacks to read/write sound data. The constructor of a derived port will typically be passed the downstream object to Open, either a device or another port.
This is a convenient way to connect processing objects to devices, provided the desired architecture is known a priori. It's not so convenient to dynamically connect processing objects to devices. See WadResWASAPI for an example of a changing the architecture during an Open call.
Use Open to create all internal objects and open the device for streaming. After Open you must call Start to actually start the device streaming. Stop is used to stop the stream, which can be restarted using Start. Close closes the stream and releases all objects in use. In a chain of device ports, Close first closes the actual device at the end of the chain and then closes ports working back towards the application. Given a port, call GetDevice to get a pointer to the actual device at the end of the device chain.
Integer WaAudioDev methods return enum WadStatus results. Any errors will store a text result in the device, use GetDevice()->GetErrorText() to get the error text after an error occurs.
If the audio thread quits due to a callback returning false, the stream does not automatically close, hence you can't use IsOpen() to test for termination. You have to call GetDevice()->IsRunning() to test for thread termination, and if the thread has terminated you can call Close. Another option is to call Wait() which blocks until the thread terminates, and then call Close.
| virtual void WaAudioDevPort::Close | ( | ) | [pure 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.
Implemented in WaVQE, WadResWASAPI, WadMme, WadResInPort, WadResMacHAL, WadWASAPI, WadResPort, WadFile, WadMacHAL, and WadConvPort.
| virtual WaAudioDev* WaAudioDevPort::GetDevice | ( | ) | [pure virtual] |
Get audio device.
Get the actual audio device interface at the end of the processing chain.
Implemented in WaAudioDevPortObj, and WaAudioDev.
| virtual bool WaAudioDevPort::IsOpen | ( | ) | [pure virtual] |
Test if streaming.
Return T/F if devices are currently open for streaming.
Implemented in WaAudioDevPortObj, and WaAudioDev.
| virtual int WaAudioDevPort::Open | ( | WadParam * | param, |
| WadCallbackFn * | inFn, | ||
| WadCallbackFn * | outFn, | ||
| void * | arg | ||
| ) | [pure 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.
| [in] | param | Stream parameters |
| [in] | inFn | Input callback function, or NULL |
| [in] | outFn | Output callback function, or NULL |
| [in] | arg | Argument to callbacks |
Implemented in WaVQE, WadResWASAPI, WadMme, WadResInPort, WadResMacHAL, WadWASAPI, WadResPort, WadFile, WadMacHAL, and WadConvPort.
| virtual int WaAudioDevPort::Start | ( | ) | [pure virtual] |
Start streaming.
Start streaming audio. This must be called after Open to actually start stream.
Implemented in WaAudioDevPortObj, WadMme, WadWASAPI, WadFile, and WadMacHAL.
| virtual int WaAudioDevPort::Stop | ( | ) | [pure virtual] |
| virtual void WaAudioDevPort::Wait | ( | ) | [pure 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.
Implemented in WaAudioDevPortObj, WadMme, WadWASAPI, WadFile, and WadMacHAL.
1.7.5.1