shithub: sox

Download patch

ref: e2f6fd3c004cf2f3e75d91828acc6ff479108d83
parent: 222ca19dc1716f5bd864aa7e5aa82d3c0b91ed33
author: robs <robs>
date: Sat Feb 7 05:34:50 EST 2009

formats' handler fns --> lsx_

--- a/src/effects.c
+++ b/src/effects.c
@@ -458,7 +458,7 @@
   chain->length = 0;
 }
 
-/* Effects library: */
+/*----------------------------- Effects library ------------------------------*/
 
 sox_effect_fn_t sox_effect_fns[] = {
 #define EFFECT(f) lsx_##f##_effect_fn,
--- a/src/formats.c
+++ b/src/formats.c
@@ -1002,9 +1002,29 @@
   return result;
 }
 
+/*----------------------------- Formats library ------------------------------*/
+
 #ifdef HAVE_LIBLTDL /* Plugin format handlers */
+#define sox_format_fns sox_format_fns0
+#endif
 
+#ifndef HAVE_LIBLTDL
+#define FORMAT(f) extern sox_format_handler_t const * lsx_##f##_format_fn(void);
+#include "formats.h"
+#undef FORMAT
+
+sox_format_tab_t sox_format_fns[] = {
+  #define FORMAT(f) {NULL, lsx_##f##_format_fn},
+  #include "formats.h"
+  #undef FORMAT
+  {NULL, NULL}
+};
+#endif
+
+#ifdef HAVE_LIBLTDL
+
 #include <ltdl.h>
+#undef sox_format_fns
 #define MAX_FORMATS 256 /* FIXME: Use a vector, not a fixed-size array */
 #define MAX_NAME_LEN (size_t)1024 /* FIXME: Use vasprintf */
 
@@ -1024,7 +1044,7 @@
 
   (void)data;
   if (start && (start += sizeof(prefix) - 1) < end) {
-    int ret = snprintf(fnname, MAX_NAME_LEN, "sox_%.*s_format_fn", (int)(end - start), start);
+    int ret = snprintf(fnname, MAX_NAME_LEN, "lsx_%.*s_format_fn", (int)(end - start), start);
     if (ret > 0 && ret < (int)MAX_NAME_LEN) {
       union {sox_format_fn_t fn; lt_ptr ptr;} ltptr;
       ltptr.ptr = lt_dlsym(lth, fnname);
@@ -1038,10 +1058,15 @@
 
 int sox_format_init(void) /* Find & load format handlers.  */
 {
-  sox_format_handler_t const * sox_sox_format_fn(void);
+  sox_format_handler_t const * lsx_sox_format_fn(void);
   int ret;
 
-  sox_format_fns[nformats++].fn = sox_sox_format_fn;
+#if 0
+  nformats = array_length(sox_format_fns0) - 1;
+  memcpy(sox_format_fns, sox_format_fns0, nformats * sizeof(sox_format_fns[0]));
+#else
+  sox_format_fns[nformats++].fn = lsx_sox_format_fn;
+#endif 
 
   if ((ret = lt_dlinit()) != 0) {
     lsx_fail("lt_dlinit failed with %d error(s): %s", ret, lt_dlerror());
@@ -1061,17 +1086,6 @@
 }
 
 #else /* Static format handlers */
-
-#define FORMAT(f) extern sox_format_handler_t const * lsx_##f##_format_fn(void);
-#include "formats.h"
-#undef FORMAT
-
-sox_format_tab_t sox_format_fns[] = {
-  #define FORMAT(f) {NULL, lsx_##f##_format_fn},
-  #include "formats.h"
-  #undef FORMAT
-  {NULL, NULL}
-};
 
 int sox_format_init(void) {return SOX_SUCCESS;}
 void sox_format_quit(void) {}
--- a/src/formats.h
+++ b/src/formats.h
@@ -1,4 +1,4 @@
-/* libSoX static formats list   (c) 2006-8 Chris Bagwell and SoX contributors
+/* libSoX static formats list   (c) 2006-9 Chris Bagwell and SoX contributors
  *
  * This library is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Lesser General Public License as published by
@@ -15,8 +15,6 @@
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-/* FIXME: generate this list automatically */
-
   FORMAT(aifc)
   FORMAT(aiff)
   FORMAT(al)
@@ -63,6 +61,8 @@
   FORMAT(wve)
   FORMAT(xa)
 
+#ifndef HAVE_LIBLTDL /* Plugin format handlers */
+
 #if defined HAVE_ALSA
   FORMAT(alsa)
 #endif
@@ -115,4 +115,6 @@
 #endif
 #if defined HAVE_WAVPACK
   FORMAT(wavpack)
+#endif
+
 #endif