aboutsummaryrefslogtreecommitdiffstats
path: root/src/decoder
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-11-14 23:53:04 +0100
committerMax Kellermann <max@duempel.org>2009-12-15 23:12:11 +0100
commit228b03edf8513aa1cdaf4e4647279cc580245555 (patch)
tree7f5b03a9727fb8c371885469296eb7f49f6fa68b /src/decoder
parentd000d31355c824a076324b647a3f056aab9ddabe (diff)
downloadmpd-228b03edf8513aa1cdaf4e4647279cc580245555.tar.gz
mpd-228b03edf8513aa1cdaf4e4647279cc580245555.tar.xz
mpd-228b03edf8513aa1cdaf4e4647279cc580245555.zip
input_stream: return errors with GError
Diffstat (limited to 'src/decoder')
-rw-r--r--src/decoder/audiofile_plugin.c16
-rw-r--r--src/decoder/faad_plugin.c4
-rw-r--r--src/decoder/ffmpeg_plugin.c4
-rw-r--r--src/decoder/flac_plugin.c4
-rw-r--r--src/decoder/mad_plugin.c4
-rw-r--r--src/decoder/modplug_plugin.c2
-rw-r--r--src/decoder/mpcdec_plugin.c4
-rw-r--r--src/decoder/oggflac_plugin.c16
-rw-r--r--src/decoder/sndfile_decoder_plugin.c10
-rwxr-xr-xsrc/decoder/vorbis_plugin.c4
-rw-r--r--src/decoder/wavpack_plugin.c6
11 files changed, 48 insertions, 26 deletions
diff --git a/src/decoder/audiofile_plugin.c b/src/decoder/audiofile_plugin.c
index fcb431db7..a1fefcb0d 100644
--- a/src/decoder/audiofile_plugin.c
+++ b/src/decoder/audiofile_plugin.c
@@ -47,10 +47,20 @@ static int audiofile_get_duration(const char *file)
}
static ssize_t
-audiofile_file_read(AFvirtualfile *vfile, void *data, size_t nbytes)
+audiofile_file_read(AFvirtualfile *vfile, void *data, size_t length)
{
struct input_stream *is = (struct input_stream *) vfile->closure;
- return input_stream_read(is, data, nbytes);
+ GError *error = NULL;
+ size_t nbytes;
+
+ nbytes = input_stream_read(is, data, length, &error);
+ if (nbytes == 0 && error != NULL) {
+ g_warning("%s", error->message);
+ g_error_free(error);
+ return -1;
+ }
+
+ return nbytes;
}
static long
@@ -80,7 +90,7 @@ audiofile_file_seek(AFvirtualfile *vfile, long offset, int is_relative)
{
struct input_stream *is = (struct input_stream *) vfile->closure;
int whence = (is_relative ? SEEK_CUR : SEEK_SET);
- if (input_stream_seek(is, offset, whence)) {
+ if (input_stream_seek(is, offset, whence, NULL)) {
return is->offset;
} else {
return -1;
diff --git a/src/decoder/faad_plugin.c b/src/decoder/faad_plugin.c
index 2a05e33e8..c91f8e8f6 100644
--- a/src/decoder/faad_plugin.c
+++ b/src/decoder/faad_plugin.c
@@ -205,7 +205,7 @@ faad_song_duration(struct decoder_buffer *buffer, struct input_stream *is)
/* obtain the duration from the ADTS header */
float song_length = adts_song_duration(buffer);
- input_stream_seek(is, tagsize, SEEK_SET);
+ input_stream_seek(is, tagsize, SEEK_SET, NULL);
data = decoder_buffer_read(buffer, &length);
if (data != NULL)
@@ -330,7 +330,7 @@ faad_get_file_time_float(const char *file)
faacDecConfigurationPtr config;
struct input_stream is;
- if (!input_stream_open(&is, file))
+ if (!input_stream_open(&is, file, NULL))
return -1;
buffer = decoder_buffer_new(NULL, &is,
diff --git a/src/decoder/ffmpeg_plugin.c b/src/decoder/ffmpeg_plugin.c
index d9a5f7feb..213621b8c 100644
--- a/src/decoder/ffmpeg_plugin.c
+++ b/src/decoder/ffmpeg_plugin.c
@@ -101,7 +101,7 @@ static int64_t mpd_ffmpeg_seek(URLContext *h, int64_t pos, int whence)
if (whence == AVSEEK_SIZE)
return stream->input->size;
- ret = input_stream_seek(stream->input, pos, whence);
+ ret = input_stream_seek(stream->input, pos, whence, NULL);
if (!ret)
return -1;
@@ -434,7 +434,7 @@ static struct tag *ffmpeg_tag(const char *file)
struct ffmpeg_context ctx;
bool ret;
- if (!input_stream_open(&input, file)) {
+ if (!input_stream_open(&input, file, NULL)) {
g_warning("failed to open %s\n", file);
return NULL;
}
diff --git a/src/decoder/flac_plugin.c b/src/decoder/flac_plugin.c
index 427d2c4d9..50cf1f020 100644
--- a/src/decoder/flac_plugin.c
+++ b/src/decoder/flac_plugin.c
@@ -72,7 +72,7 @@ flac_seek_cb(G_GNUC_UNUSED const FLAC__StreamDecoder *fd,
if (!data->input_stream->seekable)
return FLAC__STREAM_DECODER_SEEK_STATUS_UNSUPPORTED;
- if (!input_stream_seek(data->input_stream, offset, SEEK_SET))
+ if (!input_stream_seek(data->input_stream, offset, SEEK_SET, NULL))
return FLAC__STREAM_DECODER_SEEK_STATUS_ERROR;
return FLAC__STREAM_DECODER_SEEK_STATUS_OK;
@@ -784,7 +784,7 @@ oggflac_decode(struct decoder *decoder, struct input_stream *input_stream)
/* rewind the stream, because ogg_stream_type_detect() has
moved it */
- input_stream_seek(input_stream, 0, SEEK_SET);
+ input_stream_seek(input_stream, 0, SEEK_SET, NULL);
flac_decode_internal(decoder, input_stream, true);
}
diff --git a/src/decoder/mad_plugin.c b/src/decoder/mad_plugin.c
index cba40aea0..50c9f62bc 100644
--- a/src/decoder/mad_plugin.c
+++ b/src/decoder/mad_plugin.c
@@ -165,7 +165,7 @@ mp3_data_init(struct mp3_data *data, struct decoder *decoder,
static bool mp3_seek(struct mp3_data *data, long offset)
{
- if (!input_stream_seek(data->input_stream, offset, SEEK_SET))
+ if (!input_stream_seek(data->input_stream, offset, SEEK_SET, NULL))
return false;
mad_stream_buffer(&data->stream, data->input_buffer, 0);
@@ -920,7 +920,7 @@ static int mp3_total_file_time(const char *file)
struct mp3_data data;
int ret;
- if (!input_stream_open(&input_stream, file))
+ if (!input_stream_open(&input_stream, file, NULL))
return -1;
mp3_data_init(&data, NULL, &input_stream);
if (!mp3_decode_first_frame(&data, NULL, NULL))
diff --git a/src/decoder/modplug_plugin.c b/src/decoder/modplug_plugin.c
index 02292992d..df4a99f7f 100644
--- a/src/decoder/modplug_plugin.c
+++ b/src/decoder/modplug_plugin.c
@@ -163,7 +163,7 @@ static struct tag *mod_tagdup(const char *file)
char *title;
struct input_stream is;
- if (!input_stream_open(&is, file)) {
+ if (!input_stream_open(&is, file, NULL)) {
g_warning("cant open file %s\n", file);
return NULL;
}
diff --git a/src/decoder/mpcdec_plugin.c b/src/decoder/mpcdec_plugin.c
index 2f1936e55..bf27ec314 100644
--- a/src/decoder/mpcdec_plugin.c
+++ b/src/decoder/mpcdec_plugin.c
@@ -60,7 +60,7 @@ mpc_seek_cb(cb_first_arg, mpc_int32_t offset)
{
struct mpc_decoder_data *data = (struct mpc_decoder_data *) cb_data;
- return input_stream_seek(data->is, offset, SEEK_SET);
+ return input_stream_seek(data->is, offset, SEEK_SET, NULL);
}
static mpc_int32_t
@@ -295,7 +295,7 @@ mpcdec_get_file_duration(const char *file)
mpc_streaminfo info;
struct mpc_decoder_data data;
- if (!input_stream_open(&is, file))
+ if (!input_stream_open(&is, file, NULL))
return -1;
data.is = &is;
diff --git a/src/decoder/oggflac_plugin.c b/src/decoder/oggflac_plugin.c
index 3b6987c6d..cff01453c 100644
--- a/src/decoder/oggflac_plugin.c
+++ b/src/decoder/oggflac_plugin.c
@@ -66,7 +66,7 @@ static OggFLAC__SeekableStreamDecoderSeekStatus of_seek_cb(G_GNUC_UNUSED const
{
struct flac_data *data = (struct flac_data *) fdata;
- if (!input_stream_seek(data->input_stream, offset, SEEK_SET))
+ if (!input_stream_seek(data->input_stream, offset, SEEK_SET, NULL))
return OggFLAC__SEEKABLE_STREAM_DECODER_SEEK_STATUS_ERROR;
return OggFLAC__SEEKABLE_STREAM_DECODER_SEEK_STATUS_OK;
@@ -245,13 +245,21 @@ fail:
static struct tag *
oggflac_tag_dup(const char *file)
{
+ GError *error = NULL;
struct input_stream input_stream;
OggFLAC__SeekableStreamDecoder *decoder;
struct flac_data data;
struct tag *tag;
- if (!input_stream_open(&input_stream, file))
+ if (!input_stream_open(&input_stream, file, &error)) {
+ if (error != NULL) {
+ g_warning("%s", error->message);
+ g_error_free(error);
+ }
+
return NULL;
+ }
+
if (ogg_stream_type_detect(&input_stream) != FLAC) {
input_stream_close(&input_stream);
return NULL;
@@ -259,7 +267,7 @@ oggflac_tag_dup(const char *file)
/* rewind the stream, because ogg_stream_type_detect() has
moved it */
- input_stream_seek(&input_stream, 0, SEEK_SET);
+ input_stream_seek(&input_stream, 0, SEEK_SET, NULL);
flac_data_init(&data, NULL, &input_stream);
@@ -295,7 +303,7 @@ oggflac_decode(struct decoder * mpd_decoder, struct input_stream *input_stream)
/* rewind the stream, because ogg_stream_type_detect() has
moved it */
- input_stream_seek(input_stream, 0, SEEK_SET);
+ input_stream_seek(input_stream, 0, SEEK_SET, NULL);
flac_data_init(&data, mpd_decoder, input_stream);
diff --git a/src/decoder/sndfile_decoder_plugin.c b/src/decoder/sndfile_decoder_plugin.c
index fee0f8292..a5fd4243b 100644
--- a/src/decoder/sndfile_decoder_plugin.c
+++ b/src/decoder/sndfile_decoder_plugin.c
@@ -40,7 +40,7 @@ sndfile_vio_seek(sf_count_t offset, int whence, void *user_data)
struct input_stream *is = user_data;
bool success;
- success = input_stream_seek(is, offset, whence);
+ success = input_stream_seek(is, offset, whence, NULL);
if (!success)
return -1;
@@ -51,11 +51,15 @@ static sf_count_t
sndfile_vio_read(void *ptr, sf_count_t count, void *user_data)
{
struct input_stream *is = user_data;
+ GError *error = NULL;
size_t nbytes;
- nbytes = input_stream_read(is, ptr, count);
- if (nbytes == 0 && is->error != 0)
+ nbytes = input_stream_read(is, ptr, count, &error);
+ if (nbytes == 0 && error != NULL) {
+ g_warning("%s", error->message);
+ g_error_free(error);
return -1;
+ }
return nbytes;
}
diff --git a/src/decoder/vorbis_plugin.c b/src/decoder/vorbis_plugin.c
index cb61e5999..91a9101f1 100755
--- a/src/decoder/vorbis_plugin.c
+++ b/src/decoder/vorbis_plugin.c
@@ -80,7 +80,7 @@ static int ogg_seek_cb(void *vdata, ogg_int64_t offset, int whence)
return data->seekable &&
decoder_get_command(data->decoder) != DECODE_COMMAND_STOP &&
- input_stream_seek(data->input_stream, offset, whence)
+ input_stream_seek(data->input_stream, offset, whence, NULL)
? 0 : -1;
}
@@ -286,7 +286,7 @@ vorbis_stream_decode(struct decoder *decoder,
/* rewind the stream, because ogg_stream_type_detect() has
moved it */
- input_stream_seek(input_stream, 0, SEEK_SET);
+ input_stream_seek(input_stream, 0, SEEK_SET, NULL);
data.decoder = decoder;
data.input_stream = input_stream;
diff --git a/src/decoder/wavpack_plugin.c b/src/decoder/wavpack_plugin.c
index 68a958788..da2c8df77 100644
--- a/src/decoder/wavpack_plugin.c
+++ b/src/decoder/wavpack_plugin.c
@@ -417,13 +417,13 @@ wavpack_input_get_pos(void *id)
static int
wavpack_input_set_pos_abs(void *id, uint32_t pos)
{
- return input_stream_seek(wpin(id)->is, pos, SEEK_SET) ? 0 : -1;
+ return input_stream_seek(wpin(id)->is, pos, SEEK_SET, NULL) ? 0 : -1;
}
static int
wavpack_input_set_pos_rel(void *id, int32_t delta, int mode)
{
- return input_stream_seek(wpin(id)->is, delta, mode) ? 0 : -1;
+ return input_stream_seek(wpin(id)->is, delta, mode, NULL) ? 0 : -1;
}
static int
@@ -494,7 +494,7 @@ wavpack_open_wvc(struct decoder *decoder, struct input_stream *is_wvc,
wvc_url = g_strconcat(utf8url, "c", NULL);
g_free(utf8url);
- ret = input_stream_open(is_wvc, wvc_url);
+ ret = input_stream_open(is_wvc, wvc_url, NULL);
g_free(wvc_url);
if (!ret) {