Browse Source

libjack: separate hints and SM type

tags/1.9.8
falkTX 7 years ago
parent
commit
ffbcc9b6f4
5 changed files with 224 additions and 141 deletions
  1. +153
    -99
      resources/ui/carla_add_jack.ui
  2. +6
    -4
      source/backend/plugin/CarlaPluginJack.cpp
  3. +23
    -16
      source/carla_database.py
  4. +33
    -16
      source/interposer/interposer-jack-x11.cpp
  5. +9
    -6
      source/libjack/libjack.cpp

+ 153
- 99
resources/ui/carla_add_jack.ui View File

@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>418</width>
<height>278</height>
<width>416</width>
<height>344</height>
</rect>
</property>
<property name="windowTitle">
@@ -24,7 +24,7 @@
<item>
<widget class="QGroupBox" name="group_command">
<property name="title">
<string>Command</string>
<string>Application</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0">
@@ -40,19 +40,6 @@
<item row="1" column="1" colspan="3">
<widget class="QLineEdit" name="le_command"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_6">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Session Manager:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="2" column="3">
<spacer name="horizontalSpacer_3">
<property name="orientation">
@@ -82,35 +69,6 @@
</property>
</widget>
</item>
<item row="3" column="1" colspan="3">
<widget class="QCheckBox" name="cb_manage_window">
<property name="text">
<string>Take control of main applicaton window</string>
</property>
</widget>
</item>
<item row="2" column="1" colspan="2">
<widget class="QComboBox" name="cb_session_mgr">
<property name="enabled">
<bool>false</bool>
</property>
<item>
<property name="text">
<string>None / Manual</string>
</property>
</item>
<item>
<property name="text">
<string>LADISH (SIGUSR1)</string>
</property>
</item>
<item>
<property name="text">
<string>Non Session Manager (OSC)</string>
</property>
</item>
</widget>
</item>
<item row="3" column="0">
<spacer name="horizontalSpacer_4">
<property name="orientation">
@@ -136,8 +94,49 @@
<string>Setup</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="1" column="0">
<spacer name="horizontalSpacer_6">
<item row="2" column="6">
<widget class="QLabel" name="label_7">
<property name="text">
<string>MIDI inputs:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="2" column="7">
<widget class="QSpinBox" name="sb_midi_ins">
<property name="maximum">
<number>1</number>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QSpinBox" name="sb_audio_outs">
<property name="maximum">
<number>64</number>
</property>
</widget>
</item>
<item row="3" column="6">
<widget class="QLabel" name="label_8">
<property name="text">
<string>MIDI outputs:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="3" column="7">
<widget class="QSpinBox" name="sb_midi_outs">
<property name="maximum">
<number>1</number>
</property>
</widget>
</item>
<item row="2" column="8">
<spacer name="horizontalSpacer_15">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
@@ -149,7 +148,7 @@
</property>
</spacer>
</item>
<item row="1" column="8">
<item row="3" column="8">
<spacer name="horizontalSpacer_16">
<property name="orientation">
<enum>Qt::Horizontal</enum>
@@ -162,7 +161,7 @@
</property>
</spacer>
</item>
<item row="1" column="3">
<item row="3" column="3">
<spacer name="horizontalSpacer_8">
<property name="orientation">
<enum>Qt::Horizontal</enum>
@@ -175,20 +174,23 @@
</property>
</spacer>
</item>
<item row="0" column="0">
<item row="2" column="0">
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>1</width>
<width>20</width>
<height>1</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="5">
<item row="2" column="5">
<spacer name="horizontalSpacer_13">
<property name="orientation">
<enum>Qt::Horizontal</enum>
@@ -201,7 +203,7 @@
</property>
</spacer>
</item>
<item row="0" column="1">
<item row="2" column="1">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Audio inputs:</string>
@@ -211,14 +213,27 @@
</property>
</widget>
</item>
<item row="0" column="2">
<item row="2" column="3">
<spacer name="horizontalSpacer_7">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>1</width>
<height>1</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="2">
<widget class="QSpinBox" name="sb_audio_ins">
<property name="maximum">
<number>64</number>
</property>
</widget>
</item>
<item row="0" column="4" rowspan="2">
<item row="2" column="4" rowspan="2">
<widget class="Line" name="line">
<property name="lineWidth">
<number>0</number>
@@ -231,24 +246,23 @@
</property>
</widget>
</item>
<item row="0" column="6">
<widget class="QLabel" name="label_7">
<property name="text">
<string>MIDI inputs:</string>
<item row="3" column="0">
<spacer name="horizontalSpacer_6">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
</widget>
</item>
<item row="0" column="7">
<widget class="QSpinBox" name="sb_midi_ins">
<property name="maximum">
<number>1</number>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>1</height>
</size>
</property>
</widget>
</spacer>
</item>
<item row="1" column="1">
<item row="3" column="1">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Audio outputs:</string>
@@ -258,68 +272,108 @@
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QSpinBox" name="sb_audio_outs">
<property name="maximum">
<number>64</number>
<item row="3" column="5">
<spacer name="horizontalSpacer_14">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
<property name="sizeHint" stdset="0">
<size>
<width>1</width>
<height>1</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="6">
<widget class="QLabel" name="label_8">
<item row="1" column="1" colspan="7">
<widget class="QCheckBox" name="cb_manage_window">
<property name="text">
<string>MIDI outputs:</string>
<string>Take control of main applicaton window</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</widget>
</item>
<item row="0" column="6" colspan="3">
<widget class="QComboBox" name="cb_session_mgr">
<property name="enabled">
<bool>false</bool>
</property>
<item>
<property name="text">
<string>None / Manual</string>
</property>
</item>
<item>
<property name="text">
<string>LADISH (SIGUSR1)</string>
</property>
</item>
<item>
<property name="text">
<string>Non Session Manager (OSC)</string>
</property>
</item>
</widget>
</item>
<item row="1" column="7">
<widget class="QSpinBox" name="sb_midi_outs">
<property name="maximum">
<number>1</number>
<item row="0" column="1" colspan="3">
<widget class="QLabel" name="label_6">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Session Manager:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="0" column="3">
<spacer name="horizontalSpacer_7">
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Workarounds</string>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>1</width>
<width>20</width>
<height>1</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="8">
<spacer name="horizontalSpacer_15">
<item row="0" column="2">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>1</width>
<width>135</width>
<height>1</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="5">
<spacer name="horizontalSpacer_14">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<item row="0" column="1">
<widget class="QCheckBox" name="cb_capture_first_window">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>1</width>
<height>1</height>
</size>
<property name="text">
<string>Capture only the first X11 Window</string>
</property>
</spacer>
</widget>
</item>
</layout>
</widget>


