From 84fc0e355d3b4b055a9cedb22d65ce8eadcbe343 Mon Sep 17 00:00:00 2001 From: Cacodemon345 Date: Wed, 7 Oct 2020 16:41:53 +0600 Subject: [PATCH] Improve ALSA MIDI backend 1. No longer excludes builtin MIDI passthrough ports. 2. "GZDoom" references changed to "ZMusic Program". 3. No longer bugs out when MIDI playback is paused. --- source/mididevices/music_alsa_mididevice.cpp | 18 ++++++------------ source/mididevices/music_alsa_state.cpp | 6 +----- 2 files changed, 7 insertions(+), 17 deletions(-) diff --git a/source/mididevices/music_alsa_mididevice.cpp b/source/mididevices/music_alsa_mididevice.cpp index 3ad9f13..181f395 100644 --- a/source/mididevices/music_alsa_mididevice.cpp +++ b/source/mididevices/music_alsa_mididevice.cpp @@ -50,7 +50,6 @@ namespace { enum class EventType { Null, - Delay, Action }; @@ -160,7 +159,7 @@ int AlsaMIDIDevice::Open() snd_seq_port_info_set_port(pinfo, IntendedPortId); snd_seq_port_info_set_port_specified(pinfo, 1); - snd_seq_port_info_set_name(pinfo, "GZDoom Music"); + snd_seq_port_info_set_name(pinfo, "ZMusic Program Music"); snd_seq_port_info_set_capability(pinfo, 0); snd_seq_port_info_set_type(pinfo, SND_SEQ_PORT_TYPE_MIDI_GENERIC | SND_SEQ_PORT_TYPE_APPLICATION); @@ -172,7 +171,7 @@ int AlsaMIDIDevice::Open() if (QueueId < 0) { - QueueId = snd_seq_alloc_named_queue(sequencer.handle, "GZDoom Queue"); + QueueId = snd_seq_alloc_named_queue(sequencer.handle, "ZMusic Program Queue"); } if (!Connected) { @@ -315,8 +314,10 @@ EventType AlsaMIDIDevice::PullEvent(EventState & state) { break; } } - // We didn't really recognize the event, treat it as a delay - return EventType::Delay; + // We didn't really recognize the event, treat it as a NOP + state.data.type = SND_SEQ_EVENT_NONE; + snd_seq_ev_set_fixed(&state.data); + return EventType::Action; } void AlsaMIDIDevice::SetExit(bool exit) { @@ -374,13 +375,6 @@ void AlsaMIDIDevice::PumpEvents() { continue; } - // chomp delays as they come... - if(type == EventType::Delay) { - buffer_ticks += event.ticks; - Position += event.size_of; - continue; - } - // Figure out if we should sleep (the event is too far in the future for us to care), and for how long int next_event_tick = buffer_ticks + event.ticks; int queue_tick = snd_seq_queue_status_get_tick_time(status); diff --git a/source/mididevices/music_alsa_state.cpp b/source/mididevices/music_alsa_state.cpp index 544fae8..c7bb8dd 100644 --- a/source/mididevices/music_alsa_state.cpp +++ b/source/mididevices/music_alsa_state.cpp @@ -67,7 +67,7 @@ bool AlsaSequencer::Open() { if(error) { return false; } - error = snd_seq_set_client_name(handle, "GZDoom"); + error = snd_seq_set_client_name(handle, "ZMusic Program"); if(error) { snd_seq_close(handle); handle = nullptr; @@ -131,11 +131,7 @@ int AlsaSequencer::EnumerateDevices() { while (snd_seq_query_next_client(handle, cinfo) >= 0) { snd_seq_port_info_set_client(pinfo, snd_seq_client_info_get_client(cinfo)); - // Ignore 'ALSA oddities' that we don't want to use int clientID = snd_seq_client_info_get_client(cinfo); - if(clientID < 16) { - continue; - } snd_seq_port_info_set_port(pinfo, -1); // enumerate ports