Lines Matching refs:thread

115 // allow less retry attempts on direct output thread.
132 // minimum sleep time for the mixer thread loop when tracks are active but in underrun
134 // maximum divider applied to the active sleep time in the mixer thread loop
471 PlaybackThread *thread = checkPlaybackThread_l(output);
473 if (thread == NULL) {
474 ALOGE("unknown output thread");
484 // output thread and move it here.
505 track = thread->createTrack_l(client, streamType, sampleRate, format,
508 // move effect chain to this output thread if an effect on same session was waiting
511 Mutex::Autolock _dl(thread->mLock);
513 moveEffectChain_l(lSessionId, effectThread, thread, true);
519 if (thread->isValidSyncEvent(mPendingSyncEvents[i])) {
550 PlaybackThread *thread = checkPlaybackThread_l(output);
551 if (thread == NULL) {
552 ALOGW("sampleRate() unknown thread %d", output);
555 return thread->sampleRate();
561 PlaybackThread *thread = checkPlaybackThread_l(output);
562 if (thread == NULL) {
563 ALOGW("channelCount() unknown thread %d", output);
566 return thread->channelCount();
572 PlaybackThread *thread = checkPlaybackThread_l(output);
573 if (thread == NULL) {
574 ALOGW("format() unknown thread %d", output);
577 return thread->format();
583 PlaybackThread *thread = checkPlaybackThread_l(output);
584 if (thread == NULL) {
585 ALOGW("frameCount() unknown thread %d", output);
590 return thread->frameCount();
596 PlaybackThread *thread = checkPlaybackThread_l(output);
597 if (thread == NULL) {
598 ALOGW("latency() unknown thread %d", output);
601 return thread->latency();
631 // Now set the master volume in each playback thread. Playback threads
738 // Now set the master mute in each playback thread. Playback threads
784 PlaybackThread *thread = NULL;
786 thread = checkPlaybackThread_l(output);
787 if (thread == NULL) {
794 if (thread == NULL) {
799 thread->setStreamVolume(stream, value);
835 PlaybackThread *thread = checkPlaybackThread_l(output);
836 if (thread == NULL) {
839 volume = thread->streamVolume(stream);
887 sp<RecordThread> thread = mRecordThreads.valueAt(i);
888 audio_devices_t device = thread->inDevice();
890 // collect all of the thread's session IDs
891 KeyedVector<int, bool> ids = thread->sessionIds();
895 thread->setEffectSuspended(FX_IID_AEC,
898 thread->setEffectSuspended(FX_IID_NS,
916 // hold a strong ref on thread in case closeOutput() or closeInput() is called
917 // and the thread is exited once the lock is released
918 sp<ThreadBase> thread;
921 thread = checkPlaybackThread_l(ioHandle);
922 if (thread == 0) {
923 thread = checkRecordThread_l(ioHandle);
924 } else if (thread == primaryPlaybackThread_l()) {
936 if (thread != 0) {
937 return thread->setParameters(keyValuePairs);
1122 sp<PlaybackThread> thread;
1126 ALOG_ASSERT(thread == 0);
1127 thread = mPlaybackThreads.valueAt(i);
1131 return thread;
1169 // This lock prevents the following race in thread (uniprocessor for illustration):
1176 // // now thread is hung
1196 // wait condition with timeout in case the thread loop has exited
1275 snprintf(buffer, SIZE, "thread %p maybe dead locked\n", this);
1398 sp<ThreadBase> thread = mThread.promote();
1399 if (thread != 0) {
1400 thread->clearPowerManager();
1612 result.appendFormat("Output thread %p stream volumes in dB:\n ", this);
1627 snprintf(buffer, SIZE, "Output thread %p tracks\n", this);
1638 snprintf(buffer, SIZE, "Output thread %p active tracks\n", this);
1662 snprintf(buffer, SIZE, "\nOutput thread %p internals\n", this);
1687 ALOGI("AudioFlinger's thread %p ready to run", this);
2028 ALOGV("PlaybackThread::audioConfigChanged_l, thread %p, event %d, param %d", this, event, param);
2200 // this method must always be called either with ThreadBase mLock held or inside the thread loop
2302 // This pipe depth compensates for scheduling latency of the normal mixer thread.
2412 // Though the fast mixer thread has exited, it's state queue is still valid.
2439 ThreadCpuUsage mCpuUsage; // instantaneous thread CPU usage in wall clock ns
2440 CentralTendencyStatistics mWcStats; // statistics on thread CPU usage in wall clock ns
2442 CentralTendencyStatistics mHzStats; // statistics on thread CPU usage in cycles
2444 int mCpuNum; // thread's current CPU number
2445 int mCpukHz; // frequency of thread's current CPU in kHz
2458 // get current thread's delta CPU time in wall clock ns
2569 const String8 myName(String8::format("thread %p type %d TID %d", this, mType, gettid()));
2677 ALOGW("write blocked for %llu msecs, %d delayed writes, thread %p",
2796 // Direct output thread.
3128 //ALOGV("track %d u=%08x, s=%08x [OK] on thread %p", name, cblk->user, cblk->server, this);
3271 //ALOGV("track %d u=%08x, s=%08x [NOT READY] on thread %p", name, cblk->user, cblk->server, this);
3292 ALOGV("BUFFER TIMEOUT: remove(%d) from active list on thread %p", name, this);
3565 // wait for condition with time out in case the thread calling ThreadBase::setParameters()
3932 // wait for condition with time out in case the thread calling ThreadBase::setParameters()
4057 void AudioFlinger::DuplicatingThread::addOutputTrack(MixerThread *thread)
4061 int frameCount = (3 * mNormalFrameCount * mSampleRate) / thread->sampleRate();
4062 OutputTrack *outputTrack = new OutputTrack(thread,
4069 thread->setStreamVolume(AUDIO_STREAM_CNT, 1.0f);
4071 ALOGV("addOutputTrack() track %p, on thread %p", outputTrack, thread);
4076 void AudioFlinger::DuplicatingThread::removeOutputTrack(MixerThread *thread)
4080 if (mOutputTracks[i]->thread() == thread) {
4087 ALOGV("removeOutputTrack(): unkonwn thread: %p", thread);
4095 sp<ThreadBase> strong = mOutputTracks[i]->thread().promote();
4109 sp<ThreadBase> thread = outputTracks[i]->thread().promote();
4110 if (thread == 0) {
4111 ALOGW("DuplicatingThread::outputsReady() could not promote thread on output track %p", outputTracks[i].get());
4114 PlaybackThread *playbackThread = (PlaybackThread *)thread.get();
4117 ALOGV("DuplicatingThread output track %p on thread %p Not Ready", outputTracks[i].get(), thread.get());
4141 ThreadBase *thread,
4150 mThread(thread),
4315 PlaybackThread *thread,
4325 : TrackBase(thread, client, sampleRate, format, channelMask, frameCount, sharedBuffer, sessionId),
4332 mMainBuffer(thread->mixBuffer()),
4346 mName = thread->getTrackName_l(channelMask, sessionId);
4355 ALOG_ASSERT(thread->mFastTrackAvailMask != 0);
4356 int i = __builtin_ctz(thread->mFastTrackAvailMask);
4365 mObservedUnderruns = thread->getFastTrackUnderruns(i);
4366 thread->mFastTrackAvailMask &= ~(1 << i);
4389 sp<ThreadBase> thread = mThread.promote();
4390 if (thread != 0) {
4393 AudioSystem::stopOutput(thread->id(), mStreamType, mSessionId);
4400 AudioSystem::releaseOutput(thread->id());
4402 Mutex::Autolock _l(thread->mLock);
4403 PlaybackThread *playbackThread = (PlaybackThread *)thread.get();
4510 // Since the fast mixer is higher priority than client callback thread,
4544 ALOGV("getNextBuffer() no more data for track %d on thread %p", mName, mThread.unsafe_get());
4550 // as the normal mixer thread runs at lower
4551 // priority than the client's callback thread: there is a short window within framesReady()
4580 sp<ThreadBase> thread = mThread.promote();
4581 if (thread != 0) {
4582 Mutex::Autolock _l(thread->mLock);
4588 ALOGV("PAUSED => RESUMING (%d) on thread %p", mName, this);
4591 ALOGV("? => ACTIVE (%d) on thread %p", mName, this);
4595 thread->mLock.unlock();
4596 status = AudioSystem::startOutput(thread->id(), mStreamType, mSessionId);
4597 thread->mLock.lock();
4607 PlaybackThread *playbackThread = (PlaybackThread *)thread.get();
4622 sp<ThreadBase> thread = mThread.promote();
4623 if (thread != 0) {
4624 Mutex::Autolock _l(thread->mLock);
4628 PlaybackThread *playbackThread = (PlaybackThread *)thread.get();
4639 ALOGV("not stopping/stopped => stopping/stopped (%d) on thread %p", mName, playbackThread);
4642 thread->mLock.unlock();
4643 AudioSystem::stopOutput(thread->id(), mStreamType, mSessionId);
4644 thread->mLock.lock();
4657 sp<ThreadBase> thread = mThread.promote();
4658 if (thread != 0) {
4659 Mutex::Autolock _l(thread->mLock);
4662 ALOGV("ACTIVE/RESUMING => PAUSING (%d) on thread %p", mName, thread.get());
4664 thread->mLock.unlock();
4665 AudioSystem::stopOutput(thread->id(), mStreamType, mSessionId);
4666 thread->mLock.lock();
4680 sp<ThreadBase> thread = mThread.promote();
4681 if (thread != 0) {
4682 Mutex::Autolock _l(thread->mLock);
4694 PlaybackThread *playbackThread = (PlaybackThread *)thread.get();
4704 // the audioflinger thread detects the track is stopped.
4727 sp<ThreadBase> thread = mThread.promote();
4728 if (thread != 0) {
4729 PlaybackThread *playbackThread = (PlaybackThread *)thread.get();
4855 PlaybackThread *thread,
4868 thread, client, streamType, sampleRate, format, channelMask, frameCount,
4873 PlaybackThread *thread,
4882 : Track(thread, client, streamType, sampleRate, format, channelMask,
5369 RecordThread *thread,
5376 : TrackBase(thread, client, sampleRate, format,
5438 sp<ThreadBase> thread = mThread.promote();
5439 if (thread != 0) {
5440 RecordThread *recordThread = (RecordThread *)thread.get();
5449 sp<ThreadBase> thread = mThread.promote();
5450 if (thread != 0) {
5451 RecordThread *recordThread = (RecordThread *)thread.get();
5512 ALOGW("Error creating output track on thread %p", playbackThread);
5555 sp<ThreadBase> thread = mThread.promote();
5556 if (thread != 0) {
5557 MixerThread *mixerThread = (MixerThread *)thread.get();
5590 ALOGV ("OutputTrack::write() %p thread %p no more output buffers", this, mThread.unsafe_get());
5615 ALOGV("OutputTrack::write() %p thread %p released overflow buffer %d", this, mThread.unsafe_get(), mBufferQueue.size());
5624 sp<ThreadBase> thread = mThread.promote();
5625 if (thread != 0 && !thread->standby()) {
5633 ALOGV("OutputTrack::write() %p thread %p adding overflow buffer %d", this, mThread.unsafe_get(), mBufferQueue.size());
5635 ALOGW("OutputTrack::write() %p thread %p no more overflow buffers", mThread.unsafe_get(), this);
5803 // will be freed from the main thread once all pending buffers have
5894 RecordThread *thread;
5907 thread = checkRecordThread_l(input);
5908 if (thread == NULL) {
5925 recordTrack = thread->createRecordTrack_l(client, sampleRate, format, channelMask,
6343 // signal thread to start
6344 ALOGV("Signal record thread");
6449 sp<ThreadBase> thread = mThread.promote();
6450 if (thread != 0) {
6452 AudioSystem::stopInput(thread->id());
6454 AudioSystem::releaseInput(thread->id());
6455 Mutex::Autolock _l(thread->mLock);
6456 RecordThread *recordThread = (RecordThread *) thread.get();
6491 snprintf(buffer, SIZE, "\nInput thread %p internals\n", this);
6520 snprintf(buffer, SIZE, "Input thread %p tracks\n", this);
6532 snprintf(buffer, SIZE, "\nInput thread %p active tracks\n", this);
6686 // wait for condition with time out in case the thread calling ThreadBase::setParameters()
6824 // this method must always be called either with ThreadBase mLock held or inside the thread loop
6930 PlaybackThread *thread = primaryPlaybackThread_l();
6931 return thread != NULL ? thread->sampleRate() : 0;
6937 PlaybackThread *thread = primaryPlaybackThread_l();
6938 return thread != NULL ? thread->frameCountHAL() : 0;
6952 PlaybackThread *thread = NULL;
7005 thread = new DirectOutputThread(this, output, id, *pDevices);
7006 ALOGV("openOutput() created direct output: ID %d thread %p", id, thread);
7008 thread = new MixerThread(this, output, id, *pDevices);
7009 ALOGV("openOutput() created mixer output: ID %d thread %p", id, thread);
7011 mPlaybackThreads.add(id, thread);
7016 if (pLatencyMs != NULL) *pLatencyMs = thread->latency();
7019 thread->audioConfigChanged_l(AudioSystem::OUTPUT_OPENED);
7050 DuplicatingThread *thread = new DuplicatingThread(this, thread1, id);
7051 thread->addOutputTrack(thread2);
7052 mPlaybackThreads.add(id, thread);
7054 thread->audioConfigChanged_l(AudioSystem::OUTPUT_OPENED);
7065 // keep strong reference on the playback thread so that
7067 sp<PlaybackThread> thread;
7070 thread = checkPlaybackThread_l(output);
7071 if (thread == NULL) {
7077 if (thread->type() == ThreadBase::MIXER) {
7081 dupThread->removeOutputTrack((MixerThread *)thread.get());
7088 thread->exit();
7089 // The thread entity (active unit of execution) is no longer running here,
7092 if (thread->type() != ThreadBase::DUPLICATING) {
7093 AudioStreamOut *out = thread->clearOutput();
7095 // from now on thread->mOutput is NULL
7105 PlaybackThread *thread = checkPlaybackThread_l(output);
7107 if (thread == NULL) {
7112 thread->suspend();
7120 PlaybackThread *thread = checkPlaybackThread_l(output);
7122 if (thread == NULL) {
7128 thread->restore();
7140 RecordThread *thread = NULL;
7189 // Start record thread
7193 thread = new RecordThread(this,
7199 mRecordThreads.add(id, thread);
7200 ALOGV("openInput() created record thread: ID %d thread %p", id, thread);
7206 thread->audioConfigChanged_l(AudioSystem::INPUT_OPENED);
7220 // keep strong reference on the record thread so that
7222 sp<RecordThread> thread;
7225 thread = checkRecordThread_l(input);
7226 if (thread == 0) {
7234 thread->exit();
7235 // The thread entity (active unit of execution) is no longer running here,
7238 AudioStreamIn *in = thread->clearInput();
7240 // from now on thread->mInput is NULL
7253 PlaybackThread *thread = mPlaybackThreads.valueAt(i).get();
7254 thread->invalidateTracks(stream);
7373 PlaybackThread *thread = checkPlaybackThread_l(output);
7374 return thread != NULL && thread->type() != ThreadBase::DIRECT ? (MixerThread *) thread : NULL;
7391 PlaybackThread *thread = mPlaybackThreads.valueAt(i).get();
7392 AudioStreamOut *output = thread->getOutput();
7394 return thread;
7402 PlaybackThread *thread = primaryPlaybackThread_l();
7404 if (thread == NULL) {
7408 return thread->outDevice();
7600 // look for the thread where the specified audio session is present
7615 // If no output thread contains the requested session ID, default to
7617 // thread when a track with the same session ID is created
7623 ThreadBase *thread = checkRecordThread_l(io);
7624 if (thread == NULL) {
7625 thread = checkPlaybackThread_l(io);
7626 if (thread == NULL) {
7627 ALOGE("createEffect() unknown output thread");
7635 // create effect on selected output thread
7636 handle = thread->createEffect_l(client, effectClient, priority, sessionId,
7684 ALOGV("moveEffectChain_l() session %d from thread %p to thread %p",
7689 ALOGW("moveEffectChain_l() effect chain for session %d not on source thread %p",
7694 // remove chain first. This is useful only if reconfiguring effect chain on same output thread,
7700 // transfer all effects one by one so that new effect chain is created on new thread with
7775 ALOGW("createEffect_l() effect %s (flags %08x) created on wrong thread type %d",
7781 ALOGV("createEffect_l() thread %p effect %s on session %d", this, desc->name, sessionId);
7990 ALOGV("addEffectChain_l() %p on thread %p for session %d", chain.get(), this, session);
7992 // Only one effect chain can be present in direct output thread and it uses
8050 ALOGV("removeEffectChain_l() %p from thread %p for session %d", chain.get(), this, session);
8122 // only one chain per input thread
8126 ALOGV("addEffectChain_l() %p on thread %p", chain.get(), this);
8140 ALOGV("removeEffectChain_l() %p from thread %p", chain.get(), this);
8142 "removeEffectChain_l() %p invalid chain size %d on thread %p",
8157 AudioFlinger::EffectModule::EffectModule(ThreadBase *thread,
8163 mThread(thread), mChain(chain), mId(id), mSessionId(sessionId),
8176 mStatus = EffectCreate(&desc->uuid, sessionId, thread->id(), &mEffectInterface);
8201 sp<ThreadBase> thread = mThread.promote();
8202 if (thread != 0) {
8203 audio_stream_t *stream = thread->stream();
8301 sp<ThreadBase> thread = mThread.promote();
8302 if (thread != 0) {
8303 thread->disconnectEffect(keep, handle, unpinIfLast);
8408 sp<ThreadBase> thread = mThread.promote();
8409 if (thread == 0) {
8414 audio_channel_mask_t channelMask = thread->channelMask();
8424 mConfig.inputCfg.samplingRate = thread->sampleRate();
8449 mConfig.inputCfg.buffer.frameCount = thread->frameCount();
8452 ALOGV("configure() %p thread %p buffer %p framecount %d",
8453 this, thread.get(), mConfig.inputCfg.buffer.raw, mConfig.inputCfg.buffer.frameCount);
8478 PlaybackThread *pbt = thread->mAudioFlinger->checkPlaybackThread_l(thread->mId);
8543 sp<ThreadBase> thread = mThread.promote();
8544 if (thread != 0) {
8545 audio_stream_t *stream = thread->stream();
8579 sp<ThreadBase> thread = mThread.promote();
8580 if (thread != 0) {
8581 audio_stream_t *stream = thread->stream();
8968 sp<ThreadBase> thread = mEffect->thread().promote();
8969 if (thread != 0) {
8970 thread->checkSuspendOnEffectEnabled(mEffect, true, mEffect->sessionId());
8980 if (thread != 0) {
8981 thread->checkSuspendOnEffectEnabled(mEffect, false, mEffect->sessionId());
9005 sp<ThreadBase> thread = mEffect->thread().promote();
9006 if (thread != 0) {
9007 thread->checkSuspendOnEffectEnabled(mEffect, false, mEffect->sessionId());
9026 sp<ThreadBase> thread = mEffect->thread().promote();
9027 if (thread != 0) {
9028 thread->checkSuspendOnEffectEnabled(mEffect, false, mEffect->sessionId());
9064 // No need to trylock() here as this function is executed in the binder thread serving a particular client process:
9182 AudioFlinger::EffectChain::EffectChain(ThreadBase *thread,
9184 : mThread(thread), mSessionId(sessionId), mActiveTrackCnt(0), mTrackCnt(0), mTailBufferCount(0),
9189 if (thread == NULL) {
9192 mMaxTailBuffers = ((kProcessTailDurationMs * thread->sampleRate()) / 1000) /
9193 thread->frameCount();
9248 sp<ThreadBase> thread = mThread.promote();
9249 if (thread == 0) {
9250 ALOGW("clearInputBuffer(): cannot promote mixer thread");
9253 clearInputBuffer_l(thread);
9257 void AudioFlinger::EffectChain::clearInputBuffer_l(sp<ThreadBase> thread)
9259 size_t numSamples = thread->frameCount() * thread->channelCount();
9267 sp<ThreadBase> thread = mThread.promote();
9268 if (thread == 0) {
9269 ALOGW("process_l(): cannot promote mixer thread");
9288 clearInputBuffer_l(thread);
9315 sp<ThreadBase> thread = mThread.promote();
9316 if (thread == 0) {
9319 effect->setThread(thread);
9330 size_t numSamples = thread->frameCount();