shithub: sox

Download patch

ref: cca5c5acce39dac0bb25cd0b2585bc3a59d01f8c
parent: 2e752dcefa76dc4636322bdf9a497a5af0a32ccb
author: cbagwell <cbagwell>
date: Mon Dec 30 20:08:48 EST 2002

Bugfixes in configure, and -c option.  Changed vorbis to use VBR.

--- a/Changelog
+++ b/Changelog
@@ -36,6 +36,13 @@
     for System/Alarms in some Psion devices.
   o Richard Bannister sent in a patch to make writing vorbis files
     work with Vorbis 1.0 libraries.
+  o Fixed configure scripts so that they can be ran with the
+    --with-oss-dsp, --with-alsa, and --with-sun-audio options.
+    Was causing compile time problems.  Reported by Raul Coronado.
+  o Change Ogg Vorbis support to use VBR encoding to match defaults
+    of oggenc based on suggestion from Christian Weisgerber.
+  o Prints error message now when a channel value of -1 is given.
+    Reported by Pierre Fortin.
 
 sox-12.17.3
 -----------
--- a/configure
+++ b/configure
@@ -836,9 +836,9 @@
 Optional Packages:
   --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
   --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
-  --with-alsa-dsp         Force support for /dev/snd/pcmABXY (ALSA)
-  --with-oss-dsp          Force support for /dev/dsp (OSS)
-  --with-sun-audio        Force support for /dev/audio (SUN, etc)
+  --without-alsa-dsp      Disable detection of /dev/snd/pcmABXY (ALSA)
+  --without-oss-dsp       Disable detection of /dev/dsp (OSS)
+  --without-sun-audio     Disable detection of /dev/audio (SUN, etc)
   --with-ogg-vorbislib    Location of Ogg Vorbis libraries (=dir)
   --with-ogg-vorbisinc    Location of Ogg Vorbis headers (=dir)
   --with-madlib    Location of MAD (MP3 Audio Decoder) libraries (=dir)
@@ -4241,241 +4241,14 @@
 
 
 
-if test "$alsa_dsp" = auto
+if test "$alsa_dsp" = yes
 then
-
-for ac_header in linux/asound.h
-do
-as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
-if eval "test \"\${$as_ac_Header+set}\" = set"; then
-  echo "$as_me:$LINENO: checking for $ac_header" >&5
-echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
-if eval "test \"\${$as_ac_Header+set}\" = set"; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
+	alsa_type=alsa9
 fi
-echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
-else
-  # Is the header compilable?
-echo "$as_me:$LINENO: checking $ac_header usability" >&5
-echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6
-cat >conftest.$ac_ext <<_ACEOF
-#line $LINENO "configure"
-#include "confdefs.h"
-$ac_includes_default
-#include <$ac_header>
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_header_compiler=yes
-else
-  echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-ac_header_compiler=no
-fi
-rm -f conftest.$ac_objext conftest.$ac_ext
-echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
-echo "${ECHO_T}$ac_header_compiler" >&6
 
