Tweaks to ALSA midi handling

This commit is contained in:
Jack Andersen 2016-05-20 15:16:28 -10:00
parent df61d6678b
commit 6f04bea1f0
3 changed files with 8 additions and 18 deletions

View File

@ -174,12 +174,12 @@ add_definitions(${_BOO_SYS_DEFINES})
include_directories(include glslang soxr/src) include_directories(include glslang soxr/src)
add_library(boo add_library(boo
lib/inputdev/DeviceBase.cpp include/boo/inputdev/DeviceBase.hpp
lib/inputdev/CafeProPad.cpp include/boo/inputdev/CafeProPad.hpp lib/inputdev/CafeProPad.cpp include/boo/inputdev/CafeProPad.hpp
lib/inputdev/RevolutionPad.cpp include/boo/inputdev/RevolutionPad.hpp lib/inputdev/RevolutionPad.cpp include/boo/inputdev/RevolutionPad.hpp
lib/inputdev/DolphinSmashAdapter.cpp include/boo/inputdev/DolphinSmashAdapter.hpp lib/inputdev/DolphinSmashAdapter.cpp include/boo/inputdev/DolphinSmashAdapter.hpp
lib/inputdev/DualshockPad.cpp include/boo/inputdev/DualshockPad.hpp lib/inputdev/DualshockPad.cpp include/boo/inputdev/DualshockPad.hpp
lib/inputdev/GenericPad.cpp include/boo/inputdev/GenericPad.hpp lib/inputdev/GenericPad.cpp include/boo/inputdev/GenericPad.hpp
lib/inputdev/DeviceBase.cpp include/boo/inputdev/DeviceBase.hpp
lib/inputdev/DeviceSignature.cpp include/boo/inputdev/DeviceSignature.hpp lib/inputdev/DeviceSignature.cpp include/boo/inputdev/DeviceSignature.hpp
lib/inputdev/IHIDDevice.hpp lib/inputdev/IHIDDevice.hpp
lib/audiodev/AudioMatrix.hpp lib/audiodev/AudioMatrix.hpp

View File

@ -351,8 +351,8 @@ struct ALSAAudioVoiceEngine : BaseAudioVoiceEngine
snd_rawmidi_info_t *info; snd_rawmidi_info_t *info;
snd_rawmidi_info_alloca(&info); snd_rawmidi_info_alloca(&info);
snd_rawmidi_info_set_device(info, device); snd_rawmidi_info_set_device(info, device);
ret.push_back(std::make_pair(snd_rawmidi_info_get_id(info), sprintf(name + strlen(name), ",%d", device);
snd_rawmidi_info_get_name(info))); ret.push_back(std::make_pair(name, snd_rawmidi_info_get_name(info)));
} }
} while (device >= 0); } while (device >= 0);
@ -501,12 +501,8 @@ struct ALSAAudioVoiceEngine : BaseAudioVoiceEngine
std::unique_ptr<IMIDIIn> newRealMIDIIn(const char* name, ReceiveFunctor&& receiver) std::unique_ptr<IMIDIIn> newRealMIDIIn(const char* name, ReceiveFunctor&& receiver)
{ {
int status;
char path[128];
snprintf(path, 128, "hw:%s", name);
snd_rawmidi_t* midi; snd_rawmidi_t* midi;
status = snd_rawmidi_open(&midi, nullptr, path, 0); int status = snd_rawmidi_open(&midi, nullptr, name, 0);
if (status) if (status)
return {}; return {};
return std::make_unique<MIDIIn>(midi, true, std::move(receiver)); return std::make_unique<MIDIIn>(midi, true, std::move(receiver));
@ -514,12 +510,8 @@ struct ALSAAudioVoiceEngine : BaseAudioVoiceEngine
std::unique_ptr<IMIDIOut> newRealMIDIOut(const char* name) std::unique_ptr<IMIDIOut> newRealMIDIOut(const char* name)
{ {
int status;
char path[128];
snprintf(path, 128, "hw:%s", name);
snd_rawmidi_t* midi; snd_rawmidi_t* midi;
status = snd_rawmidi_open(nullptr, &midi, path, 0); int status = snd_rawmidi_open(nullptr, &midi, name, 0);
if (status) if (status)
return {}; return {};
return std::make_unique<MIDIOut>(midi, true); return std::make_unique<MIDIOut>(midi, true);
@ -527,13 +519,9 @@ struct ALSAAudioVoiceEngine : BaseAudioVoiceEngine
std::unique_ptr<IMIDIInOut> newRealMIDIInOut(const char* name, ReceiveFunctor&& receiver) std::unique_ptr<IMIDIInOut> newRealMIDIInOut(const char* name, ReceiveFunctor&& receiver)
{ {
int status;
char path[128];
snprintf(path, 128, "hw:%s", name);
snd_rawmidi_t* midiIn; snd_rawmidi_t* midiIn;
snd_rawmidi_t* midiOut; snd_rawmidi_t* midiOut;
status = snd_rawmidi_open(&midiIn, &midiOut, path, 0); int status = snd_rawmidi_open(&midiIn, &midiOut, name, 0);
if (status) if (status)
return {}; return {};
return std::make_unique<MIDIInOut>(midiIn, midiOut, true, std::move(receiver)); return std::make_unique<MIDIInOut>(midiIn, midiOut, true, std::move(receiver));

View File

@ -47,6 +47,8 @@ MIDIDecoder::receiveBytes(std::vector<uint8_t>::const_iterator begin,
uint8_t b; uint8_t b;
if (a & 0x80) if (a & 0x80)
m_status = a; m_status = a;
else
it--;
uint8_t chan = m_status & 0xf; uint8_t chan = m_status & 0xf;
switch (Status(m_status & 0xf0)) switch (Status(m_status & 0xf0))