diff options
author | Max Kellermann <max@duempel.org> | 2014-05-22 13:04:35 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2014-05-22 13:52:00 +0200 |
commit | 36c9e95969387516c07d37039e09c737be021669 (patch) | |
tree | b8f812ecf9166894a6d4c2540d86f0e0bac7fe69 /src/decoder | |
parent | a3142ee4e6e9d2fd04be9442d15ba5c7d6891c11 (diff) | |
download | mpd-36c9e95969387516c07d37039e09c737be021669.tar.gz mpd-36c9e95969387516c07d37039e09c737be021669.tar.xz mpd-36c9e95969387516c07d37039e09c737be021669.zip |
decoder/vorbis: add VorbisInputStream constructor
Diffstat (limited to 'src/decoder')
-rw-r--r-- | src/decoder/plugins/VorbisDecoderPlugin.cxx | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/src/decoder/plugins/VorbisDecoderPlugin.cxx b/src/decoder/plugins/VorbisDecoderPlugin.cxx index 4fdf6cff8..bcc5ae787 100644 --- a/src/decoder/plugins/VorbisDecoderPlugin.cxx +++ b/src/decoder/plugins/VorbisDecoderPlugin.cxx @@ -49,10 +49,14 @@ #include <errno.h> struct VorbisInputStream { - Decoder *decoder; + Decoder *const decoder; - InputStream *input_stream; + InputStream *const input_stream; bool seekable; + + VorbisInputStream(Decoder *_decoder, InputStream &_is) + :decoder(_decoder), input_stream(&_is), + seekable(input_stream->CheapSeeking()) {} }; static size_t ogg_read_cb(void *ptr, size_t size, size_t nmemb, void *data) @@ -123,17 +127,12 @@ vorbis_strerror(int code) } static bool -vorbis_is_open(VorbisInputStream *vis, OggVorbis_File *vf, - Decoder *decoder, InputStream &input_stream) +vorbis_is_open(VorbisInputStream *vis, OggVorbis_File *vf) { - vis->decoder = decoder; - vis->input_stream = &input_stream; - vis->seekable = input_stream.CheapSeeking(); - int ret = ov_open_callbacks(vis, vf, nullptr, 0, vorbis_is_callbacks); if (ret < 0) { - if (decoder == nullptr || - decoder_get_command(*decoder) == DecoderCommand::NONE) + if (vis->decoder == nullptr || + decoder_get_command(*vis->decoder) == DecoderCommand::NONE) FormatWarning(vorbis_domain, "Failed to open Ogg Vorbis stream: %s", vorbis_strerror(ret)); @@ -192,9 +191,9 @@ vorbis_stream_decode(Decoder &decoder, moved it */ input_stream.LockRewind(IgnoreError()); - VorbisInputStream vis; + VorbisInputStream vis(&decoder, input_stream); OggVorbis_File vf; - if (!vorbis_is_open(&vis, &vf, &decoder, input_stream)) + if (!vorbis_is_open(&vis, &vf)) return; const vorbis_info *vi = ov_info(&vf, -1); @@ -313,10 +312,10 @@ static bool vorbis_scan_stream(InputStream &is, const struct tag_handler *handler, void *handler_ctx) { - VorbisInputStream vis; + VorbisInputStream vis(nullptr, is); OggVorbis_File vf; - if (!vorbis_is_open(&vis, &vf, nullptr, is)) + if (!vorbis_is_open(&vis, &vf)) return false; tag_handler_invoke_duration(handler, handler_ctx, |