Lines Matching refs:track

151     FastMixer_Dynamic,  // initialize if needed, then use dynamically depending on track load,
169 // for the track. The client then sub-divides this into smaller buffers for its use.
455 sp<PlaybackThread::Track> track;
505 track = thread->createTrack_l(client, streamType, sampleRate, format,
509 // for a track to be created
521 (void) track->setSyncEvent(mPendingSyncEvents[i]);
532 trackHandle = new TrackHandle(track);
537 track.clear();
1631 sp<Track> track = mTracks[i];
1632 if (track != 0) {
1633 track->dump(buffer, SIZE);
1642 sp<Track> track = mActiveTracks[i].promote();
1643 if (track != 0) {
1644 track->dump(buffer, SIZE);
1677 fdprintf(fd, "Fast track availMask=%#x\n", mFastTrackAvailMask);
1722 sp<Track> track;
1756 // there are sufficient fast track slots available
1758 // FIXME test that MixerThread for this fast track has a capable output HAL
1837 track = new Track(this, client, streamType, sampleRate, format,
1840 track = TimedTrack::create(this, client, streamType, sampleRate, format,
1843 if (track == 0 || track->getCblk() == NULL || track->name() < 0) {
1847 mTracks.add(track);
1852 track->setMainBuffer(chain->inBuffer());
1853 chain->setStrategy(AudioSystem::getStrategyForStream(track->streamType()));
1871 return track;
1945 status_t AudioFlinger::PlaybackThread::addTrack_l(const sp<Track>& track)
1950 track->mRetryCount = kMaxTrackStartupRetries;
1951 if (mActiveTracks.indexOf(track) < 0) {
1952 // the track is newly added, make sure it fills up all its
1955 track->mFillingUpStatus = Track::FS_FILLING;
1956 track->mResetDone = false;
1957 track->mPresentationCompleteFrames = 0;
1958 mActiveTracks.add(track);
1959 if (track->mainBuffer() != mMixBuffer) {
1960 sp<EffectChain> chain = getEffectChain_l(track->sessionId());
1962 ALOGV("addTrack_l() starting track on chain %p for session %d", chain.get(), track->sessionId());
1977 void AudioFlinger::PlaybackThread::destroyTrack_l(const sp<Track>& track)
1979 track->mState = TrackBase::TERMINATED;
1981 if (mActiveTracks.indexOf(track) < 0) {
1982 removeTrack_l(track);
1986 void AudioFlinger::PlaybackThread::removeTrack_l(const sp<Track>& track)
1988 track->triggerEvents(AudioSystem::SYNC_EVENT_PRESENTATION_COMPLETE);
1989 mTracks.remove(track);
1990 deleteTrackName_l(track->name());
1991 // redundant as track is about to be destroyed, for dumpsys only
1992 track->mName = -1;
1993 if (track->isFastTrack()) {
1994 int index = track->mFastIndex;
1998 // redundant as track is about to be destroyed, for dumpsys only
1999 track->mFastIndex = -1;
2001 sp<EffectChain> chain = getEffectChain_l(track->sessionId());
2086 // track, but we sometimes have to do this to satisfy the maximum frame count constraint)
2152 sp<Track> track = mTracks[i];
2153 if (sessionId == track->sessionId() &&
2154 !(track->mCblk->flags & CBLK_INVALID_MSK)) {
2171 sp<Track> track = mTracks[i];
2172 if (sessionId == track->sessionId() &&
2173 !(track->mCblk->flags & CBLK_INVALID_MSK)) {
2174 return AudioSystem::getStrategyForStream(track->streamType());
2223 sp<Track> track = mTracks[i];
2224 if (event->triggerSession() == track->sessionId()) {
2225 (void) track->setSyncEvent(event);
2243 const sp<Track>& track = tracksToRemove.itemAt(i);
2244 if ((track->sharedBuffer() != 0) &&
2245 (track->mState == TrackBase::ACTIVE || track->mState == TrackBase::RESUMING)) {
2246 AudioSystem::stopOutput(mId, track->streamType(), track->sessionId());
2328 // create fast mixer and configure it initially with just one fast track for our submix
2413 // We'll use that extract the final state which contains one remaining fast track
2689 // Finally let go of removed track(s), without the lock held
2943 Track* const track = t.get();
2946 if (track->isFastTrack()) {
2948 // It's theoretically possible (though unlikely) for a fast track to be created
2950 // the track never becomes active so it's fast mixer slot is never touched.
2951 // The converse, of removing an (active) track and then creating a new track
2954 int j = track->mFastIndex;
2959 // Determine whether the track is currently in underrun condition,
2964 track->mObservedUnderruns.mBitFields.mFull) & UNDERRUN_MASK;
2966 track->mObservedUnderruns.mBitFields.mPartial) & UNDERRUN_MASK;
2968 track->mObservedUnderruns.mBitFields.mEmpty) & UNDERRUN_MASK;
2970 track->mObservedUnderruns = underruns;
2973 if (!(track->isStopping() || track->isPausing() || track->isStopped())) {
2974 track->mUnderrunCount += recentUnderruns;
2980 switch (track->mState) {
2982 // track stays active in STOPPING_1 state until first underrun
2984 track->mState = TrackBase::STOPPING_2;
2989 track->setPaused();
2993 track->mState = TrackBase::ACTIVE;
2997 // track has provided at least some frames recently: reset retry count
2998 track->mRetryCount = kMaxTrackRetries;
3005 if (track->sharedBuffer() == 0) {
3012 if (--(track->mRetryCount) > 0) {
3015 // indicate to client process that the track was disabled because of underrun;
3017 android_atomic_or(CBLK_DISABLED_ON, &track->mCblk->flags);
3028 // Check for presentation complete if track is inactive
3029 // We have consumed all the buffers of this track.
3036 if (!(mStandby || track->presentationComplete(framesWritten, audioHALFrames))) {
3037 // track stays in active list until presentation is complete
3041 if (track->isStopping_2()) {
3042 track->mState = TrackBase::STOPPED;
3044 if (track->isStopped()) {
3045 // Can't reset directly, as fast mixer is still polling this track
3046 // track->reset();
3047 // So instead mark this track as needing to be reset after push with ack
3054 LOG_FATAL("unexpected track state %d", track->mState);
3060 ExtendedAudioBufferProvider *eabp = track;
3061 VolumeProvider *vp = track;
3064 fastTrack->mSampleRate = track->mSampleRate;
3065 fastTrack->mChannelMask = track->mChannelMask;
3073 track->mCachedVolume = track->isMuted() ?
3074 0 : masterVolume * mStreamTypes[track->streamType()].volume;
3087 LOG_FATAL("fast track %d should have been active", j);
3089 tracksToRemove->add(track);
3091 track->mObservedUnderruns.mBitFields.mMostRecent = UNDERRUN_FULL;
3098 audio_track_cblk_t* cblk = track->cblk();
3100 // The first time a track is added we wait
3102 int name = track->name();
3106 // hence the test on (mMixerStatus == MIXER_TRACKS_READY) meaning the track was mixed
3109 if ((track->sharedBuffer() == 0) && !track->isStopped() && !track->isPausing() &&
3118 minFrames += mAudioMixer->getUnreleasedFrames(track->name());
3119 // the minimum track buffer size is normally twice the number of frames necessary
3125 if ((track->framesReady() >= minFrames) && track->isReady() &&
3126 !track->isPaused() && !track->isTerminated())
3128 //ALOGV("track %d u=%08x, s=%08x [OK] on thread %p", name, cblk->user, cblk->server, this);
3132 // track->mainBuffer() != mMixBuffer means there is an effect chain
3133 // connected to the track
3135 if (track->mainBuffer() != mMixBuffer) {
3136 chain = getEffectChain_l(track->sessionId());
3137 // Delegate volume control to effect in track effect chain if needed
3141 ALOGW("prepareTracks_l(): track %d attached to effect but no chain found on session %d",
3142 name, track->sessionId());
3148 if (track->mFillingUpStatus == Track::FS_FILLED) {
3150 track->mFillingUpStatus = Track::FS_ACTIVE;
3151 if (track->mState == TrackBase::RESUMING) {
3152 track->mState = TrackBase::ACTIVE;
3157 // If the track is stopped before the first frame was mixed,
3162 // compute volume for this track
3164 if (track->isMuted() || track->isPausing() ||
3165 mStreamTypes[track->streamType()].mute) {
3167 if (track->isPausing()) {
3168 track->setPaused();
3173 float typeVolume = mStreamTypes[track->streamType()].volume;
3178 // track volumes come from shared memory, so can't be trusted and must be clamped
3201 // Delegate volume control to effect in track effect chain if needed
3205 track->mHasVolumeController = true;
3209 if (track->mHasVolumeController) {
3212 track->mHasVolumeController = false;
3225 mAudioMixer->setBufferProvider(name, track);
3234 AudioMixer::FORMAT, (void *)track->format());
3238 AudioMixer::CHANNEL_MASK, (void *)track->channelMask());
3247 AudioMixer::MAIN_BUFFER, (void *)track->mainBuffer());
3251 AudioMixer::AUX_BUFFER, (void *)track->auxBuffer());
3254 track->mRetryCount = kMaxTrackRetries;
3256 // If one track is ready, set the mixer ready if:
3258 // - no other track is not ready
3264 // clear effect chain input buffer if an active track underruns to avoid sending
3266 chain = getEffectChain_l(track->sessionId());
3271 //ALOGV("track %d u=%08x, s=%08x [NOT READY] on thread %p", name, cblk->user, cblk->server, this);
3272 if ((track->sharedBuffer() != 0) || track->isTerminated() ||
3273 track->isStopped() || track->isPaused()) {
3274 // We have consumed all the buffers of this track.
3281 if (mStandby || track->presentationComplete(framesWritten, audioHALFrames)) {
3282 if (track->isStopped()) {
3283 track->reset();
3285 tracksToRemove->add(track);
3288 track->mUnderrunCount++;
3289 // No buffers for this track. Give it a few chances to
3291 if (--(track->mRetryCount) <= 0) {
3293 tracksToRemove->add(track);
3294 // indicate to client process that the track was disabled because of underrun;
3297 // If one track is not ready, mark the mixer also not ready if:
3299 // - no other track is ready
3351 Track* track = t.get();
3352 ALOG_ASSERT(track->isFastTrack() && track->isStopped());
3353 track->reset();
3360 const sp<Track>& track = tracksToRemove->itemAt(i);
3361 mActiveTracks.remove(track);
3362 if (track->mainBuffer() != mMixBuffer) {
3363 chain = getEffectChain_l(track->sessionId());
3365 ALOGV("stopping track on chain %p for session Id: %d", chain.get(), track->sessionId());
3369 if (track->isTerminated()) {
3370 removeTrack_l(track);
3377 // mix buffer and track effects will accumulate into it
3442 ALOGV("remove track (%d) and delete from mixer", name);
3491 // do not accept frame count changes if tracks are open as the track buffer
3493 // if frame count is changed after track creation
3552 // limit track sample rate to 2 x new output sample rate
3717 // The track died recently
3720 Track* const track = t.get();
3721 audio_track_cblk_t* cblk = track->cblk();
3723 // The first time a track is added we wait
3726 if ((track->sharedBuffer() == 0) && !track->isStopped() && !track->isPausing()) {
3731 if ((track->framesReady() >= minFrames) && track->isReady() &&
3732 !track->isPaused() && !track->isTerminated())
3734 //ALOGV("track %d u=%08x, s=%08x [OK]", track->name(), cblk->user, cblk->server);
3736 if (track->mFillingUpStatus == Track::FS_FILLED) {
3737 track->mFillingUpStatus = Track::FS_ACTIVE;
3739 if (track->mState == TrackBase::RESUMING) {
3740 track->mState = TrackBase::ACTIVE;
3744 // compute volume for this track
3746 if (track->isMuted() || mMasterMute || track->isPausing() ||
3747 mStreamTypes[track->streamType()].mute) {
3749 if (track->isPausing()) {
3750 track->setPaused();
3753 float typeVolume = mStreamTypes[track->streamType()].volume;
3772 // Delegate volume control to effect in track effect chain if needed
3774 // there is one, the track is connected to it
3785 track->mRetryCount = kMaxTrackRetriesDirect;
3789 // clear effect chain input buffer if an active track underruns to avoid sending
3795 //ALOGV("track %d u=%08x, s=%08x [NOT READY]", track->name(), cblk->user, cblk->server);
3796 if ((track->sharedBuffer() != 0) || track->isTerminated() ||
3797 track->isStopped() || track->isPaused()) {
3798 // We have consumed all the buffers of this track.
3804 if (mStandby || track->presentationComplete(framesWritten, audioHALFrames)) {
3805 if (track->isStopped()) {
3806 track->reset();
3808 trackToRemove = track;
3811 // No buffers for this track. Give it a few chances to
3813 if (--(track->mRetryCount) <= 0) {
3814 ALOGV("BUFFER TIMEOUT: remove(%d) from active list", track->name());
3815 trackToRemove = track;
3829 ALOGV("stopping track on chain %p for session Id: %d", mEffectChains[0].get(),
3903 // do not accept frame count changes if tracks are open as the track buffer
3905 // if frame count is changed after track creation
4071 ALOGV("addOutputTrack() track %p, on thread %p", outputTrack, thread);
4111 ALOGW("DuplicatingThread::outputsReady() could not promote thread on output track %p", outputTracks[i].get());
4117 ALOGV("DuplicatingThread output track %p on thread %p Not Ready", outputTracks[i].get(), thread.get());
4166 // ALOGD("Creating track with %d buffers @ %d bytes", bufferCount, bufferSize);
4294 // Check validity of returned pointer in case the track control block would have been corrupted.
4345 // to avoid leaking a track name, do not allocate one unless there is an mCblk
4349 ALOGE("no more track names available");
4352 // only allocate a fast track index if we were able to allocate a normal track name
4358 // FIXME This is too eager. We allocate a fast track index before the
4359 // fast track becomes active. Since fast tracks are a scarce resource,
4396 // to track the speaker usage
4544 ALOGV("getNextBuffer() no more data for track %d on thread %p", mName, mThread.unsafe_get());
4584 // here the track could be either new, or restarted
4585 // in both cases "unstop" the track
4600 // to track the speaker usage
4627 // If the track is not active (PAUSED and buffers full), flush buffers
4647 // to track the speaker usage
4669 // to track the speaker usage
4690 // do not reset the track if it is still in the process of being stopped or paused.
4691 // this will be done by prepareTracks_l() when the track is stopped.
4693 // remove from active track list, reset(), and trigger presentation complete
4704 // the audioflinger thread detects the track is stopped.
4782 // a track is considered presented when the total number of frames written to audio HAL
4819 // track volumes come from shared memory, so can't be trusted and must be clamped
5197 // if this is the first buffer of audio that we're emitting from this track
5512 ALOGW("Error creating output track on thread %p", playbackThread);
5641 // If no more buffers are pending, fill output track buffer to make sure it is started
5749 // Reserve one of the limited slots for a timed audio track associated
5758 ALOGW("can not create timed track - pid %d has exceeded the limit",
5767 // Release a slot for a timed audio track
5795 AudioFlinger::TrackHandle::TrackHandle(const sp<AudioFlinger::PlaybackThread::Track>& track)
5797 mTrack(track)
5802 // just stop the track on deletion, associated resources
5804 // been played. Unless it's not in the active track list, in which
5924 // create new record track. The record track uses one track in mHardwareMixerThread by convention.
6252 sp<RecordTrack> track;
6266 track = new RecordTrack(this, client, sampleRate,
6269 if (track->getCblk() == 0) {
6273 mTracks.add(track);
6287 return track;
6306 // Sync event can be cancelled by the trigger session if the track is not in a
6432 sp<RecordTrack> track = mTracks[i];
6433 if (eventSession == track->sessionId()) {
6434 (void) track->setSyncEvent(event);
6463 void AudioFlinger::RecordThread::destroyTrack_l(const sp<RecordTrack>& track)
6465 track->mState = TrackBase::TERMINATED;
6467 if (mActiveTrack != track) {
6468 removeTrack_l(track);
6472 void AudioFlinger::RecordThread::removeTrack_l(const sp<RecordTrack>& track)
6474 mTracks.remove(track);
6524 sp<RecordTrack> track = mTracks[i];
6525 if (track != 0) {
6526 track->dump(buffer, SIZE);
6614 // do not accept frame count changes if tracks are open as the track buffer
6616 // if frame count is changed after track creation
6643 sp<RecordTrack> track = mTracks[i];
6644 setEffectSuspended_l(FX_IID_AEC, suspend, track->sessionId());
6645 setEffectSuspended_l(FX_IID_NS, suspend, track->sessionId());
6807 sp<RecordThread::RecordTrack> track = mTracks[j];
6808 int sessionId = track->sessionId();
7617 // thread when a track with the same session ID is created
8004 sp<Track> track = mTracks[i];
8005 if (session == track->sessionId()) {
8006 ALOGV("addEffectChain_l() track->setMainBuffer track %p buffer %p", track.get(), buffer);
8007 track->setMainBuffer(buffer);
8014 sp<Track> track = mActiveTracks[i].promote();
8015 if (track == 0) continue;
8016 if (session == track->sessionId()) {
8017 ALOGV("addEffectChain_l() activating track %p on session %d", track.get(), session);
8029 // after track specific effects and before output stage
8057 sp<Track> track = mActiveTracks[i].promote();
8058 if (track == 0) continue;
8059 if (session == track->sessionId()) {
8060 ALOGV("removeEffectChain_l(): stopping track on chain %p for session Id: %d",
8068 sp<Track> track = mTracks[i];
8069 if (session == track->sessionId()) {
8070 track->setMainBuffer(mMixBuffer);
8081 const sp<AudioFlinger::PlaybackThread::Track> track, int EffectId)
8084 return attachAuxEffect_l(track, EffectId);
8088 const sp<AudioFlinger::PlaybackThread::Track> track, int EffectId)
8093 track->setAuxBuffer(0, NULL);
8099 track->setAuxBuffer(EffectId, (int32_t *)effect->inBuffer());
8113 sp<Track> track = mTracks[i];
8114 if (track->auxEffectId() == effectId) {
8115 attachAuxEffect_l(track, 0);
8413 // TODO: handle configuration of effects replacing track process
9285 // if no track is active and the effect tail has not been rendered,
9339 // after track and auxiliary effects.