1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import gettext
23 import os
24
25 from zope.interface import implements
26
27 from flumotion.admin.assistant.interfaces import IProducerPlugin
28 from flumotion.admin.assistant.models import AudioProducer
29 from flumotion.common.errors import RemoteRunFailure
30 from flumotion.common.i18n import N_, gettexter
31 from flumotion.common.messages import Info
32 from flumotion.admin.gtk.basesteps import AudioProducerStep
33
34 __version__ = "$Rev: 8057 $"
35 _ = gettext.gettext
36 T_ = gettexter()
37
38 CHANNELS = {1: _('Mono'),
39 2: _('Stereo')}
40
41 SAMPLE_RATES = [48000,
42 44100,
43 32000,
44 22050,
45 16000,
46 11025,
47 8000]
48
49
50 SOURCE_ELEMENTS = [(_('Alsa'), 'alsasrc'),
51 (_('OSS'), 'osssrc')]
52
53
59
60
62 name = 'Soundcard'
63 title = _('Sound Card')
64 icon = 'soundcard.png'
65 gladeFile = os.path.join(os.path.dirname(os.path.abspath(__file__)),
66 'wizard.glade')
67 componentType = 'osssrc'
68 docSection = 'help-configuration-assistant-producer-audio-soundcard'
69 docAnchor = ''
70
73
74
75
77 self.input_track.data_type = str
78 self.channels.data_type = int
79 self.samplerate.data_type = int
80 self.depth.data_type = int
81 self.device.data_type = str
82 self.source_element.data_type = str
83
84 self.source_element.prefill(SOURCE_ELEMENTS)
85
86 self.add_proxy(self.model.properties,
87 ['input_track',
88 'channels',
89 'samplerate',
90 'depth',
91 'device',
92 'source_element'])
93
94
95
96 self.source_element.connect('changed', self.on_source_element__changed)
97
102
105
106
107
109 self.input_track.set_sensitive(not block)
110 self.channels.set_sensitive(not block)
111 self.depth.set_sensitive(not block)
112 self.samplerate.set_sensitive(not block)
113
115 self.wizard.waitForTask('soundcard checks')
116 self.wizard.clear_msg('soundcard-device')
117
118 msg = Info(T_(
119 N_("Looking for the sound devices present on the system. "
120 "This can take a while...")), mid='soundcard-check')
121 self.wizard.add_msg(msg)
122
123 def checkFailed(failure):
124 failure.trap(RemoteRunFailure)
125 self.wizard.taskFinished(blockNext=True)
126 self._blockCombos()
127
128 def gotSoundDevices(devices):
129 self.wizard.clear_msg('soundcard-check')
130 self.wizard.taskFinished(False)
131 self.device.set_sensitive(True)
132 self.device.prefill(devices)
133
134 sourceElement = self.source_element.get_selected()
135
136 d = self.runInWorker(
137 'flumotion.worker.checks.audio', 'getAudioDevices',
138 sourceElement, mid='soundcard-device')
139
140 d.addCallback(gotSoundDevices)
141 d.addErrback(checkFailed)
142
143 return d
144
162
163 def soundcardCheckComplete((deviceName, tracks, caps)):
164 self.wizard.clear_msg('soundcard-check')
165 self.wizard.taskFinished(False)
166 self._caps = caps
167 self.input_track.prefill(tracks)
168 self.input_track.set_sensitive(bool(tracks))
169
170 d = self.runInWorker(
171 'flumotion.worker.checks.audio', 'checkMixerTracks',
172 sourceElement, device, mid='soundcard-check')
173
174 d.addCallback(soundcardCheckComplete)
175 d.addErrback(checkFailed)
176
177 return d
178
180 bitdepths = {}
181 for capStruct in self._caps:
182 data = capStruct.copy()
183 bitdepths[data.pop('depth')] = data
184 self._capStructs = bitdepths
185 bitdepths = sorted(bitdepths)
186 self.depth.prefill(
187 [(_('%d-bit') % bitdepth, bitdepth) for bitdepth in bitdepths])
188 self.depth.set_sensitive(True)
189
191 capStruct = self._capStructs.get(self.depth.get_selected())
192 if capStruct is None:
193 return
194 channels = []
195 if type(capStruct['channels']) == int:
196 nchannels = capStruct['channels']
197 channels.append((CHANNELS[nchannels], nchannels))
198 else:
199 for nchannels in capStruct['channels']:
200 channels.append((CHANNELS[nchannels], nchannels))
201
202 self.channels.prefill(channels)
203 self.channels.set_sensitive(True)
204
206 capStruct = self._capStructs.get(self.depth.get_selected())
207 if capStruct is None:
208 return
209 max, min = capStruct['rate']
210 self.samplerate.prefill(
211 [(str(rate), rate) for rate in SAMPLE_RATES if min <= rate <= max])
212 self.samplerate.set_sensitive(True)
213
214
215
218
221
225
228
229
239