audiohal: Prevent logspam when calling get_presentation_position

get_presentation_position can return ENODATA if the stream
has stopped but the write is still querying the position.

Bug: 38376424
Change-Id: I9d516a19fb347843a8ec8e8e9a0f5eab0b0798e6
Test: no log messages from StreamHAL about get_presentation_position
diff --git a/audio/2.0/default/StreamOut.cpp b/audio/2.0/default/StreamOut.cpp
index e48497f..290d0b1 100644
--- a/audio/2.0/default/StreamOut.cpp
+++ b/audio/2.0/default/StreamOut.cpp
@@ -487,16 +487,17 @@
 Result StreamOut::getPresentationPositionImpl(audio_stream_out_t* stream,
                                               uint64_t* frames,
                                               TimeSpec* timeStamp) {
+    // Don't logspam on EINVAL--it's normal for get_presentation_position
+    // to return it sometimes. EAGAIN may be returned by A2DP audio HAL
+    // implementation. ENODATA can also be reported while the writer is
+    // continuously querying it, but the stream has been stopped.
+    static const std::vector<int> ignoredErrors{EINVAL, EAGAIN, ENODATA};
     Result retval(Result::NOT_SUPPORTED);
     if (stream->get_presentation_position == NULL) return retval;
     struct timespec halTimeStamp;
-    retval = Stream::analyzeStatus(
-        "get_presentation_position",
-        stream->get_presentation_position(stream, frames, &halTimeStamp),
-        // Don't logspam on EINVAL--it's normal for get_presentation_position
-        // to return it sometimes. EAGAIN may be returned by A2DP audio HAL
-        // implementation.
-        EINVAL, EAGAIN);
+    retval = Stream::analyzeStatus("get_presentation_position",
+                                   stream->get_presentation_position(stream, frames, &halTimeStamp),
+                                   ignoredErrors);
     if (retval == Result::OK) {
         timeStamp->tvSec = halTimeStamp.tv_sec;
         timeStamp->tvNSec = halTimeStamp.tv_nsec;