audio encoders: fix initial timestamp
Use timestamp from the first non-empty work, not the very first one
which may be empty with an invalid timestamp.
Bug: 123428627
Test: atest CtsMediaTestCases:MediaRecorderTest
Change-Id: I50f68765355b1fd3af4241adad0c6199fd7b4de8
diff --git a/media/codec2/components/opus/C2SoftOpusEnc.cpp b/media/codec2/components/opus/C2SoftOpusEnc.cpp
index d6ed5ff..68fcea1 100644
--- a/media/codec2/components/opus/C2SoftOpusEnc.cpp
+++ b/media/codec2/components/opus/C2SoftOpusEnc.cpp
@@ -350,7 +350,7 @@
return;
}
}
- if (mIsFirstFrame) {
+ if (mIsFirstFrame && inSize > 0) {
mAnchorTimeStamp = work->input.ordinal.timestamp.peekull();
mIsFirstFrame = false;
}