aboutsummaryrefslogtreecommitdiffstats
path: root/src/decoder
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2013-10-21 21:12:37 +0200
committerMax Kellermann <max@duempel.org>2013-10-21 21:12:37 +0200
commit82059645f18e4a8aa734e0a376d10bb52fc1cc7d (patch)
treee2d1c113c887cdafe95ec07419150d6b768211b6 /src/decoder
parent13e9f18403b98f8123b1b983c4680957d684e47b (diff)
downloadmpd-82059645f18e4a8aa734e0a376d10bb52fc1cc7d.tar.gz
mpd-82059645f18e4a8aa734e0a376d10bb52fc1cc7d.tar.xz
mpd-82059645f18e4a8aa734e0a376d10bb52fc1cc7d.zip
decoder: rename the struct to "Decoder"
Diffstat (limited to 'src/decoder')
-rw-r--r--src/decoder/AdPlugDecoderPlugin.cxx2
-rw-r--r--src/decoder/AudiofileDecoderPlugin.cxx2
-rw-r--r--src/decoder/DsdLib.cxx6
-rw-r--r--src/decoder/DsdLib.hxx8
-rw-r--r--src/decoder/DsdiffDecoderPlugin.cxx26
-rw-r--r--src/decoder/DsfDecoderPlugin.cxx12
-rw-r--r--src/decoder/FaadDecoderPlugin.cxx4
-rw-r--r--src/decoder/FfmpegDecoderPlugin.cxx14
-rw-r--r--src/decoder/FlacCommon.cxx4
-rw-r--r--src/decoder/FlacCommon.hxx4
-rw-r--r--src/decoder/FlacDecoderPlugin.cxx10
-rw-r--r--src/decoder/FlacInput.cxx8
-rw-r--r--src/decoder/FlacInput.hxx6
-rw-r--r--src/decoder/FluidsynthDecoderPlugin.cxx2
-rw-r--r--src/decoder/GmeDecoderPlugin.cxx2
-rw-r--r--src/decoder/MadDecoderPlugin.cxx30
-rw-r--r--src/decoder/MikmodDecoderPlugin.cxx2
-rw-r--r--src/decoder/ModplugDecoderPlugin.cxx9
-rw-r--r--src/decoder/MpcdecDecoderPlugin.cxx6
-rw-r--r--src/decoder/Mpg123DecoderPlugin.cxx2
-rw-r--r--src/decoder/OggCodec.cxx2
-rw-r--r--src/decoder/OggCodec.hxx2
-rw-r--r--src/decoder/OggSyncState.hxx4
-rw-r--r--src/decoder/OggUtil.cxx12
-rw-r--r--src/decoder/OggUtil.hxx14
-rw-r--r--src/decoder/OpusDecoderPlugin.cxx10
-rw-r--r--src/decoder/PcmDecoderPlugin.cxx2
-rw-r--r--src/decoder/SidplayDecoderPlugin.cxx2
-rw-r--r--src/decoder/SndfileDecoderPlugin.cxx2
-rw-r--r--src/decoder/VorbisDecoderPlugin.cxx17
-rw-r--r--src/decoder/WavpackDecoderPlugin.cxx14
-rw-r--r--src/decoder/WildmidiDecoderPlugin.cxx2
32 files changed, 124 insertions, 118 deletions
diff --git a/src/decoder/AdPlugDecoderPlugin.cxx b/src/decoder/AdPlugDecoderPlugin.cxx
index bf9cb71e4..8f2ed3bd7 100644
--- a/src/decoder/AdPlugDecoderPlugin.cxx
+++ b/src/decoder/AdPlugDecoderPlugin.cxx
@@ -48,7 +48,7 @@ adplug_init(const config_param &param)
}
static void
-adplug_file_decode(struct decoder *decoder, const char *path_fs)
+adplug_file_decode(Decoder &decoder, const char *path_fs)
{
CEmuopl opl(sample_rate, true, true);
opl.init();
diff --git a/src/decoder/AudiofileDecoderPlugin.cxx b/src/decoder/AudiofileDecoderPlugin.cxx
index 65fb14c0f..5b3ffa642 100644
--- a/src/decoder/AudiofileDecoderPlugin.cxx
+++ b/src/decoder/AudiofileDecoderPlugin.cxx
@@ -157,7 +157,7 @@ audiofile_setup_sample_format(AFfilehandle af_fp)
}
static void
-audiofile_stream_decode(struct decoder *decoder, struct input_stream *is)
+audiofile_stream_decode(Decoder &decoder, struct input_stream *is)
{
AFvirtualfile *vf;
int fs, frame_count;
diff --git a/src/decoder/DsdLib.cxx b/src/decoder/DsdLib.cxx
index 491b158e6..ab1a132fc 100644
--- a/src/decoder/DsdLib.cxx
+++ b/src/decoder/DsdLib.cxx
@@ -51,7 +51,7 @@ dsdlib_id_equals(const struct dsdlib_id *id, const char *s)
}
bool
-dsdlib_read(struct decoder *decoder, struct input_stream *is,
+dsdlib_read(Decoder *decoder, struct input_stream *is,
void *data, size_t length)
{
size_t nbytes = decoder_read(decoder, is, data, length);
@@ -62,7 +62,7 @@ dsdlib_read(struct decoder *decoder, struct input_stream *is,
* Skip the #input_stream to the specified offset.
*/
bool
-dsdlib_skip_to(struct decoder *decoder, struct input_stream *is,
+dsdlib_skip_to(Decoder *decoder, struct input_stream *is,
int64_t offset)
{
if (is->IsSeekable())
@@ -90,7 +90,7 @@ dsdlib_skip_to(struct decoder *decoder, struct input_stream *is,
* Skip some bytes from the #input_stream.
*/
bool
-dsdlib_skip(struct decoder *decoder, struct input_stream *is,
+dsdlib_skip(Decoder *decoder, struct input_stream *is,
int64_t delta)
{
assert(delta >= 0);
diff --git a/src/decoder/DsdLib.hxx b/src/decoder/DsdLib.hxx
index b1c708fca..261273091 100644
--- a/src/decoder/DsdLib.hxx
+++ b/src/decoder/DsdLib.hxx
@@ -23,6 +23,8 @@
#include <stdlib.h>
#include <stdint.h>
+struct Decoder;
+
struct dsdlib_id {
char value[4];
};
@@ -31,15 +33,15 @@ bool
dsdlib_id_equals(const struct dsdlib_id *id, const char *s);
bool
-dsdlib_read(struct decoder *decoder, struct input_stream *is,
+dsdlib_read(Decoder *decoder, struct input_stream *is,
void *data, size_t length);
bool
-dsdlib_skip_to(struct decoder *decoder, struct input_stream *is,
+dsdlib_skip_to(Decoder *decoder, struct input_stream *is,
int64_t offset);
bool
-dsdlib_skip(struct decoder *decoder, struct input_stream *is,
+dsdlib_skip(Decoder *decoder, struct input_stream *is,
int64_t delta);
void
diff --git a/src/decoder/DsdiffDecoderPlugin.cxx b/src/decoder/DsdiffDecoderPlugin.cxx
index f5598826b..3f768f60f 100644
--- a/src/decoder/DsdiffDecoderPlugin.cxx
+++ b/src/decoder/DsdiffDecoderPlugin.cxx
@@ -91,21 +91,21 @@ dsdiff_init(const config_param &param)
}
static bool
-dsdiff_read_id(struct decoder *decoder, struct input_stream *is,
+dsdiff_read_id(Decoder *decoder, struct input_stream *is,
struct dsdlib_id *id)
{
return dsdlib_read(decoder, is, id, sizeof(*id));
}
static bool
-dsdiff_read_chunk_header(struct decoder *decoder, struct input_stream *is,
+dsdiff_read_chunk_header(Decoder *decoder, struct input_stream *is,
DsdiffChunkHeader *header)
{
return dsdlib_read(decoder, is, header, sizeof(*header));
}
static bool
-dsdiff_read_payload(struct decoder *decoder, struct input_stream *is,
+dsdiff_read_payload(Decoder *decoder, struct input_stream *is,
const DsdiffChunkHeader *header,
void *data, size_t length)
{
@@ -121,7 +121,7 @@ dsdiff_read_payload(struct decoder *decoder, struct input_stream *is,
* Read and parse a "SND" chunk inside "PROP".
*/
static bool
-dsdiff_read_prop_snd(struct decoder *decoder, struct input_stream *is,
+dsdiff_read_prop_snd(Decoder *decoder, struct input_stream *is,
DsdiffMetaData *metadata,
input_stream::offset_type end_offset)
{
@@ -179,7 +179,7 @@ dsdiff_read_prop_snd(struct decoder *decoder, struct input_stream *is,
* Read and parse a "PROP" chunk.
*/
static bool
-dsdiff_read_prop(struct decoder *decoder, struct input_stream *is,
+dsdiff_read_prop(Decoder *decoder, struct input_stream *is,
DsdiffMetaData *metadata,
const DsdiffChunkHeader *prop_header)
{
@@ -239,7 +239,7 @@ dsdiff_handle_native_tag(struct input_stream *is,
*/
static bool
-dsdiff_read_metadata_extra(struct decoder *decoder, struct input_stream *is,
+dsdiff_read_metadata_extra(Decoder *decoder, struct input_stream *is,
DsdiffMetaData *metadata,
DsdiffChunkHeader *chunk_header,
const struct tag_handler *handler,
@@ -325,7 +325,7 @@ dsdiff_read_metadata_extra(struct decoder *decoder, struct input_stream *is,
* "chunk_header" parameter.
*/
static bool
-dsdiff_read_metadata(struct decoder *decoder, struct input_stream *is,
+dsdiff_read_metadata(Decoder *decoder, struct input_stream *is,
DsdiffMetaData *metadata,
DsdiffChunkHeader *chunk_header)
{
@@ -371,7 +371,7 @@ bit_reverse_buffer(uint8_t *p, uint8_t *end)
* Decode one "DSD" chunk.
*/
static bool
-dsdiff_decode_chunk(struct decoder *decoder, struct input_stream *is,
+dsdiff_decode_chunk(Decoder &decoder, struct input_stream *is,
unsigned channels,
uint64_t chunk_size)
{
@@ -418,17 +418,17 @@ dsdiff_decode_chunk(struct decoder *decoder, struct input_stream *is,
break;
}
}
- return dsdlib_skip(decoder, is, chunk_size);
+ return dsdlib_skip(&decoder, is, chunk_size);
}
static void
-dsdiff_stream_decode(struct decoder *decoder, struct input_stream *is)
+dsdiff_stream_decode(Decoder &decoder, struct input_stream *is)
{
DsdiffMetaData metadata;
DsdiffChunkHeader chunk_header;
/* check if it is is a proper DFF file */
- if (!dsdiff_read_metadata(decoder, is, &metadata, &chunk_header))
+ if (!dsdiff_read_metadata(&decoder, is, &metadata, &chunk_header))
return;
Error error;
@@ -461,13 +461,13 @@ dsdiff_stream_decode(struct decoder *decoder, struct input_stream *is)
break;
} else {
/* ignore other chunks */
- if (!dsdlib_skip(decoder, is, chunk_size))
+ if (!dsdlib_skip(&decoder, is, chunk_size))
break;
}
/* read next chunk header; the first one was read by
dsdiff_read_metadata() */
- if (!dsdiff_read_chunk_header(decoder,
+ if (!dsdiff_read_chunk_header(&decoder,
is, &chunk_header))
break;
}
diff --git a/src/decoder/DsfDecoderPlugin.cxx b/src/decoder/DsfDecoderPlugin.cxx
index 8aa24a1f9..4b848d4a4 100644
--- a/src/decoder/DsfDecoderPlugin.cxx
+++ b/src/decoder/DsfDecoderPlugin.cxx
@@ -99,7 +99,7 @@ struct DsfDataChunk {
* Read and parse all needed metadata chunks for DSF files.
*/
static bool
-dsf_read_metadata(struct decoder *decoder, struct input_stream *is,
+dsf_read_metadata(Decoder *decoder, struct input_stream *is,
DsfMetaData *metadata)
{
uint64_t chunk_size;
@@ -219,7 +219,7 @@ dsf_to_pcm_order(uint8_t *dest, uint8_t *scratch, size_t nrbytes)
* Decode one complete DSF 'data' chunk i.e. a complete song
*/
static bool
-dsf_decode_chunk(struct decoder *decoder, struct input_stream *is,
+dsf_decode_chunk(Decoder &decoder, struct input_stream *is,
unsigned channels,
uint64_t chunk_size,
bool bitreverse)
@@ -246,7 +246,7 @@ dsf_decode_chunk(struct decoder *decoder, struct input_stream *is,
now_size = now_frames * frame_size;
}
- size_t nbytes = decoder_read(decoder, is, buffer, now_size);
+ size_t nbytes = decoder_read(&decoder, is, buffer, now_size);
if (nbytes != now_size)
return false;
@@ -273,15 +273,15 @@ dsf_decode_chunk(struct decoder *decoder, struct input_stream *is,
break;
}
}
- return dsdlib_skip(decoder, is, chunk_size);
+ return dsdlib_skip(&decoder, is, chunk_size);
}
static void
-dsf_stream_decode(struct decoder *decoder, struct input_stream *is)
+dsf_stream_decode(Decoder &decoder, struct input_stream *is)
{
/* check if it is a proper DSF file */
DsfMetaData metadata;
- if (!dsf_read_metadata(decoder, is, &metadata))
+ if (!dsf_read_metadata(&decoder, is, &metadata))
return;
Error error;
diff --git a/src/decoder/FaadDecoderPlugin.cxx b/src/decoder/FaadDecoderPlugin.cxx
index 4056c73fa..05d929fb4 100644
--- a/src/decoder/FaadDecoderPlugin.cxx
+++ b/src/decoder/FaadDecoderPlugin.cxx
@@ -357,7 +357,7 @@ faad_get_file_time(struct input_stream *is)
}
static void
-faad_stream_decode(struct decoder *mpd_decoder, struct input_stream *is)
+faad_stream_decode(Decoder &mpd_decoder, struct input_stream *is)
{
float total_time = 0;
AudioFormat audio_format;
@@ -365,7 +365,7 @@ faad_stream_decode(struct decoder *mpd_decoder, struct input_stream *is)
uint16_t bit_rate = 0;
DecoderBuffer *buffer;
- buffer = decoder_buffer_new(mpd_decoder, is,
+ buffer = decoder_buffer_new(&mpd_decoder, is,
FAAD_MIN_STREAMSIZE * AAC_MAX_CHANNELS);
total_time = faad_song_duration(buffer, is);
diff --git a/src/decoder/FfmpegDecoderPlugin.cxx b/src/decoder/FfmpegDecoderPlugin.cxx
index f7743180b..5092bdf9e 100644
--- a/src/decoder/FfmpegDecoderPlugin.cxx
+++ b/src/decoder/FfmpegDecoderPlugin.cxx
@@ -91,14 +91,14 @@ mpd_ffmpeg_log_callback(gcc_unused void *ptr, int level,
}
struct AvioStream {
- struct decoder *decoder;
+ Decoder *const decoder;
struct input_stream *input;
AVIOContext *io;
unsigned char buffer[8192];
- AvioStream(struct decoder *_decoder, input_stream *_input)
+ AvioStream(Decoder *_decoder, input_stream *_input)
:decoder(_decoder), input(_input), io(nullptr) {}
~AvioStream() {
@@ -255,7 +255,7 @@ copy_interleave_frame(const AVCodecContext *codec_context,
}
static DecoderCommand
-ffmpeg_send_packet(struct decoder *decoder, struct input_stream *is,
+ffmpeg_send_packet(Decoder &decoder, struct input_stream *is,
const AVPacket *packet,
AVCodecContext *codec_context,
const AVRational *time_base,
@@ -341,7 +341,7 @@ ffmpeg_sample_format(enum AVSampleFormat sample_fmt)
}
static AVInputFormat *
-ffmpeg_probe(struct decoder *decoder, struct input_stream *is)
+ffmpeg_probe(Decoder *decoder, struct input_stream *is)
{
enum {
BUFFER_SIZE = 16384,
@@ -370,16 +370,16 @@ ffmpeg_probe(struct decoder *decoder, struct input_stream *is)
}
static void
-ffmpeg_decode(struct decoder *decoder, struct input_stream *input)
+ffmpeg_decode(Decoder &decoder, struct input_stream *input)
{
- AVInputFormat *input_format = ffmpeg_probe(decoder, input);
+ AVInputFormat *input_format = ffmpeg_probe(&decoder, input);
if (input_format == nullptr)
return;
FormatDebug(ffmpeg_domain, "detected input format '%s' (%s)",
input_format->name, input_format->long_name);
- AvioStream stream(decoder, input);
+ AvioStream stream(&decoder, input);
if (!stream.Open()) {
LogError(ffmpeg_domain, "Failed to open stream");
return;
diff --git a/src/decoder/FlacCommon.cxx b/src/decoder/FlacCommon.cxx
index 6bafeb9c2..46fd9fff9 100644
--- a/src/decoder/FlacCommon.cxx
+++ b/src/decoder/FlacCommon.cxx
@@ -32,9 +32,9 @@
#include <assert.h>
-flac_data::flac_data(struct decoder *_decoder,
+flac_data::flac_data(Decoder &_decoder,
struct input_stream *_input_stream)
- :FlacInput(_input_stream, _decoder),
+ :FlacInput(_input_stream, &_decoder),
initialized(false), unsupported(false),
total_frames(0), first_frame(0), next_frame(0), position(0),
decoder(_decoder), input_stream(_input_stream)
diff --git a/src/decoder/FlacCommon.hxx b/src/decoder/FlacCommon.hxx
index 726e9de92..e35bceb30 100644
--- a/src/decoder/FlacCommon.hxx
+++ b/src/decoder/FlacCommon.hxx
@@ -75,12 +75,12 @@ struct flac_data : public FlacInput {
FLAC__uint64 position;
- struct decoder *decoder;
+ Decoder &decoder;
struct input_stream *input_stream;
Tag tag;
- flac_data(struct decoder *decoder, struct input_stream *input_stream);
+ flac_data(Decoder &decoder, struct input_stream *input_stream);
};
void flac_metadata_common_cb(const FLAC__StreamMetadata * block,
diff --git a/src/decoder/FlacDecoderPlugin.cxx b/src/decoder/FlacDecoderPlugin.cxx
index ff67727b7..168dfdd19 100644
--- a/src/decoder/FlacDecoderPlugin.cxx
+++ b/src/decoder/FlacDecoderPlugin.cxx
@@ -173,7 +173,7 @@ static void
flac_decoder_loop(struct flac_data *data, FLAC__StreamDecoder *flac_dec,
FLAC__uint64 t_start, FLAC__uint64 t_end)
{
- struct decoder *decoder = data->decoder;
+ Decoder &decoder = data->decoder;
data->first_frame = t_start;
@@ -255,7 +255,7 @@ stream_init(FLAC__StreamDecoder *flac_dec, struct flac_data *data, bool is_ogg)
}
static void
-flac_decode_internal(struct decoder * decoder,
+flac_decode_internal(Decoder &decoder,
struct input_stream *input_stream,
bool is_ogg)
{
@@ -289,7 +289,7 @@ flac_decode_internal(struct decoder * decoder,
}
static void
-flac_decode(struct decoder * decoder, struct input_stream *input_stream)
+flac_decode(Decoder &decoder, struct input_stream *input_stream)
{
flac_decode_internal(decoder, input_stream, false);
}
@@ -333,9 +333,9 @@ oggflac_scan_stream(struct input_stream *is,
}
static void
-oggflac_decode(struct decoder *decoder, struct input_stream *input_stream)
+oggflac_decode(Decoder &decoder, struct input_stream *input_stream)
{
- if (ogg_codec_detect(decoder, input_stream) != OGG_CODEC_FLAC)
+ if (ogg_codec_detect(&decoder, input_stream) != OGG_CODEC_FLAC)
return;
/* rewind the stream, because ogg_codec_detect() has
diff --git a/src/decoder/FlacInput.cxx b/src/decoder/FlacInput.cxx
index 399e78905..39e323716 100644
--- a/src/decoder/FlacInput.cxx
+++ b/src/decoder/FlacInput.cxx
@@ -35,7 +35,7 @@ FlacInput::Read(FLAC__byte buffer[], size_t *bytes)
if (r == 0) {
if (input_stream->LockIsEOF() ||
(decoder != nullptr &&
- decoder_get_command(decoder) != DecoderCommand::NONE))
+ decoder_get_command(*decoder) != DecoderCommand::NONE))
return FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM;
else
return FLAC__STREAM_DECODER_READ_STATUS_ABORT;
@@ -83,8 +83,8 @@ FLAC__bool
FlacInput::Eof()
{
return (decoder != nullptr &&
- decoder_get_command(decoder) != DecoderCommand::NONE &&
- decoder_get_command(decoder) != DecoderCommand::SEEK) ||
+ decoder_get_command(*decoder) != DecoderCommand::NONE &&
+ decoder_get_command(*decoder) != DecoderCommand::SEEK) ||
input_stream->LockIsEOF();
}
@@ -92,7 +92,7 @@ void
FlacInput::Error(FLAC__StreamDecoderErrorStatus status)
{
if (decoder == nullptr ||
- decoder_get_command(decoder) != DecoderCommand::STOP)
+ decoder_get_command(*decoder) != DecoderCommand::STOP)
LogWarning(flac_domain,
FLAC__StreamDecoderErrorStatusString[status]);
}
diff --git a/src/decoder/FlacInput.hxx b/src/decoder/FlacInput.hxx
index 8fc69f960..2879f5dd4 100644
--- a/src/decoder/FlacInput.hxx
+++ b/src/decoder/FlacInput.hxx
@@ -22,18 +22,20 @@
#include <FLAC/stream_decoder.h>
+struct Decoder;
+
/**
* This class wraps an #input_stream in libFLAC stream decoder
* callbacks.
*/
class FlacInput {
- struct decoder *decoder;
+ Decoder *const decoder;
struct input_stream *input_stream;
public:
FlacInput(struct input_stream *_input_stream,
- struct decoder *_decoder=nullptr)
+ Decoder *_decoder=nullptr)
:decoder(_decoder), input_stream(_input_stream) {}
protected:
diff --git a/src/decoder/FluidsynthDecoderPlugin.cxx b/src/decoder/FluidsynthDecoderPlugin.cxx
index 93d935c6c..fa946f219 100644
--- a/src/decoder/FluidsynthDecoderPlugin.cxx
+++ b/src/decoder/FluidsynthDecoderPlugin.cxx
@@ -92,7 +92,7 @@ fluidsynth_init(const config_param &param)
}
static void
-fluidsynth_file_decode(struct decoder *decoder, const char *path_fs)
+fluidsynth_file_decode(Decoder &decoder, const char *path_fs)
{
char setting_sample_rate[] = "synth.sample-rate";
/*
diff --git a/src/decoder/GmeDecoderPlugin.cxx b/src/decoder/GmeDecoderPlugin.cxx
index 76b0eea9d..815fd8d69 100644
--- a/src/decoder/GmeDecoderPlugin.cxx
+++ b/src/decoder/GmeDecoderPlugin.cxx
@@ -130,7 +130,7 @@ gme_container_scan(const char *path_fs, const unsigned int tnum)
}
static void
-gme_file_decode(struct decoder *decoder, const char *path_fs)
+gme_file_decode(Decoder &decoder, const char *path_fs)
{
char *path_container = get_container_name(path_fs);
diff --git a/src/decoder/MadDecoderPlugin.cxx b/src/decoder/MadDecoderPlugin.cxx
index e36bfeaac..4b25ef87b 100644
--- a/src/decoder/MadDecoderPlugin.cxx
+++ b/src/decoder/MadDecoderPlugin.cxx
@@ -139,11 +139,11 @@ struct MadDecoder {
bool found_first_frame;
bool decoded_first_frame;
unsigned long bit_rate;
- struct decoder *decoder;
+ Decoder *const decoder;
struct input_stream *input_stream;
enum mad_layer layer;
- MadDecoder(struct decoder *decoder, struct input_stream *input_stream);
+ MadDecoder(Decoder *decoder, struct input_stream *input_stream);
~MadDecoder();
bool Seek(long offset);
@@ -184,7 +184,7 @@ struct MadDecoder {
bool Read();
};
-MadDecoder::MadDecoder(struct decoder *_decoder,
+MadDecoder::MadDecoder(Decoder *_decoder,
struct input_stream *_input_stream)
:mute_frame(MUTEFRAME_NONE),
frame_offsets(nullptr),
@@ -397,12 +397,12 @@ MadDecoder::ParseId3(size_t tagsize, Tag **mpd_tag)
char *mixramp_end;
if (parse_id3_replay_gain_info(&rgi, id3_tag)) {
- decoder_replay_gain(decoder, &rgi);
+ decoder_replay_gain(*decoder, &rgi);
found_replay_gain = true;
}
if (parse_id3_mixramp(&mixramp_start, &mixramp_end, id3_tag))
- decoder_mixramp(decoder, mixramp_start, mixramp_end);
+ decoder_mixramp(*decoder, mixramp_start, mixramp_end);
}
id3_tag_delete(id3_tag);
@@ -875,7 +875,7 @@ MadDecoder::DecodeFirstFrame(Tag **tag)
replay_gain_info_init(&rgi);
rgi.tuples[REPLAY_GAIN_TRACK].gain = lame.track_gain;
rgi.tuples[REPLAY_GAIN_TRACK].peak = lame.peak;
- decoder_replay_gain(decoder, &rgi);
+ decoder_replay_gain(*decoder, &rgi);
}
}
}
@@ -979,7 +979,7 @@ MadDecoder::SendPCM(unsigned i, unsigned pcm_length)
MAD_NCHANNELS(&frame.header));
num_samples *= MAD_NCHANNELS(&frame.header);
- auto cmd = decoder_data(decoder, input_stream, output_buffer,
+ auto cmd = decoder_data(*decoder, input_stream, output_buffer,
sizeof(output_buffer[0]) * num_samples,
bit_rate / 1000);
if (cmd != DecoderCommand::NONE)
@@ -1065,17 +1065,17 @@ MadDecoder::Read()
assert(input_stream->IsSeekable());
- j = TimeToFrame(decoder_seek_where(decoder));
+ j = TimeToFrame(decoder_seek_where(*decoder));
if (j < highest_frame) {
if (Seek(frame_offsets[j])) {
current_frame = j;
- decoder_command_finished(decoder);
+ decoder_command_finished(*decoder);
} else
- decoder_seek_error(decoder);
+ decoder_seek_error(*decoder);
} else {
- seek_where = decoder_seek_where(decoder);
+ seek_where = decoder_seek_where(*decoder);
mute_frame = MUTEFRAME_SEEK;
- decoder_command_finished(decoder);
+ decoder_command_finished(*decoder);
}
} else if (cmd != DecoderCommand::NONE)
return false;
@@ -1090,7 +1090,7 @@ MadDecoder::Read()
ret = DecodeNextFrameHeader(&tag);
if (tag != nullptr) {
- decoder_tag(decoder, input_stream,
+ decoder_tag(*decoder, input_stream,
std::move(*tag));
delete tag;
}
@@ -1116,9 +1116,9 @@ MadDecoder::Read()
}
static void
-mp3_decode(struct decoder *decoder, struct input_stream *input_stream)
+mp3_decode(Decoder &decoder, struct input_stream *input_stream)
{
- MadDecoder data(decoder, input_stream);
+ MadDecoder data(&decoder, input_stream);
Tag *tag = nullptr;
if (!data.DecodeFirstFrame(&tag)) {
diff --git a/src/decoder/MikmodDecoderPlugin.cxx b/src/decoder/MikmodDecoderPlugin.cxx
index e2d8d76d1..34381aafa 100644
--- a/src/decoder/MikmodDecoderPlugin.cxx
+++ b/src/decoder/MikmodDecoderPlugin.cxx
@@ -146,7 +146,7 @@ mikmod_decoder_finish(void)
}
static void
-mikmod_decoder_file_decode(struct decoder *decoder, const char *path_fs)
+mikmod_decoder_file_decode(Decoder &decoder, const char *path_fs)
{
/* deconstify the path because libmikmod wants a non-const
string pointer */
diff --git a/src/decoder/ModplugDecoderPlugin.cxx b/src/decoder/ModplugDecoderPlugin.cxx
index d8c911f8e..a86166622 100644
--- a/src/decoder/ModplugDecoderPlugin.cxx
+++ b/src/decoder/ModplugDecoderPlugin.cxx
@@ -29,6 +29,7 @@
#include <libmodplug/modplug.h>
+
#include <assert.h>
static constexpr Domain modplug_domain("modplug");
@@ -51,7 +52,7 @@ modplug_decoder_init(const config_param &param)
}
static WritableBuffer<uint8_t>
-mod_loadfile(struct decoder *decoder, struct input_stream *is)
+mod_loadfile(Decoder *decoder, struct input_stream *is)
{
const input_stream::offset_type size = is->GetSize();
@@ -106,7 +107,7 @@ mod_loadfile(struct decoder *decoder, struct input_stream *is)
}
static ModPlugFile *
-LoadModPlugFile(struct decoder *decoder, struct input_stream *is)
+LoadModPlugFile(Decoder *decoder, struct input_stream *is)
{
const auto buffer = mod_loadfile(decoder, is);
if (buffer.IsNull()) {
@@ -120,7 +121,7 @@ LoadModPlugFile(struct decoder *decoder, struct input_stream *is)
}
static void
-mod_decode(struct decoder *decoder, struct input_stream *is)
+mod_decode(Decoder &decoder, struct input_stream *is)
{
ModPlug_Settings settings;
int ret;
@@ -136,7 +137,7 @@ mod_decode(struct decoder *decoder, struct input_stream *is)
/* insert more setting changes here */
ModPlug_SetSettings(&settings);
- ModPlugFile *f = LoadModPlugFile(decoder, is);
+ ModPlugFile *f = LoadModPlugFile(&decoder, is);
if (f == nullptr) {
LogWarning(modplug_domain, "could not decode stream");
return;
diff --git a/src/decoder/MpcdecDecoderPlugin.cxx b/src/decoder/MpcdecDecoderPlugin.cxx
index cc16ad838..1d38ec23b 100644
--- a/src/decoder/MpcdecDecoderPlugin.cxx
+++ b/src/decoder/MpcdecDecoderPlugin.cxx
@@ -36,7 +36,7 @@
struct mpc_decoder_data {
struct input_stream *is;
- struct decoder *decoder;
+ Decoder *decoder;
};
static constexpr Domain mpcdec_domain("mpcdec");
@@ -130,13 +130,13 @@ mpc_to_mpd_buffer(int32_t *dest, const MPC_SAMPLE_FORMAT *src,
}
static void
-mpcdec_decode(struct decoder *mpd_decoder, struct input_stream *is)
+mpcdec_decode(Decoder &mpd_decoder, struct input_stream *is)
{
MPC_SAMPLE_FORMAT sample_buffer[MPC_DECODER_BUFFER_LENGTH];
struct mpc_decoder_data data;
data.is = is;
- data.decoder = mpd_decoder;
+ data.decoder = &mpd_decoder;
mpc_reader reader;
reader.read = mpc_read_cb;
diff --git a/src/decoder/Mpg123DecoderPlugin.cxx b/src/decoder/Mpg123DecoderPlugin.cxx
index 9aa06831f..df23f7847 100644
--- a/src/decoder/Mpg123DecoderPlugin.cxx
+++ b/src/decoder/Mpg123DecoderPlugin.cxx
@@ -104,7 +104,7 @@ mpd_mpg123_open(mpg123_handle *handle, const char *path_fs,
}
static void
-mpd_mpg123_file_decode(struct decoder *decoder, const char *path_fs)
+mpd_mpg123_file_decode(Decoder &decoder, const char *path_fs)
{
mpg123_handle *handle;
int error;
diff --git a/src/decoder/OggCodec.cxx b/src/decoder/OggCodec.cxx
index d7e5b7642..adc88188e 100644
--- a/src/decoder/OggCodec.cxx
+++ b/src/decoder/OggCodec.cxx
@@ -27,7 +27,7 @@
#include <string.h>
enum ogg_codec
-ogg_codec_detect(struct decoder *decoder, struct input_stream *is)
+ogg_codec_detect(Decoder *decoder, struct input_stream *is)
{
/* oggflac detection based on code in ogg123 and this post
* http://lists.xiph.org/pipermail/flac/2004-December/000393.html
diff --git a/src/decoder/OggCodec.hxx b/src/decoder/OggCodec.hxx
index eb709286b..b24b4ec5c 100644
--- a/src/decoder/OggCodec.hxx
+++ b/src/decoder/OggCodec.hxx
@@ -34,6 +34,6 @@ enum ogg_codec {
};
enum ogg_codec
-ogg_codec_detect(struct decoder *decoder, struct input_stream *is);
+ogg_codec_detect(Decoder *decoder, struct input_stream *is);
#endif /* _OGG_COMMON_H */
diff --git a/src/decoder/OggSyncState.hxx b/src/decoder/OggSyncState.hxx
index eaeb9bd8c..c85b931bb 100644
--- a/src/decoder/OggSyncState.hxx
+++ b/src/decoder/OggSyncState.hxx
@@ -34,10 +34,10 @@ class OggSyncState {
ogg_sync_state oy;
input_stream &is;
- struct decoder *const decoder;
+ Decoder *const decoder;
public:
- OggSyncState(input_stream &_is, struct decoder *const _decoder=nullptr)
+ OggSyncState(input_stream &_is, Decoder *const _decoder=nullptr)
:is(_is), decoder(_decoder) {
ogg_sync_init(&oy);
}
diff --git a/src/decoder/OggUtil.cxx b/src/decoder/OggUtil.cxx
index 0e2f48f51..294a87276 100644
--- a/src/decoder/OggUtil.cxx
+++ b/src/decoder/OggUtil.cxx
@@ -22,7 +22,7 @@
#include "DecoderAPI.hxx"
bool
-OggFeed(ogg_sync_state &oy, struct decoder *decoder,
+OggFeed(ogg_sync_state &oy, Decoder *decoder,
input_stream *input_stream, size_t size)
{
char *buffer = ogg_sync_buffer(&oy, size);
@@ -40,7 +40,7 @@ OggFeed(ogg_sync_state &oy, struct decoder *decoder,
bool
OggExpectPage(ogg_sync_state &oy, ogg_page &page,
- decoder *decoder, input_stream *input_stream)
+ Decoder *decoder, input_stream *input_stream)
{
while (true) {
int r = ogg_sync_pageout(&oy, &page);
@@ -54,7 +54,7 @@ OggExpectPage(ogg_sync_state &oy, ogg_page &page,
bool
OggExpectFirstPage(ogg_sync_state &oy, ogg_stream_state &os,
- decoder *decoder, input_stream *is)
+ Decoder *decoder, input_stream *is)
{
ogg_page page;
if (!OggExpectPage(oy, page, decoder, is))
@@ -67,7 +67,7 @@ OggExpectFirstPage(ogg_sync_state &oy, ogg_stream_state &os,
bool
OggExpectPageIn(ogg_sync_state &oy, ogg_stream_state &os,
- decoder *decoder, input_stream *is)
+ Decoder *decoder, input_stream *is)
{
ogg_page page;
if (!OggExpectPage(oy, page, decoder, is))
@@ -79,7 +79,7 @@ OggExpectPageIn(ogg_sync_state &oy, ogg_stream_state &os,
bool
OggExpectPageSeek(ogg_sync_state &oy, ogg_page &page,
- decoder *decoder, input_stream *input_stream)
+ Decoder *decoder, input_stream *input_stream)
{
size_t remaining_skipped = 16384;
@@ -107,7 +107,7 @@ OggExpectPageSeek(ogg_sync_state &oy, ogg_page &page,
bool
OggExpectPageSeekIn(ogg_sync_state &oy, ogg_stream_state &os,
- decoder *decoder, input_stream *is)
+ Decoder *decoder, input_stream *is)
{
ogg_page page;
if (!OggExpectPageSeek(oy, page, decoder, is))
diff --git a/src/decoder/OggUtil.hxx b/src/decoder/OggUtil.hxx
index 324797815..77ec83f2c 100644
--- a/src/decoder/OggUtil.hxx
+++ b/src/decoder/OggUtil.hxx
@@ -27,7 +27,7 @@
#include <stddef.h>
struct input_stream;
-struct decoder;
+struct Decoder;
/**
* Feed data from the #input_stream into the #ogg_sync_state.
@@ -35,7 +35,7 @@ struct decoder;
* @return false on error or end-of-file
*/
bool
-OggFeed(ogg_sync_state &oy, struct decoder *decoder, input_stream *is,
+OggFeed(ogg_sync_state &oy, Decoder *decoder, input_stream *is,
size_t size);
/**
@@ -46,7 +46,7 @@ OggFeed(ogg_sync_state &oy, struct decoder *decoder, input_stream *is,
*/
bool
OggExpectPage(ogg_sync_state &oy, ogg_page &page,
- decoder *decoder, input_stream *input_stream);
+ Decoder *decoder, input_stream *input_stream);
/**
* Combines OggExpectPage(), ogg_stream_init() and
@@ -57,7 +57,7 @@ OggExpectPage(ogg_sync_state &oy, ogg_page &page,
*/
bool
OggExpectFirstPage(ogg_sync_state &oy, ogg_stream_state &os,
- decoder *decoder, input_stream *is);
+ Decoder *decoder, input_stream *is);
/**
* Combines OggExpectPage() and ogg_stream_pagein().
@@ -66,14 +66,14 @@ OggExpectFirstPage(ogg_sync_state &oy, ogg_stream_state &os,
*/
bool
OggExpectPageIn(ogg_sync_state &oy, ogg_stream_state &os,
- decoder *decoder, input_stream *is);
+ Decoder *decoder, input_stream *is);
/**
* Like OggExpectPage(), but allow skipping garbage (after seeking).
*/
bool
OggExpectPageSeek(ogg_sync_state &oy, ogg_page &page,
- decoder *decoder, input_stream *input_stream);
+ Decoder *decoder, input_stream *input_stream);
/**
* Combines OggExpectPageSeek() and ogg_stream_pagein().
@@ -82,6 +82,6 @@ OggExpectPageSeek(ogg_sync_state &oy, ogg_page &page,
*/
bool
OggExpectPageSeekIn(ogg_sync_state &oy, ogg_stream_state &os,
- decoder *decoder, input_stream *is);
+ Decoder *decoder, input_stream *is);
#endif
diff --git a/src/decoder/OpusDecoderPlugin.cxx b/src/decoder/OpusDecoderPlugin.cxx
index ade611e31..48267e104 100644
--- a/src/decoder/OpusDecoderPlugin.cxx
+++ b/src/decoder/OpusDecoderPlugin.cxx
@@ -67,7 +67,7 @@ mpd_opus_init(gcc_unused const config_param &param)
}
class MPDOpusDecoder {
- struct decoder *decoder;
+ Decoder &decoder;
struct input_stream *input_stream;
ogg_stream_state os;
@@ -84,7 +84,7 @@ class MPDOpusDecoder {
size_t frame_size;
public:
- MPDOpusDecoder(struct decoder *_decoder,
+ MPDOpusDecoder(Decoder &_decoder,
struct input_stream *_input_stream)
:decoder(_decoder), input_stream(_input_stream),
opus_decoder(nullptr),
@@ -265,10 +265,10 @@ MPDOpusDecoder::HandleAudio(const ogg_packet &packet)
}
static void
-mpd_opus_stream_decode(struct decoder *decoder,
+mpd_opus_stream_decode(Decoder &decoder,
struct input_stream *input_stream)
{
- if (ogg_codec_detect(decoder, input_stream) != OGG_CODEC_OPUS)
+ if (ogg_codec_detect(&decoder, input_stream) != OGG_CODEC_OPUS)
return;
/* rewind the stream, because ogg_codec_detect() has
@@ -276,7 +276,7 @@ mpd_opus_stream_decode(struct decoder *decoder,
input_stream->LockSeek(0, SEEK_SET, IgnoreError());
MPDOpusDecoder d(decoder, input_stream);
- OggSyncState oy(*input_stream, decoder);
+ OggSyncState oy(*input_stream, &decoder);
if (!d.ReadFirstPage(oy))
return;
diff --git a/src/decoder/PcmDecoderPlugin.cxx b/src/decoder/PcmDecoderPlugin.cxx
index 8cde45cd7..0a19ed59b 100644
--- a/src/decoder/PcmDecoderPlugin.cxx
+++ b/src/decoder/PcmDecoderPlugin.cxx
@@ -31,7 +31,7 @@
#include <stdio.h> /* for SEEK_SET */
static void
-pcm_stream_decode(struct decoder *decoder, struct input_stream *is)
+pcm_stream_decode(Decoder &decoder, struct input_stream *is)
{
static constexpr AudioFormat audio_format = {
44100,
diff --git a/src/decoder/SidplayDecoderPlugin.cxx b/src/decoder/SidplayDecoderPlugin.cxx
index a31eee3a8..d2778867c 100644
--- a/src/decoder/SidplayDecoderPlugin.cxx
+++ b/src/decoder/SidplayDecoderPlugin.cxx
@@ -201,7 +201,7 @@ get_song_length(const char *path_fs)
}
static void
-sidplay_file_decode(struct decoder *decoder, const char *path_fs)
+sidplay_file_decode(Decoder &decoder, const char *path_fs)
{
int channels;
diff --git a/src/decoder/SndfileDecoderPlugin.cxx b/src/decoder/SndfileDecoderPlugin.cxx
index 6f4c5bb33..5f5c256e9 100644
--- a/src/decoder/SndfileDecoderPlugin.cxx
+++ b/src/decoder/SndfileDecoderPlugin.cxx
@@ -113,7 +113,7 @@ time_to_frame(float t, const AudioFormat *audio_format)
}
static void
-sndfile_stream_decode(struct decoder *decoder, struct input_stream *is)
+sndfile_stream_decode(Decoder &decoder, struct input_stream *is)
{
SNDFILE *sf;
SF_INFO info;
diff --git a/src/decoder/VorbisDecoderPlugin.cxx b/src/decoder/VorbisDecoderPlugin.cxx
index a7fbb9290..105ca018e 100644
--- a/src/decoder/VorbisDecoderPlugin.cxx
+++ b/src/decoder/VorbisDecoderPlugin.cxx
@@ -53,7 +53,7 @@
#include <unistd.h>
struct vorbis_input_stream {
- struct decoder *decoder;
+ Decoder *decoder;
struct input_stream *input_stream;
bool seekable;
@@ -76,7 +76,8 @@ static int ogg_seek_cb(void *data, ogg_int64_t offset, int whence)
Error error;
return vis->seekable &&
- (!vis->decoder || decoder_get_command(vis->decoder) != DecoderCommand::STOP) &&
+ (vis->decoder == nullptr ||
+ decoder_get_command(*vis->decoder) != DecoderCommand::STOP) &&
vis->input_stream->LockSeek(offset, whence, error)
? 0 : -1;
}
@@ -127,7 +128,7 @@ vorbis_strerror(int code)
static bool
vorbis_is_open(struct vorbis_input_stream *vis, OggVorbis_File *vf,
- struct decoder *decoder, struct input_stream *input_stream)
+ Decoder *decoder, struct input_stream *input_stream)
{
vis->decoder = decoder;
vis->input_stream = input_stream;
@@ -136,7 +137,7 @@ vorbis_is_open(struct vorbis_input_stream *vis, OggVorbis_File *vf,
int ret = ov_open_callbacks(vis, vf, NULL, 0, vorbis_is_callbacks);
if (ret < 0) {
if (decoder == NULL ||
- decoder_get_command(decoder) == DecoderCommand::NONE)
+ decoder_get_command(*decoder) == DecoderCommand::NONE)
FormatWarning(vorbis_domain,
"Failed to open Ogg Vorbis stream: %s",
vorbis_strerror(ret));
@@ -147,7 +148,7 @@ vorbis_is_open(struct vorbis_input_stream *vis, OggVorbis_File *vf,
}
static void
-vorbis_send_comments(struct decoder *decoder, struct input_stream *is,
+vorbis_send_comments(Decoder &decoder, struct input_stream *is,
char **comments)
{
Tag *tag = vorbis_comments_to_tag(comments);
@@ -175,10 +176,10 @@ vorbis_interleave(float *dest, const float *const*src,
/* public */
static void
-vorbis_stream_decode(struct decoder *decoder,
+vorbis_stream_decode(Decoder &decoder,
struct input_stream *input_stream)
{
- if (ogg_codec_detect(decoder, input_stream) != OGG_CODEC_VORBIS)
+ if (ogg_codec_detect(&decoder, input_stream) != OGG_CODEC_VORBIS)
return;
/* rewind the stream, because ogg_codec_detect() has
@@ -187,7 +188,7 @@ vorbis_stream_decode(struct decoder *decoder,
struct vorbis_input_stream vis;
OggVorbis_File vf;
- if (!vorbis_is_open(&vis, &vf, decoder, input_stream))
+ if (!vorbis_is_open(&vis, &vf, &decoder, input_stream))
return;
const vorbis_info *vi = ov_info(&vf, -1);
diff --git a/src/decoder/WavpackDecoderPlugin.cxx b/src/decoder/WavpackDecoderPlugin.cxx
index 098436c4f..9805a5f78 100644
--- a/src/decoder/WavpackDecoderPlugin.cxx
+++ b/src/decoder/WavpackDecoderPlugin.cxx
@@ -138,7 +138,7 @@ wavpack_bits_to_sample_format(bool is_float, int bytes_per_sample)
* Requires an already opened WavpackContext.
*/
static void
-wavpack_decode(struct decoder *decoder, WavpackContext *wpc, bool can_seek)
+wavpack_decode(Decoder &decoder, WavpackContext *wpc, bool can_seek)
{
bool is_float;
SampleFormat sample_format;
@@ -345,7 +345,7 @@ wavpack_scan_file(const char *fname,
/* This struct is needed for per-stream last_byte storage. */
struct wavpack_input {
- struct decoder *decoder;
+ Decoder *decoder;
struct input_stream *is;
/* Needed for push_back_byte() */
int last_byte;
@@ -449,16 +449,16 @@ static WavpackStreamReader mpd_is_reader = {
};
static void
-wavpack_input_init(struct wavpack_input *isp, struct decoder *decoder,
+wavpack_input_init(struct wavpack_input *isp, Decoder &decoder,
struct input_stream *is)
{
- isp->decoder = decoder;
+ isp->decoder = &decoder;
isp->is = is;
isp->last_byte = EOF;
}
static struct input_stream *
-wavpack_open_wvc(struct decoder *decoder, const char *uri,
+wavpack_open_wvc(Decoder &decoder, const char *uri,
Mutex &mutex, Cond &cond,
struct wavpack_input *wpi)
{
@@ -504,7 +504,7 @@ wavpack_open_wvc(struct decoder *decoder, const char *uri,
* Decodes a stream.
*/
static void
-wavpack_streamdecode(struct decoder * decoder, struct input_stream *is)
+wavpack_streamdecode(Decoder & decoder, struct input_stream *is)
{
char error[ERRORLEN];
WavpackContext *wpc;
@@ -550,7 +550,7 @@ wavpack_streamdecode(struct decoder * decoder, struct input_stream *is)
* Decodes a file.
*/
static void
-wavpack_filedecode(struct decoder *decoder, const char *fname)
+wavpack_filedecode(Decoder &decoder, const char *fname)
{
char error[ERRORLEN];
WavpackContext *wpc;
diff --git a/src/decoder/WildmidiDecoderPlugin.cxx b/src/decoder/WildmidiDecoderPlugin.cxx
index 0b2ffb6c3..3da3f1387 100644
--- a/src/decoder/WildmidiDecoderPlugin.cxx
+++ b/src/decoder/WildmidiDecoderPlugin.cxx
@@ -65,7 +65,7 @@ wildmidi_finish(void)
}
static void
-wildmidi_file_decode(struct decoder *decoder, const char *path_fs)
+wildmidi_file_decode(Decoder &decoder, const char *path_fs)
{
static constexpr AudioFormat audio_format = {
WILDMIDI_SAMPLE_RATE,