mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-22 15:18:21 +00:00
fluiddec: add more soundfont search paths
Fedora installs the soundfonts in /usr/share/soundfonts/ so make sure we look there as well.
This commit is contained in:
parent
270b57fc33
commit
64367f33a6
1 changed files with 43 additions and 53 deletions
|
@ -63,8 +63,6 @@ enum
|
|||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
#define SOUNDFONT_PATH "sounds/sf2/"
|
||||
|
||||
#define DEFAULT_SOUNDFONT NULL
|
||||
#define DEFAULT_SYNTH_CHORUS TRUE
|
||||
#define DEFAULT_SYNTH_REVERB TRUE
|
||||
|
@ -507,8 +505,6 @@ gst_fluid_dec_open (GstFluidDec * fluiddec)
|
|||
{
|
||||
GDir *dir;
|
||||
GError *error = NULL;
|
||||
gint shared_dirs_count;
|
||||
gint shared_dirs_failed;
|
||||
const gchar *const *sharedirs;
|
||||
|
||||
if (fluiddec->sf != -1)
|
||||
|
@ -525,53 +521,56 @@ gst_fluid_dec_open (GstFluidDec * fluiddec)
|
|||
GST_DEBUG_OBJECT (fluiddec, "loaded soundfont file %s",
|
||||
fluiddec->soundfont);
|
||||
} else {
|
||||
gint i;
|
||||
shared_dirs_count = 0;
|
||||
shared_dirs_failed = 0;
|
||||
gint i, j;
|
||||
/* ubuntu/debian in sounds/sf2, fedora in soundfonts */
|
||||
static const gchar *paths[] = { "sounds/sf2/", "soundfonts/", NULL };
|
||||
|
||||
sharedirs = g_get_system_data_dirs ();
|
||||
|
||||
for (i = 0; sharedirs[i]; i++) {
|
||||
gchar *soundfont_path = g_build_path ("/", sharedirs[i], SOUNDFONT_PATH,
|
||||
NULL);
|
||||
shared_dirs_count += 1;
|
||||
GST_DEBUG_OBJECT (fluiddec, "Trying to list contents of a %s directory",
|
||||
soundfont_path);
|
||||
error = NULL;
|
||||
dir = g_dir_open (soundfont_path, 0, &error);
|
||||
if (dir == NULL) {
|
||||
GST_DEBUG_OBJECT (fluiddec, "Can't open a potential soundfont directory %s: %s",
|
||||
soundfont_path, error->message);
|
||||
g_free (soundfont_path);
|
||||
g_error_free (error);
|
||||
shared_dirs_failed += 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
while (TRUE) {
|
||||
const gchar *name;
|
||||
gchar *filename;
|
||||
|
||||
if ((name = g_dir_read_name (dir)) == NULL)
|
||||
break;
|
||||
|
||||
filename = g_build_filename (soundfont_path, name, NULL);
|
||||
|
||||
GST_DEBUG_OBJECT (fluiddec, "loading soundfont file %s", filename);
|
||||
fluiddec->sf = fluid_synth_sfload (fluiddec->synth, filename, 1);
|
||||
if (fluiddec->sf != -1) {
|
||||
GST_DEBUG_OBJECT (fluiddec, "loaded soundfont file %s", filename);
|
||||
break;
|
||||
for (j = 0; paths[j]; j++) {
|
||||
gchar *soundfont_path = g_build_path ("/", sharedirs[i], paths[j],
|
||||
NULL);
|
||||
GST_DEBUG_OBJECT (fluiddec, "Trying to list contents of a %s directory",
|
||||
soundfont_path);
|
||||
error = NULL;
|
||||
dir = g_dir_open (soundfont_path, 0, &error);
|
||||
if (dir == NULL) {
|
||||
GST_DEBUG_OBJECT (fluiddec,
|
||||
"Can't open a potential soundfont directory %s: %s",
|
||||
soundfont_path, error->message);
|
||||
g_free (soundfont_path);
|
||||
g_error_free (error);
|
||||
continue;
|
||||
}
|
||||
GST_DEBUG_OBJECT (fluiddec, "could not load soundfont file %s", filename);
|
||||
|
||||
while (TRUE) {
|
||||
const gchar *name;
|
||||
gchar *filename;
|
||||
|
||||
if ((name = g_dir_read_name (dir)) == NULL)
|
||||
break;
|
||||
|
||||
filename = g_build_filename (soundfont_path, name, NULL);
|
||||
|
||||
GST_DEBUG_OBJECT (fluiddec, "loading soundfont file %s", filename);
|
||||
fluiddec->sf = fluid_synth_sfload (fluiddec->synth, filename, 1);
|
||||
if (fluiddec->sf != -1) {
|
||||
GST_DEBUG_OBJECT (fluiddec, "loaded soundfont file %s", filename);
|
||||
goto done;
|
||||
}
|
||||
GST_DEBUG_OBJECT (fluiddec, "could not load soundfont file %s",
|
||||
filename);
|
||||
}
|
||||
g_dir_close (dir);
|
||||
g_free (soundfont_path);
|
||||
}
|
||||
g_dir_close (dir);
|
||||
g_free (soundfont_path);
|
||||
}
|
||||
if (fluiddec->sf == -1) {
|
||||
if (shared_dirs_count == shared_dirs_failed)
|
||||
goto open_dir_failed;
|
||||
goto no_soundfont;
|
||||
}
|
||||
}
|
||||
done:
|
||||
return TRUE;
|
||||
|
||||
/* ERRORS */
|
||||
|
@ -582,20 +581,11 @@ load_failed:
|
|||
("failed to open soundfont file %s for reading", fluiddec->soundfont));
|
||||
return FALSE;
|
||||
}
|
||||
open_dir_failed:
|
||||
{
|
||||
GST_ELEMENT_ERROR (fluiddec, RESOURCE, OPEN_READ,
|
||||
("No path in the XDG_DATA_DIRS pathlist has a %s subdirectory that can be opened",
|
||||
SOUNDFONT_PATH),
|
||||
("failed to open subdirectory %s in each of the directories in XDG_DATA_DIRS pathlist",
|
||||
SOUNDFONT_PATH));
|
||||
return FALSE;
|
||||
}
|
||||
no_soundfont:
|
||||
{
|
||||
GST_ELEMENT_ERROR (fluiddec, RESOURCE, OPEN_READ,
|
||||
("Can't find a soundfont file in subdirectory %s of XDG_DATA_DIRS paths", SOUNDFONT_PATH),
|
||||
("no usable soundfont files found in %s subdirectories of XDG_DATA_DIRS", SOUNDFONT_PATH));
|
||||
("Can't find a soundfont file in subdirectories of XDG_DATA_DIRS paths"),
|
||||
("no usable soundfont files found in subdirectories of XDG_DATA_DIRS"));
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue