shithub: sox

Download patch

ref: a1b0c9fb99683b7de9a9eddebd4b3792292186b3
parent: 4d1745ba29c8404b5eb4a37be300528c47b3407d
author: Chris Bagwell <chris@cnpbagwell.com>
date: Tue Dec 27 09:42:56 EST 2011

Make libsndfile-1.0.12 the minimum supported.

Allows to remove some conditional checks.

--- a/ChangeLog
+++ b/ChangeLog
@@ -21,6 +21,7 @@
   14.1.0   E resample alias        rate
   14.1.0   E polyphase alias       rate
   14.1.0   E rabbit alias          rate
+  14.3.1   F sndfile: sndfile 1.0.11 sndfile > 1.0.11
 
 Previously deprecated features (to be removed in future):
 
@@ -28,7 +29,6 @@
   ated in  [F(ormat)] [E(ffect)]   Replacement             due after
   -------  ----------------------  ----------------------  -------
   14.3.1   F mp3: lame 3.97        lame > 3.97             14.3.2
-  14.3.1   F sndfile: sndfile 1.0.11 sndfile > 1.0.11      14.3.1
   14.3.0   F flac: libFLAC 1.1.2,3 libFLAC > 1.1.3         14.3.1
   14.3.0   O -1/-2/-3/-4/-8        -b                      14.4.0
   14.3.0   O -s/-u/-f              -e                      14.4.0
