--- mp3gain-1.4.6.orig/debian/dirs
+++ mp3gain-1.4.6/debian/dirs
@@ -0,0 +1,3 @@
+usr/bin
+usr/share/man/man1
+
--- mp3gain-1.4.6.orig/debian/mp3gain.sgml
+++ mp3gain-1.4.6/debian/mp3gain.sgml
@@ -0,0 +1,417 @@
+ manpage.1'. You may view
+ the manual page with: `docbook-to-man manpage.sgml | nroff -man |
+ less'. A typical entry in a Makefile or Makefile.am is:
+
+manpage.1: manpage.sgml
+ docbook-to-man $< > $@
+
+
+ The docbook-to-man binary is found in the docbook-to-man package.
+ Please remember that if you create the nroff version in one of the
+ debian/rules file targets (such as build), you will need to include
+ docbook-to-man in your Build-Depends control field.
+
+ -->
+
+
+ STEFAN">
+ FRITSCH">
+
+ February 4, 2004">
+
+ 1">
+ sf@sfritsch.de">
+
+ MP3GAIN">
+
+ Debian">
+ GNU">
+ LGPL">
+]>
+
+
+
+
+ &dhemail;
+
+
+ &dhfirstname;
+ &dhsurname;
+
+
+ 2004
+ Glen Sawyer and &dhusername;
+
+ &dhdate;
+
+
+ &dhucpackage;
+
+ &dhsection;
+
+
+ &dhpackage;
+
+ lossless mp3 normalizer
+
+
+
+ &dhpackage;
+
+
+
+ infile
+
+
+
+
+
+
+ DESCRIPTION
+
+ This manual page documents briefly the
+ &dhpackage;
+ command.
+
+ This manual page was written for the &debian; distribution
+ because the original program does not have a manual page.
+
+
+ &dhpackage; can analyze and adjust mp3 files
+ so that they have the same volume.
+
+ &dhpackage; does not just do peak normalization,
+ as many normalizers do. Instead, it does some statistical analysis to
+ determine how loud the file actually sounds to the human ear. Also, the
+ changes &dhpackage; makes are completely lossless. There
+ is no quality lost in the change because the program adjusts the mp3 file
+ directly, without decoding and re-encoding. Also, this works with all mp3
+ players, i.e. no support for a special tag or something similar is
+ required.
+
+ &dhpackage; actually changes your file's gain only
+ when you use one of the options , ,
+ , or . If none of these options is
+ given, only a tag denoting the recommended gain change is written to the
+ file. If you only want to print the recommended gain change (and not modify
+ the file at all) you have to use the (skip tag)
+ option.
+
+ The method mp3gain uses to determine the desired volume
+ is described at
+ www.replaygain.org.
+ See also /usr/share/doc/mp3gain/README.method .
+
+
+
+
+
+
+
+ OPTIONS
+
+
+
+
+
+
+
+
+ Show summary of options.
+
+
+
+
+
+
+
+ apply gain i to mp3 without
+ doing any analysis
+
+
+
+
+
+
+
+ apply gain i to channel 0
+ (left channel) of mp3
+ without doing any analysis (ONLY works for STEREO mp3s,
+ not Joint Stereo mp3s)
+
+
+
+
+
+
+
+ apply gain i to channel 1
+ (right channel) of mp3
+ without doing any analysis (ONLY works for STEREO mp3s,
+ not Joint Stereo mp3s)
+
+
+
+
+
+
+
+ apply Track gain automatically (all files set to equal loudness)
+
+
+
+
+
+
+
+ automatically lower Track gain to not clip audio
+
+
+
+
+
+
+
+ apply Album gain automatically (files are all from the same
+ album: a single gain change is applied to all files, so
+ their loudness relative to each other remains unchanged,
+ but the average album loudness is normalized)
+
+
+
+
+
+
+
+ modify suggested MP3 gain by integer i
+
+
+
+
+
+
+
+ modify suggested dB gain by floating-point
+ n
+
+
+
+
+
+
+
+ ignore clipping warning when applying gain
+
+
+
+
+
+
+
+ output is a database-friendly tab-delimited list
+
+
+
+
+
+
+
+ mp3gain writes modified mp3 to temp file, then deletes original
+ instead of modifying bytes in original file (This is the default in
+ Debian)
+
+
+
+
+
+
+
+ mp3gain modifies bytes in original file instead of
+ writing to temp file.
+
+
+
+
+
+
+
+ Quiet mode: no status messages
+
+
+
+
+
+
+
+ Preserve original file timestamp
+
+
+
+
+
+
+
+ Only find max. amplitude of mp3
+
+
+
+
+
+
+
+ Force mp3gain to assume input file
+ is an MPEG 2 Layer III file
+ (i.e. don't check for mis-named Layer I or Layer II files)
+
+
+
+
+
+
+
+ only check stored tag info (no other processing)
+
+
+
+
+
+
+
+ delete stored tag info (no other processing)
+
+
+
+
+
+
+
+ skip (ignore) stored tag info (do not read or write tags)
+
+
+
+
+
+
+
+ force re-calculation (do not read tag info)
+
+
+
+
+
+
+
+ undo changes made by mp3gain (based on stored tag info)
+
+
+
+
+
+
+
+ "wrap" gain change if gain+change > 255 or gain+change < 0
+ (see below or use switch for a complete
+ explanation)
+
+
+
+
+
+
+
+ Show version of program.
+
+
+
+ If you specify and ,
+ only the second one will work.
+ If you do not specify , the program will
+ stop and ask before
+ applying gain change to a file that might clip
+ The WRAP option
+ Here's the problem:
+ The "global gain" field that mp3gain adjusts is an 8-bit unsigned integer, so
+ the possible values are 0 to 255.
+
+ MOST mp3 files (in fact, ALL the mp3 files I've examined so far) don't go
+ over 230. So there's plenty of headroom on top-- you can increase the gain
+ by 37dB (multiplying the amplitude by 76) without a problem.
+
+ The problem is at the bottom of the range. Some encoders create frames with
+ 0 as the global gain for silent frames.
+ What happens when you _lower_ the global gain by 1?
+ Well, in the past, mp3gain always simply wrapped the result up to 255.
+ That way, if you lowered the gain by any amount and then raised it by the
+ same amount, the mp3 would always be _exactly_ the same.
+
+ There are a few encoders out there, unfortunately, that create 0-gain frames
+ with other audio data in the frame.
+ As long as the global gain is 0, you'll never hear the data.
+ But if you lower the gain on such a file, the global gain is suddenly _huge_.
+ If you play this modified file, there might be a brief, very loud blip.
+
+ So now the default behavior of mp3gain is to _not_ wrap gain changes.
+ In other words,
+
+
+ If the gain change would make a frame's global gain drop below 0,
+ then the global gain is set to 0.
+
+ If the gain change would make a frame's global gain grow above 255,
+ then the global gain is set to 255.
+
+ If a frame's global gain field is already 0, it is not changed, even if
+ the gain change is a positive number.
+
+
+
+ To use the original "wrapping" behavior, use the switch.
+
+
+
+
+ SEE ALSO
+
+ The homepage of mp3gain is located at
+ http://mp3gain.sourceforge.net/ .
+
+
+
+ AUTHOR
+
+ This manual page was written by &dhusername; &dhemail; for
+ the &debian; system (but may be used by others). Permission is
+ granted to copy, distribute and/or modify this document under
+ the terms of the &gnu; Lesser General Public License, Version 2.1 or
+ any later version published by the Free Software Foundation.
+
+
+ On Debian systems, the complete text of the GNU Lesser General Public
+ License can be found in /usr/share/common-licenses/LGPL.
+
+
+
+
+
+
+
+
--- mp3gain-1.4.6.orig/debian/control
+++ mp3gain-1.4.6/debian/control
@@ -0,0 +1,21 @@
+Source: mp3gain
+Section: sound
+Priority: optional
+Maintainer: Stefan Fritsch
+Build-Depends: debhelper (>= 4.0.0), docbook-to-man, dpatch
+Standards-Version: 3.7.2
+
+Package: mp3gain
+Architecture: any
+Depends: ${shlibs:Depends}
+Description: Lossless mp3 normalizer with statistical analysis
+ MP3Gain analyzes and adjusts mp3 files so that they have the same volume.
+ MP3Gain does not just do peak normalization, as many normalizers do. Instead,
+ it does some statistical analysis (using the replaygain algorithm) to
+ determine how loud the file actually sounds to the human ear.
+ .
+ MP3Gain can adjust the volume in a completely lossless way by modifying the
+ mp3 file directly, without decoding and re-encoding. This works with all mp3
+ players, i.e. no support for a special tag is required.
+ .
+ MP3Gain can also add replaygain compatible tags to mp3 files.
--- mp3gain-1.4.6.orig/debian/README.method
+++ mp3gain-1.4.6/debian/README.method
@@ -0,0 +1,23 @@
+Q: What dB value does mp3gain normalize to? How does this compare with
+normalize-audio?
+
+A: mp3gain and normalize-audio use different methods to determine the
+perceived volume of a file, so the numbers are not comparable. As I understand
+it, normalize-audio applies a smoothing filter and then sets the maximum to
+-12dBFS. mp3gain sorts the volume and then uses the value at 95% (i.e. 5% of
+the file are louder, 95% are quieter). This value is set to -20dBFS. I have
+tried a few files and found the difference in the recomended values to vary
+between 3dB and 6dB.
+
+The method mp3gain uses to determine the perceived volume is described at
+http://www.replaygain.org/.
+
+
+
+
+Q: Why are the files not exactly at the same volume?
+
+A: Since mp3gain changes the global gain value in every mp3 frame, it can only
+use 1.5dB steps for adjusting the volume. It will however write replaygain
+values to tags with finer accuracy than these 1.5dB steps.
+
--- mp3gain-1.4.6.orig/debian/rules
+++ mp3gain-1.4.6/debian/rules
@@ -0,0 +1,74 @@
+#!/usr/bin/make -f
+# -*- makefile -*-
+
+# Uncomment this to turn on verbose mode.
+#export DH_VERBOSE=1
+
+include /usr/share/dpatch/dpatch.make
+
+
+CFLAGS = -Wall -g
+export CFLAGS
+
+ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
+ CFLAGS += -O0
+else
+ CFLAGS += -O3
+endif
+
+
+
+build: build-stamp
+
+build-stamp: patch
+ dh_testdir
+
+ $(MAKE)
+ docbook-to-man debian/mp3gain.sgml > debian/mp3gain.1
+
+ touch build-stamp
+
+clean: clean-patched unpatch
+
+clean-patched:
+ dh_testdir
+ dh_testroot
+ rm -f build-stamp
+
+ $(MAKE) clean
+ rm -f debian/mp3gain.1
+
+ dh_clean
+
+install: build
+ dh_testdir
+ dh_testroot
+ dh_clean -k
+ dh_installdirs
+
+ $(MAKE) install DESTDIR=$(CURDIR)/debian/mp3gain
+
+
+# Build architecture-independent files here.
+binary-indep: build install
+# We have nothing to do by default.
+
+# Build architecture-dependent files here.
+binary-arch: build install
+ dh_testdir
+ dh_testroot
+ dh_installchangelogs
+ dh_installdocs debian/README.method
+ dh_installman debian/mp3gain.1
+ dh_link
+ dh_strip
+ dh_compress
+ dh_fixperms
+ dh_installdeb
+ dh_shlibdeps
+ dh_gencontrol
+ dh_md5sums
+ dh_builddeb
+
+binary: binary-indep binary-arch
+.PHONY: build clean binary-indep binary-arch binary install
--- mp3gain-1.4.6.orig/debian/watch
+++ mp3gain-1.4.6/debian/watch
@@ -0,0 +1,2 @@
+version=3
+opts="uversionmangle=s/_/./g" http://sf.net/mp3gain/mp3gain-([0-9].*)-src.zip
--- mp3gain-1.4.6.orig/debian/changelog
+++ mp3gain-1.4.6/debian/changelog
@@ -0,0 +1,78 @@
+mp3gain (1.4.6-7) unstable; urgency=low
+
+ * Fix another segfault with not-writable files (Closes: #444373)
+
+ -- Stefan Fritsch Sat, 29 Sep 2007 11:18:21 +0200
+
+mp3gain (1.4.6-6) unstable; urgency=low
+
+ * fix exit code on error in some more cases (hopefully all, closes: #433757)
+ * fix handling of DEB_BUILD_OPTIONS
+
+ -- Stefan Fritsch Sat, 28 Jul 2007 22:33:23 +0200
+
+mp3gain (1.4.6-5) unstable; urgency=low
+
+ * Change build system to dpatch.
+ * Assume 'n' on queries if we don't have stdin (Closes: #428301)
+ * Fix typo in man page (Closes: #428703)
+
+ -- Stefan Fritsch Sun, 17 Jun 2007 17:05:22 +0200
+
+mp3gain (1.4.6-4) unstable; urgency=low
+
+ * Modify description to mention replaygain (Closes: #411321)
+ * Change maintainer email address
+
+ -- Stefan Fritsch Thu, 15 Mar 2007 00:01:26 +0100
+
+mp3gain (1.4.6-3) unstable; urgency=low
+
+ * fix path to README.method in manpage (closes: #368679)
+ * bump standards version to 3.7.2 (no changes)
+
+ -- Stefan Fritsch Sat, 9 Sep 2006 17:05:33 +0200
+
+mp3gain (1.4.6-2) unstable; urgency=low
+
+ * Fix segfault if unable to write files (thanks to Michael Thaler for
+ the report).
+ * Clarify man page (thanks to Jameson C. Burt).
+ * Add shiny new watch file using QA's sourceforge redirector.
+ * Bump up standards version (no changes needed).
+
+ -- Stefan Fritsch Sat, 1 Oct 2005 00:04:01 +0200
+
+mp3gain (1.4.6-1) unstable; urgency=low
+
+ * New upstream release
+ * Closes: #284802: Segfaults on 48khz mp3 files
+ * Remove broken watch file
+
+ -- Stefan Fritsch Wed, 12 Jan 2005 12:03:18 +0100
+
+mp3gain (1.4.5-1) unstable; urgency=low
+
+ * New upstream release
+ * Add note about method. Closes: #269759
+
+ -- Stefan Fritsch Fri, 5 Nov 2004 19:37:22 +0100
+
+mp3gain (1.4.3-2) unstable; urgency=low
+
+ * Add watch file.
+ * Make -t the default since it is faster on ReiserFS.
+ * Closes: #264596: mp3gain does exit(1) upon success
+ (thanks to Roderick Schertler)
+ * Change maintainer email
+
+ -- Stefan Fritsch Tue, 10 Aug 2004 11:24:43 +0200
+
+mp3gain (1.4.3-1) unstable; urgency=low
+
+ * Fixed copyright information.
+ * Initial Upload sponsored by Joachim Breitner; Closes: #241748: ITP
+
+ -- Stefan Fritsch Thu, 15 Apr 2004 23:12:05 +0200
+
+
--- mp3gain-1.4.6.orig/debian/compat
+++ mp3gain-1.4.6/debian/compat
@@ -0,0 +1 @@
+4
--- mp3gain-1.4.6.orig/debian/README.Debian
+++ mp3gain-1.4.6/debian/README.Debian
@@ -0,0 +1,4 @@
+On ReiserFS (as of kernel 2.4.26 and 2.6.7), writing to a temp file
+(-t option) seems to be a lot faster than modifying the original
+file directly. Therefore, -t is now the default in Debian. The
+original behaviour can be restored with -T.
--- mp3gain-1.4.6.orig/debian/patches/06_fix_overwrite_query_loop.dpatch
+++ mp3gain-1.4.6/debian/patches/06_fix_overwrite_query_loop.dpatch
@@ -0,0 +1,29 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## 06_fix_overwrite_query_loop.dpatch by Stefan Fritsch
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: assume "n" if we don't have stdin (#428301)
+
+@DPATCH@
+diff -urNad mp3gain-1.4.6~/mp3gain.c mp3gain-1.4.6/mp3gain.c
+--- mp3gain-1.4.6~/mp3gain.c 2004-12-23 15:47:04.000000000 +0100
++++ mp3gain-1.4.6/mp3gain.c 2007-06-17 17:02:34.000000000 +0200
+@@ -1115,7 +1115,7 @@
+ static
+ int queryUserForClipping(char * argv_mainloop,int intGainChange)
+ {
+- char ch;
++ int ch;
+
+ fprintf(stderr,"\nWARNING: %s may clip with mp3 gain change %d\n",argv_mainloop,intGainChange);
+ ch = 0;
+@@ -1125,6 +1125,9 @@
+ fprintf(stderr,"Make change? [y/n]:");
+ fflush(stderr);
+ ch = getchar();
++ if (ch == EOF) {
++ ch='N';
++ }
+ ch = toupper(ch);
+ }
+ if (ch == 'N')
--- mp3gain-1.4.6.orig/debian/patches/07_fix_CFLAGS.dpatch
+++ mp3gain-1.4.6/debian/patches/07_fix_CFLAGS.dpatch
@@ -0,0 +1,19 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## 07_fix_CFLAGS.dpatch by Stefan Fritsch
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Allow using CFLAGS from debian/rules to fix DEB_BUILD_OPTIONS
+
+@DPATCH@
+diff -urNad mp3gain-1.4.6~/Makefile mp3gain-1.4.6/Makefile
+--- mp3gain-1.4.6~/Makefile 2007-07-28 22:08:24.000000000 +0200
++++ mp3gain-1.4.6/Makefile 2007-07-28 22:11:27.000000000 +0200
+@@ -6,7 +6,7 @@
+
+ CC= gcc
+
+-CFLAGS= -Wall -O3 -DHAVE_MEMCPY
++CFLAGS+= -Wall -DHAVE_MEMCPY
+
+ ifneq ($(OSTYPE),beos)
+ INSTALL_PATH= /usr/local/bin
--- mp3gain-1.4.6.orig/debian/patches/03_use_tempfile_by_default.dpatch
+++ mp3gain-1.4.6/debian/patches/03_use_tempfile_by_default.dpatch
@@ -0,0 +1,67 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## 03_use_tempfile_by_default.dpatch by Stefan Fritsch
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Using a tempfile is a lot faster than direct writes on ReiserFS
+## DP: and has no disadvantages besides diskspace usage.
+## DP: => We make it the default and let -T restore the old behaviour.
+
+@DPATCH@
+diff -urNad mp3gain-1.4.6~/mp3gain.c mp3gain-1.4.6/mp3gain.c
+--- mp3gain-1.4.6~/mp3gain.c 2006-04-06 22:22:35.000000000 +0200
++++ mp3gain-1.4.6/mp3gain.c 2006-04-06 22:36:12.000000000 +0200
+@@ -44,6 +44,9 @@
+ * So have fun dissecting.
+ */
+
++/* stf: make -t the default
++ -T restores old behaviour */
++
+ #include
+ #include
+ #include
+@@ -118,7 +121,7 @@
+
+ int writeself = 0;
+ int QuietMode = 0;
+-int UsingTemp = 0;
++int UsingTemp = 1;
+ int NowWriting = 0;
+ double lastfreq = -1.0;
+
+@@ -996,7 +999,7 @@
+ deleteFile(outfilename);
+ passError( MP3GAIN_UNSPECIFED_ERROR, 3,
+ "Not enough temp space on disk to modify ", filename,
+- "\nEither free some space, or do not use \"temp file\" option\n");
++ "\nEither free some space, or switch off \"temp file\" option with -T\n");
+ return M3G_ERR_NOT_ENOUGH_TMP_SPACE;
+ }
+ else {
+@@ -1215,8 +1218,9 @@
+ fprintf(stderr,"\t%cd - modify suggested dB gain by floating-point n\n",SWITCH_CHAR);
+ fprintf(stderr,"\t%cc - ignore clipping warning when applying gain\n",SWITCH_CHAR);
+ fprintf(stderr,"\t%co - output is a database-friendly tab-delimited list\n",SWITCH_CHAR);
+- fprintf(stderr,"\t%ct - mp3gain writes modified mp3 to temp file, then deletes original\n",SWITCH_CHAR);
+- fprintf(stderr,"\t instead of modifying bytes in original file\n");
++ fprintf(stderr,"\t%ct - mp3gain writes modified mp3 to temp file, then deletes original \n",SWITCH_CHAR);
++ fprintf(stderr,"\t instead of modifying bytes in original file (default)\n");
++ fprintf(stderr,"\t%cT - mp3gain directly modifies mp3 file (opposite of %ct)\n",SWITCH_CHAR,SWITCH_CHAR);
+ fprintf(stderr,"\t%cq - Quiet mode: no status messages\n",SWITCH_CHAR);
+ fprintf(stderr,"\t%cp - Preserve original file timestamp\n",SWITCH_CHAR);
+ fprintf(stderr,"\t%cx - Only find max. amplitude of mp3\n",SWITCH_CHAR);
+@@ -1506,10 +1510,13 @@
+ break;
+
+ case 't':
+- case 'T':
+ UsingTemp = !0;
+ break;
+
++ case 'T':
++ UsingTemp = 0;
++ break;
++
+ case 'u':
+ case 'U':
+ undoChanges = !0;
--- mp3gain-1.4.6.orig/debian/patches/05_fix_segfault_when_files_not_writable.dpatch
+++ mp3gain-1.4.6/debian/patches/05_fix_segfault_when_files_not_writable.dpatch
@@ -0,0 +1,80 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## 05_fix_segfault_when_files_not_writable.dpatch by Stefan Fritsch
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: don't segfault when files are not writable
+
+@DPATCH@
+diff -urNad mp3gain-1.4.6~/mp3gain.c mp3gain-1.4.6/mp3gain.c
+--- mp3gain-1.4.6~/mp3gain.c 2007-09-29 11:11:15.792120650 +0200
++++ mp3gain-1.4.6/mp3gain.c 2007-09-29 11:12:27.580211620 +0200
+@@ -705,6 +705,7 @@
+ inf = NULL;
+ passError(MP3GAIN_UNSPECIFED_ERROR, 3,
+ "\nCan't open ", outfilename, " for temp writing\n");
++ NowWriting = 0;
+ return M3G_ERR_CANT_MAKE_TMP;
+ }
+
+@@ -715,10 +716,13 @@
+ }
+
+ if (inf == NULL) {
+- if (UsingTemp && (outf != NULL))
++ if (UsingTemp && (outf != NULL)) {
+ fclose(outf);
++ outf = NULL;
++ }
+ passError( MP3GAIN_UNSPECIFED_ERROR, 3,
+ "\nCan't open ", filename, " for modifying\n");
++ NowWriting = 0;
+ return M3G_ERR_CANT_MODIFY_FILE;
+ }
+ else {
+@@ -921,6 +925,7 @@
+ fclose(inf);
+ if (UsingTemp) {
+ fclose(outf);
++ outf = NULL;
+ deleteFile(outfilename);
+ free(outfilename);
+ passError(MP3GAIN_CANCELLED,2,"Cancelled processing of ",filename);
+@@ -930,6 +935,7 @@
+ }
+ if (saveTime)
+ fileTime(filename, setStoredTime);
++ NowWriting = 0;
+ return;
+ }
+ #endif
+@@ -994,12 +1000,14 @@
+ fclose(outf);
+ fclose(inf);
+ inf = NULL;
++ outf = NULL;
+
+ if (outlength != inlength) {
+ deleteFile(outfilename);
+ passError( MP3GAIN_UNSPECIFED_ERROR, 3,
+ "Not enough temp space on disk to modify ", filename,
+ "\nEither free some space, or switch off \"temp file\" option with -T\n");
++ NowWriting = 0;
+ return M3G_ERR_NOT_ENOUGH_TMP_SPACE;
+ }
+ else {
+@@ -1008,6 +1016,7 @@
+ deleteFile(outfilename); //try to delete tmp file
+ passError( MP3GAIN_UNSPECIFED_ERROR, 3,
+ "Can't open ", filename, " for modifying\n");
++ NowWriting = 0;
+ return M3G_ERR_CANT_MODIFY_FILE;
+ }
+ if (moveFile(outfilename, filename)) {
+@@ -1016,6 +1025,7 @@
+ "\nThe mp3 was correctly modified, but you will need to re-name ",
+ outfilename, " to ", filename,
+ " yourself.\n");
++ NowWriting = 0;
+ return M3G_ERR_RENAME_TMP;
+ };
+ if (saveTime)
--- mp3gain-1.4.6.orig/debian/patches/01_fix_installdir.dpatch
+++ mp3gain-1.4.6/debian/patches/01_fix_installdir.dpatch
@@ -0,0 +1,19 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## 01_fix_installdir.dpatch by Stefan Fritsch
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: use DESTDIR
+
+@DPATCH@
+diff -urNad mp3gain-1.4.6~/Makefile mp3gain-1.4.6/Makefile
+--- mp3gain-1.4.6~/Makefile 2006-04-06 22:22:35.000000000 +0200
++++ mp3gain-1.4.6/Makefile 2006-04-06 22:36:29.000000000 +0200
+@@ -9,7 +9,7 @@
+ CFLAGS= -Wall -O3 -DHAVE_MEMCPY
+
+ ifneq ($(OSTYPE),beos)
+-INSTALL_PATH= /usr/local/bin
++INSTALL_PATH= $(DESTDIR)/usr/bin
+ else
+ INSTALL_PATH= $(HOME)/config/bin
+ endif
--- mp3gain-1.4.6.orig/debian/patches/02_correct_errorcode_on_failure.dpatch
+++ mp3gain-1.4.6/debian/patches/02_correct_errorcode_on_failure.dpatch
@@ -0,0 +1,111 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## 02_correct_errorcode_on_failure.dpatch by Stefan Fritsch
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: don't return 0 on error
+
+@DPATCH@
+diff -urNad mp3gain-1.4.6~/mp3gain.c mp3gain-1.4.6/mp3gain.c
+--- mp3gain-1.4.6~/mp3gain.c 2007-07-28 22:22:50.000000000 +0200
++++ mp3gain-1.4.6/mp3gain.c 2007-07-28 22:32:30.000000000 +0200
+@@ -1777,6 +1777,7 @@
+ } else {
+ fprintf(stderr,"No undo information in %s\n",argv[mainloop]);
+ }
++ gSuccess = 0;
+ }
+ }
+ }
+@@ -1825,8 +1826,9 @@
+ }
+
+ if ((inf == NULL)&&(tagInfo[mainloop].recalc > 0)) {
+- fprintf(stdout, "Can't open %s for reading\n",argv[mainloop]);
+- fflush(stdout);
++ fprintf(stderr, "Can't open %s for reading\n",argv[mainloop]);
++ fflush(stderr);
++ gSuccess = 0;
+ }
+ else {
+ InitMP3(&mp);
+@@ -1863,8 +1865,9 @@
+
+ if (!ok) {
+ if (!BadLayer) {
+- fprintf(stdout,"Can't find any valid MP3 frames in file %s\n",argv[mainloop]);
+- fflush(stdout);
++ fprintf(stderr,"Can't find any valid MP3 frames in file %s\n",argv[mainloop]);
++ fflush(stderr);
++ gSuccess = 0;
+ }
+ }
+ else {
+@@ -1892,8 +1895,8 @@
+ (Xingcheck[0] == 'I' && Xingcheck[1] == 'n' && Xingcheck[2] == 'f' && Xingcheck[3] == 'o')) {
+ bitridx = (curframe[2] >> 4) & 0x0F;
+ if (bitridx == 0) {
+- fprintf(stdout, "%s is free format (not currently supported)\n",curfilename);
+- fflush(stdout);
++ fprintf(stderr, "%s is free format (not currently supported)\n",curfilename);
++ fflush(stderr);
+ ok = 0;
+ }
+ else {
+@@ -1936,8 +1939,8 @@
+ while (ok) {
+ bitridx = (curframe[2] >> 4) & 0x0F;
+ if (bitridx == 0) {
+- fprintf(stdout,"%s is free format (not currently supported)\n",curfilename);
+- fflush(stdout);
++ fprintf(stderr,"%s is free format (not currently supported)\n",curfilename);
++ fflush(stderr);
+ ok = 0;
+ }
+ else {
+@@ -2030,8 +2033,9 @@
+ }
+
+ if (dBchange == GAIN_NOT_ENOUGH_SAMPLES) {
+- fprintf(stdout,"Not enough samples in %s to do analysis\n",argv[mainloop]);
+- fflush(stdout);
++ fprintf(stderr,"Not enough samples in %s to do analysis\n",argv[mainloop]);
++ fflush(stderr);
++ gSuccess = 0;
+ numFiles--;
+ }
+ else {
+@@ -2167,8 +2171,8 @@
+ }
+
+ if (dBchange == GAIN_NOT_ENOUGH_SAMPLES) {
+- fprintf(stdout,"Not enough samples in mp3 files to do analysis\n");
+- fflush(stdout);
++ fprintf(stderr,"Not enough samples in mp3 files to do analysis\n");
++ fflush(stderr);
+ }
+ else {
+ Float_t maxmaxsample;
+diff -urNad mp3gain-1.4.6~/mpglibDBL/common.c mp3gain-1.4.6/mpglibDBL/common.c
+--- mp3gain-1.4.6~/mpglibDBL/common.c 2007-07-28 22:22:50.000000000 +0200
++++ mp3gain-1.4.6/mpglibDBL/common.c 2007-07-28 22:22:53.000000000 +0200
+@@ -160,7 +160,7 @@
+ fprintf(stderr,"Stream error\n");
+ fclose(stdout);
+ fclose(stderr);
+- exit(0);
++ exit(EXIT_FAILURE);
+ }
+ if(fr->mpeg25) {
+ fr->sampling_frequency = 6 + ((newhead>>10)&0x3);
+diff -urNad mp3gain-1.4.6~/mpglibDBL/interface.c mp3gain-1.4.6/mpglibDBL/interface.c
+--- mp3gain-1.4.6~/mpglibDBL/interface.c 2007-07-28 22:22:50.000000000 +0200
++++ mp3gain-1.4.6/mpglibDBL/interface.c 2007-07-28 22:22:53.000000000 +0200
+@@ -137,7 +137,7 @@
+ fprintf(stderr,"Fatal error! tried to read past mp buffer\n");
+ fclose(stdout);
+ fclose(stderr);
+- exit(0);
++ exit(EXIT_FAILURE);
+ }
+ pos = mp->tail->pos;
+ }
--- mp3gain-1.4.6.orig/debian/patches/04_fix_segfault_for_48khz.dpatch
+++ mp3gain-1.4.6/debian/patches/04_fix_segfault_for_48khz.dpatch
@@ -0,0 +1,19 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## 04_fix_segfault_for_48khz.dpatch by Stefan Fritsch
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Fix buffer overflow for 48khz mp3s
+
+@DPATCH@
+diff -urNad mp3gain-1.4.6~/gain_analysis.c mp3gain-1.4.6/gain_analysis.c
+--- mp3gain-1.4.6~/gain_analysis.c 2006-04-06 22:22:35.000000000 +0200
++++ mp3gain-1.4.6/gain_analysis.c 2006-04-06 22:36:12.000000000 +0200
+@@ -111,7 +111,7 @@
+ #define MAX_dB 120. // Table entries for 0...MAX_dB (normal max. values are 70...80 dB)
+
+ #define MAX_ORDER (BUTTER_ORDER > YULE_ORDER ? BUTTER_ORDER : YULE_ORDER)
+-#define MAX_SAMPLES_PER_WINDOW (size_t) (MAX_SAMP_FREQ * RMS_WINDOW_TIME) // max. Samples per Time slice
++#define MAX_SAMPLES_PER_WINDOW (size_t) (MAX_SAMP_FREQ * RMS_WINDOW_TIME + 1) // max. Samples per Time slice
+ #define PINK_REF 64.82 //298640883795 // calibration value
+
+ Float_t linprebuf [MAX_ORDER * 2];
--- mp3gain-1.4.6.orig/debian/patches/00list
+++ mp3gain-1.4.6/debian/patches/00list
@@ -0,0 +1,7 @@
+01_fix_installdir.dpatch
+02_correct_errorcode_on_failure.dpatch
+03_use_tempfile_by_default.dpatch
+04_fix_segfault_for_48khz.dpatch
+05_fix_segfault_when_files_not_writable.dpatch
+06_fix_overwrite_query_loop.dpatch
+07_fix_CFLAGS.dpatch
--- mp3gain-1.4.6.orig/debian/copyright
+++ mp3gain-1.4.6/debian/copyright
@@ -0,0 +1,44 @@
+This package was debianized by Stefan Fritsch on
+Wed, 4 Feb 2004 21:33:28 +0100.
+
+Current maintainer email address is sf@sfritsch.de.
+
+It was downloaded from http://mp3gain.sourceforge.net/download.php
+
+Upstream Author: "Glen Sawyer"
+
+Copyright: 2001-2004 Glen Sawyer
+ 2002 John Zitterkopf
+ 2001 David Robinson
+ 2000 Mark Taylor
+ 2000 Don Melton
+ 1999 Takehiro TOMINAGA
+ 1999, 2000 Albert L. Faber
+ 1995,1996,1997 by Michael Hipp
+ Stefan Partheymüller
+ Artur Polaczynski
+ Frank Klemm
+ Mark Armbrust
+
+Concept and filter values by David Robinson
+
+
+
+ This package is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This package 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 package; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301,
+ USA.
+
+On Debian systems, the complete text of the GNU Lesser General
+Public License can be found in `/usr/share/common-licenses/LGPL'.
+