summaryrefslogtreecommitdiffstats
path: root/services/audioflinger/AudioFlinger.h
diff options
context:
space:
mode:
authorEric Laurent <elaurent@google.com>2011-05-09 12:09:06 -0700
committerEric Laurent <elaurent@google.com>2011-05-13 08:34:45 -0700
commit90681d6ad203119a2a6a761740dddc6c6662c542 (patch)
treee29dcfa39980a1d9be5b952f92a0c241cecd8f8a /services/audioflinger/AudioFlinger.h
parented742306b3d24ba1c2ca3fea0cc2ada8534a18b0 (diff)
downloadframeworks_base-90681d6ad203119a2a6a761740dddc6c6662c542.zip
frameworks_base-90681d6ad203119a2a6a761740dddc6c6662c542.tar.gz
frameworks_base-90681d6ad203119a2a6a761740dddc6c6662c542.tar.bz2
Fix audio effect framework issues
Fix two issues in audio effect framework reported by partners. 1 - Fixed duplicated audio buffer sent to effect process function when pausing a track. Modified Effectchain::process_l() function to clear the effect chain input buffer before calling the effect process functions when no track is active on the session. Previous code was clearing the buffer after calling the process functions and when transitioning from active to inactive, the last processed buffer was passed again once to effect process function before being cleared. 2 - Fixed potential mutex cross deadlock when disconnecting an effect while playback is active. This is because EffectChain::process_l() was calling PlaybackThread::hasAudioSession() thus creating an inversion in the mutex lock order (EffectChain mutex locked before ThreadBase mutex). The fix consists in removing the call to hasAudioSession() from process_l() and requires each effect chain to keep count of the number of audio tracks attached to it (previously only the active tracks were accounted for). Change-Id: Iee4246694ea8c7a66c012120c629d72dd38f9c35
Diffstat (limited to 'services/audioflinger/AudioFlinger.h')
-rw-r--r--services/audioflinger/AudioFlinger.h14
1 files changed, 10 insertions, 4 deletions
diff --git a/services/audioflinger/AudioFlinger.h b/services/audioflinger/AudioFlinger.h
index 22e5116..b324d49 100644
--- a/services/audioflinger/AudioFlinger.h
+++ b/services/audioflinger/AudioFlinger.h
@@ -684,6 +684,7 @@ private:
status_t addTrack_l(const sp<Track>& track);
void destroyTrack_l(const sp<Track>& track);
+ void removeTrack_l(const sp<Track>& track);
void readOutputParameters();
@@ -1134,9 +1135,13 @@ private:
return mOutBuffer;
}
- void startTrack() {mActiveTrackCnt++;}
- void stopTrack() {mActiveTrackCnt--;}
- int activeTracks() { return mActiveTrackCnt;}
+ void incTrackCnt() { android_atomic_inc(&mTrackCnt); }
+ void decTrackCnt() { android_atomic_dec(&mTrackCnt); }
+ int32_t trackCnt() { return mTrackCnt;}
+
+ void incActiveTrackCnt() { android_atomic_inc(&mActiveTrackCnt); }
+ void decActiveTrackCnt() { android_atomic_dec(&mActiveTrackCnt); }
+ int32_t activeTrackCnt() { return mActiveTrackCnt;}
uint32_t strategy() { return mStrategy; }
void setStrategy(uint32_t strategy)
@@ -1155,7 +1160,8 @@ private:
int mSessionId; // audio session ID
int16_t *mInBuffer; // chain input buffer
int16_t *mOutBuffer; // chain output buffer
- int mActiveTrackCnt; // number of active tracks connected
+ volatile int32_t mActiveTrackCnt; // number of active tracks connected
+ volatile int32_t mTrackCnt; // number of tracks connected
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