pulse 4+ changes
[profile/ivi/pulseaudio-module-murphy-ivi.git] / augment / module-dir-watch.c
index cc0c490..56b4c67 100644 (file)
@@ -55,7 +55,7 @@
 PA_MODULE_AUTHOR("Ismo Puustinen");
 PA_MODULE_DESCRIPTION("Directory watch module");
 PA_MODULE_VERSION(PACKAGE_VERSION);
-PA_MODULE_LOAD_ONCE(TRUE);
+PA_MODULE_LOAD_ONCE(true);
 PA_MODULE_USAGE("");
 
 struct userdata {
@@ -172,7 +172,7 @@ static void dir_watch_inotify_cb(
 
     pa_log_debug("> inotify_cb");
 
-    while (TRUE) {
+    while (true) {
 
         r = pa_read(fd, &eventbuf, sizeof(eventbuf), &type);
 
@@ -285,7 +285,7 @@ static int add_directory(const char *directory, pa_client *c, struct userdata *u
 
         PA_LLIST_PREPEND(struct client_id, cd->ids, id);
 
-        pa_hashmap_put(u->paths_to_clients, (const void *)0 + wd, (void *) cd);
+        pa_hashmap_put(u->paths_to_clients, (void *)0 + wd, (void *) cd);
     }
 #endif
     return 0;
@@ -302,14 +302,14 @@ static pa_hook_result_t client_unlink_cb(
     void *state;
     struct client_data *cd;
     struct client_id *id;
-    pa_bool_t found = FALSE;
+    bool found = false;
 
     PA_HASHMAP_FOREACH(cd, u->paths_to_clients, state) {
         PA_LLIST_FOREACH(id, cd->ids) {
             if (id->id == c->index) {
                 PA_LLIST_REMOVE(struct client_id, cd->ids, id);
                 pa_xfree(id);
-                found = TRUE;
+                found = true;
                 break;
             }
         }
@@ -362,6 +362,10 @@ fail:
 
 void pa__done(pa_module *m) {
     struct userdata *u;
+#ifdef HAVE_INOTIFY
+    void       *state;
+    struct client_data *cd;
+#endif
 
     pa_assert(m);
     pa_assert(m->userdata);
@@ -376,8 +380,19 @@ void pa__done(pa_module *m) {
         pa_close(u->inotify_fd);
 
 
-    if (u->paths_to_clients)
-        pa_hashmap_free(u->paths_to_clients, (pa_free_cb_t) client_data_free);
+    if (u->paths_to_clients) {
+
+        PA_HASHMAP_FOREACH(cd, u->paths_to_clients, state) { 
+            pa_xfree(cd->directory);
+            while(cd->ids) {
+                struct client_id *id = cd->ids;
+                PA_LLIST_REMOVE(struct client_id, cd->ids, id);
+                pa_xfree(id);
+            }
+        }
+
+        pa_hashmap_free(u->paths_to_clients);
+    }
 #endif
 
     pa_xfree(u);