-# Is the header present?
-echo "$as_me:$LINENO: checking $ac_header presence" >&5
-echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6
-cat >conftest.$ac_ext <<_ACEOF
-#line $LINENO "configure"
-#include "confdefs.h"
-#include <$ac_header>
-_ACEOF
-if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
-  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
-  ac_status=$?
-  egrep -v '^ *\+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } >/dev/null; then
-  if test -s conftest.err; then
-    ac_cpp_err=$ac_c_preproc_warn_flag
-  else
-    ac_cpp_err=
-  fi
-else
-  ac_cpp_err=yes
-fi
-if test -z "$ac_cpp_err"; then
-  ac_header_preproc=yes
-else
-  echo "$as_me: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  ac_header_preproc=no
-fi
-rm -f conftest.err conftest.$ac_ext
-echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
-echo "${ECHO_T}$ac_header_preproc" >&6
-
-# So?  What about this header?
-case $ac_header_compiler:$ac_header_preproc in
-  yes:no )
-    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
-echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
-    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
-echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;};;
-  no:yes )
-    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
-echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
-    { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
-echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
-    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
-echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;};;
-esac
-echo "$as_me:$LINENO: checking for $ac_header" >&5
-echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
-if eval "test \"\${$as_ac_Header+set}\" = set"; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  eval "$as_ac_Header=$ac_header_preproc"
-fi
-echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
-
-fi
-if test `eval echo '${'$as_ac_Header'}'` = yes; then
-  cat >>confdefs.h <<_ACEOF
-#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
-_ACEOF
- alsa_dsp=check_ioctl
-fi
-
-done
-
-
-for ac_header in sound/asound.h
-do
-as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
-if eval "test \"\${$as_ac_Header+set}\" = set"; then
-  echo "$as_me:$LINENO: checking for $ac_header" >&5
-echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
-if eval "test \"\${$as_ac_Header+set}\" = set"; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-fi
-echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
-else
-  # Is the header compilable?
-echo "$as_me:$LINENO: checking $ac_header usability" >&5
-echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6
-cat >conftest.$ac_ext <<_ACEOF
-#line $LINENO "configure"
-#include "confdefs.h"
-$ac_includes_default
-#include <$ac_header>
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_header_compiler=yes
-else
-  echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-ac_header_compiler=no
-fi
-rm -f conftest.$ac_objext conftest.$ac_ext
-echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
-echo "${ECHO_T}$ac_header_compiler" >&6
-
-# Is the header present?
-echo "$as_me:$LINENO: checking $ac_header presence" >&5
-echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6
-cat >conftest.$ac_ext <<_ACEOF
-#line $LINENO "configure"
-#include "confdefs.h"
-#include <$ac_header>
-_ACEOF
-if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
-  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
-  ac_status=$?
-  egrep -v '^ *\+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } >/dev/null; then
-  if test -s conftest.err; then
-    ac_cpp_err=$ac_c_preproc_warn_flag
-  else
-    ac_cpp_err=
-  fi
-else
-  ac_cpp_err=yes
-fi
-if test -z "$ac_cpp_err"; then
-  ac_header_preproc=yes
-else
-  echo "$as_me: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  ac_header_preproc=no
-fi
-rm -f conftest.err conftest.$ac_ext
-echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
-echo "${ECHO_T}$ac_header_preproc" >&6
-
-# So?  What about this header?
-case $ac_header_compiler:$ac_header_preproc in
-  yes:no )
-    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
-echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
-    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
-echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;};;
-  no:yes )
-    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
-echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
-    { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
-echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
-    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
-echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;};;
-esac
-echo "$as_me:$LINENO: checking for $ac_header" >&5
-echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
-if eval "test \"\${$as_ac_Header+set}\" = set"; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  eval "$as_ac_Header=$ac_header_preproc"
-fi
-echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
-
-fi
-if test `eval echo '${'$as_ac_Header'}'` = yes; then
-  cat >>confdefs.h <<_ACEOF
-#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
-_ACEOF
- alsa_dsp=alsa9
-fi
-
-done
-
-fi
-
 echo "$as_me:$LINENO: checking for ALSA ioctl API" >&5
 echo $ECHO_N "checking for ALSA ioctl API... $ECHO_C" >&6
-if test "$alsa_dsp" = check_ioctl
+if test "$alsa_type" = check_ioctl
 then
 	cat >conftest.$ac_ext <<_ACEOF
 #line $LINENO "configure"
@@ -4511,16 +4284,16 @@
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  alsa_dsp=alsa4
+  alsa_type=alsa4
 else
   echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
-alsa_dsp=alsa5
+alsa_type=alsa5
 fi
 rm -f conftest.$ac_objext conftest.$ac_ext
 fi
 
