Adding sanity checks for invalid frame sizes
Invalid frame size can cause the audio server to crash due to a
divide-by-zero error. Adding sanity checks to make that issue easier to
diagnose.
Bug: 155646578
Test: Ran CarAudioManagerSystemTest suite which was encountering the
error
Change-Id: Ibc5b8e13738eb8957d21509b7f87ddaf3115cd4a
diff --git a/services/audioflinger/AudioStreamOut.cpp b/services/audioflinger/AudioStreamOut.cpp
index d13cb8f..7e06096 100644
--- a/services/audioflinger/AudioStreamOut.cpp
+++ b/services/audioflinger/AudioStreamOut.cpp
@@ -164,6 +164,10 @@
stream = outStream;
mHalFormatHasProportionalFrames = audio_has_proportional_frames(config->format);
status = stream->getFrameSize(&mHalFrameSize);
+ LOG_ALWAYS_FATAL_IF(status != OK, "Error retrieving frame size from HAL: %d", status);
+ LOG_ALWAYS_FATAL_IF(mHalFrameSize <= 0, "Error frame size was %zu but must be greater than"
+ " zero", mHalFrameSize);
+
}
return status;