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
(cherry picked from commit 96a3a19beda45bef7c34fc06a0048174f3a7e362)
diff --git a/audio/2.0/default/Stream.cpp b/audio/2.0/default/Stream.cpp
index 671f171..effdd28 100644
--- a/audio/2.0/default/Stream.cpp
+++ b/audio/2.0/default/Stream.cpp
@@ -44,8 +44,20 @@
 }
 
 // static
-Result Stream::analyzeStatus(const char* funcName, int status, int ignoreError, int ignoreError2) {
-    if (status != 0 && status != -ignoreError && status != -ignoreError2) {
+Result Stream::analyzeStatus(const char* funcName, int status) {
+    static const std::vector<int> empty;
+    return analyzeStatus(funcName, status, empty);
+}
+
+template <typename T>
+inline bool element_in(T e, const std::vector<T>& v) {
+    return std::find(v.begin(), v.end(), e) != v.end();
+}
+
+// static
+Result Stream::analyzeStatus(const char* funcName, int status,
+                             const std::vector<int>& ignoreErrors) {
+    if (status != 0 && (ignoreErrors.empty() || !element_in(-status, ignoreErrors))) {
         ALOGW("Error from HAL stream in function %s: %s", funcName, strerror(-status));
     }
     switch (status) {