-if test "$alsa_dsp" = alsa9
+if test "$alsa_type" = alsa9
 then
 	CFLAGS="$CFLAGS -DALSA_PLAYER -DUSE_ALSA9"
 	NEED_ALSA=1
@@ -4527,7 +4300,7 @@
 	PLAY_SUPPORT=1
 	echo "$as_me:$LINENO: result: 0.9.X" >&5
 echo "${ECHO_T}0.9.X" >&6
-elif test "$alsa_dsp" = alsa5
+elif test "$alsa_type" = alsa5
 then
 	CFLAGS="$CFLAGS -DALSA_PLAYER -DUSE_ALSA5"
 	NEED_ALSA=1
@@ -4534,7 +4307,7 @@
 	PLAY_SUPPORT=1
 	echo "$as_me:$LINENO: result: 0.5.X" >&5
 echo "${ECHO_T}0.5.X" >&6
-elif test "$alsa_dsp" = alsa4
+elif test "$alsa_type" = alsa4
 then
 	CFLAGS="$CFLAGS -DALSA_PLAYER -DUSE_ALSA4"
 	NEED_ALSA=1
@@ -4546,8 +4319,6 @@
 echo "${ECHO_T}not found" >&6
 fi
 
-if test "$oss_dsp" = auto
-then
 
 
 for ac_header in sys/soundcard.h machine/soundcard.h
@@ -4663,7 +4434,6 @@
 
 done
 
-fi
 
 if test "$oss_dsp" = yes
 then
@@ -4672,8 +4442,6 @@
 	PLAY_SUPPORT=1
 fi
 
-if test "$sun_audio" = auto
-then
 
 
 for ac_header in sys/audioio.h sun/audioio.h
@@ -4789,7 +4557,6 @@
 
 done
 
-fi
 
 if test "$sun_audio" = yes
 then
--- a/configure.in
+++ b/configure.in
@@ -25,17 +25,17 @@
 	enable_gsm=$enableval, enable_gsm=yes)
 
 AC_ARG_WITH(alsa_dsp,
-	[  --with-alsa-dsp         Force support for /dev/snd/pcmABXY (ALSA)],
+	[  --without-alsa-dsp      Disable detection of /dev/snd/pcmABXY (ALSA)],
 	[alsa_dsp="$withval"],
 	[alsa_dsp=auto])
 
 AC_ARG_WITH(oss_dsp,
-	[  --with-oss-dsp          Force support for /dev/dsp (OSS)],
+	[  --without-oss-dsp       Disable detection of /dev/dsp (OSS)],
 	[oss_dsp="$withval"],
 	[oss_dsp=auto])
 
 AC_ARG_WITH(sun_audio,
-	[  --with-sun-audio        Force support for /dev/audio (SUN, etc)],
+	[  --without-sun-audio     Disable detection of /dev/audio (SUN, etc)],
 	[sun_audio="$withval"],
 	[sun_audio=auto])
 
@@ -217,14 +217,13 @@
 
 dnl Checks for system services.
 
-if test "$alsa_dsp" = auto
+if test "$alsa_dsp" = yes
 then
-	AC_CHECK_HEADERS(linux/asound.h, alsa_dsp=check_ioctl)
-	AC_CHECK_HEADERS(sound/asound.h, alsa_dsp=alsa9)
+	alsa_type=alsa9
 fi
 
 AC_MSG_CHECKING([for ALSA ioctl API])
-if test "$alsa_dsp" = check_ioctl
+if test "$alsa_type" = check_ioctl
 then
 	AC_TRY_COMPILE(
 [
@@ -233,22 +232,22 @@
 [
 snd_pcm_capture_info_t c_info;
 ],
-		alsa_dsp=alsa4,alsa_dsp=alsa5)
+		alsa_type=alsa4,alsa_type=alsa5)
 fi
 
