summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorEric Laurent <elaurent@google.com>2010-09-28 17:39:54 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2010-09-28 17:39:54 -0700
commit9e2e2d2bc86372bde4673c31ef416b2f29d87ac2 (patch)
tree46608b895445f505be207ec4cfb76f38c79340c2 /services
parentb91d92d7147c10dd19987706d30dea011ff459af (diff)
parent307e7f5295fefe8e21113dabebf434cac0d71e6d (diff)
downloadframeworks_av-9e2e2d2bc86372bde4673c31ef416b2f29d87ac2.zip
frameworks_av-9e2e2d2bc86372bde4673c31ef416b2f29d87ac2.tar.gz
frameworks_av-9e2e2d2bc86372bde4673c31ef416b2f29d87ac2.tar.bz2
am b047e3cd: am aeb2c62e: Merge "Fix several audio effects problems." into gingerbread
Merge commit 'b047e3cdf24b32e26f366fcd4cd0eee8ae6c592c' * commit 'b047e3cdf24b32e26f366fcd4cd0eee8ae6c592c': Fix several audio effects problems.
Diffstat (limited to 'services')
-rw-r--r--services/audioflinger/AudioFlinger.cpp40
1 files changed, 32 insertions, 8 deletions
diff --git a/services/audioflinger/AudioFlinger.cpp b/services/audioflinger/AudioFlinger.cpp
index 8a732ed..97b8086 100644
--- a/services/audioflinger/AudioFlinger.cpp
+++ b/services/audioflinger/AudioFlinger.cpp
@@ -5332,6 +5332,15 @@ size_t AudioFlinger::EffectModule::removeHandle(const wp<EffectHandle>& handle)
}
}
+ // Release effect engine here so that it is done immediately. Otherwise it will be released
+ // by the destructor when the last strong reference on the this object is released which can
+ // happen after next process is called on this effect.
+ if (size == 0 && mEffectInterface != NULL) {
+ // release effect engine
+ EffectRelease(mEffectInterface);
+ mEffectInterface = NULL;
+ }
+
return size;
}
@@ -6145,21 +6154,36 @@ sp<AudioFlinger::EffectModule> AudioFlinger::EffectChain::getEffectFromId_l(int
// Must be called with EffectChain::mLock locked
void AudioFlinger::EffectChain::process_l()
{
+ sp<ThreadBase> thread = mThread.promote();
+ if (thread == 0) {
+ LOGW("process_l(): cannot promote mixer thread");
+ return;
+ }
+ PlaybackThread *playbackThread = (PlaybackThread *)thread.get();
+ bool isGlobalSession = (mSessionId == AudioSystem::SESSION_OUTPUT_MIX) ||
+ (mSessionId == AudioSystem::SESSION_OUTPUT_STAGE);
+ bool tracksOnSession = false;
+ if (!isGlobalSession) {
+ tracksOnSession =
+ playbackThread->hasAudioSession(mSessionId) & PlaybackThread::TRACK_SESSION;
+ }
+
size_t size = mEffects.size();
- for (size_t i = 0; i < size; i++) {
- mEffects[i]->process();
+ // do not process effect if no track is present in same audio session
+ if (isGlobalSession || tracksOnSession) {
+ for (size_t i = 0; i < size; i++) {
+ mEffects[i]->process();
+ }
}
for (size_t i = 0; i < size; i++) {
mEffects[i]->updateState();
}
// if no track is active, input buffer must be cleared here as the mixer process
// will not do it
- if (mSessionId > 0 && activeTracks() == 0) {
- sp<ThreadBase> thread = mThread.promote();
- if (thread != 0) {
- size_t numSamples = thread->frameCount() * thread->channelCount();
- memset(mInBuffer, 0, numSamples * sizeof(int16_t));
- }
+ if (tracksOnSession &&
+ activeTracks() == 0) {
+ size_t numSamples = playbackThread->frameCount() * playbackThread->channelCount();
+ memset(mInBuffer, 0, numSamples * sizeof(int16_t));
}
}