[pulseaudio-commits] 2 commits - src/modules

Tanu Kaskinen tanuk at kemper.freedesktop.org
Thu Mar 9 22:35:35 UTC 2017


 src/modules/dbus/iface-card.c    |   16 ++++++++--------
 src/modules/module-udev-detect.c |   22 +++++++++-------------
 2 files changed, 17 insertions(+), 21 deletions(-)

New commits:
commit 0ced45265c0c4a14b922fbf36050d71ce3e55086
Author: Tanu Kaskinen <tanuk at iki.fi>
Date:   Sat Feb 18 18:40:42 2017 +0200

    dbus: fix card profile change signals
    
    The "profile->card != c->card" check always evaluated to false, so the
    CardProfileUpdated signal was never sent. The reason: call_data was
    assigned to a pa_card_profile pointer, but the correct type is a pa_card
    pointer.

diff --git a/src/modules/dbus/iface-card.c b/src/modules/dbus/iface-card.c
index 1b705ba..5203250 100644
--- a/src/modules/dbus/iface-card.c
+++ b/src/modules/dbus/iface-card.c
@@ -457,27 +457,27 @@ static void check_card_proplist(pa_dbusiface_card *c) {
 }
 
 static pa_hook_result_t card_profile_changed_cb(void *hook_data, void *call_data, void *slot_data) {
-    pa_dbusiface_card *c = slot_data;
-    pa_card_profile *profile = call_data;
+    pa_dbusiface_card *dbus_card = slot_data;
+    pa_card *core_card = call_data;
     const char *object_path;
     DBusMessage *signal_msg;
 
-    if (profile->card != c->card)
+    if (dbus_card->card != core_card)
         return PA_HOOK_OK;
 
-    c->active_profile = c->card->active_profile;
+    dbus_card->active_profile = dbus_card->card->active_profile;
 
-    object_path = pa_dbusiface_card_profile_get_path(pa_hashmap_get(c->profiles, c->active_profile->name));
+    object_path = pa_dbusiface_card_profile_get_path(pa_hashmap_get(dbus_card->profiles, dbus_card->active_profile->name));
 
-    pa_assert_se(signal_msg = dbus_message_new_signal(c->path,
+    pa_assert_se(signal_msg = dbus_message_new_signal(dbus_card->path,
                                                       PA_DBUSIFACE_CARD_INTERFACE,
                                                       signals[SIGNAL_ACTIVE_PROFILE_UPDATED].name));
     pa_assert_se(dbus_message_append_args(signal_msg, DBUS_TYPE_OBJECT_PATH, &object_path, DBUS_TYPE_INVALID));
 
-    pa_dbus_protocol_send_signal(c->dbus_protocol, signal_msg);
+    pa_dbus_protocol_send_signal(dbus_card->dbus_protocol, signal_msg);
     dbus_message_unref(signal_msg);
 
-    check_card_proplist(c);
+    check_card_proplist(dbus_card);
 
     return PA_HOOK_OK;
 }

commit 6022a1ee993dacfb12e8f100ab7e767e4206b0f2
Author: Tanu Kaskinen <tanuk at iki.fi>
Date:   Thu Oct 13 17:22:44 2016 +0300

    udev-detect: don't use readdir_r(), it's deprecated
    
    readdir_r() was supposed to be a thread-safe version of readdir(), but
    the interface turned out to be problematic. Due to the problems and the
    fact that readdir() is safe enough on modern libc implementations, glibc
    deprecated readdir_r() in version 2.24.
    
    The man page contains more information about what's wrong with
    readdir_r(): http://man7.org/linux/man-pages/man3/readdir_r.3.html

diff --git a/src/modules/module-udev-detect.c b/src/modules/module-udev-detect.c
index bb41a96..3d7064f 100644
--- a/src/modules/module-udev-detect.c
+++ b/src/modules/module-udev-detect.c
@@ -177,10 +177,8 @@ static bool is_card_busy(const char *id) {
     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;
+    struct dirent *de;
     bool busy = false;
-    int r;
 
     pa_assert(id);
 
@@ -194,14 +192,11 @@ static bool is_card_busy(const char *id) {
         goto fail;
     }
 
-    len = offsetof(struct dirent, d_name) + fpathconf(dirfd(card_dir), _PC_NAME_MAX) + 1;
-    space = pa_xmalloc(len);
-
     for (;;) {
-        de = NULL;
-
-        if ((r = readdir_r(card_dir, space, &de)) != 0) {
-            pa_log_warn("readdir_r() failed: %s", pa_cstrerror(r));
+        errno = 0;
+        de = readdir(card_dir);
+        if (!de && errno) {
+            pa_log_warn("readdir() failed: %s", pa_cstrerror(errno));
             goto fail;
         }
 
@@ -228,8 +223,10 @@ static bool is_card_busy(const char *id) {
         for (;;) {
             char line[32];
 
-            if ((r = readdir_r(pcm_dir, space, &de)) != 0) {
-                pa_log_warn("readdir_r() failed: %s", pa_cstrerror(r));
+            errno = 0;
+            de = readdir(pcm_dir);
+            if (!de && errno) {
+                pa_log_warn("readdir() failed: %s", pa_cstrerror(errno));
                 goto fail;
             }
 
@@ -267,7 +264,6 @@ fail:
     pa_xfree(card_path);
     pa_xfree(pcm_path);
     pa_xfree(sub_status);
-    pa_xfree(space);
 
     if (card_dir)
         closedir(card_dir);



More information about the pulseaudio-commits mailing list