/usr/share/pyshared/udevdiscover/device/sound.py is in udev-discover 0.2.2-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 | # -*- coding: utf-8 -*-
# vim: ts=4
###
#
# Copyright (c) 2011 J. Félix Ontañón
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 3 as
# published by the Free Software Foundation
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# Authors : J. Félix Ontañón <fontanon@emergya.es>
#
from udevdiscover.device import Device
def get_device_object(gudevice):
devname = gudevice.get_name()
if devname.startswith('card'):
return SoundCardDevice(gudevice)
elif devname in ('timer', 'seq', 'sequencer'):
return SystemSoundDevice(gudevice)
else:
return SoundDevice(gudevice)
class SoundCardDevice(Device):
DEFAULT_ICON = 'audio-card'
@property
def nice_label(self):
if self.device.has_property('SOUND_FORM_FACTOR'):
return _('%s Sound Card') % \
self.device.get_property('SOUND_FORM_FACTOR').capitalize()
else:
return _('Sound Card')
@property
def vendor_name(self):
return self.device.get_property('ID_VENDOR_FROM_DATABASE')
@property
def model_name(self):
return self.device.get_property('ID_MODEL_FROM_DATABASE')
class SystemSoundDevice(Device):
DEFAULT_ICON = 'audio-card'
@property
def nice_label(self):
devname = self.device.get_name()
return {
'timer': _('Sound Timer'),
'seq': _('Sound Sequencer'),
'sequencer': _('Sound Sequencer'),
}.get(devname)
class SoundDevice(Device):
DEFAULT_ICON = 'audio-input-microphone'
def __init__(self, gudevice):
super(SoundDevice, self).__init__(gudevice)
devname = gudevice.get_name()
if devname.startswith('controlC'):
self.__type = 'control'
elif devname.startswith('pcmC'):
if devname.endswith('c'):
self.__type = 'capture'
elif devname.endswith('p'):
self.__type = 'playback'
else:
self.__type = 'unknown'
elif devname.startswith('hwC'):
self.__type = 'hwspecific'
elif devname.startswith('midiC'):
self.__type = 'midi'
else:
self.__type = 'unknown'
@property
def nice_label(self):
return {
'control': _('Control Sound Device'),
'capture': _('Capture Sound Device'),
'playback': _('Playback Sound Device'),
'hwspecific': _('HW Specific Sound Device'),
'midi': _('MIDI Sound Device'),
'unknown': _('Unknown Sound Device')
}.get(self.type)
@property
def type(self):
return self.__type
|