};
#define ALLOWED_CAPS \
- "audio/x-raw-float, " \
- " width = (int) 32, " \
- " endianness = (int) BYTE_ORDER, " \
+ "audio/x-raw, " \
+ " format = (string) " GST_AUDIO_NE (F32) ", " \
" rate = (int) [ 8000, MAX ], " \
" channels = (int) [ 1, 2 ]"
-GST_BOILERPLATE (GstBPMDetect, gst_bpm_detect, GstAudioFilter,
- GST_TYPE_AUDIO_FILTER);
+#define gst_bpm_detect_parent_class parent_class
+G_DEFINE_TYPE (GstBPMDetect, gst_bpm_detect, GST_TYPE_AUDIO_FILTER);
static void gst_bpm_detect_finalize (GObject * object);
static gboolean gst_bpm_detect_stop (GstBaseTransform * trans);
static GstFlowReturn gst_bpm_detect_transform_ip (GstBaseTransform * trans,
GstBuffer * in);
static gboolean gst_bpm_detect_setup (GstAudioFilter * filter,
- GstRingBufferSpec * format);
-
-static void
-gst_bpm_detect_base_init (gpointer g_class)
-{
- GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
- GstCaps *caps;
-
- gst_element_class_set_details_simple (element_class, "BPM Detector",
- "Filter/Analyzer/Audio", "Detect the BPM of an audio stream",
- "Sebastian Dröge <slomo@circular-chaos.org>");
-
- caps = gst_caps_from_string (ALLOWED_CAPS);
- gst_audio_filter_class_add_pad_templates (GST_AUDIO_FILTER_CLASS (g_class),
- caps);
- gst_caps_unref (caps);
-}
+ const GstAudioInfo * info);
static void
gst_bpm_detect_class_init (GstBPMDetectClass * klass)
{
+ GstCaps *caps;
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+ GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
GstBaseTransformClass *trans_class = GST_BASE_TRANSFORM_CLASS (klass);
GstAudioFilterClass *filter_class = GST_AUDIO_FILTER_CLASS (klass);
gobject_class->finalize = gst_bpm_detect_finalize;
+ gst_element_class_set_details_simple (element_class, "BPM Detector",
+ "Filter/Analyzer/Audio", "Detect the BPM of an audio stream",
+ "Sebastian Dröge <slomo@circular-chaos.org>");
+
+ caps = gst_caps_from_string (ALLOWED_CAPS);
+ gst_audio_filter_class_add_pad_templates (GST_AUDIO_FILTER_CLASS (klass),
+ caps);
+ gst_caps_unref (caps);
+
trans_class->stop = GST_DEBUG_FUNCPTR (gst_bpm_detect_stop);
- trans_class->event = GST_DEBUG_FUNCPTR (gst_bpm_detect_event);
+ trans_class->sink_event = GST_DEBUG_FUNCPTR (gst_bpm_detect_event);
trans_class->transform_ip = GST_DEBUG_FUNCPTR (gst_bpm_detect_transform_ip);
trans_class->passthrough_on_same_caps = TRUE;
}
static void
-gst_bpm_detect_init (GstBPMDetect * bpm_detect, GstBPMDetectClass * g_class)
+gst_bpm_detect_init (GstBPMDetect * bpm_detect)
{
bpm_detect->priv = G_TYPE_INSTANCE_GET_PRIVATE ((bpm_detect),
GST_TYPE_BPM_DETECT, GstBPMDetectPrivate);
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_FLUSH_STOP:
case GST_EVENT_EOS:
- case GST_EVENT_NEWSEGMENT:
+ case GST_EVENT_SEGMENT:
if (bpm_detect->priv->detect) {
delete bpm_detect->priv->detect;
}
static gboolean
-gst_bpm_detect_setup (GstAudioFilter * filter, GstRingBufferSpec * format)
+gst_bpm_detect_setup (GstAudioFilter * filter, const GstAudioInfo * info)
{
GstBPMDetect *bpm_detect = GST_BPM_DETECT (filter);
GstAudioFilter *filter = GST_AUDIO_FILTER (trans);
gint nsamples;
gfloat bpm;
+ GstMapInfo info;
if (G_UNLIKELY (!bpm_detect->priv->detect)) {
- if (filter->format.channels == 0 || filter->format.rate == 0) {
+ if (GST_AUDIO_INFO_FORMAT (&filter->info) == GST_AUDIO_FORMAT_UNKNOWN) {
GST_ERROR_OBJECT (bpm_detect, "No channels or rate set yet");
return GST_FLOW_ERROR;
}
#ifdef HAVE_SOUNDTOUCH_1_4
bpm_detect->priv->detect =
- new soundtouch::BPMDetect (filter->format.channels,
- filter->format.rate);
+ new soundtouch::BPMDetect (GST_AUDIO_INFO_CHANNELS (&filter->info),
+ GST_AUDIO_INFO_RATE (&filter->info));
#else
bpm_detect->priv->detect =
- new BPMDetect (filter->format.channels, filter->format.rate);
+ new BPMDetect (GST_AUDIO_INFO_CHANNELS (&filter->info),
+ GST_AUDIO_INFO_RATE (&filter->info));
#endif
}
- nsamples = GST_BUFFER_SIZE (in) / (4 * filter->format.channels);
+ gst_buffer_map (in, &info, GST_MAP_READ);
+
+ nsamples = info.size / (4 * GST_AUDIO_INFO_CHANNELS (&filter->info));
/* For stereo BPMDetect->inputSamples() does downmixing into the input
* data but our buffer data shouldn't be modified.
*/
- if (filter->format.channels == 1) {
- gfloat *inbuf = (gfloat *) GST_BUFFER_DATA (in);
+ if (GST_AUDIO_INFO_CHANNELS (&filter->info) == 1) {
+ gfloat *inbuf = (gfloat *) info.data;
while (nsamples > 0) {
bpm_detect->priv->detect->inputSamples (inbuf, MIN (nsamples, 2048));
} else {
gfloat *inbuf, *intmp, data[2 * 2048];
- inbuf = (gfloat *) GST_BUFFER_DATA (in);
+ inbuf = (gfloat *) info.data;
intmp = data;
while (nsamples > 0) {
inbuf += 2048 * 2;
}
}
+ gst_buffer_unmap (in, &info);
bpm = bpm_detect->priv->detect->getBpm ();
if (bpm >= 1.0 && fabs (bpm_detect->bpm - bpm) >= 1.0) {
- GstTagList *tags = gst_tag_list_new ();
+ GstTagList *tags = gst_tag_list_new_empty ();
gst_tag_list_add (tags, GST_TAG_MERGE_REPLACE_ALL, GST_TAG_BEATS_PER_MINUTE,
bpm, (void *) NULL);
- gst_element_found_tags (GST_ELEMENT (bpm_detect), tags);
+ gst_pad_push_event (trans->srcpad, gst_event_new_tag ("bpmdetect", tags));
GST_INFO_OBJECT (bpm_detect, "Detected BPM: %lf\n", bpm);
bpm_detect->bpm = bpm;
#include <soundtouch/SoundTouch.h>
#include <gst/gst.h>
-#include <gst/controller/gstcontroller.h>
+#include <gst/audio/audio.h>
+
#include "gstpitch.hh"
#include <math.h>
};
#define SUPPORTED_CAPS \
-GST_STATIC_CAPS( \
- "audio/x-raw-float, " \
+ "audio/x-raw, " \
+ "format = (string) " GST_AUDIO_NE (F32) ", " \
"rate = (int) [ 8000, MAX ], " \
- "channels = (int) [ 1, 2 ], " \
- "endianness = (int) BYTE_ORDER, " \
- "width = (int) 32" \
-)
+ "channels = (int) [ 1, 2 ]"
static GstStaticPadTemplate gst_pitch_sink_template =
GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
- SUPPORTED_CAPS);
+ GST_STATIC_CAPS (SUPPORTED_CAPS));
static GstStaticPadTemplate gst_pitch_src_template =
GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
- SUPPORTED_CAPS);
+ GST_STATIC_CAPS (SUPPORTED_CAPS));
static void gst_pitch_dispose (GObject * object);
static void gst_pitch_set_property (GObject * object,
guint prop_id, GValue * value, GParamSpec * pspec);
-static gboolean gst_pitch_sink_setcaps (GstPad * pad, GstCaps * caps);
-static GstFlowReturn gst_pitch_chain (GstPad * pad, GstBuffer * buffer);
+static gboolean gst_pitch_setcaps (GstPitch * pitch, GstCaps * caps);
+static GstFlowReturn gst_pitch_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer);
static GstStateChangeReturn gst_pitch_change_state (GstElement * element,
GstStateChange transition);
-static gboolean gst_pitch_sink_event (GstPad * pad, GstEvent * event);
-static gboolean gst_pitch_src_event (GstPad * pad, GstEvent * event);
-
-static gboolean gst_pitch_src_query (GstPad * pad, GstQuery * query);
-static const GstQueryType *gst_pitch_get_query_types (GstPad * pad);
-
-GST_BOILERPLATE (GstPitch, gst_pitch, GstElement, GST_TYPE_ELEMENT);
-
-static void
-gst_pitch_base_init (gpointer g_class)
-{
- GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class);
+static gboolean gst_pitch_sink_event (GstPad * pad, GstObject * parent, GstEvent * event);
+static gboolean gst_pitch_src_event (GstPad * pad, GstObject * parent, GstEvent * event);
- gst_element_class_add_pad_template (gstelement_class,
- gst_static_pad_template_get (&gst_pitch_src_template));
- gst_element_class_add_pad_template (gstelement_class,
- gst_static_pad_template_get (&gst_pitch_sink_template));
+static gboolean gst_pitch_src_query (GstPad * pad, GstObject * parent, GstQuery * query);
- gst_element_class_set_details_simple (gstelement_class, "Pitch controller",
- "Filter/Converter/Audio", "Control the pitch of an audio stream",
- "Wouter Paesen <wouter@blue-gate.be>");
-}
+#define gst_pitch_parent_class parent_class
+G_DEFINE_TYPE (GstPitch, gst_pitch, GST_TYPE_ELEMENT);
static void
gst_pitch_class_init (GstPitchClass * klass)
GST_DEBUG_CATEGORY_INIT (pitch_debug, "pitch", 0,
"audio pitch control element");
+ g_type_class_add_private (gobject_class, sizeof (GstPitchPrivate));
+
gobject_class->set_property = gst_pitch_set_property;
gobject_class->get_property = gst_pitch_get_property;
gobject_class->dispose = GST_DEBUG_FUNCPTR (gst_pitch_dispose);
- element_class->change_state = GST_DEBUG_FUNCPTR (gst_pitch_change_state);
g_object_class_install_property (gobject_class, ARG_PITCH,
g_param_spec_float ("pitch", "Pitch",
"Output rate on downstream segment events", 0.1, 10.0, 1.0,
(GParamFlags) (G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE | G_PARAM_STATIC_STRINGS)));
- g_type_class_add_private (gobject_class, sizeof (GstPitchPrivate));
+ element_class->change_state = GST_DEBUG_FUNCPTR (gst_pitch_change_state);
+
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&gst_pitch_src_template));
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&gst_pitch_sink_template));
+
+ gst_element_class_set_details_simple (element_class, "Pitch controller",
+ "Filter/Converter/Audio", "Control the pitch of an audio stream",
+ "Wouter Paesen <wouter@blue-gate.be>");
}
static void
-gst_pitch_init (GstPitch * pitch, GstPitchClass * pitch_class)
+gst_pitch_init (GstPitch * pitch)
{
pitch->priv =
G_TYPE_INSTANCE_GET_PRIVATE ((pitch), GST_TYPE_PITCH, GstPitchPrivate);
GST_DEBUG_FUNCPTR (gst_pitch_chain));
gst_pad_set_event_function (pitch->sinkpad,
GST_DEBUG_FUNCPTR (gst_pitch_sink_event));
- gst_pad_set_setcaps_function (pitch->sinkpad,
- GST_DEBUG_FUNCPTR (gst_pitch_sink_setcaps));
- gst_pad_set_getcaps_function (pitch->sinkpad,
- GST_DEBUG_FUNCPTR (gst_pad_proxy_getcaps));
+ GST_PAD_SET_PROXY_CAPS (pitch->sinkpad);
gst_element_add_pad (GST_ELEMENT (pitch), pitch->sinkpad);
pitch->srcpad =
gst_pad_new_from_static_template (&gst_pitch_src_template, "src");
gst_pad_set_event_function (pitch->srcpad,
GST_DEBUG_FUNCPTR (gst_pitch_src_event));
- gst_pad_set_query_type_function (pitch->srcpad,
- GST_DEBUG_FUNCPTR (gst_pitch_get_query_types));
gst_pad_set_query_function (pitch->srcpad,
GST_DEBUG_FUNCPTR (gst_pitch_src_query));
- gst_pad_set_setcaps_function (pitch->srcpad,
- GST_DEBUG_FUNCPTR (gst_pitch_sink_setcaps));
- gst_pad_set_getcaps_function (pitch->srcpad,
- GST_DEBUG_FUNCPTR (gst_pad_proxy_getcaps));
+ GST_PAD_SET_PROXY_CAPS (pitch->sinkpad);
gst_element_add_pad (GST_ELEMENT (pitch), pitch->srcpad);
pitch->priv->st = new soundtouch::SoundTouch ();
}
static gboolean
-gst_pitch_sink_setcaps (GstPad * pad, GstCaps * caps)
+gst_pitch_setcaps (GstPitch * pitch, GstCaps * caps)
{
- GstPitch *pitch;
GstPitchPrivate *priv;
GstStructure *structure;
- GstPad *otherpad;
gint rate, channels;
- pitch = GST_PITCH (GST_PAD_PARENT (pad));
priv = GST_PITCH_GET_PRIVATE (pitch);
- otherpad = (pad == pitch->srcpad) ? pitch->sinkpad : pitch->srcpad;
-
- if (!gst_pad_set_caps (otherpad, caps))
- return FALSE;
-
structure = gst_caps_get_structure (caps, 0);
if (!gst_structure_get_int (structure, "rate", &rate) ||
GstPitchPrivate *priv;
guint samples;
GstBuffer *buffer;
+ GstMapInfo info;
priv = GST_PITCH_GET_PRIVATE (pitch);
if (samples == 0)
return NULL;
- if (gst_pad_alloc_buffer_and_set_caps (pitch->srcpad, GST_BUFFER_OFFSET_NONE,
- samples * pitch->sample_size, GST_PAD_CAPS (pitch->srcpad), &buffer)
- != GST_FLOW_OK) {
- buffer = gst_buffer_new_and_alloc (samples * pitch->sample_size);
- gst_buffer_set_caps (buffer, GST_PAD_CAPS (pitch->srcpad));
- }
+ buffer = gst_buffer_new_and_alloc (samples * pitch->sample_size);
+ gst_buffer_map (buffer, &info, (GstMapFlags) GST_MAP_READWRITE);
samples =
- priv->st->receiveSamples ((gfloat *) GST_BUFFER_DATA (buffer), samples);
+ priv->st->receiveSamples ((gfloat *) info.data, samples);
+ gst_buffer_unmap (buffer, &info);
if (samples <= 0) {
gst_buffer_unref (buffer);
}
static gboolean
-gst_pitch_src_event (GstPad * pad, GstEvent * event)
+gst_pitch_src_event (GstPad * pad, GstObject * parent, GstEvent * event)
{
GstPitch *pitch;
gboolean res;
- pitch = GST_PITCH (gst_pad_get_parent (pad));
+ pitch = GST_PITCH (parent);
GST_DEBUG_OBJECT (pad, "received %s event", GST_EVENT_TYPE_NAME (event));
event = gst_event_new_seek (rate, format, flags,
cur_type, cur, stop_type, stop);
- res = gst_pad_event_default (pad, event);
+ res = gst_pad_event_default (pad, parent, event);
} else {
GST_WARNING_OBJECT (pitch,
"Seeking only supported in TIME or DEFAULT format");
res = FALSE;
}
-
break;
}
default:
- res = gst_pad_event_default (pad, event);
+ res = gst_pad_event_default (pad, parent, event);
break;
}
-
- gst_object_unref (pitch);
return res;
}
return res;
}
-static const GstQueryType *
-gst_pitch_get_query_types (GstPad * pad)
-{
- static const GstQueryType types[] = {
- GST_QUERY_POSITION,
- GST_QUERY_DURATION,
- GST_QUERY_CONVERT,
- GST_QUERY_LATENCY,
- GST_QUERY_NONE
- };
-
- return types;
-}
-
static gboolean
-gst_pitch_src_query (GstPad * pad, GstQuery * query)
+gst_pitch_src_query (GstPad * pad, GstObject * parent, GstQuery * query)
{
GstPitch *pitch;
gboolean res = FALSE;
gint64 next_buffer_offset;
GstClockTime next_buffer_time;
- pitch = GST_PITCH (gst_pad_get_parent (pad));
+ pitch = GST_PITCH (parent);
+
GST_LOG ("%s query", GST_QUERY_TYPE_NAME (query));
+
GST_OBJECT_LOCK (pitch);
stream_time_ratio = pitch->priv->stream_time_ratio;
next_buffer_time = pitch->next_buffer_time;
GstFormat format;
gint64 duration;
- if (!gst_pad_query_default (pad, query)) {
+ if (!gst_pad_query_default (pad, parent, query)) {
GST_DEBUG_OBJECT (pitch, "upstream provided no duration");
break;
}
break;
}
default:
- res = gst_pad_query_default (pad, query);
+ res = gst_pad_query_default (pad, parent, query);
break;
}
- gst_object_unref (pitch);
return res;
}
static gboolean
gst_pitch_process_segment (GstPitch * pitch, GstEvent ** event)
{
- GstFormat format, conv_format;
- gint64 start_value, stop_value, base;
+ GstFormat conv_format;
gint64 next_offset = 0, next_time = 0;
- gboolean update = FALSE;
- gdouble rate, out_seg_rate, arate, our_arate;
+ gdouble out_seg_rate, our_arate;
gfloat stream_time_ratio;
+ GstSegment seg;
g_return_val_if_fail (event, FALSE);
out_seg_rate = pitch->out_seg_rate;
GST_OBJECT_UNLOCK (pitch);
- gst_event_parse_new_segment_full (*event, &update, &rate, &arate, &format, &start_value,
- &stop_value, &base);
+ gst_event_copy_segment (*event, &seg);
- if (format != GST_FORMAT_TIME && format != GST_FORMAT_DEFAULT) {
+ if (seg.format != GST_FORMAT_TIME && seg.format != GST_FORMAT_DEFAULT) {
GST_WARNING_OBJECT (pitch,
"Only NEWSEGMENT in TIME or DEFAULT format supported, sending"
"open ended NEWSEGMENT in TIME format.");
- gst_event_unref (*event);
- *event =
- gst_event_new_new_segment_full (update, rate, arate, GST_FORMAT_TIME, 0, -1, 0);
- start_value = 0;
- stop_value = -1;
- base = 0;
+ seg.format = GST_FORMAT_TIME;
+ seg.start = 0;
+ seg.stop = -1;
+ seg.time = 0;
}
/* Figure out how much of the incoming 'rate' we'll apply ourselves */
- our_arate = rate / out_seg_rate;
+ our_arate = seg.rate / out_seg_rate;
/* update the output rate variables */
- rate = out_seg_rate;
- arate *= our_arate;
+ seg.rate = out_seg_rate;
+ seg.applied_rate *= our_arate;
GST_LOG_OBJECT (pitch->sinkpad,
- "segment %" G_GINT64_FORMAT " - %" G_GINT64_FORMAT " (%d)", start_value,
- stop_value, format);
+ "segment %" G_GINT64_FORMAT " - %" G_GINT64_FORMAT " (%d)", seg.start,
+ seg.stop, seg.format);
stream_time_ratio = pitch->tempo * pitch->rate * pitch->seg_arate;
pitch->priv->st->setTempo (pitch->tempo * pitch->seg_arate);
GST_OBJECT_UNLOCK (pitch);
- start_value = (gint64) (start_value / stream_time_ratio);
- if (stop_value != -1)
- stop_value = (gint64) (stop_value / stream_time_ratio);
- base = (gint64) (base / stream_time_ratio);
+ seg.start = (gint64) (seg.start / stream_time_ratio);
+ if (seg.stop != (guint64) -1)
+ seg.stop = (gint64) (seg.stop / stream_time_ratio);
+ seg.time = (gint64) (seg.time / stream_time_ratio);
conv_format = GST_FORMAT_TIME;
- if (!gst_pitch_convert (pitch, format, start_value, &conv_format, &next_time)) {
+ if (!gst_pitch_convert (pitch, seg.format, seg.start, &conv_format, &next_time)) {
GST_LOG_OBJECT (pitch->sinkpad,
"could not convert segment start value to time");
return FALSE;
}
conv_format = GST_FORMAT_DEFAULT;
- if (!gst_pitch_convert (pitch, format, start_value, &conv_format,
+ if (!gst_pitch_convert (pitch, seg.format, seg.start, &conv_format,
&next_offset)) {
GST_LOG_OBJECT (pitch->sinkpad,
"could not convert segment start value to offset");
pitch->next_buffer_offset = next_offset;
gst_event_unref (*event);
- *event = gst_event_new_new_segment_full (update, rate, arate, format,
- start_value, stop_value, base);
+ *event = gst_event_new_segment (&seg);
return TRUE;
}
static gboolean
-gst_pitch_sink_event (GstPad * pad, GstEvent * event)
+gst_pitch_sink_event (GstPad * pad, GstObject * parent, GstEvent * event)
{
gboolean res = TRUE;
GstPitch *pitch;
- pitch = GST_PITCH (gst_pad_get_parent (pad));
+ pitch = GST_PITCH (parent);
GST_LOG_OBJECT (pad, "received %s event", GST_EVENT_TYPE_NAME (event));
pitch->priv->st->clear ();
pitch->min_latency = pitch->max_latency = 0;
break;
- case GST_EVENT_NEWSEGMENT:
+ case GST_EVENT_SEGMENT:
if (!gst_pitch_process_segment (pitch, &event)) {
GST_LOG_OBJECT (pad, "not enough data known, stalling segment");
if (GST_PITCH_GET_PRIVATE (pitch)->pending_segment)
pitch->priv->st->clear ();
pitch->min_latency = pitch->max_latency = 0;
break;
+ case GST_EVENT_CAPS:
+ {
+ GstCaps * caps;
+
+ gst_event_parse_caps (event, &caps);
+ res = gst_pitch_setcaps (pitch, caps);
+ if (!res) {
+ gst_event_unref (event);
+ goto done;
+ }
+ }
default:
break;
}
/* and forward it */
if (event)
- res = gst_pad_event_default (pad, event);
+ res = gst_pad_event_default (pad, parent, event);
- gst_object_unref (pitch);
+done:
return res;
}
}
static GstFlowReturn
-gst_pitch_chain (GstPad * pad, GstBuffer * buffer)
+gst_pitch_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
{
GstPitch *pitch;
GstPitchPrivate *priv;
GstClockTime timestamp;
+ GstMapInfo info;
- pitch = GST_PITCH (GST_PAD_PARENT (pad));
+ pitch = GST_PITCH (parent);
priv = GST_PITCH_GET_PRIVATE (pitch);
- gst_object_sync_values (G_OBJECT (pitch), pitch->next_buffer_time);
+ gst_object_sync_values (GST_OBJECT (pitch), pitch->next_buffer_time);
timestamp = GST_BUFFER_TIMESTAMP (buffer);
/* push the received samples on the soundtouch buffer */
GST_LOG_OBJECT (pitch, "incoming buffer (%d samples)",
- (gint) (GST_BUFFER_SIZE (buffer) / pitch->sample_size));
+ (gint) (gst_buffer_get_size (buffer) / pitch->sample_size));
if (GST_PITCH_GET_PRIVATE (pitch)->pending_segment) {
GstEvent *event =
GST_LOG_OBJECT (pitch, "processing stalled segment");
if (!gst_pitch_process_segment (pitch, &event)) {
+ gst_buffer_unref (buffer);
gst_event_unref (event);
return GST_FLOW_ERROR;
}
- if (!gst_pad_event_default (pitch->sinkpad, event)) {
+ if (!gst_pad_event_default (pitch->sinkpad, parent, event)) {
+ gst_buffer_unref (buffer);
gst_event_unref (event);
return GST_FLOW_ERROR;
}
GST_PITCH_GET_PRIVATE (pitch)->pending_segment = NULL;
}
- priv->st->putSamples ((gfloat *) GST_BUFFER_DATA (buffer),
- GST_BUFFER_SIZE (buffer) / pitch->sample_size);
+ gst_buffer_map (buffer, &info, GST_MAP_READ);
+ priv->st->putSamples ((gfloat *) info.data, info.size / pitch->sample_size);
+ gst_buffer_unmap (buffer, &info);
gst_buffer_unref (buffer);
/* Calculate latency */
gst_pitch_update_latency (pitch, timestamp);
-
/* and try to extract some samples from the soundtouch buffer */
if (!priv->st->isEmpty ()) {
GstBuffer *out_buffer;
break;
}
- ret = parent_class->change_state (element, transition);
+ ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
if (ret != GST_STATE_CHANGE_SUCCESS)
return ret;