forked from len0rd/rockbox
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
This commit is contained in:
parent
442c0e663f
commit
ea7992455a
4 changed files with 41 additions and 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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
16
apps/misc.c
16
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
|
||||
|
|
|
|||
|
|
@ -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 */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue