sipxmedialib  Version 3.3
MpodAlsa.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2007-2017 SIPez LLC. All rights reserved.
3 //
4 // $$
6 
7 #ifndef _MpodAlsa_h_
8 #define _MpodAlsa_h_
9 
10 // SYSTEM INCLUDES
11 #include <pthread.h>
12 #include <semaphore.h>
13 
14 #ifdef __linux__
15 #include <sys/types.h>
16 #include <sys/soundcard.h>
17 #endif // __linux__
18 
19 
20 // APPLICATION INCLUDES
22 #include "mp/MpAlsa.h"
23 
24 
25 // MACROS
26 // EXTERNAL FUNCTIONS
27 // EXTERNAL VARIABLES
28 // CONSTANTS
29 #define MAX_DEVICE_NAME_SIZE 256
30 
31 // STRUCTS
32 // TYPEDEFS
33 // FORWARD DECLARATIONS
35 class UtlContainer;
36 
37 
42 {
43  friend class MpAlsa;
44 /* //////////////////////////// PUBLIC //////////////////////////////////// */
45 public:
46 
47 /* ============================ CREATORS ================================== */
49 
50 
52  MpodAlsa(const UtlString& name);
59  virtual ~MpodAlsa();
61 
63 
64 /* ============================ MANIPULATORS ============================== */
66 
67 
69  OsStatus enableDevice(unsigned samplesPerFrame,
70  unsigned samplesPerSec,
71  MpFrameTime currentFrameTime,
72  OsCallback &frameTicker);
73 
75  OsStatus disableDevice();
76 
78  OsStatus pushFrame(unsigned int numSamples,
79  const MpAudioSample* samples,
80  MpFrameTime frameTime);
81 
82  OsStatus setNotificationMode(UtlBoolean bThreadNotification);
83 
85 
86 /* ============================ ACCESSORS ================================= */
88 
89  static const char* getDefaultDeviceName();
91 
93  static int getDeviceNames(UtlContainer& devicesNames);
98 
99 /* ============================ INQUIRY =================================== */
101 
102 
104  virtual OsStatus canEnable();
105  /* @see MpOutputDeviceDriver::canEnable */
106 
108  inline UtlBoolean isDeviceValid();
109 
111 
112 /* //////////////////////////// PROTECTED ///////////////////////////////// */
113 protected:
117 
119 
121  OsStatus signalForNextFrame();
122 
124  void skipFrame();
125 
126 /* //////////////////////////// PRIVATE /////////////////////////////////// */
127 private:
130 
132  MpodAlsa(const MpodAlsa& rMpOutputDeviceDriver);
133 
135  MpodAlsa& operator=(const MpodAlsa& rhs);
136 
138 
139 };
140 
141 /* ============================ INLINE METHODS ============================ */
142 
144 {
145  //printf("MpRsOdAlsa::isDeviceValid()\n"); fflush(stdout);
146  return ((pDevWrapper != NULL) && pDevWrapper->isDeviceValid());
147 }
148 
149 #endif // _MpodAlsa_h_
MpodAlsa(const UtlString &name)
Default constructor.
Definition: MpodAlsa.cpp:43
UtlBoolean mNotificationThreadEn
Definition: MpodAlsa.h:116
int samplesPerFrame
static const char * getDefaultDeviceName()
Get the name of the default output ALSA PCM audio device.
Definition: MpodAlsa.cpp:235
UtlBoolean isDeviceValid()
Inquire if the device is valid.
Definition: MpAlsa.h:187
MpFrameTime mCurrentFrameTime
The current frame time for this device.
Definition: MpodAlsa.h:115
uint32_t MpFrameTime
Definition: MpTypes.h:53
Container for device specific input ALSA driver.
Definition: MpodAlsa.h:41
MpAlsa * pDevWrapper
Definition: MpodAlsa.h:128
Wrapper for ALSA device that use file descriptor to communicate.
Definition: MpAlsa.h:32
UtlBoolean isDeviceValid()
Inquire if the ALSA device is valid.
Definition: MpodAlsa.h:143
MpAudioSample * mAudioFrame
Wave buffer.
Definition: MpodAlsa.h:114
#define MAX_DEVICE_NAME_SIZE
Definition: MpodAlsa.h:29
static char spDefaultDeviceName[MAX_DEVICE_NAME_SIZE]
Definition: MpodAlsa.h:129
int16_t MpAudioSample
Definition: MpTypes.h:44
void skipFrame()
Adding frame time to mCurrentFrameTime.
Definition: MpodAlsa.cpp:348
OsStatus disableDevice()
Uninitialize device driver.
Definition: MpodAlsa.cpp:147
int mNullTickers
Definition: MpodAlsa.h:137
OsStatus setNotificationMode(UtlBoolean bThreadNotification)
Definition: MpodAlsa.cpp:71
OsStatus enableDevice(unsigned samplesPerFrame, unsigned samplesPerSec, MpFrameTime currentFrameTime, OsCallback &frameTicker)
Initialize device driver and state.
Definition: MpodAlsa.cpp:82
MpodAlsa & operator=(const MpodAlsa &rhs)
Assignment operator (not implemented for this class)
OsStatus signalForNextFrame()
Signaling for next frame if notificator used do nothing otherwise.
Definition: MpodAlsa.cpp:324
Container of output devices.
Definition: MpOutputDeviceManager.h:66
MpAlsaContainer * mpCont
Pointer to Wrapper container.
Definition: MpodAlsa.h:118
Definition: MpAlsaContainer.h:27
virtual OsStatus canEnable()
Check if this device can connect.
Definition: MpodAlsa.cpp:276
static int getDeviceNames(UtlContainer &devicesNames)
Get the list of names of the available output ALSA PCM audio device(s)
Definition: MpodAlsa.cpp:265
virtual ~MpodAlsa()
Destructor.
Definition: MpodAlsa.cpp:60
Container for device specific output driver.
Definition: MpOutputDeviceDriver.h:53
OsStatus pushFrame(unsigned int numSamples, const MpAudioSample *samples, MpFrameTime frameTime)
Send data to output device.
Definition: MpodAlsa.cpp:207