+ 6
- 4
source/backend/plugin/CarlaPluginJack.cpp View File

@@ -1208,7 +1208,7 @@ public:
// ---------------------------------------------------------------
// check setup

if (std::strlen(label) != 5)
if (std::strlen(label) != 6)
{
pData->engine->setLastError("invalid application setup received");
return false;
@@ -1217,7 +1217,9 @@ public:
for (int i=4; --i >= 0;) {
CARLA_SAFE_ASSERT_RETURN(label[i] >= '0' && label[i] <= '0'+64, false);
}
CARLA_SAFE_ASSERT_RETURN(label[4] >= '0' && label[4] < '0'+0x4f, false);
for (int i=6; --i >= 4;) {
CARLA_SAFE_ASSERT_RETURN(label[i] >= '0' && label[i] < '0'+0x4f, false);
}

fInfo.aIns = label[0] - '0';
fInfo.aOuts = label[1] - '0';
@@ -1226,7 +1228,7 @@ public:

fInfo.setupLabel = label;

const int setupHints = label[4] - '0';
const int setupHints = label[5] - '0';

// ---------------------------------------------------------------
// set info
@@ -1283,7 +1285,7 @@ public:
#endif
//fInfo.optionsAvailable = optionAv;

if (setupHints & 0x10)
if (setupHints & 0x1)
pData->hints |= PLUGIN_HAS_CUSTOM_UI;

// ---------------------------------------------------------------


+ 23
- 16
source/carla_database.py View File

@@ -1884,12 +1884,14 @@ class PluginDatabaseW(QDialog):
# Jack Application Dialog

class JackApplicationW(QDialog):
# TODO complete this
FLAG_SESSION_MGR_JACK = 0x01
FLAG_SESSION_MGR_LADISH = 0x02
FLAG_SESSION_MGR_LASH = 0x04
FLAG_SESSION_MGR_NSM = 0x08
FLAG_CONTROL_WINDOW = 0x10
SESSION_MGR_NONE = 0
SESSION_MGR_JACK = 1
SESSION_MGR_LADISH = 2
SESSION_MGR_LASH = 3
SESSION_MGR_NSM = 4

FLAG_CONTROL_WINDOW = 0x1
FLAG_CAPTURE_FIRST_WINDOW = 0x2

def __init__(self, parent, host):
QDialog.__init__(self, parent)
@@ -1917,25 +1919,30 @@ class JackApplicationW(QDialog):
def getCommandAndFlags(self):
name = self.ui.le_name.text()
command = self.ui.le_command.text()
smgr = self.SESSION_MGR_NONE
flags = 0x0
if not name:
name = command.split(" ",1)[0]

# TODO finalize flag definitions
sessionMgrIndex = self.ui.cb_session_mgr.currentIndex()
if sessionMgrIndex == 1:
flags |= self.FLAG_SESSION_MGR_LADISH
elif sessionMgrIndex == 2:
flags |= self.FLAG_SESSION_MGR_NSM
#uiSessionMgrIndex = self.ui.cb_session_mgr.currentIndex()
#if uiSessionMgrIndex == 1:
#smgr = self.SESSION_MGR_LADISH
#elif uiSessionMgrIndex == 2:
#smgr = self.SESSION_MGR_NSM

if self.ui.cb_manage_window.isChecked():
flags |= self.FLAG_CONTROL_WINDOW
if self.ui.cb_capture_first_window.isChecked():
flags |= self.FLAG_CAPTURE_FIRST_WINDOW

baseIntVal = ord('0')
labelSetup = "%s%s%s%s%s" % (chr(baseIntVal+self.ui.sb_audio_ins.value()),
chr(baseIntVal+self.ui.sb_audio_outs.value()),
chr(baseIntVal+self.ui.sb_midi_ins.value()),
chr(baseIntVal+self.ui.sb_midi_outs.value()),
chr(baseIntVal+flags))
labelSetup = "%s%s%s%s%s%s" % (chr(baseIntVal+self.ui.sb_audio_ins.value()),
chr(baseIntVal+self.ui.sb_audio_outs.value()),
chr(baseIntVal+self.ui.sb_midi_ins.value()),
chr(baseIntVal+self.ui.sb_midi_outs.value()),
chr(baseIntVal+smgr),
chr(baseIntVal+flags))
return (command, name, labelSetup)

def loadSettings(self):


+ 33
- 16
source/interposer/interposer-jack-x11.cpp View File

@@ -61,6 +61,8 @@ typedef int (*CarlaInterposedCallback)(int, void*);
static Display* gCurrentlyMappedDisplay = nullptr;
static Window gCurrentlyMappedWindow = 0;
static CarlaInterposedCallback gInterposedCallback = nullptr;
static int gInterposedSessionManager = 0;
static int gInterposedHints = 0;
static bool gCurrentWindowMapped = false;
static bool gCurrentWindowVisible = false;

@@ -161,7 +163,7 @@ int XMapWindow(Display* display, Window window)
// got a new window, we may need to forget last one
if (gCurrentlyMappedDisplay != nullptr && gCurrentlyMappedWindow != 0)
{
// igonre requests against the current mapped window
// ignore requests against the current mapped window
if (gCurrentlyMappedWindow == window)
return 0;

@@ -171,6 +173,7 @@ int XMapWindow(Display* display, Window window)
XSetTransientForHint(display, window, gCurrentlyMappedWindow);
break;
}

// ignore empty windows created after the main one
if (numItems == 0)
break;
@@ -220,31 +223,45 @@ int XUnmapWindow(Display* display, Window window)
// ---------------------------------------------------------------------------------------------------------------------

CARLA_EXPORT
int jack_carla_interposed_action(int action, void* ptr)
int jack_carla_interposed_action(int action, int value, void* ptr)
{
carla_debug("jack_carla_interposed_action(%i, %p)", action, ptr);
carla_debug("jack_carla_interposed_action(%i, %i, %p)", action, value, ptr);

switch (action)
{
case 1: // set callback
case 1:
// set hints and callback
gInterposedHints = value;
gInterposedCallback = (CarlaInterposedCallback)ptr;
return 1;

case 2: // show gui
gCurrentWindowVisible = true;
if (gCurrentlyMappedDisplay == nullptr || gCurrentlyMappedWindow == 0)
return 0;
case 2:
// session manager
gInterposedSessionManager = value;
return 1;

gCurrentWindowMapped = true;
return real_XMapWindow(gCurrentlyMappedDisplay, gCurrentlyMappedWindow);
case 3:
// show gui
if (value != 0)
{
gCurrentWindowVisible = true;
if (gCurrentlyMappedDisplay == nullptr || gCurrentlyMappedWindow == 0)
return 0;

case 3: // hide gui
gCurrentWindowVisible = false;
if (gCurrentlyMappedDisplay == nullptr || gCurrentlyMappedWindow == 0)
return 0;
gCurrentWindowMapped = true;
return real_XMapWindow(gCurrentlyMappedDisplay, gCurrentlyMappedWindow);
}
// hide gui
else
{
gCurrentWindowVisible = false;
if (gCurrentlyMappedDisplay == nullptr || gCurrentlyMappedWindow == 0)
return 0;

gCurrentWindowMapped = false;
return real_XUnmapWindow(gCurrentlyMappedDisplay, gCurrentlyMappedWindow);
gCurrentWindowMapped = false;
return real_XUnmapWindow(gCurrentlyMappedDisplay, gCurrentlyMappedWindow);
}
break;

case 4: // close everything
gCurrentWindowMapped = false;


+ 9
- 6
source/libjack/libjack.cpp View File

@@ -27,7 +27,7 @@ using juce::Time;
typedef int (*CarlaInterposedCallback)(int, void*);

CARLA_EXPORT
int jack_carla_interposed_action(int, void*)
int jack_carla_interposed_action(int, int, void*)
{
carla_stderr2("Non-export jack_carla_interposed_action called, this should not happen!!");
return 1337;
@@ -115,7 +115,7 @@ public:
CARLA_SAFE_ASSERT_RETURN(shmIds != nullptr && std::strlen(shmIds) == 6*4,);

const char* const libjackSetup(std::getenv("CARLA_LIBJACK_SETUP"));
CARLA_SAFE_ASSERT_RETURN(libjackSetup != nullptr && std::strlen(libjackSetup) == 5,);
CARLA_SAFE_ASSERT_RETURN(libjackSetup != nullptr && std::strlen(libjackSetup) == 6,);

// make sure we don't get loaded again
carla_unsetenv("CARLA_SHM_IDS");
@@ -126,7 +126,9 @@ public:
for (int i=4; --i >= 0;) {
CARLA_SAFE_ASSERT_RETURN(libjackSetup[i] >= '0' && libjackSetup[i] <= '0'+64,);
}
CARLA_SAFE_ASSERT_RETURN(libjackSetup[4] >= '0' && libjackSetup[4] < '0'+0x4f,);
for (int i=6; --i >= 4;) {
CARLA_SAFE_ASSERT_RETURN(libjackSetup[i] >= '0' && libjackSetup[i] < '0'+0x4f,);
}

std::memcpy(fBaseNameAudioPool, shmIds+6*0, 6);
std::memcpy(fBaseNameRtClientControl, shmIds+6*1, 6);
@@ -143,7 +145,8 @@ public:
fServer.numMidiIns = libjackSetup[2] - '0';
fServer.numMidiOuts = libjackSetup[3] - '0';

jack_carla_interposed_action(1, (void*)carla_interposed_callback);
jack_carla_interposed_action(1, libjackSetup[5] - '0', (void*)carla_interposed_callback);
jack_carla_interposed_action(2, libjackSetup[4] - '0', nullptr);

fNonRealtimeThread.startThread();
}
@@ -843,7 +846,7 @@ bool CarlaJackAppClient::handleNonRtData()
break;

case kPluginBridgeNonRtClientShowUI:
if (jack_carla_interposed_action(2, nullptr) == 1337)
if (jack_carla_interposed_action(3, 1, nullptr) == 1337)
{
// failed, LD_PRELOAD did not work?
const char* const message("Cannot show UI, LD_PRELOAD not working?");
@@ -862,7 +865,7 @@ bool CarlaJackAppClient::handleNonRtData()
break;

case kPluginBridgeNonRtClientHideUI:
jack_carla_interposed_action(3, nullptr);
jack_carla_interposed_action(3, 0, nullptr);
break;

case kPluginBridgeNonRtClientUiParameterChange:


Loading…
Cancel
Save