Browse Source

Merge 771125cf3f into c167f35fbb

pull/223/merge
Riccardo Cagnasso GitHub 4 years ago
parent
commit
f9233ee236
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 360 additions and 27 deletions
  1. +170
    -16
      resources/ui/settings_jack.ui
  2. +7
    -2
      src/cadence.py
  3. +2
    -1
      src/catia.py
  4. +136
    -8
      src/jacksettings.py
  5. +45
    -0
      src/shared_cadence.py

+ 170
- 16
resources/ui/settings_jack.ui View File

@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>680</width>
<height>449</height>
<width>749</width>
<height>569</height>
</rect>
</property>
<property name="windowTitle">
@@ -17,7 +17,7 @@
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
<number>2</number>
</property>
<widget class="QWidget" name="engine">
<attribute name="title">
@@ -1335,6 +1335,43 @@ Also known as buffer size</string>
</item>
</layout>
</widget>
<widget class="QWidget" name="toolbox_driver_miscPageNet">
<layout class="QGridLayout" name="gridLayout_15">
<item row="2" column="0">
<widget class="QLabel" name="obj_driver_hostname_label">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Client name</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="3" column="1">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>200</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="obj_driver_client_name">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
@@ -1348,19 +1385,136 @@ Also known as buffer size</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QLabel" name="label">
<property name="font">
<font>
<pointsize>16</pointsize>
</font>
</property>
<property name="text">
<string>Not Implemented Yet</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QGroupBox" name="">
<property name="title">
<string>Settings</string>
</property>
<layout class="QGridLayout" name="gridLayout_16">
<item row="1" column="1">
<widget class="QSpinBox" name="obj_net_multicast_port">
<property name="maximum">
<number>65536</number>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Auto Connect Ports</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Multicast Ip</string>
</property>
</widget>
</item>
<item row="4" column="1">
<spacer name="verticalSpacer_6">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="obj_net_multicast_ip"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Udp Net Port</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Auto Save</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QCheckBox" name="obj_net_auto_connect">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QCheckBox" name="obj_net_auto_save">
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="">
<property name="title">
<string>Controls</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QCheckBox" name="obj_net_manager_at_boot">
<property name="text">
<string>Start at Boot</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="obj_net_reset">
<property name="text">
<string>Reset Network Settings</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QPushButton" name="obj_net_manager_start">
<property name="text">
<string>Start</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="obj_net_manager_stop">
<property name="text">
<string>Stop</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer_7">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
</layout>
</item>
</layout>
</widget>


+ 7
- 2
src/cadence.py View File

@@ -1349,6 +1349,10 @@ class CadenceMainW(QMainWindow, ui_cadence.Ui_CadenceMainW):
self.checkAlsaAudio()
self.checkPulseAudio()

if GlobalSettings.value("JACKNETMANAGER/AutoStart"):
print("loadinternal")
gDBus.jack.LoadInternal("netmanager")

def jackStopped(self):
if self.m_timer500:
self.killTimer(self.m_timer500)
@@ -1649,7 +1653,8 @@ class CadenceMainW(QMainWindow, ui_cadence.Ui_CadenceMainW):
try:
gDBus.jack.StartServer()
except:
QMessageBox.warning(self, self.tr("Warning"), self.tr("Failed to start JACK, please check the logs for more information."))
pass
#QMessageBox.warning(self, self.tr("Warning"), self.tr("Failed to start JACK, please check the logs for more information."))

@pyqtSlot()
def slot_JackServerStop(self):
@@ -2364,7 +2369,7 @@ if __name__ == '__main__':

if haveDBus:
gDBus.loop = DBusQtMainLoop(set_as_default=True)
gDBus.bus = dbus.SessionBus(mainloop=gDBus.loop)
gDBus.bus = dbus.SessionBus(mainloop=gDBus.loop)

initSystemChecks()



+ 2
- 1
src/catia.py View File

@@ -1123,7 +1123,8 @@ class CatiaMainW(AbstractCanvasJackClass):
try:
ret = bool(gDBus.jack.StartServer())
except:
QMessageBox.warning(self, self.tr("Warning"), self.tr("Failed to start JACK, please check the logs for more information."))
pass
#QMessageBox.warning(self, self.tr("Warning"), self.tr("Failed to start JACK, please check the logs for more information."))
#self.jackStopped()
return ret



+ 136
- 8
src/jacksettings.py View File

@@ -30,6 +30,7 @@ else:
from PyQt4.QtGui import QFontMetrics
from PyQt4.QtGui import QDialog, QDialogButtonBox, QMessageBox

from shared_cadence import *
# ------------------------------------------------------------------------------------------------------------
# Imports (Custom Stuff)

@@ -75,13 +76,17 @@ else:

def initBus(bus):
global gJackctl
global jack_control_iface

if not bus:
gJackctl = None
return 1

try:
gJackctl = dbus.Interface(bus.get_object("org.jackaudio.service", "/org/jackaudio/Controller"), "org.jackaudio.Configure")
controller = bus.get_object("org.jackaudio.service", "/org/jackaudio/Controller")
gJackctl = dbus.Interface(controller, "org.jackaudio.Configure")
jack_control_iface = dbus.Interface(
controller, "org.jackaudio.JackControl")
return 0
except:
gJackctl = None
@@ -234,6 +239,10 @@ class JackSettingsW(QDialog):
self.ui.obj_driver_capture.currentIndexChanged[int].connect(self.slot_checkALSASelection)
self.ui.obj_driver_playback.currentIndexChanged[int].connect(self.slot_checkALSASelection)

self.ui.obj_net_manager_start.clicked.connect(self.net_manager_start)
self.ui.obj_net_manager_stop.clicked.connect(self.net_manager_stop)
self.ui.obj_net_reset.clicked.connect(self.net_manager_reset)

# -------------------------------------------------------------
# Load initial settings

@@ -243,6 +252,7 @@ class JackSettingsW(QDialog):
self.checkEngine()
self.loadServerSettings()
self.loadDriverSettings(True) # reset because we'll change it below
self.loadNetSettings()

# -------------------------------------------------------------
# Load selected JACK driver
@@ -559,11 +569,20 @@ class JackSettingsW(QDialog):

if self.ui.obj_driver_inchannels.isEnabled():
value = dbus.UInt32(self.ui.obj_driver_inchannels.value())
setDriverParameter("inchannels", value, True)
if self.fDriverName == 'net':
value = dbus.Int32(self.ui.obj_driver_inchannels.value())
setDriverParameter("input-ports", value, True)
else:
value = dbus.UInt32(self.ui.obj_driver_inchannels.value())
setDriverParameter("inchannels", value, True)

if self.ui.obj_driver_outchannels.isEnabled():
value = dbus.UInt32(self.ui.obj_driver_outchannels.value())
setDriverParameter("outchannels", value, True)
if self.fDriverName == 'net':
value = dbus.Int32(self.ui.obj_driver_outchannels.value())
setDriverParameter("output-ports", value, True)
else:
value = dbus.UInt32(self.ui.obj_driver_outchannels.value())
setDriverParameter("outchannels", value, True)

if self.ui.obj_driver_shorts.isEnabled():
value = dbus.Boolean(self.ui.obj_driver_shorts.isChecked())
@@ -610,6 +629,10 @@ class JackSettingsW(QDialog):
value = dbus.Int32(self.ui.obj_driver_channels.value())
setDriverParameter("channels", value, True)

if self.ui.obj_driver_client_name.isEnabled():
value = dbus.String(self.ui.obj_driver_client_name.text())
setDriverParameter("client-name", value, True)

def loadDriverSettings(self, reset=False, forceReset=False):
global gJackctl

