2 Copyright 2009 by Hans Baier
10 public class HardwareInfo
: Object
{
14 private HashTable
<int, string> _capture_devices
;
15 private HashTable
<int, string> _playback_devices
;
17 private List
<string> result
;
19 public List
<string> capture_devices
{
22 result
= new List
<string> ();
23 for (int i
= 0; i
< _capture_devices
.size (); i
++) {
24 result
.append (_capture_devices
.lookup (i
));
31 public List
<string> playback_devices
{
34 result
= new List
<string> ();
35 for (int i
= 0; i
< _playback_devices
.size (); i
++) {
36 result
.append (_playback_devices
.lookup (i
));
44 error
= DBus
.RawError ();
46 ctx
= new Hal
.Context ();
47 ctx
.set_dbus_connection (DBus
.RawBus
.get (DBus
.BusType
.SYSTEM
, ref error
));
50 enumerate_alsa_devices ();
53 public void enumerate_alsa_devices () {
54 _capture_devices
= new HashTable
<int, string> (direct_hash
, direct_equal
);
55 _playback_devices
= new HashTable
<int, string> (direct_hash
, direct_equal
);
57 var results
= ctx
.find_device_by_capability ("alsa", ref error
);
59 foreach (string udi
in results
) {
60 string type
= ctx
.device_get_property_string (udi
, "alsa.type", ref error
);
61 if (type
== "sequencer") {
62 debug ("got sequencer");
66 if (type
== "playback") {
67 int card_nr
= ctx
.device_get_property_int (udi
, "alsa.card", ref error
);
68 int device_nr
= ctx
.device_get_property_int (udi
, "alsa.device", ref error
);
69 string card_id
= ctx
.device_get_property_string (udi
, "alsa.card_id", ref error
);
71 _playback_devices
.insert (card_nr
, card_id
);
72 debug ("got playback card: %d, device: %d with name %s", card_nr
, device_nr
, card_id
);
74 debug("got playback card: %d, device: %d with name %s (not appended)", card_nr
, device_nr
, card_id
);
76 } else if (type
== "capture") {
77 int card_nr
= ctx
.device_get_property_int (udi
, "alsa.card", ref error
);
78 int device_nr
= ctx
.device_get_property_int (udi
, "alsa.device", ref error
);
79 string card_id
= ctx
.device_get_property_string (udi
, "alsa.card_id", ref error
);
81 _capture_devices
.insert (card_nr
, card_id
);
82 debug ("got capture card: %d, device: %d with name %s", card_nr
, device_nr
, card_id
);
84 debug("got capture card: %d, device: %d with name %s (not appended)", card_nr
, device_nr
, card_id
);
87 debug ("unknown type: %s", type
);
95 } //namespace Jackpanel