C2SoftAacDec: Fix reset while codec's stop()
Bug: 147348711
Test: atest android.mediav2.cts.CodecDecoderTest
Test: atest android.mediav2.cts.CodecDecoderSurfaceTest
Change-Id: I61b9cf8ed61fc3cd02068cdc696ba24e30d1ca3c
Merged-In: I61b9cf8ed61fc3cd02068cdc696ba24e30d1ca3c
diff --git a/media/codec2/components/aac/C2SoftAacDec.cpp b/media/codec2/components/aac/C2SoftAacDec.cpp
index f948dd4..342d771 100644
--- a/media/codec2/components/aac/C2SoftAacDec.cpp
+++ b/media/codec2/components/aac/C2SoftAacDec.cpp
@@ -289,13 +289,14 @@
mOutputDelayRingBufferFilled = 0;
mBuffersInfo.clear();
- // To make the codec behave the same before and after a reset, we need to invalidate the
- // streaminfo struct. This does that:
- mStreamInfo->sampleRate = 0; // TODO: mStreamInfo is read only
-
+ status_t status = UNKNOWN_ERROR;
+ if (mAACDecoder) {
+ aacDecoder_Close(mAACDecoder);
+ status = initDecoder();
+ }
mSignalledError = false;
- return C2_OK;
+ return status == OK ? C2_OK : C2_CORRUPTED;
}
void C2SoftAacDec::onReset() {