2 This file is part of PulseAudio.
4 Copyright 2008 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 published
8 by the Free Software Foundation; either version 2.1 of the License,
9 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 License
17 along with PulseAudio; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
29 #include <sys/types.h>
34 #include <pulse/xmalloc.h>
35 #include <pulse/volume.h>
36 #include <pulse/timeval.h>
37 #include <pulse/util.h>
39 #include <pulsecore/core-error.h>
40 #include <pulsecore/module.h>
41 #include <pulsecore/core-util.h>
42 #include <pulsecore/modargs.h>
43 #include <pulsecore/log.h>
44 #include <pulsecore/core-subscribe.h>
45 #include <pulsecore/sink-input.h>
46 #include <pulsecore/source-output.h>
47 #include <pulsecore/namereg.h>
48 #include <pulsecore/protocol-native.h>
49 #include <pulsecore/pstream.h>
50 #include <pulsecore/pstream-util.h>
51 #include <pulsecore/database.h>
53 #include "module-stream-restore-symdef.h"
55 PA_MODULE_AUTHOR("Lennart Poettering");
56 PA_MODULE_DESCRIPTION("Automatically restore the volume/mute/device state of streams");
57 PA_MODULE_VERSION(PACKAGE_VERSION
);
58 PA_MODULE_LOAD_ONCE(TRUE
);
60 "restore_device=<Save/restore sinks/sources?> "
61 "restore_volume=<Save/restore volumes?> "
62 "restore_muted=<Save/restore muted states?>");
64 #define SAVE_INTERVAL 10
65 #define IDENTIFICATION_PROPERTY "module-stream-restore.id"
67 static const char* const valid_modargs
[] = {
77 pa_subscription
*subscription
;
79 *sink_input_new_hook_slot
,
80 *sink_input_fixate_hook_slot
,
81 *source_output_new_hook_slot
,
82 *connection_unlink_hook_slot
;
83 pa_time_event
*save_time_event
;
84 pa_database
* database
;
86 pa_bool_t restore_device
:1;
87 pa_bool_t restore_volume
:1;
88 pa_bool_t restore_muted
:1;
90 pa_native_protocol
*protocol
;
91 pa_idxset
*subscribed
;
94 #define ENTRY_VERSION 2
98 pa_bool_t muted_valid
:1, volume_valid
:1, device_valid
:1;
100 pa_channel_map channel_map
;
102 char device
[PA_NAME_MAX
];
110 SUBCOMMAND_SUBSCRIBE
,
114 static void save_time_callback(pa_mainloop_api
*a
, pa_time_event
* e
, const struct timeval
*tv
, void *userdata
) {
115 struct userdata
*u
= userdata
;
122 pa_assert(e
== u
->save_time_event
);
123 u
->core
->mainloop
->time_free(u
->save_time_event
);
124 u
->save_time_event
= NULL
;
126 pa_database_sync(u
->database
);
127 pa_log_info("Synced.");
130 static char *get_name(pa_proplist
*p
, const char *prefix
) {
137 if ((r
= pa_proplist_gets(p
, IDENTIFICATION_PROPERTY
)))
138 return pa_xstrdup(r
);
140 if ((r
= pa_proplist_gets(p
, PA_PROP_MEDIA_ROLE
)))
141 t
= pa_sprintf_malloc("%s-by-media-role:%s", prefix
, r
);
142 else if ((r
= pa_proplist_gets(p
, PA_PROP_APPLICATION_ID
)))
143 t
= pa_sprintf_malloc("%s-by-application-id:%s", prefix
, r
);
144 else if ((r
= pa_proplist_gets(p
, PA_PROP_APPLICATION_NAME
)))
145 t
= pa_sprintf_malloc("%s-by-application-name:%s", prefix
, r
);
146 else if ((r
= pa_proplist_gets(p
, PA_PROP_MEDIA_NAME
)))
147 t
= pa_sprintf_malloc("%s-by-media-name:%s", prefix
, r
);
149 t
= pa_sprintf_malloc("%s-fallback:%s", prefix
, r
);
151 pa_proplist_sets(p
, IDENTIFICATION_PROPERTY
, t
);
155 static struct entry
* read_entry(struct userdata
*u
, const char *name
) {
162 key
.data
= (char*) name
;
163 key
.size
= strlen(name
);
167 if (!pa_database_get(u
->database
, &key
, &data
))
170 if (data
.size
!= sizeof(struct entry
)) {
171 /* This is probably just a database upgrade, hence let's not
172 * consider this more than a debug message */
173 pa_log_debug("Database contains entry for stream %s of wrong size %lu != %lu. Probably due to uprade, ignoring.", name
, (unsigned long) data
.size
, (unsigned long) sizeof(struct entry
));
177 e
= (struct entry
*) data
.data
;
179 if (e
->version
!= ENTRY_VERSION
) {
180 pa_log_debug("Version of database entry for stream %s doesn't match our version. Probably due to upgrade, ignoring.", name
);
184 if (!memchr(e
->device
, 0, sizeof(e
->device
))) {
185 pa_log_warn("Database contains entry for stream %s with missing NUL byte in device name", name
);
189 if (e
->device_valid
&& !pa_namereg_is_valid_name(e
->device
)) {
190 pa_log_warn("Invalid device name stored in database for stream %s", name
);
194 if (e
->volume_valid
&& !pa_channel_map_valid(&e
->channel_map
)) {
195 pa_log_warn("Invalid channel map stored in database for stream %s", name
);
199 if (e
->volume_valid
&& (!pa_cvolume_valid(&e
->volume
) || !pa_cvolume_compatible_with_channel_map(&e
->volume
, &e
->channel_map
))) {
200 pa_log_warn("Invalid volume stored in database for stream %s", name
);
208 pa_datum_free(&data
);
212 static void trigger_save(struct userdata
*u
) {
214 pa_native_connection
*c
;
217 for (c
= pa_idxset_first(u
->subscribed
, &idx
); c
; c
= pa_idxset_next(u
->subscribed
, &idx
)) {
220 t
= pa_tagstruct_new(NULL
, 0);
221 pa_tagstruct_putu32(t
, PA_COMMAND_EXTENSION
);
222 pa_tagstruct_putu32(t
, 0);
223 pa_tagstruct_putu32(t
, u
->module
->index
);
224 pa_tagstruct_puts(t
, u
->module
->name
);
225 pa_tagstruct_putu32(t
, SUBCOMMAND_EVENT
);
227 pa_pstream_send_tagstruct(pa_native_connection_get_pstream(c
), t
);
230 if (u
->save_time_event
)
233 pa_gettimeofday(&tv
);
234 tv
.tv_sec
+= SAVE_INTERVAL
;
235 u
->save_time_event
= u
->core
->mainloop
->time_new(u
->core
->mainloop
, &tv
, save_time_callback
, u
);
238 static pa_bool_t
entries_equal(const struct entry
*a
, const struct entry
*b
) {
244 if (a
->device_valid
!= b
->device_valid
||
245 (a
->device_valid
&& strncmp(a
->device
, b
->device
, sizeof(a
->device
))))
248 if (a
->muted_valid
!= b
->muted_valid
||
249 (a
->muted_valid
&& (a
->muted
!= b
->muted
)))
253 if (a
->volume_valid
!= b
->volume_valid
||
254 (a
->volume_valid
&& !pa_cvolume_equal(pa_cvolume_remap(&t
, &b
->channel_map
, &a
->channel_map
), &a
->volume
)))
260 static void subscribe_callback(pa_core
*c
, pa_subscription_event_type_t t
, uint32_t idx
, void *userdata
) {
261 struct userdata
*u
= userdata
;
262 struct entry entry
, *old
;
269 if (t
!= (PA_SUBSCRIPTION_EVENT_SINK_INPUT
|PA_SUBSCRIPTION_EVENT_NEW
) &&
270 t
!= (PA_SUBSCRIPTION_EVENT_SINK_INPUT
|PA_SUBSCRIPTION_EVENT_CHANGE
) &&
271 t
!= (PA_SUBSCRIPTION_EVENT_SOURCE_OUTPUT
|PA_SUBSCRIPTION_EVENT_NEW
) &&
272 t
!= (PA_SUBSCRIPTION_EVENT_SOURCE_OUTPUT
|PA_SUBSCRIPTION_EVENT_CHANGE
))
276 entry
.version
= ENTRY_VERSION
;
278 if ((t
& PA_SUBSCRIPTION_EVENT_FACILITY_MASK
) == PA_SUBSCRIPTION_EVENT_SINK_INPUT
) {
279 pa_sink_input
*sink_input
;
281 if (!(sink_input
= pa_idxset_get_by_index(c
->sink_inputs
, idx
)))
284 if (!(name
= get_name(sink_input
->proplist
, "sink-input")))
287 if ((old
= read_entry(u
, name
)))
290 if (sink_input
->save_volume
) {
291 entry
.channel_map
= sink_input
->channel_map
;
292 pa_sink_input_get_volume(sink_input
, &entry
.volume
, FALSE
);
293 entry
.volume_valid
= TRUE
;
296 if (sink_input
->save_muted
) {
297 entry
.muted
= pa_sink_input_get_mute(sink_input
);
298 entry
.muted_valid
= TRUE
;
301 if (sink_input
->save_sink
) {
302 pa_strlcpy(entry
.device
, sink_input
->sink
->name
, sizeof(entry
.device
));
303 entry
.device_valid
= TRUE
;
307 pa_source_output
*source_output
;
309 pa_assert((t
& PA_SUBSCRIPTION_EVENT_FACILITY_MASK
) == PA_SUBSCRIPTION_EVENT_SOURCE_OUTPUT
);
311 if (!(source_output
= pa_idxset_get_by_index(c
->source_outputs
, idx
)))
314 if (!(name
= get_name(source_output
->proplist
, "source-output")))
317 if ((old
= read_entry(u
, name
)))
320 if (source_output
->save_source
) {
321 pa_strlcpy(entry
.device
, source_output
->source
->name
, sizeof(entry
.device
));
322 entry
.device_valid
= source_output
->save_source
;
328 if (entries_equal(old
, &entry
)) {
338 key
.size
= strlen(name
);
341 data
.size
= sizeof(entry
);
343 pa_log_info("Storing volume/mute/device for stream %s.", name
);
345 pa_database_set(u
->database
, &key
, &data
, TRUE
);
352 static pa_hook_result_t
sink_input_new_hook_callback(pa_core
*c
, pa_sink_input_new_data
*new_data
, struct userdata
*u
) {
358 if (!u
->restore_device
)
361 if (!(name
= get_name(new_data
->proplist
, "sink-input")))
364 if ((e
= read_entry(u
, name
))) {
367 if (e
->device_valid
) {
369 if ((s
= pa_namereg_get(c
, e
->device
, PA_NAMEREG_SINK
))) {
370 if (!new_data
->sink
) {
371 pa_log_info("Restoring device for stream %s.", name
);
373 new_data
->save_sink
= TRUE
;
375 pa_log_info("Not restore device for stream %s, because already set.", name
);
387 static pa_hook_result_t
sink_input_fixate_hook_callback(pa_core
*c
, pa_sink_input_new_data
*new_data
, struct userdata
*u
) {
393 if (!u
->restore_volume
&& !u
->restore_muted
)
396 if (!(name
= get_name(new_data
->proplist
, "sink-input")))
399 if ((e
= read_entry(u
, name
))) {
401 if (u
->restore_volume
&& e
->volume_valid
) {
403 if (!new_data
->volume_is_set
) {
406 pa_log_info("Restoring volume for sink input %s.", name
);
408 pa_cvolume_remap(&v
, &e
->channel_map
, &new_data
->channel_map
);
409 pa_sink_input_new_data_set_volume(new_data
, &v
);
411 new_data
->volume_is_absolute
= FALSE
;
412 new_data
->save_volume
= FALSE
;
414 pa_log_debug("Not restoring volume for sink input %s, because already set.", name
);
417 if (u
->restore_muted
&& e
->muted_valid
) {
419 if (!new_data
->muted_is_set
) {
420 pa_log_info("Restoring mute state for sink input %s.", name
);
421 pa_sink_input_new_data_set_muted(new_data
, e
->muted
);
422 new_data
->save_muted
= TRUE
;
424 pa_log_debug("Not restoring mute state for sink input %s, because already set.", name
);
435 static pa_hook_result_t
source_output_new_hook_callback(pa_core
*c
, pa_source_output_new_data
*new_data
, struct userdata
*u
) {
441 if (!u
->restore_device
)
444 if (new_data
->direct_on_input
)
447 if (!(name
= get_name(new_data
->proplist
, "source-output")))
450 if ((e
= read_entry(u
, name
))) {
453 if (e
->device_valid
) {
454 if ((s
= pa_namereg_get(c
, e
->device
, PA_NAMEREG_SOURCE
))) {
455 if (!new_data
->source
) {
456 pa_log_info("Restoring device for stream %s.", name
);
457 new_data
->source
= s
;
458 new_data
->save_source
= TRUE
;
460 pa_log_info("Not restoring device for stream %s, because already set", name
);
472 #define EXT_VERSION 1
474 static void apply_entry(struct userdata
*u
, const char *name
, struct entry
*e
) {
476 pa_source_output
*so
;
483 for (si
= pa_idxset_first(u
->core
->sink_inputs
, &idx
); si
; si
= pa_idxset_next(u
->core
->sink_inputs
, &idx
)) {
487 if (!(n
= get_name(si
->proplist
, "sink-input")))
490 if (!pa_streq(name
, n
)) {
496 if (u
->restore_volume
&& e
->volume_valid
) {
500 pa_log_info("Restoring volume for sink input %s.", name
);
501 pa_sink_input_set_volume(si
, pa_cvolume_remap(&v
, &e
->channel_map
, &si
->channel_map
), FALSE
, FALSE
);
504 if (u
->restore_muted
&& e
->muted_valid
) {
505 pa_log_info("Restoring mute state for sink input %s.", name
);
506 pa_sink_input_set_mute(si
, e
->muted
, TRUE
);
509 if (u
->restore_device
&&
511 (s
= pa_namereg_get(u
->core
, e
->device
, PA_NAMEREG_SINK
))) {
513 pa_log_info("Restoring device for stream %s.", name
);
514 pa_sink_input_move_to(si
, s
, TRUE
);
518 for (so
= pa_idxset_first(u
->core
->source_outputs
, &idx
); so
; so
= pa_idxset_next(u
->core
->source_outputs
, &idx
)) {
522 if (!(n
= get_name(so
->proplist
, "source-output")))
525 if (!pa_streq(name
, n
)) {
531 if (u
->restore_device
&&
533 (s
= pa_namereg_get(u
->core
, e
->device
, PA_NAMEREG_SOURCE
))) {
535 pa_log_info("Restoring device for stream %s.", name
);
536 pa_source_output_move_to(so
, s
, TRUE
);
542 static void dump_database(struct userdata
*u
) {
546 done
= !pa_database_first(u
->database
, &key
, NULL
);
553 done
= !pa_database_next(u
->database
, &key
, &next_key
, NULL
);
555 name
= pa_xstrndup(key
.data
, key
.size
);
558 if ((e
= read_entry(u
, name
))) {
560 pa_log("name=%s", name
);
561 pa_log("device=%s %s", e
->device
, pa_yes_no(e
->device_valid
));
562 pa_log("channel_map=%s", pa_channel_map_snprint(t
, sizeof(t
), &e
->channel_map
));
563 pa_log("volume=%s %s", pa_cvolume_snprint(t
, sizeof(t
), &e
->volume
), pa_yes_no(e
->volume_valid
));
564 pa_log("mute=%s %s", pa_yes_no(e
->muted
), pa_yes_no(e
->volume_valid
));
575 static int extension_cb(pa_native_protocol
*p
, pa_module
*m
, pa_native_connection
*c
, uint32_t tag
, pa_tagstruct
*t
) {
578 pa_tagstruct
*reply
= NULL
;
587 if (pa_tagstruct_getu32(t
, &command
) < 0)
590 reply
= pa_tagstruct_new(NULL
, 0);
591 pa_tagstruct_putu32(reply
, PA_COMMAND_REPLY
);
592 pa_tagstruct_putu32(reply
, tag
);
595 case SUBCOMMAND_TEST
: {
596 if (!pa_tagstruct_eof(t
))
599 pa_tagstruct_putu32(reply
, EXT_VERSION
);
603 case SUBCOMMAND_READ
: {
607 if (!pa_tagstruct_eof(t
))
610 done
= !pa_database_first(u
->database
, &key
, NULL
);
617 done
= !pa_database_next(u
->database
, &key
, &next_key
, NULL
);
619 name
= pa_xstrndup(key
.data
, key
.size
);
622 if ((e
= read_entry(u
, name
))) {
626 pa_tagstruct_puts(reply
, name
);
627 pa_tagstruct_put_channel_map(reply
, e
->volume_valid
? &e
->channel_map
: pa_channel_map_init(&cm
));
628 pa_tagstruct_put_cvolume(reply
, e
->volume_valid
? &e
->volume
: pa_cvolume_init(&r
));
629 pa_tagstruct_puts(reply
, e
->device_valid
? e
->device
: NULL
);
630 pa_tagstruct_put_boolean(reply
, e
->muted_valid
? e
->muted
: FALSE
);
643 case SUBCOMMAND_WRITE
: {
645 pa_bool_t apply_immediately
= FALSE
;
647 if (pa_tagstruct_getu32(t
, &mode
) < 0 ||
648 pa_tagstruct_get_boolean(t
, &apply_immediately
) < 0)
651 if (mode
!= PA_UPDATE_MERGE
&&
652 mode
!= PA_UPDATE_REPLACE
&&
653 mode
!= PA_UPDATE_SET
)
656 if (mode
== PA_UPDATE_SET
)
657 pa_database_clear(u
->database
);
659 while (!pa_tagstruct_eof(t
)) {
660 const char *name
, *device
;
666 entry
.version
= ENTRY_VERSION
;
668 if (pa_tagstruct_gets(t
, &name
) < 0 ||
669 pa_tagstruct_get_channel_map(t
, &entry
.channel_map
) ||
670 pa_tagstruct_get_cvolume(t
, &entry
.volume
) < 0 ||
671 pa_tagstruct_gets(t
, &device
) < 0 ||
672 pa_tagstruct_get_boolean(t
, &muted
) < 0)
678 entry
.volume_valid
= entry
.volume
.channels
> 0;
680 if (entry
.volume_valid
)
681 if (!pa_cvolume_compatible_with_channel_map(&entry
.volume
, &entry
.channel_map
))
685 entry
.muted_valid
= TRUE
;
688 pa_strlcpy(entry
.device
, device
, sizeof(entry
.device
));
689 entry
.device_valid
= !!entry
.device
[0];
691 if (entry
.device_valid
&&
692 !pa_namereg_is_valid_name(entry
.device
))
695 key
.data
= (char*) name
;
696 key
.size
= strlen(name
);
699 data
.size
= sizeof(entry
);
701 if (pa_database_set(u
->database
, &key
, &data
, mode
== PA_UPDATE_REPLACE
) == 0)
702 if (apply_immediately
)
703 apply_entry(u
, name
, &entry
);
711 case SUBCOMMAND_DELETE
:
713 while (!pa_tagstruct_eof(t
)) {
717 if (pa_tagstruct_gets(t
, &name
) < 0)
720 key
.data
= (char*) name
;
721 key
.size
= strlen(name
);
723 pa_database_unset(u
->database
, &key
);
730 case SUBCOMMAND_SUBSCRIBE
: {
734 if (pa_tagstruct_get_boolean(t
, &enabled
) < 0 ||
735 !pa_tagstruct_eof(t
))
739 pa_idxset_put(u
->subscribed
, c
, NULL
);
741 pa_idxset_remove_by_data(u
->subscribed
, c
, NULL
);
750 pa_pstream_send_tagstruct(pa_native_connection_get_pstream(c
), reply
);
756 pa_tagstruct_free(reply
);
761 static pa_hook_result_t
connection_unlink_hook_cb(pa_native_protocol
*p
, pa_native_connection
*c
, struct userdata
*u
) {
766 pa_idxset_remove_by_data(u
->subscribed
, c
, NULL
);
770 int pa__init(pa_module
*m
) {
771 pa_modargs
*ma
= NULL
;
775 pa_source_output
*so
;
777 pa_bool_t restore_device
= TRUE
, restore_volume
= TRUE
, restore_muted
= TRUE
;
781 if (!(ma
= pa_modargs_new(m
->argument
, valid_modargs
))) {
782 pa_log("Failed to parse module arguments");
786 if (pa_modargs_get_value_boolean(ma
, "restore_device", &restore_device
) < 0 ||
787 pa_modargs_get_value_boolean(ma
, "restore_volume", &restore_volume
) < 0 ||
788 pa_modargs_get_value_boolean(ma
, "restore_muted", &restore_muted
) < 0) {
789 pa_log("restore_device=, restore_volume= and restore_muted= expect boolean arguments");
793 if (!restore_muted
&& !restore_volume
&& !restore_device
)
794 pa_log_warn("Neither restoring volume, nor restoring muted, nor restoring device enabled!");
796 m
->userdata
= u
= pa_xnew(struct userdata
, 1);
799 u
->save_time_event
= NULL
;
800 u
->restore_device
= restore_device
;
801 u
->restore_volume
= restore_volume
;
802 u
->restore_muted
= restore_muted
;
804 u
->subscribed
= pa_idxset_new(pa_idxset_trivial_hash_func
, pa_idxset_trivial_compare_func
);
806 u
->protocol
= pa_native_protocol_get(m
->core
);
807 pa_native_protocol_install_ext(u
->protocol
, m
, extension_cb
);
809 u
->connection_unlink_hook_slot
= pa_hook_connect(&pa_native_protocol_hooks(u
->protocol
)[PA_NATIVE_HOOK_CONNECTION_UNLINK
], PA_HOOK_NORMAL
, (pa_hook_cb_t
) connection_unlink_hook_cb
, u
);
811 u
->subscription
= pa_subscription_new(m
->core
, PA_SUBSCRIPTION_MASK_SINK_INPUT
|PA_SUBSCRIPTION_MASK_SOURCE_OUTPUT
, subscribe_callback
, u
);
813 if (restore_device
) {
814 u
->sink_input_new_hook_slot
= pa_hook_connect(&m
->core
->hooks
[PA_CORE_HOOK_SINK_INPUT_NEW
], PA_HOOK_EARLY
, (pa_hook_cb_t
) sink_input_new_hook_callback
, u
);
815 u
->source_output_new_hook_slot
= pa_hook_connect(&m
->core
->hooks
[PA_CORE_HOOK_SOURCE_OUTPUT_NEW
], PA_HOOK_EARLY
, (pa_hook_cb_t
) source_output_new_hook_callback
, u
);
818 if (restore_volume
|| restore_muted
)
819 u
->sink_input_fixate_hook_slot
= pa_hook_connect(&m
->core
->hooks
[PA_CORE_HOOK_SINK_INPUT_FIXATE
], PA_HOOK_EARLY
, (pa_hook_cb_t
) sink_input_fixate_hook_callback
, u
);
822 fname
= pa_state_path("stream-volumes", TRUE
);
827 if (!(u
->database
= pa_database_open(fname
, TRUE
))) {
828 pa_log("Failed to open volume database '%s': %s", fname
, pa_cstrerror(errno
));
833 pa_log_info("Sucessfully opened database file '%s'.", fname
);
836 for (si
= pa_idxset_first(m
->core
->sink_inputs
, &idx
); si
; si
= pa_idxset_next(m
->core
->sink_inputs
, &idx
))
837 subscribe_callback(m
->core
, PA_SUBSCRIPTION_EVENT_SINK_INPUT
|PA_SUBSCRIPTION_EVENT_NEW
, si
->index
, u
);
839 for (so
= pa_idxset_first(m
->core
->source_outputs
, &idx
); so
; so
= pa_idxset_next(m
->core
->source_outputs
, &idx
))
840 subscribe_callback(m
->core
, PA_SUBSCRIPTION_EVENT_SOURCE_OUTPUT
|PA_SUBSCRIPTION_EVENT_NEW
, so
->index
, u
);
854 void pa__done(pa_module
*m
) {
859 if (!(u
= m
->userdata
))
863 pa_subscription_free(u
->subscription
);
865 if (u
->sink_input_new_hook_slot
)
866 pa_hook_slot_free(u
->sink_input_new_hook_slot
);
867 if (u
->sink_input_fixate_hook_slot
)
868 pa_hook_slot_free(u
->sink_input_fixate_hook_slot
);
869 if (u
->source_output_new_hook_slot
)
870 pa_hook_slot_free(u
->source_output_new_hook_slot
);
872 if (u
->connection_unlink_hook_slot
)
873 pa_hook_slot_free(u
->connection_unlink_hook_slot
);
875 if (u
->save_time_event
)
876 u
->core
->mainloop
->time_free(u
->save_time_event
);
879 pa_database_close(u
->database
);
882 pa_native_protocol_remove_ext(u
->protocol
, m
);
883 pa_native_protocol_unref(u
->protocol
);
887 pa_idxset_free(u
->subscribed
, NULL
, NULL
);