Rémi Bernon (@rbernon) commented about dlls/dmime/segment.c:
+ entry = calloc(1, sizeof(*entry)); + if (!entry) + { + IDirectMusicTrack_Release(track); + return E_OUTOFMEMORY; + } + entry->pTrack = track; + list_add_tail(&This->tracks, &entry->entry); + length = get_midiseqtrack_length((IDirectMusicTrack8 *)track); + if (length > This->header.mtLength) + This->header.mtLength = length; + return S_OK; +} + +static HRESULT parse_midi(struct segment *This, IStream *stream) +{ I'd suggest to move this helper to the miditrack.c file so that everything MIDI-file related lives there.
This could be a `create_midi_tracks_from_stream` helper that the segment would call, getting an array of track pointers, or `enum_midi_tracks_in_stream` with a callback and user pointer that would call back into a segment helper to append the tracks, whatever is simpler. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/4982#note_59642