diff options
| author | Magnus Holmgren <magnushol@gmail.com> | 2006-11-15 20:26:33 +0000 |
|---|---|---|
| committer | Magnus Holmgren <magnushol@gmail.com> | 2006-11-15 20:26:33 +0000 |
| commit | ea7992455a9704e2eb6bd6c9b39fabd111a7b997 (patch) | |
| tree | 44e4f25d4e21b4686e682754b1f3fbef2fcfe03f | |
| parent | 442c0e663f20dfd64e6d7d818ab13f444804ab5e (diff) | |
| download | rockbox-ea7992455a9704e2eb6bd6c9b39fabd111a7b997.zip rockbox-ea7992455a9704e2eb6bd6c9b39fabd111a7b997.tar.gz rockbox-ea7992455a9704e2eb6bd6c9b39fabd111a7b997.tar.bz2 rockbox-ea7992455a9704e2eb6bd6c9b39fabd111a7b997.tar.xz | |
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
| -rw-r--r-- | apps/dsp.c | 7 | ||||
| -rw-r--r-- | apps/gui/gwps-common.c | 50 | ||||
| -rw-r--r-- | apps/misc.c | 16 | ||||
| -rw-r--r-- | apps/misc.h | 8 |
4 files changed, 41 insertions, 40 deletions
@@ -26,6 +26,7 @@ #include "system.h" #include "settings.h" #include "replaygain.h" +#include "misc.h" #include "debug.h" #ifndef SIMULATOR @@ -1093,10 +1094,8 @@ void dsp_set_replaygain(bool always) if (global_settings.replaygain || global_settings.replaygain_noclip) { - bool track_mode - = ((global_settings.replaygain_type == REPLAYGAIN_TRACK) - || ((global_settings.replaygain_type == REPLAYGAIN_SHUFFLE) - && global_settings.playlist_shuffle)); + bool track_mode = get_replaygain_mode(dsp->track_gain != 0, + dsp->album_gain != 0) == REPLAYGAIN_TRACK; long peak = (track_mode || !dsp->album_peak) ? dsp->track_peak : dsp->album_peak; diff --git a/apps/gui/gwps-common.c b/apps/gui/gwps-common.c index 2e7b7ef..7e795ff 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, *intval = 1; /* off */ else { - switch (global_settings.replaygain_type) - { - case REPLAYGAIN_TRACK: /* track */ - if (id3->track_gain_string == NULL) - *intval = 6; /* no tag */ - else - *intval = 2; - break; - case REPLAYGAIN_ALBUM: /* album */ - if (id3->album_gain_string == NULL) - *intval = 6; /* no tag */ - else - *intval = 3; - break; - case REPLAYGAIN_SHUFFLE: /* shuffle */ - if (global_settings.playlist_shuffle) - { - if (id3->track_gain_string == NULL) - *intval = 6; /* no tag */ - else - *intval = 4; /* shuffle track */ - } - else - { - if (id3->album_gain_string == NULL) - *intval = 6; /* no tag */ - else - *intval = 5; /* shuffle album */ - } - break; - default: - *intval = 1; /* shoudn't happen, treat as off */ - break; - } /* switch - replay gain type */ - } /* if - replay gain set */ + int type = get_replaygain_mode( + id3->track_gain_string != NULL, + id3->album_gain_string != NULL); + + if (type < 0) + *intval = 6; /* no tag */ + else + *intval = type + 2; + + if (global_settings.replaygain_type == REPLAYGAIN_SHUFFLE) + *intval += 2; + } + switch (*intval) { case 1: case 6: - strncpy(buf, "+0.00 dB", buf_size); + return "+0.00 dB"; break; case 2: case 4: diff --git a/apps/misc.c b/apps/misc.c index 80c4588..709bc49 100644 --- a/apps/misc.c +++ b/apps/misc.c @@ -802,3 +802,19 @@ int show_logo( void ) return 0; } + +#if CONFIG_CODEC == SWCODEC +int get_replaygain_mode(bool have_track_gain, bool have_album_gain) +{ + int type; + + bool track = ((global_settings.replaygain_type == REPLAYGAIN_TRACK) + || ((global_settings.replaygain_type == REPLAYGAIN_SHUFFLE) + && global_settings.playlist_shuffle)); + + type = (!track && have_album_gain) ? REPLAYGAIN_ALBUM + : have_track_gain ? REPLAYGAIN_TRACK : -1; + + return type; +} +#endif diff --git a/apps/misc.h b/apps/misc.h index 6c660e0..f273631 100644 --- a/apps/misc.h +++ b/apps/misc.h @@ -82,4 +82,12 @@ long default_event_handler(long event); void car_adapter_mode_init(void); extern int show_logo(void); +#if CONFIG_CODEC == SWCODEC +/* Return current ReplayGain mode a file should have (REPLAYGAIN_TRACK or + * REPLAYGAIN_ALBUM) if ReplayGain processing is enabled, or -1 if no + * information present. + */ +int get_replaygain_mode(bool have_track_gain, bool have_album_gain); +#endif + #endif /* MISC_H */ |