decoder/vorbis: moved error strings to vorbis_strerror()

This commit is contained in:
Max Kellermann 2009-11-11 21:12:10 +01:00
parent dfc09a37c9
commit 4f38cc9cae
1 changed files with 26 additions and 24 deletions

View File

@ -100,6 +100,30 @@ static long ogg_tell_cb(void *vdata)
return (long)data->input_stream->offset;
}
static const char *
vorbis_strerror(int code)
{
switch (code) {
case OV_EREAD:
return "read error";
case OV_ENOTVORBIS:
return "not vorbis stream";
case OV_EVERSION:
return "vorbis version mismatch";
case OV_EBADHEADER:
return "invalid vorbis header";
case OV_EFAULT:
return "internal logic error";
default:
return "unknown error";
}
}
static const char *
vorbis_comment_value(const char *comment, const char *needle)
{
@ -274,33 +298,11 @@ vorbis_stream_decode(struct decoder *decoder,
callbacks.close_func = ogg_close_cb;
callbacks.tell_func = ogg_tell_cb;
if ((ret = ov_open_callbacks(&data, &vf, NULL, 0, callbacks)) < 0) {
const char *error;
if (decoder_get_command(decoder) != DECODE_COMMAND_NONE)
return;
switch (ret) {
case OV_EREAD:
error = "read error";
break;
case OV_ENOTVORBIS:
error = "not vorbis stream";
break;
case OV_EVERSION:
error = "vorbis version mismatch";
break;
case OV_EBADHEADER:
error = "invalid vorbis header";
break;
case OV_EFAULT:
error = "internal logic error";
break;
default:
error = "unknown error";
break;
}
g_warning("Error decoding Ogg Vorbis stream: %s", error);
g_warning("Error decoding Ogg Vorbis stream: %s",
vorbis_strerror(ret));
return;
}