diff options
Diffstat (limited to '')
-rw-r--r-- | src/DecoderAPI.cxx (renamed from src/decoder_api.c) | 50 |
1 files changed, 26 insertions, 24 deletions
diff --git a/src/decoder_api.c b/src/DecoderAPI.cxx index a45d0f1e6..6e0460a8c 100644 --- a/src/decoder_api.c +++ b/src/DecoderAPI.cxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2011 The Music Player Daemon Project + * Copyright (C) 2003-2013 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify @@ -18,15 +18,19 @@ */ #include "config.h" + +extern "C" { #include "decoder_api.h" -#include "decoder_internal.h" -#include "decoder_control.h" #include "audio_config.h" -#include "song.h" -#include "buffer.h" -#include "pipe.h" -#include "chunk.h" #include "replay_gain_config.h" +} + +#include "MusicChunk.hxx" +#include "MusicBuffer.hxx" +#include "MusicPipe.hxx" +#include "DecoderControl.hxx" +#include "DecoderInternal.hxx" +#include "song.h" #include <glib.h> @@ -362,11 +366,10 @@ update_stream_tag(struct decoder *decoder, struct input_stream *is) enum decoder_command decoder_data(struct decoder *decoder, struct input_stream *is, - const void *_data, size_t length, + const void *data, size_t length, uint16_t kbit_rate) { struct decoder_control *dc = decoder->dc; - const char *data = _data; GError *error = NULL; enum decoder_command cmd; @@ -417,7 +420,6 @@ decoder_data(struct decoder *decoder, while (length > 0) { struct music_chunk *chunk; - char *dest; size_t nbytes; bool full; @@ -427,10 +429,10 @@ decoder_data(struct decoder *decoder, return dc->command; } - dest = music_chunk_write(chunk, &dc->out_audio_format, - decoder->timestamp - - dc->song->start_ms / 1000.0, - kbit_rate, &nbytes); + void *dest = chunk->Write(dc->out_audio_format, + decoder->timestamp - + dc->song->start_ms / 1000.0, + kbit_rate, &nbytes); if (dest == NULL) { /* the chunk is full, flush it */ decoder_flush_chunk(decoder); @@ -449,14 +451,14 @@ decoder_data(struct decoder *decoder, /* expand the music pipe chunk */ - full = music_chunk_expand(chunk, &dc->out_audio_format, nbytes); + full = chunk->Expand(dc->out_audio_format, nbytes); if (full) { /* the chunk is full, flush it */ decoder_flush_chunk(decoder); g_cond_signal(dc->client_cond); } - data += nbytes; + data = (const uint8_t *)data + nbytes; length -= nbytes; decoder->timestamp += (double)nbytes / @@ -517,11 +519,10 @@ decoder_tag(G_GNUC_UNUSED struct decoder *decoder, struct input_stream *is, return cmd; } -float +void decoder_replay_gain(struct decoder *decoder, const struct replay_gain_info *replay_gain_info) { - float return_db = 0; assert(decoder != NULL); if (replay_gain_info != NULL) { @@ -530,9 +531,13 @@ decoder_replay_gain(struct decoder *decoder, serial = 1; if (REPLAY_GAIN_OFF != replay_gain_mode) { - return_db = 20.0 * log10f( + enum replay_gain_mode rgm = replay_gain_mode; + if (rgm != REPLAY_GAIN_ALBUM) + rgm = REPLAY_GAIN_TRACK; + + decoder->dc->replay_gain_db = 20.0 * log10f( replay_gain_tuple_scale( - &replay_gain_info->tuples[replay_gain_get_real_mode()], + &replay_gain_info->tuples[rgm], replay_gain_preamp, replay_gain_missing_preamp, replay_gain_limit)); } @@ -549,19 +554,16 @@ decoder_replay_gain(struct decoder *decoder, } } else decoder->replay_gain_serial = 0; - - return return_db; } void -decoder_mixramp(struct decoder *decoder, float replay_gain_db, +decoder_mixramp(struct decoder *decoder, char *mixramp_start, char *mixramp_end) { assert(decoder != NULL); struct decoder_control *dc = decoder->dc; assert(dc != NULL); - dc->replay_gain_db = replay_gain_db; dc_mixramp_start(dc, mixramp_start); dc_mixramp_end(dc, mixramp_end); } |