[vlc-commits] fluidsynth: deal with glob() error cases correctly (and add debug)

Rémi Denis-Courmont git at videolan.org
Wed Jan 18 18:06:11 CET 2012


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Wed Jan 18 19:05:15 2012 +0200| [85488575ba5f5fe93738b73df5dc9e9d3351c8d3] | committer: 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.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=85488575ba5f5fe93738b73df5dc9e9d3351c8d3
---

 modules/codec/fluidsynth.c |   22 +++++++++++-----------
 1 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/modules/codec/fluidsynth.c b/modules/codec/fluidsynth.c
index 7c3ee9b..3228555 100644
--- a/modules/codec/fluidsynth.c
+++ b/modules/codec/fluidsynth.c
@@ -105,6 +105,7 @@ static int Open (vlc_object_t *p_this)
     {
         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);
         LocaleFree (lpath);
         if (p_sys->soundfont == -1)
@@ -116,19 +117,18 @@ static int Open (vlc_object_t *p_this)
     {
         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];
-
-                p_sys->soundfont = fluid_synth_sfload (p_sys->synth, path, 1);
-                if (p_sys->soundfont != -1)
-                    break; /* it worked! */
-                msg_Err (p_this, "cannot load sound fonts file %s", path);
-            }
-            globfree (&gl);
+            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);
+            if (p_sys->soundfont != -1)
+                break; /* it worked! */
+            msg_Err (p_this, "cannot load sound fonts file %s", path);
         }
+        globfree (&gl);
     }
 #endif
 



More information about the vlc-commits mailing list