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/StreamIn.cpp b/audio/2.0/default/StreamIn.cpp
index abd0497..b81cbb9 100644
--- a/audio/2.0/default/StreamIn.cpp
+++ b/audio/2.0/default/StreamIn.cpp
@@ -416,15 +416,15 @@
// static
Result StreamIn::getCapturePositionImpl(audio_stream_in_t* stream,
uint64_t* frames, uint64_t* time) {
+ // HAL may have a stub function, always returning ENOSYS, don't
+ // spam the log in this case.
+ static const std::vector<int> ignoredErrors{ENOSYS};
Result retval(Result::NOT_SUPPORTED);
if (stream->get_capture_position != NULL) return retval;
int64_t halFrames, halTime;
- retval = Stream::analyzeStatus(
- "get_capture_position",
- stream->get_capture_position(stream, &halFrames, &halTime),
- // HAL may have a stub function, always returning ENOSYS, don't
- // spam the log in this case.
- ENOSYS);
+ retval = Stream::analyzeStatus("get_capture_position",
+ stream->get_capture_position(stream, &halFrames, &halTime),
+ ignoredErrors);
if (retval == Result::OK) {
*frames = halFrames;
*time = halTime;