sipxmedialib  Version 3.3
MpidAlsa.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2007-2017 SIPez LLC. All rights reserved.
3 //
4 // $$
6 
7 
8 #ifndef _MpidAlsa_h_
9 #define _MpidAlsa_h_
10 
11 // SYSTEM INCLUDES
12 #include <pthread.h>
13 #include <semaphore.h>
14 
15 
16 // APPLICATION INCLUDES
17 #include "mp/MpInputDeviceDriver.h"
18 #include "mp/MpAlsa.h"
19 
20 // DEFINES
21 // MACROS
22 // EXTERNAL FUNCTIONS
23 // EXTERNAL VARIABLES
24 // CONSTANTS
25 #define MAX_DEVICE_NAME_SIZE 256
26 
27 // STRUCTS
28 // TYPEDEFS
29 // FORWARD DECLARATIONS
31 class UtlContainer;
32 
37 {
38  friend class MpAlsa;
39 /* //////////////////////////// PUBLIC //////////////////////////////////// */
40 public:
41 
42 /* ============================ CREATORS ================================== */
44 
45 
47  MpidAlsa(const UtlString& name,
48  MpInputDeviceManager& deviceManager);
56  virtual ~MpidAlsa();
58 
60 
61 /* ============================ MANIPULATORS ============================== */
63 
64 
66  OsStatus enableDevice(unsigned samplesPerFrame,
67  unsigned samplesPerSec,
68  MpFrameTime currentFrameTime);
82  OsStatus disableDevice();
94 
95 /* ============================ ACCESSORS ================================= */
97 
98  static const char* getDefaultDeviceName();
100 
102  static int getDeviceNames(UtlContainer& devicesNames);
107 
108 /* ============================ INQUIRY =================================== */
110 
111 
113  inline UtlBoolean isDeviceValid();
114 
116 
117 /* //////////////////////////// PROTECTED ///////////////////////////////// */
118 protected:
121 
123  OsStatus initBuffers();
124 
126  void freeBuffers();
127 
130 
132  void pushFrame();
133 
135  void skipFrame();
136 
137 /* //////////////////////////// PRIVATE /////////////////////////////////// */
138 private:
141 
143  MpidAlsa(const MpidAlsa& rMpInputDeviceDriver);
144 
146  MpidAlsa& operator=(const MpidAlsa& rhs);
147 
148 };
149 
150 /* ============================ INLINE METHODS ============================ */
151 
153 {
154  //printf("MpRsIdAlsa::isDeviceValid()\n"); fflush(stdout);
155  return ((pDevWrapper != NULL) && pDevWrapper->isDeviceValid());
156 }
157 
158 #endif // _MpidAlsa_h_
int samplesPerFrame
static const char * getDefaultDeviceName()
Get the name of the default input ALSA PCM audio device.
Definition: MpidAlsa.cpp:164
void skipFrame()
Add frame time to mCurrentFrameTime.
Definition: MpidAlsa.cpp:216
UtlBoolean isDeviceValid()
Inquire if the device is valid.
Definition: MpAlsa.h:187
uint32_t MpFrameTime
Definition: MpTypes.h:53
OsStatus disableDevice()
Uninitialize device driver.
Definition: MpidAlsa.cpp:127
Wrapper for ALSA device that use file descriptor to communicate.
Definition: MpAlsa.h:32
void freeBuffers()
Free internal ALSA buffers.
MpidAlsa & operator=(const MpidAlsa &rhs)
Assignment operator (not implemented for this class).
MpAudioSample * getBuffer()
Get buffer from internal buffers.
MpAlsa * pDevWrapper
Definition: MpidAlsa.h:139
OsStatus initBuffers()
Allocate internal ALSA buffers.
int16_t MpAudioSample
Definition: MpTypes.h:44
#define MAX_DEVICE_NAME_SIZE
Definition: MpidAlsa.h:25
Container of input devices for input drivers and resources.
Definition: MpInputDeviceManager.h:79
static int getDeviceNames(UtlContainer &devicesNames)
Get the list of names of the available input ALSA PCM audio device(s)
Definition: MpidAlsa.cpp:194
MpAlsaContainer * mpCont
Pointer to Wrapper container.
Definition: MpidAlsa.h:120
void pushFrame()
Push audio frame to InputDeviceManager.
Definition: MpidAlsa.cpp:205
virtual ~MpidAlsa()
Destructor.
Definition: MpidAlsa.cpp:59
Container for device specific input driver.
Definition: MpInputDeviceDriver.h:58
UtlBoolean isDeviceValid()
Inquire if the ALSA device is valid.
Definition: MpidAlsa.h:152
MpAudioSample * mAudioFrame
Wave buffer.
Definition: MpidAlsa.h:119
MpidAlsa(const UtlString &name, MpInputDeviceManager &deviceManager)
Default constructor.
Definition: MpidAlsa.cpp:42
Definition: MpAlsaContainer.h:27
Container for device specific input ALSA driver.
Definition: MpidAlsa.h:36
OsStatus enableDevice(unsigned samplesPerFrame, unsigned samplesPerSec, MpFrameTime currentFrameTime)
Initialize device driver and state.
Definition: MpidAlsa.cpp:67
static char spDefaultDeviceName[MAX_DEVICE_NAME_SIZE]
Definition: MpidAlsa.h:140