audio: Presentation time enhancements

1) Add API to query platform render latency. This API is only
valid for deep-buffer and low-latency streams.
2) Adjust frames rendered for deep-buffer and low-latency streams
with the platform render latency
3) Use tinycompress APIs to query presentation time in case of
offload streams.

Bug: 10551158
Change-Id: If94e0994bfc0b757f29aa4b48be6fc63dc17bca0
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index 76533c6..c89d88e 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -1442,8 +1442,12 @@
             size_t avail;
             if (pcm_get_htimestamp(out->pcm, &avail, timestamp) == 0) {
                 size_t kernel_buffer_size = out->config.period_size * out->config.period_count;
-                // FIXME This calculation is incorrect if there is buffering after app processor
                 int64_t signed_frames = out->written - kernel_buffer_size + avail;
+                // This adjustment accounts for buffering after app processor.
+                // It is based on estimated DSP latency per use case, rather than exact.
+                signed_frames -=
+                    (platform_render_latency(out->usecase) * out->sample_rate / 1000000LL);
+
                 // It would be unusual for this value to be negative, but check just in case ...
                 if (signed_frames >= 0) {
                     *frames = signed_frames;