2003-07-16 16:08:13 +00:00
|
|
|
/* GStreamer libsndfile plugin
|
|
|
|
* Copyright (C) 2003 Andy Wingo <wingo at pobox dot com>
|
2003-06-16 14:56:34 +00:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2003-11-06 23:36:33 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
2003-11-07 12:47:02 +00:00
|
|
|
|
2004-01-19 14:07:32 +00:00
|
|
|
#include "gst/gst-i18n-plugin.h"
|
2003-06-16 14:56:34 +00:00
|
|
|
#include <string.h>
|
2003-07-16 16:08:13 +00:00
|
|
|
#include <gst/gst.h>
|
|
|
|
|
|
|
|
#include <gst/audio/audio.h>
|
|
|
|
|
2003-06-16 14:56:34 +00:00
|
|
|
#include "gstsf.h"
|
|
|
|
|
2003-07-16 16:08:13 +00:00
|
|
|
|
2006-04-25 21:56:38 +00:00
|
|
|
static const GstElementDetails sfsrc_details =
|
|
|
|
GST_ELEMENT_DETAILS ("Sndfile source",
|
2006-04-06 11:35:26 +00:00
|
|
|
"Source/Audio",
|
|
|
|
"Read audio streams from disk using libsndfile",
|
|
|
|
"Andy Wingo <wingo at pobox dot com>");
|
|
|
|
|
2006-04-25 21:56:38 +00:00
|
|
|
static const GstElementDetails sfsink_details =
|
|
|
|
GST_ELEMENT_DETAILS ("Sndfile sink",
|
2006-04-06 11:35:26 +00:00
|
|
|
"Sink/Audio",
|
|
|
|
"Write audio streams to disk using libsndfile",
|
|
|
|
"Andy Wingo <wingo at pobox dot com>");
|
2003-06-16 14:56:34 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
enum
|
|
|
|
{
|
2003-06-16 14:56:34 +00:00
|
|
|
ARG_0,
|
|
|
|
ARG_LOCATION,
|
|
|
|
ARG_MAJOR_TYPE,
|
|
|
|
ARG_MINOR_TYPE,
|
|
|
|
ARG_LOOP,
|
|
|
|
ARG_CREATE_PADS
|
|
|
|
};
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static GstStaticPadTemplate sf_src_factory = GST_STATIC_PAD_TEMPLATE ("src%d",
|
|
|
|
GST_PAD_SRC,
|
|
|
|
GST_PAD_REQUEST,
|
|
|
|
GST_STATIC_CAPS (GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_CAPS)
|
|
|
|
);
|
|
|
|
|
|
|
|
static GstStaticPadTemplate sf_sink_factory = GST_STATIC_PAD_TEMPLATE ("sink%d",
|
|
|
|
GST_PAD_SINK,
|
|
|
|
GST_PAD_REQUEST,
|
|
|
|
GST_STATIC_CAPS (GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_CAPS)
|
|
|
|
);
|
2003-06-16 14:56:34 +00:00
|
|
|
|
|
|
|
#define GST_TYPE_SF_MAJOR_TYPES (gst_sf_major_types_get_type())
|
|
|
|
static GType
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_sf_major_types_get_type (void)
|
2003-06-16 14:56:34 +00:00
|
|
|
{
|
|
|
|
static GType sf_major_types_type = 0;
|
|
|
|
static GEnumValue *sf_major_types = NULL;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
|
|
|
if (!sf_major_types_type) {
|
2003-06-16 14:56:34 +00:00
|
|
|
SF_FORMAT_INFO format_info;
|
2004-03-14 22:34:33 +00:00
|
|
|
int k, count;
|
2003-06-16 14:56:34 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
sf_command (NULL, SFC_GET_FORMAT_MAJOR_COUNT, &count, sizeof (int));
|
2003-06-16 14:56:34 +00:00
|
|
|
|
|
|
|
sf_major_types = g_new0 (GEnumValue, count + 1);
|
2004-03-14 22:34:33 +00:00
|
|
|
|
|
|
|
for (k = 0; k < count; k++) {
|
|
|
|
format_info.format = k;
|
|
|
|
sf_command (NULL, SFC_GET_FORMAT_MAJOR, &format_info,
|
2004-03-15 19:32:27 +00:00
|
|
|
sizeof (format_info));
|
2003-06-16 14:56:34 +00:00
|
|
|
sf_major_types[k].value = format_info.format;
|
|
|
|
sf_major_types[k].value_name = g_strdup (format_info.name);
|
|
|
|
sf_major_types[k].value_nick = g_strdup (format_info.extension);
|
|
|
|
|
|
|
|
/* Irritatingly enough, there exist major_types with the same extension. Let's
|
|
|
|
just hope that sndfile gives us the list in alphabetical order, as it
|
|
|
|
currently does. */
|
2004-03-14 22:34:33 +00:00
|
|
|
if (k > 0
|
2004-03-15 19:32:27 +00:00
|
|
|
&& strcmp (sf_major_types[k].value_nick,
|
|
|
|
sf_major_types[k - 1].value_nick) == 0) {
|
|
|
|
g_free (sf_major_types[k].value_nick);
|
|
|
|
sf_major_types[k].value_nick =
|
|
|
|
g_strconcat (sf_major_types[k - 1].value_nick, "-",
|
|
|
|
sf_major_types[k].value_name, NULL);
|
|
|
|
g_strcanon (sf_major_types[k].value_nick,
|
|
|
|
G_CSET_A_2_Z G_CSET_a_2_z G_CSET_DIGITS "-", '-');
|
2003-06-16 14:56:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
sf_major_types_type =
|
2004-03-15 19:32:27 +00:00
|
|
|
g_enum_register_static ("GstSndfileMajorTypes", sf_major_types);
|
2003-06-16 14:56:34 +00:00
|
|
|
}
|
|
|
|
return sf_major_types_type;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define GST_TYPE_SF_MINOR_TYPES (gst_sf_minor_types_get_type())
|
|
|
|
static GType
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_sf_minor_types_get_type (void)
|
2003-06-16 14:56:34 +00:00
|
|
|
{
|
|
|
|
static GType sf_minor_types_type = 0;
|
|
|
|
static GEnumValue *sf_minor_types = NULL;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
|
|
|
if (!sf_minor_types_type) {
|
2003-06-16 14:56:34 +00:00
|
|
|
SF_FORMAT_INFO format_info;
|
2004-03-14 22:34:33 +00:00
|
|
|
int k, count;
|
2003-06-16 14:56:34 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
sf_command (NULL, SFC_GET_FORMAT_SUBTYPE_COUNT, &count, sizeof (int));
|
2003-06-16 14:56:34 +00:00
|
|
|
|
|
|
|
sf_minor_types = g_new0 (GEnumValue, count + 1);
|
2004-03-14 22:34:33 +00:00
|
|
|
|
|
|
|
for (k = 0; k < count; k++) {
|
|
|
|
format_info.format = k;
|
|
|
|
sf_command (NULL, SFC_GET_FORMAT_SUBTYPE, &format_info,
|
2004-03-15 19:32:27 +00:00
|
|
|
sizeof (format_info));
|
2003-06-16 14:56:34 +00:00
|
|
|
sf_minor_types[k].value = format_info.format;
|
|
|
|
sf_minor_types[k].value_name = g_strdup (format_info.name);
|
|
|
|
sf_minor_types[k].value_nick = g_ascii_strdown (format_info.name, -1);
|
2004-03-14 22:34:33 +00:00
|
|
|
g_strcanon (sf_minor_types[k].value_nick, G_CSET_a_2_z G_CSET_DIGITS "-",
|
2004-03-15 19:32:27 +00:00
|
|
|
'-');
|
2003-06-16 14:56:34 +00:00
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
sf_minor_types_type =
|
2004-03-15 19:32:27 +00:00
|
|
|
g_enum_register_static ("GstSndfileMinorTypes", sf_minor_types);
|
2003-06-16 14:56:34 +00:00
|
|
|
}
|
|
|
|
return sf_minor_types_type;
|
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static void gst_sfsrc_base_init (gpointer g_class);
|
|
|
|
static void gst_sfsink_base_init (gpointer g_class);
|
|
|
|
static void gst_sf_class_init (GstSFClass * klass);
|
|
|
|
static void gst_sf_init (GstSF * this);
|
|
|
|
static void gst_sf_dispose (GObject * object);
|
|
|
|
static void gst_sf_set_property (GObject * object, guint prop_id,
|
|
|
|
const GValue * value, GParamSpec * pspec);
|
|
|
|
static void gst_sf_get_property (GObject * object, guint prop_id,
|
|
|
|
GValue * value, GParamSpec * pspec);
|
2003-07-16 16:08:13 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static GstClock *gst_sf_get_clock (GstElement * element);
|
|
|
|
static void gst_sf_set_clock (GstElement * element, GstClock * clock);
|
|
|
|
static GstPad *gst_sf_request_new_pad (GstElement * element,
|
|
|
|
GstPadTemplate * templ, const gchar * unused);
|
|
|
|
static void gst_sf_release_request_pad (GstElement * element, GstPad * pad);
|
2005-09-05 17:20:29 +00:00
|
|
|
static GstStateChangeReturn gst_sf_change_state (GstElement * element,
|
|
|
|
GstStateChange transition);
|
2003-06-16 14:56:34 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static GstPadLinkReturn gst_sf_link (GstPad * pad, const GstCaps * caps);
|
2003-06-16 14:56:34 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static void gst_sf_loop (GstElement * element);
|
2003-06-16 14:56:34 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static GstClockTime gst_sf_get_time (GstClock * clock, gpointer data);
|
2003-06-16 14:56:34 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static gboolean gst_sf_open_file (GstSF * this);
|
|
|
|
static void gst_sf_close_file (GstSF * this);
|
2003-06-16 14:56:34 +00:00
|
|
|
|
|
|
|
static GstElementClass *parent_class = NULL;
|
|
|
|
|
2003-07-16 16:08:13 +00:00
|
|
|
GST_DEBUG_CATEGORY_STATIC (gstsf_debug);
|
|
|
|
#define INFO(...) \
|
|
|
|
GST_CAT_LEVEL_LOG (gstsf_debug, GST_LEVEL_INFO, NULL, __VA_ARGS__)
|
|
|
|
#define INFO_OBJ(obj,...) \
|
|
|
|
GST_CAT_LEVEL_LOG (gstsf_debug, GST_LEVEL_INFO, obj, __VA_ARGS__)
|
|
|
|
|
2003-06-16 14:56:34 +00:00
|
|
|
GType
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_sf_get_type (void)
|
2003-06-16 14:56:34 +00:00
|
|
|
{
|
|
|
|
static GType sf_type = 0;
|
|
|
|
|
|
|
|
if (!sf_type) {
|
|
|
|
static const GTypeInfo sf_info = {
|
2004-03-14 22:34:33 +00:00
|
|
|
sizeof (GstSFClass), NULL,
|
2003-06-16 14:56:34 +00:00
|
|
|
NULL,
|
2004-03-15 19:32:27 +00:00
|
|
|
(GClassInitFunc) NULL, /* don't even initialize the class */
|
2003-06-16 14:56:34 +00:00
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
sizeof (GstSF),
|
|
|
|
0,
|
2004-03-15 19:32:27 +00:00
|
|
|
(GInstanceInitFunc) NULL /* abstract base class */
|
2003-06-16 14:56:34 +00:00
|
|
|
};
|
2004-03-15 19:32:27 +00:00
|
|
|
|
2003-06-16 14:56:34 +00:00
|
|
|
sf_type = g_type_register_static (GST_TYPE_ELEMENT, "GstSF", &sf_info, 0);
|
|
|
|
}
|
|
|
|
return sf_type;
|
|
|
|
}
|
|
|
|
|
|
|
|
GType
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_sfsrc_get_type (void)
|
2003-06-16 14:56:34 +00:00
|
|
|
{
|
|
|
|
static GType sfsrc_type = 0;
|
|
|
|
|
|
|
|
if (!sfsrc_type) {
|
|
|
|
static const GTypeInfo sfsrc_info = {
|
2003-11-02 01:46:25 +00:00
|
|
|
sizeof (GstSFClass),
|
|
|
|
gst_sfsrc_base_init,
|
2003-06-16 14:56:34 +00:00
|
|
|
NULL,
|
|
|
|
(GClassInitFunc) gst_sf_class_init,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
sizeof (GstSF),
|
|
|
|
0,
|
|
|
|
(GInstanceInitFunc) gst_sf_init,
|
|
|
|
};
|
2004-03-15 19:32:27 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
sfsrc_type =
|
2004-03-15 19:32:27 +00:00
|
|
|
g_type_register_static (GST_TYPE_SF, "GstSFSrc", &sfsrc_info, 0);
|
2003-06-16 14:56:34 +00:00
|
|
|
}
|
|
|
|
return sfsrc_type;
|
|
|
|
}
|
|
|
|
|
|
|
|
GType
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_sfsink_get_type (void)
|
2003-06-16 14:56:34 +00:00
|
|
|
{
|
|
|
|
static GType sfsink_type = 0;
|
|
|
|
|
|
|
|
if (!sfsink_type) {
|
|
|
|
static const GTypeInfo sfsink_info = {
|
2003-11-02 01:46:25 +00:00
|
|
|
sizeof (GstSFClass),
|
|
|
|
gst_sfsink_base_init,
|
2003-06-16 14:56:34 +00:00
|
|
|
NULL,
|
|
|
|
(GClassInitFunc) gst_sf_class_init,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
sizeof (GstSF),
|
|
|
|
0,
|
|
|
|
(GInstanceInitFunc) gst_sf_init,
|
|
|
|
};
|
2004-03-15 19:32:27 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
sfsink_type =
|
2004-03-15 19:32:27 +00:00
|
|
|
g_type_register_static (GST_TYPE_SF, "GstSFSink", &sfsink_info, 0);
|
2003-06-16 14:56:34 +00:00
|
|
|
}
|
|
|
|
return sfsink_type;
|
|
|
|
}
|
|
|
|
|
2003-11-02 01:46:25 +00:00
|
|
|
static void
|
|
|
|
gst_sfsrc_base_init (gpointer g_class)
|
|
|
|
{
|
|
|
|
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_element_class_add_pad_template (element_class,
|
|
|
|
gst_static_pad_template_get (&sf_src_factory));
|
2003-11-02 01:46:25 +00:00
|
|
|
gst_element_class_set_details (element_class, &sfsrc_details);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_sfsink_base_init (gpointer g_class)
|
|
|
|
{
|
|
|
|
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_element_class_add_pad_template (element_class,
|
|
|
|
gst_static_pad_template_get (&sf_sink_factory));
|
2003-11-02 01:46:25 +00:00
|
|
|
gst_element_class_set_details (element_class, &sfsink_details);
|
|
|
|
}
|
|
|
|
|
2003-06-16 14:56:34 +00:00
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_sf_class_init (GstSFClass * klass)
|
2003-06-16 14:56:34 +00:00
|
|
|
{
|
|
|
|
GObjectClass *gobject_class;
|
|
|
|
GstElementClass *gstelement_class;
|
|
|
|
GParamSpec *pspec;
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
gobject_class = (GObjectClass *) klass;
|
|
|
|
gstelement_class = (GstElementClass *) klass;
|
2003-06-16 14:56:34 +00:00
|
|
|
|
2006-04-08 21:48:01 +00:00
|
|
|
parent_class = g_type_class_peek_parent (klass);
|
2003-06-16 14:56:34 +00:00
|
|
|
|
|
|
|
gst_element_class_install_std_props (gstelement_class, "location",
|
2004-03-14 22:34:33 +00:00
|
|
|
ARG_LOCATION, G_PARAM_READWRITE, NULL);
|
2003-06-16 14:56:34 +00:00
|
|
|
pspec = g_param_spec_enum
|
2004-03-14 22:34:33 +00:00
|
|
|
("major-type", "Major type", "Major output type", GST_TYPE_SF_MAJOR_TYPES,
|
|
|
|
SF_FORMAT_WAV, G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
|
2003-06-16 14:56:34 +00:00
|
|
|
g_object_class_install_property (gobject_class, ARG_MAJOR_TYPE, pspec);
|
|
|
|
pspec = g_param_spec_enum
|
2004-03-14 22:34:33 +00:00
|
|
|
("minor-type", "Minor type", "Minor output type", GST_TYPE_SF_MINOR_TYPES,
|
|
|
|
SF_FORMAT_FLOAT, G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
|
2003-06-16 14:56:34 +00:00
|
|
|
g_object_class_install_property (gobject_class, ARG_MINOR_TYPE, pspec);
|
|
|
|
|
|
|
|
if (G_TYPE_FROM_CLASS (klass) == GST_TYPE_SFSRC) {
|
|
|
|
pspec = g_param_spec_boolean ("loop", "Loop?", "Loop the output?",
|
2004-03-15 19:32:27 +00:00
|
|
|
FALSE, G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
|
2003-06-16 14:56:34 +00:00
|
|
|
g_object_class_install_property (gobject_class, ARG_LOOP, pspec);
|
2004-03-14 22:34:33 +00:00
|
|
|
pspec =
|
2004-03-15 19:32:27 +00:00
|
|
|
g_param_spec_boolean ("create-pads", "Create pads?",
|
|
|
|
"Create one pad for each channel in the sound file?", TRUE,
|
|
|
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
|
2003-06-16 14:56:34 +00:00
|
|
|
g_object_class_install_property (gobject_class, ARG_CREATE_PADS, pspec);
|
|
|
|
}
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2003-07-16 16:08:13 +00:00
|
|
|
gobject_class->dispose = gst_sf_dispose;
|
2003-06-16 14:56:34 +00:00
|
|
|
gobject_class->set_property = gst_sf_set_property;
|
|
|
|
gobject_class->get_property = gst_sf_get_property;
|
|
|
|
|
2003-07-16 16:08:13 +00:00
|
|
|
gstelement_class->get_clock = gst_sf_get_clock;
|
|
|
|
gstelement_class->set_clock = gst_sf_set_clock;
|
2003-06-16 14:56:34 +00:00
|
|
|
gstelement_class->change_state = gst_sf_change_state;
|
|
|
|
gstelement_class->request_new_pad = gst_sf_request_new_pad;
|
2003-07-16 16:08:13 +00:00
|
|
|
gstelement_class->release_pad = gst_sf_release_request_pad;
|
2003-06-16 14:56:34 +00:00
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static void
|
|
|
|
gst_sf_init (GstSF * this)
|
2003-06-16 14:56:34 +00:00
|
|
|
{
|
|
|
|
gst_element_set_loop_function (GST_ELEMENT (this), gst_sf_loop);
|
2003-07-16 16:08:13 +00:00
|
|
|
this->provided_clock = gst_audio_clock_new ("sfclock", gst_sf_get_time, this);
|
|
|
|
gst_object_set_parent (GST_OBJECT (this->provided_clock), GST_OBJECT (this));
|
2003-06-16 14:56:34 +00:00
|
|
|
}
|
|
|
|
|
2003-07-16 16:08:13 +00:00
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_sf_dispose (GObject * object)
|
2003-06-16 14:56:34 +00:00
|
|
|
{
|
2004-03-14 22:34:33 +00:00
|
|
|
GstSF *this = (GstSF *) object;
|
2003-06-16 14:56:34 +00:00
|
|
|
|
Fixes a bunch of problems with finalize and dispose functions, either assumptions that dispose is only called once, o...
Original commit message from CVS:
* ext/alsa/gstalsa.c: (gst_alsa_class_init), (gst_alsa_dispose),
(gst_alsa_finalize):
* ext/cdaudio/gstcdaudio.c: (gst_cdaudio_class_init),
(gst_cdaudio_finalize):
* ext/cdparanoia/gstcdparanoia.c: (cdparanoia_class_init),
(cdparanoia_finalize):
* ext/divx/gstdivxdec.c: (gst_divxdec_dispose):
* ext/divx/gstdivxenc.c: (gst_divxenc_dispose):
* ext/dvdread/dvdreadsrc.c: (dvdreadsrc_class_init),
(dvdreadsrc_finalize):
* ext/flac/gstflacdec.c: (gst_flacdec_class_init),
(gst_flacdec_finalize):
* ext/flac/gstflacenc.c: (gst_flacenc_class_init),
(gst_flacenc_finalize):
* ext/gnomevfs/gstgnomevfssink.c: (gst_gnomevfssink_class_init),
(gst_gnomevfssink_finalize):
* ext/gnomevfs/gstgnomevfssrc.c: (gst_gnomevfssrc_class_init),
(gst_gnomevfssrc_finalize):
* ext/libfame/gstlibfame.c: (gst_fameenc_class_init),
(gst_fameenc_finalize):
* ext/nas/nassink.c: (gst_nassink_class_init),
(gst_nassink_finalize):
* ext/sdl/sdlvideosink.c: (gst_sdlvideosink_finalize),
(gst_sdlvideosink_class_init):
* ext/sndfile/gstsf.c: (gst_sf_dispose):
* gst-libs/gst/mixer/mixertrack.c: (gst_mixer_track_dispose):
* gst-libs/gst/tuner/tunerchannel.c: (gst_tuner_channel_dispose):
* gst-libs/gst/tuner/tunernorm.c: (gst_tuner_norm_dispose):
* gst-libs/gst/xwindowlistener/xwindowlistener.c:
(gst_x_window_listener_dispose):
* gst/audioscale/gstaudioscale.c:
* gst/playondemand/gstplayondemand.c: (play_on_demand_class_init),
(play_on_demand_finalize):
* gst/videofilter/gstvideobalance.c: (gst_videobalance_dispose):
* gst/videoscale/gstvideoscale.c: (gst_videoscale_chain):
* sys/cdrom/gstcdplayer.c: (cdplayer_class_init),
(cdplayer_finalize):
* sys/glsink/glimagesink.c: (gst_glimagesink_finalize),
(gst_glimagesink_class_init):
* sys/oss/gstosselement.c: (gst_osselement_class_init),
(gst_osselement_finalize):
* sys/oss/gstosssink.c: (gst_osssink_dispose):
* sys/oss/gstosssrc.c: (gst_osssrc_dispose):
* sys/v4l/gstv4lelement.c: (gst_v4lelement_dispose):
Fixes a bunch of problems with finalize and dispose functions,
either assumptions that dispose is only called once, or not calling
the parent class dispose/finalize function
2004-11-01 14:43:38 +00:00
|
|
|
if (this->provided_clock) {
|
|
|
|
gst_object_unparent (GST_OBJECT (this->provided_clock));
|
|
|
|
this->provided_clock = NULL;
|
|
|
|
}
|
2003-06-16 14:56:34 +00:00
|
|
|
|
2003-07-16 16:08:13 +00:00
|
|
|
G_OBJECT_CLASS (parent_class)->dispose (object);
|
2003-06-16 14:56:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_sf_set_property (GObject * object, guint prop_id, const GValue * value,
|
|
|
|
GParamSpec * pspec)
|
2003-06-16 14:56:34 +00:00
|
|
|
{
|
|
|
|
GstSF *this = GST_SF (object);
|
|
|
|
|
|
|
|
switch (prop_id) {
|
|
|
|
case ARG_LOCATION:
|
renamed GST_FLAGS macros to GST_OBJECT_FLAGS moved bitshift from macro to enum definition
Original commit message from CVS:
* examples/indexing/indexmpeg.c: (main):
* ext/artsd/gstartsdsink.c: (gst_artsdsink_open_audio),
(gst_artsdsink_close_audio), (gst_artsdsink_change_state):
* ext/artsd/gstartsdsink.h:
* ext/audiofile/gstafparse.c: (gst_afparse_open_file),
(gst_afparse_close_file):
* ext/audiofile/gstafparse.h:
* ext/audiofile/gstafsink.c: (gst_afsink_open_file),
(gst_afsink_close_file), (gst_afsink_chain),
(gst_afsink_change_state):
* ext/audiofile/gstafsink.h:
* ext/audiofile/gstafsrc.c: (gst_afsrc_open_file),
(gst_afsrc_close_file), (gst_afsrc_change_state):
* ext/audiofile/gstafsrc.h:
* ext/cdaudio/gstcdaudio.c: (gst_cdaudio_init):
* ext/directfb/directfbvideosink.c: (gst_directfbvideosink_init):
* ext/dts/gstdtsdec.c: (gst_dtsdec_init):
* ext/jack/gstjack.h:
* ext/jack/gstjackbin.c: (gst_jack_bin_init),
(gst_jack_bin_change_state):
* ext/musepack/gstmusepackdec.c: (gst_musepackdec_init):
* ext/musicbrainz/gsttrm.c: (gst_musicbrainz_init):
* ext/nas/nassink.c: (gst_nassink_open_audio),
(gst_nassink_close_audio), (gst_nassink_change_state):
* ext/nas/nassink.h:
* ext/polyp/polypsink.c: (gst_polypsink_init):
* ext/sdl/sdlvideosink.c: (gst_sdlvideosink_change_state):
* ext/sdl/sdlvideosink.h:
* ext/smoothwave/gstsmoothwave.c: (gst_smoothwave_init):
* ext/sndfile/gstsf.c: (gst_sf_set_property),
(gst_sf_change_state), (gst_sf_release_request_pad),
(gst_sf_open_file), (gst_sf_close_file), (gst_sf_loop):
* ext/sndfile/gstsf.h:
* ext/swfdec/gstswfdec.c: (gst_swfdec_init):
* ext/tarkin/gsttarkindec.c: (gst_tarkindec_init):
* gst/apetag/apedemux.c: (gst_ape_demux_init):
* gst/cdxaparse/gstcdxaparse.c: (gst_cdxaparse_init):
* gst/cdxaparse/gstcdxastrip.c: (gst_cdxastrip_init):
* gst/festival/gstfestival.c: (gst_festival_change_state):
* gst/festival/gstfestival.h:
* gst/mpeg2sub/gstmpeg2subt.c: (gst_mpeg2subt_init):
* gst/multifilesink/gstmultifilesink.c: (gst_multifilesink_init),
(gst_multifilesink_set_location), (gst_multifilesink_open_file),
(gst_multifilesink_close_file), (gst_multifilesink_next_file),
(gst_multifilesink_pad_query), (gst_multifilesink_handle_event),
(gst_multifilesink_chain), (gst_multifilesink_change_state):
* gst/multifilesink/gstmultifilesink.h:
* gst/videodrop/gstvideodrop.c: (gst_videodrop_init):
* sys/cdrom/gstcdplayer.c: (cdplayer_init):
* sys/dxr3/dxr3audiosink.c: (dxr3audiosink_init),
(dxr3audiosink_open), (dxr3audiosink_close),
(dxr3audiosink_chain_pcm), (dxr3audiosink_chain_ac3),
(dxr3audiosink_change_state):
* sys/dxr3/dxr3audiosink.h:
* sys/dxr3/dxr3spusink.c: (dxr3spusink_init), (dxr3spusink_open),
(dxr3spusink_close), (dxr3spusink_chain),
(dxr3spusink_change_state):
* sys/dxr3/dxr3spusink.h:
* sys/dxr3/dxr3videosink.c: (dxr3videosink_init),
(dxr3videosink_open), (dxr3videosink_close),
(dxr3videosink_write_data), (dxr3videosink_change_state):
* sys/dxr3/dxr3videosink.h:
* sys/glsink/glimagesink.c: (gst_glimagesink_init):
* sys/qcam/gstqcamsrc.c: (gst_qcamsrc_change_state),
(gst_qcamsrc_open), (gst_qcamsrc_close):
* sys/qcam/gstqcamsrc.h:
* sys/v4l2/gstv4l2src.c: (gst_v4l2src_init):
* sys/vcd/vcdsrc.c: (gst_vcdsrc_set_property), (gst_vcdsrc_get),
(gst_vcdsrc_open_file), (gst_vcdsrc_close_file),
(gst_vcdsrc_change_state), (gst_vcdsrc_recalculate):
* sys/vcd/vcdsrc.h:
renamed GST_FLAGS macros to GST_OBJECT_FLAGS
moved bitshift from macro to enum definition
2005-10-12 14:29:55 +00:00
|
|
|
if (GST_OBJECT_FLAG_IS_SET (object, GST_SF_OPEN))
|
2004-03-15 19:32:27 +00:00
|
|
|
gst_sf_close_file (this);
|
2003-06-16 14:56:34 +00:00
|
|
|
if (this->filename)
|
2004-03-15 19:32:27 +00:00
|
|
|
g_free (this->filename);
|
2003-06-16 14:56:34 +00:00
|
|
|
|
|
|
|
if (g_value_get_string (value))
|
2004-03-15 19:32:27 +00:00
|
|
|
this->filename = g_strdup (g_value_get_string (value));
|
2003-06-16 14:56:34 +00:00
|
|
|
else
|
2004-03-15 19:32:27 +00:00
|
|
|
this->filename = NULL;
|
2003-06-16 14:56:34 +00:00
|
|
|
|
|
|
|
if (this->filename)
|
2004-03-15 19:32:27 +00:00
|
|
|
gst_sf_open_file (this);
|
2003-06-16 14:56:34 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ARG_MAJOR_TYPE:
|
|
|
|
this->format_major = g_value_get_enum (value);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ARG_MINOR_TYPE:
|
|
|
|
this->format_subtype = g_value_get_enum (value);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ARG_LOOP:
|
|
|
|
this->loop = g_value_get_boolean (value);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ARG_CREATE_PADS:
|
|
|
|
this->create_pads = g_value_get_boolean (value);
|
|
|
|
if (this->file && this->create_pads) {
|
2004-03-15 19:32:27 +00:00
|
|
|
int i;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2004-03-15 19:32:27 +00:00
|
|
|
for (i = g_list_length (this->channels); i < this->numchannels; i++)
|
|
|
|
gst_element_get_request_pad ((GstElement *) this, "src%d");
|
2003-06-16 14:56:34 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static void
|
|
|
|
gst_sf_get_property (GObject * object, guint prop_id, GValue * value,
|
|
|
|
GParamSpec * pspec)
|
2003-06-16 14:56:34 +00:00
|
|
|
{
|
|
|
|
GstSF *this = GST_SF (object);
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2003-06-16 14:56:34 +00:00
|
|
|
switch (prop_id) {
|
|
|
|
case ARG_LOCATION:
|
|
|
|
g_value_set_string (value, this->filename);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ARG_MAJOR_TYPE:
|
|
|
|
g_value_set_enum (value, this->format_major);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ARG_MINOR_TYPE:
|
|
|
|
g_value_set_enum (value, this->format_subtype);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ARG_LOOP:
|
|
|
|
g_value_set_boolean (value, this->loop);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ARG_CREATE_PADS:
|
|
|
|
g_value_set_boolean (value, this->create_pads);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static GstClock *
|
|
|
|
gst_sf_get_clock (GstElement * element)
|
2003-07-16 16:08:13 +00:00
|
|
|
{
|
|
|
|
GstSF *this = GST_SF (element);
|
|
|
|
|
|
|
|
return this->provided_clock;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_sf_set_clock (GstElement * element, GstClock * clock)
|
2003-07-16 16:08:13 +00:00
|
|
|
{
|
|
|
|
GstSF *this = GST_SF (element);
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2003-07-16 16:08:13 +00:00
|
|
|
this->clock = clock;
|
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static GstClockTime
|
|
|
|
gst_sf_get_time (GstClock * clock, gpointer data)
|
2003-07-16 16:08:13 +00:00
|
|
|
{
|
|
|
|
GstSF *this = GST_SF (data);
|
|
|
|
|
|
|
|
return this->time;
|
|
|
|
}
|
|
|
|
|
2005-09-05 17:20:29 +00:00
|
|
|
static GstStateChangeReturn
|
|
|
|
gst_sf_change_state (GstElement * element, GstStateChange transition)
|
2003-07-16 16:08:13 +00:00
|
|
|
{
|
|
|
|
GstSF *this = GST_SF (element);
|
|
|
|
|
2005-09-05 17:20:29 +00:00
|
|
|
switch (transition) {
|
|
|
|
case GST_STATE_CHANGE_NULL_TO_READY:
|
2003-07-16 16:08:13 +00:00
|
|
|
break;
|
2005-09-05 17:20:29 +00:00
|
|
|
case GST_STATE_CHANGE_READY_TO_PAUSED:
|
2003-07-16 16:08:13 +00:00
|
|
|
break;
|
2005-09-05 17:20:29 +00:00
|
|
|
case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
|
2003-07-16 16:08:13 +00:00
|
|
|
gst_audio_clock_set_active (GST_AUDIO_CLOCK (this->provided_clock), TRUE);
|
|
|
|
break;
|
2005-09-05 17:20:29 +00:00
|
|
|
case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_audio_clock_set_active (GST_AUDIO_CLOCK (this->provided_clock),
|
2004-03-15 19:32:27 +00:00
|
|
|
FALSE);
|
2003-07-16 16:08:13 +00:00
|
|
|
break;
|
2005-09-05 17:20:29 +00:00
|
|
|
case GST_STATE_CHANGE_PAUSED_TO_READY:
|
2003-07-16 16:08:13 +00:00
|
|
|
break;
|
2005-09-05 17:20:29 +00:00
|
|
|
case GST_STATE_CHANGE_READY_TO_NULL:
|
renamed GST_FLAGS macros to GST_OBJECT_FLAGS moved bitshift from macro to enum definition
Original commit message from CVS:
* examples/indexing/indexmpeg.c: (main):
* ext/artsd/gstartsdsink.c: (gst_artsdsink_open_audio),
(gst_artsdsink_close_audio), (gst_artsdsink_change_state):
* ext/artsd/gstartsdsink.h:
* ext/audiofile/gstafparse.c: (gst_afparse_open_file),
(gst_afparse_close_file):
* ext/audiofile/gstafparse.h:
* ext/audiofile/gstafsink.c: (gst_afsink_open_file),
(gst_afsink_close_file), (gst_afsink_chain),
(gst_afsink_change_state):
* ext/audiofile/gstafsink.h:
* ext/audiofile/gstafsrc.c: (gst_afsrc_open_file),
(gst_afsrc_close_file), (gst_afsrc_change_state):
* ext/audiofile/gstafsrc.h:
* ext/cdaudio/gstcdaudio.c: (gst_cdaudio_init):
* ext/directfb/directfbvideosink.c: (gst_directfbvideosink_init):
* ext/dts/gstdtsdec.c: (gst_dtsdec_init):
* ext/jack/gstjack.h:
* ext/jack/gstjackbin.c: (gst_jack_bin_init),
(gst_jack_bin_change_state):
* ext/musepack/gstmusepackdec.c: (gst_musepackdec_init):
* ext/musicbrainz/gsttrm.c: (gst_musicbrainz_init):
* ext/nas/nassink.c: (gst_nassink_open_audio),
(gst_nassink_close_audio), (gst_nassink_change_state):
* ext/nas/nassink.h:
* ext/polyp/polypsink.c: (gst_polypsink_init):
* ext/sdl/sdlvideosink.c: (gst_sdlvideosink_change_state):
* ext/sdl/sdlvideosink.h:
* ext/smoothwave/gstsmoothwave.c: (gst_smoothwave_init):
* ext/sndfile/gstsf.c: (gst_sf_set_property),
(gst_sf_change_state), (gst_sf_release_request_pad),
(gst_sf_open_file), (gst_sf_close_file), (gst_sf_loop):
* ext/sndfile/gstsf.h:
* ext/swfdec/gstswfdec.c: (gst_swfdec_init):
* ext/tarkin/gsttarkindec.c: (gst_tarkindec_init):
* gst/apetag/apedemux.c: (gst_ape_demux_init):
* gst/cdxaparse/gstcdxaparse.c: (gst_cdxaparse_init):
* gst/cdxaparse/gstcdxastrip.c: (gst_cdxastrip_init):
* gst/festival/gstfestival.c: (gst_festival_change_state):
* gst/festival/gstfestival.h:
* gst/mpeg2sub/gstmpeg2subt.c: (gst_mpeg2subt_init):
* gst/multifilesink/gstmultifilesink.c: (gst_multifilesink_init),
(gst_multifilesink_set_location), (gst_multifilesink_open_file),
(gst_multifilesink_close_file), (gst_multifilesink_next_file),
(gst_multifilesink_pad_query), (gst_multifilesink_handle_event),
(gst_multifilesink_chain), (gst_multifilesink_change_state):
* gst/multifilesink/gstmultifilesink.h:
* gst/videodrop/gstvideodrop.c: (gst_videodrop_init):
* sys/cdrom/gstcdplayer.c: (cdplayer_init):
* sys/dxr3/dxr3audiosink.c: (dxr3audiosink_init),
(dxr3audiosink_open), (dxr3audiosink_close),
(dxr3audiosink_chain_pcm), (dxr3audiosink_chain_ac3),
(dxr3audiosink_change_state):
* sys/dxr3/dxr3audiosink.h:
* sys/dxr3/dxr3spusink.c: (dxr3spusink_init), (dxr3spusink_open),
(dxr3spusink_close), (dxr3spusink_chain),
(dxr3spusink_change_state):
* sys/dxr3/dxr3spusink.h:
* sys/dxr3/dxr3videosink.c: (dxr3videosink_init),
(dxr3videosink_open), (dxr3videosink_close),
(dxr3videosink_write_data), (dxr3videosink_change_state):
* sys/dxr3/dxr3videosink.h:
* sys/glsink/glimagesink.c: (gst_glimagesink_init):
* sys/qcam/gstqcamsrc.c: (gst_qcamsrc_change_state),
(gst_qcamsrc_open), (gst_qcamsrc_close):
* sys/qcam/gstqcamsrc.h:
* sys/v4l2/gstv4l2src.c: (gst_v4l2src_init):
* sys/vcd/vcdsrc.c: (gst_vcdsrc_set_property), (gst_vcdsrc_get),
(gst_vcdsrc_open_file), (gst_vcdsrc_close_file),
(gst_vcdsrc_change_state), (gst_vcdsrc_recalculate):
* sys/vcd/vcdsrc.h:
renamed GST_FLAGS macros to GST_OBJECT_FLAGS
moved bitshift from macro to enum definition
2005-10-12 14:29:55 +00:00
|
|
|
if (GST_OBJECT_FLAG_IS_SET (this, GST_SF_OPEN))
|
2004-03-15 19:32:27 +00:00
|
|
|
gst_sf_close_file (this);
|
2003-07-16 16:08:13 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (GST_ELEMENT_CLASS (parent_class)->change_state)
|
2005-09-05 17:20:29 +00:00
|
|
|
return GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
|
2003-07-16 16:08:13 +00:00
|
|
|
|
2005-09-05 17:20:29 +00:00
|
|
|
return GST_STATE_CHANGE_SUCCESS;
|
2003-07-16 16:08:13 +00:00
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static GstPad *
|
|
|
|
gst_sf_request_new_pad (GstElement * element, GstPadTemplate * templ,
|
|
|
|
const gchar * unused)
|
2003-07-16 16:08:13 +00:00
|
|
|
{
|
|
|
|
gchar *name;
|
|
|
|
GstSF *this;
|
|
|
|
GstSFChannel *channel;
|
|
|
|
|
|
|
|
this = GST_SF (element);
|
|
|
|
channel = g_new0 (GstSFChannel, 1);
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2003-07-16 16:08:13 +00:00
|
|
|
if (templ->direction == GST_PAD_SINK) {
|
|
|
|
/* we have an SFSink */
|
|
|
|
name = g_strdup_printf ("sink%d", this->channelcount);
|
|
|
|
this->numchannels++;
|
|
|
|
if (this->file) {
|
|
|
|
gst_sf_close_file (this);
|
|
|
|
gst_sf_open_file (this);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* we have an SFSrc */
|
|
|
|
name = g_strdup_printf ("src%d", this->channelcount);
|
|
|
|
}
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2003-07-16 16:08:13 +00:00
|
|
|
channel->pad = gst_pad_new_from_template (templ, name);
|
|
|
|
gst_element_add_pad (GST_ELEMENT (this), channel->pad);
|
|
|
|
gst_pad_set_link_function (channel->pad, gst_sf_link);
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2003-07-16 16:08:13 +00:00
|
|
|
this->channels = g_list_append (this->channels, channel);
|
|
|
|
this->channelcount++;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2003-07-16 16:08:13 +00:00
|
|
|
INFO_OBJ (element, "added pad %s\n", name);
|
|
|
|
|
|
|
|
g_free (name);
|
|
|
|
return channel->pad;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_sf_release_request_pad (GstElement * element, GstPad * pad)
|
2003-07-16 16:08:13 +00:00
|
|
|
{
|
|
|
|
GstSF *this;
|
|
|
|
GstSFChannel *channel = NULL;
|
|
|
|
GList *l;
|
|
|
|
|
|
|
|
this = GST_SF (element);
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2003-07-16 16:08:13 +00:00
|
|
|
if (GST_STATE (element) == GST_STATE_PLAYING) {
|
2004-03-14 22:34:33 +00:00
|
|
|
g_warning
|
2004-03-15 19:32:27 +00:00
|
|
|
("You can't release a request pad if the element is PLAYING, sorry.");
|
2003-07-16 16:08:13 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
for (l = this->channels; l; l = l->next) {
|
2003-07-16 16:08:13 +00:00
|
|
|
if (GST_SF_CHANNEL (l)->pad == pad) {
|
|
|
|
channel = GST_SF_CHANNEL (l);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
g_return_if_fail (channel != NULL);
|
|
|
|
|
|
|
|
INFO_OBJ (element, "Releasing request pad %s", GST_PAD_NAME (channel->pad));
|
|
|
|
|
renamed GST_FLAGS macros to GST_OBJECT_FLAGS moved bitshift from macro to enum definition
Original commit message from CVS:
* examples/indexing/indexmpeg.c: (main):
* ext/artsd/gstartsdsink.c: (gst_artsdsink_open_audio),
(gst_artsdsink_close_audio), (gst_artsdsink_change_state):
* ext/artsd/gstartsdsink.h:
* ext/audiofile/gstafparse.c: (gst_afparse_open_file),
(gst_afparse_close_file):
* ext/audiofile/gstafparse.h:
* ext/audiofile/gstafsink.c: (gst_afsink_open_file),
(gst_afsink_close_file), (gst_afsink_chain),
(gst_afsink_change_state):
* ext/audiofile/gstafsink.h:
* ext/audiofile/gstafsrc.c: (gst_afsrc_open_file),
(gst_afsrc_close_file), (gst_afsrc_change_state):
* ext/audiofile/gstafsrc.h:
* ext/cdaudio/gstcdaudio.c: (gst_cdaudio_init):
* ext/directfb/directfbvideosink.c: (gst_directfbvideosink_init):
* ext/dts/gstdtsdec.c: (gst_dtsdec_init):
* ext/jack/gstjack.h:
* ext/jack/gstjackbin.c: (gst_jack_bin_init),
(gst_jack_bin_change_state):
* ext/musepack/gstmusepackdec.c: (gst_musepackdec_init):
* ext/musicbrainz/gsttrm.c: (gst_musicbrainz_init):
* ext/nas/nassink.c: (gst_nassink_open_audio),
(gst_nassink_close_audio), (gst_nassink_change_state):
* ext/nas/nassink.h:
* ext/polyp/polypsink.c: (gst_polypsink_init):
* ext/sdl/sdlvideosink.c: (gst_sdlvideosink_change_state):
* ext/sdl/sdlvideosink.h:
* ext/smoothwave/gstsmoothwave.c: (gst_smoothwave_init):
* ext/sndfile/gstsf.c: (gst_sf_set_property),
(gst_sf_change_state), (gst_sf_release_request_pad),
(gst_sf_open_file), (gst_sf_close_file), (gst_sf_loop):
* ext/sndfile/gstsf.h:
* ext/swfdec/gstswfdec.c: (gst_swfdec_init):
* ext/tarkin/gsttarkindec.c: (gst_tarkindec_init):
* gst/apetag/apedemux.c: (gst_ape_demux_init):
* gst/cdxaparse/gstcdxaparse.c: (gst_cdxaparse_init):
* gst/cdxaparse/gstcdxastrip.c: (gst_cdxastrip_init):
* gst/festival/gstfestival.c: (gst_festival_change_state):
* gst/festival/gstfestival.h:
* gst/mpeg2sub/gstmpeg2subt.c: (gst_mpeg2subt_init):
* gst/multifilesink/gstmultifilesink.c: (gst_multifilesink_init),
(gst_multifilesink_set_location), (gst_multifilesink_open_file),
(gst_multifilesink_close_file), (gst_multifilesink_next_file),
(gst_multifilesink_pad_query), (gst_multifilesink_handle_event),
(gst_multifilesink_chain), (gst_multifilesink_change_state):
* gst/multifilesink/gstmultifilesink.h:
* gst/videodrop/gstvideodrop.c: (gst_videodrop_init):
* sys/cdrom/gstcdplayer.c: (cdplayer_init):
* sys/dxr3/dxr3audiosink.c: (dxr3audiosink_init),
(dxr3audiosink_open), (dxr3audiosink_close),
(dxr3audiosink_chain_pcm), (dxr3audiosink_chain_ac3),
(dxr3audiosink_change_state):
* sys/dxr3/dxr3audiosink.h:
* sys/dxr3/dxr3spusink.c: (dxr3spusink_init), (dxr3spusink_open),
(dxr3spusink_close), (dxr3spusink_chain),
(dxr3spusink_change_state):
* sys/dxr3/dxr3spusink.h:
* sys/dxr3/dxr3videosink.c: (dxr3videosink_init),
(dxr3videosink_open), (dxr3videosink_close),
(dxr3videosink_write_data), (dxr3videosink_change_state):
* sys/dxr3/dxr3videosink.h:
* sys/glsink/glimagesink.c: (gst_glimagesink_init):
* sys/qcam/gstqcamsrc.c: (gst_qcamsrc_change_state),
(gst_qcamsrc_open), (gst_qcamsrc_close):
* sys/qcam/gstqcamsrc.h:
* sys/v4l2/gstv4l2src.c: (gst_v4l2src_init):
* sys/vcd/vcdsrc.c: (gst_vcdsrc_set_property), (gst_vcdsrc_get),
(gst_vcdsrc_open_file), (gst_vcdsrc_close_file),
(gst_vcdsrc_change_state), (gst_vcdsrc_recalculate):
* sys/vcd/vcdsrc.h:
renamed GST_FLAGS macros to GST_OBJECT_FLAGS
moved bitshift from macro to enum definition
2005-10-12 14:29:55 +00:00
|
|
|
if (GST_OBJECT_FLAG_IS_SET (element, GST_SF_OPEN))
|
2003-07-16 16:08:13 +00:00
|
|
|
gst_sf_close_file (this);
|
|
|
|
|
|
|
|
gst_element_remove_pad (element, channel->pad);
|
|
|
|
this->channels = g_list_remove (this->channels, channel);
|
|
|
|
this->numchannels--;
|
|
|
|
g_free (channel);
|
|
|
|
}
|
|
|
|
|
|
|
|
static GstPadLinkReturn
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_sf_link (GstPad * pad, const GstCaps * caps)
|
2003-07-16 16:08:13 +00:00
|
|
|
{
|
2004-03-14 22:34:33 +00:00
|
|
|
GstSF *this = (GstSF *) GST_OBJECT_PARENT (pad);
|
2003-12-22 01:47:09 +00:00
|
|
|
GstStructure *structure;
|
|
|
|
|
|
|
|
structure = gst_caps_get_structure (caps, 0);
|
2004-03-14 22:34:33 +00:00
|
|
|
|
|
|
|
gst_structure_get_int (structure, "rate", &this->rate);
|
|
|
|
gst_structure_get_int (structure, "buffer-frames", &this->buffer_frames);
|
2003-12-22 01:47:09 +00:00
|
|
|
|
2004-02-20 14:17:57 +00:00
|
|
|
INFO_OBJ (this, "linked pad %s:%s with fixed caps, rate=%d, frames=%d",
|
2004-03-14 22:34:33 +00:00
|
|
|
GST_DEBUG_PAD_NAME (pad), this->rate, this->buffer_frames);
|
2003-12-22 01:47:09 +00:00
|
|
|
|
|
|
|
if (this->numchannels) {
|
|
|
|
/* we can go ahead and allocate our buffer */
|
|
|
|
if (this->buffer)
|
|
|
|
g_free (this->buffer);
|
2004-03-14 22:34:33 +00:00
|
|
|
this->buffer =
|
2004-03-15 19:32:27 +00:00
|
|
|
g_malloc (this->numchannels * this->buffer_frames * sizeof (float));
|
2004-03-14 22:34:33 +00:00
|
|
|
memset (this->buffer, 0,
|
2004-03-15 19:32:27 +00:00
|
|
|
this->numchannels * this->buffer_frames * sizeof (float));
|
2003-07-16 16:08:13 +00:00
|
|
|
}
|
2003-12-22 01:47:09 +00:00
|
|
|
return GST_PAD_LINK_OK;
|
2003-07-16 16:08:13 +00:00
|
|
|
}
|
|
|
|
|
2003-06-16 14:56:34 +00:00
|
|
|
static gboolean
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_sf_open_file (GstSF * this)
|
2003-06-16 14:56:34 +00:00
|
|
|
{
|
|
|
|
int mode;
|
|
|
|
SF_INFO info;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
renamed GST_FLAGS macros to GST_OBJECT_FLAGS moved bitshift from macro to enum definition
Original commit message from CVS:
* examples/indexing/indexmpeg.c: (main):
* ext/artsd/gstartsdsink.c: (gst_artsdsink_open_audio),
(gst_artsdsink_close_audio), (gst_artsdsink_change_state):
* ext/artsd/gstartsdsink.h:
* ext/audiofile/gstafparse.c: (gst_afparse_open_file),
(gst_afparse_close_file):
* ext/audiofile/gstafparse.h:
* ext/audiofile/gstafsink.c: (gst_afsink_open_file),
(gst_afsink_close_file), (gst_afsink_chain),
(gst_afsink_change_state):
* ext/audiofile/gstafsink.h:
* ext/audiofile/gstafsrc.c: (gst_afsrc_open_file),
(gst_afsrc_close_file), (gst_afsrc_change_state):
* ext/audiofile/gstafsrc.h:
* ext/cdaudio/gstcdaudio.c: (gst_cdaudio_init):
* ext/directfb/directfbvideosink.c: (gst_directfbvideosink_init):
* ext/dts/gstdtsdec.c: (gst_dtsdec_init):
* ext/jack/gstjack.h:
* ext/jack/gstjackbin.c: (gst_jack_bin_init),
(gst_jack_bin_change_state):
* ext/musepack/gstmusepackdec.c: (gst_musepackdec_init):
* ext/musicbrainz/gsttrm.c: (gst_musicbrainz_init):
* ext/nas/nassink.c: (gst_nassink_open_audio),
(gst_nassink_close_audio), (gst_nassink_change_state):
* ext/nas/nassink.h:
* ext/polyp/polypsink.c: (gst_polypsink_init):
* ext/sdl/sdlvideosink.c: (gst_sdlvideosink_change_state):
* ext/sdl/sdlvideosink.h:
* ext/smoothwave/gstsmoothwave.c: (gst_smoothwave_init):
* ext/sndfile/gstsf.c: (gst_sf_set_property),
(gst_sf_change_state), (gst_sf_release_request_pad),
(gst_sf_open_file), (gst_sf_close_file), (gst_sf_loop):
* ext/sndfile/gstsf.h:
* ext/swfdec/gstswfdec.c: (gst_swfdec_init):
* ext/tarkin/gsttarkindec.c: (gst_tarkindec_init):
* gst/apetag/apedemux.c: (gst_ape_demux_init):
* gst/cdxaparse/gstcdxaparse.c: (gst_cdxaparse_init):
* gst/cdxaparse/gstcdxastrip.c: (gst_cdxastrip_init):
* gst/festival/gstfestival.c: (gst_festival_change_state):
* gst/festival/gstfestival.h:
* gst/mpeg2sub/gstmpeg2subt.c: (gst_mpeg2subt_init):
* gst/multifilesink/gstmultifilesink.c: (gst_multifilesink_init),
(gst_multifilesink_set_location), (gst_multifilesink_open_file),
(gst_multifilesink_close_file), (gst_multifilesink_next_file),
(gst_multifilesink_pad_query), (gst_multifilesink_handle_event),
(gst_multifilesink_chain), (gst_multifilesink_change_state):
* gst/multifilesink/gstmultifilesink.h:
* gst/videodrop/gstvideodrop.c: (gst_videodrop_init):
* sys/cdrom/gstcdplayer.c: (cdplayer_init):
* sys/dxr3/dxr3audiosink.c: (dxr3audiosink_init),
(dxr3audiosink_open), (dxr3audiosink_close),
(dxr3audiosink_chain_pcm), (dxr3audiosink_chain_ac3),
(dxr3audiosink_change_state):
* sys/dxr3/dxr3audiosink.h:
* sys/dxr3/dxr3spusink.c: (dxr3spusink_init), (dxr3spusink_open),
(dxr3spusink_close), (dxr3spusink_chain),
(dxr3spusink_change_state):
* sys/dxr3/dxr3spusink.h:
* sys/dxr3/dxr3videosink.c: (dxr3videosink_init),
(dxr3videosink_open), (dxr3videosink_close),
(dxr3videosink_write_data), (dxr3videosink_change_state):
* sys/dxr3/dxr3videosink.h:
* sys/glsink/glimagesink.c: (gst_glimagesink_init):
* sys/qcam/gstqcamsrc.c: (gst_qcamsrc_change_state),
(gst_qcamsrc_open), (gst_qcamsrc_close):
* sys/qcam/gstqcamsrc.h:
* sys/v4l2/gstv4l2src.c: (gst_v4l2src_init):
* sys/vcd/vcdsrc.c: (gst_vcdsrc_set_property), (gst_vcdsrc_get),
(gst_vcdsrc_open_file), (gst_vcdsrc_close_file),
(gst_vcdsrc_change_state), (gst_vcdsrc_recalculate):
* sys/vcd/vcdsrc.h:
renamed GST_FLAGS macros to GST_OBJECT_FLAGS
moved bitshift from macro to enum definition
2005-10-12 14:29:55 +00:00
|
|
|
g_return_val_if_fail (!GST_OBJECT_FLAG_IS_SET (this, GST_SF_OPEN), FALSE);
|
2003-06-16 14:56:34 +00:00
|
|
|
|
2003-07-16 16:08:13 +00:00
|
|
|
this->time = 0;
|
|
|
|
|
2003-06-16 14:56:34 +00:00
|
|
|
if (!this->filename) {
|
2004-01-29 23:20:45 +00:00
|
|
|
GST_ELEMENT_ERROR (this, RESOURCE, NOT_FOUND,
|
2004-03-15 19:32:27 +00:00
|
|
|
(_("No filename specified.")), (NULL));
|
2003-06-16 14:56:34 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2003-06-16 14:56:34 +00:00
|
|
|
if (GST_IS_SFSRC (this)) {
|
|
|
|
mode = SFM_READ;
|
|
|
|
info.format = 0;
|
|
|
|
} else {
|
2003-07-16 16:08:13 +00:00
|
|
|
if (!this->rate) {
|
2004-03-14 22:34:33 +00:00
|
|
|
INFO_OBJ (this, "Not opening %s yet because caps are not set",
|
2004-03-15 19:32:27 +00:00
|
|
|
this->filename);
|
2003-07-16 16:08:13 +00:00
|
|
|
return FALSE;
|
|
|
|
} else if (!this->numchannels) {
|
2004-03-14 22:34:33 +00:00
|
|
|
INFO_OBJ (this, "Not opening %s yet because we have no input channels",
|
2004-03-15 19:32:27 +00:00
|
|
|
this->filename);
|
2003-07-16 16:08:13 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2003-06-16 14:56:34 +00:00
|
|
|
mode = SFM_WRITE;
|
|
|
|
this->format = this->format_major | this->format_subtype;
|
|
|
|
info.samplerate = this->rate;
|
|
|
|
info.channels = this->numchannels;
|
|
|
|
info.format = this->format;
|
|
|
|
|
2003-07-16 16:08:13 +00:00
|
|
|
INFO_OBJ (this, "Opening %s with rate %d, %d channels, format 0x%x",
|
2004-03-15 19:32:27 +00:00
|
|
|
this->filename, info.samplerate, info.channels, info.format);
|
2003-07-16 16:08:13 +00:00
|
|
|
|
2003-06-16 14:56:34 +00:00
|
|
|
if (!sf_format_check (&info)) {
|
2004-02-02 17:23:33 +00:00
|
|
|
GST_ELEMENT_ERROR (this, STREAM, ENCODE, (NULL),
|
2004-03-15 19:32:27 +00:00
|
|
|
("Input parameters (rate:%d, channels:%d, format:0x%x) invalid",
|
|
|
|
info.samplerate, info.channels, info.format));
|
2003-06-16 14:56:34 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
this->file = sf_open (this->filename, mode, &info);
|
|
|
|
|
|
|
|
if (!this->file) {
|
2004-01-29 23:20:45 +00:00
|
|
|
GST_ELEMENT_ERROR (this, RESOURCE, OPEN_WRITE,
|
2004-03-15 19:32:27 +00:00
|
|
|
(_("Could not open file \"%s\" for writing."), this->filename),
|
|
|
|
("soundfile error: %s", sf_strerror (NULL)));
|
2003-06-16 14:56:34 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (GST_IS_SFSRC (this)) {
|
|
|
|
GList *l = NULL;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2003-06-16 14:56:34 +00:00
|
|
|
/* the number of channels in the file can be different than the number of
|
|
|
|
* pads */
|
|
|
|
this->numchannels = info.channels;
|
|
|
|
this->rate = info.samplerate;
|
|
|
|
|
|
|
|
if (this->create_pads) {
|
|
|
|
int i;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
|
|
|
for (i = g_list_length (this->channels); i < this->numchannels; i++)
|
2004-03-15 19:32:27 +00:00
|
|
|
gst_element_get_request_pad ((GstElement *) this, "src%d");
|
2003-06-16 14:56:34 +00:00
|
|
|
}
|
2004-03-14 22:34:33 +00:00
|
|
|
|
|
|
|
for (l = this->channels; l; l = l->next)
|
2003-06-16 14:56:34 +00:00
|
|
|
/* queue the need to set caps */
|
|
|
|
GST_SF_CHANNEL (l)->caps_set = FALSE;
|
|
|
|
}
|
|
|
|
|
renamed GST_FLAGS macros to GST_OBJECT_FLAGS moved bitshift from macro to enum definition
Original commit message from CVS:
* examples/indexing/indexmpeg.c: (main):
* ext/artsd/gstartsdsink.c: (gst_artsdsink_open_audio),
(gst_artsdsink_close_audio), (gst_artsdsink_change_state):
* ext/artsd/gstartsdsink.h:
* ext/audiofile/gstafparse.c: (gst_afparse_open_file),
(gst_afparse_close_file):
* ext/audiofile/gstafparse.h:
* ext/audiofile/gstafsink.c: (gst_afsink_open_file),
(gst_afsink_close_file), (gst_afsink_chain),
(gst_afsink_change_state):
* ext/audiofile/gstafsink.h:
* ext/audiofile/gstafsrc.c: (gst_afsrc_open_file),
(gst_afsrc_close_file), (gst_afsrc_change_state):
* ext/audiofile/gstafsrc.h:
* ext/cdaudio/gstcdaudio.c: (gst_cdaudio_init):
* ext/directfb/directfbvideosink.c: (gst_directfbvideosink_init):
* ext/dts/gstdtsdec.c: (gst_dtsdec_init):
* ext/jack/gstjack.h:
* ext/jack/gstjackbin.c: (gst_jack_bin_init),
(gst_jack_bin_change_state):
* ext/musepack/gstmusepackdec.c: (gst_musepackdec_init):
* ext/musicbrainz/gsttrm.c: (gst_musicbrainz_init):
* ext/nas/nassink.c: (gst_nassink_open_audio),
(gst_nassink_close_audio), (gst_nassink_change_state):
* ext/nas/nassink.h:
* ext/polyp/polypsink.c: (gst_polypsink_init):
* ext/sdl/sdlvideosink.c: (gst_sdlvideosink_change_state):
* ext/sdl/sdlvideosink.h:
* ext/smoothwave/gstsmoothwave.c: (gst_smoothwave_init):
* ext/sndfile/gstsf.c: (gst_sf_set_property),
(gst_sf_change_state), (gst_sf_release_request_pad),
(gst_sf_open_file), (gst_sf_close_file), (gst_sf_loop):
* ext/sndfile/gstsf.h:
* ext/swfdec/gstswfdec.c: (gst_swfdec_init):
* ext/tarkin/gsttarkindec.c: (gst_tarkindec_init):
* gst/apetag/apedemux.c: (gst_ape_demux_init):
* gst/cdxaparse/gstcdxaparse.c: (gst_cdxaparse_init):
* gst/cdxaparse/gstcdxastrip.c: (gst_cdxastrip_init):
* gst/festival/gstfestival.c: (gst_festival_change_state):
* gst/festival/gstfestival.h:
* gst/mpeg2sub/gstmpeg2subt.c: (gst_mpeg2subt_init):
* gst/multifilesink/gstmultifilesink.c: (gst_multifilesink_init),
(gst_multifilesink_set_location), (gst_multifilesink_open_file),
(gst_multifilesink_close_file), (gst_multifilesink_next_file),
(gst_multifilesink_pad_query), (gst_multifilesink_handle_event),
(gst_multifilesink_chain), (gst_multifilesink_change_state):
* gst/multifilesink/gstmultifilesink.h:
* gst/videodrop/gstvideodrop.c: (gst_videodrop_init):
* sys/cdrom/gstcdplayer.c: (cdplayer_init):
* sys/dxr3/dxr3audiosink.c: (dxr3audiosink_init),
(dxr3audiosink_open), (dxr3audiosink_close),
(dxr3audiosink_chain_pcm), (dxr3audiosink_chain_ac3),
(dxr3audiosink_change_state):
* sys/dxr3/dxr3audiosink.h:
* sys/dxr3/dxr3spusink.c: (dxr3spusink_init), (dxr3spusink_open),
(dxr3spusink_close), (dxr3spusink_chain),
(dxr3spusink_change_state):
* sys/dxr3/dxr3spusink.h:
* sys/dxr3/dxr3videosink.c: (dxr3videosink_init),
(dxr3videosink_open), (dxr3videosink_close),
(dxr3videosink_write_data), (dxr3videosink_change_state):
* sys/dxr3/dxr3videosink.h:
* sys/glsink/glimagesink.c: (gst_glimagesink_init):
* sys/qcam/gstqcamsrc.c: (gst_qcamsrc_change_state),
(gst_qcamsrc_open), (gst_qcamsrc_close):
* sys/qcam/gstqcamsrc.h:
* sys/v4l2/gstv4l2src.c: (gst_v4l2src_init):
* sys/vcd/vcdsrc.c: (gst_vcdsrc_set_property), (gst_vcdsrc_get),
(gst_vcdsrc_open_file), (gst_vcdsrc_close_file),
(gst_vcdsrc_change_state), (gst_vcdsrc_recalculate):
* sys/vcd/vcdsrc.h:
renamed GST_FLAGS macros to GST_OBJECT_FLAGS
moved bitshift from macro to enum definition
2005-10-12 14:29:55 +00:00
|
|
|
GST_OBJECT_FLAG_SET (this, GST_SF_OPEN);
|
2003-06-16 14:56:34 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_sf_close_file (GstSF * this)
|
2003-06-16 14:56:34 +00:00
|
|
|
{
|
|
|
|
int err = 0;
|
|
|
|
|
renamed GST_FLAGS macros to GST_OBJECT_FLAGS moved bitshift from macro to enum definition
Original commit message from CVS:
* examples/indexing/indexmpeg.c: (main):
* ext/artsd/gstartsdsink.c: (gst_artsdsink_open_audio),
(gst_artsdsink_close_audio), (gst_artsdsink_change_state):
* ext/artsd/gstartsdsink.h:
* ext/audiofile/gstafparse.c: (gst_afparse_open_file),
(gst_afparse_close_file):
* ext/audiofile/gstafparse.h:
* ext/audiofile/gstafsink.c: (gst_afsink_open_file),
(gst_afsink_close_file), (gst_afsink_chain),
(gst_afsink_change_state):
* ext/audiofile/gstafsink.h:
* ext/audiofile/gstafsrc.c: (gst_afsrc_open_file),
(gst_afsrc_close_file), (gst_afsrc_change_state):
* ext/audiofile/gstafsrc.h:
* ext/cdaudio/gstcdaudio.c: (gst_cdaudio_init):
* ext/directfb/directfbvideosink.c: (gst_directfbvideosink_init):
* ext/dts/gstdtsdec.c: (gst_dtsdec_init):
* ext/jack/gstjack.h:
* ext/jack/gstjackbin.c: (gst_jack_bin_init),
(gst_jack_bin_change_state):
* ext/musepack/gstmusepackdec.c: (gst_musepackdec_init):
* ext/musicbrainz/gsttrm.c: (gst_musicbrainz_init):
* ext/nas/nassink.c: (gst_nassink_open_audio),
(gst_nassink_close_audio), (gst_nassink_change_state):
* ext/nas/nassink.h:
* ext/polyp/polypsink.c: (gst_polypsink_init):
* ext/sdl/sdlvideosink.c: (gst_sdlvideosink_change_state):
* ext/sdl/sdlvideosink.h:
* ext/smoothwave/gstsmoothwave.c: (gst_smoothwave_init):
* ext/sndfile/gstsf.c: (gst_sf_set_property),
(gst_sf_change_state), (gst_sf_release_request_pad),
(gst_sf_open_file), (gst_sf_close_file), (gst_sf_loop):
* ext/sndfile/gstsf.h:
* ext/swfdec/gstswfdec.c: (gst_swfdec_init):
* ext/tarkin/gsttarkindec.c: (gst_tarkindec_init):
* gst/apetag/apedemux.c: (gst_ape_demux_init):
* gst/cdxaparse/gstcdxaparse.c: (gst_cdxaparse_init):
* gst/cdxaparse/gstcdxastrip.c: (gst_cdxastrip_init):
* gst/festival/gstfestival.c: (gst_festival_change_state):
* gst/festival/gstfestival.h:
* gst/mpeg2sub/gstmpeg2subt.c: (gst_mpeg2subt_init):
* gst/multifilesink/gstmultifilesink.c: (gst_multifilesink_init),
(gst_multifilesink_set_location), (gst_multifilesink_open_file),
(gst_multifilesink_close_file), (gst_multifilesink_next_file),
(gst_multifilesink_pad_query), (gst_multifilesink_handle_event),
(gst_multifilesink_chain), (gst_multifilesink_change_state):
* gst/multifilesink/gstmultifilesink.h:
* gst/videodrop/gstvideodrop.c: (gst_videodrop_init):
* sys/cdrom/gstcdplayer.c: (cdplayer_init):
* sys/dxr3/dxr3audiosink.c: (dxr3audiosink_init),
(dxr3audiosink_open), (dxr3audiosink_close),
(dxr3audiosink_chain_pcm), (dxr3audiosink_chain_ac3),
(dxr3audiosink_change_state):
* sys/dxr3/dxr3audiosink.h:
* sys/dxr3/dxr3spusink.c: (dxr3spusink_init), (dxr3spusink_open),
(dxr3spusink_close), (dxr3spusink_chain),
(dxr3spusink_change_state):
* sys/dxr3/dxr3spusink.h:
* sys/dxr3/dxr3videosink.c: (dxr3videosink_init),
(dxr3videosink_open), (dxr3videosink_close),
(dxr3videosink_write_data), (dxr3videosink_change_state):
* sys/dxr3/dxr3videosink.h:
* sys/glsink/glimagesink.c: (gst_glimagesink_init):
* sys/qcam/gstqcamsrc.c: (gst_qcamsrc_change_state),
(gst_qcamsrc_open), (gst_qcamsrc_close):
* sys/qcam/gstqcamsrc.h:
* sys/v4l2/gstv4l2src.c: (gst_v4l2src_init):
* sys/vcd/vcdsrc.c: (gst_vcdsrc_set_property), (gst_vcdsrc_get),
(gst_vcdsrc_open_file), (gst_vcdsrc_close_file),
(gst_vcdsrc_change_state), (gst_vcdsrc_recalculate):
* sys/vcd/vcdsrc.h:
renamed GST_FLAGS macros to GST_OBJECT_FLAGS
moved bitshift from macro to enum definition
2005-10-12 14:29:55 +00:00
|
|
|
g_return_if_fail (GST_OBJECT_FLAG_IS_SET (this, GST_SF_OPEN));
|
2003-06-16 14:56:34 +00:00
|
|
|
|
2003-07-16 16:08:13 +00:00
|
|
|
INFO_OBJ (this, "Closing file %s", this->filename);
|
|
|
|
|
2003-06-16 14:56:34 +00:00
|
|
|
if ((err = sf_close (this->file)))
|
2004-01-29 23:20:45 +00:00
|
|
|
GST_ELEMENT_ERROR (this, RESOURCE, CLOSE,
|
2004-03-15 19:32:27 +00:00
|
|
|
("Could not close file file \"%s\".", this->filename),
|
|
|
|
("soundfile error: %s", strerror (err)));
|
2003-06-16 14:56:34 +00:00
|
|
|
else
|
renamed GST_FLAGS macros to GST_OBJECT_FLAGS moved bitshift from macro to enum definition
Original commit message from CVS:
* examples/indexing/indexmpeg.c: (main):
* ext/artsd/gstartsdsink.c: (gst_artsdsink_open_audio),
(gst_artsdsink_close_audio), (gst_artsdsink_change_state):
* ext/artsd/gstartsdsink.h:
* ext/audiofile/gstafparse.c: (gst_afparse_open_file),
(gst_afparse_close_file):
* ext/audiofile/gstafparse.h:
* ext/audiofile/gstafsink.c: (gst_afsink_open_file),
(gst_afsink_close_file), (gst_afsink_chain),
(gst_afsink_change_state):
* ext/audiofile/gstafsink.h:
* ext/audiofile/gstafsrc.c: (gst_afsrc_open_file),
(gst_afsrc_close_file), (gst_afsrc_change_state):
* ext/audiofile/gstafsrc.h:
* ext/cdaudio/gstcdaudio.c: (gst_cdaudio_init):
* ext/directfb/directfbvideosink.c: (gst_directfbvideosink_init):
* ext/dts/gstdtsdec.c: (gst_dtsdec_init):
* ext/jack/gstjack.h:
* ext/jack/gstjackbin.c: (gst_jack_bin_init),
(gst_jack_bin_change_state):
* ext/musepack/gstmusepackdec.c: (gst_musepackdec_init):
* ext/musicbrainz/gsttrm.c: (gst_musicbrainz_init):
* ext/nas/nassink.c: (gst_nassink_open_audio),
(gst_nassink_close_audio), (gst_nassink_change_state):
* ext/nas/nassink.h:
* ext/polyp/polypsink.c: (gst_polypsink_init):
* ext/sdl/sdlvideosink.c: (gst_sdlvideosink_change_state):
* ext/sdl/sdlvideosink.h:
* ext/smoothwave/gstsmoothwave.c: (gst_smoothwave_init):
* ext/sndfile/gstsf.c: (gst_sf_set_property),
(gst_sf_change_state), (gst_sf_release_request_pad),
(gst_sf_open_file), (gst_sf_close_file), (gst_sf_loop):
* ext/sndfile/gstsf.h:
* ext/swfdec/gstswfdec.c: (gst_swfdec_init):
* ext/tarkin/gsttarkindec.c: (gst_tarkindec_init):
* gst/apetag/apedemux.c: (gst_ape_demux_init):
* gst/cdxaparse/gstcdxaparse.c: (gst_cdxaparse_init):
* gst/cdxaparse/gstcdxastrip.c: (gst_cdxastrip_init):
* gst/festival/gstfestival.c: (gst_festival_change_state):
* gst/festival/gstfestival.h:
* gst/mpeg2sub/gstmpeg2subt.c: (gst_mpeg2subt_init):
* gst/multifilesink/gstmultifilesink.c: (gst_multifilesink_init),
(gst_multifilesink_set_location), (gst_multifilesink_open_file),
(gst_multifilesink_close_file), (gst_multifilesink_next_file),
(gst_multifilesink_pad_query), (gst_multifilesink_handle_event),
(gst_multifilesink_chain), (gst_multifilesink_change_state):
* gst/multifilesink/gstmultifilesink.h:
* gst/videodrop/gstvideodrop.c: (gst_videodrop_init):
* sys/cdrom/gstcdplayer.c: (cdplayer_init):
* sys/dxr3/dxr3audiosink.c: (dxr3audiosink_init),
(dxr3audiosink_open), (dxr3audiosink_close),
(dxr3audiosink_chain_pcm), (dxr3audiosink_chain_ac3),
(dxr3audiosink_change_state):
* sys/dxr3/dxr3audiosink.h:
* sys/dxr3/dxr3spusink.c: (dxr3spusink_init), (dxr3spusink_open),
(dxr3spusink_close), (dxr3spusink_chain),
(dxr3spusink_change_state):
* sys/dxr3/dxr3spusink.h:
* sys/dxr3/dxr3videosink.c: (dxr3videosink_init),
(dxr3videosink_open), (dxr3videosink_close),
(dxr3videosink_write_data), (dxr3videosink_change_state):
* sys/dxr3/dxr3videosink.h:
* sys/glsink/glimagesink.c: (gst_glimagesink_init):
* sys/qcam/gstqcamsrc.c: (gst_qcamsrc_change_state),
(gst_qcamsrc_open), (gst_qcamsrc_close):
* sys/qcam/gstqcamsrc.h:
* sys/v4l2/gstv4l2src.c: (gst_v4l2src_init):
* sys/vcd/vcdsrc.c: (gst_vcdsrc_set_property), (gst_vcdsrc_get),
(gst_vcdsrc_open_file), (gst_vcdsrc_close_file),
(gst_vcdsrc_change_state), (gst_vcdsrc_recalculate):
* sys/vcd/vcdsrc.h:
renamed GST_FLAGS macros to GST_OBJECT_FLAGS
moved bitshift from macro to enum definition
2005-10-12 14:29:55 +00:00
|
|
|
GST_OBJECT_FLAG_UNSET (this, GST_SF_OPEN);
|
2003-06-16 14:56:34 +00:00
|
|
|
|
|
|
|
this->file = NULL;
|
|
|
|
if (this->buffer)
|
|
|
|
g_free (this->buffer);
|
|
|
|
this->buffer = NULL;
|
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static void
|
|
|
|
gst_sf_loop (GstElement * element)
|
2003-06-16 14:56:34 +00:00
|
|
|
{
|
|
|
|
GstSF *this;
|
|
|
|
GList *l = NULL;
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
this = (GstSF *) element;
|
|
|
|
|
2003-06-16 14:56:34 +00:00
|
|
|
if (this->channels == NULL) {
|
2004-03-14 22:34:33 +00:00
|
|
|
GST_ELEMENT_ERROR (element, CORE, PAD, (NULL),
|
2004-03-15 19:32:27 +00:00
|
|
|
("You must connect at least one pad to sndfile elements."));
|
2003-06-16 14:56:34 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (GST_IS_SFSRC (this)) {
|
|
|
|
sf_count_t read;
|
|
|
|
gint i, j;
|
|
|
|
int eos = 0;
|
2003-07-16 16:08:13 +00:00
|
|
|
int buffer_frames = this->buffer_frames;
|
2003-06-16 14:56:34 +00:00
|
|
|
int nchannels = this->numchannels;
|
|
|
|
GstSFChannel *channel = NULL;
|
|
|
|
gfloat *data;
|
|
|
|
gfloat *buf = this->buffer;
|
|
|
|
GstBuffer *out;
|
|
|
|
|
renamed GST_FLAGS macros to GST_OBJECT_FLAGS moved bitshift from macro to enum definition
Original commit message from CVS:
* examples/indexing/indexmpeg.c: (main):
* ext/artsd/gstartsdsink.c: (gst_artsdsink_open_audio),
(gst_artsdsink_close_audio), (gst_artsdsink_change_state):
* ext/artsd/gstartsdsink.h:
* ext/audiofile/gstafparse.c: (gst_afparse_open_file),
(gst_afparse_close_file):
* ext/audiofile/gstafparse.h:
* ext/audiofile/gstafsink.c: (gst_afsink_open_file),
(gst_afsink_close_file), (gst_afsink_chain),
(gst_afsink_change_state):
* ext/audiofile/gstafsink.h:
* ext/audiofile/gstafsrc.c: (gst_afsrc_open_file),
(gst_afsrc_close_file), (gst_afsrc_change_state):
* ext/audiofile/gstafsrc.h:
* ext/cdaudio/gstcdaudio.c: (gst_cdaudio_init):
* ext/directfb/directfbvideosink.c: (gst_directfbvideosink_init):
* ext/dts/gstdtsdec.c: (gst_dtsdec_init):
* ext/jack/gstjack.h:
* ext/jack/gstjackbin.c: (gst_jack_bin_init),
(gst_jack_bin_change_state):
* ext/musepack/gstmusepackdec.c: (gst_musepackdec_init):
* ext/musicbrainz/gsttrm.c: (gst_musicbrainz_init):
* ext/nas/nassink.c: (gst_nassink_open_audio),
(gst_nassink_close_audio), (gst_nassink_change_state):
* ext/nas/nassink.h:
* ext/polyp/polypsink.c: (gst_polypsink_init):
* ext/sdl/sdlvideosink.c: (gst_sdlvideosink_change_state):
* ext/sdl/sdlvideosink.h:
* ext/smoothwave/gstsmoothwave.c: (gst_smoothwave_init):
* ext/sndfile/gstsf.c: (gst_sf_set_property),
(gst_sf_change_state), (gst_sf_release_request_pad),
(gst_sf_open_file), (gst_sf_close_file), (gst_sf_loop):
* ext/sndfile/gstsf.h:
* ext/swfdec/gstswfdec.c: (gst_swfdec_init):
* ext/tarkin/gsttarkindec.c: (gst_tarkindec_init):
* gst/apetag/apedemux.c: (gst_ape_demux_init):
* gst/cdxaparse/gstcdxaparse.c: (gst_cdxaparse_init):
* gst/cdxaparse/gstcdxastrip.c: (gst_cdxastrip_init):
* gst/festival/gstfestival.c: (gst_festival_change_state):
* gst/festival/gstfestival.h:
* gst/mpeg2sub/gstmpeg2subt.c: (gst_mpeg2subt_init):
* gst/multifilesink/gstmultifilesink.c: (gst_multifilesink_init),
(gst_multifilesink_set_location), (gst_multifilesink_open_file),
(gst_multifilesink_close_file), (gst_multifilesink_next_file),
(gst_multifilesink_pad_query), (gst_multifilesink_handle_event),
(gst_multifilesink_chain), (gst_multifilesink_change_state):
* gst/multifilesink/gstmultifilesink.h:
* gst/videodrop/gstvideodrop.c: (gst_videodrop_init):
* sys/cdrom/gstcdplayer.c: (cdplayer_init):
* sys/dxr3/dxr3audiosink.c: (dxr3audiosink_init),
(dxr3audiosink_open), (dxr3audiosink_close),
(dxr3audiosink_chain_pcm), (dxr3audiosink_chain_ac3),
(dxr3audiosink_change_state):
* sys/dxr3/dxr3audiosink.h:
* sys/dxr3/dxr3spusink.c: (dxr3spusink_init), (dxr3spusink_open),
(dxr3spusink_close), (dxr3spusink_chain),
(dxr3spusink_change_state):
* sys/dxr3/dxr3spusink.h:
* sys/dxr3/dxr3videosink.c: (dxr3videosink_init),
(dxr3videosink_open), (dxr3videosink_close),
(dxr3videosink_write_data), (dxr3videosink_change_state):
* sys/dxr3/dxr3videosink.h:
* sys/glsink/glimagesink.c: (gst_glimagesink_init):
* sys/qcam/gstqcamsrc.c: (gst_qcamsrc_change_state),
(gst_qcamsrc_open), (gst_qcamsrc_close):
* sys/qcam/gstqcamsrc.h:
* sys/v4l2/gstv4l2src.c: (gst_v4l2src_init):
* sys/vcd/vcdsrc.c: (gst_vcdsrc_set_property), (gst_vcdsrc_get),
(gst_vcdsrc_open_file), (gst_vcdsrc_close_file),
(gst_vcdsrc_change_state), (gst_vcdsrc_recalculate):
* sys/vcd/vcdsrc.h:
renamed GST_FLAGS macros to GST_OBJECT_FLAGS
moved bitshift from macro to enum definition
2005-10-12 14:29:55 +00:00
|
|
|
if (!GST_OBJECT_FLAG_IS_SET (this, GST_SF_OPEN))
|
2003-07-16 16:08:13 +00:00
|
|
|
if (!gst_sf_open_file (this))
|
2004-03-15 19:32:27 +00:00
|
|
|
return; /* we've already set gst_element_error */
|
2003-07-16 16:08:13 +00:00
|
|
|
|
|
|
|
if (buffer_frames == 0) {
|
|
|
|
/* we have to set the caps later */
|
|
|
|
buffer_frames = this->buffer_frames = 1024;
|
|
|
|
}
|
|
|
|
if (buf == NULL) {
|
2004-03-14 22:34:33 +00:00
|
|
|
buf = this->buffer =
|
2004-03-15 19:32:27 +00:00
|
|
|
g_malloc (this->numchannels * this->buffer_frames * sizeof (float));
|
2004-03-14 22:34:33 +00:00
|
|
|
memset (this->buffer, 0,
|
2004-03-15 19:32:27 +00:00
|
|
|
this->numchannels * this->buffer_frames * sizeof (float));
|
2003-07-16 16:08:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
read = sf_readf_float (this->file, buf, buffer_frames);
|
|
|
|
if (read < buffer_frames)
|
2003-06-16 14:56:34 +00:00
|
|
|
eos = 1;
|
|
|
|
|
|
|
|
if (read)
|
2004-03-14 22:34:33 +00:00
|
|
|
for (i = 0, l = this->channels; l; l = l->next, i++) {
|
2004-03-15 19:32:27 +00:00
|
|
|
channel = GST_SF_CHANNEL (l);
|
|
|
|
|
|
|
|
/* don't push on disconnected pads -- useful for ::create-pads=TRUE */
|
|
|
|
if (!GST_PAD_PEER (channel->pad))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (!channel->caps_set) {
|
|
|
|
GstCaps *caps =
|
|
|
|
gst_caps_copy (GST_PAD_CAPS (GST_SF_CHANNEL (l)->pad));
|
|
|
|
if (!caps)
|
|
|
|
caps = gst_caps_copy
|
|
|
|
(GST_PAD_TEMPLATE_CAPS (GST_PAD_PAD_TEMPLATE (GST_SF_CHANNEL
|
|
|
|
(l)->pad)));
|
|
|
|
gst_caps_set_simple (caps, "rate", G_TYPE_INT, this->rate,
|
|
|
|
"buffer-frames", G_TYPE_INT, this->buffer_frames, NULL);
|
|
|
|
if (!gst_pad_try_set_caps (GST_SF_CHANNEL (l)->pad, caps)) {
|
|
|
|
GST_ELEMENT_ERROR (this, CORE, NEGOTIATION, (NULL),
|
|
|
|
("Opened file with sample rate %d, but could not set caps",
|
|
|
|
this->rate));
|
|
|
|
gst_sf_close_file (this);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
channel->caps_set = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
out = gst_buffer_new_and_alloc (read * sizeof (float));
|
|
|
|
data = (gfloat *) GST_BUFFER_DATA (out);
|
|
|
|
for (j = 0; j < read; j++)
|
|
|
|
data[j] = buf[j * nchannels + i % nchannels];
|
|
|
|
gst_pad_push (channel->pad, GST_DATA (out));
|
2003-06-16 14:56:34 +00:00
|
|
|
}
|
|
|
|
|
2003-07-16 16:08:13 +00:00
|
|
|
this->time += read * (GST_SECOND / this->rate);
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_audio_clock_update_time ((GstAudioClock *) this->provided_clock,
|
2004-03-15 19:32:27 +00:00
|
|
|
this->time);
|
2003-07-16 16:08:13 +00:00
|
|
|
|
2003-06-16 14:56:34 +00:00
|
|
|
if (eos) {
|
|
|
|
if (this->loop) {
|
2004-03-15 19:32:27 +00:00
|
|
|
sf_seek (this->file, (sf_count_t) 0, SEEK_SET);
|
|
|
|
eos = 0;
|
2003-06-16 14:56:34 +00:00
|
|
|
} else {
|
2004-03-15 19:32:27 +00:00
|
|
|
for (l = this->channels; l; l = l->next)
|
|
|
|
gst_pad_push (GST_SF_CHANNEL (l)->pad,
|
|
|
|
GST_DATA (gst_event_new (GST_EVENT_EOS)));
|
|
|
|
gst_element_set_eos (element);
|
2003-06-16 14:56:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
2003-07-16 16:08:13 +00:00
|
|
|
sf_count_t written, num_to_write;
|
|
|
|
gint i, j;
|
|
|
|
int buffer_frames = this->buffer_frames;
|
|
|
|
int nchannels = this->numchannels;
|
|
|
|
GstSFChannel *channel = NULL;
|
|
|
|
gfloat *data;
|
|
|
|
gfloat *buf = this->buffer;
|
|
|
|
GstBuffer *in;
|
2003-06-16 14:56:34 +00:00
|
|
|
|
2003-07-16 16:08:13 +00:00
|
|
|
/* the problem: we can't allocate a buffer for pulled data before caps is
|
|
|
|
* set, and we can't open the file without the sample rate from the
|
|
|
|
* caps... */
|
2003-06-16 14:56:34 +00:00
|
|
|
|
2003-07-16 16:08:13 +00:00
|
|
|
num_to_write = buffer_frames;
|
2003-06-16 14:56:34 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
INFO_OBJ (this, "looping, buffer_frames=%d, nchannels=%d", buffer_frames,
|
2004-03-15 19:32:27 +00:00
|
|
|
nchannels);
|
2003-06-16 14:56:34 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
for (i = 0, l = this->channels; l; l = l->next, i++) {
|
2003-07-16 16:08:13 +00:00
|
|
|
channel = GST_SF_CHANNEL (l);
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2004-02-20 14:17:57 +00:00
|
|
|
pull_again:
|
2003-10-08 16:08:19 +00:00
|
|
|
in = GST_BUFFER (gst_pad_pull (channel->pad));
|
2003-07-16 16:08:13 +00:00
|
|
|
|
|
|
|
if (buffer_frames == 0) {
|
2004-03-15 19:32:27 +00:00
|
|
|
/* pulling a buffer from the pad should have caused capsnego to occur,
|
|
|
|
which then would set this->buffer_frames to a new value */
|
|
|
|
buffer_frames = this->buffer_frames;
|
|
|
|
if (buffer_frames == 0) {
|
|
|
|
GST_ELEMENT_ERROR (element, CORE, NEGOTIATION, (NULL),
|
|
|
|
("format wasn't negotiated before chain function"));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
buf = this->buffer;
|
|
|
|
num_to_write = buffer_frames;
|
2003-07-16 16:08:13 +00:00
|
|
|
}
|
|
|
|
|
renamed GST_FLAGS macros to GST_OBJECT_FLAGS moved bitshift from macro to enum definition
Original commit message from CVS:
* examples/indexing/indexmpeg.c: (main):
* ext/artsd/gstartsdsink.c: (gst_artsdsink_open_audio),
(gst_artsdsink_close_audio), (gst_artsdsink_change_state):
* ext/artsd/gstartsdsink.h:
* ext/audiofile/gstafparse.c: (gst_afparse_open_file),
(gst_afparse_close_file):
* ext/audiofile/gstafparse.h:
* ext/audiofile/gstafsink.c: (gst_afsink_open_file),
(gst_afsink_close_file), (gst_afsink_chain),
(gst_afsink_change_state):
* ext/audiofile/gstafsink.h:
* ext/audiofile/gstafsrc.c: (gst_afsrc_open_file),
(gst_afsrc_close_file), (gst_afsrc_change_state):
* ext/audiofile/gstafsrc.h:
* ext/cdaudio/gstcdaudio.c: (gst_cdaudio_init):
* ext/directfb/directfbvideosink.c: (gst_directfbvideosink_init):
* ext/dts/gstdtsdec.c: (gst_dtsdec_init):
* ext/jack/gstjack.h:
* ext/jack/gstjackbin.c: (gst_jack_bin_init),
(gst_jack_bin_change_state):
* ext/musepack/gstmusepackdec.c: (gst_musepackdec_init):
* ext/musicbrainz/gsttrm.c: (gst_musicbrainz_init):
* ext/nas/nassink.c: (gst_nassink_open_audio),
(gst_nassink_close_audio), (gst_nassink_change_state):
* ext/nas/nassink.h:
* ext/polyp/polypsink.c: (gst_polypsink_init):
* ext/sdl/sdlvideosink.c: (gst_sdlvideosink_change_state):
* ext/sdl/sdlvideosink.h:
* ext/smoothwave/gstsmoothwave.c: (gst_smoothwave_init):
* ext/sndfile/gstsf.c: (gst_sf_set_property),
(gst_sf_change_state), (gst_sf_release_request_pad),
(gst_sf_open_file), (gst_sf_close_file), (gst_sf_loop):
* ext/sndfile/gstsf.h:
* ext/swfdec/gstswfdec.c: (gst_swfdec_init):
* ext/tarkin/gsttarkindec.c: (gst_tarkindec_init):
* gst/apetag/apedemux.c: (gst_ape_demux_init):
* gst/cdxaparse/gstcdxaparse.c: (gst_cdxaparse_init):
* gst/cdxaparse/gstcdxastrip.c: (gst_cdxastrip_init):
* gst/festival/gstfestival.c: (gst_festival_change_state):
* gst/festival/gstfestival.h:
* gst/mpeg2sub/gstmpeg2subt.c: (gst_mpeg2subt_init):
* gst/multifilesink/gstmultifilesink.c: (gst_multifilesink_init),
(gst_multifilesink_set_location), (gst_multifilesink_open_file),
(gst_multifilesink_close_file), (gst_multifilesink_next_file),
(gst_multifilesink_pad_query), (gst_multifilesink_handle_event),
(gst_multifilesink_chain), (gst_multifilesink_change_state):
* gst/multifilesink/gstmultifilesink.h:
* gst/videodrop/gstvideodrop.c: (gst_videodrop_init):
* sys/cdrom/gstcdplayer.c: (cdplayer_init):
* sys/dxr3/dxr3audiosink.c: (dxr3audiosink_init),
(dxr3audiosink_open), (dxr3audiosink_close),
(dxr3audiosink_chain_pcm), (dxr3audiosink_chain_ac3),
(dxr3audiosink_change_state):
* sys/dxr3/dxr3audiosink.h:
* sys/dxr3/dxr3spusink.c: (dxr3spusink_init), (dxr3spusink_open),
(dxr3spusink_close), (dxr3spusink_chain),
(dxr3spusink_change_state):
* sys/dxr3/dxr3spusink.h:
* sys/dxr3/dxr3videosink.c: (dxr3videosink_init),
(dxr3videosink_open), (dxr3videosink_close),
(dxr3videosink_write_data), (dxr3videosink_change_state):
* sys/dxr3/dxr3videosink.h:
* sys/glsink/glimagesink.c: (gst_glimagesink_init):
* sys/qcam/gstqcamsrc.c: (gst_qcamsrc_change_state),
(gst_qcamsrc_open), (gst_qcamsrc_close):
* sys/qcam/gstqcamsrc.h:
* sys/v4l2/gstv4l2src.c: (gst_v4l2src_init):
* sys/vcd/vcdsrc.c: (gst_vcdsrc_set_property), (gst_vcdsrc_get),
(gst_vcdsrc_open_file), (gst_vcdsrc_close_file),
(gst_vcdsrc_change_state), (gst_vcdsrc_recalculate):
* sys/vcd/vcdsrc.h:
renamed GST_FLAGS macros to GST_OBJECT_FLAGS
moved bitshift from macro to enum definition
2005-10-12 14:29:55 +00:00
|
|
|
if (!GST_OBJECT_FLAG_IS_SET (this, GST_SF_OPEN))
|
2004-03-15 19:32:27 +00:00
|
|
|
if (!gst_sf_open_file (this))
|
|
|
|
return; /* we've already set gst_element_error */
|
2003-07-16 16:08:13 +00:00
|
|
|
|
|
|
|
if (GST_IS_EVENT (in)) {
|
2004-03-15 19:32:27 +00:00
|
|
|
switch (GST_EVENT_TYPE (in)) {
|
|
|
|
case GST_EVENT_EOS:
|
|
|
|
case GST_EVENT_INTERRUPT:
|
|
|
|
num_to_write = 0;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
goto pull_again;
|
|
|
|
break;
|
|
|
|
}
|
2004-02-20 14:17:57 +00:00
|
|
|
}
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2004-02-20 14:17:57 +00:00
|
|
|
if (num_to_write) {
|
2004-03-15 19:32:27 +00:00
|
|
|
data = (gfloat *) GST_BUFFER_DATA (in);
|
|
|
|
num_to_write =
|
|
|
|
MIN (num_to_write, GST_BUFFER_SIZE (in) / sizeof (gfloat));
|
|
|
|
for (j = 0; j < num_to_write; j++)
|
|
|
|
buf[j * nchannels + i % nchannels] = data[j];
|
2003-07-16 16:08:13 +00:00
|
|
|
}
|
2004-02-20 14:17:57 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_data_unref ((GstData *) in);
|
2003-07-16 16:08:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (num_to_write) {
|
|
|
|
written = sf_writef_float (this->file, buf, num_to_write);
|
|
|
|
if (written != num_to_write)
|
2004-03-15 19:32:27 +00:00
|
|
|
GST_ELEMENT_ERROR (element, RESOURCE, WRITE,
|
|
|
|
(_("Could not write to file \"%s\"."), this->filename),
|
|
|
|
("soundfile error: %s", sf_strerror (this->file)));
|
2003-07-16 16:08:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
this->time += num_to_write * (GST_SECOND / this->rate);
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_audio_clock_update_time ((GstAudioClock *) this->provided_clock,
|
2004-03-15 19:32:27 +00:00
|
|
|
this->time);
|
2003-07-16 16:08:13 +00:00
|
|
|
|
|
|
|
if (num_to_write != buffer_frames)
|
|
|
|
gst_element_set_eos (element);
|
|
|
|
}
|
2003-06-16 14:56:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2004-03-14 22:34:33 +00:00
|
|
|
plugin_init (GstPlugin * plugin)
|
2003-06-16 14:56:34 +00:00
|
|
|
{
|
2003-07-16 16:08:13 +00:00
|
|
|
if (!gst_library_load ("gstaudio"))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
GST_DEBUG_CATEGORY_INIT (gstsf_debug, "sf",
|
2004-03-14 22:34:33 +00:00
|
|
|
GST_DEBUG_FG_WHITE | GST_DEBUG_BG_GREEN | GST_DEBUG_BOLD,
|
|
|
|
"libsndfile plugin");
|
2003-07-16 16:08:13 +00:00
|
|
|
|
2003-11-02 01:46:25 +00:00
|
|
|
if (!gst_element_register (plugin, "sfsrc", GST_RANK_NONE, GST_TYPE_SFSRC))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (!gst_element_register (plugin, "sfsink", GST_RANK_NONE, GST_TYPE_SFSINK))
|
|
|
|
return FALSE;
|
|
|
|
|
2004-01-19 15:45:55 +00:00
|
|
|
#ifdef ENABLE_NLS
|
|
|
|
setlocale (LC_ALL, "");
|
|
|
|
bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
|
|
|
|
#endif /* ENABLE_NLS */
|
|
|
|
|
2003-06-16 14:56:34 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
|
|
|
|
GST_VERSION_MINOR,
|
2005-08-14 16:10:55 +00:00
|
|
|
"sndfile",
|
|
|
|
"use libsndfile to read and write audio from and to files",
|
2006-04-01 10:09:11 +00:00
|
|
|
plugin_init, VERSION, "LGPL", GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN)
|