Rémi Bernon (@rbernon) commented about dlls/dmime/segment.c:
case mmioFOURCC('M','T','h','d'):
hr = midi_parser_new(stream, &midi_parser);
if (FAILED(hr)) break;
This->header.mtLength = 0;
while ((hr = midi_parser_next_track(midi_parser, &track, &length)) == S_OK)
{
hr = segment_append_track(This, track, 1, 0);
IDirectMusicTrack_Release(track);
if (FAILED(hr)) break;
if (length > This->header.mtLength)
This->header.mtLength = length;
}
midi_parser_destroy(midi_parser);
if (FAILED(hr = midi_parser_new(stream, &midi_parser))) break;
if (FAILED(hr = midi_parser_parse(midi_parser, &This->IDirectMusicSegment8_iface))) break;
Now that you introduce a function that parses a MIDI file at once, do you even need midi_parser_new / midi_parser_destroy to be externally called? Imo you could call them directly in midi.c and make them static.
I'm fine with the refactoring of the internal interface, but you could split it to a separate change, to make the band parsing commit simpler.