2005-08-25 09:32:22 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
|
|
|
|
* 2000 Wim Taymans <wtay@chello.be>
|
|
|
|
* 2005 Wim Taymans <wim@fluendo.com>
|
|
|
|
*
|
|
|
|
* gstsignalprocessor.c:
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
2009-03-25 21:04:13 +00:00
|
|
|
/*
|
|
|
|
* SECTION:gstsignalprocessor
|
|
|
|
*
|
|
|
|
* This baseclass allows to write elements that need data on all pads before
|
|
|
|
* their processing function can run.
|
|
|
|
*
|
|
|
|
* In push mode (gst_signal_processor_chain) it operates as follows:
|
|
|
|
* 1. store each received buffer on the pad and decrement pending_in
|
|
|
|
* 2. when pending_in==0, process as much as we can and push outputs
|
|
|
|
*
|
2009-07-04 00:00:11 +00:00
|
|
|
* In pull mode (gst_signal_processor_getrange) it operates as follows:
|
2009-03-25 21:04:13 +00:00
|
|
|
* 1. if there is an output ready, deliver
|
|
|
|
* 2. otherwise pull from each sink-pad, process requested frames and deliver
|
|
|
|
* the buffer
|
|
|
|
*/
|
2005-08-25 09:32:22 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2010-01-11 19:41:57 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2005-08-25 09:32:22 +00:00
|
|
|
#include <gst/audio/audio.h>
|
|
|
|
#include "gstsignalprocessor.h"
|
|
|
|
|
|
|
|
|
|
|
|
GST_DEBUG_CATEGORY_STATIC (gst_signal_processor_debug);
|
|
|
|
#define GST_CAT_DEFAULT gst_signal_processor_debug
|
|
|
|
|
|
|
|
#define GST_TYPE_SIGNAL_PROCESSOR_PAD_TEMPLATE \
|
|
|
|
(gst_signal_processor_pad_template_get_type ())
|
|
|
|
#define GST_SIGNAL_PROCESSOR_PAD_TEMPLATE(obj) \
|
|
|
|
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_SIGNAL_PROCESSOR_PAD_TEMPLATE,\
|
|
|
|
GstSignalProcessorPadTemplate))
|
|
|
|
typedef struct _GstSignalProcessorPadTemplate GstSignalProcessorPadTemplate;
|
|
|
|
typedef GstPadTemplateClass GstSignalProcessorPadTemplateClass;
|
|
|
|
|
|
|
|
struct _GstSignalProcessorPadTemplate
|
|
|
|
{
|
|
|
|
GstPadTemplate parent;
|
|
|
|
|
|
|
|
guint index;
|
2009-07-04 00:00:11 +00:00
|
|
|
guint channels;
|
2005-08-25 09:32:22 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static GType
|
|
|
|
gst_signal_processor_pad_template_get_type (void)
|
|
|
|
{
|
|
|
|
static GType type = 0;
|
|
|
|
|
|
|
|
if (!type) {
|
|
|
|
static const GTypeInfo info = {
|
|
|
|
sizeof (GstSignalProcessorPadTemplateClass), NULL, NULL, NULL, NULL,
|
|
|
|
NULL, sizeof (GstSignalProcessorPadTemplate), 0, NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
type = g_type_register_static (GST_TYPE_PAD_TEMPLATE,
|
|
|
|
"GstSignalProcessorPadTemplate", &info, 0);
|
|
|
|
}
|
|
|
|
return type;
|
|
|
|
}
|
|
|
|
|
2009-03-25 21:04:13 +00:00
|
|
|
/*
|
|
|
|
* gst_signal_processor_class_add_pad_template:
|
|
|
|
* @klass: element class
|
|
|
|
* @name: pad name
|
|
|
|
* @direction: pad direction (src/sink)
|
|
|
|
* @index: index for the pad per direction (starting from 0)
|
2009-08-12 05:03:32 +00:00
|
|
|
* @channels: number of channels in this pad
|
|
|
|
* @positions: array of channel positions in order
|
2009-03-25 21:04:13 +00:00
|
|
|
*
|
|
|
|
*/
|
2005-08-25 09:32:22 +00:00
|
|
|
void
|
|
|
|
gst_signal_processor_class_add_pad_template (GstSignalProcessorClass * klass,
|
2009-11-15 19:46:01 +00:00
|
|
|
const gchar * name, GstPadDirection direction, guint index, guint channels)
|
2005-08-25 09:32:22 +00:00
|
|
|
{
|
|
|
|
GstPadTemplate *new;
|
2009-03-25 21:04:13 +00:00
|
|
|
GstCaps *caps;
|
2005-08-25 09:32:22 +00:00
|
|
|
|
|
|
|
g_return_if_fail (GST_IS_SIGNAL_PROCESSOR_CLASS (klass));
|
|
|
|
g_return_if_fail (name != NULL);
|
|
|
|
g_return_if_fail (direction == GST_PAD_SRC || direction == GST_PAD_SINK);
|
|
|
|
|
2009-06-25 19:10:24 +00:00
|
|
|
caps = gst_caps_new_simple ("audio/x-raw-float",
|
|
|
|
"endianness", G_TYPE_INT, G_BYTE_ORDER,
|
2010-03-25 21:07:46 +00:00
|
|
|
"width", G_TYPE_INT, 32, "channels", G_TYPE_INT, channels,
|
|
|
|
"rate", GST_TYPE_INT_RANGE, 1, G_MAXINT, NULL);
|
2009-03-25 21:04:13 +00:00
|
|
|
|
2009-10-03 18:35:02 +00:00
|
|
|
new = g_object_new (GST_TYPE_SIGNAL_PROCESSOR_PAD_TEMPLATE,
|
2009-03-25 21:04:13 +00:00
|
|
|
"name", name, "name-template", name,
|
|
|
|
"direction", direction, "presence", GST_PAD_ALWAYS, "caps", caps, NULL);
|
2005-08-25 09:32:22 +00:00
|
|
|
|
2011-01-07 13:22:07 +00:00
|
|
|
gst_caps_unref (caps);
|
|
|
|
|
2005-08-25 09:32:22 +00:00
|
|
|
GST_SIGNAL_PROCESSOR_PAD_TEMPLATE (new)->index = index;
|
2009-07-04 00:00:11 +00:00
|
|
|
GST_SIGNAL_PROCESSOR_PAD_TEMPLATE (new)->channels = channels;
|
2005-08-25 09:32:22 +00:00
|
|
|
|
|
|
|
gst_element_class_add_pad_template (GST_ELEMENT_CLASS (klass), new);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#define GST_TYPE_SIGNAL_PROCESSOR_PAD (gst_signal_processor_pad_get_type ())
|
|
|
|
#define GST_SIGNAL_PROCESSOR_PAD(obj) \
|
|
|
|
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_SIGNAL_PROCESSOR_PAD,\
|
|
|
|
GstSignalProcessorPad))
|
|
|
|
typedef struct _GstSignalProcessorPad GstSignalProcessorPad;
|
|
|
|
typedef GstPadClass GstSignalProcessorPadClass;
|
|
|
|
|
|
|
|
struct _GstSignalProcessorPad
|
|
|
|
{
|
|
|
|
GstPad parent;
|
|
|
|
|
|
|
|
GstBuffer *pen;
|
|
|
|
|
2009-03-25 21:04:13 +00:00
|
|
|
/* index for the pad per direction (starting from 0) */
|
2005-08-25 09:32:22 +00:00
|
|
|
guint index;
|
2006-08-04 09:05:53 +00:00
|
|
|
|
2009-07-04 00:00:11 +00:00
|
|
|
/* number of channels for the pad */
|
|
|
|
guint channels;
|
|
|
|
|
2006-08-04 09:05:53 +00:00
|
|
|
/* these are only used for sink pads */
|
2009-03-25 21:04:13 +00:00
|
|
|
guint samples_avail; /* available mono sample frames */
|
|
|
|
gfloat *data; /* data pointer to read from / write to */
|
2005-08-25 09:32:22 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static GType
|
|
|
|
gst_signal_processor_pad_get_type (void)
|
|
|
|
{
|
|
|
|
static GType type = 0;
|
|
|
|
|
|
|
|
if (!type) {
|
|
|
|
static const GTypeInfo info = {
|
|
|
|
sizeof (GstSignalProcessorPadClass), NULL, NULL, NULL, NULL,
|
|
|
|
NULL, sizeof (GstSignalProcessorPad), 0, NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
type = g_type_register_static (GST_TYPE_PAD,
|
|
|
|
"GstSignalProcessorPad", &info, 0);
|
|
|
|
}
|
|
|
|
return type;
|
|
|
|
}
|
|
|
|
|
2011-10-04 11:33:53 +00:00
|
|
|
static GstElementClass *parent_class = NULL;
|
|
|
|
|
|
|
|
static void gst_signal_processor_class_init (GstSignalProcessorClass * klass);
|
|
|
|
static void gst_signal_processor_init (GstSignalProcessor * self,
|
|
|
|
GstSignalProcessorClass * klass);
|
2005-08-25 09:32:22 +00:00
|
|
|
|
2011-10-04 11:33:53 +00:00
|
|
|
GType
|
|
|
|
gst_signal_processor_get_type (void)
|
|
|
|
{
|
|
|
|
static volatile gsize signal_processor_type = 0;
|
|
|
|
|
|
|
|
if (g_once_init_enter (&signal_processor_type)) {
|
|
|
|
GType _type;
|
|
|
|
static const GTypeInfo signal_processor_info = {
|
|
|
|
sizeof (GstSignalProcessorClass),
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
(GClassInitFunc) gst_signal_processor_class_init,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
sizeof (GstSignalProcessor),
|
|
|
|
0,
|
|
|
|
(GInstanceInitFunc) gst_signal_processor_init,
|
|
|
|
};
|
2005-08-25 09:32:22 +00:00
|
|
|
|
2011-10-04 11:33:53 +00:00
|
|
|
_type = g_type_register_static (GST_TYPE_ELEMENT,
|
|
|
|
"GstSignalProcessor", &signal_processor_info, G_TYPE_FLAG_ABSTRACT);
|
|
|
|
g_once_init_leave (&signal_processor_type, _type);
|
|
|
|
}
|
|
|
|
return signal_processor_type;
|
|
|
|
}
|
2005-08-25 09:32:22 +00:00
|
|
|
|
|
|
|
static void gst_signal_processor_finalize (GObject * object);
|
|
|
|
static gboolean gst_signal_processor_src_activate_pull (GstPad * pad,
|
|
|
|
gboolean active);
|
|
|
|
static gboolean gst_signal_processor_sink_activate_push (GstPad * pad,
|
|
|
|
gboolean active);
|
2005-09-02 15:44:44 +00:00
|
|
|
static GstStateChangeReturn gst_signal_processor_change_state (GstElement *
|
2005-10-07 15:24:24 +00:00
|
|
|
element, GstStateChange transition);
|
2005-08-25 09:32:22 +00:00
|
|
|
|
|
|
|
static gboolean gst_signal_processor_event (GstPad * pad, GstEvent * event);
|
|
|
|
static GstFlowReturn gst_signal_processor_getrange (GstPad * pad,
|
|
|
|
guint64 offset, guint length, GstBuffer ** buffer);
|
|
|
|
static GstFlowReturn gst_signal_processor_chain (GstPad * pad,
|
|
|
|
GstBuffer * buffer);
|
|
|
|
static gboolean gst_signal_processor_setcaps (GstPad * pad, GstCaps * caps);
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_signal_processor_class_init (GstSignalProcessorClass * klass)
|
|
|
|
{
|
|
|
|
GObjectClass *gobject_class;
|
|
|
|
GstElementClass *gstelement_class;
|
|
|
|
|
|
|
|
gobject_class = G_OBJECT_CLASS (klass);
|
|
|
|
gstelement_class = GST_ELEMENT_CLASS (klass);
|
|
|
|
|
2011-10-04 11:33:53 +00:00
|
|
|
parent_class = g_type_class_peek_parent (klass);
|
|
|
|
|
2005-08-25 09:32:22 +00:00
|
|
|
gobject_class->finalize = GST_DEBUG_FUNCPTR (gst_signal_processor_finalize);
|
|
|
|
|
|
|
|
gstelement_class->change_state =
|
|
|
|
GST_DEBUG_FUNCPTR (gst_signal_processor_change_state);
|
2010-03-25 21:12:37 +00:00
|
|
|
|
|
|
|
GST_DEBUG_REGISTER_FUNCPTR (gst_signal_processor_setcaps);
|
2010-03-26 08:41:46 +00:00
|
|
|
GST_DEBUG_REGISTER_FUNCPTR (gst_signal_processor_event);
|
2010-03-25 21:12:37 +00:00
|
|
|
GST_DEBUG_REGISTER_FUNCPTR (gst_signal_processor_chain);
|
|
|
|
GST_DEBUG_REGISTER_FUNCPTR (gst_signal_processor_sink_activate_push);
|
|
|
|
GST_DEBUG_REGISTER_FUNCPTR (gst_signal_processor_getrange);
|
|
|
|
GST_DEBUG_REGISTER_FUNCPTR (gst_signal_processor_src_activate_pull);
|
2011-10-04 11:33:53 +00:00
|
|
|
|
|
|
|
GST_DEBUG_CATEGORY_INIT (gst_signal_processor_debug, "signalprocessor", 0,
|
|
|
|
"signalprocessor baseclass");
|
2005-08-25 09:32:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_signal_processor_add_pad_from_template (GstSignalProcessor * self,
|
|
|
|
GstPadTemplate * templ)
|
|
|
|
{
|
2010-01-31 13:53:27 +00:00
|
|
|
GstPad *pad;
|
2005-08-25 09:32:22 +00:00
|
|
|
|
2010-01-31 13:53:27 +00:00
|
|
|
pad = g_object_new (GST_TYPE_SIGNAL_PROCESSOR_PAD,
|
2005-08-28 17:59:20 +00:00
|
|
|
"name", GST_OBJECT_NAME (templ), "direction", templ->direction,
|
|
|
|
"template", templ, NULL);
|
2010-01-31 13:53:27 +00:00
|
|
|
GST_SIGNAL_PROCESSOR_PAD (pad)->index =
|
2005-08-25 09:32:22 +00:00
|
|
|
GST_SIGNAL_PROCESSOR_PAD_TEMPLATE (templ)->index;
|
2010-01-31 13:53:27 +00:00
|
|
|
GST_SIGNAL_PROCESSOR_PAD (pad)->channels =
|
2009-07-04 00:00:11 +00:00
|
|
|
GST_SIGNAL_PROCESSOR_PAD_TEMPLATE (templ)->channels;
|
2005-08-25 09:32:22 +00:00
|
|
|
|
|
|
|
if (templ->direction == GST_PAD_SINK) {
|
2010-01-31 13:53:27 +00:00
|
|
|
GST_DEBUG_OBJECT (pad, "added new sink pad");
|
ext/ladspa/gstsignalprocessor.c: Add debugs logs here and there, add more error handling, add some
Original commit message from CVS:
* ext/ladspa/gstsignalprocessor.c:
(gst_signal_processor_add_pad_from_template),
(gst_signal_processor_init), (gst_signal_processor_setcaps),
(gst_signal_processor_process), (gst_signal_processor_pen_buffer),
(gst_signal_processor_do_pulls), (gst_signal_processor_getrange),
(gst_signal_processor_sink_activate_push),
(gst_signal_processor_src_activate_pull),
(gst_signal_processor_change_state):
Add debugs logs here and there, add more error handling, add some
FIXME comments, filed #349189
2006-07-29 16:32:26 +00:00
|
|
|
|
2010-03-26 08:41:46 +00:00
|
|
|
gst_pad_set_event_function (pad, gst_signal_processor_event);
|
2010-03-25 21:12:37 +00:00
|
|
|
gst_pad_set_chain_function (pad, gst_signal_processor_chain);
|
2010-01-31 13:53:27 +00:00
|
|
|
gst_pad_set_activatepush_function (pad,
|
2010-03-25 21:12:37 +00:00
|
|
|
gst_signal_processor_sink_activate_push);
|
2005-08-25 09:32:22 +00:00
|
|
|
} else {
|
2010-01-31 13:53:27 +00:00
|
|
|
GST_DEBUG_OBJECT (pad, "added new src pad");
|
ext/ladspa/gstsignalprocessor.c: Add debugs logs here and there, add more error handling, add some
Original commit message from CVS:
* ext/ladspa/gstsignalprocessor.c:
(gst_signal_processor_add_pad_from_template),
(gst_signal_processor_init), (gst_signal_processor_setcaps),
(gst_signal_processor_process), (gst_signal_processor_pen_buffer),
(gst_signal_processor_do_pulls), (gst_signal_processor_getrange),
(gst_signal_processor_sink_activate_push),
(gst_signal_processor_src_activate_pull),
(gst_signal_processor_change_state):
Add debugs logs here and there, add more error handling, add some
FIXME comments, filed #349189
2006-07-29 16:32:26 +00:00
|
|
|
|
2010-03-25 21:12:37 +00:00
|
|
|
gst_pad_set_getrange_function (pad, gst_signal_processor_getrange);
|
2010-01-31 13:53:27 +00:00
|
|
|
gst_pad_set_activatepull_function (pad,
|
2010-03-25 21:12:37 +00:00
|
|
|
gst_signal_processor_src_activate_pull);
|
2005-08-25 09:32:22 +00:00
|
|
|
}
|
|
|
|
|
2010-01-31 13:53:27 +00:00
|
|
|
gst_element_add_pad (GST_ELEMENT (self), pad);
|
2005-08-25 09:32:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2005-08-28 17:59:20 +00:00
|
|
|
gst_signal_processor_init (GstSignalProcessor * self,
|
|
|
|
GstSignalProcessorClass * klass)
|
2005-08-25 09:32:22 +00:00
|
|
|
{
|
|
|
|
GList *templates;
|
|
|
|
|
|
|
|
templates =
|
2005-08-28 17:59:20 +00:00
|
|
|
gst_element_class_get_pad_template_list (GST_ELEMENT_CLASS (klass));
|
2005-08-25 09:32:22 +00:00
|
|
|
|
|
|
|
while (templates) {
|
|
|
|
GstPadTemplate *templ = GST_PAD_TEMPLATE (templates->data);
|
|
|
|
gst_signal_processor_add_pad_from_template (self, templ);
|
|
|
|
templates = templates->next;
|
|
|
|
}
|
2005-08-26 11:05:13 +00:00
|
|
|
|
2006-08-04 11:38:54 +00:00
|
|
|
self->state = GST_SIGNAL_PROCESSOR_STATE_NULL;
|
|
|
|
|
2009-07-04 00:00:11 +00:00
|
|
|
self->group_in = g_new0 (GstSignalProcessorGroup, klass->num_group_in);
|
|
|
|
self->group_out = g_new0 (GstSignalProcessorGroup, klass->num_group_out);
|
2005-08-26 11:05:13 +00:00
|
|
|
self->audio_in = g_new0 (gfloat *, klass->num_audio_in);
|
|
|
|
self->audio_out = g_new0 (gfloat *, klass->num_audio_out);
|
2009-07-04 00:00:11 +00:00
|
|
|
self->control_in = g_new0 (gfloat, klass->num_control_in);
|
2005-08-26 11:05:13 +00:00
|
|
|
self->control_out = g_new0 (gfloat, klass->num_control_out);
|
ext/ladspa/gstsignalprocessor.c: Add debugs logs here and there, add more error handling, add some
Original commit message from CVS:
* ext/ladspa/gstsignalprocessor.c:
(gst_signal_processor_add_pad_from_template),
(gst_signal_processor_init), (gst_signal_processor_setcaps),
(gst_signal_processor_process), (gst_signal_processor_pen_buffer),
(gst_signal_processor_do_pulls), (gst_signal_processor_getrange),
(gst_signal_processor_sink_activate_push),
(gst_signal_processor_src_activate_pull),
(gst_signal_processor_change_state):
Add debugs logs here and there, add more error handling, add some
FIXME comments, filed #349189
2006-07-29 16:32:26 +00:00
|
|
|
|
2006-07-31 22:27:22 +00:00
|
|
|
/* init */
|
2009-07-04 00:00:11 +00:00
|
|
|
self->pending_in = klass->num_group_in + klass->num_audio_in;
|
2006-07-31 22:27:22 +00:00
|
|
|
self->pending_out = 0;
|
2005-08-25 09:32:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_signal_processor_finalize (GObject * object)
|
|
|
|
{
|
2005-08-26 11:05:13 +00:00
|
|
|
GstSignalProcessor *self = GST_SIGNAL_PROCESSOR (object);
|
|
|
|
|
2009-07-04 00:00:11 +00:00
|
|
|
g_free (self->group_in);
|
|
|
|
self->group_in = NULL;
|
|
|
|
g_free (self->group_out);
|
|
|
|
self->group_out = NULL;
|
2005-08-26 11:05:13 +00:00
|
|
|
g_free (self->audio_in);
|
|
|
|
self->audio_in = NULL;
|
|
|
|
g_free (self->audio_out);
|
|
|
|
self->audio_out = NULL;
|
2009-07-04 00:00:11 +00:00
|
|
|
g_free (self->control_in);
|
|
|
|
self->control_in = NULL;
|
2005-08-26 11:05:13 +00:00
|
|
|
g_free (self->control_out);
|
|
|
|
self->control_out = NULL;
|
|
|
|
|
2005-08-25 09:32:22 +00:00
|
|
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
|
|
|
}
|
|
|
|
|
2006-08-04 11:38:54 +00:00
|
|
|
static gboolean
|
2009-11-16 19:50:20 +00:00
|
|
|
gst_signal_processor_setup (GstSignalProcessor * self, GstCaps * caps)
|
2006-08-04 11:38:54 +00:00
|
|
|
{
|
|
|
|
GstSignalProcessorClass *klass;
|
|
|
|
gboolean ret = TRUE;
|
|
|
|
|
|
|
|
klass = GST_SIGNAL_PROCESSOR_GET_CLASS (self);
|
|
|
|
|
2006-08-16 16:50:00 +00:00
|
|
|
GST_INFO_OBJECT (self, "setup()");
|
|
|
|
|
2006-08-04 11:38:54 +00:00
|
|
|
g_return_val_if_fail (self->state == GST_SIGNAL_PROCESSOR_STATE_NULL, FALSE);
|
|
|
|
|
|
|
|
if (klass->setup)
|
2009-11-16 19:50:20 +00:00
|
|
|
ret = klass->setup (self, caps);
|
2006-08-04 11:38:54 +00:00
|
|
|
|
|
|
|
if (!ret)
|
|
|
|
goto setup_failed;
|
|
|
|
|
|
|
|
self->state = GST_SIGNAL_PROCESSOR_STATE_INITIALIZED;
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
setup_failed:
|
|
|
|
{
|
2009-11-16 19:50:20 +00:00
|
|
|
GST_INFO_OBJECT (self, "setup() failed for caps: %" GST_PTR_FORMAT, caps);
|
2006-08-04 11:38:54 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gst_signal_processor_start (GstSignalProcessor * self)
|
|
|
|
{
|
|
|
|
GstSignalProcessorClass *klass;
|
|
|
|
gboolean ret = TRUE;
|
|
|
|
|
|
|
|
klass = GST_SIGNAL_PROCESSOR_GET_CLASS (self);
|
|
|
|
|
|
|
|
g_return_val_if_fail (self->state == GST_SIGNAL_PROCESSOR_STATE_INITIALIZED,
|
|
|
|
FALSE);
|
|
|
|
|
2006-08-16 16:50:00 +00:00
|
|
|
GST_INFO_OBJECT (self, "start()");
|
|
|
|
|
2006-08-04 11:38:54 +00:00
|
|
|
if (klass->start)
|
|
|
|
ret = klass->start (self);
|
|
|
|
|
|
|
|
if (!ret)
|
|
|
|
goto start_failed;
|
|
|
|
|
|
|
|
self->state = GST_SIGNAL_PROCESSOR_STATE_RUNNING;
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
start_failed:
|
|
|
|
{
|
|
|
|
GST_INFO_OBJECT (self, "start() failed");
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_signal_processor_stop (GstSignalProcessor * self)
|
|
|
|
{
|
|
|
|
GstSignalProcessorClass *klass;
|
2006-08-16 16:50:00 +00:00
|
|
|
GstElement *elem;
|
|
|
|
GList *sinks;
|
2006-08-04 11:38:54 +00:00
|
|
|
|
|
|
|
klass = GST_SIGNAL_PROCESSOR_GET_CLASS (self);
|
2006-08-16 16:50:00 +00:00
|
|
|
elem = GST_ELEMENT (self);
|
|
|
|
|
|
|
|
GST_INFO_OBJECT (self, "stop()");
|
2006-08-04 11:38:54 +00:00
|
|
|
|
|
|
|
g_return_if_fail (self->state == GST_SIGNAL_PROCESSOR_STATE_RUNNING);
|
|
|
|
|
|
|
|
if (klass->stop)
|
|
|
|
klass->stop (self);
|
|
|
|
|
2006-08-16 16:50:00 +00:00
|
|
|
for (sinks = elem->sinkpads; sinks; sinks = sinks->next)
|
2009-03-25 21:04:13 +00:00
|
|
|
/* force set_caps when going to RUNNING, see note in _setcaps () */
|
2006-08-16 16:50:00 +00:00
|
|
|
gst_pad_set_caps (GST_PAD (sinks->data), NULL);
|
|
|
|
|
2006-08-04 11:38:54 +00:00
|
|
|
/* should also flush our buffers perhaps? */
|
|
|
|
|
|
|
|
self->state = GST_SIGNAL_PROCESSOR_STATE_INITIALIZED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_signal_processor_cleanup (GstSignalProcessor * self)
|
|
|
|
{
|
|
|
|
GstSignalProcessorClass *klass;
|
2009-07-04 00:00:11 +00:00
|
|
|
gint i;
|
2006-08-04 11:38:54 +00:00
|
|
|
|
|
|
|
klass = GST_SIGNAL_PROCESSOR_GET_CLASS (self);
|
|
|
|
|
2006-08-16 16:50:00 +00:00
|
|
|
GST_INFO_OBJECT (self, "cleanup()");
|
|
|
|
|
2006-08-04 11:38:54 +00:00
|
|
|
g_return_if_fail (self->state == GST_SIGNAL_PROCESSOR_STATE_INITIALIZED);
|
|
|
|
|
|
|
|
if (klass->cleanup)
|
|
|
|
klass->cleanup (self);
|
|
|
|
|
2009-07-04 00:00:11 +00:00
|
|
|
for (i = 0; i < klass->num_group_in; ++i) {
|
|
|
|
g_free (self->group_in[i].buffer);
|
|
|
|
memset (&self->group_in[i], '\0', sizeof (GstSignalProcessorGroup));
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < klass->num_group_out; ++i) {
|
|
|
|
g_free (self->group_out[i].buffer);
|
|
|
|
memset (&self->group_in[i], '\0', sizeof (GstSignalProcessorGroup));
|
|
|
|
}
|
|
|
|
|
2006-08-04 11:38:54 +00:00
|
|
|
self->state = GST_SIGNAL_PROCESSOR_STATE_NULL;
|
|
|
|
}
|
|
|
|
|
2007-01-12 21:58:43 +00:00
|
|
|
static gboolean
|
|
|
|
gst_signal_processor_setcaps_pull (GstSignalProcessor * self, GstPad * pad,
|
|
|
|
GstCaps * caps)
|
|
|
|
{
|
|
|
|
if (GST_PAD_IS_SRC (pad)) {
|
|
|
|
GList *l;
|
|
|
|
|
|
|
|
for (l = GST_ELEMENT (self)->sinkpads; l; l = l->next)
|
|
|
|
if (!gst_pad_set_caps (GST_PAD (l->data), caps))
|
|
|
|
goto src_setcaps_failed;
|
|
|
|
} else {
|
|
|
|
GstPad *peer;
|
|
|
|
gboolean res;
|
|
|
|
|
|
|
|
peer = gst_pad_get_peer (pad);
|
|
|
|
if (!peer)
|
|
|
|
goto unlinked_sink;
|
|
|
|
|
|
|
|
res = gst_pad_set_caps (peer, caps);
|
|
|
|
gst_object_unref (peer);
|
|
|
|
|
|
|
|
if (!res)
|
|
|
|
goto peer_setcaps_failed;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
src_setcaps_failed:
|
|
|
|
{
|
|
|
|
/* not logging, presumably the sink pad already logged */
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
unlinked_sink:
|
|
|
|
{
|
|
|
|
GST_WARNING_OBJECT (self, "unlinked sink pad %" GST_PTR_FORMAT ", I wonder "
|
|
|
|
"how we passed activate_pull()", pad);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
peer_setcaps_failed:
|
|
|
|
{
|
|
|
|
GST_INFO_OBJECT (self, "peer of %" GST_PTR_FORMAT " did not accept caps",
|
|
|
|
pad);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-08-25 09:32:22 +00:00
|
|
|
static gboolean
|
|
|
|
gst_signal_processor_setcaps (GstPad * pad, GstCaps * caps)
|
|
|
|
{
|
|
|
|
GstSignalProcessor *self;
|
|
|
|
|
2006-07-31 22:03:09 +00:00
|
|
|
self = GST_SIGNAL_PROCESSOR (gst_pad_get_parent (pad));
|
2005-08-25 09:32:22 +00:00
|
|
|
|
2011-11-01 00:45:25 +00:00
|
|
|
if (self->mode == GST_PAD_ACTIVATE_PULL
|
|
|
|
&& !gst_caps_is_equal (caps, self->caps)
|
2007-01-12 21:58:43 +00:00
|
|
|
&& !gst_signal_processor_setcaps_pull (self, pad, caps))
|
|
|
|
goto setcaps_pull_failed;
|
|
|
|
|
2006-07-31 22:03:09 +00:00
|
|
|
/* the whole processor has one caps; if the sample rate changes, let subclass
|
|
|
|
implementations know */
|
2006-08-16 16:50:00 +00:00
|
|
|
if (!gst_caps_is_equal (caps, self->caps)) {
|
2010-02-01 20:32:32 +00:00
|
|
|
GstStructure *s;
|
|
|
|
|
2006-12-18 15:51:54 +00:00
|
|
|
GST_DEBUG_OBJECT (pad, "got caps %" GST_PTR_FORMAT, caps);
|
|
|
|
|
2006-08-16 16:50:00 +00:00
|
|
|
if (GST_SIGNAL_PROCESSOR_IS_RUNNING (self))
|
|
|
|
gst_signal_processor_stop (self);
|
|
|
|
if (GST_SIGNAL_PROCESSOR_IS_INITIALIZED (self))
|
|
|
|
gst_signal_processor_cleanup (self);
|
|
|
|
|
2010-02-01 20:32:32 +00:00
|
|
|
s = gst_caps_get_structure (caps, 0);
|
|
|
|
if (!gst_structure_get_int (s, "rate", &self->sample_rate))
|
|
|
|
goto no_sample_rate;
|
|
|
|
|
2009-11-16 19:50:20 +00:00
|
|
|
if (!gst_signal_processor_setup (self, caps))
|
2009-03-25 21:04:13 +00:00
|
|
|
goto start_or_setup_failed;
|
2006-12-18 15:51:54 +00:00
|
|
|
|
|
|
|
gst_caps_replace (&self->caps, caps);
|
ext/ladspa/gstsignalprocessor.c: Add debugs logs here and there, add more error handling, add some
Original commit message from CVS:
* ext/ladspa/gstsignalprocessor.c:
(gst_signal_processor_add_pad_from_template),
(gst_signal_processor_init), (gst_signal_processor_setcaps),
(gst_signal_processor_process), (gst_signal_processor_pen_buffer),
(gst_signal_processor_do_pulls), (gst_signal_processor_getrange),
(gst_signal_processor_sink_activate_push),
(gst_signal_processor_src_activate_pull),
(gst_signal_processor_change_state):
Add debugs logs here and there, add more error handling, add some
FIXME comments, filed #349189
2006-07-29 16:32:26 +00:00
|
|
|
} else {
|
2006-08-04 09:05:53 +00:00
|
|
|
GST_DEBUG_OBJECT (self, "skipping, have caps already");
|
2005-08-25 09:32:22 +00:00
|
|
|
}
|
|
|
|
|
2006-08-16 16:50:00 +00:00
|
|
|
/* we use this method to manage the processor's state, hence the caps clearing
|
|
|
|
in stop(). so it can be that we enter here just to manage the processor's
|
|
|
|
state, to take it to RUNNING from already being INITIALIZED with the right
|
|
|
|
sample rate (e.g., when having gone PLAYING->READY->PLAYING). make sure
|
|
|
|
when we leave that the processor is RUNNING. */
|
|
|
|
if (!GST_SIGNAL_PROCESSOR_IS_INITIALIZED (self)
|
2009-11-16 19:50:20 +00:00
|
|
|
&& !gst_signal_processor_setup (self, self->caps))
|
2009-03-25 21:04:13 +00:00
|
|
|
goto start_or_setup_failed;
|
2006-08-16 16:50:00 +00:00
|
|
|
if (!GST_SIGNAL_PROCESSOR_IS_RUNNING (self)
|
|
|
|
&& !gst_signal_processor_start (self))
|
2009-03-25 21:04:13 +00:00
|
|
|
goto start_or_setup_failed;
|
2005-08-25 09:32:22 +00:00
|
|
|
|
2006-07-31 22:03:09 +00:00
|
|
|
gst_object_unref (self);
|
|
|
|
|
2005-08-25 09:32:22 +00:00
|
|
|
return TRUE;
|
2006-07-31 22:03:09 +00:00
|
|
|
|
2010-02-01 20:32:32 +00:00
|
|
|
no_sample_rate:
|
|
|
|
{
|
|
|
|
GST_WARNING_OBJECT (self, "got no sample-rate");
|
|
|
|
gst_object_unref (self);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2009-03-25 21:04:13 +00:00
|
|
|
start_or_setup_failed:
|
2006-07-31 22:03:09 +00:00
|
|
|
{
|
2010-02-01 20:32:32 +00:00
|
|
|
GST_WARNING_OBJECT (self, "start or setup failed");
|
2006-07-31 22:03:09 +00:00
|
|
|
gst_object_unref (self);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2007-01-12 21:58:43 +00:00
|
|
|
setcaps_pull_failed:
|
|
|
|
{
|
2010-02-01 20:32:32 +00:00
|
|
|
GST_WARNING_OBJECT (self, "activating in pull-mode failed");
|
2007-01-12 21:58:43 +00:00
|
|
|
gst_object_unref (self);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2005-08-25 09:32:22 +00:00
|
|
|
}
|
|
|
|
|
2010-01-31 20:07:09 +00:00
|
|
|
/* De-interleave a pad (gstreamer => plugin) */
|
2009-07-04 00:00:11 +00:00
|
|
|
static void
|
|
|
|
gst_signal_processor_deinterleave_group (GstSignalProcessorGroup * group,
|
|
|
|
guint nframes)
|
|
|
|
{
|
|
|
|
guint i, j;
|
|
|
|
g_assert (group->nframes == nframes);
|
|
|
|
g_assert (group->interleaved_buffer);
|
|
|
|
g_assert (group->buffer);
|
|
|
|
for (i = 0; i < nframes; ++i)
|
|
|
|
for (j = 0; j < group->channels; ++j)
|
|
|
|
group->buffer[(j * nframes) + i]
|
|
|
|
= group->interleaved_buffer[(i * group->channels) + j];
|
|
|
|
}
|
|
|
|
|
2010-01-31 20:07:09 +00:00
|
|
|
/* Interleave a pad (plugin => gstreamer) */
|
2009-07-04 00:00:11 +00:00
|
|
|
static void
|
|
|
|
gst_signal_processor_interleave_group (GstSignalProcessorGroup * group,
|
|
|
|
guint nframes)
|
|
|
|
{
|
|
|
|
guint i, j;
|
|
|
|
g_assert (group->nframes == nframes);
|
|
|
|
g_assert (group->interleaved_buffer);
|
|
|
|
g_assert (group->buffer);
|
|
|
|
for (i = 0; i < nframes; ++i)
|
|
|
|
for (j = 0; j < group->channels; ++j)
|
|
|
|
group->interleaved_buffer[(i * group->channels) + j]
|
|
|
|
= group->buffer[(j * nframes) + i];
|
|
|
|
}
|
|
|
|
|
2005-08-25 09:32:22 +00:00
|
|
|
static gboolean
|
|
|
|
gst_signal_processor_event (GstPad * pad, GstEvent * event)
|
|
|
|
{
|
|
|
|
GstSignalProcessor *self;
|
|
|
|
GstSignalProcessorClass *bclass;
|
2006-02-20 13:08:50 +00:00
|
|
|
gboolean ret;
|
2005-08-25 09:32:22 +00:00
|
|
|
|
2006-07-31 22:03:09 +00:00
|
|
|
self = GST_SIGNAL_PROCESSOR (gst_pad_get_parent (pad));
|
2005-08-25 09:32:22 +00:00
|
|
|
bclass = GST_SIGNAL_PROCESSOR_GET_CLASS (self);
|
|
|
|
|
2010-03-25 21:24:36 +00:00
|
|
|
GST_DEBUG_OBJECT (pad, "got event %s", GST_EVENT_TYPE_NAME (event));
|
|
|
|
|
2009-03-25 21:04:13 +00:00
|
|
|
/* FIXME, this probably isn't the correct interface: what about return values,
|
|
|
|
* what about overriding event_default
|
2008-10-30 13:02:18 +00:00
|
|
|
* Sync with GstBaseTransform::gst_base_transform_sink_event */
|
2005-08-25 09:32:22 +00:00
|
|
|
if (bclass->event)
|
|
|
|
bclass->event (self, event);
|
|
|
|
|
2006-12-18 15:51:54 +00:00
|
|
|
switch (GST_EVENT_TYPE (event)) {
|
2011-10-04 11:33:53 +00:00
|
|
|
case GST_EVENT_CAPS:
|
|
|
|
{
|
|
|
|
GstCaps *caps;
|
|
|
|
|
|
|
|
gst_event_parse_caps (event, &caps);
|
|
|
|
ret = gst_signal_processor_setcaps (pad, caps);
|
|
|
|
gst_event_unref (event);
|
|
|
|
break;
|
|
|
|
}
|
2006-12-18 15:51:54 +00:00
|
|
|
case GST_EVENT_FLUSH_START:
|
2011-10-04 11:33:53 +00:00
|
|
|
ret = gst_pad_event_default (pad, event);
|
2006-12-18 15:51:54 +00:00
|
|
|
break;
|
|
|
|
case GST_EVENT_FLUSH_STOP:
|
|
|
|
/* clear errors now */
|
|
|
|
self->flow_state = GST_FLOW_OK;
|
2011-10-04 11:33:53 +00:00
|
|
|
ret = gst_pad_event_default (pad, event);
|
2006-12-18 15:51:54 +00:00
|
|
|
break;
|
|
|
|
default:
|
2011-10-04 11:33:53 +00:00
|
|
|
ret = gst_pad_event_default (pad, event);
|
2006-12-18 15:51:54 +00:00
|
|
|
break;
|
|
|
|
}
|
2005-08-25 09:32:22 +00:00
|
|
|
|
2006-07-31 22:03:09 +00:00
|
|
|
gst_object_unref (self);
|
|
|
|
|
2005-08-25 09:32:22 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2010-01-31 20:16:18 +00:00
|
|
|
/*
|
|
|
|
* gst_signal_processor_prepare:
|
|
|
|
* @self: the element
|
|
|
|
* nframes: wanted sample frames
|
|
|
|
*
|
|
|
|
* Checks if wan
|
|
|
|
*
|
|
|
|
* Returns: available sample frames
|
|
|
|
*/
|
2006-08-04 09:05:53 +00:00
|
|
|
static guint
|
2007-01-06 15:56:55 +00:00
|
|
|
gst_signal_processor_prepare (GstSignalProcessor * self, guint nframes)
|
2005-08-25 09:32:22 +00:00
|
|
|
{
|
2006-08-04 09:05:53 +00:00
|
|
|
GstElement *elem = (GstElement *) self;
|
2006-08-04 11:38:54 +00:00
|
|
|
GstSignalProcessorClass *klass;
|
2006-08-04 09:05:53 +00:00
|
|
|
GList *sinks, *srcs;
|
2007-01-06 15:56:55 +00:00
|
|
|
guint samples_avail = nframes;
|
2009-07-04 00:00:11 +00:00
|
|
|
guint i, in_group_index = 0, out_group_index = 0;
|
2010-01-31 20:16:18 +00:00
|
|
|
gboolean is_gap = FALSE;
|
|
|
|
GstClockTime ts, tss = GST_CLOCK_TIME_NONE, tse = GST_CLOCK_TIME_NONE;
|
2006-08-04 09:05:53 +00:00
|
|
|
|
2006-08-04 11:38:54 +00:00
|
|
|
klass = GST_SIGNAL_PROCESSOR_GET_CLASS (self);
|
|
|
|
|
2006-08-04 09:05:53 +00:00
|
|
|
/* first, assign audio_in pointers, and determine the number of samples that
|
|
|
|
* we can process */
|
2009-07-04 00:00:11 +00:00
|
|
|
i = 0;
|
|
|
|
for (sinks = elem->sinkpads; sinks; sinks = sinks->next, ++i) {
|
2006-08-04 09:05:53 +00:00
|
|
|
GstSignalProcessorPad *sinkpad;
|
|
|
|
|
|
|
|
sinkpad = (GstSignalProcessorPad *) sinks->data;
|
|
|
|
g_assert (sinkpad->samples_avail > 0);
|
|
|
|
samples_avail = MIN (samples_avail, sinkpad->samples_avail);
|
2009-07-04 00:00:11 +00:00
|
|
|
if (sinkpad->channels > 1) {
|
|
|
|
GstSignalProcessorGroup *group = &self->group_in[in_group_index++];
|
|
|
|
group->interleaved_buffer = sinkpad->data;
|
|
|
|
/* allocate buffer for de-interleaving */
|
|
|
|
if (!group->buffer || group->channels < sinkpad->channels
|
|
|
|
|| group->nframes < samples_avail) {
|
|
|
|
group->buffer =
|
|
|
|
(gfloat *) g_realloc (group->buffer,
|
|
|
|
samples_avail * sinkpad->channels * sizeof (gfloat));
|
|
|
|
memset (group->buffer, '\0',
|
|
|
|
samples_avail * sinkpad->channels * sizeof (gfloat));
|
|
|
|
}
|
|
|
|
g_assert (group->buffer);
|
|
|
|
group->channels = sinkpad->channels;
|
|
|
|
group->nframes = samples_avail;
|
|
|
|
gst_signal_processor_deinterleave_group (group, samples_avail);
|
|
|
|
} else {
|
|
|
|
self->audio_in[sinkpad->index] = sinkpad->data;
|
|
|
|
}
|
2006-08-04 09:05:53 +00:00
|
|
|
}
|
2005-08-25 09:32:22 +00:00
|
|
|
|
2010-01-31 20:16:18 +00:00
|
|
|
GST_LOG_OBJECT (self, "want %u samples, have %u samples", nframes,
|
|
|
|
samples_avail);
|
|
|
|
|
2009-03-25 21:04:13 +00:00
|
|
|
/* FIXME: return if samples_avail==0 ? */
|
|
|
|
|
2010-01-31 20:16:18 +00:00
|
|
|
if ((sinks = elem->sinkpads)) {
|
|
|
|
is_gap = TRUE;
|
|
|
|
while (sinks) {
|
|
|
|
GstSignalProcessorPad *sinkpad = (GstSignalProcessorPad *) sinks->data;
|
|
|
|
|
|
|
|
is_gap &= GST_BUFFER_FLAG_IS_SET (sinkpad->pen, GST_BUFFER_FLAG_GAP);
|
|
|
|
ts = GST_BUFFER_TIMESTAMP (sinkpad->pen);
|
|
|
|
if (GST_CLOCK_TIME_IS_VALID (ts)) {
|
|
|
|
tss = !GST_CLOCK_TIME_IS_VALID (tss) ? ts : MIN (tss, ts);
|
|
|
|
tse = !GST_CLOCK_TIME_IS_VALID (tse) ? ts : MAX (tse, ts);
|
|
|
|
}
|
|
|
|
sinks = sinks->next;
|
|
|
|
}
|
|
|
|
ts = (tss == tse) ? tss : GST_CLOCK_TIME_NONE;
|
|
|
|
GST_LOG_OBJECT (self, "is gap: %d, tss %" GST_TIME_FORMAT ", tse %"
|
|
|
|
GST_TIME_FORMAT, is_gap, GST_TIME_ARGS (tss), GST_TIME_ARGS (tse));
|
|
|
|
} else {
|
|
|
|
/* FIXME: calculate own timestamps */
|
|
|
|
ts = GST_CLOCK_TIME_NONE;
|
|
|
|
}
|
|
|
|
|
2006-08-04 09:05:53 +00:00
|
|
|
/* now assign output buffers. we can avoid allocation by reusing input
|
|
|
|
buffers, but only if process() can work in place, and if the input buffer
|
|
|
|
is the exact size of the number of samples we are processing. */
|
|
|
|
sinks = elem->sinkpads;
|
|
|
|
srcs = elem->srcpads;
|
2010-03-25 21:24:36 +00:00
|
|
|
|
|
|
|
GST_LOG_OBJECT (self, "allocating %d buffers", g_list_length (srcs));
|
|
|
|
|
2006-08-04 11:38:54 +00:00
|
|
|
if (GST_SIGNAL_PROCESSOR_CLASS_CAN_PROCESS_IN_PLACE (klass)) {
|
|
|
|
while (sinks && srcs) {
|
|
|
|
GstSignalProcessorPad *sinkpad, *srcpad;
|
2006-02-20 13:08:50 +00:00
|
|
|
|
2006-08-04 11:38:54 +00:00
|
|
|
sinkpad = (GstSignalProcessorPad *) sinks->data;
|
|
|
|
srcpad = (GstSignalProcessorPad *) srcs->data;
|
2005-08-25 09:32:22 +00:00
|
|
|
|
2009-07-04 00:00:11 +00:00
|
|
|
if (sinkpad->channels == 1 && sinkpad->channels == srcpad->channels
|
2011-10-04 11:33:53 +00:00
|
|
|
&& gst_buffer_get_size (sinkpad->pen) ==
|
2009-07-04 00:00:11 +00:00
|
|
|
samples_avail * sizeof (gfloat)) {
|
2006-08-04 11:38:54 +00:00
|
|
|
/* reusable, yay */
|
|
|
|
g_assert (sinkpad->samples_avail == samples_avail);
|
|
|
|
srcpad->pen = sinkpad->pen;
|
|
|
|
sinkpad->pen = NULL;
|
|
|
|
self->audio_out[srcpad->index] = sinkpad->data;
|
|
|
|
self->pending_out++;
|
2006-07-31 22:27:22 +00:00
|
|
|
|
2006-08-04 11:38:54 +00:00
|
|
|
srcs = srcs->next;
|
|
|
|
}
|
2006-07-31 22:03:09 +00:00
|
|
|
|
2006-08-04 11:38:54 +00:00
|
|
|
sinks = sinks->next;
|
|
|
|
}
|
2006-08-04 09:05:53 +00:00
|
|
|
}
|
2005-08-25 09:32:22 +00:00
|
|
|
|
2007-01-06 17:22:12 +00:00
|
|
|
g_return_val_if_fail (GST_SIGNAL_PROCESSOR_IS_RUNNING (self), 0);
|
|
|
|
|
2006-08-04 09:05:53 +00:00
|
|
|
/* now allocate for any remaining outputs */
|
|
|
|
while (srcs) {
|
|
|
|
GstSignalProcessorPad *srcpad;
|
|
|
|
|
|
|
|
srcpad = (GstSignalProcessorPad *) srcs->data;
|
|
|
|
|
2011-10-04 11:33:53 +00:00
|
|
|
srcpad->pen =
|
|
|
|
gst_buffer_new_allocate (NULL,
|
|
|
|
samples_avail * srcpad->channels * sizeof (gfloat), 0);
|
|
|
|
|
|
|
|
if (srcpad->channels > 1) {
|
2009-07-04 00:00:11 +00:00
|
|
|
GstSignalProcessorGroup *group = &self->group_out[out_group_index++];
|
2011-10-04 11:33:53 +00:00
|
|
|
group->interleaved_buffer =
|
|
|
|
(gfloat *) gst_buffer_map (srcpad->pen, NULL, NULL,
|
|
|
|
GST_MAP_READWRITE);
|
2009-07-04 00:00:11 +00:00
|
|
|
if (!group->buffer || group->channels < srcpad->channels
|
|
|
|
|| group->nframes < samples_avail)
|
|
|
|
group->buffer =
|
|
|
|
(gfloat *) g_realloc (group->buffer,
|
|
|
|
samples_avail * srcpad->channels * sizeof (gfloat));
|
|
|
|
group->channels = srcpad->channels;
|
|
|
|
group->nframes = samples_avail;
|
|
|
|
self->pending_out++;
|
2006-08-04 09:05:53 +00:00
|
|
|
} else {
|
2011-10-04 11:33:53 +00:00
|
|
|
self->audio_out[srcpad->index] =
|
|
|
|
(gfloat *) gst_buffer_map (srcpad->pen, NULL, NULL,
|
|
|
|
GST_MAP_READWRITE);
|
2005-08-25 09:32:22 +00:00
|
|
|
self->pending_out++;
|
|
|
|
}
|
|
|
|
|
2010-01-31 20:16:18 +00:00
|
|
|
/* set time stamp */
|
|
|
|
GST_BUFFER_TIMESTAMP (srcpad->pen) = ts;
|
|
|
|
/* FIXME: handle gap flag ? */
|
|
|
|
|
2006-08-04 09:05:53 +00:00
|
|
|
srcs = srcs->next;
|
|
|
|
}
|
2005-08-25 09:32:22 +00:00
|
|
|
|
2010-01-31 20:16:18 +00:00
|
|
|
/* update controlled parameters */
|
|
|
|
if (samples_avail && GST_CLOCK_TIME_IS_VALID (ts)) {
|
2011-11-04 17:52:35 +00:00
|
|
|
gst_object_sync_values ((GstObject *) self, ts);
|
2010-01-31 20:16:18 +00:00
|
|
|
}
|
|
|
|
|
2006-08-04 09:05:53 +00:00
|
|
|
return samples_avail;
|
|
|
|
}
|
2006-07-31 22:27:22 +00:00
|
|
|
|
2006-08-04 09:05:53 +00:00
|
|
|
static void
|
|
|
|
gst_signal_processor_update_inputs (GstSignalProcessor * self, guint nprocessed)
|
|
|
|
{
|
|
|
|
GstElement *elem = (GstElement *) self;
|
|
|
|
GList *sinks;
|
2005-08-25 09:32:22 +00:00
|
|
|
|
2006-08-04 09:05:53 +00:00
|
|
|
for (sinks = elem->sinkpads; sinks; sinks = sinks->next) {
|
|
|
|
GstSignalProcessorPad *sinkpad;
|
2006-07-31 19:44:18 +00:00
|
|
|
|
2006-08-04 09:05:53 +00:00
|
|
|
sinkpad = (GstSignalProcessorPad *) sinks->data;
|
|
|
|
g_assert (sinkpad->samples_avail >= nprocessed);
|
2005-08-25 09:32:22 +00:00
|
|
|
|
2006-08-04 09:05:53 +00:00
|
|
|
if (sinkpad->pen && sinkpad->samples_avail == nprocessed) {
|
|
|
|
/* used up this buffer, unpen */
|
2005-08-25 09:32:22 +00:00
|
|
|
gst_buffer_unref (sinkpad->pen);
|
|
|
|
sinkpad->pen = NULL;
|
|
|
|
}
|
2006-08-04 09:05:53 +00:00
|
|
|
|
|
|
|
if (!sinkpad->pen) {
|
|
|
|
/* this buffer was used up */
|
|
|
|
self->pending_in++;
|
|
|
|
sinkpad->data = NULL;
|
|
|
|
sinkpad->samples_avail = 0;
|
|
|
|
} else {
|
|
|
|
/* advance ->data pointers and decrement ->samples_avail, unreffing buffer
|
|
|
|
if no samples are left */
|
|
|
|
sinkpad->samples_avail -= nprocessed;
|
2009-07-04 00:00:11 +00:00
|
|
|
sinkpad->data += nprocessed * sinkpad->channels; /* gfloat* arithmetic */
|
2006-08-04 09:05:53 +00:00
|
|
|
}
|
2005-08-25 09:32:22 +00:00
|
|
|
}
|
2006-08-04 09:05:53 +00:00
|
|
|
}
|
|
|
|
|
2009-07-04 00:00:11 +00:00
|
|
|
static void
|
|
|
|
gst_signal_processor_update_outputs (GstSignalProcessor * self,
|
|
|
|
guint nprocessed)
|
|
|
|
{
|
|
|
|
GstSignalProcessorClass *klass = GST_SIGNAL_PROCESSOR_GET_CLASS (self);
|
|
|
|
guint i;
|
|
|
|
for (i = 0; i < klass->num_group_out; ++i)
|
|
|
|
gst_signal_processor_interleave_group (&self->group_out[i], nprocessed);
|
|
|
|
}
|
|
|
|
|
2010-03-25 21:30:29 +00:00
|
|
|
static gboolean
|
2007-01-06 15:56:55 +00:00
|
|
|
gst_signal_processor_process (GstSignalProcessor * self, guint nframes)
|
2006-08-04 09:05:53 +00:00
|
|
|
{
|
|
|
|
GstSignalProcessorClass *klass;
|
|
|
|
|
2009-03-25 21:04:13 +00:00
|
|
|
/* check if we have buffers enqueued */
|
2010-03-25 21:30:29 +00:00
|
|
|
g_return_val_if_fail (self->pending_in == 0, FALSE);
|
|
|
|
g_return_val_if_fail (self->pending_out == 0, FALSE);
|
2006-08-04 09:05:53 +00:00
|
|
|
|
2009-03-25 21:04:13 +00:00
|
|
|
/* check how much input is available and prepare output buffers */
|
2007-01-06 15:56:55 +00:00
|
|
|
nframes = gst_signal_processor_prepare (self, nframes);
|
2006-08-04 09:05:53 +00:00
|
|
|
if (G_UNLIKELY (nframes == 0))
|
|
|
|
goto flow_error;
|
|
|
|
|
|
|
|
klass = GST_SIGNAL_PROCESSOR_GET_CLASS (self);
|
|
|
|
|
|
|
|
GST_LOG_OBJECT (self, "process(%u)", nframes);
|
|
|
|
|
|
|
|
klass->process (self, nframes);
|
|
|
|
|
|
|
|
gst_signal_processor_update_inputs (self, nframes);
|
2009-07-04 00:00:11 +00:00
|
|
|
gst_signal_processor_update_outputs (self, nframes);
|
2006-08-04 09:05:53 +00:00
|
|
|
|
2010-03-25 21:30:29 +00:00
|
|
|
return TRUE;
|
2006-07-31 22:03:09 +00:00
|
|
|
|
|
|
|
flow_error:
|
|
|
|
{
|
2010-03-25 21:24:36 +00:00
|
|
|
GST_WARNING_OBJECT (self,
|
|
|
|
"gst_signal_processor_prepare() returned %d, flow_ref=%s", nframes,
|
|
|
|
gst_flow_get_name (self->flow_state));
|
2010-03-25 21:30:29 +00:00
|
|
|
return FALSE;
|
2006-07-31 22:03:09 +00:00
|
|
|
}
|
2005-08-25 09:32:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_signal_processor_pen_buffer (GstSignalProcessor * self, GstPad * pad,
|
|
|
|
GstBuffer * buffer)
|
|
|
|
{
|
|
|
|
GstSignalProcessorPad *spad = (GstSignalProcessorPad *) pad;
|
2011-10-04 11:33:53 +00:00
|
|
|
gsize size;
|
2005-08-25 09:32:22 +00:00
|
|
|
|
2006-08-16 16:50:00 +00:00
|
|
|
if (spad->pen)
|
|
|
|
goto had_buffer;
|
2005-08-25 09:32:22 +00:00
|
|
|
|
|
|
|
/* keep the reference */
|
|
|
|
spad->pen = buffer;
|
2011-10-04 11:33:53 +00:00
|
|
|
spad->data =
|
|
|
|
(gfloat *) gst_buffer_map (buffer, &size, NULL, GST_MAP_READWRITE);
|
|
|
|
spad->samples_avail = size / sizeof (float) / spad->channels;
|
2005-08-25 09:32:22 +00:00
|
|
|
|
|
|
|
g_assert (self->pending_in != 0);
|
|
|
|
|
|
|
|
self->pending_in--;
|
2006-08-16 16:50:00 +00:00
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* ERRORS */
|
|
|
|
had_buffer:
|
|
|
|
{
|
|
|
|
GST_WARNING ("Pad %s:%s already has penned buffer",
|
|
|
|
GST_DEBUG_PAD_NAME (pad));
|
|
|
|
gst_buffer_unref (buffer);
|
|
|
|
return;
|
|
|
|
}
|
2005-08-25 09:32:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_signal_processor_flush (GstSignalProcessor * self)
|
|
|
|
{
|
|
|
|
GList *pads;
|
2006-08-16 16:50:00 +00:00
|
|
|
GstSignalProcessorClass *klass;
|
|
|
|
|
|
|
|
klass = GST_SIGNAL_PROCESSOR_GET_CLASS (self);
|
|
|
|
|
|
|
|
GST_INFO_OBJECT (self, "flush()");
|
2005-08-25 09:32:22 +00:00
|
|
|
|
2009-03-25 21:04:13 +00:00
|
|
|
/* release enqueued buffers */
|
2005-08-25 09:32:22 +00:00
|
|
|
for (pads = GST_ELEMENT (self)->pads; pads; pads = pads->next) {
|
|
|
|
GstSignalProcessorPad *spad = (GstSignalProcessorPad *) pads->data;
|
|
|
|
|
|
|
|
if (spad->pen) {
|
2011-10-04 11:33:53 +00:00
|
|
|
gst_buffer_unmap (spad->pen, spad->data, -1);
|
2005-08-25 09:32:22 +00:00
|
|
|
gst_buffer_unref (spad->pen);
|
|
|
|
spad->pen = NULL;
|
2006-08-04 09:05:53 +00:00
|
|
|
spad->data = NULL;
|
|
|
|
spad->samples_avail = 0;
|
2005-08-25 09:32:22 +00:00
|
|
|
}
|
|
|
|
}
|
2006-08-16 16:50:00 +00:00
|
|
|
|
2009-03-25 21:04:13 +00:00
|
|
|
/* no outputs prepared and inputs for each pad needed */
|
2006-08-16 16:50:00 +00:00
|
|
|
self->pending_out = 0;
|
|
|
|
self->pending_in = klass->num_audio_in;
|
2005-08-25 09:32:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2006-07-31 22:03:09 +00:00
|
|
|
gst_signal_processor_do_pulls (GstSignalProcessor * self, guint nframes)
|
2005-08-25 09:32:22 +00:00
|
|
|
{
|
|
|
|
GList *sinkpads;
|
|
|
|
|
ext/ladspa/gstsignalprocessor.c: Add debugs logs here and there, add more error handling, add some
Original commit message from CVS:
* ext/ladspa/gstsignalprocessor.c:
(gst_signal_processor_add_pad_from_template),
(gst_signal_processor_init), (gst_signal_processor_setcaps),
(gst_signal_processor_process), (gst_signal_processor_pen_buffer),
(gst_signal_processor_do_pulls), (gst_signal_processor_getrange),
(gst_signal_processor_sink_activate_push),
(gst_signal_processor_src_activate_pull),
(gst_signal_processor_change_state):
Add debugs logs here and there, add more error handling, add some
FIXME comments, filed #349189
2006-07-29 16:32:26 +00:00
|
|
|
/* FIXME: not threadsafe atm */
|
2005-08-25 09:32:22 +00:00
|
|
|
|
|
|
|
sinkpads = GST_ELEMENT (self)->sinkpads;
|
|
|
|
|
|
|
|
for (; sinkpads; sinkpads = sinkpads->next) {
|
|
|
|
GstSignalProcessorPad *spad = (GstSignalProcessorPad *) sinkpads->data;
|
|
|
|
GstFlowReturn ret = GST_FLOW_OK;
|
|
|
|
GstBuffer *buf;
|
|
|
|
|
|
|
|
if (spad->pen) {
|
|
|
|
g_warning ("Unexpectedly full buffer pen for pad %s:%s",
|
|
|
|
GST_DEBUG_PAD_NAME (spad));
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2007-01-06 15:56:55 +00:00
|
|
|
ret =
|
|
|
|
gst_pad_pull_range (GST_PAD (spad), -1, nframes * sizeof (gfloat),
|
|
|
|
&buf);
|
2005-08-25 09:32:22 +00:00
|
|
|
|
|
|
|
if (ret != GST_FLOW_OK) {
|
|
|
|
gst_signal_processor_flush (self);
|
2006-08-16 16:50:00 +00:00
|
|
|
self->flow_state = ret;
|
2005-08-25 09:32:22 +00:00
|
|
|
return;
|
|
|
|
} else if (!buf) {
|
|
|
|
g_critical ("Pull failed to make a buffer!");
|
2006-08-04 11:38:54 +00:00
|
|
|
self->flow_state = GST_FLOW_ERROR;
|
2005-08-25 09:32:22 +00:00
|
|
|
return;
|
|
|
|
} else {
|
|
|
|
gst_signal_processor_pen_buffer (self, GST_PAD (spad), buf);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (self->pending_in != 0) {
|
|
|
|
g_critical ("Something wierd happened...");
|
2006-08-04 11:38:54 +00:00
|
|
|
self->flow_state = GST_FLOW_ERROR;
|
2005-08-25 09:32:22 +00:00
|
|
|
} else {
|
2007-01-06 15:56:55 +00:00
|
|
|
gst_signal_processor_process (self, nframes);
|
2005-08-25 09:32:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static GstFlowReturn
|
|
|
|
gst_signal_processor_getrange (GstPad * pad, guint64 offset,
|
|
|
|
guint length, GstBuffer ** buffer)
|
|
|
|
{
|
|
|
|
GstSignalProcessor *self;
|
|
|
|
GstSignalProcessorPad *spad = (GstSignalProcessorPad *) pad;
|
ext/ladspa/gstsignalprocessor.c: Add debugs logs here and there, add more error handling, add some
Original commit message from CVS:
* ext/ladspa/gstsignalprocessor.c:
(gst_signal_processor_add_pad_from_template),
(gst_signal_processor_init), (gst_signal_processor_setcaps),
(gst_signal_processor_process), (gst_signal_processor_pen_buffer),
(gst_signal_processor_do_pulls), (gst_signal_processor_getrange),
(gst_signal_processor_sink_activate_push),
(gst_signal_processor_src_activate_pull),
(gst_signal_processor_change_state):
Add debugs logs here and there, add more error handling, add some
FIXME comments, filed #349189
2006-07-29 16:32:26 +00:00
|
|
|
GstFlowReturn ret = GST_FLOW_ERROR;
|
2005-08-25 09:32:22 +00:00
|
|
|
|
2006-07-31 22:03:09 +00:00
|
|
|
self = GST_SIGNAL_PROCESSOR (gst_pad_get_parent (pad));
|
2005-08-25 09:32:22 +00:00
|
|
|
|
|
|
|
if (spad->pen) {
|
|
|
|
*buffer = spad->pen;
|
|
|
|
spad->pen = NULL;
|
|
|
|
g_assert (self->pending_out != 0);
|
|
|
|
self->pending_out--;
|
|
|
|
ret = GST_FLOW_OK;
|
|
|
|
} else {
|
2007-01-06 15:56:55 +00:00
|
|
|
gst_signal_processor_do_pulls (self, length / sizeof (gfloat));
|
2005-08-25 09:32:22 +00:00
|
|
|
if (!spad->pen) {
|
2006-07-31 22:03:09 +00:00
|
|
|
/* this is an error condition */
|
2005-08-25 09:32:22 +00:00
|
|
|
*buffer = NULL;
|
2006-08-04 11:38:54 +00:00
|
|
|
ret = self->flow_state;
|
2005-08-25 09:32:22 +00:00
|
|
|
} else {
|
|
|
|
*buffer = spad->pen;
|
|
|
|
spad->pen = NULL;
|
|
|
|
self->pending_out--;
|
|
|
|
ret = GST_FLOW_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-07-31 22:03:09 +00:00
|
|
|
GST_DEBUG_OBJECT (self, "returns %s", gst_flow_get_name (ret));
|
|
|
|
|
|
|
|
gst_object_unref (self);
|
ext/ladspa/gstsignalprocessor.c: Add debugs logs here and there, add more error handling, add some
Original commit message from CVS:
* ext/ladspa/gstsignalprocessor.c:
(gst_signal_processor_add_pad_from_template),
(gst_signal_processor_init), (gst_signal_processor_setcaps),
(gst_signal_processor_process), (gst_signal_processor_pen_buffer),
(gst_signal_processor_do_pulls), (gst_signal_processor_getrange),
(gst_signal_processor_sink_activate_push),
(gst_signal_processor_src_activate_pull),
(gst_signal_processor_change_state):
Add debugs logs here and there, add more error handling, add some
FIXME comments, filed #349189
2006-07-29 16:32:26 +00:00
|
|
|
|
2005-08-25 09:32:22 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_signal_processor_do_pushes (GstSignalProcessor * self)
|
|
|
|
{
|
|
|
|
GList *srcpads;
|
|
|
|
|
|
|
|
/* not threadsafe atm */
|
|
|
|
|
|
|
|
srcpads = GST_ELEMENT (self)->srcpads;
|
|
|
|
|
|
|
|
for (; srcpads; srcpads = srcpads->next) {
|
|
|
|
GstSignalProcessorPad *spad = (GstSignalProcessorPad *) srcpads->data;
|
|
|
|
GstFlowReturn ret = GST_FLOW_OK;
|
2006-08-16 14:47:50 +00:00
|
|
|
GstBuffer *buffer;
|
2005-08-25 09:32:22 +00:00
|
|
|
|
|
|
|
if (!spad->pen) {
|
|
|
|
g_warning ("Unexpectedly empty buffer pen for pad %s:%s",
|
|
|
|
GST_DEBUG_PAD_NAME (spad));
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2006-08-16 14:47:50 +00:00
|
|
|
/* take buffer from pen */
|
|
|
|
buffer = spad->pen;
|
|
|
|
spad->pen = NULL;
|
|
|
|
|
|
|
|
ret = gst_pad_push (GST_PAD (spad), buffer);
|
2005-08-25 09:32:22 +00:00
|
|
|
|
|
|
|
if (ret != GST_FLOW_OK) {
|
|
|
|
gst_signal_processor_flush (self);
|
2006-08-16 16:50:00 +00:00
|
|
|
self->flow_state = ret;
|
2005-08-25 09:32:22 +00:00
|
|
|
return;
|
|
|
|
} else {
|
|
|
|
g_assert (self->pending_out > 0);
|
|
|
|
self->pending_out--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (self->pending_out != 0) {
|
|
|
|
g_critical ("Something wierd happened...");
|
2006-08-04 11:38:54 +00:00
|
|
|
self->flow_state = GST_FLOW_ERROR;
|
2005-08-25 09:32:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static GstFlowReturn
|
|
|
|
gst_signal_processor_chain (GstPad * pad, GstBuffer * buffer)
|
|
|
|
{
|
|
|
|
GstSignalProcessor *self;
|
|
|
|
|
2006-07-31 22:03:09 +00:00
|
|
|
self = GST_SIGNAL_PROCESSOR (gst_pad_get_parent (pad));
|
2005-08-25 09:32:22 +00:00
|
|
|
|
2010-03-25 21:24:36 +00:00
|
|
|
GST_LOG_OBJECT (self, "chain(%s:%s, %p) : p_in=%u, p_out=%u",
|
|
|
|
GST_DEBUG_PAD_NAME (pad), buffer, self->pending_in, self->pending_out);
|
|
|
|
|
2005-08-25 09:32:22 +00:00
|
|
|
gst_signal_processor_pen_buffer (self, pad, buffer);
|
|
|
|
|
|
|
|
if (self->pending_in == 0) {
|
2010-03-25 21:30:29 +00:00
|
|
|
if (gst_signal_processor_process (self, G_MAXUINT))
|
|
|
|
gst_signal_processor_do_pushes (self);
|
2005-08-25 09:32:22 +00:00
|
|
|
}
|
|
|
|
|
2006-07-31 22:03:09 +00:00
|
|
|
gst_object_unref (self);
|
|
|
|
|
2006-08-04 11:38:54 +00:00
|
|
|
return self->flow_state;
|
2005-08-25 09:32:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gst_signal_processor_sink_activate_push (GstPad * pad, gboolean active)
|
|
|
|
{
|
|
|
|
gboolean result = TRUE;
|
|
|
|
GstSignalProcessor *self;
|
|
|
|
|
2006-07-31 22:03:09 +00:00
|
|
|
self = GST_SIGNAL_PROCESSOR (gst_pad_get_parent (pad));
|
2005-08-25 09:32:22 +00:00
|
|
|
|
|
|
|
if (active) {
|
2011-11-01 00:45:25 +00:00
|
|
|
if (self->mode == GST_PAD_ACTIVATE_NONE) {
|
|
|
|
self->mode = GST_PAD_ACTIVATE_PUSH;
|
2005-08-25 09:32:22 +00:00
|
|
|
result = TRUE;
|
2011-11-01 00:45:25 +00:00
|
|
|
} else if (self->mode == GST_PAD_ACTIVATE_PUSH) {
|
2005-08-25 09:32:22 +00:00
|
|
|
result = TRUE;
|
|
|
|
} else {
|
|
|
|
g_warning ("foo");
|
|
|
|
result = FALSE;
|
|
|
|
}
|
|
|
|
} else {
|
2011-11-01 00:45:25 +00:00
|
|
|
if (self->mode == GST_PAD_ACTIVATE_NONE) {
|
2005-08-25 09:32:22 +00:00
|
|
|
result = TRUE;
|
2011-11-01 00:45:25 +00:00
|
|
|
} else if (self->mode == GST_PAD_ACTIVATE_PUSH) {
|
|
|
|
self->mode = GST_PAD_ACTIVATE_NONE;
|
2005-08-25 09:32:22 +00:00
|
|
|
result = TRUE;
|
|
|
|
} else {
|
|
|
|
g_warning ("foo");
|
|
|
|
result = FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-08-04 09:05:53 +00:00
|
|
|
GST_DEBUG_OBJECT (self, "result : %d", result);
|
ext/ladspa/gstsignalprocessor.c: Add debugs logs here and there, add more error handling, add some
Original commit message from CVS:
* ext/ladspa/gstsignalprocessor.c:
(gst_signal_processor_add_pad_from_template),
(gst_signal_processor_init), (gst_signal_processor_setcaps),
(gst_signal_processor_process), (gst_signal_processor_pen_buffer),
(gst_signal_processor_do_pulls), (gst_signal_processor_getrange),
(gst_signal_processor_sink_activate_push),
(gst_signal_processor_src_activate_pull),
(gst_signal_processor_change_state):
Add debugs logs here and there, add more error handling, add some
FIXME comments, filed #349189
2006-07-29 16:32:26 +00:00
|
|
|
|
2006-07-31 22:03:09 +00:00
|
|
|
gst_object_unref (self);
|
|
|
|
|
2005-08-25 09:32:22 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gst_signal_processor_src_activate_pull (GstPad * pad, gboolean active)
|
|
|
|
{
|
|
|
|
gboolean result = TRUE;
|
|
|
|
GstSignalProcessor *self;
|
|
|
|
|
2006-07-31 22:03:09 +00:00
|
|
|
self = GST_SIGNAL_PROCESSOR (gst_pad_get_parent (pad));
|
2005-08-25 09:32:22 +00:00
|
|
|
|
|
|
|
if (active) {
|
2011-11-01 00:45:25 +00:00
|
|
|
if (self->mode == GST_PAD_ACTIVATE_NONE) {
|
2005-08-25 09:32:22 +00:00
|
|
|
GList *l;
|
|
|
|
|
|
|
|
for (l = GST_ELEMENT (self)->sinkpads; l; l = l->next)
|
|
|
|
result &= gst_pad_activate_pull (pad, active);
|
|
|
|
if (result)
|
2011-11-01 00:45:25 +00:00
|
|
|
self->mode = GST_PAD_ACTIVATE_PULL;
|
|
|
|
} else if (self->mode == GST_PAD_ACTIVATE_PULL) {
|
2005-08-25 09:32:22 +00:00
|
|
|
result = TRUE;
|
|
|
|
} else {
|
|
|
|
g_warning ("foo");
|
|
|
|
result = FALSE;
|
|
|
|
}
|
|
|
|
} else {
|
2011-11-01 00:45:25 +00:00
|
|
|
if (self->mode == GST_PAD_ACTIVATE_NONE) {
|
2005-08-25 09:32:22 +00:00
|
|
|
result = TRUE;
|
2011-11-01 00:45:25 +00:00
|
|
|
} else if (self->mode == GST_PAD_ACTIVATE_PULL) {
|
2005-08-25 09:32:22 +00:00
|
|
|
GList *l;
|
|
|
|
|
|
|
|
for (l = GST_ELEMENT (self)->sinkpads; l; l = l->next)
|
|
|
|
result &= gst_pad_activate_pull (pad, active);
|
|
|
|
if (result)
|
2011-11-01 00:45:25 +00:00
|
|
|
self->mode = GST_PAD_ACTIVATE_NONE;
|
2005-08-25 09:32:22 +00:00
|
|
|
result = TRUE;
|
|
|
|
} else {
|
|
|
|
g_warning ("foo");
|
|
|
|
result = FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-08-04 09:20:26 +00:00
|
|
|
GST_DEBUG_OBJECT (self, "result : %d", result);
|
ext/ladspa/gstsignalprocessor.c: Add debugs logs here and there, add more error handling, add some
Original commit message from CVS:
* ext/ladspa/gstsignalprocessor.c:
(gst_signal_processor_add_pad_from_template),
(gst_signal_processor_init), (gst_signal_processor_setcaps),
(gst_signal_processor_process), (gst_signal_processor_pen_buffer),
(gst_signal_processor_do_pulls), (gst_signal_processor_getrange),
(gst_signal_processor_sink_activate_push),
(gst_signal_processor_src_activate_pull),
(gst_signal_processor_change_state):
Add debugs logs here and there, add more error handling, add some
FIXME comments, filed #349189
2006-07-29 16:32:26 +00:00
|
|
|
|
2006-07-31 22:03:09 +00:00
|
|
|
gst_object_unref (self);
|
|
|
|
|
2005-08-25 09:32:22 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2005-09-02 15:44:44 +00:00
|
|
|
static GstStateChangeReturn
|
|
|
|
gst_signal_processor_change_state (GstElement * element,
|
|
|
|
GstStateChange transition)
|
2005-08-25 09:32:22 +00:00
|
|
|
{
|
2006-08-04 11:38:54 +00:00
|
|
|
GstSignalProcessor *self;
|
2005-09-02 15:44:44 +00:00
|
|
|
GstStateChangeReturn result;
|
2005-08-25 09:32:22 +00:00
|
|
|
|
2006-08-04 11:38:54 +00:00
|
|
|
self = GST_SIGNAL_PROCESSOR (element);
|
2005-08-25 09:32:22 +00:00
|
|
|
|
|
|
|
switch (transition) {
|
2005-09-02 15:44:44 +00:00
|
|
|
case GST_STATE_CHANGE_NULL_TO_READY:
|
2005-08-25 09:32:22 +00:00
|
|
|
break;
|
2005-09-02 15:44:44 +00:00
|
|
|
case GST_STATE_CHANGE_READY_TO_PAUSED:
|
2006-08-16 16:50:00 +00:00
|
|
|
self->flow_state = GST_FLOW_OK;
|
2005-08-25 09:32:22 +00:00
|
|
|
break;
|
2005-09-02 15:44:44 +00:00
|
|
|
case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
|
2005-08-25 09:32:22 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
ext/ladspa/gstsignalprocessor.c: Add debugs logs here and there, add more error handling, add some
Original commit message from CVS:
* ext/ladspa/gstsignalprocessor.c:
(gst_signal_processor_add_pad_from_template),
(gst_signal_processor_init), (gst_signal_processor_setcaps),
(gst_signal_processor_process), (gst_signal_processor_pen_buffer),
(gst_signal_processor_do_pulls), (gst_signal_processor_getrange),
(gst_signal_processor_sink_activate_push),
(gst_signal_processor_src_activate_pull),
(gst_signal_processor_change_state):
Add debugs logs here and there, add more error handling, add some
FIXME comments, filed #349189
2006-07-29 16:32:26 +00:00
|
|
|
if ((result =
|
|
|
|
GST_ELEMENT_CLASS (parent_class)->change_state (element,
|
|
|
|
transition)) == GST_STATE_CHANGE_FAILURE)
|
|
|
|
goto failure;
|
2005-08-25 09:32:22 +00:00
|
|
|
|
|
|
|
switch (transition) {
|
2005-09-02 15:44:44 +00:00
|
|
|
case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
|
2005-08-25 09:32:22 +00:00
|
|
|
break;
|
2005-09-02 15:44:44 +00:00
|
|
|
case GST_STATE_CHANGE_PAUSED_TO_READY:
|
2006-08-04 11:38:54 +00:00
|
|
|
if (GST_SIGNAL_PROCESSOR_IS_RUNNING (self))
|
|
|
|
gst_signal_processor_stop (self);
|
2006-08-16 16:50:00 +00:00
|
|
|
gst_signal_processor_flush (self);
|
2005-08-25 09:32:22 +00:00
|
|
|
break;
|
2005-09-02 15:44:44 +00:00
|
|
|
case GST_STATE_CHANGE_READY_TO_NULL:
|
2006-08-04 11:38:54 +00:00
|
|
|
if (GST_SIGNAL_PROCESSOR_IS_INITIALIZED (self))
|
|
|
|
gst_signal_processor_cleanup (self);
|
2005-08-25 09:32:22 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
ext/ladspa/gstsignalprocessor.c: Add debugs logs here and there, add more error handling, add some
Original commit message from CVS:
* ext/ladspa/gstsignalprocessor.c:
(gst_signal_processor_add_pad_from_template),
(gst_signal_processor_init), (gst_signal_processor_setcaps),
(gst_signal_processor_process), (gst_signal_processor_pen_buffer),
(gst_signal_processor_do_pulls), (gst_signal_processor_getrange),
(gst_signal_processor_sink_activate_push),
(gst_signal_processor_src_activate_pull),
(gst_signal_processor_change_state):
Add debugs logs here and there, add more error handling, add some
FIXME comments, filed #349189
2006-07-29 16:32:26 +00:00
|
|
|
|
|
|
|
/* ERRORS */
|
|
|
|
failure:
|
|
|
|
{
|
2006-08-04 09:05:53 +00:00
|
|
|
GST_DEBUG_OBJECT (element, "parent failed state change");
|
ext/ladspa/gstsignalprocessor.c: Add debugs logs here and there, add more error handling, add some
Original commit message from CVS:
* ext/ladspa/gstsignalprocessor.c:
(gst_signal_processor_add_pad_from_template),
(gst_signal_processor_init), (gst_signal_processor_setcaps),
(gst_signal_processor_process), (gst_signal_processor_pen_buffer),
(gst_signal_processor_do_pulls), (gst_signal_processor_getrange),
(gst_signal_processor_sink_activate_push),
(gst_signal_processor_src_activate_pull),
(gst_signal_processor_change_state):
Add debugs logs here and there, add more error handling, add some
FIXME comments, filed #349189
2006-07-29 16:32:26 +00:00
|
|
|
return result;
|
|
|
|
}
|
2005-08-25 09:32:22 +00:00
|
|
|
}
|