From 57a20d2d638895fffe88a23cbd2960f1102b292f Mon Sep 17 00:00:00 2001 From: Michael Sevakis Date: Mon, 30 Apr 2012 16:27:01 -0400 Subject: 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 --- apps/misc.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'apps/misc.c') 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__) */ -- cgit v1.1