AudioFlinger: Use std::any for the event cookie

This generalizes over the previous wp<RefBase> cookie.

Test: atest mediasyncevent_tests
Test: atest synchronizedrecordstate_tests
Test: atest MediaSyncEventTest
Bug: 288339104
Bug: 288943829
Merged-In: Iaa535450550681517613310a7043526be38c2aae
Change-Id: Iaa535450550681517613310a7043526be38c2aae
(cherry picked from commit 8f5bb22bd01674772f92b7b326fa0783cfafd99f)
diff --git a/services/audioflinger/Threads.cpp b/services/audioflinger/Threads.cpp
index 1013a7a..2b25599 100644
--- a/services/audioflinger/Threads.cpp
+++ b/services/audioflinger/Threads.cpp
@@ -8877,7 +8877,7 @@
     sp<audioflinger::SyncEvent> strongEvent = event.promote();
 
     if (strongEvent != 0) {
-        sp<RefBase> ptr = strongEvent->cookie().promote();
+        sp<RefBase> ptr = std::any_cast<const wp<RefBase>>(strongEvent->cookie()).promote();
         if (ptr != 0) {
             RecordTrack *recordTrack = (RecordTrack *)ptr.get();
             recordTrack->handleSyncStartEvent(strongEvent);