aboutsummaryrefslogtreecommitdiffstats
path: root/src/decoder
diff options
context:
space:
mode:
Diffstat (limited to 'src/decoder')
-rw-r--r--src/decoder/AdPlugDecoderPlugin.cxx4
-rw-r--r--src/decoder/AudiofileDecoderPlugin.cxx8
-rw-r--r--src/decoder/DsdiffDecoderPlugin.cxx11
-rw-r--r--src/decoder/DsfDecoderPlugin.cxx11
-rw-r--r--src/decoder/FaadDecoderPlugin.cxx6
-rw-r--r--src/decoder/FfmpegDecoderPlugin.cxx13
-rw-r--r--src/decoder/FlacCommon.cxx15
-rw-r--r--src/decoder/FlacDecoderPlugin.cxx8
-rw-r--r--src/decoder/FlacInput.cxx8
-rw-r--r--src/decoder/FluidsynthDecoderPlugin.cxx4
-rw-r--r--src/decoder/GmeDecoderPlugin.cxx6
-rw-r--r--src/decoder/MadDecoderPlugin.cxx40
-rw-r--r--src/decoder/MikmodDecoderPlugin.cxx5
-rw-r--r--src/decoder/ModplugDecoderPlugin.cxx6
-rw-r--r--src/decoder/MpcdecDecoderPlugin.cxx8
-rw-r--r--src/decoder/Mpg123DecoderPlugin.cxx8
-rw-r--r--src/decoder/OpusDecoderPlugin.cxx55
-rw-r--r--src/decoder/PcmDecoderPlugin.cxx9
-rw-r--r--src/decoder/SndfileDecoderPlugin.cxx8
-rw-r--r--src/decoder/VorbisDecoderPlugin.cxx11
-rw-r--r--src/decoder/WavpackDecoderPlugin.cxx6
-rw-r--r--src/decoder/WildmidiDecoderPlugin.cxx8
-rw-r--r--src/decoder/sidplay_decoder_plugin.cxx6
23 files changed, 129 insertions, 135 deletions
diff --git a/src/decoder/AdPlugDecoderPlugin.cxx b/src/decoder/AdPlugDecoderPlugin.cxx
index 51a3f7ea7..5c04e116d 100644
--- a/src/decoder/AdPlugDecoderPlugin.cxx
+++ b/src/decoder/AdPlugDecoderPlugin.cxx
@@ -68,7 +68,7 @@ adplug_file_decode(struct decoder *decoder, const char *path_fs)
int16_t buffer[2048];
const unsigned frames_per_buffer = G_N_ELEMENTS(buffer) / 2;
- enum decoder_command cmd;
+ DecoderCommand cmd;
do {
if (!player->update())
@@ -78,7 +78,7 @@ adplug_file_decode(struct decoder *decoder, const char *path_fs)
cmd = decoder_data(decoder, NULL,
buffer, sizeof(buffer),
0);
- } while (cmd == DECODE_COMMAND_NONE);
+ } while (cmd == DecoderCommand::NONE);
delete player;
}
diff --git a/src/decoder/AudiofileDecoderPlugin.cxx b/src/decoder/AudiofileDecoderPlugin.cxx
index 6b638bb3f..1ee57de4a 100644
--- a/src/decoder/AudiofileDecoderPlugin.cxx
+++ b/src/decoder/AudiofileDecoderPlugin.cxx
@@ -166,7 +166,6 @@ audiofile_stream_decode(struct decoder *decoder, struct input_stream *is)
uint16_t bit_rate;
int ret;
char chunk[CHUNK_SIZE];
- enum decoder_command cmd;
if (!is->IsSeekable()) {
g_warning("not seekable");
@@ -202,6 +201,7 @@ audiofile_stream_decode(struct decoder *decoder, struct input_stream *is)
decoder_initialized(decoder, audio_format, true, total_time);
+ DecoderCommand cmd;
do {
ret = afReadFrames(af_fp, AF_DEFAULT_TRACK, chunk,
CHUNK_SIZE / fs);
@@ -212,15 +212,15 @@ audiofile_stream_decode(struct decoder *decoder, struct input_stream *is)
chunk, ret * fs,
bit_rate);
- if (cmd == DECODE_COMMAND_SEEK) {
+ if (cmd == DecoderCommand::SEEK) {
AFframecount frame = decoder_seek_where(decoder) *
audio_format.sample_rate;
afSeekFrame(af_fp, AF_DEFAULT_TRACK, frame);
decoder_command_finished(decoder);
- cmd = DECODE_COMMAND_NONE;
+ cmd = DecoderCommand::NONE;
}
- } while (cmd == DECODE_COMMAND_NONE);
+ } while (cmd == DecoderCommand::NONE);
afCloseFile(af_fp);
}
diff --git a/src/decoder/DsdiffDecoderPlugin.cxx b/src/decoder/DsdiffDecoderPlugin.cxx
index 49b0c601d..80b88a2c2 100644
--- a/src/decoder/DsdiffDecoderPlugin.cxx
+++ b/src/decoder/DsdiffDecoderPlugin.cxx
@@ -403,17 +403,16 @@ dsdiff_decode_chunk(struct decoder *decoder, struct input_stream *is,
if (lsbitfirst)
bit_reverse_buffer(buffer, buffer + nbytes);
- enum decoder_command cmd =
- decoder_data(decoder, is, buffer, nbytes, 0);
+ const auto cmd = decoder_data(decoder, is, buffer, nbytes, 0);
switch (cmd) {
- case DECODE_COMMAND_NONE:
+ case DecoderCommand::NONE:
break;
- case DECODE_COMMAND_START:
- case DECODE_COMMAND_STOP:
+ case DecoderCommand::START:
+ case DecoderCommand::STOP:
return false;
- case DECODE_COMMAND_SEEK:
+ case DecoderCommand::SEEK:
/* Not implemented yet */
decoder_seek_error(decoder);
diff --git a/src/decoder/DsfDecoderPlugin.cxx b/src/decoder/DsfDecoderPlugin.cxx
index 275f34929..b327fc9dc 100644
--- a/src/decoder/DsfDecoderPlugin.cxx
+++ b/src/decoder/DsfDecoderPlugin.cxx
@@ -258,17 +258,16 @@ dsf_decode_chunk(struct decoder *decoder, struct input_stream *is,
dsf_to_pcm_order(buffer, dsf_scratch_buffer, nbytes);
- enum decoder_command cmd =
- decoder_data(decoder, is, buffer, nbytes, 0);
+ const auto cmd = decoder_data(decoder, is, buffer, nbytes, 0);
switch (cmd) {
- case DECODE_COMMAND_NONE:
+ case DecoderCommand::NONE:
break;
- case DECODE_COMMAND_START:
- case DECODE_COMMAND_STOP:
+ case DecoderCommand::START:
+ case DecoderCommand::STOP:
return false;
- case DECODE_COMMAND_SEEK:
+ case DecoderCommand::SEEK:
/* not implemented yet */
decoder_seek_error(decoder);
diff --git a/src/decoder/FaadDecoderPlugin.cxx b/src/decoder/FaadDecoderPlugin.cxx
index c8acfb521..f026a6216 100644
--- a/src/decoder/FaadDecoderPlugin.cxx
+++ b/src/decoder/FaadDecoderPlugin.cxx
@@ -368,7 +368,6 @@ faad_stream_decode(struct decoder *mpd_decoder, struct input_stream *is)
bool ret;
uint16_t bit_rate = 0;
DecoderBuffer *buffer;
- enum decoder_command cmd;
buffer = decoder_buffer_new(mpd_decoder, is,
FAAD_MIN_STREAMSIZE * AAC_MAX_CHANNELS);
@@ -386,7 +385,7 @@ faad_stream_decode(struct decoder *mpd_decoder, struct input_stream *is)
NeAACDecSetConfiguration(decoder, config);
while (!decoder_buffer_is_full(buffer) && !is->LockIsEOF() &&
- decoder_get_command(mpd_decoder) == DECODE_COMMAND_NONE) {
+ decoder_get_command(mpd_decoder) == DecoderCommand::NONE) {
adts_find_frame(buffer);
decoder_buffer_fill(buffer);
}
@@ -407,6 +406,7 @@ faad_stream_decode(struct decoder *mpd_decoder, struct input_stream *is)
/* the decoder loop */
+ DecoderCommand cmd;
do {
size_t frame_size;
const void *decoded;
@@ -457,7 +457,7 @@ faad_stream_decode(struct decoder *mpd_decoder, struct input_stream *is)
cmd = decoder_data(mpd_decoder, is, decoded,
(size_t)frame_info.samples * 2,
bit_rate);
- } while (cmd != DECODE_COMMAND_STOP);
+ } while (cmd != DecoderCommand::STOP);
/* cleanup */
diff --git a/src/decoder/FfmpegDecoderPlugin.cxx b/src/decoder/FfmpegDecoderPlugin.cxx
index a0ac5b8fb..a725e1f7d 100644
--- a/src/decoder/FfmpegDecoderPlugin.cxx
+++ b/src/decoder/FfmpegDecoderPlugin.cxx
@@ -253,7 +253,7 @@ copy_interleave_frame(const AVCodecContext *codec_context,
return data_size;
}
-static enum decoder_command
+static DecoderCommand
ffmpeg_send_packet(struct decoder *decoder, struct input_stream *is,
const AVPacket *packet,
AVCodecContext *codec_context,
@@ -269,9 +269,8 @@ ffmpeg_send_packet(struct decoder *decoder, struct input_stream *is,
uint8_t *output_buffer;
- enum decoder_command cmd = DECODE_COMMAND_NONE;
- while (packet2.size > 0 &&
- cmd == DECODE_COMMAND_NONE) {
+ DecoderCommand cmd = DecoderCommand::NONE;
+ while (packet2.size > 0 && cmd == DecoderCommand::NONE) {
int audio_size = 0;
int got_frame = 0;
int len = avcodec_decode_audio4(codec_context,
@@ -470,7 +469,7 @@ ffmpeg_decode(struct decoder *decoder, struct input_stream *input)
uint8_t *interleaved_buffer = NULL;
int interleaved_buffer_size = 0;
- enum decoder_command cmd;
+ DecoderCommand cmd;
do {
AVPacket packet;
if (av_read_frame(format_context, &packet) < 0)
@@ -488,7 +487,7 @@ ffmpeg_decode(struct decoder *decoder, struct input_stream *input)
av_free_packet(&packet);
- if (cmd == DECODE_COMMAND_SEEK) {
+ if (cmd == DecoderCommand::SEEK) {
int64_t where =
time_to_ffmpeg(decoder_seek_where(decoder),
av_stream->time_base);
@@ -501,7 +500,7 @@ ffmpeg_decode(struct decoder *decoder, struct input_stream *input)
decoder_command_finished(decoder);
}
}
- } while (cmd != DECODE_COMMAND_STOP);
+ } while (cmd != DecoderCommand::STOP);
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(54, 28, 0)
avcodec_free_frame(&frame);
diff --git a/src/decoder/FlacCommon.cxx b/src/decoder/FlacCommon.cxx
index 62409d3cc..9f5d81f85 100644
--- a/src/decoder/FlacCommon.cxx
+++ b/src/decoder/FlacCommon.cxx
@@ -158,7 +158,6 @@ flac_common_write(struct flac_data *data, const FLAC__Frame * frame,
const FLAC__int32 *const buf[],
FLAC__uint64 nbytes)
{
- enum decoder_command cmd;
void *buffer;
unsigned bit_rate;
@@ -178,19 +177,19 @@ flac_common_write(struct flac_data *data, const FLAC__Frame * frame,
else
bit_rate = 0;
- cmd = decoder_data(data->decoder, data->input_stream,
- buffer, buffer_size,
- bit_rate);
+ auto cmd = decoder_data(data->decoder, data->input_stream,
+ buffer, buffer_size,
+ bit_rate);
data->next_frame += frame->header.blocksize;
switch (cmd) {
- case DECODE_COMMAND_NONE:
- case DECODE_COMMAND_START:
+ case DecoderCommand::NONE:
+ case DecoderCommand::START:
break;
- case DECODE_COMMAND_STOP:
+ case DecoderCommand::STOP:
return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT;
- case DECODE_COMMAND_SEEK:
+ case DecoderCommand::SEEK:
return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE;
}
diff --git a/src/decoder/FlacDecoderPlugin.cxx b/src/decoder/FlacDecoderPlugin.cxx
index c5dd03665..a6b10fbe2 100644
--- a/src/decoder/FlacDecoderPlugin.cxx
+++ b/src/decoder/FlacDecoderPlugin.cxx
@@ -168,11 +168,11 @@ flac_decoder_loop(struct flac_data *data, FLAC__StreamDecoder *flac_dec,
FLAC__uint64 t_start, FLAC__uint64 t_end)
{
struct decoder *decoder = data->decoder;
- enum decoder_command cmd;
data->first_frame = t_start;
while (true) {
+ DecoderCommand cmd;
if (!data->tag.IsEmpty()) {
cmd = decoder_tag(data->decoder, data->input_stream,
std::move(data->tag));
@@ -180,7 +180,7 @@ flac_decoder_loop(struct flac_data *data, FLAC__StreamDecoder *flac_dec,
} else
cmd = decoder_get_command(decoder);
- if (cmd == DECODE_COMMAND_SEEK) {
+ if (cmd == DecoderCommand::SEEK) {
FLAC__uint64 seek_sample = t_start +
decoder_seek_where(decoder) *
data->audio_format.sample_rate;
@@ -192,7 +192,7 @@ flac_decoder_loop(struct flac_data *data, FLAC__StreamDecoder *flac_dec,
decoder_command_finished(decoder);
} else
decoder_seek_error(decoder);
- } else if (cmd == DECODE_COMMAND_STOP ||
+ } else if (cmd == DecoderCommand::STOP ||
FLAC__stream_decoder_get_state(flac_dec) == FLAC__STREAM_DECODER_END_OF_STREAM)
break;
@@ -201,7 +201,7 @@ flac_decoder_loop(struct flac_data *data, FLAC__StreamDecoder *flac_dec,
break;
if (!FLAC__stream_decoder_process_single(flac_dec) &&
- decoder_get_command(decoder) == DECODE_COMMAND_NONE) {
+ decoder_get_command(decoder) == DecoderCommand::NONE) {
/* a failure that was not triggered by a
decoder command */
flacPrintErroredState(FLAC__stream_decoder_get_state(flac_dec));
diff --git a/src/decoder/FlacInput.cxx b/src/decoder/FlacInput.cxx
index 947177cde..19abfca81 100644
--- a/src/decoder/FlacInput.cxx
+++ b/src/decoder/FlacInput.cxx
@@ -33,7 +33,7 @@ FlacInput::Read(FLAC__byte buffer[], size_t *bytes)
if (r == 0) {
if (input_stream->LockIsEOF() ||
(decoder != nullptr &&
- decoder_get_command(decoder) != DECODE_COMMAND_NONE))
+ decoder_get_command(decoder) != DecoderCommand::NONE))
return FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM;
else
return FLAC__STREAM_DECODER_READ_STATUS_ABORT;
@@ -79,8 +79,8 @@ FLAC__bool
FlacInput::Eof()
{
return (decoder != nullptr &&
- decoder_get_command(decoder) != DECODE_COMMAND_NONE &&
- decoder_get_command(decoder) != DECODE_COMMAND_SEEK) ||
+ decoder_get_command(decoder) != DecoderCommand::NONE &&
+ decoder_get_command(decoder) != DecoderCommand::SEEK) ||
input_stream->LockIsEOF();
}
@@ -88,7 +88,7 @@ void
FlacInput::Error(FLAC__StreamDecoderErrorStatus status)
{
if (decoder == nullptr ||
- decoder_get_command(decoder) != DECODE_COMMAND_STOP)
+ decoder_get_command(decoder) != DecoderCommand::STOP)
g_warning("%s", FLAC__StreamDecoderErrorStatusString[status]);
}
diff --git a/src/decoder/FluidsynthDecoderPlugin.cxx b/src/decoder/FluidsynthDecoderPlugin.cxx
index 533f02ef1..4db4f1618 100644
--- a/src/decoder/FluidsynthDecoderPlugin.cxx
+++ b/src/decoder/FluidsynthDecoderPlugin.cxx
@@ -102,7 +102,6 @@ fluidsynth_file_decode(struct decoder *decoder, const char *path_fs)
fluid_synth_t *synth;
fluid_player_t *player;
int ret;
- enum decoder_command cmd;
/* set up fluid settings */
@@ -167,6 +166,7 @@ fluidsynth_file_decode(struct decoder *decoder, const char *path_fs)
const AudioFormat audio_format(sample_rate, SampleFormat::S16, 2);
decoder_initialized(decoder, audio_format, false, -1);
+ DecoderCommand cmd;
while (fluid_player_get_status(player) == FLUID_PLAYER_PLAYING) {
int16_t buffer[2048];
const unsigned max_frames = G_N_ELEMENTS(buffer) / 2;
@@ -182,7 +182,7 @@ fluidsynth_file_decode(struct decoder *decoder, const char *path_fs)
cmd = decoder_data(decoder, nullptr, buffer, sizeof(buffer),
0);
- if (cmd != DECODE_COMMAND_NONE)
+ if (cmd != DecoderCommand::NONE)
break;
}
diff --git a/src/decoder/GmeDecoderPlugin.cxx b/src/decoder/GmeDecoderPlugin.cxx
index cc31c6bab..dbe1d000f 100644
--- a/src/decoder/GmeDecoderPlugin.cxx
+++ b/src/decoder/GmeDecoderPlugin.cxx
@@ -174,7 +174,7 @@ gme_file_decode(struct decoder *decoder, const char *path_fs)
gme_set_fade(emu, ti->length);
/* play */
- enum decoder_command cmd;
+ DecoderCommand cmd;
do {
short buf[GME_BUFFER_SAMPLES];
gme_err = gme_play(emu, GME_BUFFER_SAMPLES, buf);
@@ -184,7 +184,7 @@ gme_file_decode(struct decoder *decoder, const char *path_fs)
}
cmd = decoder_data(decoder, nullptr, buf, sizeof(buf), 0);
- if (cmd == DECODE_COMMAND_SEEK) {
+ if (cmd == DecoderCommand::SEEK) {
float where = decoder_seek_where(decoder);
gme_err = gme_seek(emu, int(where * 1000));
if (gme_err != nullptr)
@@ -194,7 +194,7 @@ gme_file_decode(struct decoder *decoder, const char *path_fs)
if (gme_track_ended(emu))
break;
- } while (cmd != DECODE_COMMAND_STOP);
+ } while (cmd != DecoderCommand::STOP);
gme_free_info(ti);
gme_delete(emu);
diff --git a/src/decoder/MadDecoderPlugin.cxx b/src/decoder/MadDecoderPlugin.cxx
index dc2d0b806..b7d90892b 100644
--- a/src/decoder/MadDecoderPlugin.cxx
+++ b/src/decoder/MadDecoderPlugin.cxx
@@ -171,13 +171,13 @@ struct MadDecoder {
/**
* Sends the synthesized current frame via decoder_data().
*/
- enum decoder_command SendPCM(unsigned i, unsigned pcm_length);
+ DecoderCommand SendPCM(unsigned i, unsigned pcm_length);
/**
* Synthesize the current frame and send it via
* decoder_data().
*/
- enum decoder_command SyncAndSend();
+ DecoderCommand SyncAndSend();
bool Read();
};
@@ -953,7 +953,7 @@ MadDecoder::UpdateTimerNextFrame()
elapsed_time = mad_timer_count(timer, MAD_UNITS_MILLISECONDS) / 1000.0;
}
-enum decoder_command
+DecoderCommand
MadDecoder::SendPCM(unsigned i, unsigned pcm_length)
{
unsigned max_samples;
@@ -963,7 +963,6 @@ MadDecoder::SendPCM(unsigned i, unsigned pcm_length)
MAD_NCHANNELS(&frame.header);
while (i < pcm_length) {
- enum decoder_command cmd;
unsigned int num_samples = pcm_length - i;
if (num_samples > max_samples)
num_samples = max_samples;
@@ -975,17 +974,17 @@ MadDecoder::SendPCM(unsigned i, unsigned pcm_length)
MAD_NCHANNELS(&frame.header));
num_samples *= MAD_NCHANNELS(&frame.header);
- cmd = decoder_data(decoder, input_stream, output_buffer,
- sizeof(output_buffer[0]) * num_samples,
- bit_rate / 1000);
- if (cmd != DECODE_COMMAND_NONE)
+ auto cmd = decoder_data(decoder, input_stream, output_buffer,
+ sizeof(output_buffer[0]) * num_samples,
+ bit_rate / 1000);
+ if (cmd != DecoderCommand::NONE)
return cmd;
}
- return DECODE_COMMAND_NONE;
+ return DecoderCommand::NONE;
}
-inline enum decoder_command
+inline DecoderCommand
MadDecoder::SyncAndSend()
{
mad_synth_frame(&synth, &frame);
@@ -1001,12 +1000,12 @@ MadDecoder::SyncAndSend()
if (drop_start_frames > 0) {
drop_start_frames--;
- return DECODE_COMMAND_NONE;
+ return DecoderCommand::NONE;
} else if ((drop_end_frames > 0) &&
(current_frame == (max_frames + 1 - drop_end_frames))) {
/* stop decoding, effectively dropping all remaining
frames */
- return DECODE_COMMAND_STOP;
+ return DecoderCommand::STOP;
}
unsigned i = 0;
@@ -1024,28 +1023,29 @@ MadDecoder::SyncAndSend()
pcm_length -= drop_end_samples;
}
- enum decoder_command cmd = SendPCM(i, pcm_length);
- if (cmd != DECODE_COMMAND_NONE)
+ auto cmd = SendPCM(i, pcm_length);
+ if (cmd != DecoderCommand::NONE)
return cmd;
if (drop_end_samples &&
(current_frame == max_frames - drop_end_frames))
/* stop decoding, effectively dropping
* all remaining samples */
- return DECODE_COMMAND_STOP;
+ return DecoderCommand::STOP;
- return DECODE_COMMAND_NONE;
+ return DecoderCommand::NONE;
}
inline bool
MadDecoder::Read()
{
enum mp3_action ret;
- enum decoder_command cmd;
UpdateTimerNextFrame();
switch (mute_frame) {
+ DecoderCommand cmd;
+
case MUTEFRAME_SKIP:
mute_frame = MUTEFRAME_NONE;
break;
@@ -1055,7 +1055,7 @@ MadDecoder::Read()
break;
case MUTEFRAME_NONE:
cmd = SyncAndSend();
- if (cmd == DECODE_COMMAND_SEEK) {
+ if (cmd == DecoderCommand::SEEK) {
unsigned long j;
assert(input_stream->IsSeekable());
@@ -1072,7 +1072,7 @@ MadDecoder::Read()
mute_frame = MUTEFRAME_SEEK;
decoder_command_finished(decoder);
}
- } else if (cmd != DECODE_COMMAND_NONE)
+ } else if (cmd != DecoderCommand::NONE)
return false;
}
@@ -1119,7 +1119,7 @@ mp3_decode(struct decoder *decoder, struct input_stream *input_stream)
if (!data.DecodeFirstFrame(&tag)) {
delete tag;
- if (decoder_get_command(decoder) == DECODE_COMMAND_NONE)
+ if (decoder_get_command(decoder) == DecoderCommand::NONE)
g_warning
("Input does not appear to be a mp3 bit stream.\n");
return;
diff --git a/src/decoder/MikmodDecoderPlugin.cxx b/src/decoder/MikmodDecoderPlugin.cxx
index f98b22a6d..78a26891a 100644
--- a/src/decoder/MikmodDecoderPlugin.cxx
+++ b/src/decoder/MikmodDecoderPlugin.cxx
@@ -148,7 +148,6 @@ mikmod_decoder_file_decode(struct decoder *decoder, const char *path_fs)
MODULE *handle;
int ret;
SBYTE buffer[MIKMOD_FRAME_SIZE];
- enum decoder_command cmd = DECODE_COMMAND_NONE;
path2 = g_strdup(path_fs);
handle = Player_Load(path2, 128, 0);
@@ -168,7 +167,9 @@ mikmod_decoder_file_decode(struct decoder *decoder, const char *path_fs)
decoder_initialized(decoder, audio_format, false, 0);
Player_Start(handle);
- while (cmd == DECODE_COMMAND_NONE && Player_Active()) {
+
+ DecoderCommand cmd = DecoderCommand::NONE;
+ while (cmd == DecoderCommand::NONE && Player_Active()) {
ret = VC_WriteBytes(buffer, sizeof(buffer));
cmd = decoder_data(decoder, nullptr, buffer, ret, 0);
}
diff --git a/src/decoder/ModplugDecoderPlugin.cxx b/src/decoder/ModplugDecoderPlugin.cxx
index d6840300c..9cbf44b15 100644
--- a/src/decoder/ModplugDecoderPlugin.cxx
+++ b/src/decoder/ModplugDecoderPlugin.cxx
@@ -99,7 +99,6 @@ mod_decode(struct decoder *decoder, struct input_stream *is)
GByteArray *bdatas;
int ret;
char audio_buffer[MODPLUG_FRAME_SIZE];
- enum decoder_command cmd = DECODE_COMMAND_NONE;
bdatas = mod_loadfile(decoder, is);
@@ -131,6 +130,7 @@ mod_decode(struct decoder *decoder, struct input_stream *is)
is->IsSeekable(),
ModPlug_GetLength(f) / 1000.0);
+ DecoderCommand cmd;
do {
ret = ModPlug_Read(f, audio_buffer, MODPLUG_FRAME_SIZE);
if (ret <= 0)
@@ -140,7 +140,7 @@ mod_decode(struct decoder *decoder, struct input_stream *is)
audio_buffer, ret,
0);
- if (cmd == DECODE_COMMAND_SEEK) {
+ if (cmd == DecoderCommand::SEEK) {
float where = decoder_seek_where(decoder);
ModPlug_Seek(f, (int)(where * 1000.0));
@@ -148,7 +148,7 @@ mod_decode(struct decoder *decoder, struct input_stream *is)
decoder_command_finished(decoder);
}
- } while (cmd != DECODE_COMMAND_STOP);
+ } while (cmd != DecoderCommand::STOP);
ModPlug_Unload(f);
}
diff --git a/src/decoder/MpcdecDecoderPlugin.cxx b/src/decoder/MpcdecDecoderPlugin.cxx
index d9c7a17d1..252fe92e6 100644
--- a/src/decoder/MpcdecDecoderPlugin.cxx
+++ b/src/decoder/MpcdecDecoderPlugin.cxx
@@ -147,7 +147,7 @@ mpcdec_decode(struct decoder *mpd_decoder, struct input_stream *is)
mpc_demux *demux = mpc_demux_init(&reader);
if (demux == nullptr) {
- if (decoder_get_command(mpd_decoder) != DECODE_COMMAND_STOP)
+ if (decoder_get_command(mpd_decoder) != DecoderCommand::STOP)
g_warning("Not a valid musepack stream");
return;
}
@@ -178,9 +178,9 @@ mpcdec_decode(struct decoder *mpd_decoder, struct input_stream *is)
is->IsSeekable(),
mpc_streaminfo_get_length(&info));
- enum decoder_command cmd = DECODE_COMMAND_NONE;
+ DecoderCommand cmd = DecoderCommand::NONE;
do {
- if (cmd == DECODE_COMMAND_SEEK) {
+ if (cmd == DecoderCommand::SEEK) {
mpc_int64_t where = decoder_seek_where(mpd_decoder) *
audio_format.sample_rate;
bool success;
@@ -218,7 +218,7 @@ mpcdec_decode(struct decoder *mpd_decoder, struct input_stream *is)
cmd = decoder_data(mpd_decoder, is,
chunk, ret * sizeof(chunk[0]),
bit_rate);
- } while (cmd != DECODE_COMMAND_STOP);
+ } while (cmd != DecoderCommand::STOP);
mpc_demux_exit(demux);
}
diff --git a/src/decoder/Mpg123DecoderPlugin.cxx b/src/decoder/Mpg123DecoderPlugin.cxx
index a44fc1241..3100a0f1c 100644
--- a/src/decoder/Mpg123DecoderPlugin.cxx
+++ b/src/decoder/Mpg123DecoderPlugin.cxx
@@ -106,7 +106,6 @@ mpd_mpg123_file_decode(struct decoder *decoder, const char *path_fs)
mpg123_handle *handle;
int error;
off_t num_samples;
- enum decoder_command cmd;
struct mpg123_frameinfo info;
/* open the file */
@@ -149,6 +148,7 @@ mpd_mpg123_file_decode(struct decoder *decoder, const char *path_fs)
/* the decoder main loop */
+ DecoderCommand cmd;
do {
unsigned char buffer[8192];
size_t nbytes;
@@ -175,7 +175,7 @@ mpd_mpg123_file_decode(struct decoder *decoder, const char *path_fs)
cmd = decoder_data(decoder, nullptr, buffer, nbytes, info.bitrate);
- if (cmd == DECODE_COMMAND_SEEK) {
+ if (cmd == DecoderCommand::SEEK) {
off_t c = decoder_seek_where(decoder)*audio_format.sample_rate;
c = mpg123_seek(handle, c, SEEK_SET);
if (c < 0)
@@ -185,9 +185,9 @@ mpd_mpg123_file_decode(struct decoder *decoder, const char *path_fs)
decoder_timestamp(decoder, c/(double)audio_format.sample_rate);
}
- cmd = DECODE_COMMAND_NONE;
+ cmd = DecoderCommand::NONE;
}
- } while (cmd == DECODE_COMMAND_NONE);
+ } while (cmd == DecoderCommand::NONE);
/* cleanup */
diff --git a/src/decoder/OpusDecoderPlugin.cxx b/src/decoder/OpusDecoderPlugin.cxx
index c757d66ef..ea1d6660c 100644
--- a/src/decoder/OpusDecoderPlugin.cxx
+++ b/src/decoder/OpusDecoderPlugin.cxx
@@ -96,11 +96,11 @@ public:
bool ReadFirstPage(OggSyncState &oy);
bool ReadNextPage(OggSyncState &oy);
- enum decoder_command HandlePackets();
- enum decoder_command HandlePacket(const ogg_packet &packet);
- enum decoder_command HandleBOS(const ogg_packet &packet);
- enum decoder_command HandleTags(const ogg_packet &packet);
- enum decoder_command HandleAudio(const ogg_packet &packet);
+ DecoderCommand HandlePackets();
+ DecoderCommand HandlePacket(const ogg_packet &packet);
+ DecoderCommand HandleBOS(const ogg_packet &packet);
+ DecoderCommand HandleTags(const ogg_packet &packet);
+ DecoderCommand HandleAudio(const ogg_packet &packet);
};
MPDOpusDecoder::~MPDOpusDecoder()
@@ -143,29 +143,29 @@ MPDOpusDecoder::ReadNextPage(OggSyncState &oy)
return true;
}
-inline enum decoder_command
+inline DecoderCommand
MPDOpusDecoder::HandlePackets()
{
ogg_packet packet;
while (ogg_stream_packetout(&os, &packet) == 1) {
- enum decoder_command cmd = HandlePacket(packet);
- if (cmd != DECODE_COMMAND_NONE)
+ auto cmd = HandlePacket(packet);
+ if (cmd != DecoderCommand::NONE)
return cmd;
}
- return DECODE_COMMAND_NONE;
+ return DecoderCommand::NONE;
}
-inline enum decoder_command
+inline DecoderCommand
MPDOpusDecoder::HandlePacket(const ogg_packet &packet)
{
if (packet.e_o_s)
- return DECODE_COMMAND_STOP;
+ return DecoderCommand::STOP;
if (packet.b_o_s)
return HandleBOS(packet);
else if (!found_opus)
- return DECODE_COMMAND_STOP;
+ return DecoderCommand::STOP;
if (IsOpusTags(packet))
return HandleTags(packet);
@@ -173,18 +173,18 @@ MPDOpusDecoder::HandlePacket(const ogg_packet &packet)
return HandleAudio(packet);
}
-inline enum decoder_command
+inline DecoderCommand
MPDOpusDecoder::HandleBOS(const ogg_packet &packet)
{
assert(packet.b_o_s);
if (found_opus || !IsOpusHead(packet))
- return DECODE_COMMAND_STOP;
+ return DecoderCommand::STOP;
unsigned channels;
if (!ScanOpusHeader(packet.packet, packet.bytes, channels) ||
!audio_valid_channel_count(channels))
- return DECODE_COMMAND_STOP;
+ return DecoderCommand::STOP;
assert(opus_decoder == nullptr);
assert(output_buffer == nullptr);
@@ -201,7 +201,7 @@ MPDOpusDecoder::HandleBOS(const ogg_packet &packet)
if (opus_decoder == nullptr) {
g_warning("libopus error: %s",
opus_strerror(opus_error));
- return DECODE_COMMAND_STOP;
+ return DecoderCommand::STOP;
}
const AudioFormat audio_format(opus_sample_rate,
@@ -220,12 +220,12 @@ MPDOpusDecoder::HandleBOS(const ogg_packet &packet)
return decoder_get_command(decoder);
}
-inline enum decoder_command
+inline DecoderCommand
MPDOpusDecoder::HandleTags(const ogg_packet &packet)
{
TagBuilder tag_builder;
- enum decoder_command cmd;
+ DecoderCommand cmd;
if (ScanOpusTags(packet.packet, packet.bytes,
&add_tag_handler, &tag_builder) &&
!tag_builder.IsEmpty()) {
@@ -238,7 +238,7 @@ MPDOpusDecoder::HandleTags(const ogg_packet &packet)
return cmd;
}
-inline enum decoder_command
+inline DecoderCommand
MPDOpusDecoder::HandleAudio(const ogg_packet &packet)
{
assert(opus_decoder != nullptr);
@@ -250,20 +250,19 @@ MPDOpusDecoder::HandleAudio(const ogg_packet &packet)
0);
if (nframes < 0) {
g_warning("%s", opus_strerror(nframes));
- return DECODE_COMMAND_STOP;
+ return DecoderCommand::STOP;
}
if (nframes > 0) {
const size_t nbytes = nframes * frame_size;
- enum decoder_command cmd =
- decoder_data(decoder, input_stream,
- output_buffer, nbytes,
- 0);
- if (cmd != DECODE_COMMAND_NONE)
+ auto cmd = decoder_data(decoder, input_stream,
+ output_buffer, nbytes,
+ 0);
+ if (cmd != DecoderCommand::NONE)
return cmd;
}
- return DECODE_COMMAND_NONE;
+ return DecoderCommand::NONE;
}
static void
@@ -284,8 +283,8 @@ mpd_opus_stream_decode(struct decoder *decoder,
return;
while (true) {
- enum decoder_command cmd = d.HandlePackets();
- if (cmd != DECODE_COMMAND_NONE)
+ auto cmd = d.HandlePackets();
+ if (cmd != DecoderCommand::NONE)
break;
if (!d.ReadNextPage(oy))
diff --git a/src/decoder/PcmDecoderPlugin.cxx b/src/decoder/PcmDecoderPlugin.cxx
index 4fccca75d..94867f01d 100644
--- a/src/decoder/PcmDecoderPlugin.cxx
+++ b/src/decoder/PcmDecoderPlugin.cxx
@@ -48,8 +48,6 @@ pcm_stream_decode(struct decoder *decoder, struct input_stream *is)
const bool reverse_endian = mime != nullptr &&
strcmp(mime, "audio/x-mpd-cdda-pcm-reverse") == 0;
- enum decoder_command cmd;
-
const double time_to_size = audio_format.GetTimeToSize();
float total_time = -1;
@@ -60,6 +58,7 @@ pcm_stream_decode(struct decoder *decoder, struct input_stream *is)
decoder_initialized(decoder, audio_format,
is->IsSeekable(), total_time);
+ DecoderCommand cmd;
do {
char buffer[4096];
@@ -79,7 +78,7 @@ pcm_stream_decode(struct decoder *decoder, struct input_stream *is)
? decoder_data(decoder, is,
buffer, nbytes, 0)
: decoder_get_command(decoder);
- if (cmd == DECODE_COMMAND_SEEK) {
+ if (cmd == DecoderCommand::SEEK) {
goffset offset = (goffset)(time_to_size *
decoder_seek_where(decoder));
@@ -91,9 +90,9 @@ pcm_stream_decode(struct decoder *decoder, struct input_stream *is)
decoder_seek_error(decoder);
}
- cmd = DECODE_COMMAND_NONE;
+ cmd = DecoderCommand::NONE;
}
- } while (cmd == DECODE_COMMAND_NONE);
+ } while (cmd == DecoderCommand::NONE);
}
static const char *const pcm_mime_types[] = {
diff --git a/src/decoder/SndfileDecoderPlugin.cxx b/src/decoder/SndfileDecoderPlugin.cxx
index 252e88df5..56853958c 100644
--- a/src/decoder/SndfileDecoderPlugin.cxx
+++ b/src/decoder/SndfileDecoderPlugin.cxx
@@ -119,7 +119,6 @@ sndfile_stream_decode(struct decoder *decoder, struct input_stream *is)
size_t frame_size;
sf_count_t read_frames, num_frames;
int buffer[4096];
- enum decoder_command cmd;
info.format = 0;
@@ -147,6 +146,7 @@ sndfile_stream_decode(struct decoder *decoder, struct input_stream *is)
frame_size = audio_format.GetFrameSize();
read_frames = sizeof(buffer) / frame_size;
+ DecoderCommand cmd;
do {
num_frames = sf_readf_int(sf, buffer, read_frames);
if (num_frames <= 0)
@@ -155,7 +155,7 @@ sndfile_stream_decode(struct decoder *decoder, struct input_stream *is)
cmd = decoder_data(decoder, is,
buffer, num_frames * frame_size,
0);
- if (cmd == DECODE_COMMAND_SEEK) {
+ if (cmd == DecoderCommand::SEEK) {
sf_count_t c =
time_to_frame(decoder_seek_where(decoder),
&audio_format);
@@ -164,9 +164,9 @@ sndfile_stream_decode(struct decoder *decoder, struct input_stream *is)
decoder_seek_error(decoder);
else
decoder_command_finished(decoder);
- cmd = DECODE_COMMAND_NONE;
+ cmd = DecoderCommand::NONE;
}
- } while (cmd == DECODE_COMMAND_NONE);
+ } while (cmd == DecoderCommand::NONE);
sf_close(sf);
}
diff --git a/src/decoder/VorbisDecoderPlugin.cxx b/src/decoder/VorbisDecoderPlugin.cxx
index 2b175912d..a4a938aa8 100644
--- a/src/decoder/VorbisDecoderPlugin.cxx
+++ b/src/decoder/VorbisDecoderPlugin.cxx
@@ -83,7 +83,7 @@ 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) != DECODE_COMMAND_STOP) &&
+ (!vis->decoder || decoder_get_command(vis->decoder) != DecoderCommand::STOP) &&
vis->input_stream->LockSeek(offset, whence, error)
? 0 : -1;
}
@@ -143,7 +143,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) == DECODE_COMMAND_NONE)
+ decoder_get_command(decoder) == DecoderCommand::NONE)
g_warning("Failed to open Ogg Vorbis stream: %s",
vorbis_strerror(ret));
return false;
@@ -221,8 +221,6 @@ vorbis_stream_decode(struct decoder *decoder,
decoder_initialized(decoder, audio_format, vis.seekable, total_time);
- enum decoder_command cmd = decoder_get_command(decoder);
-
#ifdef HAVE_TREMOR
char buffer[4096];
#else
@@ -235,8 +233,9 @@ vorbis_stream_decode(struct decoder *decoder,
int prev_section = -1;
unsigned kbit_rate = 0;
+ DecoderCommand cmd = decoder_get_command(decoder);
do {
- if (cmd == DECODE_COMMAND_SEEK) {
+ if (cmd == DecoderCommand::SEEK) {
double seek_where = decoder_seek_where(decoder);
if (0 == ov_time_seek_page(&vf, seek_where)) {
decoder_command_finished(decoder);
@@ -302,7 +301,7 @@ vorbis_stream_decode(struct decoder *decoder,
cmd = decoder_data(decoder, input_stream,
buffer, nbytes,
kbit_rate);
- } while (cmd != DECODE_COMMAND_STOP);
+ } while (cmd != DecoderCommand::STOP);
ov_clear(&vf);
}
diff --git a/src/decoder/WavpackDecoderPlugin.cxx b/src/decoder/WavpackDecoderPlugin.cxx
index d0122ad87..ecabafefe 100644
--- a/src/decoder/WavpackDecoderPlugin.cxx
+++ b/src/decoder/WavpackDecoderPlugin.cxx
@@ -177,9 +177,9 @@ wavpack_decode(struct decoder *decoder, WavpackContext *wpc, bool can_seek)
decoder_initialized(decoder, audio_format, can_seek, total_time);
- enum decoder_command cmd = decoder_get_command(decoder);
- while (cmd != DECODE_COMMAND_STOP) {
- if (cmd == DECODE_COMMAND_SEEK) {
+ DecoderCommand cmd = decoder_get_command(decoder);
+ while (cmd != DecoderCommand::STOP) {
+ if (cmd == DecoderCommand::SEEK) {
if (can_seek) {
unsigned where = decoder_seek_where(decoder) *
audio_format.sample_rate;
diff --git a/src/decoder/WildmidiDecoderPlugin.cxx b/src/decoder/WildmidiDecoderPlugin.cxx
index daa0e0cc9..3a057ca2c 100644
--- a/src/decoder/WildmidiDecoderPlugin.cxx
+++ b/src/decoder/WildmidiDecoderPlugin.cxx
@@ -72,7 +72,6 @@ wildmidi_file_decode(struct decoder *decoder, const char *path_fs)
};
midi *wm;
const struct _WM_Info *info;
- enum decoder_command cmd;
wm = WildMidi_Open(path_fs);
if (wm == nullptr)
@@ -87,6 +86,7 @@ wildmidi_file_decode(struct decoder *decoder, const char *path_fs)
decoder_initialized(decoder, audio_format, true,
info->approx_total_samples / WILDMIDI_SAMPLE_RATE);
+ DecoderCommand cmd;
do {
char buffer[4096];
int len;
@@ -101,7 +101,7 @@ wildmidi_file_decode(struct decoder *decoder, const char *path_fs)
cmd = decoder_data(decoder, nullptr, buffer, len, 0);
- if (cmd == DECODE_COMMAND_SEEK) {
+ if (cmd == DecoderCommand::SEEK) {
unsigned long seek_where = WILDMIDI_SAMPLE_RATE *
decoder_seek_where(decoder);
@@ -111,10 +111,10 @@ wildmidi_file_decode(struct decoder *decoder, const char *path_fs)
WildMidi_FastSeek(wm, &seek_where);
#endif
decoder_command_finished(decoder);
- cmd = DECODE_COMMAND_NONE;
+ cmd = DecoderCommand::NONE;
}
- } while (cmd == DECODE_COMMAND_NONE);
+ } while (cmd == DecoderCommand::NONE);
WildMidi_Close(wm);
}
diff --git a/src/decoder/sidplay_decoder_plugin.cxx b/src/decoder/sidplay_decoder_plugin.cxx
index 19969c00a..fed0476ec 100644
--- a/src/decoder/sidplay_decoder_plugin.cxx
+++ b/src/decoder/sidplay_decoder_plugin.cxx
@@ -290,7 +290,7 @@ sidplay_file_decode(struct decoder *decoder, const char *path_fs)
const unsigned timebase = player.timebase();
song_len *= timebase;
- enum decoder_command cmd;
+ DecoderCommand cmd;
do {
char buffer[4096];
size_t nbytes;
@@ -303,7 +303,7 @@ sidplay_file_decode(struct decoder *decoder, const char *path_fs)
cmd = decoder_data(decoder, NULL, buffer, nbytes, 0);
- if(cmd==DECODE_COMMAND_SEEK) {
+ if (cmd == DecoderCommand::SEEK) {
unsigned data_time = player.time();
unsigned target_time = (unsigned)
(decoder_seek_where(decoder) * timebase);
@@ -328,7 +328,7 @@ sidplay_file_decode(struct decoder *decoder, const char *path_fs)
if (song_len > 0 && player.time() >= (unsigned)song_len)
break;
- } while (cmd != DECODE_COMMAND_STOP);
+ } while (cmd != DecoderCommand::STOP);
}
static bool