void AudioTrack::stop() { sp<AudioTrackThread> t = mAudioTrackThread; LOGV("stop %p", this); if (t != 0) { t->mLock.lock(); } AutoMutex lock(mLock); if (mActive == 1) { #ifdef WITH_QCOM_LPA if (mAudioTrack != NULL) { #endif mActive = 0; mCblk->cv.signal(); mAudioTrack->stop(); // Cancel loops (If we are in the middle of a loop, playback // would not stop until loopCount reaches 0). setLoop_l(0, 0, 0); // the playback head position will reset to 0, so if a marker is set, we need // to activate it again mMarkerReached = false; // Force flush if a shared buffer is used otherwise audioflinger // will not stop before end of buffer is reached. if (mSharedBuffer != 0) { flush_l(); } if (t != 0) { t->requestExit(); } else { setpriority(PRIO_PROCESS, 0, ANDROID_PRIORITY_NORMAL); } #ifdef WITH_QCOM_LPA } #endif } if (t != 0) { t->mLock.unlock(); } }
status_t AudioTrack::setLoop(uint32_t loopStart, uint32_t loopEnd, int loopCount) { AutoMutex lock(mLock); return setLoop_l(loopStart, loopEnd, loopCount); }