input_stream: return errors with GError
This commit is contained in:
@@ -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;
|
||||
|
@@ -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,
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -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);
|
||||
}
|
||||
|
@@ -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))
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -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;
|
||||
|
@@ -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);
|
||||
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -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;
|
||||
|
@@ -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) {
|
||||
|
Reference in New Issue
Block a user