hal: Add perf lock only during device switch
Existing Audio HAL acquires perf lock during device switch
for every Android Policy manager routing request without
checking for device switch. Acquire perf lock only when
there is actual device switch and avoid redundant acquiring
of perf locks for every routing request.
Change-Id: If81dde9f2bc5e6553dca1145b5966098712d65db
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index bce5cea..af399a1 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -2349,15 +2349,16 @@
}
if (!out->standby) {
- audio_extn_perf_lock_acquire(&adev->perf_lock_handle, 0,
- adev->perf_lock_opts,
- adev->perf_lock_opts_size);
if (!same_dev) {
ALOGV("update routing change");
out->routing_change = true;
+ audio_extn_perf_lock_acquire(&adev->perf_lock_handle, 0,
+ adev->perf_lock_opts,
+ adev->perf_lock_opts_size);
}
select_devices(adev, out->usecase);
- audio_extn_perf_lock_release(&adev->perf_lock_handle);
+ if (!same_dev)
+ audio_extn_perf_lock_release(&adev->perf_lock_handle);
}
}