RecordThread: Fix sp<> release with mutex held

The RecordThread activeTrack is now released at the end of each
read processing loop cycle, when the ThreadBase_Mutex is not held.

Prior to this, the activeTrack was being released when the new
activeTrack was determined (under lock). Occasionally
when the activeTrack changed and the prior cycle's activeTrack held
the last refCount, the RecordTrack dtor was called while the
ThreadBase_Mutex was held, resulting in a lock
order inversion when the TrackBase's client sp<> is released.

Test: compiles
Bug: 329604636
Merged-In: Ib971dd48098207d2bbc78670bfcf8e14e70efb3f
Change-Id: Ib971dd48098207d2bbc78670bfcf8e14e70efb3f
1 file changed