Container for device specific output driver.
The MpOutputDeviceDriver is the abstract base class for the implementations of output media drivers. An instance of MpOutputDeviceDriver is created for every physical or logical input device (e.g. speaker). A driver is instantiated and then added to the MpOutputDeviceManager. The driver must be enabled via the MpOutputDeviceManager to begin consuming frames.
Each audio output driver should notify its MpAudioOutputConnection when the device is ready to accept the next frame of data with provided OsNotification. See enableDevice() for more information.
MpOutputDeviceDriver has a text name which is defined upon construction. This name will typically be the same as the OS defined name for the input device. The name of the MpOutputDeviceDriver is accessed via the data() method inherited from UtlString. This allows MpOutputDeviceDriver to be contained and accessed by name.
virtual OsStatus enableDevice |
( |
unsigned |
samplesPerFrame, |
|
|
unsigned |
samplesPerSec, |
|
|
MpFrameTime |
currentFrameTime, |
|
|
OsCallback & |
frameTicker |
|
) |
| |
|
pure virtual |
Initialize device driver and state.
This method enables the device driver.
this SHOULD NOT be used to mute/unmute a device. Disabling and enabling a device results in state and buffer queues being cleared.
- Parameters
-
[in] | samplesPerFrame | - the number of samples in a frame of media |
[in] | samplesPerSec | - sample rate for media frame in samples per second |
[in] | currentFrameTime | - time in milliseconds for beginning of frame relative to the MpOutputDeviceManager reference time |
[in] | frameTicker | - notification to signal when device become ready. Device driver MUST signal this notification as soon as it become ready to receive next portion of data to play back. Note, it is a callback which in turn calls pushFrame() method of this device driver. Also notification may be used to signal begin of frame interval for one or several flowgraphs, so it should be as uniform as possible, i.e. it should not burst or hold over, driver should signal this notification after equal intervals of time. |
- Returns
- OS_INVALID_STATE if device already enabled.
This method is supposed to be used from MpAudioOutputConnection only. If you want enable device, use MpOutputDeviceManager or MpAudioOutputConnection methods.
Implemented in MpodWinMM, MpodAlsa, MpodOss, MpodAndroid, and MpodBufferRecorder.
virtual OsStatus disableDevice |
( |
| ) |
|
|
pure virtual |
Send data to output device.
This method is called from a callback which is called when we fire ticker notification. See enableDevice() for details.
- Parameters
-
[in] | numSamples | - Number of samples in samples array. |
[in] | samples | - Array of samples to push to device. |
[in] | frameTime | - Time of pushed frame. Device may consider does it want it or not internally. If frame come too late driver should return OS_SUCCESS and throw out it silently. Common problem is when MediaTask queue is jammed - no frames are processed for some time and then they are processed bursty. Using given frameTime driver may keep its internal queue short. It is guaranteed that frame time would increase monotonically. |
- Returns
- OS_LIMIT_REACHED if mixer buffer is full, i.e. frame come too early.
-
OS_FAILED for other errors.
-
OS_SUCCESS if frame sent correctly.
- See also
- enableDevice() for documentation when this is being called.
Implemented in MpodWinMM, MpodAlsa, MpodBufferRecorder, MpodOss, MpodAndroid, and MpodCoreAudio.