mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-06 13:29:56 -05:00
update upstream-2021-08-15
This commit is contained in:
parent
c8653c13fa
commit
1703683def
297 changed files with 91782 additions and 54869 deletions
|
|
@ -33,11 +33,13 @@
|
|||
#include <pulsecore/module.h>
|
||||
#include <pulsecore/core-rtclock.h>
|
||||
#include <pulsecore/core-util.h>
|
||||
#include <pulsecore/message-handler.h>
|
||||
#include <pulsecore/core-scache.h>
|
||||
#include <pulsecore/core-subscribe.h>
|
||||
#include <pulsecore/random.h>
|
||||
#include <pulsecore/log.h>
|
||||
#include <pulsecore/macro.h>
|
||||
#include <pulsecore/strbuf.h>
|
||||
|
||||
#include "core.h"
|
||||
|
||||
|
|
@ -61,6 +63,44 @@ static int core_process_msg(pa_msgobject *o, int code, void *userdata, int64_t o
|
|||
|
||||
static void core_free(pa_object *o);
|
||||
|
||||
/* Returns a list of handlers. */
|
||||
static char *message_handler_list(pa_core *c) {
|
||||
pa_json_encoder *encoder;
|
||||
void *state = NULL;
|
||||
struct pa_message_handler *handler;
|
||||
|
||||
encoder = pa_json_encoder_new();
|
||||
|
||||
pa_json_encoder_begin_element_array(encoder);
|
||||
PA_HASHMAP_FOREACH(handler, c->message_handlers, state) {
|
||||
pa_json_encoder_begin_element_object(encoder);
|
||||
|
||||
pa_json_encoder_add_member_string(encoder, "name", handler->object_path);
|
||||
pa_json_encoder_add_member_string(encoder, "description", handler->description);
|
||||
|
||||
pa_json_encoder_end_object(encoder);
|
||||
}
|
||||
pa_json_encoder_end_array(encoder);
|
||||
|
||||
return pa_json_encoder_to_string_free(encoder);
|
||||
}
|
||||
|
||||
static int core_message_handler(const char *object_path, const char *message, const pa_json_object *parameters, char **response, void *userdata) {
|
||||
pa_core *c;
|
||||
|
||||
pa_assert(c = (pa_core *) userdata);
|
||||
pa_assert(message);
|
||||
pa_assert(response);
|
||||
pa_assert(pa_safe_streq(object_path, "/core"));
|
||||
|
||||
if (pa_streq(message, "list-handlers")) {
|
||||
*response = message_handler_list(c);
|
||||
return PA_OK;
|
||||
}
|
||||
|
||||
return -PA_ERR_NOTIMPLEMENTED;
|
||||
}
|
||||
|
||||
pa_core* pa_core_new(pa_mainloop_api *m, bool shared, bool enable_memfd, size_t shm_size) {
|
||||
pa_core* c;
|
||||
pa_mempool *pool;
|
||||
|
|
@ -105,6 +145,8 @@ pa_core* pa_core_new(pa_mainloop_api *m, bool shared, bool enable_memfd, size_t
|
|||
c->shared = pa_hashmap_new(pa_idxset_string_hash_func, pa_idxset_string_compare_func);
|
||||
c->message_handlers = pa_hashmap_new(pa_idxset_string_hash_func, pa_idxset_string_compare_func);
|
||||
|
||||
pa_message_handler_register(c, "/core", "Core message handler", core_message_handler, (void *) c);
|
||||
|
||||
c->default_source = NULL;
|
||||
c->default_sink = NULL;
|
||||
|
||||
|
|
@ -159,10 +201,6 @@ pa_core* pa_core_new(pa_mainloop_api *m, bool shared, bool enable_memfd, size_t
|
|||
pa_check_signal_is_blocked(SIGPIPE);
|
||||
#endif
|
||||
|
||||
pa_core_check_idle(c);
|
||||
|
||||
c->state = PA_CORE_RUNNING;
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
|
|
@ -206,6 +244,8 @@ static void core_free(pa_object *o) {
|
|||
pa_assert(pa_hashmap_isempty(c->shared));
|
||||
pa_hashmap_free(c->shared);
|
||||
|
||||
pa_message_handler_unregister(c, "/core");
|
||||
|
||||
pa_assert(pa_hashmap_isempty(c->message_handlers));
|
||||
pa_hashmap_free(c->message_handlers);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue