--- libsndfile-1.0.18.orig/debian/control +++ libsndfile-1.0.18/debian/control @@ -0,0 +1,43 @@ +Source: libsndfile +Section: devel +Priority: optional +Maintainer: Samuel Mimram +Build-Depends: debhelper (>= 7.0.0), dpatch, pkg-config, libvorbis-dev, libflac-dev (>= 1.1.4-3), libasound2-dev [!hurd-i386 !kfreebsd-i386 !kfreebsd-amd64] +Standards-Version: 3.8.0 +Homepage: http://www.mega-nerd.com/libsndfile/ + +Package: libsndfile1-dev +Section: libdevel +Architecture: any +Depends: libsndfile1 (= ${binary:Version}), pkg-config, libvorbis-dev, libflac-dev (>= 1.1.4-3) +Conflicts: libsndfile-dev, libsndfile0-dev +Replaces: libsndfile-dev +Provides: libsndfile-dev +Description: Library for reading/writing audio files + libsndfile is a library of C routines for reading and writing files containing + sampled audio data. + . + This is the development version of libsndfile. You will need this only if you + intend to compile programs that use this library. + +Package: libsndfile1 +Section: libs +Architecture: any +Depends: ${shlibs:Depends} +Description: Library for reading/writing audio files + libsndfile is a library of C routines for reading and writing files containing + sampled audio data. + . + Various versions of WAV (integer, floating point, GSM, and compressed formats); + Microsoft PCM, A-law and u-law formats; AIFF, AIFC and RIFX; various AU/SND + formats (Sun/NeXT, Dec AU, G721 and G723 ADPCM); RAW header-less PCM files; + Amiga IFF/8SVX/16SV PCM files; Ensoniq PARIS (.PAF); Apple's Core Audio Format + (CAF) and others. + +Package: sndfile-programs +Section: utils +Architecture: any +Depends: ${shlibs:Depends} +Description: Sample programs that use libsndfile + This package contains simple programs for playing and converting sound files + with the libsndfile library. --- libsndfile-1.0.18.orig/debian/copyright +++ libsndfile-1.0.18/debian/copyright @@ -0,0 +1,29 @@ +This package was debianized by H. S. Teoh on +Mon, 28 Aug 2000 12:41:14 -0400. + +It was downloaded from: http://www.mega-nerd.com/libsndfile/ + +Upstream Author: Erik de Castro Lopo + +Copyright: + +libsndfile: a library for reading/writing audio sample files. +Copyright (C) 1999 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 the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later +version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +On Debian GNU/Linux systems, a copy of the GNU Lesser General Public +License resides in the file: /usr/share/common-licenses/LGPL-2.1 --- libsndfile-1.0.18.orig/debian/libsndfile1-dev.install +++ libsndfile-1.0.18/debian/libsndfile1-dev.install @@ -0,0 +1,6 @@ +usr/include/* +usr/lib/lib*.a +usr/lib/lib*.la +usr/lib/lib*.so +usr/lib/pkgconfig/sndfile.pc +usr/share/doc/libsndfile1-dev/html/* --- libsndfile-1.0.18.orig/debian/rules +++ libsndfile-1.0.18/debian/rules @@ -0,0 +1,75 @@ +#!/usr/bin/make -f +# Sample debian/rules that uses debhelper. +# GNU copyright 1997 to 1999 by Joey Hess. + +# Uncomment this to turn on verbose mode. +#export DH_VERBOSE=1 + +include /usr/share/dpatch/dpatch.make + +# These are used for cross-compiling and for saving the configure script +# from having to guess our platform (since we know it already) +DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE) +DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE) + + +ifneq (,$(findstring debug,$(DEB_BUILD_OPTIONS))) + CFLAGS += -g +endif +ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS))) + INSTALL_PROGRAM += -s +endif + +config.status: configure + dh_testdir + ./configure --host=$(DEB_HOST_GNU_TYPE) --build=$(DEB_BUILD_GNU_TYPE) --prefix=/usr --mandir=\$${prefix}/share/man --infodir=\$${prefix}/share/info + + +build: patch build-stamp +build-stamp: config.status + dh_testdir + + $(MAKE) + $(MAKE) check + + touch build-stamp + +clean: unpatch + dh_testdir + dh_testroot + rm -f build-stamp + + [ ! -f Makefile ] || $(MAKE) distclean + + dh_clean -a + +install: build + dh_testdir + dh_testroot + dh_prep -a + dh_installdirs + + $(MAKE) install DESTDIR=$(CURDIR)/debian/tmp + +binary-indep: build install + +binary-arch: build install + dh_testdir + dh_testroot + dh_install -a --sourcedir=debian/tmp --list-missing + dh_installdocs -a + dh_installexamples -a + dh_installchangelogs -a ChangeLog + dh_strip -a + dh_compress -a + dh_fixperms -a + dh_makeshlibs -plibsndfile1 + dh_installdeb -a + dh_shlibdeps -plibsndfile1 + dh_shlibdeps -psndfile-programs -ldebian/tmp/usr/lib + dh_gencontrol -a + dh_md5sums -a + dh_builddeb -a + +binary: binary-indep binary-arch +.PHONY: build clean binary-indep binary-arch binary install patch unpatch --- libsndfile-1.0.18.orig/debian/changelog +++ libsndfile-1.0.18/debian/changelog @@ -0,0 +1,295 @@ +libsndfile (1.0.18-2+squeeze1) testing-security; urgency=high + + * Non-maintainer upload by the Testing Security Team. + * Upload to testing due to several issues blocking migration of new release + * The following issues are fixed: + - CVE-2009-1788: heap-based buffer overflow in voc_read_header + leading to arbitrary code execution via crafted VOC headers. + - CVE-2009-1791: heap-based buffer overflow in aiff_read_header + leading to arbitrary code execution via crafted AIFF headers. + (Closes: #528650). + - CVE-2009-0186: integer overflow leading to a heap-based buffer overflow + via a crafted CAF file by limiting the number of channels per frame. + + -- Raphael Geissert Fri, 11 Sep 2009 21:50:21 -0500 + +libsndfile (1.0.18-2) unstable; urgency=low + + * Add missing build-dependencies on pkg-config and libvorbis-dev. + + -- Samuel Mimram Tue, 17 Feb 2009 19:21:03 +0100 + +libsndfile (1.0.18-1) unstable; urgency=low + + * New upstream release. + - Corrected error messages in libsndfile, closes: #481833. + * Removed flac-1.1.4.dpatch and overflow.dpatch, integrated upstream. + * Updated lossy_comp_test-overflow.dpatch and sndfile-play-kfreebsd.dpatch. + * Updated compat to 7. + * Updated standards version to 3.8.0. + * Put homepage in headers instead of description. + + -- Samuel Mimram Mon, 16 Feb 2009 10:13:44 +0100 + +libsndfile (1.0.17-4) unstable; urgency=low + + * Added overflow.dpatch to fix a possible heap-based buffer overflow + (CVE-2007-4974), closes: #443386. + + -- Samuel Mimram Thu, 20 Sep 2007 23:40:17 +0000 + +libsndfile (1.0.17-3) unstable; urgency=low + + * Version dependencies on libflac-dev, closes: #431140. + + -- Samuel Mimram Sat, 30 Jun 2007 17:05:38 +0200 + +libsndfile (1.0.17-2) unstable; urgency=low + + * Added flac-1.1.4.dpatch to adapt to the new FLAC API, closes: #426676. + * Don't build-depend on libasound2-dev on hurd, closes: #426795. + + -- Samuel Mimram Fri, 15 Jun 2007 12:41:00 +0200 + +libsndfile (1.0.17-1) unstable; urgency=low + + * Adopting the package, closes: #418082. + * New upstream release, closes: #407635. + * Big-endian architectures should now correctly be handled by sndfile-play, + closes: #350807. + * Using dpatch to handle patches. + * Added lossy_comp_test-overflow.dpatch to prevent a possible overflow in + the tests when compiled with gcc 4.2, closes: #362414. + * Added sndfile-play-kfreebsd.dpatch to make sndfile-play work on kfreebsd, + closes: #376525. + + -- Samuel Mimram Sat, 07 Apr 2007 13:07:14 +0200 + +libsndfile (1.0.16-1) unstable; urgency=low + + * New upstream release + * Update standards version (no changes required) + + -- Anand Kumria Mon, 3 Jul 2006 20:24:54 +1000 + +libsndfile (1.0.15-3) unstable; urgency=low + + * Depend on libasound2-dev so we use ALSA for the example programs + rather than (potentially) using OSS. Should fix #350807 but I'll + wait until the reporter confirms this before closing. + + -- Anand Kumria Mon, 24 Apr 2006 22:21:00 +1000 + +libsndfile (1.0.15-2) unstable; urgency=medium + + * Pull changes from 1.0.16pre1 for src/aiff.c so we can build on m68k + (Closes: #359325) + + -- Anand Kumria Wed, 29 Mar 2006 23:07:45 +1100 + +libsndfile (1.0.15-1) unstable; urgency=low + + * New upstream release + * Fix ia64 compilation issues (and possible ARM and m68k) + * Add RIFX support + + -- Anand Kumria Fri, 17 Mar 2006 11:32:16 +1100 + +libsndfile (1.0.14-1) unstable; urgency=low + + * New upstream release + + -- Anand Kumria Tue, 21 Feb 2006 22:20:26 +1100 + +libsndfile (1.0.13-1) unstable; urgency=low + + * New upstream release + * Add reading/writing of instrument chunks to WAV and AIFF files + * Support G721 / G610 coded WAV files + + -- Anand Kumria Mon, 23 Jan 2006 08:35:00 +1100 + +libsndfile (1.0.12-3) unstable; urgency=medium + + * Add dependancy on libflac-dev to libsndfile1-dev (Closes: #332591) + + -- Anand Kumria Sat, 8 Oct 2005 14:32:56 +1000 + +libsndfile (1.0.12-2) unstable; urgency=low + + * Depend on libflac7 (Closes: #331040) + + -- Anand Kumria Sat, 01 Oct 2005 20:15:28 +1000 + +libsndfile (1.0.12-1) unstable; urgency=low + + * New upstream release + * Upstream has updated config.sub/config.guess (Closes: #328147) + * Upstream now supports Ogg Flac, so depend on libflac-dev + * Update to standards version 3.6.2.1 + + -- Anand Kumria Fri, 30 Sep 2005 15:57:54 +1000 + +libsndfile (1.0.11-1) unstable; urgency=low + + * New upstream release + + -- Anand Kumria Sun, 17 Jul 2005 01:00:59 +1000 + +libsndfile (1.0.10-2) unstable; urgency=medium + + * Patch from upstream to correct flaw in sndfile-progs + * Corrects sndfile-convert (closes: #271999) + + -- Anand Kumria Sat, 18 Sep 2004 04:33:42 +1000 + +libsndfile (1.0.10-1) unstable; urgency=low + + * New upstream release + * Slightly different patch from upstream to correct #253490 + * bugfixes to AIFF/WAV read/write + * hardier testsuite + * 1.0.9 were accidently uploaded as Debian native. Fix that. + + -- Anand Kumria Thu, 17 Jun 2004 00:05:56 +1000 + +libsndfile (1.0.9-2) unstable; urgency=low + + * Apply patch from Andreas Jochens to correctly cast to size_t various + arguments (closes: #253490) + + -- Anand Kumria Wed, 16 Jun 2004 23:41:36 +1000 + +libsndfile (1.0.9-1) unstable; urgency=low + + * New upstream release (closes: #252770) + + -- Anand Kumria Sun, 6 Jun 2004 00:11:41 +1000 + +libsndfile (1.0.8-1) unstable; urgency=low + + * New upstream release + + -- Anand Kumria Sun, 28 Mar 2004 17:04:57 +1000 + +libsndfile (1.0.7-1) unstable; urgency=medium + + * New upstream releasea + * detects how the CPU clips and acts appropriately. (closes: #233970) + + -- Anand Kumria Sat, 28 Feb 2004 05:36:42 +1100 + +Libsndfile (1.0.6-1) unstable; urgency=low + + * New upstream release (closes: #223940) + * New maintainer (thanks Joshua!) + * Provide virtual package libsndfile-dev (closes: #200931) + + -- Anand Kumria Sun, 15 Feb 2004 00:52:53 +1100 + +libsndfile (1.0.4-3) unstable; urgency=low + + * Oops; forgot section change from devel to libdevel + + -- Joshua Haberman Sun, 27 Apr 2003 21:42:49 +0000 + +libsndfile (1.0.4-2) unstable; urgency=low + + * Fix from upstream to fix string_test from 'make check' + on m68k (closes: #180377) + + -- Joshua Haberman Sun, 27 Apr 2003 21:22:28 +0000 + +libsndfile (1.0.4-1) unstable; urgency=low + + * New upstream release + + -- Joshua Haberman Sat, 8 Feb 2003 23:14:17 +0000 + +libsndfile (1.0.3-1) unstable; urgency=low + + * New upstream release + - "make check" should no longer fail on Alpha + - "make check" should no longer fail on ia64 (closes: #161090) + + -- Joshua Haberman Sun, 8 Dec 2002 23:56:03 -0800 + +libsndfile (1.0.2-1) unstable; urgency=low + + * New upstream release + - "make check" should no longer fail on ARM (closes: #168424) + - though progress has been made on the ia64 problems, they have not + been fully resolved, so I am not closing #161090. + - interfaces have been added, (new sf_command SFC_GET_FORMAT_INFO) + so I am bumping the shlibs version to (>= this release) + + -- Joshua Haberman Sun, 1 Dec 2002 21:08:51 -0800 + +libsndfile (1.0.0-1) unstable; urgency=low + + * New upstream release (closes: #144821, #144897) + - The bump in sonumber makes for new binary packages libsndfile1 and + libsndfile1-dev + * New maintainer, with blessings from previous maintainer and upstream + * The -dev package now uses and depends on pkg-config instead of including + a separate program 'sndfile-config' + * Associated programs 'sndfile-info' and 'sndfile-play' moved to separate + package 'sndfile-programs' + * DH_COMPAT=4 + * Standards-Version: 3.5.6.1 + + -- Joshua Haberman Sat, 8 Jun 2002 19:56:23 -0700 + +libsndfile (0.0.26-1.1) unstable; urgency=high + + * NMU with permission of Hwei Sheng Teoh. + * Added a build conflict with automake. (closes: #120218) + + -- Adrian Bunk Fri, 7 Dec 2001 09:24:43 +0100 + +libsndfile (0.0.26-1) unstable; urgency=low + + * New upstream release + * Merged fixes by Jeff Licquia : + - Added Build-Depends on debhelper. Closes: #104308. + - Use autoconf endian test instead of the silly architecture lists. + - Fixed build problem w/ CAN_READ_WRITE_x86_IEEE on ia64 and arm. + Closes: #105136. + + -- Hwei Sheng Teoh Mon, 22 Oct 2001 19:31:32 -0400 + +libsndfile (0.0.22-2.1) unstable; urgency=low + * Run libtoolize to get support for new architectures. Closes: #95080 + + -- LaMont Jones Mon, 9 Jul 2001 21:39:34 -0600 + +libsndfile (0.0.22-2) unstable; urgency=low + + * Changed documention section of libsndfile-dev to "Programming" + (Closes: #79458). + + -- Hwei Sheng Teoh Wed, 13 Dec 2000 10:29:13 -0500 + +libsndfile (0.0.22-1) unstable; urgency=low + + * New upstream release + + -- Hwei Sheng Teoh Wed, 6 Dec 2000 09:09:51 -0500 + +libsndfile (0.0.21-2) unstable; urgency=low + + * Fixed: missing section lines in debian/control for libsndfile0 + * Removed questionable text about MP3's from package description. + + -- Hwei Sheng Teoh Mon, 4 Sep 2000 17:00:41 -0400 + +libsndfile (0.0.21-1) unstable; urgency=low + + * Initial Release. + * Converted to DH_COMPAT=2. Not sure why dh_make defaults to DH_COMPAT=1 + even in the pristine source tree (is this a bug in debhelper?) + * Fixed debian/rules to properly produce changelogs in binary packages + + -- Hwei Sheng Teoh Mon, 28 Aug 2000 12:41:14 -0400 + + --- libsndfile-1.0.18.orig/debian/sndfile-programs.install +++ libsndfile-1.0.18/debian/sndfile-programs.install @@ -0,0 +1,2 @@ +usr/bin/* +usr/share/man/man1/* --- libsndfile-1.0.18.orig/debian/libsndfile1-dev.doc-base +++ libsndfile-1.0.18/debian/libsndfile1-dev.doc-base @@ -0,0 +1,9 @@ +Document: libsndfile +Title: Debian libsndfile Manual +Author: Erik de Castro Lopo +Abstract: Programming manual and examples for the libsndfile library. +Section: Programming + +Format: HTML +Index: /usr/share/doc/libsndfile1-dev/html/index.html +Files: /usr/share/doc/libsndfile1-dev/html/*.html --- libsndfile-1.0.18.orig/debian/watch +++ libsndfile-1.0.18/debian/watch @@ -0,0 +1,3 @@ +version=3 + +http://www.mega-nerd.com/libsndfile/ libsndfile-(.*)\.tar\.gz --- libsndfile-1.0.18.orig/debian/compat +++ libsndfile-1.0.18/debian/compat @@ -0,0 +1 @@ +7 --- libsndfile-1.0.18.orig/debian/libsndfile1-dev.examples +++ libsndfile-1.0.18/debian/libsndfile1-dev.examples @@ -0,0 +1,2 @@ +examples/*.c +examples/Makefile --- libsndfile-1.0.18.orig/debian/libsndfile1-dev.docs +++ libsndfile-1.0.18/debian/libsndfile1-dev.docs @@ -0,0 +1,5 @@ +NEWS +README +TODO +AUTHORS +doc/new_file_type.HOWTO --- libsndfile-1.0.18.orig/debian/libsndfile1.install +++ libsndfile-1.0.18/debian/libsndfile1.install @@ -0,0 +1 @@ +usr/lib/lib*.so.* --- libsndfile-1.0.18.orig/debian/patches/00list +++ libsndfile-1.0.18/debian/patches/00list @@ -0,0 +1,4 @@ +lossy_comp_test-overflow +sndfile-play-kfreebsd +CVE-2009-1788_CVE-2009-1791 +CVE-2009-0186 --- libsndfile-1.0.18.orig/debian/patches/CVE-2009-1788_CVE-2009-1791.dpatch +++ libsndfile-1.0.18/debian/patches/CVE-2009-1788_CVE-2009-1791.dpatch @@ -0,0 +1,76 @@ +#! /bin/sh /usr/share/dpatch/dpatch-run +## +## All lines beginning with `## DP:' are a description of the patch. +## DP: Fix vulnerabilities described in CVE-2009-1788 and CVE-2009-1791 + +@DPATCH@ +diff -ur libsndfile-1.0.18-orig/src/aiff.c libsndfile-1.0.18/src/aiff.c +--- libsndfile-1.0.18-orig/src/aiff.c 2009-02-07 14:57:23.000000000 +1100 ++++ libsndfile-1.0.18/src/aiff.c 2009-04-27 19:14:55.000000000 +1000 +@@ -758,7 +758,6 @@ + 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) ; +@@ -767,13 +766,24 @@ + psf_log_printf (psf, " Count : %d\n", mark_count) ; + + 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) ; + + markstr [n].markerID = mark_id ; +diff -ur libsndfile-1.0.18-orig/src/voc.c libsndfile-1.0.18/src/voc.c +--- libsndfile-1.0.18-orig/src/voc.c 2009-02-07 14:54:20.000000000 +1100 ++++ libsndfile-1.0.18/src/voc.c 2009-04-27 19:14:55.000000000 +1000 +@@ -199,7 +199,7 @@ + psf->endian = SF_ENDIAN_LITTLE ; + + while (1) +- { int size ; ++ { unsigned size ; + short count ; + + block_type = 0 ; +@@ -211,9 +211,14 @@ + + psf_log_printf (psf, " ASCII : %d\n", size) ; + +- offset += psf_binheader_readf (psf, "b", psf->header, size) ; +- psf->header [size] = 0 ; +- psf_log_printf (psf, " text : %s\n", psf->header) ; ++ if (size < sizeof (psf->header) - 1) ++ { offset += psf_binheader_readf (psf, "b", psf->header, size) ; ++ psf->header [size] = 0 ; ++ psf_log_printf (psf, " text : %s\n", psf->header) ; ++ continue ; ++ } ++ ++ offset += psf_binheader_readf (psf, "j", size) ; + continue ; + + case VOC_REPEAT : --- libsndfile-1.0.18.orig/debian/patches/CVE-2009-0186.dpatch +++ libsndfile-1.0.18/debian/patches/CVE-2009-0186.dpatch @@ -0,0 +1,22 @@ +#! /bin/sh /usr/share/dpatch/dpatch-run +## CVE-2009-0186.dpatch by Nico Golde +## +## All lines beginning with `## DP:' are a description of the patch. +## DP: No description. + +@DPATCH@ +diff -urNad libsndfile-1.0.17~/src/caf.c libsndfile-1.0.17/src/caf.c +--- libsndfile-1.0.17~/src/caf.c 2006-08-31 11:22:07.000000000 +0200 ++++ libsndfile-1.0.17/src/caf.c 2009-03-14 14:38:31.000000000 +0100 +@@ -282,6 +282,11 @@ + " Frames / packet : %u\n Channels / frame : %u\n Bits / channel : %u\n", + desc.fmt_id, desc.fmt_flags, desc.pkt_bytes, desc.pkt_frames, desc.channels_per_frame, desc.bits_per_chan) ; + ++ if (desc.channels_per_frame > 200) ++ { psf_log_printf (psf, "**** Bad channels per frame value %u.\n", desc.channels_per_frame) ; ++ return SFE_MALFORMED_FILE ; ++ } ; ++ + if (chunk_size > SIGNED_SIZEOF (DESC_CHUNK)) + psf_binheader_readf (psf, "j", (int) (chunk_size - sizeof (DESC_CHUNK))) ; + --- libsndfile-1.0.18.orig/debian/patches/flac-1.1.4.dpatch +++ libsndfile-1.0.18/debian/patches/flac-1.1.4.dpatch @@ -0,0 +1,486 @@ +#! /bin/sh /usr/share/dpatch/dpatch-run +## flac-1.1.4.dpatch by Samuel Mimram +## +## All lines beginning with `## DP:' are a description of the patch. +## DP: Adapt to FLAC 1.1.4 API. +## DP: Patch stolen from http://cvs.archlinux.org/cgi-bin/viewcvs.cgi/lib/libsndfile/flac-1.1.4.patch. + +@DPATCH@ +diff -urNad libsndfile-1.0.17~/configure.ac libsndfile-1.0.17/configure.ac +--- libsndfile-1.0.17~/configure.ac 2006-08-31 11:39:37.000000000 +0200 ++++ libsndfile-1.0.17/configure.ac 2007-06-15 12:38:53.000000000 +0200 +@@ -339,7 +339,8 @@ + if test "x$HAVE_FLAC_1_1_1" = xyes ; then + AC_DEFINE(HAVE_FLAC_1_1_1, [1], [Define to 1 if you have libflac 1.1.1]) + fi +- FLAC_LIBS="-lFLAC" ++ # in FLAC 1.1.3 libOggFLAC was merged into libFLAC, hence we need -logg ++ FLAC_LIBS="-lFLAC -logg" + fi + fi + +diff -urNad libsndfile-1.0.17~/src/flac.c libsndfile-1.0.17/src/flac.c +--- libsndfile-1.0.17~/src/flac.c 2006-08-31 11:22:19.000000000 +0200 ++++ libsndfile-1.0.17/src/flac.c 2007-06-15 12:38:53.000000000 +0200 +@@ -46,6 +46,13 @@ + #include "sfendian.h" + #include "float_cast.h" + ++/* FLAC 1.1.3 has FLAC_API_VERSION_CURRENT == 8 */ ++#if !defined(FLAC_API_VERSION_CURRENT) || FLAC_API_VERSION_CURRENT < 8 ++#define LEGACY_FLAC ++#else ++#undef LEGACY_FLAC ++#endif ++ + /*------------------------------------------------------------------------------ + ** Private static functions. + */ +@@ -60,8 +67,14 @@ + } PFLAC_PCM ; + + typedef struct +-{ FLAC__SeekableStreamDecoder *fsd ; ++{ ++#ifdef LEGACY_FLAC ++ FLAC__SeekableStreamDecoder *fsd ; + FLAC__SeekableStreamEncoder *fse ; ++#else ++ FLAC__StreamDecoder *fsd ; ++ FLAC__StreamEncoder *fse ; ++#endif + PFLAC_PCM pcmtype ; + void* ptr ; + unsigned pos, len, remain ; +@@ -108,6 +121,7 @@ + static int flac_command (SF_PRIVATE *psf, int command, void *data, int datasize) ; + + /* Decoder Callbacks */ ++#ifdef LEGACY_FLAC + static FLAC__SeekableStreamDecoderReadStatus sf_flac_read_callback (const FLAC__SeekableStreamDecoder *decoder, FLAC__byte buffer [], unsigned *bytes, void *client_data) ; + static FLAC__SeekableStreamDecoderSeekStatus sf_flac_seek_callback (const FLAC__SeekableStreamDecoder *decoder, FLAC__uint64 absolute_byte_offset, void *client_data) ; + static FLAC__SeekableStreamDecoderTellStatus sf_flac_tell_callback (const FLAC__SeekableStreamDecoder *decoder, FLAC__uint64 *absolute_byte_offset, void *client_data) ; +@@ -116,13 +130,29 @@ + static FLAC__StreamDecoderWriteStatus sf_flac_write_callback (const FLAC__SeekableStreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer [], void *client_data) ; + static void sf_flac_meta_callback (const FLAC__SeekableStreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data) ; + static void sf_flac_error_callback (const FLAC__SeekableStreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data) ; ++#else ++static FLAC__StreamDecoderReadStatus sf_flac_read_callback (const FLAC__StreamDecoder *decoder, FLAC__byte buffer [], size_t *bytes, void *client_data) ; ++static FLAC__StreamDecoderSeekStatus sf_flac_seek_callback (const FLAC__StreamDecoder *decoder, FLAC__uint64 absolute_byte_offset, void *client_data) ; ++static FLAC__StreamDecoderTellStatus sf_flac_tell_callback (const FLAC__StreamDecoder *decoder, FLAC__uint64 *absolute_byte_offset, void *client_data) ; ++static FLAC__StreamDecoderLengthStatus sf_flac_length_callback (const FLAC__StreamDecoder *decoder, FLAC__uint64 *stream_length, void *client_data) ; ++static FLAC__bool sf_flac_eof_callback (const FLAC__StreamDecoder *decoder, void *client_data) ; ++static FLAC__StreamDecoderWriteStatus sf_flac_write_callback (const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer [], void *client_data) ; ++static void sf_flac_meta_callback (const FLAC__StreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data) ; ++static void sf_flac_error_callback (const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data) ; ++#endif + + /* Encoder Callbacks */ ++#ifdef LEGACY_FLAC + static FLAC__SeekableStreamEncoderSeekStatus sf_flac_enc_seek_callback (const FLAC__SeekableStreamEncoder *encoder, FLAC__uint64 absolute_byte_offset, void *client_data) ; + #ifdef HAVE_FLAC_1_1_1 + static FLAC__SeekableStreamEncoderTellStatus sf_flac_enc_tell_callback (const FLAC__SeekableStreamEncoder *encoder, FLAC__uint64 *absolute_byte_offset, void *client_data) ; + #endif + static FLAC__StreamEncoderWriteStatus sf_flac_enc_write_callback (const FLAC__SeekableStreamEncoder *encoder, const FLAC__byte buffer [], unsigned bytes, unsigned samples, unsigned current_frame, void *client_data) ; ++#else ++static FLAC__StreamEncoderSeekStatus sf_flac_enc_seek_callback (const FLAC__StreamEncoder *encoder, FLAC__uint64 absolute_byte_offset, void *client_data) ; ++static FLAC__StreamEncoderTellStatus sf_flac_enc_tell_callback (const FLAC__StreamEncoder *encoder, FLAC__uint64 *absolute_byte_offset, void *client_data) ; ++static FLAC__StreamEncoderWriteStatus sf_flac_enc_write_callback (const FLAC__StreamEncoder *encoder, const FLAC__byte buffer [], size_t bytes, unsigned samples, unsigned current_frame, void *client_data) ; ++#endif + + static const int legal_sample_rates [] = + { 8000, 16000, 22050, 24000, 32000, 44100, 48000, 96000 +@@ -283,51 +313,99 @@ + } /* flac_buffer_copy */ + + ++#ifdef LEGACY_FLAC + static FLAC__SeekableStreamDecoderReadStatus + sf_flac_read_callback (const FLAC__SeekableStreamDecoder * UNUSED (decoder), FLAC__byte buffer [], unsigned *bytes, void *client_data) ++#else ++static FLAC__StreamDecoderReadStatus ++sf_flac_read_callback (const FLAC__StreamDecoder * UNUSED (decoder), FLAC__byte buffer [], size_t *bytes, void *client_data) ++#endif + { SF_PRIVATE *psf = (SF_PRIVATE*) client_data ; + + *bytes = psf_fread (buffer, 1, *bytes, psf) ; + if (*bytes > 0 && psf->error == 0) ++#ifdef LEGACY_FLAC + return FLAC__SEEKABLE_STREAM_DECODER_READ_STATUS_OK ; + + return FLAC__SEEKABLE_STREAM_DECODER_READ_STATUS_ERROR ; ++#else ++ return FLAC__STREAM_DECODER_READ_STATUS_CONTINUE ; ++ ++ return FLAC__STREAM_DECODER_READ_STATUS_ABORT ; ++#endif + } /* sf_flac_read_callback */ + ++#ifdef LEGACY_FLAC + static FLAC__SeekableStreamDecoderSeekStatus + sf_flac_seek_callback (const FLAC__SeekableStreamDecoder * UNUSED (decoder), FLAC__uint64 absolute_byte_offset, void *client_data) ++#else ++static FLAC__StreamDecoderSeekStatus ++sf_flac_seek_callback (const FLAC__StreamDecoder * UNUSED (decoder), FLAC__uint64 absolute_byte_offset, void *client_data) ++#endif + { SF_PRIVATE *psf = (SF_PRIVATE*) client_data ; + + psf_fseek (psf, absolute_byte_offset, SEEK_SET) ; + if (psf->error) ++#ifdef LEGACY_FLAC + return FLAC__SEEKABLE_STREAM_DECODER_SEEK_STATUS_ERROR ; + + return FLAC__SEEKABLE_STREAM_DECODER_SEEK_STATUS_OK ; ++#else ++ return FLAC__STREAM_DECODER_SEEK_STATUS_ERROR ; ++ ++ return FLAC__STREAM_DECODER_SEEK_STATUS_OK ; ++#endif + } /* sf_flac_seek_callback */ + ++#ifdef LEGACY_FLAC + static FLAC__SeekableStreamDecoderTellStatus + sf_flac_tell_callback (const FLAC__SeekableStreamDecoder * UNUSED (decoder), FLAC__uint64 *absolute_byte_offset, void *client_data) ++#else ++static FLAC__StreamDecoderTellStatus ++sf_flac_tell_callback (const FLAC__StreamDecoder * UNUSED (decoder), FLAC__uint64 *absolute_byte_offset, void *client_data) ++#endif + { SF_PRIVATE *psf = (SF_PRIVATE*) client_data ; + + *absolute_byte_offset = psf_ftell (psf) ; + if (psf->error) ++#ifdef LEGACY_FLAC + return FLAC__SEEKABLE_STREAM_DECODER_TELL_STATUS_ERROR ; + + return FLAC__SEEKABLE_STREAM_DECODER_TELL_STATUS_OK ; ++#else ++ return FLAC__STREAM_DECODER_TELL_STATUS_ERROR ; ++ ++ return FLAC__STREAM_DECODER_TELL_STATUS_OK ; ++#endif + } /* sf_flac_tell_callback */ + ++#ifdef LEGACY_FLAC + static FLAC__SeekableStreamDecoderLengthStatus + sf_flac_length_callback (const FLAC__SeekableStreamDecoder * UNUSED (decoder), FLAC__uint64 *stream_length, void *client_data) ++#else ++static FLAC__StreamDecoderLengthStatus ++sf_flac_length_callback (const FLAC__StreamDecoder * UNUSED (decoder), FLAC__uint64 *stream_length, void *client_data) ++#endif + { SF_PRIVATE *psf = (SF_PRIVATE*) client_data ; + + if ((*stream_length = psf->filelength) == 0) ++#ifdef LEGACY_FLAC + return FLAC__SEEKABLE_STREAM_DECODER_LENGTH_STATUS_ERROR ; + + return FLAC__SEEKABLE_STREAM_DECODER_LENGTH_STATUS_OK ; ++#else ++ return FLAC__STREAM_DECODER_LENGTH_STATUS_ERROR ; ++ ++ return FLAC__STREAM_DECODER_LENGTH_STATUS_OK ; ++#endif + } /* sf_flac_length_callback */ + + static FLAC__bool ++#ifdef LEGACY_FLAC + sf_flac_eof_callback (const FLAC__SeekableStreamDecoder *UNUSED (decoder), void *client_data) ++#else ++sf_flac_eof_callback (const FLAC__StreamDecoder *UNUSED (decoder), void *client_data) ++#endif + { SF_PRIVATE *psf = (SF_PRIVATE*) client_data ; + + if (psf_ftell (psf) == psf->filelength) +@@ -337,7 +415,11 @@ + } /* sf_flac_eof_callback */ + + static FLAC__StreamDecoderWriteStatus ++#ifdef LEGACY_FLAC + sf_flac_write_callback (const FLAC__SeekableStreamDecoder * UNUSED (decoder), const FLAC__Frame *frame, const FLAC__int32 * const buffer [], void *client_data) ++#else ++sf_flac_write_callback (const FLAC__StreamDecoder * UNUSED (decoder), const FLAC__Frame *frame, const FLAC__int32 * const buffer [], void *client_data) ++#endif + { SF_PRIVATE *psf = (SF_PRIVATE*) client_data ; + FLAC_PRIVATE* pflac = (FLAC_PRIVATE*) psf->codec_data ; + +@@ -353,7 +435,11 @@ + } /* sf_flac_write_callback */ + + static void ++#ifdef LEGACY_FLAC + sf_flac_meta_callback (const FLAC__SeekableStreamDecoder * UNUSED (decoder), const FLAC__StreamMetadata *metadata, void *client_data) ++#else ++sf_flac_meta_callback (const FLAC__StreamDecoder * UNUSED (decoder), const FLAC__StreamMetadata *metadata, void *client_data) ++#endif + { SF_PRIVATE *psf = (SF_PRIVATE*) client_data ; + + switch (metadata->type) +@@ -387,7 +473,11 @@ + } /* sf_flac_meta_callback */ + + static void ++#ifdef LEGACY_FLAC + sf_flac_error_callback (const FLAC__SeekableStreamDecoder * UNUSED (decoder), FLAC__StreamDecoderErrorStatus status, void *client_data) ++#else ++sf_flac_error_callback (const FLAC__StreamDecoder * UNUSED (decoder), FLAC__StreamDecoderErrorStatus status, void *client_data) ++#endif + { SF_PRIVATE *psf = (SF_PRIVATE*) client_data ; + + psf_log_printf (psf, "ERROR : %s\n", FLAC__StreamDecoderErrorStatusString [status]) ; +@@ -407,17 +497,29 @@ + return ; + } /* sf_flac_error_callback */ + ++#ifdef LEGACY_FLAC + static FLAC__SeekableStreamEncoderSeekStatus + sf_flac_enc_seek_callback (const FLAC__SeekableStreamEncoder * UNUSED (encoder), FLAC__uint64 absolute_byte_offset, void *client_data) ++#else ++static FLAC__StreamEncoderSeekStatus ++sf_flac_enc_seek_callback (const FLAC__StreamEncoder * UNUSED (encoder), FLAC__uint64 absolute_byte_offset, void *client_data) ++#endif + { SF_PRIVATE *psf = (SF_PRIVATE*) client_data ; + + psf_fseek (psf, absolute_byte_offset, SEEK_SET) ; + if (psf->error) ++#ifdef LEGACY_FLAC + return FLAC__SEEKABLE_STREAM_ENCODER_SEEK_STATUS_ERROR ; + + return FLAC__SEEKABLE_STREAM_ENCODER_SEEK_STATUS_OK ; ++#else ++ return FLAC__STREAM_ENCODER_SEEK_STATUS_ERROR ; ++ ++ return FLAC__STREAM_ENCODER_SEEK_STATUS_OK ; ++#endif + } /* sf_flac_enc_seek_callback */ + ++#ifdef LEGACY_FLAC + #ifdef HAVE_FLAC_1_1_1 + static FLAC__SeekableStreamEncoderTellStatus + sf_flac_enc_tell_callback (const FLAC__SeekableStreamEncoder *UNUSED (encoder), FLAC__uint64 *absolute_byte_offset, void *client_data) +@@ -430,9 +532,25 @@ + return FLAC__SEEKABLE_STREAM_ENCODER_TELL_STATUS_OK ; + } /* sf_flac_enc_tell_callback */ + #endif ++#else ++static FLAC__StreamEncoderTellStatus ++sf_flac_enc_tell_callback (const FLAC__StreamEncoder *UNUSED (encoder), FLAC__uint64 *absolute_byte_offset, void *client_data) ++{ SF_PRIVATE *psf = (SF_PRIVATE*) client_data ; ++ ++ *absolute_byte_offset = psf_ftell (psf) ; ++ if (psf->error) ++ return FLAC__STREAM_ENCODER_TELL_STATUS_ERROR ; ++ ++ return FLAC__STREAM_ENCODER_TELL_STATUS_OK ; ++} /* sf_flac_enc_tell_callback */ ++#endif + + static FLAC__StreamEncoderWriteStatus ++#ifdef LEGACY_FLAC + sf_flac_enc_write_callback (const FLAC__SeekableStreamEncoder * UNUSED (encoder), const FLAC__byte buffer [], unsigned bytes, unsigned UNUSED (samples), unsigned UNUSED (current_frame), void *client_data) ++#else ++sf_flac_enc_write_callback (const FLAC__StreamEncoder * UNUSED (encoder), const FLAC__byte buffer [], size_t bytes, unsigned UNUSED (samples), unsigned UNUSED (current_frame), void *client_data) ++#endif + { SF_PRIVATE *psf = (SF_PRIVATE*) client_data ; + + if (psf_fwrite (buffer, 1, bytes, psf) == bytes && psf->error == 0) +@@ -509,15 +627,27 @@ + return 0 ; + + if (psf->mode == SFM_WRITE) +- { FLAC__seekable_stream_encoder_finish (pflac->fse) ; ++ { ++#ifdef LEGACY_FLAC ++ FLAC__seekable_stream_encoder_finish (pflac->fse) ; + FLAC__seekable_stream_encoder_delete (pflac->fse) ; ++#else ++ FLAC__stream_encoder_finish (pflac->fse) ; ++ FLAC__stream_encoder_delete (pflac->fse) ; ++#endif + if (pflac->encbuffer) + free (pflac->encbuffer) ; + } ; + + if (psf->mode == SFM_READ) +- { FLAC__seekable_stream_decoder_finish (pflac->fsd) ; ++ { ++#ifdef LEGACY_FLAC ++ FLAC__seekable_stream_decoder_finish (pflac->fsd) ; + FLAC__seekable_stream_decoder_delete (pflac->fsd) ; ++#else ++ FLAC__stream_decoder_finish (pflac->fsd) ; ++ FLAC__stream_decoder_delete (pflac->fsd) ; ++#endif + } ; + + for (k = 0 ; k < ARRAY_LEN (pflac->rbuffer) ; k++) +@@ -546,17 +676,6 @@ + return SFE_FLAC_BAD_SAMPLE_RATE ; + + psf_fseek (psf, 0, SEEK_SET) ; +- if ((pflac->fse = FLAC__seekable_stream_encoder_new ()) == NULL) +- return SFE_FLAC_NEW_DECODER ; +- FLAC__seekable_stream_encoder_set_write_callback (pflac->fse, sf_flac_enc_write_callback) ; +- FLAC__seekable_stream_encoder_set_seek_callback (pflac->fse, sf_flac_enc_seek_callback) ; +- +-#ifdef HAVE_FLAC_1_1_1 +- FLAC__seekable_stream_encoder_set_tell_callback (pflac->fse, sf_flac_enc_tell_callback) ; +-#endif +- FLAC__seekable_stream_encoder_set_client_data (pflac->fse, psf) ; +- FLAC__seekable_stream_encoder_set_channels (pflac->fse, psf->sf.channels) ; +- FLAC__seekable_stream_encoder_set_sample_rate (pflac->fse, psf->sf.samplerate) ; + + switch (psf->sf.format & SF_FORMAT_SUBMASK) + { case SF_FORMAT_PCM_S8 : +@@ -574,12 +693,36 @@ + break ; + } ; + ++#ifdef LEGACY_FLAC ++ if ((pflac->fse = FLAC__seekable_stream_encoder_new ()) == NULL) ++ return SFE_FLAC_NEW_DECODER ; ++ FLAC__seekable_stream_encoder_set_write_callback (pflac->fse, sf_flac_enc_write_callback) ; ++ FLAC__seekable_stream_encoder_set_seek_callback (pflac->fse, sf_flac_enc_seek_callback) ; ++ ++#ifdef HAVE_FLAC_1_1_1 ++ FLAC__seekable_stream_encoder_set_tell_callback (pflac->fse, sf_flac_enc_tell_callback) ; ++#endif ++ FLAC__seekable_stream_encoder_set_client_data (pflac->fse, psf) ; ++ FLAC__seekable_stream_encoder_set_channels (pflac->fse, psf->sf.channels) ; ++ FLAC__seekable_stream_encoder_set_sample_rate (pflac->fse, psf->sf.samplerate) ; + FLAC__seekable_stream_encoder_set_bits_per_sample (pflac->fse, bps) ; + + if ((bps = FLAC__seekable_stream_encoder_init (pflac->fse)) != FLAC__SEEKABLE_STREAM_DECODER_OK) + { psf_log_printf (psf, "Error : FLAC encoder init returned error : %s\n", FLAC__seekable_stream_encoder_get_resolved_state_string (pflac->fse)) ; + return SFE_FLAC_INIT_DECODER ; + } ; ++#else ++ if ((pflac->fse = FLAC__stream_encoder_new ()) == NULL) ++ return SFE_FLAC_NEW_DECODER ; ++ FLAC__stream_encoder_set_channels (pflac->fse, psf->sf.channels) ; ++ FLAC__stream_encoder_set_sample_rate (pflac->fse, psf->sf.samplerate) ; ++ FLAC__stream_encoder_set_bits_per_sample (pflac->fse, bps) ; ++ ++ if ((bps = FLAC__stream_encoder_init_stream (pflac->fse, sf_flac_enc_write_callback, sf_flac_enc_seek_callback, sf_flac_enc_tell_callback, NULL, psf)) != FLAC__STREAM_DECODER_INIT_STATUS_OK) ++ { psf_log_printf (psf, "Error : FLAC encoder init returned error : %s\n", FLAC__StreamEncoderInitStatusString[bps]) ; ++ return SFE_FLAC_INIT_DECODER ; ++ } ; ++#endif + + if (psf->error == 0) + psf->dataoffset = psf_ftell (psf) ; +@@ -593,6 +736,7 @@ + { FLAC_PRIVATE* pflac = (FLAC_PRIVATE*) psf->codec_data ; + + psf_fseek (psf, 0, SEEK_SET) ; ++#ifdef LEGACY_FLAC + if ((pflac->fsd = FLAC__seekable_stream_decoder_new ()) == NULL) + return SFE_FLAC_NEW_DECODER ; + +@@ -610,9 +754,22 @@ + return SFE_FLAC_INIT_DECODER ; + + FLAC__seekable_stream_decoder_process_until_end_of_metadata (pflac->fsd) ; ++#else ++ if ((pflac->fsd = FLAC__stream_decoder_new ()) == NULL) ++ return SFE_FLAC_NEW_DECODER ; ++ ++ if (FLAC__stream_decoder_init_stream (pflac->fsd, sf_flac_read_callback, sf_flac_seek_callback, sf_flac_tell_callback, sf_flac_length_callback, sf_flac_eof_callback, sf_flac_write_callback, sf_flac_meta_callback, sf_flac_error_callback, psf) != FLAC__STREAM_DECODER_INIT_STATUS_OK) ++ return SFE_FLAC_INIT_DECODER ; ++ ++ FLAC__stream_decoder_process_until_end_of_metadata (pflac->fsd) ; ++#endif + if (psf->error == 0) + { FLAC__uint64 position ; ++#ifdef LEGACY_FLAC + FLAC__seekable_stream_decoder_get_decode_position (pflac->fsd, &position) ; ++#else ++ FLAC__stream_decoder_get_decode_position (pflac->fsd, &position) ; ++#endif + psf->dataoffset = position ; + } ; + +@@ -676,10 +833,18 @@ + flac_buffer_copy (psf) ; + + while (pflac->pos < pflac->len) +- { if (FLAC__seekable_stream_decoder_process_single (pflac->fsd) == 0) ++ { ++#ifdef LEGACY_FLAC ++ if (FLAC__seekable_stream_decoder_process_single (pflac->fsd) == 0) + break ; + if (FLAC__seekable_stream_decoder_get_state (pflac->fsd) != FLAC__SEEKABLE_STREAM_DECODER_OK) + break ; ++#else ++ if (FLAC__stream_decoder_process_single (pflac->fsd) == 0) ++ break ; ++ if (FLAC__stream_decoder_get_state (pflac->fsd) >= FLAC__STREAM_DECODER_END_OF_STREAM) ++ break ; ++#endif + } ; + + pflac->ptr = NULL ; +@@ -795,7 +960,11 @@ + while (len > 0) + { writecount = (len >= bufferlen) ? bufferlen : (int) len ; + convert (ptr + total, buffer, writecount) ; ++#ifdef LEGACY_FLAC + if (FLAC__seekable_stream_encoder_process_interleaved (pflac->fse, buffer, writecount/psf->sf.channels)) ++#else ++ if (FLAC__stream_encoder_process_interleaved (pflac->fse, buffer, writecount/psf->sf.channels)) ++#endif + thiswrite = writecount ; + else + break ; +@@ -837,7 +1006,11 @@ + while (len > 0) + { writecount = (len >= bufferlen) ? bufferlen : (int) len ; + convert (ptr + total, buffer, writecount) ; ++#ifdef LEGACY_FLAC + if (FLAC__seekable_stream_encoder_process_interleaved (pflac->fse, buffer, writecount/psf->sf.channels)) ++#else ++ if (FLAC__stream_encoder_process_interleaved (pflac->fse, buffer, writecount/psf->sf.channels)) ++#endif + thiswrite = writecount ; + else + break ; +@@ -879,7 +1052,11 @@ + while (len > 0) + { writecount = (len >= bufferlen) ? bufferlen : (int) len ; + convert (ptr + total, buffer, writecount, psf->norm_float) ; ++#ifdef LEGACY_FLAC + if (FLAC__seekable_stream_encoder_process_interleaved (pflac->fse, buffer, writecount/psf->sf.channels)) ++#else ++ if (FLAC__stream_encoder_process_interleaved (pflac->fse, buffer, writecount/psf->sf.channels)) ++#endif + thiswrite = writecount ; + else + break ; +@@ -1011,7 +1188,11 @@ + while (len > 0) + { writecount = (len >= bufferlen) ? bufferlen : (int) len ; + convert (ptr + total, buffer, writecount, psf->norm_double) ; ++#ifdef LEGACY_FLAC + if (FLAC__seekable_stream_encoder_process_interleaved (pflac->fse, buffer, writecount/psf->sf.channels)) ++#else ++ if (FLAC__stream_encoder_process_interleaved (pflac->fse, buffer, writecount/psf->sf.channels)) ++#endif + thiswrite = writecount ; + else + break ; +@@ -1131,10 +1312,17 @@ + + if (psf->mode == SFM_READ) + { FLAC__uint64 position ; ++#ifdef LEGACY_FLAC + if (FLAC__seekable_stream_decoder_seek_absolute (pflac->fsd, offset)) + { FLAC__seekable_stream_decoder_get_decode_position (pflac->fsd, &position) ; + return offset ; + } ; ++#else ++ if (FLAC__stream_decoder_seek_absolute (pflac->fsd, offset)) ++ { FLAC__stream_decoder_get_decode_position (pflac->fsd, &position) ; ++ return offset ; ++ } ; ++#endif + + return ((sf_count_t) -1) ; + } ; --- libsndfile-1.0.18.orig/debian/patches/lossy_comp_test-overflow.dpatch +++ libsndfile-1.0.18/debian/patches/lossy_comp_test-overflow.dpatch @@ -0,0 +1,21 @@ +#! /bin/sh /usr/share/dpatch/dpatch-run +## lossy_comp_test-overflow.dpatch by Martin Michlmayr +## +## All lines beginning with `## DP:' are a description of the patch. +## DP: Avoid a possible overflow in sum_abs. +## DP: See #362414. + +@DPATCH@ +diff -urNad libsndfile-1.0.18~/tests/fix_this.c libsndfile-1.0.18/tests/fix_this.c +--- libsndfile-1.0.18~/tests/fix_this.c 2009-02-07 05:05:20.000000000 +0100 ++++ libsndfile-1.0.18/tests/fix_this.c 2009-02-16 09:58:08.000000000 +0100 +@@ -69,7 +69,8 @@ + lcomp_test_int (const char *str, const char *filename, int filetype, double margin) + { SNDFILE *file ; + SF_INFO sfinfo ; +- int k, m, *orig, *data, sum_abs ; ++ int k, m, *orig, *data ; ++ long long sum_abs ; + long datalen, seekpos ; + double scale ; + --- libsndfile-1.0.18.orig/debian/patches/sndfile-play-kfreebsd.dpatch +++ libsndfile-1.0.18/debian/patches/sndfile-play-kfreebsd.dpatch @@ -0,0 +1,38 @@ +#! /bin/sh /usr/share/dpatch/dpatch-run +## sndfile-play-kfreebsd.dpatch by Petr Salinger +## +## All lines beginning with `## DP:' are a description of the patch. +## DP: Allow playing files on kfreebsd. +## DP: See #376525. + +@DPATCH@ +diff -urNad libsndfile-1.0.18~/programs/sndfile-play.c libsndfile-1.0.18/programs/sndfile-play.c +--- libsndfile-1.0.18~/programs/sndfile-play.c 2009-02-07 05:09:22.000000000 +0100 ++++ libsndfile-1.0.18/programs/sndfile-play.c 2009-02-16 10:03:30.000000000 +0100 +@@ -48,7 +48,7 @@ + #include + #endif + +-#if defined (__linux__) ++#if defined (__linux__) || defined (__FreeBSD_kernel__) || defined (__FreeBSD__) + #include + #include + #include +@@ -348,7 +348,7 @@ + ** 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) ; + +@@ -937,6 +937,8 @@ + else + #endif + linux_play (argc, argv) ; ++#elif defined (__FreeBSD_kernel__) || defined (__FreeBSD__) ++ linux_play (argc, argv) ; + #elif (defined (__MACH__) && defined (__APPLE__)) + macosx_play (argc, argv) ; + #elif (defined (sun) && defined (unix))