diff options
author | Eric Laurent <elaurent@google.com> | 2013-08-31 12:59:48 -0700 |
---|---|---|
committer | Eric Laurent <elaurent@google.com> | 2013-09-09 09:09:21 -0700 |
commit | 813e2a74853bde19e37d878c596a044b3f299efc (patch) | |
tree | b95aa8b59f49b4348b2112047ee80e572637d706 /services/audioflinger/AudioFlinger.cpp | |
parent | 84b7fb0c88ddd05ed7c148c82fe1691040a9404d (diff) | |
download | frameworks_av-813e2a74853bde19e37d878c596a044b3f299efc.zip frameworks_av-813e2a74853bde19e37d878c596a044b3f299efc.tar.gz frameworks_av-813e2a74853bde19e37d878c596a044b3f299efc.tar.bz2 |
audioflinger: no effects on offloaded tracks
Invalidate offloaded tracks when an effect is enabled
so that the track is recreated in PCM mode and the effect
can be applied.
This is temporary until effect offloading is implemented.
Bug: 8174034.
Change-Id: I77b8b54a10db6cb8334be76d863ea7e720eaad09
Diffstat (limited to 'services/audioflinger/AudioFlinger.cpp')
-rw-r--r-- | services/audioflinger/AudioFlinger.cpp | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/services/audioflinger/AudioFlinger.cpp b/services/audioflinger/AudioFlinger.cpp index b8a6b37..626b5c2 100644 --- a/services/audioflinger/AudioFlinger.cpp +++ b/services/audioflinger/AudioFlinger.cpp @@ -98,6 +98,11 @@ size_t AudioFlinger::mTeeSinkOutputFrames = kTeeSinkOutputFramesDefault; size_t AudioFlinger::mTeeSinkTrackFrames = kTeeSinkTrackFramesDefault; #endif +//TODO: remove when effect offload is implemented +// In order to avoid invalidating offloaded tracks each time a Visualizer is turned on and off +// we define a minimum time during which a global effect is considered enabled. +static const nsecs_t kMinGlobalEffectEnabletimeNs = seconds(7200); + // ---------------------------------------------------------------------------- static int load_audio_interface(const char *if_name, audio_hw_device_t **dev) @@ -141,7 +146,8 @@ AudioFlinger::AudioFlinger() mMode(AUDIO_MODE_INVALID), mBtNrecIsOff(false), mIsLowRamDevice(true), - mIsDeviceTypeKnown(false) + mIsDeviceTypeKnown(false), + mGlobalEffectEnableTime(0) { getpid_cached = getpid(); char value[PROPERTY_VALUE_MAX]; @@ -2314,6 +2320,38 @@ status_t AudioFlinger::moveEffectChain_l(int sessionId, return NO_ERROR; } +bool AudioFlinger::isGlobalEffectEnabled_l() +{ + if (mGlobalEffectEnableTime != 0 && + ((systemTime() - mGlobalEffectEnableTime) < kMinGlobalEffectEnabletimeNs)) { + return true; + } + + for (size_t i = 0; i < mPlaybackThreads.size(); i++) { + sp<EffectChain> ec = + mPlaybackThreads.valueAt(i)->getEffectChain_l(AUDIO_SESSION_OUTPUT_MIX); + if (ec != 0 && ec->isEnabled()) { + return true; + } + } + return false; +} + +void AudioFlinger::onGlobalEffectEnable() +{ + Mutex::Autolock _l(mLock); + + mGlobalEffectEnableTime = systemTime(); + + for (size_t i = 0; i < mPlaybackThreads.size(); i++) { + sp<PlaybackThread> t = mPlaybackThreads.valueAt(i); + if (t->mType == ThreadBase::OFFLOAD) { + t->invalidateTracks(AUDIO_STREAM_MUSIC); + } + } + +} + struct Entry { #define MAX_NAME 32 // %Y%m%d%H%M%S_%d.wav char mName[MAX_NAME]; |