decoder: return void from decode() methods
The stream_decode() and file_decode() methods returned a boolean, indicating whether they were able to decode the song. This is redundant, since we already know that: if decoder_initialized() has been called (and dc.state==DECODE), the plugin succeeded. Change both methods to return void.
This commit is contained in:
@@ -301,7 +301,7 @@ static int getAacTotalTime(const char *file)
|
|||||||
return file_time;
|
return file_time;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static void
|
||||||
aac_stream_decode(struct decoder *mpd_decoder, struct input_stream *inStream)
|
aac_stream_decode(struct decoder *mpd_decoder, struct input_stream *inStream)
|
||||||
{
|
{
|
||||||
float file_time;
|
float file_time;
|
||||||
@@ -354,7 +354,7 @@ aac_stream_decode(struct decoder *mpd_decoder, struct input_stream *inStream)
|
|||||||
faacDecClose(decoder);
|
faacDecClose(decoder);
|
||||||
if (b.buffer)
|
if (b.buffer)
|
||||||
free(b.buffer);
|
free(b.buffer);
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
audio_format.bits = 16;
|
audio_format.bits = 16;
|
||||||
@@ -419,15 +419,10 @@ aac_stream_decode(struct decoder *mpd_decoder, struct input_stream *inStream)
|
|||||||
faacDecClose(decoder);
|
faacDecClose(decoder);
|
||||||
if (b.buffer)
|
if (b.buffer)
|
||||||
free(b.buffer);
|
free(b.buffer);
|
||||||
|
|
||||||
if (!initialized)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static bool
|
static void
|
||||||
aac_decode(struct decoder *mpd_decoder, const char *path)
|
aac_decode(struct decoder *mpd_decoder, const char *path)
|
||||||
{
|
{
|
||||||
float file_time;
|
float file_time;
|
||||||
@@ -451,10 +446,10 @@ aac_decode(struct decoder *mpd_decoder, const char *path)
|
|||||||
bool initialized = false;
|
bool initialized = false;
|
||||||
|
|
||||||
if ((totalTime = getAacFloatTotalTime(path)) < 0)
|
if ((totalTime = getAacFloatTotalTime(path)) < 0)
|
||||||
return false;
|
return;
|
||||||
|
|
||||||
if (!input_stream_open(&inStream, path))
|
if (!input_stream_open(&inStream, path))
|
||||||
return false;
|
return;
|
||||||
|
|
||||||
initAacBuffer(&b, mpd_decoder, &inStream);
|
initAacBuffer(&b, mpd_decoder, &inStream);
|
||||||
aac_parse_header(&b, NULL);
|
aac_parse_header(&b, NULL);
|
||||||
@@ -484,7 +479,7 @@ aac_decode(struct decoder *mpd_decoder, const char *path)
|
|||||||
faacDecClose(decoder);
|
faacDecClose(decoder);
|
||||||
if (b.buffer)
|
if (b.buffer)
|
||||||
free(b.buffer);
|
free(b.buffer);
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
audio_format.bits = 16;
|
audio_format.bits = 16;
|
||||||
@@ -547,11 +542,6 @@ aac_decode(struct decoder *mpd_decoder, const char *path)
|
|||||||
faacDecClose(decoder);
|
faacDecClose(decoder);
|
||||||
if (b.buffer)
|
if (b.buffer)
|
||||||
free(b.buffer);
|
free(b.buffer);
|
||||||
|
|
||||||
if (!initialized)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct tag *aacTagDup(const char *file)
|
static struct tag *aacTagDup(const char *file)
|
||||||
|
@@ -41,7 +41,7 @@ static int getAudiofileTotalTime(const char *file)
|
|||||||
return total_time;
|
return total_time;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static void
|
||||||
audiofile_decode(struct decoder *decoder, const char *path)
|
audiofile_decode(struct decoder *decoder, const char *path)
|
||||||
{
|
{
|
||||||
int fs, frame_count;
|
int fs, frame_count;
|
||||||
@@ -56,13 +56,13 @@ audiofile_decode(struct decoder *decoder, const char *path)
|
|||||||
|
|
||||||
if (stat(path, &st) < 0) {
|
if (stat(path, &st) < 0) {
|
||||||
ERROR("failed to stat: %s\n", path);
|
ERROR("failed to stat: %s\n", path);
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
af_fp = afOpenFile(path, "r", NULL);
|
af_fp = afOpenFile(path, "r", NULL);
|
||||||
if (af_fp == AF_NULL_FILEHANDLE) {
|
if (af_fp == AF_NULL_FILEHANDLE) {
|
||||||
ERROR("failed to open: %s\n", path);
|
ERROR("failed to open: %s\n", path);
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
afSetVirtualSampleFormat(af_fp, AF_DEFAULT_TRACK,
|
afSetVirtualSampleFormat(af_fp, AF_DEFAULT_TRACK,
|
||||||
@@ -84,7 +84,7 @@ audiofile_decode(struct decoder *decoder, const char *path)
|
|||||||
ERROR("Only 8 and 16-bit files are supported. %s is %i-bit\n",
|
ERROR("Only 8 and 16-bit files are supported. %s is %i-bit\n",
|
||||||
path, audio_format.bits);
|
path, audio_format.bits);
|
||||||
afCloseFile(af_fp);
|
afCloseFile(af_fp);
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
fs = (int)afGetVirtualFrameSize(af_fp, AF_DEFAULT_TRACK, 1);
|
fs = (int)afGetVirtualFrameSize(af_fp, AF_DEFAULT_TRACK, 1);
|
||||||
@@ -112,7 +112,6 @@ audiofile_decode(struct decoder *decoder, const char *path)
|
|||||||
} while (decoder_get_command(decoder) != DECODE_COMMAND_STOP);
|
} while (decoder_get_command(decoder) != DECODE_COMMAND_STOP);
|
||||||
|
|
||||||
afCloseFile(af_fp);
|
afCloseFile(af_fp);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct tag *audiofileTagDup(const char *file)
|
static struct tag *audiofileTagDup(const char *file)
|
||||||
|
@@ -281,7 +281,7 @@ ffmpeg_decode_internal(struct ffmpeg_context *ctx)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static void
|
||||||
ffmpeg_decode(struct decoder *decoder, struct input_stream *input)
|
ffmpeg_decode(struct decoder *decoder, struct input_stream *input)
|
||||||
{
|
{
|
||||||
struct ffmpeg_context ctx;
|
struct ffmpeg_context ctx;
|
||||||
@@ -289,7 +289,7 @@ ffmpeg_decode(struct decoder *decoder, struct input_stream *input)
|
|||||||
ctx.input = input;
|
ctx.input = input;
|
||||||
ctx.decoder = decoder;
|
ctx.decoder = decoder;
|
||||||
|
|
||||||
return ffmpeg_helper(input, ffmpeg_decode_internal, &ctx);
|
ffmpeg_helper(input, ffmpeg_decode_internal, &ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool ffmpeg_tag_internal(struct ffmpeg_context *ctx)
|
static bool ffmpeg_tag_internal(struct ffmpeg_context *ctx)
|
||||||
|
@@ -301,7 +301,7 @@ static struct tag *flacTagDup(const char *file)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static void
|
||||||
flac_decode_internal(struct decoder * decoder, struct input_stream *inStream,
|
flac_decode_internal(struct decoder * decoder, struct input_stream *inStream,
|
||||||
bool is_ogg)
|
bool is_ogg)
|
||||||
{
|
{
|
||||||
@@ -310,7 +310,7 @@ flac_decode_internal(struct decoder * decoder, struct input_stream *inStream,
|
|||||||
const char *err = NULL;
|
const char *err = NULL;
|
||||||
|
|
||||||
if (!(flacDec = flac_new()))
|
if (!(flacDec = flac_new()))
|
||||||
return false;
|
return;
|
||||||
init_FlacData(&data, decoder, inStream);
|
init_FlacData(&data, decoder, inStream);
|
||||||
|
|
||||||
#if defined(FLAC_API_VERSION_CURRENT) && FLAC_API_VERSION_CURRENT > 7
|
#if defined(FLAC_API_VERSION_CURRENT) && FLAC_API_VERSION_CURRENT > 7
|
||||||
@@ -375,15 +375,15 @@ fail:
|
|||||||
|
|
||||||
if (err) {
|
if (err) {
|
||||||
ERROR("flac %s\n", err);
|
ERROR("flac %s\n", err);
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
return true;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static void
|
||||||
flac_decode(struct decoder * decoder, struct input_stream *inStream)
|
flac_decode(struct decoder * decoder, struct input_stream *inStream)
|
||||||
{
|
{
|
||||||
return flac_decode_internal(decoder, inStream, false);
|
flac_decode_internal(decoder, inStream, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef HAVE_OGGFLAC
|
#ifndef HAVE_OGGFLAC
|
||||||
@@ -431,17 +431,17 @@ out:
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static void
|
||||||
oggflac_decode(struct decoder *decoder, struct input_stream *inStream)
|
oggflac_decode(struct decoder *decoder, struct input_stream *inStream)
|
||||||
{
|
{
|
||||||
if (ogg_stream_type_detect(inStream) != FLAC)
|
if (ogg_stream_type_detect(inStream) != FLAC)
|
||||||
return false;
|
return;
|
||||||
|
|
||||||
/* rewind the stream, because ogg_stream_type_detect() has
|
/* rewind the stream, because ogg_stream_type_detect() has
|
||||||
moved it */
|
moved it */
|
||||||
input_stream_seek(inStream, 0, SEEK_SET);
|
input_stream_seek(inStream, 0, SEEK_SET);
|
||||||
|
|
||||||
return flac_decode_internal(decoder, inStream, true);
|
flac_decode_internal(decoder, inStream, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *const oggflac_suffixes[] = { "ogg", "oga", NULL };
|
static const char *const oggflac_suffixes[] = { "ogg", "oga", NULL };
|
||||||
|
@@ -160,7 +160,7 @@ static void mod_close(mod_Data * data)
|
|||||||
free(data);
|
free(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static void
|
||||||
mod_decode(struct decoder *decoder, const char *path)
|
mod_decode(struct decoder *decoder, const char *path)
|
||||||
{
|
{
|
||||||
mod_Data *data;
|
mod_Data *data;
|
||||||
@@ -173,7 +173,7 @@ mod_decode(struct decoder *decoder, const char *path)
|
|||||||
if (!(data = mod_open(path))) {
|
if (!(data = mod_open(path))) {
|
||||||
ERROR("failed to open mod: %s\n", path);
|
ERROR("failed to open mod: %s\n", path);
|
||||||
MikMod_Exit();
|
MikMod_Exit();
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
audio_format.bits = 16;
|
audio_format.bits = 16;
|
||||||
@@ -197,8 +197,6 @@ mod_decode(struct decoder *decoder, const char *path)
|
|||||||
mod_close(data);
|
mod_close(data);
|
||||||
|
|
||||||
MikMod_Exit();
|
MikMod_Exit();
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct tag *modTagDup(const char *file)
|
static struct tag *modTagDup(const char *file)
|
||||||
|
@@ -1050,7 +1050,7 @@ static void mp3_audio_format(struct mp3_data *data, struct audio_format *af)
|
|||||||
af->channels = MAD_NCHANNELS(&(data->frame).header);
|
af->channels = MAD_NCHANNELS(&(data->frame).header);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static void
|
||||||
mp3_decode(struct decoder *decoder, struct input_stream *input_stream)
|
mp3_decode(struct decoder *decoder, struct input_stream *input_stream)
|
||||||
{
|
{
|
||||||
struct mp3_data data;
|
struct mp3_data data;
|
||||||
@@ -1059,12 +1059,10 @@ mp3_decode(struct decoder *decoder, struct input_stream *input_stream)
|
|||||||
struct audio_format audio_format;
|
struct audio_format audio_format;
|
||||||
|
|
||||||
if (!mp3_open(input_stream, &data, decoder, &tag, &replay_gain_info)) {
|
if (!mp3_open(input_stream, &data, decoder, &tag, &replay_gain_info)) {
|
||||||
if (decoder_get_command(decoder) == DECODE_COMMAND_NONE) {
|
if (decoder_get_command(decoder) == DECODE_COMMAND_NONE)
|
||||||
ERROR
|
ERROR
|
||||||
("Input does not appear to be a mp3 bit stream.\n");
|
("Input does not appear to be a mp3 bit stream.\n");
|
||||||
return false;
|
return;
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mp3_audio_format(&data, &audio_format);
|
mp3_audio_format(&data, &audio_format);
|
||||||
@@ -1087,7 +1085,6 @@ mp3_decode(struct decoder *decoder, struct input_stream *input_stream)
|
|||||||
decoder_command_finished(decoder);
|
decoder_command_finished(decoder);
|
||||||
|
|
||||||
mp3_data_finish(&data);
|
mp3_data_finish(&data);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct tag *mp3_tag_dup(const char *file)
|
static struct tag *mp3_tag_dup(const char *file)
|
||||||
|
@@ -90,7 +90,7 @@ mp4_seek(void *user_data, uint64_t position)
|
|||||||
? 0 : -1;
|
? 0 : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static void
|
||||||
mp4_decode(struct decoder *mpd_decoder, struct input_stream *input_stream)
|
mp4_decode(struct decoder *mpd_decoder, struct input_stream *input_stream)
|
||||||
{
|
{
|
||||||
struct mp4_context ctx = {
|
struct mp4_context ctx = {
|
||||||
@@ -133,14 +133,14 @@ mp4_decode(struct decoder *mpd_decoder, struct input_stream *input_stream)
|
|||||||
mp4fh = mp4ff_open_read(&callback);
|
mp4fh = mp4ff_open_read(&callback);
|
||||||
if (!mp4fh) {
|
if (!mp4fh) {
|
||||||
g_warning("Input does not appear to be a mp4 stream.\n");
|
g_warning("Input does not appear to be a mp4 stream.\n");
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
track = mp4_get_aac_track(mp4fh);
|
track = mp4_get_aac_track(mp4fh);
|
||||||
if (track < 0) {
|
if (track < 0) {
|
||||||
g_warning("No AAC track found in mp4 stream.\n");
|
g_warning("No AAC track found in mp4 stream.\n");
|
||||||
mp4ff_close(mp4fh);
|
mp4ff_close(mp4fh);
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
decoder = faacDecOpen();
|
decoder = faacDecOpen();
|
||||||
@@ -164,7 +164,7 @@ mp4_decode(struct decoder *mpd_decoder, struct input_stream *input_stream)
|
|||||||
g_warning("Not an AAC stream.\n");
|
g_warning("Not an AAC stream.\n");
|
||||||
faacDecClose(decoder);
|
faacDecClose(decoder);
|
||||||
mp4ff_close(mp4fh);
|
mp4ff_close(mp4fh);
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
file_time = mp4ff_get_track_duration_use_offsets(mp4fh, track);
|
file_time = mp4ff_get_track_duration_use_offsets(mp4fh, track);
|
||||||
@@ -176,7 +176,7 @@ mp4_decode(struct decoder *mpd_decoder, struct input_stream *input_stream)
|
|||||||
g_warning("Error getting audio format of mp4 AAC track.\n");
|
g_warning("Error getting audio format of mp4 AAC track.\n");
|
||||||
faacDecClose(decoder);
|
faacDecClose(decoder);
|
||||||
mp4ff_close(mp4fh);
|
mp4ff_close(mp4fh);
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
total_time = ((float)file_time) / scale;
|
total_time = ((float)file_time) / scale;
|
||||||
|
|
||||||
@@ -185,7 +185,7 @@ mp4_decode(struct decoder *mpd_decoder, struct input_stream *input_stream)
|
|||||||
g_warning("Integer overflow.\n");
|
g_warning("Integer overflow.\n");
|
||||||
faacDecClose(decoder);
|
faacDecClose(decoder);
|
||||||
mp4ff_close(mp4fh);
|
mp4ff_close(mp4fh);
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
file_time = 0.0;
|
file_time = 0.0;
|
||||||
@@ -299,14 +299,6 @@ mp4_decode(struct decoder *mpd_decoder, struct input_stream *input_stream)
|
|||||||
free(seek_table);
|
free(seek_table);
|
||||||
faacDecClose(decoder);
|
faacDecClose(decoder);
|
||||||
mp4ff_close(mp4fh);
|
mp4ff_close(mp4fh);
|
||||||
|
|
||||||
if (!initialized)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (decoder_get_command(mpd_decoder) == DECODE_COMMAND_SEEK && seeking)
|
|
||||||
decoder_command_finished(mpd_decoder);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct tag *
|
static struct tag *
|
||||||
|
@@ -96,7 +96,7 @@ static inline int32_t convertSample(MPC_SAMPLE_FORMAT sample)
|
|||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static void
|
||||||
mpc_decode(struct decoder *mpd_decoder, struct input_stream *inStream)
|
mpc_decode(struct decoder *mpd_decoder, struct input_stream *inStream)
|
||||||
{
|
{
|
||||||
mpc_decoder decoder;
|
mpc_decoder decoder;
|
||||||
@@ -135,21 +135,17 @@ mpc_decode(struct decoder *mpd_decoder, struct input_stream *inStream)
|
|||||||
mpc_streaminfo_init(&info);
|
mpc_streaminfo_init(&info);
|
||||||
|
|
||||||
if ((ret = mpc_streaminfo_read(&info, &reader)) != ERROR_CODE_OK) {
|
if ((ret = mpc_streaminfo_read(&info, &reader)) != ERROR_CODE_OK) {
|
||||||
if (decoder_get_command(mpd_decoder) != DECODE_COMMAND_STOP) {
|
if (decoder_get_command(mpd_decoder) != DECODE_COMMAND_STOP)
|
||||||
ERROR("Not a valid musepack stream\n");
|
ERROR("Not a valid musepack stream\n");
|
||||||
return false;
|
return;
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mpc_decoder_setup(&decoder, &reader);
|
mpc_decoder_setup(&decoder, &reader);
|
||||||
|
|
||||||
if (!mpc_decoder_initialize(&decoder, &info)) {
|
if (!mpc_decoder_initialize(&decoder, &info)) {
|
||||||
if (decoder_get_command(mpd_decoder) != DECODE_COMMAND_STOP) {
|
if (decoder_get_command(mpd_decoder) != DECODE_COMMAND_STOP)
|
||||||
ERROR("Not a valid musepack stream\n");
|
ERROR("Not a valid musepack stream\n");
|
||||||
return false;
|
return;
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
audio_format.bits = 24;
|
audio_format.bits = 24;
|
||||||
@@ -232,8 +228,6 @@ mpc_decode(struct decoder *mpd_decoder, struct input_stream *inStream)
|
|||||||
}
|
}
|
||||||
|
|
||||||
replay_gain_info_free(replayGainInfo);
|
replay_gain_info_free(replayGainInfo);
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static float mpcGetTime(const char *file)
|
static float mpcGetTime(const char *file)
|
||||||
|
@@ -284,17 +284,15 @@ static bool oggflac_try_decode(struct input_stream *inStream)
|
|||||||
return ogg_stream_type_detect(inStream) == FLAC;
|
return ogg_stream_type_detect(inStream) == FLAC;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static void
|
||||||
oggflac_decode(struct decoder * mpd_decoder, struct input_stream *inStream)
|
oggflac_decode(struct decoder * mpd_decoder, struct input_stream *inStream)
|
||||||
{
|
{
|
||||||
OggFLAC__SeekableStreamDecoder *decoder = NULL;
|
OggFLAC__SeekableStreamDecoder *decoder = NULL;
|
||||||
FlacData data;
|
FlacData data;
|
||||||
bool ret = true;
|
|
||||||
|
|
||||||
init_FlacData(&data, mpd_decoder, inStream);
|
init_FlacData(&data, mpd_decoder, inStream);
|
||||||
|
|
||||||
if (!(decoder = full_decoder_init_and_read_metadata(&data, 0))) {
|
if (!(decoder = full_decoder_init_and_read_metadata(&data, 0))) {
|
||||||
ret = false;
|
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -329,8 +327,6 @@ oggflac_decode(struct decoder * mpd_decoder, struct input_stream *inStream)
|
|||||||
|
|
||||||
fail:
|
fail:
|
||||||
oggflac_cleanup(&data, decoder);
|
oggflac_cleanup(&data, decoder);
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *const oggflac_Suffixes[] = { "ogg", "oga", NULL };
|
static const char *const oggflac_Suffixes[] = { "ogg", "oga", NULL };
|
||||||
|
@@ -196,7 +196,7 @@ static void putOggCommentsIntoOutputBuffer(struct decoder *decoder,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* public */
|
/* public */
|
||||||
static bool
|
static void
|
||||||
oggvorbis_decode(struct decoder *decoder, struct input_stream *inStream)
|
oggvorbis_decode(struct decoder *decoder, struct input_stream *inStream)
|
||||||
{
|
{
|
||||||
OggVorbis_File vf;
|
OggVorbis_File vf;
|
||||||
@@ -217,7 +217,7 @@ oggvorbis_decode(struct decoder *decoder, struct input_stream *inStream)
|
|||||||
bool initialized = false;
|
bool initialized = false;
|
||||||
|
|
||||||
if (ogg_stream_type_detect(inStream) != VORBIS)
|
if (ogg_stream_type_detect(inStream) != VORBIS)
|
||||||
return false;
|
return;
|
||||||
|
|
||||||
/* rewind the stream, because ogg_stream_type_detect() has
|
/* rewind the stream, because ogg_stream_type_detect() has
|
||||||
moved it */
|
moved it */
|
||||||
@@ -232,7 +232,7 @@ oggvorbis_decode(struct decoder *decoder, struct input_stream *inStream)
|
|||||||
callbacks.tell_func = ogg_tell_cb;
|
callbacks.tell_func = ogg_tell_cb;
|
||||||
if ((ret = ov_open_callbacks(&data, &vf, NULL, 0, callbacks)) < 0) {
|
if ((ret = ov_open_callbacks(&data, &vf, NULL, 0, callbacks)) < 0) {
|
||||||
if (decoder_get_command(decoder) != DECODE_COMMAND_NONE)
|
if (decoder_get_command(decoder) != DECODE_COMMAND_NONE)
|
||||||
return true;
|
return;
|
||||||
|
|
||||||
switch (ret) {
|
switch (ret) {
|
||||||
case OV_EREAD:
|
case OV_EREAD:
|
||||||
@@ -256,7 +256,7 @@ oggvorbis_decode(struct decoder *decoder, struct input_stream *inStream)
|
|||||||
}
|
}
|
||||||
ERROR("Error decoding Ogg Vorbis stream: %s\n",
|
ERROR("Error decoding Ogg Vorbis stream: %s\n",
|
||||||
errorStr);
|
errorStr);
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
audio_format.bits = 16;
|
audio_format.bits = 16;
|
||||||
|
|
||||||
@@ -336,7 +336,6 @@ oggvorbis_decode(struct decoder *decoder, struct input_stream *inStream)
|
|||||||
replay_gain_info_free(replayGainInfo);
|
replay_gain_info_free(replayGainInfo);
|
||||||
|
|
||||||
ov_clear(&vf);
|
ov_clear(&vf);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct tag *oggvorbis_TagDup(const char *file)
|
static struct tag *oggvorbis_TagDup(const char *file)
|
||||||
|
@@ -475,7 +475,7 @@ wavpack_open_wvc(struct decoder *decoder, struct input_stream *is_wvc,
|
|||||||
/*
|
/*
|
||||||
* Decodes a stream.
|
* Decodes a stream.
|
||||||
*/
|
*/
|
||||||
static bool
|
static void
|
||||||
wavpack_streamdecode(struct decoder * decoder, struct input_stream *is)
|
wavpack_streamdecode(struct decoder * decoder, struct input_stream *is)
|
||||||
{
|
{
|
||||||
char error[ERRORLEN];
|
char error[ERRORLEN];
|
||||||
@@ -496,7 +496,7 @@ wavpack_streamdecode(struct decoder * decoder, struct input_stream *is)
|
|||||||
|
|
||||||
if (wpc == NULL) {
|
if (wpc == NULL) {
|
||||||
g_warning("failed to open WavPack stream: %s\n", error);
|
g_warning("failed to open WavPack stream: %s\n", error);
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
wavpack_decode(decoder, wpc, canseek, NULL);
|
wavpack_decode(decoder, wpc, canseek, NULL);
|
||||||
@@ -505,14 +505,12 @@ wavpack_streamdecode(struct decoder * decoder, struct input_stream *is)
|
|||||||
if (open_flags & OPEN_WVC) {
|
if (open_flags & OPEN_WVC) {
|
||||||
input_stream_close(&is_wvc);
|
input_stream_close(&is_wvc);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Decodes a file.
|
* Decodes a file.
|
||||||
*/
|
*/
|
||||||
static bool
|
static void
|
||||||
wavpack_filedecode(struct decoder *decoder, const char *fname)
|
wavpack_filedecode(struct decoder *decoder, const char *fname)
|
||||||
{
|
{
|
||||||
char error[ERRORLEN];
|
char error[ERRORLEN];
|
||||||
@@ -525,7 +523,7 @@ wavpack_filedecode(struct decoder *decoder, const char *fname)
|
|||||||
if (wpc == NULL) {
|
if (wpc == NULL) {
|
||||||
g_warning("failed to open WavPack file \"%s\": %s\n",
|
g_warning("failed to open WavPack file \"%s\": %s\n",
|
||||||
fname, error);
|
fname, error);
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
replay_gain_info = wavpack_replaygain(wpc);
|
replay_gain_info = wavpack_replaygain(wpc);
|
||||||
@@ -537,8 +535,6 @@ wavpack_filedecode(struct decoder *decoder, const char *fname)
|
|||||||
}
|
}
|
||||||
|
|
||||||
WavpackCloseFile(wpc);
|
WavpackCloseFile(wpc);
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static char const *const wavpack_suffixes[] = { "wv", NULL };
|
static char const *const wavpack_suffixes[] = { "wv", NULL };
|
||||||
|
@@ -68,7 +68,7 @@ struct decoder_plugin {
|
|||||||
* true if it was able to do so (even if an error occured
|
* true if it was able to do so (even if an error occured
|
||||||
* during playback)
|
* during playback)
|
||||||
*/
|
*/
|
||||||
bool (*stream_decode)(struct decoder *, struct input_stream *);
|
void (*stream_decode)(struct decoder *, struct input_stream *);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* use this if and only if your InputPlugin can only be passed
|
* use this if and only if your InputPlugin can only be passed
|
||||||
@@ -79,7 +79,7 @@ struct decoder_plugin {
|
|||||||
* true if it was able to do so (even if an error occured
|
* true if it was able to do so (even if an error occured
|
||||||
* during playback)
|
* during playback)
|
||||||
*/
|
*/
|
||||||
bool (*file_decode)(struct decoder *, const char *path);
|
void (*file_decode)(struct decoder *, const char *path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* file should be the full path! Returns NULL if a tag cannot
|
* file should be the full path! Returns NULL if a tag cannot
|
||||||
|
@@ -33,8 +33,6 @@ decoder_stream_decode(const struct decoder_plugin *plugin,
|
|||||||
struct decoder *decoder,
|
struct decoder *decoder,
|
||||||
struct input_stream *input_stream)
|
struct input_stream *input_stream)
|
||||||
{
|
{
|
||||||
bool ret;
|
|
||||||
|
|
||||||
assert(plugin != NULL);
|
assert(plugin != NULL);
|
||||||
assert(plugin->stream_decode != NULL);
|
assert(plugin->stream_decode != NULL);
|
||||||
assert(decoder != NULL);
|
assert(decoder != NULL);
|
||||||
@@ -46,27 +44,18 @@ decoder_stream_decode(const struct decoder_plugin *plugin,
|
|||||||
/* rewind the stream, so each plugin gets a fresh start */
|
/* rewind the stream, so each plugin gets a fresh start */
|
||||||
input_stream_seek(input_stream, 0, SEEK_SET);
|
input_stream_seek(input_stream, 0, SEEK_SET);
|
||||||
|
|
||||||
ret = plugin->stream_decode(decoder, input_stream);
|
plugin->stream_decode(decoder, input_stream);
|
||||||
|
|
||||||
if (ret) {
|
assert(dc.state == DECODE_STATE_START ||
|
||||||
/* if the method has succeeded, the plugin must have
|
dc.state == DECODE_STATE_DECODE);
|
||||||
called decoder_initialized() */
|
|
||||||
assert(dc.state == DECODE_STATE_DECODE);
|
|
||||||
} else {
|
|
||||||
/* no decoder_initialized() allowed when the plugin
|
|
||||||
hasn't recognized the file format */
|
|
||||||
assert(dc.state == DECODE_STATE_START);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
return dc.state != DECODE_STATE_START;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
decoder_file_decode(const struct decoder_plugin *plugin,
|
decoder_file_decode(const struct decoder_plugin *plugin,
|
||||||
struct decoder *decoder, const char *path)
|
struct decoder *decoder, const char *path)
|
||||||
{
|
{
|
||||||
bool ret;
|
|
||||||
|
|
||||||
assert(plugin != NULL);
|
assert(plugin != NULL);
|
||||||
assert(plugin->stream_decode != NULL);
|
assert(plugin->stream_decode != NULL);
|
||||||
assert(decoder != NULL);
|
assert(decoder != NULL);
|
||||||
@@ -75,19 +64,12 @@ decoder_file_decode(const struct decoder_plugin *plugin,
|
|||||||
assert(path[0] == '/');
|
assert(path[0] == '/');
|
||||||
assert(dc.state == DECODE_STATE_START);
|
assert(dc.state == DECODE_STATE_START);
|
||||||
|
|
||||||
ret = plugin->file_decode(decoder, path);
|
plugin->file_decode(decoder, path);
|
||||||
|
|
||||||
if (ret) {
|
assert(dc.state == DECODE_STATE_START ||
|
||||||
/* if the method has succeeded, the plugin must have
|
dc.state == DECODE_STATE_DECODE);
|
||||||
called decoder_initialized() */
|
|
||||||
assert(dc.state == DECODE_STATE_DECODE);
|
|
||||||
} else {
|
|
||||||
/* no decoder_initialized() allowed when the plugin
|
|
||||||
hasn't recognized the file format */
|
|
||||||
assert(dc.state == DECODE_STATE_START);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
return dc.state != DECODE_STATE_START;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void decoder_run(void)
|
static void decoder_run(void)
|
||||||
|
Reference in New Issue
Block a user