codec2: instantiate VDAAdaptor on component start
In Codec2.0 spec, component could be started/stopped multiple times. Since
Chrome VDA only accepts to be initialized once per instance, we would like to
instantiate VDAAdaptor each time component is started, and destory it each time
component is stopped.
Bug: 78207086
Test: CtsMediaTestCases android.media.cts.DecoderTest#testCodecResetsVP8WithSurface
Change-Id: I7e38dc3f86fd05736bfd1b94368c3cff983ca2b9
diff --git a/C2VDAComponent.cpp b/C2VDAComponent.cpp
index 8a25388..35cf4eb 100644
--- a/C2VDAComponent.cpp
+++ b/C2VDAComponent.cpp
@@ -506,7 +506,6 @@
return;
}
mTaskRunner = mThread.task_runner();
- mTaskRunner->PostTask(FROM_HERE, base::Bind(&C2VDAComponent::onCreate, base::Unretained(this)));
mState.store(State::LOADED);
}
@@ -530,16 +529,6 @@
ALOGI("get parameter: mCodecProfile = %d", static_cast<int>(mCodecProfile));
}
-void C2VDAComponent::onCreate() {
- DCHECK(mTaskRunner->BelongsToCurrentThread());
- ALOGV("onCreate");
-#ifdef V4L2_CODEC2_ARC
- mVDAAdaptor.reset(new arc::C2VDAAdaptorProxy());
-#else
- mVDAAdaptor.reset(new C2VDAAdaptor());
-#endif
-}
-
void C2VDAComponent::onDestroy() {
DCHECK(mTaskRunner->BelongsToCurrentThread());
ALOGV("onDestroy");
@@ -553,6 +542,13 @@
DCHECK(mTaskRunner->BelongsToCurrentThread());
ALOGV("onStart");
CHECK_EQ(mComponentState, ComponentState::UNINITIALIZED);
+
+#ifdef V4L2_CODEC2_ARC
+ mVDAAdaptor.reset(new arc::C2VDAAdaptorProxy());
+#else
+ mVDAAdaptor.reset(new C2VDAAdaptor());
+#endif
+
// TODO: Set secureMode value dynamically.
bool secureMode = false;
mVDAInitResult = mVDAAdaptor->initialize(profile, secureMode, this);
diff --git a/include/C2VDAComponent.h b/include/C2VDAComponent.h
index 4e56fb7..e99b3f4 100644
--- a/include/C2VDAComponent.h
+++ b/include/C2VDAComponent.h
@@ -230,7 +230,6 @@
void returnOutputBuffer(int32_t pictureBufferId);
// These tasks should be run on the component thread |mThread|.
- void onCreate();
void onDestroy();
void onStart(media::VideoCodecProfile profile, base::WaitableEvent* done);
void onQueueWork(std::unique_ptr<C2Work> work);