diff --git a/sys/wasapi/gstwasapisink.c b/sys/wasapi/gstwasapisink.c index 5d4a0a679a..6ea72e1b19 100644 --- a/sys/wasapi/gstwasapisink.c +++ b/sys/wasapi/gstwasapisink.c @@ -339,22 +339,26 @@ gst_wasapi_sink_get_caps (GstBaseSink * bsink, GstCaps * filter) template_caps = gst_pad_get_pad_template_caps (bsink->sinkpad); - if (!self->client) - gst_wasapi_sink_open (GST_AUDIO_SINK (bsink)); + if (!self->client) { + caps = template_caps; + goto out; + } ret = gst_wasapi_util_get_device_format (GST_ELEMENT (self), self->sharemode, self->device, self->client, &format); if (!ret) { GST_ELEMENT_ERROR (self, STREAM, FORMAT, (NULL), ("failed to detect format")); - goto out; + gst_caps_unref (template_caps); + return NULL; } gst_wasapi_util_parse_waveformatex ((WAVEFORMATEXTENSIBLE *) format, template_caps, &caps, &self->positions); if (caps == NULL) { GST_ELEMENT_ERROR (self, STREAM, FORMAT, (NULL), ("unknown format")); - goto out; + gst_caps_unref (template_caps); + return NULL; } { @@ -376,9 +380,8 @@ gst_wasapi_sink_get_caps (GstBaseSink * bsink, GstCaps * filter) caps = filtered; } - GST_DEBUG_OBJECT (self, "returning caps %" GST_PTR_FORMAT, caps); - out: + GST_DEBUG_OBJECT (self, "returning caps %" GST_PTR_FORMAT, caps); return caps; } diff --git a/sys/wasapi/gstwasapisrc.c b/sys/wasapi/gstwasapisrc.c index b17485b53f..389d49adbe 100644 --- a/sys/wasapi/gstwasapisrc.c +++ b/sys/wasapi/gstwasapisrc.c @@ -326,22 +326,26 @@ gst_wasapi_src_get_caps (GstBaseSrc * bsrc, GstCaps * filter) template_caps = gst_pad_get_pad_template_caps (bsrc->srcpad); - if (!self->client) - gst_wasapi_src_open (GST_AUDIO_SRC (bsrc)); + if (!self->client) { + caps = template_caps; + goto out; + } ret = gst_wasapi_util_get_device_format (GST_ELEMENT (self), self->sharemode, self->device, self->client, &format); if (!ret) { GST_ELEMENT_ERROR (self, STREAM, FORMAT, (NULL), ("failed to detect format")); - goto out; + gst_caps_unref (template_caps); + return NULL; } gst_wasapi_util_parse_waveformatex ((WAVEFORMATEXTENSIBLE *) format, template_caps, &caps, &self->positions); if (caps == NULL) { GST_ELEMENT_ERROR (self, STREAM, FORMAT, (NULL), ("unknown format")); - goto out; + gst_caps_unref (template_caps); + return NULL; } { @@ -363,9 +367,8 @@ gst_wasapi_src_get_caps (GstBaseSrc * bsrc, GstCaps * filter) caps = filtered; } - GST_DEBUG_OBJECT (self, "returning caps %" GST_PTR_FORMAT, caps); - out: + GST_DEBUG_OBJECT (self, "returning caps %" GST_PTR_FORMAT, caps); return caps; }