mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-23 18:21:04 +00:00
ext/timidity/gstwildmidi.*: Initialize wildmidi only once in the plugin init function instead of once for every insta...
Original commit message from CVS: Based on a patch by: Sonicadvance1 at GMAIL dot COM * ext/timidity/gstwildmidi.c: (gst_wildmidi_init), (gst_wildmidi_change_state), (plugin_init): * ext/timidity/gstwildmidi.h: Initialize wildmidi only once in the plugin init function instead of once for every instance. The second and following calls to the wildmidi initialization function will fail. Fixes bug #525613. Also don't register the element at all if wildmidi initialization fails.
This commit is contained in:
parent
744f3efec5
commit
a14d311c96
3 changed files with 46 additions and 14 deletions
14
ChangeLog
14
ChangeLog
|
@ -1,3 +1,17 @@
|
|||
2008-06-11 Sebastian Dröge <slomo@circular-chaos.org>
|
||||
|
||||
Based on a patch by: Sonicadvance1 at GMAIL dot COM
|
||||
|
||||
* ext/timidity/gstwildmidi.c: (gst_wildmidi_init),
|
||||
(gst_wildmidi_change_state), (plugin_init):
|
||||
* ext/timidity/gstwildmidi.h:
|
||||
Initialize wildmidi only once in the plugin init function instead
|
||||
of once for every instance. The second and following calls to the
|
||||
wildmidi initialization function will fail. Fixes bug #525613.
|
||||
|
||||
Also don't register the element at all if wildmidi initialization
|
||||
fails.
|
||||
|
||||
2008-06-10 Sebastian Dröge <slomo@circular-chaos.org>
|
||||
|
||||
* ext/soundtouch/gstpitch.cc:
|
||||
|
|
|
@ -86,14 +86,19 @@ enum
|
|||
};
|
||||
|
||||
static void gst_wildmidi_base_init (gpointer g_class);
|
||||
|
||||
static void gst_wildmidi_class_init (GstWildmidiClass * klass);
|
||||
|
||||
static gboolean gst_wildmidi_src_event (GstPad * pad, GstEvent * event);
|
||||
|
||||
static GstStateChangeReturn gst_wildmidi_change_state (GstElement * element,
|
||||
GstStateChange transition);
|
||||
static gboolean gst_wildmidi_activate (GstPad * pad);
|
||||
|
||||
static gboolean gst_wildmidi_activatepull (GstPad * pad, gboolean active);
|
||||
|
||||
static void gst_wildmidi_loop (GstPad * sinkpad);
|
||||
|
||||
static gboolean gst_wildmidi_src_query (GstPad * pad, GstQuery * query);
|
||||
|
||||
static void gst_wildmidi_set_property (GObject * object, guint prop_id,
|
||||
|
@ -134,6 +139,7 @@ static gboolean
|
|||
wildmidi_open_config ()
|
||||
{
|
||||
gchar *path = g_strdup (g_getenv ("WILDMIDI_CFG"));
|
||||
|
||||
gint ret;
|
||||
|
||||
GST_DEBUG ("trying %s", GST_STR_NULL (path));
|
||||
|
@ -226,6 +232,7 @@ static void
|
|||
gst_wildmidi_class_init (GstWildmidiClass * klass)
|
||||
{
|
||||
GObjectClass *gobject_class;
|
||||
|
||||
GstElementClass *gstelement_class;
|
||||
|
||||
gobject_class = (GObjectClass *) klass;
|
||||
|
@ -254,13 +261,6 @@ gst_wildmidi_init (GstWildmidi * filter, GstWildmidiClass * g_class)
|
|||
{
|
||||
GstElementClass *klass = GST_ELEMENT_GET_CLASS (filter);
|
||||
|
||||
/* initialise wildmidi library */
|
||||
if (wildmidi_open_config ()) {
|
||||
filter->initialized = TRUE;
|
||||
} else {
|
||||
GST_WARNING ("can't initialize wildmidi");
|
||||
}
|
||||
|
||||
filter->sinkpad =
|
||||
gst_pad_new_from_template (gst_element_class_get_pad_template (klass,
|
||||
"sink"), "sink");
|
||||
|
@ -295,6 +295,7 @@ gst_wildmidi_src_convert (GstWildmidi * wildmidi,
|
|||
GstFormat * dest_format, gint64 * dest_value)
|
||||
{
|
||||
gboolean res = TRUE;
|
||||
|
||||
gint64 frames;
|
||||
|
||||
if (src_format == *dest_format) {
|
||||
|
@ -340,8 +341,11 @@ static gboolean
|
|||
gst_wildmidi_src_query (GstPad * pad, GstQuery * query)
|
||||
{
|
||||
gboolean res = TRUE;
|
||||
|
||||
GstWildmidi *wildmidi = GST_WILDMIDI (gst_pad_get_parent (pad));
|
||||
|
||||
GstFormat src_format, dst_format;
|
||||
|
||||
gint64 src_value, dst_value;
|
||||
|
||||
if (!wildmidi->song) {
|
||||
|
@ -396,7 +400,9 @@ static gboolean
|
|||
gst_wildmidi_get_upstream_size (GstWildmidi * wildmidi, gint64 * size)
|
||||
{
|
||||
GstFormat format = GST_FORMAT_BYTES;
|
||||
|
||||
gboolean res = FALSE;
|
||||
|
||||
GstPad *peer = gst_pad_get_peer (wildmidi->sinkpad);
|
||||
|
||||
if (peer != NULL)
|
||||
|
@ -441,6 +447,7 @@ gst_wildmidi_get_new_segment_event (GstWildmidi * wildmidi, GstFormat format,
|
|||
gboolean update)
|
||||
{
|
||||
GstSegment *segment;
|
||||
|
||||
GstEvent *event;
|
||||
|
||||
segment = gst_wildmidi_get_segment (wildmidi, format, update);
|
||||
|
@ -458,6 +465,7 @@ static gboolean
|
|||
gst_wildmidi_src_event (GstPad * pad, GstEvent * event)
|
||||
{
|
||||
gboolean res = FALSE;
|
||||
|
||||
GstWildmidi *wildmidi = GST_WILDMIDI (gst_pad_get_parent (pad));
|
||||
|
||||
GST_DEBUG_OBJECT (pad, "%s event received", GST_EVENT_TYPE_NAME (event));
|
||||
|
@ -466,10 +474,15 @@ gst_wildmidi_src_event (GstPad * pad, GstEvent * event)
|
|||
case GST_EVENT_SEEK:
|
||||
{
|
||||
gdouble rate;
|
||||
|
||||
GstFormat src_format, dst_format;
|
||||
|
||||
GstSeekFlags flags;
|
||||
|
||||
GstSeekType start_type, stop_type;
|
||||
|
||||
gint64 orig_start, start, stop;
|
||||
|
||||
gboolean flush, update;
|
||||
|
||||
if (!wildmidi->song)
|
||||
|
@ -562,7 +575,9 @@ static GstBuffer *
|
|||
gst_wildmidi_clip_buffer (GstWildmidi * wildmidi, GstBuffer * buffer)
|
||||
{
|
||||
gint64 new_start, new_stop;
|
||||
|
||||
gint64 offset, length;
|
||||
|
||||
GstBuffer *out;
|
||||
|
||||
return buffer;
|
||||
|
@ -599,6 +614,7 @@ static GstBuffer *
|
|||
gst_wildmidi_fill_buffer (GstWildmidi * wildmidi, GstBuffer * buffer)
|
||||
{
|
||||
size_t bytes_read;
|
||||
|
||||
gint64 samples;
|
||||
|
||||
bytes_read =
|
||||
|
@ -659,7 +675,9 @@ static void
|
|||
gst_wildmidi_loop (GstPad * sinkpad)
|
||||
{
|
||||
GstWildmidi *wildmidi = GST_WILDMIDI (GST_PAD_PARENT (sinkpad));
|
||||
|
||||
GstBuffer *out;
|
||||
|
||||
GstFlowReturn ret;
|
||||
|
||||
if (wildmidi->mididata_size == 0) {
|
||||
|
@ -679,6 +697,7 @@ gst_wildmidi_loop (GstPad * sinkpad)
|
|||
|
||||
if (wildmidi->mididata_offset < wildmidi->mididata_size) {
|
||||
GstBuffer *buffer;
|
||||
|
||||
gint64 size;
|
||||
|
||||
GST_DEBUG_OBJECT (wildmidi, "loading song");
|
||||
|
@ -822,12 +841,8 @@ static GstStateChangeReturn
|
|||
gst_wildmidi_change_state (GstElement * element, GstStateChange transition)
|
||||
{
|
||||
GstStateChangeReturn ret = GST_STATE_CHANGE_SUCCESS;
|
||||
GstWildmidi *wildmidi = GST_WILDMIDI (element);
|
||||
|
||||
if (!wildmidi->initialized) {
|
||||
GST_WARNING ("WildMidi renderer is not initialized");
|
||||
return GST_STATE_CHANGE_FAILURE;
|
||||
}
|
||||
GstWildmidi *wildmidi = GST_WILDMIDI (element);
|
||||
|
||||
switch (transition) {
|
||||
case GST_STATE_CHANGE_NULL_TO_READY:
|
||||
|
@ -925,6 +940,11 @@ plugin_init (GstPlugin * plugin)
|
|||
GST_DEBUG_CATEGORY_INIT (gst_wildmidi_debug, "wildmidi",
|
||||
0, "Wildmidi plugin");
|
||||
|
||||
if (!wildmidi_open_config ()) {
|
||||
GST_WARNING ("Can't initialize wildmidi");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return gst_element_register (plugin, "wildmidi",
|
||||
GST_RANK_SECONDARY, GST_TYPE_WILDMIDI);
|
||||
}
|
||||
|
|
|
@ -51,8 +51,6 @@ struct _GstWildmidi
|
|||
|
||||
GstPad *sinkpad, *srcpad;
|
||||
|
||||
gboolean initialized;
|
||||
|
||||
/* input stream properties */
|
||||
gint64 mididata_size, mididata_offset;
|
||||
gchar *mididata;
|
||||
|
|
Loading…
Reference in a new issue