gst-indent c++ files

Original commit message from CVS:
gst-indent c++ files
This commit is contained in:
Thomas Vander Stichele 2004-03-14 23:20:40 +00:00
parent 908defa2c4
commit ed1ef1fc34

View file

@ -28,14 +28,16 @@
#include "gstsiddec.h" #include "gstsiddec.h"
/* Sidec signals and args */ /* Sidec signals and args */
enum { enum
{
/* FILL ME */ /* FILL ME */
LAST_SIGNAL LAST_SIGNAL
}; };
#define DEFAULT_BLOCKSIZE 4096 #define DEFAULT_BLOCKSIZE 4096
enum { enum
{
ARG_0, ARG_0,
ARG_TUNE, ARG_TUNE,
ARG_CLOCK, ARG_CLOCK,
@ -49,30 +51,25 @@ enum {
/* FILL ME */ /* FILL ME */
}; };
static GstStaticPadTemplate sink_templ = static GstStaticPadTemplate sink_templ = GST_STATIC_PAD_TEMPLATE ("sink",
GST_STATIC_PAD_TEMPLATE ( GST_PAD_SINK,
"sink", GST_PAD_ALWAYS,
GST_PAD_SINK, GST_STATIC_CAPS ("audio/x-sid")
GST_PAD_ALWAYS, );
GST_STATIC_CAPS ("audio/x-sid")
);
static GstStaticPadTemplate src_templ = static GstStaticPadTemplate src_templ = GST_STATIC_PAD_TEMPLATE ("src",
GST_STATIC_PAD_TEMPLATE ( GST_PAD_SRC,
"src", GST_PAD_ALWAYS,
GST_PAD_SRC, GST_STATIC_CAPS ("audio/x-raw-int, "
GST_PAD_ALWAYS, "endianness = (int) BYTE_ORDER, "
GST_STATIC_CAPS ("audio/x-raw-int, " "signed = (boolean) { true, false }, "
"endianness = (int) BYTE_ORDER, " "width = (int) { 8, 16 }, "
"signed = (boolean) { true, false }, " "depth = (int) { 8, 16 }, "
"width = (int) { 8, 16 }, " "rate = (int) [ 8000, 48000 ], " "channels = (int) [ 1, 2 ]")
"depth = (int) { 8, 16 }, " );
"rate = (int) [ 8000, 48000 ], "
"channels = (int) [ 1, 2 ]"
)
);
enum { enum
{
SID_STATE_NEED_TUNE = 1, SID_STATE_NEED_TUNE = 1,
SID_STATE_LOAD_TUNE = 2, SID_STATE_LOAD_TUNE = 2,
SID_STATE_PLAY_TUNE = 3, SID_STATE_PLAY_TUNE = 3,
@ -84,9 +81,9 @@ gst_sid_clock_get_type (void)
{ {
static GType sid_clock_type = 0; static GType sid_clock_type = 0;
static GEnumValue sid_clock[] = { static GEnumValue sid_clock[] = {
{ SIDTUNE_CLOCK_PAL, "0", "PAL" }, {SIDTUNE_CLOCK_PAL, "0", "PAL"},
{ SIDTUNE_CLOCK_NTSC, "1", "NTSC" }, {SIDTUNE_CLOCK_NTSC, "1", "NTSC"},
{ 0, NULL, NULL }, {0, NULL, NULL},
}; };
if (!sid_clock_type) { if (!sid_clock_type) {
sid_clock_type = g_enum_register_static ("GstSidClock", sid_clock); sid_clock_type = g_enum_register_static ("GstSidClock", sid_clock);
@ -100,10 +97,10 @@ gst_sid_memory_get_type (void)
{ {
static GType sid_memory_type = 0; static GType sid_memory_type = 0;
static GEnumValue sid_memory[] = { static GEnumValue sid_memory[] = {
{ MPU_BANK_SWITCHING, "32", "Bank Switching" }, {MPU_BANK_SWITCHING, "32", "Bank Switching"},
{ MPU_TRANSPARENT_ROM, "33", "Transparent ROM" }, {MPU_TRANSPARENT_ROM, "33", "Transparent ROM"},
{ MPU_PLAYSID_ENVIRONMENT, "34", "Playsid Environment" }, {MPU_PLAYSID_ENVIRONMENT, "34", "Playsid Environment"},
{ 0, NULL, NULL }, {0, NULL, NULL},
}; };
if (!sid_memory_type) { if (!sid_memory_type) {
sid_memory_type = g_enum_register_static ("GstSidMemory", sid_memory); sid_memory_type = g_enum_register_static ("GstSidMemory", sid_memory);
@ -111,44 +108,47 @@ gst_sid_memory_get_type (void)
return sid_memory_type; return sid_memory_type;
} }
static void gst_siddec_base_init (gpointer g_class); static void gst_siddec_base_init (gpointer g_class);
static void gst_siddec_class_init (GstSidDec *klass); static void gst_siddec_class_init (GstSidDec * klass);
static void gst_siddec_init (GstSidDec *siddec); static void gst_siddec_init (GstSidDec * siddec);
static void gst_siddec_loop (GstElement *element); static void gst_siddec_loop (GstElement * element);
static gboolean gst_siddec_src_convert (GstPad *pad, GstFormat src_format, gint64 src_value, static gboolean gst_siddec_src_convert (GstPad * pad, GstFormat src_format,
GstFormat *dest_format, gint64 *dest_value); gint64 src_value, GstFormat * dest_format, gint64 * dest_value);
static gboolean gst_siddec_src_query (GstPad *pad, GstQueryType type, static gboolean gst_siddec_src_query (GstPad * pad, GstQueryType type,
GstFormat *format, gint64 *value); GstFormat * format, gint64 * value);
static void gst_siddec_get_property (GObject *object, guint prop_id, static void gst_siddec_get_property (GObject * object, guint prop_id,
GValue *value, GParamSpec *pspec); GValue * value, GParamSpec * pspec);
static void gst_siddec_set_property (GObject *object, guint prop_id, static void gst_siddec_set_property (GObject * object, guint prop_id,
const GValue *value, GParamSpec *pspec); const GValue * value, GParamSpec * pspec);
static GstElementClass *parent_class = NULL; static GstElementClass *parent_class = NULL;
//static guint gst_siddec_signals[LAST_SIGNAL] = { 0 }; //static guint gst_siddec_signals[LAST_SIGNAL] = { 0 };
GType GType
gst_siddec_get_type (void) gst_siddec_get_type (void)
{ {
static GType siddec_type = 0; static GType siddec_type = 0;
if (!siddec_type) { if (!siddec_type) {
static const GTypeInfo siddec_info = { static const GTypeInfo siddec_info = {
sizeof(GstSidDecClass), sizeof (GstSidDecClass),
gst_siddec_base_init, gst_siddec_base_init,
NULL, NULL,
(GClassInitFunc) gst_siddec_class_init, (GClassInitFunc) gst_siddec_class_init,
NULL, NULL,
NULL, NULL,
sizeof(GstSidDec), sizeof (GstSidDec),
0, 0,
(GInstanceInitFunc) gst_siddec_init, (GInstanceInitFunc) gst_siddec_init,
NULL NULL
}; };
siddec_type = g_type_register_static (GST_TYPE_ELEMENT, "GstSidDec", &siddec_info, (GTypeFlags)0); siddec_type =
g_type_register_static (GST_TYPE_ELEMENT, "GstSidDec", &siddec_info,
(GTypeFlags) 0);
} }
return siddec_type; return siddec_type;
@ -157,12 +157,11 @@ gst_siddec_get_type (void)
static void static void
gst_siddec_base_init (gpointer g_class) gst_siddec_base_init (gpointer g_class)
{ {
static GstElementDetails gst_siddec_details = GST_ELEMENT_DETAILS ( static GstElementDetails gst_siddec_details =
"Sid decoder", GST_ELEMENT_DETAILS ("Sid decoder",
"Codec/Audio/Decoder", "Codec/Audio/Decoder",
"Use sidplay to decode SID audio tunes", "Use sidplay to decode SID audio tunes",
"Wim Taymans <wim.taymans@chello.be> " "Wim Taymans <wim.taymans@chello.be> ");
);
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class); GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
gst_element_class_set_details (element_class, &gst_siddec_details); gst_element_class_set_details (element_class, &gst_siddec_details);
@ -175,59 +174,63 @@ gst_siddec_base_init (gpointer g_class)
} }
static void static void
gst_siddec_class_init (GstSidDec *klass) gst_siddec_class_init (GstSidDec * klass)
{ {
GObjectClass *gobject_class; GObjectClass *gobject_class;
GstElementClass *gstelement_class; GstElementClass *gstelement_class;
gobject_class = (GObjectClass*)klass; gobject_class = (GObjectClass *) klass;
gstelement_class = (GstElementClass*)klass; gstelement_class = (GstElementClass *) klass;
parent_class = GST_ELEMENT_CLASS (g_type_class_ref (GST_TYPE_ELEMENT)); parent_class = GST_ELEMENT_CLASS (g_type_class_ref (GST_TYPE_ELEMENT));
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_TUNE, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_TUNE,
g_param_spec_int ("tune", "tune", "tune", g_param_spec_int ("tune", "tune", "tune",
1, 100, 1, (GParamFlags)G_PARAM_READWRITE)); 1, 100, 1, (GParamFlags) G_PARAM_READWRITE));
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_CLOCK, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_CLOCK,
g_param_spec_enum ("clock", "clock", "clock", g_param_spec_enum ("clock", "clock", "clock",
GST_TYPE_SID_CLOCK, SIDTUNE_CLOCK_PAL, (GParamFlags)G_PARAM_READWRITE)); GST_TYPE_SID_CLOCK, SIDTUNE_CLOCK_PAL,
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_MEMORY, (GParamFlags) G_PARAM_READWRITE));
g_param_spec_enum ("memory", "memory", "memory", g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_MEMORY,
GST_TYPE_SID_MEMORY, MPU_PLAYSID_ENVIRONMENT, (GParamFlags)G_PARAM_READWRITE)); g_param_spec_enum ("memory", "memory", "memory", GST_TYPE_SID_MEMORY,
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_FILTER, MPU_PLAYSID_ENVIRONMENT, (GParamFlags) G_PARAM_READWRITE));
g_param_spec_boolean ("filter", "filter", "filter", g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_FILTER,
TRUE, (GParamFlags)G_PARAM_READWRITE)); g_param_spec_boolean ("filter", "filter", "filter", TRUE,
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_MEASURED_VOLUME, (GParamFlags) G_PARAM_READWRITE));
g_param_spec_boolean ("measured_volume", "measured_volume", "measured_volume", g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_MEASURED_VOLUME,
TRUE, (GParamFlags)G_PARAM_READWRITE)); g_param_spec_boolean ("measured_volume", "measured_volume",
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_MOS8580, "measured_volume", TRUE, (GParamFlags) G_PARAM_READWRITE));
g_param_spec_boolean ("mos8580", "mos8580", "mos8580", g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_MOS8580,
TRUE, (GParamFlags)G_PARAM_READWRITE)); g_param_spec_boolean ("mos8580", "mos8580", "mos8580", TRUE,
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_FORCE_SPEED, (GParamFlags) G_PARAM_READWRITE));
g_param_spec_boolean ("force_speed", "force_speed", "force_speed", g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_FORCE_SPEED,
TRUE, (GParamFlags)G_PARAM_READWRITE)); g_param_spec_boolean ("force_speed", "force_speed", "force_speed", TRUE,
(GParamFlags) G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_BLOCKSIZE, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_BLOCKSIZE,
g_param_spec_ulong ("blocksize", "Block size", "Size in bytes to output per buffer", g_param_spec_ulong ("blocksize", "Block size",
1, G_MAXULONG, DEFAULT_BLOCKSIZE, (GParamFlags)G_PARAM_READWRITE)); "Size in bytes to output per buffer", 1, G_MAXULONG,
DEFAULT_BLOCKSIZE, (GParamFlags) G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, ARG_METADATA, g_object_class_install_property (gobject_class, ARG_METADATA,
g_param_spec_boxed ("metadata", "Metadata", "Metadata", g_param_spec_boxed ("metadata", "Metadata", "Metadata", GST_TYPE_CAPS,
GST_TYPE_CAPS, (GParamFlags)G_PARAM_READABLE)); (GParamFlags) G_PARAM_READABLE));
gobject_class->set_property = gst_siddec_set_property; gobject_class->set_property = gst_siddec_set_property;
gobject_class->get_property = gst_siddec_get_property; gobject_class->get_property = gst_siddec_get_property;
} }
static void static void
gst_siddec_init (GstSidDec *siddec) gst_siddec_init (GstSidDec * siddec)
{ {
siddec->sinkpad = gst_pad_new_from_template ( siddec->sinkpad =
gst_static_pad_template_get (&sink_templ), "sink"); gst_pad_new_from_template (gst_static_pad_template_get (&sink_templ),
"sink");
gst_element_add_pad (GST_ELEMENT (siddec), siddec->sinkpad); gst_element_add_pad (GST_ELEMENT (siddec), siddec->sinkpad);
gst_pad_set_query_function (siddec->sinkpad, NULL); gst_pad_set_query_function (siddec->sinkpad, NULL);
gst_pad_set_convert_function (siddec->sinkpad, NULL); gst_pad_set_convert_function (siddec->sinkpad, NULL);
siddec->srcpad = gst_pad_new_from_template ( siddec->srcpad =
gst_static_pad_template_get (&src_templ), "src"); gst_pad_new_from_template (gst_static_pad_template_get (&src_templ),
"src");
gst_pad_set_event_function (siddec->srcpad, NULL); gst_pad_set_event_function (siddec->srcpad, NULL);
gst_pad_set_convert_function (siddec->srcpad, gst_siddec_src_convert); gst_pad_set_convert_function (siddec->srcpad, gst_siddec_src_convert);
gst_pad_set_query_function (siddec->srcpad, gst_siddec_src_query); gst_pad_set_query_function (siddec->srcpad, gst_siddec_src_query);
@ -235,28 +238,28 @@ gst_siddec_init (GstSidDec *siddec)
gst_element_set_loop_function (GST_ELEMENT (siddec), gst_siddec_loop); gst_element_set_loop_function (GST_ELEMENT (siddec), gst_siddec_loop);
siddec->engine = new emuEngine(); siddec->engine = new emuEngine ();
siddec->tune = new sidTune(0); siddec->tune = new sidTune (0);
siddec->config = (emuConfig *)g_malloc (sizeof (emuConfig)); siddec->config = (emuConfig *) g_malloc (sizeof (emuConfig));
siddec->config->frequency = 44100; // frequency siddec->config->frequency = 44100; // frequency
siddec->config->bitsPerSample = SIDEMU_16BIT; // bits per sample siddec->config->bitsPerSample = SIDEMU_16BIT; // bits per sample
siddec->config->sampleFormat = SIDEMU_SIGNED_PCM; // sample fomat siddec->config->sampleFormat = SIDEMU_SIGNED_PCM; // sample fomat
siddec->config->channels = SIDEMU_STEREO; // channels siddec->config->channels = SIDEMU_STEREO; // channels
siddec->config->sidChips = 0; // - siddec->config->sidChips = 0; // -
siddec->config->volumeControl = SIDEMU_NONE; // volume control siddec->config->volumeControl = SIDEMU_NONE; // volume control
siddec->config->mos8580 = TRUE; // mos8580 siddec->config->mos8580 = TRUE; // mos8580
siddec->config->measuredVolume = TRUE; // measure volume siddec->config->measuredVolume = TRUE; // measure volume
siddec->config->emulateFilter = TRUE; // emulate filter siddec->config->emulateFilter = TRUE; // emulate filter
siddec->config->filterFs = SIDEMU_DEFAULTFILTERFS; // filter Fs siddec->config->filterFs = SIDEMU_DEFAULTFILTERFS; // filter Fs
siddec->config->filterFm = SIDEMU_DEFAULTFILTERFM; // filter Fm siddec->config->filterFm = SIDEMU_DEFAULTFILTERFM; // filter Fm
siddec->config->filterFt = SIDEMU_DEFAULTFILTERFT; // filter Ft siddec->config->filterFt = SIDEMU_DEFAULTFILTERFT; // filter Ft
siddec->config->memoryMode = MPU_PLAYSID_ENVIRONMENT; // memory mode siddec->config->memoryMode = MPU_PLAYSID_ENVIRONMENT; // memory mode
siddec->config->clockSpeed = SIDTUNE_CLOCK_PAL; // clock speed siddec->config->clockSpeed = SIDTUNE_CLOCK_PAL; // clock speed
siddec->config->forceSongSpeed = TRUE; // force song speed siddec->config->forceSongSpeed = TRUE; // force song speed
siddec->config->digiPlayerScans = 0; // digi player scans siddec->config->digiPlayerScans = 0; // digi player scans
siddec->config->autoPanning = SIDEMU_NONE; // auto panning siddec->config->autoPanning = SIDEMU_NONE; // auto panning
siddec->engine->setConfig (*siddec->config); siddec->engine->setConfig (*siddec->config);
siddec->engine->setDefaultFilterStrength (); siddec->engine->setDefaultFilterStrength ();
@ -270,8 +273,8 @@ gst_siddec_init (GstSidDec *siddec)
} }
#if 0 #if 0
static void static void
update_metadata (GstSidDec *siddec) update_metadata (GstSidDec * siddec)
{ {
sidTuneInfo info; sidTuneInfo info;
GstProps *props; GstProps *props;
@ -285,17 +288,19 @@ update_metadata (GstSidDec *siddec)
gst_props_add_entry (props, entry); gst_props_add_entry (props, entry);
} }
if (info.authorString) { if (info.authorString) {
entry = gst_props_entry_new ("Composer", G_TYPE_STRING (info.authorString)); entry =
gst_props_entry_new ("Composer", G_TYPE_STRING (info.authorString));
gst_props_add_entry (props, entry); gst_props_add_entry (props, entry);
} }
if (info.copyrightString) { if (info.copyrightString) {
entry = gst_props_entry_new ("Copyright", G_TYPE_STRING (info.copyrightString)); entry =
gst_props_entry_new ("Copyright",
G_TYPE_STRING (info.copyrightString));
gst_props_add_entry (props, entry); gst_props_add_entry (props, entry);
} }
siddec->metadata = gst_caps_new ("sid_metadata", siddec->metadata = gst_caps_new ("sid_metadata",
"application/x-gst-metadata", "application/x-gst-metadata", props);
props);
g_object_notify (G_OBJECT (siddec), "metadata"); g_object_notify (G_OBJECT (siddec), "metadata");
} }
@ -314,7 +319,7 @@ G_STMT_START { \
} G_STMT_END } G_STMT_END
static gboolean static gboolean
siddec_negotiate (GstSidDec *siddec) siddec_negotiate (GstSidDec * siddec)
{ {
GstCaps *allowed; GstCaps *allowed;
gboolean sign = TRUE; gboolean sign = TRUE;
@ -336,7 +341,7 @@ siddec_negotiate (GstSidDec *siddec)
return FALSE; return FALSE;
} }
width = width | depth; width = width | depth;
if (width) { if (width) {
siddec->config->bitsPerSample = width; siddec->config->bitsPerSample = width;
} }
@ -347,19 +352,18 @@ siddec_negotiate (GstSidDec *siddec)
gst_structure_get_int (structure, "channels", &channels); gst_structure_get_int (structure, "channels", &channels);
siddec->config->channels = channels; siddec->config->channels = channels;
siddec->config->sampleFormat = (sign ? SIDEMU_SIGNED_PCM : SIDEMU_UNSIGNED_PCM); siddec->config->sampleFormat =
(sign ? SIDEMU_SIGNED_PCM : SIDEMU_UNSIGNED_PCM);
if (!GST_PAD_CAPS (siddec->srcpad)) { if (!GST_PAD_CAPS (siddec->srcpad)) {
if (!gst_pad_try_set_caps (siddec->srcpad, if (!gst_pad_try_set_caps (siddec->srcpad,
gst_caps_new_simple ("audio/x-raw-int", gst_caps_new_simple ("audio/x-raw-int",
"endianness", G_TYPE_INT, G_BYTE_ORDER, "endianness", G_TYPE_INT, G_BYTE_ORDER,
"signed", G_TYPE_BOOLEAN, sign, "signed", G_TYPE_BOOLEAN, sign,
"width", G_TYPE_INT, siddec->config->bitsPerSample, "width", G_TYPE_INT, siddec->config->bitsPerSample,
"depth", G_TYPE_INT, siddec->config->bitsPerSample, "depth", G_TYPE_INT, siddec->config->bitsPerSample,
"rate", G_TYPE_INT, siddec->config->frequency, "rate", G_TYPE_INT, siddec->config->frequency,
"channels", G_TYPE_INT, siddec->config->channels, "channels", G_TYPE_INT, siddec->config->channels, NULL))) {
NULL)))
{
return FALSE; return FALSE;
} }
} }
@ -369,8 +373,8 @@ siddec_negotiate (GstSidDec *siddec)
return TRUE; return TRUE;
} }
static void static void
gst_siddec_loop (GstElement *element) gst_siddec_loop (GstElement * element)
{ {
GstSidDec *siddec; GstSidDec *siddec;
@ -380,29 +384,29 @@ gst_siddec_loop (GstElement *element)
GstData *data = gst_pad_pull (siddec->sinkpad); GstData *data = gst_pad_pull (siddec->sinkpad);
g_assert (data != NULL); g_assert (data != NULL);
if (GST_IS_EVENT (data)) { if (GST_IS_EVENT (data)) {
GstEvent *event = GST_EVENT (data); GstEvent *event = GST_EVENT (data);
switch (GST_EVENT_TYPE (event)) { switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_EOS: case GST_EVENT_EOS:
siddec->state = SID_STATE_LOAD_TUNE; siddec->state = SID_STATE_LOAD_TUNE;
break; break;
case GST_EVENT_DISCONTINUOUS: case GST_EVENT_DISCONTINUOUS:
break; break;
default: default:
// bail out, we're not going to do anything // bail out, we're not going to do anything
gst_event_unref (event); gst_event_unref (event);
gst_pad_send_event (siddec->srcpad, gst_event_new (GST_EVENT_EOS)); gst_pad_send_event (siddec->srcpad, gst_event_new (GST_EVENT_EOS));
gst_element_set_eos (element); gst_element_set_eos (element);
return; return;
} }
gst_event_unref (event); gst_event_unref (event);
} } else {
else {
GstBuffer *buf = GST_BUFFER (data); GstBuffer *buf = GST_BUFFER (data);
memcpy (siddec->tune_buffer+siddec->tune_len, GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf)); memcpy (siddec->tune_buffer + siddec->tune_len, GST_BUFFER_DATA (buf),
GST_BUFFER_SIZE (buf));
siddec->tune_len += GST_BUFFER_SIZE (buf); siddec->tune_len += GST_BUFFER_SIZE (buf);
gst_buffer_unref (buf); gst_buffer_unref (buf);
@ -413,7 +417,6 @@ gst_siddec_loop (GstElement *element)
GST_ELEMENT_ERROR (siddec, LIBRARY, TOO_LAZY, (NULL), (NULL)); GST_ELEMENT_ERROR (siddec, LIBRARY, TOO_LAZY, (NULL), (NULL));
return; return;
} }
//update_metadata (siddec); //update_metadata (siddec);
if (!siddec_negotiate (siddec)) { if (!siddec_negotiate (siddec)) {
@ -421,7 +424,8 @@ gst_siddec_loop (GstElement *element)
return; return;
} }
if (!sidEmuInitializeSong (*siddec->engine, *siddec->tune, siddec->tune_number)) { if (!sidEmuInitializeSong (*siddec->engine, *siddec->tune,
siddec->tune_number)) {
GST_ELEMENT_ERROR (siddec, LIBRARY, TOO_LAZY, (NULL), (NULL)); GST_ELEMENT_ERROR (siddec, LIBRARY, TOO_LAZY, (NULL), (NULL));
return; return;
} }
@ -436,7 +440,7 @@ gst_siddec_loop (GstElement *element)
out = gst_buffer_new_and_alloc (siddec->blocksize); out = gst_buffer_new_and_alloc (siddec->blocksize);
sidEmuFillBuffer (*siddec->engine, *siddec->tune, sidEmuFillBuffer (*siddec->engine, *siddec->tune,
GST_BUFFER_DATA (out), GST_BUFFER_SIZE (out)); GST_BUFFER_DATA (out), GST_BUFFER_SIZE (out));
/* get offset in samples */ /* get offset in samples */
format = GST_FORMAT_DEFAULT; format = GST_FORMAT_DEFAULT;
@ -454,13 +458,13 @@ gst_siddec_loop (GstElement *element)
gst_siddec_src_query (siddec->srcpad, GST_QUERY_POSITION, &format, &value2); gst_siddec_src_query (siddec->srcpad, GST_QUERY_POSITION, &format, &value2);
GST_BUFFER_DURATION (out) = value2 - value; GST_BUFFER_DURATION (out) = value2 - value;
gst_pad_push (siddec->srcpad, GST_DATA(out)); gst_pad_push (siddec->srcpad, GST_DATA (out));
} }
} }
static gboolean static gboolean
gst_siddec_src_convert (GstPad *pad, GstFormat src_format, gint64 src_value, gst_siddec_src_convert (GstPad * pad, GstFormat src_format, gint64 src_value,
GstFormat *dest_format, gint64 *dest_value) GstFormat * dest_format, gint64 * dest_value)
{ {
gboolean res = TRUE; gboolean res = TRUE;
guint scale = 1; guint scale = 1;
@ -469,53 +473,55 @@ gst_siddec_src_convert (GstPad *pad, GstFormat src_format, gint64 src_value,
siddec = GST_SIDDEC (gst_pad_get_parent (pad)); siddec = GST_SIDDEC (gst_pad_get_parent (pad));
bytes_per_sample = (siddec->config->bitsPerSample>>3) * siddec->config->channels; bytes_per_sample =
(siddec->config->bitsPerSample >> 3) * siddec->config->channels;
switch (src_format) { switch (src_format) {
case GST_FORMAT_BYTES: case GST_FORMAT_BYTES:
switch (*dest_format) { switch (*dest_format) {
case GST_FORMAT_DEFAULT: case GST_FORMAT_DEFAULT:
if (bytes_per_sample == 0) if (bytes_per_sample == 0)
return FALSE; return FALSE;
*dest_value = src_value / bytes_per_sample; *dest_value = src_value / bytes_per_sample;
break; break;
case GST_FORMAT_TIME: case GST_FORMAT_TIME:
{ {
gint byterate = bytes_per_sample * siddec->config->frequency; gint byterate = bytes_per_sample * siddec->config->frequency;
if (byterate == 0) if (byterate == 0)
return FALSE; return FALSE;
*dest_value = src_value * GST_SECOND / byterate; *dest_value = src_value * GST_SECOND / byterate;
break; break;
} }
default: default:
res = FALSE; res = FALSE;
} }
break; break;
case GST_FORMAT_DEFAULT: case GST_FORMAT_DEFAULT:
switch (*dest_format) { switch (*dest_format) {
case GST_FORMAT_BYTES: case GST_FORMAT_BYTES:
*dest_value = src_value * bytes_per_sample; *dest_value = src_value * bytes_per_sample;
break; break;
case GST_FORMAT_TIME: case GST_FORMAT_TIME:
if (siddec->config->frequency == 0) if (siddec->config->frequency == 0)
return FALSE; return FALSE;
*dest_value = src_value * GST_SECOND / siddec->config->frequency; *dest_value = src_value * GST_SECOND / siddec->config->frequency;
break; break;
default: default:
res = FALSE; res = FALSE;
} }
break; break;
case GST_FORMAT_TIME: case GST_FORMAT_TIME:
switch (*dest_format) { switch (*dest_format) {
case GST_FORMAT_BYTES: case GST_FORMAT_BYTES:
scale = bytes_per_sample; scale = bytes_per_sample;
/* fallthrough */ /* fallthrough */
case GST_FORMAT_DEFAULT: case GST_FORMAT_DEFAULT:
*dest_value = src_value * scale * siddec->config->frequency / GST_SECOND; *dest_value =
break; src_value * scale * siddec->config->frequency / GST_SECOND;
default: break;
res = FALSE; default:
res = FALSE;
} }
break; break;
default: default:
@ -526,8 +532,8 @@ gst_siddec_src_convert (GstPad *pad, GstFormat src_format, gint64 src_value,
} }
static gboolean static gboolean
gst_siddec_src_query (GstPad *pad, GstQueryType type, gst_siddec_src_query (GstPad * pad, GstQueryType type,
GstFormat *format, gint64 *value) GstFormat * format, gint64 * value)
{ {
gboolean res = TRUE; gboolean res = TRUE;
GstSidDec *siddec; GstSidDec *siddec;
@ -538,8 +544,7 @@ gst_siddec_src_query (GstPad *pad, GstQueryType type,
case GST_QUERY_POSITION: case GST_QUERY_POSITION:
/* we only know about our bytes, convert to requested format */ /* we only know about our bytes, convert to requested format */
res &= gst_pad_convert (pad, res &= gst_pad_convert (pad,
GST_FORMAT_BYTES, siddec->total_bytes, GST_FORMAT_BYTES, siddec->total_bytes, format, value);
format, value);
break; break;
default: default:
res = FALSE; res = FALSE;
@ -548,16 +553,17 @@ gst_siddec_src_query (GstPad *pad, GstQueryType type,
return res; return res;
} }
static void static void
gst_siddec_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) gst_siddec_set_property (GObject * object, guint prop_id, const GValue * value,
GParamSpec * pspec)
{ {
GstSidDec *siddec; GstSidDec *siddec;
/* it's not null if we got it, but it might not be ours */ /* it's not null if we got it, but it might not be ours */
g_return_if_fail(GST_IS_SIDDEC(object)); g_return_if_fail (GST_IS_SIDDEC (object));
siddec = GST_SIDDEC(object); siddec = GST_SIDDEC (object);
switch(prop_id) { switch (prop_id) {
case ARG_TUNE: case ARG_TUNE:
siddec->tune_number = g_value_get_int (value); siddec->tune_number = g_value_get_int (value);
break; break;
@ -589,16 +595,17 @@ gst_siddec_set_property (GObject *object, guint prop_id, const GValue *value, GP
siddec->engine->setConfig (*siddec->config); siddec->engine->setConfig (*siddec->config);
} }
static void static void
gst_siddec_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) gst_siddec_get_property (GObject * object, guint prop_id, GValue * value,
GParamSpec * pspec)
{ {
GstSidDec *siddec; GstSidDec *siddec;
/* it's not null if we got it, but it might not be ours */ /* it's not null if we got it, but it might not be ours */
g_return_if_fail(GST_IS_SIDDEC(object)); g_return_if_fail (GST_IS_SIDDEC (object));
siddec = GST_SIDDEC(object); siddec = GST_SIDDEC (object);
switch(prop_id) { switch (prop_id) {
case ARG_TUNE: case ARG_TUNE:
g_value_set_int (value, siddec->tune_number); g_value_set_int (value, siddec->tune_number);
break; break;
@ -633,21 +640,14 @@ gst_siddec_get_property (GObject *object, guint prop_id, GValue *value, GParamSp
} }
static gboolean static gboolean
plugin_init (GstPlugin *plugin) plugin_init (GstPlugin * plugin)
{ {
return gst_element_register (plugin, "siddec", GST_RANK_PRIMARY, return gst_element_register (plugin, "siddec", GST_RANK_PRIMARY,
GST_TYPE_SIDDEC); GST_TYPE_SIDDEC);
} }
GST_PLUGIN_DEFINE ( GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
GST_VERSION_MAJOR, GST_VERSION_MINOR,
GST_VERSION_MINOR, "siddec",
"siddec", "Uses libsid to decode .sid files",
"Uses libsid to decode .sid files", plugin_init, VERSION, "GPL", GST_PACKAGE, GST_ORIGIN)
plugin_init,
VERSION,
"GPL",
GST_PACKAGE,
GST_ORIGIN
)