gst: refactor some of the param handling

Clear the caps when the param is NULL.
This commit is contained in:
Wim Taymans 2024-03-15 17:29:03 +01:00
parent 2bd85e08cf
commit 1fe498560b

View file

@ -1001,17 +1001,18 @@ connect_error:
}
static void
on_param_changed (void *data, uint32_t id,
handle_format_change (GstPipeWireSrc *pwsrc,
const struct spa_pod *param)
{
GstPipeWireSrc *pwsrc = data;
if (param == NULL || id != SPA_PARAM_Format) {
GST_DEBUG_OBJECT (pwsrc, "clear format");
return;
}
if (pwsrc->caps)
gst_caps_unref(pwsrc->caps);
if (param == NULL) {
GST_DEBUG_OBJECT (pwsrc, "clear format");
pwsrc->caps = NULL;
pwsrc->negotiated = FALSE;
pwsrc->is_video = FALSE;
return;
}
pwsrc->caps = gst_caps_from_format (param);
if (pwsrc->caps && gst_caps_is_fixed (pwsrc->caps)) {
@ -1093,6 +1094,18 @@ on_param_changed (void *data, uint32_t id,
pw_thread_loop_signal (pwsrc->core->loop, FALSE);
}
static void
on_param_changed (void *data, uint32_t id,
const struct spa_pod *param)
{
GstPipeWireSrc *pwsrc = data;
switch (id) {
case SPA_PARAM_Format:
handle_format_change(pwsrc, param);
break;
}
}
static gboolean
gst_pipewire_src_unlock (GstBaseSrc * basesrc)
{