[Freeswitch-svn] [commit] r13415 - in freeswitch/trunk/libs: libsndfile libsndfile/Cfg libsndfile/M4 libsndfile/Octave libsndfile/Win32 libsndfile/doc libsndfile/examples libsndfile/man libsndfile/programs libsndfile/regtest libsndfile/src libsndfile/src/G72x libsndfile/src/GSM610 libsndfile/tests win32/libsndfile
FreeSWITCH SVN
mikej at freeswitch.org
Thu May 21 14:09:30 PDT 2009
Author: mikej
Date: Thu May 21 16:09:30 2009
New Revision: 13415
Log:
libsndfile: update to 1.0.19 (LBSNDF-7)
http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2009-0186
http://www.mega-nerd.com/libsndfile/libsndfile-1.0.19.tar.gz
This will likely require a fresh boostrap to updated source checkouts.
Added:
freeswitch/trunk/libs/libsndfile/Cfg/
freeswitch/trunk/libs/libsndfile/M4/
freeswitch/trunk/libs/libsndfile/M4/Makefile.am
freeswitch/trunk/libs/libsndfile/M4/Makefile.in
freeswitch/trunk/libs/libsndfile/M4/add_cflags.m4
freeswitch/trunk/libs/libsndfile/M4/add_cxxflags.m4
freeswitch/trunk/libs/libsndfile/M4/clip_mode.m4
freeswitch/trunk/libs/libsndfile/M4/endian.m4
freeswitch/trunk/libs/libsndfile/M4/extra_largefile.m4
freeswitch/trunk/libs/libsndfile/M4/extra_pkg.m4
freeswitch/trunk/libs/libsndfile/M4/flexible_array.m4
freeswitch/trunk/libs/libsndfile/M4/gcc_version.m4
freeswitch/trunk/libs/libsndfile/M4/libtool.m4
freeswitch/trunk/libs/libsndfile/M4/llrint.m4
freeswitch/trunk/libs/libsndfile/M4/lrint.m4
freeswitch/trunk/libs/libsndfile/M4/lrintf.m4
freeswitch/trunk/libs/libsndfile/M4/ltoptions.m4
freeswitch/trunk/libs/libsndfile/M4/ltsugar.m4
freeswitch/trunk/libs/libsndfile/M4/ltversion.m4
freeswitch/trunk/libs/libsndfile/M4/lt~obsolete.m4
freeswitch/trunk/libs/libsndfile/M4/mkoctfile_version.m4
freeswitch/trunk/libs/libsndfile/M4/octave.m4
freeswitch/trunk/libs/libsndfile/Octave/PKG_ADD
freeswitch/trunk/libs/libsndfile/Octave/octave_test.m
freeswitch/trunk/libs/libsndfile/Octave/octave_test.sh
freeswitch/trunk/libs/libsndfile/Octave/sndfile.cc
freeswitch/trunk/libs/libsndfile/doc/tutorial.html
freeswitch/trunk/libs/libsndfile/examples/sndfile-to-text.c
freeswitch/trunk/libs/libsndfile/examples/sndfilehandle.cc
freeswitch/trunk/libs/libsndfile/programs/
freeswitch/trunk/libs/libsndfile/programs/Makefile.am
freeswitch/trunk/libs/libsndfile/programs/Makefile.in
freeswitch/trunk/libs/libsndfile/programs/common.c
freeswitch/trunk/libs/libsndfile/programs/common.h
freeswitch/trunk/libs/libsndfile/programs/sndfile-cmp.c
freeswitch/trunk/libs/libsndfile/programs/sndfile-convert.c
freeswitch/trunk/libs/libsndfile/programs/sndfile-info.c
freeswitch/trunk/libs/libsndfile/programs/sndfile-jackplay.c
freeswitch/trunk/libs/libsndfile/programs/sndfile-metadata-get.c
freeswitch/trunk/libs/libsndfile/programs/sndfile-metadata-set.c
freeswitch/trunk/libs/libsndfile/programs/sndfile-play-beos.cpp
freeswitch/trunk/libs/libsndfile/programs/sndfile-play.c
freeswitch/trunk/libs/libsndfile/programs/test-sndfile-metadata-set.py
freeswitch/trunk/libs/libsndfile/src/Symbols.os2
freeswitch/trunk/libs/libsndfile/src/audio_detect.c
freeswitch/trunk/libs/libsndfile/src/chunk.c
freeswitch/trunk/libs/libsndfile/src/ima_oki_adpcm.c
freeswitch/trunk/libs/libsndfile/src/ima_oki_adpcm.h
freeswitch/trunk/libs/libsndfile/src/libsndfile-1.def
freeswitch/trunk/libs/libsndfile/src/mpc2k.c
freeswitch/trunk/libs/libsndfile/src/rf64.c
freeswitch/trunk/libs/libsndfile/src/test_audio_detect.c
freeswitch/trunk/libs/libsndfile/src/test_conversions.c
freeswitch/trunk/libs/libsndfile/src/test_float.c
freeswitch/trunk/libs/libsndfile/src/test_ima_oki_adpcm.c
freeswitch/trunk/libs/libsndfile/src/test_main.c
freeswitch/trunk/libs/libsndfile/src/test_main.h
freeswitch/trunk/libs/libsndfile/tests/checksum_test.c
freeswitch/trunk/libs/libsndfile/tests/external_libs_test.c
freeswitch/trunk/libs/libsndfile/tests/generate.c
freeswitch/trunk/libs/libsndfile/tests/generate.h
freeswitch/trunk/libs/libsndfile/tests/ogg_test.c
freeswitch/trunk/libs/libsndfile/tests/test_wrapper.sh.in
freeswitch/trunk/libs/libsndfile/tests/vorbis_test.c
Removed:
freeswitch/trunk/libs/win32/libsndfile/common.c
Modified:
freeswitch/trunk/libs/libsndfile/AUTHORS
freeswitch/trunk/libs/libsndfile/ChangeLog
freeswitch/trunk/libs/libsndfile/Makefile.am
freeswitch/trunk/libs/libsndfile/Mingw-make-dist.sh
freeswitch/trunk/libs/libsndfile/NEWS
freeswitch/trunk/libs/libsndfile/Octave/Makefile.am
freeswitch/trunk/libs/libsndfile/Octave/sndfile_load.m
freeswitch/trunk/libs/libsndfile/Octave/sndfile_play.m
freeswitch/trunk/libs/libsndfile/Octave/sndfile_save.m
freeswitch/trunk/libs/libsndfile/README
freeswitch/trunk/libs/libsndfile/Win32/Makefile.am
freeswitch/trunk/libs/libsndfile/Win32/testprog.c
freeswitch/trunk/libs/libsndfile/configure.ac
freeswitch/trunk/libs/libsndfile/configure.gnu
freeswitch/trunk/libs/libsndfile/doc/FAQ.html
freeswitch/trunk/libs/libsndfile/doc/Makefile.am
freeswitch/trunk/libs/libsndfile/doc/api.html
freeswitch/trunk/libs/libsndfile/doc/bugs.html
freeswitch/trunk/libs/libsndfile/doc/command.html
freeswitch/trunk/libs/libsndfile/doc/dither.html
freeswitch/trunk/libs/libsndfile/doc/embedded_files.html
freeswitch/trunk/libs/libsndfile/doc/index.html
freeswitch/trunk/libs/libsndfile/doc/libsndfile.css
freeswitch/trunk/libs/libsndfile/doc/libsndfile.css.in
freeswitch/trunk/libs/libsndfile/doc/lists.html
freeswitch/trunk/libs/libsndfile/doc/new_file_type.HOWTO
freeswitch/trunk/libs/libsndfile/doc/octave.html
freeswitch/trunk/libs/libsndfile/doc/pkgconfig.html
freeswitch/trunk/libs/libsndfile/doc/sndfile_info.html
freeswitch/trunk/libs/libsndfile/doc/win32.html
freeswitch/trunk/libs/libsndfile/examples/Makefile.am
freeswitch/trunk/libs/libsndfile/examples/generate.c
freeswitch/trunk/libs/libsndfile/examples/list_formats.c
freeswitch/trunk/libs/libsndfile/examples/make_sine.c
freeswitch/trunk/libs/libsndfile/examples/sfprocess.c
freeswitch/trunk/libs/libsndfile/man/Makefile.am
freeswitch/trunk/libs/libsndfile/man/sndfile-convert.1
freeswitch/trunk/libs/libsndfile/man/sndfile-info.1
freeswitch/trunk/libs/libsndfile/man/sndfile-play.1
freeswitch/trunk/libs/libsndfile/regtest/Makefile.am
freeswitch/trunk/libs/libsndfile/regtest/checksum.c
freeswitch/trunk/libs/libsndfile/regtest/database.c
freeswitch/trunk/libs/libsndfile/regtest/regtest.h
freeswitch/trunk/libs/libsndfile/regtest/sndfile-regtest.c
freeswitch/trunk/libs/libsndfile/src/G72x/Makefile.am
freeswitch/trunk/libs/libsndfile/src/G72x/g721.c
freeswitch/trunk/libs/libsndfile/src/G72x/g723_16.c
freeswitch/trunk/libs/libsndfile/src/G72x/g723_24.c
freeswitch/trunk/libs/libsndfile/src/G72x/g723_40.c
freeswitch/trunk/libs/libsndfile/src/G72x/g72x.c
freeswitch/trunk/libs/libsndfile/src/G72x/g72x.h
freeswitch/trunk/libs/libsndfile/src/G72x/g72x_priv.h
freeswitch/trunk/libs/libsndfile/src/G72x/g72x_test.c
freeswitch/trunk/libs/libsndfile/src/GSM610/Makefile.am
freeswitch/trunk/libs/libsndfile/src/GSM610/add.c
freeswitch/trunk/libs/libsndfile/src/GSM610/code.c
freeswitch/trunk/libs/libsndfile/src/GSM610/config.h
freeswitch/trunk/libs/libsndfile/src/GSM610/decode.c
freeswitch/trunk/libs/libsndfile/src/GSM610/gsm.h
freeswitch/trunk/libs/libsndfile/src/GSM610/gsm610_priv.h
freeswitch/trunk/libs/libsndfile/src/GSM610/gsm_create.c
freeswitch/trunk/libs/libsndfile/src/GSM610/gsm_decode.c
freeswitch/trunk/libs/libsndfile/src/GSM610/gsm_destroy.c
freeswitch/trunk/libs/libsndfile/src/GSM610/gsm_encode.c
freeswitch/trunk/libs/libsndfile/src/GSM610/gsm_option.c
freeswitch/trunk/libs/libsndfile/src/GSM610/long_term.c
freeswitch/trunk/libs/libsndfile/src/GSM610/lpc.c
freeswitch/trunk/libs/libsndfile/src/GSM610/preprocess.c
freeswitch/trunk/libs/libsndfile/src/GSM610/rpe.c
freeswitch/trunk/libs/libsndfile/src/GSM610/short_term.c
freeswitch/trunk/libs/libsndfile/src/GSM610/table.c
freeswitch/trunk/libs/libsndfile/src/Makefile.am
freeswitch/trunk/libs/libsndfile/src/aiff.c
freeswitch/trunk/libs/libsndfile/src/alaw.c
freeswitch/trunk/libs/libsndfile/src/au.c
freeswitch/trunk/libs/libsndfile/src/avr.c
freeswitch/trunk/libs/libsndfile/src/binheader_writef_check.py
freeswitch/trunk/libs/libsndfile/src/broadcast.c
freeswitch/trunk/libs/libsndfile/src/caf.c
freeswitch/trunk/libs/libsndfile/src/command.c
freeswitch/trunk/libs/libsndfile/src/common.c
freeswitch/trunk/libs/libsndfile/src/common.h
freeswitch/trunk/libs/libsndfile/src/create_symbols_file.py
freeswitch/trunk/libs/libsndfile/src/dither.c
freeswitch/trunk/libs/libsndfile/src/double64.c
freeswitch/trunk/libs/libsndfile/src/dwd.c
freeswitch/trunk/libs/libsndfile/src/dwvw.c
freeswitch/trunk/libs/libsndfile/src/file_io.c
freeswitch/trunk/libs/libsndfile/src/flac.c
freeswitch/trunk/libs/libsndfile/src/float32.c
freeswitch/trunk/libs/libsndfile/src/g72x.c
freeswitch/trunk/libs/libsndfile/src/gsm610.c
freeswitch/trunk/libs/libsndfile/src/htk.c
freeswitch/trunk/libs/libsndfile/src/ima_adpcm.c
freeswitch/trunk/libs/libsndfile/src/interleave.c
freeswitch/trunk/libs/libsndfile/src/ircam.c
freeswitch/trunk/libs/libsndfile/src/macbinary3.c
freeswitch/trunk/libs/libsndfile/src/macos.c
freeswitch/trunk/libs/libsndfile/src/mat4.c
freeswitch/trunk/libs/libsndfile/src/mat5.c
freeswitch/trunk/libs/libsndfile/src/ms_adpcm.c
freeswitch/trunk/libs/libsndfile/src/nist.c
freeswitch/trunk/libs/libsndfile/src/ogg.c
freeswitch/trunk/libs/libsndfile/src/paf.c
freeswitch/trunk/libs/libsndfile/src/pcm.c
freeswitch/trunk/libs/libsndfile/src/pvf.c
freeswitch/trunk/libs/libsndfile/src/raw.c
freeswitch/trunk/libs/libsndfile/src/rx2.c
freeswitch/trunk/libs/libsndfile/src/sd2.c
freeswitch/trunk/libs/libsndfile/src/sds.c
freeswitch/trunk/libs/libsndfile/src/sf_unistd.h
freeswitch/trunk/libs/libsndfile/src/sfconfig.h
freeswitch/trunk/libs/libsndfile/src/sfendian.h
freeswitch/trunk/libs/libsndfile/src/sndfile.c
freeswitch/trunk/libs/libsndfile/src/sndfile.h.in
freeswitch/trunk/libs/libsndfile/src/sndfile.hh
freeswitch/trunk/libs/libsndfile/src/strings.c
freeswitch/trunk/libs/libsndfile/src/svx.c
freeswitch/trunk/libs/libsndfile/src/test_endswap.c
freeswitch/trunk/libs/libsndfile/src/test_endswap.def
freeswitch/trunk/libs/libsndfile/src/test_endswap.tpl
freeswitch/trunk/libs/libsndfile/src/test_file_io.c
freeswitch/trunk/libs/libsndfile/src/test_log_printf.c
freeswitch/trunk/libs/libsndfile/src/txw.c
freeswitch/trunk/libs/libsndfile/src/ulaw.c
freeswitch/trunk/libs/libsndfile/src/voc.c
freeswitch/trunk/libs/libsndfile/src/vox_adpcm.c
freeswitch/trunk/libs/libsndfile/src/w64.c
freeswitch/trunk/libs/libsndfile/src/wav.c
freeswitch/trunk/libs/libsndfile/src/wav_w64.c
freeswitch/trunk/libs/libsndfile/src/wav_w64.h
freeswitch/trunk/libs/libsndfile/src/wve.c
freeswitch/trunk/libs/libsndfile/src/xi.c
freeswitch/trunk/libs/libsndfile/tests/Makefile.am
freeswitch/trunk/libs/libsndfile/tests/aiff_rw_test.c
freeswitch/trunk/libs/libsndfile/tests/alaw_test.c
freeswitch/trunk/libs/libsndfile/tests/benchmark.c
freeswitch/trunk/libs/libsndfile/tests/benchmark.def
freeswitch/trunk/libs/libsndfile/tests/benchmark.tpl
freeswitch/trunk/libs/libsndfile/tests/command_test.c
freeswitch/trunk/libs/libsndfile/tests/cpp_test.cc
freeswitch/trunk/libs/libsndfile/tests/dft_cmp.c
freeswitch/trunk/libs/libsndfile/tests/dft_cmp.h
freeswitch/trunk/libs/libsndfile/tests/dither_test.c
freeswitch/trunk/libs/libsndfile/tests/dwvw_test.c
freeswitch/trunk/libs/libsndfile/tests/error_test.c
freeswitch/trunk/libs/libsndfile/tests/fix_this.c
freeswitch/trunk/libs/libsndfile/tests/floating_point_test.c
freeswitch/trunk/libs/libsndfile/tests/floating_point_test.def
freeswitch/trunk/libs/libsndfile/tests/floating_point_test.tpl
freeswitch/trunk/libs/libsndfile/tests/header_test.c
freeswitch/trunk/libs/libsndfile/tests/header_test.def
freeswitch/trunk/libs/libsndfile/tests/header_test.tpl
freeswitch/trunk/libs/libsndfile/tests/headerless_test.c
freeswitch/trunk/libs/libsndfile/tests/largefile_test.c
freeswitch/trunk/libs/libsndfile/tests/locale_test.c
freeswitch/trunk/libs/libsndfile/tests/lossy_comp_test.c
freeswitch/trunk/libs/libsndfile/tests/misc_test.c
freeswitch/trunk/libs/libsndfile/tests/multi_file_test.c
freeswitch/trunk/libs/libsndfile/tests/pcm_test.c
freeswitch/trunk/libs/libsndfile/tests/pcm_test.def
freeswitch/trunk/libs/libsndfile/tests/pcm_test.tpl
freeswitch/trunk/libs/libsndfile/tests/peak_chunk_test.c
freeswitch/trunk/libs/libsndfile/tests/pipe_test.c
freeswitch/trunk/libs/libsndfile/tests/pipe_test.def
freeswitch/trunk/libs/libsndfile/tests/pipe_test.tpl
freeswitch/trunk/libs/libsndfile/tests/raw_test.c
freeswitch/trunk/libs/libsndfile/tests/scale_clip_test.c
freeswitch/trunk/libs/libsndfile/tests/scale_clip_test.def
freeswitch/trunk/libs/libsndfile/tests/scale_clip_test.tpl
freeswitch/trunk/libs/libsndfile/tests/sfversion.c
freeswitch/trunk/libs/libsndfile/tests/stdin_test.c
freeswitch/trunk/libs/libsndfile/tests/stdio_test.c
freeswitch/trunk/libs/libsndfile/tests/stdout_test.c
freeswitch/trunk/libs/libsndfile/tests/string_test.c
freeswitch/trunk/libs/libsndfile/tests/ulaw_test.c
freeswitch/trunk/libs/libsndfile/tests/utils.c
freeswitch/trunk/libs/libsndfile/tests/utils.def
freeswitch/trunk/libs/libsndfile/tests/utils.h
freeswitch/trunk/libs/libsndfile/tests/utils.tpl
freeswitch/trunk/libs/libsndfile/tests/virtual_io_test.c
freeswitch/trunk/libs/libsndfile/tests/win32_ordinal_test.c
freeswitch/trunk/libs/libsndfile/tests/win32_test.c
freeswitch/trunk/libs/libsndfile/tests/write_read_test.c
freeswitch/trunk/libs/libsndfile/tests/write_read_test.def
freeswitch/trunk/libs/libsndfile/tests/write_read_test.tpl
freeswitch/trunk/libs/win32/libsndfile/config.h
freeswitch/trunk/libs/win32/libsndfile/libsndfile.2008.vcproj
freeswitch/trunk/libs/win32/libsndfile/libsndfile.vcproj
freeswitch/trunk/libs/win32/libsndfile/sndfile.h
Modified: freeswitch/trunk/libs/libsndfile/AUTHORS
==============================================================================
--- freeswitch/trunk/libs/libsndfile/AUTHORS (original)
+++ freeswitch/trunk/libs/libsndfile/AUTHORS Thu May 21 16:09:30 2009
@@ -1,14 +1,14 @@
-The main author of libsndfile is Erik de Castro Lopo <erikd at mega-nerd.com>.
+The main author of libsndfile is Erik de Castro Lopo <erikd at mega-nerd.com>
+apart from code in the following directories:
-The code in the src/GSM610 directory was written by Jutta Degener
-<jutta at cs.tu-berlin.de> and Carsten Bormann <cabo at cs.tu-berlin.de>.
-They should not be contacted in relation to libsndfile or the GSM 6.10 code
-that is part of libsndfile. Their original code can be found at:
+ - src/GSM610 : Written by Jutta Degener <jutta at cs.tu-berlin.de> and Carsten
+ Bormann <cabo at cs.tu-berlin.de>. They should not be contacted in relation to
+ libsndfile or the GSM 6.10 code that is part of libsndfile. Their original
+ code can be found at:
- http://kbs.cs.tu-berlin.de/~jutta/toast.html
-
-Code in the src/G72x directory was released by Sun Microsystems, Inc. to the
-public domain. Minor modifications were required to integrate these files
-into libsndfile. The changes are listed in src/G72x/ChangeLog.
+ http://kbs.cs.tu-berlin.de/~jutta/toast.html
+ - src/G72x : Released by Sun Microsystems, Inc. to the public domain. Minor
+ modifications were required to integrate these files into libsndfile. The
+ changes are listed in src/G72x/ChangeLog.
Modified: freeswitch/trunk/libs/libsndfile/ChangeLog
==============================================================================
--- freeswitch/trunk/libs/libsndfile/ChangeLog (original)
+++ freeswitch/trunk/libs/libsndfile/ChangeLog Thu May 21 16:09:30 2009
@@ -1,15 +1,1671 @@
-2006-08-31 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2009-03-03 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * configure.ac
+ Detect vorbis_version_string() correctly.
+
+2009-03-02 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * doc/index.html
+ Add a 'See Also' section with a link to sndfile-tools.
+
+ * NEWS README doc/*.html
+ Updates for 1.0.19 release.
+
+ * configure.ac
+ Fix --enable-external-libs logic.
+
+2009-03-01 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * src/aiff.c
+ Fix resource leak and potential read beyond end of buffer.
+
+ * src/nist.c
+ Fix reading of header value sample_n_bytes.
+
+ * src/sd2.c src/wav.c
+ Fix potential read beyond end of buffer.
+
+ * src/sndfile.c src/svx.c
+ Check return values of file_io functions.
+
+ * tests/win32_test.c
+ Fix resource leak.
+
+ * configure.ac
+ Detect the presence/absence of vorbis_version_string() in libvorbis.
+
+ * src/ogg.c
+ Only call vorbis_version_string() from libvorbis if present.
+
+2009-02-24 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * tests/win32_test.c
+ Don't use sprintf, even on windows.
+
+ * src/aiff.c src/rf64.c src/wav.c
+ Eliminate dead code, more validation of data read from file.
+
+2009-02-22 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * src/ima_adpcm.c
+ Clamp values to a valid range before indexing ima_step_size array.
+
+ * src/GSM610/*.c tests/*c programs/*.c src/audio_detect.c
+ Don't include un-needed headers.
+
+ * programs/sndfile-info.c
+ Remove dead code.
+
+ * tests/test_wrapper.sh.in
+ Add 'set -e' so the script exits on error.
+
+ * src/test_ima_oki_adpcm.c
+ Fix read beyond end of array.
+
+ * tests/win32_test.c
+ Add missing close on file descriptor.
+
+ * src/nist.c programs/sndfile-metadata-set.c
+ Fix 'unused variable' warnings.
+
+ * src/aiff.c
+ Fix potential memory leak in handling of 'MARK' chunk.
+ Remove un-needed test (unsigned > 0).
+
+ * src/sd2.c
+ Improve handling of heap allocated buffer.
+
+ * src/sndfile.c
+ Remove un-needed test (always true).
+
+ * src/wav.c src/rf64.c
+ Ifdef out dead code that will be resurected some time in the future.
+
+ * src/wav.c src/w64.c src/xi.c
+ Handle error return values from psf_ftell.
+
+ * src/wav_w64.c
+ Fix handling and error checking of MSADPCM coefficient arrays.
+
+ * regtest/*.c
+ Bunch of fixes.
+
+ * src/test_file_io.c
+ Use snprintf instead of strncpy in test program.
+
+2009-02-21 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * src/sd2.c
+ Validate data before using.
+
+ * src/caf.c
+ Validate channels per frame value before using, fixing a possible integer
+ overflow bug, leading to a possible heap overflow. Found by Alin Rad Pop of
+ Secunia Research (CVE-2009-0186).
+
+2009-02-20 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * Octave/octave_test.sh
+ Unset TERM environment variable and export LD_LIBRARY_PATH.
+
+2009-02-16 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * src/file_io.c
+ In windows code, cast LPVOID to 'char*' in printf.
+
+2009-02-15 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * M4/octave.m4
+ Clear the TERM environment before evaluating anything in Octave. This works
+ around problems that might occur if a users TERM settings are incorrect.
+ Thanks to Rob Til Freedmen for helping to debug this.
+
+ * src/wav.c
+ Handle four zero bytes as a marker within a LIST or INFO chunk.
+ Thanks to Rogério Brito for supplying an example file.
+
+2009-02-14 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * src/common.h src/*.c
+ Use C99 snprintf everywhere.
+
+2009-02-11 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * tests/test_wrapper.sh.in
+ New file to act as the template for the test wrapper script.
+
+ * configure.ac
+ Generate tests/test_wrapper.sh from the template.
+
+ * tests/Makefile.am
+ Replace all tests with a single invocation of the test wrapper script.
+
+2009-02-09 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * src/ogg.c
+ Record vorbis library version string.
+
+ * configure.ac
+ Require libvorbis >= 1.2.2.
+
+ * M4/endian.m4
+ Fix bracketing of function for autoconf 2.63. Thanks to Richard Ash.
+
+ * M4/octave.m4 M4/mkoctfile_version.m4
+ Clean up AC_WITH_ARG usage using AC_HELP_STRING.
+
+2009-02-08 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * Octave/Makefile.am
+ Use $(top_buildir) instead of $(builddir) which may not be defined.
+
+ * M4/octave.m4
+ Improve logic and status reporting.
+
+2009-02-07 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * configure.ac AUTHORS NEWS README doc/*.html
+ Final tweaks for 1.0.18 release.
+
+2009-02-03 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * programs/sndfile-convert.c
+ Add 'htk' to the list of convert formats.
+
+ * programs/sndfile-info.c
+ Simplify get_signal_max using SFC_CALC_SIGNAL_MAX command.
+ Increase size of files for which signal max will be calculated.
+
+2009-01-14 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * doc/index.html
+ Fix links for SoX and WavPlay. Thanks to Daniel Griscom.
+
+2009-01-11 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * programs/sndfile-metadata-get.c
+ Make valgrind clean.
+ Clean up temp string array usage.
+ Error out if trying to update coding history in RDWR mode.
+
+2009-01-10 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * doc/index.html
+ Fix links to versions of the LGPL.
+
+2008-12-14 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * tests/string_test.c
+ Add test for RDWR mode where the file ends up shorter than when it was
+ opened.
+
+ * src/wav.c
+ Truncate the file on close for RDWR mode where the file ends up shorter
+ than when it was opened.
+
+2008-11-30 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * M4/add_cflags.m4
+ Fix problem with quoting of '#include'.
+
+ * M4/add_cxxflags.m4 configure.ac
+ Add new file M4/add_cxxflags.m4 and use it in configure.ac.
+
+2008-11-19 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * programs/sndfile-info.c
+ Apply patch from Conrad Parker to calculate and display total duration when
+ more than one file is dumped.
+
+2008-11-10 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * configure.ac src/Makefile.am
+ Tweaks to generation of Symbols files.
+
+ * tests/win32_ordinal_test.c
+ Update tests for above changes.
+
+2008-11-06 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * programs/common.c
+ When merging broadcast info, make sure to clear the destination field
+ before copying in the new data.
+
+ * programs/test-sndfile-metadata-set.py
+ Add test for the above.
+
+ * src/broadcast.c
+ Fix checking of required coding_history_size.
+
+2008-10-28 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * tests/command_test.c
+ Add test to detect if coding history is truncated.
+
+ * src/broadcast.c
+ Fix truncation of coding history.
+
+2008-10-27 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * tests/command_test.c
+ Add broadcast_coding_history_size test.
+
+ * programs/*.[ch]
+ Use SF_BROADCAST_INFO_VAR to manipulate larger 'bext' chunks.
+
+ * src/rf64.c
+ Add code to prevent infinite loop on malformed file.
+
+ * src/common.h src/sndfile.c src/w64.c src/wav_w64.c
+ Rationalize and improve error handling when parsing 'fmt ' chunk.
+
+ * M4/octave.m4
+ Simplify and remove cruft.
+ Check for correct Octave version.
+
+ * Octave/*
+ Reduce 3 C++ files to one, fix build for octave 3.0, fix build.
+
+ * Octave/sndfile.cc Octave/PKG_ADD
+ Add Octave function sfversion which returns the libsndfile version that the
+ module is linked against.
+
+ * Octave/Makefile.am
+ Bunch of build and 'make distcheck' fixes.
+
+2008-10-26 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * programs/common.c
+ Return 1 if SFC_SET_BROADCAST_INFO fails.
+
+ * programs/test-sndfile-metadata-set.py
+ Update for new programs directory, exit on any error.
+
+ * tests/error_test.c
+ Fix failure behaviour in error_number_test.
+
+ * src/common.h src/sndfile.c
+ Add error number SFE_BAD_BROADCAST_INFO_SIZE.
+
+ * src/*
+ Reimplement handling of broadcast extentioon chunk in WAV/WAVEX files.
+
+ * src/broadcast.c
+ Fix generation of added coding history.
+
+2008-10-25 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * programs/sndfile-metadata-get.c programs/sndfile-info.c
+ Exit with non-zero on errors.
+
+2008-10-21 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * examples/sndfile-to-text.c examples/Makefile.am
+ Add a new example program and hook it into the build.
+
+ * examples/ programs/
+ Add a new directory programs and move sndfile-info, sndfile-play and other
+ real programs to the new directory, leaving example programs where they
+ were.
+
+2008-10-20 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * tests/Makefile.am
+ Automake 1.10 MinGW cross compiling fixes.
+
+2008-10-19 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * examples/sndfile-play.c
+ Remove call to deprecated function snd_pcm_sw_params_get_xfer_align.
+ Fix gcc-4.3 compiler warnings.
+
+ * tests/command_test.c
+ Fix a valgrind warning.
+
+ * tests/error_test.c tests/multi_file_test.c tests/peak_chunk_test.c
+ tests/pipe_test.tpl tests/stdio_test.c tests/win32_test.c
+ Fix gcc-4.3 compiler warnings.
+
+2008-10-17 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * src/broadcast.c
+ Fix termination of desitination string in strncpy_crlf.
+ When copying BROADCAST_INFO chunk, make sure destination gets correct line
+ endings.
+
+ * examples/common.c
+ Fix copying of BROADCAST_INFO coding_history field.
+
+2008-10-13 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * tests/command_test.c
+ Add test function instrument_rw_test, but don't hook it into the testing
+ yet.
+
+ * src/common.h src/command.c src/sndfile.c src/flac.c
+ Error code rationalization.
+
+ * src/common.h src/sndfile.c
+ Set psf->error to SFE_CMD_HAS_DATA when adding metadata via sf_command()
+ fails due to psf->have_written being true.
+
+ * doc/command.html
+ Document the SFC_GET/SET_BROADCAST_INFO comamnds.
+
+2008-10-10 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * tests/command_test.c
+ Improve error reporting when '\0' is found in coding history.
+ Fix false failure.
+
+2008-10-09 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * src/broadcast.c
+ Convert all coding history line endings to \r\n.
+
+ * tests/command_test.c
+ Add test to make sure all line endings are converted to \r\n.
+
+2008-10-08 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * src/broadcast.c
+ Changed the order of coding history fields.
+
+ * tests/command_test.c
+ Update bextch test to cope with previous change.
+
+ * examples/common.c
+ Add extra length check when copying broadcast info data.
+
+2008-10-05 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * tests/utils.tpl tests/pcm_test.tpl
+ Update check_file_hash_or_die to use 64 bit hash.
+
+ * tests/checksum_test.c tests/Makefile.am
+ Add new checksum_test specifically for lossy compression of headerless
+ files.
+
+2008-10-04 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * src/gsm610.c
+ Seek to psf->dataoffset before decoding first block.
+
+ * src/sndfile.c
+ Fix detection of mpc2k files on big endian systems.
+
+2008-10-03 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * src/broadcast.c
+ Use '\r\n' newlines in Coding History as required by spec.
+
+2008-10-02 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * src/test_conversions.c
+ Use int64_t instead of 'long long'.
+
+2008-10-01 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * examples/sndfile-metadata-set.c
+ Remove --bext-coding-history-append command line option because it didn't
+ really make sense.
+
+ * examples/sndfile-metadata-(get|set).c
+ Add usage messages.
+
+ * examples/test-sndfile-metadata-set.py
+ Start work on test coding history.
+
+2008-09-30 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * README doc/win32.html
+ Bring these up to date.
+
+ * src/aiff.c
+ Fix parsing of REX files.
+
+2008-09-29 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * src/file_io.c
+ Use intptr_t instead of long for return value of _get_osfhandle.
+
+ * src/test_conversions.c src/test_endswap.tpl
+ Fix printing of int64_t values.
+
+ * examples/sndfile-play.c
+ Fix win64 issues.
+
+ * tests/win32_ordinal_test.c
+ Fix calling of GetProcAddress with ordinal under win64.
+
+ * tests/utils.tpl
+ Fix win64 issues.
+
+2008-09-25 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * examples/*
+ Rename copy_data.[ch] to common.[ch]. Fix build.
+ Move code from sndfile-metadata-set.c to common.c.
+
+ * examples/Makefile.am tests/Makefile.am regtest/Makefile.am
+ Clean paths.
+
+2008-09-19 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * doc/tutorial.html doc/Makefile.am
+ Add file doc/tutorial.html and hook into build/dist system.
+
+2008-09-14 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * examples/sndfile-metadata-set.c
+ Clean up handling of bext command line params.
+
+2008-09-13 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * src/w64.c
+ Add handling/skipping of a couple of new chunk types.
+
+2008-09-09 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * configure.ac
+ Add -funsigned-char to CFLAGS if the compiler supports it.
+
+ * examples/sndfile-metadata-(get|set).c
+ Add handling for more metadata types.
+
+2008-09-04 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * src/common.h
+ Add macros SF_CONTAINER, SF_CODEC and SF_ENDIAN useful for splitting format
+ field of SF_INFO into component parts.
+
+ * src/*.c
+ Use new macros everywhere it is appropriate.
+
+2008-09-02 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * examples/sndfile-bwf-set.c
+ Massive reworking.
+
+2008-08-24 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * examples/sndfile-bwf-set.c
+ Add --info-auto-create-date command line option.
+
+ * examples/sndfile-metadata-set.c examples/sndfile-metadata-get.c
+ examples/Makefile.am examples/test-sndfile-bwf-set.py
+ Rename sndfile-bwf-(set|get).c to sndfile-metadata-(set|get).c.
+ Change command line args.
+
+2008-08-23 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * src/wav.c
+ Allow 'PAD ' chunk to be modified in RDWR mode.
+
+ * src/sndfile.h.in src/sndfile.c
+ Add handling (incomplete) for SFC_SET_ADD_HEADER_PAD_CHUNK.
+
+ * tests/Makefile.am tests/write_read_test.tpl tests/header_test.tpl
+ tests/misc_test.c
+ Add tests for RF64.
+
+ * src/rf64.c
+ Fixes to make sure all tests pass.
+
+ * tests/Makefile.am tests/string_test.c
+ Add string tests (not yet passing).
+
+2008-08-22 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * src/rf64.c
+ First pass at writing RF64 now working.
+
+2008-08-21 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * examples/sndfile-convert.c
+ Add SF_FORMAT_RF64 to format_map.
+
+ * src/common.h src/sndfile.c
+ More RF64 support code.
+
+ * examples/sndfile-bwf-set.c
+ Fix the month number in autogenerated date string and use hypen in date
+ instead of slash.
+
+ * examples/test-sndfile-bwf-set.py
+ Update tests.
+
+ * examples/sndfile-info.c
+ When called with -i or -b option, operate on all files on command line, not
+ just the first.
+
+2008-08-19 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * src/rf64.c
+ New file to handle RF64 (WAV like format supportting > 4Gig files).
+
+ * src/sndfile.h.in src/common.h src/sndfile.c src/Makefile.am
+ Hook the above into build so hacking can begin.
+
+ * src/pcm.c
+ Improve log message when pcm_init fails.
+
+ * src/sndfile-info.c
+ Only calculate and print 'Signal Max' if file is less than 10 megabytes in
+ length.
+
+2008-08-18 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * tests/string_test.c
+ Polish string_multi_set_test.
+
+ * src/wav.c
+ In RDWR mode, pad the header if necessary (ie LIST chunk has moved or
+ length has changed).
+ Minor fixes in wav_write_strings.
+ Write PAD chunk with default endian-ness, not a specific endian-ness.
+
+ * examples/test-sndfile-bwf-set.py
+ Add Python script to test sndfile-bwf-set/get.
+
+ * examples/sndfile-bwf-set.c
+ Clean up and fixes.
+
+ * src/wav.c
+ Merge function wavex_write_header into wav_write_header, deleting about 70
+ lines of code.
+
+ * src/common.h
+ Double value of SF_MAX_STRINGS.
+
+ * tests/string_test.c
+ Add string tests for WAVEX and RIFX files.
+
+ * tests/command_test.c
+ Add broadcast test for WAVEX files.
+
+2008-08-17 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * tests/string_test.c
+ Add a new string_rdwr_test (currently failing for WAV).
+ Add a new string_multi_set_test (currently failing).
+
+ * tests/command_test.c
+ Add new broadcast_rdwr_test (currently failing).
+
+ * src/wav.c
+ Fix to WAV parser to allow 'bext' chunk to be updated in place.
+ In wav_write_tailer, seek to psf->dataend if its greater than zero.
+
+ * src/sndfile.c
+ Make sure psf->have_written gets set correctly in mode SFM_RDWR.
+
+ * configure.ac
+ Test for <sys/time.h> and gettimeofday.
+
+ * src/common.c
+ Use gettimeofday() to initialize psf_rand_int32.
+
+ * src/common.h src/sndfile.c
+ Add unique_id field to SF_PRIVATE struct.
+
+ * src/common.h src/sndfile.c src/wav.c src/wav_w64.[ch]
+ Move wavex_ambisonic field from SF_PRIVATE struct to WAV_PRIVATE struct.
+
+ * src/common.h src/strings.c
+ Add function psf_location_string_count.
+
+2008-08-16 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * configure.ac
+ Test for localtime and localtime_r.
+
+ * examples/sndfile-convert.c
+ In function copy_metadata(), copy broadcast info if present.
+
+ * examples/copy_data.[ch] examples/Makefile.am
+ Break some functionality out of sndfile-convert.c so it can be used in
+ examples/sndfile-bwf-set.c.
+
+ * tests/utils.tpl
+ Add new function create_short_sndfile().
+
+ * examples/sndfile-bwf-set.c examples/sndfile-bwf-get.c
+ examples/Makefile.am
+ Add new files and hook into build.
+
+2008-08-11 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * src/sndfile.h.in
+ Fix comments. Patch from Mark Glines.
+
+2008-07-30 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * tests/misc_test.c
+ Use zero_data_test on Ogg/Vorbis files.
+
+ * src/ogg.c
+ Fix segfault when closing an Ogg/Vorbis file that has been opened for write
+ but had no actual data written to it. Bug reported by Chinoy Gupta.
+
+ * tests/Makefile.am
+ Make sure to run mist_test on Ogg/Vorbis files.
+
+2008-07-19 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * regtest/Makefile.am
+ Use SQLITE3_CFLAGS to locate sqlite headers.
+
+2008-07-10 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * doc/index.html doc/FAQ.html
+ Add notes about which versions of windows libsndfile works on.
+
+2008-07-03 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * tests/misc_test.c
+ Add a test for correct handling of Ambisonic files. Thanks to Fons
+ Adriaensen for the test.
+
+ * src/wav.c src/wav_w64.c
+ Fix handling of Ambisonic files. Thanks to Fons Adriaensen for the patch.
+
+2008-06-29 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * configure.ac
+ Fix detection/enabling of external libs.
+
+ * M4/extra_pkg.m4 M4/Makefile.am
+ Add m4 macro PKG_CHECK_MOD_VERSION which is a hacked version
+ PKG_CHECK_MODULES. The new macro prints the version number of the package
+ it is searching for.
+
+2008-06-14 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * src/aiff.c
+ Apply a fix from Axel Roebel where if the second loop in the instrument
+ chunk is none, the loop mode is written into the first loop.
+
+2008-05-31 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * src/test_float.c src/test_main.(c|h) src/Makefile.am
+ Add new file to test functions float32_(le|be)_(read|write) and
+ double64_(le|be)_(read|write). Hook into build and testsuite.
+
+ * src/double64.c src/float32.c
+ Fix bugs in functions found by test added above. Thanks to Nicolas Castagne
+ for reporting this bug.
+
+ * src/sndfile.h.in
+ Change time_reference_(low|high) entries of SF_BROADCAST_INFO struct to
+ unsigned.
+
+ * examples/sndfile-info.c
+ Print out the BEXT time reference in a sensible format.
+
+2008-05-21 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * src/*.c
+ Fuzz fixes.
+
+ * src/ogg.c
+ Add call to ogg_stream_clear to fix valgrind warning.
+
+ * src/aiff.c
+ Fix x86_64 compile issue.
+
+ * configure.ac src/Makefile.am src/flac.c src/ogg.c
+ Link to external versions of FLAC, Ogg and Vorbis.
+
+ * tests/lossy_comp_test.c tests/ogg_test.c tests/string_test.c
+ tests/vorbis_test.c tests/write_read_test.tpl
+ Fix tests when configured with --disable-external-libs.
+
+ * tests/external_libs_test.c tests/Makefile.am
+ Add new test and hook into build and test suite.
+
+ * src/command.c
+ Use HAVE_EXTERNAL_LIBS to ensure that the SFC_GET_FORMAT_* commands return
+ the right data when external libs are disabled.
+
+2008-05-11 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * tests/write_read_test.tpl
+ Add a test for extending a file during write by seeking past the current
+ end of file.
+
+ * src/sndfile.c
+ Allow seeking past end of file during write.
+
+2008-05-10 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * doc/api.html doc/command.html
+ Move all information about the sf_command function to command.html and add
+ a link from documentation of the sf_read/write_raw function to the
+ SFC_RAW_NEEDS_ENDSWAP command.
+
+ * doc/index.html doc/FAQ.html doc/libsndfile.css
+ Minor documentation tweaks.
+
+2008-05-09 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * configure.ac
+ Add AM_PROG_CC_C_O.
+
+2008-04-27 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * tests/error_test.c
+ Add a test to make sure if file opened with sf_open_fd, and then the file
+ descriptor is closed, then sf_close will return an error code. Thanks to
+ Dave Flogeras for the bug report.
+
+ * src/sndfile.c
+ Make sf_close return an error is the file descriptor is already closed.
+
+2008-04-19 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * configure.ac
+ Set object format to aout for OS/2. Thanks to David Yeo.
+
+ * src/mpc2k.c src/sndfile.c src/sndfile.h.in src/common.h src/Makefile.am
+ Add ability to read MPC 2000 file.
+
+ * tests/write_read_test.tpl tests/misc_test.c tests/header_test.tpl
+ tests/Makefile.am
+ Add tests for MPC 2000 file format.
+
+ * examples/sndfile-convert.c
+ Allow conversion to MPC 2000 file format.
+
+2008-04-17 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * src/VORBIS/lib/codebook.c
+ Sync from upstream SVN.
+
+ * autogen.sh configure.ac
+ Minor tweaks.
+
+2008-04-13 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * src/ogg.c
+ Add a patch that fixes finding the length in samples of an Ogg/Vorbis file.
+ The patch as supplied segfaulted and required many hours of debugging.
+
+ * src/OGG/bitwise.c
+ Sync from upstream SVN.
+
+2008-04-09 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * src/aiff.c
+ Fix up handling of 'APPL' chunk. Thanks to Axel Roebel for bringing up
+ this issue.
+
+2008-04-06 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * tests/*.c
+ Add calls to sf_close() where needed.
+
+ * tests/utils.tpl tests/multi_file_test.c
+ Always pass 0 as the third argument to open when OS_IS_WIN32.
+
+2008-04-03 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * src/test_*
+ Add files test_main.[ch].
+ Collapse all tests into a single executable.
+
+2008-03-30 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * src/FLAC
+ Sync to upstream CVS.
+
+2008-03-25 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * src/common.h
+ Make SF_MIN and SF_MAX macros MinGW friendly.
+
+ * examples/sndfile-(info|play).c
+ Use Sleep function from <windows.h> instead of _sleep.
+
+ * tests/locale_test.c
+ Disable some tests when OS_IS_WIN32.
+
+ * src/FLAC/src/share/replaygain_anal/replaygain_analysis.c
+ src/FLAC/src/share/utf8/utf8.c
+ MinGW fixes.
+
+2008-03-11 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * doc/FAQ.html
+ Tweaks to pcm16 <-> float conversion answer.
+
+2008-02-10 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * src/OGG
+ Sync to SVN upstream.
+
+ * Makefile.am
+ Add 'DISTCHECK_CONFIGURE_FLAGS = --enable-gcc-werror'.
+
+2008-02-05 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * examples/sndfile-jackplay.c
+ Minor tweaks to warning message printed when compiled without libjack.
+
+2008-01-27 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * tests/peak_chunk_test.c
+ Improve read_write_peak_test to find more errors. Inspired by example
+ provided by Nicolas Castagne.
+
+ * src/aiff.c
+ Another SFM_RDWR fix shown up by above test.
+
+2008-01-24 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * src/aiff.c
+ Fix reading of COMM encoding string.
+
+ * src/chunk.c src/common.h src/Makefile.am
+ New file for storing and retrieving info about header chunks. Hook into
+ build.
+
+ * src/aiff.c
+ Use new chunk logging to fix problem with AIFF in RDWR mode.
+
+2008-01-22 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * src/command.c
+ Add WVE to the list of major formats.
+
+ * tests/aiff_rw_test.c
+ Fix error reporting.
+
+2008-01-21 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * src/common.[ch]
+ Add internal functions str_of_major_format, str_of_minor_format,
+ str_of_open_mode and str_of_endianness.
+
+ * tests/write_read_test.tpl
+ Fix reporting of errors in new_rdwr_XXXX_test.
+
+2008-01-20 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * examples/sndfile-play.c
+ Apply patch from Yair K. to fix compiles with OSS v4.
+
+ * src/common.h src/float32.c src/double64.c
+ Rename psf->float_enswap to psf->data_endswap.
+
+ * src/sndfile.h.in src/sndfile.c src/pcm.c
+ Add command SFC_RAW_NEEDS_ENDSWAP.
+
+ * tests/command.c
+ Add test for SFC_RAW_NEEDS_ENDSWAP.
+
+ * doc/command.html
+ Document SFC_RAW_NEEDS_ENDSWAP.
+
+ * tests/peak_chunk_test.c
+ Add test function read_write_peak_test. Thanks to Nicolas Castagne for the
+ bug report.
+
+2008-01-09 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * examples/sndfile-cmp.c
+ Add new example program contributed by Conrad Parker.
+
+ * examples/Makefile.am
+ Hook into build.
+
+ * doc/development.html
+ Change use or reconfigure.mk to autogen.sh.
+
+2008-01-08 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * tests/win32_test.c
+ Add another win32 test.
+
+ * tests/util.tpl
+ Add function file_length_fd which wraps fstat.
+
+ * tests/Makefile.am
+ Run the multi_file_test on AU files.
+
+ * tests/multi_file_test.c
+ Use function file_length_fd() instead of file_length() to overcome stupid
+ win32 bug. Fscking hell Microsoft sucks so much.
+
+2008-01-05 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * src/sd2.c
+ Fix a rsrc parsing bug. Example file supplied by Uli Franke.
+
+2007-12-28 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * doc/index.html
+ Allow use of either LGPL v2.1 or LGPL v3.
+
+ * tests/header_test.tpl
+ Add header_shrink_test from Axel Roebel.
+
+ * src/wav.c
+ Add fix from Axel Roebel for writing files with float data but no peak
+ chunk (ie peak chunk gets removed after the file is opened).
+
+ * src/aiff.c tests/header_test.tpl
+ Apply similar fix to above for AIFF files.
+
+ * src/wav.c tests/header_test.tpl
+ Apply similar fix to above for WAVEX files.
+
+ * src/command.c
+ Add Ogg/Vorbis to 'get format' commands.
+
+2007-12-16 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * src/ogg.c
+ Fix seeking on multichannel Ogg Vorbis files. Reported by Bodo.
+ Set the default encoding quality to 0.4 instead of 4.0 (Bodo again).
+
+ * tests/ogg_test.c
+ Add stereo seek tests.
+
+2007-12-14 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * tests/ogg_test.c
+ Add a test (currently failing) for stereo seeking on Ogg Vorbis files. Test
+ case supplied by Bodo.
+
+ * tests/utils.(def|tpl)
+ Add compare_XXX_or_die functions.
+
+2007-12-05 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * src/aiff.c
+ Fix a bug where ignoring ssnd_fmt.offset and ssnd_fmt.blocksize caused
+ misaligned reading of 24 bit data. Thanks to Uli Franke for reporting this.
+
+2007-12-03 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * src/vox_adpcm.c src/ima_oki_adpcm.[ch] src/Makefile.am
+ Merge in code from the vox-patch branch. Thanks to Robs for the patch
+ which fixes a long standing bug in the VOX codec.
+
+2007-12-01 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * examples/sndfile-convert.c
+ Fix handling of -override-sample-rate=X option.
+
+2007-11-25 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * src/ogg.c src/VORBIS
+ Merge in Ogg Vorbis support from John ffitch of the Csound project.
+
+2007-11-24 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * src/sndfile.c
+ Recognise files with 'vox6' extension as 6kHz OKI VOX ADPCM files. Also
+ recognise 'vox8' as and 'vox' as 8kHz files.
+
+ * configure.ac
+ Detect libjack (JACK Audio Connect Kit).
+
+ * examples/sndfile-jackplay.c examples/Makefile.am
+ Add new example program to play sound files using the JACK audio server.
+ Thanks to Jonatan Liljedahl for allowing this to be included.
+
+2007-11-21 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * doc/index.html
+ Update support table with SD2 and FLAC.
+
+2007-11-17 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * src/sndfile.c
+ Fix calculation of internal value psf->read_current when attempting to read
+ past end of audio data.
+ Remove redundant code.
+
+ * tests/lossy_comp_test.c
+ Add read_raw_test to check that raw reads do not go past the end of the
+ audio data section.
+ Clean up error output messages.
+
+ * src/sndfile.c
+ Add code to prevent sf_read_raw from reading past the end of the audio data.
+
+ * tests/Makefile.am
+ Add the wav_pcm lossy_comp_test.
+
+2007-11-16 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * configure.ac src/Makefile.am src/create_symbols_file.py
+ More OS/2 fixes from David Yeo.
+
+2007-11-12 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * src/file_io.c tests/utils.tpl tests/benchmark.tpl
+ Improve handling of requirements for O_BINARY as suggested by Ed Schouten.
+
+2007-11-11 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * src/common.h
+ Fix symbol class when SF_MIN is nested inside SF_MAX or vice versa.
+
+ * src/create_symbols_file.py
+ Add support for OS/2 contributed by David Yeo.
+
+2007-11-05 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * M4/gcc_version.m4
+ Add macro AC_GCC_VERSION to detect GCC_MAJOR_VERSION and GCC_MINOR_VERSION.
+
+ * configure.ac
+ Use AC_GCC_VERSION to work around gcc-4.2 inline warning stupidity.
+ See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33995
+ Use -fgnu-inline to prevent stupid warnings.
+
+2007-11-03 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * tests/util.tpl
+ Increase the printing width for print_test_name().
+
+ * tests/command_test.c tests/Makefile.am
+ Add tests for correct updating of broadcast WAV coding history.
+
+ * examples/sndfilehandle.cc examples/Makefile.am
+ Add example program using the C++ SndfileHandle class.
+
+2007-10-29 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * src/common.h src/sndfile.c
+ Add error codes SFE_ZERO_MAJOR_FORMAT and SFE_ZERO_MINOR_FORMAT.
+
+2007-10-26 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * src/sd2.c
+ Identify sample-rate/sample-size/channels by resource id.
+
+2007-10-25 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * src/broadcast.c src/common.h src/sndfile.c
+ Improvements to handling of broadcast info in WAV files. Thanks to Frederic
+ Cornu and other for their input.
+
+2007-10-24 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * src/FLAC/include/share/alloc.h
+ Mingw fix for SIZE_T_MAX from Uli Franke.
+
+2007-10-23 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * tests/open_fail_test.c tests/error_test.c tests/Makefile.am
+ Move tests from open_fail_test.c to error_test.c and remove the former.
+
+2007-10-22 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * tests/scale_clip_test.(def|tpl)
+ Add tests for SFC_SET_INT_FLOAT_WRITE command.
+
+ * doc/command.html
+ Add docs for SFC_SET_INT_FLOAT_WRITE command.
+
+ * examples/sndfile-play.c tests/dft_cmp.c
+ Fix gcc-4.2 warning messages.
+
+2007-10-21 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * src/sndfile.h.in src/sndfile.c
+ Add command SFC_GET_CURRENT_SF_INFO.
+
+ * src/sndfile.h.in src/sndfile.c src/create_symbols_file.py
+ Remove function sf_get_info (only ever in pre-release code).
+
+ * tests/command_test.c
+ Add test for SFC_GET_CURRENT_SF_INFO.
+
+2007-10-15 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * src/wav.c
+ Add parsing of 'exif' chunks. Originally coded by Trent Apted.
+
+ * configure.ac
+ Put config stuff in Cfg directory.
+ Remove check for inttypes.h.
+
+2007-10-10 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * src/w64.c
+ Fix writing of 'riff' chunk length and check for correct value in parser.
+
+2007-09-20 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * doc/index.html
+ Link to MP3 FAQ entry.
+
+2007-09-18 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * src/flac.c
+ Move the blocksize check to an earlier stage of flac_buffer_copy.
+
+2007-09-12 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * src/FLAC
+ Huge merge from FLAC upstream.
+
+2007-09-10 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * examples/*.c
+ Change license to all example programs to BSD.
+
+2007-09-08 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * src/FLAC/include/FLAC/metadata.h
+ Include <sys/types.h> to prevent compile error on OSX.
+
+ * Octave/octave_test.sh
+ Disable test on OSX. Can't get it to work.
+
+ * src/flac.c
+ Check the blocksize returned from the FLAC decoder to prevent buffer
+ overruns. Reported by Jeremy Friesner. Thanks.
+
+2007-09-07 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * Makefile.am M4/octave.m4
+ Fix build when Octave headers are not present.
+
+2007-08-27 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * doc/development.html
+ Add note about bzr repository directory looking empty.
+
+2007-08-26 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * configure.ac Octave/* M4/octave_*
+ Bunch of changes to add ability to build GNU Octave modules to read/write
+ sound files using libsndfile from Octave.
+
+2007-08-23 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * acinclude.m4 configure.ac ...
+ Get rid of acinclude.m4 and replace it with an M4 directory.
+
+2007-08-21 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * src/sndfile.h.in
+ Remove crufty Metrowerks compiler support. Allow header file to be compiled
+ on windows with both GCC and microsoft compiler.
+
+2007-08-19 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * tests/dft_cmp.[ch] tests/floating_point_test.tpl
+ Clean up floating point tests.
+
+2007-08-14 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * src/aiff.c
+ Fix segfault when COMM chunk length is byte swapped.
+
+2007-08-09 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * src/common.h src/mat4.c src/mat5.c src/sndfile.c
+ Add a generic SFE_CHANNEL_COUNT_ZERO error, remove format specific errors.
+
+ * src/au.c
+ Fix crash on AU files with zero channel count. Reported by Ben Alison.
+
+2007-08-08 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * src/voc.c
+ Fix bug in handling file supplied by Matt Olenik.
+
+2007-07-31 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * src/OGG
+ Merge from OGG upstream sources.
+
+2007-07-25 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * src/FLAC
+ Merge from FLAC upstream sources.
+
+2007-07-15 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * src/flac.c
+ Fix memory leak; set copy parameter to FALSE in call to
+ FLAC__metadata_object_vorbiscomment_append_comment.
+
+ * src/common.[ch]
+ Add function psf_rand_int32().
+
+2007-07-14 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * src/FLAC
+ Merge from FLAC upstream sources.
+
+ * src/strings.c tests/string_test.c tests/Makefile.am
+ Make sure string tests for SF_STR_LICENSE actually works.
+
+2007-07-13 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * tests/string_test.c
+ Add ability to test strings stored in metadata secion of FLAC files.
+
+ * src/string.c
+ Fix logic for testing if audio data has been written and string is added.
+ Make sure SF_STR_ALBUM actually works.
+
+ * src/flac.c
+ Finalize reading/writing string metadata. Tests pass.
+
+ * src/sndfile.h.in tests/string_test.c src/flac.c
+ Add string type SF_STR_LICENSE, update test and use for FLAC files.
+
+ * src/sndfile.h.in
+ Add definition for SFC_SET_SCALE_FLOAT_INT_WRITE command.
+
+ * src/common.h src/double64.c src/float32.c src/sndfile.c
+ Add support for SFC_SET_SCALE_FLOAT_INT_WRITE (still needs testing).
+
+2007-07-12 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * src/flac.c
+ Apply patch from Ed Schouten to read artist and title metadata from FLAC
+ files.
+ Improve reporting of FLAC metadata.
+
+ * src/sndfile.h.in tests/string_test.c src/flac.c
+ Add string type SF_STR_ALBUM, update test and use for FLAC files.
+
+2007-06-28 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * src/FLAC/*
+ Merge from upstream CVS.
+
+2007-06-16 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * src/FLAC/*
+ Update from upstream CVS.
+
+2007-06-14 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * tests/cpp_test.cc
+ Add extra tests for when the SndfileHandle constructor fails.
+
+ * src/sndfile.hh
+ Make sure failure to open the file in the constructor does not allow later
+ calls to other methods to fail.
+
+2007-06-10 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * tests/util.tpl
+ Add function write_mono_file.
+
+ * tests/generate.[ch] tests/Makefile.am
+ Add files generate.[ch] and hook into build.
+
+ * tests/write_read_test.tpl
+ Add multi_seek_test.
+
+ * src/flac.c
+ Fix buffer overflow bug. Test provided by Jeremy Friesner and fix provided
+ by David Viens.
+
+2007-06-07 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * doc/FAQ.html
+ Minor update.
+
+ * configure.ac src/FLAC/src/libFLAC/ia32/Makefile.am src/Makefile.am
+ Apply patch from Trent Apted make it compile on Intel MacOSX. Thanks Trent.
+
+2007-05-28 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * src/wav.c
+ Fix writing of MSGUID subtypes. Thanks to Bruce Sharpe.
+
+2007-05-22 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * src/wav.c
+ Fix array indexing bug raised by Bruce Sharpe.
+
+2007-05-12 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * src/FLAC/src/share/getopt/getopt.c
+ Fix Mac OSX / PowerPC compile warnings.
+
+ * configure.ac
+ Make sure WORDS_BIGENDIAN gets correctly defined for FLAC code.
+
+2007-05-04 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * doc/FAQ.html
+ Add Q/A about MP3 support.
+
+2007-05-03 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * doc/new_file_type.HOWTO
+ Minor updates.
+
+2007-05-02 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * src/wve.c
+ Fix a couple bad parameters with psf_log_printf.
+
+ * src/pcm.c
+ Improve error reporting.
+
+ * src/common.h src/common.c
+ Constify psf_hexdump.
+
+2007-04-30 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * src/FLAC
+ Ditch and re-import required FLAC code.
+
+ * configure.ac
+ Force FLAC__HAS_OGG variable to 1.
+
+ * src/FLAC/src/libFLAC/stream_encoder.c
+ Fix compiler warnings.
+
+2007-04-23 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * configure.ac tests/win32_ordinal_test.c
+ Detect if win32 DLL is beging generated and only run win32_ordinal_test if
+ true.
+
+ * src/G72x/Makefile.am src/Makefile.am
+ Use $(EXEEXT) where possible.
+
+2007-04-18 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * src/wve.c src/common.h src/sndfile.c
+ Complete definition of SfE_WVE_NO_WVE error message.
+
+ * src/wve.c
+ Fix error in files generated on big endian systems. Robustify parsing.
+
+2007-04-16 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * src/double64.c
+ Fix clipping of double to short conversions on 64 bit systems.
+
+ * src/flac.c regtest/database.c tests/cpp_test.cc
+ Fix compile warnings for 64 bit systems.
+
+2007-04-15 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * src/wav.c src/wav_w64.c
+ Use audio detect function when 'fmt ' chunk data is suspicious.
+
+ * configure.ac
+ Add ugly hack to remove -Werror from some Makefiles.
+
+2007-04-14 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * src/GSM610/long_term.c src/macbinary3.c tests/cpp_test.cc
+ Add patch from André Pang to clean up compiles on OSX.
+
+ * src/wve.c src/common.h src/sndfile.c src/sndfile.h.in
+ examples/sndfile-convert.c
+ Merge changes from Reuben Thomas to improve WVE support.
+
+ * tests/lossy_comp_test.c tests/Makefile.am
+ Add tests for WVE files.
+
+2007-04-11 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * src/sndfile.hh
+ Add a static SndfileHandle::formatCheck method as suggested by Jorge
+ Jiménez.
+
+2007-04-09 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * src/sndfile.c
+ Fixed a bug in sf_error() where the function itself was being compared
+ against zero. Add a check for a NULL return from peak_info_calloc. Fix a
+ possible NULL dereference.
+
+2007-04-07 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * src/flac.c
+ Turn off seekable flag when writing, return SFE_BAD_RDWR_FORMAT when
+ opening file for RDWR.
+
+ * src/sndfile.c
+ Improve error message for SFE_BAD_RDWR_FORMAT.
+
+ * src/mat4.c
+ Fix array indexing issue. Thanks to Ben Allison (Nullsoft) for alerting me.
+
+2007-03-05 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * doc/FAQ.html
+ Add Q/A 19 on project files.
+
+2007-03-01 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * src/sndfile.c
+ Guard agains MacOSX universal binary compiles.
+
+ * doc/FAQ.html
+ Add Q/A 18 and clean up Q3.
+
+2007-02-22 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * src/aiff.c
+ Add support for 'in24' files.
+
+2007-02-13 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * src/wav.c src/wav_w64.c src/wav_w64.h
+ Start work towards detecting ausio codec type from the actual audio data.
+
+ * src/audio_detect.c src/test_audio_detect.c
+ Add new file and its unit test.
+
+2007-02-07 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * examples/cooledit-fixer.c examples/Makefile.am
+ Remove old broken example program.
+
+2007-02-06 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * src/sndfile.c src/sndfile.h.in src/create_symbols_file.py
+ Add function sf_get_info.
+
+2007-01-25 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * examples/sndfile-play.c
+ For ALSA, use the 'default' device instead of 'plughw:0'.
+
+2007-01-22 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * src/sndfile.c
+ Allow writing of WAV/WAVEX 'BEXT' chunks in SFM_RDWR mode.
+
+2007-01-21 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * doc/development.html doc/embedded_files.html man/sndfile-play.1
+ Minor documentation fixes. Thanks Reuben Thomas.
+
+2006-12-16 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * examples/sndfile-convert.c
+ Add -override-sample-rate command line option.
+
+2006-11-19 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * tests/misc_test.c
+ Force errno to zero at start of some tests.
+
+ * src/sndfile.c
+ Minor clean up of error handling.
+
+ * configure.ac
+ Remove an assembler test which was failing on OSX.
+
+2006-11-15 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * src/common.h
+ Fix the definition of SF_PLATFORM_S64 for MinGW.
+
+ * src/FLAC/Makefile.am src/FLAC/share/grabbag/Makefile.am
+ Fix path problems for MinGW.
+
+2006-11-13 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * src/sfendian.h
+ Add include guard.
+
+ * src/Makefile.am src/flac.c
+ Clean up include paths.
+
+ * src/test_conversions.c
+ New file to test psf_binheader_readf/writef functions.
+
+ * src/Makefile.am src/test_file_io.c src/test_log_printf.c src/common.c
+ Clean up unit testing.
+
+ * src/common.c
+ Fix a bug reading/writing 64 bit header fields. Thanks to Jonathan Woithe
+ for reporting this.
+
+ * src/test_conversions.c
+ Complete unit test for above fix.
+
+2006-11-11 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * src/sndfile.c
+ More refactoring to clean up psf_open_file() and vairous sf_open()
+ functions.
+
+2006-11-09 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * src/wav.c
+ Apply a patch from Jonathan Woithe to allow opening of (malformed) WAV
+ files of over 4 gigabytes.
+
+2006-11-05 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * src/sndfile.c
+ Refactor function psf_open_file() to provide a single return point.
+
+ * tests/misc_test.c
+ Fix permission_test to ensure that read only file can be created.
+
+2006-11-03 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * src/common.h
+ Add SF_PLATFORM_S64 macro as a platform independant way of doing signed 64
+ bit integers.
+
+ * src/aiff.c src/svx.c src/wav.c
+ Add warning in log if files are larger than 4 gigabytes in size.
+
+2006-11-01 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * src/FLAC src/OGG confgure.ac src/Makefile.am
+ Pull in all required FLAC and OGG code so external libraries are not
+ needed. This makes compiling on stupid fscking Windoze easier.
+
+2006-10-27 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * src/sd2.c
+ Add workaround for switched sample rate and sample size.
+
+ * src/wav.c
+ Add workaround for excessively long coding history in the 'bext' chunk.
+
+2006-10-23 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * src/sndfile.h.in src/sndfile.c src/wav.c doc/command.html
+ Use SF_AMBISONIC_* instead of SF_TRUE/SF_FALSE.
+
+2006-10-22 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * src/sndfile.h.in src/wav.c src/wav_w64.c src/common.h doc/command.html
+ Apply a patch from Fons Adriaensen to allow writing on WAVEX Ambisonic
+ files. Still needs a little tweaking before its ready for release.
+
+ * src/*.c
+ Use the UNUSED macro to prevent compiler warnings.
+
+2006-10-19 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * src/aiff.c
+ Fix a bug in parsing AIFF files with a slightly unusual 'basc' chunk. Thanks
+ to David Viens for providing two example files.
+
+ * src/common.(c|h) src/aiff.c
+ Add a function psf_sanitize_string and use it in aiff.c.
+
+2006-10-18 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * src/wav_w64.c
+ Apply a patch from Fons Adriaensen which fixes a minor WAVEX GUID issue.
+
+2006-10-17 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * src/Makefile.am
+ Fix problem related to recent test coverage changes.
+
+2006-10-15 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * configure.ac tests/Makefile.am
+ Add --enable-test-coverage configure option.
+
+2006-10-05 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * src/sndfile.hh
+ Add an std::string SndfileHandle constructor.
+
+ * tests/scale_clip_test.tpl
+ Fix the 'make distcheck' target.
+
+2006-10-03 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * src/double64.c src/float32.c
+ Add optional clipping on float file data to int read data conversions.
+
+ * tests/tests/scale_clip_test.(def|tpl)
+ Add test for above new code.
+
+2006-09-06 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * tests/aiff_rw_test.c
+ Add 'MARK' chunks to make sure they are parsed correctly.
+
+2006-09-05 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * src/aiff.c
+ Fix parsing of MARK chunks. Many thanks to Sciss for generating files to
+ help debug the problem.
+
+2006-09-02 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * src/common.h
+ Make the SF_MIN and SF_MAX macros at least partially type safe.
+
+ * tests/lossy_comp_test.c
+ Fix overflow problems when ensuring that signalis not zero.
+
+2006-08-31 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* configure.ac docs/*.html
Changes for release 1.0.17.
-2006-08-08 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2006-08-08 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* src/flac.c
Remove inline from functions called by pointer. Thanks to Sampo Savolainen
for notifying me of this.
-2006-07-31 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2006-07-31 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* src/sndfile.hh
Add writeSync method.
@@ -21,7 +1677,7 @@
* tests/cpp_test.cc
Cleanup. Add tests.
-2006-07-30 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2006-07-30 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* src/sndfile.hh
Templatize the read/write/readf/writef methods as suggested by Lars Luthman.
@@ -33,7 +1689,7 @@
* tests/cpp_test.cc
Add more tests.
-2006-07-29 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2006-07-29 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* tests/cpp_test.cc
Remove the generated file so "make distcheck" passes.
@@ -44,7 +1700,7 @@
* src/sndfile.hh
Change the license for the C++ wrapper to modified BSD.
-2006-07-28 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2006-07-28 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* src/sndfile.hh
Complete it.
@@ -52,7 +1708,7 @@
* tests/cpp_test.cc
Add more tests.
-2006-07-27 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2006-07-27 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* tests/utils.tpl
Add extern C to generated header file.
@@ -66,7 +1722,7 @@
* configure.ac
Add appropriate CXXFLAGS.
-2006-07-26 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2006-07-26 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* configure.ac
Test if compiler supports -Wpointer-arith.
@@ -74,7 +1730,7 @@
* src/common.c
Fix a warning resulting from -Wpointer-arith.
-2006-07-15 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2006-07-15 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* examples/sndfile-play.c
Explicitly set endian-ness as well as setting 16 bit output.
@@ -88,13 +1744,13 @@
* src/wav_w64.[ch]
Minor clean up, add detection of IPP ITU G723.1.
-2006-06-23 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2006-06-23 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* src/sndfile.c
Make sure psf->dataoffset gets reset to zero when openning headersless
files based on the file name extension.
-2006-06-21 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2006-06-21 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* tests/(command|lossy_comp|pcm|scale_clip)_test.c tests/fix_this.c
tests/write_read_test.(tpl|def)
@@ -104,7 +1760,7 @@
* examples/cooledit-fixer.c
More fixes like above.
-2006-06-20 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2006-06-20 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* src/file_io.c
Fix a windows bug where the syserr string of SF_PRIVATE was not being set
@@ -113,17 +1769,17 @@
* src/sndfile.c
Fixed a logic bug in sf_seek(). Thanks to Paul Davis for finding this.
-2006-06-04 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2006-06-04 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* configure.ac
Fixed detection of S_IRGRP.
-2006-05-30 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2006-05-30 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* sndfile-convert.c
Add conversion SF_INSTRUMENT data when present.
-2006-05-22 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2006-05-22 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* doc/development.html
Removed references to tla on windows.
@@ -142,7 +1798,7 @@
src/(sndfile|voc|vox_adpcm|xi).c
Remove fdata field from SF_PRIVATE struct and replace it with codec_data.
-2006-05-10 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2006-05-10 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* Win32/testprog.c Win32/Makefile.am
Add a minimal win32 test program.
@@ -150,17 +1806,17 @@
* Win32/README-precompiled-dll.txt Mingw-make-dist.sh
Update readme and Mingw build script.
-2006-05-09 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2006-05-09 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* configure.ac acinclude.m4
Minor fixes for Solaris.
-2006-05-05 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2006-05-05 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* src/test_endswap.(def|tpl)
Fix printf formatting for int64_t on 64 bit machines.
-2006-05-04 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2006-05-04 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* src/binhead_check.py
New file to check for bad parameters passed to psf_binheader_writef().
@@ -174,20 +1830,20 @@
* src/double64.c
Clean up double64_get_capability().
-2006-05-03 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2006-05-03 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* src/wav_w64.c
Fix a bug on x86_64 where an int was being passed via stdargs and being
read using size_t which is 64 bits. Thenks to John ffitch for giving me a
login on his box.
-2006-05-02 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2006-05-02 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* src/caf.c src/double64.c examples/sndfile-info.c tests/virtual_io_test.c
tests/utils.tpl
Fix a couple of signed/unsigned problems.
-2006-05-01 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2006-05-01 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* tests/command_test.c
Add channel map tests.
@@ -196,7 +1852,7 @@
Add a pointer the the SF_PRIVATE struct and make sure it gets freed in
sf_close().
-2006-04-30 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2006-04-30 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* configure.ac doc/(command|index|api).html NEWS README
Updates for 1.0.16 release.
@@ -207,7 +1863,7 @@
* examples/sndfile-info.c
Clean up usage of SF_INFO struct.
-2006-04-29 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2006-04-29 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* tests/util.tpl
Add function testing function exit_if_true().
@@ -215,7 +1871,7 @@
* tests/floating_point_test.tpl
Fix a problem where the test program was not exiting when the test failed.
-2006-04-15 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2006-04-15 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* src/sndfile.h.in src/sndfile.c src/common.h src/command.c
Implement new commands SFC_GET_SIGNAL_MAX and SFC_GET_MAX_ALL_CHANNELS.
@@ -226,7 +1882,7 @@
* tests/peak_chunk_test.c
Update tests for new commands.
-2006-04-02 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2006-04-02 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* tests/peak_chunk_test.c
Add test for RIFX and WAVEX files.
@@ -235,7 +1891,7 @@
* src/sndfile.c
Fix a bug where enabling and disabling PEAK chunk was screwing up.
-2006-03-31 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2006-03-31 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* src/sndfile.h.in
Add the block of 190 reserved bytes into this struct to allow for
@@ -250,7 +1906,7 @@
* tests/command_test.c tests/Makefile.am
Complete bext tests, hook test in test suite.
-2006-03-30 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2006-03-30 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* src/sndfile.h.in
Make coding_history field of SF_BROADCAST_INFO struct a char array instead
@@ -266,19 +1922,19 @@
* src/wav.c
Ignore and skip the 'levl' chunk.
-2006-03-26 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2006-03-26 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* configure.ac
Fix handling of --enable and --disable configure args. Thanks to Diego
'Flameeyes' Pettenò who sent the patch.
-2006-03-22 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2006-03-22 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* doc/win32.html
Make it really clear that although the MSVC++ cannot compile libsndfile,
the precompiled DLL can be used in C++ programs compiled with MSVC++.
-2006-03-18 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2006-03-18 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* src/aiff.c
Fix bug in writing of INST chunk in AIFF files.
@@ -293,7 +1949,7 @@
* tests/utils.tpl
Add usage of space character to psf_binheader_writef.
-2006-03-17 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2006-03-17 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* src/Makefile.am tests/Makefile.am
Remove --source-time argument from autogen command lines.
@@ -304,7 +1960,7 @@
* src/sndfile.c src/sndfile.h.in src/wav.c src/common.h
Add patch from Paul Davis implementing read/write of the BEXT chunk.
-2006-03-16 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2006-03-16 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* Win32/README-precompiled-dll.txt
New file descibing how to use the precompiled DLL.
@@ -315,7 +1971,7 @@
* configure.ac
Bump version to 1.0.15.
-2006-03-11 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2006-03-11 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* src/wav.c
On read, only add the endian flag if the file is big endian.
@@ -326,7 +1982,7 @@
* tests/write_read_test.tpl tests/lossy_comp_test.c
Add tests for RIFX files.
-2006-03-10 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2006-03-10 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* Mingw-make-dist.sh
Bunch of improvements.
@@ -334,7 +1990,7 @@
* doc/win32.html
Update MinGW program versions.
-2006-03-09 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2006-03-09 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* src/create_symbols_file.py
Fix the library name in created win32 DEF file. Add correct DLL name for
@@ -352,7 +2008,7 @@
* src/wav.c src/wav_w64.c src/sndfile.c src/sndfile.h.in
Apply large patch from Jesse Chappell which adds support for RIFX files.
-2006-03-08 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2006-03-08 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* Makefile.am
Add Mingw-make-dist.sh to the extra dist files.
@@ -364,7 +2020,7 @@
New test program to test that the win32 DLL ordinals agree with the DEF
file.
-2006-03-04 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2006-03-04 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* src/common.h
Add a static inline function to convert an int to a size_t. This will be
@@ -378,7 +2034,7 @@
Add a workaround for situations where OSX seems to add an extra 0x52 bytes
to the start of the resource fork.
-2006-02-19 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2006-02-19 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* Mingw-make-dist.sh
Add a shell script to build the windows binary/source ZIP file.
@@ -393,17 +2049,17 @@
* configure.ac
Bump version to 1.0.14.
-2006-02-11 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2006-02-11 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* src/sd2.c
Improve logging of errors in resource fork parser.
-2006-01-31 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2006-01-31 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* Win32/Makefile.msvc
Replace au_g72x.* with g72x.*. Thanks to ussell Borogove.
-2006-01-29 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2006-01-29 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* src/common.c
Make sure return values are initialised header buffer is full.
@@ -411,7 +2067,7 @@
* src/wav.c
Add workarounds for messed up WAV files.
-2006-01-21 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2006-01-21 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* Win32/config.h
Undef HAVE_INTTYPES_H for win32.
@@ -425,7 +2081,7 @@
* doc/*.html NEWS README
Update version numbers.
-2006-01-19 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2006-01-19 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* src/xi.c
Start work on add read/write of instrument chunks.
@@ -438,7 +2094,7 @@
automatically because it requires 3 Gig of disk space and takes 3 minutes
to run.
-2006-01-10 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2006-01-10 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* examples/sndfile-play.c
Fix calculation of samples remaining in win32 code. Thanks Axel Roebel.
@@ -447,10 +2103,10 @@
Make sure length of header buffer can hold header plus strings. Thanks Axel
Roebel.
-2006-01-09 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2006-01-09 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* src/sndfile.h.in src/aiff.c src/wav.c
- Apply a patch from John Fitch (Csound project).
+ Apply a patch from John ffitch (Csound project).
Add detune field to SF_INSTRUMENT struct.
Add reading/writing instrument chunks to WAV files.
@@ -460,7 +2116,7 @@
* tests/Makefile.am
Hook instrument tests into test suite.
-2006-01-05 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2006-01-05 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* configure.ac
Check for <inttypes.h> because some broken systems (like Solaris) don't have
@@ -469,7 +2125,7 @@
* src/sfendian.h src/common.h
Use <inttypes.h> if <stdint.h> is not available.
-2005-12-30 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2005-12-30 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* tests/peak_chunk_test.c
Extend and clean up tests.
@@ -477,7 +2133,7 @@
* src/sndfile.c
Fix a bug that prevented the turning off of PEAK chunks.
-2005-12-29 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2005-12-29 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* tests/error_test.c
Make the test distclean correct.
@@ -485,13 +2141,13 @@
* src/file_io.c
Fix an SD2 MacOSX bug (reported by vince schwarzinger).
-2005-12-28 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2005-12-28 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* src/aiff.c tests/command_test.c
Apply a big patch from John ffitch (Csound project) to add reading and
writing of instrument chunks to AIFF files. Also update the test.
-2005-12-10 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2005-12-10 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* tests/aiff_rw_test.c tests/virtual_io_test.c tests/utils.tpl
Move test function dump_data_to_file() to utils.tpl.
@@ -500,7 +2156,7 @@
Updates, including a new test to test that sf_error() returns a valid error
number.
-2005-12-07 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2005-12-07 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* examples/list_formats.c
Make sure the SF_INFO struct is memset to all zero before being used.
@@ -509,7 +2165,7 @@
* src/sndfile.c
Make the return value of sf_error() match the API documentation.
-2005-11-19 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2005-11-19 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* examples/sndfile-convert.c
Allow conversion to raw gsm610.
@@ -523,7 +2179,7 @@
* src/sndfile.c
Rejig file extension based file type detection.
-2005-11-16 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2005-11-16 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* src/sndfile.c
Add "gsm" as a recognised file extension when no magic number can be found.
@@ -531,12 +2187,12 @@
* tests/lossy_comp_test.c tests/Makefile.am
Test headerless GSM610.
-2005-11-13 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2005-11-13 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* doc/api.html
Fix a minor typo and a minor error. Thanks Christoph Kobe and John Pavel.
-2005-10-30 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2005-10-30 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* src/wav_w64.c
Add more reporting of 'fmt ' chunk for G721 encoded files.
@@ -544,12 +2200,12 @@
* src/wav.c
Gernerate a more correct 20 byte 'fmt ' chunk rather than a 16 byte one.
-2005-10-29 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2005-10-29 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* src/G72x/g72x.[ch]
Minor cleanup of interface.
-2005-10-28 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2005-10-28 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* src/ogg.c
Removed the horribly broken and non-functional OGG implementation when
@@ -559,7 +2215,7 @@
* src/caf.c
Fix a memory leak.
-2005-10-27 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2005-10-27 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* src/g72x.c src/G72x/*.(c|h) src/common.h src/sndfile.c src/wav.c src/au.c
Add support for G721 encoded WAV files.
@@ -591,7 +2247,7 @@
* src/*.c
Fix knock on effects of above.
-2005-10-26 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2005-10-26 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* examples/sndfile-info.c
Complete dumping SF_INSTRUMENT data.
@@ -603,13 +2259,13 @@
Add a string comment to the end of the files to make sure that the decoder
doesn't decode beyond the end of the audio data section.
-2005-10-25 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2005-10-25 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* examples/sndfile-info.c
Minor code cleanup.
Start work on dumping SF_INSTRUMENT data.
-2005-10-23 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2005-10-23 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* src/sndfile.h.in src/common.h src/common.c
Update definition of SF_INSTRUMENT struct and create a function to allocate
@@ -629,17 +2285,17 @@
Add test for set and getof SF_INSTRUMENT data.
The file command_test.c is no longer autogen generated.
-2005-10-15 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2005-10-15 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* src/gsm610.c
Minor cleanup.
-2005-10-14 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2005-10-14 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* tests/lossy_comp_test.c
Minor cleanup.
-2005-10-13 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2005-10-13 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* src/*.c
Ensure sfconfig.h is included before any other header file.
@@ -650,12 +2306,12 @@
* src/gsm610.c
Make sure SF_FORMAT_WAVEX are handled correctly.
-2005-10-07 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2005-10-07 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* configure.ac
Add options to allow disabling of FLAC and ALSA. Suggested by Ben Greear.
-2005-09-30 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2005-09-30 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* tests/locale_test.c
Modify the way the unicode strings were encoded so that older compilers
@@ -667,17 +2323,17 @@
* NEWS README Win32/config.h doc/(FAQ|index.html|command|api).html
Update version numbers.
-2005-09-26 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2005-09-26 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* src/flac.c
Fix valgrind error and minor cleanup.
-2005-09-25 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2005-09-25 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* src/(au|paf|aiff|w64|wav|svx).c
Make sure structs are initialised.
-2005-09-24 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2005-09-24 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* configure.ac
Make -Wdeclaration-after-statement work with --enable-gcc-werror configure
@@ -685,23 +2341,23 @@
Add -std=gnu99 (C99 plus posix style stuff like gmtime_r) to CFLAGS if the
compiler supports it.
-2005-09-23 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2005-09-23 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* configure.ac acinclude.m4
Add -Wdeclaration-after-statement to CFLAGS if the compilers supports it.
-2005-09-22 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2005-09-22 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* tests/util.(tpl|def)
Make the test_write_*_or_die() functions const safe.
-2005-09-21 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2005-09-21 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* src/nist.c
Make sure the data offset is read from the file header. Thanks to
David A. van Leeuwen for a patch.
-2005-09-20 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2005-09-20 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* configure.ac src/sfconfig.h
Check for <locale.h> and the function setlocale().
@@ -710,7 +2366,7 @@
* tests/locale_test.c tests/Makefile.am
Add new test program and hook into build/test system.
-2005-09-18 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2005-09-18 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* src/common.h src/file_io.c
On windows, use windows specific types for file handles.
@@ -722,14 +2378,14 @@
* src/sndfile.c src/test_file_io.c
Fix knock on effects.
-2005-09-06 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2005-09-06 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* src/float_cast.h
The lrint and lrintf implementations in Cygwin are both buggy and slow.
Add replacements which were pulled from the Public Domain MinGW math.h
header file.
-2005-09-05 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2005-09-05 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* tests/(lossy_comp_test|virtual_io_test).c
More Valgrind fixups.
@@ -740,7 +2396,7 @@
* Win32/config.h Win32/sndfile.h Win32/Makefile.msvc
Update build for MSVC.
-2005-09-04 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2005-09-04 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* tests/lossy_comp_test.c
Make sure to close SNDFILE when exiting test when file format is not seekable.
@@ -748,7 +2404,7 @@
* tests/(aiff_rw_test|virtual_io_test).c
Do a few valgrind fix ups.
-2005-09-03 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2005-09-03 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* src/float32.c src/double64.c
Replace floating point equality comparisons with greater/less comparisons.
@@ -764,18 +2420,18 @@
* src/file_io.c
Remove Mac OS9 Metrowerks compiler specific hacks.
-2005-08-31 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2005-08-31 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* src/w64.c
Cast integer literal to sf_count_t in call to psf_binheader_writef() to
prevent Valgrind error.
-2005-08-30 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2005-08-30 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* doc/command.html
Improve documentation of SF_GET_FORMAT_SUBTYPE.
-2005-08-26 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2005-08-26 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* examples/sndfile-convert.c
Allow files to be converted to SD2 format.
@@ -784,17 +2440,17 @@
Fix a bug in reading and writing of SD2 files on little endian CPUs.
Thanks to Matthew Willis for finding this.
-2005-08-25 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2005-08-25 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* doc/api.html
Update Note2 to point to SFC_SET_SCALE_FLOAT_INT_READ.
-2005-08-16 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2005-08-16 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* configure.ac
Use $host_os instead of $target_os (thanks to Mo De Jong).
-2005-08-15 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2005-08-15 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* src/Makefile.am
Apply a patch from Mo DeJong to allow building outside of the source dir.
@@ -806,7 +2462,7 @@
Move some code from wav.c to wav_w64.c to improve the log output of files of
type WAVE_FORMAT_EXTENSIBLE.
-2005-08-10 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2005-08-10 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* src/create_symbols_file.py
Make sure sf_write_fsync is an exported symbol.
@@ -814,7 +2470,7 @@
* examples/sndfile-convert.c
Add support for writing VOX adpcm files.
-2005-07-31 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2005-07-31 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* doc/api.html
Document the new function sf_write_sync().
@@ -822,7 +2478,7 @@
* doc/FAQ.html
Do you plan to support XYZ codec.
-2005-07-28 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2005-07-28 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* src/sndfile.h.in src/sndfile.c
Add function sf_write_sync() to the API.
@@ -833,7 +2489,7 @@
* tests/write_read_test.tpl
Use the new function in the tests.
-2005-07-24 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2005-07-24 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* src/common.h src/double64.c src/float32.c src/sndfile.c
Change the way PEAK chunk info is stored. Peaks now stored as an sf_count_t
@@ -846,7 +2502,7 @@
Implement 'peak' chunk for file wuth data in SF_FORMAT_FLOAT or
SF_FORMAT_DOUBLE format.
-2005-07-23 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2005-07-23 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* src/nist.c
Fix a bug where a variable was being used without being initialized.
@@ -858,7 +2514,7 @@
* src/aiff.c src/wav.c
Fix allocation for PEAK_CHUNK (bug found using valgrind).
-2005-07-21 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2005-07-21 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* src/common.h
Move the peak_loc field of SF_PRIVATE to the PEAK_CHUNK struct.
@@ -868,12 +2524,12 @@
* src/aiff.c src/caf.c src/wav.c src/float32.c src/double64.c
Fix knock on effects from above.
-2005-07-19 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2005-07-19 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* src/wav.c
Prevent files with unknown chunks from being opened read/write.
-2005-07-14 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2005-07-14 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* src/flac.c
Do not use psf->end_of_file because it never gets set to anything.
@@ -881,7 +2537,7 @@
* src/common.h
Remove unused SF_PRIVATE field end_of_file.
-2005-07-12 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2005-07-12 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* src/common.c
Change the 'S' format specifier of psf_binheader_writef() to write AIFF
@@ -891,7 +2547,7 @@
Move to new (correct) AIFF string style. Thanks to Axel Roebel for being
so persistent on this issue.
-2005-07-11 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2005-07-11 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* src/sndfile.c
Allow SFE_UNSUPPORTED_FORMAT as an error from sf_open().
@@ -902,7 +2558,7 @@
* src/mat5.c
Modify the way the header is written.
-2005-07-10 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2005-07-10 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* src/caf.c
Add a 'free' chunk to the written file so that the audio data starts at
@@ -911,7 +2567,7 @@
* src/sndfile.c
Allow SFE_UNSUPPORTED_FORMAT as an error from sf_open().
-2005-07-09 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2005-07-09 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* src/caf.c src/sndfile.c
Add support for signed 8 bit integers.
@@ -922,7 +2578,7 @@
* doc/index.html
Update matrix for signed 8 bit integers in CAF files.
-2005-07-08 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2005-07-08 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* src/sndfile.c
Update sf_check_format() to support CAF.
@@ -943,7 +2599,7 @@
tests/header_test.tpl misc_test.c
Add tests for CAF files.
-2005-07-07 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2005-07-07 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* doc/FAQ.html
Fix Q/A about reading/writing memory buffers.
@@ -951,7 +2607,7 @@
* src/caf.c
Bunch of work to support reading of CAF files.
-2005-07-04 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2005-07-04 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* src/(aiff|ima_adpcm|mat4|mat5|ms_adpcm).c examples/sndfile-play.c
Fix sign conversion errors reported by gcc-4.0.
@@ -962,7 +2618,7 @@
* src/sndfile.c src/common.h src/sndfile.h.in src/Makefile.am
Hook new file into build system.
-2005-06-21 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2005-06-21 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* src_wav_w64.c
Fix handling of stupidly large 'fmt ' chunks. Thanks to Vadim Berezniker
@@ -971,7 +2627,7 @@
* src/common.h src/sndfile.c
Remove redundant error code SFE_WAV_FMT_TOO_BIG.
-2005-06-20 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2005-06-20 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* src/sndfile.h.in src/common.h src/sndfile.c
Add public error value SF_ERR_MALFORMED_FILE.
@@ -986,7 +2642,7 @@
* regtest/database.c regtest/sndfile-regtest.c
Fix compiling when sqlite is missing.
-2005-06-11 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2005-06-11 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* src/file_io.c
Fix psf_is_pipe() and return value of psf_fread() when using virtual i/o.
@@ -1003,7 +2659,7 @@
* src/(sndfile.h.in|file_io.c|common.h|sndfile.c) tests/virtual_io_test.c
Rename some of the virtual i/o functions and data types.
-2005-06-10 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2005-06-10 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* src/sndfile.c
Fix the return values of sf_commands : SFC_SET_NORM_DOUBLE,
@@ -1014,7 +2670,7 @@
Correct documented return values for SFC_SET_NORM_DOUBLE and
SFC_SET_NORM_FLOAT. Thanks to Kyroz again.
-2005-05-17 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2005-05-17 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* regtest/*
Add new files for sndfile-regtest program.
@@ -1026,7 +2682,7 @@
Fix a regression where long ICMT chunks were causing the WAV parser
to exit.
-2005-05-15 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2005-05-15 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* libsndfile.spec.in
Add html docs to the files section as suggested by Karsten Jeppesen.
@@ -1034,17 +2690,17 @@
* src/aiff.c
Fix parsing of odd length ANNO chunks.
-2005-05-13 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2005-05-13 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* src/common.h
Change the include guard to prevent clashes with other code.
-2005-05-12 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2005-05-12 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* examples/sndfile-play.c
Improve error handling in code for playback under Linux/ALSA.
-2005-05-10 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2005-05-10 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* src/ircam.c
Fix writing of IRCAM files on big endian systems (thanks to Axel Roebel).
@@ -1054,7 +2710,7 @@
produce files with very short LIST chunks (thanks to Jonathan Segel who
supplied the file).
-2005-04-30 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2005-04-30 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* src/aiff.c
Apply a patch From David Viens to make the parsing of basc chunks more
@@ -1064,13 +2720,13 @@
Another patch from David Viens to write correct wavex channel masks for
the most common channel configurations.
-2005-04-08 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2005-04-08 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* src/command.c
Only allow FLAC in the format arrays if FLAC is enabled. Thanks to
Leigh Smith.
-2005-03-09 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2005-03-09 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* src/common.h
Add a directory field for storing the file directory to the SF_PRIVATE
@@ -1083,13 +2739,13 @@
Cleanup psf_open_rsrc() and also check for resource fork in
.AppleDouble/filename.
-2005-03-01 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2005-03-01 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* src/svx.c
Fix a bug in the printing of the channel count. Bug reported by Michael
Schwendt. Thanks.
-2005-01-26 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2005-01-26 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* src/paf.c
Fix a seek bug for 24 bit PAF files.
@@ -1097,7 +2753,7 @@
* tests/write_read_test.tpl
Update write_read_test to trigger the previously hidden PAF seek bug.
-2005-01-25 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+2005-01-25 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* src/aiff.c src/w64.c src/wav.c
Do not return a header parse error when the log buffer overflows.
@@ -2162,7 +3818,7 @@
* src/*.c examples/*.c tests/*.c
Fix all compiler warnings arising from the above.
-2003-08-02
+2003-08-02 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* tests/aiff_rw_test.c tests/Makefile.am
New test program to check for errors re-writing the headers of AIFC files
Added: freeswitch/trunk/libs/libsndfile/M4/Makefile.am
==============================================================================
--- (empty file)
+++ freeswitch/trunk/libs/libsndfile/M4/Makefile.am Thu May 21 16:09:30 2009
@@ -0,0 +1,5 @@
+## Process this file with automake to produce Makefile.in
+
+EXTRA_DIST = add_cflags.m4 clip_mode.m4 endian.m4 extra_largefile.m4 \
+ flexible_array.m4 llrint.m4 lrint.m4 lrintf.m4 octave.m4 extra_pkg.m4
+
Added: freeswitch/trunk/libs/libsndfile/M4/Makefile.in
==============================================================================
--- (empty file)
+++ freeswitch/trunk/libs/libsndfile/M4/Makefile.in Thu May 21 16:09:30 2009
@@ -0,0 +1,394 @@
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+ at SET_MAKE@
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+target_triplet = @target@
+subdir = M4
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/M4/add_cflags.m4 \
+ $(top_srcdir)/M4/add_cxxflags.m4 $(top_srcdir)/M4/clip_mode.m4 \
+ $(top_srcdir)/M4/endian.m4 $(top_srcdir)/M4/extra_largefile.m4 \
+ $(top_srcdir)/M4/extra_pkg.m4 \
+ $(top_srcdir)/M4/flexible_array.m4 \
+ $(top_srcdir)/M4/gcc_version.m4 $(top_srcdir)/M4/libtool.m4 \
+ $(top_srcdir)/M4/lrint.m4 $(top_srcdir)/M4/lrintf.m4 \
+ $(top_srcdir)/M4/ltoptions.m4 $(top_srcdir)/M4/ltsugar.m4 \
+ $(top_srcdir)/M4/ltversion.m4 $(top_srcdir)/M4/lt~obsolete.m4 \
+ $(top_srcdir)/M4/mkoctfile_version.m4 \
+ $(top_srcdir)/M4/octave.m4 $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/src/config.h
+CONFIG_CLEAN_FILES =
+SOURCES =
+DIST_SOURCES =
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+ACLOCAL_AMFLAGS = @ACLOCAL_AMFLAGS@
+ALSA_LIBS = @ALSA_LIBS@
+AMTAR = @AMTAR@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+COMPILER_IS_GCC = @COMPILER_IS_GCC@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+ENABLE_EXPERIMENTAL_CODE = @ENABLE_EXPERIMENTAL_CODE@
+EXEEXT = @EXEEXT@
+EXTERNAL_CFLAGS = @EXTERNAL_CFLAGS@
+EXTERNAL_LIBS = @EXTERNAL_LIBS@
+FGREP = @FGREP@
+FLAC_CFLAGS = @FLAC_CFLAGS@
+FLAC_LIBS = @FLAC_LIBS@
+GCC_MAJOR_VERSION = @GCC_MAJOR_VERSION@
+GCC_MINOR_VERSION = @GCC_MINOR_VERSION@
+GCC_VERSION = @GCC_VERSION@
+GETCONF = @GETCONF@
+GREP = @GREP@
+HAVE_AUTOGEN = @HAVE_AUTOGEN@
+HAVE_JACK = @HAVE_JACK@
+HAVE_MKOCTFILE = @HAVE_MKOCTFILE@
+HAVE_OCTAVE = @HAVE_OCTAVE@
+HAVE_OCTAVE_CONFIG = @HAVE_OCTAVE_CONFIG@
+HAVE_WINE = @HAVE_WINE@
+HTML_BGCOLOUR = @HTML_BGCOLOUR@
+HTML_FGCOLOUR = @HTML_FGCOLOUR@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+JACK_CFLAGS = @JACK_CFLAGS@
+JACK_LIBS = @JACK_LIBS@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIBTOOL_DEPS = @LIBTOOL_DEPS@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+MKOCTFILE = @MKOCTFILE@
+MKOCTFILE_VERSION = @MKOCTFILE_VERSION@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OCTAVE = @OCTAVE@
+OCTAVE_CONFIG = @OCTAVE_CONFIG@
+OCTAVE_CONFIG_VERSION = @OCTAVE_CONFIG_VERSION@
+OCTAVE_DEST_MDIR = @OCTAVE_DEST_MDIR@
+OCTAVE_DEST_ODIR = @OCTAVE_DEST_ODIR@
+OCTAVE_VERSION = @OCTAVE_VERSION@
+OGG_CFLAGS = @OGG_CFLAGS@
+OGG_LIBS = @OGG_LIBS@
+OS_SPECIFIC_CFLAGS = @OS_SPECIFIC_CFLAGS@
+OS_SPECIFIC_LINKS = @OS_SPECIFIC_LINKS@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PKG_CONFIG = @PKG_CONFIG@
+RANLIB = @RANLIB@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SF_COUNT_MAX = @SF_COUNT_MAX@
+SHARED_VERSION_INFO = @SHARED_VERSION_INFO@
+SHELL = @SHELL@
+SHLIB_VERSION_ARG = @SHLIB_VERSION_ARG@
+SIZEOF_SF_COUNT_T = @SIZEOF_SF_COUNT_T@
+SQLITE3_CFLAGS = @SQLITE3_CFLAGS@
+SQLITE3_LIBS = @SQLITE3_LIBS@
+STRIP = @STRIP@
+TYPEOF_SF_COUNT_T = @TYPEOF_SF_COUNT_T@
+VERSION = @VERSION@
+VORBISENC_CFLAGS = @VORBISENC_CFLAGS@
+VORBISENC_LIBS = @VORBISENC_LIBS@
+VORBIS_CFLAGS = @VORBIS_CFLAGS@
+VORBIS_LIBS = @VORBIS_LIBS@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+htmldocdir = @htmldocdir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+lt_ECHO = @lt_ECHO@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target = @target@
+target_alias = @target_alias@
+target_cpu = @target_cpu@
+target_os = @target_os@
+target_vendor = @target_vendor@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+EXTRA_DIST = add_cflags.m4 clip_mode.m4 endian.m4 extra_largefile.m4 \
+ flexible_array.m4 llrint.m4 lrint.m4 lrintf.m4 octave.m4 extra_pkg.m4
+
+all: all-am
+
+.SUFFIXES:
+$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
+ && exit 0; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu M4/Makefile'; \
+ cd $(top_srcdir) && \
+ $(AUTOMAKE) --gnu M4/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+tags: TAGS
+TAGS:
+
+ctags: CTAGS
+CTAGS:
+
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+ fi; \
+ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+ else \
+ test -f $(distdir)/$$file \
+ || cp -p $$d/$$file $(distdir)/$$file \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-am
+all-am: Makefile
+installdirs:
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool mostlyclean-am
+
+distclean: distclean-am
+ -rm -f Makefile
+distclean-am: clean-am distclean-generic
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-info: install-info-am
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-ps: install-ps-am
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-generic mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: install-am install-strip
+
+.PHONY: all all-am check check-am clean clean-generic clean-libtool \
+ distclean distclean-generic distclean-libtool distdir dvi \
+ dvi-am html html-am info info-am install install-am \
+ install-data install-data-am install-dvi install-dvi-am \
+ install-exec install-exec-am install-html install-html-am \
+ install-info install-info-am install-man install-pdf \
+ install-pdf-am install-ps install-ps-am install-strip \
+ installcheck installcheck-am installdirs maintainer-clean \
+ maintainer-clean-generic mostlyclean mostlyclean-generic \
+ mostlyclean-libtool pdf pdf-am ps ps-am uninstall uninstall-am
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
Added: freeswitch/trunk/libs/libsndfile/M4/add_cflags.m4
==============================================================================
--- (empty file)
+++ freeswitch/trunk/libs/libsndfile/M4/add_cflags.m4 Thu May 21 16:09:30 2009
@@ -0,0 +1,17 @@
+dnl @synopsis AC_ADD_CFLAGS
+dnl
+dnl Add the given option to CFLAGS, if it doesn't break the compiler
+
+AC_DEFUN([AC_ADD_CFLAGS],
+[AC_MSG_CHECKING([if $CC accepts $1])
+ ac_add_cflags__old_cflags="$CFLAGS"
+ CFLAGS="$CFLAGS $1"
+ AC_TRY_LINK([
+ #include <stdio.h>
+ ],
+ [puts("Hello, World!"); return 0;],
+ AC_MSG_RESULT([yes]),
+ AC_MSG_RESULT([no])
+ CFLAGS="$ac_add_cflags__old_cflags"
+ )
+])# AC_ADD_CFLAGS
Added: freeswitch/trunk/libs/libsndfile/M4/add_cxxflags.m4
==============================================================================
--- (empty file)
+++ freeswitch/trunk/libs/libsndfile/M4/add_cxxflags.m4 Thu May 21 16:09:30 2009
@@ -0,0 +1,17 @@
+dnl @synopsis AC_ADD_CXXFLAGS
+dnl
+dnl Add the given option to CXXFLAGS, if it doesn't break the compiler
+
+AC_DEFUN([AC_ADD_CXXFLAGS],
+[AC_MSG_CHECKING([if $CXX accepts $1])
+ ac_add_cxxflags__old_cxxflags="$CXXFLAGS"
+ CXXFLAGS="$CXXFLAGS $1"
+ AC_TRY_LINK([
+ #include <cstdio>
+ ],
+ [puts("Hello, World!"); return 0;],
+ AC_MSG_RESULT([yes]),
+ AC_MSG_RESULT([no])
+ CXXFLAGS="$ac_add_cxxflags__old_cxxflags"
+ )
+])# AC_ADD_CXXFLAGS
Added: freeswitch/trunk/libs/libsndfile/M4/clip_mode.m4
==============================================================================
--- (empty file)
+++ freeswitch/trunk/libs/libsndfile/M4/clip_mode.m4 Thu May 21 16:09:30 2009
@@ -0,0 +1,124 @@
+dnl @synopsis AC_C_CLIP_MODE
+dnl
+dnl Determine the clipping mode when converting float to int.
+dnl @version 1.0 May 17 2003
+dnl @author Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+dnl
+dnl Permission to use, copy, modify, distribute, and sell this file for any
+dnl purpose is hereby granted without fee, provided that the above copyright
+dnl and this permission notice appear in all copies. No representations are
+dnl made about the suitability of this software for any purpose. It is
+dnl provided "as is" without express or implied warranty.
+
+
+
+
+
+
+
+dnl Find the clipping mode in the following way:
+dnl 1) If we are not cross compiling test it.
+dnl 2) IF we are cross compiling, assume that clipping isn't done correctly.
+
+AC_DEFUN([AC_C_CLIP_MODE],
+[AC_CACHE_CHECK(processor clipping capabilities,
+ ac_cv_c_clip_type,
+
+# Initialize to unknown
+ac_cv_c_clip_positive=unknown
+ac_cv_c_clip_negative=unknown
+
+
+if test $ac_cv_c_clip_positive = unknown ; then
+ AC_TRY_RUN(
+ [[
+ #define _ISOC9X_SOURCE 1
+ #define _ISOC99_SOURCE 1
+ #define __USE_ISOC99 1
+ #define __USE_ISOC9X 1
+ #include <math.h>
+ int main (void)
+ { double fval ;
+ int k, ival ;
+
+ fval = 1.0 * 0x7FFFFFFF ;
+ for (k = 0 ; k < 100 ; k++)
+ { ival = (lrint (fval)) >> 24 ;
+ if (ival != 127)
+ return 1 ;
+
+ fval *= 1.2499999 ;
+ } ;
+
+ return 0 ;
+ }
+ ]],
+ ac_cv_c_clip_positive=yes,
+ ac_cv_c_clip_positive=no,
+ ac_cv_c_clip_positive=unknown
+ )
+
+ AC_TRY_RUN(
+ [[
+ #define _ISOC9X_SOURCE 1
+ #define _ISOC99_SOURCE 1
+ #define __USE_ISOC99 1
+ #define __USE_ISOC9X 1
+ #include <math.h>
+ int main (void)
+ { double fval ;
+ int k, ival ;
+
+ fval = -8.0 * 0x10000000 ;
+ for (k = 0 ; k < 100 ; k++)
+ { ival = (lrint (fval)) >> 24 ;
+ if (ival != -128)
+ return 1 ;
+
+ fval *= 1.2499999 ;
+ } ;
+
+ return 0 ;
+ }
+ ]],
+ ac_cv_c_clip_negative=yes,
+ ac_cv_c_clip_negative=no,
+ ac_cv_c_clip_negative=unknown
+ )
+ fi
+
+if test $ac_cv_c_clip_positive = yes ; then
+ ac_cv_c_clip_positive=1
+else
+ ac_cv_c_clip_positive=0
+ fi
+
+if test $ac_cv_c_clip_negative = yes ; then
+ ac_cv_c_clip_negative=1
+else
+ ac_cv_c_clip_negative=0
+ fi
+
+[[
+case "$ac_cv_c_clip_positive$ac_cv_c_clip_negative" in
+ "00")
+ ac_cv_c_clip_type="none"
+ ;;
+ "10")
+ ac_cv_c_clip_type="positive"
+ ;;
+ "01")
+ ac_cv_c_clip_type="negative"
+ ;;
+ "11")
+ ac_cv_c_clip_type="both"
+ ;;
+ esac
+ ]]
+
+)
+]
+
+)# AC_C_CLIP_MODE
+
+
Added: freeswitch/trunk/libs/libsndfile/M4/endian.m4
==============================================================================
--- (empty file)
+++ freeswitch/trunk/libs/libsndfile/M4/endian.m4 Thu May 21 16:09:30 2009
@@ -0,0 +1,159 @@
+dnl @synopsis AC_C_FIND_ENDIAN
+dnl
+dnl Determine endian-ness of target processor.
+dnl @version 1.1 Mar 03 2002
+dnl @author Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+dnl
+dnl Majority written from scratch to replace the standard autoconf macro
+dnl AC_C_BIGENDIAN. Only part remaining from the original it the invocation
+dnl of the AC_TRY_RUN macro.
+dnl
+dnl Permission to use, copy, modify, distribute, and sell this file for any
+dnl purpose is hereby granted without fee, provided that the above copyright
+dnl and this permission notice appear in all copies. No representations are
+dnl made about the suitability of this software for any purpose. It is
+dnl provided "as is" without express or implied warranty.
+
+dnl Find endian-ness in the following way:
+dnl 1) Look in <endian.h>.
+dnl 2) If 1) fails, look in <sys/types.h> and <sys/param.h>.
+dnl 3) If 1) and 2) fails and not cross compiling run a test program.
+dnl 4) If 1) and 2) fails and cross compiling then guess based on target.
+
+AC_DEFUN([AC_C_FIND_ENDIAN],
+[AC_CACHE_CHECK(processor byte ordering,
+ ac_cv_c_byte_order,
+
+# Initialize to unknown
+ac_cv_c_byte_order=unknown
+
+if test x$ac_cv_header_endian_h = xyes ; then
+
+ # First try <endian.h> which should set BYTE_ORDER.
+
+ [AC_TRY_LINK([
+ #include <endian.h>
+ #if BYTE_ORDER != LITTLE_ENDIAN
+ not big endian
+ #endif
+ ], return 0 ;,
+ ac_cv_c_byte_order=little
+ )]
+
+ [AC_TRY_LINK([
+ #include <endian.h>
+ #if BYTE_ORDER != BIG_ENDIAN
+ not big endian
+ #endif
+ ], return 0 ;,
+ ac_cv_c_byte_order=big
+ )]
+
+ fi
+
+if test $ac_cv_c_byte_order = unknown ; then
+
+ [AC_TRY_LINK([
+ #include <sys/types.h>
+ #include <sys/param.h>
+ #if !BYTE_ORDER || !BIG_ENDIAN || !LITTLE_ENDIAN
+ bogus endian macros
+ #endif
+ ], return 0 ;,
+
+ [AC_TRY_LINK([
+ #include <sys/types.h>
+ #include <sys/param.h>
+ #if BYTE_ORDER != LITTLE_ENDIAN
+ not big endian
+ #endif
+ ], return 0 ;,
+ ac_cv_c_byte_order=little
+ )]
+
+ [AC_TRY_LINK([
+ #include <sys/types.h>
+ #include <sys/param.h>
+ #if BYTE_ORDER != LITTLE_ENDIAN
+ not big endian
+ #endif
+ ], return 0 ;,
+ ac_cv_c_byte_order=little
+ )]
+
+ )]
+
+ fi
+
+if test $ac_cv_c_byte_order = unknown ; then
+ if test $cross_compiling = yes ; then
+ # This is the last resort. Try to guess the target processor endian-ness
+ # by looking at the target CPU type.
+ [
+ case "$target_cpu" in
+ alpha* | i?86* | mipsel* | ia64*)
+ ac_cv_c_big_endian=0
+ ac_cv_c_little_endian=1
+ ;;
+
+ m68* | mips* | powerpc* | hppa* | sparc*)
+ ac_cv_c_big_endian=1
+ ac_cv_c_little_endian=0
+ ;;
+
+ esac
+ ]
+ else
+ AC_TRY_RUN(
+ [[
+ int main (void)
+ { /* Are we little or big endian? From Harbison&Steele. */
+ union
+ { long l ;
+ char c [sizeof (long)] ;
+ } u ;
+ u.l = 1 ;
+ return (u.c [sizeof (long) - 1] == 1);
+ }
+ ]], , ac_cv_c_byte_order=big,
+ ac_cv_c_byte_order=unknown
+ )
+
+ AC_TRY_RUN(
+ [[int main (void)
+ { /* Are we little or big endian? From Harbison&Steele. */
+ union
+ { long l ;
+ char c [sizeof (long)] ;
+ } u ;
+ u.l = 1 ;
+ return (u.c [0] == 1);
+ }]], , ac_cv_c_byte_order=little,
+ ac_cv_c_byte_order=unknown
+ )
+ fi
+ fi
+
+)
+
+if test $ac_cv_c_byte_order = big ; then
+ ac_cv_c_big_endian=1
+ ac_cv_c_little_endian=0
+elif test $ac_cv_c_byte_order = little ; then
+ ac_cv_c_big_endian=0
+ ac_cv_c_little_endian=1
+else
+ ac_cv_c_big_endian=0
+ ac_cv_c_little_endian=0
+
+ AC_MSG_WARN([[*****************************************************************]])
+ AC_MSG_WARN([[*** Not able to determine endian-ness of target processor. ]])
+ AC_MSG_WARN([[*** The constants CPU_IS_BIG_ENDIAN and CPU_IS_LITTLE_ENDIAN in ]])
+ AC_MSG_WARN([[*** src/config.h may need to be hand editied. ]])
+ AC_MSG_WARN([[*****************************************************************]])
+ fi
+
+]
+)# AC_C_FIND_ENDIAN
+
+
Added: freeswitch/trunk/libs/libsndfile/M4/extra_largefile.m4
==============================================================================
--- (empty file)
+++ freeswitch/trunk/libs/libsndfile/M4/extra_largefile.m4 Thu May 21 16:09:30 2009
@@ -0,0 +1,114 @@
+dnl By default, many hosts won't let programs access large files;
+dnl one must use special compiler options to get large-file access to work.
+dnl For more details about this brain damage please see:
+dnl http://www.sas.com/standards/large.file/x_open.20Mar96.html
+
+dnl Written by Paul Eggert <eggert at twinsun.com>.
+
+dnl Internal subroutine of AC_SYS_EXTRA_LARGEFILE.
+dnl AC_SYS_EXTRA_LARGEFILE_FLAGS(FLAGSNAME)
+AC_DEFUN([AC_SYS_EXTRA_LARGEFILE_FLAGS],
+ [AC_CACHE_CHECK([for $1 value to request large file support],
+ ac_cv_sys_largefile_$1,
+ [ac_cv_sys_largefile_$1=`($GETCONF LFS_$1) 2>/dev/null` || {
+ ac_cv_sys_largefile_$1=no
+ ifelse($1, CFLAGS,
+ [case "$host_os" in
+ # IRIX 6.2 and later require cc -n32.
+changequote(, )dnl
+ irix6.[2-9]* | irix6.1[0-9]* | irix[7-9].* | irix[1-9][0-9]*)
+changequote([, ])dnl
+ if test "$GCC" != yes; then
+ ac_cv_sys_largefile_CFLAGS=-n32
+ fi
+ ac_save_CC="$CC"
+ CC="$CC $ac_cv_sys_largefile_CFLAGS"
+ AC_TRY_LINK(, , , ac_cv_sys_largefile_CFLAGS=no)
+ CC="$ac_save_CC"
+ esac])
+ }])])
+
+dnl Internal subroutine of AC_SYS_EXTRA_LARGEFILE.
+dnl AC_SYS_EXTRA_LARGEFILE_SPACE_APPEND(VAR, VAL)
+AC_DEFUN([AC_SYS_EXTRA_LARGEFILE_SPACE_APPEND],
+ [case $2 in
+ no) ;;
+ ?*)
+ case "[$]$1" in
+ '') $1=$2 ;;
+ *) $1=[$]$1' '$2 ;;
+ esac ;;
+ esac])
+
+dnl Internal subroutine of AC_SYS_EXTRA_LARGEFILE.
+dnl AC_SYS_EXTRA_LARGEFILE_MACRO_VALUE(C-MACRO, CACHE-VAR, COMMENT, CODE-TO-SET-DEFAULT)
+AC_DEFUN([AC_SYS_EXTRA_LARGEFILE_MACRO_VALUE],
+ [AC_CACHE_CHECK([for $1], $2,
+ [$2=no
+changequote(, )dnl
+ $4
+ for ac_flag in $ac_cv_sys_largefile_CFLAGS no; do
+ case "$ac_flag" in
+ -D$1)
+ $2=1 ;;
+ -D$1=*)
+ $2=`expr " $ac_flag" : '[^=]*=\(.*\)'` ;;
+ esac
+ done
+changequote([, ])dnl
+ ])
+ if test "[$]$2" != no; then
+ AC_DEFINE_UNQUOTED([$1], [$]$2, [$3])
+ fi])
+
+AC_DEFUN([AC_SYS_EXTRA_LARGEFILE],
+ [AC_REQUIRE([AC_CANONICAL_HOST])
+ AC_ARG_ENABLE(largefile,
+ [ --disable-largefile omit support for large files])
+ if test "$enable_largefile" != no; then
+ AC_CHECK_TOOL(GETCONF, getconf)
+ AC_SYS_EXTRA_LARGEFILE_FLAGS(CFLAGS)
+ AC_SYS_EXTRA_LARGEFILE_FLAGS(LDFLAGS)
+ AC_SYS_EXTRA_LARGEFILE_FLAGS(LIBS)
+
+ for ac_flag in $ac_cv_sys_largefile_CFLAGS no; do
+ case "$ac_flag" in
+ no) ;;
+ -D_FILE_OFFSET_BITS=*) ;;
+ -D_LARGEFILE_SOURCE | -D_LARGEFILE_SOURCE=*) ;;
+ -D_LARGE_FILES | -D_LARGE_FILES=*) ;;
+ -D?* | -I?*)
+ AC_SYS_EXTRA_LARGEFILE_SPACE_APPEND(CPPFLAGS, "$ac_flag") ;;
+ *)
+ AC_SYS_EXTRA_LARGEFILE_SPACE_APPEND(CFLAGS, "$ac_flag") ;;
+ esac
+ done
+ AC_SYS_EXTRA_LARGEFILE_SPACE_APPEND(LDFLAGS, "$ac_cv_sys_largefile_LDFLAGS")
+ AC_SYS_EXTRA_LARGEFILE_SPACE_APPEND(LIBS, "$ac_cv_sys_largefile_LIBS")
+ AC_SYS_EXTRA_LARGEFILE_MACRO_VALUE(_FILE_OFFSET_BITS,
+ ac_cv_sys_file_offset_bits,
+ [Number of bits in a file offset, on hosts where this is settable.])
+ [case "$host_os" in
+ # HP-UX 10.20 and later
+ hpux10.[2-9][0-9]* | hpux1[1-9]* | hpux[2-9][0-9]*)
+ ac_cv_sys_file_offset_bits=64 ;;
+ esac]
+ AC_SYS_EXTRA_LARGEFILE_MACRO_VALUE(_LARGEFILE_SOURCE,
+ ac_cv_sys_largefile_source,
+ [Define to make fseeko etc. visible, on some hosts.],
+ [case "$host_os" in
+ # HP-UX 10.20 and later
+ hpux10.[2-9][0-9]* | hpux1[1-9]* | hpux[2-9][0-9]*)
+ ac_cv_sys_largefile_source=1 ;;
+ esac])
+ AC_SYS_EXTRA_LARGEFILE_MACRO_VALUE(_LARGE_FILES,
+ ac_cv_sys_large_files,
+ [Define for large files, on AIX-style hosts.],
+ [case "$host_os" in
+ # AIX 4.2 and later
+ aix4.[2-9]* | aix4.1[0-9]* | aix[5-9].* | aix[1-9][0-9]*)
+ ac_cv_sys_large_files=1 ;;
+ esac])
+ fi
+ ])
+
Added: freeswitch/trunk/libs/libsndfile/M4/extra_pkg.m4
==============================================================================
--- (empty file)
+++ freeswitch/trunk/libs/libsndfile/M4/extra_pkg.m4 Thu May 21 16:09:30 2009
@@ -0,0 +1,85 @@
+# extra_pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*-
+#
+# Copyright (c) 2004 Scott James Remnant <scott at netsplit.com>.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# --------------------------------------------------------------
+# PKG_CHECK_MOD_VERSION(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
+# [ACTION-IF-NOT-FOUND])
+#
+# This is a very slight modification to the macro PKG_CHECK_MODULES that
+# is in the original pkg.m4 file. It prints the versions in the checking
+# message (erikd at mega-nerd.com).
+
+AC_DEFUN([PKG_CHECK_MOD_VERSION],
+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
+AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl
+AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl
+
+pkg_failed=no
+AC_MSG_CHECKING([for $2 ])
+
+_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2])
+_PKG_CONFIG([$1][_LIBS], [libs], [$2])
+
+m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS
+and $1[]_LIBS to avoid the need to call pkg-config.
+See the pkg-config man page for more details.])
+
+if test $pkg_failed = yes; then
+ _PKG_SHORT_ERRORS_SUPPORTED
+ if test $_pkg_short_errors_supported = yes; then
+ $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --errors-to-stdout --print-errors "$2"`
+ else
+ $1[]_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "$2"`
+ fi
+ # Put the nasty error message in config.log where it belongs
+ echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD
+
+ ifelse([$4], , [AC_MSG_ERROR(dnl
+[Package requirements ($2) were not met:
+
+$$1_PKG_ERRORS
+
+Consider adjusting the PKG_CONFIG_PATH environment variable if you
+installed software in a non-standard prefix.
+
+_PKG_TEXT
+])],
+ [AC_MSG_RESULT([no])
+ $4])
+elif test $pkg_failed = untried; then
+ ifelse([$4], , [AC_MSG_FAILURE(dnl
+[The pkg-config script could not be found or is too old. Make sure it
+is in your PATH or set the PKG_CONFIG environment variable to the full
+path to pkg-config.
+
+_PKG_TEXT
+
+To get pkg-config, see <http://pkg-config.freedesktop.org/>.])],
+ [$4])
+else
+ $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS
+ $1[]_LIBS=$pkg_cv_[]$1[]_LIBS
+ AC_MSG_RESULT([yes])
+ ifelse([$3], , :, [$3])
+fi[]dnl
+])# PKG_CHECK_MOD_VERSION
Added: freeswitch/trunk/libs/libsndfile/M4/flexible_array.m4
==============================================================================
--- (empty file)
+++ freeswitch/trunk/libs/libsndfile/M4/flexible_array.m4 Thu May 21 16:09:30 2009
@@ -0,0 +1,32 @@
+dnl @synopsis AC_C99_FLEXIBLE_ARRAY
+dnl
+dnl Dose the compiler support the 1999 ISO C Standard "stuct hack".
+dnl @version 1.1 Mar 15 2004
+dnl @author Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+dnl
+dnl Permission to use, copy, modify, distribute, and sell this file for any
+dnl purpose is hereby granted without fee, provided that the above copyright
+dnl and this permission notice appear in all copies. No representations are
+dnl made about the suitability of this software for any purpose. It is
+dnl provided "as is" without express or implied warranty.
+
+AC_DEFUN([AC_C99_FLEXIBLE_ARRAY],
+[AC_CACHE_CHECK(C99 struct flexible array support,
+ ac_cv_c99_flexible_array,
+
+# Initialize to unknown
+ac_cv_c99_flexible_array=no
+
+AC_TRY_LINK([[
+ #include <stdlib.h>
+ typedef struct {
+ int k;
+ char buffer [] ;
+ } MY_STRUCT ;
+ ]],
+ [ MY_STRUCT *p = calloc (1, sizeof (MY_STRUCT) + 42); ],
+ ac_cv_c99_flexible_array=yes,
+ ac_cv_c99_flexible_array=no
+ ))]
+) # AC_C99_FLEXIBLE_ARRAY
+
Added: freeswitch/trunk/libs/libsndfile/M4/gcc_version.m4
==============================================================================
--- (empty file)
+++ freeswitch/trunk/libs/libsndfile/M4/gcc_version.m4 Thu May 21 16:09:30 2009
@@ -0,0 +1,33 @@
+dnl @synopsis AC_GCC_VERSION
+dnl
+dnl Find the version of gcc.
+dnl @version 1.0 Nov 05 2007
+dnl @author Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+dnl
+dnl Permission to use, copy, modify, distribute, and sell this file for any
+dnl purpose is hereby granted without fee, provided that the above copyright
+dnl and this permission notice appear in all copies. No representations are
+dnl made about the suitability of this software for any purpose. It is
+dnl provided "as is" without express or implied warranty.
+dnl
+
+AC_DEFUN([AC_GCC_VERSION],
+[
+if test "x$ac_cv_c_compiler_gnu" = "xyes" ; then
+
+ AC_MSG_CHECKING([for version of $CC])
+ GCC_VERSION=`$CC -dumpversion`
+ AC_MSG_RESULT($GCC_VERSION)
+
+ changequote(,)dnl
+ GCC_MINOR_VERSION=`echo $GCC_VERSION | sed "s/^[0-9]\+\.//" | sed "s/\..*//"`
+ GCC_MAJOR_VERSION=`echo $GCC_VERSION | sed "s/\..*//"`
+ changequote([,])dnl
+ fi
+
+AC_SUBST(GCC_VERSION)
+AC_SUBST(GCC_MAJOR_VERSION)
+AC_SUBST(GCC_MINOR_VERSION)
+
+])# AC_GCC_VERSION
+
Added: freeswitch/trunk/libs/libsndfile/M4/libtool.m4
==============================================================================
--- (empty file)
+++ freeswitch/trunk/libs/libsndfile/M4/libtool.m4 Thu May 21 16:09:30 2009
@@ -0,0 +1,7373 @@
+# libtool.m4 - Configure libtool for the host system. -*-Autoconf-*-
+#
+# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005,
+# 2006, 2007, 2008 Free Software Foundation, Inc.
+# Written by Gordon Matzigkeit, 1996
+#
+# This file is free software; the Free Software Foundation gives
+# unlimited permission to copy and/or distribute it, with or without
+# modifications, as long as this notice is preserved.
+
+m4_define([_LT_COPYING], [dnl
+# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005,
+# 2006, 2007, 2008 Free Software Foundation, Inc.
+# Written by Gordon Matzigkeit, 1996
+#
+# This file is part of GNU Libtool.
+#
+# GNU Libtool is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+# As a special exception to the GNU General Public License,
+# if you distribute this file as part of a program or library that
+# is built using GNU Libtool, you may include this file under the
+# same distribution terms that you use for the rest of that program.
+#
+# GNU Libtool is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Libtool; see the file COPYING. If not, a copy
+# can be downloaded from http://www.gnu.org/licenses/gpl.html, or
+# obtained by writing to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+])
+
+# serial 56 LT_INIT
+
+
+# LT_PREREQ(VERSION)
+# ------------------
+# Complain and exit if this libtool version is less that VERSION.
+m4_defun([LT_PREREQ],
+[m4_if(m4_version_compare(m4_defn([LT_PACKAGE_VERSION]), [$1]), -1,
+ [m4_default([$3],
+ [m4_fatal([Libtool version $1 or higher is required],
+ 63)])],
+ [$2])])
+
+
+# _LT_CHECK_BUILDDIR
+# ------------------
+# Complain if the absolute build directory name contains unusual characters
+m4_defun([_LT_CHECK_BUILDDIR],
+[case `pwd` in
+ *\ * | *\ *)
+ AC_MSG_WARN([Libtool does not cope well with whitespace in `pwd`]) ;;
+esac
+])
+
+
+# LT_INIT([OPTIONS])
+# ------------------
+AC_DEFUN([LT_INIT],
+[AC_PREREQ([2.58])dnl We use AC_INCLUDES_DEFAULT
+AC_BEFORE([$0], [LT_LANG])dnl
+AC_BEFORE([$0], [LT_OUTPUT])dnl
+AC_BEFORE([$0], [LTDL_INIT])dnl
+m4_require([_LT_CHECK_BUILDDIR])dnl
+
+dnl Autoconf doesn't catch unexpanded LT_ macros by default:
+m4_pattern_forbid([^_?LT_[A-Z_]+$])dnl
+m4_pattern_allow([^(_LT_EOF|LT_DLGLOBAL|LT_DLLAZY_OR_NOW|LT_MULTI_MODULE)$])dnl
+dnl aclocal doesn't pull ltoptions.m4, ltsugar.m4, or ltversion.m4
+dnl unless we require an AC_DEFUNed macro:
+AC_REQUIRE([LTOPTIONS_VERSION])dnl
+AC_REQUIRE([LTSUGAR_VERSION])dnl
+AC_REQUIRE([LTVERSION_VERSION])dnl
+AC_REQUIRE([LTOBSOLETE_VERSION])dnl
+m4_require([_LT_PROG_LTMAIN])dnl
+
+dnl Parse OPTIONS
+_LT_SET_OPTIONS([$0], [$1])
+
+# This can be used to rebuild libtool when needed
+LIBTOOL_DEPS="$ltmain"
+
+# Always use our own libtool.
+LIBTOOL='$(SHELL) $(top_builddir)/libtool'
+AC_SUBST(LIBTOOL)dnl
+
+_LT_SETUP
+
+# Only expand once:
+m4_define([LT_INIT])
+])# LT_INIT
+
+# Old names:
+AU_ALIAS([AC_PROG_LIBTOOL], [LT_INIT])
+AU_ALIAS([AM_PROG_LIBTOOL], [LT_INIT])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_PROG_LIBTOOL], [])
+dnl AC_DEFUN([AM_PROG_LIBTOOL], [])
+
+
+# _LT_CC_BASENAME(CC)
+# -------------------
+# Calculate cc_basename. Skip known compiler wrappers and cross-prefix.
+m4_defun([_LT_CC_BASENAME],
+[for cc_temp in $1""; do
+ case $cc_temp in
+ compile | *[[\\/]]compile | ccache | *[[\\/]]ccache ) ;;
+ distcc | *[[\\/]]distcc | purify | *[[\\/]]purify ) ;;
+ \-*) ;;
+ *) break;;
+ esac
+done
+cc_basename=`$ECHO "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
+])
+
+
+# _LT_FILEUTILS_DEFAULTS
+# ----------------------
+# It is okay to use these file commands and assume they have been set
+# sensibly after `m4_require([_LT_FILEUTILS_DEFAULTS])'.
+m4_defun([_LT_FILEUTILS_DEFAULTS],
+[: ${CP="cp -f"}
+: ${MV="mv -f"}
+: ${RM="rm -f"}
+])# _LT_FILEUTILS_DEFAULTS
+
+
+# _LT_SETUP
+# ---------
+m4_defun([_LT_SETUP],
+[AC_REQUIRE([AC_CANONICAL_HOST])dnl
+AC_REQUIRE([AC_CANONICAL_BUILD])dnl
+_LT_DECL([], [host_alias], [0], [The host system])dnl
+_LT_DECL([], [host], [0])dnl
+_LT_DECL([], [host_os], [0])dnl
+dnl
+_LT_DECL([], [build_alias], [0], [The build system])dnl
+_LT_DECL([], [build], [0])dnl
+_LT_DECL([], [build_os], [0])dnl
+dnl
+AC_REQUIRE([AC_PROG_CC])dnl
+AC_REQUIRE([LT_PATH_LD])dnl
+AC_REQUIRE([LT_PATH_NM])dnl
+dnl
+AC_REQUIRE([AC_PROG_LN_S])dnl
+test -z "$LN_S" && LN_S="ln -s"
+_LT_DECL([], [LN_S], [1], [Whether we need soft or hard links])dnl
+dnl
+AC_REQUIRE([LT_CMD_MAX_LEN])dnl
+_LT_DECL([objext], [ac_objext], [0], [Object file suffix (normally "o")])dnl
+_LT_DECL([], [exeext], [0], [Executable file suffix (normally "")])dnl
+dnl
+m4_require([_LT_FILEUTILS_DEFAULTS])dnl
+m4_require([_LT_CHECK_SHELL_FEATURES])dnl
+m4_require([_LT_CMD_RELOAD])dnl
+m4_require([_LT_CHECK_MAGIC_METHOD])dnl
+m4_require([_LT_CMD_OLD_ARCHIVE])dnl
+m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl
+
+_LT_CONFIG_LIBTOOL_INIT([
+# See if we are running on zsh, and set the options which allow our
+# commands through without removal of \ escapes INIT.
+if test -n "\${ZSH_VERSION+set}" ; then
+ setopt NO_GLOB_SUBST
+fi
+])
+if test -n "${ZSH_VERSION+set}" ; then
+ setopt NO_GLOB_SUBST
+fi
+
+_LT_CHECK_OBJDIR
+
+m4_require([_LT_TAG_COMPILER])dnl
+_LT_PROG_ECHO_BACKSLASH
+
+case $host_os in
+aix3*)
+ # AIX sometimes has problems with the GCC collect2 program. For some
+ # reason, if we set the COLLECT_NAMES environment variable, the problems
+ # vanish in a puff of smoke.
+ if test "X${COLLECT_NAMES+set}" != Xset; then
+ COLLECT_NAMES=
+ export COLLECT_NAMES
+ fi
+ ;;
+esac
+
+# Sed substitution that helps us do robust quoting. It backslashifies
+# metacharacters that are still active within double-quoted strings.
+sed_quote_subst='s/\([["`$\\]]\)/\\\1/g'
+
+# Same as above, but do not quote variable references.
+double_quote_subst='s/\([["`\\]]\)/\\\1/g'
+
+# Sed substitution to delay expansion of an escaped shell variable in a
+# double_quote_subst'ed string.
+delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g'
+
+# Sed substitution to delay expansion of an escaped single quote.
+delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g'
+
+# Sed substitution to avoid accidental globbing in evaled expressions
+no_glob_subst='s/\*/\\\*/g'
+
+# Global variables:
+ofile=libtool
+can_build_shared=yes
+
+# All known linkers require a `.a' archive for static linking (except MSVC,
+# which needs '.lib').
+libext=a
+
+with_gnu_ld="$lt_cv_prog_gnu_ld"
+
+old_CC="$CC"
+old_CFLAGS="$CFLAGS"
+
+# Set sane defaults for various variables
+test -z "$CC" && CC=cc
+test -z "$LTCC" && LTCC=$CC
+test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS
+test -z "$LD" && LD=ld
+test -z "$ac_objext" && ac_objext=o
+
+_LT_CC_BASENAME([$compiler])
+
+# Only perform the check for file, if the check method requires it
+test -z "$MAGIC_CMD" && MAGIC_CMD=file
+case $deplibs_check_method in
+file_magic*)
+ if test "$file_magic_cmd" = '$MAGIC_CMD'; then
+ _LT_PATH_MAGIC
+ fi
+ ;;
+esac
+
+# Use C for the default configuration in the libtool script
+LT_SUPPORTED_TAG([CC])
+_LT_LANG_C_CONFIG
+_LT_LANG_DEFAULT_CONFIG
+_LT_CONFIG_COMMANDS
+])# _LT_SETUP
+
+
+# _LT_PROG_LTMAIN
+# ---------------
+# Note that this code is called both from `configure', and `config.status'
+# now that we use AC_CONFIG_COMMANDS to generate libtool. Notably,
+# `config.status' has no value for ac_aux_dir unless we are using Automake,
+# so we pass a copy along to make sure it has a sensible value anyway.
+m4_defun([_LT_PROG_LTMAIN],
+[m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([ltmain.sh])])dnl
+_LT_CONFIG_LIBTOOL_INIT([ac_aux_dir='$ac_aux_dir'])
+ltmain="$ac_aux_dir/ltmain.sh"
+])# _LT_PROG_LTMAIN
+
+
+## ------------------------------------- ##
+## Accumulate code for creating libtool. ##
+## ------------------------------------- ##
+
+# So that we can recreate a full libtool script including additional
+# tags, we accumulate the chunks of code to send to AC_CONFIG_COMMANDS
+# in macros and then make a single call at the end using the `libtool'
+# label.
+
+
+# _LT_CONFIG_LIBTOOL_INIT([INIT-COMMANDS])
+# ----------------------------------------
+# Register INIT-COMMANDS to be passed to AC_CONFIG_COMMANDS later.
+m4_define([_LT_CONFIG_LIBTOOL_INIT],
+[m4_ifval([$1],
+ [m4_append([_LT_OUTPUT_LIBTOOL_INIT],
+ [$1
+])])])
+
+# Initialize.
+m4_define([_LT_OUTPUT_LIBTOOL_INIT])
+
+
+# _LT_CONFIG_LIBTOOL([COMMANDS])
+# ------------------------------
+# Register COMMANDS to be passed to AC_CONFIG_COMMANDS later.
+m4_define([_LT_CONFIG_LIBTOOL],
+[m4_ifval([$1],
+ [m4_append([_LT_OUTPUT_LIBTOOL_COMMANDS],
+ [$1
+])])])
+
+# Initialize.
+m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS])
+
+
+# _LT_CONFIG_SAVE_COMMANDS([COMMANDS], [INIT_COMMANDS])
+# -----------------------------------------------------
+m4_defun([_LT_CONFIG_SAVE_COMMANDS],
+[_LT_CONFIG_LIBTOOL([$1])
+_LT_CONFIG_LIBTOOL_INIT([$2])
+])
+
+
+# _LT_FORMAT_COMMENT([COMMENT])
+# -----------------------------
+# Add leading comment marks to the start of each line, and a trailing
+# full-stop to the whole comment if one is not present already.
+m4_define([_LT_FORMAT_COMMENT],
+[m4_ifval([$1], [
+m4_bpatsubst([m4_bpatsubst([$1], [^ *], [# ])],
+ [['`$\]], [\\\&])]m4_bmatch([$1], [[!?.]$], [], [.])
+)])
+
+
+
+## ------------------------ ##
+## FIXME: Eliminate VARNAME ##
+## ------------------------ ##
+
+
+# _LT_DECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION], [IS-TAGGED?])
+# -------------------------------------------------------------------
+# CONFIGNAME is the name given to the value in the libtool script.
+# VARNAME is the (base) name used in the configure script.
+# VALUE may be 0, 1 or 2 for a computed quote escaped value based on
+# VARNAME. Any other value will be used directly.
+m4_define([_LT_DECL],
+[lt_if_append_uniq([lt_decl_varnames], [$2], [, ],
+ [lt_dict_add_subkey([lt_decl_dict], [$2], [libtool_name],
+ [m4_ifval([$1], [$1], [$2])])
+ lt_dict_add_subkey([lt_decl_dict], [$2], [value], [$3])
+ m4_ifval([$4],
+ [lt_dict_add_subkey([lt_decl_dict], [$2], [description], [$4])])
+ lt_dict_add_subkey([lt_decl_dict], [$2],
+ [tagged?], [m4_ifval([$5], [yes], [no])])])
+])
+
+
+# _LT_TAGDECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION])
+# --------------------------------------------------------
+m4_define([_LT_TAGDECL], [_LT_DECL([$1], [$2], [$3], [$4], [yes])])
+
+
+# lt_decl_tag_varnames([SEPARATOR], [VARNAME1...])
+# ------------------------------------------------
+m4_define([lt_decl_tag_varnames],
+[_lt_decl_filter([tagged?], [yes], $@)])
+
+
+# _lt_decl_filter(SUBKEY, VALUE, [SEPARATOR], [VARNAME1..])
+# ---------------------------------------------------------
+m4_define([_lt_decl_filter],
+[m4_case([$#],
+ [0], [m4_fatal([$0: too few arguments: $#])],
+ [1], [m4_fatal([$0: too few arguments: $#: $1])],
+ [2], [lt_dict_filter([lt_decl_dict], [$1], [$2], [], lt_decl_varnames)],
+ [3], [lt_dict_filter([lt_decl_dict], [$1], [$2], [$3], lt_decl_varnames)],
+ [lt_dict_filter([lt_decl_dict], $@)])[]dnl
+])
+
+
+# lt_decl_quote_varnames([SEPARATOR], [VARNAME1...])
+# --------------------------------------------------
+m4_define([lt_decl_quote_varnames],
+[_lt_decl_filter([value], [1], $@)])
+
+
+# lt_decl_dquote_varnames([SEPARATOR], [VARNAME1...])
+# ---------------------------------------------------
+m4_define([lt_decl_dquote_varnames],
+[_lt_decl_filter([value], [2], $@)])
+
+
+# lt_decl_varnames_tagged([SEPARATOR], [VARNAME1...])
+# ---------------------------------------------------
+m4_define([lt_decl_varnames_tagged],
+[m4_assert([$# <= 2])dnl
+_$0(m4_quote(m4_default([$1], [[, ]])),
+ m4_ifval([$2], [[$2]], [m4_dquote(lt_decl_tag_varnames)]),
+ m4_split(m4_normalize(m4_quote(_LT_TAGS)), [ ]))])
+m4_define([_lt_decl_varnames_tagged],
+[m4_ifval([$3], [lt_combine([$1], [$2], [_], $3)])])
+
+
+# lt_decl_all_varnames([SEPARATOR], [VARNAME1...])
+# ------------------------------------------------
+m4_define([lt_decl_all_varnames],
+[_$0(m4_quote(m4_default([$1], [[, ]])),
+ m4_if([$2], [],
+ m4_quote(lt_decl_varnames),
+ m4_quote(m4_shift($@))))[]dnl
+])
+m4_define([_lt_decl_all_varnames],
+[lt_join($@, lt_decl_varnames_tagged([$1],
+ lt_decl_tag_varnames([[, ]], m4_shift($@))))dnl
+])
+
+
+# _LT_CONFIG_STATUS_DECLARE([VARNAME])
+# ------------------------------------
+# Quote a variable value, and forward it to `config.status' so that its
+# declaration there will have the same value as in `configure'. VARNAME
+# must have a single quote delimited value for this to work.
+m4_define([_LT_CONFIG_STATUS_DECLARE],
+[$1='`$ECHO "X$][$1" | $Xsed -e "$delay_single_quote_subst"`'])
+
+
+# _LT_CONFIG_STATUS_DECLARATIONS
+# ------------------------------
+# We delimit libtool config variables with single quotes, so when
+# we write them to config.status, we have to be sure to quote all
+# embedded single quotes properly. In configure, this macro expands
+# each variable declared with _LT_DECL (and _LT_TAGDECL) into:
+#
+# <var>='`$ECHO "X$<var>" | $Xsed -e "$delay_single_quote_subst"`'
+m4_defun([_LT_CONFIG_STATUS_DECLARATIONS],
+[m4_foreach([_lt_var], m4_quote(lt_decl_all_varnames),
+ [m4_n([_LT_CONFIG_STATUS_DECLARE(_lt_var)])])])
+
+
+# _LT_LIBTOOL_TAGS
+# ----------------
+# Output comment and list of tags supported by the script
+m4_defun([_LT_LIBTOOL_TAGS],
+[_LT_FORMAT_COMMENT([The names of the tagged configurations supported by this script])dnl
+available_tags="_LT_TAGS"dnl
+])
+
+
+# _LT_LIBTOOL_DECLARE(VARNAME, [TAG])
+# -----------------------------------
+# Extract the dictionary values for VARNAME (optionally with TAG) and
+# expand to a commented shell variable setting:
+#
+# # Some comment about what VAR is for.
+# visible_name=$lt_internal_name
+m4_define([_LT_LIBTOOL_DECLARE],
+[_LT_FORMAT_COMMENT(m4_quote(lt_dict_fetch([lt_decl_dict], [$1],
+ [description])))[]dnl
+m4_pushdef([_libtool_name],
+ m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [libtool_name])))[]dnl
+m4_case(m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [value])),
+ [0], [_libtool_name=[$]$1],
+ [1], [_libtool_name=$lt_[]$1],
+ [2], [_libtool_name=$lt_[]$1],
+ [_libtool_name=lt_dict_fetch([lt_decl_dict], [$1], [value])])[]dnl
+m4_ifval([$2], [_$2])[]m4_popdef([_libtool_name])[]dnl
+])
+
+
+# _LT_LIBTOOL_CONFIG_VARS
+# -----------------------
+# Produce commented declarations of non-tagged libtool config variables
+# suitable for insertion in the LIBTOOL CONFIG section of the `libtool'
+# script. Tagged libtool config variables (even for the LIBTOOL CONFIG
+# section) are produced by _LT_LIBTOOL_TAG_VARS.
+m4_defun([_LT_LIBTOOL_CONFIG_VARS],
+[m4_foreach([_lt_var],
+ m4_quote(_lt_decl_filter([tagged?], [no], [], lt_decl_varnames)),
+ [m4_n([_LT_LIBTOOL_DECLARE(_lt_var)])])])
+
+
+# _LT_LIBTOOL_TAG_VARS(TAG)
+# -------------------------
+m4_define([_LT_LIBTOOL_TAG_VARS],
+[m4_foreach([_lt_var], m4_quote(lt_decl_tag_varnames),
+ [m4_n([_LT_LIBTOOL_DECLARE(_lt_var, [$1])])])])
+
+
+# _LT_TAGVAR(VARNAME, [TAGNAME])
+# ------------------------------
+m4_define([_LT_TAGVAR], [m4_ifval([$2], [$1_$2], [$1])])
+
+
+# _LT_CONFIG_COMMANDS
+# -------------------
+# Send accumulated output to $CONFIG_STATUS. Thanks to the lists of
+# variables for single and double quote escaping we saved from calls
+# to _LT_DECL, we can put quote escaped variables declarations
+# into `config.status', and then the shell code to quote escape them in
+# for loops in `config.status'. Finally, any additional code accumulated
+# from calls to _LT_CONFIG_LIBTOOL_INIT is expanded.
+m4_defun([_LT_CONFIG_COMMANDS],
+[AC_PROVIDE_IFELSE([LT_OUTPUT],
+ dnl If the libtool generation code has been placed in $CONFIG_LT,
+ dnl instead of duplicating it all over again into config.status,
+ dnl then we will have config.status run $CONFIG_LT later, so it
+ dnl needs to know what name is stored there:
+ [AC_CONFIG_COMMANDS([libtool],
+ [$SHELL $CONFIG_LT || AS_EXIT(1)], [CONFIG_LT='$CONFIG_LT'])],
+ dnl If the libtool generation code is destined for config.status,
+ dnl expand the accumulated commands and init code now:
+ [AC_CONFIG_COMMANDS([libtool],
+ [_LT_OUTPUT_LIBTOOL_COMMANDS], [_LT_OUTPUT_LIBTOOL_COMMANDS_INIT])])
+])#_LT_CONFIG_COMMANDS
+
+
+# Initialize.
+m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS_INIT],
+[
+
+# The HP-UX ksh and POSIX shell print the target directory to stdout
+# if CDPATH is set.
+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
+sed_quote_subst='$sed_quote_subst'
+double_quote_subst='$double_quote_subst'
+delay_variable_subst='$delay_variable_subst'
+_LT_CONFIG_STATUS_DECLARATIONS
+LTCC='$LTCC'
+LTCFLAGS='$LTCFLAGS'
+compiler='$compiler_DEFAULT'
+
+# Quote evaled strings.
+for var in lt_decl_all_varnames([[ \
+]], lt_decl_quote_varnames); do
+ case \`eval \\\\\$ECHO "X\\\\\$\$var"\` in
+ *[[\\\\\\\`\\"\\\$]]*)
+ eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"X\\\$\$var\\" | \\\$Xsed -e \\"\\\$sed_quote_subst\\"\\\`\\\\\\""
+ ;;
+ *)
+ eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\""
+ ;;
+ esac
+done
+
+# Double-quote double-evaled strings.
+for var in lt_decl_all_varnames([[ \
+]], lt_decl_dquote_varnames); do
+ case \`eval \\\\\$ECHO "X\\\\\$\$var"\` in
+ *[[\\\\\\\`\\"\\\$]]*)
+ eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"X\\\$\$var\\" | \\\$Xsed -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\""
+ ;;
+ *)
+ eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\""
+ ;;
+ esac
+done
+
+# Fix-up fallback echo if it was mangled by the above quoting rules.
+case \$lt_ECHO in
+*'\\\[$]0 --fallback-echo"')dnl "
+ lt_ECHO=\`\$ECHO "X\$lt_ECHO" | \$Xsed -e 's/\\\\\\\\\\\\\\\[$]0 --fallback-echo"\[$]/\[$]0 --fallback-echo"/'\`
+ ;;
+esac
+
+_LT_OUTPUT_LIBTOOL_INIT
+])
+
+
+# LT_OUTPUT
+# ---------
+# This macro allows early generation of the libtool script (before
+# AC_OUTPUT is called), incase it is used in configure for compilation
+# tests.
+AC_DEFUN([LT_OUTPUT],
+[: ${CONFIG_LT=./config.lt}
+AC_MSG_NOTICE([creating $CONFIG_LT])
+cat >"$CONFIG_LT" <<_LTEOF
+#! $SHELL
+# Generated by $as_me.
+# Run this file to recreate a libtool stub with the current configuration.
+
+lt_cl_silent=false
+SHELL=\${CONFIG_SHELL-$SHELL}
+_LTEOF
+
+cat >>"$CONFIG_LT" <<\_LTEOF
+AS_SHELL_SANITIZE
+_AS_PREPARE
+
+exec AS_MESSAGE_FD>&1
+exec AS_MESSAGE_LOG_FD>>config.log
+{
+ echo
+ AS_BOX([Running $as_me.])
+} >&AS_MESSAGE_LOG_FD
+
+lt_cl_help="\
+\`$as_me' creates a local libtool stub from the current configuration,
+for use in further configure time tests before the real libtool is
+generated.
+
+Usage: $[0] [[OPTIONS]]
+
+ -h, --help print this help, then exit
+ -V, --version print version number, then exit
+ -q, --quiet do not print progress messages
+ -d, --debug don't remove temporary files
+
+Report bugs to <bug-libtool at gnu.org>."
+
+lt_cl_version="\
+m4_ifset([AC_PACKAGE_NAME], [AC_PACKAGE_NAME ])config.lt[]dnl
+m4_ifset([AC_PACKAGE_VERSION], [ AC_PACKAGE_VERSION])
+configured by $[0], generated by m4_PACKAGE_STRING.
+
+Copyright (C) 2008 Free Software Foundation, Inc.
+This config.lt script is free software; the Free Software Foundation
+gives unlimited permision to copy, distribute and modify it."
+
+while test $[#] != 0
+do
+ case $[1] in
+ --version | --v* | -V )
+ echo "$lt_cl_version"; exit 0 ;;
+ --help | --h* | -h )
+ echo "$lt_cl_help"; exit 0 ;;
+ --debug | --d* | -d )
+ debug=: ;;
+ --quiet | --q* | --silent | --s* | -q )
+ lt_cl_silent=: ;;
+
+ -*) AC_MSG_ERROR([unrecognized option: $[1]
+Try \`$[0] --help' for more information.]) ;;
+
+ *) AC_MSG_ERROR([unrecognized argument: $[1]
+Try \`$[0] --help' for more information.]) ;;
+ esac
+ shift
+done
+
+if $lt_cl_silent; then
+ exec AS_MESSAGE_FD>/dev/null
+fi
+_LTEOF
+
+cat >>"$CONFIG_LT" <<_LTEOF
+_LT_OUTPUT_LIBTOOL_COMMANDS_INIT
+_LTEOF
+
+cat >>"$CONFIG_LT" <<\_LTEOF
+AC_MSG_NOTICE([creating $ofile])
+_LT_OUTPUT_LIBTOOL_COMMANDS
+AS_EXIT(0)
+_LTEOF
+chmod +x "$CONFIG_LT"
+
+# configure is writing to config.log, but config.lt does its own redirection,
+# appending to config.log, which fails on DOS, as config.log is still kept
+# open by configure. Here we exec the FD to /dev/null, effectively closing
+# config.log, so it can be properly (re)opened and appended to by config.lt.
+if test "$no_create" != yes; then
+ lt_cl_success=:
+ test "$silent" = yes &&
+ lt_config_lt_args="$lt_config_lt_args --quiet"
+ exec AS_MESSAGE_LOG_FD>/dev/null
+ $SHELL "$CONFIG_LT" $lt_config_lt_args || lt_cl_success=false
+ exec AS_MESSAGE_LOG_FD>>config.log
+ $lt_cl_success || AS_EXIT(1)
+fi
+])# LT_OUTPUT
+
+
+# _LT_CONFIG(TAG)
+# ---------------
+# If TAG is the built-in tag, create an initial libtool script with a
+# default configuration from the untagged config vars. Otherwise add code
+# to config.status for appending the configuration named by TAG from the
+# matching tagged config vars.
+m4_defun([_LT_CONFIG],
+[m4_require([_LT_FILEUTILS_DEFAULTS])dnl
+_LT_CONFIG_SAVE_COMMANDS([
+ m4_define([_LT_TAG], m4_if([$1], [], [C], [$1]))dnl
+ m4_if(_LT_TAG, [C], [
+ # See if we are running on zsh, and set the options which allow our
+ # commands through without removal of \ escapes.
+ if test -n "${ZSH_VERSION+set}" ; then
+ setopt NO_GLOB_SUBST
+ fi
+
+ cfgfile="${ofile}T"
+ trap "$RM \"$cfgfile\"; exit 1" 1 2 15
+ $RM "$cfgfile"
+
+ cat <<_LT_EOF >> "$cfgfile"
+#! $SHELL
+
+# `$ECHO "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services.
+# Generated automatically by $as_me ($PACKAGE$TIMESTAMP) $VERSION
+# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
+# NOTE: Changes made to this file will be lost: look at ltmain.sh.
+#
+_LT_COPYING
+_LT_LIBTOOL_TAGS
+
+# ### BEGIN LIBTOOL CONFIG
+_LT_LIBTOOL_CONFIG_VARS
+_LT_LIBTOOL_TAG_VARS
+# ### END LIBTOOL CONFIG
+
+_LT_EOF
+
+ case $host_os in
+ aix3*)
+ cat <<\_LT_EOF >> "$cfgfile"
+# AIX sometimes has problems with the GCC collect2 program. For some
+# reason, if we set the COLLECT_NAMES environment variable, the problems
+# vanish in a puff of smoke.
+if test "X${COLLECT_NAMES+set}" != Xset; then
+ COLLECT_NAMES=
+ export COLLECT_NAMES
+fi
+_LT_EOF
+ ;;
+ esac
+
+ _LT_PROG_LTMAIN
+
+ # We use sed instead of cat because bash on DJGPP gets confused if
+ # if finds mixed CR/LF and LF-only lines. Since sed operates in
+ # text mode, it properly converts lines to CR/LF. This bash problem
+ # is reportedly fixed, but why not run on old versions too?
+ sed '/^# Generated shell functions inserted here/q' "$ltmain" >> "$cfgfile" \
+ || (rm -f "$cfgfile"; exit 1)
+
+ _LT_PROG_XSI_SHELLFNS
+
+ sed -n '/^# Generated shell functions inserted here/,$p' "$ltmain" >> "$cfgfile" \
+ || (rm -f "$cfgfile"; exit 1)
+
+ mv -f "$cfgfile" "$ofile" ||
+ (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile")
+ chmod +x "$ofile"
+],
+[cat <<_LT_EOF >> "$ofile"
+
+dnl Unfortunately we have to use $1 here, since _LT_TAG is not expanded
+dnl in a comment (ie after a #).
+# ### BEGIN LIBTOOL TAG CONFIG: $1
+_LT_LIBTOOL_TAG_VARS(_LT_TAG)
+# ### END LIBTOOL TAG CONFIG: $1
+_LT_EOF
+])dnl /m4_if
+],
+[m4_if([$1], [], [
+ PACKAGE='$PACKAGE'
+ VERSION='$VERSION'
+ TIMESTAMP='$TIMESTAMP'
+ RM='$RM'
+ ofile='$ofile'], [])
+])dnl /_LT_CONFIG_SAVE_COMMANDS
+])# _LT_CONFIG
+
+
+# LT_SUPPORTED_TAG(TAG)
+# ---------------------
+# Trace this macro to discover what tags are supported by the libtool
+# --tag option, using:
+# autoconf --trace 'LT_SUPPORTED_TAG:$1'
+AC_DEFUN([LT_SUPPORTED_TAG], [])
+
+
+# C support is built-in for now
+m4_define([_LT_LANG_C_enabled], [])
+m4_define([_LT_TAGS], [])
+
+
+# LT_LANG(LANG)
+# -------------
+# Enable libtool support for the given language if not already enabled.
+AC_DEFUN([LT_LANG],
+[AC_BEFORE([$0], [LT_OUTPUT])dnl
+m4_case([$1],
+ [C], [_LT_LANG(C)],
+ [C++], [_LT_LANG(CXX)],
+ [Java], [_LT_LANG(GCJ)],
+ [Fortran 77], [_LT_LANG(F77)],
+ [Fortran], [_LT_LANG(FC)],
+ [Windows Resource], [_LT_LANG(RC)],
+ [m4_ifdef([_LT_LANG_]$1[_CONFIG],
+ [_LT_LANG($1)],
+ [m4_fatal([$0: unsupported language: "$1"])])])dnl
+])# LT_LANG
+
+
+# _LT_LANG(LANGNAME)
+# ------------------
+m4_defun([_LT_LANG],
+[m4_ifdef([_LT_LANG_]$1[_enabled], [],
+ [LT_SUPPORTED_TAG([$1])dnl
+ m4_append([_LT_TAGS], [$1 ])dnl
+ m4_define([_LT_LANG_]$1[_enabled], [])dnl
+ _LT_LANG_$1_CONFIG($1)])dnl
+])# _LT_LANG
+
+
+# _LT_LANG_DEFAULT_CONFIG
+# -----------------------
+m4_defun([_LT_LANG_DEFAULT_CONFIG],
+[AC_PROVIDE_IFELSE([AC_PROG_CXX],
+ [LT_LANG(CXX)],
+ [m4_define([AC_PROG_CXX], defn([AC_PROG_CXX])[LT_LANG(CXX)])])
+
+AC_PROVIDE_IFELSE([AC_PROG_F77],
+ [LT_LANG(F77)],
+ [m4_define([AC_PROG_F77], defn([AC_PROG_F77])[LT_LANG(F77)])])
+
+AC_PROVIDE_IFELSE([AC_PROG_FC],
+ [LT_LANG(FC)],
+ [m4_define([AC_PROG_FC], defn([AC_PROG_FC])[LT_LANG(FC)])])
+
+dnl The call to [A][M_PROG_GCJ] is quoted like that to stop aclocal
+dnl pulling things in needlessly.
+AC_PROVIDE_IFELSE([AC_PROG_GCJ],
+ [LT_LANG(GCJ)],
+ [AC_PROVIDE_IFELSE([A][M_PROG_GCJ],
+ [LT_LANG(GCJ)],
+ [AC_PROVIDE_IFELSE([LT_PROG_GCJ],
+ [LT_LANG(GCJ)],
+ [m4_ifdef([AC_PROG_GCJ],
+ [m4_define([AC_PROG_GCJ], defn([AC_PROG_GCJ])[LT_LANG(GCJ)])])
+ m4_ifdef([A][M_PROG_GCJ],
+ [m4_define([A][M_PROG_GCJ], defn([A][M_PROG_GCJ])[LT_LANG(GCJ)])])
+ m4_ifdef([LT_PROG_GCJ],
+ [m4_define([LT_PROG_GCJ], defn([LT_PROG_GCJ])[LT_LANG(GCJ)])])])])])
+
+AC_PROVIDE_IFELSE([LT_PROG_RC],
+ [LT_LANG(RC)],
+ [m4_define([LT_PROG_RC], defn([LT_PROG_RC])[LT_LANG(RC)])])
+])# _LT_LANG_DEFAULT_CONFIG
+
+# Obsolete macros:
+AU_DEFUN([AC_LIBTOOL_CXX], [LT_LANG(C++)])
+AU_DEFUN([AC_LIBTOOL_F77], [LT_LANG(Fortran 77)])
+AU_DEFUN([AC_LIBTOOL_FC], [LT_LANG(Fortran)])
+AU_DEFUN([AC_LIBTOOL_GCJ], [LT_LANG(Java)])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_LIBTOOL_CXX], [])
+dnl AC_DEFUN([AC_LIBTOOL_F77], [])
+dnl AC_DEFUN([AC_LIBTOOL_FC], [])
+dnl AC_DEFUN([AC_LIBTOOL_GCJ], [])
+
+
+# _LT_TAG_COMPILER
+# ----------------
+m4_defun([_LT_TAG_COMPILER],
+[AC_REQUIRE([AC_PROG_CC])dnl
+
+_LT_DECL([LTCC], [CC], [1], [A C compiler])dnl
+_LT_DECL([LTCFLAGS], [CFLAGS], [1], [LTCC compiler flags])dnl
+_LT_TAGDECL([CC], [compiler], [1], [A language specific compiler])dnl
+_LT_TAGDECL([with_gcc], [GCC], [0], [Is the compiler the GNU compiler?])dnl
+
+# If no C compiler was specified, use CC.
+LTCC=${LTCC-"$CC"}
+
+# If no C compiler flags were specified, use CFLAGS.
+LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
+
+# Allow CC to be a program name with arguments.
+compiler=$CC
+])# _LT_TAG_COMPILER
+
+
+# _LT_COMPILER_BOILERPLATE
+# ------------------------
+# Check for compiler boilerplate output or warnings with
+# the simple compiler test code.
+m4_defun([_LT_COMPILER_BOILERPLATE],
+[m4_require([_LT_DECL_SED])dnl
+ac_outfile=conftest.$ac_objext
+echo "$lt_simple_compile_test_code" >conftest.$ac_ext
+eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
+_lt_compiler_boilerplate=`cat conftest.err`
+$RM conftest*
+])# _LT_COMPILER_BOILERPLATE
+
+
+# _LT_LINKER_BOILERPLATE
+# ----------------------
+# Check for linker boilerplate output or warnings with
+# the simple link test code.
+m4_defun([_LT_LINKER_BOILERPLATE],
+[m4_require([_LT_DECL_SED])dnl
+ac_outfile=conftest.$ac_objext
+echo "$lt_simple_link_test_code" >conftest.$ac_ext
+eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
+_lt_linker_boilerplate=`cat conftest.err`
+$RM -r conftest*
+])# _LT_LINKER_BOILERPLATE
+
+# _LT_REQUIRED_DARWIN_CHECKS
+# -------------------------
+m4_defun_once([_LT_REQUIRED_DARWIN_CHECKS],[
+ case $host_os in
+ rhapsody* | darwin*)
+ AC_CHECK_TOOL([DSYMUTIL], [dsymutil], [:])
+ AC_CHECK_TOOL([NMEDIT], [nmedit], [:])
+ AC_CHECK_TOOL([LIPO], [lipo], [:])
+ AC_CHECK_TOOL([OTOOL], [otool], [:])
+ AC_CHECK_TOOL([OTOOL64], [otool64], [:])
+ _LT_DECL([], [DSYMUTIL], [1],
+ [Tool to manipulate archived DWARF debug symbol files on Mac OS X])
+ _LT_DECL([], [NMEDIT], [1],
+ [Tool to change global to local symbols on Mac OS X])
+ _LT_DECL([], [LIPO], [1],
+ [Tool to manipulate fat objects and archives on Mac OS X])
+ _LT_DECL([], [OTOOL], [1],
+ [ldd/readelf like tool for Mach-O binaries on Mac OS X])
+ _LT_DECL([], [OTOOL64], [1],
+ [ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4])
+
+ AC_CACHE_CHECK([for -single_module linker flag],[lt_cv_apple_cc_single_mod],
+ [lt_cv_apple_cc_single_mod=no
+ if test -z "${LT_MULTI_MODULE}"; then
+ # By default we will add the -single_module flag. You can override
+ # by either setting the environment variable LT_MULTI_MODULE
+ # non-empty at configure time, or by adding -multi_module to the
+ # link flags.
+ rm -rf libconftest.dylib*
+ echo "int foo(void){return 1;}" > conftest.c
+ echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \
+-dynamiclib -Wl,-single_module conftest.c" >&AS_MESSAGE_LOG_FD
+ $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \
+ -dynamiclib -Wl,-single_module conftest.c 2>conftest.err
+ _lt_result=$?
+ if test -f libconftest.dylib && test ! -s conftest.err && test $_lt_result = 0; then
+ lt_cv_apple_cc_single_mod=yes
+ else
+ cat conftest.err >&AS_MESSAGE_LOG_FD
+ fi
+ rm -rf libconftest.dylib*
+ rm -f conftest.*
+ fi])
+ AC_CACHE_CHECK([for -exported_symbols_list linker flag],
+ [lt_cv_ld_exported_symbols_list],
+ [lt_cv_ld_exported_symbols_list=no
+ save_LDFLAGS=$LDFLAGS
+ echo "_main" > conftest.sym
+ LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym"
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])],
+ [lt_cv_ld_exported_symbols_list=yes],
+ [lt_cv_ld_exported_symbols_list=no])
+ LDFLAGS="$save_LDFLAGS"
+ ])
+ case $host_os in
+ rhapsody* | darwin1.[[012]])
+ _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;;
+ darwin1.*)
+ _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
+ darwin*) # darwin 5.x on
+ # if running on 10.5 or later, the deployment target defaults
+ # to the OS version, if on x86, and 10.4, the deployment
+ # target defaults to 10.4. Don't you love it?
+ case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in
+ 10.0,*86*-darwin8*|10.0,*-darwin[[91]]*)
+ _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
+ 10.[[012]]*)
+ _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
+ 10.*)
+ _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
+ esac
+ ;;
+ esac
+ if test "$lt_cv_apple_cc_single_mod" = "yes"; then
+ _lt_dar_single_mod='$single_module'
+ fi
+ if test "$lt_cv_ld_exported_symbols_list" = "yes"; then
+ _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym'
+ else
+ _lt_dar_export_syms='~$NMEDIT -s $output_objdir/${libname}-symbols.expsym ${lib}'
+ fi
+ if test "$DSYMUTIL" != ":"; then
+ _lt_dsymutil='~$DSYMUTIL $lib || :'
+ else
+ _lt_dsymutil=
+ fi
+ ;;
+ esac
+])
+
+
+# _LT_DARWIN_LINKER_FEATURES
+# --------------------------
+# Checks for linker and compiler features on darwin
+m4_defun([_LT_DARWIN_LINKER_FEATURES],
+[
+ m4_require([_LT_REQUIRED_DARWIN_CHECKS])
+ _LT_TAGVAR(archive_cmds_need_lc, $1)=no
+ _LT_TAGVAR(hardcode_direct, $1)=no
+ _LT_TAGVAR(hardcode_automatic, $1)=yes
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
+ _LT_TAGVAR(whole_archive_flag_spec, $1)=''
+ _LT_TAGVAR(link_all_deplibs, $1)=yes
+ _LT_TAGVAR(allow_undefined_flag, $1)="$_lt_dar_allow_undefined"
+ case $cc_basename in
+ ifort*) _lt_dar_can_shared=yes ;;
+ *) _lt_dar_can_shared=$GCC ;;
+ esac
+ if test "$_lt_dar_can_shared" = "yes"; then
+ output_verbose_link_cmd=echo
+ _LT_TAGVAR(archive_cmds, $1)="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
+ _LT_TAGVAR(module_cmds, $1)="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
+ _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
+ _LT_TAGVAR(module_expsym_cmds, $1)="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
+ m4_if([$1], [CXX],
+[ if test "$lt_cv_apple_cc_single_mod" != "yes"; then
+ _LT_TAGVAR(archive_cmds, $1)="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dsymutil}"
+ _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dar_export_syms}${_lt_dsymutil}"
+ fi
+],[])
+ else
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ fi
+])
+
+# _LT_SYS_MODULE_PATH_AIX
+# -----------------------
+# Links a minimal program and checks the executable
+# for the system default hardcoded library path. In most cases,
+# this is /usr/lib:/lib, but when the MPI compilers are used
+# the location of the communication and MPI libs are included too.
+# If we don't find anything, use the default library path according
+# to the aix ld manual.
+m4_defun([_LT_SYS_MODULE_PATH_AIX],
+[m4_require([_LT_DECL_SED])dnl
+AC_LINK_IFELSE(AC_LANG_PROGRAM,[
+lt_aix_libpath_sed='
+ /Import File Strings/,/^$/ {
+ /^0/ {
+ s/^0 *\(.*\)$/\1/
+ p
+ }
+ }'
+aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+# Check for a 64-bit object if we didn't find anything.
+if test -z "$aix_libpath"; then
+ aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+fi],[])
+if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+])# _LT_SYS_MODULE_PATH_AIX
+
+
+# _LT_SHELL_INIT(ARG)
+# -------------------
+m4_define([_LT_SHELL_INIT],
+[ifdef([AC_DIVERSION_NOTICE],
+ [AC_DIVERT_PUSH(AC_DIVERSION_NOTICE)],
+ [AC_DIVERT_PUSH(NOTICE)])
+$1
+AC_DIVERT_POP
+])# _LT_SHELL_INIT
+
+
+# _LT_PROG_ECHO_BACKSLASH
+# -----------------------
+# Add some code to the start of the generated configure script which
+# will find an echo command which doesn't interpret backslashes.
+m4_defun([_LT_PROG_ECHO_BACKSLASH],
+[_LT_SHELL_INIT([
+# Check that we are running under the correct shell.
+SHELL=${CONFIG_SHELL-/bin/sh}
+
+case X$lt_ECHO in
+X*--fallback-echo)
+ # Remove one level of quotation (which was required for Make).
+ ECHO=`echo "$lt_ECHO" | sed 's,\\\\\[$]\\[$]0,'[$]0','`
+ ;;
+esac
+
+ECHO=${lt_ECHO-echo}
+if test "X[$]1" = X--no-reexec; then
+ # Discard the --no-reexec flag, and continue.
+ shift
+elif test "X[$]1" = X--fallback-echo; then
+ # Avoid inline document here, it may be left over
+ :
+elif test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' ; then
+ # Yippee, $ECHO works!
+ :
+else
+ # Restart under the correct shell.
+ exec $SHELL "[$]0" --no-reexec ${1+"[$]@"}
+fi
+
+if test "X[$]1" = X--fallback-echo; then
+ # used as fallback echo
+ shift
+ cat <<_LT_EOF
+[$]*
+_LT_EOF
+ exit 0
+fi
+
+# The HP-UX ksh and POSIX shell print the target directory to stdout
+# if CDPATH is set.
+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
+if test -z "$lt_ECHO"; then
+ if test "X${echo_test_string+set}" != Xset; then
+ # find a string as large as possible, as long as the shell can cope with it
+ for cmd in 'sed 50q "[$]0"' 'sed 20q "[$]0"' 'sed 10q "[$]0"' 'sed 2q "[$]0"' 'echo test'; do
+ # expected sizes: less than 2Kb, 1Kb, 512 bytes, 16 bytes, ...
+ if { echo_test_string=`eval $cmd`; } 2>/dev/null &&
+ { test "X$echo_test_string" = "X$echo_test_string"; } 2>/dev/null
+ then
+ break
+ fi
+ done
+ fi
+
+ if test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' &&
+ echo_testing_string=`{ $ECHO "$echo_test_string"; } 2>/dev/null` &&
+ test "X$echo_testing_string" = "X$echo_test_string"; then
+ :
+ else
+ # The Solaris, AIX, and Digital Unix default echo programs unquote
+ # backslashes. This makes it impossible to quote backslashes using
+ # echo "$something" | sed 's/\\/\\\\/g'
+ #
+ # So, first we look for a working echo in the user's PATH.
+
+ lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+ for dir in $PATH /usr/ucb; do
+ IFS="$lt_save_ifs"
+ if (test -f $dir/echo || test -f $dir/echo$ac_exeext) &&
+ test "X`($dir/echo '\t') 2>/dev/null`" = 'X\t' &&
+ echo_testing_string=`($dir/echo "$echo_test_string") 2>/dev/null` &&
+ test "X$echo_testing_string" = "X$echo_test_string"; then
+ ECHO="$dir/echo"
+ break
+ fi
+ done
+ IFS="$lt_save_ifs"
+
+ if test "X$ECHO" = Xecho; then
+ # We didn't find a better echo, so look for alternatives.
+ if test "X`{ print -r '\t'; } 2>/dev/null`" = 'X\t' &&
+ echo_testing_string=`{ print -r "$echo_test_string"; } 2>/dev/null` &&
+ test "X$echo_testing_string" = "X$echo_test_string"; then
+ # This shell has a builtin print -r that does the trick.
+ ECHO='print -r'
+ elif { test -f /bin/ksh || test -f /bin/ksh$ac_exeext; } &&
+ test "X$CONFIG_SHELL" != X/bin/ksh; then
+ # If we have ksh, try running configure again with it.
+ ORIGINAL_CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
+ export ORIGINAL_CONFIG_SHELL
+ CONFIG_SHELL=/bin/ksh
+ export CONFIG_SHELL
+ exec $CONFIG_SHELL "[$]0" --no-reexec ${1+"[$]@"}
+ else
+ # Try using printf.
+ ECHO='printf %s\n'
+ if test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' &&
+ echo_testing_string=`{ $ECHO "$echo_test_string"; } 2>/dev/null` &&
+ test "X$echo_testing_string" = "X$echo_test_string"; then
+ # Cool, printf works
+ :
+ elif echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` &&
+ test "X$echo_testing_string" = 'X\t' &&
+ echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` &&
+ test "X$echo_testing_string" = "X$echo_test_string"; then
+ CONFIG_SHELL=$ORIGINAL_CONFIG_SHELL
+ export CONFIG_SHELL
+ SHELL="$CONFIG_SHELL"
+ export SHELL
+ ECHO="$CONFIG_SHELL [$]0 --fallback-echo"
+ elif echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` &&
+ test "X$echo_testing_string" = 'X\t' &&
+ echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` &&
+ test "X$echo_testing_string" = "X$echo_test_string"; then
+ ECHO="$CONFIG_SHELL [$]0 --fallback-echo"
+ else
+ # maybe with a smaller string...
+ prev=:
+
+ for cmd in 'echo test' 'sed 2q "[$]0"' 'sed 10q "[$]0"' 'sed 20q "[$]0"' 'sed 50q "[$]0"'; do
+ if { test "X$echo_test_string" = "X`eval $cmd`"; } 2>/dev/null
+ then
+ break
+ fi
+ prev="$cmd"
+ done
+
+ if test "$prev" != 'sed 50q "[$]0"'; then
+ echo_test_string=`eval $prev`
+ export echo_test_string
+ exec ${ORIGINAL_CONFIG_SHELL-${CONFIG_SHELL-/bin/sh}} "[$]0" ${1+"[$]@"}
+ else
+ # Oops. We lost completely, so just stick with echo.
+ ECHO=echo
+ fi
+ fi
+ fi
+ fi
+ fi
+fi
+
+# Copy echo and quote the copy suitably for passing to libtool from
+# the Makefile, instead of quoting the original, which is used later.
+lt_ECHO=$ECHO
+if test "X$lt_ECHO" = "X$CONFIG_SHELL [$]0 --fallback-echo"; then
+ lt_ECHO="$CONFIG_SHELL \\\$\[$]0 --fallback-echo"
+fi
+
+AC_SUBST(lt_ECHO)
+])
+_LT_DECL([], [SHELL], [1], [Shell to use when invoking shell scripts])
+_LT_DECL([], [ECHO], [1],
+ [An echo program that does not interpret backslashes])
+])# _LT_PROG_ECHO_BACKSLASH
+
+
+# _LT_ENABLE_LOCK
+# ---------------
+m4_defun([_LT_ENABLE_LOCK],
+[AC_ARG_ENABLE([libtool-lock],
+ [AS_HELP_STRING([--disable-libtool-lock],
+ [avoid locking (might break parallel builds)])])
+test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes
+
+# Some flags need to be propagated to the compiler or linker for good
+# libtool support.
+case $host in
+ia64-*-hpux*)
+ # Find out which ABI we are using.
+ echo 'int i;' > conftest.$ac_ext
+ if AC_TRY_EVAL(ac_compile); then
+ case `/usr/bin/file conftest.$ac_objext` in
+ *ELF-32*)
+ HPUX_IA64_MODE="32"
+ ;;
+ *ELF-64*)
+ HPUX_IA64_MODE="64"
+ ;;
+ esac
+ fi
+ rm -rf conftest*
+ ;;
+*-*-irix6*)
+ # Find out which ABI we are using.
+ echo '[#]line __oline__ "configure"' > conftest.$ac_ext
+ if AC_TRY_EVAL(ac_compile); then
+ if test "$lt_cv_prog_gnu_ld" = yes; then
+ case `/usr/bin/file conftest.$ac_objext` in
+ *32-bit*)
+ LD="${LD-ld} -melf32bsmip"
+ ;;
+ *N32*)
+ LD="${LD-ld} -melf32bmipn32"
+ ;;
+ *64-bit*)
+ LD="${LD-ld} -melf64bmip"
+ ;;
+ esac
+ else
+ case `/usr/bin/file conftest.$ac_objext` in
+ *32-bit*)
+ LD="${LD-ld} -32"
+ ;;
+ *N32*)
+ LD="${LD-ld} -n32"
+ ;;
+ *64-bit*)
+ LD="${LD-ld} -64"
+ ;;
+ esac
+ fi
+ fi
+ rm -rf conftest*
+ ;;
+
+x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \
+s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
+ # Find out which ABI we are using.
+ echo 'int i;' > conftest.$ac_ext
+ if AC_TRY_EVAL(ac_compile); then
+ case `/usr/bin/file conftest.o` in
+ *32-bit*)
+ case $host in
+ x86_64-*kfreebsd*-gnu)
+ LD="${LD-ld} -m elf_i386_fbsd"
+ ;;
+ x86_64-*linux*)
+ LD="${LD-ld} -m elf_i386"
+ ;;
+ ppc64-*linux*|powerpc64-*linux*)
+ LD="${LD-ld} -m elf32ppclinux"
+ ;;
+ s390x-*linux*)
+ LD="${LD-ld} -m elf_s390"
+ ;;
+ sparc64-*linux*)
+ LD="${LD-ld} -m elf32_sparc"
+ ;;
+ esac
+ ;;
+ *64-bit*)
+ case $host in
+ x86_64-*kfreebsd*-gnu)
+ LD="${LD-ld} -m elf_x86_64_fbsd"
+ ;;
+ x86_64-*linux*)
+ LD="${LD-ld} -m elf_x86_64"
+ ;;
+ ppc*-*linux*|powerpc*-*linux*)
+ LD="${LD-ld} -m elf64ppc"
+ ;;
+ s390*-*linux*|s390*-*tpf*)
+ LD="${LD-ld} -m elf64_s390"
+ ;;
+ sparc*-*linux*)
+ LD="${LD-ld} -m elf64_sparc"
+ ;;
+ esac
+ ;;
+ esac
+ fi
+ rm -rf conftest*
+ ;;
+
+*-*-sco3.2v5*)
+ # On SCO OpenServer 5, we need -belf to get full-featured binaries.
+ SAVE_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS -belf"
+ AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf,
+ [AC_LANG_PUSH(C)
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[]])],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no])
+ AC_LANG_POP])
+ if test x"$lt_cv_cc_needs_belf" != x"yes"; then
+ # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf
+ CFLAGS="$SAVE_CFLAGS"
+ fi
+ ;;
+sparc*-*solaris*)
+ # Find out which ABI we are using.
+ echo 'int i;' > conftest.$ac_ext
+ if AC_TRY_EVAL(ac_compile); then
+ case `/usr/bin/file conftest.o` in
+ *64-bit*)
+ case $lt_cv_prog_gnu_ld in
+ yes*) LD="${LD-ld} -m elf64_sparc" ;;
+ *)
+ if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then
+ LD="${LD-ld} -64"
+ fi
+ ;;
+ esac
+ ;;
+ esac
+ fi
+ rm -rf conftest*
+ ;;
+esac
+
+need_locks="$enable_libtool_lock"
+])# _LT_ENABLE_LOCK
+
+
+# _LT_CMD_OLD_ARCHIVE
+# -------------------
+m4_defun([_LT_CMD_OLD_ARCHIVE],
+[AC_CHECK_TOOL(AR, ar, false)
+test -z "$AR" && AR=ar
+test -z "$AR_FLAGS" && AR_FLAGS=cru
+_LT_DECL([], [AR], [1], [The archiver])
+_LT_DECL([], [AR_FLAGS], [1])
+
+AC_CHECK_TOOL(STRIP, strip, :)
+test -z "$STRIP" && STRIP=:
+_LT_DECL([], [STRIP], [1], [A symbol stripping program])
+
+AC_CHECK_TOOL(RANLIB, ranlib, :)
+test -z "$RANLIB" && RANLIB=:
+_LT_DECL([], [RANLIB], [1],
+ [Commands used to install an old-style archive])
+
+# Determine commands to create old-style static archives.
+old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs'
+old_postinstall_cmds='chmod 644 $oldlib'
+old_postuninstall_cmds=
+
+if test -n "$RANLIB"; then
+ case $host_os in
+ openbsd*)
+ old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$oldlib"
+ ;;
+ *)
+ old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$oldlib"
+ ;;
+ esac
+ old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib"
+fi
+_LT_DECL([], [old_postinstall_cmds], [2])
+_LT_DECL([], [old_postuninstall_cmds], [2])
+_LT_TAGDECL([], [old_archive_cmds], [2],
+ [Commands used to build an old-style archive])
+])# _LT_CMD_OLD_ARCHIVE
+
+
+# _LT_COMPILER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS,
+# [OUTPUT-FILE], [ACTION-SUCCESS], [ACTION-FAILURE])
+# ----------------------------------------------------------------
+# Check whether the given compiler option works
+AC_DEFUN([_LT_COMPILER_OPTION],
+[m4_require([_LT_FILEUTILS_DEFAULTS])dnl
+m4_require([_LT_DECL_SED])dnl
+AC_CACHE_CHECK([$1], [$2],
+ [$2=no
+ m4_if([$4], , [ac_outfile=conftest.$ac_objext], [ac_outfile=$4])
+ echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+ lt_compiler_flag="$3"
+ # Insert the option either (1) after the last *FLAGS variable, or
+ # (2) before a word containing "conftest.", or (3) at the end.
+ # Note that $ac_compile itself does not contain backslashes and begins
+ # with a dollar sign (not a hyphen), so the echo should work correctly.
+ # The option is referenced via a variable to avoid confusing sed.
+ lt_compile=`echo "$ac_compile" | $SED \
+ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+ -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \
+ -e 's:$: $lt_compiler_flag:'`
+ (eval echo "\"\$as_me:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD)
+ (eval "$lt_compile" 2>conftest.err)
+ ac_status=$?
+ cat conftest.err >&AS_MESSAGE_LOG_FD
+ echo "$as_me:__oline__: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
+ if (exit $ac_status) && test -s "$ac_outfile"; then
+ # The compiler can only warn and ignore the option if not recognized
+ # So say no if there are warnings other than the usual output.
+ $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp
+ $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
+ if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
+ $2=yes
+ fi
+ fi
+ $RM conftest*
+])
+
+if test x"[$]$2" = xyes; then
+ m4_if([$5], , :, [$5])
+else
+ m4_if([$6], , :, [$6])
+fi
+])# _LT_COMPILER_OPTION
+
+# Old name:
+AU_ALIAS([AC_LIBTOOL_COMPILER_OPTION], [_LT_COMPILER_OPTION])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_LIBTOOL_COMPILER_OPTION], [])
+
+
+# _LT_LINKER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS,
+# [ACTION-SUCCESS], [ACTION-FAILURE])
+# ----------------------------------------------------
+# Check whether the given linker option works
+AC_DEFUN([_LT_LINKER_OPTION],
+[m4_require([_LT_FILEUTILS_DEFAULTS])dnl
+m4_require([_LT_DECL_SED])dnl
+AC_CACHE_CHECK([$1], [$2],
+ [$2=no
+ save_LDFLAGS="$LDFLAGS"
+ LDFLAGS="$LDFLAGS $3"
+ echo "$lt_simple_link_test_code" > conftest.$ac_ext
+ if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
+ # The linker can only warn and ignore the option if not recognized
+ # So say no if there are warnings
+ if test -s conftest.err; then
+ # Append any errors to the config.log.
+ cat conftest.err 1>&AS_MESSAGE_LOG_FD
+ $ECHO "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp
+ $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
+ if diff conftest.exp conftest.er2 >/dev/null; then
+ $2=yes
+ fi
+ else
+ $2=yes
+ fi
+ fi
+ $RM -r conftest*
+ LDFLAGS="$save_LDFLAGS"
+])
+
+if test x"[$]$2" = xyes; then
+ m4_if([$4], , :, [$4])
+else
+ m4_if([$5], , :, [$5])
+fi
+])# _LT_LINKER_OPTION
+
+# Old name:
+AU_ALIAS([AC_LIBTOOL_LINKER_OPTION], [_LT_LINKER_OPTION])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_LIBTOOL_LINKER_OPTION], [])
+
+
+# LT_CMD_MAX_LEN
+#---------------
+AC_DEFUN([LT_CMD_MAX_LEN],
+[AC_REQUIRE([AC_CANONICAL_HOST])dnl
+# find the maximum length of command line arguments
+AC_MSG_CHECKING([the maximum length of command line arguments])
+AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl
+ i=0
+ teststring="ABCD"
+
+ case $build_os in
+ msdosdjgpp*)
+ # On DJGPP, this test can blow up pretty badly due to problems in libc
+ # (any single argument exceeding 2000 bytes causes a buffer overrun
+ # during glob expansion). Even if it were fixed, the result of this
+ # check would be larger than it should be.
+ lt_cv_sys_max_cmd_len=12288; # 12K is about right
+ ;;
+
+ gnu*)
+ # Under GNU Hurd, this test is not required because there is
+ # no limit to the length of command line arguments.
+ # Libtool will interpret -1 as no limit whatsoever
+ lt_cv_sys_max_cmd_len=-1;
+ ;;
+
+ cygwin* | mingw* | cegcc*)
+ # On Win9x/ME, this test blows up -- it succeeds, but takes
+ # about 5 minutes as the teststring grows exponentially.
+ # Worse, since 9x/ME are not pre-emptively multitasking,
+ # you end up with a "frozen" computer, even though with patience
+ # the test eventually succeeds (with a max line length of 256k).
+ # Instead, let's just punt: use the minimum linelength reported by
+ # all of the supported platforms: 8192 (on NT/2K/XP).
+ lt_cv_sys_max_cmd_len=8192;
+ ;;
+
+ amigaos*)
+ # On AmigaOS with pdksh, this test takes hours, literally.
+ # So we just punt and use a minimum line length of 8192.
+ lt_cv_sys_max_cmd_len=8192;
+ ;;
+
+ netbsd* | freebsd* | openbsd* | darwin* | dragonfly*)
+ # This has been around since 386BSD, at least. Likely further.
+ if test -x /sbin/sysctl; then
+ lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax`
+ elif test -x /usr/sbin/sysctl; then
+ lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax`
+ else
+ lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs
+ fi
+ # And add a safety zone
+ lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
+ lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
+ ;;
+
+ interix*)
+ # We know the value 262144 and hardcode it with a safety zone (like BSD)
+ lt_cv_sys_max_cmd_len=196608
+ ;;
+
+ osf*)
+ # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure
+ # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not
+ # nice to cause kernel panics so lets avoid the loop below.
+ # First set a reasonable default.
+ lt_cv_sys_max_cmd_len=16384
+ #
+ if test -x /sbin/sysconfig; then
+ case `/sbin/sysconfig -q proc exec_disable_arg_limit` in
+ *1*) lt_cv_sys_max_cmd_len=-1 ;;
+ esac
+ fi
+ ;;
+ sco3.2v5*)
+ lt_cv_sys_max_cmd_len=102400
+ ;;
+ sysv5* | sco5v6* | sysv4.2uw2*)
+ kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null`
+ if test -n "$kargmax"; then
+ lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[[ ]]//'`
+ else
+ lt_cv_sys_max_cmd_len=32768
+ fi
+ ;;
+ *)
+ lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null`
+ if test -n "$lt_cv_sys_max_cmd_len"; then
+ lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
+ lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
+ else
+ # Make teststring a little bigger before we do anything with it.
+ # a 1K string should be a reasonable start.
+ for i in 1 2 3 4 5 6 7 8 ; do
+ teststring=$teststring$teststring
+ done
+ SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}}
+ # If test is not a shell built-in, we'll probably end up computing a
+ # maximum length that is only half of the actual maximum length, but
+ # we can't tell.
+ while { test "X"`$SHELL [$]0 --fallback-echo "X$teststring$teststring" 2>/dev/null` \
+ = "XX$teststring$teststring"; } >/dev/null 2>&1 &&
+ test $i != 17 # 1/2 MB should be enough
+ do
+ i=`expr $i + 1`
+ teststring=$teststring$teststring
+ done
+ # Only check the string length outside the loop.
+ lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1`
+ teststring=
+ # Add a significant safety factor because C++ compilers can tack on
+ # massive amounts of additional arguments before passing them to the
+ # linker. It appears as though 1/2 is a usable value.
+ lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2`
+ fi
+ ;;
+ esac
+])
+if test -n $lt_cv_sys_max_cmd_len ; then
+ AC_MSG_RESULT($lt_cv_sys_max_cmd_len)
+else
+ AC_MSG_RESULT(none)
+fi
+max_cmd_len=$lt_cv_sys_max_cmd_len
+_LT_DECL([], [max_cmd_len], [0],
+ [What is the maximum length of a command?])
+])# LT_CMD_MAX_LEN
+
+# Old name:
+AU_ALIAS([AC_LIBTOOL_SYS_MAX_CMD_LEN], [LT_CMD_MAX_LEN])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_LIBTOOL_SYS_MAX_CMD_LEN], [])
+
+
+# _LT_HEADER_DLFCN
+# ----------------
+m4_defun([_LT_HEADER_DLFCN],
+[AC_CHECK_HEADERS([dlfcn.h], [], [], [AC_INCLUDES_DEFAULT])dnl
+])# _LT_HEADER_DLFCN
+
+
+# _LT_TRY_DLOPEN_SELF (ACTION-IF-TRUE, ACTION-IF-TRUE-W-USCORE,
+# ACTION-IF-FALSE, ACTION-IF-CROSS-COMPILING)
+# ----------------------------------------------------------------
+m4_defun([_LT_TRY_DLOPEN_SELF],
+[m4_require([_LT_HEADER_DLFCN])dnl
+if test "$cross_compiling" = yes; then :
+ [$4]
+else
+ lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+ lt_status=$lt_dlunknown
+ cat > conftest.$ac_ext <<_LT_EOF
+[#line __oline__ "configure"
+#include "confdefs.h"
+
+#if HAVE_DLFCN_H
+#include <dlfcn.h>
+#endif
+
+#include <stdio.h>
+
+#ifdef RTLD_GLOBAL
+# define LT_DLGLOBAL RTLD_GLOBAL
+#else
+# ifdef DL_GLOBAL
+# define LT_DLGLOBAL DL_GLOBAL
+# else
+# define LT_DLGLOBAL 0
+# endif
+#endif
+
+/* We may have to define LT_DLLAZY_OR_NOW in the command line if we
+ find out it does not work in some platform. */
+#ifndef LT_DLLAZY_OR_NOW
+# ifdef RTLD_LAZY
+# define LT_DLLAZY_OR_NOW RTLD_LAZY
+# else
+# ifdef DL_LAZY
+# define LT_DLLAZY_OR_NOW DL_LAZY
+# else
+# ifdef RTLD_NOW
+# define LT_DLLAZY_OR_NOW RTLD_NOW
+# else
+# ifdef DL_NOW
+# define LT_DLLAZY_OR_NOW DL_NOW
+# else
+# define LT_DLLAZY_OR_NOW 0
+# endif
+# endif
+# endif
+# endif
+#endif
+
+void fnord() { int i=42;}
+int main ()
+{
+ void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
+ int status = $lt_dlunknown;
+
+ if (self)
+ {
+ if (dlsym (self,"fnord")) status = $lt_dlno_uscore;
+ else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore;
+ /* dlclose (self); */
+ }
+ else
+ puts (dlerror ());
+
+ return status;
+}]
+_LT_EOF
+ if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext} 2>/dev/null; then
+ (./conftest; exit; ) >&AS_MESSAGE_LOG_FD 2>/dev/null
+ lt_status=$?
+ case x$lt_status in
+ x$lt_dlno_uscore) $1 ;;
+ x$lt_dlneed_uscore) $2 ;;
+ x$lt_dlunknown|x*) $3 ;;
+ esac
+ else :
+ # compilation failed
+ $3
+ fi
+fi
+rm -fr conftest*
+])# _LT_TRY_DLOPEN_SELF
+
+
+# LT_SYS_DLOPEN_SELF
+# ------------------
+AC_DEFUN([LT_SYS_DLOPEN_SELF],
+[m4_require([_LT_HEADER_DLFCN])dnl
+if test "x$enable_dlopen" != xyes; then
+ enable_dlopen=unknown
+ enable_dlopen_self=unknown
+ enable_dlopen_self_static=unknown
+else
+ lt_cv_dlopen=no
+ lt_cv_dlopen_libs=
+
+ case $host_os in
+ beos*)
+ lt_cv_dlopen="load_add_on"
+ lt_cv_dlopen_libs=
+ lt_cv_dlopen_self=yes
+ ;;
+
+ mingw* | pw32* | cegcc*)
+ lt_cv_dlopen="LoadLibrary"
+ lt_cv_dlopen_libs=
+ ;;
+
+ cygwin*)
+ lt_cv_dlopen="dlopen"
+ lt_cv_dlopen_libs=
+ ;;
+
+ darwin*)
+ # if libdl is installed we need to link against it
+ AC_CHECK_LIB([dl], [dlopen],
+ [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],[
+ lt_cv_dlopen="dyld"
+ lt_cv_dlopen_libs=
+ lt_cv_dlopen_self=yes
+ ])
+ ;;
+
+ *)
+ AC_CHECK_FUNC([shl_load],
+ [lt_cv_dlopen="shl_load"],
+ [AC_CHECK_LIB([dld], [shl_load],
+ [lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld"],
+ [AC_CHECK_FUNC([dlopen],
+ [lt_cv_dlopen="dlopen"],
+ [AC_CHECK_LIB([dl], [dlopen],
+ [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],
+ [AC_CHECK_LIB([svld], [dlopen],
+ [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"],
+ [AC_CHECK_LIB([dld], [dld_link],
+ [lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld"])
+ ])
+ ])
+ ])
+ ])
+ ])
+ ;;
+ esac
+
+ if test "x$lt_cv_dlopen" != xno; then
+ enable_dlopen=yes
+ else
+ enable_dlopen=no
+ fi
+
+ case $lt_cv_dlopen in
+ dlopen)
+ save_CPPFLAGS="$CPPFLAGS"
+ test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H"
+
+ save_LDFLAGS="$LDFLAGS"
+ wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\"
+
+ save_LIBS="$LIBS"
+ LIBS="$lt_cv_dlopen_libs $LIBS"
+
+ AC_CACHE_CHECK([whether a program can dlopen itself],
+ lt_cv_dlopen_self, [dnl
+ _LT_TRY_DLOPEN_SELF(
+ lt_cv_dlopen_self=yes, lt_cv_dlopen_self=yes,
+ lt_cv_dlopen_self=no, lt_cv_dlopen_self=cross)
+ ])
+
+ if test "x$lt_cv_dlopen_self" = xyes; then
+ wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\"
+ AC_CACHE_CHECK([whether a statically linked program can dlopen itself],
+ lt_cv_dlopen_self_static, [dnl
+ _LT_TRY_DLOPEN_SELF(
+ lt_cv_dlopen_self_static=yes, lt_cv_dlopen_self_static=yes,
+ lt_cv_dlopen_self_static=no, lt_cv_dlopen_self_static=cross)
+ ])
+ fi
+
+ CPPFLAGS="$save_CPPFLAGS"
+ LDFLAGS="$save_LDFLAGS"
+ LIBS="$save_LIBS"
+ ;;
+ esac
+
+ case $lt_cv_dlopen_self in
+ yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;;
+ *) enable_dlopen_self=unknown ;;
+ esac
+
+ case $lt_cv_dlopen_self_static in
+ yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;;
+ *) enable_dlopen_self_static=unknown ;;
+ esac
+fi
+_LT_DECL([dlopen_support], [enable_dlopen], [0],
+ [Whether dlopen is supported])
+_LT_DECL([dlopen_self], [enable_dlopen_self], [0],
+ [Whether dlopen of programs is supported])
+_LT_DECL([dlopen_self_static], [enable_dlopen_self_static], [0],
+ [Whether dlopen of statically linked programs is supported])
+])# LT_SYS_DLOPEN_SELF
+
+# Old name:
+AU_ALIAS([AC_LIBTOOL_DLOPEN_SELF], [LT_SYS_DLOPEN_SELF])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_LIBTOOL_DLOPEN_SELF], [])
+
+
+# _LT_COMPILER_C_O([TAGNAME])
+# ---------------------------
+# Check to see if options -c and -o are simultaneously supported by compiler.
+# This macro does not hard code the compiler like AC_PROG_CC_C_O.
+m4_defun([_LT_COMPILER_C_O],
+[m4_require([_LT_DECL_SED])dnl
+m4_require([_LT_FILEUTILS_DEFAULTS])dnl
+m4_require([_LT_TAG_COMPILER])dnl
+AC_CACHE_CHECK([if $compiler supports -c -o file.$ac_objext],
+ [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)],
+ [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=no
+ $RM -r conftest 2>/dev/null
+ mkdir conftest
+ cd conftest
+ mkdir out
+ echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+ lt_compiler_flag="-o out/conftest2.$ac_objext"
+ # Insert the option either (1) after the last *FLAGS variable, or
+ # (2) before a word containing "conftest.", or (3) at the end.
+ # Note that $ac_compile itself does not contain backslashes and begins
+ # with a dollar sign (not a hyphen), so the echo should work correctly.
+ lt_compile=`echo "$ac_compile" | $SED \
+ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+ -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \
+ -e 's:$: $lt_compiler_flag:'`
+ (eval echo "\"\$as_me:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD)
+ (eval "$lt_compile" 2>out/conftest.err)
+ ac_status=$?
+ cat out/conftest.err >&AS_MESSAGE_LOG_FD
+ echo "$as_me:__oline__: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
+ if (exit $ac_status) && test -s out/conftest2.$ac_objext
+ then
+ # The compiler can only warn and ignore the option if not recognized
+ # So say no if there are warnings
+ $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp
+ $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
+ if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
+ _LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes
+ fi
+ fi
+ chmod u+w . 2>&AS_MESSAGE_LOG_FD
+ $RM conftest*
+ # SGI C++ compiler will create directory out/ii_files/ for
+ # template instantiation
+ test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files
+ $RM out/* && rmdir out
+ cd ..
+ $RM -r conftest
+ $RM conftest*
+])
+_LT_TAGDECL([compiler_c_o], [lt_cv_prog_compiler_c_o], [1],
+ [Does compiler simultaneously support -c and -o options?])
+])# _LT_COMPILER_C_O
+
+
+# _LT_COMPILER_FILE_LOCKS([TAGNAME])
+# ----------------------------------
+# Check to see if we can do hard links to lock some files if needed
+m4_defun([_LT_COMPILER_FILE_LOCKS],
+[m4_require([_LT_ENABLE_LOCK])dnl
+m4_require([_LT_FILEUTILS_DEFAULTS])dnl
+_LT_COMPILER_C_O([$1])
+
+hard_links="nottested"
+if test "$_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)" = no && test "$need_locks" != no; then
+ # do not overwrite the value of need_locks provided by the user
+ AC_MSG_CHECKING([if we can lock with hard links])
+ hard_links=yes
+ $RM conftest*
+ ln conftest.a conftest.b 2>/dev/null && hard_links=no
+ touch conftest.a
+ ln conftest.a conftest.b 2>&5 || hard_links=no
+ ln conftest.a conftest.b 2>/dev/null && hard_links=no
+ AC_MSG_RESULT([$hard_links])
+ if test "$hard_links" = no; then
+ AC_MSG_WARN([`$CC' does not support `-c -o', so `make -j' may be unsafe])
+ need_locks=warn
+ fi
+else
+ need_locks=no
+fi
+_LT_DECL([], [need_locks], [1], [Must we lock files when doing compilation?])
+])# _LT_COMPILER_FILE_LOCKS
+
+
+# _LT_CHECK_OBJDIR
+# ----------------
+m4_defun([_LT_CHECK_OBJDIR],
+[AC_CACHE_CHECK([for objdir], [lt_cv_objdir],
+[rm -f .libs 2>/dev/null
+mkdir .libs 2>/dev/null
+if test -d .libs; then
+ lt_cv_objdir=.libs
+else
+ # MS-DOS does not allow filenames that begin with a dot.
+ lt_cv_objdir=_libs
+fi
+rmdir .libs 2>/dev/null])
+objdir=$lt_cv_objdir
+_LT_DECL([], [objdir], [0],
+ [The name of the directory that contains temporary libtool files])dnl
+m4_pattern_allow([LT_OBJDIR])dnl
+AC_DEFINE_UNQUOTED(LT_OBJDIR, "$lt_cv_objdir/",
+ [Define to the sub-directory in which libtool stores uninstalled libraries.])
+])# _LT_CHECK_OBJDIR
+
+
+# _LT_LINKER_HARDCODE_LIBPATH([TAGNAME])
+# --------------------------------------
+# Check hardcoding attributes.
+m4_defun([_LT_LINKER_HARDCODE_LIBPATH],
+[AC_MSG_CHECKING([how to hardcode library paths into programs])
+_LT_TAGVAR(hardcode_action, $1)=
+if test -n "$_LT_TAGVAR(hardcode_libdir_flag_spec, $1)" ||
+ test -n "$_LT_TAGVAR(runpath_var, $1)" ||
+ test "X$_LT_TAGVAR(hardcode_automatic, $1)" = "Xyes" ; then
+
+ # We can hardcode non-existent directories.
+ if test "$_LT_TAGVAR(hardcode_direct, $1)" != no &&
+ # If the only mechanism to avoid hardcoding is shlibpath_var, we
+ # have to relink, otherwise we might link with an installed library
+ # when we should be linking with a yet-to-be-installed one
+ ## test "$_LT_TAGVAR(hardcode_shlibpath_var, $1)" != no &&
+ test "$_LT_TAGVAR(hardcode_minus_L, $1)" != no; then
+ # Linking always hardcodes the temporary library directory.
+ _LT_TAGVAR(hardcode_action, $1)=relink
+ else
+ # We can link without hardcoding, and we can hardcode nonexisting dirs.
+ _LT_TAGVAR(hardcode_action, $1)=immediate
+ fi
+else
+ # We cannot hardcode anything, or else we can only hardcode existing
+ # directories.
+ _LT_TAGVAR(hardcode_action, $1)=unsupported
+fi
+AC_MSG_RESULT([$_LT_TAGVAR(hardcode_action, $1)])
+
+if test "$_LT_TAGVAR(hardcode_action, $1)" = relink ||
+ test "$_LT_TAGVAR(inherit_rpath, $1)" = yes; then
+ # Fast installation is not supported
+ enable_fast_install=no
+elif test "$shlibpath_overrides_runpath" = yes ||
+ test "$enable_shared" = no; then
+ # Fast installation is not necessary
+ enable_fast_install=needless
+fi
+_LT_TAGDECL([], [hardcode_action], [0],
+ [How to hardcode a shared library path into an executable])
+])# _LT_LINKER_HARDCODE_LIBPATH
+
+
+# _LT_CMD_STRIPLIB
+# ----------------
+m4_defun([_LT_CMD_STRIPLIB],
+[m4_require([_LT_DECL_EGREP])
+striplib=
+old_striplib=
+AC_MSG_CHECKING([whether stripping libraries is possible])
+if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then
+ test -z "$old_striplib" && old_striplib="$STRIP --strip-debug"
+ test -z "$striplib" && striplib="$STRIP --strip-unneeded"
+ AC_MSG_RESULT([yes])
+else
+# FIXME - insert some real tests, host_os isn't really good enough
+ case $host_os in
+ darwin*)
+ if test -n "$STRIP" ; then
+ striplib="$STRIP -x"
+ old_striplib="$STRIP -S"
+ AC_MSG_RESULT([yes])
+ else
+ AC_MSG_RESULT([no])
+ fi
+ ;;
+ *)
+ AC_MSG_RESULT([no])
+ ;;
+ esac
+fi
+_LT_DECL([], [old_striplib], [1], [Commands to strip libraries])
+_LT_DECL([], [striplib], [1])
+])# _LT_CMD_STRIPLIB
+
+
+# _LT_SYS_DYNAMIC_LINKER([TAG])
+# -----------------------------
+# PORTME Fill in your ld.so characteristics
+m4_defun([_LT_SYS_DYNAMIC_LINKER],
+[AC_REQUIRE([AC_CANONICAL_HOST])dnl
+m4_require([_LT_DECL_EGREP])dnl
+m4_require([_LT_FILEUTILS_DEFAULTS])dnl
+m4_require([_LT_DECL_OBJDUMP])dnl
+m4_require([_LT_DECL_SED])dnl
+AC_MSG_CHECKING([dynamic linker characteristics])
+m4_if([$1],
+ [], [
+if test "$GCC" = yes; then
+ case $host_os in
+ darwin*) lt_awk_arg="/^libraries:/,/LR/" ;;
+ *) lt_awk_arg="/^libraries:/" ;;
+ esac
+ lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e "s,=/,/,g"`
+ if $ECHO "$lt_search_path_spec" | $GREP ';' >/dev/null ; then
+ # if the path contains ";" then we assume it to be the separator
+ # otherwise default to the standard path separator (i.e. ":") - it is
+ # assumed that no part of a normal pathname contains ";" but that should
+ # okay in the real world where ";" in dirpaths is itself problematic.
+ lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED -e 's/;/ /g'`
+ else
+ lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
+ fi
+ # Ok, now we have the path, separated by spaces, we can step through it
+ # and add multilib dir if necessary.
+ lt_tmp_lt_search_path_spec=
+ lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null`
+ for lt_sys_path in $lt_search_path_spec; do
+ if test -d "$lt_sys_path/$lt_multi_os_dir"; then
+ lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir"
+ else
+ test -d "$lt_sys_path" && \
+ lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path"
+ fi
+ done
+ lt_search_path_spec=`$ECHO $lt_tmp_lt_search_path_spec | awk '
+BEGIN {RS=" "; FS="/|\n";} {
+ lt_foo="";
+ lt_count=0;
+ for (lt_i = NF; lt_i > 0; lt_i--) {
+ if ($lt_i != "" && $lt_i != ".") {
+ if ($lt_i == "..") {
+ lt_count++;
+ } else {
+ if (lt_count == 0) {
+ lt_foo="/" $lt_i lt_foo;
+ } else {
+ lt_count--;
+ }
+ }
+ }
+ }
+ if (lt_foo != "") { lt_freq[[lt_foo]]++; }
+ if (lt_freq[[lt_foo]] == 1) { print lt_foo; }
+}'`
+ sys_lib_search_path_spec=`$ECHO $lt_search_path_spec`
+else
+ sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
+fi])
+library_names_spec=
+libname_spec='lib$name'
+soname_spec=
+shrext_cmds=".so"
+postinstall_cmds=
+postuninstall_cmds=
+finish_cmds=
+finish_eval=
+shlibpath_var=
+shlibpath_overrides_runpath=unknown
+version_type=none
+dynamic_linker="$host_os ld.so"
+sys_lib_dlsearch_path_spec="/lib /usr/lib"
+need_lib_prefix=unknown
+hardcode_into_libs=no
+
+# when you set need_version to no, make sure it does not cause -set_version
+# flags to be left without arguments
+need_version=unknown
+
+case $host_os in
+aix3*)
+ version_type=linux
+ library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
+ shlibpath_var=LIBPATH
+
+ # AIX 3 has no versioning support, so we append a major version to the name.
+ soname_spec='${libname}${release}${shared_ext}$major'
+ ;;
+
+aix[[4-9]]*)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+ hardcode_into_libs=yes
+ if test "$host_cpu" = ia64; then
+ # AIX 5 supports IA64
+ library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
+ shlibpath_var=LD_LIBRARY_PATH
+ else
+ # With GCC up to 2.95.x, collect2 would create an import file
+ # for dependence libraries. The import file would start with
+ # the line `#! .'. This would cause the generated library to
+ # depend on `.', always an invalid library. This was fixed in
+ # development snapshots of GCC prior to 3.0.
+ case $host_os in
+ aix4 | aix4.[[01]] | aix4.[[01]].*)
+ if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
+ echo ' yes '
+ echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then
+ :
+ else
+ can_build_shared=no
+ fi
+ ;;
+ esac
+ # AIX (on Power*) has no versioning support, so currently we can not hardcode correct
+ # soname into executable. Probably we can add versioning support to
+ # collect2, so additional links can be useful in future.
+ if test "$aix_use_runtimelinking" = yes; then
+ # If using run time linking (on AIX 4.2 or later) use lib<name>.so
+ # instead of lib<name>.a to let people know that these are not
+ # typical AIX shared libraries.
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ else
+ # We preserve .a as extension for shared libraries through AIX4.2
+ # and later when we are not doing run time linking.
+ library_names_spec='${libname}${release}.a $libname.a'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ fi
+ shlibpath_var=LIBPATH
+ fi
+ ;;
+
+amigaos*)
+ case $host_cpu in
+ powerpc)
+ # Since July 2007 AmigaOS4 officially supports .so libraries.
+ # When compiling the executable, add -use-dynld -Lsobjs: to the compileline.
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ ;;
+ m68k)
+ library_names_spec='$libname.ixlibrary $libname.a'
+ # Create ${libname}_ixlibrary.a entries in /sys/libs.
+ finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$ECHO "X$lib" | $Xsed -e '\''s%^.*/\([[^/]]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
+ ;;
+ esac
+ ;;
+
+beos*)
+ library_names_spec='${libname}${shared_ext}'
+ dynamic_linker="$host_os ld.so"
+ shlibpath_var=LIBRARY_PATH
+ ;;
+
+bsdi[[45]]*)
+ version_type=linux
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
+ shlibpath_var=LD_LIBRARY_PATH
+ sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
+ sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib"
+ # the default ld.so.conf also contains /usr/contrib/lib and
+ # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow
+ # libtool to hard-code these into programs
+ ;;
+
+cygwin* | mingw* | pw32* | cegcc*)
+ version_type=windows
+ shrext_cmds=".dll"
+ need_version=no
+ need_lib_prefix=no
+
+ case $GCC,$host_os in
+ yes,cygwin* | yes,mingw* | yes,pw32* | yes,cegcc*)
+ library_names_spec='$libname.dll.a'
+ # DLL is installed to $(libdir)/../bin by postinstall_cmds
+ postinstall_cmds='base_file=`basename \${file}`~
+ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
+ dldir=$destdir/`dirname \$dlpath`~
+ test -d \$dldir || mkdir -p \$dldir~
+ $install_prog $dir/$dlname \$dldir/$dlname~
+ chmod a+x \$dldir/$dlname~
+ if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
+ eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;
+ fi'
+ postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
+ dlpath=$dir/\$dldll~
+ $RM \$dlpath'
+ shlibpath_overrides_runpath=yes
+
+ case $host_os in
+ cygwin*)
+ # Cygwin DLLs use 'cyg' prefix rather than 'lib'
+ soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
+ sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib"
+ ;;
+ mingw* | cegcc*)
+ # MinGW DLLs use traditional 'lib' prefix
+ soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
+ sys_lib_search_path_spec=`$CC -print-search-dirs | $GREP "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
+ if $ECHO "$sys_lib_search_path_spec" | [$GREP ';[c-zC-Z]:/' >/dev/null]; then
+ # It is most probably a Windows format PATH printed by
+ # mingw gcc, but we are running on Cygwin. Gcc prints its search
+ # path with ; separators, and with drive letters. We can handle the
+ # drive letters (cygwin fileutils understands them), so leave them,
+ # especially as we might pass files found there to a mingw objdump,
+ # which wouldn't understand a cygwinified path. Ahh.
+ sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
+ else
+ sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
+ fi
+ ;;
+ pw32*)
+ # pw32 DLLs use 'pw' prefix rather than 'lib'
+ library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
+ ;;
+ esac
+ ;;
+
+ *)
+ library_names_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext} $libname.lib'
+ ;;
+ esac
+ dynamic_linker='Win32 ld.exe'
+ # FIXME: first we should search . and the directory the executable is in
+ shlibpath_var=PATH
+ ;;
+
+darwin* | rhapsody*)
+ dynamic_linker="$host_os dyld"
+ version_type=darwin
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext'
+ soname_spec='${libname}${release}${major}$shared_ext'
+ shlibpath_overrides_runpath=yes
+ shlibpath_var=DYLD_LIBRARY_PATH
+ shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
+m4_if([$1], [],[
+ sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib"])
+ sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib'
+ ;;
+
+dgux*)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ ;;
+
+freebsd1*)
+ dynamic_linker=no
+ ;;
+
+freebsd* | dragonfly*)
+ # DragonFly does not have aout. When/if they implement a new
+ # versioning mechanism, adjust this.
+ if test -x /usr/bin/objformat; then
+ objformat=`/usr/bin/objformat`
+ else
+ case $host_os in
+ freebsd[[123]]*) objformat=aout ;;
+ *) objformat=elf ;;
+ esac
+ fi
+ version_type=freebsd-$objformat
+ case $version_type in
+ freebsd-elf*)
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+ need_version=no
+ need_lib_prefix=no
+ ;;
+ freebsd-*)
+ library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
+ need_version=yes
+ ;;
+ esac
+ shlibpath_var=LD_LIBRARY_PATH
+ case $host_os in
+ freebsd2*)
+ shlibpath_overrides_runpath=yes
+ ;;
+ freebsd3.[[01]]* | freebsdelf3.[[01]]*)
+ shlibpath_overrides_runpath=yes
+ hardcode_into_libs=yes
+ ;;
+ freebsd3.[[2-9]]* | freebsdelf3.[[2-9]]* | \
+ freebsd4.[[0-5]] | freebsdelf4.[[0-5]] | freebsd4.1.1 | freebsdelf4.1.1)
+ shlibpath_overrides_runpath=no
+ hardcode_into_libs=yes
+ ;;
+ *) # from 4.6 on, and DragonFly
+ shlibpath_overrides_runpath=yes
+ hardcode_into_libs=yes
+ ;;
+ esac
+ ;;
+
+gnu*)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ hardcode_into_libs=yes
+ ;;
+
+hpux9* | hpux10* | hpux11*)
+ # Give a soname corresponding to the major version so that dld.sl refuses to
+ # link against other versions.
+ version_type=sunos
+ need_lib_prefix=no
+ need_version=no
+ case $host_cpu in
+ ia64*)
+ shrext_cmds='.so'
+ hardcode_into_libs=yes
+ dynamic_linker="$host_os dld.so"
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ if test "X$HPUX_IA64_MODE" = X32; then
+ sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
+ else
+ sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
+ fi
+ sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+ ;;
+ hppa*64*)
+ shrext_cmds='.sl'
+ hardcode_into_libs=yes
+ dynamic_linker="$host_os dld.sl"
+ shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
+ shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
+ sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+ ;;
+ *)
+ shrext_cmds='.sl'
+ dynamic_linker="$host_os dld.sl"
+ shlibpath_var=SHLIB_PATH
+ shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ ;;
+ esac
+ # HP-UX runs *really* slowly unless shared libraries are mode 555.
+ postinstall_cmds='chmod 555 $lib'
+ ;;
+
+interix[[3-9]]*)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=no
+ hardcode_into_libs=yes
+ ;;
+
+irix5* | irix6* | nonstopux*)
+ case $host_os in
+ nonstopux*) version_type=nonstopux ;;
+ *)
+ if test "$lt_cv_prog_gnu_ld" = yes; then
+ version_type=linux
+ else
+ version_type=irix
+ fi ;;
+ esac
+ need_lib_prefix=no
+ need_version=no
+ soname_spec='${libname}${release}${shared_ext}$major'
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
+ case $host_os in
+ irix5* | nonstopux*)
+ libsuff= shlibsuff=
+ ;;
+ *)
+ case $LD in # libtool.m4 will add one of these switches to LD
+ *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ")
+ libsuff= shlibsuff= libmagic=32-bit;;
+ *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ")
+ libsuff=32 shlibsuff=N32 libmagic=N32;;
+ *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ")
+ libsuff=64 shlibsuff=64 libmagic=64-bit;;
+ *) libsuff= shlibsuff= libmagic=never-match;;
+ esac
+ ;;
+ esac
+ shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
+ shlibpath_overrides_runpath=no
+ sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
+ sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
+ hardcode_into_libs=yes
+ ;;
+
+# No shared lib support for Linux oldld, aout, or coff.
+linux*oldld* | linux*aout* | linux*coff*)
+ dynamic_linker=no
+ ;;
+
+# This must be Linux ELF.
+linux* | k*bsd*-gnu)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=no
+ # Some binutils ld are patched to set DT_RUNPATH
+ save_LDFLAGS=$LDFLAGS
+ save_libdir=$libdir
+ eval "libdir=/foo; wl=\"$_LT_TAGVAR(lt_prog_compiler_wl, $1)\"; \
+ LDFLAGS=\"\$LDFLAGS $_LT_TAGVAR(hardcode_libdir_flag_spec, $1)\""
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])],
+ [AS_IF([ ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null],
+ [shlibpath_overrides_runpath=yes])])
+ LDFLAGS=$save_LDFLAGS
+ libdir=$save_libdir
+
+ # This implies no fast_install, which is unacceptable.
+ # Some rework will be needed to allow for fast_install
+ # before this can be enabled.
+ hardcode_into_libs=yes
+
+ # Append ld.so.conf contents to the search path
+ if test -f /etc/ld.so.conf; then
+ lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \[$]2)); skip = 1; } { if (!skip) print \[$]0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '`
+ sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
+ fi
+
+ # We used to test for /lib/ld.so.1 and disable shared libraries on
+ # powerpc, because MkLinux only supported shared libraries with the
+ # GNU dynamic linker. Since this was broken with cross compilers,
+ # most powerpc-linux boxes support dynamic linking these days and
+ # people can always --disable-shared, the test was removed, and we
+ # assume the GNU/Linux dynamic linker is in use.
+ dynamic_linker='GNU/Linux ld.so'
+ ;;
+
+netbsdelf*-gnu)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=no
+ hardcode_into_libs=yes
+ dynamic_linker='NetBSD ld.elf_so'
+ ;;
+
+netbsd*)
+ version_type=sunos
+ need_lib_prefix=no
+ need_version=no
+ if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+ finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+ dynamic_linker='NetBSD (a.out) ld.so'
+ else
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ dynamic_linker='NetBSD ld.elf_so'
+ fi
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=yes
+ hardcode_into_libs=yes
+ ;;
+
+newsos6)
+ version_type=linux
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=yes
+ ;;
+
+*nto* | *qnx*)
+ version_type=qnx
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=no
+ hardcode_into_libs=yes
+ dynamic_linker='ldqnx.so'
+ ;;
+
+openbsd*)
+ version_type=sunos
+ sys_lib_dlsearch_path_spec="/usr/lib"
+ need_lib_prefix=no
+ # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
+ case $host_os in
+ openbsd3.3 | openbsd3.3.*) need_version=yes ;;
+ *) need_version=no ;;
+ esac
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+ finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+ shlibpath_var=LD_LIBRARY_PATH
+ if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+ case $host_os in
+ openbsd2.[[89]] | openbsd2.[[89]].*)
+ shlibpath_overrides_runpath=no
+ ;;
+ *)
+ shlibpath_overrides_runpath=yes
+ ;;
+ esac
+ else
+ shlibpath_overrides_runpath=yes
+ fi
+ ;;
+
+os2*)
+ libname_spec='$name'
+ shrext_cmds=".dll"
+ need_lib_prefix=no
+ library_names_spec='$libname${shared_ext} $libname.a'
+ dynamic_linker='OS/2 ld.exe'
+ shlibpath_var=LIBPATH
+ ;;
+
+osf3* | osf4* | osf5*)
+ version_type=osf
+ need_lib_prefix=no
+ need_version=no
+ soname_spec='${libname}${release}${shared_ext}$major'
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ shlibpath_var=LD_LIBRARY_PATH
+ sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
+ sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
+ ;;
+
+rdos*)
+ dynamic_linker=no
+ ;;
+
+solaris*)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=yes
+ hardcode_into_libs=yes
+ # ldd complains unless libraries are executable
+ postinstall_cmds='chmod +x $lib'
+ ;;
+
+sunos4*)
+ version_type=sunos
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+ finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=yes
+ if test "$with_gnu_ld" = yes; then
+ need_lib_prefix=no
+ fi
+ need_version=yes
+ ;;
+
+sysv4 | sysv4.3*)
+ version_type=linux
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ case $host_vendor in
+ sni)
+ shlibpath_overrides_runpath=no
+ need_lib_prefix=no
+ runpath_var=LD_RUN_PATH
+ ;;
+ siemens)
+ need_lib_prefix=no
+ ;;
+ motorola)
+ need_lib_prefix=no
+ need_version=no
+ shlibpath_overrides_runpath=no
+ sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib'
+ ;;
+ esac
+ ;;
+
+sysv4*MP*)
+ if test -d /usr/nec ;then
+ version_type=linux
+ library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
+ soname_spec='$libname${shared_ext}.$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ fi
+ ;;
+
+sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
+ version_type=freebsd-elf
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=yes
+ hardcode_into_libs=yes
+ if test "$with_gnu_ld" = yes; then
+ sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'
+ else
+ sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'
+ case $host_os in
+ sco3.2v5*)
+ sys_lib_search_path_spec="$sys_lib_search_path_spec /lib"
+ ;;
+ esac
+ fi
+ sys_lib_dlsearch_path_spec='/usr/lib'
+ ;;
+
+tpf*)
+ # TPF is a cross-target only. Preferred cross-host = GNU/Linux.
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=no
+ hardcode_into_libs=yes
+ ;;
+
+uts4*)
+ version_type=linux
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ ;;
+
+*)
+ dynamic_linker=no
+ ;;
+esac
+AC_MSG_RESULT([$dynamic_linker])
+test "$dynamic_linker" = no && can_build_shared=no
+
+variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
+if test "$GCC" = yes; then
+ variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
+fi
+
+if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then
+ sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec"
+fi
+if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then
+ sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec"
+fi
+
+_LT_DECL([], [variables_saved_for_relink], [1],
+ [Variables whose values should be saved in libtool wrapper scripts and
+ restored at link time])
+_LT_DECL([], [need_lib_prefix], [0],
+ [Do we need the "lib" prefix for modules?])
+_LT_DECL([], [need_version], [0], [Do we need a version for libraries?])
+_LT_DECL([], [version_type], [0], [Library versioning type])
+_LT_DECL([], [runpath_var], [0], [Shared library runtime path variable])
+_LT_DECL([], [shlibpath_var], [0],[Shared library path variable])
+_LT_DECL([], [shlibpath_overrides_runpath], [0],
+ [Is shlibpath searched before the hard-coded library search path?])
+_LT_DECL([], [libname_spec], [1], [Format of library name prefix])
+_LT_DECL([], [library_names_spec], [1],
+ [[List of archive names. First name is the real one, the rest are links.
+ The last name is the one that the linker finds with -lNAME]])
+_LT_DECL([], [soname_spec], [1],
+ [[The coded name of the library, if different from the real name]])
+_LT_DECL([], [postinstall_cmds], [2],
+ [Command to use after installation of a shared archive])
+_LT_DECL([], [postuninstall_cmds], [2],
+ [Command to use after uninstallation of a shared archive])
+_LT_DECL([], [finish_cmds], [2],
+ [Commands used to finish a libtool library installation in a directory])
+_LT_DECL([], [finish_eval], [1],
+ [[As "finish_cmds", except a single script fragment to be evaled but
+ not shown]])
+_LT_DECL([], [hardcode_into_libs], [0],
+ [Whether we should hardcode library paths into libraries])
+_LT_DECL([], [sys_lib_search_path_spec], [2],
+ [Compile-time system search path for libraries])
+_LT_DECL([], [sys_lib_dlsearch_path_spec], [2],
+ [Run-time system search path for libraries])
+])# _LT_SYS_DYNAMIC_LINKER
+
+
+# _LT_PATH_TOOL_PREFIX(TOOL)
+# --------------------------
+# find a file program which can recognize shared library
+AC_DEFUN([_LT_PATH_TOOL_PREFIX],
+[m4_require([_LT_DECL_EGREP])dnl
+AC_MSG_CHECKING([for $1])
+AC_CACHE_VAL(lt_cv_path_MAGIC_CMD,
+[case $MAGIC_CMD in
+[[\\/*] | ?:[\\/]*])
+ lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path.
+ ;;
+*)
+ lt_save_MAGIC_CMD="$MAGIC_CMD"
+ lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+dnl $ac_dummy forces splitting on constant user-supplied paths.
+dnl POSIX.2 word splitting is done only on the output of word expansions,
+dnl not every word. This closes a longstanding sh security hole.
+ ac_dummy="m4_if([$2], , $PATH, [$2])"
+ for ac_dir in $ac_dummy; do
+ IFS="$lt_save_ifs"
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$1; then
+ lt_cv_path_MAGIC_CMD="$ac_dir/$1"
+ if test -n "$file_magic_test_file"; then
+ case $deplibs_check_method in
+ "file_magic "*)
+ file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"`
+ MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+ if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
+ $EGREP "$file_magic_regex" > /dev/null; then
+ :
+ else
+ cat <<_LT_EOF 1>&2
+
+*** Warning: the command libtool uses to detect shared libraries,
+*** $file_magic_cmd, produces output that libtool cannot recognize.
+*** The result is that libtool may fail to recognize shared libraries
+*** as such. This will affect the creation of libtool libraries that
+*** depend on shared libraries, but programs linked with such libtool
+*** libraries will work regardless of this problem. Nevertheless, you
+*** may want to report the problem to your system manager and/or to
+*** bug-libtool at gnu.org
+
+_LT_EOF
+ fi ;;
+ esac
+ fi
+ break
+ fi
+ done
+ IFS="$lt_save_ifs"
+ MAGIC_CMD="$lt_save_MAGIC_CMD"
+ ;;
+esac])
+MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+if test -n "$MAGIC_CMD"; then
+ AC_MSG_RESULT($MAGIC_CMD)
+else
+ AC_MSG_RESULT(no)
+fi
+_LT_DECL([], [MAGIC_CMD], [0],
+ [Used to examine libraries when file_magic_cmd begins with "file"])dnl
+])# _LT_PATH_TOOL_PREFIX
+
+# Old name:
+AU_ALIAS([AC_PATH_TOOL_PREFIX], [_LT_PATH_TOOL_PREFIX])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_PATH_TOOL_PREFIX], [])
+
+
+# _LT_PATH_MAGIC
+# --------------
+# find a file program which can recognize a shared library
+m4_defun([_LT_PATH_MAGIC],
+[_LT_PATH_TOOL_PREFIX(${ac_tool_prefix}file, /usr/bin$PATH_SEPARATOR$PATH)
+if test -z "$lt_cv_path_MAGIC_CMD"; then
+ if test -n "$ac_tool_prefix"; then
+ _LT_PATH_TOOL_PREFIX(file, /usr/bin$PATH_SEPARATOR$PATH)
+ else
+ MAGIC_CMD=:
+ fi
+fi
+])# _LT_PATH_MAGIC
+
+
+# LT_PATH_LD
+# ----------
+# find the pathname to the GNU or non-GNU linker
+AC_DEFUN([LT_PATH_LD],
+[AC_REQUIRE([AC_PROG_CC])dnl
+AC_REQUIRE([AC_CANONICAL_HOST])dnl
+AC_REQUIRE([AC_CANONICAL_BUILD])dnl
+m4_require([_LT_DECL_SED])dnl
+m4_require([_LT_DECL_EGREP])dnl
+
+AC_ARG_WITH([gnu-ld],
+ [AS_HELP_STRING([--with-gnu-ld],
+ [assume the C compiler uses GNU ld @<:@default=no@:>@])],
+ [test "$withval" = no || with_gnu_ld=yes],
+ [with_gnu_ld=no])dnl
+
+ac_prog=ld
+if test "$GCC" = yes; then
+ # Check if gcc -print-prog-name=ld gives a path.
+ AC_MSG_CHECKING([for ld used by $CC])
+ case $host in
+ *-*-mingw*)
+ # gcc leaves a trailing carriage return which upsets mingw
+ ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
+ *)
+ ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
+ esac
+ case $ac_prog in
+ # Accept absolute paths.
+ [[\\/]]* | ?:[[\\/]]*)
+ re_direlt='/[[^/]][[^/]]*/\.\./'
+ # Canonicalize the pathname of ld
+ ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'`
+ while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do
+ ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"`
+ done
+ test -z "$LD" && LD="$ac_prog"
+ ;;
+ "")
+ # If it fails, then pretend we aren't using GCC.
+ ac_prog=ld
+ ;;
+ *)
+ # If it is relative, then search for the first ld in PATH.
+ with_gnu_ld=unknown
+ ;;
+ esac
+elif test "$with_gnu_ld" = yes; then
+ AC_MSG_CHECKING([for GNU ld])
+else
+ AC_MSG_CHECKING([for non-GNU ld])
+fi
+AC_CACHE_VAL(lt_cv_path_LD,
+[if test -z "$LD"; then
+ lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+ for ac_dir in $PATH; do
+ IFS="$lt_save_ifs"
+ test -z "$ac_dir" && ac_dir=.
+ if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
+ lt_cv_path_LD="$ac_dir/$ac_prog"
+ # Check to see if the program is GNU ld. I'd rather use --version,
+ # but apparently some variants of GNU ld only accept -v.
+ # Break only if it was the GNU/non-GNU ld that we prefer.
+ case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in
+ *GNU* | *'with BFD'*)
+ test "$with_gnu_ld" != no && break
+ ;;
+ *)
+ test "$with_gnu_ld" != yes && break
+ ;;
+ esac
+ fi
+ done
+ IFS="$lt_save_ifs"
+else
+ lt_cv_path_LD="$LD" # Let the user override the test with a path.
+fi])
+LD="$lt_cv_path_LD"
+if test -n "$LD"; then
+ AC_MSG_RESULT($LD)
+else
+ AC_MSG_RESULT(no)
+fi
+test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
+_LT_PATH_LD_GNU
+AC_SUBST([LD])
+
+_LT_TAGDECL([], [LD], [1], [The linker used to build libraries])
+])# LT_PATH_LD
+
+# Old names:
+AU_ALIAS([AM_PROG_LD], [LT_PATH_LD])
+AU_ALIAS([AC_PROG_LD], [LT_PATH_LD])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AM_PROG_LD], [])
+dnl AC_DEFUN([AC_PROG_LD], [])
+
+
+# _LT_PATH_LD_GNU
+#- --------------
+m4_defun([_LT_PATH_LD_GNU],
+[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], lt_cv_prog_gnu_ld,
+[# I'd rather use --version here, but apparently some GNU lds only accept -v.
+case `$LD -v 2>&1 </dev/null` in
+*GNU* | *'with BFD'*)
+ lt_cv_prog_gnu_ld=yes
+ ;;
+*)
+ lt_cv_prog_gnu_ld=no
+ ;;
+esac])
+with_gnu_ld=$lt_cv_prog_gnu_ld
+])# _LT_PATH_LD_GNU
+
+
+# _LT_CMD_RELOAD
+# --------------
+# find reload flag for linker
+# -- PORTME Some linkers may need a different reload flag.
+m4_defun([_LT_CMD_RELOAD],
+[AC_CACHE_CHECK([for $LD option to reload object files],
+ lt_cv_ld_reload_flag,
+ [lt_cv_ld_reload_flag='-r'])
+reload_flag=$lt_cv_ld_reload_flag
+case $reload_flag in
+"" | " "*) ;;
+*) reload_flag=" $reload_flag" ;;
+esac
+reload_cmds='$LD$reload_flag -o $output$reload_objs'
+case $host_os in
+ darwin*)
+ if test "$GCC" = yes; then
+ reload_cmds='$LTCC $LTCFLAGS -nostdlib ${wl}-r -o $output$reload_objs'
+ else
+ reload_cmds='$LD$reload_flag -o $output$reload_objs'
+ fi
+ ;;
+esac
+_LT_DECL([], [reload_flag], [1], [How to create reloadable object files])dnl
+_LT_DECL([], [reload_cmds], [2])dnl
+])# _LT_CMD_RELOAD
+
+
+# _LT_CHECK_MAGIC_METHOD
+# ----------------------
+# how to check for library dependencies
+# -- PORTME fill in with the dynamic library characteristics
+m4_defun([_LT_CHECK_MAGIC_METHOD],
+[m4_require([_LT_DECL_EGREP])
+m4_require([_LT_DECL_OBJDUMP])
+AC_CACHE_CHECK([how to recognize dependent libraries],
+lt_cv_deplibs_check_method,
+[lt_cv_file_magic_cmd='$MAGIC_CMD'
+lt_cv_file_magic_test_file=
+lt_cv_deplibs_check_method='unknown'
+# Need to set the preceding variable on all platforms that support
+# interlibrary dependencies.
+# 'none' -- dependencies not supported.
+# `unknown' -- same as none, but documents that we really don't know.
+# 'pass_all' -- all dependencies passed with no checks.
+# 'test_compile' -- check by making test program.
+# 'file_magic [[regex]]' -- check by looking for files in library path
+# which responds to the $file_magic_cmd with a given extended regex.
+# If you have `file' or equivalent on your system and you're not sure
+# whether `pass_all' will *always* work, you probably want this one.
+
+case $host_os in
+aix[[4-9]]*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+beos*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+bsdi[[45]]*)
+ lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib)'
+ lt_cv_file_magic_cmd='/usr/bin/file -L'
+ lt_cv_file_magic_test_file=/shlib/libc.so
+ ;;
+
+cygwin*)
+ # func_win32_libid is a shell function defined in ltmain.sh
+ lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
+ lt_cv_file_magic_cmd='func_win32_libid'
+ ;;
+
+mingw* | pw32*)
+ # Base MSYS/MinGW do not provide the 'file' command needed by
+ # func_win32_libid shell function, so use a weaker test based on 'objdump',
+ # unless we find 'file', for example because we are cross-compiling.
+ if ( file / ) >/dev/null 2>&1; then
+ lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
+ lt_cv_file_magic_cmd='func_win32_libid'
+ else
+ lt_cv_deplibs_check_method='file_magic file format pei*-i386(.*architecture: i386)?'
+ lt_cv_file_magic_cmd='$OBJDUMP -f'
+ fi
+ ;;
+
+cegcc)
+ # use the weaker test based on 'objdump'. See mingw*.
+ lt_cv_deplibs_check_method='file_magic file format pe-arm-.*little(.*architecture: arm)?'
+ lt_cv_file_magic_cmd='$OBJDUMP -f'
+ ;;
+
+darwin* | rhapsody*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+freebsd* | dragonfly*)
+ if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then
+ case $host_cpu in
+ i*86 )
+ # Not sure whether the presence of OpenBSD here was a mistake.
+ # Let's accept both of them until this is cleared up.
+ lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[[3-9]]86 (compact )?demand paged shared library'
+ lt_cv_file_magic_cmd=/usr/bin/file
+ lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*`
+ ;;
+ esac
+ else
+ lt_cv_deplibs_check_method=pass_all
+ fi
+ ;;
+
+gnu*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+hpux10.20* | hpux11*)
+ lt_cv_file_magic_cmd=/usr/bin/file
+ case $host_cpu in
+ ia64*)
+ lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|ELF-[[0-9]][[0-9]]) shared object file - IA64'
+ lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so
+ ;;
+ hppa*64*)
+ [lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - PA-RISC [0-9].[0-9]']
+ lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl
+ ;;
+ *)
+ lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|PA-RISC[[0-9]].[[0-9]]) shared library'
+ lt_cv_file_magic_test_file=/usr/lib/libc.sl
+ ;;
+ esac
+ ;;
+
+interix[[3-9]]*)
+ # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here
+ lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|\.a)$'
+ ;;
+
+irix5* | irix6* | nonstopux*)
+ case $LD in
+ *-32|*"-32 ") libmagic=32-bit;;
+ *-n32|*"-n32 ") libmagic=N32;;
+ *-64|*"-64 ") libmagic=64-bit;;
+ *) libmagic=never-match;;
+ esac
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+# This must be Linux ELF.
+linux* | k*bsd*-gnu)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+netbsd* | netbsdelf*-gnu)
+ if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then
+ lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$'
+ else
+ lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|_pic\.a)$'
+ fi
+ ;;
+
+newos6*)
+ lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (executable|dynamic lib)'
+ lt_cv_file_magic_cmd=/usr/bin/file
+ lt_cv_file_magic_test_file=/usr/lib/libnls.so
+ ;;
+
+*nto* | *qnx*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+openbsd*)
+ if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+ lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|\.so|_pic\.a)$'
+ else
+ lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$'
+ fi
+ ;;
+
+osf3* | osf4* | osf5*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+rdos*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+solaris*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+sysv4 | sysv4.3*)
+ case $host_vendor in
+ motorola)
+ lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib) M[[0-9]][[0-9]]* Version [[0-9]]'
+ lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*`
+ ;;
+ ncr)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+ sequent)
+ lt_cv_file_magic_cmd='/bin/file'
+ lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB (shared object|dynamic lib )'
+ ;;
+ sni)
+ lt_cv_file_magic_cmd='/bin/file'
+ lt_cv_deplibs_check_method="file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB dynamic lib"
+ lt_cv_file_magic_test_file=/lib/libc.so
+ ;;
+ siemens)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+ pc)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+ esac
+ ;;
+
+tpf*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+esac
+])
+file_magic_cmd=$lt_cv_file_magic_cmd
+deplibs_check_method=$lt_cv_deplibs_check_method
+test -z "$deplibs_check_method" && deplibs_check_method=unknown
+
+_LT_DECL([], [deplibs_check_method], [1],
+ [Method to check whether dependent libraries are shared objects])
+_LT_DECL([], [file_magic_cmd], [1],
+ [Command to use when deplibs_check_method == "file_magic"])
+])# _LT_CHECK_MAGIC_METHOD
+
+
+# LT_PATH_NM
+# ----------
+# find the pathname to a BSD- or MS-compatible name lister
+AC_DEFUN([LT_PATH_NM],
+[AC_REQUIRE([AC_PROG_CC])dnl
+AC_CACHE_CHECK([for BSD- or MS-compatible name lister (nm)], lt_cv_path_NM,
+[if test -n "$NM"; then
+ # Let the user override the test.
+ lt_cv_path_NM="$NM"
+else
+ lt_nm_to_check="${ac_tool_prefix}nm"
+ if test -n "$ac_tool_prefix" && test "$build" = "$host"; then
+ lt_nm_to_check="$lt_nm_to_check nm"
+ fi
+ for lt_tmp_nm in $lt_nm_to_check; do
+ lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+ for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do
+ IFS="$lt_save_ifs"
+ test -z "$ac_dir" && ac_dir=.
+ tmp_nm="$ac_dir/$lt_tmp_nm"
+ if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then
+ # Check to see if the nm accepts a BSD-compat flag.
+ # Adding the `sed 1q' prevents false positives on HP-UX, which says:
+ # nm: unknown option "B" ignored
+ # Tru64's nm complains that /dev/null is an invalid object file
+ case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in
+ */dev/null* | *'Invalid file or object type'*)
+ lt_cv_path_NM="$tmp_nm -B"
+ break
+ ;;
+ *)
+ case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in
+ */dev/null*)
+ lt_cv_path_NM="$tmp_nm -p"
+ break
+ ;;
+ *)
+ lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
+ continue # so that we can try to find one that supports BSD flags
+ ;;
+ esac
+ ;;
+ esac
+ fi
+ done
+ IFS="$lt_save_ifs"
+ done
+ : ${lt_cv_path_NM=no}
+fi])
+if test "$lt_cv_path_NM" != "no"; then
+ NM="$lt_cv_path_NM"
+else
+ # Didn't find any BSD compatible name lister, look for dumpbin.
+ AC_CHECK_TOOLS(DUMPBIN, ["dumpbin -symbols" "link -dump -symbols"], :)
+ AC_SUBST([DUMPBIN])
+ if test "$DUMPBIN" != ":"; then
+ NM="$DUMPBIN"
+ fi
+fi
+test -z "$NM" && NM=nm
+AC_SUBST([NM])
+_LT_DECL([], [NM], [1], [A BSD- or MS-compatible name lister])dnl
+
+AC_CACHE_CHECK([the name lister ($NM) interface], [lt_cv_nm_interface],
+ [lt_cv_nm_interface="BSD nm"
+ echo "int some_variable = 0;" > conftest.$ac_ext
+ (eval echo "\"\$as_me:__oline__: $ac_compile\"" >&AS_MESSAGE_LOG_FD)
+ (eval "$ac_compile" 2>conftest.err)
+ cat conftest.err >&AS_MESSAGE_LOG_FD
+ (eval echo "\"\$as_me:__oline__: $NM \\\"conftest.$ac_objext\\\"\"" >&AS_MESSAGE_LOG_FD)
+ (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out)
+ cat conftest.err >&AS_MESSAGE_LOG_FD
+ (eval echo "\"\$as_me:__oline__: output\"" >&AS_MESSAGE_LOG_FD)
+ cat conftest.out >&AS_MESSAGE_LOG_FD
+ if $GREP 'External.*some_variable' conftest.out > /dev/null; then
+ lt_cv_nm_interface="MS dumpbin"
+ fi
+ rm -f conftest*])
+])# LT_PATH_NM
+
+# Old names:
+AU_ALIAS([AM_PROG_NM], [LT_PATH_NM])
+AU_ALIAS([AC_PROG_NM], [LT_PATH_NM])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AM_PROG_NM], [])
+dnl AC_DEFUN([AC_PROG_NM], [])
+
+
+# LT_LIB_M
+# --------
+# check for math library
+AC_DEFUN([LT_LIB_M],
+[AC_REQUIRE([AC_CANONICAL_HOST])dnl
+LIBM=
+case $host in
+*-*-beos* | *-*-cygwin* | *-*-pw32* | *-*-darwin*)
+ # These system don't have libm, or don't need it
+ ;;
+*-ncr-sysv4.3*)
+ AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw")
+ AC_CHECK_LIB(m, cos, LIBM="$LIBM -lm")
+ ;;
+*)
+ AC_CHECK_LIB(m, cos, LIBM="-lm")
+ ;;
+esac
+AC_SUBST([LIBM])
+])# LT_LIB_M
+
+# Old name:
+AU_ALIAS([AC_CHECK_LIBM], [LT_LIB_M])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_CHECK_LIBM], [])
+
+
+# _LT_COMPILER_NO_RTTI([TAGNAME])
+# -------------------------------
+m4_defun([_LT_COMPILER_NO_RTTI],
+[m4_require([_LT_TAG_COMPILER])dnl
+
+_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=
+
+if test "$GCC" = yes; then
+ _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin'
+
+ _LT_COMPILER_OPTION([if $compiler supports -fno-rtti -fno-exceptions],
+ lt_cv_prog_compiler_rtti_exceptions,
+ [-fno-rtti -fno-exceptions], [],
+ [_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)="$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) -fno-rtti -fno-exceptions"])
+fi
+_LT_TAGDECL([no_builtin_flag], [lt_prog_compiler_no_builtin_flag], [1],
+ [Compiler flag to turn off builtin functions])
+])# _LT_COMPILER_NO_RTTI
+
+
+# _LT_CMD_GLOBAL_SYMBOLS
+# ----------------------
+m4_defun([_LT_CMD_GLOBAL_SYMBOLS],
+[AC_REQUIRE([AC_CANONICAL_HOST])dnl
+AC_REQUIRE([AC_PROG_CC])dnl
+AC_REQUIRE([LT_PATH_NM])dnl
+AC_REQUIRE([LT_PATH_LD])dnl
+m4_require([_LT_DECL_SED])dnl
+m4_require([_LT_DECL_EGREP])dnl
+m4_require([_LT_TAG_COMPILER])dnl
+
+# Check for command to grab the raw symbol name followed by C symbol from nm.
+AC_MSG_CHECKING([command to parse $NM output from $compiler object])
+AC_CACHE_VAL([lt_cv_sys_global_symbol_pipe],
+[
+# These are sane defaults that work on at least a few old systems.
+# [They come from Ultrix. What could be older than Ultrix?!! ;)]
+
+# Character class describing NM global symbol codes.
+symcode='[[BCDEGRST]]'
+
+# Regexp to match symbols that can be accessed directly from C.
+sympat='\([[_A-Za-z]][[_A-Za-z0-9]]*\)'
+
+# Define system-specific variables.
+case $host_os in
+aix*)
+ symcode='[[BCDT]]'
+ ;;
+cygwin* | mingw* | pw32* | cegcc*)
+ symcode='[[ABCDGISTW]]'
+ ;;
+hpux*)
+ if test "$host_cpu" = ia64; then
+ symcode='[[ABCDEGRST]]'
+ fi
+ ;;
+irix* | nonstopux*)
+ symcode='[[BCDEGRST]]'
+ ;;
+osf*)
+ symcode='[[BCDEGQRST]]'
+ ;;
+solaris*)
+ symcode='[[BDRT]]'
+ ;;
+sco3.2v5*)
+ symcode='[[DT]]'
+ ;;
+sysv4.2uw2*)
+ symcode='[[DT]]'
+ ;;
+sysv5* | sco5v6* | unixware* | OpenUNIX*)
+ symcode='[[ABDT]]'
+ ;;
+sysv4)
+ symcode='[[DFNSTU]]'
+ ;;
+esac
+
+# If we're using GNU nm, then use its standard symbol codes.
+case `$NM -V 2>&1` in
+*GNU* | *'with BFD'*)
+ symcode='[[ABCDGIRSTW]]' ;;
+esac
+
+# Transform an extracted symbol line into a proper C declaration.
+# Some systems (esp. on ia64) link data and code symbols differently,
+# so use this general approach.
+lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'"
+
+# Transform an extracted symbol line into symbol name and symbol address
+lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (void *) \&\2},/p'"
+lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \(lib[[^ ]]*\)$/ {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"lib\2\", (void *) \&\2},/p'"
+
+# Handle CRLF in mingw tool chain
+opt_cr=
+case $build_os in
+mingw*)
+ opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp
+ ;;
+esac
+
+# Try without a prefix underscore, then with it.
+for ac_symprfx in "" "_"; do
+
+ # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol.
+ symxfrm="\\1 $ac_symprfx\\2 \\2"
+
+ # Write the raw and C identifiers.
+ if test "$lt_cv_nm_interface" = "MS dumpbin"; then
+ # Fake it for dumpbin and say T for any non-static function
+ # and D for any global variable.
+ # Also find C++ and __fastcall symbols from MSVC++,
+ # which start with @ or ?.
+ lt_cv_sys_global_symbol_pipe="$AWK ['"\
+" {last_section=section; section=\$ 3};"\
+" /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\
+" \$ 0!~/External *\|/{next};"\
+" / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\
+" {if(hide[section]) next};"\
+" {f=0}; \$ 0~/\(\).*\|/{f=1}; {printf f ? \"T \" : \"D \"};"\
+" {split(\$ 0, a, /\||\r/); split(a[2], s)};"\
+" s[1]~/^[@?]/{print s[1], s[1]; next};"\
+" s[1]~prfx {split(s[1],t,\"@\"); print t[1], substr(t[1],length(prfx))}"\
+" ' prfx=^$ac_symprfx]"
+ else
+ lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[[ ]]\($symcode$symcode*\)[[ ]][[ ]]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'"
+ fi
+
+ # Check to see that the pipe works correctly.
+ pipe_works=no
+
+ rm -f conftest*
+ cat > conftest.$ac_ext <<_LT_EOF
+#ifdef __cplusplus
+extern "C" {
+#endif
+char nm_test_var;
+void nm_test_func(void);
+void nm_test_func(void){}
+#ifdef __cplusplus
+}
+#endif
+int main(){nm_test_var='a';nm_test_func();return(0);}
+_LT_EOF
+
+ if AC_TRY_EVAL(ac_compile); then
+ # Now try to grab the symbols.
+ nlist=conftest.nm
+ if AC_TRY_EVAL(NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist) && test -s "$nlist"; then
+ # Try sorting and uniquifying the output.
+ if sort "$nlist" | uniq > "$nlist"T; then
+ mv -f "$nlist"T "$nlist"
+ else
+ rm -f "$nlist"T
+ fi
+
+ # Make sure that we snagged all the symbols we need.
+ if $GREP ' nm_test_var$' "$nlist" >/dev/null; then
+ if $GREP ' nm_test_func$' "$nlist" >/dev/null; then
+ cat <<_LT_EOF > conftest.$ac_ext
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+_LT_EOF
+ # Now generate the symbol file.
+ eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext'
+
+ cat <<_LT_EOF >> conftest.$ac_ext
+
+/* The mapping between symbol names and symbols. */
+const struct {
+ const char *name;
+ void *address;
+}
+lt__PROGRAM__LTX_preloaded_symbols[[]] =
+{
+ { "@PROGRAM@", (void *) 0 },
+_LT_EOF
+ $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (void *) \&\2},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext
+ cat <<\_LT_EOF >> conftest.$ac_ext
+ {0, (void *) 0}
+};
+
+/* This works around a problem in FreeBSD linker */
+#ifdef FREEBSD_WORKAROUND
+static const void *lt_preloaded_setup() {
+ return lt__PROGRAM__LTX_preloaded_symbols;
+}
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+_LT_EOF
+ # Now try linking the two files.
+ mv conftest.$ac_objext conftstm.$ac_objext
+ lt_save_LIBS="$LIBS"
+ lt_save_CFLAGS="$CFLAGS"
+ LIBS="conftstm.$ac_objext"
+ CFLAGS="$CFLAGS$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)"
+ if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext}; then
+ pipe_works=yes
+ fi
+ LIBS="$lt_save_LIBS"
+ CFLAGS="$lt_save_CFLAGS"
+ else
+ echo "cannot find nm_test_func in $nlist" >&AS_MESSAGE_LOG_FD
+ fi
+ else
+ echo "cannot find nm_test_var in $nlist" >&AS_MESSAGE_LOG_FD
+ fi
+ else
+ echo "cannot run $lt_cv_sys_global_symbol_pipe" >&AS_MESSAGE_LOG_FD
+ fi
+ else
+ echo "$progname: failed program was:" >&AS_MESSAGE_LOG_FD
+ cat conftest.$ac_ext >&5
+ fi
+ rm -rf conftest* conftst*
+
+ # Do not use the global_symbol_pipe unless it works.
+ if test "$pipe_works" = yes; then
+ break
+ else
+ lt_cv_sys_global_symbol_pipe=
+ fi
+done
+])
+if test -z "$lt_cv_sys_global_symbol_pipe"; then
+ lt_cv_sys_global_symbol_to_cdecl=
+fi
+if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then
+ AC_MSG_RESULT(failed)
+else
+ AC_MSG_RESULT(ok)
+fi
+
+_LT_DECL([global_symbol_pipe], [lt_cv_sys_global_symbol_pipe], [1],
+ [Take the output of nm and produce a listing of raw symbols and C names])
+_LT_DECL([global_symbol_to_cdecl], [lt_cv_sys_global_symbol_to_cdecl], [1],
+ [Transform the output of nm in a proper C declaration])
+_LT_DECL([global_symbol_to_c_name_address],
+ [lt_cv_sys_global_symbol_to_c_name_address], [1],
+ [Transform the output of nm in a C name address pair])
+_LT_DECL([global_symbol_to_c_name_address_lib_prefix],
+ [lt_cv_sys_global_symbol_to_c_name_address_lib_prefix], [1],
+ [Transform the output of nm in a C name address pair when lib prefix is needed])
+]) # _LT_CMD_GLOBAL_SYMBOLS
+
+
+# _LT_COMPILER_PIC([TAGNAME])
+# ---------------------------
+m4_defun([_LT_COMPILER_PIC],
+[m4_require([_LT_TAG_COMPILER])dnl
+_LT_TAGVAR(lt_prog_compiler_wl, $1)=
+_LT_TAGVAR(lt_prog_compiler_pic, $1)=
+_LT_TAGVAR(lt_prog_compiler_static, $1)=
+
+AC_MSG_CHECKING([for $compiler option to produce PIC])
+m4_if([$1], [CXX], [
+ # C++ specific cases for pic, static, wl, etc.
+ if test "$GXX" = yes; then
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
+
+ case $host_os in
+ aix*)
+ # All AIX code is PIC.
+ if test "$host_cpu" = ia64; then
+ # AIX 5 now supports IA64 processor
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ fi
+ ;;
+
+ amigaos*)
+ case $host_cpu in
+ powerpc)
+ # see comment about AmigaOS4 .so support
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+ ;;
+ m68k)
+ # FIXME: we need at least 68020 code to build shared libraries, but
+ # adding the `-m68020' flag to GCC prevents building anything better,
+ # like `-m68040'.
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4'
+ ;;
+ esac
+ ;;
+
+ beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
+ # PIC is the default for these OSes.
+ ;;
+ mingw* | cygwin* | os2* | pw32* | cegcc*)
+ # This hack is so that the source file can tell whether it is being
+ # built for inclusion in a dll (and should export symbols for example).
+ # Although the cygwin gcc ignores -fPIC, still need this for old-style
+ # (--disable-auto-import) libraries
+ m4_if([$1], [GCJ], [],
+ [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'])
+ ;;
+ darwin* | rhapsody*)
+ # PIC is the default on this platform
+ # Common symbols not allowed in MH_DYLIB files
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common'
+ ;;
+ *djgpp*)
+ # DJGPP does not support shared libraries at all
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)=
+ ;;
+ interix[[3-9]]*)
+ # Interix 3.x gcc -fpic/-fPIC options generate broken code.
+ # Instead, we relocate shared libraries at runtime.
+ ;;
+ sysv4*MP*)
+ if test -d /usr/nec; then
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic
+ fi
+ ;;
+ hpux*)
+ # PIC is the default for 64-bit PA HP-UX, but not for 32-bit
+ # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag
+ # sets the default TLS model and affects inlining.
+ case $host_cpu in
+ hppa*64*)
+ ;;
+ *)
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+ ;;
+ esac
+ ;;
+ *qnx* | *nto*)
+ # QNX uses GNU C++, but need to define -shared option too, otherwise
+ # it will coredump.
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared'
+ ;;
+ *)
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+ ;;
+ esac
+ else
+ case $host_os in
+ aix[[4-9]]*)
+ # All AIX code is PIC.
+ if test "$host_cpu" = ia64; then
+ # AIX 5 now supports IA64 processor
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ else
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp'
+ fi
+ ;;
+ chorus*)
+ case $cc_basename in
+ cxch68*)
+ # Green Hills C++ Compiler
+ # _LT_TAGVAR(lt_prog_compiler_static, $1)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a"
+ ;;
+ esac
+ ;;
+ dgux*)
+ case $cc_basename in
+ ec++*)
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+ ;;
+ ghcx*)
+ # Green Hills C++ Compiler
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
+ ;;
+ *)
+ ;;
+ esac
+ ;;
+ freebsd* | dragonfly*)
+ # FreeBSD uses GNU C++
+ ;;
+ hpux9* | hpux10* | hpux11*)
+ case $cc_basename in
+ CC*)
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
+ if test "$host_cpu" != ia64; then
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z'
+ fi
+ ;;
+ aCC*)
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
+ case $host_cpu in
+ hppa*64*|ia64*)
+ # +Z the default
+ ;;
+ *)
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z'
+ ;;
+ esac
+ ;;
+ *)
+ ;;
+ esac
+ ;;
+ interix*)
+ # This is c89, which is MS Visual C++ (no shared libs)
+ # Anyone wants to do a port?
+ ;;
+ irix5* | irix6* | nonstopux*)
+ case $cc_basename in
+ CC*)
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
+ # CC pic flag -KPIC is the default.
+ ;;
+ *)
+ ;;
+ esac
+ ;;
+ linux* | k*bsd*-gnu)
+ case $cc_basename in
+ KCC*)
+ # KAI C++ Compiler
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,'
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+ ;;
+ ecpc* )
+ # old Intel C++ for x86_64 which still supported -KPIC.
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
+ ;;
+ icpc* )
+ # Intel C++, used to be incompatible with GCC.
+ # ICC 10 doesn't accept -KPIC any more.
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
+ ;;
+ pgCC* | pgcpp*)
+ # Portland Group C++ compiler
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ ;;
+ cxx*)
+ # Compaq C++
+ # Make sure the PIC flag is empty. It appears that all Alpha
+ # Linux and Compaq Tru64 Unix objects are PIC.
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)=
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
+ ;;
+ xlc* | xlC*)
+ # IBM XL 8.0 on PPC
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink'
+ ;;
+ *)
+ case `$CC -V 2>&1 | sed 5q` in
+ *Sun\ C*)
+ # Sun C++ 5.9
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld '
+ ;;
+ esac
+ ;;
+ esac
+ ;;
+ lynxos*)
+ ;;
+ m88k*)
+ ;;
+ mvs*)
+ case $cc_basename in
+ cxx*)
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-W c,exportall'
+ ;;
+ *)
+ ;;
+ esac
+ ;;
+ netbsd* | netbsdelf*-gnu)
+ ;;
+ *qnx* | *nto*)
+ # QNX uses GNU C++, but need to define -shared option too, otherwise
+ # it will coredump.
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared'
+ ;;
+ osf3* | osf4* | osf5*)
+ case $cc_basename in
+ KCC*)
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,'
+ ;;
+ RCC*)
+ # Rational C++ 2.4.1
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
+ ;;
+ cxx*)
+ # Digital/Compaq C++
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ # Make sure the PIC flag is empty. It appears that all Alpha
+ # Linux and Compaq Tru64 Unix objects are PIC.
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)=
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
+ ;;
+ *)
+ ;;
+ esac
+ ;;
+ psos*)
+ ;;
+ solaris*)
+ case $cc_basename in
+ CC*)
+ # Sun C++ 4.2, 5.x and Centerline C++
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld '
+ ;;
+ gcx*)
+ # Green Hills C++ Compiler
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC'
+ ;;
+ *)
+ ;;
+ esac
+ ;;
+ sunos4*)
+ case $cc_basename in
+ CC*)
+ # Sun C++ 4.x
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ ;;
+ lcc*)
+ # Lucid
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
+ ;;
+ *)
+ ;;
+ esac
+ ;;
+ sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
+ case $cc_basename in
+ CC*)
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ ;;
+ esac
+ ;;
+ tandem*)
+ case $cc_basename in
+ NCC*)
+ # NonStop-UX NCC 3.20
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+ ;;
+ *)
+ ;;
+ esac
+ ;;
+ vxworks*)
+ ;;
+ *)
+ _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
+ ;;
+ esac
+ fi
+],
+[
+ if test "$GCC" = yes; then
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
+
+ case $host_os in
+ aix*)
+ # All AIX code is PIC.
+ if test "$host_cpu" = ia64; then
+ # AIX 5 now supports IA64 processor
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ fi
+ ;;
+
+ amigaos*)
+ case $host_cpu in
+ powerpc)
+ # see comment about AmigaOS4 .so support
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+ ;;
+ m68k)
+ # FIXME: we need at least 68020 code to build shared libraries, but
+ # adding the `-m68020' flag to GCC prevents building anything better,
+ # like `-m68040'.
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4'
+ ;;
+ esac
+ ;;
+
+ beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
+ # PIC is the default for these OSes.
+ ;;
+
+ mingw* | cygwin* | pw32* | os2* | cegcc*)
+ # This hack is so that the source file can tell whether it is being
+ # built for inclusion in a dll (and should export symbols for example).
+ # Although the cygwin gcc ignores -fPIC, still need this for old-style
+ # (--disable-auto-import) libraries
+ m4_if([$1], [GCJ], [],
+ [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'])
+ ;;
+
+ darwin* | rhapsody*)
+ # PIC is the default on this platform
+ # Common symbols not allowed in MH_DYLIB files
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common'
+ ;;
+
+ hpux*)
+ # PIC is the default for 64-bit PA HP-UX, but not for 32-bit
+ # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag
+ # sets the default TLS model and affects inlining.
+ case $host_cpu in
+ hppa*64*)
+ # +Z the default
+ ;;
+ *)
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+ ;;
+ esac
+ ;;
+
+ interix[[3-9]]*)
+ # Interix 3.x gcc -fpic/-fPIC options generate broken code.
+ # Instead, we relocate shared libraries at runtime.
+ ;;
+
+ msdosdjgpp*)
+ # Just because we use GCC doesn't mean we suddenly get shared libraries
+ # on systems that don't support them.
+ _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
+ enable_shared=no
+ ;;
+
+ *nto* | *qnx*)
+ # QNX uses GNU C++, but need to define -shared option too, otherwise
+ # it will coredump.
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared'
+ ;;
+
+ sysv4*MP*)
+ if test -d /usr/nec; then
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic
+ fi
+ ;;
+
+ *)
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+ ;;
+ esac
+ else
+ # PORTME Check for flag to pass linker flags through the system compiler.
+ case $host_os in
+ aix*)
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ if test "$host_cpu" = ia64; then
+ # AIX 5 now supports IA64 processor
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ else
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp'
+ fi
+ ;;
+
+ mingw* | cygwin* | pw32* | os2* | cegcc*)
+ # This hack is so that the source file can tell whether it is being
+ # built for inclusion in a dll (and should export symbols for example).
+ m4_if([$1], [GCJ], [],
+ [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'])
+ ;;
+
+ hpux9* | hpux10* | hpux11*)
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
+ # not for PA HP-UX.
+ case $host_cpu in
+ hppa*64*|ia64*)
+ # +Z the default
+ ;;
+ *)
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z'
+ ;;
+ esac
+ # Is there a better lt_prog_compiler_static that works with the bundled CC?
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
+ ;;
+
+ irix5* | irix6* | nonstopux*)
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ # PIC (with -KPIC) is the default.
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
+ ;;
+
+ linux* | k*bsd*-gnu)
+ case $cc_basename in
+ # old Intel for x86_64 which still supported -KPIC.
+ ecc*)
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
+ ;;
+ # icc used to be incompatible with GCC.
+ # ICC 10 doesn't accept -KPIC any more.
+ icc* | ifort*)
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
+ ;;
+ # Lahey Fortran 8.1.
+ lf95*)
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='--shared'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='--static'
+ ;;
+ pgcc* | pgf77* | pgf90* | pgf95*)
+ # Portland Group compilers (*not* the Pentium gcc compiler,
+ # which looks to be a dead project)
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ ;;
+ ccc*)
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ # All Alpha code is PIC.
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
+ ;;
+ xl*)
+ # IBM XL C 8.0/Fortran 10.1 on PPC
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink'
+ ;;
+ *)
+ case `$CC -V 2>&1 | sed 5q` in
+ *Sun\ C*)
+ # Sun C 5.9
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ ;;
+ *Sun\ F*)
+ # Sun Fortran 8.3 passes all unrecognized flags to the linker
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)=''
+ ;;
+ esac
+ ;;
+ esac
+ ;;
+
+ newsos6)
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ ;;
+
+ *nto* | *qnx*)
+ # QNX uses GNU C++, but need to define -shared option too, otherwise
+ # it will coredump.
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared'
+ ;;
+
+ osf3* | osf4* | osf5*)
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ # All OSF/1 code is PIC.
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
+ ;;
+
+ rdos*)
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
+ ;;
+
+ solaris*)
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ case $cc_basename in
+ f77* | f90* | f95*)
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ';;
+ *)
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,';;
+ esac
+ ;;
+
+ sunos4*)
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld '
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ ;;
+
+ sysv4 | sysv4.2uw2* | sysv4.3*)
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ ;;
+
+ sysv4*MP*)
+ if test -d /usr/nec ;then
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-Kconform_pic'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ fi
+ ;;
+
+ sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ ;;
+
+ unicos*)
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
+ ;;
+
+ uts4*)
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ ;;
+
+ *)
+ _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
+ ;;
+ esac
+ fi
+])
+case $host_os in
+ # For platforms which do not support PIC, -DPIC is meaningless:
+ *djgpp*)
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)=
+ ;;
+ *)
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)="$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t at m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])"
+ ;;
+esac
+AC_MSG_RESULT([$_LT_TAGVAR(lt_prog_compiler_pic, $1)])
+_LT_TAGDECL([wl], [lt_prog_compiler_wl], [1],
+ [How to pass a linker flag through the compiler])
+
+#
+# Check to make sure the PIC flag actually works.
+#
+if test -n "$_LT_TAGVAR(lt_prog_compiler_pic, $1)"; then
+ _LT_COMPILER_OPTION([if $compiler PIC flag $_LT_TAGVAR(lt_prog_compiler_pic, $1) works],
+ [_LT_TAGVAR(lt_cv_prog_compiler_pic_works, $1)],
+ [$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t at m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])], [],
+ [case $_LT_TAGVAR(lt_prog_compiler_pic, $1) in
+ "" | " "*) ;;
+ *) _LT_TAGVAR(lt_prog_compiler_pic, $1)=" $_LT_TAGVAR(lt_prog_compiler_pic, $1)" ;;
+ esac],
+ [_LT_TAGVAR(lt_prog_compiler_pic, $1)=
+ _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no])
+fi
+_LT_TAGDECL([pic_flag], [lt_prog_compiler_pic], [1],
+ [Additional compiler flags for building library objects])
+
+#
+# Check to make sure the static flag actually works.
+#
+wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1) eval lt_tmp_static_flag=\"$_LT_TAGVAR(lt_prog_compiler_static, $1)\"
+_LT_LINKER_OPTION([if $compiler static flag $lt_tmp_static_flag works],
+ _LT_TAGVAR(lt_cv_prog_compiler_static_works, $1),
+ $lt_tmp_static_flag,
+ [],
+ [_LT_TAGVAR(lt_prog_compiler_static, $1)=])
+_LT_TAGDECL([link_static_flag], [lt_prog_compiler_static], [1],
+ [Compiler flag to prevent dynamic linking])
+])# _LT_COMPILER_PIC
+
+
+# _LT_LINKER_SHLIBS([TAGNAME])
+# ----------------------------
+# See if the linker supports building shared libraries.
+m4_defun([_LT_LINKER_SHLIBS],
+[AC_REQUIRE([LT_PATH_LD])dnl
+AC_REQUIRE([LT_PATH_NM])dnl
+m4_require([_LT_FILEUTILS_DEFAULTS])dnl
+m4_require([_LT_DECL_EGREP])dnl
+m4_require([_LT_DECL_SED])dnl
+m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl
+m4_require([_LT_TAG_COMPILER])dnl
+AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries])
+m4_if([$1], [CXX], [
+ _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
+ case $host_os in
+ aix[[4-9]]*)
+ # If we're using GNU nm, then we don't want the "-C" option.
+ # -C means demangle to AIX nm, but means don't demangle with GNU nm
+ if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then
+ _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+ else
+ _LT_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+ fi
+ ;;
+ pw32*)
+ _LT_TAGVAR(export_symbols_cmds, $1)="$ltdll_cmds"
+ ;;
+ cygwin* | mingw* | cegcc*)
+ _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;/^.*[[ ]]__nm__/s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\'' | sort | uniq > $export_symbols'
+ ;;
+ linux* | k*bsd*-gnu)
+ _LT_TAGVAR(link_all_deplibs, $1)=no
+ ;;
+ *)
+ _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
+ ;;
+ esac
+ _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*']
+], [
+ runpath_var=
+ _LT_TAGVAR(allow_undefined_flag, $1)=
+ _LT_TAGVAR(always_export_symbols, $1)=no
+ _LT_TAGVAR(archive_cmds, $1)=
+ _LT_TAGVAR(archive_expsym_cmds, $1)=
+ _LT_TAGVAR(compiler_needs_object, $1)=no
+ _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)=
+ _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
+ _LT_TAGVAR(hardcode_automatic, $1)=no
+ _LT_TAGVAR(hardcode_direct, $1)=no
+ _LT_TAGVAR(hardcode_direct_absolute, $1)=no
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
+ _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
+ _LT_TAGVAR(hardcode_libdir_separator, $1)=
+ _LT_TAGVAR(hardcode_minus_L, $1)=no
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
+ _LT_TAGVAR(inherit_rpath, $1)=no
+ _LT_TAGVAR(link_all_deplibs, $1)=unknown
+ _LT_TAGVAR(module_cmds, $1)=
+ _LT_TAGVAR(module_expsym_cmds, $1)=
+ _LT_TAGVAR(old_archive_from_new_cmds, $1)=
+ _LT_TAGVAR(old_archive_from_expsyms_cmds, $1)=
+ _LT_TAGVAR(thread_safe_flag_spec, $1)=
+ _LT_TAGVAR(whole_archive_flag_spec, $1)=
+ # include_expsyms should be a list of space-separated symbols to be *always*
+ # included in the symbol list
+ _LT_TAGVAR(include_expsyms, $1)=
+ # exclude_expsyms can be an extended regexp of symbols to exclude
+ # it will be wrapped by ` (' and `)$', so one must not match beginning or
+ # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc',
+ # as well as any symbol that contains `d'.
+ _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*']
+ # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out
+ # platforms (ab)use it in PIC code, but their linkers get confused if
+ # the symbol is explicitly referenced. Since portable code cannot
+ # rely on this symbol name, it's probably fine to never include it in
+ # preloaded symbol tables.
+ # Exclude shared library initialization/finalization symbols.
+dnl Note also adjust exclude_expsyms for C++ above.
+ extract_expsyms_cmds=
+
+ case $host_os in
+ cygwin* | mingw* | pw32* | cegcc*)
+ # FIXME: the MSVC++ port hasn't been tested in a loooong time
+ # When not using gcc, we currently assume that we are using
+ # Microsoft Visual C++.
+ if test "$GCC" != yes; then
+ with_gnu_ld=no
+ fi
+ ;;
+ interix*)
+ # we just hope/assume this is gcc and not c89 (= MSVC++)
+ with_gnu_ld=yes
+ ;;
+ openbsd*)
+ with_gnu_ld=no
+ ;;
+ esac
+
+ _LT_TAGVAR(ld_shlibs, $1)=yes
+ if test "$with_gnu_ld" = yes; then
+ # If archive_cmds runs LD, not CC, wlarc should be empty
+ wlarc='${wl}'
+
+ # Set some defaults for GNU ld with shared library support. These
+ # are reset later if shared libraries are not supported. Putting them
+ # here allows them to be overridden if necessary.
+ runpath_var=LD_RUN_PATH
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+ # ancient GNU ld didn't support --whole-archive et. al.
+ if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then
+ _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+ else
+ _LT_TAGVAR(whole_archive_flag_spec, $1)=
+ fi
+ supports_anon_versioning=no
+ case `$LD -v 2>&1` in
+ *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.10.*) ;; # catch versions < 2.11
+ *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
+ *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ...
+ *\ 2.11.*) ;; # other 2.11 versions
+ *) supports_anon_versioning=yes ;;
+ esac
+
+ # See if GNU ld supports shared libraries.
+ case $host_os in
+ aix[[3-9]]*)
+ # On AIX/PPC, the GNU linker is very broken
+ if test "$host_cpu" != ia64; then
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ cat <<_LT_EOF 1>&2
+
+*** Warning: the GNU linker, at least up to release 2.9.1, is reported
+*** to be unable to reliably create shared libraries on AIX.
+*** Therefore, libtool is disabling shared libraries support. If you
+*** really care for shared libraries, you may want to modify your PATH
+*** so that a non-GNU linker is found, and then restart.
+
+_LT_EOF
+ fi
+ ;;
+
+ amigaos*)
+ case $host_cpu in
+ powerpc)
+ # see comment about AmigaOS4 .so support
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)=''
+ ;;
+ m68k)
+ _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+ _LT_TAGVAR(hardcode_minus_L, $1)=yes
+ ;;
+ esac
+ ;;
+
+ beos*)
+ if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+ _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
+ # Joseph Beckenbach <jrb3 at best.com> says some releases of gcc
+ # support --undefined. This deserves some investigation. FIXME
+ _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ else
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ fi
+ ;;
+
+ cygwin* | mingw* | pw32* | cegcc*)
+ # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless,
+ # as there is no search path for DLLs.
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+ _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
+ _LT_TAGVAR(always_export_symbols, $1)=no
+ _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
+ _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/'\'' | $SED -e '\''/^[[AITW]][[ ]]/s/.*[[ ]]//'\'' | sort | uniq > $export_symbols'
+
+ if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+ # If the export-symbols file already is a .def file (1st line
+ # is EXPORTS), use it as is; otherwise, prepend...
+ _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
+ cp $export_symbols $output_objdir/$soname.def;
+ else
+ echo EXPORTS > $output_objdir/$soname.def;
+ cat $export_symbols >> $output_objdir/$soname.def;
+ fi~
+ $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+ else
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ fi
+ ;;
+
+ interix[[3-9]]*)
+ _LT_TAGVAR(hardcode_direct, $1)=no
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+ # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
+ # Instead, shared libraries are loaded at an image base (0x10000000 by
+ # default) and relocated if they conflict, which is a slow very memory
+ # consuming and fragmenting process. To avoid this, we pick a random,
+ # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
+ # time. Moving up from 0x10000000 also allows more sbrk(2) space.
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+ ;;
+
+ gnu* | linux* | tpf* | k*bsd*-gnu)
+ tmp_diet=no
+ if test "$host_os" = linux-dietlibc; then
+ case $cc_basename in
+ diet\ *) tmp_diet=yes;; # linux-dietlibc with static linking (!diet-dyn)
+ esac
+ fi
+ if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \
+ && test "$tmp_diet" = no
+ then
+ tmp_addflag=
+ tmp_sharedflag='-shared'
+ case $cc_basename,$host_cpu in
+ pgcc*) # Portland Group C compiler
+ _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive'
+ tmp_addflag=' $pic_flag'
+ ;;
+ pgf77* | pgf90* | pgf95*) # Portland Group f77 and f90 compilers
+ _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive'
+ tmp_addflag=' $pic_flag -Mnomain' ;;
+ ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64
+ tmp_addflag=' -i_dynamic' ;;
+ efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64
+ tmp_addflag=' -i_dynamic -nofor_main' ;;
+ ifc* | ifort*) # Intel Fortran compiler
+ tmp_addflag=' -nofor_main' ;;
+ lf95*) # Lahey Fortran 8.1
+ _LT_TAGVAR(whole_archive_flag_spec, $1)=
+ tmp_sharedflag='--shared' ;;
+ xl[[cC]]*) # IBM XL C 8.0 on PPC (deal with xlf below)
+ tmp_sharedflag='-qmkshrobj'
+ tmp_addflag= ;;
+ esac
+ case `$CC -V 2>&1 | sed 5q` in
+ *Sun\ C*) # Sun C 5.9
+ _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive'
+ _LT_TAGVAR(compiler_needs_object, $1)=yes
+ tmp_sharedflag='-G' ;;
+ *Sun\ F*) # Sun Fortran 8.3
+ tmp_sharedflag='-G' ;;
+ esac
+ _LT_TAGVAR(archive_cmds, $1)='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+
+ if test "x$supports_anon_versioning" = xyes; then
+ _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~
+ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+ echo "local: *; };" >> $output_objdir/$libname.ver~
+ $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
+ fi
+
+ case $cc_basename in
+ xlf*)
+ # IBM XL Fortran 10.1 on PPC cannot create shared libs itself
+ _LT_TAGVAR(whole_archive_flag_spec, $1)='--whole-archive$convenience --no-whole-archive'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
+ _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='-rpath $libdir'
+ _LT_TAGVAR(archive_cmds, $1)='$LD -shared $libobjs $deplibs $compiler_flags -soname $soname -o $lib'
+ if test "x$supports_anon_versioning" = xyes; then
+ _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~
+ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+ echo "local: *; };" >> $output_objdir/$libname.ver~
+ $LD -shared $libobjs $deplibs $compiler_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib'
+ fi
+ ;;
+ esac
+ else
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ fi
+ ;;
+
+ netbsd* | netbsdelf*-gnu)
+ if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
+ _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
+ wlarc=
+ else
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+ fi
+ ;;
+
+ solaris*)
+ if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ cat <<_LT_EOF 1>&2
+
+*** Warning: The releases 2.8.* of the GNU linker cannot reliably
+*** create shared libraries on Solaris systems. Therefore, libtool
+*** is disabling shared libraries support. We urge you to upgrade GNU
+*** binutils to release 2.9.1 or newer. Another option is to modify
+*** your PATH or compiler configuration so that the native linker is
+*** used, and then restart.
+
+_LT_EOF
+ elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+ else
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ fi
+ ;;
+
+ sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*)
+ case `$LD -v 2>&1` in
+ *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.1[[0-5]].*)
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ cat <<_LT_EOF 1>&2
+
+*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not
+*** reliably create shared libraries on SCO systems. Therefore, libtool
+*** is disabling shared libraries support. We urge you to upgrade GNU
+*** binutils to release 2.16.91.0.3 or newer. Another option is to modify
+*** your PATH or compiler configuration so that the native linker is
+*** used, and then restart.
+
+_LT_EOF
+ ;;
+ *)
+ # For security reasons, it is highly recommended that you always
+ # use absolute paths for naming shared libraries, and exclude the
+ # DT_RUNPATH tag from executables and libraries. But doing so
+ # requires that you compile everything twice, which is a pain.
+ if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+ else
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ fi
+ ;;
+ esac
+ ;;
+
+ sunos4*)
+ _LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+ wlarc=
+ _LT_TAGVAR(hardcode_direct, $1)=yes
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ ;;
+
+ *)
+ if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+ else
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ fi
+ ;;
+ esac
+
+ if test "$_LT_TAGVAR(ld_shlibs, $1)" = no; then
+ runpath_var=
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)=
+ _LT_TAGVAR(whole_archive_flag_spec, $1)=
+ fi
+ else
+ # PORTME fill in a description of your system's linker (not GNU ld)
+ case $host_os in
+ aix3*)
+ _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
+ _LT_TAGVAR(always_export_symbols, $1)=yes
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname'
+ # Note: this linker hardcodes the directories in LIBPATH if there
+ # are no directories specified by -L.
+ _LT_TAGVAR(hardcode_minus_L, $1)=yes
+ if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then
+ # Neither direct hardcoding nor static linking is supported with a
+ # broken collect2.
+ _LT_TAGVAR(hardcode_direct, $1)=unsupported
+ fi
+ ;;
+
+ aix[[4-9]]*)
+ if test "$host_cpu" = ia64; then
+ # On IA64, the linker does run time linking by default, so we don't
+ # have to do anything special.
+ aix_use_runtimelinking=no
+ exp_sym_flag='-Bexport'
+ no_entry_flag=""
+ else
+ # If we're using GNU nm, then we don't want the "-C" option.
+ # -C means demangle to AIX nm, but means don't demangle with GNU nm
+ if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then
+ _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+ else
+ _LT_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+ fi
+ aix_use_runtimelinking=no
+
+ # Test if we are trying to use run time linking or normal
+ # AIX style linking. If -brtl is somewhere in LDFLAGS, we
+ # need to do runtime linking.
+ case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*)
+ for ld_flag in $LDFLAGS; do
+ if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
+ aix_use_runtimelinking=yes
+ break
+ fi
+ done
+ ;;
+ esac
+
+ exp_sym_flag='-bexport'
+ no_entry_flag='-bnoentry'
+ fi
+
+ # When large executables or shared objects are built, AIX ld can
+ # have problems creating the table of contents. If linking a library
+ # or program results in "error TOC overflow" add -mminimal-toc to
+ # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not
+ # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
+
+ _LT_TAGVAR(archive_cmds, $1)=''
+ _LT_TAGVAR(hardcode_direct, $1)=yes
+ _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
+ _LT_TAGVAR(hardcode_libdir_separator, $1)=':'
+ _LT_TAGVAR(link_all_deplibs, $1)=yes
+ _LT_TAGVAR(file_list_spec, $1)='${wl}-f,'
+
+ if test "$GCC" = yes; then
+ case $host_os in aix4.[[012]]|aix4.[[012]].*)
+ # We only want to do this on AIX 4.2 and lower, the check
+ # below for broken collect2 doesn't work under 4.3+
+ collect2name=`${CC} -print-prog-name=collect2`
+ if test -f "$collect2name" &&
+ strings "$collect2name" | $GREP resolve_lib_name >/dev/null
+ then
+ # We have reworked collect2
+ :
+ else
+ # We have old collect2
+ _LT_TAGVAR(hardcode_direct, $1)=unsupported
+ # It fails to find uninstalled libraries when the uninstalled
+ # path is not listed in the libpath. Setting hardcode_minus_L
+ # to unsupported forces relinking
+ _LT_TAGVAR(hardcode_minus_L, $1)=yes
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+ _LT_TAGVAR(hardcode_libdir_separator, $1)=
+ fi
+ ;;
+ esac
+ shared_flag='-shared'
+ if test "$aix_use_runtimelinking" = yes; then
+ shared_flag="$shared_flag "'${wl}-G'
+ fi
+ _LT_TAGVAR(link_all_deplibs, $1)=no
+ else
+ # not using gcc
+ if test "$host_cpu" = ia64; then
+ # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
+ # chokes on -Wl,-G. The following line is correct:
+ shared_flag='-G'
+ else
+ if test "$aix_use_runtimelinking" = yes; then
+ shared_flag='${wl}-G'
+ else
+ shared_flag='${wl}-bM:SRE'
+ fi
+ fi
+ fi
+
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-bexpall'
+ # It seems that -bexpall does not export symbols beginning with
+ # underscore (_), so it is better to generate a list of symbols to export.
+ _LT_TAGVAR(always_export_symbols, $1)=yes
+ if test "$aix_use_runtimelinking" = yes; then
+ # Warning - without using the other runtime loading flags (-brtl),
+ # -berok will link without error, but may produce a broken library.
+ _LT_TAGVAR(allow_undefined_flag, $1)='-berok'
+ # Determine the default libpath from the value encoded in an
+ # empty executable.
+ _LT_SYS_MODULE_PATH_AIX
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then $ECHO "X${wl}${allow_undefined_flag}" | $Xsed; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
+ else
+ if test "$host_cpu" = ia64; then
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib'
+ _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs"
+ _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
+ else
+ # Determine the default libpath from the value encoded in an
+ # empty executable.
+ _LT_SYS_MODULE_PATH_AIX
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
+ # Warning - without using the other run time loading flags,
+ # -berok will link without error, but may produce a broken library.
+ _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok'
+ _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok'
+ # Exported symbols can be pulled into shared objects from archives
+ _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience'
+ _LT_TAGVAR(archive_cmds_need_lc, $1)=yes
+ # This is similar to how AIX traditionally builds its shared libraries.
+ _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
+ fi
+ fi
+ ;;
+
+ amigaos*)
+ case $host_cpu in
+ powerpc)
+ # see comment about AmigaOS4 .so support
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)=''
+ ;;
+ m68k)
+ _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+ _LT_TAGVAR(hardcode_minus_L, $1)=yes
+ ;;
+ esac
+ ;;
+
+ bsdi[[45]]*)
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)=-rdynamic
+ ;;
+
+ cygwin* | mingw* | pw32* | cegcc*)
+ # When not using gcc, we currently assume that we are using
+ # Microsoft Visual C++.
+ # hardcode_libdir_flag_spec is actually meaningless, as there is
+ # no search path for DLLs.
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' '
+ _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
+ # Tell ltmain to make .lib files, not .a files.
+ libext=lib
+ # Tell ltmain to make .dll files, not .so files.
+ shrext_cmds=".dll"
+ # FIXME: Setting linknames here is a bad hack.
+ _LT_TAGVAR(archive_cmds, $1)='$CC -o $lib $libobjs $compiler_flags `$ECHO "X$deplibs" | $Xsed -e '\''s/ -lc$//'\''` -link -dll~linknames='
+ # The linker will automatically build a .lib file if we build a DLL.
+ _LT_TAGVAR(old_archive_from_new_cmds, $1)='true'
+ # FIXME: Should let the user specify the lib program.
+ _LT_TAGVAR(old_archive_cmds, $1)='lib -OUT:$oldlib$oldobjs$old_deplibs'
+ _LT_TAGVAR(fix_srcfile_path, $1)='`cygpath -w "$srcfile"`'
+ _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
+ ;;
+
+ darwin* | rhapsody*)
+ _LT_DARWIN_LINKER_FEATURES($1)
+ ;;
+
+ dgux*)
+ _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ ;;
+
+ freebsd1*)
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+
+ # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor
+ # support. Future versions do this automatically, but an explicit c++rt0.o
+ # does not break anything, and helps significantly (at the cost of a little
+ # extra space).
+ freebsd2.2*)
+ _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+ _LT_TAGVAR(hardcode_direct, $1)=yes
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ ;;
+
+ # Unfortunately, older versions of FreeBSD 2 do not have this feature.
+ freebsd2*)
+ _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+ _LT_TAGVAR(hardcode_direct, $1)=yes
+ _LT_TAGVAR(hardcode_minus_L, $1)=yes
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ ;;
+
+ # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
+ freebsd* | dragonfly*)
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+ _LT_TAGVAR(hardcode_direct, $1)=yes
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ ;;
+
+ hpux9*)
+ if test "$GCC" = yes; then
+ _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+ else
+ _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+ fi
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+ _LT_TAGVAR(hardcode_direct, $1)=yes
+
+ # hardcode_minus_L: Not really in the search PATH,
+ # but as the default location of the library.
+ _LT_TAGVAR(hardcode_minus_L, $1)=yes
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+ ;;
+
+ hpux10*)
+ if test "$GCC" = yes -a "$with_gnu_ld" = no; then
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+ else
+ _LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
+ fi
+ if test "$with_gnu_ld" = no; then
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+ _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='+b $libdir'
+ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+ _LT_TAGVAR(hardcode_direct, $1)=yes
+ _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+ # hardcode_minus_L: Not really in the search PATH,
+ # but as the default location of the library.
+ _LT_TAGVAR(hardcode_minus_L, $1)=yes
+ fi
+ ;;
+
+ hpux11*)
+ if test "$GCC" = yes -a "$with_gnu_ld" = no; then
+ case $host_cpu in
+ hppa*64*)
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+ ;;
+ ia64*)
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
+ ;;
+ *)
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+ ;;
+ esac
+ else
+ case $host_cpu in
+ hppa*64*)
+ _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+ ;;
+ ia64*)
+ _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
+ ;;
+ *)
+ _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+ ;;
+ esac
+ fi
+ if test "$with_gnu_ld" = no; then
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+
+ case $host_cpu in
+ hppa*64*|ia64*)
+ _LT_TAGVAR(hardcode_direct, $1)=no
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ ;;
+ *)
+ _LT_TAGVAR(hardcode_direct, $1)=yes
+ _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+
+ # hardcode_minus_L: Not really in the search PATH,
+ # but as the default location of the library.
+ _LT_TAGVAR(hardcode_minus_L, $1)=yes
+ ;;
+ esac
+ fi
+ ;;
+
+ irix5* | irix6* | nonstopux*)
+ if test "$GCC" = yes; then
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+ # Try to use the -exported_symbol ld option, if it does not
+ # work, assume that -exports_file does not work either and
+ # implicitly export all symbols.
+ save_LDFLAGS="$LDFLAGS"
+ LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null"
+ AC_LINK_IFELSE(int foo(void) {},
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib'
+ )
+ LDFLAGS="$save_LDFLAGS"
+ else
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib'
+ fi
+ _LT_TAGVAR(archive_cmds_need_lc, $1)='no'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+ _LT_TAGVAR(inherit_rpath, $1)=yes
+ _LT_TAGVAR(link_all_deplibs, $1)=yes
+ ;;
+
+ netbsd* | netbsdelf*-gnu)
+ if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
+ _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out
+ else
+ _LT_TAGVAR(archive_cmds, $1)='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF
+ fi
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+ _LT_TAGVAR(hardcode_direct, $1)=yes
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ ;;
+
+ newsos6)
+ _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ _LT_TAGVAR(hardcode_direct, $1)=yes
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ ;;
+
+ *nto* | *qnx*)
+ ;;
+
+ openbsd*)
+ if test -f /usr/libexec/ld.so; then
+ _LT_TAGVAR(hardcode_direct, $1)=yes
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
+ if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+ else
+ case $host_os in
+ openbsd[[01]].* | openbsd2.[[0-7]] | openbsd2.[[0-7]].*)
+ _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+ ;;
+ *)
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+ ;;
+ esac
+ fi
+ else
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ fi
+ ;;
+
+ os2*)
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+ _LT_TAGVAR(hardcode_minus_L, $1)=yes
+ _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
+ _LT_TAGVAR(archive_cmds, $1)='$ECHO "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$ECHO DATA >> $output_objdir/$libname.def~$ECHO " SINGLE NONSHARED" >> $output_objdir/$libname.def~$ECHO EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def'
+ _LT_TAGVAR(old_archive_from_new_cmds, $1)='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def'
+ ;;
+
+ osf3*)
+ if test "$GCC" = yes; then
+ _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+ else
+ _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib'
+ fi
+ _LT_TAGVAR(archive_cmds_need_lc, $1)='no'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+ ;;
+
+ osf4* | osf5*) # as osf3* with the addition of -msym flag
+ if test "$GCC" = yes; then
+ _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+ else
+ _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~
+ $CC -shared${allow_undefined_flag} ${wl}-input ${wl}$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp'
+
+ # Both c and cxx compiler support -rpath directly
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
+ fi
+ _LT_TAGVAR(archive_cmds_need_lc, $1)='no'
+ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+ ;;
+
+ solaris*)
+ _LT_TAGVAR(no_undefined_flag, $1)=' -z defs'
+ if test "$GCC" = yes; then
+ wlarc='${wl}'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+ $CC -shared ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
+ else
+ case `$CC -V 2>&1` in
+ *"Compilers 5.0"*)
+ wlarc=''
+ _LT_TAGVAR(archive_cmds, $1)='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+ $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp'
+ ;;
+ *)
+ wlarc='${wl}'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+ $CC -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
+ ;;
+ esac
+ fi
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ case $host_os in
+ solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
+ *)
+ # The compiler driver will combine and reorder linker options,
+ # but understands `-z linker_flag'. GCC discards it without `$wl',
+ # but is careful enough not to reorder.
+ # Supported since Solaris 2.6 (maybe 2.5.1?)
+ if test "$GCC" = yes; then
+ _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
+ else
+ _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract'
+ fi
+ ;;
+ esac
+ _LT_TAGVAR(link_all_deplibs, $1)=yes
+ ;;
+
+ sunos4*)
+ if test "x$host_vendor" = xsequent; then
+ # Use $CC to link under sequent, because it throws in some extra .o
+ # files that make .init and .fini sections work.
+ _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags'
+ else
+ _LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags'
+ fi
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+ _LT_TAGVAR(hardcode_direct, $1)=yes
+ _LT_TAGVAR(hardcode_minus_L, $1)=yes
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ ;;
+
+ sysv4)
+ case $host_vendor in
+ sni)
+ _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ _LT_TAGVAR(hardcode_direct, $1)=yes # is this really true???
+ ;;
+ siemens)
+ ## LD is ld it makes a PLAMLIB
+ ## CC just makes a GrossModule.
+ _LT_TAGVAR(archive_cmds, $1)='$LD -G -o $lib $libobjs $deplibs $linker_flags'
+ _LT_TAGVAR(reload_cmds, $1)='$CC -r -o $output$reload_objs'
+ _LT_TAGVAR(hardcode_direct, $1)=no
+ ;;
+ motorola)
+ _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ _LT_TAGVAR(hardcode_direct, $1)=no #Motorola manual says yes, but my tests say they lie
+ ;;
+ esac
+ runpath_var='LD_RUN_PATH'
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ ;;
+
+ sysv4.3*)
+ _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='-Bexport'
+ ;;
+
+ sysv4*MP*)
+ if test -d /usr/nec; then
+ _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ runpath_var=LD_RUN_PATH
+ hardcode_runpath_var=yes
+ _LT_TAGVAR(ld_shlibs, $1)=yes
+ fi
+ ;;
+
+ sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*)
+ _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
+ _LT_TAGVAR(archive_cmds_need_lc, $1)=no
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ runpath_var='LD_RUN_PATH'
+
+ if test "$GCC" = yes; then
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ else
+ _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ fi
+ ;;
+
+ sysv5* | sco3.2v5* | sco5v6*)
+ # Note: We can NOT use -z defs as we might desire, because we do not
+ # link with -lc, and that would cause any symbols used from libc to
+ # always be unresolved, which means just about no library would
+ # ever link correctly. If we're not using GNU ld we use -z text
+ # though, which does catch some bad symbols but isn't as heavy-handed
+ # as -z defs.
+ _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
+ _LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs'
+ _LT_TAGVAR(archive_cmds_need_lc, $1)=no
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir'
+ _LT_TAGVAR(hardcode_libdir_separator, $1)=':'
+ _LT_TAGVAR(link_all_deplibs, $1)=yes
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport'
+ runpath_var='LD_RUN_PATH'
+
+ if test "$GCC" = yes; then
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ else
+ _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ fi
+ ;;
+
+ uts4*)
+ _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ ;;
+
+ *)
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ esac
+
+ if test x$host_vendor = xsni; then
+ case $host in
+ sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Blargedynsym'
+ ;;
+ esac
+ fi
+ fi
+])
+AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)])
+test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no
+
+_LT_TAGVAR(with_gnu_ld, $1)=$with_gnu_ld
+
+_LT_DECL([], [libext], [0], [Old archive suffix (normally "a")])dnl
+_LT_DECL([], [shrext_cmds], [1], [Shared library suffix (normally ".so")])dnl
+_LT_DECL([], [extract_expsyms_cmds], [2],
+ [The commands to extract the exported symbol list from a shared archive])
+
+#
+# Do we need to explicitly link libc?
+#
+case "x$_LT_TAGVAR(archive_cmds_need_lc, $1)" in
+x|xyes)
+ # Assume -lc should be added
+ _LT_TAGVAR(archive_cmds_need_lc, $1)=yes
+
+ if test "$enable_shared" = yes && test "$GCC" = yes; then
+ case $_LT_TAGVAR(archive_cmds, $1) in
+ *'~'*)
+ # FIXME: we may have to deal with multi-command sequences.
+ ;;
+ '$CC '*)
+ # Test whether the compiler implicitly links with -lc since on some
+ # systems, -lgcc has to come before -lc. If gcc already passes -lc
+ # to ld, don't add -lc before -lgcc.
+ AC_MSG_CHECKING([whether -lc should be explicitly linked in])
+ $RM conftest*
+ echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+ if AC_TRY_EVAL(ac_compile) 2>conftest.err; then
+ soname=conftest
+ lib=conftest
+ libobjs=conftest.$ac_objext
+ deplibs=
+ wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1)
+ pic_flag=$_LT_TAGVAR(lt_prog_compiler_pic, $1)
+ compiler_flags=-v
+ linker_flags=-v
+ verstring=
+ output_objdir=.
+ libname=conftest
+ lt_save_allow_undefined_flag=$_LT_TAGVAR(allow_undefined_flag, $1)
+ _LT_TAGVAR(allow_undefined_flag, $1)=
+ if AC_TRY_EVAL(_LT_TAGVAR(archive_cmds, $1) 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1)
+ then
+ _LT_TAGVAR(archive_cmds_need_lc, $1)=no
+ else
+ _LT_TAGVAR(archive_cmds_need_lc, $1)=yes
+ fi
+ _LT_TAGVAR(allow_undefined_flag, $1)=$lt_save_allow_undefined_flag
+ else
+ cat conftest.err 1>&5
+ fi
+ $RM conftest*
+ AC_MSG_RESULT([$_LT_TAGVAR(archive_cmds_need_lc, $1)])
+ ;;
+ esac
+ fi
+ ;;
+esac
+
+_LT_TAGDECL([build_libtool_need_lc], [archive_cmds_need_lc], [0],
+ [Whether or not to add -lc for building shared libraries])
+_LT_TAGDECL([allow_libtool_libs_with_static_runtimes],
+ [enable_shared_with_static_runtimes], [0],
+ [Whether or not to disallow shared libs when runtime libs are static])
+_LT_TAGDECL([], [export_dynamic_flag_spec], [1],
+ [Compiler flag to allow reflexive dlopens])
+_LT_TAGDECL([], [whole_archive_flag_spec], [1],
+ [Compiler flag to generate shared objects directly from archives])
+_LT_TAGDECL([], [compiler_needs_object], [1],
+ [Whether the compiler copes with passing no objects directly])
+_LT_TAGDECL([], [old_archive_from_new_cmds], [2],
+ [Create an old-style archive from a shared archive])
+_LT_TAGDECL([], [old_archive_from_expsyms_cmds], [2],
+ [Create a temporary old-style archive to link instead of a shared archive])
+_LT_TAGDECL([], [archive_cmds], [2], [Commands used to build a shared archive])
+_LT_TAGDECL([], [archive_expsym_cmds], [2])
+_LT_TAGDECL([], [module_cmds], [2],
+ [Commands used to build a loadable module if different from building
+ a shared archive.])
+_LT_TAGDECL([], [module_expsym_cmds], [2])
+_LT_TAGDECL([], [with_gnu_ld], [1],
+ [Whether we are building with GNU ld or not])
+_LT_TAGDECL([], [allow_undefined_flag], [1],
+ [Flag that allows shared libraries with undefined symbols to be built])
+_LT_TAGDECL([], [no_undefined_flag], [1],
+ [Flag that enforces no undefined symbols])
+_LT_TAGDECL([], [hardcode_libdir_flag_spec], [1],
+ [Flag to hardcode $libdir into a binary during linking.
+ This must work even if $libdir does not exist])
+_LT_TAGDECL([], [hardcode_libdir_flag_spec_ld], [1],
+ [[If ld is used when linking, flag to hardcode $libdir into a binary
+ during linking. This must work even if $libdir does not exist]])
+_LT_TAGDECL([], [hardcode_libdir_separator], [1],
+ [Whether we need a single "-rpath" flag with a separated argument])
+_LT_TAGDECL([], [hardcode_direct], [0],
+ [Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes
+ DIR into the resulting binary])
+_LT_TAGDECL([], [hardcode_direct_absolute], [0],
+ [Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes
+ DIR into the resulting binary and the resulting library dependency is
+ "absolute", i.e impossible to change by setting ${shlibpath_var} if the
+ library is relocated])
+_LT_TAGDECL([], [hardcode_minus_L], [0],
+ [Set to "yes" if using the -LDIR flag during linking hardcodes DIR
+ into the resulting binary])
+_LT_TAGDECL([], [hardcode_shlibpath_var], [0],
+ [Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR
+ into the resulting binary])
+_LT_TAGDECL([], [hardcode_automatic], [0],
+ [Set to "yes" if building a shared library automatically hardcodes DIR
+ into the library and all subsequent libraries and executables linked
+ against it])
+_LT_TAGDECL([], [inherit_rpath], [0],
+ [Set to yes if linker adds runtime paths of dependent libraries
+ to runtime path list])
+_LT_TAGDECL([], [link_all_deplibs], [0],
+ [Whether libtool must link a program against all its dependency libraries])
+_LT_TAGDECL([], [fix_srcfile_path], [1],
+ [Fix the shell variable $srcfile for the compiler])
+_LT_TAGDECL([], [always_export_symbols], [0],
+ [Set to "yes" if exported symbols are required])
+_LT_TAGDECL([], [export_symbols_cmds], [2],
+ [The commands to list exported symbols])
+_LT_TAGDECL([], [exclude_expsyms], [1],
+ [Symbols that should not be listed in the preloaded symbols])
+_LT_TAGDECL([], [include_expsyms], [1],
+ [Symbols that must always be exported])
+_LT_TAGDECL([], [prelink_cmds], [2],
+ [Commands necessary for linking programs (against libraries) with templates])
+_LT_TAGDECL([], [file_list_spec], [1],
+ [Specify filename containing input files])
+dnl FIXME: Not yet implemented
+dnl _LT_TAGDECL([], [thread_safe_flag_spec], [1],
+dnl [Compiler flag to generate thread safe objects])
+])# _LT_LINKER_SHLIBS
+
+
+# _LT_LANG_C_CONFIG([TAG])
+# ------------------------
+# Ensure that the configuration variables for a C compiler are suitably
+# defined. These variables are subsequently used by _LT_CONFIG to write
+# the compiler configuration to `libtool'.
+m4_defun([_LT_LANG_C_CONFIG],
+[m4_require([_LT_DECL_EGREP])dnl
+lt_save_CC="$CC"
+AC_LANG_PUSH(C)
+
+# Source file extension for C test sources.
+ac_ext=c
+
+# Object file extension for compiled C test sources.
+objext=o
+_LT_TAGVAR(objext, $1)=$objext
+
+# Code to be used in simple compile tests
+lt_simple_compile_test_code="int some_variable = 0;"
+
+# Code to be used in simple link tests
+lt_simple_link_test_code='int main(){return(0);}'
+
+_LT_TAG_COMPILER
+# Save the default compiler, since it gets overwritten when the other
+# tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP.
+compiler_DEFAULT=$CC
+
+# save warnings/boilerplate of simple test code
+_LT_COMPILER_BOILERPLATE
+_LT_LINKER_BOILERPLATE
+
+## CAVEAT EMPTOR:
+## There is no encapsulation within the following macros, do not change
+## the running order or otherwise move them around unless you know exactly
+## what you are doing...
+if test -n "$compiler"; then
+ _LT_COMPILER_NO_RTTI($1)
+ _LT_COMPILER_PIC($1)
+ _LT_COMPILER_C_O($1)
+ _LT_COMPILER_FILE_LOCKS($1)
+ _LT_LINKER_SHLIBS($1)
+ _LT_SYS_DYNAMIC_LINKER($1)
+ _LT_LINKER_HARDCODE_LIBPATH($1)
+ LT_SYS_DLOPEN_SELF
+ _LT_CMD_STRIPLIB
+
+ # Report which library types will actually be built
+ AC_MSG_CHECKING([if libtool supports shared libraries])
+ AC_MSG_RESULT([$can_build_shared])
+
+ AC_MSG_CHECKING([whether to build shared libraries])
+ test "$can_build_shared" = "no" && enable_shared=no
+
+ # On AIX, shared libraries and static libraries use the same namespace, and
+ # are all built from PIC.
+ case $host_os in
+ aix3*)
+ test "$enable_shared" = yes && enable_static=no
+ if test -n "$RANLIB"; then
+ archive_cmds="$archive_cmds~\$RANLIB \$lib"
+ postinstall_cmds='$RANLIB $lib'
+ fi
+ ;;
+
+ aix[[4-9]]*)
+ if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
+ test "$enable_shared" = yes && enable_static=no
+ fi
+ ;;
+ esac
+ AC_MSG_RESULT([$enable_shared])
+
+ AC_MSG_CHECKING([whether to build static libraries])
+ # Make sure either enable_shared or enable_static is yes.
+ test "$enable_shared" = yes || enable_static=yes
+ AC_MSG_RESULT([$enable_static])
+
+ _LT_CONFIG($1)
+fi
+AC_LANG_POP
+CC="$lt_save_CC"
+])# _LT_LANG_C_CONFIG
+
+
+# _LT_PROG_CXX
+# ------------
+# Since AC_PROG_CXX is broken, in that it returns g++ if there is no c++
+# compiler, we have our own version here.
+m4_defun([_LT_PROG_CXX],
+[
+pushdef([AC_MSG_ERROR], [_lt_caught_CXX_error=yes])
+AC_PROG_CXX
+if test -n "$CXX" && ( test "X$CXX" != "Xno" &&
+ ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) ||
+ (test "X$CXX" != "Xg++"))) ; then
+ AC_PROG_CXXCPP
+else
+ _lt_caught_CXX_error=yes
+fi
+popdef([AC_MSG_ERROR])
+])# _LT_PROG_CXX
+
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([_LT_PROG_CXX], [])
+
+
+# _LT_LANG_CXX_CONFIG([TAG])
+# --------------------------
+# Ensure that the configuration variables for a C++ compiler are suitably
+# defined. These variables are subsequently used by _LT_CONFIG to write
+# the compiler configuration to `libtool'.
+m4_defun([_LT_LANG_CXX_CONFIG],
+[AC_REQUIRE([_LT_PROG_CXX])dnl
+m4_require([_LT_FILEUTILS_DEFAULTS])dnl
+m4_require([_LT_DECL_EGREP])dnl
+
+AC_LANG_PUSH(C++)
+_LT_TAGVAR(archive_cmds_need_lc, $1)=no
+_LT_TAGVAR(allow_undefined_flag, $1)=
+_LT_TAGVAR(always_export_symbols, $1)=no
+_LT_TAGVAR(archive_expsym_cmds, $1)=
+_LT_TAGVAR(compiler_needs_object, $1)=no
+_LT_TAGVAR(export_dynamic_flag_spec, $1)=
+_LT_TAGVAR(hardcode_direct, $1)=no
+_LT_TAGVAR(hardcode_direct_absolute, $1)=no
+_LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
+_LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
+_LT_TAGVAR(hardcode_libdir_separator, $1)=
+_LT_TAGVAR(hardcode_minus_L, $1)=no
+_LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
+_LT_TAGVAR(hardcode_automatic, $1)=no
+_LT_TAGVAR(inherit_rpath, $1)=no
+_LT_TAGVAR(module_cmds, $1)=
+_LT_TAGVAR(module_expsym_cmds, $1)=
+_LT_TAGVAR(link_all_deplibs, $1)=unknown
+_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
+_LT_TAGVAR(no_undefined_flag, $1)=
+_LT_TAGVAR(whole_archive_flag_spec, $1)=
+_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no
+
+# Source file extension for C++ test sources.
+ac_ext=cpp
+
+# Object file extension for compiled C++ test sources.
+objext=o
+_LT_TAGVAR(objext, $1)=$objext
+
+# No sense in running all these tests if we already determined that
+# the CXX compiler isn't working. Some variables (like enable_shared)
+# are currently assumed to apply to all compilers on this platform,
+# and will be corrupted by setting them based on a non-working compiler.
+if test "$_lt_caught_CXX_error" != yes; then
+ # Code to be used in simple compile tests
+ lt_simple_compile_test_code="int some_variable = 0;"
+
+ # Code to be used in simple link tests
+ lt_simple_link_test_code='int main(int, char *[[]]) { return(0); }'
+
+ # ltmain only uses $CC for tagged configurations so make sure $CC is set.
+ _LT_TAG_COMPILER
+
+ # save warnings/boilerplate of simple test code
+ _LT_COMPILER_BOILERPLATE
+ _LT_LINKER_BOILERPLATE
+
+ # Allow CC to be a program name with arguments.
+ lt_save_CC=$CC
+ lt_save_LD=$LD
+ lt_save_GCC=$GCC
+ GCC=$GXX
+ lt_save_with_gnu_ld=$with_gnu_ld
+ lt_save_path_LD=$lt_cv_path_LD
+ if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then
+ lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx
+ else
+ $as_unset lt_cv_prog_gnu_ld
+ fi
+ if test -n "${lt_cv_path_LDCXX+set}"; then
+ lt_cv_path_LD=$lt_cv_path_LDCXX
+ else
+ $as_unset lt_cv_path_LD
+ fi
+ test -z "${LDCXX+set}" || LD=$LDCXX
+ CC=${CXX-"c++"}
+ compiler=$CC
+ _LT_TAGVAR(compiler, $1)=$CC
+ _LT_CC_BASENAME([$compiler])
+
+ if test -n "$compiler"; then
+ # We don't want -fno-exception when compiling C++ code, so set the
+ # no_builtin_flag separately
+ if test "$GXX" = yes; then
+ _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin'
+ else
+ _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=
+ fi
+
+ if test "$GXX" = yes; then
+ # Set up default GNU C++ configuration
+
+ LT_PATH_LD
+
+ # Check if GNU C++ uses GNU ld as the underlying linker, since the
+ # archiving commands below assume that GNU ld is being used.
+ if test "$with_gnu_ld" = yes; then
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+
+ # If archive_cmds runs LD, not CC, wlarc should be empty
+ # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to
+ # investigate it a little bit more. (MM)
+ wlarc='${wl}'
+
+ # ancient GNU ld didn't support --whole-archive et. al.
+ if eval "`$CC -print-prog-name=ld` --help 2>&1" |
+ $GREP 'no-whole-archive' > /dev/null; then
+ _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+ else
+ _LT_TAGVAR(whole_archive_flag_spec, $1)=
+ fi
+ else
+ with_gnu_ld=no
+ wlarc=
+
+ # A generic and very simple default shared library creation
+ # command for GNU C++ for the case where it uses the native
+ # linker, instead of GNU ld. If possible, this setting should
+ # overridden to take advantage of the native linker features on
+ # the platform it is being used on.
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
+ fi
+
+ # Commands to make compiler produce verbose output that lists
+ # what "hidden" libraries, object files and flags are used when
+ # linking a shared library.
+ output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"'
+
+ else
+ GXX=no
+ with_gnu_ld=no
+ wlarc=
+ fi
+
+ # PORTME: fill in a description of your system's C++ link characteristics
+ AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries])
+ _LT_TAGVAR(ld_shlibs, $1)=yes
+ case $host_os in
+ aix3*)
+ # FIXME: insert proper C++ library support
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ aix[[4-9]]*)
+ if test "$host_cpu" = ia64; then
+ # On IA64, the linker does run time linking by default, so we don't
+ # have to do anything special.
+ aix_use_runtimelinking=no
+ exp_sym_flag='-Bexport'
+ no_entry_flag=""
+ else
+ aix_use_runtimelinking=no
+
+ # Test if we are trying to use run time linking or normal
+ # AIX style linking. If -brtl is somewhere in LDFLAGS, we
+ # need to do runtime linking.
+ case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*)
+ for ld_flag in $LDFLAGS; do
+ case $ld_flag in
+ *-brtl*)
+ aix_use_runtimelinking=yes
+ break
+ ;;
+ esac
+ done
+ ;;
+ esac
+
+ exp_sym_flag='-bexport'
+ no_entry_flag='-bnoentry'
+ fi
+
+ # When large executables or shared objects are built, AIX ld can
+ # have problems creating the table of contents. If linking a library
+ # or program results in "error TOC overflow" add -mminimal-toc to
+ # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not
+ # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
+
+ _LT_TAGVAR(archive_cmds, $1)=''
+ _LT_TAGVAR(hardcode_direct, $1)=yes
+ _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
+ _LT_TAGVAR(hardcode_libdir_separator, $1)=':'
+ _LT_TAGVAR(link_all_deplibs, $1)=yes
+ _LT_TAGVAR(file_list_spec, $1)='${wl}-f,'
+
+ if test "$GXX" = yes; then
+ case $host_os in aix4.[[012]]|aix4.[[012]].*)
+ # We only want to do this on AIX 4.2 and lower, the check
+ # below for broken collect2 doesn't work under 4.3+
+ collect2name=`${CC} -print-prog-name=collect2`
+ if test -f "$collect2name" &&
+ strings "$collect2name" | $GREP resolve_lib_name >/dev/null
+ then
+ # We have reworked collect2
+ :
+ else
+ # We have old collect2
+ _LT_TAGVAR(hardcode_direct, $1)=unsupported
+ # It fails to find uninstalled libraries when the uninstalled
+ # path is not listed in the libpath. Setting hardcode_minus_L
+ # to unsupported forces relinking
+ _LT_TAGVAR(hardcode_minus_L, $1)=yes
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+ _LT_TAGVAR(hardcode_libdir_separator, $1)=
+ fi
+ esac
+ shared_flag='-shared'
+ if test "$aix_use_runtimelinking" = yes; then
+ shared_flag="$shared_flag "'${wl}-G'
+ fi
+ else
+ # not using gcc
+ if test "$host_cpu" = ia64; then
+ # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
+ # chokes on -Wl,-G. The following line is correct:
+ shared_flag='-G'
+ else
+ if test "$aix_use_runtimelinking" = yes; then
+ shared_flag='${wl}-G'
+ else
+ shared_flag='${wl}-bM:SRE'
+ fi
+ fi
+ fi
+
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-bexpall'
+ # It seems that -bexpall does not export symbols beginning with
+ # underscore (_), so it is better to generate a list of symbols to
+ # export.
+ _LT_TAGVAR(always_export_symbols, $1)=yes
+ if test "$aix_use_runtimelinking" = yes; then
+ # Warning - without using the other runtime loading flags (-brtl),
+ # -berok will link without error, but may produce a broken library.
+ _LT_TAGVAR(allow_undefined_flag, $1)='-berok'
+ # Determine the default libpath from the value encoded in an empty
+ # executable.
+ _LT_SYS_MODULE_PATH_AIX
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
+
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then $ECHO "X${wl}${allow_undefined_flag}" | $Xsed; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
+ else
+ if test "$host_cpu" = ia64; then
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib'
+ _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs"
+ _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
+ else
+ # Determine the default libpath from the value encoded in an
+ # empty executable.
+ _LT_SYS_MODULE_PATH_AIX
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
+ # Warning - without using the other run time loading flags,
+ # -berok will link without error, but may produce a broken library.
+ _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok'
+ _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok'
+ # Exported symbols can be pulled into shared objects from archives
+ _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience'
+ _LT_TAGVAR(archive_cmds_need_lc, $1)=yes
+ # This is similar to how AIX traditionally builds its shared
+ # libraries.
+ _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
+ fi
+ fi
+ ;;
+
+ beos*)
+ if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+ _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
+ # Joseph Beckenbach <jrb3 at best.com> says some releases of gcc
+ # support --undefined. This deserves some investigation. FIXME
+ _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ else
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ fi
+ ;;
+
+ chorus*)
+ case $cc_basename in
+ *)
+ # FIXME: insert proper C++ library support
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ esac
+ ;;
+
+ cygwin* | mingw* | pw32* | cegcc*)
+ # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless,
+ # as there is no search path for DLLs.
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+ _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
+ _LT_TAGVAR(always_export_symbols, $1)=no
+ _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
+
+ if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+ # If the export-symbols file already is a .def file (1st line
+ # is EXPORTS), use it as is; otherwise, prepend...
+ _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
+ cp $export_symbols $output_objdir/$soname.def;
+ else
+ echo EXPORTS > $output_objdir/$soname.def;
+ cat $export_symbols >> $output_objdir/$soname.def;
+ fi~
+ $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+ else
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ fi
+ ;;
+ darwin* | rhapsody*)
+ _LT_DARWIN_LINKER_FEATURES($1)
+ ;;
+
+ dgux*)
+ case $cc_basename in
+ ec++*)
+ # FIXME: insert proper C++ library support
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ ghcx*)
+ # Green Hills C++ Compiler
+ # FIXME: insert proper C++ library support
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ *)
+ # FIXME: insert proper C++ library support
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ esac
+ ;;
+
+ freebsd[[12]]*)
+ # C++ shared libraries reported to be fairly broken before
+ # switch to ELF
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+
+ freebsd-elf*)
+ _LT_TAGVAR(archive_cmds_need_lc, $1)=no
+ ;;
+
+ freebsd* | dragonfly*)
+ # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF
+ # conventions
+ _LT_TAGVAR(ld_shlibs, $1)=yes
+ ;;
+
+ gnu*)
+ ;;
+
+ hpux9*)
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+ _LT_TAGVAR(hardcode_direct, $1)=yes
+ _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH,
+ # but as the default
+ # location of the library.
+
+ case $cc_basename in
+ CC*)
+ # FIXME: insert proper C++ library support
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ aCC*)
+ _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+ # Commands to make compiler produce verbose output that lists
+ # what "hidden" libraries, object files and flags are used when
+ # linking a shared library.
+ #
+ # There doesn't appear to be a way to prevent this compiler from
+ # explicitly linking system object files so we need to strip them
+ # from the output so that they don't get included in the library
+ # dependencies.
+ output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed'
+ ;;
+ *)
+ if test "$GXX" = yes; then
+ _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared -nostdlib -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+ else
+ # FIXME: insert proper C++ library support
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ fi
+ ;;
+ esac
+ ;;
+
+ hpux10*|hpux11*)
+ if test $with_gnu_ld = no; then
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+
+ case $host_cpu in
+ hppa*64*|ia64*)
+ ;;
+ *)
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+ ;;
+ esac
+ fi
+ case $host_cpu in
+ hppa*64*|ia64*)
+ _LT_TAGVAR(hardcode_direct, $1)=no
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ ;;
+ *)
+ _LT_TAGVAR(hardcode_direct, $1)=yes
+ _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
+ _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH,
+ # but as the default
+ # location of the library.
+ ;;
+ esac
+
+ case $cc_basename in
+ CC*)
+ # FIXME: insert proper C++ library support
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ aCC*)
+ case $host_cpu in
+ hppa*64*)
+ _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+ ;;
+ ia64*)
+ _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+ ;;
+ *)
+ _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+ ;;
+ esac
+ # Commands to make compiler produce verbose output that lists
+ # what "hidden" libraries, object files and flags are used when
+ # linking a shared library.
+ #
+ # There doesn't appear to be a way to prevent this compiler from
+ # explicitly linking system object files so we need to strip them
+ # from the output so that they don't get included in the library
+ # dependencies.
+ output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed'
+ ;;
+ *)
+ if test "$GXX" = yes; then
+ if test $with_gnu_ld = no; then
+ case $host_cpu in
+ hppa*64*)
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+ ;;
+ ia64*)
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+ ;;
+ *)
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+ ;;
+ esac
+ fi
+ else
+ # FIXME: insert proper C++ library support
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ fi
+ ;;
+ esac
+ ;;
+
+ interix[[3-9]]*)
+ _LT_TAGVAR(hardcode_direct, $1)=no
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+ # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
+ # Instead, shared libraries are loaded at an image base (0x10000000 by
+ # default) and relocated if they conflict, which is a slow very memory
+ # consuming and fragmenting process. To avoid this, we pick a random,
+ # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
+ # time. Moving up from 0x10000000 also allows more sbrk(2) space.
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+ ;;
+ irix5* | irix6*)
+ case $cc_basename in
+ CC*)
+ # SGI C++
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib'
+
+ # Archives containing C++ object files must be created using
+ # "CC -ar", where "CC" is the IRIX C++ compiler. This is
+ # necessary to make sure instantiated templates are included
+ # in the archive.
+ _LT_TAGVAR(old_archive_cmds, $1)='$CC -ar -WR,-u -o $oldlib $oldobjs'
+ ;;
+ *)
+ if test "$GXX" = yes; then
+ if test "$with_gnu_ld" = no; then
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+ else
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` -o $lib'
+ fi
+ fi
+ _LT_TAGVAR(link_all_deplibs, $1)=yes
+ ;;
+ esac
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+ _LT_TAGVAR(inherit_rpath, $1)=yes
+ ;;
+
+ linux* | k*bsd*-gnu)
+ case $cc_basename in
+ KCC*)
+ # Kuck and Associates, Inc. (KAI) C++ Compiler
+
+ # KCC will only create a shared library if the output file
+ # ends with ".so" (or ".sl" for HP-UX), so rename the library
+ # to its proper name (with version) after linking.
+ _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib'
+ # Commands to make compiler produce verbose output that lists
+ # what "hidden" libraries, object files and flags are used when
+ # linking a shared library.
+ #
+ # There doesn't appear to be a way to prevent this compiler from
+ # explicitly linking system object files so we need to strip them
+ # from the output so that they don't get included in the library
+ # dependencies.
+ output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | $GREP "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed'
+
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+
+ # Archives containing C++ object files must be created using
+ # "CC -Bstatic", where "CC" is the KAI C++ compiler.
+ _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs'
+ ;;
+ icpc* | ecpc* )
+ # Intel C++
+ with_gnu_ld=yes
+ # version 8.0 and above of icpc choke on multiply defined symbols
+ # if we add $predep_objects and $postdep_objects, however 7.1 and
+ # earlier do not add the objects themselves.
+ case `$CC -V 2>&1` in
+ *"Version 7."*)
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+ ;;
+ *) # Version 8.0 or newer
+ tmp_idyn=
+ case $host_cpu in
+ ia64*) tmp_idyn=' -i_dynamic';;
+ esac
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+ ;;
+ esac
+ _LT_TAGVAR(archive_cmds_need_lc, $1)=no
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+ _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
+ ;;
+ pgCC* | pgcpp*)
+ # Portland Group C++ compiler
+ case `$CC -V` in
+ *pgCC\ [[1-5]]* | *pgcpp\ [[1-5]]*)
+ _LT_TAGVAR(prelink_cmds, $1)='tpldir=Template.dir~
+ rm -rf $tpldir~
+ $CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~
+ compile_command="$compile_command `find $tpldir -name \*.o | $NL2SP`"'
+ _LT_TAGVAR(old_archive_cmds, $1)='tpldir=Template.dir~
+ rm -rf $tpldir~
+ $CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~
+ $AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | $NL2SP`~
+ $RANLIB $oldlib'
+ _LT_TAGVAR(archive_cmds, $1)='tpldir=Template.dir~
+ rm -rf $tpldir~
+ $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~
+ $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='tpldir=Template.dir~
+ rm -rf $tpldir~
+ $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~
+ $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
+ ;;
+ *) # Version 6 will use weak symbols
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
+ ;;
+ esac
+
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir'
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+ _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive'
+ ;;
+ cxx*)
+ # Compaq C++
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib ${wl}-retain-symbols-file $wl$export_symbols'
+
+ runpath_var=LD_RUN_PATH
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
+ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+
+ # Commands to make compiler produce verbose output that lists
+ # what "hidden" libraries, object files and flags are used when
+ # linking a shared library.
+ #
+ # There doesn't appear to be a way to prevent this compiler from
+ # explicitly linking system object files so we need to strip them
+ # from the output so that they don't get included in the library
+ # dependencies.
+ output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld"`; templist=`$ECHO "X$templist" | $Xsed -e "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed'
+ ;;
+ xl*)
+ # IBM XL 8.0 on PPC, with GNU ld
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ if test "x$supports_anon_versioning" = xyes; then
+ _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~
+ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+ echo "local: *; };" >> $output_objdir/$libname.ver~
+ $CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
+ fi
+ ;;
+ *)
+ case `$CC -V 2>&1 | sed 5q` in
+ *Sun\ C*)
+ # Sun C++ 5.9
+ _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file ${wl}$export_symbols'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+ _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive'
+ _LT_TAGVAR(compiler_needs_object, $1)=yes
+
+ # Not sure whether something based on
+ # $CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1
+ # would be better.
+ output_verbose_link_cmd='echo'
+
+ # Archives containing C++ object files must be created using
+ # "CC -xar", where "CC" is the Sun C++ compiler. This is
+ # necessary to make sure instantiated templates are included
+ # in the archive.
+ _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs'
+ ;;
+ esac
+ ;;
+ esac
+ ;;
+
+ lynxos*)
+ # FIXME: insert proper C++ library support
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+
+ m88k*)
+ # FIXME: insert proper C++ library support
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+
+ mvs*)
+ case $cc_basename in
+ cxx*)
+ # FIXME: insert proper C++ library support
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ *)
+ # FIXME: insert proper C++ library support
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ esac
+ ;;
+
+ netbsd*)
+ if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
+ _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags'
+ wlarc=
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+ _LT_TAGVAR(hardcode_direct, $1)=yes
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ fi
+ # Workaround some broken pre-1.5 toolchains
+ output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"'
+ ;;
+
+ *nto* | *qnx*)
+ _LT_TAGVAR(ld_shlibs, $1)=yes
+ ;;
+
+ openbsd2*)
+ # C++ shared libraries are fairly broken
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+
+ openbsd*)
+ if test -f /usr/libexec/ld.so; then
+ _LT_TAGVAR(hardcode_direct, $1)=yes
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+ if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib'
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+ _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+ fi
+ output_verbose_link_cmd=echo
+ else
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ fi
+ ;;
+
+ osf3* | osf4* | osf5*)
+ case $cc_basename in
+ KCC*)
+ # Kuck and Associates, Inc. (KAI) C++ Compiler
+
+ # KCC will only create a shared library if the output file
+ # ends with ".so" (or ".sl" for HP-UX), so rename the library
+ # to its proper name (with version) after linking.
+ _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo "$lib" | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
+
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+
+ # Archives containing C++ object files must be created using
+ # the KAI C++ compiler.
+ case $host in
+ osf3*) _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' ;;
+ *) _LT_TAGVAR(old_archive_cmds, $1)='$CC -o $oldlib $oldobjs' ;;
+ esac
+ ;;
+ RCC*)
+ # Rational C++ 2.4.1
+ # FIXME: insert proper C++ library support
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ cxx*)
+ case $host in
+ osf3*)
+ _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && $ECHO "X${wl}-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+ ;;
+ *)
+ _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~
+ echo "-hidden">> $lib.exp~
+ $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname ${wl}-input ${wl}$lib.exp `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib~
+ $RM $lib.exp'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
+ ;;
+ esac
+
+ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+
+ # Commands to make compiler produce verbose output that lists
+ # what "hidden" libraries, object files and flags are used when
+ # linking a shared library.
+ #
+ # There doesn't appear to be a way to prevent this compiler from
+ # explicitly linking system object files so we need to strip them
+ # from the output so that they don't get included in the library
+ # dependencies.
+ output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld" | $GREP -v "ld:"`; templist=`$ECHO "X$templist" | $Xsed -e "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed'
+ ;;
+ *)
+ if test "$GXX" = yes && test "$with_gnu_ld" = no; then
+ _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
+ case $host in
+ osf3*)
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+ ;;
+ *)
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+ ;;
+ esac
+
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+
+ # Commands to make compiler produce verbose output that lists
+ # what "hidden" libraries, object files and flags are used when
+ # linking a shared library.
+ output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"'
+
+ else
+ # FIXME: insert proper C++ library support
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ fi
+ ;;
+ esac
+ ;;
+
+ psos*)
+ # FIXME: insert proper C++ library support
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+
+ sunos4*)
+ case $cc_basename in
+ CC*)
+ # Sun C++ 4.x
+ # FIXME: insert proper C++ library support
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ lcc*)
+ # Lucid
+ # FIXME: insert proper C++ library support
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ *)
+ # FIXME: insert proper C++ library support
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ esac
+ ;;
+
+ solaris*)
+ case $cc_basename in
+ CC*)
+ # Sun C++ 4.2, 5.x and Centerline C++
+ _LT_TAGVAR(archive_cmds_need_lc,$1)=yes
+ _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+ $CC -G${allow_undefined_flag} ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
+
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ case $host_os in
+ solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
+ *)
+ # The compiler driver will combine and reorder linker options,
+ # but understands `-z linker_flag'.
+ # Supported since Solaris 2.6 (maybe 2.5.1?)
+ _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract'
+ ;;
+ esac
+ _LT_TAGVAR(link_all_deplibs, $1)=yes
+
+ output_verbose_link_cmd='echo'
+
+ # Archives containing C++ object files must be created using
+ # "CC -xar", where "CC" is the Sun C++ compiler. This is
+ # necessary to make sure instantiated templates are included
+ # in the archive.
+ _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs'
+ ;;
+ gcx*)
+ # Green Hills C++ Compiler
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+
+ # The C++ compiler must be used to create the archive.
+ _LT_TAGVAR(old_archive_cmds, $1)='$CC $LDFLAGS -archive -o $oldlib $oldobjs'
+ ;;
+ *)
+ # GNU C++ compiler with Solaris linker
+ if test "$GXX" = yes && test "$with_gnu_ld" = no; then
+ _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-z ${wl}defs'
+ if $CC --version | $GREP -v '^2\.7' > /dev/null; then
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+ $CC -shared -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
+
+ # Commands to make compiler produce verbose output that lists
+ # what "hidden" libraries, object files and flags are used when
+ # linking a shared library.
+ output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"'
+ else
+ # g++ 2.7 appears to require `-G' NOT `-shared' on this
+ # platform.
+ _LT_TAGVAR(archive_cmds, $1)='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+ $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
+
+ # Commands to make compiler produce verbose output that lists
+ # what "hidden" libraries, object files and flags are used when
+ # linking a shared library.
+ output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"'
+ fi
+
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $wl$libdir'
+ case $host_os in
+ solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
+ *)
+ _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
+ ;;
+ esac
+ fi
+ ;;
+ esac
+ ;;
+
+ sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*)
+ _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
+ _LT_TAGVAR(archive_cmds_need_lc, $1)=no
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ runpath_var='LD_RUN_PATH'
+
+ case $cc_basename in
+ CC*)
+ _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ ;;
+ *)
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ ;;
+ esac
+ ;;
+
+ sysv5* | sco3.2v5* | sco5v6*)
+ # Note: We can NOT use -z defs as we might desire, because we do not
+ # link with -lc, and that would cause any symbols used from libc to
+ # always be unresolved, which means just about no library would
+ # ever link correctly. If we're not using GNU ld we use -z text
+ # though, which does catch some bad symbols but isn't as heavy-handed
+ # as -z defs.
+ _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
+ _LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs'
+ _LT_TAGVAR(archive_cmds_need_lc, $1)=no
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir'
+ _LT_TAGVAR(hardcode_libdir_separator, $1)=':'
+ _LT_TAGVAR(link_all_deplibs, $1)=yes
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport'
+ runpath_var='LD_RUN_PATH'
+
+ case $cc_basename in
+ CC*)
+ _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ ;;
+ *)
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ ;;
+ esac
+ ;;
+
+ tandem*)
+ case $cc_basename in
+ NCC*)
+ # NonStop-UX NCC 3.20
+ # FIXME: insert proper C++ library support
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ *)
+ # FIXME: insert proper C++ library support
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ esac
+ ;;
+
+ vxworks*)
+ # FIXME: insert proper C++ library support
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+
+ *)
+ # FIXME: insert proper C++ library support
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ esac
+
+ AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)])
+ test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no
+
+ _LT_TAGVAR(GCC, $1)="$GXX"
+ _LT_TAGVAR(LD, $1)="$LD"
+
+ ## CAVEAT EMPTOR:
+ ## There is no encapsulation within the following macros, do not change
+ ## the running order or otherwise move them around unless you know exactly
+ ## what you are doing...
+ _LT_SYS_HIDDEN_LIBDEPS($1)
+ _LT_COMPILER_PIC($1)
+ _LT_COMPILER_C_O($1)
+ _LT_COMPILER_FILE_LOCKS($1)
+ _LT_LINKER_SHLIBS($1)
+ _LT_SYS_DYNAMIC_LINKER($1)
+ _LT_LINKER_HARDCODE_LIBPATH($1)
+
+ _LT_CONFIG($1)
+ fi # test -n "$compiler"
+
+ CC=$lt_save_CC
+ LDCXX=$LD
+ LD=$lt_save_LD
+ GCC=$lt_save_GCC
+ with_gnu_ld=$lt_save_with_gnu_ld
+ lt_cv_path_LDCXX=$lt_cv_path_LD
+ lt_cv_path_LD=$lt_save_path_LD
+ lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld
+ lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld
+fi # test "$_lt_caught_CXX_error" != yes
+
+AC_LANG_POP
+])# _LT_LANG_CXX_CONFIG
+
+
+# _LT_SYS_HIDDEN_LIBDEPS([TAGNAME])
+# ---------------------------------
+# Figure out "hidden" library dependencies from verbose
+# compiler output when linking a shared library.
+# Parse the compiler output and extract the necessary
+# objects, libraries and library flags.
+m4_defun([_LT_SYS_HIDDEN_LIBDEPS],
+[m4_require([_LT_FILEUTILS_DEFAULTS])dnl
+# Dependencies to place before and after the object being linked:
+_LT_TAGVAR(predep_objects, $1)=
+_LT_TAGVAR(postdep_objects, $1)=
+_LT_TAGVAR(predeps, $1)=
+_LT_TAGVAR(postdeps, $1)=
+_LT_TAGVAR(compiler_lib_search_path, $1)=
+
+dnl we can't use the lt_simple_compile_test_code here,
+dnl because it contains code intended for an executable,
+dnl not a library. It's possible we should let each
+dnl tag define a new lt_????_link_test_code variable,
+dnl but it's only used here...
+m4_if([$1], [], [cat > conftest.$ac_ext <<_LT_EOF
+int a;
+void foo (void) { a = 0; }
+_LT_EOF
+], [$1], [CXX], [cat > conftest.$ac_ext <<_LT_EOF
+class Foo
+{
+public:
+ Foo (void) { a = 0; }
+private:
+ int a;
+};
+_LT_EOF
+], [$1], [F77], [cat > conftest.$ac_ext <<_LT_EOF
+ subroutine foo
+ implicit none
+ integer*4 a
+ a=0
+ return
+ end
+_LT_EOF
+], [$1], [FC], [cat > conftest.$ac_ext <<_LT_EOF
+ subroutine foo
+ implicit none
+ integer a
+ a=0
+ return
+ end
+_LT_EOF
+], [$1], [GCJ], [cat > conftest.$ac_ext <<_LT_EOF
+public class foo {
+ private int a;
+ public void bar (void) {
+ a = 0;
+ }
+};
+_LT_EOF
+])
+dnl Parse the compiler output and extract the necessary
+dnl objects, libraries and library flags.
+if AC_TRY_EVAL(ac_compile); then
+ # Parse the compiler output and extract the necessary
+ # objects, libraries and library flags.
+
+ # Sentinel used to keep track of whether or not we are before
+ # the conftest object file.
+ pre_test_object_deps_done=no
+
+ for p in `eval "$output_verbose_link_cmd"`; do
+ case $p in
+
+ -L* | -R* | -l*)
+ # Some compilers place space between "-{L,R}" and the path.
+ # Remove the space.
+ if test $p = "-L" ||
+ test $p = "-R"; then
+ prev=$p
+ continue
+ else
+ prev=
+ fi
+
+ if test "$pre_test_object_deps_done" = no; then
+ case $p in
+ -L* | -R*)
+ # Internal compiler library paths should come after those
+ # provided the user. The postdeps already come after the
+ # user supplied libs so there is no need to process them.
+ if test -z "$_LT_TAGVAR(compiler_lib_search_path, $1)"; then
+ _LT_TAGVAR(compiler_lib_search_path, $1)="${prev}${p}"
+ else
+ _LT_TAGVAR(compiler_lib_search_path, $1)="${_LT_TAGVAR(compiler_lib_search_path, $1)} ${prev}${p}"
+ fi
+ ;;
+ # The "-l" case would never come before the object being
+ # linked, so don't bother handling this case.
+ esac
+ else
+ if test -z "$_LT_TAGVAR(postdeps, $1)"; then
+ _LT_TAGVAR(postdeps, $1)="${prev}${p}"
+ else
+ _LT_TAGVAR(postdeps, $1)="${_LT_TAGVAR(postdeps, $1)} ${prev}${p}"
+ fi
+ fi
+ ;;
+
+ *.$objext)
+ # This assumes that the test object file only shows up
+ # once in the compiler output.
+ if test "$p" = "conftest.$objext"; then
+ pre_test_object_deps_done=yes
+ continue
+ fi
+
+ if test "$pre_test_object_deps_done" = no; then
+ if test -z "$_LT_TAGVAR(predep_objects, $1)"; then
+ _LT_TAGVAR(predep_objects, $1)="$p"
+ else
+ _LT_TAGVAR(predep_objects, $1)="$_LT_TAGVAR(predep_objects, $1) $p"
+ fi
+ else
+ if test -z "$_LT_TAGVAR(postdep_objects, $1)"; then
+ _LT_TAGVAR(postdep_objects, $1)="$p"
+ else
+ _LT_TAGVAR(postdep_objects, $1)="$_LT_TAGVAR(postdep_objects, $1) $p"
+ fi
+ fi
+ ;;
+
+ *) ;; # Ignore the rest.
+
+ esac
+ done
+
+ # Clean up.
+ rm -f a.out a.exe
+else
+ echo "libtool.m4: error: problem compiling $1 test program"
+fi
+
+$RM -f confest.$objext
+
+# PORTME: override above test on systems where it is broken
+m4_if([$1], [CXX],
+[case $host_os in
+interix[[3-9]]*)
+ # Interix 3.5 installs completely hosed .la files for C++, so rather than
+ # hack all around it, let's just trust "g++" to DTRT.
+ _LT_TAGVAR(predep_objects,$1)=
+ _LT_TAGVAR(postdep_objects,$1)=
+ _LT_TAGVAR(postdeps,$1)=
+ ;;
+
+linux*)
+ case `$CC -V 2>&1 | sed 5q` in
+ *Sun\ C*)
+ # Sun C++ 5.9
+
+ # The more standards-conforming stlport4 library is
+ # incompatible with the Cstd library. Avoid specifying
+ # it if it's in CXXFLAGS. Ignore libCrun as
+ # -library=stlport4 depends on it.
+ case " $CXX $CXXFLAGS " in
+ *" -library=stlport4 "*)
+ solaris_use_stlport4=yes
+ ;;
+ esac
+
+ if test "$solaris_use_stlport4" != yes; then
+ _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun'
+ fi
+ ;;
+ esac
+ ;;
+
+solaris*)
+ case $cc_basename in
+ CC*)
+ # The more standards-conforming stlport4 library is
+ # incompatible with the Cstd library. Avoid specifying
+ # it if it's in CXXFLAGS. Ignore libCrun as
+ # -library=stlport4 depends on it.
+ case " $CXX $CXXFLAGS " in
+ *" -library=stlport4 "*)
+ solaris_use_stlport4=yes
+ ;;
+ esac
+
+ # Adding this requires a known-good setup of shared libraries for
+ # Sun compiler versions before 5.6, else PIC objects from an old
+ # archive will be linked into the output, leading to subtle bugs.
+ if test "$solaris_use_stlport4" != yes; then
+ _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun'
+ fi
+ ;;
+ esac
+ ;;
+esac
+])
+
+case " $_LT_TAGVAR(postdeps, $1) " in
+*" -lc "*) _LT_TAGVAR(archive_cmds_need_lc, $1)=no ;;
+esac
+ _LT_TAGVAR(compiler_lib_search_dirs, $1)=
+if test -n "${_LT_TAGVAR(compiler_lib_search_path, $1)}"; then
+ _LT_TAGVAR(compiler_lib_search_dirs, $1)=`echo " ${_LT_TAGVAR(compiler_lib_search_path, $1)}" | ${SED} -e 's! -L! !g' -e 's!^ !!'`
+fi
+_LT_TAGDECL([], [compiler_lib_search_dirs], [1],
+ [The directories searched by this compiler when creating a shared library])
+_LT_TAGDECL([], [predep_objects], [1],
+ [Dependencies to place before and after the objects being linked to
+ create a shared library])
+_LT_TAGDECL([], [postdep_objects], [1])
+_LT_TAGDECL([], [predeps], [1])
+_LT_TAGDECL([], [postdeps], [1])
+_LT_TAGDECL([], [compiler_lib_search_path], [1],
+ [The library search path used internally by the compiler when linking
+ a shared library])
+])# _LT_SYS_HIDDEN_LIBDEPS
+
+
+# _LT_PROG_F77
+# ------------
+# Since AC_PROG_F77 is broken, in that it returns the empty string
+# if there is no fortran compiler, we have our own version here.
+m4_defun([_LT_PROG_F77],
+[
+pushdef([AC_MSG_ERROR], [_lt_disable_F77=yes])
+AC_PROG_F77
+if test -z "$F77" || test "X$F77" = "Xno"; then
+ _lt_disable_F77=yes
+fi
+popdef([AC_MSG_ERROR])
+])# _LT_PROG_F77
+
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([_LT_PROG_F77], [])
+
+
+# _LT_LANG_F77_CONFIG([TAG])
+# --------------------------
+# Ensure that the configuration variables for a Fortran 77 compiler are
+# suitably defined. These variables are subsequently used by _LT_CONFIG
+# to write the compiler configuration to `libtool'.
+m4_defun([_LT_LANG_F77_CONFIG],
+[AC_REQUIRE([_LT_PROG_F77])dnl
+AC_LANG_PUSH(Fortran 77)
+
+_LT_TAGVAR(archive_cmds_need_lc, $1)=no
+_LT_TAGVAR(allow_undefined_flag, $1)=
+_LT_TAGVAR(always_export_symbols, $1)=no
+_LT_TAGVAR(archive_expsym_cmds, $1)=
+_LT_TAGVAR(export_dynamic_flag_spec, $1)=
+_LT_TAGVAR(hardcode_direct, $1)=no
+_LT_TAGVAR(hardcode_direct_absolute, $1)=no
+_LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
+_LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
+_LT_TAGVAR(hardcode_libdir_separator, $1)=
+_LT_TAGVAR(hardcode_minus_L, $1)=no
+_LT_TAGVAR(hardcode_automatic, $1)=no
+_LT_TAGVAR(inherit_rpath, $1)=no
+_LT_TAGVAR(module_cmds, $1)=
+_LT_TAGVAR(module_expsym_cmds, $1)=
+_LT_TAGVAR(link_all_deplibs, $1)=unknown
+_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
+_LT_TAGVAR(no_undefined_flag, $1)=
+_LT_TAGVAR(whole_archive_flag_spec, $1)=
+_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no
+
+# Source file extension for f77 test sources.
+ac_ext=f
+
+# Object file extension for compiled f77 test sources.
+objext=o
+_LT_TAGVAR(objext, $1)=$objext
+
+# No sense in running all these tests if we already determined that
+# the F77 compiler isn't working. Some variables (like enable_shared)
+# are currently assumed to apply to all compilers on this platform,
+# and will be corrupted by setting them based on a non-working compiler.
+if test "$_lt_disable_F77" != yes; then
+ # Code to be used in simple compile tests
+ lt_simple_compile_test_code="\
+ subroutine t
+ return
+ end
+"
+
+ # Code to be used in simple link tests
+ lt_simple_link_test_code="\
+ program t
+ end
+"
+
+ # ltmain only uses $CC for tagged configurations so make sure $CC is set.
+ _LT_TAG_COMPILER
+
+ # save warnings/boilerplate of simple test code
+ _LT_COMPILER_BOILERPLATE
+ _LT_LINKER_BOILERPLATE
+
+ # Allow CC to be a program name with arguments.
+ lt_save_CC="$CC"
+ lt_save_GCC=$GCC
+ CC=${F77-"f77"}
+ compiler=$CC
+ _LT_TAGVAR(compiler, $1)=$CC
+ _LT_CC_BASENAME([$compiler])
+ GCC=$G77
+ if test -n "$compiler"; then
+ AC_MSG_CHECKING([if libtool supports shared libraries])
+ AC_MSG_RESULT([$can_build_shared])
+
+ AC_MSG_CHECKING([whether to build shared libraries])
+ test "$can_build_shared" = "no" && enable_shared=no
+
+ # On AIX, shared libraries and static libraries use the same namespace, and
+ # are all built from PIC.
+ case $host_os in
+ aix3*)
+ test "$enable_shared" = yes && enable_static=no
+ if test -n "$RANLIB"; then
+ archive_cmds="$archive_cmds~\$RANLIB \$lib"
+ postinstall_cmds='$RANLIB $lib'
+ fi
+ ;;
+ aix[[4-9]]*)
+ if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
+ test "$enable_shared" = yes && enable_static=no
+ fi
+ ;;
+ esac
+ AC_MSG_RESULT([$enable_shared])
+
+ AC_MSG_CHECKING([whether to build static libraries])
+ # Make sure either enable_shared or enable_static is yes.
+ test "$enable_shared" = yes || enable_static=yes
+ AC_MSG_RESULT([$enable_static])
+
+ _LT_TAGVAR(GCC, $1)="$G77"
+ _LT_TAGVAR(LD, $1)="$LD"
+
+ ## CAVEAT EMPTOR:
+ ## There is no encapsulation within the following macros, do not change
+ ## the running order or otherwise move them around unless you know exactly
+ ## what you are doing...
+ _LT_COMPILER_PIC($1)
+ _LT_COMPILER_C_O($1)
+ _LT_COMPILER_FILE_LOCKS($1)
+ _LT_LINKER_SHLIBS($1)
+ _LT_SYS_DYNAMIC_LINKER($1)
+ _LT_LINKER_HARDCODE_LIBPATH($1)
+
+ _LT_CONFIG($1)
+ fi # test -n "$compiler"
+
+ GCC=$lt_save_GCC
+ CC="$lt_save_CC"
+fi # test "$_lt_disable_F77" != yes
+
+AC_LANG_POP
+])# _LT_LANG_F77_CONFIG
+
+
+# _LT_PROG_FC
+# -----------
+# Since AC_PROG_FC is broken, in that it returns the empty string
+# if there is no fortran compiler, we have our own version here.
+m4_defun([_LT_PROG_FC],
+[
+pushdef([AC_MSG_ERROR], [_lt_disable_FC=yes])
+AC_PROG_FC
+if test -z "$FC" || test "X$FC" = "Xno"; then
+ _lt_disable_FC=yes
+fi
+popdef([AC_MSG_ERROR])
+])# _LT_PROG_FC
+
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([_LT_PROG_FC], [])
+
+
+# _LT_LANG_FC_CONFIG([TAG])
+# -------------------------
+# Ensure that the configuration variables for a Fortran compiler are
+# suitably defined. These variables are subsequently used by _LT_CONFIG
+# to write the compiler configuration to `libtool'.
+m4_defun([_LT_LANG_FC_CONFIG],
+[AC_REQUIRE([_LT_PROG_FC])dnl
+AC_LANG_PUSH(Fortran)
+
+_LT_TAGVAR(archive_cmds_need_lc, $1)=no
+_LT_TAGVAR(allow_undefined_flag, $1)=
+_LT_TAGVAR(always_export_symbols, $1)=no
+_LT_TAGVAR(archive_expsym_cmds, $1)=
+_LT_TAGVAR(export_dynamic_flag_spec, $1)=
+_LT_TAGVAR(hardcode_direct, $1)=no
+_LT_TAGVAR(hardcode_direct_absolute, $1)=no
+_LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
+_LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
+_LT_TAGVAR(hardcode_libdir_separator, $1)=
+_LT_TAGVAR(hardcode_minus_L, $1)=no
+_LT_TAGVAR(hardcode_automatic, $1)=no
+_LT_TAGVAR(inherit_rpath, $1)=no
+_LT_TAGVAR(module_cmds, $1)=
+_LT_TAGVAR(module_expsym_cmds, $1)=
+_LT_TAGVAR(link_all_deplibs, $1)=unknown
+_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
+_LT_TAGVAR(no_undefined_flag, $1)=
+_LT_TAGVAR(whole_archive_flag_spec, $1)=
+_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no
+
+# Source file extension for fc test sources.
+ac_ext=${ac_fc_srcext-f}
+
+# Object file extension for compiled fc test sources.
+objext=o
+_LT_TAGVAR(objext, $1)=$objext
+
+# No sense in running all these tests if we already determined that
+# the FC compiler isn't working. Some variables (like enable_shared)
+# are currently assumed to apply to all compilers on this platform,
+# and will be corrupted by setting them based on a non-working compiler.
+if test "$_lt_disable_FC" != yes; then
+ # Code to be used in simple compile tests
+ lt_simple_compile_test_code="\
+ subroutine t
+ return
+ end
+"
+
+ # Code to be used in simple link tests
+ lt_simple_link_test_code="\
+ program t
+ end
+"
+
+ # ltmain only uses $CC for tagged configurations so make sure $CC is set.
+ _LT_TAG_COMPILER
+
+ # save warnings/boilerplate of simple test code
+ _LT_COMPILER_BOILERPLATE
+ _LT_LINKER_BOILERPLATE
+
+ # Allow CC to be a program name with arguments.
+ lt_save_CC="$CC"
+ lt_save_GCC=$GCC
+ CC=${FC-"f95"}
+ compiler=$CC
+ GCC=$ac_cv_fc_compiler_gnu
+
+ _LT_TAGVAR(compiler, $1)=$CC
+ _LT_CC_BASENAME([$compiler])
+
+ if test -n "$compiler"; then
+ AC_MSG_CHECKING([if libtool supports shared libraries])
+ AC_MSG_RESULT([$can_build_shared])
+
+ AC_MSG_CHECKING([whether to build shared libraries])
+ test "$can_build_shared" = "no" && enable_shared=no
+
+ # On AIX, shared libraries and static libraries use the same namespace, and
+ # are all built from PIC.
+ case $host_os in
+ aix3*)
+ test "$enable_shared" = yes && enable_static=no
+ if test -n "$RANLIB"; then
+ archive_cmds="$archive_cmds~\$RANLIB \$lib"
+ postinstall_cmds='$RANLIB $lib'
+ fi
+ ;;
+ aix[[4-9]]*)
+ if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
+ test "$enable_shared" = yes && enable_static=no
+ fi
+ ;;
+ esac
+ AC_MSG_RESULT([$enable_shared])
+
+ AC_MSG_CHECKING([whether to build static libraries])
+ # Make sure either enable_shared or enable_static is yes.
+ test "$enable_shared" = yes || enable_static=yes
+ AC_MSG_RESULT([$enable_static])
+
+ _LT_TAGVAR(GCC, $1)="$ac_cv_fc_compiler_gnu"
+ _LT_TAGVAR(LD, $1)="$LD"
+
+ ## CAVEAT EMPTOR:
+ ## There is no encapsulation within the following macros, do not change
+ ## the running order or otherwise move them around unless you know exactly
+ ## what you are doing...
+ _LT_SYS_HIDDEN_LIBDEPS($1)
+ _LT_COMPILER_PIC($1)
+ _LT_COMPILER_C_O($1)
+ _LT_COMPILER_FILE_LOCKS($1)
+ _LT_LINKER_SHLIBS($1)
+ _LT_SYS_DYNAMIC_LINKER($1)
+ _LT_LINKER_HARDCODE_LIBPATH($1)
+
+ _LT_CONFIG($1)
+ fi # test -n "$compiler"
+
+ GCC=$lt_save_GCC
+ CC="$lt_save_CC"
+fi # test "$_lt_disable_FC" != yes
+
+AC_LANG_POP
+])# _LT_LANG_FC_CONFIG
+
+
+# _LT_LANG_GCJ_CONFIG([TAG])
+# --------------------------
+# Ensure that the configuration variables for the GNU Java Compiler compiler
+# are suitably defined. These variables are subsequently used by _LT_CONFIG
+# to write the compiler configuration to `libtool'.
+m4_defun([_LT_LANG_GCJ_CONFIG],
+[AC_REQUIRE([LT_PROG_GCJ])dnl
+AC_LANG_SAVE
+
+# Source file extension for Java test sources.
+ac_ext=java
+
+# Object file extension for compiled Java test sources.
+objext=o
+_LT_TAGVAR(objext, $1)=$objext
+
+# Code to be used in simple compile tests
+lt_simple_compile_test_code="class foo {}"
+
+# Code to be used in simple link tests
+lt_simple_link_test_code='public class conftest { public static void main(String[[]] argv) {}; }'
+
+# ltmain only uses $CC for tagged configurations so make sure $CC is set.
+_LT_TAG_COMPILER
+
+# save warnings/boilerplate of simple test code
+_LT_COMPILER_BOILERPLATE
+_LT_LINKER_BOILERPLATE
+
+# Allow CC to be a program name with arguments.
+lt_save_CC="$CC"
+lt_save_GCC=$GCC
+GCC=yes
+CC=${GCJ-"gcj"}
+compiler=$CC
+_LT_TAGVAR(compiler, $1)=$CC
+_LT_TAGVAR(LD, $1)="$LD"
+_LT_CC_BASENAME([$compiler])
+
+# GCJ did not exist at the time GCC didn't implicitly link libc in.
+_LT_TAGVAR(archive_cmds_need_lc, $1)=no
+
+_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
+
+## CAVEAT EMPTOR:
+## There is no encapsulation within the following macros, do not change
+## the running order or otherwise move them around unless you know exactly
+## what you are doing...
+if test -n "$compiler"; then
+ _LT_COMPILER_NO_RTTI($1)
+ _LT_COMPILER_PIC($1)
+ _LT_COMPILER_C_O($1)
+ _LT_COMPILER_FILE_LOCKS($1)
+ _LT_LINKER_SHLIBS($1)
+ _LT_LINKER_HARDCODE_LIBPATH($1)
+
+ _LT_CONFIG($1)
+fi
+
+AC_LANG_RESTORE
+
+GCC=$lt_save_GCC
+CC="$lt_save_CC"
+])# _LT_LANG_GCJ_CONFIG
+
+
+# _LT_LANG_RC_CONFIG([TAG])
+# -------------------------
+# Ensure that the configuration variables for the Windows resource compiler
+# are suitably defined. These variables are subsequently used by _LT_CONFIG
+# to write the compiler configuration to `libtool'.
+m4_defun([_LT_LANG_RC_CONFIG],
+[AC_REQUIRE([LT_PROG_RC])dnl
+AC_LANG_SAVE
+
+# Source file extension for RC test sources.
+ac_ext=rc
+
+# Object file extension for compiled RC test sources.
+objext=o
+_LT_TAGVAR(objext, $1)=$objext
+
+# Code to be used in simple compile tests
+lt_simple_compile_test_code='sample MENU { MENUITEM "&Soup", 100, CHECKED }'
+
+# Code to be used in simple link tests
+lt_simple_link_test_code="$lt_simple_compile_test_code"
+
+# ltmain only uses $CC for tagged configurations so make sure $CC is set.
+_LT_TAG_COMPILER
+
+# save warnings/boilerplate of simple test code
+_LT_COMPILER_BOILERPLATE
+_LT_LINKER_BOILERPLATE
+
+# Allow CC to be a program name with arguments.
+lt_save_CC="$CC"
+lt_save_GCC=$GCC
+GCC=
+CC=${RC-"windres"}
+compiler=$CC
+_LT_TAGVAR(compiler, $1)=$CC
+_LT_CC_BASENAME([$compiler])
+_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes
+
+if test -n "$compiler"; then
+ :
+ _LT_CONFIG($1)
+fi
+
+GCC=$lt_save_GCC
+AC_LANG_RESTORE
+CC="$lt_save_CC"
+])# _LT_LANG_RC_CONFIG
+
+
+# LT_PROG_GCJ
+# -----------
+AC_DEFUN([LT_PROG_GCJ],
+[m4_ifdef([AC_PROG_GCJ], [AC_PROG_GCJ],
+ [m4_ifdef([A][M_PROG_GCJ], [A][M_PROG_GCJ],
+ [AC_CHECK_TOOL(GCJ, gcj,)
+ test "x${GCJFLAGS+set}" = xset || GCJFLAGS="-g -O2"
+ AC_SUBST(GCJFLAGS)])])[]dnl
+])
+
+# Old name:
+AU_ALIAS([LT_AC_PROG_GCJ], [LT_PROG_GCJ])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([LT_AC_PROG_GCJ], [])
+
+
+# LT_PROG_RC
+# ----------
+AC_DEFUN([LT_PROG_RC],
+[AC_CHECK_TOOL(RC, windres,)
+])
+
+# Old name:
+AU_ALIAS([LT_AC_PROG_RC], [LT_PROG_RC])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([LT_AC_PROG_RC], [])
+
+
+# _LT_DECL_EGREP
+# --------------
+# If we don't have a new enough Autoconf to choose the best grep
+# available, choose the one first in the user's PATH.
+m4_defun([_LT_DECL_EGREP],
+[AC_REQUIRE([AC_PROG_EGREP])dnl
+AC_REQUIRE([AC_PROG_FGREP])dnl
+test -z "$GREP" && GREP=grep
+_LT_DECL([], [GREP], [1], [A grep program that handles long lines])
+_LT_DECL([], [EGREP], [1], [An ERE matcher])
+_LT_DECL([], [FGREP], [1], [A literal string matcher])
+dnl Non-bleeding-edge autoconf doesn't subst GREP, so do it here too
+AC_SUBST([GREP])
+])
+
+
+# _LT_DECL_OBJDUMP
+# --------------
+# If we don't have a new enough Autoconf to choose the best objdump
+# available, choose the one first in the user's PATH.
+m4_defun([_LT_DECL_OBJDUMP],
+[AC_CHECK_TOOL(OBJDUMP, objdump, false)
+test -z "$OBJDUMP" && OBJDUMP=objdump
+_LT_DECL([], [OBJDUMP], [1], [An object symbol dumper])
+AC_SUBST([OBJDUMP])
+])
+
+
+# _LT_DECL_SED
+# ------------
+# Check for a fully-functional sed program, that truncates
+# as few characters as possible. Prefer GNU sed if found.
+m4_defun([_LT_DECL_SED],
+[AC_PROG_SED
+test -z "$SED" && SED=sed
+Xsed="$SED -e 1s/^X//"
+_LT_DECL([], [SED], [1], [A sed program that does not truncate output])
+_LT_DECL([], [Xsed], ["\$SED -e 1s/^X//"],
+ [Sed that helps us avoid accidentally triggering echo(1) options like -n])
+])# _LT_DECL_SED
+
+m4_ifndef([AC_PROG_SED], [
+############################################################
+# NOTE: This macro has been submitted for inclusion into #
+# GNU Autoconf as AC_PROG_SED. When it is available in #
+# a released version of Autoconf we should remove this #
+# macro and use it instead. #
+############################################################
+
+m4_defun([AC_PROG_SED],
+[AC_MSG_CHECKING([for a sed that does not truncate output])
+AC_CACHE_VAL(lt_cv_path_SED,
+[# Loop through the user's path and test for sed and gsed.
+# Then use that list of sed's as ones to test for truncation.
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for lt_ac_prog in sed gsed; do
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if $as_executable_p "$as_dir/$lt_ac_prog$ac_exec_ext"; then
+ lt_ac_sed_list="$lt_ac_sed_list $as_dir/$lt_ac_prog$ac_exec_ext"
+ fi
+ done
+ done
+done
+IFS=$as_save_IFS
+lt_ac_max=0
+lt_ac_count=0
+# Add /usr/xpg4/bin/sed as it is typically found on Solaris
+# along with /bin/sed that truncates output.
+for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do
+ test ! -f $lt_ac_sed && continue
+ cat /dev/null > conftest.in
+ lt_ac_count=0
+ echo $ECHO_N "0123456789$ECHO_C" >conftest.in
+ # Check for GNU sed and select it if it is found.
+ if "$lt_ac_sed" --version 2>&1 < /dev/null | grep 'GNU' > /dev/null; then
+ lt_cv_path_SED=$lt_ac_sed
+ break
+ fi
+ while true; do
+ cat conftest.in conftest.in >conftest.tmp
+ mv conftest.tmp conftest.in
+ cp conftest.in conftest.nl
+ echo >>conftest.nl
+ $lt_ac_sed -e 's/a$//' < conftest.nl >conftest.out || break
+ cmp -s conftest.out conftest.nl || break
+ # 10000 chars as input seems more than enough
+ test $lt_ac_count -gt 10 && break
+ lt_ac_count=`expr $lt_ac_count + 1`
+ if test $lt_ac_count -gt $lt_ac_max; then
+ lt_ac_max=$lt_ac_count
+ lt_cv_path_SED=$lt_ac_sed
+ fi
+ done
+done
+])
+SED=$lt_cv_path_SED
+AC_SUBST([SED])
+AC_MSG_RESULT([$SED])
+])#AC_PROG_SED
+])#m4_ifndef
+
+# Old name:
+AU_ALIAS([LT_AC_PROG_SED], [AC_PROG_SED])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([LT_AC_PROG_SED], [])
+
+
+# _LT_CHECK_SHELL_FEATURES
+# ------------------------
+# Find out whether the shell is Bourne or XSI compatible,
+# or has some other useful features.
+m4_defun([_LT_CHECK_SHELL_FEATURES],
+[AC_MSG_CHECKING([whether the shell understands some XSI constructs])
+# Try some XSI features
+xsi_shell=no
+( _lt_dummy="a/b/c"
+ test "${_lt_dummy##*/},${_lt_dummy%/*},"${_lt_dummy%"$_lt_dummy"}, \
+ = c,a/b,, \
+ && eval 'test $(( 1 + 1 )) -eq 2 \
+ && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \
+ && xsi_shell=yes
+AC_MSG_RESULT([$xsi_shell])
+_LT_CONFIG_LIBTOOL_INIT([xsi_shell='$xsi_shell'])
+
+AC_MSG_CHECKING([whether the shell understands "+="])
+lt_shell_append=no
+( foo=bar; set foo baz; eval "$[1]+=\$[2]" && test "$foo" = barbaz ) \
+ >/dev/null 2>&1 \
+ && lt_shell_append=yes
+AC_MSG_RESULT([$lt_shell_append])
+_LT_CONFIG_LIBTOOL_INIT([lt_shell_append='$lt_shell_append'])
+
+if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
+ lt_unset=unset
+else
+ lt_unset=false
+fi
+_LT_DECL([], [lt_unset], [0], [whether the shell understands "unset"])dnl
+
+# test EBCDIC or ASCII
+case `echo X|tr X '\101'` in
+ A) # ASCII based system
+ # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr
+ lt_SP2NL='tr \040 \012'
+ lt_NL2SP='tr \015\012 \040\040'
+ ;;
+ *) # EBCDIC based system
+ lt_SP2NL='tr \100 \n'
+ lt_NL2SP='tr \r\n \100\100'
+ ;;
+esac
+_LT_DECL([SP2NL], [lt_SP2NL], [1], [turn spaces into newlines])dnl
+_LT_DECL([NL2SP], [lt_NL2SP], [1], [turn newlines into spaces])dnl
+])# _LT_CHECK_SHELL_FEATURES
+
+
+# _LT_PROG_XSI_SHELLFNS
+# ---------------------
+# Bourne and XSI compatible variants of some useful shell functions.
+m4_defun([_LT_PROG_XSI_SHELLFNS],
+[case $xsi_shell in
+ yes)
+ cat << \_LT_EOF >> "$cfgfile"
+
+# func_dirname file append nondir_replacement
+# Compute the dirname of FILE. If nonempty, add APPEND to the result,
+# otherwise set result to NONDIR_REPLACEMENT.
+func_dirname ()
+{
+ case ${1} in
+ */*) func_dirname_result="${1%/*}${2}" ;;
+ * ) func_dirname_result="${3}" ;;
+ esac
+}
+
+# func_basename file
+func_basename ()
+{
+ func_basename_result="${1##*/}"
+}
+
+# func_dirname_and_basename file append nondir_replacement
+# perform func_basename and func_dirname in a single function
+# call:
+# dirname: Compute the dirname of FILE. If nonempty,
+# add APPEND to the result, otherwise set result
+# to NONDIR_REPLACEMENT.
+# value returned in "$func_dirname_result"
+# basename: Compute filename of FILE.
+# value retuned in "$func_basename_result"
+# Implementation must be kept synchronized with func_dirname
+# and func_basename. For efficiency, we do not delegate to
+# those functions but instead duplicate the functionality here.
+func_dirname_and_basename ()
+{
+ case ${1} in
+ */*) func_dirname_result="${1%/*}${2}" ;;
+ * ) func_dirname_result="${3}" ;;
+ esac
+ func_basename_result="${1##*/}"
+}
+
+# func_stripname prefix suffix name
+# strip PREFIX and SUFFIX off of NAME.
+# PREFIX and SUFFIX must not contain globbing or regex special
+# characters, hashes, percent signs, but SUFFIX may contain a leading
+# dot (in which case that matches only a dot).
+func_stripname ()
+{
+ # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are
+ # positional parameters, so assign one to ordinary parameter first.
+ func_stripname_result=${3}
+ func_stripname_result=${func_stripname_result#"${1}"}
+ func_stripname_result=${func_stripname_result%"${2}"}
+}
+
+# func_opt_split
+func_opt_split ()
+{
+ func_opt_split_opt=${1%%=*}
+ func_opt_split_arg=${1#*=}
+}
+
+# func_lo2o object
+func_lo2o ()
+{
+ case ${1} in
+ *.lo) func_lo2o_result=${1%.lo}.${objext} ;;
+ *) func_lo2o_result=${1} ;;
+ esac
+}
+
+# func_xform libobj-or-source
+func_xform ()
+{
+ func_xform_result=${1%.*}.lo
+}
+
+# func_arith arithmetic-term...
+func_arith ()
+{
+ func_arith_result=$(( $[*] ))
+}
+
+# func_len string
+# STRING may not start with a hyphen.
+func_len ()
+{
+ func_len_result=${#1}
+}
+
+_LT_EOF
+ ;;
+ *) # Bourne compatible functions.
+ cat << \_LT_EOF >> "$cfgfile"
+
+# func_dirname file append nondir_replacement
+# Compute the dirname of FILE. If nonempty, add APPEND to the result,
+# otherwise set result to NONDIR_REPLACEMENT.
+func_dirname ()
+{
+ # Extract subdirectory from the argument.
+ func_dirname_result=`$ECHO "X${1}" | $Xsed -e "$dirname"`
+ if test "X$func_dirname_result" = "X${1}"; then
+ func_dirname_result="${3}"
+ else
+ func_dirname_result="$func_dirname_result${2}"
+ fi
+}
+
+# func_basename file
+func_basename ()
+{
+ func_basename_result=`$ECHO "X${1}" | $Xsed -e "$basename"`
+}
+
+dnl func_dirname_and_basename
+dnl A portable version of this function is already defined in general.m4sh
+dnl so there is no need for it here.
+
+# func_stripname prefix suffix name
+# strip PREFIX and SUFFIX off of NAME.
+# PREFIX and SUFFIX must not contain globbing or regex special
+# characters, hashes, percent signs, but SUFFIX may contain a leading
+# dot (in which case that matches only a dot).
+# func_strip_suffix prefix name
+func_stripname ()
+{
+ case ${2} in
+ .*) func_stripname_result=`$ECHO "X${3}" \
+ | $Xsed -e "s%^${1}%%" -e "s%\\\\${2}\$%%"`;;
+ *) func_stripname_result=`$ECHO "X${3}" \
+ | $Xsed -e "s%^${1}%%" -e "s%${2}\$%%"`;;
+ esac
+}
+
+# sed scripts:
+my_sed_long_opt='1s/^\(-[[^=]]*\)=.*/\1/;q'
+my_sed_long_arg='1s/^-[[^=]]*=//'
+
+# func_opt_split
+func_opt_split ()
+{
+ func_opt_split_opt=`$ECHO "X${1}" | $Xsed -e "$my_sed_long_opt"`
+ func_opt_split_arg=`$ECHO "X${1}" | $Xsed -e "$my_sed_long_arg"`
+}
+
+# func_lo2o object
+func_lo2o ()
+{
+ func_lo2o_result=`$ECHO "X${1}" | $Xsed -e "$lo2o"`
+}
+
+# func_xform libobj-or-source
+func_xform ()
+{
+ func_xform_result=`$ECHO "X${1}" | $Xsed -e 's/\.[[^.]]*$/.lo/'`
+}
+
+# func_arith arithmetic-term...
+func_arith ()
+{
+ func_arith_result=`expr "$[@]"`
+}
+
+# func_len string
+# STRING may not start with a hyphen.
+func_len ()
+{
+ func_len_result=`expr "$[1]" : ".*" 2>/dev/null || echo $max_cmd_len`
+}
+
+_LT_EOF
+esac
+
+case $lt_shell_append in
+ yes)
+ cat << \_LT_EOF >> "$cfgfile"
+
+# func_append var value
+# Append VALUE to the end of shell variable VAR.
+func_append ()
+{
+ eval "$[1]+=\$[2]"
+}
+_LT_EOF
+ ;;
+ *)
+ cat << \_LT_EOF >> "$cfgfile"
+
+# func_append var value
+# Append VALUE to the end of shell variable VAR.
+func_append ()
+{
+ eval "$[1]=\$$[1]\$[2]"
+}
+
+_LT_EOF
+ ;;
+ esac
+])
Added: freeswitch/trunk/libs/libsndfile/M4/llrint.m4
==============================================================================
--- (empty file)
+++ freeswitch/trunk/libs/libsndfile/M4/llrint.m4 Thu May 21 16:09:30 2009
@@ -0,0 +1,38 @@
+dnl @synopsis AC_C99_FUNC_LLRINT
+dnl
+dnl Check whether C99's llrint function is available.
+dnl @version 1.1 Sep 30 2002
+dnl @author Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+dnl
+dnl Permission to use, copy, modify, distribute, and sell this file for any
+dnl purpose is hereby granted without fee, provided that the above copyright
+dnl and this permission notice appear in all copies. No representations are
+dnl made about the suitability of this software for any purpose. It is
+dnl provided "as is" without express or implied warranty.
+dnl
+AC_DEFUN([AC_C99_FUNC_LLRINT],
+[AC_CACHE_CHECK(for llrint,
+ ac_cv_c99_llrint,
+[
+llrint_save_CFLAGS=$CFLAGS
+CFLAGS="-lm"
+AC_TRY_LINK([
+#define _ISOC9X_SOURCE 1
+#define _ISOC99_SOURCE 1
+#define __USE_ISOC99 1
+#define __USE_ISOC9X 1
+
+#include <math.h>
+#include <stdint.h>
+], int64_t x ; x = llrint(3.14159) ;, ac_cv_c99_llrint=yes, ac_cv_c99_llrint=no)
+
+CFLAGS=$llrint_save_CFLAGS
+
+])
+
+if test "$ac_cv_c99_llrint" = yes; then
+ AC_DEFINE(HAVE_LLRINT, 1,
+ [Define if you have C99's llrint function.])
+fi
+])# AC_C99_FUNC_LLRINT
+
Added: freeswitch/trunk/libs/libsndfile/M4/lrint.m4
==============================================================================
--- (empty file)
+++ freeswitch/trunk/libs/libsndfile/M4/lrint.m4 Thu May 21 16:09:30 2009
@@ -0,0 +1,37 @@
+dnl @synopsis AC_C99_FUNC_LRINT
+dnl
+dnl Check whether C99's lrint function is available.
+dnl @version 1.3 Feb 12 2002
+dnl @author Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+dnl
+dnl Permission to use, copy, modify, distribute, and sell this file for any
+dnl purpose is hereby granted without fee, provided that the above copyright
+dnl and this permission notice appear in all copies. No representations are
+dnl made about the suitability of this software for any purpose. It is
+dnl provided "as is" without express or implied warranty.
+dnl
+AC_DEFUN([AC_C99_FUNC_LRINT],
+[AC_CACHE_CHECK(for lrint,
+ ac_cv_c99_lrint,
+[
+lrint_save_CFLAGS=$CFLAGS
+CFLAGS="-lm"
+AC_TRY_LINK([
+#define _ISOC9X_SOURCE 1
+#define _ISOC99_SOURCE 1
+#define __USE_ISOC99 1
+#define __USE_ISOC9X 1
+
+#include <math.h>
+], if (!lrint(3.14159)) lrint(2.7183);, ac_cv_c99_lrint=yes, ac_cv_c99_lrint=no)
+
+CFLAGS=$lrint_save_CFLAGS
+
+])
+
+if test "$ac_cv_c99_lrint" = yes; then
+ AC_DEFINE(HAVE_LRINT, 1,
+ [Define if you have C99's lrint function.])
+fi
+])# AC_C99_FUNC_LRINT
+
Added: freeswitch/trunk/libs/libsndfile/M4/lrintf.m4
==============================================================================
--- (empty file)
+++ freeswitch/trunk/libs/libsndfile/M4/lrintf.m4 Thu May 21 16:09:30 2009
@@ -0,0 +1,37 @@
+dnl @synopsis AC_C99_FUNC_LRINTF
+dnl
+dnl Check whether C99's lrintf function is available.
+dnl @version 1.3 Feb 12 2002
+dnl @author Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+dnl
+dnl Permission to use, copy, modify, distribute, and sell this file for any
+dnl purpose is hereby granted without fee, provided that the above copyright
+dnl and this permission notice appear in all copies. No representations are
+dnl made about the suitability of this software for any purpose. It is
+dnl provided "as is" without express or implied warranty.
+dnl
+AC_DEFUN([AC_C99_FUNC_LRINTF],
+[AC_CACHE_CHECK(for lrintf,
+ ac_cv_c99_lrintf,
+[
+lrintf_save_CFLAGS=$CFLAGS
+CFLAGS="-lm"
+AC_TRY_LINK([
+#define _ISOC9X_SOURCE 1
+#define _ISOC99_SOURCE 1
+#define __USE_ISOC99 1
+#define __USE_ISOC9X 1
+
+#include <math.h>
+], if (!lrintf(3.14159)) lrintf(2.7183);, ac_cv_c99_lrintf=yes, ac_cv_c99_lrintf=no)
+
+CFLAGS=$lrintf_save_CFLAGS
+
+])
+
+if test "$ac_cv_c99_lrintf" = yes; then
+ AC_DEFINE(HAVE_LRINTF, 1,
+ [Define if you have C99's lrintf function.])
+fi
+])# AC_C99_FUNC_LRINTF
+
Added: freeswitch/trunk/libs/libsndfile/M4/ltoptions.m4
==============================================================================
--- (empty file)
+++ freeswitch/trunk/libs/libsndfile/M4/ltoptions.m4 Thu May 21 16:09:30 2009
@@ -0,0 +1,368 @@
+# Helper functions for option handling. -*- Autoconf -*-
+#
+# Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc.
+# Written by Gary V. Vaughan, 2004
+#
+# This file is free software; the Free Software Foundation gives
+# unlimited permission to copy and/or distribute it, with or without
+# modifications, as long as this notice is preserved.
+
+# serial 6 ltoptions.m4
+
+# This is to help aclocal find these macros, as it can't see m4_define.
+AC_DEFUN([LTOPTIONS_VERSION], [m4_if([1])])
+
+
+# _LT_MANGLE_OPTION(MACRO-NAME, OPTION-NAME)
+# ------------------------------------------
+m4_define([_LT_MANGLE_OPTION],
+[[_LT_OPTION_]m4_bpatsubst($1__$2, [[^a-zA-Z0-9_]], [_])])
+
+
+# _LT_SET_OPTION(MACRO-NAME, OPTION-NAME)
+# ---------------------------------------
+# Set option OPTION-NAME for macro MACRO-NAME, and if there is a
+# matching handler defined, dispatch to it. Other OPTION-NAMEs are
+# saved as a flag.
+m4_define([_LT_SET_OPTION],
+[m4_define(_LT_MANGLE_OPTION([$1], [$2]))dnl
+m4_ifdef(_LT_MANGLE_DEFUN([$1], [$2]),
+ _LT_MANGLE_DEFUN([$1], [$2]),
+ [m4_warning([Unknown $1 option `$2'])])[]dnl
+])
+
+
+# _LT_IF_OPTION(MACRO-NAME, OPTION-NAME, IF-SET, [IF-NOT-SET])
+# ------------------------------------------------------------
+# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise.
+m4_define([_LT_IF_OPTION],
+[m4_ifdef(_LT_MANGLE_OPTION([$1], [$2]), [$3], [$4])])
+
+
+# _LT_UNLESS_OPTIONS(MACRO-NAME, OPTION-LIST, IF-NOT-SET)
+# -------------------------------------------------------
+# Execute IF-NOT-SET unless all options in OPTION-LIST for MACRO-NAME
+# are set.
+m4_define([_LT_UNLESS_OPTIONS],
+[m4_foreach([_LT_Option], m4_split(m4_normalize([$2])),
+ [m4_ifdef(_LT_MANGLE_OPTION([$1], _LT_Option),
+ [m4_define([$0_found])])])[]dnl
+m4_ifdef([$0_found], [m4_undefine([$0_found])], [$3
+])[]dnl
+])
+
+
+# _LT_SET_OPTIONS(MACRO-NAME, OPTION-LIST)
+# ----------------------------------------
+# OPTION-LIST is a space-separated list of Libtool options associated
+# with MACRO-NAME. If any OPTION has a matching handler declared with
+# LT_OPTION_DEFINE, dispatch to that macro; otherwise complain about
+# the unknown option and exit.
+m4_defun([_LT_SET_OPTIONS],
+[# Set options
+m4_foreach([_LT_Option], m4_split(m4_normalize([$2])),
+ [_LT_SET_OPTION([$1], _LT_Option)])
+
+m4_if([$1],[LT_INIT],[
+ dnl
+ dnl Simply set some default values (i.e off) if boolean options were not
+ dnl specified:
+ _LT_UNLESS_OPTIONS([LT_INIT], [dlopen], [enable_dlopen=no
+ ])
+ _LT_UNLESS_OPTIONS([LT_INIT], [win32-dll], [enable_win32_dll=no
+ ])
+ dnl
+ dnl If no reference was made to various pairs of opposing options, then
+ dnl we run the default mode handler for the pair. For example, if neither
+ dnl `shared' nor `disable-shared' was passed, we enable building of shared
+ dnl archives by default:
+ _LT_UNLESS_OPTIONS([LT_INIT], [shared disable-shared], [_LT_ENABLE_SHARED])
+ _LT_UNLESS_OPTIONS([LT_INIT], [static disable-static], [_LT_ENABLE_STATIC])
+ _LT_UNLESS_OPTIONS([LT_INIT], [pic-only no-pic], [_LT_WITH_PIC])
+ _LT_UNLESS_OPTIONS([LT_INIT], [fast-install disable-fast-install],
+ [_LT_ENABLE_FAST_INSTALL])
+ ])
+])# _LT_SET_OPTIONS
+
+
+## --------------------------------- ##
+## Macros to handle LT_INIT options. ##
+## --------------------------------- ##
+
+# _LT_MANGLE_DEFUN(MACRO-NAME, OPTION-NAME)
+# -----------------------------------------
+m4_define([_LT_MANGLE_DEFUN],
+[[_LT_OPTION_DEFUN_]m4_bpatsubst(m4_toupper([$1__$2]), [[^A-Z0-9_]], [_])])
+
+
+# LT_OPTION_DEFINE(MACRO-NAME, OPTION-NAME, CODE)
+# -----------------------------------------------
+m4_define([LT_OPTION_DEFINE],
+[m4_define(_LT_MANGLE_DEFUN([$1], [$2]), [$3])[]dnl
+])# LT_OPTION_DEFINE
+
+
+# dlopen
+# ------
+LT_OPTION_DEFINE([LT_INIT], [dlopen], [enable_dlopen=yes
+])
+
+AU_DEFUN([AC_LIBTOOL_DLOPEN],
+[_LT_SET_OPTION([LT_INIT], [dlopen])
+AC_DIAGNOSE([obsolete],
+[$0: Remove this warning and the call to _LT_SET_OPTION when you
+put the `dlopen' option into LT_INIT's first parameter.])
+])
+
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_LIBTOOL_DLOPEN], [])
+
+
+# win32-dll
+# ---------
+# Declare package support for building win32 dll's.
+LT_OPTION_DEFINE([LT_INIT], [win32-dll],
+[enable_win32_dll=yes
+
+case $host in
+*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-cegcc*)
+ AC_CHECK_TOOL(AS, as, false)
+ AC_CHECK_TOOL(DLLTOOL, dlltool, false)
+ AC_CHECK_TOOL(OBJDUMP, objdump, false)
+ ;;
+esac
+
+test -z "$AS" && AS=as
+_LT_DECL([], [AS], [0], [Assembler program])dnl
+
+test -z "$DLLTOOL" && DLLTOOL=dlltool
+_LT_DECL([], [DLLTOOL], [0], [DLL creation program])dnl
+
+test -z "$OBJDUMP" && OBJDUMP=objdump
+_LT_DECL([], [OBJDUMP], [0], [Object dumper program])dnl
+])# win32-dll
+
+AU_DEFUN([AC_LIBTOOL_WIN32_DLL],
+[AC_REQUIRE([AC_CANONICAL_HOST])dnl
+_LT_SET_OPTION([LT_INIT], [win32-dll])
+AC_DIAGNOSE([obsolete],
+[$0: Remove this warning and the call to _LT_SET_OPTION when you
+put the `win32-dll' option into LT_INIT's first parameter.])
+])
+
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_LIBTOOL_WIN32_DLL], [])
+
+
+# _LT_ENABLE_SHARED([DEFAULT])
+# ----------------------------
+# implement the --enable-shared flag, and supports the `shared' and
+# `disable-shared' LT_INIT options.
+# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'.
+m4_define([_LT_ENABLE_SHARED],
+[m4_define([_LT_ENABLE_SHARED_DEFAULT], [m4_if($1, no, no, yes)])dnl
+AC_ARG_ENABLE([shared],
+ [AS_HELP_STRING([--enable-shared@<:@=PKGS@:>@],
+ [build shared libraries @<:@default=]_LT_ENABLE_SHARED_DEFAULT[@:>@])],
+ [p=${PACKAGE-default}
+ case $enableval in
+ yes) enable_shared=yes ;;
+ no) enable_shared=no ;;
+ *)
+ enable_shared=no
+ # Look at the argument we got. We use all the common list separators.
+ lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+ for pkg in $enableval; do
+ IFS="$lt_save_ifs"
+ if test "X$pkg" = "X$p"; then
+ enable_shared=yes
+ fi
+ done
+ IFS="$lt_save_ifs"
+ ;;
+ esac],
+ [enable_shared=]_LT_ENABLE_SHARED_DEFAULT)
+
+ _LT_DECL([build_libtool_libs], [enable_shared], [0],
+ [Whether or not to build shared libraries])
+])# _LT_ENABLE_SHARED
+
+LT_OPTION_DEFINE([LT_INIT], [shared], [_LT_ENABLE_SHARED([yes])])
+LT_OPTION_DEFINE([LT_INIT], [disable-shared], [_LT_ENABLE_SHARED([no])])
+
+# Old names:
+AC_DEFUN([AC_ENABLE_SHARED],
+[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[shared])
+])
+
+AC_DEFUN([AC_DISABLE_SHARED],
+[_LT_SET_OPTION([LT_INIT], [disable-shared])
+])
+
+AU_DEFUN([AM_ENABLE_SHARED], [AC_ENABLE_SHARED($@)])
+AU_DEFUN([AM_DISABLE_SHARED], [AC_DISABLE_SHARED($@)])
+
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AM_ENABLE_SHARED], [])
+dnl AC_DEFUN([AM_DISABLE_SHARED], [])
+
+
+
+# _LT_ENABLE_STATIC([DEFAULT])
+# ----------------------------
+# implement the --enable-static flag, and support the `static' and
+# `disable-static' LT_INIT options.
+# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'.
+m4_define([_LT_ENABLE_STATIC],
+[m4_define([_LT_ENABLE_STATIC_DEFAULT], [m4_if($1, no, no, yes)])dnl
+AC_ARG_ENABLE([static],
+ [AS_HELP_STRING([--enable-static@<:@=PKGS@:>@],
+ [build static libraries @<:@default=]_LT_ENABLE_STATIC_DEFAULT[@:>@])],
+ [p=${PACKAGE-default}
+ case $enableval in
+ yes) enable_static=yes ;;
+ no) enable_static=no ;;
+ *)
+ enable_static=no
+ # Look at the argument we got. We use all the common list separators.
+ lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+ for pkg in $enableval; do
+ IFS="$lt_save_ifs"
+ if test "X$pkg" = "X$p"; then
+ enable_static=yes
+ fi
+ done
+ IFS="$lt_save_ifs"
+ ;;
+ esac],
+ [enable_static=]_LT_ENABLE_STATIC_DEFAULT)
+
+ _LT_DECL([build_old_libs], [enable_static], [0],
+ [Whether or not to build static libraries])
+])# _LT_ENABLE_STATIC
+
+LT_OPTION_DEFINE([LT_INIT], [static], [_LT_ENABLE_STATIC([yes])])
+LT_OPTION_DEFINE([LT_INIT], [disable-static], [_LT_ENABLE_STATIC([no])])
+
+# Old names:
+AC_DEFUN([AC_ENABLE_STATIC],
+[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[static])
+])
+
+AC_DEFUN([AC_DISABLE_STATIC],
+[_LT_SET_OPTION([LT_INIT], [disable-static])
+])
+
+AU_DEFUN([AM_ENABLE_STATIC], [AC_ENABLE_STATIC($@)])
+AU_DEFUN([AM_DISABLE_STATIC], [AC_DISABLE_STATIC($@)])
+
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AM_ENABLE_STATIC], [])
+dnl AC_DEFUN([AM_DISABLE_STATIC], [])
+
+
+
+# _LT_ENABLE_FAST_INSTALL([DEFAULT])
+# ----------------------------------
+# implement the --enable-fast-install flag, and support the `fast-install'
+# and `disable-fast-install' LT_INIT options.
+# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'.
+m4_define([_LT_ENABLE_FAST_INSTALL],
+[m4_define([_LT_ENABLE_FAST_INSTALL_DEFAULT], [m4_if($1, no, no, yes)])dnl
+AC_ARG_ENABLE([fast-install],
+ [AS_HELP_STRING([--enable-fast-install@<:@=PKGS@:>@],
+ [optimize for fast installation @<:@default=]_LT_ENABLE_FAST_INSTALL_DEFAULT[@:>@])],
+ [p=${PACKAGE-default}
+ case $enableval in
+ yes) enable_fast_install=yes ;;
+ no) enable_fast_install=no ;;
+ *)
+ enable_fast_install=no
+ # Look at the argument we got. We use all the common list separators.
+ lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+ for pkg in $enableval; do
+ IFS="$lt_save_ifs"
+ if test "X$pkg" = "X$p"; then
+ enable_fast_install=yes
+ fi
+ done
+ IFS="$lt_save_ifs"
+ ;;
+ esac],
+ [enable_fast_install=]_LT_ENABLE_FAST_INSTALL_DEFAULT)
+
+_LT_DECL([fast_install], [enable_fast_install], [0],
+ [Whether or not to optimize for fast installation])dnl
+])# _LT_ENABLE_FAST_INSTALL
+
+LT_OPTION_DEFINE([LT_INIT], [fast-install], [_LT_ENABLE_FAST_INSTALL([yes])])
+LT_OPTION_DEFINE([LT_INIT], [disable-fast-install], [_LT_ENABLE_FAST_INSTALL([no])])
+
+# Old names:
+AU_DEFUN([AC_ENABLE_FAST_INSTALL],
+[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[fast-install])
+AC_DIAGNOSE([obsolete],
+[$0: Remove this warning and the call to _LT_SET_OPTION when you put
+the `fast-install' option into LT_INIT's first parameter.])
+])
+
+AU_DEFUN([AC_DISABLE_FAST_INSTALL],
+[_LT_SET_OPTION([LT_INIT], [disable-fast-install])
+AC_DIAGNOSE([obsolete],
+[$0: Remove this warning and the call to _LT_SET_OPTION when you put
+the `disable-fast-install' option into LT_INIT's first parameter.])
+])
+
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_ENABLE_FAST_INSTALL], [])
+dnl AC_DEFUN([AM_DISABLE_FAST_INSTALL], [])
+
+
+# _LT_WITH_PIC([MODE])
+# --------------------
+# implement the --with-pic flag, and support the `pic-only' and `no-pic'
+# LT_INIT options.
+# MODE is either `yes' or `no'. If omitted, it defaults to `both'.
+m4_define([_LT_WITH_PIC],
+[AC_ARG_WITH([pic],
+ [AS_HELP_STRING([--with-pic],
+ [try to use only PIC/non-PIC objects @<:@default=use both@:>@])],
+ [pic_mode="$withval"],
+ [pic_mode=default])
+
+test -z "$pic_mode" && pic_mode=m4_default([$1], [default])
+
+_LT_DECL([], [pic_mode], [0], [What type of objects to build])dnl
+])# _LT_WITH_PIC
+
+LT_OPTION_DEFINE([LT_INIT], [pic-only], [_LT_WITH_PIC([yes])])
+LT_OPTION_DEFINE([LT_INIT], [no-pic], [_LT_WITH_PIC([no])])
+
+# Old name:
+AU_DEFUN([AC_LIBTOOL_PICMODE],
+[_LT_SET_OPTION([LT_INIT], [pic-only])
+AC_DIAGNOSE([obsolete],
+[$0: Remove this warning and the call to _LT_SET_OPTION when you
+put the `pic-only' option into LT_INIT's first parameter.])
+])
+
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_LIBTOOL_PICMODE], [])
+
+## ----------------- ##
+## LTDL_INIT Options ##
+## ----------------- ##
+
+m4_define([_LTDL_MODE], [])
+LT_OPTION_DEFINE([LTDL_INIT], [nonrecursive],
+ [m4_define([_LTDL_MODE], [nonrecursive])])
+LT_OPTION_DEFINE([LTDL_INIT], [recursive],
+ [m4_define([_LTDL_MODE], [recursive])])
+LT_OPTION_DEFINE([LTDL_INIT], [subproject],
+ [m4_define([_LTDL_MODE], [subproject])])
+
+m4_define([_LTDL_TYPE], [])
+LT_OPTION_DEFINE([LTDL_INIT], [installable],
+ [m4_define([_LTDL_TYPE], [installable])])
+LT_OPTION_DEFINE([LTDL_INIT], [convenience],
+ [m4_define([_LTDL_TYPE], [convenience])])
Added: freeswitch/trunk/libs/libsndfile/M4/ltsugar.m4
==============================================================================
--- (empty file)
+++ freeswitch/trunk/libs/libsndfile/M4/ltsugar.m4 Thu May 21 16:09:30 2009
@@ -0,0 +1,123 @@
+# ltsugar.m4 -- libtool m4 base layer. -*-Autoconf-*-
+#
+# Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc.
+# Written by Gary V. Vaughan, 2004
+#
+# This file is free software; the Free Software Foundation gives
+# unlimited permission to copy and/or distribute it, with or without
+# modifications, as long as this notice is preserved.
+
+# serial 6 ltsugar.m4
+
+# This is to help aclocal find these macros, as it can't see m4_define.
+AC_DEFUN([LTSUGAR_VERSION], [m4_if([0.1])])
+
+
+# lt_join(SEP, ARG1, [ARG2...])
+# -----------------------------
+# Produce ARG1SEPARG2...SEPARGn, omitting [] arguments and their
+# associated separator.
+# Needed until we can rely on m4_join from Autoconf 2.62, since all earlier
+# versions in m4sugar had bugs.
+m4_define([lt_join],
+[m4_if([$#], [1], [],
+ [$#], [2], [[$2]],
+ [m4_if([$2], [], [], [[$2]_])$0([$1], m4_shift(m4_shift($@)))])])
+m4_define([_lt_join],
+[m4_if([$#$2], [2], [],
+ [m4_if([$2], [], [], [[$1$2]])$0([$1], m4_shift(m4_shift($@)))])])
+
+
+# lt_car(LIST)
+# lt_cdr(LIST)
+# ------------
+# Manipulate m4 lists.
+# These macros are necessary as long as will still need to support
+# Autoconf-2.59 which quotes differently.
+m4_define([lt_car], [[$1]])
+m4_define([lt_cdr],
+[m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])],
+ [$#], 1, [],
+ [m4_dquote(m4_shift($@))])])
+m4_define([lt_unquote], $1)
+
+
+# lt_append(MACRO-NAME, STRING, [SEPARATOR])
+# ------------------------------------------
+# Redefine MACRO-NAME to hold its former content plus `SEPARATOR'`STRING'.
+# Note that neither SEPARATOR nor STRING are expanded; they are appended
+# to MACRO-NAME as is (leaving the expansion for when MACRO-NAME is invoked).
+# No SEPARATOR is output if MACRO-NAME was previously undefined (different
+# than defined and empty).
+#
+# This macro is needed until we can rely on Autoconf 2.62, since earlier
+# versions of m4sugar mistakenly expanded SEPARATOR but not STRING.
+m4_define([lt_append],
+[m4_define([$1],
+ m4_ifdef([$1], [m4_defn([$1])[$3]])[$2])])
+
+
+
+# lt_combine(SEP, PREFIX-LIST, INFIX, SUFFIX1, [SUFFIX2...])
+# ----------------------------------------------------------
+# Produce a SEP delimited list of all paired combinations of elements of
+# PREFIX-LIST with SUFFIX1 through SUFFIXn. Each element of the list
+# has the form PREFIXmINFIXSUFFIXn.
+# Needed until we can rely on m4_combine added in Autoconf 2.62.
+m4_define([lt_combine],
+[m4_if(m4_eval([$# > 3]), [1],
+ [m4_pushdef([_Lt_sep], [m4_define([_Lt_sep], m4_defn([lt_car]))])]]dnl
+[[m4_foreach([_Lt_prefix], [$2],
+ [m4_foreach([_Lt_suffix],
+ ]m4_dquote(m4_dquote(m4_shift(m4_shift(m4_shift($@)))))[,
+ [_Lt_sep([$1])[]m4_defn([_Lt_prefix])[$3]m4_defn([_Lt_suffix])])])])])
+
+
+# lt_if_append_uniq(MACRO-NAME, VARNAME, [SEPARATOR], [UNIQ], [NOT-UNIQ])
+# -----------------------------------------------------------------------
+# Iff MACRO-NAME does not yet contain VARNAME, then append it (delimited
+# by SEPARATOR if supplied) and expand UNIQ, else NOT-UNIQ.
+m4_define([lt_if_append_uniq],
+[m4_ifdef([$1],
+ [m4_if(m4_index([$3]m4_defn([$1])[$3], [$3$2$3]), [-1],
+ [lt_append([$1], [$2], [$3])$4],
+ [$5])],
+ [lt_append([$1], [$2], [$3])$4])])
+
+
+# lt_dict_add(DICT, KEY, VALUE)
+# -----------------------------
+m4_define([lt_dict_add],
+[m4_define([$1($2)], [$3])])
+
+
+# lt_dict_add_subkey(DICT, KEY, SUBKEY, VALUE)
+# --------------------------------------------
+m4_define([lt_dict_add_subkey],
+[m4_define([$1($2:$3)], [$4])])
+
+
+# lt_dict_fetch(DICT, KEY, [SUBKEY])
+# ----------------------------------
+m4_define([lt_dict_fetch],
+[m4_ifval([$3],
+ m4_ifdef([$1($2:$3)], [m4_defn([$1($2:$3)])]),
+ m4_ifdef([$1($2)], [m4_defn([$1($2)])]))])
+
+
+# lt_if_dict_fetch(DICT, KEY, [SUBKEY], VALUE, IF-TRUE, [IF-FALSE])
+# -----------------------------------------------------------------
+m4_define([lt_if_dict_fetch],
+[m4_if(lt_dict_fetch([$1], [$2], [$3]), [$4],
+ [$5],
+ [$6])])
+
+
+# lt_dict_filter(DICT, [SUBKEY], VALUE, [SEPARATOR], KEY, [...])
+# --------------------------------------------------------------
+m4_define([lt_dict_filter],
+[m4_if([$5], [], [],
+ [lt_join(m4_quote(m4_default([$4], [[, ]])),
+ lt_unquote(m4_split(m4_normalize(m4_foreach(_Lt_key, lt_car([m4_shiftn(4, $@)]),
+ [lt_if_dict_fetch([$1], _Lt_key, [$2], [$3], [_Lt_key ])])))))])[]dnl
+])
Added: freeswitch/trunk/libs/libsndfile/M4/ltversion.m4
==============================================================================
--- (empty file)
+++ freeswitch/trunk/libs/libsndfile/M4/ltversion.m4 Thu May 21 16:09:30 2009
@@ -0,0 +1,23 @@
+# ltversion.m4 -- version numbers -*- Autoconf -*-
+#
+# Copyright (C) 2004 Free Software Foundation, Inc.
+# Written by Scott James Remnant, 2004
+#
+# This file is free software; the Free Software Foundation gives
+# unlimited permission to copy and/or distribute it, with or without
+# modifications, as long as this notice is preserved.
+
+# Generated from ltversion.in.
+
+# serial 3012 ltversion.m4
+# This file is part of GNU Libtool
+
+m4_define([LT_PACKAGE_VERSION], [2.2.6])
+m4_define([LT_PACKAGE_REVISION], [1.3012])
+
+AC_DEFUN([LTVERSION_VERSION],
+[macro_version='2.2.6'
+macro_revision='1.3012'
+_LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?])
+_LT_DECL(, macro_revision, 0)
+])
Added: freeswitch/trunk/libs/libsndfile/M4/lt~obsolete.m4
==============================================================================
--- (empty file)
+++ freeswitch/trunk/libs/libsndfile/M4/lt~obsolete.m4 Thu May 21 16:09:30 2009
@@ -0,0 +1,92 @@
+# lt~obsolete.m4 -- aclocal satisfying obsolete definitions. -*-Autoconf-*-
+#
+# Copyright (C) 2004, 2005, 2007 Free Software Foundation, Inc.
+# Written by Scott James Remnant, 2004.
+#
+# This file is free software; the Free Software Foundation gives
+# unlimited permission to copy and/or distribute it, with or without
+# modifications, as long as this notice is preserved.
+
+# serial 4 lt~obsolete.m4
+
+# These exist entirely to fool aclocal when bootstrapping libtool.
+#
+# In the past libtool.m4 has provided macros via AC_DEFUN (or AU_DEFUN)
+# which have later been changed to m4_define as they aren't part of the
+# exported API, or moved to Autoconf or Automake where they belong.
+#
+# The trouble is, aclocal is a bit thick. It'll see the old AC_DEFUN
+# in /usr/share/aclocal/libtool.m4 and remember it, then when it sees us
+# using a macro with the same name in our local m4/libtool.m4 it'll
+# pull the old libtool.m4 in (it doesn't see our shiny new m4_define
+# and doesn't know about Autoconf macros at all.)
+#
+# So we provide this file, which has a silly filename so it's always
+# included after everything else. This provides aclocal with the
+# AC_DEFUNs it wants, but when m4 processes it, it doesn't do anything
+# because those macros already exist, or will be overwritten later.
+# We use AC_DEFUN over AU_DEFUN for compatibility with aclocal-1.6.
+#
+# Anytime we withdraw an AC_DEFUN or AU_DEFUN, remember to add it here.
+# Yes, that means every name once taken will need to remain here until
+# we give up compatibility with versions before 1.7, at which point
+# we need to keep only those names which we still refer to.
+
+# This is to help aclocal find these macros, as it can't see m4_define.
+AC_DEFUN([LTOBSOLETE_VERSION], [m4_if([1])])
+
+m4_ifndef([AC_LIBTOOL_LINKER_OPTION], [AC_DEFUN([AC_LIBTOOL_LINKER_OPTION])])
+m4_ifndef([AC_PROG_EGREP], [AC_DEFUN([AC_PROG_EGREP])])
+m4_ifndef([_LT_AC_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH])])
+m4_ifndef([_LT_AC_SHELL_INIT], [AC_DEFUN([_LT_AC_SHELL_INIT])])
+m4_ifndef([_LT_AC_SYS_LIBPATH_AIX], [AC_DEFUN([_LT_AC_SYS_LIBPATH_AIX])])
+m4_ifndef([_LT_PROG_LTMAIN], [AC_DEFUN([_LT_PROG_LTMAIN])])
+m4_ifndef([_LT_AC_TAGVAR], [AC_DEFUN([_LT_AC_TAGVAR])])
+m4_ifndef([AC_LTDL_ENABLE_INSTALL], [AC_DEFUN([AC_LTDL_ENABLE_INSTALL])])
+m4_ifndef([AC_LTDL_PREOPEN], [AC_DEFUN([AC_LTDL_PREOPEN])])
+m4_ifndef([_LT_AC_SYS_COMPILER], [AC_DEFUN([_LT_AC_SYS_COMPILER])])
+m4_ifndef([_LT_AC_LOCK], [AC_DEFUN([_LT_AC_LOCK])])
+m4_ifndef([AC_LIBTOOL_SYS_OLD_ARCHIVE], [AC_DEFUN([AC_LIBTOOL_SYS_OLD_ARCHIVE])])
+m4_ifndef([_LT_AC_TRY_DLOPEN_SELF], [AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF])])
+m4_ifndef([AC_LIBTOOL_PROG_CC_C_O], [AC_DEFUN([AC_LIBTOOL_PROG_CC_C_O])])
+m4_ifndef([AC_LIBTOOL_SYS_HARD_LINK_LOCKS], [AC_DEFUN([AC_LIBTOOL_SYS_HARD_LINK_LOCKS])])
+m4_ifndef([AC_LIBTOOL_OBJDIR], [AC_DEFUN([AC_LIBTOOL_OBJDIR])])
+m4_ifndef([AC_LTDL_OBJDIR], [AC_DEFUN([AC_LTDL_OBJDIR])])
+m4_ifndef([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH], [AC_DEFUN([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH])])
+m4_ifndef([AC_LIBTOOL_SYS_LIB_STRIP], [AC_DEFUN([AC_LIBTOOL_SYS_LIB_STRIP])])
+m4_ifndef([AC_PATH_MAGIC], [AC_DEFUN([AC_PATH_MAGIC])])
+m4_ifndef([AC_PROG_LD_GNU], [AC_DEFUN([AC_PROG_LD_GNU])])
+m4_ifndef([AC_PROG_LD_RELOAD_FLAG], [AC_DEFUN([AC_PROG_LD_RELOAD_FLAG])])
+m4_ifndef([AC_DEPLIBS_CHECK_METHOD], [AC_DEFUN([AC_DEPLIBS_CHECK_METHOD])])
+m4_ifndef([AC_LIBTOOL_PROG_COMPILER_NO_RTTI], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_NO_RTTI])])
+m4_ifndef([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE], [AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE])])
+m4_ifndef([AC_LIBTOOL_PROG_COMPILER_PIC], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_PIC])])
+m4_ifndef([AC_LIBTOOL_PROG_LD_SHLIBS], [AC_DEFUN([AC_LIBTOOL_PROG_LD_SHLIBS])])
+m4_ifndef([AC_LIBTOOL_POSTDEP_PREDEP], [AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP])])
+m4_ifndef([LT_AC_PROG_EGREP], [AC_DEFUN([LT_AC_PROG_EGREP])])
+m4_ifndef([LT_AC_PROG_SED], [AC_DEFUN([LT_AC_PROG_SED])])
+m4_ifndef([_LT_CC_BASENAME], [AC_DEFUN([_LT_CC_BASENAME])])
+m4_ifndef([_LT_COMPILER_BOILERPLATE], [AC_DEFUN([_LT_COMPILER_BOILERPLATE])])
+m4_ifndef([_LT_LINKER_BOILERPLATE], [AC_DEFUN([_LT_LINKER_BOILERPLATE])])
+m4_ifndef([_AC_PROG_LIBTOOL], [AC_DEFUN([_AC_PROG_LIBTOOL])])
+m4_ifndef([AC_LIBTOOL_SETUP], [AC_DEFUN([AC_LIBTOOL_SETUP])])
+m4_ifndef([_LT_AC_CHECK_DLFCN], [AC_DEFUN([_LT_AC_CHECK_DLFCN])])
+m4_ifndef([AC_LIBTOOL_SYS_DYNAMIC_LINKER], [AC_DEFUN([AC_LIBTOOL_SYS_DYNAMIC_LINKER])])
+m4_ifndef([_LT_AC_TAGCONFIG], [AC_DEFUN([_LT_AC_TAGCONFIG])])
+m4_ifndef([AC_DISABLE_FAST_INSTALL], [AC_DEFUN([AC_DISABLE_FAST_INSTALL])])
+m4_ifndef([_LT_AC_LANG_CXX], [AC_DEFUN([_LT_AC_LANG_CXX])])
+m4_ifndef([_LT_AC_LANG_F77], [AC_DEFUN([_LT_AC_LANG_F77])])
+m4_ifndef([_LT_AC_LANG_GCJ], [AC_DEFUN([_LT_AC_LANG_GCJ])])
+m4_ifndef([AC_LIBTOOL_RC], [AC_DEFUN([AC_LIBTOOL_RC])])
+m4_ifndef([AC_LIBTOOL_LANG_C_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_C_CONFIG])])
+m4_ifndef([_LT_AC_LANG_C_CONFIG], [AC_DEFUN([_LT_AC_LANG_C_CONFIG])])
+m4_ifndef([AC_LIBTOOL_LANG_CXX_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_CXX_CONFIG])])
+m4_ifndef([_LT_AC_LANG_CXX_CONFIG], [AC_DEFUN([_LT_AC_LANG_CXX_CONFIG])])
+m4_ifndef([AC_LIBTOOL_LANG_F77_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_F77_CONFIG])])
+m4_ifndef([_LT_AC_LANG_F77_CONFIG], [AC_DEFUN([_LT_AC_LANG_F77_CONFIG])])
+m4_ifndef([AC_LIBTOOL_LANG_GCJ_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_GCJ_CONFIG])])
+m4_ifndef([_LT_AC_LANG_GCJ_CONFIG], [AC_DEFUN([_LT_AC_LANG_GCJ_CONFIG])])
+m4_ifndef([AC_LIBTOOL_LANG_RC_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_RC_CONFIG])])
+m4_ifndef([_LT_AC_LANG_RC_CONFIG], [AC_DEFUN([_LT_AC_LANG_RC_CONFIG])])
+m4_ifndef([AC_LIBTOOL_CONFIG], [AC_DEFUN([AC_LIBTOOL_CONFIG])])
+m4_ifndef([_LT_AC_FILE_LTDLL_C], [AC_DEFUN([_LT_AC_FILE_LTDLL_C])])
Added: freeswitch/trunk/libs/libsndfile/M4/mkoctfile_version.m4
==============================================================================
--- (empty file)
+++ freeswitch/trunk/libs/libsndfile/M4/mkoctfile_version.m4 Thu May 21 16:09:30 2009
@@ -0,0 +1,38 @@
+dnl @synopsis AC_MKOCTFILE_VERSION
+dnl
+dnl Find the version of mkoctfile.
+dnl @version 1.0 Aug 23 2007
+dnl @author Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+dnl
+dnl Permission to use, copy, modify, distribute, and sell this file for any
+dnl purpose is hereby granted without fee, provided that the above copyright
+dnl and this permission notice appear in all copies. No representations are
+dnl made about the suitability of this software for any purpose. It is
+dnl provided "as is" without express or implied warranty.
+dnl
+
+AC_DEFUN([AC_MKOCTFILE_VERSION],
+[
+
+
+AC_ARG_WITH(mkoctfile,
+ AC_HELP_STRING([--with-mkoctfile], [choose the mkoctfile version]),
+ [ with_mkoctfile=$withval ])
+
+test -z "$with_mkoctfile" && with_mkoctfile=mkoctfile
+
+AC_CHECK_PROG(HAVE_MKOCTFILE,$with_mkoctfile,yes,no)
+
+if test "x$ac_cv_prog_HAVE_MKOCTFILE" = "xyes" ; then
+ MKOCTFILE=$with_mkoctfile
+
+ AC_MSG_CHECKING([for version of $MKOCTFILE])
+ MKOCTFILE_VERSION=`$with_mkoctfile --version 2>&1 | sed 's/mkoctfile, version //g'`
+ AC_MSG_RESULT($MKOCTFILE_VERSION)
+ fi
+
+AC_SUBST(MKOCTFILE)
+AC_SUBST(MKOCTFILE_VERSION)
+
+])# AC_MKOCTFILE_VERSION
+
Added: freeswitch/trunk/libs/libsndfile/M4/octave.m4
==============================================================================
--- (empty file)
+++ freeswitch/trunk/libs/libsndfile/M4/octave.m4 Thu May 21 16:09:30 2009
@@ -0,0 +1,143 @@
+dnl Evaluate an expression in octave
+dnl
+dnl OCTAVE_EVAL(expr,var) -> var=expr
+dnl
+dnl Stolen from octave-forge
+
+AC_DEFUN([OCTAVE_EVAL],
+[
+AC_MSG_CHECKING([for $1 in $OCTAVE])
+$2=`TERM=;$OCTAVE -qfH --eval "disp($1)"`
+AC_MSG_RESULT($$2)
+AC_SUBST($2)
+]) # OCTAVE_EVAL
+
+dnl @synopsis AC_OCTAVE_VERSION
+dnl
+dnl Find the version of Octave.
+dnl @version 1.0 Aug 23 2007
+dnl @author Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+dnl
+dnl Permission to use, copy, modify, distribute, and sell this file for any
+dnl purpose is hereby granted without fee, provided that the above copyright
+dnl and this permission notice appear in all copies. No representations are
+dnl made about the suitability of this software for any purpose. It is
+dnl provided "as is" without express or implied warranty.
+dnl
+
+AC_DEFUN([AC_OCTAVE_VERSION],
+[
+
+AC_ARG_WITH(octave,
+ AC_HELP_STRING([--with-octave], [choose the octave version]),
+ [ with_octave=$withval ])
+
+test -z "$with_octave" && with_octave=octave
+
+AC_CHECK_PROG(HAVE_OCTAVE,$with_octave,yes,no)
+
+if test "x$ac_cv_prog_HAVE_OCTAVE" = "xyes" ; then
+ OCTAVE=$with_octave
+ OCTAVE_EVAL(OCTAVE_VERSION,OCTAVE_VERSION)
+ fi
+
+AC_SUBST(OCTAVE)
+AC_SUBST(OCTAVE_VERSION)
+
+])# AC_OCTAVE_VERSION
+
+dnl @synopsis AC_OCTAVE_CONFIG_VERSION
+dnl
+dnl Find the version of Octave.
+dnl @version 1.0 Aug 23 2007
+dnl @author Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+dnl
+dnl Permission to use, copy, modify, distribute, and sell this file for any
+dnl purpose is hereby granted without fee, provided that the above copyright
+dnl and this permission notice appear in all copies. No representations are
+dnl made about the suitability of this software for any purpose. It is
+dnl provided "as is" without express or implied warranty.
+dnl
+
+AC_DEFUN([AC_OCTAVE_CONFIG_VERSION],
+[
+
+AC_ARG_WITH(octave-config,
+ AC_HELP_STRING([--with-octave-config], [choose the octave-config version]),
+ [ with_octave_config=$withval ])
+
+test -z "$with_octave_config" && with_octave_config=octave-config
+
+AC_CHECK_PROG(HAVE_OCTAVE_CONFIG,$with_octave_config,yes,no)
+
+if test "x$ac_cv_prog_HAVE_OCTAVE_CONFIG" = "xyes" ; then
+ OCTAVE_CONFIG=$with_octave_config
+ AC_MSG_CHECKING([for version of $OCTAVE_CONFIG])
+ OCTAVE_CONFIG_VERSION=`$OCTAVE_CONFIG --version`
+ AC_MSG_RESULT($OCTAVE_CONFIG_VERSION)
+ fi
+
+AC_SUBST(OCTAVE_CONFIG)
+AC_SUBST(OCTAVE_CONFIG_VERSION)
+
+])# AC_OCTAVE_CONFIG_VERSION
+
+dnl @synopsis AC_OCTAVE_BUILD
+dnl
+dnl Check programs and headers required for building octave plugins.
+dnl @version 1.0 Aug 23 2007
+dnl @author Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+dnl
+dnl Permission to use, copy, modify, distribute, and sell this file for any
+dnl purpose is hereby granted without fee, provided that the above copyright
+dnl and this permission notice appear in all copies. No representations are
+dnl made about the suitability of this software for any purpose. It is
+dnl provided "as is" without express or implied warranty.
+
+
+AC_DEFUN([AC_OCTAVE_BUILD],
+[
+
+dnl Default to no.
+OCTAVE_BUILD=no
+
+AC_OCTAVE_VERSION
+AC_MKOCTFILE_VERSION
+AC_OCTAVE_CONFIG_VERSION
+
+prog_concat="$ac_cv_prog_HAVE_OCTAVE$ac_cv_prog_HAVE_OCTAVE_CONFIG$ac_cv_prog_HAVE_MKOCTFILE"
+
+if test "x$prog_concat" = "xyesyesyes" ; then
+ if test "x$OCTAVE_VERSION" != "x$MKOCTFILE_VERSION" ; then
+ AC_MSG_WARN([** Mismatch between versions of octave and mkoctfile. **])
+ AC_MSG_WARN([** Octave libsndfile modules will not be built. **])
+ elif test "x$OCTAVE_VERSION" != "x$OCTAVE_CONFIG_VERSION" ; then
+ AC_MSG_WARN([** Mismatch between versions of octave and octave-config. **])
+ AC_MSG_WARN([** Octave libsndfile modules will not be built. **])
+ else
+ case "$MKOCTFILE_VERSION" in
+ 2.*)
+ AC_MSG_WARN([Octave version 2.X is not supported.])
+ ;;
+ 3.0.*)
+ OCTAVE_DEST_ODIR=`$OCTAVE_CONFIG --oct-site-dir | sed 's%^/usr%${prefix}%'`
+ OCTAVE_DEST_MDIR=`$OCTAVE_CONFIG --m-site-dir | sed 's%^/usr%${prefix}%'`
+
+ OCTAVE_BUILD=yes
+ ;;
+ *)
+ AC_MSG_WARN([Octave version $MKOCTFILE_VERSION is not supported.])
+ ;;
+ esac
+ fi
+ AC_MSG_RESULT([building octave libsndfile module... $OCTAVE_BUILD])
+ fi
+
+AC_SUBST(OCTAVE_DEST_ODIR)
+AC_SUBST(OCTAVE_DEST_MDIR)
+
+AC_SUBST(MKOCTFILE)
+
+AM_CONDITIONAL(BUILD_OCTAVE_MOD, test "x$OCTAVE_BUILD" = xyes)
+
+])# AC_OCTAVE_BUILD
Modified: freeswitch/trunk/libs/libsndfile/Makefile.am
==============================================================================
--- freeswitch/trunk/libs/libsndfile/Makefile.am (original)
+++ freeswitch/trunk/libs/libsndfile/Makefile.am Thu May 21 16:09:30 2009
@@ -1,28 +1,29 @@
-# Process this file with automake to produce Makefile.in
-
-SUBDIRS = Win32 Octave src
-# man doc Win32 examples regtest tests
-DIST_SUBDIRS = $(SUBDIRS)
-EXTRA_DIST = reconfigure.mk acinclude.m4 libsndfile.spec.in \
- sndfile.pc.in Mingw-make-dist.sh
-
-
-pkgconfigdir = $(libdir)/pkgconfig
-pkgconfig_DATA = sndfile.pc
-
-m4datadir = $(datadir)/aclocal
-
-test: check-recursive
-
-# Target to make autogenerated files.
-genfiles :
- (cd src ; make genfiles)
- (cd tests ; make genfiles)
-
-
-## Do not edit or modify anything in this comment block.
-## The arch-tag line is a file identity tag for the GNU Arch
-## revision control system.
-##
-## arch-tag: e40c569e-8020-4e95-b774-6b0703614526
-
+## Process this file with automake to produce Makefile.in
+
+DISTCHECK_CONFIGURE_FLAGS = --enable-gcc-werror
+
+if BUILD_OCTAVE_MOD
+octave_dir = Octave
+endif
+
+SUBDIRS = M4 Win32 src $(octave_dir)
+#man doc examples regtest tests programs
+
+DIST_SUBDIRS = M4 man doc Win32 src Octave examples regtest tests programs
+
+EXTRA_DIST = libsndfile.spec.in sndfile.pc.in Mingw-make-dist.sh
+
+
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = sndfile.pc
+
+m4datadir = $(datadir)/aclocal
+
+test: check-recursive
+
+# Target to make autogenerated files.
+genfiles :
+ (cd src ; make genfiles)
+ (cd tests ; make genfiles)
+
+
Modified: freeswitch/trunk/libs/libsndfile/Mingw-make-dist.sh
==============================================================================
--- freeswitch/trunk/libs/libsndfile/Mingw-make-dist.sh (original)
+++ freeswitch/trunk/libs/libsndfile/Mingw-make-dist.sh Thu May 21 16:09:30 2009
@@ -114,9 +114,3 @@
zip -r $ZIPNAME $INSTALL/
fi
-
-# Do not edit or modify anything in this comment block.
-# The following line is a file identity tag for the GNU Arch
-# revision control system.
-#
-# arch-tag: 3f82cd8a-f800-48d7-9646-2cdcf03c81a0
Modified: freeswitch/trunk/libs/libsndfile/NEWS
==============================================================================
--- freeswitch/trunk/libs/libsndfile/NEWS (original)
+++ freeswitch/trunk/libs/libsndfile/NEWS Thu May 21 16:09:30 2009
@@ -1,3 +1,13 @@
+Version 1.0.19 (2009-03-02)
+ * Fix for CVE-2009-0186 (Alin Rad Pop, Secunia Research).
+ * Huge number of minor bug fixes as a result of static analysis.
+
+Version 1.0.18 (2009-02-07)
+ * Add Ogg/Vorbis support (thanks to John ffitch).
+ * Remove captive FLAC library.
+ * Many new features and bug fixes.
+ * Generate Win32 and Win64 pre-compiled binaries.
+
Version 1.0.17 (2006-08-31)
* Add sndfile.hh C++ wrapper.
* Update Win32 MinGW build instructions.
Modified: freeswitch/trunk/libs/libsndfile/Octave/Makefile.am
==============================================================================
--- freeswitch/trunk/libs/libsndfile/Octave/Makefile.am (original)
+++ freeswitch/trunk/libs/libsndfile/Octave/Makefile.am Thu May 21 16:09:30 2009
@@ -1,14 +1,72 @@
## Process this file with automake to produce Makefile.in
-EXTRA_DIST = sndfile_load.m sndfile_save.m sndfile_play.m
+# Prevent any extension.
+EXEEXT =
+
+CXXLD = $(CXX)
+CXXLINK = $(LIBTOOL) --tag=CXX --mode=link $(CXXLD) $(AM_CXXFLAGS) \
+ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+
+EXTRA_DIST = sndfile_load.m sndfile_save.m sndfile_play.m \
+ octave_test.m octave_test.sh $(oct_module_srcs) PKG_ADD
octconfigdir = $(exec_prefix)/share/octave/site/m
octconfig_DATA = sndfile_load.m sndfile_save.m sndfile_play.m
-
-## Do not edit or modify anything in this comment block.
-## The arch-tag line is a file identity tag for the GNU Arch
-## revision control system.
-##
-## arch-tag: 56f1645a-3a13-4846-acc7-8b4abf2904ff
+OCTAVE_DEST_MDIR = @OCTAVE_DEST_MDIR@
+OCTAVE_DEST_ODIR = @OCTAVE_DEST_ODIR@/sndfile
+
+OCT_CXXFLAGS = @OCT_CXXFLAGS@
+OCT_LIB_DIR = @OCT_LIB_DIR@
+OCT_LIBS = @OCT_LIBS@
+
+SNDFILEDIR = $(top_builddir)/src
+INCLUDES = -I$(SNDFILEDIR)
+
+oct_module_srcs = sndfile.cc
+oct_module_files = sndfile.oct PKG_ADD
+
+# Make these noinst so they can be installed manually.
+noinst_DATA = $(oct_module_files)
+
+
+# Use Octave's mkoctfile to do all the heavy lifting. Unfortunately, its
+# a little dumb so we need to guide it carefully.
+sndfile.oct : sndfile.o
+ $(MKOCTFILE) -v $(INCLUDES) $(top_builddir)/Octave/$+ -L$(SNDFILEDIR)/.libs -L$(SNDFILEDIR) -lsndfile -o $(top_builddir)/Octave/$@
+
+sndfile.o : sndfile.cc
+ $(MKOCTFILE) -v $(INCLUDES) -c $+ -o $(top_builddir)/Octave/$@
+
+# Allow for the test being run in the build dir, but the test script
+# being located in the source dir.
+check :
+ octave_src_dir=$(srcdir) $(srcdir)/octave_test.sh
+
+
+# Since the octave modules are installed in a special location, a custom install
+# and uninstall routine must be specified.
+install-exec-local : $(oct_module_files)
+ @$(NORMAL_INSTALL)
+ test -z "$(OCTAVE_DEST_ODIR)" || $(mkdir_p) "$(DESTDIR)$(OCTAVE_DEST_ODIR)"
+ @list='$(oct_module_files)'; for p in $$list; do \
+ p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
+ if test -f $$p \
+ || test -f $$p1 \
+ ; then \
+ f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
+ echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(INSTALL) '$$p' '$(DESTDIR)$(OCTAVE_DEST_ODIR)/$$f'"; \
+ $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(INSTALL) "$$p" "$(DESTDIR)$(OCTAVE_DEST_ODIR)/$$f" || exit 1; \
+ else :; fi; \
+ done
+
+uninstall-local :
+ @$(NORMAL_UNINSTALL)
+ @list='$(oct_module_files)'; for p in $$list; do \
+ f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
+ echo " rm -f '$(DESTDIR)$(OCTAVE_DEST_ODIR)/$$f'"; \
+ rm -f "$(DESTDIR)$(OCTAVE_DEST_ODIR)/$$f"; \
+ done
+clean-local :
+ rm -f sndfile.o sndfile.oct
Added: freeswitch/trunk/libs/libsndfile/Octave/PKG_ADD
==============================================================================
--- (empty file)
+++ freeswitch/trunk/libs/libsndfile/Octave/PKG_ADD Thu May 21 16:09:30 2009
@@ -0,0 +1,3 @@
+autoload ("sfread", "sndfile.oct");
+autoload ("sfversion", "sndfile.oct");
+autoload ("sfwrite", "sndfile.oct");
Added: freeswitch/trunk/libs/libsndfile/Octave/octave_test.m
==============================================================================
--- (empty file)
+++ freeswitch/trunk/libs/libsndfile/Octave/octave_test.m Thu May 21 16:09:30 2009
@@ -0,0 +1,56 @@
+# Copyright (C) 2007 Erik de Castro Lopo <erikd at mega-nerd.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License as published by
+# the Free Software Foundation; either version 2.1 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+# These tests are nowhere near comprehensive.
+
+printf ("\n\n\n\n\n\n\n") ;
+
+printf (" Running Octave tests : ") ;
+fflush (stdout) ;
+
+filename = "whatever" ;
+srate_out = 32000 ;
+fmt_out = "wav-float" ;
+
+t = (2 * pi / srate_out * (0:srate_out-1))' ;
+data_out = sin (440.0 * t) ;
+
+# Write out a file.
+sfwrite (filename, data_out, srate_out, fmt_out) ;
+
+# Read it back in again.
+[ data_in, srate_in, fmt_in ] = sfread (filename) ;
+
+if (srate_in != srate_out)
+ error ("\n\nSample rate mismatch : %d -> %d.\n\n", srate_out, srate_in) ;
+ endif
+
+# Octave strcmp return 1 for the same.
+if (strcmp (fmt_in, fmt_out) != 1)
+ error ("\n\nFormat error : '%s' -> '%s'.\n\n", fmt_out, fmt_in) ;
+ endif
+
+err = max (abs (data_out - data_in)) ;
+
+if (err > 1e-7)
+ error ("err : %g\n", err) ;
+ endif
+
+printf ("ok") ;
+
+printf ("\n\n\n\n\n\n\n") ;
+
+unlink (filename) ;
Added: freeswitch/trunk/libs/libsndfile/Octave/octave_test.sh
==============================================================================
--- (empty file)
+++ freeswitch/trunk/libs/libsndfile/Octave/octave_test.sh Thu May 21 16:09:30 2009
@@ -0,0 +1,72 @@
+#!/bin/bash
+
+
+# Check where we're being run from.
+if [ -d Octave ]; then
+ cd Octave
+ fi
+
+# Find libsndfile shared object.
+libsndfile_lib_location=""
+
+if [ -f "../src/.libs/libsndfile.so" ]; then
+ libsndfile_lib_location="../src/.libs/"
+elif [ -f "../src/libsndfile.so" ]; then
+ libsndfile_lib_location="../src/"
+elif [ -f "../src/.libs/libsndfile.dylib" ]; then
+ libsndfile_lib_location="../src/.libs/"
+elif [ -f "../src/libsndfile.dylib" ]; then
+ libsndfile_lib_location="../src/"
+else
+ echo
+ echo
+ echo "Not able to find the libsndfile shared lib we've just built."
+ echo "This may cause the following test to fail."
+ echo
+ echo
+ fi
+
+libsndfile_lib_location=`(cd $libsndfile_lib_location && pwd)`
+
+
+# Find sndfile.oct
+sndfile_oct_location=""
+
+if [ -f .libs/sndfile.oct ]; then
+ sndfile_oct_location=".libs"
+elif [ -f sndfile.oct ]; then
+ sndfile_oct_location="."
+else
+ echo "Not able to find the sndfile.oct binaries we've just built."
+ exit 1
+ fi
+
+case `file -b $sndfile_oct_location/sndfile.oct` in
+ ELF*)
+ ;;
+ Mach*)
+ echo "Tests don't work on this platform."
+ exit 0
+ ;;
+ *)
+ echo "Not able to find the sndfile.oct binaries we've just built."
+ exit 1
+ ;;
+ esac
+
+
+# Make sure the TERM environment variable doesn't contain anything wrong.
+unset TERM
+
+# echo "libsndfile_lib_location : $libsndfile_lib_location"
+# echo "sndfile_oct_location : $sndfile_oct_location"
+
+export LD_LIBRARY_PATH="$libsndfile_lib_location:$LD_LIBRARY_PATH"
+
+octave_src_dir=`(cd $octave_src_dir && pwd)`
+
+octave_script="$octave_src_dir/octave_test.m"
+
+(cd $sndfile_oct_location && octave -qH $octave_script)
+
+
Added: freeswitch/trunk/libs/libsndfile/Octave/sndfile.cc
==============================================================================
--- (empty file)
+++ freeswitch/trunk/libs/libsndfile/Octave/sndfile.cc Thu May 21 16:09:30 2009
@@ -0,0 +1,405 @@
+/*
+** Copyright (C) 2007 Erik de Castro Lopo <erikd at mega-nerd.com>
+**
+** This program is free software; you can redistribute it and/or modify
+** it under the terms of the GNU Lesser General Public License as published by
+** the Free Software Foundation; either version 2.1 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU Lesser General Public License for more details.
+**
+** You should have received a copy of the GNU Lesser General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#include <octave/oct.h>
+
+#include "sndfile.h"
+
+#define FOUR_GIG (0x100000000LL)
+#define BUFFER_FRAMES 8192
+
+
+static int format_of_str (const std::string & fmt) ;
+static void string_of_format (std::string & fmt, int format) ;
+
+
+DEFUN_DLD (sfversion, args, nargout ,
+"-*- texinfo -*-\n\
+ at deftypefn {Loadable Function} {@var{version} =} sfversion ()\n\
+ at cindex Reading sound files\n\
+Return a string containing the libsndfile version.\n\
+ at seealso{sfread, sfwrite}\n\
+ at end deftypefn")
+{ char buffer [256] ;
+ octave_value_list retval ;
+
+ /* Bail out if the input parameters are bad. */
+ if (args.length () != 0 || nargout > 1)
+ { print_usage () ;
+ return retval ;
+ } ;
+
+ sf_command (NULL, SFC_GET_LIB_VERSION, buffer, sizeof (buffer)) ;
+
+ std::string version (buffer) ;
+
+ retval.append (version) ;
+ return retval ;
+} /* sfversion */
+
+
+DEFUN_DLD (sfread, args, nargout ,
+"-*- texinfo -*-\n\
+ at deftypefn {Loadable Function} {@var{data}, at var{srate}, at var{format} =} sfread (@var{filename})\n\
+ at cindex Reading sound files\n\
+Read a sound file from disk using libsndfile.\n\
+ at seealso{sfversion, sfwrite}\n\
+ at end deftypefn")
+{ SNDFILE * file ;
+ SF_INFO sfinfo ;
+
+ octave_value_list retval ;
+
+ int nargin = args.length () ;
+
+ /* Bail out if the input parameters are bad. */
+ if ((nargin != 1) || !args (0) .is_string () || nargout < 1 || nargout > 3)
+ { print_usage () ;
+ return retval ;
+ } ;
+
+ memset (&sfinfo, 0, sizeof (sfinfo)) ;
+
+ std::string filename = args (0).string_value () ;
+
+ if ((file = sf_open (filename.c_str (), SFM_READ, &sfinfo)) == NULL)
+ { error ("sfread: couldn't open file %s : %s", filename.c_str (), sf_strerror (NULL)) ;
+ return retval ;
+ } ;
+
+ if (sfinfo.frames > FOUR_GIG)
+ printf ("This is a really huge file (%lld frames).\nYou may run out of memory trying to load it.\n", (long long) sfinfo.frames) ;
+
+ dim_vector dim = dim_vector () ;
+ dim.resize (2) ;
+ dim (0) = sfinfo.frames ;
+ dim (1) = sfinfo.channels ;
+
+ /* Should I be using Matrix instead? */
+ NDArray out (dim, 0.0) ;
+
+ float buffer [BUFFER_FRAMES * sfinfo.channels] ;
+ int readcount ;
+ sf_count_t total = 0 ;
+
+ do
+ { readcount = sf_readf_float (file, buffer, BUFFER_FRAMES) ;
+
+ /* Make sure we don't read more frames than we allocated. */
+ if (total + readcount > sfinfo.frames)
+ readcount = sfinfo.frames - total ;
+
+ for (int ch = 0 ; ch < sfinfo.channels ; ch++)
+ { for (int k = 0 ; k < readcount ; k++)
+ out (total + k, ch) = buffer [k * sfinfo.channels + ch] ;
+ } ;
+
+ total += readcount ;
+ } while (readcount > 0 && total < sfinfo.frames) ;
+
+ retval.append (out.squeeze ()) ;
+
+ if (nargout >= 2)
+ retval.append ((octave_uint32) sfinfo.samplerate) ;
+
+ if (nargout >= 3)
+ { std::string fmt ("") ;
+ string_of_format (fmt, sfinfo.format) ;
+ retval.append (fmt) ;
+ } ;
+
+ /* Clean up. */
+ sf_close (file) ;
+
+ return retval ;
+} /* sfread */
+
+DEFUN_DLD (sfwrite, args, nargout ,
+"-*- texinfo -*-\n\
+ at deftypefn {Function File} sfwrite (@var{filename}, at var{data}, at var{srate}, at var{format})\n\
+Write a sound file to disk using libsndfile.\n\
+ at seealso{sfread, sfversion}\n\
+ at end deftypefn\n\
+")
+{ SNDFILE * file ;
+ SF_INFO sfinfo ;
+
+ octave_value_list retval ;
+
+ int nargin = args.length () ;
+
+ /* Bail out if the input parameters are bad. */
+ if (nargin != 4 || !args (0).is_string () || !args (1).is_real_matrix ()
+ || !args (2).is_real_scalar () || !args (3).is_string ()
+ || nargout != 0)
+ { print_usage () ;
+ return retval ;
+ } ;
+
+ std::string filename = args (0).string_value () ;
+ std::string format = args (3).string_value () ;
+
+ memset (&sfinfo, 0, sizeof (sfinfo)) ;
+
+ sfinfo.format = format_of_str (format) ;
+ if (sfinfo.format == 0)
+ { error ("Bad format '%s'", format.c_str ()) ;
+ return retval ;
+ } ;
+
+ sfinfo.samplerate = lrint (args (2).scalar_value ()) ;
+ if (sfinfo.samplerate < 1)
+ { error ("Bad sample rate : %d.\n", sfinfo.samplerate) ;
+ return retval ;
+ } ;
+
+ Matrix data = args (1).matrix_value () ;
+ long rows = args (1).rows () ;
+ long cols = args (1).columns () ;
+
+ if (cols > rows)
+ { error ("Audio data should have one column per channel, but supplied data "
+ "has %ld rows and %ld columns.\n", rows, cols) ;
+ return retval ;
+ } ;
+
+ sfinfo.channels = cols ;
+
+ if ((file = sf_open (filename.c_str (), SFM_WRITE, &sfinfo)) == NULL)
+ { error ("Couldn't open file %s : %s", filename.c_str (), sf_strerror (NULL)) ;
+ return retval ;
+ } ;
+
+ float buffer [BUFFER_FRAMES * sfinfo.channels] ;
+ int writecount ;
+ long total = 0 ;
+
+ do
+ {
+ writecount = BUFFER_FRAMES ;
+
+ /* Make sure we don't read more frames than we allocated. */
+ if (total + writecount > rows)
+ writecount = rows - total ;
+
+ for (int ch = 0 ; ch < sfinfo.channels ; ch++)
+ { for (int k = 0 ; k < writecount ; k++)
+ buffer [k * sfinfo.channels + ch] = data (total + k, ch) ;
+ } ;
+
+ if (writecount > 0)
+ sf_writef_float (file, buffer, writecount) ;
+
+ total += writecount ;
+ } while (writecount > 0 && total < rows) ;
+
+ /* Clean up. */
+ sf_close (file) ;
+
+ return retval ;
+} /* sfwrite */
+
+
+static void
+str_split (const std::string & str, const std::string & delim, std::vector <std::string> & output)
+{
+ unsigned int offset = 0 ;
+ size_t delim_index = 0 ;
+
+ delim_index = str.find (delim, offset) ;
+
+ while (delim_index != std::string::npos)
+ {
+ output.push_back (str.substr(offset, delim_index - offset)) ;
+ offset += delim_index - offset + delim.length () ;
+ delim_index = str.find (delim, offset) ;
+ }
+
+ output.push_back (str.substr (offset)) ;
+} /* str_split */
+
+static int
+hash_of_str (const std::string & str)
+{
+ int hash = 0 ;
+
+ for (unsigned k = 0 ; k < str.length () ; k++)
+ hash = (hash * 3) + tolower (str [k]) ;
+
+ return hash ;
+} /* hash_of_str */
+
+static int
+major_format_of_hash (const std::string & str)
+{ int hash ;
+
+ hash = hash_of_str (str) ;
+
+ switch (hash)
+ {
+ case 0x5c8 : /* 'wav' */ return SF_FORMAT_WAV ;
+ case 0xf84 : /* 'aiff' */ return SF_FORMAT_AIFF ;
+ case 0x198 : /* 'au' */ return SF_FORMAT_AU ;
+ case 0x579 : /* 'paf' */ return SF_FORMAT_PAF ;
+ case 0x5e5 : /* 'svx' */ return SF_FORMAT_SVX ;
+ case 0x1118 : /* 'nist' */ return SF_FORMAT_NIST ;
+ case 0x5d6 : /* 'voc' */ return SF_FORMAT_VOC ;
+ case 0x324a : /* 'ircam' */ return SF_FORMAT_IRCAM ;
+ case 0x505 : /* 'w64' */ return SF_FORMAT_W64 ;
+ case 0x1078 : /* 'mat4' */ return SF_FORMAT_MAT4 ;
+ case 0x1079 : /* 'mat5' */ return SF_FORMAT_MAT5 ;
+ case 0x5b8 : /* 'pvf' */ return SF_FORMAT_PVF ;
+ case 0x1d1 : /* 'xi' */ return SF_FORMAT_XI ;
+ case 0x56f : /* 'htk' */ return SF_FORMAT_HTK ;
+ case 0x5aa : /* 'sds' */ return SF_FORMAT_SDS ;
+ case 0x53d : /* 'avr' */ return SF_FORMAT_AVR ;
+ case 0x11d0 : /* 'wavx' */ return SF_FORMAT_WAVEX ;
+ case 0x569 : /* 'sd2' */ return SF_FORMAT_SD2 ;
+ case 0x1014 : /* 'flac' */ return SF_FORMAT_FLAC ;
+ case 0x504 : /* 'caf' */ return SF_FORMAT_CAF ;
+ case 0x5f6 : /* 'wve' */ return SF_FORMAT_WVE ;
+ default : break ;
+ } ;
+
+ printf ("%s : hash '%s' -> 0x%x\n", __func__, str.c_str (), hash) ;
+
+ return 0 ;
+} /* major_format_of_hash */
+
+static int
+minor_format_of_hash (const std::string & str)
+{ int hash ;
+
+ hash = hash_of_str (str) ;
+
+ switch (hash)
+ {
+ case 0x1085 : /* 'int8' */ return SF_FORMAT_PCM_S8 ;
+ case 0x358a : /* 'uint8' */ return SF_FORMAT_PCM_U8 ;
+ case 0x31b0 : /* 'int16' */ return SF_FORMAT_PCM_16 ;
+ case 0x31b1 : /* 'int24' */ return SF_FORMAT_PCM_24 ;
+ case 0x31b2 : /* 'int32' */ return SF_FORMAT_PCM_32 ;
+ case 0x3128 : /* 'float' */ return SF_FORMAT_FLOAT ;
+ case 0x937d : /* 'double' */ return SF_FORMAT_DOUBLE ;
+ case 0x11bd : /* 'ulaw' */ return SF_FORMAT_ULAW ;
+ case 0xfa1 : /* 'alaw' */ return SF_FORMAT_ALAW ;
+ case 0xfc361 : /* 'ima_adpcm' */ return SF_FORMAT_IMA_ADPCM ;
+ case 0x5739a : /* 'ms_adpcm' */ return SF_FORMAT_MS_ADPCM ;
+ case 0x9450 : /* 'gsm610' */ return SF_FORMAT_GSM610 ;
+ case 0x172a3 : /* 'g721_32' */ return SF_FORMAT_G721_32 ;
+ case 0x172d8 : /* 'g723_24' */ return SF_FORMAT_G723_24 ;
+ case 0x172da : /* 'g723_40' */ return SF_FORMAT_G723_40 ;
+ default : break ;
+ } ;
+
+ printf ("%s : hash '%s' -> 0x%x\n", __func__, str.c_str (), hash) ;
+
+ return 0 ;
+} /* minor_format_of_hash */
+
+
+static const char *
+string_of_major_format (int format)
+{
+ switch (format & SF_FORMAT_TYPEMASK)
+ {
+ case SF_FORMAT_WAV : return "wav" ;
+ case SF_FORMAT_AIFF : return "aiff" ;
+ case SF_FORMAT_AU : return "au" ;
+ case SF_FORMAT_PAF : return "paf" ;
+ case SF_FORMAT_SVX : return "svx" ;
+ case SF_FORMAT_NIST : return "nist" ;
+ case SF_FORMAT_VOC : return "voc" ;
+ case SF_FORMAT_IRCAM : return "ircam" ;
+ case SF_FORMAT_W64 : return "w64" ;
+ case SF_FORMAT_MAT4 : return "mat4" ;
+ case SF_FORMAT_MAT5 : return "mat5" ;
+ case SF_FORMAT_PVF : return "pvf" ;
+ case SF_FORMAT_XI : return "xi" ;
+ case SF_FORMAT_HTK : return "htk" ;
+ case SF_FORMAT_SDS : return "sds" ;
+ case SF_FORMAT_AVR : return "avr" ;
+ case SF_FORMAT_WAVEX : return "wavx" ;
+ case SF_FORMAT_SD2 : return "sd2" ;
+ case SF_FORMAT_FLAC : return "flac" ;
+ case SF_FORMAT_CAF : return "caf" ;
+ case SF_FORMAT_WVE : return "wfe" ;
+ default : break ;
+ } ;
+
+ return "unknown" ;
+} /* string_of_major_format */
+
+static const char *
+string_of_minor_format (int format)
+{
+ switch (format & SF_FORMAT_SUBMASK)
+ {
+ case SF_FORMAT_PCM_S8 : return "int8" ;
+ case SF_FORMAT_PCM_U8 : return "uint8" ;
+ case SF_FORMAT_PCM_16 : return "int16" ;
+ case SF_FORMAT_PCM_24 : return "int24" ;
+ case SF_FORMAT_PCM_32 : return "int32" ;
+ case SF_FORMAT_FLOAT : return "float" ;
+ case SF_FORMAT_DOUBLE : return "double" ;
+ case SF_FORMAT_ULAW : return "ulaw" ;
+ case SF_FORMAT_ALAW : return "alaw" ;
+ case SF_FORMAT_IMA_ADPCM : return "ima_adpcm" ;
+ case SF_FORMAT_MS_ADPCM : return "ms_adpcm" ;
+ case SF_FORMAT_GSM610 : return "gsm610" ;
+ case SF_FORMAT_G721_32 : return "g721_32" ;
+ case SF_FORMAT_G723_24 : return "g723_24" ;
+ case SF_FORMAT_G723_40 : return "g723_40" ;
+ default : break ;
+ } ;
+
+ return "unknown" ;
+} /* string_of_minor_format */
+
+static int
+format_of_str (const std::string & fmt)
+{
+ std::vector <std::string> split ;
+
+ str_split (fmt, "-", split) ;
+
+ if (split.size () != 2)
+ return 0 ;
+
+ int major_fmt = major_format_of_hash (split.at (0)) ;
+ if (major_fmt == 0)
+ return 0 ;
+
+ int minor_fmt = minor_format_of_hash (split.at (1)) ;
+ if (minor_fmt == 0)
+ return 0 ;
+
+ return major_fmt | minor_fmt ;
+} /* format_of_str */
+
+static void
+string_of_format (std::string & fmt, int format)
+{
+ char buffer [64] ;
+
+ snprintf (buffer, sizeof (buffer), "%s-%s", string_of_major_format (format), string_of_minor_format (format)) ;
+
+ fmt = buffer ;
+
+ return ;
+} /* string_of_format */
Modified: freeswitch/trunk/libs/libsndfile/Octave/sndfile_load.m
==============================================================================
--- freeswitch/trunk/libs/libsndfile/Octave/sndfile_load.m (original)
+++ freeswitch/trunk/libs/libsndfile/Octave/sndfile_load.m Thu May 21 16:09:30 2009
@@ -50,10 +50,3 @@
endif
endfunction
-
-# Do not edit or modify anything in this comment block.
-# The arch-tag line is a file identity tag for the GNU Arch
-# revision control system.
-#
-# arch-tag: 9d7ed7ce-41fe-4efe-8bde-f5fc6f46bb03
-
Modified: freeswitch/trunk/libs/libsndfile/Octave/sndfile_play.m
==============================================================================
--- freeswitch/trunk/libs/libsndfile/Octave/sndfile_play.m (original)
+++ freeswitch/trunk/libs/libsndfile/Octave/sndfile_play.m Thu May 21 16:09:30 2009
@@ -57,10 +57,3 @@
endif
endfunction
-
-# Do not edit or modify anything in this comment block.
-# The arch-tag line is a file identity tag for the GNU Arch
-# revision control system.
-#
-# arch-tag: 96fb14c8-2b5a-4b93-a576-ab83a6d9026b
-
Modified: freeswitch/trunk/libs/libsndfile/Octave/sndfile_save.m
==============================================================================
--- freeswitch/trunk/libs/libsndfile/Octave/sndfile_save.m (original)
+++ freeswitch/trunk/libs/libsndfile/Octave/sndfile_save.m Thu May 21 16:09:30 2009
@@ -51,10 +51,3 @@
eval (str) ;
endfunction
-
-# Do not edit or modify anything in this comment block.
-# The arch-tag line is a file identity tag for the GNU Arch
-# revision control system.
-#
-# arch-tag: 5e44602b-940b-4927-af7c-47639769a40b
-
Modified: freeswitch/trunk/libs/libsndfile/README
==============================================================================
--- freeswitch/trunk/libs/libsndfile/README (original)
+++ freeswitch/trunk/libs/libsndfile/README Thu May 21 16:09:30 2009
@@ -1,28 +1,19 @@
-This is libsndfile, 1.0.17
+This is libsndfile, 1.0.19
-libsndfile is a library of C routines for reading and writing
-files containing sampled audio data.
+libsndfile is a library of C routines for reading and writing
+files containing sampled audio data.
The src/ directory contains the source code for library itself.
The doc/ directory contains the libsndfile documentation.
The examples/ directory contains examples of how to write code using
-libsndfile. 'wav32_aiff24' converts a WAV file containing 32 bit floating
-point data into a 24 bit PCM AIFF file. 'sndfile2oct' dumps the audio
-data of a file in a human readable format. 'sfconvert' is the beginnings
-of a audio file format conversion utility. 'make_sine' generates a WAV
-file containing one cycle of a sine wave with 4096 sample points in
-32 bit floating point format. 'sfinfo' opens a sound file and prints
-out information about that file.
+libsndfile.
The tests/ directory contains programs which link against libsndfile
and test its functionality.
-The Win32/ directory contains files and documentation to allow libsndfile
-to compile under Win32 with the Microsoft Visual C++ compiler.
-
-The src/GSM610 directory contains code written by Jutta Degener and Carsten
+The src/GSM610 directory contains code written by Jutta Degener and Carsten
Bormann. Their original code can be found at :
http://kbs.cs.tu-berlin.de/~jutta/toast.html
@@ -30,41 +21,44 @@
under a suitably free license.
-Win32
+LINUX
-----
-There are detailed instructions for building libsndfile on Win32 in the file
-
- doc/win32.html
-
+Whereever possible, you should use the packages supplied by your Linux
+distribution.
-MacOSX
-------
-Building on MacOSX should be the same as building it on any other Unix.
+If you really do need to compile from source it should be as easy as:
-
-OTHER PLATFORMS
----------------
-To compile libsndfile on platforms which have a Bourne Shell compatible
-shell, an ANSI C compiler and a make utility should require no more that
-the following three commands :
./configure
make
make install
-
-For platforms without the required shell, it is usually sufficient to
-create an approriate config.h file in the src/ directory with correct
-values for the following #defines (this would work for AmigaOS) :
-
-#define HAVE_ENDIAN_H 0
-#define GUESS_BIG_ENDIAN 1
-#define GUESS_LITTLE_ENDIAN 0
-#define FORCE_BROKEN_FLOAT 0
+
+Since libsndfile optionally links against libFLAC, libogg and libvorbis, you
+will need to install appropriate versions of these libraries before running
+configure as above.
+
+
+UNIX
+----
+Compile as for Linux.
+
+
+Win32/Win64
+-----------
+The default Windows compilers are nowhere near compliant with the 1999 ISO
+C Standard and hence not able to compile libsndfile.
+
+Please use the libsndfile binaries available on the libsndfile web site.
+
+
+MacOSX
+------
+Building on MacOSX should be the same as building it on any other Unix.
CONTACTS
--------
-libsndfile was written by Erik de Castro Lopo (erikd AT mega-nerd DOT com).
+libsndfile was written by Erik de Castro Lopo (erikd AT mega-nerd DOT com).
The libsndfile home page is at :
http://www.mega-nerd.com/libsndfile/
Modified: freeswitch/trunk/libs/libsndfile/Win32/Makefile.am
==============================================================================
--- freeswitch/trunk/libs/libsndfile/Win32/Makefile.am (original)
+++ freeswitch/trunk/libs/libsndfile/Win32/Makefile.am Thu May 21 16:09:30 2009
@@ -2,9 +2,3 @@
EXTRA_DIST = README-precompiled-dll.txt testprog.c
-## Do not edit or modify anything in this comment block.
-## The arch-tag line is a file identity tag for the GNU Arch
-## revision control system.
-##
-## arch-tag: c28c7540-67f6-47e7-8035-0abbc6a174bc
-
Modified: freeswitch/trunk/libs/libsndfile/Win32/testprog.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/Win32/testprog.c (original)
+++ freeswitch/trunk/libs/libsndfile/Win32/testprog.c Thu May 21 16:09:30 2009
@@ -14,11 +14,3 @@
return 0 ;
}
-
-/*
-** Do not edit or modify anything in this comment block.
-** The following line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: 31165fd8-9d91-4e5d-8b31-8efd42ef7645
-*/
Modified: freeswitch/trunk/libs/libsndfile/configure.ac
==============================================================================
--- freeswitch/trunk/libs/libsndfile/configure.ac (original)
+++ freeswitch/trunk/libs/libsndfile/configure.ac Thu May 21 16:09:30 2009
@@ -1,15 +1,24 @@
-# Copyright (C) 1999-2006 Erik de Castro Lopo (erikd AT mega-nerd DOT com).
+# Copyright (C) 1999-2008 Erik de Castro Lopo (erikd AT mega-nerd DOT com).
dnl Require autoconf version
-AC_PREREQ(2.59)
+AC_PREREQ(2.57)
+
+AC_INIT([libsndfile],[1.0.19],[erikd at mega-nerd.com])
+
+# Put config stuff in Cfg.
+AC_CONFIG_AUX_DIR(Cfg)
-AC_INIT([libsndfile],[1.0.17],[erikd at mega-nerd.com])
AC_CONFIG_SRCDIR([src/sndfile.c])
AC_CANONICAL_TARGET([])
AM_INIT_AUTOMAKE
+AC_CONFIG_MACRO_DIR([M4])
+
AC_CONFIG_HEADERS([src/config.h])
+dnl Add parameters for aclocal
+AC_SUBST(ACLOCAL_AMFLAGS, "-I M4")
+
AC_LANG([C])
#------------------------------------------------------------------------------------
@@ -28,14 +37,19 @@
# 6. If any interfaces have been removed since the last public release, then set age
# to 0.
-SHARED_VERSION_INFO="1:17:0"
+SHARED_VERSION_INFO="1:19:0"
AC_PROG_CC
AM_PROG_CC_C_O
AC_PROG_CXX
+
+# Do not check for F77.
+define([AC_LIBTOOL_LANG_F77_CONFIG], [:])dnl
+
AM_PROG_LIBTOOL
-AC_CHECK_PROG(autogen, autogen, yes, no)
+AC_CHECK_PROG(HAVE_AUTOGEN, autogen, yes, no)
+AC_CHECK_PROG(HAVE_WINE, wine, yes, no)
AC_PROG_INSTALL
AC_PROG_LN_S
@@ -45,7 +59,7 @@
AC_CHECK_HEADERS(endian.h)
AC_CHECK_HEADERS(byteswap.h)
AC_CHECK_HEADERS(locale.h)
-AC_CHECK_HEADERS(inttypes.h)
+AC_CHECK_HEADERS(sys/time.h)
AC_HEADER_SYS_WAIT
@@ -56,6 +70,9 @@
AC_DEFINE_UNQUOTED([HAVE_DECL_S_IRGRP],0)
fi
+AM_CONDITIONAL([LINUX_MINGW_CROSS_TEST],
+ [test "$build_os:$target_os:$host_os:$HAVE_WINE" = "linux-gnu:mingw32msvc:mingw32msvc:yes"])
+
#====================================================================================
# Check for support of the struct hack.
@@ -104,12 +121,19 @@
AC_ARG_ENABLE(sqlite,
AC_HELP_STRING([--disable-sqlite], [disable use of sqlite]))
-AC_ARG_ENABLE(flac,
- AC_HELP_STRING([--disable-flac], [disable use of FLAC]))
-
AC_ARG_ENABLE(alsa,
AC_HELP_STRING([--disable-alsa], [disable use of ALSA]))
+AC_ARG_ENABLE(external-libs,
+ AC_HELP_STRING([--disable-external-libs], [disable use of FLAC, Ogg and Vorbis]))
+
+AC_ARG_ENABLE(octave,
+ AC_HELP_STRING([--enable-octave], [disable building of GNU Octave module]))
+
+AC_ARG_ENABLE(test-coverage,
+ AC_HELP_STRING([--enable-test-coverage], [enable test coverage]))
+AM_CONDITIONAL([ENABLE_TEST_COVERAGE], [test "$enable_test_coverage" = yes])
+
#====================================================================================
# Check types and their sizes.
@@ -223,6 +247,8 @@
[Target processor is big endian.])
AC_DEFINE_UNQUOTED(CPU_IS_LITTLE_ENDIAN, ${ac_cv_c_little_endian},
[Target processor is little endian.])
+AC_DEFINE_UNQUOTED(WORDS_BIGENDIAN, ${ac_cv_c_big_endian},
+ [Target processor is big endian.])
#====================================================================================
# Check for functions.
@@ -231,36 +257,78 @@
AC_CHECK_FUNCS(open read write lseek pread pwrite)
AC_CHECK_FUNCS(fstat ftruncate fsync)
AC_CHECK_FUNCS(snprintf vsnprintf)
-AC_CHECK_FUNCS(gmtime gmtime_r)
+AC_CHECK_FUNCS(gmtime gmtime_r localtime localtime_r gettimeofday)
AC_CHECK_FUNCS(mmap getpagesize)
AC_CHECK_FUNCS(setlocale)
AC_CHECK_LIB([m],floor)
AC_CHECK_FUNCS(floor ceil fmod)
-case "$host_os" in
- cygwin*)
- AC_MSG_WARN([[Not using built-in lrint() and lrintf() because they are broken on Cygwin.]])
- ;;
- *)
- AC_C99_FUNC_LRINT
- AC_C99_FUNC_LRINTF
+AC_C99_FUNC_LRINT
+AC_C99_FUNC_LRINTF
- if test "x$ac_cv_c99_lrint" = "xno" ; then
- if test "x$ac_cv_c99_lrintf" = "xno" ; then
- AC_MSG_WARN([[*** Missing C99 standard functions lrint() and lrintf().]])
- AC_MSG_WARN([[*** This may cause benign compiler warnings on some systems (ie Solaris).]])
- fi
- fi
- ;;
- esac
+#====================================================================================
+# Check for requirements for building plugins for other languages/enviroments.
+
+dnl Octave maths environment http://www.octave.org/
+if test x$cross_compiling = xno ; then
+ if test x$enable_octave = xno ; then
+ AM_CONDITIONAL(BUILD_OCTAVE_MOD, false)
+ else
+ AC_OCTAVE_BUILD
+ fi
+else
+ AM_CONDITIONAL(BUILD_OCTAVE_MOD, false)
+ fi
+
+#====================================================================================
+# Check for Ogg, Vorbis and FLAC.
+
+HAVE_EXTERNAL_LIBS=0
+EXTERNAL_CFLAGS=""
+EXTERNAL_LIBS=""
+
+# Check for pkg-config outside the if statement.
+PKG_PROG_PKG_CONFIG
+
+if test x$enable_external_libs = xno ; then
+ AC_MSG_WARN([[*** External libs (FLAC, Ogg, Vorbis) disabled. ***]])
+else
+ PKG_CHECK_MOD_VERSION(FLAC, flac >= 1.2.1, ac_cv_flac=yes, ac_cv_flac=no)
+ PKG_CHECK_MOD_VERSION(OGG, ogg >= 1.1.3, ac_cv_ogg=yes, ac_cv_ogg=no)
+
+ # Vorbis versions earlier than 1.2.1 are not const correct at the API level.
+ # Vorbis 1.2.2 adds vorbis_version_string.
+ PKG_CHECK_MOD_VERSION(VORBIS, vorbis >= 1.2.0, ac_cv_vorbis=yes, ac_cv_vorbis=no)
+ PKG_CHECK_MOD_VERSION(VORBISENC, vorbisenc >= 1.2.0, ac_cv_vorbisenc=yes, ac_cv_vorbisenc=no)
+ fi
+
+HAVE_VORBIS_VERSION_STRING=0
+if test x$ac_cv_flac$ac_cv_ogg$ac_cv_vorbis$ac_cv_vorbisenc = "xyesyesyesyes" ; then
+
+ save_LIBS="$LIBS"
+ LIBS="$VORBIS_LIBS $LIBS"
+ AC_CHECK_LIB(vorbis, vorbis_version_string, HAVE_VORBIS_VERSION_STRING=1)
+ LIBS="$save_LIBS"
+
+ HAVE_EXTERNAL_LIBS=1
+ enable_external_libs=yes
+
+ EXTERNAL_CFLAGS="$FLAC_CFLAGS $OGG_CFLAGS $VORBISENC_CFLAGS"
+ EXTERNAL_LIBS="$FLAC_LIBS $VORBISENC_LIBS"
+else
+ enable_external_libs=no
+ fi
+
+AC_DEFINE_UNQUOTED([HAVE_EXTERNAL_LIBS], $HAVE_EXTERNAL_LIBS, [Will be set to 1 if flac, ogg and vorbis are available.])
+AC_DEFINE_UNQUOTED([HAVE_VORBIS_VERSION_STRING], $HAVE_VORBIS_VERSION_STRING, [Set to 1 if we have vorbis_version_string.])
#====================================================================================
# Check for libsqlite3 (only used in regtest).
ac_cv_sqlite3=no
if test x$enable_sqlite != xno ; then
- PKG_CHECK_MODULES(SQLITE3, sqlite3 >= 3.2, ac_cv_sqlite3=yes, ac_cv_sqlite3=no)
+ PKG_CHECK_MOD_VERSION(SQLITE3, sqlite3 >= 3.2, ac_cv_sqlite3=yes, ac_cv_sqlite3=no)
fi
if test x$ac_cv_sqlite3 = "xyes" ; then
@@ -272,6 +340,19 @@
AC_DEFINE_UNQUOTED([HAVE_SQLITE3],$HAVE_SQLITE3,[Set to 1 if you have libsqlite3.])
#====================================================================================
+# Check for JACK (only used for examples/sndfile-jackplay).
+
+PKG_CHECK_MOD_VERSION(JACK, jack >= 0.100, ac_cv_jack=yes, ac_cv_jack=no)
+
+if test x$ac_cv_jack = "xyes" ; then
+ HAVE_JACK=1
+else
+ HAVE_JACK=0
+ fi
+
+AC_DEFINE_UNQUOTED([HAVE_JACK],$HAVE_JACK,[Set to 1 if you have JACK.])
+
+#====================================================================================
# Determine if the processor can do clipping on float to int conversions.
if test x$enable_cpu_clip != "xno" ; then
@@ -307,10 +388,6 @@
use_windows_api=1
OS_SPECIFIC_LINKS="-lwinmm"
;;
- cygwin*)
- os_is_win32=1
- OS_SPECIFIC_LINKS="-lwinmm"
- ;;
esac
AC_DEFINE_UNQUOTED(OS_IS_WIN32, ${os_is_win32}, [Set to 1 if compiling for Win32])
@@ -326,22 +403,7 @@
AC_CHECK_HEADERS(alsa/asoundlib.h)
if test x$ac_cv_header_alsa_asoundlib_h = xyes ; then
ALSA_LIBS="-lasound"
- fi
- fi
-
-#====================================================================================
-# Check for FLAC
-
-FLAC_LIBS=""
-
-if test x$enable_flac != xno ; then
- AC_CHECK_HEADERS(FLAC/all.h)
- if test x$ac_cv_header_FLAC_all_h = xyes ; then
- AC_CHECK_LIB(FLAC, FLAC__seekable_stream_encoder_set_tell_callback, HAVE_FLAC_1_1_1="yes")
- if test "x$HAVE_FLAC_1_1_1" = xyes ; then
- AC_DEFINE(HAVE_FLAC_1_1_1, [1], [Define to 1 if you have libflac 1.1.1])
- fi
- FLAC_LIBS="-lFLAC"
+ enable_alsa=yes
fi
fi
@@ -380,7 +442,7 @@
AC_MSG_WARN([[******************************************************************]])
fi
-if test x"$ac_cv_prog_autogen" = "xno" ; then
+if test x"$ac_cv_prog_HAVE_AUTOGEN" = "xno" ; then
AC_MSG_WARN([[Touching files in directory tests/.]])
touch tests/*.c tests/*.h
fi
@@ -407,20 +469,47 @@
#====================================================================================
# Now use the information from the checking stage.
+win32_target_dll=0
+COMPILER_IS_GCC=0
+
if test x$ac_cv_c_compiler_gnu = xyes ; then
AC_ADD_CFLAGS(-std=gnu99)
- CFLAGS="$CFLAGS -W -Wall"
- CXXFLAGS="$CXXFLAGS -W -Wall"
+ AC_GCC_VERSION
+
+ if test "x$GCC_MAJOR_VERSION$GCC_MINOR_VERSION" = "x42" ; then
+ AC_MSG_WARN([****************************************************************])
+ AC_MSG_WARN([** GCC version 4.2 warns about the inline keyword for no good **])
+ AC_MSG_WARN([** reason but the maintainers do not see it as a bug. **])
+ AC_MSG_WARN([** See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33995 **])
+ AC_MSG_WARN([** Using -fgnu-inline to avoid this stupidity. **])
+ AC_MSG_WARN([****************************************************************])
+ AC_ADD_CFLAGS([-fgnu89-inline])
+ fi
+
+ CFLAGS="$CFLAGS -Wall"
+ CXXFLAGS="$CXXFLAGS -Wall"
+
+ AC_ADD_CFLAGS([-Wextra])
- AC_ADD_CFLAGS(-Wdeclaration-after-statement)
- AC_ADD_CFLAGS(-Wpointer-arith)
+ AC_LANG_PUSH([C++])
+ AC_ADD_CXXFLAGS([-Wextra])
+ AC_LANG_POP([C++])
+
+ AC_ADD_CFLAGS([-Wdeclaration-after-statement])
+ AC_ADD_CFLAGS([-Wpointer-arith])
+ AC_ADD_CFLAGS([-funsigned-char])
if test x$enable_gcc_werror = "xyes" ; then
CFLAGS="-Werror $CFLAGS"
CXXFLAGS="-Werror $CXXFLAGS"
fi
+ if test x$enable_test_coverage = "xyes" ; then
+ # AC_ADD_CFLAGS([-ftest-coverage])
+ AC_ADD_CFLAGS([-coverage])
+ fi
+
CFLAGS="$CFLAGS -Wstrict-prototypes -Wmissing-prototypes -Waggregate-return -Wcast-align -Wcast-qual -Wnested-externs -Wshadow -Wbad-function-cast -Wwrite-strings "
# -Wundef -Wmissing-declarations -Winline -Wconversion"
CXXFLAGS="$CXXFLAGS -Wcast-align -Wcast-qual -Wshadow -Wwrite-strings -Wctor-dtor-privacy -Wnon-virtual-dtor -Woverloaded-virtual -Wreorder -Wsign-promo "
@@ -444,10 +533,16 @@
SHLIB_VERSION_ARG="-Wl,--version-script=\$(srcdir)/Symbols.linux"
;;
mingw*)
- SHLIB_VERSION_ARG="-Wl,\$(srcdir)/libsndfile.def"
+ # Linker flag '-Wl,--out-implib' does not work with mingw cross compiler
+ # so we don't use it here.
+ SHLIB_VERSION_ARG="-Wl,\$(srcdir)/libsndfile-1.def"
+ win32_target_dll=1
+ if test x"$enable_shared" = xno ; then
+ win32_target_dll=0
+ fi
;;
- cygwin*)
- SHLIB_VERSION_ARG="-Wl,\$(srcdir)/cygsndfile.def"
+ os2*)
+ SHLIB_VERSION_ARG="-Wl,-export-symbols \$(srcdir)/Symbols.os2"
;;
*)
;;
@@ -456,11 +551,11 @@
CFLAGS="$CFLAGS -pipe"
fi
- AC_DEFINE([COMPILER_IS_GCC],1, [Set to 1 if the compile is GNU GCC.])
- GCC_MAJOR_VERSION=`$CC -dumpversion | sed "s/\..*//"`
- AC_DEFINE_UNQUOTED([GCC_MAJOR_VERSION],${GCC_MAJOR_VERSION}, [Major version of GCC or 3 otherwise.])
+ COMPILER_IS_GCC=1
fi
+AC_DEFINE_UNQUOTED([WIN32_TARGET_DLL], ${win32_target_dll}, [Set to 1 if windows DLL is being built.])
+AC_DEFINE_UNQUOTED([COMPILER_IS_GCC], ${COMPILER_IS_GCC}, [Set to 1 if the compile is GNU GCC.])
AC_DEFUN([AX_COMPILER_VENDOR],
[
AC_CACHE_CHECK([for _AC_LANG compiler vendor], ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor,
@@ -497,6 +592,8 @@
exit
fi
+#-------------------------------------------------------------------------------
+
AC_SUBST(htmldocdir)
AC_SUBST(HTML_BGCOLOUR)
AC_SUBST(HTML_FGCOLOUR)
@@ -506,25 +603,33 @@
AC_SUBST(OS_SPECIFIC_CFLAGS)
AC_SUBST(OS_SPECIFIC_LINKS)
AC_SUBST(ALSA_LIBS)
-AC_SUBST(FLAC_LIBS)
AC_SUBST(ENABLE_EXPERIMENTAL_CODE)
+AC_SUBST(EXTERNAL_CFLAGS)
+AC_SUBST(EXTERNAL_LIBS)
+
AC_SUBST(COMPILER_IS_GCC)
AC_SUBST(GCC_MAJOR_VERSION)
+AC_SUBST(HAVE_JACK)
+
dnl The following line causes the libtool distributed with the source
dnl to be replaced if the build system has a more recent version.
AC_SUBST(LIBTOOL_DEPS)
AC_CONFIG_FILES([ \
- src/sndfile.h src/Makefile src/GSM610/Makefile src/G72x/Makefile \
- man/Makefile examples/Makefile tests/Makefile regtest/Makefile \
- doc/Makefile doc/libsndfile.css \
- Win32/Makefile Octave/Makefile \
- Makefile libsndfile.spec sndfile.pc \
- ])
+ src/sndfile.h src/Makefile src/GSM610/Makefile src/G72x/Makefile \
+ man/Makefile examples/Makefile tests/Makefile regtest/Makefile \
+ M4/Makefile doc/Makefile Win32/Makefile Octave/Makefile \
+ programs/Makefile doc/libsndfile.css \
+ Makefile libsndfile.spec sndfile.pc \
+ tests/test_wrapper.sh \
+ ])
AC_OUTPUT
+# Make it executable.
+chmod u+x tests/test_wrapper.sh
+
#====================================================================================
AC_MSG_RESULT([
@@ -532,18 +637,21 @@
Configuration summary :
- Version : ..................... ${VERSION}
- Experimental code : ........... ${enable_experimental:-no}
+ Version : ............................. ${VERSION}
+ Experimental code : ................... ${enable_experimental:-no}
+ Using ALSA in example programs : ...... ${enable_alsa:-no}
+ External FLAC/Ogg/Vorbis : ............ ${enable_external_libs:-no}
+
])
if test x$ac_cv_c_compiler_gnu = xyes ; then
echo -e " Tools :\n"
- echo " Compiler is GCC : ............. ${ac_cv_c_compiler_gnu}"
- echo " GCC major version : ........... ${GCC_MAJOR_VERSION}"
+ echo " Compiler is GCC : ..................... ${ac_cv_c_compiler_gnu}"
+ echo " GCC version : ......................... ${GCC_VERSION}"
if test $GCC_MAJOR_VERSION -lt 3 ; then
echo -e "\n ** This compiler version allows applications to write"
echo " ** to static strings within the library."
- echo " ** Compile with GCC version 3.X to avoid this problem."
+ echo " ** Compile with GCC version 3.X or above to avoid this problem."
fi
fi
@@ -558,10 +666,10 @@
AC_MSG_RESULT([[
Installation directories :
- Library directory : ........... $libdir
- Program directory : ........... $bindir
- Pkgconfig directory : ......... $libdir/pkgconfig
- HTML docs directory : ......... $htmldocdir
+ Library directory : ................... $libdir
+ Program directory : ................... $bindir
+ Pkgconfig directory : ................. $libdir/pkgconfig
+ HTML docs directory : ................. $htmldocdir
]])
if test x$prefix != "x/usr" ; then
@@ -570,14 +678,5 @@
echo -e "PKG_CONFIG_PATH environment variable.\n"
fi
-#====================================================================================
-
-ifelse(dnl
-
- Do not edit or modify anything in this comment block.
- The arch-tag line is a file identity tag for the GNU Arch
- revision control system.
-
- arch-tag: 6391b316-6cfc-43c2-a18a-8defdc4ee359
-
-)dnl
+(cd src && make genfiles)
+(cd tests && make genfiles)
Modified: freeswitch/trunk/libs/libsndfile/configure.gnu
==============================================================================
--- freeswitch/trunk/libs/libsndfile/configure.gnu (original)
+++ freeswitch/trunk/libs/libsndfile/configure.gnu Thu May 21 16:09:30 2009
@@ -1,3 +1,3 @@
-#! /bin/sh
-./configure "$@" --disable-sqlite --disable-shared --with-pic --disable-flac
-
+#! /bin/sh
+./configure "$@" --disable-sqlite --disable-shared --with-pic --disable-external-libs --disable-octave
+
Modified: freeswitch/trunk/libs/libsndfile/doc/FAQ.html
==============================================================================
--- freeswitch/trunk/libs/libsndfile/doc/FAQ.html (original)
+++ freeswitch/trunk/libs/libsndfile/doc/FAQ.html Thu May 21 16:09:30 2009
@@ -23,7 +23,7 @@
substitution" error during linking. What can I do to fix this?</A><BR>
<A HREF="#Q005">Q5 : Why doesn't libsndfile do interleaving/de-interleaving?</A><BR>
<A HREF="#Q006">Q6 : What's the best format for storing temporary files?</A><BR>
-<A HREF="#Q007">Q7 : On Linux/Unix/MaxOSX, what's the best way of detecting the
+<A HREF="#Q007">Q7 : On Linux/Unix/MacOSX, what's the best way of detecting the
presence of libsndfile?</A><BR>
<A HREF="#Q008">Q8 : But I just want a simple Makefile! What do I do?</A><BR>
<A HREF="#Q009">Q9 : How about adding the ability to write/read sound files to/from
@@ -43,6 +43,19 @@
</A><BR>
<A HREF="#Q017">Q17 : Can libsndfile read/write files from/to UNIX pipes?
</A><BR>
+<A HREF="#Q018">Q18 : Is it possible to build a Universal Binary on Mac OSX?
+ </A><BR>
+<A HREF="#Q019">Q19 : I have project files for Visual Studio / XCode / Whatever. Why
+ don't you distribute them with libsndfile?
+ </A><BR>
+<A HREF="#Q020">Q20 : Why doesn't libsndfile support MP3? Lots of other Open Source
+ projects support it!
+ </A><BR>
+<A HREF="#Q021">Q21 : How do I use libsndfile in a closed source or commercial program
+ and comply with the license?
+ </A><BR>
+<A HREF="#Q022">Q22 : What versions of windows does libsndfile work on?
+ </A><BR>
<HR>
<!-- ========================================================================= -->
@@ -89,9 +102,12 @@
<A NAME="Q003"></A>
<H2><BR><B>Q3 : Compiling is really slow on MacOSX. Why?</B></H2>
<P>
-When you configure and compile libsndfile, it uses the Bourne shell for a number
+When you configure and compile libsndfile, it uses the /bin/sh shell for a number
of tasks (ie configure script and libtool).
-However, Apple has decided to ship their system with a really crappy Bourne shell.
+Older versions of OSX (10.2?) shipped a a really crappy Bourne shell as /bin/sh
+which resulted in <b>really</b> slow compiles.
+New version of OSX ship GNU BASh as /bin/sh and this answer doesn't apply in that
+case.
</P>
<P>
To fix this I suggest that you install the GNU Bash shell, rename /bin/sh to
@@ -313,8 +329,18 @@
in audio quality that they should also be concerned about.
</P>
<P>
-The correct way to deal with this problem is to consider 16 bit short data as
-a final destination format only, not as an intermediate storage format.
+Since this problem only occurs when converting between integer data on disk and
+normalized floats in the application, it can be avoided by using something
+other than normalized floats in the application.
+Alternatives to normalized floats are the <b>short</b> and <b>int</b> data
+types (ie using sf_read_short or sf_read_int) or using un-normalized floats
+(see
+ <a href="http://www.mega-nerd.com/libsndfile/command.html#SFC_SET_NORM_FLOAT">
+ SFC_SET_NORM_FLOAT</a>).
+</P>
+<P>
+Another way to deal with this problem is to consider 16 bit short data as a
+final destination format only, not as an intermediate storage format.
All intermediate data (ie which is going to be processed further) should be
stored in floating point format which is supported by all of the most common
file formats.
@@ -552,26 +578,213 @@
</P>
<P>
-Sell also <A HREF="#Q006">FAQ Q6</A>.
+See also <A HREF="#Q006">FAQ Q6</A>.
+</P>
+
+<!-- ========================================================================= -->
+<A NAME="Q018"></A>
+<H2><BR><B>Q18 : Is it possible to build a Universal Binary on Mac OSX?
+</B></H2>
+
+<P>
+Yes, but you must do two separate configure/build/test runs; one on PowerPC
+and one on Intel.
+It is then possible to merge the binaries into a single universal binary using
+one of the programs in the Apple tool chain.
+</P>
+
+<P>
+It is <b>not</b> possible to build a working universal binary via a single
+compile/build run on a single CPU.
+</P>
+
+<P>
+The problem is that the libsndfile build process detects features of the CPU its
+being built for during the configure process and when building a universal binary,
+configure is only run once and that data is then used for both CPUs.
+That configure data will be wrong for one of those CPUs.
+You will still be able to compile libsndfile, and the test suite will pass on
+the machine you compiled it on.
+However, if you take the universal binary test suite programs compiled on one
+CPU and run them on the other, the test suite will fail.
+</P>
+
+<P>
+Part of the problem is the the CPU endian-ness is detected at configure time.
+Yes, I know the Apple compiler defines one of the macros __LITTLE_ENDIAN__
+and __BIG_ENDIAN__, but those macros are not part of the 1999 ISO C Standard
+and they are not portable.
+</P>
+
+<P>
+Endian issues are not the only reason why the cross compiled binary will fail.
+The configure script also detects other CPU specific idiosyncrasies to provide
+more optimized code.
+</P>
+
+<P>
+Finally, the real show stopper problem with universal binaries is the problem
+with the test suite.
+libsndfile contains a huge, comprehensive test suite.
+When you compile a universal binary and run the test suite, you only test the
+native compile.
+The cross compiled binary (the one with the much higher chance of having
+problems) cannot be tested.
+</P>
+
+<P>
+Now, if you have read this far you're probably thinking there must be a way
+to fix this and there probably is.
+The problem is that its a hell of a lot of work and would require significant
+changes to the configure process, the internal code and the test suite.
+In addition, these changes must not break compilation on any of the platforms
+libsndfile is currently working on.
+</p>
+
+
+<!-- ========================================================================= -->
+<A NAME="Q019"></A>
+<H2><BR><B>Q19 : I have project files for Visual Studio / XCode / Whatever. Why
+ don't you distribute them with libsndfile?
+</B></H2>
+
+<P>
+There's a very good reason for this.
+I will only distribute things that I actually have an ability to test and
+maintain.
+Project files for a bunch of different compilers and Integrated Development
+Environments are simply too difficult to maintain.
+</P>
+
+<P>
+The problem is that every time I add a new file to libsndfile or rename an
+existing file I would have to modify all the project files and then test that
+libsndfile still built with all the different compilers.
+</P>
+
+<P>
+Maintaining these project files is also rather difficult if I don't have access
+to the required compiler/IDE.
+If I just edit the project files without testing them I will almost certainly
+get it wrong.
+If I release a version of libsndfile with broken project files, I'll get a bunch
+of emails from people complaining about it not building and have no way of
+fixing or even testing it.
+</P>
+
+<P>
+I currently release sources that I personally test on Win32, Linux and
+MacOSX (PowerPC) using the compiler I trust (GNU GCC).
+Supporting one compiler on three (actually much more because GCC is available
+almost everywhere) platforms is doable without too much pain.
+I also release binaries for Win32 with instructions on how to use those
+binaries with Visual Studio.
+As a guy who is mainly interested in Linux, I'm not to keen to jump through
+a bunch of hoops to support compilers and operating systems I don't use.
+</P>
+
+<P>
+So, I hear you want to volunteer to maintain the project files for Some Crappy
+Compiler 2007?
+Well sorry, that won't work either.
+I have had numerous people over the years offer to maintaining the project
+files for Microsoft's Visual Studio.
+Every single time that happened, they maintained it for a release or two and
+then disappeared off the face of the earth.
+Hence, I'm not willing to enter into an arrangement like that again.
</P>
<!-- ========================================================================= -->
+<A NAME="Q020"></A>
+<H2><BR><B>Q20 : Why doesn't libsndfile support MP3? Lots of other Open Source
+ projects support it!
+</B></H2>
+
+<P>
+MP3 is not supported for one very good reason; doing so requires the payment
+of licensing fees.
+As can be seen from
+ <a href="http://www.mp3licensing.com/royalty/software.html">
+ mp3licensing.com</a>
+the required royalty payments are not cheap.
+</P>
+
+<p>
+Yes, I know other libraries ignore the licensing requirements, but their legal
+status is extremely dubious.
+At any time, the body selling the licenses could go after the authors of those
+libraries.
+Some of those authors may be students and hence wouldn't be worth pursuing.
+</P>
+
+<p>
+However, libsndfile is released under the name of a company, Mega Nerd Pty Ltd;
+a company which has income from from libsamplerate licensing, libsndfile based
+consulting income and other unrelated consulting income.
+Adding MP3 support to libsndfile could place that income would be under legal
+threat.
+</p>
+
+<p>
+Fortunately, Ogg Vorbis exists as an alternative to MP3.
+Support for Ogg Vorbis was added to libsndfile (mostly due to the efforts of
+John ffitch of the Csound project) in version 1.0.18.
+</p>
+
+
+<!-- ========================================================================= -->
+<A NAME="Q021"></A>
+<H2><BR><B>Q21 : How do I use libsndfile in a closed source or commercial program
+ and comply with the license?
+</B></H2>
+
+<p>
+Here is a checklist of things you need to do to make sure your use of libsndfile
+in a closed source or commercial project complies with the license libsndfile is
+released under, the GNU Lesser General Public License (LGPL):
+</p>
+
+<ul>
+<li>Make sure you are linking to libsndfile as a shared library (Linux and Unix
+ systems), Dynamic Link Library (Microsoft Windows) or dynlib (Mac OSX).
+ If you are using some other operating system that doesn't allow dynamically
+ linked libraries, you will not be able to use libsndfile unless you release
+ the source code to your program.
+<li>In the licensing documentation for your program, add a statement that your
+ software depends on libsndfile and that libsndfile is released under the GNU
+ Lesser General Public License, either
+ <a href="http://www.gnu.org/licenses/lgpl-2.1.txt">version 2.1</a>
+ or optionally
+ <a href="http://www.gnu.org/licenses/lgpl.txt">version 3</a>.
+<li>Include the text for both versions of the license, possibly as separate
+ files named libsndfile_lgpl_v2_1.txt and libsndfile_lgpl_v3.txt.
+</ul>
+
+<!-- ========================================================================= -->
+<A NAME="Q022"></A>
+<H2><BR><B>Q22 : What versions of windows does libsndfile work on?
+</B></H2>
+
+<p>
+Currently the precompiled windows binaries are tested in Windows XP.
+As such, they should also work on Win2k and Windows Vista.
+They may also work on earlier versions of windows.
+</p>
+
+<p>
+libsndfile does not yet work on 64 bit versions of windows.
+Support for 64 bit versions of WinXP and Vista is likely to be working some
+time late in 2008.
+</p>
+<!-- ========================================================================= -->
<HR>
<P>
The libsndfile home page is here :
<A HREF="http://www.mega-nerd.com/libsndfile/">
http://www.mega-nerd.com/libsndfile/</A>.
<BR>
-Version : 1.0.13
+Version : 1.0.19
</P>
</BODY>
</HTML>
-
-<!--
- Do not edit or modify anything in this comment block.
- The arch-tag line is a file identity tag for the GNU Arch
- revision control system.
-
- arch-tag: 508f827d-b9a7-4a86-8c2f-d82321df91f7
--->
Modified: freeswitch/trunk/libs/libsndfile/doc/Makefile.am
==============================================================================
--- freeswitch/trunk/libs/libsndfile/doc/Makefile.am (original)
+++ freeswitch/trunk/libs/libsndfile/doc/Makefile.am Thu May 21 16:09:30 2009
@@ -4,13 +4,7 @@
html_DATA = index.html libsndfile.jpg libsndfile.css api.html command.html \
bugs.html sndfile_info.html new_file_type.HOWTO pkgconfig.html \
win32.html FAQ.html lists.html embedded_files.html octave.html \
- dither.html
+ dither.html tutorial.html
EXTRA_DIST = $(html_DATA)
-## Do not edit or modify anything in this comment block.
-## The arch-tag line is a file identity tag for the GNU Arch
-## revision control system.
-##
-## arch-tag: 2f7e97fe-5ef8-49a1-ae12-14ebab69c048
-
Modified: freeswitch/trunk/libs/libsndfile/doc/api.html
==============================================================================
--- freeswitch/trunk/libs/libsndfile/doc/api.html (original)
+++ freeswitch/trunk/libs/libsndfile/doc/api.html Thu May 21 16:09:30 2009
@@ -62,7 +62,7 @@
sf_count_t <A HREF="#seek">sf_seek</A> (SNDFILE *sndfile, sf_count_t frames, int whence) ;
- int <A HREF="#command">sf_command</A> (SNDFILE *sndfile, int cmd, void *data, int datasize) ;
+ int <A HREF="command.html">sf_command</A> (SNDFILE *sndfile, int cmd, void *data, int datasize) ;
int <A HREF="#error">sf_error</A> (SNDFILE *sndfile) ;
const char* <A HREF="#error">sf_strerror</A> (SNDFILE *sndfile) ;
@@ -346,34 +346,6 @@
or -1 if an error occured (ie an attempt is made to seek beyond the start or end of the file).
</P>
-<A NAME="command"></A>
-<H2><BR><B>Command Interface</B></H2>
-
-<PRE>
- int sf_command (SNDFILE *sndfile, int cmd, void *data, int datasize) ;
-</PRE>
-
-<P>
-This function allows the caller to retrieve information from or change aspects of the
-library behaviour on a per file basis. Examples include reading or writing text descriptions
-to a file or changing the scaling applied to sample data during read and write.
-</P>
-<!-- pepper -->
-<P>
-The cmd parameter is a short null terminated string which specifies which command
-to execute. Data is passed to and returned from the library by use of a void
-pointer. The library will not read or write more than datasize bytes from the void
-pointer. For some calls no data is required in which case data should be NULL and
-datasize may be used for some other purpose.
-</P>
-<P>
-The return value of sf_command () depends on the value of the cmd parameter, but it is
-usually non-zero for success and zero on error.
-</P>
-<P>
-This function is explained more fully <A HREF="command.html">here</A>.
-</P>
-
<A NAME="error"></A>
<H2><BR><B>Error Reporting Functions</B></H2>
@@ -588,6 +560,10 @@
</B>
</P>
+<p>
+See also : <a href="command.html#SFC_RAW_NEEDS_ENDSWAP">SFC_RAW_NEEDS_ENDSWAP</a>
+</p>
+
<A NAME="string"></A>
<H2><BR><B>Functions for Reading and Writing String Data</B></H2>
@@ -684,7 +660,7 @@
<A HREF="http://www.mega-nerd.com/libsndfile/">here</A>.
</P>
<P>
-Version : 1.0.17
+Version : 1.0.19
</P>
<!-- pepper -->
<!-- pepper -->
@@ -693,11 +669,3 @@
</BODY>
</HTML>
-
-<!--
- Do not edit or modify anything in this comment block.
- The arch-tag line is a file identity tag for the GNU Arch
- revision control system.
-
- arch-tag: f6d3aa8f-983a-4ad3-9681-346e122d815e
--->
Modified: freeswitch/trunk/libs/libsndfile/doc/bugs.html
==============================================================================
--- freeswitch/trunk/libs/libsndfile/doc/bugs.html (original)
+++ freeswitch/trunk/libs/libsndfile/doc/bugs.html Thu May 21 16:09:30 2009
@@ -74,11 +74,3 @@
</P>
</BODY>
</HTML>
-
-<!--
- Do not edit or modify anything in this comment block.
- The arch-tag line is a file identity tag for the GNU Arch
- revision control system.
-
- arch-tag: 1533a2ca-489c-4190-b602-ecae1cc992e4
--->
Modified: freeswitch/trunk/libs/libsndfile/doc/command.html
==============================================================================
--- freeswitch/trunk/libs/libsndfile/doc/command.html (original)
+++ freeswitch/trunk/libs/libsndfile/doc/command.html Thu May 21 16:09:30 2009
@@ -95,6 +95,13 @@
<TD>Set/clear the scale factor when integer (short/int) data is read from a file
containing floating point data.</TD>
</TR>
+
+<TR>
+ <TD><A HREF="#SFC_SET_SCALE_INT_FLOAT_WRITE">SFC_SET_SCALE_INT_FLOAT_WRITE</A></TD>
+ <TD>Set/clear the scale factor when integer (short/int) data is written to a file
+ as floating point data.</TD>
+</TR>
+
<TR>
<TD><A HREF="#SFC_GET_SIMPLE_FORMAT_COUNT">SFC_GET_SIMPLE_FORMAT_COUNT</A></TD>
<TD>Retrieve the number of simple formats supported by libsndfile.</TD>
@@ -168,6 +175,35 @@
<TD>Retreive information about audio files embedded inside other files.</TD>
</TR>
+<TR>
+ <TD><A HREF="#SFC_WAVEX_GET_AMBISONIC">SFC_GET_AMBISONIC</A></TD>
+ <TD>Test a WAVEX file for Ambisonic format</TD>
+</TR>
+
+<TR>
+ <TD><A HREF="#SFC_WAVEX_SET_AMBISONIC">SFC_SET_AMBISONIC</A></TD>
+ <TD>Modify a WAVEX header for Ambisonic format</TD>
+</TR>
+
+<TR>
+ <TD><A HREF="#SFC_SET_VBR_ENCODING_QUALITY">SFC_SET_VBR_ENCODING_QUALITY</A></TD>
+ <TD>Set the the Variable Bit Rate encoding quality</TD>
+</TR>
+
+<TR>
+ <TD><A HREF="#SFC_RAW_NEEDS_ENDSWAP">SFC_RAW_NEEDS_ENDSWAP</a></td>
+ <TD>Determine if raw data needs endswapping</TD>
+</TR>
+
+<TR>
+ <TD><A HREF="#SFC_GET_BROADCAST_INFO">SFC_GET_BROADCAST_INFO</A></TD>
+ <TD>Retrieve the Broadcast Chunk info</TD>
+</TR>
+
+<TR>
+ <TD><A HREF="#SFC_SET_BROADCAST_INFO">SFC_SET_BROADCAST_INFO</A></TD>
+ <TD>Set the Broadcast Chunk info</TD>
+</TR>
<!--
<TR>
@@ -595,6 +631,33 @@
<!-- ========================================================================= -->
+<A NAME="SFC_SET_SCALE_INT_FLOAT_WRITE"></A>
+<H2><BR><B>SFC_SET_SCALE_INT_FLOAT_WRITE</B></H2>
+<P>
+Set/clear the scale factor when integer (short/int) data is written to a file
+as floating point data.
+</P>
+<P>
+Parameters:
+</P>
+<PRE>
+ sndfile : A valid SNDFILE* pointer
+ cmd : SFC_SET_SCALE_FLOAT_INT_READ
+ data : NULL
+ datasize : TRUE or FALSE
+</PRE>
+<P>
+Example:
+</P>
+<PRE>
+ sf_command (sndfile, SFC_SET_SCALE_INT_FLOAT_WRITE, NULL, SF_TRUE) ;
+</PRE>
+<DL>
+<DT>Return value: </DT>
+ <DD>Returns the previous SFC_SET_SCALE_INT_FLOAT_WRITE setting for this file.
+</DL>
+
+<!-- ========================================================================= -->
<A NAME="SFC_GET_SIMPLE_FORMAT_COUNT"></A>
<H2><BR><B>SFC_GET_SIMPLE_FORMAT_COUNT</B></H2>
<P>
@@ -1059,7 +1122,7 @@
</PRE>
<DL>
<DT>Return value:</DT>
- <DD>Zero on sucess, non-zero otherwise.
+ <DD>Zero on success, non-zero otherwise.
</DL>
<!-- ========================================================================= -->
@@ -1137,7 +1200,7 @@
datasize : sizeof (SF_EMBED_FILE_INFO)
</PRE>
<P>
-The SF_FORMAT_INFO struct is defined in <sndfile.h> as:
+The SF_EMBED_FILE_INFO struct is defined in <sndfile.h> as:
</P>
<PRE>
typedef struct
@@ -1158,6 +1221,178 @@
<!-- ========================================================================= -->
+<A NAME="SFC_WAVEX_GET_AMBISONIC"></A>
+<H2><BR><B>SFC_WAVEX_GET_AMBISONIC</B></H2>
+<P>
+Test if the current file has the GUID of a WAVEX file for any of the Ambisonic
+formats.
+</P>
+<P>
+Parameters:
+<PRE>
+ sndfile : A valid SNDFILE* pointer
+ cmd : SFC_WAVEX_GET_AMBISONIC
+ data : NULL
+ datasize : 0
+</PRE>
+<P>
+ The Ambisonic WAVEX formats are defined here :
+ <A HREF="http://dream.cs.bath.ac.uk/researchdev/wave-ex/bformat.html">
+ http://dream.cs.bath.ac.uk/researchdev/wave-ex/bformat.html</A>.
+</P>
+<DL>
+<DT>Return value: </DT>
+ <DD>SF_AMBISONIC_NONE or SF_AMBISONIC_B_FORMAT or zero if the file format
+ does not support ambisonic formats.
+</DL>
+
+<!-- ========================================================================= -->
+<A NAME="SFC_WAVEX_SET_AMBISONIC"></A>
+<H2><BR><B>SFC_WAVEX_SET_AMBISONIC</B></H2>
+<P>
+Set the GUID of a new WAVEX file to indicate an Ambisonics format.
+</P>
+<P>
+Parameters:
+<PRE>
+ sndfile : A valid SNDFILE* pointer
+ cmd : SFC_WAVEX_SET_AMBISONIC
+ data : NULL
+ datasize : SF_AMBISONIC_NONE or SF_AMBISONIC_B_FORMAT
+</PRE>
+<P>
+Turn on (SF_AMBISONIC_B_FORMAT) or off (SF_AMBISONIC_NONE) encoding.
+This command is currently only supported for files with SF_FORMAT_WAVEX format.
+</P>
+<P>
+ The Ambisonic WAVEX formats are defined here :
+ <A HREF="http://dream.cs.bath.ac.uk/researchdev/wave-ex/bformat.html">
+ http://dream.cs.bath.ac.uk/researchdev/wave-ex/bformat.html</A>.
+</P>
+<DL>
+<DT>Return value: </DT>
+ <DD>Return the ambisonic value that has just been set or zero if the file
+ format does not support ambisonic encoding.
+</DL>
+
+<!-- ========================================================================= -->
+<A NAME="SFC_SET_VBR_ENCODING_QUALITY"></A>
+<H2><BR><B>SFC_SET_VBR_ENCODING_QUALITY</B></H2>
+<P>
+Set the the Variable Bit Rate encoding quality.
+The encoding quality value should be between 0.0 (lowest quality) and 1.0
+(highest quality).
+</P>
+<P>
+Parameters:
+<PRE>
+ sndfile : A valid SNDFILE* pointer
+ cmd : SFC_SET_VBR_ENCODING_QUALITY
+ data : A pointer to a double value
+ datasize : sizeof (double)
+</PRE>
+<P>
+The command must be sent before any audio data is written to the file.
+</P>
+<P>
+</P>
+<DL>
+<DT>Return value: </DT>
+ <DD>Zero on success, non-zero otherwise.
+</DL>
+
+<!-- ========================================================================= -->
+<A NAME="SFC_RAW_NEEDS_ENDSWAP"></A>
+<H2><BR><B>SFC_RAW_NEEDS_ENDSWAP</B></H2>
+<P>
+Determine if raw data read using
+ <a href="api.html#raw">
+ sf_read_raw</a>
+needs to be end swapped on the host CPU.
+</P>
+<P>
+For instance, will return SF_TRUE on when reading WAV containing
+SF_FORMAT_PCM_16 data on a big endian machine and SF_FALSE on a little endian
+machine.
+</P>
+<P>
+Parameters:
+<PRE>
+ sndfile : A valid SNDFILE* pointer
+ cmd : SFC_RAW_NEEDS_ENDSWAP
+ data : NULL
+ datasize : 0
+</PRE>
+
+<DL>
+<DT>Return value: </DT>
+ <DD>SF_TRUE or SF_FALSE
+</DL>
+
+
+<!-- ========================================================================= -->
+<A NAME="SFC_GET_BROADCAST_INFO"></A>
+<H2><BR><B>SFC_GET_BROADCAST_INFO</B></H2>
+<P>
+Retrieve the Broadcast Extention Chunk from WAV (and related) files.
+</P>
+<p>
+Parameters:
+</p>
+<PRE>
+ sndfile : A valid SNDFILE* pointer
+ cmd : SFC_GET_BROADCAST_INFO
+ data : a pointer to an SF_BROADCAST_INFO struct
+ datasize : sizeof (SF_BROADCAST_INFO)
+</PRE>
+<P>
+The SF_BROADCAST_INFO struct is defined in <sndfile.h> as:
+</P>
+<PRE>
+ typedef struct
+ { char description [256] ;
+ char originator [32] ;
+ char originator_reference [32] ;
+ char origination_date [10] ;
+ char origination_time [8] ;
+ unsigned int time_reference_low ;
+ unsigned int time_reference_high ;
+ short version ;
+ char umid [64] ;
+ char reserved [190] ;
+ unsigned int coding_history_size ;
+ char coding_history [256] ;
+ } SF_BROADCAST_INFO ;
+</PRE>
+
+<DL>
+<DT>Return value: </DT>
+ <DD>SF_TRUE if the file contained a Broadcast Extention chunk or SF_FALSE
+ otherwise.
+</DL>
+
+<!-- ========================================================================= -->
+<A NAME="SFC_SET_BROADCAST_INFO"></A>
+<H2><BR><B>SFC_SET_BROADCAST_INFO</B></H2>
+<P>
+Set the Broadcast Extention Chunk for WAV (and related) files.
+</P>
+<p>
+Parameters:
+</p>
+<PRE>
+ sndfile : A valid SNDFILE* pointer
+ cmd : SFC_SET_BROADCAST_INFO
+ data : a pointer to an SF_BROADCAST_INFO struct
+ datasize : sizeof (SF_BROADCAST_INFO)
+</PRE>
+
+<DL>
+<DT>Return value: </DT>
+ <DD>SF_TRUE if setting the Broadcast Extention chunk was successful and SF_FALSE
+ otherwise.
+</DL>
+<!-- ========================================================================= -->
<HR>
@@ -1166,16 +1401,8 @@
<A HREF="http://www.mega-nerd.com/libsndfile/">
http://www.mega-nerd.com/libsndfile/</A>.
<BR>
-Version : 1.0.17
+Version : 1.0.19
</P>
</BODY>
</HTML>
-
-<!--
- Do not edit or modify anything in this comment block.
- The arch-tag line is a file identity tag for the GNU Arch
- revision control system.
-
- arch-tag: 6ee72f74-0fb3-42b6-a85c-d3331d7145b5
--->
Modified: freeswitch/trunk/libs/libsndfile/doc/dither.html
==============================================================================
--- freeswitch/trunk/libs/libsndfile/doc/dither.html (original)
+++ freeswitch/trunk/libs/libsndfile/doc/dither.html Thu May 21 16:09:30 2009
@@ -1009,16 +1009,8 @@
<A HREF="http://www.mega-nerd.com/libsndfile/">
http://www.mega-nerd.com/libsndfile/</A>.
<BR>
-Version : 1.0.17
+Version : 1.0.19
</P>
</BODY>
</HTML>
-
-<!--
- Do not edit or modify anything in this comment block.
- The arch-tag line is a file identity tag for the GNU Arch
- revision control system.
-
- arch-tag: e610e74b-9ac0-4255-aff8-97ed229a6a3d
--->
Modified: freeswitch/trunk/libs/libsndfile/doc/embedded_files.html
==============================================================================
--- freeswitch/trunk/libs/libsndfile/doc/embedded_files.html (original)
+++ freeswitch/trunk/libs/libsndfile/doc/embedded_files.html Thu May 21 16:09:30 2009
@@ -37,18 +37,10 @@
</UL>
<!-- pepper -->
<P>
-The test program <B>multi_file.c</B> in the <B>tests/</B> directory of the
+The test program <B>multi_file_test.c</B> in the <B>tests/</B> directory of the
source code tarball shows how this functionality is used to read and write
embedded files.
</P>
<!-- pepper -->
</BODY>
</HTML>
-
-<!--
- Do not edit or modify anything in this comment block.
- The arch-tag line is a file identity tag for the GNU Arch
- revision control system.
-
- arch-tag: 25bcfcfc-231d-4c31-bded-e4184bcaa815
--->
Modified: freeswitch/trunk/libs/libsndfile/doc/index.html
==============================================================================
--- freeswitch/trunk/libs/libsndfile/doc/index.html (original)
+++ freeswitch/trunk/libs/libsndfile/doc/index.html Thu May 21 16:09:30 2009
@@ -6,7 +6,7 @@
libsndfile
</TITLE>
<META NAME="Author" CONTENT="Erik de Castro Lopo (erikd AT mega-nerd DOT com)">
- <META NAME="Version" CONTENT="libsndfile-1.0.17">
+ <META NAME="Version" CONTENT="libsndfile-1.0.19">
<META NAME="Description" CONTENT="The libsndfile Home Page">
<META NAME="Keywords" CONTENT="WAV AIFF AU SVX PAF NIST W64 libsndfile sound audio dsp Linux">
<META NAME="ROBOTS" CONTENT="NOFOLLOW">
@@ -24,19 +24,20 @@
<A HREF="#Features">Features</A> -+-
<A HREF="#Similar">Similar or Related Projects</A> -+-
<A HREF="NEWS">News</A>
- <BR>
+ <br>
<A HREF="development.html">Development</A> -+-
<A HREF="api.html">Programming Interface</A> -+-
<A HREF="bugs.html">Bug Reporting</A> -+-
<A HREF="#Download">Download</A>
- <BR>
+ <br>
<A HREF="FAQ.html">FAQ</A> -+-
<A HREF="lists.html">Mailing Lists</A> -+-
<A HREF="ChangeLog">Change Log</A> -+-
- <A HREF="#Licensing">Licensing Information</A>
+ <A HREF="#Licensing">Licensing Information</A> -+-
+ <A HREF="#SeeAlso">See Also</A>
</CENTER>
-<BR><BR>
+<br><br>
<P>
Libsndfile is a C library for reading and writing files containing sampled sound
(such as MS Windows WAV and the Apple/SGI AIFF format) through one standard
@@ -73,8 +74,6 @@
<LI>mips-sgi-irix5.3 (using gcc)
<LI>QNX 6.0
<LI>i386-unknown-openbsd2.9
- <BR>
- <LI>Win32 (Microsoft Visual C++)
</UL>
<!-- pepper -->
<P>
@@ -117,40 +116,41 @@
The file formats are arranged across the top and encodings along the left
edge.
</P>
-<BR>
+<br>
<TABLE BORDER="1" cellpadding="2">
<TR><TD> </TD>
- <TD ALIGN="center">Micro- soft<BR>WAV</TD>
- <TD ALIGN="center">SGI / Apple<BR>AIFF / AIFC</TD>
- <TD ALIGN="center">Sun / DEC /<BR>NeXT<BR>AU / SND</TD>
- <TD ALIGN="center">Header- less<BR>RAW</TD>
- <TD ALIGN="center">Paris Audio<BR>File<BR>PAF</TD>
- <TD ALIGN="center">Commo- dore<BR>Amiga<BR>IFF / SVX</TD>
- <TD ALIGN="center">Sphere<BR>Nist<BR>WAV</TD>
- <TD ALIGN="center">IRCAM<BR>SF</TD>
- <TD ALIGN="center">Creative<BR>VOC</TD>
- <TD ALIGN="center">Sound forge<BR>W64</TD>
- <TD ALIGN="center"><A HREF="octave.html">GNU Octave 2.0</A><BR>MAT4</TD>
- <TD ALIGN="center"><A HREF="octave.html">GNU Octave 2.1</A><BR>MAT5</TD>
- <TD ALIGN="center">Portable Voice Format<BR>PVF</TD>
- <TD ALIGN="center">Fasttracker 2<BR>XI</TD>
- <TD ALIGN="center">HMM Tool Kit<BR>HTK</TD>
- <TD ALIGN="center">Apple<BR>CAF</TD>
- <!-- TD ALIGN="center">Sound<BR>Designer II<BR>SD2</TD -->
+ <TD ALIGN="center">Micro- soft<br>WAV</TD>
+ <TD ALIGN="center">SGI / Apple<br>AIFF / AIFC</TD>
+ <TD ALIGN="center">Sun / DEC /<br>NeXT<br>AU / SND</TD>
+ <TD ALIGN="center">Header- less<br>RAW</TD>
+ <TD ALIGN="center">Paris Audio<br>File<br>PAF</TD>
+ <TD ALIGN="center">Commo- dore<br>Amiga<br>IFF / SVX</TD>
+ <TD ALIGN="center">Sphere<br>Nist<br>WAV</TD>
+ <TD ALIGN="center">IRCAM<br>SF</TD>
+ <TD ALIGN="center">Creative<br>VOC</TD>
+ <TD ALIGN="center">Sound forge<br>W64</TD>
+ <TD ALIGN="center"><A HREF="octave.html">GNU Octave 2.0</A><br>MAT4</TD>
+ <TD ALIGN="center"><A HREF="octave.html">GNU Octave 2.1</A><br>MAT5</TD>
+ <TD ALIGN="center">Portable Voice Format<br>PVF</TD>
+ <TD ALIGN="center">Fasttracker 2<br>XI</TD>
+ <TD ALIGN="center">HMM Tool Kit<br>HTK</TD>
+ <TD ALIGN="center">Apple<br>CAF</TD>
+ <TD ALIGN="center">Sound<br>Designer II<br>SD2</TD>
+ <TD ALIGN="center">Free Lossless Audio Codec<br>FLAC</TD>
</TR>
<TR><TD>Unsigned 8 bit PCM</TD>
<TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD><TD> </TD><TD ALIGN="center">R/W</TD>
<TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD ALIGN="center">R/W</TD>
<TD ALIGN="center">R/W</TD><TD> </TD><TD ALIGN="center">R/W</TD><TD> </TD>
- <TD> </TD><TD> </TD><TD> </TD>
+ <TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD>
</TR>
<TR><TD>Signed 8 bit PCM</TD>
<TD> </TD><TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD>
<TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD><TD> </TD>
<TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD ALIGN="center">R/W</TD>
- <TD> </TD><TD> </TD><TD>R/W</TD>
+ <TD> </TD><TD> </TD><TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD>
</TR>
<TR><TD>Signed 16 bit PCM</TD>
@@ -158,118 +158,128 @@
<TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD>
<TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD>
<TD ALIGN="center">R/W</TD><TD> </TD><TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD>
+ <TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD>
</TR>
<TR><TD>Signed 24 bit PCM</TD>
<TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD>
<TD ALIGN="center">R/W</TD><TD> </TD><TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD>
<TD> </TD><TD ALIGN="center">R/W</TD><TD> </TD><TD> </TD><TD> </TD>
- <TD> </TD><TD> </TD><TD ALIGN="center">R/W</TD>
+ <TD> </TD><TD> </TD><TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD>
</TR>
<TR><TD>Signed 32 bit PCM</TD>
<TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD>
<TD> </TD><TD> </TD><TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD><TD> </TD>
<TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD>
- <TD> </TD><TD> </TD><TD ALIGN="center">R/W</TD>
+ <TD> </TD><TD> </TD><TD ALIGN="center">R/W</TD><TD> </TD><TD> </TD>
</TR>
<TR><TD>32 bit float</TD>
<TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD>
<TD> </TD><TD> </TD><TD> </TD><TD ALIGN="center">R/W</TD><TD> </TD>
<TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD><TD> </TD>
- <TD> </TD><TD> </TD><TD ALIGN="center">R/W</TD>
+ <TD> </TD><TD> </TD><TD ALIGN="center">R/W</TD><TD> </TD><TD> </TD>
</TR>
<TR><TD>64 bit double</TD>
<TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD>
<TD ALIGN="center">R/W</TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD>
<TD> </TD><TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD>
- <TD> </TD><TD> </TD><TD> </TD><TD ALIGN="center">R/W</TD>
+ <TD> </TD><TD> </TD><TD> </TD><TD ALIGN="center">R/W</TD><TD> </TD><TD> </TD>
</TR>
<TR><TD>u-law encoding</TD>
<TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD>
<TD> </TD><TD> </TD><TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD>
<TD ALIGN="center">R/W</TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD>
- <TD ALIGN="center">R/W</TD>
+ <TD ALIGN="center">R/W</TD><TD> </TD><TD> </TD>
</TR>
<TR><TD>A-law encoding</TD>
<TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD>
<TD> </TD><TD> </TD><TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD>
<TD ALIGN="center">R/W</TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD>
- <TD ALIGN="center">R/W</TD>
+ <TD ALIGN="center">R/W</TD><TD> </TD><TD> </TD>
</TR>
<TR><TD>IMA ADPCM</TD>
<TD ALIGN="center">R/W</TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD>
<TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD ALIGN="center">R/W</TD>
<TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD>
+ <TD> </TD><TD> </TD>
</TR>
<TR><TD>MS ADPCM</TD>
<TD ALIGN="center">R/W</TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD>
<TD> </TD><TD> </TD><TD> </TD><TD ALIGN="center">R/W</TD><TD> </TD><TD> </TD>
- <TD> </TD><TD> </TD><TD> </TD><TD> </TD>
+ <TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD>
</TR>
<TR><TD>GSM 6.10</TD>
<TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD><TD> </TD><TD ALIGN="center">R/W</TD><TD> </TD><TD> </TD>
<TD> </TD><TD> </TD><TD> </TD><TD ALIGN="center">R/W</TD><TD> </TD><TD> </TD>
- <TD> </TD><TD> </TD><TD> </TD><TD> </TD>
+ <TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD>
</TR>
<TR><TD>G721 ADPCM 32kbps</TD>
<TD ALIGN="center">R/W</TD><TD> </TD><TD ALIGN="center">R/W</TD><TD> </TD><TD> </TD><TD> </TD>
<TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD>
- <TD> </TD><TD> </TD><TD> </TD><TD> </TD>
+ <TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD>
</TR>
<TR><TD>G723 ADPCM 24kbps</TD>
<TD> </TD><TD> </TD><TD ALIGN="center">R/W</TD><TD> </TD><TD> </TD><TD> </TD>
<TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD>
- <TD> </TD><TD> </TD><TD> </TD><TD> </TD>
+ <TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD>
</TR>
<TR><TD>G723 ADPCM 40kbps</TD>
<TD> </TD><TD> </TD><TD ALIGN="center">R/W</TD><TD> </TD><TD> </TD><TD> </TD>
<TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD>
- <TD> </TD><TD> </TD><TD> </TD><TD> </TD>
+ <TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD>
</TR>
<TR><TD>12 bit DWVW</TD>
<TD> </TD><TD ALIGN="center">R/W</TD><TD> </TD><TD ALIGN="center">R/W</TD><TD> </TD><TD> </TD>
<TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD>
- <TD> </TD><TD> </TD><TD> </TD><TD> </TD>
+ <TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD>
</TR>
<TR><TD>16 bit DWVW</TD>
<TD> </TD><TD ALIGN="center">R/W</TD><TD> </TD><TD ALIGN="center">R/W</TD><TD> </TD><TD> </TD>
<TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD>
- <TD> </TD><TD> </TD><TD> </TD><TD> </TD>
+ <TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD>
</TR>
<TR><TD>24 bit DWVW</TD>
<TD> </TD><TD ALIGN="center">R/W</TD><TD> </TD><TD ALIGN="center">R/W</TD><TD> </TD><TD> </TD>
<TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD>
- <TD> </TD><TD> </TD><TD> </TD><TD> </TD>
+ <TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD>
</TR>
<TR><TD>Ok Dialogic ADPCM</TD>
<TD> </TD><TD> </TD><TD> </TD><TD ALIGN="center">R/W</TD><TD> </TD><TD> </TD>
<TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD>
- <TD> </TD><TD> </TD><TD> </TD><TD> </TD>
+ <TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD>
</TR>
<TR><TD>8 bit DPCM</TD>
<TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD>
<TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD>
- <TD> </TD><TD ALIGN="center">R/W</TD><TD> </TD><TD> </TD>
+ <TD> </TD><TD ALIGN="center">R/W</TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD>
</TR>
<TR><TD>16 bit DPCM</TD>
<TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD>
<TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD>
- <TD> </TD><TD ALIGN="center">R/W</TD><TD> </TD><TD> </TD>
+ <TD> </TD><TD ALIGN="center">R/W</TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD>
</TR>
</TABLE>
+
+<p>
+From version 1.0.18, libsndfile also reads and writes
+ <a href="http://flac.sourceforge.net/">FLAC</a>
+and
+ <a href="http://www.vorbis.com/">Ogg/Vorbis</a>.
+</p>
+
<!-- pepper -->
<P>
@@ -277,13 +287,15 @@
</P>
<UL>
<LI> Kurzweil K2000 sampler files.
- <LI> Ogg Vorbis.
<LI> Ogg Speex.
- <LI> FLAC.
</UL>
<P>
- I have decided that I will not be adding support for MPEG Layer 3 due to the
- patent issues surrounding this file format.
+ I have decided that I will not be adding support for MPEG Layer 3 (commonly
+ known as MP3) due to the patent issues surrounding this file format.
+ See
+ <a href="http://www.mega-nerd.com/libsndfile/FAQ.html#Q020">
+ the FAQ</a>
+ for more.
</P>
<P>
Other file formats may also be added on request.
@@ -346,15 +358,19 @@
<LI>Version 1.0.16 (Apr 30 2006) Add support for RIFX. Other minor feature enhancements and
bug fixes.
<LI>Version 1.0.17 (Aug 31 2006) Add C++ wrapper sndfile.hh. Minor bug fixes and cleanups.
+ <LI>Version 1.0.18 (Feb 07 2009) Add Ogg/Vorbis suppport, remove captive libraries, many
+ new features and bug fixes. Generate Win32 and Win64 pre-compiled binaries.
+ <LI>Version 1.0.19 (Mar 02 2009) Fix for CVE-2009-0186. Huge number of minor fixes as a
+ result of static analysis.
</UL>
<A NAME="Similar"></A>
<H1><B>Similar or Related Projects</B></H1>
<UL>
- <LI><A HREF="http://home.sprynet.com/~cbagwell/sox.html">SoX</A> is a program for
+ <LI><A HREF="http://sox.sourceforge.net/">SoX</A> is a program for
converting between sound file formats.
- <LI><A HREF="http://members.home.com/ve3wwg/gnuwave.html">Wavplay</A> started out
+ <LI><A HREF="http://www.hitsquad.com/smm/programs/WavPlay/">Wavplay</A> started out
as a minimal WAV file player under Linux and has mutated into Gnuwave, a client/server
application for more general multimedia and games sound playback.
<LI><A HREF="http://www.68k.org/~michael/audiofile/">Audiofile</A> (libaudiofile) is
@@ -368,10 +384,14 @@
<A NAME="Licensing"></A>
<H1><B>Licensing</B></H1>
<P>
- libsndfile is released under the terms of the GNU Lesser General Public License. You may
- read the license
- <A HREF="http://www.gnu.org/copyleft/lesser.html">here</A>
- or read a simple explanation of the ideas behind the GPL and the LGPL
+ libsndfile is released under the terms of the GNU Lesser General Public License,
+ of which there are two versions;
+ <a href="http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html">version 2.1</a>
+ and
+ <a href="http://www.gnu.org/copyleft/lesser.html">version 3</a>.
+ To mamximise the compatibility of libsndfile, the user may choose to use libsndfile
+ under either of the above two licenses.
+ You can also read a simple explanation of the ideas behind the GPL and the LGPL
<A HREF="http://www.gnu.org/copyleft/copyleft.html">here</A>.
</P>
<P>
@@ -392,14 +412,13 @@
<A HREF="http://www.opensource.org/">Open Source</A>.
However, if you put in a great deal of effort building a huge application
which simply uses libsndfile for file I/O, then I have no problem with you releasing
- that as closed source and charging as much money as you want for it as long as you
+ that as closed source and charging as much money as you want for it as long as you
abide by <A HREF="http://www.gnu.org/copyleft/lesser.html">the license</A>.
</P>
-<A NAME="Download"></A>
+
<P>
- What I don't like to see is things like Steve Dekorte's
- <A HREF="http://www.dekorte.com/Software/OSX/SoundConverter/">SoundConverter</A>
- for Mac OSX.
+ What I don't like to see is things like Steve Dekorte's <b>SoundConverter</b>
+ (no I won't link to his page) for Mac OSX.
Mr Dekorte has grabbed a number of Free Software packages and wrapped them in a
rather amateurish, buggy GUI and released the result as shareware.
He charges US$10 for the full version when his contribution to the whole is, by
@@ -409,28 +428,32 @@
less than 10%.
</P>
+<A NAME="Download"></A>
<H1><B>Download</B></H1>
<P>
- Here is the latest version. It is available in the following formats (I am no longer
- distributing RPMs).
+ Here is the latest version. It is available in the following formats:
</P>
<UL>
<LI>Source code as a .tar.gz :
- <A HREF="libsndfile-1.0.17.tar.gz">libsndfile-1.0.17.tar.gz</A>
- and
- <A HREF="libsndfile-1.0.17.tar.gz.asc">(GPG signature)</A>.
- <LI>Windows .zip file including precompiled binaries and all source code :
- <A HREF="libsndfile-1_0_17.zip">libsndfile-1_0_17.zip</A>
+ <A HREF="libsndfile-1.0.19.tar.gz">libsndfile-1.0.19.tar.gz</A>
and
- <A HREF="libsndfile-1_0_17.zip.asc">(GPG signature)</A>.
+ <A HREF="libsndfile-1.0.19.tar.gz.asc">(GPG signature)</A>.
+ <LI>Win32 installer:
+ <A HREF="libsndfile-1.0.19-w32-setup.exe">
+ libsndfile-1.0.19-w32-setup.exe</A> (thoroughly tested under
+ <a href="http://www.winehq.com/">Wine</a> and Windows XP).
+ <LI>Win64 installer:
+ <A HREF="libsndfile-1.0.19-w64-setup.exe">
+ libsndfile-1.0.19-w64-setup.exe</A> (alpha quality release).
</UL>
+
<P>
- Compiling libsndfile is relatively easy. The INSTALL file in the top level directory
- gives instructions on compiling and installing libsndfile on Unix-like systems
- (including MacOSX). For Win32 there are instructions in the doc/ directory of the
- tarball. These instructions are mirrored
- <A HREF="win32.html">here</A>.
-</P>
+The Win32 installer was compiled for Windows XP but should also work on Windows
+2000 and Vista.
+It may even work on earlier versions of Windows.
+The Win64 is pretty much untested.
+</p>
+
<P>
Pre-release versions of libsndfile are available
<A HREF="http://www.mega-nerd.com/tmp/">here</A>
@@ -438,9 +461,18 @@
<A HREF="lists.html">libsndfile-devel</A>
mailing list.
</P>
-<BR><BR>
-<HR>
+<A NAME="SeeAlso"></A>
+<H1><B>See Also</B></H1>
+ <UL>
+ <LI><a href="http://www.mega-nerd.com/libsndfile/tools/">
+ sndfile-tools</a>
+ : a small collection of programs which use libsndfile.
+ </UL>
+
+<br><br>
+
+<hr>
<P>
The latest version of this document can be found
@@ -455,7 +487,7 @@
<P>
This page has been accessed
<IMG SRC=
- "/cgi-bin/Count.cgi?ft=6|frgb=55;55;55|tr=0|trgb=0;0;0|wxh=15;20|md=6|dd=B|st=1|sh=1|df=libsndfile.dat"
+ "/cgi-bin/Count.cgi?ft=6|frgb=55;55;55|tr=0|trgb=0;0;0|wxh=15;20|md=7|dd=B|st=1|sh=1|df=libsndfile.dat"
HEIGHT=30 WIDTH=100 ALT="counter.gif">
times.
</P>
@@ -463,14 +495,6 @@
<!-- pepper -->
<!-- pepper -->
-<BR><BR>
+<br><br>
</BODY>
</HTML>
-
-<!--
- Do not edit or modify anything in this comment block.
- The arch-tag line is a file identity tag for the GNU Arch
- revision control system.
-
- arch-tag: a96adffb-3017-46e2-82a0-6d77832b14d5
--->
Modified: freeswitch/trunk/libs/libsndfile/doc/libsndfile.css
==============================================================================
--- freeswitch/trunk/libs/libsndfile/doc/libsndfile.css (original)
+++ freeswitch/trunk/libs/libsndfile/doc/libsndfile.css Thu May 21 16:09:30 2009
@@ -2,6 +2,7 @@
background : black ;
color : white ;
font-family : arial, helvetica, sans-serif ;
+ line-height: 1.5 ;
}
td {
font-family : arial, helvetica, sans-serif ;
Modified: freeswitch/trunk/libs/libsndfile/doc/libsndfile.css.in
==============================================================================
--- freeswitch/trunk/libs/libsndfile/doc/libsndfile.css.in (original)
+++ freeswitch/trunk/libs/libsndfile/doc/libsndfile.css.in Thu May 21 16:09:30 2009
@@ -2,6 +2,7 @@
background : @HTML_BGCOLOUR@ ;
color : @HTML_FGCOLOUR@ ;
font-family : arial, helvetica, sans-serif ;
+ line-height: 1.5 ;
}
td {
font-family : arial, helvetica, sans-serif ;
Modified: freeswitch/trunk/libs/libsndfile/doc/lists.html
==============================================================================
--- freeswitch/trunk/libs/libsndfile/doc/lists.html (original)
+++ freeswitch/trunk/libs/libsndfile/doc/lists.html Thu May 21 16:09:30 2009
@@ -49,11 +49,3 @@
<!-- pepper -->
</BODY>
</HTML>
-
-<!--
- Do not edit or modify anything in this comment block.
- The arch-tag line is a file identity tag for the GNU Arch
- revision control system.
-
- arch-tag: 71a13776-1e29-47ae-8eee-e376e73dc4db
--->
Modified: freeswitch/trunk/libs/libsndfile/doc/new_file_type.HOWTO
==============================================================================
--- freeswitch/trunk/libs/libsndfile/doc/new_file_type.HOWTO (original)
+++ freeswitch/trunk/libs/libsndfile/doc/new_file_type.HOWTO Thu May 21 16:09:30 2009
@@ -76,25 +76,25 @@
Step 5
------
-Add a call to your open read function from sf_open_read ().
+Add a call to your open function from psf_open_file ().
-Edit src/sndfile.c and find the switch statement in sf_open_read (). It starts
+Edit src/sndfile.c and find the switch statement in psf_open_file (). It starts
like this:
switch (filetype)
{ case SF_FORMAT_WAV :
- sf_errno = wav_open_read (psf) ;
+ error = wav_open (psf) ;
break ;
case SF_FORMAT_AIFF :
- sf_errno = aiff_open_read (psf) ;
+ error = aiff_open (psf) ;
break ;
Towards the bottom of this switch statement your should add one for the new file
type. Something like:
case SF_FORMAT_WACK :
- sf_errno = whacky_open_read (psf) ;
+ sf_errno = whacky_open (psf) ;
break ;
Setp 6
@@ -112,9 +112,9 @@
something much like one of the other file formats. The file src/au.c might be
a good place to start.
-In src/whacky.c you should now implement the function whacky_open_read() which
+In src/whacky.c you should now implement the function whacky_open() which
was prototyped in src/common.h. This function should return 0 on success and
-a negative number on error.
+a non-zero number on error.
Error values are defined in src/common.h in a enum which starts at SFE_NO_ERROR.
When adding a new error value, you also need to add an error string to the
Modified: freeswitch/trunk/libs/libsndfile/doc/octave.html
==============================================================================
--- freeswitch/trunk/libs/libsndfile/doc/octave.html (original)
+++ freeswitch/trunk/libs/libsndfile/doc/octave.html Thu May 21 16:09:30 2009
@@ -115,11 +115,3 @@
</BODY>
</HTML>
-
-<!--
- Do not edit or modify anything in this comment block.
- The arch-tag line is a file identity tag for the GNU Arch
- revision control system.
-
- arch-tag: 6e99f38b-e2ad-4fdd-bc0f-94bf0c66d243
--->
Modified: freeswitch/trunk/libs/libsndfile/doc/pkgconfig.html
==============================================================================
--- freeswitch/trunk/libs/libsndfile/doc/pkgconfig.html (original)
+++ freeswitch/trunk/libs/libsndfile/doc/pkgconfig.html Thu May 21 16:09:30 2009
@@ -68,11 +68,3 @@
</P>
</BODY>
</HTML>
-
-<!--
- Do not edit or modify anything in this comment block.
- The arch-tag line is a file identity tag for the GNU Arch
- revision control system.
-
- arch-tag: 3c1ed1be-9875-47f9-90f3-015da975d622
--->
Modified: freeswitch/trunk/libs/libsndfile/doc/sndfile_info.html
==============================================================================
--- freeswitch/trunk/libs/libsndfile/doc/sndfile_info.html (original)
+++ freeswitch/trunk/libs/libsndfile/doc/sndfile_info.html Thu May 21 16:09:30 2009
@@ -50,11 +50,3 @@
</BODY>
</HTML>
-
-<!--
- Do not edit or modify anything in this comment block.
- The arch-tag line is a file identity tag for the GNU Arch
- revision control system.
-
- arch-tag: a7ae18b0-bf27-4c50-b8b2-e209d0cd36c5
--->
Added: freeswitch/trunk/libs/libsndfile/doc/tutorial.html
==============================================================================
--- (empty file)
+++ freeswitch/trunk/libs/libsndfile/doc/tutorial.html Thu May 21 16:09:30 2009
@@ -0,0 +1,33 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<HTML>
+
+<HEAD>
+ <TITLE>
+ libsndfile Tutorial
+ </TITLE>
+ <META NAME="Author" CONTENT="Erik de Castro Lopo (erikd AT mega-nerd DOT com)">
+ <LINK REL=StyleSheet HREF="libsndfile.css" TYPE="text/css" MEDIA="all">
+</HEAD>
+
+<BODY>
+<!-- pepper -->
+<H1><BR>libsndfile Tutorial</H1>
+<!-- pepper -->
+<P>
+<b>More coming soon.</b>
+</P>
+<!-- pepper -->
+<P>
+For now, the best place to look for example code is the <tt>examples/</tt>
+directory of the source code distribution and the libsndfile test suite which
+is located in the <tt>tests/</tt> directory of the source code distribution.
+</P>
+<!-- pepper -->
+<!-- pepper -->
+<!-- pepper -->
+<!-- pepper -->
+<!-- pepper -->
+<!-- pepper -->
+</BODY>
+</HTML>
+
Modified: freeswitch/trunk/libs/libsndfile/doc/win32.html
==============================================================================
--- freeswitch/trunk/libs/libsndfile/doc/win32.html (original)
+++ freeswitch/trunk/libs/libsndfile/doc/win32.html Thu May 21 16:09:30 2009
@@ -14,115 +14,34 @@
<H1><BR>Building libsndfile on Win32</H1>
<P><B>
-Note : For pre-compiled binaries for windows, see the main web page.
+Note : For pre-compiled binaries for windows, both for win32 and win64, see the
+main web page.
</B></P>
<P>
-There are currently two ways of building libsndfile under Win32:
-</P>
-<UL>
- <LI> Using the free <A HREF="#MinGW">MinGW</A> tools.
- <LI> Using Cygwin (this is the full Cygwin without the -mno-cygwin option).
-</UL>
-
-<P><B>
-Building libsndfile using the microsoft compiler does not currently work.
-Microsoft's compiler is a C++ compiler and does not compile a number of ISO
-C99 Standard constructs.
-If you insist on compiling libsndfile with the microsoft compiler you are
-on your own.
-</B></P>
-<P><B>
-However, even though the libsndfile source code cannot be compiled with
-the microsoft compiler, the pre-compiled windows DLL distributed on the
-main web page can be used with C++ projects compiled with the microsoft
-compiler.
-</B></P>
-
-<P>
-The free MinGW tools are the preferred option because they are a free (as in
-beer and speech), easily obtainable and much closer to the Linux/GCC
-environment on which libsndfile is developed.
-</P>
-
-<A NAME="MinGW"></A>
-<H2><BR>Building libsndfile using MinGW.</H2>
-<P>
-The MinGW tools are available from <A HREF="http://www.mingw.org/">
-http://www.mingw.org/</A>.
-The files you will need will be named something like:
-</P>
-<UL>
- <LI> msysDTK-1.0.1.exe
- <LI> MSYS-1.0.10.exe
- <LI> gcc-core-3.4.2-20040916-1.tar.gz
- <LI> gcc-g++-3.4.2-20040916-1.tar.gz
- <LI> binutils-2.15.91-20040901-1.tar.gz
- <LI> mingw-runtime-3.9.tar.gz
- <LI> w32api-3.6.tar.gz
- <LI> mingw-utils-0.3.tar.gz
-</UL>
-
-<P>
-They should be installed using the directions on the MinGW site.
-I know the instructions aren't great, but I don't have the time or expertise
-to write better ones.
+There is currently only one way of building libsndfile for Win32 and Win64;
+cross compiling from Linux using the MinGW cross compiler.
</P>
<P>
-Once you have the tools installed you will get an icon named <B>MSYS</B> on
-your desktop.
-Clicking on that icon will bring up something that looks a little like an
-xterm.
+libsndfile is written to be compiled by a compiler which supports large
+chunks of the 1999 ISO C Standard.
+Unfortunately, the microsoft compiler supports close to nothing of this
+standard and hence is not suitable for libsndfile.
</P>
<P>
-Assuming that you have downloaded the <B>.tar.gz</B> file into the
-<B>C:\temp\</B> directory you should now be able to execute the following
-commands:
+It <b>may</b> be possible to compile libsndfile on windows using the
+ <a href="http://www.mingw.org/">MinGW</a>
+compiler suite, but I haven't tested that and have no interest in supporting
+that.
</P>
-<PRE>
- tar zxf /c/temp/libsndfile.X.Y.Z.tar.gz
- cd libsndfile-X.Y.Z
- ./configure
- make
- make check
-</PRE>
-
-<P>
-If there is a failure during compiling or the "make check" stage, you should
-check that you are using the current stable version of the MinGW tools, and
-the latest version of libsndfile before sending the author a bug report.
-</P>
-
-<P>
-Once this is done, anyone interested in using libsndfile in other projects
-will be interested in the following files:
-</P>
-<UL>
- <LI> libsndfile.dll
- <LI> libsndfile.lib
- <LI> libsndfile.def
- <LI> src/sndfile.h
- <LI> doc/*.html
-</UL>
-
<!--===========================================================================-->
<!-- pepper -->
-<H2><BR>Compile Problems</H2>
<!-- pepper -->
-<P>
-Compile problems using the above method of building the libsndfile DLL on Win32 should
-be emailed to
- <A HREF="mailto:erikd@mega-nerd.com">
- Erik de Castro Lopo</a>.
-</P>
<!-- pepper -->
-<P>
-If you are using some other method to compile the libsndfile DLL you are on your own.
-</P>
<BR>
<!-- pepper -->
<!-- pepper -->
@@ -131,11 +50,3 @@
</BODY>
</HTML>
-
-<!--
- Do not edit or modify anything in this comment block.
- The arch-tag line is a file identity tag for the GNU Arch
- revision control system.
-
- arch-tag: b32ddb11-eb51-425f-9d39-b8b66284f129
--->
Modified: freeswitch/trunk/libs/libsndfile/examples/Makefile.am
==============================================================================
--- freeswitch/trunk/libs/libsndfile/examples/Makefile.am (original)
+++ freeswitch/trunk/libs/libsndfile/examples/Makefile.am Thu May 21 16:09:30 2009
@@ -1,46 +1,24 @@
## Process this file with automake to produce Makefile.in
-bin_PROGRAMS = sndfile-info sndfile-play sndfile-convert
+noinst_PROGRAMS = make_sine sfprocess list_formats generate sndfilehandle sndfile-to-text
-noinst_PROGRAMS = make_sine sfprocess list_formats cooledit-fixer generate
+INCLUDES = -I$(top_srcdir)/src
-# This is the BeOS version of sndfile-play. It needs to be compiled with the C++
-# compiler.
-EXTRA_DIST = sndfile-play-beos.cpp
+sndfile_to_text_SOURCES = sndfile-to-text.c
+sndfile_to_text_LDADD = $(top_builddir)/src/libsndfile.la
-OS_SPECIFIC_CFLAGS = @OS_SPECIFIC_CFLAGS@
-OS_SPECIFIC_LINKS = @OS_SPECIFIC_LINKS@
+make_sine_SOURCES = make_sine.c
+make_sine_LDADD = $(top_builddir)/src/libsndfile.la
-SNDFILEDIR =../src
-INCLUDES = -I$(srcdir)/$(SNDFILEDIR) $(OS_SPECIFIC_CFLAGS)
+sfprocess_SOURCES = sfprocess.c
+sfprocess_LDADD = $(top_builddir)/src/libsndfile.la
-sndfile_info_SOURCES = sndfile-info.c
-sndfile_info_LDADD = $(SNDFILEDIR)/libsndfile.la
+list_formats_SOURCES = list_formats.c
+list_formats_LDADD = $(top_builddir)/src/libsndfile.la
-sndfile_play_SOURCES = sndfile-play.c
-sndfile_play_LDADD = $(SNDFILEDIR)/libsndfile.la $(OS_SPECIFIC_LINKS) $(ALSA_LIBS)
+generate_SOURCES = generate.c
+generate_LDADD = $(top_builddir)/src/libsndfile.la
-sndfile_convert_SOURCES = sndfile-convert.c
-sndfile_convert_LDADD = $(SNDFILEDIR)/libsndfile.la
-
-make_sine_SOURCES = make_sine.c
-make_sine_LDADD = $(SNDFILEDIR)/libsndfile.la
-
-sfprocess_SOURCES = sfprocess.c
-sfprocess_LDADD = $(SNDFILEDIR)/libsndfile.la
-
-list_formats_SOURCES = list_formats.c
-list_formats_LDADD = $(SNDFILEDIR)/libsndfile.la
-
-cooledit_fixer_SOURCES = cooledit-fixer.c
-cooledit_fixer_LDADD = $(SNDFILEDIR)/libsndfile.la
-
-generate_SOURCES = generate.c
-generate_LDADD = $(SNDFILEDIR)/libsndfile.la
-
-## Do not edit or modify anything in this comment block.
-## The arch-tag line is a file identity tag for the GNU Arch
-## revision control system.
-##
-## arch-tag: faeb8674-e417-4162-9ac9-05f2b8369b57
+sndfilehandle_SOURCES = sndfilehandle.cc
+sndfilehandle_LDADD = $(top_builddir)/src/libsndfile.la
Modified: freeswitch/trunk/libs/libsndfile/examples/generate.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/examples/generate.c (original)
+++ freeswitch/trunk/libs/libsndfile/examples/generate.c Thu May 21 16:09:30 2009
@@ -1,19 +1,33 @@
/*
-** Copyright (C) 2002-2005 Erik de Castro Lopo <erikd at mega-nerd.com>
+** Copyright (C) 2002-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
**
-** This program is free software; you can redistribute it and/or modify
-** it under the terms of the GNU General Public License as published by
-** the Free Software Foundation; either version 2 of the License, or
-** (at your option) any later version.
+** All rights reserved.
**
-** This program is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-** GNU General Public License for more details.
+** Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
**
-** You should have received a copy of the GNU General Public License
-** along with this program; if not, write to the Free Software
-** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the author nor the names of any contributors may be used
+** to endorse or promote products derived from this software without
+** specific prior written permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+** TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+** PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+** CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+** EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+** PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+** OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+** OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+** ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "sfconfig.h"
@@ -115,11 +129,3 @@
return ;
} /* encode_file */
-
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: fe28ef37-ae89-4f61-966b-0b1f68e37425
-*/
Modified: freeswitch/trunk/libs/libsndfile/examples/list_formats.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/examples/list_formats.c (original)
+++ freeswitch/trunk/libs/libsndfile/examples/list_formats.c Thu May 21 16:09:30 2009
@@ -1,19 +1,33 @@
/*
-** Copyright (C) 2001-2005 Erik de Castro Lopo <erikd at mega-nerd.com>
+** Copyright (C) 2001-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
**
-** This program is free software; you can redistribute it and/or modify
-** it under the terms of the GNU General Public License as published by
-** the Free Software Foundation; either version 2 of the License, or
-** (at your option) any later version.
+** All rights reserved.
**
-** This program is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-** GNU General Public License for more details.
+** Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
**
-** You should have received a copy of the GNU General Public License
-** along with this program; if not, write to the Free Software
-** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the author nor the names of any contributors may be used
+** to endorse or promote products derived from this software without
+** specific prior written permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+** TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+** PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+** CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+** EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+** PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+** OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+** OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+** ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <stdio.h>
@@ -67,10 +81,3 @@
return 0 ;
} /* main */
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: 58127a0c-93a2-46cf-b615-fcb9adacf3f1
-*/
Modified: freeswitch/trunk/libs/libsndfile/examples/make_sine.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/examples/make_sine.c (original)
+++ freeswitch/trunk/libs/libsndfile/examples/make_sine.c Thu May 21 16:09:30 2009
@@ -1,19 +1,33 @@
/*
-** Copyright (C) 1999-2005 Erik de Castro Lopo <erikd at mega-nerd.com>
+** Copyright (C) 1999-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
**
-** This program is free software; you can redistribute it and/or modify
-** it under the terms of the GNU General Public License as published by
-** the Free Software Foundation; either version 2 of the License, or
-** (at your option) any later version.
+** All rights reserved.
**
-** This program is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-** GNU General Public License for more details.
+** Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
**
-** You should have received a copy of the GNU General Public License
-** along with this program; if not, write to the Free Software
-** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the author nor the names of any contributors may be used
+** to endorse or promote products derived from this software without
+** specific prior written permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+** TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+** PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+** CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+** EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+** PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+** OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+** OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+** ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <stdio.h>
@@ -80,10 +94,3 @@
return 0 ;
} /* main */
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: fd945a2c-a306-49ef-a262-6336ced15246
-*/
Modified: freeswitch/trunk/libs/libsndfile/examples/sfprocess.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/examples/sfprocess.c (original)
+++ freeswitch/trunk/libs/libsndfile/examples/sfprocess.c Thu May 21 16:09:30 2009
@@ -1,19 +1,33 @@
/*
-** Copyright (C) 2001-2005 Erik de Castro Lopo <erikd at mega-nerd.com>
+** Copyright (C) 2001-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
**
-** This program is free software; you can redistribute it and/or modify
-** it under the terms of the GNU General Public License as published by
-** the Free Software Foundation; either version 2 of the License, or
-** (at your option) any later version.
+** All rights reserved.
**
-** This program is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-** GNU General Public License for more details.
+** Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
**
-** You should have received a copy of the GNU General Public License
-** along with this program; if not, write to the Free Software
-** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the author nor the names of any contributors may be used
+** to endorse or promote products derived from this software without
+** specific prior written permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+** TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+** PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+** CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+** EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+** PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+** OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+** OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+** ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <stdio.h>
@@ -121,11 +135,3 @@
return ;
} /* process_data */
-
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: de9fdd1e-b807-41ef-9d51-075ba383e536
-*/
Added: freeswitch/trunk/libs/libsndfile/examples/sndfile-to-text.c
==============================================================================
--- (empty file)
+++ freeswitch/trunk/libs/libsndfile/examples/sndfile-to-text.c Thu May 21 16:09:30 2009
@@ -0,0 +1,126 @@
+/*
+** Copyright (C) 2008-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
+**
+** All rights reserved.
+**
+** Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+**
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the author nor the names of any contributors may be used
+** to endorse or promote products derived from this software without
+** specific prior written permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+** TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+** PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+** CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+** EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+** PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+** OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+** OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+** ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+
+#include <sndfile.h>
+
+#define BLOCK_SIZE 512
+
+static void
+print_usage (char *progname)
+{ printf ("\nUsage : %s <input file> <output file>\n", progname) ;
+ puts ("\n"
+ " Where the output file will contain a line for each frame\n"
+ " and a column for each channel.\n"
+ ) ;
+
+} /* print_usage */
+
+static void
+convert_to_text (SNDFILE * infile, FILE * outfile, int channels)
+{ float buf [channels * BLOCK_SIZE] ;
+ int k, m, readcount ;
+
+ while ((readcount = sf_readf_float (infile, buf, BLOCK_SIZE)) > 0)
+ { for (k = 0 ; k < readcount ; k++)
+ { for (m = 0 ; m < channels ; m++)
+ fprintf (outfile, " % 12.10f", buf [k * channels + m]) ;
+ fprintf (outfile, "\n") ;
+ } ;
+ } ;
+
+ return ;
+} /* convert_to_text */
+
+int
+main (int argc, char * argv [])
+{ char *progname, *infilename, *outfilename ;
+ SNDFILE *infile = NULL ;
+ FILE *outfile = NULL ;
+ SF_INFO sfinfo ;
+
+ progname = strrchr (argv [0], '/') ;
+ progname = progname ? progname + 1 : argv [0] ;
+
+ if (argc != 3)
+ { print_usage (progname) ;
+ return 1 ;
+ } ;
+
+ infilename = argv [1] ;
+ outfilename = argv [2] ;
+
+ if (strcmp (infilename, outfilename) == 0)
+ { printf ("Error : Input and output filenames are the same.\n\n") ;
+ print_usage (progname) ;
+ return 1 ;
+ } ;
+
+ if (infilename [0] == '-')
+ { printf ("Error : Input filename (%s) looks like an option.\n\n", infilename) ;
+ print_usage (progname) ;
+ return 1 ;
+ } ;
+
+ if (outfilename [0] == '-')
+ { printf ("Error : Output filename (%s) looks like an option.\n\n", outfilename) ;
+ print_usage (progname) ;
+ return 1 ;
+ } ;
+
+ if ((infile = sf_open (infilename, SFM_READ, &sfinfo)) == NULL)
+ { printf ("Not able to open input file %s.\n", infilename) ;
+ puts (sf_strerror (NULL)) ;
+ return 1 ;
+ } ;
+
+ /* Open the output file. */
+ if ((outfile = fopen (outfilename, "w")) == NULL)
+ { printf ("Not able to open output file %s : %s\n", outfilename, sf_strerror (NULL)) ;
+ return 1 ;
+ } ;
+
+ fprintf (outfile, "# Converted from file %s.\n", infilename) ;
+ fprintf (outfile, "# Channels %d, Sample rate %d\n", sfinfo.channels, sfinfo.samplerate) ;
+
+ convert_to_text (infile, outfile, sfinfo.channels) ;
+
+ sf_close (infile) ;
+ fclose (outfile) ;
+
+ return 0 ;
+} /* main */
+
Added: freeswitch/trunk/libs/libsndfile/examples/sndfilehandle.cc
==============================================================================
--- (empty file)
+++ freeswitch/trunk/libs/libsndfile/examples/sndfilehandle.cc Thu May 21 16:09:30 2009
@@ -0,0 +1,84 @@
+/*
+** Copyright (C) 2007 Erik de Castro Lopo <erikd at mega-nerd.com>
+**
+** This program is free software; you can redistribute it and/or modify
+** it under the terms of the GNU General Public License as published by
+** the Free Software Foundation; either version 2 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#include <cstdio>
+#include <cstring>
+
+#include <sndfile.hh>
+
+#define BUFFER_LEN 1024
+
+static void
+create_file (const char * fname, int format)
+{ static short buffer [BUFFER_LEN] ;
+
+ SndfileHandle file ;
+ int channels = 2 ;
+ int srate = 48000 ;
+
+ printf ("Creating file named '%s'\n", fname) ;
+
+ file = SndfileHandle (fname, SFM_WRITE, format, channels, srate) ;
+
+ memset (buffer, 0, sizeof (buffer)) ;
+
+ file.write (buffer, BUFFER_LEN) ;
+
+ puts ("") ;
+ /*
+ ** The SndfileHandle object will automatically close the file and
+ ** release all allocated memory when the object goes out of scope.
+ ** This is the Resource Acquisition Is Initailization idom.
+ ** See : http://en.wikipedia.org/wiki/Resource_Acquisition_Is_Initialization
+ */
+} /* create_file */
+
+static void
+read_file (const char * fname)
+{ static short buffer [BUFFER_LEN] ;
+
+ SndfileHandle file ;
+
+ file = SndfileHandle (fname) ;
+
+ printf ("Opened file '%s'\n", fname) ;
+ printf (" Sample rate : %d\n", file.samplerate ()) ;
+ printf (" Channels : %d\n", file.channels ()) ;
+
+ file.read (buffer, BUFFER_LEN) ;
+
+ puts ("") ;
+
+ /* RAII takes care of destroying SndfileHandle object. */
+} /* read_file */
+
+int
+main (void)
+{ const char * fname = "test.wav" ;
+
+ puts ("\nSimple example showing usage of the C++ SndfileHandle object.\n") ;
+
+ create_file (fname, SF_FORMAT_WAV | SF_FORMAT_PCM_16) ;
+
+ read_file (fname) ;
+
+ puts ("Done.\n") ;
+ return 0 ;
+} /* main */
+
+
Modified: freeswitch/trunk/libs/libsndfile/man/Makefile.am
==============================================================================
--- freeswitch/trunk/libs/libsndfile/man/Makefile.am (original)
+++ freeswitch/trunk/libs/libsndfile/man/Makefile.am Thu May 21 16:09:30 2009
@@ -4,9 +4,3 @@
EXTRA_DIST = sndfile-info.1 sndfile-play.1 sndfile-convert.1
-## Do not edit or modify anything in this comment block.
-## The arch-tag line is a file identity tag for the GNU Arch
-## revision control system.
-##
-## arch-tag: a7e49b1a-d2f1-414d-aa5a-3a91ef566d9f
-
Modified: freeswitch/trunk/libs/libsndfile/man/sndfile-convert.1
==============================================================================
--- freeswitch/trunk/libs/libsndfile/man/sndfile-convert.1 (original)
+++ freeswitch/trunk/libs/libsndfile/man/sndfile-convert.1 Thu May 21 16:09:30 2009
@@ -20,9 +20,3 @@
.SH AUTHOR
This manual page was written by Erik de Castro Lopo <erikd at mega-nerd.com>.
-.\" Do not edit or modify anything in this comment block.
-.\" The following line is a file identity tag for the GNU Arch
-.\" revision control system.
-
-.\" arch-tag: 23aa443e-f38d-488b-b7e3-290fc5c77d20
-
Modified: freeswitch/trunk/libs/libsndfile/man/sndfile-info.1
==============================================================================
--- freeswitch/trunk/libs/libsndfile/man/sndfile-info.1 (original)
+++ freeswitch/trunk/libs/libsndfile/man/sndfile-info.1 Thu May 21 16:09:30 2009
@@ -14,9 +14,3 @@
others). Further additions have been made by Erik de Castro Lopo
<erikd at mega-nerd.com>.
-.\" Do not edit or modify anything in this comment block.
-.\" The following line is a file identity tag for the GNU Arch
-.\" revision control system.
-
-.\" arch-tag: f9eca35e-5519-434d-bc55-fe845df977cd
-
Modified: freeswitch/trunk/libs/libsndfile/man/sndfile-play.1
==============================================================================
--- freeswitch/trunk/libs/libsndfile/man/sndfile-play.1 (original)
+++ freeswitch/trunk/libs/libsndfile/man/sndfile-play.1 Thu May 21 16:09:30 2009
@@ -20,6 +20,7 @@
.SH DESCRIPTION
sndfile-play plays the specified sound file using :
.EX
+ALSA on Linux
/dev/dsp on systems supporting OSS (including Linux)
/dev/audio on Sun Solaris
CoreAudio on Apple MacOSX
@@ -33,8 +34,3 @@
others). Further additions have been made by Erik de Castro Lopo
<erikd at mega-nerd.com>.
-.\" Do not edit or modify anything in this comment block.
-.\" The arch-tag line is a file identity tag for the GNU Arch
-.\" revision control system.
-
-.\" arch-tag: 5a0120d9-040c-464e-b01e-89dc2c2428c9
Added: freeswitch/trunk/libs/libsndfile/programs/Makefile.am
==============================================================================
--- (empty file)
+++ freeswitch/trunk/libs/libsndfile/programs/Makefile.am Thu May 21 16:09:30 2009
@@ -0,0 +1,36 @@
+## Process this file with automake to produce Makefile.in
+
+bin_PROGRAMS = sndfile-info sndfile-play sndfile-convert sndfile-jackplay sndfile-cmp \
+ sndfile-metadata-set sndfile-metadata-get
+
+OS_SPECIFIC_CFLAGS = @OS_SPECIFIC_CFLAGS@
+OS_SPECIFIC_LINKS = @OS_SPECIFIC_LINKS@
+
+INCLUDES = -I$(top_srcdir)/src $(OS_SPECIFIC_CFLAGS)
+
+# This is the BeOS version of sndfile-play. It needs to be compiled with the C++
+# compiler.
+EXTRA_DIST = sndfile-play-beos.cpp test-sndfile-metadata-set.py
+
+sndfile_info_SOURCES = sndfile-info.c
+sndfile_info_LDADD = $(top_builddir)/src/libsndfile.la
+
+sndfile_play_SOURCES = sndfile-play.c
+sndfile_play_LDADD = $(top_builddir)/src/libsndfile.la $(OS_SPECIFIC_LINKS) $(ALSA_LIBS)
+
+sndfile_jackplay_SOURCES = sndfile-jackplay.c
+sndfile_jackplay_CFLAGS = $(JACK_CFLAGS)
+sndfile_jackplay_LDADD = $(top_builddir)/src/libsndfile.la $(JACK_LIBS)
+
+sndfile_convert_SOURCES = sndfile-convert.c common.c common.h
+sndfile_convert_LDADD = $(top_builddir)/src/libsndfile.la
+
+sndfile_cmp_SOURCES = sndfile-cmp.c
+sndfile_cmp_LDADD = $(top_builddir)/src/libsndfile.la
+
+sndfile_metadata_set_SOURCES = sndfile-metadata-set.c common.c common.h
+sndfile_metadata_set_LDADD = $(top_builddir)/src/libsndfile.la
+
+sndfile_metadata_get_SOURCES = sndfile-metadata-get.c
+sndfile_metadata_get_LDADD = $(top_builddir)/src/libsndfile.la
+
Added: freeswitch/trunk/libs/libsndfile/programs/Makefile.in
==============================================================================
--- (empty file)
+++ freeswitch/trunk/libs/libsndfile/programs/Makefile.in Thu May 21 16:09:30 2009
@@ -0,0 +1,620 @@
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+ at SET_MAKE@
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+target_triplet = @target@
+bin_PROGRAMS = sndfile-info$(EXEEXT) sndfile-play$(EXEEXT) \
+ sndfile-convert$(EXEEXT) sndfile-jackplay$(EXEEXT) \
+ sndfile-cmp$(EXEEXT) sndfile-metadata-set$(EXEEXT) \
+ sndfile-metadata-get$(EXEEXT)
+subdir = programs
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/M4/add_cflags.m4 \
+ $(top_srcdir)/M4/add_cxxflags.m4 $(top_srcdir)/M4/clip_mode.m4 \
+ $(top_srcdir)/M4/endian.m4 $(top_srcdir)/M4/extra_largefile.m4 \
+ $(top_srcdir)/M4/extra_pkg.m4 \
+ $(top_srcdir)/M4/flexible_array.m4 \
+ $(top_srcdir)/M4/gcc_version.m4 $(top_srcdir)/M4/libtool.m4 \
+ $(top_srcdir)/M4/lrint.m4 $(top_srcdir)/M4/lrintf.m4 \
+ $(top_srcdir)/M4/ltoptions.m4 $(top_srcdir)/M4/ltsugar.m4 \
+ $(top_srcdir)/M4/ltversion.m4 $(top_srcdir)/M4/lt~obsolete.m4 \
+ $(top_srcdir)/M4/mkoctfile_version.m4 \
+ $(top_srcdir)/M4/octave.m4 $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/src/config.h
+CONFIG_CLEAN_FILES =
+am__installdirs = "$(DESTDIR)$(bindir)"
+binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
+PROGRAMS = $(bin_PROGRAMS)
+am_sndfile_cmp_OBJECTS = sndfile-cmp.$(OBJEXT)
+sndfile_cmp_OBJECTS = $(am_sndfile_cmp_OBJECTS)
+sndfile_cmp_DEPENDENCIES = $(top_builddir)/src/libsndfile.la
+am_sndfile_convert_OBJECTS = sndfile-convert.$(OBJEXT) \
+ common.$(OBJEXT)
+sndfile_convert_OBJECTS = $(am_sndfile_convert_OBJECTS)
+sndfile_convert_DEPENDENCIES = $(top_builddir)/src/libsndfile.la
+am_sndfile_info_OBJECTS = sndfile-info.$(OBJEXT)
+sndfile_info_OBJECTS = $(am_sndfile_info_OBJECTS)
+sndfile_info_DEPENDENCIES = $(top_builddir)/src/libsndfile.la
+am_sndfile_jackplay_OBJECTS = \
+ sndfile_jackplay-sndfile-jackplay.$(OBJEXT)
+sndfile_jackplay_OBJECTS = $(am_sndfile_jackplay_OBJECTS)
+am__DEPENDENCIES_1 =
+sndfile_jackplay_DEPENDENCIES = $(top_builddir)/src/libsndfile.la \
+ $(am__DEPENDENCIES_1)
+sndfile_jackplay_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(sndfile_jackplay_CFLAGS) \
+ $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+am_sndfile_metadata_get_OBJECTS = sndfile-metadata-get.$(OBJEXT)
+sndfile_metadata_get_OBJECTS = $(am_sndfile_metadata_get_OBJECTS)
+sndfile_metadata_get_DEPENDENCIES = $(top_builddir)/src/libsndfile.la
+am_sndfile_metadata_set_OBJECTS = sndfile-metadata-set.$(OBJEXT) \
+ common.$(OBJEXT)
+sndfile_metadata_set_OBJECTS = $(am_sndfile_metadata_set_OBJECTS)
+sndfile_metadata_set_DEPENDENCIES = $(top_builddir)/src/libsndfile.la
+am_sndfile_play_OBJECTS = sndfile-play.$(OBJEXT)
+sndfile_play_OBJECTS = $(am_sndfile_play_OBJECTS)
+sndfile_play_DEPENDENCIES = $(top_builddir)/src/libsndfile.la \
+ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
+DEFAULT_INCLUDES = -I. at am__isrc@ -I$(top_builddir)/src
+depcomp = $(SHELL) $(top_srcdir)/Cfg/depcomp
+am__depfiles_maybe = depfiles
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+ $(LDFLAGS) -o $@
+SOURCES = $(sndfile_cmp_SOURCES) $(sndfile_convert_SOURCES) \
+ $(sndfile_info_SOURCES) $(sndfile_jackplay_SOURCES) \
+ $(sndfile_metadata_get_SOURCES) \
+ $(sndfile_metadata_set_SOURCES) $(sndfile_play_SOURCES)
+DIST_SOURCES = $(sndfile_cmp_SOURCES) $(sndfile_convert_SOURCES) \
+ $(sndfile_info_SOURCES) $(sndfile_jackplay_SOURCES) \
+ $(sndfile_metadata_get_SOURCES) \
+ $(sndfile_metadata_set_SOURCES) $(sndfile_play_SOURCES)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+ACLOCAL_AMFLAGS = @ACLOCAL_AMFLAGS@
+ALSA_LIBS = @ALSA_LIBS@
+AMTAR = @AMTAR@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+COMPILER_IS_GCC = @COMPILER_IS_GCC@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+ENABLE_EXPERIMENTAL_CODE = @ENABLE_EXPERIMENTAL_CODE@
+EXEEXT = @EXEEXT@
+EXTERNAL_CFLAGS = @EXTERNAL_CFLAGS@
+EXTERNAL_LIBS = @EXTERNAL_LIBS@
+FGREP = @FGREP@
+FLAC_CFLAGS = @FLAC_CFLAGS@
+FLAC_LIBS = @FLAC_LIBS@
+GCC_MAJOR_VERSION = @GCC_MAJOR_VERSION@
+GCC_MINOR_VERSION = @GCC_MINOR_VERSION@
+GCC_VERSION = @GCC_VERSION@
+GETCONF = @GETCONF@
+GREP = @GREP@
+HAVE_AUTOGEN = @HAVE_AUTOGEN@
+HAVE_JACK = @HAVE_JACK@
+HAVE_MKOCTFILE = @HAVE_MKOCTFILE@
+HAVE_OCTAVE = @HAVE_OCTAVE@
+HAVE_OCTAVE_CONFIG = @HAVE_OCTAVE_CONFIG@
+HAVE_WINE = @HAVE_WINE@
+HTML_BGCOLOUR = @HTML_BGCOLOUR@
+HTML_FGCOLOUR = @HTML_FGCOLOUR@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+JACK_CFLAGS = @JACK_CFLAGS@
+JACK_LIBS = @JACK_LIBS@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIBTOOL_DEPS = @LIBTOOL_DEPS@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+MKOCTFILE = @MKOCTFILE@
+MKOCTFILE_VERSION = @MKOCTFILE_VERSION@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OCTAVE = @OCTAVE@
+OCTAVE_CONFIG = @OCTAVE_CONFIG@
+OCTAVE_CONFIG_VERSION = @OCTAVE_CONFIG_VERSION@
+OCTAVE_DEST_MDIR = @OCTAVE_DEST_MDIR@
+OCTAVE_DEST_ODIR = @OCTAVE_DEST_ODIR@
+OCTAVE_VERSION = @OCTAVE_VERSION@
+OGG_CFLAGS = @OGG_CFLAGS@
+OGG_LIBS = @OGG_LIBS@
+OS_SPECIFIC_CFLAGS = @OS_SPECIFIC_CFLAGS@
+OS_SPECIFIC_LINKS = @OS_SPECIFIC_LINKS@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PKG_CONFIG = @PKG_CONFIG@
+RANLIB = @RANLIB@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SF_COUNT_MAX = @SF_COUNT_MAX@
+SHARED_VERSION_INFO = @SHARED_VERSION_INFO@
+SHELL = @SHELL@
+SHLIB_VERSION_ARG = @SHLIB_VERSION_ARG@
+SIZEOF_SF_COUNT_T = @SIZEOF_SF_COUNT_T@
+SQLITE3_CFLAGS = @SQLITE3_CFLAGS@
+SQLITE3_LIBS = @SQLITE3_LIBS@
+STRIP = @STRIP@
+TYPEOF_SF_COUNT_T = @TYPEOF_SF_COUNT_T@
+VERSION = @VERSION@
+VORBISENC_CFLAGS = @VORBISENC_CFLAGS@
+VORBISENC_LIBS = @VORBISENC_LIBS@
+VORBIS_CFLAGS = @VORBIS_CFLAGS@
+VORBIS_LIBS = @VORBIS_LIBS@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+htmldocdir = @htmldocdir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+lt_ECHO = @lt_ECHO@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target = @target@
+target_alias = @target_alias@
+target_cpu = @target_cpu@
+target_os = @target_os@
+target_vendor = @target_vendor@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+INCLUDES = -I$(top_srcdir)/src $(OS_SPECIFIC_CFLAGS)
+
+# This is the BeOS version of sndfile-play. It needs to be compiled with the C++
+# compiler.
+EXTRA_DIST = sndfile-play-beos.cpp test-sndfile-metadata-set.py
+sndfile_info_SOURCES = sndfile-info.c
+sndfile_info_LDADD = $(top_builddir)/src/libsndfile.la
+sndfile_play_SOURCES = sndfile-play.c
+sndfile_play_LDADD = $(top_builddir)/src/libsndfile.la $(OS_SPECIFIC_LINKS) $(ALSA_LIBS)
+sndfile_jackplay_SOURCES = sndfile-jackplay.c
+sndfile_jackplay_CFLAGS = $(JACK_CFLAGS)
+sndfile_jackplay_LDADD = $(top_builddir)/src/libsndfile.la $(JACK_LIBS)
+sndfile_convert_SOURCES = sndfile-convert.c common.c common.h
+sndfile_convert_LDADD = $(top_builddir)/src/libsndfile.la
+sndfile_cmp_SOURCES = sndfile-cmp.c
+sndfile_cmp_LDADD = $(top_builddir)/src/libsndfile.la
+sndfile_metadata_set_SOURCES = sndfile-metadata-set.c common.c common.h
+sndfile_metadata_set_LDADD = $(top_builddir)/src/libsndfile.la
+sndfile_metadata_get_SOURCES = sndfile-metadata-get.c
+sndfile_metadata_get_LDADD = $(top_builddir)/src/libsndfile.la
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
+ && exit 0; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu programs/Makefile'; \
+ cd $(top_srcdir) && \
+ $(AUTOMAKE) --gnu programs/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+install-binPROGRAMS: $(bin_PROGRAMS)
+ @$(NORMAL_INSTALL)
+ test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)"
+ @list='$(bin_PROGRAMS)'; for p in $$list; do \
+ p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
+ if test -f $$p \
+ || test -f $$p1 \
+ ; then \
+ f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
+ echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \
+ $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \
+ else :; fi; \
+ done
+
+uninstall-binPROGRAMS:
+ @$(NORMAL_UNINSTALL)
+ @list='$(bin_PROGRAMS)'; for p in $$list; do \
+ f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
+ echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \
+ rm -f "$(DESTDIR)$(bindir)/$$f"; \
+ done
+
+clean-binPROGRAMS:
+ @list='$(bin_PROGRAMS)'; for p in $$list; do \
+ f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
+ echo " rm -f $$p $$f"; \
+ rm -f $$p $$f ; \
+ done
+sndfile-cmp$(EXEEXT): $(sndfile_cmp_OBJECTS) $(sndfile_cmp_DEPENDENCIES)
+ @rm -f sndfile-cmp$(EXEEXT)
+ $(LINK) $(sndfile_cmp_OBJECTS) $(sndfile_cmp_LDADD) $(LIBS)
+sndfile-convert$(EXEEXT): $(sndfile_convert_OBJECTS) $(sndfile_convert_DEPENDENCIES)
+ @rm -f sndfile-convert$(EXEEXT)
+ $(LINK) $(sndfile_convert_OBJECTS) $(sndfile_convert_LDADD) $(LIBS)
+sndfile-info$(EXEEXT): $(sndfile_info_OBJECTS) $(sndfile_info_DEPENDENCIES)
+ @rm -f sndfile-info$(EXEEXT)
+ $(LINK) $(sndfile_info_OBJECTS) $(sndfile_info_LDADD) $(LIBS)
+sndfile-jackplay$(EXEEXT): $(sndfile_jackplay_OBJECTS) $(sndfile_jackplay_DEPENDENCIES)
+ @rm -f sndfile-jackplay$(EXEEXT)
+ $(sndfile_jackplay_LINK) $(sndfile_jackplay_OBJECTS) $(sndfile_jackplay_LDADD) $(LIBS)
+sndfile-metadata-get$(EXEEXT): $(sndfile_metadata_get_OBJECTS) $(sndfile_metadata_get_DEPENDENCIES)
+ @rm -f sndfile-metadata-get$(EXEEXT)
+ $(LINK) $(sndfile_metadata_get_OBJECTS) $(sndfile_metadata_get_LDADD) $(LIBS)
+sndfile-metadata-set$(EXEEXT): $(sndfile_metadata_set_OBJECTS) $(sndfile_metadata_set_DEPENDENCIES)
+ @rm -f sndfile-metadata-set$(EXEEXT)
+ $(LINK) $(sndfile_metadata_set_OBJECTS) $(sndfile_metadata_set_LDADD) $(LIBS)
+sndfile-play$(EXEEXT): $(sndfile_play_OBJECTS) $(sndfile_play_DEPENDENCIES)
+ @rm -f sndfile-play$(EXEEXT)
+ $(LINK) $(sndfile_play_OBJECTS) $(sndfile_play_LDADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/common.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/sndfile-cmp.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/sndfile-convert.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/sndfile-info.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/sndfile-metadata-get.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/sndfile-metadata-set.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/sndfile-play.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/sndfile_jackplay-sndfile-jackplay.Po at am__quote@
+
+.c.o:
+ at am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+ at am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCC_FALSE@ $(COMPILE) -c $<
+
+.c.obj:
+ at am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+ at am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+ at am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+ at am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
+
+sndfile_jackplay-sndfile-jackplay.o: sndfile-jackplay.c
+ at am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(sndfile_jackplay_CFLAGS) $(CFLAGS) -MT sndfile_jackplay-sndfile-jackplay.o -MD -MP -MF $(DEPDIR)/sndfile_jackplay-sndfile-jackplay.Tpo -c -o sndfile_jackplay-sndfile-jackplay.o `test -f 'sndfile-jackplay.c' || echo '$(srcdir)/'`sndfile-jackplay.c
+ at am__fastdepCC_TRUE@ mv -f $(DEPDIR)/sndfile_jackplay-sndfile-jackplay.Tpo $(DEPDIR)/sndfile_jackplay-sndfile-jackplay.Po
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@ source='sndfile-jackplay.c' object='sndfile_jackplay-sndfile-jackplay.o' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(sndfile_jackplay_CFLAGS) $(CFLAGS) -c -o sndfile_jackplay-sndfile-jackplay.o `test -f 'sndfile-jackplay.c' || echo '$(srcdir)/'`sndfile-jackplay.c
+
+sndfile_jackplay-sndfile-jackplay.obj: sndfile-jackplay.c
+ at am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(sndfile_jackplay_CFLAGS) $(CFLAGS) -MT sndfile_jackplay-sndfile-jackplay.obj -MD -MP -MF $(DEPDIR)/sndfile_jackplay-sndfile-jackplay.Tpo -c -o sndfile_jackplay-sndfile-jackplay.obj `if test -f 'sndfile-jackplay.c'; then $(CYGPATH_W) 'sndfile-jackplay.c'; else $(CYGPATH_W) '$(srcdir)/sndfile-jackplay.c'; fi`
+ at am__fastdepCC_TRUE@ mv -f $(DEPDIR)/sndfile_jackplay-sndfile-jackplay.Tpo $(DEPDIR)/sndfile_jackplay-sndfile-jackplay.Po
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@ source='sndfile-jackplay.c' object='sndfile_jackplay-sndfile-jackplay.obj' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(sndfile_jackplay_CFLAGS) $(CFLAGS) -c -o sndfile_jackplay-sndfile-jackplay.obj `if test -f 'sndfile-jackplay.c'; then $(CYGPATH_W) 'sndfile-jackplay.c'; else $(CYGPATH_W) '$(srcdir)/sndfile-jackplay.c'; fi`
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ mkid -fID $$unique
+tags: TAGS
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$tags $$unique; \
+ fi
+ctags: CTAGS
+CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ test -z "$(CTAGS_ARGS)$$tags$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$tags $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && cd $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+ fi; \
+ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+ else \
+ test -f $(distdir)/$$file \
+ || cp -p $$d/$$file $(distdir)/$$file \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-am
+all-am: Makefile $(PROGRAMS)
+installdirs:
+ for dir in "$(DESTDIR)$(bindir)"; do \
+ test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+ done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-binPROGRAMS clean-generic clean-libtool mostlyclean-am
+
+distclean: distclean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-exec-am: install-binPROGRAMS
+
+install-html: install-html-am
+
+install-info: install-info-am
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-ps: install-ps-am
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-binPROGRAMS
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \
+ clean-generic clean-libtool ctags distclean distclean-compile \
+ distclean-generic distclean-libtool distclean-tags distdir dvi \
+ dvi-am html html-am info info-am install install-am \
+ install-binPROGRAMS install-data install-data-am install-dvi \
+ install-dvi-am install-exec install-exec-am install-html \
+ install-html-am install-info install-info-am install-man \
+ install-pdf install-pdf-am install-ps install-ps-am \
+ install-strip installcheck installcheck-am installdirs \
+ maintainer-clean maintainer-clean-generic mostlyclean \
+ mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
+ pdf pdf-am ps ps-am tags uninstall uninstall-am \
+ uninstall-binPROGRAMS
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
Added: freeswitch/trunk/libs/libsndfile/programs/common.c
==============================================================================
--- (empty file)
+++ freeswitch/trunk/libs/libsndfile/programs/common.c Thu May 21 16:09:30 2009
@@ -0,0 +1,266 @@
+/*
+** Copyright (C) 1999-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
+** Copyright (C) 2008 George Blood Audio
+**
+** All rights reserved.
+**
+** Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+**
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the author nor the names of any contributors may be used
+** to endorse or promote products derived from this software without
+** specific prior written permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+** TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+** PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+** CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+** EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+** PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+** OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+** OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+** ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+
+#include <sndfile.h>
+
+#include "common.h"
+
+#define BUFFER_LEN 4096
+
+#define MIN(x,y) ((x) < (y) ? (x) : (y))
+
+void
+sfe_copy_data_fp (SNDFILE *outfile, SNDFILE *infile, int channels)
+{ static double data [BUFFER_LEN], max ;
+ int frames, readcount, k ;
+
+ frames = BUFFER_LEN / channels ;
+ readcount = frames ;
+
+ sf_command (infile, SFC_CALC_SIGNAL_MAX, &max, sizeof (max)) ;
+
+ if (max < 1.0)
+ { while (readcount > 0)
+ { readcount = sf_readf_double (infile, data, frames) ;
+ sf_writef_double (outfile, data, readcount) ;
+ } ;
+ }
+ else
+ { sf_command (infile, SFC_SET_NORM_DOUBLE, NULL, SF_FALSE) ;
+
+ while (readcount > 0)
+ { readcount = sf_readf_double (infile, data, frames) ;
+ for (k = 0 ; k < readcount * channels ; k++)
+ data [k] /= max ;
+ sf_writef_double (outfile, data, readcount) ;
+ } ;
+ } ;
+
+ return ;
+} /* sfe_copy_data_fp */
+
+void
+sfe_copy_data_int (SNDFILE *outfile, SNDFILE *infile, int channels)
+{ static int data [BUFFER_LEN] ;
+ int frames, readcount ;
+
+ frames = BUFFER_LEN / channels ;
+ readcount = frames ;
+
+ while (readcount > 0)
+ { readcount = sf_readf_int (infile, data, frames) ;
+ sf_writef_int (outfile, data, readcount) ;
+ } ;
+
+ return ;
+} /* sfe_copy_data_int */
+
+/*==============================================================================
+*/
+
+static int
+merge_broadcast_info (SNDFILE * infile, SNDFILE * outfile, int format, const METADATA_INFO * info)
+{ SF_BROADCAST_INFO_2K binfo ;
+ int infileminor ;
+
+ memset (&binfo, 0, sizeof (binfo)) ;
+
+ if ((SF_FORMAT_TYPEMASK & format) != SF_FORMAT_WAV)
+ { printf ("Error : This is not a WAV file and hence broadcast info cannot be added to it.\n\n") ;
+ return 1 ;
+ } ;
+
+ infileminor = SF_FORMAT_SUBMASK & format ;
+
+ switch (infileminor)
+ { case SF_FORMAT_PCM_16 :
+ case SF_FORMAT_PCM_24 :
+ case SF_FORMAT_PCM_32 :
+ break ;
+
+ default :
+ printf (
+ "Warning : The EBU Technical Recommendation R68-2000 states that the only\n"
+ " allowed encodings are Linear PCM and MPEG3. This file is not in\n"
+ " the right format.\n\n"
+ ) ;
+ break ;
+ } ;
+
+ if (sf_command (infile, SFC_GET_BROADCAST_INFO, &binfo, sizeof (binfo)) == 0)
+ { if (infile == outfile)
+ { printf (
+ "Error : Attempting in-place broadcast info update, but file does not\n"
+ " have a 'bext' chunk to modify. The solution is to specify both\n"
+ " input and output files on the command line.\n\n"
+ ) ;
+ return 1 ;
+ } ;
+ } ;
+
+#define REPLACE_IF_NEW(x) \
+ if (info->x != NULL) \
+ { memset (binfo.x, 0, sizeof (binfo.x)) ; \
+ memcpy (binfo.x, info->x, MIN (strlen (info->x), sizeof (binfo.x))) ; \
+ } ;
+
+ REPLACE_IF_NEW (description) ;
+ REPLACE_IF_NEW (originator) ;
+ REPLACE_IF_NEW (originator_reference) ;
+ REPLACE_IF_NEW (origination_date) ;
+ REPLACE_IF_NEW (origination_time) ;
+ REPLACE_IF_NEW (umid) ;
+
+ /* Special case for coding_history because we may want to append. */
+ if (info->coding_history != NULL)
+ { if (info->coding_hist_append)
+ { int slen = strlen (binfo.coding_history) ;
+
+ while (slen > 1 && isspace (binfo.coding_history [slen - 1]))
+ slen -- ;
+
+ memcpy (binfo.coding_history + slen, info->coding_history, sizeof (binfo.coding_history) - slen) ;
+ }
+ else
+ { size_t slen = MIN (strlen (info->coding_history), sizeof (binfo.coding_history)) ;
+
+ memset (binfo.coding_history, 0, sizeof (binfo.coding_history)) ;
+ memcpy (binfo.coding_history, info->coding_history, slen) ;
+ binfo.coding_history_size = slen ;
+ } ;
+ } ;
+
+ if (sf_command (outfile, SFC_SET_BROADCAST_INFO, &binfo, sizeof (binfo)) == 0)
+ { printf ("Error : Setting of broadcast info chunks failed.\n\n") ;
+ return 1 ;
+ } ;
+
+ return 0 ;
+} /* merge_broadcast_info*/
+
+static void
+update_strings (SNDFILE * outfile, const METADATA_INFO * info)
+{
+ if (info->title != NULL)
+ sf_set_string (outfile, SF_STR_TITLE, info->title) ;
+
+ if (info->copyright != NULL)
+ sf_set_string (outfile, SF_STR_TITLE, info->copyright) ;
+
+ if (info->artist != NULL)
+ sf_set_string (outfile, SF_STR_ARTIST, info->artist) ;
+
+ if (info->comment != NULL)
+ sf_set_string (outfile, SF_STR_TITLE, info->comment) ;
+
+ if (info->date != NULL)
+ sf_set_string (outfile, SF_STR_DATE, info->date) ;
+
+ if (info->album != NULL)
+ sf_set_string (outfile, SF_STR_TITLE, info->album) ;
+
+ if (info->license != NULL)
+ sf_set_string (outfile, SF_STR_TITLE, info->license) ;
+
+} /* update_strings */
+
+
+
+void
+sfe_apply_metadata_changes (const char * filenames [2], const METADATA_INFO * info)
+{ SNDFILE *infile = NULL, *outfile = NULL ;
+ SF_INFO sfinfo ;
+ METADATA_INFO tmpinfo ;
+ int error_code = 0 ;
+
+ memset (&sfinfo, 0, sizeof (sfinfo)) ;
+ memset (&tmpinfo, 0, sizeof (tmpinfo)) ;
+
+ if (filenames [1] == NULL)
+ infile = outfile = sf_open (filenames [0], SFM_RDWR, &sfinfo) ;
+ else
+ { infile = sf_open (filenames [0], SFM_READ, &sfinfo) ;
+
+ /* Output must be WAV. */
+ sfinfo.format = SF_FORMAT_WAV | (SF_FORMAT_SUBMASK & sfinfo.format) ;
+ outfile = sf_open (filenames [1], SFM_WRITE, &sfinfo) ;
+ } ;
+
+ if (infile == NULL)
+ { printf ("Error : Not able to open input file '%s' : %s\n", filenames [0], sf_strerror (infile)) ;
+ error_code = 1 ;
+ goto cleanup_exit ;
+ } ;
+
+ if (outfile == NULL)
+ { printf ("Error : Not able to open output file '%s' : %s\n", filenames [1], sf_strerror (outfile)) ;
+ error_code = 1 ;
+ goto cleanup_exit ;
+ } ;
+
+ if (info->has_bext_fields && merge_broadcast_info (infile, outfile, sfinfo.format, info))
+ { error_code = 1 ;
+ goto cleanup_exit ;
+ } ;
+
+ update_strings (outfile, info) ;
+
+ if (infile != outfile)
+ { int infileminor = SF_FORMAT_SUBMASK & sfinfo.format ;
+
+ /* If the input file is not the same as the output file, copy the data. */
+ if ((infileminor == SF_FORMAT_DOUBLE) || (infileminor == SF_FORMAT_FLOAT))
+ sfe_copy_data_fp (outfile, infile, sfinfo.channels) ;
+ else
+ sfe_copy_data_int (outfile, infile, sfinfo.channels) ;
+ } ;
+
+cleanup_exit :
+
+ if (outfile != NULL && outfile != infile)
+ sf_close (outfile) ;
+
+ if (infile != NULL)
+ sf_close (infile) ;
+
+ if (error_code)
+ exit (error_code) ;
+
+ return ;
+} /* sfe_apply_metadata_changes */
+
Added: freeswitch/trunk/libs/libsndfile/programs/common.h
==============================================================================
--- (empty file)
+++ freeswitch/trunk/libs/libsndfile/programs/common.h Thu May 21 16:09:30 2009
@@ -0,0 +1,64 @@
+/*
+** Copyright (C) 1999-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
+**
+** All rights reserved.
+**
+** Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+**
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the author nor the names of any contributors may be used
+** to endorse or promote products derived from this software without
+** specific prior written permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+** TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+** PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+** CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+** EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+** PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+** OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+** OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+** ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#include <sndfile.h>
+
+typedef struct
+{ const char * title ;
+ const char * copyright ;
+ const char * artist ;
+ const char * comment ;
+ const char * date ;
+ const char * album ;
+ const char * license ;
+
+
+ /* Stuff to go in the 'bext' chunk of WAV files. */
+ int has_bext_fields ;
+ int coding_hist_append ;
+
+ const char * description ;
+ const char * originator ;
+ const char * originator_reference ;
+ const char * origination_date ;
+ const char * origination_time ;
+ const char * umid ;
+ const char * coding_history ;
+} METADATA_INFO ;
+
+typedef SF_BROADCAST_INFO_VAR (2048) SF_BROADCAST_INFO_2K ;
+
+void sfe_apply_metadata_changes (const char * filenames [2], const METADATA_INFO * info) ;
+
+void sfe_copy_data_fp (SNDFILE *outfile, SNDFILE *infile, int channels) ;
+
+void sfe_copy_data_int (SNDFILE *outfile, SNDFILE *infile, int channels) ;
Added: freeswitch/trunk/libs/libsndfile/programs/sndfile-cmp.c
==============================================================================
--- (empty file)
+++ freeswitch/trunk/libs/libsndfile/programs/sndfile-cmp.c Thu May 21 16:09:30 2009
@@ -0,0 +1,159 @@
+/*
+** Copyright (C) 2008-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
+**
+** All rights reserved.
+**
+** Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+**
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the author nor the names of any contributors may be used
+** to endorse or promote products derived from this software without
+** specific prior written permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+** TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+** PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+** CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+** EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+** PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+** OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+** OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+** ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+/* sndfile-cmp.c
+ * Conrad Parker 2008
+ */
+
+
+#include "sfconfig.h"
+
+#include <stdio.h>
+#include <string.h>
+
+#include <sndfile.h>
+
+/* Length of comparison data buffers in units of items */
+#define BUFLEN 65536
+
+static char * progname ;
+static char * filename1, * filename2 ;
+
+static int
+comparison_error (const char * what)
+{ printf ("%s: %s of files %s and %s differ\n", progname, what, filename1, filename2) ;
+ return 1 ;
+} /* comparison_error */
+
+static int
+compare (void)
+{
+ double buf1 [BUFLEN], buf2 [BUFLEN] ;
+ SF_INFO sfinfo1, sfinfo2 ;
+ SNDFILE * sf1 = NULL, * sf2 = NULL ;
+ sf_count_t len, i, nread1, nread2 ;
+ int retval = 0 ;
+
+ memset (&sfinfo1, 0, sizeof (SF_INFO)) ;
+ sf1 = sf_open (filename1, SFM_READ, &sfinfo1) ;
+ if (sf1 == NULL)
+ { printf ("Error opening %s.\n", filename1) ;
+ retval = 1 ;
+ goto out ;
+ } ;
+
+ memset (&sfinfo2, 0, sizeof (SF_INFO)) ;
+ sf2 = sf_open (filename2, SFM_READ, &sfinfo2) ;
+ if (sf2 == NULL)
+ { printf ("Error opening %s.\n", filename2) ;
+ retval = 1 ;
+ goto out ;
+ } ;
+
+ if (sfinfo1.samplerate != sfinfo2.samplerate)
+ { retval = comparison_error ("Samplerates") ;
+ goto out ;
+ } ;
+
+ if (sfinfo1.channels != sfinfo2.channels)
+ { retval = comparison_error ("Number of channels") ;
+ goto out ;
+ } ;
+
+ /* Calculate the framecount that will fit in our data buffers */
+ len = BUFLEN / sfinfo1.channels ;
+
+ while ( (nread1 = sf_readf_double (sf1, buf1, len)) > 0)
+ { nread2 = sf_readf_double (sf2, buf2, nread1) ;
+ if (nread2 != nread1)
+ { retval = comparison_error ("PCM data lengths") ;
+ goto out ;
+ } ;
+ for (i = 0 ; i < nread1 ; i++)
+ { if (buf1 [i] != buf2 [i])
+ { retval = comparison_error ("PCM data") ;
+ goto out ;
+ } ;
+ } ;
+ } ;
+
+ if ( (nread2 = sf_readf_double (sf2, buf2, nread1)) != 0)
+ { retval = comparison_error ("PCM data lengths") ;
+ goto out ;
+ } ;
+
+out :
+ sf_close (sf1) ;
+ sf_close (sf2) ;
+
+ return retval ;
+} /* compare */
+
+static void
+print_version (void)
+{ char buffer [256] ;
+
+ sf_command (NULL, SFC_GET_LIB_VERSION, buffer, sizeof (buffer)) ;
+ printf ("\nVersion : %s\n\n", buffer) ;
+} /* print_version */
+
+static void
+print_usage (void)
+{
+ print_version () ;
+
+ printf ("Usage : %s <filename> <filename>\n", progname) ;
+ printf (" Compare the PCM data of two sound files.\n\n") ;
+} /* print_usage */
+
+int
+main (int argc, char *argv [])
+{
+ progname = strrchr (argv [0], '/') ;
+ progname = progname ? progname + 1 : argv [0] ;
+
+ if (argc != 3)
+ { print_usage () ;
+ return 1 ;
+ } ;
+
+ filename1 = argv [argc - 2] ;
+ filename2 = argv [argc - 1] ;
+
+ if (strcmp (filename1, filename2) == 0)
+ { printf ("Error : Input filenames are the same.\n\n") ;
+ print_usage () ;
+ return 1 ;
+ } ;
+
+ return compare () ;
+} /* main */
Added: freeswitch/trunk/libs/libsndfile/programs/sndfile-convert.c
==============================================================================
--- (empty file)
+++ freeswitch/trunk/libs/libsndfile/programs/sndfile-convert.c Thu May 21 16:09:30 2009
@@ -0,0 +1,369 @@
+/*
+** Copyright (C) 1999-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
+**
+** All rights reserved.
+**
+** Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+**
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the author nor the names of any contributors may be used
+** to endorse or promote products derived from this software without
+** specific prior written permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+** TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+** PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+** CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+** EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+** PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+** OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+** OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+** ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+
+#include <sndfile.h>
+
+#include "common.h"
+
+
+typedef struct
+{ char *infilename, *outfilename ;
+ SF_INFO infileinfo, outfileinfo ;
+} OptionData ;
+
+typedef struct
+{ const char *ext ;
+ int len ;
+ int format ;
+} OUTPUT_FORMAT_MAP ;
+
+static void copy_metadata (SNDFILE *outfile, SNDFILE *infile) ;
+
+static OUTPUT_FORMAT_MAP format_map [] =
+{
+ { "aif", 3, SF_FORMAT_AIFF },
+ { "wav", 0, SF_FORMAT_WAV },
+ { "au", 0, SF_FORMAT_AU },
+ { "caf", 0, SF_FORMAT_CAF },
+ { "flac", 0, SF_FORMAT_FLAC },
+ { "snd", 0, SF_FORMAT_AU },
+ { "svx", 0, SF_FORMAT_SVX },
+ { "paf", 0, SF_ENDIAN_BIG | SF_FORMAT_PAF },
+ { "fap", 0, SF_ENDIAN_LITTLE | SF_FORMAT_PAF },
+ { "gsm", 0, SF_FORMAT_RAW },
+ { "nist", 0, SF_FORMAT_NIST },
+ { "htk", 0, SF_FORMAT_HTK },
+ { "ircam", 0, SF_FORMAT_IRCAM },
+ { "sf", 0, SF_FORMAT_IRCAM },
+ { "voc", 0, SF_FORMAT_VOC },
+ { "w64", 0, SF_FORMAT_W64 },
+ { "raw", 0, SF_FORMAT_RAW },
+ { "mat4", 0, SF_FORMAT_MAT4 },
+ { "mat5", 0, SF_FORMAT_MAT5 },
+ { "mat", 0, SF_FORMAT_MAT4 },
+ { "pvf", 0, SF_FORMAT_PVF },
+ { "sds", 0, SF_FORMAT_SDS },
+ { "sd2", 0, SF_FORMAT_SD2 },
+ { "vox", 0, SF_FORMAT_RAW },
+ { "xi", 0, SF_FORMAT_XI },
+ { "wve", 0, SF_FORMAT_WVE },
+ { "oga", 0, SF_FORMAT_OGG },
+ { "mpc", 0, SF_FORMAT_MPC2K },
+ { "rf64", 0, SF_FORMAT_RF64 },
+} ; /* format_map */
+
+static int
+guess_output_file_type (char *str, int format)
+{ char buffer [16], *cptr ;
+ int k ;
+
+ format &= SF_FORMAT_SUBMASK ;
+
+ if ((cptr = strrchr (str, '.')) == NULL)
+ return 0 ;
+
+ strncpy (buffer, cptr + 1, 15) ;
+ buffer [15] = 0 ;
+
+ for (k = 0 ; buffer [k] ; k++)
+ buffer [k] = tolower ((buffer [k])) ;
+
+ if (strcmp (buffer, "gsm") == 0)
+ return SF_FORMAT_RAW | SF_FORMAT_GSM610 ;
+
+ if (strcmp (buffer, "vox") == 0)
+ return SF_FORMAT_RAW | SF_FORMAT_VOX_ADPCM ;
+
+ for (k = 0 ; k < (int) (sizeof (format_map) / sizeof (format_map [0])) ; k++)
+ { if (format_map [k].len > 0 && strncmp (buffer, format_map [k].ext, format_map [k].len) == 0)
+ return format_map [k].format | format ;
+ else if (strcmp (buffer, format_map [k].ext) == 0)
+ return format_map [k].format | format ;
+ } ;
+
+ return 0 ;
+} /* guess_output_file_type */
+
+
+static void
+print_usage (char *progname)
+{ SF_FORMAT_INFO info ;
+
+ int k ;
+
+ printf ("\nUsage : %s [options] [encoding] <input file> <output file>\n", progname) ;
+ puts ("\n"
+ " where [option] may be:\n\n"
+ " -override-sample-rate=X : force sample rate of input to X\n\n"
+ ) ;
+
+ puts ("\n"
+ " where [encoding] may be one of the following:\n\n"
+ " -pcms8 : force the output to signed 8 bit pcm\n"
+ " -pcmu8 : force the output to unsigned 8 bit pcm\n"
+ " -pcm16 : force the output to 16 bit pcm\n"
+ " -pcm24 : force the output to 24 bit pcm\n"
+ " -pcm32 : force the output to 32 bit pcm\n"
+ " -float32 : force the output to 32 bit floating point"
+ ) ;
+ puts (
+ " -ulaw : force the output ULAW\n"
+ " -alaw : force the output ALAW\n"
+ " -ima-adpcm : force the output to IMA ADPCM (WAV only)\n"
+ " -ms-adpcm : force the output to MS ADPCM (WAV only)\n"
+ " -gsm610 : force the GSM6.10 (WAV only)\n"
+ " -dwvw12 : force the output to 12 bit DWVW (AIFF only)\n"
+ " -dwvw16 : force the output to 16 bit DWVW (AIFF only)\n"
+ " -dwvw24 : force the output to 24 bit DWVW (AIFF only)\n"
+ " -vorbis : force the output to Vorbis (OGG only)\n"
+ ) ;
+
+ puts (
+ " The format of the output file is determined by the file extension of the\n"
+ " output file name. The following extensions are currently understood:\n"
+ ) ;
+
+ for (k = 0 ; k < (int) (sizeof (format_map) / sizeof (format_map [0])) ; k++)
+ { info.format = format_map [k].format ;
+ sf_command (NULL, SFC_GET_FORMAT_INFO, &info, sizeof (info)) ;
+ printf (" %-10s : %s\n", format_map [k].ext, info.name) ;
+ } ;
+
+ puts ("") ;
+} /* print_usage */
+
+int
+main (int argc, char * argv [])
+{ char *progname, *infilename, *outfilename ;
+ SNDFILE *infile = NULL, *outfile = NULL ;
+ SF_INFO sfinfo ;
+ int k, outfilemajor, outfileminor = 0, infileminor ;
+ int override_sample_rate = 0 ; /* assume no sample rate override. */
+
+ progname = strrchr (argv [0], '/') ;
+ progname = progname ? progname + 1 : argv [0] ;
+
+ if (argc < 3 || argc > 5)
+ { print_usage (progname) ;
+ return 1 ;
+ } ;
+
+ infilename = argv [argc-2] ;
+ outfilename = argv [argc-1] ;
+
+ if (strcmp (infilename, outfilename) == 0)
+ { printf ("Error : Input and output filenames are the same.\n\n") ;
+ print_usage (progname) ;
+ return 1 ;
+ } ;
+
+ if (infilename [0] == '-')
+ { printf ("Error : Input filename (%s) looks like an option.\n\n", infilename) ;
+ print_usage (progname) ;
+ return 1 ;
+ } ;
+
+ if (outfilename [0] == '-')
+ { printf ("Error : Output filename (%s) looks like an option.\n\n", outfilename) ;
+ print_usage (progname) ;
+ return 1 ;
+ } ;
+
+ for (k = 1 ; k < argc - 2 ; k++)
+ { if (! strcmp (argv [k], "-pcms8"))
+ { outfileminor = SF_FORMAT_PCM_S8 ;
+ continue ;
+ } ;
+ if (! strcmp (argv [k], "-pcmu8"))
+ { outfileminor = SF_FORMAT_PCM_U8 ;
+ continue ;
+ } ;
+ if (! strcmp (argv [k], "-pcm16"))
+ { outfileminor = SF_FORMAT_PCM_16 ;
+ continue ;
+ } ;
+ if (! strcmp (argv [k], "-pcm24"))
+ { outfileminor = SF_FORMAT_PCM_24 ;
+ continue ;
+ } ;
+ if (! strcmp (argv [k], "-pcm32"))
+ { outfileminor = SF_FORMAT_PCM_32 ;
+ continue ;
+ } ;
+ if (! strcmp (argv [k], "-float32"))
+ { outfileminor = SF_FORMAT_FLOAT ;
+ continue ;
+ } ;
+ if (! strcmp (argv [k], "-ulaw"))
+ { outfileminor = SF_FORMAT_ULAW ;
+ continue ;
+ } ;
+ if (! strcmp (argv [k], "-alaw"))
+ { outfileminor = SF_FORMAT_ALAW ;
+ continue ;
+ } ;
+ if (! strcmp (argv [k], "-ima-adpcm"))
+ { outfileminor = SF_FORMAT_IMA_ADPCM ;
+ continue ;
+ } ;
+ if (! strcmp (argv [k], "-ms-adpcm"))
+ { outfileminor = SF_FORMAT_MS_ADPCM ;
+ continue ;
+ } ;
+ if (! strcmp (argv [k], "-gsm610"))
+ { outfileminor = SF_FORMAT_GSM610 ;
+ continue ;
+ } ;
+ if (! strcmp (argv [k], "-dwvw12"))
+ { outfileminor = SF_FORMAT_DWVW_12 ;
+ continue ;
+ } ;
+ if (! strcmp (argv [k], "-dwvw16"))
+ { outfileminor = SF_FORMAT_DWVW_16 ;
+ continue ;
+ } ;
+ if (! strcmp (argv [k], "-dwvw24"))
+ { outfileminor = SF_FORMAT_DWVW_24 ;
+ continue ;
+ } ;
+ if (! strcmp (argv [k], "-vorbis"))
+ { outfileminor = SF_FORMAT_VORBIS ;
+ continue ;
+ } ;
+
+ if (strstr (argv [k], "-override-sample-rate=") == argv [k])
+ { const char *ptr ;
+
+ ptr = argv [k] + strlen ("-override-sample-rate=") ;
+ override_sample_rate = atoi (ptr) ;
+ continue ;
+ } ;
+
+ printf ("Error : Not able to decode argunment '%s'.\n", argv [k]) ;
+ exit (1) ;
+ } ;
+
+ if ((infile = sf_open (infilename, SFM_READ, &sfinfo)) == NULL)
+ { printf ("Not able to open input file %s.\n", infilename) ;
+ puts (sf_strerror (NULL)) ;
+ return 1 ;
+ } ;
+
+ /* Update sample rate if forced to something else. */
+ if (override_sample_rate)
+ sfinfo.samplerate = override_sample_rate ;
+
+ infileminor = sfinfo.format & SF_FORMAT_SUBMASK ;
+
+ if ((sfinfo.format = guess_output_file_type (outfilename, sfinfo.format)) == 0)
+ { printf ("Error : Not able to determine output file type for %s.\n", outfilename) ;
+ return 1 ;
+ } ;
+
+ outfilemajor = sfinfo.format & (SF_FORMAT_TYPEMASK | SF_FORMAT_ENDMASK) ;
+
+ if (outfileminor == 0)
+ outfileminor = sfinfo.format & SF_FORMAT_SUBMASK ;
+
+ if (outfileminor != 0)
+ sfinfo.format = outfilemajor | outfileminor ;
+ else
+ sfinfo.format = outfilemajor | (sfinfo.format & SF_FORMAT_SUBMASK) ;
+
+ if ((sfinfo.format & SF_FORMAT_TYPEMASK) == SF_FORMAT_XI)
+ switch (sfinfo.format & SF_FORMAT_SUBMASK)
+ { case SF_FORMAT_PCM_16 :
+ sfinfo.format = outfilemajor | SF_FORMAT_DPCM_16 ;
+ break ;
+
+ case SF_FORMAT_PCM_S8 :
+ case SF_FORMAT_PCM_U8 :
+ sfinfo.format = outfilemajor | SF_FORMAT_DPCM_8 ;
+ break ;
+ } ;
+
+ if (sf_format_check (&sfinfo) == 0)
+ { printf ("Error : output file format is invalid (0x%08X).\n", sfinfo.format) ;
+ return 1 ;
+ } ;
+
+ /* Open the output file. */
+ if ((outfile = sf_open (outfilename, SFM_WRITE, &sfinfo)) == NULL)
+ { printf ("Not able to open output file %s : %s\n", outfilename, sf_strerror (NULL)) ;
+ return 1 ;
+ } ;
+
+ /* Copy the metadata */
+ copy_metadata (outfile, infile) ;
+
+ if ((outfileminor == SF_FORMAT_DOUBLE) || (outfileminor == SF_FORMAT_FLOAT)
+ || (infileminor == SF_FORMAT_DOUBLE) || (infileminor == SF_FORMAT_FLOAT)
+ || (infileminor == SF_FORMAT_VORBIS) || (outfileminor == SF_FORMAT_VORBIS))
+ sfe_copy_data_fp (outfile, infile, sfinfo.channels) ;
+ else
+ sfe_copy_data_int (outfile, infile, sfinfo.channels) ;
+
+ sf_close (infile) ;
+ sf_close (outfile) ;
+
+ return 0 ;
+} /* main */
+
+static void
+copy_metadata (SNDFILE *outfile, SNDFILE *infile)
+{ SF_INSTRUMENT inst ;
+ SF_BROADCAST_INFO_2K binfo ;
+ const char *str ;
+ int k, err = 0 ;
+
+ for (k = SF_STR_FIRST ; k <= SF_STR_LAST ; k++)
+ { str = sf_get_string (infile, k) ;
+ if (str != NULL)
+ err = sf_set_string (outfile, k, str) ;
+ } ;
+
+ memset (&inst, 0, sizeof (inst)) ;
+ memset (&binfo, 0, sizeof (binfo)) ;
+
+ if (sf_command (infile, SFC_GET_INSTRUMENT, &inst, sizeof (inst)) == SF_TRUE)
+ sf_command (outfile, SFC_SET_INSTRUMENT, &inst, sizeof (inst)) ;
+
+ if (sf_command (infile, SFC_GET_BROADCAST_INFO, &binfo, sizeof (binfo)) == SF_TRUE)
+ sf_command (outfile, SFC_SET_BROADCAST_INFO, &binfo, sizeof (binfo)) ;
+
+} /* copy_metadata */
+
Added: freeswitch/trunk/libs/libsndfile/programs/sndfile-info.c
==============================================================================
--- (empty file)
+++ freeswitch/trunk/libs/libsndfile/programs/sndfile-info.c Thu May 21 16:09:30 2009
@@ -0,0 +1,386 @@
+/*
+** Copyright (C) 1999-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
+**
+** All rights reserved.
+**
+** Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+**
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the author nor the names of any contributors may be used
+** to endorse or promote products derived from this software without
+** specific prior written permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+** TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+** PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+** CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+** EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+** PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+** OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+** OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+** ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <inttypes.h>
+#include <ctype.h>
+#include <math.h>
+
+#include <sndfile.h>
+
+#include "common.h"
+
+#define BUFFER_LEN (1 << 16)
+
+#if (defined (WIN32) || defined (_WIN32))
+#include <windows.h>
+#define snprintf _snprintf
+#endif
+
+static void print_version (void) ;
+static void print_usage (const char *progname) ;
+
+static void info_dump (const char *filename) ;
+static int instrument_dump (const char *filename) ;
+static int broadcast_dump (const char *filename) ;
+static void total_dump (void) ;
+
+static double total_seconds = 0.0 ;
+
+int
+main (int argc, char *argv [])
+{ int k ;
+
+ print_version () ;
+
+ if (argc < 2 || strcmp (argv [1], "--help") == 0 || strcmp (argv [1], "-h") == 0)
+ { char *progname ;
+
+ progname = strrchr (argv [0], '/') ;
+ progname = progname ? progname + 1 : argv [0] ;
+
+ print_usage (progname) ;
+ return 1 ;
+ } ;
+
+ if (strcmp (argv [1], "-i") == 0)
+ { int error = 0 ;
+
+ for (k = 2 ; k < argc ; k++)
+ error += instrument_dump (argv [k]) ;
+ return error ;
+ } ;
+
+ if (strcmp (argv [1], "-b") == 0)
+ { int error = 0 ;
+
+ for (k = 2 ; k < argc ; k++)
+ error += broadcast_dump (argv [k]) ;
+ return error ;
+ } ;
+
+ for (k = 1 ; k < argc ; k++)
+ info_dump (argv [k]) ;
+
+ if (argc > 2)
+ total_dump () ;
+
+ return 0 ;
+} /* main */
+
+/*==============================================================================
+** Print version and usage.
+*/
+
+static double data [BUFFER_LEN] ;
+
+static void
+print_version (void)
+{ char buffer [256] ;
+
+ sf_command (NULL, SFC_GET_LIB_VERSION, buffer, sizeof (buffer)) ;
+ printf ("\nVersion : %s\n\n", buffer) ;
+} /* print_version */
+
+
+static void
+print_usage (const char *progname)
+{ printf ("Usage :\n %s <file> ...\n", progname) ;
+ printf (" Prints out information about one or more sound files.\n\n") ;
+ printf (" %s -i <file>\n", progname) ;
+ printf (" Prints out the instrument data for the given file.\n\n") ;
+ printf (" %s -b <file>\n", progname) ;
+ printf (" Prints out the broadcast WAV info for the given file.\n\n") ;
+#if (defined (_WIN32) || defined (WIN32))
+ printf ("This is a Unix style command line application which\n"
+ "should be run in a MSDOS box or Command Shell window.\n\n") ;
+ printf ("Sleeping for 5 seconds before exiting.\n\n") ;
+ fflush (stdout) ;
+
+ /* This is the officially blessed by microsoft way but I can't get
+ ** it to link.
+ ** Sleep (15) ;
+ ** Instead, use this:
+ */
+ Sleep (5 * 1000) ;
+#endif
+} /* print_usage */
+
+/*==============================================================================
+** Dumping of sndfile info.
+*/
+
+static double data [BUFFER_LEN] ;
+
+static double
+get_signal_max (SNDFILE *file)
+{ double max ;
+
+ sf_command (file, SFC_CALC_SIGNAL_MAX, &max, sizeof (max)) ;
+
+ return max ;
+} /* get_signal_max */
+
+static double
+calc_decibels (SF_INFO * sfinfo, double max)
+{ double decibels ;
+
+ switch (sfinfo->format & SF_FORMAT_SUBMASK)
+ { case SF_FORMAT_PCM_U8 :
+ case SF_FORMAT_PCM_S8 :
+ decibels = max / 0x80 ;
+ break ;
+
+ case SF_FORMAT_PCM_16 :
+ decibels = max / 0x8000 ;
+ break ;
+
+ case SF_FORMAT_PCM_24 :
+ decibels = max / 0x800000 ;
+ break ;
+
+ case SF_FORMAT_PCM_32 :
+ decibels = max / 0x80000000 ;
+ break ;
+
+ case SF_FORMAT_FLOAT :
+ case SF_FORMAT_DOUBLE :
+ decibels = max / 1.0 ;
+ break ;
+
+ default :
+ decibels = max / 0x8000 ;
+ break ;
+ } ;
+
+ return 20.0 * log10 (decibels) ;
+} /* calc_decibels */
+
+static const char *
+format_duration_str (double seconds)
+{ static char str [128] ;
+ int hrs, min ;
+ double sec ;
+
+ memset (str, 0, sizeof (str)) ;
+
+ hrs = (int) (seconds / 3600.0) ;
+ min = (int) ((seconds - (hrs * 3600.0)) / 60.0) ;
+ sec = seconds - (hrs * 3600.0) - (min * 60.0) ;
+
+ snprintf (str, sizeof (str) - 1, "%02d:%02d:%06.3f", hrs, min, sec) ;
+
+ return str ;
+} /* format_duration_str */
+
+static const char *
+generate_duration_str (SF_INFO *sfinfo)
+{
+ double seconds ;
+
+ if (sfinfo->samplerate < 1)
+ return NULL ;
+
+ if (sfinfo->frames / sfinfo->samplerate > 0x7FFFFFFF)
+ return "unknown" ;
+
+ seconds = (1.0 * sfinfo->frames) / sfinfo->samplerate ;
+
+ /* Accumulate the total of all known file durations */
+ total_seconds += seconds ;
+
+ return format_duration_str (seconds) ;
+} /* generate_duration_str */
+
+static void
+info_dump (const char *filename)
+{ static char strbuffer [BUFFER_LEN] ;
+ SNDFILE *file ;
+ SF_INFO sfinfo ;
+ double signal_max, decibels ;
+
+ memset (&sfinfo, 0, sizeof (sfinfo)) ;
+
+ if ((file = sf_open (filename, SFM_READ, &sfinfo)) == NULL)
+ { printf ("Error : Not able to open input file %s.\n", filename) ;
+ fflush (stdout) ;
+ memset (data, 0, sizeof (data)) ;
+ sf_command (file, SFC_GET_LOG_INFO, strbuffer, BUFFER_LEN) ;
+ puts (strbuffer) ;
+ puts (sf_strerror (NULL)) ;
+ return ;
+ } ;
+
+ printf ("========================================\n") ;
+ sf_command (file, SFC_GET_LOG_INFO, strbuffer, BUFFER_LEN) ;
+ puts (strbuffer) ;
+ printf ("----------------------------------------\n") ;
+
+ printf ("Sample Rate : %d\n", sfinfo.samplerate) ;
+ printf ("Frames : %" PRId64 "\n", sfinfo.frames) ;
+ printf ("Channels : %d\n", sfinfo.channels) ;
+ printf ("Format : 0x%08X\n", sfinfo.format) ;
+ printf ("Sections : %d\n", sfinfo.sections) ;
+ printf ("Seekable : %s\n", (sfinfo.seekable ? "TRUE" : "FALSE")) ;
+ printf ("Duration : %s\n", generate_duration_str (&sfinfo)) ;
+
+ if (sfinfo.frames < 100 * 1024 * 1024)
+ { /* Do not use sf_signal_max because it doesn't work for non-seekable files . */
+ signal_max = get_signal_max (file) ;
+ decibels = calc_decibels (&sfinfo, signal_max) ;
+ printf ("Signal Max : %g (%4.2f dB)\n", signal_max, decibels) ;
+ } ;
+ putchar ('\n') ;
+
+ sf_close (file) ;
+
+} /* info_dump */
+
+/*==============================================================================
+** Dumping of SF_INSTRUMENT data.
+*/
+
+static const char *
+str_of_type (int mode)
+{ switch (mode)
+ { case SF_LOOP_NONE : return "none" ;
+ case SF_LOOP_FORWARD : return "fwd " ;
+ case SF_LOOP_BACKWARD : return "back" ;
+ case SF_LOOP_ALTERNATING : return "alt " ;
+ default : break ;
+ } ;
+
+ return "????" ;
+} /* str_of_mode */
+
+static int
+instrument_dump (const char *filename)
+{ SNDFILE *file ;
+ SF_INFO sfinfo ;
+ SF_INSTRUMENT inst ;
+ int got_inst, k ;
+
+ memset (&sfinfo, 0, sizeof (sfinfo)) ;
+
+ if ((file = sf_open (filename, SFM_READ, &sfinfo)) == NULL)
+ { printf ("Error : Not able to open input file %s.\n", filename) ;
+ fflush (stdout) ;
+ memset (data, 0, sizeof (data)) ;
+ puts (sf_strerror (NULL)) ;
+ return 1 ;
+ } ;
+
+ got_inst = sf_command (file, SFC_GET_INSTRUMENT, &inst, sizeof (inst)) ;
+ sf_close (file) ;
+
+ if (got_inst == SF_FALSE)
+ { printf ("Error : File '%s' does not contain instrument data.\n\n", filename) ;
+ return 1 ;
+ } ;
+
+ printf ("Instrument : %s\n\n", filename) ;
+ printf (" Gain : %d\n", inst.gain) ;
+ printf (" Base note : %d\n", inst.basenote) ;
+ printf (" Velocity : %d - %d\n", (int) inst.velocity_lo, (int) inst.velocity_hi) ;
+ printf (" Key : %d - %d\n", (int) inst.key_lo, (int) inst.key_hi) ;
+ printf (" Loop points : %d\n", inst.loop_count) ;
+
+ for (k = 0 ; k < inst.loop_count ; k++)
+ printf (" %-2d Mode : %s Start : %6d End : %6d Count : %6d\n", k, str_of_type (inst.loops [k].mode), inst.loops [k].start, inst.loops [k].end, inst.loops [k].count) ;
+
+ putchar ('\n') ;
+ return 0 ;
+} /* instrument_dump */
+
+static int
+broadcast_dump (const char *filename)
+{ SNDFILE *file ;
+ SF_INFO sfinfo ;
+ SF_BROADCAST_INFO_2K bext ;
+ double time_ref_sec ;
+ int got_bext ;
+
+ memset (&sfinfo, 0, sizeof (sfinfo)) ;
+
+ if ((file = sf_open (filename, SFM_READ, &sfinfo)) == NULL)
+ { printf ("Error : Not able to open input file %s.\n", filename) ;
+ fflush (stdout) ;
+ memset (data, 0, sizeof (data)) ;
+ puts (sf_strerror (NULL)) ;
+ return 1 ;
+ } ;
+
+ memset (&bext, 0, sizeof (SF_BROADCAST_INFO_2K)) ;
+
+ got_bext = sf_command (file, SFC_GET_BROADCAST_INFO, &bext, sizeof (bext)) ;
+ sf_close (file) ;
+
+ if (got_bext == SF_FALSE)
+ { printf ("Error : File '%s' does not contain broadcast information.\n\n", filename) ;
+ return 1 ;
+ } ;
+
+ /*
+ ** From : http://www.ebu.ch/en/technical/publications/userguides/bwf_user_guide.php
+ **
+ ** Time Reference:
+ ** This field is a count from midnight in samples to the first sample
+ ** of the audio sequence.
+ */
+
+ time_ref_sec = ((pow (2.0, 32) * bext.time_reference_high) + (1.0 * bext.time_reference_low)) / sfinfo.samplerate ;
+
+ printf ("Description : %.*s\n", (int) sizeof (bext.description), bext.description) ;
+ printf ("Originator : %.*s\n", (int) sizeof (bext.originator), bext.originator) ;
+ printf ("Origination ref : %.*s\n", (int) sizeof (bext.originator_reference), bext.originator_reference) ;
+ printf ("Origination date : %.*s\n", (int) sizeof (bext.origination_date), bext.origination_date) ;
+ printf ("Origination time : %.*s\n", (int) sizeof (bext.origination_time), bext.origination_time) ;
+
+ if (bext.time_reference_high == 0 && bext.time_reference_low == 0)
+ printf ("Time ref : 0\n") ;
+ else
+ printf ("Time ref : 0x%x%08x (%.6f seconds)\n", bext.time_reference_high, bext.time_reference_low, time_ref_sec) ;
+
+ printf ("BWF version : %d\n", bext.version) ;
+ printf ("UMID : %.*s\n", (int) sizeof (bext.umid), bext.umid) ;
+ printf ("Coding history : %.*s\n", bext.coding_history_size, bext.coding_history) ;
+
+ return 0 ;
+} /* broadcast_dump */
+
+static void
+total_dump (void)
+{ printf ("========================================\n") ;
+ printf ("Total Duration : %s\n", format_duration_str (total_seconds)) ;
+} /* total_dump */
Added: freeswitch/trunk/libs/libsndfile/programs/sndfile-jackplay.c
==============================================================================
--- (empty file)
+++ freeswitch/trunk/libs/libsndfile/programs/sndfile-jackplay.c Thu May 21 16:09:30 2009
@@ -0,0 +1,277 @@
+/*
+** Copyright (c) 2007-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
+** Copyright (C) 2007 Jonatan Liljedahl <lijon at kymatica.com>
+**
+** This program is free software ; you can redistribute it and/or modify
+** it under the terms of the GNU General Public License as published by
+** the Free Software Foundation ; either version 2 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY ; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program ; if not, write to the Free Software
+** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#include "sfconfig.h"
+
+#include <stdio.h>
+#include <errno.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
+
+#if HAVE_JACK
+
+#include <math.h>
+#include <pthread.h>
+
+#include <jack/jack.h>
+#include <jack/ringbuffer.h>
+
+#include <sndfile.h>
+
+#define RB_SIZE (1 << 16)
+
+typedef struct _thread_info
+{ pthread_t thread_id ;
+ SNDFILE *sndfile ;
+ jack_nframes_t pos ;
+ jack_client_t *client ;
+ unsigned int channels ;
+ volatile int can_process ;
+ volatile int read_done ;
+ volatile int play_done ;
+} thread_info_t ;
+
+pthread_mutex_t disk_thread_lock = PTHREAD_MUTEX_INITIALIZER ;
+pthread_cond_t data_ready = PTHREAD_COND_INITIALIZER ;
+
+static jack_ringbuffer_t *ringbuf ;
+static jack_port_t **output_port ;
+static jack_default_audio_sample_t ** outs ;
+const size_t sample_size = sizeof (jack_default_audio_sample_t) ;
+
+static int
+process (jack_nframes_t nframes, void * arg)
+{
+ thread_info_t *info = (thread_info_t *) arg ;
+ jack_default_audio_sample_t buf [info->channels] ;
+ unsigned i, n ;
+
+ if (! info->can_process)
+ return 0 ;
+
+ for (n = 0 ; n < info->channels ; n++)
+ outs [n] = jack_port_get_buffer (output_port [n], nframes) ;
+
+ for (i = 0 ; i < nframes ; i++)
+ { size_t read_cnt ;
+
+ /* Read one frame of audio. */
+ read_cnt = jack_ringbuffer_read (ringbuf, (void*) buf, sample_size*info->channels) ;
+ if (read_cnt == 0 && info->read_done)
+ { /* File is done, so stop the main loop. */
+ info->play_done = 1 ;
+ return 0 ;
+ } ;
+
+ /* Update play-position counter. */
+ info->pos += read_cnt / (sample_size*info->channels) ;
+
+ /* Output each channel of the frame. */
+ for (n = 0 ; n < info->channels ; n++)
+ outs [n][i] = buf [n] ;
+ } ;
+
+ /* Wake up the disk thread to read more data. */
+ if (pthread_mutex_trylock (&disk_thread_lock) == 0)
+ { pthread_cond_signal (&data_ready) ;
+ pthread_mutex_unlock (&disk_thread_lock) ;
+ } ;
+
+ return 0 ;
+} /* process */
+
+static void *
+disk_thread (void *arg)
+{ thread_info_t *info = (thread_info_t *) arg ;
+ sf_count_t buf_avail, read_frames ;
+ jack_ringbuffer_data_t vec [2] ;
+ size_t bytes_per_frame = sample_size*info->channels ;
+
+ pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, NULL) ;
+ pthread_mutex_lock (&disk_thread_lock) ;
+
+ while (1)
+ { jack_ringbuffer_get_write_vector (ringbuf, vec) ;
+
+ read_frames = 0 ;
+
+ if (vec [0].len)
+ { /* Fill the first part of the ringbuffer. */
+ buf_avail = vec [0].len / bytes_per_frame ;
+ read_frames = sf_readf_float (info->sndfile, (float *) vec [0].buf, buf_avail) ;
+ if (vec [1].len)
+ { /* Fill the second part of the ringbuffer? */
+ buf_avail = vec [1].len / bytes_per_frame ;
+ read_frames += sf_readf_float (info->sndfile, (float *) vec [1].buf, buf_avail) ;
+ } ;
+ } ;
+
+ if (read_frames == 0)
+ break ; /* end of file? */
+
+ jack_ringbuffer_write_advance (ringbuf, read_frames * bytes_per_frame) ;
+
+ /* Tell process that we've filled the ringbuffer. */
+ info->can_process = 1 ;
+
+ /* Wait for the process thread to wake us up. */
+ pthread_cond_wait (&data_ready, &disk_thread_lock) ;
+ } ;
+
+ /* Tell that we're done reading the file. */
+ info->read_done = 1 ;
+ pthread_mutex_unlock (&disk_thread_lock) ;
+
+ return 0 ;
+} /* disk_thread */
+
+static void
+jack_shutdown (void *arg)
+{ (void) arg ;
+ exit (1) ;
+} /* jack_shutdown */
+
+static void
+print_time (jack_nframes_t pos, int jack_sr)
+{ float sec = pos / (1.0 * jack_sr) ;
+ int min = sec / 60.0 ;
+ fprintf (stderr, "%02d:%05.2f", min, fmod (sec, 60.0)) ;
+} /* print_time */
+
+int
+main (int narg, char * args [])
+{
+ SNDFILE *sndfile ;
+ SF_INFO sndfileinfo ;
+ jack_client_t *client ;
+ thread_info_t info ;
+ int i, jack_sr ;
+
+ if (narg < 2)
+ { fprintf (stderr, "no soundfile given\n") ;
+ return 1 ;
+ } ;
+
+ // create jack client
+ if ((client = jack_client_new ("jackplay")) == 0)
+ {
+ fprintf (stderr, "Jack server not running?\n") ;
+ return 1 ;
+ } ;
+
+ jack_sr = jack_get_sample_rate (client) ;
+
+ /* Open the soundfile. */
+ sndfileinfo.format = 0 ;
+ sndfile = sf_open (args [1], SFM_READ, &sndfileinfo) ;
+ if (sndfile == NULL)
+ { fprintf (stderr, "Could not open soundfile '%s'\n", args [1]) ;
+ return 1 ;
+ } ;
+
+ fprintf (stderr, "Channels : %d\nSample rate : %d Hz\nDuration : ", sndfileinfo.channels, sndfileinfo.samplerate) ;
+
+ print_time (sndfileinfo.frames, sndfileinfo.samplerate) ;
+ fprintf (stderr, "\n") ;
+
+ if (sndfileinfo.samplerate != jack_sr)
+ fprintf (stderr, "Warning: samplerate of soundfile (%d Hz) does not match jack server (%d Hz).\n", sndfileinfo.samplerate, jack_sr) ;
+
+ /* Init the thread info struct. */
+ memset (&info, 0, sizeof (info)) ;
+ info.can_process = 0 ;
+ info.read_done = 0 ;
+ info.play_done = 0 ;
+ info.sndfile = sndfile ;
+ info.channels = sndfileinfo.channels ;
+ info.client = client ;
+ info.pos = 0 ;
+
+ /* Set up callbacks. */
+ jack_set_process_callback (client, process, &info) ;
+ jack_on_shutdown (client, jack_shutdown, 0) ;
+
+ /* Allocate output ports. */
+ output_port = calloc (sndfileinfo.channels, sizeof (jack_port_t *)) ;
+ outs = calloc (sndfileinfo.channels, sizeof (jack_default_audio_sample_t *)) ;
+ for (i = 0 ; i < sndfileinfo.channels ; i++)
+ { char name [16] ;
+
+ snprintf (name, sizeof (name), "out_%d", i + 1) ;
+ output_port [i] = jack_port_register (client, name, JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 0) ;
+ } ;
+
+ /* Allocate and clear ringbuffer. */
+ ringbuf = jack_ringbuffer_create (sizeof (jack_default_audio_sample_t) * RB_SIZE) ;
+ memset (ringbuf->buf, 0, ringbuf->size) ;
+
+ /* Activate client. */
+ if (jack_activate (client))
+ { fprintf (stderr, "Cannot activate client.\n") ;
+ return 1 ;
+ } ;
+
+ /* Auto connect all channels. */
+ for (i = 0 ; i < sndfileinfo.channels ; i++)
+ { char name [64] ;
+
+ snprintf (name, sizeof (name), "alsa_pcm:playback_%d", i + 1) ;
+
+ if (jack_connect (client, jack_port_name (output_port [i]), name))
+ fprintf (stderr, "Cannot connect output port %d (%s).\n", i, name) ;
+ } ;
+
+ /* Start the disk thread. */
+ pthread_create (&info.thread_id, NULL, disk_thread, &info) ;
+
+ /* Sit in a loop, displaying the current play position. */
+ while (! info.play_done)
+ { fprintf (stderr, "\r-> ") ;
+ print_time (info.pos, jack_sr) ;
+ fflush (stdout) ;
+ usleep (50000) ;
+ } ;
+
+ /* Clean up. */
+ jack_client_close (client) ;
+ jack_ringbuffer_free (ringbuf) ;
+ sf_close (sndfile) ;
+ free (outs) ;
+ free (output_port) ;
+
+ puts ("") ;
+
+ return 0 ;
+} /* main */
+
+#else
+
+int
+main (void)
+{
+ puts (
+ "Sorry this program was compiled without libjack (which probably\n"
+ "only exists on Linux and Mac OSX) and hence doesn't work."
+ ) ;
+
+ return 0 ;
+} /* main */
+
+#endif
Added: freeswitch/trunk/libs/libsndfile/programs/sndfile-metadata-get.c
==============================================================================
--- (empty file)
+++ freeswitch/trunk/libs/libsndfile/programs/sndfile-metadata-get.c Thu May 21 16:09:30 2009
@@ -0,0 +1,176 @@
+/*
+** Copyright (C) 2008 George Blood Audio
+** Written by Erik de Castro Lopo <erikd at mega-nerd.com>
+**
+** All rights reserved.
+**
+** Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+**
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the author nor the names of any contributors may be used
+** to endorse or promote products derived from this software without
+** specific prior written permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+** TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+** PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+** CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+** EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+** PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+** OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+** OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+** ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#include <config.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <time.h>
+
+#include <sndfile.h>
+
+#include "common.h"
+
+#define BUFFER_LEN (1 << 16)
+
+static void usage_exit (const char *progname, int exit_code) ;
+static void process_args (SNDFILE * file, const SF_BROADCAST_INFO_2K * binfo, int argc, char * argv []) ;
+
+int
+main (int argc, char *argv [])
+{ SNDFILE *file ;
+ SF_INFO sfinfo ;
+ SF_BROADCAST_INFO_2K binfo ;
+ const char *progname ;
+ const char * filename = NULL ;
+ int start ;
+
+ /* Store the program name. */
+ progname = strrchr (argv [0], '/') ;
+ progname = progname ? progname + 1 : argv [0] ;
+
+ /* Check if we've been asked for help. */
+ if (argc <= 2 || strcmp (argv [1], "--help") == 0 || strcmp (argv [1], "-h") == 0)
+ usage_exit (progname, 0) ;
+
+ if (argv [argc - 1][0] != '-')
+ { filename = argv [argc - 1] ;
+ start = 1 ;
+ }
+ else if (argv [1][0] != '-')
+ { filename = argv [1] ;
+ start = 2 ;
+ }
+ else
+ { printf ("Error : Either the first or the last command line parameter should be a filename.\n\n") ;
+ exit (1) ;
+ } ;
+
+ /* Get the time in case we need it later. */
+ memset (&sfinfo, 0, sizeof (sfinfo)) ;
+ if ((file = sf_open (filename, SFM_READ, &sfinfo)) == NULL)
+ { printf ("Error : Open of file '%s' failed : %s\n\n", filename, sf_strerror (file)) ;
+ exit (1) ;
+ } ;
+
+ memset (&binfo, 0, sizeof (binfo)) ;
+ if (sf_command (file, SFC_GET_BROADCAST_INFO, &binfo, sizeof (binfo)) == 0)
+ memset (&binfo, 0, sizeof (binfo)) ;
+
+ process_args (file, &binfo, argc - 2, argv + start) ;
+
+ sf_close (file) ;
+ return 0 ;
+} /* main */
+
+/*==============================================================================
+** Print version and usage.
+*/
+
+static void
+usage_exit (const char *progname, int exit_code)
+{ printf ("\nUsage :\n %s [options] <file>\n\nOptions:\n", progname) ;
+
+ puts (
+ " --bext-description Print the 'bext' description.\n"
+ " --bext-originator Print the 'bext; originator info.\n"
+ " --bext-orig-ref Print the 'bext' origination reference.\n"
+ " --bext-umid Print the 'bext' UMID.\n"
+ " --bext-orig-date Print the 'bext' origination date.\n"
+ " --bext-orig-time Print the 'bext' origination time.\n"
+ " --bext-coding-hist Print the 'bext' coding history.\n"
+ ) ;
+
+ puts (
+ " --str-title Print the title metadata.\n"
+ " --str-copyright Print the copyright metadata.\n"
+ " --str-artist Print the artist metadata.\n"
+ " --str-comment Print the comment metadata.\n"
+ " --str-date Print the creation date metadata.\n"
+ " --str-album Print the album metadata.\n"
+ " --str-license Print the license metadata.\n"
+ ) ;
+
+ exit (exit_code) ;
+} /* usage_exit */
+
+static void
+process_args (SNDFILE * file, const SF_BROADCAST_INFO_2K * binfo, int argc, char * argv [])
+{ const char * str ;
+ int k, do_all = 0 ;
+
+#define HANDLE_BEXT_ARG(cmd,name,field) \
+ if (do_all || strcmp (argv [k], cmd) == 0) \
+ { printf ("%-20s : %.*s\n", name, (int) sizeof (binfo->field), binfo->field) ; \
+ if (! do_all) \
+ continue ; \
+ } ;
+
+#define HANDLE_STR_ARG(cmd,name,id) \
+ if (do_all || strcmp (argv [k], cmd) == 0) \
+ { str = sf_get_string (file, id) ; \
+ printf ("%-20s : %s\n", name, str ? str : "") ; \
+ if (! do_all) continue ; \
+ } ;
+
+ for (k = 0 ; k < argc ; k++)
+ { if (do_all || strcmp (argv [k], "--all") == 0)
+ do_all = 1 ;
+
+ HANDLE_BEXT_ARG ("--bext-description", "Description", description) ;
+ HANDLE_BEXT_ARG ("--bext-originator", "Originator", originator) ;
+ HANDLE_BEXT_ARG ("--bext-orig-ref", "Origination ref", originator_reference) ;
+ HANDLE_BEXT_ARG ("--bext-umid", "UMID", umid) ;
+ HANDLE_BEXT_ARG ("--bext-orig-date", "Origination date", origination_date) ;
+ HANDLE_BEXT_ARG ("--bext-orig-time", "Origination time", origination_time) ;
+ HANDLE_BEXT_ARG ("--bext-coding-hist", "Coding history", coding_history) ;
+
+ HANDLE_STR_ARG ("--str-title", "Name", SF_STR_TITLE) ;
+ HANDLE_STR_ARG ("--str-copyright", "Copyright", SF_STR_COPYRIGHT) ;
+ HANDLE_STR_ARG ("--str-artist", "Artist", SF_STR_ARTIST) ;
+ HANDLE_STR_ARG ("--str-comment", "Comment", SF_STR_COMMENT) ;
+ HANDLE_STR_ARG ("--str-date", "Create date", SF_STR_DATE) ;
+ HANDLE_STR_ARG ("--str-album", "Album", SF_STR_ALBUM) ;
+ HANDLE_STR_ARG ("--str-license", "License", SF_STR_LICENSE) ;
+
+ if (! do_all)
+ { printf ("Error : Don't know what to do with command line arg '%s'.\n\n", argv [k]) ;
+ exit (1) ;
+ } ;
+ break ;
+ } ;
+
+ return ;
+} /* process_args */
Added: freeswitch/trunk/libs/libsndfile/programs/sndfile-metadata-set.c
==============================================================================
--- (empty file)
+++ freeswitch/trunk/libs/libsndfile/programs/sndfile-metadata-set.c Thu May 21 16:09:30 2009
@@ -0,0 +1,280 @@
+/*
+** Copyright (C) 2008 George Blood Audio
+** Written by Erik de Castro Lopo <erikd at mega-nerd.com>
+**
+** All rights reserved.
+**
+** Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+**
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the author nor the names of any contributors may be used
+** to endorse or promote products derived from this software without
+** specific prior written permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+** TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+** PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+** CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+** EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+** PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+** OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+** OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+** ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#include <config.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <time.h>
+
+#include <sndfile.h>
+
+#include "common.h"
+
+#define BUFFER_LEN (1 << 16)
+
+
+static void usage_exit (const char *progname, int exit_code) ;
+static void missing_param (const char * option) ;
+static void read_localtime (struct tm * timedata) ;
+static int has_bext_fields_set (const METADATA_INFO * info) ;
+
+int
+main (int argc, char *argv [])
+{ METADATA_INFO info ;
+ struct tm timedata ;
+ const char *progname ;
+ const char * filenames [2] = { NULL, NULL } ;
+ int k ;
+
+ /* Store the program name. */
+ progname = strrchr (argv [0], '/') ;
+ progname = progname ? progname + 1 : argv [0] ;
+
+ /* Check if we've been asked for help. */
+ if (argc < 3 || strcmp (argv [1], "--help") == 0 || strcmp (argv [1], "-h") == 0)
+ usage_exit (progname, 0) ;
+
+ /* Clear set all fields of the struct to zero bytes. */
+ memset (&info, 0, sizeof (info)) ;
+
+ /* Get the time in case we need it later. */
+ read_localtime (&timedata) ;
+
+ for (k = 1 ; k < argc ; k++)
+ { char tmp [20] ;
+
+ if (argv [k][0] != '-')
+ { if (filenames [0] == NULL)
+ filenames [0] = argv [k] ;
+ else if (filenames [1] == NULL)
+ filenames [1] = argv [k] ;
+ else
+ { printf ("Error : Already have two file names on the command line and then found '%s'.\n\n", argv [k]) ;
+ usage_exit (progname, 1) ;
+ } ;
+ continue ;
+ } ;
+
+#define HANDLE_BEXT_ARG(cmd,field) \
+ if (strcmp (argv [k], cmd) == 0) \
+ { k ++ ; \
+ if (k == argc) missing_param (argv [k - 1]) ; \
+ info.field = argv [k] ; \
+ continue ; \
+ } ;
+
+ HANDLE_BEXT_ARG ("--bext-description", description) ;
+ HANDLE_BEXT_ARG ("--bext-originator", originator) ;
+ HANDLE_BEXT_ARG ("--bext-orig-ref", originator_reference) ;
+ HANDLE_BEXT_ARG ("--bext-umid", umid) ;
+ HANDLE_BEXT_ARG ("--bext-orig-date", origination_date) ;
+ HANDLE_BEXT_ARG ("--bext-orig-time", origination_time) ;
+ HANDLE_BEXT_ARG ("--bext-coding-hist", coding_history) ;
+
+#define HANDLE_STR_ARG(cmd,field) \
+ if (strcmp (argv [k], cmd) == 0) \
+ { k ++ ; \
+ if (k == argc) missing_param (argv [k - 1]) ; \
+ info.field = argv [k] ; \
+ continue ; \
+ } ;
+
+ HANDLE_STR_ARG ("--str-title", title) ;
+ HANDLE_STR_ARG ("--str-copyright", copyright) ;
+ HANDLE_STR_ARG ("--str-artist", artist) ;
+ HANDLE_STR_ARG ("--str-date", date) ;
+ HANDLE_STR_ARG ("--str-album", album) ;
+ HANDLE_STR_ARG ("--str-license", license) ;
+
+ /* Following options do not take an argument. */
+ if (strcmp (argv [k], "--bext-auto-time-date") == 0)
+ { snprintf (tmp, sizeof (tmp), "%02d:%02d:%02d", timedata.tm_hour, timedata.tm_min, timedata.tm_sec) ;
+ info.origination_time = strdup (tmp) ;
+
+ snprintf (tmp, sizeof (tmp), "%04d-%02d-%02d", timedata.tm_year + 1900, timedata.tm_mon + 1, timedata.tm_mday) ;
+ info.origination_date = strdup (tmp) ;
+ continue ;
+ } ;
+
+ if (strcmp (argv [k], "--bext-auto-time") == 0)
+ { snprintf (tmp, sizeof (tmp), "%02d:%02d:%02d", timedata.tm_hour, timedata.tm_min, timedata.tm_sec) ;
+ info.origination_time = strdup (tmp) ;
+ continue ;
+ } ;
+
+ if (strcmp (argv [k], "--bext-auto-date") == 0)
+ { snprintf (tmp, sizeof (tmp), "%04d-%02d-%02d", timedata.tm_year + 1900, timedata.tm_mon + 1, timedata.tm_mday) ;
+ info.origination_date = strdup (tmp) ;
+ continue ;
+ } ;
+
+ if (strcmp (argv [k], "--str-auto-date") == 0)
+ { snprintf (tmp, sizeof (tmp), "%04d-%02d-%02d", timedata.tm_year + 1900, timedata.tm_mon + 1, timedata.tm_mday) ;
+
+ info.date = strdup (tmp) ;
+ continue ;
+ } ;
+
+ printf ("Error : Don't know what to do with command line arg '%s'.\n\n", argv [k]) ;
+ usage_exit (progname, 1) ;
+ } ;
+
+ /* Find out if any of the 'bext' fields are set. */
+ info.has_bext_fields = has_bext_fields_set (&info) ;
+
+ if (filenames [0] == NULL)
+ { printf ("Error : No input file specificed.\n\n") ;
+ exit (1) ;
+ } ;
+
+ if (filenames [1] != NULL && strcmp (filenames [0], filenames [1]) == 0)
+ { printf ("Error : Input and output files are the same.\n\n") ;
+ exit (1) ;
+ } ;
+
+ if (info.coding_history != NULL && filenames [1] == NULL)
+ { printf ("\n"
+ "Error : Trying to update coding history of an existing file which unfortunately\n"
+ " is not supported. Instead, create a new file using :\n"
+ "\n"
+ " %s --bext-coding-hist \"Coding history\" old_file.wav new_file.wav\n"
+ "\n",
+ progname) ;
+ exit (1) ;
+ } ;
+
+ sfe_apply_metadata_changes (filenames, &info) ;
+
+ return 0 ;
+} /* main */
+
+/*==============================================================================
+** Print version and usage.
+*/
+
+static void
+usage_exit (const char *progname, int exit_code)
+{ printf ("\nUsage :\n\n"
+ " %s [options] <file>\n"
+ " %s [options] <input file> <output file>\n"
+ "\n",
+ progname, progname) ;
+
+ puts (
+ "Where an option is made up of a pair of a field to set (one of\n"
+ "the 'bext' or metadata fields below) and a string. Fields are\n"
+ "as follows :\n"
+ ) ;
+
+ puts (
+ " --bext-description Set the 'bext' description.\n"
+ " --bext-originator Set the 'bext' originator.\n"
+ " --bext-orig-ref Set the 'bext' originator reference.\n"
+ " --bext-umid Set the 'bext' UMID.\n"
+ " --bext-orig-date Set the 'bext' origination date.\n"
+ " --bext-orig-time Set the 'bext' origination time.\n"
+ " --bext-coding-hist Set the 'bext' coding history\n"
+ "\n"
+ " --str-title Set the metadata title.\n"
+ " --str-copyright Set the metadata copyright.\n"
+ " --str-artist Set the metadata artist.\n"
+ " --str-date Set the metadata date.\n"
+ " --str-album Set the metadata album.\n"
+ " --str-license Set the metadata license.\n"
+ ) ;
+
+ puts (
+ "There are also the following arguments which do not take a\n"
+ "parameter :\n\n"
+ " --bext-auto-time-date Set the 'bext' time and date to current time/date.\n"
+ " --bext-auto-time Set the 'bext' time to current time.\n"
+ " --bext-auto-date Set the 'bext' date to current date.\n"
+ " --str-auto-date Set the metadata date to current date.\n"
+ ) ;
+
+ puts (
+ "Most of the above operations can be done in-place on an existing\n"
+ "file. If any operation cannot be performed, the application will\n"
+ "exit with an appropriate error message.\n"
+ ) ;
+
+ exit (exit_code) ;
+} /* usage_exit */
+
+static void
+missing_param (const char * option)
+{
+ printf ("Error : Option '%s' needs a parameter but doesn't seem to have one.\n\n", option) ;
+ exit (1) ;
+} /* missing_param */
+
+/*==============================================================================
+*/
+
+static int
+has_bext_fields_set (const METADATA_INFO * info)
+{
+ if (info->description || info->originator || info->originator_reference)
+ return 1 ;
+
+ if (info->origination_date || info->origination_time || info->umid || info->coding_history)
+ return 1 ;
+
+ return 0 ;
+} /* has_bext_fields_set */
+
+static void
+read_localtime (struct tm * timedata)
+{ time_t current ;
+
+ time (¤t) ;
+ memset (timedata, 0, sizeof (struct tm)) ;
+
+#if defined (HAVE_LOCALTIME_R)
+ /* If the re-entrant version is available, use it. */
+ localtime_r (¤t, timedata) ;
+#elif defined (HAVE_LOCALTIME)
+ {
+ struct tm *tmptr ;
+ /* Otherwise use the standard one and copy the data to local storage. */
+ if ((tmptr = localtime (¤t)) != NULL)
+ memcpy (timedata, tmptr, sizeof (struct tm)) ;
+ }
+#endif
+
+ return ;
+} /* read_localtime */
+
Added: freeswitch/trunk/libs/libsndfile/programs/sndfile-play-beos.cpp
==============================================================================
--- (empty file)
+++ freeswitch/trunk/libs/libsndfile/programs/sndfile-play-beos.cpp Thu May 21 16:09:30 2009
@@ -0,0 +1,144 @@
+/*
+** Copyright (C) 2001 Marcus Overhagen <marcus at overhagen.de>
+**
+** This program is free software; you can redistribute it and/or modify
+** it under the terms of the GNU General Public License as published by
+** the Free Software Foundation; either version 2 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#include <stdio.h>
+
+#include <Application.h>
+#include <SoundPlayer.h>
+#include <string.h>
+
+#include <sndfile.h>
+
+#define BUFFER_LEN 1024
+
+/*------------------------------------------------------------------------------
+** BeOS functions for playing a sound.
+*/
+
+#if defined (__BEOS__)
+
+struct shared_data
+{
+ BSoundPlayer *player;
+ SNDFILE *sndfile;
+ SF_INFO sfinfo;
+ sem_id finished;
+};
+
+static void
+buffer_callback(void *theCookie, void *buf, size_t size, const media_raw_audio_format &format)
+{
+ shared_data *data = (shared_data *)theCookie;
+ short *buffer = (short *)buf;
+ int count = size / sizeof(short);
+ int m, readcount;
+
+ if (!data->player->HasData())
+ return;
+
+ readcount = sf_read_short(data->sndfile, buffer, count);
+ if (readcount == 0)
+ { data->player->SetHasData(false);
+ release_sem(data->finished);
+ }
+ if (readcount < count)
+ { for (m = readcount ; m < count ; m++)
+ buffer [m] = 0 ;
+ }
+ if (data->sfinfo.pcmbitwidth < 16)
+ { for (m = 0 ; m < count ; m++)
+ buffer [m] *= 256 ;
+ }
+}
+
+static void
+beos_play (int argc, char *argv [])
+{
+ shared_data data;
+ status_t status;
+ int k;
+
+ /* BSoundPlayer requires a BApplication object */
+ BApplication app("application/x-vnd.MarcusOverhagen-sfplay");
+
+ for (k = 1 ; k < argc ; k++)
+ { printf ("Playing %s\n", argv [k]) ;
+ if (! (data.sndfile = sf_open_read (argv [k], &data.sfinfo)))
+ { sf_perror (NULL) ;
+ continue ;
+ } ;
+
+ if (data.sfinfo.channels < 1 || data.sfinfo.channels > 2)
+ { printf ("Error : channels = %d.\n", data.sfinfo.channels) ;
+ sf_close (data.sndfile) ;
+ continue ;
+ } ;
+
+ data.finished = create_sem(0,"finished");
+
+ media_raw_audio_format format =
+ { data.sfinfo.samplerate,
+ data.sfinfo.channels,
+ media_raw_audio_format::B_AUDIO_SHORT,
+ B_HOST_IS_LENDIAN ? B_MEDIA_LITTLE_ENDIAN : B_MEDIA_BIG_ENDIAN,
+ BUFFER_LEN * sizeof(short)
+ };
+
+ BSoundPlayer player(&format,"player",buffer_callback,NULL,&data);
+ data.player = &player;
+
+ if ((status = player.InitCheck()) != B_OK)
+ {
+ printf ("Error : BSoundPlayer init failed, %s.\n", strerror(status)) ;
+ delete_sem(data.finished);
+ sf_close (data.sndfile) ;
+ continue ;
+ }
+
+ player.SetVolume(1.0);
+ player.Start();
+ player.SetHasData(true);
+ acquire_sem(data.finished);
+ player.Stop();
+ delete_sem(data.finished);
+
+ sf_close (data.sndfile) ;
+
+ } ;
+
+} /* beos_play */
+
+#endif
+
+/*==============================================================================
+** Main function.
+*/
+
+int
+main (int argc, char *argv [])
+{
+ if (argc < 2)
+ { printf ("Usage : %s <input sound file>\n\n", argv [0]) ;
+ return 1 ;
+ } ;
+
+ beos_play (argc, argv) ;
+
+ return 0 ;
+} /* main */
+
Added: freeswitch/trunk/libs/libsndfile/programs/sndfile-play.c
==============================================================================
--- (empty file)
+++ freeswitch/trunk/libs/libsndfile/programs/sndfile-play.c Thu May 21 16:09:30 2009
@@ -0,0 +1,958 @@
+/*
+** Copyright (C) 1999-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
+**
+** All rights reserved.
+**
+** Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+**
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the author nor the names of any contributors may be used
+** to endorse or promote products derived from this software without
+** specific prior written permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+** TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+** PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+** CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+** EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+** PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+** OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+** OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+** ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#include "sfconfig.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+
+#if HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+#if HAVE_ALSA_ASOUNDLIB_H
+ #define ALSA_PCM_NEW_HW_PARAMS_API
+ #define ALSA_PCM_NEW_SW_PARAMS_API
+ #include <alsa/asoundlib.h>
+ #include <sys/time.h>
+#endif
+
+#if defined (__linux__)
+ #include <fcntl.h>
+ #include <sys/ioctl.h>
+ #include <sys/soundcard.h>
+
+#elif (defined (__MACH__) && defined (__APPLE__))
+ #include <Carbon.h>
+ #include <CoreAudio/AudioHardware.h>
+
+#elif (defined (sun) && defined (unix))
+ #include <fcntl.h>
+ #include <sys/ioctl.h>
+ #include <sys/audioio.h>
+
+#elif (OS_IS_WIN32 == 1)
+ #include <windows.h>
+ #include <mmsystem.h>
+
+#endif
+
+#include <sndfile.h>
+
+#define SIGNED_SIZEOF(x) ((int) sizeof (x))
+#define BUFFER_LEN (2048)
+
+/*------------------------------------------------------------------------------
+** Linux/OSS functions for playing a sound.
+*/
+
+#if HAVE_ALSA_ASOUNDLIB_H
+
+static snd_pcm_t * alsa_open (int channels, unsigned srate, int realtime) ;
+static int alsa_write_float (snd_pcm_t *alsa_dev, float *data, int frames, int channels) ;
+
+static void
+alsa_play (int argc, char *argv [])
+{ static float buffer [BUFFER_LEN] ;
+ SNDFILE *sndfile ;
+ SF_INFO sfinfo ;
+ snd_pcm_t * alsa_dev ;
+ int k, readcount, subformat ;
+
+ for (k = 1 ; k < argc ; k++)
+ { memset (&sfinfo, 0, sizeof (sfinfo)) ;
+
+ printf ("Playing %s\n", argv [k]) ;
+ if (! (sndfile = sf_open (argv [k], SFM_READ, &sfinfo)))
+ { puts (sf_strerror (NULL)) ;
+ continue ;
+ } ;
+
+ if (sfinfo.channels < 1 || sfinfo.channels > 2)
+ { printf ("Error : channels = %d.\n", sfinfo.channels) ;
+ continue ;
+ } ;
+
+ if ((alsa_dev = alsa_open (sfinfo.channels, (unsigned) sfinfo.samplerate, SF_FALSE)) == NULL)
+ continue ;
+
+ subformat = sfinfo.format & SF_FORMAT_SUBMASK ;
+
+ if (subformat == SF_FORMAT_FLOAT || subformat == SF_FORMAT_DOUBLE)
+ { double scale ;
+ int m ;
+
+ sf_command (sndfile, SFC_CALC_SIGNAL_MAX, &scale, sizeof (scale)) ;
+ if (scale < 1e-10)
+ scale = 1.0 ;
+ else
+ scale = 32700.0 / scale ;
+
+ while ((readcount = sf_read_float (sndfile, buffer, BUFFER_LEN)))
+ { for (m = 0 ; m < readcount ; m++)
+ buffer [m] *= scale ;
+ alsa_write_float (alsa_dev, buffer, BUFFER_LEN / sfinfo.channels, sfinfo.channels) ;
+ } ;
+ }
+ else
+ { while ((readcount = sf_read_float (sndfile, buffer, BUFFER_LEN)))
+ alsa_write_float (alsa_dev, buffer, BUFFER_LEN / sfinfo.channels, sfinfo.channels) ;
+ } ;
+
+ snd_pcm_drain (alsa_dev) ;
+ snd_pcm_close (alsa_dev) ;
+
+ sf_close (sndfile) ;
+ } ;
+
+ return ;
+} /* alsa_play */
+
+static snd_pcm_t *
+alsa_open (int channels, unsigned samplerate, int realtime)
+{ const char * device = "default" ;
+ snd_pcm_t *alsa_dev = NULL ;
+ snd_pcm_hw_params_t *hw_params ;
+ snd_pcm_uframes_t buffer_size ;
+ snd_pcm_uframes_t alsa_period_size, alsa_buffer_frames ;
+ snd_pcm_sw_params_t *sw_params ;
+
+ int err ;
+
+ if (realtime)
+ { alsa_period_size = 256 ;
+ alsa_buffer_frames = 3 * alsa_period_size ;
+ }
+ else
+ { alsa_period_size = 1024 ;
+ alsa_buffer_frames = 4 * alsa_period_size ;
+ } ;
+
+ if ((err = snd_pcm_open (&alsa_dev, device, SND_PCM_STREAM_PLAYBACK, 0)) < 0)
+ { fprintf (stderr, "cannot open audio device \"%s\" (%s)\n", device, snd_strerror (err)) ;
+ goto catch_error ;
+ } ;
+
+ snd_pcm_nonblock (alsa_dev, 0) ;
+
+ if ((err = snd_pcm_hw_params_malloc (&hw_params)) < 0)
+ { fprintf (stderr, "cannot allocate hardware parameter structure (%s)\n", snd_strerror (err)) ;
+ goto catch_error ;
+ } ;
+
+ if ((err = snd_pcm_hw_params_any (alsa_dev, hw_params)) < 0)
+ { fprintf (stderr, "cannot initialize hardware parameter structure (%s)\n", snd_strerror (err)) ;
+ goto catch_error ;
+ } ;
+
+ if ((err = snd_pcm_hw_params_set_access (alsa_dev, hw_params, SND_PCM_ACCESS_RW_INTERLEAVED)) < 0)
+ { fprintf (stderr, "cannot set access type (%s)\n", snd_strerror (err)) ;
+ goto catch_error ;
+ } ;
+
+ if ((err = snd_pcm_hw_params_set_format (alsa_dev, hw_params, SND_PCM_FORMAT_FLOAT)) < 0)
+ { fprintf (stderr, "cannot set sample format (%s)\n", snd_strerror (err)) ;
+ goto catch_error ;
+ } ;
+
+ if ((err = snd_pcm_hw_params_set_rate_near (alsa_dev, hw_params, &samplerate, 0)) < 0)
+ { fprintf (stderr, "cannot set sample rate (%s)\n", snd_strerror (err)) ;
+ goto catch_error ;
+ } ;
+
+ if ((err = snd_pcm_hw_params_set_channels (alsa_dev, hw_params, channels)) < 0)
+ { fprintf (stderr, "cannot set channel count (%s)\n", snd_strerror (err)) ;
+ goto catch_error ;
+ } ;
+
+ if ((err = snd_pcm_hw_params_set_buffer_size_near (alsa_dev, hw_params, &alsa_buffer_frames)) < 0)
+ { fprintf (stderr, "cannot set buffer size (%s)\n", snd_strerror (err)) ;
+ goto catch_error ;
+ } ;
+
+ if ((err = snd_pcm_hw_params_set_period_size_near (alsa_dev, hw_params, &alsa_period_size, 0)) < 0)
+ { fprintf (stderr, "cannot set period size (%s)\n", snd_strerror (err)) ;
+ goto catch_error ;
+ } ;
+
+ if ((err = snd_pcm_hw_params (alsa_dev, hw_params)) < 0)
+ { fprintf (stderr, "cannot set parameters (%s)\n", snd_strerror (err)) ;
+ goto catch_error ;
+ } ;
+
+ /* extra check: if we have only one period, this code won't work */
+ snd_pcm_hw_params_get_period_size (hw_params, &alsa_period_size, 0) ;
+ snd_pcm_hw_params_get_buffer_size (hw_params, &buffer_size) ;
+ if (alsa_period_size == buffer_size)
+ { fprintf (stderr, "Can't use period equal to buffer size (%lu == %lu)", alsa_period_size, buffer_size) ;
+ goto catch_error ;
+ } ;
+
+ snd_pcm_hw_params_free (hw_params) ;
+
+ if ((err = snd_pcm_sw_params_malloc (&sw_params)) != 0)
+ { fprintf (stderr, "%s: snd_pcm_sw_params_malloc: %s", __func__, snd_strerror (err)) ;
+ goto catch_error ;
+ } ;
+
+ if ((err = snd_pcm_sw_params_current (alsa_dev, sw_params)) != 0)
+ { fprintf (stderr, "%s: snd_pcm_sw_params_current: %s", __func__, snd_strerror (err)) ;
+ goto catch_error ;
+ } ;
+
+ /* note: set start threshold to delay start until the ring buffer is full */
+ snd_pcm_sw_params_current (alsa_dev, sw_params) ;
+
+ if ((err = snd_pcm_sw_params_set_start_threshold (alsa_dev, sw_params, buffer_size)) < 0)
+ { fprintf (stderr, "cannot set start threshold (%s)\n", snd_strerror (err)) ;
+ goto catch_error ;
+ } ;
+
+ if ((err = snd_pcm_sw_params (alsa_dev, sw_params)) != 0)
+ { fprintf (stderr, "%s: snd_pcm_sw_params: %s", __func__, snd_strerror (err)) ;
+ goto catch_error ;
+ } ;
+
+ snd_pcm_sw_params_free (sw_params) ;
+
+ snd_pcm_reset (alsa_dev) ;
+
+catch_error :
+
+ if (err < 0 && alsa_dev != NULL)
+ { snd_pcm_close (alsa_dev) ;
+ return NULL ;
+ } ;
+
+ return alsa_dev ;
+} /* alsa_open */
+
+static int
+alsa_write_float (snd_pcm_t *alsa_dev, float *data, int frames, int channels)
+{ static int epipe_count = 0 ;
+
+ int total = 0 ;
+ int retval ;
+
+ if (epipe_count > 0)
+ epipe_count -- ;
+
+ while (total < frames)
+ { retval = snd_pcm_writei (alsa_dev, data + total * channels, frames - total) ;
+
+ if (retval >= 0)
+ { total += retval ;
+ if (total == frames)
+ return total ;
+
+ continue ;
+ } ;
+
+ switch (retval)
+ { case -EAGAIN :
+ puts ("alsa_write_float: EAGAIN") ;
+ continue ;
+ break ;
+
+ case -EPIPE :
+ if (epipe_count > 0)
+ { printf ("alsa_write_float: EPIPE %d\n", epipe_count) ;
+ if (epipe_count > 140)
+ return retval ;
+ } ;
+ epipe_count += 100 ;
+
+#if 0
+ if (0)
+ { snd_pcm_status_t *status ;
+
+ snd_pcm_status_alloca (&status) ;
+ if ((retval = snd_pcm_status (alsa_dev, status)) < 0)
+ fprintf (stderr, "alsa_out: xrun. can't determine length\n") ;
+ else if (snd_pcm_status_get_state (status) == SND_PCM_STATE_XRUN)
+ { struct timeval now, diff, tstamp ;
+
+ gettimeofday (&now, 0) ;
+ snd_pcm_status_get_trigger_tstamp (status, &tstamp) ;
+ timersub (&now, &tstamp, &diff) ;
+
+ fprintf (stderr, "alsa_write_float xrun: of at least %.3f msecs. resetting stream\n",
+ diff.tv_sec * 1000 + diff.tv_usec / 1000.0) ;
+ }
+ else
+ fprintf (stderr, "alsa_write_float: xrun. can't determine length\n") ;
+ } ;
+#endif
+
+ snd_pcm_prepare (alsa_dev) ;
+ break ;
+
+ case -EBADFD :
+ fprintf (stderr, "alsa_write_float: Bad PCM state.n") ;
+ return 0 ;
+ break ;
+
+ case -ESTRPIPE :
+ fprintf (stderr, "alsa_write_float: Suspend event.n") ;
+ return 0 ;
+ break ;
+
+ case -EIO :
+ puts ("alsa_write_float: EIO") ;
+ return 0 ;
+
+ default :
+ fprintf (stderr, "alsa_write_float: retval = %d\n", retval) ;
+ return 0 ;
+ break ;
+ } ; /* switch */
+ } ; /* while */
+
+ return total ;
+} /* alsa_write_float */
+
+#endif /* HAVE_ALSA_ASOUNDLIB_H */
+
+/*------------------------------------------------------------------------------
+** Linux/OSS functions for playing a sound.
+*/
+
+#if defined (__linux__)
+
+static int linux_open_dsp_device (int channels, int srate) ;
+
+static void
+linux_play (int argc, char *argv [])
+{ static short buffer [BUFFER_LEN] ;
+ SNDFILE *sndfile ;
+ SF_INFO sfinfo ;
+ int k, audio_device, readcount, writecount, subformat ;
+
+ for (k = 1 ; k < argc ; k++)
+ { memset (&sfinfo, 0, sizeof (sfinfo)) ;
+
+ printf ("Playing %s\n", argv [k]) ;
+ if (! (sndfile = sf_open (argv [k], SFM_READ, &sfinfo)))
+ { puts (sf_strerror (NULL)) ;
+ continue ;
+ } ;
+
+ if (sfinfo.channels < 1 || sfinfo.channels > 2)
+ { printf ("Error : channels = %d.\n", sfinfo.channels) ;
+ continue ;
+ } ;
+
+ audio_device = linux_open_dsp_device (sfinfo.channels, sfinfo.samplerate) ;
+
+ subformat = sfinfo.format & SF_FORMAT_SUBMASK ;
+
+ if (subformat == SF_FORMAT_FLOAT || subformat == SF_FORMAT_DOUBLE)
+ { static float float_buffer [BUFFER_LEN] ;
+ double scale ;
+ int m ;
+
+ sf_command (sndfile, SFC_CALC_SIGNAL_MAX, &scale, sizeof (scale)) ;
+ if (scale < 1e-10)
+ scale = 1.0 ;
+ else
+ scale = 32700.0 / scale ;
+
+ while ((readcount = sf_read_float (sndfile, float_buffer, BUFFER_LEN)))
+ { for (m = 0 ; m < readcount ; m++)
+ buffer [m] = scale * float_buffer [m] ;
+ writecount = write (audio_device, buffer, readcount * sizeof (short)) ;
+ } ;
+ }
+ else
+ { while ((readcount = sf_read_short (sndfile, buffer, BUFFER_LEN)))
+ writecount = write (audio_device, buffer, readcount * sizeof (short)) ;
+ } ;
+
+ if (ioctl (audio_device, SNDCTL_DSP_POST, 0) == -1)
+ perror ("ioctl (SNDCTL_DSP_POST) ") ;
+
+ if (ioctl (audio_device, SNDCTL_DSP_SYNC, 0) == -1)
+ perror ("ioctl (SNDCTL_DSP_SYNC) ") ;
+
+ close (audio_device) ;
+
+ sf_close (sndfile) ;
+ } ;
+
+ return ;
+} /* linux_play */
+
+static int
+linux_open_dsp_device (int channels, int srate)
+{ int fd, stereo, fmt ;
+
+ if ((fd = open ("/dev/dsp", O_WRONLY, 0)) == -1 &&
+ (fd = open ("/dev/sound/dsp", O_WRONLY, 0)) == -1)
+ { perror ("linux_open_dsp_device : open ") ;
+ exit (1) ;
+ } ;
+
+ stereo = 0 ;
+ if (ioctl (fd, SNDCTL_DSP_STEREO, &stereo) == -1)
+ { /* Fatal error */
+ perror ("linux_open_dsp_device : stereo ") ;
+ exit (1) ;
+ } ;
+
+ if (ioctl (fd, SNDCTL_DSP_RESET, 0))
+ { perror ("linux_open_dsp_device : reset ") ;
+ exit (1) ;
+ } ;
+
+ fmt = CPU_IS_BIG_ENDIAN ? AFMT_S16_BE : AFMT_S16_LE ;
+ if (ioctl (fd, SNDCTL_DSP_SETFMT, &fmt) != 0)
+ { perror ("linux_open_dsp_device : set format ") ;
+ exit (1) ;
+ } ;
+
+ if (ioctl (fd, SNDCTL_DSP_CHANNELS, &channels) != 0)
+ { perror ("linux_open_dsp_device : channels ") ;
+ exit (1) ;
+ } ;
+
+ if (ioctl (fd, SNDCTL_DSP_SPEED, &srate) != 0)
+ { perror ("linux_open_dsp_device : sample rate ") ;
+ exit (1) ;
+ } ;
+
+ if (ioctl (fd, SNDCTL_DSP_SYNC, 0) != 0)
+ { perror ("linux_open_dsp_device : sync ") ;
+ exit (1) ;
+ } ;
+
+ return fd ;
+} /* linux_open_dsp_device */
+
+#endif /* __linux__ */
+
+/*------------------------------------------------------------------------------
+** Mac OS X functions for playing a sound.
+*/
+
+#if (defined (__MACH__) && defined (__APPLE__)) /* MacOSX */
+
+typedef struct
+{ AudioStreamBasicDescription format ;
+
+ UInt32 buf_size ;
+ AudioDeviceID device ;
+
+ SNDFILE *sndfile ;
+ SF_INFO sfinfo ;
+
+ int fake_stereo ;
+ int done_playing ;
+} MacOSXAudioData ;
+
+#include <math.h>
+
+static OSStatus
+macosx_audio_out_callback (AudioDeviceID device, const AudioTimeStamp* current_time,
+ const AudioBufferList* data_in, const AudioTimeStamp* time_in,
+ AudioBufferList* data_out, const AudioTimeStamp* time_out,
+ void* client_data)
+{ MacOSXAudioData *audio_data ;
+ int size, sample_count, read_count, k ;
+ float *buffer ;
+
+ /* Prevent compiler warnings. */
+ device = device ;
+ current_time = current_time ;
+ data_in = data_in ;
+ time_in = time_in ;
+ time_out = time_out ;
+
+ audio_data = (MacOSXAudioData*) client_data ;
+
+ size = data_out->mBuffers [0].mDataByteSize ;
+ sample_count = size / sizeof (float) ;
+
+ buffer = (float*) data_out->mBuffers [0].mData ;
+
+ if (audio_data->fake_stereo != 0)
+ { read_count = sf_read_float (audio_data->sndfile, buffer, sample_count / 2) ;
+
+ for (k = read_count - 1 ; k >= 0 ; k--)
+ { buffer [2 * k ] = buffer [k] ;
+ buffer [2 * k + 1] = buffer [k] ;
+ } ;
+ read_count *= 2 ;
+ }
+ else
+ read_count = sf_read_float (audio_data->sndfile, buffer, sample_count) ;
+
+ /* Fill the remainder with zeroes. */
+ if (read_count < sample_count)
+ { if (audio_data->fake_stereo == 0)
+ memset (&(buffer [read_count]), 0, (sample_count - read_count) * sizeof (float)) ;
+ /* Tell the main application to terminate. */
+ audio_data->done_playing = SF_TRUE ;
+ } ;
+
+ return noErr ;
+} /* macosx_audio_out_callback */
+
+static void
+macosx_play (int argc, char *argv [])
+{ MacOSXAudioData audio_data ;
+ OSStatus err ;
+ UInt32 count, buffer_size ;
+ int k ;
+
+ audio_data.fake_stereo = 0 ;
+ audio_data.device = kAudioDeviceUnknown ;
+
+ /* get the default output device for the HAL */
+ count = sizeof (AudioDeviceID) ;
+ if ((err = AudioHardwareGetProperty (kAudioHardwarePropertyDefaultOutputDevice,
+ &count, (void *) &(audio_data.device))) != noErr)
+ { printf ("AudioHardwareGetProperty (kAudioDevicePropertyDefaultOutputDevice) failed.\n") ;
+ return ;
+ } ;
+
+ /* get the buffersize that the default device uses for IO */
+ count = sizeof (UInt32) ;
+ if ((err = AudioDeviceGetProperty (audio_data.device, 0, false, kAudioDevicePropertyBufferSize,
+ &count, &buffer_size)) != noErr)
+ { printf ("AudioDeviceGetProperty (kAudioDevicePropertyBufferSize) failed.\n") ;
+ return ;
+ } ;
+
+ /* get a description of the data format used by the default device */
+ count = sizeof (AudioStreamBasicDescription) ;
+ if ((err = AudioDeviceGetProperty (audio_data.device, 0, false, kAudioDevicePropertyStreamFormat,
+ &count, &(audio_data.format))) != noErr)
+ { printf ("AudioDeviceGetProperty (kAudioDevicePropertyStreamFormat) failed.\n") ;
+ return ;
+ } ;
+
+ /* Base setup completed. Now play files. */
+ for (k = 1 ; k < argc ; k++)
+ { printf ("Playing %s\n", argv [k]) ;
+ if (! (audio_data.sndfile = sf_open (argv [k], SFM_READ, &(audio_data.sfinfo))))
+ { puts (sf_strerror (NULL)) ;
+ continue ;
+ } ;
+
+ if (audio_data.sfinfo.channels < 1 || audio_data.sfinfo.channels > 2)
+ { printf ("Error : channels = %d.\n", audio_data.sfinfo.channels) ;
+ continue ;
+ } ;
+
+ audio_data.format.mSampleRate = audio_data.sfinfo.samplerate ;
+
+ if (audio_data.sfinfo.channels == 1)
+ { audio_data.format.mChannelsPerFrame = 2 ;
+ audio_data.fake_stereo = 1 ;
+ }
+ else
+ audio_data.format.mChannelsPerFrame = audio_data.sfinfo.channels ;
+
+ if ((err = AudioDeviceSetProperty (audio_data.device, NULL, 0, false, kAudioDevicePropertyStreamFormat,
+ sizeof (AudioStreamBasicDescription), &(audio_data.format))) != noErr)
+ { printf ("AudioDeviceSetProperty (kAudioDevicePropertyStreamFormat) failed.\n") ;
+ return ;
+ } ;
+
+ /* we want linear pcm */
+ if (audio_data.format.mFormatID != kAudioFormatLinearPCM)
+ return ;
+
+ /* Fire off the device. */
+ if ((err = AudioDeviceAddIOProc (audio_data.device, macosx_audio_out_callback,
+ (void *) &audio_data)) != noErr)
+ { printf ("AudioDeviceAddIOProc failed.\n") ;
+ return ;
+ } ;
+
+ err = AudioDeviceStart (audio_data.device, macosx_audio_out_callback) ;
+ if (err != noErr)
+ return ;
+
+ audio_data.done_playing = SF_FALSE ;
+
+ while (audio_data.done_playing == SF_FALSE)
+ usleep (10 * 1000) ; /* 10 000 milliseconds. */
+
+ if ((err = AudioDeviceStop (audio_data.device, macosx_audio_out_callback)) != noErr)
+ { printf ("AudioDeviceStop failed.\n") ;
+ return ;
+ } ;
+
+ err = AudioDeviceRemoveIOProc (audio_data.device, macosx_audio_out_callback) ;
+ if (err != noErr)
+ { printf ("AudioDeviceRemoveIOProc failed.\n") ;
+ return ;
+ } ;
+
+ sf_close (audio_data.sndfile) ;
+ } ;
+
+ return ;
+} /* macosx_play */
+
+#endif /* MacOSX */
+
+
+/*------------------------------------------------------------------------------
+** Win32 functions for playing a sound.
+**
+** This API sucks. Its needlessly complicated and is *WAY* too loose with
+** passing pointers arounf in integers and and using char* pointers to
+** point to data instead of short*. It plain sucks!
+*/
+
+#if (OS_IS_WIN32 == 1)
+
+#define WIN32_BUFFER_LEN (1<<15)
+
+typedef struct
+{ HWAVEOUT hwave ;
+ WAVEHDR whdr [2] ;
+
+ CRITICAL_SECTION mutex ; /* to control access to BuffersInUSe */
+ HANDLE Event ; /* signal that a buffer is free */
+
+ short buffer [WIN32_BUFFER_LEN / sizeof (short)] ;
+ int current, bufferlen ;
+ int BuffersInUse ;
+
+ SNDFILE *sndfile ;
+ SF_INFO sfinfo ;
+
+ sf_count_t remaining ;
+} Win32_Audio_Data ;
+
+
+static void
+win32_play_data (Win32_Audio_Data *audio_data)
+{ int thisread, readcount ;
+
+ /* fill a buffer if there is more data and we can read it sucessfully */
+ readcount = (audio_data->remaining > audio_data->bufferlen) ? audio_data->bufferlen : (int) audio_data->remaining ;
+
+ thisread = (int) sf_read_short (audio_data->sndfile, (short *) (audio_data->whdr [audio_data->current].lpData), readcount) ;
+
+ audio_data->remaining -= thisread ;
+
+ if (thisread > 0)
+ { /* Fix buffer length if this is only a partial block. */
+ if (thisread < audio_data->bufferlen)
+ audio_data->whdr [audio_data->current].dwBufferLength = thisread * sizeof (short) ;
+
+ /* Queue the WAVEHDR */
+ waveOutWrite (audio_data->hwave, (LPWAVEHDR) &(audio_data->whdr [audio_data->current]), sizeof (WAVEHDR)) ;
+
+ /* count another buffer in use */
+ EnterCriticalSection (&audio_data->mutex) ;
+ audio_data->BuffersInUse ++ ;
+ LeaveCriticalSection (&audio_data->mutex) ;
+
+ /* use the other buffer next time */
+ audio_data->current = (audio_data->current + 1) % 2 ;
+ } ;
+
+ return ;
+} /* win32_play_data */
+
+static void CALLBACK
+win32_audio_out_callback (HWAVEOUT hwave, UINT msg, DWORD_PTR data, DWORD param1, DWORD param2)
+{ Win32_Audio_Data *audio_data ;
+
+ /* Prevent compiler warnings. */
+ hwave = hwave ;
+ param1 = param2 ;
+
+ if (data == 0)
+ return ;
+
+ /*
+ ** I consider this technique of passing a pointer via an integer as
+ ** fundamentally broken but thats the way microsoft has defined the
+ ** interface.
+ */
+ audio_data = (Win32_Audio_Data*) data ;
+
+ /* let main loop know a buffer is free */
+ if (msg == MM_WOM_DONE)
+ { EnterCriticalSection (&audio_data->mutex) ;
+ audio_data->BuffersInUse -- ;
+ LeaveCriticalSection (&audio_data->mutex) ;
+ SetEvent (audio_data->Event) ;
+ } ;
+
+ return ;
+} /* win32_audio_out_callback */
+
+static void
+win32_play (int argc, char *argv [])
+{ Win32_Audio_Data audio_data ;
+
+ WAVEFORMATEX wf ;
+ int k, error ;
+
+ audio_data.sndfile = NULL ;
+ audio_data.hwave = 0 ;
+
+ for (k = 1 ; k < argc ; k++)
+ { printf ("Playing %s\n", argv [k]) ;
+
+ if (! (audio_data.sndfile = sf_open (argv [k], SFM_READ, &(audio_data.sfinfo))))
+ { puts (sf_strerror (NULL)) ;
+ continue ;
+ } ;
+
+ audio_data.remaining = audio_data.sfinfo.frames * audio_data.sfinfo.channels ;
+ audio_data.current = 0 ;
+
+ InitializeCriticalSection (&audio_data.mutex) ;
+ audio_data.Event = CreateEvent (0, FALSE, FALSE, 0) ;
+
+ wf.nChannels = audio_data.sfinfo.channels ;
+ wf.wFormatTag = WAVE_FORMAT_PCM ;
+ wf.cbSize = 0 ;
+ wf.wBitsPerSample = 16 ;
+
+ wf.nSamplesPerSec = audio_data.sfinfo.samplerate ;
+
+ wf.nBlockAlign = audio_data.sfinfo.channels * sizeof (short) ;
+
+ wf.nAvgBytesPerSec = wf.nBlockAlign * wf.nSamplesPerSec ;
+
+ error = waveOutOpen (&(audio_data.hwave), WAVE_MAPPER, &wf, (DWORD_PTR) win32_audio_out_callback,
+ (DWORD_PTR) &audio_data, CALLBACK_FUNCTION) ;
+ if (error)
+ { puts ("waveOutOpen failed.") ;
+ audio_data.hwave = 0 ;
+ continue ;
+ } ;
+
+ audio_data.whdr [0].lpData = (char*) audio_data.buffer ;
+ audio_data.whdr [1].lpData = ((char*) audio_data.buffer) + sizeof (audio_data.buffer) / 2 ;
+
+ audio_data.whdr [0].dwBufferLength = sizeof (audio_data.buffer) / 2 ;
+ audio_data.whdr [1].dwBufferLength = sizeof (audio_data.buffer) / 2 ;
+
+ audio_data.whdr [0].dwFlags = 0 ;
+ audio_data.whdr [1].dwFlags = 0 ;
+
+ /* length of each audio buffer in samples */
+ audio_data.bufferlen = sizeof (audio_data.buffer) / 2 / sizeof (short) ;
+
+ /* Prepare the WAVEHDRs */
+ if ((error = waveOutPrepareHeader (audio_data.hwave, &(audio_data.whdr [0]), sizeof (WAVEHDR))))
+ { printf ("waveOutPrepareHeader [0] failed : %08X\n", error) ;
+ waveOutClose (audio_data.hwave) ;
+ continue ;
+ } ;
+
+ if ((error = waveOutPrepareHeader (audio_data.hwave, &(audio_data.whdr [1]), sizeof (WAVEHDR))))
+ { printf ("waveOutPrepareHeader [1] failed : %08X\n", error) ;
+ waveOutUnprepareHeader (audio_data.hwave, &(audio_data.whdr [0]), sizeof (WAVEHDR)) ;
+ waveOutClose (audio_data.hwave) ;
+ continue ;
+ } ;
+
+ /* Fill up both buffers with audio data */
+ audio_data.BuffersInUse = 0 ;
+ win32_play_data (&audio_data) ;
+ win32_play_data (&audio_data) ;
+
+ /* loop until both buffers are released */
+ while (audio_data.BuffersInUse > 0)
+ {
+ /* wait for buffer to be released */
+ WaitForSingleObject (audio_data.Event, INFINITE) ;
+
+ /* refill the buffer if there is more data to play */
+ win32_play_data (&audio_data) ;
+ } ;
+
+ waveOutUnprepareHeader (audio_data.hwave, &(audio_data.whdr [0]), sizeof (WAVEHDR)) ;
+ waveOutUnprepareHeader (audio_data.hwave, &(audio_data.whdr [1]), sizeof (WAVEHDR)) ;
+
+ waveOutClose (audio_data.hwave) ;
+ audio_data.hwave = 0 ;
+
+ DeleteCriticalSection (&audio_data.mutex) ;
+
+ sf_close (audio_data.sndfile) ;
+ } ;
+
+} /* win32_play */
+
+#endif /* Win32 */
+
+/*------------------------------------------------------------------------------
+** Solaris.
+*/
+
+#if (defined (sun) && defined (unix)) /* ie Solaris */
+
+static void
+solaris_play (int argc, char *argv [])
+{ static short buffer [BUFFER_LEN] ;
+ audio_info_t audio_info ;
+ SNDFILE *sndfile ;
+ SF_INFO sfinfo ;
+ unsigned long delay_time ;
+ long k, start_count, output_count, write_count, read_count ;
+ int audio_fd, error, done ;
+
+ for (k = 1 ; k < argc ; k++)
+ { printf ("Playing %s\n", argv [k]) ;
+ if (! (sndfile = sf_open (argv [k], SFM_READ, &sfinfo)))
+ { puts (sf_strerror (NULL)) ;
+ continue ;
+ } ;
+
+ if (sfinfo.channels < 1 || sfinfo.channels > 2)
+ { printf ("Error : channels = %d.\n", sfinfo.channels) ;
+ continue ;
+ } ;
+
+ /* open the audio device - write only, non-blocking */
+ if ((audio_fd = open ("/dev/audio", O_WRONLY | O_NONBLOCK)) < 0)
+ { perror ("open (/dev/audio) failed") ;
+ return ;
+ } ;
+
+ /* Retrive standard values. */
+ AUDIO_INITINFO (&audio_info) ;
+
+ audio_info.play.sample_rate = sfinfo.samplerate ;
+ audio_info.play.channels = sfinfo.channels ;
+ audio_info.play.precision = 16 ;
+ audio_info.play.encoding = AUDIO_ENCODING_LINEAR ;
+ audio_info.play.gain = AUDIO_MAX_GAIN ;
+ audio_info.play.balance = AUDIO_MID_BALANCE ;
+
+ if ((error = ioctl (audio_fd, AUDIO_SETINFO, &audio_info)))
+ { perror ("ioctl (AUDIO_SETINFO) failed") ;
+ return ;
+ } ;
+
+ /* Delay time equal to 1/4 of a buffer in microseconds. */
+ delay_time = (BUFFER_LEN * 1000000) / (audio_info.play.sample_rate * 4) ;
+
+ done = 0 ;
+ while (! done)
+ { read_count = sf_read_short (sndfile, buffer, BUFFER_LEN) ;
+ if (read_count < BUFFER_LEN)
+ { memset (&(buffer [read_count]), 0, (BUFFER_LEN - read_count) * sizeof (short)) ;
+ /* Tell the main application to terminate. */
+ done = SF_TRUE ;
+ } ;
+
+ start_count = 0 ;
+ output_count = BUFFER_LEN * sizeof (short) ;
+
+ while (output_count > 0)
+ { /* write as much data as possible */
+ write_count = write (audio_fd, &(buffer [start_count]), output_count) ;
+ if (write_count > 0)
+ { output_count -= write_count ;
+ start_count += write_count ;
+ }
+ else
+ { /* Give the audio output time to catch up. */
+ usleep (delay_time) ;
+ } ;
+ } ; /* while (outpur_count > 0) */
+ } ; /* while (! done) */
+
+ close (audio_fd) ;
+ } ;
+
+ return ;
+} /* solaris_play */
+
+#endif /* Solaris */
+
+/*==============================================================================
+** Main function.
+*/
+
+int
+main (int argc, char *argv [])
+{
+ if (argc < 2)
+ {
+ printf ("\nUsage : %s <input sound file>\n\n", argv [0]) ;
+#if (OS_IS_WIN32 == 1)
+ printf ("This is a Unix style command line application which\n"
+ "should be run in a MSDOS box or Command Shell window.\n\n") ;
+ printf ("Sleeping for 5 seconds before exiting.\n\n") ;
+
+ /* This is the officially blessed by microsoft way but I can't get
+ ** it to link.
+ ** Sleep (15) ;
+ ** Instead, use this:
+ */
+ Sleep (5 * 1000) ;
+#endif
+ return 1 ;
+ } ;
+
+#if defined (__linux__)
+ #if HAVE_ALSA_ASOUNDLIB_H
+ if (access ("/proc/asound/cards", R_OK) == 0)
+ alsa_play (argc, argv) ;
+ else
+ #endif
+ linux_play (argc, argv) ;
+#elif (defined (__MACH__) && defined (__APPLE__))
+ macosx_play (argc, argv) ;
+#elif (defined (sun) && defined (unix))
+ solaris_play (argc, argv) ;
+#elif (OS_IS_WIN32 == 1)
+ win32_play (argc, argv) ;
+#elif defined (__BEOS__)
+ printf ("This program cannot be compiled on BeOS.\n") ;
+ printf ("Instead, compile the file sfplay_beos.cpp.\n") ;
+ return 1 ;
+#else
+ puts ("*** Playing sound not yet supported on this platform.") ;
+ puts ("*** Please feel free to submit a patch.") ;
+ return 1 ;
+#endif
+
+ return 0 ;
+} /* main */
+
Added: freeswitch/trunk/libs/libsndfile/programs/test-sndfile-metadata-set.py
==============================================================================
--- (empty file)
+++ freeswitch/trunk/libs/libsndfile/programs/test-sndfile-metadata-set.py Thu May 21 16:09:30 2009
@@ -0,0 +1,187 @@
+#!/usr/bin/python
+
+# Copyright (C) 2008 Erik de Castro Lopo <erikd at mega-nerd.com>
+#
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in
+# the documentation and/or other materials provided with the
+# distribution.
+# * Neither the author nor the names of any contributors may be used
+# to endorse or promote products derived from this software without
+# specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+# Simple test script for the sndfile-metadata-set program.
+
+import commands, os, sys
+import time, datetime
+
+def print_test_name (name):
+ print " %-30s :" % name,
+
+def assert_info (filename, arg, value):
+ cmd = "./sndfile-metadata-get %s %s" % (arg, filename)
+ status, output = commands.getstatusoutput (cmd)
+ if status:
+ print "\n\nError : command '%s' should not have failed." % cmd
+ sys.exit (1)
+ if output.find (value) < 0:
+ print "\n\nError : not able to find '%s'." % value
+ print output
+ sys.exit (1)
+ return
+
+
+def check_executable (name):
+ if not (os.path.isfile (name)):
+ print "\n\nError : Can't find executable '%s'. Have you run make?" % name
+ sys.exit (1)
+
+def test_empty_fail ():
+ print_test_name ("Empty fail test")
+ cmd = "./sndfile-metadata-set --bext-description Alpha sine.wav"
+ status, output = commands.getstatusoutput (cmd)
+ if not status:
+ print "\n\nError : command '%s' should have failed." % cmd
+ sys.exit (1)
+ print "ok"
+
+def test_copy ():
+ print_test_name ("Copy test")
+ cmd = "./sndfile-metadata-set --bext-description \"First Try\" sine.wav output.wav"
+ status, output = commands.getstatusoutput (cmd)
+ if status:
+ print "\n\nError : command '%s' should not have failed." % cmd
+ sys.exit (1)
+ assert_info ("output.wav", "--bext-description", "First Try")
+ print "ok"
+
+def test_update (tests):
+ print_test_name ("Update test")
+ for arg, value in tests:
+ cmd = "./sndfile-metadata-set %s \"%s\" output.wav" % (arg, value)
+ status, output = commands.getstatusoutput (cmd)
+ if status:
+ print "\n\nError : command '%s' should not have failed." % cmd
+ sys.exit (1)
+ assert_info ("output.wav", arg, value)
+ print "ok"
+
+def test_post_mod (tests):
+ print_test_name ("Post mod test")
+ for arg, value in tests:
+ assert_info ("output.wav", arg, value)
+ print "ok"
+
+def test_auto_date ():
+ print_test_name ("Auto date test")
+ cmd = "./sndfile-metadata-set --bext-auto-time-date sine.wav date-time.wav"
+ status, output = commands.getstatusoutput (cmd)
+ if status:
+ print "\n\nError : command '%s' should not have failed." % cmd
+ sys.exit (1)
+ target = datetime.date.today ().__str__ ()
+ assert_info ("date-time.wav", "--bext-orig-date", target)
+ print "ok"
+
+
+#-------------------------------------------------------------------------------
+
+def test_coding_history ():
+ print_test_name ("Coding history test")
+ cmd = "./sndfile-metadata-set --bext-coding-hist \"alpha beta\" output.wav"
+ status, output = commands.getstatusoutput (cmd)
+ if status:
+ print "\n\nError : command '%s' should not have failed." % cmd
+ sys.exit (1)
+ cmd = "./sndfile-metadata-get --bext-coding-hist output.wav"
+ status, output = commands.getstatusoutput (cmd)
+ if status:
+ print "\n\nError : command '%s' should not have failed." % cmd
+ sys.exit (1)
+ print "ok"
+
+#-------------------------------------------------------------------------------
+
+def test_rewrite ():
+ print_test_name ("Rewrite test")
+ cmd = "./sndfile-metadata-set --bext-originator \"Really, really long string\" output.wav"
+ status, output = commands.getstatusoutput (cmd)
+ if status:
+ print "\n\nError : command '%s' should not have failed." % cmd
+ sys.exit (1)
+ cmd = "./sndfile-metadata-set --bext-originator \"Short\" output.wav"
+ status, output = commands.getstatusoutput (cmd)
+ if status:
+ print "\n\nError : command '%s' should not have failed." % cmd
+ sys.exit (1)
+ cmd = "./sndfile-metadata-get --bext-originator output.wav"
+ status, output = commands.getstatusoutput (cmd)
+ if status:
+ print "\n\nError : command '%s' should not have failed." % cmd
+ sys.exit (1)
+ if output.find ("really long") > 0:
+ print "\n\nError : output '%s' should not contain 'really long'." % output
+ sys.exit (1)
+ print "ok"
+
+#===============================================================================
+
+test_dir = "programs"
+
+if os.path.isdir (test_dir):
+ os.chdir (test_dir)
+
+for f in [ "sndfile-metadata-set", "sndfile-metadata-get", "../examples/make_sine" ]:
+ check_executable (f)
+
+os.system ("../examples/make_sine")
+if not os.path.isfile ("sine.wav"):
+ print "\n\nError : Can't file file 'sine.wav'."
+ sys.exit (1)
+
+print ""
+
+test_empty_fail ()
+test_copy ()
+
+tests = [
+ ("--bext-description", "Alpha"), ("--bext-originator", "Beta"), ("--bext-orig-ref", "Charlie"),
+ ("--bext-umid", "Delta"), ("--bext-orig-date", "2001-10-01"), ("--bext-orig-time", "01:02:03"),
+ ("--str-title", "Echo"), ("--str-artist", "Fox trot")
+ ]
+
+test_auto_date ()
+test_update (tests)
+test_post_mod (tests)
+
+test_update ([ ("--str-artist", "Fox") ])
+
+test_coding_history ()
+
+test_rewrite ()
+
+
+print ""
+
+sys.exit (0)
+
Modified: freeswitch/trunk/libs/libsndfile/regtest/Makefile.am
==============================================================================
--- freeswitch/trunk/libs/libsndfile/regtest/Makefile.am (original)
+++ freeswitch/trunk/libs/libsndfile/regtest/Makefile.am Thu May 21 16:09:30 2009
@@ -4,15 +4,8 @@
noinst_HEADERS = regtest.h
-SNDFILEDIR =../src
-INCLUDES = -I$(srcdir)/$(SNDFILEDIR) $(OS_SPECIFIC_CFLAGS)
+INCLUDES = -I$(top_srcdir)/src $(SQLITE3_CFLAGS) $(OS_SPECIFIC_CFLAGS)
sndfile_regtest_SOURCES = sndfile-regtest.c database.c checksum.c
-sndfile_regtest_LDADD = $(SNDFILEDIR)/libsndfile.la $(SQLITE3_LIBS)
+sndfile_regtest_LDADD = $(top_builddir)/src/libsndfile.la $(SQLITE3_LIBS)
-
-## Do not edit or modify anything in this comment block.
-## The arch-tag line is a file identity tag for the GNU Arch
-## revision control system.
-##
-## arch-tag: ac4a9626-49ce-4bb4-9fb6-e43de0a23432
Modified: freeswitch/trunk/libs/libsndfile/regtest/checksum.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/regtest/checksum.c (original)
+++ freeswitch/trunk/libs/libsndfile/regtest/checksum.c Thu May 21 16:09:30 2009
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 2005 Erik de Castro Lopo
+** Copyright (C) 2005-2009 Erik de Castro Lopo
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
@@ -20,16 +20,15 @@
** A simple checksum for short, int and float data.
*/
-#include "config.h"
+#include "sfconfig.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <math.h>
#include <sndfile.h>
-#include "float_cast.h"
-
#include "regtest.h"
#define BIG_PRIME 999983
@@ -116,10 +115,3 @@
return start ;
} /* float_checksum */
-/*
-** Do not edit or modify anything in this comment block.
-** The following line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: 6ae999d1-dd5a-4306-9e11-d4cfc9e8ae27
-*/
Modified: freeswitch/trunk/libs/libsndfile/regtest/database.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/regtest/database.c (original)
+++ freeswitch/trunk/libs/libsndfile/regtest/database.c Thu May 21 16:09:30 2009
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 2005 Erik de Castro Lopo
+** Copyright (C) 2005-2009 Erik de Castro Lopo
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
@@ -185,8 +185,8 @@
snprintf (db->cmdbuf, sizeof (db->cmdbuf), "insert into sndfile "
"(fname, fpath, srate, frames, channels, format, checksum, logbuf) values"
- "('%s','%s',%d,'%lld', %d, '0x%08x', '0x%08x', '%s');",
- db->filename, db->pathname, info.samplerate, info.frames, info.channels, info.format, checksum, db->logbuf) ;
+ "('%s','%s',%d,'%ld', %d, '0x%08x', '0x%08x', '%s');",
+ db->filename, db->pathname, info.samplerate, (long) info.frames, info.channels, info.format, checksum, db->logbuf) ;
if (strlen (db->cmdbuf) >= sizeof (db->cmdbuf) - 1)
{ printf ("strlen (db->cmdbuf) too long.\n") ;
@@ -311,8 +311,8 @@
exit (1) ;
} ;
- strncpy (db->filename, result [2], sizeof (db->filename)) ;
- strncpy (db->pathname, result [3], sizeof (db->pathname)) ;
+ snprintf (db->filename, sizeof (db->filename), "%s", result [2]) ;
+ snprintf (db->pathname, sizeof (db->pathname), "%s", result [3]) ;
sqlite3_free_table (result) ;
@@ -368,7 +368,7 @@
if (strcmp (result [k], "frames") == 0)
{ if (strtoll (result [k + cols], NULL, 10) == info.frames)
continue ;
- printf ("\n\nError : frames doesn't match : %s == %lld\n", result [k + cols], info.frames) ;
+ printf ("\n\nError : frames doesn't match : %s == %ld\n", result [k + cols], (long) info.frames) ;
} ;
if (strcmp (result [k], "channels") == 0)
@@ -411,6 +411,7 @@
static void
get_filename_pathname (REGTEST_DB * db, const char *filepath)
{ const char * cptr ;
+ int slen ;
if (filepath [0] != '/')
{ memset (db->pathname, 0, sizeof (db->pathname)) ;
@@ -419,18 +420,19 @@
exit (1) ;
} ;
- db->pathname [strlen (db->pathname)] = '/' ;
- strncat (db->pathname, filepath, sizeof (db->pathname)) ;
+ slen = strlen (db->pathname) ;
+ db->pathname [slen ++] = '/' ;
+ snprintf (db->pathname + slen, sizeof (db->pathname) - slen, "%s", filepath) ;
}
else
- strncpy (db->pathname, filepath, sizeof (db->pathname)) ;
+ snprintf (db->pathname, sizeof (db->pathname), "%s", filepath) ;
if ((cptr = strrchr (db->pathname, '/')) == NULL)
{ printf ("\nError : bad pathname %s\n", filepath) ;
exit (1) ;
} ;
- strncpy (db->filename, cptr + 1, sizeof (db->filename)) ;
+ snprintf (db->filename, sizeof (db->filename), "%s", cptr + 1) ;
} /* get filename_pathname */
static void
@@ -443,9 +445,9 @@
count_callback (REGTEST_DB * db, int argc, char **argv, char **colname)
{ db->count ++ ;
- argc = 0 ;
- argv = NULL ;
- colname = NULL ;
+ (void) argc ;
+ (void) argv ;
+ (void) colname ;
return 0 ;
} /* count_callback */
@@ -453,8 +455,8 @@
ekey_max_callback (REGTEST_DB * db, int argc, char **argv, char **unused)
{ int ekey ;
- argc = 0 ;
- unused = NULL ;
+ (void) argc ;
+ (void) unused ;
ekey = strtol (argv [0], NULL, 10) ;
if (ekey > db->ekey_max)
@@ -467,7 +469,7 @@
callback (void *unused, int argc, char **argv, char **colname)
{ int k ;
- unused = NULL ;
+ (void) unused ;
for (k = 0 ; k < argc ; k++)
printf ("%s = %s\n", colname [k], argv [k] ? argv [k] : "NULL") ;
@@ -491,12 +493,3 @@
} /* dummy */
#endif
-
-
-/*
-** Do not edit or modify anything in this comment block.
-** The following line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: c6bcb7cb-0d9e-47b6-a89a-66304df4d462
-*/
Modified: freeswitch/trunk/libs/libsndfile/regtest/regtest.h
==============================================================================
--- freeswitch/trunk/libs/libsndfile/regtest/regtest.h (original)
+++ freeswitch/trunk/libs/libsndfile/regtest/regtest.h Thu May 21 16:09:30 2009
@@ -36,10 +36,3 @@
/* In checksum.c */
int calc_checksum (SNDFILE * file, const SF_INFO * info) ;
-/*
-** Do not edit or modify anything in this comment block.
-** The following line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: 80138e38-f373-48d3-8152-7f7882a62cd7
-*/
Modified: freeswitch/trunk/libs/libsndfile/regtest/sndfile-regtest.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/regtest/sndfile-regtest.c (original)
+++ freeswitch/trunk/libs/libsndfile/regtest/sndfile-regtest.c Thu May 21 16:09:30 2009
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 2005 Erik de Castro Lopo
+** Copyright (C) 2005-2009 Erik de Castro Lopo
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
@@ -119,10 +119,3 @@
#endif
-/*
-** Do not edit or modify anything in this comment block.
-** The following line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: 7f318f08-9bfa-4249-856d-fe994819bdce
-*/
Modified: freeswitch/trunk/libs/libsndfile/src/G72x/Makefile.am
==============================================================================
--- freeswitch/trunk/libs/libsndfile/src/G72x/Makefile.am (original)
+++ freeswitch/trunk/libs/libsndfile/src/G72x/Makefile.am Thu May 21 16:09:30 2009
@@ -14,15 +14,9 @@
g72x_test_SOURCES = g72x_test.c
g72x_test_LDADD = ./libg72x.la -lm
-check: g72x_test
- ./g72x_test all
+check: g72x_test$(EXEEXT)
+ ./g72x_test$(EXEEXT) all
# Disable autoheader.
AUTOHEADER=echo
-## Do not edit or modify anything in this comment block.
-## The arch-tag line is a file identity tag for the GNU Arch
-## revision control system.
-##
-## arch-tag: d417a8e8-da7f-423d-884d-f03c93379348
-
Modified: freeswitch/trunk/libs/libsndfile/src/G72x/g721.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/src/G72x/g721.c (original)
+++ freeswitch/trunk/libs/libsndfile/src/G72x/g721.c Thu May 21 16:09:30 2009
@@ -152,11 +152,4 @@
/* sr was 14-bit dynamic range */
return (sr << 2);
}
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: 101b6e25-457d-490a-99ae-e2e74a26ea24
-*/
Modified: freeswitch/trunk/libs/libsndfile/src/G72x/g723_16.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/src/G72x/g723_16.c (original)
+++ freeswitch/trunk/libs/libsndfile/src/G72x/g723_16.c Thu May 21 16:09:30 2009
@@ -159,11 +159,4 @@
/* sr was of 14-bit dynamic range */
return (sr << 2);
}
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: ae265466-c3fc-4f83-bb32-edae488a5ca5
-*/
Modified: freeswitch/trunk/libs/libsndfile/src/G72x/g723_24.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/src/G72x/g723_24.c (original)
+++ freeswitch/trunk/libs/libsndfile/src/G72x/g723_24.c Thu May 21 16:09:30 2009
@@ -136,11 +136,4 @@
return (sr << 2); /* sr was of 14-bit dynamic range */
}
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: 75389236-650b-4427-98f3-0df6e8fb24bc
-*/
Modified: freeswitch/trunk/libs/libsndfile/src/G72x/g723_40.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/src/G72x/g723_40.c (original)
+++ freeswitch/trunk/libs/libsndfile/src/G72x/g723_40.c Thu May 21 16:09:30 2009
@@ -150,11 +150,4 @@
return (sr << 2); /* sr was of 14-bit dynamic range */
}
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: eb8d9a00-32bf-4dd2-b287-01b0336d72bf
-*/
Modified: freeswitch/trunk/libs/libsndfile/src/G72x/g72x.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/src/G72x/g72x.c (original)
+++ freeswitch/trunk/libs/libsndfile/src/G72x/g72x.c Thu May 21 16:09:30 2009
@@ -87,12 +87,12 @@
/*
** The original was :
- ** wanmant = (anmant * (srn & 0x37) + 0x30) >> 4 ;
+ ** wanmant = (anmant * (srn & 0x3F) + 0x30) >> 4 ;
** but could see no valid reason for the + 0x30.
** Removed it and it improved the SNR of the codec.
*/
- wanmant = (anmant * (srn & 0x37)) >> 4 ;
+ wanmant = (anmant * (srn & 0x3F)) >> 4 ;
retval = (wanexp >= 0) ? ((wanmant << wanexp) & 0x7FFF) :
(wanmant >> -wanexp);
@@ -642,11 +642,3 @@
return bindex ;
} /* pack_bytes */
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: 6298dc75-fd0f-4062-9b90-f73ed69f22d4
-*/
-
Modified: freeswitch/trunk/libs/libsndfile/src/G72x/g72x.h
==============================================================================
--- freeswitch/trunk/libs/libsndfile/src/G72x/g72x.h (original)
+++ freeswitch/trunk/libs/libsndfile/src/G72x/g72x.h Thu May 21 16:09:30 2009
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 1999-2005 Erik de Castro Lopo <erikd at mega-nerd.com>
+** Copyright (C) 1999-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU Lesser General Public License as published by
@@ -89,11 +89,3 @@
#endif /* !G72X_HEADER_FILE */
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: 6ca84e5f-f932-4ba1-87ee-37056d921621
-*/
-
Modified: freeswitch/trunk/libs/libsndfile/src/G72x/g72x_priv.h
==============================================================================
--- freeswitch/trunk/libs/libsndfile/src/G72x/g72x_priv.h (original)
+++ freeswitch/trunk/libs/libsndfile/src/G72x/g72x_priv.h Thu May 21 16:09:30 2009
@@ -107,12 +107,3 @@
void private_init_state (G72x_STATE *state_ptr) ;
#endif /* G72X_PRIVATE_H */
-
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: d9ad4da7-0fa3-471d-8020-720b5cfb5e5b
-*/
-
Modified: freeswitch/trunk/libs/libsndfile/src/G72x/g72x_test.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/src/G72x/g72x_test.c (original)
+++ freeswitch/trunk/libs/libsndfile/src/G72x/g72x_test.c Thu May 21 16:09:30 2009
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 1999-2004 Erik de Castro Lopo <erikd at mega-nerd.com>
+** Copyright (C) 1999-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
@@ -212,11 +212,3 @@
return 0 ;
} /* oct_save_short */
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: 0597b442-a5b0-4abf-92a4-92f6c24e85a6
-*/
-
Modified: freeswitch/trunk/libs/libsndfile/src/GSM610/Makefile.am
==============================================================================
--- freeswitch/trunk/libs/libsndfile/src/GSM610/Makefile.am (original)
+++ freeswitch/trunk/libs/libsndfile/src/GSM610/Makefile.am Thu May 21 16:09:30 2009
@@ -13,9 +13,4 @@
# Disable autoheader.
AUTOHEADER=echo
-## Do not edit or modify anything in this comment block.
-## The arch-tag line is a file identity tag for the GNU Arch
-## revision control system.
-##
-## arch-tag: ba91ffbe-9d1d-4044-a1de-e8ee2f890560
Modified: freeswitch/trunk/libs/libsndfile/src/GSM610/add.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/src/GSM610/add.c (original)
+++ freeswitch/trunk/libs/libsndfile/src/GSM610/add.c Thu May 21 16:09:30 2009
@@ -12,7 +12,6 @@
#include <assert.h>
#include "gsm610_priv.h"
-#include "gsm.h"
#define saturate(x) \
((x) < MIN_WORD ? MIN_WORD : (x) > MAX_WORD ? MAX_WORD: (x))
@@ -238,11 +237,4 @@
return div;
}
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: a7398579-e2e1-4733-aa2d-4c6efc0c58ff
-*/
Modified: freeswitch/trunk/libs/libsndfile/src/GSM610/code.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/src/GSM610/code.c (original)
+++ freeswitch/trunk/libs/libsndfile/src/GSM610/code.c Thu May 21 16:09:30 2009
@@ -8,10 +8,7 @@
#include <stdlib.h>
#include <string.h>
-#include "config.h"
-
#include "gsm610_priv.h"
-#include "gsm.h"
/*
* 4.2 FIXED POINT IMPLEMENTATION OF THE RPE-LTP CODER
@@ -73,7 +70,7 @@
xmaxc++, Mc++, xMc );
/*
* Gsm_Update_of_reconstructed_short_time_residual_signal
- * ( dpp, e + 5, dp );
+ * ( dpp, State->e + 5, dp );
*/
{ register int i;
@@ -87,11 +84,4 @@
(void)memcpy( (char *)State->dp0, (char *)(State->dp0 + 160),
120 * sizeof(*State->dp0) );
}
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: ae8ef1b2-5a1e-4263-94cd-42b15dca81a3
-*/
Modified: freeswitch/trunk/libs/libsndfile/src/GSM610/config.h
==============================================================================
--- freeswitch/trunk/libs/libsndfile/src/GSM610/config.h (original)
+++ freeswitch/trunk/libs/libsndfile/src/GSM610/config.h Thu May 21 16:09:30 2009
@@ -23,11 +23,4 @@
#define HAS_UTIME_H 1 /* UTIME header file */
#endif /* CONFIG_H */
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: 5338dfef-8e59-4f51-af47-627c9ea85353
-*/
Modified: freeswitch/trunk/libs/libsndfile/src/GSM610/decode.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/src/GSM610/decode.c (original)
+++ freeswitch/trunk/libs/libsndfile/src/GSM610/decode.c Thu May 21 16:09:30 2009
@@ -7,7 +7,6 @@
#include <stdio.h>
#include "gsm610_priv.h"
-#include "gsm.h"
/*
* 4.3 FIXED POINT IMPLEMENTATION OF THE RPE-LTP DECODER
@@ -57,11 +56,4 @@
Gsm_Short_Term_Synthesis_Filter( S, LARcr, wt, s );
Postprocessing(S, s);
}
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: 11ae5b90-2e8b-400b-ac64-a69a1fc6cc41
-*/
Modified: freeswitch/trunk/libs/libsndfile/src/GSM610/gsm.h
==============================================================================
--- freeswitch/trunk/libs/libsndfile/src/GSM610/gsm.h (original)
+++ freeswitch/trunk/libs/libsndfile/src/GSM610/gsm.h Thu May 21 16:09:30 2009
@@ -48,11 +48,5 @@
void gsm_implode (gsm, gsm_signal *, gsm_byte *);
#endif /* GSM_H */
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: 8cfc7698-5433-4b6f-aeca-967c6fda4dec
-*/
+
Modified: freeswitch/trunk/libs/libsndfile/src/GSM610/gsm610_priv.h
==============================================================================
--- freeswitch/trunk/libs/libsndfile/src/GSM610/gsm610_priv.h (original)
+++ freeswitch/trunk/libs/libsndfile/src/GSM610/gsm610_priv.h Thu May 21 16:09:30 2009
@@ -298,11 +298,4 @@
#endif /* !NDEBUG */
#endif /* PRIVATE_H */
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: 8bc5fdf2-e8c8-4686-9bd7-a30b512bef0c
-*/
Modified: freeswitch/trunk/libs/libsndfile/src/GSM610/gsm_create.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/src/GSM610/gsm_create.c (original)
+++ freeswitch/trunk/libs/libsndfile/src/GSM610/gsm_create.c Thu May 21 16:09:30 2009
@@ -34,11 +34,4 @@
memset (state, 0, sizeof (struct gsm_state)) ;
state->nrp = 40 ;
}
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: 9fedb6b3-ed99-40c2-aac1-484c536261fe
-*/
Modified: freeswitch/trunk/libs/libsndfile/src/GSM610/gsm_decode.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/src/GSM610/gsm_decode.c (original)
+++ freeswitch/trunk/libs/libsndfile/src/GSM610/gsm_decode.c Thu May 21 16:09:30 2009
@@ -356,11 +356,4 @@
return 0;
}
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: 6a9b6628-821c-4a96-84c1-485ebd35f170
-*/
Modified: freeswitch/trunk/libs/libsndfile/src/GSM610/gsm_destroy.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/src/GSM610/gsm_destroy.c (original)
+++ freeswitch/trunk/libs/libsndfile/src/GSM610/gsm_destroy.c Thu May 21 16:09:30 2009
@@ -21,11 +21,4 @@
{
if (S) free((char *)S);
}
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: f423d09b-6ccc-47e0-9b18-ee1cf7a8e473
-*/
Modified: freeswitch/trunk/libs/libsndfile/src/GSM610/gsm_encode.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/src/GSM610/gsm_encode.c (original)
+++ freeswitch/trunk/libs/libsndfile/src/GSM610/gsm_encode.c Thu May 21 16:09:30 2009
@@ -446,11 +446,4 @@
}
}
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: cfe9c43d-d97c-4216-b5e5-ccd6a25b582b
-*/
Modified: freeswitch/trunk/libs/libsndfile/src/GSM610/gsm_option.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/src/GSM610/gsm_option.c (original)
+++ freeswitch/trunk/libs/libsndfile/src/GSM610/gsm_option.c Thu May 21 16:09:30 2009
@@ -64,11 +64,3 @@
}
return result;
}
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: 963ff156-506f-4359-9145-371e9060b030
-*/
-
Modified: freeswitch/trunk/libs/libsndfile/src/GSM610/long_term.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/src/GSM610/long_term.c (original)
+++ freeswitch/trunk/libs/libsndfile/src/GSM610/long_term.c Thu May 21 16:09:30 2009
@@ -9,8 +9,6 @@
#include "gsm610_priv.h"
-#include "gsm.h"
-
/*
* 4.2.11 .. 4.2.12 LONG TERM PREDICTOR (LTP) SECTION
*/
@@ -401,6 +399,15 @@
STEP_A(32); STEP_B(33); STEP_C(34); STEP_D(35);
STEP_E(36); STEP_F(37); STEP_G(38); STEP_H(39);
+# undef STEP_A
+# undef STEP_B
+# undef STEP_C
+# undef STEP_D
+# undef STEP_E
+# undef STEP_F
+# undef STEP_G
+# undef STEP_H
+
if (S0 > L_max) { L_max = S0; Nc = lambda; }
if (S1 > L_max) { L_max = S1; Nc = lambda + 1; }
if (S2 > L_max) { L_max = S2; Nc = lambda + 2; }
@@ -567,6 +574,15 @@
STEP_A(32); STEP_B(33); STEP_C(34); STEP_D(35);
STEP_E(36); STEP_F(37); STEP_G(38); STEP_H(39);
+# undef STEP_A
+# undef STEP_B
+# undef STEP_C
+# undef STEP_D
+# undef STEP_E
+# undef STEP_F
+# undef STEP_G
+# undef STEP_H
+
if (S0 > L_max) { L_max = S0; Nc = lambda; }
if (S1 > L_max) { L_max = S1; Nc = lambda + 1; }
if (S2 > L_max) { L_max = S2; Nc = lambda + 2; }
@@ -941,11 +957,3 @@
for (k = 0; k <= 119; k++) drp[ -120 + k ] = drp[ -80 + k ];
}
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: b369b90d-0284-42a0-87b0-99a25bbd93ac
-*/
-
Modified: freeswitch/trunk/libs/libsndfile/src/GSM610/lpc.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/src/GSM610/lpc.c (original)
+++ freeswitch/trunk/libs/libsndfile/src/GSM610/lpc.c Thu May 21 16:09:30 2009
@@ -9,8 +9,6 @@
#include "gsm610_priv.h"
-#include "gsm.h"
-
/*
* 4.2.4 .. 4.2.7 LPC ANALYSIS SECTION
*/
@@ -331,11 +329,3 @@
Transformation_to_Log_Area_Ratios (LARc);
Quantization_and_coding (LARc);
}
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: 63146664-a002-4e1e-8b7b-f0cc8a6a53da
-*/
-
Modified: freeswitch/trunk/libs/libsndfile/src/GSM610/preprocess.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/src/GSM610/preprocess.c (original)
+++ freeswitch/trunk/libs/libsndfile/src/GSM610/preprocess.c Thu May 21 16:09:30 2009
@@ -9,8 +9,6 @@
#include "gsm610_priv.h"
-#include "gsm.h"
-
/* 4.2.0 .. 4.2.3 PREPROCESSING SECTION
*
* After A-law to linear conversion (or directly from the
@@ -105,11 +103,3 @@
S->L_z2 = L_z2;
S->mp = mp;
}
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: b760b0d9-3a05-4da3-9dc9-441ffb905d87
-*/
-
Modified: freeswitch/trunk/libs/libsndfile/src/GSM610/rpe.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/src/GSM610/rpe.c (original)
+++ freeswitch/trunk/libs/libsndfile/src/GSM610/rpe.c Thu May 21 16:09:30 2009
@@ -9,8 +9,6 @@
#include "gsm610_priv.h"
-#include "gsm.h"
-
/* 4.2.13 .. 4.2.17 RPE ENCODING SECTION
*/
@@ -480,11 +478,3 @@
RPE_grid_positioning( Mcr, xMp, erp );
}
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: 82005b9e-1560-4e94-9ddb-00cb14867295
-*/
-
Modified: freeswitch/trunk/libs/libsndfile/src/GSM610/short_term.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/src/GSM610/short_term.c (original)
+++ freeswitch/trunk/libs/libsndfile/src/GSM610/short_term.c Thu May 21 16:09:30 2009
@@ -9,8 +9,6 @@
#include "gsm610_priv.h"
-#include "gsm.h"
-
/*
* SHORT TERM ANALYSIS FILTERING SECTION
*/
@@ -417,11 +415,3 @@
LARp_to_rp( LARp );
FILTER(S, LARp, 120, wt + 40, s + 40);
}
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: 019ac7ba-c6dd-4540-abf0-8644b6c4a633
-*/
-
Modified: freeswitch/trunk/libs/libsndfile/src/GSM610/table.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/src/GSM610/table.c (original)
+++ freeswitch/trunk/libs/libsndfile/src/GSM610/table.c Thu May 21 16:09:30 2009
@@ -15,7 +15,6 @@
#define GSM_TABLE_C
#include "gsm610_priv.h"
-#include "gsm.h"
/* Table 4.1 Quantization of the Log.-Area Ratios
*/
@@ -59,11 +58,3 @@
*/
/* i 0 1 2 3 4 5 6 7 */
word gsm_FAC[8] = { 18431, 20479, 22527, 24575, 26623, 28671, 30719, 32767 };
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: 8957c531-e6b0-4097-9202-da7ca42729ca
-*/
-
Modified: freeswitch/trunk/libs/libsndfile/src/Makefile.am
==============================================================================
--- freeswitch/trunk/libs/libsndfile/src/Makefile.am (original)
+++ freeswitch/trunk/libs/libsndfile/src/Makefile.am Thu May 21 16:09:30 2009
@@ -2,62 +2,65 @@
SUBDIRS = GSM610 G72x
+INCLUDES = @EXTERNAL_CFLAGS@
+
lib_LTLIBRARIES = libsndfile.la
include_HEADERS = sndfile.hh
nodist_include_HEADERS = sndfile.h
+noinst_LTLIBRARIES = libcommon.la
+
OS_SPECIFIC_CFLAGS = @OS_SPECIFIC_CFLAGS@
OS_SPECIFIC_LINKS = @OS_SPECIFIC_LINKS@
+SYMBOL_FILES = Symbols.linux Symbols.darwin libsndfile-1.def Symbols.os2
+
EXTRA_DIST = sndfile.h.in config.h.in test_endswap.tpl test_endswap.def \
- Symbols.linux Symbols.darwin libsndfile.def cygsndfile.def \
- create_symbols_file.py binheader_writef_check.py
+ $(SYMBOL_FILES) create_symbols_file.py binheader_writef_check.py
-noinst_HEADERS = common.h sfconfig.h sfendian.h float_cast.h wav_w64.h sf_unistd.h
+noinst_HEADERS = common.h sfconfig.h sfendian.h wav_w64.h sf_unistd.h
-noinst_PROGRAMS = test_endswap test_file_io test_log_printf
+noinst_PROGRAMS = test_main
-COMMON = sndfile.c common.c file_io.c command.c pcm.c ulaw.c alaw.c float32.c \
+COMMON = common.c file_io.c command.c pcm.c ulaw.c alaw.c float32.c \
double64.c ima_adpcm.c ms_adpcm.c gsm610.c dwvw.c vox_adpcm.c \
- interleave.c strings.c dither.c broadcast.c
+ interleave.c strings.c dither.c broadcast.c audio_detect.c \
+ ima_oki_adpcm.c ima_oki_adpcm.h chunk.c
-FILESPECIFIC = aiff.c au.c g72x.c avr.c caf.c ircam.c macbinary3.c macos.c \
- mat4.c mat5.c nist.c paf.c pvf.c raw.c svx.c voc.c htk.c dwd.c \
- ogg.c rx2.c sd2.c sds.c txw.c wve.c w64.c wav_w64.c wav.c xi.c \
- flac.c
+FILESPECIFIC = sndfile.c aiff.c au.c avr.c caf.c dwd.c flac.c g72x.c htk.c ircam.c \
+ macbinary3.c macos.c mat4.c mat5.c nist.c ogg.c paf.c pvf.c raw.c rx2.c sd2.c \
+ sds.c svx.c txw.c voc.c wve.c w64.c wav_w64.c wav.c xi.c mpc2k.c rf64.c
# MinGW requires -no-undefined if a DLL is to be built.
libsndfile_la_LDFLAGS = -no-undefined -version-info @SHARED_VERSION_INFO@ @SHLIB_VERSION_ARG@
-libsndfile_la_SOURCES = $(COMMON) $(FILESPECIFIC) $(noinst_HEADERS)
+libsndfile_la_SOURCES = $(FILESPECIFIC) $(noinst_HEADERS)
nodist_libsndfile_la_SOURCES = $(nodist_include_HEADERS)
-libsndfile_la_LIBADD = GSM610/libgsm.la G72x/libg72x.la -lm $(FLAC_LIBS)
+libsndfile_la_LIBADD = libcommon.la GSM610/libgsm.la G72x/libg72x.la \
+ @EXTERNAL_LIBS@ -lm
-test_endswap_SOURCES = test_endswap.c
+libcommon_la_SOURCES = $(COMMON)
-test_file_io_CFLAGS = $(AM_CFLAGS)
-test_file_io_SOURCES = file_io.c test_file_io.c
+test_main_SOURCES = test_main.c test_main.h test_conversions.c test_float.c test_endswap.c \
+ test_audio_detect.c test_log_printf.c test_file_io.c test_ima_oki_adpcm.c
+test_main_LDADD = libcommon.la
-test_log_printf_CFLAGS = $(AM_CFLAGS)
-test_log_printf_SOURCES = test_log_printf.c
test_endswap.c: test_endswap.def test_endswap.tpl
autogen --writable test_endswap.def
-genfiles : test_endswap.c Symbols.linux Symbols.darwin libsndfile.def cygsndfile.def
+genfiles : test_endswap.c $(SYMBOL_FILES)
-# Two test programs.
+# A single test programs.
# It is not possible to place these in the tests/ directory because they
# need access to the internals of the SF_PRIVATE struct.
-check: test_endswap test_file_io test_log_printf
+check: $(noinst_PROGRAMS)
@echo
@echo
@echo
@echo "============================================================"
- @if [ -x /usr/bin/python2.4 ]; then $(srcdir)/binheader_writef_check.py $(srcdir)/*.c ; fi
- ./test_endswap
- ./test_file_io
- ./test_log_printf
+ @if [ -x /usr/bin/python2.5 ]; then $(srcdir)/binheader_writef_check.py $(srcdir)/*.c ; fi
+ ./test_main$(EXEEXT)
@echo "============================================================"
@echo
@echo
@@ -69,19 +72,19 @@
# end user to create these files.
Symbols.linux: create_symbols_file.py
- ./create_symbols_file.py linux $(VERSION) > Symbols.linux
+ ./create_symbols_file.py linux $(VERSION) > $@
Symbols.darwin: create_symbols_file.py
- ./create_symbols_file.py darwin $(VERSION) > Symbols.darwin
+ ./create_symbols_file.py darwin $(VERSION) > $@
-libsndfile.def: create_symbols_file.py
- ./create_symbols_file.py win32 $(VERSION) > libsndfile.def
+libsndfile-1.def: create_symbols_file.py
+ ./create_symbols_file.py win32 $(VERSION) > $@
-cygsndfile.def: create_symbols_file.py
- ./create_symbols_file.py cygwin $(VERSION) > cygsndfile.def
+Symbols.os2: create_symbols_file.py
+ ./create_symbols_file.py os2 $(VERSION) > $@
# Fake dependancy to force the creation of these files.
-sndfile.c : Symbols.linux Symbols.darwin libsndfile.def cygsndfile.def
+sndfile.o : $(SYMBOL_FILES)
#======================================================================
# Disable autoheader.
@@ -95,10 +98,3 @@
command.c pcm.c ulaw.c alaw.c float32.c double64.c ima_adpcm.c : sndfile.h common.h
ms_adpcm.c gsm610.c dwvw.c vox_adpcm.c interleave.c strings.c : sndfile.h common.h
dither.c : sndfile.h common.h
-
-## Do not edit or modify anything in this comment block.
-## The arch-tag line is a file identity tag for the GNU Arch
-## revision control system.
-##
-## arch-tag: fc3511e6-4230-4bcb-9c86-f728d7a06fe7
-
Added: freeswitch/trunk/libs/libsndfile/src/Symbols.os2
==============================================================================
--- (empty file)
+++ freeswitch/trunk/libs/libsndfile/src/Symbols.os2 Thu May 21 16:09:30 2009
@@ -0,0 +1,42 @@
+; Auto-generated by create_symbols_file.py
+
+LIBRARY sndfile1.dll
+INITINSTANCE TERMINSTANCE
+CODE PRELOAD MOVEABLE DISCARDABLE
+DATA PRELOAD MOVEABLE MULTIPLE NONSHARED
+EXPORTS
+
+_sf_command @1
+_sf_open @2
+_sf_close @3
+_sf_seek @4
+_sf_error @7
+_sf_perror @8
+_sf_error_str @9
+_sf_error_number @10
+_sf_format_check @11
+_sf_read_raw @16
+_sf_readf_short @17
+_sf_readf_int @18
+_sf_readf_float @19
+_sf_readf_double @20
+_sf_read_short @21
+_sf_read_int @22
+_sf_read_float @23
+_sf_read_double @24
+_sf_write_raw @32
+_sf_writef_short @33
+_sf_writef_int @34
+_sf_writef_float @35
+_sf_writef_double @36
+_sf_write_short @37
+_sf_write_int @38
+_sf_write_float @39
+_sf_write_double @40
+_sf_strerror @50
+_sf_get_string @60
+_sf_set_string @61
+_sf_open_fd @70
+_sf_open_virtual @80
+_sf_write_sync @90
+
Modified: freeswitch/trunk/libs/libsndfile/src/aiff.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/src/aiff.c (original)
+++ freeswitch/trunk/libs/libsndfile/src/aiff.c Thu May 21 16:09:30 2009
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 1999-2006 Erik de Castro Lopo <erikd at mega-nerd.com>
+** Copyright (C) 1999-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
** Copyright (C) 2005 David Viens <davidv at plogue.com>
**
** This program is free software; you can redistribute it and/or modify
@@ -58,6 +58,8 @@
#define sowt_MARKER (MAKE_MARKER ('s', 'o', 'w', 't'))
#define twos_MARKER (MAKE_MARKER ('t', 'w', 'o', 's'))
#define raw_MARKER (MAKE_MARKER ('r', 'a', 'w', ' '))
+#define in24_MARKER (MAKE_MARKER ('i', 'n', '2', '4'))
+#define ni24_MARKER (MAKE_MARKER ('4', '2', 'n', '1'))
#define in32_MARKER (MAKE_MARKER ('i', 'n', '3', '2'))
#define ni32_MARKER (MAKE_MARKER ('2', '3', 'n', 'i'))
@@ -75,6 +77,14 @@
#define GSM_MARKER (MAKE_MARKER ('G', 'S', 'M', ' '))
#define ima4_MARKER (MAKE_MARKER ('i', 'm', 'a', '4'))
+/*
+** This value is officially assigned to Mega Nerd Pty Ltd by Apple
+** Corportation as the Application marker for libsndfile.
+**
+** See : http://developer.apple.com/faq/datatype.html
+*/
+#define m3ga_MARKER (MAKE_MARKER ('m', '3', 'g', 'a'))
+
/* Unsupported AIFC encodings.*/
#define MAC3_MARKER (MAKE_MARKER ('M', 'A', 'C', '3'))
@@ -172,8 +182,12 @@
} MARK_ID_POS ;
typedef struct
-{ sf_count_t comm_offset ;
+{ PRIV_CHUNK4 chunk4 ;
+
+ sf_count_t comm_offset ;
sf_count_t ssnd_offset ;
+
+ MARK_ID_POS *markstr ;
} AIFF_PRIVATE ;
/*------------------------------------------------------------------------------
@@ -214,7 +228,7 @@
memset (&comm_fmt, 0, sizeof (comm_fmt)) ;
- subformat = psf->sf.format & SF_FORMAT_SUBMASK ;
+ subformat = SF_CODEC (psf->sf.format) ;
if ((psf->container_data = calloc (1, sizeof (AIFF_PRIVATE))) == NULL)
return SFE_MALLOC_FAILED ;
@@ -222,7 +236,6 @@
if (psf->mode == SFM_READ || (psf->mode == SFM_RDWR && psf->filelength > 0))
{ if ((error = aiff_read_header (psf, &comm_fmt)))
return error ;
-
psf_fseek (psf, psf->dataoffset, SEEK_SET) ;
} ;
@@ -230,7 +243,7 @@
{ if (psf->is_pipe)
return SFE_NO_PIPE_WRITE ;
- if ((psf->sf.format & SF_FORMAT_TYPEMASK) != SF_FORMAT_AIFF)
+ if ((SF_CONTAINER (psf->sf.format)) != SF_FORMAT_AIFF)
return SFE_BAD_OPEN_FORMAT ;
if (psf->mode == SFM_WRITE && (subformat == SF_FORMAT_FLOAT || subformat == SF_FORMAT_DOUBLE))
@@ -257,7 +270,7 @@
psf->container_close = aiff_close ;
psf->command = aiff_command ;
- switch (psf->sf.format & SF_FORMAT_SUBMASK)
+ switch (SF_CODEC (psf->sf.format))
{ case SF_FORMAT_PCM_U8 :
error = pcm_init (psf) ;
break ;
@@ -353,13 +366,15 @@
static int
aiff_read_header (SF_PRIVATE *psf, COMM_CHUNK *comm_fmt)
{ SSND_CHUNK ssnd_fmt ;
- MARK_ID_POS *markstr = NULL ;
AIFF_PRIVATE *paiff ;
unsigned marker, dword, FORMsize, SSNDsize, bytesread ;
int k, found_chunk = 0, done = 0, error = 0 ;
char *cptr, byte ;
int instr_found = 0, mark_found = 0, mark_count = 0 ;
+ if (psf->filelength > SF_PLATFORM_S64 (0xffffffff))
+ psf_log_printf (psf, "Warning : filelength > 0xffffffff. This is bad!!!!\n") ;
+
if ((paiff = psf->container_data) == NULL)
return SFE_INTERNAL ;
@@ -390,6 +405,7 @@
return SFE_AIFF_NO_FORM ;
psf_binheader_readf (psf, "E4", &FORMsize) ;
+ pchk4_store (&(paiff->chunk4), marker, psf->headindex - 8, FORMsize) ;
if (psf->fileoffset > 0 && psf->filelength > FORMsize + 8)
{ /* Set file length. */
@@ -417,6 +433,8 @@
case COMM_MARKER :
paiff->comm_offset = psf_ftell (psf) - 4 ;
error = aiff_read_comm_chunk (psf, comm_fmt) ;
+ pchk4_store (&paiff->chunk4, marker, paiff->comm_offset, comm_fmt->size) ;
+
psf->sf.samplerate = tenbytefloat2int (comm_fmt->sampleRate) ;
psf->sf.frames = comm_fmt->numSampleFrames ;
@@ -435,6 +453,7 @@
return SFE_AIFF_PEAK_B4_COMM ;
psf_binheader_readf (psf, "E4", &dword) ;
+ pchk4_store (&paiff->chunk4, marker, psf->headindex - 8, dword) ;
psf_log_printf (psf, "%M : %d\n", marker, dword) ;
if (dword != AIFF_PEAK_CHUNK_SIZE (psf->sf.channels))
@@ -466,20 +485,22 @@
psf->peak_info->peaks [dword].value = value ;
psf->peak_info->peaks [dword].position = position ;
- LSF_SNPRINTF (cptr, sizeof (psf->u.scbuf), " %2d %-12ld %g\n",
+ snprintf (cptr, sizeof (psf->u.scbuf), " %2d %-12ld %g\n",
dword, (long) psf->peak_info->peaks [dword].position, psf->peak_info->peaks [dword].value) ;
cptr [sizeof (psf->u.scbuf) - 1] = 0 ;
psf_log_printf (psf, cptr) ;
} ;
+ psf->peak_info->peak_loc = ((found_chunk & HAVE_SSND) == 0) ? SF_PEAK_START : SF_PEAK_END ;
break ;
case SSND_MARKER :
if ((found_chunk & HAVE_AIFC) && (found_chunk & HAVE_FVER) == 0)
psf_log_printf (psf, "*** Valid AIFC files should have an FVER chunk.\n") ;
-
+
paiff->ssnd_offset = psf_ftell (psf) - 4 ;
psf_binheader_readf (psf, "E444", &SSNDsize, &(ssnd_fmt.offset), &(ssnd_fmt.blocksize)) ;
+ pchk4_store (&paiff->chunk4, marker, paiff->ssnd_offset, SSNDsize) ;
psf->datalength = SSNDsize - sizeof (ssnd_fmt) ;
psf->dataoffset = psf_ftell (psf) ;
@@ -491,27 +512,37 @@
else
psf_log_printf (psf, " SSND : %u\n", SSNDsize) ;
+ if (ssnd_fmt.offset == 0 || psf->dataoffset + ssnd_fmt.offset == ssnd_fmt.blocksize)
+ { psf_log_printf (psf, " Offset : %u\n", ssnd_fmt.offset) ;
+ psf_log_printf (psf, " Block Size : %u\n", ssnd_fmt.blocksize) ;
+
+ psf->dataoffset += ssnd_fmt.offset ;
+ psf->datalength -= ssnd_fmt.offset ;
+ }
+ else
+ { psf_log_printf (psf, " Offset : %u (Should be zero)\n", ssnd_fmt.offset) ;
+ psf_log_printf (psf, " Block Size : %u ???\n", ssnd_fmt.blocksize) ;
+ } ;
+
/* Only set dataend if there really is data at the end. */
if (psf->datalength + psf->dataoffset < psf->filelength)
psf->dataend = psf->datalength + psf->dataoffset ;
- psf_log_printf (psf, " Offset : %u\n", ssnd_fmt.offset) ;
- psf_log_printf (psf, " Block Size : %u\n", ssnd_fmt.blocksize) ;
-
found_chunk |= HAVE_SSND ;
if (! psf->sf.seekable)
break ;
- /* Seek to end of SSND chunk. */
+ /* Seek to end of SSND chunk. */
psf_fseek (psf, psf->dataoffset + psf->datalength + (SSNDsize & 1), SEEK_SET) ;
break ;
case c_MARKER :
psf_binheader_readf (psf, "E4", &dword) ;
+ pchk4_store (&paiff->chunk4, marker, psf_ftell (psf) - 8, dword) ;
if (dword == 0)
break ;
- if (dword > SIGNED_SIZEOF (psf->u.scbuf) - 1)
+ if (dword >= SIGNED_SIZEOF (psf->u.scbuf))
{ psf_log_printf (psf, " %M : %d (too big)\n", marker, dword) ;
return SFE_INTERNAL ;
} ;
@@ -519,15 +550,19 @@
cptr = psf->u.cbuf ;
psf_binheader_readf (psf, "b", cptr, dword + (dword & 1)) ;
cptr [dword] = 0 ;
+
+ psf_sanitize_string (cptr, dword) ;
+
psf_log_printf (psf, " %M : %s\n", marker, cptr) ;
psf_store_string (psf, SF_STR_COPYRIGHT, cptr) ;
break ;
case AUTH_MARKER :
psf_binheader_readf (psf, "E4", &dword) ;
+ pchk4_store (&paiff->chunk4, marker, psf_ftell (psf) - 8, dword) ;
if (dword == 0)
break ;
- if (dword > SIGNED_SIZEOF (psf->u.scbuf) - 1)
+ if (dword >= SIGNED_SIZEOF (psf->u.scbuf) - 1)
{ psf_log_printf (psf, " %M : %d (too big)\n", marker, dword) ;
return SFE_INTERNAL ;
} ;
@@ -544,6 +579,7 @@
unsigned int timestamp ;
psf_binheader_readf (psf, "E42", &dword, &count) ;
+ pchk4_store (&paiff->chunk4, marker, psf_ftell (psf) - 8, dword) ;
psf_log_printf (psf, " %M : %d\n count : %d\n", marker, dword, count) ;
dword += (dword & 1) ;
if (dword == 0)
@@ -571,7 +607,10 @@
break ;
case APPL_MARKER :
+ { unsigned appl_marker ;
+
psf_binheader_readf (psf, "E4", &dword) ;
+ pchk4_store (&paiff->chunk4, marker, psf_ftell (psf) - 8, dword) ;
if (dword == 0)
break ;
if (dword >= SIGNED_SIZEOF (psf->u.scbuf) - 1)
@@ -580,8 +619,14 @@
break ;
} ;
+ if (dword < 4)
+ { psf_log_printf (psf, " %M : %d (too small, skipping)\n", marker, dword) ;
+ psf_binheader_readf (psf, "j", dword + (dword & 1)) ;
+ break ;
+ } ;
+
cptr = psf->u.cbuf ;
- psf_binheader_readf (psf, "b", cptr, dword + (dword & 1)) ;
+ psf_binheader_readf (psf, "mb", &appl_marker, cptr, dword + (dword & 1) - 4) ;
cptr [dword] = 0 ;
for (k = 0 ; k < (int) dword ; k++)
@@ -590,15 +635,17 @@
break ;
} ;
- psf_log_printf (psf, " %M : %s\n", marker, cptr) ;
+ psf_log_printf (psf, " %M : %d\n AppSig : %M\n Name : %s\n", marker, dword, appl_marker, cptr) ;
psf_store_string (psf, SF_STR_SOFTWARE, cptr) ;
+ } ;
break ;
case NAME_MARKER :
psf_binheader_readf (psf, "E4", &dword) ;
+ pchk4_store (&paiff->chunk4, marker, psf_ftell (psf) - 8, dword) ;
if (dword == 0)
break ;
- if (dword > SIGNED_SIZEOF (psf->u.scbuf) - 2)
+ if (dword >= SIGNED_SIZEOF (psf->u.scbuf) - 2)
{ psf_log_printf (psf, " %M : %d (too big)\n", marker, dword) ;
return SFE_INTERNAL ;
} ;
@@ -612,9 +659,10 @@
case ANNO_MARKER :
psf_binheader_readf (psf, "E4", &dword) ;
+ pchk4_store (&paiff->chunk4, marker, psf_ftell (psf) - 8, dword) ;
if (dword == 0)
break ;
- if (dword > SIGNED_SIZEOF (psf->u.scbuf) - 2)
+ if (dword >= SIGNED_SIZEOF (psf->u.scbuf) - 2)
{ psf_log_printf (psf, " %M : %d (too big)\n", marker, dword) ;
return SFE_INTERNAL ;
} ;
@@ -628,6 +676,7 @@
case INST_MARKER :
psf_binheader_readf (psf, "E4", &dword) ;
+ pchk4_store (&paiff->chunk4, marker, psf_ftell (psf) - 8, dword) ;
if (dword != SIZEOF_INST_CHUNK)
{ psf_log_printf (psf, " %M : %d (should be %d)\n", marker, dword, SIZEOF_INST_CHUNK) ;
psf_binheader_readf (psf, "j", dword) ;
@@ -679,7 +728,7 @@
loop_mode = get_loop_mode_str (mode) ;
mode = get_loop_mode (mode) ;
if (mode == SF_LOOP_NONE)
- psf->instrument->loops [0].mode = SF_LOOP_NONE ;
+ psf->instrument->loops [1].mode = SF_LOOP_NONE ;
else
{ psf->instrument->loop_count += 1 ;
psf->instrument->loops [1].mode = SF_LOOP_FORWARD ;
@@ -695,6 +744,7 @@
case basc_MARKER :
psf_binheader_readf (psf, "E4", &dword) ;
+ pchk4_store (&paiff->chunk4, marker, psf_ftell (psf) - 8, dword) ;
psf_log_printf (psf, " basc : %u\n", dword) ;
if ((error = aiff_read_basc_chunk (psf, dword)))
@@ -703,6 +753,7 @@
case MARK_MARKER :
psf_binheader_readf (psf, "E4", &dword) ;
+ pchk4_store (&paiff->chunk4, marker, psf_ftell (psf) - 8, dword) ;
psf_log_printf (psf, " %M : %d\n", marker, dword) ;
{ unsigned short mark_id, n = 0 ;
unsigned char pstr_len ;
@@ -710,20 +761,27 @@
bytesread = psf_binheader_readf (psf, "E2", &n) ;
mark_count = n ;
- markstr = calloc (mark_count, sizeof (MARK_ID_POS)) ;
psf_log_printf (psf, " Count : %d\n", mark_count) ;
+ if (paiff->markstr != NULL)
+ { psf_log_printf (psf, "*** Second MARK chunk found. Throwing away the first.\n") ;
+ free (paiff->markstr) ;
+ } ;
+ paiff->markstr = calloc (mark_count, sizeof (MARK_ID_POS)) ;
+ if (paiff->markstr == NULL)
+ return SFE_MALLOC_FAILED ;
for (n = 0 ; n < mark_count && bytesread < dword ; n++)
{ bytesread += psf_binheader_readf (psf, "E241", &mark_id, &position, &pstr_len) ;
psf_log_printf (psf, " Mark ID : %u\n Position : %u\n", mark_id, position) ;
- pstr_len += (pstr_len & 1) + 1 ; /* fudgy, fudgy, hack, hack */
+ pstr_len += (pstr_len & 1) ? 0 : 1 ;
bytesread += psf_binheader_readf (psf, "b", psf->u.scbuf, pstr_len) ;
+ psf->u.scbuf [pstr_len] = 0 ;
psf_log_printf (psf, " Name : %s\n", psf->u.scbuf) ;
- markstr [n].markerID = mark_id ;
- markstr [n].position = position ;
+ paiff->markstr [n].markerID = mark_id ;
+ paiff->markstr [n].position = position ;
/*
** TODO if psf->u.scbuf is equal to
** either Beg_loop, Beg loop or beg loop and spam
@@ -742,6 +800,7 @@
case SFX_MARKER :
psf_binheader_readf (psf, "E4", &dword) ;
+ pchk4_store (&paiff->chunk4, marker, psf_ftell (psf) - 8, dword) ;
psf_log_printf (psf, " %M : %d\n", marker, dword) ;
psf_binheader_readf (psf, "j", dword) ;
@@ -786,16 +845,13 @@
for (j = 0 ; j<psf->instrument->loop_count ; j ++)
{ if (j < ARRAY_LEN (psf->instrument->loops))
- { psf->instrument->loops [j].start = marker_to_position (markstr, psf->instrument->loops [j].start, mark_count) ;
- psf->instrument->loops [j].end = marker_to_position (markstr, psf->instrument->loops [j].end, mark_count) ;
+ { psf->instrument->loops [j].start = marker_to_position (paiff->markstr, psf->instrument->loops [j].start, mark_count) ;
+ psf->instrument->loops [j].end = marker_to_position (paiff->markstr, psf->instrument->loops [j].end, mark_count) ;
psf->instrument->loops [j].mode = SF_LOOP_FORWARD ;
} ;
} ;
} ;
- if (markstr)
- free (markstr) ;
-
if (! (found_chunk & HAVE_FORM))
return SFE_AIFF_NO_FORM ;
@@ -813,7 +869,13 @@
static int
aiff_close (SF_PRIVATE *psf)
-{
+{ AIFF_PRIVATE *paiff = psf->container_data ;
+
+ if (paiff != NULL && paiff->markstr != NULL)
+ { free (paiff->markstr) ;
+ paiff->markstr = NULL ;
+ } ;
+
if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR)
{ aiff_write_tailer (psf) ;
aiff_write_header (psf, SF_TRUE) ;
@@ -840,23 +902,31 @@
psf_binheader_readf (psf, "E242b", &(comm_fmt->numChannels), &(comm_fmt->numSampleFrames),
&(comm_fmt->sampleSize), &(comm_fmt->sampleRate), SIGNED_SIZEOF (comm_fmt->sampleRate)) ;
+ if (comm_fmt->size > 0x10000 && (comm_fmt->size & 0xffff) == 0)
+ { psf_log_printf (psf, " COMM : %d (0x%x) *** should be ", comm_fmt->size, comm_fmt->size) ;
+ comm_fmt->size = ENDSWAP_INT (comm_fmt->size) ;
+ psf_log_printf (psf, "%d (0x%x)\n", comm_fmt->size, comm_fmt->size) ;
+ }
+ else
+ psf_log_printf (psf, " COMM : %d\n", comm_fmt->size) ;
+
if (comm_fmt->size == SIZEOF_AIFF_COMM)
comm_fmt->encoding = NONE_MARKER ;
else if (comm_fmt->size == SIZEOF_AIFC_COMM_MIN)
bytesread += psf_binheader_readf (psf, "Em", &(comm_fmt->encoding)) ;
else if (comm_fmt->size >= SIZEOF_AIFC_COMM)
{ unsigned char encoding_len ;
+ unsigned read_len ;
bytesread += psf_binheader_readf (psf, "Em1", &(comm_fmt->encoding), &encoding_len) ;
+ comm_fmt->size = SF_MIN (sizeof (psf->u.scbuf), make_size_t (comm_fmt->size)) ;
memset (psf->u.scbuf, 0, comm_fmt->size) ;
-
- bytesread += psf_binheader_readf (psf, "b", psf->u.scbuf,
- comm_fmt->size - SIZEOF_AIFC_COMM + 1) ;
- psf->u.scbuf [encoding_len] = 0 ;
+ read_len = comm_fmt->size - SIZEOF_AIFC_COMM + 1 ;
+ bytesread += psf_binheader_readf (psf, "b", psf->u.scbuf, read_len) ;
+ psf->u.scbuf [read_len + 1] = 0 ;
} ;
- psf_log_printf (psf, " COMM : %d\n", comm_fmt->size) ;
psf_log_printf (psf, " Sample Rate : %d\n", tenbytefloat2int (comm_fmt->sampleRate)) ;
psf_log_printf (psf, " Frames : %u%s\n", comm_fmt->numSampleFrames, (comm_fmt->numSampleFrames == 0 && psf->filelength > 104) ? " (Should not be 0)" : "") ;
psf_log_printf (psf, " Channels : %d\n", comm_fmt->numChannels) ;
@@ -883,11 +953,13 @@
break ;
case twos_MARKER :
+ case in24_MARKER :
case in32_MARKER :
psf->sf.format = (SF_ENDIAN_BIG | SF_FORMAT_AIFF | subformat) ;
break ;
case sowt_MARKER :
+ case ni24_MARKER :
case ni32_MARKER :
psf->endian = SF_ENDIAN_LITTLE ;
psf->sf.format = (SF_ENDIAN_LITTLE | SF_FORMAT_AIFF | subformat) ;
@@ -961,13 +1033,71 @@
} /* aiff_read_comm_chunk */
+/*==========================================================================================
+*/
+
+static int
+aiff_rewrite_header (SF_PRIVATE *psf, AIFF_PRIVATE * paiff)
+{
+ /* Assuming here that the header has already been written and just
+ ** needs to be corrected for new data length. That means that we
+ ** only change the length fields of the FORM and SSND chunks ;
+ ** everything else can be skipped over.
+ */
+ int k, ch ;
+ int comm_size, comm_frames ;
+
+ psf_fseek (psf, 0, SEEK_SET) ;
+ psf_fread (psf->header, psf->dataoffset, 1, psf) ;
+
+ psf->headindex = 0 ;
+
+ for (k = 0 ; k < paiff->chunk4.count ; k++)
+ { switch (paiff->chunk4.l [k].chunk)
+ { case FORM_MARKER :
+ psf_binheader_writef (psf, "Etm8", FORM_MARKER, psf->filelength - 8) ;
+ break ;
+
+ case COMM_MARKER :
+ psf->headindex = paiff->chunk4.l [k].offset ;
+ comm_frames = psf->sf.frames ;
+ comm_size = paiff->chunk4.l [k].len ;
+ psf_binheader_writef (psf, "Em42t4", COMM_MARKER, comm_size, psf->sf.channels, comm_frames) ;
+ break ;
+
+ case SSND_MARKER :
+ psf->headindex = paiff->chunk4.l [k].offset ;
+ psf_binheader_writef (psf, "Etm8", SSND_MARKER, psf->datalength + SIZEOF_SSND_CHUNK) ;
+ break ;
+
+ case PEAK_MARKER :
+ psf->headindex = paiff->chunk4.l [k].offset ;
+ psf_binheader_writef (psf, "Em4", PEAK_MARKER, AIFF_PEAK_CHUNK_SIZE (psf->sf.channels)) ;
+ psf_binheader_writef (psf, "E44", 1, time (NULL)) ;
+ for (ch = 0 ; ch < psf->sf.channels ; ch++)
+ psf_binheader_writef (psf, "Eft8", (float) psf->peak_info->peaks [ch].value, psf->peak_info->peaks [ch].position) ;
+ break ;
+
+ default :
+ /* There are a whole bunch of chunks we should just ignore. */
+ break ;
+ } ;
+ } ;
+
+ /* Header mangling complete so write it out. */
+ psf_fseek (psf, 0, SEEK_SET) ;
+ psf_fwrite (psf->header, psf->headindex, 1, psf) ;
+
+ return 0 ;
+} /* aiff_rewrite_header */
+
static int
aiff_write_header (SF_PRIVATE *psf, int calc_length)
{ sf_count_t current ;
AIFF_PRIVATE *paiff ;
unsigned char comm_sample_rate [10], comm_zero_bytes [2] = { 0, 0 } ;
- unsigned int comm_type, comm_size, comm_encoding, comm_frames ;
- int k, endian ;
+ unsigned int comm_type, comm_size, comm_encoding, comm_frames = 0 ;
+ int k, endian, has_data = SF_FALSE ;
short bit_width ;
if ((paiff = psf->container_data) == NULL)
@@ -975,6 +1105,9 @@
current = psf_ftell (psf) ;
+ if (current > psf->dataoffset)
+ has_data = SF_TRUE ;
+
if (calc_length)
{ psf->filelength = psf_get_filelen (psf) ;
@@ -986,43 +1119,14 @@
psf->sf.frames = psf->datalength / (psf->bytewidth * psf->sf.channels) ;
} ;
- if (psf->mode == SFM_RDWR && psf->dataoffset > 0)
- { /* Assuming here that the header has already been written and just
- ** needs to be corrected for new data length. That means that we
- ** only change the length fields of the FORM and SSND chunks ;
- ** everything else can be skipped over.
- */
-
- /* First write new FORM chunk. */
- psf->headindex = 0 ;
- psf_fseek (psf, 0, SEEK_SET) ;
-
- psf_binheader_writef (psf, "Etm8", FORM_MARKER, psf->filelength - 8) ;
- psf_fwrite (psf->header, psf->headindex, 1, psf) ;
-
- /* Now write frame count field of COMM chunk header. */
- psf->headindex = 0 ;
- psf_fseek (psf, paiff->comm_offset + 10, SEEK_SET) ;
-
- psf_binheader_writef (psf, "Et8", psf->sf.frames) ;
- psf_fwrite (psf->header, psf->headindex, 1, psf) ;
-
- /* Now write new SSND chunk header. */
- psf->headindex = 0 ;
- psf_fseek (psf, paiff->ssnd_offset, SEEK_SET) ;
-
- psf_binheader_writef (psf, "Etm8", SSND_MARKER, psf->datalength + SIZEOF_SSND_CHUNK) ;
- psf_fwrite (psf->header, psf->headindex, 1, psf) ;
-
- if (current < psf->dataoffset)
- psf_fseek (psf, psf->dataoffset, SEEK_SET) ;
- else if (current > 0)
+ if (psf->mode == SFM_RDWR && psf->dataoffset > 0 && paiff->chunk4.count > 0)
+ { int err = aiff_rewrite_header (psf, paiff) ;
+ if (current > 0)
psf_fseek (psf, current, SEEK_SET) ;
-
- return 0 ;
+ return err ;
} ;
- endian = psf->sf.format & SF_FORMAT_ENDMASK ;
+ endian = SF_ENDIAN (psf->sf.format) ;
if (CPU_IS_LITTLE_ENDIAN && endian == SF_ENDIAN_CPU)
endian = SF_ENDIAN_LITTLE ;
@@ -1030,7 +1134,7 @@
bit_width = psf->bytewidth * 8 ;
comm_frames = (psf->sf.frames > 0xFFFFFFFF) ? 0xFFFFFFFF : psf->sf.frames ;
- switch (psf->sf.format & SF_FORMAT_SUBMASK)
+ switch (SF_CODEC (psf->sf.format))
{ case SF_FORMAT_PCM_S8 :
case SF_FORMAT_PCM_16 :
case SF_FORMAT_PCM_24 :
@@ -1158,16 +1262,16 @@
/* Write AIFF/AIFC marker and COM chunk. */
if (comm_type == AIFC_MARKER)
/* AIFC must have an FVER chunk. */
- psf_binheader_writef (psf, "Emm44m4", comm_type, FVER_MARKER, 4, 0xA2805140, COMM_MARKER, comm_size) ;
+ psf_binheader_writef (psf, "Emm44", comm_type, FVER_MARKER, 4, 0xA2805140) ;
else
- psf_binheader_writef (psf, "Emm4", comm_type, COMM_MARKER, comm_size) ;
+ psf_binheader_writef (psf, "Em", comm_type) ;
paiff->comm_offset = psf->headindex - 8 ;
memset (comm_sample_rate, 0, sizeof (comm_sample_rate)) ;
uint2tenbytefloat (psf->sf.samplerate, comm_sample_rate) ;
- psf_binheader_writef (psf, "Et242", psf->sf.channels, comm_frames, bit_width) ;
+ psf_binheader_writef (psf, "Em42t42", COMM_MARKER, comm_size, psf->sf.channels, comm_frames, bit_width) ;
psf_binheader_writef (psf, "b", comm_sample_rate, sizeof (comm_sample_rate)) ;
/* AIFC chunks have some extra data. */
@@ -1253,9 +1357,12 @@
if (psf->error)
return psf->error ;
+ if (has_data && psf->dataoffset != psf->headindex)
+ return psf->error = SFE_INTERNAL ;
+
psf->dataoffset = psf->headindex ;
- if (current < psf->dataoffset)
+ if (! has_data)
psf_fseek (psf, psf->dataoffset, SEEK_SET) ;
else if (current > 0)
psf_fseek (psf, current, SEEK_SET) ;
@@ -1298,7 +1405,7 @@
static void
aiff_write_strings (SF_PRIVATE *psf, int location)
-{ int k ;
+{ int k, slen ;
for (k = 0 ; k < SF_MAX_STRINGS ; k++)
{ if (psf->strings [k].type == 0)
@@ -1309,7 +1416,8 @@
switch (psf->strings [k].type)
{ case SF_STR_SOFTWARE :
- psf_binheader_writef (psf, "EmS", APPL_MARKER, psf->strings [k].str) ;
+ slen = strlen (psf->strings [k].str) ;
+ psf_binheader_writef (psf, "Em4mb", APPL_MARKER, slen + 4, m3ga_MARKER, psf->strings [k].str, make_size_t (slen + (slen & 1))) ;
break ;
case SF_STR_TITLE :
@@ -1340,17 +1448,8 @@
} /* aiff_write_strings */
static int
-aiff_command (SF_PRIVATE *psf, int command, void *data, int datasize)
+aiff_command (SF_PRIVATE * UNUSED (psf), int UNUSED (command), void * UNUSED (data), int UNUSED (datasize))
{
- /* Avoid compiler warnings. */
- psf = psf ;
- data = data ;
- datasize = datasize ;
-
- switch (command)
- { default : break ;
- } ;
-
return 0 ;
} /* aiff_command */
@@ -1448,10 +1547,11 @@
aiff_read_basc_chunk (SF_PRIVATE * psf, int datasize)
{ const char * type_str ;
basc_CHUNK bc ;
+ int count ;
- psf_binheader_readf (psf, "E442", &bc.version, &bc.numBeats, &bc.rootNote) ;
- psf_binheader_readf (psf, "E222", &bc.scaleType, &bc.sigNumerator, &bc.sigDenominator) ;
- psf_binheader_readf (psf, "E2j", &bc.loopType, datasize - sizeof (bc)) ;
+ count = psf_binheader_readf (psf, "E442", &bc.version, &bc.numBeats, &bc.rootNote) ;
+ count += psf_binheader_readf (psf, "E222", &bc.scaleType, &bc.sigNumerator, &bc.sigDenominator) ;
+ count += psf_binheader_readf (psf, "E2j", &bc.loopType, datasize - sizeof (bc)) ;
psf_log_printf (psf, " Version ? : %u\n Num Beats : %u\n Root Note : 0x%x\n",
bc.version, bc.numBeats, bc.rootNote) ;
@@ -1504,13 +1604,9 @@
* ((bc.numBeats * 4.0) / bc.sigDenominator) * 60.0 ;
psf->loop_info->root_key = bc.rootNote ;
+ if (count < datasize)
+ psf_binheader_readf (psf, "j", datasize - count) ;
+
return 0 ;
} /* aiff_read_basc_chunk */
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: 7dec56ca-d6f2-48cf-863b-a72e7e17a5d9
-*/
Modified: freeswitch/trunk/libs/libsndfile/src/alaw.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/src/alaw.c (original)
+++ freeswitch/trunk/libs/libsndfile/src/alaw.c Thu May 21 16:09:30 2009
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 1999-2005 Erik de Castro Lopo <erikd at mega-nerd.com>
+** Copyright (C) 1999-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU Lesser General Public License as published by
@@ -16,8 +16,11 @@
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
+#include "sfconfig.h"
+
+#include <math.h>
+
#include "sndfile.h"
-#include "float_cast.h"
#include "common.h"
static sf_count_t alaw_read_alaw2s (SF_PRIVATE *psf, short *ptr, sf_count_t len) ;
@@ -535,10 +538,3 @@
return total ;
} /* alaw_write_d2alaw */
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: 289ccfc2-42a6-4f1f-a29f-4dcc9bfa8752
-*/
Modified: freeswitch/trunk/libs/libsndfile/src/au.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/src/au.c (original)
+++ freeswitch/trunk/libs/libsndfile/src/au.c Thu May 21 16:09:30 2009
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 1999-2004 Erik de Castro Lopo <erikd at mega-nerd.com>
+** Copyright (C) 1999-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU Lesser General Public License as published by
@@ -111,13 +111,13 @@
return error ;
} ;
- if ((psf->sf.format & SF_FORMAT_TYPEMASK) != SF_FORMAT_AU)
+ if ((SF_CONTAINER (psf->sf.format)) != SF_FORMAT_AU)
return SFE_BAD_OPEN_FORMAT ;
- subformat = psf->sf.format & SF_FORMAT_SUBMASK ;
+ subformat = SF_CODEC (psf->sf.format) ;
if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR)
- { psf->endian = psf->sf.format & SF_FORMAT_ENDMASK ;
+ { psf->endian = SF_ENDIAN (psf->sf.format) ;
if (CPU_IS_LITTLE_ENDIAN && psf->endian == SF_ENDIAN_CPU)
psf->endian = SF_ENDIAN_LITTLE ;
else if (psf->endian != SF_ENDIAN_LITTLE)
@@ -215,7 +215,7 @@
psf->sf.frames = psf->datalength / (psf->bytewidth * psf->sf.channels) ;
} ;
- encoding = au_format_to_encoding (psf->sf.format & SF_FORMAT_SUBMASK) ;
+ encoding = au_format_to_encoding (SF_CODEC (psf->sf.format)) ;
if (! encoding)
return (psf->error = SFE_BAD_OPEN_FORMAT) ;
@@ -352,7 +352,7 @@
psf_log_printf (psf, " Encoding : %d => ", au_fmt.encoding) ;
- psf->sf.format = psf->sf.format & SF_FORMAT_ENDMASK ;
+ psf->sf.format = SF_ENDIAN (psf->sf.format) ;
switch (au_fmt.encoding)
{ case AU_ENCODING_ULAW_8 :
@@ -435,7 +435,12 @@
} ;
psf_log_printf (psf, " Sample Rate : %d\n", au_fmt.samplerate) ;
- psf_log_printf (psf, " Channels : %d\n", au_fmt.channels) ;
+ if (au_fmt.channels < 1)
+ { psf_log_printf (psf, " Channels : %d **** should be >= 1\n", au_fmt.channels) ;
+ return SFE_CHANNEL_COUNT_ZERO ;
+ }
+ else
+ psf_log_printf (psf, " Channels : %d\n", au_fmt.channels) ;
psf->blockwidth = psf->sf.channels * psf->bytewidth ;
@@ -444,10 +449,4 @@
return 0 ;
} /* au_read_header */
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: 31f691b1-cde9-4ed2-9469-6bca60fb9cd0
-*/
+
Added: freeswitch/trunk/libs/libsndfile/src/audio_detect.c
==============================================================================
--- (empty file)
+++ freeswitch/trunk/libs/libsndfile/src/audio_detect.c Thu May 21 16:09:30 2009
@@ -0,0 +1,105 @@
+/*
+** Copyright (C) 1999-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
+**
+** This program is free software; you can redistribute it and/or modify
+** it under the terms of the GNU Lesser General Public License as published by
+** the Free Software Foundation; either version 2.1 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU Lesser General Public License for more details.
+**
+** You should have received a copy of the GNU Lesser General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+
+#include "sfconfig.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#if HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+#include <string.h>
+#include <errno.h>
+
+#include "common.h"
+
+typedef struct
+{ int le_float ;
+ int be_float ;
+ int le_int_24_32 ;
+ int be_int_24_32 ;
+} VOTE ;
+
+
+static void vote_for_format (VOTE * vote, const unsigned char * data, int datalen) ;
+
+int
+audio_detect (SF_PRIVATE * psf, AUDIO_DETECT *ad, const unsigned char * data, int datalen)
+{ VOTE vote ;
+
+ if (psf == NULL)
+ return 0 ;
+
+ if (ad == NULL || datalen < 256)
+ return 0 ;
+
+ vote_for_format (&vote, data, datalen) ;
+
+ psf_log_printf (psf, "audio_detect :\n"
+ " le_float : %d\n"
+ " be_float : %d\n"
+ " le_int_24_32 : %d\n"
+ " be_int_24_32 : %d\n",
+ vote.le_float, vote.be_float, vote.le_int_24_32, vote.be_int_24_32) ;
+
+ if (0) puts (psf->logbuffer) ;
+
+ if (ad->endianness == SF_ENDIAN_LITTLE && vote.le_float > (3 * datalen) / 4)
+ { /* Almost certainly 32 bit floats. */
+ return SF_FORMAT_FLOAT ;
+ } ;
+
+ if (ad->endianness == SF_ENDIAN_LITTLE && vote.le_int_24_32 > (3 * datalen) / 4)
+ { /* Almost certainly 24 bit data stored in 32 bit ints. */
+ return SF_FORMAT_PCM_32 ;
+ } ;
+
+ return 0 ;
+} /* data_detect */
+
+static void
+vote_for_format (VOTE * vote, const unsigned char * data, int datalen)
+{
+ int k ;
+
+ memset (vote, 0, sizeof (VOTE)) ;
+
+ datalen -= datalen % 4 ;
+
+ for (k = 0 ; k < datalen ; k ++)
+ { if ((k % 4) == 0)
+ { if (data [k] == 0 && data [k + 1] != 0)
+ vote->le_int_24_32 += 4 ;
+
+ if (data [2] != 0 && data [3] == 0)
+ vote->le_int_24_32 += 4 ;
+
+ if (data [0] != 0 && data [3] > 0x43 && data [3] < 0x4B)
+ vote->le_float += 4 ;
+
+ if (data [3] != 0 && data [0] > 0x43 && data [0] < 0x4B)
+ vote->be_float += 4 ;
+ } ;
+ } ;
+
+ return ;
+} /* vote_for_format */
+
Modified: freeswitch/trunk/libs/libsndfile/src/avr.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/src/avr.c (original)
+++ freeswitch/trunk/libs/libsndfile/src/avr.c Thu May 21 16:09:30 2009
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 2004-2006 Erik de Castro Lopo <erikd at mega-nerd.com>
+** Copyright (C) 2004-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU Lesser General Public License as published by
@@ -85,11 +85,11 @@
return error ;
} ;
- if ((psf->sf.format & SF_FORMAT_TYPEMASK) != SF_FORMAT_AVR)
+ if ((SF_CONTAINER (psf->sf.format)) != SF_FORMAT_AVR)
return SFE_BAD_OPEN_FORMAT ;
if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR)
- { psf->endian = psf->sf.format & SF_FORMAT_ENDMASK ;
+ { psf->endian = SF_ENDIAN (psf->sf.format) ;
psf->endian = SF_ENDIAN_BIG ;
if (avr_write_header (psf, SF_FALSE))
@@ -215,7 +215,7 @@
psf_binheader_writef (psf, "Emz22", TWOBIT_MARKER, make_size_t (8),
psf->sf.channels == 2 ? 0xFFFF : 0, psf->bytewidth * 8) ;
- sign = ((psf->sf.format & SF_FORMAT_SUBMASK) == SF_FORMAT_PCM_U8) ? 0 : 0xFFFF ;
+ sign = ((SF_CODEC (psf->sf.format)) == SF_FORMAT_PCM_U8) ? 0 : 0xFFFF ;
psf_binheader_writef (psf, "E222", sign, 0, 0xFFFF) ;
psf_binheader_writef (psf, "E4444", psf->sf.samplerate, psf->sf.frames, 0, 0) ;
@@ -245,10 +245,3 @@
return 0 ;
} /* avr_close */
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: 0823d454-f39a-4a28-a776-607f1ef33b52
-*/
Modified: freeswitch/trunk/libs/libsndfile/src/binheader_writef_check.py
==============================================================================
--- freeswitch/trunk/libs/libsndfile/src/binheader_writef_check.py (original)
+++ freeswitch/trunk/libs/libsndfile/src/binheader_writef_check.py Thu May 21 16:09:30 2009
@@ -1,4 +1,4 @@
-#!/usr/bin/python2.4
+#!/usr/bin/python2.5
# Copyright (C) 2006 Erik de Castro Lopo <erikd at mega-nerd.com>
#
@@ -30,6 +30,13 @@
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+# This parses C code using regexes (yes, thats horrible) and makes sure
+# that calling conventions to the function psf_binheader_writef are
+# correct.
+
+
+
import re, string, sys
_whitespace_re = re.compile ("\s+", re.MULTILINE)
@@ -107,8 +114,3 @@
print "ok"
-# Do not edit or modify anything in this comment block.
-# The following line is a file identity tag for the GNU Arch
-# revision control system.
-#
-# arch-tag: 4ed34789-925a-4135-af90-2e51523ca1ce
Modified: freeswitch/trunk/libs/libsndfile/src/broadcast.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/src/broadcast.c (original)
+++ freeswitch/trunk/libs/libsndfile/src/broadcast.c Thu May 21 16:09:30 2009
@@ -1,6 +1,6 @@
/*
** Copyright (C) 2006 Paul Davis <paul at linuxaudiosystems.com>
-** Copyright (C) 2006 Erik de Castro Lopo <erikd at mega-nerd.com>
+** Copyright (C) 2006-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU Lesser General Public License as published by
@@ -18,40 +18,169 @@
*/
#include <stdio.h>
+#include <stddef.h>
#include <string.h>
#include "common.h"
-/*
-** Allocate and initialize a broadcast info structure.
-*/
+static void strncpy_crlf (char *dest, const char *src, size_t destmax, size_t srcmax) ;
+static int gen_coding_history (char * added_history, int added_history_max, const SF_INFO * psfinfo) ;
+
+static inline size_t
+bc_min_size (const SF_BROADCAST_INFO* info)
+{ if (info == NULL)
+ return 0 ;
+
+ return offsetof (SF_BROADCAST_INFO, coding_history) + info->coding_history_size ;
+} /* broadcast_size */
+
+
+static inline size_t
+bc_var_coding_hist_size (const SF_BROADCAST_VAR* var)
+{ return var->size - offsetof (SF_BROADCAST_VAR, binfo.coding_history) ;
+} /* broadcast_size */
+
+SF_BROADCAST_VAR*
+broadcast_var_alloc (size_t datasize)
+{ SF_BROADCAST_VAR * data ;
-SF_BROADCAST_INFO*
-broadcast_info_alloc (void)
-{ SF_BROADCAST_INFO* bext ;
+ if ((data = calloc (1, datasize)) != NULL)
+ data->size = datasize ;
- if ((bext = calloc (1, sizeof (SF_BROADCAST_INFO))) == NULL)
- return NULL ;
+ return data ;
+} /* broadcast_var_alloc */
- return bext ;
-} /* broadcast_info_alloc */
int
-broadcast_info_copy (SF_BROADCAST_INFO* dst, SF_BROADCAST_INFO* src)
-{ memcpy (dst, src, sizeof (SF_BROADCAST_INFO)) ;
+broadcast_var_set (SF_PRIVATE *psf, const SF_BROADCAST_INFO * info, size_t datasize)
+{ char added_history [256] ;
+ int added_history_len, len ;
+
+ if (info == NULL)
+ return SF_FALSE ;
+
+ if (bc_min_size (info) > datasize)
+ { psf->error = SFE_BAD_BROADCAST_INFO_SIZE ;
+ return SF_FALSE ;
+ } ;
+
+ added_history_len = gen_coding_history (added_history, sizeof (added_history), &(psf->sf)) ;
+
+ if (psf->broadcast_var != NULL)
+ { size_t coding_hist_offset = offsetof (SF_BROADCAST_INFO, coding_history) ;
+
+ if (psf->broadcast_var->binfo.coding_history_size + added_history_len < datasize - coding_hist_offset)
+ { free (psf->broadcast_var) ;
+ psf->broadcast_var = NULL ;
+ } ;
+ } ;
+
+ if (psf->broadcast_var == NULL)
+ { int size = datasize + added_history_len + 512 ;
+
+ psf->broadcast_var = calloc (1, size) ;
+ psf->broadcast_var->size = size ;
+ } ;
+
+ memcpy (&(psf->broadcast_var->binfo), info, offsetof (SF_BROADCAST_INFO, coding_history)) ;
+
+ strncpy_crlf (psf->broadcast_var->binfo.coding_history, info->coding_history, bc_var_coding_hist_size (psf->broadcast_var), info->coding_history_size) ;
+ len = strlen (psf->broadcast_var->binfo.coding_history) ;
+
+ if (len > 0 && psf->broadcast_var->binfo.coding_history [len] != '\n')
+ strncat (psf->broadcast_var->binfo.coding_history, "\r\n", 2) ;
+
+ if (psf->mode == SFM_WRITE)
+ strncat (psf->broadcast_var->binfo.coding_history, added_history, strlen (added_history)) ;
+
+ psf->broadcast_var->binfo.coding_history_size = strlen (psf->broadcast_var->binfo.coding_history) ;
+
+ /* Fore coding_history_size to be even. */
+ psf->broadcast_var->binfo.coding_history_size += (psf->broadcast_var->binfo.coding_history_size & 1) ? 1 : 0 ;
/* Currently writing this version. */
- dst->version = 1 ;
+ psf->broadcast_var->binfo.version = 1 ;
return SF_TRUE ;
-} /* broadcast_info_copy */
+} /* broadcast_var_set */
+
int
-broadcast_add_coding_history (SF_BROADCAST_INFO* bext, unsigned int channels, unsigned int samplerate)
+broadcast_var_get (SF_PRIVATE *psf, SF_BROADCAST_INFO * data, size_t datasize)
+{ size_t size ;
+
+ if (psf->broadcast_var == NULL)
+ return SF_FALSE ;
+
+ size = SF_MIN (datasize, bc_min_size (&(psf->broadcast_var->binfo))) ;
+
+ memcpy (data, &(psf->broadcast_var->binfo), size) ;
+
+ return SF_TRUE ;
+} /* broadcast_var_set */
+
+/*------------------------------------------------------------------------------
+** Strncpy which converts all line endings to CR/LF.
+*/
+
+static void
+strncpy_crlf (char *dest, const char *src, size_t destmax, size_t srcmax)
+{ char * destend = dest + destmax - 1 ;
+ const char * srcend = src + srcmax ;
+
+ while (dest < destend && src < srcend)
+ { if ((src [0] == '\r' && src [1] == '\n') || (src [0] == '\n' && src [1] == '\r'))
+ { *dest++ = '\r' ;
+ *dest++ = '\n' ;
+ src += 2 ;
+ continue ;
+ } ;
+
+ if (src [0] == '\r')
+ { *dest++ = '\r' ;
+ *dest++ = '\n' ;
+ src += 1 ;
+ continue ;
+ } ;
+
+ if (src [0] == '\n')
+ { *dest++ = '\r' ;
+ *dest++ = '\n' ;
+ src += 1 ;
+ continue ;
+ } ;
+
+ *dest++ = *src++ ;
+ } ;
+
+ /* Make sure dest is terminated. */
+ *dest = 0 ;
+} /* strncpy_crlf */
+
+static int
+gen_coding_history (char * added_history, int added_history_max, const SF_INFO * psfinfo)
{ char chnstr [16] ;
- int count ;
+ int count, width ;
+
+ /*
+ ** From : http://www.sr.se/utveckling/tu/bwf/docs/codhist2.htm
+ **
+ ** Parameter Variable string <allowed option> Unit
+ ** ==========================================================================================
+ ** Coding Algorithm A=<ANALOGUE, PCM, MPEG1L1, MPEG1L2, MPEG1L3,
+ ** MPEG2L1, MPEG2L2, MPEG2L3>
+ ** Sampling frequency F=<11000,22050,24000,32000,44100,48000> [Hz]
+ ** Bit-rate B=<any bit-rate allowed in MPEG 2 (ISO/IEC [kbit/s per channel]
+ ** 13818-3)>
+ ** Word Length W=<8, 12, 14, 16, 18, 20, 22, 24> [bits]
+ ** Mode M=<mono, stereo, dual-mono, joint-stereo>
+ ** Text, free string T=<a free ASCII-text string for in house use.
+ ** This string should contain no commas (ASCII
+ ** 2Chex). Examples of the contents: ID-No; codec
+ ** type; A/D type>
+ */
- switch (channels)
+ switch (psfinfo->channels)
{ case 0 :
return SF_FALSE ;
@@ -63,27 +192,47 @@
strncpy (chnstr, "stereo", sizeof (chnstr)) ;
break ;
- default :
- LSF_SNPRINTF (chnstr, sizeof (chnstr), "%uchn", channels) ;
- break ;
- }
-
- count = LSF_SNPRINTF (bext->coding_history, sizeof (bext->coding_history), "F=%u,A=PCM,M=%s,W=24,T=%s-%s", samplerate, chnstr, PACKAGE, VERSION) ;
-
- if (count >= SIGNED_SIZEOF (bext->coding_history))
- bext->coding_history_size = sizeof (bext->coding_history) ;
- else
- { count += count & 1 ;
- bext->coding_history_size = count ;
+ default :
+ snprintf (chnstr, sizeof (chnstr), "%uchn", psfinfo->channels) ;
+ break ;
} ;
- return SF_TRUE ;
-} /* broadcast_add_coding_history */
+ switch (SF_CODEC (psfinfo->format))
+ { case SF_FORMAT_PCM_U8 :
+ case SF_FORMAT_PCM_S8 :
+ width = 8 ;
+ break ;
+ case SF_FORMAT_PCM_16 :
+ width = 16 ;
+ break ;
+ case SF_FORMAT_PCM_24 :
+ width = 24 ;
+ break ;
+ case SF_FORMAT_PCM_32 :
+ width = 32 ;
+ break ;
+ case SF_FORMAT_FLOAT :
+ width = 24 ; /* Bits in the mantissa + 1 */
+ break ;
+ case SF_FORMAT_DOUBLE :
+ width = 53 ; /* Bits in the mantissa + 1 */
+ break ;
+ case SF_FORMAT_ULAW :
+ case SF_FORMAT_ALAW :
+ width = 12 ;
+ break ;
+ default :
+ width = 42 ;
+ break ;
+ } ;
+
+ count = snprintf (added_history, added_history_max,
+ "A=PCM,F=%u,W=%hu,M=%s,T=%s-%s\r\n",
+ psfinfo->samplerate, width, chnstr, PACKAGE, VERSION) ;
+
+ if (count >= added_history_max)
+ return 0 ;
+
+ return count ;
+} /* gen_coding_history */
-/*
-** Do not edit or modify anything in this comment block.
-** The following line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: 4b3b69c7-d710-4424-9da0-5048534a0beb
-*/
Modified: freeswitch/trunk/libs/libsndfile/src/caf.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/src/caf.c (original)
+++ freeswitch/trunk/libs/libsndfile/src/caf.c Thu May 21 16:09:30 2009
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 2005, 2006 Erik de Castro Lopo <erikd at mega-nerd.com>
+** Copyright (C) 2005-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU Lesser General Public License as published by
@@ -22,10 +22,10 @@
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
+#include <math.h>
#include "sndfile.h"
#include "sfendian.h"
-#include "float_cast.h"
#include "common.h"
/*------------------------------------------------------------------------------
@@ -103,13 +103,13 @@
return error ;
} ;
- subformat = psf->sf.format & SF_FORMAT_SUBMASK ;
+ subformat = SF_CODEC (psf->sf.format) ;
if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR)
{ if (psf->is_pipe)
return SFE_NO_PIPE_WRITE ;
- format = psf->sf.format & SF_FORMAT_TYPEMASK ;
+ format = SF_CONTAINER (psf->sf.format) ;
if (format != SF_FORMAT_CAF)
return SFE_BAD_OPEN_FORMAT ;
@@ -264,7 +264,7 @@
psf_binheader_readf (psf, "mE8b", &marker, &chunk_size, psf->u.ucbuf, 8) ;
srate = double64_be_read (psf->u.ucbuf) ;
- LSF_SNPRINTF (psf->u.cbuf, sizeof (psf->u.cbuf), "%5.3f", srate) ;
+ snprintf (psf->u.cbuf, sizeof (psf->u.cbuf), "%5.3f", srate) ;
psf_log_printf (psf, "%M : %D\n Sample rate : %s\n", marker, chunk_size, psf->u.cbuf) ;
if (marker != desc_MARKER)
return SFE_CAF_NO_DESC ;
@@ -282,6 +282,11 @@
" Frames / packet : %u\n Channels / frame : %u\n Bits / channel : %u\n",
desc.fmt_id, desc.fmt_flags, desc.pkt_bytes, desc.pkt_frames, desc.channels_per_frame, desc.bits_per_chan) ;
+ if (desc.channels_per_frame > 200)
+ { psf_log_printf (psf, "**** Bad channels per frame value %u.\n", desc.channels_per_frame) ;
+ return SFE_MALFORMED_FILE ;
+ } ;
+
if (chunk_size > SIGNED_SIZEOF (DESC_CHUNK))
psf_binheader_readf (psf, "j", (int) (chunk_size - sizeof (DESC_CHUNK))) ;
@@ -315,7 +320,7 @@
psf->peak_info->peaks [k].value = value ;
psf->peak_info->peaks [k].position = position ;
- LSF_SNPRINTF (psf->u.cbuf, sizeof (psf->u.cbuf), " %2d %-12ld %g\n", k, (long) position, value) ;
+ snprintf (psf->u.cbuf, sizeof (psf->u.cbuf), " %2d %-12ld %g\n", k, (long) position, value) ;
psf_log_printf (psf, psf->u.cbuf) ;
} ;
@@ -400,9 +405,9 @@
double64_be_write (1.0 * psf->sf.samplerate, psf->u.ucbuf) ;
psf_binheader_writef (psf, "b", psf->u.ucbuf, make_size_t (8)) ;
- subformat = psf->sf.format & SF_FORMAT_SUBMASK ;
+ subformat = SF_CODEC (psf->sf.format) ;
- psf->endian = psf->sf.format & SF_FORMAT_ENDMASK ;
+ psf->endian = SF_ENDIAN (psf->sf.format) ;
if (CPU_IS_BIG_ENDIAN && (psf->endian == 0 || psf->endian == SF_ENDIAN_CPU))
psf->endian = SF_ENDIAN_BIG ;
@@ -529,10 +534,3 @@
return psf->error ;
} /* caf_write_header */
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: 65883e65-bd3c-4618-9241-d3c02fd630bd
-*/
Added: freeswitch/trunk/libs/libsndfile/src/chunk.c
==============================================================================
--- (empty file)
+++ freeswitch/trunk/libs/libsndfile/src/chunk.c Thu May 21 16:09:30 2009
@@ -0,0 +1,54 @@
+/*
+** Copyright (C) 2008-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
+**
+** This program is free software; you can redistribute it and/or modify
+** it under the terms of the GNU Lesser General Public License as published by
+** the Free Software Foundation; either version 2.1 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU Lesser General Public License for more details.
+**
+** You should have received a copy of the GNU Lesser General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#include "sfconfig.h"
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "sndfile.h"
+#include "sfendian.h"
+#include "common.h"
+
+
+void
+pchk4_store (PRIV_CHUNK4 * pchk, int marker, sf_count_t offset, sf_count_t len)
+{
+ if (pchk->count >= ARRAY_LEN (pchk->l))
+ return ;
+
+ pchk->l [pchk->count].chunk = marker ;
+ pchk->l [pchk->count].offset = offset ;
+ pchk->l [pchk->count].len = len ;
+
+ pchk->count ++ ;
+
+ return ;
+} /* pchk4_store */
+
+int
+pchk4_find (PRIV_CHUNK4 * pchk, int marker)
+{ int k ;
+
+ for (k = 0 ; k < pchk->count ; k++)
+ if (pchk->l [k].chunk == marker)
+ return k ;
+
+ return -1 ;
+} /* pchk4_find */
+
Modified: freeswitch/trunk/libs/libsndfile/src/command.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/src/command.c (original)
+++ freeswitch/trunk/libs/libsndfile/src/command.c Thu May 21 16:09:30 2009
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 2001-2004 Erik de Castro Lopo <erikd at mega-nerd.com>
+** Copyright (C) 2001-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU Lesser General Public License as published by
@@ -51,7 +51,7 @@
"CAF (Apple 16 bit PCM)", "caf"
},
-#ifdef HAVE_FLAC_ALL_H
+#if HAVE_EXTERNAL_LIBS
{ SF_FORMAT_FLAC | SF_FORMAT_PCM_16,
"FLAC 16 bit", "flac"
},
@@ -61,6 +61,12 @@
"OKI Dialogic VOX ADPCM", "vox"
},
+#if HAVE_EXTERNAL_LIBS
+ { SF_FORMAT_OGG | SF_FORMAT_VORBIS,
+ "Ogg Vorbis (Xiph Foundation)", "oga"
+ },
+#endif
+
{ SF_FORMAT_WAV | SF_FORMAT_PCM_16,
"WAV (Microsoft 16 bit PCM)", "wav"
},
@@ -93,7 +99,7 @@
{ int indx ;
if (data->format < 0 || data->format >= (SIGNED_SIZEOF (simple_formats) / SIGNED_SIZEOF (SF_FORMAT_INFO)))
- return SFE_BAD_CONTROL_CMD ;
+ return SFE_BAD_COMMAND_PARAM ;
indx = data->format ;
memcpy (data, &(simple_formats [indx]), SIGNED_SIZEOF (SF_FORMAT_INFO)) ;
@@ -111,13 +117,16 @@
{ SF_FORMAT_AU, "AU (Sun/NeXT)", "au" },
{ SF_FORMAT_AVR, "AVR (Audio Visual Research)", "avr" },
{ SF_FORMAT_CAF, "CAF (Apple Core Audio File)", "caf" },
-#ifdef HAVE_FLAC_ALL_H
+#if HAVE_EXTERNAL_LIBS
{ SF_FORMAT_FLAC, "FLAC (FLAC Lossless Audio Codec)", "flac" },
#endif
{ SF_FORMAT_HTK, "HTK (HMM Tool Kit)", "htk" },
{ SF_FORMAT_SVX, "IFF (Amiga IFF/SVX8/SV16)", "iff" },
{ SF_FORMAT_MAT4, "MAT4 (GNU Octave 2.0 / Matlab 4.2)", "mat" },
{ SF_FORMAT_MAT5, "MAT5 (GNU Octave 2.1 / Matlab 5.0)", "mat" },
+#if HAVE_EXTERNAL_LIBS
+ { SF_FORMAT_OGG, "OGG (OGG Container format)", "oga" },
+#endif
{ SF_FORMAT_PAF, "PAF (Ensoniq PARIS)", "paf" },
{ SF_FORMAT_PVF, "PVF (Portable Voice Format)", "pvf" },
{ SF_FORMAT_RAW, "RAW (header-less)", "raw" },
@@ -129,6 +138,7 @@
{ SF_FORMAT_WAV, "WAV (Microsoft)", "wav" },
{ SF_FORMAT_NIST, "WAV (NIST Sphere)", "wav" },
{ SF_FORMAT_WAVEX, "WAVEX (Microsoft)", "wav" },
+ { SF_FORMAT_WVE, "WVE (Psion Series 3)", "wve" },
{ SF_FORMAT_XI, "XI (FastTracker 2)", "xi" },
} ; /* major_formats */
@@ -143,7 +153,7 @@
{ int indx ;
if (data->format < 0 || data->format >= (SIGNED_SIZEOF (major_formats) / SIGNED_SIZEOF (SF_FORMAT_INFO)))
- return SFE_BAD_CONTROL_CMD ;
+ return SFE_BAD_COMMAND_PARAM ;
indx = data->format ;
memcpy (data, &(major_formats [indx]), SIGNED_SIZEOF (SF_FORMAT_INFO)) ;
@@ -183,7 +193,11 @@
{ SF_FORMAT_VOX_ADPCM, "VOX ADPCM", "vox" },
{ SF_FORMAT_DPCM_16, "16 bit DPCM", NULL },
- { SF_FORMAT_DPCM_8, "8 bit DPCM", NULL }
+ { SF_FORMAT_DPCM_8, "8 bit DPCM", NULL },
+
+#if HAVE_EXTERNAL_LIBS
+ { SF_FORMAT_VORBIS, "Vorbis", NULL },
+#endif
} ; /* subtype_formats */
int
@@ -196,7 +210,7 @@
{ int indx ;
if (data->format < 0 || data->format >= (SIGNED_SIZEOF (subtype_formats) / SIGNED_SIZEOF (SF_FORMAT_INFO)))
- return SFE_BAD_CONTROL_CMD ;
+ return SFE_BAD_COMMAND_PARAM ;
indx = data->format ;
memcpy (data, &(subtype_formats [indx]), sizeof (SF_FORMAT_INFO)) ;
@@ -211,8 +225,8 @@
psf_get_format_info (SF_FORMAT_INFO *data)
{ int k, format ;
- if (data->format & SF_FORMAT_TYPEMASK)
- { format = data->format & SF_FORMAT_TYPEMASK ;
+ if (SF_CONTAINER (data->format))
+ { format = SF_CONTAINER (data->format) ;
for (k = 0 ; k < (SIGNED_SIZEOF (major_formats) / SIGNED_SIZEOF (SF_FORMAT_INFO)) ; k++)
{ if (format == major_formats [k].format)
@@ -221,8 +235,8 @@
} ;
} ;
}
- else if (data->format & SF_FORMAT_SUBMASK)
- { format = data->format & SF_FORMAT_SUBMASK ;
+ else if (SF_CODEC (data->format))
+ { format = SF_CODEC (data->format) ;
for (k = 0 ; k < (SIGNED_SIZEOF (subtype_formats) / SIGNED_SIZEOF (SF_FORMAT_INFO)) ; k++)
{ if (format == subtype_formats [k].format)
@@ -234,7 +248,7 @@
memset (data, 0, sizeof (SF_FORMAT_INFO)) ;
- return SFE_BAD_CONTROL_CMD ;
+ return SFE_BAD_COMMAND_PARAM ;
} /* psf_get_format_info */
/*==============================================================================
@@ -355,13 +369,6 @@
peaks [k] = psf->peak_info->peaks [k].value ;
return SF_TRUE ;
-} /* psf_get_max_all_channels */
+} /* psf_get_max_all_channels */
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: 0aae0d9d-ab2b-4d70-ade3-47a534666f8e
-*/
Modified: freeswitch/trunk/libs/libsndfile/src/common.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/src/common.c (original)
+++ freeswitch/trunk/libs/libsndfile/src/common.c Thu May 21 16:09:30 2009
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 1999-2006 Erik de Castro Lopo <erikd at mega-nerd.com>
+** Copyright (C) 1999-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU Lesser General Public License as published by
@@ -16,12 +16,16 @@
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
+#include <config.h>
+
#include <stdarg.h>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <time.h>
-
+#ifndef _MSC_VER
+#include <sys/time.h>
+#endif
#include "sndfile.h"
#include "sfendian.h"
#include "common.h"
@@ -314,7 +318,6 @@
return ;
} /* psf_log_printf */
-#ifndef PSF_LOG_PRINTF_ONLY
/*-----------------------------------------------------------------------------------------------
** ASCII header printf functions.
** Some formats (ie NIST) use ascii text in their headers.
@@ -334,7 +337,7 @@
maxlen = sizeof (psf->header) - maxlen ;
va_start (argptr, format) ;
- LSF_VSNPRINTF (start, maxlen, format, argptr) ;
+ vsnprintf (start, maxlen, format, argptr) ;
va_end (argptr) ;
/* Make sure the string is properly terminated. */
@@ -776,24 +779,17 @@
#define GET_BE_INT(ptr) ( ((ptr) [0] << 24) | ((ptr) [1] << 16) | \
((ptr) [2] << 8) | ((ptr) [3]) )
-#if (SIZEOF_LONG == 4)
-#define GET_LE_8BYTE(ptr) ( ((ptr) [3] << 24) | ((ptr) [2] << 16) | \
- ((ptr) [1] << 8) | ((ptr) [0]) )
+#define GET_LE_8BYTE(ptr) ( (((sf_count_t) (ptr) [7]) << 56) | (((sf_count_t) (ptr) [6]) << 48) | \
+ (((sf_count_t) (ptr) [5]) << 40) | (((sf_count_t) (ptr) [4]) << 32) | \
+ (((sf_count_t) (ptr) [3]) << 24) | (((sf_count_t) (ptr) [2]) << 16) | \
+ (((sf_count_t) (ptr) [1]) << 8 ) | ((ptr) [0]))
+
+#define GET_BE_8BYTE(ptr) ( (((sf_count_t) (ptr) [0]) << 56) | (((sf_count_t) (ptr) [1]) << 48) | \
+ (((sf_count_t) (ptr) [2]) << 40) | (((sf_count_t) (ptr) [3]) << 32) | \
+ (((sf_count_t) (ptr) [4]) << 24) | (((sf_count_t) (ptr) [5]) << 16) | \
+ (((sf_count_t) (ptr) [6]) << 8 ) | ((ptr) [7]))
-#define GET_BE_8BYTE(ptr) ( ((ptr) [4] << 24) | ((ptr) [5] << 16) | \
- ((ptr) [6] << 8) | ((ptr) [7]) )
-#else
-#define GET_LE_8BYTE(ptr) ( (((ptr) [7] * 1L) << 56) | (((ptr) [6] * 1L) << 48) | \
- (((ptr) [5] * 1L) << 40) | (((ptr) [4] * 1L) << 32) | \
- (((ptr) [3] * 1L) << 24) | (((ptr) [2] * 1L) << 16) | \
- (((ptr) [1] * 1L) << 8 ) | ((ptr) [0]))
-
-#define GET_BE_8BYTE(ptr) ( (((ptr) [0] * 1L) << 56) | (((ptr) [1] * 1L) << 48) | \
- (((ptr) [2] * 1L) << 40) | (((ptr) [3] * 1L) << 32) | \
- (((ptr) [4] * 1L) << 24) | (((ptr) [5] * 1L) << 16) | \
- (((ptr) [6] * 1L) << 8 ) | ((ptr) [7]))
-#endif
static int
header_read (SF_PRIVATE *psf, void *ptr, int bytes)
@@ -1093,7 +1089,7 @@
*/
sf_count_t
-psf_default_seek (SF_PRIVATE *psf, int mode, sf_count_t samples_from_start)
+psf_default_seek (SF_PRIVATE *psf, int UNUSED (mode), sf_count_t samples_from_start)
{ sf_count_t position, retval ;
if (! (psf->blockwidth && psf->dataoffset >= 0))
@@ -1113,8 +1109,6 @@
return PSF_SEEK_ERROR ;
} ;
- mode = mode ;
-
return samples_from_start ;
} /* psf_default_seek */
@@ -1122,8 +1116,9 @@
*/
void
-psf_hexdump (void *ptr, int len)
-{ char ascii [17], *data ;
+psf_hexdump (const void *ptr, int len)
+{ const char *data ;
+ char ascii [17] ;
int k, m ;
if ((data = ptr) == NULL)
@@ -1169,6 +1164,25 @@
/*========================================================================================
*/
+void*
+psf_memset (void *s, int c, sf_count_t len)
+{ char *ptr ;
+ int setcount ;
+
+ ptr = (char *) s ;
+
+ while (len > 0)
+ { setcount = (len > 0x10000000) ? 0x10000000 : (int) len ;
+
+ memset (ptr, c, setcount) ;
+
+ ptr += setcount ;
+ len -= setcount ;
+ } ;
+
+ return s ;
+} /* psf_memset */
+
SF_INSTRUMENT *
psf_instrument_alloc (void)
{ SF_INSTRUMENT *instr ;
@@ -1188,26 +1202,19 @@
return instr ;
} /* psf_instrument_alloc */
-void*
-psf_memset (void *s, int c, sf_count_t len)
-{ char *ptr ;
- int setcount ;
-
- ptr = (char *) s ;
-
- while (len > 0)
- { setcount = (len > 0x10000000) ? 0x10000000 : (int) len ;
-
- memset (ptr, c, setcount) ;
-
- ptr += setcount ;
- len -= setcount ;
- } ;
-
- return s ;
-} /* psf_memset */
+void
+psf_sanitize_string (char * cptr, int len)
+{
+ do
+ {
+ len -- ;
+ cptr [len] = isprint (cptr [len]) ? cptr [len] : '.' ;
+ }
+ while (len > 0) ;
+} /* psf_sanitize_string */
-void psf_get_date_str (char *str, int maxlen)
+void
+psf_get_date_str (char *str, int maxlen)
{ time_t current ;
struct tm timedata, *tmptr ;
@@ -1225,11 +1232,11 @@
#endif
if (tmptr)
- LSF_SNPRINTF (str, maxlen, "%4d-%02d-%02d %02d:%02d:%02d UTC",
+ snprintf (str, maxlen, "%4d-%02d-%02d %02d:%02d:%02d UTC",
1900 + timedata.tm_year, timedata.tm_mon, timedata.tm_mday,
timedata.tm_hour, timedata.tm_min, timedata.tm_sec) ;
else
- LSF_SNPRINTF (str, maxlen, "Unknown date") ;
+ snprintf (str, maxlen, "Unknown date") ;
return ;
} /* psf_get_date_str */
@@ -1279,12 +1286,130 @@
return array [((bits + 7) / 8) - 1] ;
} /* bitwidth_to_subformat */
-#endif /* PSF_LOG_PRINTF_ONLY */
-
/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: 33e9795e-f717-461a-9feb-65d083a56395
+** psf_rand_int32 : Not crypto quality, but more than adequate for things
+** like stream serial numbers in Ogg files or the unique_id field of the
+** SF_PRIVATE struct.
+*/
+
+int32_t
+psf_rand_int32 (void)
+{ static int32_t value = -1 ;
+ int k, count ;
+
+ if (value == -1)
+ {
+#if HAVE_GETTIMEOFDAY
+ struct timeval tv ;
+ gettimeofday (&tv, NULL) ;
+ value = tv.tv_sec + tv.tv_usec ;
+#else
+ value = time (NULL) ;
+#endif
+ } ;
+
+ count = 4 + (value & 7) ;
+ for (k = 0 ; k < count ; k++)
+ value = 11117 * value + 211231 ;
+
+ return value ;
+} /* psf_rand_int32 */
+
+/*==============================================================================
*/
+
+#define CASE_NAME(x) case x : return #x ; break ;
+
+const char *
+str_of_major_format (int format)
+{ switch (SF_CONTAINER (format))
+ { CASE_NAME (SF_FORMAT_WAV) ;
+ CASE_NAME (SF_FORMAT_AIFF) ;
+ CASE_NAME (SF_FORMAT_AU) ;
+ CASE_NAME (SF_FORMAT_RAW) ;
+ CASE_NAME (SF_FORMAT_PAF) ;
+ CASE_NAME (SF_FORMAT_SVX) ;
+ CASE_NAME (SF_FORMAT_NIST) ;
+ CASE_NAME (SF_FORMAT_VOC) ;
+ CASE_NAME (SF_FORMAT_IRCAM) ;
+ CASE_NAME (SF_FORMAT_W64) ;
+ CASE_NAME (SF_FORMAT_MAT4) ;
+ CASE_NAME (SF_FORMAT_MAT5) ;
+ CASE_NAME (SF_FORMAT_PVF) ;
+ CASE_NAME (SF_FORMAT_XI) ;
+ CASE_NAME (SF_FORMAT_HTK) ;
+ CASE_NAME (SF_FORMAT_SDS) ;
+ CASE_NAME (SF_FORMAT_AVR) ;
+ CASE_NAME (SF_FORMAT_WAVEX) ;
+ CASE_NAME (SF_FORMAT_SD2) ;
+ CASE_NAME (SF_FORMAT_FLAC) ;
+ CASE_NAME (SF_FORMAT_CAF) ;
+ CASE_NAME (SF_FORMAT_WVE) ;
+ CASE_NAME (SF_FORMAT_OGG) ;
+ default :
+ break ;
+ } ;
+
+ return "BAD_MAJOR_FORMAT" ;
+} /* str_of_major_format */
+
+const char *
+str_of_minor_format (int format)
+{ switch (SF_CODEC (format))
+ { CASE_NAME (SF_FORMAT_PCM_S8) ;
+ CASE_NAME (SF_FORMAT_PCM_16) ;
+ CASE_NAME (SF_FORMAT_PCM_24) ;
+ CASE_NAME (SF_FORMAT_PCM_32) ;
+ CASE_NAME (SF_FORMAT_PCM_U8) ;
+ CASE_NAME (SF_FORMAT_FLOAT) ;
+ CASE_NAME (SF_FORMAT_DOUBLE) ;
+ CASE_NAME (SF_FORMAT_ULAW) ;
+ CASE_NAME (SF_FORMAT_ALAW) ;
+ CASE_NAME (SF_FORMAT_IMA_ADPCM) ;
+ CASE_NAME (SF_FORMAT_MS_ADPCM) ;
+ CASE_NAME (SF_FORMAT_GSM610) ;
+ CASE_NAME (SF_FORMAT_VOX_ADPCM) ;
+ CASE_NAME (SF_FORMAT_G721_32) ;
+ CASE_NAME (SF_FORMAT_G723_24) ;
+ CASE_NAME (SF_FORMAT_G723_40) ;
+ CASE_NAME (SF_FORMAT_DWVW_12) ;
+ CASE_NAME (SF_FORMAT_DWVW_16) ;
+ CASE_NAME (SF_FORMAT_DWVW_24) ;
+ CASE_NAME (SF_FORMAT_DWVW_N) ;
+ CASE_NAME (SF_FORMAT_DPCM_8) ;
+ CASE_NAME (SF_FORMAT_DPCM_16) ;
+ CASE_NAME (SF_FORMAT_VORBIS) ;
+ default :
+ break ;
+ } ;
+
+ return "BAD_MINOR_FORMAT" ;
+} /* str_of_minor_format */
+
+const char *
+str_of_open_mode (int mode)
+{ switch (mode)
+ { CASE_NAME (SFM_READ) ;
+ CASE_NAME (SFM_WRITE) ;
+ CASE_NAME (SFM_RDWR) ;
+
+ default :
+ break ;
+ } ;
+
+ return "BAD_MODE" ;
+} /* str_of_open_mode */
+
+const char *
+str_of_endianness (int end)
+{ switch (end)
+ { CASE_NAME (SF_ENDIAN_BIG) ;
+ CASE_NAME (SF_ENDIAN_LITTLE) ;
+ CASE_NAME (SF_ENDIAN_CPU) ;
+ default :
+ break ;
+ } ;
+
+ /* Zero length string for SF_ENDIAN_FILE. */
+ return "" ;
+} /* str_of_endianness */
Modified: freeswitch/trunk/libs/libsndfile/src/common.h
==============================================================================
--- freeswitch/trunk/libs/libsndfile/src/common.h (original)
+++ freeswitch/trunk/libs/libsndfile/src/common.h Thu May 21 16:09:30 2009
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 1999-2006 Erik de Castro Lopo <erikd at mega-nerd.com>
+** Copyright (C) 1999-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU Lesser General Public License as published by
@@ -37,6 +37,21 @@
#error "This code is not designed to be compiled with a C++ compiler."
#endif
+#if (SIZEOF_LONG == 8)
+# define SF_PLATFORM_S64(x) x##l
+#elif COMPILER_IS_GCC
+# define SF_PLATFORM_S64(x) x##ll
+#elif OS_IS_WIN32
+# define SF_PLATFORM_S64(x) x##I64
+#else
+# error "Don't know how to define a 64 bit integer constant."
+#endif
+
+
+
+/*
+** Inspiration : http://sourcefrog.net/weblog/software/languages/C/unused.html
+*/
#ifdef UNUSED
#elif defined (__GNUC__)
# define UNUSED(x) UNUSED_ ## x __attribute__ ((unused))
@@ -55,7 +70,7 @@
#define SF_BUFFER_LEN (8192*2)
#define SF_FILENAME_LEN (512)
#define SF_SYSERR_LEN (256)
-#define SF_MAX_STRINGS (16)
+#define SF_MAX_STRINGS (32)
#define SF_STR_BUFFER_LEN (8192)
#define SF_HEADER_LEN (4100 + SF_STR_BUFFER_LEN)
@@ -72,8 +87,31 @@
#define ARRAY_LEN(x) ((int) (sizeof (x) / sizeof ((x) [0])))
+#if (COMPILER_IS_GCC == 1)
+#define SF_MAX(x,y) ({ \
+ typeof (x) sf_max_x1 = (x) ; \
+ typeof (y) sf_max_y1 = (y) ; \
+ (void) (&sf_max_x1 == &sf_max_y1) ; \
+ sf_max_x1 > sf_max_y1 ? sf_max_x1 : sf_max_y1 ; })
+
+#define SF_MIN(x,y) ({ \
+ typeof (x) sf_min_x2 = (x) ; \
+ typeof (y) sf_min_y2 = (y) ; \
+ (void) (&sf_min_x2 == &sf_min_y2) ; \
+ sf_min_x2 < sf_min_y2 ? sf_min_x2 : sf_min_y2 ; })
+#else
#define SF_MAX(a,b) ((a) > (b) ? (a) : (b))
#define SF_MIN(a,b) ((a) < (b) ? (a) : (b))
+#endif
+
+/*
+* Macros for spliting the format file of SF_INFI into contrainer type,
+** codec type and endian-ness.
+*/
+#define SF_CONTAINER(x) ((x) & SF_FORMAT_TYPEMASK)
+#define SF_CODEC(x) ((x) & SF_FORMAT_SUBMASK)
+#define SF_ENDIAN(x) ((x) & SF_FORMAT_ENDMASK)
+
enum
{ /* PEAK chunk location. */
@@ -107,13 +145,10 @@
{ /* Work in progress. */
/* Formats supported read only. */
- SF_FORMAT_WVE = 0x4020000, /* Psion ALaw Sound File */
SF_FORMAT_TXW = 0x4030000, /* Yamaha TX16 sampler file */
SF_FORMAT_DWD = 0x4040000, /* DiamondWare Digirized */
/* Following are detected but not supported. */
- SF_FORMAT_OGG = 0x4090000,
-
SF_FORMAT_REX = 0x40A0000, /* Propellorheads Rex/Rcy */
SF_FORMAT_REX2 = 0x40D0000, /* Propellorheads Rex2 */
SF_FORMAT_KRZ = 0x40E0000, /* Kurzweil sampler file */
@@ -121,8 +156,6 @@
SF_FORMAT_SHN = 0x4110000, /* Shorten. */
/* Unsupported encodings. */
- SF_FORMAT_VORBIS = 0x1001,
-
SF_FORMAT_SVX_FIB = 0x1020, /* SVX Fibonacci Delta encoding. */
SF_FORMAT_SVX_EXP = 0x1021, /* SVX Exponential Delta encoding. */
@@ -187,8 +220,18 @@
** contents.
*/
+
+typedef struct
+{ int size ;
+ SF_BROADCAST_INFO binfo ;
+} SF_BROADCAST_VAR ;
+
typedef struct sf_private_tag
-{ /* Force the compiler to double align the start of buffer. */
+{
+ /* Canary in a coal mine. */
+ char canary [64] ;
+
+ /* Force the compiler to double align the start of buffer. */
union
{ double dbuf [SF_BUFFER_LEN / sizeof (double)] ;
#if (defined (SIZEOF_INT64_T) && (SIZEOF_INT64_T == 8))
@@ -229,6 +272,8 @@
/* Guard value. If this changes the buffers above have overflowed. */
int Magick ;
+ unsigned unique_id ;
+
/* Index variables for maintaining logbuffer and header above. */
int logindex ;
int headindex, headend ;
@@ -250,7 +295,7 @@
int mode ; /* Open mode : SFM_READ, SFM_WRITE or SFM_RDWR. */
int endian ; /* File endianness : SF_ENDIAN_LITTLE or SF_ENDIAN_BIG. */
- int float_endswap ; /* Need to endswap float32s? */
+ int data_endswap ; /* Need to endswap data? */
/*
** Maximum float value for calculating the multiplier for
@@ -259,6 +304,8 @@
int float_int_mult ;
float float_max ;
+ int scale_int_float ;
+
/* Vairables for handling pipes. */
int is_pipe ; /* True if file is a pipe. */
sf_count_t pipeoffset ; /* Number of bytes read from a pipe. */
@@ -276,7 +323,7 @@
SF_INSTRUMENT *instrument ;
/* Broadcast (EBU) Info */
- SF_BROADCAST_INFO *broadcast_info ;
+ SF_BROADCAST_VAR *broadcast_var ;
/* Channel map data (if present) : an array of ints. */
int *channel_map ;
@@ -317,8 +364,8 @@
int auto_header ;
int ieee_replace ;
- /* A set of file specific function pointers */
+ /* A set of file specific function pointers */
sf_count_t (*read_short) (struct sf_private_tag*, short *ptr, sf_count_t len) ;
sf_count_t (*read_int) (struct sf_private_tag*, int *ptr, sf_count_t len) ;
sf_count_t (*read_float) (struct sf_private_tag*, float *ptr, sf_count_t len) ;
@@ -357,6 +404,8 @@
SFE_MALFORMED_FILE = SF_ERR_MALFORMED_FILE,
SFE_UNSUPPORTED_ENCODING = SF_ERR_UNSUPPORTED_ENCODING,
+ SFE_ZERO_MAJOR_FORMAT,
+ SFE_ZERO_MINOR_FORMAT,
SFE_BAD_FILE,
SFE_BAD_FILE_READ,
SFE_OPEN_FAILED,
@@ -381,10 +430,10 @@
SFE_NO_PIPE_WRITE,
SFE_INTERNAL,
- SFE_BAD_CONTROL_CMD,
+ SFE_BAD_COMMAND_PARAM,
SFE_BAD_ENDIAN,
+ SFE_CHANNEL_COUNT_ZERO,
SFE_CHANNEL_COUNT,
- SFE_BAD_RDWR_FORMAT,
SFE_BAD_VIRTUAL_IO,
@@ -402,6 +451,8 @@
SFE_OPEN_PIPE_RDWR,
SFE_RDWR_POSITION,
SFE_RDWR_BAD_HEADER,
+ SFE_CMD_HAS_DATA,
+ SFE_BAD_BROADCAST_INFO_SIZE,
SFE_STR_NO_SUPPORT,
SFE_STR_NOT_WRITE,
@@ -415,6 +466,7 @@
SFE_WAV_NO_RIFF,
SFE_WAV_NO_WAVE,
SFE_WAV_NO_FMT,
+ SFE_WAV_BAD_FMT,
SFE_WAV_FMT_SHORT,
SFE_WAV_BAD_FACT,
SFE_WAV_BAD_PEAK,
@@ -483,22 +535,17 @@
SFE_W64_64_BIT,
SFE_W64_NO_RIFF,
SFE_W64_NO_WAVE,
- SFE_W64_NO_FMT,
SFE_W64_NO_DATA,
- SFE_W64_FMT_SHORT,
- SFE_W64_FMT_TOO_BIG,
SFE_W64_ADPCM_NOT4BIT,
SFE_W64_ADPCM_CHANNELS,
SFE_W64_GSM610_FORMAT,
SFE_MAT4_BAD_NAME,
SFE_MAT4_NO_SAMPLERATE,
- SFE_MAT4_ZERO_CHANNELS,
SFE_MAT5_BAD_ENDIAN,
SFE_MAT5_NO_BLOCK,
SFE_MAT5_SAMPLE_RATE,
- SFE_MAT5_ZERO_CHANNELS,
SFE_PVF_NO_PVF1,
SFE_PVF_BAD_HEADER,
@@ -531,6 +578,13 @@
SFE_FLAC_BAD_SAMPLE_RATE,
SFE_FLAC_UNKOWN_ERROR,
+ SFE_WVE_NOT_WVE,
+ SFE_WVE_NO_PIPE,
+
+ SFE_VORBIS_ENCODER_BUG,
+
+ SFE_RF64_NOT_RF64,
+
SFE_MAX_ERROR /* This must be last in list. */
} ;
@@ -556,7 +610,7 @@
void psf_log_printf (SF_PRIVATE *psf, const char *format, ...) ;
void psf_log_SF_INFO (SF_PRIVATE *psf) ;
-void psf_hexdump (void *ptr, int len) ;
+int32_t psf_rand_int32 (void) ;
/* Functions used when writing file headers. */
@@ -599,13 +653,11 @@
const char* psf_get_string (SF_PRIVATE *psf, int str_type) ;
int psf_set_string (SF_PRIVATE *psf, int str_type, const char *str) ;
int psf_store_string (SF_PRIVATE *psf, int str_type, const char *str) ;
+int psf_location_string_count (const SF_PRIVATE * psf, int location) ;
/* Default seek function. Use for PCM and float encoded data. */
sf_count_t psf_default_seek (SF_PRIVATE *psf, int mode, sf_count_t samples_from_start) ;
-/* Generate the currebt date as a string. */
-void psf_get_date_str (char *str, int maxlen) ;
-
int macos_guess_file_type (SF_PRIVATE *psf, const char *filename) ;
/*------------------------------------------------------------------------------------
@@ -667,6 +719,8 @@
int xi_open (SF_PRIVATE *psf) ;
int flac_open (SF_PRIVATE *psf) ;
int caf_open (SF_PRIVATE *psf) ;
+int mpc2k_open (SF_PRIVATE *psf) ;
+int rf64_open (SF_PRIVATE *psf) ;
/* In progress. Do not currently work. */
@@ -704,6 +758,23 @@
int interleave_init (SF_PRIVATE *psf) ;
/*------------------------------------------------------------------------------------
+** Chunk logging functions.
+*/
+
+typedef struct
+{ struct
+ { int chunk ;
+ sf_count_t offset ;
+ sf_count_t len ;
+ } l [100] ;
+
+ int count ;
+} PRIV_CHUNK4 ;
+
+void pchk4_store (PRIV_CHUNK4 * pchk, int marker, sf_count_t offset, sf_count_t len) ;
+int pchk4_find (PRIV_CHUNK4 * pchk, int marker) ;
+
+/*------------------------------------------------------------------------------------
** Other helper functions.
*/
@@ -711,33 +782,34 @@
SF_INSTRUMENT * psf_instrument_alloc (void) ;
+void psf_sanitize_string (char * cptr, int len) ;
+
+/* Generate the current date as a string. */
+void psf_get_date_str (char *str, int maxlen) ;
+
+SF_BROADCAST_VAR* broadcast_var_alloc (size_t datasize) ;
+int broadcast_var_set (SF_PRIVATE *psf, const SF_BROADCAST_INFO * data, size_t datasize) ;
+int broadcast_var_get (SF_PRIVATE *psf, SF_BROADCAST_INFO * data, size_t datasize) ;
+
+
+typedef struct
+{ int channels ;
+ int endianness ;
+} AUDIO_DETECT ;
+
+int audio_detect (SF_PRIVATE * psf, AUDIO_DETECT *ad, const unsigned char * data, int datalen) ;
-SF_BROADCAST_INFO* broadcast_info_alloc (void) ;
-int broadcast_info_copy (SF_BROADCAST_INFO* dst, SF_BROADCAST_INFO* src) ;
-int broadcast_add_coding_history (SF_BROADCAST_INFO* bext, unsigned int channels, unsigned int samplerate) ;
/*------------------------------------------------------------------------------------
-** Here's how we fix systems which don't snprintf / vsnprintf.
-** Systems without these functions should use the
+** Helper/debug functions.
*/
-#if USE_WINDOWS_API
-#define LSF_SNPRINTF _snprintf
-#elif (HAVE_SNPRINTF && ! FORCE_MISSING_SNPRINTF)
-#define LSF_SNPRINTF snprintf
-#else
-int missing_snprintf (char *str, size_t n, char const *fmt, ...) ;
-#define LSF_SNPRINTF missing_snprintf
-#endif
+void psf_hexdump (const void *ptr, int len) ;
-#if USE_WINDOWS_API
-#define LSF_VSNPRINTF _vsnprintf
-#elif (HAVE_VSNPRINTF && ! FORCE_MISSING_SNPRINTF)
-#define LSF_VSNPRINTF vsnprintf
-#else
-int missing_vsnprintf (char *str, size_t n, const char *fmt, ...) ;
-#define LSF_VSNPRINTF missing_vsnprintf
-#endif
+const char * str_of_major_format (int format) ;
+const char * str_of_minor_format (int format) ;
+const char * str_of_open_mode (int mode) ;
+const char * str_of_endianness (int end) ;
/*------------------------------------------------------------------------------------
** Extra commands for sf_command(). Not for public use yet.
@@ -764,10 +836,3 @@
#endif /* SNDFILE_COMMON_H */
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: 7b45c0ee-5835-4a18-a4ef-994e4cd95b67
-*/
Modified: freeswitch/trunk/libs/libsndfile/src/create_symbols_file.py
==============================================================================
--- freeswitch/trunk/libs/libsndfile/src/create_symbols_file.py (original)
+++ freeswitch/trunk/libs/libsndfile/src/create_symbols_file.py Thu May 21 16:09:30 2009
@@ -1,6 +1,6 @@
#!/usr/bin/python
-# Copyright (C) 2003,2004 Erik de Castro Lopo <erikd at mega-nerd.com>
+# Copyright (C) 2003-2007 Erik de Castro Lopo <erikd at mega-nerd.com>
#
# All rights reserved.
#
@@ -105,6 +105,18 @@
print
return
+def os2_symbols (progname, version, name):
+ print "; Auto-generated by %s\n" %progname
+ print "LIBRARY %s%s.dll" % (name, re.sub ("\..*", "", version))
+ print "INITINSTANCE TERMINSTANCE"
+ print "CODE PRELOAD MOVEABLE DISCARDABLE"
+ print "DATA PRELOAD MOVEABLE MULTIPLE NONSHARED"
+ print "EXPORTS\n"
+ for name, ordinal in ALL_SYMBOLS:
+ print "_%-20s @%s" % (name, ordinal)
+ print
+ return
+
def no_symbols (os_name):
print
print "No known way of restricting exported symbols on '%s'." % os_name
@@ -125,6 +137,7 @@
print " darwin (ie MacOSX)"
print " win32 (ie wintendo)"
print " cygwin (Cygwin on wintendo)"
+ print " os2 (OS/2)"
print
sys.exit (1)
@@ -139,14 +152,10 @@
win32_symbols (progname, version, "libsndfile")
elif os_name == "cygwin":
win32_symbols (progname, version, "cygsndfile")
+elif os_name == "os2":
+ os2_symbols (progname, version, "sndfile")
else:
no_symbols (os_name)
sys.exit (0)
-# Do not edit or modify anything in this comment block.
-# The arch-tag line is a file identity tag for the GNU Arch
-# revision control system.
-#
-# arch-tag: 5814f35c-318f-4023-a0c3-d9cf7c9e5f6c
-
Modified: freeswitch/trunk/libs/libsndfile/src/dither.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/src/dither.c (original)
+++ freeswitch/trunk/libs/libsndfile/src/dither.c Thu May 21 16:09:30 2009
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 2003,2005 Erik de Castro Lopo <erikd at mega-nerd.com>
+** Copyright (C) 2003-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU Lesser General Public License as published by
@@ -128,11 +128,12 @@
if (pdither == NULL)
return SFE_MALLOC_FAILED ;
- switch (psf->sf.format & SF_FORMAT_SUBMASK)
+ switch (SF_CODEC (psf->sf.format))
{ case SF_FORMAT_DOUBLE :
case SF_FORMAT_FLOAT :
pdither->read_int = psf->read_int ;
psf->read_int = dither_read_int ;
+ break ;
case SF_FORMAT_PCM_32 :
case SF_FORMAT_PCM_24 :
@@ -141,6 +142,7 @@
case SF_FORMAT_PCM_U8 :
pdither->read_short = psf->read_short ;
psf->read_short = dither_read_short ;
+ break ;
default : break ;
} ;
@@ -153,17 +155,19 @@
if (pdither == NULL)
return SFE_MALLOC_FAILED ;
- switch (psf->sf.format & SF_FORMAT_SUBMASK)
+ switch (SF_CODEC (psf->sf.format))
{ case SF_FORMAT_DOUBLE :
case SF_FORMAT_FLOAT :
pdither->write_int = psf->write_int ;
psf->write_int = dither_write_int ;
+ break ;
case SF_FORMAT_PCM_32 :
case SF_FORMAT_PCM_24 :
case SF_FORMAT_PCM_16 :
case SF_FORMAT_PCM_S8 :
case SF_FORMAT_PCM_U8 :
+ break ;
default : break ;
} ;
@@ -194,16 +198,14 @@
static void dither_double (const double *in, double *out, int frames, int channels) ;
static sf_count_t
-dither_read_short (SF_PRIVATE *psf, short *ptr, sf_count_t len)
-{ psf = psf ;
- ptr = ptr ;
+dither_read_short (SF_PRIVATE * UNUSED (psf), short * UNUSED (ptr), sf_count_t len)
+{
return len ;
} /* dither_read_short */
static sf_count_t
-dither_read_int (SF_PRIVATE *psf, int *ptr, sf_count_t len)
-{ psf = psf ;
- ptr = ptr ;
+dither_read_int (SF_PRIVATE * UNUSED (psf), int * UNUSED (ptr), sf_count_t len)
+{
return len ;
} /* dither_read_int */
@@ -221,7 +223,7 @@
return 0 ;
} ;
- switch (psf->sf.format & SF_FORMAT_SUBMASK)
+ switch (SF_CODEC (psf->sf.format))
{ case SF_FORMAT_PCM_S8 :
case SF_FORMAT_PCM_U8 :
case SF_FORMAT_DPCM_8 :
@@ -261,11 +263,12 @@
return 0 ;
} ;
- switch (psf->sf.format & SF_FORMAT_SUBMASK)
+ switch (SF_CODEC (psf->sf.format))
{ case SF_FORMAT_PCM_S8 :
case SF_FORMAT_PCM_U8 :
case SF_FORMAT_PCM_16 :
case SF_FORMAT_PCM_24 :
+ break ;
case SF_FORMAT_DPCM_8 :
case SF_FORMAT_DPCM_16 :
@@ -306,11 +309,12 @@
return 0 ;
} ;
- switch (psf->sf.format & SF_FORMAT_SUBMASK)
+ switch (SF_CODEC (psf->sf.format))
{ case SF_FORMAT_PCM_S8 :
case SF_FORMAT_PCM_U8 :
case SF_FORMAT_PCM_16 :
case SF_FORMAT_PCM_24 :
+ break ;
case SF_FORMAT_DPCM_8 :
case SF_FORMAT_DPCM_16 :
@@ -350,11 +354,12 @@
return 0 ;
} ;
- switch (psf->sf.format & SF_FORMAT_SUBMASK)
+ switch (SF_CODEC (psf->sf.format))
{ case SF_FORMAT_PCM_S8 :
case SF_FORMAT_PCM_U8 :
case SF_FORMAT_PCM_16 :
case SF_FORMAT_PCM_24 :
+ break ;
case SF_FORMAT_DPCM_8 :
case SF_FORMAT_DPCM_16 :
@@ -526,10 +531,4 @@
} /* DO_NOT_USE_sf_dither_double */
#endif
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: 673fad58-5314-421c-9144-9d54bfdf104c
-*/
+
Modified: freeswitch/trunk/libs/libsndfile/src/double64.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/src/double64.c (original)
+++ freeswitch/trunk/libs/libsndfile/src/double64.c Thu May 21 16:09:30 2009
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 1999-2005 Erik de Castro Lopo <erikd at mega-nerd.com>
+** Copyright (C) 1999-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU Lesser General Public License as published by
@@ -21,11 +21,12 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <limits.h>
+#include <math.h>
#include "sndfile.h"
#include "sfendian.h"
#include "common.h"
-#include "float_cast.h"
#if CPU_IS_LITTLE_ENDIAN
#define DOUBLE64_READ double64_le_read
@@ -97,7 +98,7 @@
if (psf->mode == SFM_READ || psf->mode == SFM_RDWR)
{ switch (psf->endian + double64_caps)
{ case (SF_ENDIAN_BIG + DOUBLE_CAN_RW_BE) :
- psf->float_endswap = SF_FALSE ;
+ psf->data_endswap = SF_FALSE ;
psf->read_short = host_read_d2s ;
psf->read_int = host_read_d2i ;
psf->read_float = host_read_d2f ;
@@ -105,7 +106,7 @@
break ;
case (SF_ENDIAN_LITTLE + DOUBLE_CAN_RW_LE) :
- psf->float_endswap = SF_FALSE ;
+ psf->data_endswap = SF_FALSE ;
psf->read_short = host_read_d2s ;
psf->read_int = host_read_d2i ;
psf->read_float = host_read_d2f ;
@@ -113,7 +114,7 @@
break ;
case (SF_ENDIAN_BIG + DOUBLE_CAN_RW_LE) :
- psf->float_endswap = SF_TRUE ;
+ psf->data_endswap = SF_TRUE ;
psf->read_short = host_read_d2s ;
psf->read_int = host_read_d2i ;
psf->read_float = host_read_d2f ;
@@ -121,7 +122,7 @@
break ;
case (SF_ENDIAN_LITTLE + DOUBLE_CAN_RW_BE) :
- psf->float_endswap = SF_TRUE ;
+ psf->data_endswap = SF_TRUE ;
psf->read_short = host_read_d2s ;
psf->read_int = host_read_d2i ;
psf->read_float = host_read_d2f ;
@@ -130,7 +131,7 @@
/* When the CPU is not IEEE compatible. */
case (SF_ENDIAN_BIG + DOUBLE_BROKEN_BE) :
- psf->float_endswap = SF_FALSE ;
+ psf->data_endswap = SF_FALSE ;
psf->read_short = replace_read_d2s ;
psf->read_int = replace_read_d2i ;
psf->read_float = replace_read_d2f ;
@@ -138,7 +139,7 @@
break ;
case (SF_ENDIAN_LITTLE + DOUBLE_BROKEN_LE) :
- psf->float_endswap = SF_FALSE ;
+ psf->data_endswap = SF_FALSE ;
psf->read_short = replace_read_d2s ;
psf->read_int = replace_read_d2i ;
psf->read_float = replace_read_d2f ;
@@ -146,7 +147,7 @@
break ;
case (SF_ENDIAN_BIG + DOUBLE_BROKEN_LE) :
- psf->float_endswap = SF_TRUE ;
+ psf->data_endswap = SF_TRUE ;
psf->read_short = replace_read_d2s ;
psf->read_int = replace_read_d2i ;
psf->read_float = replace_read_d2f ;
@@ -154,7 +155,7 @@
break ;
case (SF_ENDIAN_LITTLE + DOUBLE_BROKEN_BE) :
- psf->float_endswap = SF_TRUE ;
+ psf->data_endswap = SF_TRUE ;
psf->read_short = replace_read_d2s ;
psf->read_int = replace_read_d2i ;
psf->read_float = replace_read_d2f ;
@@ -168,7 +169,7 @@
if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR)
{ switch (psf->endian + double64_caps)
{ case (SF_ENDIAN_LITTLE + DOUBLE_CAN_RW_LE) :
- psf->float_endswap = SF_FALSE ;
+ psf->data_endswap = SF_FALSE ;
psf->write_short = host_write_s2d ;
psf->write_int = host_write_i2d ;
psf->write_float = host_write_f2d ;
@@ -176,7 +177,7 @@
break ;
case (SF_ENDIAN_BIG + DOUBLE_CAN_RW_BE) :
- psf->float_endswap = SF_FALSE ;
+ psf->data_endswap = SF_FALSE ;
psf->write_short = host_write_s2d ;
psf->write_int = host_write_i2d ;
psf->write_float = host_write_f2d ;
@@ -184,7 +185,7 @@
break ;
case (SF_ENDIAN_BIG + DOUBLE_CAN_RW_LE) :
- psf->float_endswap = SF_TRUE ;
+ psf->data_endswap = SF_TRUE ;
psf->write_short = host_write_s2d ;
psf->write_int = host_write_i2d ;
psf->write_float = host_write_f2d ;
@@ -192,7 +193,7 @@
break ;
case (SF_ENDIAN_LITTLE + DOUBLE_CAN_RW_BE) :
- psf->float_endswap = SF_TRUE ;
+ psf->data_endswap = SF_TRUE ;
psf->write_short = host_write_s2d ;
psf->write_int = host_write_i2d ;
psf->write_float = host_write_f2d ;
@@ -201,7 +202,7 @@
/* When the CPU is not IEEE compatible. */
case (SF_ENDIAN_LITTLE + DOUBLE_BROKEN_LE) :
- psf->float_endswap = SF_FALSE ;
+ psf->data_endswap = SF_FALSE ;
psf->write_short = replace_write_s2d ;
psf->write_int = replace_write_i2d ;
psf->write_float = replace_write_f2d ;
@@ -209,7 +210,7 @@
break ;
case (SF_ENDIAN_BIG + DOUBLE_BROKEN_BE) :
- psf->float_endswap = SF_FALSE ;
+ psf->data_endswap = SF_FALSE ;
psf->write_short = replace_write_s2d ;
psf->write_int = replace_write_i2d ;
psf->write_float = replace_write_f2d ;
@@ -217,7 +218,7 @@
break ;
case (SF_ENDIAN_BIG + DOUBLE_BROKEN_LE) :
- psf->float_endswap = SF_TRUE ;
+ psf->data_endswap = SF_TRUE ;
psf->write_short = replace_write_s2d ;
psf->write_int = replace_write_i2d ;
psf->write_float = replace_write_f2d ;
@@ -225,7 +226,7 @@
break ;
case (SF_ENDIAN_LITTLE + DOUBLE_BROKEN_BE) :
- psf->float_endswap = SF_TRUE ;
+ psf->data_endswap = SF_TRUE ;
psf->write_short = replace_write_s2d ;
psf->write_int = replace_write_i2d ;
psf->write_float = replace_write_f2d ;
@@ -300,9 +301,9 @@
dvalue *= -1 ;
if (exponent > 0)
- dvalue *= (1 << exponent) ;
+ dvalue *= pow (2.0, exponent) ;
else if (exponent < 0)
- dvalue /= (1 << abs (exponent)) ;
+ dvalue /= pow (2.0, abs (exponent)) ;
return dvalue ;
} /* double64_be_read */
@@ -333,9 +334,9 @@
dvalue *= -1 ;
if (exponent > 0)
- dvalue *= (1 << exponent) ;
+ dvalue *= pow (2.0, exponent) ;
else if (exponent < 0)
- dvalue /= (1 << abs (exponent)) ;
+ dvalue /= pow (2.0, abs (exponent)) ;
return dvalue ;
} /* double64_le_read */
@@ -478,20 +479,48 @@
/*=======================================================================================
*/
-static inline void
+static void
d2s_array (const double *src, int count, short *dest, double scale)
{ while (--count >= 0)
{ dest [count] = lrint (scale * src [count]) ;
} ;
} /* d2s_array */
-static inline void
+static void
+d2s_clip_array (const double *src, int count, short *dest, double scale)
+{ while (--count >= 0)
+ { double tmp = scale * src [count] ;
+
+ if (CPU_CLIPS_POSITIVE == 0 && tmp > 32767.0)
+ dest [count] = SHRT_MAX ;
+ else if (CPU_CLIPS_NEGATIVE == 0 && tmp < -32768.0)
+ dest [count] = SHRT_MIN ;
+ else
+ dest [count] = lrint (tmp) ;
+ } ;
+} /* d2s_clip_array */
+
+static void
d2i_array (const double *src, int count, int *dest, double scale)
{ while (--count >= 0)
{ dest [count] = lrint (scale * src [count]) ;
} ;
} /* d2i_array */
+static void
+d2i_clip_array (const double *src, int count, int *dest, double scale)
+{ while (--count >= 0)
+ { float tmp = scale * src [count] ;
+
+ if (CPU_CLIPS_POSITIVE == 0 && tmp > (1.0 * INT_MAX))
+ dest [count] = INT_MAX ;
+ else if (CPU_CLIPS_NEGATIVE == 0 && tmp < (-1.0 * INT_MAX))
+ dest [count] = INT_MIN ;
+ else
+ dest [count] = lrint (tmp) ;
+ } ;
+} /* d2i_clip_array */
+
static inline void
d2f_array (const double *src, int count, float *dest)
{ while (--count >= 0)
@@ -500,16 +529,16 @@
} /* d2f_array */
static inline void
-s2d_array (const short *src, double *dest, int count)
+s2d_array (const short *src, double *dest, int count, double scale)
{ while (--count >= 0)
- { dest [count] = src [count] ;
+ { dest [count] = scale * src [count] ;
} ;
} /* s2d_array */
static inline void
-i2d_array (const int *src, double *dest, int count)
+i2d_array (const int *src, double *dest, int count, double scale)
{ while (--count >= 0)
- { dest [count] = src [count] ;
+ { dest [count] = scale * src [count] ;
} ;
} /* i2d_array */
@@ -525,10 +554,12 @@
static sf_count_t
host_read_d2s (SF_PRIVATE *psf, short *ptr, sf_count_t len)
-{ int bufferlen, readcount ;
+{ void (*convert) (const double *, int, short *, double) ;
+ int bufferlen, readcount ;
sf_count_t total = 0 ;
double scale ;
+ convert = (psf->add_clipping) ? d2s_clip_array : d2s_array ;
bufferlen = ARRAY_LEN (psf->u.dbuf) ;
scale = (psf->float_int_mult == 0) ? 1.0 : 0x7FFF / psf->float_max ;
@@ -537,10 +568,10 @@
bufferlen = (int) len ;
readcount = psf_fread (psf->u.dbuf, sizeof (double), bufferlen, psf) ;
- if (psf->float_endswap == SF_TRUE)
+ if (psf->data_endswap == SF_TRUE)
endswap_double_array (psf->u.dbuf, readcount) ;
- d2s_array (psf->u.dbuf, readcount, ptr + total, scale) ;
+ convert (psf->u.dbuf, readcount, ptr + total, scale) ;
total += readcount ;
len -= readcount ;
if (readcount < bufferlen)
@@ -552,9 +583,12 @@
static sf_count_t
host_read_d2i (SF_PRIVATE *psf, int *ptr, sf_count_t len)
-{ int bufferlen, readcount ;
+{ void (*convert) (const double *, int, int *, double) ;
+ int bufferlen, readcount ;
sf_count_t total = 0 ;
double scale ;
+
+ convert = (psf->add_clipping) ? d2i_clip_array : d2i_array ;
bufferlen = ARRAY_LEN (psf->u.dbuf) ;
scale = (psf->float_int_mult == 0) ? 1.0 : 0x7FFFFFFF / psf->float_max ;
@@ -563,10 +597,10 @@
bufferlen = (int) len ;
readcount = psf_fread (psf->u.dbuf, sizeof (double), bufferlen, psf) ;
- if (psf->float_endswap == SF_TRUE)
+ if (psf->data_endswap == SF_TRUE)
endswap_double_array (psf->u.dbuf, bufferlen) ;
- d2i_array (psf->u.dbuf, readcount, ptr + total, scale) ;
+ convert (psf->u.dbuf, readcount, ptr + total, scale) ;
total += readcount ;
len -= readcount ;
if (readcount < bufferlen)
@@ -588,7 +622,7 @@
bufferlen = (int) len ;
readcount = psf_fread (psf->u.dbuf, sizeof (double), bufferlen, psf) ;
- if (psf->float_endswap == SF_TRUE)
+ if (psf->data_endswap == SF_TRUE)
endswap_double_array (psf->u.dbuf, bufferlen) ;
d2f_array (psf->u.dbuf, readcount, ptr + total) ;
@@ -608,7 +642,7 @@
readcount = psf_fread (ptr, sizeof (double), len, psf) ;
- if (psf->float_endswap != SF_TRUE)
+ if (psf->data_endswap != SF_TRUE)
return readcount ;
/* If the read length was sensible, endswap output in one go. */
@@ -635,19 +669,21 @@
host_write_s2d (SF_PRIVATE *psf, const short *ptr, sf_count_t len)
{ int bufferlen, writecount ;
sf_count_t total = 0 ;
+ double scale ;
+ scale = (psf->scale_int_float == 0) ? 1.0 : 1.0 / 0x8000 ;
bufferlen = ARRAY_LEN (psf->u.dbuf) ;
while (len > 0)
{ if (len < bufferlen)
bufferlen = (int) len ;
- s2d_array (ptr + total, psf->u.dbuf, bufferlen) ;
+ s2d_array (ptr + total, psf->u.dbuf, bufferlen, scale) ;
if (psf->peak_info)
double64_peak_update (psf, psf->u.dbuf, bufferlen, total / psf->sf.channels) ;
- if (psf->float_endswap == SF_TRUE)
+ if (psf->data_endswap == SF_TRUE)
endswap_double_array (psf->u.dbuf, bufferlen) ;
writecount = psf_fwrite (psf->u.dbuf, sizeof (double), bufferlen, psf) ;
@@ -664,18 +700,20 @@
host_write_i2d (SF_PRIVATE *psf, const int *ptr, sf_count_t len)
{ int bufferlen, writecount ;
sf_count_t total = 0 ;
+ double scale ;
+ scale = (psf->scale_int_float == 0) ? 1.0 : 1.0 / (8.0 * 0x10000000) ;
bufferlen = ARRAY_LEN (psf->u.dbuf) ;
while (len > 0)
{ if (len < bufferlen)
bufferlen = (int) len ;
- i2d_array (ptr + total, psf->u.dbuf, bufferlen) ;
+ i2d_array (ptr + total, psf->u.dbuf, bufferlen, scale) ;
if (psf->peak_info)
double64_peak_update (psf, psf->u.dbuf, bufferlen, total / psf->sf.channels) ;
- if (psf->float_endswap == SF_TRUE)
+ if (psf->data_endswap == SF_TRUE)
endswap_double_array (psf->u.dbuf, bufferlen) ;
writecount = psf_fwrite (psf->u.dbuf, sizeof (double), bufferlen, psf) ;
@@ -703,7 +741,7 @@
if (psf->peak_info)
double64_peak_update (psf, psf->u.dbuf, bufferlen, total / psf->sf.channels) ;
- if (psf->float_endswap == SF_TRUE)
+ if (psf->data_endswap == SF_TRUE)
endswap_double_array (psf->u.dbuf, bufferlen) ;
writecount = psf_fwrite (psf->u.dbuf, sizeof (double), bufferlen, psf) ;
@@ -724,7 +762,7 @@
if (psf->peak_info)
double64_peak_update (psf, ptr, len, 0) ;
- if (psf->float_endswap != SF_TRUE)
+ if (psf->data_endswap != SF_TRUE)
return psf_fwrite (ptr, sizeof (double), len, psf) ;
bufferlen = ARRAY_LEN (psf->u.dbuf) ;
@@ -762,7 +800,7 @@
bufferlen = (int) len ;
readcount = psf_fread (psf->u.dbuf, sizeof (double), bufferlen, psf) ;
- if (psf->float_endswap == SF_TRUE)
+ if (psf->data_endswap == SF_TRUE)
endswap_double_array (psf->u.dbuf, bufferlen) ;
d2bd_read (psf->u.dbuf, bufferlen) ;
@@ -791,7 +829,7 @@
bufferlen = (int) len ;
readcount = psf_fread (psf->u.dbuf, sizeof (double), bufferlen, psf) ;
- if (psf->float_endswap == SF_TRUE)
+ if (psf->data_endswap == SF_TRUE)
endswap_double_array (psf->u.dbuf, bufferlen) ;
d2bd_read (psf->u.dbuf, bufferlen) ;
@@ -818,7 +856,7 @@
bufferlen = (int) len ;
readcount = psf_fread (psf->u.dbuf, sizeof (double), bufferlen, psf) ;
- if (psf->float_endswap == SF_TRUE)
+ if (psf->data_endswap == SF_TRUE)
endswap_double_array (psf->u.dbuf, bufferlen) ;
d2bd_read (psf->u.dbuf, bufferlen) ;
@@ -847,7 +885,7 @@
bufferlen = (int) len ;
readcount = psf_fread (psf->u.dbuf, sizeof (double), bufferlen, psf) ;
- if (psf->float_endswap == SF_TRUE)
+ if (psf->data_endswap == SF_TRUE)
endswap_double_array (psf->u.dbuf, readcount) ;
d2bd_read (psf->u.dbuf, readcount) ;
@@ -867,20 +905,22 @@
replace_write_s2d (SF_PRIVATE *psf, const short *ptr, sf_count_t len)
{ int bufferlen, writecount ;
sf_count_t total = 0 ;
+ double scale ;
+ scale = (psf->scale_int_float == 0) ? 1.0 : 1.0 / 0x8000 ;
bufferlen = ARRAY_LEN (psf->u.dbuf) ;
while (len > 0)
{ if (len < bufferlen)
bufferlen = (int) len ;
- s2d_array (ptr + total, psf->u.dbuf, bufferlen) ;
+ s2d_array (ptr + total, psf->u.dbuf, bufferlen, scale) ;
if (psf->peak_info)
double64_peak_update (psf, psf->u.dbuf, bufferlen, total / psf->sf.channels) ;
bd2d_write (psf->u.dbuf, bufferlen) ;
- if (psf->float_endswap == SF_TRUE)
+ if (psf->data_endswap == SF_TRUE)
endswap_double_array (psf->u.dbuf, bufferlen) ;
writecount = psf_fwrite (psf->u.dbuf, sizeof (double), bufferlen, psf) ;
@@ -897,20 +937,22 @@
replace_write_i2d (SF_PRIVATE *psf, const int *ptr, sf_count_t len)
{ int bufferlen, writecount ;
sf_count_t total = 0 ;
+ double scale ;
+ scale = (psf->scale_int_float == 0) ? 1.0 : 1.0 / (8.0 * 0x10000000) ;
bufferlen = ARRAY_LEN (psf->u.dbuf) ;
while (len > 0)
{ if (len < bufferlen)
bufferlen = (int) len ;
- i2d_array (ptr + total, psf->u.dbuf, bufferlen) ;
+ i2d_array (ptr + total, psf->u.dbuf, bufferlen, scale) ;
if (psf->peak_info)
double64_peak_update (psf, psf->u.dbuf, bufferlen, total / psf->sf.channels) ;
bd2d_write (psf->u.dbuf, bufferlen) ;
- if (psf->float_endswap == SF_TRUE)
+ if (psf->data_endswap == SF_TRUE)
endswap_double_array (psf->u.dbuf, bufferlen) ;
writecount = psf_fwrite (psf->u.dbuf, sizeof (double), bufferlen, psf) ;
@@ -937,7 +979,7 @@
bd2d_write (psf->u.dbuf, bufferlen) ;
- if (psf->float_endswap == SF_TRUE)
+ if (psf->data_endswap == SF_TRUE)
endswap_double_array (psf->u.dbuf, bufferlen) ;
writecount = psf_fwrite (psf->u.dbuf, sizeof (double), bufferlen, psf) ;
@@ -969,7 +1011,7 @@
bd2d_write (psf->u.dbuf, bufferlen) ;
- if (psf->float_endswap == SF_TRUE)
+ if (psf->data_endswap == SF_TRUE)
endswap_double_array (psf->u.dbuf, bufferlen) ;
writecount = psf_fwrite (psf->u.dbuf, sizeof (double), bufferlen, psf) ;
@@ -999,10 +1041,3 @@
} ;
} /* bd2d_write */
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: 4ee243b7-8c7a-469b-869c-e9aa0ee3b77f
-*/
Modified: freeswitch/trunk/libs/libsndfile/src/dwd.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/src/dwd.c (original)
+++ freeswitch/trunk/libs/libsndfile/src/dwd.c Thu May 21 16:09:30 2009
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 2002-2004 Erik de Castro Lopo <erikd at mega-nerd.com>
+** Copyright (C) 2002-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU Lesser General Public License as published by
@@ -33,7 +33,7 @@
dwd_open (SF_PRIVATE *psf)
{ if (psf)
return SFE_UNIMPLEMENTED ;
- return (psf && 0) ;
+ return 0 ;
} /* dwd_open */
#else
@@ -76,14 +76,14 @@
return error ;
} ;
- if ((psf->sf.format & SF_FORMAT_TYPEMASK) != SF_FORMAT_DWD)
+ if ((SF_CONTAINER (psf->sf.format)) != SF_FORMAT_DWD)
return SFE_BAD_OPEN_FORMAT ;
- subformat = psf->sf.format & SF_FORMAT_SUBMASK ;
+ subformat = SF_CODEC (psf->sf.format) ;
if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR)
{
- /*-psf->endian = psf->sf.format & SF_FORMAT_ENDMASK ;
+ /*-psf->endian = SF_ENDIAN (psf->sf.format) ;
if (CPU_IS_LITTLE_ENDIAN && psf->endian == SF_ENDIAN_CPU)
psf->endian = SF_ENDIAN_LITTLE ;
else if (psf->endian != SF_ENDIAN_LITTLE)
@@ -107,10 +107,8 @@
*/
static int
-dwd_close (SF_PRIVATE *psf)
+dwd_close (SF_PRIVATE * UNUSED (psf))
{
- psf = psf ;
-
return 0 ;
} /* dwd_close */
@@ -201,10 +199,4 @@
*/
#endif
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: a5e1d2a6-a840-4039-a0e7-e1a43eb05a4f
-*/
+
Modified: freeswitch/trunk/libs/libsndfile/src/dwvw.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/src/dwvw.c (original)
+++ freeswitch/trunk/libs/libsndfile/src/dwvw.c Thu May 21 16:09:30 2009
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 2002-2005 Erik de Castro Lopo <erikd at mega-nerd.com>
+** Copyright (C) 2002-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU Lesser General Public License as published by
@@ -31,10 +31,10 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <math.h>
#include "sndfile.h"
#include "sfendian.h"
-#include "float_cast.h"
#include "common.h"
typedef struct
@@ -154,11 +154,9 @@
} /* dwvw_close */
static sf_count_t
-dwvw_seek (SF_PRIVATE *psf, int mode, sf_count_t offset)
+dwvw_seek (SF_PRIVATE *psf, int UNUSED (mode), sf_count_t offset)
{ DWVW_PRIVATE *pdwvw ;
- mode = mode ;
-
if (! psf->codec_data)
{ psf->error = SFE_INTERNAL ;
return PSF_SEEK_ERROR ;
@@ -662,10 +660,3 @@
return total ;
} /* dwvw_write_d */
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: 1ca09552-b01f-4d7f-9bcf-612f834fe41d
-*/
Modified: freeswitch/trunk/libs/libsndfile/src/file_io.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/src/file_io.c (original)
+++ freeswitch/trunk/libs/libsndfile/src/file_io.c Thu May 21 16:09:30 2009
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 2002-2005 Erik de Castro Lopo <erikd at mega-nerd.com>
+** Copyright (C) 2002-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
** Copyright (C) 2003 Ross Bencina <rbencina at iprimus.com.au>
**
** This program is free software; you can redistribute it and/or modify
@@ -55,6 +55,15 @@
#define SENSIBLE_SIZE (0x40000000)
+/*
+** Neat solution to the Win32/OS2 binary file flage requirement.
+** If O_BINARY isn't already defined by the inclusion of the system
+** headers, set it to zero.
+*/
+#ifndef O_BINARY
+#define O_BINARY 0
+#endif
+
static void psf_log_syserr (SF_PRIVATE *psf, int error) ;
#if (USE_WINDOWS_API == 0)
@@ -114,7 +123,7 @@
return 0 ;
/* Test for MacOSX style resource fork on HPFS or HPFS+ filesystems. */
- LSF_SNPRINTF (psf->rsrcpath, sizeof (psf->rsrcpath), "%s/rsrc", psf->filepath) ;
+ snprintf (psf->rsrcpath, sizeof (psf->rsrcpath), "%s/rsrc", psf->filepath) ;
psf->error = SFE_NO_ERROR ;
if ((psf->rsrcdes = psf_open_fd (psf->rsrcpath, open_mode)) >= 0)
{ psf->rsrclength = psf_get_filelen_fd (psf->rsrcdes) ;
@@ -133,7 +142,7 @@
** Now try for a resource fork stored as a separate file in the same
** directory, but preceded with a dot underscore.
*/
- LSF_SNPRINTF (psf->rsrcpath, sizeof (psf->rsrcpath), "%s._%s", psf->directory, psf->filename) ;
+ snprintf (psf->rsrcpath, sizeof (psf->rsrcpath), "%s._%s", psf->directory, psf->filename) ;
psf->error = SFE_NO_ERROR ;
if ((psf->rsrcdes = psf_open_fd (psf->rsrcpath, open_mode)) >= 0)
{ psf->rsrclength = psf_get_filelen_fd (psf->rsrcdes) ;
@@ -144,7 +153,7 @@
** Now try for a resource fork stored in a separate file in the
** .AppleDouble/ directory.
*/
- LSF_SNPRINTF (psf->rsrcpath, sizeof (psf->rsrcpath), "%s.AppleDouble/%s", psf->directory, psf->filename) ;
+ snprintf (psf->rsrcpath, sizeof (psf->rsrcpath), "%s.AppleDouble/%s", psf->directory, psf->filename) ;
psf->error = SFE_NO_ERROR ;
if ((psf->rsrcdes = psf_open_fd (psf->rsrcpath, open_mode)) >= 0)
{ psf->rsrclength = psf_get_filelen_fd (psf->rsrcdes) ;
@@ -526,17 +535,17 @@
switch (open_mode)
{ case SFM_READ :
- oflag = O_RDONLY ;
+ oflag = O_RDONLY | O_BINARY ;
mode = 0 ;
break ;
case SFM_WRITE :
- oflag = O_WRONLY | O_CREAT | O_TRUNC ;
+ oflag = O_WRONLY | O_CREAT | O_TRUNC | O_BINARY ;
mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH ;
break ;
case SFM_RDWR :
- oflag = O_RDWR | O_CREAT ;
+ oflag = O_RDWR | O_CREAT | O_BINARY ;
mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH ;
break ;
@@ -545,11 +554,6 @@
break ;
} ;
-#if OS_IS_WIN32
- /* For Cygwin. */
- oflag |= O_BINARY ;
-#endif
-
if (mode == 0)
fd = open (pathname, oflag) ;
else
@@ -564,7 +568,7 @@
/* Only log an error if no error has been set yet. */
if (psf->error == 0)
{ psf->error = SFE_SYSTEM ;
- LSF_SNPRINTF (psf->syserr, sizeof (psf->syserr), "System error : %s.", strerror (error)) ;
+ snprintf (psf->syserr, sizeof (psf->syserr), "System error : %s.", strerror (error)) ;
} ;
return ;
@@ -588,10 +592,6 @@
#include <windows.h>
#include <io.h>
-#ifndef HAVE_SSIZE_T
-typedef long ssize_t ;
-#endif
-
static int psf_close_handle (HANDLE handle) ;
static HANDLE psf_open_handle (const char * path, int mode) ;
static sf_count_t psf_get_filelen_handle (HANDLE handle) ;
@@ -603,7 +603,7 @@
psf->hfile = psf_open_handle (pathname, open_mode) ;
if (psf->hfile == NULL)
- psf_log_syserr (psf, GetLastError()) ;
+ psf_log_syserr (psf, GetLastError ()) ;
psf->mode = open_mode ;
@@ -637,7 +637,7 @@
return 0 ;
/* Test for MacOSX style resource fork on HPFS or HPFS+ filesystems. */
- LSF_SNPRINTF (psf->rsrcpath, sizeof (psf->rsrcpath), "%s/rsrc", psf->filepath) ;
+ snprintf (psf->rsrcpath, sizeof (psf->rsrcpath), "%s/rsrc", psf->filepath) ;
psf->error = SFE_NO_ERROR ;
if ((psf->hrsrc = psf_open_handle (psf->rsrcpath, open_mode)) != NULL)
{ psf->rsrclength = psf_get_filelen_handle (psf->hrsrc) ;
@@ -648,7 +648,7 @@
** Now try for a resource fork stored as a separate file in the same
** directory, but preceded with a dot underscore.
*/
- LSF_SNPRINTF (psf->rsrcpath, sizeof (psf->rsrcpath), "%s._%s", psf->directory, psf->filename) ;
+ snprintf (psf->rsrcpath, sizeof (psf->rsrcpath), "%s._%s", psf->directory, psf->filename) ;
psf->error = SFE_NO_ERROR ;
if ((psf->hrsrc = psf_open_handle (psf->rsrcpath, open_mode)) != NULL)
{ psf->rsrclength = psf_get_filelen_handle (psf->hrsrc) ;
@@ -659,7 +659,7 @@
** Now try for a resource fork stored in a separate file in the
** .AppleDouble/ directory.
*/
- LSF_SNPRINTF (psf->rsrcpath, sizeof (psf->rsrcpath), "%s.AppleDouble/%s", psf->directory, psf->filename) ;
+ snprintf (psf->rsrcpath, sizeof (psf->rsrcpath), "%s.AppleDouble/%s", psf->directory, psf->filename) ;
psf->error = SFE_NO_ERROR ;
if ((psf->hrsrc = psf_open_handle (psf->rsrcpath, open_mode)) != NULL)
{ psf->rsrclength = psf_get_filelen_handle (psf->hrsrc) ;
@@ -806,7 +806,7 @@
NULL
) ;
- LSF_SNPRINTF (psf->syserr, sizeof (psf->syserr), "System error : %s", lpMsgBuf) ;
+ snprintf (psf->syserr, sizeof (psf->syserr), "System error : %s", (char*) lpMsgBuf) ;
LocalFree (lpMsgBuf) ;
} ;
@@ -858,8 +858,10 @@
/* USE_WINDOWS_API */ void
psf_set_file (SF_PRIVATE *psf, int fd)
{ HANDLE handle ;
+ intptr_t osfhandle ;
- handle = (HANDLE) _get_osfhandle (fd) ;
+ osfhandle = _get_osfhandle (fd) ;
+ handle = (HANDLE) osfhandle ;
psf->hfile = handle ;
} /* psf_set_file */
@@ -1159,10 +1161,6 @@
#include <io.h>
#include <direct.h>
-#ifndef HAVE_SSIZE_T
-typedef long ssize_t ;
-#endif
-
/* Win32 */ int
psf_fopen (SF_PRIVATE *psf, const char *pathname, int open_mode)
{ int oflag, mode ;
@@ -1518,7 +1516,7 @@
/* Only log an error if no error has been set yet. */
if (psf->error == 0)
{ psf->error = SFE_SYSTEM ;
- LSF_SNPRINTF (psf->syserr, sizeof (psf->syserr), "System error : %s", strerror (error)) ;
+ snprintf (psf->syserr, sizeof (psf->syserr), "System error : %s", strerror (error)) ;
} ;
return ;
@@ -1526,10 +1524,3 @@
#endif
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: 749740d7-ecc7-47bd-8cf7-600f31d32e6d
-*/
Modified: freeswitch/trunk/libs/libsndfile/src/flac.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/src/flac.c (original)
+++ freeswitch/trunk/libs/libsndfile/src/flac.c Thu May 21 16:09:30 2009
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 2004, 2005 Erik de Castro Lopo <erikd at mega-nerd.com>
+** Copyright (C) 2004-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
** Copyright (C) 2004 Tobias Gehrig <tgehrig at ira.uka.de>
**
** This program is free software ; you can redistribute it and/or modify
@@ -24,48 +24,43 @@
#include <fcntl.h>
#include <string.h>
#include <ctype.h>
+#include <math.h>
#include "sndfile.h"
#include "common.h"
+#if HAVE_EXTERNAL_LIBS
-#ifndef HAVE_FLAC_ALL_H
-
-int
-flac_open (SF_PRIVATE *psf)
-{ if (psf)
- return SFE_UNIMPLEMENTED ;
- return (psf && 0) ;
-} /* flac_open */
-
-
-#else
-
-#include <FLAC/all.h>
+#include <FLAC/stream_decoder.h>
+#include <FLAC/stream_encoder.h>
+#include <FLAC/metadata.h>
#include "sfendian.h"
-#include "float_cast.h"
/*------------------------------------------------------------------------------
** Private static functions.
*/
-#define ENC_BUFFER_SIZE 4096
+#define ENC_BUFFER_SIZE 8192
typedef enum
-{ PFLAC_PCM_SHORT = 0,
- PFLAC_PCM_INT = 1,
- PFLAC_PCM_FLOAT = 2,
- PFLAC_PCM_DOUBLE = 3
+{ PFLAC_PCM_SHORT = 50,
+ PFLAC_PCM_INT = 51,
+ PFLAC_PCM_FLOAT = 52,
+ PFLAC_PCM_DOUBLE = 53
} PFLAC_PCM ;
typedef struct
-{ FLAC__SeekableStreamDecoder *fsd ;
- FLAC__SeekableStreamEncoder *fse ;
+{
+ FLAC__StreamDecoder *fsd ;
+ FLAC__StreamEncoder *fse ;
+
PFLAC_PCM pcmtype ;
void* ptr ;
unsigned pos, len, remain ;
+ FLAC__StreamMetadata *metadata ;
+
const FLAC__int32 * const * wbuffer ;
FLAC__int32 * rbuffer [FLAC__MAX_CHANNELS] ;
@@ -76,6 +71,11 @@
FLAC__bool bufferbackup ;
} FLAC_PRIVATE ;
+typedef struct
+{ const char *tag ;
+ int type ;
+} FLAC_TAG ;
+
static sf_count_t flac_seek (SF_PRIVATE *psf, int mode, sf_count_t offset) ;
static int flac_close (SF_PRIVATE *psf) ;
@@ -108,21 +108,19 @@
static int flac_command (SF_PRIVATE *psf, int command, void *data, int datasize) ;
/* Decoder Callbacks */
-static FLAC__SeekableStreamDecoderReadStatus sf_flac_read_callback (const FLAC__SeekableStreamDecoder *decoder, FLAC__byte buffer [], unsigned *bytes, void *client_data) ;
-static FLAC__SeekableStreamDecoderSeekStatus sf_flac_seek_callback (const FLAC__SeekableStreamDecoder *decoder, FLAC__uint64 absolute_byte_offset, void *client_data) ;
-static FLAC__SeekableStreamDecoderTellStatus sf_flac_tell_callback (const FLAC__SeekableStreamDecoder *decoder, FLAC__uint64 *absolute_byte_offset, void *client_data) ;
-static FLAC__SeekableStreamDecoderLengthStatus sf_flac_length_callback (const FLAC__SeekableStreamDecoder *decoder, FLAC__uint64 *stream_length, void *client_data) ;
-static FLAC__bool sf_flac_eof_callback (const FLAC__SeekableStreamDecoder *decoder, void *client_data) ;
-static FLAC__StreamDecoderWriteStatus sf_flac_write_callback (const FLAC__SeekableStreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer [], void *client_data) ;
-static void sf_flac_meta_callback (const FLAC__SeekableStreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data) ;
-static void sf_flac_error_callback (const FLAC__SeekableStreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data) ;
+static FLAC__StreamDecoderReadStatus sf_flac_read_callback (const FLAC__StreamDecoder *decoder, FLAC__byte buffer [], size_t *bytes, void *client_data) ;
+static FLAC__StreamDecoderSeekStatus sf_flac_seek_callback (const FLAC__StreamDecoder *decoder, FLAC__uint64 absolute_byte_offset, void *client_data) ;
+static FLAC__StreamDecoderTellStatus sf_flac_tell_callback (const FLAC__StreamDecoder *decoder, FLAC__uint64 *absolute_byte_offset, void *client_data) ;
+static FLAC__StreamDecoderLengthStatus sf_flac_length_callback (const FLAC__StreamDecoder *decoder, FLAC__uint64 *stream_length, void *client_data) ;
+static FLAC__bool sf_flac_eof_callback (const FLAC__StreamDecoder *decoder, void *client_data) ;
+static FLAC__StreamDecoderWriteStatus sf_flac_write_callback (const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer [], void *client_data) ;
+static void sf_flac_meta_callback (const FLAC__StreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data) ;
+static void sf_flac_error_callback (const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data) ;
/* Encoder Callbacks */
-static FLAC__SeekableStreamEncoderSeekStatus sf_flac_enc_seek_callback (const FLAC__SeekableStreamEncoder *encoder, FLAC__uint64 absolute_byte_offset, void *client_data) ;
-#ifdef HAVE_FLAC_1_1_1
-static FLAC__SeekableStreamEncoderTellStatus sf_flac_enc_tell_callback (const FLAC__SeekableStreamEncoder *encoder, FLAC__uint64 *absolute_byte_offset, void *client_data) ;
-#endif
-static FLAC__StreamEncoderWriteStatus sf_flac_enc_write_callback (const FLAC__SeekableStreamEncoder *encoder, const FLAC__byte buffer [], unsigned bytes, unsigned samples, unsigned current_frame, void *client_data) ;
+static FLAC__StreamEncoderSeekStatus sf_flac_enc_seek_callback (const FLAC__StreamEncoder *encoder, FLAC__uint64 absolute_byte_offset, void *client_data) ;
+static FLAC__StreamEncoderTellStatus sf_flac_enc_tell_callback (const FLAC__StreamEncoder *encoder, FLAC__uint64 *absolute_byte_offset, void *client_data) ;
+static FLAC__StreamEncoderWriteStatus sf_flac_enc_write_callback (const FLAC__StreamEncoder *encoder, const FLAC__byte buffer [], size_t bytes, unsigned samples, unsigned current_frame, void *client_data) ;
static const int legal_sample_rates [] =
{ 8000, 16000, 22050, 24000, 32000, 44100, 48000, 96000
@@ -172,6 +170,17 @@
const FLAC__int32* const *buffer = pflac->wbuffer ;
unsigned i = 0, j, offset ;
+ /*
+ ** frame->header.blocksize is variable and we're using a constant blocksize
+ ** of FLAC__MAX_BLOCK_SIZE.
+ ** Check our assumptions here.
+ */
+ if (frame->header.blocksize > FLAC__MAX_BLOCK_SIZE)
+ { psf_log_printf (psf, "Ooops : frame->header.blocksize (%d) > FLAC__MAX_BLOCK_SIZE (%d)\n", __func__, __LINE__, frame->header.blocksize, FLAC__MAX_BLOCK_SIZE) ;
+ psf->error = SFE_INTERNAL ;
+ return 0 ;
+ } ;
+
if (pflac->ptr == NULL)
{ /*
** Not sure why this code is here and not elsewhere.
@@ -179,8 +188,10 @@
*/
pflac->bufferbackup = SF_TRUE ;
for (i = 0 ; i < frame->header.channels ; i++)
- { if (pflac->rbuffer [i] == NULL)
- pflac->rbuffer [i] = calloc (frame->header.blocksize, sizeof (FLAC__int32)) ;
+ {
+ if (pflac->rbuffer [i] == NULL)
+ pflac->rbuffer [i] = calloc (FLAC__MAX_BLOCK_SIZE, sizeof (FLAC__int32)) ;
+
memcpy (pflac->rbuffer [i], buffer [i], frame->header.blocksize * sizeof (FLAC__int32)) ;
} ;
pflac->wbuffer = (const FLAC__int32* const*) pflac->rbuffer ;
@@ -190,12 +201,16 @@
switch (pflac->pcmtype)
{ case PFLAC_PCM_SHORT :
- { short *retpcm = ((short*) pflac->ptr) ;
+ { short *retpcm = (short*) pflac->ptr ;
int shift = 16 - frame->header.bits_per_sample ;
if (shift < 0)
{ shift = abs (shift) ;
for (i = 0 ; i < frame->header.blocksize && pflac->remain > 0 ; i++)
{ offset = pflac->pos + i * frame->header.channels ;
+
+ if (pflac->bufferpos >= frame->header.blocksize)
+ break ;
+
for (j = 0 ; j < frame->header.channels ; j++)
retpcm [offset + j] = buffer [j][pflac->bufferpos] >> shift ;
pflac->remain -= frame->header.channels ;
@@ -220,7 +235,7 @@
break ;
case PFLAC_PCM_INT :
- { int *retpcm = ((int*) pflac->ptr) ;
+ { int *retpcm = (int*) pflac->ptr ;
int shift = 32 - frame->header.bits_per_sample ;
for (i = 0 ; i < frame->header.blocksize && pflac->remain > 0 ; i++)
{ offset = pflac->pos + i * frame->header.channels ;
@@ -237,7 +252,7 @@
break ;
case PFLAC_PCM_FLOAT :
- { float *retpcm = ((float*) pflac->ptr) ;
+ { float *retpcm = (float*) pflac->ptr ;
float norm = (psf->norm_float == SF_TRUE) ? 1.0 / (1 << (frame->header.bits_per_sample - 1)) : 1.0 ;
for (i = 0 ; i < frame->header.blocksize && pflac->remain > 0 ; i++)
@@ -255,7 +270,7 @@
break ;
case PFLAC_PCM_DOUBLE :
- { double *retpcm = ((double*) pflac->ptr) ;
+ { double *retpcm = (double*) pflac->ptr ;
double norm = (psf->norm_double == SF_TRUE) ? 1.0 / (1 << (frame->header.bits_per_sample - 1)) : 1.0 ;
for (i = 0 ; i < frame->header.blocksize && pflac->remain > 0 ; i++)
@@ -283,51 +298,51 @@
} /* flac_buffer_copy */
-static FLAC__SeekableStreamDecoderReadStatus
-sf_flac_read_callback (const FLAC__SeekableStreamDecoder * UNUSED (decoder), FLAC__byte buffer [], unsigned *bytes, void *client_data)
+static FLAC__StreamDecoderReadStatus
+sf_flac_read_callback (const FLAC__StreamDecoder * UNUSED (decoder), FLAC__byte buffer [], size_t *bytes, void *client_data)
{ SF_PRIVATE *psf = (SF_PRIVATE*) client_data ;
*bytes = psf_fread (buffer, 1, *bytes, psf) ;
if (*bytes > 0 && psf->error == 0)
- return FLAC__SEEKABLE_STREAM_DECODER_READ_STATUS_OK ;
+ return FLAC__STREAM_DECODER_READ_STATUS_CONTINUE ;
- return FLAC__SEEKABLE_STREAM_DECODER_READ_STATUS_ERROR ;
+ return FLAC__STREAM_DECODER_READ_STATUS_ABORT ;
} /* sf_flac_read_callback */
-static FLAC__SeekableStreamDecoderSeekStatus
-sf_flac_seek_callback (const FLAC__SeekableStreamDecoder * UNUSED (decoder), FLAC__uint64 absolute_byte_offset, void *client_data)
+static FLAC__StreamDecoderSeekStatus
+sf_flac_seek_callback (const FLAC__StreamDecoder * UNUSED (decoder), FLAC__uint64 absolute_byte_offset, void *client_data)
{ SF_PRIVATE *psf = (SF_PRIVATE*) client_data ;
psf_fseek (psf, absolute_byte_offset, SEEK_SET) ;
if (psf->error)
- return FLAC__SEEKABLE_STREAM_DECODER_SEEK_STATUS_ERROR ;
+ return FLAC__STREAM_DECODER_SEEK_STATUS_ERROR ;
- return FLAC__SEEKABLE_STREAM_DECODER_SEEK_STATUS_OK ;
+ return FLAC__STREAM_DECODER_SEEK_STATUS_OK ;
} /* sf_flac_seek_callback */
-static FLAC__SeekableStreamDecoderTellStatus
-sf_flac_tell_callback (const FLAC__SeekableStreamDecoder * UNUSED (decoder), FLAC__uint64 *absolute_byte_offset, void *client_data)
+static FLAC__StreamDecoderTellStatus
+sf_flac_tell_callback (const FLAC__StreamDecoder * UNUSED (decoder), FLAC__uint64 *absolute_byte_offset, void *client_data)
{ SF_PRIVATE *psf = (SF_PRIVATE*) client_data ;
*absolute_byte_offset = psf_ftell (psf) ;
if (psf->error)
- return FLAC__SEEKABLE_STREAM_DECODER_TELL_STATUS_ERROR ;
+ return FLAC__STREAM_DECODER_TELL_STATUS_ERROR ;
- return FLAC__SEEKABLE_STREAM_DECODER_TELL_STATUS_OK ;
+ return FLAC__STREAM_DECODER_TELL_STATUS_OK ;
} /* sf_flac_tell_callback */
-static FLAC__SeekableStreamDecoderLengthStatus
-sf_flac_length_callback (const FLAC__SeekableStreamDecoder * UNUSED (decoder), FLAC__uint64 *stream_length, void *client_data)
+static FLAC__StreamDecoderLengthStatus
+sf_flac_length_callback (const FLAC__StreamDecoder * UNUSED (decoder), FLAC__uint64 *stream_length, void *client_data)
{ SF_PRIVATE *psf = (SF_PRIVATE*) client_data ;
if ((*stream_length = psf->filelength) == 0)
- return FLAC__SEEKABLE_STREAM_DECODER_LENGTH_STATUS_ERROR ;
+ return FLAC__STREAM_DECODER_LENGTH_STATUS_ERROR ;
- return FLAC__SEEKABLE_STREAM_DECODER_LENGTH_STATUS_OK ;
+ return FLAC__STREAM_DECODER_LENGTH_STATUS_OK ;
} /* sf_flac_length_callback */
static FLAC__bool
-sf_flac_eof_callback (const FLAC__SeekableStreamDecoder *UNUSED (decoder), void *client_data)
+sf_flac_eof_callback (const FLAC__StreamDecoder *UNUSED (decoder), void *client_data)
{ SF_PRIVATE *psf = (SF_PRIVATE*) client_data ;
if (psf_ftell (psf) == psf->filelength)
@@ -337,7 +352,7 @@
} /* sf_flac_eof_callback */
static FLAC__StreamDecoderWriteStatus
-sf_flac_write_callback (const FLAC__SeekableStreamDecoder * UNUSED (decoder), const FLAC__Frame *frame, const FLAC__int32 * const buffer [], void *client_data)
+sf_flac_write_callback (const FLAC__StreamDecoder * UNUSED (decoder), const FLAC__Frame *frame, const FLAC__int32 * const buffer [], void *client_data)
{ SF_PRIVATE *psf = (SF_PRIVATE*) client_data ;
FLAC_PRIVATE* pflac = (FLAC_PRIVATE*) psf->codec_data ;
@@ -353,8 +368,42 @@
} /* sf_flac_write_callback */
static void
-sf_flac_meta_callback (const FLAC__SeekableStreamDecoder * UNUSED (decoder), const FLAC__StreamMetadata *metadata, void *client_data)
+sf_flac_meta_get_vorbiscomments (SF_PRIVATE *psf, const FLAC__StreamMetadata *metadata)
+{ FLAC_TAG tags [] =
+ { { "title", SF_STR_TITLE },
+ { "copyright", SF_STR_COPYRIGHT },
+ { "software", SF_STR_SOFTWARE },
+ { "artist", SF_STR_ARTIST },
+ { "comment", SF_STR_COMMENT },
+ { "date", SF_STR_DATE },
+ { "album", SF_STR_ALBUM },
+ { "license", SF_STR_LICENSE }
+ } ;
+
+ const char *value, *cptr ;
+ int k, tag_num ;
+
+ for (k = 0 ; k < ARRAY_LEN (tags) ; k++)
+ { tag_num = FLAC__metadata_object_vorbiscomment_find_entry_from (metadata, 0, tags [k].tag) ;
+
+ if (tag_num < 0)
+ continue ;
+
+ value = (const char*) metadata->data.vorbis_comment.comments [tag_num].entry ;
+ if ((cptr = strchr (value, '=')) != NULL)
+ value = cptr + 1 ;
+
+ psf_log_printf (psf, " %-10s : %s\n", tags [k].tag, value) ;
+ psf_store_string (psf, tags [k].type, value) ;
+ } ;
+
+ return ;
+} /* sf_flac_meta_get_vorbiscomments */
+
+static void
+sf_flac_meta_callback (const FLAC__StreamDecoder * UNUSED (decoder), const FLAC__StreamMetadata *metadata, void *client_data)
{ SF_PRIVATE *psf = (SF_PRIVATE*) client_data ;
+ int bitwidth = 0 ;
switch (metadata->type)
{ case FLAC__METADATA_TYPE_STREAMINFO :
@@ -362,32 +411,69 @@
psf->sf.samplerate = metadata->data.stream_info.sample_rate ;
psf->sf.frames = metadata->data.stream_info.total_samples ;
+ psf_log_printf (psf, "FLAC Stream Metadata\n Channels : %d\n Sample rate : %d\n Frames : %D\n", psf->sf.channels, psf->sf.samplerate, psf->sf.frames) ;
+
switch (metadata->data.stream_info.bits_per_sample)
{ case 8 :
psf->sf.format |= SF_FORMAT_PCM_S8 ;
+ bitwidth = 8 ;
break ;
case 16 :
psf->sf.format |= SF_FORMAT_PCM_16 ;
+ bitwidth = 16 ;
break ;
case 24 :
psf->sf.format |= SF_FORMAT_PCM_24 ;
+ bitwidth = 24 ;
break ;
default :
psf_log_printf (psf, "sf_flac_meta_callback : bits_per_sample %d not yet implemented.\n", metadata->data.stream_info.bits_per_sample) ;
break ;
} ;
+
+ if (bitwidth > 0)
+ psf_log_printf (psf, " Bit width : %d\n", bitwidth) ;
+ break ;
+
+ case FLAC__METADATA_TYPE_VORBIS_COMMENT :
+ psf_log_printf (psf, "Vorbis Comment Metadata\n") ;
+ sf_flac_meta_get_vorbiscomments (psf, metadata) ;
+ break ;
+
+ case FLAC__METADATA_TYPE_PADDING :
+ psf_log_printf (psf, "Padding Metadata\n") ;
+ break ;
+
+ case FLAC__METADATA_TYPE_APPLICATION :
+ psf_log_printf (psf, "Application Metadata\n") ;
+ break ;
+
+ case FLAC__METADATA_TYPE_SEEKTABLE :
+ psf_log_printf (psf, "Seektable Metadata\n") ;
+ break ;
+
+ case FLAC__METADATA_TYPE_CUESHEET :
+ psf_log_printf (psf, "Cuesheet Metadata\n") ;
+ break ;
+
+ case FLAC__METADATA_TYPE_PICTURE :
+ psf_log_printf (psf, "Picture Metadata\n") ;
+ break ;
+
+ case FLAC__METADATA_TYPE_UNDEFINED :
+ psf_log_printf (psf, "Undefined Metadata\n") ;
break ;
default :
psf_log_printf (psf, "sf_flac_meta_callback : metadata-type %d not yet implemented.\n", metadata->type) ;
- break ;
+ break ;
} ;
return ;
} /* sf_flac_meta_callback */
static void
-sf_flac_error_callback (const FLAC__SeekableStreamDecoder * UNUSED (decoder), FLAC__StreamDecoderErrorStatus status, void *client_data)
+sf_flac_error_callback (const FLAC__StreamDecoder * UNUSED (decoder), FLAC__StreamDecoderErrorStatus status, void *client_data)
{ SF_PRIVATE *psf = (SF_PRIVATE*) client_data ;
psf_log_printf (psf, "ERROR : %s\n", FLAC__StreamDecoderErrorStatusString [status]) ;
@@ -407,40 +493,121 @@
return ;
} /* sf_flac_error_callback */
-static FLAC__SeekableStreamEncoderSeekStatus
-sf_flac_enc_seek_callback (const FLAC__SeekableStreamEncoder * UNUSED (encoder), FLAC__uint64 absolute_byte_offset, void *client_data)
+static FLAC__StreamEncoderSeekStatus
+sf_flac_enc_seek_callback (const FLAC__StreamEncoder * UNUSED (encoder), FLAC__uint64 absolute_byte_offset, void *client_data)
{ SF_PRIVATE *psf = (SF_PRIVATE*) client_data ;
psf_fseek (psf, absolute_byte_offset, SEEK_SET) ;
if (psf->error)
- return FLAC__SEEKABLE_STREAM_ENCODER_SEEK_STATUS_ERROR ;
+ return FLAC__STREAM_ENCODER_SEEK_STATUS_ERROR ;
- return FLAC__SEEKABLE_STREAM_ENCODER_SEEK_STATUS_OK ;
+ return FLAC__STREAM_ENCODER_SEEK_STATUS_OK ;
} /* sf_flac_enc_seek_callback */
-#ifdef HAVE_FLAC_1_1_1
-static FLAC__SeekableStreamEncoderTellStatus
-sf_flac_enc_tell_callback (const FLAC__SeekableStreamEncoder *UNUSED (encoder), FLAC__uint64 *absolute_byte_offset, void *client_data)
+static FLAC__StreamEncoderTellStatus
+sf_flac_enc_tell_callback (const FLAC__StreamEncoder *UNUSED (encoder), FLAC__uint64 *absolute_byte_offset, void *client_data)
{ SF_PRIVATE *psf = (SF_PRIVATE*) client_data ;
*absolute_byte_offset = psf_ftell (psf) ;
if (psf->error)
- return FLAC__SEEKABLE_STREAM_ENCODER_TELL_STATUS_ERROR ;
+ return FLAC__STREAM_ENCODER_TELL_STATUS_ERROR ;
- return FLAC__SEEKABLE_STREAM_ENCODER_TELL_STATUS_OK ;
+ return FLAC__STREAM_ENCODER_TELL_STATUS_OK ;
} /* sf_flac_enc_tell_callback */
-#endif
static FLAC__StreamEncoderWriteStatus
-sf_flac_enc_write_callback (const FLAC__SeekableStreamEncoder * UNUSED (encoder), const FLAC__byte buffer [], unsigned bytes, unsigned UNUSED (samples), unsigned UNUSED (current_frame), void *client_data)
+sf_flac_enc_write_callback (const FLAC__StreamEncoder * UNUSED (encoder), const FLAC__byte buffer [], size_t bytes, unsigned UNUSED (samples), unsigned UNUSED (current_frame), void *client_data)
{ SF_PRIVATE *psf = (SF_PRIVATE*) client_data ;
- if (psf_fwrite (buffer, 1, bytes, psf) == bytes && psf->error == 0)
+ if (psf_fwrite (buffer, 1, bytes, psf) == (sf_count_t) bytes && psf->error == 0)
return FLAC__STREAM_ENCODER_WRITE_STATUS_OK ;
return FLAC__STREAM_ENCODER_WRITE_STATUS_FATAL_ERROR ;
} /* sf_flac_enc_write_callback */
+static void
+flac_write_strings (SF_PRIVATE *psf, FLAC_PRIVATE* pflac)
+{ FLAC__StreamMetadata_VorbisComment_Entry entry ;
+ int k, string_count = 0 ;
+
+ for (k = 0 ; k < SF_MAX_STRINGS ; k++)
+ { if (psf->strings [k].type != 0)
+ string_count ++ ;
+ } ;
+
+ if (string_count == 0)
+ return ;
+
+ if (pflac->metadata == NULL && (pflac->metadata = FLAC__metadata_object_new (FLAC__METADATA_TYPE_VORBIS_COMMENT)) == NULL)
+ { psf_log_printf (psf, "FLAC__metadata_object_new returned NULL\n") ;
+ return ;
+ } ;
+
+ for (k = 0 ; k < SF_MAX_STRINGS && psf->strings [k].type != 0 ; k++)
+ { const char * key, * value ;
+
+ switch (psf->strings [k].type)
+ { case SF_STR_SOFTWARE :
+ key = "software" ;
+ break ;
+ case SF_STR_TITLE :
+ key = "title" ;
+ break ;
+ case SF_STR_COPYRIGHT :
+ key = "copyright" ;
+ break ;
+ case SF_STR_ARTIST :
+ key = "artist" ;
+ break ;
+ case SF_STR_COMMENT :
+ key = "comment" ;
+ break ;
+ case SF_STR_DATE :
+ key = "date" ;
+ break ;
+ case SF_STR_ALBUM :
+ key = "album" ;
+ break ;
+ case SF_STR_LICENSE :
+ key = "license" ;
+ break ;
+ default :
+ continue ;
+ } ;
+
+ value = psf->strings [k].str ;
+
+ FLAC__metadata_object_vorbiscomment_entry_from_name_value_pair (&entry, key, value) ;
+ FLAC__metadata_object_vorbiscomment_append_comment (pflac->metadata, entry, /* copy */ SF_FALSE) ;
+ } ;
+
+ if (! FLAC__stream_encoder_set_metadata (pflac->fse, &pflac->metadata, 1))
+ { printf ("%s %d : fail\n", __func__, __LINE__) ;
+ return ;
+ } ;
+
+ return ;
+} /* flac_write_strings */
+
+static int
+flac_write_header (SF_PRIVATE *psf, int UNUSED (calc_length))
+{ FLAC_PRIVATE* pflac = (FLAC_PRIVATE*) psf->codec_data ;
+ int err ;
+
+ flac_write_strings (psf, pflac) ;
+
+ if ((err = FLAC__stream_encoder_init_stream (pflac->fse, sf_flac_enc_write_callback, sf_flac_enc_seek_callback, sf_flac_enc_tell_callback, NULL, psf)) != FLAC__STREAM_DECODER_INIT_STATUS_OK)
+ { psf_log_printf (psf, "Error : FLAC encoder init returned error : %s\n", FLAC__StreamEncoderInitStatusString [err]) ;
+ return SFE_FLAC_INIT_DECODER ;
+ } ;
+
+ if (psf->error == 0)
+ psf->dataoffset = psf_ftell (psf) ;
+ pflac->encbuffer = calloc (ENC_BUFFER_SIZE, sizeof (FLAC__int32)) ;
+
+ return psf->error ;
+} /* flac_write_header */
+
/*------------------------------------------------------------------------------
** Public function.
*/
@@ -454,23 +621,28 @@
psf->codec_data = pflac ;
if (psf->mode == SFM_RDWR)
- return SFE_UNIMPLEMENTED ;
+ return SFE_BAD_MODE_RW ;
if (psf->mode == SFM_READ)
{ if ((error = flac_read_header (psf)))
return error ;
} ;
- subformat = psf->sf.format & SF_FORMAT_SUBMASK ;
+ subformat = SF_CODEC (psf->sf.format) ;
if (psf->mode == SFM_WRITE)
- { if ((psf->sf.format & SF_FORMAT_TYPEMASK) != SF_FORMAT_FLAC)
+ { if ((SF_CONTAINER (psf->sf.format)) != SF_FORMAT_FLAC)
return SFE_BAD_OPEN_FORMAT ;
psf->endian = SF_ENDIAN_BIG ;
+ psf->sf.seekable = 0 ;
+
+ psf->str_flags = SF_STR_ALLOW_START ;
if ((error = flac_enc_init (psf)))
return error ;
+
+ psf->write_header = flac_write_header ;
} ;
psf->datalength = psf->filelength ;
@@ -485,7 +657,7 @@
psf->blockwidth = psf->bytewidth * psf->sf.channels ;
switch (subformat)
- { case SF_FORMAT_PCM_S8 : /* 8-bit FLAC. */
+ { case SF_FORMAT_PCM_S8 : /* 8-bit FLAC. */
case SF_FORMAT_PCM_16 : /* 16-bit FLAC. */
case SF_FORMAT_PCM_24 : /* 24-bit FLAC. */
error = flac_init (psf) ;
@@ -508,16 +680,20 @@
if ((pflac = (FLAC_PRIVATE*) psf->codec_data) == NULL)
return 0 ;
+ if (pflac->metadata != NULL)
+ FLAC__metadata_object_delete (pflac->metadata) ;
+
if (psf->mode == SFM_WRITE)
- { FLAC__seekable_stream_encoder_finish (pflac->fse) ;
- FLAC__seekable_stream_encoder_delete (pflac->fse) ;
+ { FLAC__stream_encoder_finish (pflac->fse) ;
+ FLAC__stream_encoder_delete (pflac->fse) ;
+
if (pflac->encbuffer)
free (pflac->encbuffer) ;
} ;
if (psf->mode == SFM_READ)
- { FLAC__seekable_stream_decoder_finish (pflac->fsd) ;
- FLAC__seekable_stream_decoder_delete (pflac->fsd) ;
+ { FLAC__stream_decoder_finish (pflac->fsd) ;
+ FLAC__stream_decoder_delete (pflac->fsd) ;
} ;
for (k = 0 ; k < ARRAY_LEN (pflac->rbuffer) ; k++)
@@ -546,19 +722,8 @@
return SFE_FLAC_BAD_SAMPLE_RATE ;
psf_fseek (psf, 0, SEEK_SET) ;
- if ((pflac->fse = FLAC__seekable_stream_encoder_new ()) == NULL)
- return SFE_FLAC_NEW_DECODER ;
- FLAC__seekable_stream_encoder_set_write_callback (pflac->fse, sf_flac_enc_write_callback) ;
- FLAC__seekable_stream_encoder_set_seek_callback (pflac->fse, sf_flac_enc_seek_callback) ;
-
-#ifdef HAVE_FLAC_1_1_1
- FLAC__seekable_stream_encoder_set_tell_callback (pflac->fse, sf_flac_enc_tell_callback) ;
-#endif
- FLAC__seekable_stream_encoder_set_client_data (pflac->fse, psf) ;
- FLAC__seekable_stream_encoder_set_channels (pflac->fse, psf->sf.channels) ;
- FLAC__seekable_stream_encoder_set_sample_rate (pflac->fse, psf->sf.samplerate) ;
- switch (psf->sf.format & SF_FORMAT_SUBMASK)
+ switch (SF_CODEC (psf->sf.format))
{ case SF_FORMAT_PCM_S8 :
bps = 8 ;
break ;
@@ -574,18 +739,25 @@
break ;
} ;
- FLAC__seekable_stream_encoder_set_bits_per_sample (pflac->fse, bps) ;
+ if ((pflac->fse = FLAC__stream_encoder_new ()) == NULL)
+ return SFE_FLAC_NEW_DECODER ;
- if ((bps = FLAC__seekable_stream_encoder_init (pflac->fse)) != FLAC__SEEKABLE_STREAM_DECODER_OK)
- { psf_log_printf (psf, "Error : FLAC encoder init returned error : %s\n", FLAC__seekable_stream_encoder_get_resolved_state_string (pflac->fse)) ;
+ if (! FLAC__stream_encoder_set_channels (pflac->fse, psf->sf.channels))
+ { psf_log_printf (psf, "FLAC__stream_encoder_set_channels (%d) return false.\n", psf->sf.channels) ;
return SFE_FLAC_INIT_DECODER ;
} ;
- if (psf->error == 0)
- psf->dataoffset = psf_ftell (psf) ;
- pflac->encbuffer = calloc (ENC_BUFFER_SIZE, sizeof (FLAC__int32)) ;
+ if (! FLAC__stream_encoder_set_sample_rate (pflac->fse, psf->sf.samplerate))
+ { psf_log_printf (psf, "FLAC__stream_encoder_set_sample_rate (%d) returned false.\n", psf->sf.samplerate) ;
+ return SFE_FLAC_BAD_SAMPLE_RATE ;
+ } ;
- return psf->error ;
+ if (! FLAC__stream_encoder_set_bits_per_sample (pflac->fse, bps))
+ { psf_log_printf (psf, "FLAC__stream_encoder_set_bits_per_sample (%d) return false.\n", bps) ;
+ return SFE_FLAC_INIT_DECODER ;
+ } ;
+
+ return 0 ;
} /* flac_enc_init */
static int
@@ -593,26 +765,22 @@
{ FLAC_PRIVATE* pflac = (FLAC_PRIVATE*) psf->codec_data ;
psf_fseek (psf, 0, SEEK_SET) ;
- if ((pflac->fsd = FLAC__seekable_stream_decoder_new ()) == NULL)
+ if ((pflac->fsd = FLAC__stream_decoder_new ()) == NULL)
return SFE_FLAC_NEW_DECODER ;
- FLAC__seekable_stream_decoder_set_read_callback (pflac->fsd, sf_flac_read_callback) ;
- FLAC__seekable_stream_decoder_set_seek_callback (pflac->fsd, sf_flac_seek_callback) ;
- FLAC__seekable_stream_decoder_set_tell_callback (pflac->fsd, sf_flac_tell_callback) ;
- FLAC__seekable_stream_decoder_set_length_callback (pflac->fsd, sf_flac_length_callback) ;
- FLAC__seekable_stream_decoder_set_eof_callback (pflac->fsd, sf_flac_eof_callback) ;
- FLAC__seekable_stream_decoder_set_write_callback (pflac->fsd, sf_flac_write_callback) ;
- FLAC__seekable_stream_decoder_set_metadata_callback (pflac->fsd, sf_flac_meta_callback) ;
- FLAC__seekable_stream_decoder_set_error_callback (pflac->fsd, sf_flac_error_callback) ;
- FLAC__seekable_stream_decoder_set_client_data (pflac->fsd, psf) ;
+ FLAC__stream_decoder_set_metadata_respond_all (pflac->fsd) ;
- if (FLAC__seekable_stream_decoder_init (pflac->fsd) != FLAC__SEEKABLE_STREAM_DECODER_OK)
+ if (FLAC__stream_decoder_init_stream (pflac->fsd, sf_flac_read_callback, sf_flac_seek_callback, sf_flac_tell_callback, sf_flac_length_callback, sf_flac_eof_callback, sf_flac_write_callback, sf_flac_meta_callback, sf_flac_error_callback, psf) != FLAC__STREAM_DECODER_INIT_STATUS_OK)
return SFE_FLAC_INIT_DECODER ;
- FLAC__seekable_stream_decoder_process_until_end_of_metadata (pflac->fsd) ;
+ FLAC__stream_decoder_process_until_end_of_metadata (pflac->fsd) ;
+
+ psf_log_printf (psf, "End\n") ;
+
if (psf->error == 0)
{ FLAC__uint64 position ;
- FLAC__seekable_stream_decoder_get_decode_position (pflac->fsd, &position) ;
+
+ FLAC__stream_decoder_get_decode_position (pflac->fsd, &position) ;
psf->dataoffset = position ;
} ;
@@ -620,17 +788,8 @@
} /* flac_read_header */
static int
-flac_command (SF_PRIVATE *psf, int command, void *data, int datasize)
+flac_command (SF_PRIVATE * UNUSED (psf), int UNUSED (command), void * UNUSED (data), int UNUSED (datasize))
{
- /* Avoid compiler warnings. */
- psf = psf ;
- data = data ;
- datasize = datasize ;
-
- switch (command)
- { default : break ;
- } ;
-
return 0 ;
} /* flac_command */
@@ -676,9 +835,9 @@
flac_buffer_copy (psf) ;
while (pflac->pos < pflac->len)
- { if (FLAC__seekable_stream_decoder_process_single (pflac->fsd) == 0)
+ { if (FLAC__stream_decoder_process_single (pflac->fsd) == 0)
break ;
- if (FLAC__seekable_stream_decoder_get_state (pflac->fsd) != FLAC__SEEKABLE_STREAM_DECODER_OK)
+ if (FLAC__stream_decoder_get_state (pflac->fsd) >= FLAC__STREAM_DECODER_END_OF_STREAM)
break ;
} ;
@@ -775,7 +934,7 @@
sf_count_t total = 0 ;
FLAC__int32* buffer = pflac->encbuffer ;
- switch (psf->sf.format & SF_FORMAT_SUBMASK)
+ switch (SF_CODEC (psf->sf.format))
{ case SF_FORMAT_PCM_S8 :
convert = s2flac8_array ;
break ;
@@ -795,7 +954,7 @@
while (len > 0)
{ writecount = (len >= bufferlen) ? bufferlen : (int) len ;
convert (ptr + total, buffer, writecount) ;
- if (FLAC__seekable_stream_encoder_process_interleaved (pflac->fse, buffer, writecount/psf->sf.channels))
+ if (FLAC__stream_encoder_process_interleaved (pflac->fse, buffer, writecount/psf->sf.channels))
thiswrite = writecount ;
else
break ;
@@ -817,7 +976,7 @@
sf_count_t total = 0 ;
FLAC__int32* buffer = pflac->encbuffer ;
- switch (psf->sf.format & SF_FORMAT_SUBMASK)
+ switch (SF_CODEC (psf->sf.format))
{ case SF_FORMAT_PCM_S8 :
convert = i2flac8_array ;
break ;
@@ -837,7 +996,7 @@
while (len > 0)
{ writecount = (len >= bufferlen) ? bufferlen : (int) len ;
convert (ptr + total, buffer, writecount) ;
- if (FLAC__seekable_stream_encoder_process_interleaved (pflac->fse, buffer, writecount/psf->sf.channels))
+ if (FLAC__stream_encoder_process_interleaved (pflac->fse, buffer, writecount/psf->sf.channels))
thiswrite = writecount ;
else
break ;
@@ -859,7 +1018,7 @@
sf_count_t total = 0 ;
FLAC__int32* buffer = pflac->encbuffer ;
- switch (psf->sf.format & SF_FORMAT_SUBMASK)
+ switch (SF_CODEC (psf->sf.format))
{ case SF_FORMAT_PCM_S8 :
convert = (psf->add_clipping) ? f2flac8_clip_array : f2flac8_array ;
break ;
@@ -879,7 +1038,7 @@
while (len > 0)
{ writecount = (len >= bufferlen) ? bufferlen : (int) len ;
convert (ptr + total, buffer, writecount, psf->norm_float) ;
- if (FLAC__seekable_stream_encoder_process_interleaved (pflac->fse, buffer, writecount/psf->sf.channels))
+ if (FLAC__stream_encoder_process_interleaved (pflac->fse, buffer, writecount/psf->sf.channels))
thiswrite = writecount ;
else
break ;
@@ -991,7 +1150,7 @@
sf_count_t total = 0 ;
FLAC__int32* buffer = pflac->encbuffer ;
- switch (psf->sf.format & SF_FORMAT_SUBMASK)
+ switch (SF_CODEC (psf->sf.format))
{ case SF_FORMAT_PCM_S8 :
convert = (psf->add_clipping) ? d2flac8_clip_array : d2flac8_array ;
break ;
@@ -1011,7 +1170,7 @@
while (len > 0)
{ writecount = (len >= bufferlen) ? bufferlen : (int) len ;
convert (ptr + total, buffer, writecount, psf->norm_double) ;
- if (FLAC__seekable_stream_encoder_process_interleaved (pflac->fse, buffer, writecount/psf->sf.channels))
+ if (FLAC__stream_encoder_process_interleaved (pflac->fse, buffer, writecount/psf->sf.channels))
thiswrite = writecount ;
else
break ;
@@ -1131,8 +1290,8 @@
if (psf->mode == SFM_READ)
{ FLAC__uint64 position ;
- if (FLAC__seekable_stream_decoder_seek_absolute (pflac->fsd, offset))
- { FLAC__seekable_stream_decoder_get_decode_position (pflac->fsd, &position) ;
+ if (FLAC__stream_decoder_seek_absolute (pflac->fsd, offset))
+ { FLAC__stream_decoder_get_decode_position (pflac->fsd, &position) ;
return offset ;
} ;
@@ -1145,12 +1304,13 @@
return ((sf_count_t) -1) ;
} /* flac_seek */
-#endif
+#else /* HAVE_EXTERNAL_LIBS */
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: 46d49617-ebff-42b4-8f66-a0e428147360
-*/
+int
+flac_open (SF_PRIVATE *psf)
+{
+ psf_log_printf (psf, "This version of libsndfile was compiled without FLAC support.\n") ;
+ return SFE_UNIMPLEMENTED ;
+} /* flac_open */
+
+#endif
Modified: freeswitch/trunk/libs/libsndfile/src/float32.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/src/float32.c (original)
+++ freeswitch/trunk/libs/libsndfile/src/float32.c Thu May 21 16:09:30 2009
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 1999-2005 Erik de Castro Lopo <erikd at mega-nerd.com>
+** Copyright (C) 1999-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU Lesser General Public License as published by
@@ -21,11 +21,12 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <limits.h>
+#include <math.h>
#include "sndfile.h"
#include "sfendian.h"
#include "common.h"
-#include "float_cast.h"
#if CPU_IS_LITTLE_ENDIAN
#define FLOAT32_READ float32_le_read
@@ -94,7 +95,7 @@
if (psf->mode == SFM_READ || psf->mode == SFM_RDWR)
{ switch (psf->endian + float_caps)
{ case (SF_ENDIAN_BIG + FLOAT_CAN_RW_BE) :
- psf->float_endswap = SF_FALSE ;
+ psf->data_endswap = SF_FALSE ;
psf->read_short = host_read_f2s ;
psf->read_int = host_read_f2i ;
psf->read_float = host_read_f ;
@@ -102,7 +103,7 @@
break ;
case (SF_ENDIAN_LITTLE + FLOAT_CAN_RW_LE) :
- psf->float_endswap = SF_FALSE ;
+ psf->data_endswap = SF_FALSE ;
psf->read_short = host_read_f2s ;
psf->read_int = host_read_f2i ;
psf->read_float = host_read_f ;
@@ -110,7 +111,7 @@
break ;
case (SF_ENDIAN_BIG + FLOAT_CAN_RW_LE) :
- psf->float_endswap = SF_TRUE ;
+ psf->data_endswap = SF_TRUE ;
psf->read_short = host_read_f2s ;
psf->read_int = host_read_f2i ;
psf->read_float = host_read_f ;
@@ -118,7 +119,7 @@
break ;
case (SF_ENDIAN_LITTLE + FLOAT_CAN_RW_BE) :
- psf->float_endswap = SF_TRUE ;
+ psf->data_endswap = SF_TRUE ;
psf->read_short = host_read_f2s ;
psf->read_int = host_read_f2i ;
psf->read_float = host_read_f ;
@@ -127,7 +128,7 @@
/* When the CPU is not IEEE compatible. */
case (SF_ENDIAN_BIG + FLOAT_BROKEN_LE) :
- psf->float_endswap = SF_TRUE ;
+ psf->data_endswap = SF_TRUE ;
psf->read_short = replace_read_f2s ;
psf->read_int = replace_read_f2i ;
psf->read_float = replace_read_f ;
@@ -135,7 +136,7 @@
break ;
case (SF_ENDIAN_LITTLE + FLOAT_BROKEN_LE) :
- psf->float_endswap = SF_FALSE ;
+ psf->data_endswap = SF_FALSE ;
psf->read_short = replace_read_f2s ;
psf->read_int = replace_read_f2i ;
psf->read_float = replace_read_f ;
@@ -143,7 +144,7 @@
break ;
case (SF_ENDIAN_BIG + FLOAT_BROKEN_BE) :
- psf->float_endswap = SF_FALSE ;
+ psf->data_endswap = SF_FALSE ;
psf->read_short = replace_read_f2s ;
psf->read_int = replace_read_f2i ;
psf->read_float = replace_read_f ;
@@ -151,7 +152,7 @@
break ;
case (SF_ENDIAN_LITTLE + FLOAT_BROKEN_BE) :
- psf->float_endswap = SF_TRUE ;
+ psf->data_endswap = SF_TRUE ;
psf->read_short = replace_read_f2s ;
psf->read_int = replace_read_f2i ;
psf->read_float = replace_read_f ;
@@ -165,7 +166,7 @@
if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR)
{ switch (psf->endian + float_caps)
{ case (SF_ENDIAN_LITTLE + FLOAT_CAN_RW_LE) :
- psf->float_endswap = SF_FALSE ;
+ psf->data_endswap = SF_FALSE ;
psf->write_short = host_write_s2f ;
psf->write_int = host_write_i2f ;
psf->write_float = host_write_f ;
@@ -173,7 +174,7 @@
break ;
case (SF_ENDIAN_BIG + FLOAT_CAN_RW_BE) :
- psf->float_endswap = SF_FALSE ;
+ psf->data_endswap = SF_FALSE ;
psf->write_short = host_write_s2f ;
psf->write_int = host_write_i2f ;
psf->write_float = host_write_f ;
@@ -181,7 +182,7 @@
break ;
case (SF_ENDIAN_BIG + FLOAT_CAN_RW_LE) :
- psf->float_endswap = SF_TRUE ;
+ psf->data_endswap = SF_TRUE ;
psf->write_short = host_write_s2f ;
psf->write_int = host_write_i2f ;
psf->write_float = host_write_f ;
@@ -189,7 +190,7 @@
break ;
case (SF_ENDIAN_LITTLE + FLOAT_CAN_RW_BE) :
- psf->float_endswap = SF_TRUE ;
+ psf->data_endswap = SF_TRUE ;
psf->write_short = host_write_s2f ;
psf->write_int = host_write_i2f ;
psf->write_float = host_write_f ;
@@ -198,7 +199,7 @@
/* When the CPU is not IEEE compatible. */
case (SF_ENDIAN_BIG + FLOAT_BROKEN_LE) :
- psf->float_endswap = SF_TRUE ;
+ psf->data_endswap = SF_TRUE ;
psf->write_short = replace_write_s2f ;
psf->write_int = replace_write_i2f ;
psf->write_float = replace_write_f ;
@@ -206,7 +207,7 @@
break ;
case (SF_ENDIAN_LITTLE + FLOAT_BROKEN_LE) :
- psf->float_endswap = SF_FALSE ;
+ psf->data_endswap = SF_FALSE ;
psf->write_short = replace_write_s2f ;
psf->write_int = replace_write_i2f ;
psf->write_float = replace_write_f ;
@@ -214,7 +215,7 @@
break ;
case (SF_ENDIAN_BIG + FLOAT_BROKEN_BE) :
- psf->float_endswap = SF_FALSE ;
+ psf->data_endswap = SF_FALSE ;
psf->write_short = replace_write_s2f ;
psf->write_int = replace_write_i2f ;
psf->write_float = replace_write_f ;
@@ -222,7 +223,7 @@
break ;
case (SF_ENDIAN_LITTLE + FLOAT_BROKEN_BE) :
- psf->float_endswap = SF_TRUE ;
+ psf->data_endswap = SF_TRUE ;
psf->write_short = replace_write_s2f ;
psf->write_int = replace_write_i2f ;
psf->write_float = replace_write_f ;
@@ -266,9 +267,9 @@
fvalue *= -1 ;
if (exponent > 0)
- fvalue *= (1 << exponent) ;
+ fvalue *= pow (2.0, exponent) ;
else if (exponent < 0)
- fvalue /= (1 << abs (exponent)) ;
+ fvalue /= pow (2.0, abs (exponent)) ;
return fvalue ;
} /* float32_be_read */
@@ -294,9 +295,9 @@
fvalue *= -1 ;
if (exponent > 0)
- fvalue *= (1 << exponent) ;
+ fvalue *= pow (2.0, exponent) ;
else if (exponent < 0)
- fvalue /= (1 << abs (exponent)) ;
+ fvalue /= pow (2.0, abs (exponent)) ;
return fvalue ;
} /* float32_le_read */
@@ -428,13 +429,28 @@
/*=======================================================================================
*/
-static inline void
+static void
f2s_array (const float *src, int count, short *dest, float scale)
-{ while (--count >= 0)
+{
+ while (--count >= 0)
{ dest [count] = lrintf (scale * src [count]) ;
} ;
} /* f2s_array */
+static void
+f2s_clip_array (const float *src, int count, short *dest, float scale)
+{ while (--count >= 0)
+ { float tmp = scale * src [count] ;
+
+ if (CPU_CLIPS_POSITIVE == 0 && tmp > 32767.0)
+ dest [count] = SHRT_MAX ;
+ else if (CPU_CLIPS_NEGATIVE == 0 && tmp < 32768.0)
+ dest [count] = SHRT_MIN ;
+ else
+ dest [count] = lrintf (tmp) ;
+ } ;
+} /* f2s_clip_array */
+
static inline void
f2i_array (const float *src, int count, int *dest, float scale)
{ while (--count >= 0)
@@ -443,6 +459,20 @@
} /* f2i_array */
static inline void
+f2i_clip_array (const float *src, int count, int *dest, float scale)
+{ while (--count >= 0)
+ { float tmp = scale * src [count] ;
+
+ if (CPU_CLIPS_POSITIVE == 0 && tmp > (1.0 * INT_MAX))
+ dest [count] = INT_MAX ;
+ else if (CPU_CLIPS_NEGATIVE == 0 && tmp < (-1.0 * INT_MAX))
+ dest [count] = INT_MIN ;
+ else
+ dest [count] = lrintf (tmp) ;
+ } ;
+} /* f2i_clip_array */
+
+static inline void
f2d_array (const float *src, int count, double *dest)
{ while (--count >= 0)
{ dest [count] = src [count] ;
@@ -450,17 +480,16 @@
} /* f2d_array */
static inline void
-s2f_array (const short *src, float *dest, int count)
+s2f_array (const short *src, float *dest, int count, float scale)
{ while (--count >= 0)
- { dest [count] = src [count] ;
+ { dest [count] = scale * src [count] ;
} ;
-
} /* s2f_array */
static inline void
-i2f_array (const int *src, float *dest, int count)
+i2f_array (const int *src, float *dest, int count, float scale)
{ while (--count >= 0)
- { dest [count] = src [count] ;
+ { dest [count] = scale * src [count] ;
} ;
} /* i2f_array */
@@ -476,10 +505,12 @@
static sf_count_t
host_read_f2s (SF_PRIVATE *psf, short *ptr, sf_count_t len)
-{ int bufferlen, readcount ;
+{ void (*convert) (const float *, int, short *, float) ;
+ int bufferlen, readcount ;
sf_count_t total = 0 ;
float scale ;
+ convert = (psf->add_clipping) ? f2s_clip_array : f2s_array ;
bufferlen = ARRAY_LEN (psf->u.fbuf) ;
scale = (psf->float_int_mult == 0) ? 1.0 : 0x7FFF / psf->float_max ;
@@ -489,7 +520,7 @@
readcount = psf_fread (psf->u.fbuf, sizeof (float), bufferlen, psf) ;
/* Fix me : Need lef2s_array */
- if (psf->float_endswap == SF_TRUE)
+ if (psf->data_endswap == SF_TRUE)
endswap_int_array (psf->u.ibuf, bufferlen) ;
f2s_array (psf->u.fbuf, readcount, ptr + total, scale) ;
@@ -504,10 +535,12 @@
static sf_count_t
host_read_f2i (SF_PRIVATE *psf, int *ptr, sf_count_t len)
-{ int bufferlen, readcount ;
+{ void (*convert) (const float *, int, int *, float) ;
+ int bufferlen, readcount ;
sf_count_t total = 0 ;
float scale ;
+ convert = (psf->add_clipping) ? f2i_clip_array : f2i_array ;
bufferlen = ARRAY_LEN (psf->u.fbuf) ;
scale = (psf->float_int_mult == 0) ? 1.0 : 0x7FFFFFFF / psf->float_max ;
@@ -516,10 +549,10 @@
bufferlen = (int) len ;
readcount = psf_fread (psf->u.fbuf, sizeof (float), bufferlen, psf) ;
- if (psf->float_endswap == SF_TRUE)
+ if (psf->data_endswap == SF_TRUE)
endswap_int_array (psf->u.ibuf, bufferlen) ;
- f2i_array (psf->u.fbuf, readcount, ptr + total, scale) ;
+ convert (psf->u.fbuf, readcount, ptr + total, scale) ;
total += readcount ;
if (readcount < bufferlen)
break ;
@@ -534,7 +567,7 @@
{ int bufferlen, readcount ;
sf_count_t total = 0 ;
- if (psf->float_endswap != SF_TRUE)
+ if (psf->data_endswap != SF_TRUE)
return psf_fread (ptr, sizeof (float), len, psf) ;
bufferlen = ARRAY_LEN (psf->u.fbuf) ;
@@ -567,7 +600,7 @@
bufferlen = (int) len ;
readcount = psf_fread (psf->u.fbuf, sizeof (float), bufferlen, psf) ;
- if (psf->float_endswap == SF_TRUE)
+ if (psf->data_endswap == SF_TRUE)
endswap_int_array (psf->u.ibuf, bufferlen) ;
/* Fix me : Need lef2d_array */
@@ -585,18 +618,21 @@
host_write_s2f (SF_PRIVATE *psf, const short *ptr, sf_count_t len)
{ int bufferlen, writecount ;
sf_count_t total = 0 ;
+ float scale ;
+/* Erik */
+ scale = (psf->scale_int_float == 0) ? 1.0 : 1.0 / 0x8000 ;
bufferlen = ARRAY_LEN (psf->u.fbuf) ;
while (len > 0)
{ if (len < bufferlen)
bufferlen = (int) len ;
- s2f_array (ptr + total, psf->u.fbuf, bufferlen) ;
+ s2f_array (ptr + total, psf->u.fbuf, bufferlen, scale) ;
if (psf->peak_info)
float32_peak_update (psf, psf->u.fbuf, bufferlen, total / psf->sf.channels) ;
- if (psf->float_endswap == SF_TRUE)
+ if (psf->data_endswap == SF_TRUE)
endswap_int_array (psf->u.ibuf, bufferlen) ;
writecount = psf_fwrite (psf->u.fbuf, sizeof (float), bufferlen, psf) ;
@@ -613,18 +649,20 @@
host_write_i2f (SF_PRIVATE *psf, const int *ptr, sf_count_t len)
{ int bufferlen, writecount ;
sf_count_t total = 0 ;
+ float scale ;
+ scale = (psf->scale_int_float == 0) ? 1.0 : 1.0 / (8.0 * 0x10000000) ;
bufferlen = ARRAY_LEN (psf->u.fbuf) ;
while (len > 0)
{ if (len < bufferlen)
bufferlen = (int) len ;
- i2f_array (ptr + total, psf->u.fbuf, bufferlen) ;
+ i2f_array (ptr + total, psf->u.fbuf, bufferlen, scale) ;
if (psf->peak_info)
float32_peak_update (psf, psf->u.fbuf, bufferlen, total / psf->sf.channels) ;
- if (psf->float_endswap == SF_TRUE)
+ if (psf->data_endswap == SF_TRUE)
endswap_int_array (psf->u.ibuf, bufferlen) ;
writecount = psf_fwrite (psf->u.fbuf, sizeof (float) , bufferlen, psf) ;
@@ -645,7 +683,7 @@
if (psf->peak_info)
float32_peak_update (psf, ptr, len, 0) ;
- if (psf->float_endswap != SF_TRUE)
+ if (psf->data_endswap != SF_TRUE)
return psf_fwrite (ptr, sizeof (float), len, psf) ;
bufferlen = ARRAY_LEN (psf->u.fbuf) ;
@@ -682,7 +720,7 @@
if (psf->peak_info)
float32_peak_update (psf, psf->u.fbuf, bufferlen, total / psf->sf.channels) ;
- if (psf->float_endswap == SF_TRUE)
+ if (psf->data_endswap == SF_TRUE)
endswap_int_array (psf->u.ibuf, bufferlen) ;
writecount = psf_fwrite (psf->u.fbuf, sizeof (float), bufferlen, psf) ;
@@ -712,7 +750,7 @@
bufferlen = (int) len ;
readcount = psf_fread (psf->u.fbuf, sizeof (float), bufferlen, psf) ;
- if (psf->float_endswap == SF_TRUE)
+ if (psf->data_endswap == SF_TRUE)
endswap_int_array (psf->u.ibuf, bufferlen) ;
bf2f_array (psf->u.fbuf, bufferlen) ;
@@ -741,7 +779,7 @@
bufferlen = (int) len ;
readcount = psf_fread (psf->u.fbuf, sizeof (float), bufferlen, psf) ;
- if (psf->float_endswap == SF_TRUE)
+ if (psf->data_endswap == SF_TRUE)
endswap_int_array (psf->u.ibuf, bufferlen) ;
bf2f_array (psf->u.fbuf, bufferlen) ;
@@ -770,7 +808,7 @@
bufferlen = (int) len ;
readcount = psf_fread (psf->u.fbuf, sizeof (float), bufferlen, psf) ;
- if (psf->float_endswap == SF_TRUE)
+ if (psf->data_endswap == SF_TRUE)
endswap_int_array (psf->u.ibuf, bufferlen) ;
bf2f_array (psf->u.fbuf, bufferlen) ;
@@ -798,7 +836,7 @@
bufferlen = (int) len ;
readcount = psf_fread (psf->u.fbuf, sizeof (float), bufferlen, psf) ;
- if (psf->float_endswap == SF_TRUE)
+ if (psf->data_endswap == SF_TRUE)
endswap_int_array (psf->u.ibuf, bufferlen) ;
bf2f_array (psf->u.fbuf, bufferlen) ;
@@ -817,20 +855,22 @@
replace_write_s2f (SF_PRIVATE *psf, const short *ptr, sf_count_t len)
{ int bufferlen, writecount ;
sf_count_t total = 0 ;
+ float scale ;
+ scale = (psf->scale_int_float == 0) ? 1.0 : 1.0 / 0x8000 ;
bufferlen = ARRAY_LEN (psf->u.fbuf) ;
while (len > 0)
{ if (len < bufferlen)
bufferlen = (int) len ;
- s2f_array (ptr + total, psf->u.fbuf, bufferlen) ;
+ s2f_array (ptr + total, psf->u.fbuf, bufferlen, scale) ;
if (psf->peak_info)
float32_peak_update (psf, psf->u.fbuf, bufferlen, total / psf->sf.channels) ;
f2bf_array (psf->u.fbuf, bufferlen) ;
- if (psf->float_endswap == SF_TRUE)
+ if (psf->data_endswap == SF_TRUE)
endswap_int_array (psf->u.ibuf, bufferlen) ;
writecount = psf_fwrite (psf->u.fbuf, sizeof (float), bufferlen, psf) ;
@@ -847,20 +887,22 @@
replace_write_i2f (SF_PRIVATE *psf, const int *ptr, sf_count_t len)
{ int bufferlen, writecount ;
sf_count_t total = 0 ;
+ float scale ;
+ scale = (psf->scale_int_float == 0) ? 1.0 : 1.0 / (8.0 * 0x10000000) ;
bufferlen = ARRAY_LEN (psf->u.fbuf) ;
while (len > 0)
{ if (len < bufferlen)
bufferlen = (int) len ;
- i2f_array (ptr + total, psf->u.fbuf, bufferlen) ;
+ i2f_array (ptr + total, psf->u.fbuf, bufferlen, scale) ;
if (psf->peak_info)
float32_peak_update (psf, psf->u.fbuf, bufferlen, total / psf->sf.channels) ;
f2bf_array (psf->u.fbuf, bufferlen) ;
- if (psf->float_endswap == SF_TRUE)
+ if (psf->data_endswap == SF_TRUE)
endswap_int_array (psf->u.ibuf, bufferlen) ;
writecount = psf_fwrite (psf->u.fbuf, sizeof (float), bufferlen, psf) ;
@@ -892,7 +934,7 @@
f2bf_array (psf->u.fbuf, bufferlen) ;
- if (psf->float_endswap == SF_TRUE)
+ if (psf->data_endswap == SF_TRUE)
endswap_int_array (psf->u.ibuf, bufferlen) ;
writecount = psf_fwrite (psf->u.fbuf, sizeof (float) , bufferlen, psf) ;
@@ -922,7 +964,7 @@
f2bf_array (psf->u.fbuf, bufferlen) ;
- if (psf->float_endswap == SF_TRUE)
+ if (psf->data_endswap == SF_TRUE)
endswap_int_array (psf->u.ibuf, bufferlen) ;
writecount = psf_fwrite (psf->u.fbuf, sizeof (float), bufferlen, psf) ;
@@ -952,10 +994,3 @@
} ;
} /* f2bf_array */
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: b6c34917-488c-4145-9648-f4371fc4c889
-*/
Modified: freeswitch/trunk/libs/libsndfile/src/g72x.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/src/g72x.c (original)
+++ freeswitch/trunk/libs/libsndfile/src/g72x.c Thu May 21 16:09:30 2009
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 1999-2005 Erik de Castro Lopo <erikd at mega-nerd.com>
+** Copyright (C) 1999-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU Lesser General Public License as published by
@@ -21,10 +21,10 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <math.h>
#include "sndfile.h"
#include "sfendian.h"
-#include "float_cast.h"
#include "common.h"
#include "G72x/g72x.h"
@@ -90,7 +90,7 @@
pg72x->block_curr = 0 ;
pg72x->sample_curr = 0 ;
- switch (psf->sf.format & SF_FORMAT_SUBMASK)
+ switch (SF_CODEC (psf->sf.format))
{ case SF_FORMAT_G721_32 :
codec = G721_32_BITS_PER_SAMPLE ;
bytesperblock = G721_32_BYTES_PER_BLOCK ;
@@ -343,12 +343,8 @@
} /* g72x_read_d */
static sf_count_t
-g72x_seek (SF_PRIVATE *psf, int mode, sf_count_t offset)
+g72x_seek (SF_PRIVATE *psf, int UNUSED (mode), sf_count_t UNUSED (offset))
{
- /* Prevent compiler warnings. */
- mode ++ ;
- offset ++ ;
-
psf_log_printf (psf, "seek unsupported\n") ;
/* No simple solution. To do properly, would need to seek
@@ -606,10 +602,3 @@
return 0 ;
} /* g72x_close */
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: 3cc5439e-7247-486b-b2e6-11a4affa5744
-*/
Modified: freeswitch/trunk/libs/libsndfile/src/gsm610.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/src/gsm610.c (original)
+++ freeswitch/trunk/libs/libsndfile/src/gsm610.c Thu May 21 16:09:30 2009
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 1999-2006 Erik de Castro Lopo <erikd at mega-nerd.com>
+** Copyright (C) 1999-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU Lesser General Public License as published by
@@ -21,10 +21,10 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <math.h>
#include "sndfile.h"
#include "sfendian.h"
-#include "float_cast.h"
#include "common.h"
#include "wav_w64.h"
#include "GSM610/gsm.h"
@@ -105,7 +105,7 @@
if ((pgsm610->gsm_data = gsm_create ()) == NULL)
return SFE_MALLOC_FAILED ;
- switch (psf->sf.format & SF_FORMAT_TYPEMASK)
+ switch (SF_CONTAINER (psf->sf.format))
{ case SF_FORMAT_WAV :
case SF_FORMAT_WAVEX :
case SF_FORMAT_W64 :
@@ -152,6 +152,8 @@
psf->sf.frames = pgsm610->samplesperblock * pgsm610->blocks ;
+ psf_fseek (psf, psf->dataoffset, SEEK_SET) ;
+
pgsm610->decode_block (psf, pgsm610) ; /* Read first block. */
psf->read_short = gsm610_read_s ;
@@ -200,12 +202,12 @@
psf_log_printf (psf, "*** Warning : short read (%d != %d).\n", k, WAV_W64_GSM610_BLOCKSIZE) ;
if (gsm_decode (pgsm610->gsm_data, pgsm610->block, pgsm610->samples) < 0)
- { psf_log_printf (psf, "Error from gsm_decode() on frame : %d\n", pgsm610->blockcount) ;
+ { psf_log_printf (psf, "Error from WAV gsm_decode() on frame : %d\n", pgsm610->blockcount) ;
return 0 ;
} ;
if (gsm_decode (pgsm610->gsm_data, pgsm610->block + (WAV_W64_GSM610_BLOCKSIZE + 1) / 2, pgsm610->samples + WAV_W64_GSM610_SAMPLES / 2) < 0)
- { psf_log_printf (psf, "Error from gsm_decode() on frame : %d.5\n", pgsm610->blockcount) ;
+ { psf_log_printf (psf, "Error from WAV gsm_decode() on frame : %d.5\n", pgsm610->blockcount) ;
return 0 ;
} ;
@@ -228,7 +230,7 @@
psf_log_printf (psf, "*** Warning : short read (%d != %d).\n", k, GSM610_BLOCKSIZE) ;
if (gsm_decode (pgsm610->gsm_data, pgsm610->block, pgsm610->samples) < 0)
- { psf_log_printf (psf, "Error from gsm_decode() on frame : %d\n", pgsm610->blockcount) ;
+ { psf_log_printf (psf, "Error from standard gsm_decode() on frame : %d\n", pgsm610->blockcount) ;
return 0 ;
} ;
@@ -367,12 +369,10 @@
} /* gsm610_read_d */
static sf_count_t
-gsm610_seek (SF_PRIVATE *psf, int mode, sf_count_t offset)
+gsm610_seek (SF_PRIVATE *psf, int UNUSED (mode), sf_count_t offset)
{ GSM610_PRIVATE *pgsm610 ;
int newblock, newsample ;
- mode = mode ;
-
if (psf->codec_data == NULL)
return 0 ;
pgsm610 = (GSM610_PRIVATE*) psf->codec_data ;
@@ -389,8 +389,8 @@
pgsm610->blockcount = 0 ;
gsm_init (pgsm610->gsm_data) ;
- if ((psf->sf.format & SF_FORMAT_TYPEMASK) == SF_FORMAT_WAV ||
- (psf->sf.format & SF_FORMAT_TYPEMASK) == SF_FORMAT_W64)
+ if ((SF_CONTAINER (psf->sf.format)) == SF_FORMAT_WAV ||
+ (SF_CONTAINER (psf->sf.format)) == SF_FORMAT_W64)
gsm_option (pgsm610->gsm_data, GSM_OPT_WAV49, &true_flag) ;
pgsm610->decode_block (psf, pgsm610) ;
@@ -619,10 +619,3 @@
return 0 ;
} /* gsm610_close */
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: 8575187d-af4f-4acf-b9dd-6ff705628345
-*/
Modified: freeswitch/trunk/libs/libsndfile/src/htk.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/src/htk.c (original)
+++ freeswitch/trunk/libs/libsndfile/src/htk.c Thu May 21 16:09:30 2009
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 2002-2004 Erik de Castro Lopo <erikd at mega-nerd.com>
+** Copyright (C) 2002-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU Lesser General Public License as published by
@@ -60,10 +60,10 @@
return error ;
} ;
- subformat = psf->sf.format & SF_FORMAT_SUBMASK ;
+ subformat = SF_CODEC (psf->sf.format) ;
if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR)
- { if ((psf->sf.format & SF_FORMAT_TYPEMASK) != SF_FORMAT_HTK)
+ { if ((SF_CONTAINER (psf->sf.format)) != SF_FORMAT_HTK)
return SFE_BAD_OPEN_FORMAT ;
psf->endian = SF_ENDIAN_BIG ;
@@ -216,10 +216,4 @@
return 0 ;
} /* htk_read_header */
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: c350e972-082e-4c20-8934-03391a723560
-*/
+
Modified: freeswitch/trunk/libs/libsndfile/src/ima_adpcm.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/src/ima_adpcm.c (original)
+++ freeswitch/trunk/libs/libsndfile/src/ima_adpcm.c Thu May 21 16:09:30 2009
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 1999-2005 Erik de Castro Lopo <erikd at mega-nerd.com>
+** Copyright (C) 1999-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU Lesser General Public License as published by
@@ -21,10 +21,10 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <math.h>
#include "sndfile.h"
#include "sfendian.h"
-#include "float_cast.h"
#include "common.h"
typedef struct IMA_ADPCM_PRIVATE_tag
@@ -93,6 +93,16 @@
static int aiff_ima_encode_block (SF_PRIVATE *psf, IMA_ADPCM_PRIVATE *pima) ;
+static inline int
+clamp_ima_step_index (int indx)
+{ if (indx < 0)
+ return 0 ;
+ if (indx >= ARRAY_LEN (ima_step_size))
+ return ARRAY_LEN (ima_step_size) - 1 ;
+
+ return indx ;
+} /* clamp_ima_step_index */
+
/*============================================================================================
** IMA ADPCM Reader initialisation function.
*/
@@ -194,18 +204,25 @@
psf->datalength = (psf->dataend) ? psf->dataend - psf->dataoffset :
psf->filelength - psf->dataoffset ;
+ if (pima->blocksize == 0)
+ { psf_log_printf (psf, "*** Error : pima->blocksize should not be zero.\n") ;
+ return SFE_INTERNAL ;
+ } ;
+
if (psf->datalength % pima->blocksize)
pima->blocks = psf->datalength / pima->blocksize + 1 ;
else
pima->blocks = psf->datalength / pima->blocksize ;
- switch (psf->sf.format & SF_FORMAT_TYPEMASK)
+ switch (SF_CONTAINER (psf->sf.format))
{ case SF_FORMAT_WAV :
case SF_FORMAT_W64 :
count = 2 * (pima->blocksize - 4 * pima->channels) / pima->channels + 1 ;
if (pima->samplesperblock != count)
- psf_log_printf (psf, "*** Warning : samplesperblock should be %d.\n", count) ;
+ { psf_log_printf (psf, "*** Error : samplesperblock should be %d.\n", count) ;
+ return SFE_INTERNAL ;
+ } ;
pima->decode_block = wav_w64_ima_decode_block ;
@@ -260,16 +277,9 @@
sampledata = pima->samples + chan ;
predictor = (blockdata [0] << 8) | (blockdata [1] & 0x80) ;
- stepindx = blockdata [1] & 0x7F ;
-{
-if (count < 5)
-printf ("\nchan: %d predictor: %d stepindx: %d (%d)\n",
- chan, predictor, stepindx, ima_step_size [stepindx]) ;
-}
- /* FIXME : Do this a better way. */
- if (stepindx < 0) stepindx = 0 ;
- else if (stepindx > 88) stepindx = 88 ;
+ stepindx = blockdata [1] & 0x7F ;
+ stepindx = clamp_ima_step_index (stepindx) ;
/*
** Pull apart the packed 4 bit samples and store them in their
@@ -288,9 +298,7 @@
bytecode = pima->samples [pima->channels * k + chan] ;
stepindx += ima_indx_adjust [bytecode] ;
-
- if (stepindx < 0) stepindx = 0 ;
- else if (stepindx > 88) stepindx = 88 ;
+ stepindx = clamp_ima_step_index (stepindx) ;
diff = step >> 3 ;
if (bytecode & 1) diff += step >> 2 ;
@@ -299,18 +307,10 @@
if (bytecode & 8) diff = -diff ;
predictor += diff ;
-
pima->samples [pima->channels * k + chan] = predictor ;
} ;
} ;
-if (count < 5)
-{
- for (k = 0 ; k < 10 ; k++)
- printf ("% 7d,", pima->samples [k]) ;
- puts ("") ;
-}
-
return 1 ;
} /* aiff_ima_decode_block */
@@ -319,14 +319,6 @@
{ int chan, k, step, diff, vpdiff, blockindx, indx ;
short bytecode, mask ;
-static int count = 0 ;
-if (0 && count == 0)
-{ pima->samples [0] = 0 ;
- printf ("blocksize : %d\n", pima->blocksize) ;
- printf ("pima->stepindx [0] : %d\n", pima->stepindx [0]) ;
- }
-count ++ ;
-
/* Encode the block header. */
for (chan = 0 ; chan < pima->channels ; chan ++)
{ blockindx = chan * pima->blocksize ;
@@ -372,11 +364,8 @@
pima->previous [chan] = -32768 ;
pima->stepindx [chan] += ima_indx_adjust [bytecode] ;
- if (pima->stepindx [chan] < 0)
- pima->stepindx [chan] = 0 ;
- else if (pima->stepindx [chan] > 88)
- pima->stepindx [chan] = 88 ;
+ pima->stepindx [chan] = clamp_ima_step_index (pima->stepindx [chan]) ;
pima->samples [k] = bytecode ;
} ;
@@ -386,9 +375,6 @@
{ for (indx = pima->channels ; indx < pima->channels * pima->samplesperblock ; indx += 2 * pima->channels)
{ blockindx = chan * pima->blocksize + 2 + indx / 2 ;
-if (0 && count ++ < 5)
- printf ("chan: %d blockindx: %3d indx: %3d\n", chan, blockindx, indx) ;
-
pima->block [blockindx] = pima->samples [indx] & 0x0F ;
pima->block [blockindx] |= (pima->samples [indx + pima->channels] << 4) & 0xF0 ;
} ;
@@ -430,10 +416,8 @@
current -= 0x10000 ;
stepindx [chan] = pima->block [chan*4+2] ;
- if (stepindx [chan] < 0)
- stepindx [chan] = 0 ;
- else if (stepindx [chan] > 88)
- stepindx [chan] = 88 ;
+ stepindx [chan] = clamp_ima_step_index (stepindx [chan]) ;
+
if (pima->block [chan*4+3] != 0)
psf_log_printf (psf, "IMA ADPCM synchronisation error.\n") ;
@@ -491,11 +475,7 @@
current = -32768 ;
stepindx [chan] += ima_indx_adjust [bytecode] ;
-
- if (stepindx [chan] < 0)
- stepindx [chan] = 0 ;
- else if (stepindx [chan] > 88)
- stepindx [chan] = 88 ;
+ stepindx [chan] = clamp_ima_step_index (stepindx [chan]) ;
pima->samples [k] = current ;
} ;
@@ -555,10 +535,7 @@
pima->previous [chan] = -32768 ;
pima->stepindx [chan] += ima_indx_adjust [bytecode] ;
- if (pima->stepindx [chan] < 0)
- pima->stepindx [chan] = 0 ;
- else if (pima->stepindx [chan] > 88)
- pima->stepindx [chan] = 88 ;
+ pima->stepindx [chan] = clamp_ima_step_index (pima->stepindx [chan]) ;
pima->samples [k] = bytecode ;
} ;
@@ -806,7 +783,7 @@
pima->samplecount = 0 ;
- switch (psf->sf.format & SF_FORMAT_TYPEMASK)
+ switch (SF_CONTAINER (psf->sf.format))
{ case SF_FORMAT_WAV :
case SF_FORMAT_W64 :
pima->encode_block = wav_w64_ima_encode_block ;
@@ -966,11 +943,3 @@
return total ;
} /* ima_write_d */
-
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: 75a54b82-ad18-4758-9933-64e00a7f24e0
-*/
Added: freeswitch/trunk/libs/libsndfile/src/ima_oki_adpcm.c
==============================================================================
--- (empty file)
+++ freeswitch/trunk/libs/libsndfile/src/ima_oki_adpcm.c Thu May 21 16:09:30 2009
@@ -0,0 +1,295 @@
+/*
+** Copyright (c) 2007 <robs at users.sourceforge.net>
+** Copyright (C) 2007-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
+**
+** 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
+** the Free Software Foundation; either version 2 of the License, or (at
+** your option) any later version.
+**
+** This library is distributed in the hope that it will be useful, but
+** WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
+** General Public License for more details.
+**
+** You should have received a copy of the GNU Lesser General Public License
+** along with this library. If not, write to the Free Software Foundation,
+** Fifth Floor, 51 Franklin Street, Boston, MA 02111-1301, USA.
+*/
+
+/* ADPCM: IMA, OKI <==> 16-bit PCM. */
+
+#include <string.h>
+
+/* Set up for libsndfile environment: */
+#include "common.h"
+
+#include "ima_oki_adpcm.h"
+
+#define MIN_SAMPLE -0x8000
+#define MAX_SAMPLE 0x7fff
+
+static int const ima_steps [] = /* ~16-bit precision */
+{ 7, 8, 9, 10, 11, 12, 13, 14, 16, 17, 19, 21, 23, 25, 28, 31, 34, 37, 41, 45,
+ 50, 55, 60, 66, 73, 80, 88, 97, 107, 118, 130, 143, 157, 173, 190, 209, 230,
+ 253, 279, 307, 337, 371, 408, 449, 494, 544, 598, 658, 724, 796, 876, 963,
+ 1060, 1166, 1282, 1411, 1552, 1707, 1878, 2066, 2272, 2499, 2749, 3024, 3327,
+ 3660, 4026, 4428, 4871, 5358, 5894, 6484, 7132, 7845, 8630, 9493, 10442,
+ 11487, 12635, 13899, 15289, 16818, 18500, 20350, 22385, 24623, 27086, 29794,
+ 32767
+} ;
+
+static int const oki_steps [] = /* ~12-bit precision */
+{ 256, 272, 304, 336, 368, 400, 448, 496, 544, 592, 656, 720, 800, 880, 960,
+ 1056, 1168, 1280, 1408, 1552, 1712, 1888, 2080, 2288, 2512, 2768, 3040, 3344,
+ 3680, 4048, 4464, 4912, 5392, 5936, 6528, 7184, 7904, 8704, 9568, 10528,
+ 11584, 12736, 14016, 15408, 16960, 18656, 20512, 22576, 24832
+} ;
+
+static int const step_changes [] = { -1, -1, -1, -1, 2, 4, 6, 8 } ;
+
+void
+ima_oki_adpcm_init (IMA_OKI_ADPCM * state, IMA_OKI_ADPCM_TYPE type)
+{
+ memset (state, 0, sizeof (*state)) ;
+
+ if (type == IMA_OKI_ADPCM_TYPE_IMA)
+ { state->max_step_index = ARRAY_LEN (ima_steps) - 1 ;
+ state->steps = ima_steps ;
+ state->mask = (~0) ;
+ }
+ else
+ { state->max_step_index = ARRAY_LEN (oki_steps) - 1 ;
+ state->steps = oki_steps ;
+ state->mask = (~0) << 4 ;
+ } ;
+
+} /* ima_oki_adpcm_init */
+
+
+int
+adpcm_decode (IMA_OKI_ADPCM * state, int code)
+{ int s ;
+
+ s = ((code & 7) << 1) | 1 ;
+ s = ((state->steps [state->step_index] * s) >> 3) & state->mask ;
+
+ if (code & 8)
+ s = -s ;
+ s += state->last_output ;
+
+ if (s < MIN_SAMPLE || s > MAX_SAMPLE)
+ { int grace ;
+
+ grace = (state->steps [state->step_index] >> 3) & state->mask ;
+
+ if (s < MIN_SAMPLE - grace || s > MAX_SAMPLE + grace)
+ state->errors ++ ;
+
+ s = s < MIN_SAMPLE ? MIN_SAMPLE : MAX_SAMPLE ;
+ } ;
+
+ state->step_index += step_changes [code & 7] ;
+ state->step_index = SF_MIN (SF_MAX (state->step_index, 0), state->max_step_index) ;
+ state->last_output = s ;
+
+ return s ;
+} /* adpcm_decode */
+
+int
+adpcm_encode (IMA_OKI_ADPCM * state, int sample)
+{ int delta, sign = 0, code ;
+
+ delta = sample - state->last_output ;
+
+ if (delta < 0)
+ { sign = 8 ;
+ delta = -delta ;
+ } ;
+
+ code = 4 * delta / state->steps [state->step_index] ;
+ code = sign | SF_MIN (code, 7) ;
+ adpcm_decode (state, code) ; /* Update encoder state */
+
+ return code ;
+} /* adpcm_encode */
+
+
+void
+ima_oki_adpcm_decode_block (IMA_OKI_ADPCM * state)
+{ unsigned char code ;
+ int k ;
+
+ for (k = 0 ; k < state->code_count ; k++)
+ { code = state->codes [k] ;
+ state->pcm [2 * k] = adpcm_decode (state, code >> 4) ;
+ state->pcm [2 * k + 1] = adpcm_decode (state, code) ;
+ } ;
+
+ state->pcm_count = 2 * k ;
+} /* ima_oki_adpcm_decode_block */
+
+
+void
+ima_oki_adpcm_encode_block (IMA_OKI_ADPCM * state)
+{ unsigned char code ;
+ int k ;
+
+ /*
+ ** The codec expects an even number of input samples.
+ **
+ ** Samples should always be passed in even length blocks. If the last block to
+ ** be encoded is odd length, extend that block by one zero valued sample.
+ */
+ if (state->pcm_count % 2 == 1)
+ state->pcm [state->pcm_count ++] = 0 ;
+
+ for (k = 0 ; k < state->pcm_count / 2 ; k++)
+ { code = adpcm_encode (state, state->pcm [2 * k]) << 4 ;
+ code |= adpcm_encode (state, state->pcm [2 * k + 1]) ;
+ state->codes [k] = code ;
+ } ;
+
+ state->code_count = k ;
+} /* ima_oki_adpcm_encode_block */
+
+
+#ifdef TEST
+
+static const unsigned char test_codes [] =
+{ 0x08, 0x08, 0x04, 0x7f, 0x72, 0xf7, 0x9f, 0x7c, 0xd7, 0xbc, 0x7a, 0xa7, 0xb8,
+ 0x4b, 0x0b, 0x38, 0xf6, 0x9d, 0x7a, 0xd7, 0xbc, 0x7a, 0xd7, 0xa8, 0x6c, 0x81,
+ 0x98, 0xe4, 0x0e, 0x7a, 0xd7, 0x9e, 0x7b, 0xc7, 0xab, 0x7a, 0x85, 0xc0, 0xb3,
+ 0x8f, 0x58, 0xd7, 0xad, 0x7a, 0xd7, 0xad, 0x7a, 0x87, 0xd0, 0x2b, 0x0e, 0x48,
+ 0xd7, 0xad, 0x78, 0xf7, 0xbc, 0x7a, 0xb7, 0xa8, 0x4b, 0x88, 0x18, 0xd5, 0x8d,
+ 0x6a, 0xa4, 0x98, 0x08, 0x00, 0x80, 0x88,
+} ;
+
+static const short test_pcm [] =
+{ 32, 0, 32, 0, 32, 320, 880, -336, 2304, 4192, -992, 10128, 5360, -16352,
+ 30208, 2272, -31872, 14688, -7040, -32432, 14128, -1392, -15488, 22960,
+ 1232, -1584, 21488, -240, 2576, -15360, 960, -1152, -30032, 10320, 1008,
+ -30032, 16528, 1008, -30032, 16528, -5200, -30592, 15968, 448, -30592,
+ 15968, 448, -2368, 30960, 3024, -80, 8384, 704, -1616, -29168, -1232, 1872,
+ -32768, 13792, -1728, -32768, 13792, 4480, -32192, 14368, -7360, -32752,
+ 13808, -1712, -21456, 16992, 1472, -1344, 26848, -1088, 2016, -17728, 208,
+ -2112, -32768, 1376, -1728, -32768, 13792, -1728, -32768, 13792, -1728,
+ -32768, 13792, -1728, -32768, 13792, -1728, -4544, 32767, -1377, 1727,
+ 15823, -2113, 207, -27345, 591, -2513, -32768, 13792, -1728, -32768, 13792,
+ 10688, -31632, 14928, -6800, -32192, 14368, -1152, -20896, 17552, 2032,
+ -784, 22288, 560, -2256, -4816, 2176, 64, -21120, 9920, 6816, -24224, 16128,
+ 608, -13488, 9584, 272, -2544, 16, -2304, -192, 1728, -16, 1568, 128, -1184,
+} ;
+
+
+static void
+test_oki_adpcm (void)
+{
+ IMA_OKI_ADPCM adpcm ;
+ unsigned char code ;
+ int i, j ;
+
+ printf (" Testing encoder : ") ;
+ fflush (stdout) ;
+
+ ima_oki_adpcm_init (&adpcm, IMA_OKI_ADPCM_TYPE_OKI) ;
+ for (i = 0 ; i < ARRAY_LEN (test_codes) ; i++)
+ for (j = 0, code = test_codes [i] ; j < 2 ; j++, code <<= 4)
+ if (adpcm_decode (&adpcm, code >> 4) != test_pcm [2 * i + j])
+ { printf ("\n\nFail at i = %d, j = %d.\n\n", i, j) ;
+ exit (1) ;
+ } ;
+
+ puts ("ok") ;
+
+ printf (" Testing decoder : ") ;
+ fflush (stdout) ;
+
+ ima_oki_adpcm_init (&adpcm, IMA_OKI_ADPCM_TYPE_OKI) ;
+ for (i = 0 ; i < ARRAY_LEN (test_pcm) ; i += j)
+ { code = adpcm_encode (&adpcm, test_pcm [i]) ;
+ code = (code << 4) | adpcm_encode (&adpcm, test_pcm [i + 1]) ;
+ if (code != test_codes [i / 2])
+ { printf ("\n\nFail at i = %d, %d should be %d\n\n", i, code, test_codes [i / 2]) ;
+ exit (1) ;
+ } ;
+ } ;
+
+ puts ("ok") ;
+} /* test_oki_adpcm */
+
+static void
+test_oki_adpcm_block (void)
+{
+ IMA_OKI_ADPCM adpcm ;
+ int k ;
+
+ if (ARRAY_LEN (adpcm.pcm) < ARRAY_LEN (test_pcm))
+ { printf ("\n\nLine %d : ARRAY_LEN (adpcm->pcm) > ARRAY_LEN (test_pcm) (%d > %d).\n\n", __LINE__, ARRAY_LEN (adpcm.pcm), ARRAY_LEN (test_pcm)) ;
+ exit (1) ;
+ } ;
+
+ if (ARRAY_LEN (adpcm.codes) < ARRAY_LEN (test_codes))
+ { printf ("\n\nLine %d : ARRAY_LEN (adcodes->codes) > ARRAY_LEN (test_codes).n", __LINE__) ;
+ exit (1) ;
+ } ;
+
+ printf (" Testing block encoder : ") ;
+ fflush (stdout) ;
+
+ ima_oki_adpcm_init (&adpcm, IMA_OKI_ADPCM_TYPE_OKI) ;
+
+ memcpy (adpcm.pcm, test_pcm, sizeof (adpcm.pcm [0]) * ARRAY_LEN (test_pcm)) ;
+ adpcm.pcm_count = ARRAY_LEN (test_pcm) ;
+ adpcm.code_count = 13 ;
+
+ ima_oki_adpcm_encode_block (&adpcm) ;
+
+ if (adpcm.code_count * 2 != ARRAY_LEN (test_pcm))
+ { printf ("\n\nLine %d : %d * 2 != %d\n\n", __LINE__, adpcm.code_count * 2, ARRAY_LEN (test_pcm)) ;
+ exit (1) ;
+ } ;
+
+ for (k = 0 ; k < ARRAY_LEN (test_codes) ; k++)
+ if (adpcm.codes [k] != test_codes [k])
+ { printf ("\n\nLine %d : Fail at k = %d, %d should be %d\n\n", __LINE__, k, adpcm.codes [k], test_codes [k]) ;
+ exit (1) ;
+ } ;
+
+ puts ("ok") ;
+
+ printf (" Testing block decoder : ") ;
+ fflush (stdout) ;
+
+ ima_oki_adpcm_init (&adpcm, IMA_OKI_ADPCM_TYPE_OKI) ;
+
+ memcpy (adpcm.codes, test_codes, sizeof (adpcm.codes [0]) * ARRAY_LEN (test_codes)) ;
+ adpcm.code_count = ARRAY_LEN (test_codes) ;
+ adpcm.pcm_count = 13 ;
+
+ ima_oki_adpcm_decode_block (&adpcm) ;
+
+ if (adpcm.pcm_count != 2 * ARRAY_LEN (test_codes))
+ { printf ("\n\nLine %d : %d * 2 != %d\n\n", __LINE__, adpcm.pcm_count, 2 * ARRAY_LEN (test_codes)) ;
+ exit (1) ;
+ } ;
+
+ for (k = 0 ; k < ARRAY_LEN (test_pcm) ; k++)
+ if (adpcm.pcm [k] != test_pcm [k])
+ { printf ("\n\nLine %d : Fail at i = %d, %d should be %d.\n\n", __LINE__, k, adpcm.pcm [k], test_pcm [k]) ;
+ exit (1) ;
+ } ;
+
+ puts ("ok") ;
+} /* test_oki_adpcm_block */
+
+int
+main (void)
+{
+ test_oki_adpcm () ;
+ test_oki_adpcm_block () ;
+
+ return 0 ;
+} /* main */
+
+#endif
Added: freeswitch/trunk/libs/libsndfile/src/ima_oki_adpcm.h
==============================================================================
--- (empty file)
+++ freeswitch/trunk/libs/libsndfile/src/ima_oki_adpcm.h Thu May 21 16:09:30 2009
@@ -0,0 +1,54 @@
+/*
+** Copyright (c) 2007 <robs at users.sourceforge.net>
+** Copyright (C) 2007-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
+**
+** 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
+** the Free Software Foundation; either version 2 of the License, or (at
+** your option) any later version.
+**
+** This library is distributed in the hope that it will be useful, but
+** WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
+** General Public License for more details.
+**
+** You should have received a copy of the GNU Lesser General Public License
+** along with this library. If not, write to the Free Software Foundation,
+** Fifth Floor, 51 Franklin Street, Boston, MA 02111-1301, USA.
+*/
+
+/* ADPCM: IMA, OKI <==> 16-bit PCM. */
+
+
+#define IMA_OKI_ADPCM_CODE_LEN 256
+#define IMA_OKI_ADPCM_PCM_LEN (IMA_OKI_ADPCM_CODE_LEN *2)
+
+typedef struct
+{
+ /* private: */
+ int mask ;
+ int last_output ;
+ int step_index ;
+ int max_step_index ;
+ int const * steps ;
+
+ /* public: */
+ int errors ;
+ int code_count, pcm_count ;
+
+ unsigned char codes [IMA_OKI_ADPCM_CODE_LEN] ;
+ short pcm [IMA_OKI_ADPCM_PCM_LEN] ;
+} IMA_OKI_ADPCM ;
+
+typedef enum
+{ IMA_OKI_ADPCM_TYPE_IMA,
+ IMA_OKI_ADPCM_TYPE_OKI
+} IMA_OKI_ADPCM_TYPE ;
+
+void ima_oki_adpcm_init (IMA_OKI_ADPCM * state, IMA_OKI_ADPCM_TYPE type) ;
+
+int adpcm_decode (IMA_OKI_ADPCM * state, int /* 0..15 */ code) ;
+int adpcm_encode (IMA_OKI_ADPCM * state, int /* -32768..32767 */ sample) ;
+
+void ima_oki_adpcm_decode_block (IMA_OKI_ADPCM * state) ;
+void ima_oki_adpcm_encode_block (IMA_OKI_ADPCM * state) ;
Modified: freeswitch/trunk/libs/libsndfile/src/interleave.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/src/interleave.c (original)
+++ freeswitch/trunk/libs/libsndfile/src/interleave.c Thu May 21 16:09:30 2009
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 2002-2004 Erik de Castro Lopo <erikd at mega-nerd.com>
+** Copyright (C) 2002-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU Lesser General Public License as published by
@@ -297,10 +297,4 @@
return samples_from_start ;
} /* interleave_seek */
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: 82314e13-0225-4408-a2f2-e6dab3f38904
-*/
+
Modified: freeswitch/trunk/libs/libsndfile/src/ircam.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/src/ircam.c (original)
+++ freeswitch/trunk/libs/libsndfile/src/ircam.c Thu May 21 16:09:30 2009
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 2001-2004 Erik de Castro Lopo <erikd at mega-nerd.com>
+** Copyright (C) 2001-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU Lesser General Public License as published by
@@ -85,13 +85,13 @@
return error ;
} ;
- subformat = psf->sf.format & SF_FORMAT_SUBMASK ;
+ subformat = SF_CODEC (psf->sf.format) ;
if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR)
- { if ((psf->sf.format & SF_FORMAT_TYPEMASK) != SF_FORMAT_IRCAM)
+ { if ((SF_CONTAINER (psf->sf.format)) != SF_FORMAT_IRCAM)
return SFE_BAD_OPEN_FORMAT ;
- psf->endian = psf->sf.format & SF_FORMAT_ENDMASK ;
+ psf->endian = SF_ENDIAN (psf->sf.format) ;
if (psf->endian == 0 || psf->endian == SF_ENDIAN_CPU)
psf->endian = (CPU_IS_BIG_ENDIAN) ? SF_ENDIAN_BIG : SF_ENDIAN_LITTLE ;
@@ -238,7 +238,7 @@
} /* ircam_close */
static int
-ircam_write_header (SF_PRIVATE *psf, int calc_length)
+ircam_write_header (SF_PRIVATE *psf, int UNUSED (calc_length))
{ int encoding ;
float samplerate ;
sf_count_t current ;
@@ -248,10 +248,8 @@
current = psf_ftell (psf) ;
- calc_length = calc_length ;
-
/* This also sets psf->endian. */
- encoding = get_encoding (psf->sf.format & SF_FORMAT_SUBMASK) ;
+ encoding = get_encoding (SF_CODEC (psf->sf.format)) ;
if (encoding == 0)
return SFE_BAD_OPEN_FORMAT ;
@@ -322,10 +320,3 @@
return "Unknown encoding" ;
} /* get_encoding_str */
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: f2714ab8-f286-4c94-9740-edaf673a1c71
-*/
Added: freeswitch/trunk/libs/libsndfile/src/libsndfile-1.def
==============================================================================
--- (empty file)
+++ freeswitch/trunk/libs/libsndfile/src/libsndfile-1.def Thu May 21 16:09:30 2009
@@ -0,0 +1,39 @@
+; Auto-generated by create_symbols_file.py
+
+LIBRARY libsndfile-1.dll
+EXPORTS
+
+sf_command @1
+sf_open @2
+sf_close @3
+sf_seek @4
+sf_error @7
+sf_perror @8
+sf_error_str @9
+sf_error_number @10
+sf_format_check @11
+sf_read_raw @16
+sf_readf_short @17
+sf_readf_int @18
+sf_readf_float @19
+sf_readf_double @20
+sf_read_short @21
+sf_read_int @22
+sf_read_float @23
+sf_read_double @24
+sf_write_raw @32
+sf_writef_short @33
+sf_writef_int @34
+sf_writef_float @35
+sf_writef_double @36
+sf_write_short @37
+sf_write_int @38
+sf_write_float @39
+sf_write_double @40
+sf_strerror @50
+sf_get_string @60
+sf_set_string @61
+sf_open_fd @70
+sf_open_virtual @80
+sf_write_sync @90
+
Modified: freeswitch/trunk/libs/libsndfile/src/macbinary3.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/src/macbinary3.c (original)
+++ freeswitch/trunk/libs/libsndfile/src/macbinary3.c Thu May 21 16:09:30 2009
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 2003-2005 Erik de Castro Lopo <erikd at mega-nerd.com>
+** Copyright (C) 2003-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU Lesser General Public License as published by
@@ -27,32 +27,19 @@
#if (OS_IS_MACOSX == 1)
-#include <CoreServices.h>
-
int
-macbinary3_open (SF_PRIVATE *psf)
+macbinary3_open (SF_PRIVATE * UNUSED (psf))
{
- if (psf)
- return 0 ;
-
return 0 ;
} /* macbinary3_open */
#else
int
-macbinary3_open (SF_PRIVATE *psf)
+macbinary3_open (SF_PRIVATE * UNUSED (psf))
{
- psf = psf ;
return 0 ;
} /* macbinary3_open */
#endif /* OS_IS_MACOSX */
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: c397a7d7-1a31-4349-9684-bd29ef06211e
-*/
Modified: freeswitch/trunk/libs/libsndfile/src/macos.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/src/macos.c (original)
+++ freeswitch/trunk/libs/libsndfile/src/macos.c Thu May 21 16:09:30 2009
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 2003-2005 Erik de Castro Lopo <erikd at mega-nerd.com>
+** Copyright (C) 2003-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU Lesser General Public License as published by
@@ -29,12 +29,9 @@
#define STR_MARKER MAKE_MARKER ('S', 'T', 'R', ' ')
int
-macos_guess_file_type (SF_PRIVATE *psf, const char *filename)
+macos_guess_file_type (SF_PRIVATE * psf, const char *filename)
{ static char rsrc_name [1024] ;
struct stat statbuf ;
- int format ;
-
- psf = psf ;
snprintf (rsrc_name, sizeof (rsrc_name), "%s/rsrc", filename) ;
@@ -49,15 +46,6 @@
return 0 ;
} ;
- format = 0 ;
-
- return format ;
+ return 0 ;
} /* macos_guess_file_type */
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: 5fbf66d7-9547-442a-9c73-92fd164f3a95
-*/
Modified: freeswitch/trunk/libs/libsndfile/src/mat4.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/src/mat4.c (original)
+++ freeswitch/trunk/libs/libsndfile/src/mat4.c Thu May 21 16:09:30 2009
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 2002-2006 Erik de Castro Lopo <erikd at mega-nerd.com>
+** Copyright (C) 2002-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU Lesser General Public License as published by
@@ -22,11 +22,11 @@
#include <fcntl.h>
#include <string.h>
#include <ctype.h>
+#include <math.h>
#include "sndfile.h"
#include "sfendian.h"
#include "common.h"
-#include "float_cast.h"
/*------------------------------------------------------------------------------
** Information on how to decode and encode this file was obtained in a PDF
@@ -81,16 +81,16 @@
return error ;
} ;
- if ((psf->sf.format & SF_FORMAT_TYPEMASK) != SF_FORMAT_MAT4)
+ if ((SF_CONTAINER (psf->sf.format)) != SF_FORMAT_MAT4)
return SFE_BAD_OPEN_FORMAT ;
- subformat = psf->sf.format & SF_FORMAT_SUBMASK ;
+ subformat = SF_CODEC (psf->sf.format) ;
if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR)
{ if (psf->is_pipe)
return SFE_NO_PIPE_WRITE ;
- psf->endian = psf->sf.format & SF_FORMAT_ENDMASK ;
+ psf->endian = SF_ENDIAN (psf->sf.format) ;
if (CPU_IS_LITTLE_ENDIAN && (psf->endian == SF_ENDIAN_CPU || psf->endian == 0))
psf->endian = SF_ENDIAN_LITTLE ;
else if (CPU_IS_BIG_ENDIAN && (psf->endian == SF_ENDIAN_CPU || psf->endian == 0))
@@ -162,7 +162,7 @@
psf->sf.frames = psf->datalength / (psf->bytewidth * psf->sf.channels) ;
} ;
- encoding = mat4_format_to_encoding (psf->sf.format & SF_FORMAT_SUBMASK, psf->endian) ;
+ encoding = mat4_format_to_encoding (SF_CODEC (psf->sf.format), psf->endian) ;
if (encoding == -1)
return SFE_BAD_OPEN_FORMAT ;
@@ -206,7 +206,8 @@
static int
mat4_read_header (SF_PRIVATE *psf)
-{ int marker, namesize, rows, cols, imag ;
+{ int marker, rows, cols, imag ;
+ unsigned namesize ;
double value ;
const char *marker_str ;
char name [64] ;
@@ -243,7 +244,7 @@
psf_binheader_readf (psf, "d", &value) ;
- LSF_SNPRINTF (psf->u.cbuf, sizeof (psf->u.cbuf), " Value : %f\n", value) ;
+ snprintf (psf->u.cbuf, sizeof (psf->u.cbuf), " Value : %f\n", value) ;
psf_log_printf (psf, psf->u.cbuf) ;
if ((rows != 1) || (cols != 1))
@@ -275,7 +276,7 @@
if (rows == 0 && cols == 0)
{ psf_log_printf (psf, "*** Error : zero channel count.\n") ;
- return SFE_MAT4_ZERO_CHANNELS ;
+ return SFE_CHANNEL_COUNT_ZERO ;
} ;
psf->sf.channels = rows ;
@@ -382,13 +383,7 @@
/* This is a little unsafe but is really only for debugging. */
str [sizeof (str) - 1] = 0 ;
- LSF_SNPRINTF (str, sizeof (str) - 1, "%08X", marker) ;
+ snprintf (str, sizeof (str) - 1, "%08X", marker) ;
return str ;
} /* mat4_marker_to_str */
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: f7e5f5d6-fc39-452e-bc4a-59627116ff59
-*/
+
Modified: freeswitch/trunk/libs/libsndfile/src/mat5.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/src/mat5.c (original)
+++ freeswitch/trunk/libs/libsndfile/src/mat5.c Thu May 21 16:09:30 2009
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 2002-2006 Erik de Castro Lopo <erikd at mega-nerd.com>
+** Copyright (C) 2002-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU Lesser General Public License as published by
@@ -22,11 +22,11 @@
#include <fcntl.h>
#include <string.h>
#include <ctype.h>
+#include <math.h>
#include "sndfile.h"
#include "sfendian.h"
#include "common.h"
-#include "float_cast.h"
/*------------------------------------------------------------------------------
** Information on how to decode and encode this file was obtained in a PDF
@@ -91,16 +91,16 @@
return error ;
} ;
- if ((psf->sf.format & SF_FORMAT_TYPEMASK) != SF_FORMAT_MAT5)
+ if ((SF_CONTAINER (psf->sf.format)) != SF_FORMAT_MAT5)
return SFE_BAD_OPEN_FORMAT ;
- subformat = psf->sf.format & SF_FORMAT_SUBMASK ;
+ subformat = SF_CODEC (psf->sf.format) ;
if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR)
{ if (psf->is_pipe)
return SFE_NO_PIPE_WRITE ;
- psf->endian = psf->sf.format & SF_FORMAT_ENDMASK ;
+ psf->endian = SF_ENDIAN (psf->sf.format) ;
if (CPU_IS_LITTLE_ENDIAN && (psf->endian == SF_ENDIAN_CPU || psf->endian == 0))
psf->endian = SF_ENDIAN_LITTLE ;
else if (CPU_IS_BIG_ENDIAN && (psf->endian == SF_ENDIAN_CPU || psf->endian == 0))
@@ -174,7 +174,7 @@
psf->sf.frames = psf->datalength / (psf->bytewidth * psf->sf.channels) ;
} ;
- switch (psf->sf.format & SF_FORMAT_SUBMASK)
+ switch (SF_CODEC (psf->sf.format))
{ case SF_FORMAT_PCM_U8 :
encoding = MAT5_TYPE_UCHAR ;
break ;
@@ -259,7 +259,8 @@
mat5_read_header (SF_PRIVATE *psf)
{ char name [32] ;
short version, endian ;
- int type, size, flags1, flags2, rows, cols ;
+ int type, flags1, flags2, rows, cols ;
+ unsigned size ;
psf_binheader_readf (psf, "pb", 0, psf->u.cbuf, 124) ;
@@ -359,7 +360,7 @@
{ double samplerate ;
psf_binheader_readf (psf, "d", &samplerate) ;
- LSF_SNPRINTF (name, sizeof (name), "%f\n", samplerate) ;
+ snprintf (name, sizeof (name), "%f\n", samplerate) ;
psf_log_printf (psf, " Val : %s\n", name) ;
psf->sf.samplerate = lrint (samplerate) ;
@@ -448,7 +449,7 @@
if (rows == 0 && cols == 0)
{ psf_log_printf (psf, "*** Error : zero channel count.\n") ;
- return SFE_MAT5_ZERO_CHANNELS ;
+ return SFE_CHANNEL_COUNT_ZERO ;
} ;
psf->sf.channels = rows ;
@@ -498,10 +499,3 @@
return 0 ;
} /* mat5_read_header */
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: dfdb6742-b2be-4be8-b390-d0c674e8bc8e
-*/
Added: freeswitch/trunk/libs/libsndfile/src/mpc2k.c
==============================================================================
--- (empty file)
+++ freeswitch/trunk/libs/libsndfile/src/mpc2k.c Thu May 21 16:09:30 2009
@@ -0,0 +1,207 @@
+/*
+** Copyright (C) 2008-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
+**
+** This program is free software; you can redistribute it and/or modify
+** it under the terms of the GNU Lesser General Public License as published by
+** the Free Software Foundation; either version 2.1 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU Lesser General Public License for more details.
+**
+** You should have received a copy of the GNU Lesser General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#include "sfconfig.h"
+
+#include <stdio.h>
+#include <fcntl.h>
+#include <string.h>
+#include <ctype.h>
+
+#include "sndfile.h"
+#include "sfendian.h"
+#include "common.h"
+
+/*
+** Info from Olivier Tristan <o.tristan at ultimatesoundbank.com>
+**
+** HEADER
+** 2 magic bytes: 1 and 4.
+** 17 char for the name of the sample.
+** 3 bytes: level, tune and channels (0 for channels is mono while 1 is stereo)
+** 4 uint32: sampleStart, loopEnd, sampleFrames and loopLength
+** 1 byte: loopMode (0 no loop, 1 forward looping)
+** 1 byte: number of beat in loop
+** 1 uint16: sampleRate
+**
+** DATA
+** Data are always non compressed 16 bits interleaved
+*/
+
+#define HEADER_LENGTH 42 /* Sum of above data fields. */
+#define HEADER_NAME_LEN 17 /* Length of name string. */
+
+#define SFE_MPC_NO_MARKER 666
+
+/*------------------------------------------------------------------------------
+** Private static functions.
+*/
+
+static int mpc2k_close (SF_PRIVATE *psf) ;
+
+static int mpc2k_write_header (SF_PRIVATE *psf, int calc_length) ;
+static int mpc2k_read_header (SF_PRIVATE *psf) ;
+
+/*------------------------------------------------------------------------------
+** Public function.
+*/
+
+int
+mpc2k_open (SF_PRIVATE *psf)
+{ int subformat ;
+ int error = 0 ;
+
+ if (psf->mode == SFM_READ || (psf->mode == SFM_RDWR && psf->filelength > 0))
+ { if ((error = mpc2k_read_header (psf)))
+ return error ;
+ } ;
+
+ if ((SF_CONTAINER (psf->sf.format)) != SF_FORMAT_MPC2K)
+ return SFE_BAD_OPEN_FORMAT ;
+
+ subformat = SF_CODEC (psf->sf.format) ;
+
+ if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR)
+ { if (mpc2k_write_header (psf, SF_FALSE))
+ return psf->error ;
+
+ psf->write_header = mpc2k_write_header ;
+ } ;
+
+ psf->container_close = mpc2k_close ;
+
+ psf->blockwidth = psf->bytewidth * psf->sf.channels ;
+
+ error = pcm_init (psf) ;
+
+ return error ;
+} /* mpc2k_open */
+
+/*------------------------------------------------------------------------------
+*/
+
+static int
+mpc2k_close (SF_PRIVATE *psf)
+{
+ if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR)
+ mpc2k_write_header (psf, SF_TRUE) ;
+
+ return 0 ;
+} /* mpc2k_close */
+
+static int
+mpc2k_write_header (SF_PRIVATE *psf, int calc_length)
+{ char sample_name [HEADER_NAME_LEN + 1] ;
+ sf_count_t current ;
+
+ if (psf->pipeoffset > 0)
+ return 0 ;
+
+ current = psf_ftell (psf) ;
+
+ if (calc_length)
+ { psf->filelength = psf_get_filelen (psf) ;
+
+ psf->dataoffset = HEADER_LENGTH ;
+ psf->datalength = psf->filelength - psf->dataoffset ;
+
+ psf->sf.frames = psf->datalength / (psf->bytewidth * psf->sf.channels) ;
+ } ;
+
+ /* Reset the current header length to zero. */
+ psf->header [0] = 0 ;
+ psf->headindex = 0 ;
+
+ /*
+ ** Only attempt to seek if we are not writng to a pipe. If we are
+ ** writing to a pipe we shouldn't be here anyway.
+ */
+ if (psf->is_pipe == SF_FALSE)
+ psf_fseek (psf, 0, SEEK_SET) ;
+
+ snprintf (sample_name, sizeof (sample_name), "%s ", psf->filename) ;
+
+ psf_binheader_writef (psf, "e11b", 1, 4, sample_name, make_size_t (HEADER_NAME_LEN)) ;
+ psf_binheader_writef (psf, "e111", 100, 0, (psf->sf.channels - 1) & 1) ;
+ psf_binheader_writef (psf, "et4888", 0, psf->sf.frames, psf->sf.frames, psf->sf.frames) ;
+ psf_binheader_writef (psf, "e112", 0, 1, (uint16_t) psf->sf.samplerate) ;
+
+ /* Always 16 bit little endian data. */
+ psf->bytewidth = 2 ;
+ psf->endian = SF_ENDIAN_LITTLE ;
+
+ psf_fwrite (psf->header, psf->headindex, 1, psf) ;
+
+ if (psf->error)
+ return psf->error ;
+
+ psf->dataoffset = psf->headindex ;
+
+ if (current > 0)
+ psf_fseek (psf, current, SEEK_SET) ;
+
+ return psf->error ;
+} /* mpc2k_write_header */
+
+static int
+mpc2k_read_header (SF_PRIVATE *psf)
+{ char sample_name [HEADER_NAME_LEN + 1] ;
+ unsigned char bytes [4] ;
+ uint32_t sample_start, loop_end, sample_frames, loop_length ;
+ uint16_t sample_rate ;
+
+ psf_binheader_readf (psf, "pebb", 0, bytes, 2, sample_name, make_size_t (HEADER_NAME_LEN)) ;
+
+ if (bytes [0] != 1 || bytes [1] != 4)
+ return SFE_MPC_NO_MARKER ;
+
+ sample_name [HEADER_NAME_LEN] = 0 ;
+
+ psf_log_printf (psf, "MPC2000\n Name : %s\n", sample_name) ;
+
+ psf_binheader_readf (psf, "eb4444", bytes, 3, &sample_start, &loop_end, &sample_frames, &loop_length) ;
+
+ psf->sf.channels = bytes [2] ? 2 : 1 ;
+
+ psf_log_printf (psf, " Level : %d\n Tune : %d\n Stereo : %s\n", bytes [0], bytes [1], bytes [2] ? "Yes" : "No") ;
+
+ psf_log_printf (psf, " Sample start : %d\n Loop end : %d\n Frames : %d\n Length : %d\n", sample_start, loop_end, sample_frames, loop_length) ;
+
+ psf_binheader_readf (psf, "eb2", bytes, 2, &sample_rate) ;
+
+ psf_log_printf (psf, " Loop mode : %s\n Beats : %d\n Sample rate : %d\nEnd\n", bytes [0] ? "None" : "Fwd", bytes [1], sample_rate) ;
+
+ psf->sf.samplerate = sample_rate ;
+
+ psf->sf.format = SF_FORMAT_MPC2K | SF_FORMAT_PCM_16 ;
+
+ psf->dataoffset = psf_ftell (psf) ;
+
+ /* Always 16 bit little endian data. */
+ psf->bytewidth = 2 ;
+ psf->endian = SF_ENDIAN_LITTLE ;
+
+ psf->datalength = psf->filelength - psf->dataoffset ;
+ psf->blockwidth = psf->sf.channels * psf->bytewidth ;
+ psf->sf.frames = psf->datalength / psf->blockwidth ;
+
+ psf->sf.frames = (psf->filelength - psf->dataoffset) / psf->blockwidth ;
+
+ return 0 ;
+} /* mpc2k_read_header */
+
Modified: freeswitch/trunk/libs/libsndfile/src/ms_adpcm.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/src/ms_adpcm.c (original)
+++ freeswitch/trunk/libs/libsndfile/src/ms_adpcm.c Thu May 21 16:09:30 2009
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 1999-2005 Erik de Castro Lopo <erikd at mega-nerd.com>
+** Copyright (C) 1999-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU Lesser General Public License as published by
@@ -21,10 +21,10 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <math.h>
#include "sndfile.h"
#include "sfendian.h"
-#include "float_cast.h"
#include "common.h"
#include "wav_w64.h"
@@ -154,6 +154,11 @@
pms->blocksize = blockalign ;
pms->samplesperblock = samplesperblock ;
+ if (pms->blocksize == 0)
+ { psf_log_printf (psf, "*** Error : pms->blocksize should not be zero.\n") ;
+ return SFE_INTERNAL ;
+ } ;
+
if (psf->mode == SFM_READ)
{ pms->dataremaining = psf->datalength ;
@@ -164,7 +169,9 @@
count = 2 * (pms->blocksize - 6 * pms->channels) / pms->channels ;
if (pms->samplesperblock != count)
- psf_log_printf (psf, "*** Warning : samplesperblock shoud be %d.\n", count) ;
+ { psf_log_printf (psf, "*** Error : samplesperblock should be %d.\n", count) ;
+ return SFE_INTERNAL ;
+ } ;
psf->sf.frames = (psf->datalength / pms->blocksize) * pms->samplesperblock ;
@@ -825,10 +832,4 @@
return ;
} /* choose_predictor */
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: a98908a3-5305-4935-872b-77d6a86c330f
-*/
+
Modified: freeswitch/trunk/libs/libsndfile/src/nist.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/src/nist.c (original)
+++ freeswitch/trunk/libs/libsndfile/src/nist.c Thu May 21 16:09:30 2009
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 1999-2004 Erik de Castro Lopo <erikd at mega-nerd.com>
+** Copyright (C) 1999-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU Lesser General Public License as published by
@@ -63,10 +63,10 @@
{ if (psf->is_pipe)
return SFE_NO_PIPE_WRITE ;
- if ((psf->sf.format & SF_FORMAT_TYPEMASK) != SF_FORMAT_NIST)
+ if ((SF_CONTAINER (psf->sf.format)) != SF_FORMAT_NIST)
return SFE_BAD_OPEN_FORMAT ;
- psf->endian = psf->sf.format & SF_FORMAT_ENDMASK ;
+ psf->endian = SF_ENDIAN (psf->sf.format) ;
if (psf->endian == 0 || psf->endian == SF_ENDIAN_CPU)
psf->endian = (CPU_IS_BIG_ENDIAN) ? SF_ENDIAN_BIG : SF_ENDIAN_LITTLE ;
@@ -81,7 +81,7 @@
psf->container_close = nist_close ;
- switch (psf->sf.format & SF_FORMAT_SUBMASK)
+ switch (SF_CODEC (psf->sf.format))
{ case SF_FORMAT_PCM_S8 :
error = pcm_init (psf) ;
break ;
@@ -175,18 +175,18 @@
} ;
} ;
- if ((cptr = strstr (psf_header, "channel_count -i ")))
+ if ((cptr = strstr (psf_header, "channel_count -i ")) != NULL)
sscanf (cptr, "channel_count -i %d", &(psf->sf.channels)) ;
- if ((cptr = strstr (psf_header, "sample_rate -i ")))
+ if ((cptr = strstr (psf_header, "sample_rate -i ")) != NULL)
sscanf (cptr, "sample_rate -i %d", &(psf->sf.samplerate)) ;
- if ((cptr = strstr (psf_header, "sample_count -i ")))
- { sscanf (psf_header, "sample_count -i %ld", &samples) ;
+ if ((cptr = strstr (psf_header, "sample_count -i ")) != NULL)
+ { sscanf (cptr, "sample_count -i %ld", &samples) ;
psf->sf.frames = samples ;
} ;
- if ((cptr = strstr (psf_header, "sample_n_bytes -i ")))
+ if ((cptr = strstr (psf_header, "sample_n_bytes -i ")) != NULL)
sscanf (cptr, "sample_n_bytes -i %d", &(psf->bytewidth)) ;
/* Default endian-ness (for 8 bit, u-law, A-law. */
@@ -307,7 +307,7 @@
psf_asciiheader_printf (psf, "channel_count -i %d\n", psf->sf.channels) ;
psf_asciiheader_printf (psf, "sample_rate -i %d\n", psf->sf.samplerate) ;
- switch (psf->sf.format & SF_FORMAT_SUBMASK)
+ switch (SF_CODEC (psf->sf.format))
{ case SF_FORMAT_PCM_S8 :
psf_asciiheader_printf (psf, "sample_coding -s3 pcm\n") ;
psf_asciiheader_printf (psf, "sample_n_bytes -i 1\n"
@@ -357,11 +357,3 @@
return psf->error ;
} /* nist_write_header */
-
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: b45ed85d-9e22-4ad9-b78c-4b58b67152a8
-*/
Modified: freeswitch/trunk/libs/libsndfile/src/ogg.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/src/ogg.c (original)
+++ freeswitch/trunk/libs/libsndfile/src/ogg.c Thu May 21 16:09:30 2009
@@ -1,5 +1,6 @@
/*
-** Copyright (C) 2002-2004 Erik de Castro Lopo <erikd at mega-nerd.com>
+** Copyright (C) 2002-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
+** Copyright (C) 2007 John ffitch
**
** This program is free software ; you can redistribute it and/or modify
** it under the terms of the GNU Lesser General Public License as published by
@@ -8,7 +9,7 @@
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY ; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public License
@@ -16,29 +17,1142 @@
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
+/*
+** Much of this code is based on the examples in libvorbis from the
+** XIPHOPHORUS Company http://www.xiph.org/ which has a BSD-style Licence
+** Copyright (c) 2002, Xiph.org Foundation
+**
+** Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions
+** are met:
+**
+** - Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+**
+** - Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in the
+** documentation and/or other materials provided with the distribution.
+**
+** - Neither the name of the Xiph.org Foundation nor the names of its
+** contributors may be used to endorse or promote products derived from
+** this software without specific prior written permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION
+** OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE,
+** DATA, OR PROFITS ; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
#include "sfconfig.h"
#include <stdio.h>
#include <fcntl.h>
#include <string.h>
#include <ctype.h>
+#include <time.h>
+#include <math.h>
+
+#if HAVE_UNISTD_H
+#include <unistd.h>
+#endif
#include "sndfile.h"
#include "sfendian.h"
#include "common.h"
+#if HAVE_EXTERNAL_LIBS
+
+#include <vorbis/codec.h>
+#include <vorbis/vorbisenc.h>
+
+typedef int convert_func (int, void *, int, int, float **) ;
+
+static int ogg_read_header (SF_PRIVATE *psf, int log_data) ;
+static int ogg_write_header (SF_PRIVATE *psf, int calc_length) ;
+static int ogg_close (SF_PRIVATE *psf) ;
+static int ogg_command (SF_PRIVATE *psf, int command, void *data, int datasize) ;
+static sf_count_t ogg_seek (SF_PRIVATE *psf, int mode, sf_count_t offset) ;
+static sf_count_t ogg_read_s (SF_PRIVATE *psf, short *ptr, sf_count_t len) ;
+static sf_count_t ogg_read_i (SF_PRIVATE *psf, int *ptr, sf_count_t len) ;
+static sf_count_t ogg_read_f (SF_PRIVATE *psf, float *ptr, sf_count_t len) ;
+static sf_count_t ogg_read_d (SF_PRIVATE *psf, double *ptr, sf_count_t len) ;
+static sf_count_t ogg_write_s (SF_PRIVATE *psf, const short *ptr, sf_count_t len) ;
+static sf_count_t ogg_write_i (SF_PRIVATE *psf, const int *ptr, sf_count_t len) ;
+static sf_count_t ogg_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t len) ;
+static sf_count_t ogg_write_d (SF_PRIVATE *psf, const double *ptr, sf_count_t len) ;
+static sf_count_t ogg_read_sample (SF_PRIVATE *psf, void *ptr, sf_count_t lens, convert_func *transfn) ;
+static sf_count_t ogg_length (SF_PRIVATE *psf) ;
+
+typedef struct
+{ int id ;
+ const char *name ;
+} STR_PAIRS ;
+
+static STR_PAIRS vorbis_metatypes [] =
+{ { SF_STR_TITLE, "Title" },
+ { SF_STR_COPYRIGHT, "Copyright" },
+ { SF_STR_SOFTWARE, "Software" },
+ { SF_STR_ARTIST, "Artist" },
+ { SF_STR_COMMENT, "Comment" },
+ { SF_STR_DATE, "Date" },
+ { SF_STR_ALBUM, "Album" },
+ { SF_STR_LICENSE, "License" },
+} ;
+
+typedef struct
+{ /* Sync and verify incoming physical bitstream */
+ ogg_sync_state oy ;
+ /* Take physical pages, weld into a logical stream of packets */
+ ogg_stream_state os ;
+ /* One Ogg bitstream page. Vorbis packets are inside */
+ ogg_page og ;
+ /* One raw packet of data for decode */
+ ogg_packet op ;
+ int eos ;
+} OGG_PRIVATE ;
+
+typedef struct
+{ /* Count current location */
+ sf_count_t loc ;
+ /* Struct that stores all the static vorbis bitstream settings */
+ vorbis_info vi ;
+ /* Struct that stores all the bitstream user comments */
+ vorbis_comment vc ;
+ /* Ventral working state for the packet->PCM decoder */
+ vorbis_dsp_state vd ;
+ /* Local working space for packet->PCM decode */
+ vorbis_block vb ;
+
+ /* Encoding quality in range [0.0, 1.0]. */
+ double quality ;
+} VORBIS_PRIVATE ;
+
+static int
+ogg_read_header (SF_PRIVATE *psf, int log_data)
+{
+ OGG_PRIVATE *odata = (OGG_PRIVATE *) psf->container_data ;
+ VORBIS_PRIVATE *vdata = (VORBIS_PRIVATE *) psf->codec_data ;
+ char *buffer ;
+ int bytes ;
+ int i, nn ;
+
+ odata->eos = 0 ;
+
+ /* Weird stuff happens if these aren't called. */
+ ogg_stream_reset (&odata->os) ;
+ ogg_sync_reset (&odata->oy) ;
+
+ /*
+ ** Grab some data at the head of the stream. We want the first page
+ ** (which is guaranteed to be small and only contain the Vorbis
+ ** stream initial header) We need the first page to get the stream
+ ** serialno.
+ */
+
+ /* Expose the buffer */
+ buffer = ogg_sync_buffer (&odata->oy, 4096L) ;
+
+ /* Grab the part of the header that has already been read. */
+ memcpy (buffer, psf->header, psf->headindex) ;
+ bytes = psf->headindex ;
+
+ /* Submit a 4k block to libvorbis' Ogg layer */
+ bytes += psf_fread (buffer + psf->headindex, 1, 4096 - psf->headindex, psf) ;
+ ogg_sync_wrote (&odata->oy, bytes) ;
+
+ /* Get the first page. */
+ if ((nn = ogg_sync_pageout (&odata->oy, &odata->og)) != 1)
+ {
+ /* Have we simply run out of data? If so, we're done. */
+ if (bytes < 4096)
+ return 0 ;
+
+ /* Error case. Must not be Vorbis data */
+ psf_log_printf (psf, "Input does not appear to be an Ogg bitstream.\n") ;
+ return SFE_MALFORMED_FILE ;
+ } ;
+
+ /*
+ ** Get the serial number and set up the rest of decode.
+ ** Serialno first ; use it to set up a logical stream.
+ */
+ ogg_stream_clear (&odata->os) ;
+ ogg_stream_init (&odata->os, ogg_page_serialno (&odata->og)) ;
+
+ /*
+ ** This function (ogg_read_header) gets called multiple times, so the OGG
+ ** and vorbis structs have to be cleared every time we pass through to
+ ** prevent memory leaks.
+ */
+ vorbis_block_clear (&vdata->vb) ;
+ vorbis_dsp_clear (&vdata->vd) ;
+ vorbis_comment_clear (&vdata->vc) ;
+ vorbis_info_clear (&vdata->vi) ;
+
+ /*
+ ** Extract the initial header from the first page and verify that the
+ ** Ogg bitstream is in fact Vorbis data.
+ **
+ ** I handle the initial header first instead of just having the code
+ ** read all three Vorbis headers at once because reading the initial
+ ** header is an easy way to identify a Vorbis bitstream and it's
+ ** useful to see that functionality seperated out.
+ */
+ vorbis_info_init (&vdata->vi) ;
+ vorbis_comment_init (&vdata->vc) ;
+
+ if (ogg_stream_pagein (&odata->os, &odata->og) < 0)
+ { /* Error ; stream version mismatch perhaps. */
+ psf_log_printf (psf, "Error reading first page of Ogg bitstream data\n") ;
+ return SFE_MALFORMED_FILE ;
+ } ;
+
+ if (ogg_stream_packetout (&odata->os, &odata->op) != 1)
+ { /* No page? must not be vorbis. */
+ psf_log_printf (psf, "Error reading initial header packet.\n") ;
+ return SFE_MALFORMED_FILE ;
+ } ;
+
+ if (vorbis_synthesis_headerin (&vdata->vi, &vdata->vc, &odata->op) < 0)
+ { /* Error case ; not a vorbis header. */
+ psf_log_printf (psf, "This Ogg bitstream does not contain Vorbis audio data.\n") ;
+ return SFE_MALFORMED_FILE ;
+ } ;
+
+ /*
+ ** Common Ogg metadata fields?
+ ** TITLE, VERSION, ALBUM, TRACKNUMBER, ARTIST, PERFORMER, COPYRIGHT, LICENSE,
+ ** ORGANIZATION, DESCRIPTION, GENRE, DATE, LOCATION, CONTACT, ISRC,
+ */
+
+ if (log_data)
+ { int k ;
+
+ for (k = 0 ; k < ARRAY_LEN (vorbis_metatypes) ; k++)
+ { char *dd ;
+
+ dd = vorbis_comment_query (&vdata->vc, vorbis_metatypes [k].name, 0) ;
+ if (dd == NULL)
+ continue ;
+ psf_store_string (psf, vorbis_metatypes [k].id, dd) ;
+ } ;
+ } ;
+
+ /*
+ ** At this point, we're sure we're Vorbis. We've set up the logical (Ogg)
+ ** bitstream decoder. Get the comment and codebook headers and set up the
+ ** Vorbis decoder.
+ **
+ ** The next two packets in order are the comment and codebook headers.
+ ** They're likely large and may span multiple pages. Thus we reead
+ ** and submit data until we get our two pacakets, watching that no
+ ** pages are missing. If a page is missing, error out ; losing a
+ ** header page is the only place where missing data is fatal.
+ */
+
+ i = 0 ; /* Count of number of packets read */
+ while (i < 2)
+ { int result = ogg_sync_pageout (&odata->oy, &odata->og) ;
+ if (result == 0)
+ { /* Need more data */
+ buffer = ogg_sync_buffer (&odata->oy, 4096) ;
+ bytes = psf_fread (buffer, 1, 4096, psf) ;
+
+ if (bytes == 0 && i < 2)
+ { psf_log_printf (psf, "End of file before finding all Vorbis headers!\n") ;
+ return SFE_MALFORMED_FILE ;
+ } ;
+ nn = ogg_sync_wrote (&odata->oy, bytes) ;
+ }
+ else if (result == 1)
+ { /*
+ ** Don't complain about missing or corrupt data yet. We'll
+ ** catch it at the packet output phase.
+ **
+ ** We can ignore any errors here as they'll also become apparent
+ ** at packetout.
+ */
+ nn = ogg_stream_pagein (&odata->os, &odata->og) ;
+ while (i < 2)
+ { result = ogg_stream_packetout (&odata->os, &odata->op) ;
+ if (result == 0)
+ break ;
+ if (result < 0)
+ { /* Uh oh ; data at some point was corrupted or missing!
+ ** We can't tolerate that in a header. Die. */
+ psf_log_printf (psf, "Corrupt secondary header. Exiting.\n") ;
+ return SFE_MALFORMED_FILE ;
+ } ;
+
+ vorbis_synthesis_headerin (&vdata->vi, &vdata->vc, &odata->op) ;
+ i++ ;
+ } ;
+ } ;
+ } ;
+
+ if (log_data)
+ { int printed_metadata_msg = 0 ;
+ int k ;
+
+ psf_log_printf (psf, "\nBitstream is %d channel, %D Hz\n", vdata->vi.channels, vdata->vi.rate) ;
+ psf_log_printf (psf, "Encoded by: %s\n", vdata->vc.vendor) ;
+
+ /* Throw the comments plus a few lines about the bitstream we're decoding. */
+ for (k = 0 ; k < ARRAY_LEN (vorbis_metatypes) ; k++)
+ { char *dd ;
+
+ dd = vorbis_comment_query (&vdata->vc, vorbis_metatypes [k].name, 0) ;
+ if (dd == NULL)
+ continue ;
+
+ if (printed_metadata_msg == 0)
+ { psf_log_printf (psf, "Metadata :\n") ;
+ printed_metadata_msg = 1 ;
+ } ;
+
+ psf_store_string (psf, vorbis_metatypes [k].id, dd) ;
+ psf_log_printf (psf, " %-10s : %s\n", vorbis_metatypes [k].name, dd) ;
+ } ;
+
+ psf_log_printf (psf, "End\n") ;
+ } ;
+
+ psf->sf.samplerate = vdata->vi.rate ;
+ psf->sf.channels = vdata->vi.channels ;
+ psf->sf.format = SF_FORMAT_OGG | SF_FORMAT_VORBIS ;
+
+ /* OK, got and parsed all three headers. Initialize the Vorbis
+ ** packet->PCM decoder.
+ ** Central decode state. */
+ vorbis_synthesis_init (&vdata->vd, &vdata->vi) ;
+
+ /* Local state for most of the decode so multiple block decodes can
+ ** proceed in parallel. We could init multiple vorbis_block structures
+ ** for vd here. */
+ vorbis_block_init (&vdata->vd, &vdata->vb) ;
+
+ vdata->loc = 0 ;
+
+ return 0 ;
+} /* ogg_read_header */
+
+static int
+ogg_write_header (SF_PRIVATE *psf, int UNUSED (calc_length))
+{
+ OGG_PRIVATE *odata = (OGG_PRIVATE *) psf->container_data ;
+ VORBIS_PRIVATE *vdata = (VORBIS_PRIVATE *) psf->codec_data ;
+ int k, ret ;
+
+ vorbis_info_init (&vdata->vi) ;
+
+ /* The style of encoding should be selectable here, VBR quality mode. */
+ ret = vorbis_encode_init_vbr (&vdata->vi, psf->sf.channels, psf->sf.samplerate, vdata->quality) ;
+
+#if 0
+ ret = vorbis_encode_init (&vdata->vi, psf->sf.channels, psf->sf.samplerate, -1, 128000, -1) ; /* average bitrate mode */
+ ret = ( vorbis_encode_setup_managed (&vdata->vi, psf->sf.channels,
+ psf->sf.samplerate, -1, 128000, -1) ||
+ vorbis_encode_ctl (&vdata->vi, OV_ECTL_RATEMANAGE_AVG, NULL) ||
+ vorbis_encode_setup_init (&vdata->vi)) ;
+#endif
+ if (ret)
+ return SFE_BAD_OPEN_FORMAT ;
+
+ vdata->loc = 0 ;
+
+ /* add a comment */
+ vorbis_comment_init (&vdata->vc) ;
+
+ vorbis_comment_add_tag (&vdata->vc, "ENCODER", "libsndfile") ;
+ for (k = 0 ; k < SF_MAX_STRINGS ; k++)
+ { const char * name ;
+
+ if (psf->strings [k].type == 0)
+ break ;
+
+ switch (psf->strings [k].type)
+ { case SF_STR_TITLE : name = "TITLE" ; break ;
+ case SF_STR_COPYRIGHT : name = "COPYRIGHT" ; break ;
+ case SF_STR_SOFTWARE : name = "SOFTWARE" ; break ;
+ case SF_STR_ARTIST : name = "ARTIST" ; break ;
+ case SF_STR_COMMENT : name = "COMMENT" ; break ;
+ case SF_STR_DATE : name = "DATE" ; break ;
+ case SF_STR_ALBUM : name = "ALBUM" ; break ;
+ case SF_STR_LICENSE : name = "LICENSE" ; break ;
+ default : continue ;
+ } ;
+
+ vorbis_comment_add_tag (&vdata->vc, name, psf->strings [k].str) ;
+ } ;
+
+ /* set up the analysis state and auxiliary encoding storage */
+ vorbis_analysis_init (&vdata->vd, &vdata->vi) ;
+ vorbis_block_init (&vdata->vd, &vdata->vb) ;
+
+ /*
+ ** Set up our packet->stream encoder.
+ ** Pick a random serial number ; that way we can more likely build
+ ** chained streams just by concatenation.
+ */
+
+ ogg_stream_init (&odata->os, psf_rand_int32 ()) ;
+
+ /* Vorbis streams begin with three headers ; the initial header (with
+ most of the codec setup parameters) which is mandated by the Ogg
+ bitstream spec. The second header holds any comment fields. The
+ third header holds the bitstream codebook. We merely need to
+ make the headers, then pass them to libvorbis one at a time ;
+ libvorbis handles the additional Ogg bitstream constraints */
+
+ { ogg_packet header ;
+ ogg_packet header_comm ;
+ ogg_packet header_code ;
+ int result ;
+
+ vorbis_analysis_headerout (&vdata->vd, &vdata->vc, &header, &header_comm, &header_code) ;
+ ogg_stream_packetin (&odata->os, &header) ; /* automatically placed in its own page */
+ ogg_stream_packetin (&odata->os, &header_comm) ;
+ ogg_stream_packetin (&odata->os, &header_code) ;
+
+ /* This ensures the actual
+ * audio data will start on a new page, as per spec
+ */
+ while ((result = ogg_stream_flush (&odata->os, &odata->og)) != 0)
+ { psf_fwrite (odata->og.header, 1, odata->og.header_len, psf) ;
+ psf_fwrite (odata->og.body, 1, odata->og.body_len, psf) ;
+ } ;
+ }
+
+ return 0 ;
+} /* ogg_write_header */
+
+static int
+ogg_close (SF_PRIVATE *psf)
+{
+ OGG_PRIVATE *odata = (OGG_PRIVATE *) psf->container_data ;
+ VORBIS_PRIVATE *vdata = (VORBIS_PRIVATE *) psf->codec_data ;
+
+ if (odata == NULL || vdata == NULL)
+ return 0 ;
+
+ /* Clean up this logical bitstream ; before exit we shuld see if we're
+ ** followed by another [chained]. */
+
+ if (psf->mode == SFM_WRITE)
+ {
+ if (psf->write_current <= 0)
+ ogg_write_header (psf, 0) ;
+
+ vorbis_analysis_wrote (&vdata->vd, 0) ;
+ while (vorbis_analysis_blockout (&vdata->vd, &vdata->vb) == 1)
+ {
+
+ /* analysis, assume we want to use bitrate management */
+ vorbis_analysis (&vdata->vb, NULL) ;
+ vorbis_bitrate_addblock (&vdata->vb) ;
+
+ while (vorbis_bitrate_flushpacket (&vdata->vd, &odata->op))
+ { /* weld the packet into the bitstream */
+ ogg_stream_packetin (&odata->os, &odata->op) ;
+
+ /* write out pages (if any) */
+ while (!odata->eos)
+ { int result = ogg_stream_pageout (&odata->os, &odata->og) ;
+ if (result == 0) break ;
+ psf_fwrite (odata->og.header, 1, odata->og.header_len, psf) ;
+ psf_fwrite (odata->og.body, 1, odata->og.body_len, psf) ;
+
+ /* this could be set above, but for illustrative purposes, I do
+ it here (to show that vorbis does know where the stream ends) */
+
+ if (ogg_page_eos (&odata->og)) odata->eos = 1 ;
+ }
+ }
+ }
+ }
+
+ /* ogg_page and ogg_packet structs always point to storage in
+ libvorbis. They are never freed or manipulated directly */
+
+ vorbis_block_clear (&vdata->vb) ;
+ vorbis_dsp_clear (&vdata->vd) ;
+ vorbis_comment_clear (&vdata->vc) ;
+ vorbis_info_clear (&vdata->vi) ; /* must be called last */
+ /* should look here to reopen if chained */
+
+ /* OK, clean up the framer */
+ ogg_sync_clear (&odata->oy) ;
+ ogg_stream_clear (&odata->os) ;
+
+ return 0 ;
+} /* ogg_close */
+
int
-ogg_open (SF_PRIVATE *psf)
-{ if (psf)
- return SFE_UNIMPLEMENTED ;
- return (psf && 0) ;
+ogg_open (SF_PRIVATE *psf)
+{ OGG_PRIVATE* odata = calloc (1, sizeof (OGG_PRIVATE)) ;
+ VORBIS_PRIVATE* vdata = calloc (1, sizeof (VORBIS_PRIVATE)) ;
+ int error = 0 ;
+
+ psf->container_data = odata ;
+ psf->codec_data = vdata ;
+
+ if (psf->mode == SFM_RDWR)
+ return SFE_BAD_MODE_RW ;
+
+#if HAVE_VORBIS_VERSION_STRING
+ psf_log_printf (psf, "Vorbis library version : %s\n", vorbis_version_string ()) ;
+#endif
+
+ if (psf->mode == SFM_READ)
+ { /* Call this here so it only gets called once, so no memory is leaked. */
+ ogg_sync_init (&odata->oy) ;
+
+ if ((error = ogg_read_header (psf, 1)))
+ return error ;
+
+ psf->read_short = ogg_read_s ;
+ psf->read_int = ogg_read_i ;
+ psf->read_float = ogg_read_f ;
+ psf->read_double = ogg_read_d ;
+ psf->sf.frames = ogg_length (psf) ;
+ } ;
+
+ psf->container_close = ogg_close ;
+ if (psf->mode == SFM_WRITE)
+ {
+ /* Set the default vorbis quality here. */
+ vdata->quality = 0.4 ;
+
+ psf->write_header = ogg_write_header ;
+ psf->write_short = ogg_write_s ;
+ psf->write_int = ogg_write_i ;
+ psf->write_float = ogg_write_f ;
+ psf->write_double = ogg_write_d ;
+
+ psf->sf.frames = SF_COUNT_MAX ; /* Unknown really */
+ psf->str_flags = SF_STR_ALLOW_START ;
+ } ;
+
+ psf->bytewidth = 1 ;
+ psf->blockwidth = psf->bytewidth * psf->sf.channels ;
+
+ psf->seek = ogg_seek ;
+ psf->command = ogg_command ;
+
+ /* FIXME, FIXME, FIXME : Hack these here for now and correct later. */
+ psf->sf.format = SF_FORMAT_OGG | SF_FORMAT_VORBIS ;
+ psf->sf.sections = 1 ;
+
+ psf->datalength = 1 ;
+ psf->dataoffset = 0 ;
+ /* End FIXME. */
+
+ return error ;
} /* ogg_open */
+static int
+ogg_command (SF_PRIVATE *psf, int command, void * data, int datasize)
+{ VORBIS_PRIVATE *vdata = (VORBIS_PRIVATE *) psf->codec_data ;
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: 9ff1fe9c-629e-4e9c-9ef5-3d0eb1e427a0
+ switch (command)
+ { case SFC_SET_VBR_ENCODING_QUALITY :
+ if (data == NULL || datasize != sizeof (double))
+ return 1 ;
+
+ if (psf->have_written)
+ return 1 ;
+
+ vdata->quality = *((double *) data) ;
+
+ /* Clip range. */
+ vdata->quality = SF_MAX (0.0, SF_MIN (1.0, vdata->quality)) ;
+
+ psf_log_printf (psf, "%s : Setting SFC_SET_VBR_ENCODING_QUALITY to %f.\n", __func__, vdata->quality) ;
+ break ;
+
+ default :
+ return 0 ;
+ } ;
+
+ return 0 ;
+} /* ogg_command */
+
+static int
+ogg_rnull (int samples, void *UNUSED (vptr), int UNUSED (off) , int channels, float **UNUSED (pcm))
+{
+ return samples * channels ;
+} /* ogg_rnull */
+
+static int
+ogg_rshort (int samples, void *vptr, int off, int channels, float **pcm)
+{
+ short *ptr = (short*) vptr + off ;
+ int i = 0, j, n ;
+ for (j = 0 ; j < samples ; j++)
+ for (n = 0 ; n < channels ; n++)
+ ptr [i++] = lrintf (pcm [n][j] * 32767.0f) ;
+ return i ;
+} /* ogg_rshort */
+
+static int
+ogg_rint (int samples, void *vptr, int off, int channels, float **pcm)
+{
+ int *ptr = (int*) vptr + off ;
+ int i = 0, j, n ;
+
+ for (j = 0 ; j < samples ; j++)
+ for (n = 0 ; n < channels ; n++)
+ ptr [i++] = lrintf (pcm [n][j] * 2147483647.0f) ;
+ return i ;
+} /* ogg_rint */
+
+static int
+ogg_rfloat (int samples, void *vptr, int off, int channels, float **pcm)
+{
+ float *ptr = (float*) vptr + off ;
+ int i = 0, j, n ;
+ for (j = 0 ; j < samples ; j++)
+ for (n = 0 ; n < channels ; n++)
+ ptr [i++] = pcm [n][j] ;
+ return i ;
+} /* ogg_rfloat */
+
+static int
+ogg_rdouble (int samples, void *vptr, int off, int channels, float **pcm)
+{
+ double *ptr = (double*) vptr + off ;
+ int i = 0, j, n ;
+ for (j = 0 ; j < samples ; j++)
+ for (n = 0 ; n < channels ; n++)
+ ptr [i++] = pcm [n][j] ;
+ return i ;
+} /* ogg_rdouble */
+
+
+static sf_count_t
+ogg_read_sample (SF_PRIVATE *psf, void *ptr, sf_count_t lens, convert_func *transfn)
+{
+ VORBIS_PRIVATE *vdata = psf->codec_data ;
+ OGG_PRIVATE *odata = psf->container_data ;
+ int len, samples, i = 0 ;
+ float **pcm ;
+
+ len = lens / psf->sf.channels ;
+
+ while ((samples = vorbis_synthesis_pcmout (&vdata->vd, &pcm)) > 0)
+ { if (samples > len) samples = len ;
+ i += transfn (samples, ptr, i, psf->sf.channels, pcm) ;
+ len -= samples ;
+ /* tell libvorbis how many samples we actually consumed */
+ vorbis_synthesis_read (&vdata->vd, samples) ;
+ vdata->loc += samples ;
+ if (len == 0)
+ return i ; /* Is this necessary */
+ }
+ goto start0 ; /* Jump into the nasty nest */
+ while (len > 0 && !odata->eos)
+ {
+ while (len > 0 && !odata->eos)
+ { int result = ogg_sync_pageout (&odata->oy, &odata->og) ;
+ if (result == 0) break ; /* need more data */
+ if (result < 0)
+ { /* missing or corrupt data at this page position */
+ psf_log_printf (psf, "Corrupt or missing data in bitstream ; continuing...\n") ;
+ }
+ else
+ { /* can safely ignore errors at this point */
+ ogg_stream_pagein (&odata->os, &odata->og) ;
+ start0:
+ while (1)
+ { result = ogg_stream_packetout (&odata->os, &odata->op) ;
+ if (result == 0)
+ break ; /* need more data */
+ if (result < 0)
+ { /* missing or corrupt data at this page position */
+ /* no reason to complain ; already complained above */
+ }
+ else
+ { /* we have a packet. Decode it */
+ if (vorbis_synthesis (&vdata->vb, &odata->op) == 0) /* test for success! */
+ vorbis_synthesis_blockin (&vdata->vd, &vdata->vb) ;
+ /*
+ **pcm is a multichannel float vector. In stereo, for
+ example, pcm [0] is left, and pcm [1] is right. samples is
+ the size of each channel. Convert the float values
+ (-1.<=range<=1.) to whatever PCM format and write it out */
+
+ while ((samples = vorbis_synthesis_pcmout (&vdata->vd, &pcm)) > 0)
+ { if (samples>len) samples = len ;
+ i += transfn (samples, ptr, i, psf->sf.channels, pcm) ;
+ len -= samples ;
+ /* tell libvorbis how many samples we actually consumed */
+ vorbis_synthesis_read (&vdata->vd, samples) ;
+ vdata->loc += samples ;
+ if (len == 0)
+ return i ; /* Is this necessary */
+ } ;
+ }
+ }
+ if (ogg_page_eos (&odata->og)) odata->eos = 1 ;
+ }
+ }
+ if (!odata->eos)
+ { char *buffer ;
+ int bytes ;
+ buffer = ogg_sync_buffer (&odata->oy, 4096) ;
+ bytes = psf_fread (buffer, 1, 4096, psf) ;
+ ogg_sync_wrote (&odata->oy, bytes) ;
+ if (bytes == 0) odata->eos = 1 ;
+ }
+ }
+ return i ;
+} /* ogg_read_sample */
+
+static sf_count_t
+ogg_read_s (SF_PRIVATE *psf, short *ptr, sf_count_t lens)
+{ return ogg_read_sample (psf, (void*) ptr, lens, ogg_rshort) ;
+} /* ogg_read_s */
+
+static sf_count_t
+ogg_read_i (SF_PRIVATE *psf, int *ptr, sf_count_t lens)
+{ return ogg_read_sample (psf, (void*) ptr, lens, ogg_rint) ;
+} /* ogg_read_i */
+
+static sf_count_t
+ogg_read_f (SF_PRIVATE *psf, float *ptr, sf_count_t lens)
+{ return ogg_read_sample (psf, (void*) ptr, lens, ogg_rfloat) ;
+} /* ogg_read_f */
+
+static sf_count_t
+ogg_read_d (SF_PRIVATE *psf, double *ptr, sf_count_t lens)
+{ return ogg_read_sample (psf, (void*) ptr, lens, ogg_rdouble) ;
+} /* ogg_read_d */
+
+/*==============================================================================
*/
+
+static void
+ogg_write_samples (SF_PRIVATE *psf, OGG_PRIVATE *odata, VORBIS_PRIVATE *vdata, int in_frames)
+{
+ vorbis_analysis_wrote (&vdata->vd, in_frames) ;
+
+ /*
+ ** Vorbis does some data preanalysis, then divvies up blocks for
+ ** more involved (potentially parallel) processing. Get a single
+ ** block for encoding now.
+ */
+ while (vorbis_analysis_blockout (&vdata->vd, &vdata->vb) == 1)
+ {
+ /* analysis, assume we want to use bitrate management */
+ vorbis_analysis (&vdata->vb, NULL) ;
+ vorbis_bitrate_addblock (&vdata->vb) ;
+
+ while (vorbis_bitrate_flushpacket (&vdata->vd, &odata->op))
+ {
+ /* weld the packet into the bitstream */
+ ogg_stream_packetin (&odata->os, &odata->op) ;
+
+ /* write out pages (if any) */
+ while (!odata->eos)
+ { int result = ogg_stream_pageout (&odata->os, &odata->og) ;
+ if (result == 0)
+ break ;
+ psf_fwrite (odata->og.header, 1, odata->og.header_len, psf) ;
+ psf_fwrite (odata->og.body, 1, odata->og.body_len, psf) ;
+
+ /* This could be set above, but for illustrative purposes, I do
+ ** it here (to show that vorbis does know where the stream ends) */
+ if (ogg_page_eos (&odata->og))
+ odata->eos = 1 ;
+ } ;
+ } ;
+ } ;
+
+ vdata->loc += in_frames ;
+} /* ogg_write_data */
+
+
+static sf_count_t
+ogg_write_s (SF_PRIVATE *psf, const short *ptr, sf_count_t lens)
+{
+ int i, m, j = 0 ;
+ OGG_PRIVATE *odata = (OGG_PRIVATE *) psf->container_data ;
+ VORBIS_PRIVATE *vdata = (VORBIS_PRIVATE *) psf->codec_data ;
+ int in_frames = lens / psf->sf.channels ;
+ float **buffer = vorbis_analysis_buffer (&vdata->vd, in_frames) ;
+ for (i = 0 ; i < in_frames ; i++)
+ for (m = 0 ; m < psf->sf.channels ; m++)
+ buffer [m][i] = (float) (ptr [j++]) / 32767.0f ;
+
+ ogg_write_samples (psf, odata, vdata, in_frames) ;
+
+ return lens ;
+} /* ogg_write_s */
+
+static sf_count_t
+ogg_write_i (SF_PRIVATE *psf, const int *ptr, sf_count_t lens)
+{ int i, m, j = 0 ;
+ OGG_PRIVATE *odata = (OGG_PRIVATE *) psf->container_data ;
+ VORBIS_PRIVATE *vdata = (VORBIS_PRIVATE *) psf->codec_data ;
+ int in_frames = lens / psf->sf.channels ;
+ float **buffer = vorbis_analysis_buffer (&vdata->vd, in_frames) ;
+ for (i = 0 ; i < in_frames ; i++)
+ for (m = 0 ; m < psf->sf.channels ; m++)
+ buffer [m][i] = (float) (ptr [j++]) / 2147483647.0f ;
+
+ ogg_write_samples (psf, odata, vdata, in_frames) ;
+
+ return lens ;
+} /* ogg_write_i */
+
+static sf_count_t
+ogg_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t lens)
+{ int i, m, j = 0 ;
+ OGG_PRIVATE *odata = (OGG_PRIVATE *) psf->container_data ;
+ VORBIS_PRIVATE *vdata = (VORBIS_PRIVATE *) psf->codec_data ;
+ int in_frames = lens / psf->sf.channels ;
+ float **buffer = vorbis_analysis_buffer (&vdata->vd, in_frames) ;
+ for (i = 0 ; i < in_frames ; i++)
+ for (m = 0 ; m < psf->sf.channels ; m++)
+ buffer [m][i] = ptr [j++] ;
+
+ ogg_write_samples (psf, odata, vdata, in_frames) ;
+
+ return lens ;
+} /* ogg_write_f */
+
+static sf_count_t
+ogg_write_d (SF_PRIVATE *psf, const double *ptr, sf_count_t lens)
+{ int i, m, j = 0 ;
+ OGG_PRIVATE *odata = (OGG_PRIVATE *) psf->container_data ;
+ VORBIS_PRIVATE *vdata = (VORBIS_PRIVATE *) psf->codec_data ;
+ int in_frames = lens / psf->sf.channels ;
+ float **buffer = vorbis_analysis_buffer (&vdata->vd, in_frames) ;
+ for (i = 0 ; i < in_frames ; i++)
+ for (m = 0 ; m < psf->sf.channels ; m++)
+ buffer [m][i] = (float) ptr [j++] ;
+
+ ogg_write_samples (psf, odata, vdata, in_frames) ;
+
+ return lens ;
+} /* ogg_write_d */
+
+static sf_count_t
+ogg_seek (SF_PRIVATE *psf, int UNUSED (mode), sf_count_t offset)
+{
+ OGG_PRIVATE *odata = (OGG_PRIVATE *) psf->container_data ;
+ VORBIS_PRIVATE *vdata = (VORBIS_PRIVATE *) psf->codec_data ;
+
+ if (odata == NULL || vdata == NULL)
+ return 0 ;
+
+ if (offset < 0)
+ { psf->error = SFE_BAD_SEEK ;
+ return ((sf_count_t) -1) ;
+ } ;
+
+ if (psf->mode == SFM_READ)
+ { sf_count_t target = offset - vdata->loc ;
+
+ if (target < 0)
+ { /* 12 to allow for OggS bit */
+ psf_fseek (psf, 12, SEEK_SET) ;
+ ogg_read_header (psf, 0) ; /* Reset state */
+ target = offset ;
+ } ;
+
+ while (target > 0)
+ { sf_count_t m = target > 4096 ? 4096 : target ;
+
+ /*
+ ** Need to multiply by channels here because the seek is done in
+ ** terms of frames and the read function is done in terms of
+ ** samples.
+ */
+ ogg_read_sample (psf, (void *) NULL, m * psf->sf.channels, ogg_rnull) ;
+
+ target -= m ;
+ } ;
+
+ return vdata->loc ;
+ } ;
+
+ return 0 ;
+} /* ogg_seek */
+
+/*==============================================================================
+** Most of the following code was snipped from Mike Smith's ogginfo utility
+** which is part of vorbis-tools.
+** Vorbis tools is released under the GPL but Mike has kindly allowed the
+** following to be relicensed as LGPL for libsndfile.
+*/
+
+typedef struct
+{
+ int isillegal ;
+ int shownillegal ;
+ int isnew ;
+ int end ;
+
+ uint32_t serial ; /* must be 32 bit unsigned */
+ ogg_stream_state os ;
+
+ vorbis_info vi ;
+ vorbis_comment vc ;
+ sf_count_t lastgranulepos ;
+ int doneheaders ;
+} stream_processor ;
+
+typedef struct
+{
+ stream_processor *streams ;
+ int allocated ;
+ int used ;
+ int in_headers ;
+} stream_set ;
+
+static stream_set *
+create_stream_set (void)
+{ stream_set *set = calloc (1, sizeof (stream_set)) ;
+
+ set->streams = calloc (5, sizeof (stream_processor)) ;
+ set->allocated = 5 ;
+ set->used = 0 ;
+
+ return set ;
+} /* create_stream_set */
+
+static void
+vorbis_end (stream_processor *stream, sf_count_t * len)
+{ *len += stream->lastgranulepos ;
+ vorbis_comment_clear (&stream->vc) ;
+ vorbis_info_clear (&stream->vi) ;
+} /* vorbis_end */
+
+static void
+free_stream_set (stream_set *set, sf_count_t * len)
+{ int i ;
+
+ for (i = 0 ; i < set->used ; i++)
+ { if (!set->streams [i].end)
+ vorbis_end (&set->streams [i], len) ;
+ ogg_stream_clear (&set->streams [i].os) ;
+ } ;
+
+ free (set->streams) ;
+ free (set) ;
+} /* free_stream_set */
+
+static int
+streams_open (stream_set *set)
+{ int i, res = 0 ;
+
+ for (i = 0 ; i < set->used ; i++)
+ if (!set->streams [i].end)
+ res ++ ;
+ return res ;
+} /* streams_open */
+
+static stream_processor *
+find_stream_processor (stream_set *set, ogg_page *page)
+{ uint32_t serial = ogg_page_serialno (page) ;
+ int i, found = 0 ;
+ int invalid = 0 ;
+
+ stream_processor *stream ;
+
+ for (i = 0 ; i < set->used ; i++)
+ {
+ if (serial == set->streams [i].serial)
+ { /* We have a match! */
+ found = 1 ;
+ stream = & (set->streams [i]) ;
+
+ set->in_headers = 0 ;
+ /* if we have detected EOS, then this can't occur here. */
+ if (stream->end)
+ { stream->isillegal = 1 ;
+ return stream ;
+ }
+
+ stream->isnew = 0 ;
+ stream->end = ogg_page_eos (page) ;
+ stream->serial = serial ;
+ return stream ;
+ } ;
+ } ;
+
+ /* If there are streams open, and we've reached the end of the
+ ** headers, then we can't be starting a new stream.
+ ** XXX: might this sometimes catch ok streams if EOS flag is missing,
+ ** but the stream is otherwise ok?
+ */
+ if (streams_open (set) && !set->in_headers)
+ invalid = 1 ;
+
+ set->in_headers = 1 ;
+
+ if (set->allocated < set->used)
+ stream = &set->streams [set->used] ;
+ else
+ { set->allocated += 5 ;
+ set->streams = realloc (set->streams, sizeof (stream_processor) * set->allocated) ;
+ stream = &set->streams [set->used] ;
+ } ;
+
+ set->used++ ;
+
+ stream->isnew = 1 ;
+ stream->isillegal = invalid ;
+
+ {
+ int res ;
+ ogg_packet packet ;
+
+ /* We end up processing the header page twice, but that's ok. */
+ ogg_stream_init (&stream->os, serial) ;
+ ogg_stream_pagein (&stream->os, page) ;
+ res = ogg_stream_packetout (&stream->os, &packet) ;
+ if (res <= 0)
+ return NULL ;
+ else if (packet.bytes >= 7 && memcmp (packet.packet, "\x01vorbis", 7) == 0)
+ {
+ stream->lastgranulepos = 0 ;
+ vorbis_comment_init (&stream->vc) ;
+ vorbis_info_init (&stream->vi) ;
+ } ;
+
+ res = ogg_stream_packetout (&stream->os, &packet) ;
+
+ /* re-init, ready for processing */
+ ogg_stream_clear (&stream->os) ;
+ ogg_stream_init (&stream->os, serial) ;
+ }
+
+ stream->end = ogg_page_eos (page) ;
+ stream->serial = serial ;
+
+ return stream ;
+} /* find_stream_processor */
+
+static int
+ogg_length_get_next_page (SF_PRIVATE *psf, ogg_sync_state * osync, ogg_page *page)
+{ static const int CHUNK_SIZE = 4500 ;
+
+ while (ogg_sync_pageout (osync, page) <= 0)
+ { char * buffer = ogg_sync_buffer (osync, CHUNK_SIZE) ;
+ int bytes = psf_fread (buffer, 1, 4096, psf) ;
+
+ if (bytes <= 0)
+ { ogg_sync_wrote (osync, 0) ;
+ return 0 ;
+ } ;
+
+ ogg_sync_wrote (osync, bytes) ;
+ } ;
+
+ return 1 ;
+} /* ogg_length_get_next_page */
+
+static sf_count_t
+ogg_length_aux (SF_PRIVATE * psf)
+{
+ ogg_sync_state osync ;
+ ogg_page page ;
+ int gotpage = 0 ;
+ sf_count_t len = 0 ;
+ stream_set *processors ;
+
+ processors = create_stream_set () ;
+ if (processors == NULL)
+ return 0 ; // out of memory?
+
+ ogg_sync_init (&osync) ;
+
+ while (ogg_length_get_next_page (psf, &osync, &page))
+ {
+ stream_processor *p = find_stream_processor (processors, &page) ;
+ gotpage = 1 ;
+
+ if (!p)
+ { len = 0 ;
+ break ;
+ } ;
+
+ if (p->isillegal && !p->shownillegal)
+ {
+ p->shownillegal = 1 ;
+ /* If it's a new stream, we want to continue processing this page
+ ** anyway to suppress additional spurious errors
+ */
+ if (!p->isnew) continue ;
+ } ;
+
+ if (!p->isillegal)
+ { ogg_packet packet ;
+ int header = 0 ;
+
+ ogg_stream_pagein (&p->os, &page) ;
+ if (p->doneheaders < 3)
+ header = 1 ;
+
+ while (ogg_stream_packetout (&p->os, &packet) > 0)
+ {
+ if (p->doneheaders < 3)
+ { if (vorbis_synthesis_headerin (&p->vi, &p->vc, &packet) < 0)
+ continue ;
+ p->doneheaders ++ ;
+ } ;
+ } ;
+ if (!header)
+ { sf_count_t gp = ogg_page_granulepos (&page) ;
+ if (gp > 0) p->lastgranulepos = gp ;
+ } ;
+ if (p->end)
+ { vorbis_end (p, &len) ;
+ p->isillegal = 1 ;
+ } ;
+ } ;
+ } ;
+
+ ogg_sync_clear (&osync) ;
+ free_stream_set (processors, &len) ;
+
+ return len ;
+} /* ogg_length_aux */
+
+static sf_count_t
+ogg_length (SF_PRIVATE *psf)
+{ sf_count_t length ;
+ int error ;
+
+ if (psf->sf.seekable == 0)
+ return SF_COUNT_MAX ;
+
+ psf_fseek (psf, 0, SEEK_SET) ;
+ length = ogg_length_aux (psf) ;
+
+ psf_fseek (psf, 12, SEEK_SET) ;
+ if ((error = ogg_read_header (psf, 0)) != 0)
+ psf->error = error ;
+
+ return length ;
+} /* ogg_length */
+
+#else /* HAVE_EXTERNAL_LIBS */
+
+int
+ogg_open (SF_PRIVATE *psf)
+{
+ psf_log_printf (psf, "This version of libsndfile was compiled without Ogg/Vorbis support.\n") ;
+ return SFE_UNIMPLEMENTED ;
+} /* ogg_open */
+
+#endif
Modified: freeswitch/trunk/libs/libsndfile/src/paf.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/src/paf.c (original)
+++ freeswitch/trunk/libs/libsndfile/src/paf.c Thu May 21 16:09:30 2009
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 1999-2005 Erik de Castro Lopo <erikd at mega-nerd.com>
+** Copyright (C) 1999-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU Lesser General Public License as published by
@@ -23,10 +23,10 @@
#include <fcntl.h>
#include <string.h>
#include <ctype.h>
+#include <math.h>
#include "sndfile.h"
#include "sfendian.h"
-#include "float_cast.h"
#include "common.h"
/*------------------------------------------------------------------------------
@@ -113,13 +113,13 @@
return error ;
} ;
- subformat = psf->sf.format & SF_FORMAT_SUBMASK ;
+ subformat = SF_CODEC (psf->sf.format) ;
if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR)
- { if ((psf->sf.format & SF_FORMAT_TYPEMASK) != SF_FORMAT_PAF)
+ { if ((SF_CONTAINER (psf->sf.format)) != SF_FORMAT_PAF)
return SFE_BAD_OPEN_FORMAT ;
- endian = psf->sf.format & SF_FORMAT_ENDMASK ;
+ endian = SF_ENDIAN (psf->sf.format) ;
/* PAF is by default big endian. */
psf->endian = SF_ENDIAN_BIG ;
@@ -273,7 +273,7 @@
} /* paf_read_header */
static int
-paf_write_header (SF_PRIVATE *psf, int calc_length)
+paf_write_header (SF_PRIVATE *psf, int UNUSED (calc_length))
{ int paf_format ;
/* PAF header already written so no need to re-write. */
@@ -282,12 +282,7 @@
psf->dataoffset = PAF_HEADER_LENGTH ;
- psf->dataoffset = PAF_HEADER_LENGTH ;
-
- /* Prevent compiler warning. */
- calc_length = calc_length ;
-
- switch (psf->sf.format & SF_FORMAT_SUBMASK)
+ switch (SF_CODEC (psf->sf.format))
{ case SF_FORMAT_PCM_S8 :
paf_format = PAF_PCM_S8 ;
break ;
@@ -833,11 +828,3 @@
return total ;
} /* paf24_write_d */
-
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: 477a5308-451e-4bbd-bab4-fab6caa4e884
-*/
Modified: freeswitch/trunk/libs/libsndfile/src/pcm.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/src/pcm.c (original)
+++ freeswitch/trunk/libs/libsndfile/src/pcm.c Thu May 21 16:09:30 2009
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 1999-2005 Erik de Castro Lopo <erikd at mega-nerd.com>
+** Copyright (C) 1999-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU Lesser General Public License as published by
@@ -18,9 +18,10 @@
#include "sfconfig.h"
+#include <math.h>
+
#include "sndfile.h"
#include "sfendian.h"
-#include "float_cast.h"
#include "common.h"
/* Need to be able to handle 3 byte (24 bit) integers. So defined a
@@ -120,15 +121,22 @@
{ int chars = 0 ;
if (psf->bytewidth == 0 || psf->sf.channels == 0)
+ { psf_log_printf (psf, "pcm_init : internal error : bytewitdh = %d, channels = %d\n", psf->bytewidth, psf->sf.channels) ;
return SFE_INTERNAL ;
+ } ;
psf->blockwidth = psf->bytewidth * psf->sf.channels ;
- if ((psf->sf.format & SF_FORMAT_SUBMASK) == SF_FORMAT_PCM_S8)
+ if ((SF_CODEC (psf->sf.format)) == SF_FORMAT_PCM_S8)
chars = SF_CHARS_SIGNED ;
- else if ((psf->sf.format & SF_FORMAT_SUBMASK) == SF_FORMAT_PCM_U8)
+ else if ((SF_CODEC (psf->sf.format)) == SF_FORMAT_PCM_U8)
chars = SF_CHARS_UNSIGNED ;
+ if (CPU_IS_BIG_ENDIAN)
+ psf->data_endswap = (psf->endian == SF_ENDIAN_BIG) ? SF_FALSE : SF_TRUE ;
+ else
+ psf->data_endswap = (psf->endian == SF_ENDIAN_LITTLE) ? SF_FALSE : SF_TRUE ;
+
if (psf->mode == SFM_READ || psf->mode == SFM_RDWR)
{ switch (psf->bytewidth * 0x10000 + psf->endian + chars)
{ case (0x10000 + SF_ENDIAN_BIG + SF_CHARS_SIGNED) :
@@ -159,6 +167,7 @@
psf->read_double = pcm_read_bet2d ;
break ;
case (4 * 0x10000 + SF_ENDIAN_BIG) :
+
psf->read_short = pcm_read_bei2s ;
psf->read_int = pcm_read_bei2i ;
psf->read_float = pcm_read_bei2f ;
@@ -184,7 +193,7 @@
psf->read_double = pcm_read_lei2d ;
break ;
default :
- psf_log_printf (psf, "pcm.c returning SFE_UNIMPLEMENTED\n") ;
+ psf_log_printf (psf, "pcm.c returning SFE_UNIMPLEMENTED\nbytewidth %d endian %d\n", psf->bytewidth, psf->endian) ;
return SFE_UNIMPLEMENTED ;
} ;
} ;
@@ -249,7 +258,7 @@
break ;
default :
- psf_log_printf (psf, "pcm.c returning SFE_UNIMPLEMENTED\n") ;
+ psf_log_printf (psf, "pcm.c returning SFE_UNIMPLEMENTED\nbytewidth %s endian %d\n", psf->bytewidth, psf->endian) ;
return SFE_UNIMPLEMENTED ;
} ;
@@ -2890,10 +2899,3 @@
return total ;
} /* pcm_write_d2lei */
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: d8bc7c0e-1e2f-4ff3-a28f-10ce1fbade3b
-*/
Modified: freeswitch/trunk/libs/libsndfile/src/pvf.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/src/pvf.c (original)
+++ freeswitch/trunk/libs/libsndfile/src/pvf.c Thu May 21 16:09:30 2009
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 2002-2004 Erik de Castro Lopo <erikd at mega-nerd.com>
+** Copyright (C) 2002-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU Lesser General Public License as published by
@@ -56,10 +56,10 @@
return error ;
} ;
- subformat = psf->sf.format & SF_FORMAT_SUBMASK ;
+ subformat = SF_CODEC (psf->sf.format) ;
if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR)
- { if ((psf->sf.format & SF_FORMAT_TYPEMASK) != SF_FORMAT_PVF)
+ { if ((SF_CONTAINER (psf->sf.format)) != SF_FORMAT_PVF)
return SFE_BAD_OPEN_FORMAT ;
psf->endian = SF_ENDIAN_BIG ;
@@ -91,22 +91,18 @@
*/
static int
-pvf_close (SF_PRIVATE *psf)
+pvf_close (SF_PRIVATE * UNUSED (psf))
{
- psf = psf ;
-
return 0 ;
} /* pvf_close */
static int
-pvf_write_header (SF_PRIVATE *psf, int calc_length)
+pvf_write_header (SF_PRIVATE *psf, int UNUSED (calc_length))
{ sf_count_t current ;
if (psf->pipeoffset > 0)
return 0 ;
- calc_length = calc_length ; /* Avoid a compiler warning. */
-
current = psf_ftell (psf) ;
/* Reset the current header length to zero. */
@@ -116,7 +112,7 @@
if (psf->is_pipe == SF_FALSE)
psf_fseek (psf, 0, SEEK_SET) ;
- LSF_SNPRINTF ((char*) psf->header, sizeof (psf->header), "PVF1\n%d %d %d\n",
+ snprintf ((char*) psf->header, sizeof (psf->header), "PVF1\n%d %d %d\n",
psf->sf.channels, psf->sf.samplerate, psf->bytewidth * 8) ;
psf->headindex = strlen ((char*) psf->header) ;
@@ -190,10 +186,3 @@
return 0 ;
} /* pvf_read_header */
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: 20a26761-8bc1-41d7-b1f3-9793bf3d9864
-*/
Modified: freeswitch/trunk/libs/libsndfile/src/raw.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/src/raw.c (original)
+++ freeswitch/trunk/libs/libsndfile/src/raw.c Thu May 21 16:09:30 2009
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 1999-2004 Erik de Castro Lopo <erikd at mega-nerd.com>
+** Copyright (C) 1999-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU Lesser General Public License as published by
@@ -31,9 +31,9 @@
raw_open (SF_PRIVATE *psf)
{ int subformat, error = SFE_NO_ERROR ;
- subformat = psf->sf.format & SF_FORMAT_SUBMASK ;
+ subformat = SF_CODEC (psf->sf.format) ;
- psf->endian = psf->sf.format & SF_FORMAT_ENDMASK ;
+ psf->endian = SF_ENDIAN (psf->sf.format) ;
if (CPU_IS_BIG_ENDIAN && (psf->endian == 0 || psf->endian == SF_ENDIAN_CPU))
psf->endian = SF_ENDIAN_BIG ;
@@ -102,10 +102,3 @@
return error ;
} /* raw_open */
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: f0066de7-d6ce-4f36-a1e0-e475c07d4e1a
-*/
Added: freeswitch/trunk/libs/libsndfile/src/rf64.c
==============================================================================
--- (empty file)
+++ freeswitch/trunk/libs/libsndfile/src/rf64.c Thu May 21 16:09:30 2009
@@ -0,0 +1,496 @@
+/*
+** Copyright (C) 2008-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
+**
+** This program is free software; you can redistribute it and/or modify
+** it under the terms of the GNU Lesser General Public License as published by
+** the Free Software Foundation; either version 2.1 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU Lesser General Public License for more details.
+**
+** You should have received a copy of the GNU Lesser General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+/*
+** This format documented at:
+** http://www.sr.se/utveckling/tu/bwf/prog/RF_64v1_4.pdf
+*/
+
+#include "sfconfig.h"
+
+#include <stdio.h>
+#include <fcntl.h>
+#include <string.h>
+#include <ctype.h>
+
+#include "sndfile.h"
+#include "sfendian.h"
+#include "common.h"
+#include "wav_w64.h"
+
+/*------------------------------------------------------------------------------
+** Macros to handle big/little endian issues.
+*/
+#define RF64_MARKER MAKE_MARKER ('R', 'F', '6', '4')
+#define FFFF_MARKER MAKE_MARKER (0xff, 0xff, 0xff, 0xff)
+#define WAVE_MARKER MAKE_MARKER ('W', 'A', 'V', 'E')
+#define ds64_MARKER MAKE_MARKER ('d', 's', '6', '4')
+#define fmt_MARKER MAKE_MARKER ('f', 'm', 't', ' ')
+#define fact_MARKER MAKE_MARKER ('f', 'a', 'c', 't')
+#define data_MARKER MAKE_MARKER ('d', 'a', 't', 'a')
+
+/*------------------------------------------------------------------------------
+** Typedefs.
+*/
+
+/*------------------------------------------------------------------------------
+** Private static functions.
+*/
+
+static int rf64_read_header (SF_PRIVATE *psf) ;
+static int rf64_write_header (SF_PRIVATE *psf, int calc_length) ;
+static int rf64_close (SF_PRIVATE *psf) ;
+
+/*------------------------------------------------------------------------------
+** Public function.
+*/
+
+int
+rf64_open (SF_PRIVATE *psf)
+{ WAV_PRIVATE *wpriv ;
+ int subformat, error = 0 ;
+
+ if ((wpriv = calloc (1, sizeof (WAV_PRIVATE))) == NULL)
+ return SFE_MALLOC_FAILED ;
+ psf->container_data = wpriv ;
+
+ /* All RF64 files are little endian. */
+ psf->endian = SF_ENDIAN_LITTLE ;
+
+
+ if (psf->mode == SFM_READ || (psf->mode == SFM_RDWR && psf->filelength > 0))
+ { if ((error = rf64_read_header (psf)) != 0)
+ return error ;
+ } ;
+
+ if ((psf->sf.format & SF_FORMAT_TYPEMASK) != SF_FORMAT_RF64)
+ return SFE_BAD_OPEN_FORMAT ;
+
+ subformat = psf->sf.format & SF_FORMAT_SUBMASK ;
+
+ if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR)
+ { if (psf->is_pipe)
+ return SFE_NO_PIPE_WRITE ;
+
+ psf->blockwidth = psf->bytewidth * psf->sf.channels ;
+
+ if ((error = rf64_write_header (psf, SF_FALSE)))
+ return error ;
+
+ psf->write_header = rf64_write_header ;
+ } ;
+
+ psf->container_close = rf64_close ;
+
+ switch (subformat)
+ { case SF_FORMAT_PCM_U8 :
+ case SF_FORMAT_PCM_16 :
+ case SF_FORMAT_PCM_24 :
+ case SF_FORMAT_PCM_32 :
+ error = pcm_init (psf) ;
+ break ;
+
+ case SF_FORMAT_ULAW :
+ error = ulaw_init (psf) ;
+ break ;
+
+ case SF_FORMAT_ALAW :
+ error = alaw_init (psf) ;
+ break ;
+
+ /* Lite remove start */
+ case SF_FORMAT_FLOAT :
+ error = float32_init (psf) ;
+ break ;
+
+ case SF_FORMAT_DOUBLE :
+ error = double64_init (psf) ;
+ break ;
+
+ /* Lite remove end */
+
+ default : return SFE_UNIMPLEMENTED ;
+ } ;
+
+ return error ;
+} /* rf64_open */
+
+/*------------------------------------------------------------------------------
+*/
+
+static int
+rf64_read_header (SF_PRIVATE *psf)
+{ WAV_PRIVATE *wpriv ;
+ sf_count_t riff_size, data_size ;
+ unsigned int size32 ;
+ int marker, marks [2], error, done = 0 ;
+
+ if ((wpriv = psf->container_data) == NULL)
+ return SFE_INTERNAL ;
+
+ /* Set position to start of file to begin reading header. */
+ psf_binheader_readf (psf, "pmmm", 0, &marker, marks, marks + 1) ;
+ if (marker != RF64_MARKER || marks [0] != FFFF_MARKER || marks [1] != WAVE_MARKER)
+ return SFE_RF64_NOT_RF64 ;
+
+ psf_log_printf (psf, "%M\n %M\n", RF64_MARKER, WAVE_MARKER) ;
+
+ while (! done)
+ { psf_binheader_readf (psf, "em4", &marker, &size32) ;
+
+ switch (marker)
+ { case ds64_MARKER :
+ psf_log_printf (psf, "%M : %u\n", marker, size32) ;
+
+ psf_binheader_readf (psf, "888", &riff_size, &data_size, &psf->sf.frames) ;
+ psf_log_printf (psf, " Riff size : %D\n Data size : %D\n Frames : %D\n",
+ riff_size, data_size, psf->sf.frames) ;
+
+ psf_binheader_readf (psf, "4", &size32) ;
+ psf_log_printf (psf, " Table len : %u\n", size32) ;
+
+ psf_binheader_readf (psf, "jm4", size32 + 4, &marker, &size32) ;
+ psf_log_printf (psf, "%M : %u\n", marker, size32) ;
+
+ if ((error = wav_w64_read_fmt_chunk (psf, size32)) != 0)
+ return error ;
+ psf->sf.format = SF_FORMAT_RF64 | (psf->sf.format & SF_FORMAT_SUBMASK) ;
+ break ;
+
+ case data_MARKER :
+ psf_log_printf (psf, "%M : %x\n", marker, size32) ;
+ psf->dataoffset = psf->headindex ;
+ done = SF_TRUE ;
+ break ;
+
+ default :
+ if (isprint ((marker >> 24) & 0xFF) && isprint ((marker >> 16) & 0xFF)
+ && isprint ((marker >> 8) & 0xFF) && isprint (marker & 0xFF))
+ { psf_binheader_readf (psf, "4", &size32) ;
+ psf_log_printf (psf, "*** %M : %d (unknown marker)\n", marker, size32) ;
+ if (size32 < 8)
+ done = SF_TRUE ;
+ psf_binheader_readf (psf, "j", size32) ;
+ break ;
+ } ;
+ if (psf_ftell (psf) & 0x03)
+ { psf_log_printf (psf, " Unknown chunk marker at position %d. Resynching.\n", size32 - 4) ;
+ psf_binheader_readf (psf, "j", -3) ;
+ break ;
+ } ;
+ psf_log_printf (psf, "*** Unknown chunk marker (%X) at position %D. Exiting parser.\n", marker, psf_ftell (psf) - 4) ;
+ done = SF_TRUE ;
+ break ;
+ } ; /* switch (marker) */
+
+ if (psf_ftell (psf) >= psf->filelength - SIGNED_SIZEOF (marker))
+ { psf_log_printf (psf, "End\n") ;
+ break ;
+ } ;
+ } ;
+
+ return 0 ;
+} /* rf64_read_header */
+
+/* known WAVEFORMATEXTENSIBLE GUIDS */
+static const EXT_SUBFORMAT MSGUID_SUBTYPE_PCM =
+{ 0x00000001, 0x0000, 0x0010, { 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71 }
+} ;
+
+static const EXT_SUBFORMAT MSGUID_SUBTYPE_MS_ADPCM =
+{ 0x00000002, 0x0000, 0x0010, { 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71 }
+} ;
+
+static const EXT_SUBFORMAT MSGUID_SUBTYPE_IEEE_FLOAT =
+{ 0x00000003, 0x0000, 0x0010, { 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71 }
+} ;
+
+static const EXT_SUBFORMAT MSGUID_SUBTYPE_ALAW =
+{ 0x00000006, 0x0000, 0x0010, { 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71 }
+} ;
+
+static const EXT_SUBFORMAT MSGUID_SUBTYPE_MULAW =
+{ 0x00000007, 0x0000, 0x0010, { 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71 }
+} ;
+
+/*
+** the next two are from
+** http://dream.cs.bath.ac.uk/researchdev/wave-ex/bformat.html
+*/
+static const EXT_SUBFORMAT MSGUID_SUBTYPE_AMBISONIC_B_FORMAT_PCM =
+{ 0x00000001, 0x0721, 0x11d3, { 0x86, 0x44, 0xC8, 0xC1, 0xCA, 0x00, 0x00, 0x00 }
+} ;
+
+static const EXT_SUBFORMAT MSGUID_SUBTYPE_AMBISONIC_B_FORMAT_IEEE_FLOAT =
+{ 0x00000003, 0x0721, 0x11d3, { 0x86, 0x44, 0xC8, 0xC1, 0xCA, 0x00, 0x00, 0x00 }
+} ;
+
+
+static int
+wavex_write_fmt_chunk (SF_PRIVATE *psf)
+{ WAV_PRIVATE *wpriv ;
+ int subformat, fmt_size, add_fact_chunk = 0 ;
+
+ if ((wpriv = psf->container_data) == NULL)
+ return SFE_INTERNAL ;
+
+ subformat = psf->sf.format & SF_FORMAT_SUBMASK ;
+
+ /* initial section (same for all, it appears) */
+ switch (subformat)
+ { case SF_FORMAT_PCM_U8 :
+ case SF_FORMAT_PCM_16 :
+ case SF_FORMAT_PCM_24 :
+ case SF_FORMAT_PCM_32 :
+ case SF_FORMAT_FLOAT :
+ case SF_FORMAT_DOUBLE :
+ case SF_FORMAT_ULAW :
+ case SF_FORMAT_ALAW :
+ fmt_size = 2 + 2 + 4 + 4 + 2 + 2 + 2 + 2 + 4 + 4 + 2 + 2 + 8 ;
+
+ /* fmt : format, channels, samplerate */
+ psf_binheader_writef (psf, "4224", fmt_size, WAVE_FORMAT_EXTENSIBLE, psf->sf.channels, psf->sf.samplerate) ;
+ /* fmt : bytespersec */
+ psf_binheader_writef (psf, "4", psf->sf.samplerate * psf->bytewidth * psf->sf.channels) ;
+ /* fmt : blockalign, bitwidth */
+ psf_binheader_writef (psf, "22", psf->bytewidth * psf->sf.channels, psf->bytewidth * 8) ;
+
+ /* cbSize 22 is sizeof (WAVEFORMATEXTENSIBLE) - sizeof (WAVEFORMATEX) */
+ psf_binheader_writef (psf, "2", 22) ;
+
+ /* wValidBitsPerSample, for our use same as bitwidth as we use it fully */
+ psf_binheader_writef (psf, "2", psf->bytewidth * 8) ;
+
+ /* For an Ambisonic file set the channel mask to zero.
+ ** Otherwise use a default based on the channel count.
+ */
+ if (wpriv->wavex_ambisonic != SF_AMBISONIC_NONE)
+ psf_binheader_writef (psf, "4", 0) ;
+ else
+ { /*
+ ** Ok some liberty is taken here to use the most commonly used channel masks
+ ** instead of "no mapping". If you really want to use "no mapping" for 8 channels and less
+ ** please don't use wavex. (otherwise we'll have to create a new SF_COMMAND)
+ */
+ switch (psf->sf.channels)
+ { case 1 : /* center channel mono */
+ psf_binheader_writef (psf, "4", 0x4) ;
+ break ;
+
+ case 2 : /* front left and right */
+ psf_binheader_writef (psf, "4", 0x1 | 0x2) ;
+ break ;
+
+ case 4 : /* Quad */
+ psf_binheader_writef (psf, "4", 0x1 | 0x2 | 0x10 | 0x20) ;
+ break ;
+
+ case 6 : /* 5.1 */
+ psf_binheader_writef (psf, "4", 0x1 | 0x2 | 0x4 | 0x8 | 0x10 | 0x20) ;
+ break ;
+
+ case 8 : /* 7.1 */
+ psf_binheader_writef (psf, "4", 0x1 | 0x2 | 0x4 | 0x8 | 0x10 | 0x20 | 0x40 | 0x80) ;
+ break ;
+
+ default : /* 0 when in doubt , use direct out, ie NO mapping*/
+ psf_binheader_writef (psf, "4", 0x0) ;
+ break ;
+ } ;
+ } ;
+ break ;
+
+ case SF_FORMAT_MS_ADPCM : /* Todo, GUID exists might have different header as per wav_write_header */
+ default :
+ return SFE_UNIMPLEMENTED ;
+ } ;
+
+ /* GUID section, different for each */
+
+ switch (subformat)
+ { case SF_FORMAT_PCM_U8 :
+ case SF_FORMAT_PCM_16 :
+ case SF_FORMAT_PCM_24 :
+ case SF_FORMAT_PCM_32 :
+ wavex_write_guid (psf, wpriv->wavex_ambisonic == SF_AMBISONIC_NONE ?
+ &MSGUID_SUBTYPE_PCM : &MSGUID_SUBTYPE_AMBISONIC_B_FORMAT_PCM) ;
+ break ;
+
+ case SF_FORMAT_FLOAT :
+ case SF_FORMAT_DOUBLE :
+ wavex_write_guid (psf, wpriv->wavex_ambisonic == SF_AMBISONIC_NONE ?
+ &MSGUID_SUBTYPE_IEEE_FLOAT : &MSGUID_SUBTYPE_AMBISONIC_B_FORMAT_IEEE_FLOAT) ;
+ break ;
+
+ case SF_FORMAT_ULAW :
+ wavex_write_guid (psf, &MSGUID_SUBTYPE_MULAW) ;
+ break ;
+
+ case SF_FORMAT_ALAW :
+ wavex_write_guid (psf, &MSGUID_SUBTYPE_ALAW) ;
+ break ;
+
+#if 0
+ /* This is dead code due to return in previous switch statement. */
+ case SF_FORMAT_MS_ADPCM : /* todo, GUID exists */
+ wavex_write_guid (psf, &MSGUID_SUBTYPE_MS_ADPCM) ;
+ break ;
+ return SFE_UNIMPLEMENTED ;
+#endif
+
+ default : return SFE_UNIMPLEMENTED ;
+ } ;
+
+ if (add_fact_chunk)
+ psf_binheader_writef (psf, "tm48", fact_MARKER, 4, psf->sf.frames) ;
+
+ return 0 ;
+} /* wavex_write_fmt_chunk */
+
+
+static int
+rf64_write_header (SF_PRIVATE *psf, int calc_length)
+{ sf_count_t current ;
+ int error = 0, has_data = SF_FALSE ;
+
+ current = psf_ftell (psf) ;
+
+ if (psf->dataoffset > 0 && current > psf->dataoffset)
+ has_data = SF_TRUE ;
+
+ if (calc_length)
+ { psf->filelength = psf_get_filelen (psf) ;
+
+ psf->datalength = psf->filelength - psf->dataoffset ;
+
+ if (psf->dataend)
+ psf->datalength -= psf->filelength - psf->dataend ;
+
+ if (psf->bytewidth > 0)
+ psf->sf.frames = psf->datalength / (psf->bytewidth * psf->sf.channels) ;
+ } ;
+
+ /* Reset the current header length to zero. */
+ psf->header [0] = 0 ;
+ psf->headindex = 0 ;
+ psf_fseek (psf, 0, SEEK_SET) ;
+
+ psf_binheader_writef (psf, "em4m", RF64_MARKER, 0xffffffff, WAVE_MARKER) ;
+
+ psf_binheader_writef (psf, "m488844", ds64_MARKER, 32, psf->filelength, psf->datalength, psf->sf.frames, 0, 0x005c0064) ;
+
+ /* WAVE and 'fmt ' markers. */
+ psf_binheader_writef (psf, "m", fmt_MARKER) ;
+
+ /* Write the 'fmt ' chunk. */
+ switch (psf->sf.format & SF_FORMAT_TYPEMASK)
+ { case SF_FORMAT_WAV :
+ psf_log_printf (psf, "ooops SF_FORMAT_WAV\n") ;
+ return SFE_UNIMPLEMENTED ;
+ break ;
+
+ case SF_FORMAT_WAVEX :
+ case SF_FORMAT_RF64 :
+ if ((error = wavex_write_fmt_chunk (psf)) != 0)
+ return error ;
+ break ;
+
+ default :
+ return SFE_UNIMPLEMENTED ;
+ } ;
+
+#if 0
+ /* The LIST/INFO chunk. */
+ if (psf->str_flags & SF_STR_LOCATE_START)
+ wav_write_strings (psf, SF_STR_LOCATE_START) ;
+
+ if (psf->peak_info != NULL && psf->peak_info->peak_loc == SF_PEAK_START)
+ { psf_binheader_writef (psf, "m4", PEAK_MARKER, WAV_PEAK_CHUNK_SIZE (psf->sf.channels)) ;
+ psf_binheader_writef (psf, "44", 1, time (NULL)) ;
+ for (k = 0 ; k < psf->sf.channels ; k++)
+ psf_binheader_writef (psf, "ft8", (float) psf->peak_info->peaks [k].value, psf->peak_info->peaks [k].position) ;
+ } ;
+
+ if (psf->broadcast_info != NULL)
+ wav_write_bext_chunk (psf) ;
+
+ if (psf->instrument != NULL)
+ { int tmp ;
+ double dtune = (double) (0x40000000) / 25.0 ;
+
+ psf_binheader_writef (psf, "m4", smpl_MARKER, 9 * 4 + psf->instrument->loop_count * 6 * 4) ;
+ psf_binheader_writef (psf, "44", 0, 0) ; /* Manufacturer zero is everyone */
+ tmp = (int) (1.0e9 / psf->sf.samplerate) ; /* Sample period in nano seconds */
+ psf_binheader_writef (psf, "44", tmp, psf->instrument->basenote) ;
+ tmp = (unsigned int) (psf->instrument->detune * dtune + 0.5) ;
+ psf_binheader_writef (psf, "4", tmp) ;
+ psf_binheader_writef (psf, "44", 0, 0) ; /* SMTPE format */
+ psf_binheader_writef (psf, "44", psf->instrument->loop_count, 0) ;
+
+ for (tmp = 0 ; tmp < psf->instrument->loop_count ; tmp++)
+ { int type ;
+
+ type = psf->instrument->loops [tmp].mode ;
+ type = (type == SF_LOOP_FORWARD ? 0 : type==SF_LOOP_BACKWARD ? 2 : type == SF_LOOP_ALTERNATING ? 1 : 32) ;
+
+ psf_binheader_writef (psf, "44", tmp, type) ;
+ psf_binheader_writef (psf, "44", psf->instrument->loops [tmp].start, psf->instrument->loops [tmp].end) ;
+ psf_binheader_writef (psf, "44", 0, psf->instrument->loops [tmp].count) ;
+ } ;
+ } ;
+
+ if (psf->headindex + 8 < psf->dataoffset)
+ { /* Add PAD data if necessary. */
+ k = psf->dataoffset - 16 - psf->headindex ;
+ psf_binheader_writef (psf, "m4z", PAD_MARKER, k, make_size_t (k)) ;
+ } ;
+
+#endif
+
+ psf_binheader_writef (psf, "m4", data_MARKER, 0xffffffff) ;
+
+ psf_fwrite (psf->header, psf->headindex, 1, psf) ;
+ if (psf->error)
+ return psf->error ;
+
+ if (has_data && psf->dataoffset != psf->headindex)
+ { printf ("Oooops : has_data && psf->dataoffset != psf->headindex\n") ;
+ return psf->error = SFE_INTERNAL ;
+ } ;
+
+ psf->dataoffset = psf->headindex ;
+
+ if (! has_data)
+ psf_fseek (psf, psf->dataoffset, SEEK_SET) ;
+ else if (current > 0)
+ psf_fseek (psf, current, SEEK_SET) ;
+
+ return psf->error ;
+} /* rf64_write_header */
+
+static int
+rf64_close (SF_PRIVATE *psf)
+{
+ if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR)
+ { // rf64_write_tailer (psf) ;
+
+ psf->write_header (psf, SF_TRUE) ;
+ } ;
+
+ return 0 ;
+} /* rf64_close */
Modified: freeswitch/trunk/libs/libsndfile/src/rx2.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/src/rx2.c (original)
+++ freeswitch/trunk/libs/libsndfile/src/rx2.c Thu May 21 16:09:30 2009
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 2001-2004 Erik de Castro Lopo <erikd at mega-nerd.com>
+** Copyright (C) 2001-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU Lesser General Public License as published by
@@ -33,7 +33,7 @@
rx2_open (SF_PRIVATE *psf)
{ if (psf)
return SFE_UNIMPLEMENTED ;
- return (psf && 0) ;
+ return 0 ;
} /* rx2_open */
#else
@@ -317,10 +317,3 @@
} /* rx2_close */
#endif
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: 7366e813-9fee-4d1f-881e-e4a691469370
-*/
Modified: freeswitch/trunk/libs/libsndfile/src/sd2.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/src/sd2.c (original)
+++ freeswitch/trunk/libs/libsndfile/src/sd2.c Thu May 21 16:09:30 2009
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 2001-2006 Erik de Castro Lopo <erikd at mega-nerd.com>
+** Copyright (C) 2001-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
** Copyright (C) 2004 Paavo Jumppanen
**
** This program is free software; you can redistribute it and/or modify
@@ -58,6 +58,7 @@
typedef struct
{ unsigned char * rsrc_data ;
int rsrc_len ;
+ int need_to_free_rsrc_data ;
int data_offset, data_length ;
int map_offset, map_length ;
@@ -118,12 +119,12 @@
goto error_cleanup ;
} ;
- if ((psf->sf.format & SF_FORMAT_TYPEMASK) != SF_FORMAT_SD2)
+ if ((SF_CONTAINER (psf->sf.format)) != SF_FORMAT_SD2)
{ error = SFE_BAD_OPEN_FORMAT ;
goto error_cleanup ;
} ;
- subformat = psf->sf.format & SF_FORMAT_SUBMASK ;
+ subformat = SF_CODEC (psf->sf.format) ;
psf->dataoffset = 0 ;
/* Only open and write the resource in RDWR mode is its current length is zero. */
@@ -249,9 +250,9 @@
rsrc.rsrc_len = sizeof (psf->header) ;
memset (rsrc.rsrc_data, 0xea, rsrc.rsrc_len) ;
- LSF_SNPRINTF (str_rsrc [0].value, sizeof (str_rsrc [0].value), "_%d", rsrc.sample_size) ;
- LSF_SNPRINTF (str_rsrc [1].value, sizeof (str_rsrc [1].value), "_%d.000000", rsrc.sample_rate) ;
- LSF_SNPRINTF (str_rsrc [2].value, sizeof (str_rsrc [2].value), "_%d", rsrc.channels) ;
+ snprintf (str_rsrc [0].value, sizeof (str_rsrc [0].value), "_%d", rsrc.sample_size) ;
+ snprintf (str_rsrc [1].value, sizeof (str_rsrc [1].value), "_%d.000000", rsrc.sample_rate) ;
+ snprintf (str_rsrc [2].value, sizeof (str_rsrc [2].value), "_%d", rsrc.channels) ;
for (k = 0 ; k < ARRAY_LEN (str_rsrc) ; k++)
{ if (str_rsrc [k].value_len == 0)
@@ -420,7 +421,9 @@
psf_log_printf (psf, "Resource length : %d (0x%04X)\n", rsrc.rsrc_len, rsrc.rsrc_len) ;
if (rsrc.rsrc_len > SIGNED_SIZEOF (psf->header))
- rsrc.rsrc_data = calloc (1, rsrc.rsrc_len) ;
+ { rsrc.rsrc_data = calloc (1, rsrc.rsrc_len) ;
+ rsrc.need_to_free_rsrc_data = SF_TRUE ;
+ }
else
rsrc.rsrc_data = psf->header ;
@@ -477,6 +480,12 @@
goto parse_rsrc_fork_cleanup ;
} ;
+ if (rsrc.map_offset + 28 >= rsrc.rsrc_len)
+ { psf_log_printf (psf, "Bad map offset (%d + 28 > %d).\n", rsrc.map_offset, rsrc.rsrc_len) ;
+ error = SFE_SD2_BAD_RSRC ;
+ goto parse_rsrc_fork_cleanup ;
+ } ;
+
rsrc.string_offset = rsrc.map_offset + read_short (rsrc.rsrc_data, rsrc.map_offset + 26) ;
if (rsrc.string_offset > rsrc.rsrc_len)
{ psf_log_printf (psf, "Bad string offset (%d).\n", rsrc.string_offset) ;
@@ -519,7 +528,7 @@
psf_use_rsrc (psf, SF_FALSE) ;
- if ((void *) rsrc.rsrc_data < (void *) psf || (void *) rsrc.rsrc_data > (void *) (psf + 1))
+ if (rsrc.need_to_free_rsrc_data)
free (rsrc.rsrc_data) ;
return error ;
@@ -528,12 +537,14 @@
static int
parse_str_rsrc (SF_PRIVATE *psf, SD2_RSRC * rsrc)
{ char name [32], value [32] ;
- int k, str_offset, data_offset, data_len, rsrc_id ;
+ int k, str_offset, rsrc_id, data_offset = 0, data_len = 0 ;
psf_log_printf (psf, "Finding parameters :\n") ;
str_offset = rsrc->string_offset ;
- for (k = 0 ; k < rsrc->str_count ; k++)
+ psf_log_printf (psf, " Offset RsrcId dlen slen Value\n") ;
+
+ for (k = 0 ; data_offset + data_len < rsrc->rsrc_len ; k++)
{ int slen ;
slen = read_char (rsrc->rsrc_data, str_offset) ;
@@ -544,29 +555,43 @@
data_offset = rsrc->data_offset + read_int (rsrc->rsrc_data, rsrc->item_offset + k * 12 + 4) ;
if (data_offset < 0 || data_offset > rsrc->rsrc_len)
- { psf_log_printf (psf, "Bad data offset (%d)\n", data_offset) ;
- return SFE_SD2_BAD_DATA_OFFSET ;
+ { psf_log_printf (psf, "Exiting parser on data offset of %d.\n", data_offset) ;
+ break ;
} ;
data_len = read_int (rsrc->rsrc_data, data_offset) ;
if (data_len < 0 || data_len > rsrc->rsrc_len)
- { psf_log_printf (psf, "Bad data length (%d).\n", data_len) ;
- return SFE_SD2_BAD_RSRC ;
+ { psf_log_printf (psf, "Exiting parser on data length of %d.\n", data_len) ;
+ break ;
} ;
slen = read_char (rsrc->rsrc_data, data_offset + 4) ;
read_str (rsrc->rsrc_data, data_offset + 5, value, SF_MIN (SIGNED_SIZEOF (value), slen + 1)) ;
- psf_log_printf (psf, " %-12s 0x%04x %4d %2d %2d '%s'\n", name, data_offset, rsrc_id, data_len, slen, value) ;
+ psf_log_printf (psf, " 0x%04x %4d %4d %3d '%s'\n", data_offset, rsrc_id, data_len, slen, value) ;
- if (strcmp (name, "sample-size") == 0 && rsrc->sample_size == 0)
+ if (rsrc_id == 1000 && rsrc->sample_size == 0)
rsrc->sample_size = strtol (value, NULL, 10) ;
- else if (strcmp (name, "sample-rate") == 0 && rsrc->sample_rate == 0)
+ else if (rsrc_id == 1001 && rsrc->sample_rate == 0)
rsrc->sample_rate = strtol (value, NULL, 10) ;
- else if (strcmp (name, "channels") == 0 && rsrc->channels == 0)
+ else if (rsrc_id == 1002 && rsrc->channels == 0)
rsrc->channels = strtol (value, NULL, 10) ;
} ;
+ psf_log_printf (psf, "Found Parameters :\n") ;
+ psf_log_printf (psf, " sample-size : %d\n", rsrc->sample_size) ;
+ psf_log_printf (psf, " sample-rate : %d\n", rsrc->sample_rate) ;
+ psf_log_printf (psf, " channels : %d\n", rsrc->channels) ;
+
+ if (rsrc->sample_rate <= 4 && rsrc->sample_size > 4)
+ { int temp ;
+
+ psf_log_printf (psf, "Geez!! Looks like sample rate and sample size got switched.\nCorrecting this screw up.\n") ;
+ temp = rsrc->sample_rate ;
+ rsrc->sample_rate = rsrc->sample_size ;
+ rsrc->sample_size = temp ;
+ } ;
+
if (rsrc->sample_rate < 0)
{ psf_log_printf (psf, "Bad sample rate (%d)\n", rsrc->sample_rate) ;
return SFE_SD2_BAD_RSRC ;
@@ -604,10 +629,3 @@
return 0 ;
} /* parse_str_rsrc */
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: 1ee183e5-6b9f-4c2c-bd0a-24f35595cefc
-*/
Modified: freeswitch/trunk/libs/libsndfile/src/sds.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/src/sds.c (original)
+++ freeswitch/trunk/libs/libsndfile/src/sds.c Thu May 21 16:09:30 2009
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 2002-2005 Erik de Castro Lopo <erikd at mega-nerd.com>
+** Copyright (C) 2002-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU Lesser General Public License as published by
@@ -23,11 +23,11 @@
#include <fcntl.h>
#include <string.h>
#include <ctype.h>
+#include <math.h>
#include "sndfile.h"
#include "sfendian.h"
#include "common.h"
-#include "float_cast.h"
/*------------------------------------------------------------------------------
*/
@@ -116,7 +116,7 @@
return error ;
} ;
- if ((psf->sf.format & SF_FORMAT_TYPEMASK) != SF_FORMAT_SDS)
+ if ((SF_CONTAINER (psf->sf.format)) != SF_FORMAT_SDS)
return SFE_BAD_OPEN_FORMAT ;
if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR)
@@ -360,7 +360,7 @@
psf_binheader_writef (psf, "E211", 0xF07E, 0, 1) ;
- switch (psf->sf.format & SF_FORMAT_SUBMASK)
+ switch (SF_CODEC (psf->sf.format))
{ case SF_FORMAT_PCM_S8 :
psds->bitwidth = 8 ;
break ;
@@ -984,10 +984,3 @@
return total ;
} /* sds_write */
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: d5d26aa3-368c-4ca6-bb85-377e5a2578cc
-*/
Modified: freeswitch/trunk/libs/libsndfile/src/sf_unistd.h
==============================================================================
--- freeswitch/trunk/libs/libsndfile/src/sf_unistd.h (original)
+++ freeswitch/trunk/libs/libsndfile/src/sf_unistd.h Thu May 21 16:09:30 2009
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 2002-2004 Erik de Castro Lopo <erikd at mega-nerd.com>
+** Copyright (C) 2002-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU Lesser General Public License as published by
@@ -58,10 +58,4 @@
** #define _IFMT _S_IFMT
** #define _IFREG _S_IFREG
*/
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: 253aea6d-6299-46fd-8d06-bc5f6224c8fe
-*/
+
Modified: freeswitch/trunk/libs/libsndfile/src/sfconfig.h
==============================================================================
--- freeswitch/trunk/libs/libsndfile/src/sfconfig.h (original)
+++ freeswitch/trunk/libs/libsndfile/src/sfconfig.h Thu May 21 16:09:30 2009
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 2005 Erik de Castro Lopo <erikd at mega-nerd.com>
+** Copyright (C) 2005-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU Lesser General Public License as published by
@@ -99,10 +99,3 @@
#endif
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: 2df2316e-8f9d-4860-bba7-f3c16c63eed3
-*/
Modified: freeswitch/trunk/libs/libsndfile/src/sfendian.h
==============================================================================
--- freeswitch/trunk/libs/libsndfile/src/sfendian.h (original)
+++ freeswitch/trunk/libs/libsndfile/src/sfendian.h Thu May 21 16:09:30 2009
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 1999-2006 Erik de Castro Lopo <erikd at mega-nerd.com>
+** Copyright (C) 1999-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU Lesser General Public License as published by
@@ -16,6 +16,9 @@
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
+#ifndef SFENDIAN_INCLUDED
+#define SFENDIAN_INCLUDED
+
#include "sfconfig.h"
#if HAVE_STDINT_H
@@ -247,10 +250,5 @@
{ endswap_int64_t_copy ((int64_t *) dest, (const int64_t *) src, len) ;
} /* endswap_double_copy */
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: f0c5cd54-42d3-4237-90ec-11fe24995de7
-*/
+#endif /* SFENDIAN_INCLUDED */
+
Modified: freeswitch/trunk/libs/libsndfile/src/sndfile.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/src/sndfile.c (original)
+++ freeswitch/trunk/libs/libsndfile/src/sndfile.c Thu May 21 16:09:30 2009
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 1999-2005 Erik de Castro Lopo <erikd at mega-nerd.com>
+** Copyright (C) 1999-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU Lesser General Public License as published by
@@ -28,6 +28,25 @@
#define SNDFILE_MAGICK 0x1234C0DE
+#ifdef __APPLE__
+ /*
+ ** Detect if a compile for a universal binary is being attempted and barf if it is.
+ ** See the URL below for the rationale.
+ */
+ #ifdef __BIG_ENDIAN__
+ #if (CPU_IS_LITTLE_ENDIAN == 1)
+ #error "Universal binary compile detected. See http://www.mega-nerd.com/libsndfile/FAQ.html#Q018"
+ #endif
+ #endif
+
+ #ifdef __LITTLE_ENDIAN__
+ #if (CPU_IS_BIG_ENDIAN == 1)
+ #error "Universal binary compile detected. See http://www.mega-nerd.com/libsndfile/FAQ.html#Q018"
+ #endif
+ #endif
+#endif
+
+
typedef struct
{ int error ;
const char *str ;
@@ -44,6 +63,8 @@
{ SF_ERR_UNSUPPORTED_ENCODING , "Supported file format but unsupported encoding." },
/* Private error values and their associated strings. */
+ { SFE_ZERO_MAJOR_FORMAT , "Error : major format is 0." },
+ { SFE_ZERO_MINOR_FORMAT , "Error : major format is 0." },
{ SFE_BAD_FILE , "File does not exist or is not a regular file (possibly a pipe?)." },
{ SFE_BAD_FILE_READ , "File exists but no data could be read." },
{ SFE_OPEN_FAILED , "Could not open file." },
@@ -61,22 +82,23 @@
{ SFE_UNKNOWN_FORMAT , "File contains data in an unknown format." },
{ SFE_NOT_READMODE , "Read attempted on file currently open for write." },
{ SFE_NOT_WRITEMODE , "Write attempted on file currently open for read." },
- { SFE_BAD_MODE_RW , "This file format does not support read/write mode." },
+ { SFE_BAD_MODE_RW , "Error : This file format does not support read/write mode." },
{ SFE_BAD_SF_INFO , "Internal error : SF_INFO struct incomplete." },
{ SFE_BAD_OFFSET , "Error : supplied offset beyond end of file." },
{ SFE_NO_EMBED_SUPPORT , "Error : embedding not supported for this file format." },
{ SFE_NO_EMBEDDED_RDWR , "Error : cannot open embedded file read/write." },
{ SFE_NO_PIPE_WRITE , "Error : this file format does not support pipe write." },
- { SFE_BAD_RDWR_FORMAT , "Attempted to open read only format for RDWR." },
{ SFE_BAD_VIRTUAL_IO , "Error : bad pointer on SF_VIRTUAL_IO struct." },
+ { SFE_BAD_BROADCAST_INFO_SIZE, "Error : badd SF_BROADCAST_INFO_SIZE." },
{ SFE_INTERLEAVE_MODE , "Attempt to write to file with non-interleaved data." },
{ SFE_INTERLEAVE_SEEK , "Bad karma in seek during interleave read operation." },
{ SFE_INTERLEAVE_READ , "Bad karma in read during interleave read operation." },
{ SFE_INTERNAL , "Unspecified internal error." },
- { SFE_BAD_CONTROL_CMD , "Bad command passed to function sf_command()." },
+ { SFE_BAD_COMMAND_PARAM , "Bad parameter passed to function sf_command." },
{ SFE_BAD_ENDIAN , "Bad endian-ness. Try default endian-ness" },
+ { SFE_CHANNEL_COUNT_ZERO , "Channel count is zero." },
{ SFE_CHANNEL_COUNT , "Too many channels specified." },
{ SFE_BAD_SEEK , "Internal psf_fseek() failed." },
@@ -89,6 +111,7 @@
{ SFE_OPEN_PIPE_RDWR , "Error : attempt toopen a pipe in read/write mode." },
{ SFE_RDWR_POSITION , "Error on RDWR position (cryptic)." },
{ SFE_RDWR_BAD_HEADER , "Error : Cannot open file in read/write mode due to string data in header." },
+ { SFE_CMD_HAS_DATA , "Error : Command fails because file already has audio data." },
{ SFE_STR_NO_SUPPORT , "Error : File type does not support string data." },
{ SFE_STR_NOT_WRITE , "Error : Trying to set a string when file is not in write mode." },
@@ -101,8 +124,9 @@
{ SFE_WAV_NO_RIFF , "Error in WAV file. No 'RIFF' chunk marker." },
{ SFE_WAV_NO_WAVE , "Error in WAV file. No 'WAVE' chunk marker." },
- { SFE_WAV_NO_FMT , "Error in WAV file. No 'fmt ' chunk marker." },
- { SFE_WAV_FMT_SHORT , "Error in WAV file. Short 'fmt ' chunk." },
+ { SFE_WAV_NO_FMT , "Error in WAV/W64/RF64 file. No 'fmt ' chunk marker." },
+ { SFE_WAV_BAD_FMT , "Error in WAV/W64/RF64 file. Malformed 'fmt ' chunk." },
+ { SFE_WAV_FMT_SHORT , "Error in WAV/W64/RF64 file. Short 'fmt ' chunk." },
{ SFE_WAV_BAD_FACT , "Error in WAV file. 'fact' chunk out of place." },
{ SFE_WAV_BAD_PEAK , "Error in WAV file. Bad 'PEAK' chunk." },
@@ -173,27 +197,19 @@
{ SFE_IRCAM_UNKNOWN_FORMAT, "Error in IRCAM file, unknow encoding format." },
{ SFE_W64_64_BIT , "Error in W64 file, file contains 64 bit offset." },
-
{ SFE_W64_NO_RIFF , "Error in W64 file. No 'riff' chunk marker." },
{ SFE_W64_NO_WAVE , "Error in W64 file. No 'wave' chunk marker." },
- { SFE_W64_NO_FMT , "Error in W64 file. No 'fmt ' chunk marker." },
{ SFE_W64_NO_DATA , "Error in W64 file. No 'data' chunk marker." },
-
- { SFE_W64_FMT_SHORT , "Error in W64 file. Short 'fmt ' chunk." },
- { SFE_W64_FMT_TOO_BIG , "Error in W64 file. 'fmt ' chunk too large." },
-
{ SFE_W64_ADPCM_NOT4BIT , "Error in ADPCM W64 file. Invalid bit width." },
{ SFE_W64_ADPCM_CHANNELS , "Error in ADPCM W64 file. Invalid number of channels." },
{ SFE_W64_GSM610_FORMAT , "Error in GSM610 W64 file. Invalid format chunk." },
{ SFE_MAT4_BAD_NAME , "Error in MAT4 file. No variable name." },
{ SFE_MAT4_NO_SAMPLERATE , "Error in MAT4 file. No sample rate." },
- { SFE_MAT4_ZERO_CHANNELS , "Error in MAT4 file. Channel count is zero." },
{ SFE_MAT5_BAD_ENDIAN , "Error in MAT5 file. Not able to determine endian-ness." },
{ SFE_MAT5_NO_BLOCK , "Error in MAT5 file. Bad block structure." },
{ SFE_MAT5_SAMPLE_RATE , "Error in MAT5 file. Not able to determine sample rate." },
- { SFE_MAT5_ZERO_CHANNELS , "Error in MAT5 file. Channel count is zero." },
{ SFE_PVF_NO_PVF1 , "Error in PVF file. No PVF1 marker." },
{ SFE_PVF_BAD_HEADER , "Error in PVF file. Bad header." },
@@ -223,9 +239,16 @@
{ SFE_FLAC_BAD_SAMPLE_RATE, "Error : flac does not support this sample rate." },
{ SFE_FLAC_UNKOWN_ERROR , "Error : unkown error in flac decoder." },
+ { SFE_WVE_NOT_WVE , "Error : not a WVE file." },
+ { SFE_WVE_NO_PIPE , "Error : not able to operate on WVE files over a pipe." },
+
{ SFE_DWVW_BAD_BITWIDTH , "Error : Bad bit width for DWVW encoding. Must be 12, 16 or 24." },
{ SFE_G72X_NOT_MONO , "Error : G72x encoding does not support more than 1 channel." },
+ { SFE_VORBIS_ENCODER_BUG , "Error : Sample rate chosen is known to trigger a Vorbis encoder bug on this CPU." },
+
+ { SFE_RF64_NOT_RF64 , "Error : Not an RF64 file." },
+
{ SFE_MAX_ERROR , "Maximum error number." },
{ SFE_MAX_ERROR + 1 , NULL }
} ;
@@ -240,7 +263,7 @@
static void save_header_info (SF_PRIVATE *psf) ;
static void copy_filename (SF_PRIVATE *psf, const char *path) ;
static int psf_close (SF_PRIVATE *psf) ;
-static int psf_open_file (SF_PRIVATE *psf, int mode, SF_INFO *sfinfo) ;
+static SNDFILE * psf_open_file (SF_PRIVATE *psf, int mode, SF_INFO *sfinfo) ;
static int try_resource_fork (SF_PRIVATE * psf, int mode) ;
@@ -280,7 +303,6 @@
SNDFILE*
sf_open (const char *path, int mode, SF_INFO *sfinfo)
{ SF_PRIVATE *psf ;
- int error = 0 ;
if ((psf = calloc (1, sizeof (SF_PRIVATE))) == NULL)
{ sf_errno = SFE_MALLOC_FAILED ;
@@ -295,33 +317,18 @@
copy_filename (psf, path) ;
if (strcmp (path, "-") == 0)
- error = psf_set_stdio (psf, mode) ;
+ psf->error = psf_set_stdio (psf, mode) ;
else
- error = psf_fopen (psf, path, mode) ;
-
- if (error == 0)
- error = psf_open_file (psf, mode, sfinfo) ;
-
- if (error)
- { sf_errno = error ;
- if (error == SFE_SYSTEM)
- LSF_SNPRINTF (sf_syserr, sizeof (sf_syserr), "%s", psf->syserr) ;
- LSF_SNPRINTF (sf_logbuffer, sizeof (sf_logbuffer), "%s", psf->logbuffer) ;
- psf_close (psf) ;
- return NULL ;
- } ;
-
- memcpy (sfinfo, &(psf->sf), sizeof (SF_INFO)) ;
+ psf->error = psf_fopen (psf, path, mode) ;
- return (SNDFILE*) psf ;
+ return psf_open_file (psf, mode, sfinfo) ;
} /* sf_open */
SNDFILE*
sf_open_fd (int fd, int mode, SF_INFO *sfinfo, int close_desc)
{ SF_PRIVATE *psf ;
- int error ;
- if ((sfinfo->format & SF_FORMAT_TYPEMASK) == SF_FORMAT_SD2)
+ if ((SF_CONTAINER (sfinfo->format)) == SF_FORMAT_SD2)
{ sf_errno = SFE_SD2_FD_DISALLOWED ;
return NULL ;
} ;
@@ -340,43 +347,29 @@
if (! close_desc)
psf->do_not_close_descriptor = SF_TRUE ;
- error = psf_open_file (psf, mode, sfinfo) ;
-
- if (error)
- { sf_errno = error ;
- if (error == SFE_SYSTEM)
- LSF_SNPRINTF (sf_syserr, sizeof (sf_syserr), "%s", psf->syserr) ;
- LSF_SNPRINTF (sf_logbuffer, sizeof (sf_logbuffer), "%s", psf->logbuffer) ;
- psf_close (psf) ;
- return NULL ;
- } ;
-
- memcpy (sfinfo, &(psf->sf), sizeof (SF_INFO)) ;
-
- return (SNDFILE*) psf ;
+ return psf_open_file (psf, mode, sfinfo) ;
} /* sf_open_fd */
SNDFILE*
sf_open_virtual (SF_VIRTUAL_IO *sfvirtual, int mode, SF_INFO *sfinfo, void *user_data)
{ SF_PRIVATE *psf ;
- int error = 0 ;
/* Make sure we have a valid set ot virtual pointers. */
if (sfvirtual->get_filelen == NULL || sfvirtual->seek == NULL || sfvirtual->tell == NULL)
{ sf_errno = SFE_BAD_VIRTUAL_IO ;
- LSF_SNPRINTF (sf_logbuffer, sizeof (sf_logbuffer), "Bad vio_get_filelen / vio_seek / vio_tell in SF_VIRTUAL_IO struct.\n") ;
+ snprintf (sf_logbuffer, sizeof (sf_logbuffer), "Bad vio_get_filelen / vio_seek / vio_tell in SF_VIRTUAL_IO struct.\n") ;
return NULL ;
} ;
if ((mode == SFM_READ || mode == SFM_RDWR) && sfvirtual->read == NULL)
{ sf_errno = SFE_BAD_VIRTUAL_IO ;
- LSF_SNPRINTF (sf_logbuffer, sizeof (sf_logbuffer), "Bad vio_read in SF_VIRTUAL_IO struct.\n") ;
+ snprintf (sf_logbuffer, sizeof (sf_logbuffer), "Bad vio_read in SF_VIRTUAL_IO struct.\n") ;
return NULL ;
} ;
if ((mode == SFM_WRITE || mode == SFM_RDWR) && sfvirtual->write == NULL)
{ sf_errno = SFE_BAD_VIRTUAL_IO ;
- LSF_SNPRINTF (sf_logbuffer, sizeof (sf_logbuffer), "Bad vio_write in SF_VIRTUAL_IO struct.\n") ;
+ snprintf (sf_logbuffer, sizeof (sf_logbuffer), "Bad vio_write in SF_VIRTUAL_IO struct.\n") ;
return NULL ;
} ;
@@ -393,20 +386,7 @@
psf->mode = mode ;
- error = psf_open_file (psf, mode, sfinfo) ;
-
- if (error)
- { sf_errno = error ;
- if (error == SFE_SYSTEM)
- LSF_SNPRINTF (sf_syserr, sizeof (sf_syserr), "%s", psf->syserr) ;
- LSF_SNPRINTF (sf_logbuffer, sizeof (sf_logbuffer), "%s", psf->logbuffer) ;
- psf_close (psf) ;
- return NULL ;
- } ;
-
- memcpy (sfinfo, &(psf->sf), sizeof (SF_INFO)) ;
-
- return (SNDFILE*) psf ;
+ return psf_open_file (psf, mode, sfinfo) ;
} /* sf_open_virtual */
int
@@ -488,10 +468,7 @@
{ SF_PRIVATE *psf ;
if (sndfile == NULL)
- { if (sf_errno != 0)
- return sf_errno ;
- return 0 ;
- } ;
+ return sf_errno ;
VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile, psf, 0) ;
@@ -540,7 +517,7 @@
errnum = psf->error ;
} ;
- LSF_SNPRINTF (str, maxlen, "%s", sf_error_number (errnum)) ;
+ snprintf (str, maxlen, "%s", sf_error_number (errnum)) ;
return SFE_NO_ERROR ;
} /* sf_error_str */
@@ -552,8 +529,8 @@
sf_format_check (const SF_INFO *info)
{ int subformat, endian ;
- subformat = info->format & SF_FORMAT_SUBMASK ;
- endian = info->format & SF_FORMAT_ENDMASK ;
+ subformat = SF_CODEC (info->format) ;
+ endian = SF_ENDIAN (info->format) ;
/* This is the place where each file format can check if the suppiled
** SF_INFO struct is valid.
@@ -566,7 +543,7 @@
if (info->samplerate < 0)
return 0 ;
- switch (info->format & SF_FORMAT_TYPEMASK)
+ switch (SF_CONTAINER (info->format))
{ case SF_FORMAT_WAV :
case SF_FORMAT_WAVEX :
/* WAV now allows both endian, RIFF or RIFX (little or big respectively) */
@@ -791,6 +768,43 @@
return 1 ;
break ;
+ case SF_FORMAT_WVE :
+ /* WVE is strictly big endian. */
+ if (endian == SF_ENDIAN_BIG || endian == SF_ENDIAN_CPU)
+ return 0 ;
+ if (info->channels > 1)
+ return 0 ;
+ if (subformat == SF_FORMAT_ALAW)
+ return 1 ;
+ break ;
+
+ case SF_FORMAT_OGG :
+ if (subformat == SF_FORMAT_VORBIS)
+ return 1 ;
+ break ;
+
+ case SF_FORMAT_MPC2K :
+ /* MPC2000 is strictly little endian. */
+ if (endian == SF_ENDIAN_BIG || endian == SF_ENDIAN_CPU)
+ return 0 ;
+ if (info->channels > 2)
+ return 0 ;
+ if (subformat == SF_FORMAT_PCM_16)
+ return 1 ;
+ break ;
+
+ case SF_FORMAT_RF64 :
+ if (endian == SF_ENDIAN_BIG || endian == SF_ENDIAN_CPU)
+ return 0 ;
+ if (subformat == SF_FORMAT_PCM_U8 || subformat == SF_FORMAT_PCM_16)
+ return 1 ;
+ if (subformat == SF_FORMAT_PCM_24 || subformat == SF_FORMAT_PCM_32)
+ return 1 ;
+ if (subformat == SF_FORMAT_ULAW || subformat == SF_FORMAT_ALAW)
+ return 1 ;
+ if (subformat == SF_FORMAT_FLOAT || subformat == SF_FORMAT_DOUBLE)
+ return 1 ;
+ break ;
default : break ;
} ;
@@ -802,63 +816,66 @@
int
sf_command (SNDFILE *sndfile, int command, void *data, int datasize)
-{ SF_PRIVATE *psf = NULL ;
+{ SF_PRIVATE *psf = (SF_PRIVATE *) sndfile ;
int old_value ;
/* This set of commands do not need the sndfile parameter. */
switch (command)
{ case SFC_GET_LIB_VERSION :
if (data == NULL)
- return (psf->error = SFE_BAD_CONTROL_CMD) ;
+ { if (psf)
+ psf->error = SFE_BAD_COMMAND_PARAM ;
+ return SFE_BAD_COMMAND_PARAM ;
+ } ;
if (ENABLE_EXPERIMENTAL_CODE)
- LSF_SNPRINTF (data, datasize, "%s-%s-exp", PACKAGE_NAME, PACKAGE_VERSION) ;
+ snprintf (data, datasize, "%s-%s-exp", PACKAGE_NAME, PACKAGE_VERSION) ;
else
- LSF_SNPRINTF (data, datasize, "%s-%s", PACKAGE_NAME, PACKAGE_VERSION) ;
+ snprintf (data, datasize, "%s-%s", PACKAGE_NAME, PACKAGE_VERSION) ;
return strlen (data) ;
case SFC_GET_SIMPLE_FORMAT_COUNT :
if (data == NULL || datasize != SIGNED_SIZEOF (int))
- return (sf_errno = SFE_BAD_CONTROL_CMD) ;
+ return (sf_errno = SFE_BAD_COMMAND_PARAM) ;
*((int*) data) = psf_get_format_simple_count () ;
return 0 ;
case SFC_GET_SIMPLE_FORMAT :
if (data == NULL || datasize != SIGNED_SIZEOF (SF_FORMAT_INFO))
- return (sf_errno = SFE_BAD_CONTROL_CMD) ;
+ return (sf_errno = SFE_BAD_COMMAND_PARAM) ;
return psf_get_format_simple (data) ;
case SFC_GET_FORMAT_MAJOR_COUNT :
if (data == NULL || datasize != SIGNED_SIZEOF (int))
- return (sf_errno = SFE_BAD_CONTROL_CMD) ;
+ return (sf_errno = SFE_BAD_COMMAND_PARAM) ;
*((int*) data) = psf_get_format_major_count () ;
return 0 ;
case SFC_GET_FORMAT_MAJOR :
if (data == NULL || datasize != SIGNED_SIZEOF (SF_FORMAT_INFO))
- return (sf_errno = SFE_BAD_CONTROL_CMD) ;
+ return (sf_errno = SFE_BAD_COMMAND_PARAM) ;
return psf_get_format_major (data) ;
case SFC_GET_FORMAT_SUBTYPE_COUNT :
if (data == NULL || datasize != SIGNED_SIZEOF (int))
- return (sf_errno = SFE_BAD_CONTROL_CMD) ;
+ return (sf_errno = SFE_BAD_COMMAND_PARAM) ;
*((int*) data) = psf_get_format_subtype_count () ;
return 0 ;
case SFC_GET_FORMAT_SUBTYPE :
if (data == NULL || datasize != SIGNED_SIZEOF (SF_FORMAT_INFO))
- return (sf_errno = SFE_BAD_CONTROL_CMD) ;
+ return (sf_errno = SFE_BAD_COMMAND_PARAM) ;
return psf_get_format_subtype (data) ;
case SFC_GET_FORMAT_INFO :
if (data == NULL || datasize != SIGNED_SIZEOF (SF_FORMAT_INFO))
- return (sf_errno = SFE_BAD_CONTROL_CMD) ;
+ return (sf_errno = SFE_BAD_COMMAND_PARAM) ;
return psf_get_format_info (data) ;
} ;
if (sndfile == NULL && command == SFC_GET_LOG_INFO)
{ if (data == NULL)
- return (psf->error = SFE_BAD_CONTROL_CMD) ;
- LSF_SNPRINTF (data, datasize, "%s", sf_logbuffer) ;
+ return (psf->error = SFE_BAD_COMMAND_PARAM) ;
+ snprintf (data, datasize, "%s", sf_logbuffer) ;
return strlen (data) ;
} ;
@@ -870,6 +887,12 @@
psf->norm_float = (datasize) ? SF_TRUE : SF_FALSE ;
return old_value ;
+ case SFC_GET_CURRENT_SF_INFO :
+ if (data == NULL || datasize != SIGNED_SIZEOF (SF_INFO))
+ return (sf_errno = SFE_BAD_COMMAND_PARAM) ;
+ memcpy (data, &psf->sf, sizeof (SF_INFO)) ;
+ break ;
+
case SFC_SET_NORM_DOUBLE :
old_value = psf->norm_double ;
psf->norm_double = (datasize) ? SF_TRUE : SF_FALSE ;
@@ -889,14 +912,19 @@
psf->float_max = psf_calc_signal_max (psf, SF_FALSE) ;
return old_value ;
+ case SFC_SET_SCALE_INT_FLOAT_WRITE :
+ old_value = psf->scale_int_float ;
+ psf->scale_int_float = (datasize != 0) ? SF_TRUE : SF_FALSE ;
+ return old_value ;
+
case SFC_SET_ADD_PEAK_CHUNK :
- { int format = psf->sf.format & SF_FORMAT_TYPEMASK ;
+ { int format = SF_CONTAINER (psf->sf.format) ;
/* Only WAV and AIFF support the PEAK chunk. */
if (format != SF_FORMAT_WAV && format != SF_FORMAT_WAVEX && format != SF_FORMAT_AIFF)
return SF_FALSE ;
- format = psf->sf.format & SF_FORMAT_SUBMASK ;
+ format = SF_CODEC (psf->sf.format) ;
/* Only files containg the following data types support the PEAK chunk. */
if (format != SF_FORMAT_FLOAT && format != SF_FORMAT_DOUBLE)
@@ -904,11 +932,13 @@
} ;
/* Can only do this is in SFM_WRITE mode. */
- if (psf->mode != SFM_WRITE)
+ if (psf->mode != SFM_WRITE && psf->mode != SFM_RDWR)
return SF_FALSE ;
/* If data has already been written this must fail. */
if (psf->have_written)
+ { psf->error = SFE_CMD_HAS_DATA ;
return SF_FALSE ;
+ } ;
/* Everything seems OK, so set psf->has_peak and re-write header. */
if (datasize == SF_FALSE && psf->peak_info != NULL)
{ free (psf->peak_info) ;
@@ -916,51 +946,55 @@
}
else if (psf->peak_info == NULL)
{ psf->peak_info = peak_info_calloc (psf->sf.channels) ;
- psf->peak_info->peak_loc = SF_PEAK_START ;
+ if (psf->peak_info != NULL)
+ psf->peak_info->peak_loc = SF_PEAK_START ;
} ;
if (psf->write_header)
psf->write_header (psf, SF_TRUE) ;
return datasize ;
+ case SFC_SET_ADD_HEADER_PAD_CHUNK :
+ return SF_FALSE ;
+
case SFC_GET_LOG_INFO :
if (data == NULL)
- return (psf->error = SFE_BAD_CONTROL_CMD) ;
- LSF_SNPRINTF (data, datasize, "%s", psf->logbuffer) ;
+ return SFE_BAD_COMMAND_PARAM ;
+ snprintf (data, datasize, "%s", psf->logbuffer) ;
break ;
case SFC_CALC_SIGNAL_MAX :
if (data == NULL || datasize != sizeof (double))
- return (psf->error = SFE_BAD_CONTROL_CMD) ;
+ return (psf->error = SFE_BAD_COMMAND_PARAM) ;
*((double*) data) = psf_calc_signal_max (psf, SF_FALSE) ;
break ;
case SFC_CALC_NORM_SIGNAL_MAX :
if (data == NULL || datasize != sizeof (double))
- return (psf->error = SFE_BAD_CONTROL_CMD) ;
+ return (psf->error = SFE_BAD_COMMAND_PARAM) ;
*((double*) data) = psf_calc_signal_max (psf, SF_TRUE) ;
break ;
case SFC_CALC_MAX_ALL_CHANNELS :
if (data == NULL || datasize != SIGNED_SIZEOF (double) * psf->sf.channels)
- return (psf->error = SFE_BAD_CONTROL_CMD) ;
+ return (psf->error = SFE_BAD_COMMAND_PARAM) ;
return psf_calc_max_all_channels (psf, (double*) data, SF_FALSE) ;
case SFC_CALC_NORM_MAX_ALL_CHANNELS :
if (data == NULL || datasize != SIGNED_SIZEOF (double) * psf->sf.channels)
- return (psf->error = SFE_BAD_CONTROL_CMD) ;
+ return (psf->error = SFE_BAD_COMMAND_PARAM) ;
return psf_calc_max_all_channels (psf, (double*) data, SF_TRUE) ;
case SFC_GET_SIGNAL_MAX :
if (data == NULL || datasize != sizeof (double))
- { psf->error = SFE_BAD_CONTROL_CMD ;
+ { psf->error = SFE_BAD_COMMAND_PARAM ;
return SF_FALSE ;
} ;
return psf_get_signal_max (psf, (double *) data) ;
case SFC_GET_MAX_ALL_CHANNELS :
if (data == NULL || datasize != SIGNED_SIZEOF (double) * psf->sf.channels)
- { psf->error = SFE_BAD_CONTROL_CMD ;
+ { psf->error = SFE_BAD_COMMAND_PARAM ;
return SF_FALSE ;
} ;
return psf_get_max_all_channels (psf, (double*) data) ;
@@ -986,7 +1020,7 @@
case SFC_SET_DITHER_ON_WRITE :
if (data == NULL || datasize != SIGNED_SIZEOF (SF_DITHER_INFO))
- return (psf->error = SFE_BAD_CONTROL_CMD) ;
+ return (psf->error = SFE_BAD_COMMAND_PARAM) ;
memcpy (&psf->write_dither, data, sizeof (psf->write_dither)) ;
if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR)
dither_init (psf, SFM_WRITE) ;
@@ -994,7 +1028,7 @@
case SFC_SET_DITHER_ON_READ :
if (data == NULL || datasize != SIGNED_SIZEOF (SF_DITHER_INFO))
- return (psf->error = SFE_BAD_CONTROL_CMD) ;
+ return (psf->error = SFE_BAD_COMMAND_PARAM) ;
memcpy (&psf->read_dither, data, sizeof (psf->read_dither)) ;
if (psf->mode == SFM_READ || psf->mode == SFM_RDWR)
dither_init (psf, SFM_READ) ;
@@ -1022,9 +1056,10 @@
case SFC_SET_RAW_START_OFFSET :
if (data == NULL || datasize != sizeof (sf_count_t))
- return (psf->error = SFE_BAD_CONTROL_CMD) ;
- if ((psf->sf.format & SF_FORMAT_TYPEMASK) != SF_FORMAT_RAW)
- return (psf->error = SFE_BAD_CONTROL_CMD) ;
+ return (psf->error = SFE_BAD_COMMAND_PARAM) ;
+
+ if ((SF_CONTAINER (psf->sf.format)) != SF_FORMAT_RAW)
+ return (psf->error = SFE_BAD_COMMAND_PARAM) ;
psf->dataoffset = *((sf_count_t*) data) ;
sf_seek (sndfile, 0, SEEK_CUR) ;
@@ -1032,7 +1067,7 @@
case SFC_GET_EMBED_FILE_INFO :
if (data == NULL || datasize != sizeof (SF_EMBED_FILE_INFO))
- return (psf->error = SFE_BAD_CONTROL_CMD) ;
+ return (psf->error = SFE_BAD_COMMAND_PARAM) ;
((SF_EMBED_FILE_INFO*) data)->offset = psf->fileoffset ;
((SF_EMBED_FILE_INFO*) data)->length = psf->filelength ;
@@ -1041,12 +1076,12 @@
/* Lite remove start */
case SFC_TEST_IEEE_FLOAT_REPLACE :
psf->ieee_replace = (datasize) ? SF_TRUE : SF_FALSE ;
- if ((psf->sf.format & SF_FORMAT_SUBMASK) == SF_FORMAT_FLOAT)
+ if ((SF_CODEC (psf->sf.format)) == SF_FORMAT_FLOAT)
float32_init (psf) ;
- else if ((psf->sf.format & SF_FORMAT_SUBMASK) == SF_FORMAT_DOUBLE)
+ else if ((SF_CODEC (psf->sf.format)) == SF_FORMAT_DOUBLE)
double64_init (psf) ;
else
- return (psf->error = SFE_BAD_CONTROL_CMD) ;
+ return (psf->error = SFE_BAD_COMMAND_PARAM) ;
break ;
/* Lite remove end */
@@ -1059,47 +1094,63 @@
case SFC_GET_LOOP_INFO :
if (datasize != sizeof (SF_LOOP_INFO) || data == NULL)
+ { psf->error = SFE_BAD_COMMAND_PARAM ;
return SF_FALSE ;
+ } ;
if (psf->loop_info == NULL)
return SF_FALSE ;
memcpy (data, psf->loop_info, sizeof (SF_LOOP_INFO)) ;
return SF_TRUE ;
case SFC_SET_BROADCAST_INFO :
- { int format = psf->sf.format & SF_FORMAT_TYPEMASK ;
+ { int format = SF_CONTAINER (psf->sf.format) ;
/* Only WAV supports the BEXT (Broadcast) chunk. */
if (format != SF_FORMAT_WAV && format != SF_FORMAT_WAVEX)
return SF_FALSE ;
} ;
- /* Can only do this is in SFM_WRITE mode. */
- if (psf->mode != SFM_WRITE)
+ /* Only makes sense in SFM_WRITE or SFM_RDWR mode. */
+ if ((psf->mode != SFM_WRITE) && (psf->mode != SFM_RDWR))
return SF_FALSE ;
/* If data has already been written this must fail. */
- if (psf->have_written)
+ if (psf->broadcast_var == NULL && psf->have_written)
+ { psf->error = SFE_CMD_HAS_DATA ;
return SF_FALSE ;
+ } ;
+#if 0
if (psf->broadcast_info == NULL)
psf->broadcast_info = broadcast_info_alloc () ;
broadcast_info_copy (psf->broadcast_info, data) ;
- broadcast_add_coding_history (psf->broadcast_info, psf->sf.channels, psf->sf.samplerate) ;
+ broadcast_add_coding_history (psf->broadcast_info, psf->sf.channels, psf->sf.samplerate, psf->sf.format) ;
+#else
+ broadcast_var_set (psf, data, datasize) ;
+#endif
if (psf->write_header)
psf->write_header (psf, SF_TRUE) ;
return SF_TRUE ;
case SFC_GET_BROADCAST_INFO :
- if (datasize != sizeof (SF_BROADCAST_INFO) || data == NULL)
+ if (data == NULL)
+ { psf->error = SFE_BAD_COMMAND_PARAM ;
return SF_FALSE ;
+ } ;
+#if 0
if (psf->broadcast_info == NULL)
return SF_FALSE ;
return broadcast_info_copy (data, psf->broadcast_info) ;
+#else
+ return broadcast_var_get (psf, data, datasize) ;
+#endif
case SFC_GET_INSTRUMENT :
if (datasize != sizeof (SF_INSTRUMENT) || data == NULL)
+ { psf->error = SFE_BAD_COMMAND_PARAM ;
return SF_FALSE ;
+ } ;
if (psf->instrument == NULL)
return SF_FALSE ;
memcpy (data, psf->instrument, sizeof (SF_INSTRUMENT)) ;
@@ -1108,9 +1159,14 @@
case SFC_SET_INSTRUMENT :
/* If data has already been written this must fail. */
if (psf->have_written)
+ { psf->error = SFE_CMD_HAS_DATA ;
return SF_FALSE ;
+ } ;
if (datasize != sizeof (SF_INSTRUMENT) || data == NULL)
+ { psf->error = SFE_BAD_COMMAND_PARAM ;
return SF_FALSE ;
+ } ;
+
if (psf->instrument == NULL && (psf->instrument = psf_instrument_alloc ()) == NULL)
{ psf->error = SFE_MALLOC_FAILED ;
return SF_FALSE ;
@@ -1118,13 +1174,16 @@
memcpy (psf->instrument, data, sizeof (SF_INSTRUMENT)) ;
return SF_TRUE ;
+ case SFC_RAW_DATA_NEEDS_ENDSWAP :
+ return psf->data_endswap ;
+
default :
/* Must be a file specific command. Pass it on. */
if (psf->command)
return psf->command (psf, command, data, datasize) ;
psf_log_printf (psf, "*** sf_command : cmd = 0x%X\n", command) ;
- return (psf->error = SFE_BAD_CONTROL_CMD) ;
+ return (psf->error = SFE_BAD_COMMAND_PARAM) ;
} ;
return 0 ;
@@ -1209,7 +1268,13 @@
if (psf->error)
return PSF_SEEK_ERROR ;
- if (seek_from_start < 0 || seek_from_start > psf->sf.frames)
+ if (psf->mode == SFM_RDWR || psf->mode == SFM_WRITE)
+ { if (seek_from_start < 0)
+ { psf->error = SFE_BAD_SEEK ;
+ return PSF_SEEK_ERROR ;
+ } ;
+ }
+ else if (seek_from_start < 0 || seek_from_start > psf->sf.frames)
{ psf->error = SFE_BAD_SEEK ;
return PSF_SEEK_ERROR ;
} ;
@@ -1272,7 +1337,7 @@
sf_count_t
sf_read_raw (SNDFILE *sndfile, void *ptr, sf_count_t bytes)
{ SF_PRIVATE *psf ;
- sf_count_t count ;
+ sf_count_t count, extra ;
int bytewidth, blockwidth ;
VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile, psf, 1) ;
@@ -1297,10 +1362,14 @@
count = psf_fread (ptr, 1, bytes, psf) ;
- if (count < bytes)
- psf_memset (((char*) ptr) + count, 0, bytes - count) ;
-
- psf->read_current += count / blockwidth ;
+ if (psf->read_current + count / blockwidth <= psf->sf.frames)
+ psf->read_current += count / blockwidth ;
+ else
+ { count = (psf->sf.frames - psf->read_current) * blockwidth ;
+ extra = bytes - count ;
+ psf_memset (((char *) ptr) + count, 0, extra) ;
+ psf->read_current = psf->sf.frames ;
+ } ;
psf->last_op = SFM_READ ;
@@ -1343,22 +1412,17 @@
count = psf->read_short (psf, ptr, len) ;
- if (psf->read_current + count / psf->sf.channels > psf->sf.frames)
+ if (psf->read_current + count / psf->sf.channels <= psf->sf.frames)
+ psf->read_current += count / psf->sf.channels ;
+ else
{ count = (psf->sf.frames - psf->read_current) * psf->sf.channels ;
extra = len - count ;
psf_memset (ptr + count, 0, extra * sizeof (short)) ;
psf->read_current = psf->sf.frames ;
} ;
- psf->read_current += count / psf->sf.channels ;
-
psf->last_op = SFM_READ ;
- if (psf->read_current > psf->sf.frames)
- { count = psf->sf.channels * (psf->read_current - psf->sf.frames) ;
- psf->read_current = psf->sf.frames ;
- } ;
-
return count ;
} /* sf_read_short */
@@ -1390,22 +1454,17 @@
count = psf->read_short (psf, ptr, frames * psf->sf.channels) ;
- if (psf->read_current + count / psf->sf.channels > psf->sf.frames)
+ if (psf->read_current + count / psf->sf.channels <= psf->sf.frames)
+ psf->read_current += count / psf->sf.channels ;
+ else
{ count = (psf->sf.frames - psf->read_current) * psf->sf.channels ;
extra = frames * psf->sf.channels - count ;
psf_memset (ptr + count, 0, extra * sizeof (short)) ;
psf->read_current = psf->sf.frames ;
} ;
- psf->read_current += count / psf->sf.channels ;
-
psf->last_op = SFM_READ ;
- if (psf->read_current > psf->sf.frames)
- { count = psf->sf.channels * (psf->read_current - psf->sf.frames) ;
- psf->read_current = psf->sf.frames ;
- } ;
-
return count / psf->sf.channels ;
} /* sf_readf_short */
@@ -1445,22 +1504,17 @@
count = psf->read_int (psf, ptr, len) ;
- if (psf->read_current + count / psf->sf.channels > psf->sf.frames)
+ if (psf->read_current + count / psf->sf.channels <= psf->sf.frames)
+ psf->read_current += count / psf->sf.channels ;
+ else
{ count = (psf->sf.frames - psf->read_current) * psf->sf.channels ;
extra = len - count ;
psf_memset (ptr + count, 0, extra * sizeof (int)) ;
psf->read_current = psf->sf.frames ;
} ;
- psf->read_current += count / psf->sf.channels ;
-
psf->last_op = SFM_READ ;
- if (psf->read_current > psf->sf.frames)
- { count = psf->sf.channels * (psf->read_current - psf->sf.frames) ;
- psf->read_current = psf->sf.frames ;
- } ;
-
return count ;
} /* sf_read_int */
@@ -1492,22 +1546,17 @@
count = psf->read_int (psf, ptr, frames * psf->sf.channels) ;
- if (psf->read_current + count / psf->sf.channels > psf->sf.frames)
+ if (psf->read_current + count / psf->sf.channels <= psf->sf.frames)
+ psf->read_current += count / psf->sf.channels ;
+ else
{ count = (psf->sf.frames - psf->read_current) * psf->sf.channels ;
extra = frames * psf->sf.channels - count ;
psf_memset (ptr + count, 0, extra * sizeof (int)) ;
psf->read_current = psf->sf.frames ;
} ;
- psf->read_current += count / psf->sf.channels ;
-
psf->last_op = SFM_READ ;
- if (psf->read_current > psf->sf.frames)
- { count = psf->sf.channels * (psf->read_current - psf->sf.frames) ;
- psf->read_current = psf->sf.frames ;
- } ;
-
return count / psf->sf.channels ;
} /* sf_readf_int */
@@ -1547,22 +1596,17 @@
count = psf->read_float (psf, ptr, len) ;
- if (psf->read_current + count / psf->sf.channels > psf->sf.frames)
+ if (psf->read_current + count / psf->sf.channels <= psf->sf.frames)
+ psf->read_current += count / psf->sf.channels ;
+ else
{ count = (psf->sf.frames - psf->read_current) * psf->sf.channels ;
extra = len - count ;
psf_memset (ptr + count, 0, extra * sizeof (float)) ;
psf->read_current = psf->sf.frames ;
} ;
- psf->read_current += count / psf->sf.channels ;
-
psf->last_op = SFM_READ ;
- if (psf->read_current > psf->sf.frames)
- { count = psf->sf.channels * (psf->read_current - psf->sf.frames) ;
- psf->read_current = psf->sf.frames ;
- } ;
-
return count ;
} /* sf_read_float */
@@ -1594,22 +1638,17 @@
count = psf->read_float (psf, ptr, frames * psf->sf.channels) ;
- if (psf->read_current + count / psf->sf.channels > psf->sf.frames)
+ if (psf->read_current + count / psf->sf.channels <= psf->sf.frames)
+ psf->read_current += count / psf->sf.channels ;
+ else
{ count = (psf->sf.frames - psf->read_current) * psf->sf.channels ;
extra = frames * psf->sf.channels - count ;
psf_memset (ptr + count, 0, extra * sizeof (float)) ;
psf->read_current = psf->sf.frames ;
} ;
- psf->read_current += count / psf->sf.channels ;
-
psf->last_op = SFM_READ ;
- if (psf->read_current > psf->sf.frames)
- { count = psf->sf.channels * (psf->read_current - psf->sf.frames) ;
- psf->read_current = psf->sf.frames ;
- } ;
-
return count / psf->sf.channels ;
} /* sf_readf_float */
@@ -1649,22 +1688,17 @@
count = psf->read_double (psf, ptr, len) ;
- if (psf->read_current + count / psf->sf.channels > psf->sf.frames)
+ if (psf->read_current + count / psf->sf.channels <= psf->sf.frames)
+ psf->read_current += count / psf->sf.channels ;
+ else
{ count = (psf->sf.frames - psf->read_current) * psf->sf.channels ;
extra = len - count ;
psf_memset (ptr + count, 0, extra * sizeof (double)) ;
psf->read_current = psf->sf.frames ;
} ;
- psf->read_current += count / psf->sf.channels ;
-
psf->last_op = SFM_READ ;
- if (psf->read_current > psf->sf.frames)
- { count = psf->sf.channels * (psf->read_current - psf->sf.frames) ;
- psf->read_current = psf->sf.frames ;
- } ;
-
return count ;
} /* sf_read_double */
@@ -1696,22 +1730,17 @@
count = psf->read_double (psf, ptr, frames * psf->sf.channels) ;
- if (psf->read_current + count / psf->sf.channels > psf->sf.frames)
+ if (psf->read_current + count / psf->sf.channels <= psf->sf.frames)
+ psf->read_current += count / psf->sf.channels ;
+ else
{ count = (psf->sf.frames - psf->read_current) * psf->sf.channels ;
extra = frames * psf->sf.channels - count ;
psf_memset (ptr + count, 0, extra * sizeof (double)) ;
psf->read_current = psf->sf.frames ;
} ;
- psf->read_current += count / psf->sf.channels ;
-
psf->last_op = SFM_READ ;
- if (psf->read_current > psf->sf.frames)
- { count = psf->sf.channels * (psf->read_current - psf->sf.frames) ;
- psf->read_current = psf->sf.frames ;
- } ;
-
return count / psf->sf.channels ;
} /* sf_readf_double */
@@ -2129,9 +2158,6 @@
char buffer [16] ;
int format = 0 ;
- if (psf->filename == NULL)
- return 0 ;
-
if ((cptr = strrchr (psf->filename, '.')) == NULL)
return 0 ;
@@ -2161,11 +2187,17 @@
psf->sf.samplerate = 8000 ;
format = SF_FORMAT_RAW | SF_FORMAT_ULAW ;
}
- else if (strcmp (cptr, "vox") == 0)
+
+ else if (strcmp (cptr, "vox") == 0 || strcmp (cptr, "vox8") == 0)
{ psf->sf.channels = 1 ;
psf->sf.samplerate = 8000 ;
format = SF_FORMAT_RAW | SF_FORMAT_VOX_ADPCM ;
}
+ else if (strcmp (cptr, "vox6") == 0)
+ { psf->sf.channels = 1 ;
+ psf->sf.samplerate = 6000 ;
+ format = SF_FORMAT_RAW | SF_FORMAT_VOX_ADPCM ;
+ }
else if (strcmp (cptr, "gsm") == 0)
{ psf->sf.channels = 1 ;
psf->sf.samplerate = 8000 ;
@@ -2173,7 +2205,7 @@
}
/* For RAW files, make sure the dataoffset if set correctly. */
- if ((format & SF_FORMAT_TYPEMASK) == SF_FORMAT_RAW)
+ if ((SF_CONTAINER (format)) == SF_FORMAT_RAW)
psf->dataoffset = 0 ;
return format ;
@@ -2240,7 +2272,7 @@
if (buffer [0] == MAKE_MARKER ('c', 'a', 'f', 'f') && buffer [2] == MAKE_MARKER ('d', 'e', 's', 'c'))
return SF_FORMAT_CAF ;
- if (ENABLE_EXPERIMENTAL_CODE && buffer [0] == MAKE_MARKER ('O', 'g', 'g', 'S'))
+ if (buffer [0] == MAKE_MARKER ('O', 'g', 'g', 'S'))
return SF_FORMAT_OGG ;
if (buffer [0] == MAKE_MARKER ('A', 'L', 'a', 'w') && buffer [1] == MAKE_MARKER ('S', 'o', 'u', 'n')
@@ -2257,6 +2289,9 @@
if ((buffer [0] & MAKE_MARKER (0xFF, 0xFF, 0x80, 0xFF)) == MAKE_MARKER (0xF0, 0x7E, 0, 0x01))
return SF_FORMAT_SDS ;
+ if ((buffer [0] & MAKE_MARKER (0xFF, 0xFF, 0, 0)) == MAKE_MARKER (1, 4, 0, 0))
+ return SF_FORMAT_MPC2K ;
+
if (buffer [0] == MAKE_MARKER ('C', 'A', 'T', ' ') && buffer [2] == MAKE_MARKER ('R', 'E', 'X', '2'))
return SF_FORMAT_REX2 ;
@@ -2283,6 +2318,9 @@
if (buffer [0] == MAKE_MARKER ('2', 'B', 'I', 'T'))
return SF_FORMAT_AVR ;
+ if (buffer [0] == MAKE_MARKER ('R', 'F', '6', '4') && buffer [2] == MAKE_MARKER ('W', 'A', 'V', 'E'))
+ return SF_FORMAT_RF64 ;
+
/* This must be the second last one. */
if (psf->filelength > 0 && (format = try_resource_fork (psf, SFM_READ)) != 0)
return format ;
@@ -2299,9 +2337,9 @@
return 0 ;
if (sfinfo->channels < 1)
return 0 ;
- if ((sfinfo->format & SF_FORMAT_TYPEMASK) == 0)
+ if ((SF_CONTAINER (sfinfo->format)) == 0)
return 0 ;
- if ((sfinfo->format & SF_FORMAT_SUBMASK) == 0)
+ if ((SF_CODEC (sfinfo->format)) == 0)
return 0 ;
if (sfinfo->sections < 1)
return 0 ;
@@ -2329,7 +2367,7 @@
static void
save_header_info (SF_PRIVATE *psf)
-{ LSF_SNPRINTF (sf_logbuffer, sizeof (sf_logbuffer), "%s", psf->logbuffer) ;
+{ snprintf (sf_logbuffer, sizeof (sf_logbuffer), "%s", psf->logbuffer) ;
} /* save_header_info */
static void
@@ -2337,16 +2375,16 @@
{ const char *ccptr ;
char *cptr ;
- LSF_SNPRINTF (psf->filepath, sizeof (psf->filepath), "%s", path) ;
+ snprintf (psf->filepath, sizeof (psf->filepath), "%s", path) ;
if ((ccptr = strrchr (path, '/')) || (ccptr = strrchr (path, '\\')))
ccptr ++ ;
else
ccptr = path ;
- LSF_SNPRINTF (psf->filename, sizeof (psf->filename), "%s", ccptr) ;
+ snprintf (psf->filename, sizeof (psf->filename), "%s", ccptr) ;
/* Now grab the directory. */
- LSF_SNPRINTF (psf->directory, sizeof (psf->directory), "%s", path) ;
+ snprintf (psf->directory, sizeof (psf->directory), "%s", path) ;
if ((cptr = strrchr (psf->directory, '/')) || (cptr = strrchr (psf->directory, '\\')))
cptr [1] = 0 ;
else
@@ -2360,14 +2398,14 @@
static int
psf_close (SF_PRIVATE *psf)
-{ int error ;
+{ int error = 0 ;
if (psf->codec_close)
error = psf->codec_close (psf) ;
if (psf->container_close)
error = psf->container_close (psf) ;
- psf_fclose (psf) ;
+ error = psf_fclose (psf) ;
psf_close_rsrc (psf) ;
if (psf->container_data)
@@ -2385,8 +2423,8 @@
if (psf->peak_info)
free (psf->peak_info) ;
- if (psf->broadcast_info)
- free (psf->broadcast_info) ;
+ if (psf->broadcast_var)
+ free (psf->broadcast_var) ;
if (psf->loop_info)
free (psf->loop_info) ;
@@ -2398,25 +2436,37 @@
free (psf->channel_map) ;
if (psf->format_desc)
- { memset (psf->format_desc, 0, strlen (psf->format_desc)) ;
+ { psf->format_desc [0] = 0 ;
free (psf->format_desc) ;
} ;
memset (psf, 0, sizeof (SF_PRIVATE)) ;
free (psf) ;
- return 0 ;
+ return error ;
} /* psf_close */
-static int
+static SNDFILE *
psf_open_file (SF_PRIVATE *psf, int mode, SF_INFO *sfinfo)
{ int error, format ;
+ sf_errno = error = 0 ;
+ sf_logbuffer [0] = 0 ;
+
+ if (psf->error)
+ { error = psf->error ;
+ goto error_exit ;
+ } ;
+
if (mode != SFM_READ && mode != SFM_WRITE && mode != SFM_RDWR)
- return SFE_BAD_OPEN_MODE ;
+ { error = SFE_BAD_OPEN_MODE ;
+ goto error_exit ;
+ } ;
if (sfinfo == NULL)
- return SFE_BAD_SF_INFO_PTR ;
+ { error = SFE_BAD_SF_INFO_PTR ;
+ goto error_exit ;
+ } ;
/* Zero out these fields. */
sfinfo->frames = 0 ;
@@ -2424,17 +2474,16 @@
sfinfo->seekable = 0 ;
if (mode == SFM_READ)
- { if ((sfinfo->format & SF_FORMAT_TYPEMASK) == SF_FORMAT_RAW)
+ { if ((SF_CONTAINER (sfinfo->format)) == SF_FORMAT_RAW)
{ if (sf_format_check (sfinfo) == 0)
- return SFE_RAW_BAD_FORMAT ;
+ { error = SFE_RAW_BAD_FORMAT ;
+ goto error_exit ;
+ } ;
}
else
memset (sfinfo, 0, sizeof (SF_INFO)) ;
} ;
- sf_errno = error = 0 ;
- sf_logbuffer [0] = 0 ;
-
memcpy (&(psf->sf), sfinfo, sizeof (SF_INFO)) ;
psf->Magick = SNDFILE_MAGICK ;
@@ -2451,6 +2500,9 @@
psf->float_int_mult = 0 ;
psf->float_max = -1.0 ;
+ /* An attempt at a per SF_PRIVATE unique id. */
+ psf->unique_id = psf_rand_int32 () ;
+
psf->sf.sections = 1 ;
psf->is_pipe = psf_is_pipe (psf) ;
@@ -2471,7 +2523,8 @@
{ case SFM_READ :
if (psf->filelength < 44)
{ psf_log_printf (psf, "Short filelength: %D (fileoffset: %D)\n", psf->filelength, psf->fileoffset) ;
- return SFE_BAD_OFFSET ;
+ error = SFE_BAD_OFFSET ;
+ goto error_exit ;
} ;
break ;
@@ -2482,7 +2535,8 @@
break ;
case SFM_RDWR :
- return SFE_NO_EMBEDDED_RDWR ;
+ error = SFE_NO_EMBEDDED_RDWR ;
+ goto error_exit ;
} ;
psf_log_printf (psf, "Embedded file offset : %D\n", psf->fileoffset) ;
@@ -2497,10 +2551,21 @@
{ /* If the file is being opened for write or RDWR and the file is currently
** empty, then the SF_INFO struct must contain valid data.
*/
+ if ((SF_CONTAINER (psf->sf.format)) == 0)
+ { error = SFE_ZERO_MAJOR_FORMAT ;
+ goto error_exit ;
+ } ;
+ if ((SF_CONTAINER (psf->sf.format)) == 0)
+ { error = SFE_ZERO_MINOR_FORMAT ;
+ goto error_exit ;
+ } ;
+
if (sf_format_check (&(psf->sf)) == 0)
- return SFE_BAD_OPEN_FORMAT ;
+ { error = SFE_BAD_OPEN_FORMAT ;
+ goto error_exit ;
+ } ;
}
- else if ((psf->sf.format & SF_FORMAT_TYPEMASK) != SF_FORMAT_RAW)
+ else if ((SF_CONTAINER (psf->sf.format)) != SF_FORMAT_RAW)
{ /* If type RAW has not been specified then need to figure out file type. */
psf->sf.format = guess_file_type (psf) ;
@@ -2512,7 +2577,7 @@
psf->last_op = psf->mode ;
/* Set bytewidth if known. */
- switch (psf->sf.format & SF_FORMAT_SUBMASK)
+ switch (SF_CODEC (psf->sf.format))
{ case SF_FORMAT_PCM_S8 :
case SF_FORMAT_PCM_U8 :
case SF_FORMAT_ULAW :
@@ -2541,7 +2606,7 @@
} ;
/* Call the initialisation function for the relevant file type. */
- switch (psf->sf.format & SF_FORMAT_TYPEMASK)
+ switch (SF_CONTAINER (psf->sf.format))
{ case SF_FORMAT_WAV :
case SF_FORMAT_WAVEX :
error = wav_open (psf) ;
@@ -2563,6 +2628,10 @@
error = w64_open (psf) ;
break ;
+ case SF_FORMAT_RF64 :
+ error = rf64_open (psf) ;
+ break ;
+
/* Lite remove start */
case SF_FORMAT_PAF :
error = paf_open (psf) ;
@@ -2644,6 +2713,10 @@
error = caf_open (psf) ;
break ;
+ case SF_FORMAT_MPC2K :
+ error = mpc2k_open (psf) ;
+ break ;
+
/* Lite remove end */
default :
@@ -2651,57 +2724,76 @@
} ;
if (error)
- { switch (error)
- { case SF_ERR_SYSTEM :
- case SF_ERR_UNSUPPORTED_ENCODING :
- case SFE_UNIMPLEMENTED :
- break ;
-
- default :
- psf_log_printf (psf, "Parse error : %s\n", sf_error_number (error)) ;
- error = SF_ERR_MALFORMED_FILE ;
- } ;
-
- return error ;
- } ;
+ goto error_exit ;
/* For now, check whether embedding is supported. */
- format = psf->sf.format & SF_FORMAT_TYPEMASK ;
+ format = SF_CONTAINER (psf->sf.format) ;
if (psf->fileoffset > 0 &&
(format != SF_FORMAT_WAV) && (format != SF_FORMAT_WAVEX) &&
(format != SF_FORMAT_AIFF) && (format != SF_FORMAT_AU)
)
- return SFE_NO_EMBED_SUPPORT ;
+ { error = SFE_NO_EMBED_SUPPORT ;
+ goto error_exit ;
+ } ;
if (psf->fileoffset > 0)
psf_log_printf (psf, "Embedded file length : %D\n", psf->filelength) ;
if (mode == SFM_RDWR && sf_format_check (&(psf->sf)) == 0)
- return SFE_BAD_RDWR_FORMAT ;
+ { error = SFE_BAD_MODE_RW ;
+ goto error_exit ;
+ } ;
if (validate_sfinfo (&(psf->sf)) == 0)
{ psf_log_SF_INFO (psf) ;
save_header_info (psf) ;
- return SFE_BAD_SF_INFO ;
+ error = SFE_BAD_SF_INFO ;
+ goto error_exit ;
} ;
if (validate_psf (psf) == 0)
{ save_header_info (psf) ;
- return SFE_INTERNAL ;
+ error = SFE_INTERNAL ;
+ goto error_exit ;
} ;
psf->read_current = 0 ;
- psf->write_current = (psf->mode == SFM_RDWR) ? psf->sf.frames : 0 ;
+ psf->write_current = 0 ;
+ if (psf->mode == SFM_RDWR)
+ { psf->write_current = psf->sf.frames ;
+ psf->have_written = psf->sf.frames > 0 ? SF_TRUE : SF_FALSE ;
+ } ;
memcpy (sfinfo, &(psf->sf), sizeof (SF_INFO)) ;
- return 0 ;
+ memcpy (sfinfo, &(psf->sf), sizeof (SF_INFO)) ;
+
+ return (SNDFILE *) psf ;
+
+error_exit :
+ sf_errno = error ;
+
+ if (error == SFE_SYSTEM)
+ snprintf (sf_syserr, sizeof (sf_syserr), "%s", psf->syserr) ;
+ snprintf (sf_logbuffer, sizeof (sf_logbuffer), "%s", psf->logbuffer) ;
+
+ switch (error)
+ { case SF_ERR_SYSTEM :
+ case SF_ERR_UNSUPPORTED_ENCODING :
+ case SFE_UNIMPLEMENTED :
+ break ;
+
+ case SFE_RAW_BAD_FORMAT :
+ break ;
+
+ default :
+ if (psf->mode == SFM_READ)
+ { psf_log_printf (psf, "Parse error : %s\n", sf_error_number (error)) ;
+ error = SF_ERR_MALFORMED_FILE ;
+ } ;
+ } ;
+
+ psf_close (psf) ;
+ return NULL ;
} /* psf_open_file */
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: cd4f9e91-a8ec-4154-9bf6-fe4b8c69a615
-*/
Modified: freeswitch/trunk/libs/libsndfile/src/sndfile.h.in
==============================================================================
--- freeswitch/trunk/libs/libsndfile/src/sndfile.h.in (original)
+++ freeswitch/trunk/libs/libsndfile/src/sndfile.h.in Thu May 21 16:09:30 2009
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 1999-2006 Erik de Castro Lopo <erikd at mega-nerd.com>
+** Copyright (C) 1999-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU Lesser General Public License as published by
@@ -30,14 +30,7 @@
#define SNDFILE_1
#include <stdio.h>
-
-/* For the Metrowerks CodeWarrior Pro Compiler (mainly MacOS) */
-
-#if (defined (__MWERKS__))
-#include <unix.h>
-#else
-#include <sys/types.h>
-#endif
+#include <sys/types.h>
#ifdef __cplusplus
extern "C" {
@@ -73,6 +66,10 @@
SF_FORMAT_SD2 = 0x160000, /* Sound Designer 2 */
SF_FORMAT_FLAC = 0x170000, /* FLAC lossless file format */
SF_FORMAT_CAF = 0x180000, /* Core Audio File format */
+ SF_FORMAT_WVE = 0x190000, /* Psion WVE format */
+ SF_FORMAT_OGG = 0x200000, /* Xiph OGG container */
+ SF_FORMAT_MPC2K = 0x210000, /* Akai MPC 2000 sampler */
+ SF_FORMAT_RF64 = 0x220000, /* RF64 WAV file */
/* Subtypes from here on. */
@@ -106,6 +103,8 @@
SF_FORMAT_DPCM_8 = 0x0050, /* 8 bit differential PCM (XI only) */
SF_FORMAT_DPCM_16 = 0x0051, /* 16 bit differential PCM (XI only) */
+ SF_FORMAT_VORBIS = 0x0060, /* Xiph Vorbis encoding. */
+
/* Endian-ness options. */
SF_ENDIAN_FILE = 0x00000000, /* Default file endian-ness. */
@@ -127,12 +126,15 @@
enum
{ SFC_GET_LIB_VERSION = 0x1000,
SFC_GET_LOG_INFO = 0x1001,
+ SFC_GET_CURRENT_SF_INFO = 0x1002,
+
SFC_GET_NORM_DOUBLE = 0x1010,
SFC_GET_NORM_FLOAT = 0x1011,
SFC_SET_NORM_DOUBLE = 0x1012,
SFC_SET_NORM_FLOAT = 0x1013,
SFC_SET_SCALE_FLOAT_INT_READ = 0x1014,
+ SFC_SET_SCALE_INT_FLOAT_WRITE = 0x1015,
SFC_GET_SIMPLE_FORMAT_COUNT = 0x1020,
SFC_GET_SIMPLE_FORMAT = 0x1021,
@@ -152,6 +154,7 @@
SFC_GET_MAX_ALL_CHANNELS = 0x1045,
SFC_SET_ADD_PEAK_CHUNK = 0x1050,
+ SFC_SET_ADD_HEADER_PAD_CHUNK = 0x1051,
SFC_UPDATE_HEADER_NOW = 0x1060,
SFC_SET_UPDATE_HEADER_AUTO = 0x1061,
@@ -179,6 +182,17 @@
SFC_GET_BROADCAST_INFO = 0x10F0,
SFC_SET_BROADCAST_INFO = 0x10F1,
+ SFC_GET_CHANNEL_MAP_INFO = 0x1100,
+ SFC_SET_CHANNEL_MAP_INFO = 0x1101,
+
+ SFC_RAW_DATA_NEEDS_ENDSWAP = 0x1110,
+
+ /* Support for Wavex Ambisonics Format */
+ SFC_WAVEX_SET_AMBISONIC = 0x1200,
+ SFC_WAVEX_GET_AMBISONIC = 0x1201,
+
+ SFC_SET_VBR_ENCODING_QUALITY = 0x1300,
+
/* Following commands for testing only. */
SFC_TEST_IEEE_FLOAT_REPLACE = 0x6001,
@@ -205,7 +219,9 @@
SF_STR_SOFTWARE = 0x03,
SF_STR_ARTIST = 0x04,
SF_STR_COMMENT = 0x05,
- SF_STR_DATE = 0x06
+ SF_STR_DATE = 0x06,
+ SF_STR_ALBUM = 0x07,
+ SF_STR_LICENSE = 0x08
} ;
/*
@@ -214,7 +230,7 @@
*/
#define SF_STR_FIRST SF_STR_TITLE
-#define SF_STR_LAST SF_STR_DATE
+#define SF_STR_LAST SF_STR_LICENSE
enum
{ /* True and false */
@@ -224,7 +240,10 @@
/* Modes for opening files. */
SFM_READ = 0x10,
SFM_WRITE = 0x20,
- SFM_RDWR = 0x30
+ SFM_RDWR = 0x30,
+
+ SF_AMBISONIC_NONE = 0x40,
+ SF_AMBISONIC_B_FORMAT = 0x41
} ;
/* Public error values. These are guaranteed to remain unchanged for the duration
@@ -241,18 +260,55 @@
SF_ERR_UNSUPPORTED_ENCODING = 4
} ;
+
+/* Channel map values (used with SFC_SET/GET_CHANNEL_MAP).
+*/
+
+enum
+{ SF_CHANNEL_MAP_INVALID = 0,
+ SF_CHANNEL_MAP_MONO = 1,
+ SF_CHANNEL_MAP_LEFT,
+ SF_CHANNEL_MAP_RIGHT,
+ SF_CHANNEL_MAP_CENTER,
+ SF_CHANNEL_MAP_FRONT_LEFT,
+ SF_CHANNEL_MAP_FRONT_RIGHT,
+ SF_CHANNEL_MAP_FRONT_CENTER,
+ SF_CHANNEL_MAP_REAR_CENTER,
+ SF_CHANNEL_MAP_REAR_LEFT,
+ SF_CHANNEL_MAP_REAR_RIGHT,
+ SF_CHANNEL_MAP_LFE,
+ SF_CHANNEL_MAP_FRONT_LEFT_OF_CENTER,
+ SF_CHANNEL_MAP_FRONT_RIGHT_OF_CENTER,
+ SF_CHANNEL_MAP_SIDE_LEFT,
+ SF_CHANNEL_MAP_SIDE_RIGHT,
+ SF_CHANNEL_MAP_TOP_CENTER,
+ SF_CHANNEL_MAP_TOP_FRONT_LEFT,
+ SF_CHANNEL_MAP_TOP_FRONT_RIGHT,
+ SF_CHANNEL_MAP_TOP_FRONT_CENTER,
+ SF_CHANNEL_MAP_TOP_REAR_LEFT,
+ SF_CHANNEL_MAP_TOP_REAR_RIGHT,
+ SF_CHANNEL_MAP_TOP_REAR_CENTER
+} ;
+
+
/* A SNDFILE* pointer can be passed around much like stdio.h's FILE* pointer. */
typedef struct SNDFILE_tag SNDFILE ;
-/* The following typedef is system specific and is defined when libsndfile is.
-** compiled. sf_count_t can be one of loff_t (Linux), off_t (*BSD),
-** off64_t (Solaris), __int64_t (Win32) etc.
+/* The following typedef is system specific and is defined when libsndfile is
+** compiled. sf_count_t can be one of loff_t (Linux), off_t (*BSD), off64_t
+** (Solaris), __int64_t (Win32) etc. On windows, we need to allow the same
+** header file to be compiler by both GCC and the microsoft compiler.
*/
+#ifdef _MSCVER
+typedef __int64_t sf_count_t ;
+#define SF_COUNT_MAX 0x7fffffffffffffffi64
+#else
typedef @TYPEOF_SF_COUNT_T@ sf_count_t ;
-
#define SF_COUNT_MAX @SF_COUNT_MAX@
+#endif
+
/* A pointer to a SF_INFO structure is passed to sf_open_read () and filled in.
** On write, the SF_INFO structure is filled in by the user and passed into
@@ -368,23 +424,30 @@
} SF_LOOP_INFO ;
-/* Struct used to retrieve broadcast (EBU) information from a file.
+/* Struct used to retrieve broadcast (EBU) information from a file.
** Strongly (!) based on EBU "bext" chunk format used in Broadcast WAVE.
*/
-typedef struct
-{ char description [256] ;
- char originator [32] ;
- char originator_reference [32] ;
- char origination_date [10] ;
- char origination_time [8] ;
- int time_reference_low ;
- int time_reference_high ;
- short version ;
- char umid [64] ;
- char reserved [190] ;
- unsigned int coding_history_size ;
- char coding_history [256] ;
-} SF_BROADCAST_INFO ;
+#define SF_BROADCAST_INFO_VAR(coding_hist_size) \
+ struct \
+ { char description [256] ; \
+ char originator [32] ; \
+ char originator_reference [32] ; \
+ char origination_date [10] ; \
+ char origination_time [8] ; \
+ unsigned int time_reference_low ; \
+ unsigned int time_reference_high ; \
+ short version ; \
+ char umid [64] ; \
+ char reserved [190] ; \
+ unsigned int coding_history_size ; \
+ char coding_history [coding_hist_size] ; \
+ }
+
+/* SF_BROADCAST_INFO is the above struct with coding_history field of 256 bytes. */
+typedef SF_BROADCAST_INFO_VAR (256) SF_BROADCAST_INFO ;
+
+
+/* Virtual I/O functionality. */
typedef sf_count_t (*sf_vio_get_filelen) (void *user_data) ;
typedef sf_count_t (*sf_vio_seek) (sf_count_t offset, int whence, void *user_data) ;
@@ -404,7 +467,7 @@
/* Open the specified file for read, write or both. On error, this will
** return a NULL pointer. To find the error number, pass a NULL SNDFILE
-** to sf_perror () or sf_error_str ().
+** to sf_strerror ().
** All calls to sf_open() should be matched with a call to sf_close().
*/
@@ -417,7 +480,7 @@
** of file header is at the current file offset. This allows sound files within
** larger container files to be read and/or written.
** On error, this will return a NULL pointer. To find the error number, pass a
-** NULL SNDFILE to sf_perror () or sf_error_str ().
+** NULL SNDFILE to sf_strerror ().
** All calls to sf_open_fd() should be matched with a call to sf_close().
*/
@@ -445,7 +508,7 @@
const char* sf_error_number (int errnum) ;
-/* The following three error functions are deprecated but they will remain in the
+/* The following two error functions are deprecated but they will remain in the
** library for the forseeable future. The function sf_strerror() should be used
** in their place.
*/
Modified: freeswitch/trunk/libs/libsndfile/src/sndfile.hh
==============================================================================
--- freeswitch/trunk/libs/libsndfile/src/sndfile.hh (original)
+++ freeswitch/trunk/libs/libsndfile/src/sndfile.hh Thu May 21 16:09:30 2009
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 2005,2006 Erik de Castro Lopo <erikd at mega-nerd.com>
+** Copyright (C) 2005-2007 Erik de Castro Lopo <erikd at mega-nerd.com>
**
** All rights reserved.
**
@@ -54,6 +54,7 @@
#include <sndfile.h>
+#include <string>
#include <new> // for std::nothrow
class SndfileHandle
@@ -74,6 +75,8 @@
SndfileHandle (void) : p (NULL) {} ;
SndfileHandle (const char *path, int mode = SFM_READ,
int format = 0, int channels = 0, int samplerate = 0) ;
+ SndfileHandle (std::string const & path, int mode = SFM_READ,
+ int format = 0, int channels = 0, int samplerate = 0) ;
~SndfileHandle (void) ;
SndfileHandle (const SndfileHandle &orig) ;
@@ -104,6 +107,8 @@
const char* getString (int str_type) const ;
+ static int formatCheck (int format, int channels, int samplerate) ;
+
sf_count_t read (short *ptr, sf_count_t items) ;
sf_count_t read (int *ptr, sf_count_t items) ;
sf_count_t read (float *ptr, sf_count_t items) ;
@@ -158,12 +163,33 @@
p->sfinfo.sections = 0 ;
p->sfinfo.seekable = 0 ;
- if ((p->sf = sf_open (path, mode, &p->sfinfo)) == NULL)
- { delete p ;
- p = NULL ;
- } ;
+ p->sf = sf_open (path, mode, &p->sfinfo) ;
} ;
-} /* SndfileHandle constructor */
+
+ return ;
+} /* SndfileHandle const char * constructor */
+
+inline
+SndfileHandle::SndfileHandle (std::string const & path, int mode, int fmt, int chans, int srate)
+: p (NULL)
+{
+ p = new (std::nothrow) SNDFILE_ref () ;
+
+ if (p != NULL)
+ { p->ref = 1 ;
+
+ p->sfinfo.frames = 0 ;
+ p->sfinfo.channels = chans ;
+ p->sfinfo.format = fmt ;
+ p->sfinfo.samplerate = srate ;
+ p->sfinfo.sections = 0 ;
+ p->sfinfo.seekable = 0 ;
+
+ p->sf = sf_open (path.c_str (), mode, &p->sfinfo) ;
+ } ;
+
+ return ;
+} /* SndfileHandle std::string constructor */
inline
SndfileHandle::~SndfileHandle (void)
@@ -222,6 +248,20 @@
SndfileHandle::getString (int str_type) const
{ return sf_get_string (p->sf, str_type) ; }
+inline int
+SndfileHandle::formatCheck(int fmt, int chans, int srate)
+{
+ SF_INFO sfinfo ;
+
+ sfinfo.frames = 0 ;
+ sfinfo.channels = chans ;
+ sfinfo.format = fmt ;
+ sfinfo.samplerate = srate ;
+ sfinfo.sections = 0 ;
+ sfinfo.seekable = 0 ;
+
+ return sf_format_check (&sfinfo) ;
+}
/*---------------------------------------------------------------------*/
@@ -300,10 +340,3 @@
#endif /* SNDFILE_HH */
-/*
-** Do not edit or modify anything in this comment block.
-** The following line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: a0e9d996-73d7-47c4-a78d-79a3232a9eef
-*/
Modified: freeswitch/trunk/libs/libsndfile/src/strings.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/src/strings.c (original)
+++ freeswitch/trunk/libs/libsndfile/src/strings.c Thu May 21 16:09:30 2009
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 2001-2004 Erik de Castro Lopo <erikd at mega-nerd.com>
+** Copyright (C) 2001-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU Lesser General Public License as published by
@@ -34,7 +34,7 @@
psf_store_string (SF_PRIVATE *psf, int str_type, const char *str)
{ static char lsf_name [] = PACKAGE "-" VERSION ;
static char bracket_name [] = " (" PACKAGE "-" VERSION ")" ;
- int k, str_len, len_remaining, str_flags ;
+ int k, str_len, len_remaining, str_flags, str_type_replace = 0 ;
if (str == NULL)
return SFE_STR_BAD_STRING ;
@@ -45,26 +45,31 @@
if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR)
{ if ((psf->str_flags & SF_STR_ALLOW_START) == 0)
return SFE_STR_NO_SUPPORT ;
- if ((psf->str_flags & SF_STR_ALLOW_END) == 0)
+ if (psf->have_written && (psf->str_flags & SF_STR_ALLOW_END) == 0)
return SFE_STR_NO_SUPPORT ;
/* Only allow zero length strings for software. */
if (str_type != SF_STR_SOFTWARE && str_len == 0)
return SFE_STR_BAD_STRING ;
} ;
+ /* Find the next free slot in table. */
+ for (k = 0 ; k < SF_MAX_STRINGS ; k++)
+ { /* If we find a matching entry clear it. */
+ if (psf->strings [k].type == str_type)
+ psf->strings [k].type = -1 ;
+
+ if (psf->strings [k].type == 0)
+ break ;
+ } ;
+
/* Determine flags */
str_flags = SF_STR_LOCATE_START ;
- if (psf->have_written)
+ if (psf->mode == SFM_RDWR || psf->have_written || str_type_replace)
{ if ((psf->str_flags & SF_STR_ALLOW_END) == 0)
return SFE_STR_NO_ADD_END ;
str_flags = SF_STR_LOCATE_END ;
} ;
- /* Find next free slot in table. */
- for (k = 0 ; k < SF_MAX_STRINGS ; k++)
- if (psf->strings [k].type == 0)
- break ;
-
/* More sanity checking. */
if (k >= SF_MAX_STRINGS)
return SFE_STR_MAX_COUNT ;
@@ -83,13 +88,6 @@
if (k == 0)
psf->str_end = psf->str_storage ;
-
-#if STRINGS_DEBUG
- psf_log_printf (psf, "str_storage : %X\n", (int) psf->str_storage) ;
- psf_log_printf (psf, "str_end : %X\n", (int) psf->str_end) ;
- psf_log_printf (psf, "sizeof (str_storage) : %d\n", SIGNED_SIZEOF (psf->str_storage)) ;
-#endif
-
len_remaining = SIGNED_SIZEOF (psf->str_storage) - (psf->str_end - psf->str_storage) ;
if (len_remaining < str_len + 2)
@@ -130,6 +128,8 @@
case SF_STR_ARTIST :
case SF_STR_COMMENT :
case SF_STR_DATE :
+ case SF_STR_ALBUM :
+ case SF_STR_LICENSE :
psf->strings [k].type = str_type ;
psf->strings [k].str = psf->str_end ;
psf->strings [k].flags = str_flags ;
@@ -140,12 +140,19 @@
break ;
default :
+ psf_log_printf (psf, "%s : SFE_STR_BAD_TYPE\n", __func__) ;
return SFE_STR_BAD_TYPE ;
} ;
- psf->str_flags |= (psf->have_written) ? SF_STR_LOCATE_END : SF_STR_LOCATE_START ;
+ psf->str_flags |= str_flags ;
#if STRINGS_DEBUG
+ psf_log_printf (psf, "str_storage : %X\n", (int) psf->str_storage) ;
+ psf_log_printf (psf, "str_end : %X\n", (int) psf->str_end) ;
+ psf_log_printf (psf, "sizeof (str_storage) : %d\n", SIGNED_SIZEOF (psf->str_storage)) ;
+ psf_log_printf (psf, "used : %d\n", (int ) (psf->str_end - psf->str_storage)) ;
+ psf_log_printf (psf, "remaining : %d\n", SIGNED_SIZEOF (psf->str_storage) - (psf->str_end - psf->str_storage)) ;
+
hexdump (psf->str_storage, 300) ;
#endif
@@ -171,6 +178,20 @@
return NULL ;
} /* psf_get_string */
+int
+psf_location_string_count (const SF_PRIVATE * psf, int location)
+{ int k, count = 0 ;
+
+ for (k = 0 ; k < SF_MAX_STRINGS ; k++)
+ if (psf->strings [k].type > 0 && psf->strings [k].flags & location)
+ count ++ ;
+
+ return count ;
+} /* psf_location_string_count */
+
+/*==============================================================================
+*/
+
#if STRINGS_DEBUG
#include <ctype.h>
@@ -195,10 +216,3 @@
} /* hexdump */
#endif
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: 04393aa1-9389-46fe-baf2-58a7bd544fd6
-*/
Modified: freeswitch/trunk/libs/libsndfile/src/svx.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/src/svx.c (original)
+++ freeswitch/trunk/libs/libsndfile/src/svx.c Thu May 21 16:09:30 2009
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 1999-2004 Erik de Castro Lopo <erikd at mega-nerd.com>
+** Copyright (C) 1999-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU Lesser General Public License as published by
@@ -99,10 +99,10 @@
{ if (psf->is_pipe)
return SFE_NO_PIPE_WRITE ;
- if ((psf->sf.format & SF_FORMAT_TYPEMASK) != SF_FORMAT_SVX)
+ if ((SF_CONTAINER (psf->sf.format)) != SF_FORMAT_SVX)
return SFE_BAD_OPEN_FORMAT ;
- psf->endian = psf->sf.format & SF_FORMAT_ENDMASK ;
+ psf->endian = SF_ENDIAN (psf->sf.format) ;
if (psf->endian == SF_ENDIAN_LITTLE || (CPU_IS_LITTLE_ENDIAN && psf->endian == SF_ENDIAN_CPU))
return SFE_BAD_ENDIAN ;
@@ -134,6 +134,9 @@
int filetype = 0, parsestage = 0, done = 0 ;
int bytecount = 0, channels ;
+ if (psf->filelength > SF_PLATFORM_S64 (0xffffffff))
+ psf_log_printf (psf, "Warning : filelength > 0xffffffff. This is bad!!!!\n") ;
+
memset (&vhdr, 0, sizeof (vhdr)) ;
psf_binheader_readf (psf, "p", 0) ;
@@ -223,6 +226,8 @@
psf->datalength = dword ;
psf->dataoffset = psf_ftell (psf) ;
+ if (psf->dataoffset < 0)
+ return SFE_SVX_NO_BODY ;
if (psf->datalength > psf->filelength - psf->dataoffset)
{ psf_log_printf (psf, " BODY : %D (should be %D)\n", psf->datalength, psf->filelength - psf->dataoffset) ;
@@ -400,11 +405,3 @@
return psf->error ;
} /* svx_write_header */
-
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: a80ab6fb-7d75-4d32-a6b0-0061a3f05d95
-*/
Added: freeswitch/trunk/libs/libsndfile/src/test_audio_detect.c
==============================================================================
--- (empty file)
+++ freeswitch/trunk/libs/libsndfile/src/test_audio_detect.c Thu May 21 16:09:30 2009
@@ -0,0 +1,112 @@
+/*
+** Copyright (C) 2007-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
+**
+** This program is free software; you can redistribute it and/or modify
+** it under the terms of the GNU Lesser General Public License as published by
+** the Free Software Foundation; either version 2.1 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU Lesser General Public License for more details.
+**
+** You should have received a copy of the GNU Lesser General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#include "sfconfig.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#if HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+#include <string.h>
+#include <errno.h>
+
+#include "common.h"
+#include "sfendian.h"
+
+#include "test_main.h"
+
+static unsigned char float_le_mono [] =
+{ 0x36, 0x86, 0x21, 0x44, 0xB5, 0xB4, 0x49, 0x44, 0xA2, 0xC0, 0x71, 0x44, 0x7B, 0xD1, 0x8C, 0x44,
+ 0x54, 0xAA, 0xA0, 0x44, 0x60, 0x67, 0xB4, 0x44, 0x22, 0x05, 0xC8, 0x44, 0x29, 0x80, 0xDB, 0x44,
+ 0x04, 0xD5, 0xEE, 0x44, 0x27, 0x00, 0x01, 0x45, 0x50, 0x7F, 0x0A, 0x45, 0x53, 0xE6, 0x13, 0x45,
+ 0x85, 0x33, 0x1D, 0x45, 0x43, 0x65, 0x26, 0x45, 0xEC, 0x79, 0x2F, 0x45, 0xE3, 0x6F, 0x38, 0x45,
+ 0x98, 0x45, 0x41, 0x45, 0x77, 0xF9, 0x49, 0x45, 0xF6, 0x89, 0x52, 0x45, 0x8F, 0xF5, 0x5A, 0x45,
+ 0xC9, 0x3A, 0x63, 0x45, 0x28, 0x58, 0x6B, 0x45, 0x3C, 0x4C, 0x73, 0x45, 0x9F, 0x15, 0x7B, 0x45,
+ 0x75, 0x59, 0x81, 0x45, 0x64, 0x11, 0x85, 0x45, 0xF1, 0xB1, 0x88, 0x45, 0x78, 0x3A, 0x8C, 0x45,
+ 0x58, 0xAA, 0x8F, 0x45, 0xF2, 0x00, 0x93, 0x45, 0xB2, 0x3D, 0x96, 0x45, 0x01, 0x60, 0x99, 0x45,
+ 0x50, 0x67, 0x9C, 0x45, 0x15, 0x53, 0x9F, 0x45, 0xCC, 0x22, 0xA2, 0x45, 0xF0, 0xD5, 0xA4, 0x45,
+ 0x07, 0x6C, 0xA7, 0x45, 0x9C, 0xE4, 0xA9, 0x45, 0x3D, 0x3F, 0xAC, 0x45, 0x7A, 0x7B, 0xAE, 0x45,
+ 0xF2, 0x98, 0xB0, 0x45, 0x3C, 0x97, 0xB2, 0x45, 0x02, 0x76, 0xB4, 0x45, 0xEC, 0x34, 0xB6, 0x45,
+ 0xA8, 0xD3, 0xB7, 0x45, 0xEB, 0x51, 0xB9, 0x45, 0x6F, 0xAF, 0xBA, 0x45, 0xF5, 0xEB, 0xBB, 0x45,
+ 0x41, 0x07, 0xBD, 0x45, 0x21, 0x01, 0xBE, 0x45, 0x64, 0xD9, 0xBE, 0x45, 0xE3, 0x8F, 0xBF, 0x45,
+ 0x7E, 0x24, 0xC0, 0x45, 0x15, 0x97, 0xC0, 0x45, 0x92, 0xE7, 0xC0, 0x45, 0xE8, 0x15, 0xC1, 0x45,
+ 0x7E, 0x24, 0xC0, 0x45, 0x15, 0x97, 0xC0, 0x45, 0x92, 0xE7, 0xC0, 0x45, 0xE8, 0x15, 0xC1, 0x45,
+ 0x7E, 0x24, 0xC0, 0x45, 0x15, 0x97, 0xC0, 0x45, 0x92, 0xE7, 0xC0, 0x45, 0xE8, 0x15, 0xC1, 0x45,
+} ;
+
+static unsigned char int24_32_le_stereo [] =
+{
+ 0x00, 0xE7, 0xFB, 0xFF, 0x00, 0x7C, 0xFD, 0xFF, 0x00, 0xA2, 0xFC, 0xFF, 0x00, 0x2B, 0xFC, 0xFF,
+ 0x00, 0xF3, 0xFD, 0xFF, 0x00, 0x19, 0xFB, 0xFF, 0x00, 0xA5, 0xFE, 0xFF, 0x00, 0x8D, 0xFA, 0xFF,
+ 0x00, 0x91, 0xFF, 0xFF, 0x00, 0xB5, 0xFA, 0xFF, 0x00, 0x91, 0x00, 0x00, 0x00, 0x5E, 0xFB, 0xFF,
+ 0x00, 0xD9, 0x01, 0x00, 0x00, 0x82, 0xFB, 0xFF, 0x00, 0xDF, 0x03, 0x00, 0x00, 0x44, 0xFC, 0xFF,
+ 0x00, 0x1C, 0x05, 0x00, 0x00, 0x77, 0xFC, 0xFF, 0x00, 0x8D, 0x06, 0x00, 0x00, 0x4F, 0xFC, 0xFF,
+ 0x00, 0x84, 0x07, 0x00, 0x00, 0x74, 0xFC, 0xFF, 0x00, 0x98, 0x08, 0x00, 0x00, 0x33, 0xFD, 0xFF,
+ 0x00, 0xB9, 0x09, 0x00, 0x00, 0x48, 0xFF, 0xFF, 0x00, 0xD1, 0x0A, 0x00, 0x00, 0x10, 0x02, 0x00,
+ 0x00, 0x28, 0x0C, 0x00, 0x00, 0xA2, 0x05, 0x00, 0x00, 0xA7, 0x0C, 0x00, 0x00, 0x45, 0x08, 0x00,
+ 0x00, 0x44, 0x0D, 0x00, 0x00, 0x1A, 0x0A, 0x00, 0x00, 0x65, 0x0D, 0x00, 0x00, 0x51, 0x0B, 0x00,
+ 0x00, 0x8B, 0x0D, 0x00, 0x00, 0x18, 0x0B, 0x00, 0x00, 0x37, 0x0E, 0x00, 0x00, 0x24, 0x0B, 0x00,
+ 0x00, 0x00, 0x0F, 0x00, 0x00, 0xDD, 0x0A, 0x00, 0x00, 0x83, 0x10, 0x00, 0x00, 0x31, 0x0A, 0x00,
+ 0x00, 0x07, 0x12, 0x00, 0x00, 0xC0, 0x08, 0x00, 0x00, 0xF7, 0x12, 0x00, 0x00, 0x47, 0x06, 0x00,
+ 0x00, 0xDD, 0x12, 0x00, 0x00, 0x6A, 0x03, 0x00, 0x00, 0xD5, 0x11, 0x00, 0x00, 0x99, 0x00, 0x00,
+ 0x00, 0x01, 0x10, 0x00, 0x00, 0xC5, 0xFE, 0xFF, 0x00, 0xF4, 0x0D, 0x00, 0x00, 0x97, 0xFD, 0xFF,
+ 0x00, 0x62, 0x0B, 0x00, 0x00, 0x75, 0xFC, 0xFF, 0x00, 0xE9, 0x08, 0x00, 0x00, 0xC0, 0xFB, 0xFF,
+ 0x00, 0x80, 0x06, 0x00, 0x00, 0x3C, 0xFB, 0xFF, 0x00, 0xDA, 0x03, 0x00, 0x00, 0xE4, 0xFA, 0xFF,
+ 0x00, 0xEB, 0x01, 0x00, 0x00, 0x21, 0xFB, 0xFF, 0x00, 0x20, 0x00, 0x00, 0x00, 0xE7, 0xFB, 0xFF,
+} ;
+
+
+void
+test_audio_detect (void)
+{
+ SF_PRIVATE psf ;
+ AUDIO_DETECT ad ;
+ int errors = 0 ;
+
+ print_test_name ("Testing audio detect") ;
+
+ memset (&psf, 0, sizeof (psf)) ;
+
+ ad.endianness = SF_ENDIAN_LITTLE ;
+ ad.channels = 1 ;
+ if (audio_detect (&psf, &ad, float_le_mono, sizeof (float_le_mono)) != SF_FORMAT_FLOAT)
+ { if (errors == 0) puts ("\nFailed tests :\n") ;
+ puts (" float_le_mono") ;
+ errors ++ ;
+ } ;
+
+ ad.endianness = SF_ENDIAN_LITTLE ;
+ ad.channels = 2 ;
+ if (audio_detect (&psf, &ad, int24_32_le_stereo, sizeof (int24_32_le_stereo)) != SF_FORMAT_PCM_32)
+ { if (errors == 0) puts ("\nFailed tests :\n") ;
+ puts (" int24_32_le_stereo") ;
+ errors ++ ;
+ } ;
+
+ if (errors != 0)
+ { printf ("\n Errors : %d\n\n", errors) ;
+ exit (1) ;
+ } ;
+
+ puts ("ok") ;
+
+ return ;
+} /* test_audio_detect */
Added: freeswitch/trunk/libs/libsndfile/src/test_conversions.c
==============================================================================
--- (empty file)
+++ freeswitch/trunk/libs/libsndfile/src/test_conversions.c Thu May 21 16:09:30 2009
@@ -0,0 +1,104 @@
+/*
+** Copyright (C) 2006-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
+**
+** This program is free software; you can redistribute it and/or modify
+** it under the terms of the GNU Lesser General Public License as published by
+** the Free Software Foundation; either version 2.1 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU Lesser General Public License for more details.
+**
+** You should have received a copy of the GNU Lesser General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#include "sfconfig.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <string.h>
+#include <stdarg.h>
+#include <errno.h>
+#include <inttypes.h>
+
+#include "common.h"
+#include "test_main.h"
+
+
+/*
+** This is a bit rough, but it is the nicest way to do it.
+*/
+
+#define cmp_test(line,ival,tval,str) \
+ if (ival != tval) \
+ { printf (str, line, ival, tval) ; \
+ exit (1) ; \
+ } ;
+
+static void
+conversion_test (char endian)
+{
+ SF_PRIVATE sf_private, *psf ;
+ const char * filename = "conversion.bin" ;
+ int64_t i64 = SF_PLATFORM_S64 (0x0123456789abcdef), t64 = 0 ;
+ char format_str [16] ;
+ char test_name [64] ;
+ char i8 = 12, t8 = 0 ;
+ short i16 = 0x123, t16 = 0 ;
+ int i24 = 0x23456, t24 = 0 ;
+ int i32 = 0x0a0b0c0d, t32 = 0 ;
+ int bytes ;
+
+ snprintf (format_str, sizeof (format_str), "%c12348", endian) ;
+
+ snprintf (test_name, sizeof (test_name), "Testing %s conversions", endian == 'e' ? "little endian" : "big endian") ;
+ print_test_name (test_name) ;
+
+ psf = &sf_private ;
+ memset (psf, 0, sizeof (sf_private)) ;
+
+ if (psf_fopen (psf, filename, SFM_WRITE) != 0)
+ { printf ("\n\nError : failed to open file '%s' for write.\n\n", filename) ;
+ exit (1) ;
+ } ;
+
+ psf_binheader_writef (psf, format_str, i8, i16, i24, i32, i64) ;
+ psf_fwrite (psf->header, 1, psf->headindex, psf) ;
+ psf_fclose (psf) ;
+
+ memset (psf, 0, sizeof (sf_private)) ;
+ if (psf_fopen (psf, filename, SFM_READ) != 0)
+ { printf ("\n\nError : failed to open file '%s' for read.\n\n", filename) ;
+ exit (1) ;
+ } ;
+
+ bytes = psf_binheader_readf (psf, format_str, &t8, &t16, &t24, &t32, &t64) ;
+ psf_fclose (psf) ;
+
+ if (bytes != 18)
+ { printf ("\n\nLine %d : read %d bytes.\n\n", __LINE__, bytes) ;
+ exit (1) ;
+ } ;
+
+ cmp_test (__LINE__, i8, t8, "\n\nLine %d : 8 bit int failed %d -> %d.\n\n") ;
+ cmp_test (__LINE__, i16, t16, "\n\nLine %d : 16 bit int failed 0x%x -> 0x%x.\n\n") ;
+ cmp_test (__LINE__, i24, t24, "\n\nLine %d : 24 bit int failed 0x%x -> 0x%x.\n\n") ;
+ cmp_test (__LINE__, i32, t32, "\n\nLine %d : 32 bit int failed 0x%x -> 0x%x.\n\n") ;
+ cmp_test (__LINE__, i64, t64, "\n\nLine %d : 64 bit int failed 0x%" PRIx64 "x -> 0x%" PRIx64 "x.\n\n") ;
+
+ remove (filename) ;
+ puts ("ok") ;
+} /* conversion_test */
+
+void
+test_conversions (void)
+{
+ conversion_test ('E') ;
+ conversion_test ('e') ;
+} /* test_conversion */
+
Modified: freeswitch/trunk/libs/libsndfile/src/test_endswap.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/src/test_endswap.c (original)
+++ freeswitch/trunk/libs/libsndfile/src/test_endswap.c Thu May 21 16:09:30 2009
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 2002-2005 Erik de Castro Lopo <erikd at mega-nerd.com>
+** Copyright (C) 2002-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU Lesser General Public License as published by
@@ -20,43 +20,25 @@
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <inttypes.h>
#if HAVE_UNISTD_H
#include <unistd.h>
#endif
-#include <string.h>
-#include <errno.h>
-
#include "common.h"
#include "sfendian.h"
+#include "test_main.h"
+
#define FMT_SHORT "0x%04x\n"
#define FMT_INT "0x%08x\n"
-
-#if SIZEOF_INT64_T == SIZEOF_LONG
-#define FMT_INT64 "0x%016lx\n"
-#else
-#define FMT_INT64 "0x%016llx\n"
-#endif
-
-static void test_endswap_short (void) ;
-static void test_endswap_int (void) ;
-static void test_endswap_int64_t (void) ;
-
-
-int
-main (void)
-{
- test_endswap_short () ;
- test_endswap_int () ;
- test_endswap_int64_t () ;
-
- return 0 ;
-} /* main */
+#define FMT_INT64 "0x%016" PRIx64 "\n"
/*==============================================================================
-** Actual test functions.
+** Test functions.
*/
@@ -75,7 +57,7 @@
{ short orig [4], first [4], second [4] ;
int k ;
- printf (" %-24s : ", "test_endswap_short") ;
+ printf (" %-40s : ", "test_endswap_short") ;
fflush (stdout) ;
for (k = 0 ; k < ARRAY_LEN (orig) ; k++)
@@ -135,7 +117,7 @@
{ int orig [4], first [4], second [4] ;
int k ;
- printf (" %-24s : ", "test_endswap_int") ;
+ printf (" %-40s : ", "test_endswap_int") ;
fflush (stdout) ;
for (k = 0 ; k < ARRAY_LEN (orig) ; k++)
@@ -195,7 +177,7 @@
{ int64_t orig [4], first [4], second [4] ;
int k ;
- printf (" %-24s : ", "test_endswap_int64_t") ;
+ printf (" %-40s : ", "test_endswap_int64_t") ;
fflush (stdout) ;
for (k = 0 ; k < ARRAY_LEN (orig) ; k++)
@@ -242,4 +224,12 @@
+void
+test_endswap (void)
+{
+ test_endswap_short () ;
+ test_endswap_int () ;
+ test_endswap_int64_t () ;
+
+} /* test_endswap */
Modified: freeswitch/trunk/libs/libsndfile/src/test_endswap.def
==============================================================================
--- freeswitch/trunk/libs/libsndfile/src/test_endswap.def (original)
+++ freeswitch/trunk/libs/libsndfile/src/test_endswap.def Thu May 21 16:09:30 2009
@@ -18,11 +18,3 @@
format = FMT_INT64 ;
} ;
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: 098c07e0-2d3f-4f62-ad93-f3f4b91c5211
-*/
-
Modified: freeswitch/trunk/libs/libsndfile/src/test_endswap.tpl
==============================================================================
--- freeswitch/trunk/libs/libsndfile/src/test_endswap.tpl (original)
+++ freeswitch/trunk/libs/libsndfile/src/test_endswap.tpl Thu May 21 16:09:30 2009
@@ -21,43 +21,25 @@
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <inttypes.h>
#if HAVE_UNISTD_H
#include <unistd.h>
#endif
-#include <string.h>
-#include <errno.h>
-
#include "common.h"
#include "sfendian.h"
+#include "test_main.h"
+
#define FMT_SHORT "0x%04x\n"
#define FMT_INT "0x%08x\n"
-
-#if SIZEOF_INT64_T == SIZEOF_LONG
-#define FMT_INT64 "0x%016lx\n"
-#else
-#define FMT_INT64 "0x%016llx\n"
-#endif
-
-[+ FOR int_type
-+]static void test_endswap_[+ (get "name") +] (void) ;
-[+ ENDFOR int_type
-+]
-
-int
-main (void)
-{
-[+ FOR int_type
-+] test_endswap_[+ (get "name") +] () ;
-[+ ENDFOR int_type
-+]
- return 0 ;
-} /* main */
+#define FMT_INT64 "0x%016" PRIx64 "\n"
/*==============================================================================
-** Actual test functions.
+** Test functions.
*/
[+ FOR int_type +]
@@ -76,7 +58,7 @@
{ [+ (get "name") +] orig [4], first [4], second [4] ;
int k ;
- printf (" %-24s : ", "test_endswap_[+ (get "name") +]") ;
+ printf (" %-40s : ", "test_endswap_[+ (get "name") +]") ;
fflush (stdout) ;
for (k = 0 ; k < ARRAY_LEN (orig) ; k++)
@@ -124,12 +106,12 @@
+]
-[+ COMMENT
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: fd8887e8-8202-4f30-a419-0cf01a0e799b
-*/
+void
+test_endswap (void)
+{
+[+ FOR int_type
++] test_endswap_[+ (get "name") +] () ;
+[+ ENDFOR int_type
+]
+} /* test_endswap */
+
Modified: freeswitch/trunk/libs/libsndfile/src/test_file_io.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/src/test_file_io.c (original)
+++ freeswitch/trunk/libs/libsndfile/src/test_file_io.c Thu May 21 16:09:30 2009
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 2002-2004 Erik de Castro Lopo <erikd at mega-nerd.com>
+** Copyright (C) 2002-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU Lesser General Public License as published by
@@ -30,6 +30,8 @@
#include "common.h"
+#include "test_main.h"
+
static void make_data (int *data, int len, int seed) ;
static void file_open_test (const char *filename) ;
@@ -46,19 +48,6 @@
-int
-main (void)
-{ const char *filename = "file_io.dat" ;
-
- file_open_test (filename) ;
- file_read_write_test (filename) ;
- file_truncate_test (filename) ;
-
- unlink (filename) ;
-
- return 0 ;
-} /* main */
-
/*==============================================================================
** Actual test functions.
*/
@@ -68,8 +57,7 @@
{ SF_PRIVATE sf_data, *psf ;
int error ;
- printf (" %-24s : ", "file_open_test") ;
- fflush (stdout) ;
+ print_test_name ("Testing file open") ;
memset (&sf_data, 0, sizeof (sf_data)) ;
psf = &sf_data ;
@@ -80,7 +68,7 @@
exit (1) ;
} ;
- strncpy (psf->filename, filename, sizeof (psf->filename)) ;
+ snprintf (psf->filename, sizeof (psf->filename), "%s", filename) ;
/* Test that open for read fails if the file doesn't exist. */
error = psf_fopen (psf, psf->filename, SFM_READ) ;
@@ -129,12 +117,11 @@
** write, test that psf_get_filelen() returns the new length.
*/
- printf (" %-24s : ", "file_write_test") ;
- fflush (stdout) ;
+ print_test_name ("Testing file write") ;
memset (&sf_data, 0, sizeof (sf_data)) ;
psf = &sf_data ;
- strncpy (psf->filename, filename, sizeof (psf->filename)) ;
+ snprintf (psf->filename, sizeof (psf->filename), "%s", filename) ;
/* Test file open in write mode. */
psf->mode = SFM_WRITE ;
@@ -166,8 +153,7 @@
** that the data is correct.
*/
- printf (" %-24s : ", "file_read_test") ;
- fflush (stdout) ;
+ print_test_name ("Testing file read") ;
/* Test file open in write mode. */
psf->mode = SFM_READ ;
@@ -191,8 +177,7 @@
** go back and check that all three blocks are correct.
*/
- printf (" %-24s : ", "file_seek_test") ;
- fflush (stdout) ;
+ print_test_name ("Testing file seek") ;
/* Test file open in read/write mode. */
psf->mode = SFM_RDWR ;
@@ -230,8 +215,7 @@
** the file will actually be a seek to the value given by psf->fileoffset.
*/
- printf (" %-24s : ", "file_offset_test") ;
- fflush (stdout) ;
+ print_test_name ("Testing file offset") ;
/* Test file open in read/write mode. */
psf->mode = SFM_RDWR ;
@@ -287,14 +271,13 @@
** write, test that psf_get_filelen() returns the new length.
*/
- printf (" %-24s : ", "file_truncate_test") ;
- fflush (stdout) ;
+ print_test_name ("Testing file truncate") ;
memset (&sf_data, 0, sizeof (sf_data)) ;
memset (buffer, 0xEE, sizeof (buffer)) ;
psf = &sf_data ;
- strncpy (psf->filename, filename, sizeof (psf->filename)) ;
+ snprintf (psf->filename, sizeof (psf->filename), "%s", filename) ;
/*
** Open the file write mode, write 0xEE data and then extend the file
@@ -439,10 +422,15 @@
data [k] = rand () ;
} /* make_data */
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: 0a21fb93-78dd-4f72-8338-4bca9e77b8c8
-*/
+
+void
+test_file_io (void)
+{ const char *filename = "file_io.dat" ;
+
+ file_open_test (filename) ;
+ file_read_write_test (filename) ;
+ file_truncate_test (filename) ;
+
+ unlink (filename) ;
+} /* main */
+
Added: freeswitch/trunk/libs/libsndfile/src/test_float.c
==============================================================================
--- (empty file)
+++ freeswitch/trunk/libs/libsndfile/src/test_float.c Thu May 21 16:09:30 2009
@@ -0,0 +1,104 @@
+/*
+** Copyright (C) 2006-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
+**
+** This program is free software; you can redistribute it and/or modify
+** it under the terms of the GNU Lesser General Public License as published by
+** the Free Software Foundation; either version 2.1 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU Lesser General Public License for more details.
+**
+** You should have received a copy of the GNU Lesser General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#include "sfconfig.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdarg.h>
+#include <errno.h>
+#include <math.h>
+
+#include "common.h"
+#include "test_main.h"
+
+void
+test_float_convert (void)
+{ static float data [] =
+ { 0.0, 1.0, -1.0, 1.0 * M_PI, -1.0 * M_PI,
+ 1e9, -1e9, 1e-9, -1e-9, 1e-10, -1e-10,
+ 1e-19, -1e-19, 1e19, -1e19, 1e-20, -1e-20,
+ } ;
+
+ int k ;
+
+ print_test_name (__func__) ;
+
+ for (k = 0 ; k < ARRAY_LEN (data) ; k++)
+ { unsigned char bytes [4] ;
+ float test ;
+
+ float32_le_write (data [k], bytes) ;
+ test = float32_le_read (bytes) ;
+
+ if (fabs (data [k] - test) > 1e-20)
+ { printf ("\n\nLine %d : Test %d, little endian error %.15g -> %.15g.\n\n", __LINE__, k, data [k], test ) ;
+ exit (1) ;
+ } ;
+
+ float32_be_write (data [k], bytes) ;
+ test = float32_be_read (bytes) ;
+
+ if (fabs (data [k] - test) > 1e-20)
+ { printf ("\n\nLine %d : Test %d, big endian error %.15g -> %.15g.\n\n", __LINE__, k, data [k], test) ;
+ exit (1) ;
+ } ;
+
+ } ;
+
+ puts ("ok") ;
+} /* test_float_convert */
+
+void
+test_double_convert (void)
+{ static double data [] =
+ { 0.0, 1.0, -1.0, 1.0 * M_PI, -1.0 * M_PI,
+ 1e9, -1e9, 1e-9, -1e-9, 1e-10, -1e-10,
+ 1e-19, -1e-19, 1e19, -1e19, 1e-20, -1e-20,
+ } ;
+
+ int k ;
+
+ print_test_name (__func__) ;
+
+ for (k = 0 ; k < ARRAY_LEN (data) ; k++)
+ { unsigned char bytes [8] ;
+ double test ;
+
+ double64_le_write (data [k], bytes) ;
+ test = double64_le_read (bytes) ;
+
+ if (fabs (data [k] - test) > 1e-20)
+ { printf ("\n\nLine %d : Test %d, little endian error %.15g -> %.15g.\n\n", __LINE__, k, data [k], test ) ;
+ exit (1) ;
+ } ;
+
+ double64_be_write (data [k], bytes) ;
+ test = double64_be_read (bytes) ;
+
+ if (fabs (data [k] - test) > 1e-20)
+ { printf ("\n\nLine %d : Test %d, big endian error %.15g -> %.15g.\n\n", __LINE__, k, data [k], test) ;
+ exit (1) ;
+ } ;
+
+ } ;
+
+ puts ("ok") ;
+} /* test_double_convert */
+
Added: freeswitch/trunk/libs/libsndfile/src/test_ima_oki_adpcm.c
==============================================================================
--- (empty file)
+++ freeswitch/trunk/libs/libsndfile/src/test_ima_oki_adpcm.c Thu May 21 16:09:30 2009
@@ -0,0 +1,155 @@
+/*
+** Copyright (c) 2007 <robs at users.sourceforge.net>
+** Copyright (C) 2007-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
+**
+** 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
+** the Free Software Foundation; either version 2 of the License, or (at
+** your option) any later version.
+**
+** This library is distributed in the hope that it will be useful, but
+** WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
+** General Public License for more details.
+**
+** You should have received a copy of the GNU Lesser General Public License
+** along with this library. If not, write to the Free Software Foundation,
+** Fifth Floor, 51 Franklin Street, Boston, MA 02111-1301, USA.
+*/
+
+#include <stdio.h>
+
+#include "test_main.h"
+
+#include "ima_oki_adpcm.c"
+
+static const unsigned char test_codes [] =
+{ 0x08, 0x08, 0x04, 0x7f, 0x72, 0xf7, 0x9f, 0x7c, 0xd7, 0xbc, 0x7a, 0xa7, 0xb8,
+ 0x4b, 0x0b, 0x38, 0xf6, 0x9d, 0x7a, 0xd7, 0xbc, 0x7a, 0xd7, 0xa8, 0x6c, 0x81,
+ 0x98, 0xe4, 0x0e, 0x7a, 0xd7, 0x9e, 0x7b, 0xc7, 0xab, 0x7a, 0x85, 0xc0, 0xb3,
+ 0x8f, 0x58, 0xd7, 0xad, 0x7a, 0xd7, 0xad, 0x7a, 0x87, 0xd0, 0x2b, 0x0e, 0x48,
+ 0xd7, 0xad, 0x78, 0xf7, 0xbc, 0x7a, 0xb7, 0xa8, 0x4b, 0x88, 0x18, 0xd5, 0x8d,
+ 0x6a, 0xa4, 0x98, 0x08, 0x00, 0x80, 0x88,
+} ;
+
+static const short test_pcm [] =
+{ 32, 0, 32, 0, 32, 320, 880, -336, 2304, 4192, -992, 10128, 5360, -16352,
+ 30208, 2272, -31872, 14688, -7040, -32432, 14128, -1392, -15488, 22960,
+ 1232, -1584, 21488, -240, 2576, -15360, 960, -1152, -30032, 10320, 1008,
+ -30032, 16528, 1008, -30032, 16528, -5200, -30592, 15968, 448, -30592,
+ 15968, 448, -2368, 30960, 3024, -80, 8384, 704, -1616, -29168, -1232, 1872,
+ -32768, 13792, -1728, -32768, 13792, 4480, -32192, 14368, -7360, -32752,
+ 13808, -1712, -21456, 16992, 1472, -1344, 26848, -1088, 2016, -17728, 208,
+ -2112, -32768, 1376, -1728, -32768, 13792, -1728, -32768, 13792, -1728,
+ -32768, 13792, -1728, -32768, 13792, -1728, -4544, 32767, -1377, 1727,
+ 15823, -2113, 207, -27345, 591, -2513, -32768, 13792, -1728, -32768, 13792,
+ 10688, -31632, 14928, -6800, -32192, 14368, -1152, -20896, 17552, 2032,
+ -784, 22288, 560, -2256, -4816, 2176, 64, -21120, 9920, 6816, -24224, 16128,
+ 608, -13488, 9584, 272, -2544, 16, -2304, -192, 1728, -16, 1568, 128, -1184,
+} ;
+
+
+static void
+test_oki_adpcm (void)
+{
+ IMA_OKI_ADPCM adpcm ;
+ unsigned char code ;
+ int i, j ;
+
+ print_test_name ("Testing ima/oki encoder") ;
+
+ ima_oki_adpcm_init (&adpcm, IMA_OKI_ADPCM_TYPE_OKI) ;
+ for (i = 0 ; i < ARRAY_LEN (test_codes) ; i++)
+ for (j = 0, code = test_codes [i] ; j < 2 ; j++, code <<= 4)
+ if (adpcm_decode (&adpcm, code >> 4) != test_pcm [2 * i + j])
+ { printf ("\n\nFail at i = %d, j = %d.\n\n", i, j) ;
+ exit (1) ;
+ } ;
+
+ puts ("ok") ;
+
+ print_test_name ("Testing ima/oki decoder") ;
+
+ ima_oki_adpcm_init (&adpcm, IMA_OKI_ADPCM_TYPE_OKI) ;
+ for (i = 0 ; i < ARRAY_LEN (test_pcm) - 1 ; i += j)
+ { code = adpcm_encode (&adpcm, test_pcm [i]) ;
+ code = (code << 4) | adpcm_encode (&adpcm, test_pcm [i + 1]) ;
+ if (code != test_codes [i / 2])
+ { printf ("\n\nFail at i = %d, %d should be %d\n\n", i, code, test_codes [i / 2]) ;
+ exit (1) ;
+ } ;
+ } ;
+
+ puts ("ok") ;
+} /* test_oki_adpcm */
+
+static void
+test_oki_adpcm_block (void)
+{
+ IMA_OKI_ADPCM adpcm ;
+ int k ;
+
+ if (ARRAY_LEN (adpcm.pcm) < ARRAY_LEN (test_pcm))
+ { printf ("\n\nLine %d : ARRAY_LEN (adpcm->pcm) > ARRAY_LEN (test_pcm) (%d > %d).\n\n", __LINE__, ARRAY_LEN (adpcm.pcm), ARRAY_LEN (test_pcm)) ;
+ exit (1) ;
+ } ;
+
+ if (ARRAY_LEN (adpcm.codes) < ARRAY_LEN (test_codes))
+ { printf ("\n\nLine %d : ARRAY_LEN (adcodes->codes) > ARRAY_LEN (test_codes).n", __LINE__) ;
+ exit (1) ;
+ } ;
+
+ print_test_name ("Testing ima/oki block encoder") ;
+
+ ima_oki_adpcm_init (&adpcm, IMA_OKI_ADPCM_TYPE_OKI) ;
+
+ memcpy (adpcm.pcm, test_pcm, sizeof (adpcm.pcm [0]) * ARRAY_LEN (test_pcm)) ;
+ adpcm.pcm_count = ARRAY_LEN (test_pcm) ;
+ adpcm.code_count = 13 ;
+
+ ima_oki_adpcm_encode_block (&adpcm) ;
+
+ if (adpcm.code_count * 2 != ARRAY_LEN (test_pcm))
+ { printf ("\n\nLine %d : %d * 2 != %d\n\n", __LINE__, adpcm.code_count * 2, ARRAY_LEN (test_pcm)) ;
+ exit (1) ;
+ } ;
+
+ for (k = 0 ; k < ARRAY_LEN (test_codes) ; k++)
+ if (adpcm.codes [k] != test_codes [k])
+ { printf ("\n\nLine %d : Fail at k = %d, %d should be %d\n\n", __LINE__, k, adpcm.codes [k], test_codes [k]) ;
+ exit (1) ;
+ } ;
+
+ puts ("ok") ;
+
+ print_test_name ("Testing ima/oki block decoder") ;
+
+ ima_oki_adpcm_init (&adpcm, IMA_OKI_ADPCM_TYPE_OKI) ;
+
+ memcpy (adpcm.codes, test_codes, sizeof (adpcm.codes [0]) * ARRAY_LEN (test_codes)) ;
+ adpcm.code_count = ARRAY_LEN (test_codes) ;
+ adpcm.pcm_count = 13 ;
+
+ ima_oki_adpcm_decode_block (&adpcm) ;
+
+ if (adpcm.pcm_count != 2 * ARRAY_LEN (test_codes))
+ { printf ("\n\nLine %d : %d * 2 != %d\n\n", __LINE__, adpcm.pcm_count, 2 * ARRAY_LEN (test_codes)) ;
+ exit (1) ;
+ } ;
+
+ for (k = 0 ; k < ARRAY_LEN (test_pcm) ; k++)
+ if (adpcm.pcm [k] != test_pcm [k])
+ { printf ("\n\nLine %d : Fail at i = %d, %d should be %d.\n\n", __LINE__, k, adpcm.pcm [k], test_pcm [k]) ;
+ exit (1) ;
+ } ;
+
+ puts ("ok") ;
+} /* test_oki_adpcm_block */
+
+void
+test_ima_oki_adpcm (void)
+{
+ test_oki_adpcm () ;
+ test_oki_adpcm_block () ;
+} /* main */
+
Modified: freeswitch/trunk/libs/libsndfile/src/test_log_printf.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/src/test_log_printf.c (original)
+++ freeswitch/trunk/libs/libsndfile/src/test_log_printf.c Thu May 21 16:09:30 2009
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 2003-2005 Erik de Castro Lopo <erikd at mega-nerd.com>
+** Copyright (C) 2003-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU Lesser General Public License as published by
@@ -16,67 +16,76 @@
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
+#include "sfconfig.h"
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <errno.h>
-#include "sfconfig.h"
-
-/*
-** This is a bit rough, but it is the nicest way to do it.
-*/
-#define PSF_LOG_PRINTF_ONLY
-#include "common.c"
+#include "common.h"
+#include "test_main.h"
#define CMP_0_ARGS(line,err,fmt) \
{ psf->logindex = 0 ; \
- LSF_SNPRINTF (buffer, sizeof (buffer), (fmt)) ; \
+ snprintf (buffer, sizeof (buffer), (fmt)) ; \
psf_log_printf (psf, (fmt)) ; \
err += compare_strings_or_die (line, fmt, buffer, psf->logbuffer) ; \
}
#define CMP_2_ARGS(line,err,fmt,a) \
{ psf->logindex = 0 ; \
- LSF_SNPRINTF (buffer, sizeof (buffer), (fmt), (a), (a)) ; \
+ snprintf (buffer, sizeof (buffer), (fmt), (a), (a)) ; \
psf_log_printf (psf, (fmt), (a), (a)) ; \
err += compare_strings_or_die (line, fmt, buffer, psf->logbuffer) ; \
}
#define CMP_4_ARGS(line,err,fmt,a) \
{ psf->logindex = 0 ; \
- LSF_SNPRINTF (buffer, sizeof (buffer), (fmt), (a), (a), (a), (a)) ; \
+ snprintf (buffer, sizeof (buffer), (fmt), (a), (a), (a), (a)) ; \
psf_log_printf (psf, (fmt), (a), (a), (a), (a)) ; \
err += compare_strings_or_die (line, fmt, buffer, psf->logbuffer) ; \
}
#define CMP_5_ARGS(line,err,fmt,a) \
{ psf->logindex = 0 ; \
- LSF_SNPRINTF (buffer, sizeof (buffer), (fmt), (a), (a), (a), (a), (a)) ; \
+ snprintf (buffer, sizeof (buffer), (fmt), (a), (a), (a), (a), (a)) ; \
psf_log_printf (psf, (fmt), (a), (a), (a), (a), (a)) ; \
err += compare_strings_or_die (line, fmt, buffer, psf->logbuffer) ; \
}
#define CMP_6_ARGS(line,err,fmt,a) \
{ psf->logindex = 0 ; \
- LSF_SNPRINTF (buffer, sizeof (buffer), (fmt), (a), (a), (a), (a), (a), (a)) ; \
+ snprintf (buffer, sizeof (buffer), (fmt), (a), (a), (a), (a), (a), (a)) ; \
psf_log_printf (psf, (fmt), (a), (a), (a), (a), (a), (a)) ; \
err += compare_strings_or_die (line, fmt, buffer, psf->logbuffer) ; \
}
-static int compare_strings_or_die (int linenum, const char *fmt, const char* s1, const char* s3) ;
+static int
+compare_strings_or_die (int linenum, const char *fmt, const char* s1, const char* s2)
+{ int errors = 0 ;
+/*-puts (s1) ;puts (s2) ;-*/
+
+ if (strcmp (s1, s2) != 0)
+ { printf ("\n\nLine %d: string compare mismatch:\n\t", linenum) ;
+ printf ("\"%s\"\n", fmt) ;
+ printf ("\t\"%s\"\n\t\"%s\"\n", s1, s2) ;
+ errors ++ ;
+ } ;
+
+ return errors ;
+} /* compare_strings_or_die */
-int
-main (void)
+void
+test_log_printf (void)
{ static char buffer [2048] ;
SF_PRIVATE sf_private, *psf ;
int k, errors = 0 ;
int int_values [] = { 0, 1, 12, 123, 1234, 123456, -1, -12, -123, -1234, -123456 } ;
- printf (" %-24s : ", "psf_log_printf_test") ;
- fflush (stdout) ;
+ print_test_name ("Testing psf_log_printf") ;
psf = &sf_private ;
memset (psf, 0, sizeof (sf_private)) ;
@@ -110,29 +119,5 @@
} ;
puts ("ok") ;
+} /* test_log_printf */
- return 0 ;
-} /* main */
-
-static int
-compare_strings_or_die (int linenum, const char *fmt, const char* s1, const char* s2)
-{ int errors = 0 ;
-/*-puts (s1) ;puts (s2) ;-*/
-
- if (strcmp (s1, s2) != 0)
- { printf ("\n\nLine %d: string compare mismatch:\n\t", linenum) ;
- printf ("\"%s\"\n", fmt) ;
- printf ("\t\"%s\"\n\t\"%s\"\n", s1, s2) ;
- errors ++ ;
- } ;
-
- return errors ;
-} /* compare_strings_or_die */
-
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: 45147310-868b-400a-97e8-cc0a572a6270
-*/
Added: freeswitch/trunk/libs/libsndfile/src/test_main.c
==============================================================================
--- (empty file)
+++ freeswitch/trunk/libs/libsndfile/src/test_main.c Thu May 21 16:09:30 2009
@@ -0,0 +1,45 @@
+/*
+** Copyright (C) 2008-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
+**
+** This program is free software; you can redistribute it and/or modify
+** it under the terms of the GNU Lesser General Public License as published by
+** the Free Software Foundation; either version 2.1 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU Lesser General Public License for more details.
+**
+** You should have received a copy of the GNU Lesser General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#include "sfconfig.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdarg.h>
+#include <errno.h>
+
+#include "test_main.h"
+
+int
+main (void)
+{
+ test_conversions () ;
+ test_endswap () ;
+ test_float_convert () ;
+ test_double_convert () ;
+
+ test_log_printf () ;
+ test_file_io () ;
+
+ test_audio_detect () ;
+ test_ima_oki_adpcm () ;
+
+ return 0 ;
+} /* main */
+
Added: freeswitch/trunk/libs/libsndfile/src/test_main.h
==============================================================================
--- (empty file)
+++ freeswitch/trunk/libs/libsndfile/src/test_main.h Thu May 21 16:09:30 2009
@@ -0,0 +1,36 @@
+/*
+** Copyright (C) 2008-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
+**
+** This program is free software; you can redistribute it and/or modify
+** it under the terms of the GNU Lesser General Public License as published by
+** the Free Software Foundation; either version 2.1 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU Lesser General Public License for more details.
+**
+** You should have received a copy of the GNU Lesser General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+static inline void
+print_test_name (const char * name)
+{ printf (" %-40s : ", name) ;
+ fflush (stdout) ;
+} /* print_test_name */
+
+
+
+void test_conversions (void) ;
+void test_endswap (void) ;
+void test_log_printf (void) ;
+void test_file_io (void) ;
+
+void test_float_convert (void) ;
+void test_double_convert (void) ;
+
+void test_audio_detect (void) ;
+void test_ima_oki_adpcm (void) ;
Modified: freeswitch/trunk/libs/libsndfile/src/txw.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/src/txw.c (original)
+++ freeswitch/trunk/libs/libsndfile/src/txw.c Thu May 21 16:09:30 2009
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 2002-2004 Erik de Castro Lopo <erikd at mega-nerd.com>
+** Copyright (C) 2002-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU Lesser General Public License as published by
@@ -40,7 +40,7 @@
txw_open (SF_PRIVATE *psf)
{ if (psf)
return SFE_UNIMPLEMENTED ;
- return (psf && 0) ;
+ return 0 ;
} /* txw_open */
#else
@@ -125,7 +125,7 @@
static int
txw_read_header (SF_PRIVATE *psf)
{ TXW_HEADER txwh ;
- char *strptr ;
+ const char *strptr ;
memset (&txwh, 0, sizeof (txwh)) ;
memset (psf->u.cbuf, 0, sizeof (psf->u.cbuf)) ;
@@ -370,10 +370,3 @@
} /* txw_seek */
#endif
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: 4d0ba7af-b1c5-46b4-a900-7c6f59fd9a89
-*/
Modified: freeswitch/trunk/libs/libsndfile/src/ulaw.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/src/ulaw.c (original)
+++ freeswitch/trunk/libs/libsndfile/src/ulaw.c Thu May 21 16:09:30 2009
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 1999-2005 Erik de Castro Lopo <erikd at mega-nerd.com>
+** Copyright (C) 1999-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU Lesser General Public License as published by
@@ -16,8 +16,11 @@
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
+#include "sfconfig.h"
+
+#include <math.h>
+
#include "sndfile.h"
-#include "float_cast.h"
#include "common.h"
static sf_count_t ulaw_read_ulaw2s (SF_PRIVATE *psf, short *ptr, sf_count_t len) ;
@@ -1038,10 +1041,3 @@
return total ;
} /* ulaw_write_d2ulaw */
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: 655cc790-f058-45e8-89c9-86967cccc37e
-*/
Modified: freeswitch/trunk/libs/libsndfile/src/voc.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/src/voc.c (original)
+++ freeswitch/trunk/libs/libsndfile/src/voc.c Thu May 21 16:09:30 2009
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 2001-2006 Erik de Castro Lopo <erikd at mega-nerd.com>
+** Copyright (C) 2001-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU Lesser General Public License as published by
@@ -112,10 +112,10 @@
return error ;
} ;
- subformat = psf->sf.format & SF_FORMAT_SUBMASK ;
+ subformat = SF_CODEC (psf->sf.format) ;
if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR)
- { if ((psf->sf.format & SF_FORMAT_TYPEMASK) != SF_FORMAT_VOC)
+ { if ((SF_CONTAINER (psf->sf.format)) != SF_FORMAT_VOC)
return SFE_BAD_OPEN_FORMAT ;
psf->endian = SF_ENDIAN_LITTLE ;
@@ -199,20 +199,26 @@
psf->endian = SF_ENDIAN_LITTLE ;
while (1)
- { offset += psf_binheader_readf (psf, "1", &block_type) ;
+ { int size ;
+ short count ;
+
+ block_type = 0 ;
+ offset += psf_binheader_readf (psf, "1", &block_type) ;
switch (block_type)
{ case VOC_ASCII :
- { int size ;
+ offset += psf_binheader_readf (psf, "e3", &size) ;
- offset += psf_binheader_readf (psf, "e3", &size) ;
+ psf_log_printf (psf, " ASCII : %d\n", size) ;
- psf_log_printf (psf, " ASCII : %d\n", size) ;
+ offset += psf_binheader_readf (psf, "b", psf->header, size) ;
+ psf->header [size] = 0 ;
+ psf_log_printf (psf, " text : %s\n", psf->header) ;
+ continue ;
- offset += psf_binheader_readf (psf, "b", psf->header, size) ;
- psf->header [size] = 0 ;
- psf_log_printf (psf, " text : %s\n", psf->header) ;
- } ;
+ case VOC_REPEAT :
+ offset += psf_binheader_readf (psf, "e32", &size, &count) ;
+ psf_log_printf (psf, " Repeat : %d\n", count) ;
continue ;
case VOC_SOUND_DATA :
@@ -242,7 +248,7 @@
psf_log_printf (psf, "offset: %d size: %d sum: %d filelength: %D\n", offset, size, offset + size, psf->filelength) ;
return SFE_VOC_BAD_SECTIONS ;
}
- else if (offset + size - 1 < psf->filelength)
+ else if (psf->filelength - offset - size > 4)
{ psf_log_printf (psf, "Seems to be a multi-segment file (#1).\n") ;
psf_log_printf (psf, "offset: %d size: %d sum: %d filelength: %D\n", offset, size, offset + size, psf->filelength) ;
return SFE_VOC_BAD_SECTIONS ;
@@ -422,7 +428,7 @@
psf->sf.frames = psf->datalength / (psf->bytewidth * psf->sf.channels) ;
} ;
- subformat = psf->sf.format & SF_FORMAT_SUBMASK ;
+ subformat = SF_CODEC (psf->sf.format) ;
/* Reset the current header length to zero. */
psf->header [0] = 0 ;
psf->headindex = 0 ;
@@ -869,10 +875,3 @@
Data is stored left, right
------------------------------------------------------------------------*/
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: 40a50167-a81c-463a-9e1d-3282ff84e09d
-*/
Modified: freeswitch/trunk/libs/libsndfile/src/vox_adpcm.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/src/vox_adpcm.c (original)
+++ freeswitch/trunk/libs/libsndfile/src/vox_adpcm.c Thu May 21 16:09:30 2009
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 2002-2005 Erik de Castro Lopo <erikd at mega-nerd.com>
+** Copyright (C) 2002-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU Lesser General Public License as published by
@@ -19,45 +19,28 @@
/*
** This is the OKI / Dialogic ADPCM encoder/decoder. It converts from
** 12 bit linear sample data to a 4 bit ADPCM.
-**
-** Implemented from the description found here:
-**
-** http://www.comptek.ru:8100/telephony/tnotes/tt1-13.html
-**
-** and compared against the encoder/decoder found here:
-**
-** http://ibiblio.org/pub/linux/apps/sound/convert/vox.tar.gz
*/
+/*
+ * Note: some early Dialogic hardware does not always reset the ADPCM encoder
+ * at the start of each vox file. This can result in clipping and/or DC offset
+ * problems when it comes to decoding the audio. Whilst little can be done
+ * about the clipping, a DC offset can be removed by passing the decoded audio
+ * through a high-pass filter at e.g. 10Hz.
+ */
+
#include "sfconfig.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <math.h>
#include "sndfile.h"
#include "sfendian.h"
-#include "float_cast.h"
#include "common.h"
+#include "ima_oki_adpcm.h"
-#define VOX_DATA_LEN 2048
-#define PCM_DATA_LEN (VOX_DATA_LEN *2)
-
-typedef struct
-{ short last ;
- short step_index ;
-
- int vox_bytes, pcm_samples ;
-
- unsigned char vox_data [VOX_DATA_LEN] ;
- short pcm_data [PCM_DATA_LEN] ;
-} VOX_ADPCM_PRIVATE ;
-
-static int vox_adpcm_encode_block (VOX_ADPCM_PRIVATE *pvox) ;
-static int vox_adpcm_decode_block (VOX_ADPCM_PRIVATE *pvox) ;
-
-static short vox_adpcm_decode (char code, VOX_ADPCM_PRIVATE *pvox) ;
-static char vox_adpcm_encode (short samp, VOX_ADPCM_PRIVATE *pvox) ;
static sf_count_t vox_read_s (SF_PRIVATE *psf, short *ptr, sf_count_t len) ;
static sf_count_t vox_read_i (SF_PRIVATE *psf, int *ptr, sf_count_t len) ;
@@ -69,29 +52,24 @@
static sf_count_t vox_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t len) ;
static sf_count_t vox_write_d (SF_PRIVATE *psf, const double *ptr, sf_count_t len) ;
-static int vox_read_block (SF_PRIVATE *psf, VOX_ADPCM_PRIVATE *pvox, short *ptr, int len) ;
-
-/*============================================================================================
-** Predefined OKI ADPCM encoder/decoder tables.
-*/
-
-static short step_size_table [49] =
-{ 16, 17, 19, 21, 23, 25, 28, 31, 34, 37, 41, 45, 50, 55, 60,
- 66, 73, 80, 88, 97, 107, 118, 130, 143, 157, 173, 190, 209,
- 230, 253, 279, 307, 337, 371, 408, 449, 494, 544, 598, 658,
- 724, 796, 876, 963, 1060, 1166, 1282, 1408, 1552
-} ; /* step_size_table */
-
-static short step_adjust_table [8] =
-{ -1, -1, -1, -1, 2, 4, 6, 8
-} ; /* step_adjust_table */
+static int vox_read_block (SF_PRIVATE *psf, IMA_OKI_ADPCM *pvox, short *ptr, int len) ;
/*------------------------------------------------------------------------------
*/
+static int
+codec_close (SF_PRIVATE * psf)
+{
+ IMA_OKI_ADPCM * p = (IMA_OKI_ADPCM *) psf->codec_data ;
+
+ if (p->errors)
+ psf_log_printf (psf, "*** Warning : ADPCM state errors: %d\n", p->errors) ;
+ return p->errors ;
+} /* code_close */
+
int
vox_adpcm_init (SF_PRIVATE *psf)
-{ VOX_ADPCM_PRIVATE *pvox = NULL ;
+{ IMA_OKI_ADPCM *pvox = NULL ;
if (psf->mode == SFM_RDWR)
return SFE_BAD_MODE_RW ;
@@ -99,11 +77,11 @@
if (psf->mode == SFM_WRITE && psf->sf.channels != 1)
return SFE_CHANNEL_COUNT ;
- if ((pvox = malloc (sizeof (VOX_ADPCM_PRIVATE))) == NULL)
+ if ((pvox = malloc (sizeof (IMA_OKI_ADPCM))) == NULL)
return SFE_MALLOC_FAILED ;
psf->codec_data = (void*) pvox ;
- memset (pvox, 0, sizeof (VOX_ADPCM_PRIVATE)) ;
+ memset (pvox, 0, sizeof (IMA_OKI_ADPCM)) ;
if (psf->mode == SFM_WRITE)
{ psf->write_short = vox_write_s ;
@@ -129,153 +107,40 @@
psf->sf.frames = psf->filelength * 2 ;
psf->sf.seekable = SF_FALSE ;
+ psf->codec_close = codec_close ;
/* Seek back to start of data. */
if (psf_fseek (psf, 0 , SEEK_SET) == -1)
return SFE_BAD_SEEK ;
- return 0 ;
-} /* vox_adpcm_init */
-
-/*------------------------------------------------------------------------------
-*/
-
-static char
-vox_adpcm_encode (short samp, VOX_ADPCM_PRIVATE *pvox)
-{ short code ;
- short diff, error, stepsize ;
-
- stepsize = step_size_table [pvox->step_index] ;
- code = 0 ;
-
- diff = samp - pvox->last ;
- if (diff < 0)
- { code = 0x08 ;
- error = -diff ;
- }
- else
- error = diff ;
-
- if (error >= stepsize)
- { code = code | 0x04 ;
- error -= stepsize ;
- } ;
-
- if (error >= stepsize / 2)
- { code = code | 0x02 ;
- error -= stepsize / 2 ;
- } ;
-
- if (error >= stepsize / 4)
- code = code | 0x01 ;
-
- /*
- ** To close the feedback loop, the deocder is used to set the
- ** estimate of last sample and in doing so, also set the step_index.
- */
- pvox->last = vox_adpcm_decode (code, pvox) ;
-
- return code ;
-} /* vox_adpcm_encode */
-
-static short
-vox_adpcm_decode (char code, VOX_ADPCM_PRIVATE *pvox)
-{ short diff, error, stepsize, samp ;
-
- stepsize = step_size_table [pvox->step_index] ;
-
- error = stepsize / 8 ;
-
- if (code & 0x01)
- error += stepsize / 4 ;
-
- if (code & 0x02)
- error += stepsize / 2 ;
-
- if (code & 0x04)
- error += stepsize ;
-
- diff = (code & 0x08) ? -error : error ;
- samp = pvox->last + diff ;
-
- /*
- ** Apply clipping.
- */
- if (samp > 2048)
- samp = 2048 ;
- if (samp < -2048)
- samp = -2048 ;
-
- pvox->last = samp ;
- pvox->step_index += step_adjust_table [code & 0x7] ;
-
- if (pvox->step_index < 0)
- pvox->step_index = 0 ;
- if (pvox->step_index > 48)
- pvox->step_index = 48 ;
-
- return samp ;
-} /* vox_adpcm_decode */
-
-static int
-vox_adpcm_encode_block (VOX_ADPCM_PRIVATE *pvox)
-{ unsigned char code ;
- int j, k ;
-
- /* If data_count is odd, add an extra zero valued sample. */
- if (pvox->pcm_samples & 1)
- pvox->pcm_data [pvox->pcm_samples++] = 0 ;
-
- for (j = k = 0 ; k < pvox->pcm_samples ; j++)
- { code = vox_adpcm_encode (pvox->pcm_data [k++] / 16, pvox) << 4 ;
- code |= vox_adpcm_encode (pvox->pcm_data [k++] / 16, pvox) ;
- pvox->vox_data [j] = code ;
- } ;
-
- pvox->vox_bytes = j ;
+ ima_oki_adpcm_init (pvox, IMA_OKI_ADPCM_TYPE_OKI) ;
return 0 ;
-} /* vox_adpcm_encode_block */
-
-static int
-vox_adpcm_decode_block (VOX_ADPCM_PRIVATE *pvox)
-{ unsigned char code ;
- int j, k ;
-
- for (j = k = 0 ; j < pvox->vox_bytes ; j++)
- { code = pvox->vox_data [j] ;
- pvox->pcm_data [k++] = 16 * vox_adpcm_decode ((code >> 4) & 0x0f, pvox) ;
- pvox->pcm_data [k++] = 16 * vox_adpcm_decode (code & 0x0f, pvox) ;
- } ;
-
- pvox->pcm_samples = k ;
-
- return 0 ;
-} /* vox_adpcm_decode_block */
+} /* vox_adpcm_init */
/*==============================================================================
*/
static int
-vox_read_block (SF_PRIVATE *psf, VOX_ADPCM_PRIVATE *pvox, short *ptr, int len)
+vox_read_block (SF_PRIVATE *psf, IMA_OKI_ADPCM *pvox, short *ptr, int len)
{ int indx = 0, k ;
while (indx < len)
- { pvox->vox_bytes = (len - indx > PCM_DATA_LEN) ? VOX_DATA_LEN : (len - indx + 1) / 2 ;
+ { pvox->code_count = (len - indx > IMA_OKI_ADPCM_PCM_LEN) ? IMA_OKI_ADPCM_CODE_LEN : (len - indx + 1) / 2 ;
- if ((k = psf_fread (pvox->vox_data, 1, pvox->vox_bytes, psf)) != pvox->vox_bytes)
- { if (psf_ftell (psf) + k != psf->filelength)
- psf_log_printf (psf, "*** Warning : short read (%d != %d).\n", k, pvox->vox_bytes) ;
+ if ((k = psf_fread (pvox->codes, 1, pvox->code_count, psf)) != pvox->code_count)
+ { if (psf_ftell (psf) != psf->filelength)
+ psf_log_printf (psf, "*** Warning : short read (%d != %d).\n", k, pvox->code_count) ;
if (k == 0)
break ;
} ;
- pvox->vox_bytes = k ;
+ pvox->code_count = k ;
- vox_adpcm_decode_block (pvox) ;
+ ima_oki_adpcm_decode_block (pvox) ;
- memcpy (&(ptr [indx]), pvox->pcm_data, pvox->pcm_samples * sizeof (short)) ;
- indx += pvox->pcm_samples ;
+ memcpy (&(ptr [indx]), pvox->pcm, pvox->pcm_count * sizeof (short)) ;
+ indx += pvox->pcm_count ;
} ;
return indx ;
@@ -284,13 +149,13 @@
static sf_count_t
vox_read_s (SF_PRIVATE *psf, short *ptr, sf_count_t len)
-{ VOX_ADPCM_PRIVATE *pvox ;
+{ IMA_OKI_ADPCM *pvox ;
int readcount, count ;
sf_count_t total = 0 ;
if (! psf->codec_data)
return 0 ;
- pvox = (VOX_ADPCM_PRIVATE*) psf->codec_data ;
+ pvox = (IMA_OKI_ADPCM*) psf->codec_data ;
while (len > 0)
{ readcount = (len > 0x10000000) ? 0x10000000 : (int) len ;
@@ -308,14 +173,14 @@
static sf_count_t
vox_read_i (SF_PRIVATE *psf, int *ptr, sf_count_t len)
-{ VOX_ADPCM_PRIVATE *pvox ;
+{ IMA_OKI_ADPCM *pvox ;
short *sptr ;
int k, bufferlen, readcount, count ;
sf_count_t total = 0 ;
if (! psf->codec_data)
return 0 ;
- pvox = (VOX_ADPCM_PRIVATE*) psf->codec_data ;
+ pvox = (IMA_OKI_ADPCM*) psf->codec_data ;
sptr = psf->u.sbuf ;
bufferlen = ARRAY_LEN (psf->u.sbuf) ;
@@ -335,7 +200,7 @@
static sf_count_t
vox_read_f (SF_PRIVATE *psf, float *ptr, sf_count_t len)
-{ VOX_ADPCM_PRIVATE *pvox ;
+{ IMA_OKI_ADPCM *pvox ;
short *sptr ;
int k, bufferlen, readcount, count ;
sf_count_t total = 0 ;
@@ -343,7 +208,7 @@
if (! psf->codec_data)
return 0 ;
- pvox = (VOX_ADPCM_PRIVATE*) psf->codec_data ;
+ pvox = (IMA_OKI_ADPCM*) psf->codec_data ;
normfact = (psf->norm_float == SF_TRUE) ? 1.0 / ((float) 0x8000) : 1.0 ;
@@ -365,7 +230,7 @@
static sf_count_t
vox_read_d (SF_PRIVATE *psf, double *ptr, sf_count_t len)
-{ VOX_ADPCM_PRIVATE *pvox ;
+{ IMA_OKI_ADPCM *pvox ;
short *sptr ;
int k, bufferlen, readcount, count ;
sf_count_t total = 0 ;
@@ -373,7 +238,7 @@
if (! psf->codec_data)
return 0 ;
- pvox = (VOX_ADPCM_PRIVATE*) psf->codec_data ;
+ pvox = (IMA_OKI_ADPCM*) psf->codec_data ;
normfact = (psf->norm_double == SF_TRUE) ? 1.0 / ((double) 0x8000) : 1.0 ;
@@ -397,20 +262,20 @@
*/
static int
-vox_write_block (SF_PRIVATE *psf, VOX_ADPCM_PRIVATE *pvox, const short *ptr, int len)
+vox_write_block (SF_PRIVATE *psf, IMA_OKI_ADPCM *pvox, const short *ptr, int len)
{ int indx = 0, k ;
while (indx < len)
- { pvox->pcm_samples = (len - indx > PCM_DATA_LEN) ? PCM_DATA_LEN : len - indx ;
+ { pvox->pcm_count = (len - indx > IMA_OKI_ADPCM_PCM_LEN) ? IMA_OKI_ADPCM_PCM_LEN : len - indx ;
- memcpy (pvox->pcm_data, &(ptr [indx]), pvox->pcm_samples * sizeof (short)) ;
+ memcpy (pvox->pcm, &(ptr [indx]), pvox->pcm_count * sizeof (short)) ;
- vox_adpcm_encode_block (pvox) ;
+ ima_oki_adpcm_encode_block (pvox) ;
- if ((k = psf_fwrite (pvox->vox_data, 1, pvox->vox_bytes, psf)) != pvox->vox_bytes)
- psf_log_printf (psf, "*** Warning : short read (%d != %d).\n", k, pvox->vox_bytes) ;
+ if ((k = psf_fwrite (pvox->codes, 1, pvox->code_count, psf)) != pvox->code_count)
+ psf_log_printf (psf, "*** Warning : short write (%d != %d).\n", k, pvox->code_count) ;
- indx += pvox->pcm_samples ;
+ indx += pvox->pcm_count ;
} ;
return indx ;
@@ -418,13 +283,13 @@
static sf_count_t
vox_write_s (SF_PRIVATE *psf, const short *ptr, sf_count_t len)
-{ VOX_ADPCM_PRIVATE *pvox ;
+{ IMA_OKI_ADPCM *pvox ;
int writecount, count ;
sf_count_t total = 0 ;
if (! psf->codec_data)
return 0 ;
- pvox = (VOX_ADPCM_PRIVATE*) psf->codec_data ;
+ pvox = (IMA_OKI_ADPCM*) psf->codec_data ;
while (len)
{ writecount = (len > 0x10000000) ? 0x10000000 : (int) len ;
@@ -442,14 +307,14 @@
static sf_count_t
vox_write_i (SF_PRIVATE *psf, const int *ptr, sf_count_t len)
-{ VOX_ADPCM_PRIVATE *pvox ;
+{ IMA_OKI_ADPCM *pvox ;
short *sptr ;
int k, bufferlen, writecount, count ;
sf_count_t total = 0 ;
if (! psf->codec_data)
return 0 ;
- pvox = (VOX_ADPCM_PRIVATE*) psf->codec_data ;
+ pvox = (IMA_OKI_ADPCM*) psf->codec_data ;
sptr = psf->u.sbuf ;
bufferlen = ARRAY_LEN (psf->u.sbuf) ;
@@ -469,7 +334,7 @@
static sf_count_t
vox_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t len)
-{ VOX_ADPCM_PRIVATE *pvox ;
+{ IMA_OKI_ADPCM *pvox ;
short *sptr ;
int k, bufferlen, writecount, count ;
sf_count_t total = 0 ;
@@ -477,7 +342,7 @@
if (! psf->codec_data)
return 0 ;
- pvox = (VOX_ADPCM_PRIVATE*) psf->codec_data ;
+ pvox = (IMA_OKI_ADPCM*) psf->codec_data ;
normfact = (psf->norm_float == SF_TRUE) ? (1.0 * 0x7FFF) : 1.0 ;
@@ -499,7 +364,7 @@
static sf_count_t
vox_write_d (SF_PRIVATE *psf, const double *ptr, sf_count_t len)
-{ VOX_ADPCM_PRIVATE *pvox ;
+{ IMA_OKI_ADPCM *pvox ;
short *sptr ;
int k, bufferlen, writecount, count ;
sf_count_t total = 0 ;
@@ -507,7 +372,7 @@
if (! psf->codec_data)
return 0 ;
- pvox = (VOX_ADPCM_PRIVATE*) psf->codec_data ;
+ pvox = (IMA_OKI_ADPCM*) psf->codec_data ;
normfact = (psf->norm_double == SF_TRUE) ? (1.0 * 0x7FFF) : 1.0 ;
@@ -527,11 +392,3 @@
return total ;
} /* vox_write_d */
-
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: e15e97fe-ff9d-4b46-a489-7059fb2d0b1e
-*/
Modified: freeswitch/trunk/libs/libsndfile/src/w64.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/src/w64.c (original)
+++ freeswitch/trunk/libs/libsndfile/src/w64.c Thu May 21 16:09:30 2009
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 1999-2005 Erik de Castro Lopo <erikd at mega-nerd.com>
+** Copyright (C) 1999-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU Lesser General Public License as published by
@@ -47,8 +47,8 @@
static unsigned char name [16] = { (x0), (x1), (x2), (x3), (x4), (x5), \
(x6), (x7), (x8), (x9), (xa), (xb), (xc), (xd), (xe), (xf) }
-#define riff_HASH16 MAKE_HASH16 ('r', 'i', 'f', 'f', 0x2E, 0x91, 0xCF, 0x11, 0xA5, \
- 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00)
+#define riff_HASH16 MAKE_HASH16 ('r', 'i', 'f', 'f', 0x2E, 0x91, 0xCF, 0x11, \
+ 0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00)
#define wave_HASH16 MAKE_HASH16 ('w', 'a', 'v', 'e', 0xF3, 0xAC, 0xD3, 0x11, \
0x8C, 0xD1, 0x00, 0xC0, 0x4F, 0x8E, 0xDB, 0x8A)
@@ -65,6 +65,25 @@
#define ACID_HASH16 MAKE_HASH16 (0x6D, 0x07, 0x1C, 0xEA, 0xA3, 0xEF, 0x78, 0x4C, \
0x90, 0x57, 0x7F, 0x79, 0xEE, 0x25, 0x2A, 0xAE)
+#define levl_HASH16 MAKE_HASH16 (0x6c, 0x65, 0x76, 0x6c, 0xf3, 0xac, 0xd3, 0x11, \
+ 0xd1, 0x8c, 0x00, 0xC0, 0x4F, 0x8E, 0xDB, 0x8A)
+
+#define list_HASH16 MAKE_HASH16 (0x6C, 0x69, 0x73, 0x74, 0x2F, 0x91, 0xCF, 0x11, \
+ 0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00)
+
+#define junk_HASH16 MAKE_HASH16 (0x6A, 0x75, 0x6E, 0x6b, 0xF3, 0xAC, 0xD3, 0x11, \
+ 0x8C, 0xD1, 0x00, 0xC0, 0x4f, 0x8E, 0xDB, 0x8A)
+
+#define bext_MARKER MAKE_HASH16 (0x62, 0x65, 0x78, 0x74, 0xf3, 0xac, 0xd3, 0xaa, \
+ 0xd1, 0x8c, 0x00, 0xC0, 0x4F, 0x8E, 0xDB, 0x8A)
+
+#define MARKER_HASH16 MAKE_HASH16 (0x56, 0x62, 0xf7, 0xab, 0x2d, 0x39, 0xd2, 0x11, \
+ 0x86, 0xc7, 0x00, 0xc0, 0x4f, 0x8e, 0xdb, 0x8a)
+
+#define SUMLIST_HASH16 MAKE_HASH16 (0xBC, 0x94, 0x5F, 0x92, 0x5A, 0x52, 0xD2, 0x11, \
+ 0x86, 0xDC, 0x00, 0xC0, 0x4F, 0x8E, 0xDB, 0x8A)
+
+
MAKE_MARKER16 (riff_MARKER16, 'r', 'i', 'f', 'f', 0x2E, 0x91, 0xCF, 0x11,
0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00) ;
@@ -103,17 +122,22 @@
int
w64_open (SF_PRIVATE *psf)
-{ int subformat, error, blockalign = 0, framesperblock = 0 ;
+{ WAV_PRIVATE * wpriv ;
+ int subformat, error, blockalign = 0, framesperblock = 0 ;
+
+ if ((wpriv = calloc (1, sizeof (WAV_PRIVATE))) == NULL)
+ return SFE_MALLOC_FAILED ;
+ psf->container_data = wpriv ;
if (psf->mode == SFM_READ || (psf->mode == SFM_RDWR &&psf->filelength > 0))
{ if ((error = w64_read_header (psf, &blockalign, &framesperblock)))
return error ;
} ;
- if ((psf->sf.format & SF_FORMAT_TYPEMASK) != SF_FORMAT_W64)
+ if ((SF_CONTAINER (psf->sf.format)) != SF_FORMAT_W64)
return SFE_BAD_OPEN_FORMAT ;
- subformat = psf->sf.format & SF_FORMAT_SUBMASK ;
+ subformat = SF_CODEC (psf->sf.format) ;
if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR)
{ if (psf->is_pipe)
@@ -196,17 +220,25 @@
static int
w64_read_header (SF_PRIVATE *psf, int *blockalign, int *framesperblock)
-{ WAV_FMT wav_fmt ;
+{ WAV_PRIVATE *wpriv ;
+ WAV_FMT *wav_fmt ;
int dword = 0, marker, format = 0 ;
sf_count_t chunk_size, bytesread = 0 ;
int parsestage = 0, error, done = 0 ;
+ if ((wpriv = psf->container_data) == NULL)
+ return SFE_INTERNAL ;
+ wav_fmt = &wpriv->wav_fmt ;
+
/* Set position to start of file to begin reading header. */
- memset (&wav_fmt, 0, sizeof (wav_fmt)) ;
psf_binheader_readf (psf, "p", 0) ;
while (! done)
- { /* Read the 4 byte marker and jump 12 bytes. */
+ { /* Each new chunk must start on an 8 byte boundary, so jump if needed. */
+ if (psf->headindex & 0x7)
+ psf_binheader_readf (psf, "j", 8 - (psf->headindex & 0x7)) ;
+
+ /* Generate hash of 16 byte marker. */
bytesread += psf_binheader_readf (psf, "h", &marker) ;
chunk_size = 0 ;
@@ -217,7 +249,7 @@
bytesread += psf_binheader_readf (psf, "e8", &chunk_size) ;
- if (psf->filelength < chunk_size)
+ if (psf->filelength != chunk_size)
psf_log_printf (psf, "riff : %D (should be %D)\n", chunk_size, psf->filelength) ;
else
psf_log_printf (psf, "riff : %D\n", chunk_size) ;
@@ -238,7 +270,7 @@
case fmt_HASH16 :
if ((parsestage & (HAVE_riff | HAVE_wave)) != (HAVE_riff | HAVE_wave))
- return SFE_W64_NO_FMT ;
+ return SFE_WAV_NO_FMT ;
bytesread += psf_binheader_readf (psf, "e8", &chunk_size) ;
psf_log_printf (psf, " fmt : %D\n", chunk_size) ;
@@ -246,13 +278,13 @@
/* size of 16 byte marker and 8 byte chunk_size value. */
chunk_size -= 24 ;
- if ((error = wav_w64_read_fmt_chunk (psf, &wav_fmt, (int) chunk_size)))
+ if ((error = wav_w64_read_fmt_chunk (psf, (int) chunk_size)))
return error ;
if (chunk_size % 8)
psf_binheader_readf (psf, "j", 8 - (chunk_size % 8)) ;
- format = wav_fmt.format ;
+ format = wav_fmt->format ;
parsestage |= HAVE_fmt ;
break ;
@@ -290,12 +322,49 @@
psf_fseek (psf, chunk_size, SEEK_CUR) ;
break ;
+ case levl_HASH16 :
+ psf_binheader_readf (psf, "e8", &chunk_size) ;
+ psf_log_printf (psf, "levl : %D\n", chunk_size) ;
+ dword = chunk_size ;
+ psf_binheader_readf (psf, "j", dword - 24) ;
+ break ;
+
+ case list_HASH16 :
+ psf_binheader_readf (psf, "e8", &chunk_size) ;
+ psf_log_printf (psf, "list : %D\n", chunk_size) ;
+ dword = chunk_size ;
+ psf_binheader_readf (psf, "j", dword - 24) ;
+ break ;
+
+ case junk_HASH16 :
+ psf_binheader_readf (psf, "e8", &chunk_size) ;
+ psf_log_printf (psf, "junk : %D\n", chunk_size) ;
+ dword = chunk_size ;
+ psf_binheader_readf (psf, "j", dword - 24) ;
+ break ;
+
+ case bext_MARKER :
+ psf_binheader_readf (psf, "e8", &chunk_size) ;
+ psf_log_printf (psf, "bext : %D\n", chunk_size) ;
+ dword = chunk_size ;
+ psf_binheader_readf (psf, "j", dword - 24) ;
+ break ;
+
+ case MARKER_HASH16 :
+ psf_binheader_readf (psf, "e8", &chunk_size) ;
+ psf_log_printf (psf, "marker : %D\n", chunk_size) ;
+ dword = chunk_size ;
+ psf_binheader_readf (psf, "j", dword - 24) ;
+ break ;
+
+ case SUMLIST_HASH16 :
+ psf_binheader_readf (psf, "e8", &chunk_size) ;
+ psf_log_printf (psf, "summary list : %D\n", chunk_size) ;
+ dword = chunk_size ;
+ psf_binheader_readf (psf, "j", dword - 24) ;
+ break ;
+
default :
- if (psf_ftell (psf) & 0x0F)
- { psf_log_printf (psf, " Unknown chunk marker at position %d. Resynching.\n", dword - 4) ;
- psf_binheader_readf (psf, "j", -3) ;
- break ;
- } ;
psf_log_printf (psf, "*** Unknown chunk marker : %X. Exiting parser.\n", marker) ;
done = SF_TRUE ;
break ;
@@ -308,10 +377,10 @@
break ;
} ; /* while (1) */
- if (! psf->dataoffset)
+ if (psf->dataoffset <= 0)
return SFE_W64_NO_DATA ;
- psf->endian = SF_ENDIAN_LITTLE ; /* All WAV files are little endian. */
+ psf->endian = SF_ENDIAN_LITTLE ; /* All W64 files are little endian. */
if (psf_ftell (psf) != psf->dataoffset)
psf_fseek (psf, psf->dataoffset, SEEK_SET) ;
@@ -340,14 +409,14 @@
case WAVE_FORMAT_MS_ADPCM :
psf->sf.format = (SF_FORMAT_W64 | SF_FORMAT_MS_ADPCM) ;
- *blockalign = wav_fmt.msadpcm.blockalign ;
- *framesperblock = wav_fmt.msadpcm.samplesperblock ;
+ *blockalign = wav_fmt->msadpcm.blockalign ;
+ *framesperblock = wav_fmt->msadpcm.samplesperblock ;
break ;
case WAVE_FORMAT_IMA_ADPCM :
psf->sf.format = (SF_FORMAT_W64 | SF_FORMAT_IMA_ADPCM) ;
- *blockalign = wav_fmt.ima.blockalign ;
- *framesperblock = wav_fmt.ima.samplesperblock ;
+ *blockalign = wav_fmt->ima.blockalign ;
+ *framesperblock = wav_fmt->ima.samplesperblock ;
break ;
case WAVE_FORMAT_GSM610 :
@@ -390,9 +459,9 @@
psf_fseek (psf, 0, SEEK_SET) ;
/* riff marker, length, wave and 'fmt ' markers. */
- psf_binheader_writef (psf, "eh8hh", riff_MARKER16, psf->filelength - 8, wave_MARKER16, fmt_MARKER16) ;
+ psf_binheader_writef (psf, "eh8hh", riff_MARKER16, psf->filelength, wave_MARKER16, fmt_MARKER16) ;
- subformat = psf->sf.format & SF_FORMAT_SUBMASK ;
+ subformat = SF_CODEC (psf->sf.format) ;
switch (subformat)
{ case SF_FORMAT_PCM_U8 :
@@ -568,11 +637,3 @@
return 0 ;
} /* w64_close */
-
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: 9aa4e141-538a-4dd9-99c9-b3f0f2dd4f4a
-*/
Modified: freeswitch/trunk/libs/libsndfile/src/wav.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/src/wav.c (original)
+++ freeswitch/trunk/libs/libsndfile/src/wav.c Thu May 21 16:09:30 2009
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 1999-2006 Erik de Castro Lopo <erikd at mega-nerd.com>
+** Copyright (C) 1999-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
** Copyright (C) 2004-2005 David Viens <davidv at plogue.com>
**
** This program is free software; you can redistribute it and/or modify
@@ -54,6 +54,7 @@
#define note_MARKER (MAKE_MARKER ('n', 'o', 't', 'e'))
#define smpl_MARKER (MAKE_MARKER ('s', 'm', 'p', 'l'))
#define bext_MARKER (MAKE_MARKER ('b', 'e', 'x', 't'))
+#define iXML_MARKER (MAKE_MARKER ('i', 'X', 'M', 'L'))
#define levl_MARKER (MAKE_MARKER ('l', 'e', 'v', 'l'))
#define MEXT_MARKER (MAKE_MARKER ('M', 'E', 'X', 'T'))
#define DISP_MARKER (MAKE_MARKER ('D', 'I', 'S', 'P'))
@@ -63,6 +64,16 @@
#define afsp_MARKER (MAKE_MARKER ('a', 'f', 's', 'p'))
#define clm_MARKER (MAKE_MARKER ('c', 'l', 'm', ' '))
#define elmo_MARKER (MAKE_MARKER ('e', 'l', 'm', 'o'))
+#define cart_MARKER (MAKE_MARKER ('c', 'a', 'r', 't'))
+
+#define exif_MARKER (MAKE_MARKER ('e', 'x', 'i', 'f'))
+#define ever_MARKER (MAKE_MARKER ('e', 'v', 'e', 'r'))
+#define etim_MARKER (MAKE_MARKER ('e', 't', 'i', 'm'))
+#define ecor_MARKER (MAKE_MARKER ('e', 'c', 'o', 'r'))
+#define emdl_MARKER (MAKE_MARKER ('e', 'm', 'd', 'l'))
+#define emnt_MARKER (MAKE_MARKER ('e', 'm', 'n', 't'))
+#define erel_MARKER (MAKE_MARKER ('e', 'r', 'e', 'l'))
+#define eucm_MARKER (MAKE_MARKER ('e', 'u', 'c', 'm'))
#define ISFT_MARKER (MAKE_MARKER ('I', 'S', 'F', 'T'))
#define ICRD_MARKER (MAKE_MARKER ('I', 'C', 'R', 'D'))
@@ -83,7 +94,8 @@
#define OggS_MARKER (MAKE_MARKER ('O', 'g', 'g', 'S'))
#define WAV_PEAK_CHUNK_SIZE(ch) (2 * sizeof (int) + ch * (sizeof (float) + sizeof (int)))
-#define WAV_BEXT_CHUNK_SIZE 602
+#define WAV_BEXT_MIN_CHUNK_SIZE 602
+#define WAV_BEXT_MAX_CHUNK_SIZE (10 * 1024)
enum
{ HAVE_RIFF = 0x01,
@@ -146,14 +158,13 @@
static int wav_read_header (SF_PRIVATE *psf, int *blockalign, int *framesperblock) ;
static int wav_write_header (SF_PRIVATE *psf, int calc_length) ;
-static int wavex_write_header (SF_PRIVATE *psf, int calc_length) ;
-
static int wav_write_tailer (SF_PRIVATE *psf) ;
static void wav_write_strings (SF_PRIVATE *psf, int location) ;
static int wav_command (SF_PRIVATE *psf, int command, void *data, int datasize) ;
static int wav_close (SF_PRIVATE *psf) ;
static int wav_subchunk_parse (SF_PRIVATE *psf, int chunk) ;
+static int exif_subchunk_parse (SF_PRIVATE *psf, unsigned int length) ;
static int wav_read_smpl_chunk (SF_PRIVATE *psf, unsigned int chunklen) ;
static int wav_read_acid_chunk (SF_PRIVATE *psf, unsigned int chunklen) ;
static int wav_read_bext_chunk (SF_PRIVATE *psf, unsigned int chunklen) ;
@@ -165,27 +176,37 @@
int
wav_open (SF_PRIVATE *psf)
-{ int format, subformat, error, blockalign = 0, framesperblock = 0 ;
+{ WAV_PRIVATE * wpriv ;
+ int format, subformat, error, blockalign = 0, framesperblock = 0 ;
+
+ if ((wpriv = calloc (1, sizeof (WAV_PRIVATE))) == NULL)
+ return SFE_MALLOC_FAILED ;
+ psf->container_data = wpriv ;
+
+ wpriv->wavex_ambisonic = SF_AMBISONIC_NONE ;
+ psf->str_flags = SF_STR_ALLOW_START | SF_STR_ALLOW_END ;
if (psf->mode == SFM_READ || (psf->mode == SFM_RDWR && psf->filelength > 0))
{ if ((error = wav_read_header (psf, &blockalign, &framesperblock)))
return error ;
} ;
- subformat = psf->sf.format & SF_FORMAT_SUBMASK ;
+ subformat = SF_CODEC (psf->sf.format) ;
if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR)
{ if (psf->is_pipe)
return SFE_NO_PIPE_WRITE ;
- format = psf->sf.format & SF_FORMAT_TYPEMASK ;
+ wpriv->wavex_ambisonic = SF_AMBISONIC_NONE ;
+
+ format = SF_CONTAINER (psf->sf.format) ;
if (format != SF_FORMAT_WAV && format != SF_FORMAT_WAVEX)
return SFE_BAD_OPEN_FORMAT ;
psf->blockwidth = psf->bytewidth * psf->sf.channels ;
/* RIFF WAVs are little-endian, RIFX WAVs are big-endian, default to little */
- psf->endian = psf->sf.format & SF_FORMAT_ENDMASK ;
+ psf->endian = SF_ENDIAN (psf->sf.format) ;
if (CPU_IS_BIG_ENDIAN && psf->endian == SF_ENDIAN_CPU)
psf->endian = SF_ENDIAN_BIG ;
else if (psf->endian != SF_ENDIAN_BIG)
@@ -203,8 +224,6 @@
framesperblock = -1 ; /* Corrected later. */
} ;
- psf->str_flags = SF_STR_ALLOW_START | SF_STR_ALLOW_END ;
-
/* By default, add the peak chunk to floating point files. Default behaviour
** can be switched off using sf_command (SFC_SET_PEAK_CHUNK, SF_FALSE).
*/
@@ -214,7 +233,7 @@
psf->peak_info->peak_loc = SF_PEAK_START ;
} ;
- psf->write_header = (format == SF_FORMAT_WAV) ? wav_write_header : wavex_write_header ;
+ psf->write_header = wav_write_header ;
} ;
psf->container_close = wav_close ;
@@ -277,13 +296,20 @@
static int
wav_read_header (SF_PRIVATE *psf, int *blockalign, int *framesperblock)
-{ WAV_FMT wav_fmt ;
+{ WAV_PRIVATE *wpriv ;
+ WAV_FMT *wav_fmt ;
FACT_CHUNK fact_chunk ;
unsigned dword = 0, marker, RIFFsize, done = 0 ;
int parsestage = 0, error, format = 0 ;
char *cptr ;
- memset (&wav_fmt, 0, sizeof (wav_fmt)) ;
+ if (psf->filelength > SF_PLATFORM_S64 (0xffffffff))
+ psf_log_printf (psf, "Warning : filelength > 0xffffffff. This is bad!!!!\n") ;
+
+ if ((wpriv = psf->container_data) == NULL)
+ return SFE_INTERNAL ;
+ wav_fmt = &wpriv->wav_fmt ;
+
/* Set position to start of file to begin reading header. */
psf_binheader_readf (psf, "p", 0) ;
@@ -354,10 +380,10 @@
psf_binheader_readf (psf, "4", &dword) ;
psf_log_printf (psf, "fmt : %d\n", dword) ;
- if ((error = wav_w64_read_fmt_chunk (psf, &wav_fmt, dword)))
+ if ((error = wav_w64_read_fmt_chunk (psf, dword)))
return error ;
- format = wav_fmt.format ;
+ format = wav_fmt->format ;
break ;
case data_MARKER :
@@ -374,35 +400,36 @@
psf->datalength = dword ;
psf->dataoffset = psf_ftell (psf) ;
- if (dword == 0 && RIFFsize == 8 && psf->filelength > 44)
- { psf_log_printf (psf, "*** Looks like a WAV file which wasn't closed properly. Fixing it.\n") ;
- psf->datalength = dword = psf->filelength - psf->dataoffset ;
- } ;
+ if (psf->dataoffset > 0)
+ { if (dword == 0 && RIFFsize == 8 && psf->filelength > 44)
+ { psf_log_printf (psf, "*** Looks like a WAV file which wasn't closed properly. Fixing it.\n") ;
+ psf->datalength = psf->filelength - psf->dataoffset ;
+ } ;
- if (psf->datalength > psf->filelength - psf->dataoffset)
- { psf_log_printf (psf, "data : %D (should be %D)\n", psf->datalength, psf->filelength - psf->dataoffset) ;
- psf->datalength = psf->filelength - psf->dataoffset ;
- }
- else
- psf_log_printf (psf, "data : %D\n", psf->datalength) ;
+ if (psf->datalength > psf->filelength - psf->dataoffset)
+ { psf_log_printf (psf, "data : %D (should be %D)\n", psf->datalength, psf->filelength - psf->dataoffset) ;
+ psf->datalength = psf->filelength - psf->dataoffset ;
+ }
+ else
+ psf_log_printf (psf, "data : %D\n", psf->datalength) ;
- /* Only set dataend if there really is data at the end. */
- if (psf->datalength + psf->dataoffset < psf->filelength)
- psf->dataend = psf->datalength + psf->dataoffset ;
-
- if (format == WAVE_FORMAT_MS_ADPCM && psf->datalength % 2)
- { psf->datalength ++ ;
- psf_log_printf (psf, "*** Data length odd. Increasing it by 1.\n") ;
+ /* Only set dataend if there really is data at the end. */
+ if (psf->datalength + psf->dataoffset < psf->filelength)
+ psf->dataend = psf->datalength + psf->dataoffset ;
+
+ if (format == WAVE_FORMAT_MS_ADPCM && psf->datalength % 2)
+ { psf->datalength ++ ;
+ psf_log_printf (psf, "*** Data length odd. Increasing it by 1.\n") ;
+ } ;
} ;
- if (! psf->sf.seekable)
+ if (! psf->sf.seekable || psf->dataoffset < 0)
break ;
/* Seek past data and continue reading header. */
psf_fseek (psf, psf->datalength, SEEK_CUR) ;
- dword = psf_ftell (psf) ;
- if (dword != (sf_count_t) (psf->dataoffset + psf->datalength))
+ if (psf_ftell (psf) != psf->datalength + psf->dataoffset)
psf_log_printf (psf, "*** psf_fseek past end error ***\n", dword, psf->dataoffset + psf->datalength) ;
break ;
@@ -465,7 +492,7 @@
psf->peak_info->peaks [dword].value = value ;
psf->peak_info->peaks [dword].position = position ;
- LSF_SNPRINTF (cptr, sizeof (psf->u.cbuf), " %2d %-12ld %g\n",
+ snprintf (cptr, sizeof (psf->u.cbuf), " %2d %-12ld %g\n",
dword, (long) psf->peak_info->peaks [dword].position, psf->peak_info->peaks [dword].value) ;
cptr [sizeof (psf->u.cbuf) - 1] = 0 ;
psf_log_printf (psf, cptr) ;
@@ -539,28 +566,36 @@
break ;
case bext_MARKER :
+ /*
+ The 'bext' chunk can actually be updated, so don't need to set this.
parsestage |= HAVE_other ;
-
+ */
psf_binheader_readf (psf, "4", &dword) ;
- if (dword < WAV_BEXT_CHUNK_SIZE)
- psf_log_printf (psf, "bext : %u (should be >= %d)\n", dword, WAV_BEXT_CHUNK_SIZE) ;
- else
- psf_log_printf (psf, "bext : %u\n", dword) ;
-
if ((error = wav_read_bext_chunk (psf, dword)))
return error ;
break ;
- case strc_MARKER : /* Multiple of 32 bytes. */
+ case PAD_MARKER :
+ /*
+ We can eat into a 'PAD ' chunk if we need to.
+ parsestage |= HAVE_other ;
+ */
+ psf_binheader_readf (psf, "4", &dword) ;
+ psf_log_printf (psf, "%M : %u\n", marker, dword) ;
+ dword += (dword & 1) ;
+ psf_binheader_readf (psf, "j", dword) ;
+ break ;
+ case iXML_MARKER : /* See http://en.wikipedia.org/wiki/IXML */
+ case strc_MARKER : /* Multiple of 32 bytes. */
case afsp_MARKER :
case clm_MARKER :
case elmo_MARKER :
+ case cart_MARKER :
case levl_MARKER :
case plst_MARKER :
case DISP_MARKER :
case MEXT_MARKER :
- case PAD_MARKER :
parsestage |= HAVE_other ;
psf_binheader_readf (psf, "4", &dword) ;
@@ -597,7 +632,7 @@
} ;
} ; /* while (1) */
- if (! psf->dataoffset)
+ if (psf->dataoffset <= 0)
return SFE_WAV_NO_DATA ;
/* WAVs can be little or big endian */
@@ -628,8 +663,8 @@
switch (format)
{ case WAVE_FORMAT_EXTENSIBLE :
if (psf->sf.format == (SF_FORMAT_WAVEX | SF_FORMAT_MS_ADPCM))
- { *blockalign = wav_fmt.msadpcm.blockalign ;
- *framesperblock = wav_fmt.msadpcm.samplesperblock ;
+ { *blockalign = wav_fmt->msadpcm.blockalign ;
+ *framesperblock = wav_fmt->msadpcm.samplesperblock ;
} ;
break ;
@@ -649,14 +684,14 @@
case WAVE_FORMAT_MS_ADPCM :
psf->sf.format = (SF_FORMAT_WAV | SF_FORMAT_MS_ADPCM) ;
- *blockalign = wav_fmt.msadpcm.blockalign ;
- *framesperblock = wav_fmt.msadpcm.samplesperblock ;
+ *blockalign = wav_fmt->msadpcm.blockalign ;
+ *framesperblock = wav_fmt->msadpcm.samplesperblock ;
break ;
case WAVE_FORMAT_IMA_ADPCM :
psf->sf.format = (SF_FORMAT_WAV | SF_FORMAT_IMA_ADPCM) ;
- *blockalign = wav_fmt.ima.blockalign ;
- *framesperblock = wav_fmt.ima.samplesperblock ;
+ *blockalign = wav_fmt->ima.blockalign ;
+ *framesperblock = wav_fmt->ima.samplesperblock ;
break ;
case WAVE_FORMAT_GSM610 :
@@ -675,6 +710,9 @@
default : return SFE_UNIMPLEMENTED ;
} ;
+ if (wpriv->fmt_is_broken)
+ wav_w64_analyze (psf) ;
+
/* Only set the format endian-ness if its non-standard big-endian. */
if (psf->endian == SF_ENDIAN_BIG)
psf->sf.format |= SF_ENDIAN_BIG ;
@@ -683,46 +721,10 @@
} /* wav_read_header */
static int
-wav_write_header (SF_PRIVATE *psf, int calc_length)
-{ sf_count_t current ;
- int fmt_size, k, subformat, add_fact_chunk = SF_FALSE ;
-
- current = psf_ftell (psf) ;
-
- if (calc_length)
- { psf->filelength = psf_get_filelen (psf) ;
-
- psf->datalength = psf->filelength - psf->dataoffset ;
+wav_write_fmt_chunk (SF_PRIVATE *psf)
+{ int subformat, fmt_size, add_fact_chunk = 0 ;
- if (psf->dataend)
- psf->datalength -= psf->filelength - psf->dataend ;
-
- if (psf->bytewidth > 0)
- psf->sf.frames = psf->datalength / (psf->bytewidth * psf->sf.channels) ;
- } ;
-
- /* Reset the current header length to zero. */
- psf->header [0] = 0 ;
- psf->headindex = 0 ;
- psf_fseek (psf, 0, SEEK_SET) ;
-
- /*
- ** RIFX signifies big-endian format for all header and data.
- ** To prevent lots of code copying here, we'll set the psf->rwf_endian flag
- ** once here, and never specify endian-ness for all other header operations.
- */
-
- /* RIFF/RIFX marker, length, WAVE and 'fmt ' markers. */
-
- if (psf->endian == SF_ENDIAN_LITTLE)
- psf_binheader_writef (psf, "etm8", RIFF_MARKER, (psf->filelength < 8) ? 8 : psf->filelength - 8) ;
- else
- psf_binheader_writef (psf, "Etm8", RIFX_MARKER, (psf->filelength < 8) ? 8 : psf->filelength - 8) ;
-
- /* WAVE and 'fmt ' markers. */
- psf_binheader_writef (psf, "mm", WAVE_MARKER, fmt_MARKER) ;
-
- subformat = psf->sf.format & SF_FORMAT_SUBMASK ;
+ subformat = SF_CODEC (psf->sf.format) ;
switch (subformat)
{ case SF_FORMAT_PCM_U8 :
@@ -873,110 +875,18 @@
if (add_fact_chunk)
psf_binheader_writef (psf, "tm48", fact_MARKER, 4, psf->sf.frames) ;
- if (psf->str_flags & SF_STR_LOCATE_START)
- wav_write_strings (psf, SF_STR_LOCATE_START) ;
-
- if (psf->peak_info != NULL && psf->peak_info->peak_loc == SF_PEAK_START)
- { psf_binheader_writef (psf, "m4", PEAK_MARKER, WAV_PEAK_CHUNK_SIZE (psf->sf.channels)) ;
- psf_binheader_writef (psf, "44", 1, time (NULL)) ;
- for (k = 0 ; k < psf->sf.channels ; k++)
- psf_binheader_writef (psf, "ft8", (float) psf->peak_info->peaks [k].value, psf->peak_info->peaks [k].position) ;
- } ;
-
- if (psf->broadcast_info != NULL)
- wav_write_bext_chunk (psf) ;
-
- if (psf->instrument != NULL)
- { int tmp ;
- double dtune = (double) (0x40000000) / 25.0 ;
-
- psf_binheader_writef (psf, "m4", smpl_MARKER, 9 * 4 + psf->instrument->loop_count * 6 * 4) ;
- psf_binheader_writef (psf, "44", 0, 0) ; /* Manufacturer zero is everyone */
- tmp = (int) (1.0e9 / psf->sf.samplerate) ; /* Sample period in nano seconds */
- psf_binheader_writef (psf, "44", tmp, psf->instrument->basenote) ;
- tmp = (unsigned int) (psf->instrument->detune * dtune + 0.5) ;
- psf_binheader_writef (psf, "4", tmp) ;
- psf_binheader_writef (psf, "44", 0, 0) ; /* SMTPE format */
- psf_binheader_writef (psf, "44", psf->instrument->loop_count, 0) ;
-
- for (tmp = 0 ; tmp < psf->instrument->loop_count ; tmp++)
- { int type ;
-
- type = psf->instrument->loops [tmp].mode ;
- type = (type == SF_LOOP_FORWARD ? 0 : type==SF_LOOP_BACKWARD ? 2 : type == SF_LOOP_ALTERNATING ? 1 : 32) ;
-
- psf_binheader_writef (psf, "44", tmp, type) ;
- psf_binheader_writef (psf, "44", psf->instrument->loops [tmp].start, psf->instrument->loops [tmp].end) ;
- psf_binheader_writef (psf, "44", 0, psf->instrument->loops [tmp].count) ;
- } ;
- } ;
-
- psf_binheader_writef (psf, "tm8", data_MARKER, psf->datalength) ;
- psf_fwrite (psf->header, psf->headindex, 1, psf) ;
- if (psf->error)
- return psf->error ;
-
- psf->dataoffset = psf->headindex ;
-
- if (current < psf->dataoffset)
- psf_fseek (psf, psf->dataoffset, SEEK_SET) ;
- else if (current > 0)
- psf_fseek (psf, current, SEEK_SET) ;
-
- return psf->error ;
-} /* wav_write_header */
-
-
+ return 0 ;
+} /* wav_write_fmt_chunk */
static int
-wavex_write_header (SF_PRIVATE *psf, int calc_length)
-{ sf_count_t current ;
- int fmt_size, k, subformat, add_fact_chunk = SF_FALSE ;
-
- current = psf_ftell (psf) ;
+wavex_write_fmt_chunk (SF_PRIVATE *psf)
+{ WAV_PRIVATE *wpriv ;
+ int subformat, fmt_size, add_fact_chunk = 0 ;
- if (calc_length)
- { psf->filelength = psf_get_filelen (psf) ;
-
- psf->datalength = psf->filelength - psf->dataoffset ;
-
- if (psf->dataend)
- psf->datalength -= psf->filelength - psf->dataend ;
-
- if (psf->bytewidth > 0)
- psf->sf.frames = psf->datalength / (psf->bytewidth * psf->sf.channels) ;
- } ;
+ if ((wpriv = psf->container_data) == NULL)
+ return SFE_INTERNAL ;
-
- /* Reset the current header length to zero. */
- psf->header [0] = 0 ;
- psf->headindex = 0 ;
- psf_fseek (psf, 0, SEEK_SET) ;
-
- /* RIFX signifies big-endian format for all header and data
- ** to prevent lots of code copying here, we'll set the psf->rwf_endian
- ** flag once here, and never specify endian-ness for all other header ops
- */
-
- /* RIFF marker, length, WAVE and 'fmt ' markers. */
-
- if (psf->endian == SF_ENDIAN_LITTLE)
- { if (psf->filelength < 8)
- psf_binheader_writef (psf, "tm8", RIFF_MARKER, 8) ;
- else
- psf_binheader_writef (psf, "tm8", RIFF_MARKER, psf->filelength - 8) ;
- }
- else
- { if (psf->filelength < 8)
- psf_binheader_writef (psf, "Etm8", RIFX_MARKER, 8) ;
- else
- psf_binheader_writef (psf, "Etm8", RIFX_MARKER, psf->filelength - 8) ;
- } ;
-
- /* WAVE and 'fmt ' markers. */
- psf_binheader_writef (psf, "mm", WAVE_MARKER, fmt_MARKER) ;
-
- subformat = psf->sf.format & SF_FORMAT_SUBMASK ;
+ subformat = SF_CODEC (psf->sf.format) ;
/* initial section (same for all, it appears) */
switch (subformat)
@@ -1003,37 +913,43 @@
/* wValidBitsPerSample, for our use same as bitwidth as we use it fully */
psf_binheader_writef (psf, "2", psf->bytewidth * 8) ;
- /*
- ** Ok some liberty is taken here to use the most commonly used channel masks
- ** instead of "no mapping". If you really want to use "no mapping" for 8 channels and less
- ** please don't use wavex. (otherwise we'll have to create a new SF_COMMAND)
+ /* For an Ambisonic file set the channel mask to zero.
+ ** Otherwise use a default based on the channel count.
*/
- switch (psf->sf.channels)
- { case 1 : /* center channel mono */
- psf_binheader_writef (psf, "4", 0x4) ;
- break ;
-
- case 2 : /* front left and right */
- psf_binheader_writef (psf, "4", 0x1 | 0x2) ;
- break ;
+ if (wpriv->wavex_ambisonic != SF_AMBISONIC_NONE)
+ psf_binheader_writef (psf, "4", 0) ;
+ else
+ { /*
+ ** Ok some liberty is taken here to use the most commonly used channel masks
+ ** instead of "no mapping". If you really want to use "no mapping" for 8 channels and less
+ ** please don't use wavex. (otherwise we'll have to create a new SF_COMMAND)
+ */
+ switch (psf->sf.channels)
+ { case 1 : /* center channel mono */
+ psf_binheader_writef (psf, "4", 0x4) ;
+ break ;
- case 4 : /* Quad */
- psf_binheader_writef (psf, "4", 0x1 | 0x2 | 0x10 | 0x20) ;
- break ;
+ case 2 : /* front left and right */
+ psf_binheader_writef (psf, "4", 0x1 | 0x2) ;
+ break ;
- case 6 : /* 5.1 */
- psf_binheader_writef (psf, "4", 0x1 | 0x2 | 0x4 | 0x8 | 0x10 | 0x20) ;
- break ;
+ case 4 : /* Quad */
+ psf_binheader_writef (psf, "4", 0x1 | 0x2 | 0x10 | 0x20) ;
+ break ;
- case 8 : /* 7.1 */
- psf_binheader_writef (psf, "4", 0x1 | 0x2 | 0x4 | 0x8 | 0x10 | 0x20 | 0x40 | 0x80) ;
- break ;
+ case 6 : /* 5.1 */
+ psf_binheader_writef (psf, "4", 0x1 | 0x2 | 0x4 | 0x8 | 0x10 | 0x20) ;
+ break ;
- default : /* 0 when in doubt , use direct out, ie NO mapping*/
- psf_binheader_writef (psf, "4", 0x0) ;
- break ;
- }
+ case 8 : /* 7.1 */
+ psf_binheader_writef (psf, "4", 0x1 | 0x2 | 0x4 | 0x8 | 0x10 | 0x20 | 0x40 | 0x80) ;
+ break ;
+ default : /* 0 when in doubt , use direct out, ie NO mapping*/
+ psf_binheader_writef (psf, "4", 0x0) ;
+ break ;
+ } ;
+ } ;
break ;
case SF_FORMAT_MS_ADPCM : /* Todo, GUID exists might have different header as per wav_write_header */
@@ -1048,12 +964,14 @@
case SF_FORMAT_PCM_16 :
case SF_FORMAT_PCM_24 :
case SF_FORMAT_PCM_32 :
- wavex_write_guid (psf, &MSGUID_SUBTYPE_PCM) ;
+ wavex_write_guid (psf, wpriv->wavex_ambisonic == SF_AMBISONIC_NONE ?
+ &MSGUID_SUBTYPE_PCM : &MSGUID_SUBTYPE_AMBISONIC_B_FORMAT_PCM) ;
break ;
case SF_FORMAT_FLOAT :
case SF_FORMAT_DOUBLE :
- wavex_write_guid (psf, &MSGUID_SUBTYPE_IEEE_FLOAT) ;
+ wavex_write_guid (psf, wpriv->wavex_ambisonic == SF_AMBISONIC_NONE ?
+ &MSGUID_SUBTYPE_IEEE_FLOAT : &MSGUID_SUBTYPE_AMBISONIC_B_FORMAT_IEEE_FLOAT) ;
add_fact_chunk = SF_TRUE ;
break ;
@@ -1067,7 +985,14 @@
add_fact_chunk = SF_TRUE ;
break ;
+#if 0
+ /* This is dead code due to return in previous switch statement. */
case SF_FORMAT_MS_ADPCM : /* todo, GUID exists */
+ wavex_write_guid (psf, &MSGUID_SUBTYPE_MS_ADPCM) ;
+ add_fact_chunk = SF_TRUE ;
+ break ;
+ return SFE_UNIMPLEMENTED ;
+#endif
default : return SFE_UNIMPLEMENTED ;
} ;
@@ -1075,6 +1000,70 @@
if (add_fact_chunk)
psf_binheader_writef (psf, "tm48", fact_MARKER, 4, psf->sf.frames) ;
+ return 0 ;
+} /* wavex_write_fmt_chunk */
+
+
+static int
+wav_write_header (SF_PRIVATE *psf, int calc_length)
+{ sf_count_t current ;
+ int k, error, has_data = SF_FALSE ;
+
+ current = psf_ftell (psf) ;
+
+ if (current > psf->dataoffset)
+ has_data = SF_TRUE ;
+
+ if (calc_length)
+ { psf->filelength = psf_get_filelen (psf) ;
+
+ psf->datalength = psf->filelength - psf->dataoffset ;
+
+ if (psf->dataend)
+ psf->datalength -= psf->filelength - psf->dataend ;
+
+ if (psf->bytewidth > 0)
+ psf->sf.frames = psf->datalength / (psf->bytewidth * psf->sf.channels) ;
+ } ;
+
+ /* Reset the current header length to zero. */
+ psf->header [0] = 0 ;
+ psf->headindex = 0 ;
+ psf_fseek (psf, 0, SEEK_SET) ;
+
+ /*
+ ** RIFX signifies big-endian format for all header and data.
+ ** To prevent lots of code copying here, we'll set the psf->rwf_endian flag
+ ** once here, and never specify endian-ness for all other header operations.
+ */
+
+ /* RIFF/RIFX marker, length, WAVE and 'fmt ' markers. */
+
+ if (psf->endian == SF_ENDIAN_LITTLE)
+ psf_binheader_writef (psf, "etm8", RIFF_MARKER, (psf->filelength < 8) ? 8 : psf->filelength - 8) ;
+ else
+ psf_binheader_writef (psf, "Etm8", RIFX_MARKER, (psf->filelength < 8) ? 8 : psf->filelength - 8) ;
+
+ /* WAVE and 'fmt ' markers. */
+ psf_binheader_writef (psf, "mm", WAVE_MARKER, fmt_MARKER) ;
+
+ /* Write the 'fmt ' chunk. */
+ switch (SF_CONTAINER (psf->sf.format))
+ { case SF_FORMAT_WAV :
+ if ((error = wav_write_fmt_chunk (psf)) != 0)
+ return error ;
+ break ;
+
+ case SF_FORMAT_WAVEX :
+ if ((error = wavex_write_fmt_chunk (psf)) != 0)
+ return error ;
+ break ;
+
+ default :
+ return SFE_UNIMPLEMENTED ;
+ } ;
+
+ /* The LIST/INFO chunk. */
if (psf->str_flags & SF_STR_LOCATE_START)
wav_write_strings (psf, SF_STR_LOCATE_START) ;
@@ -1085,21 +1074,59 @@
psf_binheader_writef (psf, "ft8", (float) psf->peak_info->peaks [k].value, psf->peak_info->peaks [k].position) ;
} ;
+ if (psf->broadcast_var != NULL)
+ wav_write_bext_chunk (psf) ;
+
+ if (psf->instrument != NULL)
+ { int tmp ;
+ double dtune = (double) (0x40000000) / 25.0 ;
+
+ psf_binheader_writef (psf, "m4", smpl_MARKER, 9 * 4 + psf->instrument->loop_count * 6 * 4) ;
+ psf_binheader_writef (psf, "44", 0, 0) ; /* Manufacturer zero is everyone */
+ tmp = (int) (1.0e9 / psf->sf.samplerate) ; /* Sample period in nano seconds */
+ psf_binheader_writef (psf, "44", tmp, psf->instrument->basenote) ;
+ tmp = (unsigned int) (psf->instrument->detune * dtune + 0.5) ;
+ psf_binheader_writef (psf, "4", tmp) ;
+ psf_binheader_writef (psf, "44", 0, 0) ; /* SMTPE format */
+ psf_binheader_writef (psf, "44", psf->instrument->loop_count, 0) ;
+
+ for (tmp = 0 ; tmp < psf->instrument->loop_count ; tmp++)
+ { int type ;
+
+ type = psf->instrument->loops [tmp].mode ;
+ type = (type == SF_LOOP_FORWARD ? 0 : type==SF_LOOP_BACKWARD ? 2 : type == SF_LOOP_ALTERNATING ? 1 : 32) ;
+
+ psf_binheader_writef (psf, "44", tmp, type) ;
+ psf_binheader_writef (psf, "44", psf->instrument->loops [tmp].start, psf->instrument->loops [tmp].end) ;
+ psf_binheader_writef (psf, "44", 0, psf->instrument->loops [tmp].count) ;
+ } ;
+ } ;
+
+ if (psf->headindex + 16 < psf->dataoffset)
+ { /* Add PAD data if necessary. */
+ k = psf->dataoffset - (psf->headindex + 16) ;
+ psf_binheader_writef (psf, "m4z", PAD_MARKER, k, make_size_t (k)) ;
+ } ;
+
psf_binheader_writef (psf, "tm8", data_MARKER, psf->datalength) ;
psf_fwrite (psf->header, psf->headindex, 1, psf) ;
if (psf->error)
return psf->error ;
+ if (has_data && psf->dataoffset != psf->headindex)
+ { psf_log_printf (psf, "Oooops : has_data && psf->dataoffset != psf->headindex\n") ;
+ return psf->error = SFE_INTERNAL ;
+ } ;
+
psf->dataoffset = psf->headindex ;
- if (current < psf->dataoffset)
+ if (! has_data)
psf_fseek (psf, psf->dataoffset, SEEK_SET) ;
else if (current > 0)
psf_fseek (psf, current, SEEK_SET) ;
return psf->error ;
-} /* wavex_write_header */
-
+} /* wav_write_header */
static int
@@ -1110,7 +1137,10 @@
psf->header [0] = 0 ;
psf->headindex = 0 ;
- psf->dataend = psf_fseek (psf, 0, SEEK_END) ;
+ if (psf->dataend > 0)
+ psf_fseek (psf, psf->dataend, SEEK_SET) ;
+ else
+ psf->dataend = psf_fseek (psf, 0, SEEK_END) ;
/* Add a PEAK chunk if requested. */
if (psf->peak_info != NULL && psf->peak_info->peak_loc == SF_PEAK_END)
@@ -1134,6 +1164,9 @@
wav_write_strings (SF_PRIVATE *psf, int location)
{ int k, prev_head_index, saved_head_index ;
+ if (psf_location_string_count (psf, location) == 0)
+ return ;
+
prev_head_index = psf->headindex + 4 ;
psf_binheader_writef (psf, "m4m", LIST_MARKER, 0xBADBAD, INFO_MARKER) ;
@@ -1141,7 +1174,7 @@
for (k = 0 ; k < SF_MAX_STRINGS ; k++)
{ if (psf->strings [k].type == 0)
break ;
- if (psf->strings [k].flags != location)
+ if (psf->strings [k].type < 0 || psf->strings [k].flags != location)
continue ;
switch (psf->strings [k].type)
@@ -1168,6 +1201,9 @@
case SF_STR_DATE :
psf_binheader_writef (psf, "ms", ICRD_MARKER, psf->strings [k].str) ;
break ;
+
+ default :
+ break ;
} ;
} ;
@@ -1184,6 +1220,20 @@
if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR)
{ wav_write_tailer (psf) ;
+ if (psf->mode == SFM_RDWR)
+ { sf_count_t current = psf_ftell (psf) ;
+
+ /*
+ ** If the mode is RDWR and the current position is less than the
+ ** filelength, truncate the file.
+ */
+
+ if (current < psf->filelength)
+ { psf_ftruncate (psf, current) ;
+ psf->filelength = current ;
+ } ;
+ } ;
+
psf->write_header (psf, SF_TRUE) ;
} ;
@@ -1191,16 +1241,30 @@
} /* wav_close */
static int
-wav_command (SF_PRIVATE *psf, int command, void *data, int datasize)
-{
- /* Avoid compiler warnings. */
- psf = psf ;
- data = data ;
- datasize = datasize ;
+wav_command (SF_PRIVATE *psf, int command, void * UNUSED (data), int datasize)
+{ WAV_PRIVATE *wpriv ;
+
+ if ((wpriv = psf->container_data) == NULL)
+ return SFE_INTERNAL ;
switch (command)
- { default : break ;
- } ;
+ { case SFC_WAVEX_SET_AMBISONIC :
+ if ((SF_CONTAINER (psf->sf.format)) == SF_FORMAT_WAVEX)
+ { if (datasize == SF_AMBISONIC_NONE)
+ wpriv->wavex_ambisonic = SF_AMBISONIC_NONE ;
+ else if (datasize == SF_AMBISONIC_B_FORMAT)
+ wpriv->wavex_ambisonic = SF_AMBISONIC_B_FORMAT ;
+ else
+ return 0 ;
+ } ;
+ return wpriv->wavex_ambisonic ;
+
+ case SFC_WAVEX_GET_AMBISONIC :
+ return wpriv->wavex_ambisonic ;
+
+ default :
+ break ;
+ } ;
return 0 ;
} /* wav_command */
@@ -1209,7 +1273,7 @@
wav_subchunk_parse (SF_PRIVATE *psf, int chunk)
{ sf_count_t current_pos ;
char *cptr ;
- int dword, bytesread, length ;
+ unsigned dword, bytesread, length ;
current_pos = psf_fseek (psf, 0, SEEK_CUR) ;
@@ -1246,7 +1310,7 @@
psf_log_printf (psf, " %M\n", chunk) ;
break ;
- case data_MARKER:
+ case data_MARKER :
psf_log_printf (psf, " %M inside a LIST block??? Backing out.\n", chunk) ;
/* Jump back four bytes and return to caller. */
psf_binheader_readf (psf, "j", -4) ;
@@ -1266,7 +1330,7 @@
case ISRC_MARKER :
bytesread += psf_binheader_readf (psf, "4", &dword) ;
dword += (dword & 1) ;
- if (dword < 0 || dword > SIGNED_SIZEOF (psf->u.cbuf))
+ if (dword >= SIGNED_SIZEOF (psf->u.cbuf))
{ psf_log_printf (psf, " *** %M : %d (too big)\n", chunk, dword) ;
psf_binheader_readf (psf, "j", dword) ;
break ;
@@ -1275,7 +1339,7 @@
cptr = psf->u.cbuf ;
psf_binheader_readf (psf, "b", cptr, dword) ;
bytesread += dword ;
- cptr [dword - 1] = 0 ;
+ cptr [dword] = 0 ;
psf_log_printf (psf, " %M : %s\n", chunk, cptr) ;
break ;
@@ -1285,7 +1349,7 @@
bytesread += psf_binheader_readf (psf, "44", &dword, &mark_id) ;
dword -= 4 ;
dword += (dword & 1) ;
- if (dword < 1 || dword > SIGNED_SIZEOF (psf->u.cbuf))
+ if (dword < 1 || dword >= SIGNED_SIZEOF (psf->u.cbuf))
{ psf_log_printf (psf, " *** %M : %d (too big)\n", chunk, dword) ;
psf_binheader_readf (psf, "j", dword) ;
break ;
@@ -1294,7 +1358,7 @@
cptr = psf->u.cbuf ;
psf_binheader_readf (psf, "b", cptr, dword) ;
bytesread += dword ;
- cptr [dword - 1] = 0 ;
+ cptr [dword] = 0 ;
psf_log_printf (psf, " %M : %d : %s\n", chunk, mark_id, cptr) ;
} ;
break ;
@@ -1310,6 +1374,22 @@
psf_log_printf (psf, " %M : %d\n", chunk, dword) ;
break ;
+ case exif_MARKER :
+ psf_log_printf (psf, " %M\n", chunk) ;
+ bytesread += exif_subchunk_parse (psf, length - bytesread) ;
+ break ;
+
+ case 0 :
+ /*
+ ** Four zero bytes where a marker was expected. Assume this means
+ ** the rest of the chunk is garbage.
+ */
+ psf_log_printf (psf, " *** Found weird-ass zero marker. Jumping to end of chunk.\n") ;
+ if (bytesread < length)
+ bytesread += psf_binheader_readf (psf, "j", length - bytesread + 4) ;
+ psf_log_printf (psf, " *** Offset is now : 0x%X\n", psf_fseek (psf, 0, SEEK_CUR)) ;
+ return 0 ;
+
default :
psf_binheader_readf (psf, "4", &dword) ;
bytesread += sizeof (dword) ;
@@ -1374,7 +1454,7 @@
bytesread += psf_binheader_readf (psf, "4", &dword) ;
if (dword != 0)
- { LSF_SNPRINTF (psf->u.cbuf, sizeof (psf->u.cbuf), "%f",
+ { snprintf (psf->u.cbuf, sizeof (psf->u.cbuf), "%f",
(1.0 * 0x80000000) / ((unsigned int) dword)) ;
psf_log_printf (psf, " Pitch Fract. : %s\n", psf->u.cbuf) ;
}
@@ -1385,7 +1465,7 @@
psf_log_printf (psf, " SMPTE Format : %u\n", dword) ;
bytesread += psf_binheader_readf (psf, "4", &dword) ;
- LSF_SNPRINTF (psf->u.cbuf, sizeof (psf->u.cbuf), "%02d:%02d:%02d %02d",
+ snprintf (psf->u.cbuf, sizeof (psf->u.cbuf), "%02d:%02d:%02d %02d",
(dword >> 24) & 0x7F, (dword >> 16) & 0x7F, (dword >> 8) & 0x7F, dword & 0x7F) ;
psf_log_printf (psf, " SMPTE Offset : %s\n", psf->u.cbuf) ;
@@ -1523,7 +1603,7 @@
bytesread += psf_binheader_readf (psf, "422f", &flags, &rootnote, &q1, &q2) ;
- LSF_SNPRINTF (psf->u.cbuf, sizeof (psf->u.cbuf), "%f", q2) ;
+ snprintf (psf->u.cbuf, sizeof (psf->u.cbuf), "%f", q2) ;
psf_log_printf (psf, " Flags : 0x%04x (%s,%s,%s,%s,%s)\n", flags,
(flags & 0x01) ? "OneShot" : "Loop",
@@ -1536,7 +1616,7 @@
rootnote, q1, psf->u.cbuf) ;
bytesread += psf_binheader_readf (psf, "422f", &beats, &meter_denom, &meter_numer, &tempo) ;
- LSF_SNPRINTF (psf->u.cbuf, sizeof (psf->u.cbuf), "%f", tempo) ;
+ snprintf (psf->u.cbuf, sizeof (psf->u.cbuf), "%f", tempo) ;
psf_log_printf (psf, " Beats : %d\n Meter : %d/%d\n Tempo : %s\n",
beats, meter_numer, meter_denom, psf->u.cbuf) ;
@@ -1555,43 +1635,53 @@
return 0 ;
} /* wav_read_acid_chunk */
-int
+static int
wav_read_bext_chunk (SF_PRIVATE *psf, unsigned int chunksize)
{
SF_BROADCAST_INFO* b ;
+ unsigned int bytes = 0 ;
+
+ if (chunksize < WAV_BEXT_MIN_CHUNK_SIZE)
+ { psf_log_printf (psf, "bext : %u (should be >= %d)\n", chunksize, WAV_BEXT_MIN_CHUNK_SIZE) ;
+ psf_binheader_readf (psf, "j", chunksize) ;
+ return 0 ;
+ } ;
+
+ if (chunksize > WAV_BEXT_MAX_CHUNK_SIZE)
+ { psf_log_printf (psf, "bext : %u (should be < %d)\n", chunksize, WAV_BEXT_MAX_CHUNK_SIZE) ;
+ psf_binheader_readf (psf, "j", chunksize) ;
+ return 0 ;
+ } ;
+
+ psf_log_printf (psf, "bext : %u\n", chunksize) ;
- if ((psf->broadcast_info = calloc (1, sizeof (SF_BROADCAST_INFO))) == NULL)
+ if ((psf->broadcast_var = broadcast_var_alloc (chunksize + 128)) == NULL)
{ psf->error = SFE_MALLOC_FAILED ;
- return -1 ;
+ return psf->error ;
} ;
- b = psf->broadcast_info ;
+ b = & psf->broadcast_var->binfo ;
- psf_binheader_readf (psf, "b", b->description, sizeof (b->description)) ;
- psf_binheader_readf (psf, "b", b->originator, sizeof (b->originator)) ;
- psf_binheader_readf (psf, "b", b->originator_reference, sizeof (b->originator_reference)) ;
- psf_binheader_readf (psf, "b", b->origination_date, sizeof (b->origination_date)) ;
- psf_binheader_readf (psf, "b", b->origination_time, sizeof (b->origination_time)) ;
- psf_binheader_readf (psf, "442", &b->time_reference_low, &b->time_reference_high, &b->version) ;
- psf_binheader_readf (psf, "bj", &b->umid, sizeof (b->umid), 190) ;
+ bytes += psf_binheader_readf (psf, "b", b->description, sizeof (b->description)) ;
+ bytes += psf_binheader_readf (psf, "b", b->originator, sizeof (b->originator)) ;
+ bytes += psf_binheader_readf (psf, "b", b->originator_reference, sizeof (b->originator_reference)) ;
+ bytes += psf_binheader_readf (psf, "b", b->origination_date, sizeof (b->origination_date)) ;
+ bytes += psf_binheader_readf (psf, "b", b->origination_time, sizeof (b->origination_time)) ;
+ bytes += psf_binheader_readf (psf, "442", &b->time_reference_low, &b->time_reference_high, &b->version) ;
+ bytes += psf_binheader_readf (psf, "bj", &b->umid, sizeof (b->umid), 190) ;
- if (chunksize > WAV_BEXT_CHUNK_SIZE)
+ if (chunksize > WAV_BEXT_MIN_CHUNK_SIZE)
{ /* File has coding history data. */
- b->coding_history_size = chunksize - WAV_BEXT_CHUNK_SIZE ;
-
- if (b->coding_history_size > SIGNED_SIZEOF (b->coding_history))
- { free (psf->broadcast_info) ;
- psf->broadcast_info = NULL ;
- psf->error = SFE_MALLOC_FAILED ;
- return -1 ;
- } ;
+ b->coding_history_size = chunksize - WAV_BEXT_MIN_CHUNK_SIZE ;
/* We do not parse the coding history */
- psf_binheader_readf (psf, "b", b->coding_history, b->coding_history_size) ;
- b->coding_history [sizeof (b->coding_history) - 1] = 0 ;
+ bytes += psf_binheader_readf (psf, "b", b->coding_history, b->coding_history_size) ;
} ;
+ if (bytes < chunksize)
+ psf_binheader_readf (psf, "j", chunksize - bytes) ;
+
return 0 ;
} /* wav_read_bext_chunk */
@@ -1599,10 +1689,12 @@
wav_write_bext_chunk (SF_PRIVATE *psf)
{ SF_BROADCAST_INFO *b ;
- if ((b = psf->broadcast_info) == NULL)
+ if (psf->broadcast_var == NULL)
return -1 ;
- psf_binheader_writef (psf, "m4", bext_MARKER, WAV_BEXT_CHUNK_SIZE + b->coding_history_size) ;
+ b = & psf->broadcast_var->binfo ;
+
+ psf_binheader_writef (psf, "m4", bext_MARKER, WAV_BEXT_MIN_CHUNK_SIZE + b->coding_history_size) ;
/*
** Note that it is very important the the field widths of the SF_BROADCAST_INFO
@@ -1624,10 +1716,85 @@
return 0 ;
} /* wav_write_bext_chunk */
+static int
+exif_fill_and_sink (SF_PRIVATE *psf, char* buf, size_t bufsz, size_t toread)
+{
+ size_t bytesread = 0 ;
+
+ buf [0] = 0 ;
+ bufsz -= 1 ;
+ if (toread < bufsz)
+ bufsz = toread ;
+ bytesread = psf_binheader_readf (psf, "b", buf, bufsz) ;
+ buf [bufsz] = 0 ;
+
+ if (bytesread == bufsz && toread > bufsz)
+ bytesread += psf_binheader_readf (psf, "j", toread - bufsz) ;
+
+ return bytesread ;
+} /* exif_fill_and_sink */
+
/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: 9c551689-a1d8-4905-9f56-26a204374f18
+** Exif specification for audio files, at JEITA CP-3451 Exif 2.2 section 5
+** (Exif Audio File Specification) http://www.exif.org/Exif2-2.PDF
*/
+static int
+exif_subchunk_parse (SF_PRIVATE *psf, unsigned int length)
+{ unsigned marker, dword, vmajor = -1, vminor = -1, bytesread = 0 ;
+ char buf [4096] ;
+
+ while (bytesread < length)
+ {
+ bytesread += psf_binheader_readf (psf, "m", &marker) ;
+
+ switch (marker)
+ {
+ case 0 : /* camera padding? */
+ break ;
+
+ case ever_MARKER :
+ bytesread += psf_binheader_readf (psf, "j4", 4, &dword) ;
+ vmajor = 10 * (((dword >> 24) & 0xff) - '0') + (((dword >> 16) & 0xff) - '0') ;
+ vminor = 10 * (((dword >> 8) & 0xff) - '0') + ((dword & 0xff) - '0') ;
+ psf_log_printf (psf, " EXIF Version : %u.%02u\n", vmajor, vminor) ;
+ break ;
+
+ case emnt_MARKER : /* design information: null-terminated string */
+ case emdl_MARKER : /* model name ; null-terminated string */
+ case ecor_MARKER : /* manufacturer: null-terminated string */
+ case etim_MARKER : /* creation time: null-terminated string in the format "hour:minute:second.subsecond" */
+ case erel_MARKER : /* relation info: null-terminated string (filename) */
+ case eucm_MARKER : /* user comment: 4-byte size follows, then possibly unicode data */
+ psf_binheader_readf (psf, "4", &dword) ;
+ bytesread += sizeof (dword) ;
+ dword += (dword & 1) ;
+
+ if (dword >= sizeof (buf))
+ { psf_log_printf (psf, "*** Marker '%M' is too big %u\n\n", marker, dword) ;
+ return bytesread ;
+ } ;
+
+ bytesread += exif_fill_and_sink (psf, buf, sizeof (buf), dword) ;
+
+ /* BAD - don't know what's going on here -- maybe a bug in the camera */
+ /* field should be NULL-terminated but there's no room for it with the reported number */
+ /* example output: emdl : 8 (EX-Z1050) */
+ if (marker == emdl_MARKER && dword == strlen (buf) /* should be >= strlen+1*/)
+ { psf_log_printf (psf, " *** field size too small for string (sinking 2 bytes)\n") ;
+ bytesread += psf_binheader_readf (psf, "j", 2) ;
+ } ;
+
+ psf_log_printf (psf, " %M : %d (%s)\n", marker, dword, buf) ;
+ if (dword > length)
+ return bytesread ;
+ break ;
+
+ default :
+ psf_log_printf (psf, " *** %M (%d): -- ignored --\n", marker, marker) ;
+ break ;
+ } ;
+ } ;
+
+ return bytesread ;
+} /* exif_subchunk_parse */
+
Modified: freeswitch/trunk/libs/libsndfile/src/wav_w64.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/src/wav_w64.c (original)
+++ freeswitch/trunk/libs/libsndfile/src/wav_w64.c Thu May 21 16:09:30 2009
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 1999-2005 Erik de Castro Lopo <erikd at mega-nerd.com>
+** Copyright (C) 1999-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
** Copyright (C) 2004-2005 David Viens <davidv at plogue.com>
**
** This program is free software; you can redistribute it and/or modify
@@ -56,11 +56,11 @@
*/
static const EXT_SUBFORMAT MSGUID_SUBTYPE_AMBISONIC_B_FORMAT_PCM =
-{ 0x00000001, 0x0721, 0x11d3, { 0x86, 0x44, 0xC8, 0xC1, 0xCA, 0x00, 0x00, 0x00 }
+{ 0x00000001, 0x0721, 0x11d3, { 0x86, 0x44, 0xc8, 0xc1, 0xca, 0x00, 0x00, 0x00 }
} ;
static const EXT_SUBFORMAT MSGUID_SUBTYPE_AMBISONIC_B_FORMAT_IEEE_FLOAT =
-{ 0x00000003, 0x0721, 0x11d3, { 0x86, 0x44, 0xC8, 0xC1, 0xCA, 0x00, 0x00, 0x00 }
+{ 0x00000003, 0x0721, 0x11d3, { 0x86, 0x44, 0xc8, 0xc1, 0xca, 0x00, 0x00, 0x00 }
} ;
@@ -68,7 +68,7 @@
/* maybe interesting one day to read the following through sf_read_raw */
/* http://www.bath.ac.uk/~masrwd/pvocex/pvocex.html */
static const EXT_SUBFORMAT MSGUID_SUBTYPE_PVOCEX =
-{ 0x8312B9C2, 0x2E6E, 0x11d4, { 0xA8, 0x24, 0xDE, 0x5B, 0x96, 0xC3, 0xAB, 0x21 }
+{ 0x8312b9c2, 0x2e6e, 0x11d4, { 0xa8, 0x24, 0xde, 0x5b, 0x96, 0xc3, 0xab, 0x21 }
} ;
#endif
@@ -77,19 +77,25 @@
*/
static int
-wavex_write_guid_equal (const EXT_SUBFORMAT * first, const EXT_SUBFORMAT * second)
+wavex_guid_equal (const EXT_SUBFORMAT * first, const EXT_SUBFORMAT * second)
{ return !memcmp (first, second, sizeof (EXT_SUBFORMAT)) ;
-} /* wavex_write_guid_equal */
+} /* wavex_guid_equal */
int
-wav_w64_read_fmt_chunk (SF_PRIVATE *psf, WAV_FMT *wav_fmt, int structsize)
-{ int bytesread, k, bytespersec = 0 ;
+wav_w64_read_fmt_chunk (SF_PRIVATE *psf, int fmtsize)
+{ WAV_PRIVATE * wpriv ;
+ WAV_FMT *wav_fmt ;
+ int bytesread, k, bytespersec = 0 ;
+
+ if ((wpriv = psf->container_data) == NULL)
+ return SFE_INTERNAL ;
+ wav_fmt = &wpriv->wav_fmt ;
memset (wav_fmt, 0, sizeof (WAV_FMT)) ;
- if (structsize < 16)
+ if (fmtsize < 16)
return SFE_WAV_FMT_SHORT ;
/* assume psf->rwf_endian is already properly set */
@@ -105,14 +111,23 @@
psf_log_printf (psf, " Sample Rate : %d\n", wav_fmt->min.samplerate) ;
psf_log_printf (psf, " Block Align : %d\n", wav_fmt->min.blockalign) ;
+ if (wav_fmt->min.blockalign == 0)
+ { psf_log_printf (psf, "*** Error : wav_fmt->min.blockalign should not be zero.\n") ;
+ return SFE_INTERNAL ;
+ } ;
+
if (wav_fmt->format == WAVE_FORMAT_PCM && wav_fmt->min.bitwidth == 24 &&
wav_fmt->min.blockalign == 4 * wav_fmt->min.channels)
- {
- psf_log_printf (psf, "\nInvalid file generated by Syntrillium's Cooledit!\n"
- "Treating as WAVE_FORMAT_IEEE_FLOAT 32 bit floating point file.\n\n") ;
- psf_log_printf (psf, " Bit Width : 24 (should be 32)\n") ;
- wav_fmt->min.bitwidth = 32 ;
- wav_fmt->format = WAVE_FORMAT_IEEE_FLOAT ;
+ { psf_log_printf (psf, " Bit Width : 24\n") ;
+
+ psf_log_printf (psf, "\n"
+ " Ambiguous information in 'fmt ' chunk. Possibile file types:\n"
+ " 0) Invalid IEEE float file generated by Syntrillium's Cooledit!\n"
+ " 1) File generated by ALSA's arecord containing 24 bit samples in 32 bit containers.\n"
+ " 2) 24 bit file with incorrect Block Align value.\n"
+ "\n") ;
+
+ wpriv->fmt_is_broken = 1 ;
}
else if (wav_fmt->min.bitwidth == 0)
{ switch (wav_fmt->format)
@@ -159,7 +174,7 @@
psf_log_printf (psf, " Bytes/sec : %d\n", wav_fmt->min.bytespersec) ;
psf->bytewidth = 1 ;
- if (structsize >= 18)
+ if (fmtsize >= 18)
{ bytesread += psf_binheader_readf (psf, "2", &(wav_fmt->size20.extrabytes)) ;
psf_log_printf (psf, " Extra Bytes : %d\n", wav_fmt->size20.extrabytes) ;
} ;
@@ -207,9 +222,9 @@
psf->bytewidth = 2 ;
psf_log_printf (psf, " Extra Bytes : %d\n", wav_fmt->msadpcm.extrabytes) ;
psf_log_printf (psf, " Samples/Block : %d\n", wav_fmt->msadpcm.samplesperblock) ;
- if (wav_fmt->msadpcm.numcoeffs > SIGNED_SIZEOF (MS_ADPCM_WAV_FMT) / SIGNED_SIZEOF (int))
- { psf_log_printf (psf, " No. of Coeffs : %d ****\n", wav_fmt->msadpcm.numcoeffs) ;
- wav_fmt->msadpcm.numcoeffs = SIGNED_SIZEOF (MS_ADPCM_WAV_FMT) / SIGNED_SIZEOF (int) ;
+ if (wav_fmt->msadpcm.numcoeffs > ARRAY_LEN (wav_fmt->msadpcm.coeffs))
+ { psf_log_printf (psf, " No. of Coeffs : %d (should be <= %d)\n", wav_fmt->msadpcm.numcoeffs, ARRAY_LEN (wav_fmt->msadpcm.coeffs)) ;
+ wav_fmt->msadpcm.numcoeffs = ARRAY_LEN (wav_fmt->msadpcm.coeffs) ;
}
else
psf_log_printf (psf, " No. of Coeffs : %d\n", wav_fmt->msadpcm.numcoeffs) ;
@@ -218,7 +233,7 @@
for (k = 0 ; k < wav_fmt->msadpcm.numcoeffs ; k++)
{ bytesread +=
psf_binheader_readf (psf, "22", &(wav_fmt->msadpcm.coeffs [k].coeff1), &(wav_fmt->msadpcm.coeffs [k].coeff2)) ;
- LSF_SNPRINTF (psf->u.cbuf, sizeof (psf->u.cbuf), " %2d %7d %7d\n", k, wav_fmt->msadpcm.coeffs [k].coeff1, wav_fmt->msadpcm.coeffs [k].coeff2) ;
+ snprintf (psf->u.cbuf, sizeof (psf->u.cbuf), " %2d %7d %7d\n", k, wav_fmt->msadpcm.coeffs [k].coeff1, wav_fmt->msadpcm.coeffs [k].coeff2) ;
psf_log_printf (psf, psf->u.cbuf) ;
} ;
break ;
@@ -275,35 +290,44 @@
psf->bytewidth = BITWIDTH2BYTES (wav_fmt->ext.bitwidth) ;
/* Compare GUIDs for known ones. */
- if (wavex_write_guid_equal (&wav_fmt->ext.esf, &MSGUID_SUBTYPE_PCM)
- || wavex_write_guid_equal (&wav_fmt->ext.esf, &MSGUID_SUBTYPE_AMBISONIC_B_FORMAT_PCM))
+ if (wavex_guid_equal (&wav_fmt->ext.esf, &MSGUID_SUBTYPE_PCM))
{ psf->sf.format = SF_FORMAT_WAVEX | u_bitwidth_to_subformat (psf->bytewidth * 8) ;
psf_log_printf (psf, " format : pcm\n") ;
}
- else if (wavex_write_guid_equal (&wav_fmt->ext.esf, &MSGUID_SUBTYPE_MS_ADPCM))
+ else if (wavex_guid_equal (&wav_fmt->ext.esf, &MSGUID_SUBTYPE_MS_ADPCM))
{ psf->sf.format = (SF_FORMAT_WAVEX | SF_FORMAT_MS_ADPCM) ;
psf_log_printf (psf, " format : ms adpcm\n") ;
}
- else if (wavex_write_guid_equal (&wav_fmt->ext.esf, &MSGUID_SUBTYPE_IEEE_FLOAT)
- || wavex_write_guid_equal (&wav_fmt->ext.esf, &MSGUID_SUBTYPE_AMBISONIC_B_FORMAT_PCM))
+ else if (wavex_guid_equal (&wav_fmt->ext.esf, &MSGUID_SUBTYPE_IEEE_FLOAT))
{ psf->sf.format = SF_FORMAT_WAVEX | ((psf->bytewidth == 8) ? SF_FORMAT_DOUBLE : SF_FORMAT_FLOAT) ;
psf_log_printf (psf, " format : IEEE float\n") ;
}
- else if (wavex_write_guid_equal (&wav_fmt->ext.esf, &MSGUID_SUBTYPE_ALAW))
+ else if (wavex_guid_equal (&wav_fmt->ext.esf, &MSGUID_SUBTYPE_ALAW))
{ psf->sf.format = (SF_FORMAT_WAVEX | SF_FORMAT_ALAW) ;
psf_log_printf (psf, " format : A-law\n") ;
}
- else if (wavex_write_guid_equal (&wav_fmt->ext.esf, &MSGUID_SUBTYPE_MULAW))
+ else if (wavex_guid_equal (&wav_fmt->ext.esf, &MSGUID_SUBTYPE_MULAW))
{ psf->sf.format = (SF_FORMAT_WAVEX | SF_FORMAT_ULAW) ;
psf_log_printf (psf, " format : u-law\n") ;
}
+ else if (wavex_guid_equal (&wav_fmt->ext.esf, &MSGUID_SUBTYPE_AMBISONIC_B_FORMAT_PCM))
+ { psf->sf.format = SF_FORMAT_WAVEX | u_bitwidth_to_subformat (psf->bytewidth * 8) ;
+ psf_log_printf (psf, " format : pcm (Ambisonic B)\n") ;
+ wpriv->wavex_ambisonic = SF_AMBISONIC_B_FORMAT ;
+ }
+ else if (wavex_guid_equal (&wav_fmt->ext.esf, &MSGUID_SUBTYPE_AMBISONIC_B_FORMAT_IEEE_FLOAT))
+ { psf->sf.format = SF_FORMAT_WAVEX | ((psf->bytewidth == 8) ? SF_FORMAT_DOUBLE : SF_FORMAT_FLOAT) ;
+ psf_log_printf (psf, " format : IEEE float (Ambisonic B)\n") ;
+ wpriv->wavex_ambisonic = SF_AMBISONIC_B_FORMAT ;
+ }
else
return SFE_UNIMPLEMENTED ;
+
break ;
case WAVE_FORMAT_G721_ADPCM :
psf_log_printf (psf, " Bytes/sec : %d\n", wav_fmt->g72x.bytespersec) ;
- if (structsize >= 20)
+ if (fmtsize >= 20)
{ bytesread += psf_binheader_readf (psf, "22", &(wav_fmt->g72x.extrabytes), &(wav_fmt->g72x.auxblocksize)) ;
if (wav_fmt->g72x.extrabytes == 0)
psf_log_printf (psf, " Extra Bytes : %d (should be 2)\n", wav_fmt->g72x.extrabytes) ;
@@ -311,7 +335,7 @@
psf_log_printf (psf, " Extra Bytes : %d\n", wav_fmt->g72x.extrabytes) ;
psf_log_printf (psf, " Aux Blk Size : %d\n", wav_fmt->g72x.auxblocksize) ;
}
- else if (structsize == 18)
+ else if (fmtsize == 18)
{ bytesread += psf_binheader_readf (psf, "2", &(wav_fmt->g72x.extrabytes)) ;
psf_log_printf (psf, " Extra Bytes : %d%s\n", wav_fmt->g72x.extrabytes, wav_fmt->g72x.extrabytes != 0 ? " (should be 0)" : "") ;
}
@@ -321,15 +345,15 @@
default :
psf_log_printf (psf, "*** No 'fmt ' chunk dumper for this format!\n") ;
- break ;
+ return SFE_WAV_BAD_FMT ;
} ;
- if (bytesread > structsize)
- { psf_log_printf (psf, "*** wav_w64_read_fmt_chunk (bytesread > structsize)\n") ;
- return SFE_W64_FMT_SHORT ;
+ if (bytesread > fmtsize)
+ { psf_log_printf (psf, "*** wav_w64_read_fmt_chunk (bytesread > fmtsize)\n") ;
+ return SFE_WAV_BAD_FMT ;
}
else
- psf_binheader_readf (psf, "j", structsize - bytesread) ;
+ psf_binheader_readf (psf, "j", fmtsize - bytesread) ;
psf->blockwidth = wav_fmt->min.channels * psf->bytewidth ;
@@ -344,6 +368,62 @@
subformat->esf_field4, make_size_t (8)) ;
} /* wavex_write_guid */
+void
+wav_w64_analyze (SF_PRIVATE *psf)
+{ AUDIO_DETECT ad ;
+ int format = 0 ;
+
+ if (psf->is_pipe)
+ { psf_log_printf (psf, "*** Error : Reading from a pipe. Can't analyze data section to figure out real data format.\n\n") ;
+ return ;
+ } ;
+
+ psf_log_printf (psf, "---------------------------------------------------\n"
+ "Format is known to be broken. Using detection code.\n") ;
+
+ /* Code goes here. */
+ ad.endianness = SF_ENDIAN_LITTLE ;
+ ad.channels = psf->sf.channels ;
+
+ psf_fseek (psf, 3 * 4 * 50, SEEK_SET) ;
+
+ while (psf_fread (psf->u.ucbuf, 1, 4096, psf) == 4096)
+ { format = audio_detect (psf, &ad, psf->u.ucbuf, 4096) ;
+ if (format != 0)
+ break ;
+ } ;
+
+ /* Seek to start of DATA section. */
+ psf_fseek (psf, psf->dataoffset, SEEK_SET) ;
+
+ if (format == 0)
+ { psf_log_printf (psf, "wav_w64_analyze : detection failed.\n") ;
+ return ;
+ } ;
+
+ switch (format)
+ { case SF_FORMAT_PCM_32 :
+ case SF_FORMAT_FLOAT :
+ psf_log_printf (psf, "wav_w64_analyze : found format : 0x%X\n", format) ;
+ psf->sf.format = (psf->sf.format & ~SF_FORMAT_SUBMASK) + format ;
+ psf->bytewidth = 4 ;
+ psf->blockwidth = psf->sf.channels * psf->bytewidth ;
+ break ;
+
+ case SF_FORMAT_PCM_24 :
+ psf_log_printf (psf, "wav_w64_analyze : found format : 0x%X\n", format) ;
+ psf->sf.format = (psf->sf.format & ~SF_FORMAT_SUBMASK) + format ;
+ psf->bytewidth = 3 ;
+ psf->blockwidth = psf->sf.channels * psf->bytewidth ;
+ break ;
+
+ default :
+ psf_log_printf (psf, "wav_w64_analyze : unhandled format : 0x%X\n", format) ;
+ break ;
+ } ;
+
+ return ;
+} /* wav_w64_analyze */
/*==============================================================================
*/
@@ -500,10 +580,3 @@
return 1024 ;
return 2048 ;
} /* srate2blocksize */
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: 43c1b1dd-8abd-43da-a8cd-44da914b64a5
-*/
Modified: freeswitch/trunk/libs/libsndfile/src/wav_w64.h
==============================================================================
--- freeswitch/trunk/libs/libsndfile/src/wav_w64.h (original)
+++ freeswitch/trunk/libs/libsndfile/src/wav_w64.h Thu May 21 16:09:30 2009
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 1999-2005 Erik de Castro Lopo <erikd at mega-nerd.com>
+** Copyright (C) 1999-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU Lesser General Public License as published by
@@ -256,6 +256,15 @@
{ int frames ;
} FACT_CHUNK ;
+typedef struct
+{ /* For ambisonic commands */
+ int wavex_ambisonic ;
+
+ /* Set to true when 'fmt ' chunk is ambiguous.*/
+ int fmt_is_broken ;
+ WAV_FMT wav_fmt ;
+} WAV_PRIVATE ;
+
#define WAV_W64_GSM610_BLOCKSIZE 65
#define WAV_W64_GSM610_SAMPLES 320
@@ -273,14 +282,9 @@
int wav_w64_srate2blocksize (int srate_chan_product) ;
char const* wav_w64_format_str (int k) ;
-int wav_w64_read_fmt_chunk (SF_PRIVATE *psf, WAV_FMT *wav_fmt, int structsize) ;
+int wav_w64_read_fmt_chunk (SF_PRIVATE *psf, int fmtsize) ;
void wavex_write_guid (SF_PRIVATE *psf, const EXT_SUBFORMAT * subformat) ;
+void wav_w64_analyze (SF_PRIVATE *psf) ;
#endif
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: 877fde12-9be3-4a31-8a5a-fdae39958613
-*/
+
Modified: freeswitch/trunk/libs/libsndfile/src/wve.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/src/wve.c (original)
+++ freeswitch/trunk/libs/libsndfile/src/wve.c Thu May 21 16:09:30 2009
@@ -1,5 +1,6 @@
/*
-** Copyright (C) 2002-2004 Erik de Castro Lopo <erikd at mega-nerd.com>
+** Copyright (C) 2002-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
+** Copyright (C) 2007 Reuben Thomas
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU Lesser General Public License as published by
@@ -27,32 +28,24 @@
#include "sfendian.h"
#include "common.h"
-#if (ENABLE_EXPERIMENTAL_CODE == 0)
-
-int
-wve_open (SF_PRIVATE *psf)
-{ if (psf)
- return SFE_UNIMPLEMENTED ;
- return (psf && 0) ;
-} /* wve_open */
-
-#else
-
-#define SFE_WVE_NOT_WVE 666
-
/*------------------------------------------------------------------------------
-** Macros to handle big/little endian issues.
+** Macros to handle big/little endian issues, and other magic numbers.
*/
-#define ALAW_MARKER MAKE_MARKER ('A', 'L', 'a', 'w')
-#define SOUN_MARKER MAKE_MARKER ('S', 'o', 'u', 'n')
-#define DFIL_MARKER MAKE_MARKER ('d', 'F', 'i', 'l')
+#define ALAW_MARKER MAKE_MARKER ('A', 'L', 'a', 'w')
+#define SOUN_MARKER MAKE_MARKER ('S', 'o', 'u', 'n')
+#define DFIL_MARKER MAKE_MARKER ('d', 'F', 'i', 'l')
+#define ESSN_MARKER MAKE_MARKER ('e', '*', '*', '\0')
+#define PSION_VERSION ((unsigned short) 3856)
+#define PSION_DATAOFFSET 0x20
/*------------------------------------------------------------------------------
** Private static functions.
*/
static int wve_read_header (SF_PRIVATE *psf) ;
+static int wve_write_header (SF_PRIVATE *psf, int calc_length) ;
+static int wve_close (SF_PRIVATE *psf) ;
/*------------------------------------------------------------------------------
** Public function.
@@ -60,18 +53,33 @@
int
wve_open (SF_PRIVATE *psf)
-{ int subformat, error = 0 ;
+{ int error = 0 ;
+
+ if (psf->is_pipe)
+ return SFE_WVE_NO_PIPE ;
+
+ if (psf->mode == SFM_READ || (psf->mode == SFM_RDWR && psf->filelength > 0))
+ { if ((error = wve_read_header (psf)))
+ return error ;
+ } ;
if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR)
- return SFE_UNIMPLEMENTED ;
+ { if ((SF_CONTAINER (psf->sf.format)) != SF_FORMAT_WVE)
+ return SFE_BAD_OPEN_FORMAT ;
+
+ psf->endian = SF_ENDIAN_BIG ;
+
+ if ((error = wve_write_header (psf, SF_FALSE)))
+ return error ;
- if ((error = wve_read_header (psf)))
- return error ;
+ psf->write_header = wve_write_header ;
+ } ;
- if ((psf->sf.format & SF_FORMAT_TYPEMASK) != SF_FORMAT_WVE)
- return SFE_BAD_OPEN_FORMAT ;
+ psf->blockwidth = psf->bytewidth * psf->sf.channels ;
- subformat = psf->sf.format & SF_FORMAT_SUBMASK ;
+ psf->container_close = wve_close ;
+
+ error = alaw_init (psf) ;
return error ;
} /* wve_open */
@@ -82,44 +90,120 @@
static int
wve_read_header (SF_PRIVATE *psf)
{ int marker ;
+ unsigned short version, padding, repeats, trash ;
+ unsigned datalength ;
/* Set position to start of file to begin reading header. */
psf_binheader_readf (psf, "pm", 0, &marker) ;
if (marker != ALAW_MARKER)
+ { psf_log_printf (psf, "Could not find '%M'\n", ALAW_MARKER) ;
return SFE_WVE_NOT_WVE ;
+ } ;
psf_binheader_readf (psf, "m", &marker) ;
if (marker != SOUN_MARKER)
+ { psf_log_printf (psf, "Could not find '%M'\n", SOUN_MARKER) ;
return SFE_WVE_NOT_WVE ;
+ } ;
psf_binheader_readf (psf, "m", &marker) ;
if (marker != DFIL_MARKER)
+ { psf_log_printf (psf, "Could not find '%M'\n", DFIL_MARKER) ;
return SFE_WVE_NOT_WVE ;
+ } ;
+
+ psf_binheader_readf (psf, "m", &marker) ;
+ if (marker != ESSN_MARKER)
+ { psf_log_printf (psf, "Could not find '%M'\n", ESSN_MARKER) ;
+ return SFE_WVE_NOT_WVE ;
+ } ;
+
+ psf_binheader_readf (psf, "E2", &version) ;
- psf_log_printf (psf, "Read only : Psion Palmtop Alaw (.wve)\n"
+ psf_log_printf (psf, "Psion Palmtop Alaw (.wve)\n"
" Sample Rate : 8000\n"
" Channels : 1\n"
" Encoding : A-law\n") ;
- psf->dataoffset = 0x20 ;
- psf->datalength = psf->filelength - psf->dataoffset ;
+ if (version != PSION_VERSION)
+ psf_log_printf (psf, "Psion version %d should be %d\n", version, PSION_VERSION) ;
+
+ psf_binheader_readf (psf, "E4", &datalength) ;
+ psf->dataoffset = PSION_DATAOFFSET ;
+ if (datalength != psf->filelength - psf->dataoffset)
+ { psf->datalength = psf->filelength - psf->dataoffset ;
+ psf_log_printf (psf, "Data length %d should be %D\n", datalength, psf->datalength) ;
+ }
+ else
+ psf->datalength = datalength ;
+
+ psf_binheader_readf (psf, "E22222", &padding, &repeats, &trash, &trash, &trash) ;
psf->sf.format = SF_FORMAT_WVE | SF_FORMAT_ALAW ;
psf->sf.samplerate = 8000 ;
psf->sf.frames = psf->datalength ;
psf->sf.channels = 1 ;
- return alaw_init (psf) ;
+ return SFE_NO_ERROR ;
} /* wve_read_header */
/*------------------------------------------------------------------------------
*/
-#endif
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: ba368cb5-523f-45e4-98c1-5b99a102f73f
+static int
+wve_write_header (SF_PRIVATE *psf, int calc_length)
+{ sf_count_t current ;
+ unsigned datalen ;
+
+ current = psf_ftell (psf) ;
+
+ if (calc_length)
+ { psf->filelength = psf_get_filelen (psf) ;
+
+ psf->datalength = psf->filelength - psf->dataoffset ;
+ if (psf->dataend)
+ psf->datalength -= psf->filelength - psf->dataend ;
+
+ psf->sf.frames = psf->datalength / (psf->bytewidth * psf->sf.channels) ;
+ } ;
+
+ /* Reset the current header length to zero. */
+ psf->header [0] = 0 ;
+ psf->headindex = 0 ;
+ psf_fseek (psf, 0, SEEK_SET) ;
+
+ /* Write header. */
+ datalen = psf->datalength ;
+ psf_binheader_writef (psf, "Emmmm", ALAW_MARKER, SOUN_MARKER, DFIL_MARKER, ESSN_MARKER) ;
+ psf_binheader_writef (psf, "E2422222", PSION_VERSION, datalen, 0, 0, 0, 0, 0) ;
+ psf_fwrite (psf->header, psf->headindex, 1, psf) ;
+
+ if (psf->sf.channels != 1)
+ return SFE_CHANNEL_COUNT ;
+
+ if (psf->error)
+ return psf->error ;
+
+ psf->dataoffset = psf->headindex ;
+
+ if (current > 0)
+ psf_fseek (psf, current, SEEK_SET) ;
+
+ return psf->error ;
+} /* wve_write_header */
+
+/*------------------------------------------------------------------------------
*/
+
+static int
+wve_close (SF_PRIVATE *psf)
+{
+ if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR)
+ { /* Now we know for certain the length of the file we can re-write
+ ** the header.
+ */
+ wve_write_header (psf, SF_TRUE) ;
+ } ;
+
+ return 0 ;
+} /* wve_close */
Modified: freeswitch/trunk/libs/libsndfile/src/xi.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/src/xi.c (original)
+++ freeswitch/trunk/libs/libsndfile/src/xi.c Thu May 21 16:09:30 2009
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 2003-2006 Erik de Castro Lopo <erikd at mega-nerd.com>
+** Copyright (C) 2003-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU Lesser General Public License as published by
@@ -23,11 +23,11 @@
#include <fcntl.h>
#include <string.h>
#include <ctype.h>
+#include <math.h>
#include "sndfile.h"
#include "sfendian.h"
#include "common.h"
-#include "float_cast.h"
#define MAX_XI_SAMPLES 16
@@ -80,10 +80,10 @@
return error ;
} ;
- subformat = psf->sf.format & SF_FORMAT_SUBMASK ;
+ subformat = SF_CODEC (psf->sf.format) ;
if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR)
- { if ((psf->sf.format & SF_FORMAT_TYPEMASK) != SF_FORMAT_XI)
+ { if ((SF_CONTAINER (psf->sf.format)) != SF_FORMAT_XI)
return SFE_BAD_OPEN_FORMAT ;
psf->endian = SF_ENDIAN_LITTLE ;
@@ -95,7 +95,7 @@
memcpy (pxi->software, PACKAGE "-" VERSION " ", sizeof (pxi->software)) ;
memset (pxi->sample_name, 0, sizeof (pxi->sample_name)) ;
- LSF_SNPRINTF (pxi->sample_name, sizeof (pxi->sample_name), "%s", "Sample #1") ;
+ snprintf (pxi->sample_name, sizeof (pxi->sample_name), "%s", "Sample #1") ;
pxi->sample_flags = (subformat == SF_FORMAT_DPCM_16) ? 16 : 0 ;
@@ -128,10 +128,8 @@
*/
static int
-xi_close (SF_PRIVATE *psf)
+xi_close (SF_PRIVATE * UNUSED (psf))
{
- psf = psf ;
-
return 0 ;
} /* xi_close */
@@ -248,7 +246,7 @@
psf_fseek (psf, psf->dataoffset, SEEK_SET) ;
- if ((psf->sf.format & SF_FORMAT_SUBMASK) == SF_FORMAT_DPCM_16)
+ if ((SF_CODEC (psf->sf.format)) == SF_FORMAT_DPCM_16)
{ total = offset ;
bufferlen = ARRAY_LEN (psf->u.sbuf) ;
while (total > 0)
@@ -270,7 +268,7 @@
static int
-xi_write_header (SF_PRIVATE *psf, int calc_length)
+xi_write_header (SF_PRIVATE *psf, int UNUSED (calc_length))
{ XI_PRIVATE *pxi ;
sf_count_t current ;
const char *string ;
@@ -278,8 +276,6 @@
if ((pxi = psf->codec_data) == NULL)
return SFE_INTERNAL ;
- calc_length = calc_length ; /* Avoid a compiler warning. */
-
current = psf_ftell (psf) ;
/* Reset the current header length to zero. */
@@ -446,18 +442,22 @@
return SFE_XI_EXCESS_SAMPLES ;
} ;
- psf->dataoffset = psf_fseek (psf, 0, SEEK_CUR) ;
- psf_log_printf (psf, "Data Offset : %D\n", psf->dataoffset) ;
-
psf->datalength = sample_sizes [0] ;
+ psf->dataoffset = psf_ftell (psf) ;
+ if (psf->dataoffset < 0)
+ { psf_log_printf (psf, "*** Bad Data Offset : %D\n", psf->dataoffset) ;
+ return SFE_BAD_OFFSET ;
+ } ;
+ psf_log_printf (psf, "Data Offset : %D\n", psf->dataoffset) ;
+
if (psf->dataoffset + psf->datalength > psf->filelength)
{ psf_log_printf (psf, "*** File seems to be truncated. Should be at least %D bytes long.\n",
psf->dataoffset + sample_sizes [0]) ;
psf->datalength = psf->filelength - psf->dataoffset ;
} ;
- if (psf_fseek (psf, psf->dataoffset, SEEK_SET) != psf->dataoffset)
+ if (psf_fseek (psf, psf->dataoffset, SEEK_SET) != psf->dataoffset)
return SFE_BAD_SEEK ;
psf->endian = SF_ENDIAN_LITTLE ;
@@ -1195,10 +1195,3 @@
pxi->last_16 = last_val ;
} /* d2dles_array */
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: 1ab2dbe0-29af-4d80-9c6f-cb21b67521bc
-*/
Modified: freeswitch/trunk/libs/libsndfile/tests/Makefile.am
==============================================================================
--- freeswitch/trunk/libs/libsndfile/tests/Makefile.am (original)
+++ freeswitch/trunk/libs/libsndfile/tests/Makefile.am Thu May 21 16:09:30 2009
@@ -1,16 +1,23 @@
## Process this file with automake to produce Makefile.in
+if ENABLE_TEST_COVERAGE
+CPP_TEST =
+else
+CPP_TEST = cpp_test
+endif
+
+INCLUDES = -I$(top_srcdir)/src
+
noinst_PROGRAMS = sfversion floating_point_test write_read_test \
lossy_comp_test error_test ulaw_test alaw_test dwvw_test \
peak_chunk_test command_test stdin_test stdout_test stdio_test \
pcm_test headerless_test pipe_test benchmark header_test misc_test \
- raw_test string_test open_fail_test multi_file_test dither_test \
+ raw_test string_test multi_file_test dither_test \
scale_clip_test win32_test fix_this aiff_rw_test virtual_io_test \
- locale_test largefile_test win32_ordinal_test cpp_test
+ locale_test largefile_test win32_ordinal_test ogg_test vorbis_test \
+ checksum_test external_libs_test $(CPP_TEST)
-SNDFILEDIR = ../src
-INCLUDES = -I$(srcdir)/$(SNDFILEDIR)
-noinst_HEADERS = dft_cmp.h utils.h
+noinst_HEADERS = dft_cmp.h utils.h generate.h
autogen_sources = write_read_test.tpl write_read_test.def \
pcm_test.tpl pcm_test.def \
@@ -26,104 +33,113 @@
#===============================================================================
sfversion_SOURCES = sfversion.c
-sfversion_LDADD = $(SNDFILEDIR)/libsndfile.la
+sfversion_LDADD = $(top_builddir)/src/libsndfile.la
-write_read_test_SOURCES = utils.c write_read_test.c
-write_read_test_LDADD = $(SNDFILEDIR)/libsndfile.la
+write_read_test_SOURCES = utils.c generate.c write_read_test.c
+write_read_test_LDADD = $(top_builddir)/src/libsndfile.la
lossy_comp_test_SOURCES = utils.c lossy_comp_test.c
-lossy_comp_test_LDADD = $(SNDFILEDIR)/libsndfile.la
+lossy_comp_test_LDADD = $(top_builddir)/src/libsndfile.la
fix_this_SOURCES = utils.c fix_this.c
-fix_this_LDADD = $(SNDFILEDIR)/libsndfile.la
+fix_this_LDADD = $(top_builddir)/src/libsndfile.la
error_test_SOURCES = error_test.c utils.c
-error_test_LDADD = $(SNDFILEDIR)/libsndfile.la
+error_test_LDADD = $(top_builddir)/src/libsndfile.la
ulaw_test_SOURCES = utils.c ulaw_test.c
-ulaw_test_LDADD = $(SNDFILEDIR)/libsndfile.la
+ulaw_test_LDADD = $(top_builddir)/src/libsndfile.la
alaw_test_SOURCES = utils.c alaw_test.c
-alaw_test_LDADD = $(SNDFILEDIR)/libsndfile.la
+alaw_test_LDADD = $(top_builddir)/src/libsndfile.la
aiff_rw_test_SOURCES = utils.c aiff_rw_test.c
-aiff_rw_test_LDADD = $(SNDFILEDIR)/libsndfile.la
+aiff_rw_test_LDADD = $(top_builddir)/src/libsndfile.la
command_test_SOURCES = command_test.c utils.c
-command_test_LDADD = $(SNDFILEDIR)/libsndfile.la
+command_test_LDADD = $(top_builddir)/src/libsndfile.la
locale_test_SOURCES = locale_test.c utils.c
-locale_test_LDADD = $(SNDFILEDIR)/libsndfile.la
+locale_test_LDADD = $(top_builddir)/src/libsndfile.la
largefile_test_SOURCES = largefile_test.c utils.c
-largefile_test_LDADD = $(SNDFILEDIR)/libsndfile.la
+largefile_test_LDADD = $(top_builddir)/src/libsndfile.la
pcm_test_SOURCES = pcm_test.c utils.c
-pcm_test_LDADD = $(SNDFILEDIR)/libsndfile.la
+pcm_test_LDADD = $(top_builddir)/src/libsndfile.la
headerless_test_SOURCES = utils.c headerless_test.c
-headerless_test_LDADD = $(SNDFILEDIR)/libsndfile.la
+headerless_test_LDADD = $(top_builddir)/src/libsndfile.la
stdin_test_SOURCES = stdin_test.c utils.c
-stdin_test_LDADD = $(SNDFILEDIR)/libsndfile.la
+stdin_test_LDADD = $(top_builddir)/src/libsndfile.la
stdout_test_SOURCES = stdout_test.c
-stdout_test_LDADD = $(SNDFILEDIR)/libsndfile.la
+stdout_test_LDADD = $(top_builddir)/src/libsndfile.la
stdio_test_SOURCES = stdio_test.c utils.c
-stdio_test_LDADD = $(SNDFILEDIR)/libsndfile.la
+stdio_test_LDADD = $(top_builddir)/src/libsndfile.la
pipe_test_SOURCES = pipe_test.c utils.c
-pipe_test_LDADD = $(SNDFILEDIR)/libsndfile.la
+pipe_test_LDADD = $(top_builddir)/src/libsndfile.la
benchmark_SOURCES = benchmark.c
-benchmark_LDADD = $(SNDFILEDIR)/libsndfile.la
+benchmark_LDADD = $(top_builddir)/src/libsndfile.la
header_test_SOURCES = header_test.c utils.c
-header_test_LDADD = $(SNDFILEDIR)/libsndfile.la
+header_test_LDADD = $(top_builddir)/src/libsndfile.la
misc_test_SOURCES = misc_test.c utils.c
-misc_test_LDADD = $(SNDFILEDIR)/libsndfile.la
+misc_test_LDADD = $(top_builddir)/src/libsndfile.la
raw_test_SOURCES = raw_test.c utils.c
-raw_test_LDADD = $(SNDFILEDIR)/libsndfile.la
+raw_test_LDADD = $(top_builddir)/src/libsndfile.la
string_test_SOURCES = string_test.c utils.c
-string_test_LDADD = $(SNDFILEDIR)/libsndfile.la
+string_test_LDADD = $(top_builddir)/src/libsndfile.la
dither_test_SOURCES = dither_test.c utils.c
-dither_test_LDADD = $(SNDFILEDIR)/libsndfile.la
-
-open_fail_test_SOURCES = open_fail_test.c utils.c
-open_fail_test_LDADD = $(SNDFILEDIR)/libsndfile.la
+dither_test_LDADD = $(top_builddir)/src/libsndfile.la
multi_file_test_SOURCES = multi_file_test.c utils.c
-multi_file_test_LDADD = $(SNDFILEDIR)/libsndfile.la
+multi_file_test_LDADD = $(top_builddir)/src/libsndfile.la
virtual_io_test_SOURCES = virtual_io_test.c utils.c
-virtual_io_test_LDADD = $(SNDFILEDIR)/libsndfile.la
+virtual_io_test_LDADD = $(top_builddir)/src/libsndfile.la
+
+ogg_test_SOURCES = ogg_test.c utils.c
+ogg_test_LDADD = $(top_builddir)/src/libsndfile.la
+
+vorbis_test_SOURCES = vorbis_test.c utils.c
+vorbis_test_LDADD = $(top_builddir)/src/libsndfile.la
win32_test_SOURCES = win32_test.c
win32_test_LDADD =
win32_ordinal_test_SOURCES = win32_ordinal_test.c utils.c
-win32_ordinal_test_LDADD = $(SNDFILEDIR)/libsndfile.la
+win32_ordinal_test_LDADD = $(top_builddir)/src/libsndfile.la
+
+external_libs_test_SOURCES = external_libs_test.c utils.c
+external_libs_test_LDADD = $(top_builddir)/src/libsndfile.la
cpp_test_SOURCES = cpp_test.cc utils.c
-cpp_test_LDADD = $(SNDFILEDIR)/libsndfile.la
+cpp_test_LDADD = $(top_builddir)/src/libsndfile.la
+
+checksum_test_SOURCES = checksum_test.c utils.c
+checksum_test_LDADD = $(top_builddir)/src/libsndfile.la
# Lite remove start
dwvw_test_SOURCES = utils.c dwvw_test.c
-dwvw_test_LDADD = $(SNDFILEDIR)/libsndfile.la
+dwvw_test_LDADD = $(top_builddir)/src/libsndfile.la
floating_point_test_SOURCES = utils.c dft_cmp.c floating_point_test.c
-floating_point_test_LDADD = $(SNDFILEDIR)/libsndfile.la
+floating_point_test_LDADD = $(top_builddir)/src/libsndfile.la
peak_chunk_test_SOURCES = peak_chunk_test.c utils.c
-peak_chunk_test_LDADD = $(SNDFILEDIR)/libsndfile.la
+peak_chunk_test_LDADD = $(top_builddir)/src/libsndfile.la
scale_clip_test_SOURCES = scale_clip_test.c utils.c
-scale_clip_test_LDADD = $(SNDFILEDIR)/libsndfile.la
+scale_clip_test_LDADD = $(top_builddir)/src/libsndfile.la
# Lite remove end
#===============================================================================
@@ -137,7 +153,7 @@
header_test.c: header_test.def header_test.tpl
autogen --writable header_test.def
-utils.c: utils.def utils.tpl
+utils.c utils.h : utils.def utils.tpl
autogen --writable utils.def
scale_clip_test.c: scale_clip_test.def scale_clip_test.tpl
@@ -156,246 +172,24 @@
scale_clip_test.c pipe_test.c floating_point_test.c benchmark.c
#===============================================================================
+# If we're cross compiling from Linux to Windows and running the test suite
+# under Wine, we need a symbolic link to the generated libsndfile DLL.
-check: generic-tests wav-tests aiff-tests au-tests caf-tests raw-tests \
- paf-tests svx-tests nist-tests ircam-tests voc-tests w64-tests mat4-tests \
- mat5-tests pvf-tests xi-tests htk-tests avr-tests sds-tests sd2-tests \
- flac-tests caf-tests io-tests
-
-generic-tests : error_test ulaw_test alaw_test command_test floating_point_test \
- pcm_test win32_ordinal_test cpp_test
- uname -a
- ./error_test
- ./pcm_test
- ./ulaw_test
- ./alaw_test
- ./dwvw_test
- ./command_test ver
- ./command_test norm
- ./command_test format
- ./command_test peak
- ./command_test trunc
- ./command_test inst
- ./command_test bext
- ./floating_point_test
- ./scale_clip_test
- ./headerless_test
- ./locale_test
- ./win32_ordinal_test
- ./cpp_test
- @echo "----------------------------------------------------------------------"
- @echo " `./sfversion` passed common tests."
- @echo "----------------------------------------------------------------------"
-
-wav-tests: write_read_test lossy_comp_test peak_chunk_test header_test misc_test multi_file_test
- ./write_read_test wav
- ./lossy_comp_test wav_ima
- ./lossy_comp_test wav_msadpcm
- ./lossy_comp_test wav_ulaw
- ./lossy_comp_test wav_alaw
- ./lossy_comp_test wav_gsm610
- ./lossy_comp_test wav_g721
- ./peak_chunk_test wav
- ./header_test wav
- ./misc_test wav
- ./string_test wav
- ./multi_file_test wav
- ./open_fail_test wav
- @echo "----------------------------------------------------------------------"
- @echo " `./sfversion` passed tests on WAV files."
- @echo "----------------------------------------------------------------------"
-
-aiff-tests: write_read_test lossy_comp_test peak_chunk_test header_test misc_test aiff_rw_test
- ./write_read_test aiff
- ./lossy_comp_test aiff_ulaw
- ./lossy_comp_test aiff_alaw
- ./lossy_comp_test aiff_gsm610
- @echo "=========================="
- @echo "./lossy_comp_test aiff_ima"
- @echo "=========================="
- ./peak_chunk_test aiff
- ./header_test aiff
- ./misc_test aiff
- ./string_test aiff
- ./multi_file_test aiff
- ./aiff_rw_test
- @echo "----------------------------------------------------------------------"
- @echo " `./sfversion` passed tests on AIFF files."
- @echo "----------------------------------------------------------------------"
-
-caf-tests: write_read_test lossy_comp_test header_test misc_test
- ./write_read_test caf
- ./lossy_comp_test caf_ulaw
- ./lossy_comp_test caf_alaw
- ./header_test caf
- ./misc_test caf
- @echo "----------------------------------------------------------------------"
- @echo " `./sfversion` passed tests on CAF files."
- @echo "----------------------------------------------------------------------"
-
-au-tests: write_read_test lossy_comp_test header_test misc_test
- ./write_read_test au
- ./lossy_comp_test au_ulaw
- ./lossy_comp_test au_alaw
- ./lossy_comp_test au_g721
- ./lossy_comp_test au_g723
- ./header_test au
- ./misc_test au
- ./multi_file_test wav
- @echo "----------------------------------------------------------------------"
- @echo " `./sfversion` passed tests on AU files."
- @echo "----------------------------------------------------------------------"
-
-raw-tests: write_read_test lossy_comp_test raw_test
- ./write_read_test raw
- ./lossy_comp_test raw_ulaw
- ./lossy_comp_test raw_alaw
- ./lossy_comp_test raw_gsm610
- ./lossy_comp_test vox_adpcm
- ./raw_test
- @echo "----------------------------------------------------------------------"
- @echo " `./sfversion` passed tests on RAW (header-less) files."
- @echo "----------------------------------------------------------------------"
-
-w64-tests: write_read_test lossy_comp_test misc_test
- ./write_read_test w64
- ./lossy_comp_test w64_ima
- ./lossy_comp_test w64_msadpcm
- ./lossy_comp_test w64_ulaw
- ./lossy_comp_test w64_alaw
- ./lossy_comp_test w64_gsm610
- ./header_test w64
- ./misc_test w64
- @echo "----------------------------------------------------------------------"
- @echo " `./sfversion` passed tests on W64 files."
- @echo "----------------------------------------------------------------------"
+if LINUX_MINGW_CROSS_TEST
-# Lite remove start
-paf-tests: write_read_test misc_test
- ./write_read_test paf
- ./header_test paf
- ./misc_test paf
- @echo "----------------------------------------------------------------------"
- @echo " `./sfversion` passed tests on PAF files."
- @echo "----------------------------------------------------------------------"
-
-svx-tests: write_read_test misc_test
- ./write_read_test svx
- ./header_test svx
- ./misc_test svx
- @echo "----------------------------------------------------------------------"
- @echo " `./sfversion` passed tests on SVX files."
- @echo "----------------------------------------------------------------------"
-
-nist-tests: write_read_test lossy_comp_test misc_test
- ./write_read_test nist
- ./lossy_comp_test nist_ulaw
- ./lossy_comp_test nist_alaw
- ./header_test nist
- ./misc_test nist
- @echo "----------------------------------------------------------------------"
- @echo " `./sfversion` passed tests on NIST files."
- @echo "----------------------------------------------------------------------"
-
-ircam-tests: write_read_test lossy_comp_test misc_test
- ./write_read_test ircam
- ./lossy_comp_test ircam_ulaw
- ./lossy_comp_test ircam_alaw
- ./header_test ircam
- ./misc_test ircam
- @echo "----------------------------------------------------------------------"
- @echo " `./sfversion` passed tests on IRCAM files."
- @echo "----------------------------------------------------------------------"
-
-voc-tests: write_read_test lossy_comp_test misc_test
- ./write_read_test voc
- ./lossy_comp_test voc_ulaw
- ./lossy_comp_test voc_alaw
- ./header_test voc
- ./misc_test voc
- @echo "----------------------------------------------------------------------"
- @echo " `./sfversion` passed tests on VOC files."
- @echo "----------------------------------------------------------------------"
-
-mat4-tests: write_read_test misc_test
- ./write_read_test mat4
- ./header_test mat4
- ./misc_test mat4
- @echo "----------------------------------------------------------------------"
- @echo " `./sfversion` passed tests on MAT4 files."
- @echo "----------------------------------------------------------------------"
-
-mat5-tests: write_read_test misc_test
- ./write_read_test mat5
- ./header_test mat5
- ./misc_test mat5
- @echo "----------------------------------------------------------------------"
- @echo " `./sfversion` passed tests on MAT5 files."
- @echo "----------------------------------------------------------------------"
-
-pvf-tests: write_read_test misc_test
- ./write_read_test pvf
- ./header_test pvf
- ./misc_test pvf
- @echo "----------------------------------------------------------------------"
- @echo " `./sfversion` passed tests on PVF files."
- @echo "----------------------------------------------------------------------"
-
-xi-tests: lossy_comp_test
- ./lossy_comp_test xi_dpcm
- @echo "----------------------------------------------------------------------"
- @echo " `./sfversion` passed tests on XI files."
- @echo "----------------------------------------------------------------------"
-
-htk-tests: write_read_test misc_test
- ./write_read_test htk
- ./header_test htk
- ./misc_test htk
- @echo "----------------------------------------------------------------------"
- @echo " `./sfversion` passed tests on HTK files."
- @echo "----------------------------------------------------------------------"
-
-avr-tests: write_read_test misc_test
- ./write_read_test avr
- ./header_test avr
- ./misc_test avr
- @echo "----------------------------------------------------------------------"
- @echo " `./sfversion` passed tests on AVR files."
- @echo "----------------------------------------------------------------------"
-
-sds-tests: write_read_test misc_test
- ./write_read_test sds
- ./header_test sds
- ./misc_test sds
- @echo "----------------------------------------------------------------------"
- @echo " `./sfversion` passed tests on SDS files."
- @echo "----------------------------------------------------------------------"
-
-sd2-tests: write_read_test
- ./write_read_test sd2
- @echo "----------------------------------------------------------------------"
- @echo " `./sfversion` passed tests on SD2 files."
- @echo "----------------------------------------------------------------------"
-
-flac-tests: write_read_test
- ./write_read_test flac
- @echo "----------------------------------------------------------------------"
- @echo " `./sfversion` passed tests on FLAC files."
- @echo "----------------------------------------------------------------------"
+$(noinst_PROGRAMS) : libsndfile-1.dll
-# Lite remove end
+libsndfile-1.dll :
+ ln -s $(top_builddir)/src/.libs/$@ $@
+
+clean-local :
+ -rm -f libsndfile-1.dll
+
+endif
+
+#===============================================================================
-io-tests: stdio_test stdin_test stdout_test pipe_test
- ./stdio_test
- ./pipe_test
- ./virtual_io_test
- @echo "----------------------------------------------------------------------"
- @echo " `./sfversion` passed stdio/pipe/vio tests."
- @echo "----------------------------------------------------------------------"
-
-## Do not edit or modify anything in this comment block.
-## The arch-tag line is a file identity tag for the GNU Arch
-## revision control system.
-##
-## arch-tag: 820ec297-29b9-48a4-998f-48b17053f435
+check: $(noinst_PROGRAMS) test_wrapper.sh
+ sh test_wrapper.sh
+
Modified: freeswitch/trunk/libs/libsndfile/tests/aiff_rw_test.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/tests/aiff_rw_test.c (original)
+++ freeswitch/trunk/libs/libsndfile/tests/aiff_rw_test.c Thu May 21 16:09:30 2009
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 2003,2004 Erik de Castro Lopo <erikd at mega-nerd.com>
+** Copyright (C) 2003-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
@@ -30,7 +30,7 @@
static unsigned char aifc_data [] =
{ 'F' , 'O' , 'R' , 'M' ,
- 0x00, 0x00, 0x01, 0xAA, /* FORM length */
+ 0x00, 0x00, 0x01, 0xE8, /* FORM length */
'A' , 'I' , 'F' , 'C' ,
0x43, 0x4F, 0x4D, 0x4D, /* COMM */
@@ -42,6 +42,14 @@
'F' , 'V' , 'E' , 'R' , 0x00, 0x00, 0x00, 0x04, 0xA2, 0x80, 0x51, 0x40,
+ /* A 'MARK' chunk. */
+ 'M' , 'A' , 'R' , 'K' , 0x00, 0x00, 0x00, 0x36, 0x00, 0x05,
+ 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 'A' ,
+ 0x00, 0x02, 0x00, 0x00, 0x11, 0x3A, 0x02, 'B' , 'C' , 0x00,
+ 0x00, 0x03, 0x00, 0x00, 0x22, 0x74, 0x03, 'D' , 'E' , 'F',
+ 0x00, 0x04, 0x00, 0x00, 0x33, 0xAE, 0x04, 'G' , 'H' , 'I', 'J' , 0x00,
+ 0x00, 0x05, 0x00, 0x00, 0x44, 0xE8, 0x05, 'K' , 'L' , 'M', 'N' , 'O' ,
+
'S' , 'S' , 'N' , 'D' ,
0x00, 0x00, 0x01, 0x64, /* SSND length */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@@ -132,7 +140,7 @@
/* Now compare the two. */
if (sfinfo_rd.format != sfinfo_rw.format)
- { printf ("\n\nLine %d : channel count mismatch (0x%08X != 0x%08X).\n\n", __LINE__,
+ { printf ("\n\nLine %d : format mismatch (0x%08X != 0x%08X).\n\n", __LINE__,
sfinfo_rd.format, sfinfo_rw.format) ;
exit (1) ;
} ;
@@ -144,7 +152,7 @@
} ;
if (sfinfo_rd.frames != sfinfo_rw.frames)
- { printf ("\n\nLine %d : frame count mismatch (%ld != %ld).\n\n", __LINE__,
+ { printf ("\n\nLine %d : frame count mismatch (rd %ld != rw %ld).\n\n", __LINE__,
SF_COUNT_TO_LONG (sfinfo_rd.frames), SF_COUNT_TO_LONG (sfinfo_rw.frames)) ;
exit (1) ;
} ;
@@ -152,10 +160,3 @@
return ;
} /* rw_test */
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: 12561248-1ad1-4ba6-941c-029f1333c080
-*/
Modified: freeswitch/trunk/libs/libsndfile/tests/alaw_test.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/tests/alaw_test.c (original)
+++ freeswitch/trunk/libs/libsndfile/tests/alaw_test.c Thu May 21 16:09:30 2009
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 1999-2004 Erik de Castro Lopo <erikd at mega-nerd.com>
+** Copyright (C) 1999-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
@@ -233,18 +233,3 @@
return sample ;
} /* alaw_decode */
-
-
-
-
-
-
-
-
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: d3fb5eae-b3a4-4c5b-90ab-e3daa64c4a57
-*/
Modified: freeswitch/trunk/libs/libsndfile/tests/benchmark.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/tests/benchmark.c (original)
+++ freeswitch/trunk/libs/libsndfile/tests/benchmark.c Thu May 21 16:09:30 2009
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 2002-2004 Erik de Castro Lopo <erikd at mega-nerd.com>
+** Copyright (C) 2002-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
@@ -41,13 +41,21 @@
#define M_PI 3.14159265358979323846264338
#endif
-#if (defined (WIN32) || defined (_WIN32))
- #define WRITE_FLAGS (O_WRONLY | O_CREAT | O_TRUNC | O_BINARY)
- #define READ_FLAGS (O_RDONLY | O_BINARY)
+/*
+** Neat solution to the Win32/OS2 binary file flage requirement.
+** If O_BINARY isn't already defined by the inclusion of the system
+** headers, set it to zero.
+*/
+#ifndef O_BINARY
+#define O_BINARY 0
+#endif
+
+#define WRITE_FLAGS (O_WRONLY | O_CREAT | O_TRUNC | O_BINARY)
+#define READ_FLAGS (O_RDONLY | O_BINARY)
+
+#if (defined (WIN32) || defined (_WIN32) || defined (__OS2__))
#define WRITE_PERMS 0777
#else
- #define WRITE_FLAGS (O_WRONLY | O_CREAT | O_TRUNC)
- #define READ_FLAGS (O_RDONLY)
#define WRITE_PERMS (S_IRUSR | S_IWUSR | S_IRGRP)
#endif
@@ -535,4 +543,3 @@
return "UNKNOWN" ;
} /* get_subtype_str */
-
Modified: freeswitch/trunk/libs/libsndfile/tests/benchmark.def
==============================================================================
--- freeswitch/trunk/libs/libsndfile/tests/benchmark.def (original)
+++ freeswitch/trunk/libs/libsndfile/tests/benchmark.def Thu May 21 16:09:30 2009
@@ -15,11 +15,3 @@
multiplier = "1.0" ;
};
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: 5cadd2d0-dd74-4067-9d75-781a36d6bf15
-*/
-
Modified: freeswitch/trunk/libs/libsndfile/tests/benchmark.tpl
==============================================================================
--- freeswitch/trunk/libs/libsndfile/tests/benchmark.tpl (original)
+++ freeswitch/trunk/libs/libsndfile/tests/benchmark.tpl Thu May 21 16:09:30 2009
@@ -1,6 +1,6 @@
[+ AutoGen5 template c +]
/*
-** Copyright (C) 2002-2004 Erik de Castro Lopo <erikd at mega-nerd.com>
+** Copyright (C) 2002-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
@@ -42,13 +42,21 @@
#define M_PI 3.14159265358979323846264338
#endif
-#if (defined (WIN32) || defined (_WIN32))
- #define WRITE_FLAGS (O_WRONLY | O_CREAT | O_TRUNC | O_BINARY)
- #define READ_FLAGS (O_RDONLY | O_BINARY)
+/*
+** Neat solution to the Win32/OS2 binary file flage requirement.
+** If O_BINARY isn't already defined by the inclusion of the system
+** headers, set it to zero.
+*/
+#ifndef O_BINARY
+#define O_BINARY 0
+#endif
+
+#define WRITE_FLAGS (O_WRONLY | O_CREAT | O_TRUNC | O_BINARY)
+#define READ_FLAGS (O_RDONLY | O_BINARY)
+
+#if (defined (WIN32) || defined (_WIN32) || defined (__OS2__))
#define WRITE_PERMS 0777
#else
- #define WRITE_FLAGS (O_WRONLY | O_CREAT | O_TRUNC)
- #define READ_FLAGS (O_RDONLY)
#define WRITE_PERMS (S_IRUSR | S_IWUSR | S_IRGRP)
#endif
@@ -350,12 +358,3 @@
return "UNKNOWN" ;
} /* get_subtype_str */
-[+ COMMENT
-
- Do not edit or modify anything in this comment block.
- The following line is a file identity tag for the GNU Arch
- revision control system.
-
- arch-tag: 64ccb3fb-c61d-42d7-b14f-0ec3ba303f88
-
-+]
Added: freeswitch/trunk/libs/libsndfile/tests/checksum_test.c
==============================================================================
--- (empty file)
+++ freeswitch/trunk/libs/libsndfile/tests/checksum_test.c Thu May 21 16:09:30 2009
@@ -0,0 +1,128 @@
+/*
+** Copyright (C) 2008-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
+**
+** This program is free software; you can redistribute it and/or modify
+** it under the terms of the GNU General Public License as published by
+** the Free Software Foundation; either version 2 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#include "sfconfig.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <math.h>
+
+#include <sndfile.h>
+
+#include "utils.h"
+
+#define SAMPLE_RATE 8000
+
+typedef struct
+{ int enc_fmt ;
+
+ const char * enc_name ;
+ const char * dec_name ;
+
+ uint64_t enc_cksum ;
+ uint64_t dec_cksum ;
+} CHECKSUM ;
+
+static CHECKSUM
+checksum_orig [] =
+{
+ { SF_FORMAT_RAW | SF_FORMAT_ULAW,
+ "checksum.ulaw", "cksum_ulaw.pcm16",
+ 0x33aefae029e0c888LL, 0x595cd6e47edd0cffLL
+ },
+ { SF_FORMAT_RAW | SF_FORMAT_ALAW,
+ "checksum.alaw", "cksum_alaw.pcm16",
+ 0x48c798da3572d468LL, 0x6837d74869af5bb6LL
+ },
+ { SF_FORMAT_RAW | SF_FORMAT_GSM610,
+ "checksum.gsm", "cksum_gsm.pcm16",
+ 0x1b1f64ff2acf858fLL, 0x504179dbadd4bce6LL
+ },
+ { SF_FORMAT_RAW | SF_FORMAT_VOX_ADPCM,
+ "checksum.vox", "cksum_vox.pcm16",
+ 0xf1147fb3a298f4dfLL, 0xfc9c0cb8b12cb0abLL
+ },
+} ;
+
+static void checksum_test (const CHECKSUM * cksum) ;
+
+static float orig [1 << 14] ;
+static short data [1 << 14] ;
+
+int
+main (void)
+{ unsigned k ;
+
+ gen_windowed_sine_float (orig, ARRAY_LEN (orig), 0.9) ;
+
+ for (k = 0 ; k < ARRAY_LEN (checksum_orig) ; k++)
+ checksum_test (&checksum_orig [k]) ;
+
+ return 0 ;
+} /* main */
+
+/*==============================================================================
+*/
+
+static void
+checksum_test (const CHECKSUM * cksum)
+{ SNDFILE * file ;
+ SF_INFO info ;
+
+ print_test_name (__func__, cksum->enc_name) ;
+
+ info.format = cksum->enc_fmt ;
+ info.channels = 1 ;
+ info.samplerate = SAMPLE_RATE ;
+
+ file = test_open_file_or_die (cksum->enc_name, SFM_WRITE, &info, 0, __LINE__) ;
+ test_write_float_or_die (file, 0, orig, ARRAY_LEN (orig), __LINE__) ;
+ sf_close (file) ;
+
+ check_file_hash_or_die (cksum->enc_name, cksum->enc_cksum, __LINE__) ;
+ puts ("ok") ;
+
+ /*------------------------------------------------------------------------*/
+
+ print_test_name (__func__, cksum->dec_name) ;
+
+ info.format = cksum->enc_fmt ;
+ info.channels = 1 ;
+ info.samplerate = SAMPLE_RATE ;
+
+ file = test_open_file_or_die (cksum->enc_name, SFM_READ, &info, 0, __LINE__) ;
+ test_read_short_or_die (file, 0, data, ARRAY_LEN (data), __LINE__) ;
+ sf_close (file) ;
+
+ info.format = SF_ENDIAN_LITTLE | SF_FORMAT_RAW | SF_FORMAT_PCM_16 ;
+ info.channels = 1 ;
+ info.samplerate = SAMPLE_RATE ;
+
+ file = test_open_file_or_die (cksum->dec_name, SFM_WRITE, &info, 0, __LINE__) ;
+ test_write_short_or_die (file, 0, data, ARRAY_LEN (data), __LINE__) ;
+ sf_close (file) ;
+
+ check_file_hash_or_die (cksum->dec_name, cksum->dec_cksum, __LINE__) ;
+
+ remove (cksum->enc_name) ;
+ remove (cksum->dec_name) ;
+
+ puts ("ok") ;
+} /* checksum_test */
+
Modified: freeswitch/trunk/libs/libsndfile/tests/command_test.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/tests/command_test.c (original)
+++ freeswitch/trunk/libs/libsndfile/tests/command_test.c Thu May 21 16:09:30 2009
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 2001-2006 Erik de Castro Lopo <erikd at mega-nerd.com>
+** Copyright (C) 2001-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
@@ -36,14 +36,20 @@
#define BUFFER_LEN (1<<10)
#define LOG_BUFFER_SIZE 1024
-static void float_norm_test (const char *filename) ;
-static void double_norm_test (const char *filename) ;
-static void format_tests (void) ;
-static void calc_peak_test (int filetype, const char *filename) ;
-static void truncate_test (const char *filename, int filetype) ;
-static void instrument_test (const char *filename, int filetype) ;
-static void channel_map_test (const char *filename, int filetype) ;
-static void broadcast_test (const char *filename, int filetype) ;
+static void float_norm_test (const char *filename) ;
+static void double_norm_test (const char *filename) ;
+static void format_tests (void) ;
+static void calc_peak_test (int filetype, const char *filename) ;
+static void truncate_test (const char *filename, int filetype) ;
+static void instrument_test (const char *filename, int filetype) ;
+static void channel_map_test (const char *filename, int filetype) ;
+static void current_sf_info_test (const char *filename) ;
+static void raw_needs_endswap_test (const char *filename, int filetype) ;
+
+static void broadcast_test (const char *filename, int filetype) ;
+static void broadcast_rdwr_test (const char *filename, int filetype) ;
+static void broadcast_coding_history_test (const char *filename) ;
+static void broadcast_coding_history_size (const char *filename) ;
/* Force the start of this buffer to be double aligned. Sparc-solaris will
** choke if its not.
@@ -68,6 +74,9 @@
printf (" trunc - test file truncation\n") ;
printf (" inst - test set/get of SF_INSTRUMENT.\n") ;
printf (" chanmap - test set/get of channel map data..\n") ;
+ printf (" bext - test set/get of SF_BROADCAST_INFO.\n") ;
+ printf (" bextch - test set/get of SF_BROADCAST_INFO coding_history.\n") ;
+ printf (" rawend - test SFC_RAW_NEEDS_ENDSWAP.\n") ;
printf (" all - perform all tests\n") ;
exit (1) ;
} ;
@@ -76,13 +85,16 @@
if (do_all || strcmp (argv [1], "ver") == 0)
{ char buffer [128] ;
+
+ print_test_name ("version_test", "(none)") ;
buffer [0] = 0 ;
sf_command (NULL, SFC_GET_LIB_VERSION, buffer, sizeof (buffer)) ;
if (strlen (buffer) < 1)
{ printf ("Line %d: could not retrieve lib version.\n", __LINE__) ;
exit (1) ;
} ;
- test_count++ ;
+ puts ("ok") ;
+ test_count ++ ;
} ;
if (do_all || strcmp (argv [1], "norm") == 0)
@@ -91,43 +103,66 @@
*/
float_norm_test ("float.wav") ;
double_norm_test ("double.wav") ;
- test_count++ ;
+ test_count ++ ;
} ;
if (do_all || strcmp (argv [1], "peak") == 0)
{ calc_peak_test (SF_ENDIAN_BIG | SF_FORMAT_RAW, "be-peak.raw") ;
calc_peak_test (SF_ENDIAN_LITTLE | SF_FORMAT_RAW, "le-peak.raw") ;
- test_count++ ;
+ test_count ++ ;
} ;
if (do_all || ! strcmp (argv [1], "format"))
{ format_tests () ;
- test_count++ ;
+ test_count ++ ;
} ;
if (do_all || strcmp (argv [1], "trunc") == 0)
{ truncate_test ("truncate.raw", SF_FORMAT_RAW | SF_FORMAT_PCM_32) ;
truncate_test ("truncate.au" , SF_FORMAT_AU | SF_FORMAT_PCM_16) ;
- test_count++ ;
+ test_count ++ ;
} ;
if (do_all || strcmp (argv [1], "inst") == 0)
{ instrument_test ("instrument.wav", SF_FORMAT_WAV | SF_FORMAT_PCM_16) ;
instrument_test ("instrument.aiff" , SF_FORMAT_AIFF | SF_FORMAT_PCM_24) ;
/*-instrument_test ("instrument.xi", SF_FORMAT_XI | SF_FORMAT_DPCM_16) ;-*/
- test_count++ ;
+ test_count ++ ;
+ } ;
+
+ if (do_all || strcmp (argv [1], "current_sf_info") == 0)
+ { current_sf_info_test ("current.wav") ;
+ test_count ++ ;
+ } ;
+
+ if (do_all || strcmp (argv [1], "bext") == 0)
+ { broadcast_test ("broadcast.wav", SF_FORMAT_WAV | SF_FORMAT_PCM_16) ;
+ broadcast_rdwr_test ("broadcast.wav", SF_FORMAT_WAV | SF_FORMAT_PCM_16) ;
+
+ broadcast_test ("broadcast.wavex", SF_FORMAT_WAVEX | SF_FORMAT_PCM_16) ;
+ broadcast_rdwr_test ("broadcast.wavex", SF_FORMAT_WAVEX | SF_FORMAT_PCM_16) ;
+ test_count ++ ;
+ } ;
+
+ if (do_all || strcmp (argv [1], "bextch") == 0)
+ { broadcast_coding_history_test ("coding_history.wav") ;
+ broadcast_coding_history_size ("coding_hist_size.wav") ;
+ test_count ++ ;
} ;
if (do_all || strcmp (argv [1], "chanmap") == 0)
{ channel_map_test ("chanmap.wav", SF_FORMAT_WAV | SF_FORMAT_PCM_16) ;
channel_map_test ("chanmap.aiff" , SF_FORMAT_AIFF | SF_FORMAT_PCM_24) ;
- /*-instrument_test ("instrument.xi", SF_FORMAT_XI | SF_FORMAT_DPCM_16) ;-*/
- test_count++ ;
+ test_count ++ ;
} ;
- if (do_all || strcmp (argv [1], "bext") == 0)
- { broadcast_test ("broadcast.wav", SF_FORMAT_WAV | SF_FORMAT_PCM_16) ;
- test_count++ ;
+ if (do_all || strcmp (argv [1], "rawend") == 0)
+ { raw_needs_endswap_test ("raw_end.wav", SF_FORMAT_WAV) ;
+ raw_needs_endswap_test ("raw_end.wavex", SF_FORMAT_WAVEX) ;
+ raw_needs_endswap_test ("raw_end.rifx", SF_ENDIAN_BIG | SF_FORMAT_WAV) ;
+ raw_needs_endswap_test ("raw_end.aiff", SF_FORMAT_AIFF) ;
+ raw_needs_endswap_test ("raw_end.aiff_le", SF_ENDIAN_LITTLE | SF_FORMAT_AIFF) ;
+ test_count ++ ;
} ;
if (test_count == 0)
@@ -612,6 +647,39 @@
puts ("ok") ;
} /* truncate_test */
+/*------------------------------------------------------------------------------
+*/
+
+static void
+instrumet_rw_test (const char *filename)
+{ SNDFILE *sndfile ;
+ SF_INFO sfinfo ;
+ SF_INSTRUMENT inst ;
+ memset (&sfinfo, 0, sizeof (SF_INFO)) ;
+
+ sndfile = test_open_file_or_die (filename, SFM_RDWR, &sfinfo, SF_FALSE, __LINE__) ;
+
+ if (sf_command (sndfile, SFC_GET_INSTRUMENT, &inst, sizeof (inst)) == SF_TRUE)
+ { inst.basenote = 22 ;
+
+ if (sf_command (sndfile, SFC_SET_INSTRUMENT, &inst, sizeof (inst)) == SF_TRUE)
+ printf ("Sucess: [%s] updated\n", filename) ;
+ else
+ printf ("Error: SFC_SET_INSTRUMENT on [%s] [%s]\n", filename, sf_strerror (sndfile)) ;
+ }
+ else
+ printf ("Error: SFC_GET_INSTRUMENT on [%s] [%s]\n", filename, sf_strerror (sndfile)) ;
+
+
+ if (sf_command (sndfile, SFC_UPDATE_HEADER_NOW, NULL, 0) != 0)
+ printf ("Error: SFC_UPDATE_HEADER_NOW on [%s] [%s]\n", filename, sf_strerror (sndfile)) ;
+
+ sf_write_sync (sndfile) ;
+ sf_close (sndfile) ;
+
+ return ;
+} /* instrumet_rw_test */
+
static void
instrument_test (const char *filename, int filetype)
{ static SF_INSTRUMENT write_inst =
@@ -722,10 +790,62 @@
exit (1) ;
} ;
+ if (0) instrumet_rw_test (filename) ;
+
unlink (filename) ;
puts ("ok") ;
} /* instrument_test */
+static void
+current_sf_info_test (const char *filename)
+{ SNDFILE *outfile, *infile ;
+ SF_INFO outinfo, ininfo ;
+ sf_count_t last_count ;
+
+ print_test_name ("current_sf_info_test", filename) ;
+
+ outinfo.samplerate = 44100 ;
+ outinfo.format = (SF_FORMAT_WAV | SF_FORMAT_PCM_16) ;
+ outinfo.channels = 1 ;
+ outinfo.frames = 0 ;
+
+ outfile = test_open_file_or_die (filename, SFM_WRITE, &outinfo, SF_TRUE, __LINE__) ;
+ sf_command (outfile, SFC_SET_UPDATE_HEADER_AUTO, NULL, 0) ;
+
+ exit_if_true (outinfo.frames != 0,
+ "\n\nLine %d : Initial sfinfo.frames is not zero.\n\n", __LINE__
+ ) ;
+
+ test_write_double_or_die (outfile, 0, double_data, BUFFER_LEN, __LINE__) ;
+ sf_command (outfile, SFC_GET_CURRENT_SF_INFO, &outinfo, sizeof (outinfo)) ;
+
+ exit_if_true (outinfo.frames != BUFFER_LEN,
+ "\n\nLine %d : Initial sfinfo.frames (%ld) should be %d.\n\n", __LINE__,
+ SF_COUNT_TO_LONG (outinfo.frames), BUFFER_LEN
+ ) ;
+
+ /* Read file making sure no channel map exists. */
+ memset (&ininfo, 0, sizeof (ininfo)) ;
+ infile = test_open_file_or_die (filename, SFM_READ, &ininfo, SF_TRUE, __LINE__) ;
+
+ last_count = ininfo.frames ;
+
+ test_write_double_or_die (outfile, 0, double_data, BUFFER_LEN, __LINE__) ;
+
+ sf_command (infile, SFC_GET_CURRENT_SF_INFO, &ininfo, sizeof (ininfo)) ;
+
+ exit_if_true (ininfo.frames != BUFFER_LEN,
+ "\n\nLine %d : Initial sfinfo.frames (%ld) should be %d.\n\n", __LINE__,
+ SF_COUNT_TO_LONG (ininfo.frames), BUFFER_LEN
+ ) ;
+
+ sf_close (outfile) ;
+ sf_close (infile) ;
+
+ unlink (filename) ;
+ puts ("ok") ;
+} /* current_sf_info_test */
+
static void
broadcast_test (const char *filename, int filetype)
{ static SF_BROADCAST_INFO bc_write, bc_read ;
@@ -761,7 +881,7 @@
file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ;
if (sf_command (file, SFC_GET_BROADCAST_INFO, &bc_read, sizeof (bc_read)) == SF_FALSE)
- { printf ("\n\nLine %d : sf_command (SFC_SET_BROADCAST_INFO) failed.\n\n", __LINE__) ;
+ { printf ("\n\nLine %d : sf_command (SFC_GET_BROADCAST_INFO) failed.\n\n", __LINE__) ;
exit (1) ;
return ;
} ;
@@ -814,15 +934,283 @@
} /* broadcast_test */
static void
-channel_map_test (const char *filename, int filetype)
-{
-#if 1
- filetype = 0 ;
- print_test_name ("channel_map_test", filename) ;
- puts ("not working yet") ;
-#else
+broadcast_rdwr_test (const char *filename, int filetype)
+{ SF_BROADCAST_INFO binfo ;
+ SNDFILE *file ;
+ SF_INFO sfinfo ;
+ sf_count_t frames ;
+
+ print_test_name (__func__, filename) ;
+
+ create_short_sndfile (filename, filetype, 2) ;
+
+ memset (&sfinfo, 0, sizeof (sfinfo)) ;
+ memset (&binfo, 0, sizeof (binfo)) ;
+
+ snprintf (binfo.description, sizeof (binfo.description), "Test description") ;
+ snprintf (binfo.originator, sizeof (binfo.originator), "Test originator") ;
+ snprintf (binfo.originator_reference, sizeof (binfo.originator_reference), "%08x-%08x", (unsigned int) time (NULL), (unsigned int) (~ time (NULL))) ;
+ snprintf (binfo.origination_date, sizeof (binfo.origination_date), "%d/%02d/%02d", 2006, 3, 30) ;
+ snprintf (binfo.origination_time, sizeof (binfo.origination_time), "%02d:%02d:%02d", 20, 27, 0) ;
+ snprintf (binfo.umid, sizeof (binfo.umid), "Some umid") ;
+ binfo.coding_history_size = 0 ;
+
+ file = test_open_file_or_die (filename, SFM_RDWR, &sfinfo, SF_TRUE, __LINE__) ;
+ frames = sfinfo.frames ;
+ if (sf_command (file, SFC_SET_BROADCAST_INFO, &binfo, sizeof (binfo)) != SF_FALSE)
+ { printf ("\n\nLine %d : sf_command (SFC_SET_BROADCAST_INFO) should have failed but didn't.\n\n", __LINE__) ;
+ exit (1) ;
+ } ;
+ sf_close (file) ;
+
+ file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ;
+ sf_close (file) ;
+ exit_if_true (frames != sfinfo.frames, "\n\nLine %d : Frame count %lld should be %lld.\n", __LINE__, sfinfo.frames, frames) ;
+
+ unlink (filename) ;
+ puts ("ok") ;
+} /* broadcast_rdwr_test */
+
+static void
+check_coding_history_newlines (const char *filename)
+{ static SF_BROADCAST_INFO bc_write, bc_read ;
+ SNDFILE *file ;
+ SF_INFO sfinfo ;
+ unsigned k ;
+
+ sfinfo.samplerate = 22050 ;
+ sfinfo.format = SF_FORMAT_WAV | SF_FORMAT_PCM_16 ;
+ sfinfo.channels = 1 ;
+
+ memset (&bc_write, 0, sizeof (bc_write)) ;
+
+ snprintf (bc_write.description, sizeof (bc_write.description), "Test description") ;
+ snprintf (bc_write.originator, sizeof (bc_write.originator), "Test originator") ;
+ snprintf (bc_write.originator_reference, sizeof (bc_write.originator_reference), "%08x-%08x", (unsigned int) time (NULL), (unsigned int) (~ time (NULL))) ;
+ snprintf (bc_write.origination_date, sizeof (bc_write.origination_date), "%d/%02d/%02d", 2006, 3, 30) ;
+ snprintf (bc_write.origination_time, sizeof (bc_write.origination_time), "%02d:%02d:%02d", 20, 27, 0) ;
+ snprintf (bc_write.umid, sizeof (bc_write.umid), "Some umid") ;
+ bc_write.coding_history_size = snprintf (bc_write.coding_history, sizeof (bc_write.coding_history), "This has\nUnix\nand\rMac OS9\rline endings.\nLast line") ; ;
+
+ file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ;
+ if (sf_command (file, SFC_SET_BROADCAST_INFO, &bc_write, sizeof (bc_write)) == SF_FALSE)
+ { printf ("\n\nLine %d : sf_command (SFC_SET_BROADCAST_INFO) failed.\n\n", __LINE__) ;
+ exit (1) ;
+ } ;
+
+ test_write_double_or_die (file, 0, double_data, BUFFER_LEN, __LINE__) ;
+ sf_close (file) ;
+
+ memset (&bc_read, 0, sizeof (bc_read)) ;
+
+ file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ;
+ if (sf_command (file, SFC_GET_BROADCAST_INFO, &bc_read, sizeof (bc_read)) == SF_FALSE)
+ { printf ("\n\nLine %d : sf_command (SFC_SET_BROADCAST_INFO) failed.\n\n", __LINE__) ;
+ exit (1) ;
+ } ;
+ check_log_buffer_or_die (file, __LINE__) ;
+ sf_close (file) ;
+
+ if (bc_read.coding_history_size == 0)
+ { printf ("\n\nLine %d : missing coding history.\n\n", __LINE__) ;
+ exit (1) ;
+ } ;
+
+ if (strstr (bc_read.coding_history, "Last line") == NULL)
+ { printf ("\n\nLine %d : coding history truncated.\n\n", __LINE__) ;
+ exit (1) ;
+ } ;
+
+ for (k = 1 ; k < bc_read.coding_history_size ; k++)
+ { if (bc_read.coding_history [k] == '\n' && bc_read.coding_history [k - 1] != '\r')
+ { printf ("\n\nLine %d : '\\n' without '\\r' before.\n\n", __LINE__) ;
+ exit (1) ;
+ } ;
+
+ if (bc_read.coding_history [k] == '\r' && bc_read.coding_history [k + 1] != '\n')
+ { printf ("\n\nLine %d : '\\r' without '\\n' after.\n\n", __LINE__) ;
+ exit (1) ;
+ } ;
+
+ if (bc_read.coding_history [k] == 0 && k < bc_read.coding_history_size - 1)
+ { printf ("\n\nLine %d : '\\0' within coding history at index %d of %d.\n\n", __LINE__, k, bc_read.coding_history_size) ;
+ exit (1) ;
+ } ;
+ } ;
+
+ return ;
+} /* check_coding_history_newlines */
+
+static void
+broadcast_coding_history_test (const char *filename)
+{ static SF_BROADCAST_INFO bc_write, bc_read ;
+ SNDFILE *file ;
+ SF_INFO sfinfo ;
+ const char *default_history = "A=PCM,F=22050,W=16,M=mono" ;
+ const char *supplied_history =
+ "A=PCM,F=44100,W=24,M=mono,T=other\r\n"
+ "A=PCM,F=22050,W=16,M=mono,T=yet_another\r\n" ;
+
+ print_test_name ("broadcast_coding_history_test", filename) ;
+
+ sfinfo.samplerate = 22050 ;
+ sfinfo.format = SF_FORMAT_WAV | SF_FORMAT_PCM_16 ;
+ sfinfo.channels = 1 ;
+
+ memset (&bc_write, 0, sizeof (bc_write)) ;
+
+ snprintf (bc_write.description, sizeof (bc_write.description), "Test description") ;
+ snprintf (bc_write.originator, sizeof (bc_write.originator), "Test originator") ;
+ snprintf (bc_write.originator_reference, sizeof (bc_write.originator_reference), "%08x-%08x", (unsigned int) time (NULL), (unsigned int) (~ time (NULL))) ;
+ snprintf (bc_write.origination_date, sizeof (bc_write.origination_date), "%d/%02d/%02d", 2006, 3, 30) ;
+ snprintf (bc_write.origination_time, sizeof (bc_write.origination_time), "%02d:%02d:%02d", 20, 27, 0) ;
+ snprintf (bc_write.umid, sizeof (bc_write.umid), "Some umid") ;
+ /* Coding history will be filled in by the library. */
+ bc_write.coding_history_size = 0 ;
+
+ file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ;
+ if (sf_command (file, SFC_SET_BROADCAST_INFO, &bc_write, sizeof (bc_write)) == SF_FALSE)
+ { printf ("\n\nLine %d : sf_command (SFC_SET_BROADCAST_INFO) failed.\n\n", __LINE__) ;
+ exit (1) ;
+ } ;
+
+ test_write_double_or_die (file, 0, double_data, BUFFER_LEN, __LINE__) ;
+ sf_close (file) ;
+
+ memset (&bc_read, 0, sizeof (bc_read)) ;
+
+ file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ;
+ if (sf_command (file, SFC_GET_BROADCAST_INFO, &bc_read, sizeof (bc_read)) == SF_FALSE)
+ { printf ("\n\nLine %d : sf_command (SFC_SET_BROADCAST_INFO) failed.\n\n", __LINE__) ;
+ exit (1) ;
+ } ;
+ check_log_buffer_or_die (file, __LINE__) ;
+ sf_close (file) ;
+
+ if (bc_read.coding_history_size == 0)
+ { printf ("\n\nLine %d : missing coding history.\n\n", __LINE__) ;
+ exit (1) ;
+ } ;
+
+ if (bc_read.coding_history_size < strlen (default_history) || memcmp (bc_read.coding_history, default_history, strlen (default_history)) != 0)
+ { printf ("\n\nLine %d : unexpected coding history '%.*s'.\n\n", __LINE__, bc_read.coding_history_size, bc_read.coding_history) ;
+ exit (1) ;
+ } ;
+
+ bc_write.coding_history_size = strlen (supplied_history) ;
+ bc_write.coding_history_size = snprintf (bc_write.coding_history, sizeof (bc_write.coding_history), "%s", supplied_history) ;
+
+ file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ;
+ if (sf_command (file, SFC_SET_BROADCAST_INFO, &bc_write, sizeof (bc_write)) == SF_FALSE)
+ { printf ("\n\nLine %d : sf_command (SFC_SET_BROADCAST_INFO) failed.\n\n", __LINE__) ;
+ exit (1) ;
+ } ;
+
+ test_write_double_or_die (file, 0, double_data, BUFFER_LEN, __LINE__) ;
+ sf_close (file) ;
+
+ memset (&bc_read, 0, sizeof (bc_read)) ;
+
+ file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ;
+ if (sf_command (file, SFC_GET_BROADCAST_INFO, &bc_read, sizeof (bc_read)) == SF_FALSE)
+ { printf ("\n\nLine %d : sf_command (SFC_SET_BROADCAST_INFO) failed.\n\n", __LINE__) ;
+ exit (1) ;
+ } ;
+
+ check_log_buffer_or_die (file, __LINE__) ;
+ sf_close (file) ;
+
+ if (strstr (bc_read.coding_history, supplied_history) != bc_read.coding_history)
+ { printf ("\n\nLine %d : unexpected coding history :\n"
+ "----------------------------------------------------\n%s"
+ "----------------------------------------------------\n"
+ "should be this :\n"
+ "----------------------------------------------------\n%s"
+ "----------------------------------------------------\n"
+ "with one more line at the end.\n\n",
+ __LINE__, bc_read.coding_history, supplied_history) ;
+ exit (1) ;
+ } ;
+
+ check_coding_history_newlines (filename) ;
+
+ unlink (filename) ;
+ puts ("ok") ;
+} /* broadcast_coding_history_test */
+
+/*==============================================================================
+*/
+
+static void
+broadcast_coding_history_size (const char *filename)
+{ /* SF_BROADCAST_INFO struct with coding_history field of 1024 bytes. */
+ static SF_BROADCAST_INFO_VAR (1024) bc_write ;
+ static SF_BROADCAST_INFO_VAR (1024) bc_read ;
SNDFILE *file ;
SF_INFO sfinfo ;
+ int k ;
+
+ print_test_name (__func__, filename) ;
+
+ sfinfo.samplerate = 22050 ;
+ sfinfo.format = SF_FORMAT_WAV | SF_FORMAT_PCM_16 ;
+ sfinfo.channels = 1 ;
+
+ memset (&bc_write, 0, sizeof (bc_write)) ;
+
+ snprintf (bc_write.description, sizeof (bc_write.description), "Test description") ;
+ snprintf (bc_write.originator, sizeof (bc_write.originator), "Test originator") ;
+ snprintf (bc_write.originator_reference, sizeof (bc_write.originator_reference), "%08x-%08x", (unsigned int) time (NULL), (unsigned int) (~ time (NULL))) ;
+ snprintf (bc_write.origination_date, sizeof (bc_write.origination_date), "%d/%02d/%02d", 2006, 3, 30) ;
+ snprintf (bc_write.origination_time, sizeof (bc_write.origination_time), "%02d:%02d:%02d", 20, 27, 0) ;
+ snprintf (bc_write.umid, sizeof (bc_write.umid), "Some umid") ;
+ bc_write.coding_history_size = 0 ;
+
+ for (k = 0 ; bc_write.coding_history_size < 512 ; k++)
+ { snprintf (bc_write.coding_history + bc_write.coding_history_size,
+ sizeof (bc_write.coding_history) - bc_write.coding_history_size, "line %4d\n", k) ;
+ bc_write.coding_history_size = strlen (bc_write.coding_history) ;
+ } ;
+
+ exit_if_true (bc_write.coding_history_size < 512,
+ "\n\nLine %d : bc_write.coding_history_size (%d) should be > 512.\n\n", __LINE__, bc_write.coding_history_size) ;
+
+ file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ;
+ if (sf_command (file, SFC_SET_BROADCAST_INFO, &bc_write, sizeof (bc_write)) == SF_FALSE)
+ { printf ("\n\nLine %d : sf_command (SFC_SET_BROADCAST_INFO) failed.\n\n", __LINE__) ;
+ exit (1) ;
+ } ;
+
+ test_write_double_or_die (file, 0, double_data, BUFFER_LEN, __LINE__) ;
+ sf_close (file) ;
+
+ memset (&bc_read, 0, sizeof (bc_read)) ;
+
+ file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ;
+ if (sf_command (file, SFC_GET_BROADCAST_INFO, &bc_read, sizeof (bc_read)) == SF_FALSE)
+ { printf ("\n\nLine %d : sf_command (SFC_SET_BROADCAST_INFO) failed.\n\n", __LINE__) ;
+ exit (1) ;
+ } ;
+ check_log_buffer_or_die (file, __LINE__) ;
+ sf_close (file) ;
+
+ exit_if_true (bc_read.coding_history_size < 512,
+ "\n\nLine %d : unexpected coding history size %d (should be > 512).\n\n", __LINE__, bc_read.coding_history_size) ;
+
+ exit_if_true (strstr (bc_read.coding_history, "libsndfile") == NULL,
+ "\n\nLine %d : coding history incomplete (should contain 'libsndfile').\n\n", __LINE__) ;
+
+ unlink (filename) ;
+ puts ("ok") ;
+} /* broadcast_coding_history_size */
+
+/*==============================================================================
+*/
+
+static void
+channel_map_test (const char *filename, int filetype)
+{ SNDFILE *file ;
+ SF_INFO sfinfo ;
int channel_map_read [4], channel_map_write [4] =
{ SF_CHANNEL_MAP_FRONT_LEFT, SF_CHANNEL_MAP_FRONT_CENTER,
SF_CHANNEL_MAP_REAR_LEFT, SF_CHANNEL_MAP_REAR_RIGHT
@@ -874,13 +1262,70 @@
unlink (filename) ;
puts ("ok") ;
-#endif
} /* channel_map_test */
-/*
-** Do not edit or modify anything in this comment block.
-** The following line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: 59e5d452-8dae-45aa-99aa-b78dc0deba1c
-*/
+static void
+raw_needs_endswap_test (const char *filename, int filetype)
+{ static int subtypes [] =
+ { SF_FORMAT_FLOAT, SF_FORMAT_DOUBLE,
+ SF_FORMAT_PCM_16, SF_FORMAT_PCM_24, SF_FORMAT_PCM_32
+ } ;
+ SNDFILE *file ;
+ SF_INFO sfinfo ;
+ unsigned k ;
+ int needs_endswap ;
+
+ print_test_name (__func__, filename) ;
+
+ for (k = 0 ; k < ARRAY_LEN (subtypes) ; k++)
+ {
+ if (filetype == (SF_ENDIAN_LITTLE | SF_FORMAT_AIFF))
+ switch (subtypes [k])
+ { /* Little endian AIFF does not AFAIK support fl32 and fl64. */
+ case SF_FORMAT_FLOAT :
+ case SF_FORMAT_DOUBLE :
+ continue ;
+ default :
+ break ;
+ } ;
+
+ memset (&sfinfo, 0, sizeof (sfinfo)) ;
+ sfinfo.samplerate = 11025 ;
+ sfinfo.format = filetype | subtypes [k] ;
+ sfinfo.channels = 1 ;
+
+ file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ;
+ test_write_double_or_die (file, 0, double_data, BUFFER_LEN, __LINE__) ;
+ sf_close (file) ;
+
+ memset (&sfinfo, 0, sizeof (sfinfo)) ;
+ file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ;
+
+ needs_endswap = sf_command (file, SFC_RAW_DATA_NEEDS_ENDSWAP, NULL, 0) ;
+
+ switch (filetype)
+ { case SF_FORMAT_WAV :
+ case SF_FORMAT_WAVEX :
+ case SF_FORMAT_AIFF | SF_ENDIAN_LITTLE :
+ exit_if_true (needs_endswap != CPU_IS_BIG_ENDIAN,
+ "\n\nLine %d : SFC_RAW_DATA_NEEDS_ENDSWAP failed for (%d | %d).\n\n", __LINE__, filetype, k) ;
+ break ;
+
+ case SF_FORMAT_AIFF :
+ case SF_FORMAT_WAV | SF_ENDIAN_BIG :
+ exit_if_true (needs_endswap != CPU_IS_LITTLE_ENDIAN,
+ "\n\nLine %d : SFC_RAW_DATA_NEEDS_ENDSWAP failed for (%d | %d).\n\n", __LINE__, filetype, k) ;
+ break ;
+
+ default :
+ printf ("\n\nLine %d : bad format value %d.\n\n", __LINE__, filetype) ;
+ exit (1) ;
+ break ;
+ } ;
+
+ sf_close (file) ;
+ } ;
+
+ unlink (filename) ;
+ puts ("ok") ;
+} /* raw_needs_endswap_test */
Modified: freeswitch/trunk/libs/libsndfile/tests/cpp_test.cc
==============================================================================
--- freeswitch/trunk/libs/libsndfile/tests/cpp_test.cc (original)
+++ freeswitch/trunk/libs/libsndfile/tests/cpp_test.cc Thu May 21 16:09:30 2009
@@ -123,8 +123,8 @@
} ;
if (file.frames () != ARRAY_LEN (sbuffer) * 4)
- { printf ("\n\n%s %d : Error : frames %ld should be %d.\n\n", __func__, __LINE__,
- SF_COUNT_TO_LONG (file.frames ()), ARRAY_LEN (sbuffer) * 4 / 2) ;
+ { printf ("\n\n%s %d : Error : frames %ld should be %lu.\n\n", __func__, __LINE__,
+ SF_COUNT_TO_LONG (file.frames ()), (long unsigned int) ARRAY_LEN (sbuffer) * 4 / 2) ;
exit (1) ;
} ;
@@ -178,6 +178,35 @@
puts ("ok") ;
} /* ceeplusplus_test */
+static void
+ceeplusplus_extra_test (void)
+{ SndfileHandle file ;
+ const char * filename = "bad_file_name.wav" ;
+ int error ;
+
+ print_test_name ("ceeplusplus_extra_test", filename) ;
+
+ file = SndfileHandle (filename) ;
+
+ error = file.error () ;
+ if (error == 0)
+ { printf ("\n\n%s %d : error should be zero.\n\n", __func__, __LINE__) ;
+ exit (1) ;
+ } ;
+
+ if (file.strError () == NULL)
+ { printf ("\n\n%s %d : strError should not return NULL.\n\n", __func__, __LINE__) ;
+ exit (1) ;
+ } ;
+
+ if (file.seek (0, SEEK_SET) != 0)
+ { printf ("\n\n%s %d : bad seek ().\n\n", __func__, __LINE__) ;
+ exit (1) ;
+ } ;
+
+ puts ("ok") ;
+} /* ceeplusplus_extra_test */
+
int
main (void)
{
@@ -185,13 +214,8 @@
ceeplusplus_test ("cpp_test.aiff", SF_FORMAT_AIFF | SF_FORMAT_PCM_S8) ;
ceeplusplus_test ("cpp_test.au", SF_FORMAT_AU | SF_FORMAT_FLOAT) ;
+ ceeplusplus_extra_test () ;
+
return 0 ;
} /* main */
-/*
-** Do not edit or modify anything in this comment block.
-** The following line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: 06e48ee6-b19d-4453-9999-a5cf2d7bf0b6
-*/
Modified: freeswitch/trunk/libs/libsndfile/tests/dft_cmp.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/tests/dft_cmp.c (original)
+++ freeswitch/trunk/libs/libsndfile/tests/dft_cmp.c Thu May 21 16:09:30 2009
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 2002-2004 Erik de Castro Lopo <erikd at mega-nerd.com>
+** Copyright (C) 2002-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
@@ -30,25 +30,44 @@
#define DFT_SPEC_LENGTH (DFT_DATA_LENGTH / 2)
static void dft_magnitude (const double *data, double *spectrum) ;
-static double calc_max_spectral_difference (double *spec1, double *spec2) ;
+static double calc_max_spectral_difference (const double *spec1, const double *spec2) ;
/*--------------------------------------------------------------------------------
** Public functions.
*/
double
-dft_cmp (int linenum, double *orig, double *test, int len, double target_snr, int allow_exit)
+dft_cmp_float (int linenum, const float *in_data, const float *test_data, int len, double target_snr, int allow_exit)
+{ static double orig [DFT_DATA_LENGTH] ;
+ static double test [DFT_DATA_LENGTH] ;
+ unsigned k ;
+
+ if (len != DFT_DATA_LENGTH)
+ { printf ("Error (line %d) : dft_cmp_float : Bad input array length.\n", linenum) ;
+ return 1 ;
+ } ;
+
+ for (k = 0 ; k < ARRAY_LEN (orig) ; k++)
+ { test [k] = test_data [k] ;
+ orig [k] = in_data [k] ;
+ } ;
+
+ return dft_cmp_double (linenum, orig, test, len, target_snr, allow_exit) ;
+} /* dft_cmp_float */
+
+double
+dft_cmp_double (int linenum, const double *orig, const double *test, int len, double target_snr, int allow_exit)
{ static double orig_spec [DFT_SPEC_LENGTH] ;
static double test_spec [DFT_SPEC_LENGTH] ;
double snr ;
if (! orig || ! test)
- { printf ("Error (line % d) : dft_cmp : Bad input arrays.\n", linenum) ;
+ { printf ("Error (line %d) : dft_cmp_double : Bad input arrays.\n", linenum) ;
return 1 ;
} ;
if (len != DFT_DATA_LENGTH)
- { printf ("Error (line % d) : dft_cmp : Bad input array length.\n", linenum) ;
+ { printf ("Error (line %d) : dft_cmp_double : Bad input array length.\n", linenum) ;
return 1 ;
} ;
@@ -68,7 +87,7 @@
snr = -500.0 ;
return snr ;
-} /* dft_cmp */
+} /* dft_cmp_double */
/*--------------------------------------------------------------------------------
** Quick dirty calculation of magnitude spectrum for real valued data using
@@ -112,7 +131,7 @@
} /* dft_magnitude */
static double
-calc_max_spectral_difference (double *orig, double *test)
+calc_max_spectral_difference (const double *orig, const double *test)
{ double orig_max = 0.0, max_diff = 0.0 ;
int k ;
@@ -128,10 +147,3 @@
return 20.0 * log10 (max_diff / orig_max) ;
} /* calc_max_spectral_difference */
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: cba7ffe2-bafe-44bd-b57a-15def3408410
-*/
Modified: freeswitch/trunk/libs/libsndfile/tests/dft_cmp.h
==============================================================================
--- freeswitch/trunk/libs/libsndfile/tests/dft_cmp.h (original)
+++ freeswitch/trunk/libs/libsndfile/tests/dft_cmp.h Thu May 21 16:09:30 2009
@@ -1,30 +1,25 @@
/*
-** Copyright (C) 2002-2004 Erik de Castro Lopo <erikd at mega-nerd.com>
-**
+** Copyright (C) 2002-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
+**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
-**
+**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
-**
+**
** You should have received a copy of the GNU General Public License
-** along with this program; if not, write to the Free Software
+** along with this program; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#define DFT_DATA_LENGTH (2048)
-double dft_cmp (int linenum, double *orig, double *test, int len, double tolerance, int allow_exit) ;
+double dft_cmp_float (int linenum, const float *orig, const float *test, int len, double tolerance, int allow_exit) ;
+
+double dft_cmp_double (int linenum, const double *orig, const double *test, int len, double tolerance, int allow_exit) ;
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: 10eac7b2-04ef-4d86-b7c0-8f1de57b12a0
-*/
Modified: freeswitch/trunk/libs/libsndfile/tests/dither_test.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/tests/dither_test.c (original)
+++ freeswitch/trunk/libs/libsndfile/tests/dither_test.c Thu May 21 16:09:30 2009
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 2003,2004 Erik de Castro Lopo <erikd at mega-nerd.com>
+** Copyright (C) 2003-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
@@ -183,10 +183,3 @@
puts ("ok") ;
} /* dither_test */
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: ad688dd9-5211-48ef-b82d-089eafb1e7ad
-*/
Modified: freeswitch/trunk/libs/libsndfile/tests/dwvw_test.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/tests/dwvw_test.c (original)
+++ freeswitch/trunk/libs/libsndfile/tests/dwvw_test.c Thu May 21 16:09:30 2009
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 2002-2004 Erik de Castro Lopo <erikd at mega-nerd.com>
+** Copyright (C) 2002-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
@@ -20,13 +20,12 @@
#include <stdio.h>
#include <stdlib.h>
+#include <math.h>
#if HAVE_UNISTD_H
#include <unistd.h>
#endif
-#include <float_cast.h>
-
#include <sndfile.h>
#include "utils.h"
@@ -110,10 +109,4 @@
return ;
} /* dwvw_test */
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: 9e7731c3-43cd-4de5-b539-1ce6fa11d937
-*/
+
Modified: freeswitch/trunk/libs/libsndfile/tests/error_test.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/tests/error_test.c (original)
+++ freeswitch/trunk/libs/libsndfile/tests/error_test.c Thu May 21 16:09:30 2009
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 1999-2004 Erik de Castro Lopo <erikd at mega-nerd.com>
+** Copyright (C) 1999-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
@@ -33,17 +33,6 @@
#define BUFFER_SIZE (1<<15)
#define SHORT_BUFFER (256)
-static void error_number_test (void) ;
-static void error_value_test (void) ;
-
-int
-main (void)
-{ error_number_test () ;
- error_value_test () ;
-
- return 0 ;
-} /* main */
-
static void
error_number_test (void)
{ const char *noerror, *errstr ;
@@ -62,7 +51,9 @@
/* Test for error. */
if (strstr (errstr, "This is a bug in libsndfile."))
+ { printf ("\n\nError : error number %d : %s\n\n\n", k, errstr) ;
exit (1) ;
+ } ;
} ;
@@ -104,10 +95,134 @@
return ;
} /* error_value_test */
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: 799eba74-b505-49d9-89a6-22a7f51a31b4
-*/
+static void
+no_file_test (const char * filename)
+{ SNDFILE *sndfile ;
+ SF_INFO sfinfo ;
+
+ print_test_name (__func__, filename) ;
+
+ unlink (filename) ;
+
+ memset (&sfinfo, 0, sizeof (sfinfo)) ;
+ sndfile = sf_open (filename, SFM_READ, &sfinfo) ;
+
+ exit_if_true (sndfile != NULL, "\n\nLine %d : should not have received a valid SNDFILE* pointer.\n", __LINE__) ;
+
+ unlink (filename) ;
+ puts ("ok") ;
+} /* no_file_test */
+
+static void
+zero_length_test (const char *filename)
+{ SNDFILE *sndfile ;
+ SF_INFO sfinfo ;
+ FILE *file ;
+
+ print_test_name (__func__, filename) ;
+
+ /* Create a zero length file. */
+ file = fopen (filename, "w") ;
+ exit_if_true (file == NULL, "\n\nLine %d : fopen ('%s') failed.\n", __LINE__, filename) ;
+ fclose (file) ;
+
+ memset (&sfinfo, 0, sizeof (sfinfo)) ;
+ sndfile = sf_open (filename, SFM_READ, &sfinfo) ;
+
+ exit_if_true (sndfile != NULL, "\n\nLine %d : should not have received a valid SNDFILE* pointer.\n", __LINE__) ;
+
+ exit_if_true (0 && sf_error (NULL) != SF_ERR_UNRECOGNISED_FORMAT,
+ "\n\nLine %3d : Error : %s\n should be : %s\n", __LINE__,
+ sf_strerror (NULL), sf_error_number (SF_ERR_UNRECOGNISED_FORMAT)) ;
+
+ unlink (filename) ;
+ puts ("ok") ;
+} /* zero_length_test */
+
+static void
+bad_wav_test (const char * filename)
+{ SNDFILE *sndfile ;
+ SF_INFO sfinfo ;
+
+ FILE *file ;
+ const char data [] = "RIFF WAVEfmt " ;
+
+ print_test_name (__func__, filename) ;
+
+ if ((file = fopen (filename, "w")) == NULL)
+ { printf ("\n\nLine %d : fopen returned NULL.\n", __LINE__) ;
+ exit (1) ;
+ } ;
+
+ exit_if_true (fwrite (data, sizeof (data), 1, file) != 1, "\n\nLine %d : fwrite failed.\n", __LINE__) ;
+ fclose (file) ;
+
+ memset (&sfinfo, 0, sizeof (sfinfo)) ;
+ sndfile = sf_open (filename, SFM_READ, &sfinfo) ;
+
+ if (sndfile)
+ { printf ("\n\nLine %d : should not have received a valid SNDFILE* pointer.\n", __LINE__) ;
+ exit (1) ;
+ } ;
+
+ unlink (filename) ;
+ puts ("ok") ;
+} /* bad_wav_test */
+
+static void
+error_close_test (void)
+{ static short buffer [SHORT_BUFFER] ;
+ const char *filename = "error_close.wav" ;
+ SNDFILE *sndfile ;
+ SF_INFO sfinfo ;
+ FILE *file ;
+
+ print_test_name (__func__, filename) ;
+
+ /* Open a FILE* from which we will extract a file descriptor. */
+ if ((file = fopen (filename, "w")) == NULL)
+ { printf ("\n\nLine %d : fopen returned NULL.\n", __LINE__) ;
+ exit (1) ;
+ } ;
+
+ /* Set parameters for writing the file. */
+ memset (&sfinfo, 0, sizeof (sfinfo)) ;
+ sfinfo.channels = 1 ;
+ sfinfo.samplerate = 44100 ;
+ sfinfo.format = SF_FORMAT_WAV | SF_FORMAT_PCM_16 ;
+
+ sndfile = sf_open_fd (fileno (file), SFM_WRITE, &sfinfo, SF_TRUE) ;
+ if (sndfile == NULL)
+ { printf ("\n\nLine %d : sf_open_fd failed : %s\n", __LINE__, sf_strerror (NULL)) ;
+ exit (1) ;
+ } ;
+
+ test_write_short_or_die (sndfile, 0, buffer, ARRAY_LEN (buffer), __LINE__) ;
+
+ /* Now close the fd associated with file before calling sf_close. */
+ fclose (file) ;
+
+ if (sf_close (sndfile) == 0)
+ { printf ("\n\nLine %d : sf_close should not have returned zero.\n", __LINE__) ;
+ exit (1) ;
+ } ;
+
+ unlink (filename) ;
+ puts ("ok") ;
+} /* error_close_test */
+
+int
+main (void)
+{
+ error_number_test () ;
+ error_value_test () ;
+
+ error_close_test () ;
+
+ no_file_test ("no_file.wav") ;
+ zero_length_test ("zero_length.wav") ;
+ bad_wav_test ("bad_wav.wav") ;
+
+ return 0 ;
+} /* main */
+
Added: freeswitch/trunk/libs/libsndfile/tests/external_libs_test.c
==============================================================================
--- (empty file)
+++ freeswitch/trunk/libs/libsndfile/tests/external_libs_test.c Thu May 21 16:09:30 2009
@@ -0,0 +1,149 @@
+/*
+** Copyright (C) 2008-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
+**
+** This program is free software ; you can redistribute it and/or modify
+** it under the terms of the GNU General Public License as published by
+** the Free Software Foundation ; either version 2 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY ; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program ; if not, write to the Free Software
+** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#include "sfconfig.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+
+#include <sndfile.h>
+
+#include "utils.h"
+
+static void major_format_test (void) ;
+static void subtype_format_test (void) ;
+static void simple_format_test (void) ;
+
+int
+main (void)
+{
+ major_format_test () ;
+ subtype_format_test () ;
+ simple_format_test () ;
+
+ return 0 ;
+} /* main */
+
+static void
+major_format_test (void)
+{ SF_FORMAT_INFO info ;
+ int have_ogg = 0, have_flac = 0 ;
+ int m, major_count ;
+
+ print_test_name (__func__, NULL) ;
+
+ sf_command (NULL, SFC_GET_FORMAT_MAJOR_COUNT, &major_count, sizeof (int)) ;
+
+ for (m = 0 ; m < major_count ; m++)
+ { info.format = m ;
+ sf_command (NULL, SFC_GET_FORMAT_MAJOR, &info, sizeof (info)) ;
+
+ have_flac = info.format == SF_FORMAT_FLAC ? 1 : have_flac ;
+ have_ogg = info.format == SF_FORMAT_OGG ? 1 : have_ogg ;
+ } ;
+
+ if (HAVE_EXTERNAL_LIBS)
+ { exit_if_true (have_flac == 0, "\n\nLine %d : FLAC should be available.\n\n", __LINE__) ;
+ exit_if_true (have_ogg == 0, "\n\nLine %d : Ogg/Vorbis should be available.\n\n", __LINE__) ;
+ }
+ else
+ { exit_if_true (have_flac, "\n\nLine %d : FLAC should not be available.\n\n", __LINE__) ;
+ exit_if_true (have_ogg, "\n\nLine %d : Ogg/Vorbis should not be available.\n\n", __LINE__) ;
+ } ;
+
+ puts ("ok") ;
+} /* major_format_test */
+
+static void
+subtype_format_test (void)
+{ SF_FORMAT_INFO info ;
+ int have_vorbis = 0 ;
+ int s, subtype_count ;
+
+ print_test_name (__func__, NULL) ;
+
+ sf_command (NULL, SFC_GET_FORMAT_SUBTYPE_COUNT, &subtype_count, sizeof (int)) ;
+
+ for (s = 0 ; s < subtype_count ; s++)
+ { info.format = s ;
+ sf_command (NULL, SFC_GET_FORMAT_SUBTYPE, &info, sizeof (info)) ;
+
+ have_vorbis = info.format == SF_FORMAT_VORBIS ? 1 : have_vorbis ;
+ } ;
+
+ if (HAVE_EXTERNAL_LIBS)
+ exit_if_true (have_vorbis == 0, "\n\nLine %d : Ogg/Vorbis should be available.\n\n", __LINE__) ;
+ else
+ exit_if_true (have_vorbis, "\n\nLine %d : Ogg/Vorbis should not be available.\n\n", __LINE__) ;
+
+ puts ("ok") ;
+} /* subtype_format_test */
+
+static void
+simple_format_test (void)
+{ SF_FORMAT_INFO info ;
+ int have_flac = 0, have_ogg = 0, have_vorbis = 0 ;
+ int s, simple_count ;
+
+ print_test_name (__func__, NULL) ;
+
+ sf_command (NULL, SFC_GET_SIMPLE_FORMAT_COUNT, &simple_count, sizeof (int)) ;
+
+ for (s = 0 ; s < simple_count ; s++)
+ { info.format = s ;
+ sf_command (NULL, SFC_GET_SIMPLE_FORMAT, &info, sizeof (info)) ;
+
+ switch (info.format & SF_FORMAT_TYPEMASK)
+ { case SF_FORMAT_FLAC :
+ have_flac = 1 ;
+ break ;
+
+ case SF_FORMAT_OGG :
+ have_ogg = 1 ;
+ break ;
+
+ default :
+ break ;
+ } ;
+
+ switch (info.format & SF_FORMAT_SUBMASK)
+ { case SF_FORMAT_VORBIS :
+ have_vorbis = 1 ;
+ break ;
+
+ default :
+ break ;
+ } ;
+
+ } ;
+
+ if (HAVE_EXTERNAL_LIBS)
+ { exit_if_true (have_flac == 0, "\n\nLine %d : FLAC should be available.\n\n", __LINE__) ;
+ exit_if_true (have_ogg == 0, "\n\nLine %d : Ogg/Vorbis should be available.\n\n", __LINE__) ;
+ exit_if_true (have_vorbis == 0, "\n\nLine %d : Ogg/Vorbis should be available.\n\n", __LINE__) ;
+ }
+ else
+ { exit_if_true (have_flac, "\n\nLine %d : FLAC should not be available.\n\n", __LINE__) ;
+ exit_if_true (have_ogg, "\n\nLine %d : Ogg/Vorbis should not be available.\n\n", __LINE__) ;
+ exit_if_true (have_vorbis, "\n\nLine %d : Ogg/Vorbis should not be available.\n\n", __LINE__) ;
+ } ;
+
+ puts ("ok") ;
+} /* simple_format_test */
Modified: freeswitch/trunk/libs/libsndfile/tests/fix_this.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/tests/fix_this.c (original)
+++ freeswitch/trunk/libs/libsndfile/tests/fix_this.c Thu May 21 16:09:30 2009
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 1999-2004 Erik de Castro Lopo <erikd at mega-nerd.com>
+** Copyright (C) 1999-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
@@ -45,8 +45,8 @@
*/
typedef union
-{ double d [BUFFER_SIZE + 1];
- int i [BUFFER_SIZE + 1];
+{ double d [BUFFER_SIZE + 1] ;
+ int i [BUFFER_SIZE + 1] ;
} BUFFER ;
static BUFFER data_buffer ;
@@ -322,10 +322,3 @@
return 0 ;
} /* error_function */
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: 368e2777-2848-4e16-a77f-4db841377c73
-*/
Modified: freeswitch/trunk/libs/libsndfile/tests/floating_point_test.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/tests/floating_point_test.c (original)
+++ freeswitch/trunk/libs/libsndfile/tests/floating_point_test.c Thu May 21 16:09:30 2009
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 1999-2005 Erik de Castro Lopo <erikd at mega-nerd.com>
+** Copyright (C) 1999-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
@@ -32,8 +32,6 @@
#include "dft_cmp.h"
#include "utils.h"
-#include "float_cast.h"
-
#define SAMPLE_RATE 16000
static void float_scaled_test (const char *filename, int allow_exit, int replace_float, int filetype, double target_snr) ;
@@ -50,9 +48,11 @@
static double double_data [DFT_DATA_LENGTH] ;
-static double test_data [DFT_DATA_LENGTH] ;
+static double double_test [DFT_DATA_LENGTH] ;
static float float_data [DFT_DATA_LENGTH] ;
+static float float_test [DFT_DATA_LENGTH] ;
+
static double double_data [DFT_DATA_LENGTH] ;
static short short_data [DFT_DATA_LENGTH] ;
static int int_data [DFT_DATA_LENGTH] ;
@@ -110,10 +110,12 @@
float_scaled_test ("pcm_16.sds", allow_exit, SF_FALSE, SF_FORMAT_SDS | SF_FORMAT_PCM_16, -140.0) ;
float_scaled_test ("pcm_24.sds", allow_exit, SF_FALSE, SF_FORMAT_SDS | SF_FORMAT_PCM_24, -170.0) ;
-#ifdef HAVE_FLAC_ALL_H
+#if HAVE_EXTERNAL_LIBS
float_scaled_test ("flac_8.flac", allow_exit, SF_FALSE, SF_FORMAT_FLAC | SF_FORMAT_PCM_S8, -39.0) ;
float_scaled_test ("flac_16.flac", allow_exit, SF_FALSE, SF_FORMAT_FLAC | SF_FORMAT_PCM_16, -87.0) ;
float_scaled_test ("flac_24.flac", allow_exit, SF_FALSE, SF_FORMAT_FLAC | SF_FORMAT_PCM_24, -138.0) ;
+
+ float_scaled_test ("vorbis.oga", allow_exit, SF_FALSE, SF_FORMAT_OGG | SF_FORMAT_VORBIS, -31.0) ;
#endif
float_scaled_test ("replace_float.raw", allow_exit, SF_TRUE, SF_ENDIAN_LITTLE | SF_FORMAT_RAW | SF_FORMAT_FLOAT, -163.0) ;
@@ -160,10 +162,12 @@
double_scaled_test ("pcm_16.sds", allow_exit, SF_FALSE, SF_FORMAT_SDS | SF_FORMAT_PCM_16, -140.0) ;
double_scaled_test ("pcm_24.sds", allow_exit, SF_FALSE, SF_FORMAT_SDS | SF_FORMAT_PCM_24, -180.0) ;
-#ifdef HAVE_FLAC_ALL_H
+#if HAVE_EXTERNAL_LIBS
double_scaled_test ("flac_8.flac", allow_exit, SF_FALSE, SF_FORMAT_FLAC | SF_FORMAT_PCM_S8, -39.0) ;
double_scaled_test ("flac_16.flac", allow_exit, SF_FALSE, SF_FORMAT_FLAC | SF_FORMAT_PCM_16, -87.0) ;
double_scaled_test ("flac_24.flac", allow_exit, SF_FALSE, SF_FORMAT_FLAC | SF_FORMAT_PCM_24, -138.0) ;
+
+ double_scaled_test ("vorbis.oga", allow_exit, SF_FALSE, SF_FORMAT_OGG | SF_FORMAT_VORBIS, -29.0) ;
#endif
double_scaled_test ("replace_double.raw", allow_exit, SF_TRUE, SF_FORMAT_RAW | SF_FORMAT_DOUBLE, -300.0) ;
@@ -189,20 +193,13 @@
static void
float_scaled_test (const char *filename, int allow_exit, int replace_float, int filetype, double target_snr)
-{ static float float_orig [DFT_DATA_LENGTH] ;
- static float float_test [DFT_DATA_LENGTH] ;
-
- SNDFILE *file ;
+{ SNDFILE *file ;
SF_INFO sfinfo ;
- int k ;
double snr ;
print_test_name ("float_scaled_test", filename) ;
- gen_windowed_sine_double (double_data, DFT_DATA_LENGTH, 1.0) ;
-
- for (k = 0 ; k < DFT_DATA_LENGTH ; k++)
- float_orig [k] = double_data [k] ;
+ gen_windowed_sine_float (float_data, DFT_DATA_LENGTH, 1.0) ;
sfinfo.samplerate = SAMPLE_RATE ;
sfinfo.frames = DFT_DATA_LENGTH ;
@@ -212,7 +209,7 @@
file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ;
sf_command (file, SFC_TEST_IEEE_FLOAT_REPLACE, NULL, replace_float) ;
- test_write_float_or_die (file, 0, float_orig, DFT_DATA_LENGTH, __LINE__) ;
+ test_write_float_or_die (file, 0, float_data, DFT_DATA_LENGTH, __LINE__) ;
sf_close (file) ;
@@ -231,10 +228,7 @@
sf_close (file) ;
- for (k = 0 ; k < DFT_DATA_LENGTH ; k++)
- test_data [k] = float_test [k] ;
-
- snr = dft_cmp (__LINE__, double_data, test_data, DFT_DATA_LENGTH, target_snr, allow_exit) ;
+ snr = dft_cmp_float (__LINE__, float_data, float_test, DFT_DATA_LENGTH, target_snr, allow_exit) ;
exit_if_true (snr > target_snr, "% 6.1fdB SNR\n\n Error : should be better than % 6.1fdB\n\n", snr, target_snr) ;
@@ -267,7 +261,7 @@
sf_close (file) ;
- memset (test_data, 0, sizeof (test_data)) ;
+ memset (double_test, 0, sizeof (double_test)) ;
file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ;
sf_command (file, SFC_TEST_IEEE_FLOAT_REPLACE, NULL, replace_float) ;
@@ -278,11 +272,11 @@
check_log_buffer_or_die (file, __LINE__) ;
- test_read_double_or_die (file, 0, test_data, DFT_DATA_LENGTH, __LINE__) ;
+ test_read_double_or_die (file, 0, double_test, DFT_DATA_LENGTH, __LINE__) ;
sf_close (file) ;
- snr = dft_cmp (__LINE__, double_data, test_data, DFT_DATA_LENGTH, target_snr, allow_exit) ;
+ snr = dft_cmp_double (__LINE__, double_data, double_test, DFT_DATA_LENGTH, target_snr, allow_exit) ;
exit_if_true (snr > target_snr, "% 6.1fdB SNR\n\n Error : should be better than % 6.1fdB\n\n", snr, target_snr) ;
@@ -335,7 +329,7 @@
max = 0 ;
for (k = 0 ; k < ARRAY_LEN (short_data) ; k++)
- if (abs (short_data [k]) > max)
+ if ((unsigned) abs (short_data [k]) > max)
max = abs (short_data [k]) ;
if (1.0 * abs (max - 0x7FFF) / 0x7FFF > 0.01)
@@ -385,7 +379,7 @@
max = 0 ;
for (k = 0 ; k < ARRAY_LEN (short_data) ; k++)
- if (abs (short_data [k]) > max)
+ if ((unsigned) abs (short_data [k]) > max)
max = abs (short_data [k]) ;
if (1.0 * abs (max - 0x7FFF) / 0x7FFF > 0.01)
@@ -435,7 +429,7 @@
max = 0 ;
for (k = 0 ; k < ARRAY_LEN (int_data) ; k++)
- if (abs (int_data [k]) > max)
+ if ((unsigned) abs (int_data [k]) > max)
max = abs (int_data [k]) ;
if (1.0 * abs (max - 0x7FFFFFFF) / 0x7FFFFFFF > 0.01)
@@ -485,7 +479,7 @@
max = 0 ;
for (k = 0 ; k < ARRAY_LEN (int_data) ; k++)
- if (abs (int_data [k]) > max)
+ if ((unsigned) abs (int_data [k]) > max)
max = abs (int_data [k]) ;
if (1.0 * abs (max - 0x7FFFFFFF) / 0x7FFFFFFF > 0.01)
@@ -535,7 +529,7 @@
max = 0 ;
for (k = 0 ; k < ARRAY_LEN (short_data) ; k++)
- if (abs (short_data [k]) > max)
+ if ((unsigned) abs (short_data [k]) > max)
max = abs (short_data [k]) ;
if (1.0 * abs (max - 0x7FFF) / 0x7FFF > 0.01)
@@ -585,7 +579,7 @@
max = 0 ;
for (k = 0 ; k < ARRAY_LEN (short_data) ; k++)
- if (abs (short_data [k]) > max)
+ if ((unsigned) abs (short_data [k]) > max)
max = abs (short_data [k]) ;
if (1.0 * abs (max - 0x7FFF) / 0x7FFF > 0.01)
@@ -635,7 +629,7 @@
max = 0 ;
for (k = 0 ; k < ARRAY_LEN (int_data) ; k++)
- if (abs (int_data [k]) > max)
+ if ((unsigned) abs (int_data [k]) > max)
max = abs (int_data [k]) ;
if (1.0 * abs (max - 0x7FFFFFFF) / 0x7FFFFFFF > 0.01)
@@ -685,7 +679,7 @@
max = 0 ;
for (k = 0 ; k < ARRAY_LEN (int_data) ; k++)
- if (abs (int_data [k]) > max)
+ if ((unsigned) abs (int_data [k]) > max)
max = abs (int_data [k]) ;
if (1.0 * abs (max - 0x7FFFFFFF) / 0x7FFFFFFF > 0.01)
@@ -698,4 +692,3 @@
} /* double_int_big_test */
-
Modified: freeswitch/trunk/libs/libsndfile/tests/floating_point_test.def
==============================================================================
--- freeswitch/trunk/libs/libsndfile/tests/floating_point_test.def (original)
+++ freeswitch/trunk/libs/libsndfile/tests/floating_point_test.def Thu May 21 16:09:30 2009
@@ -30,11 +30,3 @@
int_max = 0x7FFFFFFF ;
} ;
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: 053997cb-74d9-424e-aabf-3ad7622e3eee
-*/
-
Modified: freeswitch/trunk/libs/libsndfile/tests/floating_point_test.tpl
==============================================================================
--- freeswitch/trunk/libs/libsndfile/tests/floating_point_test.tpl (original)
+++ freeswitch/trunk/libs/libsndfile/tests/floating_point_test.tpl Thu May 21 16:09:30 2009
@@ -1,6 +1,6 @@
[+ AutoGen5 template c +]
/*
-** Copyright (C) 1999-2005 Erik de Castro Lopo <erikd at mega-nerd.com>
+** Copyright (C) 1999-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
@@ -33,22 +33,22 @@
#include "dft_cmp.h"
#include "utils.h"
-#include "float_cast.h"
-
#define SAMPLE_RATE 16000
static void float_scaled_test (const char *filename, int allow_exit, int replace_float, int filetype, double target_snr) ;
static void double_scaled_test (const char *filename, int allow_exit, int replace_float, int filetype, double target_snr) ;
-[+ FOR float_type +][+ FOR int_type +][+ FOR endian_type
+[+ FOR float_type +][+ FOR int_type +][+ FOR endian_type
+]static void [+ (get "float_name") +]_[+ (get "int_name") +]_[+ (get "end_name") +]_test (const char * filename) ;
-[+ ENDFOR endian_type +][+ ENDFOR int_type +][+ ENDFOR float_type
+[+ ENDFOR endian_type +][+ ENDFOR int_type +][+ ENDFOR float_type
+]
static double double_data [DFT_DATA_LENGTH] ;
-static double test_data [DFT_DATA_LENGTH] ;
+static double double_test [DFT_DATA_LENGTH] ;
static float float_data [DFT_DATA_LENGTH] ;
+static float float_test [DFT_DATA_LENGTH] ;
+
static double double_data [DFT_DATA_LENGTH] ;
static short short_data [DFT_DATA_LENGTH] ;
static int int_data [DFT_DATA_LENGTH] ;
@@ -106,10 +106,12 @@
float_scaled_test ("pcm_16.sds", allow_exit, SF_FALSE, SF_FORMAT_SDS | SF_FORMAT_PCM_16, -140.0) ;
float_scaled_test ("pcm_24.sds", allow_exit, SF_FALSE, SF_FORMAT_SDS | SF_FORMAT_PCM_24, -170.0) ;
-#ifdef HAVE_FLAC_ALL_H
+#if HAVE_EXTERNAL_LIBS
float_scaled_test ("flac_8.flac", allow_exit, SF_FALSE, SF_FORMAT_FLAC | SF_FORMAT_PCM_S8, -39.0) ;
float_scaled_test ("flac_16.flac", allow_exit, SF_FALSE, SF_FORMAT_FLAC | SF_FORMAT_PCM_16, -87.0) ;
float_scaled_test ("flac_24.flac", allow_exit, SF_FALSE, SF_FORMAT_FLAC | SF_FORMAT_PCM_24, -138.0) ;
+
+ float_scaled_test ("vorbis.oga", allow_exit, SF_FALSE, SF_FORMAT_OGG | SF_FORMAT_VORBIS, -31.0) ;
#endif
float_scaled_test ("replace_float.raw", allow_exit, SF_TRUE, SF_ENDIAN_LITTLE | SF_FORMAT_RAW | SF_FORMAT_FLOAT, -163.0) ;
@@ -156,19 +158,21 @@
double_scaled_test ("pcm_16.sds", allow_exit, SF_FALSE, SF_FORMAT_SDS | SF_FORMAT_PCM_16, -140.0) ;
double_scaled_test ("pcm_24.sds", allow_exit, SF_FALSE, SF_FORMAT_SDS | SF_FORMAT_PCM_24, -180.0) ;
-#ifdef HAVE_FLAC_ALL_H
+#if HAVE_EXTERNAL_LIBS
double_scaled_test ("flac_8.flac", allow_exit, SF_FALSE, SF_FORMAT_FLAC | SF_FORMAT_PCM_S8, -39.0) ;
double_scaled_test ("flac_16.flac", allow_exit, SF_FALSE, SF_FORMAT_FLAC | SF_FORMAT_PCM_16, -87.0) ;
double_scaled_test ("flac_24.flac", allow_exit, SF_FALSE, SF_FORMAT_FLAC | SF_FORMAT_PCM_24, -138.0) ;
+
+ double_scaled_test ("vorbis.oga", allow_exit, SF_FALSE, SF_FORMAT_OGG | SF_FORMAT_VORBIS, -29.0) ;
#endif
double_scaled_test ("replace_double.raw", allow_exit, SF_TRUE, SF_FORMAT_RAW | SF_FORMAT_DOUBLE, -300.0) ;
putchar ('\n') ;
/* Float int tests. */
-[+ FOR float_type +][+ FOR int_type +][+ FOR endian_type
+[+ FOR float_type +][+ FOR int_type +][+ FOR endian_type
+] [+ (get "float_name") +]_[+ (get "int_name") +]_[+ (get "end_name") +]_test ("[+ (get "float_name") +]_[+ (get "int_name") +]_[+ (get "end_name") +].au") ;
-[+ ENDFOR endian_type +][+ ENDFOR int_type +][+ ENDFOR float_type
+[+ ENDFOR endian_type +][+ ENDFOR int_type +][+ ENDFOR float_type
+]
return 0 ;
@@ -180,20 +184,13 @@
static void
float_scaled_test (const char *filename, int allow_exit, int replace_float, int filetype, double target_snr)
-{ static float float_orig [DFT_DATA_LENGTH] ;
- static float float_test [DFT_DATA_LENGTH] ;
-
- SNDFILE *file ;
+{ SNDFILE *file ;
SF_INFO sfinfo ;
- int k ;
double snr ;
print_test_name ("float_scaled_test", filename) ;
- gen_windowed_sine_double (double_data, DFT_DATA_LENGTH, 1.0) ;
-
- for (k = 0 ; k < DFT_DATA_LENGTH ; k++)
- float_orig [k] = double_data [k] ;
+ gen_windowed_sine_float (float_data, DFT_DATA_LENGTH, 1.0) ;
sfinfo.samplerate = SAMPLE_RATE ;
sfinfo.frames = DFT_DATA_LENGTH ;
@@ -203,7 +200,7 @@
file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ;
sf_command (file, SFC_TEST_IEEE_FLOAT_REPLACE, NULL, replace_float) ;
- test_write_float_or_die (file, 0, float_orig, DFT_DATA_LENGTH, __LINE__) ;
+ test_write_float_or_die (file, 0, float_data, DFT_DATA_LENGTH, __LINE__) ;
sf_close (file) ;
@@ -222,10 +219,7 @@
sf_close (file) ;
- for (k = 0 ; k < DFT_DATA_LENGTH ; k++)
- test_data [k] = float_test [k] ;
-
- snr = dft_cmp (__LINE__, double_data, test_data, DFT_DATA_LENGTH, target_snr, allow_exit) ;
+ snr = dft_cmp_float (__LINE__, float_data, float_test, DFT_DATA_LENGTH, target_snr, allow_exit) ;
exit_if_true (snr > target_snr, "% 6.1fdB SNR\n\n Error : should be better than % 6.1fdB\n\n", snr, target_snr) ;
@@ -258,7 +252,7 @@
sf_close (file) ;
- memset (test_data, 0, sizeof (test_data)) ;
+ memset (double_test, 0, sizeof (double_test)) ;
file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ;
sf_command (file, SFC_TEST_IEEE_FLOAT_REPLACE, NULL, replace_float) ;
@@ -269,11 +263,11 @@
check_log_buffer_or_die (file, __LINE__) ;
- test_read_double_or_die (file, 0, test_data, DFT_DATA_LENGTH, __LINE__) ;
+ test_read_double_or_die (file, 0, double_test, DFT_DATA_LENGTH, __LINE__) ;
sf_close (file) ;
- snr = dft_cmp (__LINE__, double_data, test_data, DFT_DATA_LENGTH, target_snr, allow_exit) ;
+ snr = dft_cmp_double (__LINE__, double_data, double_test, DFT_DATA_LENGTH, target_snr, allow_exit) ;
exit_if_true (snr > target_snr, "% 6.1fdB SNR\n\n Error : should be better than % 6.1fdB\n\n", snr, target_snr) ;
@@ -287,7 +281,7 @@
/*==============================================================================
*/
-[+ FOR float_type +][+ FOR int_type +][+ FOR endian_type
+[+ FOR float_type +][+ FOR int_type +][+ FOR endian_type
+]
static void
[+ (get "float_name") +]_[+ (get "int_name") +]_[+ (get "end_name") +]_test (const char * filename)
@@ -327,7 +321,7 @@
max = 0 ;
for (k = 0 ; k < ARRAY_LEN ([+ (get "int_name") +]_data) ; k++)
- if (abs ([+ (get "int_name") +]_data [k]) > max)
+ if ((unsigned) abs ([+ (get "int_name") +]_data [k]) > max)
max = abs ([+ (get "int_name") +]_data [k]) ;
if (1.0 * abs (max - [+ (get "int_max") +]) / [+ (get "int_max") +] > 0.01)
@@ -340,12 +334,3 @@
} /* [+ (get "float_name") +]_[+ (get "int_name") +]_[+ (get "end_name") +]_test */
[+ ENDFOR endian_type +][+ ENDFOR int_type +][+ ENDFOR float_type +]
-[+ COMMENT
-
- Do not edit or modify anything in this comment block.
- The arch-tag line is a file identity tag for the GNU Arch
- revision control system.
-
- arch-tag: c1043a35-f0aa-44af-9f7f-f193c67f140d
-
-+]
Added: freeswitch/trunk/libs/libsndfile/tests/generate.c
==============================================================================
--- (empty file)
+++ freeswitch/trunk/libs/libsndfile/tests/generate.c Thu May 21 16:09:30 2009
@@ -0,0 +1,73 @@
+/*
+** Copyright (C) 2007-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
+**
+** This program is free software; you can redistribute it and/or modify
+** it under the terms of the GNU General Public License as published by
+** the Free Software Foundation; either version 2 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <math.h>
+
+#include <sndfile.h>
+
+#include "utils.h"
+#include "generate.h"
+
+#define SF_MAX(x,y) ((x) > (y) ? (x) : (y))
+
+static float crappy_snare (float *output, int len, int offset, float gain, float maxabs) ;
+
+void
+generate_file (const char * filename, int format, int len)
+{ float * output ;
+ float maxabs = 0.0 ;
+
+ output = calloc (len, sizeof (float)) ;
+
+ maxabs = crappy_snare (output, len, 0, 0.95, maxabs) ;
+ maxabs = crappy_snare (output, len, len / 4, 0.85, maxabs) ;
+ maxabs = crappy_snare (output, len, 2 * len / 4, 0.85, maxabs) ;
+ maxabs = crappy_snare (output, len, 3 * len / 4, 0.85, maxabs) ;
+
+ write_mono_file (filename, format, 44100, output, len) ;
+
+ free (output) ;
+} /* generate_file */
+
+static inline float
+rand_float (void)
+{ return rand () / (0.5 * RAND_MAX) - 1.0 ;
+} /* rand_float */
+
+static float
+crappy_snare (float *output, int len, int offset, float gain, float maxabs)
+{ int k ;
+ float env = 0.0 ;
+
+ for (k = offset ; k < len && env < gain ; k++)
+ { env += 0.03 ;
+ output [k] += env * rand_float () ;
+ maxabs = SF_MAX (maxabs, fabs (output [k])) ;
+ } ;
+
+ for ( ; k < len && env > 1e-8 ; k++)
+ { env *= 0.995 ;
+ output [k] += env * rand_float () ;
+ maxabs = SF_MAX (maxabs, fabs (output [k])) ;
+ } ;
+
+ return maxabs ;
+} /* crappy_snare */
Added: freeswitch/trunk/libs/libsndfile/tests/generate.h
==============================================================================
--- (empty file)
+++ freeswitch/trunk/libs/libsndfile/tests/generate.h Thu May 21 16:09:30 2009
@@ -0,0 +1,19 @@
+/*
+** Copyright (C) 2007-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
+**
+** This program is free software; you can redistribute it and/or modify
+** it under the terms of the GNU General Public License as published by
+** the Free Software Foundation; either version 2 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+void generate_file (const char * filename, int format, int len) ;
Modified: freeswitch/trunk/libs/libsndfile/tests/header_test.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/tests/header_test.c (original)
+++ freeswitch/trunk/libs/libsndfile/tests/header_test.c Thu May 21 16:09:30 2009
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 2001-2005 Erik de Castro Lopo <erikd at mega-nerd.com>
+** Copyright (C) 2001-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
**
** This program is free software ; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
@@ -55,6 +55,8 @@
static void extra_header_test (const char *filename, int filetype) ;
+static void header_shrink_test (const char *filename, int filetype) ;
+
/* Force the start of this buffer to be double aligned. Sparc-solaris will
** choke if its not.
*/
@@ -83,7 +85,16 @@
update_seek_int_test ("header_int.wav", SF_FORMAT_WAV) ;
update_seek_float_test ("header_float.wav", SF_FORMAT_WAV) ;
update_seek_double_test ("header_double.wav", SF_FORMAT_WAV) ;
+ header_shrink_test ("header_shrink.wav", SF_FORMAT_WAV) ;
extra_header_test ("extra.wav", SF_FORMAT_WAV) ;
+
+ update_header_test ("header.wavex", SF_FORMAT_WAVEX) ;
+ update_seek_short_test ("header_short.wavex", SF_FORMAT_WAVEX) ;
+ update_seek_int_test ("header_int.wavex", SF_FORMAT_WAVEX) ;
+ update_seek_float_test ("header_float.wavex", SF_FORMAT_WAVEX) ;
+ update_seek_double_test ("header_double.wavex", SF_FORMAT_WAVEX) ;
+ header_shrink_test ("header_shrink.wavex", SF_FORMAT_WAVEX) ;
+ extra_header_test ("extra.wavex", SF_FORMAT_WAVEX) ;
test_count++ ;
} ;
@@ -93,6 +104,7 @@
update_seek_int_test ("header_int.aiff", SF_FORMAT_AIFF) ;
update_seek_float_test ("header_float.aiff", SF_FORMAT_AIFF) ;
update_seek_double_test ("header_double.aiff", SF_FORMAT_AIFF) ;
+ header_shrink_test ("header_shrink.wav", SF_FORMAT_AIFF) ;
extra_header_test ("extra.aiff", SF_FORMAT_AIFF) ;
test_count++ ;
} ;
@@ -144,6 +156,15 @@
test_count++ ;
} ;
+ if (do_all || ! strcmp (argv [1], "rf64"))
+ { update_header_test ("header.rf64", SF_FORMAT_RF64) ;
+ update_seek_short_test ("header_short.rf64", SF_FORMAT_RF64) ;
+ update_seek_int_test ("header_int.rf64", SF_FORMAT_RF64) ;
+ update_seek_float_test ("header_float.rf64", SF_FORMAT_RF64) ;
+ update_seek_double_test ("header_double.rf64", SF_FORMAT_RF64) ;
+ test_count++ ;
+ } ;
+
if (do_all || ! strcmp (argv [1], "mat4"))
{ update_header_test ("header.mat4", SF_FORMAT_MAT4) ;
update_seek_short_test ("header_short.mat4", SF_FORMAT_MAT4) ;
@@ -198,6 +219,12 @@
test_count++ ;
} ;
+ if (do_all || ! strcmp (argv [1], "mpc2k"))
+ { update_header_test ("header.mpc", SF_FORMAT_MPC2K) ;
+ update_seek_short_test ("header_short.mpc", SF_FORMAT_MPC2K) ;
+ test_count++ ;
+ } ;
+
if (test_count == 0)
{ printf ("Mono : ************************************\n") ;
printf ("Mono : * No '%s' test defined.\n", argv [1]) ;
@@ -290,18 +317,6 @@
{
print_test_name ("update_header_test", filename) ;
-#if 0 /*-(OS_IS_WIN32 == 0)-*/
- if (typemajor == SF_FORMAT_PAF)
- { /*
- ** I think this is a bug in the win32 file I/O code in src/file_io.c.
- ** I didn't write that code and I don't have the time to debug and
- ** fix it. Patches will gladly be accepted. Erik
- */
- puts ("doesn't work on win32") ;
- return ;
- } ;
-#endif
-
update_header_sub (filename, typemajor, SFM_WRITE) ;
update_header_sub (filename, typemajor, SFM_RDWR) ;
@@ -378,6 +393,7 @@
puts ("ok") ;
return ;
} /* update_seek_short_test */
+
static void
update_seek_int_test (const char *filename, int filetype)
{ SNDFILE *outfile, *infile ;
@@ -444,6 +460,7 @@
puts ("ok") ;
return ;
} /* update_seek_int_test */
+
static void
update_seek_float_test (const char *filename, int filetype)
{ SNDFILE *outfile, *infile ;
@@ -510,6 +527,7 @@
puts ("ok") ;
return ;
} /* update_seek_float_test */
+
static void
update_seek_double_test (const char *filename, int filetype)
{ SNDFILE *outfile, *infile ;
@@ -579,12 +597,52 @@
+static void
+header_shrink_test (const char *filename, int filetype)
+{ SNDFILE *outfile, *infile ;
+ SF_INFO sfinfo ;
+ sf_count_t frames ;
+ float buffer [8], bufferin [8] ;
+ print_test_name ("header_shrink_test", filename) ;
+
+ memset (&sfinfo, 0, sizeof (sfinfo)) ;
+ sfinfo.samplerate = 44100 ;
+ sfinfo.format = filetype | SF_FORMAT_FLOAT ;
+ sfinfo.channels = 1 ;
+
+ memset (buffer, 0xA0, sizeof (buffer)) ;
+
+ /* Now write some frames. */
+ frames = ARRAY_LEN (buffer) / sfinfo.channels ;
+
+ /* Test the file with extra header data. */
+ outfile = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_FALSE, __LINE__) ;
+
+ sf_command (outfile, SFC_SET_ADD_PEAK_CHUNK, NULL, SF_TRUE) ;
+ sf_command (outfile, SFC_UPDATE_HEADER_NOW, NULL, SF_FALSE) ;
+ sf_command (outfile, SFC_SET_ADD_PEAK_CHUNK, NULL, SF_FALSE) ;
+
+ test_writef_float_or_die (outfile, 0, buffer, frames, __LINE__) ;
+ sf_close (outfile) ;
+
+ /* Open again for read. */
+ infile = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_FALSE, __LINE__) ;
+
+ test_readf_float_or_die (infile, 0, bufferin, frames, __LINE__) ;
+ sf_close (infile) ;
+
+ compare_float_or_die (buffer, bufferin, frames, __LINE__) ;
+
+ unlink (filename) ;
+ puts ("ok") ;
+ return ;
+} /* header_shrink_test */
static void
extra_header_test (const char *filename, int filetype)
-{ SNDFILE *outfile, *infile ;
+{ SNDFILE *outfile ;
SF_INFO sfinfo ;
sf_count_t frames ;
short buffer [8] ;
@@ -602,9 +660,9 @@
frames = ARRAY_LEN (buffer) / sfinfo.channels ;
/* Test the file with extra header data. */
- outfile = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, 409) ;
+ outfile = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, 464) ;
sf_set_string (outfile, SF_STR_TITLE, filename) ;
- test_writef_short_or_die (outfile, k, buffer, frames, 411) ;
+ test_writef_short_or_die (outfile, k, buffer, frames, 466) ;
sf_set_string (outfile, SF_STR_COPYRIGHT, "(c) 1980 Erik") ;
sf_close (outfile) ;
@@ -618,7 +676,7 @@
** integration is done.
*/
- if ((infile = sf_open (filename, SFM_RDWR, &sfinfo)) != NULL)
+ if (sf_open (filename, SFM_RDWR, &sfinfo) != NULL)
{ printf ("\n\nError : should not be able to open this file in SFM_RDWR.\n\n") ;
exit (1) ;
} ;
@@ -631,7 +689,7 @@
hexdump_file (filename, 0, 100000) ;
/* Open again for read/write. */
- outfile = test_open_file_or_die (filename, SFM_RDWR, &sfinfo, 438) ;
+ outfile = test_open_file_or_die (filename, SFM_RDWR, &sfinfo, 493) ;
/*
** In auto header update mode, seeking to the end of the file with
@@ -652,26 +710,26 @@
memset (buffer, 0xA0 + k, sizeof (buffer)) ;
- test_seek_or_die (outfile, k * frames, SEEK_SET, k * frames, sfinfo.channels, 459) ;
- test_seek_or_die (outfile, 0, SEEK_END, k * frames, sfinfo.channels, 460) ;
+ test_seek_or_die (outfile, k * frames, SEEK_SET, k * frames, sfinfo.channels, 514) ;
+ test_seek_or_die (outfile, 0, SEEK_END, k * frames, sfinfo.channels, 515) ;
/* Open file again and make sure no errors in log buffer. */
if (0)
- { infile = test_open_file_or_die (filename, SFM_READ, &sfinfo, 464) ;
- check_log_buffer_or_die (infile, 465) ;
+ { infile = test_open_file_or_die (filename, SFM_READ, &sfinfo, 519) ;
+ check_log_buffer_or_die (infile, 520) ;
sf_close (infile) ;
} ;
if (sfinfo.frames != k * frames)
- { printf ("\n\nLine %d : Incorrect sample count (%ld should be %ld)\n", 470, SF_COUNT_TO_LONG (sfinfo.frames), SF_COUNT_TO_LONG (k + frames)) ;
+ { printf ("\n\nLine %d : Incorrect sample count (%ld should be %ld)\n", 525, SF_COUNT_TO_LONG (sfinfo.frames), SF_COUNT_TO_LONG (k + frames)) ;
dump_log_buffer (infile) ;
exit (1) ;
} ;
if ((k & 1) == 0)
- test_write_short_or_die (outfile, k, buffer, sfinfo.channels * frames, 476) ;
+ test_write_short_or_die (outfile, k, buffer, sfinfo.channels * frames, 531) ;
else
- test_writef_short_or_die (outfile, k, buffer, frames, 478) ;
+ test_writef_short_or_die (outfile, k, buffer, frames, 533) ;
hexdump_file (filename, 0, 100000) ;
} ;
@@ -683,4 +741,3 @@
#endif
} /* extra_header_test */
-
Modified: freeswitch/trunk/libs/libsndfile/tests/header_test.def
==============================================================================
--- freeswitch/trunk/libs/libsndfile/tests/header_test.def (original)
+++ freeswitch/trunk/libs/libsndfile/tests/header_test.def Thu May 21 16:09:30 2009
@@ -20,11 +20,3 @@
format = "SF_FORMAT_DOUBLE" ;
} ;
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: 436e1f37-a274-4377-b8fa-b2e2fc29f85b
-*/
-
Modified: freeswitch/trunk/libs/libsndfile/tests/header_test.tpl
==============================================================================
--- freeswitch/trunk/libs/libsndfile/tests/header_test.tpl (original)
+++ freeswitch/trunk/libs/libsndfile/tests/header_test.tpl Thu May 21 16:09:30 2009
@@ -1,6 +1,6 @@
[+ AutoGen5 template c +]
/*
-** Copyright (C) 2001-2005 Erik de Castro Lopo <erikd at mega-nerd.com>
+** Copyright (C) 2001-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
**
** This program is free software ; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
@@ -55,6 +55,8 @@
static void extra_header_test (const char *filename, int filetype) ;
+static void header_shrink_test (const char *filename, int filetype) ;
+
/* Force the start of this buffer to be double aligned. Sparc-solaris will
** choke if its not.
*/
@@ -83,7 +85,16 @@
update_seek_int_test ("header_int.wav", SF_FORMAT_WAV) ;
update_seek_float_test ("header_float.wav", SF_FORMAT_WAV) ;
update_seek_double_test ("header_double.wav", SF_FORMAT_WAV) ;
+ header_shrink_test ("header_shrink.wav", SF_FORMAT_WAV) ;
extra_header_test ("extra.wav", SF_FORMAT_WAV) ;
+
+ update_header_test ("header.wavex", SF_FORMAT_WAVEX) ;
+ update_seek_short_test ("header_short.wavex", SF_FORMAT_WAVEX) ;
+ update_seek_int_test ("header_int.wavex", SF_FORMAT_WAVEX) ;
+ update_seek_float_test ("header_float.wavex", SF_FORMAT_WAVEX) ;
+ update_seek_double_test ("header_double.wavex", SF_FORMAT_WAVEX) ;
+ header_shrink_test ("header_shrink.wavex", SF_FORMAT_WAVEX) ;
+ extra_header_test ("extra.wavex", SF_FORMAT_WAVEX) ;
test_count++ ;
} ;
@@ -93,6 +104,7 @@
update_seek_int_test ("header_int.aiff", SF_FORMAT_AIFF) ;
update_seek_float_test ("header_float.aiff", SF_FORMAT_AIFF) ;
update_seek_double_test ("header_double.aiff", SF_FORMAT_AIFF) ;
+ header_shrink_test ("header_shrink.wav", SF_FORMAT_AIFF) ;
extra_header_test ("extra.aiff", SF_FORMAT_AIFF) ;
test_count++ ;
} ;
@@ -144,6 +156,15 @@
test_count++ ;
} ;
+ if (do_all || ! strcmp (argv [1], "rf64"))
+ { update_header_test ("header.rf64", SF_FORMAT_RF64) ;
+ update_seek_short_test ("header_short.rf64", SF_FORMAT_RF64) ;
+ update_seek_int_test ("header_int.rf64", SF_FORMAT_RF64) ;
+ update_seek_float_test ("header_float.rf64", SF_FORMAT_RF64) ;
+ update_seek_double_test ("header_double.rf64", SF_FORMAT_RF64) ;
+ test_count++ ;
+ } ;
+
if (do_all || ! strcmp (argv [1], "mat4"))
{ update_header_test ("header.mat4", SF_FORMAT_MAT4) ;
update_seek_short_test ("header_short.mat4", SF_FORMAT_MAT4) ;
@@ -198,6 +219,12 @@
test_count++ ;
} ;
+ if (do_all || ! strcmp (argv [1], "mpc2k"))
+ { update_header_test ("header.mpc", SF_FORMAT_MPC2K) ;
+ update_seek_short_test ("header_short.mpc", SF_FORMAT_MPC2K) ;
+ test_count++ ;
+ } ;
+
if (test_count == 0)
{ printf ("Mono : ************************************\n") ;
printf ("Mono : * No '%s' test defined.\n", argv [1]) ;
@@ -290,18 +317,6 @@
{
print_test_name ("update_header_test", filename) ;
-#if 0 /*-(OS_IS_WIN32 == 0)-*/
- if (typemajor == SF_FORMAT_PAF)
- { /*
- ** I think this is a bug in the win32 file I/O code in src/file_io.c.
- ** I didn't write that code and I don't have the time to debug and
- ** fix it. Patches will gladly be accepted. Erik
- */
- puts ("doesn't work on win32") ;
- return ;
- } ;
-#endif
-
update_header_sub (filename, typemajor, SFM_WRITE) ;
update_header_sub (filename, typemajor, SFM_RDWR) ;
@@ -379,11 +394,51 @@
puts ("ok") ;
return ;
} /* update_seek_[+ (get "name") +]_test */
+
[+ ENDFOR data_type
+]
+static void
+header_shrink_test (const char *filename, int filetype)
+{ SNDFILE *outfile, *infile ;
+ SF_INFO sfinfo ;
+ sf_count_t frames ;
+ float buffer [8], bufferin [8] ;
+ print_test_name ("header_shrink_test", filename) ;
+ memset (&sfinfo, 0, sizeof (sfinfo)) ;
+ sfinfo.samplerate = 44100 ;
+ sfinfo.format = filetype | SF_FORMAT_FLOAT ;
+ sfinfo.channels = 1 ;
+
+ memset (buffer, 0xA0, sizeof (buffer)) ;
+
+ /* Now write some frames. */
+ frames = ARRAY_LEN (buffer) / sfinfo.channels ;
+
+ /* Test the file with extra header data. */
+ outfile = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_FALSE, __LINE__) ;
+
+ sf_command (outfile, SFC_SET_ADD_PEAK_CHUNK, NULL, SF_TRUE) ;
+ sf_command (outfile, SFC_UPDATE_HEADER_NOW, NULL, SF_FALSE) ;
+ sf_command (outfile, SFC_SET_ADD_PEAK_CHUNK, NULL, SF_FALSE) ;
+
+ test_writef_float_or_die (outfile, 0, buffer, frames, __LINE__) ;
+ sf_close (outfile) ;
+
+ /* Open again for read. */
+ infile = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_FALSE, __LINE__) ;
+
+ test_readf_float_or_die (infile, 0, bufferin, frames, __LINE__) ;
+ sf_close (infile) ;
+
+ compare_float_or_die (buffer, bufferin, frames, __LINE__) ;
+
+ unlink (filename) ;
+ puts ("ok") ;
+ return ;
+} /* header_shrink_test */
static void
@@ -487,12 +542,3 @@
#endif
} /* extra_header_test */
-[+ COMMENT
-
- Do not edit or modify anything in this comment block.
- The arch-tag line is a file identity tag for the GNU Arch
- revision control system.
-
- arch-tag: ba02b7d6-8a89-45f3-aad2-a50390f52af5
-
-+]
Modified: freeswitch/trunk/libs/libsndfile/tests/headerless_test.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/tests/headerless_test.c (original)
+++ freeswitch/trunk/libs/libsndfile/tests/headerless_test.c Thu May 21 16:09:30 2009
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 1999-2004 Erik de Castro Lopo <erikd at mega-nerd.com>
+** Copyright (C) 1999-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
@@ -104,6 +104,8 @@
check_log_buffer_or_die (file, __LINE__) ;
+ sf_close (file) ;
+
printf ("ok\n") ;
unlink (filename) ;
} /* headerless_test */
@@ -174,14 +176,9 @@
exit (1) ;
} ;
+ sf_close (file) ;
+
printf ("ok\n") ;
unlink (filename) ;
} /* old_test */
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: 0820bc1a-c396-4e66-9997-096999b0bc40
-*/
Modified: freeswitch/trunk/libs/libsndfile/tests/largefile_test.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/tests/largefile_test.c (original)
+++ freeswitch/trunk/libs/libsndfile/tests/largefile_test.c Thu May 21 16:09:30 2009
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 2006 Erik de Castro Lopo <erikd at mega-nerd.com>
+** Copyright (C) 2006-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
@@ -81,10 +81,3 @@
return ;
} /* largefile_test */
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: 4ef10b9a-3356-4b92-8b7b-c60c0c4123fe
-*/
Modified: freeswitch/trunk/libs/libsndfile/tests/locale_test.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/tests/locale_test.c (original)
+++ freeswitch/trunk/libs/libsndfile/tests/locale_test.c Thu May 21 16:09:30 2009
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 2005 Erik de Castro Lopo <erikd at mega-nerd.com>
+** Copyright (C) 2005-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
@@ -48,8 +48,11 @@
{ "en_AU", "kangaroo.au", 11 },
{ "POSIX", "posix.au", 8 },
{ "pt_PT", "concei\303\247\303\243o.au", 12 },
+
+#if OS_IS_WIN32 == 0
{ "ja_JP", "\343\201\212\343\201\257\343\202\210\343\201\206\343\201\224\343\201\226\343\201\204\343\201\276\343\201\231.au", 21 },
{ "vi_VN", "qu\341\273\221c ng\341\273\257.au", 11 },
+#endif
{ NULL, NULL, 0 }
} ;
@@ -104,11 +107,3 @@
#endif
} /* locale_test */
-
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: 087b25a3-03a2-4195-acd2-23fbbc489021
-*/
Modified: freeswitch/trunk/libs/libsndfile/tests/lossy_comp_test.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/tests/lossy_comp_test.c (original)
+++ freeswitch/trunk/libs/libsndfile/tests/lossy_comp_test.c Thu May 21 16:09:30 2009
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 1999-2005 Erik de Castro Lopo <erikd at mega-nerd.com>
+** Copyright (C) 1999-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
@@ -38,6 +38,8 @@
#define M_PI 3.14159265358979323846264338
#endif
+#define LCT_MAX(x,y) ((x) > (y) ? (x) : (y))
+
static void lcomp_test_short (const char *filename, int filetype, int chan, double margin) ;
static void lcomp_test_int (const char *filename, int filetype, int chan, double margin) ;
static void lcomp_test_float (const char *filename, int filetype, int chan, double margin) ;
@@ -48,6 +50,8 @@
static void sdlcomp_test_float (const char *filename, int filetype, int chan, double margin) ;
static void sdlcomp_test_double (const char *filename, int filetype, int chan, double margin) ;
+static void read_raw_test (const char *filename, int filetype, int chan) ;
+
static int error_function (double data, double orig, double margin) ;
static int decay_response (int k) ;
@@ -58,18 +62,20 @@
static void smoothed_diff_float (float *data, unsigned int datalen) ;
static void smoothed_diff_double (double *data, unsigned int datalen) ;
-static void check_comment (SNDFILE * file, int format, int lineno) ;
+static void check_comment (SNDFILE * file, int format, int lineno) ;
+
+static int is_lossy (int filetype) ;
/*
** Force the start of these buffers to be double aligned. Sparc-solaris will
** choke if they are not.
*/
typedef union
-{ double d [BUFFER_SIZE + 1] ;
- float f [BUFFER_SIZE + 1] ;
- int i [BUFFER_SIZE + 1] ;
- short s [BUFFER_SIZE + 1] ;
- char c [BUFFER_SIZE + 1] ;
+{ double d [BUFFER_SIZE + 1] ;
+ float f [BUFFER_SIZE + 1] ;
+ int i [BUFFER_SIZE + 1] ;
+ short s [BUFFER_SIZE + 1] ;
+ char c [BUFFER_SIZE + 1] ;
} BUFFER ;
static BUFFER data_buffer ;
@@ -96,22 +102,25 @@
printf (" wav_gsm610 - test GSM 6.10 WAV file functions\n") ;
printf (" wav_ulaw - test u-law WAV file functions\n") ;
printf (" wav_alaw - test A-law WAV file functions\n") ;
+ printf (" wve - test Psion WVE file functions\n") ;
printf (" all - perform all tests\n") ;
exit (1) ;
} ;
do_all = ! strcmp (argv [1], "all") ;
- if (strcmp (argv [1], "wav_pcm") == 0)
+ if (do_all || strcmp (argv [1], "wav_pcm") == 0)
{ /* This is just a sanity test for PCM encoding. */
- lcomp_test_short ("pcm.wav", SF_FORMAT_WAV | SF_FORMAT_PCM_16, 2, 0.00001) ;
- lcomp_test_int ("pcm.wav", SF_FORMAT_WAV | SF_FORMAT_PCM_16, 2, 0.00001) ;
- lcomp_test_short ("pcm.rifx", SF_ENDIAN_BIG | SF_FORMAT_WAV | SF_FORMAT_PCM_16, 2, 0.00001) ;
- lcomp_test_int ("pcm.rifx", SF_ENDIAN_BIG | SF_FORMAT_WAV | SF_FORMAT_PCM_16, 2, 0.00001) ;
+ lcomp_test_short ("pcm.wav", SF_FORMAT_WAV | SF_FORMAT_PCM_16, 2, 1e-50) ;
+ lcomp_test_int ("pcm.wav", SF_FORMAT_WAV | SF_FORMAT_PCM_32, 2, 1e-50) ;
+ lcomp_test_short ("pcm.rifx", SF_ENDIAN_BIG | SF_FORMAT_WAV | SF_FORMAT_PCM_16, 2, 1e-50) ;
+ lcomp_test_int ("pcm.rifx", SF_ENDIAN_BIG | SF_FORMAT_WAV | SF_FORMAT_PCM_32, 2, 1e-50) ;
/* Lite remove start */
- lcomp_test_float ("pcm.wav", SF_FORMAT_WAV | SF_FORMAT_PCM_16, 2, 0.005) ;
- lcomp_test_double ("pcm.wav", SF_FORMAT_WAV | SF_FORMAT_PCM_16, 2, 0.005) ;
+ lcomp_test_float ("pcm.wav", SF_FORMAT_WAV | SF_FORMAT_FLOAT, 2, 1e-50) ;
+ lcomp_test_double ("pcm.wav", SF_FORMAT_WAV | SF_FORMAT_DOUBLE, 2, 1e-50) ;
/* Lite remove end */
+
+ read_raw_test ("pcm.wav", SF_FORMAT_WAV | SF_FORMAT_PCM_U8, 2) ;
test_count++ ;
} ;
@@ -119,7 +128,7 @@
/* Lite remove start */
if (do_all || strcmp (argv [1], "wav_ima") == 0)
{ lcomp_test_short ("ima.wav", SF_FORMAT_WAV | SF_FORMAT_IMA_ADPCM, 2, 0.18) ;
- lcomp_test_int ("ima.wav", SF_FORMAT_WAV | SF_FORMAT_IMA_ADPCM, 2, 0.18) ;
+ lcomp_test_int ("ima.wav", SF_FORMAT_WAV | SF_FORMAT_IMA_ADPCM, 2, 0.65) ;
lcomp_test_float ("ima.wav", SF_FORMAT_WAV | SF_FORMAT_IMA_ADPCM, 2, 0.18) ;
lcomp_test_double ("ima.wav", SF_FORMAT_WAV | SF_FORMAT_IMA_ADPCM, 2, 0.18) ;
@@ -177,6 +186,8 @@
lcomp_test_float ("ulaw.wav", SF_FORMAT_WAV | SF_FORMAT_ULAW, 2, 0.04) ;
lcomp_test_double ("ulaw.wav", SF_FORMAT_WAV | SF_FORMAT_ULAW, 2, 0.04) ;
/* Lite remove end */
+
+ read_raw_test ("ulaw.wav", SF_FORMAT_WAV | SF_FORMAT_ULAW, 2) ;
test_count++ ;
} ;
@@ -187,6 +198,8 @@
lcomp_test_float ("alaw.wav", SF_FORMAT_WAV | SF_FORMAT_ALAW, 2, 0.04) ;
lcomp_test_double ("alaw.wav", SF_FORMAT_WAV | SF_FORMAT_ALAW, 2, 0.04) ;
/* Lite remove end */
+
+ read_raw_test ("alaw.wav", SF_FORMAT_WAV | SF_FORMAT_ALAW, 2) ;
test_count++ ;
} ;
@@ -212,6 +225,8 @@
lcomp_test_float ("ulaw.aiff", SF_FORMAT_AIFF | SF_FORMAT_ULAW, 2, 0.04) ;
lcomp_test_double ("ulaw.aiff", SF_FORMAT_AIFF | SF_FORMAT_ULAW, 2, 0.04) ;
/* Lite remove end */
+
+ read_raw_test ("ulaw.aiff", SF_FORMAT_AIFF | SF_FORMAT_ULAW, 2) ;
test_count++ ;
} ;
@@ -222,6 +237,8 @@
lcomp_test_float ("alaw.aiff", SF_FORMAT_AIFF | SF_FORMAT_ALAW, 2, 0.04) ;
lcomp_test_double ("alaw.aiff", SF_FORMAT_AIFF | SF_FORMAT_ALAW, 2, 0.04) ;
/* Lite remove end */
+
+ read_raw_test ("alaw.aiff", SF_FORMAT_AIFF | SF_FORMAT_ALAW, 2) ;
test_count++ ;
} ;
@@ -288,10 +305,10 @@
lcomp_test_float ("g723_24.au", SF_ENDIAN_LITTLE | SF_FORMAT_AU | SF_FORMAT_G723_24, 1, 0.7) ;
lcomp_test_double ("g723_24.au", SF_ENDIAN_BIG | SF_FORMAT_AU | SF_FORMAT_G723_24, 1, 0.7) ;
- lcomp_test_short ("g723_40.au", SF_ENDIAN_LITTLE | SF_FORMAT_AU | SF_FORMAT_G723_40, 1, 0.21) ;
- lcomp_test_int ("g723_40.au", SF_ENDIAN_BIG | SF_FORMAT_AU | SF_FORMAT_G723_40, 1, 0.21) ;
- lcomp_test_float ("g723_40.au", SF_ENDIAN_LITTLE | SF_FORMAT_AU | SF_FORMAT_G723_40, 1, 0.21) ;
- lcomp_test_double ("g723_40.au", SF_ENDIAN_BIG | SF_FORMAT_AU | SF_FORMAT_G723_40, 1, 0.21) ;
+ lcomp_test_short ("g723_40.au", SF_ENDIAN_LITTLE | SF_FORMAT_AU | SF_FORMAT_G723_40, 1, 0.85) ;
+ lcomp_test_int ("g723_40.au", SF_ENDIAN_BIG | SF_FORMAT_AU | SF_FORMAT_G723_40, 1, 0.84) ;
+ lcomp_test_float ("g723_40.au", SF_ENDIAN_LITTLE | SF_FORMAT_AU | SF_FORMAT_G723_40, 1, 0.86) ;
+ lcomp_test_double ("g723_40.au", SF_ENDIAN_BIG | SF_FORMAT_AU | SF_FORMAT_G723_40, 1, 0.86) ;
/*- sdlcomp_test_short ("g723.au", SF_ENDIAN_BIG | SF_FORMAT_AU | SF_FORMAT_G723_24, 1, 0.15) ;
sdlcomp_test_int ("g723.au", SF_ENDIAN_LITTLE | SF_FORMAT_AU | SF_FORMAT_G723_24, 1, 0.15) ;
@@ -309,6 +326,8 @@
lcomp_test_float ("ulaw.caf", SF_FORMAT_CAF | SF_FORMAT_ULAW, 2, 0.04) ;
lcomp_test_double ("ulaw.caf", SF_FORMAT_CAF | SF_FORMAT_ULAW, 2, 0.04) ;
/* Lite remove end */
+
+ read_raw_test ("ulaw.caf", SF_FORMAT_CAF | SF_FORMAT_ULAW, 2) ;
test_count++ ;
} ;
@@ -319,6 +338,8 @@
lcomp_test_float ("alaw.caf", SF_FORMAT_CAF | SF_FORMAT_ALAW, 2, 0.04) ;
lcomp_test_double ("alaw.caf", SF_FORMAT_CAF | SF_FORMAT_ALAW, 2, 0.04) ;
/* Lite remove end */
+
+ read_raw_test ("alaw.caf", SF_FORMAT_CAF | SF_FORMAT_ALAW, 2) ;
test_count++ ;
} ;
@@ -352,6 +373,20 @@
test_count++ ;
} ;
+ if (do_all || strcmp (argv [1], "ogg_vorbis") == 0)
+ { if (HAVE_EXTERNAL_LIBS)
+ { /* Don't do lcomp_test_XXX as the errors are too big. */
+ sdlcomp_test_short ("vorbis.oga", SF_FORMAT_OGG | SF_FORMAT_VORBIS, 1, 0.30) ;
+ sdlcomp_test_int ("vorbis.oga", SF_FORMAT_OGG | SF_FORMAT_VORBIS, 1, 0.30) ;
+ sdlcomp_test_float ("vorbis.oga", SF_FORMAT_OGG | SF_FORMAT_VORBIS, 1, 0.30) ;
+ sdlcomp_test_double ("vorbis.oga", SF_FORMAT_OGG | SF_FORMAT_VORBIS, 1, 0.30) ;
+ }
+ else
+ puts (" No Ogg/Vorbis tests because Ogg/Vorbis support was not compiled in.") ;
+
+ test_count++ ;
+ } ;
+
/* Lite remove start */
if (do_all || strcmp (argv [1], "ircam_ulaw") == 0)
{ lcomp_test_short ("ulaw.ircam", SF_ENDIAN_LITTLE | SF_FORMAT_IRCAM | SF_FORMAT_ULAW, 2, 0.04) ;
@@ -409,6 +444,8 @@
lcomp_test_float ("ulaw.w64", SF_FORMAT_W64 | SF_FORMAT_ULAW, 2, 0.04) ;
lcomp_test_double ("ulaw.w64", SF_FORMAT_W64 | SF_FORMAT_ULAW, 2, 0.04) ;
/* Lite remove end */
+
+ read_raw_test ("ulaw.w64", SF_FORMAT_W64 | SF_FORMAT_ULAW, 2) ;
test_count++ ;
} ;
@@ -419,6 +456,8 @@
lcomp_test_float ("alaw.w64", SF_FORMAT_W64 | SF_FORMAT_ALAW, 2, 0.04) ;
lcomp_test_double ("alaw.w64", SF_FORMAT_W64 | SF_FORMAT_ALAW, 2, 0.04) ;
/* Lite remove end */
+
+ read_raw_test ("alaw.w64", SF_FORMAT_W64 | SF_FORMAT_ALAW, 2) ;
test_count++ ;
} ;
@@ -448,6 +487,17 @@
sdlcomp_test_double ("msadpcm.w64", SF_FORMAT_W64 | SF_FORMAT_MS_ADPCM, 2, 0.36) ;
test_count++ ;
} ;
+
+ if (do_all || strcmp (argv [1], "wve") == 0)
+ { lcomp_test_short ("psion.wve", SF_FORMAT_WVE | SF_FORMAT_ALAW, 1, 0.04) ;
+ lcomp_test_int ("psion.wve", SF_FORMAT_WVE | SF_FORMAT_ALAW, 1, 0.04) ;
+ /* Lite remove start */
+ lcomp_test_float ("psion.wve", SF_FORMAT_WVE | SF_FORMAT_ALAW, 1, 0.04) ;
+ lcomp_test_double ("psion.wve", SF_FORMAT_WVE | SF_FORMAT_ALAW, 1, 0.04) ;
+ /* Lite remove end */
+ test_count++ ;
+ } ;
+
/* Lite remove end */
if (do_all || strcmp (argv [1], "w64_gsm610") == 0)
@@ -505,7 +555,7 @@
lcomp_test_short (const char *filename, int filetype, int channels, double margin)
{ SNDFILE *file ;
SF_INFO sfinfo ;
- int k, m, seekpos, sum_abs ;
+ int k, m, seekpos, half_max_abs ;
long datalen ;
short *orig, *data ;
@@ -563,17 +613,17 @@
test_readf_short_or_die (file, 0, data, datalen, __LINE__) ;
- sum_abs = 0 ;
+ half_max_abs = 0 ;
for (k = 0 ; k < datalen ; k++)
{ if (error_function (data [k], orig [k], margin))
{ printf ("\n\nLine %d: Incorrect sample A (#%d : %d should be %d).\n", __LINE__, k, data [k], orig [k]) ;
oct_save_short (orig, data, datalen) ;
exit (1) ;
} ;
- sum_abs = abs (sum_abs + abs (data [k])) ;
+ half_max_abs = LCT_MAX (half_max_abs, abs (data [k] / 2)) ;
} ;
- if (sum_abs < 1.0)
+ if (half_max_abs < 1.0)
{ printf ("\n\nLine %d: Signal is all zeros.\n", __LINE__) ;
exit (1) ;
} ;
@@ -611,7 +661,7 @@
{ test_readf_short_or_die (file, m, data, 11, __LINE__) ;
for (k = 0 ; k < channels * 11 ; k++)
- if (error_function ((double) data [k], (double) orig [k + channels * m * 11], margin))
+ if (error_function (1.0 * data [k], 1.0 * orig [k + channels * m * 11], margin))
{ printf ("\n\nLine %d: Incorrect sample (m = %d) (#%d : %d => %d).\n", __LINE__, m, k + channels * m * 11, orig [k + channels * m * 11], data [k]) ;
for (m = 0 ; m < channels ; m++)
printf ("%d ", data [m]) ;
@@ -630,7 +680,7 @@
test_readf_short_or_die (file, 0, data, 1, __LINE__) ;
- if (error_function ((double) data [0], (double) orig [seekpos * channels], margin))
+ if (error_function (1.0 * data [0], 1.0 * orig [seekpos * channels], margin))
{ printf ("\n\nLine %d: sf_seek (SEEK_SET) followed by sf_readf_short failed (%d, %d).\n", __LINE__, orig [1], data [0]) ;
exit (1) ;
} ;
@@ -643,7 +693,7 @@
seekpos = sf_seek (file, 0, SEEK_CUR) + BUFFER_SIZE / 5 ;
k = sf_seek (file, BUFFER_SIZE / 5, SEEK_CUR) ;
test_readf_short_or_die (file, 0, data, 1, __LINE__) ;
- if (error_function ((double) data [0], (double) orig [seekpos * channels], margin) || k != seekpos)
+ if (error_function (1.0 * data [0], 1.0 * orig [seekpos * channels], margin) || k != seekpos)
{ printf ("\n\nLine %d: sf_seek (forwards, SEEK_CUR) followed by sf_readf_short failed (%d, %d) (%d, %d).\n", __LINE__, data [0], orig [seekpos * channels], k, seekpos + 1) ;
oct_save_short (orig, data, datalen) ;
exit (1) ;
@@ -653,13 +703,13 @@
/* Check seek backward from current position. */
k = sf_seek (file, -20, SEEK_CUR) ;
test_readf_short_or_die (file, 0, data, 1, __LINE__) ;
- if (error_function ((double) data [0], (double) orig [seekpos * channels], margin) || k != seekpos)
- { printf ("sf_seek (backwards, SEEK_CUR) followed by sf_readf_short failed (%d, %d) (%d, %d).\n", data [0], orig [seekpos * channels], k, seekpos) ;
+ if (error_function (1.0 * data [0], 1.0 * orig [seekpos * channels], margin) || k != seekpos)
+ { printf ("\nLine %d: sf_seek (backwards, SEEK_CUR) followed by sf_readf_short failed (%d, %d) (%d, %d).\n", __LINE__, data [0], orig [seekpos * channels], k, seekpos) ;
exit (1) ;
} ;
/* Check that read past end of file returns number of items. */
- sf_seek (file, (short) sfinfo.frames, SEEK_SET) ;
+ sf_seek (file, sfinfo.frames, SEEK_SET) ;
if ((k = sf_readf_short (file, data, datalen)) != 0)
{ printf ("\n\nLine %d: Return value from sf_readf_short past end of file incorrect (%d).\n", __LINE__, k) ;
@@ -667,14 +717,14 @@
} ;
/* Check seek backward from end. */
- if ((k = sf_seek (file, 5 - (short) sfinfo.frames, SEEK_END)) != 5)
- { printf ("sf_seek (SEEK_END) returned %d instead of %d.\n", k, 5) ;
+ if ((k = sf_seek (file, 5 - sfinfo.frames, SEEK_END)) != 5)
+ { printf ("\n\nLine %d: sf_seek (SEEK_END) returned %d instead of %d.\n", __LINE__, k, 5) ;
exit (1) ;
} ;
- test_readf_short_or_die (file, 0, data, channels, __LINE__) ;
- if (error_function ((double) data [0], (double) orig [5], margin))
- { printf ("\n\nLine %d: sf_seek (SEEK_END) followed by sf_readf_short failed (%d should be %d).\n", __LINE__, data [0], orig [5]) ;
+ test_readf_short_or_die (file, 0, data, 1, __LINE__) ;
+ if (error_function (1.0 * data [0], 1.0 * orig [5 * channels], margin))
+ { printf ("\nLine %d: sf_seek (SEEK_END) followed by sf_readf_short failed (%d should be %d).\n", __LINE__, data [0], orig [5 * channels]) ;
exit (1) ;
} ;
@@ -689,24 +739,33 @@
static void
lcomp_test_int (const char *filename, int filetype, int channels, double margin)
-{ SNDFILE *file ;
- SF_INFO sfinfo ;
- int k, m, *orig, *data, sum_abs ;
- long datalen, seekpos ;
- double scale ;
+{ SNDFILE *file ;
+ SF_INFO sfinfo ;
+ int k, m, half_max_abs ;
+ long datalen, seekpos ;
+ double scale, max_val ;
+ int *orig, *data ;
print_test_name ("lcomp_test_int", filename) ;
datalen = BUFFER_SIZE / channels ;
- scale = 1.0 * 0x10000 ;
+ if (is_lossy (filetype))
+ { scale = 1.0 * 0x10000 ;
+ max_val = 32000.0 * scale ;
+ }
+ else
+ { scale = 1.0 ;
+ max_val = 0x7fffffff * scale ;
+ } ;
data = data_buffer.i ;
orig = orig_buffer.i ;
- gen_signal_double (orig_buffer.d, 32000.0 * scale, channels, datalen) ;
+ gen_signal_double (orig_buffer.d, max_val, channels, datalen) ;
+
for (k = 0 ; k < channels * datalen ; k++)
- orig [k] = orig_buffer.d [k] ;
+ orig [k] = lrint (orig_buffer.d [k]) ;
sfinfo.samplerate = SAMPLE_RATE ;
sfinfo.frames = 123456789 ; /* Ridiculous value. */
@@ -751,18 +810,18 @@
test_readf_int_or_die (file, 0, data, datalen, __LINE__) ;
- sum_abs = 0 ;
+ half_max_abs = 0 ;
for (k = 0 ; k < datalen ; k++)
{ if (error_function (data [k] / scale, orig [k] / scale, margin))
- { printf ("\n\nLine %d: Incorrect sample (#%d : %f should be %f).\n", __LINE__, k, data [k] / scale, orig [k] / scale) ;
+ { printf ("\nLine %d: Incorrect sample (#%d : %f should be %f).\n", __LINE__, k, data [k] / scale, orig [k] / scale) ;
oct_save_int (orig, data, datalen) ;
exit (1) ;
} ;
- sum_abs = abs (sum_abs + abs (abs (data [k]) - 256)) ;
+ half_max_abs = LCT_MAX (half_max_abs, abs (data [k] / 2)) ;
} ;
- if (sum_abs < 1.0)
- { printf ("\n\nLine %d: Signal is all zeros (%d, 0x%X).\n", __LINE__, sum_abs, sum_abs) ;
+ if (half_max_abs < 1.0)
+ { printf ("\n\nLine %d: Signal is all zeros (%d, 0x%X).\n", __LINE__, half_max_abs, half_max_abs) ;
exit (1) ;
} ;
@@ -801,7 +860,7 @@
for (k = 0 ; k < channels * 11 ; k++)
if (error_function (data [k] / scale, orig [k + channels * m * 11] / scale, margin))
- { printf ("\n\nLine %d: Incorrect sample (m = %d) (#%d : %d => %d).\n", __LINE__, m, k + channels * m * 11, orig [k + channels * m * 11], data [k]) ;
+ { printf ("\nLine %d: Incorrect sample (m = %d) (#%d : %d => %d).\n", __LINE__, m, k + channels * m * 11, orig [k + channels * m * 11], data [k]) ;
for (m = 0 ; m < channels ; m++)
printf ("%d ", data [m]) ;
printf ("\n") ;
@@ -819,8 +878,8 @@
test_readf_int_or_die (file, 0, data, 1, __LINE__) ;
- if (error_function ((double) data [0], (double) orig [seekpos * channels], margin))
- { printf ("\n\nLine %d: sf_seek (SEEK_SET) followed by sf_readf_int failed (%d, %d).\n", __LINE__, orig [1], data [0]) ;
+ if (error_function (1.0 * data [0], 1.0 * orig [seekpos * channels], margin))
+ { printf ("\nLine %d: sf_seek (SEEK_SET) followed by sf_readf_int failed (%d, %d).\n", __LINE__, orig [1], data [0]) ;
exit (1) ;
} ;
@@ -832,8 +891,8 @@
seekpos = sf_seek (file, 0, SEEK_CUR) + BUFFER_SIZE / 5 ;
k = sf_seek (file, BUFFER_SIZE / 5, SEEK_CUR) ;
test_readf_int_or_die (file, 0, data, 1, __LINE__) ;
- if (error_function ((double) data [0], (double) orig [seekpos * channels], margin) || k != seekpos)
- { printf ("\n\nLine %d: sf_seek (forwards, SEEK_CUR) followed by sf_readf_int failed (%d, %d) (%d, %ld).\n", __LINE__, data [0], orig [seekpos * channels], k, seekpos + 1) ;
+ if (error_function (1.0 * data [0], 1.0 * orig [seekpos * channels], margin) || k != seekpos)
+ { printf ("\nLine %d: sf_seek (forwards, SEEK_CUR) followed by sf_readf_int failed (%d, %d) (%d, %ld).\n", __LINE__, data [0], orig [seekpos * channels], k, seekpos + 1) ;
exit (1) ;
} ;
@@ -841,13 +900,13 @@
/* Check seek backward from current position. */
k = sf_seek (file, -20, SEEK_CUR) ;
test_readf_int_or_die (file, 0, data, 1, __LINE__) ;
- if (error_function ((double) data [0], (double) orig [seekpos * channels], margin) || k != seekpos)
- { printf ("sf_seek (backwards, SEEK_CUR) followed by sf_readf_int failed (%d, %d) (%d, %ld).\n", data [0], orig [seekpos * channels], k, seekpos) ;
+ if (error_function (1.0 * data [0], 1.0 * orig [seekpos * channels], margin) || k != seekpos)
+ { printf ("\nLine %d: sf_seek (backwards, SEEK_CUR) followed by sf_readf_int failed (%d, %d) (%d, %ld).\n", __LINE__, data [0], orig [seekpos * channels], k, seekpos) ;
exit (1) ;
} ;
/* Check that read past end of file returns number of items. */
- sf_seek (file, (int) sfinfo.frames, SEEK_SET) ;
+ sf_seek (file, sfinfo.frames, SEEK_SET) ;
if ((k = sf_readf_int (file, data, datalen)) != 0)
{ printf ("\n\nLine %d: Return value from sf_readf_int past end of file incorrect (%d).\n", __LINE__, k) ;
@@ -855,14 +914,14 @@
} ;
/* Check seek backward from end. */
- if ((k = sf_seek (file, 5 - (int) sfinfo.frames, SEEK_END)) != 5)
- { printf ("sf_seek (SEEK_END) returned %d instead of %d.\n", k, 5) ;
+ if ((k = sf_seek (file, 5 - sfinfo.frames, SEEK_END)) != 5)
+ { printf ("\n\nLine %d: sf_seek (SEEK_END) returned %d instead of %d.\n", __LINE__, k, 5) ;
exit (1) ;
} ;
- test_readf_int_or_die (file, 0, data, channels, __LINE__) ;
- if (error_function (data [0] / scale, orig [5] / scale, margin))
- { printf ("\n\nLine %d: sf_seek (SEEK_END) followed by sf_readf_short failed (%d should be %d).\n", __LINE__, data [0], orig [5]) ;
+ test_readf_int_or_die (file, 0, data, 1, __LINE__) ;
+ if (error_function (data [0] / scale, orig [5 * channels] / scale, margin))
+ { printf ("\nLine %d: sf_seek (SEEK_END) followed by sf_readf_short failed (%d should be %d).\n", __LINE__, data [0], orig [5]) ;
exit (1) ;
} ;
@@ -879,9 +938,10 @@
lcomp_test_float (const char *filename, int filetype, int channels, double margin)
{ SNDFILE *file ;
SF_INFO sfinfo ;
- int k, m, seekpos, sum_abs ;
+ int k, m, seekpos ;
long datalen ;
float *orig, *data ;
+ double half_max_abs ;
print_test_name ("lcomp_test_float", filename) ;
@@ -892,7 +952,7 @@
gen_signal_double (orig_buffer.d, 32000.0, channels, datalen) ;
for (k = 0 ; k < channels * datalen ; k++)
- orig [k] = (float) (orig_buffer.d [k]) ;
+ orig [k] = orig_buffer.d [k] ;
sfinfo.samplerate = SAMPLE_RATE ;
sfinfo.frames = 123456789 ; /* Ridiculous value. */
@@ -944,17 +1004,17 @@
test_readf_float_or_die (file, 0, data, datalen, __LINE__) ;
- sum_abs = 0.0 ;
+ half_max_abs = 0.0 ;
for (k = 0 ; k < datalen ; k++)
- { if (error_function ((double) data [k], (double) orig [k], margin))
- { printf ("\n\nLine %d: Incorrect sample A (#%d : %f should be %f).\n", __LINE__, k, data [k], orig [k]) ;
+ { if (error_function (data [k], orig [k], margin))
+ { printf ("\nLine %d: Incorrect sample A (#%d : %f should be %f).\n", __LINE__, k, data [k], orig [k]) ;
oct_save_float (orig, data, datalen) ;
exit (1) ;
} ;
- sum_abs += fabs (data [k]) ;
+ half_max_abs = LCT_MAX (half_max_abs, fabs (0.5 * data [k])) ;
} ;
- if (sum_abs < 1.0)
+ if (half_max_abs < 1.0)
{ printf ("\n\nLine %d: Signal is all zeros.\n", __LINE__) ;
exit (1) ;
} ;
@@ -993,8 +1053,8 @@
{ test_readf_float_or_die (file, 0, data, 11, __LINE__) ;
for (k = 0 ; k < channels * 11 ; k++)
- if (error_function ((double) data [k], (double) orig [k + channels * m * 11], margin))
- { printf ("\n\nLine %d: Incorrect sample (m = %d) (#%d : %f => %f).\n", __LINE__, m, k + channels * m * 11, orig [k + channels * m * 11], data [k]) ;
+ if (error_function (data [k], orig [k + channels * m * 11], margin))
+ { printf ("\nLine %d: Incorrect sample (m = %d) (#%d : %f => %f).\n", __LINE__, m, k + channels * m * 11, orig [k + channels * m * 11], data [k]) ;
for (m = 0 ; m < channels ; m++)
printf ("%f ", data [m]) ;
printf ("\n") ;
@@ -1012,8 +1072,8 @@
test_readf_float_or_die (file, 0, data, 1, __LINE__) ;
- if (error_function ((double) data [0], (double) orig [seekpos * channels], margin))
- { printf ("\n\nLine %d: sf_seek (SEEK_SET) followed by sf_readf_float failed (%f, %f).\n", __LINE__, orig [1], data [0]) ;
+ if (error_function (data [0], orig [seekpos * channels], margin))
+ { printf ("\nLine %d: sf_seek (SEEK_SET) followed by sf_readf_float failed (%f, %f).\n", __LINE__, orig [1], data [0]) ;
exit (1) ;
} ;
@@ -1025,8 +1085,8 @@
seekpos = sf_seek (file, 0, SEEK_CUR) + BUFFER_SIZE / 5 ;
k = sf_seek (file, BUFFER_SIZE / 5, SEEK_CUR) ;
test_readf_float_or_die (file, 0, data, 1, __LINE__) ;
- if (error_function ((double) data [0], (double) orig [seekpos * channels], margin) || k != seekpos)
- { printf ("\n\nLine %d: sf_seek (forwards, SEEK_CUR) followed by sf_readf_float failed (%f, %f) (%d, %d).\n", __LINE__, data [0], orig [seekpos * channels], k, seekpos + 1) ;
+ if (error_function (data [0], orig [seekpos * channels], margin) || k != seekpos)
+ { printf ("\nLine %d: sf_seek (forwards, SEEK_CUR) followed by sf_readf_float failed (%f, %f) (%d, %d).\n", __LINE__, data [0], orig [seekpos * channels], k, seekpos + 1) ;
exit (1) ;
} ;
@@ -1034,13 +1094,13 @@
/* Check seek backward from current position. */
k = sf_seek (file, -20, SEEK_CUR) ;
test_readf_float_or_die (file, 0, data, 1, __LINE__) ;
- if (error_function ((double) data [0], (double) orig [seekpos * channels], margin) || k != seekpos)
- { printf ("sf_seek (backwards, SEEK_CUR) followed by sf_readf_float failed (%f, %f) (%d, %d).\n", data [0], orig [seekpos * channels], k, seekpos) ;
+ if (error_function (data [0], orig [seekpos * channels], margin) || k != seekpos)
+ { printf ("\nLine %d: sf_seek (backwards, SEEK_CUR) followed by sf_readf_float failed (%f, %f) (%d, %d).\n", __LINE__, data [0], orig [seekpos * channels], k, seekpos) ;
exit (1) ;
} ;
/* Check that read past end of file returns number of items. */
- sf_seek (file, (float) sfinfo.frames, SEEK_SET) ;
+ sf_seek (file, sfinfo.frames, SEEK_SET) ;
if ((k = sf_readf_float (file, data, datalen)) != 0)
{ printf ("\n\nLine %d: Return value from sf_readf_float past end of file incorrect (%d).\n", __LINE__, k) ;
@@ -1048,14 +1108,14 @@
} ;
/* Check seek backward from end. */
- if ((k = sf_seek (file, 5 - (float) sfinfo.frames, SEEK_END)) != 5)
- { printf ("sf_seek (SEEK_END) returned %d instead of %d.\n", k, 5) ;
+ if ((k = sf_seek (file, 5 - sfinfo.frames, SEEK_END)) != 5)
+ { printf ("\n\nLine %d: sf_seek (SEEK_END) returned %d instead of %d.\n", __LINE__, k, 5) ;
exit (1) ;
} ;
- test_readf_float_or_die (file, 0, data, channels, __LINE__) ;
- if (error_function ((double) data [0], (double) orig [5], margin))
- { printf ("\n\nLine %d: sf_seek (SEEK_END) followed by sf_readf_short failed (%f should be %f).\n", __LINE__, data [0], orig [5]) ;
+ test_readf_float_or_die (file, 0, data, 1, __LINE__) ;
+ if (error_function (data [0], orig [5 * channels], margin))
+ { printf ("\nLine %d: sf_seek (SEEK_END) followed by sf_readf_short failed (%f should be %f).\n", __LINE__, data [0], orig [5 * channels]) ;
exit (1) ;
} ;
@@ -1072,9 +1132,10 @@
lcomp_test_double (const char *filename, int filetype, int channels, double margin)
{ SNDFILE *file ;
SF_INFO sfinfo ;
- int k, m, seekpos, sum_abs ;
+ int k, m, seekpos ;
long datalen ;
double *orig, *data ;
+ double half_max_abs ;
print_test_name ("lcomp_test_double", filename) ;
@@ -1085,7 +1146,7 @@
gen_signal_double (orig_buffer.d, 32000.0, channels, datalen) ;
for (k = 0 ; k < channels * datalen ; k++)
- orig [k] = (double) (orig_buffer.d [k]) ;
+ orig [k] = orig_buffer.d [k] ;
sfinfo.samplerate = SAMPLE_RATE ;
sfinfo.frames = 123456789 ; /* Ridiculous value. */
@@ -1137,17 +1198,17 @@
test_readf_double_or_die (file, 0, data, datalen, __LINE__) ;
- sum_abs = 0.0 ;
+ half_max_abs = 0.0 ;
for (k = 0 ; k < datalen ; k++)
- { if (error_function ((double) data [k], (double) orig [k], margin))
- { printf ("\n\nLine %d: Incorrect sample A (#%d : %f should be %f).\n", __LINE__, k, data [k], orig [k]) ;
+ { if (error_function (data [k], orig [k], margin))
+ { printf ("\nLine %d: Incorrect sample A (#%d : %f should be %f).\n", __LINE__, k, data [k], orig [k]) ;
oct_save_double (orig, data, datalen) ;
exit (1) ;
} ;
- sum_abs += fabs (data [k]) ;
+ half_max_abs = LCT_MAX (half_max_abs, abs (0.5 * data [k])) ;
} ;
- if (sum_abs < 1.0)
+ if (half_max_abs < 1.0)
{ printf ("\n\nLine %d: Signal is all zeros.\n", __LINE__) ;
exit (1) ;
} ;
@@ -1186,8 +1247,8 @@
{ test_readf_double_or_die (file, m, data, 11, __LINE__) ;
for (k = 0 ; k < channels * 11 ; k++)
- if (error_function ((double) data [k], (double) orig [k + channels * m * 11], margin))
- { printf ("\n\nLine %d: Incorrect sample (m = %d) (#%d : %f => %f).\n", __LINE__, m, k + channels * m * 11, orig [k + channels * m * 11], data [k]) ;
+ if (error_function (data [k], orig [k + channels * m * 11], margin))
+ { printf ("\nLine %d: Incorrect sample (m = %d) (#%d : %f => %f).\n", __LINE__, m, k + channels * m * 11, orig [k + channels * m * 11], data [k]) ;
for (m = 0 ; m < channels ; m++)
printf ("%f ", data [m]) ;
printf ("\n") ;
@@ -1205,8 +1266,8 @@
test_readf_double_or_die (file, 0, data, 1, __LINE__) ;
- if (error_function ((double) data [0], (double) orig [seekpos * channels], margin))
- { printf ("\n\nLine %d: sf_seek (SEEK_SET) followed by sf_readf_double failed (%f, %f).\n", __LINE__, orig [1], data [0]) ;
+ if (error_function (data [0], orig [seekpos * channels], margin))
+ { printf ("\nLine %d: sf_seek (SEEK_SET) followed by sf_readf_double failed (%f, %f).\n", __LINE__, orig [1], data [0]) ;
exit (1) ;
} ;
@@ -1218,8 +1279,8 @@
seekpos = sf_seek (file, 0, SEEK_CUR) + BUFFER_SIZE / 5 ;
k = sf_seek (file, BUFFER_SIZE / 5, SEEK_CUR) ;
test_readf_double_or_die (file, 0, data, 1, __LINE__) ;
- if (error_function ((double) data [0], (double) orig [seekpos * channels], margin) || k != seekpos)
- { printf ("\n\nLine %d: sf_seek (forwards, SEEK_CUR) followed by sf_readf_double failed (%f, %f) (%d, %d).\n", __LINE__, data [0], orig [seekpos * channels], k, seekpos + 1) ;
+ if (error_function (data [0], orig [seekpos * channels], margin) || k != seekpos)
+ { printf ("\nLine %d: sf_seek (forwards, SEEK_CUR) followed by sf_readf_double failed (%f, %f) (%d, %d).\n", __LINE__, data [0], orig [seekpos * channels], k, seekpos + 1) ;
exit (1) ;
} ;
@@ -1227,13 +1288,13 @@
/* Check seek backward from current position. */
k = sf_seek (file, -20, SEEK_CUR) ;
test_readf_double_or_die (file, 0, data, 1, __LINE__) ;
- if (error_function ((double) data [0], (double) orig [seekpos * channels], margin) || k != seekpos)
- { printf ("sf_seek (backwards, SEEK_CUR) followed by sf_readf_double failed (%f, %f) (%d, %d).\n", data [0], orig [seekpos * channels], k, seekpos) ;
+ if (error_function (data [0], orig [seekpos * channels], margin) || k != seekpos)
+ { printf ("\nLine %d: sf_seek (backwards, SEEK_CUR) followed by sf_readf_double failed (%f, %f) (%d, %d).\n", __LINE__, data [0], orig [seekpos * channels], k, seekpos) ;
exit (1) ;
} ;
/* Check that read past end of file returns number of items. */
- sf_seek (file, (double) sfinfo.frames, SEEK_SET) ;
+ sf_seek (file, sfinfo.frames, SEEK_SET) ;
if ((k = sf_readf_double (file, data, datalen)) != 0)
{ printf ("\n\nLine %d: Return value from sf_readf_double past end of file incorrect (%d).\n", __LINE__, k) ;
@@ -1241,14 +1302,14 @@
} ;
/* Check seek backward from end. */
- if ((k = sf_seek (file, 5 - (double) sfinfo.frames, SEEK_END)) != 5)
- { printf ("sf_seek (SEEK_END) returned %d instead of %d.\n", k, 5) ;
+ if ((k = sf_seek (file, 5 - sfinfo.frames, SEEK_END)) != 5)
+ { printf ("\n\nLine %d: sf_seek (SEEK_END) returned %d instead of %d.\n", __LINE__, k, 5) ;
exit (1) ;
} ;
- test_readf_double_or_die (file, 0, data, channels, __LINE__) ;
- if (error_function ((double) data [0], (double) orig [5], margin))
- { printf ("\n\nLine %d: sf_seek (SEEK_END) followed by sf_readf_short failed (%f should be %f).\n", __LINE__, data [0], orig [5]) ;
+ test_readf_double_or_die (file, 0, data, 1, __LINE__) ;
+ if (error_function (data [0], orig [5 * channels], margin))
+ { printf ("\nLine %d: sf_seek (SEEK_END) followed by sf_readf_short failed (%f should be %f).\n", __LINE__, data [0], orig [5 * channels]) ;
exit (1) ;
} ;
@@ -1266,7 +1327,7 @@
sdlcomp_test_short (const char *filename, int filetype, int channels, double margin)
{ SNDFILE *file ;
SF_INFO sfinfo ;
- int k, m, seekpos, sum_abs ;
+ int k, m, seekpos, half_max_abs ;
long datalen ;
short *orig, *data, *smooth ;
@@ -1281,14 +1342,33 @@
gen_signal_double (orig_buffer.d, 32000.0, channels, datalen) ;
for (k = 0 ; k < datalen ; k++)
- orig [k] = (short) (orig_buffer.d [k]) ;
+ orig [k] = lrint (orig_buffer.d [k]) ;
sfinfo.samplerate = SAMPLE_RATE ;
sfinfo.frames = 123456789 ; /* Ridiculous value. */
sfinfo.channels = channels ;
sfinfo.format = filetype ;
- file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_FALSE, __LINE__) ;
+ /* The Vorbis encoder has a bug on PowerPC and X86-64 with sample rates
+ ** <= 22050. Increasing the sample rate to 32000 avoids triggering it.
+ ** See https://trac.xiph.org/ticket/1229
+ */
+ if ((file = sf_open (filename, SFM_WRITE, &sfinfo)) == NULL)
+ { const char * errstr ;
+
+ errstr = sf_strerror (NULL) ;
+ if (strstr (errstr, "Sample rate chosen is known to trigger a Vorbis") == NULL)
+ { printf ("Line %d: sf_open_fd (SFM_WRITE) failed : %s\n", __LINE__, errstr) ;
+ dump_log_buffer (NULL) ;
+ exit (1) ;
+ } ;
+
+ printf ("\n Sample rate -> 32kHz ") ;
+ sfinfo.samplerate = 32000 ;
+
+ file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ;
+ } ;
+
test_write_short_or_die (file, 0, orig, datalen, __LINE__) ;
sf_set_string (file, SF_STR_COMMENT, long_comment) ;
sf_close (file) ;
@@ -1332,17 +1412,17 @@
smoothed_diff_short (data, datalen) ;
smoothed_diff_short (smooth, datalen) ;
- sum_abs = abs (data [0]) ;
- for (k = 1 ; k < datalen ; k++)
- { if (error_function ((double) data [k], (double) smooth [k], margin))
- { printf ("\n\nLine %d: Incorrect sample (#%d : %d should be %d).\n", __LINE__, k, data [k], smooth [k]) ;
+ half_max_abs = 0.0 ;
+ for (k = 0 ; k < datalen ; k++)
+ { if (error_function (1.0 * data [k], 1.0 * smooth [k], margin))
+ { printf ("\nLine %d: Incorrect sample (#%d : %d should be %d).\n", __LINE__, k, data [k], smooth [k]) ;
oct_save_short (orig, smooth, datalen) ;
exit (1) ;
} ;
- sum_abs = abs (sum_abs + abs (data [k])) ;
+ half_max_abs = LCT_MAX (half_max_abs, abs (0.5 * data [k])) ;
} ;
- if (sum_abs < 1)
+ if (half_max_abs < 1)
{ printf ("\n\nLine %d: Signal is all zeros.\n", __LINE__) ;
exit (1) ;
} ;
@@ -1375,8 +1455,8 @@
smoothed_diff_short (smooth, datalen / 7) ;
for (k = 0 ; k < datalen / 7 ; k++)
- if (error_function ((double) data [k], (double) smooth [k], margin))
- { printf ("Incorrect sample C (#%d (%ld) : %d => %d).\n", k, k + m * (datalen / 7), smooth [k], data [k]) ;
+ if (error_function (1.0 * data [k], 1.0 * smooth [k], margin))
+ { printf ("\nLine %d: Incorrect sample C (#%d (%ld) : %d => %d).\n", __LINE__, k, k + m * (datalen / 7), smooth [k], data [k]) ;
for (m = 0 ; m < 10 ; m++)
printf ("%d ", data [k]) ;
printf ("\n") ;
@@ -1393,35 +1473,35 @@
} ;
test_readf_short_or_die (file, 0, data, 1, __LINE__) ;
- if (error_function ((double) data [0], (double) orig [seekpos * channels], margin))
- { printf ("sf_seek (SEEK_SET) followed by sf_read_short failed (%d, %d).\n", orig [1], data [0]) ;
+ if (error_function (1.0 * data [0], 1.0 * orig [seekpos * channels], margin))
+ { printf ("\nLine %d: sf_seek (SEEK_SET) followed by sf_read_short failed (%d, %d).\n", __LINE__, orig [1], data [0]) ;
exit (1) ;
} ;
if ((k = sf_seek (file, 0, SEEK_CUR)) != seekpos + 1)
- { printf ("sf_seek (SEEK_CUR) with 0 offset failed (%d should be %d)\n", k, seekpos + 1) ;
+ { printf ("\n\nLine %d: sf_seek (SEEK_CUR) with 0 offset failed (%d should be %d)\n", __LINE__, k, seekpos + 1) ;
exit (1) ;
} ;
seekpos = sf_seek (file, 0, SEEK_CUR) + BUFFER_SIZE / 5 ;
k = sf_seek (file, BUFFER_SIZE / 5, SEEK_CUR) ;
- test_readf_short_or_die (file, 0, data, channels, __LINE__) ;
- if (error_function ((double) data [0], (double) orig [seekpos * channels], margin) || k != seekpos)
- { printf ("sf_seek (forwards, SEEK_CUR) followed by sf_read_short failed (%d, %d) (%d, %d).\n", data [0], orig [seekpos * channels], k, seekpos + 1) ;
+ test_readf_short_or_die (file, 0, data, 1, __LINE__) ;
+ if (error_function (1.0 * data [0], 1.0 * orig [seekpos * channels], margin) || k != seekpos)
+ { printf ("\nLine %d: sf_seek (forwards, SEEK_CUR) followed by sf_read_short failed (%d, %d) (%d, %d).\n", __LINE__, data [0], orig [seekpos * channels], k, seekpos + 1) ;
exit (1) ;
} ;
seekpos = sf_seek (file, 0, SEEK_CUR) - 20 ;
/* Check seek backward from current position. */
k = sf_seek (file, -20, SEEK_CUR) ;
- test_readf_short_or_die (file, 0, data, channels, __LINE__) ;
- if (error_function ((double) data [0], (double) orig [seekpos * channels], margin) || k != seekpos)
- { printf ("sf_seek (backwards, SEEK_CUR) followed by sf_read_short failed (%d, %d) (%d, %d).\n", data [0], orig [seekpos * channels], k, seekpos) ;
+ test_readf_short_or_die (file, 0, data, 1, __LINE__) ;
+ if (error_function (1.0 * data [0], 1.0 * orig [seekpos * channels], margin) || k != seekpos)
+ { printf ("\nLine %d: sf_seek (backwards, SEEK_CUR) followed by sf_read_short failed (%d, %d) (%d, %d).\n", __LINE__, data [0], orig [seekpos * channels], k, seekpos) ;
exit (1) ;
} ;
/* Check that read past end of file returns number of items. */
- sf_seek (file, (int) sfinfo.frames, SEEK_SET) ;
+ sf_seek (file, sfinfo.frames, SEEK_SET) ;
if ((k = sf_read_short (file, data, datalen)) != 0)
{ printf ("\n\nLine %d: Return value from sf_read_short past end of file incorrect (%d).\n", __LINE__, k) ;
@@ -1430,14 +1510,14 @@
/* Check seek backward from end. */
- if ((k = sf_seek (file, 5 - (int) sfinfo.frames, SEEK_END)) != 5)
- { printf ("sf_seek (SEEK_END) returned %d instead of %d.\n", k, 5) ;
+ if ((k = sf_seek (file, 5 - sfinfo.frames, SEEK_END)) != 5)
+ { printf ("\n\nLine %d: sf_seek (SEEK_END) returned %d instead of %d.\n", __LINE__, k, 5) ;
exit (1) ;
} ;
test_read_short_or_die (file, 0, data, channels, __LINE__) ;
- if (error_function ((double) data [0], (double) orig [5], margin))
- { printf ("sf_seek (SEEK_END) followed by sf_read_short failed (%d should be %d).\n", data [0], orig [5]) ;
+ if (error_function (1.0 * data [0], 1.0 * orig [5 * channels], margin))
+ { printf ("\nLine %d: sf_seek (SEEK_END) followed by sf_read_short failed (%d should be %d).\n", __LINE__, data [0], orig [5 * channels]) ;
exit (1) ;
} ;
} /* if (sfinfo.seekable) */
@@ -1452,7 +1532,7 @@
sdlcomp_test_int (const char *filename, int filetype, int channels, double margin)
{ SNDFILE *file ;
SF_INFO sfinfo ;
- int k, m, seekpos, sum_abs ;
+ int k, m, seekpos, half_max_abs ;
long datalen ;
int *orig, *data, *smooth ;
double scale ;
@@ -1470,14 +1550,33 @@
gen_signal_double (orig_buffer.d, 32000.0 * scale, channels, datalen) ;
for (k = 0 ; k < datalen ; k++)
- orig [k] = (int) (orig_buffer.d [k]) ;
+ orig [k] = lrint (orig_buffer.d [k]) ;
sfinfo.samplerate = SAMPLE_RATE ;
sfinfo.frames = 123456789 ; /* Ridiculous value. */
sfinfo.channels = channels ;
sfinfo.format = filetype ;
- file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_FALSE, __LINE__) ;
+ /* The Vorbis encoder has a bug on PowerPC and X86-64 with sample rates
+ ** <= 22050. Increasing the sample rate to 32000 avoids triggering it.
+ ** See https://trac.xiph.org/ticket/1229
+ */
+ if ((file = sf_open (filename, SFM_WRITE, &sfinfo)) == NULL)
+ { const char * errstr ;
+
+ errstr = sf_strerror (NULL) ;
+ if (strstr (errstr, "Sample rate chosen is known to trigger a Vorbis") == NULL)
+ { printf ("Line %d: sf_open_fd (SFM_WRITE) failed : %s\n", __LINE__, errstr) ;
+ dump_log_buffer (NULL) ;
+ exit (1) ;
+ } ;
+
+ printf ("\n Sample rate -> 32kHz ") ;
+ sfinfo.samplerate = 32000 ;
+
+ file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ;
+ } ;
+
test_writef_int_or_die (file, 0, orig, datalen, __LINE__) ;
sf_set_string (file, SF_STR_COMMENT, long_comment) ;
sf_close (file) ;
@@ -1517,17 +1616,17 @@
smoothed_diff_int (data, datalen) ;
smoothed_diff_int (smooth, datalen) ;
- sum_abs = abs (data [0] >> 16) ;
+ half_max_abs = abs (data [0] >> 16) ;
for (k = 1 ; k < datalen ; k++)
{ if (error_function (data [k] / scale, smooth [k] / scale, margin))
- { printf ("\n\nLine %d: Incorrect sample (#%d : %d should be %d).\n", __LINE__, k, data [k], smooth [k]) ;
+ { printf ("\nLine %d: Incorrect sample (#%d : %d should be %d).\n", __LINE__, k, data [k], smooth [k]) ;
oct_save_int (orig, smooth, datalen) ;
exit (1) ;
} ;
- sum_abs = abs (sum_abs + abs (data [k] >> 16)) ;
+ half_max_abs = LCT_MAX (half_max_abs, abs (data [k] / 2)) ;
} ;
- if (sum_abs < 1)
+ if (half_max_abs < 1)
{ printf ("\n\nLine %d: Signal is all zeros.\n", __LINE__) ;
exit (1) ;
} ;
@@ -1564,7 +1663,7 @@
for (k = 0 ; k < datalen / 7 ; k++)
if (error_function (data [k] / scale, smooth [k] / scale, margin))
- { printf ("\n\nLine %d: Incorrect sample (#%d (%ld) : %d => %d).\n", __LINE__, k, k + m * (datalen / 7), smooth [k], data [k]) ;
+ { printf ("\nLine %d: Incorrect sample (#%d (%ld) : %d => %d).\n", __LINE__, k, k + m * (datalen / 7), smooth [k], data [k]) ;
for (m = 0 ; m < 10 ; m++)
printf ("%d ", data [k]) ;
printf ("\n") ;
@@ -1581,21 +1680,21 @@
} ;
test_readf_int_or_die (file, 0, data, 1, __LINE__) ;
- if (error_function ((double) data [0], (double) orig [seekpos * channels], margin))
- { printf ("sf_seek (SEEK_SET) followed by sf_readf_int failed (%d, %d).\n", orig [1], data [0]) ;
+ if (error_function (1.0 * data [0], 1.0 * orig [seekpos * channels], margin))
+ { printf ("\nLine %d: sf_seek (SEEK_SET) followed by sf_readf_int failed (%d, %d).\n", __LINE__, orig [1], data [0]) ;
exit (1) ;
} ;
if ((k = sf_seek (file, 0, SEEK_CUR)) != seekpos + 1)
- { printf ("sf_seek (SEEK_CUR) with 0 offset failed (%d should be %d)\n", k, seekpos + 1) ;
+ { printf ("\n\nLine %d: sf_seek (SEEK_CUR) with 0 offset failed (%d should be %d)\n", __LINE__, k, seekpos + 1) ;
exit (1) ;
} ;
seekpos = sf_seek (file, 0, SEEK_CUR) + BUFFER_SIZE / 5 ;
k = sf_seek (file, BUFFER_SIZE / 5, SEEK_CUR) ;
test_readf_int_or_die (file, 0, data, 1, __LINE__) ;
- if (error_function ((double) data [0], (double) orig [seekpos * channels], margin) || k != seekpos)
- { printf ("sf_seek (forwards, SEEK_CUR) followed by sf_readf_int failed (%d, %d) (%d, %d).\n", data [0], orig [seekpos * channels], k, seekpos + 1) ;
+ if (error_function (1.0 * data [0], 1.0 * orig [seekpos * channels], margin) || k != seekpos)
+ { printf ("\nLine %d: sf_seek (forwards, SEEK_CUR) followed by sf_readf_int failed (%d, %d) (%d, %d).\n", __LINE__, data [0], orig [seekpos * channels], k, seekpos + 1) ;
exit (1) ;
} ;
@@ -1603,13 +1702,13 @@
/* Check seek backward from current position. */
k = sf_seek (file, -20, SEEK_CUR) ;
test_readf_int_or_die (file, 0, data, 1, __LINE__) ;
- if (error_function ((double) data [0], (double) orig [seekpos * channels], margin) || k != seekpos)
- { printf ("sf_seek (backwards, SEEK_CUR) followed by sf_readf_int failed (%d, %d) (%d, %d).\n", data [0], orig [seekpos * channels], k, seekpos) ;
+ if (error_function (1.0 * data [0], 1.0 * orig [seekpos * channels], margin) || k != seekpos)
+ { printf ("\nLine %d: sf_seek (backwards, SEEK_CUR) followed by sf_readf_int failed (%d, %d) (%d, %d).\n", __LINE__, data [0], orig [seekpos * channels], k, seekpos) ;
exit (1) ;
} ;
/* Check that read past end of file returns number of items. */
- sf_seek (file, (int) sfinfo.frames, SEEK_SET) ;
+ sf_seek (file, sfinfo.frames, SEEK_SET) ;
if ((k = sf_readf_int (file, data, datalen)) != 0)
{ printf ("\n\nLine %d: Return value from sf_readf_int past end of file incorrect (%d).\n", __LINE__, k) ;
@@ -1618,14 +1717,14 @@
/* Check seek backward from end. */
- if ((k = sf_seek (file, 5 - (int) sfinfo.frames, SEEK_END)) != 5)
- { printf ("sf_seek (SEEK_END) returned %d instead of %d.\n", k, 5) ;
+ if ((k = sf_seek (file, 5 - sfinfo.frames, SEEK_END)) != 5)
+ { printf ("\n\nLine %d: sf_seek (SEEK_END) returned %d instead of %d.\n", __LINE__, k, 5) ;
exit (1) ;
} ;
test_readf_int_or_die (file, 0, data, 1, __LINE__) ;
if (error_function (data [0] / scale, orig [5] / scale, margin))
- { printf ("\n\nLine %d: sf_seek (SEEK_END) followed by sf_readf_int failed (%d should be %d).\n", __LINE__, data [0], orig [5]) ;
+ { printf ("\nLine %d: sf_seek (SEEK_END) followed by sf_readf_int failed (%d should be %d).\n", __LINE__, data [0], orig [5]) ;
exit (1) ;
} ;
} /* if (sfinfo.seekable) */
@@ -1643,12 +1742,17 @@
int k, m, seekpos ;
long datalen ;
float *orig, *data, *smooth ;
- double sum_abs ;
+ double half_max_abs ;
channels = 1 ;
print_test_name ("sdlcomp_test_float", filename) ;
+ if ((filetype & SF_FORMAT_SUBMASK) == SF_FORMAT_VORBIS)
+ { puts ("Not working for this format.") ;
+ return ;
+ } ;
+
printf ("** fix this ** ") ;
datalen = BUFFER_SIZE ;
@@ -1659,7 +1763,7 @@
gen_signal_double (orig_buffer.d, 32000.0, channels, datalen) ;
for (k = 0 ; k < datalen ; k++)
- orig [k] = (int) (orig_buffer.d [k]) ;
+ orig [k] = lrint (orig_buffer.d [k]) ;
sfinfo.samplerate = SAMPLE_RATE ;
sfinfo.frames = 123456789 ; /* Ridiculous value. */
@@ -1711,19 +1815,19 @@
smoothed_diff_float (data, datalen) ;
smoothed_diff_float (smooth, datalen) ;
- sum_abs = fabs (data [0]) ;
+ half_max_abs = fabs (data [0]) ;
for (k = 1 ; k < datalen ; k++)
{ if (error_function (data [k], smooth [k], margin))
- { printf ("\n\nLine %d: Incorrect sample (#%d : %d should be %d).\n", __LINE__, k, (int) data [k], (int) smooth [k]) ;
+ { printf ("\nLine %d: Incorrect sample (#%d : %d should be %d).\n", __LINE__, k, (int) data [k], (int) smooth [k]) ;
oct_save_float (orig, smooth, datalen) ;
exit (1) ;
} ;
- sum_abs += fabs (data [k]) ;
+ half_max_abs = LCT_MAX (half_max_abs, abs (0.5 * data [k])) ;
} ;
- if (sum_abs <= 0.0)
+ if (half_max_abs <= 0.0)
{ printf ("\n\nLine %d: Signal is all zeros.\n", __LINE__) ;
- printf ("sum_abs : % 10.6f\n", sum_abs) ;
+ printf ("half_max_abs : % 10.6f\n", half_max_abs) ;
exit (1) ;
} ;
@@ -1755,8 +1859,8 @@
smoothed_diff_float (smooth, datalen / 7) ;
for (k = 0 ; k < datalen / 7 ; k++)
- if (error_function ((float) data [k], (float) smooth [k], margin))
- { printf ("Incorrect sample C (#%d (%ld) : %d => %d).\n", k, k + m * (datalen / 7), (int) smooth [k], (int) data [k]) ;
+ if (error_function (data [k], smooth [k], margin))
+ { printf ("\nLine %d: Incorrect sample C (#%d (%ld) : %d => %d).\n", __LINE__, k, k + m * (datalen / 7), (int) smooth [k], (int) data [k]) ;
for (m = 0 ; m < 10 ; m++)
printf ("%d ", (int) data [k]) ;
printf ("\n") ;
@@ -1771,23 +1875,23 @@
{ printf ("Seek to start of file + %d failed (%d).\n", seekpos, k) ;
exit (1) ;
} ;
- test_read_float_or_die (file, 0, data, 1, __LINE__) ;
+ test_read_float_or_die (file, 0, data, channels, __LINE__) ;
- if (error_function ((float) data [0], (float) orig [seekpos * channels], margin))
- { printf ("sf_seek (SEEK_SET) followed by sf_read_float failed (%d, %d).\n", (int) orig [1], (int) data [0]) ;
+ if (error_function (data [0], orig [seekpos * channels], margin))
+ { printf ("\nLine %d: sf_seek (SEEK_SET) followed by sf_read_float failed (%d, %d).\n", __LINE__, (int) orig [1], (int) data [0]) ;
exit (1) ;
} ;
if ((k = sf_seek (file, 0, SEEK_CUR)) != seekpos + 1)
- { printf ("sf_seek (SEEK_CUR) with 0 offset failed (%d should be %d)\n", k, seekpos + 1) ;
+ { printf ("\n\nLine %d: sf_seek (SEEK_CUR) with 0 offset failed (%d should be %d)\n", __LINE__, k, seekpos + 1) ;
exit (1) ;
} ;
seekpos = sf_seek (file, 0, SEEK_CUR) + BUFFER_SIZE / 5 ;
k = sf_seek (file, BUFFER_SIZE / 5, SEEK_CUR) ;
test_read_float_or_die (file, 0, data, channels, __LINE__) ;
- if (error_function ((float) data [0], (float) orig [seekpos * channels], margin) || k != seekpos)
- { printf ("sf_seek (forwards, SEEK_CUR) followed by sf_read_float failed (%d, %d) (%d, %d).\n", (int) data [0], (int) orig [seekpos * channels], k, seekpos + 1) ;
+ if (error_function (data [0], orig [seekpos * channels], margin) || k != seekpos)
+ { printf ("\nLine %d: sf_seek (forwards, SEEK_CUR) followed by sf_read_float failed (%d, %d) (%d, %d).\n", __LINE__, (int) data [0], (int) orig [seekpos * channels], k, seekpos + 1) ;
exit (1) ;
} ;
@@ -1795,13 +1899,13 @@
/* Check seek backward from current position. */
k = sf_seek (file, -20, SEEK_CUR) ;
test_read_float_or_die (file, 0, data, channels, __LINE__) ;
- if (error_function ((float) data [0], (float) orig [seekpos * channels], margin) || k != seekpos)
- { printf ("sf_seek (backwards, SEEK_CUR) followed by sf_read_float failed (%d, %d) (%d, %d).\n", (int) data [0], (int) orig [seekpos * channels], k, seekpos) ;
+ if (error_function (data [0], orig [seekpos * channels], margin) || k != seekpos)
+ { printf ("\nLine %d: sf_seek (backwards, SEEK_CUR) followed by sf_read_float failed (%d, %d) (%d, %d).\n", __LINE__, (int) data [0], (int) orig [seekpos * channels], k, seekpos) ;
exit (1) ;
} ;
/* Check that read past end of file returns number of items. */
- sf_seek (file, (int) sfinfo.frames, SEEK_SET) ;
+ sf_seek (file, sfinfo.frames, SEEK_SET) ;
if ((k = sf_read_float (file, data, datalen)) != 0)
{ printf ("\n\nLine %d: Return value from sf_read_float past end of file incorrect (%d).\n", __LINE__, k) ;
@@ -1810,14 +1914,14 @@
/* Check seek backward from end. */
- if ((k = sf_seek (file, 5 - (int) sfinfo.frames, SEEK_END)) != 5)
- { printf ("sf_seek (SEEK_END) returned %d instead of %d.\n", k, 5) ;
+ if ((k = sf_seek (file, 5 - sfinfo.frames, SEEK_END)) != 5)
+ { printf ("\n\nLine %d: sf_seek (SEEK_END) returned %d instead of %d.\n", __LINE__, k, 5) ;
exit (1) ;
} ;
test_read_float_or_die (file, 0, data, channels, __LINE__) ;
- if (error_function ((float) data [0], (float) orig [5], margin))
- { printf ("sf_seek (SEEK_END) followed by sf_read_float failed (%d should be %d).\n", (int) data [0], (int) orig [5]) ;
+ if (error_function (data [0], orig [5 * channels], margin))
+ { printf ("\nLine %d: sf_seek (SEEK_END) followed by sf_read_float failed (%f should be %f).\n", __LINE__, data [0], orig [5 * channels]) ;
exit (1) ;
} ;
} /* if (sfinfo.seekable) */
@@ -1834,11 +1938,16 @@
SF_INFO sfinfo ;
int k, m, seekpos ;
long datalen ;
- double *orig, *data, *smooth, sum_abs ;
+ double *orig, *data, *smooth, half_max_abs ;
channels = 1 ;
print_test_name ("sdlcomp_test_double", filename) ;
+ if ((filetype & SF_FORMAT_SUBMASK) == SF_FORMAT_VORBIS)
+ { puts ("Not working for this format.") ;
+ return ;
+ } ;
+
datalen = BUFFER_SIZE ;
orig = orig_buffer.d ;
@@ -1899,17 +2008,17 @@
smoothed_diff_double (data, datalen) ;
smoothed_diff_double (smooth, datalen) ;
- sum_abs = fabs (data [0]) ;
- for (k = 1 ; k < datalen ; k++)
+ half_max_abs = 0.0 ;
+ for (k = 0 ; k < datalen ; k++)
{ if (error_function (data [k], smooth [k], margin))
{ printf ("\n\nLine %d: Incorrect sample (#%d : %d should be %d).\n", __LINE__, k, (int) data [k], (int) smooth [k]) ;
oct_save_double (orig, smooth, datalen) ;
exit (1) ;
} ;
- sum_abs += fabs (data [k]) ;
+ half_max_abs = LCT_MAX (half_max_abs, 0.5 * fabs (data [k])) ;
} ;
- if (sum_abs < 1.0)
+ if (half_max_abs < 1.0)
{ printf ("\n\nLine %d: Signal is all zeros.\n", __LINE__) ;
exit (1) ;
} ;
@@ -1942,8 +2051,8 @@
smoothed_diff_double (smooth, datalen / 7) ;
for (k = 0 ; k < datalen / 7 ; k++)
- if (error_function ((double) data [k], (double) smooth [k], margin))
- { printf ("Incorrect sample C (#%d (%ld) : %d => %d).\n", k, k + m * (datalen / 7), (int) smooth [k], (int) data [k]) ;
+ if (error_function (data [k], smooth [k], margin))
+ { printf ("\nLine %d: Incorrect sample C (#%d (%ld) : %d => %d).\n", __LINE__, k, k + m * (datalen / 7), (int) smooth [k], (int) data [k]) ;
for (m = 0 ; m < 10 ; m++)
printf ("%d ", (int) data [k]) ;
printf ("\n") ;
@@ -1958,37 +2067,37 @@
{ printf ("Seek to start of file + %d failed (%d).\n", seekpos, k) ;
exit (1) ;
} ;
- test_read_double_or_die (file, 0, data, 1, __LINE__) ;
+ test_read_double_or_die (file, 0, data, channels, __LINE__) ;
- if (error_function ((double) data [0], (double) orig [seekpos * channels], margin))
- { printf ("sf_seek (SEEK_SET) followed by sf_read_double failed (%d, %d).\n", (int) orig [1], (int) data [0]) ;
+ if (error_function (data [0], orig [seekpos * channels], margin))
+ { printf ("\nLine %d: sf_seek (SEEK_SET) followed by sf_read_double failed (%d, %d).\n", __LINE__, (int) orig [1], (int) data [0]) ;
exit (1) ;
} ;
if ((k = sf_seek (file, 0, SEEK_CUR)) != seekpos + 1)
- { printf ("sf_seek (SEEK_CUR) with 0 offset failed (%d should be %d)\n", k, seekpos + 1) ;
+ { printf ("\n\nLine %d: sf_seek (SEEK_CUR) with 0 offset failed (%d should be %d)\n", __LINE__, k, seekpos + 1) ;
exit (1) ;
} ;
seekpos = sf_seek (file, 0, SEEK_CUR) + BUFFER_SIZE / 5 ;
k = sf_seek (file, BUFFER_SIZE / 5, SEEK_CUR) ;
- test_read_double_or_die (file, 0, data, 1, __LINE__) ;
- if (error_function ((double) data [0], (double) orig [seekpos * channels], margin) || k != seekpos)
- { printf ("sf_seek (forwards, SEEK_CUR) followed by sf_read_double failed (%d, %d) (%d, %d).\n", (int) data [0], (int) orig [seekpos * channels], k, seekpos + 1) ;
+ test_read_double_or_die (file, 0, data, channels, __LINE__) ;
+ if (error_function (data [0], orig [seekpos * channels], margin) || k != seekpos)
+ { printf ("\nLine %d: sf_seek (forwards, SEEK_CUR) followed by sf_read_double failed (%d, %d) (%d, %d).\n", __LINE__, (int) data [0], (int) orig [seekpos * channels], k, seekpos + 1) ;
exit (1) ;
} ;
seekpos = sf_seek (file, 0, SEEK_CUR) - 20 ;
/* Check seek backward from current position. */
k = sf_seek (file, -20, SEEK_CUR) ;
- test_read_double_or_die (file, 0, data, 1, __LINE__) ;
- if (error_function ((double) data [0], (double) orig [seekpos * channels], margin) || k != seekpos)
- { printf ("sf_seek (backwards, SEEK_CUR) followed by sf_read_double failed (%d, %d) (%d, %d).\n", (int) data [0], (int) orig [seekpos * channels], k, seekpos) ;
+ test_read_double_or_die (file, 0, data, channels, __LINE__) ;
+ if (error_function (data [0], orig [seekpos * channels], margin) || k != seekpos)
+ { printf ("\nLine %d: sf_seek (backwards, SEEK_CUR) followed by sf_read_double failed (%d, %d) (%d, %d).\n", __LINE__, (int) data [0], (int) orig [seekpos * channels], k, seekpos) ;
exit (1) ;
} ;
/* Check that read past end of file returns number of items. */
- sf_seek (file, (int) sfinfo.frames, SEEK_SET) ;
+ sf_seek (file, sfinfo.frames, SEEK_SET) ;
if ((k = sf_read_double (file, data, datalen)) != 0)
{ printf ("\n\nLine %d: Return value from sf_read_double past end of file incorrect (%d).\n", __LINE__, k) ;
@@ -1997,14 +2106,14 @@
/* Check seek backward from end. */
- if ((k = sf_seek (file, 5 - (int) sfinfo.frames, SEEK_END)) != 5)
- { printf ("sf_seek (SEEK_END) returned %d instead of %d.\n", k, 5) ;
+ if ((k = sf_seek (file, 5 - sfinfo.frames, SEEK_END)) != 5)
+ { printf ("\n\nLine %d: sf_seek (SEEK_END) returned %d instead of %d.\n", __LINE__, k, 5) ;
exit (1) ;
} ;
- test_read_double_or_die (file, 0, data, 1, __LINE__) ;
- if (error_function ((double) data [0], (double) orig [5], margin))
- { printf ("sf_seek (SEEK_END) followed by sf_read_double failed (%d should be %d).\n", (int) data [0], (int) orig [5]) ;
+ test_read_double_or_die (file, 0, data, channels, __LINE__) ;
+ if (error_function (data [0], orig [5 * channels], margin))
+ { printf ("\nLine %d: sf_seek (SEEK_END) followed by sf_read_double failed (%f should be %f).\n", __LINE__, data [0], orig [5 * channels]) ;
exit (1) ;
} ;
} /* if (sfinfo.seekable) */
@@ -2015,6 +2124,77 @@
printf ("ok\n") ;
} /* sdlcomp_test_double */
+static void
+read_raw_test (const char *filename, int filetype, int channels)
+{ SNDFILE *file ;
+ SF_INFO sfinfo ;
+ sf_count_t count ;
+ long datalen ;
+ short *orig, *data ;
+ int k ;
+
+ print_test_name ("read_raw_test", filename) ;
+
+ datalen = ARRAY_LEN (orig_buffer.s) / 2 ;
+
+ orig = orig_buffer.s ;
+ data = data_buffer.s ;
+
+ gen_signal_double (orig_buffer.d, 32000.0, channels, datalen) ;
+ for (k = 0 ; k < datalen ; k++)
+ orig [k] = lrint (orig_buffer.d [k]) ;
+
+ sfinfo.samplerate = SAMPLE_RATE ;
+ sfinfo.frames = 123456789 ; /* Ridiculous value. */
+ sfinfo.channels = channels ;
+ sfinfo.format = filetype ;
+
+ file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_FALSE, __LINE__) ;
+ test_write_short_or_die (file, 0, orig, datalen, __LINE__) ;
+ sf_set_string (file, SF_STR_COMMENT, long_comment) ;
+ sf_close (file) ;
+
+ memset (data, 0, datalen * sizeof (double)) ;
+
+ if ((filetype & SF_FORMAT_TYPEMASK) != SF_FORMAT_RAW)
+ memset (&sfinfo, 0, sizeof (sfinfo)) ;
+
+ file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_FALSE, __LINE__) ;
+
+ if (sfinfo.format != filetype)
+ { printf ("Returned format incorrect (0x%08X => 0x%08X).\n", filetype, sfinfo.format) ;
+ exit (1) ;
+ } ;
+
+ if (sfinfo.frames < datalen / channels)
+ { printf ("Too few.frames in file. (%ld should be a little more than %ld)\n", datalen, SF_COUNT_TO_LONG (sfinfo.frames)) ;
+ exit (1) ;
+ } ;
+
+ if (sfinfo.frames > (datalen + 400))
+ { printf ("Too many.frames in file. (%ld should be a little more than %ld)\n", SF_COUNT_TO_LONG (sfinfo.frames), datalen) ;
+ exit (1) ;
+ } ;
+
+ if (sfinfo.channels != channels)
+ { printf ("Incorrect number of channels in file.\n") ;
+ exit (1) ;
+ } ;
+
+ check_comment (file, filetype, __LINE__) ;
+
+ count = sf_read_raw (file, orig_buffer.c, datalen + 5 * channels) ;
+ if (count != sfinfo.channels * sfinfo.frames)
+ { printf ("\nLine %d : sf_read_raw returned %ld should be %ld\n", __LINE__, SF_COUNT_TO_LONG (count), sfinfo.channels * SF_COUNT_TO_LONG (sfinfo.frames)) ;
+ exit (1) ;
+ } ;
+
+ sf_close (file) ;
+
+ unlink (filename) ;
+ printf ("ok\n") ;
+} /* read_raw_test */
+
/*========================================================================================
** Auxiliary functions
*/
@@ -2080,7 +2260,7 @@
error = fabs (data - orig) / fabs (orig) ;
if (error > margin)
- { printf ("\n\n*******************\nError : %f\n", error) ;
+ { printf ("\n\nerror_function (data = %f, orig = %f, margin = %f) -> %f\n", data, orig, margin, error) ;
return 1 ;
} ;
return 0 ;
@@ -2169,10 +2349,23 @@
return ;
} /* check_comment */
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: 5eb86888-3311-48b8-920e-c2a0393b7ad2
-*/
+static int
+is_lossy (int filetype)
+{
+ switch (SF_FORMAT_SUBMASK & filetype)
+ { case SF_FORMAT_PCM_U8 :
+ case SF_FORMAT_PCM_S8 :
+ case SF_FORMAT_PCM_16 :
+ case SF_FORMAT_PCM_24 :
+ case SF_FORMAT_PCM_32 :
+ case SF_FORMAT_FLOAT :
+ case SF_FORMAT_DOUBLE :
+ return 0 ;
+
+ default :
+ break ;
+ } ;
+
+ return 1 ;
+} /* is_lossy */
+
Modified: freeswitch/trunk/libs/libsndfile/tests/misc_test.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/tests/misc_test.c (original)
+++ freeswitch/trunk/libs/libsndfile/tests/misc_test.c Thu May 21 16:09:30 2009
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 2001-2005 Erik de Castro Lopo <erikd at mega-nerd.com>
+** Copyright (C) 2001-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
**
** This program is free software ; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
@@ -21,6 +21,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <errno.h>
#include <sys/stat.h>
#include <math.h>
@@ -45,9 +46,10 @@
#define BUFFER_LEN (1<<10)
#define LOG_BUFFER_SIZE 1024
-static void zero_data_test (const char *filename, int typemajor) ;
-static void filesystem_full_test (int typemajor) ;
+static void zero_data_test (const char *filename, int format) ;
+static void filesystem_full_test (int format) ;
static void permission_test (const char *filename, int typemajor) ;
+static void wavex_amb_test (const char *filename) ;
int
main (int argc, char *argv [])
@@ -66,117 +68,139 @@
do_all=!strcmp (argv [1], "all") ;
if (do_all || ! strcmp (argv [1], "wav"))
- { zero_data_test ("zerolen.wav", SF_FORMAT_WAV) ;
- filesystem_full_test (SF_FORMAT_WAV) ;
+ { zero_data_test ("zerolen.wav", SF_FORMAT_WAV | SF_FORMAT_PCM_16) ;
+ filesystem_full_test (SF_FORMAT_WAV | SF_FORMAT_PCM_16) ;
permission_test ("readonly.wav", SF_FORMAT_WAV) ;
+ wavex_amb_test ("ambisonic.wav") ;
test_count++ ;
} ;
if (do_all || ! strcmp (argv [1], "aiff"))
- { zero_data_test ("zerolen.aiff", SF_FORMAT_AIFF) ;
- filesystem_full_test (SF_FORMAT_AIFF) ;
+ { zero_data_test ("zerolen.aiff", SF_FORMAT_AIFF | SF_FORMAT_PCM_16) ;
+ filesystem_full_test (SF_FORMAT_AIFF | SF_FORMAT_PCM_16) ;
permission_test ("readonly.aiff", SF_FORMAT_AIFF) ;
test_count++ ;
} ;
if (do_all || ! strcmp (argv [1], "au"))
- { zero_data_test ("zerolen.au", SF_FORMAT_AU) ;
- filesystem_full_test (SF_FORMAT_AU) ;
+ { zero_data_test ("zerolen.au", SF_FORMAT_AU | SF_FORMAT_PCM_16) ;
+ filesystem_full_test (SF_FORMAT_AU | SF_FORMAT_PCM_16) ;
permission_test ("readonly.au", SF_FORMAT_AU) ;
test_count++ ;
} ;
if (do_all || ! strcmp (argv [1], "caf"))
- { zero_data_test ("zerolen.caf", SF_FORMAT_CAF) ;
- filesystem_full_test (SF_FORMAT_CAF) ;
+ { zero_data_test ("zerolen.caf", SF_FORMAT_CAF | SF_FORMAT_PCM_16) ;
+ filesystem_full_test (SF_FORMAT_CAF | SF_FORMAT_PCM_16) ;
permission_test ("readonly.caf", SF_FORMAT_CAF) ;
test_count++ ;
} ;
if (do_all || ! strcmp (argv [1], "svx"))
- { zero_data_test ("zerolen.svx", SF_FORMAT_SVX) ;
- filesystem_full_test (SF_FORMAT_SVX) ;
+ { zero_data_test ("zerolen.svx", SF_FORMAT_SVX | SF_FORMAT_PCM_16) ;
+ filesystem_full_test (SF_FORMAT_SVX | SF_FORMAT_PCM_16) ;
permission_test ("readonly.svx", SF_FORMAT_SVX) ;
test_count++ ;
} ;
if (do_all || ! strcmp (argv [1], "nist"))
- { zero_data_test ("zerolen.nist", SF_FORMAT_NIST) ;
- filesystem_full_test (SF_FORMAT_NIST) ;
+ { zero_data_test ("zerolen.nist", SF_FORMAT_NIST | SF_FORMAT_PCM_16) ;
+ filesystem_full_test (SF_FORMAT_NIST | SF_FORMAT_PCM_16) ;
permission_test ("readonly.nist", SF_FORMAT_NIST) ;
test_count++ ;
} ;
if (do_all || ! strcmp (argv [1], "paf"))
- { zero_data_test ("zerolen.paf", SF_FORMAT_PAF) ;
- filesystem_full_test (SF_FORMAT_PAF) ;
+ { zero_data_test ("zerolen.paf", SF_FORMAT_PAF | SF_FORMAT_PCM_16) ;
+ filesystem_full_test (SF_FORMAT_PAF | SF_FORMAT_PCM_16) ;
permission_test ("readonly.paf", SF_FORMAT_PAF) ;
test_count++ ;
} ;
if (do_all || ! strcmp (argv [1], "ircam"))
- { zero_data_test ("zerolen.ircam", SF_FORMAT_IRCAM) ;
- filesystem_full_test (SF_FORMAT_IRCAM) ;
+ { zero_data_test ("zerolen.ircam", SF_FORMAT_IRCAM | SF_FORMAT_PCM_16) ;
+ filesystem_full_test (SF_FORMAT_IRCAM | SF_FORMAT_PCM_16) ;
permission_test ("readonly.ircam", SF_FORMAT_IRCAM) ;
test_count++ ;
} ;
if (do_all || ! strcmp (argv [1], "voc"))
- { zero_data_test ("zerolen.voc", SF_FORMAT_VOC) ;
- filesystem_full_test (SF_FORMAT_VOC) ;
+ { zero_data_test ("zerolen.voc", SF_FORMAT_VOC | SF_FORMAT_PCM_16) ;
+ filesystem_full_test (SF_FORMAT_VOC | SF_FORMAT_PCM_16) ;
permission_test ("readonly.voc", SF_FORMAT_VOC) ;
test_count++ ;
} ;
if (do_all || ! strcmp (argv [1], "w64"))
- { zero_data_test ("zerolen.w64", SF_FORMAT_W64) ;
- filesystem_full_test (SF_FORMAT_W64) ;
+ { zero_data_test ("zerolen.w64", SF_FORMAT_W64 | SF_FORMAT_PCM_16) ;
+ filesystem_full_test (SF_FORMAT_W64 | SF_FORMAT_PCM_16) ;
permission_test ("readonly.w64", SF_FORMAT_W64) ;
test_count++ ;
} ;
+ if (do_all || ! strcmp (argv [1], "rf64"))
+ { zero_data_test ("zerolen.rf64", SF_FORMAT_W64 | SF_FORMAT_PCM_16) ;
+ filesystem_full_test (SF_FORMAT_W64 | SF_FORMAT_PCM_16) ;
+ permission_test ("readonly.rf64", SF_FORMAT_W64) ;
+ test_count++ ;
+ } ;
+
if (do_all || ! strcmp (argv [1], "mat4"))
- { zero_data_test ("zerolen.mat4", SF_FORMAT_MAT4) ;
- filesystem_full_test (SF_FORMAT_MAT4) ;
+ { zero_data_test ("zerolen.mat4", SF_FORMAT_MAT4 | SF_FORMAT_PCM_16) ;
+ filesystem_full_test (SF_FORMAT_MAT4 | SF_FORMAT_PCM_16) ;
permission_test ("readonly.mat4", SF_FORMAT_MAT4) ;
test_count++ ;
} ;
if (do_all || ! strcmp (argv [1], "mat5"))
- { zero_data_test ("zerolen.mat5", SF_FORMAT_MAT5) ;
- filesystem_full_test (SF_FORMAT_MAT5) ;
+ { zero_data_test ("zerolen.mat5", SF_FORMAT_MAT5 | SF_FORMAT_PCM_16) ;
+ filesystem_full_test (SF_FORMAT_MAT5 | SF_FORMAT_PCM_16) ;
permission_test ("readonly.mat5", SF_FORMAT_MAT5) ;
test_count++ ;
} ;
if (do_all || ! strcmp (argv [1], "pvf"))
- { zero_data_test ("zerolen.pvf", SF_FORMAT_PVF) ;
- filesystem_full_test (SF_FORMAT_PVF) ;
+ { zero_data_test ("zerolen.pvf", SF_FORMAT_PVF | SF_FORMAT_PCM_16) ;
+ filesystem_full_test (SF_FORMAT_PVF | SF_FORMAT_PCM_16) ;
permission_test ("readonly.pvf", SF_FORMAT_PVF) ;
test_count++ ;
} ;
if (do_all || ! strcmp (argv [1], "htk"))
- { zero_data_test ("zerolen.htk", SF_FORMAT_HTK) ;
- filesystem_full_test (SF_FORMAT_HTK) ;
+ { zero_data_test ("zerolen.htk", SF_FORMAT_HTK | SF_FORMAT_PCM_16) ;
+ filesystem_full_test (SF_FORMAT_HTK | SF_FORMAT_PCM_16) ;
permission_test ("readonly.htk", SF_FORMAT_HTK) ;
test_count++ ;
} ;
if (do_all || ! strcmp (argv [1], "avr"))
- { zero_data_test ("zerolen.avr", SF_FORMAT_AVR) ;
- filesystem_full_test (SF_FORMAT_AVR) ;
+ { zero_data_test ("zerolen.avr", SF_FORMAT_AVR | SF_FORMAT_PCM_16) ;
+ filesystem_full_test (SF_FORMAT_AVR | SF_FORMAT_PCM_16) ;
permission_test ("readonly.avr", SF_FORMAT_AVR) ;
test_count++ ;
} ;
if (do_all || ! strcmp (argv [1], "sds"))
- { zero_data_test ("zerolen.sds", SF_FORMAT_SDS) ;
- filesystem_full_test (SF_FORMAT_SDS) ;
+ { zero_data_test ("zerolen.sds", SF_FORMAT_SDS | SF_FORMAT_PCM_16) ;
+ filesystem_full_test (SF_FORMAT_SDS | SF_FORMAT_PCM_16) ;
permission_test ("readonly.sds", SF_FORMAT_SDS) ;
test_count++ ;
} ;
+ if (do_all || ! strcmp (argv [1], "mpc2k"))
+ { zero_data_test ("zerolen.mpc", SF_FORMAT_MPC2K | SF_FORMAT_PCM_16) ;
+ filesystem_full_test (SF_FORMAT_MPC2K | SF_FORMAT_PCM_16) ;
+ permission_test ("readonly.mpc", SF_FORMAT_MPC2K) ;
+ test_count++ ;
+ } ;
+
+ if (do_all || ! strcmp (argv [1], "ogg"))
+ { zero_data_test ("zerolen.oga", SF_FORMAT_OGG | SF_FORMAT_VORBIS) ;
+ /*-filesystem_full_test (SF_FORMAT_OGG | SF_FORMAT_VORBIS) ;-*/
+ permission_test ("readonly.oga", SF_FORMAT_OGG) ;
+ test_count++ ;
+ } ;
+
if (test_count == 0)
{ printf ("Mono : ************************************\n") ;
printf ("Mono : * No '%s' test defined.\n", argv [1]) ;
@@ -193,15 +217,24 @@
*/
static void
-zero_data_test (const char *filename, int typemajor)
+zero_data_test (const char *filename, int format)
{ SNDFILE *file ;
SF_INFO sfinfo ;
int frames ;
+ switch (format & SF_FORMAT_TYPEMASK)
+ { case SF_FORMAT_OGG :
+ if (HAVE_EXTERNAL_LIBS == 0)
+ return ;
+ break ;
+ default :
+ break ;
+ } ;
+
print_test_name ("zero_data_test", filename) ;
sfinfo.samplerate = 44100 ;
- sfinfo.format = (typemajor | SF_FORMAT_PCM_16) ;
+ sfinfo.format = format ;
sfinfo.channels = 1 ;
sfinfo.frames = 0 ;
@@ -222,7 +255,7 @@
} /* zero_data_test */
static void
-filesystem_full_test (int typemajor)
+filesystem_full_test (int format)
{ SNDFILE *file ;
SF_INFO sfinfo ;
struct stat buf ;
@@ -235,6 +268,9 @@
return ;
#endif
+ /* Make sure errno is zero before doing anything else. */
+ errno = 0 ;
+
print_test_name ("filesystem_full_test", filename) ;
if (stat (filename, &buf) != 0)
@@ -248,7 +284,7 @@
} ;
sfinfo.samplerate = 44100 ;
- sfinfo.format = (typemajor | SF_FORMAT_PCM_16) ;
+ sfinfo.format = format ;
sfinfo.channels = 1 ;
sfinfo.frames = 0 ;
@@ -287,6 +323,9 @@
const char *errorstr ;
int frames ;
+ /* Make sure errno is zero before doing anything else. */
+ errno = 0 ;
+
if (getuid () == 0)
{ /* If running as root bypass this test.
** Root is allowed to open a readonly file for write.
@@ -296,6 +335,11 @@
print_test_name ("permission_test", filename) ;
+ if (access (filename, F_OK) == 0)
+ { chmod (filename, S_IWUSR) ;
+ unlink (filename) ;
+ } ;
+
if ((textfile = fopen (filename, "w")) == NULL)
{ printf ("\n\nLine %d : not able to open text file for write.\n", __LINE__) ;
exit (1) ;
@@ -344,10 +388,37 @@
#endif
} /* permission_test */
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: efc6c227-8881-4a1d-8680-0d1255975267
-*/
+static void
+wavex_amb_test (const char *filename)
+{ static short buffer [800] ;
+ SNDFILE *file ;
+ SF_INFO sfinfo ;
+ sf_count_t frames ;
+
+ print_test_name (__func__, filename) ;
+
+ sfinfo.samplerate = 44100 ;
+ sfinfo.format = SF_FORMAT_WAVEX | SF_FORMAT_PCM_16 ;
+ sfinfo.channels = 4 ;
+
+ frames = ARRAY_LEN (buffer) / sfinfo.channels ;
+
+ file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ;
+ sf_command (file, SFC_WAVEX_SET_AMBISONIC, NULL, SF_AMBISONIC_B_FORMAT) ;
+ test_writef_short_or_die (file, 0, buffer, frames, __LINE__) ;
+ sf_close (file) ;
+
+ memset (&sfinfo, 0, sizeof (sfinfo)) ;
+
+ file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ;
+
+ exit_if_true (
+ sf_command (file, SFC_WAVEX_GET_AMBISONIC, NULL, 0) != SF_AMBISONIC_B_FORMAT,
+ "\n\nLine %d : Error, this file should be in Ambisonic B format.\n", __LINE__
+ ) ;
+
+ sf_close (file) ;
+
+ unlink (filename) ;
+ puts ("ok") ;
+} /* wavex_amb_test */
Modified: freeswitch/trunk/libs/libsndfile/tests/multi_file_test.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/tests/multi_file_test.c (original)
+++ freeswitch/trunk/libs/libsndfile/tests/multi_file_test.c Thu May 21 16:09:30 2009
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 1999-2004 Erik de Castro Lopo <erikd at mega-nerd.com>
+** Copyright (C) 1999-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
@@ -41,7 +41,6 @@
#define DATA_LENGTH (512)
-static off_t get_file_length (int fd) ;
static void write_file_at_end (int fd, int filetype, int channels, int file_num) ;
static void multi_file_test (const char *filename, int *formats, int format_count) ;
@@ -131,31 +130,32 @@
{ SNDFILE *sndfile ;
SF_INFO sfinfo ;
SF_EMBED_FILE_INFO embed_info ;
- off_t file_length ;
- int fd, k, file_count = 0 ;
+ sf_count_t filelen ;
+ int fd, k, file_count = 0, open_perm ;
print_test_name ("multi_file_test", filename) ;
unlink (filename) ;
- if ((fd = open (filename, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP )) < 0)
+ open_perm = OS_IS_WIN32 ? 0 : S_IRUSR | S_IWUSR | S_IRGRP ;
+
+ if ((fd = open (filename, O_RDWR | O_CREAT, open_perm)) < 0)
{ printf ("\n\nLine %d: open failed : %s\n", __LINE__, strerror (errno)) ;
exit (1) ;
} ;
- write (fd, "1234", 4) ;
+ k = write (fd, "1234", 4) ;
for (k = 0 ; k < format_count ; k++)
write_file_at_end (fd, formats [k], 2, k) ;
- file_length = get_file_length (fd) ;
+ filelen = file_length_fd (fd) ;
embed_info.offset = 4 ;
embed_info.length = 0 ;
- file_count = 0 ;
- while (embed_info.offset + embed_info.length < file_length)
+ for (file_count = 0 ; embed_info.offset + embed_info.length < filelen ; )
{
file_count ++ ;
@@ -237,22 +237,3 @@
sf_close (sndfile) ;
} /* write_file_at_end */
-static off_t
-get_file_length (int fd)
-{ struct stat statbuf ;
-
- if (fstat (fd, &statbuf) == -1)
- { printf ("\n\nError : fstat error : %s\n\n", strerror (errno)) ;
- exit (1) ;
- } ;
-
- return statbuf.st_size ;
-} /* get_file_length */
-
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: c1a09b0e-57c9-4306-b69e-a865d44eecb3
-*/
Added: freeswitch/trunk/libs/libsndfile/tests/ogg_test.c
==============================================================================
--- (empty file)
+++ freeswitch/trunk/libs/libsndfile/tests/ogg_test.c Thu May 21 16:09:30 2009
@@ -0,0 +1,341 @@
+/*
+** Copyright (C) 2007-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
+**
+** This program is free software; you can redistribute it and/or modify
+** it under the terms of the GNU General Public License as published by
+** the Free Software Foundation; either version 2 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#include "sfconfig.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include <math.h>
+
+#include <sndfile.h>
+
+#include "utils.h"
+
+#define SAMPLE_RATE 44100
+#define DATA_LENGTH (SAMPLE_RATE / 8)
+
+typedef union
+{ double d [DATA_LENGTH] ;
+ float f [DATA_LENGTH] ;
+ int i [DATA_LENGTH] ;
+ short s [DATA_LENGTH] ;
+} BUFFER ;
+
+static BUFFER data_out ;
+static BUFFER data_in ;
+
+static void
+ogg_short_test (void)
+{ const char * filename = "vorbis_short.oga" ;
+
+ SNDFILE * file ;
+ SF_INFO sfinfo ;
+ short seek_data [10] ;
+ unsigned k ;
+
+ print_test_name ("ogg_short_test", filename) ;
+
+ /* Generate float data. */
+ gen_windowed_sine_float (data_out.f, ARRAY_LEN (data_out.f), 1.0 * 0x7F00) ;
+
+ /* Convert to shorteger. */
+ for (k = 0 ; k < ARRAY_LEN (data_out.s) ; k++)
+ data_out.s [k] = lrintf (data_out.f [k]) ;
+
+ memset (&sfinfo, 0, sizeof (sfinfo)) ;
+
+ /* Set up output file type. */
+ sfinfo.format = SF_FORMAT_OGG | SF_FORMAT_VORBIS ;
+ sfinfo.channels = 1 ;
+ sfinfo.samplerate = SAMPLE_RATE ;
+
+ /* Write the output file. */
+ file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_FALSE, __LINE__) ;
+ test_write_short_or_die (file, 0, data_out.s, ARRAY_LEN (data_out.s), __LINE__) ;
+ sf_close (file) ;
+
+ /* Read the file in again. */
+ memset (&sfinfo, 0, sizeof (sfinfo)) ;
+
+ file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_FALSE, __LINE__) ;
+ test_read_short_or_die (file, 0, data_in.s, ARRAY_LEN (data_in.s), __LINE__) ;
+ sf_close (file) ;
+
+ puts ("ok") ;
+
+ /* Test seeking. */
+ print_test_name ("ogg_seek_test", filename) ;
+
+ file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_FALSE, __LINE__) ;
+
+ test_seek_or_die (file, 10, SEEK_SET, 10, sfinfo.channels, __LINE__) ;
+ test_read_short_or_die (file, 0, seek_data, ARRAY_LEN (seek_data), __LINE__) ;
+ compare_short_or_die (seek_data, data_in.s + 10, ARRAY_LEN (seek_data), __LINE__) ;
+
+ sf_close (file) ;
+
+ puts ("ok") ;
+
+ unlink (filename) ;
+} /* ogg_short_test */
+
+static void
+ogg_int_test (void)
+{ const char * filename = "vorbis_int.oga" ;
+
+ SNDFILE * file ;
+ SF_INFO sfinfo ;
+ int seek_data [10] ;
+ unsigned k ;
+
+ print_test_name ("ogg_int_test", filename) ;
+
+ /* Generate float data. */
+ gen_windowed_sine_float (data_out.f, ARRAY_LEN (data_out.f), 1.0 * 0x7FFF0000) ;
+
+ /* Convert to integer. */
+ for (k = 0 ; k < ARRAY_LEN (data_out.i) ; k++)
+ data_out.i [k] = lrintf (data_out.f [k]) ;
+
+ memset (&sfinfo, 0, sizeof (sfinfo)) ;
+
+ /* Set up output file type. */
+ sfinfo.format = SF_FORMAT_OGG | SF_FORMAT_VORBIS ;
+ sfinfo.channels = 1 ;
+ sfinfo.samplerate = SAMPLE_RATE ;
+
+ /* Write the output file. */
+ file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_FALSE, __LINE__) ;
+ test_write_int_or_die (file, 0, data_out.i, ARRAY_LEN (data_out.i), __LINE__) ;
+ sf_close (file) ;
+
+ /* Read the file in again. */
+ memset (&sfinfo, 0, sizeof (sfinfo)) ;
+
+ file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_FALSE, __LINE__) ;
+ test_read_int_or_die (file, 0, data_in.i, ARRAY_LEN (data_in.i), __LINE__) ;
+ sf_close (file) ;
+
+ puts ("ok") ;
+
+ /* Test seeking. */
+ print_test_name ("ogg_seek_test", filename) ;
+
+ file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_FALSE, __LINE__) ;
+
+ test_seek_or_die (file, 10, SEEK_SET, 10, sfinfo.channels, __LINE__) ;
+ test_read_int_or_die (file, 0, seek_data, ARRAY_LEN (seek_data), __LINE__) ;
+ compare_int_or_die (seek_data, data_in.i + 10, ARRAY_LEN (seek_data), __LINE__) ;
+
+ sf_close (file) ;
+
+ puts ("ok") ;
+
+ unlink (filename) ;
+} /* ogg_int_test */
+
+static void
+ogg_float_test (void)
+{ const char * filename = "vorbis_float.oga" ;
+
+ SNDFILE * file ;
+ SF_INFO sfinfo ;
+ float seek_data [10] ;
+
+ print_test_name ("ogg_float_test", filename) ;
+
+ gen_windowed_sine_float (data_out.f, ARRAY_LEN (data_out.f), 0.95) ;
+
+ memset (&sfinfo, 0, sizeof (sfinfo)) ;
+
+ /* Set up output file type. */
+ sfinfo.format = SF_FORMAT_OGG | SF_FORMAT_VORBIS ;
+ sfinfo.channels = 1 ;
+ sfinfo.samplerate = SAMPLE_RATE ;
+
+ /* Write the output file. */
+ file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_FALSE, __LINE__) ;
+ test_write_float_or_die (file, 0, data_out.f, ARRAY_LEN (data_out.f), __LINE__) ;
+ sf_close (file) ;
+
+ /* Read the file in again. */
+ memset (&sfinfo, 0, sizeof (sfinfo)) ;
+
+ file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_FALSE, __LINE__) ;
+ test_read_float_or_die (file, 0, data_in.f, ARRAY_LEN (data_in.f), __LINE__) ;
+ sf_close (file) ;
+
+ puts ("ok") ;
+
+ /* Test seeking. */
+ print_test_name ("ogg_seek_test", filename) ;
+
+ file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_FALSE, __LINE__) ;
+
+ test_seek_or_die (file, 10, SEEK_SET, 10, sfinfo.channels, __LINE__) ;
+ test_read_float_or_die (file, 0, seek_data, ARRAY_LEN (seek_data), __LINE__) ;
+ compare_float_or_die (seek_data, data_in.f + 10, ARRAY_LEN (seek_data), __LINE__) ;
+
+ sf_close (file) ;
+
+ puts ("ok") ;
+
+ unlink (filename) ;
+} /* ogg_float_test */
+
+static void
+ogg_double_test (void)
+{ const char * filename = "vorbis_double.oga" ;
+
+ SNDFILE * file ;
+ SF_INFO sfinfo ;
+ double seek_data [10] ;
+
+ print_test_name ("ogg_double_test", filename) ;
+
+ gen_windowed_sine_double (data_out.d, ARRAY_LEN (data_out.d), 0.95) ;
+
+ memset (&sfinfo, 0, sizeof (sfinfo)) ;
+
+ /* Set up output file type. */
+ sfinfo.format = SF_FORMAT_OGG | SF_FORMAT_VORBIS ;
+ sfinfo.channels = 1 ;
+ sfinfo.samplerate = SAMPLE_RATE ;
+
+ /* Write the output file. */
+ file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_FALSE, __LINE__) ;
+ test_write_double_or_die (file, 0, data_out.d, ARRAY_LEN (data_out.d), __LINE__) ;
+ sf_close (file) ;
+
+ /* Read the file in again. */
+ memset (&sfinfo, 0, sizeof (sfinfo)) ;
+
+ file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_FALSE, __LINE__) ;
+ test_read_double_or_die (file, 0, data_in.d, ARRAY_LEN (data_in.d), __LINE__) ;
+ sf_close (file) ;
+
+ puts ("ok") ;
+
+ /* Test seeking. */
+ print_test_name ("ogg_seek_test", filename) ;
+
+ file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_FALSE, __LINE__) ;
+
+ test_seek_or_die (file, 10, SEEK_SET, 10, sfinfo.channels, __LINE__) ;
+ test_read_double_or_die (file, 0, seek_data, ARRAY_LEN (seek_data), __LINE__) ;
+ compare_double_or_die (seek_data, data_in.d + 10, ARRAY_LEN (seek_data), __LINE__) ;
+
+ sf_close (file) ;
+
+ puts ("ok") ;
+
+ unlink (filename) ;
+} /* ogg_double_test */
+
+
+static void
+ogg_stereo_seek_test (const char * filename, int format)
+{ static float data [SAMPLE_RATE] ;
+ static float stereo_out [SAMPLE_RATE * 2] ;
+
+ SNDFILE * file ;
+ SF_INFO sfinfo ;
+ sf_count_t pos ;
+ unsigned k ;
+
+ print_test_name (__func__, filename) ;
+
+ gen_windowed_sine_float (data, ARRAY_LEN (data), 0.95) ;
+ for (k = 0 ; k < ARRAY_LEN (data) ; k++)
+ { stereo_out [2 * k] = data [k] ;
+ stereo_out [2 * k + 1] = data [ARRAY_LEN (data) - k - 1] ;
+ } ;
+
+ memset (&sfinfo, 0, sizeof (sfinfo)) ;
+
+ /* Set up output file type. */
+ sfinfo.format = format ;
+ sfinfo.channels = 2 ;
+ sfinfo.samplerate = SAMPLE_RATE ;
+
+ /* Write the output file. */
+ file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_FALSE, __LINE__) ;
+ test_write_float_or_die (file, 0, stereo_out, ARRAY_LEN (stereo_out), __LINE__) ;
+ sf_close (file) ;
+
+ /* Open file in again for reading. */
+ memset (&sfinfo, 0, sizeof (sfinfo)) ;
+ file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_FALSE, __LINE__) ;
+
+ /* Read in the whole file. */
+ test_read_float_or_die (file, 0, stereo_out, ARRAY_LEN (stereo_out), __LINE__) ;
+
+ /* Now hammer seeking code. */
+ test_seek_or_die (file, 234, SEEK_SET, 234, sfinfo.channels, __LINE__) ;
+ test_readf_float_or_die (file, 0, data, 10, __LINE__) ;
+ compare_float_or_die (data, stereo_out + (234 * sfinfo.channels), 10, __LINE__) ;
+
+ test_seek_or_die (file, 442, SEEK_SET, 442, sfinfo.channels, __LINE__) ;
+ test_readf_float_or_die (file, 0, data, 10, __LINE__) ;
+ compare_float_or_die (data, stereo_out + (442 * sfinfo.channels), 10, __LINE__) ;
+
+ test_seek_or_die (file, 12, SEEK_CUR, 442 + 10 + 12, sfinfo.channels, __LINE__) ;
+ test_readf_float_or_die (file, 0, data, 10, __LINE__) ;
+ compare_float_or_die (data, stereo_out + ((442 + 10 + 12) * sfinfo.channels), 10, __LINE__) ;
+
+ test_seek_or_die (file, 12, SEEK_CUR, 442 + 20 + 24, sfinfo.channels, __LINE__) ;
+ test_readf_float_or_die (file, 0, data, 10, __LINE__) ;
+ compare_float_or_die (data, stereo_out + ((442 + 20 + 24) * sfinfo.channels), 10, __LINE__) ;
+
+ pos = 500 - sfinfo.frames ;
+ test_seek_or_die (file, pos, SEEK_END, 500, sfinfo.channels, __LINE__) ;
+ test_readf_float_or_die (file, 0, data, 10, __LINE__) ;
+ compare_float_or_die (data, stereo_out + (500 * sfinfo.channels), 10, __LINE__) ;
+
+ pos = 10 - sfinfo.frames ;
+ test_seek_or_die (file, pos, SEEK_END, 10, sfinfo.channels, __LINE__) ;
+ test_readf_float_or_die (file, 0, data, 10, __LINE__) ;
+ compare_float_or_die (data, stereo_out + (10 * sfinfo.channels), 10, __LINE__) ;
+
+ sf_close (file) ;
+
+ puts ("ok") ;
+ unlink (filename) ;
+} /* ogg_stereo_seek_test */
+
+
+int
+main (void)
+{
+ if (HAVE_EXTERNAL_LIBS)
+ { ogg_short_test () ;
+ ogg_int_test () ;
+ ogg_float_test () ;
+ ogg_double_test () ;
+
+ /*-ogg_stereo_seek_test ("pcm.wav", SF_FORMAT_WAV | SF_FORMAT_PCM_16) ;-*/
+ ogg_stereo_seek_test ("vorbis_seek.ogg", SF_FORMAT_OGG | SF_FORMAT_VORBIS) ;
+ }
+ else
+ puts (" No Ogg/Vorbis tests because Ogg/Vorbis support was not compiled in.") ;
+
+ return 0 ;
+} /* main */
Modified: freeswitch/trunk/libs/libsndfile/tests/pcm_test.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/tests/pcm_test.c (original)
+++ freeswitch/trunk/libs/libsndfile/tests/pcm_test.c Thu May 21 16:09:30 2009
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 1999-2004 Erik de Castro Lopo <erikd at mega-nerd.com>
+** Copyright (C) 1999-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
@@ -21,6 +21,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <math.h>
#if HAVE_UNISTD_H
#include <unistd.h>
@@ -28,26 +29,25 @@
#include <sndfile.h>
-#include "float_cast.h"
#include "utils.h"
#define BUFFER_SIZE (1<<12)
static void lrintf_test (void) ;
-static void pcm_test_bits_8 (const char *filename, int filetype, int hash) ;
-static void pcm_test_bits_16 (const char *filename, int filetype, int hash) ;
-static void pcm_test_bits_24 (const char *filename, int filetype, int hash) ;
-static void pcm_test_bits_32 (const char *filename, int filetype, int hash) ;
+static void pcm_test_bits_8 (const char *filename, int filetype, uint64_t hash) ;
+static void pcm_test_bits_16 (const char *filename, int filetype, uint64_t hash) ;
+static void pcm_test_bits_24 (const char *filename, int filetype, uint64_t hash) ;
+static void pcm_test_bits_32 (const char *filename, int filetype, uint64_t hash) ;
-static void pcm_test_float (const char *filename, int filetype, int hash, int replace_float) ;
-static void pcm_test_double (const char *filename, int filetype, int hash, int replace_float) ;
+static void pcm_test_float (const char *filename, int filetype, uint64_t hash, int replace_float) ;
+static void pcm_test_double (const char *filename, int filetype, uint64_t hash, int replace_float) ;
typedef union
-{ double d [BUFFER_SIZE + 1];
- float f [BUFFER_SIZE + 1];
- int i [BUFFER_SIZE + 1];
- short s [BUFFER_SIZE + 1];
+{ double d [BUFFER_SIZE + 1] ;
+ float f [BUFFER_SIZE + 1] ;
+ int i [BUFFER_SIZE + 1] ;
+ short s [BUFFER_SIZE + 1] ;
} BUFFER ;
/* Data written to the file. */
@@ -61,32 +61,32 @@
{
lrintf_test () ;
- pcm_test_bits_8 ("pcm-s8.raw", SF_FORMAT_RAW | SF_FORMAT_PCM_S8, 0x9ae33814) ;
- pcm_test_bits_8 ("pcm-u8.raw", SF_FORMAT_RAW | SF_FORMAT_PCM_U8, 0x651d4694) ;
+ pcm_test_bits_8 ("pcm-s8.raw", SF_FORMAT_RAW | SF_FORMAT_PCM_S8, 0x1cda335091249dbfLL) ;
+ pcm_test_bits_8 ("pcm-u8.raw", SF_FORMAT_RAW | SF_FORMAT_PCM_U8, 0x7f748c433d695f3fLL) ;
- pcm_test_bits_16 ("le-pcm16.raw", SF_ENDIAN_LITTLE | SF_FORMAT_RAW | SF_FORMAT_PCM_16, 0x16866fa0) ;
- pcm_test_bits_16 ("be-pcm16.raw", SF_ENDIAN_BIG | SF_FORMAT_RAW | SF_FORMAT_PCM_16, 0xc571826c) ;
+ pcm_test_bits_16 ("le-pcm16.raw", SF_ENDIAN_LITTLE | SF_FORMAT_RAW | SF_FORMAT_PCM_16, 0x3a2b956c881ebf08LL) ;
+ pcm_test_bits_16 ("be-pcm16.raw", SF_ENDIAN_BIG | SF_FORMAT_RAW | SF_FORMAT_PCM_16, 0xd9e2f840c55750f8LL) ;
- pcm_test_bits_24 ("le-pcm24.raw", SF_ENDIAN_LITTLE | SF_FORMAT_RAW | SF_FORMAT_PCM_24, 0x658e4bb6) ;
- pcm_test_bits_24 ("be-pcm24.raw", SF_ENDIAN_BIG | SF_FORMAT_RAW | SF_FORMAT_PCM_24, 0xbf8cde4a) ;
+ pcm_test_bits_24 ("le-pcm24.raw", SF_ENDIAN_LITTLE | SF_FORMAT_RAW | SF_FORMAT_PCM_24, 0x933b6a759ab496f8LL) ;
+ pcm_test_bits_24 ("be-pcm24.raw", SF_ENDIAN_BIG | SF_FORMAT_RAW | SF_FORMAT_PCM_24, 0xbb1f3eaf9c30b6f8LL) ;
- pcm_test_bits_32 ("le-pcm32.raw", SF_ENDIAN_LITTLE | SF_FORMAT_RAW | SF_FORMAT_PCM_32, 0x04c84a70) ;
- pcm_test_bits_32 ("be-pcm32.raw", SF_ENDIAN_BIG | SF_FORMAT_RAW | SF_FORMAT_PCM_32, 0x069c84f6) ;
+ pcm_test_bits_32 ("le-pcm32.raw", SF_ENDIAN_LITTLE | SF_FORMAT_RAW | SF_FORMAT_PCM_32, 0xa77aece1c1c17f08LL) ;
+ pcm_test_bits_32 ("be-pcm32.raw", SF_ENDIAN_BIG | SF_FORMAT_RAW | SF_FORMAT_PCM_32, 0x3099ddf142d0b0f8LL) ;
/* Lite remove start */
- pcm_test_float ("le-float.raw", SF_ENDIAN_LITTLE | SF_FORMAT_RAW | SF_FORMAT_FLOAT, 0xbb836603, SF_FALSE) ;
- pcm_test_float ("be-float.raw", SF_ENDIAN_BIG | SF_FORMAT_RAW | SF_FORMAT_FLOAT, 0x903cd8fc, SF_FALSE) ;
+ pcm_test_float ("le-float.raw", SF_ENDIAN_LITTLE | SF_FORMAT_RAW | SF_FORMAT_FLOAT, 0x3c2ad04f7554267aLL, SF_FALSE) ;
+ pcm_test_float ("be-float.raw", SF_ENDIAN_BIG | SF_FORMAT_RAW | SF_FORMAT_FLOAT, 0x074de3e248fa9186LL, SF_FALSE) ;
- pcm_test_double ("le-double.raw", SF_ENDIAN_LITTLE | SF_FORMAT_RAW | SF_FORMAT_DOUBLE, 0xbf84448e, SF_FALSE) ;
- pcm_test_double ("be-double.raw", SF_ENDIAN_BIG | SF_FORMAT_RAW | SF_FORMAT_DOUBLE, 0xaf3d9fb5, SF_FALSE) ;
+ pcm_test_double ("le-double.raw", SF_ENDIAN_LITTLE | SF_FORMAT_RAW | SF_FORMAT_DOUBLE, 0xc682726f958f669cLL, SF_FALSE) ;
+ pcm_test_double ("be-double.raw", SF_ENDIAN_BIG | SF_FORMAT_RAW | SF_FORMAT_DOUBLE, 0xd9a3583f8ee51164LL, SF_FALSE) ;
puts ("Test IEEE replacement code.") ;
- pcm_test_float ("le-float.raw", SF_ENDIAN_LITTLE | SF_FORMAT_RAW | SF_FORMAT_FLOAT, 0xbb836603, SF_TRUE) ;
- pcm_test_float ("be-float.raw", SF_ENDIAN_BIG | SF_FORMAT_RAW | SF_FORMAT_FLOAT, 0x903cd8fc, SF_TRUE) ;
+ pcm_test_float ("le-float.raw", SF_ENDIAN_LITTLE | SF_FORMAT_RAW | SF_FORMAT_FLOAT, 0x3c2ad04f7554267aLL, SF_TRUE) ;
+ pcm_test_float ("be-float.raw", SF_ENDIAN_BIG | SF_FORMAT_RAW | SF_FORMAT_FLOAT, 0x074de3e248fa9186LL, SF_TRUE) ;
- pcm_test_double ("le-double.raw", SF_ENDIAN_LITTLE | SF_FORMAT_RAW | SF_FORMAT_DOUBLE, 0xbf84448e, SF_TRUE) ;
- pcm_test_double ("be-double.raw", SF_ENDIAN_BIG | SF_FORMAT_RAW | SF_FORMAT_DOUBLE, 0xaf3d9fb5, SF_TRUE) ;
+ pcm_test_double ("le-double.raw", SF_ENDIAN_LITTLE | SF_FORMAT_RAW | SF_FORMAT_DOUBLE, 0xc682726f958f669cLL, SF_TRUE) ;
+ pcm_test_double ("be-double.raw", SF_ENDIAN_BIG | SF_FORMAT_RAW | SF_FORMAT_DOUBLE, 0xd9a3583f8ee51164LL, SF_TRUE) ;
/* Lite remove end */
return 0 ;
@@ -125,7 +125,7 @@
} /* lrintf_test */
static void
-pcm_test_bits_8 (const char *filename, int filetype, int hash)
+pcm_test_bits_8 (const char *filename, int filetype, uint64_t hash)
{ SNDFILE *file ;
SF_INFO sfinfo ;
int k, items, zero_count ;
@@ -392,7 +392,7 @@
} /* pcm_test_bits_8 */
static void
-pcm_test_bits_16 (const char *filename, int filetype, int hash)
+pcm_test_bits_16 (const char *filename, int filetype, uint64_t hash)
{ SNDFILE *file ;
SF_INFO sfinfo ;
int k, items, zero_count ;
@@ -659,7 +659,7 @@
} /* pcm_test_bits_16 */
static void
-pcm_test_bits_24 (const char *filename, int filetype, int hash)
+pcm_test_bits_24 (const char *filename, int filetype, uint64_t hash)
{ SNDFILE *file ;
SF_INFO sfinfo ;
int k, items, zero_count ;
@@ -926,7 +926,7 @@
} /* pcm_test_bits_24 */
static void
-pcm_test_bits_32 (const char *filename, int filetype, int hash)
+pcm_test_bits_32 (const char *filename, int filetype, uint64_t hash)
{ SNDFILE *file ;
SF_INFO sfinfo ;
int k, items, zero_count ;
@@ -1198,7 +1198,7 @@
*/
static void
-pcm_test_float (const char *filename, int filetype, int hash, int replace_float)
+pcm_test_float (const char *filename, int filetype, uint64_t hash, int replace_float)
{ SNDFILE *file ;
SF_INFO sfinfo ;
int k, items, frames ;
@@ -1452,7 +1452,7 @@
} /* pcm_test_float */
static void
-pcm_test_double (const char *filename, int filetype, int hash, int replace_float)
+pcm_test_double (const char *filename, int filetype, uint64_t hash, int replace_float)
{ SNDFILE *file ;
SF_INFO sfinfo ;
int k, items, frames ;
@@ -1727,5 +1727,3 @@
/*==============================================================================
*/
-
-
Modified: freeswitch/trunk/libs/libsndfile/tests/pcm_test.def
==============================================================================
--- freeswitch/trunk/libs/libsndfile/tests/pcm_test.def (original)
+++ freeswitch/trunk/libs/libsndfile/tests/pcm_test.def Thu May 21 16:09:30 2009
@@ -32,11 +32,3 @@
float_func = "(k * ((k % 2) ? 333333 : -333333))" ;
} ;
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: a939b77e-4175-460b-a393-fb38012ded7c
-*/
-
Modified: freeswitch/trunk/libs/libsndfile/tests/pcm_test.tpl
==============================================================================
--- freeswitch/trunk/libs/libsndfile/tests/pcm_test.tpl (original)
+++ freeswitch/trunk/libs/libsndfile/tests/pcm_test.tpl Thu May 21 16:09:30 2009
@@ -1,6 +1,6 @@
[+ AutoGen5 template c +]
/*
-** Copyright (C) 1999-2004 Erik de Castro Lopo <erikd at mega-nerd.com>
+** Copyright (C) 1999-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
@@ -22,6 +22,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <math.h>
#if HAVE_UNISTD_H
#include <unistd.h>
@@ -29,7 +30,6 @@
#include <sndfile.h>
-#include "float_cast.h"
#include "utils.h"
#define BUFFER_SIZE (1<<12)
@@ -37,17 +37,17 @@
static void lrintf_test (void) ;
[+ FOR data_type
-+]static void pcm_test_[+ (get "name") +] (const char *filename, int filetype, int hash) ;
++]static void pcm_test_[+ (get "name") +] (const char *filename, int filetype, uint64_t hash) ;
[+ ENDFOR data_type
+]
-static void pcm_test_float (const char *filename, int filetype, int hash, int replace_float) ;
-static void pcm_test_double (const char *filename, int filetype, int hash, int replace_float) ;
+static void pcm_test_float (const char *filename, int filetype, uint64_t hash, int replace_float) ;
+static void pcm_test_double (const char *filename, int filetype, uint64_t hash, int replace_float) ;
typedef union
-{ double d [BUFFER_SIZE + 1];
- float f [BUFFER_SIZE + 1];
- int i [BUFFER_SIZE + 1];
- short s [BUFFER_SIZE + 1];
+{ double d [BUFFER_SIZE + 1] ;
+ float f [BUFFER_SIZE + 1] ;
+ int i [BUFFER_SIZE + 1] ;
+ short s [BUFFER_SIZE + 1] ;
} BUFFER ;
/* Data written to the file. */
@@ -61,32 +61,32 @@
{
lrintf_test () ;
- pcm_test_bits_8 ("pcm-s8.raw", SF_FORMAT_RAW | SF_FORMAT_PCM_S8, 0x9ae33814) ;
- pcm_test_bits_8 ("pcm-u8.raw", SF_FORMAT_RAW | SF_FORMAT_PCM_U8, 0x651d4694) ;
+ pcm_test_bits_8 ("pcm-s8.raw", SF_FORMAT_RAW | SF_FORMAT_PCM_S8, 0x1cda335091249dbfLL) ;
+ pcm_test_bits_8 ("pcm-u8.raw", SF_FORMAT_RAW | SF_FORMAT_PCM_U8, 0x7f748c433d695f3fLL) ;
- pcm_test_bits_16 ("le-pcm16.raw", SF_ENDIAN_LITTLE | SF_FORMAT_RAW | SF_FORMAT_PCM_16, 0x16866fa0) ;
- pcm_test_bits_16 ("be-pcm16.raw", SF_ENDIAN_BIG | SF_FORMAT_RAW | SF_FORMAT_PCM_16, 0xc571826c) ;
+ pcm_test_bits_16 ("le-pcm16.raw", SF_ENDIAN_LITTLE | SF_FORMAT_RAW | SF_FORMAT_PCM_16, 0x3a2b956c881ebf08LL) ;
+ pcm_test_bits_16 ("be-pcm16.raw", SF_ENDIAN_BIG | SF_FORMAT_RAW | SF_FORMAT_PCM_16, 0xd9e2f840c55750f8LL) ;
- pcm_test_bits_24 ("le-pcm24.raw", SF_ENDIAN_LITTLE | SF_FORMAT_RAW | SF_FORMAT_PCM_24, 0x658e4bb6) ;
- pcm_test_bits_24 ("be-pcm24.raw", SF_ENDIAN_BIG | SF_FORMAT_RAW | SF_FORMAT_PCM_24, 0xbf8cde4a) ;
+ pcm_test_bits_24 ("le-pcm24.raw", SF_ENDIAN_LITTLE | SF_FORMAT_RAW | SF_FORMAT_PCM_24, 0x933b6a759ab496f8LL) ;
+ pcm_test_bits_24 ("be-pcm24.raw", SF_ENDIAN_BIG | SF_FORMAT_RAW | SF_FORMAT_PCM_24, 0xbb1f3eaf9c30b6f8LL) ;
- pcm_test_bits_32 ("le-pcm32.raw", SF_ENDIAN_LITTLE | SF_FORMAT_RAW | SF_FORMAT_PCM_32, 0x04c84a70) ;
- pcm_test_bits_32 ("be-pcm32.raw", SF_ENDIAN_BIG | SF_FORMAT_RAW | SF_FORMAT_PCM_32, 0x069c84f6) ;
+ pcm_test_bits_32 ("le-pcm32.raw", SF_ENDIAN_LITTLE | SF_FORMAT_RAW | SF_FORMAT_PCM_32, 0xa77aece1c1c17f08LL) ;
+ pcm_test_bits_32 ("be-pcm32.raw", SF_ENDIAN_BIG | SF_FORMAT_RAW | SF_FORMAT_PCM_32, 0x3099ddf142d0b0f8LL) ;
/* Lite remove start */
- pcm_test_float ("le-float.raw", SF_ENDIAN_LITTLE | SF_FORMAT_RAW | SF_FORMAT_FLOAT, 0xbb836603, SF_FALSE) ;
- pcm_test_float ("be-float.raw", SF_ENDIAN_BIG | SF_FORMAT_RAW | SF_FORMAT_FLOAT, 0x903cd8fc, SF_FALSE) ;
+ pcm_test_float ("le-float.raw", SF_ENDIAN_LITTLE | SF_FORMAT_RAW | SF_FORMAT_FLOAT, 0x3c2ad04f7554267aLL, SF_FALSE) ;
+ pcm_test_float ("be-float.raw", SF_ENDIAN_BIG | SF_FORMAT_RAW | SF_FORMAT_FLOAT, 0x074de3e248fa9186LL, SF_FALSE) ;
- pcm_test_double ("le-double.raw", SF_ENDIAN_LITTLE | SF_FORMAT_RAW | SF_FORMAT_DOUBLE, 0xbf84448e, SF_FALSE) ;
- pcm_test_double ("be-double.raw", SF_ENDIAN_BIG | SF_FORMAT_RAW | SF_FORMAT_DOUBLE, 0xaf3d9fb5, SF_FALSE) ;
+ pcm_test_double ("le-double.raw", SF_ENDIAN_LITTLE | SF_FORMAT_RAW | SF_FORMAT_DOUBLE, 0xc682726f958f669cLL, SF_FALSE) ;
+ pcm_test_double ("be-double.raw", SF_ENDIAN_BIG | SF_FORMAT_RAW | SF_FORMAT_DOUBLE, 0xd9a3583f8ee51164LL, SF_FALSE) ;
puts ("Test IEEE replacement code.") ;
- pcm_test_float ("le-float.raw", SF_ENDIAN_LITTLE | SF_FORMAT_RAW | SF_FORMAT_FLOAT, 0xbb836603, SF_TRUE) ;
- pcm_test_float ("be-float.raw", SF_ENDIAN_BIG | SF_FORMAT_RAW | SF_FORMAT_FLOAT, 0x903cd8fc, SF_TRUE) ;
+ pcm_test_float ("le-float.raw", SF_ENDIAN_LITTLE | SF_FORMAT_RAW | SF_FORMAT_FLOAT, 0x3c2ad04f7554267aLL, SF_TRUE) ;
+ pcm_test_float ("be-float.raw", SF_ENDIAN_BIG | SF_FORMAT_RAW | SF_FORMAT_FLOAT, 0x074de3e248fa9186LL, SF_TRUE) ;
- pcm_test_double ("le-double.raw", SF_ENDIAN_LITTLE | SF_FORMAT_RAW | SF_FORMAT_DOUBLE, 0xbf84448e, SF_TRUE) ;
- pcm_test_double ("be-double.raw", SF_ENDIAN_BIG | SF_FORMAT_RAW | SF_FORMAT_DOUBLE, 0xaf3d9fb5, SF_TRUE) ;
+ pcm_test_double ("le-double.raw", SF_ENDIAN_LITTLE | SF_FORMAT_RAW | SF_FORMAT_DOUBLE, 0xc682726f958f669cLL, SF_TRUE) ;
+ pcm_test_double ("be-double.raw", SF_ENDIAN_BIG | SF_FORMAT_RAW | SF_FORMAT_DOUBLE, 0xd9a3583f8ee51164LL, SF_TRUE) ;
/* Lite remove end */
return 0 ;
@@ -126,7 +126,7 @@
[+ FOR data_type
+]static void
-pcm_test_[+ (get "name") +] (const char *filename, int filetype, int hash)
+pcm_test_[+ (get "name") +] (const char *filename, int filetype, uint64_t hash)
{ SNDFILE *file ;
SF_INFO sfinfo ;
int k, items, zero_count ;
@@ -399,7 +399,7 @@
*/
static void
-pcm_test_float (const char *filename, int filetype, int hash, int replace_float)
+pcm_test_float (const char *filename, int filetype, uint64_t hash, int replace_float)
{ SNDFILE *file ;
SF_INFO sfinfo ;
int k, items, frames ;
@@ -653,7 +653,7 @@
} /* pcm_test_float */
static void
-pcm_test_double (const char *filename, int filetype, int hash, int replace_float)
+pcm_test_double (const char *filename, int filetype, uint64_t hash, int replace_float)
{ SNDFILE *file ;
SF_INFO sfinfo ;
int k, items, frames ;
@@ -928,13 +928,3 @@
/*==============================================================================
*/
-
-[+ COMMENT
-
- Do not edit or modify anything in this comment block.
- The following line is a file identity tag for the GNU Arch
- revision control system.
-
- arch-tag: cad1443b-99d9-414e-883f-178817600d40
-
-+]
Modified: freeswitch/trunk/libs/libsndfile/tests/peak_chunk_test.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/tests/peak_chunk_test.c (original)
+++ freeswitch/trunk/libs/libsndfile/tests/peak_chunk_test.c Thu May 21 16:09:30 2009
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 2001-2004 Erik de Castro Lopo <erikd at mega-nerd.com>
+** Copyright (C) 2001-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
@@ -36,6 +36,7 @@
static void test_float_peak (const char *filename, int filetype) ;
+static void read_write_peak_test (const char *filename, int filetype) ;
static void check_logged_peaks (char *buffer) ;
@@ -59,17 +60,22 @@
exit (1) ;
} ;
- do_all=!strcmp (argv [1], "all") ;
+ do_all = ! strcmp (argv [1], "all") ;
if (do_all || ! strcmp (argv [1], "wav"))
{ test_float_peak ("peak_float.wav", SF_FORMAT_WAV | SF_FORMAT_FLOAT) ;
test_float_peak ("peak_float.wavex", SF_FORMAT_WAVEX | SF_FORMAT_FLOAT) ;
test_float_peak ("peak_float.rifx", SF_ENDIAN_BIG | SF_FORMAT_WAV | SF_FORMAT_FLOAT) ;
+
+ read_write_peak_test ("rw_peak.wav", SF_FORMAT_WAV | SF_FORMAT_FLOAT) ;
+ read_write_peak_test ("rw_peak.wavex", SF_FORMAT_WAVEX | SF_FORMAT_FLOAT) ;
test_count++ ;
} ;
if (do_all || ! strcmp (argv [1], "aiff"))
{ test_float_peak ("peak_float.aiff", SF_FORMAT_AIFF | SF_FORMAT_FLOAT) ;
+
+ read_write_peak_test ("rw_peak.aiff", SF_FORMAT_AIFF | SF_FORMAT_FLOAT) ;
test_count++ ;
} ;
@@ -95,6 +101,7 @@
print_test_name ("test_float_peak", filename) ;
+ memset (&sfinfo, 0, sizeof (sfinfo)) ;
sfinfo.samplerate = 44100 ;
sfinfo.format = filetype ;
sfinfo.channels = 4 ;
@@ -267,12 +274,12 @@
} ;
if (position == 0)
{ printf ("\n\nLine %d: peak position for channel %d should not be at offset 0.\n", __LINE__, chan) ;
- printf (buffer) ;
+ printf ("%s", buffer) ;
exit (1) ;
} ;
if (chan != k || fabs ((position) * 0.01 - value) > 1e-6)
{ printf ("\n\nLine %d: Error : peak value incorrect!\n", __LINE__) ;
- printf (buffer) ;
+ printf ("%s", buffer) ;
printf ("\n\nLine %d: %d %f %f\n", __LINE__, chan, position * 0.01, value) ;
exit (1) ;
} ;
@@ -280,10 +287,62 @@
} ;
} /* check_logged_peaks */
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: f10ca506-5808-4393-9d58-e3ec201fb7ee
-*/
+
+static void
+read_write_peak_test (const char *filename, int filetype)
+{ SNDFILE *file ;
+ SF_INFO sfinfo ;
+
+ double small_data [10] ;
+ double max_peak = 0.0 ;
+ unsigned k ;
+
+ print_test_name (__func__, filename) ;
+
+ for (k = 0 ; k < ARRAY_LEN (small_data) ; k ++)
+ small_data [k] = 0.1 ;
+
+ sfinfo.samplerate = 44100 ;
+ sfinfo.channels = 2 ;
+ sfinfo.format = filetype ;
+ sfinfo.frames = 0 ;
+
+ /* Open the file, add peak chunk and write samples with value 0.1. */
+ file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_FALSE, __LINE__) ;
+
+ sf_command (file, SFC_SET_ADD_PEAK_CHUNK, NULL, SF_TRUE) ;
+
+ test_write_double_or_die (file, 0, small_data, ARRAY_LEN (small_data), __LINE__) ;
+
+ sf_close (file) ;
+
+ /* Open the fiel RDWR, write sample valied 1.25. */
+ file = test_open_file_or_die (filename, SFM_RDWR, &sfinfo, SF_FALSE, __LINE__) ;
+
+ for (k = 0 ; k < ARRAY_LEN (small_data) ; k ++)
+ small_data [k] = 1.0 ;
+
+ test_write_double_or_die (file, 0, small_data, ARRAY_LEN (small_data), __LINE__) ;
+
+ sf_command (file, SFC_GET_SIGNAL_MAX, &max_peak, sizeof (max_peak)) ;
+
+ sf_close (file) ;
+
+ exit_if_true (max_peak < 0.1, "\n\nLine %d : max peak (%5.3f) should not be 0.1.\n\n", __LINE__, max_peak) ;
+
+ /* Open the file and test the values written to the PEAK chunk. */
+ file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_FALSE, __LINE__) ;
+
+ exit_if_true (sfinfo.channels * sfinfo.frames != 2 * ARRAY_LEN (small_data),
+ "Line %d : frame count is %ld, should be %d\n", __LINE__, SF_COUNT_TO_LONG (sfinfo.frames), 2 * ARRAY_LEN (small_data)) ;
+
+ sf_command (file, SFC_GET_SIGNAL_MAX, &max_peak, sizeof (double)) ;
+
+ sf_close (file) ;
+
+ exit_if_true (max_peak < 1.0, "\n\nLine %d : max peak (%5.3f) should be 1.0.\n\n", __LINE__, max_peak) ;
+
+ unlink (filename) ;
+ puts ("ok") ;
+} /* read_write_peak_test */
+
Modified: freeswitch/trunk/libs/libsndfile/tests/pipe_test.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/tests/pipe_test.c (original)
+++ freeswitch/trunk/libs/libsndfile/tests/pipe_test.c Thu May 21 16:09:30 2009
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 2001-2004 Erik de Castro Lopo <erikd at mega-nerd.com>
+** Copyright (C) 2001-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
@@ -41,6 +41,7 @@
#include <unistd.h>
#endif
+#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/wait.h>
@@ -94,7 +95,7 @@
{ int k ;
if (file_exists ("libsndfile.spec.in"))
- chdir ("tests") ;
+ exit_if_true (chdir ("tests") != 0, "\n Error : chdir ('tests') failed.\n") ;
for (k = 0 ; read_only_types [k].format ; k++)
pipe_read_test (read_only_types [k].format, read_only_types [k].ext) ;
@@ -192,7 +193,7 @@
/*
** Create the pipe.
*/
- pipe (pipefd) ;
+ exit_if_true (pipe (pipefd) != 0, "\n\n%s %d : pipe failed : %s\n", __func__, __LINE__, strerror (errno)) ;
/*
** Attach the write end of the pipe to be written to.
@@ -268,7 +269,7 @@
/*
** Create the pipe.
*/
- pipe (pipefd) ;
+ exit_if_true (pipe (pipefd) != 0, "\n\n%s %d : pipe failed : %s\n", __func__, __LINE__, strerror (errno)) ;
/*
** Attach the write end of the pipe to be written to.
@@ -344,7 +345,7 @@
/*
** Create the pipe.
*/
- pipe (pipefd) ;
+ exit_if_true (pipe (pipefd) != 0, "\n\n%s %d : pipe failed : %s\n", __func__, __LINE__, strerror (errno)) ;
/*
** Attach the write end of the pipe to be written to.
@@ -522,4 +523,3 @@
#endif
-
Modified: freeswitch/trunk/libs/libsndfile/tests/pipe_test.def
==============================================================================
--- freeswitch/trunk/libs/libsndfile/tests/pipe_test.def (original)
+++ freeswitch/trunk/libs/libsndfile/tests/pipe_test.def Thu May 21 16:09:30 2009
@@ -12,11 +12,3 @@
type_name = double ;
};
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: 5bbde7f4-71e4-4f3e-bdae-a1cb27cdf338
-*/
-
Modified: freeswitch/trunk/libs/libsndfile/tests/pipe_test.tpl
==============================================================================
--- freeswitch/trunk/libs/libsndfile/tests/pipe_test.tpl (original)
+++ freeswitch/trunk/libs/libsndfile/tests/pipe_test.tpl Thu May 21 16:09:30 2009
@@ -1,6 +1,6 @@
[+ AutoGen5 template c +]
/*
-** Copyright (C) 2001-2004 Erik de Castro Lopo <erikd at mega-nerd.com>
+** Copyright (C) 2001-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
@@ -42,6 +42,7 @@
#include <unistd.h>
#endif
+#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/wait.h>
@@ -95,7 +96,7 @@
{ int k ;
if (file_exists ("libsndfile.spec.in"))
- chdir ("tests") ;
+ exit_if_true (chdir ("tests") != 0, "\n Error : chdir ('tests') failed.\n") ;
for (k = 0 ; read_only_types [k].format ; k++)
pipe_read_test (read_only_types [k].format, read_only_types [k].ext) ;
@@ -193,7 +194,7 @@
/*
** Create the pipe.
*/
- pipe (pipefd) ;
+ exit_if_true (pipe (pipefd) != 0, "\n\n%s %d : pipe failed : %s\n", __func__, __LINE__, strerror (errno)) ;
/*
** Attach the write end of the pipe to be written to.
@@ -371,12 +372,3 @@
#endif
-[+ COMMENT
-
- Do not edit or modify anything in this comment block.
- The arch-tag line is a file identity tag for the GNU Arch
- revision control system.
-
- arch-tag: 968ad8d5-e724-41fe-8209-fa1578569dfe
-
-+]
Modified: freeswitch/trunk/libs/libsndfile/tests/raw_test.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/tests/raw_test.c (original)
+++ freeswitch/trunk/libs/libsndfile/tests/raw_test.c Thu May 21 16:09:30 2009
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 2002-2004 Erik de Castro Lopo <erikd at mega-nerd.com>
+** Copyright (C) 2002-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
@@ -186,10 +186,3 @@
puts ("ok") ;
} /* bad_raw_test */
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: 3dccee22-b0bc-4a1f-966c-8ae96f0921ae
-*/
Modified: freeswitch/trunk/libs/libsndfile/tests/scale_clip_test.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/tests/scale_clip_test.c (original)
+++ freeswitch/trunk/libs/libsndfile/tests/scale_clip_test.c Thu May 21 16:09:30 2009
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 1999-2004 Erik de Castro Lopo <erikd at mega-nerd.com>
+** Copyright (C) 1999-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
@@ -54,9 +54,27 @@
static void dbl_scale_clip_test_08 (const char *filename, int filetype, float maxval) ;
+
+static void flt_short_clip_read_test (const char *filename, int filetype) ;
+static void flt_int_clip_read_test (const char *filename, int filetype) ;
+
+static void dbl_short_clip_read_test (const char *filename, int filetype) ;
+static void dbl_int_clip_read_test (const char *filename, int filetype) ;
+
+
+
+static void short_flt_scale_write_test (const char *filename, int filetype) ;
+static void short_dbl_scale_write_test (const char *filename, int filetype) ;
+
+static void int_flt_scale_write_test (const char *filename, int filetype) ;
+static void int_dbl_scale_write_test (const char *filename, int filetype) ;
+
+
typedef union
{ double dbl [BUFFER_SIZE] ;
float flt [BUFFER_SIZE] ;
+ int i [BUFFER_SIZE] ;
+ short s [BUFFER_SIZE] ;
} BUFFER ;
/* Data buffer. */
@@ -91,6 +109,16 @@
dbl_scale_clip_test_32 ("scale_clip_be32.au", SF_ENDIAN_BIG | SF_FORMAT_AU | SF_FORMAT_PCM_32, 1.0 * 0x80000000) ;
dbl_scale_clip_test_32 ("scale_clip_le32.au", SF_ENDIAN_LITTLE | SF_FORMAT_AU | SF_FORMAT_PCM_32, 1.0 * 0x80000000) ;
+ flt_short_clip_read_test ("flt_short.au" , SF_ENDIAN_BIG | SF_FORMAT_AU | SF_FORMAT_FLOAT) ;
+ flt_int_clip_read_test ("flt_int.au" , SF_ENDIAN_LITTLE | SF_FORMAT_AU | SF_FORMAT_FLOAT) ;
+ dbl_short_clip_read_test ("dbl_short.au" , SF_ENDIAN_BIG | SF_FORMAT_AU | SF_FORMAT_DOUBLE) ;
+ dbl_int_clip_read_test ("dbl_int.au" , SF_ENDIAN_LITTLE | SF_FORMAT_AU | SF_FORMAT_DOUBLE) ;
+
+ short_flt_scale_write_test ("short_flt.au" , SF_ENDIAN_BIG | SF_FORMAT_AU | SF_FORMAT_FLOAT) ;
+ int_flt_scale_write_test ("int_flt.au" , SF_ENDIAN_LITTLE | SF_FORMAT_AU | SF_FORMAT_FLOAT) ;
+ short_dbl_scale_write_test ("short_dbl.au" , SF_ENDIAN_BIG | SF_FORMAT_AU | SF_FORMAT_DOUBLE) ;
+ int_dbl_scale_write_test ("int_dbl.au" , SF_ENDIAN_LITTLE | SF_FORMAT_AU | SF_FORMAT_DOUBLE) ;
+
return 0 ;
} /* main */
@@ -113,7 +141,7 @@
data_in = buffer_in.flt ;
for (k = 0 ; k < HALF_BUFFER_SIZE ; k++)
- { data_out [k] = SINE_AMP * sin (2 * M_PI * k / HALF_BUFFER_SIZE) ;
+ { data_out [k] = 1.2 * sin (2 * M_PI * k / HALF_BUFFER_SIZE) ;
data_out [k + HALF_BUFFER_SIZE] = data_out [k] * maxval ;
} ;
@@ -243,7 +271,7 @@
data_in = buffer_in.flt ;
for (k = 0 ; k < HALF_BUFFER_SIZE ; k++)
- { data_out [k] = SINE_AMP * sin (2 * M_PI * k / HALF_BUFFER_SIZE) ;
+ { data_out [k] = 1.2 * sin (2 * M_PI * k / HALF_BUFFER_SIZE) ;
data_out [k + HALF_BUFFER_SIZE] = data_out [k] * maxval ;
} ;
@@ -373,7 +401,7 @@
data_in = buffer_in.flt ;
for (k = 0 ; k < HALF_BUFFER_SIZE ; k++)
- { data_out [k] = SINE_AMP * sin (2 * M_PI * k / HALF_BUFFER_SIZE) ;
+ { data_out [k] = 1.2 * sin (2 * M_PI * k / HALF_BUFFER_SIZE) ;
data_out [k + HALF_BUFFER_SIZE] = data_out [k] * maxval ;
} ;
@@ -503,7 +531,7 @@
data_in = buffer_in.flt ;
for (k = 0 ; k < HALF_BUFFER_SIZE ; k++)
- { data_out [k] = SINE_AMP * sin (2 * M_PI * k / HALF_BUFFER_SIZE) ;
+ { data_out [k] = 1.2 * sin (2 * M_PI * k / HALF_BUFFER_SIZE) ;
data_out [k + HALF_BUFFER_SIZE] = data_out [k] * maxval ;
} ;
@@ -635,7 +663,7 @@
data_in = buffer_in.dbl ;
for (k = 0 ; k < HALF_BUFFER_SIZE ; k++)
- { data_out [k] = SINE_AMP * sin (2 * M_PI * k / HALF_BUFFER_SIZE) ;
+ { data_out [k] = 1.2 * sin (2 * M_PI * k / HALF_BUFFER_SIZE) ;
data_out [k + HALF_BUFFER_SIZE] = data_out [k] * maxval ;
} ;
@@ -765,7 +793,7 @@
data_in = buffer_in.dbl ;
for (k = 0 ; k < HALF_BUFFER_SIZE ; k++)
- { data_out [k] = SINE_AMP * sin (2 * M_PI * k / HALF_BUFFER_SIZE) ;
+ { data_out [k] = 1.2 * sin (2 * M_PI * k / HALF_BUFFER_SIZE) ;
data_out [k + HALF_BUFFER_SIZE] = data_out [k] * maxval ;
} ;
@@ -895,7 +923,7 @@
data_in = buffer_in.dbl ;
for (k = 0 ; k < HALF_BUFFER_SIZE ; k++)
- { data_out [k] = SINE_AMP * sin (2 * M_PI * k / HALF_BUFFER_SIZE) ;
+ { data_out [k] = 1.2 * sin (2 * M_PI * k / HALF_BUFFER_SIZE) ;
data_out [k + HALF_BUFFER_SIZE] = data_out [k] * maxval ;
} ;
@@ -1025,7 +1053,7 @@
data_in = buffer_in.dbl ;
for (k = 0 ; k < HALF_BUFFER_SIZE ; k++)
- { data_out [k] = SINE_AMP * sin (2 * M_PI * k / HALF_BUFFER_SIZE) ;
+ { data_out [k] = 1.2 * sin (2 * M_PI * k / HALF_BUFFER_SIZE) ;
data_out [k + HALF_BUFFER_SIZE] = data_out [k] * maxval ;
} ;
@@ -1144,4 +1172,682 @@
+/*==============================================================================
+*/
+
+
+static void flt_short_clip_read_test (const char *filename, int filetype)
+{ SNDFILE *file ;
+ SF_INFO sfinfo ;
+ float *data_out ;
+ short *data_in, max_value ;
+ int k ;
+
+ print_test_name ("flt_short_clip_read_test", filename) ;
+
+ data_out = buffer_out.flt ;
+ data_in = buffer_in.s ;
+
+ for (k = 0 ; k < BUFFER_SIZE ; k++)
+ data_out [k] = 0.995 * sin (4 * M_PI * k / BUFFER_SIZE) ;
+ data_out [BUFFER_SIZE / 8] = 1.0 ;
+ data_out [3 * BUFFER_SIZE / 8] = -1.000000001 ;
+ data_out [5 * BUFFER_SIZE / 8] = 1.0 ;
+ data_out [7 * BUFFER_SIZE / 8] = -1.000000001 ;
+
+ memset (&sfinfo, 0, sizeof (sfinfo)) ;
+ sfinfo.samplerate = 44100 ;
+ sfinfo.frames = 123456789 ; /* Wrong length. Library should correct this on sf_close. */
+ sfinfo.channels = 1 ;
+ sfinfo.format = filetype ;
+
+ /* Save unclipped data to the file. */
+ file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ;
+ test_write_float_or_die (file, 0, data_out, BUFFER_SIZE, __LINE__) ;
+ sf_close (file) ;
+
+ memset (&sfinfo, 0, sizeof (sfinfo)) ;
+
+ file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ;
+ sf_command (file, SFC_SET_SCALE_FLOAT_INT_READ, NULL, SF_TRUE) ;
+
+ sfinfo.format &= (SF_FORMAT_TYPEMASK | SF_FORMAT_SUBMASK) ;
+
+ if (sfinfo.format != (filetype & (SF_FORMAT_TYPEMASK | SF_FORMAT_SUBMASK)))
+ { printf ("\n\nLine %d: Returned format incorrect (0x%08X => 0x%08X).\n\n", __LINE__, filetype, sfinfo.format) ;
+ exit (1) ;
+ } ;
+
+ if (sfinfo.frames != BUFFER_SIZE)
+ { printf ("\n\nLine %d: Incorrect number of frames in file (%d => %ld).\n\n", __LINE__, BUFFER_SIZE, SF_COUNT_TO_LONG (sfinfo.frames)) ;
+ exit (1) ;
+ } ;
+
+ if (sfinfo.channels != 1)
+ { printf ("\n\nLine %d: Incorrect number of channels in file.\n\n", __LINE__) ;
+ exit (1) ;
+ } ;
+
+ check_log_buffer_or_die (file, __LINE__) ;
+
+ sf_command (file, SFC_SET_CLIPPING, NULL, SF_TRUE) ;
+ test_read_short_or_die (file, 0, data_in, BUFFER_SIZE, __LINE__) ;
+ /*-sf_command (file, SFC_SET_NORM_FLOAT, NULL, SF_FALSE) ;-*/
+ sf_close (file) ;
+
+ /* Check the first half. */
+ max_value = 0 ;
+ for (k = 0 ; k < sfinfo.frames ; k++)
+ { /* Check if data_out has different sign from data_in. */
+ if ((data_out [k] < 0.0 && data_in [k] > 0) || (data_out [k] > 0.0 && data_in [k] < 0))
+ { printf ("\n\nLine %d: Data wrap around at index %d/%d (%f -> %d).\n\n", __LINE__, k, BUFFER_SIZE, data_out [k], data_in [k]) ;
+ exit (1) ;
+ } ;
+ max_value = (max_value > abs (data_in [k])) ? max_value : abs (data_in [k]) ;
+ } ;
+
+ unlink (filename) ;
+ puts ("ok") ;
+} /* flt_short_clip_read_test */
+static void flt_int_clip_read_test (const char *filename, int filetype)
+{ SNDFILE *file ;
+ SF_INFO sfinfo ;
+ float *data_out ;
+ int *data_in, max_value ;
+ int k ;
+
+ print_test_name ("flt_int_clip_read_test", filename) ;
+
+ data_out = buffer_out.flt ;
+ data_in = buffer_in.i ;
+
+ for (k = 0 ; k < BUFFER_SIZE ; k++)
+ data_out [k] = 0.995 * sin (4 * M_PI * k / BUFFER_SIZE) ;
+ data_out [BUFFER_SIZE / 8] = 1.0 ;
+ data_out [3 * BUFFER_SIZE / 8] = -1.000000001 ;
+ data_out [5 * BUFFER_SIZE / 8] = 1.0 ;
+ data_out [7 * BUFFER_SIZE / 8] = -1.000000001 ;
+
+ memset (&sfinfo, 0, sizeof (sfinfo)) ;
+ sfinfo.samplerate = 44100 ;
+ sfinfo.frames = 123456789 ; /* Wrong length. Library should correct this on sf_close. */
+ sfinfo.channels = 1 ;
+ sfinfo.format = filetype ;
+
+ /* Save unclipped data to the file. */
+ file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ;
+ test_write_float_or_die (file, 0, data_out, BUFFER_SIZE, __LINE__) ;
+ sf_close (file) ;
+
+ memset (&sfinfo, 0, sizeof (sfinfo)) ;
+
+ file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ;
+ sf_command (file, SFC_SET_SCALE_FLOAT_INT_READ, NULL, SF_TRUE) ;
+
+ sfinfo.format &= (SF_FORMAT_TYPEMASK | SF_FORMAT_SUBMASK) ;
+
+ if (sfinfo.format != (filetype & (SF_FORMAT_TYPEMASK | SF_FORMAT_SUBMASK)))
+ { printf ("\n\nLine %d: Returned format incorrect (0x%08X => 0x%08X).\n\n", __LINE__, filetype, sfinfo.format) ;
+ exit (1) ;
+ } ;
+
+ if (sfinfo.frames != BUFFER_SIZE)
+ { printf ("\n\nLine %d: Incorrect number of frames in file (%d => %ld).\n\n", __LINE__, BUFFER_SIZE, SF_COUNT_TO_LONG (sfinfo.frames)) ;
+ exit (1) ;
+ } ;
+
+ if (sfinfo.channels != 1)
+ { printf ("\n\nLine %d: Incorrect number of channels in file.\n\n", __LINE__) ;
+ exit (1) ;
+ } ;
+
+ check_log_buffer_or_die (file, __LINE__) ;
+
+ sf_command (file, SFC_SET_CLIPPING, NULL, SF_TRUE) ;
+ test_read_int_or_die (file, 0, data_in, BUFFER_SIZE, __LINE__) ;
+ /*-sf_command (file, SFC_SET_NORM_FLOAT, NULL, SF_FALSE) ;-*/
+ sf_close (file) ;
+
+ /* Check the first half. */
+ max_value = 0 ;
+ for (k = 0 ; k < sfinfo.frames ; k++)
+ { /* Check if data_out has different sign from data_in. */
+ if ((data_out [k] < 0.0 && data_in [k] > 0) || (data_out [k] > 0.0 && data_in [k] < 0))
+ { printf ("\n\nLine %d: Data wrap around at index %d/%d (%f -> %d).\n\n", __LINE__, k, BUFFER_SIZE, data_out [k], data_in [k]) ;
+ exit (1) ;
+ } ;
+ max_value = (max_value > abs (data_in [k])) ? max_value : abs (data_in [k]) ;
+ } ;
+
+ unlink (filename) ;
+ puts ("ok") ;
+} /* flt_int_clip_read_test */
+
+static void dbl_short_clip_read_test (const char *filename, int filetype)
+{ SNDFILE *file ;
+ SF_INFO sfinfo ;
+ double *data_out ;
+ short *data_in, max_value ;
+ int k ;
+
+ print_test_name ("dbl_short_clip_read_test", filename) ;
+
+ data_out = buffer_out.dbl ;
+ data_in = buffer_in.s ;
+
+ for (k = 0 ; k < BUFFER_SIZE ; k++)
+ data_out [k] = 0.995 * sin (4 * M_PI * k / BUFFER_SIZE) ;
+ data_out [BUFFER_SIZE / 8] = 1.0 ;
+ data_out [3 * BUFFER_SIZE / 8] = -1.000000001 ;
+ data_out [5 * BUFFER_SIZE / 8] = 1.0 ;
+ data_out [7 * BUFFER_SIZE / 8] = -1.000000001 ;
+
+ memset (&sfinfo, 0, sizeof (sfinfo)) ;
+ sfinfo.samplerate = 44100 ;
+ sfinfo.frames = 123456789 ; /* Wrong length. Library should correct this on sf_close. */
+ sfinfo.channels = 1 ;
+ sfinfo.format = filetype ;
+
+ /* Save unclipped data to the file. */
+ file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ;
+ test_write_double_or_die (file, 0, data_out, BUFFER_SIZE, __LINE__) ;
+ sf_close (file) ;
+
+ memset (&sfinfo, 0, sizeof (sfinfo)) ;
+
+ file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ;
+ sf_command (file, SFC_SET_SCALE_FLOAT_INT_READ, NULL, SF_TRUE) ;
+
+ sfinfo.format &= (SF_FORMAT_TYPEMASK | SF_FORMAT_SUBMASK) ;
+
+ if (sfinfo.format != (filetype & (SF_FORMAT_TYPEMASK | SF_FORMAT_SUBMASK)))
+ { printf ("\n\nLine %d: Returned format incorrect (0x%08X => 0x%08X).\n\n", __LINE__, filetype, sfinfo.format) ;
+ exit (1) ;
+ } ;
+
+ if (sfinfo.frames != BUFFER_SIZE)
+ { printf ("\n\nLine %d: Incorrect number of frames in file (%d => %ld).\n\n", __LINE__, BUFFER_SIZE, SF_COUNT_TO_LONG (sfinfo.frames)) ;
+ exit (1) ;
+ } ;
+
+ if (sfinfo.channels != 1)
+ { printf ("\n\nLine %d: Incorrect number of channels in file.\n\n", __LINE__) ;
+ exit (1) ;
+ } ;
+
+ check_log_buffer_or_die (file, __LINE__) ;
+
+ sf_command (file, SFC_SET_CLIPPING, NULL, SF_TRUE) ;
+ test_read_short_or_die (file, 0, data_in, BUFFER_SIZE, __LINE__) ;
+ /*-sf_command (file, SFC_SET_NORM_DOUBLE, NULL, SF_FALSE) ;-*/
+ sf_close (file) ;
+
+ /* Check the first half. */
+ max_value = 0 ;
+ for (k = 0 ; k < sfinfo.frames ; k++)
+ { /* Check if data_out has different sign from data_in. */
+ if ((data_out [k] < 0.0 && data_in [k] > 0) || (data_out [k] > 0.0 && data_in [k] < 0))
+ { printf ("\n\nLine %d: Data wrap around at index %d/%d (%f -> %d).\n\n", __LINE__, k, BUFFER_SIZE, data_out [k], data_in [k]) ;
+ exit (1) ;
+ } ;
+ max_value = (max_value > abs (data_in [k])) ? max_value : abs (data_in [k]) ;
+ } ;
+
+ unlink (filename) ;
+ puts ("ok") ;
+} /* dbl_short_clip_read_test */
+static void dbl_int_clip_read_test (const char *filename, int filetype)
+{ SNDFILE *file ;
+ SF_INFO sfinfo ;
+ double *data_out ;
+ int *data_in, max_value ;
+ int k ;
+
+ print_test_name ("dbl_int_clip_read_test", filename) ;
+
+ data_out = buffer_out.dbl ;
+ data_in = buffer_in.i ;
+
+ for (k = 0 ; k < BUFFER_SIZE ; k++)
+ data_out [k] = 0.995 * sin (4 * M_PI * k / BUFFER_SIZE) ;
+ data_out [BUFFER_SIZE / 8] = 1.0 ;
+ data_out [3 * BUFFER_SIZE / 8] = -1.000000001 ;
+ data_out [5 * BUFFER_SIZE / 8] = 1.0 ;
+ data_out [7 * BUFFER_SIZE / 8] = -1.000000001 ;
+
+ memset (&sfinfo, 0, sizeof (sfinfo)) ;
+ sfinfo.samplerate = 44100 ;
+ sfinfo.frames = 123456789 ; /* Wrong length. Library should correct this on sf_close. */
+ sfinfo.channels = 1 ;
+ sfinfo.format = filetype ;
+
+ /* Save unclipped data to the file. */
+ file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ;
+ test_write_double_or_die (file, 0, data_out, BUFFER_SIZE, __LINE__) ;
+ sf_close (file) ;
+
+ memset (&sfinfo, 0, sizeof (sfinfo)) ;
+
+ file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ;
+ sf_command (file, SFC_SET_SCALE_FLOAT_INT_READ, NULL, SF_TRUE) ;
+
+ sfinfo.format &= (SF_FORMAT_TYPEMASK | SF_FORMAT_SUBMASK) ;
+
+ if (sfinfo.format != (filetype & (SF_FORMAT_TYPEMASK | SF_FORMAT_SUBMASK)))
+ { printf ("\n\nLine %d: Returned format incorrect (0x%08X => 0x%08X).\n\n", __LINE__, filetype, sfinfo.format) ;
+ exit (1) ;
+ } ;
+
+ if (sfinfo.frames != BUFFER_SIZE)
+ { printf ("\n\nLine %d: Incorrect number of frames in file (%d => %ld).\n\n", __LINE__, BUFFER_SIZE, SF_COUNT_TO_LONG (sfinfo.frames)) ;
+ exit (1) ;
+ } ;
+
+ if (sfinfo.channels != 1)
+ { printf ("\n\nLine %d: Incorrect number of channels in file.\n\n", __LINE__) ;
+ exit (1) ;
+ } ;
+
+ check_log_buffer_or_die (file, __LINE__) ;
+
+ sf_command (file, SFC_SET_CLIPPING, NULL, SF_TRUE) ;
+ test_read_int_or_die (file, 0, data_in, BUFFER_SIZE, __LINE__) ;
+ /*-sf_command (file, SFC_SET_NORM_DOUBLE, NULL, SF_FALSE) ;-*/
+ sf_close (file) ;
+
+ /* Check the first half. */
+ max_value = 0 ;
+ for (k = 0 ; k < sfinfo.frames ; k++)
+ { /* Check if data_out has different sign from data_in. */
+ if ((data_out [k] < 0.0 && data_in [k] > 0) || (data_out [k] > 0.0 && data_in [k] < 0))
+ { printf ("\n\nLine %d: Data wrap around at index %d/%d (%f -> %d).\n\n", __LINE__, k, BUFFER_SIZE, data_out [k], data_in [k]) ;
+ exit (1) ;
+ } ;
+ max_value = (max_value > abs (data_in [k])) ? max_value : abs (data_in [k]) ;
+ } ;
+
+ unlink (filename) ;
+ puts ("ok") ;
+} /* dbl_int_clip_read_test */
+
+
+/*==============================================================================
+*/
+
+
+static void short_flt_scale_write_test (const char *filename, int filetype)
+{ SNDFILE *file ;
+ SF_INFO sfinfo ;
+ short *data_out ;
+ float *data_in, max_value ;
+ int k ;
+
+ print_test_name ("short_flt_clip_write_test", filename) ;
+
+ data_out = buffer_out.s ;
+ data_in = buffer_in.flt ;
+
+ for (k = 0 ; k < BUFFER_SIZE ; k++)
+ data_out [k] = lrintf (0x7FFFF * 0.995 * sin (4 * M_PI * k / BUFFER_SIZE)) ;
+
+ memset (&sfinfo, 0, sizeof (sfinfo)) ;
+ sfinfo.samplerate = 44100 ;
+ sfinfo.frames = 123456789 ; /* Wrong length. Library should correct this on sf_close. */
+ sfinfo.channels = 1 ;
+ sfinfo.format = filetype ;
+
+ file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ;
+ test_write_short_or_die (file, 0, data_out, BUFFER_SIZE, __LINE__) ;
+ sf_command (file, SFC_SET_SCALE_INT_FLOAT_WRITE, NULL, SF_TRUE) ;
+ test_write_short_or_die (file, 0, data_out, BUFFER_SIZE, __LINE__) ;
+ sf_command (file, SFC_SET_SCALE_INT_FLOAT_WRITE, NULL, SF_FALSE) ;
+ test_write_short_or_die (file, 0, data_out, BUFFER_SIZE, __LINE__) ;
+ sf_close (file) ;
+
+ memset (&sfinfo, 0, sizeof (sfinfo)) ;
+
+ file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ;
+
+ sfinfo.format &= (SF_FORMAT_TYPEMASK | SF_FORMAT_SUBMASK) ;
+
+ if (sfinfo.format != (filetype & (SF_FORMAT_TYPEMASK | SF_FORMAT_SUBMASK)))
+ { printf ("\n\nLine %d: Returned format incorrect (0x%08X => 0x%08X).\n\n", __LINE__, filetype, sfinfo.format) ;
+ exit (1) ;
+ } ;
+
+ if (sfinfo.frames != 3 * BUFFER_SIZE)
+ { printf ("\n\nLine %d: Incorrect number of frames in file (%d => %ld).\n\n", __LINE__, 3 * BUFFER_SIZE, SF_COUNT_TO_LONG (sfinfo.frames)) ;
+ exit (1) ;
+ } ;
+
+ if (sfinfo.channels != 1)
+ { printf ("\n\nLine %d: Incorrect number of channels in file.\n\n", __LINE__) ;
+ exit (1) ;
+ } ;
+
+ check_log_buffer_or_die (file, __LINE__) ;
+
+ /* Check the first section. */
+ test_read_float_or_die (file, 0, data_in, BUFFER_SIZE, __LINE__) ;
+
+ max_value = 0.0 ;
+ for (k = 0 ; k < BUFFER_SIZE ; k++)
+ max_value = (max_value > fabs (data_in [k])) ? max_value : fabs (data_in [k]) ;
+
+ if (max_value < 1000.0)
+ { printf ("\n\nLine %d: Max value (%f) < 1000.0.\n\n", __LINE__, max_value) ;
+ exit (1) ;
+ } ;
+
+ /* Check the second section. */
+ test_read_float_or_die (file, 0, data_in, BUFFER_SIZE, __LINE__) ;
+
+ max_value = 0.0 ;
+ for (k = 0 ; k < BUFFER_SIZE ; k++)
+ max_value = (max_value > fabs (data_in [k])) ? max_value : fabs (data_in [k]) ;
+
+ if (max_value > 1.0)
+ { printf ("\n\nLine %d: Max value (%f) > 1.0.\n\n", __LINE__, max_value) ;
+ exit (1) ;
+ } ;
+
+ /* Check the third section. */
+ test_read_float_or_die (file, 0, data_in, BUFFER_SIZE, __LINE__) ;
+
+ max_value = 0.0 ;
+ for (k = 0 ; k < BUFFER_SIZE ; k++)
+ max_value = (max_value > fabs (data_in [k])) ? max_value : fabs (data_in [k]) ;
+
+ if (max_value < 1000.0)
+ { printf ("\n\nLine %d: Max value (%f) < 1000.0.\n\n", __LINE__, max_value) ;
+ exit (1) ;
+ } ;
+
+ sf_close (file) ;
+
+ unlink (filename) ;
+ puts ("ok") ;
+} /* short_flt_scale_write_test */
+static void short_dbl_scale_write_test (const char *filename, int filetype)
+{ SNDFILE *file ;
+ SF_INFO sfinfo ;
+ short *data_out ;
+ double *data_in, max_value ;
+ int k ;
+
+ print_test_name ("short_dbl_clip_write_test", filename) ;
+
+ data_out = buffer_out.s ;
+ data_in = buffer_in.dbl ;
+
+ for (k = 0 ; k < BUFFER_SIZE ; k++)
+ data_out [k] = lrint (0x7FFFF * 0.995 * sin (4 * M_PI * k / BUFFER_SIZE)) ;
+
+ memset (&sfinfo, 0, sizeof (sfinfo)) ;
+ sfinfo.samplerate = 44100 ;
+ sfinfo.frames = 123456789 ; /* Wrong length. Library should correct this on sf_close. */
+ sfinfo.channels = 1 ;
+ sfinfo.format = filetype ;
+
+ file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ;
+ test_write_short_or_die (file, 0, data_out, BUFFER_SIZE, __LINE__) ;
+ sf_command (file, SFC_SET_SCALE_INT_FLOAT_WRITE, NULL, SF_TRUE) ;
+ test_write_short_or_die (file, 0, data_out, BUFFER_SIZE, __LINE__) ;
+ sf_command (file, SFC_SET_SCALE_INT_FLOAT_WRITE, NULL, SF_FALSE) ;
+ test_write_short_or_die (file, 0, data_out, BUFFER_SIZE, __LINE__) ;
+ sf_close (file) ;
+
+ memset (&sfinfo, 0, sizeof (sfinfo)) ;
+
+ file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ;
+
+ sfinfo.format &= (SF_FORMAT_TYPEMASK | SF_FORMAT_SUBMASK) ;
+
+ if (sfinfo.format != (filetype & (SF_FORMAT_TYPEMASK | SF_FORMAT_SUBMASK)))
+ { printf ("\n\nLine %d: Returned format incorrect (0x%08X => 0x%08X).\n\n", __LINE__, filetype, sfinfo.format) ;
+ exit (1) ;
+ } ;
+
+ if (sfinfo.frames != 3 * BUFFER_SIZE)
+ { printf ("\n\nLine %d: Incorrect number of frames in file (%d => %ld).\n\n", __LINE__, 3 * BUFFER_SIZE, SF_COUNT_TO_LONG (sfinfo.frames)) ;
+ exit (1) ;
+ } ;
+
+ if (sfinfo.channels != 1)
+ { printf ("\n\nLine %d: Incorrect number of channels in file.\n\n", __LINE__) ;
+ exit (1) ;
+ } ;
+
+ check_log_buffer_or_die (file, __LINE__) ;
+
+ /* Check the first section. */
+ test_read_double_or_die (file, 0, data_in, BUFFER_SIZE, __LINE__) ;
+
+ max_value = 0.0 ;
+ for (k = 0 ; k < BUFFER_SIZE ; k++)
+ max_value = (max_value > fabs (data_in [k])) ? max_value : fabs (data_in [k]) ;
+
+ if (max_value < 1000.0)
+ { printf ("\n\nLine %d: Max value (%f) < 1000.0.\n\n", __LINE__, max_value) ;
+ exit (1) ;
+ } ;
+
+ /* Check the second section. */
+ test_read_double_or_die (file, 0, data_in, BUFFER_SIZE, __LINE__) ;
+
+ max_value = 0.0 ;
+ for (k = 0 ; k < BUFFER_SIZE ; k++)
+ max_value = (max_value > fabs (data_in [k])) ? max_value : fabs (data_in [k]) ;
+
+ if (max_value > 1.0)
+ { printf ("\n\nLine %d: Max value (%f) > 1.0.\n\n", __LINE__, max_value) ;
+ exit (1) ;
+ } ;
+
+ /* Check the third section. */
+ test_read_double_or_die (file, 0, data_in, BUFFER_SIZE, __LINE__) ;
+
+ max_value = 0.0 ;
+ for (k = 0 ; k < BUFFER_SIZE ; k++)
+ max_value = (max_value > fabs (data_in [k])) ? max_value : fabs (data_in [k]) ;
+
+ if (max_value < 1000.0)
+ { printf ("\n\nLine %d: Max value (%f) < 1000.0.\n\n", __LINE__, max_value) ;
+ exit (1) ;
+ } ;
+
+ sf_close (file) ;
+
+ unlink (filename) ;
+ puts ("ok") ;
+} /* short_dbl_scale_write_test */
+
+static void int_flt_scale_write_test (const char *filename, int filetype)
+{ SNDFILE *file ;
+ SF_INFO sfinfo ;
+ int *data_out ;
+ float *data_in, max_value ;
+ int k ;
+
+ print_test_name ("int_flt_clip_write_test", filename) ;
+
+ data_out = buffer_out.i ;
+ data_in = buffer_in.flt ;
+
+ for (k = 0 ; k < BUFFER_SIZE ; k++)
+ data_out [k] = lrintf (0x7FFFFFFF * 0.995 * sin (4 * M_PI * k / BUFFER_SIZE)) ;
+
+ memset (&sfinfo, 0, sizeof (sfinfo)) ;
+ sfinfo.samplerate = 44100 ;
+ sfinfo.frames = 123456789 ; /* Wrong length. Library should correct this on sf_close. */
+ sfinfo.channels = 1 ;
+ sfinfo.format = filetype ;
+
+ file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ;
+ test_write_int_or_die (file, 0, data_out, BUFFER_SIZE, __LINE__) ;
+ sf_command (file, SFC_SET_SCALE_INT_FLOAT_WRITE, NULL, SF_TRUE) ;
+ test_write_int_or_die (file, 0, data_out, BUFFER_SIZE, __LINE__) ;
+ sf_command (file, SFC_SET_SCALE_INT_FLOAT_WRITE, NULL, SF_FALSE) ;
+ test_write_int_or_die (file, 0, data_out, BUFFER_SIZE, __LINE__) ;
+ sf_close (file) ;
+
+ memset (&sfinfo, 0, sizeof (sfinfo)) ;
+
+ file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ;
+
+ sfinfo.format &= (SF_FORMAT_TYPEMASK | SF_FORMAT_SUBMASK) ;
+
+ if (sfinfo.format != (filetype & (SF_FORMAT_TYPEMASK | SF_FORMAT_SUBMASK)))
+ { printf ("\n\nLine %d: Returned format incorrect (0x%08X => 0x%08X).\n\n", __LINE__, filetype, sfinfo.format) ;
+ exit (1) ;
+ } ;
+
+ if (sfinfo.frames != 3 * BUFFER_SIZE)
+ { printf ("\n\nLine %d: Incorrect number of frames in file (%d => %ld).\n\n", __LINE__, 3 * BUFFER_SIZE, SF_COUNT_TO_LONG (sfinfo.frames)) ;
+ exit (1) ;
+ } ;
+
+ if (sfinfo.channels != 1)
+ { printf ("\n\nLine %d: Incorrect number of channels in file.\n\n", __LINE__) ;
+ exit (1) ;
+ } ;
+
+ check_log_buffer_or_die (file, __LINE__) ;
+
+ /* Check the first section. */
+ test_read_float_or_die (file, 0, data_in, BUFFER_SIZE, __LINE__) ;
+
+ max_value = 0.0 ;
+ for (k = 0 ; k < BUFFER_SIZE ; k++)
+ max_value = (max_value > fabs (data_in [k])) ? max_value : fabs (data_in [k]) ;
+
+ if (max_value < 1000.0)
+ { printf ("\n\nLine %d: Max value (%f) < 1000.0.\n\n", __LINE__, max_value) ;
+ exit (1) ;
+ } ;
+
+ /* Check the second section. */
+ test_read_float_or_die (file, 0, data_in, BUFFER_SIZE, __LINE__) ;
+
+ max_value = 0.0 ;
+ for (k = 0 ; k < BUFFER_SIZE ; k++)
+ max_value = (max_value > fabs (data_in [k])) ? max_value : fabs (data_in [k]) ;
+
+ if (max_value > 1.0)
+ { printf ("\n\nLine %d: Max value (%f) > 1.0.\n\n", __LINE__, max_value) ;
+ exit (1) ;
+ } ;
+
+ /* Check the third section. */
+ test_read_float_or_die (file, 0, data_in, BUFFER_SIZE, __LINE__) ;
+
+ max_value = 0.0 ;
+ for (k = 0 ; k < BUFFER_SIZE ; k++)
+ max_value = (max_value > fabs (data_in [k])) ? max_value : fabs (data_in [k]) ;
+
+ if (max_value < 1000.0)
+ { printf ("\n\nLine %d: Max value (%f) < 1000.0.\n\n", __LINE__, max_value) ;
+ exit (1) ;
+ } ;
+
+ sf_close (file) ;
+
+ unlink (filename) ;
+ puts ("ok") ;
+} /* int_flt_scale_write_test */
+static void int_dbl_scale_write_test (const char *filename, int filetype)
+{ SNDFILE *file ;
+ SF_INFO sfinfo ;
+ int *data_out ;
+ double *data_in, max_value ;
+ int k ;
+
+ print_test_name ("int_dbl_clip_write_test", filename) ;
+
+ data_out = buffer_out.i ;
+ data_in = buffer_in.dbl ;
+
+ for (k = 0 ; k < BUFFER_SIZE ; k++)
+ data_out [k] = lrint (0x7FFFFFFF * 0.995 * sin (4 * M_PI * k / BUFFER_SIZE)) ;
+
+ memset (&sfinfo, 0, sizeof (sfinfo)) ;
+ sfinfo.samplerate = 44100 ;
+ sfinfo.frames = 123456789 ; /* Wrong length. Library should correct this on sf_close. */
+ sfinfo.channels = 1 ;
+ sfinfo.format = filetype ;
+
+ file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ;
+ test_write_int_or_die (file, 0, data_out, BUFFER_SIZE, __LINE__) ;
+ sf_command (file, SFC_SET_SCALE_INT_FLOAT_WRITE, NULL, SF_TRUE) ;
+ test_write_int_or_die (file, 0, data_out, BUFFER_SIZE, __LINE__) ;
+ sf_command (file, SFC_SET_SCALE_INT_FLOAT_WRITE, NULL, SF_FALSE) ;
+ test_write_int_or_die (file, 0, data_out, BUFFER_SIZE, __LINE__) ;
+ sf_close (file) ;
+
+ memset (&sfinfo, 0, sizeof (sfinfo)) ;
+
+ file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ;
+
+ sfinfo.format &= (SF_FORMAT_TYPEMASK | SF_FORMAT_SUBMASK) ;
+
+ if (sfinfo.format != (filetype & (SF_FORMAT_TYPEMASK | SF_FORMAT_SUBMASK)))
+ { printf ("\n\nLine %d: Returned format incorrect (0x%08X => 0x%08X).\n\n", __LINE__, filetype, sfinfo.format) ;
+ exit (1) ;
+ } ;
+
+ if (sfinfo.frames != 3 * BUFFER_SIZE)
+ { printf ("\n\nLine %d: Incorrect number of frames in file (%d => %ld).\n\n", __LINE__, 3 * BUFFER_SIZE, SF_COUNT_TO_LONG (sfinfo.frames)) ;
+ exit (1) ;
+ } ;
+
+ if (sfinfo.channels != 1)
+ { printf ("\n\nLine %d: Incorrect number of channels in file.\n\n", __LINE__) ;
+ exit (1) ;
+ } ;
+
+ check_log_buffer_or_die (file, __LINE__) ;
+
+ /* Check the first section. */
+ test_read_double_or_die (file, 0, data_in, BUFFER_SIZE, __LINE__) ;
+
+ max_value = 0.0 ;
+ for (k = 0 ; k < BUFFER_SIZE ; k++)
+ max_value = (max_value > fabs (data_in [k])) ? max_value : fabs (data_in [k]) ;
+
+ if (max_value < 1000.0)
+ { printf ("\n\nLine %d: Max value (%f) < 1000.0.\n\n", __LINE__, max_value) ;
+ exit (1) ;
+ } ;
+
+ /* Check the second section. */
+ test_read_double_or_die (file, 0, data_in, BUFFER_SIZE, __LINE__) ;
+
+ max_value = 0.0 ;
+ for (k = 0 ; k < BUFFER_SIZE ; k++)
+ max_value = (max_value > fabs (data_in [k])) ? max_value : fabs (data_in [k]) ;
+
+ if (max_value > 1.0)
+ { printf ("\n\nLine %d: Max value (%f) > 1.0.\n\n", __LINE__, max_value) ;
+ exit (1) ;
+ } ;
+
+ /* Check the third section. */
+ test_read_double_or_die (file, 0, data_in, BUFFER_SIZE, __LINE__) ;
+
+ max_value = 0.0 ;
+ for (k = 0 ; k < BUFFER_SIZE ; k++)
+ max_value = (max_value > fabs (data_in [k])) ? max_value : fabs (data_in [k]) ;
+
+ if (max_value < 1000.0)
+ { printf ("\n\nLine %d: Max value (%f) < 1000.0.\n\n", __LINE__, max_value) ;
+ exit (1) ;
+ } ;
+
+ sf_close (file) ;
+
+ unlink (filename) ;
+ puts ("ok") ;
+} /* int_dbl_scale_write_test */
+
+
Modified: freeswitch/trunk/libs/libsndfile/tests/scale_clip_test.def
==============================================================================
--- freeswitch/trunk/libs/libsndfile/tests/scale_clip_test.def (original)
+++ freeswitch/trunk/libs/libsndfile/tests/scale_clip_test.def Thu May 21 16:09:30 2009
@@ -1,15 +1,31 @@
autogen definitions scale_clip_test.tpl;
float_type = {
- type_name = "float" ;
- short_name = "flt" ;
- upper_name = "FLOAT" ;
+ float_type_name = "float" ;
+ float_short_name = "flt" ;
+ float_upper_name = "FLOAT" ;
+ float_to_int = "lrintf" ;
} ;
float_type = {
- type_name = "double" ;
- short_name = "dbl" ;
- upper_name = "DOUBLE" ;
+ float_type_name = "double" ;
+ float_short_name = "dbl" ;
+ float_upper_name = "DOUBLE" ;
+ float_to_int = "lrint" ;
+ } ;
+
+
+
+int_type = {
+ int_type_name = "short" ;
+ int_short_name = "s" ;
+ int_max_value = 0x7FFFF ;
+ } ;
+
+int_type = {
+ int_type_name = "int" ;
+ int_short_name = "i" ;
+ int_max_value = 0x7FFFFFFF ;
} ;
@@ -38,11 +54,3 @@
error_val = "1.0 / 0x80" ;
} ;
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: 4938e5b6-6f4c-4c69-8b92-f6c6d7a6b0ec
-*/
-
Modified: freeswitch/trunk/libs/libsndfile/tests/scale_clip_test.tpl
==============================================================================
--- freeswitch/trunk/libs/libsndfile/tests/scale_clip_test.tpl (original)
+++ freeswitch/trunk/libs/libsndfile/tests/scale_clip_test.tpl Thu May 21 16:09:30 2009
@@ -1,6 +1,6 @@
[+ AutoGen5 template c +]
/*
-** Copyright (C) 1999-2004 Erik de Castro Lopo <erikd at mega-nerd.com>
+** Copyright (C) 1999-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
@@ -45,13 +45,27 @@
[+ FOR float_type +]
[+ FOR data_type
-+]static void [+ (get "short_name") +]_scale_clip_test_[+ (get "name") +] (const char *filename, int filetype, float maxval) ;
++]static void [+ (get "float_short_name") +]_scale_clip_test_[+ (get "name") +] (const char *filename, int filetype, float maxval) ;
[+ ENDFOR data_type
+][+ ENDFOR float_type +]
+[+ FOR float_type +]
+[+ FOR int_type
++]static void [+ (get "float_short_name") +]_[+ (get "int_type_name") +]_clip_read_test (const char *filename, int filetype) ;
+[+ ENDFOR int_type
++][+ ENDFOR float_type +]
+
+[+ FOR int_type +]
+[+ FOR float_type
++]static void [+ (get "int_type_name") +]_[+ (get "float_short_name") +]_scale_write_test (const char *filename, int filetype) ;
+[+ ENDFOR float_type
++][+ ENDFOR int_type +]
+
typedef union
{ double dbl [BUFFER_SIZE] ;
float flt [BUFFER_SIZE] ;
+ int i [BUFFER_SIZE] ;
+ short s [BUFFER_SIZE] ;
} BUFFER ;
/* Data buffer. */
@@ -86,6 +100,16 @@
dbl_scale_clip_test_32 ("scale_clip_be32.au", SF_ENDIAN_BIG | SF_FORMAT_AU | SF_FORMAT_PCM_32, 1.0 * 0x80000000) ;
dbl_scale_clip_test_32 ("scale_clip_le32.au", SF_ENDIAN_LITTLE | SF_FORMAT_AU | SF_FORMAT_PCM_32, 1.0 * 0x80000000) ;
+ flt_short_clip_read_test ("flt_short.au" , SF_ENDIAN_BIG | SF_FORMAT_AU | SF_FORMAT_FLOAT) ;
+ flt_int_clip_read_test ("flt_int.au" , SF_ENDIAN_LITTLE | SF_FORMAT_AU | SF_FORMAT_FLOAT) ;
+ dbl_short_clip_read_test ("dbl_short.au" , SF_ENDIAN_BIG | SF_FORMAT_AU | SF_FORMAT_DOUBLE) ;
+ dbl_int_clip_read_test ("dbl_int.au" , SF_ENDIAN_LITTLE | SF_FORMAT_AU | SF_FORMAT_DOUBLE) ;
+
+ short_flt_scale_write_test ("short_flt.au" , SF_ENDIAN_BIG | SF_FORMAT_AU | SF_FORMAT_FLOAT) ;
+ int_flt_scale_write_test ("int_flt.au" , SF_ENDIAN_LITTLE | SF_FORMAT_AU | SF_FORMAT_FLOAT) ;
+ short_dbl_scale_write_test ("short_dbl.au" , SF_ENDIAN_BIG | SF_FORMAT_AU | SF_FORMAT_DOUBLE) ;
+ int_dbl_scale_write_test ("int_dbl.au" , SF_ENDIAN_LITTLE | SF_FORMAT_AU | SF_FORMAT_DOUBLE) ;
+
return 0 ;
} /* main */
@@ -96,20 +120,20 @@
[+ FOR float_type +]
[+ FOR data_type
+]static void
-[+ (get "short_name") +]_scale_clip_test_[+ (get "name") +] (const char *filename, int filetype, float maxval)
+[+ (get "float_short_name") +]_scale_clip_test_[+ (get "name") +] (const char *filename, int filetype, float maxval)
{ SNDFILE *file ;
SF_INFO sfinfo ;
int k ;
- [+ (get "type_name") +] *data_out, *data_in ;
+ [+ (get "float_type_name") +] *data_out, *data_in ;
double diff, clip_max_diff ;
- print_test_name ("[+ (get "short_name") +]_scale_clip_test_[+ (get "name") +]", filename) ;
+ print_test_name ("[+ (get "float_short_name") +]_scale_clip_test_[+ (get "name") +]", filename) ;
- data_out = buffer_out.[+ (get "short_name") +] ;
- data_in = buffer_in.[+ (get "short_name") +] ;
+ data_out = buffer_out.[+ (get "float_short_name") +] ;
+ data_in = buffer_in.[+ (get "float_short_name") +] ;
for (k = 0 ; k < HALF_BUFFER_SIZE ; k++)
- { data_out [k] = SINE_AMP * sin (2 * M_PI * k / HALF_BUFFER_SIZE) ;
+ { data_out [k] = 1.2 * sin (2 * M_PI * k / HALF_BUFFER_SIZE) ;
data_out [k + HALF_BUFFER_SIZE] = data_out [k] * maxval ;
} ;
@@ -126,9 +150,9 @@
file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ;
sf_command (file, SFC_SET_CLIPPING, NULL, SF_TRUE) ;
- test_write_[+ (get "type_name") +]_or_die (file, 0, data_out, HALF_BUFFER_SIZE, __LINE__) ;
- sf_command (file, SFC_SET_NORM_[+ (get "upper_name") +], NULL, SF_FALSE) ;
- test_write_[+ (get "type_name") +]_or_die (file, 0, data_out + HALF_BUFFER_SIZE, HALF_BUFFER_SIZE, __LINE__) ;
+ test_write_[+ (get "float_type_name") +]_or_die (file, 0, data_out, HALF_BUFFER_SIZE, __LINE__) ;
+ sf_command (file, SFC_SET_NORM_[+ (get "float_upper_name") +], NULL, SF_FALSE) ;
+ test_write_[+ (get "float_type_name") +]_or_die (file, 0, data_out + HALF_BUFFER_SIZE, HALF_BUFFER_SIZE, __LINE__) ;
sf_close (file) ;
memset (&buffer_in, 0, sizeof (buffer_in)) ;
@@ -154,9 +178,9 @@
check_log_buffer_or_die (file, __LINE__) ;
- test_read_[+ (get "type_name") +]_or_die (file, 0, data_in, HALF_BUFFER_SIZE, __LINE__) ;
- sf_command (file, SFC_SET_NORM_[+ (get "upper_name") +], NULL, SF_FALSE) ;
- test_read_[+ (get "type_name") +]_or_die (file, 0, data_in + HALF_BUFFER_SIZE, HALF_BUFFER_SIZE, __LINE__) ;
+ test_read_[+ (get "float_type_name") +]_or_die (file, 0, data_in, HALF_BUFFER_SIZE, __LINE__) ;
+ sf_command (file, SFC_SET_NORM_[+ (get "float_upper_name") +], NULL, SF_FALSE) ;
+ test_read_[+ (get "float_type_name") +]_or_die (file, 0, data_in + HALF_BUFFER_SIZE, HALF_BUFFER_SIZE, __LINE__) ;
sf_close (file) ;
/* Check normalized version. */
@@ -223,18 +247,192 @@
printf ("ok\n") ;
unlink (filename) ;
-} /* [+ (get "short_name") +]_scale_clip_test_[+ (get "name") +] */
+} /* [+ (get "float_short_name") +]_scale_clip_test_[+ (get "name") +] */
[+ ENDFOR data_type
+]
[+ ENDFOR float_type +]
-[+ COMMENT
+/*==============================================================================
+*/
+
+[+ FOR float_type +]
+[+ FOR int_type
++]static void [+ (get "float_short_name") +]_[+ (get "int_type_name") +]_clip_read_test (const char *filename, int filetype)
+{ SNDFILE *file ;
+ SF_INFO sfinfo ;
+ [+ (get "float_type_name") +] *data_out ;
+ [+ (get "int_type_name") +] *data_in, max_value ;
+ int k ;
- Do not edit or modify anything in this comment block.
- The following line is a file identity tag for the GNU Arch
- revision control system.
+ print_test_name ("[+ (get "float_short_name") +]_[+ (get "int_type_name") +]_clip_read_test", filename) ;
+
+ data_out = buffer_out.[+ (get "float_short_name") +] ;
+ data_in = buffer_in.[+ (get "int_short_name") +] ;
+
+ for (k = 0 ; k < BUFFER_SIZE ; k++)
+ data_out [k] = 0.995 * sin (4 * M_PI * k / BUFFER_SIZE) ;
+ data_out [BUFFER_SIZE / 8] = 1.0 ;
+ data_out [3 * BUFFER_SIZE / 8] = -1.000000001 ;
+ data_out [5 * BUFFER_SIZE / 8] = 1.0 ;
+ data_out [7 * BUFFER_SIZE / 8] = -1.000000001 ;
+
+ memset (&sfinfo, 0, sizeof (sfinfo)) ;
+ sfinfo.samplerate = 44100 ;
+ sfinfo.frames = 123456789 ; /* Wrong length. Library should correct this on sf_close. */
+ sfinfo.channels = 1 ;
+ sfinfo.format = filetype ;
+
+ /* Save unclipped data to the file. */
+ file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ;
+ test_write_[+ (get "float_type_name") +]_or_die (file, 0, data_out, BUFFER_SIZE, __LINE__) ;
+ sf_close (file) ;
+
+ memset (&sfinfo, 0, sizeof (sfinfo)) ;
+
+ file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ;
+ sf_command (file, SFC_SET_SCALE_FLOAT_INT_READ, NULL, SF_TRUE) ;
+
+ sfinfo.format &= (SF_FORMAT_TYPEMASK | SF_FORMAT_SUBMASK) ;
+
+ if (sfinfo.format != (filetype & (SF_FORMAT_TYPEMASK | SF_FORMAT_SUBMASK)))
+ { printf ("\n\nLine %d: Returned format incorrect (0x%08X => 0x%08X).\n\n", __LINE__, filetype, sfinfo.format) ;
+ exit (1) ;
+ } ;
+
+ if (sfinfo.frames != BUFFER_SIZE)
+ { printf ("\n\nLine %d: Incorrect number of frames in file (%d => %ld).\n\n", __LINE__, BUFFER_SIZE, SF_COUNT_TO_LONG (sfinfo.frames)) ;
+ exit (1) ;
+ } ;
+
+ if (sfinfo.channels != 1)
+ { printf ("\n\nLine %d: Incorrect number of channels in file.\n\n", __LINE__) ;
+ exit (1) ;
+ } ;
+
+ check_log_buffer_or_die (file, __LINE__) ;
+
+ sf_command (file, SFC_SET_CLIPPING, NULL, SF_TRUE) ;
+ test_read_[+ (get "int_type_name") +]_or_die (file, 0, data_in, BUFFER_SIZE, __LINE__) ;
+ /*-sf_command (file, SFC_SET_NORM_[+ (get "float_upper_name") +], NULL, SF_FALSE) ;-*/
+ sf_close (file) ;
+
+ /* Check the first half. */
+ max_value = 0 ;
+ for (k = 0 ; k < sfinfo.frames ; k++)
+ { /* Check if data_out has different sign from data_in. */
+ if ((data_out [k] < 0.0 && data_in [k] > 0) || (data_out [k] > 0.0 && data_in [k] < 0))
+ { printf ("\n\nLine %d: Data wrap around at index %d/%d (%f -> %d).\n\n", __LINE__, k, BUFFER_SIZE, data_out [k], data_in [k]) ;
+ exit (1) ;
+ } ;
+ max_value = (max_value > abs (data_in [k])) ? max_value : abs (data_in [k]) ;
+ } ;
+
+ unlink (filename) ;
+ puts ("ok") ;
+} /* [+ (get "float_short_name") +]_[+ (get "int_type_name") +]_clip_read_test */
+[+ ENDFOR int_type
++][+ ENDFOR float_type +]
+
+/*==============================================================================
+*/
+
+[+ FOR int_type +]
+[+ FOR float_type
++]static void [+ (get "int_type_name") +]_[+ (get "float_short_name") +]_scale_write_test (const char *filename, int filetype)
+{ SNDFILE *file ;
+ SF_INFO sfinfo ;
+ [+ (get "int_type_name") +] *data_out ;
+ [+ (get "float_type_name") +] *data_in, max_value ;
+ int k ;
+
+ print_test_name ("[+ (get "int_type_name") +]_[+ (get "float_short_name") +]_clip_write_test", filename) ;
+
+ data_out = buffer_out.[+ (get "int_short_name") +] ;
+ data_in = buffer_in.[+ (get "float_short_name") +] ;
+
+ for (k = 0 ; k < BUFFER_SIZE ; k++)
+ data_out [k] = [+ (get "float_to_int") +] ([+ (get "int_max_value") +] * 0.995 * sin (4 * M_PI * k / BUFFER_SIZE)) ;
+
+ memset (&sfinfo, 0, sizeof (sfinfo)) ;
+ sfinfo.samplerate = 44100 ;
+ sfinfo.frames = 123456789 ; /* Wrong length. Library should correct this on sf_close. */
+ sfinfo.channels = 1 ;
+ sfinfo.format = filetype ;
+
+ file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ;
+ test_write_[+ (get "int_type_name") +]_or_die (file, 0, data_out, BUFFER_SIZE, __LINE__) ;
+ sf_command (file, SFC_SET_SCALE_INT_FLOAT_WRITE, NULL, SF_TRUE) ;
+ test_write_[+ (get "int_type_name") +]_or_die (file, 0, data_out, BUFFER_SIZE, __LINE__) ;
+ sf_command (file, SFC_SET_SCALE_INT_FLOAT_WRITE, NULL, SF_FALSE) ;
+ test_write_[+ (get "int_type_name") +]_or_die (file, 0, data_out, BUFFER_SIZE, __LINE__) ;
+ sf_close (file) ;
+
+ memset (&sfinfo, 0, sizeof (sfinfo)) ;
+
+ file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ;
+
+ sfinfo.format &= (SF_FORMAT_TYPEMASK | SF_FORMAT_SUBMASK) ;
+
+ if (sfinfo.format != (filetype & (SF_FORMAT_TYPEMASK | SF_FORMAT_SUBMASK)))
+ { printf ("\n\nLine %d: Returned format incorrect (0x%08X => 0x%08X).\n\n", __LINE__, filetype, sfinfo.format) ;
+ exit (1) ;
+ } ;
+
+ if (sfinfo.frames != 3 * BUFFER_SIZE)
+ { printf ("\n\nLine %d: Incorrect number of frames in file (%d => %ld).\n\n", __LINE__, 3 * BUFFER_SIZE, SF_COUNT_TO_LONG (sfinfo.frames)) ;
+ exit (1) ;
+ } ;
+
+ if (sfinfo.channels != 1)
+ { printf ("\n\nLine %d: Incorrect number of channels in file.\n\n", __LINE__) ;
+ exit (1) ;
+ } ;
+
+ check_log_buffer_or_die (file, __LINE__) ;
+
+ /* Check the first section. */
+ test_read_[+ (get "float_type_name") +]_or_die (file, 0, data_in, BUFFER_SIZE, __LINE__) ;
+
+ max_value = 0.0 ;
+ for (k = 0 ; k < BUFFER_SIZE ; k++)
+ max_value = (max_value > fabs (data_in [k])) ? max_value : fabs (data_in [k]) ;
+
+ if (max_value < 1000.0)
+ { printf ("\n\nLine %d: Max value (%f) < 1000.0.\n\n", __LINE__, max_value) ;
+ exit (1) ;
+ } ;
+
+ /* Check the second section. */
+ test_read_[+ (get "float_type_name") +]_or_die (file, 0, data_in, BUFFER_SIZE, __LINE__) ;
+
+ max_value = 0.0 ;
+ for (k = 0 ; k < BUFFER_SIZE ; k++)
+ max_value = (max_value > fabs (data_in [k])) ? max_value : fabs (data_in [k]) ;
+
+ if (max_value > 1.0)
+ { printf ("\n\nLine %d: Max value (%f) > 1.0.\n\n", __LINE__, max_value) ;
+ exit (1) ;
+ } ;
+
+ /* Check the third section. */
+ test_read_[+ (get "float_type_name") +]_or_die (file, 0, data_in, BUFFER_SIZE, __LINE__) ;
+
+ max_value = 0.0 ;
+ for (k = 0 ; k < BUFFER_SIZE ; k++)
+ max_value = (max_value > fabs (data_in [k])) ? max_value : fabs (data_in [k]) ;
+
+ if (max_value < 1000.0)
+ { printf ("\n\nLine %d: Max value (%f) < 1000.0.\n\n", __LINE__, max_value) ;
+ exit (1) ;
+ } ;
+
+ sf_close (file) ;
+
+ unlink (filename) ;
+ puts ("ok") ;
+} /* [+ (get "int_type_name") +]_[+ (get "float_short_name") +]_scale_write_test */
+[+ ENDFOR float_type
++][+ ENDFOR int_type +]
- arch-tag: dc1613fe-2985-462c-a0b4-62143a7570e8
-+]
Modified: freeswitch/trunk/libs/libsndfile/tests/sfversion.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/tests/sfversion.c (original)
+++ freeswitch/trunk/libs/libsndfile/tests/sfversion.c Thu May 21 16:09:30 2009
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 1999-2004 Erik de Castro Lopo <erikd at mega-nerd.com>
+** Copyright (C) 1999-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
@@ -40,10 +40,3 @@
return 0 ;
} /* main */
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: 53b0b14d-a52b-4094-b510-df91e4947574
-*/
Modified: freeswitch/trunk/libs/libsndfile/tests/stdin_test.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/tests/stdin_test.c (original)
+++ freeswitch/trunk/libs/libsndfile/tests/stdin_test.c Thu May 21 16:09:30 2009
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 2001-2004 Erik de Castro Lopo <erikd at mega-nerd.com>
+** Copyright (C) 2001-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
@@ -195,10 +195,4 @@
return ;
} /* stdin_test */
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: 5e470e3e-743e-4bbc-a588-ec883843c938
-*/
+
Modified: freeswitch/trunk/libs/libsndfile/tests/stdio_test.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/tests/stdio_test.c (original)
+++ freeswitch/trunk/libs/libsndfile/tests/stdio_test.c Thu May 21 16:09:30 2009
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 2001-2004 Erik de Castro Lopo <erikd at mega-nerd.com>
+** Copyright (C) 2001-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
@@ -74,7 +74,7 @@
{ int k ;
if (file_exists ("libsndfile.spec.in"))
- chdir ("tests") ;
+ exit_if_true (chdir ("tests") != 0, "\n Error : chdir ('tests') failed.\n") ;
for (k = 0 ; filetypes [k] ; k++)
stdio_test (filetypes [k]) ;
@@ -150,10 +150,3 @@
#endif
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: f46d84fd-d37b-4d08-b1ba-80f2f1e0cfb9
-*/
Modified: freeswitch/trunk/libs/libsndfile/tests/stdout_test.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/tests/stdout_test.c (original)
+++ freeswitch/trunk/libs/libsndfile/tests/stdout_test.c Thu May 21 16:09:30 2009
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 2001-2004 Erik de Castro Lopo <erikd at mega-nerd.com>
+** Copyright (C) 2001-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
@@ -158,10 +158,4 @@
return ;
} /* stdout_test */
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: 660c3f79-a459-4c7c-899b-b360b7403403
-*/
+
Modified: freeswitch/trunk/libs/libsndfile/tests/string_test.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/tests/string_test.c (original)
+++ freeswitch/trunk/libs/libsndfile/tests/string_test.c Thu May 21 16:09:30 2009
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 2003,2004 Erik de Castro Lopo <erikd at mega-nerd.com>
+** Copyright (C) 2003-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
@@ -34,9 +34,13 @@
#define BUFFER_LEN (1 << 10)
#define LOG_BUFFER_SIZE 1024
-static void string_test (const char *filename, int typemajor) ;
+static void string_start_test (const char *filename, int typemajor) ;
+static void string_start_end_test (const char *filename, int typemajor) ;
+static void string_multi_set_test (const char *filename, int typemajor) ;
+static void string_rdwr_test (const char *filename, int typemajor) ;
+static void string_short_rdwr_test (const char *filename, int typemajor) ;
-static int libsndfile_str_count (const char * cptr) ;
+static int str_count (const char * haystack, const char * needle) ;
int
main (int argc, char *argv [])
@@ -48,6 +52,8 @@
printf (" Where <test> is one of the following:\n") ;
printf (" wav - test adding strings to WAV files\n") ;
printf (" aiff - test adding strings to AIFF files\n") ;
+ printf (" flac - test adding strings to FLAC files\n") ;
+ printf (" ogg - test adding strings to OGG files\n") ;
printf (" all - perform all tests\n") ;
exit (1) ;
} ;
@@ -55,12 +61,57 @@
do_all =! strcmp (argv [1], "all") ;
if (do_all || ! strcmp (argv [1], "wav"))
- { string_test ("strings.wav", SF_FORMAT_WAV) ;
+ { string_start_end_test ("strings.wav", SF_FORMAT_WAV) ;
+ string_multi_set_test ("multi.wav", SF_FORMAT_WAV) ;
+ string_rdwr_test ("rdwr.wav", SF_FORMAT_WAV) ;
+ string_short_rdwr_test ("short_rdwr.wav", SF_FORMAT_WAV) ;
+
+ string_start_end_test ("strings.wavex", SF_FORMAT_WAVEX) ;
+ string_multi_set_test ("multi.wavex", SF_FORMAT_WAVEX) ;
+ string_rdwr_test ("rdwr.wavex", SF_FORMAT_WAVEX) ;
+ string_short_rdwr_test ("short_rdwr.wavex", SF_FORMAT_WAVEX) ;
+
+ string_start_end_test ("strings.rifx", SF_ENDIAN_BIG | SF_FORMAT_WAV) ;
+ string_multi_set_test ("multi.rifx", SF_ENDIAN_BIG | SF_FORMAT_WAV) ;
+ string_rdwr_test ("rdwr.rifx", SF_ENDIAN_BIG | SF_FORMAT_WAV) ;
+ string_short_rdwr_test ("short_rdwr.rifx", SF_ENDIAN_BIG | SF_FORMAT_WAV) ;
test_count++ ;
} ;
if (do_all || ! strcmp (argv [1], "aiff"))
- { string_test ("strings.aiff", SF_FORMAT_AIFF) ;
+ { string_start_end_test ("strings.aiff", SF_FORMAT_AIFF) ;
+ /*
+ string_multi_set_test ("multi.aiff", SF_FORMAT_AIFF) ;
+ string_rdwr_test ("rdwr.aiff", SF_FORMAT_AIFF) ;
+ string_short_rdwr_test ("short_rdwr.aiff", SF_FORMAT_AIFF) ;
+ */
+ test_count++ ;
+ } ;
+
+ if (do_all || ! strcmp (argv [1], "flac"))
+ { if (HAVE_EXTERNAL_LIBS)
+ string_start_test ("strings.flac", SF_FORMAT_FLAC) ;
+ else
+ puts (" No FLAC tests because FLAC support was not compiled in.") ;
+ test_count++ ;
+ } ;
+
+ if (do_all || ! strcmp (argv [1], "ogg"))
+ { if (HAVE_EXTERNAL_LIBS)
+ string_start_test ("vorbis.oga", SF_FORMAT_OGG) ;
+ else
+ puts (" No Ogg/Vorbis tests because Ogg/Vorbis support was not compiled in.") ;
+ test_count++ ;
+ } ;
+
+ if (do_all || ! strcmp (argv [1], "rf64"))
+ { puts ("\n\n **** String test not working yet for RF64 format. ****\n") ;
+ /*
+ string_start_end_test ("strings.rf64", SF_FORMAT_RF64) ;
+ string_multi_set_test ("multi.rf64", SF_FORMAT_RF64) ;
+ string_rdwr_test ("rdwr.rf64", SF_FORMAT_RF64) ;
+ string_short_rdwr_test ("short_rdwr.rf64", SF_FORMAT_RF64) ;
+ */
test_count++ ;
} ;
@@ -82,14 +133,20 @@
static const char
software [] = "software (libsndfile-X.Y.Z)",
artist [] = "The Artist",
- copyright [] = "Copyright (c) 2001 The Artist",
+ copyright [] = "Copyright (c) 2001 Artist",
comment [] = "Comment goes here!!!",
- date [] = "2001/01/27" ;
+ date [] = "2001/01/27",
+ album [] = "The Album",
+ license [] = "The license",
+ title [] = "This is the title",
+ long_title [] = "This is a very long and very boring title for this file",
+ long_artist [] = "The artist who kept on changing its name" ;
+
static short data_out [BUFFER_LEN] ;
static void
-string_test (const char *filename, int typemajor)
+string_start_end_test (const char *filename, int typemajor)
{ const char *cptr ;
SNDFILE *file ;
SF_INFO sfinfo ;
@@ -97,19 +154,151 @@
typemajor = typemajor ;
- print_test_name ("string_test", filename) ;
+ print_test_name ("string_start_end_test", filename) ;
sfinfo.samplerate = 44100 ;
sfinfo.channels = 1 ;
sfinfo.frames = 0 ;
+ sfinfo.format = typemajor | SF_FORMAT_PCM_16 ;
+
+ frames = BUFFER_LEN / sfinfo.channels ;
+
+ file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ;
+
+ /* Write stuff at start of file. */
+ sf_set_string (file, SF_STR_TITLE, filename) ;
+ sf_set_string (file, SF_STR_SOFTWARE, software) ;
+ sf_set_string (file, SF_STR_ARTIST, artist) ;
+
+ /* Write data to file. */
+ test_write_short_or_die (file, 0, data_out, BUFFER_LEN, __LINE__) ;
+ test_seek_or_die (file, 0, SEEK_SET, 0, sfinfo.channels, __LINE__) ;
+
+ /* Write more stuff at end of file. */
+ sf_set_string (file, SF_STR_COPYRIGHT, copyright) ;
+ sf_set_string (file, SF_STR_COMMENT, comment) ;
+ sf_set_string (file, SF_STR_DATE, date) ;
+ sf_set_string (file, SF_STR_ALBUM, album) ;
+ sf_set_string (file, SF_STR_LICENSE, license) ;
+
+ sf_close (file) ;
+
+ file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ;
+
+ check_log_buffer_or_die (file, __LINE__) ;
+
+ if (sfinfo.frames != BUFFER_LEN)
+ { printf ("***** Bad frame count %d (should be %d)\n\n", (int) sfinfo.frames, BUFFER_LEN) ;
+ errors ++ ;
+ } ;
+
+ cptr = sf_get_string (file, SF_STR_TITLE) ;
+ if (cptr == NULL || strcmp (filename, cptr) != 0)
+ { if (errors++ == 0)
+ puts ("\n") ;
+ printf (" Bad filename : %s\n", cptr) ;
+ } ;
+
+ cptr = sf_get_string (file, SF_STR_COPYRIGHT) ;
+ if (cptr == NULL || strcmp (copyright, cptr) != 0)
+ { if (errors++ == 0)
+ puts ("\n") ;
+ printf (" Bad copyright : %s\n", cptr) ;
+ } ;
+
+ cptr = sf_get_string (file, SF_STR_SOFTWARE) ;
+ if (cptr == NULL || strstr (cptr, software) != cptr)
+ { if (errors++ == 0)
+ puts ("\n") ;
+ printf (" Bad software : %s\n", cptr) ;
+ } ;
+
+ if (str_count (cptr, "libsndfile") != 1)
+ { if (errors++ == 0)
+ puts ("\n") ;
+ printf (" Bad software : %s\n", cptr) ;
+ } ;
+
+ cptr = sf_get_string (file, SF_STR_ARTIST) ;
+ if (cptr == NULL || strcmp (artist, cptr) != 0)
+ { if (errors++ == 0)
+ puts ("\n") ;
+ printf (" Bad artist : %s\n", cptr) ;
+ } ;
+
+ cptr = sf_get_string (file, SF_STR_COMMENT) ;
+ if (cptr == NULL || strcmp (comment, cptr) != 0)
+ { if (errors++ == 0)
+ puts ("\n") ;
+ printf (" Bad comment : %s\n", cptr) ;
+ } ;
+
+ if (typemajor != SF_FORMAT_AIFF)
+ { cptr = sf_get_string (file, SF_STR_DATE) ;
+ if (cptr == NULL || strcmp (date, cptr) != 0)
+ { if (errors++ == 0)
+ puts ("\n") ;
+ printf (" Bad date : %s\n", cptr) ;
+ } ;
+ } ;
switch (typemajor)
- { case SF_FORMAT_WAV :
- sfinfo.format = (typemajor | SF_FORMAT_PCM_U8) ;
+ { case SF_FORMAT_AIFF :
+ case SF_FORMAT_WAV :
+ case SF_FORMAT_WAVEX :
+ case SF_ENDIAN_BIG | SF_FORMAT_WAV :
break ;
default :
- sfinfo.format = (typemajor | SF_FORMAT_PCM_S8) ;
+ cptr = sf_get_string (file, SF_STR_ALBUM) ;
+ if (cptr == NULL || strcmp (album, cptr) != 0)
+ { if (errors++ == 0)
+ puts ("\n") ;
+ printf (" Bad album : %s\n", cptr) ;
+ } ;
+
+ cptr = sf_get_string (file, SF_STR_LICENSE) ;
+ if (cptr == NULL || strcmp (license, cptr) != 0)
+ { if (errors++ == 0)
+ puts ("\n") ;
+ printf (" Bad license : %s\n", cptr) ;
+ } ;
+
+ break ;
+ } ;
+
+ if (errors > 0)
+ { printf ("\n*** Error count : %d ***\n\n", errors) ;
+ dump_log_buffer (file) ;
+ exit (1) ;
+ } ;
+
+ sf_close (file) ;
+ unlink (filename) ;
+
+ puts ("ok") ;
+} /* string_start_end_test */
+
+static void
+string_start_test (const char *filename, int typemajor)
+{ const char *cptr ;
+ SNDFILE *file ;
+ SF_INFO sfinfo ;
+ int frames, errors = 0 ;
+
+ print_test_name ("string_start_test", filename) ;
+
+ sfinfo.samplerate = 44100 ;
+ sfinfo.channels = 1 ;
+ sfinfo.frames = 0 ;
+
+ switch (typemajor)
+ { case SF_FORMAT_OGG :
+ sfinfo.format = typemajor | SF_FORMAT_VORBIS ;
+ break ;
+
+ default :
+ sfinfo.format = typemajor | SF_FORMAT_PCM_16 ;
break ;
} ;
@@ -121,15 +310,14 @@
sf_set_string (file, SF_STR_TITLE, filename) ;
sf_set_string (file, SF_STR_SOFTWARE, software) ;
sf_set_string (file, SF_STR_ARTIST, artist) ;
-
- /* Write data to file. */
- test_write_short_or_die (file, 0, data_out, BUFFER_LEN, __LINE__) ;
- test_seek_or_die (file, 0, SEEK_SET, 0, sfinfo.channels, __LINE__) ;
-
- /* Write more stuff at end of file. */
sf_set_string (file, SF_STR_COPYRIGHT, copyright) ;
sf_set_string (file, SF_STR_COMMENT, comment) ;
sf_set_string (file, SF_STR_DATE, date) ;
+ sf_set_string (file, SF_STR_ALBUM, album) ;
+ sf_set_string (file, SF_STR_LICENSE, license) ;
+
+ /* Write data to file. */
+ test_write_short_or_die (file, 0, data_out, BUFFER_LEN, __LINE__) ;
sf_close (file) ;
@@ -163,7 +351,7 @@
printf (" Bad software : %s\n", cptr) ;
} ;
- if (libsndfile_str_count (cptr) != 1)
+ if (str_count (cptr, "libsndfile") != 1)
{ if (errors++ == 0)
puts ("\n") ;
printf (" Bad software : %s\n", cptr) ;
@@ -192,6 +380,24 @@
} ;
} ;
+ if (typemajor != SF_FORMAT_WAV && typemajor != SF_FORMAT_AIFF)
+ { cptr = sf_get_string (file, SF_STR_ALBUM) ;
+ if (cptr == NULL || strcmp (album, cptr) != 0)
+ { if (errors++ == 0)
+ puts ("\n") ;
+ printf (" Bad album : %s\n", cptr) ;
+ } ;
+ } ;
+
+ if (typemajor != SF_FORMAT_WAV && typemajor != SF_FORMAT_AIFF)
+ { cptr = sf_get_string (file, SF_STR_LICENSE) ;
+ if (cptr == NULL || strcmp (license, cptr) != 0)
+ { if (errors++ == 0)
+ puts ("\n") ;
+ printf (" Bad license : %s\n", cptr) ;
+ } ;
+ } ;
+
if (errors > 0)
{ printf ("\n*** Error count : %d ***\n\n", errors) ;
dump_log_buffer (file) ;
@@ -202,26 +408,201 @@
unlink (filename) ;
puts ("ok") ;
-} /* string_test */
+} /* string_start_test */
-static int
-libsndfile_str_count (const char * str)
-{ const char * cptr ;
+static void
+string_multi_set_test (const char *filename, int typemajor)
+{ static const char
+ new_software [] = "new software (libsndfile-X.Y.Z)",
+ new_copyright [] = "Copyright (c) 2001 New Artist",
+ new_artist [] = "The New Artist",
+ new_title [] = "This is the new title" ;
+
+ static char buffer [2048] ;
+ SNDFILE *file ;
+ SF_INFO sfinfo ;
+ int count ;
- if ((cptr = strstr (str, "libsndfile")) == NULL)
- return 0 ;
+ print_test_name (__func__, filename) ;
- if ((cptr = strstr (cptr + 1, "libsndfile")) == NULL)
- return 1 ;
+ sfinfo.format = typemajor | SF_FORMAT_PCM_16 ;
+ sfinfo.samplerate = 44100 ;
+ sfinfo.channels = 1 ;
+ sfinfo.frames = 0 ;
- return 2 ;
-} /* libsndfile_str_count */
+ file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ;
+ /* Write stuff at start of file. */
+ sf_set_string (file, SF_STR_TITLE, title) ;
+ sf_set_string (file, SF_STR_SOFTWARE, software) ;
+ sf_set_string (file, SF_STR_ARTIST, artist) ;
+
+ /* Write data to file. */
+ test_write_short_or_die (file, 0, data_out, BUFFER_LEN, __LINE__) ;
+
+ /* Write it all again. */
+
+ sf_set_string (file, SF_STR_TITLE, new_title) ;
+ sf_set_string (file, SF_STR_SOFTWARE, new_software) ;
+ sf_set_string (file, SF_STR_ARTIST, new_artist) ;
+
+ sf_set_string (file, SF_STR_COPYRIGHT, copyright) ;
+ sf_set_string (file, SF_STR_COMMENT, comment) ;
+ sf_set_string (file, SF_STR_DATE, date) ;
+ sf_set_string (file, SF_STR_ALBUM, album) ;
+ sf_set_string (file, SF_STR_LICENSE, license) ;
+ sf_set_string (file, SF_STR_COPYRIGHT, new_copyright) ;
+ sf_set_string (file, SF_STR_COMMENT, comment) ;
+ sf_set_string (file, SF_STR_DATE, date) ;
+ sf_set_string (file, SF_STR_ALBUM, album) ;
+ sf_set_string (file, SF_STR_LICENSE, license) ;
+
+ sf_close (file) ;
+
+ file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ;
+ sf_command (file, SFC_GET_LOG_INFO, buffer, sizeof (buffer)) ;
+ sf_close (file) ;
+
+ count = str_count (buffer, new_title) ;
+ exit_if_true (count < 1, "\n\nLine %d : Could not find new_title in :\n%s\n", __LINE__, buffer) ;
+ exit_if_true (count > 1, "\n\nLine %d : new_title appears %d times in :\n\n%s\n", __LINE__, count, buffer) ;
+
+ count = str_count (buffer, software) ;
+ exit_if_true (count < 1, "\n\nLine %d : Could not find new_software in :\n%s\n", __LINE__, buffer) ;
+ exit_if_true (count > 1, "\n\nLine %d : new_software appears %d times in :\n\n%s\n", __LINE__, count, buffer) ;
+
+ count = str_count (buffer, new_artist) ;
+ exit_if_true (count < 1, "\n\nLine %d : Could not find new_artist in :\n%s\n", __LINE__, buffer) ;
+ exit_if_true (count > 1, "\n\nLine %d : new_artist appears %d times in :\n\n%s\n", __LINE__, count, buffer) ;
+
+ count = str_count (buffer, new_copyright) ;
+ exit_if_true (count < 1, "\n\nLine %d : Could not find new_copyright in :\n%s\n", __LINE__, buffer) ;
+ exit_if_true (count > 1, "\n\nLine %d : new_copyright appears %d times in :\n\n%s\n", __LINE__, count, buffer) ;
+
+ unlink (filename) ;
+
+ puts ("ok") ;
+} /* string_multi_set_test */
+
+static void
+string_rdwr_test (const char *filename, int typemajor)
+{ SNDFILE *file ;
+ SF_INFO sfinfo ;
+ sf_count_t frames ;
+ const char * str ;
+
+ print_test_name (__func__, filename) ;
+ create_short_sndfile (filename, typemajor | SF_FORMAT_PCM_16, 2) ;
+
+ memset (&sfinfo, 0, sizeof (sfinfo)) ;
+ file = test_open_file_or_die (filename, SFM_RDWR, &sfinfo, SF_FALSE, __LINE__) ;
+ frames = sfinfo.frames ;
+ sf_set_string (file, SF_STR_TITLE, title) ;
+ sf_close (file) ;
+
+ file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_FALSE, __LINE__) ;
+ exit_if_true (frames != sfinfo.frames, "\n\nLine %d : Frame count %lld should be %lld.\n", __LINE__, sfinfo.frames, frames) ;
+ str = sf_get_string (file, SF_STR_TITLE) ;
+ exit_if_true (str == NULL, "\n\nLine %d : SF_STR_TITLE string is NULL.\n", __LINE__) ;
+ exit_if_true (strcmp (str, title) != 0, "\n\nLine %d : SF_STR_TITLE doesn't match what was written.\n", __LINE__) ;
+ sf_close (file) ;
+
+ file = test_open_file_or_die (filename, SFM_RDWR, &sfinfo, SF_FALSE, __LINE__) ;
+ frames = sfinfo.frames ;
+ sf_set_string (file, SF_STR_TITLE, title) ;
+ sf_close (file) ;
+
+ file = test_open_file_or_die (filename, SFM_RDWR, &sfinfo, SF_FALSE, __LINE__) ;
+ str = sf_get_string (file, SF_STR_TITLE) ;
+ exit_if_true (str == NULL, "\n\nLine %d : SF_STR_TITLE string is NULL.\n", __LINE__) ;
+ sf_set_string (file, SF_STR_ARTIST, artist) ;
+ sf_close (file) ;
+
+ file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_FALSE, __LINE__) ;
+
+ str = sf_get_string (file, SF_STR_ARTIST) ;
+ exit_if_true (str == NULL, "\n\nLine %d : SF_STR_ARTIST string is NULL.\n", __LINE__) ;
+ exit_if_true (strcmp (str, artist) != 0, "\n\nLine %d : SF_STR_ARTIST doesn't match what was written.\n", __LINE__) ;
+
+ str = sf_get_string (file, SF_STR_TITLE) ;
+ exit_if_true (str == NULL, "\n\nLine %d : SF_STR_TITLE string is NULL.\n", __LINE__) ;
+ exit_if_true (strcmp (str, title) != 0, "\n\nLine %d : SF_STR_TITLE doesn't match what was written.\n", __LINE__) ;
+
+ exit_if_true (frames != sfinfo.frames, "\n\nLine %d : Frame count %lld should be %lld.\n", __LINE__, sfinfo.frames, frames) ;
+
+ sf_close (file) ;
+ unlink (filename) ;
+
+ puts ("ok") ;
+} /* string_rdwr_test */
+
+static void
+string_short_rdwr_test (const char *filename, int typemajor)
+{ SNDFILE *file ;
+ SF_INFO sfinfo ;
+ sf_count_t frames = BUFFER_LEN ;
+ const char * str ;
+
+ print_test_name (__func__, filename) ;
+
+ memset (&sfinfo, 0, sizeof (sfinfo)) ;
+ sfinfo.format = typemajor | SF_FORMAT_PCM_16 ;
+ sfinfo.samplerate = 44100 ;
+ sfinfo.channels = 1 ;
+ sfinfo.frames = 0 ;
+
+ file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_FALSE, __LINE__) ;
+
+ /* Write data to file. */
+ test_write_short_or_die (file, 0, data_out, BUFFER_LEN, __LINE__) ;
+
+ sf_set_string (file, SF_STR_TITLE, long_title) ;
+ sf_set_string (file, SF_STR_ARTIST, long_artist) ;
+ sf_close (file) ;
+
+ /* Open the file RDWR. */
+ file = test_open_file_or_die (filename, SFM_RDWR, &sfinfo, SF_FALSE, __LINE__) ;
+ exit_if_true (frames != sfinfo.frames, "\n\nLine %d : Frame count %lld should be %lld.\n", __LINE__, sfinfo.frames, frames) ;
+ str = sf_get_string (file, SF_STR_TITLE) ;
+ exit_if_true (str == NULL, "\n\nLine %d : SF_STR_TITLE string is NULL.\n", __LINE__) ;
+ exit_if_true (strcmp (str, long_title) != 0, "\n\nLine %d : SF_STR_TITLE doesn't match what was written.\n", __LINE__) ;
+ str = sf_get_string (file, SF_STR_ARTIST) ;
+ exit_if_true (str == NULL, "\n\nLine %d : SF_STR_TITLE string is NULL.\n", __LINE__) ;
+ exit_if_true (strcmp (str, long_artist) != 0, "\n\nLine %d : SF_STR_ARTIST doesn't match what was written.\n", __LINE__) ;
+
+ /* Change title and artist. */
+ sf_set_string (file, SF_STR_TITLE, title) ;
+ sf_set_string (file, SF_STR_ARTIST, artist) ;
+
+ sf_close (file) ;
+
+ file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_FALSE, __LINE__) ;
+
+ check_log_buffer_or_die (file, __LINE__) ;
+
+ str = sf_get_string (file, SF_STR_TITLE) ;
+ exit_if_true (str == NULL, "\n\nLine %d : SF_STR_TITLE string is NULL.\n", __LINE__) ;
+ exit_if_true (strcmp (str, title) != 0, "\n\nLine %d : SF_STR_TITLE doesn't match what was written.\n", __LINE__) ;
+
+ str = sf_get_string (file, SF_STR_ARTIST) ;
+ exit_if_true (str == NULL, "\n\nLine %d : SF_STR_ARTIST string is NULL.\n", __LINE__) ;
+ exit_if_true (strcmp (str, artist) != 0, "\n\nLine %d : SF_STR_ARTIST doesn't match what was written.\n", __LINE__) ;
+
+ sf_close (file) ;
+ unlink (filename) ;
+
+ puts ("ok") ;
+} /* string_short_rdwr_test */
+
+static int
+str_count (const char * haystack, const char * needle)
+{ int count = 0 ;
+
+ while ((haystack = strstr (haystack, needle)) != NULL)
+ { count ++ ;
+ haystack ++ ;
+ } ;
+
+ return count ;
+} /* str_count */
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: 0260b3db-c250-4244-95a0-d288a913729a
-*/
Added: freeswitch/trunk/libs/libsndfile/tests/test_wrapper.sh.in
==============================================================================
--- (empty file)
+++ freeswitch/trunk/libs/libsndfile/tests/test_wrapper.sh.in Thu May 21 16:09:30 2009
@@ -0,0 +1,281 @@
+#!/bin/sh
+
+if [ -f tests/sfversion at EXEEXT@ ]; then
+ cd tests
+ fi
+
+if [ ! -f sfversion at EXEEXT@ ]; then
+ echo "Not able to find test executables."
+ exit 1
+ fi
+
+sfversion=`./sfversion at EXEEXT@`
+
+# Force exit on errors.
+set -e
+
+# generic-tests
+uname -a
+./error_test at EXEEXT@
+./pcm_test at EXEEXT@
+./ulaw_test at EXEEXT@
+./alaw_test at EXEEXT@
+./dwvw_test at EXEEXT@
+./command_test at EXEEXT@ ver
+./command_test at EXEEXT@ norm
+./command_test at EXEEXT@ format
+./command_test at EXEEXT@ peak
+./command_test at EXEEXT@ trunc
+./command_test at EXEEXT@ inst
+./command_test at EXEEXT@ current_sf_info
+./command_test at EXEEXT@ bext
+./command_test at EXEEXT@ bextch
+./floating_point_test at EXEEXT@
+./checksum_test at EXEEXT@
+./scale_clip_test at EXEEXT@
+./headerless_test at EXEEXT@
+./locale_test at EXEEXT@
+./win32_ordinal_test at EXEEXT@
+./external_libs_test at EXEEXT@
+./cpp_test at EXEEXT@
+echo "----------------------------------------------------------------------"
+echo " $sfversion passed common tests."
+echo "----------------------------------------------------------------------"
+
+# aiff-tests
+./write_read_test at EXEEXT@ aiff
+./lossy_comp_test at EXEEXT@ aiff_ulaw
+./lossy_comp_test at EXEEXT@ aiff_alaw
+./lossy_comp_test at EXEEXT@ aiff_gsm610
+echo "=========================="
+echo "./lossy_comp_test at EXEEXT@ aiff_ima"
+echo "=========================="
+./peak_chunk_test at EXEEXT@ aiff
+./header_test at EXEEXT@ aiff
+./misc_test at EXEEXT@ aiff
+./string_test at EXEEXT@ aiff
+./multi_file_test at EXEEXT@ aiff
+./aiff_rw_test at EXEEXT@
+echo "----------------------------------------------------------------------"
+echo " $sfversion passed tests on AIFF files."
+echo "----------------------------------------------------------------------"
+
+# au-tests
+./write_read_test at EXEEXT@ au
+./lossy_comp_test at EXEEXT@ au_ulaw
+./lossy_comp_test at EXEEXT@ au_alaw
+./lossy_comp_test at EXEEXT@ au_g721
+./lossy_comp_test at EXEEXT@ au_g723
+./header_test at EXEEXT@ au
+./misc_test at EXEEXT@ au
+./multi_file_test at EXEEXT@ au
+echo "----------------------------------------------------------------------"
+echo " $sfversion passed tests on AU files."
+echo "----------------------------------------------------------------------"
+
+# caf-tests
+./write_read_test at EXEEXT@ caf
+./lossy_comp_test at EXEEXT@ caf_ulaw
+./lossy_comp_test at EXEEXT@ caf_alaw
+./header_test at EXEEXT@ caf
+./misc_test at EXEEXT@ caf
+echo "----------------------------------------------------------------------"
+echo " $sfversion passed tests on CAF files."
+echo "----------------------------------------------------------------------"
+
+# wav-tests
+./write_read_test at EXEEXT@ wav
+./lossy_comp_test at EXEEXT@ wav_pcm
+./lossy_comp_test at EXEEXT@ wav_ima
+./lossy_comp_test at EXEEXT@ wav_msadpcm
+./lossy_comp_test at EXEEXT@ wav_ulaw
+./lossy_comp_test at EXEEXT@ wav_alaw
+./lossy_comp_test at EXEEXT@ wav_gsm610
+./lossy_comp_test at EXEEXT@ wav_g721
+./peak_chunk_test at EXEEXT@ wav
+./header_test at EXEEXT@ wav
+./misc_test at EXEEXT@ wav
+./string_test at EXEEXT@ wav
+./multi_file_test at EXEEXT@ wav
+echo "----------------------------------------------------------------------"
+echo " $sfversion passed tests on WAV files."
+echo "----------------------------------------------------------------------"
+
+# w64-tests
+./write_read_test at EXEEXT@ w64
+./lossy_comp_test at EXEEXT@ w64_ima
+./lossy_comp_test at EXEEXT@ w64_msadpcm
+./lossy_comp_test at EXEEXT@ w64_ulaw
+./lossy_comp_test at EXEEXT@ w64_alaw
+./lossy_comp_test at EXEEXT@ w64_gsm610
+./header_test at EXEEXT@ w64
+./misc_test at EXEEXT@ w64
+echo "----------------------------------------------------------------------"
+echo " $sfversion passed tests on W64 files."
+echo "----------------------------------------------------------------------"
+
+# rf64-tests
+./write_read_test at EXEEXT@ rf64
+./header_test at EXEEXT@ rf64
+./misc_test at EXEEXT@ rf64
+echo "----------------------------------------------------------------------"
+echo " $sfversion passed tests on RF64 files."
+echo "----------------------------------------------------------------------"
+
+# raw-tests
+./write_read_test at EXEEXT@ raw
+./lossy_comp_test at EXEEXT@ raw_ulaw
+./lossy_comp_test at EXEEXT@ raw_alaw
+./lossy_comp_test at EXEEXT@ raw_gsm610
+./lossy_comp_test at EXEEXT@ vox_adpcm
+./raw_test at EXEEXT@
+echo "----------------------------------------------------------------------"
+echo " $sfversion passed tests on RAW (header-less) files."
+echo "----------------------------------------------------------------------"
+
+# paf-tests
+./write_read_test at EXEEXT@ paf
+./header_test at EXEEXT@ paf
+./misc_test at EXEEXT@ paf
+echo "----------------------------------------------------------------------"
+echo " $sfversion passed tests on PAF files."
+echo "----------------------------------------------------------------------"
+
+# svx-tests
+./write_read_test at EXEEXT@ svx
+./header_test at EXEEXT@ svx
+./misc_test at EXEEXT@ svx
+echo "----------------------------------------------------------------------"
+echo " $sfversion passed tests on SVX files."
+echo "----------------------------------------------------------------------"
+
+# nist-tests
+./write_read_test at EXEEXT@ nist
+./lossy_comp_test at EXEEXT@ nist_ulaw
+./lossy_comp_test at EXEEXT@ nist_alaw
+./header_test at EXEEXT@ nist
+./misc_test at EXEEXT@ nist
+echo "----------------------------------------------------------------------"
+echo " $sfversion passed tests on NIST files."
+echo "----------------------------------------------------------------------"
+
+# ircam-tests
+./write_read_test at EXEEXT@ ircam
+./lossy_comp_test at EXEEXT@ ircam_ulaw
+./lossy_comp_test at EXEEXT@ ircam_alaw
+./header_test at EXEEXT@ ircam
+./misc_test at EXEEXT@ ircam
+echo "----------------------------------------------------------------------"
+echo " $sfversion passed tests on IRCAM files."
+echo "----------------------------------------------------------------------"
+
+# voc-tests
+./write_read_test at EXEEXT@ voc
+./lossy_comp_test at EXEEXT@ voc_ulaw
+./lossy_comp_test at EXEEXT@ voc_alaw
+./header_test at EXEEXT@ voc
+./misc_test at EXEEXT@ voc
+echo "----------------------------------------------------------------------"
+echo " $sfversion passed tests on VOC files."
+echo "----------------------------------------------------------------------"
+
+# mat4-tests
+./write_read_test at EXEEXT@ mat4
+./header_test at EXEEXT@ mat4
+./misc_test at EXEEXT@ mat4
+echo "----------------------------------------------------------------------"
+echo " $sfversion passed tests on MAT4 files."
+echo "----------------------------------------------------------------------"
+
+# mat5-tests
+./write_read_test at EXEEXT@ mat5
+./header_test at EXEEXT@ mat5
+./misc_test at EXEEXT@ mat5
+echo "----------------------------------------------------------------------"
+echo " $sfversion passed tests on MAT5 files."
+echo "----------------------------------------------------------------------"
+
+# pvf-tests
+./write_read_test at EXEEXT@ pvf
+./header_test at EXEEXT@ pvf
+./misc_test at EXEEXT@ pvf
+echo "----------------------------------------------------------------------"
+echo " $sfversion passed tests on PVF files."
+echo "----------------------------------------------------------------------"
+
+# xi-tests
+./lossy_comp_test at EXEEXT@ xi_dpcm
+echo "----------------------------------------------------------------------"
+echo " $sfversion passed tests on XI files."
+echo "----------------------------------------------------------------------"
+
+# htk-tests
+./write_read_test at EXEEXT@ htk
+./header_test at EXEEXT@ htk
+./misc_test at EXEEXT@ htk
+echo "----------------------------------------------------------------------"
+echo " $sfversion passed tests on HTK files."
+echo "----------------------------------------------------------------------"
+
+# avr-tests
+./write_read_test at EXEEXT@ avr
+./header_test at EXEEXT@ avr
+./misc_test at EXEEXT@ avr
+echo "----------------------------------------------------------------------"
+echo " $sfversion passed tests on AVR files."
+echo "----------------------------------------------------------------------"
+
+# sds-tests
+./write_read_test at EXEEXT@ sds
+./header_test at EXEEXT@ sds
+./misc_test at EXEEXT@ sds
+echo "----------------------------------------------------------------------"
+echo " $sfversion passed tests on SDS files."
+echo "----------------------------------------------------------------------"
+
+# sd2-tests
+./write_read_test at EXEEXT@ sd2
+echo "----------------------------------------------------------------------"
+echo " $sfversion passed tests on SD2 files."
+echo "----------------------------------------------------------------------"
+
+# wve-tests
+./lossy_comp_test at EXEEXT@ wve
+echo "----------------------------------------------------------------------"
+echo " $sfversion passed tests on WVE files."
+echo "----------------------------------------------------------------------"
+
+# mpc2k-tests
+./write_read_test at EXEEXT@ mpc2k
+./header_test at EXEEXT@ mpc2k
+./misc_test at EXEEXT@ mpc2k
+echo "----------------------------------------------------------------------"
+echo " $sfversion passed tests on MPC 2000 files."
+echo "----------------------------------------------------------------------"
+
+# flac-tests
+./write_read_test at EXEEXT@ flac
+./string_test at EXEEXT@ flac
+echo "----------------------------------------------------------------------"
+echo " $sfversion passed tests on FLAC files."
+echo "----------------------------------------------------------------------"
+
+# vorbis-tests
+./ogg_test at EXEEXT@
+./vorbis_test at EXEEXT@
+./lossy_comp_test at EXEEXT@ ogg_vorbis
+./string_test at EXEEXT@ ogg
+./misc_test at EXEEXT@ ogg
+echo "----------------------------------------------------------------------"
+echo " $sfversion passed tests on OGG/VORBIS files."
+echo "----------------------------------------------------------------------"
+
+# io-tests
+./stdio_test at EXEEXT@
+./pipe_test at EXEEXT@
+./virtual_io_test at EXEEXT@
+echo "----------------------------------------------------------------------"
+echo " $sfversion passed stdio/pipe/vio tests."
+echo "----------------------------------------------------------------------"
+
+
Modified: freeswitch/trunk/libs/libsndfile/tests/ulaw_test.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/tests/ulaw_test.c (original)
+++ freeswitch/trunk/libs/libsndfile/tests/ulaw_test.c Thu May 21 16:09:30 2009
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 1999-2004 Erik de Castro Lopo <erikd at mega-nerd.com>
+** Copyright (C) 1999-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
@@ -253,10 +253,3 @@
return sample ;
} /* ulaw_decode */
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: e764cee1-5a9a-480b-a4ca-34d9b57dea6f
-*/
Modified: freeswitch/trunk/libs/libsndfile/tests/utils.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/tests/utils.c (original)
+++ freeswitch/trunk/libs/libsndfile/tests/utils.c Thu May 21 16:09:30 2009
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 2002-2005 Erik de Castro Lopo <erikd at mega-nerd.com>
+** Copyright (C) 2002-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
@@ -29,6 +29,7 @@
#include <stdio.h>
#include <stdlib.h>
+#include <inttypes.h>
#if HAVE_UNISTD_H
#include <unistd.h>
@@ -55,6 +56,15 @@
#define LOG_BUFFER_SIZE 2048
+/*
+** Neat solution to the Win32/OS2 binary file flage requirement.
+** If O_BINARY isn't already defined by the inclusion of the system
+** headers, set it to zero.
+*/
+#ifndef O_BINARY
+#define O_BINARY 0
+#endif
+
void
gen_windowed_sine_float (float *data, int len, double maximum)
@@ -104,42 +114,57 @@
void
-check_file_hash_or_die (const char *filename, unsigned int target_hash, int line_num)
-{ static unsigned char buffer [2048] ;
- unsigned int hash1, hash2 ;
- FILE *file ;
- int k, read_count ;
+create_short_sndfile (const char *filename, int format, int channels)
+{ short data [2 * 3 * 4 * 5 * 6 * 7] = { 0, } ;
+ SNDFILE *file ;
+ SF_INFO sfinfo ;
+
+ sfinfo.samplerate = 44100 ;
+ sfinfo.channels = channels ;
+ sfinfo.format = format ;
+
+ if ((file = sf_open (filename, SFM_WRITE, &sfinfo)) == NULL)
+ { printf ("Error (%s, %d) : sf_open failed : %s\n", __FILE__, __LINE__, sf_strerror (file)) ;
+ exit (1) ;
+ } ;
+
+ sf_write_short (file, data, ARRAY_LEN (data)) ;
+
+ sf_close (file) ;
+} /* create_short_sndfile */
+
+void
+check_file_hash_or_die (const char *filename, uint64_t target_hash, int line_num)
+{ static unsigned char buf [4096] ;
+ uint64_t cksum ;
+ FILE *file ;
+ int k, read_count ;
- memset (buffer, 0xEE, sizeof (buffer)) ;
+ memset (buf, 0, sizeof (buf)) ;
/* The 'b' in the mode string means binary for Win32. */
- if (! (file = fopen (filename, "rb")))
+ if ((file = fopen (filename, "rb")) == NULL)
{ printf ("\n\nLine %d: could not open file '%s'\n\n", line_num, filename) ;
exit (1) ;
} ;
- hash1 = hash2 = 0 ;
+ cksum = 0 ;
- while ((read_count = fread (buffer, 1, sizeof (buffer), file)))
- { for (k = 0 ; k < read_count ; k++)
- { hash1 = hash1 + buffer [k] ;
- hash2 = hash2 ^ (buffer [k] << (k % 25)) ;
- } ;
- } ;
+ while ((read_count = fread (buf, 1, sizeof (buf), file)))
+ for (k = 0 ; k < read_count ; k++)
+ cksum = cksum * 511 + buf [k] ;
fclose (file) ;
- hash1 += hash2 ;
-
if (target_hash == 0)
- { printf (" 0x%08x ", hash1) ;
+ { printf (" 0x%016" PRIx64 "\n", cksum) ;
return ;
} ;
- if (hash1 != target_hash)
- { printf ("\n\nLine %d: incorrect hash value 0x%08x should be 0x%08x\n\n", line_num, hash1, target_hash) ;
+ if (cksum != target_hash)
+ { printf ("\n\nLine %d: incorrect hash value 0x%016" PRIx64 " should be 0x%016" PRIx64 ".\n\n", line_num, cksum, target_hash) ;
exit (1) ;
- }
+ } ;
return ;
} /* check_file_hash_or_die */
@@ -148,14 +173,20 @@
print_test_name (const char *test, const char *filename)
{ int count ;
- if (test == NULL || filename == NULL)
+ if (test == NULL)
{ printf (__FILE__ ": bad test of filename parameter.\n") ;
exit (1) ;
} ;
- printf (" %-25s : %s ", test, filename) ;
+ if (filename == NULL || strlen (filename) == 0)
+ { printf (" %-30s : ", test) ;
+ count = 25 ;
+ }
+ else
+ { printf (" %-30s : %s ", test, filename) ;
+ count = 24 - strlen (filename) ;
+ } ;
- count = 24 - strlen (filename) ;
while (count -- > 0)
putchar ('.') ;
putchar (' ') ;
@@ -164,7 +195,7 @@
} /* print_test_name */
void
-dump_data_to_file (const char *filename, void *data, unsigned int datalen)
+dump_data_to_file (const char *filename, const void *data, unsigned int datalen)
{ FILE *file ;
if ((file = fopen (filename, "wb")) == NULL)
@@ -187,7 +218,7 @@
static char octfilename [] = "error.dat" ;
int
-oct_save_short (short *a, short *b, int len)
+oct_save_short (const short *a, const short *b, int len)
{ FILE *file ;
int k ;
@@ -202,7 +233,7 @@
fprintf (file, "# columns: 1\n") ;
for (k = 0 ; k < len ; k++)
- fprintf (file, "% d\n", a [k]) ;
+ fprintf (file, "% d" "\n", a [k]) ;
fprintf (file, "# name: b\n") ;
fprintf (file, "# type: matrix\n") ;
@@ -210,13 +241,13 @@
fprintf (file, "# columns: 1\n") ;
for (k = 0 ; k < len ; k++)
- fprintf (file, "% d\n", b [k]) ;
+ fprintf (file, "% d" "\n", b [k]) ;
fclose (file) ;
return 0 ;
} /* oct_save_short */
int
-oct_save_int (int *a, int *b, int len)
+oct_save_int (const int *a, const int *b, int len)
{ FILE *file ;
int k ;
@@ -231,7 +262,7 @@
fprintf (file, "# columns: 1\n") ;
for (k = 0 ; k < len ; k++)
- fprintf (file, "% d\n", a [k]) ;
+ fprintf (file, "% d" "\n", a [k]) ;
fprintf (file, "# name: b\n") ;
fprintf (file, "# type: matrix\n") ;
@@ -239,13 +270,13 @@
fprintf (file, "# columns: 1\n") ;
for (k = 0 ; k < len ; k++)
- fprintf (file, "% d\n", b [k]) ;
+ fprintf (file, "% d" "\n", b [k]) ;
fclose (file) ;
return 0 ;
} /* oct_save_int */
int
-oct_save_float (float *a, float *b, int len)
+oct_save_float (const float *a, const float *b, int len)
{ FILE *file ;
int k ;
@@ -260,7 +291,7 @@
fprintf (file, "# columns: 1\n") ;
for (k = 0 ; k < len ; k++)
- fprintf (file, "% g\n", a [k]) ;
+ fprintf (file, "% g" "\n", a [k]) ;
fprintf (file, "# name: b\n") ;
fprintf (file, "# type: matrix\n") ;
@@ -268,13 +299,13 @@
fprintf (file, "# columns: 1\n") ;
for (k = 0 ; k < len ; k++)
- fprintf (file, "% g\n", b [k]) ;
+ fprintf (file, "% g" "\n", b [k]) ;
fclose (file) ;
return 0 ;
} /* oct_save_float */
int
-oct_save_double (double *a, double *b, int len)
+oct_save_double (const double *a, const double *b, int len)
{ FILE *file ;
int k ;
@@ -289,7 +320,7 @@
fprintf (file, "# columns: 1\n") ;
for (k = 0 ; k < len ; k++)
- fprintf (file, "% g\n", a [k]) ;
+ fprintf (file, "% g" "\n", a [k]) ;
fprintf (file, "# name: b\n") ;
fprintf (file, "# type: matrix\n") ;
@@ -297,7 +328,7 @@
fprintf (file, "# columns: 1\n") ;
for (k = 0 ; k < len ; k++)
- fprintf (file, "% g\n", b [k]) ;
+ fprintf (file, "% g" "\n", b [k]) ;
fclose (file) ;
return 0 ;
@@ -447,19 +478,19 @@
switch (mode)
{ case SFM_READ :
modestr = "SFM_READ" ;
- oflags = O_RDONLY ;
+ oflags = O_RDONLY | O_BINARY ;
omode = 0 ;
break ;
case SFM_WRITE :
modestr = "SFM_WRITE" ;
- oflags = O_WRONLY | O_CREAT | O_TRUNC ;
+ oflags = O_WRONLY | O_CREAT | O_TRUNC | O_BINARY ;
omode = S_IRUSR | S_IWUSR | S_IRGRP ;
break ;
case SFM_RDWR :
modestr = "SFM_RDWR" ;
- oflags = O_RDWR | O_CREAT ;
+ oflags = O_RDWR | O_CREAT | O_BINARY ;
omode = S_IRUSR | S_IWUSR | S_IRGRP ;
break ;
default :
@@ -468,18 +499,15 @@
exit (1) ;
} ;
-#if (defined (WIN32) || defined (_WIN32))
- /* Stupid fscking windows. */
- oflags |= O_BINARY ;
-#endif
+ if (OS_IS_WIN32)
+ { /* Windows doesn't support Unix file permissions so set it to zero. */
+ omode = 0 ;
+ } ;
if (allow_fd && ((++count) & 1) == 1)
{ int fd ;
- if (omode == 0)
- fd = open (filename, oflags) ;
- else
- fd = open (filename, oflags, omode) ;
+ fd = open (filename, oflags, omode) ;
if (fd < 0)
{ perror ("open") ;
@@ -880,6 +908,61 @@
void
+compare_short_or_die (const short *left, const short *right, unsigned count, int line_num)
+{
+ unsigned k ;
+
+ for (k = 0 ; k < count ;k++)
+ if (left [k] != right [k])
+ { printf ("\n\nLine %d : Error at index %d, " "% d" " should be " "% d" ".\n\n", line_num, k, left [k], right [k]) ;
+ exit (1) ;
+ } ;
+
+ return ;
+} /* compare_short_or_die */
+void
+compare_int_or_die (const int *left, const int *right, unsigned count, int line_num)
+{
+ unsigned k ;
+
+ for (k = 0 ; k < count ;k++)
+ if (left [k] != right [k])
+ { printf ("\n\nLine %d : Error at index %d, " "% d" " should be " "% d" ".\n\n", line_num, k, left [k], right [k]) ;
+ exit (1) ;
+ } ;
+
+ return ;
+} /* compare_int_or_die */
+void
+compare_float_or_die (const float *left, const float *right, unsigned count, int line_num)
+{
+ unsigned k ;
+
+ for (k = 0 ; k < count ;k++)
+ if (left [k] != right [k])
+ { printf ("\n\nLine %d : Error at index %d, " "% g" " should be " "% g" ".\n\n", line_num, k, left [k], right [k]) ;
+ exit (1) ;
+ } ;
+
+ return ;
+} /* compare_float_or_die */
+void
+compare_double_or_die (const double *left, const double *right, unsigned count, int line_num)
+{
+ unsigned k ;
+
+ for (k = 0 ; k < count ;k++)
+ if (left [k] != right [k])
+ { printf ("\n\nLine %d : Error at index %d, " "% g" " should be " "% g" ".\n\n", line_num, k, left [k], right [k]) ;
+ exit (1) ;
+ } ;
+
+ return ;
+} /* compare_double_or_die */
+
+
+
+void
delete_file (int format, const char *filename)
{ char rsrc_name [512], *fname ;
@@ -959,6 +1042,75 @@
#endif
} /* check_open_file_count_or_die */
+void
+write_mono_file (const char * filename, int format, int srate, float * output, int len)
+{ SNDFILE * file ;
+ SF_INFO sfinfo ;
+
+ memset (&sfinfo, 0, sizeof (sfinfo)) ;
+
+ sfinfo.samplerate = srate ;
+ sfinfo.channels = 1 ;
+ sfinfo.format = format ;
+
+ if ((file = sf_open (filename, SFM_WRITE, &sfinfo)) == NULL)
+ { printf ("sf_open (%s) : %s\n", filename, sf_strerror (NULL)) ;
+ exit (1) ;
+ } ;
+
+ sf_write_float (file, output, len) ;
+
+ sf_close (file) ;
+} /* write_mono_file */
+
+void
+gen_lowpass_noise_float (float *data, int len)
+{ int32_t value = 0x1243456 ;
+ double sample, last_val = 0.0 ;
+ int k ;
+
+ for (k = 0 ; k < len ; k++)
+ { /* Not a crypto quality RNG. */
+ value = 11117 * value + 211231 ;
+ value = 11117 * value + 211231 ;
+ value = 11117 * value + 211231 ;
+
+ sample = value / (0x7fffffff * 1.000001) ;
+ sample = 0.2 * sample - 0.9 * last_val ;
+
+ data [k] = last_val = sample ;
+ } ;
+
+} /* gen_lowpass_noise_float */
+
+
+/*
+** Windows is fucked.
+** If a file is opened R/W and data is written to it, then fstat will return
+** the correct file length, but stat will return zero.
+*/
+
+sf_count_t
+file_length (const char * fname)
+{ struct stat data ;
+
+ if (stat (fname, &data) != 0)
+ return 0 ;
+
+ return (sf_count_t) data.st_size ;
+} /* file_length */
+
+sf_count_t
+file_length_fd (int fd)
+{ struct stat data ;
+
+ memset (&data, 0, sizeof (data)) ;
+ if (fstat (fd, &data) != 0)
+ return 0 ;
+
+ return (sf_count_t) data.st_size ;
+} /* file_length_fd */
+
Modified: freeswitch/trunk/libs/libsndfile/tests/utils.def
==============================================================================
--- freeswitch/trunk/libs/libsndfile/tests/utils.def (original)
+++ freeswitch/trunk/libs/libsndfile/tests/utils.def Thu May 21 16:09:30 2009
@@ -12,22 +12,22 @@
io_type = {
io_element = short ;
- format_str = "\"% d\\n\"" ;
+ format_str = "\"% d\"" ;
};
io_type = {
io_element = int ;
- format_str = "\"% d\\n\"" ;
+ format_str = "\"% d\"" ;
};
io_type = {
io_element = float ;
- format_str = "\"% g\\n\"" ;
+ format_str = "\"% g\"" ;
};
io_type = {
io_element = double ;
- format_str = "\"% g\\n\"" ;
+ format_str = "\"% g\"" ;
};
read_op = {
@@ -49,11 +49,4 @@
op_element = writef ;
count_name = frames ;
};
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: 735898a2-711e-42c2-aaf1-354b20c07ac7
-*/
Modified: freeswitch/trunk/libs/libsndfile/tests/utils.h
==============================================================================
--- freeswitch/trunk/libs/libsndfile/tests/utils.h (original)
+++ freeswitch/trunk/libs/libsndfile/tests/utils.h Thu May 21 16:09:30 2009
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 2002-2005 Erik de Castro Lopo <erikd at mega-nerd.com>
+** Copyright (C) 2002-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
@@ -29,6 +29,7 @@
extern "C" {
#endif /* __cplusplus */
+#include <stdint.h>
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
@@ -40,7 +41,7 @@
#define PIPE_INDEX(x) ((x) + 500)
#define PIPE_TEST_LEN 12345
-#if (defined (WIN32) || defined (_WIN32))
+#if (defined (WIN32) || defined (_WIN32) || defined (__OS2__))
#define snprintf _snprintf
#endif
@@ -48,11 +49,15 @@
void gen_windowed_sine_double (double *data, int len, double maximum) ;
-void check_file_hash_or_die (const char *filename, unsigned int target_hash, int line_num) ;
+void create_short_sndfile (const char *filename, int format, int channels) ;
+
+void check_file_hash_or_die (const char *filename, uint64_t target_hash, int line_num) ;
void print_test_name (const char *test, const char *filename) ;
-void dump_data_to_file (const char *filename, void *data, unsigned int datalen) ;
+void dump_data_to_file (const char *filename, const void *data, unsigned int datalen) ;
+
+void write_mono_file (const char * filename, int format, int srate, float * output, int len) ;
static inline void
exit_if_true (int test, const char *format, ...)
@@ -70,10 +75,10 @@
** can then be loaded into GNU octave for comparison.
*/
-int oct_save_short (short *a, short *b, int len) ;
-int oct_save_int (int *a, int *b, int len) ;
-int oct_save_float (float *a, float *b, int len) ;
-int oct_save_double (double *a, double *b, int len) ;
+int oct_save_short (const short *a, const short *b, int len) ;
+int oct_save_int (const int *a, const int *b, int len) ;
+int oct_save_float (const float *a, const float *b, int len) ;
+int oct_save_double (const double *a, const double *b, int len) ;
void delete_file (int format, const char *filename) ;
@@ -139,6 +144,18 @@
(SNDFILE *file, int pass, const double *test, sf_count_t frames, int line_num) ;
+void compare_short_or_die (const short *left, const short *right, unsigned count, int line_num) ;
+void compare_int_or_die (const int *left, const int *right, unsigned count, int line_num) ;
+void compare_float_or_die (const float *left, const float *right, unsigned count, int line_num) ;
+void compare_double_or_die (const double *left, const double *right, unsigned count, int line_num) ;
+
+
+
+void gen_lowpass_noise_float (float *data, int len) ;
+
+sf_count_t file_length (const char * fname) ;
+sf_count_t file_length_fd (int fd) ;
+
#endif
#ifdef __cplusplus
@@ -147,4 +164,3 @@
-
Modified: freeswitch/trunk/libs/libsndfile/tests/utils.tpl
==============================================================================
--- freeswitch/trunk/libs/libsndfile/tests/utils.tpl (original)
+++ freeswitch/trunk/libs/libsndfile/tests/utils.tpl Thu May 21 16:09:30 2009
@@ -1,6 +1,6 @@
[+ AutoGen5 template h c +]
/*
-** Copyright (C) 2002-2005 Erik de Castro Lopo <erikd at mega-nerd.com>
+** Copyright (C) 2002-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
@@ -31,6 +31,7 @@
extern "C" {
#endif /* __cplusplus */
+#include <stdint.h>
#include <stdarg.h>
#define SF_COUNT_TO_LONG(x) ((long) (x))
@@ -40,7 +41,7 @@
#define PIPE_INDEX(x) ((x) + 500)
#define PIPE_TEST_LEN 12345
-#if (defined (WIN32) || defined (_WIN32))
+#if (defined (WIN32) || defined (_WIN32) || defined (__OS2__))
#define snprintf _snprintf
#endif
@@ -49,11 +50,15 @@
[+ ENDFOR float_type
+]
-void check_file_hash_or_die (const char *filename, unsigned int target_hash, int line_num) ;
+void create_short_sndfile (const char *filename, int format, int channels) ;
+
+void check_file_hash_or_die (const char *filename, uint64_t target_hash, int line_num) ;
void print_test_name (const char *test, const char *filename) ;
-void dump_data_to_file (const char *filename, void *data, unsigned int datalen) ;
+void dump_data_to_file (const char *filename, const void *data, unsigned int datalen) ;
+
+void write_mono_file (const char * filename, int format, int srate, float * output, int len) ;
static inline void
exit_if_true (int test, const char *format, ...)
@@ -72,7 +77,7 @@
*/
[+ FOR io_type
-+]int oct_save_[+ (get "io_element") +] ([+ (get "io_element") +] *a, [+ (get "io_element") +] *b, int len) ;
++]int oct_save_[+ (get "io_element") +] (const [+ (get "io_element") +] *a, const [+ (get "io_element") +] *b, int len) ;
[+ ENDFOR io_type
+]
@@ -111,6 +116,16 @@
(SNDFILE *file, int pass, const [+ (get "io_element") +] *test, sf_count_t [+ (get "count_name") +], int line_num) ;
[+ ENDFOR io_type +][+ ENDFOR write_op +]
+[+ FOR io_type
++]void compare_[+ (get "io_element") +]_or_die (const [+ (get "io_element") +] *left, const [+ (get "io_element") +] *right, unsigned count, int line_num) ;
+[+ ENDFOR io_type +]
+
+
+void gen_lowpass_noise_float (float *data, int len) ;
+
+sf_count_t file_length (const char * fname) ;
+sf_count_t file_length_fd (int fd) ;
+
#endif
#ifdef __cplusplus
@@ -123,6 +138,7 @@
#include <stdio.h>
#include <stdlib.h>
+#include <inttypes.h>
#if HAVE_UNISTD_H
#include <unistd.h>
@@ -149,6 +165,15 @@
#define LOG_BUFFER_SIZE 2048
+/*
+** Neat solution to the Win32/OS2 binary file flage requirement.
+** If O_BINARY isn't already defined by the inclusion of the system
+** headers, set it to zero.
+*/
+#ifndef O_BINARY
+#define O_BINARY 0
+#endif
+
[+ FOR float_type +]
void
gen_windowed_sine_[+ (get "name") +] ([+ (get "name") +] *data, int len, double maximum)
@@ -175,42 +200,57 @@
[+ ENDFOR float_type +]
void
-check_file_hash_or_die (const char *filename, unsigned int target_hash, int line_num)
-{ static unsigned char buffer [2048] ;
- unsigned int hash1, hash2 ;
- FILE *file ;
- int k, read_count ;
+create_short_sndfile (const char *filename, int format, int channels)
+{ short data [2 * 3 * 4 * 5 * 6 * 7] = { 0, } ;
+ SNDFILE *file ;
+ SF_INFO sfinfo ;
+
+ sfinfo.samplerate = 44100 ;
+ sfinfo.channels = channels ;
+ sfinfo.format = format ;
+
+ if ((file = sf_open (filename, SFM_WRITE, &sfinfo)) == NULL)
+ { printf ("Error (%s, %d) : sf_open failed : %s\n", __FILE__, __LINE__, sf_strerror (file)) ;
+ exit (1) ;
+ } ;
- memset (buffer, 0xEE, sizeof (buffer)) ;
+ sf_write_short (file, data, ARRAY_LEN (data)) ;
+
+ sf_close (file) ;
+} /* create_short_sndfile */
+
+void
+check_file_hash_or_die (const char *filename, uint64_t target_hash, int line_num)
+{ static unsigned char buf [4096] ;
+ uint64_t cksum ;
+ FILE *file ;
+ int k, read_count ;
+
+ memset (buf, 0, sizeof (buf)) ;
/* The 'b' in the mode string means binary for Win32. */
- if (! (file = fopen (filename, "rb")))
+ if ((file = fopen (filename, "rb")) == NULL)
{ printf ("\n\nLine %d: could not open file '%s'\n\n", line_num, filename) ;
exit (1) ;
} ;
- hash1 = hash2 = 0 ;
+ cksum = 0 ;
- while ((read_count = fread (buffer, 1, sizeof (buffer), file)))
- { for (k = 0 ; k < read_count ; k++)
- { hash1 = hash1 + buffer [k] ;
- hash2 = hash2 ^ (buffer [k] << (k % 25)) ;
- } ;
- } ;
+ while ((read_count = fread (buf, 1, sizeof (buf), file)))
+ for (k = 0 ; k < read_count ; k++)
+ cksum = cksum * 511 + buf [k] ;
fclose (file) ;
- hash1 += hash2 ;
-
if (target_hash == 0)
- { printf (" 0x%08x ", hash1) ;
+ { printf (" 0x%016" PRIx64 "\n", cksum) ;
return ;
} ;
- if (hash1 != target_hash)
- { printf ("\n\nLine %d: incorrect hash value 0x%08x should be 0x%08x\n\n", line_num, hash1, target_hash) ;
+ if (cksum != target_hash)
+ { printf ("\n\nLine %d: incorrect hash value 0x%016" PRIx64 " should be 0x%016" PRIx64 ".\n\n", line_num, cksum, target_hash) ;
exit (1) ;
- }
+ } ;
return ;
} /* check_file_hash_or_die */
@@ -219,14 +259,20 @@
print_test_name (const char *test, const char *filename)
{ int count ;
- if (test == NULL || filename == NULL)
+ if (test == NULL)
{ printf (__FILE__ ": bad test of filename parameter.\n") ;
exit (1) ;
} ;
- printf (" %-25s : %s ", test, filename) ;
+ if (filename == NULL || strlen (filename) == 0)
+ { printf (" %-30s : ", test) ;
+ count = 25 ;
+ }
+ else
+ { printf (" %-30s : %s ", test, filename) ;
+ count = 24 - strlen (filename) ;
+ } ;
- count = 24 - strlen (filename) ;
while (count -- > 0)
putchar ('.') ;
putchar (' ') ;
@@ -235,7 +281,7 @@
} /* print_test_name */
void
-dump_data_to_file (const char *filename, void *data, unsigned int datalen)
+dump_data_to_file (const char *filename, const void *data, unsigned int datalen)
{ FILE *file ;
if ((file = fopen (filename, "wb")) == NULL)
@@ -259,7 +305,7 @@
[+ FOR io_type
+]int
-oct_save_[+ (get "io_element") +] ([+ (get "io_element") +] *a, [+ (get "io_element") +] *b, int len)
+oct_save_[+ (get "io_element") +] (const [+ (get "io_element") +] *a, const [+ (get "io_element") +] *b, int len)
{ FILE *file ;
int k ;
@@ -274,7 +320,7 @@
fprintf (file, "# columns: 1\n") ;
for (k = 0 ; k < len ; k++)
- fprintf (file, [+ (get "format_str") +], a [k]) ;
+ fprintf (file, [+ (get "format_str") +] "\n", a [k]) ;
fprintf (file, "# name: b\n") ;
fprintf (file, "# type: matrix\n") ;
@@ -282,7 +328,7 @@
fprintf (file, "# columns: 1\n") ;
for (k = 0 ; k < len ; k++)
- fprintf (file, [+ (get "format_str") +], b [k]) ;
+ fprintf (file, [+ (get "format_str") +] "\n", b [k]) ;
fclose (file) ;
return 0 ;
@@ -433,19 +479,19 @@
switch (mode)
{ case SFM_READ :
modestr = "SFM_READ" ;
- oflags = O_RDONLY ;
+ oflags = O_RDONLY | O_BINARY ;
omode = 0 ;
break ;
case SFM_WRITE :
modestr = "SFM_WRITE" ;
- oflags = O_WRONLY | O_CREAT | O_TRUNC ;
+ oflags = O_WRONLY | O_CREAT | O_TRUNC | O_BINARY ;
omode = S_IRUSR | S_IWUSR | S_IRGRP ;
break ;
case SFM_RDWR :
modestr = "SFM_RDWR" ;
- oflags = O_RDWR | O_CREAT ;
+ oflags = O_RDWR | O_CREAT | O_BINARY ;
omode = S_IRUSR | S_IWUSR | S_IRGRP ;
break ;
default :
@@ -454,18 +500,15 @@
exit (1) ;
} ;
-#if (defined (WIN32) || defined (_WIN32))
- /* Stupid fscking windows. */
- oflags |= O_BINARY ;
-#endif
+ if (OS_IS_WIN32)
+ { /* Windows doesn't support Unix file permissions so set it to zero. */
+ omode = 0 ;
+ } ;
if (allow_fd && ((++count) & 1) == 1)
{ int fd ;
- if (omode == 0)
- fd = open (filename, oflags) ;
- else
- fd = open (filename, oflags, omode) ;
+ fd = open (filename, oflags, omode) ;
if (fd < 0)
{ perror ("open") ;
@@ -611,6 +654,23 @@
} /* test_[+ (get "op_element") +]_[+ (get "io_element") +] */
[+ ENDFOR io_type +][+ ENDFOR write_op +]
+[+ FOR io_type
++]void
+compare_[+ (get "io_element") +]_or_die (const [+ (get "io_element") +] *left, const [+ (get "io_element") +] *right, unsigned count, int line_num)
+{
+ unsigned k ;
+
+ for (k = 0 ; k < count ;k++)
+ if (left [k] != right [k])
+ { printf ("\n\nLine %d : Error at index %d, " [+ (get "format_str") +] " should be " [+ (get "format_str") +] ".\n\n", line_num, k, left [k], right [k]) ;
+ exit (1) ;
+ } ;
+
+ return ;
+} /* compare_[+ (get "io_element") +]_or_die */
+[+ ENDFOR io_type +]
+
+
void
delete_file (int format, const char *filename)
{ char rsrc_name [512], *fname ;
@@ -691,14 +751,75 @@
#endif
} /* check_open_file_count_or_die */
-[+ ESAC +]
+void
+write_mono_file (const char * filename, int format, int srate, float * output, int len)
+{ SNDFILE * file ;
+ SF_INFO sfinfo ;
+
+ memset (&sfinfo, 0, sizeof (sfinfo)) ;
+
+ sfinfo.samplerate = srate ;
+ sfinfo.channels = 1 ;
+ sfinfo.format = format ;
-[+ COMMENT
+ if ((file = sf_open (filename, SFM_WRITE, &sfinfo)) == NULL)
+ { printf ("sf_open (%s) : %s\n", filename, sf_strerror (NULL)) ;
+ exit (1) ;
+ } ;
- Do not edit or modify anything in this comment block.
- The following line is a file identity tag for the GNU Arch
- revision control system.
+ sf_write_float (file, output, len) ;
- arch-tag: b1183d5d-ebd4-4bc5-af50-60d774d6b1f5
+ sf_close (file) ;
+} /* write_mono_file */
+
+void
+gen_lowpass_noise_float (float *data, int len)
+{ int32_t value = 0x1243456 ;
+ double sample, last_val = 0.0 ;
+ int k ;
+
+ for (k = 0 ; k < len ; k++)
+ { /* Not a crypto quality RNG. */
+ value = 11117 * value + 211231 ;
+ value = 11117 * value + 211231 ;
+ value = 11117 * value + 211231 ;
+
+ sample = value / (0x7fffffff * 1.000001) ;
+ sample = 0.2 * sample - 0.9 * last_val ;
+
+ data [k] = last_val = sample ;
+ } ;
+
+} /* gen_lowpass_noise_float */
+
+
+/*
+** Windows is fucked.
+** If a file is opened R/W and data is written to it, then fstat will return
+** the correct file length, but stat will return zero.
+*/
+
+sf_count_t
+file_length (const char * fname)
+{ struct stat data ;
+
+ if (stat (fname, &data) != 0)
+ return 0 ;
+
+ return (sf_count_t) data.st_size ;
+} /* file_length */
+
+sf_count_t
+file_length_fd (int fd)
+{ struct stat data ;
+
+ memset (&data, 0, sizeof (data)) ;
+ if (fstat (fd, &data) != 0)
+ return 0 ;
+
+ return (sf_count_t) data.st_size ;
+} /* file_length_fd */
+
+
+[+ ESAC +]
-+]
Modified: freeswitch/trunk/libs/libsndfile/tests/virtual_io_test.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/tests/virtual_io_test.c (original)
+++ freeswitch/trunk/libs/libsndfile/tests/virtual_io_test.c Thu May 21 16:09:30 2009
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 1999-2005 Erik de Castro Lopo <erikd at mega-nerd.com>
+** Copyright (C) 1999-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
@@ -229,10 +229,3 @@
puts ("ok") ;
} /* vio_test */
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: 5569fa52-15dd-496f-ab47-1fd42d76195d
-*/
Added: freeswitch/trunk/libs/libsndfile/tests/vorbis_test.c
==============================================================================
--- (empty file)
+++ freeswitch/trunk/libs/libsndfile/tests/vorbis_test.c Thu May 21 16:09:30 2009
@@ -0,0 +1,176 @@
+/*
+** Copyright (C) 2007-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
+**
+** This program is free software; you can redistribute it and/or modify
+** it under the terms of the GNU General Public License as published by
+** the Free Software Foundation; either version 2 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#include "sfconfig.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include <math.h>
+
+#include <sndfile.h>
+
+#include "utils.h"
+#include "dft_cmp.h"
+
+#define SAMPLE_RATE 16000
+#define DATA_LENGTH (SAMPLE_RATE / 8)
+
+static float data_out [DATA_LENGTH] ;
+
+static inline float
+max_float (float a, float b)
+{ return a > b ? a : b ;
+} /* max_float */
+
+static void
+vorbis_test (void)
+{ static float float_data [DFT_DATA_LENGTH] ;
+ const char * filename = "vorbis_test.oga" ;
+ SNDFILE * file ;
+ SF_INFO sfinfo ;
+ float max_abs = 0.0 ;
+ unsigned k ;
+
+ print_test_name ("vorbis_test", filename) ;
+
+ /* Generate float data. */
+ gen_windowed_sine_float (float_data, ARRAY_LEN (float_data), 1.0) ;
+
+ /* Set up output file type. */
+ memset (&sfinfo, 0, sizeof (sfinfo)) ;
+ sfinfo.format = SF_FORMAT_OGG | SF_FORMAT_VORBIS ;
+ sfinfo.channels = 1 ;
+ sfinfo.samplerate = SAMPLE_RATE ;
+
+ /* Write the output file. */
+
+ /* The Vorbis encoder has a bug on PowerPC and X86-64 with sample rates
+ ** <= 22050. Increasing the sample rate to 32000 avoids triggering it.
+ ** See https://trac.xiph.org/ticket/1229
+ */
+ if ((file = sf_open (filename, SFM_WRITE, &sfinfo)) == NULL)
+ { const char * errstr ;
+
+ errstr = sf_strerror (NULL) ;
+ if (strstr (errstr, "Sample rate chosen is known to trigger a Vorbis") == NULL)
+ { printf ("Line %d: sf_open (SFM_WRITE) failed : %s\n", __LINE__, errstr) ;
+ dump_log_buffer (NULL) ;
+ exit (1) ;
+ } ;
+
+ printf ("\n Sample rate -> 32kHz ") ;
+ sfinfo.samplerate = 32000 ;
+
+ file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ;
+ } ;
+
+ test_write_float_or_die (file, 0, float_data, ARRAY_LEN (float_data), __LINE__) ;
+ sf_close (file) ;
+
+ memset (float_data, 0, sizeof (float_data)) ;
+
+ /* Read the file back in again. */
+ memset (&sfinfo, 0, sizeof (sfinfo)) ;
+ file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_FALSE, __LINE__) ;
+ test_read_float_or_die (file, 0, float_data, ARRAY_LEN (float_data), __LINE__) ;
+ sf_close (file) ;
+
+ for (k = 0 ; k < ARRAY_LEN (float_data) ; k ++)
+ max_abs = max_float (max_abs, fabs (float_data [k])) ;
+
+ if (max_abs > 1.02)
+ { printf ("\n\n Error : max_abs %f should be < 1.02.\n\n", max_abs) ;
+ exit (1) ;
+ } ;
+
+ puts ("ok") ;
+ unlink (filename) ;
+} /* vorbis_test */
+
+static void
+vorbis_quality_test (void)
+{ /*
+ ** Encode two files, one at quality 0.3 and one at quality 0.5 and then
+ ** make sure that the quality 0.3 files is the smaller of the two.
+ */
+ const char * q3_fname = "q3_vorbis.oga" ;
+ const char * q5_fname = "q5_vorbis.oga" ;
+
+ SNDFILE *q3_file, *q5_file ;
+ SF_INFO sfinfo ;
+ int q3_size, q5_size ;
+ double quality ;
+ int k ;
+
+ print_test_name (__func__, "q[35]_vorbis.oga") ;
+
+ memset (&sfinfo, 0, sizeof (sfinfo)) ;
+
+ /* Set up output file type. */
+ sfinfo.format = SF_FORMAT_OGG | SF_FORMAT_VORBIS ;
+ sfinfo.channels = 1 ;
+ sfinfo.samplerate = SAMPLE_RATE ;
+
+ /* Write the output file. */
+ q3_file = test_open_file_or_die (q3_fname, SFM_WRITE, &sfinfo, SF_FALSE, __LINE__) ;
+ q5_file = test_open_file_or_die (q5_fname, SFM_WRITE, &sfinfo, SF_FALSE, __LINE__) ;
+
+ quality = 0.3 ;
+ sf_command (q3_file, SFC_SET_VBR_ENCODING_QUALITY, &quality, sizeof (quality)) ;
+ quality = 0.5 ;
+ sf_command (q5_file, SFC_SET_VBR_ENCODING_QUALITY, &quality, sizeof (quality)) ;
+
+ for (k = 0 ; k < 5 ; k++)
+ { gen_lowpass_noise_float (data_out, ARRAY_LEN (data_out)) ;
+ test_write_float_or_die (q3_file, 0, data_out, ARRAY_LEN (data_out), __LINE__) ;
+ test_write_float_or_die (q5_file, 0, data_out, ARRAY_LEN (data_out), __LINE__) ;
+ } ;
+
+ sf_close (q3_file) ;
+ sf_close (q5_file) ;
+
+ q3_size = file_length (q3_fname) ;
+ q5_size = file_length (q5_fname) ;
+
+ if (q3_size >= q5_size)
+ { printf ("\n\nLine %d : q3 size (%d) >= q5 size (%d)\n\n", __LINE__, q3_size, q5_size) ;
+ exit (1) ;
+ } ;
+
+ puts ("ok") ;
+ unlink (q3_fname) ;
+ unlink (q5_fname) ;
+} /* vorbis_quality_test */
+
+
+
+int
+main (void)
+{
+ if (HAVE_EXTERNAL_LIBS)
+ { vorbis_test () ;
+ vorbis_quality_test () ;
+ }
+ else
+ puts (" No Ogg/Vorbis tests because Ogg/Vorbis support was not compiled in.") ;
+
+ return 0 ;
+} /* main */
Modified: freeswitch/trunk/libs/libsndfile/tests/win32_ordinal_test.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/tests/win32_ordinal_test.c (original)
+++ freeswitch/trunk/libs/libsndfile/tests/win32_ordinal_test.c Thu May 21 16:09:30 2009
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 2006 Erik de Castro Lopo <erikd at mega-nerd.com>
+** Copyright (C) 2006-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
@@ -32,7 +32,6 @@
#include <string.h>
#include <fcntl.h>
-#include <errno.h>
#include <sys/types.h>
#include "utils.h"
@@ -46,11 +45,6 @@
#if TEST_WIN32
#include <windows.h>
-#ifdef __CYGWIN__
-#define DLL_NAME "cygsndfile"
-#else
-#define DLL_NAME "libsndfile"
-#endif
static const char * locations [] =
{ "../src/", "src/", "../src/.libs/", "src/.libs/",
@@ -64,7 +58,13 @@
print_test_name ("win32_ordinal_test", func_name) ;
- ord = GetProcAddress (hmod, (LPSTR) ordinal) ;
+#if SIZEOF_VOIDP == 8
+#define LPCSTR_OF_ORDINAL(x) ((LPCSTR) ((int64_t) (x)))
+#else
+#define LPCSTR_OF_ORDINAL(x) ((LPCSTR) (x))
+#endif
+
+ ord = GetProcAddress (hmod, LPCSTR_OF_ORDINAL (ordinal)) ;
if ((name = GetProcAddress (hmod, func_name)) == NULL)
{ FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError (),
MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) &lpmsg, 0, NULL) ;
@@ -89,7 +89,7 @@
int k, ordinal, errors = 0 ;
for (k = 0 ; locations [k] != NULL ; k++)
- { snprintf (buffer, sizeof (buffer), "%s/%s.def", locations [k], DLL_NAME) ;
+ { snprintf (buffer, sizeof (buffer), "%s/libsndfile-1.def", locations [k]) ;
if ((file = fopen (buffer, "r")) != NULL)
break ;
} ;
@@ -100,7 +100,7 @@
} ;
for (k = 0 ; locations [k] != NULL ; k++)
- { snprintf (buffer, sizeof (buffer), "%s/%s-1.dll", locations [k], DLL_NAME) ;
+ { snprintf (buffer, sizeof (buffer), "%s/libsndfile-1.dll", locations [k]) ;
if ((hmod = (HMODULE) LoadLibrary (buffer)) != NULL)
break ;
} ;
@@ -137,18 +137,10 @@
int
main (void)
{
-#if TEST_WIN32
+#if (TEST_WIN32 && WIN32_TARGET_DLL)
win32_ordinal_test () ;
#endif
return 0 ;
} /* main */
-
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: 708f6815-e787-4143-bb99-f32c1bb5564e
-*/
Modified: freeswitch/trunk/libs/libsndfile/tests/win32_test.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/tests/win32_test.c (original)
+++ freeswitch/trunk/libs/libsndfile/tests/win32_test.c Thu May 21 16:09:30 2009
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 2001-2004 Erik de Castro Lopo <erikd at mega-nerd.com>
+** Copyright (C) 2001-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
@@ -48,7 +48,6 @@
static char dir_cmd [] = "ls -l" ;
- #define COMPILE_FULL_TEST 1
#elif (defined (WIN32) || defined (_WIN32))
#define LSEEK _lseeki64
@@ -59,8 +58,7 @@
static char dir_cmd [] = "dir" ;
- #define COMPILE_FULL_TEST 1
-#elif defined (linux)
+#else
#define LSEEK lseek
#define FSTAT fstat
@@ -71,25 +69,25 @@
#define O_BINARY 0
static char dir_cmd [] = "ls -l" ;
- #define COMPILE_FULL_TEST 1
-#else
- #define COMPILE_FULL_TEST 0
#endif
-#if COMPILE_FULL_TEST
static void show_fstat_error (void) ;
static void show_lseek_error (void) ;
+static void show_stat_fstat_error (void) ;
int
main (void)
-{ puts ("\n\n\n\n"
- "This program shows up some errors in the Win32 implementation of\n"
- "a couple of POSIX API functions. It can also be compiled on Linux\n"
- "(which works correctly) just to provide a sanity check.\n"
+{
+ puts ("\n\n\n\n"
+ "This program shows up errors in the Win32 implementation of\n"
+ "a couple of POSIX API functions on some versions of windoze.\n"
+ "It can also be compiled on Linux (which works correctly) and\n"
+ "other OSes just to provide a sanity check.\n"
) ;
show_fstat_error () ;
show_lseek_error () ;
+ show_stat_fstat_error () ;
puts ("\n\n") ;
@@ -102,7 +100,7 @@
static char data [256] ;
STATBUF statbuf ;
- int fd, mode, flags ;
+ int fd, mode, flags, ignored ;
if (sizeof (statbuf.st_size) != sizeof (INT64))
{ printf ("\n\nLine %d: Error, sizeof (statbuf.st_size) != 8.\n\n", __LINE__) ;
@@ -118,7 +116,7 @@
{ printf ("\n\nLine %d: open() failed : %s\n\n", __LINE__, strerror (errno)) ;
return ;
} ;
- write (fd, data, sizeof (data)) ;
+ ignored = write (fd, data, sizeof (data)) ;
close (fd) ;
printf ("1) Re-open file in read/write mode and write another %d bytes at the end.\n", SIGNED_SIZEOF (data)) ;
@@ -129,11 +127,17 @@
return ;
} ;
LSEEK (fd, 0, SEEK_END) ;
- write (fd, data, sizeof (data)) ;
+ ignored = write (fd, data, sizeof (data)) ;
printf ("2) Now use system (\"%s %s\") to show the file length.\n\n", dir_cmd, filename) ;
- sprintf (data, "%s %s", dir_cmd, filename) ;
- system (data) ;
+
+ /* Would use snprintf, but thats not really available on windows. */
+ memset (data, 0, sizeof (data)) ;
+ strncpy (data, dir_cmd, sizeof (data) - 1) ;
+ strncat (data, " ", sizeof (data) - 1 - strlen (data)) ;
+ strncat (data, filename, sizeof (data) - 1 - strlen (data)) ;
+
+ ignored = system (data) ;
puts ("") ;
printf ("3) Now use fstat() to get the file length.\n") ;
@@ -161,7 +165,7 @@
static char data [256] ;
INT64 retval ;
- int fd, mode, flags ;
+ int fd, mode, flags, ignored ;
puts ("\n64 bit lseek() test.\n--------------------") ;
@@ -172,7 +176,7 @@
{ printf ("\n\nLine %d: open() failed : %s\n\n", __LINE__, strerror (errno)) ;
return ;
} ;
- write (fd, data, sizeof (data)) ;
+ ignored = write (fd, data, sizeof (data)) ;
close (fd) ;
printf ("1) Re-open file in read/write mode and write another %d bytes at the end.\n", SIGNED_SIZEOF (data)) ;
@@ -184,11 +188,17 @@
} ;
LSEEK (fd, 0, SEEK_END) ;
- write (fd, data, sizeof (data)) ;
+ ignored = write (fd, data, sizeof (data)) ;
printf ("2) Now use system (\"%s %s\") to show the file length.\n\n", dir_cmd, filename) ;
- sprintf (data, "%s %s", dir_cmd, filename) ;
- system (data) ;
+
+ /* Would use snprintf, but thats not really available on windows. */
+ memset (data, 0, sizeof (data)) ;
+ strncpy (data, dir_cmd, sizeof (data) - 1) ;
+ strncat (data, " ", sizeof (data) - 1 - strlen (data)) ;
+ strncat (data, filename, sizeof (data) - 1 - strlen (data)) ;
+
+ ignored = system (data) ;
puts ("") ;
printf ("3) Now use lseek() to go to the end of the file.\n") ;
@@ -207,29 +217,57 @@
} /* show_lseek_error */
-#else
+static void
+show_stat_fstat_error (void)
+{ static const char *filename = "stat_fstat.dat" ;
+ static char data [256] ;
-int
-main (void)
-{ puts ("\n"
- "This program shows up some errors in the Win32 implementation of\n"
- "a couple of POSIX API functions. It can also be compiled on Linux\n"
- "and under Cygwin32 (which both work correctly) just to provide a \n"
- "sanity check.\n"
- "Unfortunately, it does not compile on this platform."
- ) ;
+ int fd, mode, flags ;
+ int stat_size, fstat_size, ignored ;
+ struct stat buf ;
- return 0 ;
-} /* main */
+ /* Known to fail on WinXP. */
+ puts ("\nstat/fstat test.\n----------------") ;
-#endif
+ printf ("0) Create a file and write %d bytes.\n", SIGNED_SIZEOF (data)) ;
+
+ mode = O_WRONLY | O_CREAT | O_TRUNC | O_BINARY ;
+ flags = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH ;
+ if ((fd = open (filename, mode, flags)) < 0)
+ { printf ("\n\nLine %d: open() failed : %s\n\n", __LINE__, strerror (errno)) ;
+ return ;
+ } ;
+ ignored = write (fd, data, sizeof (data)) ;
+
+ printf ("1) Now call stat and fstat on the file and retreive the file lengths.\n") ;
+
+ if (stat (filename, &buf) != 0)
+ { printf ("\n\nLine %d: stat() failed : %s\n\n", __LINE__, strerror (errno)) ;
+ goto error_exit ;
+ } ;
+ stat_size = buf.st_size ;
+
+ if (fstat (fd, &buf) != 0)
+ { printf ("\n\nLine %d: fstat() failed : %s\n\n", __LINE__, strerror (errno)) ;
+ goto error_exit ;
+ } ;
+ fstat_size = buf.st_size ;
+
+ printf ("3) Size returned by stat and fstat is %d and %d, ", stat_size, fstat_size) ;
+
+
+ if (stat_size == 0 || stat_size != fstat_size)
+ printf ("but thats just plain ***WRONG***.\n\n") ;
+ else
+ printf ("which is correct.\n\n") ;
+
+error_exit :
+
+ close (fd) ;
+ unlink (filename) ;
+
+ return ;
+} /* show_stat_fstat_error */
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: 228b9a18-0555-46d9-b9e6-2b37ce048702
-*/
Modified: freeswitch/trunk/libs/libsndfile/tests/write_read_test.c
==============================================================================
--- freeswitch/trunk/libs/libsndfile/tests/write_read_test.c (original)
+++ freeswitch/trunk/libs/libsndfile/tests/write_read_test.c Thu May 21 16:09:30 2009
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 1999-2005 Erik de Castro Lopo <erikd at mega-nerd.com>
+** Copyright (C) 1999-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
@@ -36,6 +36,7 @@
#include <sndfile.h>
#include "utils.h"
+#include "generate.h"
#define SAMPLE_RATE 11025
#define DATA_LENGTH (1<<12)
@@ -85,6 +86,8 @@
printf (" voc - Create Voice file functions\n") ;
printf (" w64 - Sonic Foundry's W64 file functions\n") ;
printf (" flac - test FLAC file functions\n") ;
+ printf (" mpc2k - test MPC 2000 file functions\n") ;
+ printf (" rf64 - test RF64 file functions\n") ;
printf (" all - perform all tests\n") ;
exit (1) ;
} ;
@@ -313,6 +316,11 @@
test_count++ ;
} ;
+ if (do_all || ! strcmp (argv [1], "mpc2k"))
+ { pcm_test_short ("short.mpc", SF_FORMAT_MPC2K | SF_FORMAT_PCM_16, SF_FALSE) ;
+ test_count++ ;
+ } ;
+
if (do_all || ! strcmp (argv [1], "avr"))
{ pcm_test_char ("char_u8.avr" , SF_FORMAT_AVR | SF_FORMAT_PCM_U8, SF_FALSE) ;
pcm_test_char ("char_s8.avr" , SF_FORMAT_AVR | SF_FORMAT_PCM_S8, SF_FALSE) ;
@@ -342,6 +350,10 @@
{ pcm_test_char ("char.sds" , SF_FORMAT_SDS | SF_FORMAT_PCM_S8, SF_TRUE) ;
pcm_test_short ("short.sds" , SF_FORMAT_SDS | SF_FORMAT_PCM_16, SF_TRUE) ;
pcm_test_24bit ("24bit.sds" , SF_FORMAT_SDS | SF_FORMAT_PCM_24, SF_TRUE) ;
+
+ empty_file_test ("empty_char.sds", SF_FORMAT_SDS | SF_FORMAT_PCM_S8) ;
+ empty_file_test ("empty_short.sds", SF_FORMAT_SDS | SF_FORMAT_PCM_16) ;
+
test_count++ ;
} ;
@@ -353,14 +365,30 @@
} ;
if (do_all || ! strcmp (argv [1], "flac"))
- {
-#ifdef HAVE_FLAC_ALL_H
- pcm_test_char ("char.flac" , SF_FORMAT_FLAC | SF_FORMAT_PCM_S8, SF_TRUE) ;
- pcm_test_short ("short.flac" , SF_FORMAT_FLAC | SF_FORMAT_PCM_16, SF_TRUE) ;
- pcm_test_24bit ("24bit.flac" , SF_FORMAT_FLAC | SF_FORMAT_PCM_24, SF_TRUE) ;
-#else
- printf (" **** flac not supported in this binary. ****\n") ;
-#endif
+ { if (HAVE_EXTERNAL_LIBS)
+ { pcm_test_char ("char.flac" , SF_FORMAT_FLAC | SF_FORMAT_PCM_S8, SF_TRUE) ;
+ pcm_test_short ("short.flac" , SF_FORMAT_FLAC | SF_FORMAT_PCM_16, SF_TRUE) ;
+ pcm_test_24bit ("24bit.flac" , SF_FORMAT_FLAC | SF_FORMAT_PCM_24, SF_TRUE) ;
+ }
+ else
+ puts (" No FLAC tests because FLAC support was not compiled in.") ;
+ test_count++ ;
+ } ;
+
+ if (do_all || ! strcmp (argv [1], "rf64"))
+ { pcm_test_char ("char.rf64" , SF_FORMAT_RF64 | SF_FORMAT_PCM_U8, SF_FALSE) ;
+ pcm_test_short ("short.rf64" , SF_FORMAT_RF64 | SF_FORMAT_PCM_16, SF_FALSE) ;
+ pcm_test_24bit ("24bit.rf64" , SF_FORMAT_RF64 | SF_FORMAT_PCM_24, SF_FALSE) ;
+ pcm_test_int ("int.rf64" , SF_FORMAT_RF64 | SF_FORMAT_PCM_32, SF_FALSE) ;
+
+ /* Lite remove start */
+ pcm_test_float ("float.rf64" , SF_FORMAT_RF64 | SF_FORMAT_FLOAT , SF_FALSE) ;
+ pcm_test_double ("double.rf64" , SF_FORMAT_RF64 | SF_FORMAT_DOUBLE, SF_FALSE) ;
+ empty_file_test ("empty_char.rf64", SF_FORMAT_RF64 | SF_FORMAT_PCM_U8) ;
+ empty_file_test ("empty_short.rf64", SF_FORMAT_RF64 | SF_FORMAT_PCM_16) ;
+ empty_file_test ("empty_float.rf64", SF_FORMAT_RF64 | SF_FORMAT_FLOAT) ;
+ /* Lite remove end */
+
test_count++ ;
} ;
@@ -401,6 +429,8 @@
static void stereo_char_test (const char *filename, int format, int long_file_ok, int allow_fd) ;
static void mono_rdwr_char_test (const char *filename, int format, int long_file_ok, int allow_fd) ;
static void new_rdwr_char_test (const char *filename, int format, int allow_fd) ;
+static void multi_seek_test (const char * filename, int format) ;
+static void write_seek_extend_test (const char * filename, int format) ;
static void
pcm_test_char (const char *filename, int format, int long_file_ok)
@@ -531,6 +561,7 @@
for (k = 0 ; k < items ; k++)
if (CHAR_ERROR (orig [k], test [k]))
{ printf ("\n\nLine %d: Mono : Incorrect sample A (#%d : 0x%X => 0x%X).\n", __LINE__, k, orig [k], test [k]) ;
+ oct_save_short (orig, test, items) ;
exit (1) ;
} ;
@@ -606,6 +637,9 @@
sf_close (file) ;
+ multi_seek_test (filename, format) ;
+ write_seek_extend_test (filename, format) ;
+
} /* mono_char_test */
static void
@@ -807,7 +841,7 @@
/* Check the data. */
for (k = 0 ; k < DATA_LENGTH ; k++)
if (CHAR_ERROR (orig [k], test [k]))
- { printf ("\n\nLine %d (pass %d): Error at sample %d (0x%X => 0x%X).\n", __LINE__, pass, k, orig [k], test [k]) ;
+ { printf ("\n\nLine %d (pass %d) A : Error at sample %d (0x%X => 0x%X).\n", __LINE__, pass, k, orig [k], test [k]) ;
oct_save_short (orig, test, DATA_LENGTH) ;
exit (1) ;
} ;
@@ -856,7 +890,7 @@
/* Check the data. */
for (k = 0 ; k < DATA_LENGTH ; k++)
if (CHAR_ERROR (orig [k], test [k]))
- { printf ("\n\nLine %d (pass %d): Error at sample %d (0x%X => 0x%X).\n", __LINE__, pass, k, orig [k], test [k]) ;
+ { printf ("\n\nLine %d (pass %d) B : Error at sample %d (0x%X => 0x%X).\n", __LINE__, pass, k, orig [k], test [k]) ;
oct_save_short (orig, test, DATA_LENGTH) ;
exit (1) ;
} ;
@@ -893,7 +927,7 @@
rwfile = test_open_file_or_die (filename, SFM_RDWR, &sfinfo, allow_fd, __LINE__) ;
if (sfinfo.frames != 2 * frames)
- { printf ("\n\nLine %d : incorrect number of frames in file (%ld shold be %d)\n\n", __LINE__, SF_COUNT_TO_LONG (sfinfo.frames), frames) ;
+ { printf ("\n\nLine %d : incorrect number of frames in file (%ld should be %d)\n\n", __LINE__, SF_COUNT_TO_LONG (sfinfo.frames), 2 * frames) ;
exit (1) ;
} ;
@@ -914,6 +948,8 @@
static void stereo_short_test (const char *filename, int format, int long_file_ok, int allow_fd) ;
static void mono_rdwr_short_test (const char *filename, int format, int long_file_ok, int allow_fd) ;
static void new_rdwr_short_test (const char *filename, int format, int allow_fd) ;
+static void multi_seek_test (const char * filename, int format) ;
+static void write_seek_extend_test (const char * filename, int format) ;
static void
pcm_test_short (const char *filename, int format, int long_file_ok)
@@ -1044,6 +1080,7 @@
for (k = 0 ; k < items ; k++)
if (INT_ERROR (orig [k], test [k]))
{ printf ("\n\nLine %d: Mono : Incorrect sample A (#%d : 0x%X => 0x%X).\n", __LINE__, k, orig [k], test [k]) ;
+ oct_save_short (orig, test, items) ;
exit (1) ;
} ;
@@ -1119,6 +1156,9 @@
sf_close (file) ;
+ multi_seek_test (filename, format) ;
+ write_seek_extend_test (filename, format) ;
+
} /* mono_short_test */
static void
@@ -1320,7 +1360,7 @@
/* Check the data. */
for (k = 0 ; k < DATA_LENGTH ; k++)
if (INT_ERROR (orig [k], test [k]))
- { printf ("\n\nLine %d (pass %d): Error at sample %d (0x%X => 0x%X).\n", __LINE__, pass, k, orig [k], test [k]) ;
+ { printf ("\n\nLine %d (pass %d) A : Error at sample %d (0x%X => 0x%X).\n", __LINE__, pass, k, orig [k], test [k]) ;
oct_save_short (orig, test, DATA_LENGTH) ;
exit (1) ;
} ;
@@ -1369,7 +1409,7 @@
/* Check the data. */
for (k = 0 ; k < DATA_LENGTH ; k++)
if (INT_ERROR (orig [k], test [k]))
- { printf ("\n\nLine %d (pass %d): Error at sample %d (0x%X => 0x%X).\n", __LINE__, pass, k, orig [k], test [k]) ;
+ { printf ("\n\nLine %d (pass %d) B : Error at sample %d (0x%X => 0x%X).\n", __LINE__, pass, k, orig [k], test [k]) ;
oct_save_short (orig, test, DATA_LENGTH) ;
exit (1) ;
} ;
@@ -1406,7 +1446,7 @@
rwfile = test_open_file_or_die (filename, SFM_RDWR, &sfinfo, allow_fd, __LINE__) ;
if (sfinfo.frames != 2 * frames)
- { printf ("\n\nLine %d : incorrect number of frames in file (%ld shold be %d)\n\n", __LINE__, SF_COUNT_TO_LONG (sfinfo.frames), frames) ;
+ { printf ("\n\nLine %d : incorrect number of frames in file (%ld should be %d)\n\n", __LINE__, SF_COUNT_TO_LONG (sfinfo.frames), 2 * frames) ;
exit (1) ;
} ;
@@ -1427,6 +1467,8 @@
static void stereo_24bit_test (const char *filename, int format, int long_file_ok, int allow_fd) ;
static void mono_rdwr_24bit_test (const char *filename, int format, int long_file_ok, int allow_fd) ;
static void new_rdwr_24bit_test (const char *filename, int format, int allow_fd) ;
+static void multi_seek_test (const char * filename, int format) ;
+static void write_seek_extend_test (const char * filename, int format) ;
static void
pcm_test_24bit (const char *filename, int format, int long_file_ok)
@@ -1557,6 +1599,7 @@
for (k = 0 ; k < items ; k++)
if (TRIBYTE_ERROR (orig [k], test [k]))
{ printf ("\n\nLine %d: Mono : Incorrect sample A (#%d : 0x%X => 0x%X).\n", __LINE__, k, orig [k], test [k]) ;
+ oct_save_int (orig, test, items) ;
exit (1) ;
} ;
@@ -1632,6 +1675,9 @@
sf_close (file) ;
+ multi_seek_test (filename, format) ;
+ write_seek_extend_test (filename, format) ;
+
} /* mono_24bit_test */
static void
@@ -1833,7 +1879,7 @@
/* Check the data. */
for (k = 0 ; k < DATA_LENGTH ; k++)
if (TRIBYTE_ERROR (orig [k], test [k]))
- { printf ("\n\nLine %d (pass %d): Error at sample %d (0x%X => 0x%X).\n", __LINE__, pass, k, orig [k], test [k]) ;
+ { printf ("\n\nLine %d (pass %d) A : Error at sample %d (0x%X => 0x%X).\n", __LINE__, pass, k, orig [k], test [k]) ;
oct_save_int (orig, test, DATA_LENGTH) ;
exit (1) ;
} ;
@@ -1882,7 +1928,7 @@
/* Check the data. */
for (k = 0 ; k < DATA_LENGTH ; k++)
if (TRIBYTE_ERROR (orig [k], test [k]))
- { printf ("\n\nLine %d (pass %d): Error at sample %d (0x%X => 0x%X).\n", __LINE__, pass, k, orig [k], test [k]) ;
+ { printf ("\n\nLine %d (pass %d) B : Error at sample %d (0x%X => 0x%X).\n", __LINE__, pass, k, orig [k], test [k]) ;
oct_save_int (orig, test, DATA_LENGTH) ;
exit (1) ;
} ;
@@ -1919,7 +1965,7 @@
rwfile = test_open_file_or_die (filename, SFM_RDWR, &sfinfo, allow_fd, __LINE__) ;
if (sfinfo.frames != 2 * frames)
- { printf ("\n\nLine %d : incorrect number of frames in file (%ld shold be %d)\n\n", __LINE__, SF_COUNT_TO_LONG (sfinfo.frames), frames) ;
+ { printf ("\n\nLine %d : incorrect number of frames in file (%ld should be %d)\n\n", __LINE__, SF_COUNT_TO_LONG (sfinfo.frames), 2 * frames) ;
exit (1) ;
} ;
@@ -1940,6 +1986,8 @@
static void stereo_int_test (const char *filename, int format, int long_file_ok, int allow_fd) ;
static void mono_rdwr_int_test (const char *filename, int format, int long_file_ok, int allow_fd) ;
static void new_rdwr_int_test (const char *filename, int format, int allow_fd) ;
+static void multi_seek_test (const char * filename, int format) ;
+static void write_seek_extend_test (const char * filename, int format) ;
static void
pcm_test_int (const char *filename, int format, int long_file_ok)
@@ -2070,6 +2118,7 @@
for (k = 0 ; k < items ; k++)
if (INT_ERROR (orig [k], test [k]))
{ printf ("\n\nLine %d: Mono : Incorrect sample A (#%d : 0x%X => 0x%X).\n", __LINE__, k, orig [k], test [k]) ;
+ oct_save_int (orig, test, items) ;
exit (1) ;
} ;
@@ -2145,6 +2194,9 @@
sf_close (file) ;
+ multi_seek_test (filename, format) ;
+ write_seek_extend_test (filename, format) ;
+
} /* mono_int_test */
static void
@@ -2346,7 +2398,7 @@
/* Check the data. */
for (k = 0 ; k < DATA_LENGTH ; k++)
if (INT_ERROR (orig [k], test [k]))
- { printf ("\n\nLine %d (pass %d): Error at sample %d (0x%X => 0x%X).\n", __LINE__, pass, k, orig [k], test [k]) ;
+ { printf ("\n\nLine %d (pass %d) A : Error at sample %d (0x%X => 0x%X).\n", __LINE__, pass, k, orig [k], test [k]) ;
oct_save_int (orig, test, DATA_LENGTH) ;
exit (1) ;
} ;
@@ -2395,7 +2447,7 @@
/* Check the data. */
for (k = 0 ; k < DATA_LENGTH ; k++)
if (INT_ERROR (orig [k], test [k]))
- { printf ("\n\nLine %d (pass %d): Error at sample %d (0x%X => 0x%X).\n", __LINE__, pass, k, orig [k], test [k]) ;
+ { printf ("\n\nLine %d (pass %d) B : Error at sample %d (0x%X => 0x%X).\n", __LINE__, pass, k, orig [k], test [k]) ;
oct_save_int (orig, test, DATA_LENGTH) ;
exit (1) ;
} ;
@@ -2432,7 +2484,7 @@
rwfile = test_open_file_or_die (filename, SFM_RDWR, &sfinfo, allow_fd, __LINE__) ;
if (sfinfo.frames != 2 * frames)
- { printf ("\n\nLine %d : incorrect number of frames in file (%ld shold be %d)\n\n", __LINE__, SF_COUNT_TO_LONG (sfinfo.frames), frames) ;
+ { printf ("\n\nLine %d : incorrect number of frames in file (%ld should be %d)\n\n", __LINE__, SF_COUNT_TO_LONG (sfinfo.frames), 2 * frames) ;
exit (1) ;
} ;
@@ -2453,6 +2505,8 @@
static void stereo_float_test (const char *filename, int format, int long_file_ok, int allow_fd) ;
static void mono_rdwr_float_test (const char *filename, int format, int long_file_ok, int allow_fd) ;
static void new_rdwr_float_test (const char *filename, int format, int allow_fd) ;
+static void multi_seek_test (const char * filename, int format) ;
+static void write_seek_extend_test (const char * filename, int format) ;
static void
pcm_test_float (const char *filename, int format, int long_file_ok)
@@ -2583,6 +2637,7 @@
for (k = 0 ; k < items ; k++)
if (FLOAT_ERROR (orig [k], test [k]))
{ printf ("\n\nLine %d: Mono : Incorrect sample A (#%d : %g => %g).\n", __LINE__, k, orig [k], test [k]) ;
+ oct_save_float (orig, test, items) ;
exit (1) ;
} ;
@@ -2658,6 +2713,9 @@
sf_close (file) ;
+ multi_seek_test (filename, format) ;
+ write_seek_extend_test (filename, format) ;
+
} /* mono_float_test */
static void
@@ -2859,7 +2917,7 @@
/* Check the data. */
for (k = 0 ; k < DATA_LENGTH ; k++)
if (FLOAT_ERROR (orig [k], test [k]))
- { printf ("\n\nLine %d (pass %d): Error at sample %d (%g => %g).\n", __LINE__, pass, k, orig [k], test [k]) ;
+ { printf ("\n\nLine %d (pass %d) A : Error at sample %d (%g => %g).\n", __LINE__, pass, k, orig [k], test [k]) ;
oct_save_float (orig, test, DATA_LENGTH) ;
exit (1) ;
} ;
@@ -2908,7 +2966,7 @@
/* Check the data. */
for (k = 0 ; k < DATA_LENGTH ; k++)
if (FLOAT_ERROR (orig [k], test [k]))
- { printf ("\n\nLine %d (pass %d): Error at sample %d (%g => %g).\n", __LINE__, pass, k, orig [k], test [k]) ;
+ { printf ("\n\nLine %d (pass %d) B : Error at sample %d (%g => %g).\n", __LINE__, pass, k, orig [k], test [k]) ;
oct_save_float (orig, test, DATA_LENGTH) ;
exit (1) ;
} ;
@@ -2945,7 +3003,7 @@
rwfile = test_open_file_or_die (filename, SFM_RDWR, &sfinfo, allow_fd, __LINE__) ;
if (sfinfo.frames != 2 * frames)
- { printf ("\n\nLine %d : incorrect number of frames in file (%ld shold be %d)\n\n", __LINE__, SF_COUNT_TO_LONG (sfinfo.frames), frames) ;
+ { printf ("\n\nLine %d : incorrect number of frames in file (%ld should be %d)\n\n", __LINE__, SF_COUNT_TO_LONG (sfinfo.frames), 2 * frames) ;
exit (1) ;
} ;
@@ -2966,6 +3024,8 @@
static void stereo_double_test (const char *filename, int format, int long_file_ok, int allow_fd) ;
static void mono_rdwr_double_test (const char *filename, int format, int long_file_ok, int allow_fd) ;
static void new_rdwr_double_test (const char *filename, int format, int allow_fd) ;
+static void multi_seek_test (const char * filename, int format) ;
+static void write_seek_extend_test (const char * filename, int format) ;
static void
pcm_test_double (const char *filename, int format, int long_file_ok)
@@ -3096,6 +3156,7 @@
for (k = 0 ; k < items ; k++)
if (FLOAT_ERROR (orig [k], test [k]))
{ printf ("\n\nLine %d: Mono : Incorrect sample A (#%d : %g => %g).\n", __LINE__, k, orig [k], test [k]) ;
+ oct_save_double (orig, test, items) ;
exit (1) ;
} ;
@@ -3171,6 +3232,9 @@
sf_close (file) ;
+ multi_seek_test (filename, format) ;
+ write_seek_extend_test (filename, format) ;
+
} /* mono_double_test */
static void
@@ -3372,7 +3436,7 @@
/* Check the data. */
for (k = 0 ; k < DATA_LENGTH ; k++)
if (FLOAT_ERROR (orig [k], test [k]))
- { printf ("\n\nLine %d (pass %d): Error at sample %d (%g => %g).\n", __LINE__, pass, k, orig [k], test [k]) ;
+ { printf ("\n\nLine %d (pass %d) A : Error at sample %d (%g => %g).\n", __LINE__, pass, k, orig [k], test [k]) ;
oct_save_double (orig, test, DATA_LENGTH) ;
exit (1) ;
} ;
@@ -3421,7 +3485,7 @@
/* Check the data. */
for (k = 0 ; k < DATA_LENGTH ; k++)
if (FLOAT_ERROR (orig [k], test [k]))
- { printf ("\n\nLine %d (pass %d): Error at sample %d (%g => %g).\n", __LINE__, pass, k, orig [k], test [k]) ;
+ { printf ("\n\nLine %d (pass %d) B : Error at sample %d (%g => %g).\n", __LINE__, pass, k, orig [k], test [k]) ;
oct_save_double (orig, test, DATA_LENGTH) ;
exit (1) ;
} ;
@@ -3458,7 +3522,7 @@
rwfile = test_open_file_or_die (filename, SFM_RDWR, &sfinfo, allow_fd, __LINE__) ;
if (sfinfo.frames != 2 * frames)
- { printf ("\n\nLine %d : incorrect number of frames in file (%ld shold be %d)\n\n", __LINE__, SF_COUNT_TO_LONG (sfinfo.frames), frames) ;
+ { printf ("\n\nLine %d : incorrect number of frames in file (%ld should be %d)\n\n", __LINE__, SF_COUNT_TO_LONG (sfinfo.frames), 2 * frames) ;
exit (1) ;
} ;
@@ -3586,4 +3650,100 @@
#endif
+static void
+multi_seek_test (const char * filename, int format)
+{ SNDFILE * file ;
+ SF_INFO info ;
+ sf_count_t pos ;
+ int k ;
+
+ /* This test doesn't work on the following. */
+ switch (format & SF_FORMAT_TYPEMASK)
+ { case SF_FORMAT_RAW :
+ return ;
+
+ default :
+ break ;
+ } ;
+
+ memset (&info, 0, sizeof (info)) ;
+
+ generate_file (filename, format, 88200) ;
+
+ file = test_open_file_or_die (filename, SFM_READ, &info, SF_FALSE, __LINE__) ;
+
+ for (k = 0 ; k < 10 ; k++)
+ { pos = info.frames / (k + 2) ;
+ test_seek_or_die (file, pos, SEEK_SET, pos, info.channels, __LINE__) ;
+ } ;
+
+ sf_close (file) ;
+} /* multi_seek_test */
+
+static void
+write_seek_extend_test (const char * filename, int format)
+{ SNDFILE * file ;
+ SF_INFO info ;
+ short *orig, *test ;
+ unsigned items, k ;
+
+ /* This test doesn't work on the following. */
+ switch (format & SF_FORMAT_TYPEMASK)
+ { case SF_FORMAT_FLAC :
+ case SF_FORMAT_HTK :
+ case SF_FORMAT_PAF :
+ case SF_FORMAT_SDS :
+ case SF_FORMAT_SVX :
+ return ;
+
+ default :
+ break ;
+ } ;
+
+ memset (&info, 0, sizeof (info)) ;
+
+ info.samplerate = 48000 ;
+ info.channels = 1 ;
+ info.format = format ;
+
+ items = 512 ;
+ exit_if_true (items > ARRAY_LEN (orig_data.s), "Line %d : Bad assumption.\n", __LINE__) ;
+
+ orig = orig_data.s ;
+ test = test_data.s ;
+
+ for (k = 0 ; k < ARRAY_LEN (orig_data.s) ; k++)
+ orig [k] = 0x3fff ;
+
+ file = test_open_file_or_die (filename, SFM_WRITE, &info, SF_FALSE, __LINE__) ;
+ test_write_short_or_die (file, 0, orig, items, __LINE__) ;
+
+ /* Extend the file using a seek. */
+ test_seek_or_die (file, 2 * items, SEEK_SET, 2 * items, info.channels, __LINE__) ;
+
+ test_writef_short_or_die (file, 0, orig, items, __LINE__) ;
+ sf_close (file) ;
+
+ file = test_open_file_or_die (filename, SFM_READ, &info, SF_FALSE, __LINE__) ;
+ test_read_short_or_die (file, 0, test, 3 * items, __LINE__) ;
+ sf_close (file) ;
+
+ /* Can't do these formats due to scaling. */
+ switch (format & SF_FORMAT_SUBMASK)
+ { case SF_FORMAT_PCM_S8 :
+ case SF_FORMAT_PCM_U8 :
+ return ;
+ default :
+ break ;
+ } ;
+
+ for (k = 0 ; k < items ; k++)
+ { exit_if_true (test [k] != 0x3fff, "Line %d : test [%d] == %d, should be 0x3fff.\n", __LINE__, k, test [k]) ;
+ exit_if_true (test [items + k] != 0, "Line %d : test [%d] == %d, should be 0.\n", __LINE__, items + k, test [items + k]) ;
+ exit_if_true (test [2 * items + k] != 0x3fff, "Line %d : test [%d] == %d, should be 0x3fff.\n", __LINE__, 2 * items + k, test [2 * items + k]) ;
+ } ;
+
+ return ;
+} /* write_seek_extend_test */
+
Modified: freeswitch/trunk/libs/libsndfile/tests/write_read_test.def
==============================================================================
--- freeswitch/trunk/libs/libsndfile/tests/write_read_test.def (original)
+++ freeswitch/trunk/libs/libsndfile/tests/write_read_test.def Thu May 21 16:09:30 2009
@@ -63,11 +63,3 @@
} ;
/* Lite remove end */
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: 624d498a-9ea1-46b5-a386-c1c2261cfce3
-*/
-
Modified: freeswitch/trunk/libs/libsndfile/tests/write_read_test.tpl
==============================================================================
--- freeswitch/trunk/libs/libsndfile/tests/write_read_test.tpl (original)
+++ freeswitch/trunk/libs/libsndfile/tests/write_read_test.tpl Thu May 21 16:09:30 2009
@@ -1,6 +1,6 @@
[+ AutoGen5 template c +]
/*
-** Copyright (C) 1999-2005 Erik de Castro Lopo <erikd at mega-nerd.com>
+** Copyright (C) 1999-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
@@ -37,6 +37,7 @@
#include <sndfile.h>
#include "utils.h"
+#include "generate.h"
#define SAMPLE_RATE 11025
#define DATA_LENGTH (1<<12)
@@ -83,6 +84,8 @@
printf (" voc - Create Voice file functions\n") ;
printf (" w64 - Sonic Foundry's W64 file functions\n") ;
printf (" flac - test FLAC file functions\n") ;
+ printf (" mpc2k - test MPC 2000 file functions\n") ;
+ printf (" rf64 - test RF64 file functions\n") ;
printf (" all - perform all tests\n") ;
exit (1) ;
} ;
@@ -311,6 +314,11 @@
test_count++ ;
} ;
+ if (do_all || ! strcmp (argv [1], "mpc2k"))
+ { pcm_test_short ("short.mpc", SF_FORMAT_MPC2K | SF_FORMAT_PCM_16, SF_FALSE) ;
+ test_count++ ;
+ } ;
+
if (do_all || ! strcmp (argv [1], "avr"))
{ pcm_test_char ("char_u8.avr" , SF_FORMAT_AVR | SF_FORMAT_PCM_U8, SF_FALSE) ;
pcm_test_char ("char_s8.avr" , SF_FORMAT_AVR | SF_FORMAT_PCM_S8, SF_FALSE) ;
@@ -340,6 +348,10 @@
{ pcm_test_char ("char.sds" , SF_FORMAT_SDS | SF_FORMAT_PCM_S8, SF_TRUE) ;
pcm_test_short ("short.sds" , SF_FORMAT_SDS | SF_FORMAT_PCM_16, SF_TRUE) ;
pcm_test_24bit ("24bit.sds" , SF_FORMAT_SDS | SF_FORMAT_PCM_24, SF_TRUE) ;
+
+ empty_file_test ("empty_char.sds", SF_FORMAT_SDS | SF_FORMAT_PCM_S8) ;
+ empty_file_test ("empty_short.sds", SF_FORMAT_SDS | SF_FORMAT_PCM_16) ;
+
test_count++ ;
} ;
@@ -351,14 +363,30 @@
} ;
if (do_all || ! strcmp (argv [1], "flac"))
- {
-#ifdef HAVE_FLAC_ALL_H
- pcm_test_char ("char.flac" , SF_FORMAT_FLAC | SF_FORMAT_PCM_S8, SF_TRUE) ;
- pcm_test_short ("short.flac" , SF_FORMAT_FLAC | SF_FORMAT_PCM_16, SF_TRUE) ;
- pcm_test_24bit ("24bit.flac" , SF_FORMAT_FLAC | SF_FORMAT_PCM_24, SF_TRUE) ;
-#else
- printf (" **** flac not supported in this binary. ****\n") ;
-#endif
+ { if (HAVE_EXTERNAL_LIBS)
+ { pcm_test_char ("char.flac" , SF_FORMAT_FLAC | SF_FORMAT_PCM_S8, SF_TRUE) ;
+ pcm_test_short ("short.flac" , SF_FORMAT_FLAC | SF_FORMAT_PCM_16, SF_TRUE) ;
+ pcm_test_24bit ("24bit.flac" , SF_FORMAT_FLAC | SF_FORMAT_PCM_24, SF_TRUE) ;
+ }
+ else
+ puts (" No FLAC tests because FLAC support was not compiled in.") ;
+ test_count++ ;
+ } ;
+
+ if (do_all || ! strcmp (argv [1], "rf64"))
+ { pcm_test_char ("char.rf64" , SF_FORMAT_RF64 | SF_FORMAT_PCM_U8, SF_FALSE) ;
+ pcm_test_short ("short.rf64" , SF_FORMAT_RF64 | SF_FORMAT_PCM_16, SF_FALSE) ;
+ pcm_test_24bit ("24bit.rf64" , SF_FORMAT_RF64 | SF_FORMAT_PCM_24, SF_FALSE) ;
+ pcm_test_int ("int.rf64" , SF_FORMAT_RF64 | SF_FORMAT_PCM_32, SF_FALSE) ;
+
+ /* Lite remove start */
+ pcm_test_float ("float.rf64" , SF_FORMAT_RF64 | SF_FORMAT_FLOAT , SF_FALSE) ;
+ pcm_test_double ("double.rf64" , SF_FORMAT_RF64 | SF_FORMAT_DOUBLE, SF_FALSE) ;
+ empty_file_test ("empty_char.rf64", SF_FORMAT_RF64 | SF_FORMAT_PCM_U8) ;
+ empty_file_test ("empty_short.rf64", SF_FORMAT_RF64 | SF_FORMAT_PCM_16) ;
+ empty_file_test ("empty_float.rf64", SF_FORMAT_RF64 | SF_FORMAT_FLOAT) ;
+ /* Lite remove end */
+
test_count++ ;
} ;
@@ -400,6 +428,8 @@
static void stereo_[+ (get "type_name") +]_test (const char *filename, int format, int long_file_ok, int allow_fd) ;
static void mono_rdwr_[+ (get "type_name") +]_test (const char *filename, int format, int long_file_ok, int allow_fd) ;
static void new_rdwr_[+ (get "type_name") +]_test (const char *filename, int format, int allow_fd) ;
+static void multi_seek_test (const char * filename, int format) ;
+static void write_seek_extend_test (const char * filename, int format) ;
static void
pcm_test_[+ (get "type_name") +] (const char *filename, int format, int long_file_ok)
@@ -530,6 +560,7 @@
for (k = 0 ; k < items ; k++)
if ([+ (get "error_func") +] (orig [k], test [k]))
{ printf ("\n\nLine %d: Mono : Incorrect sample A (#%d : [+ (get "format_char") +] => [+ (get "format_char") +]).\n", __LINE__, k, orig [k], test [k]) ;
+ oct_save_[+ (get "data_type") +] (orig, test, items) ;
exit (1) ;
} ;
@@ -605,6 +636,9 @@
sf_close (file) ;
+ multi_seek_test (filename, format) ;
+ write_seek_extend_test (filename, format) ;
+
} /* mono_[+ (get "type_name") +]_test */
static void
@@ -806,7 +840,7 @@
/* Check the data. */
for (k = 0 ; k < DATA_LENGTH ; k++)
if ([+ (get "error_func") +] (orig [k], test [k]))
- { printf ("\n\nLine %d (pass %d): Error at sample %d ([+ (get "format_char") +] => [+ (get "format_char") +]).\n", __LINE__, pass, k, orig [k], test [k]) ;
+ { printf ("\n\nLine %d (pass %d) A : Error at sample %d ([+ (get "format_char") +] => [+ (get "format_char") +]).\n", __LINE__, pass, k, orig [k], test [k]) ;
oct_save_[+ (get "data_type") +] (orig, test, DATA_LENGTH) ;
exit (1) ;
} ;
@@ -855,7 +889,7 @@
/* Check the data. */
for (k = 0 ; k < DATA_LENGTH ; k++)
if ([+ (get "error_func") +] (orig [k], test [k]))
- { printf ("\n\nLine %d (pass %d): Error at sample %d ([+ (get "format_char") +] => [+ (get "format_char") +]).\n", __LINE__, pass, k, orig [k], test [k]) ;
+ { printf ("\n\nLine %d (pass %d) B : Error at sample %d ([+ (get "format_char") +] => [+ (get "format_char") +]).\n", __LINE__, pass, k, orig [k], test [k]) ;
oct_save_[+ (get "data_type") +] (orig, test, DATA_LENGTH) ;
exit (1) ;
} ;
@@ -892,7 +926,7 @@
rwfile = test_open_file_or_die (filename, SFM_RDWR, &sfinfo, allow_fd, __LINE__) ;
if (sfinfo.frames != 2 * frames)
- { printf ("\n\nLine %d : incorrect number of frames in file (%ld shold be %d)\n\n", __LINE__, SF_COUNT_TO_LONG (sfinfo.frames), frames) ;
+ { printf ("\n\nLine %d : incorrect number of frames in file (%ld should be %d)\n\n", __LINE__, SF_COUNT_TO_LONG (sfinfo.frames), 2 * frames) ;
exit (1) ;
} ;
@@ -1020,12 +1054,100 @@
#endif
-[+ COMMENT
+static void
+multi_seek_test (const char * filename, int format)
+{ SNDFILE * file ;
+ SF_INFO info ;
+ sf_count_t pos ;
+ int k ;
+
+ /* This test doesn't work on the following. */
+ switch (format & SF_FORMAT_TYPEMASK)
+ { case SF_FORMAT_RAW :
+ return ;
- Do not edit or modify anything in this comment block.
- The following line is a file identity tag for the GNU Arch
- revision control system.
+ default :
+ break ;
+ } ;
+
+ memset (&info, 0, sizeof (info)) ;
+
+ generate_file (filename, format, 88200) ;
+
+ file = test_open_file_or_die (filename, SFM_READ, &info, SF_FALSE, __LINE__) ;
+
+ for (k = 0 ; k < 10 ; k++)
+ { pos = info.frames / (k + 2) ;
+ test_seek_or_die (file, pos, SEEK_SET, pos, info.channels, __LINE__) ;
+ } ;
+
+ sf_close (file) ;
+} /* multi_seek_test */
+
+static void
+write_seek_extend_test (const char * filename, int format)
+{ SNDFILE * file ;
+ SF_INFO info ;
+ short *orig, *test ;
+ unsigned items, k ;
+
+ /* This test doesn't work on the following. */
+ switch (format & SF_FORMAT_TYPEMASK)
+ { case SF_FORMAT_FLAC :
+ case SF_FORMAT_HTK :
+ case SF_FORMAT_PAF :
+ case SF_FORMAT_SDS :
+ case SF_FORMAT_SVX :
+ return ;
+
+ default :
+ break ;
+ } ;
+
+ memset (&info, 0, sizeof (info)) ;
+
+ info.samplerate = 48000 ;
+ info.channels = 1 ;
+ info.format = format ;
+
+ items = 512 ;
+ exit_if_true (items > ARRAY_LEN (orig_data.s), "Line %d : Bad assumption.\n", __LINE__) ;
+
+ orig = orig_data.s ;
+ test = test_data.s ;
+
+ for (k = 0 ; k < ARRAY_LEN (orig_data.s) ; k++)
+ orig [k] = 0x3fff ;
+
+ file = test_open_file_or_die (filename, SFM_WRITE, &info, SF_FALSE, __LINE__) ;
+ test_write_short_or_die (file, 0, orig, items, __LINE__) ;
+
+ /* Extend the file using a seek. */
+ test_seek_or_die (file, 2 * items, SEEK_SET, 2 * items, info.channels, __LINE__) ;
+
+ test_writef_short_or_die (file, 0, orig, items, __LINE__) ;
+ sf_close (file) ;
+
+ file = test_open_file_or_die (filename, SFM_READ, &info, SF_FALSE, __LINE__) ;
+ test_read_short_or_die (file, 0, test, 3 * items, __LINE__) ;
+ sf_close (file) ;
+
+ /* Can't do these formats due to scaling. */
+ switch (format & SF_FORMAT_SUBMASK)
+ { case SF_FORMAT_PCM_S8 :
+ case SF_FORMAT_PCM_U8 :
+ return ;
+ default :
+ break ;
+ } ;
+
+ for (k = 0 ; k < items ; k++)
+ { exit_if_true (test [k] != 0x3fff, "Line %d : test [%d] == %d, should be 0x3fff.\n", __LINE__, k, test [k]) ;
+ exit_if_true (test [items + k] != 0, "Line %d : test [%d] == %d, should be 0.\n", __LINE__, items + k, test [items + k]) ;
+ exit_if_true (test [2 * items + k] != 0x3fff, "Line %d : test [%d] == %d, should be 0x3fff.\n", __LINE__, 2 * items + k, test [2 * items + k]) ;
+ } ;
+
+ return ;
+} /* write_seek_extend_test */
- arch-tag: 4187de93-d434-41a2-93a9-4f6e2995b5c1
-+]
Modified: freeswitch/trunk/libs/win32/libsndfile/config.h
==============================================================================
--- freeswitch/trunk/libs/win32/libsndfile/config.h (original)
+++ freeswitch/trunk/libs/win32/libsndfile/config.h Thu May 21 16:09:30 2009
@@ -263,7 +263,7 @@
#define USE_WINDOWS_API 1
/* Version number of package */
-#define VERSION "1.0.16"
+#define VERSION "1.0.18"
/* Number of bits in a file offset, on hosts where this is settable. */
/* #undef _FILE_OFFSET_BITS */
@@ -274,11 +274,14 @@
/* Define for large files, on AIX-style hosts. */
/* #undef _LARGE_FILES */
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: 78a733c0-a430-46bd-81ab-4e479fbcffac
-*/
+#include <stddef.h>
+typedef __int32 int32_t;
+typedef intptr_t ssize_t;
+typedef unsigned __int16 uint16_t;
+typedef unsigned __int32 uint32_t;
+
+#define __func__ __FUNCTION__
+#define snprintf _snprintf
+
+#include <float_cast.h>
\ No newline at end of file
Modified: freeswitch/trunk/libs/win32/libsndfile/libsndfile.2008.vcproj
==============================================================================
--- freeswitch/trunk/libs/win32/libsndfile/libsndfile.2008.vcproj (original)
+++ freeswitch/trunk/libs/win32/libsndfile/libsndfile.2008.vcproj Thu May 21 16:09:30 2009
@@ -295,6 +295,10 @@
>
</File>
<File
+ RelativePath="..\..\libsndfile\src\audio_detect.c"
+ >
+ </File>
+ <File
RelativePath="..\..\libsndfile\src\avr.c"
>
</File>
@@ -307,11 +311,15 @@
>
</File>
<File
+ RelativePath="..\..\libsndfile\src\chunk.c"
+ >
+ </File>
+ <File
RelativePath="..\..\libsndfile\src\command.c"
>
</File>
<File
- RelativePath=".\common.c"
+ RelativePath="..\..\libsndfile\src\common.c"
>
</File>
<File
@@ -395,6 +403,14 @@
>
</File>
<File
+ RelativePath="..\..\libsndfile\src\ima_oki_adpcm.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\libsndfile\src\ima_oki_adpcm.h"
+ >
+ </File>
+ <File
RelativePath="..\..\libsndfile\src\ircam.c"
>
</File>
@@ -407,6 +423,10 @@
>
</File>
<File
+ RelativePath="..\..\libsndfile\src\mpc2k.c"
+ >
+ </File>
+ <File
RelativePath="..\..\libsndfile\src\ms_adpcm.c"
>
</File>
@@ -435,6 +455,10 @@
>
</File>
<File
+ RelativePath="..\..\libsndfile\src\rf64.c"
+ >
+ </File>
+ <File
RelativePath="..\..\libsndfile\src\rx2.c"
>
</File>
Modified: freeswitch/trunk/libs/win32/libsndfile/libsndfile.vcproj
==============================================================================
--- freeswitch/trunk/libs/win32/libsndfile/libsndfile.vcproj (original)
+++ freeswitch/trunk/libs/win32/libsndfile/libsndfile.vcproj Thu May 21 16:09:30 2009
@@ -165,6 +165,10 @@
>
</File>
<File
+ RelativePath="..\..\libsndfile\src\audio_detect.c"
+ >
+ </File>
+ <File
RelativePath="..\..\libsndfile\src\avr.c"
>
</File>
@@ -177,11 +181,15 @@
>
</File>
<File
+ RelativePath="..\..\libsndfile\src\chunk.c"
+ >
+ </File>
+ <File
RelativePath="..\..\libsndfile\src\command.c"
>
</File>
<File
- RelativePath=".\common.c"
+ RelativePath="..\..\libsndfile\src\common.c"
>
</File>
<File
@@ -247,6 +255,14 @@
>
</File>
<File
+ RelativePath="..\..\libsndfile\src\ima_oki_adpcm.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\libsndfile\src\ima_oki_adpcm.h"
+ >
+ </File>
+ <File
RelativePath="..\..\libsndfile\src\ircam.c"
>
</File>
@@ -259,6 +275,10 @@
>
</File>
<File
+ RelativePath="..\..\libsndfile\src\mpc2k.c"
+ >
+ </File>
+ <File
RelativePath="..\..\libsndfile\src\ms_adpcm.c"
>
</File>
@@ -287,6 +307,10 @@
>
</File>
<File
+ RelativePath="..\..\libsndfile\src\rf64.c"
+ >
+ </File>
+ <File
RelativePath="..\..\libsndfile\src\rx2.c"
>
</File>
Modified: freeswitch/trunk/libs/win32/libsndfile/sndfile.h
==============================================================================
--- freeswitch/trunk/libs/win32/libsndfile/sndfile.h (original)
+++ freeswitch/trunk/libs/win32/libsndfile/sndfile.h Thu May 21 16:09:30 2009
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 1999-2006 Erik de Castro Lopo <erikd at mega-nerd.com>
+** Copyright (C) 1999-2009 Erik de Castro Lopo <erikd at mega-nerd.com>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU Lesser General Public License as published by
@@ -30,14 +30,7 @@
#define SNDFILE_1
#include <stdio.h>
-
-/* For the Metrowerks CodeWarrior Pro Compiler (mainly MacOS) */
-
-#if (defined (__MWERKS__))
-#include <unix.h>
-#else
-#include <sys/types.h>
-#endif
+#include <sys/types.h>
#ifdef __cplusplus
extern "C" {
@@ -73,6 +66,10 @@
SF_FORMAT_SD2 = 0x160000, /* Sound Designer 2 */
SF_FORMAT_FLAC = 0x170000, /* FLAC lossless file format */
SF_FORMAT_CAF = 0x180000, /* Core Audio File format */
+ SF_FORMAT_WVE = 0x190000, /* Psion WVE format */
+ SF_FORMAT_OGG = 0x200000, /* Xiph OGG container */
+ SF_FORMAT_MPC2K = 0x210000, /* Akai MPC 2000 sampler */
+ SF_FORMAT_RF64 = 0x220000, /* RF64 WAV file */
/* Subtypes from here on. */
@@ -106,6 +103,8 @@
SF_FORMAT_DPCM_8 = 0x0050, /* 8 bit differential PCM (XI only) */
SF_FORMAT_DPCM_16 = 0x0051, /* 16 bit differential PCM (XI only) */
+ SF_FORMAT_VORBIS = 0x0060, /* Xiph Vorbis encoding. */
+
/* Endian-ness options. */
SF_ENDIAN_FILE = 0x00000000, /* Default file endian-ness. */
@@ -127,12 +126,15 @@
enum
{ SFC_GET_LIB_VERSION = 0x1000,
SFC_GET_LOG_INFO = 0x1001,
+ SFC_GET_CURRENT_SF_INFO = 0x1002,
+
SFC_GET_NORM_DOUBLE = 0x1010,
SFC_GET_NORM_FLOAT = 0x1011,
SFC_SET_NORM_DOUBLE = 0x1012,
SFC_SET_NORM_FLOAT = 0x1013,
SFC_SET_SCALE_FLOAT_INT_READ = 0x1014,
+ SFC_SET_SCALE_INT_FLOAT_WRITE = 0x1015,
SFC_GET_SIMPLE_FORMAT_COUNT = 0x1020,
SFC_GET_SIMPLE_FORMAT = 0x1021,
@@ -152,6 +154,7 @@
SFC_GET_MAX_ALL_CHANNELS = 0x1045,
SFC_SET_ADD_PEAK_CHUNK = 0x1050,
+ SFC_SET_ADD_HEADER_PAD_CHUNK = 0x1051,
SFC_UPDATE_HEADER_NOW = 0x1060,
SFC_SET_UPDATE_HEADER_AUTO = 0x1061,
@@ -179,6 +182,17 @@
SFC_GET_BROADCAST_INFO = 0x10F0,
SFC_SET_BROADCAST_INFO = 0x10F1,
+ SFC_GET_CHANNEL_MAP_INFO = 0x1100,
+ SFC_SET_CHANNEL_MAP_INFO = 0x1101,
+
+ SFC_RAW_DATA_NEEDS_ENDSWAP = 0x1110,
+
+ /* Support for Wavex Ambisonics Format */
+ SFC_WAVEX_SET_AMBISONIC = 0x1200,
+ SFC_WAVEX_GET_AMBISONIC = 0x1201,
+
+ SFC_SET_VBR_ENCODING_QUALITY = 0x1300,
+
/* Following commands for testing only. */
SFC_TEST_IEEE_FLOAT_REPLACE = 0x6001,
@@ -205,7 +219,9 @@
SF_STR_SOFTWARE = 0x03,
SF_STR_ARTIST = 0x04,
SF_STR_COMMENT = 0x05,
- SF_STR_DATE = 0x06
+ SF_STR_DATE = 0x06,
+ SF_STR_ALBUM = 0x07,
+ SF_STR_LICENSE = 0x08
} ;
/*
@@ -214,7 +230,7 @@
*/
#define SF_STR_FIRST SF_STR_TITLE
-#define SF_STR_LAST SF_STR_DATE
+#define SF_STR_LAST SF_STR_LICENSE
enum
{ /* True and false */
@@ -224,7 +240,10 @@
/* Modes for opening files. */
SFM_READ = 0x10,
SFM_WRITE = 0x20,
- SFM_RDWR = 0x30
+ SFM_RDWR = 0x30,
+
+ SF_AMBISONIC_NONE = 0x40,
+ SF_AMBISONIC_B_FORMAT = 0x41
} ;
/* Public error values. These are guaranteed to remain unchanged for the duration
@@ -241,13 +260,45 @@
SF_ERR_UNSUPPORTED_ENCODING = 4
} ;
+
+/* Channel map values (used with SFC_SET/GET_CHANNEL_MAP).
+*/
+
+enum
+{ SF_CHANNEL_MAP_INVALID = 0,
+ SF_CHANNEL_MAP_MONO = 1,
+ SF_CHANNEL_MAP_LEFT,
+ SF_CHANNEL_MAP_RIGHT,
+ SF_CHANNEL_MAP_CENTER,
+ SF_CHANNEL_MAP_FRONT_LEFT,
+ SF_CHANNEL_MAP_FRONT_RIGHT,
+ SF_CHANNEL_MAP_FRONT_CENTER,
+ SF_CHANNEL_MAP_REAR_CENTER,
+ SF_CHANNEL_MAP_REAR_LEFT,
+ SF_CHANNEL_MAP_REAR_RIGHT,
+ SF_CHANNEL_MAP_LFE,
+ SF_CHANNEL_MAP_FRONT_LEFT_OF_CENTER,
+ SF_CHANNEL_MAP_FRONT_RIGHT_OF_CENTER,
+ SF_CHANNEL_MAP_SIDE_LEFT,
+ SF_CHANNEL_MAP_SIDE_RIGHT,
+ SF_CHANNEL_MAP_TOP_CENTER,
+ SF_CHANNEL_MAP_TOP_FRONT_LEFT,
+ SF_CHANNEL_MAP_TOP_FRONT_RIGHT,
+ SF_CHANNEL_MAP_TOP_FRONT_CENTER,
+ SF_CHANNEL_MAP_TOP_REAR_LEFT,
+ SF_CHANNEL_MAP_TOP_REAR_RIGHT,
+ SF_CHANNEL_MAP_TOP_REAR_CENTER
+} ;
+
+
/* A SNDFILE* pointer can be passed around much like stdio.h's FILE* pointer. */
typedef struct SNDFILE_tag SNDFILE ;
-/* The following typedef is system specific and is defined when libsndfile is.
-** compiled. sf_count_t can be one of loff_t (Linux), off_t (*BSD),
-** off64_t (Solaris), __int64_t (Win32) etc.
+/* The following typedef is system specific and is defined when libsndfile is
+** compiled. sf_count_t can be one of loff_t (Linux), off_t (*BSD), off64_t
+** (Solaris), __int64_t (Win32) etc. On windows, we need to allow the same
+** header file to be compiler by both GCC and the microsoft compiler.
*/
typedef __int64 sf_count_t ;
@@ -368,23 +419,30 @@
} SF_LOOP_INFO ;
-/* Struct used to retrieve broadcast (EBU) information from a file.
+/* Struct used to retrieve broadcast (EBU) information from a file.
** Strongly (!) based on EBU "bext" chunk format used in Broadcast WAVE.
*/
-typedef struct
-{ char description [256] ;
- char originator [32] ;
- char originator_reference [32] ;
- char origination_date [10] ;
- char origination_time [8] ;
- int time_reference_low ;
- int time_reference_high ;
- short version ;
- char umid [64] ;
- char reserved [190] ;
- unsigned int coding_history_size ;
- char coding_history [256] ;
-} SF_BROADCAST_INFO ;
+#define SF_BROADCAST_INFO_VAR(coding_hist_size) \
+ struct \
+ { char description [256] ; \
+ char originator [32] ; \
+ char originator_reference [32] ; \
+ char origination_date [10] ; \
+ char origination_time [8] ; \
+ unsigned int time_reference_low ; \
+ unsigned int time_reference_high ; \
+ short version ; \
+ char umid [64] ; \
+ char reserved [190] ; \
+ unsigned int coding_history_size ; \
+ char coding_history [coding_hist_size] ; \
+ }
+
+/* SF_BROADCAST_INFO is the above struct with coding_history field of 256 bytes. */
+typedef SF_BROADCAST_INFO_VAR (256) SF_BROADCAST_INFO ;
+
+
+/* Virtual I/O functionality. */
typedef sf_count_t (*sf_vio_get_filelen) (void *user_data) ;
typedef sf_count_t (*sf_vio_seek) (sf_count_t offset, int whence, void *user_data) ;
@@ -404,7 +462,7 @@
/* Open the specified file for read, write or both. On error, this will
** return a NULL pointer. To find the error number, pass a NULL SNDFILE
-** to sf_perror () or sf_error_str ().
+** to sf_strerror ().
** All calls to sf_open() should be matched with a call to sf_close().
*/
@@ -417,7 +475,7 @@
** of file header is at the current file offset. This allows sound files within
** larger container files to be read and/or written.
** On error, this will return a NULL pointer. To find the error number, pass a
-** NULL SNDFILE to sf_perror () or sf_error_str ().
+** NULL SNDFILE to sf_strerror ().
** All calls to sf_open_fd() should be matched with a call to sf_close().
*/
@@ -445,7 +503,7 @@
const char* sf_error_number (int errnum) ;
-/* The following three error functions are deprecated but they will remain in the
+/* The following two error functions are deprecated but they will remain in the
** library for the forseeable future. The function sf_strerror() should be used
** in their place.
*/
@@ -552,12 +610,3 @@
#endif /* __cplusplus */
#endif /* SNDFILE_H */
-
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: 906bb197-18f2-4f66-a395-b4722bab5114
-*/
-
More information about the Freeswitch-svn
mailing list