From a4cf1c8aec984e09c2814504c0383148cae9a8e9 Mon Sep 17 00:00:00 2001 From: Niels Martin Hansen Date: Thu, 4 Jul 2019 21:44:39 +0200 Subject: Fix: Don't keep mutex locked while parsing MIDI data --- src/music/win32_m.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/music') diff --git a/src/music/win32_m.cpp b/src/music/win32_m.cpp index abc0fcd72..1447fd88a 100644 --- a/src/music/win32_m.cpp +++ b/src/music/win32_m.cpp @@ -312,10 +312,14 @@ void CALLBACK TimerCallback(UINT uTimerID, UINT, DWORD_PTR dwUser, DWORD_PTR, DW void MusicDriver_Win32::PlaySong(const MusicSongInfo &song) { DEBUG(driver, 2, "Win32-MIDI: PlaySong: entry"); - std::lock_guard mutex_lock(_midi.lock); - if (!_midi.next_file.LoadSong(song)) return; + MidiFile new_song; + if (!new_song.LoadSong(song)) return; + DEBUG(driver, 2, "Win32-MIDI: PlaySong: Loaded song"); + + std::lock_guard mutex_lock(_midi.lock); + _midi.next_file.MoveFrom(new_song); _midi.next_segment.start = song.override_start; _midi.next_segment.end = song.override_end; _midi.next_segment.loop = song.loop; -- cgit v1.2.3-70-g09d2