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

Audio output driver for Android OS. More...

#include <MpodAndroid.h>

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

Protected Types

enum  State {
  DRIVER_IDLE, DRIVER_INIT, DRIVER_STARTING, DRIVER_PLAYING,
  DRIVER_STOPPING, DRIVER_STOPPED
}
 

Protected Member Functions

UtlBoolean initAudioTrack ()
 Allocates and configures AudioTrack used for PCM output. More...
 

Static Protected Member Functions

static void audioCallback (int event, void *user, void *info)
 Callback function called by Android to request more data. More...
 

Protected Attributes

MpAndroidAudioBindingInterface::StreamType mStreamType
 Android type of the output stream. More...
 
OsAtomicLightUInt mState
 Internal class state. More...
 
MpAndroidAudioTrackmpAudioTrack
 Pointer to audio track used for playback. More...
 
Mutex mLock
 
Condition mWaitCbkCond
 
MpFrameTime mCurFrameTime
 The current frame time for this device. More...
 
OsNotification * mpNotifier
 Event signaled when windows is ready to receive a new buffer. 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

 MpodAndroid (const MpodAndroid &rMpodAndroid)
 Copy constructor (not implemented for this class) More...
 
MpodAndroidoperator= (const MpodAndroid &rhs)
 Assignment operator (not implemented for this class) More...
 

Creators

 MpodAndroid (MpAndroidAudioBindingInterface::StreamType streamType)
 Default constructor. More...
 
virtual ~MpodAndroid ()
 Destructor. More...
 

Manipulators

virtual OsStatus enableDevice (unsigned samplesPerFrame, unsigned samplesPerSec, MpFrameTime currentFrameTime, OsCallback &frameTicker)
 
virtual OsStatus disableDevice ()
 Uninitialize device driver. More...
 
virtual OsStatus pushFrame (unsigned int numSamples, const MpAudioSample *samples, MpFrameTime frameTime)
 Send data to output device. More...
 

Variables to push audio data to callback.

MpAudioSamplempSampleBuffer
 Buffer which pushBuffer should copy to. More...
 
int mSampleBufferIndex
 Index of the first sample not yet pushed to device. More...
 

Additional Inherited Members

- 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 inherited from MpOutputDeviceDriver
static MpFrameTime getFramePeriod (unsigned samplesPerFrame, unsigned samplesPerSec)
 Calculate the number of milliseconds that a frame occupies in time. More...
 

Detailed Description

Audio output driver for Android OS.

See also
MpOutputDeviceDriver

Member Enumeration Documentation

enum State
protected
Enumerator
DRIVER_IDLE 

MpodAndroid is being initialized or initialization failed.

DRIVER_INIT 

MpodAndroid has been successfully initialized and is not playing.

DRIVER_STARTING 

MpodAndroid is starting playing.

DRIVER_PLAYING 

MpodAndroid is playing.

DRIVER_STOPPING 

MpodAndroid is stopping.

DRIVER_STOPPED 

MpodAndroid is stopped: the AudioTrack will be stopped.

Constructor & Destructor Documentation

Default constructor.

Note
Device name is not supported under Android for now.
~MpodAndroid ( )
virtual

Destructor.

MpodAndroid ( const MpodAndroid rMpodAndroid)
private

Copy constructor (not implemented for this class)

Member Function Documentation

OsStatus enableDevice ( unsigned  samplesPerFrame,
unsigned  samplesPerSec,
MpFrameTime  currentFrameTime,
OsCallback &  frameTicker 
)
virtual

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.

UtlBoolean initAudioTrack ( )
protected

Allocates and configures AudioTrack used for PCM output.

void audioCallback ( int  event,
void *  user,
void *  info 
)
staticprotected

Callback function called by Android to request more data.

MpodAndroid& operator= ( const MpodAndroid rhs)
private

Assignment operator (not implemented for this class)

Member Data Documentation

Android type of the output stream.

OsAtomicLightUInt mState
protected

Internal class state.

MpAndroidAudioTrack* mpAudioTrack
protected

Pointer to audio track used for playback.

Mutex mLock
protected

Mutex to control concurrent access to this object from audio callback and application API

Condition mWaitCbkCond
protected

condition enabling interface to wait for audio callback completion after a change is requested

MpFrameTime mCurFrameTime
protected

The current frame time for this device.

OsNotification* mpNotifier
protected

Event signaled when windows is ready to receive a new buffer.

MpAudioSample* mpSampleBuffer
protected

Buffer which pushBuffer should copy to.

int mSampleBufferIndex
protected

Index of the first sample not yet pushed to device.