sipxmedialib  Version 3.3
MpodCoreAudio.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2009 SIPez LLC.
3 // Licensed to SIPfoundry under a Contributor Agreement.
4 //
5 // Copyright (C) 2009 SIPfoundry Inc.
6 // Licensed by SIPfoundry under the LGPL license.
7 //
8 // $$
10 
11 // Author: Sergey Kostanbaev <Sergey DOT Kostanbaev AT sipez DOT com>
12 
13 #ifndef _MpodCoreAudio_h_
14 #define _MpodCoreAudio_h_
15 
16 // SYSTEM INCLUDES
17 #include <pthread.h>
18 #include <semaphore.h>
19 
20 // APPLICATION INCLUDES
22 #include "mp/MpCoreAudioHardware.h"
23 
24 
25 // MACROS
26 // EXTERNAL FUNCTIONS
27 // EXTERNAL VARIABLES
28 // CONSTANTS
29 // STRUCTS
30 // TYPEDEFS
31 // FORWARD DECLARATIONS
33 
34 
39 {
40 /* //////////////////////////// PUBLIC //////////////////////////////////// */
41 public:
42 
43 /* ============================ CREATORS ================================== */
45 
46 
48  MpodCoreAudio(const UtlString& name);
57 
59 
60 /* ============================ MANIPULATORS ============================== */
62 
63 
65  OsStatus enableDevice(unsigned samplesPerFrame,
66  unsigned samplesPerSec,
67  MpFrameTime currentFrameTime);
68 
70  OsStatus disableDevice();
71 
73  OsStatus pushFrame(unsigned int numSamples,
74  const MpAudioSample* samples,
75  MpFrameTime frameTime);
76 
78  OsStatus setTickerNotification(OsNotification *pFrameTicker);
79 
81 
82 /* ============================ ACCESSORS ================================= */
84 
85 
87 
88 /* ============================ INQUIRY =================================== */
90 
91 
92 
94 
95 /* //////////////////////////// PROTECTED ///////////////////////////////// */
96 protected:
97  AudioUnit mOutputUnit;
98  AudioConverterRef mConverter;
100 
104 
105  OsNotification *pNotificator;
107 
109  OsStatus signalForNextFrame();
110 
112  void skipFrame();
113 
114  bool setAudioUnitFormat(const AudioStreamBasicDescription& ds);
115 
116  bool initResempler(const AudioStreamBasicDescription& ds);
117 
118  bool setBuffers();
119 
120  static
121  void propertyListener(void * inRefCon,
122  AudioUnit ci,
123  AudioUnitPropertyID inID,
124  AudioUnitScope inScope,
125  AudioUnitElement inElement);
126 
127  static
128  OSStatus renderProc(void * inRefCon,
129  AudioUnitRenderActionFlags* inActionFlags,
130  const AudioTimeStamp * inTimeStamp,
131  UInt32 inBusNumber,
132  UInt32 inNumFrames,
133  AudioBufferList * ioData);
134 
135  static
136  OSStatus ACproc(AudioConverterRef inAudioConverter,
137  UInt32 * ioDataPackets,
138  AudioBufferList* ioData,
139  AudioStreamPacketDescription ** inUserData,
140  void *inUData);
141 
142 /* //////////////////////////// PRIVATE /////////////////////////////////// */
143 private:
144 
146  MpodCoreAudio(const MpodCoreAudio& rMpOutputDeviceDriver);
147 
150 
151 
152 };
153 
154 /* ============================ INLINE METHODS ============================ */
155 
156 
157 #endif // _MpodCoreAudio_h_
OsStatus pushFrame(unsigned int numSamples, const MpAudioSample *samples, MpFrameTime frameTime)
Send data to output device.
Definition: MpodCoreAudio.cpp:271
int samplesPerFrame
static void propertyListener(void *inRefCon, AudioUnit ci, AudioUnitPropertyID inID, AudioUnitScope inScope, AudioUnitElement inElement)
Definition: MpodCoreAudio.cpp:434
uint32_t MpFrameTime
Definition: MpTypes.h:53
CoreAudioHardware mDevice
CoreAudio hardware device handle.
Definition: MpodCoreAudio.h:99
OsStatus disableDevice()
Uninitialize device driver.
Definition: MpodCoreAudio.cpp:242
AudioConverterRef mConverter
Sample rate converter.
Definition: MpodCoreAudio.h:98
int16_t MpAudioSample
Definition: MpTypes.h:44
double mOutputSampleRate
Device smaple rate.
Definition: MpodCoreAudio.h:101
static OSStatus renderProc(void *inRefCon, AudioUnitRenderActionFlags *inActionFlags, const AudioTimeStamp *inTimeStamp, UInt32 inBusNumber, UInt32 inNumFrames, AudioBufferList *ioData)
Definition: MpodCoreAudio.cpp:497
AudioUnit mOutputUnit
AudioUnit output handle.
Definition: MpodCoreAudio.h:97
bool initResempler(const AudioStreamBasicDescription &ds)
Definition: MpodCoreAudio.cpp:358
OsNotification * pNotificator
Notificator used for signaling next frame.
Definition: MpodCoreAudio.h:105
void skipFrame()
Adding frame time to mCurrentFrameTime.
Definition: MpodCoreAudio.cpp:428
MpFrameTime mCurrentFrameTime
The current frame time for this device.
Definition: MpodCoreAudio.h:106
bool setBuffers()
Definition: MpodCoreAudio.cpp:380
MpAudioSample * mAudioFrameData
Second wave buffer for actual data.
Definition: MpodCoreAudio.h:103
~MpodCoreAudio()
Destructor.
Definition: MpodCoreAudio.cpp:55
OsStatus enableDevice(unsigned samplesPerFrame, unsigned samplesPerSec, MpFrameTime currentFrameTime)
Initialize device driver and state.
Definition: MpodCoreAudio.cpp:64
static OSStatus ACproc(AudioConverterRef inAudioConverter, UInt32 *ioDataPackets, AudioBufferList *ioData, AudioStreamPacketDescription **inUserData, void *inUData)
Definition: MpodCoreAudio.cpp:534
MpodCoreAudio & operator=(const MpodCoreAudio &rhs)
Assignment operator (not implemented for this class)
MpodCoreAudio(const UtlString &name)
Default constructor.
Definition: MpodCoreAudio.cpp:46
Container of output devices.
Definition: MpOutputDeviceManager.h:66
MpAudioSample * mAudioFrame
Wave buffer for silence.
Definition: MpodCoreAudio.h:102
bool setAudioUnitFormat(const AudioStreamBasicDescription &ds)
Definition: MpodCoreAudio.cpp:300
Container for CoreAudio hardware device specific.
Definition: MpCoreAudioHardware.h:40
OsStatus setTickerNotification(OsNotification *pFrameTicker)
Definition: MpodCoreAudio.cpp:290
OsStatus signalForNextFrame()
Signaling for next frame if notificator used do nothing otherwise.
Definition: MpodCoreAudio.cpp:420
Container for device specific output CoreAudio driver.
Definition: MpodCoreAudio.h:38
Container for device specific output driver.
Definition: MpOutputDeviceDriver.h:53