audio flinger: shared audio record fixes

Fix several issues with shared audio record history implementation:
- Resetting the shared audio package name when detroyinng a RecordTrack
did not work because RecordThread::shareAudioHistory_l() bailed if the
session ID was not specified: create a new method to reset the shared
audio package and session explicitly.
- RecordThread::getOldestFront_l() must not return a value lagging more
than mRsmpInFrames behind mRsmpInRear because the caller does not check
this condition and can reach outside of the buffer when
copying data to newly allocated buffer.
- Align RecordThread::shareAudioHistory_l() implementation with the API
documentation that indicates best effort in providing history up to the
specified start time: do not reject the request if the specified start
time does not fit within the allocated buffer duratione but adjust the
start time accordingly.

Test: atest AudioRecordSharedAudioTest
Bug: 192718483
Change-Id: Ib058d2180d16d380bbcb7c61fc7455b663bf1e6a
diff --git a/services/audioflinger/Tracks.cpp b/services/audioflinger/Tracks.cpp
index a6e3c06..d2a30b1 100644
--- a/services/audioflinger/Tracks.cpp
+++ b/services/audioflinger/Tracks.cpp
@@ -2458,7 +2458,7 @@
             RecordThread *recordThread = (RecordThread *) thread.get();
             priorState = mState;
             if (!mSharedAudioPackageName.empty()) {
-                recordThread->shareAudioHistory_l("");
+                recordThread->resetAudioHistory_l();
             }
             recordThread->destroyTrack_l(this); // move mState to STOPPED, terminate
         }