core: add simple message interface

This patch adds a new feature to the core which allows to send messages
to objects. An object can register/unregister a message handler with
pa_message_handler_{register, unregister}() while a message can be sent
to the handler using the pa_message_handler_send_message() function.
A message has 4 arguments (apart from passing the core):

object_path: The path identifying the object that will receive the message
message: message command
message_parameters: A string containing additional parameters
response: Pointer to a response string that will be filled by the
          message handler. The caller is responsible to free the string.

The patch is a precondition for the following patches that allow clients
to send messages to pulseaudio objects.

There is no restriction on object names, except that an object path
always starts with a "/". The intention is to use a path-like syntax,
for example /core/sink_1 for a sink or /name/instances/index for modules.
The exact naming convention still needs to be agreed.
This commit is contained in:
Georg Chini 2019-03-26 10:41:05 +01:00 committed by Tanu Kaskinen
parent ab9fed9523
commit 755884d131
6 changed files with 162 additions and 1 deletions

View file

@ -164,7 +164,7 @@ struct pa_core {
pa_idxset *clients, *cards, *sinks, *sources, *sink_inputs, *source_outputs, *modules, *scache;
/* Some hashmaps for all sorts of entities */
pa_hashmap *namereg, *shared;
pa_hashmap *namereg, *shared, *message_handlers;
/* The default sink/source as configured by the user. If the user hasn't
* explicitly configured anything, these are set to NULL. These are strings