sipxmedialib  Version 3.3
Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
MpodAlsa Class Reference

Container for device specific input ALSA driver. More...

#include <MpodAlsa.h>

Inheritance diagram for MpodAlsa:
Inheritance graph
[legend]
Collaboration diagram for MpodAlsa:
Collaboration graph
[legend]

Public Member Functions

Creators
 MpodAlsa (const UtlString &name)
 Default constructor. More...
 
virtual ~MpodAlsa ()
 Destructor. More...
 
Manipulators
OsStatus enableDevice (unsigned samplesPerFrame, unsigned samplesPerSec, MpFrameTime currentFrameTime, OsCallback &frameTicker)
 Initialize device driver and state. More...
 
OsStatus disableDevice ()
 Uninitialize device driver. More...
 
OsStatus pushFrame (unsigned int numSamples, const MpAudioSample *samples, MpFrameTime frameTime)
 Send data to output device. More...
 
OsStatus setNotificationMode (UtlBoolean bThreadNotification)
 
Inquiry
Returns
the number of output devices found
virtual OsStatus canEnable ()
 Check if this device can connect. More...
 
UtlBoolean isDeviceValid ()
 Inquire if the ALSA 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 UtlBoolean isEnabled () const
 Inquire if this driver is enabled. More...
 

Static Public Member Functions

Accessors
static const char * getDefaultDeviceName ()
 Get the name of the default output ALSA PCM audio device. More...
 
static int getDeviceNames (UtlContainer &devicesNames)
 Get the list of names of the available output ALSA PCM audio device(s) 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

OsStatus signalForNextFrame ()
 Signaling for next frame if notificator used do nothing otherwise. More...
 
void skipFrame ()
 Adding frame time to mCurrentFrameTime. More...
 

Protected Attributes

MpAudioSamplemAudioFrame
 Wave buffer. More...
 
MpFrameTime mCurrentFrameTime
 The current frame time for this device. More...
 
UtlBoolean mNotificationThreadEn
 
MpAlsaContainermpCont
 Pointer to Wrapper container. 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

 MpodAlsa (const MpodAlsa &rMpOutputDeviceDriver)
 Copy constructor (not implemented for this class) More...
 
MpodAlsaoperator= (const MpodAlsa &rhs)
 Assignment operator (not implemented for this class) More...
 

Private Attributes

MpAlsapDevWrapper
 
int mNullTickers
 

Static Private Attributes

static char spDefaultDeviceName [MAX_DEVICE_NAME_SIZE]
 

Friends

class MpAlsa
 

Detailed Description

Container for device specific input ALSA driver.

Constructor & Destructor Documentation

MpodAlsa ( const UtlString &  name)

Default constructor.

Parameters
name- (in) unique device driver name (e.g. "/dev/dsp", "YAMAHA AC-XG WDM Audio", etc.).
nInputBuffers- (in) Maximum number of frames in internal buffer.
~MpodAlsa ( )
virtual

Destructor.

MpodAlsa ( const MpodAlsa rMpOutputDeviceDriver)
private

Copy constructor (not implemented for this class)

Member Function Documentation

OsStatus enableDevice ( unsigned  samplesPerFrame,
unsigned  samplesPerSec,
MpFrameTime  currentFrameTime,
OsCallback &  frameTicker 
)
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.

Implements MpOutputDeviceDriver.

OsStatus disableDevice ( )
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.

OsStatus pushFrame ( unsigned int  numSamples,
const MpAudioSample samples,
MpFrameTime  frameTime 
)
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.

Implements MpOutputDeviceDriver.

OsStatus setNotificationMode ( UtlBoolean  bThreadNotification)
const char * getDefaultDeviceName ( )
static

Get the name of the default output ALSA PCM audio device.

int getDeviceNames ( UtlContainer &  devicesNames)
static

Get the list of names of the available output ALSA PCM audio device(s)

OsStatus canEnable ( )
virtual

Check if this device can connect.

Reimplemented from MpOutputDeviceDriver.

UtlBoolean isDeviceValid ( )
inline

Inquire if the ALSA device is valid.

OsStatus signalForNextFrame ( )
protected

Signaling for next frame if notificator used do nothing otherwise.

void skipFrame ( )
protected

Adding frame time to mCurrentFrameTime.

MpodAlsa& operator= ( const MpodAlsa rhs)
private

Assignment operator (not implemented for this class)

Friends And Related Function Documentation

friend class MpAlsa
friend

Member Data Documentation

MpAudioSample* mAudioFrame
protected

Wave buffer.

MpFrameTime mCurrentFrameTime
protected

The current frame time for this device.

UtlBoolean mNotificationThreadEn
protected
MpAlsaContainer* mpCont
protected

Pointer to Wrapper container.

MpAlsa* pDevWrapper
private
char spDefaultDeviceName
staticprivate
int mNullTickers
private