From 02a604f7150777ccab17a12cd2bc9b1ea00e72a9 Mon Sep 17 00:00:00 2001
From: Anthony Minessale
Date: Tue, 8 Nov 2011 15:04:40 -0600
Subject: [PATCH] FS-1197 --resolve do make sndfile-reconf if your build breaks
---
libs/libsndfile/.update | 2 +-
libs/libsndfile/Cfg/.empty | 0
libs/libsndfile/ChangeLog | 1137 +++++++++++++++-
libs/libsndfile/M4/add_cflags.m4 | 13 +-
libs/libsndfile/M4/add_cxxflags.m4 | 14 +-
libs/libsndfile/M4/clip_mode.m4 | 6 +-
libs/libsndfile/M4/endian.m4 | 14 +-
libs/libsndfile/M4/extra_largefile.m4 | 10 +-
libs/libsndfile/M4/flexible_array.m4 | 6 +-
libs/libsndfile/M4/gcc_version.m4 | 6 +-
libs/libsndfile/M4/llrint.m4 | 6 +-
libs/libsndfile/M4/lrint.m4 | 6 +-
libs/libsndfile/M4/lrintf.m4 | 6 +-
libs/libsndfile/M4/mkoctfile_version.m4 | 6 +-
libs/libsndfile/M4/octave.m4 | 2 +-
libs/libsndfile/Makefile.am | 70 +-
libs/libsndfile/Mingw-make-dist.sh | 116 --
libs/libsndfile/NEWS | 34 +
libs/libsndfile/Octave/Makefile.am | 10 +-
libs/libsndfile/Octave/octave_test.m | 8 +-
libs/libsndfile/Octave/octave_test.sh | 2 -
libs/libsndfile/Octave/sndfile.cc | 4 +-
libs/libsndfile/Octave/sndfile_load.m | 6 +-
libs/libsndfile/Octave/sndfile_play.m | 2 +-
libs/libsndfile/Octave/sndfile_save.m | 2 +-
libs/libsndfile/README | 2 +-
libs/libsndfile/TODO | 42 -
libs/libsndfile/acinclude.m4 | 627 ---------
libs/libsndfile/configure.ac | 302 +++--
libs/libsndfile/doc/FAQ.html | 203 ++-
libs/libsndfile/doc/api.html | 136 +-
libs/libsndfile/doc/bugs.html | 5 +-
libs/libsndfile/doc/command.html | 221 +++-
libs/libsndfile/doc/dither.html | 5 +-
libs/libsndfile/doc/embedded_files.html | 3 +-
libs/libsndfile/doc/index.html | 76 +-
libs/libsndfile/doc/libsndfile.css | 32 +-
libs/libsndfile/doc/libsndfile.css.in | 32 +-
libs/libsndfile/doc/lists.html | 3 +-
libs/libsndfile/doc/octave.html | 5 +-
libs/libsndfile/doc/pkgconfig.html | 7 +-
libs/libsndfile/doc/sndfile_info.html | 3 +-
libs/libsndfile/doc/tutorial.html | 3 +-
libs/libsndfile/doc/win32.html | 3 +-
libs/libsndfile/examples/cooledit-fixer.c | 231 ----
libs/libsndfile/examples/generate.c | 4 +-
libs/libsndfile/examples/list_formats.c | 2 +-
libs/libsndfile/examples/make_sine.c | 2 +-
libs/libsndfile/examples/sfprocess.c | 2 +-
libs/libsndfile/examples/sndfile-convert.c | 376 ------
libs/libsndfile/examples/sndfile-info.c | 354 -----
.../libsndfile/examples/sndfile-play-beos.cpp | 153 ---
libs/libsndfile/examples/sndfile-play.c | 960 --------------
libs/libsndfile/examples/sndfile-to-text.c | 2 +-
libs/libsndfile/examples/sndfilehandle.cc | 2 +-
libs/libsndfile/man/Makefile.am | 13 +-
libs/libsndfile/man/sndfile-convert.1 | 2 +-
libs/libsndfile/programs/Makefile.am | 33 +-
libs/libsndfile/programs/common.c | 127 +-
libs/libsndfile/programs/common.h | 13 +-
libs/libsndfile/programs/sndfile-cmp.c | 56 +-
libs/libsndfile/programs/sndfile-convert.c | 130 +-
libs/libsndfile/programs/sndfile-info.c | 110 +-
libs/libsndfile/programs/sndfile-jackplay.c | 277 ----
.../programs/sndfile-metadata-get.c | 8 +-
.../programs/sndfile-metadata-set.c | 16 +-
libs/libsndfile/programs/sndfile-play.c | 119 +-
.../programs/test-sndfile-metadata-set.py | 5 +-
libs/libsndfile/reconfigure.mk | 63 -
libs/libsndfile/regtest/checksum.c | 2 +-
libs/libsndfile/regtest/database.c | 4 +-
libs/libsndfile/regtest/regtest.h | 2 +-
libs/libsndfile/regtest/sndfile-regtest.c | 2 +-
libs/libsndfile/sndfile.pc.in | 1 +
libs/libsndfile/src/G72x/Makefile.am | 22 -
libs/libsndfile/src/G72x/g72x.h | 2 +-
libs/libsndfile/src/G72x/g72x_test.c | 44 +-
libs/libsndfile/src/GSM610/Makefile.am | 16 -
libs/libsndfile/src/Makefile.am | 103 +-
libs/libsndfile/src/Symbols.darwin | 1 +
libs/libsndfile/src/Symbols.linux | 42 -
libs/libsndfile/src/Symbols.os2 | 3 +-
libs/libsndfile/src/aiff.c | 232 +++-
libs/libsndfile/src/alaw.c | 8 +-
libs/libsndfile/src/au.c | 8 +-
libs/libsndfile/src/audio_detect.c | 2 +-
libs/libsndfile/src/avr.c | 8 +-
libs/libsndfile/src/binheader_writef_check.py | 10 +-
libs/libsndfile/src/broadcast.c | 128 +-
libs/libsndfile/src/caf.c | 112 +-
libs/libsndfile/src/chunk.c | 2 +-
libs/libsndfile/src/command.c | 4 +-
libs/libsndfile/src/common.c | 68 +-
libs/libsndfile/src/common.h | 147 ++-
libs/libsndfile/src/create_symbols_file.py | 23 +-
libs/libsndfile/src/cygsndfile.def | 39 -
libs/libsndfile/src/dither.c | 2 +-
libs/libsndfile/src/double64.c | 6 +-
libs/libsndfile/src/dwd.c | 10 +-
libs/libsndfile/src/dwvw.c | 10 +-
libs/libsndfile/src/file_io.c | 339 ++---
libs/libsndfile/src/flac.c | 62 +-
libs/libsndfile/src/float32.c | 12 +-
libs/libsndfile/src/float_cast.h | 271 ----
libs/libsndfile/src/g72x.c | 10 +-
libs/libsndfile/src/gsm610.c | 12 +-
libs/libsndfile/src/htk.c | 21 +-
libs/libsndfile/src/ima_adpcm.c | 61 +-
libs/libsndfile/src/ima_oki_adpcm.c | 6 +-
libs/libsndfile/src/ima_oki_adpcm.h | 2 +-
libs/libsndfile/src/interleave.c | 4 +-
libs/libsndfile/src/ircam.c | 6 +-
libs/libsndfile/src/libsndfile-1.def | 2 +
libs/libsndfile/src/libsndfile.def | 39 -
libs/libsndfile/src/macbinary3.c | 2 +-
libs/libsndfile/src/macos.c | 2 +-
libs/libsndfile/src/mat4.c | 8 +-
libs/libsndfile/src/mat5.c | 8 +-
libs/libsndfile/src/mpc2k.c | 17 +-
libs/libsndfile/src/ms_adpcm.c | 13 +-
libs/libsndfile/src/nist.c | 42 +-
libs/libsndfile/src/ogg.c | 1166 ++---------------
libs/libsndfile/src/paf.c | 26 +-
libs/libsndfile/src/pcm.c | 8 +-
libs/libsndfile/src/pvf.c | 6 +-
libs/libsndfile/src/raw.c | 2 +-
libs/libsndfile/src/rf64.c | 328 ++++-
libs/libsndfile/src/rx2.c | 4 +-
libs/libsndfile/src/sd2.c | 21 +-
libs/libsndfile/src/sds.c | 91 +-
libs/libsndfile/src/sf_unistd.h | 20 +-
libs/libsndfile/src/sfconfig.h | 14 +-
libs/libsndfile/src/sfendian.h | 2 +-
libs/libsndfile/src/sndfile.c | 352 +++--
libs/libsndfile/src/sndfile.h.in | 105 +-
libs/libsndfile/src/sndfile.hh | 84 +-
libs/libsndfile/src/strings.c | 82 +-
libs/libsndfile/src/svx.c | 37 +-
libs/libsndfile/src/test_audio_detect.c | 5 +-
libs/libsndfile/src/test_conversions.c | 14 +-
libs/libsndfile/src/test_endswap.c | 2 +-
libs/libsndfile/src/test_endswap.tpl | 2 +-
libs/libsndfile/src/test_file_io.c | 64 +-
libs/libsndfile/src/test_float.c | 2 +-
libs/libsndfile/src/test_ima_oki_adpcm.c | 6 +-
libs/libsndfile/src/test_log_printf.c | 2 +-
libs/libsndfile/src/test_main.c | 5 +-
libs/libsndfile/src/test_main.h | 5 +-
libs/libsndfile/src/txw.c | 4 +-
libs/libsndfile/src/ulaw.c | 8 +-
libs/libsndfile/src/voc.c | 23 +-
libs/libsndfile/src/vox_adpcm.c | 8 +-
libs/libsndfile/src/w64.c | 8 +-
libs/libsndfile/src/wav.c | 100 +-
libs/libsndfile/src/wav_w64.c | 117 +-
libs/libsndfile/src/wav_w64.h | 7 +-
libs/libsndfile/src/wve.c | 8 +-
libs/libsndfile/src/xi.c | 10 +-
libs/libsndfile/tests/Makefile.am | 68 +-
libs/libsndfile/tests/aiff_rw_test.c | 2 +-
libs/libsndfile/tests/alaw_test.c | 15 +-
libs/libsndfile/tests/benchmark.c | 2 +-
libs/libsndfile/tests/benchmark.tpl | 2 +-
libs/libsndfile/tests/checksum_test.c | 2 +-
libs/libsndfile/tests/command_test.c | 57 +-
libs/libsndfile/tests/cpp_test.cc | 94 +-
libs/libsndfile/tests/dft_cmp.c | 2 +-
libs/libsndfile/tests/dft_cmp.h | 2 +-
libs/libsndfile/tests/dither_test.c | 5 +-
libs/libsndfile/tests/dwvw_test.c | 9 +-
libs/libsndfile/tests/error_test.c | 22 +-
libs/libsndfile/tests/external_libs_test.c | 2 +-
libs/libsndfile/tests/fix_this.c | 10 +-
libs/libsndfile/tests/floating_point_test.c | 2 +-
libs/libsndfile/tests/floating_point_test.tpl | 2 +-
libs/libsndfile/tests/generate.c | 4 +-
libs/libsndfile/tests/generate.h | 2 +-
libs/libsndfile/tests/header_test.c | 30 +-
libs/libsndfile/tests/header_test.tpl | 6 +-
libs/libsndfile/tests/headerless_test.c | 2 +-
libs/libsndfile/tests/largefile_test.c | 2 +-
libs/libsndfile/tests/locale_test.c | 130 +-
libs/libsndfile/tests/lossy_comp_test.c | 2 +-
libs/libsndfile/tests/misc_test.c | 11 +-
libs/libsndfile/tests/multi_file_test.c | 14 +-
libs/libsndfile/tests/ogg_test.c | 2 +-
libs/libsndfile/tests/open_fail_test.c | 81 --
libs/libsndfile/tests/pcm_test.c | 12 +-
libs/libsndfile/tests/pcm_test.tpl | 9 +-
libs/libsndfile/tests/peak_chunk_test.c | 20 +-
libs/libsndfile/tests/pipe_test.c | 6 +-
libs/libsndfile/tests/pipe_test.tpl | 6 +-
libs/libsndfile/tests/raw_test.c | 6 +-
libs/libsndfile/tests/scale_clip_test.c | 2 +-
libs/libsndfile/tests/scale_clip_test.tpl | 2 +-
libs/libsndfile/tests/sfversion.c | 21 +-
libs/libsndfile/tests/stdin_test.c | 16 +-
libs/libsndfile/tests/stdio_test.c | 5 +-
libs/libsndfile/tests/stdout_test.c | 2 +-
libs/libsndfile/tests/string_test.c | 71 +-
libs/libsndfile/tests/test_wrapper.sh.in | 88 +-
libs/libsndfile/tests/ulaw_test.c | 16 +-
libs/libsndfile/tests/utils.c | 104 +-
libs/libsndfile/tests/utils.h | 29 +-
libs/libsndfile/tests/utils.tpl | 101 +-
libs/libsndfile/tests/virtual_io_test.c | 8 +-
libs/libsndfile/tests/vorbis_test.c | 6 +-
libs/libsndfile/tests/win32_ordinal_test.c | 4 +-
libs/libsndfile/tests/win32_test.c | 71 +-
libs/libsndfile/tests/write_read_test.c | 50 +-
libs/libsndfile/tests/write_read_test.tpl | 15 +-
src/mod/formats/mod_sndfile/mod_sndfile.c | 3 +
212 files changed, 5472 insertions(+), 6793 deletions(-)
delete mode 100644 libs/libsndfile/Cfg/.empty
delete mode 100755 libs/libsndfile/Mingw-make-dist.sh
delete mode 100644 libs/libsndfile/TODO
delete mode 100644 libs/libsndfile/acinclude.m4
delete mode 100644 libs/libsndfile/examples/cooledit-fixer.c
delete mode 100644 libs/libsndfile/examples/sndfile-convert.c
delete mode 100644 libs/libsndfile/examples/sndfile-info.c
delete mode 100644 libs/libsndfile/examples/sndfile-play-beos.cpp
delete mode 100644 libs/libsndfile/examples/sndfile-play.c
delete mode 100644 libs/libsndfile/programs/sndfile-jackplay.c
mode change 100644 => 100755 libs/libsndfile/programs/test-sndfile-metadata-set.py
delete mode 100644 libs/libsndfile/reconfigure.mk
delete mode 100644 libs/libsndfile/src/G72x/Makefile.am
delete mode 100644 libs/libsndfile/src/GSM610/Makefile.am
delete mode 100644 libs/libsndfile/src/Symbols.linux
mode change 100644 => 100755 libs/libsndfile/src/binheader_writef_check.py
delete mode 100644 libs/libsndfile/src/cygsndfile.def
delete mode 100644 libs/libsndfile/src/float_cast.h
delete mode 100644 libs/libsndfile/src/libsndfile.def
delete mode 100644 libs/libsndfile/tests/open_fail_test.c
diff --git a/libs/libsndfile/.update b/libs/libsndfile/.update
index f195187f18..9088eb921c 100644
--- a/libs/libsndfile/.update
+++ b/libs/libsndfile/.update
@@ -1 +1 @@
-Thu May 21 16:11:03 CDT 2009
+Tue Nov 8 14:58:00 CST 2011
diff --git a/libs/libsndfile/Cfg/.empty b/libs/libsndfile/Cfg/.empty
deleted file mode 100644
index e69de29bb2..0000000000
diff --git a/libs/libsndfile/ChangeLog b/libs/libsndfile/ChangeLog
index d36eb00e35..53353df3dd 100644
--- a/libs/libsndfile/ChangeLog
+++ b/libs/libsndfile/ChangeLog
@@ -1,3 +1,1082 @@
+2011-07-13 Erik de Castro Lopo
+
+ * src/ogg_vorbis.c
+ Fix return value of SFC_SET_VBR_ENCODING_QUALITY command.
+
+ * doc/command.html
+ Document SFC_SET_VBR_ENCODING_QUALITY, SFC_GET/SET_LOOP_INFO and
+ SFC_GET_INSTRUMENT.
+
+ * NEWS README configure.ac doc/*.html
+ Updates for 1.0.25.
+
+2011-07-07 Erik de Castro Lopo
+
+ * src/sfconfig.h
+ Add handling for HAVE_SYS_WAIT_H.
+
+ * Makefile.am src/Makefile.am tests/Makefile.am
+ Add 'checkprograms' target.
+
+2011-07-05 Erik de Castro Lopo
+
+ * src/common.h src/sndfile.c
+ Purge SF_ASSERT macro. Use standard C assert instead.
+
+ * src/paf.c src/common.h src/sndfile.c
+ Fix for Secunia Advisory SA45125, heap overflow (heap gets overwritten with
+ byte value of 0) due to integer overflow if PAF file handler.
+
+ * src/ima_adpcm.c src/ms_adpcm.c src/paf.c
+ Use calloc instead of malloc followed by memset.
+
+ * tests/utils.tpl
+ Clean up use of memset.
+
+2011-07-05 Erik de Castro Lopo
+
+ * src/ogg.c
+ Fix log message.
+
+ * tests/format_check_test.c
+ Fix compiler warnings.
+
+2011-07-04 Erik de Castro Lopo
+
+ * src/sndfile.c
+ Fix error message for erro code SFE_ZERO_MINOR_FORMAT.
+
+ * tests/format_check_test.c
+ Add a test to for SF_FINFO format field validation.
+
+ * src/ogg.c src/ogg_vorbis.c src/ogg.h src/ogg_pcm.c src/ogg_speex.c
+ src/common.h src/Makefile.am
+ Move vorbis specific code to ogg_vorbis.c, add new files for handling PCM
+ and Speex codecs in an Ogg container. The later two are only enabled with
+ ENABLE_EXPERIMENTAL_CODE config variable.
+
+2011-06-28 Erik de Castro Lopo
+
+ * src/strings.c
+ Clean up and refactor storage of SF_STR_SOFTWARE.
+
+2011-06-23 Erik de Castro Lopo
+
+ * src/sndfile.h.in doc/api.html
+ Fix definition of SF_STR_LAST and update SF_STR_* related docs. Thanks to
+ Tim van der Molen for the patch.
+
+2011-06-21 Erik de Castro Lopo
+
+ * programs/sndfile-interleave.c
+ Fix handling of argc. Thanks to Marius Hennecke.
+
+ * src/wav_w64.c
+ Accept broken WAV files with blockalign == 0. Thanks to Olivier Tristan for
+ providing example files.
+
+ * src/wav.c
+ Jump over 'FLLR' chunks.
+
+2011-06-14 Erik de Castro Lopo
+
+ * src/sndfile.h.in
+ Fix -Wundef warning due to ENABLE_SNDFILE_WINDOWS_PROTOTYPES.
+
+ * configure.ac
+ Add -Wundef to CFLAGS.
+
+ * src/ogg.c
+ Fix -Wunder warning.
+
+2011-05-18 Erik de Castro Lopo
+
+ * configure.ac
+ Use int64_t instead of off_t when they are the same size.
+
+ * src/Makefile.am tests/Makefile.am
+ Use check_PROGRAMS instead of noinst_PROGRAMS where appropriate.
+
+2011-05-08 Erik de Castro Lopo
+
+ * src/wav.c
+ Don't allow unknown and/or un-editable chunks to prevent the file from being
+ opened in SFM_RDWR mode.
+
+2011-04-25 Erik de Castro Lopo
+
+ * tests/format_check_test.c
+ Fix segfault in test program.
+
+2011-04-25 Erik de Castro Lopo
+
+ * tests/format_check_test.c
+ New test program to check to make sure that sf_open() and sf_check_format()
+ agree as to what is a valid program.
+
+ * tests/Makefile.am tests/test_wrapper.sh.in
+ Hook into build and test runner.
+
+ * src/sndfile.c
+ Fix some sf_format_check() problems. Thanks to Charles Van Winkle for the
+ notification.
+
+2011-04-06 Erik de Castro Lopo
+
+ * src/caf.c
+ Add validation to size of 'data' chunk and fix size of written 'data'
+ chunk. Thanks to Michael Pruett for reporting this.
+
+2011-03-28 Erik de Castro Lopo
+
+ * src/* tests/* programs/*
+ Fix a bunch of compiler warnings with gcc-4.6.
+
+2011-03-25 Erik de Castro Lopo
+
+ * tests/util.tpl
+ Add NOT macro to util.h.
+
+ * src/strings.c
+ Fix handling of SF_STR_SOFTWARE that resulted in a segfault due to calling
+ strlen() on an unterminated string. Thanks to Francois Thibaud for reporting
+ this problem.
+
+ * tests/string_test.c
+ Add test for SF_STR_SOFTWARE segfault bug.
+
+ * configure.ac
+ Sanitize FLAC_CFLAGS value supplied by pkg-config which returns a value of
+ '-I${includedir}/FLAC'. However FLAC also provides an include file
+ which clashes with the Standard C header of the same name. The
+ solution is strip the 'FLAC' part off the end and include all FLAC headers
+ as .
+
+ * configure.ac src/Makefile.am
+ Use non-recursive make in src/ directory.
+
+2011-03-23 Erik de Castro Lopo
+
+ * NEWS README docs/*.html
+ Updates for 1.0.24 release.
+
+2011-03-22 Erik de Castro Lopo
+
+ * configure.ac
+ Fix up usage of sed (should not assume GNU sed).
+
+ * M4/add_(c|cxx)flags.m4
+ Test flags in isolation.
+
+ * tests/cpp_test.cc
+ Fix a broken test (test segfaults). Report by Dave Flogeras.
+
+2011-03-21 Erik de Castro Lopo
+
+ * programs/common.[ch]
+ Add function program_name() which returns the program name minus the path
+ from argv [0].
+
+ * programs/*.c programs/Makefile.am
+ Use program_name() where appropriate. Fix build.
+
+2011-03-20 Erik de Castro Lopo
+
+ * src/wav.c
+ For u-law and A-law files, write an 18 byte 'fmt ' chunk instead of a 16
+ byte one. Win98 accepts files with a 16 but not 18 byte 'fmt' chunk. Later
+ version accept 18 byte but not 16 byte.
+
+2011-03-15 Erik de Castro Lopo
+
+ * doc/FAQ.html
+ Add examples for question 12.
+
+ * doc/libsndfile.css.in
+ Add tweaks for h4 element.
+
+ * doc/api.html
+ Add documentation for virtual I/O functionality. Thanks to Uli Franke.
+
+ * tests/util.tpl
+ Add static inline functions sf_info_clear() and sf_info_setup().
+
+ * tests/(alaw|dwvw|ulaw)_test.c
+ Use functions sf_info_clear() and sf_info_setup().
+
+2011-03-08 Erik de Castro Lopo
+
+ * configure.ac
+ Fail more gracefully if pkg-config is missing. Suggestion from Brian
+ Willoughby.
+
+2011-02-27 Erik de Castro Lopo
+
+ * src/common.c
+ Use size_t instead of int for size params with varargs.
+
+2011-02-09 Erik de Castro Lopo
+
+ * doc/index.html
+ Update supported platforms with more Debian platforms and Android.
+
+2011-01-27 Erik de Castro Lopo
+
+ * src/sndfile.hh
+ Add an LPCWSTR version of the SndfileHandle constructor to the SndfileHandle
+ class definition. Thanks to Eric Eizenman for pointing out this was missing.
+
+ * tests/cpp_test.cc
+ Add test for LPCWSTR version of the SndfileHandle constructor.
+
+2011-01-19 Erik de Castro Lopo
+
+ * programs/sndfile-play.c
+ Remove cruft.
+
+2010-12-01 Erik de Castro Lopo
+
+ * src/sndfile.hh
+ Add methods rawHandle() and takeOwnership(). Thanks to Tim Blechmann for
+ the patch.
+
+ * tests/cpp_test.cc
+ Add tests for above two methods. Also supplied by Tim Blechmann.
+
+2010-11-11 Erik de Castro Lopo
+
+ * doc/api.html
+ Add mention of use of sf_strerror() when sf_open() fails.
+
+2010-11-01 Erik de Castro Lopo
+
+ * configure.ac
+ Make TYPEOF_SF_COUNT_T int64_t where possible. This may fix problems where
+ people are compiling on a 64 bit system with the GCC -m32 flag.
+
+ * src/sndfile.h.in
+ Fix comments on sf_count_t.
+
+2010-10-26 Erik de Castro Lopo
+
+ * src/aiff.c
+ Handle non-zero offset field in SSND chunk. Thanks to Michael Chinen.
+
+2010-10-20 Erik de Castro Lopo
+
+ * configure.ac
+ Sed fix for FreeBSD. Thanks Tony Theodore.
+
+2010-10-14 Erik de Castro Lopo
+
+ * shave.in M4/shave.m4
+ Fix shave invocation of windres compiler. Thanks Damien Lespiau (upstream
+ shave author).
+
+ * configure.ac M4/shave.m4 shave-libtool.in shave.in
+ Switch from shave to automake-1.11's AM_SILENT_RULES.
+
+2010-10-13 Erik de Castro Lopo
+
+ * shave-libtool.in shave.in
+ Sync to upstream version.
+
+ * src/rf64.c
+ More work to make the parser more robust and accepting of mal-formed files.
+
+2010-10-12 Erik de Castro Lopo
+
+ * src/common.h
+ Add functions psf_strlcpy() and psf_strlcat().
+
+ * src/broadcast.c src/sndfile.c src/strings.c src/test_main.c
+ src/test_main.h src/test_strncpy_crlf.c
+ Use functions psf_strlcpy() and psf_strlcat() as appropriate.
+
+ * tests/string_test.c
+ Add tests for SF_STR_GENRE and SF_STR_TRACKNUMBER.
+
+ * src/rf64.c
+ Fix size of 'ds64' chunk when writing RF64.
+
+2010-10-10 Erik de Castro Lopo
+
+ * programs/*.c
+ Add the libsndfile version to the usage message of all programs.
+
+2010-10-10 Erik de Castro Lopo
+
+ * configure.ac src/version-metadata.rc.in src/Makefile.am
+ Add version string resources to the windows DLL.
+
+ * doc/api.html
+ Update to add missing SF_FORMAT_* values. Closed Debian bug #545257.
+
+ * NEWS README configure.ac doc/*.html
+ Updates for 1.0.23 release.
+
+2010-10-09 Erik de Castro Lopo
+
+ * tests/pedantic-header-test.sh.in
+ Handle unusual values of CC environment variable.
+
+ * src/rf64.c
+ Minor tweaks and additional sanity checking.
+
+ * src/Makefile.am src/binheader_writef_check.py
+ Use python 2.6.
+
+2010-10-08 Erik de Castro Lopo
+
+ * src/sndfile.hh
+ Add a missing 'inline' before a constructor defintion.
+
+2010-10-06 Erik de Castro Lopo
+
+ * src/common.h
+ Add macro NOT.
+
+ * src/rf64.c
+ Minor tweaks.
+
+ * Makefile.am */Makefile.am
+ Add *~ to CLEANFILES.
+
+2010-10-05 Erik de Castro Lopo
+
+ * src/sndfile.c
+ Fix a typo in the error string for SFE_OPEN_PIPE_RDWR. Thanks to Charles
+ Van Winkle for the report.
+
+2010-10-04 Erik de Castro Lopo
+
+ * src/flac.c src/ogg.c src/sndfile.h.in src/strings.c src/wav.c
+ Add ability to read/write tracknumber and genre to flac/ogg/wav files.
+ Thanks to Matti Nykyri for the patch.
+
+ * src/common.h src/broadcast.c src/strings.c
+ Add function psf_safe_strncpy() and use where appropriate.
+
+2010-10-04 Erik de Castro Lopo
+
+ * NEWS README configure.ac doc/*.html
+ Updates for 1.0.22 release.
+
+2010-10-03 Erik de Castro Lopo
+
+ * src/common.h src/broadcast.c src/rf64.c src/sndfile.c src/wav.c
+ Rewrite of SF_BROADCAST_INFO handling.
+
+ * src/test_broadcast_var.c tests/command_test.c
+ Tweak SF_BROADCAST_INFO tests.
+
+ * src/test_broadcast_var.c
+ Fix OSX stack check error.
+
+2010-09-30 Erik de Castro Lopo
+
+ * src/sds.c
+ Set sustain_loop_end to 0 as suggested by Brian Lewis.
+
+2010-09-29 Erik de Castro Lopo
+
+ * src/sds.c
+ Make sure the correct frame count gets written into the header.
+
+ * tests/write_read_test.tpl
+ Don't allow SDS files to have a long frame count.
+
+2010-09-17 Erik de Castro Lopo
+
+ * src/sds.c
+ Apply a pair of patches from Brian Lewis to fix the packet number location
+ and the checksum.
+
+2010-09-10 Erik de Castro Lopo
+
+ * src/aiff.c src/file_io.c src/ogg.c src/rf64.c src/sndfile.c
+ src/strings.c src/test_audio_detect.c src/test_strncpy_crlf.c
+ src/wav.c tests/pcm_test.tpl
+ Fix a bunch of minor issues found using static analysis.
+
+2010-08-23 Erik de Castro Lopo
+
+ * src/test_broadcast_var.c
+ New file containing tests for broadcast_set_var().
+
+ * src/Makefile.am src/test_main.[ch]
+ Hook test_broadcast_var.c into tests.
+
+2010-08-22 Erik de Castro Lopo
+
+ * src/broadcast.c src/common.(c|h)
+ Move function strncpy_crlf() to src/common.c so the function can be tested
+ in isolation.
+
+ * src/test_strncpy_crlf.c
+ New file.
+
+ * src/Makefile.am src/test_main.[ch]
+ Hook test_strncpy_crlf.c into tests.
+
+2010-08-18 Erik de Castro Lopo
+
+ * src/common.h
+ Move code around to make comments make sense.
+
+ * src/broadcast.c
+ Add debugging code that is disabled by default.
+
+2010-08-02 Erik de Castro Lopo
+
+ * src/flac.c
+ When the file meta data says the file has zero frames set psf->sf.frames
+ to SF_COUNT_MAX. Fixes Debian bug #590752.
+
+ * programs/sndfile-info.c
+ Print 'unknown' if frame count == SF_COUNT_MAX.
+
+2010-06-27 Erik de Castro Lopo
+
+ * src/sndfile.c
+ Only support writing mono SVX files. Multichannel SVX files are not
+ interleaved and there is no support infrastructure to cache and write
+ multiple channels to create a non-interleaved file.
+
+ * src/file_io.c
+ Don't call close() on a file descriptor of -1. Thanks to Jeremy Friesner
+ for the bug report.
+
+2010-06-09 Erik de Castro Lopo
+
+ * src/common.h
+ Add macro SF_ASSERT.
+
+ * src/sndfile.c
+ Use SF_ASSERT to ensure sizeof (sf_count_t) == 8.
+
+ * src/svx.c
+ Add support for reading and writing stereo SVX files.
+
+2010-05-07 Erik de Castro Lopo
+
+ * configure.ac
+ When compiling with x86_64-w64-mingw32-gcc link with -static-libgcc flags.
+
+ * programs/common.c programs/sndfile-metadata-set.c
+ Update metadata after the audio data is copied. Other minor fixes. Patch
+ from Marius Hennecke.
+
+2010-05-04 Erik de Castro Lopo
+
+ * src/nist.c
+ Fix a regression reported by Hugh Secker-Walker.
+
+ * src/api.html
+ Add comment about sf_open_fd() not working on Windows if the application
+ and the libsndfile DLL are linked to different versions of the Microsoft
+ C runtime DLL.
+
+2010-04-23 Erik de Castro Lopo
+
+ * tests/pedantic-header-test.sh.in
+ Fix 'make distcheck'.
+
+2010-04-21 Erik de Castro Lopo
+
+ * tests/pedantic-header-test.sh.in
+ New file to test whether sndfile.h can be compiled with gcc's -pedantic
+ flag.
+
+ * configure.ac tests/test_wrapper.sh.in
+ Hook pedantic-header-test into test suite.
+
+ * src/sndfile.h.in
+ Fix -pedantic warning.
+
+2010-04-19 Erik de Castro Lopo
+
+ * programs/sndfile-salvage.c programs/Makefile.am
+ New program to salvage the audio data from WAV/WAVEX/AIFF files which are
+ greater than 4Gig in size.
+
+2010-04-09 Erik de Castro Lopo
+
+ * programs/sndfile-convert.c
+ Fix valgrind warning.
+
+2010-04-06 Erik de Castro Lopo
+
+ * programs/sndfile-cmp.c
+ When files differ in the PCM data, also print the difference offset.
+ Minor cleanup.
+
+2010-03-19 Erik de Castro Lopo
+
+ * src/aiff.c
+ Don't use the 'twos' marker for 24 and 32 bit PCM, use 'in24' and 'in32'
+ instead. Thanks to Paul Davis (Ardour) for this suggestion.
+
+2010-02-28 Erik de Castro Lopo
+
+ * configure.ac
+ Clean up configure report.
+
+ * tests/utils.tpl
+ Add functions test_read_raw_or_die and test_write_raw_or_die.
+
+ * tests/rdwr_test.(def|tpl) tests/Makefile.am
+ Add new test program and hook into build.
+
+ * src/sndfile.c
+ Fix minor issues with sf_read/write_raw(). Bug reported by Milan Křápek.
+
+ * tests/test_wrapper.sh.in
+ Add rdwr_test to the test wrapper script.
+
+2010-02-22 Erik de Castro Lopo
+
+ * configure.ac
+ Remove -fpascal-strings from OSX's OS_SPECIFIC_CFLAGS.
+
+ * programs/common.[ch] programs/sndfile-metadata-set.c
+ Apply a patch from Robin Gareus allowing the setting of the time reference
+ field of the BEXT chunk.
+
+2010-02-06 Erik de Castro Lopo
+
+ * src/ima_adpcm.c
+ Add a fix from Jonatan Liljedahl to handle predictor overflow when decoding
+ IMA4.
+
+2010-01-26 Erik de Castro Lopo
+
+ * src/sndfile.hh
+ Add a constructor which takes an existing file descriptor and then calls
+ sf_open_fd(). Patch from Sakari Bergen.
+
+2010-01-10 Erik de Castro Lopo
+
+ * programs/sndfile-deinterleave.c programs/sndfile-interleave.c
+ Improve usage messages.
+
+2010-01-09 Erik de Castro Lopo
+
+ * src/id3.c src/Makefile.am
+ Add new file src/id3.c and hook into build.
+
+ * src/sndfile.c src/common.h
+ Detect and skip and ID3 header at the start of the file.
+
+2010-01-07 Erik de Castro Lopo
+
+ * programs/common.c
+ Fix update_strings() copyright, comment, album and license are correctly
+ written. Thanks to Todd Allen for reporting this.
+
+ * man/Makefile.am
+ Change GNU makeism to something more widely supported. Thanks to Christian
+ Weisgerber for reporting this.
+
+ * configure.ac programs/Makefile.am programs/sndfile-play.c
+ Apply patch from Christian Weisgerber and Jacob Meuserto add support for
+ OpenBSD's sndio.
+
+2010-01-05 Erik de Castro Lopo
+
+ * doc/api.html
+ Discourage the use of sf_read/write_raw().
+
+2009-12-28 Erik de Castro Lopo
+
+ * configure.ac
+ Test for Unix pipe() and waitpid() functions.
+
+ * src/sfconfig.h tests/pipe_test.tpl
+ Disable pipe_test if pipe() and waitpid() aren't available.
+
+2009-12-16 Erik de Castro Lopo
+
+ * configure.ac src/Makefile.am src/create_symbols_file.py
+ src/make-static-lib-hidden-privates.sh
+ Change name of generated file src/Symbols.linux to Symbols.gnu-binutils and
+ and use the same symbols file for other systems which use GNU binutils like
+ Debian's kfreebsd.
+
+ * M4/shave.m4 shave.in
+ Update shave files from upstream.
+
+2009-12-15 Erik de Castro Lopo
+
+ * man/sndfile-metadata-get.1
+ Fix typo.
+
+ * man/sndfile-interleave.1 man/Makefile.am
+ New man page.
+
+2009-12-13 Erik de Castro Lopo
+
+ * src/ogg.c
+ When decoding to short or int, clip the decoded signal to [-1.0, 1.0] if
+ its too hot. Thanks to Dmitry Baikov for suggesting this.
+
+ * NEWS README doc/*.html
+ Updates for 1.0.21.
+
+2009-12-09 Erik de Castro Lopo
+
+ * programs/sndfile-jackplay.c man/sndfile-jackplay.1
+ Remove these which will now be in found in the sndfile-tools package.
+
+ * programs/Makefile.am man/Makefile.am
+ Remove build rules for sndfile-jackplay.
+
+ * configure.ac
+ Remove detection of JACK Audio Connect Kit.
+
+ * programs/sndfile-concat.c man/sndfile-concat.1
+ Add new program with man page.
+
+ * man/Makefile.am programs/Makefile.am
+ Hook sndfile-concat into build system.
+
+2009-12-08 Erik de Castro Lopo
+
+ * tests/error_test.c
+ Don't terminate when sf_close() returns zero in error_close_test().
+ It seems that Windows 7 behaves differently from earlier versions of
+ Windows.
+
+2009-12-03 Erik de Castro Lopo
+
+ * configure.ac M4/*.m4
+ Rename all custom macros from AC_* to MN_*.
+
+ * programs/sndfile-interleave.c
+ Make it actually work.
+
+2009-12-02 Erik de Castro Lopo
+
+ * doc/*.html configure.ac
+ Corrections and clarifications courtesy of Robin Forder.
+
+ * programs/sndfile-convert.c programs/common.[ch]
+ Move some code from convert to common for reuse.
+
+ * programs/sndfile-interleave.c programs/sndfile-interleave.c
+ Add new programs sndfile-interleave and sndfile-deinterleave.
+
+ * programs/Makefile.am
+ Hook new programs into build.
+
+2009-12-01 Erik de Castro Lopo
+
+ * src/create_symbols_file.py tests/stdio_test.c tests/win32_test.c
+ Minor OS/2 tweaks as suggested by David Yeo.
+
+ * tests/multi_file_test.c
+ Fix file creation flags on windows. Thanks to Bruce Sharpe.
+
+ * src/sf_unistd.h
+ Set all group and other file create permssions to zero.
+
+ * tests/win32_test.c
+ Add a new test.
+
+2009-11-30 Erik de Castro Lopo
+
+ * doc/print.css doc/*.html
+ Add a print stylesheet and update all HTML documents to reference it.
+ Thanks to Aditya Bhargava for suggesting this.
+
+ * doc/index.html
+ Minor corrections.
+
+2009-11-29 Erik de Castro Lopo
+
+ * sndfile.pc.in
+ Add a Libs.private entry to assist with static linking.
+
+2009-11-28 Erik de Castro Lopo
+
+ * src/make-static-lib-hidden-privates.sh src/Makefile.am
+ Add a script to hide all non-public symbols in the libsndfile.a static
+ library.
+
+2009-11-22 Erik de Castro Lopo
+
+ * tests/locale_test.c
+ Correct usage of ENABLE_SNDFILE_WINDOWS_PROTOTYPES.
+
+2009-11-20 Erik de Castro Lopo
+
+ * src/windows.c
+ Correct usage of ENABLE_SNDFILE_WINDOWS_PROTOTYPES.
+
+2009-11-16 Erik de Castro Lopo
+
+ * programs/sndfile-convert.c
+ Allow the program to read from stdin by specifying '-' on the command line
+ as the input file.
+
+ * src/sndfile.h.in
+ Hash define ENABLE_SNDFILE_WINDOWS_PROTOTYPES to 1 for greater safety.
+
+ * tests/virtual_io_test.c
+ Add a PAF/PCM_24 test and verify the file length is not negative
+ immediately after openning the file for write.
+
+2009-10-18 Erik de Castro Lopo
+
+ * src/wav.c
+ When writing loop lengths, adjust the end position by one to make up for
+ Microsoft's screwed up spec. Thanks to Olivier Tristan for the patch.
+
+2009-10-14 Erik de Castro Lopo
+
+ * src/flac.c
+ Apply patch from Uli Franke allowing FLAC files to be encoded at any sample
+ rate.
+
+2009-10-09 Erik de Castro Lopo
+
+ * src/nist.c
+ Fix parsing of odd ulaw encoded file provided by Jan Silovsky.
+
+ * configure.ac
+ Insist on libvorbis >= 1.2.3. Earlier verions have bugs that cause the
+ libsndfile test suite to fail on MIPS, PowerPC and others.
+ See: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=549899
+
+2009-10-06 Erik de Castro Lopo
+
+ * man/sndfile-convert.1
+ Fix warning from Debian's lintian checks.
+
+ * man/sndfile-cmp.1 man/sndfile-jackplay.1 man/sndfile-metadata-get.1
+ man/Makefile.am
+ Add three new minimal manpages and hook into build.
+
+2009-10-05 Erik de Castro Lopo
+
+ * tests/test_wrapper.sh.in
+ Don't run cpp_test on x86_64-w64-mingw32.
+
+2009-09-28 Erik de Castro Lopo
+
+ * tests/utils.tpl
+ On windows, make sure the open() function doesn't get called with a third
+ parameter of 0 which fails for no good reason. Also make sure this third
+ parameter doesn't get called with S_IRGRP when compiling for windows because
+ Wine complains.
+
+ * src/sndfile.hh
+ Add a SndfileHandle constructor for windows that takes a 'const wchar_t *'
+ string.
+
+ * doc/FAQ.html
+ Add Q/A : I'm cross compiling libsndfile for another platform. How can I
+ run the test suite?
+
+ * src/create_symbols_file.py src/Makefile.am
+ Add Symbols.static target, a list of symbols, one per line.
+
+2009-09-27 Erik de Castro Lopo
+
+ * tests/test_wrapper.sh.in
+ Update to allow all tests to be gathered up into a testsuite tarball and
+ then be run using this script.
+
+ * build-test-tarball.mk.in
+ Add a Make script to build a tarball of all the test binaries and the test
+ wrapper script. This is useful for cross compiling; you can build the
+ binaries, build test test tarball and transfer the test tarball to the
+ target machine for testing.
+
+2009-09-26 Erik de Castro Lopo
+
+ * src/common.h src/*.c
+ Modify SF_FILE struct to allow it to carry either 8-bit or 16-bit strings
+ for the file path, directory and name. Fixes for this change throughout.
+
+ * src/windows.c src/Makefile.am
+ New file defining new windows only public function sf_wchar_open() which
+ takes a 'const wchar_t *' string (LPCWSTR) for the file name parameter.
+
+ * src/sndfile.h.in
+ Add SF_CHANNEL_MAP_ABISONIC_* entries.
+ Add windows only defintion for sf_wchar_open().
+
+ * src/create_symbols_file.py
+ Add sf_wchar_open() to the list of public symbols (windows only).
+
+ * tests/locale_test.c
+ Add a wchar_test() to test sf_wchar_open().
+
+2009-09-25 Erik de Castro Lopo
+
+ * src/common.h src/*.c
+ Split file stuff into PSF_FILE struct within the SF_PRIVATE struct.
+
+2009-09-23 Erik de Castro Lopo
+
+ * src/aiff.c src/voc.c
+ When a byte is needed, use unsigned char.
+
+ * src/ima_oki_adpcm.c src/broadcast.c src/test_ima_oki_adpcm.c
+ Include sfconfig.h to prevent compile errors with MinGW compilers.
+
+ * configure.ac
+ Remove AM_CONFIG_HEADER due to warnings from autoconf 2.64.
+
+ * tests/locale_test.c
+ Update to work with xx_XX.UTF-8 style locales. Refactoring.
+
+2009-09-22 Erik de Castro Lopo
+
+ * configure.ac
+ Set __USE_MINGW_ANSI_STDIO to 1 when compiling using MinGW compilers.
+ Remove unneeded AC_SUBST.
+ Report Host CPU/OS/vendor.
+
+2009-09-19 Erik de Castro Lopo
+
+ * src/sndfile.c
+ Fix error message string.
+
+ * src/flac.c
+ Add 88200 to the list of supported sample rates.
+
+ * src/ogg.c
+ Fix compiler warning when using gcc-4.5.0.
+
+ * programs/sndfile-info.c tests/utils.tpl
+ Remove WIN32 snprintf #define.
+
+ * src/ima_adpcm.c
+ Fix minor bug in aiff_ima_encode_block. Thanks to Denis Fileev for finding
+ this.
+
+2009-09-16 Erik de Castro Lopo
+
+ * src/caf.c
+ Use the correct C99 format specifier for int64_t.
+
+ * M4/endian.m4
+ Fix detection of CPU endian-ness when cross compiling. Thanks to Pierre
+ Ossman for the bug report.
+
+ * src/caf.c src/sndfile.c
+ Fix reading and writing of PEAK chunks in CAF files.
+
+ * tests/peak_chunk_test.c tests/test_wrapper.sh.in
+ Run peak_chunk_test on CAF files.
+
+2009-09-15 Erik de Castro Lopo
+
+ * src/aiff.c src/wav.c
+ Use the correct C99 format specifier for int64_t.
+
+2009-08-30 Erik de Castro Lopo
+
+ * src/rf64.c src/sndfile.c src/wav.c src/wav_w64.h
+ Apply a patch (massaged slightly) from Uli Franke adding handling of the
+ BEXT chunk in RF64 files.
+
+ * tests/command_test.c
+ Update channel_map_test() function so WAV test passes.
+
+ * src/rf64.c
+ Add channel mapping and ambisonic support.
+
+ * src/sndfile.h
+ Add comments showing correspondance between libsndfile channel map
+ defintiions and those used by Apple and MS.
+
+ Add handling of reading/writing channel map info.
+
+ * tests/command_test.c tests/test_wrapper.sh.in
+ Update channel map tests.
+
+2009-07-29 Erik de Castro Lopo
+
+ * src/common.h
+ Add function psf_isprint() a replacement for the standard C isprint()
+ function which ignores any locale settings and treats all input as ASCII.
+
+ * src/(aiff|common|rf64|sd2|strings|svx|wav).c
+ Use psf_isprint() instead of isprint().
+
+2009-07-13 Erik de Castro Lopo
+
+ * src/command.c
+ Add string descriptions for SF_FORMAT_RF64 and SF_FORMAT_MPC2K.
+
+2009-06-30 Erik de Castro Lopo
+
+ * programs/sndfile-play.c
+ Allow use of Open Sound System audio output under FreeBSD.
+
+2009-06-24 Erik de Castro Lopo
+
+ * configure.ac
+ Add patch from Conrad Parker to add --disable-jack.
+
+2009-05-28 Erik de Castro Lopo
+
+ * src/alaw.c src/float32.c src/htk.c src/pcm.c src/sds.c src/ulaw.c
+ Fix bugs where invalid files can cause a divide by zero error (SIGFPE).
+ Thanks to Sami Liedes for reporting this a Debian bug #530831.
+
+2009-05-26 Erik de Castro Lopo
+
+ * src/chanmap.[ch]
+ New files for channel map decoding/encoding.
+
+2009-05-25 Erik de Castro Lopo
+
+ * configure.ac src/sndfile.h.in
+ Fix MSVC definition of sf_count_t.
+
+2009-05-24 Erik de Castro Lopo
+
+ * src/wav_w64.[ch]
+ Add wavex_channelmask to WAV_PRIVATE struct and add a function to convert
+ an array of SF_CHANNEL_MASK_* values into a bit mask for use in WAV files.
+
+ * src/wav.c
+ Add ability to write the channel mask.
+
+2009-05-23 Erik de Castro Lopo
+
+ * programs/sndfile-info.c
+ Add -c command line option to dump the channel map information.
+
+ * src/wav_w64.c
+ Don't bail from parser if channel map bitmask is faulty.
+
+ * src/common.h src/sndfile.c
+ Remove error code SFE_W64_BAD_CHANNEL_MAP which is not needed any more.
+
+ * src/sndfile.c
+ On SFC_SET_CHANNEL_MAP_INFO pass the channel map command down to container's
+ command handler.
+
+2009-05-22 Erik de Castro Lopo
+
+ * src/sndfile.h.in src/common.h src/sndfile.c src/wav_w64.c
+ Apply a patch from Lennart Poettering (PulseAudio) to allow reading of
+ channel data in WAV and W64 files.
+ Add a test for the above.
+
+2009-05-20 Erik de Castro Lopo
+
+ * src/FAQ.html
+ Update the section about pre-compiled binaries for Win64.
+
+2009-05-14 Erik de Castro Lopo
+
+ * src/common.h src/test_conversions.c
+ Be more careful when including so compiling on pre-C99 platforms
+ (hello Slowlaris) might actually work.
+
+ * NEWS README doc/*.html
+ Updates for 1.0.20.
+
+2009-04-21 Erik de Castro Lopo
+
+ * src/voc.c
+ Fix a bug whereby opening a specially crafted VOC file could result in a
+ heap overflow. Thanks to Tobias Klein (http://www.trapkit.de) for reporting
+ this issue.
+
+ * src/aiff.c
+ Fix potential (heap) buffer overflow when parsing 'MARK' chunk.
+
+2009-04-12 Erik de Castro Lopo
+
+ * tests/stdin_test.c
+ Check psf->error after opening file.
+
+ * src/file_io.c
+ Fix obscure seeking bug reported by Hugh Secker-Walker.
+
+ * tests/utils.tpl
+ Add check of sf_error to test_open_file_or_die().
+
+ * src/sndfile.c
+ Clear error if opening resource fork fails.
+
+2009-04-11 Erik de Castro Lopo
+
+ * tests/alaw_test.c tests/locale_test.c tests/ulaw_test.c
+ Cleanup output.
+
+2009-03-25 Erik de Castro Lopo
+
+ * src/float32.c
+ Fix f2s_clip_array.
+
+2009-03-24 Erik de Castro Lopo
+
+ * src/float32.c
+ In host_read_f2s call convert instead of f2s_array.
+
+ * src/ima_adpcm.c
+ Remove dead code.
+
+ * src/test_ima_oki_adpcm.c examples/generate.c tests/dither_test.c
+ tests/dwvw_test.c tests/fix_this.c tests/generate.c
+ tests/multi_file_test.c
+ Minor fixes.
+
+2009-03-23 Erik de Castro Lopo
+
+ * M4/shave.m4 shave.in
+ Pulled update from upstream.
+
+2009-03-19 Erik de Castro Lopo
+
+ * doc/api.html
+ Add pointers to example programs in source code tarball.
+
+2009-03-17 Erik de Castro Lopo
+
+ * src/common.h
+ Define SF_PLATFORM_S64 for non-gcc compilers with 'long long' type.
+
+ * configure.ac
+ Add documentation for --disable-external-libs and improve error handling
+ for that option.
+
+ * src/sndfile.c src/sndfile.h.in src/create_symbols_file.py
+ Add public function sf_version_string.
+
+ * tests/sfversion.c
+ Test function sf_version_string.
+
+ * M4/shave.m4 shave-libtool.in shave.in
+ Add new files from 'git clone git://git.lespiau.name/shave'.
+
+ * configure.ac
+ Enable shave.
+
+ * src/Makefile.am src/binheader_writef_check.py Octave/*
+ Shave related tweaks.
+
+2009-03-15 Erik de Castro Lopo
+
+ * src/common.h src/caf.c src/sndfile.c
+ Add SF_MAX_CHANNELS (set to 256) and use it.
+
+ * src/sndfile.h.in
+ Check for either _MSCVER or _MSC_VER being defined.
+
+2009-03-04 Erik de Castro Lopo
+
+ * tests/vorbis_test.c
+ Relax test slighly to allow test to pass on more CPUs etc.
+
2009-03-03 Erik de Castro Lopo
* configure.ac
@@ -122,7 +1201,7 @@
* 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.
+ Thanks to Rogério Brito for supplying an example file.
2009-02-14 Erik de Castro Lopo
@@ -683,7 +1762,7 @@
2008-06-14 Erik de Castro Lopo
* src/aiff.c
- Apply a fix from Axel Roebel where if the second loop in the instrument
+ Apply a fix from Axel Röbel 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
@@ -797,7 +1876,7 @@
2008-04-09 Erik de Castro Lopo
* src/aiff.c
- Fix up handling of 'APPL' chunk. Thanks to Axel Roebel for bringing up
+ Fix up handling of 'APPL' chunk. Thanks to Axel Röbel for bringing up
this issue.
2008-04-06 Erik de Castro Lopo
@@ -948,10 +2027,10 @@
Allow use of either LGPL v2.1 or LGPL v3.
* tests/header_test.tpl
- Add header_shrink_test from Axel Roebel.
+ Add header_shrink_test from Axel Röbel.
* src/wav.c
- Add fix from Axel Roebel for writing files with float data but no peak
+ Add fix from Axel Röbel 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
@@ -1408,7 +2487,7 @@
2007-04-14 Erik de Castro Lopo
* src/GSM610/long_term.c src/macbinary3.c tests/cpp_test.cc
- Add patch from André Pang to clean up compiles on OSX.
+ 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
@@ -1421,7 +2500,7 @@
* src/sndfile.hh
Add a static SndfileHandle::formatCheck method as suggested by Jorge
- Jiménez.
+ Jiménez.
2007-04-09 Erik de Castro Lopo
@@ -1926,7 +3005,7 @@
* configure.ac
Fix handling of --enable and --disable configure args. Thanks to Diego
- 'Flameeyes' Pettenò who sent the patch.
+ 'Flameeyes' Pettenò who sent the patch.
2006-03-22 Erik de Castro Lopo
@@ -2097,11 +3176,11 @@
2006-01-10 Erik de Castro Lopo
* examples/sndfile-play.c
- Fix calculation of samples remaining in win32 code. Thanks Axel Roebel.
+ Fix calculation of samples remaining in win32 code. Thanks Axel Röbel.
* src/common.h
Make sure length of header buffer can hold header plus strings. Thanks Axel
- Roebel.
+ Röbel.
2006-01-09 Erik de Castro Lopo
@@ -2315,7 +3394,7 @@
* tests/locale_test.c
Modify the way the unicode strings were encoded so that older compilers
- do not complain. Thanks Axel Roebel.
+ do not complain. Thanks Axel Röbel.
* configure.ac
Bump the version to 1.0.12 for release.
@@ -2544,7 +3623,7 @@
style strings (no terminating character).
* src/aiff.c
- Move to new (correct) AIFF string style. Thanks to Axel Roebel for being
+ Move to new (correct) AIFF string style. Thanks to Axel Röbel for being
so persistent on this issue.
2005-07-11 Erik de Castro Lopo
@@ -2703,7 +3782,7 @@
2005-05-10 Erik de Castro Lopo
* src/ircam.c
- Fix writing of IRCAM files on big endian systems (thanks to Axel Roebel).
+ Fix writing of IRCAM files on big endian systems (thanks to Axel Röbel).
* src/wav.c
Add workaround for files created by the Peak audio editor on Mac which can
@@ -3302,7 +4381,7 @@
2004-04-03 Erik de Castro Lopo
* configure.ac
- Improve printout configuration summary (as suggested by Axel Röbel).
+ Improve printout configuration summary (as suggested by Axel Röbel).
* doc/index.html
Add link to pre-release location.
@@ -3576,7 +4655,7 @@
2003-12-07 Erik de Castro Lopo
* src/file_io.c
- Axel Roebel pointed out that on Mac OSX a pipe is not considered a fifo
+ Axel Röbel pointed out that on Mac OSX a pipe is not considered a fifo
(S_ISFIFO (st.st_mode) is false) but a socket (S_ISSOCK (st.st_mode) is
true). The test has therefore been changed to is S_ISREG and anything
which which does not return true for S_ISREG is considered a pipe.
@@ -3780,11 +4859,11 @@
* src/aiff.c
Fixed a bug where opening a file with a non-trival header in SFM_RDWR mode
- would over-write part of the header. Thanks to Axel Roebel for pointing
+ would over-write part of the header. Thanks to Axel Röbel for pointing
this out. Axel also provided a patch to fix this but I came up with a
neater and more general solution.
Return error when openning an AIFF file with data after the SSND chunk
- (Thanks Axel Roebel).
+ (Thanks Axel Röbel).
* tests/aiff_rw_test.c
Improvements to test program which will later allow it to be generalised to
@@ -4068,28 +5147,28 @@
* src/common.c src/common.h src/file_io.h
Added is_pipe field to SF_PRIVATE and declaration of psf_is_pipe()
- function. (Axel Roebel)
+ function. (Axel Röbel)
* src/sndfile.c
- Fixed determination of whether the file is a pipe. (Axel Roebel)
+ Fixed determination of whether the file is a pipe. (Axel Röbel)
* src/paf.c
- Force paf24 to start with undefined mode. (Axel Roebel)
+ Force paf24 to start with undefined mode. (Axel Röbel)
* tests/pipe_test.c
Mods to make this test work and actually do the test on RAW files. (Axel
- Roebel).
+ Röbel).
2003-05-05 Erik de Castro Lopo
* src/sndfile.c
Fixed a potential bug where psf->sf.seekable was being set to FALSE when
operating on stdin or stdout but then the default initialiser was reseting
- it to TRUE. Thanks to Axel Roebel.
+ it to TRUE. Thanks to Axel Röbel.
* src/aiff.c
Fixed a bug in the header parser where it was not handling an odd length
- COMM chunk correctly. Thanks to Axel Roebel.
+ COMM chunk correctly. Thanks to Axel Röbel.
* src/test_file_io.c
Add more tests.
@@ -7013,7 +8092,7 @@ This is the boundary between version 1 of the library above and version 0 below.
* src/paf.c src/wav_gsm610.c
Removed two printf()s which had escaped notice for some time (thanks
- Sigbjørn Skjæret).
+ Sigbjørn Skjæret).
2001-07-19 Erik de Castro Lopo
@@ -7333,7 +8412,7 @@ This is the boundary between version 1 of the library above and version 0 below.
* src/sndfile.h
Removed prototype of unimplemented function sf_get_info(). Added prototype
- for sf_error_number() Thanks to Sigbjørn Skjæret for spotting these.
+ for sf_error_number() Thanks to Sigbjørn Skjæret for spotting these.
2000-08-18 Erik de Castro Lopo
@@ -7343,8 +8422,8 @@ This is the boundary between version 1 of the library above and version 0 below.
2000-08-15 Erik de Castro Lopo
* src/sndfile.c
- Fixed a leak of FILE* pointers in sf_open_write(). Thanks to Sigbjørn
- Skjæret for spotting this one.
+ Fixed a leak of FILE* pointers in sf_open_write(). Thanks to Sigbjørn
+ Skjæret for spotting this one.
2000-08-13 Erik de Castro Lopo
@@ -7438,7 +8517,7 @@ This is the boundary between version 1 of the library above and version 0 below.
* src/wav.c
Fixed bug in GSM 6.10 handling for big-endian machines. Thanks
- to Sigbjørn Skjæret for reporting this.
+ to Sigbjørn Skjæret for reporting this.
2000-04-25 Erik de Castro Lopo
@@ -7620,7 +8699,7 @@ This is the boundary between version 1 of the library above and version 0 below.
* src/aiff.c
Fixed calculation of datalength when reading SSND chunk. Thanks to
- Sigbjørn Skjæret for pointing out this error.
+ Sigbjørn Skjæret for pointing out this error.
1999-07-29 Erik de Castro Lopo
diff --git a/libs/libsndfile/M4/add_cflags.m4 b/libs/libsndfile/M4/add_cflags.m4
index 7b6b555c7f..55a326c580 100644
--- a/libs/libsndfile/M4/add_cflags.m4
+++ b/libs/libsndfile/M4/add_cflags.m4
@@ -1,17 +1,18 @@
-dnl @synopsis AC_ADD_CFLAGS
+dnl @synopsis MN_ADD_CFLAGS
dnl
dnl Add the given option to CFLAGS, if it doesn't break the compiler
-AC_DEFUN([AC_ADD_CFLAGS],
+AC_DEFUN([MN_ADD_CFLAGS],
[AC_MSG_CHECKING([if $CC accepts $1])
ac_add_cflags__old_cflags="$CFLAGS"
- CFLAGS="$CFLAGS $1"
+ CFLAGS="$1"
AC_TRY_LINK([
#include
],
[puts("Hello, World!"); return 0;],
- AC_MSG_RESULT([yes]),
+ AC_MSG_RESULT([yes])
+ CFLAGS="$ac_add_cflags__old_cflags $1",
AC_MSG_RESULT([no])
- CFLAGS="$ac_add_cflags__old_cflags"
+ CFLAGS="$ac_add_cflags__old_cflags"
)
-])# AC_ADD_CFLAGS
+])# MN_ADD_CFLAGS
diff --git a/libs/libsndfile/M4/add_cxxflags.m4 b/libs/libsndfile/M4/add_cxxflags.m4
index 5e6489faf2..1c0a4deb96 100644
--- a/libs/libsndfile/M4/add_cxxflags.m4
+++ b/libs/libsndfile/M4/add_cxxflags.m4
@@ -1,17 +1,19 @@
-dnl @synopsis AC_ADD_CXXFLAGS
+dnl @synopsis MN_ADD_CXXFLAGS
dnl
dnl Add the given option to CXXFLAGS, if it doesn't break the compiler
-AC_DEFUN([AC_ADD_CXXFLAGS],
+AC_DEFUN([MN_ADD_CXXFLAGS],
[AC_MSG_CHECKING([if $CXX accepts $1])
+ AC_LANG_ASSERT([C++])
ac_add_cxxflags__old_cxxflags="$CXXFLAGS"
- CXXFLAGS="$CXXFLAGS $1"
+ CXXFLAGS="$1"
AC_TRY_LINK([
#include
],
[puts("Hello, World!"); return 0;],
- AC_MSG_RESULT([yes]),
+ AC_MSG_RESULT([yes])
+ CXXFLAGS="$ac_add_cxxflags__old_cxxflags $1",
AC_MSG_RESULT([no])
- CXXFLAGS="$ac_add_cxxflags__old_cxxflags"
+ CXXFLAGS="$ac_add_cxxflags__old_cxxflags"
)
-])# AC_ADD_CXXFLAGS
+])# MN_ADD_CXXFLAGS
diff --git a/libs/libsndfile/M4/clip_mode.m4 b/libs/libsndfile/M4/clip_mode.m4
index 57c94a9626..4556b937a0 100644
--- a/libs/libsndfile/M4/clip_mode.m4
+++ b/libs/libsndfile/M4/clip_mode.m4
@@ -1,4 +1,4 @@
-dnl @synopsis AC_C_CLIP_MODE
+dnl @synopsis MN_C_CLIP_MODE
dnl
dnl Determine the clipping mode when converting float to int.
dnl @version 1.0 May 17 2003
@@ -20,7 +20,7 @@ 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_DEFUN([MN_C_CLIP_MODE],
[AC_CACHE_CHECK(processor clipping capabilities,
ac_cv_c_clip_type,
@@ -119,6 +119,6 @@ case "$ac_cv_c_clip_positive$ac_cv_c_clip_negative" in
)
]
-)# AC_C_CLIP_MODE
+)# MN_C_CLIP_MODE
diff --git a/libs/libsndfile/M4/endian.m4 b/libs/libsndfile/M4/endian.m4
index b3a4589764..5d766ff39e 100644
--- a/libs/libsndfile/M4/endian.m4
+++ b/libs/libsndfile/M4/endian.m4
@@ -1,4 +1,4 @@
-dnl @synopsis AC_C_FIND_ENDIAN
+dnl @synopsis MN_C_FIND_ENDIAN
dnl
dnl Determine endian-ness of target processor.
dnl @version 1.1 Mar 03 2002
@@ -20,7 +20,7 @@ dnl 2) If 1) fails, look in and .
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_DEFUN([MN_C_FIND_ENDIAN],
[AC_CACHE_CHECK(processor byte ordering,
ac_cv_c_byte_order,
@@ -92,13 +92,11 @@ if test $ac_cv_c_byte_order = unknown ; then
[
case "$target_cpu" in
alpha* | i?86* | mipsel* | ia64*)
- ac_cv_c_big_endian=0
- ac_cv_c_little_endian=1
+ ac_cv_c_byte_order=little
;;
m68* | mips* | powerpc* | hppa* | sparc*)
- ac_cv_c_big_endian=1
- ac_cv_c_little_endian=0
+ ac_cv_c_byte_order=big
;;
esac
@@ -116,7 +114,6 @@ if test $ac_cv_c_byte_order = unknown ; then
return (u.c [sizeof (long) - 1] == 1);
}
]], , ac_cv_c_byte_order=big,
- ac_cv_c_byte_order=unknown
)
AC_TRY_RUN(
@@ -129,7 +126,6 @@ if test $ac_cv_c_byte_order = unknown ; then
u.l = 1 ;
return (u.c [0] == 1);
}]], , ac_cv_c_byte_order=little,
- ac_cv_c_byte_order=unknown
)
fi
fi
@@ -154,6 +150,6 @@ else
fi
]
-)# AC_C_FIND_ENDIAN
+)# MN_C_FIND_ENDIAN
diff --git a/libs/libsndfile/M4/extra_largefile.m4 b/libs/libsndfile/M4/extra_largefile.m4
index 47401f85a4..3e614c3f70 100644
--- a/libs/libsndfile/M4/extra_largefile.m4
+++ b/libs/libsndfile/M4/extra_largefile.m4
@@ -6,8 +6,8 @@ dnl http://www.sas.com/standards/large.file/x_open.20Mar96.html
dnl Written by Paul Eggert .
dnl Internal subroutine of AC_SYS_EXTRA_LARGEFILE.
-dnl AC_SYS_EXTRA_LARGEFILE_FLAGS(FLAGSNAME)
-AC_DEFUN([AC_SYS_EXTRA_LARGEFILE_FLAGS],
+dnl MN_SYS_EXTRA_LARGEFILE_FLAGS(FLAGSNAME)
+AC_DEFUN([MN_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` || {
@@ -67,9 +67,9 @@ AC_DEFUN([AC_SYS_EXTRA_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)
+ MN_SYS_EXTRA_LARGEFILE_FLAGS(CFLAGS)
+ MN_SYS_EXTRA_LARGEFILE_FLAGS(LDFLAGS)
+ MN_SYS_EXTRA_LARGEFILE_FLAGS(LIBS)
for ac_flag in $ac_cv_sys_largefile_CFLAGS no; do
case "$ac_flag" in
diff --git a/libs/libsndfile/M4/flexible_array.m4 b/libs/libsndfile/M4/flexible_array.m4
index 7f558d3ebd..661da17b23 100644
--- a/libs/libsndfile/M4/flexible_array.m4
+++ b/libs/libsndfile/M4/flexible_array.m4
@@ -1,4 +1,4 @@
-dnl @synopsis AC_C99_FLEXIBLE_ARRAY
+dnl @synopsis MN_C99_FLEXIBLE_ARRAY
dnl
dnl Dose the compiler support the 1999 ISO C Standard "stuct hack".
dnl @version 1.1 Mar 15 2004
@@ -10,7 +10,7 @@ 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_DEFUN([MN_C99_FLEXIBLE_ARRAY],
[AC_CACHE_CHECK(C99 struct flexible array support,
ac_cv_c99_flexible_array,
@@ -28,5 +28,5 @@ AC_TRY_LINK([[
ac_cv_c99_flexible_array=yes,
ac_cv_c99_flexible_array=no
))]
-) # AC_C99_FLEXIBLE_ARRAY
+) # MN_C99_FLEXIBLE_ARRAY
diff --git a/libs/libsndfile/M4/gcc_version.m4 b/libs/libsndfile/M4/gcc_version.m4
index 84a5ba8d74..1ef28d9316 100644
--- a/libs/libsndfile/M4/gcc_version.m4
+++ b/libs/libsndfile/M4/gcc_version.m4
@@ -1,4 +1,4 @@
-dnl @synopsis AC_GCC_VERSION
+dnl @synopsis MN_GCC_VERSION
dnl
dnl Find the version of gcc.
dnl @version 1.0 Nov 05 2007
@@ -11,7 +11,7 @@ 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],
+AC_DEFUN([MN_GCC_VERSION],
[
if test "x$ac_cv_c_compiler_gnu" = "xyes" ; then
@@ -29,5 +29,5 @@ AC_SUBST(GCC_VERSION)
AC_SUBST(GCC_MAJOR_VERSION)
AC_SUBST(GCC_MINOR_VERSION)
-])# AC_GCC_VERSION
+])# MN_GCC_VERSION
diff --git a/libs/libsndfile/M4/llrint.m4 b/libs/libsndfile/M4/llrint.m4
index 0f5ce698c4..66be206187 100644
--- a/libs/libsndfile/M4/llrint.m4
+++ b/libs/libsndfile/M4/llrint.m4
@@ -1,4 +1,4 @@
-dnl @synopsis AC_C99_FUNC_LLRINT
+dnl @synopsis MN_C99_FUNC_LLRINT
dnl
dnl Check whether C99's llrint function is available.
dnl @version 1.1 Sep 30 2002
@@ -10,7 +10,7 @@ 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_DEFUN([MN_C99_FUNC_LLRINT],
[AC_CACHE_CHECK(for llrint,
ac_cv_c99_llrint,
[
@@ -34,5 +34,5 @@ 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
+])# MN_C99_FUNC_LLRINT
diff --git a/libs/libsndfile/M4/lrint.m4 b/libs/libsndfile/M4/lrint.m4
index 3e3319e15b..c2c21d60f4 100644
--- a/libs/libsndfile/M4/lrint.m4
+++ b/libs/libsndfile/M4/lrint.m4
@@ -1,4 +1,4 @@
-dnl @synopsis AC_C99_FUNC_LRINT
+dnl @synopsis MN_C99_FUNC_LRINT
dnl
dnl Check whether C99's lrint function is available.
dnl @version 1.3 Feb 12 2002
@@ -10,7 +10,7 @@ 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_DEFUN([MN_C99_FUNC_LRINT],
[AC_CACHE_CHECK(for lrint,
ac_cv_c99_lrint,
[
@@ -33,5 +33,5 @@ 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
+])# MN_C99_FUNC_LRINT
diff --git a/libs/libsndfile/M4/lrintf.m4 b/libs/libsndfile/M4/lrintf.m4
index f921e9ed29..04f4d6603c 100644
--- a/libs/libsndfile/M4/lrintf.m4
+++ b/libs/libsndfile/M4/lrintf.m4
@@ -1,4 +1,4 @@
-dnl @synopsis AC_C99_FUNC_LRINTF
+dnl @synopsis MN_C99_FUNC_LRINTF
dnl
dnl Check whether C99's lrintf function is available.
dnl @version 1.3 Feb 12 2002
@@ -10,7 +10,7 @@ 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_DEFUN([MN_C99_FUNC_LRINTF],
[AC_CACHE_CHECK(for lrintf,
ac_cv_c99_lrintf,
[
@@ -33,5 +33,5 @@ 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
+])# MN_C99_FUNC_LRINTF
diff --git a/libs/libsndfile/M4/mkoctfile_version.m4 b/libs/libsndfile/M4/mkoctfile_version.m4
index 3704398298..c17333ea25 100644
--- a/libs/libsndfile/M4/mkoctfile_version.m4
+++ b/libs/libsndfile/M4/mkoctfile_version.m4
@@ -1,4 +1,4 @@
-dnl @synopsis AC_MKOCTFILE_VERSION
+dnl @synopsis OCTAVE_MKOCTFILE_VERSION
dnl
dnl Find the version of mkoctfile.
dnl @version 1.0 Aug 23 2007
@@ -11,7 +11,7 @@ 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_DEFUN([OCTAVE_MKOCTFILE_VERSION],
[
@@ -34,5 +34,5 @@ if test "x$ac_cv_prog_HAVE_MKOCTFILE" = "xyes" ; then
AC_SUBST(MKOCTFILE)
AC_SUBST(MKOCTFILE_VERSION)
-])# AC_MKOCTFILE_VERSION
+])# OCTAVE_MKOCTFILE_VERSION
diff --git a/libs/libsndfile/M4/octave.m4 b/libs/libsndfile/M4/octave.m4
index 164653456d..216306feab 100644
--- a/libs/libsndfile/M4/octave.m4
+++ b/libs/libsndfile/M4/octave.m4
@@ -102,7 +102,7 @@ dnl Default to no.
OCTAVE_BUILD=no
AC_OCTAVE_VERSION
-AC_MKOCTFILE_VERSION
+OCTAVE_MKOCTFILE_VERSION
AC_OCTAVE_CONFIG_VERSION
prog_concat="$ac_cv_prog_HAVE_OCTAVE$ac_cv_prog_HAVE_OCTAVE_CONFIG$ac_cv_prog_HAVE_MKOCTFILE"
diff --git a/libs/libsndfile/Makefile.am b/libs/libsndfile/Makefile.am
index 4fe98eaad4..c7c1474403 100644
--- a/libs/libsndfile/Makefile.am
+++ b/libs/libsndfile/Makefile.am
@@ -1,29 +1,41 @@
-## 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)
-
-
+## 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 man doc Win32 src $(octave_dir) examples regtest tests programs
+DIST_SUBDIRS = M4 man doc Win32 src Octave examples regtest tests programs
+
+EXTRA_DIST = libsndfile.spec.in sndfile.pc.in
+
+CLEANFILES = *~
+
+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)
+
+checkprograms :
+ (cd src ; make libsndfile.la checkprograms)
+ (cd tests ; make checkprograms)
+
+testprogs :
+ (cd src ; make testprogs)
+ (cd tests ; make testprogs)
+
+
+test-tarball : build-test-tarball.mk
+ make all
+ make -f build-test-tarball.mk
diff --git a/libs/libsndfile/Mingw-make-dist.sh b/libs/libsndfile/Mingw-make-dist.sh
deleted file mode 100755
index f2a6474233..0000000000
--- a/libs/libsndfile/Mingw-make-dist.sh
+++ /dev/null
@@ -1,116 +0,0 @@
-#!/bin/sh
-
-# Copyright (C) 2006 Erik de Castro Lopo
-#
-# 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.
-
-set -e
-
-function unix_to_dos {
- sed -e "s/\n/\r\n/" $1 > temp_file
- mv -f temp_file $1
-}
-
-if [ $# -lt 1 ] || [ $# -gt 2 ]; then
- echo "Usage : Mingw-make-dist.sh ."
- exit 1
- fi
-
-TARGZ=$1
-if [ ! -f $TARGZ ]; then
- echo "Can't find source tarball."
- fi
-
-TARGZ=$1
-if [ ! -f $TARGZ.asc ]; then
- echo "Can't find source tarball signature."
- fi
-
-UNAME=`uname -s`
-if [ x$UNAME != "xMINGW32_NT-5.1" ]; then
- echo "Not able to build Win32 binaries on this platform."
- fi
-
-echo "Building MinGW binary/source zip file."
-
-VERSION=`pwd | sed -e "s#.*/##" | sed -e s/libsndfile-//`
-BUILD=`echo $VERSION | sed -e "s/\./_/g"`
-INSTALL="libsndfile-$BUILD"
-ZIPNAME="$INSTALL.zip"
-
-if [ -z "$BUILD" ]; then
- echo "Bad BUILD variable : '$BUILD'"
- exit 1
- fi
-
-if [ ! -d $INSTALL/ ]; then
- mkdir $INSTALL
- fi
-
-if [ ! -f config.status ]; then
- ./configure --prefix=`pwd`/$INSTALL/
-else
- teststr=`grep "with options" config.status | grep -- --prefix=`
- if [ -z "$teststr" ]; then
- # --disable-static doesn't work.
- ./configure --prefix=`pwd`/$INSTALL/
- fi
- fi
-
-if [ ! -f src/.libs/libsndfile-1.dll ]; then
- make all check
- fi
-
-if [ ! -f $INSTALL/bin/libsndfile-1.dll ]; then
- make install
- rm -f $INSTALL/bin/sndfile-regtest.exe
- strip $INSTALL/bin/*.*
- mv $INSTALL/bin/*.* $INSTALL/include/*.* $INSTALL/
- rmdir $INSTALL/bin
- rm -rf $INSTALL/lib
- rmdir $INSTALL/include
- cp src/libsndfile.def $INSTALL/libsndfile-1.def
- cp Win32/README-precompiled-dll.txt Win32/testprog.c $INSTALL/
- unix_to_dos $INSTALL/libsndfile-1.def
- unix_to_dos $INSTALL/sndfile.h
- unix_to_dos $INSTALL/README-precompiled-dll.txt
- unix_to_dos $INSTALL/testprog.c
- fi
-
-if [ ! -f $INSTALL/libsndfile-$VERSION.tar.gz ]; then
- cp $TARGZ $INSTALL/
- if [ -f $TARGZ.asc ]; then
- cp $TARGZ.asc $INSTALL/
- fi
- fi
-
-if [ ! -f $ZIPNAME ]; then
- zip -r $ZIPNAME $INSTALL/
- fi
-
diff --git a/libs/libsndfile/NEWS b/libs/libsndfile/NEWS
index 37bf671e4c..9626d45166 100644
--- a/libs/libsndfile/NEWS
+++ b/libs/libsndfile/NEWS
@@ -1,3 +1,37 @@
+Version 1.0.25 (2011-07-13)
+ * Fix for Secunia Advisory SA45125, heap overflow in PAF file handler.
+ * Accept broken WAV files with blockalign == 0.
+ * Minor bug fixes and improvements.
+
+Version 1.0.24 (2011-03-23)
+ * WAV files now have an 18 byte u-law and A-law fmt chunk.
+ * Document virtual I/O functionality.
+ * Two new methods rawHandle() and takeOwnership() in sndfile.hh.
+ * AIFF fix for non-zero offset value in SSND chunk.
+ * Minor bug fixes and improvements.
+
+Version 1.0.23 (2010-10-10)
+ * Add version metadata to Windows DLL.
+ * Add a missing 'inline' to sndfile.hh.
+ * Update docs.
+ * Minor bug fixes and improvements.
+
+Version 1.0.22 (2010-10-04)
+ * Couple of fixes for SDS file writer.
+ * Fixes arising from static analysis.
+ * Handle FLAC files with ID3 meta data at start of file.
+ * Handle FLAC files which report zero length.
+ * Other minor bug fixes and improvements.
+
+Version 1.0.21 (2009-12-13)
+ * Add a couple of new binary programs to programs/ dir.
+ * Remove sndfile-jackplay (now in sndfile-tools package).
+ * Add windows only function sf_wchar_open().
+ * Bunch of minor bug fixes.
+
+Version 1.0.20 (2009-05-14)
+ * Fix potential heap overflow in VOC file parser (Tobias Klein, http://www.trapkit.de/).
+
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.
diff --git a/libs/libsndfile/Octave/Makefile.am b/libs/libsndfile/Octave/Makefile.am
index d905cf6d81..40968dda60 100644
--- a/libs/libsndfile/Octave/Makefile.am
+++ b/libs/libsndfile/Octave/Makefile.am
@@ -30,13 +30,19 @@ oct_module_files = sndfile.oct PKG_ADD
noinst_DATA = $(oct_module_files)
+# Used by shave which cleans up automake generated Makefile output.
+V = @
+Q = $(V:1=)
+QUIET_GEN = $(Q:@=@echo ' GEN '$@;)
+
+
# 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/$@
+ $(QUIET_GEN) $(MKOCTFILE) -v $(INCLUDES) $(top_builddir)/Octave/$+ -L$(SNDFILEDIR)/.libs -L$(SNDFILEDIR) -lsndfile -o $(top_builddir)/Octave/$@ > /dev/null
sndfile.o : sndfile.cc
- $(MKOCTFILE) -v $(INCLUDES) -c $+ -o $(top_builddir)/Octave/$@
+ $(QUIET_GEN) $(MKOCTFILE) -v $(INCLUDES) -c $+ -o $(top_builddir)/Octave/$@ > /dev/null
# Allow for the test being run in the build dir, but the test script
# being located in the source dir.
diff --git a/libs/libsndfile/Octave/octave_test.m b/libs/libsndfile/Octave/octave_test.m
index 30b60139b4..25a922e897 100644
--- a/libs/libsndfile/Octave/octave_test.m
+++ b/libs/libsndfile/Octave/octave_test.m
@@ -1,4 +1,4 @@
-# Copyright (C) 2007 Erik de Castro Lopo
+# Copyright (C) 2007-2011 Erik de Castro Lopo
#
# 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,9 +16,7 @@
# These tests are nowhere near comprehensive.
-printf ("\n\n\n\n\n\n\n") ;
-
-printf (" Running Octave tests : ") ;
+printf (" Running Octave tests : ") ;
fflush (stdout) ;
filename = "whatever" ;
@@ -51,6 +49,4 @@ if (err > 1e-7)
printf ("ok") ;
-printf ("\n\n\n\n\n\n\n") ;
-
unlink (filename) ;
diff --git a/libs/libsndfile/Octave/octave_test.sh b/libs/libsndfile/Octave/octave_test.sh
index 6c8bd10d02..319d86b81e 100755
--- a/libs/libsndfile/Octave/octave_test.sh
+++ b/libs/libsndfile/Octave/octave_test.sh
@@ -18,12 +18,10 @@ elif [ -f "../src/.libs/libsndfile.dylib" ]; then
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)`
diff --git a/libs/libsndfile/Octave/sndfile.cc b/libs/libsndfile/Octave/sndfile.cc
index e75e3279bd..6e9cd44cc9 100644
--- a/libs/libsndfile/Octave/sndfile.cc
+++ b/libs/libsndfile/Octave/sndfile.cc
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 2007 Erik de Castro Lopo
+** Copyright (C) 2007-2011 Erik de Castro Lopo
**
** 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
@@ -367,7 +367,7 @@ string_of_minor_format (int format)
case SF_FORMAT_G723_40 : return "g723_40" ;
default : break ;
} ;
-
+
return "unknown" ;
} /* string_of_minor_format */
diff --git a/libs/libsndfile/Octave/sndfile_load.m b/libs/libsndfile/Octave/sndfile_load.m
index d13c21a276..c66198fa35 100644
--- a/libs/libsndfile/Octave/sndfile_load.m
+++ b/libs/libsndfile/Octave/sndfile_load.m
@@ -1,4 +1,4 @@
-## Copyright (C) 2002 Erik de Castro Lopo
+## Copyright (C) 2002-2011 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
@@ -33,7 +33,7 @@ samplingrate = -1 ;
wavedata = -1 ;
-eval (sprintf ('load -f %s', filename)) ;
+eval (sprintf ('load -f %s', filename)) ;
if (samplerate > 0),
fs = samplerate ;
@@ -42,7 +42,7 @@ elseif (samplingrate > 0),
else
error ("Not able to find sample rate.") ;
endif
-
+
if (max (size (wavedata)) > 1),
data = wavedata ;
else
diff --git a/libs/libsndfile/Octave/sndfile_play.m b/libs/libsndfile/Octave/sndfile_play.m
index c0631d94c1..e8a34a74cb 100644
--- a/libs/libsndfile/Octave/sndfile_play.m
+++ b/libs/libsndfile/Octave/sndfile_play.m
@@ -1,4 +1,4 @@
-## Copyright (C) 2002 Erik de Castro Lopo
+## Copyright (C) 2002-2011 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
diff --git a/libs/libsndfile/Octave/sndfile_save.m b/libs/libsndfile/Octave/sndfile_save.m
index cddbc648b2..5b7e7c7d0f 100644
--- a/libs/libsndfile/Octave/sndfile_save.m
+++ b/libs/libsndfile/Octave/sndfile_save.m
@@ -1,4 +1,4 @@
-## Copyright (C) 2002 Erik de Castro Lopo
+## Copyright (C) 2002-2011 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
diff --git a/libs/libsndfile/README b/libs/libsndfile/README
index aeb597d410..06767113da 100644
--- a/libs/libsndfile/README
+++ b/libs/libsndfile/README
@@ -1,4 +1,4 @@
-This is libsndfile, 1.0.19
+This is libsndfile, 1.0.25
libsndfile is a library of C routines for reading and writing
files containing sampled audio data.
diff --git a/libs/libsndfile/TODO b/libs/libsndfile/TODO
deleted file mode 100644
index f6da6dff6a..0000000000
--- a/libs/libsndfile/TODO
+++ /dev/null
@@ -1,42 +0,0 @@
-Here's a list of what I (erikd AT mega-nerd DOT com) think needs to be
-done. The list is by no means exhaustive and people are encouraged to
-email me with suggestions.
-
- o Add pipe in/out capabilities. libsndfile should be able to read
- its input from a pipe and write its output to a pipe.
-
- o Add checks of the error state after fseek???? Use ferror ().
-
- o Modify tests/lossy_comp_test.c to add tests for stereo files.
-
- o Testing compilation and correctness on more platforms.
-
- o Improve testing routines. Must test all combinations of inputs
- and outputs.
-
- o Test sf_seek function on write???
-
- o Add more sound file formats. People should contact me with their
- requirements.
-
- o Add support for accessing sound formats with multiple audio
- data sections (ie samples within tracker files, Soundfont II and
- multi-sample sampler formats).
-
- o Add an interface to allow reading and writing of sample loop points
- and other info within AIFF and other file formats. This must be a
- general solution.
-
- o Improve documentation. Is HTML documentation good enough?
-
- o Look into the possibility of optional sample rate convert on file
- read.
-
-As I am the person who knows libsndfile best, I can probably implement
-any new features faster than anybody else (and you can spend your time
-writing applications with libsndfile). All I need is some
-documentation and some sample files. Please contact me before emailing
-me documentation and sample files. I would much rather pull them off
-the web than have them clogging up my email inbox.
-
-
diff --git a/libs/libsndfile/acinclude.m4 b/libs/libsndfile/acinclude.m4
deleted file mode 100644
index 2f27dbd9ef..0000000000
--- a/libs/libsndfile/acinclude.m4
+++ /dev/null
@@ -1,627 +0,0 @@
-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 .
-
-
-m4_include([M4/gcc_version.m4])
-m4_include([M4/octave.m4])
-m4_include([M4/mkoctfile_version.m4])
-
-
-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
- ])
-
-
-
-
-
-
-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
-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 .
-dnl 2) If 1) fails, look in and .
-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 which should set BYTE_ORDER.
-
- [AC_TRY_LINK([
- #include
- #if BYTE_ORDER != LITTLE_ENDIAN
- not big endian
- #endif
- ], return 0 ;,
- ac_cv_c_byte_order=little
- )]
-
- [AC_TRY_LINK([
- #include
- #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
- #include
- #if !BYTE_ORDER || !BIG_ENDIAN || !LITTLE_ENDIAN
- bogus endian macros
- #endif
- ], return 0 ;,
-
- [AC_TRY_LINK([
- #include
- #include
- #if BYTE_ORDER != LITTLE_ENDIAN
- not big endian
- #endif
- ], return 0 ;,
- ac_cv_c_byte_order=little
- )]
-
- [AC_TRY_LINK([
- #include
- #include
- #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
-
- fi
-
-)# AC_C_FIND_ENDIAN
-
-
-
-
-
-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
-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
- 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
-
-
-
-
-
-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
-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
-], 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
-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
-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,
-[
-AC_TRY_LINK([
-#define _ISOC9X_SOURCE 1
-#define _ISOC99_SOURCE 1
-#define __USE_ISOC99 1
-#define __USE_ISOC9X 1
-
-#include
-], if (!lrintf(3.14159)) lrintf(2.7183);, ac_cv_c99_lrintf=yes, ac_cv_c99_lrintf=no)
-])
-
-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
-
-
-
-
-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
-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,
-[
-AC_TRY_LINK([
-#define _ISOC9X_SOURCE 1
-#define _ISOC99_SOURCE 1
-#define __USE_ISOC99 1
-#define __USE_ISOC9X 1
-
-#include
-#include
-], int64_t x ; x = llrint(3.14159) ;, ac_cv_c99_llrint=yes, ac_cv_c99_llrint=no)
-])
-
-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
-
-
-
-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
-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
- 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
- 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
-
-
-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 ],
- [printf("Hello, World!\n"); return 0;],
- AC_MSG_RESULT([yes]),
- AC_MSG_RESULT([no])
- CFLAGS="$ac_add_cflags__old_cflags")
-])
-
-
-
-dnl PKG_CHECK_MODULES(GSTUFF, gtk+-2.0 >= 1.3 glib = 1.3.4, action-if, action-not)
-dnl defines GSTUFF_LIBS, GSTUFF_CFLAGS, see pkg-config man page
-dnl also defines GSTUFF_PKG_ERRORS on error
-AC_DEFUN([PKG_CHECK_MODULES], [
- succeeded=no
-
- if test -z "$PKG_CONFIG"; then
- AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
- fi
-
- if test "$PKG_CONFIG" = "no" ; then
- echo "*** The pkg-config script could not be found. Make sure it is"
- echo "*** in your path, or set the PKG_CONFIG environment variable"
- echo "*** to the full path to pkg-config."
- echo "*** Or see http://www.freedesktop.org/software/pkgconfig to get pkg-config."
- else
- PKG_CONFIG_MIN_VERSION=0.9.0
- if $PKG_CONFIG --atleast-pkgconfig-version $PKG_CONFIG_MIN_VERSION; then
- AC_MSG_CHECKING(for $2)
-
- if $PKG_CONFIG --exists "$2" ; then
- AC_MSG_RESULT(yes)
- succeeded=yes
-
- AC_MSG_CHECKING($1_CFLAGS)
- $1_CFLAGS=`$PKG_CONFIG --cflags "$2"`
- AC_MSG_RESULT($$1_CFLAGS)
-
- AC_MSG_CHECKING($1_LIBS)
- $1_LIBS=`$PKG_CONFIG --libs "$2"`
- AC_MSG_RESULT($$1_LIBS)
- else
- $1_CFLAGS=""
- $1_LIBS=""
- ## If we have a custom action on failure, don't print errors, but
- ## do set a variable so people can do so.
- $1_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "$2"`
- ifelse([$4], ,echo $$1_PKG_ERRORS,)
- fi
-
- AC_SUBST($1_CFLAGS)
- AC_SUBST($1_LIBS)
- else
- echo "*** Your version of pkg-config is too old. You need version $PKG_CONFIG_MIN_VERSION or newer."
- echo "*** See http://www.freedesktop.org/software/pkgconfig"
- fi
- fi
-
- if test $succeeded = yes; then
- ifelse([$3], , :, [$3])
- else
- ifelse([$4], , AC_MSG_ERROR([Library requirements ($2) not met; consider adjusting the PKG_CONFIG_PATH environment variable if your libraries are in a nonstandard prefix so pkg-config can find them.]), [$4])
- 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: bc38294d-bb5c-42ad-90b9-779def5eaab7
-
-)dnl
diff --git a/libs/libsndfile/configure.ac b/libs/libsndfile/configure.ac
index 4bdbfd0969..20ba55a552 100644
--- a/libs/libsndfile/configure.ac
+++ b/libs/libsndfile/configure.ac
@@ -1,30 +1,45 @@
-# Copyright (C) 1999-2008 Erik de Castro Lopo (erikd AT mega-nerd DOT com).
+# Copyright (C) 1999-2011 Erik de Castro Lopo (erikd AT mega-nerd DOT com).
dnl Require autoconf version
AC_PREREQ(2.57)
-AC_INIT([libsndfile],[1.0.19],[erikd@mega-nerd.com])
+AC_INIT([libsndfile],[1.0.25],[sndfile@mega-nerd.com],
+ [libsndfile],[http://www.mega-nerd.com/libsndfile/])
# Put config stuff in Cfg.
AC_CONFIG_AUX_DIR(Cfg)
-CFLAGS="$CFLAGS $CONFIGURE_CFLAGS"
-CXXFLAGS="$CXXFLAGS $CONFIGURE_CXXFLAGS"
-LDFLAGS="$LDFLAGS $CONFIGURE_LDFLAGS"
-
AC_CONFIG_SRCDIR([src/sndfile.c])
AC_CANONICAL_TARGET([])
-AM_INIT_AUTOMAKE
AC_CONFIG_MACRO_DIR([M4])
-
AC_CONFIG_HEADERS([src/config.h])
+AM_INIT_AUTOMAKE($PACKAGE_NAME,$PACKAGE_VERSION)
+AM_SILENT_RULES([yes])
+
dnl Add parameters for aclocal
AC_SUBST(ACLOCAL_AMFLAGS, "-I M4")
AC_LANG([C])
+AC_PROG_CC
+AM_PROG_CC_C_O
+AC_PROG_CXX
+AC_PROG_SED
+
+# Do not check for F77.
+define([AC_LIBTOOL_LANG_F77_CONFIG], [:])dnl
+
+AM_PROG_LIBTOOL
+LT_PROG_RC
+
+AC_CHECK_PROG(HAVE_AUTOGEN, autogen, yes, no)
+AC_CHECK_PROG(HAVE_WINE, wine, yes, no)
+
+AC_PROG_INSTALL
+AC_PROG_LN_S
+
#------------------------------------------------------------------------------------
# Rules for library version information:
#
@@ -41,22 +56,12 @@ AC_LANG([C])
# 6. If any interfaces have been removed since the last public release, then set age
# to 0.
-SHARED_VERSION_INFO="1:19:0"
+CLEAN_VERSION=`echo $PACKAGE_VERSION | $SED "s/p.*//"`
+VERSION_MINOR=`echo $CLEAN_VERSION | $SED "s/.*\.//"`
-AC_PROG_CC
-AM_PROG_CC_C_O
-AC_PROG_CXX
+SHARED_VERSION_INFO="1:$VERSION_MINOR:0"
-# Do not check for F77.
-define([AC_LIBTOOL_LANG_F77_CONFIG], [:])dnl
-
-AM_PROG_LIBTOOL
-
-AC_CHECK_PROG(HAVE_AUTOGEN, autogen, yes, no)
-AC_CHECK_PROG(HAVE_WINE, wine, yes, no)
-
-AC_PROG_INSTALL
-AC_PROG_LN_S
+#------------------------------------------------------------------------------------
AC_HEADER_STDC
@@ -80,7 +85,7 @@ AM_CONDITIONAL([LINUX_MINGW_CROSS_TEST],
#====================================================================================
# Check for support of the struct hack.
-AC_C99_FLEXIBLE_ARRAY
+MN_C99_FLEXIBLE_ARRAY
if test x$ac_cv_c99_flexible_array = xyes ; then
AC_DEFINE([HAVE_FLEXIBLE_ARRAY],1, [Set to 1 if the compile supports the struct hack.])
@@ -129,7 +134,7 @@ 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_HELP_STRING([--disable-external-libs], [disable use of FLAC, Ogg and Vorbis [[default=no]]]))
AC_ARG_ENABLE(octave,
AC_HELP_STRING([--enable-octave], [disable building of GNU Octave module]))
@@ -141,6 +146,7 @@ AM_CONDITIONAL([ENABLE_TEST_COVERAGE], [test "$enable_test_coverage" = yes])
#====================================================================================
# Check types and their sizes.
+AC_CHECK_SIZEOF(wchar_t,4)
AC_CHECK_SIZEOF(short,2)
AC_CHECK_SIZEOF(int,4)
AC_CHECK_SIZEOF(long,4)
@@ -162,15 +168,16 @@ unset ac_cv_sizeof_off_t
AC_CHECK_SIZEOF(off_t,1) # Fake default value.
case "$host_os" in
- mingw*)
+ mingw32msvc | mingw32)
TYPEOF_SF_COUNT_T="__int64"
SF_COUNT_MAX="0x7FFFFFFFFFFFFFFFLL"
SIZEOF_SF_COUNT_T=8
+ AC_DEFINE([__USE_MINGW_ANSI_STDIO],1,[Set to 1 to use C99 printf/snprintf in MinGW.])
;;
*)
if test "x$ac_cv_sizeof_off_t" = "x8" ; then
# If sizeof (off_t) is 8, no further checking is needed.
- TYPEOF_SF_COUNT_T="off_t"
+ TYPEOF_SF_COUNT_T="int64_t"
SF_COUNT_MAX="0x7FFFFFFFFFFFFFFFLL"
SIZEOF_SF_COUNT_T=8
else
@@ -180,10 +187,10 @@ case "$host_os" in
TYPEOF_SF_COUNT_T="unknown"
if test "x$ac_cv_sizeof_loff_t" = "x8" ; then
- TYPEOF_SF_COUNT_T="loff_t"
+ TYPEOF_SF_COUNT_T="int64_t"
SIZEOF_SF_COUNT_T=8
elif test "x$ac_cv_sizeof_off64_t" = "x8" ; then
- TYPEOF_SF_COUNT_T="off64_t"
+ TYPEOF_SF_COUNT_T="int64_t"
SIZEOF_SF_COUNT_T=8
fi
@@ -208,6 +215,7 @@ case "$host_os" in
AC_CHECK_SIZEOF(off_t,1) # Fake default value.
if test "x$ac_cv_sizeof_off_t" = "x8" ; then
+ TYPEOF_SF_COUNT_T="int64_t"
SF_COUNT_MAX="0x7FFFFFFFFFFFFFFFLL"
elif test "x$ac_cv_sizeof_off_t" = "x$pre_largefile_sizeof_off_t" ; then
AC_MSG_WARN([[This machine does not seem to support 64 bit file offsets.]])
@@ -245,7 +253,7 @@ AC_CHECK_SIZEOF(ssize_t,4)
#====================================================================================
# Determine endian-ness of target processor.
-AC_C_FIND_ENDIAN
+MN_C_FIND_ENDIAN
AC_DEFINE_UNQUOTED(CPU_IS_BIG_ENDIAN, ${ac_cv_c_big_endian},
[Target processor is big endian.])
@@ -264,12 +272,13 @@ AC_CHECK_FUNCS(snprintf vsnprintf)
AC_CHECK_FUNCS(gmtime gmtime_r localtime localtime_r gettimeofday)
AC_CHECK_FUNCS(mmap getpagesize)
AC_CHECK_FUNCS(setlocale)
+AC_CHECK_FUNCS(pipe waitpid)
AC_CHECK_LIB([m],floor)
AC_CHECK_FUNCS(floor ceil fmod)
-AC_C99_FUNC_LRINT
-AC_C99_FUNC_LRINTF
+MN_C99_FUNC_LRINT
+MN_C99_FUNC_LRINTF
#====================================================================================
# Check for requirements for building plugins for other languages/enviroments.
@@ -295,45 +304,60 @@ 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)
+if test -n "$PKG_CONFIG" ; then
+ 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)
- # 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
+ # Make sure the FLAC_CFLAGS value is sane.
+ FLAC_CFLAGS=`echo $FLAC_CLFAGS | $SED "s/FLAC$//"`
-HAVE_VORBIS_VERSION_STRING=0
-if test x$ac_cv_flac$ac_cv_ogg$ac_cv_vorbis$ac_cv_vorbisenc = "xyesyesyesyes" ; then
+ PKG_CHECK_MOD_VERSION(OGG, ogg >= 1.1.3, ac_cv_ogg=yes, ac_cv_ogg=no)
- save_LIBS="$LIBS"
- LIBS="$VORBIS_LIBS $LIBS"
- AC_CHECK_LIB(vorbis, vorbis_version_string, HAVE_VORBIS_VERSION_STRING=1)
- LIBS="$save_LIBS"
+ if test x$enable_experimental = xyes ; then
+ PKG_CHECK_MOD_VERSION(SPEEX, speex >= 1.2, ac_cv_speex=yes, ac_cv_speex=no)
+ else
+ SPEEX_CFLAGS=""
+ SPEEX_LIBS=""
+ fi
- HAVE_EXTERNAL_LIBS=1
- enable_external_libs=yes
+ # Vorbis versions earlier than 1.2.3 have bugs that cause the libsndfile
+ # test suite to fail on MIPS, PowerPC and others.
+ # See: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=549899
+ PKG_CHECK_MOD_VERSION(VORBIS, vorbis >= 1.2.3, ac_cv_vorbis=yes, ac_cv_vorbis=no)
+ PKG_CHECK_MOD_VERSION(VORBISENC, vorbisenc >= 1.2.3, ac_cv_vorbisenc=yes, ac_cv_vorbisenc=no)
+ enable_external_libs=yes
+ fi
- EXTERNAL_CFLAGS="$FLAC_CFLAGS $OGG_CFLAGS $VORBISENC_CFLAGS"
- EXTERNAL_LIBS="$FLAC_LIBS $VORBISENC_LIBS"
-else
- enable_external_libs=no
+ if test x$ac_cv_flac$ac_cv_ogg$ac_cv_vorbis$ac_cv_vorbisenc = "xyesyesyesyes" ; then
+ HAVE_EXTERNAL_LIBS=1
+ enable_external_libs=yes
+
+ EXTERNAL_CFLAGS="$FLAC_CFLAGS $OGG_CFLAGS $VORBISENC_CFLAGS $SPEEX_CFLAGS"
+ EXTERNAL_LIBS="$FLAC_LIBS $VORBISENC_LIBS $SPEEX_LIBS"
+ else
+ echo
+ AC_MSG_WARN([[*** One or more of the external libraries (ie libflac, libogg and]])
+ AC_MSG_WARN([[*** libvorbis) is either missing (possibly only the development]])
+ AC_MSG_WARN([[*** headers) or is of an unsupported version.]])
+ AC_MSG_WARN([[***]])
+ AC_MSG_WARN([[*** Unfortunately, for ease of maintenance, the external libs]])
+ AC_MSG_WARN([[*** are an all or nothing affair.]])
+ echo
+ enable_external_libs=no
+ fi
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_MOD_VERSION(SQLITE3, sqlite3 >= 3.2, ac_cv_sqlite3=yes, ac_cv_sqlite3=no)
-# fi
+if test x$enable_sqlite != xno ; then
+ 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
HAVE_SQLITE3=1
@@ -343,24 +367,11 @@ else
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
- AC_C_CLIP_MODE
+ MN_C_CLIP_MODE
else
echo "checking processor clipping capabilities... disabled"
ac_cv_c_clip_positive=0
@@ -384,7 +395,7 @@ use_windows_api=0
case "$host_os" in
darwin* | rhapsody*)
os_is_macosx=1
- OS_SPECIFIC_CFLAGS="-fpascal-strings -I/Developer/Headers/FlatCarbon"
+ OS_SPECIFIC_CFLAGS="-I/Developer/Headers/FlatCarbon"
OS_SPECIFIC_LINKS="-framework CoreAudio"
;;
mingw*)
@@ -398,6 +409,8 @@ AC_DEFINE_UNQUOTED(OS_IS_WIN32, ${os_is_win32}, [Set to 1 if compiling for Win32
AC_DEFINE_UNQUOTED(OS_IS_MACOSX, ${os_is_macosx}, [Set to 1 if compiling for MacOSX])
AC_DEFINE_UNQUOTED(USE_WINDOWS_API, ${use_windows_api}, [Set to 1 to use the native windows API])
+AM_CONDITIONAL(USE_WIN_VERSION_FILE, test ${use_windows_api} -eq 1)
+
#====================================================================================
# Check for ALSA.
@@ -411,6 +424,15 @@ if test x$enable_alsa != xno ; then
fi
fi
+#====================================================================================
+# Check for OpenBSD's sndio.
+
+SNDIO_LIBS=""
+AC_CHECK_HEADERS(sndio.h)
+if test x$ac_cv_header_sndio_h = xyes ; then
+ SNDIO_LIBS="-lsndio"
+ fi
+
#====================================================================================
# Test for sanity when cross-compiling.
@@ -477,32 +499,32 @@ win32_target_dll=0
COMPILER_IS_GCC=0
if test x$ac_cv_c_compiler_gnu = xyes ; then
- AC_ADD_CFLAGS(-std=gnu99)
+ MN_ADD_CFLAGS(-std=gnu99)
- AC_GCC_VERSION
+ MN_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])
+ 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([****************************************************************])
+ MN_ADD_CFLAGS([-fgnu89-inline])
fi
CFLAGS="$CFLAGS -Wall"
CXXFLAGS="$CXXFLAGS -Wall"
-# AC_ADD_CFLAGS([-Wextra])
+ MN_ADD_CFLAGS([-Wextra])
AC_LANG_PUSH([C++])
-# AC_ADD_CXXFLAGS([-Wextra])
+ MN_ADD_CXXFLAGS([-Wextra])
AC_LANG_POP([C++])
- AC_ADD_CFLAGS([-Wdeclaration-after-statement])
- AC_ADD_CFLAGS([-Wpointer-arith])
- AC_ADD_CFLAGS([-funsigned-char])
+ MN_ADD_CFLAGS([-Wdeclaration-after-statement])
+ MN_ADD_CFLAGS([-Wpointer-arith])
+ MN_ADD_CFLAGS([-funsigned-char])
if test x$enable_gcc_werror = "xyes" ; then
CFLAGS="-Werror $CFLAGS"
@@ -510,16 +532,16 @@ if test x$ac_cv_c_compiler_gnu = xyes ; then
fi
if test x$enable_test_coverage = "xyes" ; then
- # AC_ADD_CFLAGS([-ftest-coverage])
- AC_ADD_CFLAGS([-coverage])
+ # MN_ADD_CFLAGS([-ftest-coverage])
+ MN_ADD_CFLAGS([-coverage])
fi
- CFLAGS="$CFLAGS -Wstrict-prototypes -Wmissing-prototypes -Waggregate-return -Wcast-align -Wcast-qual -Wnested-externs -Wshadow -Wbad-function-cast -Wwrite-strings "
+ CFLAGS="$CFLAGS -Wstrict-prototypes -Wmissing-prototypes -Waggregate-return -Wcast-align -Wcast-qual -Wnested-externs -Wshadow -Wbad-function-cast -Wwrite-strings -Wundef "
# -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 "
+ CXXFLAGS="$CXXFLAGS -Wcast-align -Wcast-qual -Wshadow -Wwrite-strings -Wctor-dtor-privacy -Wnon-virtual-dtor -Woverloaded-virtual -Wreorder -Wsign-promo -Wundef "
if test "x$enable_gcc_opt" = "xno" ; then
- temp_CFLAGS=`echo $CFLAGS | sed "s/O2/O0/"`
+ temp_CFLAGS=`echo $CFLAGS | $SED "s/O2/O0/"`
CFLAGS=$temp_CFLAGS
AC_MSG_WARN([[*** Compiler optimisations switched off. ***]])
fi
@@ -529,12 +551,12 @@ if test x$ac_cv_c_compiler_gnu = xyes ; then
darwin* | rhapsody*)
# Disable -Wall, -pedantic and -Wshadow for Apple Darwin/Rhapsody.
# System headers on these systems are broken.
- temp_CFLAGS=`echo $CFLAGS | sed "s/-Wall -pedantic//" | sed "s/-Wshadow//" | sed "s/-Waggregate-return//"`
+ temp_CFLAGS=`echo $CFLAGS | $SED "s/-Wall -pedantic//" | $SED "s/-Wshadow//" | $SED "s/-Waggregate-return//"`
CFLAGS=$temp_CFLAGS
SHLIB_VERSION_ARG="-Wl,-exported_symbols_list -Wl,\$(srcdir)/Symbols.darwin"
;;
- linux*)
- SHLIB_VERSION_ARG="-Wl,--version-script=\$(srcdir)/Symbols.linux"
+ linux*|kfreebsd*-gnu*|gnu*)
+ SHLIB_VERSION_ARG="-Wl,--version-script=\$(srcdir)/Symbols.gnu-binutils"
;;
mingw*)
# Linker flag '-Wl,--out-implib' does not work with mingw cross compiler
@@ -560,34 +582,6 @@ if test x$ac_cv_c_compiler_gnu = xyes ; then
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,
- [ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor=unknown
- # note: don't check for gcc first since some other compilers define __GNUC__
- for ventest in intel:__ICC,__ECC,__INTEL_COMPILER ibm:__xlc__,__xlC__,__IBMC__,__IBMCPP__ gnu:__GNUC__ sun:__SUNPRO_C,__SUNPRO_CC hp:__HP_cc,__HP_aCC dec:__DECC,__DECCXX,__DECC_VER,__DECCXX_VER borland:__BORLANDC__,__TURBOC__ comeau:__COMO__ cray:_CRAYC kai:__KCC lcc:__LCC__ metrowerks:__MWERKS__ sgi:__sgi,sgi microsoft:_MSC_VER watcom:__WATCOMC__ portland:__PGI; do
- vencpp="defined("`echo $ventest | cut -d: -f2 | sed 's/,/) || defined(/g'`")"
- AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[
-#if !($vencpp)
- thisisanerror;
-#endif
-])], [ax_cv_]_AC_LANG_ABBREV[_compiler_vendor=`echo $ventest | cut -d: -f1`; break])
- done
- ])
-])
-
-AX_COMPILER_VENDOR
-
-# Enable 64 bit build
-AC_ARG_ENABLE(64,
-[AC_HELP_STRING([--enable-64],[build with 64 bit support])],[enable_64="$enable_64"],[enable_64="no"])
-
-if test "x${ax_cv_c_compiler_vendor}" = "xsun" ; then
- if test "${enable_64}" = "yes"; then
- CFLAGS="$CFLAGS -m64"
- fi
-fi
-
CFLAGS="$CFLAGS $OS_SPECIFIC_CFLAGS"
@@ -596,43 +590,51 @@ if test x"$CFLAGS" = x ; then
exit
fi
+HOST_TRIPLET="${host_cpu}-${host_vendor}-${host_os}"
+
+if test "$HOST_TRIPLET" = "x86_64-w64-mingw32" ; then
+ OS_SPECIFIC_LINKS=" -static-libgcc $OS_SPECIFIC_LINKS"
+ fi
+
+WIN_RC_VERSION=`echo $PACKAGE_VERSION | $SED -e "s/p.*//" -e "s/\./,/g"`
+
#-------------------------------------------------------------------------------
+AC_SUBST(HOST_TRIPLET)
+
AC_SUBST(htmldocdir)
AC_SUBST(HTML_BGCOLOUR)
AC_SUBST(HTML_FGCOLOUR)
AC_SUBST(SHLIB_VERSION_ARG)
AC_SUBST(SHARED_VERSION_INFO)
+AC_SUBST(CLEAN_VERSION)
+AC_SUBST(WIN_RC_VERSION)
+
AC_SUBST(OS_SPECIFIC_CFLAGS)
AC_SUBST(OS_SPECIFIC_LINKS)
AC_SUBST(ALSA_LIBS)
-AC_SUBST(ENABLE_EXPERIMENTAL_CODE)
+AC_SUBST(SNDIO_LIBS)
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 \
- M4/Makefile doc/Makefile Win32/Makefile Octave/Makefile \
- programs/Makefile doc/libsndfile.css \
- Makefile libsndfile.spec sndfile.pc \
- tests/test_wrapper.sh \
+ src/Makefile man/Makefile examples/Makefile tests/Makefile regtest/Makefile \
+ M4/Makefile doc/Makefile Win32/Makefile Octave/Makefile programs/Makefile \
+ Makefile \
+ src/version-metadata.rc tests/test_wrapper.sh tests/pedantic-header-test.sh \
+ doc/libsndfile.css build-test-tarball.mk libsndfile.spec sndfile.pc \
+ src/sndfile.h \
])
AC_OUTPUT
-# Make it executable.
-chmod u+x tests/test_wrapper.sh
+# Make sure these are executable.
+chmod u+x tests/test_wrapper.sh build-test-tarball.mk
#====================================================================================
@@ -641,19 +643,34 @@ AC_MSG_RESULT([
Configuration summary :
- Version : ............................. ${VERSION}
+ libsndfile version : .................. ${VERSION}
+
+ Host CPU : ............................ ${host_cpu}
+ Host Vendor : ......................... ${host_vendor}
+ Host OS : ............................. ${host_os}
+
Experimental code : ................... ${enable_experimental:-no}
Using ALSA in example programs : ...... ${enable_alsa:-no}
External FLAC/Ogg/Vorbis : ............ ${enable_external_libs:-no}
-
])
+if test -z "$PKG_CONFIG" ; then
+ echo " *****************************************************************"
+ echo " *** The pkg-config program is missing. ***"
+ echo " *** External FLAC/Ogg/Vorbis libs cannot be found without it. ***"
+ echo " *** http://pkg-config.freedesktop.org/wiki/ ***"
+ echo " *****************************************************************"
+ echo
+ fi
+
if test x$ac_cv_c_compiler_gnu = xyes ; then
- echo -e " Tools :\n"
+ echo " Tools :"
+ echo
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 "\n"
+ echo " ** This compiler version allows applications to write"
echo " ** to static strings within the library."
echo " ** Compile with GCC version 3.X or above to avoid this problem."
fi
@@ -678,8 +695,9 @@ AC_MSG_RESULT([[
if test x$prefix != "x/usr" ; then
echo "Compiling some other packages against libsndfile may require"
- echo -e "the addition of \"$libdir/pkgconfig\" to the"
- echo -e "PKG_CONFIG_PATH environment variable.\n"
+ echo "the addition of '$libdir/pkgconfig' to the"
+ echo "PKG_CONFIG_PATH environment variable."
+ echo
fi
(cd src && make genfiles)
diff --git a/libs/libsndfile/doc/FAQ.html b/libs/libsndfile/doc/FAQ.html
index f46c4c321f..ce0164a23e 100644
--- a/libs/libsndfile/doc/FAQ.html
+++ b/libs/libsndfile/doc/FAQ.html
@@ -8,65 +8,69 @@
-
+
+
libsndfile : Frequently Asked Questions.
-Q1 : Do you plan to support XYZ codec in libsndfile?
+Q1 : Do you plan to support XYZ codec in libsndfile?
Q2 : In version 0 the SF_INFO struct had a pcmbitwidth field
- but version 1 does not. Why?
-Q3 : Compiling is really slow on MacOSX. Why?
+ but version 1 does not. Why?
+Q3 : Compiling is really slow on MacOS X. Why?
Q4 : When trying to compile libsndfile on Solaris I get a "bad
- substitution" error during linking. What can I do to fix this?
-Q5 : Why doesn't libsndfile do interleaving/de-interleaving?
-Q6 : What's the best format for storing temporary files?
-Q7 : On Linux/Unix/MacOSX, what's the best way of detecting the
- presence of libsndfile?
-Q8 : But I just want a simple Makefile! What do I do?
+ substitution" error during linking. What can I do to fix this?
+Q5 : Why doesn't libsndfile do interleaving/de-interleaving?
+Q6 : What's the best format for storing temporary files?
+Q7 : On Linux/Unix/MacOS X, what's the best way of detecting the
+ presence of libsndfile?
+Q8 : But I just want a simple Makefile! What do I do?
Q9 : How about adding the ability to write/read sound files to/from
- memory buffers?
+ memory buffers?
Q10 : Reading a 16 bit PCM file as normalised floats and then
- writing them back changes some sample values. Why?
+ writing them back changes some sample values. Why?
Q11 : I'm having problems with u-law encoded WAV files generated by
- libsndfile in Winamp. Why?
-Q12 : I'm looking at sf_read*. What are items? What are frames?
+ libsndfile in Winamp. Why?
+Q12 : I'm looking at sf_read*. What are items? What are frames?
Q13 : Why can't libsndfile open this Sound Designer II (SD2)
- file?
+ file?
Q14 : I'd like to statically link libsndfile to my closed source
- application. Can I buy a license so that this is possible?
+ application. Can I buy a license so that this is possible?
Q15 : My program is crashing during a call to a function in libsndfile.
- Is this a bug in libsndfile?
+ Is this a bug in libsndfile?
Q16 : Will you accept a fix for compiling libsndfile with compiler X?
-
+
Q17 : Can libsndfile read/write files from/to UNIX pipes?
-
-Q18 : Is it possible to build a Universal Binary on Mac OSX?
-
+
+Q18 : Is it possible to build a Universal Binary on Mac OS X?
+
Q19 : I have project files for Visual Studio / XCode / Whatever. Why
don't you distribute them with libsndfile?
-
+
Q20 : Why doesn't libsndfile support MP3? Lots of other Open Source
projects support it!
-
+
Q21 : How do I use libsndfile in a closed source or commercial program
and comply with the license?
-
+
Q22 : What versions of windows does libsndfile work on?
-
+
+Q23 : I'm cross compiling libsndfile for another platform. How can I
+ run the test suite?
+
-Q1 : Do you plan to support XYZ codec in libsnfile?
+Q1 : Do you plan to support XYZ codec in libsndfile?
If source code for XYZ codec is available under a suitable license (LGPL, BSD,
MIT etc) then yes, I'd like to add it.
-If suitable documentation is available on how to decode and enocde the format
+If suitable documentation is available on how to decode and encode the format
then maybe, depending on how much work is involved.
@@ -80,7 +84,7 @@ If you can't find either then the answer is no.
-Q2 : In version 0 the SF_INFO struct had a pcmbitwidth field
+Q2 : In version 0 the SF_INFO struct had a pcmbitwidth field
but version 1 does not. Why?
This was dropped for a number of reasons:
@@ -92,49 +96,49 @@ If you can't find either then the answer is no.
As documented
here
-there is now a well defined behavior which ensures that no matter what the
+there is now a well defined behaviour which ensures that no matter what the
bit width of the source file, the scaling always does something sensible.
This makes it safe to read 8, 16, 24 and 32 bit PCM files using sf_read_short()
-and always have the optimal behavior.
+and always have the optimal behaviour.
-Q3 : Compiling is really slow on MacOSX. Why?
+Q3 : Compiling is really slow on MacOS X. Why?
When you configure and compile libsndfile, it uses the /bin/sh shell for a number
of tasks (ie configure script and libtool).
-Older versions of OSX (10.2?) shipped a a really crappy Bourne shell as /bin/sh
+Older versions of OS X (10.2?) shipped a really crappy Bourne shell as /bin/sh
which resulted in really slow compiles.
-New version of OSX ship GNU BASh as /bin/sh and this answer doesn't apply in that
+Newer version of OS X ship GNU Bash as /bin/sh and this answer doesn't apply in that
case.
To fix this I suggest that you install the GNU Bash shell, rename /bin/sh to
-/bin/sh.old and make a softlink from /bin/sh to the bash shell.
+/bin/sh.old and make a symlink from /bin/sh to the bash shell.
Bash is designed to behave as a Bourne shell when is is called as /bin/sh.
-When I did this on my iBook running MacOSX, compile times dropped from 13 minutes
+When I did this on my iBook running MacOS X, compile times dropped from 13 minutes
to 3 minutes.
-Q4 : When trying to compile libsndfile on Solaris I get a "bad
+Q4 : When trying to compile libsndfile on Solaris I get a "bad
substitution" error on linking. Why?
It seems that the Solaris Bourne shell disagrees with GNU libtool.
To fix this I suggest that you install the GNU Bash shell, rename /bin/sh to
-/bin/sh.old and make a softlink from /bin/sh to the bash shell.
+/bin/sh.old and make a symlink from /bin/sh to the bash shell.
Bash is designed to behave as a Bourne shell when is is called as /bin/sh.
-Q5 : Why doesn't libsndfile do interleaving/de-interleaving?
+Q5 : Why doesn't libsndfile do interleaving/de-interleaving?
This problem is bigger than it may seem at first.
@@ -143,7 +147,7 @@ For a stereo file, it is a pretty safe bet that a simple interleaving/de-interle
could satisfy most users.
However, for files with more than 2 channels this is unlikely to be the case.
If the user has a 4 channel file and want to play that file on a stereo output
-sound card they either want the first two channels or they want some mixed combination
+sound card they either want the first 2 channels or they want some mixed combination
of the 4 channels.
@@ -156,7 +160,7 @@ This means that this feature will not be added any time soon.
-
When you want to store temporary data there are a number of requirements;
@@ -184,7 +188,7 @@ regardless of the host CPU.
-
@@ -242,7 +246,7 @@ libsndfile configure process. For instance on my system I get this:
-
@@ -352,7 +356,7 @@ storage format (and which is also supported by most common file types).
-
-For multi channel sound files, a single frame contains a single item for
-each channel.
+Here are two simple, correct examples, both of which are assumed to be working
+on a stereo file, first using items:
+
@@ -407,7 +437,7 @@ First some background.
SD2 files are native to the Apple Macintosh platform and use features of
the Mac filesystem (file resource forks) to store the file's sample rate,
number of channels, sample width and more.
-When you look at a file and its resource fork on Mac OSX it looks like
+When you look at a file and its resource fork on Mac OS X it looks like
this:
@@ -419,7 +449,7 @@ this:
Notice how the file itself looks like a directory containing a single file
named rsrc .
-When libsndfile is compiled for MacOSX, it should open (for write and read)
+When libsndfile is compiled for MacOS X, it should open (for write and read)
SD2 file with resource forks like this without any problems.
It will also handle files with the resource fork in a separate file as
described below.
@@ -436,8 +466,8 @@ libsndfile to open the file.
However, it is possible to safely move an SD2 file to a Linux or Windows
machine.
-For instance, when an SD2 file is copied from inside MacOSX to a windows
-shared directory or a Samba share (ie Linux), MacOSX is clever enough to
+For instance, when an SD2 file is copied from inside MacOS X to a windows
+shared directory or a Samba share (ie Linux), MacOS X is clever enough to
store the resource fork of the file in a separate hidden file in the
same directory like this:
@@ -475,7 +505,7 @@ files are.
@@ -548,7 +578,7 @@ This can make compiling libsndfile with some older compilers difficult.
-
I currently release sources that I personally test on Win32, Linux and
-MacOSX (PowerPC) using the compiler I trust (GNU GCC).
+MacOS X (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
@@ -696,7 +726,7 @@ Hence, I'm not willing to enter into an arrangement like that again.
-
-On success, the sf_open function returns a non NULL pointer which should be
+On success, the sf_open function returns a non-NULL pointer which should be
passed as the first parameter to all subsequent libsndfile calls dealing with
that audio file.
On fail, the sf_open function returns a NULL pointer.
+An explanation of the error can obtained by passing NULL to
+ sf_strerror .
The second open function takes a file descriptor of a file that has already been
opened.
@@ -280,12 +300,92 @@ parameter was TRUE when the sf_open_fd() function was called.
-On success, the sf_open_fd function returns a non NULL pointer which should be
+On success, the sf_open_fd function returns a non-NULL pointer which should be
passed as the first parameter to all subsequent libsndfile calls dealing with
that audio file.
On fail, the sf_open_fd function returns a NULL pointer.
+
+ Opens a soundfile from a virtual file I/O context which is provided
+ by the caller. This is usually used to interface libsndfile to a stream or buffer
+ based system. Apart from the sfvirtual and the user_data parameters this function behaves
+ like sf_open .
+
+
+
+Libsndfile calls the callbacks provided by the SF_VIRTUAL_IO structure when opening, reading
+and writing to the virtual file context. The user_data pointer is a user defined context which
+will be available in the callbacks.
+
+
+The virtual file contex must return the length of the virtual file in bytes.
+
+
+The virtual file context must seek to offset using the seek mode provided by whence which is one of
+
+
+The virtual file context must copy ("read") "count" bytes into the
+buffer provided by ptr and return the count of actually copied bytes.
+
+
+The virtual file context must process "count" bytes stored in the
+buffer passed with ptr and return the count of actually processed bytes.
+
+
+Return the current position of the virtual file context.
+
+
+
The raw read and write functions read raw audio data from the audio file (not to be
confused with reading RAW header-less PCM files). The number of bytes read or written
@@ -586,12 +692,16 @@ The str_type parameter can be any one of the following string types:
SF_STR_SOFTWARE,
SF_STR_ARTIST,
SF_STR_COMMENT,
- SF_STR_DATE
+ SF_STR_DATE,
+ SF_STR_ALBUM,
+ SF_STR_LICENSE,
+ SF_STR_TRACKNUMBER,
+ SF_STR_GENRE
} ;
-The sf_get_string() function returns the specificed string if it exists and a
+The sf_get_string() function returns the specified string if it exists and a
NULL pointer otherwise.
In addition to the string ids above, SF_STR_FIRST (== SF_STR_TITLE) and
SF_STR_LAST (always the same as the highest numbers string id) are also
@@ -648,7 +758,7 @@ would mean that all sample values read from the file will be zero.
In order to read these files correctly using integer read methods, it is recommended
that you use the
sf_command
-interface a command of
+interface, a command of
SFC_SET_SCALE_FLOAT_INT_READ
and a parameter of SF_TRUE to force correct scaling.
@@ -660,7 +770,7 @@ and a parameter of SF_TRUE to force correct scaling.
Version 1.0.25 (July 13 2011) Fix for Secunia Advisory SA45125. Minor bug fixes and
+ improvements.
@@ -389,7 +396,7 @@ and
version 2.1
and
version 3 .
- To mamximise the compatibility of libsndfile, the user may choose to use libsndfile
+ To maximise 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
here .
@@ -410,24 +417,12 @@ and
Free Software
or
Open Source .
- However, if you put in a great deal of effort building a huge application
+ However, if you put in a great deal of effort building a significant 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
abide by the license .
-
- What I don't like to see is things like Steve Dekorte's SoundConverter
- (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
- his own
-
- admission ,
- less than 10%.
-
-
Download
@@ -435,23 +430,22 @@ and
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.
+2000, Vista and Windows 7.
diff --git a/libs/libsndfile/doc/libsndfile.css b/libs/libsndfile/doc/libsndfile.css
index 940c136fe8..eab8d0616b 100644
--- a/libs/libsndfile/doc/libsndfile.css
+++ b/libs/libsndfile/doc/libsndfile.css
@@ -48,24 +48,32 @@ dl {
margin-left : 3% ;
margin-right : 3% ;
}
-h1 {
- font-size : xx-large ;
- background : black ;
- color : #5050FF ;
- text-align : left ;
- margin-left : 3% ;
- margin-right : 3% ;
-}
-h2 {
- font-size : x-large ;
+h1 {
+ font-size : xx-large ;
background : black ;
color : #5050FF ;
text-align : left ;
margin-left : 3% ;
margin-right : 3% ;
}
-h3 {
- font-size : large ;
+h2 {
+ font-size : x-large ;
+ background : black ;
+ color : #5050FF ;
+ text-align : left ;
+ margin-left : 3% ;
+ margin-right : 3% ;
+}
+h3 {
+ font-size : large ;
+ background : black ;
+ color : #5050FF ;
+ text-align : left ;
+ margin-left : 3% ;
+ margin-right : 3% ;
+}
+h4 {
+ font-size : medium ;
background : black ;
color : #5050FF ;
text-align : left ;
diff --git a/libs/libsndfile/doc/libsndfile.css.in b/libs/libsndfile/doc/libsndfile.css.in
index 3e308b2cc3..90690805ec 100644
--- a/libs/libsndfile/doc/libsndfile.css.in
+++ b/libs/libsndfile/doc/libsndfile.css.in
@@ -48,24 +48,32 @@ dl {
margin-left : 3% ;
margin-right : 3% ;
}
-h1 {
- font-size : xx-large ;
- background : @HTML_BGCOLOUR@ ;
- color : #5050FF ;
- text-align : left ;
- margin-left : 3% ;
- margin-right : 3% ;
-}
-h2 {
- font-size : x-large ;
+h1 {
+ font-size : xx-large ;
background : @HTML_BGCOLOUR@ ;
color : #5050FF ;
text-align : left ;
margin-left : 3% ;
margin-right : 3% ;
}
-h3 {
- font-size : large ;
+h2 {
+ font-size : x-large ;
+ background : @HTML_BGCOLOUR@ ;
+ color : #5050FF ;
+ text-align : left ;
+ margin-left : 3% ;
+ margin-right : 3% ;
+}
+h3 {
+ font-size : large ;
+ background : @HTML_BGCOLOUR@ ;
+ color : #5050FF ;
+ text-align : left ;
+ margin-left : 3% ;
+ margin-right : 3% ;
+}
+h4 {
+ font-size : medium ;
background : @HTML_BGCOLOUR@ ;
color : #5050FF ;
text-align : left ;
diff --git a/libs/libsndfile/doc/lists.html b/libs/libsndfile/doc/lists.html
index 349e494cff..7d95170271 100644
--- a/libs/libsndfile/doc/lists.html
+++ b/libs/libsndfile/doc/lists.html
@@ -6,7 +6,8 @@
libsndfile Mailing Lists
-
+
+
diff --git a/libs/libsndfile/doc/octave.html b/libs/libsndfile/doc/octave.html
index 33ef1b6c53..525b7aec9b 100644
--- a/libs/libsndfile/doc/octave.html
+++ b/libs/libsndfile/doc/octave.html
@@ -6,7 +6,8 @@
libsndfile and GNU Octave
-
+
+
@@ -85,7 +86,7 @@
to play the correct types of Octave files.
Using this command line player sndfile-play and a third Octave script
file allows Octave data to be played from within Octave on any of the platforms
- which sndfile-play supports (at the moment: Linux, MacOSX, Solaris and
+ which sndfile-play supports (at the moment: Linux, MacOS X, Solaris and
Win32).
diff --git a/libs/libsndfile/doc/pkgconfig.html b/libs/libsndfile/doc/pkgconfig.html
index 1711de9f70..c89193d1ed 100644
--- a/libs/libsndfile/doc/pkgconfig.html
+++ b/libs/libsndfile/doc/pkgconfig.html
@@ -6,7 +6,8 @@
libsndfile : pkg-config
-
+
+
@@ -18,7 +19,7 @@
From version 1.0.0 libsndfile has had the ability to read and write files of
greater than 2 Gig in size on most OSes even if sizeof (long) == 4.
OSes which support this feature include Linux (2.4 kernel, glibc6) on x86, PPC and
- probably others, Win32, MacOSX, *BSD, Solaris and probably others.
+ probably others, Win32, MacOS X, *BSD, Solaris and probably others.
OSes on 64 bit processors where the default compile environment is LP64 (longs and
pointers are 64 bit ie Linux on DEC/Compaq/HP Alpha processors) automatically
support large file access.
@@ -30,7 +31,7 @@
programs which link to the library.
- Note : People using Win32, MacOS (both OSX and pre-OSX) or *BSD can disregard the
+ Note : People using Win32, MacOS (both OS X and pre-OS X) or *BSD can disregard the
rest of this document as it does not apply to either of these OSes.
diff --git a/libs/libsndfile/doc/sndfile_info.html b/libs/libsndfile/doc/sndfile_info.html
index 51e2dd35ad..a84f24150f 100644
--- a/libs/libsndfile/doc/sndfile_info.html
+++ b/libs/libsndfile/doc/sndfile_info.html
@@ -6,7 +6,8 @@
sndfile-info
-
+
+
diff --git a/libs/libsndfile/doc/tutorial.html b/libs/libsndfile/doc/tutorial.html
index 77c4f0457e..e3112393ad 100644
--- a/libs/libsndfile/doc/tutorial.html
+++ b/libs/libsndfile/doc/tutorial.html
@@ -6,7 +6,8 @@
libsndfile Tutorial
-
+
+
diff --git a/libs/libsndfile/doc/win32.html b/libs/libsndfile/doc/win32.html
index 5da8f18d0e..6ee3153c7d 100644
--- a/libs/libsndfile/doc/win32.html
+++ b/libs/libsndfile/doc/win32.html
@@ -6,7 +6,8 @@
Building libsndfile on Win32
-
+
+
diff --git a/libs/libsndfile/examples/cooledit-fixer.c b/libs/libsndfile/examples/cooledit-fixer.c
deleted file mode 100644
index 06ceae6a92..0000000000
--- a/libs/libsndfile/examples/cooledit-fixer.c
+++ /dev/null
@@ -1,231 +0,0 @@
-/*
-** Copyright (C) 2002-2005 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
-** 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
-#include
-#include
-#include
-#include
-
-#include
-
-#define BUFFER_LEN 1024
-
-static void usage_exit (char *progname) ;
-static int is_data_really_float (SNDFILE *sndfile) ;
-static void fix_file (char *filename) ;
-static off_t file_size (char *filename) ;
-
-static union
-{ int i [BUFFER_LEN] ;
- float f [BUFFER_LEN] ;
-} buffer ;
-
-int
-main (int argc, char *argv [])
-{ SNDFILE *sndfile ;
- SF_INFO sfinfo ;
- int k, data_is_float, converted = 0 ;
-
- puts ("\nCooledit Fixer.\n---------------") ;
-
- if (argc < 2)
- usage_exit (argv [0]) ;
-
- for (k = 1 ; k < argc ; k++)
- { if ((sndfile = sf_open (argv [k], SFM_READ, &sfinfo)) == NULL)
- { /*-printf ("Failed to open : %s\n", argv [k]) ;-*/
- continue ;
- } ;
-
- if (sfinfo.format != (SF_FORMAT_WAV | SF_FORMAT_PCM_32))
- { /*-printf ("%-50s : not a 32 bit PCM WAV file.\n", argv [k]) ;-*/
- sf_close (sndfile) ;
- continue ;
- } ;
-
- data_is_float = is_data_really_float (sndfile) ;
-
- sf_close (sndfile) ;
-
- if (data_is_float == SF_FALSE)
- { /*-printf ("%-50s : not a Cooledit abomination.\n", argv [k]) ;-*/
- continue ;
- } ;
-
- fix_file (argv [k]) ;
- converted ++ ;
- } ;
-
- if (converted == 0)
- puts ("\nNo files converted.") ;
-
- puts ("") ;
-
- return 0 ;
-} /* main */
-
-
-static void
-usage_exit (char *progname)
-{ char *cptr ;
-
- if ((cptr = strrchr (progname, '/')))
- progname = cptr + 1 ;
- if ((cptr = strrchr (progname, '\\')))
- progname = cptr + 1 ;
-
- printf ("\n Usage : %s \n", progname) ;
- puts ("\n"
- "Fix broken files created by Syntrillium's Cooledit. These files are \n"
- "marked as containing PCM data but actually contain floating point \n"
- "data. Only the broken files created by Cooledit are processed. All \n"
- "other files remain untouched.\n"
- "\n"
- "More than one file may be included on the command line. \n"
- ) ;
-
- exit (1) ;
-} /* usage_exit */
-
-static int
-is_data_really_float (SNDFILE *sndfile)
-{ int k, readcount ;
-
- while ((readcount = sf_read_int (sndfile, buffer.i, BUFFER_LEN)) > 0)
- { for (k = 0 ; k < readcount ; k++)
- { if (buffer.i [k] == 0)
- continue ;
-
- if (fabs (buffer.f [k]) > 32768.0)
- return SF_FALSE ;
- } ;
- } ;
-
- return SF_TRUE ;
-} /* is_data_really_float */
-
-static void
-fix_file (char *filename)
-{ static char newfilename [512] ;
-
- SNDFILE *infile, *outfile ;
- SF_INFO sfinfo ;
- int readcount, k ;
- float normfactor ;
- char *cptr ;
-
- printf ("\nFixing : %s\n", filename) ;
-
- if ((infile = sf_open (filename, SFM_READ, &sfinfo)) == NULL)
- { printf ("Not able to open input file %s\n", filename) ;
- exit (1) ;
- } ;
-
- if (strlen (filename) >= sizeof (newfilename) - 1)
- { puts ("Error : Path name too long.\n") ;
- exit (1) ;
- } ;
-
- strncpy (newfilename, filename, sizeof (newfilename)) ;
- newfilename [sizeof (newfilename) - 1] = 0 ;
-
- if ((cptr = strrchr (newfilename, '/')) == NULL)
- cptr = strrchr (newfilename, '\\') ;
-
- if (cptr)
- { cptr [1] = 0 ;
- strncat (newfilename, "fixed.wav", sizeof (newfilename) - strlen (newfilename) - 1) ;
- }
- else
- strncpy (newfilename, "fixed.wav", sizeof (newfilename) - 1) ;
-
- newfilename [sizeof (newfilename) - 1] = 0 ;
-
- printf (" Output : %s\n", newfilename) ;
-
- sfinfo.format = SF_FORMAT_WAV | SF_FORMAT_FLOAT ;
-
- if ((outfile = sf_open (newfilename, SFM_WRITE, &sfinfo)) == NULL)
- { printf ("Not able to output open file %s\n", filename) ;
- exit (1) ;
- } ;
-
- /* Find the file peak. sf-command (SFC_CALC_SIGNAL_MAX) cannot be used. */
-
- normfactor = 0.0 ;
-
- while ((readcount = sf_read_int (infile, buffer.i, BUFFER_LEN)) > 0)
- { for (k = 0 ; k < readcount ; k++)
- if (fabs (buffer.f [k]) > normfactor)
- normfactor = fabs (buffer.f [k]) ;
- } ;
-
- printf (" Peak : %g\n", normfactor) ;
-
- normfactor = 1.0 / normfactor ;
-
- sf_seek (infile, 0, SEEK_SET) ;
-
- while ((readcount = sf_read_int (infile, buffer.i, BUFFER_LEN)) > 0)
- { for (k = 0 ; k < readcount ; k++)
- buffer.f [k] *= normfactor ;
- sf_write_float (outfile, buffer.f, readcount) ;
- } ;
-
- sf_close (infile) ;
- sf_close (outfile) ;
-
- if (abs (file_size (filename) - file_size (newfilename)) > 50)
- { puts ("Error : file size mismatch.\n") ;
- exit (1) ;
- } ;
-
- printf (" Renaming : %s\n", filename) ;
-
- if (remove (filename) != 0)
- { perror ("rename") ;
- exit (1) ;
- } ;
-
- if (rename (newfilename, filename) != 0)
- { perror ("rename") ;
- exit (1) ;
- } ;
-
- return ;
-} /* fix_file */
-
-static off_t
-file_size (char *filename)
-{ struct stat buf ;
-
- if (stat (filename, &buf) != 0)
- { perror ("stat") ;
- exit (1) ;
- } ;
-
- return buf.st_size ;
-} /* file_size */
-/*
-** 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: 5475655e-3898-40ff-969b-c8ab2351b0e4
-*/
diff --git a/libs/libsndfile/examples/generate.c b/libs/libsndfile/examples/generate.c
index 8228c12c4b..8a92332978 100644
--- a/libs/libsndfile/examples/generate.c
+++ b/libs/libsndfile/examples/generate.c
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 2002-2009 Erik de Castro Lopo
+** Copyright (C) 2002-2011 Erik de Castro Lopo
**
** All rights reserved.
**
@@ -119,7 +119,7 @@ encode_file (const char *infilename, const char *outfilename, int filetype)
} ;
while ((readcount = sf_read_float (infile, buffer, BUFFER_LEN)) > 0)
- sf_write_float (outfile, buffer, BUFFER_LEN) ;
+ sf_write_float (outfile, buffer, readcount) ;
sf_close (infile) ;
sf_close (outfile) ;
diff --git a/libs/libsndfile/examples/list_formats.c b/libs/libsndfile/examples/list_formats.c
index c529247da7..6d462f0790 100644
--- a/libs/libsndfile/examples/list_formats.c
+++ b/libs/libsndfile/examples/list_formats.c
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 2001-2009 Erik de Castro Lopo
+** Copyright (C) 2001-2011 Erik de Castro Lopo
**
** All rights reserved.
**
diff --git a/libs/libsndfile/examples/make_sine.c b/libs/libsndfile/examples/make_sine.c
index 3e760333b7..ec8a830272 100644
--- a/libs/libsndfile/examples/make_sine.c
+++ b/libs/libsndfile/examples/make_sine.c
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 1999-2009 Erik de Castro Lopo
+** Copyright (C) 1999-2011 Erik de Castro Lopo
**
** All rights reserved.
**
diff --git a/libs/libsndfile/examples/sfprocess.c b/libs/libsndfile/examples/sfprocess.c
index 42c98bdeb3..5c7db28843 100644
--- a/libs/libsndfile/examples/sfprocess.c
+++ b/libs/libsndfile/examples/sfprocess.c
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 2001-2009 Erik de Castro Lopo
+** Copyright (C) 2001-2011 Erik de Castro Lopo
**
** All rights reserved.
**
diff --git a/libs/libsndfile/examples/sndfile-convert.c b/libs/libsndfile/examples/sndfile-convert.c
deleted file mode 100644
index e1422579bd..0000000000
--- a/libs/libsndfile/examples/sndfile-convert.c
+++ /dev/null
@@ -1,376 +0,0 @@
-/*
-** Copyright (C) 1999-2005 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
-** 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
-#include
-#include
-#include
-
-#include
-
-#define BUFFER_LEN 1024
-
-
-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 void copy_data_fp (SNDFILE *outfile, SNDFILE *infile, int channels) ;
-static void copy_data_int (SNDFILE *outfile, SNDFILE *infile, int channels) ;
-
-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 },
- { "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 }
-} ; /* 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 [encoding] \n", progname) ;
- 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"
- ) ;
-
- 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 ;
-
- 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 ;
- } ;
-
- 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 ;
- } ;
-
- 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))
- copy_data_fp (outfile, infile, sfinfo.channels) ;
- else
- 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 ;
- 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)) ;
- if (sf_command (infile, SFC_GET_INSTRUMENT, &inst, sizeof (inst)) == SF_TRUE)
- sf_command (outfile, SFC_SET_INSTRUMENT, &inst, sizeof (inst)) ;
-
-} /* copy_metadata */
-
-static void
-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 ;
-} /* copy_data_fp */
-
-static void
-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 ;
-} /* copy_data_int */
-
-/*
-** 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: 259682b3-2887-48a6-b5bb-3cde00521ba3
-*/
diff --git a/libs/libsndfile/examples/sndfile-info.c b/libs/libsndfile/examples/sndfile-info.c
deleted file mode 100644
index 44e2ec174f..0000000000
--- a/libs/libsndfile/examples/sndfile-info.c
+++ /dev/null
@@ -1,354 +0,0 @@
-/*
-** Copyright (C) 1999-2006 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
-** 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
-#include
-#include
-#include
-#include
-
-#include
-
-#define BUFFER_LEN (1 << 16)
-
-#if (defined (WIN32) || defined (_WIN32))
-#define snprintf _snprintf
-#endif
-
-static void print_version (void) ;
-static void print_usage (const char *progname) ;
-
-static void info_dump (const char *filename) ;
-static void instrument_dump (const char *filename) ;
-static void broadcast_dump (const char *filename) ;
-
-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)
- { instrument_dump (argv [2]) ;
- return 0 ;
- } ;
-
- if (strcmp (argv [1], "-b") == 0)
- { broadcast_dump (argv [2]) ;
- return 0 ;
- } ;
-
- for (k = 1 ; k < argc ; k++)
- info_dump (argv [k]) ;
-
- 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 ...\n", progname) ;
- printf (" Prints out information about one or more sound files.\n\n") ;
- printf (" %s -i \n", progname) ;
- printf (" Prints out the instrument data for the given file.\n\n") ;
- printf (" %s -b \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, temp ;
- int readcount, k, save_state ;
-
- save_state = sf_command (file, SFC_GET_NORM_DOUBLE, NULL, 0) ;
- sf_command (file, SFC_SET_NORM_DOUBLE, NULL, SF_FALSE) ;
-
- max = 0.0 ;
- while ((readcount = sf_read_double (file, data, BUFFER_LEN)))
- { for (k = 0 ; k < readcount ; k++)
- { temp = fabs (data [k]) ;
- if (temp > max)
- max = temp ;
- } ;
- } ;
-
- sf_command (file, SFC_SET_NORM_DOUBLE, NULL, save_state) ;
-
- 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 *
-generate_duration_str (SF_INFO *sfinfo)
-{ static char str [128] ;
-
- int seconds ;
-
- memset (str, 0, sizeof (str)) ;
-
- if (sfinfo->samplerate < 1)
- return NULL ;
-
- if (sfinfo->frames / sfinfo->samplerate > 0x7FFFFFFF)
- return "unknown" ;
-
- seconds = sfinfo->frames / sfinfo->samplerate ;
-
- snprintf (str, sizeof (str) - 1, "%02d:", seconds / 60 / 60) ;
-
- seconds = seconds % (60 * 60) ;
- snprintf (str + strlen (str), sizeof (str) - strlen (str) - 1, "%02d:", seconds / 60) ;
-
- seconds = seconds % 60 ;
- snprintf (str + strlen (str), sizeof (str) - strlen (str) - 1, "%02d.", seconds) ;
-
- seconds = ((1000 * sfinfo->frames) / sfinfo->samplerate) % 1000 ;
- snprintf (str + strlen (str), sizeof (str) - strlen (str) - 1, "%03d", seconds) ;
-
- return str ;
-} /* 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") ;
-
- if (file == NULL)
- { printf ("Error : Not able to open input file %s.\n", filename) ;
- fflush (stdout) ;
- memset (data, 0, sizeof (data)) ;
- puts (sf_strerror (NULL)) ;
- }
- else
- { printf ("Sample Rate : %d\n", sfinfo.samplerate) ;
- if (sfinfo.frames > 0x7FFFFFFF)
- printf ("Frames : unknown\n") ;
- else
- printf ("Frames : %ld\n", (long) 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)) ;
-
- /* Do not use sf_signal_max because it doesn 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\n", signal_max, decibels) ;
- } ;
-
- 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 void
-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 ;
- } ;
-
- 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 ;
- } ;
-
- 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') ;
-} /* instrument_dump */
-
-static void
-broadcast_dump (const char *filename)
-{ SNDFILE *file ;
- SF_INFO sfinfo ;
- SF_BROADCAST_INFO bext ;
- 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 ;
- } ;
-
- memset (&bext, 0, sizeof (SF_BROADCAST_INFO)) ;
-
- 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 ;
- } ;
-
- 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) ;
- 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) ;
-
-} /* broadcast_dump */
-
-/*
-** 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: f59a05db-a182-41de-aedd-d717ce2bb099
-*/
diff --git a/libs/libsndfile/examples/sndfile-play-beos.cpp b/libs/libsndfile/examples/sndfile-play-beos.cpp
deleted file mode 100644
index 56f7415119..0000000000
--- a/libs/libsndfile/examples/sndfile-play-beos.cpp
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
-** Copyright (C) 2001 Marcus Overhagen
-**
-** 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
-
-#include
-#include
-#include
-
-#include
-
-#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 \n\n", argv [0]) ;
- return 1 ;
- } ;
-
- beos_play (argc, argv) ;
-
- 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: 5407a79d-88de-41c7-8d8e-9acf2cf13cc1
-*/
-
diff --git a/libs/libsndfile/examples/sndfile-play.c b/libs/libsndfile/examples/sndfile-play.c
deleted file mode 100644
index 7969693a44..0000000000
--- a/libs/libsndfile/examples/sndfile-play.c
+++ /dev/null
@@ -1,960 +0,0 @@
-/*
-** Copyright (C) 1999-2005 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
-** 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
-#include
-#include
-#include
-
-#if HAVE_UNISTD_H
-#include
-#endif
-
-#if HAVE_ALSA_ASOUNDLIB_H
- #define ALSA_PCM_NEW_HW_PARAMS_API
- #define ALSA_PCM_NEW_SW_PARAMS_API
- #include
- #include
-#endif
-
-#if defined (__linux__)
- #include
- #include
- #include
-
-#elif (defined (__MACH__) && defined (__APPLE__))
- #include
- #include
-
-#elif (defined (sun) && defined (unix))
- #include
- #include
- #include
-
-#elif (OS_IS_WIN32 == 1)
- #include
- #include
-
-#endif
-
-#include
-
-#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 = "plughw:0" ;
- snd_pcm_t *alsa_dev = NULL ;
- snd_pcm_hw_params_t *hw_params ;
- snd_pcm_uframes_t buffer_size, xfer_align, start_threshold ;
- 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_get_xfer_align (sw_params, &xfer_align)) < 0)
- { fprintf (stderr, "cannot get xfer align (%s)\n", snd_strerror (err)) ;
- goto catch_error ;
- } ;
-
- /* round up to closest transfer boundary */
- start_threshold = (buffer_size / xfer_align) * xfer_align ;
- if (start_threshold < 1)
- start_threshold = 1 ;
- if ((err = snd_pcm_sw_params_set_start_threshold (alsa_dev, sw_params, start_threshold)) < 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 ;
-
- snd_pcm_status_t *status ;
- 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)
- { 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") ;
- } ;
-
- 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, 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] ;
- write (audio_device, buffer, readcount * sizeof (short)) ;
- } ;
- }
- else
- { while ((readcount = sf_read_short (sndfile, buffer, BUFFER_LEN)))
- 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, SOUND_PCM_SETFMT, &fmt) != 0)
- { perror ("linux_open_dsp_device : set format ") ;
- exit (1) ;
- } ;
-
- if (ioctl (fd, SOUND_PCM_WRITE_CHANNELS, &channels) != 0)
- { perror ("linux_open_dsp_device : channels ") ;
- exit (1) ;
- } ;
-
- if (ioctl (fd, SOUND_PCM_WRITE_RATE, &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
-
-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 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 */
-
-/* This is needed for earlier versions of the M$ development tools. */
-#ifndef DWORD_PTR
-#define DWORD_PTR DWORD
-#endif
-
-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 \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 */
-/*
-** 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: 8fc4110d-6cec-4e03-91df-0f384cabedac
-*/
diff --git a/libs/libsndfile/examples/sndfile-to-text.c b/libs/libsndfile/examples/sndfile-to-text.c
index d7d6492d3b..7a7a219199 100644
--- a/libs/libsndfile/examples/sndfile-to-text.c
+++ b/libs/libsndfile/examples/sndfile-to-text.c
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 2008-2009 Erik de Castro Lopo
+** Copyright (C) 2008-2011 Erik de Castro Lopo
**
** All rights reserved.
**
diff --git a/libs/libsndfile/examples/sndfilehandle.cc b/libs/libsndfile/examples/sndfilehandle.cc
index 693a4422ed..c9a1931aea 100644
--- a/libs/libsndfile/examples/sndfilehandle.cc
+++ b/libs/libsndfile/examples/sndfilehandle.cc
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 2007 Erik de Castro Lopo
+** Copyright (C) 2007-2011 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
diff --git a/libs/libsndfile/man/Makefile.am b/libs/libsndfile/man/Makefile.am
index 574f924841..3f5d9efdc4 100644
--- a/libs/libsndfile/man/Makefile.am
+++ b/libs/libsndfile/man/Makefile.am
@@ -1,6 +1,15 @@
## Process this file with automake to produce Makefile.in
-man_MANS = sndfile-info.1 sndfile-play.1 sndfile-convert.1
+man_MANS = sndfile-info.1 sndfile-play.1 sndfile-convert.1 sndfile-cmp.1 \
+ sndfile-metadata-get.1 sndfile-metadata-set.1 sndfile-concat.1 \
+ sndfile-interleave.1 sndfile-deinterleave.1
-EXTRA_DIST = sndfile-info.1 sndfile-play.1 sndfile-convert.1
+EXTRA_DIST = sndfile-info.1 sndfile-play.1 sndfile-convert.1 sndfile-cmp.1 \
+ sndfile-metadata-get.1 sndfile-concat.1 sndfile-interleave.1
+# Same manpage for both programs.
+sndfile-metadata-set.1 : sndfile-metadata-get.1
+ $(LN_S) $(srcdir)/sndfile-metadata-get.1 $@
+
+sndfile-deinterleave.1 : sndfile-interleave.1
+ $(LN_S) $(srcdir)/sndfile-interleave.1 $@
diff --git a/libs/libsndfile/man/sndfile-convert.1 b/libs/libsndfile/man/sndfile-convert.1
index 7847173656..583c9562c9 100644
--- a/libs/libsndfile/man/sndfile-convert.1
+++ b/libs/libsndfile/man/sndfile-convert.1
@@ -16,7 +16,7 @@ The format of the output file is determined by the filename extension
of the output file.
.LP
The optional encoding parameter allows setting of the data encoding for
-the output file. Run "sndfile-convert --help" for more information.
+the output file. Run "sndfile\-convert \-\-help" for more information.
.SH AUTHOR
This manual page was written by Erik de Castro Lopo .
diff --git a/libs/libsndfile/programs/Makefile.am b/libs/libsndfile/programs/Makefile.am
index 5a3f9ee32b..b513c562c4 100644
--- a/libs/libsndfile/programs/Makefile.am
+++ b/libs/libsndfile/programs/Makefile.am
@@ -1,36 +1,47 @@
## 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
+bin_PROGRAMS = sndfile-info sndfile-play sndfile-convert sndfile-cmp \
+ sndfile-metadata-set sndfile-metadata-get sndfile-interleave \
+ sndfile-deinterleave sndfile-concat sndfile-salvage
OS_SPECIFIC_CFLAGS = @OS_SPECIFIC_CFLAGS@
OS_SPECIFIC_LINKS = @OS_SPECIFIC_LINKS@
INCLUDES = -I$(top_srcdir)/src $(OS_SPECIFIC_CFLAGS)
+CLEANFILES = *~
+
# 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_SOURCES = sndfile-info.c common.c common.h
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_play_SOURCES = sndfile-play.c common.c common.h
+sndfile_play_LDADD = $(top_builddir)/src/libsndfile.la $(OS_SPECIFIC_LINKS) $(ALSA_LIBS) $(SNDIO_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_SOURCES = sndfile-cmp.c common.c common.h
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_SOURCES = sndfile-metadata-get.c common.c common.h
sndfile_metadata_get_LDADD = $(top_builddir)/src/libsndfile.la
+sndfile_interleave_SOURCES = sndfile-interleave.c common.c common.h
+sndfile_interleave_LDADD = $(top_builddir)/src/libsndfile.la
+
+sndfile_deinterleave_SOURCES = sndfile-deinterleave.c common.c common.h
+sndfile_deinterleave_LDADD = $(top_builddir)/src/libsndfile.la
+
+sndfile_concat_SOURCES = sndfile-concat.c common.c common.h
+sndfile_concat_LDADD = $(top_builddir)/src/libsndfile.la
+
+sndfile_salvage_SOURCES = sndfile-salvage.c common.c common.h
+sndfile_salvage_LDADD = $(top_builddir)/src/libsndfile.la
+
diff --git a/libs/libsndfile/programs/common.c b/libs/libsndfile/programs/common.c
index d38d7472ad..41b8e6e499 100644
--- a/libs/libsndfile/programs/common.c
+++ b/libs/libsndfile/programs/common.c
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 1999-2009 Erik de Castro Lopo
+** Copyright (C) 1999-2011 Erik de Castro Lopo
** Copyright (C) 2008 George Blood Audio
**
** All rights reserved.
@@ -35,6 +35,7 @@
#include
#include
#include
+#include
#include
@@ -146,6 +147,14 @@ merge_broadcast_info (SNDFILE * infile, SNDFILE * outfile, int format, const MET
REPLACE_IF_NEW (origination_time) ;
REPLACE_IF_NEW (umid) ;
+ /* Special case for Time Ref. */
+ if (info->time_ref != NULL)
+ { uint64_t ts = atoll (info->time_ref) ;
+
+ binfo.time_reference_high = (ts >> 32) ;
+ binfo.time_reference_low = (ts & 0xffffffff) ;
+ } ;
+
/* Special case for coding_history because we may want to append. */
if (info->coding_history != NULL)
{ if (info->coding_hist_append)
@@ -180,22 +189,22 @@ update_strings (SNDFILE * outfile, const METADATA_INFO * info)
sf_set_string (outfile, SF_STR_TITLE, info->title) ;
if (info->copyright != NULL)
- sf_set_string (outfile, SF_STR_TITLE, info->copyright) ;
+ sf_set_string (outfile, SF_STR_COPYRIGHT, 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) ;
+ sf_set_string (outfile, SF_STR_COMMENT, 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) ;
+ sf_set_string (outfile, SF_STR_ALBUM, info->album) ;
if (info->license != NULL)
- sf_set_string (outfile, SF_STR_TITLE, info->license) ;
+ sf_set_string (outfile, SF_STR_LICENSE, info->license) ;
} /* update_strings */
@@ -238,8 +247,6 @@ sfe_apply_metadata_changes (const char * filenames [2], const METADATA_INFO * in
goto cleanup_exit ;
} ;
- update_strings (outfile, info) ;
-
if (infile != outfile)
{ int infileminor = SF_FORMAT_SUBMASK & sfinfo.format ;
@@ -250,6 +257,8 @@ sfe_apply_metadata_changes (const char * filenames [2], const METADATA_INFO * in
sfe_copy_data_int (outfile, infile, sfinfo.channels) ;
} ;
+ update_strings (outfile, info) ;
+
cleanup_exit :
if (outfile != NULL && outfile != infile)
@@ -264,3 +273,107 @@ cleanup_exit :
return ;
} /* sfe_apply_metadata_changes */
+/*==============================================================================
+*/
+
+typedef struct
+{ const char *ext ;
+ int len ;
+ int format ;
+} OUTPUT_FORMAT_MAP ;
+
+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 */
+
+int
+sfe_file_type_of_ext (const 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 ;
+ } ;
+
+ /* Default if all the above fails. */
+ return (SF_FORMAT_WAV | SF_FORMAT_PCM_24) ;
+} /* sfe_file_type_of_ext */
+
+void
+sfe_dump_format_map (void)
+{ SF_FORMAT_INFO info ;
+ int k ;
+
+ for (k = 0 ; k < ARRAY_LEN (format_map) ; 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 == NULL ? "????" : info.name) ;
+ } ;
+
+} /* sfe_dump_format_map */
+
+const char *
+program_name (const char * argv0)
+{ const char * tmp ;
+
+ tmp = strrchr (argv0, '/') ;
+ argv0 = tmp ? tmp + 1 : argv0 ;
+
+ tmp = strrchr (argv0, '/') ;
+ argv0 = tmp ? tmp + 1 : argv0 ;
+
+ /* Remove leading libtool name mangling. */
+ if (strstr (argv0, "lt-") == argv0)
+ return argv0 + 3 ;
+
+ return argv0 ;
+} /* program_name */
diff --git a/libs/libsndfile/programs/common.h b/libs/libsndfile/programs/common.h
index dd4d54dd87..999690d909 100644
--- a/libs/libsndfile/programs/common.h
+++ b/libs/libsndfile/programs/common.h
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 1999-2009 Erik de Castro Lopo
+** Copyright (C) 1999-2011 Erik de Castro Lopo
**
** All rights reserved.
**
@@ -30,7 +30,9 @@
** ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include
+
+#define ARRAY_LEN(x) ((int) (sizeof (x) / sizeof (x [0])))
+#define MAX(a,b) ((a) > (b) ? (a) : (b))
typedef struct
{ const char * title ;
@@ -53,6 +55,7 @@ typedef struct
const char * origination_time ;
const char * umid ;
const char * coding_history ;
+ const char * time_ref ;
} METADATA_INFO ;
typedef SF_BROADCAST_INFO_VAR (2048) SF_BROADCAST_INFO_2K ;
@@ -62,3 +65,9 @@ void sfe_apply_metadata_changes (const char * filenames [2], const METADATA_INFO
void sfe_copy_data_fp (SNDFILE *outfile, SNDFILE *infile, int channels) ;
void sfe_copy_data_int (SNDFILE *outfile, SNDFILE *infile, int channels) ;
+
+int sfe_file_type_of_ext (const char *filename, int format) ;
+
+void sfe_dump_format_map (void) ;
+
+const char * program_name (const char * argv0) ;
diff --git a/libs/libsndfile/programs/sndfile-cmp.c b/libs/libsndfile/programs/sndfile-cmp.c
index 59cfbb12b1..f550d13d4f 100644
--- a/libs/libsndfile/programs/sndfile-cmp.c
+++ b/libs/libsndfile/programs/sndfile-cmp.c
@@ -1,5 +1,6 @@
/*
-** Copyright (C) 2008-2009 Erik de Castro Lopo
+** Copyright (C) 2008-2011 Erik de Castro Lopo
+** Copyright (C) 2008 Conrad Parker
**
** All rights reserved.
**
@@ -30,27 +31,31 @@
** ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-/* sndfile-cmp.c
- * Conrad Parker 2008
- */
-
-
#include "sfconfig.h"
#include
+#include
#include
+#include
#include
+#include "common.h"
+
/* Length of comparison data buffers in units of items */
#define BUFLEN 65536
-static char * progname ;
-static char * filename1, * filename2 ;
+static const char * progname = NULL ;
+static char * filename1 = NULL, * filename2 = NULL ;
static int
-comparison_error (const char * what)
-{ printf ("%s: %s of files %s and %s differ\n", progname, what, filename1, filename2) ;
+comparison_error (const char * what, sf_count_t frame_offset)
+{ char buffer [128] = "" ;
+
+ if (frame_offset >= 0)
+ snprintf (buffer, sizeof (buffer), " (at frame offset %" PRId64 ")", frame_offset) ;
+
+ printf ("%s: %s of files %s and %s differ%s.\n", progname, what, filename1, filename2, buffer) ;
return 1 ;
} /* comparison_error */
@@ -60,7 +65,7 @@ compare (void)
double buf1 [BUFLEN], buf2 [BUFLEN] ;
SF_INFO sfinfo1, sfinfo2 ;
SNDFILE * sf1 = NULL, * sf2 = NULL ;
- sf_count_t len, i, nread1, nread2 ;
+ sf_count_t items, i, nread1, nread2, offset = 0 ;
int retval = 0 ;
memset (&sfinfo1, 0, sizeof (SF_INFO)) ;
@@ -80,34 +85,35 @@ compare (void)
} ;
if (sfinfo1.samplerate != sfinfo2.samplerate)
- { retval = comparison_error ("Samplerates") ;
+ { retval = comparison_error ("Samplerates", -1) ;
goto out ;
} ;
if (sfinfo1.channels != sfinfo2.channels)
- { retval = comparison_error ("Number of channels") ;
+ { retval = comparison_error ("Number of channels", -1) ;
goto out ;
} ;
/* Calculate the framecount that will fit in our data buffers */
- len = BUFLEN / sfinfo1.channels ;
+ items = BUFLEN / sfinfo1.channels ;
- while ( (nread1 = sf_readf_double (sf1, buf1, len)) > 0)
+ while ( (nread1 = sf_readf_double (sf1, buf1, items)) > 0)
{ nread2 = sf_readf_double (sf2, buf2, nread1) ;
if (nread2 != nread1)
- { retval = comparison_error ("PCM data lengths") ;
+ { retval = comparison_error ("PCM data lengths", -1) ;
goto out ;
} ;
- for (i = 0 ; i < nread1 ; i++)
+ for (i = 0 ; i < nread1 * sfinfo1.channels ; i++)
{ if (buf1 [i] != buf2 [i])
- { retval = comparison_error ("PCM data") ;
+ { retval = comparison_error ("PCM data", offset + i / sfinfo1.channels) ;
goto out ;
} ;
} ;
+ offset += nread1 ;
} ;
if ( (nread2 = sf_readf_double (sf2, buf2, nread1)) != 0)
- { retval = comparison_error ("PCM data lengths") ;
+ { retval = comparison_error ("PCM data lengths", -1) ;
goto out ;
} ;
@@ -127,22 +133,22 @@ print_version (void)
} /* print_version */
static void
-print_usage (void)
+usage_exit (void)
{
print_version () ;
printf ("Usage : %s \n", progname) ;
printf (" Compare the PCM data of two sound files.\n\n") ;
-} /* print_usage */
+ exit (0) ;
+} /* usage_exit */
int
main (int argc, char *argv [])
{
- progname = strrchr (argv [0], '/') ;
- progname = progname ? progname + 1 : argv [0] ;
+ progname = program_name (argv [0]) ;
if (argc != 3)
- { print_usage () ;
+ { usage_exit () ;
return 1 ;
} ;
@@ -151,7 +157,7 @@ main (int argc, char *argv [])
if (strcmp (filename1, filename2) == 0)
{ printf ("Error : Input filenames are the same.\n\n") ;
- print_usage () ;
+ usage_exit () ;
return 1 ;
} ;
diff --git a/libs/libsndfile/programs/sndfile-convert.c b/libs/libsndfile/programs/sndfile-convert.c
index f1aa58ebd0..09889829a2 100644
--- a/libs/libsndfile/programs/sndfile-convert.c
+++ b/libs/libsndfile/programs/sndfile-convert.c
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 1999-2009 Erik de Castro Lopo
+** Copyright (C) 1999-2011 Erik de Castro Lopo
**
** All rights reserved.
**
@@ -45,93 +45,18 @@ typedef struct
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 copy_metadata (SNDFILE *outfile, SNDFILE *infile, int channels) ;
static void
-print_usage (char *progname)
-{ SF_FORMAT_INFO info ;
-
- int k ;
-
+usage_exit (const char *progname)
+{
printf ("\nUsage : %s [options] [encoding] \n", progname) ;
puts ("\n"
" where [option] may be:\n\n"
- " -override-sample-rate=X : force sample rate of input to X\n\n"
+ " -override-sample-rate=X : force sample rate of input to X\n"
) ;
- puts ("\n"
+ puts (
" 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"
@@ -157,28 +82,24 @@ print_usage (char *progname)
" 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) ;
- } ;
+ sfe_dump_format_map () ;
puts ("") ;
-} /* print_usage */
+ exit (0) ;
+} /* usage_exit */
int
main (int argc, char * argv [])
-{ char *progname, *infilename, *outfilename ;
+{ const 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] ;
+ progname = program_name (argv [0]) ;
if (argc < 3 || argc > 5)
- { print_usage (progname) ;
+ { usage_exit (progname) ;
return 1 ;
} ;
@@ -187,19 +108,19 @@ main (int argc, char * argv [])
if (strcmp (infilename, outfilename) == 0)
{ printf ("Error : Input and output filenames are the same.\n\n") ;
- print_usage (progname) ;
+ usage_exit (progname) ;
return 1 ;
} ;
- if (infilename [0] == '-')
+ if (strlen (infilename) > 1 && infilename [0] == '-')
{ printf ("Error : Input filename (%s) looks like an option.\n\n", infilename) ;
- print_usage (progname) ;
+ usage_exit (progname) ;
return 1 ;
} ;
if (outfilename [0] == '-')
{ printf ("Error : Output filename (%s) looks like an option.\n\n", outfilename) ;
- print_usage (progname) ;
+ usage_exit (progname) ;
return 1 ;
} ;
@@ -277,6 +198,8 @@ main (int argc, char * argv [])
exit (1) ;
} ;
+ memset (&sfinfo, 0, sizeof (sfinfo)) ;
+
if ((infile = sf_open (infilename, SFM_READ, &sfinfo)) == NULL)
{ printf ("Not able to open input file %s.\n", infilename) ;
puts (sf_strerror (NULL)) ;
@@ -289,7 +212,7 @@ main (int argc, char * argv [])
infileminor = sfinfo.format & SF_FORMAT_SUBMASK ;
- if ((sfinfo.format = guess_output_file_type (outfilename, sfinfo.format)) == 0)
+ if ((sfinfo.format = sfe_file_type_of_ext (outfilename, sfinfo.format)) == 0)
{ printf ("Error : Not able to determine output file type for %s.\n", outfilename) ;
return 1 ;
} ;
@@ -328,7 +251,7 @@ main (int argc, char * argv [])
} ;
/* Copy the metadata */
- copy_metadata (outfile, infile) ;
+ copy_metadata (outfile, infile, sfinfo.channels) ;
if ((outfileminor == SF_FORMAT_DOUBLE) || (outfileminor == SF_FORMAT_FLOAT)
|| (infileminor == SF_FORMAT_DOUBLE) || (infileminor == SF_FORMAT_FLOAT)
@@ -344,21 +267,28 @@ main (int argc, char * argv [])
} /* main */
static void
-copy_metadata (SNDFILE *outfile, SNDFILE *infile)
+copy_metadata (SNDFILE *outfile, SNDFILE *infile, int channels)
{ SF_INSTRUMENT inst ;
SF_BROADCAST_INFO_2K binfo ;
const char *str ;
- int k, err = 0 ;
+ int k, chanmap [256] ;
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) ;
+ sf_set_string (outfile, k, str) ;
} ;
memset (&inst, 0, sizeof (inst)) ;
memset (&binfo, 0, sizeof (binfo)) ;
+ if (channels < ARRAY_LEN (chanmap))
+ { size_t size = channels * sizeof (chanmap [0]) ;
+
+ if (sf_command (infile, SFC_GET_CHANNEL_MAP_INFO, chanmap, size) == SF_TRUE)
+ sf_command (outfile, SFC_SET_CHANNEL_MAP_INFO, chanmap, size) ;
+ } ;
+
if (sf_command (infile, SFC_GET_INSTRUMENT, &inst, sizeof (inst)) == SF_TRUE)
sf_command (outfile, SFC_SET_INSTRUMENT, &inst, sizeof (inst)) ;
diff --git a/libs/libsndfile/programs/sndfile-info.c b/libs/libsndfile/programs/sndfile-info.c
index 3ac12a8f04..5663044f01 100644
--- a/libs/libsndfile/programs/sndfile-info.c
+++ b/libs/libsndfile/programs/sndfile-info.c
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 1999-2009 Erik de Castro Lopo
+** Copyright (C) 1999-2011 Erik de Castro Lopo
**
** All rights reserved.
**
@@ -45,15 +45,15 @@
#if (defined (WIN32) || defined (_WIN32))
#include
-#define snprintf _snprintf
#endif
static void print_version (void) ;
-static void print_usage (const char *progname) ;
+static void usage_exit (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 int chanmap_dump (const char *filename) ;
static void total_dump (void) ;
static double total_seconds = 0.0 ;
@@ -65,12 +65,7 @@ main (int argc, char *argv [])
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) ;
+ { usage_exit (program_name (argv [0])) ;
return 1 ;
} ;
@@ -90,6 +85,14 @@ main (int argc, char *argv [])
return error ;
} ;
+ if (strcmp (argv [1], "-c") == 0)
+ { int error = 0 ;
+
+ for (k = 2 ; k < argc ; k++)
+ error += chanmap_dump (argv [k]) ;
+ return error ;
+ } ;
+
for (k = 1 ; k < argc ; k++)
info_dump (argv [k]) ;
@@ -115,7 +118,7 @@ print_version (void)
static void
-print_usage (const char *progname)
+usage_exit (const char *progname)
{ printf ("Usage :\n %s ...\n", progname) ;
printf (" Prints out information about one or more sound files.\n\n") ;
printf (" %s -i \n", progname) ;
@@ -135,7 +138,9 @@ print_usage (const char *progname)
*/
Sleep (5 * 1000) ;
#endif
-} /* print_usage */
+ printf ("Using %s.\n\n", sf_version_string ()) ;
+ exit (0) ;
+} /* usage_exit */
/*==============================================================================
** Dumping of sndfile info.
@@ -248,7 +253,12 @@ info_dump (const char *filename)
printf ("----------------------------------------\n") ;
printf ("Sample Rate : %d\n", sfinfo.samplerate) ;
- printf ("Frames : %" PRId64 "\n", sfinfo.frames) ;
+
+ if (sfinfo.frames == SF_COUNT_MAX)
+ printf ("Frames : unknown\n") ;
+ else
+ 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) ;
@@ -379,6 +389,82 @@ broadcast_dump (const char *filename)
return 0 ;
} /* broadcast_dump */
+static int
+chanmap_dump (const char *filename)
+{ SNDFILE *file ;
+ SF_INFO sfinfo ;
+ int * channel_map ;
+ int got_chanmap, 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 ;
+ } ;
+
+ if ((channel_map = calloc (sfinfo.channels, sizeof (int))) == NULL)
+ { printf ("Error : malloc failed.\n\n") ;
+ return 1 ;
+ } ;
+
+ got_chanmap = sf_command (file, SFC_GET_CHANNEL_MAP_INFO, channel_map, sfinfo.channels * sizeof (int)) ;
+ sf_close (file) ;
+
+ if (got_chanmap == SF_FALSE)
+ { printf ("Error : File '%s' does not contain channel map information.\n\n", filename) ;
+ free (channel_map) ;
+ return 1 ;
+ } ;
+
+ printf ("File : %s\n\n", filename) ;
+
+ puts (" Chan Position") ;
+ for (k = 0 ; k < sfinfo.channels ; k ++)
+ { const char * name ;
+
+#define CASE_NAME(x) case x : name = #x ; break ;
+ switch (channel_map [k])
+ { CASE_NAME (SF_CHANNEL_MAP_INVALID) ;
+ CASE_NAME (SF_CHANNEL_MAP_MONO) ;
+ CASE_NAME (SF_CHANNEL_MAP_LEFT) ;
+ CASE_NAME (SF_CHANNEL_MAP_RIGHT) ;
+ CASE_NAME (SF_CHANNEL_MAP_CENTER) ;
+ CASE_NAME (SF_CHANNEL_MAP_FRONT_LEFT) ;
+ CASE_NAME (SF_CHANNEL_MAP_FRONT_RIGHT) ;
+ CASE_NAME (SF_CHANNEL_MAP_FRONT_CENTER) ;
+ CASE_NAME (SF_CHANNEL_MAP_REAR_CENTER) ;
+ CASE_NAME (SF_CHANNEL_MAP_REAR_LEFT) ;
+ CASE_NAME (SF_CHANNEL_MAP_REAR_RIGHT) ;
+ CASE_NAME (SF_CHANNEL_MAP_LFE) ;
+ CASE_NAME (SF_CHANNEL_MAP_FRONT_LEFT_OF_CENTER) ;
+ CASE_NAME (SF_CHANNEL_MAP_FRONT_RIGHT_OF_CENTER) ;
+ CASE_NAME (SF_CHANNEL_MAP_SIDE_LEFT) ;
+ CASE_NAME (SF_CHANNEL_MAP_SIDE_RIGHT) ;
+ CASE_NAME (SF_CHANNEL_MAP_TOP_CENTER) ;
+ CASE_NAME (SF_CHANNEL_MAP_TOP_FRONT_LEFT) ;
+ CASE_NAME (SF_CHANNEL_MAP_TOP_FRONT_RIGHT) ;
+ CASE_NAME (SF_CHANNEL_MAP_TOP_FRONT_CENTER) ;
+ CASE_NAME (SF_CHANNEL_MAP_TOP_REAR_LEFT) ;
+ CASE_NAME (SF_CHANNEL_MAP_TOP_REAR_RIGHT) ;
+ CASE_NAME (SF_CHANNEL_MAP_TOP_REAR_CENTER) ;
+ CASE_NAME (SF_CHANNEL_MAP_MAX) ;
+ default : name = "default" ;
+ break ;
+ } ;
+
+ printf (" %3d %s\n", k, name) ;
+ } ;
+
+ putchar ('\n') ;
+ free (channel_map) ;
+
+ return 0 ;
+} /* chanmap_dump */
+
static void
total_dump (void)
{ printf ("========================================\n") ;
diff --git a/libs/libsndfile/programs/sndfile-jackplay.c b/libs/libsndfile/programs/sndfile-jackplay.c
deleted file mode 100644
index 87b722de2f..0000000000
--- a/libs/libsndfile/programs/sndfile-jackplay.c
+++ /dev/null
@@ -1,277 +0,0 @@
-/*
-** Copyright (c) 2007-2009 Erik de Castro Lopo
-** Copyright (C) 2007 Jonatan Liljedahl
-**
-** 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
-#include
-#include
-#include
-#include
-
-#if HAVE_JACK
-
-#include
-#include
-
-#include
-#include
-
-#include
-
-#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
diff --git a/libs/libsndfile/programs/sndfile-metadata-get.c b/libs/libsndfile/programs/sndfile-metadata-get.c
index 1d370b38e5..b77ef4f4b7 100644
--- a/libs/libsndfile/programs/sndfile-metadata-get.c
+++ b/libs/libsndfile/programs/sndfile-metadata-get.c
@@ -1,6 +1,6 @@
/*
-** Copyright (C) 2008 George Blood Audio
-** Written by Erik de Castro Lopo
+** Copyright (C) 2008-2011 Erik de Castro Lopo
+** Copyright (C) 2008-2010 George Blood Audio
**
** All rights reserved.
**
@@ -58,8 +58,7 @@ main (int argc, char *argv [])
int start ;
/* Store the program name. */
- progname = strrchr (argv [0], '/') ;
- progname = progname ? progname + 1 : argv [0] ;
+ progname = program_name (argv [0]) ;
/* Check if we've been asked for help. */
if (argc <= 2 || strcmp (argv [1], "--help") == 0 || strcmp (argv [1], "-h") == 0)
@@ -123,6 +122,7 @@ usage_exit (const char *progname, int exit_code)
" --str-license Print the license metadata.\n"
) ;
+ printf ("Using %s.\n\n", sf_version_string ()) ;
exit (exit_code) ;
} /* usage_exit */
diff --git a/libs/libsndfile/programs/sndfile-metadata-set.c b/libs/libsndfile/programs/sndfile-metadata-set.c
index 58e1922fa9..cf0babfc2e 100644
--- a/libs/libsndfile/programs/sndfile-metadata-set.c
+++ b/libs/libsndfile/programs/sndfile-metadata-set.c
@@ -1,6 +1,6 @@
/*
-** Copyright (C) 2008 George Blood Audio
-** Written by Erik de Castro Lopo
+** Copyright (C) 2008-2011 Erik de Castro Lopo
+** Copyright (C) 2008-2010 George Blood Audio
**
** All rights reserved.
**
@@ -60,8 +60,7 @@ main (int argc, char *argv [])
int k ;
/* Store the program name. */
- progname = strrchr (argv [0], '/') ;
- progname = progname ? progname + 1 : argv [0] ;
+ progname = program_name (argv [0]) ;
/* Check if we've been asked for help. */
if (argc < 3 || strcmp (argv [1], "--help") == 0 || strcmp (argv [1], "-h") == 0)
@@ -103,6 +102,7 @@ main (int argc, char *argv [])
HANDLE_BEXT_ARG ("--bext-orig-date", origination_date) ;
HANDLE_BEXT_ARG ("--bext-orig-time", origination_time) ;
HANDLE_BEXT_ARG ("--bext-coding-hist", coding_history) ;
+ HANDLE_BEXT_ARG ("--bext-time-ref", time_ref) ;
#define HANDLE_STR_ARG(cmd,field) \
if (strcmp (argv [k], cmd) == 0) \
@@ -112,6 +112,7 @@ main (int argc, char *argv [])
continue ; \
} ;
+ HANDLE_STR_ARG ("--str-comment", comment) ;
HANDLE_STR_ARG ("--str-title", title) ;
HANDLE_STR_ARG ("--str-copyright", copyright) ;
HANDLE_STR_ARG ("--str-artist", artist) ;
@@ -206,8 +207,10 @@ usage_exit (const char *progname, int exit_code)
" --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"
+ " --bext-coding-hist Set the 'bext' coding history.\n"
+ " --bext-time-raf Set the 'bext' Time ref.\n"
"\n"
+ " --str-comment Set the metadata comment.\n"
" --str-title Set the metadata title.\n"
" --str-copyright Set the metadata copyright.\n"
" --str-artist Set the metadata artist.\n"
@@ -231,6 +234,7 @@ usage_exit (const char *progname, int exit_code)
"exit with an appropriate error message.\n"
) ;
+ printf ("Using %s.\n\n", sf_version_string ()) ;
exit (exit_code) ;
} /* usage_exit */
@@ -250,7 +254,7 @@ 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)
+ if (info->origination_date || info->origination_time || info->umid || info->coding_history || info->time_ref)
return 1 ;
return 0 ;
diff --git a/libs/libsndfile/programs/sndfile-play.c b/libs/libsndfile/programs/sndfile-play.c
index 56d1a7b06c..f2a32d7e7f 100644
--- a/libs/libsndfile/programs/sndfile-play.c
+++ b/libs/libsndfile/programs/sndfile-play.c
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 1999-2009 Erik de Castro Lopo
+** Copyright (C) 1999-2011 Erik de Castro Lopo
**
** All rights reserved.
**
@@ -41,6 +41,10 @@
#include
#endif
+#include
+
+#include "common.h"
+
#if HAVE_ALSA_ASOUNDLIB_H
#define ALSA_PCM_NEW_HW_PARAMS_API
#define ALSA_PCM_NEW_SW_PARAMS_API
@@ -48,7 +52,7 @@
#include
#endif
-#if defined (__linux__)
+#if defined (__linux__) || defined (__FreeBSD_kernel__) || defined (__FreeBSD__)
#include
#include
#include
@@ -57,6 +61,9 @@
#include
#include
+#elif defined (HAVE_SNDIO_H)
+ #include
+
#elif (defined (sun) && defined (unix))
#include
#include
@@ -68,8 +75,6 @@
#endif
-#include
-
#define SIGNED_SIZEOF(x) ((int) sizeof (x))
#define BUFFER_LEN (2048)
@@ -348,12 +353,12 @@ alsa_write_float (snd_pcm_t *alsa_dev, float *data, int frames, int channels)
** Linux/OSS functions for playing a sound.
*/
-#if defined (__linux__)
+#if defined (__linux__) || defined (__FreeBSD_kernel__) || defined (__FreeBSD__)
-static int linux_open_dsp_device (int channels, int srate) ;
+static int opensoundsys_open_device (int channels, int srate) ;
-static void
-linux_play (int argc, char *argv [])
+static int
+opensoundsys_play (int argc, char *argv [])
{ static short buffer [BUFFER_LEN] ;
SNDFILE *sndfile ;
SF_INFO sfinfo ;
@@ -373,7 +378,7 @@ linux_play (int argc, char *argv [])
continue ;
} ;
- audio_device = linux_open_dsp_device (sfinfo.channels, sfinfo.samplerate) ;
+ audio_device = opensoundsys_open_device (sfinfo.channels, sfinfo.samplerate) ;
subformat = sfinfo.format & SF_FORMAT_SUBMASK ;
@@ -410,54 +415,54 @@ linux_play (int argc, char *argv [])
sf_close (sndfile) ;
} ;
- return ;
-} /* linux_play */
+ return writecount ;
+} /* opensoundsys_play */
static int
-linux_open_dsp_device (int channels, int srate)
+opensoundsys_open_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 ") ;
+ { perror ("opensoundsys_open_device : open ") ;
exit (1) ;
} ;
stereo = 0 ;
if (ioctl (fd, SNDCTL_DSP_STEREO, &stereo) == -1)
{ /* Fatal error */
- perror ("linux_open_dsp_device : stereo ") ;
+ perror ("opensoundsys_open_device : stereo ") ;
exit (1) ;
} ;
if (ioctl (fd, SNDCTL_DSP_RESET, 0))
- { perror ("linux_open_dsp_device : reset ") ;
+ { perror ("opensoundsys_open_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 ") ;
+ { perror ("opensoundsys_open_device : set format ") ;
exit (1) ;
} ;
if (ioctl (fd, SNDCTL_DSP_CHANNELS, &channels) != 0)
- { perror ("linux_open_dsp_device : channels ") ;
+ { perror ("opensoundsys_open_device : channels ") ;
exit (1) ;
} ;
if (ioctl (fd, SNDCTL_DSP_SPEED, &srate) != 0)
- { perror ("linux_open_dsp_device : sample rate ") ;
+ { perror ("opensoundsys_open_device : sample rate ") ;
exit (1) ;
} ;
if (ioctl (fd, SNDCTL_DSP_SYNC, 0) != 0)
- { perror ("linux_open_dsp_device : sync ") ;
+ { perror ("opensoundsys_open_device : sync ") ;
exit (1) ;
} ;
return fd ;
-} /* linux_open_dsp_device */
+} /* opensoundsys_open_device */
#endif /* __linux__ */
@@ -819,6 +824,66 @@ win32_play (int argc, char *argv [])
#endif /* Win32 */
+/*------------------------------------------------------------------------------
+** OpenBDS's sndio.
+*/
+
+#if defined (HAVE_SNDIO_H)
+
+static void
+sndio_play (int argc, char *argv [])
+{ struct sio_hdl *hdl ;
+ struct sio_par par ;
+ short buffer [BUFFER_LEN] ;
+ SNDFILE *sndfile ;
+ SF_INFO sfinfo ;
+ int k, readcount ;
+
+ 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 ;
+ } ;
+
+ if ((hdl = sio_open (NULL, SIO_PLAY, 0)) == NULL)
+ { fprintf (stderr, "open sndio device failed") ;
+ return ;
+ } ;
+
+ sio_initpar (&par) ;
+ par.rate = sfinfo.samplerate ;
+ par.pchan = sfinfo.channels ;
+ par.bits = 16 ;
+ par.sig = 1 ;
+ par.le = SIO_LE_NATIVE ;
+
+ if (! sio_setpar (hdl, &par) || ! sio_getpar (hdl, &par))
+ { fprintf (stderr, "set sndio params failed") ;
+ return ;
+ } ;
+
+ if (! sio_start (hdl))
+ { fprintf (stderr, "sndio start failed") ;
+ return ;
+ } ;
+
+ while ((readcount = sf_read_short (sndfile, buffer, BUFFER_LEN)))
+ sio_write (hdl, buffer, readcount * sizeof (short)) ;
+
+ sio_close (hdl) ;
+ } ;
+
+ return ;
+} /* sndio_play */
+
+#endif /* sndio */
+
/*------------------------------------------------------------------------------
** Solaris.
*/
@@ -914,17 +979,13 @@ main (int argc, char *argv [])
{
if (argc < 2)
{
- printf ("\nUsage : %s \n\n", argv [0]) ;
+ printf ("\nUsage : %s \n\n", program_name (argv [0])) ;
+ printf (" Using %s.\n\n", sf_version_string ()) ;
#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 ;
@@ -936,9 +997,13 @@ main (int argc, char *argv [])
alsa_play (argc, argv) ;
else
#endif
- linux_play (argc, argv) ;
+ opensoundsys_play (argc, argv) ;
+#elif defined (__FreeBSD_kernel__) || defined (__FreeBSD__)
+ opensoundsys_play (argc, argv) ;
#elif (defined (__MACH__) && defined (__APPLE__))
macosx_play (argc, argv) ;
+#elif defined HAVE_SNDIO_H
+ sndio_play (argc, argv) ;
#elif (defined (sun) && defined (unix))
solaris_play (argc, argv) ;
#elif (OS_IS_WIN32 == 1)
diff --git a/libs/libsndfile/programs/test-sndfile-metadata-set.py b/libs/libsndfile/programs/test-sndfile-metadata-set.py
old mode 100644
new mode 100755
index 248cb70cd1..a21a36b3d1
--- a/libs/libsndfile/programs/test-sndfile-metadata-set.py
+++ b/libs/libsndfile/programs/test-sndfile-metadata-set.py
@@ -1,6 +1,6 @@
#!/usr/bin/python
-# Copyright (C) 2008 Erik de Castro Lopo
+# Copyright (C) 2008-2011 Erik de Castro Lopo
#
# All rights reserved.
#
@@ -176,7 +176,8 @@ test_post_mod (tests)
test_update ([ ("--str-artist", "Fox") ])
-test_coding_history ()
+# This never worked.
+# test_coding_history ()
test_rewrite ()
diff --git a/libs/libsndfile/reconfigure.mk b/libs/libsndfile/reconfigure.mk
deleted file mode 100644
index 5ec5943ea8..0000000000
--- a/libs/libsndfile/reconfigure.mk
+++ /dev/null
@@ -1,63 +0,0 @@
-#!/usr/bin/make -f
-
-# The auto tools MUST be run in the following order:
-#
-# 1. aclocal
-# 2. libtoolize (if you use libtool)
-# 3. autoconf
-# 4. autoheader (if you use autoheader)
-# 5. automake (if you use automake)
-#
-# The following makefile runs these in the correct order according to their
-# dependancies. It also makes up for Mac OSX's fucked-upped-ness.
-
-ACLOCAL = aclocal
-
-ifneq ($(shell uname -s), Darwin)
- LIBTOOLIZE = libtoolize
-else
- # Fuck Apple! Why the hell did they rename libtoolize????
- LIBTOOLIZE = glibtoolize
- # Fink sucks as well, but this seems necessary.
- ACLOCAL_INC = -I /sw/share/aclocal
-endif
-
-genfiles : config.status
- (cd src && make genfiles)
- (cd tests && make genfiles)
-
-config.status: configure src/config.h.in Makefile.in src/Makefile.in tests/Makefile.in
- ./configure --enable-gcc-werror
-
-configure: ltmain.sh
- autoconf
-
-Makefile.in: Makefile.am
- automake --copy --add-missing
-
-src/Makefile.in: src/Makefile.am
- automake --copy --add-missing
-
-tests/Makefile.in: tests/Makefile.am
- automake --copy --add-missing
-
-src/config.h.in: configure
- autoheader
-
-libtool ltmain.sh: aclocal.m4
- $(LIBTOOLIZE) --copy --force
-
-# Need to re-run aclocal whenever acinclude.m4 is modified.
-aclocal.m4: acinclude.m4
- $(ACLOCAL) $(ACLOCAL_INC)
-
-clean:
- rm -f libtool ltmain.sh aclocal.m4 Makefile.in src/config.h.in config.cache config.status
- find . -name .deps -type d -exec rm -rf {} \;
-
-
-# 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: 2b02bfd0-d5ed-489b-a554-2bf36903cca9
diff --git a/libs/libsndfile/regtest/checksum.c b/libs/libsndfile/regtest/checksum.c
index 863fbed708..7f433a41c8 100644
--- a/libs/libsndfile/regtest/checksum.c
+++ b/libs/libsndfile/regtest/checksum.c
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 2005-2009 Erik de Castro Lopo
+** Copyright (C) 2005-2011 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
diff --git a/libs/libsndfile/regtest/database.c b/libs/libsndfile/regtest/database.c
index f439f685df..f800a2c873 100644
--- a/libs/libsndfile/regtest/database.c
+++ b/libs/libsndfile/regtest/database.c
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 2005-2009 Erik de Castro Lopo
+** Copyright (C) 2005-2011 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
@@ -146,7 +146,7 @@ db_file_exists (REG_DB * db_handle, const char * filename)
db->count = 0 ;
err = sqlite3_exec (db->sql, db->cmdbuf, (sqlite3_callback) count_callback, db, &errmsg) ;
- if (db->count == 1)
+ if (err == 0 && db->count == 1)
return 1 ;
return 0 ;
diff --git a/libs/libsndfile/regtest/regtest.h b/libs/libsndfile/regtest/regtest.h
index 589f386de8..567d97be28 100644
--- a/libs/libsndfile/regtest/regtest.h
+++ b/libs/libsndfile/regtest/regtest.h
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 2005 Erik de Castro Lopo
+** Copyright (C) 2005-2011 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
diff --git a/libs/libsndfile/regtest/sndfile-regtest.c b/libs/libsndfile/regtest/sndfile-regtest.c
index f7db490bd0..a28caa2d84 100644
--- a/libs/libsndfile/regtest/sndfile-regtest.c
+++ b/libs/libsndfile/regtest/sndfile-regtest.c
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 2005-2009 Erik de Castro Lopo
+** Copyright (C) 2005-2011 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
diff --git a/libs/libsndfile/sndfile.pc.in b/libs/libsndfile/sndfile.pc.in
index f2a833bddb..28269c19eb 100644
--- a/libs/libsndfile/sndfile.pc.in
+++ b/libs/libsndfile/sndfile.pc.in
@@ -8,4 +8,5 @@ Description: A library for reading and writing audio files
Requires:
Version: @VERSION@
Libs: -L${libdir} -lsndfile
+Libs.private: @EXTERNAL_LIBS@
Cflags: -I${includedir}
diff --git a/libs/libsndfile/src/G72x/Makefile.am b/libs/libsndfile/src/G72x/Makefile.am
deleted file mode 100644
index 62a0aa112f..0000000000
--- a/libs/libsndfile/src/G72x/Makefile.am
+++ /dev/null
@@ -1,22 +0,0 @@
-## Process this file with automake to produce Makefile.in
-
-EXTRA_DIST = README README.original ChangeLog
-
-noinst_HEADERS = g72x.h g72x_priv.h
-noinst_LTLIBRARIES = libg72x.la
-
-noinst_PROGRAMS = g72x_test
-
-CFILES = g72x.c g721.c g723_16.c g723_24.c g723_40.c
-
-libg72x_la_SOURCES = $(CFILES) $(noinst_HEADERS)
-
-g72x_test_SOURCES = g72x_test.c
-g72x_test_LDADD = ./libg72x.la -lm
-
-check: g72x_test$(EXEEXT)
- ./g72x_test$(EXEEXT) all
-
-# Disable autoheader.
-AUTOHEADER=echo
-
diff --git a/libs/libsndfile/src/G72x/g72x.h b/libs/libsndfile/src/G72x/g72x.h
index 785a5d090d..d7631e6d8e 100644
--- a/libs/libsndfile/src/G72x/g72x.h
+++ b/libs/libsndfile/src/G72x/g72x.h
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 1999-2009 Erik de Castro Lopo
+** Copyright (C) 1999-2011 Erik de Castro Lopo
**
** 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
diff --git a/libs/libsndfile/src/G72x/g72x_test.c b/libs/libsndfile/src/G72x/g72x_test.c
index 3959efe69e..79cabce11b 100644
--- a/libs/libsndfile/src/G72x/g72x_test.c
+++ b/libs/libsndfile/src/G72x/g72x_test.c
@@ -1,21 +1,21 @@
/*
-** Copyright (C) 1999-2009 Erik de Castro Lopo
-**
+** Copyright (C) 1999-2011 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
** 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.
*/
-
+
#include
#include
#include
@@ -77,20 +77,20 @@ main (int argc, char *argv [])
return 0 ;
} /* main */
-static void
+static void
g721_test (void)
{
return ;
} /* g721_test */
-static void
+static void
g723_test (double margin)
{ static double orig_buffer [BUFFER_SIZE] ;
static short orig [BUFFER_SIZE] ;
static short data [BUFFER_SIZE] ;
G72x_STATE encoder_state, decoder_state ;
-
+
long k ;
int code, position, max_err ;
@@ -104,10 +104,10 @@ g723_test (double margin)
memset (data, 0, BUFFER_SIZE * sizeof (short)) ;
memset (orig, 0, BUFFER_SIZE * sizeof (short)) ;
-
+
printf (" g723_test : ") ;
fflush (stdout) ;
-
+
gen_signal_double (orig_buffer, 32000.0, BUFFER_SIZE) ;
for (k = 0 ; k < BUFFER_SIZE ; k++)
orig [k] = (short) orig_buffer [k] ;
@@ -144,13 +144,13 @@ g723_test (double margin)
#define SIGNAL_MAXVAL 30000.0
#define DECAY_COUNT 1000
-static void
+static void
gen_signal_double (double *gendata, double scale, int gendatalen)
{ int k, ramplen ;
double amp = 0.0 ;
-
+
ramplen = DECAY_COUNT ;
-
+
for (k = 0 ; k < gendatalen ; k++)
{ if (k <= ramplen)
amp = scale * k / ((double) ramplen) ;
@@ -160,11 +160,11 @@ gen_signal_double (double *gendata, double scale, int gendatalen)
gendata [k] = amp * (0.4 * sin (33.3 * 2.0 * M_PI * ((double) (k+1)) / ((double) SAMPLE_RATE))
+ 0.3 * cos (201.1 * 2.0 * M_PI * ((double) (k+1)) / ((double) SAMPLE_RATE))) ;
} ;
-
+
return ;
} /* gen_signal_double */
-static int
+static int
error_function (double data, double orig, double margin)
{ double error ;
@@ -174,7 +174,7 @@ error_function (double data, double orig, double margin)
error = fabs (data - orig) / 3000.0 ;
else
error = fabs (data - orig) / fabs (orig) ;
-
+
if (error > margin)
{ printf ("\n\n*******************\nError : %f\n", error) ;
return 1 ;
@@ -182,21 +182,21 @@ error_function (double data, double orig, double margin)
return 0 ;
} /* error_function */
-static int
+static int
oct_save_short (short *a, short *b, int len)
{ FILE *file ;
int k ;
if (! (file = fopen ("error.dat", "w")))
return 1 ;
-
+
fprintf (file, "# Not created by Octave\n") ;
-
+
fprintf (file, "# name: a\n") ;
fprintf (file, "# type: matrix\n") ;
fprintf (file, "# rows: %d\n", len) ;
fprintf (file, "# columns: 1\n") ;
-
+
for (k = 0 ; k < len ; k++)
fprintf (file, "% d\n", a [k]) ;
@@ -204,7 +204,7 @@ oct_save_short (short *a, short *b, int len)
fprintf (file, "# type: matrix\n") ;
fprintf (file, "# rows: %d\n", len) ;
fprintf (file, "# columns: 1\n") ;
-
+
for (k = 0 ; k < len ; k++)
fprintf (file, "% d\n", b [k]) ;
diff --git a/libs/libsndfile/src/GSM610/Makefile.am b/libs/libsndfile/src/GSM610/Makefile.am
deleted file mode 100644
index a7358f283b..0000000000
--- a/libs/libsndfile/src/GSM610/Makefile.am
+++ /dev/null
@@ -1,16 +0,0 @@
-## Process this file with automake to produce Makefile.in
-
-EXTRA_DIST = README COPYRIGHT ChangeLog
-
-noinst_HEADERS = gsm.h config.h gsm610_priv.h
-noinst_LTLIBRARIES = libgsm.la
-
-CFILES = add.c decode.c gsm_decode.c gsm_encode.c long_term.c preprocess.c \
- short_term.c code.c gsm_create.c gsm_destroy.c gsm_option.c lpc.c rpe.c table.c
-
-libgsm_la_SOURCES = $(CFILES) $(noinst_HEADERS)
-
-# Disable autoheader.
-AUTOHEADER=echo
-
-
diff --git a/libs/libsndfile/src/Makefile.am b/libs/libsndfile/src/Makefile.am
index 1297b360f7..7834e283d2 100644
--- a/libs/libsndfile/src/Makefile.am
+++ b/libs/libsndfile/src/Makefile.am
@@ -1,6 +1,6 @@
## Process this file with automake to produce Makefile.in
-SUBDIRS = GSM610 G72x
+AUTOMAKE_OPTIONS = subdir-objects
INCLUDES = @EXTERNAL_CFLAGS@
@@ -8,29 +8,43 @@ lib_LTLIBRARIES = libsndfile.la
include_HEADERS = sndfile.hh
nodist_include_HEADERS = sndfile.h
-noinst_LTLIBRARIES = libcommon.la
+noinst_LTLIBRARIES = GSM610/libgsm.la G72x/libg72x.la 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
+SYMBOL_FILES = Symbols.gnu-binutils Symbols.darwin libsndfile-1.def Symbols.os2 Symbols.static
EXTRA_DIST = sndfile.h.in config.h.in test_endswap.tpl test_endswap.def \
- $(SYMBOL_FILES) create_symbols_file.py binheader_writef_check.py
+ $(SYMBOL_FILES) create_symbols_file.py binheader_writef_check.py \
+ GSM610/README GSM610/COPYRIGHT GSM610/ChangeLog \
+ G72x/README G72x/README.original G72x/ChangeLog \
+ make-static-lib-hidden-privates.sh
-noinst_HEADERS = common.h sfconfig.h sfendian.h wav_w64.h sf_unistd.h
+noinst_HEADERS = common.h sfconfig.h sfendian.h wav_w64.h sf_unistd.h ogg.h chanmap.h
-noinst_PROGRAMS =
+check_PROGRAMS = test_main G72x/g72x_test
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 audio_detect.c \
- ima_oki_adpcm.c ima_oki_adpcm.h chunk.c
+ ima_oki_adpcm.c ima_oki_adpcm.h chunk.c ogg.c chanmap.c \
+ windows.c id3.c $(WIN_VERSION_FILE)
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
+ macbinary3.c macos.c mat4.c mat5.c nist.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 \
+ ogg_vorbis.c ogg_speex.c ogg_pcm.c
+CLEANFILES = *~
+
+if USE_WIN_VERSION_FILE
+WIN_VERSION_FILE = version-metadata.rc
+else
+WIN_VERSION_FILE =
+endif
+
+#===============================================================================
# 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 = $(FILESPECIFIC) $(noinst_HEADERS)
@@ -40,38 +54,48 @@ libsndfile_la_LIBADD = libcommon.la GSM610/libgsm.la G72x/libg72x.la \
libcommon_la_SOURCES = $(COMMON)
-#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_endswap.c: test_endswap.def test_endswap.tpl
-# autogen --writable test_endswap.def
+#======================================================================
+# Subdir libraries.
-genfiles : $(SYMBOL_FILES)
+GSM610_libgsm_la_SOURCES = GSM610/config.h GSM610/gsm.h GSM610/gsm610_priv.h \
+ GSM610/add.c GSM610/code.c GSM610/decode.c GSM610/gsm_create.c \
+ GSM610/gsm_decode.c GSM610/gsm_destroy.c GSM610/gsm_encode.c \
+ GSM610/gsm_option.c GSM610/long_term.c GSM610/lpc.c GSM610/preprocess.c \
+ GSM610/rpe.c GSM610/short_term.c GSM610/table.c
-# 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.
+G72x_libg72x_la_SOURCES = $(COMMON)G72x/g72x.h G72x/g72x_priv.h \
+ G72x/g721.c G72x/g723_16.c G72x/g723_24.c G72x/g723_40.c G72x/g72x.c
-check: $(noinst_PROGRAMS)
- @echo
- @echo
- @echo
- @echo "============================================================"
- @if [ -x /usr/bin/python2.5 ]; then $(srcdir)/binheader_writef_check.py $(srcdir)/*.c ; fi
+#======================================================================
+# Test programs.
+
+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_strncpy_crlf.c test_broadcast_var.c
+test_main_LDADD = libcommon.la
+
+G72x_g72x_test_SOURCES = G72x/g72x_test.c
+G72x_g72x_test_LDADD = G72x/libg72x.la
+
+test_endswap.c: test_endswap.def test_endswap.tpl
+ autogen --writable test_endswap.def
+
+genfiles : test_endswap.c $(SYMBOL_FILES)
+
+check :
+ @if [ -x /usr/bin/python ]; then $(srcdir)/binheader_writef_check.py $(srcdir)/*.c ; fi
+ G72x/g72x_test$(EXEEXT) all
./test_main$(EXEEXT)
- @echo "============================================================"
- @echo
- @echo
- @echo
+
+# Need this target to force building of test programs.
+checkprograms : $(check_PROGRAMS)
#======================================================================
# Generate an OS specific Symbols files. This is done when the author
# builds the distribution tarball. There should be not need for the
# end user to create these files.
-Symbols.linux: create_symbols_file.py
+Symbols.gnu-binutils: create_symbols_file.py
./create_symbols_file.py linux $(VERSION) > $@
Symbols.darwin: create_symbols_file.py
@@ -83,18 +107,21 @@ libsndfile-1.def: create_symbols_file.py
Symbols.os2: create_symbols_file.py
./create_symbols_file.py os2 $(VERSION) > $@
+Symbols.static: create_symbols_file.py
+ ./create_symbols_file.py static $(VERSION) > $@
+
# Fake dependancy to force the creation of these files.
sndfile.o : $(SYMBOL_FILES)
+#======================================================================
+# Building windows resource files (if needed).
+
+.rc.lo:
+ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --tag=RC --mode=compile $(RC) $(RCFLAGS) $< -o $@
+
#======================================================================
# Disable autoheader.
AUTOHEADER=echo
-# Dependancies.
-aiff.c au.c g72x.c ircam.c mat4.c mat5.c nist.c paf.c pvf.c : sndfile.h common.h
-raw.c svx.c voc.c w64.c wav.c wav_w64.c htk.c sd2.c rx2.c txw.c : sndfile.h common.h
-sds.c wve.c dwd.c ogg.c xi.c sndfile.c common.c file_io.c : sndfile.h common.h
-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
+
diff --git a/libs/libsndfile/src/Symbols.darwin b/libs/libsndfile/src/Symbols.darwin
index 271e0b0c87..a671460756 100644
--- a/libs/libsndfile/src/Symbols.darwin
+++ b/libs/libsndfile/src/Symbols.darwin
@@ -30,6 +30,7 @@ _sf_write_double
_sf_strerror
_sf_get_string
_sf_set_string
+_sf_version_string
_sf_open_fd
_sf_open_virtual
_sf_write_sync
diff --git a/libs/libsndfile/src/Symbols.linux b/libs/libsndfile/src/Symbols.linux
deleted file mode 100644
index 163346f700..0000000000
--- a/libs/libsndfile/src/Symbols.linux
+++ /dev/null
@@ -1,42 +0,0 @@
-# Auto-generated by create_symbols_file.py
-
-libsndfile.so.1.0
-{
- global:
- sf_command ;
- sf_open ;
- sf_close ;
- sf_seek ;
- sf_error ;
- sf_perror ;
- sf_error_str ;
- sf_error_number ;
- sf_format_check ;
- sf_read_raw ;
- sf_readf_short ;
- sf_readf_int ;
- sf_readf_float ;
- sf_readf_double ;
- sf_read_short ;
- sf_read_int ;
- sf_read_float ;
- sf_read_double ;
- sf_write_raw ;
- sf_writef_short ;
- sf_writef_int ;
- sf_writef_float ;
- sf_writef_double ;
- sf_write_short ;
- sf_write_int ;
- sf_write_float ;
- sf_write_double ;
- sf_strerror ;
- sf_get_string ;
- sf_set_string ;
- sf_open_fd ;
- sf_open_virtual ;
- sf_write_sync ;
- local:
- * ;
-} ;
-
diff --git a/libs/libsndfile/src/Symbols.os2 b/libs/libsndfile/src/Symbols.os2
index fbef2c42e4..118ceba728 100644
--- a/libs/libsndfile/src/Symbols.os2
+++ b/libs/libsndfile/src/Symbols.os2
@@ -1,6 +1,6 @@
; Auto-generated by create_symbols_file.py
-LIBRARY sndfile1.dll
+LIBRARY sndfile1
INITINSTANCE TERMINSTANCE
CODE PRELOAD MOVEABLE DISCARDABLE
DATA PRELOAD MOVEABLE MULTIPLE NONSHARED
@@ -36,6 +36,7 @@ _sf_write_double @40
_sf_strerror @50
_sf_get_string @60
_sf_set_string @61
+_sf_version_string @68
_sf_open_fd @70
_sf_open_virtual @80
_sf_write_sync @90
diff --git a/libs/libsndfile/src/aiff.c b/libs/libsndfile/src/aiff.c
index c18324c262..0113ba6513 100644
--- a/libs/libsndfile/src/aiff.c
+++ b/libs/libsndfile/src/aiff.c
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 1999-2009 Erik de Castro Lopo
+** Copyright (C) 1999-2011 Erik de Castro Lopo
** Copyright (C) 2005 David Viens
**
** This program is free software; you can redistribute it and/or modify
@@ -24,10 +24,12 @@
#include
#include
#include
+#include
#include "sndfile.h"
#include "sfendian.h"
#include "common.h"
+#include "chanmap.h"
/*------------------------------------------------------------------------------
* Macros to handle big/little endian issues.
@@ -41,6 +43,7 @@
#define MARK_MARKER (MAKE_MARKER ('M', 'A', 'R', 'K'))
#define INST_MARKER (MAKE_MARKER ('I', 'N', 'S', 'T'))
#define APPL_MARKER (MAKE_MARKER ('A', 'P', 'P', 'L'))
+#define CHAN_MARKER (MAKE_MARKER ('C', 'H', 'A', 'N'))
#define c_MARKER (MAKE_MARKER ('(', 'c', ')', ' '))
#define NAME_MARKER (MAKE_MARKER ('N', 'A', 'M', 'E'))
@@ -187,6 +190,8 @@ typedef struct
sf_count_t comm_offset ;
sf_count_t ssnd_offset ;
+ int chanmap_tag ;
+
MARK_ID_POS *markstr ;
} AIFF_PRIVATE ;
@@ -215,6 +220,8 @@ static short get_loop_mode (short mode) ;
static int aiff_read_basc_chunk (SF_PRIVATE * psf, int) ;
+static int aiff_read_chanmap (SF_PRIVATE * psf, unsigned dword) ;
+
static unsigned int marker_to_position (const MARK_ID_POS *m, unsigned short n, int marksize) ;
/*------------------------------------------------------------------------------
@@ -233,26 +240,26 @@ aiff_open (SF_PRIVATE *psf)
if ((psf->container_data = calloc (1, sizeof (AIFF_PRIVATE))) == NULL)
return SFE_MALLOC_FAILED ;
- if (psf->mode == SFM_READ || (psf->mode == SFM_RDWR && psf->filelength > 0))
+ if (psf->file.mode == SFM_READ || (psf->file.mode == SFM_RDWR && psf->filelength > 0))
{ if ((error = aiff_read_header (psf, &comm_fmt)))
return error ;
psf_fseek (psf, psf->dataoffset, SEEK_SET) ;
} ;
- if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR)
+ if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR)
{ if (psf->is_pipe)
return SFE_NO_PIPE_WRITE ;
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))
+ if (psf->file.mode == SFM_WRITE && (subformat == SF_FORMAT_FLOAT || subformat == SF_FORMAT_DOUBLE))
{ if ((psf->peak_info = peak_info_calloc (psf->sf.channels)) == NULL)
return SFE_MALLOC_FAILED ;
psf->peak_info->peak_loc = SF_PEAK_START ;
} ;
- if (psf->mode != SFM_RDWR || psf->filelength < 40)
+ if (psf->file.mode != SFM_RDWR || psf->filelength < 40)
{ psf->filelength = 0 ;
psf->datalength = 0 ;
psf->dataoffset = 0 ;
@@ -315,7 +322,7 @@ aiff_open (SF_PRIVATE *psf)
break ;
case SF_FORMAT_DWVW_N :
- if (psf->mode != SFM_READ)
+ if (psf->file.mode != SFM_READ)
{ error = SFE_DWVW_BAD_BITWIDTH ;
break ;
} ;
@@ -369,7 +376,7 @@ aiff_read_header (SF_PRIVATE *psf, COMM_CHUNK *comm_fmt)
AIFF_PRIVATE *paiff ;
unsigned marker, dword, FORMsize, SSNDsize, bytesread ;
int k, found_chunk = 0, done = 0, error = 0 ;
- char *cptr, byte ;
+ char *cptr ;
int instr_found = 0, mark_found = 0, mark_count = 0 ;
if (psf->filelength > SF_PLATFORM_S64 (0xffffffff))
@@ -396,7 +403,7 @@ aiff_read_header (SF_PRIVATE *psf, COMM_CHUNK *comm_fmt)
while (! done)
{ psf_binheader_readf (psf, "m", &marker) ;
- if (psf->mode == SFM_RDWR && (found_chunk & HAVE_SSND))
+ if (psf->file.mode == SFM_RDWR && (found_chunk & HAVE_SSND))
return SFE_AIFF_RW_SSND_NOT_LAST ;
switch (marker)
@@ -405,7 +412,7 @@ aiff_read_header (SF_PRIVATE *psf, COMM_CHUNK *comm_fmt)
return SFE_AIFF_NO_FORM ;
psf_binheader_readf (psf, "E4", &FORMsize) ;
- pchk4_store (&(paiff->chunk4), marker, psf->headindex - 8, FORMsize) ;
+ pchk4_store (&paiff->chunk4, marker, psf->headindex - 8, FORMsize) ;
if (psf->fileoffset > 0 && psf->filelength > FORMsize + 8)
{ /* Set file length. */
@@ -485,10 +492,10 @@ aiff_read_header (SF_PRIVATE *psf, COMM_CHUNK *comm_fmt)
psf->peak_info->peaks [dword].value = value ;
psf->peak_info->peaks [dword].position = position ;
- snprintf (cptr, sizeof (psf->u.scbuf), " %2d %-12ld %g\n",
- dword, (long) psf->peak_info->peaks [dword].position, psf->peak_info->peaks [dword].value) ;
+ snprintf (cptr, sizeof (psf->u.scbuf), " %2d %-12" PRId64 " %g\n",
+ dword, 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_log_printf (psf, "%s", cptr) ;
} ;
psf->peak_info->peak_loc = ((found_chunk & HAVE_SSND) == 0) ? SF_PEAK_START : SF_PEAK_END ;
@@ -520,8 +527,10 @@ aiff_read_header (SF_PRIVATE *psf, COMM_CHUNK *comm_fmt)
psf->datalength -= ssnd_fmt.offset ;
}
else
- { psf_log_printf (psf, " Offset : %u (Should be zero)\n", ssnd_fmt.offset) ;
+ { 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 ;
} ;
/* Only set dataend if there really is data at the end. */
@@ -630,7 +639,7 @@ aiff_read_header (SF_PRIVATE *psf, COMM_CHUNK *comm_fmt)
cptr [dword] = 0 ;
for (k = 0 ; k < (int) dword ; k++)
- if (! isprint (cptr [k]))
+ if (! psf_isprint (cptr [k]))
{ cptr [k] = 0 ;
break ;
} ;
@@ -756,7 +765,6 @@ aiff_read_header (SF_PRIVATE *psf, COMM_CHUNK *comm_fmt)
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 ;
unsigned int position ;
bytesread = psf_binheader_readf (psf, "E2", &n) ;
@@ -771,13 +779,24 @@ aiff_read_header (SF_PRIVATE *psf, COMM_CHUNK *comm_fmt)
return SFE_MALLOC_FAILED ;
for (n = 0 ; n < mark_count && bytesread < dword ; n++)
- { bytesread += psf_binheader_readf (psf, "E241", &mark_id, &position, &pstr_len) ;
+ { unsigned int pstr_len ;
+ unsigned char ch ;
+
+ bytesread += psf_binheader_readf (psf, "E241", &mark_id, &position, &ch) ;
psf_log_printf (psf, " Mark ID : %u\n Position : %u\n", mark_id, position) ;
- pstr_len += (pstr_len & 1) ? 0 : 1 ;
+ pstr_len = (ch & 1) ? ch : ch + 1 ;
+
+ if (pstr_len < sizeof (psf->u.scbuf) - 1)
+ { bytesread += psf_binheader_readf (psf, "b", psf->u.scbuf, pstr_len) ;
+ psf->u.scbuf [pstr_len] = 0 ;
+ }
+ else
+ { unsigned int read_len = pstr_len - (sizeof (psf->u.scbuf) - 1) ;
+ bytesread += psf_binheader_readf (psf, "bj", psf->u.scbuf, read_len, pstr_len - read_len) ;
+ psf->u.scbuf [sizeof (psf->u.scbuf) - 1] = 0 ;
+ }
- 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) ;
paiff->markstr [n].markerID = mark_id ;
@@ -808,14 +827,32 @@ aiff_read_header (SF_PRIVATE *psf, COMM_CHUNK *comm_fmt)
case NONE_MARKER :
/* Fix for broken AIFC files with incorrect COMM chunk length. */
- psf_binheader_readf (psf, "1", &byte) ;
- dword = byte ;
- psf_binheader_readf (psf, "j", dword) ;
+ { unsigned char byte ;
+ psf_binheader_readf (psf, "1", &byte) ;
+ dword = byte ;
+ psf_binheader_readf (psf, "j", dword) ;
+ }
+ break ;
+
+ case CHAN_MARKER :
+ psf_binheader_readf (psf, "E4", &dword) ;
+ pchk4_store (&paiff->chunk4, marker, psf_ftell (psf) - 8, dword) ;
+
+ if (dword < 12)
+ { psf_log_printf (psf, " %M : %d (should be >= 12)\n", marker, dword) ;
+ psf_binheader_readf (psf, "j", dword) ;
+ break ;
+ }
+
+ psf_log_printf (psf, " %M : %d\n", marker, dword) ;
+
+ if ((error = aiff_read_chanmap (psf, dword)))
+ return error ;
break ;
default :
- if (isprint ((marker >> 24) & 0xFF) && isprint ((marker >> 16) & 0xFF)
- && isprint ((marker >> 8) & 0xFF) && isprint (marker & 0xFF))
+ if (psf_isprint ((marker >> 24) & 0xFF) && psf_isprint ((marker >> 16) & 0xFF)
+ && psf_isprint ((marker >> 8) & 0xFF) && psf_isprint (marker & 0xFF))
{ psf_binheader_readf (psf, "E4", &dword) ;
psf_log_printf (psf, " %M : %d (unknown marker)\n", marker, dword) ;
@@ -876,7 +913,7 @@ aiff_close (SF_PRIVATE *psf)
paiff->markstr = NULL ;
} ;
- if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR)
+ if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR)
{ aiff_write_tailer (psf) ;
aiff_write_header (psf, SF_TRUE) ;
} ;
@@ -1119,7 +1156,7 @@ aiff_write_header (SF_PRIVATE *psf, int calc_length)
psf->sf.frames = psf->datalength / (psf->bytewidth * psf->sf.channels) ;
} ;
- if (psf->mode == SFM_RDWR && psf->dataoffset > 0 && paiff->chunk4.count > 0)
+ if (psf->file.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) ;
@@ -1134,34 +1171,72 @@ aiff_write_header (SF_PRIVATE *psf, int calc_length)
bit_width = psf->bytewidth * 8 ;
comm_frames = (psf->sf.frames > 0xFFFFFFFF) ? 0xFFFFFFFF : psf->sf.frames ;
- switch (SF_CODEC (psf->sf.format))
- { case SF_FORMAT_PCM_S8 :
+ switch (SF_CODEC (psf->sf.format) | endian)
+ { case SF_FORMAT_PCM_S8 | SF_ENDIAN_BIG :
+ psf->endian = SF_ENDIAN_BIG ;
+ comm_type = AIFC_MARKER ;
+ comm_size = SIZEOF_AIFC_COMM ;
+ comm_encoding = twos_MARKER ;
+ break ;
+
+ case SF_FORMAT_PCM_S8 | SF_ENDIAN_LITTLE :
+ psf->endian = SF_ENDIAN_LITTLE ;
+ comm_type = AIFC_MARKER ;
+ comm_size = SIZEOF_AIFC_COMM ;
+ comm_encoding = sowt_MARKER ;
+ break ;
+
+ case SF_FORMAT_PCM_16 | SF_ENDIAN_BIG :
+ psf->endian = SF_ENDIAN_BIG ;
+ comm_type = AIFC_MARKER ;
+ comm_size = SIZEOF_AIFC_COMM ;
+ comm_encoding = twos_MARKER ;
+ break ;
+
+ case SF_FORMAT_PCM_16 | SF_ENDIAN_LITTLE :
+ psf->endian = SF_ENDIAN_LITTLE ;
+ comm_type = AIFC_MARKER ;
+ comm_size = SIZEOF_AIFC_COMM ;
+ comm_encoding = sowt_MARKER ;
+ break ;
+
+ case SF_FORMAT_PCM_24 | SF_ENDIAN_BIG :
+ psf->endian = SF_ENDIAN_BIG ;
+ comm_type = AIFC_MARKER ;
+ comm_size = SIZEOF_AIFC_COMM ;
+ comm_encoding = in24_MARKER ;
+ break ;
+
+ case SF_FORMAT_PCM_24 | SF_ENDIAN_LITTLE :
+ psf->endian = SF_ENDIAN_LITTLE ;
+ comm_type = AIFC_MARKER ;
+ comm_size = SIZEOF_AIFC_COMM ;
+ comm_encoding = ni24_MARKER ;
+ break ;
+
+ case SF_FORMAT_PCM_32 | SF_ENDIAN_BIG :
+ psf->endian = SF_ENDIAN_BIG ;
+ comm_type = AIFC_MARKER ;
+ comm_size = SIZEOF_AIFC_COMM ;
+ comm_encoding = in32_MARKER ;
+ break ;
+
+ case SF_FORMAT_PCM_32 | SF_ENDIAN_LITTLE :
+ psf->endian = SF_ENDIAN_LITTLE ;
+ comm_type = AIFC_MARKER ;
+ comm_size = SIZEOF_AIFC_COMM ;
+ comm_encoding = ni32_MARKER ;
+ break ;
+
+ case SF_FORMAT_PCM_S8 : /* SF_ENDIAN_FILE */
case SF_FORMAT_PCM_16 :
case SF_FORMAT_PCM_24 :
case SF_FORMAT_PCM_32 :
- switch (endian)
- { case SF_ENDIAN_BIG :
- psf->endian = SF_ENDIAN_BIG ;
- comm_type = AIFC_MARKER ;
- comm_size = SIZEOF_AIFC_COMM ;
- comm_encoding = twos_MARKER ;
- break ;
-
- case SF_ENDIAN_LITTLE :
- psf->endian = SF_ENDIAN_LITTLE ;
- comm_type = AIFC_MARKER ;
- comm_size = SIZEOF_AIFC_COMM ;
- comm_encoding = sowt_MARKER ;
- break ;
-
- default : /* SF_ENDIAN_FILE */
- psf->endian = SF_ENDIAN_BIG ;
- comm_type = AIFF_MARKER ;
- comm_size = SIZEOF_AIFF_COMM ;
- comm_encoding = 0 ;
- break ;
- } ;
- break ;
+ psf->endian = SF_ENDIAN_BIG ;
+ comm_type = AIFF_MARKER ;
+ comm_size = SIZEOF_AIFF_COMM ;
+ comm_encoding = 0 ;
+ break ;
case SF_FORMAT_FLOAT : /* Big endian floating point. */
psf->endian = SF_ENDIAN_BIG ;
@@ -1278,6 +1353,9 @@ aiff_write_header (SF_PRIVATE *psf, int calc_length)
if (comm_type == AIFC_MARKER)
psf_binheader_writef (psf, "mb", comm_encoding, comm_zero_bytes, sizeof (comm_zero_bytes)) ;
+ if (psf->channel_map && paiff->chanmap_tag)
+ psf_binheader_writef (psf, "Em4444", CHAN_MARKER, 12, paiff->chanmap_tag, 0, 0) ;
+
if (psf->instrument != NULL)
{ MARK_ID_POS m [4] ;
INST_CHUNK ch ;
@@ -1448,8 +1526,23 @@ aiff_write_strings (SF_PRIVATE *psf, int location)
} /* aiff_write_strings */
static int
-aiff_command (SF_PRIVATE * UNUSED (psf), int UNUSED (command), void * UNUSED (data), int UNUSED (datasize))
-{
+aiff_command (SF_PRIVATE * psf, int command, void * UNUSED (data), int UNUSED (datasize))
+{ AIFF_PRIVATE *paiff ;
+
+ if ((paiff = psf->container_data) == NULL)
+ return SFE_INTERNAL ;
+
+ switch (command)
+ { case SFC_SET_CHANNEL_MAP_INFO :
+ paiff->chanmap_tag = aiff_caf_find_channel_layout_tag (psf->channel_map, psf->sf.channels) ;
+ return (paiff->chanmap_tag != 0) ;
+
+ default :
+ break ;
+ } ;
+
+
+
return 0 ;
} /* aiff_command */
@@ -1610,3 +1703,36 @@ aiff_read_basc_chunk (SF_PRIVATE * psf, int datasize)
return 0 ;
} /* aiff_read_basc_chunk */
+
+static int
+aiff_read_chanmap (SF_PRIVATE * psf, unsigned dword)
+{ const AIFF_CAF_CHANNEL_MAP * map_info ;
+ unsigned channel_bitmap, channel_decriptions, bytesread ;
+ int layout_tag ;
+
+ bytesread = psf_binheader_readf (psf, "444", &layout_tag, &channel_bitmap, &channel_decriptions) ;
+
+ if ((map_info = aiff_caf_of_channel_layout_tag (layout_tag)) == NULL)
+ return 0 ;
+
+ psf_log_printf (psf, " Tag : %x\n", layout_tag) ;
+ if (map_info)
+ psf_log_printf (psf, " Layout : %s\n", map_info->name) ;
+
+ if (bytesread < dword)
+ psf_binheader_readf (psf, "j", dword - bytesread) ;
+
+ if (map_info->channel_map != NULL)
+ { size_t chanmap_size = psf->sf.channels * sizeof (psf->channel_map [0]) ;
+
+ free (psf->channel_map) ;
+
+ if ((psf->channel_map = malloc (chanmap_size)) == NULL)
+ return SFE_MALLOC_FAILED ;
+
+ memcpy (psf->channel_map, map_info->channel_map, chanmap_size) ;
+ } ;
+
+ return 0 ;
+} /* aiff_read_chanmap */
+
diff --git a/libs/libsndfile/src/alaw.c b/libs/libsndfile/src/alaw.c
index 900054aae5..6d06b4bb03 100644
--- a/libs/libsndfile/src/alaw.c
+++ b/libs/libsndfile/src/alaw.c
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 1999-2009 Erik de Castro Lopo
+** Copyright (C) 1999-2011 Erik de Castro Lopo
**
** 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,14 +47,14 @@ static void d2alaw_array (const double *buffer, int count, unsigned char *ptr, d
int
alaw_init (SF_PRIVATE *psf)
{
- if (psf->mode == SFM_READ || psf->mode == SFM_RDWR)
+ if (psf->file.mode == SFM_READ || psf->file.mode == SFM_RDWR)
{ psf->read_short = alaw_read_alaw2s ;
psf->read_int = alaw_read_alaw2i ;
psf->read_float = alaw_read_alaw2f ;
psf->read_double = alaw_read_alaw2d ;
} ;
- if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR)
+ if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR)
{ psf->write_short = alaw_write_s2alaw ;
psf->write_int = alaw_write_i2alaw ;
psf->write_float = alaw_write_f2alaw ;
@@ -69,7 +69,7 @@ alaw_init (SF_PRIVATE *psf)
else
psf->datalength = 0 ;
- psf->sf.frames = psf->datalength / psf->blockwidth ;
+ psf->sf.frames = psf->blockwidth > 0 ? psf->datalength / psf->blockwidth : 0 ;
return 0 ;
} /* alaw_init */
diff --git a/libs/libsndfile/src/au.c b/libs/libsndfile/src/au.c
index cdc1c203d5..0ac3bf3c20 100644
--- a/libs/libsndfile/src/au.c
+++ b/libs/libsndfile/src/au.c
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 1999-2009 Erik de Castro Lopo
+** Copyright (C) 1999-2011 Erik de Castro Lopo
**
** 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
@@ -106,7 +106,7 @@ au_open (SF_PRIVATE *psf)
{ int subformat ;
int error = 0 ;
- if (psf->mode == SFM_READ || (psf->mode == SFM_RDWR && psf->filelength > 0))
+ if (psf->file.mode == SFM_READ || (psf->file.mode == SFM_RDWR && psf->filelength > 0))
{ if ((error = au_read_header (psf)))
return error ;
} ;
@@ -116,7 +116,7 @@ au_open (SF_PRIVATE *psf)
subformat = SF_CODEC (psf->sf.format) ;
- if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR)
+ if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR)
{ psf->endian = SF_ENDIAN (psf->sf.format) ;
if (CPU_IS_LITTLE_ENDIAN && psf->endian == SF_ENDIAN_CPU)
psf->endian = SF_ENDIAN_LITTLE ;
@@ -189,7 +189,7 @@ au_open (SF_PRIVATE *psf)
static int
au_close (SF_PRIVATE *psf)
{
- if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR)
+ if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR)
au_write_header (psf, SF_TRUE) ;
return 0 ;
diff --git a/libs/libsndfile/src/audio_detect.c b/libs/libsndfile/src/audio_detect.c
index 9e73bc5d0e..775077e7cd 100644
--- a/libs/libsndfile/src/audio_detect.c
+++ b/libs/libsndfile/src/audio_detect.c
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 1999-2009 Erik de Castro Lopo
+** Copyright (C) 1999-2011 Erik de Castro Lopo
**
** 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
diff --git a/libs/libsndfile/src/avr.c b/libs/libsndfile/src/avr.c
index 33288af5ce..dd09b46c37 100644
--- a/libs/libsndfile/src/avr.c
+++ b/libs/libsndfile/src/avr.c
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 2004-2009 Erik de Castro Lopo
+** Copyright (C) 2004-2011 Erik de Castro Lopo
**
** 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
@@ -80,7 +80,7 @@ int
avr_open (SF_PRIVATE *psf)
{ int error = 0 ;
- if (psf->mode == SFM_READ || (psf->mode == SFM_RDWR && psf->filelength > 0))
+ if (psf->file.mode == SFM_READ || (psf->file.mode == SFM_RDWR && psf->filelength > 0))
{ if ((error = avr_read_header (psf)))
return error ;
} ;
@@ -88,7 +88,7 @@ avr_open (SF_PRIVATE *psf)
if ((SF_CONTAINER (psf->sf.format)) != SF_FORMAT_AVR)
return SFE_BAD_OPEN_FORMAT ;
- if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR)
+ if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR)
{ psf->endian = SF_ENDIAN (psf->sf.format) ;
psf->endian = SF_ENDIAN_BIG ;
@@ -239,7 +239,7 @@ avr_write_header (SF_PRIVATE *psf, int calc_length)
static int
avr_close (SF_PRIVATE *psf)
{
- if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR)
+ if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR)
avr_write_header (psf, SF_TRUE) ;
return 0 ;
diff --git a/libs/libsndfile/src/binheader_writef_check.py b/libs/libsndfile/src/binheader_writef_check.py
old mode 100644
new mode 100755
index 3c5d1c8423..adfc5f96e2
--- a/libs/libsndfile/src/binheader_writef_check.py
+++ b/libs/libsndfile/src/binheader_writef_check.py
@@ -1,6 +1,6 @@
-#!/usr/bin/python2.5
+#!/usr/bin/python
-# Copyright (C) 2006 Erik de Castro Lopo
+# Copyright (C) 2006-2011 Erik de Castro Lopo
#
# All rights reserved.
#
@@ -97,13 +97,13 @@ def handle_file (fname):
print " %s" % item
errors += 1
param_index += 2
-
+
return errors
#===============================================================================
if len (sys.argv) > 1:
- print "%s\n binheader_writef_check :" % sys.argv [0],
+ print "\n binheader_writef_check :",
sys.stdout.flush ()
errors = 0
for fname in sys.argv [1:]:
@@ -112,5 +112,5 @@ if len (sys.argv) > 1:
print "\nErrors : %d\n" % errors
sys.exit (1)
-print "ok"
+print "ok\n"
diff --git a/libs/libsndfile/src/broadcast.c b/libs/libsndfile/src/broadcast.c
index 8654452dab..975ee8471d 100644
--- a/libs/libsndfile/src/broadcast.c
+++ b/libs/libsndfile/src/broadcast.c
@@ -1,6 +1,6 @@
/*
+** Copyright (C) 2006-2011 Erik de Castro Lopo
** Copyright (C) 2006 Paul Davis
-** Copyright (C) 2006-2009 Erik de Castro Lopo
**
** 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
@@ -17,13 +17,15 @@
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
+#include "sfconfig.h"
+
#include
#include
#include
#include "common.h"
-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
@@ -32,29 +34,16 @@ bc_min_size (const SF_BROADCAST_INFO* info)
return 0 ;
return offsetof (SF_BROADCAST_INFO, coding_history) + info->coding_history_size ;
-} /* broadcast_size */
+} /* bc_min_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 ;
-
- if ((data = calloc (1, datasize)) != NULL)
- data->size = datasize ;
-
- return data ;
+SF_BROADCAST_INFO_16K*
+broadcast_var_alloc (void)
+{ return calloc (1, sizeof (SF_BROADCAST_INFO_16K)) ;
} /* broadcast_var_alloc */
-
int
broadcast_var_set (SF_PRIVATE *psf, const SF_BROADCAST_INFO * info, size_t datasize)
-{ char added_history [256] ;
- int added_history_len, len ;
+{ size_t len ;
if (info == NULL)
return SF_FALSE ;
@@ -64,42 +53,40 @@ broadcast_var_set (SF_PRIVATE *psf, const SF_BROADCAST_INFO * info, size_t datas
return SF_FALSE ;
} ;
- added_history_len = gen_coding_history (added_history, sizeof (added_history), &(psf->sf)) ;
+ if (datasize >= sizeof (SF_BROADCAST_INFO_16K))
+ { psf->error = SFE_BAD_BROADCAST_INFO_TOO_BIG ;
+ return SF_FALSE ;
+ } ;
- 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_16k == NULL)
+ { if ((psf->broadcast_16k = broadcast_var_alloc ()) == NULL)
+ { psf->error = SFE_MALLOC_FAILED ;
+ return SF_FALSE ;
} ;
} ;
- if (psf->broadcast_var == NULL)
- { int size = datasize + added_history_len + 512 ;
+ memcpy (psf->broadcast_16k, info, offsetof (SF_BROADCAST_INFO, coding_history)) ;
- psf->broadcast_var = calloc (1, size) ;
- psf->broadcast_var->size = size ;
+ psf_strlcpy_crlf (psf->broadcast_16k->coding_history, info->coding_history, sizeof (psf->broadcast_16k->coding_history), datasize - offsetof (SF_BROADCAST_INFO, coding_history)) ;
+ len = strlen (psf->broadcast_16k->coding_history) ;
+
+ if (len > 0 && psf->broadcast_16k->coding_history [len - 1] != '\n')
+ psf_strlcat (psf->broadcast_16k->coding_history, sizeof (psf->broadcast_16k->coding_history), "\r\n") ;
+
+ if (psf->file.mode == SFM_WRITE)
+ { char added_history [256] ;
+
+ gen_coding_history (added_history, sizeof (added_history), &(psf->sf)) ;
+ psf_strlcat (psf->broadcast_16k->coding_history, sizeof (psf->broadcast_16k->coding_history), added_history) ;
} ;
- 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 ;
+ /* Force coding_history_size to be even. */
+ len = strlen (psf->broadcast_16k->coding_history) ;
+ len += (len & 1) ? 1 : 2 ;
+ psf->broadcast_16k->coding_history_size = len ;
/* Currently writing this version. */
- psf->broadcast_var->binfo.version = 1 ;
+ psf->broadcast_16k->version = 1 ;
return SF_TRUE ;
} /* broadcast_var_set */
@@ -109,54 +96,19 @@ int
broadcast_var_get (SF_PRIVATE *psf, SF_BROADCAST_INFO * data, size_t datasize)
{ size_t size ;
- if (psf->broadcast_var == NULL)
+ if (psf->broadcast_16k == NULL)
return SF_FALSE ;
- size = SF_MIN (datasize, bc_min_size (&(psf->broadcast_var->binfo))) ;
+ size = SF_MIN (datasize, bc_min_size ((const SF_BROADCAST_INFO *) psf->broadcast_16k)) ;
- memcpy (data, &(psf->broadcast_var->binfo), size) ;
+ memcpy (data, psf->broadcast_16k, size) ;
return SF_TRUE ;
-} /* broadcast_var_set */
+} /* broadcast_var_get */
/*------------------------------------------------------------------------------
-** 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] ;
@@ -185,11 +137,11 @@ gen_coding_history (char * added_history, int added_history_max, const SF_INFO *
return SF_FALSE ;
case 1 :
- strncpy (chnstr, "mono", sizeof (chnstr)) ;
+ psf_strlcpy (chnstr, sizeof (chnstr), "mono") ;
break ;
case 2 :
- strncpy (chnstr, "stereo", sizeof (chnstr)) ;
+ psf_strlcpy (chnstr, sizeof (chnstr), "stereo") ;
break ;
default :
diff --git a/libs/libsndfile/src/caf.c b/libs/libsndfile/src/caf.c
index 93d8e9a2ee..99e9117c7e 100644
--- a/libs/libsndfile/src/caf.c
+++ b/libs/libsndfile/src/caf.c
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 2005-2009 Erik de Castro Lopo
+** Copyright (C) 2005-2011 Erik de Castro Lopo
**
** 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,12 @@
#include
#include
#include
+#include
#include "sndfile.h"
#include "sfendian.h"
#include "common.h"
+#include "chanmap.h"
/*------------------------------------------------------------------------------
** Macros to handle big/little endian issues.
@@ -82,6 +84,10 @@ typedef struct
unsigned int bits_per_chan ;
} DESC_CHUNK ;
+typedef struct
+{ int chanmap_tag ;
+} CAF_PRIVATE ;
+
/*------------------------------------------------------------------------------
** Private static functions.
*/
@@ -89,6 +95,8 @@ typedef struct
static int caf_close (SF_PRIVATE *psf) ;
static int caf_read_header (SF_PRIVATE *psf) ;
static int caf_write_header (SF_PRIVATE *psf, int calc_length) ;
+static int caf_command (SF_PRIVATE *psf, int command, void *data, int datasize) ;
+static int caf_read_chanmap (SF_PRIVATE * psf, sf_count_t chunk_size) ;
/*------------------------------------------------------------------------------
** Public function.
@@ -98,14 +106,17 @@ int
caf_open (SF_PRIVATE *psf)
{ int subformat, format, error = 0 ;
- if (psf->mode == SFM_READ || (psf->mode == SFM_RDWR && psf->filelength > 0))
+ if (psf->file.mode == SFM_READ || (psf->file.mode == SFM_RDWR && psf->filelength > 0))
{ if ((error = caf_read_header (psf)))
return error ;
} ;
subformat = SF_CODEC (psf->sf.format) ;
- if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR)
+ if ((psf->container_data = calloc (1, sizeof (CAF_PRIVATE))) == NULL)
+ return SFE_MALLOC_FAILED ;
+
+ if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR)
{ if (psf->is_pipe)
return SFE_NO_PIPE_WRITE ;
@@ -115,7 +126,7 @@ caf_open (SF_PRIVATE *psf)
psf->blockwidth = psf->bytewidth * psf->sf.channels ;
- if (psf->mode != SFM_RDWR || psf->filelength < 44)
+ if (psf->file.mode != SFM_RDWR || psf->filelength < 44)
{ psf->filelength = 0 ;
psf->datalength = 0 ;
psf->dataoffset = 0 ;
@@ -128,7 +139,7 @@ caf_open (SF_PRIVATE *psf)
** 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).
*/
- if (psf->mode == SFM_WRITE && (subformat == SF_FORMAT_FLOAT || subformat == SF_FORMAT_DOUBLE))
+ if (psf->file.mode == SFM_WRITE && (subformat == SF_FORMAT_FLOAT || subformat == SF_FORMAT_DOUBLE))
{ if ((psf->peak_info = peak_info_calloc (psf->sf.channels)) == NULL)
return SFE_MALLOC_FAILED ;
psf->peak_info->peak_loc = SF_PEAK_START ;
@@ -141,7 +152,7 @@ caf_open (SF_PRIVATE *psf)
} ;
psf->container_close = caf_close ;
- /*psf->command = caf_command ;*/
+ psf->command = caf_command ;
switch (subformat)
{ case SF_FORMAT_PCM_S8 :
@@ -179,12 +190,31 @@ caf_open (SF_PRIVATE *psf)
static int
caf_close (SF_PRIVATE *psf)
{
- if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR)
+ if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR)
caf_write_header (psf, SF_TRUE) ;
return 0 ;
} /* caf_close */
+static int
+caf_command (SF_PRIVATE * psf, int command, void * UNUSED (data), int UNUSED (datasize))
+{ CAF_PRIVATE *pcaf ;
+
+ if ((pcaf = psf->container_data) == NULL)
+ return SFE_INTERNAL ;
+
+ switch (command)
+ { case SFC_SET_CHANNEL_MAP_INFO :
+ pcaf->chanmap_tag = aiff_caf_find_channel_layout_tag (psf->channel_map, psf->sf.channels) ;
+ return (pcaf->chanmap_tag != 0) ;
+
+ default :
+ break ;
+ } ;
+
+ return 0 ;
+} /* caf_command */
+
/*------------------------------------------------------------------------------
*/
@@ -252,7 +282,7 @@ caf_read_header (SF_PRIVATE *psf)
sf_count_t chunk_size ;
double srate ;
short version, flags ;
- int marker, k, have_data = 0 ;
+ int marker, k, have_data = 0, error ;
memset (&desc, 0, sizeof (desc)) ;
@@ -282,7 +312,7 @@ caf_read_header (SF_PRIVATE *psf)
" 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)
+ if (desc.channels_per_frame > SF_MAX_CHANNELS)
{ psf_log_printf (psf, "**** Bad channels per frame value %u.\n", desc.channels_per_frame) ;
return SFE_MALFORMED_FILE ;
} ;
@@ -311,7 +341,7 @@ caf_read_header (SF_PRIVATE *psf)
psf_binheader_readf (psf, "E4", & (psf->peak_info->edit_number)) ;
psf_log_printf (psf, " edit count : %d\n", psf->peak_info->edit_number) ;
- psf_log_printf (psf, " Ch Position Value\n") ;
+ psf_log_printf (psf, " Ch Position Value\n") ;
for (k = 0 ; k < psf->sf.channels ; k++)
{ sf_count_t position ;
float value ;
@@ -320,20 +350,36 @@ caf_read_header (SF_PRIVATE *psf)
psf->peak_info->peaks [k].value = value ;
psf->peak_info->peaks [k].position = position ;
- 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 %-12" PRId64 " %g\n", k, position, value) ;
psf_log_printf (psf, psf->u.cbuf) ;
} ;
psf->peak_info->peak_loc = SF_PEAK_START ;
break ;
+ case chan_MARKER :
+ if (chunk_size < 12)
+ { psf_log_printf (psf, "%M : %D (should be >= 12)\n", marker, chunk_size) ;
+ psf_binheader_readf (psf, "j", (int) chunk_size) ;
+ break ;
+ }
+
+ psf_log_printf (psf, "%M : %D\n", marker, chunk_size) ;
+
+ if ((error = caf_read_chanmap (psf, chunk_size)))
+ return error ;
+ break ;
+
case free_MARKER :
psf_log_printf (psf, "%M : %D\n", marker, chunk_size) ;
psf_binheader_readf (psf, "j", (int) chunk_size) ;
break ;
case data_MARKER :
- psf_log_printf (psf, "%M : %D\n", marker, chunk_size) ;
+ if (psf->filelength > 0 && chunk_size + psf->headindex != psf->filelength)
+ psf_log_printf (psf, "%M : %D (should be %D)\n", marker, chunk_size, chunk_size + 4) ;
+ else
+ psf_log_printf (psf, "%M : %D\n", marker, chunk_size) ;
psf_binheader_readf (psf, "E4", &k) ;
psf_log_printf (psf, " edit : %u\n", k) ;
have_data = 1 ;
@@ -371,10 +417,14 @@ caf_read_header (SF_PRIVATE *psf)
static int
caf_write_header (SF_PRIVATE *psf, int calc_length)
-{ DESC_CHUNK desc ;
+{ CAF_PRIVATE *pcaf ;
+ DESC_CHUNK desc ;
sf_count_t current, free_len ;
int subformat ;
+ if ((pcaf = psf->container_data) == NULL)
+ return SFE_INTERNAL ;
+
memset (&desc, 0, sizeof (desc)) ;
current = psf_ftell (psf) ;
@@ -513,13 +563,16 @@ caf_write_header (SF_PRIVATE *psf, int calc_length)
psf_binheader_writef (psf, "Ef8", (float) psf->peak_info->peaks [k].value, psf->peak_info->peaks [k].position) ;
} ;
+ if (psf->channel_map && pcaf->chanmap_tag)
+ psf_binheader_writef (psf, "Em8444", chan_MARKER, (sf_count_t) 12, pcaf->chanmap_tag, 0, 0) ;
+
/* Add free chunk so that the actual audio data starts at a multiple 0x1000. */
free_len = 0x1000 - psf->headindex - 16 - 12 ;
while (free_len < 0)
free_len += 0x1000 ;
psf_binheader_writef (psf, "Em8z", free_MARKER, free_len, (int) free_len) ;
- psf_binheader_writef (psf, "Em84", data_MARKER, psf->datalength, 0) ;
+ psf_binheader_writef (psf, "Em84", data_MARKER, psf->datalength + 4, 0) ;
psf_fwrite (psf->header, psf->headindex, 1, psf) ;
if (psf->error)
@@ -534,3 +587,34 @@ caf_write_header (SF_PRIVATE *psf, int calc_length)
return psf->error ;
} /* caf_write_header */
+static int
+caf_read_chanmap (SF_PRIVATE * psf, sf_count_t chunk_size)
+{ const AIFF_CAF_CHANNEL_MAP * map_info ;
+ unsigned channel_bitmap, channel_decriptions, bytesread ;
+ int layout_tag ;
+
+ bytesread = psf_binheader_readf (psf, "E444", &layout_tag, &channel_bitmap, &channel_decriptions) ;
+
+ map_info = aiff_caf_of_channel_layout_tag (layout_tag) ;
+
+ psf_log_printf (psf, " Tag : %x\n", layout_tag) ;
+ if (map_info)
+ psf_log_printf (psf, " Layout : %s\n", map_info->name) ;
+
+ if (bytesread < chunk_size)
+ psf_binheader_readf (psf, "j", chunk_size - bytesread) ;
+
+ if (map_info->channel_map != NULL)
+ { size_t chanmap_size = psf->sf.channels * sizeof (psf->channel_map [0]) ;
+
+ free (psf->channel_map) ;
+
+ if ((psf->channel_map = malloc (chanmap_size)) == NULL)
+ return SFE_MALLOC_FAILED ;
+
+ memcpy (psf->channel_map, map_info->channel_map, chanmap_size) ;
+ } ;
+
+ return 0 ;
+} /* caf_read_chanmap */
+
diff --git a/libs/libsndfile/src/chunk.c b/libs/libsndfile/src/chunk.c
index 98ff05ae54..dc17aaeabf 100644
--- a/libs/libsndfile/src/chunk.c
+++ b/libs/libsndfile/src/chunk.c
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 2008-2009 Erik de Castro Lopo
+** Copyright (C) 2008-2011 Erik de Castro Lopo
**
** 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
diff --git a/libs/libsndfile/src/command.c b/libs/libsndfile/src/command.c
index 72c892c40f..aae2a2716b 100644
--- a/libs/libsndfile/src/command.c
+++ b/libs/libsndfile/src/command.c
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 2001-2009 Erik de Castro Lopo
+** Copyright (C) 2001-2011 Erik de Castro Lopo
**
** 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
@@ -124,12 +124,14 @@ static SF_FORMAT_INFO const major_formats [] =
{ 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" },
+ { SF_FORMAT_MPC2K, "MPC (Akai MPC 2k)", "mpc" },
#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" },
+ { SF_FORMAT_RF64, "RF64 (RIFF 64)", "rf64" },
{ SF_FORMAT_SD2, "SD2 (Sound Designer II)", "sd2" },
{ SF_FORMAT_SDS, "SDS (Midi Sample Dump Standard)", "sds" },
{ SF_FORMAT_IRCAM, "SF (Berkeley/IRCAM/CARL)", "sf" },
diff --git a/libs/libsndfile/src/common.c b/libs/libsndfile/src/common.c
index 3b937f90e9..8aadbabe9f 100644
--- a/libs/libsndfile/src/common.c
+++ b/libs/libsndfile/src/common.c
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 1999-2009 Erik de Castro Lopo
+** Copyright (C) 1999-2011 Erik de Castro Lopo
**
** 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,9 +23,8 @@
#include
#include
#include
-#ifndef _MSC_VER
#include
-#endif
+
#include "sndfile.h"
#include "sfendian.h"
#include "common.h"
@@ -1035,14 +1034,14 @@ psf_binheader_readf (SF_PRIVATE *psf, char const *format, ...)
case 'b' :
charptr = va_arg (argptr, char*) ;
- count = va_arg (argptr, int) ;
+ count = va_arg (argptr, size_t) ;
if (count > 0)
byte_count += header_read (psf, charptr, count) ;
break ;
case 'G' :
charptr = va_arg (argptr, char*) ;
- count = va_arg (argptr, int) ;
+ count = va_arg (argptr, size_t) ;
if (count > 0)
byte_count += header_gets (psf, charptr, count) ;
break ;
@@ -1061,14 +1060,14 @@ psf_binheader_readf (SF_PRIVATE *psf, char const *format, ...)
case 'p' :
/* Get the seek position first. */
- count = va_arg (argptr, int) ;
+ count = va_arg (argptr, size_t) ;
header_seek (psf, count, SEEK_SET) ;
byte_count = count ;
break ;
case 'j' :
/* Get the seek position first. */
- count = va_arg (argptr, int) ;
+ count = va_arg (argptr, size_t) ;
header_seek (psf, count, SEEK_CUR) ;
byte_count += count ;
break ;
@@ -1133,7 +1132,7 @@ psf_hexdump (const void *ptr, int len)
printf ("%08X: ", k) ;
for (m = 0 ; m < 16 && k + m < len ; m++)
{ printf (m == 8 ? " %02X " : "%02X ", data [k + m] & 0xFF) ;
- ascii [m] = isprint (data [k + m]) ? data [k + m] : '.' ;
+ ascii [m] = psf_isprint (data [k + m]) ? data [k + m] : '.' ;
} ;
if (m <= 8) printf (" ") ;
@@ -1208,7 +1207,7 @@ psf_sanitize_string (char * cptr, int len)
do
{
len -- ;
- cptr [len] = isprint (cptr [len]) ? cptr [len] : '.' ;
+ cptr [len] = psf_isprint (cptr [len]) ? cptr [len] : '.' ;
}
while (len > 0) ;
} /* psf_sanitize_string */
@@ -1315,6 +1314,57 @@ psf_rand_int32 (void)
return value ;
} /* psf_rand_int32 */
+void
+append_snprintf (char * dest, size_t maxlen, const char * fmt, ...)
+{ size_t len = strlen (dest) ;
+
+ if (len < maxlen)
+ { va_list ap ;
+
+ va_start (ap, fmt) ;
+ vsnprintf (dest + len, maxlen - len, fmt, ap) ;
+ va_end (ap) ;
+ } ;
+
+ return ;
+} /* append_snprintf */
+
+
+void
+psf_strlcpy_crlf (char *dest, const char *src, size_t destmax, size_t srcmax)
+{ /* Must be minus 2 so it can still expand a single trailing '\n' or '\r'. */
+ char * destend = dest + destmax - 2 ;
+ 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 ;
+} /* psf_strlcpy_crlf */
+
/*==============================================================================
*/
diff --git a/libs/libsndfile/src/common.h b/libs/libsndfile/src/common.h
index 3e3aec0cbc..ed578048d7 100644
--- a/libs/libsndfile/src/common.h
+++ b/libs/libsndfile/src/common.h
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 1999-2009 Erik de Castro Lopo
+** Copyright (C) 1999-2011 Erik de Castro Lopo
**
** 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,15 +22,16 @@
#include "sfconfig.h"
#include
+#include
#if HAVE_STDINT_H
#include
+#elif HAVE_INTTYPES_H
+#include
#endif
#ifndef SNDFILE_H
#include "sndfile.h"
-#elif HAVE_INTTYPES_H
-#include
#endif
#ifdef __cplusplus
@@ -39,7 +40,9 @@
#if (SIZEOF_LONG == 8)
# define SF_PLATFORM_S64(x) x##l
-#elif COMPILER_IS_GCC || __SUNPRO_C
+#elif (SIZEOF_LONG_LONG == 8)
+# define SF_PLATFORM_S64(x) x##ll
+#elif COMPILER_IS_GCC
# define SF_PLATFORM_S64(x) x##ll
#elif OS_IS_WIN32
# define SF_PLATFORM_S64(x) x##I64
@@ -87,6 +90,8 @@
#define ARRAY_LEN(x) ((int) (sizeof (x) / sizeof ((x) [0])))
+#define NOT(x) (! (x))
+
#if (COMPILER_IS_GCC == 1)
#define SF_MAX(x,y) ({ \
typeof (x) sf_max_x1 = (x) ; \
@@ -104,6 +109,10 @@
#define SF_MIN(a,b) ((a) < (b) ? (a) : (b))
#endif
+
+#define SF_MAX_CHANNELS 256
+
+
/*
* Macros for spliting the format file of SF_INFI into contrainer type,
** codec type and endian-ness.
@@ -112,7 +121,6 @@
#define SF_CODEC(x) ((x) & SF_FORMAT_SUBMASK)
#define SF_ENDIAN(x) ((x) & SF_FORMAT_ENDMASK)
-
enum
{ /* PEAK chunk location. */
SF_PEAK_START = 42,
@@ -143,6 +151,8 @@ enum
enum
{ /* Work in progress. */
+ SF_FORMAT_SPEEX = 0x5000000,
+ SF_FORMAT_OGGFLAC = 0x5000001,
/* Formats supported read only. */
SF_FORMAT_TXW = 0x4030000, /* Yamaha TX16 sampler file */
@@ -214,22 +224,72 @@ make_size_t (int x)
{ return (size_t) x ;
} /* size_t_of_int */
+typedef SF_BROADCAST_INFO_VAR (16 * 1024) SF_BROADCAST_INFO_16K ;
+
+#if SIZEOF_WCHAR_T == 2
+typedef wchar_t sfwchar_t ;
+#else
+typedef int16_t sfwchar_t ;
+#endif
+
+/*
+** This version of isprint specifically ignores any locale info. Its used for
+** determining which characters can be printed in things like hexdumps.
+*/
+static inline int
+psf_isprint (int ch)
+{ return (ch >= ' ' && ch <= '~') ;
+} /* psf_isprint */
+
/*=======================================================================================
** SF_PRIVATE stuct - a pointer to this struct is passed back to the caller of the
** sf_open_XXXX functions. The caller however has no knowledge of the struct's
** contents.
*/
-
typedef struct
-{ int size ;
- SF_BROADCAST_INFO binfo ;
-} SF_BROADCAST_VAR ;
+{
+ union
+ { char c [SF_FILENAME_LEN] ;
+ sfwchar_t wc [SF_FILENAME_LEN] ;
+ } path ;
+
+ union
+ { char c [SF_FILENAME_LEN] ;
+ sfwchar_t wc [SF_FILENAME_LEN] ;
+ } dir ;
+
+ union
+ { char c [SF_FILENAME_LEN / 4] ;
+ sfwchar_t wc [SF_FILENAME_LEN / 4] ;
+ } name ;
+
+#if USE_WINDOWS_API
+ /*
+ ** These fields can only be used in src/file_io.c.
+ ** They are basically the same as a windows file HANDLE.
+ */
+ void *handle, *hsaved ;
+
+ int use_wchar ;
+#else
+ /* These fields can only be used in src/file_io.c. */
+ int filedes, savedes ;
+#endif
+
+ int do_not_close_descriptor ;
+ int mode ; /* Open mode : SFM_READ, SFM_WRITE or SFM_RDWR. */
+} PSF_FILE ;
+
typedef struct sf_private_tag
{
/* Canary in a coal mine. */
- char canary [64] ;
+ union
+ { /* Place a double here to encourage double alignment. */
+ double d [2] ;
+ char c [16] ;
+ } canary ;
/* Force the compiler to double align the start of buffer. */
union
@@ -247,10 +307,8 @@ typedef struct sf_private_tag
unsigned char ucbuf [SF_BUFFER_LEN / sizeof (signed char)] ;
} u ;
- char filepath [SF_FILENAME_LEN] ;
- char rsrcpath [SF_FILENAME_LEN] ;
- char directory [SF_FILENAME_LEN] ;
- char filename [SF_FILENAME_LEN / 4] ;
+
+ PSF_FILE file, rsrc ;
char syserr [SF_SYSERR_LEN] ;
@@ -278,22 +336,9 @@ typedef struct sf_private_tag
int logindex ;
int headindex, headend ;
int has_text ;
- int do_not_close_descriptor ;
-
-#if USE_WINDOWS_API
- /*
- ** These fields can only be used in src/file_io.c.
- ** They are basically the same as a windows file HANDLE.
- */
- void *hfile, *hrsrc, *hsaved ;
-#else
- /* These fields can only be used in src/file_io.c. */
- int filedes, rsrcdes, savedes ;
-#endif
int error ;
- int mode ; /* Open mode : SFM_READ, SFM_WRITE or SFM_RDWR. */
int endian ; /* File endianness : SF_ENDIAN_LITTLE or SF_ENDIAN_BIG. */
int data_endswap ; /* Need to endswap data? */
@@ -323,7 +368,7 @@ typedef struct sf_private_tag
SF_INSTRUMENT *instrument ;
/* Broadcast (EBU) Info */
- SF_BROADCAST_VAR *broadcast_var ;
+ SF_BROADCAST_INFO_16K *broadcast_16k ;
/* Channel map data (if present) : an array of ints. */
int *channel_map ;
@@ -453,6 +498,7 @@ enum
SFE_RDWR_BAD_HEADER,
SFE_CMD_HAS_DATA,
SFE_BAD_BROADCAST_INFO_SIZE,
+ SFE_BAD_BROADCAST_INFO_TOO_BIG,
SFE_STR_NO_SUPPORT,
SFE_STR_NOT_WRITE,
@@ -506,6 +552,7 @@ enum
SFE_PAF_VERSION,
SFE_PAF_UNKNOWN_FORMAT,
SFE_PAF_SHORT_HEADER,
+ SFE_PAF_BAD_CHANNELS,
SFE_SVX_NO_FORM,
SFE_SVX_NO_BODY,
@@ -612,6 +659,9 @@ void psf_log_SF_INFO (SF_PRIVATE *psf) ;
int32_t psf_rand_int32 (void) ;
+void append_snprintf (char * dest, size_t maxlen, const char * fmt, ...) ;
+void psf_strlcpy_crlf (char *dest, const char *src, size_t destmax, size_t srcmax) ;
+
/* Functions used when writing file headers. */
int psf_binheader_writef (SF_PRIVATE *psf, const char *format, ...) ;
@@ -665,13 +715,15 @@ int macos_guess_file_type (SF_PRIVATE *psf, const char *filename) ;
** some 32 bit OSes. Implementation in file_io.c.
*/
-int psf_fopen (SF_PRIVATE *psf, const char *pathname, int flags) ;
-int psf_set_stdio (SF_PRIVATE *psf, int mode) ;
+int psf_fopen (SF_PRIVATE *psf) ;
+int psf_set_stdio (SF_PRIVATE *psf) ;
int psf_file_valid (SF_PRIVATE *psf) ;
void psf_set_file (SF_PRIVATE *psf, int fd) ;
void psf_init_files (SF_PRIVATE *psf) ;
void psf_use_rsrc (SF_PRIVATE *psf, int on_off) ;
+SNDFILE * psf_open_file (SF_PRIVATE *psf, SF_INFO *sfinfo) ;
+
sf_count_t psf_fseek (SF_PRIVATE *psf, sf_count_t offset, int whence) ;
sf_count_t psf_fread (void *ptr, sf_count_t bytes, sf_count_t count, SF_PRIVATE *psf) ;
sf_count_t psf_fwrite (const void *ptr, sf_count_t bytes, sf_count_t count, SF_PRIVATE *psf) ;
@@ -687,7 +739,7 @@ int psf_ftruncate (SF_PRIVATE *psf, sf_count_t len) ;
int psf_fclose (SF_PRIVATE *psf) ;
/* Open and close the resource fork of a file. */
-int psf_open_rsrc (SF_PRIVATE *psf, int mode) ;
+int psf_open_rsrc (SF_PRIVATE *psf) ;
int psf_close_rsrc (SF_PRIVATE *psf) ;
/*
@@ -724,6 +776,11 @@ int rf64_open (SF_PRIVATE *psf) ;
/* In progress. Do not currently work. */
+int ogg_vorbis_open (SF_PRIVATE *psf) ;
+int ogg_speex_open (SF_PRIVATE *psf) ;
+int ogg_pcm_open (SF_PRIVATE *psf) ;
+
+
int mpeg_open (SF_PRIVATE *psf) ;
int ogg_open (SF_PRIVATE *psf) ;
int rx2_open (SF_PRIVATE *psf) ;
@@ -774,6 +831,30 @@ typedef struct
void pchk4_store (PRIV_CHUNK4 * pchk, int marker, sf_count_t offset, sf_count_t len) ;
int pchk4_find (PRIV_CHUNK4 * pchk, int marker) ;
+/*------------------------------------------------------------------------------------
+** Functions that work like OpenBSD's strlcpy/strlcat to replace strncpy/strncat.
+**
+** See : http://www.gratisoft.us/todd/papers/strlcpy.html
+**
+** These functions are available on *BSD, but are not avaialble everywhere so we
+** implement them here.
+**
+** The argument order has been changed to that of strncpy/strncat to cause
+** compiler errors if code is carelessly converted from one to the other.
+*/
+
+static inline void
+psf_strlcat (char *dest, size_t n, const char *src)
+{ strncat (dest, src, n - strlen (dest) - 1) ;
+ dest [n - 1] = 0 ;
+} /* psf_strlcat */
+
+static inline void
+psf_strlcpy (char *dest, size_t n, const char *src)
+{ strncpy (dest, src, n - 1) ;
+ dest [n - 1] = 0 ;
+} /* psf_strlcpy */
+
/*------------------------------------------------------------------------------------
** Other helper functions.
*/
@@ -787,7 +868,7 @@ 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) ;
+SF_BROADCAST_INFO_16K * broadcast_var_alloc (void) ;
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) ;
@@ -798,7 +879,7 @@ typedef struct
} AUDIO_DETECT ;
int audio_detect (SF_PRIVATE * psf, AUDIO_DETECT *ad, const unsigned char * data, int datalen) ;
-
+int id3_skip (SF_PRIVATE * psf) ;
/*------------------------------------------------------------------------------------
** Helper/debug functions.
diff --git a/libs/libsndfile/src/create_symbols_file.py b/libs/libsndfile/src/create_symbols_file.py
index a91e89edb2..f2cab122e9 100755
--- a/libs/libsndfile/src/create_symbols_file.py
+++ b/libs/libsndfile/src/create_symbols_file.py
@@ -1,6 +1,6 @@
#!/usr/bin/python
-# Copyright (C) 2003-2007 Erik de Castro Lopo
+# Copyright (C) 2003-2011 Erik de Castro Lopo
#
# All rights reserved.
#
@@ -69,7 +69,9 @@ ALL_SYMBOLS = (
( "sf_strerror", 50 ),
( "sf_get_string", 60 ),
( "sf_set_string", 61 ),
+ ( "sf_version_string",68 ),
( "sf_open_fd", 70 ),
+ ( "sf_wchar_open", 71 ),
( "sf_open_virtual", 80 ),
( "sf_write_sync", 90 )
)
@@ -82,6 +84,8 @@ def linux_symbols (progname, version):
print "{"
print " global:"
for name, ordinal in ALL_SYMBOLS:
+ if name == "sf_wchar_open":
+ continue
print " %s ;" % name
print " local:"
print " * ;"
@@ -92,6 +96,8 @@ def linux_symbols (progname, version):
def darwin_symbols (progname, version):
print "# Auto-generated by %s\n" %progname
for name, ordinal in ALL_SYMBOLS:
+ if name == "sf_wchar_open":
+ continue
print "_%s" % name
print
return
@@ -107,16 +113,22 @@ def win32_symbols (progname, version, name):
def os2_symbols (progname, version, name):
print "; Auto-generated by %s\n" %progname
- print "LIBRARY %s%s.dll" % (name, re.sub ("\..*", "", version))
+ print "LIBRARY %s%s" % (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)
+ if name == "sf_wchar_open":
+ continue
+ print "_%-20s @%s" % (name, ordinal)
print
return
+def plain_symbols (progname, version, name):
+ for name, ordinal in ALL_SYMBOLS:
+ print name
+
def no_symbols (os_name):
print
print "No known way of restricting exported symbols on '%s'." % os_name
@@ -138,13 +150,14 @@ if len (sys.argv) != 3:
print " win32 (ie wintendo)"
print " cygwin (Cygwin on wintendo)"
print " os2 (OS/2)"
+ print " plain (plain list of symbols)"
print
sys.exit (1)
os_name = sys.argv [1]
version = re.sub ("\.[a-z0-9]+$", "", sys.argv [2])
-if os_name == "linux":
+if os_name == "linux" or os_name == "gnu" or os_name == "binutils":
linux_symbols (progname, version)
elif os_name == "darwin":
darwin_symbols (progname, version)
@@ -154,6 +167,8 @@ elif os_name == "cygwin":
win32_symbols (progname, version, "cygsndfile")
elif os_name == "os2":
os2_symbols (progname, version, "sndfile")
+elif os_name == "static":
+ plain_symbols (progname, version, "")
else:
no_symbols (os_name)
diff --git a/libs/libsndfile/src/cygsndfile.def b/libs/libsndfile/src/cygsndfile.def
deleted file mode 100644
index 510aa8e229..0000000000
--- a/libs/libsndfile/src/cygsndfile.def
+++ /dev/null
@@ -1,39 +0,0 @@
-; Auto-generated by create_symbols_file.py
-
-LIBRARY cygsndfile-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
-
diff --git a/libs/libsndfile/src/dither.c b/libs/libsndfile/src/dither.c
index d6284ac72b..d149bc1b68 100644
--- a/libs/libsndfile/src/dither.c
+++ b/libs/libsndfile/src/dither.c
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 2003-2009 Erik de Castro Lopo
+** Copyright (C) 2003-2011 Erik de Castro Lopo
**
** 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
diff --git a/libs/libsndfile/src/double64.c b/libs/libsndfile/src/double64.c
index 7f5e107fbb..425088bb3e 100644
--- a/libs/libsndfile/src/double64.c
+++ b/libs/libsndfile/src/double64.c
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 1999-2009 Erik de Castro Lopo
+** Copyright (C) 1999-2011 Erik de Castro Lopo
**
** 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
@@ -95,7 +95,7 @@ double64_init (SF_PRIVATE *psf)
psf->blockwidth = sizeof (double) * psf->sf.channels ;
- if (psf->mode == SFM_READ || psf->mode == SFM_RDWR)
+ if (psf->file.mode == SFM_READ || psf->file.mode == SFM_RDWR)
{ switch (psf->endian + double64_caps)
{ case (SF_ENDIAN_BIG + DOUBLE_CAN_RW_BE) :
psf->data_endswap = SF_FALSE ;
@@ -166,7 +166,7 @@ double64_init (SF_PRIVATE *psf)
} ;
} ;
- if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR)
+ if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR)
{ switch (psf->endian + double64_caps)
{ case (SF_ENDIAN_LITTLE + DOUBLE_CAN_RW_LE) :
psf->data_endswap = SF_FALSE ;
diff --git a/libs/libsndfile/src/dwd.c b/libs/libsndfile/src/dwd.c
index 943c6d0a9e..fba7b0cfd1 100644
--- a/libs/libsndfile/src/dwd.c
+++ b/libs/libsndfile/src/dwd.c
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 2002-2009 Erik de Castro Lopo
+** Copyright (C) 2002-2011 Erik de Castro Lopo
**
** 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
@@ -69,9 +69,9 @@ static int dwd_close (SF_PRIVATE *psf) ;
int
dwd_open (SF_PRIVATE *psf)
-{ int subformat, error = 0 ;
+{ int error = 0 ;
- if (psf->mode == SFM_READ || (psf->mode == SFM_RDWR && psf->filelength > 0))
+ if (psf->file.mode == SFM_READ || (psf->file.mode == SFM_RDWR && psf->filelength > 0))
{ if ((error = dwd_read_header (psf)))
return error ;
} ;
@@ -79,9 +79,7 @@ dwd_open (SF_PRIVATE *psf)
if ((SF_CONTAINER (psf->sf.format)) != SF_FORMAT_DWD)
return SFE_BAD_OPEN_FORMAT ;
- subformat = SF_CODEC (psf->sf.format) ;
-
- if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR)
+ if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR)
{
/*-psf->endian = SF_ENDIAN (psf->sf.format) ;
if (CPU_IS_LITTLE_ENDIAN && psf->endian == SF_ENDIAN_CPU)
diff --git a/libs/libsndfile/src/dwvw.c b/libs/libsndfile/src/dwvw.c
index d5537f1a23..562f01513e 100644
--- a/libs/libsndfile/src/dwvw.c
+++ b/libs/libsndfile/src/dwvw.c
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 2002-2009 Erik de Castro Lopo
+** Copyright (C) 2002-2011 Erik de Castro Lopo
**
** 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
@@ -86,7 +86,7 @@ dwvw_init (SF_PRIVATE *psf, int bitwidth)
if (bitwidth > 24)
return SFE_DWVW_BAD_BITWIDTH ;
- if (psf->mode == SFM_RDWR)
+ if (psf->file.mode == SFM_RDWR)
return SFE_BAD_MODE_RW ;
if ((pdwvw = calloc (1, sizeof (DWVW_PRIVATE))) == NULL)
@@ -101,14 +101,14 @@ dwvw_init (SF_PRIVATE *psf, int bitwidth)
dwvw_read_reset (pdwvw) ;
- if (psf->mode == SFM_READ)
+ if (psf->file.mode == SFM_READ)
{ psf->read_short = dwvw_read_s ;
psf->read_int = dwvw_read_i ;
psf->read_float = dwvw_read_f ;
psf->read_double = dwvw_read_d ;
} ;
- if (psf->mode == SFM_WRITE)
+ if (psf->file.mode == SFM_WRITE)
{ psf->write_short = dwvw_write_s ;
psf->write_int = dwvw_write_i ;
psf->write_float = dwvw_write_f ;
@@ -137,7 +137,7 @@ dwvw_close (SF_PRIVATE *psf)
return 0 ;
pdwvw = (DWVW_PRIVATE*) psf->codec_data ;
- if (psf->mode == SFM_WRITE)
+ if (psf->file.mode == SFM_WRITE)
{ static int last_values [12] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } ;
/* Write 8 zero samples to fully flush output. */
diff --git a/libs/libsndfile/src/file_io.c b/libs/libsndfile/src/file_io.c
index 4e5ee3eed6..44f1b5a350 100644
--- a/libs/libsndfile/src/file_io.c
+++ b/libs/libsndfile/src/file_io.c
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 2002-2009 Erik de Castro Lopo
+** Copyright (C) 2002-2011 Erik de Castro Lopo
** Copyright (C) 2003 Ross Bencina
**
** This program is free software; you can redistribute it and/or modify
@@ -73,26 +73,24 @@ static void psf_log_syserr (SF_PRIVATE *psf, int error) ;
*/
static int psf_close_fd (int fd) ;
-static int psf_open_fd (const char * path, int mode) ;
+static int psf_open_fd (PSF_FILE * pfile) ;
static sf_count_t psf_get_filelen_fd (int fd) ;
int
-psf_fopen (SF_PRIVATE *psf, const char *pathname, int open_mode)
+psf_fopen (SF_PRIVATE *psf)
{
psf->error = 0 ;
- psf->filedes = psf_open_fd (pathname, open_mode) ;
+ psf->file.filedes = psf_open_fd (&psf->file) ;
- if (psf->filedes == - SFE_BAD_OPEN_MODE)
+ if (psf->file.filedes == - SFE_BAD_OPEN_MODE)
{ psf->error = SFE_BAD_OPEN_MODE ;
- psf->filedes = -1 ;
+ psf->file.filedes = -1 ;
return psf->error ;
} ;
- if (psf->filedes == -1)
+ if (psf->file.filedes == -1)
psf_log_syserr (psf, errno) ;
- psf->mode = open_mode ;
-
return psf->error ;
} /* psf_fopen */
@@ -103,37 +101,37 @@ psf_fclose (SF_PRIVATE *psf)
if (psf->virtual_io)
return 0 ;
- if (psf->do_not_close_descriptor)
- { psf->filedes = -1 ;
+ if (psf->file.do_not_close_descriptor)
+ { psf->file.filedes = -1 ;
return 0 ;
} ;
- if ((retval = psf_close_fd (psf->filedes)) == -1)
+ if ((retval = psf_close_fd (psf->file.filedes)) == -1)
psf_log_syserr (psf, errno) ;
- psf->filedes = -1 ;
+ psf->file.filedes = -1 ;
return retval ;
} /* psf_fclose */
int
-psf_open_rsrc (SF_PRIVATE *psf, int open_mode)
+psf_open_rsrc (SF_PRIVATE *psf)
{
- if (psf->rsrcdes > 0)
+ if (psf->rsrc.filedes > 0)
return 0 ;
/* Test for MacOSX style resource fork on HPFS or HPFS+ filesystems. */
- snprintf (psf->rsrcpath, sizeof (psf->rsrcpath), "%s/rsrc", psf->filepath) ;
+ snprintf (psf->rsrc.path.c, sizeof (psf->rsrc.path.c), "%s/rsrc", psf->file.path.c) ;
psf->error = SFE_NO_ERROR ;
- if ((psf->rsrcdes = psf_open_fd (psf->rsrcpath, open_mode)) >= 0)
- { psf->rsrclength = psf_get_filelen_fd (psf->rsrcdes) ;
- if (psf->rsrclength > 0 || (open_mode & SFM_WRITE))
+ if ((psf->rsrc.filedes = psf_open_fd (&psf->rsrc)) >= 0)
+ { psf->rsrclength = psf_get_filelen_fd (psf->rsrc.filedes) ;
+ if (psf->rsrclength > 0 || (psf->rsrc.mode & SFM_WRITE))
return SFE_NO_ERROR ;
- psf_close_fd (psf->rsrcdes) ;
- psf->rsrcdes = -1 ;
+ psf_close_fd (psf->rsrc.filedes) ;
+ psf->rsrc.filedes = -1 ;
} ;
- if (psf->rsrcdes == - SFE_BAD_OPEN_MODE)
+ if (psf->rsrc.filedes == - SFE_BAD_OPEN_MODE)
{ psf->error = SFE_BAD_OPEN_MODE ;
return psf->error ;
} ;
@@ -142,10 +140,10 @@ psf_open_rsrc (SF_PRIVATE *psf, int open_mode)
** Now try for a resource fork stored as a separate file in the same
** directory, but preceded with a dot underscore.
*/
- snprintf (psf->rsrcpath, sizeof (psf->rsrcpath), "%s._%s", psf->directory, psf->filename) ;
+ snprintf (psf->rsrc.path.c, sizeof (psf->rsrc.path.c), "%s._%s", psf->file.dir.c, psf->file.name.c) ;
psf->error = SFE_NO_ERROR ;
- if ((psf->rsrcdes = psf_open_fd (psf->rsrcpath, open_mode)) >= 0)
- { psf->rsrclength = psf_get_filelen_fd (psf->rsrcdes) ;
+ if ((psf->rsrc.filedes = psf_open_fd (&psf->rsrc)) >= 0)
+ { psf->rsrclength = psf_get_filelen_fd (psf->rsrc.filedes) ;
return SFE_NO_ERROR ;
} ;
@@ -153,18 +151,18 @@ psf_open_rsrc (SF_PRIVATE *psf, int open_mode)
** Now try for a resource fork stored in a separate file in the
** .AppleDouble/ directory.
*/
- snprintf (psf->rsrcpath, sizeof (psf->rsrcpath), "%s.AppleDouble/%s", psf->directory, psf->filename) ;
+ snprintf (psf->rsrc.path.c, sizeof (psf->rsrc.path.c), "%s.AppleDouble/%s", psf->file.dir.c, psf->file.name.c) ;
psf->error = SFE_NO_ERROR ;
- if ((psf->rsrcdes = psf_open_fd (psf->rsrcpath, open_mode)) >= 0)
- { psf->rsrclength = psf_get_filelen_fd (psf->rsrcdes) ;
+ if ((psf->rsrc.filedes = psf_open_fd (&psf->rsrc)) >= 0)
+ { psf->rsrclength = psf_get_filelen_fd (psf->rsrc.filedes) ;
return SFE_NO_ERROR ;
} ;
/* No resource file found. */
- if (psf->rsrcdes == -1)
+ if (psf->rsrc.filedes == -1)
psf_log_syserr (psf, errno) ;
- psf->rsrcdes = -1 ;
+ psf->rsrc.filedes = -1 ;
return psf->error ;
} /* psf_open_rsrc */
@@ -176,7 +174,7 @@ psf_get_filelen (SF_PRIVATE *psf)
if (psf->virtual_io)
return psf->vio.get_filelen (psf->vio_user_data) ;
- filelen = psf_get_filelen_fd (psf->filedes) ;
+ filelen = psf_get_filelen_fd (psf->file.filedes) ;
if (filelen == -1)
{ psf_log_syserr (psf, errno) ;
@@ -188,7 +186,7 @@ psf_get_filelen (SF_PRIVATE *psf)
return (sf_count_t) -1 ;
} ;
- switch (psf->mode)
+ switch (psf->file.mode)
{ case SFM_WRITE :
filelen = filelen - psf->fileoffset ;
break ;
@@ -216,28 +214,26 @@ psf_get_filelen (SF_PRIVATE *psf)
int
psf_close_rsrc (SF_PRIVATE *psf)
-{
- if (psf->rsrcdes >= 0)
- psf_close_fd (psf->rsrcdes) ;
- psf->rsrcdes = -1 ;
+{ psf_close_fd (psf->rsrc.filedes) ;
+ psf->rsrc.filedes = -1 ;
return 0 ;
} /* psf_close_rsrc */
int
-psf_set_stdio (SF_PRIVATE *psf, int mode)
+psf_set_stdio (SF_PRIVATE *psf)
{ int error = 0 ;
- switch (mode)
+ switch (psf->file.mode)
{ case SFM_RDWR :
error = SFE_OPEN_PIPE_RDWR ;
break ;
case SFM_READ :
- psf->filedes = 0 ;
+ psf->file.filedes = 0 ;
break ;
case SFM_WRITE :
- psf->filedes = 1 ;
+ psf->file.filedes = 1 ;
break ;
default :
@@ -251,29 +247,31 @@ psf_set_stdio (SF_PRIVATE *psf, int mode)
void
psf_set_file (SF_PRIVATE *psf, int fd)
-{ psf->filedes = fd ;
+{ psf->file.filedes = fd ;
} /* psf_set_file */
int
psf_file_valid (SF_PRIVATE *psf)
-{ return (psf->filedes >= 0) ? SF_TRUE : SF_FALSE ;
+{ return (psf->file.filedes >= 0) ? SF_TRUE : SF_FALSE ;
} /* psf_set_file */
sf_count_t
psf_fseek (SF_PRIVATE *psf, sf_count_t offset, int whence)
-{ sf_count_t new_position ;
+{ sf_count_t current_pos, new_position ;
if (psf->virtual_io)
return psf->vio.seek (offset, whence, psf->vio_user_data) ;
+ current_pos = psf_ftell (psf) ;
+
switch (whence)
{ case SEEK_SET :
offset += psf->fileoffset ;
break ;
case SEEK_END :
- if (psf->mode == SFM_WRITE)
- { new_position = lseek (psf->filedes, offset, whence) ;
+ if (psf->file.mode == SFM_WRITE)
+ { new_position = lseek (psf->file.filedes, offset, whence) ;
if (new_position < 0)
psf_log_syserr (psf, errno) ;
@@ -286,15 +284,25 @@ psf_fseek (SF_PRIVATE *psf, sf_count_t offset, int whence)
** get the offset wrt the start of file.
*/
whence = SEEK_SET ;
- offset = lseek (psf->filedes, 0, SEEK_END) + offset ;
+ offset = lseek (psf->file.filedes, 0, SEEK_END) + offset ;
+ break ;
+
+ case SEEK_CUR :
+ /* Translate a SEEK_CUR into a SEEK_SET. */
+ offset += current_pos ;
+ whence = SEEK_SET ;
break ;
default :
- /* No need to do anything about SEEK_CUR. */
- break ;
+ /* We really should not be here. */
+ psf_log_printf (psf, "psf_fseek : whence is %d *****.\n", whence) ;
+ return 0 ;
} ;
- new_position = lseek (psf->filedes, offset, whence) ;
+ if (current_pos != offset)
+ new_position = lseek (psf->file.filedes, offset, whence) ;
+ else
+ new_position = offset ;
if (new_position < 0)
psf_log_syserr (psf, errno) ;
@@ -322,7 +330,7 @@ psf_fread (void *ptr, sf_count_t bytes, sf_count_t items, SF_PRIVATE *psf)
{ /* Break the read down to a sensible size. */
count = (items > SENSIBLE_SIZE) ? SENSIBLE_SIZE : (ssize_t) items ;
- count = read (psf->filedes, ((char*) ptr) + total, (size_t) count) ;
+ count = read (psf->file.filedes, ((char*) ptr) + total, (size_t) count) ;
if (count == -1)
{ if (errno == EINTR)
@@ -363,7 +371,7 @@ psf_fwrite (const void *ptr, sf_count_t bytes, sf_count_t items, SF_PRIVATE *psf
{ /* Break the writes down to a sensible size. */
count = (items > SENSIBLE_SIZE) ? SENSIBLE_SIZE : items ;
- count = write (psf->filedes, ((const char*) ptr) + total, count) ;
+ count = write (psf->file.filedes, ((const char*) ptr) + total, count) ;
if (count == -1)
{ if (errno == EINTR)
@@ -396,7 +404,7 @@ psf_ftell (SF_PRIVATE *psf)
if (psf->is_pipe)
return psf->pipeoffset ;
- pos = lseek (psf->filedes, 0, SEEK_CUR) ;
+ pos = lseek (psf->file.filedes, 0, SEEK_CUR) ;
if (pos == ((sf_count_t) -1))
{ psf_log_syserr (psf, errno) ;
@@ -410,6 +418,9 @@ static int
psf_close_fd (int fd)
{ int retval ;
+ if (fd < 0)
+ return 0 ;
+
while ((retval = close (fd)) == -1 && errno == EINTR)
/* Do nothing. */ ;
@@ -422,7 +433,7 @@ psf_fgets (char *buffer, sf_count_t bufsize, SF_PRIVATE *psf)
sf_count_t count ;
while (k < bufsize - 1)
- { count = read (psf->filedes, &(buffer [k]), 1) ;
+ { count = read (psf->file.filedes, &(buffer [k]), 1) ;
if (count == -1)
{ if (errno == EINTR)
@@ -448,7 +459,7 @@ psf_is_pipe (SF_PRIVATE *psf)
if (psf->virtual_io)
return SF_FALSE ;
- if (fstat (psf->filedes, &statbuf) == -1)
+ if (fstat (psf->file.filedes, &statbuf) == -1)
{ psf_log_syserr (psf, errno) ;
/* Default to maximum safety. */
return SF_TRUE ;
@@ -488,7 +499,7 @@ psf_ftruncate (SF_PRIVATE *psf, sf_count_t len)
if ((sizeof (off_t) < sizeof (sf_count_t)) && len > 0x7FFFFFFF)
return -1 ;
- retval = ftruncate (psf->filedes, len) ;
+ retval = ftruncate (psf->file.filedes, len) ;
if (retval == -1)
psf_log_syserr (psf, errno) ;
@@ -498,28 +509,28 @@ psf_ftruncate (SF_PRIVATE *psf, sf_count_t len)
void
psf_init_files (SF_PRIVATE *psf)
-{ psf->filedes = -1 ;
- psf->rsrcdes = -1 ;
- psf->savedes = -1 ;
+{ psf->file.filedes = -1 ;
+ psf->rsrc.filedes = -1 ;
+ psf->file.savedes = -1 ;
} /* psf_init_files */
void
psf_use_rsrc (SF_PRIVATE *psf, int on_off)
{
if (on_off)
- { if (psf->filedes != psf->rsrcdes)
- { psf->savedes = psf->filedes ;
- psf->filedes = psf->rsrcdes ;
+ { if (psf->file.filedes != psf->rsrc.filedes)
+ { psf->file.savedes = psf->file.filedes ;
+ psf->file.filedes = psf->rsrc.filedes ;
} ;
}
- else if (psf->filedes == psf->rsrcdes)
- psf->filedes = psf->savedes ;
+ else if (psf->file.filedes == psf->rsrc.filedes)
+ psf->file.filedes = psf->file.savedes ;
return ;
} /* psf_use_rsrc */
static int
-psf_open_fd (const char * pathname, int open_mode)
+psf_open_fd (PSF_FILE * pfile)
{ int fd, oflag, mode ;
/*
@@ -533,7 +544,7 @@ psf_open_fd (const char * pathname, int open_mode)
exit (1) ;
} ;
- switch (open_mode)
+ switch (pfile->mode)
{ case SFM_READ :
oflag = O_RDONLY | O_BINARY ;
mode = 0 ;
@@ -555,9 +566,9 @@ psf_open_fd (const char * pathname, int open_mode)
} ;
if (mode == 0)
- fd = open (pathname, oflag) ;
+ fd = open (pfile->path.c, oflag) ;
else
- fd = open (pathname, oflag, mode) ;
+ fd = open (pfile->path.c, oflag, mode) ;
return fd ;
} /* psf_open_fd */
@@ -578,8 +589,8 @@ void
psf_fsync (SF_PRIVATE *psf)
{
#if HAVE_FSYNC
- if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR)
- fsync (psf->filedes) ;
+ if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR)
+ fsync (psf->file.filedes) ;
#else
psf = NULL ;
#endif
@@ -593,20 +604,18 @@ psf_fsync (SF_PRIVATE *psf)
#include
static int psf_close_handle (HANDLE handle) ;
-static HANDLE psf_open_handle (const char * path, int mode) ;
+static HANDLE psf_open_handle (PSF_FILE * pfile) ;
static sf_count_t psf_get_filelen_handle (HANDLE handle) ;
/* USE_WINDOWS_API */ int
-psf_fopen (SF_PRIVATE *psf, const char *pathname, int open_mode)
+psf_fopen (SF_PRIVATE *psf)
{
psf->error = 0 ;
- psf->hfile = psf_open_handle (pathname, open_mode) ;
+ psf->file.handle = psf_open_handle (&psf->file) ;
- if (psf->hfile == NULL)
+ if (psf->file.handle == NULL)
psf_log_syserr (psf, GetLastError ()) ;
- psf->mode = open_mode ;
-
return psf->error ;
} /* psf_fopen */
@@ -617,30 +626,30 @@ psf_fclose (SF_PRIVATE *psf)
if (psf->virtual_io)
return 0 ;
- if (psf->do_not_close_descriptor)
- { psf->hfile = NULL ;
+ if (psf->file.do_not_close_descriptor)
+ { psf->file.handle = NULL ;
return 0 ;
} ;
- if ((retval = psf_close_handle (psf->hfile)) == -1)
+ if ((retval = psf_close_handle (psf->file.handle)) == -1)
psf_log_syserr (psf, GetLastError ()) ;
- psf->hfile = NULL ;
+ psf->file.handle = NULL ;
return retval ;
} /* psf_fclose */
/* USE_WINDOWS_API */ int
-psf_open_rsrc (SF_PRIVATE *psf, int open_mode)
+psf_open_rsrc (SF_PRIVATE *psf)
{
- if (psf->hrsrc != NULL)
+ if (psf->rsrc.handle != NULL)
return 0 ;
/* Test for MacOSX style resource fork on HPFS or HPFS+ filesystems. */
- snprintf (psf->rsrcpath, sizeof (psf->rsrcpath), "%s/rsrc", psf->filepath) ;
+ snprintf (psf->rsrc.path.c, sizeof (psf->rsrc.path.c), "%s/rsrc", psf->file.path.c) ;
psf->error = SFE_NO_ERROR ;
- if ((psf->hrsrc = psf_open_handle (psf->rsrcpath, open_mode)) != NULL)
- { psf->rsrclength = psf_get_filelen_handle (psf->hrsrc) ;
+ if ((psf->rsrc.handle = psf_open_handle (&psf->rsrc)) != NULL)
+ { psf->rsrclength = psf_get_filelen_handle (psf->rsrc.handle) ;
return SFE_NO_ERROR ;
} ;
@@ -648,10 +657,10 @@ psf_open_rsrc (SF_PRIVATE *psf, int open_mode)
** Now try for a resource fork stored as a separate file in the same
** directory, but preceded with a dot underscore.
*/
- snprintf (psf->rsrcpath, sizeof (psf->rsrcpath), "%s._%s", psf->directory, psf->filename) ;
+ snprintf (psf->rsrc.path.c, sizeof (psf->rsrc.path.c), "%s._%s", psf->file.dir.c, psf->file.name.c) ;
psf->error = SFE_NO_ERROR ;
- if ((psf->hrsrc = psf_open_handle (psf->rsrcpath, open_mode)) != NULL)
- { psf->rsrclength = psf_get_filelen_handle (psf->hrsrc) ;
+ if ((psf->rsrc.handle = psf_open_handle (&psf->rsrc)) != NULL)
+ { psf->rsrclength = psf_get_filelen_handle (psf->rsrc.handle) ;
return SFE_NO_ERROR ;
} ;
@@ -659,18 +668,18 @@ psf_open_rsrc (SF_PRIVATE *psf, int open_mode)
** Now try for a resource fork stored in a separate file in the
** .AppleDouble/ directory.
*/
- snprintf (psf->rsrcpath, sizeof (psf->rsrcpath), "%s.AppleDouble/%s", psf->directory, psf->filename) ;
+ snprintf (psf->rsrc.path.c, sizeof (psf->rsrc.path.c), "%s.AppleDouble/%s", psf->file.dir.c, psf->file.name.c) ;
psf->error = SFE_NO_ERROR ;
- if ((psf->hrsrc = psf_open_handle (psf->rsrcpath, open_mode)) != NULL)
- { psf->rsrclength = psf_get_filelen_handle (psf->hrsrc) ;
- return SFE_NO_ERROR ;
+ if ((psf->rsrc.handle = psf_open_handle (&psf->rsrc)) != NULL)
+ { psf->rsrclength = psf_get_filelen_handle (psf->rsrc.handle) ;
+ return SFE_NO_ERROR ;
} ;
/* No resource file found. */
- if (psf->hrsrc == NULL)
+ if (psf->rsrc.handle == NULL)
psf_log_syserr (psf, GetLastError ()) ;
- psf->hrsrc = NULL ;
+ psf->rsrc.handle = NULL ;
return psf->error ;
} /* psf_open_rsrc */
@@ -682,7 +691,7 @@ psf_get_filelen (SF_PRIVATE *psf)
if (psf->virtual_io)
return psf->vio.get_filelen (psf->vio_user_data) ;
- filelen = psf_get_filelen_handle (psf->hfile) ;
+ filelen = psf_get_filelen_handle (psf->file.handle) ;
if (filelen == -1)
{ psf_log_syserr (psf, errno) ;
@@ -694,7 +703,7 @@ psf_get_filelen (SF_PRIVATE *psf)
return (sf_count_t) -1 ;
} ;
- switch (psf->mode)
+ switch (psf->file.mode)
{ case SFM_WRITE :
filelen = filelen - psf->fileoffset ;
break ;
@@ -722,34 +731,34 @@ psf_get_filelen (SF_PRIVATE *psf)
/* USE_WINDOWS_API */ void
psf_init_files (SF_PRIVATE *psf)
-{ psf->hfile = NULL ;
- psf->hrsrc = NULL ;
- psf->hsaved = NULL ;
+{ psf->file.handle = NULL ;
+ psf->rsrc.handle = NULL ;
+ psf->file.hsaved = NULL ;
} /* psf_init_files */
/* USE_WINDOWS_API */ void
psf_use_rsrc (SF_PRIVATE *psf, int on_off)
{
if (on_off)
- { if (psf->hfile != psf->hrsrc)
- { psf->hsaved = psf->hfile ;
- psf->hfile = psf->hrsrc ;
+ { if (psf->file.handle != psf->rsrc.handle)
+ { psf->file.hsaved = psf->file.handle ;
+ psf->file.handle = psf->rsrc.handle ;
} ;
}
- else if (psf->hfile == psf->hrsrc)
- psf->hfile = psf->hsaved ;
+ else if (psf->file.handle == psf->rsrc.handle)
+ psf->file.handle = psf->file.hsaved ;
return ;
} /* psf_use_rsrc */
/* USE_WINDOWS_API */ static HANDLE
-psf_open_handle (const char * pathname, int open_mode)
+psf_open_handle (PSF_FILE * pfile)
{ DWORD dwDesiredAccess ;
DWORD dwShareMode ;
DWORD dwCreationDistribution ;
HANDLE handle ;
- switch (open_mode)
+ switch (pfile->mode)
{ case SFM_READ :
dwDesiredAccess = GENERIC_READ ;
dwShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE ;
@@ -772,15 +781,26 @@ psf_open_handle (const char * pathname, int open_mode)
return NULL ;
} ;
- handle = CreateFile (
- pathname, /* pointer to name of the file */
- dwDesiredAccess, /* access (read-write) mode */
- dwShareMode, /* share mode */
- 0, /* pointer to security attributes */
- dwCreationDistribution, /* how to create */
- FILE_ATTRIBUTE_NORMAL, /* file attributes (could use FILE_FLAG_SEQUENTIAL_SCAN) */
- NULL /* handle to file with attributes to copy */
- ) ;
+ if (pfile->use_wchar)
+ handle = CreateFileW (
+ pfile->path.wc, /* pointer to name of the file */
+ dwDesiredAccess, /* access (read-write) mode */
+ dwShareMode, /* share mode */
+ 0, /* pointer to security attributes */
+ dwCreationDistribution, /* how to create */
+ FILE_ATTRIBUTE_NORMAL, /* file attributes (could use FILE_FLAG_SEQUENTIAL_SCAN) */
+ NULL /* handle to file with attributes to copy */
+ ) ;
+ else
+ handle = CreateFile (
+ pfile->path.c, /* pointer to name of the file */
+ dwDesiredAccess, /* access (read-write) mode */
+ dwShareMode, /* share mode */
+ 0, /* pointer to security attributes */
+ dwCreationDistribution, /* how to create */
+ FILE_ATTRIBUTE_NORMAL, /* file attributes (could use FILE_FLAG_SEQUENTIAL_SCAN) */
+ NULL /* handle to file with attributes to copy */
+ ) ;
if (handle == INVALID_HANDLE_VALUE)
return NULL ;
@@ -816,32 +836,30 @@ psf_log_syserr (SF_PRIVATE *psf, int error)
/* USE_WINDOWS_API */ int
psf_close_rsrc (SF_PRIVATE *psf)
-{
- if (psf->hrsrc != NULL)
- psf_close_handle (psf->hrsrc) ;
- psf->hrsrc = NULL ;
+{ psf_close_handle (psf->rsrc.handle) ;
+ psf->rsrc.handle = NULL ;
return 0 ;
} /* psf_close_rsrc */
/* USE_WINDOWS_API */ int
-psf_set_stdio (SF_PRIVATE *psf, int mode)
+psf_set_stdio (SF_PRIVATE *psf)
{ HANDLE handle = NULL ;
int error = 0 ;
- switch (mode)
+ switch (psf->file.mode)
{ case SFM_RDWR :
error = SFE_OPEN_PIPE_RDWR ;
break ;
case SFM_READ :
handle = GetStdHandle (STD_INPUT_HANDLE) ;
- psf->do_not_close_descriptor = 1 ;
+ psf->file.do_not_close_descriptor = 1 ;
break ;
case SFM_WRITE :
handle = GetStdHandle (STD_OUTPUT_HANDLE) ;
- psf->do_not_close_descriptor = 1 ;
+ psf->file.do_not_close_descriptor = 1 ;
break ;
default :
@@ -849,7 +867,7 @@ psf_set_stdio (SF_PRIVATE *psf, int mode)
break ;
} ;
- psf->hfile = handle ;
+ psf->file.handle = handle ;
psf->filelength = 0 ;
return error ;
@@ -863,14 +881,14 @@ psf_set_file (SF_PRIVATE *psf, int fd)
osfhandle = _get_osfhandle (fd) ;
handle = (HANDLE) osfhandle ;
- psf->hfile = handle ;
+ psf->file.handle = handle ;
} /* psf_set_file */
/* USE_WINDOWS_API */ int
psf_file_valid (SF_PRIVATE *psf)
-{ if (psf->hfile == NULL)
+{ if (psf->file.handle == NULL)
return SF_FALSE ;
- if (psf->hfile == INVALID_HANDLE_VALUE)
+ if (psf->file.handle == INVALID_HANDLE_VALUE)
return SF_FALSE ;
return SF_TRUE ;
} /* psf_set_file */
@@ -903,7 +921,7 @@ psf_fseek (SF_PRIVATE *psf, sf_count_t offset, int whence)
lDistanceToMove = (DWORD) (offset & 0xFFFFFFFF) ;
lDistanceToMoveHigh = (DWORD) ((offset >> 32) & 0xFFFFFFFF) ;
- dwResult = SetFilePointer (psf->hfile, lDistanceToMove, &lDistanceToMoveHigh, dwMoveMethod) ;
+ dwResult = SetFilePointer (psf->file.handle, lDistanceToMove, &lDistanceToMoveHigh, dwMoveMethod) ;
if (dwResult == 0xFFFFFFFF)
dwError = GetLastError () ;
@@ -939,7 +957,7 @@ psf_fread (void *ptr, sf_count_t bytes, sf_count_t items, SF_PRIVATE *psf)
{ /* Break the writes down to a sensible size. */
count = (items > SENSIBLE_SIZE) ? SENSIBLE_SIZE : (ssize_t) items ;
- if (ReadFile (psf->hfile, ((char*) ptr) + total, count, &dwNumberOfBytesRead, 0) == 0)
+ if (ReadFile (psf->file.handle, ((char*) ptr) + total, count, &dwNumberOfBytesRead, 0) == 0)
{ psf_log_syserr (psf, GetLastError ()) ;
break ;
}
@@ -978,7 +996,7 @@ psf_fwrite (const void *ptr, sf_count_t bytes, sf_count_t items, SF_PRIVATE *psf
{ /* Break the writes down to a sensible size. */
count = (items > SENSIBLE_SIZE) ? SENSIBLE_SIZE : (ssize_t) items ;
- if (WriteFile (psf->hfile, ((const char*) ptr) + total, count, &dwNumberOfBytesWritten, 0) == 0)
+ if (WriteFile (psf->file.handle, ((const char*) ptr) + total, count, &dwNumberOfBytesWritten, 0) == 0)
{ psf_log_syserr (psf, GetLastError ()) ;
break ;
}
@@ -1013,7 +1031,7 @@ psf_ftell (SF_PRIVATE *psf)
lDistanceToMoveLow = 0 ;
lDistanceToMoveHigh = 0 ;
- dwResult = SetFilePointer (psf->hfile, lDistanceToMoveLow, &lDistanceToMoveHigh, FILE_CURRENT) ;
+ dwResult = SetFilePointer (psf->file.handle, lDistanceToMoveLow, &lDistanceToMoveHigh, FILE_CURRENT) ;
if (dwResult == 0xFFFFFFFF)
dwError = GetLastError () ;
@@ -1032,7 +1050,10 @@ psf_ftell (SF_PRIVATE *psf)
/* USE_WINDOWS_API */ static int
psf_close_handle (HANDLE handle)
-{ if (CloseHandle (handle) == 0)
+{ if (handle == NULL)
+ return 0 ;
+
+ if (CloseHandle (handle) == 0)
return -1 ;
return 0 ;
@@ -1045,7 +1066,7 @@ psf_fgets (char *buffer, sf_count_t bufsize, SF_PRIVATE *psf)
DWORD dwNumberOfBytesRead ;
while (k < bufsize - 1)
- { if (ReadFile (psf->hfile, &(buffer [k]), 1, &dwNumberOfBytesRead, 0) == 0)
+ { if (ReadFile (psf->file.handle, &(buffer [k]), 1, &dwNumberOfBytesRead, 0) == 0)
{ psf_log_syserr (psf, GetLastError ()) ;
break ;
}
@@ -1068,7 +1089,7 @@ psf_is_pipe (SF_PRIVATE *psf)
if (psf->virtual_io)
return SF_FALSE ;
- if (GetFileType (psf->hfile) == FILE_TYPE_DISK)
+ if (GetFileType (psf->file.handle) == FILE_TYPE_DISK)
return SF_FALSE ;
/* Default to maximum safety. */
@@ -1095,7 +1116,7 @@ psf_get_filelen_handle (HANDLE handle)
/* USE_WINDOWS_API */ void
psf_fsync (SF_PRIVATE *psf)
-{ FlushFileBuffers (psf->hfile) ;
+{ FlushFileBuffers (psf->file.handle) ;
} /* psf_fsync */
@@ -1117,7 +1138,7 @@ psf_ftruncate (SF_PRIVATE *psf, sf_count_t len)
lDistanceToMoveLow = (DWORD) (len & 0xFFFFFFFF) ;
lDistanceToMoveHigh = (DWORD) ((len >> 32) & 0xFFFFFFFF) ;
- dwResult = SetFilePointer (psf->hfile, lDistanceToMoveLow, &lDistanceToMoveHigh, FILE_BEGIN) ;
+ dwResult = SetFilePointer (psf->file.handle, lDistanceToMoveLow, &lDistanceToMoveHigh, FILE_BEGIN) ;
if (dwResult == 0xFFFFFFFF)
dwError = GetLastError () ;
@@ -1132,7 +1153,7 @@ psf_ftruncate (SF_PRIVATE *psf, sf_count_t len)
** which guarantees that the new portion of the file will be zeroed.
** Not sure if this is important or not.
*/
- if (SetEndOfFile (psf->hfile) == 0)
+ if (SetEndOfFile (psf->file.handle) == 0)
{ retval = -1 ;
psf_log_syserr (psf, GetLastError ()) ;
} ;
@@ -1188,14 +1209,14 @@ psf_fopen (SF_PRIVATE *psf, const char *pathname, int open_mode)
} ;
if (mode == 0)
- psf->filedes = open (pathname, oflag) ;
+ psf->file.filedes = open (pathname, oflag) ;
else
- psf->filedes = open (pathname, oflag, mode) ;
+ psf->file.filedes = open (pathname, oflag, mode) ;
- if (psf->filedes == -1)
+ if (psf->file.filedes == -1)
psf_log_syserr (psf, errno) ;
- return psf->filedes ;
+ return psf->file.filedes ;
} /* psf_fopen */
/* Win32 */ sf_count_t
@@ -1211,8 +1232,8 @@ psf_fseek (SF_PRIVATE *psf, sf_count_t offset, int whence)
break ;
case SEEK_END :
- if (psf->mode == SFM_WRITE)
- { new_position = _lseeki64 (psf->filedes, offset, whence) ;
+ if (psf->file.mode == SFM_WRITE)
+ { new_position = _lseeki64 (psf->file.filedes, offset, whence) ;
if (new_position < 0)
psf_log_syserr (psf, errno) ;
@@ -1225,7 +1246,7 @@ psf_fseek (SF_PRIVATE *psf, sf_count_t offset, int whence)
** get the offset wrt the start of file.
*/
whence = SEEK_SET ;
- offset = _lseeki64 (psf->filedes, 0, SEEK_END) + offset ;
+ offset = _lseeki64 (psf->file.filedes, 0, SEEK_END) + offset ;
break ;
default :
@@ -1240,9 +1261,9 @@ psf_fseek (SF_PRIVATE *psf, sf_count_t offset, int whence)
*** Use the _telli64() function instead.
*/
if (offset == 0 && whence == SEEK_CUR)
- new_position = _telli64 (psf->filedes) ;
+ new_position = _telli64 (psf->file.filedes) ;
else
- new_position = _lseeki64 (psf->filedes, offset, whence) ;
+ new_position = _lseeki64 (psf->file.filedes, offset, whence) ;
if (new_position < 0)
psf_log_syserr (psf, errno) ;
@@ -1270,7 +1291,7 @@ psf_fread (void *ptr, sf_count_t bytes, sf_count_t items, SF_PRIVATE *psf)
{ /* Break the writes down to a sensible size. */
count = (items > SENSIBLE_SIZE) ? SENSIBLE_SIZE : (ssize_t) items ;
- count = read (psf->filedes, ((char*) ptr) + total, (size_t) count) ;
+ count = read (psf->file.filedes, ((char*) ptr) + total, (size_t) count) ;
if (count == -1)
{ if (errno == EINTR)
@@ -1308,7 +1329,7 @@ psf_fwrite (const void *ptr, sf_count_t bytes, sf_count_t items, SF_PRIVATE *psf
{ /* Break the writes down to a sensible size. */
count = (items > SENSIBLE_SIZE) ? SENSIBLE_SIZE : items ;
- count = write (psf->filedes, ((const char*) ptr) + total, count) ;
+ count = write (psf->file.filedes, ((const char*) ptr) + total, count) ;
if (count == -1)
{ if (errno == EINTR)
@@ -1335,7 +1356,7 @@ psf_ftell (SF_PRIVATE *psf)
if (psf->virtual_io)
return psf->vio.tell (psf->vio_user_data) ;
- pos = _telli64 (psf->filedes) ;
+ pos = _telli64 (psf->file.filedes) ;
if (pos == ((sf_count_t) -1))
{ psf_log_syserr (psf, errno) ;
@@ -1349,13 +1370,13 @@ psf_ftell (SF_PRIVATE *psf)
psf_fclose (SF_PRIVATE *psf)
{ int retval ;
- while ((retval = close (psf->filedes)) == -1 && errno == EINTR)
+ while ((retval = close (psf->file.filedes)) == -1 && errno == EINTR)
/* Do nothing. */ ;
if (retval == -1)
psf_log_syserr (psf, errno) ;
- psf->filedes = -1 ;
+ psf->file.filedes = -1 ;
return retval ;
} /* psf_fclose */
@@ -1366,7 +1387,7 @@ psf_fgets (char *buffer, sf_count_t bufsize, SF_PRIVATE *psf)
sf_count_t count ;
while (k < bufsize - 1)
- { count = read (psf->filedes, &(buffer [k]), 1) ;
+ { count = read (psf->file.filedes, &(buffer [k]), 1) ;
if (count == -1)
{ if (errno == EINTR)
@@ -1393,7 +1414,7 @@ psf_is_pipe (SF_PRIVATE *psf)
return SF_FALSE ;
/* Not sure if this works. */
- if (fstat (psf->filedes, &statbuf) == -1)
+ if (fstat (psf->file.filedes, &statbuf) == -1)
{ psf_log_syserr (psf, errno) ;
/* Default to maximum safety. */
return SF_TRUE ;
@@ -1417,7 +1438,7 @@ psf_get_filelen (SF_PRIVATE *psf)
*/
struct _stati64 statbuf ;
- if (_fstati64 (psf->filedes, &statbuf))
+ if (_fstati64 (psf->file.filedes, &statbuf))
{ psf_log_syserr (psf, errno) ;
return (sf_count_t) -1 ;
} ;
@@ -1429,7 +1450,7 @@ psf_get_filelen (SF_PRIVATE *psf)
if (psf->virtual_io)
return psf->vio.get_filelen (psf->vio_user_data) ;
- if ((current = _telli64 (psf->filedes)) < 0)
+ if ((current = _telli64 (psf->file.filedes)) < 0)
{ psf_log_syserr (psf, errno) ;
return (sf_count_t) -1 ;
} ;
@@ -1447,17 +1468,17 @@ psf_get_filelen (SF_PRIVATE *psf)
** by libsndfile and changing the license to GPL at the same time.
*/
- _lseeki64 (psf->filedes, 0, SEEK_END) ;
+ _lseeki64 (psf->file.filedes, 0, SEEK_END) ;
- if ((filelen = _lseeki64 (psf->filedes, 0, SEEK_END)) < 0)
+ if ((filelen = _lseeki64 (psf->file.filedes, 0, SEEK_END)) < 0)
{ psf_log_syserr (psf, errno) ;
return (sf_count_t) -1 ;
} ;
if (filelen > current)
- _lseeki64 (psf->filedes, current, SEEK_SET) ;
+ _lseeki64 (psf->file.filedes, current, SEEK_SET) ;
- switch (psf->mode)
+ switch (psf->file.mode)
{ case SFM_WRITE :
filelen = filelen - psf->fileoffset ;
break ;
@@ -1501,7 +1522,7 @@ psf_ftruncate (SF_PRIVATE *psf, sf_count_t len)
if (len > 0x7FFFFFFF)
return -1 ;
- retval = chsize (psf->filedes, len) ;
+ retval = chsize (psf->file.filedes, len) ;
if (retval == -1)
psf_log_syserr (psf, errno) ;
diff --git a/libs/libsndfile/src/flac.c b/libs/libsndfile/src/flac.c
index 9b580156d1..7949b0a948 100644
--- a/libs/libsndfile/src/flac.c
+++ b/libs/libsndfile/src/flac.c
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 2004-2009 Erik de Castro Lopo
+** Copyright (C) 2004-2011 Erik de Castro Lopo
** Copyright (C) 2004 Tobias Gehrig
**
** This program is free software ; you can redistribute it and/or modify
@@ -35,8 +35,6 @@
#include
#include
-#include "sfendian.h"
-
/*------------------------------------------------------------------------------
** Private static functions.
*/
@@ -122,10 +120,6 @@ static FLAC__StreamEncoderSeekStatus sf_flac_enc_seek_callback (const FLAC__Stre
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
-} ;
-
static void
s2flac8_array (const short *src, FLAC__int32 *dest, int count)
{ while (--count >= 0)
@@ -377,7 +371,9 @@ sf_flac_meta_get_vorbiscomments (SF_PRIVATE *psf, const FLAC__StreamMetadata *me
{ "comment", SF_STR_COMMENT },
{ "date", SF_STR_DATE },
{ "album", SF_STR_ALBUM },
- { "license", SF_STR_LICENSE }
+ { "license", SF_STR_LICENSE },
+ { "tracknumber", SF_STR_TRACKNUMBER },
+ { "genre", SF_STR_GENRE }
} ;
const char *value, *cptr ;
@@ -411,7 +407,14 @@ sf_flac_meta_callback (const FLAC__StreamDecoder * UNUSED (decoder), const FLAC_
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) ;
+ psf_log_printf (psf, "FLAC Stream Metadata\n Channels : %d\n Sample rate : %d\n", psf->sf.channels, psf->sf.samplerate) ;
+
+ if (psf->sf.frames == 0)
+ { psf_log_printf (psf, " Frames : 0 (bumping to SF_COUNT_MAX)\n") ;
+ psf->sf.frames = SF_COUNT_MAX ;
+ }
+ else
+ psf_log_printf (psf, " Frames : %D\n", psf->sf.frames) ;
switch (metadata->data.stream_info.bits_per_sample)
{ case 8 :
@@ -571,6 +574,12 @@ flac_write_strings (SF_PRIVATE *psf, FLAC_PRIVATE* pflac)
case SF_STR_LICENSE :
key = "license" ;
break ;
+ case SF_STR_TRACKNUMBER :
+ key = "tracknumber" ;
+ break ;
+ case SF_STR_GENRE :
+ key = "genre" ;
+ break ;
default :
continue ;
} ;
@@ -620,17 +629,17 @@ flac_open (SF_PRIVATE *psf)
FLAC_PRIVATE* pflac = calloc (1, sizeof (FLAC_PRIVATE)) ;
psf->codec_data = pflac ;
- if (psf->mode == SFM_RDWR)
+ if (psf->file.mode == SFM_RDWR)
return SFE_BAD_MODE_RW ;
- if (psf->mode == SFM_READ)
+ if (psf->file.mode == SFM_READ)
{ if ((error = flac_read_header (psf)))
return error ;
} ;
subformat = SF_CODEC (psf->sf.format) ;
- if (psf->mode == SFM_WRITE)
+ if (psf->file.mode == SFM_WRITE)
{ if ((SF_CONTAINER (psf->sf.format)) != SF_FORMAT_FLAC)
return SFE_BAD_OPEN_FORMAT ;
@@ -683,7 +692,7 @@ flac_close (SF_PRIVATE *psf)
if (pflac->metadata != NULL)
FLAC__metadata_object_delete (pflac->metadata) ;
- if (psf->mode == SFM_WRITE)
+ if (psf->file.mode == SFM_WRITE)
{ FLAC__stream_encoder_finish (pflac->fse) ;
FLAC__stream_encoder_delete (pflac->fse) ;
@@ -691,7 +700,7 @@ flac_close (SF_PRIVATE *psf)
free (pflac->encbuffer) ;
} ;
- if (psf->mode == SFM_READ)
+ if (psf->file.mode == SFM_READ)
{ FLAC__stream_decoder_finish (pflac->fsd) ;
FLAC__stream_decoder_delete (pflac->fsd) ;
} ;
@@ -709,17 +718,16 @@ static int
flac_enc_init (SF_PRIVATE *psf)
{ FLAC_PRIVATE* pflac = (FLAC_PRIVATE*) psf->codec_data ;
unsigned bps ;
- int k, found ;
- found = 0 ;
- for (k = 0 ; k < ARRAY_LEN (legal_sample_rates) ; k++)
- if (psf->sf.samplerate == legal_sample_rates [k])
- { found = 1 ;
- break ;
- } ;
-
- if (found == 0)
+ /* To cite the flac FAQ at
+ ** http://flac.sourceforge.net/faq.html#general__samples
+ ** "FLAC supports linear sample rates from 1Hz - 655350Hz in 1Hz
+ ** increments."
+ */
+ if ( psf->sf.samplerate < 1 || psf->sf.samplerate > 655350 )
+ { psf_log_printf (psf, "flac sample rate out of range.\n", psf->sf.samplerate) ;
return SFE_FLAC_BAD_SAMPLE_RATE ;
+ } ;
psf_fseek (psf, 0, SEEK_SET) ;
@@ -796,17 +804,17 @@ flac_command (SF_PRIVATE * UNUSED (psf), int UNUSED (command), void * UNUSED (da
int
flac_init (SF_PRIVATE *psf)
{
- if (psf->mode == SFM_RDWR)
+ if (psf->file.mode == SFM_RDWR)
return SFE_BAD_MODE_RW ;
- if (psf->mode == SFM_READ)
+ if (psf->file.mode == SFM_READ)
{ psf->read_short = flac_read_flac2s ;
psf->read_int = flac_read_flac2i ;
psf->read_float = flac_read_flac2f ;
psf->read_double = flac_read_flac2d ;
} ;
- if (psf->mode == SFM_WRITE)
+ if (psf->file.mode == SFM_WRITE)
{ psf->write_short = flac_write_s2flac ;
psf->write_int = flac_write_i2flac ;
psf->write_float = flac_write_f2flac ;
@@ -1288,7 +1296,7 @@ flac_seek (SF_PRIVATE *psf, int UNUSED (mode), sf_count_t offset)
pflac->frame = NULL ;
- if (psf->mode == SFM_READ)
+ if (psf->file.mode == SFM_READ)
{ FLAC__uint64 position ;
if (FLAC__stream_decoder_seek_absolute (pflac->fsd, offset))
{ FLAC__stream_decoder_get_decode_position (pflac->fsd, &position) ;
diff --git a/libs/libsndfile/src/float32.c b/libs/libsndfile/src/float32.c
index 2ab4450f84..4a87cefc34 100644
--- a/libs/libsndfile/src/float32.c
+++ b/libs/libsndfile/src/float32.c
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 1999-2009 Erik de Castro Lopo
+** Copyright (C) 1999-2011 Erik de Castro Lopo
**
** 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
@@ -92,7 +92,7 @@ float32_init (SF_PRIVATE *psf)
psf->blockwidth = sizeof (float) * psf->sf.channels ;
- if (psf->mode == SFM_READ || psf->mode == SFM_RDWR)
+ if (psf->file.mode == SFM_READ || psf->file.mode == SFM_RDWR)
{ switch (psf->endian + float_caps)
{ case (SF_ENDIAN_BIG + FLOAT_CAN_RW_BE) :
psf->data_endswap = SF_FALSE ;
@@ -163,7 +163,7 @@ float32_init (SF_PRIVATE *psf)
} ;
} ;
- if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR)
+ if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR)
{ switch (psf->endian + float_caps)
{ case (SF_ENDIAN_LITTLE + FLOAT_CAN_RW_LE) :
psf->data_endswap = SF_FALSE ;
@@ -241,7 +241,7 @@ float32_init (SF_PRIVATE *psf)
else
psf->datalength = 0 ;
- psf->sf.frames = psf->datalength / psf->blockwidth ;
+ psf->sf.frames = psf->blockwidth > 0 ? psf->datalength / psf->blockwidth : 0 ;
return 0 ;
} /* float32_init */
@@ -444,7 +444,7 @@ f2s_clip_array (const float *src, int count, short *dest, float scale)
if (CPU_CLIPS_POSITIVE == 0 && tmp > 32767.0)
dest [count] = SHRT_MAX ;
- else if (CPU_CLIPS_NEGATIVE == 0 && tmp < 32768.0)
+ else if (CPU_CLIPS_NEGATIVE == 0 && tmp < -32768.0)
dest [count] = SHRT_MIN ;
else
dest [count] = lrintf (tmp) ;
@@ -523,7 +523,7 @@ host_read_f2s (SF_PRIVATE *psf, short *ptr, sf_count_t len)
if (psf->data_endswap == SF_TRUE)
endswap_int_array (psf->u.ibuf, bufferlen) ;
- f2s_array (psf->u.fbuf, readcount, ptr + total, scale) ;
+ convert (psf->u.fbuf, readcount, ptr + total, scale) ;
total += readcount ;
if (readcount < bufferlen)
break ;
diff --git a/libs/libsndfile/src/float_cast.h b/libs/libsndfile/src/float_cast.h
deleted file mode 100644
index 2c06aaf233..0000000000
--- a/libs/libsndfile/src/float_cast.h
+++ /dev/null
@@ -1,271 +0,0 @@
-/*
-** Copyright (C) 2001-2004 Erik de Castro Lopo
-**
-** 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.
-*/
-
-/* Version 1.4 */
-
-#ifndef FLOAT_CAST_HEADER
-#define FLOAT_CAST_HEADER
-
-/*============================================================================
-** On Intel Pentium processors (especially PIII and probably P4), converting
-** from float to int is very slow. To meet the C specs, the code produced by
-** most C compilers targeting Pentium needs to change the FPU rounding mode
-** before the float to int conversion is performed.
-**
-** Changing the FPU rounding mode causes the FPU pipeline to be flushed. It
-** is this flushing of the pipeline which is so slow.
-**
-** Fortunately the ISO C99 specifications define the functions lrint, lrintf,
-** llrint and llrintf which fix this problem as a side effect.
-**
-** On Unix-like systems, the configure process should have detected the
-** presence of these functions. If they weren't found we have to replace them
-** here with a standard C cast.
-*/
-
-/*
-** The C99 prototypes for lrint and lrintf are as follows:
-**
-** long int lrintf (float x) ;
-** long int lrint (double x) ;
-*/
-
-#include "sfconfig.h"
-
-/*
-** The presence of the required functions are detected during the configure
-** process and the values HAVE_LRINT and HAVE_LRINTF are set accordingly in
-** the sfconfig.h file.
-*/
-
-#define HAVE_LRINT_REPLACEMENT 0
-
-#if (HAVE_LRINT && HAVE_LRINTF)
-
- /*
- ** These defines enable functionality introduced with the 1999 ISO C
- ** standard. They must be defined before the inclusion of math.h to
- ** engage them. If optimisation is enabled, these functions will be
- ** inlined. With optimisation switched off, you have to link in the
- ** maths library using -lm.
- */
-
- #define _ISOC9X_SOURCE 1
- #define _ISOC99_SOURCE 1
-
- #define __USE_ISOC9X 1
- #define __USE_ISOC99 1
-
- #include
-
-#elif (defined (__CYGWIN__))
-
- #include
-
- #undef HAVE_LRINT_REPLACEMENT
- #define HAVE_LRINT_REPLACEMENT 1
-
- #undef lrint
- #undef lrintf
-
- #define lrint double2int
- #define lrintf float2int
-
- /*
- ** The native CYGWIN lrint and lrintf functions are buggy:
- ** http://sourceware.org/ml/cygwin/2005-06/msg00153.html
- ** http://sourceware.org/ml/cygwin/2005-09/msg00047.html
- ** and slow.
- ** These functions (pulled from the Public Domain MinGW math.h header)
- ** replace the native versions.
- */
-
- static inline long double2int (double in)
- { long retval ;
-
- __asm__ __volatile__
- ( "fistpl %0"
- : "=m" (retval)
- : "t" (in)
- : "st"
- ) ;
-
- return retval ;
- } /* double2int */
-
- static inline long float2int (float in)
- { long retval ;
-
- __asm__ __volatile__
- ( "fistpl %0"
- : "=m" (retval)
- : "t" (in)
- : "st"
- ) ;
-
- return retval ;
- } /* float2int */
-
-#elif (defined (WIN32) || defined (_WIN32)) && !defined(_WIN64)
-
- #undef HAVE_LRINT_REPLACEMENT
- #define HAVE_LRINT_REPLACEMENT 1
-
- #include
-
- /*
- ** Win32 doesn't seem to have these functions.
- ** Therefore implement inline versions of these functions here.
- */
-
- __inline long int
- lrint (double flt)
- { int intgr ;
-
- _asm
- { fld flt
- fistp intgr
- } ;
-
- return intgr ;
- }
-
- __inline long int
- lrintf (float flt)
- { int intgr ;
-
- _asm
- { fld flt
- fistp intgr
- } ;
-
- return intgr ;
- }
-
-#elif defined(_WIN64)
- __inline long int lrint(double x)
- {
- return (long int) (x);
- }
- __inline long int lrintf(float x)
- {
- return (long int) (x);
- }
-#elif (defined (__MWERKS__) && defined (macintosh))
-
- /* This MacOS 9 solution was provided by Stephane Letz */
-
- #undef HAVE_LRINT_REPLACEMENT
- #define HAVE_LRINT_REPLACEMENT 1
- #include
-
- #undef lrint
- #undef lrintf
-
- #define lrint double2int
- #define lrintf float2int
-
- inline int
- float2int (register float in)
- { long res [2] ;
-
- asm
- { fctiw in, in
- stfd in, res
- }
- return res [1] ;
- } /* float2int */
-
- inline int
- double2int (register double in)
- { long res [2] ;
-
- asm
- { fctiw in, in
- stfd in, res
- }
- return res [1] ;
- } /* double2int */
-
-#elif (defined (__MACH__) && defined (__APPLE__))
-
- /* For Apple MacOSX. */
-
- #undef HAVE_LRINT_REPLACEMENT
- #define HAVE_LRINT_REPLACEMENT 1
- #include
-
- #undef lrint
- #undef lrintf
-
- #define lrint double2int
- #define lrintf float2int
-
- inline static long
- float2int (register float in)
- { int res [2] ;
-
- __asm__ __volatile__
- ( "fctiw %1, %1\n\t"
- "stfd %1, %0"
- : "=m" (res) /* Output */
- : "f" (in) /* Input */
- : "memory"
- ) ;
-
- return res [1] ;
- } /* lrintf */
-
- inline static long
- double2int (register double in)
- { int res [2] ;
-
- __asm__ __volatile__
- ( "fctiw %1, %1\n\t"
- "stfd %1, %0"
- : "=m" (res) /* Output */
- : "f" (in) /* Input */
- : "memory"
- ) ;
-
- return res [1] ;
- } /* lrint */
-
-#else
- #ifndef __sgi
- #warning "Don't have the functions lrint() and lrintf()."
- #warning "Replacing these functions with a standard C cast."
- #endif
-
- #include
-
- #define lrint(dbl) ((long) (dbl))
- #define lrintf(flt) ((long) (flt))
-
-#endif
-
-
-#endif /* FLOAT_CAST_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: 42db1693-ff61-4051-bac1-e4d24c4e30b7
-*/
diff --git a/libs/libsndfile/src/g72x.c b/libs/libsndfile/src/g72x.c
index a6b5fffde2..99729d3412 100644
--- a/libs/libsndfile/src/g72x.c
+++ b/libs/libsndfile/src/g72x.c
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 1999-2009 Erik de Castro Lopo
+** Copyright (C) 1999-2011 Erik de Castro Lopo
**
** 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
@@ -122,7 +122,7 @@ g72x_init (SF_PRIVATE * psf)
if (psf->dataend > 0)
psf->datalength -= psf->filelength - psf->dataend ;
- if (psf->mode == SFM_READ)
+ if (psf->file.mode == SFM_READ)
{ pg72x->private = g72x_reader_init (codec, &(pg72x->blocksize), &(pg72x->samplesperblock)) ;
if (pg72x->private == NULL)
return SFE_MALLOC_FAILED ;
@@ -147,7 +147,7 @@ g72x_init (SF_PRIVATE * psf)
psf_g72x_decode_block (psf, pg72x) ;
}
- else if (psf->mode == SFM_WRITE)
+ else if (psf->file.mode == SFM_WRITE)
{ pg72x->private = g72x_writer_init (codec, &(pg72x->blocksize), &(pg72x->samplesperblock)) ;
if (pg72x->private == NULL)
return SFE_MALLOC_FAILED ;
@@ -401,7 +401,7 @@ g72x_seek (SF_PRIVATE *psf, int UNUSED (mode), sf_count_t UNUSED (offset))
** return PSF_SEEK_ERROR ;
** } ;
**
-** if (psf->mode == SFM_READ)
+** if (psf->file.mode == SFM_READ)
** { psf_fseek (psf, psf->dataoffset + newblock * pg72x->blocksize, SEEK_SET) ;
** pg72x->block_curr = newblock ;
** psf_g72x_decode_block (psf, pg72x) ;
@@ -584,7 +584,7 @@ g72x_close (SF_PRIVATE *psf)
pg72x = (G72x_PRIVATE*) psf->codec_data ;
- if (psf->mode == SFM_WRITE)
+ if (psf->file.mode == SFM_WRITE)
{ /* If a block has been partially assembled, write it out
** as the final block.
*/
diff --git a/libs/libsndfile/src/gsm610.c b/libs/libsndfile/src/gsm610.c
index a459cb1e04..b16594ec81 100644
--- a/libs/libsndfile/src/gsm610.c
+++ b/libs/libsndfile/src/gsm610.c
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 1999-2009 Erik de Castro Lopo
+** Copyright (C) 1999-2011 Erik de Castro Lopo
**
** 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
@@ -84,7 +84,7 @@ gsm610_init (SF_PRIVATE *psf)
return SFE_INTERNAL ;
} ;
- if (psf->mode == SFM_RDWR)
+ if (psf->file.mode == SFM_RDWR)
return SFE_BAD_MODE_RW ;
psf->sf.seekable = SF_FALSE ;
@@ -132,7 +132,7 @@ Need separate gsm_data structs for encode and decode.
break ;
} ;
- if (psf->mode == SFM_READ)
+ if (psf->file.mode == SFM_READ)
{ if (psf->datalength % pgsm610->blocksize == 0)
pgsm610->blocks = psf->datalength / pgsm610->blocksize ;
else if (psf->datalength % pgsm610->blocksize == 1 && pgsm610->blocksize == GSM610_BLOCKSIZE)
@@ -162,7 +162,7 @@ Need separate gsm_data structs for encode and decode.
psf->read_double = gsm610_read_d ;
} ;
- if (psf->mode == SFM_WRITE)
+ if (psf->file.mode == SFM_WRITE)
{ pgsm610->blockcount = 0 ;
pgsm610->samplecount = 0 ;
@@ -406,7 +406,7 @@ gsm610_seek (SF_PRIVATE *psf, int UNUSED (mode), sf_count_t offset)
newblock = offset / pgsm610->samplesperblock ;
newsample = offset % pgsm610->samplesperblock ;
- if (psf->mode == SFM_READ)
+ if (psf->file.mode == SFM_READ)
{ if (psf->read_current != newblock * pgsm610->samplesperblock + newsample)
{ psf_fseek (psf, psf->dataoffset + newblock * pgsm610->samplesperblock, SEEK_SET) ;
pgsm610->blockcount = newblock ;
@@ -604,7 +604,7 @@ gsm610_close (SF_PRIVATE *psf)
pgsm610 = (GSM610_PRIVATE*) psf->codec_data ;
- if (psf->mode == SFM_WRITE)
+ if (psf->file.mode == SFM_WRITE)
{ /* If a block has been partially assembled, write it out
** as the final block.
*/
diff --git a/libs/libsndfile/src/htk.c b/libs/libsndfile/src/htk.c
index c503042804..25390f1dc1 100644
--- a/libs/libsndfile/src/htk.c
+++ b/libs/libsndfile/src/htk.c
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 2002-2009 Erik de Castro Lopo
+** Copyright (C) 2002-2011 Erik de Castro Lopo
**
** 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
@@ -55,14 +55,14 @@ htk_open (SF_PRIVATE *psf)
if (psf->is_pipe)
return SFE_HTK_NO_PIPE ;
- if (psf->mode == SFM_READ || (psf->mode == SFM_RDWR && psf->filelength > 0))
+ if (psf->file.mode == SFM_READ || (psf->file.mode == SFM_RDWR && psf->filelength > 0))
{ if ((error = htk_read_header (psf)))
return error ;
} ;
subformat = SF_CODEC (psf->sf.format) ;
- if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR)
+ if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR)
{ if ((SF_CONTAINER (psf->sf.format)) != SF_FORMAT_HTK)
return SFE_BAD_OPEN_FORMAT ;
@@ -95,7 +95,7 @@ htk_open (SF_PRIVATE *psf)
static int
htk_close (SF_PRIVATE *psf)
{
- if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR)
+ if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR)
htk_write_header (psf, SF_TRUE) ;
return 0 ;
@@ -195,10 +195,17 @@ htk_read_header (SF_PRIVATE *psf)
return SFE_HTK_NOT_WAVEFORM ;
psf->sf.channels = 1 ;
- psf->sf.samplerate = 10000000 / sample_period ;
- psf_log_printf (psf, "HTK Waveform file\n Sample Count : %d\n Sample Period : %d => %d Hz\n",
- sample_count, sample_period, psf->sf.samplerate) ;
+ if (sample_period > 0)
+ { psf->sf.samplerate = 10000000 / sample_period ;
+ psf_log_printf (psf, "HTK Waveform file\n Sample Count : %d\n Sample Period : %d => %d Hz\n",
+ sample_count, sample_period, psf->sf.samplerate) ;
+ }
+ else
+ { psf->sf.samplerate = 16000 ;
+ psf_log_printf (psf, "HTK Waveform file\n Sample Count : %d\n Sample Period : %d (should be > 0) => Guessed sample rate %d Hz\n",
+ sample_count, sample_period, psf->sf.samplerate) ;
+ } ;
psf->sf.format = SF_FORMAT_HTK | SF_FORMAT_PCM_16 ;
psf->bytewidth = 2 ;
diff --git a/libs/libsndfile/src/ima_adpcm.c b/libs/libsndfile/src/ima_adpcm.c
index a9bd6ef521..b0763ea9e3 100644
--- a/libs/libsndfile/src/ima_adpcm.c
+++ b/libs/libsndfile/src/ima_adpcm.c
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 1999-2009 Erik de Castro Lopo
+** Copyright (C) 1999-2011 Erik de Castro Lopo
**
** 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
@@ -116,14 +116,14 @@ wav_w64_ima_init (SF_PRIVATE *psf, int blockalign, int samplesperblock)
return SFE_INTERNAL ;
} ;
- if (psf->mode == SFM_RDWR)
+ if (psf->file.mode == SFM_RDWR)
return SFE_BAD_MODE_RW ;
- if (psf->mode == SFM_READ)
+ if (psf->file.mode == SFM_READ)
if ((error = ima_reader_init (psf, blockalign, samplesperblock)))
return error ;
- if (psf->mode == SFM_WRITE)
+ if (psf->file.mode == SFM_WRITE)
if ((error = ima_writer_init (psf, blockalign)))
return error ;
@@ -137,14 +137,14 @@ int
aiff_ima_init (SF_PRIVATE *psf, int blockalign, int samplesperblock)
{ int error ;
- if (psf->mode == SFM_RDWR)
+ if (psf->file.mode == SFM_RDWR)
return SFE_BAD_MODE_RW ;
- if (psf->mode == SFM_READ)
+ if (psf->file.mode == SFM_READ)
if ((error = ima_reader_init (psf, blockalign, samplesperblock)))
return error ;
- if (psf->mode == SFM_WRITE)
+ if (psf->file.mode == SFM_WRITE)
if ((error = ima_writer_init (psf, blockalign)))
return error ;
@@ -159,7 +159,7 @@ ima_close (SF_PRIVATE *psf)
pima = (IMA_ADPCM_PRIVATE*) psf->codec_data ;
- if (psf->mode == SFM_WRITE)
+ if (psf->file.mode == SFM_WRITE)
{ /* If a block has been partially assembled, write it out
** as the final block.
*/
@@ -181,18 +181,16 @@ ima_reader_init (SF_PRIVATE *psf, int blockalign, int samplesperblock)
{ IMA_ADPCM_PRIVATE *pima ;
int pimasize, count ;
- if (psf->mode != SFM_READ)
+ if (psf->file.mode != SFM_READ)
return SFE_BAD_MODE_RW ;
pimasize = sizeof (IMA_ADPCM_PRIVATE) + blockalign * psf->sf.channels + 3 * psf->sf.channels * samplesperblock ;
- if (! (pima = malloc (pimasize)))
+ if (! (pima = calloc (1, pimasize)))
return SFE_MALLOC_FAILED ;
psf->codec_data = (void*) pima ;
- memset (pima, 0, pimasize) ;
-
pima->samples = pima->data ;
pima->block = (unsigned char*) (pima->data + samplesperblock * psf->sf.channels) ;
@@ -238,7 +236,6 @@ ima_reader_init (SF_PRIVATE *psf, int blockalign, int samplesperblock)
default :
psf_log_printf (psf, "ima_reader_init: bad psf->sf.format\n") ;
return SFE_INTERNAL ;
- break ;
} ;
pima->decode_block (psf, pima) ; /* Read first block. */
@@ -254,8 +251,8 @@ ima_reader_init (SF_PRIVATE *psf, int blockalign, int samplesperblock)
static int
aiff_ima_decode_block (SF_PRIVATE *psf, IMA_ADPCM_PRIVATE *pima)
{ unsigned char *blockdata ;
- int chan, k, diff, bytecode ;
- short step, stepindx, predictor, *sampledata ;
+ int chan, k, diff, bytecode, predictor ;
+ short step, stepindx, *sampledata ;
static int count = 0 ;
count ++ ;
@@ -307,6 +304,11 @@ count ++ ;
if (bytecode & 8) diff = -diff ;
predictor += diff ;
+ if (predictor < -32768)
+ predictor = -32768 ;
+ else if (predictor > 32767)
+ predictor = 32767 ;
+
pima->samples [pima->channels * k + chan] = predictor ;
} ;
} ;
@@ -376,7 +378,7 @@ aiff_ima_encode_block (SF_PRIVATE *psf, IMA_ADPCM_PRIVATE *pima)
{ blockindx = chan * pima->blocksize + 2 + indx / 2 ;
pima->block [blockindx] = pima->samples [indx] & 0x0F ;
- pima->block [blockindx] |= (pima->samples [indx + pima->channels] << 4) & 0xF0 ;
+ pima->block [blockindx] |= (pima->samples [indx + chan] << 4) & 0xF0 ;
} ;
} ;
@@ -394,7 +396,7 @@ aiff_ima_encode_block (SF_PRIVATE *psf, IMA_ADPCM_PRIVATE *pima)
static int
wav_w64_ima_decode_block (SF_PRIVATE *psf, IMA_ADPCM_PRIVATE *pima)
-{ int chan, k, current, blockindx, indx, indxstart, diff ;
+{ int chan, k, predictor, blockindx, indx, indxstart, diff ;
short step, bytecode, stepindx [2] ;
pima->blockcount ++ ;
@@ -411,9 +413,9 @@ wav_w64_ima_decode_block (SF_PRIVATE *psf, IMA_ADPCM_PRIVATE *pima)
/* Read and check the block header. */
for (chan = 0 ; chan < pima->channels ; chan++)
- { current = pima->block [chan*4] | (pima->block [chan*4+1] << 8) ;
- if (current & 0x8000)
- current -= 0x10000 ;
+ { predictor = pima->block [chan*4] | (pima->block [chan*4+1] << 8) ;
+ if (predictor & 0x8000)
+ predictor -= 0x10000 ;
stepindx [chan] = pima->block [chan*4+2] ;
stepindx [chan] = clamp_ima_step_index (stepindx [chan]) ;
@@ -422,7 +424,7 @@ wav_w64_ima_decode_block (SF_PRIVATE *psf, IMA_ADPCM_PRIVATE *pima)
if (pima->block [chan*4+3] != 0)
psf_log_printf (psf, "IMA ADPCM synchronisation error.\n") ;
- pima->samples [chan] = current ;
+ pima->samples [chan] = predictor ;
} ;
/*
@@ -455,7 +457,7 @@ wav_w64_ima_decode_block (SF_PRIVATE *psf, IMA_ADPCM_PRIVATE *pima)
bytecode = pima->samples [k] & 0xF ;
step = ima_step_size [stepindx [chan]] ;
- current = pima->samples [k - pima->channels] ;
+ predictor = pima->samples [k - pima->channels] ;
diff = step >> 3 ;
if (bytecode & 1)
@@ -467,17 +469,17 @@ wav_w64_ima_decode_block (SF_PRIVATE *psf, IMA_ADPCM_PRIVATE *pima)
if (bytecode & 8)
diff = -diff ;
- current += diff ;
+ predictor += diff ;
- if (current > 32767)
- current = 32767 ;
- else if (current < -32768)
- current = -32768 ;
+ if (predictor > 32767)
+ predictor = 32767 ;
+ else if (predictor < -32768)
+ predictor = -32768 ;
stepindx [chan] += ima_indx_adjust [bytecode] ;
stepindx [chan] = clamp_ima_step_index (stepindx [chan]) ;
- pima->samples [k] = current ;
+ pima->samples [k] = predictor ;
} ;
return 1 ;
@@ -762,7 +764,7 @@ ima_writer_init (SF_PRIVATE *psf, int blockalign)
int samplesperblock ;
unsigned int pimasize ;
- if (psf->mode != SFM_WRITE)
+ if (psf->file.mode != SFM_WRITE)
return SFE_BAD_MODE_RW ;
samplesperblock = 2 * (blockalign - 4 * psf->sf.channels) / psf->sf.channels + 1 ;
@@ -796,7 +798,6 @@ ima_writer_init (SF_PRIVATE *psf, int blockalign)
default :
psf_log_printf (psf, "ima_reader_init: bad psf->sf.format\n") ;
return SFE_INTERNAL ;
- break ;
} ;
psf->write_short = ima_write_s ;
diff --git a/libs/libsndfile/src/ima_oki_adpcm.c b/libs/libsndfile/src/ima_oki_adpcm.c
index ca943c9b90..399d2e4ace 100644
--- a/libs/libsndfile/src/ima_oki_adpcm.c
+++ b/libs/libsndfile/src/ima_oki_adpcm.c
@@ -1,6 +1,6 @@
/*
+** Copyright (C) 2007-2011 Erik de Castro Lopo
** Copyright (c) 2007
-** Copyright (C) 2007-2009 Erik de Castro Lopo
**
** 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
@@ -19,6 +19,8 @@
/* ADPCM: IMA, OKI <==> 16-bit PCM. */
+#include "sfconfig.h"
+
#include
/* Set up for libsndfile environment: */
@@ -137,7 +139,7 @@ ima_oki_adpcm_encode_block (IMA_OKI_ADPCM * state)
/*
** 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.
*/
diff --git a/libs/libsndfile/src/ima_oki_adpcm.h b/libs/libsndfile/src/ima_oki_adpcm.h
index 52d348647f..86241e7a2c 100644
--- a/libs/libsndfile/src/ima_oki_adpcm.h
+++ b/libs/libsndfile/src/ima_oki_adpcm.h
@@ -1,6 +1,6 @@
/*
+** Copyright (C) 2007-2011 Erik de Castro Lopo
** Copyright (c) 2007
-** Copyright (C) 2007-2009 Erik de Castro Lopo
**
** 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
diff --git a/libs/libsndfile/src/interleave.c b/libs/libsndfile/src/interleave.c
index 30578ba24f..ca9d7b4097 100644
--- a/libs/libsndfile/src/interleave.c
+++ b/libs/libsndfile/src/interleave.c
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 2002-2009 Erik de Castro Lopo
+** Copyright (C) 2002-2011 Erik de Castro Lopo
**
** 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
@@ -53,7 +53,7 @@ int
interleave_init (SF_PRIVATE *psf)
{ INTERLEAVE_DATA *pdata ;
- if (psf->mode != SFM_READ)
+ if (psf->file.mode != SFM_READ)
return SFE_INTERLEAVE_MODE ;
if (psf->interleave)
diff --git a/libs/libsndfile/src/ircam.c b/libs/libsndfile/src/ircam.c
index 4bae7015bd..4aa1173abb 100644
--- a/libs/libsndfile/src/ircam.c
+++ b/libs/libsndfile/src/ircam.c
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 2001-2009 Erik de Castro Lopo
+** Copyright (C) 2001-2011 Erik de Castro Lopo
**
** 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
@@ -80,14 +80,14 @@ ircam_open (SF_PRIVATE *psf)
{ int subformat ;
int error = SFE_NO_ERROR ;
- if (psf->mode == SFM_READ || (psf->mode == SFM_RDWR && psf->filelength > 0))
+ if (psf->file.mode == SFM_READ || (psf->file.mode == SFM_RDWR && psf->filelength > 0))
{ if ((error = ircam_read_header (psf)))
return error ;
} ;
subformat = SF_CODEC (psf->sf.format) ;
- if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR)
+ if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR)
{ if ((SF_CONTAINER (psf->sf.format)) != SF_FORMAT_IRCAM)
return SFE_BAD_OPEN_FORMAT ;
diff --git a/libs/libsndfile/src/libsndfile-1.def b/libs/libsndfile/src/libsndfile-1.def
index 7b144538fc..93cab02d98 100644
--- a/libs/libsndfile/src/libsndfile-1.def
+++ b/libs/libsndfile/src/libsndfile-1.def
@@ -33,7 +33,9 @@ sf_write_double @40
sf_strerror @50
sf_get_string @60
sf_set_string @61
+sf_version_string @68
sf_open_fd @70
+sf_wchar_open @71
sf_open_virtual @80
sf_write_sync @90
diff --git a/libs/libsndfile/src/libsndfile.def b/libs/libsndfile/src/libsndfile.def
deleted file mode 100644
index 7b144538fc..0000000000
--- a/libs/libsndfile/src/libsndfile.def
+++ /dev/null
@@ -1,39 +0,0 @@
-; 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
-
diff --git a/libs/libsndfile/src/macbinary3.c b/libs/libsndfile/src/macbinary3.c
index d9b1ad43a4..184cc18fcd 100644
--- a/libs/libsndfile/src/macbinary3.c
+++ b/libs/libsndfile/src/macbinary3.c
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 2003-2009 Erik de Castro Lopo
+** Copyright (C) 2003-2011 Erik de Castro Lopo
**
** 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
diff --git a/libs/libsndfile/src/macos.c b/libs/libsndfile/src/macos.c
index cbedb890cf..5f6c53191c 100644
--- a/libs/libsndfile/src/macos.c
+++ b/libs/libsndfile/src/macos.c
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 2003-2009 Erik de Castro Lopo
+** Copyright (C) 2003-2011 Erik de Castro Lopo
**
** 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
diff --git a/libs/libsndfile/src/mat4.c b/libs/libsndfile/src/mat4.c
index a4919a4668..3471e34c0c 100644
--- a/libs/libsndfile/src/mat4.c
+++ b/libs/libsndfile/src/mat4.c
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 2002-2009 Erik de Castro Lopo
+** Copyright (C) 2002-2011 Erik de Castro Lopo
**
** 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
@@ -76,7 +76,7 @@ int
mat4_open (SF_PRIVATE *psf)
{ int subformat, error = 0 ;
- if (psf->mode == SFM_READ || (psf->mode == SFM_RDWR && psf->filelength > 0))
+ if (psf->file.mode == SFM_READ || (psf->file.mode == SFM_RDWR && psf->filelength > 0))
{ if ((error = mat4_read_header (psf)))
return error ;
} ;
@@ -86,7 +86,7 @@ mat4_open (SF_PRIVATE *psf)
subformat = SF_CODEC (psf->sf.format) ;
- if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR)
+ if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR)
{ if (psf->is_pipe)
return SFE_NO_PIPE_WRITE ;
@@ -135,7 +135,7 @@ mat4_open (SF_PRIVATE *psf)
static int
mat4_close (SF_PRIVATE *psf)
{
- if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR)
+ if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR)
mat4_write_header (psf, SF_TRUE) ;
return 0 ;
diff --git a/libs/libsndfile/src/mat5.c b/libs/libsndfile/src/mat5.c
index 40ffe0a73f..338477e07a 100644
--- a/libs/libsndfile/src/mat5.c
+++ b/libs/libsndfile/src/mat5.c
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 2002-2009 Erik de Castro Lopo
+** Copyright (C) 2002-2011 Erik de Castro Lopo
**
** 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
@@ -86,7 +86,7 @@ int
mat5_open (SF_PRIVATE *psf)
{ int subformat, error = 0 ;
- if (psf->mode == SFM_READ || (psf->mode == SFM_RDWR && psf->filelength > 0))
+ if (psf->file.mode == SFM_READ || (psf->file.mode == SFM_RDWR && psf->filelength > 0))
{ if ((error = mat5_read_header (psf)))
return error ;
} ;
@@ -96,7 +96,7 @@ mat5_open (SF_PRIVATE *psf)
subformat = SF_CODEC (psf->sf.format) ;
- if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR)
+ if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR)
{ if (psf->is_pipe)
return SFE_NO_PIPE_WRITE ;
@@ -143,7 +143,7 @@ mat5_open (SF_PRIVATE *psf)
static int
mat5_close (SF_PRIVATE *psf)
{
- if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR)
+ if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR)
mat5_write_header (psf, SF_TRUE) ;
return 0 ;
diff --git a/libs/libsndfile/src/mpc2k.c b/libs/libsndfile/src/mpc2k.c
index ad782ed6e0..0170f7ccfb 100644
--- a/libs/libsndfile/src/mpc2k.c
+++ b/libs/libsndfile/src/mpc2k.c
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 2008-2009 Erik de Castro Lopo
+** Copyright (C) 2008-2011 Erik de Castro Lopo
**
** 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
@@ -38,7 +38,7 @@
** 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
*/
@@ -63,10 +63,9 @@ static int mpc2k_read_header (SF_PRIVATE *psf) ;
int
mpc2k_open (SF_PRIVATE *psf)
-{ int subformat ;
- int error = 0 ;
+{ int error = 0 ;
- if (psf->mode == SFM_READ || (psf->mode == SFM_RDWR && psf->filelength > 0))
+ if (psf->file.mode == SFM_READ || (psf->file.mode == SFM_RDWR && psf->filelength > 0))
{ if ((error = mpc2k_read_header (psf)))
return error ;
} ;
@@ -74,9 +73,7 @@ mpc2k_open (SF_PRIVATE *psf)
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 (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR)
{ if (mpc2k_write_header (psf, SF_FALSE))
return psf->error ;
@@ -98,7 +95,7 @@ mpc2k_open (SF_PRIVATE *psf)
static int
mpc2k_close (SF_PRIVATE *psf)
{
- if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR)
+ if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR)
mpc2k_write_header (psf, SF_TRUE) ;
return 0 ;
@@ -134,7 +131,7 @@ mpc2k_write_header (SF_PRIVATE *psf, int calc_length)
if (psf->is_pipe == SF_FALSE)
psf_fseek (psf, 0, SEEK_SET) ;
- snprintf (sample_name, sizeof (sample_name), "%s ", psf->filename) ;
+ snprintf (sample_name, sizeof (sample_name), "%s ", psf->file.name.c) ;
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) ;
diff --git a/libs/libsndfile/src/ms_adpcm.c b/libs/libsndfile/src/ms_adpcm.c
index f276c602c1..7d04f85b95 100644
--- a/libs/libsndfile/src/ms_adpcm.c
+++ b/libs/libsndfile/src/ms_adpcm.c
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 1999-2009 Erik de Castro Lopo
+** Copyright (C) 1999-2011 Erik de Castro Lopo
**
** 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
@@ -137,15 +137,14 @@ wav_w64_msadpcm_init (SF_PRIVATE *psf, int blockalign, int samplesperblock)
return SFE_INTERNAL ;
} ;
- if (psf->mode == SFM_WRITE)
+ if (psf->file.mode == SFM_WRITE)
samplesperblock = 2 + 2 * (blockalign - 7 * psf->sf.channels) / psf->sf.channels ;
pmssize = sizeof (MSADPCM_PRIVATE) + blockalign + 3 * psf->sf.channels * samplesperblock ;
- if (! (psf->codec_data = malloc (pmssize)))
+ if (! (psf->codec_data = calloc (1, pmssize)))
return SFE_MALLOC_FAILED ;
pms = (MSADPCM_PRIVATE*) psf->codec_data ;
- memset (pms, 0, pmssize) ;
pms->samples = pms->dummydata ;
pms->block = (unsigned char*) (pms->dummydata + psf->sf.channels * samplesperblock) ;
@@ -159,7 +158,7 @@ wav_w64_msadpcm_init (SF_PRIVATE *psf, int blockalign, int samplesperblock)
return SFE_INTERNAL ;
} ;
- if (psf->mode == SFM_READ)
+ if (psf->file.mode == SFM_READ)
{ pms->dataremaining = psf->datalength ;
if (psf->datalength % pms->blocksize)
@@ -185,7 +184,7 @@ wav_w64_msadpcm_init (SF_PRIVATE *psf, int blockalign, int samplesperblock)
psf->read_double = msadpcm_read_d ;
} ;
- if (psf->mode == SFM_WRITE)
+ if (psf->file.mode == SFM_WRITE)
{ pms->samples = pms->dummydata ;
pms->samplecount = 0 ;
@@ -764,7 +763,7 @@ msadpcm_close (SF_PRIVATE *psf)
pms = (MSADPCM_PRIVATE*) psf->codec_data ;
- if (psf->mode == SFM_WRITE)
+ if (psf->file.mode == SFM_WRITE)
{ /* Now we know static int for certain the length of the file we can
** re-write the header.
*/
diff --git a/libs/libsndfile/src/nist.c b/libs/libsndfile/src/nist.c
index 1993f00b3e..cd3afac842 100644
--- a/libs/libsndfile/src/nist.c
+++ b/libs/libsndfile/src/nist.c
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 1999-2009 Erik de Castro Lopo
+** Copyright (C) 1999-2011 Erik de Castro Lopo
**
** 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
@@ -54,12 +54,12 @@ int
nist_open (SF_PRIVATE *psf)
{ int error ;
- if (psf->mode == SFM_READ || (psf->mode == SFM_RDWR && psf->filelength > 0))
+ if (psf->file.mode == SFM_READ || (psf->file.mode == SFM_RDWR && psf->filelength > 0))
{ if ((error = nist_read_header (psf)))
return error ;
} ;
- if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR)
+ if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR)
{ if (psf->is_pipe)
return SFE_NO_PIPE_WRITE ;
@@ -119,12 +119,11 @@ static char bad_header [] =
static int
nist_read_header (SF_PRIVATE *psf)
{ char *psf_header ;
- int bitwidth = 0, bytes = 0, count, encoding ;
+ int bitwidth = 0, count, encoding ;
+ unsigned bytes = 0 ;
char str [64], *cptr ;
long samples ;
- psf->sf.format = SF_FORMAT_NIST ;
-
psf_header = psf->u.cbuf ;
if (sizeof (psf->header) <= NIST_HEADER_LENGTH)
@@ -164,7 +163,9 @@ nist_read_header (SF_PRIVATE *psf)
{ sscanf (cptr, "sample_coding -s%d %63s", &count, str) ;
if (strcmp (str, "pcm") == 0)
+ { /* Correct this later when we find out the bitwidth. */
encoding = SF_FORMAT_PCM_U8 ;
+ }
else if (strcmp (str, "alaw") == 0)
encoding = SF_FORMAT_ALAW ;
else if ((strcmp (str, "ulaw") == 0) || (strcmp (str, "mu-law") == 0))
@@ -193,19 +194,23 @@ nist_read_header (SF_PRIVATE *psf)
psf->endian = (CPU_IS_BIG_ENDIAN) ? SF_ENDIAN_BIG : SF_ENDIAN_LITTLE ;
/* This is where we figure out endian-ness. */
- if ((cptr = strstr (psf_header, "sample_byte_format -s")))
- { sscanf (cptr, "sample_byte_format -s%d %8s", &bytes, str) ;
+ if ((cptr = strstr (psf_header, "sample_byte_format -s"))
+ && sscanf (cptr, "sample_byte_format -s%u %8s", &bytes, str) == 2)
+ {
+ if (bytes != strlen (str))
+ psf_log_printf (psf, "Weird sample_byte_format : strlen '%s' != %d\n", str, bytes) ;
+
if (bytes > 1)
{ if (psf->bytewidth == 0)
psf->bytewidth = bytes ;
- else if (psf->bytewidth != bytes)
+ else if (psf->bytewidth - bytes != 0)
{ psf_log_printf (psf, "psf->bytewidth (%d) != bytes (%d)\n", psf->bytewidth, bytes) ;
return SFE_NIST_BAD_ENCODING ;
} ;
- if (strstr (str, "01") == str)
+ if (strcmp (str, "01") == 0)
psf->endian = SF_ENDIAN_LITTLE ;
- else if (strstr (str, "10"))
+ else if (strcmp (str, "10") == 0)
psf->endian = SF_ENDIAN_BIG ;
else
{ psf_log_printf (psf, "Weird endian-ness : %s\n", str) ;
@@ -255,13 +260,26 @@ nist_read_header (SF_PRIVATE *psf)
else
return SFE_UNIMPLEMENTED ;
+ /* Sanitize psf->sf.format. */
+ switch (SF_CODEC (psf->sf.format))
+ { case SF_FORMAT_ULAW :
+ case SF_FORMAT_ALAW :
+ case SF_FORMAT_PCM_U8 :
+ /* Blank out endian bits. */
+ psf->sf.format = SF_FORMAT_NIST | SF_CODEC (psf->sf.format) ;
+ break ;
+
+ default :
+ break ;
+ } ;
+
return 0 ;
} /* nist_read_header */
static int
nist_close (SF_PRIVATE *psf)
{
- if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR)
+ if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR)
nist_write_header (psf, SF_TRUE) ;
return 0 ;
diff --git a/libs/libsndfile/src/ogg.c b/libs/libsndfile/src/ogg.c
index 50484ac60c..d868fdbc42 100644
--- a/libs/libsndfile/src/ogg.c
+++ b/libs/libsndfile/src/ogg.c
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 2002-2009 Erik de Castro Lopo
+** Copyright (C) 2002-2011 Erik de Castro Lopo
** Copyright (C) 2007 John ffitch
**
** This program is free software ; you can redistribute it and/or modify
@@ -17,39 +17,6 @@
** 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
@@ -69,85 +36,86 @@
#if HAVE_EXTERNAL_LIBS
-#include
-#include
+#include
-typedef int convert_func (int, void *, int, int, float **) ;
+#include "ogg.h"
-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) ;
+static int ogg_stream_classify (SF_PRIVATE *psf, OGG_PRIVATE * odata) ;
+static int ogg_page_classify (SF_PRIVATE * psf, const ogg_page * og) ;
-typedef struct
-{ int id ;
- const char *name ;
-} STR_PAIRS ;
+int
+ogg_open (SF_PRIVATE *psf)
+{ OGG_PRIVATE* odata = calloc (1, sizeof (OGG_PRIVATE)) ;
+ sf_count_t pos = psf_ftell (psf) ;
+ int error = 0 ;
-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" },
-} ;
+ psf->container_data = odata ;
+ psf->container_close = ogg_close ;
-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 ;
+ if (psf->file.mode == SFM_RDWR)
+ return SFE_BAD_MODE_RW ;
-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 ;
+ if (psf->file.mode == SFM_READ)
+ if ((error = ogg_stream_classify (psf, odata)) != 0)
+ return error ;
+
+ /* Reset everything to an initial state. */
+ ogg_sync_clear (&odata->osync) ;
+ ogg_stream_clear (&odata->ostream) ;
+ psf_fseek (psf, pos, SEEK_SET) ;
+
+ switch (psf->sf.format)
+ { case SF_FORMAT_OGG | SF_FORMAT_VORBIS :
+ return ogg_vorbis_open (psf) ;
+
+ case SF_FORMAT_OGGFLAC :
+ free (psf->container_data) ;
+ psf->container_data = NULL ;
+ psf->container_close = NULL ;
+ return flac_open (psf) ;
+
+#if ENABLE_EXPERIMENTAL_CODE
+ case SF_FORMAT_OGG | SF_FORMAT_SPEEX :
+ return ogg_speex_open (psf) ;
+
+ case SF_FORMAT_OGG | SF_FORMAT_PCM_16 :
+ case SF_FORMAT_OGG | SF_FORMAT_PCM_24 :
+ return ogg_pcm_open (psf) ;
+#endif
+
+ default :
+ break ;
+ } ;
+
+ psf_log_printf (psf, "%s : mode should be SFM_READ or SFM_WRITE.\n", __func__) ;
+ return SFE_INTERNAL ;
+} /* ogg_open */
- /* 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 ;
+ogg_close (SF_PRIVATE *psf)
+{ OGG_PRIVATE* odata = psf->container_data ;
+
+ ogg_sync_clear (&odata->osync) ;
+ ogg_stream_clear (&odata->ostream) ;
+
+ return 0 ;
+} /* ogg_close */
+
+static int
+ogg_stream_classify (SF_PRIVATE *psf, OGG_PRIVATE* odata)
+{ char *buffer ;
+ int bytes, nn ;
+
+ /* Call this here so it only gets called once, so no memory is leaked. */
+ ogg_sync_init (&odata->osync) ;
odata->eos = 0 ;
/* Weird stuff happens if these aren't called. */
- ogg_stream_reset (&odata->os) ;
- ogg_sync_reset (&odata->oy) ;
+ ogg_stream_reset (&odata->ostream) ;
+ ogg_sync_reset (&odata->osync) ;
/*
** Grab some data at the head of the stream. We want the first page
@@ -157,7 +125,7 @@ ogg_read_header (SF_PRIVATE *psf, int log_data)
*/
/* Expose the buffer */
- buffer = ogg_sync_buffer (&odata->oy, 4096L) ;
+ buffer = ogg_sync_buffer (&odata->osync, 4096L) ;
/* Grab the part of the header that has already been read. */
memcpy (buffer, psf->header, psf->headindex) ;
@@ -165,10 +133,10 @@ ogg_read_header (SF_PRIVATE *psf, int log_data)
/* 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) ;
+ ogg_sync_wrote (&odata->osync, bytes) ;
/* Get the first page. */
- if ((nn = ogg_sync_pageout (&odata->oy, &odata->og)) != 1)
+ if ((nn = ogg_sync_pageout (&odata->osync, &odata->opage)) != 1)
{
/* Have we simply run out of data? If so, we're done. */
if (bytes < 4096)
@@ -183,968 +151,92 @@ ogg_read_header (SF_PRIVATE *psf, int log_data)
** 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)) ;
+ ogg_stream_clear (&odata->ostream) ;
+ ogg_stream_init (&odata->ostream, ogg_page_serialno (&odata->opage)) ;
- /*
- ** 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)
+ if (ogg_stream_pagein (&odata->ostream, &odata->opage) < 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)
+ if (ogg_stream_packetout (&odata->ostream, &odata->opacket) != 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 ;
- } ;
+ odata->codec = ogg_page_classify (psf, &odata->opage) ;
- /*
- ** Common Ogg metadata fields?
- ** TITLE, VERSION, ALBUM, TRACKNUMBER, ARTIST, PERFORMER, COPYRIGHT, LICENSE,
- ** ORGANIZATION, DESCRIPTION, GENRE, DATE, LOCATION, CONTACT, ISRC,
- */
+ switch (odata->codec)
+ { case OGG_VORBIS :
+ psf->sf.format = SF_FORMAT_OGG | SF_FORMAT_VORBIS ;
+ return 0 ;
- if (log_data)
- { int k ;
+ case OGG_FLAC :
+ case OGG_FLAC0 :
+ psf->sf.format = SF_FORMAT_OGGFLAC ;
+ return 0 ;
- for (k = 0 ; k < ARRAY_LEN (vorbis_metatypes) ; k++)
- { char *dd ;
+ case OGG_SPEEX :
+ psf->sf.format = SF_FORMAT_OGG | SF_FORMAT_SPEEX ;
+ return 0 ;
- 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)
-{ 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 ;
-
- 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 ;
+ case OGG_PCM :
+ psf_log_printf (psf, "Detected Ogg/PCM data. This is not supported yet.\n") ;
+ return SFE_UNIMPLEMENTED ;
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 ;
- } ;
+ psf_log_printf (psf, "This Ogg bitstream contains some uknown data type.\n") ;
+ return SFE_UNIMPLEMENTED ;
+} /* ogg_stream_classify */
- if (!p->isillegal)
- { ogg_packet packet ;
- int header = 0 ;
+/*==============================================================================
+*/
- ogg_stream_pagein (&p->os, &page) ;
- if (p->doneheaders < 3)
- header = 1 ;
+static struct
+{ const char *str, *name ;
+ int len, codec ;
+} codec_lookup [] =
+{ { "Annodex", "Annodex", 8, OGG_ANNODEX },
+ { "AnxData", "AnxData", 7, OGG_ANXDATA },
+ { "\177FLAC", "Flac1", 5, OGG_FLAC },
+ { "fLaC", "Flac0", 4, OGG_FLAC0 },
+ { "PCM ", "PCM", 8, OGG_PCM },
+ { "Speex", "Speex", 5, OGG_SPEEX },
+ { "\001vorbis", "Vorbis", 7, OGG_VORBIS },
+} ;
- 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 ;
- } ;
+static int
+ogg_page_classify (SF_PRIVATE * psf, const ogg_page * og)
+{ int k, len ;
+
+ for (k = 0 ; k < ARRAY_LEN (codec_lookup) ; k++)
+ { if (codec_lookup [k].len > og->body_len)
+ continue ;
+
+ if (memcmp (og->body, codec_lookup [k].str, codec_lookup [k].len) == 0)
+ { psf_log_printf (psf, "Ogg stream data : %s\n", codec_lookup [k].name) ;
+ psf_log_printf (psf, "Stream serialno : %010D\n", (int64_t) ogg_page_serialno (og)) ;
+ return codec_lookup [k].codec ;
} ;
} ;
- ogg_sync_clear (&osync) ;
- free_stream_set (processors, &len) ;
+ len = og->body_len < 8 ? og->body_len : 8 ;
- return len ;
-} /* ogg_length_aux */
+ psf_log_printf (psf, "Ogg_stream data : '") ;
+ for (k = 0 ; k < len ; k++)
+ psf_log_printf (psf, "%c", isprint (og->body [k]) ? og->body [k] : '.') ;
+ psf_log_printf (psf, "' ") ;
+ for (k = 0 ; k < len ; k++)
+ psf_log_printf (psf, " %02x", og->body [k] & 0xff) ;
+ psf_log_printf (psf, "\n") ;
-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 */
+ return 0 ;
+} /* ogg_page_classify */
#else /* HAVE_EXTERNAL_LIBS */
diff --git a/libs/libsndfile/src/paf.c b/libs/libsndfile/src/paf.c
index b4737dc316..7c7d527f47 100644
--- a/libs/libsndfile/src/paf.c
+++ b/libs/libsndfile/src/paf.c
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 1999-2009 Erik de Castro Lopo
+** Copyright (C) 1999-2011 Erik de Castro Lopo
**
** 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
@@ -108,14 +108,14 @@ paf_open (SF_PRIVATE *psf)
psf->dataoffset = PAF_HEADER_LENGTH ;
- if (psf->mode == SFM_READ || (psf->mode == SFM_RDWR && psf->filelength > 0))
+ if (psf->file.mode == SFM_READ || (psf->file.mode == SFM_RDWR && psf->filelength > 0))
{ if ((error = paf_read_header (psf)))
return error ;
} ;
subformat = SF_CODEC (psf->sf.format) ;
- if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR)
+ if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR)
{ if ((SF_CONTAINER (psf->sf.format)) != SF_FORMAT_PAF)
return SFE_BAD_OPEN_FORMAT ;
@@ -163,6 +163,9 @@ paf_read_header (SF_PRIVATE *psf)
{ PAF_FMT paf_fmt ;
int marker ;
+ if (psf->filelength < PAF_HEADER_LENGTH)
+ return SFE_PAF_SHORT_HEADER ;
+
memset (&paf_fmt, 0, sizeof (paf_fmt)) ;
psf_binheader_readf (psf, "pm", 0, &marker) ;
@@ -199,8 +202,8 @@ paf_read_header (SF_PRIVATE *psf)
psf->endian = SF_ENDIAN_BIG ;
} ;
- if (psf->filelength < PAF_HEADER_LENGTH)
- return SFE_PAF_SHORT_HEADER ;
+ if (paf_fmt.channels > SF_MAX_CHANNELS)
+ return SFE_PAF_BAD_CHANNELS ;
psf->datalength = psf->filelength - psf->dataoffset ;
@@ -356,11 +359,10 @@ paf24_init (SF_PRIVATE *psf)
*/
psf->last_op = 0 ;
- if (! (psf->codec_data = malloc (paf24size)))
+ if (! (psf->codec_data = calloc (1, paf24size)))
return SFE_MALLOC_FAILED ;
ppaf24 = (PAF24_PRIVATE*) psf->codec_data ;
- memset (ppaf24, 0, paf24size) ;
ppaf24->channels = psf->sf.channels ;
ppaf24->samples = ppaf24->data ;
@@ -369,7 +371,7 @@ paf24_init (SF_PRIVATE *psf)
ppaf24->blocksize = PAF24_BLOCK_SIZE * ppaf24->channels ;
ppaf24->samplesperblock = PAF24_SAMPLES_PER_BLOCK ;
- if (psf->mode == SFM_READ || psf->mode == SFM_RDWR)
+ if (psf->file.mode == SFM_READ || psf->file.mode == SFM_RDWR)
{ paf24_read_block (psf, ppaf24) ; /* Read first block. */
psf->read_short = paf24_read_s ;
@@ -378,7 +380,7 @@ paf24_init (SF_PRIVATE *psf)
psf->read_double = paf24_read_d ;
} ;
- if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR)
+ if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR)
{ psf->write_short = paf24_write_s ;
psf->write_int = paf24_write_i ;
psf->write_float = paf24_write_f ;
@@ -392,7 +394,7 @@ paf24_init (SF_PRIVATE *psf)
psf->datalength = psf->filelength - psf->dataoffset ;
if (psf->datalength % PAF24_BLOCK_SIZE)
- { if (psf->mode == SFM_READ)
+ { if (psf->file.mode == SFM_READ)
psf_log_printf (psf, "*** Warning : file seems to be truncated.\n") ;
ppaf24->max_blocks = psf->datalength / ppaf24->blocksize + 1 ;
}
@@ -400,7 +402,7 @@ paf24_init (SF_PRIVATE *psf)
ppaf24->max_blocks = psf->datalength / ppaf24->blocksize ;
ppaf24->read_block = 0 ;
- if (psf->mode == SFM_RDWR)
+ if (psf->file.mode == SFM_RDWR)
ppaf24->write_block = ppaf24->max_blocks ;
else
ppaf24->write_block = 0 ;
@@ -472,7 +474,7 @@ paf24_close (SF_PRIVATE *psf)
ppaf24 = (PAF24_PRIVATE*) psf->codec_data ;
- if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR)
+ if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR)
{ if (ppaf24->write_count > 0)
paf24_write_block (psf, ppaf24) ;
} ;
diff --git a/libs/libsndfile/src/pcm.c b/libs/libsndfile/src/pcm.c
index 76cb58b5da..ec450bcd37 100644
--- a/libs/libsndfile/src/pcm.c
+++ b/libs/libsndfile/src/pcm.c
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 1999-2009 Erik de Castro Lopo
+** Copyright (C) 1999-2011 Erik de Castro Lopo
**
** 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
@@ -137,7 +137,7 @@ pcm_init (SF_PRIVATE *psf)
else
psf->data_endswap = (psf->endian == SF_ENDIAN_LITTLE) ? SF_FALSE : SF_TRUE ;
- if (psf->mode == SFM_READ || psf->mode == SFM_RDWR)
+ if (psf->file.mode == SFM_READ || psf->file.mode == SFM_RDWR)
{ switch (psf->bytewidth * 0x10000 + psf->endian + chars)
{ case (0x10000 + SF_ENDIAN_BIG + SF_CHARS_SIGNED) :
case (0x10000 + SF_ENDIAN_LITTLE + SF_CHARS_SIGNED) :
@@ -198,7 +198,7 @@ pcm_init (SF_PRIVATE *psf)
} ;
} ;
- if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR)
+ if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR)
{ switch (psf->bytewidth * 0x10000 + psf->endian + chars)
{ case (0x10000 + SF_ENDIAN_BIG + SF_CHARS_SIGNED) :
case (0x10000 + SF_ENDIAN_LITTLE + SF_CHARS_SIGNED) :
@@ -271,7 +271,7 @@ pcm_init (SF_PRIVATE *psf)
else
psf->datalength = 0 ;
- psf->sf.frames = psf->datalength / psf->blockwidth ;
+ psf->sf.frames = psf->blockwidth > 0 ? psf->datalength / psf->blockwidth : 0 ;
return 0 ;
} /* pcm_init */
diff --git a/libs/libsndfile/src/pvf.c b/libs/libsndfile/src/pvf.c
index 5e027cb66b..4ea24b6b68 100644
--- a/libs/libsndfile/src/pvf.c
+++ b/libs/libsndfile/src/pvf.c
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 2002-2009 Erik de Castro Lopo
+** Copyright (C) 2002-2011 Erik de Castro Lopo
**
** 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,14 +51,14 @@ pvf_open (SF_PRIVATE *psf)
{ int subformat ;
int error = 0 ;
- if (psf->mode == SFM_READ || (psf->mode == SFM_RDWR && psf->filelength > 0))
+ if (psf->file.mode == SFM_READ || (psf->file.mode == SFM_RDWR && psf->filelength > 0))
{ if ((error = pvf_read_header (psf)))
return error ;
} ;
subformat = SF_CODEC (psf->sf.format) ;
- if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR)
+ if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR)
{ if ((SF_CONTAINER (psf->sf.format)) != SF_FORMAT_PVF)
return SFE_BAD_OPEN_FORMAT ;
diff --git a/libs/libsndfile/src/raw.c b/libs/libsndfile/src/raw.c
index 99e19d0ebf..e5dc49e2ff 100644
--- a/libs/libsndfile/src/raw.c
+++ b/libs/libsndfile/src/raw.c
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 1999-2009 Erik de Castro Lopo
+** Copyright (C) 1999-2011 Erik de Castro Lopo
**
** 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
diff --git a/libs/libsndfile/src/rf64.c b/libs/libsndfile/src/rf64.c
index ad29ce347c..d40bfab842 100644
--- a/libs/libsndfile/src/rf64.c
+++ b/libs/libsndfile/src/rf64.c
@@ -1,5 +1,6 @@
/*
-** Copyright (C) 2008-2009 Erik de Castro Lopo