CCodec: Guard against null output->buffers
In CCodecBufferChannel::feedInputBufferIfAvailable(), there is a call to
output->buffers->hasPending(). Since we have changed the logic to allow
output->buffers to be null, the call to hasPending() must be done after
confirming that output->buffers is not null.
Test: atest CtsMediaTestCases
Bug: 158509743
Bug: 158539113
Change-Id: Icb1a46c954ff2b8d5018c0827ff9ca9acd8d4d8e
diff --git a/media/codec2/sfplugin/CCodecBufferChannel.cpp b/media/codec2/sfplugin/CCodecBufferChannel.cpp
index c07f3dc..2cd357b 100644
--- a/media/codec2/sfplugin/CCodecBufferChannel.cpp
+++ b/media/codec2/sfplugin/CCodecBufferChannel.cpp
@@ -618,13 +618,14 @@
}
void CCodecBufferChannel::feedInputBufferIfAvailableInternal() {
- if (mInputMetEos ||
- mOutput.lock()->buffers->hasPending() ||
- mPipelineWatcher.lock()->pipelineFull()) {
+ if (mInputMetEos || mPipelineWatcher.lock()->pipelineFull()) {
return;
- } else {
+ }
+ {
Mutexed<Output>::Locked output(mOutput);
- if (!output->buffers || output->buffers->numClientBuffers() >= output->numSlots) {
+ if (!output->buffers ||
+ output->buffers->hasPending() ||
+ output->buffers->numClientBuffers() >= output->numSlots) {
return;
}
}