Proper MIDI thread termination

This commit is contained in:
Jack Andersen 2016-05-21 12:43:43 -10:00
parent 0a049645d8
commit 9078a16642
1 changed files with 3 additions and 0 deletions

View File

@ -5,6 +5,7 @@
#include "logvisor/logvisor.hpp" #include "logvisor/logvisor.hpp"
#include <alsa/asoundlib.h> #include <alsa/asoundlib.h>
#include <signal.h>
namespace boo namespace boo
{ {
@ -395,6 +396,7 @@ struct ALSAAudioVoiceEngine : BaseAudioVoiceEngine
~MIDIIn() ~MIDIIn()
{ {
m_midiRunning = false; m_midiRunning = false;
pthread_kill(m_midiThread.native_handle(), SIGTERM);
if (m_midiThread.joinable()) if (m_midiThread.joinable())
m_midiThread.join(); m_midiThread.join();
snd_rawmidi_close(m_midi); snd_rawmidi_close(m_midi);
@ -447,6 +449,7 @@ struct ALSAAudioVoiceEngine : BaseAudioVoiceEngine
~MIDIInOut() ~MIDIInOut()
{ {
m_midiRunning = false; m_midiRunning = false;
pthread_kill(m_midiThread.native_handle(), SIGTERM);
if (m_midiThread.joinable()) if (m_midiThread.joinable())
m_midiThread.join(); m_midiThread.join();
snd_rawmidi_close(m_midiIn); snd_rawmidi_close(m_midiIn);