2 This file is part of PulseAudio.
4 Copyright 2009 Lennart Poettering
6 PulseAudio is free software; you can redistribute it and/or modify
7 it under the terms of the GNU Lesser General Public License as
8 published by the Free Software Foundation; either version 2.1 of the
9 License, or (at your option) any later version.
11 PulseAudio is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with PulseAudio; if not, see <http://www.gnu.org/licenses/>.
27 #include <sys/inotify.h>
30 #include <pulse/timeval.h>
32 #include <pulsecore/modargs.h>
33 #include <pulsecore/core-error.h>
34 #include <pulsecore/core-util.h>
35 #include <pulsecore/namereg.h>
36 #include <pulsecore/ratelimit.h>
37 #include <pulsecore/strbuf.h>
40 #define DEFAULT_FRAGMENT_MSEC 25
43 PA_MODULE_AUTHOR("Lennart Poettering");
44 PA_MODULE_DESCRIPTION("Detect available audio hardware and load matching drivers");
45 PA_MODULE_VERSION(PACKAGE_VERSION);
46 PA_MODULE_LOAD_ONCE(true);
48 "tsched=<enable system timer based scheduling mode?> "
49 "tsched_buffer_size=<buffer size when using timer based scheduling> "
50 "fixed_latency_range=<disable latency range changes on underrun?> "
51 "ignore_dB=<ignore dB information from the device?> "
52 "deferred_volume=<syncronize sw and hw volume changes in IO-thread?> "
53 "use_ucm=<use ALSA UCM for card configuration?> "
54 "avoid_resampling=<use stream original sample rate if possible?>"
56 "use_tizen_hal=<use tizen hal through tizenaudio-sink2/source2, it must be 'both', 'sink', 'source'>"
57 "fixed_latency_msec=<use fixed latency based on millisecond>"
68 pa_ratelimit ratelimit;
76 bool tsched_buffer_size_valid:1;
77 bool fixed_latency_range:1;
79 bool deferred_volume:1;
81 bool avoid_resampling:1;
83 uint32_t tsched_buffer_size;
86 struct udev_monitor *monitor;
90 pa_io_event *inotify_io;
93 uint32_t fixed_latency_msec;
97 static const char* const valid_modargs[] = {
100 "fixed_latency_range",
107 "fixed_latency_msec",
112 static int setup_inotify(struct userdata *u);
114 static void device_free(struct device *d) {
118 pa_xfree(d->card_name);
123 static const char *path_get_card_id(const char *path) {
129 if (!(e = strrchr(path, '/')))
132 if (!pa_startswith(e, "/card"))
138 static char *card_get_sysattr(const char *card_idx, const char *name) {
140 struct udev_device *card = NULL;
147 if (!(udev = udev_new())) {
148 pa_log_error("Failed to allocate udev context.");
152 t = pa_sprintf_malloc("/sys/class/sound/card%s", card_idx);
153 card = udev_device_new_from_syspath(udev, t);
157 pa_log_error("Failed to get card object.");
161 if ((v = udev_device_get_sysattr_value(card, name)) && *v)
167 udev_device_unref(card);
175 static bool pcm_is_modem(const char *card_idx, const char *pcm) {
176 char *sysfs_path, *pcm_class;
182 /* Check /sys/class/sound/card.../pcmC...../pcm_class. An HDA
183 * modem can be used simultaneously with generic
184 * playback/record. */
186 sysfs_path = pa_sprintf_malloc("pcmC%sD%s/pcm_class", card_idx, pcm);
187 pcm_class = card_get_sysattr(card_idx, sysfs_path);
188 is_modem = pcm_class && pa_streq(pcm_class, "modem");
190 pa_xfree(sysfs_path);
195 static bool is_card_busy(const char *id) {
196 char *card_path = NULL, *pcm_path = NULL, *sub_status = NULL;
197 DIR *card_dir = NULL, *pcm_dir = NULL;
198 FILE *status_file = NULL;
204 /* This simply uses /proc/asound/card.../pcm.../sub.../status to
205 * check whether there is still a process using this audio device. */
207 card_path = pa_sprintf_malloc("/proc/asound/card%s", id);
209 if (!(card_dir = opendir(card_path))) {
210 pa_log_warn("Failed to open %s: %s", card_path, pa_cstrerror(errno));
216 de = readdir(card_dir);
218 pa_log_warn("readdir() failed: %s", pa_cstrerror(errno));
225 if (!pa_startswith(de->d_name, "pcm"))
228 if (pcm_is_modem(id, de->d_name + 3))
232 pcm_path = pa_sprintf_malloc("%s/%s", card_path, de->d_name);
237 if (!(pcm_dir = opendir(pcm_path))) {
238 pa_log_warn("Failed to open %s: %s", pcm_path, pa_cstrerror(errno));
246 de = readdir(pcm_dir);
248 pa_log_warn("readdir() failed: %s", pa_cstrerror(errno));
255 if (!pa_startswith(de->d_name, "sub"))
258 pa_xfree(sub_status);
259 sub_status = pa_sprintf_malloc("%s/%s/status", pcm_path, de->d_name);
264 if (!(status_file = pa_fopen_cloexec(sub_status, "r"))) {
265 pa_log_warn("Failed to open %s: %s", sub_status, pa_cstrerror(errno));
269 if (!(fgets(line, sizeof(line)-1, status_file))) {
270 pa_log_warn("Failed to read from %s: %s", sub_status, pa_cstrerror(errno));
274 if (!pa_streq(line, "closed\n")) {
285 pa_xfree(sub_status);
299 static void verify_access(struct userdata *u, struct device *d) {
310 cd = pa_sprintf_malloc("/dev/snd/controlC%s", path_get_card_id(d->path));
311 accessible = access(cd, R_OK|W_OK) >= 0;
312 pa_log_debug("%s is accessible: %s", cd, pa_yes_no(accessible));
316 if (d->module == PA_INVALID_INDEX) {
318 /* If we are not loaded, try to load */
324 /* Check if any of the PCM devices that belong to this
325 * card are currently busy. If they are, don't try to load
326 * right now, to make sure the probing phase can
327 * successfully complete. When the current user of the
328 * device closes it we will get another notification via
329 * inotify and can then recheck. */
331 busy = is_card_busy(path_get_card_id(d->path));
332 pa_log_debug("%s is busy: %s", d->path, pa_yes_no(busy));
336 /* So, why do we rate limit here? It's certainly ugly,
337 * but there seems to be no other way. Problem is
338 * this: if we are unable to configure/probe an audio
339 * device after opening it we will close it again and
340 * the module initialization will fail. This will then
341 * cause an inotify event on the device node which
342 * will be forwarded to us. We then try to reopen the
343 * audio device again, practically entering a busy
346 * A clean fix would be if we would be able to ignore
347 * our own inotify close events. However, inotify
348 * lacks such functionality. Also, during probing of
349 * the device we cannot really distinguish between
350 * other processes causing EBUSY or ourselves, which
351 * means we have no way to figure out if the probing
352 * during opening was canceled by a "try again"
353 * failure or a "fatal" failure. */
355 if (pa_ratelimit_test(&d->ratelimit, PA_LOG_DEBUG)) {
358 pa_log_debug("Loading module-alsa-card with arguments '%s'", d->args);
359 err = pa_module_load(&m, u->core, "module-alsa-card", d->args);
362 d->module = m->index;
363 pa_log_info("Card %s (%s) module loaded.", d->path, d->card_name);
364 } else if (err == -PA_ERR_NOENTITY) {
365 pa_log_info("Card %s (%s) module skipped.", d->path, d->card_name);
368 pa_log_info("Card %s (%s) failed to load module.", d->path, d->card_name);
371 pa_log_warn("Tried to configure %s (%s) more often than %u times in %llus",
375 (long long unsigned) (d->ratelimit.interval / PA_USEC_PER_SEC));
381 /* If we are already loaded update suspend status with
382 * accessible boolean */
384 if ((card = pa_namereg_get(u->core, d->card_name, PA_NAMEREG_CARD))) {
385 pa_log_debug("%s all sinks and sources of card %s.", accessible ? "Resuming" : "Suspending", d->card_name);
386 pa_card_suspend(card, !accessible, PA_SUSPEND_SESSION);
391 static void card_changed(struct userdata *u, struct udev_device *dev) {
401 /* Maybe /dev/snd is now available? */
404 path = udev_device_get_devpath(dev);
406 if ((d = pa_hashmap_get(u->devices, path))) {
411 d = pa_xnew0(struct device, 1);
412 d->path = pa_xstrdup(path);
413 d->module = PA_INVALID_INDEX;
414 PA_INIT_RATELIMIT(d->ratelimit, 10*PA_USEC_PER_SEC, 5);
416 if (!(t = udev_device_get_property_value(dev, "PULSE_NAME")))
417 if (!(t = udev_device_get_property_value(dev, "ID_ID")))
418 if (!(t = udev_device_get_property_value(dev, "ID_PATH")))
419 t = path_get_card_id(path);
421 n = pa_namereg_make_valid_name(t);
422 d->card_name = pa_sprintf_malloc("alsa_card.%s", n);
423 args_buf = pa_strbuf_new();
424 pa_strbuf_printf(args_buf,
429 "use_tizen_hal=\"%s\" "
430 "fixed_latency_msec=%d "
432 "namereg_fail=false "
434 "fixed_latency_range=%s "
436 "deferred_volume=%s "
438 "avoid_resampling=%s "
439 "card_properties=\"module-udev-detect.discovered=1\"",
440 path_get_card_id(path),
445 u->fixed_latency_msec,
447 pa_yes_no(u->use_tsched),
448 pa_yes_no(u->fixed_latency_range),
449 pa_yes_no(u->ignore_dB),
450 pa_yes_no(u->deferred_volume),
451 pa_yes_no(u->use_ucm),
452 pa_yes_no(u->avoid_resampling));
455 if (u->tsched_buffer_size_valid)
456 pa_strbuf_printf(args_buf, " tsched_buffer_size=%" PRIu32, u->tsched_buffer_size);
458 d->args = pa_strbuf_to_string_free(args_buf);
460 pa_hashmap_put(u->devices, d->path, d);
465 static void remove_card(struct userdata *u, struct udev_device *dev) {
471 if (!(d = pa_hashmap_remove(u->devices, udev_device_get_devpath(dev))))
474 pa_log_info("Card %s removed.", d->path);
476 if (d->module != PA_INVALID_INDEX)
477 pa_module_unload_request_by_index(u->core, d->module, true);
483 static void dump_device(struct udev_device *dev) {
484 pa_log_debug("[ devpath = %s", udev_device_get_devpath(dev));
485 pa_log_debug(" subsystem = %s", udev_device_get_subsystem(dev));
486 pa_log_debug(" devtype = %s", udev_device_get_devtype(dev));
487 pa_log_debug(" syspath = %s", udev_device_get_syspath(dev));
488 pa_log_debug(" sysname = %s", udev_device_get_sysname(dev));
489 pa_log_debug(" sysnum = %s", udev_device_get_sysnum(dev));
490 pa_log_debug(" devnode = %s", udev_device_get_devnode(dev));
491 pa_log_debug(" parent subsystem = %s ]", udev_device_get_subsystem(udev_device_get_parent(dev)));
494 static bool is_devpath_hdmi_extcon(struct udev_device *dev) {
495 const char *devpath = udev_device_get_devpath(dev);
499 return (bool)strstr(devpath, "hdmi");
502 static void add_hdmi_card(struct userdata *u, const char *card) {
504 struct udev_device *card_dev;
507 if (!(udev = udev_new())) {
508 pa_log_error("Failed to allocate udev context.");
512 syspath = pa_sprintf_malloc("/sys/class/sound/%s", card);
514 if ((card_dev = udev_device_new_from_syspath(udev, syspath))) {
515 card_changed(u, card_dev);
516 udev_device_unref(card_dev);
518 pa_log_error("Failed to get card object.");
525 /* NOTE : based from pa_card_choose_initial_profile() */
526 pa_card_profile *find_best_card_profile(pa_card *card) {
527 pa_card_profile *profile;
529 pa_card_profile *best = NULL;
533 pa_log_info("Looking for best profile for card %s", card->name);
534 PA_HASHMAP_FOREACH(profile, card->profiles, state) {
535 pa_log_debug(" name(%s), avail(%s)", profile->name, pa_available_to_string(profile->available));
536 if (profile->available == PA_AVAILABLE_NO)
539 if (!best || profile->priority > best->priority)
544 PA_HASHMAP_FOREACH(profile, card->profiles, state) {
545 if (!best || profile->priority > best->priority)
551 pa_log_info("Found best profile %s", best->name);
553 pa_log_error("No best profile!");
558 static void process_hdmi_device(struct userdata *u, struct udev_device *dev) {
563 const char *event_str[] = { "Added", "Removed" };
564 const char *sysfs_path;
566 pa_card_profile *profile_to_set;
571 devtype = udev_device_get_devtype(dev);
573 pa_log_error("no parent devtype exist!");
578 is_removed = pa_safe_streq(udev_device_get_property_value(dev, "STATE"), "HDMI=0");
580 if (!pa_startswith(devtype, "extcon")) {
581 pa_log_error("invalid devtype %s", devtype);
585 card_to_find = pa_replace(devtype, "extcon", "card");
587 pa_log_info("%s %s, devtype : %s", card_to_find, event_str[is_removed], devtype);
589 PA_IDXSET_FOREACH(card, u->core->cards, idx) {
590 sysfs_path = pa_proplist_gets(card->proplist, "sysfs.path");
592 pa_log_warn("no sysfs.path property...");
595 pa_log_info("sysfs.path : %s, finding : %s", sysfs_path, card_to_find);
597 if (pa_endswith(sysfs_path, card_to_find)) {
598 pa_log_info(" card exists, update proper profile for event (%s)", event_str[is_removed]);
600 profile_to_set = is_removed ? pa_hashmap_get(card->profiles, "off") : find_best_card_profile(card);
603 pa_card_set_profile(card, profile_to_set, false);
605 pa_log_error("no profile to set!");
611 pa_log_info("No card found, add new card (%s)", card_to_find);
612 add_hdmi_card(u, card_to_find);
615 pa_xfree(card_to_find);
617 #endif /* __TIZEN__ */
619 static void process_device(struct userdata *u, struct udev_device *dev) {
620 const char *action, *ff;
625 if (udev_device_get_property_value(dev, "PULSE_IGNORE")) {
626 pa_log_debug("Ignoring %s, because marked so.", udev_device_get_devpath(dev));
630 if ((ff = udev_device_get_property_value(dev, "SOUND_CLASS")) &&
631 pa_streq(ff, "modem")) {
632 pa_log_debug("Ignoring %s, because it is a modem.", udev_device_get_devpath(dev));
639 action = udev_device_get_action(dev);
641 if (action && pa_streq(action, "remove"))
643 else if ((!action || pa_streq(action, "change")) && udev_device_get_property_value(dev, "SOUND_INITIALIZED"))
644 card_changed(u, dev);
646 /* For an explanation why we don't look for 'add' events here
647 * have a look into /lib/udev/rules.d/78-sound-card.rules! */
650 static void process_path(struct userdata *u, const char *path) {
651 struct udev_device *dev;
653 if (!path_get_card_id(path))
656 if (!(dev = udev_device_new_from_syspath(u->udev, path))) {
657 pa_log("Failed to get udev device object from udev.");
661 process_device(u, dev);
662 udev_device_unref(dev);
665 static void monitor_cb(
669 pa_io_event_flags_t events,
672 struct userdata *u = userdata;
673 struct udev_device *dev;
677 if (!(dev = udev_monitor_receive_device(u->monitor))) {
678 pa_log("Failed to get udev device object from monitor.");
683 if (is_devpath_hdmi_extcon(dev)) {
684 pa_log_info("HDMI, devpath : %s", udev_device_get_devpath(dev));
685 process_hdmi_device(u, dev);
686 udev_device_unref(dev);
690 if (!path_get_card_id(udev_device_get_devpath(dev))) {
691 udev_device_unref(dev);
695 process_device(u, dev);
696 udev_device_unref(dev);
700 a->io_free(u->udev_io);
704 static bool pcm_node_belongs_to_device(
711 cd = pa_sprintf_malloc("pcmC%sD", path_get_card_id(d->path));
712 b = pa_startswith(node, cd);
718 static bool control_node_belongs_to_device(
725 cd = pa_sprintf_malloc("controlC%s", path_get_card_id(d->path));
726 b = pa_streq(node, cd);
732 static void inotify_cb(
736 pa_io_event_flags_t events,
740 struct inotify_event e;
743 struct userdata *u = userdata;
745 bool deleted = false;
751 struct inotify_event *event;
754 if ((r = pa_read(fd, &buf, sizeof(buf), &type)) <= 0) {
756 if (r < 0 && errno == EAGAIN)
759 pa_log("read() from inotify failed: %s", r < 0 ? pa_cstrerror(errno) : "EOF");
767 if ((size_t) r < sizeof(struct inotify_event)) {
768 pa_log("read() too short.");
772 len = sizeof(struct inotify_event) + event->len;
774 if ((size_t) r < len) {
775 pa_log("Payload missing.");
779 /* From udev we get the guarantee that the control
780 * device's ACL is changed last. To avoid races when ACLs
781 * are changed we hence watch only the control device */
782 if (((event->mask & IN_ATTRIB) && pa_startswith(event->name, "controlC")))
783 PA_HASHMAP_FOREACH(d, u->devices, state)
784 if (control_node_belongs_to_device(d, event->name))
785 d->need_verify = true;
787 /* ALSA doesn't really give us any guarantee on the closing
788 * order, so let's simply hope */
789 if (((event->mask & IN_CLOSE_WRITE) && pa_startswith(event->name, "pcmC")))
790 PA_HASHMAP_FOREACH(d, u->devices, state)
791 if (pcm_node_belongs_to_device(d, event->name))
792 d->need_verify = true;
794 /* /dev/snd/ might have been removed */
795 if ((event->mask & (IN_DELETE_SELF|IN_MOVE_SELF)))
798 event = (struct inotify_event*) ((uint8_t*) event + len);
803 PA_HASHMAP_FOREACH(d, u->devices, state)
804 if (d->need_verify) {
805 d->need_verify = false;
814 a->io_free(u->inotify_io);
815 u->inotify_io = NULL;
818 if (u->inotify_fd >= 0) {
819 pa_close(u->inotify_fd);
824 static int setup_inotify(struct userdata *u) {
827 if (u->inotify_fd >= 0)
830 if ((u->inotify_fd = inotify_init1(IN_CLOEXEC|IN_NONBLOCK)) < 0) {
831 pa_log("inotify_init1() failed: %s", pa_cstrerror(errno));
835 r = inotify_add_watch(u->inotify_fd, "/dev/snd", IN_ATTRIB|IN_CLOSE_WRITE|IN_DELETE_SELF|IN_MOVE_SELF);
838 int saved_errno = errno;
840 pa_close(u->inotify_fd);
843 if (saved_errno == ENOENT) {
844 pa_log_debug("/dev/snd/ is apparently not existing yet, retrying to create inotify watch later.");
848 if (saved_errno == ENOSPC) {
849 pa_log("You apparently ran out of inotify watches, probably because Tracker/Beagle took them all away. "
850 "I wished people would do their homework first and fix inotify before using it for watching whole "
851 "directory trees which is something the current inotify is certainly not useful for. "
852 "Please make sure to drop the Tracker/Beagle guys a line complaining about their broken use of inotify.");
856 pa_log("inotify_add_watch() failed: %s", pa_cstrerror(saved_errno));
860 pa_assert_se(u->inotify_io = u->core->mainloop->io_new(u->core->mainloop, u->inotify_fd, PA_IO_EVENT_INPUT, inotify_cb, u));
865 int pa__init(pa_module *m) {
866 struct userdata *u = NULL;
868 struct udev_enumerate *enumerate = NULL;
869 struct udev_list_entry *item = NULL, *first = NULL;
871 bool use_tsched = true, fixed_latency_range = false, ignore_dB = false, deferred_volume = m->core->deferred_volume;
873 bool avoid_resampling;
877 if (!(ma = pa_modargs_new(m->argument, valid_modargs))) {
878 pa_log("Failed to parse module arguments");
882 m->userdata = u = pa_xnew0(struct userdata, 1);
884 u->devices = pa_hashmap_new_full(pa_idxset_string_hash_func, pa_idxset_string_compare_func, NULL, (pa_free_cb_t) device_free);
887 if (pa_modargs_get_value_boolean(ma, "tsched", &use_tsched) < 0) {
888 pa_log("Failed to parse tsched= argument.");
891 u->use_tsched = use_tsched;
893 if (pa_modargs_get_value(ma, "tsched_buffer_size", NULL)) {
894 if (pa_modargs_get_value_u32(ma, "tsched_buffer_size", &u->tsched_buffer_size) < 0) {
895 pa_log("Failed to parse tsched_buffer_size= argument.");
899 u->tsched_buffer_size_valid = true;
902 if (pa_modargs_get_value_boolean(ma, "fixed_latency_range", &fixed_latency_range) < 0) {
903 pa_log("Failed to parse fixed_latency_range= argument.");
906 u->fixed_latency_range = fixed_latency_range;
908 if (pa_modargs_get_value_boolean(ma, "ignore_dB", &ignore_dB) < 0) {
909 pa_log("Failed to parse ignore_dB= argument.");
912 u->ignore_dB = ignore_dB;
914 if (pa_modargs_get_value_boolean(ma, "deferred_volume", &deferred_volume) < 0) {
915 pa_log("Failed to parse deferred_volume= argument.");
918 u->deferred_volume = deferred_volume;
920 if (pa_modargs_get_value_boolean(ma, "use_ucm", &use_ucm) < 0) {
921 pa_log("Failed to parse use_ucm= argument.");
924 u->use_ucm = use_ucm;
926 avoid_resampling = m->core->avoid_resampling;
927 if (pa_modargs_get_value_boolean(ma, "avoid_resampling", &avoid_resampling) < 0) {
928 pa_log("Failed to parse avoid_resampling= argument.");
931 u->avoid_resampling = avoid_resampling;
934 u->use_tizen_hal = pa_xstrdup(pa_modargs_get_value(ma, "use_tizen_hal", "empty"));
935 u->fixed_latency_msec = DEFAULT_FRAGMENT_MSEC;
936 if (pa_modargs_get_value_u32(ma, "fixed_latency_msec", &u->fixed_latency_msec) < 0)
937 pa_log("Failed to get fixed_latency_msec args");
940 if (!(u->udev = udev_new())) {
941 pa_log("Failed to initialize udev library.");
945 if (setup_inotify(u) < 0)
948 if (!(u->monitor = udev_monitor_new_from_netlink(u->udev, "udev"))) {
949 pa_log("Failed to initialize monitor.");
953 if (udev_monitor_filter_add_match_subsystem_devtype(u->monitor, "sound", NULL) < 0) {
954 pa_log("Failed to subscribe to sound devices.");
958 #ifndef TIZEN_TV_PROD
959 if (udev_monitor_filter_add_match_subsystem_devtype(u->monitor, "extcon", NULL) < 0) {
960 pa_log("Failed to subscribe to extcon devices.");
967 if (udev_monitor_enable_receiving(u->monitor) < 0) {
968 pa_log("Failed to enable monitor: %s", pa_cstrerror(errno));
970 pa_log_info("Most likely your kernel is simply too old and "
971 "allows only privileged processes to listen to device events. "
972 "Please upgrade your kernel to at least 2.6.30.");
976 if ((fd = udev_monitor_get_fd(u->monitor)) < 0) {
977 pa_log("Failed to get udev monitor fd.");
981 pa_assert_se(u->udev_io = u->core->mainloop->io_new(u->core->mainloop, fd, PA_IO_EVENT_INPUT, monitor_cb, u));
983 if (!(enumerate = udev_enumerate_new(u->udev))) {
984 pa_log("Failed to initialize udev enumerator.");
988 if (udev_enumerate_add_match_subsystem(enumerate, "sound") < 0) {
989 pa_log("Failed to match to subsystem.");
993 if (udev_enumerate_scan_devices(enumerate) < 0) {
994 pa_log("Failed to scan for devices.");
998 first = udev_enumerate_get_list_entry(enumerate);
999 udev_list_entry_foreach(item, first)
1000 process_path(u, udev_list_entry_get_name(item));
1002 udev_enumerate_unref(enumerate);
1004 pa_log_info("Found %u cards.", pa_hashmap_size(u->devices));
1006 pa_modargs_free(ma);
1013 udev_enumerate_unref(enumerate);
1016 pa_modargs_free(ma);
1023 void pa__done(pa_module *m) {
1028 if (!(u = m->userdata))
1032 m->core->mainloop->io_free(u->udev_io);
1035 udev_monitor_unref(u->monitor);
1038 udev_unref(u->udev);
1041 m->core->mainloop->io_free(u->inotify_io);
1043 if (u->inotify_fd >= 0)
1044 pa_close(u->inotify_fd);
1047 pa_hashmap_free(u->devices);
1050 pa_xfree(u->use_tizen_hal);