@@ -700,9 +723,92 @@ class JackSettingsW(QDialog):
self.ui.obj_driver_snoop.setChecked(bool(value))
elif attribute == "channels":
self.ui.obj_driver_channels.setValue(int(value))
elif attribute == 'client-name':
self.ui.obj_driver_client_name.setText(value)
elif attribute == 'input-ports':
self.ui.obj_driver_inchannels.setValue(int(value))
elif attribute == 'output-ports':
self.ui.obj_driver_outchannels.setValue(int(value))
else:
print("JackSettingsW::loadDriverSettings() - Unimplemented driver attribute '%s', value: '%s'" % (attribute, str(value)))

def saveNetSettings(self):
path = ['internals', 'netmanager']

isset, default, value = map(
dbus_type_to_python_type,
gJackctl.GetParameterValue(path + ['multicast-ip']))

curvalue = self.ui.obj_net_multicast_ip.text()

if curvalue != value:
gJackctl.SetParameterValue(
path + ['multicast-ip'],
python_type_to_jackdbus_type(curvalue, 's'))

isset, default, value = map(
dbus_type_to_python_type,
gJackctl.GetParameterValue(path + ['udp-net-port']))

curvalue = self.ui.obj_net_multicast_port.value()

if curvalue != value:
gJackctl.SetParameterValue(
path + ['udp-net-port'],
python_type_to_jackdbus_type(curvalue, 'u'))

isset, default, value = map(
dbus_type_to_python_type,
gJackctl.GetParameterValue(path + ['auto-connect']))

curvalue = self.ui.obj_net_auto_connect.isChecked()

if curvalue != value:
gJackctl.SetParameterValue(path + ['auto-connect'], curvalue)

isset, default, value = map(
dbus_type_to_python_type,
gJackctl.GetParameterValue(path + ['auto-save']))

curvalue = self.ui.obj_net_auto_save.isChecked()

if curvalue != value:
gJackctl.SetParameterValue(path + ['auto-save'], curvalue)

GlobalSettings = QSettings("Cadence", "GlobalSettings")
GlobalSettings.setValue('JACKNETMANAGER/AutoStart',
self.ui.obj_net_manager_at_boot.isChecked())

def loadNetSettings(self):
path = ['internals', 'netmanager']

_, _, value = map(
dbus_type_to_python_type,
gJackctl.GetParameterValue(path + ['multicast-ip']))

self.ui.obj_net_multicast_ip.setText(value)

_, _, value = map(
dbus_type_to_python_type,
gJackctl.GetParameterValue(path + ['udp-net-port']))

self.ui.obj_net_multicast_port.setValue(value)

_, _, value = map(
dbus_type_to_python_type,
gJackctl.GetParameterValue(path + ['auto-connect']))

self.ui.obj_net_auto_connect.setChecked(value)

_, _, value = map(
dbus_type_to_python_type,
gJackctl.GetParameterValue(path + ['auto-save']))

self.ui.obj_net_auto_save.setChecked(value)

GlobalSettings = QSettings("Cadence", "GlobalSettings")
self.ui.obj_net_manager_at_boot.setChecked(
GlobalSettings.value('JACKNETMANAGER/AutoStart') == "true")
# -----------------------------------------------------------------
# Helper functions

@@ -768,6 +874,7 @@ class JackSettingsW(QDialog):

# Save previous settings
self.saveDriverSettings(False)
self.saveNetSettings()

