~diwic/ubuntu/lucid/pulseaudio/bugfixes

« back to all changes in this revision

Viewing changes to debian/patches/0070-dont-bail-on-sound-class-modem-devs.patch

  • Committer: Bazaar Package Importer
  • Author(s): Daniel T Chen
  • Date: 2009-12-06 19:40:04 UTC
  • Revision ID: james.westby@ubuntu.com-20091206194004-47jpo06j6oymymu0
Tags: 1:0.9.21-0ubuntu2
* Fix LP: #394500, #450222:
  + 0070-dont-bail-on-sound-class-modem-devs.patch:
    + Add pa_udev_get_sysattr() helper function so that we can
      retrieve pcm_class.
    + Add short-circuit in is_card_busy(). Currently there is an
      incorrect break out of the loop when an HDA modem is driven by
      slmodemd/hsfmodem. An HDA modem resides in device 6 and will
      not contain "closed\n" for
      /proc/asound/card.../pcm.../sub.../status.
* 0058-Backport-4c793.patch: Use pa_stream pointers to hashmaps
  instead of dynarrays.
* 0059-Backport-978d3.patch: Mark shared variables as volatile
  to supress compiler optimizations.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
Index: pulseaudio-0.9.21/src/modules/module-udev-detect.c
 
2
===================================================================
 
3
--- pulseaudio-0.9.21.orig/src/modules/module-udev-detect.c     2009-12-07 22:26:14.000000000 -0500
 
4
+++ pulseaudio-0.9.21/src/modules/module-udev-detect.c  2009-12-07 22:26:30.000000000 -0500
 
5
@@ -103,13 +103,17 @@
 
6
     return e + 5;
 
7
 }
 
8
 
 
9
+static const char *pa_udev_get_sysattr(const char *card_idx, const char *name);
 
10
+
 
11
 static pa_bool_t is_card_busy(const char *id) {
 
12
-    char *card_path = NULL, *pcm_path = NULL, *sub_status = NULL;
 
13
+    const char *pcm_class;
 
14
+    char *card_path = NULL, *pcm_path = NULL, *sub_status = NULL,
 
15
+         *sysfs_path = NULL;
 
16
     DIR *card_dir = NULL, *pcm_dir = NULL;
 
17
     FILE *status_file = NULL;
 
18
     size_t len;
 
19
     struct dirent *space = NULL, *de;
 
20
-    pa_bool_t busy = FALSE;
 
21
+    pa_bool_t busy = FALSE, is_modem = FALSE;
 
22
     int r;
 
23
 
 
24
     pa_assert(id);
 
25
@@ -127,6 +131,17 @@
 
26
     len = offsetof(struct dirent, d_name) + fpathconf(dirfd(card_dir), _PC_NAME_MAX) + 1;
 
27
     space = pa_xmalloc(len);
 
28
 
 
29
+    /* Also check /sys/class/sound/card.../pcmC...D6p/pcm_class. An HDA
 
30
+     * modem can be used simultaneously with generic playback/record. */
 
31
+
 
32
+    pa_xfree(sysfs_path);
 
33
+    sysfs_path = pa_sprintf_malloc("pcmC%sD6p/pcm_class", id);
 
34
+
 
35
+    pcm_class = pa_udev_get_sysattr(id, sysfs_path);
 
36
+
 
37
+    if (pcm_class && pa_streq(pcm_class, "modem"))
 
38
+        is_modem = TRUE;
 
39
+
 
40
     for (;;) {
 
41
         de = NULL;
 
42
 
 
43
@@ -182,7 +197,7 @@
 
44
                 continue;
 
45
             }
 
46
 
 
47
-            if (!pa_streq(line, "closed\n")) {
 
48
+            if (!is_modem && !pa_streq(line, "closed\n")) {
 
49
                 busy = TRUE;
 
50
                 break;
 
51
             }
 
52
@@ -193,6 +208,7 @@
 
53
 
 
54
     pa_xfree(card_path);
 
55
     pa_xfree(pcm_path);
 
56
+    pa_xfree(sysfs_path);
 
57
     pa_xfree(sub_status);
 
58
     pa_xfree(space);
 
59
 
 
60
@@ -592,6 +608,43 @@
 
61
     return 0;
 
62
 }
 
63
 
 
64
+static const char *pa_udev_get_sysattr(const char *card_idx, const char *name) {
 
65
+    struct udev *udev;
 
66
+    struct udev_device *card = NULL;
 
67
+    char *t, *r = NULL;
 
68
+    const char *v;
 
69
+
 
70
+    pa_assert(card_idx);
 
71
+    pa_assert(name);
 
72
+
 
73
+    if (!(udev = udev_new())) {
 
74
+        pa_log_error("Failed to allocate udev context.");
 
75
+        goto finish;
 
76
+    }
 
77
+
 
78
+    t = pa_sprintf_malloc("%s/class/sound/card%i", udev_get_sys_path(udev), card_idx);
 
79
+    card = udev_device_new_from_syspath(udev, t);
 
80
+    pa_xfree(t);
 
81
+
 
82
+    if (!card) {
 
83
+        pa_log_error("Failed to get card object.");
 
84
+        goto finish;
 
85
+    }
 
86
+
 
87
+    if ((v = udev_device_get_sysattr_value(card, name)) && *v)
 
88
+        r = pa_xstrdup(v);
 
89
+
 
90
+finish:
 
91
+
 
92
+    if (card)
 
93
+        udev_device_unref(card);
 
94
+
 
95
+    if (udev)
 
96
+        udev_unref(udev);
 
97
+
 
98
+    return r;
 
99
+}
 
100
+
 
101
 int pa__init(pa_module *m) {
 
102
     struct userdata *u = NULL;
 
103
     pa_modargs *ma;