root/branches/libffado-2.0/support/mixer-qt4/ffadomixer.in

Revision 1298, 3.3 kB (checked in by ppalmers, 13 years ago)

add Qt4 port of the mixer (only for audiofire and saffire ATM). needed since PyQt?3 doesn't support DBUS signals.

  • Property svn:executable set to *
Line 
1 #!/usr/bin/python
2 #
3 # Copyright (C) 2005-2008 by Pieter Palmers
4 #               2007-2008 by Arnold Krille
5 #
6 # This file is part of FFADO
7 # FFADO = Free Firewire (pro-)audio drivers for linux
8 #
9 # FFADO is based upon FreeBoB.
10 #
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.
15 #
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.
20 #
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/>.
23 #
24
25 #
26 # QT 4 version
27 #
28
29 import sys
30
31 # Add the path of the installed ffado-mixer-modules
32 sys.path.append( "$PYTHONDIR" )
33
34 from ffadomixer_config import POLL_SLEEP_TIME_MSEC, FFADO_DBUS_SERVER, FFADO_DBUS_BASEPATH
35
36 import os
37 import time
38
39 from PyQt4.QtCore import SIGNAL, SLOT, QObject, QTimer
40 from PyQt4.QtGui import QApplication, QMessageBox
41
42 from ffado_dbus_util import *
43
44 from ffado_panelmanager import PanelManager
45
46 if __name__ == "__main__":
47
48     app = QApplication(sys.argv)
49
50     msg = QMessageBox()
51
52     repeat = 1
53     while repeat > 0:
54         try:
55             devmgr = DeviceManagerInterface(FFADO_DBUS_SERVER, FFADO_DBUS_BASEPATH)
56             nbDevices = devmgr.getNbDevices()
57             repeat -= 1
58         except dbus.DBusException, ex:
59             print "\n"
60             print "==========================================================="
61             print "ERROR: Could not communicate with the FFADO DBus service..."
62             print "==========================================================="
63             print "\n"
64             tmp = msg.question( msg, "FFADO-DBus not found", "<qt><b>The connection to FFADOs DBus service could not be established.</b><p>Probably you didn't start the ffado-dbus-server. Should I try this now?</qt>", QMessageBox.Yes, QMessageBox.No )
65             if tmp == QMessageBox.No:
66                 sys.exit(-1)
67             else:
68                 os.spawnlp( os.P_NOWAIT, "ffado-dbus-server" )
69                 nb_checks = 20
70                 while nb_checks > 0:
71                     nb_checks = nb_checks - 1
72                     try:
73                         devmgr = DeviceManagerInterface(FFADO_DBUS_SERVER, FFADO_DBUS_BASEPATH)
74                         nbDevices = devmgr.getNbDevices()
75                         nb_checks = 0
76                         repeat = 0
77                     except dbus.DBusException, ex:
78                         time.sleep( 1 )
79
80     manager = PanelManager(None, devmgr)
81
82     # create a timer to poll the panels
83     polltimer = QTimer()
84     QObject.connect( polltimer, SIGNAL('timeout()'), manager.pollPanels )
85     polltimer.start( POLL_SLEEP_TIME_MSEC )
86
87     # create a timer to initialize the panel after the main form is shown
88     # since initialization can take a while
89     showtimer = QTimer()
90     QObject.connect( showtimer, SIGNAL('timeout()'), manager.updatePanels )
91     showtimer.setSingleShot(True)
92     showtimer.start( POLL_SLEEP_TIME_MSEC )
93
94     # rock & roll
95     manager.show()
96     QObject.connect(app,SIGNAL("lastWindowClosed()"),app,SLOT("quit()"))
97     app.exec_()
Note: See TracBrowser for help on using the browser.