From 25deae6cc7cb49ee02278509c7904d3efc69a00b Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 15 Aug 2016 10:07:08 +0200 Subject: [PATCH] decoder/wildmidi: move code to wildmidi_output() --- src/decoder/plugins/WildmidiDecoderPlugin.cxx | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/decoder/plugins/WildmidiDecoderPlugin.cxx b/src/decoder/plugins/WildmidiDecoderPlugin.cxx index fc58f0977..1c18860b4 100644 --- a/src/decoder/plugins/WildmidiDecoderPlugin.cxx +++ b/src/decoder/plugins/WildmidiDecoderPlugin.cxx @@ -65,6 +65,17 @@ wildmidi_finish(void) WildMidi_Shutdown(); } +static DecoderCommand +wildmidi_output(Decoder &decoder, midi *wm) +{ + char buffer[4096]; + int length = WildMidi_GetOutput(wm, buffer, sizeof(buffer)); + if (length <= 0) + return DecoderCommand::STOP; + + return decoder_data(decoder, nullptr, buffer, length, 0); +} + static void wildmidi_file_decode(Decoder &decoder, Path path_fs) { @@ -94,18 +105,11 @@ wildmidi_file_decode(Decoder &decoder, Path path_fs) DecoderCommand cmd; do { - char buffer[4096]; - int len; - info = WildMidi_GetInfo(wm); if (info == nullptr) break; - len = WildMidi_GetOutput(wm, buffer, sizeof(buffer)); - if (len <= 0) - break; - - cmd = decoder_data(decoder, nullptr, buffer, len, 0); + cmd = wildmidi_output(decoder, wm); if (cmd == DecoderCommand::SEEK) { unsigned long seek_where =