2002-03-20 21:45:03 +00:00
|
|
|
/* GStreamer
|
2001-12-23 15:41:33 +00:00
|
|
|
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
|
2006-06-13 15:46:09 +00:00
|
|
|
* (C) <2006> Wim Taymans <wim@fluendo.com>
|
2001-12-23 15:41:33 +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
|
2012-11-03 20:40:37 +00:00
|
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
2001-12-23 15:41:33 +00:00
|
|
|
*/
|
|
|
|
|
2007-02-28 15:49:35 +00:00
|
|
|
/**
|
|
|
|
* SECTION:element-siddec
|
|
|
|
*
|
2016-07-24 08:00:48 +00:00
|
|
|
* This element decodes .sid files to raw audio. .sid files are in fact
|
|
|
|
* small Commodore 64 programs that are executed on an emulated 6502 CPU and a
|
2008-06-13 06:57:21 +00:00
|
|
|
* MOS 6581 sound chip.
|
2016-07-24 08:00:48 +00:00
|
|
|
*
|
2007-02-28 15:49:35 +00:00
|
|
|
* This plugin will first load the complete program into memory before starting
|
|
|
|
* the emulator and producing output.
|
2016-07-24 08:00:48 +00:00
|
|
|
*
|
2007-02-28 15:49:35 +00:00
|
|
|
* Seeking is not (and cannot be) implemented.
|
2016-07-24 08:00:48 +00:00
|
|
|
*
|
2019-05-29 21:00:48 +00:00
|
|
|
* ## Example pipelines
|
|
|
|
*
|
2008-06-13 06:57:21 +00:00
|
|
|
* |[
|
2015-05-10 10:34:33 +00:00
|
|
|
* gst-launch-1.0 -v filesrc location=Hawkeye.sid ! siddec ! audioconvert ! audioresample ! autoaudiosink
|
|
|
|
* ]| Decode a sid file and play it back.
|
2007-02-28 15:49:35 +00:00
|
|
|
*/
|
|
|
|
|
2003-11-07 12:46:51 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
2001-12-23 15:41:33 +00:00
|
|
|
|
|
|
|
#include <string.h>
|
2011-08-19 16:07:58 +00:00
|
|
|
#include <gst/audio/audio.h>
|
2001-12-23 15:41:33 +00:00
|
|
|
#include "gstsiddec.h"
|
|
|
|
|
2006-06-13 15:46:09 +00:00
|
|
|
#define DEFAULT_TUNE 0
|
|
|
|
#define DEFAULT_CLOCK SIDTUNE_CLOCK_PAL
|
|
|
|
#define DEFAULT_MEMORY MPU_BANK_SWITCHING
|
|
|
|
#define DEFAULT_FILTER TRUE
|
|
|
|
#define DEFAULT_MEASURED_VOLUME TRUE
|
|
|
|
#define DEFAULT_MOS8580 FALSE
|
|
|
|
#define DEFAULT_FORCE_SPEED FALSE
|
2003-06-03 18:23:14 +00:00
|
|
|
#define DEFAULT_BLOCKSIZE 4096
|
|
|
|
|
2004-03-14 23:20:40 +00:00
|
|
|
enum
|
|
|
|
{
|
2006-06-13 15:46:09 +00:00
|
|
|
PROP_0,
|
|
|
|
PROP_TUNE,
|
|
|
|
PROP_CLOCK,
|
|
|
|
PROP_MEMORY,
|
|
|
|
PROP_FILTER,
|
|
|
|
PROP_MEASURED_VOLUME,
|
|
|
|
PROP_MOS8580,
|
|
|
|
PROP_FORCE_SPEED,
|
|
|
|
PROP_BLOCKSIZE,
|
|
|
|
PROP_METADATA
|
2001-12-23 15:41:33 +00:00
|
|
|
};
|
|
|
|
|
2004-03-14 23:20:40 +00:00
|
|
|
static GstStaticPadTemplate sink_templ = GST_STATIC_PAD_TEMPLATE ("sink",
|
|
|
|
GST_PAD_SINK,
|
|
|
|
GST_PAD_ALWAYS,
|
|
|
|
GST_STATIC_CAPS ("audio/x-sid")
|
|
|
|
);
|
|
|
|
|
2016-02-17 22:25:56 +00:00
|
|
|
#define FORMATS "{ " GST_AUDIO_NE(S16) "," GST_AUDIO_NE(U16) ", S8, U8 }"
|
2011-08-19 16:07:58 +00:00
|
|
|
|
2004-03-14 23:20:40 +00:00
|
|
|
static GstStaticPadTemplate src_templ = GST_STATIC_PAD_TEMPLATE ("src",
|
|
|
|
GST_PAD_SRC,
|
|
|
|
GST_PAD_ALWAYS,
|
2011-08-19 16:07:58 +00:00
|
|
|
GST_STATIC_CAPS ("audio/x-raw, "
|
|
|
|
"format = (string) " FORMATS ", "
|
2012-02-09 15:14:55 +00:00
|
|
|
"layout = (string) interleaved, "
|
2004-03-15 19:32:25 +00:00
|
|
|
"rate = (int) [ 8000, 48000 ], " "channels = (int) [ 1, 2 ]")
|
2004-03-14 23:20:40 +00:00
|
|
|
);
|
|
|
|
|
2011-10-27 14:53:44 +00:00
|
|
|
GST_DEBUG_CATEGORY_STATIC (gst_siddec_debug);
|
|
|
|
#define GST_CAT_DEFAULT gst_siddec_debug
|
2001-12-23 15:41:33 +00:00
|
|
|
|
|
|
|
#define GST_TYPE_SID_CLOCK (gst_sid_clock_get_type())
|
|
|
|
static GType
|
|
|
|
gst_sid_clock_get_type (void)
|
|
|
|
{
|
|
|
|
static GType sid_clock_type = 0;
|
2006-06-13 15:46:09 +00:00
|
|
|
static const GEnumValue sid_clock[] = {
|
2005-11-22 17:04:38 +00:00
|
|
|
{SIDTUNE_CLOCK_PAL, "PAL", "pal"},
|
|
|
|
{SIDTUNE_CLOCK_NTSC, "NTSC", "ntsc"},
|
2004-03-14 23:20:40 +00:00
|
|
|
{0, NULL, NULL},
|
2001-12-23 15:41:33 +00:00
|
|
|
};
|
2004-03-15 19:32:25 +00:00
|
|
|
|
2001-12-23 15:41:33 +00:00
|
|
|
if (!sid_clock_type) {
|
|
|
|
sid_clock_type = g_enum_register_static ("GstSidClock", sid_clock);
|
|
|
|
}
|
|
|
|
return sid_clock_type;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define GST_TYPE_SID_MEMORY (gst_sid_memory_get_type())
|
|
|
|
static GType
|
|
|
|
gst_sid_memory_get_type (void)
|
|
|
|
{
|
|
|
|
static GType sid_memory_type = 0;
|
2006-06-13 15:46:09 +00:00
|
|
|
static const GEnumValue sid_memory[] = {
|
2005-11-22 17:04:38 +00:00
|
|
|
{MPU_BANK_SWITCHING, "Bank Switching", "bank-switching"},
|
|
|
|
{MPU_TRANSPARENT_ROM, "Transparent ROM", "transparent-rom"},
|
|
|
|
{MPU_PLAYSID_ENVIRONMENT, "Playsid Environment", "playsid-environment"},
|
2004-03-14 23:20:40 +00:00
|
|
|
{0, NULL, NULL},
|
2001-12-23 15:41:33 +00:00
|
|
|
};
|
2004-03-15 19:32:25 +00:00
|
|
|
|
2001-12-23 15:41:33 +00:00
|
|
|
if (!sid_memory_type) {
|
|
|
|
sid_memory_type = g_enum_register_static ("GstSidMemory", sid_memory);
|
|
|
|
}
|
|
|
|
return sid_memory_type;
|
|
|
|
}
|
|
|
|
|
2006-06-13 15:46:09 +00:00
|
|
|
static void gst_siddec_finalize (GObject * object);
|
2001-12-23 15:41:33 +00:00
|
|
|
|
2012-07-27 22:28:27 +00:00
|
|
|
static GstFlowReturn gst_siddec_chain (GstPad * pad, GstObject * parent,
|
|
|
|
GstBuffer * buffer);
|
|
|
|
static gboolean gst_siddec_sink_event (GstPad * pad, GstObject * parent,
|
|
|
|
GstEvent * event);
|
2001-12-23 15:41:33 +00:00
|
|
|
|
2004-03-14 23:20:40 +00:00
|
|
|
static gboolean gst_siddec_src_convert (GstPad * pad, GstFormat src_format,
|
|
|
|
gint64 src_value, GstFormat * dest_format, gint64 * dest_value);
|
2012-07-27 22:28:27 +00:00
|
|
|
static gboolean gst_siddec_src_event (GstPad * pad, GstObject * parent,
|
|
|
|
GstEvent * event);
|
|
|
|
static gboolean gst_siddec_src_query (GstPad * pad, GstObject * parent,
|
|
|
|
GstQuery * query);
|
2002-06-02 20:09:43 +00:00
|
|
|
|
2004-03-14 23:20:40 +00:00
|
|
|
static void gst_siddec_get_property (GObject * object, guint prop_id,
|
|
|
|
GValue * value, GParamSpec * pspec);
|
|
|
|
static void gst_siddec_set_property (GObject * object, guint prop_id,
|
|
|
|
const GValue * value, GParamSpec * pspec);
|
2001-12-23 15:41:33 +00:00
|
|
|
|
2011-06-08 16:18:17 +00:00
|
|
|
#define gst_siddec_parent_class parent_class
|
|
|
|
G_DEFINE_TYPE (GstSidDec, gst_siddec, GST_TYPE_ELEMENT);
|
2021-03-29 10:33:00 +00:00
|
|
|
GST_ELEMENT_REGISTER_DEFINE (siddec, "siddec", GST_RANK_PRIMARY,
|
|
|
|
GST_TYPE_SIDDEC);
|
2001-12-23 15:41:33 +00:00
|
|
|
|
2003-11-03 20:16:05 +00:00
|
|
|
static void
|
2011-06-08 16:18:17 +00:00
|
|
|
gst_siddec_class_init (GstSidDecClass * klass)
|
2001-12-23 15:41:33 +00:00
|
|
|
{
|
|
|
|
GObjectClass *gobject_class;
|
2011-06-08 16:18:17 +00:00
|
|
|
GstElementClass *gstelement_class;
|
2001-12-23 15:41:33 +00:00
|
|
|
|
2004-03-14 23:20:40 +00:00
|
|
|
gobject_class = (GObjectClass *) klass;
|
2011-06-08 16:18:17 +00:00
|
|
|
gstelement_class = (GstElementClass *) klass;
|
2001-12-23 15:41:33 +00:00
|
|
|
|
2006-06-13 15:46:09 +00:00
|
|
|
gobject_class->finalize = gst_siddec_finalize;
|
2005-05-06 17:24:44 +00:00
|
|
|
gobject_class->set_property = gst_siddec_set_property;
|
|
|
|
gobject_class->get_property = gst_siddec_get_property;
|
|
|
|
|
2006-06-13 15:46:09 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_TUNE,
|
2004-03-14 23:20:40 +00:00
|
|
|
g_param_spec_int ("tune", "tune", "tune",
|
2010-10-19 07:06:33 +00:00
|
|
|
0, 100, DEFAULT_TUNE,
|
2012-07-27 22:28:27 +00:00
|
|
|
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
|
2006-06-13 15:46:09 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_CLOCK,
|
2004-03-14 23:20:40 +00:00
|
|
|
g_param_spec_enum ("clock", "clock", "clock",
|
2010-10-19 07:06:33 +00:00
|
|
|
GST_TYPE_SID_CLOCK, DEFAULT_CLOCK,
|
2012-07-27 22:28:27 +00:00
|
|
|
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
|
2006-06-13 15:46:09 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_MEMORY,
|
2004-03-14 23:20:40 +00:00
|
|
|
g_param_spec_enum ("memory", "memory", "memory", GST_TYPE_SID_MEMORY,
|
2010-10-19 07:06:33 +00:00
|
|
|
DEFAULT_MEMORY,
|
2012-07-27 22:28:27 +00:00
|
|
|
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
|
2006-06-13 15:46:09 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_FILTER,
|
|
|
|
g_param_spec_boolean ("filter", "filter", "filter", DEFAULT_FILTER,
|
2012-07-27 22:28:27 +00:00
|
|
|
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
|
2006-06-13 15:46:09 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_MEASURED_VOLUME,
|
2010-10-19 09:20:40 +00:00
|
|
|
g_param_spec_boolean ("measured-volume", "measured_volume",
|
2006-06-13 15:46:09 +00:00
|
|
|
"measured_volume", DEFAULT_MEASURED_VOLUME,
|
2012-07-27 22:28:27 +00:00
|
|
|
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
|
2006-06-13 15:46:09 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_MOS8580,
|
|
|
|
g_param_spec_boolean ("mos8580", "mos8580", "mos8580", DEFAULT_MOS8580,
|
2012-07-27 22:28:27 +00:00
|
|
|
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
|
2006-06-13 15:46:09 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_FORCE_SPEED,
|
2010-10-19 09:20:40 +00:00
|
|
|
g_param_spec_boolean ("force-speed", "force_speed", "force_speed",
|
2010-10-19 07:06:33 +00:00
|
|
|
DEFAULT_FORCE_SPEED,
|
2012-07-27 22:28:27 +00:00
|
|
|
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
|
2006-06-13 15:46:09 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_BLOCKSIZE,
|
2012-02-09 17:10:48 +00:00
|
|
|
g_param_spec_uint ("blocksize", "Block size",
|
|
|
|
"Size in bytes to output per buffer", 1, G_MAXUINT,
|
2010-10-19 07:06:33 +00:00
|
|
|
DEFAULT_BLOCKSIZE,
|
2012-07-27 22:28:27 +00:00
|
|
|
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
|
2006-06-13 15:46:09 +00:00
|
|
|
g_object_class_install_property (gobject_class, PROP_METADATA,
|
2004-03-14 23:20:40 +00:00
|
|
|
g_param_spec_boxed ("metadata", "Metadata", "Metadata", GST_TYPE_CAPS,
|
2012-07-27 22:28:27 +00:00
|
|
|
(GParamFlags) (G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)));
|
2011-06-08 16:18:17 +00:00
|
|
|
|
2012-04-09 23:47:44 +00:00
|
|
|
gst_element_class_set_static_metadata (gstelement_class, "Sid decoder",
|
2011-06-08 16:18:17 +00:00
|
|
|
"Codec/Decoder/Audio", "Use libsidplay to decode SID audio tunes",
|
|
|
|
"Wim Taymans <wim.taymans@gmail.com>");
|
|
|
|
|
2016-03-04 07:14:44 +00:00
|
|
|
gst_element_class_add_static_pad_template (gstelement_class, &src_templ);
|
|
|
|
gst_element_class_add_static_pad_template (gstelement_class, &sink_templ);
|
2012-12-01 12:26:26 +00:00
|
|
|
|
2013-07-22 13:43:18 +00:00
|
|
|
GST_DEBUG_CATEGORY_INIT (gst_siddec_debug, "siddec", 0,
|
|
|
|
"C64 sid song player");
|
2020-05-30 20:16:50 +00:00
|
|
|
|
2020-06-06 09:15:25 +00:00
|
|
|
gst_type_mark_as_plugin_api (GST_TYPE_SID_CLOCK, static_cast<GstPluginAPIFlags>(0));
|
|
|
|
gst_type_mark_as_plugin_api (GST_TYPE_SID_MEMORY, static_cast<GstPluginAPIFlags>(0));
|
2001-12-23 15:41:33 +00:00
|
|
|
}
|
|
|
|
|
2004-03-14 23:20:40 +00:00
|
|
|
static void
|
|
|
|
gst_siddec_init (GstSidDec * siddec)
|
2001-12-23 15:41:33 +00:00
|
|
|
{
|
2007-08-17 06:56:53 +00:00
|
|
|
siddec->sinkpad = gst_pad_new_from_static_template (&sink_templ, "sink");
|
2005-05-06 17:24:44 +00:00
|
|
|
gst_pad_set_event_function (siddec->sinkpad, gst_siddec_sink_event);
|
|
|
|
gst_pad_set_chain_function (siddec->sinkpad, gst_siddec_chain);
|
|
|
|
gst_element_add_pad (GST_ELEMENT (siddec), siddec->sinkpad);
|
2001-12-23 15:41:33 +00:00
|
|
|
|
2007-08-17 06:56:53 +00:00
|
|
|
siddec->srcpad = gst_pad_new_from_static_template (&src_templ, "src");
|
2006-06-13 15:46:09 +00:00
|
|
|
gst_pad_set_event_function (siddec->srcpad, gst_siddec_src_event);
|
2002-06-02 20:09:43 +00:00
|
|
|
gst_pad_set_query_function (siddec->srcpad, gst_siddec_src_query);
|
2006-06-13 15:46:09 +00:00
|
|
|
gst_pad_use_fixed_caps (siddec->srcpad);
|
2001-12-23 15:41:33 +00:00
|
|
|
gst_element_add_pad (GST_ELEMENT (siddec), siddec->srcpad);
|
|
|
|
|
2004-03-14 23:20:40 +00:00
|
|
|
siddec->engine = new emuEngine ();
|
|
|
|
siddec->tune = new sidTune (0);
|
|
|
|
siddec->config = (emuConfig *) g_malloc (sizeof (emuConfig));
|
|
|
|
|
2006-06-13 15:46:09 +00:00
|
|
|
/* get default config parameters */
|
|
|
|
siddec->engine->getConfig (*siddec->config);
|
|
|
|
|
|
|
|
siddec->config->mos8580 = DEFAULT_MOS8580; // mos8580
|
|
|
|
siddec->config->memoryMode = DEFAULT_MEMORY; // memory mode
|
|
|
|
siddec->config->clockSpeed = DEFAULT_CLOCK; // clock speed
|
|
|
|
siddec->config->forceSongSpeed = DEFAULT_FORCE_SPEED; // force song speed
|
2001-12-23 15:41:33 +00:00
|
|
|
|
|
|
|
siddec->engine->setConfig (*siddec->config);
|
|
|
|
|
|
|
|
siddec->tune_buffer = (guchar *) g_malloc (maxSidtuneFileLen);
|
|
|
|
siddec->tune_len = 0;
|
2006-06-13 15:46:09 +00:00
|
|
|
siddec->tune_number = 0;
|
2002-06-02 20:09:43 +00:00
|
|
|
siddec->total_bytes = 0;
|
2003-06-03 18:23:14 +00:00
|
|
|
siddec->blocksize = DEFAULT_BLOCKSIZE;
|
2013-07-22 13:43:18 +00:00
|
|
|
|
|
|
|
siddec->have_group_id = FALSE;
|
|
|
|
siddec->group_id = G_MAXUINT;
|
2001-12-23 15:41:33 +00:00
|
|
|
}
|
|
|
|
|
2004-03-14 23:20:40 +00:00
|
|
|
static void
|
2006-06-13 15:46:09 +00:00
|
|
|
gst_siddec_finalize (GObject * object)
|
|
|
|
{
|
|
|
|
GstSidDec *siddec = GST_SIDDEC (object);
|
|
|
|
|
|
|
|
g_free (siddec->config);
|
|
|
|
g_free (siddec->tune_buffer);
|
|
|
|
|
|
|
|
delete (siddec->tune);
|
|
|
|
delete (siddec->engine);
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
update_tags (GstSidDec * siddec)
|
2002-12-08 01:14:59 +00:00
|
|
|
{
|
|
|
|
sidTuneInfo info;
|
2006-06-13 15:46:09 +00:00
|
|
|
GstTagList *list;
|
2002-12-08 01:14:59 +00:00
|
|
|
|
|
|
|
if (siddec->tune->getInfo (info)) {
|
2011-10-30 11:51:58 +00:00
|
|
|
list = gst_tag_list_new_empty ();
|
2002-12-08 01:14:59 +00:00
|
|
|
|
|
|
|
if (info.nameString) {
|
2006-06-13 15:46:09 +00:00
|
|
|
gst_tag_list_add (list, GST_TAG_MERGE_REPLACE,
|
2008-04-25 23:10:54 +00:00
|
|
|
GST_TAG_TITLE, info.nameString, (void *) NULL);
|
2002-12-08 01:14:59 +00:00
|
|
|
}
|
|
|
|
if (info.authorString) {
|
2006-06-13 15:46:09 +00:00
|
|
|
gst_tag_list_add (list, GST_TAG_MERGE_REPLACE,
|
2008-04-25 23:10:54 +00:00
|
|
|
GST_TAG_ARTIST, info.authorString, (void *) NULL);
|
2002-12-08 01:14:59 +00:00
|
|
|
}
|
|
|
|
if (info.copyrightString) {
|
2006-06-13 15:46:09 +00:00
|
|
|
gst_tag_list_add (list, GST_TAG_MERGE_REPLACE,
|
2008-04-25 23:10:54 +00:00
|
|
|
GST_TAG_COPYRIGHT, info.copyrightString, (void *) NULL);
|
2002-12-08 01:14:59 +00:00
|
|
|
}
|
2012-07-27 22:28:27 +00:00
|
|
|
gst_pad_push_event (siddec->srcpad, gst_event_new_tag (list));
|
2002-12-08 01:14:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2004-03-14 23:20:40 +00:00
|
|
|
siddec_negotiate (GstSidDec * siddec)
|
2002-12-08 01:14:59 +00:00
|
|
|
{
|
2012-03-12 11:23:43 +00:00
|
|
|
GstCaps *allowed;
|
2003-12-22 01:47:08 +00:00
|
|
|
GstStructure *structure;
|
2006-06-13 15:46:09 +00:00
|
|
|
int rate = 44100;
|
|
|
|
int channels = 1;
|
|
|
|
GstCaps *caps;
|
2011-08-19 16:07:58 +00:00
|
|
|
const gchar *str;
|
|
|
|
GstAudioFormat format;
|
2013-07-22 13:43:18 +00:00
|
|
|
GstEvent *event;
|
2012-08-05 16:30:52 +00:00
|
|
|
gchar *stream_id;
|
2002-12-08 01:14:59 +00:00
|
|
|
|
|
|
|
allowed = gst_pad_get_allowed_caps (siddec->srcpad);
|
2006-06-13 15:46:09 +00:00
|
|
|
if (!allowed)
|
|
|
|
goto nothing_allowed;
|
|
|
|
|
2006-10-05 17:07:52 +00:00
|
|
|
GST_DEBUG_OBJECT (siddec, "allowed caps: %" GST_PTR_FORMAT, allowed);
|
2002-12-08 01:14:59 +00:00
|
|
|
|
2012-03-12 11:23:43 +00:00
|
|
|
allowed = gst_caps_normalize (allowed);
|
2012-02-09 15:14:55 +00:00
|
|
|
|
2003-12-22 01:47:08 +00:00
|
|
|
structure = gst_caps_get_structure (allowed, 0);
|
|
|
|
|
2011-08-19 16:07:58 +00:00
|
|
|
str = gst_structure_get_string (structure, "format");
|
|
|
|
if (str == NULL)
|
|
|
|
goto invalid_format;
|
|
|
|
|
|
|
|
format = gst_audio_format_from_string (str);
|
|
|
|
switch (format) {
|
|
|
|
case GST_AUDIO_FORMAT_S8:
|
|
|
|
siddec->config->bitsPerSample = 8;
|
|
|
|
siddec->config->sampleFormat = SIDEMU_SIGNED_PCM;
|
|
|
|
break;
|
|
|
|
case GST_AUDIO_FORMAT_U8:
|
|
|
|
siddec->config->bitsPerSample = 8;
|
|
|
|
siddec->config->sampleFormat = SIDEMU_UNSIGNED_PCM;
|
|
|
|
break;
|
|
|
|
case GST_AUDIO_FORMAT_S16:
|
|
|
|
siddec->config->bitsPerSample = 16;
|
|
|
|
siddec->config->sampleFormat = SIDEMU_SIGNED_PCM;
|
|
|
|
break;
|
|
|
|
case GST_AUDIO_FORMAT_U16:
|
|
|
|
siddec->config->bitsPerSample = 16;
|
|
|
|
siddec->config->sampleFormat = SIDEMU_UNSIGNED_PCM;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
goto invalid_format;
|
2002-12-08 01:14:59 +00:00
|
|
|
}
|
|
|
|
|
2003-12-22 01:47:08 +00:00
|
|
|
gst_structure_get_int (structure, "rate", &rate);
|
|
|
|
siddec->config->frequency = rate;
|
|
|
|
gst_structure_get_int (structure, "channels", &channels);
|
|
|
|
siddec->config->channels = channels;
|
2002-12-08 01:14:59 +00:00
|
|
|
|
2013-07-22 13:43:18 +00:00
|
|
|
stream_id =
|
|
|
|
gst_pad_create_stream_id (siddec->srcpad, GST_ELEMENT_CAST (siddec),
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
event = gst_pad_get_sticky_event (siddec->sinkpad, GST_EVENT_STREAM_START, 0);
|
|
|
|
if (event) {
|
|
|
|
if (gst_event_parse_group_id (event, &siddec->group_id))
|
|
|
|
siddec->have_group_id = TRUE;
|
|
|
|
else
|
|
|
|
siddec->have_group_id = FALSE;
|
|
|
|
gst_event_unref (event);
|
|
|
|
} else if (!siddec->have_group_id) {
|
|
|
|
siddec->have_group_id = TRUE;
|
|
|
|
siddec->group_id = gst_util_group_id_next ();
|
|
|
|
}
|
|
|
|
|
|
|
|
event = gst_event_new_stream_start (stream_id);
|
|
|
|
if (siddec->have_group_id)
|
|
|
|
gst_event_set_group_id (event, siddec->group_id);
|
|
|
|
|
|
|
|
gst_pad_push_event (siddec->srcpad, event);
|
2012-08-05 16:30:52 +00:00
|
|
|
g_free (stream_id);
|
|
|
|
|
2011-08-19 16:07:58 +00:00
|
|
|
caps = gst_caps_new_simple ("audio/x-raw",
|
|
|
|
"format", G_TYPE_STRING, gst_audio_format_to_string (format),
|
2012-02-09 15:14:55 +00:00
|
|
|
"layout", G_TYPE_STRING, "interleaved",
|
2006-06-13 15:46:09 +00:00
|
|
|
"rate", G_TYPE_INT, siddec->config->frequency,
|
|
|
|
"channels", G_TYPE_INT, siddec->config->channels, NULL);
|
|
|
|
gst_pad_set_caps (siddec->srcpad, caps);
|
|
|
|
gst_caps_unref (caps);
|
2002-12-08 01:14:59 +00:00
|
|
|
|
2012-03-12 11:23:43 +00:00
|
|
|
gst_caps_unref (allowed);
|
|
|
|
|
2002-12-08 01:14:59 +00:00
|
|
|
siddec->engine->setConfig (*siddec->config);
|
|
|
|
|
|
|
|
return TRUE;
|
2006-06-13 15:46:09 +00:00
|
|
|
|
2007-02-28 15:49:35 +00:00
|
|
|
/* ERRORS */
|
2006-06-13 15:46:09 +00:00
|
|
|
nothing_allowed:
|
|
|
|
{
|
|
|
|
GST_DEBUG_OBJECT (siddec, "could not get allowed caps");
|
|
|
|
return FALSE;
|
|
|
|
}
|
2011-08-19 16:07:58 +00:00
|
|
|
invalid_format:
|
2006-06-13 15:46:09 +00:00
|
|
|
{
|
2011-08-19 16:07:58 +00:00
|
|
|
GST_DEBUG_OBJECT (siddec, "invalid audio caps");
|
2012-03-12 11:23:43 +00:00
|
|
|
gst_caps_unref (allowed);
|
2006-06-13 15:46:09 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
2002-12-08 01:14:59 +00:00
|
|
|
}
|
|
|
|
|
2004-03-14 23:20:40 +00:00
|
|
|
static void
|
2005-05-06 17:24:44 +00:00
|
|
|
play_loop (GstPad * pad)
|
2001-12-23 15:41:33 +00:00
|
|
|
{
|
2005-05-06 17:24:44 +00:00
|
|
|
GstFlowReturn ret;
|
2001-12-23 15:41:33 +00:00
|
|
|
GstSidDec *siddec;
|
2005-05-06 17:24:44 +00:00
|
|
|
GstBuffer *out;
|
2012-01-25 06:24:59 +00:00
|
|
|
GstMapInfo outmap;
|
2016-07-24 08:00:48 +00:00
|
|
|
gint64 value, offset, time = 0;
|
2005-05-12 20:05:19 +00:00
|
|
|
GstFormat format;
|
2001-12-23 15:41:33 +00:00
|
|
|
|
2006-06-13 15:46:09 +00:00
|
|
|
siddec = GST_SIDDEC (gst_pad_get_parent (pad));
|
2001-12-23 15:41:33 +00:00
|
|
|
|
2005-05-06 17:24:44 +00:00
|
|
|
out = gst_buffer_new_and_alloc (siddec->blocksize);
|
2003-10-09 02:23:01 +00:00
|
|
|
|
2012-01-25 06:24:59 +00:00
|
|
|
gst_buffer_map (out, &outmap, GST_MAP_WRITE);
|
2005-05-06 17:24:44 +00:00
|
|
|
sidEmuFillBuffer (*siddec->engine, *siddec->tune,
|
2012-01-25 06:24:59 +00:00
|
|
|
outmap.data, siddec->blocksize);
|
|
|
|
gst_buffer_unmap (out, &outmap);
|
2004-03-14 23:20:40 +00:00
|
|
|
|
2005-05-06 17:24:44 +00:00
|
|
|
/* get offset in samples */
|
|
|
|
format = GST_FORMAT_DEFAULT;
|
2016-07-24 08:00:48 +00:00
|
|
|
if (gst_siddec_src_convert (siddec->srcpad,
|
2019-02-22 23:54:30 +00:00
|
|
|
GST_FORMAT_BYTES, siddec->total_bytes, &format, &offset))
|
2016-07-24 08:00:48 +00:00
|
|
|
GST_BUFFER_OFFSET (out) = offset;
|
2002-07-08 19:38:26 +00:00
|
|
|
|
2005-05-06 17:24:44 +00:00
|
|
|
/* get current timestamp */
|
2005-10-20 08:30:33 +00:00
|
|
|
format = GST_FORMAT_TIME;
|
2016-07-24 08:00:48 +00:00
|
|
|
if (gst_siddec_src_convert (siddec->srcpad,
|
2019-02-22 23:54:30 +00:00
|
|
|
GST_FORMAT_BYTES, siddec->total_bytes, &format, &time))
|
2016-07-24 08:00:48 +00:00
|
|
|
GST_BUFFER_TIMESTAMP (out) = time;
|
2003-10-09 02:23:01 +00:00
|
|
|
|
2005-05-06 17:24:44 +00:00
|
|
|
/* update position and get new timestamp to calculate duration */
|
|
|
|
siddec->total_bytes += siddec->blocksize;
|
2001-12-23 15:41:33 +00:00
|
|
|
|
2005-05-06 17:24:44 +00:00
|
|
|
/* get offset in samples */
|
|
|
|
format = GST_FORMAT_DEFAULT;
|
2016-07-24 08:00:48 +00:00
|
|
|
if (gst_siddec_src_convert (siddec->srcpad,
|
2019-02-22 23:54:30 +00:00
|
|
|
GST_FORMAT_BYTES, siddec->total_bytes, &format, &value))
|
2016-07-24 08:00:48 +00:00
|
|
|
GST_BUFFER_OFFSET_END (out) = value;
|
2005-05-06 17:24:44 +00:00
|
|
|
|
|
|
|
format = GST_FORMAT_TIME;
|
2016-07-24 08:00:48 +00:00
|
|
|
if (gst_siddec_src_convert (siddec->srcpad,
|
2019-02-22 23:54:30 +00:00
|
|
|
GST_FORMAT_BYTES, siddec->total_bytes, &format, &value))
|
2016-07-24 08:00:48 +00:00
|
|
|
GST_BUFFER_DURATION (out) = value - time;
|
2005-05-06 17:24:44 +00:00
|
|
|
|
|
|
|
if ((ret = gst_pad_push (siddec->srcpad, out)) != GST_FLOW_OK)
|
|
|
|
goto pause;
|
|
|
|
|
2006-06-13 15:46:09 +00:00
|
|
|
done:
|
|
|
|
gst_object_unref (siddec);
|
|
|
|
|
2005-05-06 17:24:44 +00:00
|
|
|
return;
|
|
|
|
|
2006-06-13 15:46:09 +00:00
|
|
|
/* ERRORS */
|
2005-05-06 17:24:44 +00:00
|
|
|
pause:
|
|
|
|
{
|
2012-01-03 14:27:42 +00:00
|
|
|
if (ret == GST_FLOW_EOS) {
|
2010-09-06 22:51:23 +00:00
|
|
|
/* perform EOS logic, FIXME, segment seek? */
|
|
|
|
gst_pad_push_event (pad, gst_event_new_eos ());
|
2012-07-27 22:28:27 +00:00
|
|
|
} else if (ret < GST_FLOW_EOS || ret == GST_FLOW_NOT_LINKED) {
|
2010-09-06 22:51:23 +00:00
|
|
|
/* for fatal errors we post an error message */
|
2016-08-19 18:11:14 +00:00
|
|
|
GST_ELEMENT_FLOW_ERROR (siddec, ret);
|
2010-09-06 22:51:23 +00:00
|
|
|
gst_pad_push_event (pad, gst_event_new_eos ());
|
2006-06-13 15:46:09 +00:00
|
|
|
}
|
2010-09-06 22:51:23 +00:00
|
|
|
|
2019-02-22 23:54:30 +00:00
|
|
|
GST_INFO_OBJECT (siddec, "pausing task, reason: %s",
|
|
|
|
gst_flow_get_name (ret));
|
2010-09-06 22:51:23 +00:00
|
|
|
gst_pad_pause_task (pad);
|
2006-06-13 15:46:09 +00:00
|
|
|
goto done;
|
2001-12-23 23:00:59 +00:00
|
|
|
}
|
2005-05-06 17:24:44 +00:00
|
|
|
}
|
2001-12-23 15:41:33 +00:00
|
|
|
|
2005-05-06 17:24:44 +00:00
|
|
|
static gboolean
|
|
|
|
start_play_tune (GstSidDec * siddec)
|
|
|
|
{
|
|
|
|
gboolean res;
|
2011-06-08 16:18:17 +00:00
|
|
|
GstSegment segment;
|
2002-12-08 01:14:59 +00:00
|
|
|
|
2005-05-06 17:24:44 +00:00
|
|
|
if (!siddec->tune->load (siddec->tune_buffer, siddec->tune_len))
|
|
|
|
goto could_not_load;
|
|
|
|
|
2006-06-13 15:46:09 +00:00
|
|
|
update_tags (siddec);
|
2002-12-08 01:14:59 +00:00
|
|
|
|
2005-05-06 17:24:44 +00:00
|
|
|
if (!siddec_negotiate (siddec))
|
|
|
|
goto could_not_negotiate;
|
|
|
|
|
|
|
|
if (!sidEmuInitializeSong (*siddec->engine, *siddec->tune,
|
|
|
|
siddec->tune_number))
|
|
|
|
goto could_not_init;
|
|
|
|
|
2011-06-08 16:18:17 +00:00
|
|
|
gst_segment_init (&segment, GST_FORMAT_TIME);
|
2012-07-27 22:28:27 +00:00
|
|
|
gst_pad_push_event (siddec->srcpad, gst_event_new_segment (&segment));
|
2012-10-30 09:20:04 +00:00
|
|
|
siddec->total_bytes = 0;
|
2013-07-22 13:43:18 +00:00
|
|
|
siddec->have_group_id = FALSE;
|
|
|
|
siddec->group_id = G_MAXUINT;
|
2005-10-20 08:30:33 +00:00
|
|
|
|
2005-05-25 12:58:23 +00:00
|
|
|
res = gst_pad_start_task (siddec->srcpad,
|
2012-06-20 08:39:37 +00:00
|
|
|
(GstTaskFunction) play_loop, siddec->srcpad, NULL);
|
2005-05-06 17:24:44 +00:00
|
|
|
return res;
|
|
|
|
|
|
|
|
/* ERRORS */
|
|
|
|
could_not_load:
|
|
|
|
{
|
2005-10-20 08:30:33 +00:00
|
|
|
GST_ELEMENT_ERROR (siddec, LIBRARY, INIT,
|
|
|
|
("Could not load tune"), ("Could not load tune"));
|
2005-05-06 17:24:44 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
could_not_negotiate:
|
|
|
|
{
|
2005-10-20 08:30:33 +00:00
|
|
|
GST_ELEMENT_ERROR (siddec, CORE, NEGOTIATION,
|
|
|
|
("Could not negotiate format"), ("Could not negotiate format"));
|
2005-05-06 17:24:44 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
could_not_init:
|
|
|
|
{
|
2005-10-20 08:30:33 +00:00
|
|
|
GST_ELEMENT_ERROR (siddec, LIBRARY, INIT,
|
|
|
|
("Could not initialize song"), ("Could not initialize song"));
|
2005-05-06 17:24:44 +00:00
|
|
|
return FALSE;
|
2001-12-23 23:00:59 +00:00
|
|
|
}
|
2005-05-06 17:24:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2011-11-17 14:25:58 +00:00
|
|
|
gst_siddec_sink_event (GstPad * pad, GstObject * parent, GstEvent * event)
|
2005-05-06 17:24:44 +00:00
|
|
|
{
|
|
|
|
GstSidDec *siddec;
|
|
|
|
gboolean res;
|
|
|
|
|
2011-11-17 14:25:58 +00:00
|
|
|
siddec = GST_SIDDEC (parent);
|
2005-05-06 17:24:44 +00:00
|
|
|
|
|
|
|
switch (GST_EVENT_TYPE (event)) {
|
|
|
|
case GST_EVENT_EOS:
|
|
|
|
res = start_play_tune (siddec);
|
|
|
|
break;
|
2011-06-08 16:18:17 +00:00
|
|
|
case GST_EVENT_SEGMENT:
|
2012-02-09 15:14:55 +00:00
|
|
|
res = TRUE;
|
2005-05-06 17:24:44 +00:00
|
|
|
break;
|
|
|
|
default:
|
2012-02-09 15:14:55 +00:00
|
|
|
res = TRUE;
|
2005-05-06 17:24:44 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
gst_event_unref (event);
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GstFlowReturn
|
2011-11-17 14:25:58 +00:00
|
|
|
gst_siddec_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
|
2005-05-06 17:24:44 +00:00
|
|
|
{
|
|
|
|
GstSidDec *siddec;
|
|
|
|
guint64 size;
|
2001-12-23 15:41:33 +00:00
|
|
|
|
2011-11-17 14:25:58 +00:00
|
|
|
siddec = GST_SIDDEC (parent);
|
2001-12-23 15:41:33 +00:00
|
|
|
|
2011-06-08 16:18:17 +00:00
|
|
|
size = gst_buffer_get_size (buffer);
|
2005-05-06 17:24:44 +00:00
|
|
|
if (siddec->tune_len + size > maxSidtuneFileLen)
|
|
|
|
goto overflow;
|
2001-12-23 15:41:33 +00:00
|
|
|
|
2011-06-08 16:18:17 +00:00
|
|
|
gst_buffer_extract (buffer, 0, siddec->tune_buffer + siddec->tune_len, size);
|
|
|
|
|
2005-05-06 17:24:44 +00:00
|
|
|
siddec->tune_len += size;
|
2002-06-02 20:09:43 +00:00
|
|
|
|
2005-05-06 17:24:44 +00:00
|
|
|
gst_buffer_unref (buffer);
|
2004-06-18 11:46:32 +00:00
|
|
|
|
2005-05-06 17:24:44 +00:00
|
|
|
return GST_FLOW_OK;
|
2002-06-02 20:09:43 +00:00
|
|
|
|
2006-06-13 15:46:09 +00:00
|
|
|
/* ERRORS */
|
2005-05-06 17:24:44 +00:00
|
|
|
overflow:
|
|
|
|
{
|
2006-06-13 15:46:09 +00:00
|
|
|
GST_ELEMENT_ERROR (siddec, STREAM, DECODE,
|
2007-02-28 15:49:35 +00:00
|
|
|
(NULL), ("Input data bigger than allowed buffer size"));
|
2005-05-06 17:24:44 +00:00
|
|
|
return GST_FLOW_ERROR;
|
2001-12-23 23:00:59 +00:00
|
|
|
}
|
2001-12-23 15:41:33 +00:00
|
|
|
}
|
|
|
|
|
2002-06-02 20:09:43 +00:00
|
|
|
static gboolean
|
2004-03-14 23:20:40 +00:00
|
|
|
gst_siddec_src_convert (GstPad * pad, GstFormat src_format, gint64 src_value,
|
|
|
|
GstFormat * dest_format, gint64 * dest_value)
|
2002-06-02 20:09:43 +00:00
|
|
|
{
|
|
|
|
gboolean res = TRUE;
|
|
|
|
guint scale = 1;
|
|
|
|
GstSidDec *siddec;
|
|
|
|
gint bytes_per_sample;
|
|
|
|
|
2006-06-13 15:46:09 +00:00
|
|
|
siddec = GST_SIDDEC (gst_pad_get_parent (pad));
|
2002-06-02 20:09:43 +00:00
|
|
|
|
2005-05-12 20:05:19 +00:00
|
|
|
if (src_format == *dest_format) {
|
|
|
|
*dest_value = src_value;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2004-03-14 23:20:40 +00:00
|
|
|
bytes_per_sample =
|
|
|
|
(siddec->config->bitsPerSample >> 3) * siddec->config->channels;
|
2002-06-02 20:09:43 +00:00
|
|
|
|
|
|
|
switch (src_format) {
|
|
|
|
case GST_FORMAT_BYTES:
|
|
|
|
switch (*dest_format) {
|
2004-03-15 19:32:25 +00:00
|
|
|
case GST_FORMAT_DEFAULT:
|
|
|
|
if (bytes_per_sample == 0)
|
|
|
|
return FALSE;
|
|
|
|
*dest_value = src_value / bytes_per_sample;
|
|
|
|
break;
|
|
|
|
case GST_FORMAT_TIME:
|
|
|
|
{
|
|
|
|
gint byterate = bytes_per_sample * siddec->config->frequency;
|
|
|
|
|
|
|
|
if (byterate == 0)
|
|
|
|
return FALSE;
|
2006-06-13 15:46:09 +00:00
|
|
|
*dest_value =
|
|
|
|
gst_util_uint64_scale_int (src_value, GST_SECOND, byterate);
|
2004-03-15 19:32:25 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
res = FALSE;
|
2002-06-02 20:09:43 +00:00
|
|
|
}
|
|
|
|
break;
|
2003-05-24 10:41:58 +00:00
|
|
|
case GST_FORMAT_DEFAULT:
|
2002-06-02 20:09:43 +00:00
|
|
|
switch (*dest_format) {
|
2004-03-15 19:32:25 +00:00
|
|
|
case GST_FORMAT_BYTES:
|
|
|
|
*dest_value = src_value * bytes_per_sample;
|
|
|
|
break;
|
|
|
|
case GST_FORMAT_TIME:
|
|
|
|
if (siddec->config->frequency == 0)
|
|
|
|
return FALSE;
|
2006-06-13 15:46:09 +00:00
|
|
|
*dest_value =
|
|
|
|
gst_util_uint64_scale_int (src_value, GST_SECOND,
|
|
|
|
siddec->config->frequency);
|
2004-03-15 19:32:25 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
res = FALSE;
|
2002-06-02 20:09:43 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case GST_FORMAT_TIME:
|
|
|
|
switch (*dest_format) {
|
2004-03-15 19:32:25 +00:00
|
|
|
case GST_FORMAT_BYTES:
|
|
|
|
scale = bytes_per_sample;
|
|
|
|
/* fallthrough */
|
|
|
|
case GST_FORMAT_DEFAULT:
|
|
|
|
*dest_value =
|
2006-06-13 15:46:09 +00:00
|
|
|
gst_util_uint64_scale_int (src_value,
|
|
|
|
scale * siddec->config->frequency, GST_SECOND);
|
2004-03-15 19:32:25 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
res = FALSE;
|
2002-06-02 20:09:43 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
res = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2006-06-13 15:46:09 +00:00
|
|
|
static gboolean
|
2011-11-17 14:25:58 +00:00
|
|
|
gst_siddec_src_event (GstPad * pad, GstObject * parent, GstEvent * event)
|
2006-06-13 15:46:09 +00:00
|
|
|
{
|
|
|
|
gboolean res = FALSE;
|
|
|
|
|
|
|
|
switch (GST_EVENT_TYPE (event)) {
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
gst_event_unref (event);
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2002-06-02 20:09:43 +00:00
|
|
|
static gboolean
|
2011-11-16 16:28:56 +00:00
|
|
|
gst_siddec_src_query (GstPad * pad, GstObject * parent, GstQuery * query)
|
2002-06-02 20:09:43 +00:00
|
|
|
{
|
|
|
|
gboolean res = TRUE;
|
|
|
|
GstSidDec *siddec;
|
|
|
|
|
2011-11-16 16:28:56 +00:00
|
|
|
siddec = GST_SIDDEC (parent);
|
2002-06-02 20:09:43 +00:00
|
|
|
|
2005-05-12 20:05:19 +00:00
|
|
|
switch (GST_QUERY_TYPE (query)) {
|
2002-12-30 17:53:18 +00:00
|
|
|
case GST_QUERY_POSITION:
|
2005-05-12 20:05:19 +00:00
|
|
|
{
|
|
|
|
GstFormat format;
|
|
|
|
gint64 current;
|
|
|
|
|
2005-10-19 16:01:35 +00:00
|
|
|
gst_query_parse_position (query, &format, NULL);
|
2005-05-12 20:05:19 +00:00
|
|
|
|
2002-06-02 20:09:43 +00:00
|
|
|
/* we only know about our bytes, convert to requested format */
|
2004-06-18 11:46:32 +00:00
|
|
|
res &= gst_siddec_src_convert (pad,
|
2005-05-12 20:05:19 +00:00
|
|
|
GST_FORMAT_BYTES, siddec->total_bytes, &format, ¤t);
|
|
|
|
if (res) {
|
2005-10-19 16:01:35 +00:00
|
|
|
gst_query_set_position (query, format, current);
|
2005-05-12 20:05:19 +00:00
|
|
|
}
|
2002-06-02 20:09:43 +00:00
|
|
|
break;
|
2005-05-12 20:05:19 +00:00
|
|
|
}
|
2002-06-02 20:09:43 +00:00
|
|
|
default:
|
2011-11-16 16:28:56 +00:00
|
|
|
res = gst_pad_query_default (pad, parent, query);
|
2002-06-02 20:09:43 +00:00
|
|
|
break;
|
|
|
|
}
|
2006-06-13 15:46:09 +00:00
|
|
|
|
2002-06-02 20:09:43 +00:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2004-03-14 23:20:40 +00:00
|
|
|
static void
|
|
|
|
gst_siddec_set_property (GObject * object, guint prop_id, const GValue * value,
|
|
|
|
GParamSpec * pspec)
|
2001-12-23 15:41:33 +00:00
|
|
|
{
|
2011-10-27 14:53:44 +00:00
|
|
|
GstSidDec *siddec = GST_SIDDEC (object);
|
2001-12-23 15:41:33 +00:00
|
|
|
|
2004-03-14 23:20:40 +00:00
|
|
|
switch (prop_id) {
|
2006-06-13 15:46:09 +00:00
|
|
|
case PROP_TUNE:
|
2001-12-23 15:41:33 +00:00
|
|
|
siddec->tune_number = g_value_get_int (value);
|
|
|
|
break;
|
2006-06-13 15:46:09 +00:00
|
|
|
case PROP_CLOCK:
|
2001-12-23 15:41:33 +00:00
|
|
|
siddec->config->clockSpeed = g_value_get_enum (value);
|
|
|
|
break;
|
2006-06-13 15:46:09 +00:00
|
|
|
case PROP_MEMORY:
|
2001-12-23 15:41:33 +00:00
|
|
|
siddec->config->memoryMode = g_value_get_enum (value);
|
|
|
|
break;
|
2006-06-13 15:46:09 +00:00
|
|
|
case PROP_FILTER:
|
2001-12-23 15:41:33 +00:00
|
|
|
siddec->config->emulateFilter = g_value_get_boolean (value);
|
|
|
|
break;
|
2006-06-13 15:46:09 +00:00
|
|
|
case PROP_MEASURED_VOLUME:
|
2001-12-23 15:41:33 +00:00
|
|
|
siddec->config->measuredVolume = g_value_get_boolean (value);
|
|
|
|
break;
|
2006-06-13 15:46:09 +00:00
|
|
|
case PROP_MOS8580:
|
2001-12-23 15:41:33 +00:00
|
|
|
siddec->config->mos8580 = g_value_get_boolean (value);
|
|
|
|
break;
|
2006-06-13 15:46:09 +00:00
|
|
|
case PROP_BLOCKSIZE:
|
2012-02-09 17:10:48 +00:00
|
|
|
siddec->blocksize = g_value_get_uint (value);
|
2003-06-03 18:23:14 +00:00
|
|
|
break;
|
2006-06-13 15:46:09 +00:00
|
|
|
case PROP_FORCE_SPEED:
|
2001-12-23 15:41:33 +00:00
|
|
|
siddec->config->forceSongSpeed = g_value_get_boolean (value);
|
|
|
|
break;
|
|
|
|
default:
|
2011-10-27 14:53:44 +00:00
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
2001-12-23 15:41:33 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
siddec->engine->setConfig (*siddec->config);
|
|
|
|
}
|
|
|
|
|
2004-03-14 23:20:40 +00:00
|
|
|
static void
|
|
|
|
gst_siddec_get_property (GObject * object, guint prop_id, GValue * value,
|
|
|
|
GParamSpec * pspec)
|
2001-12-23 15:41:33 +00:00
|
|
|
{
|
2011-10-27 14:53:44 +00:00
|
|
|
GstSidDec *siddec = GST_SIDDEC (object);
|
2001-12-23 15:41:33 +00:00
|
|
|
|
2004-03-14 23:20:40 +00:00
|
|
|
switch (prop_id) {
|
2006-06-13 15:46:09 +00:00
|
|
|
case PROP_TUNE:
|
2001-12-23 15:41:33 +00:00
|
|
|
g_value_set_int (value, siddec->tune_number);
|
|
|
|
break;
|
2006-06-13 15:46:09 +00:00
|
|
|
case PROP_CLOCK:
|
2001-12-23 15:41:33 +00:00
|
|
|
g_value_set_enum (value, siddec->config->clockSpeed);
|
|
|
|
break;
|
2006-06-13 15:46:09 +00:00
|
|
|
case PROP_MEMORY:
|
2001-12-23 15:41:33 +00:00
|
|
|
g_value_set_enum (value, siddec->config->memoryMode);
|
|
|
|
break;
|
2006-06-13 15:46:09 +00:00
|
|
|
case PROP_FILTER:
|
2001-12-23 15:41:33 +00:00
|
|
|
g_value_set_boolean (value, siddec->config->emulateFilter);
|
|
|
|
break;
|
2006-06-13 15:46:09 +00:00
|
|
|
case PROP_MEASURED_VOLUME:
|
2001-12-23 15:41:33 +00:00
|
|
|
g_value_set_boolean (value, siddec->config->measuredVolume);
|
|
|
|
break;
|
2006-06-13 15:46:09 +00:00
|
|
|
case PROP_MOS8580:
|
2001-12-23 15:41:33 +00:00
|
|
|
g_value_set_boolean (value, siddec->config->mos8580);
|
|
|
|
break;
|
2006-06-13 15:46:09 +00:00
|
|
|
case PROP_FORCE_SPEED:
|
2001-12-23 15:41:33 +00:00
|
|
|
g_value_set_boolean (value, siddec->config->forceSongSpeed);
|
|
|
|
break;
|
2006-06-13 15:46:09 +00:00
|
|
|
case PROP_BLOCKSIZE:
|
2012-02-09 17:10:48 +00:00
|
|
|
g_value_set_uint (value, siddec->blocksize);
|
2003-06-03 18:23:14 +00:00
|
|
|
break;
|
2006-06-13 15:46:09 +00:00
|
|
|
case PROP_METADATA:
|
2006-07-21 11:01:55 +00:00
|
|
|
g_value_set_boxed (value, NULL);
|
2002-12-08 01:14:59 +00:00
|
|
|
break;
|
2001-12-23 15:41:33 +00:00
|
|
|
default:
|
2011-10-27 14:53:44 +00:00
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
2001-12-23 15:41:33 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2004-03-14 23:20:40 +00:00
|
|
|
plugin_init (GstPlugin * plugin)
|
2001-12-23 15:41:33 +00:00
|
|
|
{
|
2021-03-29 10:33:00 +00:00
|
|
|
return GST_ELEMENT_REGISTER (siddec, plugin);
|
2001-12-23 15:41:33 +00:00
|
|
|
}
|
|
|
|
|
2004-03-14 23:20:40 +00:00
|
|
|
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
|
|
|
|
GST_VERSION_MINOR,
|
2017-05-09 13:45:27 +00:00
|
|
|
sid,
|
2011-10-27 14:53:44 +00:00
|
|
|
"Uses libsidplay to decode .sid files",
|
2006-04-01 09:54:39 +00:00
|
|
|
plugin_init, VERSION, "GPL", GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN);
|