summaryrefslogtreecommitdiff
path: root/apps/misc.c
diff options
context:
space:
mode:
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 3cb314fc51..3bee0772a6 100644
--- a/apps/misc.c
+++ b/apps/misc.c
@@ -953,6 +953,45 @@ void keyclick_click(bool rawbutton, int action)
953#endif 953#endif
954 } 954 }
955} 955}
956
957/* Return the ReplayGain mode adjusted by other relevant settings */
958static int replaygain_setting_mode(int type)
959{
960 switch (type)
961 {
962 case REPLAYGAIN_SHUFFLE:
963 type = global_settings.playlist_shuffle ?
964 REPLAYGAIN_TRACK : REPLAYGAIN_ALBUM;
965 case REPLAYGAIN_ALBUM:
966 case REPLAYGAIN_TRACK:
967 case REPLAYGAIN_OFF:
968 default:
969 break;
970 }
971
972 return type;
973}
974
975/* Return the ReplayGain mode adjusted for display purposes */
976int id3_get_replaygain_mode(const struct mp3entry *id3)
977{
978 if (!id3)
979 return -1;
980
981 int type = global_settings.replaygain_settings.type;
982 type = replaygain_setting_mode(type);
983
984 return (type != REPLAYGAIN_TRACK && id3->album_gain != 0) ?
985 REPLAYGAIN_ALBUM : (id3->track_gain != 0 ? REPLAYGAIN_TRACK : -1);
986}
987
988/* Update DSP's replaygain from global settings */
989void replaygain_update(void)
990{
991 struct replaygain_settings settings = global_settings.replaygain_settings;
992 settings.type = replaygain_setting_mode(settings.type);
993 dsp_replaygain_set_settings(&settings);
994}
956#endif /* CONFIG_CODEC == SWCODEC */ 995#endif /* CONFIG_CODEC == SWCODEC */
957 996
958#endif /* !defined(__PCTOOL__) */ 997#endif /* !defined(__PCTOOL__) */