test/FakeDecoderAPI: move code to DumpReplayGainTuple()

This commit is contained in:
Max Kellermann 2016-11-24 17:17:08 +01:00
parent 0759d72108
commit 85c2b396ce
2 changed files with 33 additions and 18 deletions

View File

@ -121,18 +121,26 @@ FakeDecoder::SubmitTag(gcc_unused InputStream *is,
return DecoderCommand::NONE;
}
static void
DumpReplayGainTuple(const char *name, const ReplayGainTuple &tuple)
{
if (tuple.IsDefined())
fprintf(stderr, "replay_gain[%s]: gain=%f peak=%f\n",
name, tuple.gain, tuple.peak);
}
static void
DumpReplayGainInfo(const ReplayGainInfo &info)
{
DumpReplayGainTuple("album", info.tuples[REPLAY_GAIN_ALBUM]);
DumpReplayGainTuple("track", info.tuples[REPLAY_GAIN_TRACK]);
}
void
FakeDecoder::SubmitReplayGain(const ReplayGainInfo *rgi)
{
const ReplayGainTuple *tuple = &rgi->tuples[REPLAY_GAIN_ALBUM];
if (tuple->IsDefined())
fprintf(stderr, "replay_gain[album]: gain=%f peak=%f\n",
tuple->gain, tuple->peak);
tuple = &rgi->tuples[REPLAY_GAIN_TRACK];
if (tuple->IsDefined())
fprintf(stderr, "replay_gain[track]: gain=%f peak=%f\n",
tuple->gain, tuple->peak);
if (rgi != nullptr)
DumpReplayGainInfo(*rgi);
}
void

View File

@ -45,6 +45,21 @@ config_get_string(gcc_unused enum ConfigOption option,
return default_value;
}
static void
DumpReplayGainTuple(const char *name, const ReplayGainTuple &tuple)
{
if (tuple.IsDefined())
fprintf(stderr, "replay_gain[%s]: gain=%f peak=%f\n",
name, tuple.gain, tuple.peak);
}
static void
DumpReplayGainInfo(const ReplayGainInfo &info)
{
DumpReplayGainTuple("album", info.tuples[REPLAY_GAIN_ALBUM]);
DumpReplayGainTuple("track", info.tuples[REPLAY_GAIN_TRACK]);
}
int main(int argc, char **argv)
try {
#ifdef HAVE_LOCALE_H
@ -79,15 +94,7 @@ try {
return EXIT_FAILURE;
}
const ReplayGainTuple *tuple = &replay_gain.tuples[REPLAY_GAIN_ALBUM];
if (tuple->IsDefined())
fprintf(stderr, "replay_gain[album]: gain=%f peak=%f\n",
tuple->gain, tuple->peak);
tuple = &replay_gain.tuples[REPLAY_GAIN_TRACK];
if (tuple->IsDefined())
fprintf(stderr, "replay_gain[track]: gain=%f peak=%f\n",
tuple->gain, tuple->peak);
DumpReplayGainInfo(replay_gain);
return EXIT_SUCCESS;
} catch (const std::exception &e) {