gnome-control-center r8832 - trunk/capplets/sound
- From: jensg svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-control-center r8832 - trunk/capplets/sound
- Date: Sat, 2 Aug 2008 12:59:44 +0000 (UTC)
Author: jensg
Date: Sat Aug 2 12:59:44 2008
New Revision: 8832
URL: http://svn.gnome.org/viewvc/gnome-control-center?rev=8832&view=rev
Log:
2008-08-02 Jens Granseuer <jensgr gmx net>
Based on a patch by: Alexander Schwenn <alesch xelaris net>
* sound-properties-capplet.c: (filter_device_generic),
(filter_device_alsa), (filter_device_oss),
(get_device_description), (device_added_alsa), (device_added_oss): add
some filtering for OSS devices and create more useful device
descriptions (bug #545275)
Modified:
trunk/capplets/sound/ChangeLog
trunk/capplets/sound/sound-properties-capplet.c
Modified: trunk/capplets/sound/sound-properties-capplet.c
==============================================================================
--- trunk/capplets/sound/sound-properties-capplet.c (original)
+++ trunk/capplets/sound/sound-properties-capplet.c Sat Aug 2 12:59:44 2008
@@ -62,6 +62,11 @@
VIDEO_CAPTURE
} device_type;
+typedef enum {
+ SYSTEM_ALSA,
+ SYSTEM_OSS
+} SoundSystemType;
+
typedef struct _DeviceChooser
{
const gchar *profile;
@@ -398,15 +403,38 @@
}
}
-static void
-device_added_alsa (LibHalContext *ctx, const char *udi)
+static gboolean
+filter_device_generic (LibHalContext *ctx, const char *udi)
+{
+ gboolean ignore = FALSE;
+ gchar *parent_udi;
+ gchar *subsystem;
+
+ parent_udi = libhal_device_get_property_string (ctx, udi, "info.parent", NULL);
+
+ if (!parent_udi)
+ return FALSE;
+
+ subsystem = libhal_device_get_property_string (ctx, parent_udi, "info.subsystem", NULL);
+
+ /* filter out pc speaker */
+ if (subsystem && (!strcmp (subsystem, "platform") || !strcmp (subsystem, "sound"))) {
+ gchar *device_id = libhal_device_get_property_string (ctx, parent_udi, "platform.id", NULL);
+ ignore = device_id && !strncmp (device_id, "pcspk", 5);
+ libhal_free_string (device_id);
+ }
+
+ libhal_free_string (parent_udi);
+ libhal_free_string (subsystem);
+
+ return ignore;
+}
+
+static gboolean
+filter_device_alsa (LibHalContext *ctx, const char *udi)
{
- gchar *type_string;
- gchar *class_string;
- int type;
- const gchar *element;
- gchar *pipeline, *description;
gboolean ignore;
+ gchar *class_string;
/* filter out "digitizer", "modem", "none", "unknown" */
class_string = libhal_device_get_property_string (ctx, udi, "alsa.pcm_class", NULL);
@@ -414,10 +442,94 @@
&& strcmp (class_string, "generic") != 0
&& strcmp (class_string, "multi") != 0;
libhal_free_string (class_string);
- if (ignore) {
- return;
+
+ if (!ignore)
+ ignore = filter_device_generic (ctx, udi);
+
+ return ignore;
+}
+
+static gboolean
+filter_device_oss (LibHalContext *ctx, const char *udi)
+{
+ gboolean ignore = FALSE;
+ gchar *parent_udi;
+ gchar *subsystem;
+
+ parent_udi = libhal_device_get_property_string (ctx, udi, "info.parent", NULL);
+
+ if (!parent_udi)
+ return FALSE;
+
+ subsystem = libhal_device_get_property_string (ctx, parent_udi, "info.subsystem", NULL);
+ /* filter out modem devices */
+ if (subsystem && !strcmp (subsystem, "pci")) {
+ dbus_int32_t device_class = libhal_device_get_property_int (ctx, parent_udi, "pci.device_class", NULL);
+ /* this means "Simple communications controllers". Maybe there is a headerfile with definitions?
+ * visit http://www.acm.uiuc.edu/sigops/roll_your_own/7.c.1.html for further information */
+ ignore = (device_class == 0x7);
}
+ libhal_free_string (parent_udi);
+ libhal_free_string (subsystem);
+
+ if (!ignore)
+ ignore = filter_device_generic (ctx, udi);
+
+ return ignore;
+}
+
+static gchar *
+get_device_description (LibHalContext *ctx, const char *udi, SoundSystemType snd_sys)
+{
+ gchar *card_id = NULL, *device_id = NULL, *product, *desc;
+ const gchar *indicator = NULL;
+
+ /* the device number should be reported if there is a second (playback)
+ * device with the same description on the same card */
+ /* dbus_int32_t device_num = 0; */
+
+ switch (snd_sys) {
+ case SYSTEM_ALSA:
+ card_id = libhal_device_get_property_string (ctx, udi, "alsa.card_id", NULL);
+ device_id = libhal_device_get_property_string (ctx, udi, "alsa.device_id", NULL);
+ /* device_num = libhal_device_get_property_int (ctx, udi, "alsa.device", NULL); */
+ indicator = "(ALSA)";
+ break;
+ case SYSTEM_OSS:
+ card_id = libhal_device_get_property_string (ctx, udi, "oss.card_id", NULL);
+ device_id = libhal_device_get_property_string (ctx, udi, "oss.device_id", NULL);
+ /* device_num = libhal_device_get_property_int (ctx, udi, "oss.device", NULL); */
+ indicator = "(OSS)";
+ }
+
+ /* card_id and device_id are not mandatory in OSS and ALSA namespace
+ * according to the specification so it could be possible go get an
+ * empty string */
+ if (card_id && device_id) {
+ desc = g_strconcat (card_id, " ", device_id, " ", indicator, NULL);
+ } else {
+ product = libhal_device_get_property_string (ctx, udi, "info.product", NULL);
+ desc = g_strconcat (product, " ", indicator, NULL);
+ libhal_free_string (product);
+ }
+ libhal_free_string (card_id);
+ libhal_free_string (device_id);
+
+ return desc;
+}
+
+static void
+device_added_alsa (LibHalContext *ctx, const char *udi)
+{
+ gchar *type_string;
+ int type;
+ const gchar *element;
+ gchar *pipeline, *description;
+
+ if (filter_device_alsa (ctx, udi))
+ return;
+
type_string = libhal_device_get_property_string (ctx, udi, "alsa.type", NULL);
if (strcmp (type_string, "playback") == 0) {
type = AUDIO_PLAYBACK;
@@ -435,12 +547,12 @@
}
pipeline = g_strconcat (element, " udi=", udi, NULL);
- description = libhal_device_get_property_string (ctx, udi, "alsa.device_id", NULL);
+ description = get_device_description (ctx, udi, SYSTEM_ALSA);
add_device (type, pipeline, description, NULL);
g_free (pipeline);
- libhal_free_string (description);
+ g_free (description);
}
static void
@@ -451,6 +563,9 @@
const gchar *element;
gchar *pipeline, *description;
+ if (filter_device_oss (ctx, udi))
+ return;
+
type_string = libhal_device_get_property_string (ctx, udi, "oss.type", NULL);
if (strcmp (type_string, "pcm") == 0) {
type = AUDIO_PLAYBACK;
@@ -468,12 +583,12 @@
}
pipeline = g_strconcat (element, " udi=", udi, NULL);
- description = libhal_device_get_property_string (ctx, udi, "oss.device_id", NULL);
+ description = get_device_description (ctx, udi, SYSTEM_OSS);
add_device (type, pipeline, description, NULL);
g_free (pipeline);
- libhal_free_string (description);
+ g_free (description);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]