summaryrefslogtreecommitdiff
path: root/apps/misc.c
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2012-04-30 16:27:01 -0400
committerMichael Sevakis <jethead71@rockbox.org>2012-04-30 22:47:37 +0200
commit57a20d2d638895fffe88a23cbd2960f1102b292f (patch)
treedf1943429ec040a18d854fa0a0091051e4200304 /apps/misc.c
parenta32cbf33465367cd6fe36d636da8d03485e9d15d (diff)
downloadrockbox-57a20d2d638895fffe88a23cbd2960f1102b292f.zip
rockbox-57a20d2d638895fffe88a23cbd2960f1102b292f.tar.gz
rockbox-57a20d2d638895fffe88a23cbd2960f1102b292f.tar.bz2
rockbox-57a20d2d638895fffe88a23cbd2960f1102b292f.tar.xz
Make DSP's replaygain independent of global_settings.
Moves replaygain definitions to lib/rbcodec/dsp/dsp_misc.h. Intermediate functions in misc.c handle any adjustment and calling the rbcodec APIs. Change-Id: I9f03561bca9aedd13760cf19c4e19aa3c68e7024 Reviewed-on: http://gerrit.rockbox.org/140 Reviewed-by: Michael Sevakis <jethead71@rockbox.org>
Diffstat (limited to 'apps/misc.c')
-rw-r--r--apps/misc.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/apps/misc.c b/apps/misc.c
index 3cb314f..3bee077 100644
--- a/apps/misc.c
+++ b/apps/misc.c
@@ -953,6 +953,45 @@ void keyclick_click(bool rawbutton, int action)
#endif
}
}
+
+/* Return the ReplayGain mode adjusted by other relevant settings */
+static int replaygain_setting_mode(int type)
+{
+ switch (type)
+ {
+ case REPLAYGAIN_SHUFFLE:
+ type = global_settings.playlist_shuffle ?
+ REPLAYGAIN_TRACK : REPLAYGAIN_ALBUM;
+ case REPLAYGAIN_ALBUM:
+ case REPLAYGAIN_TRACK:
+ case REPLAYGAIN_OFF:
+ default:
+ break;
+ }
+
+ return type;
+}
+
+/* Return the ReplayGain mode adjusted for display purposes */
+int id3_get_replaygain_mode(const struct mp3entry *id3)
+{
+ if (!id3)
+ return -1;
+
+ int type = global_settings.replaygain_settings.type;
+ type = replaygain_setting_mode(type);
+
+ return (type != REPLAYGAIN_TRACK && id3->album_gain != 0) ?
+ REPLAYGAIN_ALBUM : (id3->track_gain != 0 ? REPLAYGAIN_TRACK : -1);
+}
+
+/* Update DSP's replaygain from global settings */
+void replaygain_update(void)
+{
+ struct replaygain_settings settings = global_settings.replaygain_settings;
+ settings.type = replaygain_setting_mode(settings.type);
+ dsp_replaygain_set_settings(&settings);
+}
#endif /* CONFIG_CODEC == SWCODEC */
#endif /* !defined(__PCTOOL__) */