3 # Copyright (C) 2005-2008 by Pieter Palmers
4 # 2007-2009 by Arnold Krille
6 # This file is part of FFADO
7 # FFADO = Free Firewire (pro-)audio drivers for linux
9 # FFADO is based upon FreeBoB.
11 # This program is free software: you can redistribute it and/or modify
12 # it under the terms of the GNU General Public License as published by
13 # the Free Software Foundation, either version 3 of the License, or
14 # (at your option) any later version.
16 # This program is distributed in the hope that it will be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 # GNU General Public License for more details.
21 # You should have received a copy of the GNU General Public License
22 # along with this program. If not, see <http://www.gnu.org/licenses/>.
27 from ffado
.config
import *
31 from PyQt4
.QtCore
import SIGNAL
, SLOT
, QObject
, QTimer
, Qt
32 from PyQt4
.QtGui
import *
34 from ffado
.dbus_util
import *
36 from ffado
.panelmanager
import PanelManager
38 from ffado
.logginghandler
import *
40 """Just a small helper to ask the retry-question without a blocking messagebox"""
41 class StartDialog(QWidget
):
42 def __init__(self
, parent
):
43 QWidget
.__init
__(self
, parent
)
44 self
.setObjectName("Restart Dialog")
45 self
.label
= QLabel("<qt>Somehow the connection to the dbus-service of FFADO couldn't be established.<p>\nShall we take another try?</qt>",self
)
46 self
.button
= QPushButton("Retry", self
)
47 self
.layout
= QGridLayout(self
)
48 self
.layout
.setContentsMargins( 50, 10, 50, 10 )
49 self
.layout
.addWidget(self
.label
, 0, 0, Qt
.AlignHCenter|Qt
.AlignBottom
)
50 self
.layout
.addWidget(self
.button
, 1, 0, Qt
.AlignHCenter|Qt
.AlignTop
)
52 class FFADOWindow(QMainWindow
):
53 def __init__(self
, parent
):
54 QMainWindow
.__init
__(self
, parent
)
56 self
.textlogger
= QTextLogger(self
)
57 dock
= QDockWidget("Log Messages",self
)
58 dock
.setWidget(self
.textlogger
.textedit
)
59 logging
.getLogger('').addHandler(self
.textlogger
)
60 self
.addDockWidget(Qt
.BottomDockWidgetArea
, dock
)
62 self
.statuslogger
= QStatusLogger(self
, self
.statusBar(), 20)
63 logging
.getLogger('').addHandler(self
.statuslogger
)
65 self
.manager
= PanelManager(self
)
66 self
.connect(self
.manager
, SIGNAL("connectionLost"), self
.connectToDBUS
)
68 filemenu
= self
.menuBar().addMenu("File")
69 self
.openaction
= QAction("Open", self
)
70 self
.openaction
.setShortcut(self
.tr("Ctrl+O"))
71 self
.openaction
.setEnabled(False)
72 self
.connect(self
.openaction
, SIGNAL("triggered()"), self
.manager
.readSettings
)
73 filemenu
.addAction(self
.openaction
)
74 self
.saveaction
= QAction("Save as...", self
)
75 self
.saveaction
.setShortcut(self
.tr("Ctrl+S"))
76 self
.saveaction
.setEnabled(False)
77 self
.connect(self
.saveaction
, SIGNAL("triggered()"), self
.manager
.saveSettings
)
78 filemenu
.addAction(self
.saveaction
)
79 quitaction
= QAction("Quit", self
)
80 quitaction
.setShortcut(self
.tr("Ctrl+q"))
81 self
.connect(quitaction
, SIGNAL("triggered()"), self
, SLOT("close()"))
82 filemenu
.addAction(quitaction
)
84 editmenu
= self
.menuBar().addMenu("Edit")
85 self
.updateaction
= QAction("Update Mixer Panels", self
)
86 self
.updateaction
.setEnabled(False)
87 self
.connect(self
.updateaction
, SIGNAL("triggered()"), self
.manager
.updatePanels
)
88 editmenu
.addAction(self
.updateaction
)
89 refreshaction
= QAction("Refresh Current Panels", self
)
90 self
.connect(refreshaction
, SIGNAL("triggered()"), self
.manager
.refreshPanels
)
91 editmenu
.addAction(refreshaction
)
93 helpmenu
= self
.menuBar().addMenu( "Help" )
94 aboutaction
= QAction( "About FFADO", self
)
95 self
.connect( aboutaction
, SIGNAL( "triggered()" ), self
.aboutFFADO
)
96 helpmenu
.addAction( aboutaction
)
97 aboutqtaction
= QAction( "About Qt", self
)
98 self
.connect( aboutqtaction
, SIGNAL( "triggered()" ), qApp
, SLOT( "aboutQt()" ) )
99 helpmenu
.addAction( aboutqtaction
)
101 log
.info( "Starting up" )
103 QTimer
.singleShot( 1, self
.tryStartDBUSServer
)
108 log
.info("__del__ finished")
110 def closeEvent(self
, event
):
111 log
.info("closeEvent()")
114 def connectToDBUS(self
):
115 log
.info("connectToDBUS")
117 self
.setupDeviceManager()
118 except dbus
.DBusException
, ex
:
119 log
.error("Could not communicate with the FFADO DBus service...")
120 if not hasattr(self
,"retry"):
121 self
.retry
= StartDialog(self
)
122 self
.connect(self
.retry
.button
, SIGNAL("clicked()"), self
.tryStartDBUSServer
)
123 if hasattr(self
, "retry"):
124 self
.manager
.setParent(None)
125 self
.setCentralWidget(self
.retry
)
126 self
.retry
.setEnabled(True)
128 def tryStartDBUSServer(self
):
130 self
.setupDeviceManager()
131 except dbus
.DBusException
, ex
:
132 if hasattr(self
, "retry"):
133 self
.retry
.setEnabled(False)
134 subprocess
.Popen(['ffado-dbus-server', '-v3']).pid
135 QTimer
.singleShot(5000, self
.connectToDBUS
)
137 def setupDeviceManager(self
):
138 devmgr
= DeviceManagerInterface(FFADO_DBUS_SERVER
, FFADO_DBUS_BASEPATH
)
139 self
.manager
.setManager(devmgr
)
140 if hasattr(self
, "retry"):
141 self
.retry
.setParent(None)
142 self
.setCentralWidget(self
.manager
)
143 self
.updateaction
.setEnabled(True)
145 def aboutFFADO(self
):
146 QMessageBox
.about( self
, "About FFADO", """
149 <p>FFADO is the new approach to have firewire audio on linux.</p>
151 <p>© 2006-2014 by the FFADO developers<br />ffado is licensed under the GPLv3, for the full license text see <a href="http://www.gnu.org/licenses/">www.gnu.org/licenses</a> or the LICENSE.* files shipped with ffado.</p>
153 <p>FFADO developers are:<ul>
158 <li>Philippe Carriere
161 with contributions from:<ul>
169 def get_lock(process_name
):
174 lock_socket
= socket
.socket(socket
.AF_UNIX
, socket
.SOCK_DGRAM
)
176 lock_socket
.bind('\0' + process_name
)
179 print 'ffado-mixer instance is already running'
186 logging
.basicConfig( datefmt
="%H:%M:%S", format
="%(asctime)s %(name)-16s %(levelname)-8s %(message)s" )
189 debug_level
= logging
.DEBUG
191 debug_level
= logging
.INFO
193 get_lock('ffado-mixer')
196 logging
.getLogger('main').setLevel(debug_level
)
197 logging
.getLogger('dbus').setLevel(debug_level
)
198 logging
.getLogger('registration').setLevel(debug_level
)
199 logging
.getLogger('panelmanager').setLevel(debug_level
)
200 logging
.getLogger('configparser').setLevel(logging
.INFO
)
203 logging
.getLogger('matrixmixer').setLevel(debug_level
)
204 logging
.getLogger('crossbarrouter').setLevel(debug_level
)
207 logging
.getLogger('audiofire').setLevel(debug_level
)
208 logging
.getLogger('bridgeco').setLevel(debug_level
)
209 logging
.getLogger('edirolfa101').setLevel(debug_level
)
210 logging
.getLogger('edirolfa66').setLevel(debug_level
)
211 logging
.getLogger('motu').setLevel(debug_level
)
212 logging
.getLogger('rme').setLevel(debug_level
)
213 logging
.getLogger('phase24').setLevel(debug_level
)
214 logging
.getLogger('phase88').setLevel(debug_level
)
215 logging
.getLogger('quatafire').setLevel(debug_level
)
216 logging
.getLogger('saffirebase').setLevel(debug_level
)
217 logging
.getLogger('saffire').setLevel(debug_level
)
218 logging
.getLogger('saffirepro').setLevel(debug_level
)
220 logging
.getLogger('global').setLevel(debug_level
)
222 log
= logging
.getLogger('main')
224 app
= QApplication(args
)
225 app
.setWindowIcon( QIcon( SHAREDIR
+ "/icons/hi64-apps-ffado.png" ) )
227 app
.setOrganizationName("FFADO")
228 app
.setOrganizationDomain("ffado.org")
229 app
.setApplicationName("ffado-mixer")
231 mainwindow
= FFADOWindow(None)
238 if __name__
== "__main__":
240 sys
.exit(ffadomain(sys
.argv
))