Browse Source

Clean up temporary code, properly handle unsubscribing from rtmidi

device
tags/v0.6.1
Andrew Belt 6 years ago
parent
commit
c6b7b90839
3 changed files with 8 additions and 10 deletions
  1. +0
    -4
      src/main.cpp
  2. +7
    -5
      src/rtmidi.cpp
  3. +1
    -1
      src/window.cpp

+ 0
- 4
src/main.cpp View File

@@ -18,10 +18,6 @@ using namespace rack;
int main(int argc, char* argv[]) {
randomInit();
loggerInit();
debug("Hello world!");
info("Hello world!");
warn("Hello world!");
fatal("Hello world!");

info("Rack %s", gApplicationVersion.c_str());



+ 7
- 5
src/rtmidi.cpp View File

@@ -77,6 +77,8 @@ std::string RtMidiDriver::getInputDeviceName(int deviceId) {
}

MidiInputDevice *RtMidiDriver::subscribeInputDevice(int deviceId, MidiInput *midiInput) {
if (!(0 <= deviceId && deviceId < (int) rtMidiIn->getPortCount()))
return NULL;
RtMidiInputDevice *device = devices[deviceId];
if (!device) {
devices[deviceId] = device = new RtMidiInputDevice(driverId, deviceId);
@@ -87,14 +89,14 @@ MidiInputDevice *RtMidiDriver::subscribeInputDevice(int deviceId, MidiInput *mid
}

void RtMidiDriver::unsubscribeInputDevice(int deviceId, MidiInput *midiInput) {
RtMidiInputDevice *device = devices[deviceId];
assert(device);
auto it = devices.find(deviceId);
if (it == devices.end())
return;
RtMidiInputDevice *device = it->second;
device->unsubscribe(midiInput);

// Destroy device if nothing else is subscribed
// Destroy device if nothing is subscribed anymore
if (device->subscribed.empty()) {
auto it = devices.find(deviceId);
assert(it != devices.end());
devices.erase(it);
delete device;
}


+ 1
- 1
src/window.cpp View File

@@ -264,7 +264,7 @@ void charCallback(GLFWwindow *window, unsigned int codepoint) {

void keyCallback(GLFWwindow *window, int key, int scancode, int action, int mods) {
// Keyboard MIDI driver
if (1 || glfwGetInputMode(gWindow, GLFW_LOCK_KEY_MODS) & GLFW_MOD_CAPS_LOCK) {
if (glfwGetInputMode(gWindow, GLFW_LOCK_KEY_MODS) & GLFW_MOD_CAPS_LOCK) {
if (action == GLFW_PRESS) {
keyboardPress(key);
}


Loading…
Cancel
Save