+2007-04-18 Michael Smith <msmith@fluendo.com>
+
+ * gst/cutter/gstcutter.c: (gst_cutter_init), (gst_cutter_chain),
+ (gst_cutter_get_caps):
+ * gst/cutter/gstcutter.h:
+ Fix some of the most obvious bugs in cutter. Now doesn't leak
+ everything if input is silent.
+
2007-04-18 Sebastian Dröge <slomo@circular-chaos.org>
* gst/wavenc/gstwavenc.c: (gst_wavenc_create_header_buf),
filter->threshold_length = CUTTER_DEFAULT_THRESHOLD_LENGTH;
filter->silent_run_length = 0 * GST_SECOND;
filter->silent = TRUE;
+ filter->silent_prev = FALSE; /* previous value of silent */
filter->pre_length = CUTTER_DEFAULT_PRE_LENGTH;
filter->pre_run_length = 0 * GST_SECOND;
gdouble NCS = 0.0; /* Normalized Cumulative Square of buffer */
gdouble RMS = 0.0; /* RMS of signal in buffer */
gdouble NMS = 0.0; /* Normalized Mean Square of buffer */
- static gboolean silent_prev = FALSE; /* previous value of silent */
GstBuffer *prebuf; /* pointer to a prebuffer element */
g_return_val_if_fail (pad != NULL, GST_FLOW_ERROR);
g_return_val_if_fail (filter != NULL, GST_FLOW_ERROR);
g_return_val_if_fail (GST_IS_CUTTER (filter), GST_FLOW_ERROR);
- if (gst_audio_is_buffer_framed (pad, buf) == FALSE) {
- g_warning ("audio buffer is not framed !\n");
- return GST_FLOW_ERROR;
- }
-
if (!filter->have_caps)
gst_cutter_get_caps (pad, filter);
break;
}
- silent_prev = filter->silent;
+ filter->silent_prev = filter->silent;
RMS = sqrt (NMS);
/* if RMS below threshold, add buffer length to silent run length count
/* has the silent status changed ? if so, send right signal
* and, if from silent -> not silent, flush pre_record buffer
*/
- if (filter->silent != silent_prev) {
+ if (filter->silent != filter->silent_prev) {
if (filter->silent) {
GstMessage *m =
gst_cutter_message_new (filter, FALSE, GST_BUFFER_TIMESTAMP (buf));
/* only pass buffers if we don't leak */
if (!filter->leaky)
gst_pad_push (filter->srcpad, prebuf);
+ else
+ gst_buffer_unref (prebuf);
}
} else
gst_pad_push (filter->srcpad, buf);
void
gst_cutter_get_caps (GstPad * pad, GstCutter * filter)
{
- const GstCaps *caps = NULL;
+ GstCaps *caps;
GstStructure *structure;
- caps = GST_PAD_CAPS (pad);
+ caps = gst_pad_get_caps (pad);
/* FIXME : Please change this to a better warning method ! */
g_assert (caps != NULL);
structure = gst_caps_get_structure (caps, 0);
gst_structure_get_int (structure, "width", &filter->width);
filter->max_sample = 1 << (filter->width - 1); /* signed */
filter->have_caps = TRUE;
+
+ gst_caps_unref (caps);
}