mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-23 00:36:51 +00:00
ext/timidity/gstwildmidi.*: Don't initialize wildmidi in plugin_init as it also setups audio filters which is slow.
Original commit message from CVS: * ext/timidity/gstwildmidi.c: (wildmidi_open_config), (gst_wildmidi_init), (gst_wildmidi_change_state), (plugin_init): * ext/timidity/gstwildmidi.h: Don't initialize wildmidi in plugin_init as it also setups audio filters which is slow.
This commit is contained in:
parent
2a8bc6a2e1
commit
9c8ef16a8a
3 changed files with 73 additions and 56 deletions
|
@ -1,3 +1,11 @@
|
||||||
|
2007-07-24 Stefan Kost <ensonic@users.sf.net>
|
||||||
|
|
||||||
|
* ext/timidity/gstwildmidi.c: (wildmidi_open_config),
|
||||||
|
(gst_wildmidi_init), (gst_wildmidi_change_state), (plugin_init):
|
||||||
|
* ext/timidity/gstwildmidi.h:
|
||||||
|
Don't initialize wildmidi in plugin_init as it also setups audio
|
||||||
|
filters which is slow.
|
||||||
|
|
||||||
2007-07-24 Hans de Goede <j.w.r.degoede@hhs.nl>
|
2007-07-24 Hans de Goede <j.w.r.degoede@hhs.nl>
|
||||||
|
|
||||||
reviewed by: Edward Hervey <bilboed@bilboed.com>
|
reviewed by: Edward Hervey <bilboed@bilboed.com>
|
||||||
|
|
|
@ -126,6 +126,57 @@ gst_wildmidi_base_init (gpointer gclass)
|
||||||
gst_element_class_set_details (element_class, &gst_wildmidi_details);
|
gst_element_class_set_details (element_class, &gst_wildmidi_details);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
wildmidi_open_config ()
|
||||||
|
{
|
||||||
|
gchar *path = g_strdup (g_getenv ("WILDMIDI_CFG"));
|
||||||
|
gint ret;
|
||||||
|
|
||||||
|
GST_DEBUG ("trying %s", GST_STR_NULL (path));
|
||||||
|
if (path && (g_access (path, R_OK) == -1)) {
|
||||||
|
g_free (path);
|
||||||
|
path = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (path == NULL) {
|
||||||
|
path =
|
||||||
|
g_build_path (G_DIR_SEPARATOR_S, g_get_home_dir (), ".wildmidirc",
|
||||||
|
NULL);
|
||||||
|
GST_DEBUG ("trying %s", path);
|
||||||
|
if (path && (g_access (path, R_OK) == -1)) {
|
||||||
|
g_free (path);
|
||||||
|
path = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (path == NULL) {
|
||||||
|
path = g_build_path (G_DIR_SEPARATOR_S, "/etc", "wildmidi.cfg", NULL);
|
||||||
|
GST_DEBUG ("trying %s", path);
|
||||||
|
if (path && (g_access (path, R_OK) == -1)) {
|
||||||
|
g_free (path);
|
||||||
|
path = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (path == NULL) {
|
||||||
|
/* I've created a symlink to get it playing
|
||||||
|
* ln -s /usr/share/timidity/timidity.cfg /etc/wildmidi.cfg
|
||||||
|
* we could make it use : TIMIDITY_CFG
|
||||||
|
* but unfortunately it fails to create a proper filename if the config
|
||||||
|
* has a redirect
|
||||||
|
* http://sourceforge.net/tracker/index.php?func=detail&aid=1657358&group_id=42635&atid=433744
|
||||||
|
*/
|
||||||
|
GST_WARNING ("no config file, can't initialise");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* this also initializes a some filter and stuff and thus is slow */
|
||||||
|
ret = WildMidi_Init (path, WILDMIDI_RATE, 0);
|
||||||
|
g_free (path);
|
||||||
|
|
||||||
|
return (ret == 0);
|
||||||
|
}
|
||||||
|
|
||||||
/* initialize the plugin's class */
|
/* initialize the plugin's class */
|
||||||
static void
|
static void
|
||||||
gst_wildmidi_class_init (GstWildmidiClass * klass)
|
gst_wildmidi_class_init (GstWildmidiClass * klass)
|
||||||
|
@ -159,6 +210,13 @@ gst_wildmidi_init (GstWildmidi * filter, GstWildmidiClass * g_class)
|
||||||
{
|
{
|
||||||
GstElementClass *klass = GST_ELEMENT_GET_CLASS (filter);
|
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 =
|
filter->sinkpad =
|
||||||
gst_pad_new_from_template (gst_element_class_get_pad_template (klass,
|
gst_pad_new_from_template (gst_element_class_get_pad_template (klass,
|
||||||
"sink"), "sink");
|
"sink"), "sink");
|
||||||
|
@ -722,6 +780,11 @@ gst_wildmidi_change_state (GstElement * element, GstStateChange transition)
|
||||||
GstStateChangeReturn ret = GST_STATE_CHANGE_SUCCESS;
|
GstStateChangeReturn ret = GST_STATE_CHANGE_SUCCESS;
|
||||||
GstWildmidi *wildmidi = GST_WILDMIDI (element);
|
GstWildmidi *wildmidi = GST_WILDMIDI (element);
|
||||||
|
|
||||||
|
if (!wildmidi->initialized) {
|
||||||
|
GST_WARNING ("WildMidi renderer is not initialized");
|
||||||
|
return GST_STATE_CHANGE_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
switch (transition) {
|
switch (transition) {
|
||||||
case GST_STATE_CHANGE_NULL_TO_READY:
|
case GST_STATE_CHANGE_NULL_TO_READY:
|
||||||
wildmidi->out_caps =
|
wildmidi->out_caps =
|
||||||
|
@ -827,56 +890,6 @@ gst_wildmidi_typefind (GstTypeFind * tf, gpointer _data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
|
||||||
wildmidi_open_config ()
|
|
||||||
{
|
|
||||||
gchar *path = g_strdup (g_getenv ("WILDMIDI_CFG"));
|
|
||||||
gint ret;
|
|
||||||
|
|
||||||
GST_DEBUG ("trying %s", GST_STR_NULL (path));
|
|
||||||
if (path && (g_access (path, R_OK) == -1)) {
|
|
||||||
g_free (path);
|
|
||||||
path = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (path == NULL) {
|
|
||||||
path =
|
|
||||||
g_build_path (G_DIR_SEPARATOR_S, g_get_home_dir (), ".wildmidirc",
|
|
||||||
NULL);
|
|
||||||
GST_DEBUG ("trying %s", path);
|
|
||||||
if (path && (g_access (path, R_OK) == -1)) {
|
|
||||||
g_free (path);
|
|
||||||
path = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (path == NULL) {
|
|
||||||
path = g_build_path (G_DIR_SEPARATOR_S, "/etc", "wildmidi.cfg", NULL);
|
|
||||||
GST_DEBUG ("trying %s", path);
|
|
||||||
if (path && (g_access (path, R_OK) == -1)) {
|
|
||||||
g_free (path);
|
|
||||||
path = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (path == NULL) {
|
|
||||||
/* I've created a symlink to get it playing
|
|
||||||
* ln -s /usr/share/timidity/timidity.cfg /etc/wildmidi.cfg
|
|
||||||
* we could make it use : TIMIDITY_CFG
|
|
||||||
* but unfortunately it fails to create a proper filename if the config
|
|
||||||
* has a redirect
|
|
||||||
* http://sourceforge.net/tracker/index.php?func=detail&aid=1657358&group_id=42635&atid=433744
|
|
||||||
*/
|
|
||||||
GST_WARNING ("no config file, can't initialise");
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = WildMidi_Init (path, WILDMIDI_RATE, 0);
|
|
||||||
g_free (path);
|
|
||||||
|
|
||||||
return (ret == 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
plugin_init (GstPlugin * plugin)
|
plugin_init (GstPlugin * plugin)
|
||||||
{
|
{
|
||||||
|
@ -886,12 +899,6 @@ plugin_init (GstPlugin * plugin)
|
||||||
GST_DEBUG_CATEGORY_INIT (gst_wildmidi_debug, "wildmidi",
|
GST_DEBUG_CATEGORY_INIT (gst_wildmidi_debug, "wildmidi",
|
||||||
0, "Wildmidi plugin");
|
0, "Wildmidi plugin");
|
||||||
|
|
||||||
/* initialise wildmidi library, fail loading the plugin if this fails */
|
|
||||||
if (!wildmidi_open_config ()) {
|
|
||||||
GST_WARNING ("can't initialize wildmidi");
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!gst_type_find_register (plugin, "audio/midi", GST_RANK_SECONDARY,
|
if (!gst_type_find_register (plugin, "audio/midi", GST_RANK_SECONDARY,
|
||||||
gst_wildmidi_typefind, exts,
|
gst_wildmidi_typefind, exts,
|
||||||
gst_caps_new_simple ("audio/midi", NULL), NULL, NULL)) {
|
gst_caps_new_simple ("audio/midi", NULL), NULL, NULL)) {
|
||||||
|
|
|
@ -51,6 +51,8 @@ struct _GstWildmidi
|
||||||
|
|
||||||
GstPad *sinkpad, *srcpad;
|
GstPad *sinkpad, *srcpad;
|
||||||
|
|
||||||
|
gboolean initialized;
|
||||||
|
|
||||||
/* input stream properties */
|
/* input stream properties */
|
||||||
gint64 mididata_size, mididata_offset;
|
gint64 mididata_size, mididata_offset;
|
||||||
gchar *mididata;
|
gchar *mididata;
|
||||||
|
|
Loading…
Reference in a new issue