Commit 6d475c40 authored by Max Kellermann's avatar Max Kellermann

ReplayGainInfo: use CamelCase for struct name

parent ed7891bf
...@@ -506,7 +506,7 @@ decoder_tag(Decoder &decoder, InputStream *is, ...@@ -506,7 +506,7 @@ decoder_tag(Decoder &decoder, InputStream *is,
void void
decoder_replay_gain(Decoder &decoder, decoder_replay_gain(Decoder &decoder,
const struct replay_gain_info *replay_gain_info) const ReplayGainInfo *replay_gain_info)
{ {
if (replay_gain_info != nullptr) { if (replay_gain_info != nullptr) {
static unsigned serial; static unsigned serial;
...@@ -514,7 +514,7 @@ decoder_replay_gain(Decoder &decoder, ...@@ -514,7 +514,7 @@ decoder_replay_gain(Decoder &decoder,
serial = 1; serial = 1;
if (REPLAY_GAIN_OFF != replay_gain_mode) { if (REPLAY_GAIN_OFF != replay_gain_mode) {
enum replay_gain_mode rgm = replay_gain_mode; ReplayGainMode rgm = replay_gain_mode;
if (rgm != REPLAY_GAIN_ALBUM) if (rgm != REPLAY_GAIN_ALBUM)
rgm = REPLAY_GAIN_TRACK; rgm = REPLAY_GAIN_TRACK;
......
...@@ -174,7 +174,7 @@ decoder_tag(Decoder &decoder, InputStream &is, Tag &&tag) ...@@ -174,7 +174,7 @@ decoder_tag(Decoder &decoder, InputStream &is, Tag &&tag)
*/ */
void void
decoder_replay_gain(Decoder &decoder, decoder_replay_gain(Decoder &decoder,
const struct replay_gain_info *replay_gain_info); const ReplayGainInfo *replay_gain_info);
/** /**
* Store MixRamp tags. * Store MixRamp tags.
......
...@@ -75,7 +75,7 @@ struct Decoder { ...@@ -75,7 +75,7 @@ struct Decoder {
/** the chunk currently being written to */ /** the chunk currently being written to */
struct music_chunk *chunk; struct music_chunk *chunk;
struct replay_gain_info replay_gain_info; ReplayGainInfo replay_gain_info;
/** /**
* A positive serial number for checking if replay gain info * A positive serial number for checking if replay gain info
......
...@@ -274,8 +274,8 @@ decoder_run_stream(Decoder &decoder, const char *uri) ...@@ -274,8 +274,8 @@ decoder_run_stream(Decoder &decoder, const char *uri)
static void static void
decoder_load_replay_gain(Decoder &decoder, const char *path_fs) decoder_load_replay_gain(Decoder &decoder, const char *path_fs)
{ {
struct replay_gain_info info; ReplayGainInfo info;
if (replay_gain_ape_read(path_fs, &info)) if (replay_gain_ape_read(path_fs, info))
decoder_replay_gain(decoder, &info); decoder_replay_gain(decoder, &info);
} }
......
...@@ -75,7 +75,7 @@ struct music_chunk { ...@@ -75,7 +75,7 @@ struct music_chunk {
* Replay gain information associated with this chunk. * Replay gain information associated with this chunk.
* Only valid if the serial is not 0. * Only valid if the serial is not 0.
*/ */
struct replay_gain_info replay_gain_info; ReplayGainInfo replay_gain_info;
/** /**
* A serial number for checking if replay gain info has * A serial number for checking if replay gain info has
......
...@@ -268,7 +268,7 @@ audio_output_all_update(void) ...@@ -268,7 +268,7 @@ audio_output_all_update(void)
} }
void void
audio_output_all_set_replay_gain_mode(enum replay_gain_mode mode) audio_output_all_set_replay_gain_mode(ReplayGainMode mode)
{ {
for (unsigned i = 0; i < num_audio_outputs; ++i) for (unsigned i = 0; i < num_audio_outputs; ++i)
audio_output_set_replay_gain_mode(audio_outputs[i], mode); audio_output_set_replay_gain_mode(audio_outputs[i], mode);
......
...@@ -104,7 +104,7 @@ void ...@@ -104,7 +104,7 @@ void
audio_output_all_release(void); audio_output_all_release(void);
void void
audio_output_all_set_replay_gain_mode(enum replay_gain_mode mode); audio_output_all_set_replay_gain_mode(ReplayGainMode mode);
/** /**
* Enqueue a #music_chunk object for playing, i.e. pushes it to a * Enqueue a #music_chunk object for playing, i.e. pushes it to a
......
/* /*
* Copyright (C) 2003-2013 The Music Player Daemon Project * Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org * http://www.musicpd.org
...@@ -96,7 +97,7 @@ ao_lock_command(struct audio_output *ao, enum audio_output_command cmd) ...@@ -96,7 +97,7 @@ ao_lock_command(struct audio_output *ao, enum audio_output_command cmd)
void void
audio_output_set_replay_gain_mode(struct audio_output *ao, audio_output_set_replay_gain_mode(struct audio_output *ao,
enum replay_gain_mode mode) ReplayGainMode mode)
{ {
if (ao->replay_gain_filter != nullptr) if (ao->replay_gain_filter != nullptr)
replay_gain_filter_set_mode(ao->replay_gain_filter, mode); replay_gain_filter_set_mode(ao->replay_gain_filter, mode);
......
...@@ -32,7 +32,7 @@ struct player_control; ...@@ -32,7 +32,7 @@ struct player_control;
void void
audio_output_set_replay_gain_mode(struct audio_output *ao, audio_output_set_replay_gain_mode(struct audio_output *ao,
enum replay_gain_mode mode); ReplayGainMode mode);
/** /**
* Enables the device. * Enables the device.
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
enum replay_gain_mode replay_gain_mode = REPLAY_GAIN_OFF; ReplayGainMode replay_gain_mode = REPLAY_GAIN_OFF;
static constexpr bool DEFAULT_REPLAYGAIN_LIMIT = true; static constexpr bool DEFAULT_REPLAYGAIN_LIMIT = true;
...@@ -134,10 +134,10 @@ void replay_gain_global_init(void) ...@@ -134,10 +134,10 @@ void replay_gain_global_init(void)
replay_gain_limit = config_get_bool(CONF_REPLAYGAIN_LIMIT, DEFAULT_REPLAYGAIN_LIMIT); replay_gain_limit = config_get_bool(CONF_REPLAYGAIN_LIMIT, DEFAULT_REPLAYGAIN_LIMIT);
} }
enum replay_gain_mode ReplayGainMode
replay_gain_get_real_mode(bool random_mode) replay_gain_get_real_mode(bool random_mode)
{ {
enum replay_gain_mode rgm; ReplayGainMode rgm;
rgm = replay_gain_mode; rgm = replay_gain_mode;
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
#include "ReplayGainInfo.hxx" #include "ReplayGainInfo.hxx"
#include "Compiler.h" #include "Compiler.h"
extern enum replay_gain_mode replay_gain_mode; extern ReplayGainMode replay_gain_mode;
extern float replay_gain_preamp; extern float replay_gain_preamp;
extern float replay_gain_missing_preamp; extern float replay_gain_missing_preamp;
extern bool replay_gain_limit; extern bool replay_gain_limit;
...@@ -50,7 +50,7 @@ replay_gain_set_mode_string(const char *p); ...@@ -50,7 +50,7 @@ replay_gain_set_mode_string(const char *p);
* Returns the "real" mode according to the "auto" setting" * Returns the "real" mode according to the "auto" setting"
*/ */
gcc_pure gcc_pure
enum replay_gain_mode ReplayGainMode
replay_gain_get_real_mode(bool random_mode); replay_gain_get_real_mode(bool random_mode);
#endif #endif
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
#include "ReplayGainInfo.hxx" #include "ReplayGainInfo.hxx"
float float
replay_gain_tuple_scale(const struct replay_gain_tuple *tuple, float preamp, float missing_preamp, bool peak_limit) replay_gain_tuple_scale(const ReplayGainTuple *tuple, float preamp, float missing_preamp, bool peak_limit)
{ {
float scale; float scale;
...@@ -40,9 +40,9 @@ replay_gain_tuple_scale(const struct replay_gain_tuple *tuple, float preamp, flo ...@@ -40,9 +40,9 @@ replay_gain_tuple_scale(const struct replay_gain_tuple *tuple, float preamp, flo
} }
void void
replay_gain_info_complete(struct replay_gain_info *info) replay_gain_info_complete(ReplayGainInfo &info)
{ {
if (!replay_gain_tuple_defined(&info->tuples[REPLAY_GAIN_ALBUM])) if (!replay_gain_tuple_defined(&info.tuples[REPLAY_GAIN_ALBUM]))
info->tuples[REPLAY_GAIN_ALBUM] = info.tuples[REPLAY_GAIN_ALBUM] =
info->tuples[REPLAY_GAIN_TRACK]; info.tuples[REPLAY_GAIN_TRACK];
} }
...@@ -24,50 +24,50 @@ ...@@ -24,50 +24,50 @@
#include <cmath> #include <cmath>
enum replay_gain_mode { enum ReplayGainMode {
REPLAY_GAIN_AUTO = -2, REPLAY_GAIN_AUTO = -2,
REPLAY_GAIN_OFF, REPLAY_GAIN_OFF,
REPLAY_GAIN_ALBUM, REPLAY_GAIN_ALBUM,
REPLAY_GAIN_TRACK, REPLAY_GAIN_TRACK,
}; };
struct replay_gain_tuple { struct ReplayGainTuple {
float gain; float gain;
float peak; float peak;
}; };
struct replay_gain_info { struct ReplayGainInfo {
struct replay_gain_tuple tuples[2]; ReplayGainTuple tuples[2];
}; };
static inline void static inline void
replay_gain_tuple_init(struct replay_gain_tuple *tuple) replay_gain_tuple_init(ReplayGainTuple *tuple)
{ {
tuple->gain = INFINITY; tuple->gain = INFINITY;
tuple->peak = 0.0; tuple->peak = 0.0;
} }
static inline void static inline void
replay_gain_info_init(struct replay_gain_info *info) replay_gain_info_init(struct ReplayGainInfo *info)
{ {
replay_gain_tuple_init(&info->tuples[REPLAY_GAIN_ALBUM]); replay_gain_tuple_init(&info->tuples[REPLAY_GAIN_ALBUM]);
replay_gain_tuple_init(&info->tuples[REPLAY_GAIN_TRACK]); replay_gain_tuple_init(&info->tuples[REPLAY_GAIN_TRACK]);
} }
static inline bool static inline bool
replay_gain_tuple_defined(const struct replay_gain_tuple *tuple) replay_gain_tuple_defined(const ReplayGainTuple *tuple)
{ {
return !std::isinf(tuple->gain); return !std::isinf(tuple->gain);
} }
float float
replay_gain_tuple_scale(const struct replay_gain_tuple *tuple, float preamp, float missing_preamp, bool peak_limit); replay_gain_tuple_scale(const ReplayGainTuple *tuple, float preamp, float missing_preamp, bool peak_limit);
/** /**
* Attempt to auto-complete missing data. In particular, if album * Attempt to auto-complete missing data. In particular, if album
* information is missing, track gain is used. * information is missing, track gain is used.
*/ */
void void
replay_gain_info_complete(struct replay_gain_info *info); replay_gain_info_complete(ReplayGainInfo &info);
#endif #endif
...@@ -93,7 +93,7 @@ void flac_metadata_common_cb(const FLAC__StreamMetadata * block, ...@@ -93,7 +93,7 @@ void flac_metadata_common_cb(const FLAC__StreamMetadata * block,
if (data->unsupported) if (data->unsupported)
return; return;
struct replay_gain_info rgi; ReplayGainInfo rgi;
char *mixramp_start; char *mixramp_start;
char *mixramp_end; char *mixramp_end;
...@@ -103,7 +103,7 @@ void flac_metadata_common_cb(const FLAC__StreamMetadata * block, ...@@ -103,7 +103,7 @@ void flac_metadata_common_cb(const FLAC__StreamMetadata * block,
break; break;
case FLAC__METADATA_TYPE_VORBIS_COMMENT: case FLAC__METADATA_TYPE_VORBIS_COMMENT:
if (flac_parse_replay_gain(&rgi, block)) if (flac_parse_replay_gain(rgi, block))
decoder_replay_gain(data->decoder, &rgi); decoder_replay_gain(data->decoder, &rgi);
if (flac_parse_mixramp(&mixramp_start, &mixramp_end, block)) if (flac_parse_mixramp(&mixramp_start, &mixramp_end, block))
......
...@@ -61,24 +61,24 @@ flac_find_float_comment(const FLAC__StreamMetadata *block, ...@@ -61,24 +61,24 @@ flac_find_float_comment(const FLAC__StreamMetadata *block,
} }
bool bool
flac_parse_replay_gain(struct replay_gain_info *rgi, flac_parse_replay_gain(ReplayGainInfo &rgi,
const FLAC__StreamMetadata *block) const FLAC__StreamMetadata *block)
{ {
bool found = false; bool found = false;
replay_gain_info_init(rgi); replay_gain_info_init(&rgi);
if (flac_find_float_comment(block, "replaygain_album_gain", if (flac_find_float_comment(block, "replaygain_album_gain",
&rgi->tuples[REPLAY_GAIN_ALBUM].gain)) &rgi.tuples[REPLAY_GAIN_ALBUM].gain))
found = true; found = true;
if (flac_find_float_comment(block, "replaygain_album_peak", if (flac_find_float_comment(block, "replaygain_album_peak",
&rgi->tuples[REPLAY_GAIN_ALBUM].peak)) &rgi.tuples[REPLAY_GAIN_ALBUM].peak))
found = true; found = true;
if (flac_find_float_comment(block, "replaygain_track_gain", if (flac_find_float_comment(block, "replaygain_track_gain",
&rgi->tuples[REPLAY_GAIN_TRACK].gain)) &rgi.tuples[REPLAY_GAIN_TRACK].gain))
found = true; found = true;
if (flac_find_float_comment(block, "replaygain_track_peak", if (flac_find_float_comment(block, "replaygain_track_peak",
&rgi->tuples[REPLAY_GAIN_TRACK].peak)) &rgi.tuples[REPLAY_GAIN_TRACK].peak))
found = true; found = true;
return found; return found;
......
...@@ -110,7 +110,7 @@ public: ...@@ -110,7 +110,7 @@ public:
struct tag_handler; struct tag_handler;
struct Tag; struct Tag;
struct replay_gain_info; struct ReplayGainInfo;
static inline unsigned static inline unsigned
flac_duration(const FLAC__StreamMetadata_StreamInfo *stream_info) flac_duration(const FLAC__StreamMetadata_StreamInfo *stream_info)
...@@ -122,7 +122,7 @@ flac_duration(const FLAC__StreamMetadata_StreamInfo *stream_info) ...@@ -122,7 +122,7 @@ flac_duration(const FLAC__StreamMetadata_StreamInfo *stream_info)
} }
bool bool
flac_parse_replay_gain(struct replay_gain_info *rgi, flac_parse_replay_gain(ReplayGainInfo &rgi,
const FLAC__StreamMetadata *block); const FLAC__StreamMetadata *block);
bool bool
......
...@@ -251,7 +251,7 @@ MadDecoder::FillBuffer() ...@@ -251,7 +251,7 @@ MadDecoder::FillBuffer()
#ifdef HAVE_ID3TAG #ifdef HAVE_ID3TAG
static bool static bool
parse_id3_replay_gain_info(struct replay_gain_info *replay_gain_info, parse_id3_replay_gain_info(ReplayGainInfo &rgi,
struct id3_tag *tag) struct id3_tag *tag)
{ {
int i; int i;
...@@ -260,7 +260,7 @@ parse_id3_replay_gain_info(struct replay_gain_info *replay_gain_info, ...@@ -260,7 +260,7 @@ parse_id3_replay_gain_info(struct replay_gain_info *replay_gain_info,
struct id3_frame *frame; struct id3_frame *frame;
bool found = false; bool found = false;
replay_gain_info_init(replay_gain_info); replay_gain_info_init(&rgi);
for (i = 0; (frame = id3_tag_findframe(tag, "TXXX", i)); i++) { for (i = 0; (frame = id3_tag_findframe(tag, "TXXX", i)); i++) {
if (frame->nfields < 3) if (frame->nfields < 3)
...@@ -274,16 +274,16 @@ parse_id3_replay_gain_info(struct replay_gain_info *replay_gain_info, ...@@ -274,16 +274,16 @@ parse_id3_replay_gain_info(struct replay_gain_info *replay_gain_info,
(&frame->fields[2])); (&frame->fields[2]));
if (StringEqualsCaseASCII(key, "replaygain_track_gain")) { if (StringEqualsCaseASCII(key, "replaygain_track_gain")) {
replay_gain_info->tuples[REPLAY_GAIN_TRACK].gain = atof(value); rgi.tuples[REPLAY_GAIN_TRACK].gain = atof(value);
found = true; found = true;
} else if (StringEqualsCaseASCII(key, "replaygain_album_gain")) { } else if (StringEqualsCaseASCII(key, "replaygain_album_gain")) {
replay_gain_info->tuples[REPLAY_GAIN_ALBUM].gain = atof(value); rgi.tuples[REPLAY_GAIN_ALBUM].gain = atof(value);
found = true; found = true;
} else if (StringEqualsCaseASCII(key, "replaygain_track_peak")) { } else if (StringEqualsCaseASCII(key, "replaygain_track_peak")) {
replay_gain_info->tuples[REPLAY_GAIN_TRACK].peak = atof(value); rgi.tuples[REPLAY_GAIN_TRACK].peak = atof(value);
found = true; found = true;
} else if (StringEqualsCaseASCII(key, "replaygain_album_peak")) { } else if (StringEqualsCaseASCII(key, "replaygain_album_peak")) {
replay_gain_info->tuples[REPLAY_GAIN_ALBUM].peak = atof(value); rgi.tuples[REPLAY_GAIN_ALBUM].peak = atof(value);
found = true; found = true;
} }
...@@ -293,7 +293,7 @@ parse_id3_replay_gain_info(struct replay_gain_info *replay_gain_info, ...@@ -293,7 +293,7 @@ parse_id3_replay_gain_info(struct replay_gain_info *replay_gain_info,
return found || return found ||
/* fall back on RVA2 if no replaygain tags found */ /* fall back on RVA2 if no replaygain tags found */
tag_rva2_parse(tag, replay_gain_info); tag_rva2_parse(tag, rgi);
} }
#endif #endif
...@@ -392,11 +392,11 @@ MadDecoder::ParseId3(size_t tagsize, Tag **mpd_tag) ...@@ -392,11 +392,11 @@ MadDecoder::ParseId3(size_t tagsize, Tag **mpd_tag)
} }
if (decoder != nullptr) { if (decoder != nullptr) {
struct replay_gain_info rgi; ReplayGainInfo rgi;
char *mixramp_start; char *mixramp_start;
char *mixramp_end; char *mixramp_end;
if (parse_id3_replay_gain_info(&rgi, id3_tag)) { if (parse_id3_replay_gain_info(rgi, id3_tag)) {
decoder_replay_gain(*decoder, &rgi); decoder_replay_gain(*decoder, &rgi);
found_replay_gain = true; found_replay_gain = true;
} }
...@@ -871,7 +871,7 @@ MadDecoder::DecodeFirstFrame(Tag **tag) ...@@ -871,7 +871,7 @@ MadDecoder::DecodeFirstFrame(Tag **tag)
* parse_lame() for details. -- jat */ * parse_lame() for details. -- jat */
if (decoder != nullptr && !found_replay_gain && if (decoder != nullptr && !found_replay_gain &&
lame.track_gain) { lame.track_gain) {
struct replay_gain_info rgi; ReplayGainInfo rgi;
replay_gain_info_init(&rgi); replay_gain_info_init(&rgi);
rgi.tuples[REPLAY_GAIN_TRACK].gain = lame.track_gain; rgi.tuples[REPLAY_GAIN_TRACK].gain = lame.track_gain;
rgi.tuples[REPLAY_GAIN_TRACK].peak = lame.peak; rgi.tuples[REPLAY_GAIN_TRACK].peak = lame.peak;
......
...@@ -168,14 +168,14 @@ mpcdec_decode(Decoder &mpd_decoder, InputStream &is) ...@@ -168,14 +168,14 @@ mpcdec_decode(Decoder &mpd_decoder, InputStream &is)
return; return;
} }
struct replay_gain_info replay_gain_info; ReplayGainInfo rgi;
replay_gain_info_init(&replay_gain_info); replay_gain_info_init(&rgi);
replay_gain_info.tuples[REPLAY_GAIN_ALBUM].gain = MPC_OLD_GAIN_REF - (info.gain_album / 256.); rgi.tuples[REPLAY_GAIN_ALBUM].gain = MPC_OLD_GAIN_REF - (info.gain_album / 256.);
replay_gain_info.tuples[REPLAY_GAIN_ALBUM].peak = pow(10, info.peak_album / 256. / 20) / 32767; rgi.tuples[REPLAY_GAIN_ALBUM].peak = pow(10, info.peak_album / 256. / 20) / 32767;
replay_gain_info.tuples[REPLAY_GAIN_TRACK].gain = MPC_OLD_GAIN_REF - (info.gain_title / 256.); rgi.tuples[REPLAY_GAIN_TRACK].gain = MPC_OLD_GAIN_REF - (info.gain_title / 256.);
replay_gain_info.tuples[REPLAY_GAIN_TRACK].peak = pow(10, info.peak_title / 256. / 20) / 32767; rgi.tuples[REPLAY_GAIN_TRACK].peak = pow(10, info.peak_title / 256. / 20) / 32767;
decoder_replay_gain(mpd_decoder, &replay_gain_info); decoder_replay_gain(mpd_decoder, &rgi);
decoder_initialized(mpd_decoder, audio_format, decoder_initialized(mpd_decoder, audio_format,
is.IsSeekable(), is.IsSeekable(),
......
...@@ -282,7 +282,7 @@ MPDOpusDecoder::HandleBOS(const ogg_packet &packet) ...@@ -282,7 +282,7 @@ MPDOpusDecoder::HandleBOS(const ogg_packet &packet)
inline DecoderCommand inline DecoderCommand
MPDOpusDecoder::HandleTags(const ogg_packet &packet) MPDOpusDecoder::HandleTags(const ogg_packet &packet)
{ {
replay_gain_info rgi; ReplayGainInfo rgi;
replay_gain_info_init(&rgi); replay_gain_info_init(&rgi);
TagBuilder tag_builder; TagBuilder tag_builder;
......
...@@ -42,7 +42,7 @@ ParseOpusTagName(const char *name) ...@@ -42,7 +42,7 @@ ParseOpusTagName(const char *name)
static void static void
ScanOneOpusTag(const char *name, const char *value, ScanOneOpusTag(const char *name, const char *value,
replay_gain_info *rgi, ReplayGainInfo *rgi,
const struct tag_handler *handler, void *ctx) const struct tag_handler *handler, void *ctx)
{ {
if (rgi != nullptr && strcmp(name, "R128_TRACK_GAIN") == 0) { if (rgi != nullptr && strcmp(name, "R128_TRACK_GAIN") == 0) {
...@@ -66,7 +66,7 @@ ScanOneOpusTag(const char *name, const char *value, ...@@ -66,7 +66,7 @@ ScanOneOpusTag(const char *name, const char *value,
bool bool
ScanOpusTags(const void *data, size_t size, ScanOpusTags(const void *data, size_t size,
replay_gain_info *rgi, ReplayGainInfo *rgi,
const struct tag_handler *handler, void *ctx) const struct tag_handler *handler, void *ctx)
{ {
OpusReader r(data, size); OpusReader r(data, size);
......
...@@ -24,11 +24,11 @@ ...@@ -24,11 +24,11 @@
#include <stddef.h> #include <stddef.h>
struct replay_gain_info; struct ReplayGainInfo;
bool bool
ScanOpusTags(const void *data, size_t size, ScanOpusTags(const void *data, size_t size,
replay_gain_info *rgi, ReplayGainInfo *rgi,
const struct tag_handler *handler, void *ctx); const struct tag_handler *handler, void *ctx);
#endif #endif
...@@ -47,29 +47,29 @@ vorbis_comment_value(const char *comment, const char *needle) ...@@ -47,29 +47,29 @@ vorbis_comment_value(const char *comment, const char *needle)
} }
bool bool
vorbis_comments_to_replay_gain(struct replay_gain_info *rgi, char **comments) vorbis_comments_to_replay_gain(ReplayGainInfo &rgi, char **comments)
{ {
const char *temp; const char *temp;
bool found = false; bool found = false;
replay_gain_info_init(rgi); replay_gain_info_init(&rgi);
while (*comments) { while (*comments) {
if ((temp = if ((temp =
vorbis_comment_value(*comments, "replaygain_track_gain"))) { vorbis_comment_value(*comments, "replaygain_track_gain"))) {
rgi->tuples[REPLAY_GAIN_TRACK].gain = atof(temp); rgi.tuples[REPLAY_GAIN_TRACK].gain = atof(temp);
found = true; found = true;
} else if ((temp = vorbis_comment_value(*comments, } else if ((temp = vorbis_comment_value(*comments,
"replaygain_album_gain"))) { "replaygain_album_gain"))) {
rgi->tuples[REPLAY_GAIN_ALBUM].gain = atof(temp); rgi.tuples[REPLAY_GAIN_ALBUM].gain = atof(temp);
found = true; found = true;
} else if ((temp = vorbis_comment_value(*comments, } else if ((temp = vorbis_comment_value(*comments,
"replaygain_track_peak"))) { "replaygain_track_peak"))) {
rgi->tuples[REPLAY_GAIN_TRACK].peak = atof(temp); rgi.tuples[REPLAY_GAIN_TRACK].peak = atof(temp);
found = true; found = true;
} else if ((temp = vorbis_comment_value(*comments, } else if ((temp = vorbis_comment_value(*comments,
"replaygain_album_peak"))) { "replaygain_album_peak"))) {
rgi->tuples[REPLAY_GAIN_ALBUM].peak = atof(temp); rgi.tuples[REPLAY_GAIN_ALBUM].peak = atof(temp);
found = true; found = true;
} }
......
...@@ -22,12 +22,12 @@ ...@@ -22,12 +22,12 @@
#include "check.h" #include "check.h"
struct replay_gain_info; struct ReplayGainInfo;
struct tag_handler; struct tag_handler;
struct Tag; struct Tag;
bool bool
vorbis_comments_to_replay_gain(struct replay_gain_info *rgi, char **comments); vorbis_comments_to_replay_gain(ReplayGainInfo &rgi, char **comments);
void void
vorbis_comments_scan(char **comments, vorbis_comments_scan(char **comments,
......
...@@ -283,8 +283,8 @@ vorbis_stream_decode(Decoder &decoder, ...@@ -283,8 +283,8 @@ vorbis_stream_decode(Decoder &decoder,
char **comments = ov_comment(&vf, -1)->user_comments; char **comments = ov_comment(&vf, -1)->user_comments;
vorbis_send_comments(decoder, input_stream, comments); vorbis_send_comments(decoder, input_stream, comments);
struct replay_gain_info rgi; ReplayGainInfo rgi;
if (vorbis_comments_to_replay_gain(&rgi, comments)) if (vorbis_comments_to_replay_gain(rgi, comments))
decoder_replay_gain(decoder, &rgi); decoder_replay_gain(decoder, &rgi);
prev_section = current_section; prev_section = current_section;
......
...@@ -221,29 +221,21 @@ wavpack_tag_float(WavpackContext *wpc, const char *key, float *value_r) ...@@ -221,29 +221,21 @@ wavpack_tag_float(WavpackContext *wpc, const char *key, float *value_r)
} }
static bool static bool
wavpack_replaygain(struct replay_gain_info *replay_gain_info, wavpack_replaygain(ReplayGainInfo &rgi,
WavpackContext *wpc) WavpackContext *wpc)
{ {
bool found = false; bool found = false;
replay_gain_info_init(replay_gain_info); replay_gain_info_init(&rgi);
found |= wavpack_tag_float( found |= wavpack_tag_float(wpc, "replaygain_track_gain",
wpc, "replaygain_track_gain", &rgi.tuples[REPLAY_GAIN_TRACK].gain);
&replay_gain_info->tuples[REPLAY_GAIN_TRACK].gain found |= wavpack_tag_float(wpc, "replaygain_track_peak",
); &rgi.tuples[REPLAY_GAIN_TRACK].peak);
found |= wavpack_tag_float( found |= wavpack_tag_float(wpc, "replaygain_album_gain",
wpc, "replaygain_track_peak", &rgi.tuples[REPLAY_GAIN_ALBUM].gain);
&replay_gain_info->tuples[REPLAY_GAIN_TRACK].peak found |= wavpack_tag_float(wpc, "replaygain_album_peak",
); &rgi.tuples[REPLAY_GAIN_ALBUM].peak);
found |= wavpack_tag_float(
wpc, "replaygain_album_gain",
&replay_gain_info->tuples[REPLAY_GAIN_ALBUM].gain
);
found |= wavpack_tag_float(
wpc, "replaygain_album_peak",
&replay_gain_info->tuples[REPLAY_GAIN_ALBUM].peak
);
return found; return found;
} }
...@@ -547,9 +539,9 @@ wavpack_filedecode(Decoder &decoder, const char *fname) ...@@ -547,9 +539,9 @@ wavpack_filedecode(Decoder &decoder, const char *fname)
return; return;
} }
struct replay_gain_info replay_gain_info; ReplayGainInfo rgi;
if (wavpack_replaygain(&replay_gain_info, wpc)) if (wavpack_replaygain(rgi, wpc))
decoder_replay_gain(decoder, &replay_gain_info); decoder_replay_gain(decoder, &rgi);
wavpack_decode(decoder, wpc, true); wavpack_decode(decoder, wpc, true);
......
...@@ -50,9 +50,9 @@ class ReplayGainFilter final : public Filter { ...@@ -50,9 +50,9 @@ class ReplayGainFilter final : public Filter {
*/ */
unsigned base; unsigned base;
enum replay_gain_mode mode; ReplayGainMode mode;
struct replay_gain_info info; ReplayGainInfo info;
/** /**
* The current volume, between 0 and a value that may or may not exceed * The current volume, between 0 and a value that may or may not exceed
...@@ -88,17 +88,17 @@ public: ...@@ -88,17 +88,17 @@ public:
Update(); Update();
} }
void SetInfo(const struct replay_gain_info *_info) { void SetInfo(const ReplayGainInfo *_info) {
if (_info != NULL) { if (_info != NULL) {
info = *_info; info = *_info;
replay_gain_info_complete(&info); replay_gain_info_complete(info);
} else } else
replay_gain_info_init(&info); replay_gain_info_init(&info);
Update(); Update();
} }
void SetMode(enum replay_gain_mode _mode) { void SetMode(ReplayGainMode _mode) {
if (_mode == mode) if (_mode == mode)
/* no change */ /* no change */
return; return;
...@@ -217,7 +217,7 @@ replay_gain_filter_set_mixer(Filter *_filter, Mixer *mixer, ...@@ -217,7 +217,7 @@ replay_gain_filter_set_mixer(Filter *_filter, Mixer *mixer,
} }
void void
replay_gain_filter_set_info(Filter *_filter, const replay_gain_info *info) replay_gain_filter_set_info(Filter *_filter, const ReplayGainInfo *info)
{ {
ReplayGainFilter *filter = (ReplayGainFilter *)_filter; ReplayGainFilter *filter = (ReplayGainFilter *)_filter;
...@@ -225,7 +225,7 @@ replay_gain_filter_set_info(Filter *_filter, const replay_gain_info *info) ...@@ -225,7 +225,7 @@ replay_gain_filter_set_info(Filter *_filter, const replay_gain_info *info)
} }
void void
replay_gain_filter_set_mode(Filter *_filter, enum replay_gain_mode mode) replay_gain_filter_set_mode(Filter *_filter, ReplayGainMode mode)
{ {
ReplayGainFilter *filter = (ReplayGainFilter *)_filter; ReplayGainFilter *filter = (ReplayGainFilter *)_filter;
......
...@@ -44,9 +44,9 @@ replay_gain_filter_set_mixer(Filter *_filter, Mixer *mixer, ...@@ -44,9 +44,9 @@ replay_gain_filter_set_mixer(Filter *_filter, Mixer *mixer,
* gain data is available for the current song * gain data is available for the current song
*/ */
void void
replay_gain_filter_set_info(Filter *filter, const replay_gain_info *info); replay_gain_filter_set_info(Filter *filter, const ReplayGainInfo *info);
void void
replay_gain_filter_set_mode(Filter *filter, enum replay_gain_mode mode); replay_gain_filter_set_mode(Filter *filter, ReplayGainMode mode);
#endif #endif
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
static bool static bool
replay_gain_ape_callback(unsigned long flags, const char *key, replay_gain_ape_callback(unsigned long flags, const char *key,
const char *_value, size_t value_length, const char *_value, size_t value_length,
struct replay_gain_info *info) ReplayGainInfo &info)
{ {
/* we only care about utf-8 text tags */ /* we only care about utf-8 text tags */
if ((flags & (0x3 << 1)) != 0) if ((flags & (0x3 << 1)) != 0)
...@@ -43,27 +43,27 @@ replay_gain_ape_callback(unsigned long flags, const char *key, ...@@ -43,27 +43,27 @@ replay_gain_ape_callback(unsigned long flags, const char *key,
value[value_length] = 0; value[value_length] = 0;
if (StringEqualsCaseASCII(key, "replaygain_track_gain")) { if (StringEqualsCaseASCII(key, "replaygain_track_gain")) {
info->tuples[REPLAY_GAIN_TRACK].gain = atof(value); info.tuples[REPLAY_GAIN_TRACK].gain = atof(value);
return true; return true;
} else if (StringEqualsCaseASCII(key, "replaygain_album_gain")) { } else if (StringEqualsCaseASCII(key, "replaygain_album_gain")) {
info->tuples[REPLAY_GAIN_ALBUM].gain = atof(value); info.tuples[REPLAY_GAIN_ALBUM].gain = atof(value);
return true; return true;
} else if (StringEqualsCaseASCII(key, "replaygain_track_peak")) { } else if (StringEqualsCaseASCII(key, "replaygain_track_peak")) {
info->tuples[REPLAY_GAIN_TRACK].peak = atof(value); info.tuples[REPLAY_GAIN_TRACK].peak = atof(value);
return true; return true;
} else if (StringEqualsCaseASCII(key, "replaygain_album_peak")) { } else if (StringEqualsCaseASCII(key, "replaygain_album_peak")) {
info->tuples[REPLAY_GAIN_ALBUM].peak = atof(value); info.tuples[REPLAY_GAIN_ALBUM].peak = atof(value);
return true; return true;
} else } else
return false; return false;
} }
bool bool
replay_gain_ape_read(const char *path_fs, struct replay_gain_info *info) replay_gain_ape_read(const char *path_fs, ReplayGainInfo &info)
{ {
bool found = false; bool found = false;
auto callback = [info, &found] auto callback = [&info, &found]
(unsigned long flags, const char *key, (unsigned long flags, const char *key,
const char *value, const char *value,
size_t value_length) { size_t value_length) {
......
...@@ -22,9 +22,9 @@ ...@@ -22,9 +22,9 @@
#include "check.h" #include "check.h"
struct replay_gain_info; struct ReplayGainInfo;
bool bool
replay_gain_ape_read(const char *path_fs, struct replay_gain_info *info); replay_gain_ape_read(const char *path_fs, ReplayGainInfo &info);
#endif #endif
...@@ -73,7 +73,7 @@ rva2_float_volume_adjustment(const struct rva2_data *data) ...@@ -73,7 +73,7 @@ rva2_float_volume_adjustment(const struct rva2_data *data)
} }
static inline bool static inline bool
rva2_apply_data(struct replay_gain_info *replay_gain_info, rva2_apply_data(ReplayGainInfo &rgi,
const struct rva2_data *data, const id3_latin1_t *id) const struct rva2_data *data, const id3_latin1_t *id)
{ {
if (data->type != CHANNEL_MASTER_VOLUME) if (data->type != CHANNEL_MASTER_VOLUME)
...@@ -82,19 +82,19 @@ rva2_apply_data(struct replay_gain_info *replay_gain_info, ...@@ -82,19 +82,19 @@ rva2_apply_data(struct replay_gain_info *replay_gain_info,
float volume_adjustment = rva2_float_volume_adjustment(data); float volume_adjustment = rva2_float_volume_adjustment(data);
if (strcmp((const char *)id, "album") == 0) { if (strcmp((const char *)id, "album") == 0) {
replay_gain_info->tuples[REPLAY_GAIN_ALBUM].gain = volume_adjustment; rgi.tuples[REPLAY_GAIN_ALBUM].gain = volume_adjustment;
} else if (strcmp((const char *)id, "track") == 0) { } else if (strcmp((const char *)id, "track") == 0) {
replay_gain_info->tuples[REPLAY_GAIN_TRACK].gain = volume_adjustment; rgi.tuples[REPLAY_GAIN_TRACK].gain = volume_adjustment;
} else { } else {
replay_gain_info->tuples[REPLAY_GAIN_ALBUM].gain = volume_adjustment; rgi.tuples[REPLAY_GAIN_ALBUM].gain = volume_adjustment;
replay_gain_info->tuples[REPLAY_GAIN_TRACK].gain = volume_adjustment; rgi.tuples[REPLAY_GAIN_TRACK].gain = volume_adjustment;
} }
return true; return true;
} }
static bool static bool
rva2_apply_frame(struct replay_gain_info *replay_gain_info, rva2_apply_frame(ReplayGainInfo &replay_gain_info,
const struct id3_frame *frame) const struct id3_frame *frame)
{ {
const id3_latin1_t *id = id3_field_getlatin1(id3_frame_field(frame, 0)); const id3_latin1_t *id = id3_field_getlatin1(id3_frame_field(frame, 0));
...@@ -133,7 +133,7 @@ rva2_apply_frame(struct replay_gain_info *replay_gain_info, ...@@ -133,7 +133,7 @@ rva2_apply_frame(struct replay_gain_info *replay_gain_info,
} }
bool bool
tag_rva2_parse(struct id3_tag *tag, struct replay_gain_info *replay_gain_info) tag_rva2_parse(struct id3_tag *tag, ReplayGainInfo &replay_gain_info)
{ {
bool found = false; bool found = false;
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
#include "check.h" #include "check.h"
struct id3_tag; struct id3_tag;
struct replay_gain_info; struct ReplayGainInfo;
/** /**
* Parse the RVA2 tag, and fill the #replay_gain_info struct. This is * Parse the RVA2 tag, and fill the #replay_gain_info struct. This is
...@@ -32,6 +32,6 @@ struct replay_gain_info; ...@@ -32,6 +32,6 @@ struct replay_gain_info;
* @return true on success * @return true on success
*/ */
bool bool
tag_rva2_parse(struct id3_tag *tag, struct replay_gain_info *replay_gain_info); tag_rva2_parse(struct id3_tag *tag, ReplayGainInfo &replay_gain_info);
#endif #endif
...@@ -117,15 +117,14 @@ decoder_tag(gcc_unused Decoder &decoder, ...@@ -117,15 +117,14 @@ decoder_tag(gcc_unused Decoder &decoder,
void void
decoder_replay_gain(gcc_unused Decoder &decoder, decoder_replay_gain(gcc_unused Decoder &decoder,
const struct replay_gain_info *replay_gain_info) const ReplayGainInfo *rgi)
{ {
const struct replay_gain_tuple *tuple = const ReplayGainTuple *tuple = &rgi->tuples[REPLAY_GAIN_ALBUM];
&replay_gain_info->tuples[REPLAY_GAIN_ALBUM];
if (replay_gain_tuple_defined(tuple)) if (replay_gain_tuple_defined(tuple))
g_printerr("replay_gain[album]: gain=%f peak=%f\n", g_printerr("replay_gain[album]: gain=%f peak=%f\n",
tuple->gain, tuple->peak); tuple->gain, tuple->peak);
tuple = &replay_gain_info->tuples[REPLAY_GAIN_TRACK]; tuple = &rgi->tuples[REPLAY_GAIN_TRACK];
if (replay_gain_tuple_defined(tuple)) if (replay_gain_tuple_defined(tuple))
g_printerr("replay_gain[track]: gain=%f peak=%f\n", g_printerr("replay_gain[track]: gain=%f peak=%f\n",
tuple->gain, tuple->peak); tuple->gain, tuple->peak);
......
...@@ -66,10 +66,10 @@ int main(int argc, char **argv) ...@@ -66,10 +66,10 @@ int main(int argc, char **argv)
return EXIT_FAILURE; return EXIT_FAILURE;
} }
struct replay_gain_info replay_gain; ReplayGainInfo replay_gain;
replay_gain_info_init(&replay_gain); replay_gain_info_init(&replay_gain);
bool success = tag_rva2_parse(tag, &replay_gain); bool success = tag_rva2_parse(tag, replay_gain);
id3_tag_delete(tag); id3_tag_delete(tag);
if (!success) { if (!success) {
...@@ -77,8 +77,7 @@ int main(int argc, char **argv) ...@@ -77,8 +77,7 @@ int main(int argc, char **argv)
return EXIT_FAILURE; return EXIT_FAILURE;
} }
const struct replay_gain_tuple *tuple = const ReplayGainTuple *tuple = &replay_gain.tuples[REPLAY_GAIN_ALBUM];
&replay_gain.tuples[REPLAY_GAIN_ALBUM];
if (replay_gain_tuple_defined(tuple)) if (replay_gain_tuple_defined(tuple))
g_printerr("replay_gain[album]: gain=%f peak=%f\n", g_printerr("replay_gain[album]: gain=%f peak=%f\n",
tuple->gain, tuple->peak); tuple->gain, tuple->peak);
......
...@@ -105,7 +105,7 @@ decoder_tag(gcc_unused Decoder &decoder, ...@@ -105,7 +105,7 @@ decoder_tag(gcc_unused Decoder &decoder,
void void
decoder_replay_gain(gcc_unused Decoder &decoder, decoder_replay_gain(gcc_unused Decoder &decoder,
gcc_unused const struct replay_gain_info *replay_gain_info) gcc_unused const ReplayGainInfo *replay_gain_info)
{ {
} }
......
...@@ -127,15 +127,14 @@ decoder_tag(gcc_unused Decoder &decoder, ...@@ -127,15 +127,14 @@ decoder_tag(gcc_unused Decoder &decoder,
void void
decoder_replay_gain(gcc_unused Decoder &decoder, decoder_replay_gain(gcc_unused Decoder &decoder,
const struct replay_gain_info *replay_gain_info) const ReplayGainInfo *rgi)
{ {
const struct replay_gain_tuple *tuple = const ReplayGainTuple *tuple = &rgi->tuples[REPLAY_GAIN_ALBUM];
&replay_gain_info->tuples[REPLAY_GAIN_ALBUM];
if (replay_gain_tuple_defined(tuple)) if (replay_gain_tuple_defined(tuple))
g_printerr("replay_gain[album]: gain=%f peak=%f\n", g_printerr("replay_gain[album]: gain=%f peak=%f\n",
tuple->gain, tuple->peak); tuple->gain, tuple->peak);
tuple = &replay_gain_info->tuples[REPLAY_GAIN_TRACK]; tuple = &rgi->tuples[REPLAY_GAIN_TRACK];
if (replay_gain_tuple_defined(tuple)) if (replay_gain_tuple_defined(tuple))
g_printerr("replay_gain[track]: gain=%f peak=%f\n", g_printerr("replay_gain[track]: gain=%f peak=%f\n",
tuple->gain, tuple->peak); tuple->gain, tuple->peak);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment