audiohal: Do not log if EINVAL is received from get_presentation_position
This happens often, and it's normal. Avoid logging it down as this
causes logspam.
Bug: 33353073
Change-Id: Ia3b1b8af61bdf83e9bcde0e5bed0285af037df45
Test: cause the system to play some sounds (e.g. UI clicks), watch logcat
diff --git a/audio/2.0/default/Stream.cpp b/audio/2.0/default/Stream.cpp
index 1b6d593..40f67f0 100644
--- a/audio/2.0/default/Stream.cpp
+++ b/audio/2.0/default/Stream.cpp
@@ -43,8 +43,8 @@
mStream = nullptr;
}
-Result Stream::analyzeStatus(const char* funcName, int status) {
- if (status != 0) {
+Result Stream::analyzeStatus(const char* funcName, int status, int ignoreError) {
+ if (status != 0 && status != -ignoreError) {
ALOGW("Stream %p %s: %s", mStream, funcName, strerror(-status));
}
switch (status) {
diff --git a/audio/2.0/default/Stream.h b/audio/2.0/default/Stream.h
index 2e641d6..0ebd723 100644
--- a/audio/2.0/default/Stream.h
+++ b/audio/2.0/default/Stream.h
@@ -73,7 +73,7 @@
Return<void> debugDump(const hidl_handle& fd) override;
// Utility methods for extending interfaces.
- Result analyzeStatus(const char* funcName, int status);
+ Result analyzeStatus(const char* funcName, int status, int ignoreError = OK);
private:
audio_stream_t *mStream;
diff --git a/audio/2.0/default/StreamOut.cpp b/audio/2.0/default/StreamOut.cpp
index 546b264..913b6ae 100644
--- a/audio/2.0/default/StreamOut.cpp
+++ b/audio/2.0/default/StreamOut.cpp
@@ -262,7 +262,10 @@
struct timespec halTimeStamp;
retval = mStreamCommon->analyzeStatus(
"get_presentation_position",
- mStream->get_presentation_position(mStream, &frames, &halTimeStamp));
+ mStream->get_presentation_position(mStream, &frames, &halTimeStamp),
+ // Don't logspam on EINVAL--it's normal for get_presentation_position
+ // to return it sometimes.
+ EINVAL);
if (retval == Result::OK) {
timeStamp.tvSec = halTimeStamp.tv_sec;
timeStamp.tvNSec = halTimeStamp.tv_nsec;