Lines Matching refs:ap

42 SLresult aplayer_setPlayState(const android::sp<android::GenericPlayer> &ap, SLuint32 playState,
50 ap->stop();
57 ap->prepare();
62 ap->pause();
75 ap->prepare();
80 ap->play();
103 static size_t adecoder_writeToBufferQueue(const uint8_t *data, size_t size, CAudioPlayer* ap) {
104 if (!android::CallbackProtector::enterCbIfOk(ap->mCallbackProtector)) {
114 object_lock_exclusive(&ap->mObject);
116 if (ap->mBufferQueue.mState.count != 0) {
117 assert(ap->mBufferQueue.mFront != ap->mBufferQueue.mRear);
119 BufferHeader *oldFront = ap->mBufferQueue.mFront;
122 uint8_t *pDest = (uint8_t *)oldFront->mBuffer + ap->mBufferQueue.mSizeConsumed;
123 if (ap->mBufferQueue.mSizeConsumed + size < oldFront->mSize) {
125 ap->mBufferQueue.mSizeConsumed += size;
131 sizeConsumed = oldFront->mSize - ap->mBufferQueue.mSizeConsumed;
134 ap->mBufferQueue.mSizeConsumed = 0;
135 if (newFront == &ap->mBufferQueue.mArray[ap->mBufferQueue.mNumBuffers + 1]) {
136 newFront = ap->mBufferQueue.mArray;
138 ap->mBufferQueue.mFront = newFront;
140 ap->mBufferQueue.mState.count--;
141 ap->mBufferQueue.mState.playIndex++;
146 callback = ap->mBufferQueue.mCallback;
148 callbackPContext = ap->mBufferQueue.mContext;
156 object_unlock_exclusive(&ap->mObject);
159 (*callback)(&ap->mBufferQueue.mItf, callbackPContext);
162 ap->mCallbackProtector->exitCb();
195 void android_audioPlayer_volumeUpdate(CAudioPlayer* ap)
197 assert(ap != NULL);
200 SLuint8 channelCount = ap->mNumChannels;
207 if (ap->mMuteMask & LEFT_CHANNEL_MASK) {
212 if (ap->mSoloMask & LEFT_CHANNEL_MASK) {
217 if (ap->mSoloMask & RIGHT_CHANNEL_MASK) {
227 if (ap->mMuteMask & RIGHT_CHANNEL_MASK) {
232 if (ap->mSoloMask & RIGHT_CHANNEL_MASK) {
237 if (ap->mSoloMask & LEFT_CHANNEL_MASK) {
256 android_player_volumeUpdate(volumes, &ap->mVolume, channelCount, ap->mAmplFromDirectLevel,
261 if (ap->mAPlayer != 0) {
262 ap->mAPlayer->setVolume(leftVol, rightVol);
263 } else if (ap->mAudioTrack != 0) {
264 ap->mAudioTrack->setVolume(leftVol, rightVol);
270 if (NULL != ap->mEffectSend.mItf) {
272 if (ap->mEffectSend.mEnableLevels[i].mEnable) {
273 android_fxSend_setSendLevel(ap,
274 ap->mEffectSend.mEnableLevels[i].mSendLevel + ap->mVolume.mLevel);
280 } else if (NULL != ap->mAndroidEffectSend.mItf) {
281 android_fxSend_setSendLevel(ap, ap->mAndroidEffectSend.mSendLevel + ap->mVolume.mLevel);
361 void audioTrack_handleMarker_lockPlay(CAudioPlayer* ap) {
366 interface_lock_shared(&ap->mPlay);
367 callback = ap->mPlay.mCallback;
368 callbackPContext = ap->mPlay.mContext;
369 interface_unlock_shared(&ap->mPlay);
373 (*callback)(&ap->mPlay.mItf, callbackPContext, SL_PLAYEVENT_HEADATMARKER);
378 void audioTrack_handleNewPos_lockPlay(CAudioPlayer* ap) {
383 interface_lock_shared(&ap->mPlay);
384 callback = ap->mPlay.mCallback;
385 callbackPContext = ap->mPlay.mContext;
386 interface_unlock_shared(&ap->mPlay);
390 (*callback)(&ap->mPlay.mItf, callbackPContext, SL_PLAYEVENT_HEADATNEWPOS);
396 void audioTrack_handleUnderrun_lockPlay(CAudioPlayer* ap) {
400 interface_lock_shared(&ap->mPlay);
401 callback = ap->mPlay.mCallback;
402 callbackPContext = ap->mPlay.mContext;
403 bool headStalled = (ap->mPlay.mEventFlags & SL_PLAYEVENT_HEADSTALLED) != 0;
404 interface_unlock_shared(&ap->mPlay);
407 (*callback)(&ap->mPlay.mItf, callbackPContext, SL_PLAYEVENT_HEADSTALLED);
426 void audioPlayer_dispatch_headAtEnd_lockPlay(CAudioPlayer *ap, bool setPlayStateToPaused,
428 //SL_LOGV("ap=%p, setPlayStateToPaused=%d, needToLock=%d", ap, setPlayStateToPaused,
434 interface_lock_exclusive(&ap->mPlay);
436 if (ap->mPlay.mEventFlags & SL_PLAYEVENT_HEADATEND) {
437 playCallback = ap->mPlay.mCallback;
438 playContext = ap->mPlay.mContext;
441 ap->mPlay.mState = SL_PLAYSTATE_PAUSED;
444 interface_unlock_exclusive(&ap->mPlay);
449 (*playCallback)(&ap->mPlay.mItf, playContext, SL_PLAYEVENT_HEADATEND);
451 SLresult result = EnqueueAsyncCallback_ppi(ap, playCallback, &ap->mPlay.mItf, playContext,
455 &ap->mPlay.mItf, playContext);
464 SLresult audioPlayer_setStreamType(CAudioPlayer* ap, SLint32 type) {
495 // (ap->mAudioTrack is supposed to be NULL until then)
496 if (SL_OBJECT_STATE_UNREALIZED != ap->mObject.mState) {
500 ap->mStreamType = newStreamType;
508 SLresult audioPlayer_getStreamType(CAudioPlayer* ap, SLint32 *pType) {
511 switch(ap->mStreamType) {
542 void audioPlayer_auxEffectUpdate(CAudioPlayer* ap) {
543 if ((ap->mAudioTrack != 0) && (ap->mAuxEffect != 0)) {
544 android_fxSend_attach(ap, true, ap->mAuxEffect, ap->mVolume.mLevel + ap->mAuxSendLevel);
589 AndroidObjectType audioPlayer_getAndroidObjectTypeForSourceSink(CAudioPlayer *ap) {
591 const SLDataSource *pAudioSrc = &ap->mDataSource.u.mSource;
592 const SLDataSink *pAudioSnk = &ap->mDataSink.u.mSink;
684 CAudioPlayer *ap = (CAudioPlayer *)user;
685 if (!android::CallbackProtector::enterCbIfOk(ap->mCallbackProtector)) {
699 SL_LOGV("Received GenericPlayer::kEventPrepared for CAudioPlayer %p", ap);
706 object_lock_exclusive(&ap->mObject);
709 assert(ap->mAndroidObjState == ANDROID_PREPARING);
710 ap->mAndroidObjState = ANDROID_READY;
713 // Most of successful prepare completion for ap->mAPlayer
721 if (IsInterfaceInitialized(&(ap->mObject), MPH_PREFETCHSTATUS)) {
722 ap->mPrefetchStatus.mLevel = 0;
723 ap->mPrefetchStatus.mStatus = SL_PREFETCHSTATUS_UNDERFLOW;
724 if (!(~ap->mPrefetchStatus.mCallbackEventsMask &
726 callback = ap->mPrefetchStatus.mCallback;
727 callbackPContext = ap->mPrefetchStatus.mContext;
733 object_unlock_exclusive(&ap->mObject);
737 (*callback)(&ap->mPrefetchStatus.mItf, callbackPContext, events);
744 if (!IsInterfaceInitialized(&(ap->mObject), MPH_PREFETCHSTATUS)) {
751 interface_lock_exclusive(&ap->mPrefetchStatus);
752 if (ap->mPrefetchStatus.mCallbackEventsMask & SL_PREFETCHEVENT_FILLLEVELCHANGE) {
753 callback = ap->mPrefetchStatus.mCallback;
754 callbackPContext = ap->mPrefetchStatus.mContext;
756 ap->mPrefetchStatus.mLevel = (SLpermille)data1;
757 interface_unlock_exclusive(&ap->mPrefetchStatus);
761 (*callback)(&ap->mPrefetchStatus.mItf, callbackPContext,
768 if (!IsInterfaceInitialized(&(ap->mObject), MPH_PREFETCHSTATUS)) {
775 object_lock_exclusive(&ap->mObject);
776 if (ap->mPrefetchStatus.mCallbackEventsMask & SL_PREFETCHEVENT_STATUSCHANGE) {
777 callback = ap->mPrefetchStatus.mCallback;
778 callbackPContext = ap->mPrefetchStatus.mContext;
781 ap->mPrefetchStatus.mStatus = SL_PREFETCHSTATUS_SUFFICIENTDATA;
783 ap->mPrefetchStatus.mStatus = SL_PREFETCHSTATUS_UNDERFLOW;
785 object_unlock_exclusive(&ap->mObject);
789 (*callback)(&ap->mPrefetchStatus.mItf, callbackPContext, SL_PREFETCHEVENT_STATUSCHANGE);
795 audioPlayer_dispatch_headAtEnd_lockPlay(ap, true /*set state to paused?*/, true);
796 if ((ap->mAudioTrack != 0) && (!ap->mSeek.mLoopEnabled)) {
797 ap->mAudioTrack->stop();
803 object_lock_exclusive(&ap->mObject);
804 if (UNKNOWN_NUMCHANNELS == ap->mNumChannels && UNKNOWN_NUMCHANNELS != data1) {
805 ap->mNumChannels = data1;
806 android_audioPlayer_volumeUpdate(ap);
808 object_unlock_exclusive(&ap->mObject);
816 interface_lock_shared(&ap->mPlay);
817 callback = ap->mPlay.mCallback;
818 callbackPContext = ap->mPlay.mContext;
819 interface_unlock_shared(&ap->mPlay);
825 (*callback)(&ap->mPlay.mItf, callbackPContext, event);
828 SLresult result = EnqueueAsyncCallback_ppi(ap, callback, &ap->mPlay.mItf,
832 &ap->mPlay.mItf, callbackPContext, event);
846 object_lock_exclusive(&ap->mObject);
847 if (IsInterfaceInitialized(&ap->mObject, MPH_PREFETCHSTATUS)) {
848 ap->mPrefetchStatus.mLevel = 0;
849 ap->mPrefetchStatus.mStatus = SL_PREFETCHSTATUS_UNDERFLOW;
850 if (!(~ap->mPrefetchStatus.mCallbackEventsMask &
852 callback = ap->mPrefetchStatus.mCallback;
853 callbackPContext = ap->mPrefetchStatus.mContext;
856 object_unlock_exclusive(&ap->mObject);
863 (*callback)(&ap->mPrefetchStatus.mItf, callbackPContext,
878 ap->mCallbackProtector->exitCb();
1114 CAudioPlayer *ap = (CAudioPlayer *)user;
1116 if (!android::CallbackProtector::enterCbIfOk(ap->mCallbackProtector)) {
1133 interface_lock_exclusive(&ap->mBufferQueue);
1135 if (ap->mBufferQueue.mState.count != 0) {
1136 //SL_LOGV("nbBuffers in queue = %u",ap->mBufferQueue.mState.count);
1137 assert(ap->mBufferQueue.mFront != ap->mBufferQueue.mRear);
1139 BufferHeader *oldFront = ap->mBufferQueue.mFront;
1143 void *pSrc = (char *)oldFront->mBuffer + ap->mBufferQueue.mSizeConsumed;
1144 if (ap->mBufferQueue.mSizeConsumed + pBuff->size < oldFront->mSize) {
1146 ap->mBufferQueue.mSizeConsumed += pBuff->size;
1153 pBuff->size = oldFront->mSize - ap->mBufferQueue.mSizeConsumed;
1154 ap->mBufferQueue.mSizeConsumed = 0;
1157 &ap->mBufferQueue.mArray
1158 [ap->mBufferQueue.mNumBuffers + 1])
1160 newFront = ap->mBufferQueue.mArray;
1162 ap->mBufferQueue.mFront = newFront;
1164 ap->mBufferQueue.mState.count--;
1165 ap->mBufferQueue.mState.playIndex++;
1173 callback = ap->mBufferQueue.mCallback;
1175 callbackPContext = ap->mBufferQueue.mContext;
1182 audioPlayer_dispatch_headAtEnd_lockPlay(ap, false /*set state to paused?*/, false);
1185 if (IsInterfaceInitialized(&(ap->mObject), MPH_PREFETCHSTATUS)) {
1186 ap->mPrefetchStatus.mStatus = SL_PREFETCHSTATUS_UNDERFLOW;
1187 ap->mPrefetchStatus.mLevel = 0;
1189 prefetchEvents = ap->mPrefetchStatus.mCallbackEventsMask &
1192 prefetchCallback = ap->mPrefetchStatus.mCallback;
1193 prefetchContext = ap->mPrefetchStatus.mContext;
1198 ap->mAudioTrack->stop();
1200 interface_unlock_exclusive(&ap->mBufferQueue);
1207 (*prefetchCallback)(&ap->mPrefetchStatus.mItf, prefetchContext,
1211 (*prefetchCallback)(&ap->mPrefetchStatus.mItf, prefetchContext,
1216 (*callback)(&ap->mBufferQueue.mItf, callbackPContext);
1223 audioTrack_handleMarker_lockPlay(ap);
1228 audioTrack_handleNewPos_lockPlay(ap);
1233 audioTrack_handleUnderrun_lockPlay(ap);
1246 ap->mCallbackProtector->exitCb();
1300 SLresult android_audioPlayer_setConfig(CAudioPlayer *ap, const SLchar *configKey,
1305 assert(NULL != ap && NULL != configKey && NULL != pConfigValue);
1313 result = audioPlayer_setStreamType(ap, *(SLuint32*)pConfigValue);
1326 SLresult android_audioPlayer_getConfig(CAudioPlayer* ap, const SLchar *configKey,
1331 assert(NULL != ap && NULL != configKey && NULL != pValueSize);
1341 result = audioPlayer_getStreamType(ap, (SLint32*)pConfigValue);
1732 SLresult android_audioPlayer_setPlaybackRateAndConstraints(CAudioPlayer *ap, SLpermille rate,
1735 switch(ap->mAndroidObjType) {
1742 uint32_t contentRate = sles_to_android_sampleRate(ap->mSampleRateMilliHz);
1744 if (ap->mAudioTrack != 0) {
1745 ap->mAudioTrack->setSampleRate(contentRate * (rate/1000.0f));
1754 if (ap->mAPlayer != 0) {
1755 ap->mAPlayer->setPlaybackRate((int16_t)rate);
1761 SL_LOGE("Unexpected object type %d", ap->mAndroidObjType);
1772 // ap != NULL
1774 SLresult android_audioPlayer_metadata_getItemCount(CAudioPlayer *ap, SLuint32 *pItemCount) {
1775 if (ap->mAPlayer == 0) {
1778 switch(ap->mAndroidObjType) {
1783 static_cast<android::AudioSfDecoder*>(ap->mAPlayer.get());
1798 // ap != NULL
1800 SLresult android_audioPlayer_metadata_getKeySize(CAudioPlayer *ap,
1802 if (ap->mAPlayer == 0) {
1806 switch(ap->mAndroidObjType) {
1811 static_cast<android::AudioSfDecoder*>(ap->mAPlayer.get());
1834 // ap != NULL
1836 SLresult android_audioPlayer_metadata_getKey(CAudioPlayer *ap,
1838 if (ap->mAPlayer == 0) {
1842 switch(ap->mAndroidObjType) {
1847 static_cast<android::AudioSfDecoder*>(ap->mAPlayer.get());
1871 // ap != NULL
1873 SLresult android_audioPlayer_metadata_getValueSize(CAudioPlayer *ap,
1875 if (ap->mAPlayer == 0) {
1879 switch(ap->mAndroidObjType) {
1884 static_cast<android::AudioSfDecoder*>(ap->mAPlayer.get());
1907 // ap != NULL
1909 SLresult android_audioPlayer_metadata_getValue(CAudioPlayer *ap,
1911 if (ap->mAPlayer == 0) {
1915 switch(ap->mAndroidObjType) {
1920 static_cast<android::AudioSfDecoder*>(ap->mAPlayer.get());
1943 // ap != NULL
1946 void android_audioPlayer_setPlayState(CAudioPlayer *ap) {
1948 SLuint32 playState = ap->mPlay.mState;
1949 AndroidObjectState objState = ap->mAndroidObjState;
1951 switch(ap->mAndroidObjType) {
1956 if (ap->mAudioTrack != 0) {
1957 ap->mAudioTrack->stop();
1962 if (ap->mAudioTrack != 0) {
1963 ap->mAudioTrack->pause();
1968 if (ap->mAudioTrack != 0) {
1969 // instead of ap->mAudioTrack->start();
1970 ap->mDeferredStart = true;
1985 aplayer_setPlayState(ap->mAPlayer, playState, &(ap->mAndroidObjState));
1988 SL_LOGE(ERROR_PLAYERSETPLAYSTATE_UNEXPECTED_OBJECT_TYPE_D, ap->mAndroidObjType);
1996 void android_audioPlayer_usePlayEventMask(CAudioPlayer *ap) {
1997 IPlay *pPlayItf = &ap->mPlay;
1999 /*switch(ap->mAndroidObjType) {
2002 if (ap->mAPlayer != 0) {
2003 assert(ap->mAudioTrack == 0);
2004 ap->mAPlayer->setPlayEvents((int32_t) eventFlags, (int32_t) pPlayItf->mMarkerPosition,
2009 if (ap->mAudioTrack == 0) {
2014 ap->mAudioTrack->setMarkerPosition((uint32_t)((((int64_t)pPlayItf->mMarkerPosition
2015 * sles_to_android_sampleRate(ap->mSampleRateMilliHz)))/1000));
2018 ap->mAudioTrack->setMarkerPosition(0);
2022 ap->mAudioTrack->setPositionUpdatePeriod(
2024 * sles_to_android_sampleRate(ap->mSampleRateMilliHz)))/1000));
2027 ap->mAudioTrack->setPositionUpdatePeriod(0);
2048 CAudioPlayer *ap = (CAudioPlayer *)pPlayItf->mThis;
2049 switch(ap->mAndroidObjType) {
2054 if (ap->mAPlayer != 0) {
2055 ap->mAPlayer->getDurationMsec(&durationMsec);
2074 CAudioPlayer *ap = (CAudioPlayer *)pPlayItf->mThis;
2075 switch(ap->mAndroidObjType) {
2078 if ((ap->mSampleRateMilliHz == UNKNOWN_SAMPLERATE) || (ap->mAudioTrack == 0)) {
2082 ap->mAudioTrack->getPosition(&positionInFrames);
2084 sles_to_android_sampleRate(ap->mSampleRateMilliHz);
2093 if (ap->mAPlayer != 0) {
2094 ap->mAPlayer->getPositionMsec(&posMsec);
2107 SLresult android_audioPlayer_seek(CAudioPlayer *ap, SLmillisecond posMsec) {
2110 switch(ap->mAndroidObjType) {
2120 if (ap->mAPlayer != 0) {
2121 ap->mAPlayer->seek(posMsec);
2133 SLresult android_audioPlayer_loop(CAudioPlayer *ap, SLboolean loopEnable) {
2136 switch (ap->mAndroidObjType) {
2140 if (ap->mAPlayer != 0) {
2141 ap->mAPlayer->loop((bool)loopEnable);
2153 SLresult android_audioPlayer_setBufferingUpdateThresholdPerMille(CAudioPlayer *ap,
2157 switch (ap->mAndroidObjType) {
2159 if (ap->mAPlayer != 0) {
2160 ap->mAPlayer->setBufferingUpdateThreshold(threshold / 10);
2172 void android_audioPlayer_bufferQueue_onRefilled_l(CAudioPlayer *ap) {
2176 if (ap->mAudioTrack != 0) {
2177 // instead of ap->mAudioTrack->start();
2178 ap->mDeferredStart = true;
2183 if (IsInterfaceInitialized(&(ap->mObject), MPH_PREFETCHSTATUS)) {
2185 assert(SL_PREFETCHSTATUS_UNDERFLOW == ap->mPrefetchStatus.mStatus);
2186 assert(0 == ap->mPrefetchStatus.mLevel);
2187 ap->mPrefetchStatus.mStatus = SL_PREFETCHSTATUS_SUFFICIENTDATA;
2188 ap->mPrefetchStatus.mLevel = 1000;
2190 SLuint32 prefetchEvents = ap->mPrefetchStatus.mCallbackEventsMask &
2193 ap->mPrefetchStatus.mDeferredPrefetchCallback = ap->mPrefetchStatus.mCallback;
2194 ap->mPrefetchStatus.mDeferredPrefetchContext = ap->mPrefetchStatus.mContext;
2195 ap->mPrefetchStatus.mDeferredPrefetchEvents = prefetchEvents;
2205 SLresult android_audioPlayer_bufferQueue_onClear(CAudioPlayer *ap) {
2208 switch (ap->mAndroidObjType) {
2212 if (ap->mAudioTrack != 0) {
2213 ap->mAudioTrack->flush();
2226 void android_audioPlayer_androidBufferQueue_clear_l(CAudioPlayer *ap) {
2227 switch (ap->mAndroidObjType) {
2229 if (ap->mAPlayer != 0) {
2230 android::StreamPlayer* splr = static_cast<android::StreamPlayer*>(ap->mAPlayer.get());
2240 void android_audioPlayer_androidBufferQueue_onRefilled_l(CAudioPlayer *ap) {
2241 switch (ap->mAndroidObjType) {
2243 if (ap->mAPlayer != 0) {
2244 android::StreamPlayer* splr = static_cast<android::StreamPlayer*>(ap->mAPlayer.get());