Commit cab29ad8 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

fluidsynth: deal with glob() error cases correctly (and add debug)

glob() sets the result structure also in case of error. The results
may be incomplete.
(cherry picked from commit 85488575ba5f5fe93738b73df5dc9e9d3351c8d3)
parent 4dbb8157
...@@ -105,6 +105,7 @@ static int Open (vlc_object_t *p_this) ...@@ -105,6 +105,7 @@ static int Open (vlc_object_t *p_this)
{ {
const char *lpath = ToLocale (font_path); const char *lpath = ToLocale (font_path);
msg_Dbg (p_this, "loading sound fonts file %s", font_path);
p_sys->soundfont = fluid_synth_sfload (p_sys->synth, font_path, 1); p_sys->soundfont = fluid_synth_sfload (p_sys->synth, font_path, 1);
LocaleFree (lpath); LocaleFree (lpath);
if (p_sys->soundfont == -1) if (p_sys->soundfont == -1)
...@@ -116,19 +117,18 @@ static int Open (vlc_object_t *p_this) ...@@ -116,19 +117,18 @@ static int Open (vlc_object_t *p_this)
{ {
glob_t gl; glob_t gl;
if (!glob ("/usr/share/sounds/sf2/*.sf2", GLOB_NOESCAPE, NULL, &gl)) glob ("/usr/share/sounds/sf2/*.sf2", GLOB_NOESCAPE, NULL, &gl);
for (size_t i = 0; i < gl.gl_pathc; i++)
{ {
for (size_t i = 0; i < gl.gl_pathc; i++) const char *path = gl.gl_pathv[i];
{
const char *path = gl.gl_pathv[i]; msg_Dbg (p_this, "loading sound fonts file %s", path);
p_sys->soundfont = fluid_synth_sfload (p_sys->synth, path, 1);
p_sys->soundfont = fluid_synth_sfload (p_sys->synth, path, 1); if (p_sys->soundfont != -1)
if (p_sys->soundfont != -1) break; /* it worked! */
break; /* it worked! */ msg_Err (p_this, "cannot load sound fonts file %s", path);
msg_Err (p_this, "cannot load sound fonts file %s", path);
}
globfree (&gl);
} }
globfree (&gl);
} }
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment