Beispiel #1
0
status_t AudioTrack::reload()
{
    AutoMutex lock(mLock);

    if (!stopped()) return INVALID_OPERATION;

    flush_l();

    mCblk->stepUser(mCblk->frameCount);

    return NO_ERROR;
}
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();
    }
}
Beispiel #3
0
void AudioTrack::flush()
{
    AutoMutex lock(mLock);
    flush_l();
}