2 This file is part of PulseAudio.
4 Copyright 2009 Tanu Kaskinen
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
28 #include <dbus/dbus.h>
30 #include <pulse/utf8.h>
31 #include <pulse/xmalloc.h>
33 #include <pulsecore/core-util.h>
34 #include <pulsecore/dbus-util.h>
35 #include <pulsecore/macro.h>
36 #include <pulsecore/namereg.h>
37 #include <pulsecore/protocol-dbus.h>
38 #include <pulsecore/socket-util.h>
39 #include <pulsecore/strbuf.h>
41 #include "iface-card.h"
42 #include "iface-client.h"
43 #include "iface-device.h"
44 #include "iface-memstats.h"
45 #include "iface-module.h"
46 #include "iface-sample.h"
47 #include "iface-stream.h"
49 #include "iface-core.h"
51 #define OBJECT_PATH "/org/pulseaudio/core1"
53 #define INTERFACE_REVISION 0
57 static void handle_get_interface_revision(DBusConnection
*conn
, DBusMessage
*msg
, void *userdata
);
58 static void handle_get_name(DBusConnection
*conn
, DBusMessage
*msg
, void *userdata
);
59 static void handle_get_version(DBusConnection
*conn
, DBusMessage
*msg
, void *userdata
);
60 static void handle_get_is_local(DBusConnection
*conn
, DBusMessage
*msg
, void *userdata
);
61 static void handle_get_username(DBusConnection
*conn
, DBusMessage
*msg
, void *userdata
);
62 static void handle_get_hostname(DBusConnection
*conn
, DBusMessage
*msg
, void *userdata
);
63 static void handle_get_default_channels(DBusConnection
*conn
, DBusMessage
*msg
, void *userdata
);
64 static void handle_set_default_channels(DBusConnection
*conn
, DBusMessage
*msg
, void *userdata
);
65 static void handle_get_default_sample_format(DBusConnection
*conn
, DBusMessage
*msg
, void *userdata
);
66 static void handle_set_default_sample_format(DBusConnection
*conn
, DBusMessage
*msg
, void *userdata
);
67 static void handle_get_default_sample_rate(DBusConnection
*conn
, DBusMessage
*msg
, void *userdata
);
68 static void handle_set_default_sample_rate(DBusConnection
*conn
, DBusMessage
*msg
, void *userdata
);
69 static void handle_get_cards(DBusConnection
*conn
, DBusMessage
*msg
, void *userdata
);
70 static void handle_get_sinks(DBusConnection
*conn
, DBusMessage
*msg
, void *userdata
);
71 static void handle_get_fallback_sink(DBusConnection
*conn
, DBusMessage
*msg
, void *userdata
);
72 static void handle_set_fallback_sink(DBusConnection
*conn
, DBusMessage
*msg
, void *userdata
);
73 static void handle_get_sources(DBusConnection
*conn
, DBusMessage
*msg
, void *userdata
);
74 static void handle_get_fallback_source(DBusConnection
*conn
, DBusMessage
*msg
, void *userdata
);
75 static void handle_set_fallback_source(DBusConnection
*conn
, DBusMessage
*msg
, void *userdata
);
76 static void handle_get_playback_streams(DBusConnection
*conn
, DBusMessage
*msg
, void *userdata
);
77 static void handle_get_record_streams(DBusConnection
*conn
, DBusMessage
*msg
, void *userdata
);
78 static void handle_get_samples(DBusConnection
*conn
, DBusMessage
*msg
, void *userdata
);
79 static void handle_get_modules(DBusConnection
*conn
, DBusMessage
*msg
, void *userdata
);
80 static void handle_get_clients(DBusConnection
*conn
, DBusMessage
*msg
, void *userdata
);
81 static void handle_get_my_client(DBusConnection
*conn
, DBusMessage
*msg
, void *userdata
);
82 static void handle_get_extensions(DBusConnection
*conn
, DBusMessage
*msg
, void *userdata
);
84 static void handle_get_all(DBusConnection
*conn
, DBusMessage
*msg
, void *userdata
);
86 static void handle_get_card_by_name(DBusConnection
*conn
, DBusMessage
*msg
, void *userdata
);
87 static void handle_get_sink_by_name(DBusConnection
*conn
, DBusMessage
*msg
, void *userdata
);
88 static void handle_get_source_by_name(DBusConnection
*conn
, DBusMessage
*msg
, void *userdata
);
89 static void handle_get_sample_by_name(DBusConnection
*conn
, DBusMessage
*msg
, void *userdata
);
90 static void handle_upload_sample(DBusConnection
*conn
, DBusMessage
*msg
, void *userdata
);
91 static void handle_load_module(DBusConnection
*conn
, DBusMessage
*msg
, void *userdata
);
92 static void handle_exit(DBusConnection
*conn
, DBusMessage
*msg
, void *userdata
);
93 static void handle_listen_for_signal(DBusConnection
*conn
, DBusMessage
*msg
, void *userdata
);
94 static void handle_stop_listening_for_signal(DBusConnection
*conn
, DBusMessage
*msg
, void *userdata
);
96 struct pa_dbusiface_core
{
98 pa_subscription
*subscription
;
100 pa_dbus_protocol
*dbus_protocol
;
103 pa_hashmap
*sinks_by_index
;
104 pa_hashmap
*sinks_by_path
;
105 pa_hashmap
*sources_by_index
;
106 pa_hashmap
*sources_by_path
;
107 pa_hashmap
*playback_streams
;
108 pa_hashmap
*record_streams
;
113 pa_sink
*fallback_sink
;
114 pa_source
*fallback_source
;
116 pa_hook_slot
*extension_registered_slot
;
117 pa_hook_slot
*extension_unregistered_slot
;
119 pa_dbusiface_memstats
*memstats
;
122 enum property_handler_index
{
123 PROPERTY_HANDLER_INTERFACE_REVISION
,
124 PROPERTY_HANDLER_NAME
,
125 PROPERTY_HANDLER_VERSION
,
126 PROPERTY_HANDLER_IS_LOCAL
,
127 PROPERTY_HANDLER_USERNAME
,
128 PROPERTY_HANDLER_HOSTNAME
,
129 PROPERTY_HANDLER_DEFAULT_CHANNELS
,
130 PROPERTY_HANDLER_DEFAULT_SAMPLE_FORMAT
,
131 PROPERTY_HANDLER_DEFAULT_SAMPLE_RATE
,
132 PROPERTY_HANDLER_CARDS
,
133 PROPERTY_HANDLER_SINKS
,
134 PROPERTY_HANDLER_FALLBACK_SINK
,
135 PROPERTY_HANDLER_SOURCES
,
136 PROPERTY_HANDLER_FALLBACK_SOURCE
,
137 PROPERTY_HANDLER_PLAYBACK_STREAMS
,
138 PROPERTY_HANDLER_RECORD_STREAMS
,
139 PROPERTY_HANDLER_SAMPLES
,
140 PROPERTY_HANDLER_MODULES
,
141 PROPERTY_HANDLER_CLIENTS
,
142 PROPERTY_HANDLER_MY_CLIENT
,
143 PROPERTY_HANDLER_EXTENSIONS
,
147 static pa_dbus_property_handler property_handlers
[PROPERTY_HANDLER_MAX
] = {
148 [PROPERTY_HANDLER_INTERFACE_REVISION
] = { .property_name
= "InterfaceRevision", .type
= "u", .get_cb
= handle_get_interface_revision
, .set_cb
= NULL
},
149 [PROPERTY_HANDLER_NAME
] = { .property_name
= "Name", .type
= "s", .get_cb
= handle_get_name
, .set_cb
= NULL
},
150 [PROPERTY_HANDLER_VERSION
] = { .property_name
= "Version", .type
= "s", .get_cb
= handle_get_version
, .set_cb
= NULL
},
151 [PROPERTY_HANDLER_IS_LOCAL
] = { .property_name
= "IsLocal", .type
= "b", .get_cb
= handle_get_is_local
, .set_cb
= NULL
},
152 [PROPERTY_HANDLER_USERNAME
] = { .property_name
= "Username", .type
= "s", .get_cb
= handle_get_username
, .set_cb
= NULL
},
153 [PROPERTY_HANDLER_HOSTNAME
] = { .property_name
= "Hostname", .type
= "s", .get_cb
= handle_get_hostname
, .set_cb
= NULL
},
154 [PROPERTY_HANDLER_DEFAULT_CHANNELS
] = { .property_name
= "DefaultChannels", .type
= "au", .get_cb
= handle_get_default_channels
, .set_cb
= handle_set_default_channels
},
155 [PROPERTY_HANDLER_DEFAULT_SAMPLE_FORMAT
] = { .property_name
= "DefaultSampleFormat", .type
= "u", .get_cb
= handle_get_default_sample_format
, .set_cb
= handle_set_default_sample_format
},
156 [PROPERTY_HANDLER_DEFAULT_SAMPLE_RATE
] = { .property_name
= "DefaultSampleRate", .type
= "u", .get_cb
= handle_get_default_sample_rate
, .set_cb
= handle_set_default_sample_rate
},
157 [PROPERTY_HANDLER_CARDS
] = { .property_name
= "Cards", .type
= "ao", .get_cb
= handle_get_cards
, .set_cb
= NULL
},
158 [PROPERTY_HANDLER_SINKS
] = { .property_name
= "Sinks", .type
= "ao", .get_cb
= handle_get_sinks
, .set_cb
= NULL
},
159 [PROPERTY_HANDLER_FALLBACK_SINK
] = { .property_name
= "FallbackSink", .type
= "o", .get_cb
= handle_get_fallback_sink
, .set_cb
= handle_set_fallback_sink
},
160 [PROPERTY_HANDLER_SOURCES
] = { .property_name
= "Sources", .type
= "ao", .get_cb
= handle_get_sources
, .set_cb
= NULL
},
161 [PROPERTY_HANDLER_FALLBACK_SOURCE
] = { .property_name
= "FallbackSource", .type
= "o", .get_cb
= handle_get_fallback_source
, .set_cb
= handle_set_fallback_source
},
162 [PROPERTY_HANDLER_PLAYBACK_STREAMS
] = { .property_name
= "PlaybackStreams", .type
= "ao", .get_cb
= handle_get_playback_streams
, .set_cb
= NULL
},
163 [PROPERTY_HANDLER_RECORD_STREAMS
] = { .property_name
= "RecordStreams", .type
= "ao", .get_cb
= handle_get_record_streams
, .set_cb
= NULL
},
164 [PROPERTY_HANDLER_SAMPLES
] = { .property_name
= "Samples", .type
= "ao", .get_cb
= handle_get_samples
, .set_cb
= NULL
},
165 [PROPERTY_HANDLER_MODULES
] = { .property_name
= "Modules", .type
= "ao", .get_cb
= handle_get_modules
, .set_cb
= NULL
},
166 [PROPERTY_HANDLER_CLIENTS
] = { .property_name
= "Clients", .type
= "ao", .get_cb
= handle_get_clients
, .set_cb
= NULL
},
167 [PROPERTY_HANDLER_MY_CLIENT
] = { .property_name
= "MyClient", .type
= "o", .get_cb
= handle_get_my_client
, .set_cb
= NULL
},
168 [PROPERTY_HANDLER_EXTENSIONS
] = { .property_name
= "Extensions", .type
= "as", .get_cb
= handle_get_extensions
, .set_cb
= NULL
}
171 enum method_handler_index
{
172 METHOD_HANDLER_GET_CARD_BY_NAME
,
173 METHOD_HANDLER_GET_SINK_BY_NAME
,
174 METHOD_HANDLER_GET_SOURCE_BY_NAME
,
175 METHOD_HANDLER_GET_SAMPLE_BY_NAME
,
176 METHOD_HANDLER_UPLOAD_SAMPLE
,
177 METHOD_HANDLER_LOAD_MODULE
,
179 METHOD_HANDLER_LISTEN_FOR_SIGNAL
,
180 METHOD_HANDLER_STOP_LISTENING_FOR_SIGNAL
,
184 static pa_dbus_arg_info get_card_by_name_args
[] = { { "name", "s", "in" }, { "card", "o", "out" } };
185 static pa_dbus_arg_info get_sink_by_name_args
[] = { { "name", "s", "in" }, { "sink", "o", "out" } };
186 static pa_dbus_arg_info get_source_by_name_args
[] = { { "name", "s", "in" }, { "source", "o", "out" } };
187 static pa_dbus_arg_info get_sample_by_name_args
[] = { { "name", "s", "in" }, { "sample", "o", "out" } };
188 static pa_dbus_arg_info upload_sample_args
[] = { { "name", "s", "in" },
189 { "sample_format", "u", "in" },
190 { "sample_rate", "u", "in" },
191 { "channels", "au", "in" },
192 { "default_volume", "au", "in" },
193 { "property_list", "a{say}", "in" },
194 { "data", "ay", "in" },
195 { "sample", "o", "out" } };
196 static pa_dbus_arg_info load_module_args
[] = { { "name", "s", "in" }, { "arguments", "a{ss}", "in" }, { "module", "o", "out" } };
197 static pa_dbus_arg_info listen_for_signal_args
[] = { { "signal", "s", "in" }, { "objects", "ao", "in" } };
198 static pa_dbus_arg_info stop_listening_for_signal_args
[] = { { "signal", "s", "in" } };
200 static pa_dbus_method_handler method_handlers
[METHOD_HANDLER_MAX
] = {
201 [METHOD_HANDLER_GET_CARD_BY_NAME
] = {
202 .method_name
= "GetCardByName",
203 .arguments
= get_card_by_name_args
,
204 .n_arguments
= sizeof(get_card_by_name_args
) / sizeof(pa_dbus_arg_info
),
205 .receive_cb
= handle_get_card_by_name
},
206 [METHOD_HANDLER_GET_SINK_BY_NAME
] = {
207 .method_name
= "GetSinkByName",
208 .arguments
= get_sink_by_name_args
,
209 .n_arguments
= sizeof(get_sink_by_name_args
) / sizeof(pa_dbus_arg_info
),
210 .receive_cb
= handle_get_sink_by_name
},
211 [METHOD_HANDLER_GET_SOURCE_BY_NAME
] = {
212 .method_name
= "GetSourceByName",
213 .arguments
= get_source_by_name_args
,
214 .n_arguments
= sizeof(get_source_by_name_args
) / sizeof(pa_dbus_arg_info
),
215 .receive_cb
= handle_get_source_by_name
},
216 [METHOD_HANDLER_GET_SAMPLE_BY_NAME
] = {
217 .method_name
= "GetSampleByName",
218 .arguments
= get_sample_by_name_args
,
219 .n_arguments
= sizeof(get_sample_by_name_args
) / sizeof(pa_dbus_arg_info
),
220 .receive_cb
= handle_get_sample_by_name
},
221 [METHOD_HANDLER_UPLOAD_SAMPLE
] = {
222 .method_name
= "UploadSample",
223 .arguments
= upload_sample_args
,
224 .n_arguments
= sizeof(upload_sample_args
) / sizeof(pa_dbus_arg_info
),
225 .receive_cb
= handle_upload_sample
},
226 [METHOD_HANDLER_LOAD_MODULE
] = {
227 .method_name
= "LoadModule",
228 .arguments
= load_module_args
,
229 .n_arguments
= sizeof(load_module_args
) / sizeof(pa_dbus_arg_info
),
230 .receive_cb
= handle_load_module
},
231 [METHOD_HANDLER_EXIT
] = {
232 .method_name
= "Exit",
235 .receive_cb
= handle_exit
},
236 [METHOD_HANDLER_LISTEN_FOR_SIGNAL
] = {
237 .method_name
= "ListenForSignal",
238 .arguments
= listen_for_signal_args
,
239 .n_arguments
= sizeof(listen_for_signal_args
) / sizeof(pa_dbus_arg_info
),
240 .receive_cb
= handle_listen_for_signal
},
241 [METHOD_HANDLER_STOP_LISTENING_FOR_SIGNAL
] = {
242 .method_name
= "StopListeningForSignal",
243 .arguments
= stop_listening_for_signal_args
,
244 .n_arguments
= sizeof(stop_listening_for_signal_args
) / sizeof(pa_dbus_arg_info
),
245 .receive_cb
= handle_stop_listening_for_signal
}
253 SIGNAL_FALLBACK_SINK_UPDATED
,
255 SIGNAL_SOURCE_REMOVED
,
256 SIGNAL_FALLBACK_SOURCE_UPDATED
,
257 SIGNAL_NEW_PLAYBACK_STREAM
,
258 SIGNAL_PLAYBACK_STREAM_REMOVED
,
259 SIGNAL_NEW_RECORD_STREAM
,
260 SIGNAL_RECORD_STREAM_REMOVED
,
262 SIGNAL_SAMPLE_REMOVED
,
264 SIGNAL_MODULE_REMOVED
,
266 SIGNAL_CLIENT_REMOVED
,
267 SIGNAL_NEW_EXTENSION
,
268 SIGNAL_EXTENSION_REMOVED
,
272 static pa_dbus_arg_info new_card_args
[] = { { "card", "o", NULL
} };
273 static pa_dbus_arg_info card_removed_args
[] = { { "card", "o", NULL
} };
274 static pa_dbus_arg_info new_sink_args
[] = { { "sink", "o", NULL
} };
275 static pa_dbus_arg_info sink_removed_args
[] = { { "sink", "o", NULL
} };
276 static pa_dbus_arg_info fallback_sink_updated_args
[] = { { "sink", "o", NULL
} };
277 static pa_dbus_arg_info new_source_args
[] = { { "source", "o", NULL
} };
278 static pa_dbus_arg_info source_removed_args
[] = { { "source", "o", NULL
} };
279 static pa_dbus_arg_info fallback_source_updated_args
[] = { { "source", "o", NULL
} };
280 static pa_dbus_arg_info new_playback_stream_args
[] = { { "playback_stream", "o", NULL
} };
281 static pa_dbus_arg_info playback_stream_removed_args
[] = { { "playback_stream", "o", NULL
} };
282 static pa_dbus_arg_info new_record_stream_args
[] = { { "record_stream", "o", NULL
} };
283 static pa_dbus_arg_info record_stream_removed_args
[] = { { "record_stream", "o", NULL
} };
284 static pa_dbus_arg_info new_sample_args
[] = { { "sample", "o", NULL
} };
285 static pa_dbus_arg_info sample_removed_args
[] = { { "sample", "o", NULL
} };
286 static pa_dbus_arg_info new_module_args
[] = { { "module", "o", NULL
} };
287 static pa_dbus_arg_info module_removed_args
[] = { { "module", "o", NULL
} };
288 static pa_dbus_arg_info new_client_args
[] = { { "client", "o", NULL
} };
289 static pa_dbus_arg_info client_removed_args
[] = { { "client", "o", NULL
} };
290 static pa_dbus_arg_info new_extension_args
[] = { { "extension", "s", NULL
} };
291 static pa_dbus_arg_info extension_removed_args
[] = { { "extension", "s", NULL
} };
293 static pa_dbus_signal_info signals
[SIGNAL_MAX
] = {
294 [SIGNAL_NEW_CARD
] = { .name
= "NewCard", .arguments
= new_card_args
, .n_arguments
= 1 },
295 [SIGNAL_CARD_REMOVED
] = { .name
= "CardRemoved", .arguments
= card_removed_args
, .n_arguments
= 1 },
296 [SIGNAL_NEW_SINK
] = { .name
= "NewSink", .arguments
= new_sink_args
, .n_arguments
= 1 },
297 [SIGNAL_SINK_REMOVED
] = { .name
= "SinkRemoved", .arguments
= sink_removed_args
, .n_arguments
= 1 },
298 [SIGNAL_FALLBACK_SINK_UPDATED
] = { .name
= "FallbackSinkUpdated", .arguments
= fallback_sink_updated_args
, .n_arguments
= 1 },
299 [SIGNAL_NEW_SOURCE
] = { .name
= "NewSource", .arguments
= new_source_args
, .n_arguments
= 1 },
300 [SIGNAL_SOURCE_REMOVED
] = { .name
= "SourceRemoved", .arguments
= source_removed_args
, .n_arguments
= 1 },
301 [SIGNAL_FALLBACK_SOURCE_UPDATED
] = { .name
= "FallbackSourceUpdated", .arguments
= fallback_source_updated_args
, .n_arguments
= 1 },
302 [SIGNAL_NEW_PLAYBACK_STREAM
] = { .name
= "NewPlaybackStream", .arguments
= new_playback_stream_args
, .n_arguments
= 1 },
303 [SIGNAL_PLAYBACK_STREAM_REMOVED
] = { .name
= "PlaybackStreamRemoved", .arguments
= playback_stream_removed_args
, .n_arguments
= 1 },
304 [SIGNAL_NEW_RECORD_STREAM
] = { .name
= "NewRecordStream", .arguments
= new_record_stream_args
, .n_arguments
= 1 },
305 [SIGNAL_RECORD_STREAM_REMOVED
] = { .name
= "RecordStreamRemoved", .arguments
= record_stream_removed_args
, .n_arguments
= 1 },
306 [SIGNAL_NEW_SAMPLE
] = { .name
= "NewSample", .arguments
= new_sample_args
, .n_arguments
= 1 },
307 [SIGNAL_SAMPLE_REMOVED
] = { .name
= "SampleRemoved", .arguments
= sample_removed_args
, .n_arguments
= 1 },
308 [SIGNAL_NEW_MODULE
] = { .name
= "NewModule", .arguments
= new_module_args
, .n_arguments
= 1 },
309 [SIGNAL_MODULE_REMOVED
] = { .name
= "ModuleRemoved", .arguments
= module_removed_args
, .n_arguments
= 1 },
310 [SIGNAL_NEW_CLIENT
] = { .name
= "NewClient", .arguments
= new_client_args
, .n_arguments
= 1 },
311 [SIGNAL_CLIENT_REMOVED
] = { .name
= "ClientRemoved", .arguments
= client_removed_args
, .n_arguments
= 1 },
312 [SIGNAL_NEW_EXTENSION
] = { .name
= "NewExtension", .arguments
= new_extension_args
, .n_arguments
= 1 },
313 [SIGNAL_EXTENSION_REMOVED
] = { .name
= "ExtensionRemoved", .arguments
= extension_removed_args
, .n_arguments
= 1 }
316 static pa_dbus_interface_info core_interface_info
= {
317 .name
= PA_DBUSIFACE_CORE_INTERFACE
,
318 .method_handlers
= method_handlers
,
319 .n_method_handlers
= METHOD_HANDLER_MAX
,
320 .property_handlers
= property_handlers
,
321 .n_property_handlers
= PROPERTY_HANDLER_MAX
,
322 .get_all_properties_cb
= handle_get_all
,
324 .n_signals
= SIGNAL_MAX
327 static void handle_get_interface_revision(DBusConnection
*conn
, DBusMessage
*msg
, void *userdata
) {
328 dbus_uint32_t interface_revision
= INTERFACE_REVISION
;
333 pa_dbus_send_basic_variant_reply(conn
, msg
, DBUS_TYPE_UINT32
, &interface_revision
);
336 static void handle_get_name(DBusConnection
*conn
, DBusMessage
*msg
, void *userdata
) {
337 const char *server_name
= PACKAGE_NAME
;
342 pa_dbus_send_basic_variant_reply(conn
, msg
, DBUS_TYPE_STRING
, &server_name
);
345 static void handle_get_version(DBusConnection
*conn
, DBusMessage
*msg
, void *userdata
) {
346 const char *version
= PACKAGE_VERSION
;
351 pa_dbus_send_basic_variant_reply(conn
, msg
, DBUS_TYPE_STRING
, &version
);
354 static dbus_bool_t
get_is_local(DBusConnection
*conn
) {
359 if (!dbus_connection_get_socket(conn
, &conn_fd
))
362 return pa_socket_is_local(conn_fd
);
365 static void handle_get_is_local(DBusConnection
*conn
, DBusMessage
*msg
, void *userdata
) {
366 dbus_bool_t is_local
;
371 is_local
= get_is_local(conn
);
373 pa_dbus_send_basic_variant_reply(conn
, msg
, DBUS_TYPE_BOOLEAN
, &is_local
);
376 static void handle_get_username(DBusConnection
*conn
, DBusMessage
*msg
, void *userdata
) {
377 char *username
= NULL
;
382 username
= pa_get_user_name_malloc();
384 pa_dbus_send_basic_variant_reply(conn
, msg
, DBUS_TYPE_STRING
, &username
);
389 static void handle_get_hostname(DBusConnection
*conn
, DBusMessage
*msg
, void *userdata
) {
390 char *hostname
= NULL
;
395 hostname
= pa_get_host_name_malloc();
397 pa_dbus_send_basic_variant_reply(conn
, msg
, DBUS_TYPE_STRING
, &hostname
);
402 /* Caller frees the returned array. */
403 static dbus_uint32_t
*get_default_channels(pa_dbusiface_core
*c
, unsigned *n
) {
404 dbus_uint32_t
*default_channels
= NULL
;
410 *n
= c
->core
->default_channel_map
.channels
;
411 default_channels
= pa_xnew(dbus_uint32_t
, *n
);
413 for (i
= 0; i
< *n
; ++i
)
414 default_channels
[i
] = c
->core
->default_channel_map
.map
[i
];
416 return default_channels
;
419 static void handle_get_default_channels(DBusConnection
*conn
, DBusMessage
*msg
, void *userdata
) {
420 pa_dbusiface_core
*c
= userdata
;
421 dbus_uint32_t
*default_channels
= NULL
;
428 default_channels
= get_default_channels(c
, &n
);
430 pa_dbus_send_basic_array_variant_reply(conn
, msg
, DBUS_TYPE_UINT32
, default_channels
, n
);
432 pa_xfree(default_channels
);
435 static void handle_set_default_channels(DBusConnection
*conn
, DBusMessage
*msg
, void *userdata
) {
436 pa_dbusiface_core
*c
= userdata
;
437 pa_channel_map new_channel_map
;
438 dbus_uint32_t
*default_channels
;
446 pa_channel_map_init(&new_channel_map
);
448 if (pa_dbus_get_fixed_array_set_property_arg(conn
, msg
, DBUS_TYPE_UINT32
, &default_channels
, &n_channels
) < 0)
451 if (n_channels
<= 0) {
452 pa_dbus_send_error(conn
, msg
, DBUS_ERROR_INVALID_ARGS
, "Empty channel array.");
456 if (n_channels
> PA_CHANNELS_MAX
) {
457 pa_dbus_send_error(conn
, msg
, DBUS_ERROR_INVALID_ARGS
, "Too many channels: %u. The maximum number of channels is %u.", n_channels
, PA_CHANNELS_MAX
);
461 new_channel_map
.channels
= n_channels
;
463 for (i
= 0; i
< new_channel_map
.channels
; ++i
) {
464 if (default_channels
[i
] >= PA_CHANNEL_POSITION_MAX
) {
465 pa_dbus_send_error(conn
, msg
, DBUS_ERROR_INVALID_ARGS
, "Invalid channel position: %u.", default_channels
[i
]);
469 new_channel_map
.map
[i
] = default_channels
[i
];
472 c
->core
->default_channel_map
= new_channel_map
;
473 c
->core
->default_sample_spec
.channels
= n_channels
;
475 pa_dbus_send_empty_reply(conn
, msg
);
478 static void handle_get_default_sample_format(DBusConnection
*conn
, DBusMessage
*msg
, void *userdata
) {
479 pa_dbusiface_core
*c
= userdata
;
480 dbus_uint32_t default_sample_format
;
486 default_sample_format
= c
->core
->default_sample_spec
.format
;
488 pa_dbus_send_basic_variant_reply(conn
, msg
, DBUS_TYPE_UINT32
, &default_sample_format
);
491 static void handle_set_default_sample_format(DBusConnection
*conn
, DBusMessage
*msg
, void *userdata
) {
492 pa_dbusiface_core
*c
= userdata
;
493 dbus_uint32_t default_sample_format
;
499 if (pa_dbus_get_basic_set_property_arg(conn
, msg
, DBUS_TYPE_UINT32
, &default_sample_format
) < 0)
502 if (default_sample_format
>= PA_SAMPLE_MAX
) {
503 pa_dbus_send_error(conn
, msg
, DBUS_ERROR_INVALID_ARGS
, "Invalid sample format.");
507 c
->core
->default_sample_spec
.format
= default_sample_format
;
509 pa_dbus_send_empty_reply(conn
, msg
);
512 static void handle_get_default_sample_rate(DBusConnection
*conn
, DBusMessage
*msg
, void *userdata
) {
513 pa_dbusiface_core
*c
= userdata
;
514 dbus_uint32_t default_sample_rate
;
520 default_sample_rate
= c
->core
->default_sample_spec
.rate
;
522 pa_dbus_send_basic_variant_reply(conn
, msg
, DBUS_TYPE_UINT32
, &default_sample_rate
);
525 static void handle_set_default_sample_rate(DBusConnection
*conn
, DBusMessage
*msg
, void *userdata
) {
526 pa_dbusiface_core
*c
= userdata
;
527 dbus_uint32_t default_sample_rate
;
533 if (pa_dbus_get_basic_set_property_arg(conn
, msg
, DBUS_TYPE_UINT32
, &default_sample_rate
) < 0)
536 if (default_sample_rate
<= 0 || default_sample_rate
> PA_RATE_MAX
) {
537 pa_dbus_send_error(conn
, msg
, DBUS_ERROR_INVALID_ARGS
, "Invalid sample rate.");
541 c
->core
->default_sample_spec
.rate
= default_sample_rate
;
543 pa_dbus_send_empty_reply(conn
, msg
);
546 /* The caller frees the array, but not the strings. */
547 static const char **get_cards(pa_dbusiface_core
*c
, unsigned *n
) {
551 pa_dbusiface_card
*card
;
556 *n
= pa_hashmap_size(c
->cards
);
561 cards
= pa_xnew(const char *, *n
);
563 for (i
= 0, card
= pa_hashmap_iterate(c
->cards
, &state
, NULL
); card
; ++i
, card
= pa_hashmap_iterate(c
->cards
, &state
, NULL
))
564 cards
[i
] = pa_dbusiface_card_get_path(card
);
571 static void handle_get_cards(DBusConnection
*conn
, DBusMessage
*msg
, void *userdata
) {
572 pa_dbusiface_core
*c
= userdata
;
580 cards
= get_cards(c
, &n
);
582 pa_dbus_send_basic_array_variant_reply(conn
, msg
, DBUS_TYPE_OBJECT_PATH
, cards
, n
);
587 /* The caller frees the array, but not the strings. */
588 static const char **get_sinks(pa_dbusiface_core
*c
, unsigned *n
) {
592 pa_dbusiface_device
*sink
;
597 *n
= pa_hashmap_size(c
->sinks_by_index
);
602 sinks
= pa_xnew(const char *, *n
);
604 for (i
= 0, sink
= pa_hashmap_iterate(c
->sinks_by_index
, &state
, NULL
); sink
; ++i
, sink
= pa_hashmap_iterate(c
->sinks_by_index
, &state
, NULL
))
605 sinks
[i
] = pa_dbusiface_device_get_path(sink
);
612 static void handle_get_sinks(DBusConnection
*conn
, DBusMessage
*msg
, void *userdata
) {
613 pa_dbusiface_core
*c
= userdata
;
621 sinks
= get_sinks(c
, &n
);
623 pa_dbus_send_basic_array_variant_reply(conn
, msg
, DBUS_TYPE_OBJECT_PATH
, sinks
, n
);
628 static void handle_get_fallback_sink(DBusConnection
*conn
, DBusMessage
*msg
, void *userdata
) {
629 pa_dbusiface_core
*c
= userdata
;
630 pa_dbusiface_device
*fallback_sink
;
631 const char *object_path
;
637 if (!c
->fallback_sink
) {
638 pa_dbus_send_error(conn
, msg
, PA_DBUS_ERROR_NO_SUCH_PROPERTY
, "There are no sinks, and therefore no fallback sink either.");
642 pa_assert_se((fallback_sink
= pa_hashmap_get(c
->sinks_by_index
, PA_UINT32_TO_PTR(c
->fallback_sink
->index
))));
643 object_path
= pa_dbusiface_device_get_path(fallback_sink
);
645 pa_dbus_send_basic_variant_reply(conn
, msg
, DBUS_TYPE_OBJECT_PATH
, &object_path
);
648 static void handle_set_fallback_sink(DBusConnection
*conn
, DBusMessage
*msg
, void *userdata
) {
649 pa_dbusiface_core
*c
= userdata
;
650 pa_dbusiface_device
*fallback_sink
;
651 const char *object_path
;
657 if (!c
->fallback_sink
) {
658 pa_dbus_send_error(conn
, msg
, PA_DBUS_ERROR_NO_SUCH_PROPERTY
, "There are no sinks, and therefore no fallback sink either.");
662 if (pa_dbus_get_basic_set_property_arg(conn
, msg
, DBUS_TYPE_OBJECT_PATH
, &object_path
) < 0)
665 if (!(fallback_sink
= pa_hashmap_get(c
->sinks_by_path
, object_path
))) {
666 pa_dbus_send_error(conn
, msg
, PA_DBUS_ERROR_NOT_FOUND
, "No such sink.");
670 pa_namereg_set_default_sink(c
->core
, pa_dbusiface_device_get_sink(fallback_sink
));
672 pa_dbus_send_empty_reply(conn
, msg
);
675 /* The caller frees the array, but not the strings. */
676 static const char **get_sources(pa_dbusiface_core
*c
, unsigned *n
) {
677 const char **sources
;
680 pa_dbusiface_device
*source
;
685 *n
= pa_hashmap_size(c
->sources_by_index
);
690 sources
= pa_xnew(const char *, *n
);
692 for (i
= 0, source
= pa_hashmap_iterate(c
->sources_by_index
, &state
, NULL
); source
; ++i
, source
= pa_hashmap_iterate(c
->sources_by_index
, &state
, NULL
))
693 sources
[i
] = pa_dbusiface_device_get_path(source
);
700 static void handle_get_sources(DBusConnection
*conn
, DBusMessage
*msg
, void *userdata
) {
701 pa_dbusiface_core
*c
= userdata
;
702 const char **sources
;
709 sources
= get_sources(c
, &n
);
711 pa_dbus_send_basic_array_variant_reply(conn
, msg
, DBUS_TYPE_OBJECT_PATH
, sources
, n
);
716 static void handle_get_fallback_source(DBusConnection
*conn
, DBusMessage
*msg
, void *userdata
) {
717 pa_dbusiface_core
*c
= userdata
;
718 pa_dbusiface_device
*fallback_source
;
719 const char *object_path
;
725 if (!c
->fallback_source
) {
726 pa_dbus_send_error(conn
, msg
, PA_DBUS_ERROR_NO_SUCH_PROPERTY
, "There are no sources, and therefore no fallback source either.");
730 pa_assert_se((fallback_source
= pa_hashmap_get(c
->sources_by_index
, PA_UINT32_TO_PTR(c
->fallback_source
->index
))));
731 object_path
= pa_dbusiface_device_get_path(fallback_source
);
733 pa_dbus_send_basic_variant_reply(conn
, msg
, DBUS_TYPE_OBJECT_PATH
, &object_path
);
736 static void handle_set_fallback_source(DBusConnection
*conn
, DBusMessage
*msg
, void *userdata
) {
737 pa_dbusiface_core
*c
= userdata
;
738 pa_dbusiface_device
*fallback_source
;
739 const char *object_path
;
745 if (!c
->fallback_source
) {
746 pa_dbus_send_error(conn
, msg
, PA_DBUS_ERROR_NO_SUCH_PROPERTY
, "There are no sources, and therefore no fallback source either.");
750 if (pa_dbus_get_basic_set_property_arg(conn
, msg
, DBUS_TYPE_OBJECT_PATH
, &object_path
) < 0)
753 if (!(fallback_source
= pa_hashmap_get(c
->sources_by_path
, object_path
))) {
754 pa_dbus_send_error(conn
, msg
, PA_DBUS_ERROR_NOT_FOUND
, "No such source.");
758 pa_namereg_set_default_source(c
->core
, pa_dbusiface_device_get_source(fallback_source
));
760 pa_dbus_send_empty_reply(conn
, msg
);
763 /* The caller frees the array, but not the strings. */
764 static const char **get_playback_streams(pa_dbusiface_core
*c
, unsigned *n
) {
765 const char **streams
;
768 pa_dbusiface_stream
*stream
;
773 *n
= pa_hashmap_size(c
->playback_streams
);
778 streams
= pa_xnew(const char *, *n
);
780 for (i
= 0, stream
= pa_hashmap_iterate(c
->playback_streams
, &state
, NULL
); stream
; ++i
, stream
= pa_hashmap_iterate(c
->playback_streams
, &state
, NULL
))
781 streams
[i
] = pa_dbusiface_stream_get_path(stream
);
788 static void handle_get_playback_streams(DBusConnection
*conn
, DBusMessage
*msg
, void *userdata
) {
789 pa_dbusiface_core
*c
= userdata
;
790 const char **playback_streams
;
797 playback_streams
= get_playback_streams(c
, &n
);
799 pa_dbus_send_basic_array_variant_reply(conn
, msg
, DBUS_TYPE_OBJECT_PATH
, playback_streams
, n
);
801 pa_xfree(playback_streams
);
804 /* The caller frees the array, but not the strings. */
805 static const char **get_record_streams(pa_dbusiface_core
*c
, unsigned *n
) {
806 const char **streams
;
809 pa_dbusiface_stream
*stream
;
814 *n
= pa_hashmap_size(c
->record_streams
);
819 streams
= pa_xnew(const char *, *n
);
821 for (i
= 0, stream
= pa_hashmap_iterate(c
->record_streams
, &state
, NULL
); stream
; ++i
, stream
= pa_hashmap_iterate(c
->record_streams
, &state
, NULL
))
822 streams
[i
] = pa_dbusiface_stream_get_path(stream
);
829 static void handle_get_record_streams(DBusConnection
*conn
, DBusMessage
*msg
, void *userdata
) {
830 pa_dbusiface_core
*c
= userdata
;
831 const char **record_streams
;
838 record_streams
= get_record_streams(c
, &n
);
840 pa_dbus_send_basic_array_variant_reply(conn
, msg
, DBUS_TYPE_OBJECT_PATH
, record_streams
, n
);
842 pa_xfree(record_streams
);
845 /* The caller frees the array, but not the strings. */
846 static const char **get_samples(pa_dbusiface_core
*c
, unsigned *n
) {
847 const char **samples
;
850 pa_dbusiface_sample
*sample
;
855 *n
= pa_hashmap_size(c
->samples
);
860 samples
= pa_xnew(const char *, *n
);
862 for (i
= 0, sample
= pa_hashmap_iterate(c
->samples
, &state
, NULL
); sample
; ++i
, sample
= pa_hashmap_iterate(c
->samples
, &state
, NULL
))
863 samples
[i
] = pa_dbusiface_sample_get_path(sample
);
870 static void handle_get_samples(DBusConnection
*conn
, DBusMessage
*msg
, void *userdata
) {
871 pa_dbusiface_core
*c
= userdata
;
872 const char **samples
;
879 samples
= get_samples(c
, &n
);
881 pa_dbus_send_basic_array_variant_reply(conn
, msg
, DBUS_TYPE_OBJECT_PATH
, samples
, n
);
886 /* The caller frees the array, but not the strings. */
887 static const char **get_modules(pa_dbusiface_core
*c
, unsigned *n
) {
888 const char **modules
;
891 pa_dbusiface_module
*module
;
896 *n
= pa_hashmap_size(c
->modules
);
901 modules
= pa_xnew(const char *, *n
);
903 for (i
= 0, module
= pa_hashmap_iterate(c
->modules
, &state
, NULL
); module
; ++i
, module
= pa_hashmap_iterate(c
->modules
, &state
, NULL
))
904 modules
[i
] = pa_dbusiface_module_get_path(module
);
911 static void handle_get_modules(DBusConnection
*conn
, DBusMessage
*msg
, void *userdata
) {
912 pa_dbusiface_core
*c
= userdata
;
913 const char **modules
;
920 modules
= get_modules(c
, &n
);
922 pa_dbus_send_basic_array_variant_reply(conn
, msg
, DBUS_TYPE_OBJECT_PATH
, modules
, n
);
927 /* The caller frees the array, but not the strings. */
928 static const char **get_clients(pa_dbusiface_core
*c
, unsigned *n
) {
929 const char **clients
;
932 pa_dbusiface_client
*client
;
937 *n
= pa_hashmap_size(c
->clients
);
942 clients
= pa_xnew(const char *, *n
);
944 for (i
= 0, client
= pa_hashmap_iterate(c
->clients
, &state
, NULL
); client
; ++i
, client
= pa_hashmap_iterate(c
->clients
, &state
, NULL
))
945 clients
[i
] = pa_dbusiface_client_get_path(client
);
952 static void handle_get_clients(DBusConnection
*conn
, DBusMessage
*msg
, void *userdata
) {
953 pa_dbusiface_core
*c
= userdata
;
954 const char **clients
;
961 clients
= get_clients(c
, &n
);
963 pa_dbus_send_basic_array_variant_reply(conn
, msg
, DBUS_TYPE_OBJECT_PATH
, clients
, n
);
968 static const char *get_my_client(pa_dbusiface_core
*c
, DBusConnection
*conn
) {
969 pa_client
*my_client
;
974 pa_assert_se((my_client
= pa_dbus_protocol_get_client(c
->dbus_protocol
, conn
)));
976 return pa_dbusiface_client_get_path(pa_hashmap_get(c
->clients
, PA_UINT32_TO_PTR(my_client
->index
)));
979 static void handle_get_my_client(DBusConnection
*conn
, DBusMessage
*msg
, void *userdata
) {
980 pa_dbusiface_core
*c
= userdata
;
981 const char *my_client
;
987 my_client
= get_my_client(c
, conn
);
989 pa_dbus_send_basic_variant_reply(conn
, msg
, DBUS_TYPE_OBJECT_PATH
, &my_client
);
992 static void handle_get_extensions(DBusConnection
*conn
, DBusMessage
*msg
, void *userdata
) {
993 pa_dbusiface_core
*c
= userdata
;
994 const char **extensions
;
1001 extensions
= pa_dbus_protocol_get_extensions(c
->dbus_protocol
, &n
);
1003 pa_dbus_send_basic_array_variant_reply(conn
, msg
, DBUS_TYPE_STRING
, extensions
, n
);
1005 pa_xfree(extensions
);
1008 static void handle_get_all(DBusConnection
*conn
, DBusMessage
*msg
, void *userdata
) {
1009 pa_dbusiface_core
*c
= userdata
;
1010 DBusMessage
*reply
= NULL
;
1011 DBusMessageIter msg_iter
;
1012 DBusMessageIter dict_iter
;
1013 dbus_uint32_t interface_revision
;
1014 const char *server_name
;
1015 const char *version
;
1016 dbus_bool_t is_local
;
1019 dbus_uint32_t
*default_channels
;
1020 unsigned n_default_channels
;
1021 dbus_uint32_t default_sample_format
;
1022 dbus_uint32_t default_sample_rate
;
1027 const char *fallback_sink
;
1028 const char **sources
;
1030 const char *fallback_source
;
1031 const char **playback_streams
;
1032 unsigned n_playback_streams
;
1033 const char **record_streams
;
1034 unsigned n_record_streams
;
1035 const char **samples
;
1037 const char **modules
;
1039 const char **clients
;
1041 const char *my_client
;
1042 const char **extensions
;
1043 unsigned n_extensions
;
1049 interface_revision
= INTERFACE_REVISION
;
1050 server_name
= PACKAGE_NAME
;
1051 version
= PACKAGE_VERSION
;
1052 is_local
= get_is_local(conn
);
1053 username
= pa_get_user_name_malloc();
1054 hostname
= pa_get_host_name_malloc();
1055 default_channels
= get_default_channels(c
, &n_default_channels
);
1056 default_sample_format
= c
->core
->default_sample_spec
.format
;
1057 default_sample_rate
= c
->core
->default_sample_spec
.rate
;
1058 cards
= get_cards(c
, &n_cards
);
1059 sinks
= get_sinks(c
, &n_sinks
);
1060 fallback_sink
= c
->fallback_sink
? pa_dbusiface_device_get_path(pa_hashmap_get(c
->sinks_by_index
, PA_UINT32_TO_PTR(c
->fallback_sink
->index
))) : NULL
;
1061 sources
= get_sources(c
, &n_sources
);
1062 fallback_source
= c
->fallback_source
? pa_dbusiface_device_get_path(pa_hashmap_get(c
->sources_by_index
, PA_UINT32_TO_PTR(c
->fallback_source
->index
))) : NULL
;
1063 playback_streams
= get_playback_streams(c
, &n_playback_streams
);
1064 record_streams
= get_record_streams(c
, &n_record_streams
);
1065 samples
= get_samples(c
, &n_samples
);
1066 modules
= get_modules(c
, &n_modules
);
1067 clients
= get_clients(c
, &n_clients
);
1068 my_client
= get_my_client(c
, conn
);
1069 extensions
= pa_dbus_protocol_get_extensions(c
->dbus_protocol
, &n_extensions
);
1071 pa_assert_se((reply
= dbus_message_new_method_return(msg
)));
1073 dbus_message_iter_init_append(reply
, &msg_iter
);
1074 pa_assert_se(dbus_message_iter_open_container(&msg_iter
, DBUS_TYPE_ARRAY
, "{sv}", &dict_iter
));
1076 pa_dbus_append_basic_variant_dict_entry(&dict_iter
, property_handlers
[PROPERTY_HANDLER_INTERFACE_REVISION
].property_name
, DBUS_TYPE_UINT32
, &interface_revision
);
1077 pa_dbus_append_basic_variant_dict_entry(&dict_iter
, property_handlers
[PROPERTY_HANDLER_NAME
].property_name
, DBUS_TYPE_STRING
, &server_name
);
1078 pa_dbus_append_basic_variant_dict_entry(&dict_iter
, property_handlers
[PROPERTY_HANDLER_VERSION
].property_name
, DBUS_TYPE_STRING
, &version
);
1079 pa_dbus_append_basic_variant_dict_entry(&dict_iter
, property_handlers
[PROPERTY_HANDLER_IS_LOCAL
].property_name
, DBUS_TYPE_BOOLEAN
, &is_local
);
1080 pa_dbus_append_basic_variant_dict_entry(&dict_iter
, property_handlers
[PROPERTY_HANDLER_USERNAME
].property_name
, DBUS_TYPE_STRING
, &username
);
1081 pa_dbus_append_basic_variant_dict_entry(&dict_iter
, property_handlers
[PROPERTY_HANDLER_HOSTNAME
].property_name
, DBUS_TYPE_STRING
, &hostname
);
1082 pa_dbus_append_basic_array_variant_dict_entry(&dict_iter
, property_handlers
[PROPERTY_HANDLER_DEFAULT_CHANNELS
].property_name
, DBUS_TYPE_UINT32
, default_channels
, n_default_channels
);
1083 pa_dbus_append_basic_variant_dict_entry(&dict_iter
, property_handlers
[PROPERTY_HANDLER_DEFAULT_SAMPLE_FORMAT
].property_name
, DBUS_TYPE_UINT32
, &default_sample_format
);
1084 pa_dbus_append_basic_variant_dict_entry(&dict_iter
, property_handlers
[PROPERTY_HANDLER_DEFAULT_SAMPLE_RATE
].property_name
, DBUS_TYPE_UINT32
, &default_sample_rate
);
1085 pa_dbus_append_basic_array_variant_dict_entry(&dict_iter
, property_handlers
[PROPERTY_HANDLER_CARDS
].property_name
, DBUS_TYPE_OBJECT_PATH
, cards
, n_cards
);
1086 pa_dbus_append_basic_array_variant_dict_entry(&dict_iter
, property_handlers
[PROPERTY_HANDLER_SINKS
].property_name
, DBUS_TYPE_OBJECT_PATH
, sinks
, n_sinks
);
1089 pa_dbus_append_basic_variant_dict_entry(&dict_iter
, property_handlers
[PROPERTY_HANDLER_FALLBACK_SINK
].property_name
, DBUS_TYPE_OBJECT_PATH
, &fallback_sink
);
1091 pa_dbus_append_basic_array_variant_dict_entry(&dict_iter
, property_handlers
[PROPERTY_HANDLER_SOURCES
].property_name
, DBUS_TYPE_OBJECT_PATH
, sources
, n_sources
);
1093 if (fallback_source
)
1094 pa_dbus_append_basic_variant_dict_entry(&dict_iter
, property_handlers
[PROPERTY_HANDLER_FALLBACK_SOURCE
].property_name
, DBUS_TYPE_OBJECT_PATH
, &fallback_source
);
1096 pa_dbus_append_basic_array_variant_dict_entry(&dict_iter
, property_handlers
[PROPERTY_HANDLER_PLAYBACK_STREAMS
].property_name
, DBUS_TYPE_OBJECT_PATH
, playback_streams
, n_playback_streams
);
1097 pa_dbus_append_basic_array_variant_dict_entry(&dict_iter
, property_handlers
[PROPERTY_HANDLER_RECORD_STREAMS
].property_name
, DBUS_TYPE_OBJECT_PATH
, record_streams
, n_record_streams
);
1098 pa_dbus_append_basic_array_variant_dict_entry(&dict_iter
, property_handlers
[PROPERTY_HANDLER_SAMPLES
].property_name
, DBUS_TYPE_OBJECT_PATH
, samples
, n_samples
);
1099 pa_dbus_append_basic_array_variant_dict_entry(&dict_iter
, property_handlers
[PROPERTY_HANDLER_MODULES
].property_name
, DBUS_TYPE_OBJECT_PATH
, modules
, n_modules
);
1100 pa_dbus_append_basic_array_variant_dict_entry(&dict_iter
, property_handlers
[PROPERTY_HANDLER_CLIENTS
].property_name
, DBUS_TYPE_OBJECT_PATH
, clients
, n_clients
);
1101 pa_dbus_append_basic_variant_dict_entry(&dict_iter
, property_handlers
[PROPERTY_HANDLER_MY_CLIENT
].property_name
, DBUS_TYPE_OBJECT_PATH
, &my_client
);
1102 pa_dbus_append_basic_array_variant_dict_entry(&dict_iter
, property_handlers
[PROPERTY_HANDLER_EXTENSIONS
].property_name
, DBUS_TYPE_STRING
, extensions
, n_extensions
);
1104 pa_assert_se(dbus_message_iter_close_container(&msg_iter
, &dict_iter
));
1106 pa_assert_se(dbus_connection_send(conn
, reply
, NULL
));
1108 dbus_message_unref(reply
);
1112 pa_xfree(default_channels
);
1116 pa_xfree(playback_streams
);
1117 pa_xfree(record_streams
);
1121 pa_xfree(extensions
);
1124 static void handle_get_card_by_name(DBusConnection
*conn
, DBusMessage
*msg
, void *userdata
) {
1125 pa_dbusiface_core
*c
= userdata
;
1128 pa_dbusiface_card
*dbus_card
;
1129 const char *object_path
;
1136 dbus_error_init(&error
);
1138 if (!dbus_message_get_args(msg
, &error
, DBUS_TYPE_STRING
, &card_name
, DBUS_TYPE_INVALID
)) {
1139 pa_dbus_send_error(conn
, msg
, DBUS_ERROR_INVALID_ARGS
, "%s", error
.message
);
1140 dbus_error_free(&error
);
1144 if (!(card
= pa_namereg_get(c
->core
, card_name
, PA_NAMEREG_CARD
))) {
1145 pa_dbus_send_error(conn
, msg
, PA_DBUS_ERROR_NOT_FOUND
, "No such card.");
1149 pa_assert_se((dbus_card
= pa_hashmap_get(c
->cards
, PA_UINT32_TO_PTR(card
->index
))));
1151 object_path
= pa_dbusiface_card_get_path(dbus_card
);
1153 pa_dbus_send_basic_value_reply(conn
, msg
, DBUS_TYPE_OBJECT_PATH
, &object_path
);
1156 static void handle_get_sink_by_name(DBusConnection
*conn
, DBusMessage
*msg
, void *userdata
) {
1157 pa_dbusiface_core
*c
= userdata
;
1160 pa_dbusiface_device
*dbus_sink
;
1161 const char *object_path
;
1168 dbus_error_init(&error
);
1170 if (!dbus_message_get_args(msg
, &error
, DBUS_TYPE_STRING
, &sink_name
, DBUS_TYPE_INVALID
)) {
1171 pa_dbus_send_error(conn
, msg
, DBUS_ERROR_INVALID_ARGS
, "%s", error
.message
);
1172 dbus_error_free(&error
);
1176 if (!(sink
= pa_namereg_get(c
->core
, sink_name
, PA_NAMEREG_SINK
))) {
1177 pa_dbus_send_error(conn
, msg
, PA_DBUS_ERROR_NOT_FOUND
, "No such sink.");
1181 pa_assert_se((dbus_sink
= pa_hashmap_get(c
->sinks_by_index
, PA_UINT32_TO_PTR(sink
->index
))));
1183 object_path
= pa_dbusiface_device_get_path(dbus_sink
);
1185 pa_dbus_send_basic_value_reply(conn
, msg
, DBUS_TYPE_OBJECT_PATH
, &object_path
);
1188 static void handle_get_source_by_name(DBusConnection
*conn
, DBusMessage
*msg
, void *userdata
) {
1189 pa_dbusiface_core
*c
= userdata
;
1192 pa_dbusiface_device
*dbus_source
;
1193 const char *object_path
;
1200 dbus_error_init(&error
);
1202 if (!dbus_message_get_args(msg
, &error
, DBUS_TYPE_STRING
, &source_name
, DBUS_TYPE_INVALID
)) {
1203 pa_dbus_send_error(conn
, msg
, DBUS_ERROR_INVALID_ARGS
, "%s", error
.message
);
1204 dbus_error_free(&error
);
1208 if (!(source
= pa_namereg_get(c
->core
, source_name
, PA_NAMEREG_SOURCE
))) {
1209 pa_dbus_send_error(conn
, msg
, PA_DBUS_ERROR_NOT_FOUND
, "No such source.");
1213 pa_assert_se((dbus_source
= pa_hashmap_get(c
->sources_by_index
, PA_UINT32_TO_PTR(source
->index
))));
1215 object_path
= pa_dbusiface_device_get_path(dbus_source
);
1217 pa_dbus_send_basic_value_reply(conn
, msg
, DBUS_TYPE_OBJECT_PATH
, &object_path
);
1220 static void handle_get_sample_by_name(DBusConnection
*conn
, DBusMessage
*msg
, void *userdata
) {
1221 pa_dbusiface_core
*c
= userdata
;
1223 pa_scache_entry
*sample
;
1224 pa_dbusiface_sample
*dbus_sample
;
1225 const char *object_path
;
1232 dbus_error_init(&error
);
1234 if (!dbus_message_get_args(msg
, &error
, DBUS_TYPE_STRING
, &sample_name
, DBUS_TYPE_INVALID
)) {
1235 pa_dbus_send_error(conn
, msg
, DBUS_ERROR_INVALID_ARGS
, "%s", error
.message
);
1236 dbus_error_free(&error
);
1240 if (!(sample
= pa_namereg_get(c
->core
, sample_name
, PA_NAMEREG_SAMPLE
))) {
1241 pa_dbus_send_error(conn
, msg
, PA_DBUS_ERROR_NOT_FOUND
, "No such sample.");
1245 pa_assert_se((dbus_sample
= pa_hashmap_get(c
->samples
, PA_UINT32_TO_PTR(sample
->index
))));
1247 object_path
= pa_dbusiface_sample_get_path(dbus_sample
);
1249 pa_dbus_send_basic_value_reply(conn
, msg
, DBUS_TYPE_OBJECT_PATH
, &object_path
);
1252 static void handle_upload_sample(DBusConnection
*conn
, DBusMessage
*msg
, void *userdata
) {
1253 pa_dbusiface_core
*c
= userdata
;
1254 DBusMessageIter msg_iter
;
1256 dbus_uint32_t sample_format
;
1257 dbus_uint32_t sample_rate
;
1258 const dbus_uint32_t
*channels
;
1259 unsigned n_channels
;
1260 const dbus_uint32_t
*default_volume
;
1261 unsigned n_volume_entries
;
1262 pa_proplist
*property_list
;
1263 const uint8_t *data
;
1264 unsigned data_length
;
1270 pa_dbusiface_sample
*dbus_sample
= NULL
;
1271 pa_scache_entry
*sample
= NULL
;
1272 const char *object_path
;
1278 chunk
.memblock
= NULL
;
1280 if (!dbus_message_iter_init(msg
, &msg_iter
)) {
1281 pa_dbus_send_error(conn
, msg
, DBUS_ERROR_INVALID_ARGS
, "Too few arguments.");
1285 if (pa_dbus_get_basic_arg(conn
, msg
, &msg_iter
, DBUS_TYPE_STRING
, &name
) < 0)
1288 if (pa_dbus_get_basic_arg(conn
, msg
, &msg_iter
, DBUS_TYPE_UINT32
, &sample_format
) < 0)
1291 if (pa_dbus_get_basic_arg(conn
, msg
, &msg_iter
, DBUS_TYPE_UINT32
, &sample_rate
) < 0)
1294 if (pa_dbus_get_fixed_array_arg(conn
, msg
, &msg_iter
, DBUS_TYPE_UINT32
, &channels
, &n_channels
) < 0)
1297 if (pa_dbus_get_fixed_array_arg(conn
, msg
, &msg_iter
, DBUS_TYPE_UINT32
, &default_volume
, &n_volume_entries
) < 0)
1300 if (!(property_list
= pa_dbus_get_proplist_arg(conn
, msg
, &msg_iter
)))
1303 if (pa_dbus_get_fixed_array_arg(conn
, msg
, &msg_iter
, DBUS_TYPE_BYTE
, &data
, &data_length
) < 0)
1306 if (sample_format
>= PA_SAMPLE_MAX
) {
1307 pa_dbus_send_error(conn
, msg
, DBUS_ERROR_INVALID_ARGS
, "Invalid sample format.");
1311 if (sample_rate
<= 0 || sample_rate
> PA_RATE_MAX
) {
1312 pa_dbus_send_error(conn
, msg
, DBUS_ERROR_INVALID_ARGS
, "Invalid sample rate.");
1316 if (n_channels
== 0) {
1317 pa_dbus_send_error(conn
, msg
, DBUS_ERROR_INVALID_ARGS
, "Empty channel map.");
1321 if (n_channels
> PA_CHANNELS_MAX
) {
1322 pa_dbus_send_error(conn
, msg
, DBUS_ERROR_INVALID_ARGS
, "Too many channels.");
1326 for (i
= 0; i
< n_channels
; ++i
) {
1327 if (channels
[i
] >= PA_CHANNEL_POSITION_MAX
) {
1328 pa_dbus_send_error(conn
, msg
, DBUS_ERROR_INVALID_ARGS
, "Invalid channel position.");
1333 if (n_volume_entries
!= 0 && n_volume_entries
!= n_channels
) {
1334 pa_dbus_send_error(conn
, msg
, DBUS_ERROR_INVALID_ARGS
, "The channels and default_volume arguments have different number of elements.");
1338 for (i
= 0; i
< n_volume_entries
; ++i
) {
1339 if (default_volume
[i
] > PA_VOLUME_MAX
) {
1340 pa_dbus_send_error(conn
, msg
, DBUS_ERROR_INVALID_ARGS
, "Invalid volume.");
1345 if (data_length
== 0) {
1346 pa_dbus_send_error(conn
, msg
, DBUS_ERROR_INVALID_ARGS
, "Empty data.");
1350 if (data_length
> PA_SCACHE_ENTRY_SIZE_MAX
) {
1351 pa_dbus_send_error(conn
, msg
, DBUS_ERROR_INVALID_ARGS
, "Too big sample.");
1355 ss
.format
= sample_format
;
1356 ss
.rate
= sample_rate
;
1357 ss
.channels
= n_channels
;
1359 if (!pa_frame_aligned(data_length
, &ss
)) {
1360 pa_dbus_send_error(conn
, msg
, DBUS_ERROR_INVALID_ARGS
, "The sample length in bytes doesn't align with the sample format and channels.");
1364 map
.channels
= n_channels
;
1365 for (i
= 0; i
< n_channels
; ++i
)
1366 map
.map
[i
] = channels
[i
];
1368 chunk
.memblock
= pa_memblock_new(c
->core
->mempool
, data_length
);
1370 chunk
.length
= data_length
;
1372 memcpy(pa_memblock_acquire(chunk
.memblock
), data
, data_length
);
1373 pa_memblock_release(chunk
.memblock
);
1375 if (pa_scache_add_item(c
->core
, name
, &ss
, &map
, &chunk
, property_list
, &idx
) < 0) {
1376 pa_dbus_send_error(conn
, msg
, DBUS_ERROR_FAILED
, "Adding the sample failed.");
1380 sample
= pa_idxset_get_by_index(c
->core
->scache
, idx
);
1382 if (n_volume_entries
> 0) {
1383 sample
->volume
.channels
= n_channels
;
1384 for (i
= 0; i
< n_volume_entries
; ++i
)
1385 sample
->volume
.values
[i
] = default_volume
[i
];
1386 sample
->volume_is_set
= TRUE
;
1388 sample
->volume_is_set
= FALSE
;
1391 dbus_sample
= pa_dbusiface_sample_new(sample
, OBJECT_PATH
);
1392 pa_hashmap_put(c
->samples
, PA_UINT32_TO_PTR(idx
), dbus_sample
);
1394 object_path
= pa_dbusiface_sample_get_path(dbus_sample
);
1396 pa_dbus_send_basic_value_reply(conn
, msg
, DBUS_TYPE_OBJECT_PATH
, &object_path
);
1400 pa_proplist_free(property_list
);
1403 pa_memblock_unref(chunk
.memblock
);
1406 static pa_bool_t
contains_space(const char *string
) {
1411 for (p
= string
; *p
; ++p
) {
1419 static void handle_load_module(DBusConnection
*conn
, DBusMessage
*msg
, void *userdata
) {
1420 pa_dbusiface_core
*c
= userdata
;
1421 DBusMessageIter msg_iter
;
1422 DBusMessageIter dict_iter
;
1423 DBusMessageIter dict_entry_iter
;
1427 char *escaped_value
;
1428 pa_strbuf
*arg_buffer
= NULL
;
1430 pa_dbusiface_module
*dbus_module
;
1431 const char *object_path
;
1438 if (c
->core
->disallow_module_loading
) {
1439 pa_dbus_send_error(conn
, msg
, DBUS_ERROR_ACCESS_DENIED
, "The server is configured to disallow module loading.");
1443 if (!dbus_message_iter_init(msg
, &msg_iter
)) {
1444 pa_dbus_send_error(conn
, msg
, DBUS_ERROR_INVALID_ARGS
, "Too few arguments.");
1448 if (pa_dbus_get_basic_arg(conn
, msg
, &msg_iter
, DBUS_TYPE_STRING
, &name
) < 0)
1451 arg_type
= dbus_message_iter_get_arg_type(&msg_iter
);
1452 if (arg_type
!= DBUS_TYPE_ARRAY
) {
1453 if (arg_type
== DBUS_TYPE_INVALID
)
1454 pa_dbus_send_error(conn
, msg
, DBUS_ERROR_INVALID_ARGS
, "Too few arguments. A dictionary from strings to strings was expected.");
1456 pa_dbus_send_error(conn
, msg
, DBUS_ERROR_INVALID_ARGS
, "Wrong argument type: '%c'. An dictionary from strings to strings was expected.", (char) arg_type
);
1460 arg_type
= dbus_message_iter_get_element_type(&msg_iter
);
1461 if (arg_type
!= DBUS_TYPE_DICT_ENTRY
) {
1462 pa_dbus_send_error(conn
, msg
, DBUS_ERROR_INVALID_ARGS
, "Wrong array element type: '%c'. A dict entry (string to string) was expected.", (char) arg_type
);
1466 arg_buffer
= pa_strbuf_new();
1468 dbus_message_iter_recurse(&msg_iter
, &dict_iter
);
1470 while (dbus_message_iter_get_arg_type(&dict_iter
) != DBUS_TYPE_INVALID
) {
1471 if (!pa_strbuf_isempty(arg_buffer
))
1472 pa_strbuf_putc(arg_buffer
, ' ');
1474 dbus_message_iter_recurse(&dict_iter
, &dict_entry_iter
);
1476 arg_type
= dbus_message_iter_get_arg_type(&dict_entry_iter
);
1477 if (arg_type
!= DBUS_TYPE_STRING
) {
1478 pa_dbus_send_error(conn
, msg
, DBUS_ERROR_INVALID_ARGS
, "Wrong dict key type: '%c'. A string was expected.", (char) arg_type
);
1482 dbus_message_iter_get_basic(&dict_entry_iter
, &key
);
1483 dbus_message_iter_next(&dict_entry_iter
);
1485 if (strlen(key
) <= 0 || !pa_ascii_valid(key
) || contains_space(key
)) {
1486 pa_dbus_send_error(conn
, msg
, DBUS_ERROR_INVALID_ARGS
, "Invalid module argument name: %s", key
);
1490 arg_type
= dbus_message_iter_get_arg_type(&dict_entry_iter
);
1491 if (arg_type
!= DBUS_TYPE_STRING
) {
1492 if (arg_type
== DBUS_TYPE_INVALID
)
1493 pa_dbus_send_error(conn
, msg
, DBUS_ERROR_INVALID_ARGS
, "Dict value missing.");
1495 pa_dbus_send_error(conn
, msg
, DBUS_ERROR_INVALID_ARGS
, "Wrong dict value type: '%c'. A string was expected.", (char) arg_type
);
1499 dbus_message_iter_get_basic(&dict_entry_iter
, &value
);
1501 dbus_message_iter_next(&dict_iter
);
1503 escaped_value
= pa_escape(value
, "\"");
1504 pa_strbuf_printf(arg_buffer
, "%s=\"%s\"", key
, escaped_value
);
1505 pa_xfree(escaped_value
);
1508 if (!(module
= pa_module_load(c
->core
, name
, pa_strbuf_tostring(arg_buffer
)))) {
1509 pa_dbus_send_error(conn
, msg
, DBUS_ERROR_FAILED
, "Failed to load module.");
1513 dbus_module
= pa_dbusiface_module_new(module
, OBJECT_PATH
);
1514 pa_hashmap_put(c
->modules
, PA_UINT32_TO_PTR(module
->index
), dbus_module
);
1516 object_path
= pa_dbusiface_module_get_path(dbus_module
);
1518 pa_dbus_send_basic_value_reply(conn
, msg
, DBUS_TYPE_OBJECT_PATH
, &object_path
);
1522 pa_strbuf_free(arg_buffer
);
1525 static void handle_exit(DBusConnection
*conn
, DBusMessage
*msg
, void *userdata
) {
1526 pa_dbusiface_core
*c
= userdata
;
1532 if (c
->core
->disallow_exit
) {
1533 pa_dbus_send_error(conn
, msg
, DBUS_ERROR_ACCESS_DENIED
, "The server is configured to disallow exiting.");
1537 pa_dbus_send_empty_reply(conn
, msg
);
1539 pa_core_exit(c
->core
, FALSE
, 0);
1542 static void handle_listen_for_signal(DBusConnection
*conn
, DBusMessage
*msg
, void *userdata
) {
1543 pa_dbusiface_core
*c
= userdata
;
1545 char **objects
= NULL
;
1553 dbus_error_init(&error
);
1555 if (!dbus_message_get_args(msg
, &error
, DBUS_TYPE_STRING
, &signal
, DBUS_TYPE_ARRAY
, DBUS_TYPE_OBJECT_PATH
, &objects
, &n_objects
, DBUS_TYPE_INVALID
)) {
1556 pa_dbus_send_error(conn
, msg
, DBUS_ERROR_INVALID_ARGS
, "%s", error
.message
);
1557 dbus_error_free(&error
);
1561 pa_dbus_protocol_add_signal_listener(c
->dbus_protocol
, conn
, *signal
? signal
: NULL
, objects
, n_objects
);
1563 pa_dbus_send_empty_reply(conn
, msg
);
1566 dbus_free_string_array(objects
);
1569 static void handle_stop_listening_for_signal(DBusConnection
*conn
, DBusMessage
*msg
, void *userdata
) {
1570 pa_dbusiface_core
*c
= userdata
;
1578 dbus_error_init(&error
);
1580 if (!dbus_message_get_args(msg
, &error
, DBUS_TYPE_STRING
, &signal
, DBUS_TYPE_INVALID
)) {
1581 pa_dbus_send_error(conn
, msg
, DBUS_ERROR_INVALID_ARGS
, "%s", error
.message
);
1582 dbus_error_free(&error
);
1586 pa_dbus_protocol_remove_signal_listener(c
->dbus_protocol
, conn
, *signal
? signal
: NULL
);
1588 pa_dbus_send_empty_reply(conn
, msg
);
1591 static void subscription_cb(pa_core
*core
, pa_subscription_event_type_t t
, uint32_t idx
, void *userdata
) {
1592 pa_dbusiface_core
*c
= userdata
;
1593 pa_dbusiface_card
*card
= NULL
;
1594 pa_dbusiface_device
*device
= NULL
;
1595 pa_dbusiface_stream
*stream
= NULL
;
1596 pa_dbusiface_sample
*sample
= NULL
;
1597 pa_dbusiface_module
*module
= NULL
;
1598 pa_dbusiface_client
*client
= NULL
;
1599 DBusMessage
*signal
= NULL
;
1600 const char *object_path
= NULL
;
1601 pa_sink
*new_fallback_sink
= NULL
;
1602 pa_source
*new_fallback_source
= NULL
;
1606 switch (t
& PA_SUBSCRIPTION_EVENT_FACILITY_MASK
) {
1607 case PA_SUBSCRIPTION_EVENT_SERVER
:
1608 new_fallback_sink
= pa_namereg_get_default_sink(core
);
1609 new_fallback_source
= pa_namereg_get_default_source(core
);
1611 if (c
->fallback_sink
!= new_fallback_sink
) {
1612 c
->fallback_sink
= new_fallback_sink
;
1614 if (new_fallback_sink
&& (device
= pa_hashmap_get(c
->sinks_by_index
, PA_UINT32_TO_PTR(new_fallback_sink
->index
)))) {
1615 object_path
= pa_dbusiface_device_get_path(device
);
1617 pa_assert_se((signal
= dbus_message_new_signal(OBJECT_PATH
, PA_DBUSIFACE_CORE_INTERFACE
, signals
[SIGNAL_FALLBACK_SINK_UPDATED
].name
)));
1618 pa_assert_se(dbus_message_append_args(signal
, DBUS_TYPE_OBJECT_PATH
, &object_path
, DBUS_TYPE_INVALID
));
1619 pa_dbus_protocol_send_signal(c
->dbus_protocol
, signal
);
1620 dbus_message_unref(signal
);
1625 if (c
->fallback_source
!= new_fallback_source
) {
1626 c
->fallback_source
= new_fallback_source
;
1628 if (new_fallback_source
&& (device
= pa_hashmap_get(c
->sources_by_index
, PA_UINT32_TO_PTR(new_fallback_source
->index
)))) {
1629 object_path
= pa_dbusiface_device_get_path(device
);
1631 pa_assert_se((signal
= dbus_message_new_signal(OBJECT_PATH
, PA_DBUSIFACE_CORE_INTERFACE
, signals
[SIGNAL_FALLBACK_SOURCE_UPDATED
].name
)));
1632 pa_assert_se(dbus_message_append_args(signal
, DBUS_TYPE_OBJECT_PATH
, &object_path
, DBUS_TYPE_INVALID
));
1633 pa_dbus_protocol_send_signal(c
->dbus_protocol
, signal
);
1634 dbus_message_unref(signal
);
1640 case PA_SUBSCRIPTION_EVENT_CARD
:
1641 if ((t
& PA_SUBSCRIPTION_EVENT_TYPE_MASK
) == PA_SUBSCRIPTION_EVENT_NEW
) {
1642 if (!(card
= pa_hashmap_get(c
->cards
, PA_UINT32_TO_PTR(idx
)))) {
1643 card
= pa_dbusiface_card_new(pa_idxset_get_by_index(core
->cards
, idx
), OBJECT_PATH
);
1644 pa_hashmap_put(c
->cards
, PA_UINT32_TO_PTR(idx
), card
);
1647 object_path
= pa_dbusiface_card_get_path(card
);
1649 pa_assert_se((signal
= dbus_message_new_signal(OBJECT_PATH
, PA_DBUSIFACE_CORE_INTERFACE
, signals
[SIGNAL_NEW_CARD
].name
)));
1650 pa_assert_se(dbus_message_append_args(signal
, DBUS_TYPE_OBJECT_PATH
, &object_path
, DBUS_TYPE_INVALID
));
1652 } else if ((t
& PA_SUBSCRIPTION_EVENT_TYPE_MASK
) == PA_SUBSCRIPTION_EVENT_REMOVE
) {
1653 pa_assert_se((card
= pa_hashmap_remove(c
->cards
, PA_UINT32_TO_PTR(idx
))));
1655 object_path
= pa_dbusiface_card_get_path(card
);
1657 pa_assert_se((signal
= dbus_message_new_signal(OBJECT_PATH
, PA_DBUSIFACE_CORE_INTERFACE
, signals
[SIGNAL_CARD_REMOVED
].name
)));
1658 pa_assert_se(dbus_message_append_args(signal
, DBUS_TYPE_OBJECT_PATH
, &object_path
, DBUS_TYPE_INVALID
));
1660 pa_dbusiface_card_free(card
);
1664 case PA_SUBSCRIPTION_EVENT_SINK
:
1665 if ((t
& PA_SUBSCRIPTION_EVENT_TYPE_MASK
) == PA_SUBSCRIPTION_EVENT_NEW
) {
1666 pa_sink
*sink
= pa_idxset_get_by_index(core
->sinks
, idx
);
1668 if (!(device
= pa_hashmap_get(c
->sinks_by_index
, PA_UINT32_TO_PTR(idx
)))) {
1669 device
= pa_dbusiface_device_new_sink(sink
, OBJECT_PATH
);
1670 pa_hashmap_put(c
->sinks_by_index
, PA_UINT32_TO_PTR(idx
), device
);
1671 pa_hashmap_put(c
->sinks_by_path
, pa_dbusiface_device_get_path(device
), device
);
1674 object_path
= pa_dbusiface_device_get_path(device
);
1676 pa_assert_se((signal
= dbus_message_new_signal(OBJECT_PATH
, PA_DBUSIFACE_CORE_INTERFACE
, signals
[SIGNAL_NEW_SINK
].name
)));
1677 pa_assert_se(dbus_message_append_args(signal
, DBUS_TYPE_OBJECT_PATH
, &object_path
, DBUS_TYPE_INVALID
));
1679 pa_dbus_protocol_send_signal(c
->dbus_protocol
, signal
);
1680 dbus_message_unref(signal
);
1683 if (c
->fallback_sink
&& pa_streq(c
->fallback_sink
->name
, sink
->name
)) {
1684 /* We have got default sink change event, but at that point
1685 * the D-Bus sink object wasn't created yet. Now that the
1686 * object is created, let's send the fallback sink change
1688 pa_assert_se((signal
= dbus_message_new_signal(OBJECT_PATH
, PA_DBUSIFACE_CORE_INTERFACE
, signals
[SIGNAL_FALLBACK_SINK_UPDATED
].name
)));
1689 pa_assert_se(dbus_message_append_args(signal
, DBUS_TYPE_OBJECT_PATH
, &object_path
, DBUS_TYPE_INVALID
));
1691 pa_dbus_protocol_send_signal(c
->dbus_protocol
, signal
);
1692 dbus_message_unref(signal
);
1696 } else if ((t
& PA_SUBSCRIPTION_EVENT_TYPE_MASK
) == PA_SUBSCRIPTION_EVENT_REMOVE
) {
1697 pa_assert_se((device
= pa_hashmap_remove(c
->sinks_by_index
, PA_UINT32_TO_PTR(idx
))));
1698 object_path
= pa_dbusiface_device_get_path(device
);
1699 pa_assert_se(pa_hashmap_remove(c
->sinks_by_path
, object_path
));
1701 pa_assert_se((signal
= dbus_message_new_signal(OBJECT_PATH
, PA_DBUSIFACE_CORE_INTERFACE
, signals
[SIGNAL_SINK_REMOVED
].name
)));
1702 pa_assert_se(dbus_message_append_args(signal
, DBUS_TYPE_OBJECT_PATH
, &object_path
, DBUS_TYPE_INVALID
));
1704 pa_dbusiface_device_free(device
);
1708 case PA_SUBSCRIPTION_EVENT_SOURCE
:
1709 if ((t
& PA_SUBSCRIPTION_EVENT_TYPE_MASK
) == PA_SUBSCRIPTION_EVENT_NEW
) {
1710 pa_source
*source
= pa_idxset_get_by_index(core
->sources
, idx
);
1712 if (!(device
= pa_hashmap_get(c
->sources_by_index
, PA_UINT32_TO_PTR(idx
)))) {
1713 device
= pa_dbusiface_device_new_source(source
, OBJECT_PATH
);
1714 pa_hashmap_put(c
->sources_by_index
, PA_UINT32_TO_PTR(idx
), device
);
1715 pa_hashmap_put(c
->sources_by_path
, pa_dbusiface_device_get_path(device
), device
);
1718 object_path
= pa_dbusiface_device_get_path(device
);
1720 pa_assert_se((signal
= dbus_message_new_signal(OBJECT_PATH
, PA_DBUSIFACE_CORE_INTERFACE
, signals
[SIGNAL_NEW_SOURCE
].name
)));
1721 pa_assert_se(dbus_message_append_args(signal
, DBUS_TYPE_OBJECT_PATH
, &object_path
, DBUS_TYPE_INVALID
));
1723 pa_dbus_protocol_send_signal(c
->dbus_protocol
, signal
);
1724 dbus_message_unref(signal
);
1727 if (c
->fallback_source
&& pa_streq(c
->fallback_source
->name
, source
->name
)) {
1728 /* We have got default source change event, but at that
1729 * point the D-Bus source object wasn't created yet. Now
1730 * that the object is created, let's send the fallback
1731 * source change signal. */
1732 pa_assert_se((signal
= dbus_message_new_signal(OBJECT_PATH
, PA_DBUSIFACE_CORE_INTERFACE
, signals
[SIGNAL_FALLBACK_SOURCE_UPDATED
].name
)));
1733 pa_assert_se(dbus_message_append_args(signal
, DBUS_TYPE_OBJECT_PATH
, &object_path
, DBUS_TYPE_INVALID
));
1735 pa_dbus_protocol_send_signal(c
->dbus_protocol
, signal
);
1736 dbus_message_unref(signal
);
1740 } else if ((t
& PA_SUBSCRIPTION_EVENT_TYPE_MASK
) == PA_SUBSCRIPTION_EVENT_REMOVE
) {
1741 pa_assert_se((device
= pa_hashmap_remove(c
->sources_by_index
, PA_UINT32_TO_PTR(idx
))));
1742 object_path
= pa_dbusiface_device_get_path(device
);
1743 pa_assert_se(pa_hashmap_remove(c
->sources_by_path
, object_path
));
1745 pa_assert_se((signal
= dbus_message_new_signal(OBJECT_PATH
, PA_DBUSIFACE_CORE_INTERFACE
, signals
[SIGNAL_SOURCE_REMOVED
].name
)));
1746 pa_assert_se(dbus_message_append_args(signal
, DBUS_TYPE_OBJECT_PATH
, &object_path
, DBUS_TYPE_INVALID
));
1748 pa_dbusiface_device_free(device
);
1752 case PA_SUBSCRIPTION_EVENT_SINK_INPUT
:
1753 if ((t
& PA_SUBSCRIPTION_EVENT_TYPE_MASK
) == PA_SUBSCRIPTION_EVENT_NEW
) {
1754 if (!(stream
= pa_hashmap_get(c
->playback_streams
, PA_UINT32_TO_PTR(idx
)))) {
1755 stream
= pa_dbusiface_stream_new_playback(pa_idxset_get_by_index(core
->sink_inputs
, idx
), OBJECT_PATH
);
1756 pa_hashmap_put(c
->playback_streams
, PA_UINT32_TO_PTR(idx
), stream
);
1759 object_path
= pa_dbusiface_stream_get_path(stream
);
1761 pa_assert_se((signal
= dbus_message_new_signal(OBJECT_PATH
, PA_DBUSIFACE_CORE_INTERFACE
, signals
[SIGNAL_NEW_PLAYBACK_STREAM
].name
)));
1762 pa_assert_se(dbus_message_append_args(signal
, DBUS_TYPE_OBJECT_PATH
, &object_path
, DBUS_TYPE_INVALID
));
1764 } else if ((t
& PA_SUBSCRIPTION_EVENT_TYPE_MASK
) == PA_SUBSCRIPTION_EVENT_REMOVE
) {
1765 pa_assert_se((stream
= pa_hashmap_remove(c
->playback_streams
, PA_UINT32_TO_PTR(idx
))));
1767 object_path
= pa_dbusiface_stream_get_path(stream
);
1769 pa_assert_se((signal
= dbus_message_new_signal(OBJECT_PATH
, PA_DBUSIFACE_CORE_INTERFACE
, signals
[SIGNAL_PLAYBACK_STREAM_REMOVED
].name
)));
1770 pa_assert_se(dbus_message_append_args(signal
, DBUS_TYPE_OBJECT_PATH
, &object_path
, DBUS_TYPE_INVALID
));
1772 pa_dbusiface_stream_free(stream
);
1776 case PA_SUBSCRIPTION_EVENT_SOURCE_OUTPUT
:
1777 if ((t
& PA_SUBSCRIPTION_EVENT_TYPE_MASK
) == PA_SUBSCRIPTION_EVENT_NEW
) {
1778 if (!(stream
= pa_hashmap_get(c
->record_streams
, PA_UINT32_TO_PTR(idx
)))) {
1779 stream
= pa_dbusiface_stream_new_record(pa_idxset_get_by_index(core
->source_outputs
, idx
), OBJECT_PATH
);
1780 pa_hashmap_put(c
->record_streams
, PA_UINT32_TO_PTR(idx
), stream
);
1783 object_path
= pa_dbusiface_stream_get_path(stream
);
1785 pa_assert_se((signal
= dbus_message_new_signal(OBJECT_PATH
, PA_DBUSIFACE_CORE_INTERFACE
, signals
[SIGNAL_NEW_RECORD_STREAM
].name
)));
1786 pa_assert_se(dbus_message_append_args(signal
, DBUS_TYPE_OBJECT_PATH
, &object_path
, DBUS_TYPE_INVALID
));
1788 } else if ((t
& PA_SUBSCRIPTION_EVENT_TYPE_MASK
) == PA_SUBSCRIPTION_EVENT_REMOVE
) {
1789 pa_assert_se((stream
= pa_hashmap_remove(c
->record_streams
, PA_UINT32_TO_PTR(idx
))));
1791 object_path
= pa_dbusiface_stream_get_path(stream
);
1793 pa_assert_se((signal
= dbus_message_new_signal(OBJECT_PATH
, PA_DBUSIFACE_CORE_INTERFACE
, signals
[SIGNAL_RECORD_STREAM_REMOVED
].name
)));
1794 pa_assert_se(dbus_message_append_args(signal
, DBUS_TYPE_OBJECT_PATH
, &object_path
, DBUS_TYPE_INVALID
));
1796 pa_dbusiface_stream_free(stream
);
1800 case PA_SUBSCRIPTION_EVENT_SAMPLE_CACHE
:
1801 if ((t
& PA_SUBSCRIPTION_EVENT_TYPE_MASK
) == PA_SUBSCRIPTION_EVENT_NEW
) {
1802 if (!(sample
= pa_hashmap_get(c
->samples
, PA_UINT32_TO_PTR(idx
)))) {
1803 sample
= pa_dbusiface_sample_new(pa_idxset_get_by_index(core
->scache
, idx
), OBJECT_PATH
);
1804 pa_hashmap_put(c
->samples
, PA_UINT32_TO_PTR(idx
), sample
);
1807 object_path
= pa_dbusiface_sample_get_path(sample
);
1809 pa_assert_se((signal
= dbus_message_new_signal(OBJECT_PATH
, PA_DBUSIFACE_CORE_INTERFACE
, signals
[SIGNAL_NEW_SAMPLE
].name
)));
1810 pa_assert_se(dbus_message_append_args(signal
, DBUS_TYPE_OBJECT_PATH
, &object_path
, DBUS_TYPE_INVALID
));
1812 } else if ((t
& PA_SUBSCRIPTION_EVENT_TYPE_MASK
) == PA_SUBSCRIPTION_EVENT_REMOVE
) {
1813 pa_assert_se((sample
= pa_hashmap_remove(c
->samples
, PA_UINT32_TO_PTR(idx
))));
1815 object_path
= pa_dbusiface_sample_get_path(sample
);
1817 pa_assert_se((signal
= dbus_message_new_signal(OBJECT_PATH
, PA_DBUSIFACE_CORE_INTERFACE
, signals
[SIGNAL_SAMPLE_REMOVED
].name
)));
1818 pa_assert_se(dbus_message_append_args(signal
, DBUS_TYPE_OBJECT_PATH
, &object_path
, DBUS_TYPE_INVALID
));
1820 pa_dbusiface_sample_free(sample
);
1824 case PA_SUBSCRIPTION_EVENT_MODULE
:
1825 if ((t
& PA_SUBSCRIPTION_EVENT_TYPE_MASK
) == PA_SUBSCRIPTION_EVENT_NEW
) {
1826 if (!(module
= pa_hashmap_get(c
->modules
, PA_UINT32_TO_PTR(idx
)))) {
1827 module
= pa_dbusiface_module_new(pa_idxset_get_by_index(core
->modules
, idx
), OBJECT_PATH
);
1828 pa_hashmap_put(c
->modules
, PA_UINT32_TO_PTR(idx
), module
);
1831 object_path
= pa_dbusiface_module_get_path(module
);
1833 pa_assert_se((signal
= dbus_message_new_signal(OBJECT_PATH
, PA_DBUSIFACE_CORE_INTERFACE
, signals
[SIGNAL_NEW_MODULE
].name
)));
1834 pa_assert_se(dbus_message_append_args(signal
, DBUS_TYPE_OBJECT_PATH
, &object_path
, DBUS_TYPE_INVALID
));
1836 } else if ((t
& PA_SUBSCRIPTION_EVENT_TYPE_MASK
) == PA_SUBSCRIPTION_EVENT_REMOVE
) {
1837 pa_assert_se((module
= pa_hashmap_remove(c
->modules
, PA_UINT32_TO_PTR(idx
))));
1839 object_path
= pa_dbusiface_module_get_path(module
);
1841 pa_assert_se((signal
= dbus_message_new_signal(OBJECT_PATH
, PA_DBUSIFACE_CORE_INTERFACE
, signals
[SIGNAL_MODULE_REMOVED
].name
)));
1842 pa_assert_se(dbus_message_append_args(signal
, DBUS_TYPE_OBJECT_PATH
, &object_path
, DBUS_TYPE_INVALID
));
1844 pa_dbusiface_module_free(module
);
1848 case PA_SUBSCRIPTION_EVENT_CLIENT
:
1849 if ((t
& PA_SUBSCRIPTION_EVENT_TYPE_MASK
) == PA_SUBSCRIPTION_EVENT_NEW
) {
1850 if (!(client
= pa_hashmap_get(c
->clients
, PA_UINT32_TO_PTR(idx
)))) {
1851 client
= pa_dbusiface_client_new(pa_idxset_get_by_index(core
->clients
, idx
), OBJECT_PATH
);
1852 pa_hashmap_put(c
->clients
, PA_UINT32_TO_PTR(idx
), client
);
1855 object_path
= pa_dbusiface_client_get_path(client
);
1857 pa_assert_se((signal
= dbus_message_new_signal(OBJECT_PATH
, PA_DBUSIFACE_CORE_INTERFACE
, signals
[SIGNAL_NEW_CLIENT
].name
)));
1858 pa_assert_se(dbus_message_append_args(signal
, DBUS_TYPE_OBJECT_PATH
, &object_path
, DBUS_TYPE_INVALID
));
1860 } else if ((t
& PA_SUBSCRIPTION_EVENT_TYPE_MASK
) == PA_SUBSCRIPTION_EVENT_REMOVE
) {
1861 pa_assert_se((client
= pa_hashmap_remove(c
->clients
, PA_UINT32_TO_PTR(idx
))));
1863 object_path
= pa_dbusiface_client_get_path(client
);
1865 pa_assert_se((signal
= dbus_message_new_signal(OBJECT_PATH
, PA_DBUSIFACE_CORE_INTERFACE
, signals
[SIGNAL_CLIENT_REMOVED
].name
)));
1866 pa_assert_se(dbus_message_append_args(signal
, DBUS_TYPE_OBJECT_PATH
, &object_path
, DBUS_TYPE_INVALID
));
1868 pa_dbusiface_client_free(client
);
1874 pa_dbus_protocol_send_signal(c
->dbus_protocol
, signal
);
1875 dbus_message_unref(signal
);
1879 static pa_hook_result_t
extension_registered_cb(void *hook_data
, void *call_data
, void *slot_data
) {
1880 pa_dbusiface_core
*c
= slot_data
;
1881 const char *ext_name
= call_data
;
1882 DBusMessage
*signal
= NULL
;
1885 pa_assert(ext_name
);
1887 pa_assert_se((signal
= dbus_message_new_signal(OBJECT_PATH
, PA_DBUSIFACE_CORE_INTERFACE
, signals
[SIGNAL_NEW_EXTENSION
].name
)));
1888 pa_assert_se(dbus_message_append_args(signal
, DBUS_TYPE_STRING
, &ext_name
, DBUS_TYPE_INVALID
));
1890 pa_dbus_protocol_send_signal(c
->dbus_protocol
, signal
);
1891 dbus_message_unref(signal
);
1896 static pa_hook_result_t
extension_unregistered_cb(void *hook_data
, void *call_data
, void *slot_data
) {
1897 pa_dbusiface_core
*c
= slot_data
;
1898 const char *ext_name
= call_data
;
1899 DBusMessage
*signal
= NULL
;
1902 pa_assert(ext_name
);
1904 pa_assert_se((signal
= dbus_message_new_signal(OBJECT_PATH
, PA_DBUSIFACE_CORE_INTERFACE
, signals
[SIGNAL_EXTENSION_REMOVED
].name
)));
1905 pa_assert_se(dbus_message_append_args(signal
, DBUS_TYPE_STRING
, &ext_name
, DBUS_TYPE_INVALID
));
1907 pa_dbus_protocol_send_signal(c
->dbus_protocol
, signal
);
1908 dbus_message_unref(signal
);
1913 pa_dbusiface_core
*pa_dbusiface_core_new(pa_core
*core
) {
1914 pa_dbusiface_core
*c
;
1918 pa_dbusiface_device
*device
;
1919 pa_sink_input
*sink_input
;
1920 pa_source_output
*source_output
;
1921 pa_scache_entry
*sample
;
1928 c
= pa_xnew(pa_dbusiface_core
, 1);
1929 c
->core
= pa_core_ref(core
);
1930 c
->subscription
= pa_subscription_new(core
, PA_SUBSCRIPTION_MASK_ALL
, subscription_cb
, c
);
1931 c
->dbus_protocol
= pa_dbus_protocol_get(core
);
1932 c
->cards
= pa_hashmap_new(pa_idxset_trivial_hash_func
, pa_idxset_trivial_compare_func
);
1933 c
->sinks_by_index
= pa_hashmap_new(pa_idxset_trivial_hash_func
, pa_idxset_trivial_compare_func
);
1934 c
->sinks_by_path
= pa_hashmap_new(pa_idxset_string_hash_func
, pa_idxset_string_compare_func
);
1935 c
->sources_by_index
= pa_hashmap_new(pa_idxset_trivial_hash_func
, pa_idxset_trivial_compare_func
);
1936 c
->sources_by_path
= pa_hashmap_new(pa_idxset_string_hash_func
, pa_idxset_string_compare_func
);
1937 c
->playback_streams
= pa_hashmap_new(pa_idxset_trivial_hash_func
, pa_idxset_trivial_compare_func
);
1938 c
->record_streams
= pa_hashmap_new(pa_idxset_trivial_hash_func
, pa_idxset_trivial_compare_func
);
1939 c
->samples
= pa_hashmap_new(pa_idxset_trivial_hash_func
, pa_idxset_trivial_compare_func
);
1940 c
->modules
= pa_hashmap_new(pa_idxset_trivial_hash_func
, pa_idxset_trivial_compare_func
);
1941 c
->clients
= pa_hashmap_new(pa_idxset_trivial_hash_func
, pa_idxset_trivial_compare_func
);
1942 c
->fallback_sink
= pa_namereg_get_default_sink(core
);
1943 c
->fallback_source
= pa_namereg_get_default_source(core
);
1944 c
->extension_registered_slot
= pa_dbus_protocol_hook_connect(c
->dbus_protocol
, PA_DBUS_PROTOCOL_HOOK_EXTENSION_REGISTERED
, PA_HOOK_NORMAL
, extension_registered_cb
, c
);
1945 c
->extension_unregistered_slot
= pa_dbus_protocol_hook_connect(c
->dbus_protocol
, PA_DBUS_PROTOCOL_HOOK_EXTENSION_UNREGISTERED
, PA_HOOK_NORMAL
, extension_unregistered_cb
, c
);
1946 c
->memstats
= pa_dbusiface_memstats_new(core
, OBJECT_PATH
);
1948 for (card
= pa_idxset_first(core
->cards
, &idx
); card
; card
= pa_idxset_next(core
->cards
, &idx
))
1949 pa_hashmap_put(c
->cards
, PA_UINT32_TO_PTR(idx
), pa_dbusiface_card_new(card
, OBJECT_PATH
));
1951 for (sink
= pa_idxset_first(core
->sinks
, &idx
); sink
; sink
= pa_idxset_next(core
->sinks
, &idx
)) {
1952 device
= pa_dbusiface_device_new_sink(sink
, OBJECT_PATH
);
1953 pa_hashmap_put(c
->sinks_by_index
, PA_UINT32_TO_PTR(idx
), device
);
1954 pa_hashmap_put(c
->sinks_by_path
, pa_dbusiface_device_get_path(device
), device
);
1957 for (source
= pa_idxset_first(core
->sources
, &idx
); source
; source
= pa_idxset_next(core
->sources
, &idx
)) {
1958 device
= pa_dbusiface_device_new_source(source
, OBJECT_PATH
);
1959 pa_hashmap_put(c
->sources_by_index
, PA_UINT32_TO_PTR(idx
), device
);
1960 pa_hashmap_put(c
->sources_by_path
, pa_dbusiface_device_get_path(device
), device
);
1963 for (sink_input
= pa_idxset_first(core
->sink_inputs
, &idx
); sink_input
; sink_input
= pa_idxset_next(core
->sink_inputs
, &idx
))
1964 pa_hashmap_put(c
->playback_streams
, PA_UINT32_TO_PTR(idx
), pa_dbusiface_stream_new_playback(sink_input
, OBJECT_PATH
));
1966 for (source_output
= pa_idxset_first(core
->source_outputs
, &idx
); source_output
; source_output
= pa_idxset_next(core
->source_outputs
, &idx
))
1967 pa_hashmap_put(c
->record_streams
, PA_UINT32_TO_PTR(idx
), pa_dbusiface_stream_new_record(source_output
, OBJECT_PATH
));
1969 for (sample
= pa_idxset_first(core
->scache
, &idx
); sample
; sample
= pa_idxset_next(core
->scache
, &idx
))
1970 pa_hashmap_put(c
->samples
, PA_UINT32_TO_PTR(idx
), pa_dbusiface_sample_new(sample
, OBJECT_PATH
));
1972 for (module
= pa_idxset_first(core
->modules
, &idx
); module
; module
= pa_idxset_next(core
->modules
, &idx
))
1973 pa_hashmap_put(c
->modules
, PA_UINT32_TO_PTR(idx
), pa_dbusiface_module_new(module
, OBJECT_PATH
));
1975 for (client
= pa_idxset_first(core
->clients
, &idx
); client
; client
= pa_idxset_next(core
->clients
, &idx
))
1976 pa_hashmap_put(c
->clients
, PA_UINT32_TO_PTR(idx
), pa_dbusiface_client_new(client
, OBJECT_PATH
));
1978 pa_dbus_protocol_add_interface(c
->dbus_protocol
, OBJECT_PATH
, &core_interface_info
, c
);
1983 static void free_card_cb(void *p
, void *userdata
) {
1984 pa_dbusiface_card
*c
= p
;
1988 pa_dbusiface_card_free(c
);
1991 static void free_device_cb(void *p
, void *userdata
) {
1992 pa_dbusiface_device
*d
= p
;
1996 pa_dbusiface_device_free(d
);
1999 static void free_stream_cb(void *p
, void *userdata
) {
2000 pa_dbusiface_stream
*s
= p
;
2004 pa_dbusiface_stream_free(s
);
2007 static void free_sample_cb(void *p
, void *userdata
) {
2008 pa_dbusiface_sample
*s
= p
;
2012 pa_dbusiface_sample_free(s
);
2015 static void free_module_cb(void *p
, void *userdata
) {
2016 pa_dbusiface_module
*m
= p
;
2020 pa_dbusiface_module_free(m
);
2023 static void free_client_cb(void *p
, void *userdata
) {
2024 pa_dbusiface_client
*c
= p
;
2028 pa_dbusiface_client_free(c
);
2031 void pa_dbusiface_core_free(pa_dbusiface_core
*c
) {
2034 pa_dbus_protocol_remove_interface(c
->dbus_protocol
, OBJECT_PATH
, core_interface_info
.name
);
2036 pa_subscription_free(c
->subscription
);
2037 pa_hashmap_free(c
->cards
, free_card_cb
, NULL
);
2038 pa_hashmap_free(c
->sinks_by_index
, free_device_cb
, NULL
);
2039 pa_hashmap_free(c
->sinks_by_path
, NULL
, NULL
);
2040 pa_hashmap_free(c
->sources_by_index
, free_device_cb
, NULL
);
2041 pa_hashmap_free(c
->sources_by_path
, NULL
, NULL
);
2042 pa_hashmap_free(c
->playback_streams
, free_stream_cb
, NULL
);
2043 pa_hashmap_free(c
->record_streams
, free_stream_cb
, NULL
);
2044 pa_hashmap_free(c
->samples
, free_sample_cb
, NULL
);
2045 pa_hashmap_free(c
->modules
, free_module_cb
, NULL
);
2046 pa_hashmap_free(c
->clients
, free_client_cb
, NULL
);
2047 pa_hook_slot_free(c
->extension_registered_slot
);
2048 pa_hook_slot_free(c
->extension_unregistered_slot
);
2049 pa_dbusiface_memstats_free(c
->memstats
);
2051 pa_dbus_protocol_unref(c
->dbus_protocol
);
2052 pa_core_unref(c
->core
);