AudioDeviceMac: fix mutex re-entry.
This change fixes two cases of encountered mutex re-entries. Bug: webrtc:11821 Change-Id: Iaef730e4233a79b0d1b2bf6a17fe3f14e2558e98 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/180800 Reviewed-by: Henrik Andreassson <henrika@webrtc.org> Commit-Queue: Markus Handell <handellm@webrtc.org> Cr-Commit-Position: refs/heads/master@{#31831}
This commit is contained in:

committed by
Commit Bot

parent
e48851d910
commit
6b7d25eed3
@ -382,12 +382,17 @@ bool AudioDeviceMac::Initialized() const {
|
||||
}
|
||||
|
||||
int32_t AudioDeviceMac::SpeakerIsAvailable(bool& available) {
|
||||
MutexLock lock(&mutex_);
|
||||
return SpeakerIsAvailableLocked(available);
|
||||
}
|
||||
|
||||
int32_t AudioDeviceMac::SpeakerIsAvailableLocked(bool& available) {
|
||||
bool wasInitialized = _mixerManager.SpeakerIsInitialized();
|
||||
|
||||
// Make an attempt to open up the
|
||||
// output mixer corresponding to the currently selected output device.
|
||||
//
|
||||
if (!wasInitialized && InitSpeaker() == -1) {
|
||||
if (!wasInitialized && InitSpeakerLocked() == -1) {
|
||||
available = false;
|
||||
return 0;
|
||||
}
|
||||
@ -433,12 +438,17 @@ int32_t AudioDeviceMac::InitSpeakerLocked() {
|
||||
}
|
||||
|
||||
int32_t AudioDeviceMac::MicrophoneIsAvailable(bool& available) {
|
||||
MutexLock lock(&mutex_);
|
||||
return MicrophoneIsAvailableLocked(available);
|
||||
}
|
||||
|
||||
int32_t AudioDeviceMac::MicrophoneIsAvailableLocked(bool& available) {
|
||||
bool wasInitialized = _mixerManager.MicrophoneIsInitialized();
|
||||
|
||||
// Make an attempt to open up the
|
||||
// input mixer corresponding to the currently selected output device.
|
||||
//
|
||||
if (!wasInitialized && InitMicrophone() == -1) {
|
||||
if (!wasInitialized && InitMicrophoneLocked() == -1) {
|
||||
available = false;
|
||||
return 0;
|
||||
}
|
||||
@ -971,7 +981,7 @@ int32_t AudioDeviceMac::InitPlayout() {
|
||||
// Make this call to check if we are using
|
||||
// one or two devices (_twoDevices)
|
||||
bool available = false;
|
||||
if (MicrophoneIsAvailable(available) == -1) {
|
||||
if (MicrophoneIsAvailableLocked(available) == -1) {
|
||||
RTC_LOG(LS_WARNING) << "MicrophoneIsAvailable() failed";
|
||||
}
|
||||
}
|
||||
@ -1109,7 +1119,7 @@ int32_t AudioDeviceMac::InitRecording() {
|
||||
// Make this call to check if we are using
|
||||
// one or two devices (_twoDevices)
|
||||
bool available = false;
|
||||
if (SpeakerIsAvailable(available) == -1) {
|
||||
if (SpeakerIsAvailableLocked(available) == -1) {
|
||||
RTC_LOG(LS_WARNING) << "SpeakerIsAvailable() failed";
|
||||
}
|
||||
}
|
||||
|
@ -113,31 +113,36 @@ class AudioDeviceMac : public AudioDeviceGeneric {
|
||||
virtual bool MicrophoneIsInitialized() const;
|
||||
|
||||
// Speaker volume controls
|
||||
virtual int32_t SpeakerVolumeIsAvailable(bool& available);
|
||||
virtual int32_t SpeakerVolumeIsAvailable(bool& available)
|
||||
RTC_LOCKS_EXCLUDED(mutex_);
|
||||
virtual int32_t SetSpeakerVolume(uint32_t volume);
|
||||
virtual int32_t SpeakerVolume(uint32_t& volume) const;
|
||||
virtual int32_t MaxSpeakerVolume(uint32_t& maxVolume) const;
|
||||
virtual int32_t MinSpeakerVolume(uint32_t& minVolume) const;
|
||||
|
||||
// Microphone volume controls
|
||||
virtual int32_t MicrophoneVolumeIsAvailable(bool& available);
|
||||
virtual int32_t MicrophoneVolumeIsAvailable(bool& available)
|
||||
RTC_LOCKS_EXCLUDED(mutex_);
|
||||
virtual int32_t SetMicrophoneVolume(uint32_t volume);
|
||||
virtual int32_t MicrophoneVolume(uint32_t& volume) const;
|
||||
virtual int32_t MaxMicrophoneVolume(uint32_t& maxVolume) const;
|
||||
virtual int32_t MinMicrophoneVolume(uint32_t& minVolume) const;
|
||||
|
||||
// Microphone mute control
|
||||
virtual int32_t MicrophoneMuteIsAvailable(bool& available);
|
||||
virtual int32_t MicrophoneMuteIsAvailable(bool& available)
|
||||
RTC_LOCKS_EXCLUDED(mutex_);
|
||||
virtual int32_t SetMicrophoneMute(bool enable);
|
||||
virtual int32_t MicrophoneMute(bool& enabled) const;
|
||||
|
||||
// Speaker mute control
|
||||
virtual int32_t SpeakerMuteIsAvailable(bool& available);
|
||||
virtual int32_t SpeakerMuteIsAvailable(bool& available)
|
||||
RTC_LOCKS_EXCLUDED(mutex_);
|
||||
virtual int32_t SetSpeakerMute(bool enable);
|
||||
virtual int32_t SpeakerMute(bool& enabled) const;
|
||||
|
||||
// Stereo support
|
||||
virtual int32_t StereoPlayoutIsAvailable(bool& available);
|
||||
virtual int32_t StereoPlayoutIsAvailable(bool& available)
|
||||
RTC_LOCKS_EXCLUDED(mutex_);
|
||||
virtual int32_t SetStereoPlayout(bool enable);
|
||||
virtual int32_t StereoPlayout(bool& enabled) const;
|
||||
virtual int32_t StereoRecordingIsAvailable(bool& available);
|
||||
@ -154,8 +159,14 @@ class AudioDeviceMac : public AudioDeviceGeneric {
|
||||
int32_t InitSpeakerLocked() RTC_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
|
||||
int32_t InitMicrophoneLocked() RTC_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
|
||||
|
||||
virtual int32_t MicrophoneIsAvailable(bool& available);
|
||||
virtual int32_t SpeakerIsAvailable(bool& available);
|
||||
virtual int32_t MicrophoneIsAvailable(bool& available)
|
||||
RTC_LOCKS_EXCLUDED(mutex_);
|
||||
virtual int32_t MicrophoneIsAvailableLocked(bool& available)
|
||||
RTC_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
|
||||
virtual int32_t SpeakerIsAvailable(bool& available)
|
||||
RTC_LOCKS_EXCLUDED(mutex_);
|
||||
virtual int32_t SpeakerIsAvailableLocked(bool& available)
|
||||
RTC_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
|
||||
|
||||
static void AtomicSet32(int32_t* theValue, int32_t newValue);
|
||||
static int32_t AtomicGet32(int32_t* theValue);
|
||||
|
Reference in New Issue
Block a user