mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-15 06:59:58 -05:00
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:
parent
ab9fed9523
commit
755884d131
6 changed files with 162 additions and 1 deletions
50
src/pulsecore/message-handler.h
Normal file
50
src/pulsecore/message-handler.h
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
#ifndef foocoremessageshfoo
|
||||
#define foocoremessageshfoo
|
||||
|
||||
/***
|
||||
This file is part of PulseAudio.
|
||||
|
||||
PulseAudio is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published
|
||||
by the Free Software Foundation; either version 2.1 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
PulseAudio is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with PulseAudio; if not, see <http://www.gnu.org/licenses/>.
|
||||
***/
|
||||
|
||||
#include <pulsecore/core.h>
|
||||
|
||||
/* Message handler types and functions */
|
||||
|
||||
/* Prototype for message callback */
|
||||
typedef int (*pa_message_handler_cb_t)(
|
||||
const char *object_path,
|
||||
const char *message,
|
||||
const char *message_parameters,
|
||||
char **response,
|
||||
void *userdata);
|
||||
|
||||
/* Message handler object */
|
||||
struct pa_message_handler {
|
||||
char *object_path;
|
||||
char *description;
|
||||
pa_message_handler_cb_t callback;
|
||||
void *userdata;
|
||||
};
|
||||
|
||||
/* Handler registration */
|
||||
void pa_message_handler_register(pa_core *c, const char *object_path, const char *description, pa_message_handler_cb_t cb, void *userdata);
|
||||
void pa_message_handler_unregister(pa_core *c, const char *object_path);
|
||||
|
||||
/* Send message to the specified object path */
|
||||
int pa_message_handler_send_message(pa_core *c, const char *object_path, const char *message, const char *message_parameters, char **response);
|
||||
|
||||
/* Set handler description */
|
||||
int pa_message_handler_set_description(pa_core *c, const char *object_path, const char *description);
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue