yukawa: Fix output audio timestamp reporting

Bug: b/147375795
Test: Verified output timestamps are correctly updated on device.

Change-Id: I8afdfac7d9a4b3db2c1600630ee25fb8606b188b
diff --git a/audio/audio_hw.c b/audio/audio_hw.c
index 5c6dbae..65327d4 100644
--- a/audio/audio_hw.c
+++ b/audio/audio_hw.c
@@ -281,6 +281,7 @@
 
         struct aec_info info;
         get_pcm_timestamp(out->pcm, out->config.rate, &info, true /*isOutput*/);
+        out->timestamp = info.timestamp;
         info.bytes = out_frames * frame_size;
         int aec_ret = write_to_reference_fifo(adev->aec, (void *)buffer, &info);
         if (aec_ret) {
@@ -310,22 +311,17 @@
 static int out_get_presentation_position(const struct audio_stream_out *stream,
                                    uint64_t *frames, struct timespec *timestamp)
 {
-    struct alsa_stream_out *out = (struct alsa_stream_out *)stream;
-    int ret = -1;
+    if (stream == NULL || frames == NULL || timestamp == NULL) {
+        return -EINVAL;
+    }
+    struct alsa_stream_out* out = (struct alsa_stream_out*)stream;
 
-        if (out->pcm) {
-            unsigned int avail;
-            if (pcm_get_htimestamp(out->pcm, &avail, timestamp) == 0) {
-                size_t kernel_buffer_size = out->config.period_size * out->config.period_count;
-                int64_t signed_frames = out->frames_written - kernel_buffer_size + avail;
-                if (signed_frames >= 0) {
-                    *frames = signed_frames;
-                    ret = 0;
-                }
-            }
-        }
+    *frames = out->frames_written;
+    *timestamp = out->timestamp;
+    ALOGV("%s: frames: %" PRIu64 ", timestamp (nsec): %" PRIu64, __func__, *frames,
+          audio_utils_ns_from_timespec(timestamp));
 
-    return ret;
+    return 0;
 }
 
 
diff --git a/audio/audio_hw.h b/audio/audio_hw.h
index f50c8bc..3bc1421 100644
--- a/audio/audio_hw.h
+++ b/audio/audio_hw.h
@@ -103,6 +103,7 @@
     struct alsa_audio_device *dev;
     int write_threshold;
     unsigned int frames_written;
+    struct timespec timestamp;
 };
 
 /* 'bytes' are the number of bytes written to audio FIFO, for which 'timestamp' is valid.