[pulseaudio-commits] [SCM] PulseAudio Sound Server branch, stable-queue, updated. v0.9.21-18-gacb4996

Lennart Poettering gitmailer-noreply at 0pointer.de
Wed Jan 13 17:08:09 PST 2010


This is an automated email from the git hooks/post-receive script. It was
generated because of a push to the "PulseAudio Sound Server" repository.

The stable-queue branch has been updated
      from  291cd096015d540d5064bfae94a66adc3bc3fc64 (commit)

- Log -----------------------------------------------------------------
acb4996 udev: rework modem detection a bit
63c968b udev: handle sound cards with both modem and audio properly
-----------------------------------------------------------------------

Summary of changes:
 src/modules/module-udev-detect.c |   60 ++++++++++++++++++++++++++++++++++++++
 1 files changed, 60 insertions(+), 0 deletions(-)

-----------------------------------------------------------------------

commit 63c968bf775ec7e172b89e45ddc4981d79587bc5
Author: Daniel T. Chen <crimsun at ubuntu.com>
Date:   Thu Jan 14 00:57:27 2010 +0100

    udev: handle sound cards with both modem and audio properly
    
    http://pulseaudio.org/ticket/681
    https://bugs.launchpad.net/ubuntu/+source/pulseaudio/+bug/394500

diff --git a/src/modules/module-udev-detect.c b/src/modules/module-udev-detect.c
index 58635a5..1fe9fdc 100644
--- a/src/modules/module-udev-detect.c
+++ b/src/modules/module-udev-detect.c
@@ -103,13 +103,17 @@ static const char *path_get_card_id(const char *path) {
     return e + 5;
 }
 
