Merge "audiohal: Add diagnostic message to check the number of bytes written"
diff --git a/audio/2.0/default/StreamOut.cpp b/audio/2.0/default/StreamOut.cpp
index 6ccdbcd..cdc8ded 100644
--- a/audio/2.0/default/StreamOut.cpp
+++ b/audio/2.0/default/StreamOut.cpp
@@ -79,6 +79,10 @@
         ssize_t writeResult = mStream->write(mStream, &mBuffer[0], availToRead);
         if (writeResult >= 0) {
             mStatus.reply.written = writeResult;
+            // Diagnostics of the cause of b/35813113.
+            ALOGE_IF(writeResult > availToRead,
+                    "legacy hal reports more bytes written than asked for: %lld > %lld",
+                    (long long)writeResult, (long long)availToRead);
         } else {
             mStatus.retval = Stream::analyzeStatus("write", writeResult);
         }