--- a/m4/sndfile.m4
+++ b/m4/sndfile.m4
@@ -49,13 +49,11 @@
   LIBS="$LIBS $SNDFILE_LIBS"
   AC_CHECK_HEADER([sndfile.h], [
     AC_DEFINE([HAVE_SNDFILE_H], 1, [Define if you have <sndfile.h>])
-    AC_CHECK_FUNC([sf_open], [
+    AC_CHECK_FUNC([sf_open_virtual], [
       ifelse([$1], , :, [$1])
       have_sndfile="yes"
     ])
-    AC_CHECK_FUNC([sf_open_virtual], AC_DEFINE([HAVE_SNDFILE_1_0_12], 1, [Define if you have libsndfile >= 1.0.12]))
     AC_CHECK_DECL([SF_FORMAT_OGG], AC_DEFINE([HAVE_SNDFILE_1_0_18], 1, [Define if you have libsndfile >= 1.0.18]),, [#include <sndfile.h>])
-    AC_CHECK_DECL([SFC_SET_SCALE_FLOAT_INT_READ], AC_DEFINE([HAVE_SFC_SET_SCALE_FLOAT_INT_READ], 1, [Define if you have libsndfile with SFC_SET_SCALE_FLOAT_INT_READ]),, [#include <sndfile.h>])
     AC_CHECK_DECL([SFC_SET_SCALE_INT_FLOAT_WRITE], AC_DEFINE([HAVE_SFC_SET_SCALE_INT_FLOAT_WRITE], 1, [Define if you have libsndfile with SFC_SFC_SET_SCALE_INT_FLOAT_WRITE]),, [#include <sndfile.h>])
   ])
   CFLAGS="$ac_save_CFLAGS"
--- a/src/sndfile.c
+++ b/src/sndfile.c
@@ -30,7 +30,7 @@
 
 #define LOG_MAX 2048 /* As per the SFC_GET_LOG_INFO example */
 
-#if !defined(HAVE_LIBLTDL) || !defined(HAVE_SNDFILE_1_0_12)
+#if !defined(HAVE_LIBLTDL)
 #undef DL_SNDFILE
 #endif
 
@@ -56,12 +56,8 @@
 #endif
 #endif /* DL_SNDFILE */
 
-#ifdef HAVE_SNDFILE_1_0_12
 #define SNDFILE_FUNC_OPEN(f,x) \
   SNDFILE_FUNC(f,x, SNDFILE*, sf_open_virtual, (SF_VIRTUAL_IO *sfvirtual, int mode, SF_INFO *sfinfo, void *user_data))
-#else
-  SNDFILE_FUNC(f,x, SNDFILE*, sf_open_fd, (int fd, int mode, SF_INFO *sfinfo, int close_desc))
-#endif
 
 #define SNDFILE_FUNC_ENTRIES(f,x) \
   SNDFILE_FUNC_OPEN(f,x) \
@@ -133,12 +129,10 @@
   if (e == SOX_ENCODING_DWVW      && size == 24) return SF_FORMAT_DWVW_24;
   if (e == SOX_ENCODING_DWVWN     && size ==  0) return SF_FORMAT_DWVW_N;
   if (e == SOX_ENCODING_GSM       && size ==  0) return SF_FORMAT_GSM610;
-#ifdef HAVE_SNDFILE_1_0_12
   if (e == SOX_ENCODING_FLAC      && size ==  8) return SF_FORMAT_PCM_S8;
   if (e == SOX_ENCODING_FLAC      && size == 16) return SF_FORMAT_PCM_16;
   if (e == SOX_ENCODING_FLAC      && size == 24) return SF_FORMAT_PCM_24;
   if (e == SOX_ENCODING_FLAC      && size == 32) return SF_FORMAT_PCM_32;
-#endif
   return 0; /* Bad encoding */
 }
 
@@ -148,13 +142,11 @@
   int sub = ft_encoding & SF_FORMAT_SUBMASK;
   int type = ft_encoding & SF_FORMAT_TYPEMASK;
 
-#ifdef HAVE_SNDFILE_1_0_12
   if (type == SF_FORMAT_FLAC) switch (sub) {
     case SF_FORMAT_PCM_S8   : *size =  8; return SOX_ENCODING_FLAC;
     case SF_FORMAT_PCM_16   : *size = 16; return SOX_ENCODING_FLAC;
     case SF_FORMAT_PCM_24   : *size = 24; return SOX_ENCODING_FLAC;
   }
-#endif
   switch (sub) {
     case SF_FORMAT_ULAW     : *size =  8; return SOX_ENCODING_ULAW;
     case SF_FORMAT_ALAW     : *size =  8; return SOX_ENCODING_ALAW;
@@ -192,10 +184,8 @@
   { "wav",      SF_FORMAT_WAV },
   { "au",       SF_FORMAT_AU },
   { "snd",      SF_FORMAT_AU },
-#ifdef HAVE_SNDFILE_1_0_12
   { "caf",      SF_FORMAT_CAF },
   { "flac",     SF_FORMAT_FLAC },
-#endif
 #ifdef HAVE_SNDFILE_1_0_18
   { "wve",      SF_FORMAT_WVE },
   { "ogg",      SF_FORMAT_OGG },
@@ -227,8 +217,6 @@
     return 1;
 }
 
-#ifdef HAVE_SNDFILE_1_0_12
-
 static sf_count_t vio_get_filelen(void *user_data)
 {
   sox_format_t *ft = (sox_format_t *)user_data;
@@ -268,8 +256,6 @@
     vio_tell
 };
 
-#endif /* HAVE_SNDFILE_1_0_12 */
-
 /* Convert file name or type to libsndfile format */
 static int name_to_format(const char *name)
 {
@@ -370,12 +356,7 @@
   if (start(ft) == SOX_EOF)
       return SOX_EOF;
 
-#ifdef HAVE_SNDFILE_1_0_12
   sf->sf_file = sf->sf_open_virtual(&vio, SFM_READ, sf->sf_info, ft);
-#else
-  sf->sf_file = sf->sf_open_fd(fileno(ft->fp), SFM_READ, sf->sf_info, 1);
-  ft->fp = NULL; /* Transfer ownership of fp to LSF */
-#endif
   drain_log_buffer(ft);
 
   if (sf->sf_file == NULL) {
@@ -397,12 +378,10 @@
   }
   else rate = sf->sf_info->samplerate;
 
-#ifdef HAVE_SFC_SET_SCALE_FLOAT_INT_READ
   if ((sf->sf_info->format & SF_FORMAT_SUBMASK) == SF_FORMAT_FLOAT) {
     sf->sf_command(sf->sf_file, SFC_SET_SCALE_FLOAT_INT_READ, NULL, SF_TRUE);
     sf->sf_command(sf->sf_file, SFC_SET_CLIPPING, NULL, SF_TRUE);
   }
-#endif
 
 #if 0 /* FIXME */
     sox_append_comments(&ft->oob.comments, buf);
@@ -468,12 +447,7 @@
       lsx_warn("cannot use desired output encoding, choosing default");
   }
 
-#ifdef HAVE_SNDFILE_1_0_12
   sf->sf_file = sf->sf_open_virtual(&vio, SFM_WRITE, sf->sf_info, ft);
-#else
-  sf->sf_file = sf->sf_open_fd(fileno(ft->fp), SFM_WRITE, sf->sf_info, 1);
-  ft->fp = NULL; /* Transfer ownership of fp to LSF */
-#endif
   drain_log_buffer(ft);
 
   if (sf->sf_file == NULL) {
@@ -487,7 +461,7 @@
   if ((sf->sf_info->format & SF_FORMAT_SUBMASK) == SF_FORMAT_FLOAT)
     sf->sf_command(sf->sf_file, SFC_SET_SCALE_INT_FLOAT_WRITE, NULL, SF_TRUE);
 #endif
-           
+
   return SOX_SUCCESS;
 }