+static const char *pa_udev_get_sysattr(const char *card_idx, const char *name);
+
 static pa_bool_t is_card_busy(const char *id) {
-    char *card_path = NULL, *pcm_path = NULL, *sub_status = NULL;
+    const char *pcm_class;
+    char *card_path = NULL, *pcm_path = NULL, *sub_status = NULL,
+         *sysfs_path = NULL;
     DIR *card_dir = NULL, *pcm_dir = NULL;
     FILE *status_file = NULL;
     size_t len;
     struct dirent *space = NULL, *de;
-    pa_bool_t busy = FALSE;
+    pa_bool_t busy = FALSE, is_modem = FALSE;
     int r;
 
     pa_assert(id);
@@ -127,6 +131,17 @@ static pa_bool_t is_card_busy(const char *id) {
     len = offsetof(struct dirent, d_name) + fpathconf(dirfd(card_dir), _PC_NAME_MAX) + 1;
     space = pa_xmalloc(len);
 
+    /* Also check /sys/class/sound/card.../pcmC...D6p/pcm_class. An HDA
+     * modem can be used simultaneously with generic playback/record. */
+
+    pa_xfree(sysfs_path);
+    sysfs_path = pa_sprintf_malloc("pcmC%sD6p/pcm_class", id);
+
+    pcm_class = pa_udev_get_sysattr(id, sysfs_path);
+
+    if (pcm_class && pa_streq(pcm_class, "modem"))
+        is_modem = TRUE;
+
     for (;;) {
         de = NULL;
 
@@ -182,7 +197,7 @@ static pa_bool_t is_card_busy(const char *id) {
                 continue;
             }
 
-            if (!pa_streq(line, "closed\n")) {
+            if (!is_modem && !pa_streq(line, "closed\n")) {
                 busy = TRUE;
                 break;
             }
@@ -193,6 +208,7 @@ fail:
 
     pa_xfree(card_path);
     pa_xfree(pcm_path);
+    pa_xfree(sysfs_path);
     pa_xfree(sub_status);
     pa_xfree(space);
 
@@ -594,6 +610,43 @@ static int setup_inotify(struct userdata *u) {
     return 0;
 }
 
+static const char *pa_udev_get_sysattr(const char *card_idx, const char *name) {
+    struct udev *udev;
+    struct udev_device *card = NULL;
+    char *t, *r = NULL;
+    const char *v;
+
+    pa_assert(card_idx);
+    pa_assert(name);
+
+    if (!(udev = udev_new())) {
+        pa_log_error("Failed to allocate udev context.");
+        goto finish;
+    }
+
+    t = pa_sprintf_malloc("%s/class/sound/card%s", udev_get_sys_path(udev), card_idx);
+    card = udev_device_new_from_syspath(udev, t);
+    pa_xfree(t);
+
+    if (!card) {
+        pa_log_error("Failed to get card object.");
+        goto finish;
+    }
+
+    if ((v = udev_device_get_sysattr_value(card, name)) && *v)
+        r = pa_xstrdup(v);
+
+finish:
+
+    if (card)
+        udev_device_unref(card);
+
+    if (udev)
+        udev_unref(udev);
+
+    return r;
+}
+
 int pa__init(pa_module *m) {
     struct userdata *u = NULL;
     pa_modargs *ma;

commit acb4996203f6723d92a9b0df4e60db83c65116fc
Author: Lennart Poettering <lennart at poettering.net>
Date:   Thu Jan 14 02:06:52 2010 +0100

    udev: rework modem detection a bit
    
    Check every single pcm device of a card whether it is a modem.

diff --git a/src/modules/module-udev-detect.c b/src/modules/module-udev-detect.c
index 1fe9fdc..b8568b2 100644
--- a/src/modules/module-udev-detect.c
+++ b/src/modules/module-udev-detect.c
@@ -103,17 +103,70 @@ static const char *path_get_card_id(const char *path) {
     return e + 5;
 }
 
-static const char *pa_udev_get_sysattr(const char *card_idx, const char *name);
+static char *card_get_sysattr(const char *card_idx, const char *name) {
+    struct udev *udev;
+    struct udev_device *card = NULL;
+    char *t, *r = NULL;
+    const char *v;
+
+    pa_assert(card_idx);
+    pa_assert(name);
+
+    if (!(udev = udev_new())) {
+        pa_log_error("Failed to allocate udev context.");
+        goto finish;
+    }
+
+    t = pa_sprintf_malloc("%s/class/sound/card%s", udev_get_sys_path(udev), card_idx);
+    card = udev_device_new_from_syspath(udev, t);
+    pa_xfree(t);
+
+    if (!card) {
+        pa_log_error("Failed to get card object.");
+        goto finish;
+    }
+
+    if ((v = udev_device_get_sysattr_value(card, name)) && *v)
+        r = pa_xstrdup(v);
+
+finish:
+
+    if (card)
+        udev_device_unref(card);
+
+    if (udev)
+        udev_unref(udev);
+
+    return r;
+}
+
+static pa_bool_t pcm_is_modem(const char *card_idx, const char *pcm) {
+    char *sysfs_path, *pcm_class;
+    pa_bool_t is_modem;
+
+    pa_assert(card_idx);
+    pa_assert(pcm);
+
+    /* Check /sys/class/sound/card.../pcmC...../pcm_class. An HDA
+     * modem can be used simultaneously with generic
+     * playback/record. */
+
+    sysfs_path = pa_sprintf_malloc("pcmC%sD%s/pcm_class", card_idx, pcm);
+    pcm_class = card_get_sysattr(card_idx, sysfs_path);
+    is_modem = pcm_class && pa_streq(pcm_class, "modem");
+    pa_xfree(pcm_class);
+    pa_xfree(sysfs_path);
+
+    return is_modem;
+}
 
 static pa_bool_t is_card_busy(const char *id) {
-    const char *pcm_class;
-    char *card_path = NULL, *pcm_path = NULL, *sub_status = NULL,
-         *sysfs_path = NULL;
+    char *card_path = NULL, *pcm_path = NULL, *sub_status = NULL;
     DIR *card_dir = NULL, *pcm_dir = NULL;
     FILE *status_file = NULL;
     size_t len;
     struct dirent *space = NULL, *de;
-    pa_bool_t busy = FALSE, is_modem = FALSE;
+    pa_bool_t busy = FALSE;
     int r;
 
     pa_assert(id);
@@ -131,17 +184,6 @@ static pa_bool_t is_card_busy(const char *id) {
     len = offsetof(struct dirent, d_name) + fpathconf(dirfd(card_dir), _PC_NAME_MAX) + 1;
     space = pa_xmalloc(len);
 
-    /* Also check /sys/class/sound/card.../pcmC...D6p/pcm_class. An HDA
-     * modem can be used simultaneously with generic playback/record. */
-
-    pa_xfree(sysfs_path);
-    sysfs_path = pa_sprintf_malloc("pcmC%sD6p/pcm_class", id);
-
-    pcm_class = pa_udev_get_sysattr(id, sysfs_path);
-
-    if (pcm_class && pa_streq(pcm_class, "modem"))
-        is_modem = TRUE;
-
     for (;;) {
         de = NULL;
 
@@ -156,6 +198,9 @@ static pa_bool_t is_card_busy(const char *id) {
         if (!pa_startswith(de->d_name, "pcm"))
             continue;
 
+        if (pcm_is_modem(id, de->d_name + 3))
+            continue;
+
         pa_xfree(pcm_path);
         pcm_path = pa_sprintf_malloc("%s/%s", card_path, de->d_name);
 
@@ -197,7 +242,7 @@ static pa_bool_t is_card_busy(const char *id) {
                 continue;
             }
 
-            if (!is_modem && !pa_streq(line, "closed\n")) {
+            if (!pa_streq(line, "closed\n")) {
                 busy = TRUE;
                 break;
             }
@@ -208,7 +253,6 @@ fail:
 
     pa_xfree(card_path);
     pa_xfree(pcm_path);
-    pa_xfree(sysfs_path);
     pa_xfree(sub_status);
     pa_xfree(space);
 
@@ -610,43 +654,6 @@ static int setup_inotify(struct userdata *u) {
     return 0;
 }
 
-static const char *pa_udev_get_sysattr(const char *card_idx, const char *name) {
-    struct udev *udev;
-    struct udev_device *card = NULL;
-    char *t, *r = NULL;
-    const char *v;
-
-    pa_assert(card_idx);
-    pa_assert(name);
-
-    if (!(udev = udev_new())) {
-        pa_log_error("Failed to allocate udev context.");
-        goto finish;
-    }
-
-    t = pa_sprintf_malloc("%s/class/sound/card%s", udev_get_sys_path(udev), card_idx);
-    card = udev_device_new_from_syspath(udev, t);
-    pa_xfree(t);
-
-    if (!card) {
-        pa_log_error("Failed to get card object.");
-        goto finish;
-    }
-
-    if ((v = udev_device_get_sysattr_value(card, name)) && *v)
-        r = pa_xstrdup(v);
-
-finish:
-
-    if (card)
-        udev_device_unref(card);
-
-    if (udev)
-        udev_unref(udev);
-
-    return r;
-}
-
 int pa__init(pa_module *m) {
     struct userdata *u = NULL;
     pa_modargs *ma;

-- 
hooks/post-receive
PulseAudio Sound Server



More information about the pulseaudio-commits mailing list