9 #ifndef _MpAndroidX_XAudioTrack_h_ 10 #define _MpAndroidX_XAudioTrack_h_ 15 # define MP_ANDROID_AUDIO_TRACK MpAndroid2_0AudioTrack 16 # define QUOTED_MP_ANDROID_AUDIO_TRACK "MpAndroid2_0AudioTrack" 18 # define LOG_TAG QUOTED_MP_ANDROID_AUDIO_TRACK 21 # define MP_ANDROID_AUDIO_TRACK MpAndroid2_3AudioTrack 22 # define QUOTED_MP_ANDROID_AUDIO_TRACK "MpAndroid2_3AudioTrack" 23 # define CREATE_TRACK_METHOD createTrack 25 # define LOG_TAG QUOTED_MP_ANDROID_AUDIO_TRACK 27 extern "C" int setpriority(
int,
int,
int);
28 # define PRIO_PROCESS 0 30 # define MP_ANDROID_AUDIO_TRACK MpAndroid2_3_4AudioTrack 31 # define QUOTED_MP_ANDROID_AUDIO_TRACK "MpAndroid2_3_4AudioTrack" 33 # define LOG_TAG QUOTED_MP_ANDROID_AUDIO_TRACK 35 # define CREATE_TRACK_METHOD createTrack_l 36 extern "C" int setpriority(
int,
int,
int);
37 # define PRIO_PROCESS 0 39 # define MP_ANDROID_AUDIO_TRACK MpAndroid4_0_1AudioTrack 40 # define QUOTED_MP_ANDROID_AUDIO_TRACK "MpAndroid4_0_1AudioTrack" 42 # define LOG_TAG QUOTED_MP_ANDROID_AUDIO_TRACK 44 # define CREATE_TRACK_METHOD createTrack_l 45 extern "C" int setpriority(
int,
int,
int);
46 # define PRIO_PROCESS 0 48 # define MP_ANDROID_AUDIO_TRACK MpAndroid4_1_1AudioTrack 49 # define QUOTED_MP_ANDROID_AUDIO_TRACK "MpAndroid4_1_1AudioTrack" 51 # define LOG_TAG QUOTED_MP_ANDROID_AUDIO_TRACK 53 # define CREATE_TRACK_METHOD createTrack_l 54 extern "C" int setpriority(
int,
int,
int);
55 # define PRIO_PROCESS 0 59 # define MP_ANDROID_AUDIO_TRACK MpAndroid4_2_1AudioTrack 60 # define QUOTED_MP_ANDROID_AUDIO_TRACK "MpAndroid4_2_1AudioTrack" 62 # define LOG_TAG QUOTED_MP_ANDROID_AUDIO_TRACK 64 # define CREATE_TRACK_METHOD createTrack_l 65 extern "C" int setpriority(
int,
int,
int);
66 # define PRIO_PROCESS 0 70 # error Unsupported version of Android AudioTrack 78 #include <media/AudioTrack.h> 79 #include <private/media/AudioTrackShared.h> 92 int notificationFrames);
120 int notificationFrames) :
121 AudioTrack(streamType, sampleRate, format, channels, frameCount, flags, cbf, user, notificationFrames)
129 LOGD(
"SipxAudioTrack::start() entered");
130 #if defined(ANDROID_2_3) || defined(ANDROID_2_3_4) 150 LOGD(
"%s line: %d", __FILE__, __LINE__);
151 LOGD(
"mAudioTrackThread: %p", &mAudioTrackThread);
152 LOGD(
"exit pending: %s", mAudioTrackThread->exitPending() ?
"TRUE" :
"FALSE");
153 LOGD(
"ref count: %d", mAudioTrackThread->getStrongCount());
155 LOGD(
"%s line: %d", __FILE__, __LINE__);
156 sp<AudioTrackThread> t = mAudioTrackThread;
157 LOGD(
"%s line: %d", __FILE__, __LINE__);
160 LOGV(
"start %p",
this);
162 if (t->exitPending()) {
163 LOGD(
"SipxAudioTrack::start() exitPending");
165 if (t->requestExitAndWait() == WOULD_BLOCK) {
166 LOGE(
"AudioTrack::start called from thread");
172 LOGD(
"SipxAudioTrack::start() NOT exitPending");
176 LOGD(
"SipxAudioTrack::start() after t->mLock.lock");
178 if (android_atomic_or(1, &mActive) == 0) {
179 mNewPosition = mCblk->server + mUpdatePeriod;
180 mCblk->bufferTimeoutMs = MAX_STARTUP_TIMEOUT_MS;
181 mCblk->waitTimeMs = 0;
182 mCblk->flags &= ~CBLK_DISABLED_ON;
184 LOGD(
"SipxAudioTrack::start() about to t->run");
185 t->run(
"AudioTrackThread", THREAD_PRIORITY_AUDIO_CLIENT);
187 LOGD(
"SipxAudioTrack::start() about to setpriority");
188 setpriority(PRIO_PROCESS, 0, THREAD_PRIORITY_AUDIO_CLIENT);
190 LOGD(
"SipxAudioTrack::start() after set priority");
192 if (mCblk->flags & CBLK_INVALID_MSK) {
193 LOGW(
"start() track %p invalidated, creating a new one",
this);
196 status = DEAD_OBJECT;
198 status = mAudioTrack->start();
200 LOGD(
"SipxAudioTrack::start() after mAudioTrack->start()");
201 if (status == DEAD_OBJECT) {
202 LOGV(
"start() dead IAudioTrack: creating a new one");
203 status = CREATE_TRACK_METHOD(mStreamType, mCblk->sampleRate, mFormat, mChannelCount,
204 mFrameCount, mFlags, mSharedBuffer, getOutput(),
false);
205 if (status == NO_ERROR) {
206 status = mAudioTrack->start();
207 if (status == NO_ERROR) {
208 mNewPosition = mCblk->server + mUpdatePeriod;
212 if (status != NO_ERROR) {
213 LOGV(
"start() failed");
214 android_atomic_and(~1, &mActive);
218 setpriority(PRIO_PROCESS, 0, ANDROID_PRIORITY_NORMAL);
223 LOGD(
"SipxAudioTrack::start() end unlock");
229 LOGD(
"SipxAudioTrack::start() exit");
232 LOGD(
"SipxAudioTrack::start() exited");
264 int notificationFrames);
275 uint32_t sampleRate0,
282 int notificationFrames);
294 virtual void start();
304 virtual int initCheck()
const;
306 virtual uint32_t getSampleRate();
308 virtual int frameSize()
const;
312 virtual uint32_t latency()
const;
314 virtual void setVolume(
float left,
float right);
316 virtual void dumpAudioTrack(
const char* label);
342 #endif // _MpAndroidX_XAudioTrack_h_ Audio input driver for Android OS.
Definition: MpAndroidAudioTrack.h:37
SipxAudioTrack(int streamType, uint32_t sampleRate, int format, int channels, int frameCount, uint32_t flags, callback_t cbf, void *user, int notificationFrames)
Definition: MpAndroidX_XAudioTrack.h:112
MpAndroidAudioTrack * createAndroidAudioTrack(int streamType, uint32_t sampleRate, int format, int channels, int frameCount, uint32_t flags, sipXcallback_t cbf, void *user, int notificationFrames)
Definition: MpAndroidX_XAudioTrack.cpp:34
int dummy2
Definition: MpAndroidX_XAudioTrack.h:241
int frameCount
Definition: dmaTaskWnt.cpp:61
void start()
Definition: MpAndroidX_XAudioTrack.h:127
Definition: MpAndroidX_XAudioTrack.h:109
int dummy1
Definition: MpAndroidX_XAudioTrack.h:240
void(* sipXcallback_t)(int event, void *user, void *info)
Definition: MpAndroidAudioBindingInterface.h:32
MP_ANDROID_AUDIO_BINDING_INTERFACE & operator=(const MP_ANDROID_AUDIO_BINDING_INTERFACE &rhs)
Assignment operator (not implemented for this class)
Audio input driver for Android OS.
Definition: MpAndroidX_XAudioTrack.h:252
Audio interface for Android OS version specific differences.
Definition: MpAndroidX_XAudioBinding.h:95
SipxAudioTrack * mpAudioTrack
Definition: MpAndroidX_XAudioTrack.h:337