mAudioHwDevs and related cleanup
Inline AudioFlinger::initCheck and remove unnecessary lock.
Remove redundant check of mAudioHwDevs.size().
No need to lock mHardwareLock for each device separately
during initialization.
Use size_t not int to loop through Vector, since size() returns size_t.
Add missing hardware lock for get_mic_mute() and get_input_buffer_size().
Add comments.
Change-Id: Iafae78ef78bbf65f703d99fcc27c2f4ff221aedc
diff --git a/services/audioflinger/AudioFlinger.h b/services/audioflinger/AudioFlinger.h
index c66b19e..fdcd916 100644
--- a/services/audioflinger/AudioFlinger.h
+++ b/services/audioflinger/AudioFlinger.h
@@ -199,7 +199,9 @@
AudioFlinger();
virtual ~AudioFlinger();
- status_t initCheck() const;
+ // call in any IAudioFlinger method that accesses mPrimaryHardwareDev
+ status_t initCheck() const { return mPrimaryHardwareDev == NULL ? NO_INIT : NO_ERROR; }
+
virtual void onFirstRef();
audio_hw_device_t* findSuitableHwDev_l(uint32_t devices);
void purgeStaleEffects_l();
@@ -1391,7 +1393,9 @@
DefaultKeyedVector< pid_t, wp<Client> > mClients; // see ~Client()
mutable Mutex mHardwareLock;
- audio_hw_device_t* mPrimaryHardwareDev;
+
+ // These two fields are immutable after onFirstRef(), so no lock needed to access
+ audio_hw_device_t* mPrimaryHardwareDev; // mAudioHwDevs[0] or NULL
Vector<audio_hw_device_t*> mAudioHwDevs;
enum hardware_call_state {
@@ -1411,6 +1415,7 @@
AUDIO_HW_SET_MIC_MUTE,
AUDIO_SET_VOICE_VOLUME,
AUDIO_SET_PARAMETER,
+ AUDIO_HW_GET_INPUT_BUFFER_SIZE,
};
mutable hardware_call_state mHardwareStatus; // for dump only