wasapi: Don't open the device in get_caps()

We can just return the template caps till the device is opened when
going from READY -> PAUSED. This fixes a CRITICAL when calling
ELEMENT_ERROR before the ringbuffer is allocated.

Also fixes a couple of leaks in error conditions.

https://bugzilla.gnome.org/show_bug.cgi?id=794611
This commit is contained in:
Nirbheek Chauhan 2018-04-09 17:16:38 +05:30
parent b7653925db
commit c427860a20
2 changed files with 18 additions and 12 deletions

View file

@ -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;
}

View file

@ -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;
}