alsa: Check for element types when reconfiguring

Make gst_alsa_device_reconfigure_element() check whether the passed element
type matches that of the device itself before attempting to apply the new
configuration.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/9558>
This commit is contained in:
Adrian Perez de Castro 2025-08-14 21:44:59 +03:00
parent 7a48a0036f
commit 9c166d6dfa

View File

@ -24,6 +24,8 @@
#endif
#include "gstalsadeviceprovider.h"
#include "gstalsasink.h"
#include "gstalsasrc.h"
#include <gst/gst.h>
static GstDevice *gst_alsa_device_new (const gchar * device_name,
@ -382,6 +384,16 @@ gst_alsa_device_reconfigure_element (GstDevice * device, GstElement * element)
{
GstAlsaDevice *alsa_dev = GST_ALSA_DEVICE (device);
if (strcmp (alsa_dev->element, "alsasrc") == 0) {
if (!GST_IS_ALSA_SRC (element))
return FALSE;
} else if (strcmp (alsa_dev->element, "alsasink") == 0) {
if (!GST_IS_ALSA_SINK (element))
return FALSE;
} else {
g_assert_not_reached ();
}
g_object_set (element, "device", alsa_dev->internal_name, NULL);
return TRUE;