summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorMagnus Holmgren <magnushol@gmail.com>2006-11-15 20:26:33 +0000
committerMagnus Holmgren <magnushol@gmail.com>2006-11-15 20:26:33 +0000
commitea7992455a9704e2eb6bd6c9b39fabd111a7b997 (patch)
tree44e4f25d4e21b4686e682754b1f3fbef2fcfe03f /apps
parent442c0e663f20dfd64e6d7d818ab13f444804ab5e (diff)
downloadrockbox-ea7992455a9704e2eb6bd6c9b39fabd111a7b997.tar.gz
rockbox-ea7992455a9704e2eb6bd6c9b39fabd111a7b997.zip
Make the updated %rg tag match playback behaviour (fall back to track gain if album gain requested but not available). Share the mode decision logic with playback code and simplify the %rg tag handling.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@11532 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r--apps/dsp.c7
-rw-r--r--apps/gui/gwps-common.c50
-rw-r--r--apps/misc.c16
-rw-r--r--apps/misc.h8
4 files changed, 41 insertions, 40 deletions
diff --git a/apps/dsp.c b/apps/dsp.c
index 94e825c532..5627b05bca 100644
--- a/apps/dsp.c
+++ b/apps/dsp.c
@@ -26,6 +26,7 @@
26#include "system.h" 26#include "system.h"
27#include "settings.h" 27#include "settings.h"
28#include "replaygain.h" 28#include "replaygain.h"
29#include "misc.h"
29#include "debug.h" 30#include "debug.h"
30 31
31#ifndef SIMULATOR 32#ifndef SIMULATOR
@@ -1093,10 +1094,8 @@ void dsp_set_replaygain(bool always)
1093 1094
1094 if (global_settings.replaygain || global_settings.replaygain_noclip) 1095 if (global_settings.replaygain || global_settings.replaygain_noclip)
1095 { 1096 {
1096 bool track_mode 1097 bool track_mode = get_replaygain_mode(dsp->track_gain != 0,
1097 = ((global_settings.replaygain_type == REPLAYGAIN_TRACK) 1098 dsp->album_gain != 0) == REPLAYGAIN_TRACK;
1098 || ((global_settings.replaygain_type == REPLAYGAIN_SHUFFLE)
1099 && global_settings.playlist_shuffle));
1100 long peak = (track_mode || !dsp->album_peak) 1099 long peak = (track_mode || !dsp->album_peak)
1101 ? dsp->track_peak : dsp->album_peak; 1100 ? dsp->track_peak : dsp->album_peak;
1102 1101
diff --git a/apps/gui/gwps-common.c b/apps/gui/gwps-common.c
index 2e7b7ef09c..7e795ffd96 100644
--- a/apps/gui/gwps-common.c
+++ b/apps/gui/gwps-common.c
@@ -941,46 +941,24 @@ static char* get_tag(struct wps_data* wps_data,
941 *intval = 1; /* off */ 941 *intval = 1; /* off */
942 else 942 else
943 { 943 {
944 switch (global_settings.replaygain_type) 944 int type = get_replaygain_mode(
945 { 945 id3->track_gain_string != NULL,
946 case REPLAYGAIN_TRACK: /* track */ 946 id3->album_gain_string != NULL);
947 if (id3->track_gain_string == NULL) 947
948 *intval = 6; /* no tag */ 948 if (type < 0)
949 else 949 *intval = 6; /* no tag */
950 *intval = 2; 950 else
951 break; 951 *intval = type + 2;
952 case REPLAYGAIN_ALBUM: /* album */ 952
953 if (id3->album_gain_string == NULL) 953 if (global_settings.replaygain_type == REPLAYGAIN_SHUFFLE)
954 *intval = 6; /* no tag */ 954 *intval += 2;
955 else 955 }
956 *intval = 3; 956
957 break;
958 case REPLAYGAIN_SHUFFLE: /* shuffle */
959 if (global_settings.playlist_shuffle)
960 {
961 if (id3->track_gain_string == NULL)
962 *intval = 6; /* no tag */
963 else
964 *intval = 4; /* shuffle track */
965 }
966 else
967 {
968 if (id3->album_gain_string == NULL)
969 *intval = 6; /* no tag */
970 else
971 *intval = 5; /* shuffle album */
972 }
973 break;
974 default:
975 *intval = 1; /* shoudn't happen, treat as off */
976 break;
977 } /* switch - replay gain type */
978 } /* if - replay gain set */
979 switch (*intval) 957 switch (*intval)
980 { 958 {
981 case 1: 959 case 1:
982 case 6: 960 case 6:
983 strncpy(buf, "+0.00 dB", buf_size); 961 return "+0.00 dB";
984 break; 962 break;
985 case 2: 963 case 2:
986 case 4: 964 case 4:
diff --git a/apps/misc.c b/apps/misc.c
index 80c4588f0f..709bc49208 100644
--- a/apps/misc.c
+++ b/apps/misc.c
@@ -802,3 +802,19 @@ int show_logo( void )
802 802
803 return 0; 803 return 0;
804} 804}
805
806#if CONFIG_CODEC == SWCODEC
807int get_replaygain_mode(bool have_track_gain, bool have_album_gain)
808{
809 int type;
810
811 bool track = ((global_settings.replaygain_type == REPLAYGAIN_TRACK)
812 || ((global_settings.replaygain_type == REPLAYGAIN_SHUFFLE)
813 && global_settings.playlist_shuffle));
814
815 type = (!track && have_album_gain) ? REPLAYGAIN_ALBUM
816 : have_track_gain ? REPLAYGAIN_TRACK : -1;
817
818 return type;
819}
820#endif
diff --git a/apps/misc.h b/apps/misc.h
index 6c660e0a5e..f273631030 100644
--- a/apps/misc.h
+++ b/apps/misc.h
@@ -82,4 +82,12 @@ long default_event_handler(long event);
82void car_adapter_mode_init(void); 82void car_adapter_mode_init(void);
83extern int show_logo(void); 83extern int show_logo(void);
84 84
85#if CONFIG_CODEC == SWCODEC
86/* Return current ReplayGain mode a file should have (REPLAYGAIN_TRACK or
87 * REPLAYGAIN_ALBUM) if ReplayGain processing is enabled, or -1 if no
88 * information present.
89 */
90int get_replaygain_mode(bool have_track_gain, bool have_album_gain);
91#endif
92
85#endif /* MISC_H */ 93#endif /* MISC_H */