aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/decoder/_flac_common.c14
-rw-r--r--src/decoder/_flac_common.h2
-rw-r--r--src/decoder/flac_plugin.c2
-rw-r--r--src/decoder/mp3_plugin.c47
-rw-r--r--src/decoder/mpc_plugin.c14
-rw-r--r--src/decoder/oggflac_plugin.c2
-rw-r--r--src/decoder/oggvorbis_plugin.c22
-rw-r--r--src/decoder/wavpack_plugin.c22
-rw-r--r--src/decoder_api.c6
-rw-r--r--src/decoder_api.h2
-rw-r--r--src/main.c2
-rw-r--r--src/replay_gain.c61
-rw-r--r--src/replay_gain.h34
13 files changed, 119 insertions, 111 deletions
diff --git a/src/decoder/_flac_common.c b/src/decoder/_flac_common.c
index a8a856755..3df7d24e5 100644
--- a/src/decoder/_flac_common.c
+++ b/src/decoder/_flac_common.c
@@ -70,21 +70,21 @@ static void flacParseReplayGain(const FLAC__StreamMetadata * block,
int found = 0;
if (data->replayGainInfo)
- freeReplayGainInfo(data->replayGainInfo);
+ replay_gain_info_free(data->replayGainInfo);
- data->replayGainInfo = newReplayGainInfo();
+ data->replayGainInfo = replay_gain_info_new();
found |= flacFindVorbisCommentFloat(block, "replaygain_album_gain",
- &data->replayGainInfo->albumGain);
+ &data->replayGainInfo->album_gain);
found |= flacFindVorbisCommentFloat(block, "replaygain_album_peak",
- &data->replayGainInfo->albumPeak);
+ &data->replayGainInfo->album_peak);
found |= flacFindVorbisCommentFloat(block, "replaygain_track_gain",
- &data->replayGainInfo->trackGain);
+ &data->replayGainInfo->track_gain);
found |= flacFindVorbisCommentFloat(block, "replaygain_track_peak",
- &data->replayGainInfo->trackPeak);
+ &data->replayGainInfo->track_peak);
if (!found) {
- freeReplayGainInfo(data->replayGainInfo);
+ replay_gain_info_free(data->replayGainInfo);
data->replayGainInfo = NULL;
}
}
diff --git a/src/decoder/_flac_common.h b/src/decoder/_flac_common.h
index c1c648a62..37465a216 100644
--- a/src/decoder/_flac_common.h
+++ b/src/decoder/_flac_common.h
@@ -145,7 +145,7 @@ typedef struct {
FLAC__uint64 position;
struct decoder *decoder;
struct input_stream *inStream;
- ReplayGainInfo *replayGainInfo;
+ struct replay_gain_info *replayGainInfo;
struct tag *tag;
} FlacData;
diff --git a/src/decoder/flac_plugin.c b/src/decoder/flac_plugin.c
index ad64b7355..c6421031b 100644
--- a/src/decoder/flac_plugin.c
+++ b/src/decoder/flac_plugin.c
@@ -368,7 +368,7 @@ flac_decode_internal(struct decoder * decoder, struct input_stream *inStream,
fail:
if (data.replayGainInfo)
- freeReplayGainInfo(data.replayGainInfo);
+ replay_gain_info_free(data.replayGainInfo);
if (flacDec)
flac_delete(flacDec);
diff --git a/src/decoder/mp3_plugin.c b/src/decoder/mp3_plugin.c
index cf46ac166..602c9e2f9 100644
--- a/src/decoder/mp3_plugin.c
+++ b/src/decoder/mp3_plugin.c
@@ -204,16 +204,17 @@ mp3_fill_buffer(struct mp3_data *data)
}
#ifdef HAVE_ID3TAG
-static ReplayGainInfo *parse_id3_replay_gain_info(struct id3_tag *tag)
+static struct replay_gain_info *
+parse_id3_replay_gain_info(struct id3_tag *tag)
{
int i;
char *key;
char *value;
struct id3_frame *frame;
bool found = false;
- ReplayGainInfo *replay_gain_info;
+ struct replay_gain_info *replay_gain_info;
- replay_gain_info = newReplayGainInfo();
+ replay_gain_info = replay_gain_info_new();
for (i = 0; (frame = id3_tag_findframe(tag, "TXXX", i)); i++) {
if (frame->nfields < 3)
@@ -227,16 +228,16 @@ static ReplayGainInfo *parse_id3_replay_gain_info(struct id3_tag *tag)
(&frame->fields[2]));
if (strcasecmp(key, "replaygain_track_gain") == 0) {
- replay_gain_info->trackGain = atof(value);
+ replay_gain_info->track_gain = atof(value);
found = true;
} else if (strcasecmp(key, "replaygain_album_gain") == 0) {
- replay_gain_info->albumGain = atof(value);
+ replay_gain_info->album_gain = atof(value);
found = true;
} else if (strcasecmp(key, "replaygain_track_peak") == 0) {
- replay_gain_info->trackPeak = atof(value);
+ replay_gain_info->track_peak = atof(value);
found = true;
} else if (strcasecmp(key, "replaygain_album_peak") == 0) {
- replay_gain_info->albumPeak = atof(value);
+ replay_gain_info->album_peak = atof(value);
found = true;
}
@@ -246,7 +247,7 @@ static ReplayGainInfo *parse_id3_replay_gain_info(struct id3_tag *tag)
if (found)
return replay_gain_info;
- freeReplayGainInfo(replay_gain_info);
+ replay_gain_info_free(replay_gain_info);
return NULL;
}
#endif
@@ -254,7 +255,7 @@ static ReplayGainInfo *parse_id3_replay_gain_info(struct id3_tag *tag)
#ifdef HAVE_ID3TAG
static void mp3_parse_id3(struct mp3_data *data, size_t tagsize,
struct tag **mpd_tag,
- ReplayGainInfo **replay_gain_info_r)
+ struct replay_gain_info **replay_gain_info_r)
{
struct id3_tag *id3_tag = NULL;
id3_length_t count;
@@ -307,10 +308,11 @@ static void mp3_parse_id3(struct mp3_data *data, size_t tagsize,
}
if (replay_gain_info_r) {
- ReplayGainInfo *tmp_rgi = parse_id3_replay_gain_info(id3_tag);
+ struct replay_gain_info *tmp_rgi =
+ parse_id3_replay_gain_info(id3_tag);
if (tmp_rgi != NULL) {
if (*replay_gain_info_r)
- freeReplayGainInfo(*replay_gain_info_r);
+ replay_gain_info_free(*replay_gain_info_r);
*replay_gain_info_r = tmp_rgi;
}
}
@@ -323,7 +325,7 @@ static void mp3_parse_id3(struct mp3_data *data, size_t tagsize,
static enum mp3_action
decode_next_frame_header(struct mp3_data *data, struct tag **tag,
- ReplayGainInfo **replay_gain_info_r)
+ struct replay_gain_info **replay_gain_info_r)
{
enum mad_layer layer;
@@ -698,7 +700,7 @@ mp3_filesize_to_song_length(struct mp3_data *data)
static bool
mp3_decode_first_frame(struct mp3_data *data, struct tag **tag,
- ReplayGainInfo **replay_gain_info_r)
+ struct replay_gain_info **replay_gain_info_r)
{
struct decoder *decoder = data->decoder;
struct xing xing;
@@ -758,9 +760,9 @@ mp3_decode_first_frame(struct mp3_data *data, struct tag **tag,
* parse_lame() for details. -- jat */
if (replay_gain_info_r && !*replay_gain_info_r &&
lame.track_gain) {
- *replay_gain_info_r = newReplayGainInfo();
- (*replay_gain_info_r)->trackGain = lame.track_gain;
- (*replay_gain_info_r)->trackPeak = lame.peak;
+ *replay_gain_info_r = replay_gain_info_new();
+ (*replay_gain_info_r)->track_gain = lame.track_gain;
+ (*replay_gain_info_r)->track_peak = lame.peak;
}
}
}
@@ -813,7 +815,7 @@ static int mp3_total_file_time(const char *file)
static bool
mp3_open(struct input_stream *is, struct mp3_data *data,
struct decoder *decoder, struct tag **tag,
- ReplayGainInfo **replay_gain_info_r)
+ struct replay_gain_info **replay_gain_info_r)
{
mp3_data_init(data, decoder, is);
*tag = NULL;
@@ -877,7 +879,7 @@ mp3_update_timer_next_frame(struct mp3_data *data)
*/
static enum decoder_command
mp3_send_pcm(struct mp3_data *data, unsigned i, unsigned pcm_length,
- ReplayGainInfo *replay_gain_info)
+ struct replay_gain_info *replay_gain_info)
{
unsigned max_samples;
@@ -916,7 +918,8 @@ mp3_send_pcm(struct mp3_data *data, unsigned i, unsigned pcm_length,
* Synthesize the current frame and send it via decoder_data().
*/
static enum decoder_command
-mp3_synth_and_send(struct mp3_data *data, ReplayGainInfo *replay_gain_info)
+mp3_synth_and_send(struct mp3_data *data,
+ struct replay_gain_info *replay_gain_info)
{
unsigned i, pcm_length;
enum decoder_command cmd;
@@ -971,7 +974,7 @@ mp3_synth_and_send(struct mp3_data *data, ReplayGainInfo *replay_gain_info)
}
static bool
-mp3_read(struct mp3_data *data, ReplayGainInfo **replay_gain_info_r)
+mp3_read(struct mp3_data *data, struct replay_gain_info **replay_gain_info_r)
{
struct decoder *decoder = data->decoder;
int ret;
@@ -1052,7 +1055,7 @@ mp3_decode(struct decoder *decoder, struct input_stream *input_stream)
{
struct mp3_data data;
struct tag *tag = NULL;
- ReplayGainInfo *replay_gain_info = NULL;
+ struct replay_gain_info *replay_gain_info = NULL;
struct audio_format audio_format;
if (!mp3_open(input_stream, &data, decoder, &tag, &replay_gain_info)) {
@@ -1077,7 +1080,7 @@ mp3_decode(struct decoder *decoder, struct input_stream *input_stream)
while (mp3_read(&data, &replay_gain_info)) ;
if (replay_gain_info)
- freeReplayGainInfo(replay_gain_info);
+ replay_gain_info_free(replay_gain_info);
if (decoder_get_command(decoder) == DECODE_COMMAND_SEEK &&
data.mute_frame == MUTEFRAME_SEEK)
diff --git a/src/decoder/mpc_plugin.c b/src/decoder/mpc_plugin.c
index a9917d9f9..6bb1d4f59 100644
--- a/src/decoder/mpc_plugin.c
+++ b/src/decoder/mpc_plugin.c
@@ -120,7 +120,7 @@ mpc_decode(struct decoder *mpd_decoder, struct input_stream *inStream)
mpc_uint32_t vbrUpdateBits;
float total_time;
int i;
- ReplayGainInfo *replayGainInfo = NULL;
+ struct replay_gain_info *replayGainInfo = NULL;
data.inStream = inStream;
data.decoder = mpd_decoder;
@@ -156,11 +156,11 @@ mpc_decode(struct decoder *mpd_decoder, struct input_stream *inStream)
audio_format.channels = info.channels;
audio_format.sample_rate = info.sample_freq;
- replayGainInfo = newReplayGainInfo();
- replayGainInfo->albumGain = info.gain_album * 0.01;
- replayGainInfo->albumPeak = info.peak_album / 32767.0;
- replayGainInfo->trackGain = info.gain_title * 0.01;
- replayGainInfo->trackPeak = info.peak_title / 32767.0;
+ replayGainInfo = replay_gain_info_new();
+ replayGainInfo->album_gain = info.gain_album * 0.01;
+ replayGainInfo->album_peak = info.peak_album / 32767.0;
+ replayGainInfo->track_gain = info.gain_title * 0.01;
+ replayGainInfo->track_peak = info.peak_title / 32767.0;
decoder_initialized(mpd_decoder, &audio_format,
inStream->seekable,
@@ -231,7 +231,7 @@ mpc_decode(struct decoder *mpd_decoder, struct input_stream *inStream)
replayGainInfo);
}
- freeReplayGainInfo(replayGainInfo);
+ replay_gain_info_free(replayGainInfo);
return true;
}
diff --git a/src/decoder/oggflac_plugin.c b/src/decoder/oggflac_plugin.c
index c117cf3d2..17770a2a7 100644
--- a/src/decoder/oggflac_plugin.c
+++ b/src/decoder/oggflac_plugin.c
@@ -31,7 +31,7 @@ static void oggflac_cleanup(FlacData * data,
OggFLAC__SeekableStreamDecoder * decoder)
{
if (data->replayGainInfo)
- freeReplayGainInfo(data->replayGainInfo);
+ replay_gain_info_free(data->replayGainInfo);
if (decoder)
OggFLAC__seekable_stream_decoder_delete(decoder);
}
diff --git a/src/decoder/oggvorbis_plugin.c b/src/decoder/oggvorbis_plugin.c
index cc6f8f119..d73a5f7f5 100644
--- a/src/decoder/oggvorbis_plugin.c
+++ b/src/decoder/oggvorbis_plugin.c
@@ -93,31 +93,33 @@ static const char *ogg_parseComment(const char *comment, const char *needle)
return NULL;
}
-static void ogg_getReplayGainInfo(char **comments, ReplayGainInfo ** infoPtr)
+static void
+ogg_getReplayGainInfo(char **comments,
+ struct replay_gain_info **infoPtr)
{
const char *temp;
bool found = false;
if (*infoPtr)
- freeReplayGainInfo(*infoPtr);
- *infoPtr = newReplayGainInfo();
+ replay_gain_info_free(*infoPtr);
+ *infoPtr = replay_gain_info_new();
while (*comments) {
if ((temp =
ogg_parseComment(*comments, "replaygain_track_gain"))) {
- (*infoPtr)->trackGain = atof(temp);
+ (*infoPtr)->track_gain = atof(temp);
found = true;
} else if ((temp = ogg_parseComment(*comments,
"replaygain_album_gain"))) {
- (*infoPtr)->albumGain = atof(temp);
+ (*infoPtr)->album_gain = atof(temp);
found = true;
} else if ((temp = ogg_parseComment(*comments,
"replaygain_track_peak"))) {
- (*infoPtr)->trackPeak = atof(temp);
+ (*infoPtr)->track_peak = atof(temp);
found = true;
} else if ((temp = ogg_parseComment(*comments,
"replaygain_album_peak"))) {
- (*infoPtr)->albumPeak = atof(temp);
+ (*infoPtr)->album_peak = atof(temp);
found = true;
}
@@ -125,7 +127,7 @@ static void ogg_getReplayGainInfo(char **comments, ReplayGainInfo ** infoPtr)
}
if (!found) {
- freeReplayGainInfo(*infoPtr);
+ replay_gain_info_free(*infoPtr);
*infoPtr = NULL;
}
}
@@ -209,7 +211,7 @@ oggvorbis_decode(struct decoder *decoder, struct input_stream *inStream)
int chunkpos = 0;
long bitRate = 0;
long test;
- ReplayGainInfo *replayGainInfo = NULL;
+ struct replay_gain_info *replayGainInfo = NULL;
char **comments;
const char *errorStr;
bool initialized = false;
@@ -324,7 +326,7 @@ oggvorbis_decode(struct decoder *decoder, struct input_stream *inStream)
}
if (replayGainInfo)
- freeReplayGainInfo(replayGainInfo);
+ replay_gain_info_free(replayGainInfo);
ov_clear(&vf);
return true;
diff --git a/src/decoder/wavpack_plugin.c b/src/decoder/wavpack_plugin.c
index 1dc496648..d76f46974 100644
--- a/src/decoder/wavpack_plugin.c
+++ b/src/decoder/wavpack_plugin.c
@@ -121,7 +121,7 @@ format_samples_float(mpd_unused int bytes_per_sample, void *buffer,
*/
static void
wavpack_decode(struct decoder * decoder, WavpackContext *wpc, bool canseek,
- ReplayGainInfo *replayGainInfo)
+ struct replay_gain_info *replayGainInfo)
{
struct audio_format audio_format;
void (*format_samples)(int bytes_per_sample,
@@ -229,43 +229,43 @@ wavpack_tag(WavpackContext *wpc, char *key)
return value;
}
-static ReplayGainInfo *
+static struct replay_gain_info *
wavpack_replaygain(WavpackContext *wpc)
{
static char replaygain_track_gain[] = "replaygain_track_gain";
static char replaygain_album_gain[] = "replaygain_album_gain";
static char replaygain_track_peak[] = "replaygain_track_peak";
static char replaygain_album_peak[] = "replaygain_album_peak";
- ReplayGainInfo *replay_gain_info;
+ struct replay_gain_info *replay_gain_info;
bool found = false;
char *value;
- replay_gain_info = newReplayGainInfo();
+ replay_gain_info = replay_gain_info_new();
value = wavpack_tag(wpc, replaygain_track_gain);
if (value) {
- replay_gain_info->trackGain = atof(value);
+ replay_gain_info->track_gain = atof(value);
free(value);
found = true;
}
value = wavpack_tag(wpc, replaygain_album_gain);
if (value) {
- replay_gain_info->albumGain = atof(value);
+ replay_gain_info->album_gain = atof(value);
free(value);
found = true;
}
value = wavpack_tag(wpc, replaygain_track_peak);
if (value) {
- replay_gain_info->trackPeak = atof(value);
+ replay_gain_info->track_peak = atof(value);
free(value);
found = true;
}
value = wavpack_tag(wpc, replaygain_album_peak);
if (value) {
- replay_gain_info->albumPeak = atof(value);
+ replay_gain_info->album_peak = atof(value);
free(value);
found = true;
}
@@ -275,7 +275,7 @@ wavpack_replaygain(WavpackContext *wpc)
return replay_gain_info;
}
- freeReplayGainInfo(replay_gain_info);
+ replay_gain_info_free(replay_gain_info);
return NULL;
}
@@ -537,7 +537,7 @@ wavpack_filedecode(struct decoder *decoder, const char *fname)
{
char error[ERRORLEN];
WavpackContext *wpc;
- ReplayGainInfo *replay_gain_info;
+ struct replay_gain_info *replay_gain_info;
wpc = WavpackOpenFileInput(fname, error,
OPEN_TAGS | OPEN_WVC |
@@ -553,7 +553,7 @@ wavpack_filedecode(struct decoder *decoder, const char *fname)
wavpack_decode(decoder, wpc, true, replay_gain_info);
if (replay_gain_info) {
- freeReplayGainInfo(replay_gain_info);
+ replay_gain_info_free(replay_gain_info);
}
WavpackCloseFile(wpc);
diff --git a/src/decoder_api.c b/src/decoder_api.c
index d60dbb8d2..25616e569 100644
--- a/src/decoder_api.c
+++ b/src/decoder_api.c
@@ -175,7 +175,7 @@ decoder_data(struct decoder *decoder,
struct input_stream *is,
void *_data, size_t length,
float data_time, uint16_t bitRate,
- ReplayGainInfo *replay_gain_info)
+ struct replay_gain_info *replay_gain_info)
{
static char *conv_buffer;
static size_t conv_buffer_size;
@@ -234,8 +234,8 @@ decoder_data(struct decoder *decoder,
data, &decoder->conv_state);
}
- if (replay_gain_info != NULL && (replayGainState != REPLAYGAIN_OFF))
- doReplayGain(replay_gain_info, data, length,
+ if (replay_gain_info != NULL && (replay_gain_mode != REPLAY_GAIN_OFF))
+ replay_gain_apply(replay_gain_info, data, length,
&dc.out_audio_format);
else if (normalizationEnabled)
normalizeData(data, length, &dc.out_audio_format);
diff --git a/src/decoder_api.h b/src/decoder_api.h
index 88b3ea5c5..3e72d7a2c 100644
--- a/src/decoder_api.h
+++ b/src/decoder_api.h
@@ -143,7 +143,7 @@ enum decoder_command
decoder_data(struct decoder *decoder,
struct input_stream *inStream,
void *data, size_t datalen, float data_time, uint16_t bitRate,
- ReplayGainInfo * replayGainInfo);
+ struct replay_gain_info *replay_gain_info);
/**
* This function is called by the decoder plugin when it has
diff --git a/src/main.c b/src/main.c
index 2555aa30a..a42655f68 100644
--- a/src/main.c
+++ b/src/main.c
@@ -429,7 +429,7 @@ int main(int argc, char *argv[])
initAudioDriver();
initVolume();
client_manager_init();
- initReplayGainState();
+ replay_gain_global_init();
initNormalization();
input_stream_global_init();
diff --git a/src/replay_gain.c b/src/replay_gain.c
index 094c1c4f7..b9b2fe276 100644
--- a/src/replay_gain.c
+++ b/src/replay_gain.c
@@ -26,11 +26,11 @@
#include "os_compat.h"
/* Added 4/14/2004 by AliasMrJones */
-int replayGainState = REPLAYGAIN_OFF;
+int replay_gain_mode = REPLAY_GAIN_OFF;
-static float replayGainPreamp = 1.0;
+static float replay_gain_preamp = 1.0;
-void initReplayGainState(void)
+void replay_gain_global_init(void)
{
ConfigParam *param = getConfigParam(CONF_REPLAYGAIN);
@@ -38,9 +38,9 @@ void initReplayGainState(void)
return;
if (strcmp(param->value, "track") == 0) {
- replayGainState = REPLAYGAIN_TRACK;
+ replay_gain_mode = REPLAY_GAIN_TRACK;
} else if (strcmp(param->value, "album") == 0) {
- replayGainState = REPLAYGAIN_ALBUM;
+ replay_gain_mode = REPLAY_GAIN_ALBUM;
} else {
FATAL("replaygain value \"%s\" at line %i is invalid\n",
param->value, param->line);
@@ -62,18 +62,18 @@ void initReplayGainState(void)
"15 at line %i\n", param->value, param->line);
}
- replayGainPreamp = pow(10, f / 20.0);
+ replay_gain_preamp = pow(10, f / 20.0);
}
}
-static float computeReplayGainScale(float gain, float peak)
+static float calc_replay_gain_scale(float gain, float peak)
{
float scale;
if (gain == 0.0)
return (1);
scale = pow(10.0, gain / 20.0);
- scale *= replayGainPreamp;
+ scale *= replay_gain_preamp;
if (scale > 15.0)
scale = 15.0;
@@ -83,28 +83,29 @@ static float computeReplayGainScale(float gain, float peak)
return (scale);
}
-ReplayGainInfo *newReplayGainInfo(void)
+struct replay_gain_info *replay_gain_info_new(void)
{
- ReplayGainInfo *ret = xmalloc(sizeof(ReplayGainInfo));
+ struct replay_gain_info *ret = xmalloc(sizeof(*ret));
- ret->albumGain = 0.0;
- ret->albumPeak = 0.0;
+ ret->album_gain = 0.0;
+ ret->album_peak = 0.0;
- ret->trackGain = 0.0;
- ret->trackPeak = 0.0;
+ ret->track_gain = 0.0;
+ ret->track_peak = 0.0;
- /* set to -1 so that we know in doReplayGain to compute the scale */
+ /* set to -1 so that we know in replay_gain_apply to compute the scale */
ret->scale = -1.0;
return ret;
}
-void freeReplayGainInfo(ReplayGainInfo * info)
+void replay_gain_info_free(struct replay_gain_info *info)
{
free(info);
}
-void doReplayGain(ReplayGainInfo * info, char *buffer, int bufferSize,
+void
+replay_gain_apply(struct replay_gain_info *info, char *buffer, int size,
const struct audio_format *format)
{
int16_t *buffer16;
@@ -112,22 +113,22 @@ void doReplayGain(ReplayGainInfo * info, char *buffer, int bufferSize,
int32_t temp32;
float scale;
- if (replayGainState == REPLAYGAIN_OFF || !info)
+ if (replay_gain_mode == REPLAY_GAIN_OFF || !info)
return;
if (info->scale < 0) {
- switch (replayGainState) {
- case REPLAYGAIN_TRACK:
+ switch (replay_gain_mode) {
+ case REPLAY_GAIN_TRACK:
DEBUG("computing ReplayGain track scale with gain %f, "
- "peak %f\n", info->trackGain, info->trackPeak);
- info->scale = computeReplayGainScale(info->trackGain,
- info->trackPeak);
+ "peak %f\n", info->track_gain, info->track_peak);
+ info->scale = calc_replay_gain_scale(info->track_gain,
+ info->track_peak);
break;
default:
DEBUG("computing ReplayGain album scale with gain %f, "
- "peak %f\n", info->albumGain, info->albumPeak);
- info->scale = computeReplayGainScale(info->albumGain,
- info->albumPeak);
+ "peak %f\n", info->album_gain, info->album_peak);
+ info->scale = calc_replay_gain_scale(info->album_gain,
+ info->album_peak);
break;
}
}
@@ -142,23 +143,23 @@ void doReplayGain(ReplayGainInfo * info, char *buffer, int bufferSize,
switch (format->bits) {
case 16:
- while (bufferSize > 0) {
+ while (size > 0) {
temp32 = *buffer16;
temp32 *= scale;
*buffer16 = temp32 > 32767 ? 32767 :
(temp32 < -32768 ? -32768 : temp32);
buffer16++;
- bufferSize -= 2;
+ size -= 2;
}
break;
case 8:
- while (bufferSize > 0) {
+ while (size > 0) {
temp32 = *buffer8;
temp32 *= scale;
*buffer8 = temp32 > 127 ? 127 :
(temp32 < -128 ? -128 : temp32);
buffer8++;
- bufferSize--;
+ size--;
}
break;
default:
diff --git a/src/replay_gain.h b/src/replay_gain.h
index f1c24e1c0..9dae1fb1b 100644
--- a/src/replay_gain.h
+++ b/src/replay_gain.h
@@ -17,34 +17,36 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifndef MPD_REPLAYGAIN_H
-#define MPD_REPLAYGAIN_H
+#ifndef MPD_REPLAY_GAIN_H
+#define MPD_REPLAY_GAIN_H
-#define REPLAYGAIN_OFF 0
-#define REPLAYGAIN_TRACK 1
-#define REPLAYGAIN_ALBUM 2
+#define REPLAY_GAIN_OFF 0
+#define REPLAY_GAIN_TRACK 1
+#define REPLAY_GAIN_ALBUM 2
struct audio_format;
-extern int replayGainState;
+extern int replay_gain_mode;
-typedef struct _ReplayGainInfo {
- float albumGain;
- float albumPeak;
- float trackGain;
- float trackPeak;
+struct replay_gain_info {
+ float album_gain;
+ float album_peak;
+ float track_gain;
+ float track_peak;
/* used internally by mpd, to mess with it */
float scale;
-} ReplayGainInfo;
+};
-ReplayGainInfo *newReplayGainInfo(void);
+struct replay_gain_info *
+replay_gain_info_new(void);
-void freeReplayGainInfo(ReplayGainInfo * info);
+void replay_gain_info_free(struct replay_gain_info *info);
-void initReplayGainState(void);
+void replay_gain_global_init(void);
-void doReplayGain(ReplayGainInfo * info, char *buffer, int bufferSize,
+void
+replay_gain_apply(struct replay_gain_info *info, char *buffer, int bufferSize,
const struct audio_format *format);
#endif