mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-22 15:18:21 +00:00
gst/level/gstlevel.*: figure out if we're initialized directly instead of keeping a variable that's wrong in 90% of c...
Original commit message from CVS: * gst/level/gstlevel.c: (gst_level_link), (gst_level_chain), (gst_level_change_state), (gst_level_init): * gst/level/gstlevel.h: figure out if we're initialized directly instead of keeping a variable that's wrong in 90% of cases don't initialize pads and then leak them and use a new unitialized pad. (fixes #142084) these were bugs so n00bish I didn't find them for an hour :/
This commit is contained in:
parent
f868ebb4bc
commit
368d6780c2
3 changed files with 21 additions and 11 deletions
11
ChangeLog
11
ChangeLog
|
@ -1,3 +1,14 @@
|
|||
2004-05-08 Benjamin Otte <otte@gnome.org>
|
||||
|
||||
* gst/level/gstlevel.c: (gst_level_link), (gst_level_chain),
|
||||
(gst_level_change_state), (gst_level_init):
|
||||
* gst/level/gstlevel.h:
|
||||
figure out if we're initialized directly instead of keeping a
|
||||
variable that's wrong in 90% of cases
|
||||
don't initialize pads and then leak them and use a new unitialized
|
||||
pad. (fixes #142084)
|
||||
these were bugs so n00bish I didn't find them for an hour :/
|
||||
|
||||
2004-05-08 Iain <iain@prettypeople.org>
|
||||
|
||||
* gst/wavparse/gstwavparse.[ch]: Rewrote to use RiffRead instead.
|
||||
|
|
|
@ -165,8 +165,6 @@ gst_level_link (GstPad * pad, const GstCaps * caps)
|
|||
filter->MS[i] = filter->RMS_dB[i] = 0.0;
|
||||
}
|
||||
|
||||
filter->inited = TRUE;
|
||||
|
||||
return GST_PAD_LINK_OK;
|
||||
}
|
||||
|
||||
|
@ -196,6 +194,13 @@ gst_level_fast_16bit_chain (gint16 * in, guint num, gint channels,
|
|||
g_return_if_fail (filter != NULL);
|
||||
g_return_if_fail (GST_IS_LEVEL (filter));
|
||||
|
||||
if (!gst_pad_is_negotiated (pad)) {
|
||||
GST_ELEMENT_ERROR (filter, CORE, NEGOTIATION, (NULL),
|
||||
("sinkpad not negotiated"));
|
||||
gst_data_unref (_data);
|
||||
return;
|
||||
}
|
||||
|
||||
for (i = 0; i < filter->channels; ++i)
|
||||
filter->CS[i] = filter->peak[i] = filter->MS[i] = filter->RMS_dB[i] = 0.0;
|
||||
|
||||
|
@ -288,12 +293,8 @@ gst_level_fast_16bit_chain (gint16 * in, guint num, gint channels,
|
|||
static GstElementStateReturn
|
||||
gst_level_change_state (GstElement * element)
|
||||
{
|
||||
GstLevel *filter = GST_LEVEL (element);
|
||||
|
||||
switch (GST_STATE_TRANSITION (element)) {
|
||||
case GST_STATE_PAUSED_TO_PLAYING:
|
||||
if (!filter->inited)
|
||||
return GST_STATE_FAILURE;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -418,15 +419,14 @@ gst_level_init (GstLevel * filter)
|
|||
(&sink_template_factory), "sink");
|
||||
gst_pad_set_link_function (filter->sinkpad, gst_level_link);
|
||||
gst_pad_set_getcaps_function (filter->sinkpad, gst_pad_proxy_getcaps);
|
||||
gst_element_add_pad (GST_ELEMENT (filter), filter->sinkpad);
|
||||
gst_pad_set_chain_function (filter->sinkpad, gst_level_chain);
|
||||
|
||||
filter->srcpad =
|
||||
gst_pad_new_from_template (gst_static_pad_template_get
|
||||
(&src_template_factory), "src");
|
||||
gst_pad_set_link_function (filter->srcpad, gst_level_link);
|
||||
gst_pad_set_getcaps_function (filter->srcpad, gst_pad_proxy_getcaps);
|
||||
|
||||
gst_element_add_pad (GST_ELEMENT (filter), filter->sinkpad);
|
||||
gst_pad_set_chain_function (filter->sinkpad, gst_level_chain);
|
||||
filter->srcpad = gst_pad_new ("src", GST_PAD_SRC);
|
||||
gst_element_add_pad (GST_ELEMENT (filter), filter->srcpad);
|
||||
|
||||
filter->CS = NULL;
|
||||
|
|
|
@ -54,7 +54,6 @@ struct _GstLevel {
|
|||
|
||||
GstPad *sinkpad, *srcpad;
|
||||
gboolean signal; /* whether or not to emit signals */
|
||||
gboolean inited; /* whether or not the element is initialized */
|
||||
gdouble interval; /* how many seconds between emits */
|
||||
|
||||
gint rate; /* caps variables */
|
||||
|
|
Loading…
Reference in a new issue