AudioDeviceMac, AudioMixerManagerMac: remove lock recursions.
This change removes lock recursions and adds thread annotations. Bug: webrtc:11567 Change-Id: I995cdc71b4e447e1153617b3d8472f35c1670181 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/176440 Reviewed-by: Henrik Andreassson <henrika@webrtc.org> Commit-Queue: Markus Handell <handellm@webrtc.org> Cr-Commit-Position: refs/heads/master@{#31426}
This commit is contained in:
parent
341434e4da
commit
44b8b0bebb
@ -410,7 +410,10 @@ int32_t AudioDeviceMac::SpeakerIsAvailable(bool& available) {
|
||||
|
||||
int32_t AudioDeviceMac::InitSpeaker() {
|
||||
rtc::CritScope lock(&_critSect);
|
||||
return InitSpeakerLocked();
|
||||
}
|
||||
|
||||
int32_t AudioDeviceMac::InitSpeakerLocked() {
|
||||
if (_playing) {
|
||||
return -1;
|
||||
}
|
||||
@ -458,7 +461,10 @@ int32_t AudioDeviceMac::MicrophoneIsAvailable(bool& available) {
|
||||
|
||||
int32_t AudioDeviceMac::InitMicrophone() {
|
||||
rtc::CritScope lock(&_critSect);
|
||||
return InitMicrophoneLocked();
|
||||
}
|
||||
|
||||
int32_t AudioDeviceMac::InitMicrophoneLocked() {
|
||||
if (_recording) {
|
||||
return -1;
|
||||
}
|
||||
@ -960,7 +966,7 @@ int32_t AudioDeviceMac::InitPlayout() {
|
||||
}
|
||||
|
||||
// Initialize the speaker (devices might have been added or removed)
|
||||
if (InitSpeaker() == -1) {
|
||||
if (InitSpeakerLocked() == -1) {
|
||||
RTC_LOG(LS_WARNING) << "InitSpeaker() failed";
|
||||
}
|
||||
|
||||
@ -1098,7 +1104,7 @@ int32_t AudioDeviceMac::InitRecording() {
|
||||
}
|
||||
|
||||
// Initialize the microphone (devices might have been added or removed)
|
||||
if (InitMicrophone() == -1) {
|
||||
if (InitMicrophoneLocked() == -1) {
|
||||
RTC_LOG(LS_WARNING) << "InitMicrophone() failed";
|
||||
}
|
||||
|
||||
|
||||
@ -69,8 +69,8 @@ class AudioDeviceMac : public AudioDeviceGeneric {
|
||||
AudioDeviceModule::AudioLayer& audioLayer) const;
|
||||
|
||||
// Main initializaton and termination
|
||||
virtual InitStatus Init();
|
||||
virtual int32_t Terminate();
|
||||
virtual InitStatus Init() RTC_LOCKS_EXCLUDED(_critSect);
|
||||
virtual int32_t Terminate() RTC_LOCKS_EXCLUDED(_critSect);
|
||||
virtual bool Initialized() const;
|
||||
|
||||
// Device enumeration
|
||||
@ -84,7 +84,8 @@ class AudioDeviceMac : public AudioDeviceGeneric {
|
||||
char guid[kAdmMaxGuidSize]);
|
||||
|
||||
// Device selection
|
||||
virtual int32_t SetPlayoutDevice(uint16_t index);
|
||||
virtual int32_t SetPlayoutDevice(uint16_t index)
|
||||
RTC_LOCKS_EXCLUDED(_critSect);
|
||||
virtual int32_t SetPlayoutDevice(AudioDeviceModule::WindowsDeviceType device);
|
||||
virtual int32_t SetRecordingDevice(uint16_t index);
|
||||
virtual int32_t SetRecordingDevice(
|
||||
@ -92,24 +93,24 @@ class AudioDeviceMac : public AudioDeviceGeneric {
|
||||
|
||||
// Audio transport initialization
|
||||
virtual int32_t PlayoutIsAvailable(bool& available);
|
||||
virtual int32_t InitPlayout();
|
||||
virtual int32_t InitPlayout() RTC_LOCKS_EXCLUDED(_critSect);
|
||||
virtual bool PlayoutIsInitialized() const;
|
||||
virtual int32_t RecordingIsAvailable(bool& available);
|
||||
virtual int32_t InitRecording();
|
||||
virtual int32_t InitRecording() RTC_LOCKS_EXCLUDED(_critSect);
|
||||
virtual bool RecordingIsInitialized() const;
|
||||
|
||||
// Audio transport control
|
||||
virtual int32_t StartPlayout();
|
||||
virtual int32_t StopPlayout();
|
||||
virtual int32_t StartPlayout() RTC_LOCKS_EXCLUDED(_critSect);
|
||||
virtual int32_t StopPlayout() RTC_LOCKS_EXCLUDED(_critSect);
|
||||
virtual bool Playing() const;
|
||||
virtual int32_t StartRecording();
|
||||
virtual int32_t StopRecording();
|
||||
virtual int32_t StartRecording() RTC_LOCKS_EXCLUDED(_critSect);
|
||||
virtual int32_t StopRecording() RTC_LOCKS_EXCLUDED(_critSect);
|
||||
virtual bool Recording() const;
|
||||
|
||||
// Audio mixer initialization
|
||||
virtual int32_t InitSpeaker();
|
||||
virtual int32_t InitSpeaker() RTC_LOCKS_EXCLUDED(_critSect);
|
||||
virtual bool SpeakerIsInitialized() const;
|
||||
virtual int32_t InitMicrophone();
|
||||
virtual int32_t InitMicrophone() RTC_LOCKS_EXCLUDED(_critSect);
|
||||
virtual bool MicrophoneIsInitialized() const;
|
||||
|
||||
// Speaker volume controls
|
||||
@ -147,9 +148,13 @@ class AudioDeviceMac : public AudioDeviceGeneric {
|
||||
// Delay information and control
|
||||
virtual int32_t PlayoutDelay(uint16_t& delayMS) const;
|
||||
|
||||
virtual void AttachAudioBuffer(AudioDeviceBuffer* audioBuffer);
|
||||
virtual void AttachAudioBuffer(AudioDeviceBuffer* audioBuffer)
|
||||
RTC_LOCKS_EXCLUDED(_critSect);
|
||||
|
||||
private:
|
||||
int32_t InitSpeakerLocked() RTC_EXCLUSIVE_LOCKS_REQUIRED(_critSect);
|
||||
int32_t InitMicrophoneLocked() RTC_EXCLUSIVE_LOCKS_REQUIRED(_critSect);
|
||||
|
||||
virtual int32_t MicrophoneIsAvailable(bool& available);
|
||||
virtual int32_t SpeakerIsAvailable(bool& available);
|
||||
|
||||
@ -229,13 +234,15 @@ class AudioDeviceMac : public AudioDeviceGeneric {
|
||||
OSStatus implDeviceIOProc(const AudioBufferList* inputData,
|
||||
const AudioTimeStamp* inputTime,
|
||||
AudioBufferList* outputData,
|
||||
const AudioTimeStamp* outputTime);
|
||||
const AudioTimeStamp* outputTime)
|
||||
RTC_LOCKS_EXCLUDED(_critSect);
|
||||
|
||||
OSStatus implOutConverterProc(UInt32* numberDataPackets,
|
||||
AudioBufferList* data);
|
||||
|
||||
OSStatus implInDeviceIOProc(const AudioBufferList* inputData,
|
||||
const AudioTimeStamp* inputTime);
|
||||
const AudioTimeStamp* inputTime)
|
||||
RTC_LOCKS_EXCLUDED(_critSect);
|
||||
|
||||
OSStatus implInConverterProc(UInt32* numberDataPackets,
|
||||
AudioBufferList* data);
|
||||
|
||||
@ -63,16 +63,19 @@ int32_t AudioMixerManagerMac::Close() {
|
||||
|
||||
rtc::CritScope lock(&_critSect);
|
||||
|
||||
CloseSpeaker();
|
||||
CloseMicrophone();
|
||||
CloseSpeakerLocked();
|
||||
CloseMicrophoneLocked();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t AudioMixerManagerMac::CloseSpeaker() {
|
||||
RTC_LOG(LS_VERBOSE) << __FUNCTION__;
|
||||
|
||||
rtc::CritScope lock(&_critSect);
|
||||
return CloseSpeakerLocked();
|
||||
}
|
||||
|
||||
int32_t AudioMixerManagerMac::CloseSpeakerLocked() {
|
||||
RTC_LOG(LS_VERBOSE) << __FUNCTION__;
|
||||
|
||||
_outputDeviceID = kAudioObjectUnknown;
|
||||
_noOutputChannels = 0;
|
||||
@ -81,9 +84,12 @@ int32_t AudioMixerManagerMac::CloseSpeaker() {
|
||||
}
|
||||
|
||||
int32_t AudioMixerManagerMac::CloseMicrophone() {
|
||||
RTC_LOG(LS_VERBOSE) << __FUNCTION__;
|
||||
|
||||
rtc::CritScope lock(&_critSect);
|
||||
return CloseMicrophoneLocked();
|
||||
}
|
||||
|
||||
int32_t AudioMixerManagerMac::CloseMicrophoneLocked() {
|
||||
RTC_LOG(LS_VERBOSE) << __FUNCTION__;
|
||||
|
||||
_inputDeviceID = kAudioObjectUnknown;
|
||||
_noInputChannels = 0;
|
||||
|
||||
@ -21,29 +21,29 @@ namespace webrtc {
|
||||
|
||||
class AudioMixerManagerMac {
|
||||
public:
|
||||
int32_t OpenSpeaker(AudioDeviceID deviceID);
|
||||
int32_t OpenMicrophone(AudioDeviceID deviceID);
|
||||
int32_t SetSpeakerVolume(uint32_t volume);
|
||||
int32_t OpenSpeaker(AudioDeviceID deviceID) RTC_LOCKS_EXCLUDED(_critSect);
|
||||
int32_t OpenMicrophone(AudioDeviceID deviceID) RTC_LOCKS_EXCLUDED(_critSect);
|
||||
int32_t SetSpeakerVolume(uint32_t volume) RTC_LOCKS_EXCLUDED(_critSect);
|
||||
int32_t SpeakerVolume(uint32_t& volume) const;
|
||||
int32_t MaxSpeakerVolume(uint32_t& maxVolume) const;
|
||||
int32_t MinSpeakerVolume(uint32_t& minVolume) const;
|
||||
int32_t SpeakerVolumeIsAvailable(bool& available);
|
||||
int32_t SpeakerMuteIsAvailable(bool& available);
|
||||
int32_t SetSpeakerMute(bool enable);
|
||||
int32_t SetSpeakerMute(bool enable) RTC_LOCKS_EXCLUDED(_critSect);
|
||||
int32_t SpeakerMute(bool& enabled) const;
|
||||
int32_t StereoPlayoutIsAvailable(bool& available);
|
||||
int32_t StereoRecordingIsAvailable(bool& available);
|
||||
int32_t MicrophoneMuteIsAvailable(bool& available);
|
||||
int32_t SetMicrophoneMute(bool enable);
|
||||
int32_t SetMicrophoneMute(bool enable) RTC_LOCKS_EXCLUDED(_critSect);
|
||||
int32_t MicrophoneMute(bool& enabled) const;
|
||||
int32_t MicrophoneVolumeIsAvailable(bool& available);
|
||||
int32_t SetMicrophoneVolume(uint32_t volume);
|
||||
int32_t SetMicrophoneVolume(uint32_t volume) RTC_LOCKS_EXCLUDED(_critSect);
|
||||
int32_t MicrophoneVolume(uint32_t& volume) const;
|
||||
int32_t MaxMicrophoneVolume(uint32_t& maxVolume) const;
|
||||
int32_t MinMicrophoneVolume(uint32_t& minVolume) const;
|
||||
int32_t Close();
|
||||
int32_t CloseSpeaker();
|
||||
int32_t CloseMicrophone();
|
||||
int32_t Close() RTC_LOCKS_EXCLUDED(_critSect);
|
||||
int32_t CloseSpeaker() RTC_LOCKS_EXCLUDED(_critSect);
|
||||
int32_t CloseMicrophone() RTC_LOCKS_EXCLUDED(_critSect);
|
||||
bool SpeakerIsInitialized() const;
|
||||
bool MicrophoneIsInitialized() const;
|
||||
|
||||
@ -52,6 +52,8 @@ class AudioMixerManagerMac {
|
||||
~AudioMixerManagerMac();
|
||||
|
||||
private:
|
||||
int32_t CloseSpeakerLocked() RTC_EXCLUSIVE_LOCKS_REQUIRED(_critSect);
|
||||
int32_t CloseMicrophoneLocked() RTC_EXCLUSIVE_LOCKS_REQUIRED(_critSect);
|
||||
static void logCAMsg(const rtc::LoggingSeverity sev,
|
||||
const char* msg,
|
||||
const char* err);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user