| Trees | Indices | Help |
|---|
|
|
1 # -*- Mode: Python -*-
2 # vi:si:et:sw=4:sts=4:ts=4
3 #
4 # Flumotion - a streaming media server
5 # Copyright (C) 2004,2005,2006,2007,2008 Fluendo, S.L. (www.fluendo.com).
6 # All rights reserved.
7
8 # This file may be distributed and/or modified under the terms of
9 # the GNU General Public License version 2 as published by
10 # the Free Software Foundation.
11 # This file is distributed without any warranty; without even the implied
12 # warranty of merchantability or fitness for a particular purpose.
13 # See "LICENSE.GPL" in the source distribution for more information.
14
15 # Licensees having purchased or holding a valid Flumotion Advanced
16 # Streaming Server license may use this file in accordance with the
17 # Flumotion Advanced Streaming Server Commercial License Agreement.
18 # See "LICENSE.Flumotion" in the source distribution for more information.
19
20 # Headers in this file shall remain intact.
21
22 import gettext
23 import os
24
25 from zope.interface import implements
26
27 from flumotion.common.errors import RemoteRunFailure
28 from flumotion.common.i18n import N_, gettexter
29 from flumotion.common.messages import Info
30 from flumotion.wizard.basesteps import AudioProducerStep
31 from flumotion.wizard.interfaces import IProducerPlugin
32 from flumotion.wizard.models import AudioProducer
33
34 __version__ = "$Rev: 7097 $"
35 _ = gettext.gettext
36 T_ = gettexter()
37
38 OSS_DEVICES = ["/dev/dsp",
39 "/dev/dsp1",
40 "/dev/dsp2"]
41 ALSA_DEVICES = ['hw:0',
42 'hw:1',
43 'hw:2']
44 CHANNELS = [(_('Stereo'), 2),
45 (_('Mono'), 1)]
46 BITDEPTHS = [(_('16-bit'), 16)]
47 SAMPLE_RATES = [48000,
48 44100,
49 32000,
50 22050,
51 16000,
52 11025,
53 8000]
54 SOURCE_ELEMENTS = [(_('Alsa'), 'alsasrc'),
55 (_('OSS'), 'osssrc')]
56
57
59 componentType = 'soundcard-producer'
60
62 super(SoundcardProducer, self).__init__()
63
64 self.properties.input_track = ''
65 self.properties.channels = 2
66 self.properties.rate = 44100
67 self.properties.depth = 16
68 self.properties.device = ''
69 self.properties.source_element = 'alsasrc'
70
71
73 name = 'Soundcard'
74 title = _('Sound Card')
75 icon = 'soundcard.png'
76 gladeFile = os.path.join(os.path.dirname(os.path.abspath(__file__)),
77 'wizard.glade')
78 componentType = 'osssrc'
79
83
84 # WizardStep
85
87 # block updates, because populating a shown combobox will of course
88 # trigger the callback
89 self._blockUpdate = True
90 self.input_track.data_type = str
91 self.channels.data_type = int
92 self.rate.data_type = int
93 self.depth.data_type = int
94 self.device.data_type = str
95 self.source_element.data_type = str
96
97 self.input_track.prefill([''])
98 self.channels.prefill(CHANNELS)
99 self.rate.prefill([(str(r), r) for r in SAMPLE_RATES])
100 self.depth.prefill(BITDEPTHS)
101 self.device.prefill([''])
102 self.source_element.prefill(SOURCE_ELEMENTS)
103
104 self.add_proxy(self.model.properties,
105 ['input_track',
106 'channels',
107 'rate',
108 'depth',
109 'device',
110 'source_element'])
111
112 self._blockUpdate = False
113
115 self.model.worker = worker
116 self._clear_combos()
117 self._update_devices()
118 self._updateInputs()
119
122
123 # Private
124
126 self.input_track.clear()
127 self.input_track.set_sensitive(False)
128 self.channels.set_sensitive(False)
129 self.rate.set_sensitive(False)
130 self.depth.set_sensitive(False)
131
133 self._blockUpdate = True
134 self.device.clear()
135 sourceElement = self.source_element.get_selected()
136 if sourceElement == 'alsasrc':
137 self.device.prefill(ALSA_DEVICES)
138 elif sourceElement == 'osssrc':
139 self.device.prefill(OSS_DEVICES)
140 else:
141 raise AssertionError
142 self._blockUpdate = False
143
145 if self._blockUpdate:
146 return
147 self.wizard.waitForTask('soundcard checks')
148
149 device = self.device.get_selected()
150 elementName = self.source_element.get_selected()
151 channels = self.channels.get_selected() or 2
152 assert device
153 assert elementName
154 assert channels
155 msg = Info(T_(
156 N_("Probing the sound card. This can take a while...")),
157 mid='soundcard-check')
158 self.wizard.add_msg(msg)
159 d = self.runInWorker(
160 'flumotion.worker.checks.audio', 'checkMixerTracks',
161 elementName, device, channels, mid='soundcard-check')
162
163 def checkFailed(failure):
164 failure.trap(RemoteRunFailure)
165 self._clear_combos()
166 self.wizard.taskFinished()
167
168 def soundcardCheckComplete((deviceName, tracks)):
169 self.wizard.clear_msg('soundcard-check')
170 self.wizard.taskFinished(False)
171 self.label_devicename.set_label(deviceName)
172 self._blockUpdate = True
173 self.channels.set_sensitive(True)
174 self.rate.set_sensitive(True)
175 self.depth.set_sensitive(True)
176 self.input_track.prefill(tracks)
177 self.input_track.set_sensitive(bool(tracks))
178 self._blockUpdate = False
179
180 d.addCallback(soundcardCheckComplete)
181 d.addErrback(checkFailed)
182
183 return d
184
185 # Callbacks
186
191
193 self._updateInputs()
194
196 # FIXME: make it so that the number of channels can be changed
197 # and the check gets executed with the new number
198 # self.updateInputs()
199 pass
200
201
210
| Trees | Indices | Help |
|---|
| Generated by Epydoc 3.0.1 on Sat Jul 26 09:43:08 2008 | http://epydoc.sourceforge.net |