[SCM] flac/master: flac should not use locales when running with 'replaygain' option (Closes: #498050).
alessio at users.alioth.debian.org
alessio at users.alioth.debian.org
Sat Apr 16 10:13:33 UTC 2011
The following commit has been merged in the master branch:
commit f2cd05043b1e2668390218ba69049b67ccadf5fb
Author: Alessio Treglia <alessio at debian.org>
Date: Sat Apr 16 12:12:48 2011 +0200
flac should not use locales when running with 'replaygain' option (Closes: #498050).
diff --git a/debian/patches/13_replaygain_c_locale.patch b/debian/patches/13_replaygain_c_locale.patch
new file mode 100644
index 0000000..b242fe5
--- /dev/null
+++ b/debian/patches/13_replaygain_c_locale.patch
@@ -0,0 +1,63 @@
+From: hhaamu at gmail.com
+Description: flac should not use locales when running with 'replaygain' option.
+Bug-Debian: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=498050
+Forwarded: Bug: https://sourceforge.net/support/tracker.php?aid=3288157
+---
+ src/share/grabbag/replaygain.c | 32 +++++++++++++++++++++++++-------
+ 1 file changed, 25 insertions(+), 7 deletions(-)
+
+--- flac.orig/src/share/grabbag/replaygain.c
++++ flac/src/share/grabbag/replaygain.c
+@@ -625,6 +625,8 @@ static FLAC__bool parse_double_(const FL
+ FLAC__bool grabbag__replaygain_load_from_vorbiscomment(const FLAC__StreamMetadata *block, FLAC__bool album_mode, FLAC__bool strict, double *reference, double *gain, double *peak)
+ {
+ int reference_offset, gain_offset, peak_offset;
++ char *saved_locale;
++ FLAC__bool res = true;
+
+ FLAC__ASSERT(0 != block);
+ FLAC__ASSERT(0 != reference);
+@@ -637,20 +639,36 @@ FLAC__bool grabbag__replaygain_load_from
+ */
+ *reference = ReplayGainReferenceLoudness;
+
++ /*
++ * We need to save the old locale and switch to "C" because the locale
++ * influences the formatting of %f and we want it a certain way.
++ */
++ saved_locale = strdup(setlocale(LC_ALL, 0));
++ if (0 == saved_locale)
++ return false;
++ setlocale(LC_ALL, "C");
++
+ if(0 <= (reference_offset = FLAC__metadata_object_vorbiscomment_find_entry_from(block, /*offset=*/0, (const char *)GRABBAG__REPLAYGAIN_TAG_REFERENCE_LOUDNESS)))
+ (void)parse_double_(block->data.vorbis_comment.comments + reference_offset, reference);
+
+ if(0 > (gain_offset = FLAC__metadata_object_vorbiscomment_find_entry_from(block, /*offset=*/0, (const char *)(album_mode? GRABBAG__REPLAYGAIN_TAG_ALBUM_GAIN : GRABBAG__REPLAYGAIN_TAG_TITLE_GAIN))))
+- return !strict && grabbag__replaygain_load_from_vorbiscomment(block, !album_mode, /*strict=*/true, reference, gain, peak);
++ res = false;
+ if(0 > (peak_offset = FLAC__metadata_object_vorbiscomment_find_entry_from(block, /*offset=*/0, (const char *)(album_mode? GRABBAG__REPLAYGAIN_TAG_ALBUM_PEAK : GRABBAG__REPLAYGAIN_TAG_TITLE_PEAK))))
+- return !strict && grabbag__replaygain_load_from_vorbiscomment(block, !album_mode, /*strict=*/true, reference, gain, peak);
++ res = false;
++
++ if(res && !parse_double_(block->data.vorbis_comment.comments + gain_offset, gain))
++ res = false;
++ if(res && !parse_double_(block->data.vorbis_comment.comments + peak_offset, peak))
++ res = false;
++
++ setlocale(LC_ALL, saved_locale);
++ free(saved_locale);
+
+- if(!parse_double_(block->data.vorbis_comment.comments + gain_offset, gain))
+- return !strict && grabbag__replaygain_load_from_vorbiscomment(block, !album_mode, /*strict=*/true, reference, gain, peak);
+- if(!parse_double_(block->data.vorbis_comment.comments + peak_offset, peak))
+- return !strict && grabbag__replaygain_load_from_vorbiscomment(block, !album_mode, /*strict=*/true, reference, gain, peak);
++ /* something failed; retry with strict */
++ if (!res && !strict)
++ res = grabbag__replaygain_load_from_vorbiscomment(block, !album_mode, /*strict=*/true, reference, gain, peak);
+
+- return true;
++ return res;
+ }
+
+ double grabbag__replaygain_compute_scale_factor(double peak, double gain, double preamp, FLAC__bool prevent_clipping)
diff --git a/debian/patches/series b/debian/patches/series
index d0f0b1d..9a5048b 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -6,3 +6,4 @@
10_empty_-L_flag.patch
11_no-altivec-on-SPE.patch
12_ac_config_macro_dir.patch
+13_replaygain_c_locale.patch
--
flac packaging
More information about the pkg-multimedia-commits
mailing list