changeset 2991:2cdf6400594c

flacng: enable replaygain
author Teemu Torma <teemu@torma.org>
date Tue, 10 Feb 2009 23:56:41 +0100
parents be86c72a06c9
children 2a4eb326eb1d
files src/flacng/plugin.c src/flacng/tools.c src/flacng/tools.h
diffstat 3 files changed, 33 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/flacng/plugin.c	Fri Feb 06 14:10:52 2009 +0200
+++ b/src/flacng/plugin.c	Tue Feb 10 23:56:41 2009 +0100
@@ -331,6 +331,9 @@
     stream_info.channels = main_info->stream.channels;
     main_info->metadata_changed = FALSE;
 
+    ReplayGainInfo rg_info = get_replay_gain(main_info);
+    playback->set_replaygain_info(playback, &rg_info);
+
     if (!playback->output->open_audio(SAMPLE_FMT(main_info->stream.bits_per_sample),
                                       main_info->stream.samplerate,
                                       main_info->stream.channels)) {
--- a/src/flacng/tools.c	Fri Feb 06 14:10:52 2009 +0200
+++ b/src/flacng/tools.c	Tue Feb 10 23:56:41 2009 +0100
@@ -400,3 +400,32 @@
 
     _LEAVE;
 }
+
+/* --- */
+
+ReplayGainInfo get_replay_gain(callback_info *info) {
+
+    ReplayGainInfo rg;
+    
+    if (info->replaygain.has_rg) {
+	rg.track_gain = (info->replaygain.track_gain
+			 ? atof(info->replaygain.track_gain)
+			 : 0.0);
+	rg.track_peak = (info->replaygain.track_peak
+			 ? atof(info->replaygain.track_peak)
+			 : 0.0);
+	rg.album_gain = (info->replaygain.album_gain
+			 ? atof(info->replaygain.album_gain)
+			 : 0.0);
+	rg.album_peak = (info->replaygain.album_peak
+			 ? atof(info->replaygain.album_peak)
+			 : 0.0);
+    } else {
+	rg.track_gain = 0.0;
+	rg.track_peak = 0.0;
+	rg.album_gain = 0.0;
+	rg.album_peak = 0.0;
+    }
+
+    return rg;
+}
--- a/src/flacng/tools.h	Fri Feb 06 14:10:52 2009 +0200
+++ b/src/flacng/tools.h	Tue Feb 10 23:56:41 2009 +0100
@@ -46,5 +46,6 @@
 Tuple *get_tuple(const gchar *filename, callback_info* info);
 void add_comment(callback_info* info, gchar* key, gchar* value);
 gboolean read_metadata(VFSFile* fd, FLAC__StreamDecoder* decoder, callback_info* info);
+ReplayGainInfo get_replay_gain(callback_info *info);
 
 #endif