Commit 25deae6c authored by Max Kellermann's avatar Max Kellermann

decoder/wildmidi: move code to wildmidi_output()

parent 62000670
...@@ -65,6 +65,17 @@ wildmidi_finish(void) ...@@ -65,6 +65,17 @@ wildmidi_finish(void)
WildMidi_Shutdown(); 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 static void
wildmidi_file_decode(Decoder &decoder, Path path_fs) wildmidi_file_decode(Decoder &decoder, Path path_fs)
{ {
...@@ -94,18 +105,11 @@ wildmidi_file_decode(Decoder &decoder, Path path_fs) ...@@ -94,18 +105,11 @@ wildmidi_file_decode(Decoder &decoder, Path path_fs)
DecoderCommand cmd; DecoderCommand cmd;
do { do {
char buffer[4096];
int len;
info = WildMidi_GetInfo(wm); info = WildMidi_GetInfo(wm);
if (info == nullptr) if (info == nullptr)
break; break;
len = WildMidi_GetOutput(wm, buffer, sizeof(buffer)); cmd = wildmidi_output(decoder, wm);
if (len <= 0)
break;
cmd = decoder_data(decoder, nullptr, buffer, len, 0);
if (cmd == DecoderCommand::SEEK) { if (cmd == DecoderCommand::SEEK) {
unsigned long seek_where = unsigned long seek_where =
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment