codec2: propagate C2_NO_MEMORY from C2ComponentStore::createComponent()
When C2ComponentStore::createComponent() returns C2_NO_MEMORY,
MediaCodec should raise CodecException with error code
ERROR_INSUFFICIENT_RESOURCE. This CL progagates the error properly.
Bug: 174530542
Test: android.media.cts.MediaCodecCapabilitiesTest#testGetMaxSupportedInstances
Change-Id: I6c8c2de0888944f57b4ea404a5f589e70ee61dc4
diff --git a/media/codec2/sfplugin/CCodec.cpp b/media/codec2/sfplugin/CCodec.cpp
index 9c1df71..4c16796 100644
--- a/media/codec2/sfplugin/CCodec.cpp
+++ b/media/codec2/sfplugin/CCodec.cpp
@@ -645,17 +645,18 @@
std::make_shared<Codec2ClientInterfaceWrapper>(client));
}
- std::shared_ptr<Codec2Client::Component> comp =
- Codec2Client::CreateComponentByName(
+ std::shared_ptr<Codec2Client::Component> comp;
+ c2_status_t status = Codec2Client::CreateComponentByName(
componentName.c_str(),
mClientListener,
+ &comp,
&client);
- if (!comp) {
- ALOGE("Failed Create component: %s", componentName.c_str());
+ if (status != C2_OK) {
+ ALOGE("Failed Create component: %s, error=%d", componentName.c_str(), status);
Mutexed<State>::Locked state(mState);
state->set(RELEASED);
state.unlock();
- mCallback->onError(UNKNOWN_ERROR, ACTION_CODE_FATAL);
+ mCallback->onError((status == C2_NO_MEMORY ? NO_MEMORY : UNKNOWN_ERROR), ACTION_CODE_FATAL);
state.lock();
return;
}