libaudiohal: When starting write, consider the stream buffer size

When starting writing into a stream, use the bigger value from
the requested bytes to write and the stream buffer size.

This fixes a corner case when offload playback starts close
to the end of the track, and then jumps to the middle.

Bug: 63979005
Test: checked HAL logs for the repro case,
  confirmed that Loopback, PM, YT, Camcoder, still work, also over BT

Change-Id: I924468619d2185fd679b739747c423babfb36ada
diff --git a/media/libaudiohal/StreamHalHidl.h b/media/libaudiohal/StreamHalHidl.h
index a69cce8..d4ab943 100644
--- a/media/libaudiohal/StreamHalHidl.h
+++ b/media/libaudiohal/StreamHalHidl.h
@@ -102,6 +102,8 @@
     // The destructor automatically closes the stream.
     virtual ~StreamHalHidl();
 
+    status_t getCachedBufferSize(size_t *size);
+
     bool requestHalThreadPriority(pid_t threadPid, pid_t threadId);
 
     // mStreamPowerLog is used for audio signal power logging.
@@ -111,6 +113,7 @@
     const int HAL_THREAD_PRIORITY_DEFAULT = -1;
     IStream *mStream;
     int mHalThreadPriority;
+    size_t mCachedBufferSize;
 };
 
 class StreamOutHalHidl : public StreamOutHalInterface, public StreamHalHidl {