OutputTrack: Ensure weak pointer is held outside of lambda creation.

Ensure there are no races with respect to capture initialization,
construction, and locking.

Flag: EXEMPT bugfix
Test: Play notifications with Sony 1000XM4 (duplicating thread), toggle BT on/off 10 times.
Bug: 349514538
Change-Id: If63cb0306a8184648e3ba8034c2f081927ec016d
diff --git a/services/audioflinger/Tracks.cpp b/services/audioflinger/Tracks.cpp
index 9ce01f8..a692773 100644
--- a/services/audioflinger/Tracks.cpp
+++ b/services/audioflinger/Tracks.cpp
@@ -318,9 +318,9 @@
 {
     const auto thread = mThread.promote();
     if (thread == nullptr) return;
-    thread->getThreadloopExecutor().defer(
-            [track = wp<TrackBase>::fromExisting(this)] {
-            const auto actual = track.promote();
+    auto weakTrack = wp<TrackBase>::fromExisting(this);
+    thread->getThreadloopExecutor().defer([weakTrack] {
+            const auto actual = weakTrack.promote();
             if (actual) actual->restartIfDisabled();
         });
 }