Fix crash on close; Set getDefaultDeviceId; Cleanup

Signed-off-by: falkTX <falktx@falktx.com>
This commit is contained in:
falkTX 2021-10-20 12:02:47 +01:00
parent b5785743e8
commit 94f6412b4c
No known key found for this signature in database
GPG key ID: CDBAA37ABC74FBA0
2 changed files with 23 additions and 17 deletions

View file

@ -69,8 +69,18 @@ class CardinalUI : public UI,
WindowParametersRestore(context->window);
}
ScopedContext(CardinalUI* const ui, const int mods)
: context(ui->fContext),
cml(context->plugin->contextMutex)
{
rack::contextSet(context);
rack::window::WindowMods(context->window, mods);
WindowParametersRestore(context->window);
}
~ScopedContext()
{
if (context->window != nullptr)
WindowParametersSave(context->window);
rack::contextSet(nullptr);
}
@ -321,9 +331,7 @@ protected:
#endif
*/
rack::window::WindowMods(fContext->window, mods);
const ScopedContext sc(this);
const ScopedContext sc(this, mods);
return fContext->event->handleButton(fLastMousePos, button, action, mods);
}
@ -333,9 +341,8 @@ protected:
const rack::math::Vec mouseDelta = mousePos.minus(fLastMousePos);
fLastMousePos = mousePos;
rack::window::WindowMods(fContext->window, glfwMods(ev.mod));
const ScopedContext sc(this);
const ScopedContext sc(this, glfwMods(ev.mod));
return fContext->event->handleHover(mousePos, mouseDelta);
}
@ -348,9 +355,7 @@ protected:
scrollDelta = scrollDelta.mult(50.0);
#endif
rack::window::WindowMods(fContext->window, glfwMods(ev.mod));
const ScopedContext sc(this);
const ScopedContext sc(this, glfwMods(ev.mod));
return fContext->event->handleScroll(fLastMousePos, scrollDelta);
}
@ -359,9 +364,7 @@ protected:
if (ev.character <= ' ' || ev.character >= kKeyDelete)
return false;
rack::window::WindowMods(fContext->window, glfwMods(ev.mod));
const ScopedContext sc(this);
const ScopedContext sc(this, glfwMods(ev.mod));
return fContext->event->handleText(fLastMousePos, ev.character);
}
@ -438,7 +441,7 @@ protected:
rack::window::WindowMods(fContext->window, mods);
const ScopedContext sc(this);
const ScopedContext sc(this, mods);
return fContext->event->handleKey(fLastMousePos, key, ev.keycode, action, mods);
}
@ -447,9 +450,7 @@ protected:
if (focus)
return;
rack::window::WindowMods(fContext->window, 0);
const ScopedContext sc(this);
const ScopedContext sc(this, 0);
fContext->event->handleLeave();
}

View file

@ -114,7 +114,12 @@ struct CardinalAudioDriver : rack::audio::Driver {
std::vector<int> getDeviceIds() override
{
return std::vector<int>({ 1 });
return std::vector<int>({ 0 });
}
int getDefaultDeviceId() override
{
return 0;
}
std::string getDeviceName(int) override