-if test "$alsa_dsp" = alsa9
+if test "$alsa_type" = alsa9
 then
 	CFLAGS="$CFLAGS -DALSA_PLAYER -DUSE_ALSA9"
 	NEED_ALSA=1
 	PLAY_SUPPORT=1
 	AC_MSG_RESULT([0.9.X])
-elif test "$alsa_dsp" = alsa5
+elif test "$alsa_type" = alsa5
 then
 	CFLAGS="$CFLAGS -DALSA_PLAYER -DUSE_ALSA5"
 	NEED_ALSA=1
 	PLAY_SUPPORT=1
 	AC_MSG_RESULT([0.5.X])
-elif test "$alsa_dsp" = alsa4
+elif test "$alsa_type" = alsa4
 then
 	CFLAGS="$CFLAGS -DALSA_PLAYER -DUSE_ALSA4"
 	NEED_ALSA=1
@@ -258,10 +257,7 @@
 	AC_MSG_RESULT([not found])
 fi
 
-if test "$oss_dsp" = auto
-then
-	AC_CHECK_HEADERS(sys/soundcard.h machine/soundcard.h, oss_dsp=yes)
-fi
+AC_CHECK_HEADERS(sys/soundcard.h machine/soundcard.h, oss_dsp=yes)
 
 if test "$oss_dsp" = yes
 then
@@ -270,10 +266,7 @@
 	PLAY_SUPPORT=1
 fi
 
-if test "$sun_audio" = auto
-then
-	AC_CHECK_HEADERS(sys/audioio.h sun/audioio.h, sun_audio=yes)
-fi
+AC_CHECK_HEADERS(sys/audioio.h sun/audioio.h, sun_audio=yes)
 
 if test "$sun_audio" = yes
 then
--- a/src/sndrtool.c
+++ b/src/sndrtool.c
@@ -240,7 +240,7 @@
 st_writew (ft,10);
 st_writew (ft,4);
 memset (name_buf, 0, 96);
-sprintf (name_buf,"%s - File created by Sound Exchange",ft->filename);
+sprintf (name_buf,"%.62s - File created by Sound Exchange",ft->filename);
 fwrite (name_buf, 1, 96, ft->fp);
 }
 
--- a/src/sox.c
+++ b/src/sox.c
@@ -467,8 +467,15 @@
                 case 'c':
                         if (! ft) usage("-c");
                         str = optarg;
-                        if (! sscanf(str, "%d", &i))
-                                st_fail("-c must be given a number");
+                        if (!sscanf(str, "%d", &i))
+                            st_fail("-c must be given a number");
+			/* Since we use -1 as a special internal value,
+			 * we must do some extra logic so user doesn't
+			 * get confused when we translate -1 to mean
+			 * something valid.
+			 */
+			if (i < 1)
+			    st_fail("-c must be given a positive number");
                         ft->info.channels = i;
                         break;
                 case 'b':
--- a/src/sphere.c
+++ b/src/sphere.c
@@ -53,7 +53,7 @@
 
 	if (st_reads(ft, fldsval, 8) == ST_EOF)
 	{
-	    st_fail_errno(ft,ST_EHDR,"Error reading Sphere header %s",fldsval);
+	    st_fail_errno(ft,ST_EHDR,"Error reading Sphere header");
 	    return(ST_EOF);
 	}
 
--- a/src/vorbis.c
+++ b/src/vorbis.c
@@ -341,9 +341,8 @@
 	fprintf(stdout, "Channels: %d  Rate: %ld\n", ft->info.channels,
 		rate);
 
-	/* Set encoding to average bit rate of 128kbps with no min or max */
-	vorbis_encode_init(&ve->vi, ft->info.channels, ft->info.rate,
-			   -1, 128000, -1);
+	/* Set encoding to average bit rate of 112kbps VBR */
+	vorbis_encode_init_vbr(&ve->vi, ft->info.channels, ft->info.rate, 0.3f);
 
 	vorbis_analysis_init(&ve->vd, &ve->vi);
 	vorbis_block_init(&ve->vd, &ve->vb);