sipxmedialib
Version 3.3
|
Container for Microsoft Windows device specific output driver. More...
#include <MpodWinMM.h>
Classes | |
class | MpWinOutputAudioDeviceNotifier |
class | WinAudioData |
Structure used to pass WMM message data to processing thread. More... | |
Public Member Functions | |
Creators | |
MpodWinMM (const UtlString &name, MpOutputDeviceManager *outputManger, unsigned nOutputBuffers=DEFAULT_N_OUTPUT_BUFS) | |
Default constructor. More... | |
~MpodWinMM () | |
Destructor. More... | |
Manipulators | |
OsStatus | enableDevice (unsigned samplesPerFrame, unsigned samplesPerSec, MpFrameTime currentFrameTime, OsCallback &frameTicker) |
OsStatus | disableDevice () |
Uninitialize device driver. More... | |
OsStatus | pushFrame (unsigned int numSamples, const MpAudioSample *samples, MpFrameTime frameTime) |
Send data to output device. More... | |
OsStatus | switchToMMTimer () |
Switch to use MMTimer for Media subsystem ticks instead of output device. More... | |
virtual OsStatus | signal (const intptr_t eventData) |
callback used by MpMMTimer when output device is not providing ticks More... | |
Inquiry | |
UtlBoolean | isDeviceValid () |
Inquire if the windows device is valid. More... | |
Public Member Functions inherited from MpOutputDeviceDriver | |
MpOutputDeviceDriver (const UtlString &name) | |
Default constructor. More... | |
virtual | ~MpOutputDeviceDriver () |
Destructor. More... | |
MpFrameTime | getFramePeriod () const |
Calculate the number of milliseconds that a frame occupies in time. More... | |
unsigned | getSamplesPerFrame () const |
Get number of samples in a frame. More... | |
unsigned | getSamplesPerSec () const |
Get number of samples per second. More... | |
const UtlString & | getDeviceName () const |
Get device name. More... | |
virtual OsStatus | canEnable () |
Check if this device can connect. More... | |
virtual UtlBoolean | isEnabled () const |
Inquire if this driver is enabled. More... | |
Static Public Member Functions | |
Accessors | |
static UtlString | getDefaultDeviceName () |
get the windows name of the default wave output device. More... | |
Static Public Member Functions inherited from MpOutputDeviceDriver | |
static MpFrameTime | getFramePeriod (unsigned samplesPerFrame, unsigned samplesPerSec) |
Calculate the number of milliseconds that a frame occupies in time. More... | |
Protected Member Functions | |
WAVEHDR * | initWaveHeader (int n) |
Zero out a wave header, so it is ready to be filled in by us. More... | |
void | finalizeProcessedHeader (WAVEHDR *pWaveHdr) |
Adds a header/buffer to the empty header list and notifies for a new frame. More... | |
OsStatus | internalPushFrame (unsigned int numSamples, const MpAudioSample *samples, MpFrameTime frameTime) |
internal method to handle final writing of audio to the output device More... | |
Static Protected Member Functions | |
static void CALLBACK | waveOutCallbackStatic (HWAVEOUT hwo, UINT uMsg, void *dwInstance, void *dwParam1, void *dwParam2) |
callback used by wave output multimedia interface More... | |
Protected Attributes | |
MpOutputDeviceManager * | mpOutputManger |
output manager this device will belong to. More... | |
OsMutex | mEmptyHdrVPtrListsMutex |
Mutex to serialize access to vptr and empty header lists. More... | |
int | mWinMMDeviceId |
HWAVEOUT | mDevHandle |
The Microsoft handle for this audio input device. More... | |
MpFrameTime | mCurFrameTime |
The current frame time for this device. More... | |
unsigned | mNumOutBuffers |
unsigned | mWaveBufSize |
WAVEHDR * | mpWaveHeaders |
Array of nNumInBuffers wave headers. More... | |
LPSTR * | mpWaveBuffers |
Array of nNumInBuffers wave buffers. More... | |
UtlSList | mEmptyHeaderList |
UtlSList | mUnusedVPtrList |
int | mUnderrunLength |
Length of underrun, taking place now (in frames). More... | |
DWORD | mTotSampleCount |
A count of the samples coming in via pushFrame. More... | |
IMMNotificationClient * | mWinAudioDeviceChangeCallback |
device state changes. More... | |
IMMDeviceEnumerator * | mDeviceEnumeratorPtr |
HANDLE | mCallbackThread |
Handle of thread which processes WMM messages. More... | |
HANDLE | mCallbackEvent |
Event to signal that WMM message is available for processing. More... | |
OsAtomicLightBool | mExitFlag |
Should processing thread finish its execution? More... | |
MpMMTimer * | mpTickerTimer |
UtlSList | mListSignaled |
Queue of WMM messages signaled for processing. More... | |
UtlSList | mListFree |
Pool of WMM messages. More... | |
Protected Attributes inherited from MpOutputDeviceDriver | |
OsAtomicLightBool | mIsEnabled |
Whether this device driver is enabled or not. More... | |
OsAtomicLightUInt | mSamplesPerFrame |
number of samples. More... | |
OsAtomicLightUInt | mSamplesPerSec |
of samples per second. More... | |
OsCallback * | mpTickerNotification |
is ready to accept more data. See enableDevice() for details. More... | |
Private Member Functions | |
MpodWinMM (const MpodWinMM &rMpodWinMM) | |
Copy constructor (not implemented for this class) More... | |
MpodWinMM & | operator= (const MpodWinMM &rhs) |
Assignment operator (not implemented for this class) More... | |
OsStatus | resetDevice () |
Static Private Member Functions | |
static DWORD WINAPI | ThreadMMProc (LPVOID lpMessage) |
WMM messages processing thread. More... | |
Container for Microsoft Windows device specific output driver.
The MpOutputDeviceDriver is the class for the Microsoft Windows output media driver wrapper implementation. An instance of MpodWinMM is created for every physical or logical output device (e.g. speaker).
|
explicit |
Default constructor.
[in] | name | - unique windows device driver name (e.g. "YAMAHA AC-XG WDM Audio", etc.) |
[in] | outputmanager | - pounter to the output manager this device will belong to. |
[in] | nOutputBuffers | - The number of frame-sized buffers to have around for filling with data and passing to windows. |
nOutputBuffers
does not directly determine the latency – this doesn't wait until all nOutputBuffers
are full before passing on to windows, it just makes them available if we're passing frames faster than they're being output. ~MpodWinMM | ( | ) |
Destructor.
|
virtual |
Implements MpOutputDeviceDriver.
|
virtual |
Uninitialize device driver.
This method disables the device driver and should release any platform device resources so that the device might be used else where.
this SHOULD NOT be used to mute/unmute a device. Disabling and enabling a device results in state and buffer queues being cleared.
This method is supposed to be used from MpAudioOutputConnection only. If you want disable device, use MpOutputDeviceManager or MpAudioOutputConnection methods.
Implements MpOutputDeviceDriver.
|
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.
[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. |
Implements MpOutputDeviceDriver.
OsStatus switchToMMTimer | ( | ) |
Switch to use MMTimer for Media subsystem ticks instead of output device.
|
virtual |
callback used by MpMMTimer when output device is not providing ticks
|
static |
get the windows name of the default wave output device.
|
inline |
Inquire if the windows device is valid.
|
protected |
Zero out a wave header, so it is ready to be filled in by us.
Initialize all the values in the wave header indicated by n
.
[in] | n | - The index into mpWaveHeaders indicating which wave header to initialize. |
|
protected |
Adds a header/buffer to the empty header list and notifies for a new frame.
This method, called from ThreadMMProc thread, adds a header/buffer to a list of empty headers so pushFrame() knows there are free buffers to fill and send to WMM, pumps silence if we are critically low, and sends a ticker notification to keep processing data.
[in] | pWaveHdr | - Pointer to a wave header that windows is done with. |
|
staticprotected |
callback used by wave output multimedia interface
This should only be called by the windows wave output multimedia.
|
protected |
internal method to handle final writing of audio to the output device
Assignment operator (not implemented for this class)
|
staticprivate |
WMM messages processing thread.
All WMM messages are forwarded from static callback function to this thread and are actually processed here. This is done to avoid deadlocks, when other WMM functions are called from static callback functions.
|
private |
|
protected |
output manager this device will belong to.
|
protected |
Mutex to serialize access to vptr and empty header lists.
|
protected |
The underlying windows Device ID (not the logical Mp device ID)
|
protected |
The Microsoft handle for this audio input device.
|
protected |
The current frame time for this device.
|
protected |
The number of buffers to supply to windows for audio processing.
|
protected |
The size, in bytes, of mpWaveBuffer after allocation.
|
protected |
Array of nNumInBuffers wave headers.
|
protected |
Array of nNumInBuffers wave buffers.
|
protected |
List of pointers to the mpWaveHeaders that are empty, waiting to be filled.
|
protected |
List of unused UtlVoidPtrs. Used ones are in mEmptyHeaderList.
|
protected |
Length of underrun, taking place now (in frames).
|
protected |
A count of the samples coming in via pushFrame.
|
protected |
device state changes.
Callback interface for audio
|
protected |
|
protected |
Handle of thread which processes WMM messages.
|
protected |
Event to signal that WMM message is available for processing.
|
protected |
Should processing thread finish its execution?
|
protected |
Optional timer to provide media subsystem ticks when output device is not working properly.
|
protected |
Queue of WMM messages signaled for processing.
|
protected |
Pool of WMM messages.