am 2bccbcc7: Merge change 25050 into eclair

Merge commit '2bccbcc777ca48a08663c16e90ea3f76ace6eb07' into eclair-plus-aosp

* commit '2bccbcc777ca48a08663c16e90ea3f76ace6eb07':
  Fix issue 2118464: cannot play ring tones and notifications after disconnecting BT headset while in call.
This commit is contained in:
Eric Laurent
2009-09-15 08:35:04 -07:00
committed by Android Git Automerger
2 changed files with 14 additions and 18 deletions

View File

@@ -677,8 +677,8 @@ void AudioFlinger::binderDied(const wp<IBinder>& who) {
} }
} }
void AudioFlinger::audioConfigChanged(int event, const sp<ThreadBase>& thread, void *param2) { // audioConfigChanged_l() must be called with AudioFlinger::mLock held
Mutex::Autolock _l(mLock); void AudioFlinger::audioConfigChanged_l(int event, const sp<ThreadBase>& thread, void *param2) {
int ioHandle = 0; int ioHandle = 0;
for (size_t i = 0; i < mPlaybackThreads.size(); i++) { for (size_t i = 0; i < mPlaybackThreads.size(); i++) {
@@ -700,7 +700,7 @@ void AudioFlinger::audioConfigChanged(int event, const sp<ThreadBase>& thread, v
size_t size = mNotificationClients.size(); size_t size = mNotificationClients.size();
for (size_t i = 0; i < size; i++) { for (size_t i = 0; i < size; i++) {
sp<IBinder> binder = mNotificationClients.itemAt(i); sp<IBinder> binder = mNotificationClients.itemAt(i);
LOGV("audioConfigChanged() Notifying change to client %p", binder.get()); LOGV("audioConfigChanged_l() Notifying change to client %p", binder.get());
sp<IAudioFlingerClient> client = interface_cast<IAudioFlingerClient> (binder); sp<IAudioFlingerClient> client = interface_cast<IAudioFlingerClient> (binder);
client->ioConfigChanged(event, ioHandle, param2); client->ioConfigChanged(event, ioHandle, param2);
} }
@@ -803,8 +803,8 @@ void AudioFlinger::ThreadBase::processConfigEvents()
LOGV("processConfigEvents() remaining events %d", mConfigEvents.size()); LOGV("processConfigEvents() remaining events %d", mConfigEvents.size());
ConfigEvent *configEvent = mConfigEvents[0]; ConfigEvent *configEvent = mConfigEvents[0];
mConfigEvents.removeAt(0); mConfigEvents.removeAt(0);
// release mLock because audioConfigChanged() will call // release mLock because audioConfigChanged() will lock AudioFlinger mLock
// Audioflinger::audioConfigChanged() which locks AudioFlinger mLock thus creating // before calling Audioflinger::audioConfigChanged_l() thus creating
// potential cross deadlock between AudioFlinger::mLock and mLock // potential cross deadlock between AudioFlinger::mLock and mLock
mLock.unlock(); mLock.unlock();
audioConfigChanged(configEvent->mEvent, configEvent->mParam); audioConfigChanged(configEvent->mEvent, configEvent->mParam);
@@ -1118,7 +1118,8 @@ void AudioFlinger::PlaybackThread::audioConfigChanged(int event, int param) {
default: default:
break; break;
} }
mAudioFlinger->audioConfigChanged(event, this, param2); Mutex::Autolock _l(mAudioFlinger->mLock);
mAudioFlinger->audioConfigChanged_l(event, this, param2);
} }
void AudioFlinger::PlaybackThread::readOutputParameters() void AudioFlinger::PlaybackThread::readOutputParameters()
@@ -1272,8 +1273,6 @@ bool AudioFlinger::MixerThread::threadLoop()
if (!mStandby) { if (!mStandby) {
mOutput->standby(); mOutput->standby();
} }
sendConfigEvent(AudioSystem::OUTPUT_CLOSED);
processConfigEvents();
LOGV("MixerThread %p exiting", this); LOGV("MixerThread %p exiting", this);
return false; return false;
@@ -1772,8 +1771,6 @@ bool AudioFlinger::DirectOutputThread::threadLoop()
if (!mStandby) { if (!mStandby) {
mOutput->standby(); mOutput->standby();
} }
sendConfigEvent(AudioSystem::OUTPUT_CLOSED);
processConfigEvents();
LOGV("DirectOutputThread %p exiting", this); LOGV("DirectOutputThread %p exiting", this);
return false; return false;
@@ -1965,9 +1962,6 @@ bool AudioFlinger::DuplicatingThread::threadLoop()
} }
} }
sendConfigEvent(AudioSystem::OUTPUT_CLOSED);
processConfigEvents();
return false; return false;
} }
@@ -3047,9 +3041,6 @@ bool AudioFlinger::RecordThread::threadLoop()
} }
mActiveTrack.clear(); mActiveTrack.clear();
sendConfigEvent(AudioSystem::INPUT_CLOSED);
processConfigEvents();
LOGV("RecordThread %p exiting", this); LOGV("RecordThread %p exiting", this);
return false; return false;
} }
@@ -3234,7 +3225,8 @@ void AudioFlinger::RecordThread::audioConfigChanged(int event, int param) {
default: default:
break; break;
} }
mAudioFlinger->audioConfigChanged(event, this, param2); Mutex::Autolock _l(mAudioFlinger->mLock);
mAudioFlinger->audioConfigChanged_l(event, this, param2);
} }
void AudioFlinger::RecordThread::readInputParameters() void AudioFlinger::RecordThread::readInputParameters()
@@ -3379,6 +3371,8 @@ status_t AudioFlinger::closeOutput(int output)
} }
} }
} }
void *param2 = 0;
audioConfigChanged_l(AudioSystem::OUTPUT_CLOSED, thread, param2);
mPlaybackThreads.removeItem(output); mPlaybackThreads.removeItem(output);
} }
thread->exit(); thread->exit();
@@ -3498,6 +3492,8 @@ status_t AudioFlinger::closeInput(int input)
} }
LOGV("closeInput() %d", input); LOGV("closeInput() %d", input);
void *param2 = 0;
audioConfigChanged_l(AudioSystem::INPUT_CLOSED, thread, param2);
mRecordThreads.removeItem(input); mRecordThreads.removeItem(input);
} }
thread->exit(); thread->exit();

View File

@@ -616,7 +616,7 @@ private:
MixerThread *checkMixerThread_l(int output) const; MixerThread *checkMixerThread_l(int output) const;
RecordThread *checkRecordThread_l(int input) const; RecordThread *checkRecordThread_l(int input) const;
float streamVolumeInternal(int stream) const { return mStreamTypes[stream].volume; } float streamVolumeInternal(int stream) const { return mStreamTypes[stream].volume; }
void audioConfigChanged(int event, const sp<ThreadBase>& thread, void *param2); void audioConfigChanged_l(int event, const sp<ThreadBase>& thread, void *param2);
friend class AudioBuffer; friend class AudioBuffer;