Lines Matching refs:track

157     FastMixer_Dynamic,  // initialize if needed, then use dynamically depending on track load,
452 sp<PlaybackThread::Track> track;
502 track = thread->createTrack_l(client, streamType, sampleRate, format,
506 // for a track to be created
518 track->setSyncEvent(mPendingSyncEvents[i]);
529 trackHandle = new TrackHandle(track);
534 track.clear();
879 RecordThread::RecordTrack *track = thread->track();
880 if (track != NULL) {
886 track->sessionId());
889 track->sessionId());
1585 sp<Track> track = mTracks[i];
1586 if (track != 0) {
1587 track->dump(buffer, SIZE);
1596 sp<Track> track = mActiveTracks[i].promote();
1597 if (track != 0) {
1598 track->dump(buffer, SIZE);
1633 fdprintf(fd, "Fast track availMask=%#x\n", mFastTrackAvailMask);
1671 sp<Track> track;
1705 // there are sufficient fast track slots available
1707 // FIXME test that MixerThread for this fast track has a capable output HAL
1786 track = new Track(this, client, streamType, sampleRate, format,
1789 track = TimedTrack::create(this, client, streamType, sampleRate, format,
1792 if (track == NULL || track->getCblk() == NULL || track->name() < 0) {
1796 mTracks.add(track);
1801 track->setMainBuffer(chain->inBuffer());
1802 chain->setStrategy(AudioSystem::getStrategyForStream(track->streamType()));
1826 return track;
1888 status_t AudioFlinger::PlaybackThread::addTrack_l(const sp<Track>& track)
1893 track->mRetryCount = kMaxTrackStartupRetries;
1894 if (mActiveTracks.indexOf(track) < 0) {
1895 // the track is newly added, make sure it fills up all its
1898 track->mFillingUpStatus = Track::FS_FILLING;
1899 track->mResetDone = false;
1900 track->mPresentationCompleteFrames = 0;
1901 mActiveTracks.add(track);
1902 if (track->mainBuffer() != mMixBuffer) {
1903 sp<EffectChain> chain = getEffectChain_l(track->sessionId());
1905 ALOGV("addTrack_l() starting track on chain %p for session %d", chain.get(), track->sessionId());
1920 void AudioFlinger::PlaybackThread::destroyTrack_l(const sp<Track>& track)
1922 track->mState = TrackBase::TERMINATED;
1924 if (mActiveTracks.indexOf(track) < 0) {
1925 removeTrack_l(track);
1929 void AudioFlinger::PlaybackThread::removeTrack_l(const sp<Track>& track)
1931 track->triggerEvents(AudioSystem::SYNC_EVENT_PRESENTATION_COMPLETE);
1932 mTracks.remove(track);
1933 deleteTrackName_l(track->name());
1934 // redundant as track is about to be destroyed, for dumpsys only
1935 track->mName = -1;
1936 if (track->isFastTrack()) {
1937 int index = track->mFastIndex;
1941 // redundant as track is about to be destroyed, for dumpsys only
1942 track->mFastIndex = -1;
1944 sp<EffectChain> chain = getEffectChain_l(track->sessionId());
2029 // track, but we sometimes have to do this to satisfy the maximum frame count constraint)
2085 sp<Track> track = mTracks[i];
2086 if (sessionId == track->sessionId() &&
2087 !(track->mCblk->flags & CBLK_INVALID_MSK)) {
2104 sp<Track> track = mTracks[i];
2105 if (sessionId == track->sessionId() &&
2106 !(track->mCblk->flags & CBLK_INVALID_MSK)) {
2107 return AudioSystem::getStrategyForStream(track->streamType());
2156 sp<Track> track = mTracks[i];
2157 if (event->triggerSession() == track->sessionId()) {
2158 track->setSyncEvent(event);
2182 const sp<Track>& track = tracksToRemove.itemAt(i);
2183 if ((track->sharedBuffer() != 0) &&
2184 (track->mState == TrackBase::ACTIVE || track->mState == TrackBase::RESUMING)) {
2185 AudioSystem::stopOutput(mId, track->streamType(), track->sessionId());
2277 // create fast mixer and configure it initially with just one fast track for our submix
2364 // We'll use that extract the final state which contains one remaining fast track
2651 // Finally let go of removed track(s), without the lock held
2903 Track* const track = t.get();
2906 if (track->isFastTrack()) {
2908 // It's theoretically possible (though unlikely) for a fast track to be created
2910 // the track never becomes active so it's fast mixer slot is never touched.
2911 // The converse, of removing an (active) track and then creating a new track
2914 int j = track->mFastIndex;
2919 // Determine whether the track is currently in underrun condition,
2924 track->mObservedUnderruns.mBitFields.mFull) & UNDERRUN_MASK;
2926 track->mObservedUnderruns.mBitFields.mPartial) & UNDERRUN_MASK;
2928 track->mObservedUnderruns.mBitFields.mEmpty) & UNDERRUN_MASK;
2930 track->mObservedUnderruns = underruns;
2933 if (!(track->isStopping() || track->isPausing() || track->isStopped())) {
2934 track->mUnderrunCount += recentUnderruns;
2940 switch (track->mState) {
2942 // track stays active in STOPPING_1 state until first underrun
2944 track->mState = TrackBase::STOPPING_2;
2949 track->setPaused();
2953 track->mState = TrackBase::ACTIVE;
2957 // track has provided at least some frames recently: reset retry count
2958 track->mRetryCount = kMaxTrackRetries;
2965 if (track->sharedBuffer() == 0) {
2972 if (--(track->mRetryCount) > 0) {
2975 // indicate to client process that the track was disabled because of underrun;
2977 android_atomic_or(CBLK_DISABLED_ON, &track->mCblk->flags);
2988 // Check for presentation complete if track is inactive
2989 // We have consumed all the buffers of this track.
2996 if (!track->presentationComplete(framesWritten, audioHALFrames)) {
2997 // track stays in active list until presentation is complete
3001 if (track->isStopping_2()) {
3002 track->mState = TrackBase::STOPPED;
3004 if (track->isStopped()) {
3005 // Can't reset directly, as fast mixer is still polling this track
3006 // track->reset();
3007 // So instead mark this track as needing to be reset after push with ack
3014 LOG_FATAL("unexpected track state %d", track->mState);
3020 ExtendedAudioBufferProvider *eabp = track;
3021 VolumeProvider *vp = track;
3024 fastTrack->mSampleRate = track->mSampleRate;
3025 fastTrack->mChannelMask = track->mChannelMask;
3033 track->mCachedVolume = track->isMuted() ?
3034 0 : masterVolume * mStreamTypes[track->streamType()].volume;
3047 LOG_FATAL("fast track %d should have been active", j);
3049 tracksToRemove->add(track);
3051 track->mObservedUnderruns.mBitFields.mMostRecent = UNDERRUN_FULL;
3058 audio_track_cblk_t* cblk = track->cblk();
3060 // The first time a track is added we wait
3062 int name = track->name();
3066 // hence the test on (mMixerStatus == MIXER_TRACKS_READY) meaning the track was mixed
3069 if ((track->sharedBuffer() == 0) && !track->isStopped() && !track->isPausing() &&
3078 minFrames += mAudioMixer->getUnreleasedFrames(track->name());
3079 // the minimum track buffer size is normally twice the number of frames necessary
3085 if ((track->framesReady() >= minFrames) && track->isReady() &&
3086 !track->isPaused() && !track->isTerminated())
3088 //ALOGV("track %d u=%08x, s=%08x [OK] on thread %p", name, cblk->user, cblk->server, this);
3092 // track->mainBuffer() != mMixBuffer means there is an effect chain
3093 // connected to the track
3095 if (track->mainBuffer() != mMixBuffer) {
3096 chain = getEffectChain_l(track->sessionId());
3097 // Delegate volume control to effect in track effect chain if needed
3101 ALOGW("prepareTracks_l(): track %d attached to effect but no chain found on session %d",
3102 name, track->sessionId());
3108 if (track->mFillingUpStatus == Track::FS_FILLED) {
3110 track->mFillingUpStatus = Track::FS_ACTIVE;
3111 if (track->mState == TrackBase::RESUMING) {
3112 track->mState = TrackBase::ACTIVE;
3117 // If the track is stopped before the first frame was mixed,
3122 // compute volume for this track
3124 if (track->isMuted() || track->isPausing() ||
3125 mStreamTypes[track->streamType()].mute) {
3127 if (track->isPausing()) {
3128 track->setPaused();
3133 float typeVolume = mStreamTypes[track->streamType()].volume;
3138 // track volumes come from shared memory, so can't be trusted and must be clamped
3161 // Delegate volume control to effect in track effect chain if needed
3165 track->mHasVolumeController = true;
3169 if (track->mHasVolumeController) {
3172 track->mHasVolumeController = false;
3185 mAudioMixer->setBufferProvider(name, track);
3194 AudioMixer::FORMAT, (void *)track->format());
3198 AudioMixer::CHANNEL_MASK, (void *)track->channelMask());
3207 AudioMixer::MAIN_BUFFER, (void *)track->mainBuffer());
3211 AudioMixer::AUX_BUFFER, (void *)track->auxBuffer());
3214 track->mRetryCount = kMaxTrackRetries;
3216 // If one track is ready, set the mixer ready if:
3218 // - no other track is not ready
3224 // clear effect chain input buffer if an active track underruns to avoid sending
3226 chain = getEffectChain_l(track->sessionId());
3231 //ALOGV("track %d u=%08x, s=%08x [NOT READY] on thread %p", name, cblk->user, cblk->server, this);
3232 if ((track->sharedBuffer() != 0) || track->isTerminated() ||
3233 track->isStopped() || track->isPaused()) {
3234 // We have consumed all the buffers of this track.
3242 if (track->presentationComplete(framesWritten, audioHALFrames)) {
3243 if (track->isStopped()) {
3244 track->reset();
3246 tracksToRemove->add(track);
3249 track->mUnderrunCount++;
3250 // No buffers for this track. Give it a few chances to
3252 if (--(track->mRetryCount) <= 0) {
3254 tracksToRemove->add(track);
3255 // indicate to client process that the track was disabled because of underrun;
3258 // If one track is not ready, mark the mixer also not ready if:
3260 // - no other track is ready
3310 Track* track = t.get();
3311 ALOG_ASSERT(track->isFastTrack() && track->isStopped());
3312 track->reset();
3319 const sp<Track>& track = tracksToRemove->itemAt(i);
3320 mActiveTracks.remove(track);
3321 if (track->mainBuffer() != mMixBuffer) {
3322 chain = getEffectChain_l(track->sessionId());
3324 ALOGV("stopping track on chain %p for session Id: %d", chain.get(), track->sessionId());
3328 if (track->isTerminated()) {
3329 removeTrack_l(track);
3336 // mix buffer and track effects will accumulate into it
3401 ALOGV("remove track (%d) and delete from mixer", name);
3450 // do not accept frame count changes if tracks are open as the track buffer
3452 // if frame count is changed after track creation
3511 // limit track sample rate to 2 x new output sample rate
3675 // The track died recently
3678 Track* const track = t.get();
3679 audio_track_cblk_t* cblk = track->cblk();
3681 // The first time a track is added we wait
3684 if ((track->sharedBuffer() == 0) && !track->isStopped() && !track->isPausing()) {
3689 if ((track->framesReady() >= minFrames) && track->isReady() &&
3690 !track->isPaused() && !track->isTerminated())
3692 //ALOGV("track %d u=%08x, s=%08x [OK]", track->name(), cblk->user, cblk->server);
3694 if (track->mFillingUpStatus == Track::FS_FILLED) {
3695 track->mFillingUpStatus = Track::FS_ACTIVE;
3697 if (track->mState == TrackBase::RESUMING) {
3698 track->mState = TrackBase::ACTIVE;
3702 // compute volume for this track
3704 if (track->isMuted() || mMasterMute || track->isPausing() ||
3705 mStreamTypes[track->streamType()].mute) {
3707 if (track->isPausing()) {
3708 track->setPaused();
3711 float typeVolume = mStreamTypes[track->streamType()].volume;
3730 // Delegate volume control to effect in track effect chain if needed
3732 // there is one, the track is connected to it
3743 track->mRetryCount = kMaxTrackRetriesDirect;
3747 // clear effect chain input buffer if an active track underruns to avoid sending
3753 //ALOGV("track %d u=%08x, s=%08x [NOT READY]", track->name(), cblk->user, cblk->server);
3754 if ((track->sharedBuffer() != 0) || track->isTerminated() ||
3755 track->isStopped() || track->isPaused()) {
3756 // We have consumed all the buffers of this track.
3763 if (track->presentationComplete(framesWritten, audioHALFrames)) {
3764 if (track->isStopped()) {
3765 track->reset();
3767 trackToRemove = track;
3770 // No buffers for this track. Give it a few chances to
3772 if (--(track->mRetryCount) <= 0) {
3773 ALOGV("BUFFER TIMEOUT: remove(%d) from active list", track->name());
3774 trackToRemove = track;
3788 ALOGV("stopping track on chain %p for session Id: %d", mEffectChains[0].get(),
3861 // do not accept frame count changes if tracks are open as the track buffer
3863 // if frame count is changed after track creation
4029 ALOGV("addOutputTrack() track %p, on thread %p", outputTrack, thread);
4069 ALOGW("DuplicatingThread::outputsReady() could not promote thread on output track %p", outputTracks[i].get());
4074 ALOGV("DuplicatingThread output track %p on thread %p Not Ready", outputTracks[i].get(), thread.get());
4123 // ALOGD("Creating track with %d buffers @ %d bytes", bufferCount, bufferSize);
4251 // Check validity of returned pointer in case the track control block would have been corrupted.
4302 // to avoid leaking a track name, do not allocate one unless there is an mCblk
4306 ALOGE("no more track names available");
4309 // only allocate a fast track index if we were able to allocate a normal track name
4315 // FIXME This is too eager. We allocate a fast track index before the
4316 // fast track becomes active. Since fast tracks are a scarce resource,
4358 // to track the speaker usage
4508 ALOGV("getNextBuffer() no more data for track %d on thread %p", mName, mThread.unsafe_get());
4548 // here the track could be either new, or restarted
4549 // in both cases "unstop" the track
4564 // to track the speaker usage
4591 // If the track is not active (PAUSED and buffers full), flush buffers
4611 // to track the speaker usage
4633 // to track the speaker usage
4654 // do not reset the track if it is still in the process of being stopped or paused.
4655 // this will be done by prepareTracks_l() when the track is stopped.
4657 // remove from active track list, reset(), and trigger presentation complete
4668 // the audioflinger thread detects the track is stopped.
4746 // a track is considered presented when the total number of frames written to audio HAL
4783 // track volumes come from shared memory, so can't be trusted and must be clamped
5161 // if this is the first buffer of audio that we're emitting from this track
5468 ALOGW("Error creating output track on thread %p", playbackThread);
5597 // If no more buffers are pending, fill output track buffer to make sure it is started
5705 // Reserve one of the limited slots for a timed audio track associated
5714 ALOGW("can not create timed track - pid %d has exceeded the limit",
5723 // Release a slot for a timed audio track
5751 AudioFlinger::TrackHandle::TrackHandle(const sp<AudioFlinger::PlaybackThread::Track>& track)
5753 mTrack(track)
5758 // just stop the track on deletion, associated resources
5760 // been played. Unless it's not in the active track list, in which
5879 // create new record track. The record track uses one track in mHardwareMixerThread by convention.
6199 sp<RecordTrack> track;
6211 track = new RecordTrack(this, client, sampleRate,
6214 if (track->getCblk() == 0) {
6219 mTrack = track.get();
6232 return track;
6251 // Sync event can be cancelled by the trigger session if the track is not in a
6493 // do not accept frame count changes if tracks are open as the track buffer
6495 // if frame count is changed after track creation
6666 AudioFlinger::RecordThread::RecordTrack* AudioFlinger::RecordThread::track()
7464 // thread when a track with the same session ID is created
7847 sp<Track> track = mTracks[i];
7848 if (session == track->sessionId()) {
7849 ALOGV("addEffectChain_l() track->setMainBuffer track %p buffer %p", track.get(), buffer);
7850 track->setMainBuffer(buffer);
7857 sp<Track> track = mActiveTracks[i].promote();
7858 if (track == 0) continue;
7859 if (session == track->sessionId()) {
7860 ALOGV("addEffectChain_l() activating track %p on session %d", track.get(), session);
7872 // after track specific effects and before output stage
7900 sp<Track> track = mActiveTracks[i].promote();
7901 if (track == 0) continue;
7902 if (session == track->sessionId()) {
7903 ALOGV("removeEffectChain_l(): stopping track on chain %p for session Id: %d",
7911 sp<Track> track = mTracks[i];
7912 if (session == track->sessionId()) {
7913 track->setMainBuffer(mMixBuffer);
7924 const sp<AudioFlinger::PlaybackThread::Track> track, int EffectId)
7927 return attachAuxEffect_l(track, EffectId);
7931 const sp<AudioFlinger::PlaybackThread::Track> track, int EffectId)
7936 track->setAuxBuffer(0, NULL);
7942 track->setAuxBuffer(EffectId, (int32_t *)effect->inBuffer());
7956 sp<Track> track = mTracks[i];
7957 if (track->auxEffectId() == effectId) {
7958 attachAuxEffect_l(track, 0);
8253 // TODO: handle configuration of effects replacing track process
9108 // if no track is active and the effect tail has not been rendered,
9162 // after track and auxiliary effects.