diff options
author | The Android Open Source Project <initial-contribution@android.com> | 2009-03-13 13:04:22 -0700 |
---|---|---|
committer | The Android Open Source Project <initial-contribution@android.com> | 2009-03-13 13:04:22 -0700 |
commit | ebad147e654682b6f05438ca8f3685809df5d2e2 (patch) | |
tree | bb7852e568b6d8714e24c5cce9911d925ae05985 | |
parent | bcef13b666c7459241235bc6209837ae81884d2f (diff) | |
download | frameworks_native-ebad147e654682b6f05438ca8f3685809df5d2e2.zip frameworks_native-ebad147e654682b6f05438ca8f3685809df5d2e2.tar.gz frameworks_native-ebad147e654682b6f05438ca8f3685809df5d2e2.tar.bz2 |
auto import from //branches/cupcake_rel/...@138607
-rw-r--r-- | libs/audioflinger/AudioFlinger.cpp | 37 | ||||
-rw-r--r-- | libs/audioflinger/AudioFlinger.h | 2 |
2 files changed, 28 insertions, 11 deletions
diff --git a/libs/audioflinger/AudioFlinger.cpp b/libs/audioflinger/AudioFlinger.cpp index 57a53bd..5652b28 100644 --- a/libs/audioflinger/AudioFlinger.cpp +++ b/libs/audioflinger/AudioFlinger.cpp @@ -837,12 +837,12 @@ void AudioFlinger::handleForcedSpeakerRoute(int command) } #ifdef WITH_A2DP -void AudioFlinger::handleStreamDisablesA2dp(int command) +// handleStreamDisablesA2dp_l() must be called with AudioFlinger::mLock held +void AudioFlinger::handleStreamDisablesA2dp_l(int command) { switch(command) { case ACTIVE_TRACK_ADDED: { - AutoMutex lock(mHardwareLock); if (mA2dpDisableCount++ == 0) { if (mA2dpEnabled) { setA2dpEnabled_l(false); @@ -854,8 +854,7 @@ void AudioFlinger::handleStreamDisablesA2dp(int command) break; case ACTIVE_TRACK_REMOVED: { - AutoMutex lock(mHardwareLock); - if (mA2dpDisableCount > 0){ + if (mA2dpDisableCount > 0) { if (--mA2dpDisableCount == 0) { if (mA2dpSuppressed) { setA2dpEnabled_l(true); @@ -1502,8 +1501,10 @@ void AudioFlinger::MixerThread::addActiveTrack_l(const wp<Track>& t) mAudioFlinger->handleForcedSpeakerRoute(ACTIVE_TRACK_ADDED); } #ifdef WITH_A2DP + // AudioFlinger::mLock must be locked before calling + // handleStreamDisablesA2dp_l because it calls setA2dpEnabled_l(). if (streamDisablesA2dp(track->type())) { - mAudioFlinger->handleStreamDisablesA2dp(ACTIVE_TRACK_ADDED); + mAudioFlinger->handleStreamDisablesA2dp_l(ACTIVE_TRACK_ADDED); } #endif } @@ -1524,8 +1525,10 @@ void AudioFlinger::MixerThread::removeActiveTrack_l(const wp<Track>& t) mAudioFlinger->handleForcedSpeakerRoute(ACTIVE_TRACK_REMOVED); } #ifdef WITH_A2DP + // AudioFlinger::mLock must be locked before calling + // handleStreamDisablesA2dp_l because it calls setA2dpEnabled_l(). if (streamDisablesA2dp(track->type())) { - mAudioFlinger->handleStreamDisablesA2dp(ACTIVE_TRACK_REMOVED); + mAudioFlinger->handleStreamDisablesA2dp_l(ACTIVE_TRACK_REMOVED); } #endif } @@ -2476,8 +2479,15 @@ status_t AudioFlinger::AudioRecordThread::start(MixerThread::RecordTrack* record mRecordTrack = recordTrack; #ifdef WITH_A2DP - if (streamDisablesA2dp(recordTrack->type())) { - mAudioFlinger->handleStreamDisablesA2dp(ACTIVE_TRACK_ADDED); + { // scope for lock2 + + // AudioFlinger::mLock must be locked before calling + // handleStreamDisablesA2dp_l because it calls setA2dpEnabled_l(). + AutoMutex lock2(&mAudioFlinger->mLock); + + // Currently there is no way to detect if we are recording over SCO, + // so we disable A2DP during any recording. + mAudioFlinger->handleStreamDisablesA2dp_l(ACTIVE_TRACK_ADDED); } #endif @@ -2494,8 +2504,15 @@ void AudioFlinger::AudioRecordThread::stop(MixerThread::RecordTrack* recordTrack AutoMutex lock(&mLock); if (mActive && (recordTrack == mRecordTrack.get())) { #ifdef WITH_A2DP - if (streamDisablesA2dp(recordTrack->type())) { - mAudioFlinger->handleStreamDisablesA2dp(ACTIVE_TRACK_REMOVED); + { // scope for lock2 + + // AudioFlinger::mLock must be locked before calling + // handleStreamDisablesA2dp_l because it calls setA2dpEnabled_l(). + AutoMutex lock2(&mAudioFlinger->mLock); + + // Currently there is no way to detect if we are recording over SCO, + // so we disable A2DP during any recording. + mAudioFlinger->handleStreamDisablesA2dp_l(ACTIVE_TRACK_REMOVED); } #endif mActive = false; diff --git a/libs/audioflinger/AudioFlinger.h b/libs/audioflinger/AudioFlinger.h index 596e7f3..ab15947 100644 --- a/libs/audioflinger/AudioFlinger.h +++ b/libs/audioflinger/AudioFlinger.h @@ -176,7 +176,7 @@ private: }; void handleForcedSpeakerRoute(int command); #ifdef WITH_A2DP - void handleStreamDisablesA2dp(int command); + void handleStreamDisablesA2dp_l(int command); #endif // Internal dump utilites. |