Lines Matching refs:ap

44 SLresult aplayer_setPlayState(const android::sp<android::GenericPlayer> &ap, SLuint32 playState,
52 ap->stop();
59 ap->prepare();
64 ap->pause();
77 ap->prepare();
82 ap->play();
105 static size_t adecoder_writeToBufferQueue(const uint8_t *data, size_t size, CAudioPlayer* ap) {
106 if (!android::CallbackProtector::enterCbIfOk(ap->mCallbackProtector)) {
116 object_lock_exclusive(&ap->mObject);
118 if (ap->mBufferQueue.mState.count != 0) {
119 assert(ap->mBufferQueue.mFront != ap->mBufferQueue.mRear);
121 BufferHeader *oldFront = ap->mBufferQueue.mFront;
124 uint8_t *pDest = (uint8_t *)oldFront->mBuffer + ap->mBufferQueue.mSizeConsumed;
125 if (ap->mBufferQueue.mSizeConsumed + size < oldFront->mSize) {
127 ap->mBufferQueue.mSizeConsumed += size;
133 sizeConsumed = oldFront->mSize - ap->mBufferQueue.mSizeConsumed;
136 ap->mBufferQueue.mSizeConsumed = 0;
137 if (newFront == &ap->mBufferQueue.mArray[ap->mBufferQueue.mNumBuffers + 1]) {
138 newFront = ap->mBufferQueue.mArray;
140 ap->mBufferQueue.mFront = newFront;
142 ap->mBufferQueue.mState.count--;
143 ap->mBufferQueue.mState.playIndex++;
148 callback = ap->mBufferQueue.mCallback;
150 callbackPContext = ap->mBufferQueue.mContext;
158 object_unlock_exclusive(&ap->mObject);
161 (*callback)(&ap->mBufferQueue.mItf, callbackPContext);
164 ap->mCallbackProtector->exitCb();
173 void android_audioPlayer_volumeUpdate(CAudioPlayer* ap)
175 assert(ap != NULL);
178 SLuint8 channelCount = ap->mNumChannels;
185 if (ap->mMuteMask & LEFT_CHANNEL_MASK) {
190 if (ap->mSoloMask & LEFT_CHANNEL_MASK) {
195 if (ap->mSoloMask & RIGHT_CHANNEL_MASK) {
205 if (ap->mMuteMask & RIGHT_CHANNEL_MASK) {
210 if (ap->mSoloMask & RIGHT_CHANNEL_MASK) {
215 if (ap->mSoloMask & LEFT_CHANNEL_MASK) {
234 android_player_volumeUpdate(volumes, &ap->mVolume, channelCount, ap->mAmplFromDirectLevel,
239 if (ap->mAPlayer != 0) {
240 ap->mAPlayer->setVolume(leftVol, rightVol);
241 } else if (ap->mAudioTrack != 0) {
242 ap->mAudioTrack->setVolume(leftVol, rightVol);
248 if (NULL != ap->mEffectSend.mItf) {
250 if (ap->mEffectSend.mEnableLevels[i].mEnable) {
251 android_fxSend_setSendLevel(ap,
252 ap->mEffectSend.mEnableLevels[i].mSendLevel + ap->mVolume.mLevel);
258 } else if (NULL != ap->mAndroidEffectSend.mItf) {
259 android_fxSend_setSendLevel(ap, ap->mAndroidEffectSend.mSendLevel + ap->mVolume.mLevel);
339 void audioTrack_handleMarker_lockPlay(CAudioPlayer* ap) {
344 interface_lock_shared(&ap->mPlay);
345 callback = ap->mPlay.mCallback;
346 callbackPContext = ap->mPlay.mContext;
347 interface_unlock_shared(&ap->mPlay);
351 (*callback)(&ap->mPlay.mItf, callbackPContext, SL_PLAYEVENT_HEADATMARKER);
356 void audioTrack_handleNewPos_lockPlay(CAudioPlayer* ap) {
361 interface_lock_shared(&ap->mPlay);
362 callback = ap->mPlay.mCallback;
363 callbackPContext = ap->mPlay.mContext;
364 interface_unlock_shared(&ap->mPlay);
368 (*callback)(&ap->mPlay.mItf, callbackPContext, SL_PLAYEVENT_HEADATNEWPOS);
374 void audioTrack_handleUnderrun_lockPlay(CAudioPlayer* ap) {
378 interface_lock_shared(&ap->mPlay);
379 callback = ap->mPlay.mCallback;
380 callbackPContext = ap->mPlay.mContext;
381 bool headStalled = (ap->mPlay.mEventFlags & SL_PLAYEVENT_HEADSTALLED) != 0;
382 interface_unlock_shared(&ap->mPlay);
385 (*callback)(&ap->mPlay.mItf, callbackPContext, SL_PLAYEVENT_HEADSTALLED);
404 void audioPlayer_dispatch_headAtEnd_lockPlay(CAudioPlayer *ap, bool setPlayStateToPaused,
406 //SL_LOGV("ap=%p, setPlayStateToPaused=%d, needToLock=%d", ap, setPlayStateToPaused,
412 interface_lock_exclusive(&ap->mPlay);
414 if (ap->mPlay.mEventFlags & SL_PLAYEVENT_HEADATEND) {
415 playCallback = ap->mPlay.mCallback;
416 playContext = ap->mPlay.mContext;
419 ap->mPlay.mState = SL_PLAYSTATE_PAUSED;
422 interface_unlock_exclusive(&ap->mPlay);
427 (*playCallback)(&ap->mPlay.mItf, playContext, SL_PLAYEVENT_HEADATEND);
429 SLresult result = EnqueueAsyncCallback_ppi(ap, playCallback, &ap->mPlay.mItf, playContext,
433 &ap->mPlay.mItf, playContext);
442 SLresult audioPlayer_setStreamType(CAudioPlayer* ap, SLint32 type) {
473 // (ap->mAudioTrack is supposed to be NULL until then)
474 if (SL_OBJECT_STATE_UNREALIZED != ap->mObject.mState) {
478 ap->mStreamType = newStreamType;
486 SLresult audioPlayer_getStreamType(CAudioPlayer* ap, SLint32 *pType) {
489 switch (ap->mStreamType) {
520 void audioPlayer_auxEffectUpdate(CAudioPlayer* ap) {
521 if ((ap->mAudioTrack != 0) && (ap->mAuxEffect != 0)) {
522 android_fxSend_attach(ap, true, ap->mAuxEffect, ap->mVolume.mLevel + ap->mAuxSendLevel);
568 AndroidObjectType audioPlayer_getAndroidObjectTypeForSourceSink(const CAudioPlayer *ap) {
570 const SLDataSource *pAudioSrc = &ap->mDataSource.u.mSource;
571 const SLDataSink *pAudioSnk = &ap->mDataSink.u.mSink;
663 CAudioPlayer *ap = (CAudioPlayer *)user;
664 if (!android::CallbackProtector::enterCbIfOk(ap->mCallbackProtector)) {
678 SL_LOGV("Received GenericPlayer::kEventPrepared for CAudioPlayer %p", ap);
685 object_lock_exclusive(&ap->mObject);
688 assert(ap->mAndroidObjState == ANDROID_PREPARING);
689 ap->mAndroidObjState = ANDROID_READY;
692 // Most of successful prepare completion for ap->mAPlayer
700 if (IsInterfaceInitialized(&ap->mObject, MPH_PREFETCHSTATUS)) {
701 ap->mPrefetchStatus.mLevel = 0;
702 ap->mPrefetchStatus.mStatus = SL_PREFETCHSTATUS_UNDERFLOW;
703 if (!(~ap->mPrefetchStatus.mCallbackEventsMask &
705 callback = ap->mPrefetchStatus.mCallback;
706 callbackPContext = ap->mPrefetchStatus.mContext;
712 object_unlock_exclusive(&ap->mObject);
716 (*callback)(&ap->mPrefetchStatus.mItf, callbackPContext, events);
723 if (!IsInterfaceInitialized(&ap->mObject, MPH_PREFETCHSTATUS)) {
730 interface_lock_exclusive(&ap->mPrefetchStatus);
731 if (ap->mPrefetchStatus.mCallbackEventsMask & SL_PREFETCHEVENT_FILLLEVELCHANGE) {
732 callback = ap->mPrefetchStatus.mCallback;
733 callbackPContext = ap->mPrefetchStatus.mContext;
735 ap->mPrefetchStatus.mLevel = (SLpermille)data1;
736 interface_unlock_exclusive(&ap->mPrefetchStatus);
740 (*callback)(&ap->mPrefetchStatus.mItf, callbackPContext,
747 if (!IsInterfaceInitialized(&ap->mObject, MPH_PREFETCHSTATUS)) {
754 object_lock_exclusive(&ap->mObject);
755 if (ap->mPrefetchStatus.mCallbackEventsMask & SL_PREFETCHEVENT_STATUSCHANGE) {
756 callback = ap->mPrefetchStatus.mCallback;
757 callbackPContext = ap->mPrefetchStatus.mContext;
760 ap->mPrefetchStatus.mStatus = SL_PREFETCHSTATUS_SUFFICIENTDATA;
762 ap->mPrefetchStatus.mStatus = SL_PREFETCHSTATUS_UNDERFLOW;
764 object_unlock_exclusive(&ap->mObject);
768 (*callback)(&ap->mPrefetchStatus.mItf, callbackPContext, SL_PREFETCHEVENT_STATUSCHANGE);
774 audioPlayer_dispatch_headAtEnd_lockPlay(ap, true /*set state to paused?*/, true);
775 if ((ap->mAudioTrack != 0) && (!ap->mSeek.mLoopEnabled)) {
776 ap->mAudioTrack->stop();
782 object_lock_exclusive(&ap->mObject);
783 if (UNKNOWN_NUMCHANNELS == ap->mNumChannels && UNKNOWN_NUMCHANNELS != data1) {
784 ap->mNumChannels = data1;
785 android_audioPlayer_volumeUpdate(ap);
787 object_unlock_exclusive(&ap->mObject);
795 interface_lock_shared(&ap->mPlay);
796 callback = ap->mPlay.mCallback;
797 callbackPContext = ap->mPlay.mContext;
798 interface_unlock_shared(&ap->mPlay);
804 (*callback)(&ap->mPlay.mItf, callbackPContext, event);
807 SLresult result = EnqueueAsyncCallback_ppi(ap, callback, &ap->mPlay.mItf,
811 &ap->mPlay.mItf, callbackPContext, event);
825 object_lock_exclusive(&ap->mObject);
826 if (IsInterfaceInitialized(&ap->mObject, MPH_PREFETCHSTATUS)) {
827 ap->mPrefetchStatus.mLevel = 0;
828 ap->mPrefetchStatus.mStatus = SL_PREFETCHSTATUS_UNDERFLOW;
829 if (!(~ap->mPrefetchStatus.mCallbackEventsMask &
831 callback = ap->mPrefetchStatus.mCallback;
832 callbackPContext = ap->mPrefetchStatus.mContext;
835 object_unlock_exclusive(&ap->mObject);
842 (*callback)(&ap->mPrefetchStatus.mItf, callbackPContext,
857 ap->mCallbackProtector->exitCb();
1124 CAudioPlayer *ap = (CAudioPlayer *)user;
1126 if (!android::CallbackProtector::enterCbIfOk(ap->mCallbackProtector)) {
1142 interface_lock_exclusive(&ap->mBufferQueue);
1144 if (ap->mBufferQueue.mCallbackPending) {
1146 slBufferQueueCallback callback = ap->mBufferQueue.mCallback;
1148 callbackPContext = ap->mBufferQueue.mContext;
1149 interface_unlock_exclusive(&ap->mBufferQueue);
1150 (*callback)(&ap->mBufferQueue.mItf, callbackPContext);
1151 interface_lock_exclusive(&ap->mBufferQueue);
1152 ap->mBufferQueue.mCallbackPending = false;
1156 if (ap->mBufferQueue.mState.count != 0) {
1157 //SL_LOGV("nbBuffers in queue = %u",ap->mBufferQueue.mState.count);
1158 assert(ap->mBufferQueue.mFront != ap->mBufferQueue.mRear);
1160 BufferHeader *oldFront = ap->mBufferQueue.mFront;
1163 size_t availSource = oldFront->mSize - ap->mBufferQueue.mSizeConsumed;
1166 void *pSrc = (char *)oldFront->mBuffer + ap->mBufferQueue.mSizeConsumed;
1170 ap->mBufferQueue.mSizeConsumed += bytesToCopy;
1175 ap->mBufferQueue.mSizeConsumed = 0;
1177 &ap->mBufferQueue.mArray
1178 [ap->mBufferQueue.mNumBuffers + 1])
1180 newFront = ap->mBufferQueue.mArray;
1182 ap->mBufferQueue.mFront = newFront;
1184 ap->mBufferQueue.mState.count--;
1185 ap->mBufferQueue.mState.playIndex++;
1186 ap->mBufferQueue.mCallbackPending = true;
1193 audioPlayer_dispatch_headAtEnd_lockPlay(ap, false /*set state to paused?*/, false);
1196 if (IsInterfaceInitialized(&ap->mObject, MPH_PREFETCHSTATUS)) {
1197 ap->mPrefetchStatus.mStatus = SL_PREFETCHSTATUS_UNDERFLOW;
1198 ap->mPrefetchStatus.mLevel = 0;
1200 prefetchEvents = ap->mPrefetchStatus.mCallbackEventsMask &
1203 prefetchCallback = ap->mPrefetchStatus.mCallback;
1204 prefetchContext = ap->mPrefetchStatus.mContext;
1209 ap->mAudioTrack->stop();
1211 interface_unlock_exclusive(&ap->mBufferQueue);
1218 (*prefetchCallback)(&ap->mPrefetchStatus.mItf, prefetchContext,
1222 (*prefetchCallback)(&ap->mPrefetchStatus.mItf, prefetchContext,
1231 audioTrack_handleMarker_lockPlay(ap);
1236 audioTrack_handleNewPos_lockPlay(ap);
1241 audioTrack_handleUnderrun_lockPlay(ap);
1259 ap->mCallbackProtector->exitCb();
1313 SLresult android_audioPlayer_setConfig(CAudioPlayer *ap, const SLchar *configKey,
1318 assert(NULL != ap && NULL != configKey && NULL != pConfigValue);
1326 result = audioPlayer_setStreamType(ap, *(SLuint32*)pConfigValue);
1339 SLresult android_audioPlayer_getConfig(CAudioPlayer* ap, const SLchar *configKey,
1344 assert(NULL != ap && NULL != configKey && NULL != pValueSize);
1354 result = audioPlayer_getStreamType(ap, (SLint32*)pConfigValue);
1747 SLresult android_audioPlayer_setPlaybackRateAndConstraints(CAudioPlayer *ap, SLpermille rate,
1750 switch (ap->mAndroidObjType) {
1757 uint32_t contentRate = sles_to_android_sampleRate(ap->mSampleRateMilliHz);
1759 if (ap->mAudioTrack != 0) {
1760 ap->mAudioTrack->setSampleRate(contentRate * (rate/1000.0f));
1769 if (ap->mAPlayer != 0) {
1770 ap->mAPlayer->setPlaybackRate((int16_t)rate);
1776 SL_LOGE("Unexpected object type %d", ap->mAndroidObjType);
1787 // ap != NULL
1789 SLresult android_audioPlayer_metadata_getItemCount(CAudioPlayer *ap, SLuint32 *pItemCount) {
1790 if (ap->mAPlayer == 0) {
1793 switch (ap->mAndroidObjType) {
1798 static_cast<android::AudioSfDecoder*>(ap->mAPlayer.get());
1813 // ap != NULL
1815 SLresult android_audioPlayer_metadata_getKeySize(CAudioPlayer *ap,
1817 if (ap->mAPlayer == 0) {
1821 switch (ap->mAndroidObjType) {
1826 static_cast<android::AudioSfDecoder*>(ap->mAPlayer.get());
1849 // ap != NULL
1851 SLresult android_audioPlayer_metadata_getKey(CAudioPlayer *ap,
1853 if (ap->mAPlayer == 0) {
1857 switch (ap->mAndroidObjType) {
1862 static_cast<android::AudioSfDecoder*>(ap->mAPlayer.get());
1886 // ap != NULL
1888 SLresult android_audioPlayer_metadata_getValueSize(CAudioPlayer *ap,
1890 if (ap->mAPlayer == 0) {
1894 switch (ap->mAndroidObjType) {
1899 static_cast<android::AudioSfDecoder*>(ap->mAPlayer.get());
1922 // ap != NULL
1924 SLresult android_audioPlayer_metadata_getValue(CAudioPlayer *ap,
1926 if (ap->mAPlayer == 0) {
1930 switch (ap->mAndroidObjType) {
1935 static_cast<android::AudioSfDecoder*>(ap->mAPlayer.get());
1958 // ap != NULL
1961 void android_audioPlayer_setPlayState(CAudioPlayer *ap) {
1963 SLuint32 playState = ap->mPlay.mState;
1964 AndroidObjectState objState = ap->mAndroidObjState;
1966 switch (ap->mAndroidObjType) {
1971 if (ap->mAudioTrack != 0) {
1972 ap->mAudioTrack->stop();
1977 if (ap->mAudioTrack != 0) {
1978 ap->mAudioTrack->pause();
1983 if (ap->mAudioTrack != 0) {
1984 // instead of ap->mAudioTrack->start();
1985 ap->mDeferredStart = true;
2000 aplayer_setPlayState(ap->mAPlayer, playState, &ap->mAndroidObjState);
2003 SL_LOGE(ERROR_PLAYERSETPLAYSTATE_UNEXPECTED_OBJECT_TYPE_D, ap->mAndroidObjType);
2011 void android_audioPlayer_usePlayEventMask(CAudioPlayer *ap) {
2012 IPlay *pPlayItf = &ap->mPlay;
2014 /*switch (ap->mAndroidObjType) {
2017 if (ap->mAPlayer != 0) {
2018 assert(ap->mAudioTrack == 0);
2019 ap->mAPlayer->setPlayEvents((int32_t) eventFlags, (int32_t) pPlayItf->mMarkerPosition,
2024 if (ap->mAudioTrack == 0) {
2029 ap->mAudioTrack->setMarkerPosition((uint32_t)((((int64_t)pPlayItf->mMarkerPosition
2030 * sles_to_android_sampleRate(ap->mSampleRateMilliHz)))/1000));
2033 ap->mAudioTrack->setMarkerPosition(0);
2037 ap->mAudioTrack->setPositionUpdatePeriod(
2039 * sles_to_android_sampleRate(ap->mSampleRateMilliHz)))/1000));
2042 ap->mAudioTrack->setPositionUpdatePeriod(0);
2063 CAudioPlayer *ap = (CAudioPlayer *)pPlayItf->mThis;
2064 switch (ap->mAndroidObjType) {
2069 if (ap->mAPlayer != 0) {
2070 ap->mAPlayer->getDurationMsec(&durationMsec);
2089 CAudioPlayer *ap = (CAudioPlayer *)pPlayItf->mThis;
2090 switch (ap->mAndroidObjType) {
2093 if ((ap->mSampleRateMilliHz == UNKNOWN_SAMPLERATE) || (ap->mAudioTrack == 0)) {
2097 ap->mAudioTrack->getPosition(&positionInFrames);
2099 sles_to_android_sampleRate(ap->mSampleRateMilliHz);
2108 if (ap->mAPlayer != 0) {
2109 ap->mAPlayer->getPositionMsec(&posMsec);
2122 SLresult android_audioPlayer_seek(CAudioPlayer *ap, SLmillisecond posMsec) {
2125 switch (ap->mAndroidObjType) {
2135 if (ap->mAPlayer != 0) {
2136 ap->mAPlayer->seek(posMsec);
2148 SLresult android_audioPlayer_loop(CAudioPlayer *ap, SLboolean loopEnable) {
2151 switch (ap->mAndroidObjType) {
2155 if (ap->mAPlayer != 0) {
2156 ap->mAPlayer->loop((bool)loopEnable);
2168 SLresult android_audioPlayer_setBufferingUpdateThresholdPerMille(CAudioPlayer *ap,
2172 switch (ap->mAndroidObjType) {
2174 if (ap->mAPlayer != 0) {
2175 ap->mAPlayer->setBufferingUpdateThreshold(threshold / 10);
2187 void android_audioPlayer_bufferQueue_onRefilled_l(CAudioPlayer *ap) {
2191 if (ap->mAudioTrack != 0) {
2192 // instead of ap->mAudioTrack->start();
2193 ap->mDeferredStart = true;
2198 if (IsInterfaceInitialized(&ap->mObject, MPH_PREFETCHSTATUS)) {
2200 assert(SL_PREFETCHSTATUS_UNDERFLOW == ap->mPrefetchStatus.mStatus);
2201 assert(0 == ap->mPrefetchStatus.mLevel);
2202 ap->mPrefetchStatus.mStatus = SL_PREFETCHSTATUS_SUFFICIENTDATA;
2203 ap->mPrefetchStatus.mLevel = 1000;
2205 SLuint32 prefetchEvents = ap->mPrefetchStatus.mCallbackEventsMask &
2208 ap->mPrefetchStatus.mDeferredPrefetchCallback = ap->mPrefetchStatus.mCallback;
2209 ap->mPrefetchStatus.mDeferredPrefetchContext = ap->mPrefetchStatus.mContext;
2210 ap->mPrefetchStatus.mDeferredPrefetchEvents = prefetchEvents;
2220 SLresult android_audioPlayer_bufferQueue_onClear(CAudioPlayer *ap) {
2223 switch (ap->mAndroidObjType) {
2227 if (ap->mAudioTrack != 0) {
2228 ap->mAudioTrack->flush();
2241 void android_audioPlayer_androidBufferQueue_clear_l(CAudioPlayer *ap) {
2242 switch (ap->mAndroidObjType) {
2244 if (ap->mAPlayer != 0) {
2245 android::StreamPlayer* splr = static_cast<android::StreamPlayer*>(ap->mAPlayer.get());
2255 void android_audioPlayer_androidBufferQueue_onRefilled_l(CAudioPlayer *ap) {
2256 switch (ap->mAndroidObjType) {
2258 if (ap->mAPlayer != 0) {
2259 android::StreamPlayer* splr = static_cast<android::StreamPlayer*>(ap->mAPlayer.get());