# Set new Jack driver
self.fDriverName = dbus.String(self.ui.obj_server_driver.item(row, 0).text().lower())
@@ -844,10 +951,10 @@ class JackSettingsW(QDialog):
self.ui.obj_driver_monitor.setEnabled(driverHasFeature("monitor"))
self.ui.obj_driver_dither.setEnabled(driverHasFeature("dither"))
self.ui.obj_driver_dither_label.setEnabled(driverHasFeature("dither"))
self.ui.obj_driver_inchannels.setEnabled(driverHasFeature("inchannels"))
self.ui.obj_driver_inchannels_label.setEnabled(driverHasFeature("inchannels"))
self.ui.obj_driver_outchannels.setEnabled(driverHasFeature("outchannels"))
self.ui.obj_driver_outchannels_label.setEnabled(driverHasFeature("outchannels"))
self.ui.obj_driver_inchannels.setEnabled(driverHasFeature("inchannels") or driverHasFeature("input-ports"))
self.ui.obj_driver_inchannels_label.setEnabled(driverHasFeature("inchannels") or driverHasFeature("input-ports"))
self.ui.obj_driver_outchannels.setEnabled(driverHasFeature("outchannels") or driverHasFeature("output-ports"))
self.ui.obj_driver_outchannels_label.setEnabled(driverHasFeature("outchannels") or driverHasFeature("output-ports"))
self.ui.obj_driver_shorts.setEnabled(driverHasFeature("shorts"))
self.ui.obj_driver_input_latency.setEnabled(driverHasFeature("input-latency"))
self.ui.obj_driver_input_latency_label.setEnabled(driverHasFeature("input-latency"))
@@ -862,6 +969,7 @@ class JackSettingsW(QDialog):
self.ui.obj_driver_snoop.setEnabled(driverHasFeature("snoop"))
self.ui.obj_driver_channels.setEnabled(driverHasFeature("channels"))
self.ui.obj_driver_channels_label.setEnabled(driverHasFeature("channels"))
self.ui.obj_driver_client_name.setEnabled(driverHasFeature("client-name"))

# Misc stuff
if self.ui.obj_server_driver.item(row, 0).text() == "ALSA":
@@ -882,15 +990,35 @@ class JackSettingsW(QDialog):
elif self.ui.obj_server_driver.item(row, 0).text() == "Loopback":
self.ui.toolbox_driver_misc.setCurrentIndex(4)

elif self.ui.obj_server_driver.item(row, 0).text() == "Net":
self.ui.toolbox_driver_misc.setCurrentIndex(5)

else:
self.ui.toolbox_driver_misc.setCurrentIndex(0)

self.slot_checkDuplexSelection(self.ui.obj_driver_duplex.isChecked())

def net_manager_start(self):
jack_control_iface.LoadInternal("netmanager")

def net_manager_stop(self):
jack_control_iface.UnloadInternal("netmanager")

def net_manager_reset(self):
path = ['internals', 'netmanager']
for _, name, _, _ in gJackctl.GetParametersInfo(path):
gJackctl.ResetParameterValue(path + [name])

GlobalSettings = QSettings("Cadence", "GlobalSettings")
GlobalSettings.setValue('JACKNETMANAGER/AutoStart', False)

self.loadNetSettings()

@pyqtSlot()
def slot_saveJackSettings(self):
self.saveServerSettings()
self.saveDriverSettings(True)
self.saveNetSettings()

@pyqtSlot()
def slot_resetJackSettings(self):


+ 45
- 0
src/shared_cadence.py View File

@@ -20,6 +20,7 @@
# Imports (Global)

from time import sleep
import dbus

if True:
from PyQt5.QtCore import QProcess, QSettings
@@ -164,3 +165,47 @@ def stopAllAudioProcesses(tryCloseJack = True):
process.start("killall", ["-KILL"] + procsKill)
process.waitForFinished()
waitProcsEnd(procsKill, tries)


def bool_convert(str_value):
if str_value.lower() == "false":
return False

if str_value.lower() == "off":
return False

if str_value.lower() == "no":
return False

if str_value == "0":
return False

if str_value.lower() == "(null)":
return False

return bool(str_value)


def dbus_type_to_python_type(dbus_value):
if type(dbus_value) == dbus.Boolean:
return bool(dbus_value)
if type(dbus_value) == dbus.Int32 or type(dbus_value) == dbus.UInt32:
return int(dbus_value)
return dbus_value


def python_type_to_jackdbus_type(value, type_char):
type_char = str(type_char)

if type_char == "b":
return bool_convert(value)
elif type_char == "y":
return dbus.Byte(value)
elif type_char == "i":
return dbus.Int32(value)
elif type_char == "u":
return dbus.UInt32(value)
elif type_char == "s":
return dbus.String(value)

return value

Loading…
Cancel
Save