vcomp/lavc: fix init fail

Due to recent changes, libavcodec initialization fails because trying
to register the lavc module prior to vcomp.

This crashes due to the recent changes but it has been a dark zone so far.

Initialize the vcomp module correctly prior to the lavc.

+ add assert to module_register that would catch this problem
This commit is contained in:
Martin Pulec
2025-06-18 12:05:22 +02:00
parent 9ac2c6b33a
commit 976e9ef2e7
2 changed files with 12 additions and 8 deletions

View File

@@ -90,6 +90,7 @@ void module_register(struct module *module_data, struct module *parent)
if (parent == NULL) {
return;
}
assert(parent->module_priv != NULL);
module_priv->parent = parent->module_priv;
module_mutex_lock(&parent->module_priv->lock);
simple_linked_list_append(parent->module_priv->children, module_priv);

View File

@@ -99,8 +99,17 @@ public:
* state. The point of doing this is to allow dynamic reconfiguration of the real state.
*/
struct compress_state {
explicit compress_state(struct module *parent)
{
module_init_default(&mod);
mod.cls = MODULE_CLASS_COMPRESS;
mod.priv_data = this;
module_register(&mod, parent);
}
~compress_state() { module_done(&mod); }
struct module mod; ///< compress module data
struct compress_state_real *ptr; ///< pointer to real compress state
struct compress_state_real *ptr{}; ///< pointer to real compress state
synchronized_queue<shared_ptr<video_frame>, 1> queue;
bool poisoned = false;
};
@@ -195,11 +204,7 @@ static void compress_process_message(struct compress_state *proxy, struct msg_ch
*/
int compress_init(struct module *parent, const char *config_string, struct compress_state **state) {
struct compress_state *proxy;
proxy = new struct compress_state();
module_init_default(&proxy->mod);
proxy->mod.cls = MODULE_CLASS_COMPRESS;
proxy->mod.priv_data = proxy;
proxy = new struct compress_state(parent);
try {
proxy->ptr = compress_state_real::create(&proxy->mod, config_string, proxy);
@@ -208,7 +213,6 @@ int compress_init(struct module *parent, const char *config_string, struct compr
return i;
}
module_register(&proxy->mod, parent);
*state = proxy;
return 0;
@@ -497,7 +501,6 @@ compress_done(struct compress_state *proxy)
}
delete s;
module_done(&proxy->mod);
delete proxy;
}