2021-10-16 14:05:45 -04:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
2020-05-23 18:06:22 -04:00
|
|
|
From: Oscar Mira <valldrac@pm.me>
|
|
|
|
Date: Sun, 10 May 2020 01:56:34 +0200
|
|
|
|
Subject: [PATCH] Fix AudioPolicy device entries order to support
|
|
|
|
SLOT_RANDOMIZE
|
|
|
|
|
|
|
|
Fix GrapheneOS/os_issue_tracker#137
|
|
|
|
---
|
|
|
|
.../include/DeviceDescriptor.h | 16 ++++++++++++++++
|
|
|
|
1 file changed, 16 insertions(+)
|
|
|
|
|
|
|
|
diff --git a/services/audiopolicy/common/managerdefinitions/include/DeviceDescriptor.h b/services/audiopolicy/common/managerdefinitions/include/DeviceDescriptor.h
|
2021-10-16 14:05:45 -04:00
|
|
|
index 33e506f1b7..5f9f8b558c 100644
|
2020-05-23 18:06:22 -04:00
|
|
|
--- a/services/audiopolicy/common/managerdefinitions/include/DeviceDescriptor.h
|
|
|
|
+++ b/services/audiopolicy/common/managerdefinitions/include/DeviceDescriptor.h
|
2021-10-16 14:05:45 -04:00
|
|
|
@@ -206,6 +206,22 @@ public:
|
2020-05-23 18:06:22 -04:00
|
|
|
|
|
|
|
void dump(String8 *dst, const String8 &tag, int spaces = 0, bool verbose = true) const;
|
|
|
|
|
|
|
|
+protected:
|
|
|
|
+ // Sorts devices by type.
|
|
|
|
+ int do_compare(const void* lhs, const void* rhs) const override
|
|
|
|
+ {
|
|
|
|
+ const auto& l = *reinterpret_cast<const sp<DeviceDescriptor>*>(lhs);
|
|
|
|
+ const auto& r = *reinterpret_cast<const sp<DeviceDescriptor>*>(rhs);
|
|
|
|
+
|
|
|
|
+ audio_devices_t lt = l->type();
|
|
|
|
+ audio_devices_t rt = r->type();
|
|
|
|
+
|
|
|
|
+ if (lt == rt) {
|
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
|
|
+ return lt > rt ? 1 : -1;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
private:
|
|
|
|
void refreshTypes();
|
|
|
|
audio_devices_t mDeviceTypes;
|