From 4d6d372a5b8f7903bbcbec943587c593ac08df3c Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 30 Jun 2010 19:24:41 +0000 Subject: decoder/vorbis: use single global ov_callbacks constant Initialize the ov_callbacks struct at compile time. --- src/decoder/vorbis_plugin.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/decoder/vorbis_plugin.c b/src/decoder/vorbis_plugin.c index 0ff898647..3da56bd5c 100644 --- a/src/decoder/vorbis_plugin.c +++ b/src/decoder/vorbis_plugin.c @@ -97,6 +97,13 @@ static long ogg_tell_cb(void *vdata) return (long)data->input_stream->offset; } +static const ov_callbacks vorbis_is_callbacks = { + .read_func = ogg_read_cb, + .seek_func = ogg_seek_cb, + .close_func = ogg_close_cb, + .tell_func = ogg_tell_cb, +}; + static const char * vorbis_comment_value(const char *comment, const char *needle) { @@ -241,7 +248,6 @@ vorbis_stream_decode(struct decoder *decoder, struct input_stream *input_stream) { OggVorbis_File vf; - ov_callbacks callbacks; OggCallbackData data; struct audio_format audio_format; int current_section; @@ -266,13 +272,9 @@ vorbis_stream_decode(struct decoder *decoder, data.input_stream = input_stream; data.seekable = input_stream->seekable && oggvorbis_seekable(decoder); - callbacks.read_func = ogg_read_cb; - callbacks.seek_func = ogg_seek_cb; - callbacks.close_func = ogg_close_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, + vorbis_is_callbacks)) < 0) { const char *error; - if (decoder_get_command(decoder) != DECODE_COMMAND_NONE) return; -- cgit v1.2.3