shithub: sox

Download patch

ref: 2c31c161e39b25569893e35ff0952ecabcede8b6
parent: c0a280c1b09a710b325c18a9ade16b15047c7bfe
author: robs <robs>
date: Tue Dec 9 14:33:09 EST 2008

gomp

--- a/configure.ac
+++ b/configure.ac
@@ -180,6 +180,23 @@
 fi
 AC_SUBST(LIBTOOLFLAGS)
    
+dnl Check for GOMP
+AC_MSG_CHECKING([whether to use GOMP])
+AC_ARG_ENABLE(gomp,
+    AC_HELP_STRING([--disable-gomp], [Don't use GOMP.]),,enable_gomp=yes)
+AC_MSG_RESULT($enable_gomp)
+if test "$enable_gomp" = "yes"; then
+    AC_CHECK_HEADERS(omp.h,
+        AC_CHECK_LIB(gomp, omp_get_thread_num, GOMP_LIBS="$GOMP_LIBS -lgomp", enable_gomp=no),
+        enable_gomp=no)
+fi
+if test "$enable_gomp" = yes; then
+   AC_DEFINE(HAVE_GOMP, 1, [Define to 1 if you have GOMP.])
+   CFLAGS="$CFLAGS -fopenmp"
+fi
+AM_CONDITIONAL(HAVE_GOMP, test x$enable_gomp = xyes)
+AC_SUBST(GOMP_LIBS)
+
 audio_driver_found=no  
     
 dnl Check for ALSA
@@ -629,6 +646,7 @@
 echo "Distro name ...................... $DISTRO"
 echo "Debugging build................... $enable_debug"
 echo "External module support........... $using_libltdl"
+echo "GOMP support...................... $enable_gomp"
 echo "ALSA driver....................... $enable_alsa"
 echo "libao driver...................... $enable_libao"
 echo "OSS driver........................ $enable_oss"
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -14,6 +14,8 @@
     add_definitions(-Wtraditional-conversion)
   endif(${ver} LESS 403)
   add_definitions(-Werror)
+  add_definitions(-fopenmp)
+  set(optional_libs ${optional_libs} gomp)
 endif(CMAKE_COMPILER_IS_GNUCC)
 
 if (NOT EXTERNAL_GSM)
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -284,6 +284,9 @@
 if HAVE_MAGIC
 libsox_la_LIBADD += @MAGIC_LIBS@
 endif
+if HAVE_GOMP
+libsox_la_LIBADD += @GOMP_LIBS@
+endif
 
 libsox_la_CFLAGS = @WARN_CFLAGS@  @SAMPLERATE_CFLAGS@
 libsox_la_LDFLAGS = @APP_LDFLAGS@ -version-info @SHLIB_VERSION@
@@ -300,7 +303,6 @@
     ima_rw.c ima_rw.h wav.c wve.c xa.c nulfile.c f4-fmt.c f8-fmt.c
 libsox_la_LIBADD += @GSM_LIBS@ @LIBGSM_LIBADD@
 libsox_la_LIBADD += @LPC10_LIBS@ @LIBLPC10_LIBADD@
-
 
 sox_LDADD += @GSM_LIBS@ @LIBGSM_LIBADD@
 sox_LDADD += @LPC10_LIBS@ @LIBLPC10_LIBADD@
--- a/src/effects.c
+++ b/src/effects.c
@@ -196,8 +196,8 @@
 {
   sox_effect_t * effp1 = &chain->effects[n - 1][0];
   sox_effect_t * effp = &chain->effects[n][0];
-  int effstatus = SOX_SUCCESS;
-  size_t i, f;
+  int effstatus = SOX_SUCCESS, f;
+  size_t i;
   const sox_sample_t *ibuf;
   size_t idone = effp1->oend - effp1->obeg;
   size_t obeg = sox_globals.bufsiz - effp->oend;
@@ -215,10 +215,11 @@
 
     ibuf = &effp1->obuf[effp1->obeg];
     for (i = 0; i < idone; i += effp->flows)
-      for (f = 0; f < effp->flows; ++f)
+      for (f = 0; f < (int)effp->flows; ++f)
         chain->ibufc[f][i / effp->flows] = *ibuf++;
 
-    for (f = 0; f < effp->flows; ++f) {
+    #pragma omp parallel for
+    for (f = 0; f < (int)effp->flows; ++f) {
       size_t idonec = idone / effp->flows;
       size_t odonec = obeg / effp->flows;
       int eff_status_c = effp->handler.flow(&chain->effects[n][f],
@@ -235,7 +236,7 @@
     }
 
     for (i = 0; i < odone_last; ++i)
-      for (f = 0; f < effp->flows; ++f)
+      for (f = 0; f < (int)effp->flows; ++f)
         *obuf++ = chain->obufc[f][i];
 
     idone = f * idone_last;