summaryrefslogtreecommitdiffstats
path: root/services/audioflinger/AudioFlinger.h
diff options
context:
space:
mode:
authorEric Laurent <elaurent@google.com>2011-11-11 15:42:52 -0800
committerEric Laurent <elaurent@google.com>2011-11-11 16:33:24 -0800
commitf9c361dec4b9380db2b7eeaed68c828e154681ed (patch)
tree28470dce4b4c925746499203c866112be04ad872 /services/audioflinger/AudioFlinger.h
parent843e04d977fd348ed474da1d3c6a62e7dc837444 (diff)
downloadframeworks_base-f9c361dec4b9380db2b7eeaed68c828e154681ed.zip
frameworks_base-f9c361dec4b9380db2b7eeaed68c828e154681ed.tar.gz
frameworks_base-f9c361dec4b9380db2b7eeaed68c828e154681ed.tar.bz2
audioflinger: fix noise when skipping to next song
When audio effects are enabled, a noise can be heard at the beginning of the new song when skipping to next song in music app. This is because some effects (especially virtualizer) have a tail. This tail was not played when previous song was stopped because effects were not processed when no tracks were present on a given session. This is to reduce CPU load when effects are enabled but no audio is playing. The tail was then rendered when the new song was started. Added a delay before stopping effect process after all tracks have been removed from a session. Issue 5584880. Change-Id: I815e0f7441f9302e8dfe413dc269a94e4cc6fd95
Diffstat (limited to 'services/audioflinger/AudioFlinger.h')
-rw-r--r--services/audioflinger/AudioFlinger.h9
1 files changed, 8 insertions, 1 deletions
diff --git a/services/audioflinger/AudioFlinger.h b/services/audioflinger/AudioFlinger.h
index 4b794ef..897bc78 100644
--- a/services/audioflinger/AudioFlinger.h
+++ b/services/audioflinger/AudioFlinger.h
@@ -1247,6 +1247,10 @@ private:
// corresponding to a suspend all request.
static const int kKeyForSuspendAll = 0;
+ // minimum duration during which we force calling effect process when last track on
+ // a session is stopped or removed to allow effect tail to be rendered
+ static const int kProcessTailDurationMs = 1000;
+
void process_l();
void lock() {
@@ -1287,7 +1291,8 @@ private:
void decTrackCnt() { android_atomic_dec(&mTrackCnt); }
int32_t trackCnt() { return mTrackCnt;}
- void incActiveTrackCnt() { android_atomic_inc(&mActiveTrackCnt); }
+ void incActiveTrackCnt() { android_atomic_inc(&mActiveTrackCnt);
+ mTailBufferCount = mMaxTailBuffers; }
void decActiveTrackCnt() { android_atomic_dec(&mActiveTrackCnt); }
int32_t activeTrackCnt() { return mActiveTrackCnt;}
@@ -1338,6 +1343,8 @@ private:
int16_t *mOutBuffer; // chain output buffer
volatile int32_t mActiveTrackCnt; // number of active tracks connected
volatile int32_t mTrackCnt; // number of tracks connected
+ int32_t mTailBufferCount; // current effect tail buffer count
+ int32_t mMaxTailBuffers; // maximum effect tail buffers
bool mOwnInBuffer; // true if the chain owns its input buffer
int mVolumeCtrlIdx; // index of insert effect having control over volume
uint32_t mLeftVolume; // previous volume on left channel