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();
171 void android_audioPlayer_volumeUpdate(CAudioPlayer* ap)
173 assert(ap != NULL);
176 SLuint8 channelCount = ap->mNumChannels;
183 if (ap->mMuteMask & LEFT_CHANNEL_MASK) {
188 if (ap->mSoloMask & LEFT_CHANNEL_MASK) {
193 if (ap->mSoloMask & RIGHT_CHANNEL_MASK) {
203 if (ap->mMuteMask & RIGHT_CHANNEL_MASK) {
208 if (ap->mSoloMask & RIGHT_CHANNEL_MASK) {
213 if (ap->mSoloMask & LEFT_CHANNEL_MASK) {
232 android_player_volumeUpdate(volumes, &ap->mVolume, channelCount, ap->mAmplFromDirectLevel,
237 if (ap->mAPlayer != 0) {
238 ap->mAPlayer->setVolume(leftVol, rightVol);
239 } else if (ap->mAudioTrack != 0) {
240 ap->mAudioTrack->setVolume(leftVol, rightVol);
246 if (NULL != ap->mEffectSend.mItf) {
248 if (ap->mEffectSend.mEnableLevels[i].mEnable) {
249 android_fxSend_setSendLevel(ap,
250 ap->mEffectSend.mEnableLevels[i].mSendLevel + ap->mVolume.mLevel);
256 } else if (NULL != ap->mAndroidEffectSend.mItf) {
257 android_fxSend_setSendLevel(ap, ap->mAndroidEffectSend.mSendLevel + ap->mVolume.mLevel);
337 void audioTrack_handleMarker_lockPlay(CAudioPlayer* ap) {
342 interface_lock_shared(&ap->mPlay);
343 callback = ap->mPlay.mCallback;
344 callbackPContext = ap->mPlay.mContext;
345 interface_unlock_shared(&ap->mPlay);
349 (*callback)(&ap->mPlay.mItf, callbackPContext, SL_PLAYEVENT_HEADATMARKER);
354 void audioTrack_handleNewPos_lockPlay(CAudioPlayer* ap) {
359 interface_lock_shared(&ap->mPlay);
360 callback = ap->mPlay.mCallback;
361 callbackPContext = ap->mPlay.mContext;
362 interface_unlock_shared(&ap->mPlay);
366 (*callback)(&ap->mPlay.mItf, callbackPContext, SL_PLAYEVENT_HEADATNEWPOS);
372 void audioTrack_handleUnderrun_lockPlay(CAudioPlayer* ap) {
376 interface_lock_shared(&ap->mPlay);
377 callback = ap->mPlay.mCallback;
378 callbackPContext = ap->mPlay.mContext;
379 bool headStalled = (ap->mPlay.mEventFlags & SL_PLAYEVENT_HEADSTALLED) != 0;
380 interface_unlock_shared(&ap->mPlay);
383 (*callback)(&ap->mPlay.mItf, callbackPContext, SL_PLAYEVENT_HEADSTALLED);
402 void audioPlayer_dispatch_headAtEnd_lockPlay(CAudioPlayer *ap, bool setPlayStateToPaused,
404 //SL_LOGV("ap=%p, setPlayStateToPaused=%d, needToLock=%d", ap, setPlayStateToPaused,
410 interface_lock_exclusive(&ap->mPlay);
412 if (ap->mPlay.mEventFlags & SL_PLAYEVENT_HEADATEND) {
413 playCallback = ap->mPlay.mCallback;
414 playContext = ap->mPlay.mContext;
417 ap->mPlay.mState = SL_PLAYSTATE_PAUSED;
420 interface_unlock_exclusive(&ap->mPlay);
425 ap->mPlay.mItf, playContext, SL_PLAYEVENT_HEADATEND);
427 SLresult result = EnqueueAsyncCallback_ppi(ap, playCallback, &ap->mPlay.mItf, playContext,
431 &ap->mPlay.mItf, playContext);
440 SLresult audioPlayer_setStreamType(CAudioPlayer* ap, SLint32 type) {
471 // (ap->mAudioTrack is supposed to be NULL until then)
472 if (SL_OBJECT_STATE_UNREALIZED != ap->mObject.mState) {
476 ap->mStreamType = newStreamType;
484 SLresult audioPlayer_getStreamType(CAudioPlayer* ap, SLint32 *pType) {
487 switch(ap->mStreamType) {
518 void audioPlayer_auxEffectUpdate(CAudioPlayer* ap) {
519 if ((ap->mAudioTrack != 0) && (ap->mAuxEffect != 0)) {
520 android_fxSend_attach(ap, true, ap->mAuxEffect, ap->mVolume.mLevel + ap->mAuxSendLevel);
565 AndroidObjectType audioPlayer_getAndroidObjectTypeForSourceSink(CAudioPlayer *ap) {
567 const SLDataSource *pAudioSrc = &ap->mDataSource.u.mSource;
568 const SLDataSink *pAudioSnk = &ap->mDataSink.u.mSink;
660 CAudioPlayer *ap = (CAudioPlayer *)user;
661 if (!android::CallbackProtector::enterCbIfOk(ap->mCallbackProtector)) {
675 SL_LOGV("Received GenericPlayer::kEventPrepared for CAudioPlayer %p", ap);
682 object_lock_exclusive(&ap->mObject);
685 assert(ap->mAndroidObjState == ANDROID_PREPARING);
686 ap->mAndroidObjState = ANDROID_READY;
689 // Most of successful prepare completion for ap->mAPlayer
697 if (IsInterfaceInitialized(&(ap->mObject), MPH_PREFETCHSTATUS)) {
698 ap->mPrefetchStatus.mLevel = 0;
699 ap->mPrefetchStatus.mStatus = SL_PREFETCHSTATUS_UNDERFLOW;
700 if (!(~ap->mPrefetchStatus.mCallbackEventsMask &
702 callback = ap->mPrefetchStatus.mCallback;
703 callbackPContext = ap->mPrefetchStatus.mContext;
709 object_unlock_exclusive(&ap->mObject);
713 (*callback)(&ap->mPrefetchStatus.mItf, callbackPContext, events);
720 if (!IsInterfaceInitialized(&(ap->mObject), MPH_PREFETCHSTATUS)) {
727 interface_lock_exclusive(&ap->mPrefetchStatus);
728 if (ap->mPrefetchStatus.mCallbackEventsMask & SL_PREFETCHEVENT_FILLLEVELCHANGE) {
729 callback = ap->mPrefetchStatus.mCallback;
730 callbackPContext = ap->mPrefetchStatus.mContext;
732 ap->mPrefetchStatus.mLevel = (SLpermille)data1;
733 interface_unlock_exclusive(&ap->mPrefetchStatus);
737 (*callback)(&ap->mPrefetchStatus.mItf, callbackPContext,
744 if (!IsInterfaceInitialized(&(ap->mObject), MPH_PREFETCHSTATUS)) {
751 object_lock_exclusive(&ap->mObject);
752 if (ap->mPrefetchStatus.mCallbackEventsMask & SL_PREFETCHEVENT_STATUSCHANGE) {
753 callback = ap->mPrefetchStatus.mCallback;
754 callbackPContext = ap->mPrefetchStatus.mContext;
757 ap->mPrefetchStatus.mStatus = SL_PREFETCHSTATUS_SUFFICIENTDATA;
759 ap->mPrefetchStatus.mStatus = SL_PREFETCHSTATUS_UNDERFLOW;
761 object_unlock_exclusive(&ap->mObject);
765 (*callback)(&ap->mPrefetchStatus.mItf, callbackPContext, SL_PREFETCHEVENT_STATUSCHANGE);
771 audioPlayer_dispatch_headAtEnd_lockPlay(ap, true /*set state to paused?*/, true);
772 if ((ap->mAudioTrack != 0) && (!ap->mSeek.mLoopEnabled)) {
773 ap->mAudioTrack->stop();
779 object_lock_exclusive(&ap->mObject);
780 if (UNKNOWN_NUMCHANNELS == ap->mNumChannels && UNKNOWN_NUMCHANNELS != data1) {
781 ap->mNumChannels = data1;
782 android_audioPlayer_volumeUpdate(ap);
784 object_unlock_exclusive(&ap->mObject);
792 interface_lock_shared(&ap->mPlay);
793 callback = ap->mPlay.mCallback;
794 callbackPContext = ap->mPlay.mContext;
795 interface_unlock_shared(&ap->mPlay);
801 (*callback)(&ap->mPlay.mItf, callbackPContext, event);
804 SLresult result = EnqueueAsyncCallback_ppi(ap, callback, &ap->mPlay.mItf,
808 &ap->mPlay.mItf, callbackPContext, event);
822 object_lock_exclusive(&ap->mObject);
823 if (IsInterfaceInitialized(&ap->mObject, MPH_PREFETCHSTATUS)) {
824 ap->mPrefetchStatus.mLevel = 0;
825 ap->mPrefetchStatus.mStatus = SL_PREFETCHSTATUS_UNDERFLOW;
826 if (!(~ap->mPrefetchStatus.mCallbackEventsMask &
828 callback = ap->mPrefetchStatus.mCallback;
829 callbackPContext = ap->mPrefetchStatus.mContext;
832 object_unlock_exclusive(&ap->mObject);
839 (*callback)(&ap->mPrefetchStatus.mItf, callbackPContext,
854 ap->mCallbackProtector->exitCb();
1090 CAudioPlayer *ap = (CAudioPlayer *)user;
1092 if (!android::CallbackProtector::enterCbIfOk(ap->mCallbackProtector)) {
1109 interface_lock_exclusive(&ap->mBufferQueue);
1111 if (ap->mBufferQueue.mState.count != 0) {
1112 //SL_LOGV("nbBuffers in queue = %u",ap->mBufferQueue.mState.count);
1113 assert(ap->mBufferQueue.mFront != ap->mBufferQueue.mRear);
1115 BufferHeader *oldFront = ap->mBufferQueue.mFront;
1119 void *pSrc = (char *)oldFront->mBuffer + ap->mBufferQueue.mSizeConsumed;
1120 if (ap->mBufferQueue.mSizeConsumed + pBuff->size < oldFront->mSize) {
1122 ap->mBufferQueue.mSizeConsumed += pBuff->size;
1129 pBuff->size = oldFront->mSize - ap->mBufferQueue.mSizeConsumed;
1130 ap->mBufferQueue.mSizeConsumed = 0;
1133 &ap->mBufferQueue.mArray
1134 [ap->mBufferQueue.mNumBuffers + 1])
1136 newFront = ap->mBufferQueue.mArray;
1138 ap->mBufferQueue.mFront = newFront;
1140 ap->mBufferQueue.mState.count--;
1141 ap->mBufferQueue.mState.playIndex++;
1149 callback = ap->mBufferQueue.mCallback;
1151 callbackPContext = ap->mBufferQueue.mContext;
1158 audioPlayer_dispatch_headAtEnd_lockPlay(ap, false /*set state to paused?*/, false);
1161 if (IsInterfaceInitialized(&(ap->mObject), MPH_PREFETCHSTATUS)) {
1162 ap->mPrefetchStatus.mStatus = SL_PREFETCHSTATUS_UNDERFLOW;
1163 ap->mPrefetchStatus.mLevel = 0;
1165 prefetchEvents = ap->mPrefetchStatus.mCallbackEventsMask &
1168 prefetchCallback = ap->mPrefetchStatus.mCallback;
1169 prefetchContext = ap->mPrefetchStatus.mContext;
1174 ap->mAudioTrack->stop();
1176 interface_unlock_exclusive(&ap->mBufferQueue);
1183 (*prefetchCallback)(&ap->mPrefetchStatus.mItf, prefetchContext,
1187 (*prefetchCallback)(&ap->mPrefetchStatus.mItf, prefetchContext,
1192 (*callback)(&ap->mBufferQueue.mItf, callbackPContext);
1199 audioTrack_handleMarker_lockPlay(ap);
1204 audioTrack_handleNewPos_lockPlay(ap);
1209 audioTrack_handleUnderrun_lockPlay(ap);
1222 ap->mCallbackProtector->exitCb();
1276 SLresult android_audioPlayer_setConfig(CAudioPlayer *ap, const SLchar *configKey,
1281 assert(NULL != ap && NULL != configKey && NULL != pConfigValue);
1289 result = audioPlayer_setStreamType(ap, *(SLuint32*)pConfigValue);
1302 SLresult android_audioPlayer_getConfig(CAudioPlayer* ap, const SLchar *configKey,
1307 assert(NULL != ap && NULL != configKey && NULL != pValueSize);
1317 result = audioPlayer_getStreamType(ap, (SLint32*)pConfigValue);
1708 SLresult android_audioPlayer_setPlaybackRateAndConstraints(CAudioPlayer *ap, SLpermille rate,
1711 switch(ap->mAndroidObjType) {
1718 uint32_t contentRate = sles_to_android_sampleRate(ap->mSampleRateMilliHz);
1720 if (ap->mAudioTrack != 0) {
1721 ap->mAudioTrack->setSampleRate(contentRate * (rate/1000.0f));
1730 if (ap->mAPlayer != 0) {
1731 ap->mAPlayer->setPlaybackRate((int16_t)rate);
1737 SL_LOGE("Unexpected object type %d", ap->mAndroidObjType);
1748 // ap != NULL
1750 SLresult android_audioPlayer_metadata_getItemCount(CAudioPlayer *ap, SLuint32 *pItemCount) {
1751 if (ap->mAPlayer == 0) {
1754 switch(ap->mAndroidObjType) {
1759 static_cast<android::AudioSfDecoder*>(ap->mAPlayer.get());
1774 // ap != NULL
1776 SLresult android_audioPlayer_metadata_getKeySize(CAudioPlayer *ap,
1778 if (ap->mAPlayer == 0) {
1782 switch(ap->mAndroidObjType) {
1787 static_cast<android::AudioSfDecoder*>(ap->mAPlayer.get());
1810 // ap != NULL
1812 SLresult android_audioPlayer_metadata_getKey(CAudioPlayer *ap,
1814 if (ap->mAPlayer == 0) {
1818 switch(ap->mAndroidObjType) {
1823 static_cast<android::AudioSfDecoder*>(ap->mAPlayer.get());
1847 // ap != NULL
1849 SLresult android_audioPlayer_metadata_getValueSize(CAudioPlayer *ap,
1851 if (ap->mAPlayer == 0) {
1855 switch(ap->mAndroidObjType) {
1860 static_cast<android::AudioSfDecoder*>(ap->mAPlayer.get());
1883 // ap != NULL
1885 SLresult android_audioPlayer_metadata_getValue(CAudioPlayer *ap,
1887 if (ap->mAPlayer == 0) {
1891 switch(ap->mAndroidObjType) {
1896 static_cast<android::AudioSfDecoder*>(ap->mAPlayer.get());
1919 // ap != NULL
1922 void android_audioPlayer_setPlayState(CAudioPlayer *ap) {
1924 SLuint32 playState = ap->mPlay.mState;
1925 AndroidObjectState objState = ap->mAndroidObjState;
1927 switch(ap->mAndroidObjType) {
1932 if (ap->mAudioTrack != 0) {
1933 ap->mAudioTrack->stop();
1938 if (ap->mAudioTrack != 0) {
1939 ap->mAudioTrack->pause();
1944 if (ap->mAudioTrack != 0) {
1945 // instead of ap->mAudioTrack->start();
1946 ap->mDeferredStart = true;
1961 aplayer_setPlayState(ap->mAPlayer, playState, &(ap->mAndroidObjState));
1964 SL_LOGE(ERROR_PLAYERSETPLAYSTATE_UNEXPECTED_OBJECT_TYPE_D, ap->mAndroidObjType);
1972 void android_audioPlayer_usePlayEventMask(CAudioPlayer *ap) {
1973 IPlay *pPlayItf = &ap->mPlay;
1975 /*switch(ap->mAndroidObjType) {
1978 if (ap->mAPlayer != 0) {
1979 assert(ap->mAudioTrack == 0);
1980 ap->mAPlayer->setPlayEvents((int32_t) eventFlags, (int32_t) pPlayItf->mMarkerPosition,
1985 if (ap->mAudioTrack == 0) {
1990 ap->mAudioTrack->setMarkerPosition((uint32_t)((((int64_t)pPlayItf->mMarkerPosition
1991 * sles_to_android_sampleRate(ap->mSampleRateMilliHz)))/1000));
1994 ap->mAudioTrack->setMarkerPosition(0);
1998 ap->mAudioTrack->setPositionUpdatePeriod(
2000 * sles_to_android_sampleRate(ap->mSampleRateMilliHz)))/1000));
2003 ap->mAudioTrack->setPositionUpdatePeriod(0);
2024 CAudioPlayer *ap = (CAudioPlayer *)pPlayItf->mThis;
2025 switch(ap->mAndroidObjType) {
2030 if (ap->mAPlayer != 0) {
2031 ap->mAPlayer->getDurationMsec(&durationMsec);
2050 CAudioPlayer *ap = (CAudioPlayer *)pPlayItf->mThis;
2051 switch(ap->mAndroidObjType) {
2054 if ((ap->mSampleRateMilliHz == UNKNOWN_SAMPLERATE) || (ap->mAudioTrack == 0)) {
2058 ap->mAudioTrack->getPosition(&positionInFrames);
2060 sles_to_android_sampleRate(ap->mSampleRateMilliHz);
2069 if (ap->mAPlayer != 0) {
2070 ap->mAPlayer->getPositionMsec(&posMsec);
2083 SLresult android_audioPlayer_seek(CAudioPlayer *ap, SLmillisecond posMsec) {
2086 switch(ap->mAndroidObjType) {
2096 if (ap
2097 ap->mAPlayer->seek(posMsec);
2109 SLresult android_audioPlayer_loop(CAudioPlayer *ap, SLboolean loopEnable) {
2112 switch (ap->mAndroidObjType) {
2116 if (ap->mAPlayer != 0) {
2117 ap->mAPlayer->loop((bool)loopEnable);
2129 SLresult android_audioPlayer_setBufferingUpdateThresholdPerMille(CAudioPlayer *ap,
2133 switch (ap->mAndroidObjType) {
2135 if (ap->mAPlayer != 0) {
2136 ap->mAPlayer->setBufferingUpdateThreshold(threshold / 10);
2148 void android_audioPlayer_bufferQueue_onRefilled_l(CAudioPlayer *ap) {
2152 if (ap->mAudioTrack != 0) {
2153 // instead of ap->mAudioTrack->start();
2154 ap->mDeferredStart = true;
2159 if (IsInterfaceInitialized(&(ap->mObject), MPH_PREFETCHSTATUS)) {
2161 assert(SL_PREFETCHSTATUS_UNDERFLOW == ap->mPrefetchStatus.mStatus);
2162 assert(0 == ap->mPrefetchStatus.mLevel);
2163 ap->mPrefetchStatus.mStatus = SL_PREFETCHSTATUS_SUFFICIENTDATA;
2164 ap->mPrefetchStatus.mLevel = 1000;
2166 SLuint32 prefetchEvents = ap->mPrefetchStatus.mCallbackEventsMask &
2169 ap->mPrefetchStatus.mDeferredPrefetchCallback = ap->mPrefetchStatus.mCallback;
2170 ap->mPrefetchStatus.mDeferredPrefetchContext = ap->mPrefetchStatus.mContext;
2171 ap->mPrefetchStatus.mDeferredPrefetchEvents = prefetchEvents;
2181 SLresult android_audioPlayer_bufferQueue_onClear(CAudioPlayer *ap) {
2184 switch (ap->mAndroidObjType) {
2188 if (ap->mAudioTrack != 0) {
2189 ap->mAudioTrack->flush();
2202 void android_audioPlayer_androidBufferQueue_clear_l(CAudioPlayer *ap) {
2203 switch (ap->mAndroidObjType) {
2205 if (ap->mAPlayer != 0) {
2206 android::StreamPlayer* splr = static_cast<android::StreamPlayer*>(ap->mAPlayer.get());
2216 void android_audioPlayer_androidBufferQueue_onRefilled_l(CAudioPlayer *ap) {
2217 switch (ap->mAndroidObjType) {
2219 if (ap->mAPlayer != 0) {
2220 android::StreamPlayer* splr = static_cast<android::StreamPlayer*>(ap->mAPlayer.get());