1 |
# |
---|
2 |
# Copyright (C) 2008 by Arnold Krille |
---|
3 |
# |
---|
4 |
# This file is part of FFADO |
---|
5 |
# FFADO = Free Firewire (pro-)audio drivers for linux |
---|
6 |
# |
---|
7 |
# FFADO is based upon FreeBoB. |
---|
8 |
# |
---|
9 |
# This program is free software: you can redistribute it and/or modify |
---|
10 |
# it under the terms of the GNU General Public License as published by |
---|
11 |
# the Free Software Foundation, either version 2 of the License, or |
---|
12 |
# (at your option) version 3 of the License. |
---|
13 |
# |
---|
14 |
# This program is distributed in the hope that it will be useful, |
---|
15 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
16 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
17 |
# GNU General Public License for more details. |
---|
18 |
# |
---|
19 |
# You should have received a copy of the GNU General Public License |
---|
20 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
---|
21 |
# |
---|
22 |
|
---|
23 |
from PyQt4.QtGui import QWidget, QMessageBox |
---|
24 |
from mixer_globalui import Ui_GlobalMixerUi |
---|
25 |
|
---|
26 |
import logging |
---|
27 |
log = logging.getLogger('global') |
---|
28 |
|
---|
29 |
class GlobalMixer( QWidget, Ui_GlobalMixerUi ): |
---|
30 |
def __init__( self, parent ): |
---|
31 |
QWidget.__init__( self, parent ) |
---|
32 |
self.setupUi(self) |
---|
33 |
|
---|
34 |
def clockChanged( self, clock ): |
---|
35 |
#print "updateClockSource( " + str(clock) + " )" |
---|
36 |
if self.clockselect.canChangeValue(): |
---|
37 |
self.clockselect.select( clock ) |
---|
38 |
else: |
---|
39 |
msg = QMessageBox() |
---|
40 |
msg.question( msg, "Error", \ |
---|
41 |
"<qt>Clock source change not permitted. Is streaming active?</qt>", \ |
---|
42 |
QMessageBox.Ok ) |
---|
43 |
self.clocksource.setEnabled(False) |
---|
44 |
return |
---|
45 |
|
---|
46 |
selected = self.clockselect.selected() |
---|
47 |
if selected != clock: |
---|
48 |
clockname = self.clockselect.getEnumLabel( clock ) |
---|
49 |
msg = QMessageBox() |
---|
50 |
msg.question( msg, "Failed to select clock source", \ |
---|
51 |
"<qt>Could not select %s as clock source.</qt>" % clockname, \ |
---|
52 |
QMessageBox.Ok ) |
---|
53 |
self.clocksource.setCurrentIndex( selected ) |
---|
54 |
|
---|
55 |
def samplerateChanged( self, sr ): |
---|
56 |
log.debug("samplerateChanged( " + str(sr) + " )") |
---|
57 |
self.samplerateselect.select( sr ) |
---|
58 |
if self.samplerateselect.canChangeValue(): |
---|
59 |
self.samplerateselect.select( st ) |
---|
60 |
else: |
---|
61 |
msg = QMessageBox() |
---|
62 |
msg.question( msg, "Error", \ |
---|
63 |
"<qt>Sample rate change not permitted. Is streaming active?</qt>", \ |
---|
64 |
QMessageBox.Ok ) |
---|
65 |
self.samplerate.setEnabled(False) |
---|
66 |
return |
---|
67 |
|
---|
68 |
selected = self.samplerateselect.selected() |
---|
69 |
if selected != sr: |
---|
70 |
srname = self.samplerateselect.getEnumLabel( sr ) |
---|
71 |
msg = QMessageBox() |
---|
72 |
msg.question( msg, "Failed to select sample rate", \ |
---|
73 |
"<qt>Could not select %s as samplerate.</qt>" % srname, \ |
---|
74 |
QMessageBox.Ok ) |
---|
75 |
self.samplerate.setCurrentIndex( selected ) |
---|
76 |
|
---|
77 |
def nicknameChanged( self, name ): |
---|
78 |
#print "nicknameChanged( %s )" % name |
---|
79 |
asciiData = name.toAscii() |
---|
80 |
self.nickname.setText( asciiData.data() ) |
---|
81 |
|
---|
82 |
def initValues( self ): |
---|
83 |
#print "GlobalMixer::initValues()" |
---|
84 |
nb_clocks = self.clockselect.count() |
---|
85 |
for i in range( nb_clocks ): |
---|
86 |
self.clocksource.insertItem( nb_clocks, self.clockselect.getEnumLabel( i ) ) |
---|
87 |
self.clocksource.setCurrentIndex( self.clockselect.selected() ) |
---|
88 |
|
---|
89 |
nb_rates = self.samplerateselect.count() |
---|
90 |
for i in range( nb_rates ): |
---|
91 |
self.samplerate.insertItem( nb_rates, self.samplerateselect.getEnumLabel( i ) ) |
---|
92 |
self.samplerate.setCurrentIndex( self.samplerateselect.selected() ) |
---|
93 |
|
---|
94 |
self.txtNickname.setText( self.nickname.text() ) |
---|
95 |
|
---|
96 |
def polledUpdate(self): |
---|
97 |
self.samplerate.setEnabled(self.samplerateselect.canChangeValue()) |
---|
98 |
self.clocksource.setEnabled(self.clockselect.canChangeValue()) |
---|