Home | History | Annotate | Download | only in audioflinger

Lines Matching refs:TRACK

112 // Offloaded output thread standby delay: allows track transition without going to standby
122 FastMixer_Dynamic, // initialize if needed, then use dynamically depending on track load,
137 // for the track. The client then sub-divides this into smaller buffers for its use.
1096 Track::appendDumpHeader(result);
1098 sp<Track> track = mTracks[i];
1099 if (track != 0) {
1100 track->dump(buffer, SIZE);
1107 Track::appendDumpHeader(result);
1109 sp<Track> track = mActiveTracks[i].promote();
1110 if (track != 0) {
1111 track->dump(buffer, SIZE);
1147 fdprintf(fd, "Fast track availMask=%#x\n", mFastTrackAvailMask);
1179 sp<AudioFlinger::PlaybackThread::Track> AudioFlinger::PlaybackThread::createTrack_l(
1193 sp<Track> track;
1227 // there are sufficient fast track slots available
1229 // FIXME test that MixerThread for this fast track has a capable output HAL
1310 sp<Track> t = mTracks[i];
1323 track = new Track(this, client, streamType, sampleRate, format,
1326 track = TimedTrack::create(this, client, streamType, sampleRate, format,
1330 if (track == 0 || track->getCblk() == NULL || track->name() < 0) {
1332 // track must be cleared from the caller as the caller has the AF lock
1336 mTracks.add(track);
1341 track->setMainBuffer(chain->inBuffer());
1342 chain->setStrategy(AudioSystem::getStrategyForStream(track->streamType()));
1360 return track;
1427 status_t AudioFlinger::PlaybackThread::addTrack_l(const sp<Track>& track)
1432 track->mRetryCount = kMaxTrackStartupRetries;
1433 if (mActiveTracks.indexOf(track) < 0) {
1434 // the track is newly added, make sure it fills up all its
1437 if (!track->isOutputTrack()) {
1438 TrackBase::track_state state = track->mState;
1440 status = AudioSystem::startOutput(mId, track->streamType(), track->sessionId());
1442 // abort track was stopped/paused while we released the lock
1443 if (state != track->mState) {
1446 AudioSystem::stopOutput(mId, track->streamType(), track->sessionId());
1456 // to track the speaker usage
1461 track->mFillingUpStatus = track->sharedBuffer() != 0 ? Track::FS_FILLED : Track::FS_FILLING;
1462 track->mResetDone = false;
1463 track->mPresentationCompleteFrames = 0;
1464 mActiveTracks.add(track);
1465 mWakeLockUids.add(track->uid());
1467 mLatestActiveTrack = track;
1468 sp<EffectChain> chain = getEffectChain_l(track->sessionId());
1470 ALOGV("addTrack_l() starting track on chain %p for session %d", chain.get(),
1471 track->sessionId());
1484 bool AudioFlinger::PlaybackThread::destroyTrack_l(const sp<Track>& track)
1486 track->terminate();
1488 bool trackActive = (mActiveTracks.indexOf(track) >= 0);
1489 track->mState = TrackBase::STOPPED;
1491 removeTrack_l(track);
1492 } else if (track->isFastTrack() || track->isOffloaded()) {
1493 track->mState = TrackBase::STOPPING_1;
1499 void AudioFlinger::PlaybackThread::removeTrack_l(const sp<Track>& track)
1501 track->triggerEvents(AudioSystem::SYNC_EVENT_PRESENTATION_COMPLETE);
1502 mTracks.remove(track);
1503 deleteTrackName_l(track->name());
1504 // redundant as track is about to be destroyed, for dumpsys only
1505 track->mName = -1;
1506 if (track->isFastTrack()) {
1507 int index = track->mFastIndex;
1511 // redundant as track is about to be destroyed, for dumpsys only
1512 track->mFastIndex = -1;
1514 sp<EffectChain> chain = getEffectChain_l(track->sessionId());
1686 // track, but we sometimes have to do this to satisfy the maximum frame count
1754 sp<Track> track = mTracks[i];
1755 if (sessionId == track->sessionId() && !track->isInvalid()) {
1772 sp<Track> track = mTracks[i];
1773 if (sessionId == track->sessionId() && !track->isInvalid()) {
1774 return AudioSystem::getStrategyForStream(track->streamType());
1823 sp<Track> track = mTracks[i];
1824 if (event->triggerSession() == track->sessionId()) {
1825 (void) track->setSyncEvent(event);
1839 const Vector< sp<Track> >& tracksToRemove)
1844 const sp<Track>& track = tracksToRemove.itemAt(i);
1845 if (!track->isOutputTrack()) {
1846 AudioSystem::stopOutput(mId, track->streamType(), track->sessionId());
1848 // to track the speaker usage
1851 if (track->isTerminated()) {
2000 sp<Track> t = mTracks[i];
2027 sp<Track> track = mTracks[i];
2028 if (session == track->sessionId()) {
2029 ALOGV("addEffectChain_l() track->setMainBuffer track %p buffer %p", track.get(),
2031 track->setMainBuffer(buffer);
2038 sp<Track> track = mActiveTracks[i].promote();
2039 if (track == 0) {
2042 if (session == track->sessionId()) {
2043 ALOGV("addEffectChain_l() activating track %p on session %d", track.get(), session);
2055 // after track specific effects and before output stage
2085 sp<Track> track = mActiveTracks[i].promote();
2086 if (track == 0) {
2089 if (session == track->sessionId()) {
2090 ALOGV("removeEffectChain_l(): stopping track on chain %p for session Id: %d",
2098 sp<Track> track = mTracks[i];
2099 if (session == track->sessionId()) {
2100 track->setMainBuffer(mMixBuffer);
2111 const sp<AudioFlinger::PlaybackThread::Track> track, int EffectId)
2114 return attachAuxEffect_l(track, EffectId);
2118 const sp<AudioFlinger::PlaybackThread::Track> track, int EffectId)
2123 track->setAuxBuffer(0, NULL);
2129 track->setAuxBuffer(EffectId, (int32_t *)effect->inBuffer());
2143 sp<Track> track = mTracks[i];
2144 if (track->auxEffectId() == effectId) {
2145 attachAuxEffect_l(track, 0);
2152 Vector< sp<Track> > tracksToRemove;
2322 // was read from audio track: process only updates effect state
2369 // Finally let go of removed track(s), without the lock held
2407 void AudioFlinger::PlaybackThread::removeTracks_l(const Vector< sp<Track> >& tracksToRemove)
2412 const sp<Track>& track = tracksToRemove.itemAt(i);
2413 mActiveTracks.remove(track);
2414 mWakeLockUids.remove(track->uid());
2416 ALOGV("removeTracks_l removing track on session %d", track->sessionId());
2417 sp<EffectChain> chain = getEffectChain_l(track->sessionId());
2419 ALOGV("stopping track on chain %p for session Id: %d", chain.get(),
2420 track->sessionId());
2423 if (track->isTerminated()) {
2424 removeTrack_l(track);
2524 // create fast mixer and configure it initially with just one fast track for our submix
2613 // We'll use that extract the final state which contains one remaining fast track
2645 void AudioFlinger::MixerThread::threadLoop_removeTracks(const Vector< sp<Track> >& tracksToRemove)
2813 Vector< sp<Track> > *tracksToRemove)
2851 const sp<Track> t = mActiveTracks[i].promote();
2857 Track* const track = t.get();
2860 if (track->isFastTrack()) {
2862 // It's theoretically possible (though unlikely) for a fast track to be created
2864 // the track never becomes active so it's fast mixer slot is never touched.
2865 // The converse, of removing an (active) track and then creating a new track
2868 int j = track->mFastIndex;
2873 // Determine whether the track is currently in underrun condition,
2878 track->mObservedUnderruns.mBitFields.mFull) & UNDERRUN_MASK;
2880 track->mObservedUnderruns.mBitFields.mPartial) & UNDERRUN_MASK;
2882 track->mObservedUnderruns.mBitFields.mEmpty) & UNDERRUN_MASK;
2884 track->mObservedUnderruns = underruns;
2887 if (!(track->isStopping() || track->isPausing() || track->isStopped()) &&
2890 track->mAudioTrackServerProxy->tallyUnderrunFrames(recentUnderruns * mFrameCount);
2896 switch (track->mState) {
2898 // track stays active in STOPPING_1 state until first underrun
2899 if (recentUnderruns > 0 || track->isTerminated()) {
2900 track->mState = TrackBase::STOPPING_2;
2905 track->setPaused();
2909 track->mState = TrackBase::ACTIVE;
2913 // track has provided at least some frames recently: reset retry count
2914 track->mRetryCount = kMaxTrackRetries;
2921 if (track->sharedBuffer() == 0) {
2928 if (--(track->mRetryCount) > 0) {
2931 // indicate to client process that the track was disabled because of underrun;
2933 android_atomic_or(CBLK_DISABLED, &track->mCblk->mFlags);
2943 // Check for presentation complete if track is inactive
2944 // We have consumed all the buffers of this track.
2950 if (!(mStandby || track->presentationComplete(framesWritten, audioHALFrames))) {
2951 // track stays in active list until presentation is complete
2955 if (track->isStopping_2()) {
2956 track->mState = TrackBase::STOPPED;
2958 if (track->isStopped()) {
2959 // Can't reset directly, as fast mixer is still polling this track
2960 // track->reset();
2961 // So instead mark this track as needing to be reset after push with ack
2968 LOG_FATAL("unexpected track state %d", track->mState);
2974 ExtendedAudioBufferProvider *eabp = track;
2975 VolumeProvider *vp = track;
2978 fastTrack->mSampleRate = track->mSampleRate;
2979 fastTrack->mChannelMask = track->mChannelMask;
2987 track->mCachedVolume = masterVolume * mStreamTypes[track->streamType()].volume;
3000 LOG_FATAL("fast track %d should have been active", j);
3002 tracksToRemove->add(track);
3004 track->mObservedUnderruns.mBitFields.mMostRecent = UNDERRUN_FULL;
3011 audio_track_cblk_t* cblk = track->cblk();
3013 // The first time a track is added we wait
3015 int name = track->name();
3019 // hence the test on (mMixerStatus == MIXER_TRACKS_READY) meaning the track was mixed
3022 uint32_t sr = track->sampleRate();
3030 desiredFrames += mAudioMixer->getUnreleasedFrames(track->name());
3031 // the minimum track buffer size is normally twice the number of frames necessary
3037 if ((track->sharedBuffer() == 0) && !track->isStopped() && !track->isPausing() &&
3042 size_t framesReady = track->framesReady();
3043 if ((framesReady >= minFrames) && track->isReady() &&
3044 !track->isPaused() && !track->isTerminated())
3046 ALOGVV("track %d s=%08x [OK] on thread %p", name, cblk->mServer, this);
3050 // track->mainBuffer() != mMixBuffer means there is an effect chain
3051 // connected to the track
3053 if (track->mainBuffer() != mMixBuffer) {
3054 chain = getEffectChain_l(track->sessionId());
3055 // Delegate volume control to effect in track effect chain if needed
3059 ALOGW("prepareTracks_l(): track %d attached to effect but no chain found on "
3061 name, track->sessionId());
3067 if (track->mFillingUpStatus == Track::FS_FILLED) {
3069 track->mFillingUpStatus = Track::FS_ACTIVE;
3070 if (track->mState == TrackBase::RESUMING) {
3071 track->mState = TrackBase::ACTIVE;
3077 // If the track is stopped before the first frame was mixed,
3082 // compute volume for this track
3084 if (track->isPausing() || mStreamTypes[track->streamType()].mute) {
3086 if (track->isPausing()) {
3087 track->setPaused();
3092 track->streamType()].volume;
3094 AudioTrackServerProxy *proxy = track->mAudioTrackServerProxy;
3098 // track volumes come from shared memory, so can't be trusted and must be clamped
3100 ALOGV("Track left volume out of range: %04X", vl);
3104 ALOGV("Track right volume out of range: %04X", vr);
3116 ALOGV("Track send level out of range: %04X", sendLevel);
3122 // Delegate volume control to effect in track effect chain if needed
3126 track->mHasVolumeController = true;
3130 if (track->mHasVolumeController) {
3133 track->mHasVolumeController = false;
3152 mAudioMixer->setBufferProvider(name, track);
3160 AudioMixer::TRACK,
3161 AudioMixer::FORMAT, (void *)track->format());
3164 AudioMixer::TRACK,
3165 AudioMixer::CHANNEL_MASK, (void *)track->channelMask());
3166 // limit track sample rate to 2 x output sample rate, which changes at re-configuration
3168 uint32_t reqSampleRate = track->mAudioTrackServerProxy->getSampleRate();
3181 AudioMixer::TRACK,
3182 AudioMixer::MAIN_BUFFER, (void *)track->mainBuffer());
3185 AudioMixer::TRACK,
3186 AudioMixer::AUX_BUFFER, (void *)track->auxBuffer());
3189 track->mRetryCount = kMaxTrackRetries;
3191 // If one track is ready, set the mixer ready if:
3193 // - no other track is not ready
3199 if (framesReady < desiredFrames && !track->isStopped() && !track->isPaused()) {
3200 track->mAudioTrackServerProxy->tallyUnderrunFrames(desiredFrames);
3202 // clear effect chain input buffer if an active track underruns to avoid sending
3204 chain = getEffectChain_l(track->sessionId());
3209 ALOGVV("track %d s=%08x [NOT READY] on thread %p", name, cblk->mServer, this);
3210 if ((track->sharedBuffer() != 0) || track->isTerminated() ||
3211 track->isStopped() || track->isPaused()) {
3212 // We have consumed all the buffers of this track.
3218 if (mStandby || track->presentationComplete(framesWritten, audioHALFrames)) {
3219 if (track->isStopped()) {
3220 track->reset();
3222 tracksToRemove->add(track);
3225 // No buffers for this track. Give it a few chances to
3227 if (--(track->mRetryCount) <= 0) {
3229 tracksToRemove->add(track);
3230 // indicate to client process that the track was disabled because of underrun;
3233 // If one track is not ready, mark the mixer also not ready if:
3235 // - no other track is ready
3284 sp<Track> t = mActiveTracks[i].promote();
3288 Track* track = t.get();
3289 ALOG_ASSERT(track->isFastTrack() && track->isStopped());
3290 track->reset();
3298 // mix buffer and track effects will accumulate into it
3322 ALOGV("remove track (%d) and delete from mixer", name);
3371 // do not accept frame count changes if tracks are open as the track buffer
3373 // if frame count is changed after track creation
3542 void AudioFlinger::DirectOutputThread::processVolume_l(Track *track, bool lastTrack)
3544 audio_track_cblk_t* cblk = track->cblk();
3547 if (mMasterMute || mStreamTypes[track->streamType()].mute) {
3550 float typeVolume = mStreamTypes[track->streamType()].volume;
3552 AudioTrackServerProxy *proxy = track->mAudioTrackServerProxy;
3571 // Delegate volume control to effect in track effect chain if needed
3573 // there is one, the track is connected to it
3588 Vector< sp<Track> > *tracksToRemove
3596 sp<Track> t = mActiveTracks[i].promote();
3597 // The track died recently
3602 Track* const track = t.get();
3603 audio_track_cblk_t* cblk = track->cblk();
3604 // Only consider last track started for volume and mixer state control.
3605 // In theory an older track could underrun and restart after the new one starts
3608 sp<Track> l = mLatestActiveTrack.promote();
3609 bool last = l.get() == track;
3611 // The first time a track is added we wait
3614 if ((track->sharedBuffer() == 0) && !track->isStopped() && !track->isPausing()) {
3620 if ((track->framesReady() >= minFrames) && track->isReady() &&
3621 !track->isPaused() && !track->isTerminated())
3623 ALOGVV("track %d s=%08x [OK]", track->name(), cblk->mServer);
3625 if (track->mFillingUpStatus == Track::FS_FILLED) {
3626 track->mFillingUpStatus = Track::FS_ACTIVE;
3629 if (track->mState == TrackBase::RESUMING) {
3630 track->mState = TrackBase::ACTIVE;
3634 // compute volume for this track
3635 processVolume_l(track, last);
3638 track->mRetryCount = kMaxTrackRetriesDirect;
3643 // clear effect chain input buffer if the last active track started underruns
3649 ALOGVV("track %d s=%08x [NOT READY]", track->name(), cblk->mServer);
3650 if ((track->sharedBuffer() != 0) || track->isTerminated() ||
3651 track->isStopped() || track->isPaused()) {
3652 // We have consumed all the buffers of this track.
3658 track->presentationComplete(framesWritten, audioHALFrames)) {
3659 if (track->isStopped()) {
3660 track->reset();
3662 tracksToRemove->add(track);
3665 // No buffers for this track. Give it a few chances to
3667 // Only consider last track started for mixer state control
3668 if (--(track->mRetryCount) <= 0) {
3669 ALOGV("BUFFER TIMEOUT: remove(%d) from active list", track->name());
3670 tracksToRemove->add(track);
3671 // indicate to client process that the track was disabled because of underrun;
3749 // do not accept frame count changes if tracks are open as the track buffer
3751 // if frame count is changed after track creation
3948 // If a flush is pending or track was paused, just discard buffered data
3959 Vector< sp<Track> > *tracksToRemove
3972 sp<Track> t = mActiveTracks[i].promote();
3973 // The track died recently
3977 Track* const track = t.get();
3978 audio_track_cblk_t* cblk = track->cblk();
3979 // Only consider last track started for volume and mixer state control.
3980 // In theory an older track could underrun and restart after the new one starts
3983 sp<Track> l = mLatestActiveTrack.promote();
3984 bool last = l.get() == track;
3986 if (track->isPausing()) {
3987 track->setPaused();
3995 // BUG - this will be wrong if a different track is made active,
3998 // track is resumed
4003 tracksToRemove->add(track);
4004 } else if (track->framesReady() && track->isReady() &&
4005 !track->isPaused() && !track->isTerminated() && !track->isStopping_2()) {
4006 ALOGVV("OffloadThread: track %d s=%08x [OK]", track->name(), cblk->mServer);
4007 if (track->mFillingUpStatus == Track::FS_FILLED) {
4008 track->mFillingUpStatus = Track::FS_ACTIVE;
4011 if (track->mState == TrackBase::RESUMING) {
4012 track->mState = TrackBase::ACTIVE;
4033 sp<Track> previousTrack = mPreviousTrack.promote();
4035 if (track != previousTrack.get()) {
4036 // Flush any data still being written from last track
4039 // Last track was paused so we also need to flush saved
4040 // mixbuffer state and invalidate track so that it will
4049 // comes from a different source. Also invalidate previous track to force a
4051 if (previousTrack->sessionId() != track->sessionId()) {
4057 mPreviousTrack = track;
4059 track->mRetryCount = kMaxTrackRetriesOffload;
4064 ALOGVV("OffloadThread: track %d s=%08x [NOT READY]", track->name(), cblk->mServer);
4065 if (track->isStopping_1()) {
4067 // wait for all current track's data to drain before we say
4068 // that the track is stopped.
4073 track->mState = TrackBase::STOPPING_2; // so presentation completes after drain
4092 } else if (track->isStopping_2()) {
4095 track->mState = TrackBase::STOPPED;
4100 track->presentationComplete(framesWritten, audioHALFrames);
4101 track->reset();
4102 tracksToRemove->add(track);
4105 // No buffers for this track. Give it a few chances to
4107 if (--(track->mRetryCount) <= 0) {
4109 track->name());
4110 tracksToRemove->add(track);
4111 // indicate to client process that the track was disabled because of underrun;
4119 // compute volume for this track
4120 processVolume_l(track, last);
4124 // If a flush is pending and a track is active but the HW is not paused, force a HW pause
4296 ALOGV("addOutputTrack() track %p, on thread %p", outputTrack, thread);
4337 ALOGW("DuplicatingThread::outputsReady() could not promote thread on output track %p",
4344 ALOGV("DuplicatingThread output track %p on thread %p Not Ready", outputTracks[i].get(),
4567 // resampler accumulates, but we only have one source track
4637 sp<RecordTrack> track = mTracks[i];
4638 track->invalidate();
4675 sp<RecordTrack> track;
4700 // FIXME test that RecordThread for this fast track has a capable output HAL
4739 track = new RecordTrack(this, client, sampleRate,
4742 if (track->getCblk() == 0) {
4745 // track must be cleared from the caller as the caller has the AF lock
4748 mTracks.add(track);
4769 return track;
4788 // Sync event can be cancelled by the trigger session if the track is not in a
4916 sp<RecordTrack> track = mTracks[i];
4917 if (eventSession == track->sessionId()) {
4918 (void) track->setSyncEvent(event);
4929 void AudioFlinger::RecordThread::destroyTrack_l(const sp<RecordTrack>& track)
4931 track->terminate();
4932 track->mState = TrackBase::STOPPED;
4934 if (mActiveTrack != track) {
4935 removeTrack_l(track);
4939 void AudioFlinger::RecordThread::removeTrack_l(const sp<RecordTrack>& track)
4941 mTracks.remove(track);
4991 sp<RecordTrack> track = mTracks[i];
4992 if (track != 0) {
4993 track->dump(buffer, SIZE);
5085 // do not accept frame count changes if tracks are open as the track buffer
5087 // if frame count is changed after track creation
5115 sp<RecordTrack> track = mTracks[i];
5116 setEffectSuspended_l(FX_IID_AEC, suspend, track->sessionId());
5117 setEffectSuspended_l(FX_IID_NS, suspend, track->sessionId());
5282 sp<RecordThread::RecordTrack> track = mTracks[j];
5283 int sessionId = track->sessionId();