mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-03 09:01:54 -05:00
Use int instead of bool as result
Prefer to use an int return from a function instead of bool because it can contain more info about failures.
This commit is contained in:
parent
e5e360d5df
commit
4d6ac37398
38 changed files with 308 additions and 297 deletions
|
|
@ -177,8 +177,6 @@ typedef int (*spa_handle_factory_enum_func_t) (const struct spa_handle_factory *
|
|||
*/
|
||||
int spa_handle_factory_enum(const struct spa_handle_factory **factory, uint32_t *index);
|
||||
|
||||
void spa_handle_factory_register(const struct spa_handle_factory *factory);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -264,6 +264,8 @@ static const struct spa_handle_factory logger_factory = {
|
|||
impl_enum_interface_info,
|
||||
};
|
||||
|
||||
int spa_handle_factory_register(const struct spa_handle_factory *factory);
|
||||
|
||||
static void reg(void) __attribute__ ((constructor));
|
||||
static void reg(void)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -778,6 +778,8 @@ static const struct spa_handle_factory loop_factory = {
|
|||
impl_enum_interface_info
|
||||
};
|
||||
|
||||
int spa_handle_factory_register(const struct spa_handle_factory *factory);
|
||||
|
||||
static void reg(void) __attribute__ ((constructor));
|
||||
static void reg(void)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -211,6 +211,8 @@ static const struct spa_handle_factory type_map_factory = {
|
|||
impl_enum_interface_info,
|
||||
};
|
||||
|
||||
int spa_handle_factory_register(const struct spa_handle_factory *factory);
|
||||
|
||||
static void reg(void) __attribute__ ((constructor));
|
||||
static void reg(void)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -27,13 +27,15 @@
|
|||
static const struct spa_handle_factory *factories[MAX_FACTORIES];
|
||||
static int n_factories;
|
||||
|
||||
void
|
||||
spa_handle_factory_register(const struct spa_handle_factory *factory)
|
||||
int spa_handle_factory_register(const struct spa_handle_factory *factory)
|
||||
{
|
||||
if (n_factories < MAX_FACTORIES)
|
||||
factories[n_factories++] = factory;
|
||||
else
|
||||
else {
|
||||
fprintf(stderr, "too many factories\n");
|
||||
return -ENOMEM;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
|
|
|
|||
|
|
@ -34,13 +34,13 @@
|
|||
|
||||
#define DEFAULT_CONFIG_FILE PIPEWIRE_CONFIG_DIR "/pipewire.conf"
|
||||
|
||||
static bool
|
||||
static int
|
||||
parse_line(struct pw_daemon_config *config,
|
||||
const char *filename, char *line, unsigned int lineno, char **err)
|
||||
{
|
||||
struct pw_command *command = NULL;
|
||||
char *p;
|
||||
bool ret = true;
|
||||
int ret = 0;
|
||||
char *local_err = NULL;
|
||||
|
||||
/* search for comments */
|
||||
|
|
@ -51,12 +51,12 @@ parse_line(struct pw_daemon_config *config,
|
|||
pw_strip(line, "\n\r \t");
|
||||
|
||||
if (*line == '\0') /* empty line */
|
||||
return true;
|
||||
return 0;
|
||||
|
||||
if ((command = pw_command_parse(line, &local_err)) == NULL) {
|
||||
asprintf(err, "%s:%u: %s", filename, lineno, local_err);
|
||||
free(local_err);
|
||||
ret = false;
|
||||
ret = -EINVAL;
|
||||
} else {
|
||||
spa_list_append(&config->commands, &command->link);
|
||||
}
|
||||
|
|
@ -103,9 +103,9 @@ void pw_daemon_config_free(struct pw_daemon_config *config)
|
|||
*
|
||||
* Loads PipeWire config from @filename.
|
||||
*
|
||||
* Returns: %true on success, otherwise %false and @err is set.
|
||||
* Returns: 0 on success, otherwise < 0 and @err is set.
|
||||
*/
|
||||
bool pw_daemon_config_load_file(struct pw_daemon_config *config, const char *filename, char **err)
|
||||
int pw_daemon_config_load_file(struct pw_daemon_config *config, const char *filename, char **err)
|
||||
{
|
||||
unsigned int line;
|
||||
FILE *f;
|
||||
|
|
@ -133,18 +133,18 @@ bool pw_daemon_config_load_file(struct pw_daemon_config *config, const char *fil
|
|||
|
||||
line++;
|
||||
|
||||
if (!parse_line(config, filename, buf, line, err))
|
||||
if (parse_line(config, filename, buf, line, err) != 0)
|
||||
goto parse_failed;
|
||||
}
|
||||
fclose(f);
|
||||
|
||||
return true;
|
||||
return 0;
|
||||
|
||||
parse_failed:
|
||||
read_error:
|
||||
fclose(f);
|
||||
open_error:
|
||||
return false;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -155,9 +155,9 @@ bool pw_daemon_config_load_file(struct pw_daemon_config *config, const char *fil
|
|||
* Loads the default config file for PipeWire. The filename can be overridden with
|
||||
* an evironment variable PIPEWIRE_CONFIG_FILE.
|
||||
*
|
||||
* Return: %true on success, otherwise %false and @err is set.
|
||||
* Return: 0 on success, otherwise < 0 and @err is set.
|
||||
*/
|
||||
bool pw_daemon_config_load(struct pw_daemon_config *config, char **err)
|
||||
int pw_daemon_config_load(struct pw_daemon_config *config, char **err)
|
||||
{
|
||||
const char *filename;
|
||||
|
||||
|
|
@ -178,19 +178,18 @@ bool pw_daemon_config_load(struct pw_daemon_config *config, char **err)
|
|||
* Run all commands that have been parsed. The list of commands will be cleared
|
||||
* when this function has been called.
|
||||
*
|
||||
* Returns: %true if all commands where executed with success, otherwise %false.
|
||||
* Returns: 0 if all commands where executed with success, otherwise < 0.
|
||||
*/
|
||||
bool pw_daemon_config_run_commands(struct pw_daemon_config *config, struct pw_core *core)
|
||||
int pw_daemon_config_run_commands(struct pw_daemon_config *config, struct pw_core *core)
|
||||
{
|
||||
char *err = NULL;
|
||||
bool ret = true;
|
||||
int ret = 0;
|
||||
struct pw_command *command, *tmp;
|
||||
|
||||
spa_list_for_each(command, &config->commands, link) {
|
||||
if (!pw_command_run(command, core, &err)) {
|
||||
if ((ret = pw_command_run(command, core, &err)) < 0) {
|
||||
pw_log_warn("could not run command %s: %s", command->args[0], err);
|
||||
free(err);
|
||||
ret = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -31,20 +31,15 @@ struct pw_daemon_config {
|
|||
struct spa_list commands;
|
||||
};
|
||||
|
||||
struct pw_daemon_config *
|
||||
pw_daemon_config_new(void);
|
||||
struct pw_daemon_config * pw_daemon_config_new(void);
|
||||
|
||||
void
|
||||
pw_daemon_config_free(struct pw_daemon_config *config);
|
||||
void pw_daemon_config_free(struct pw_daemon_config *config);
|
||||
|
||||
bool
|
||||
pw_daemon_config_load_file(struct pw_daemon_config *config, const char *filename, char **err);
|
||||
int pw_daemon_config_load_file(struct pw_daemon_config *config, const char *filename, char **err);
|
||||
|
||||
bool
|
||||
pw_daemon_config_load(struct pw_daemon_config *config, char **err);
|
||||
int pw_daemon_config_load(struct pw_daemon_config *config, char **err);
|
||||
|
||||
bool
|
||||
pw_daemon_config_run_commands(struct pw_daemon_config *config, struct pw_core *core);
|
||||
int pw_daemon_config_run_commands(struct pw_daemon_config *config, struct pw_core *core);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ int main(int argc, char *argv[])
|
|||
|
||||
/* parse configuration */
|
||||
config = pw_daemon_config_new();
|
||||
if (!pw_daemon_config_load(config, &err)) {
|
||||
if (pw_daemon_config_load(config, &err) < 0) {
|
||||
pw_log_error("failed to parse config: %s", err);
|
||||
free(err);
|
||||
return -1;
|
||||
|
|
@ -58,7 +58,7 @@ int main(int argc, char *argv[])
|
|||
|
||||
core = pw_core_new(pw_main_loop_get_loop(loop), props);
|
||||
|
||||
if (!pw_daemon_config_run_commands(config, core)) {
|
||||
if (pw_daemon_config_run_commands(config, core) < 0) {
|
||||
pw_log_error("failed to run config commands");
|
||||
return -1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -81,8 +81,8 @@ struct pw_client_node_transport {
|
|||
/** Get next message from a transport
|
||||
* \param trans the transport to get the message of
|
||||
* \param[out] message the message to read
|
||||
* \return 0 on success, < 0 on error, SPA_RESULT_ENUM_END when no more messages
|
||||
* are available.
|
||||
* \return < 0 on error, 1 when a message is available,
|
||||
* 0 when no more messages are available.
|
||||
*
|
||||
* Get the skeleton next message from \a trans into \a message. This function will
|
||||
* only read the head and object body of the message.
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ extern "C" {
|
|||
#define PW_TYPE_PROTOCOL_NATIVE_BASE PW_TYPE_PROTOCOL__Native ":"
|
||||
|
||||
struct pw_protocol_native_demarshal {
|
||||
bool (*func) (void *object, void *data, size_t size);
|
||||
int (*func) (void *object, void *data, size_t size);
|
||||
|
||||
#define PW_PROTOCOL_NATIVE_REMAP (1<<0)
|
||||
#define PW_PROTOCOL_NATIVE_PERM_W (1<<1)
|
||||
|
|
|
|||
|
|
@ -359,12 +359,15 @@ static const struct pw_core_events core_events = {
|
|||
*
|
||||
* Returns: a new #struct impl
|
||||
*/
|
||||
static bool module_init(struct pw_module *module, struct pw_properties *properties)
|
||||
static int module_init(struct pw_module *module, struct pw_properties *properties)
|
||||
{
|
||||
struct pw_core *core = pw_module_get_core(module);
|
||||
struct impl *impl;
|
||||
|
||||
impl = calloc(1, sizeof(struct impl));
|
||||
if (impl == NULL)
|
||||
return -ENOMEM;
|
||||
|
||||
pw_log_debug("module %p: new", impl);
|
||||
|
||||
impl->core = core;
|
||||
|
|
@ -377,10 +380,10 @@ static bool module_init(struct pw_module *module, struct pw_properties *properti
|
|||
pw_core_add_listener(core, &impl->core_listener, &core_events, impl);
|
||||
pw_module_add_listener(module, &impl->module_listener, &module_events, impl);
|
||||
|
||||
return impl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool pipewire__module_init(struct pw_module *module, const char *args)
|
||||
int pipewire__module_init(struct pw_module *module, const char *args)
|
||||
{
|
||||
return module_init(module, NULL);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ static const struct pw_module_events module_events = {
|
|||
.destroy = module_destroy,
|
||||
};
|
||||
|
||||
static bool module_init(struct pw_module *module, struct pw_properties *properties)
|
||||
static int module_init(struct pw_module *module, struct pw_properties *properties)
|
||||
{
|
||||
struct pw_core *core = pw_module_get_core(module);
|
||||
struct pw_type *t = pw_core_get_type(core);
|
||||
|
|
@ -118,7 +118,7 @@ static bool module_init(struct pw_module *module, struct pw_properties *properti
|
|||
NULL,
|
||||
sizeof(*data));
|
||||
if (factory == NULL)
|
||||
return false;
|
||||
return -ENOMEM;
|
||||
|
||||
data = pw_factory_get_user_data(factory);
|
||||
data->this = factory;
|
||||
|
|
@ -137,10 +137,10 @@ static bool module_init(struct pw_module *module, struct pw_properties *properti
|
|||
|
||||
pw_module_add_listener(module, &data->module_listener, &module_events, data);
|
||||
|
||||
return true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool pipewire__module_init(struct pw_module *module, const char *args)
|
||||
int pipewire__module_init(struct pw_module *module, const char *args)
|
||||
{
|
||||
return module_init(module, NULL);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -149,7 +149,7 @@ static void client_node_marshal_destroy(void *object)
|
|||
pw_protocol_native_end_proxy(proxy, b);
|
||||
}
|
||||
|
||||
static bool client_node_demarshal_add_mem(void *object, void *data, size_t size)
|
||||
static int client_node_demarshal_add_mem(void *object, void *data, size_t size)
|
||||
{
|
||||
struct pw_proxy *proxy = object;
|
||||
struct spa_pod_parser prs;
|
||||
|
|
@ -163,7 +163,7 @@ static bool client_node_demarshal_add_mem(void *object, void *data, size_t size)
|
|||
"I", &type,
|
||||
"i", &memfd_idx,
|
||||
"i", &flags, NULL) < 0)
|
||||
return false;
|
||||
return -EINVAL;
|
||||
|
||||
memfd = pw_protocol_native_get_proxy_fd(proxy, memfd_idx);
|
||||
|
||||
|
|
@ -171,10 +171,10 @@ static bool client_node_demarshal_add_mem(void *object, void *data, size_t size)
|
|||
mem_id,
|
||||
type,
|
||||
memfd, flags);
|
||||
return true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static bool client_node_demarshal_transport(void *object, void *data, size_t size)
|
||||
static int client_node_demarshal_transport(void *object, void *data, size_t size)
|
||||
{
|
||||
struct pw_proxy *proxy = object;
|
||||
struct spa_pod_parser prs;
|
||||
|
|
@ -192,23 +192,23 @@ static bool client_node_demarshal_transport(void *object, void *data, size_t siz
|
|||
"i", &memfd_idx,
|
||||
"i", &info.offset,
|
||||
"i", &info.size, NULL) < 0)
|
||||
return false;
|
||||
return -EINVAL;
|
||||
|
||||
readfd = pw_protocol_native_get_proxy_fd(proxy, ridx);
|
||||
writefd = pw_protocol_native_get_proxy_fd(proxy, widx);
|
||||
info.memfd = pw_protocol_native_get_proxy_fd(proxy, memfd_idx);
|
||||
|
||||
if (readfd == -1 || writefd == -1 || info.memfd == -1)
|
||||
return false;
|
||||
return -EINVAL;
|
||||
|
||||
transport = pw_client_node_transport_new_from_info(&info);
|
||||
|
||||
pw_proxy_notify(proxy, struct pw_client_node_proxy_events, transport, node_id,
|
||||
readfd, writefd, transport);
|
||||
return true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static bool client_node_demarshal_set_param(void *object, void *data, size_t size)
|
||||
static int client_node_demarshal_set_param(void *object, void *data, size_t size)
|
||||
{
|
||||
struct pw_proxy *proxy = object;
|
||||
struct spa_pod_parser prs;
|
||||
|
|
@ -222,13 +222,13 @@ static bool client_node_demarshal_set_param(void *object, void *data, size_t siz
|
|||
"I", &id,
|
||||
"i", &flags,
|
||||
"O", ¶m, NULL) < 0)
|
||||
return false;
|
||||
return -EINVAL;
|
||||
|
||||
pw_proxy_notify(proxy, struct pw_client_node_proxy_events, set_param, seq, id, flags, param);
|
||||
return true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static bool client_node_demarshal_event_event(void *object, void *data, size_t size)
|
||||
static int client_node_demarshal_event_event(void *object, void *data, size_t size)
|
||||
{
|
||||
struct pw_proxy *proxy = object;
|
||||
struct spa_pod_parser prs;
|
||||
|
|
@ -236,13 +236,13 @@ static bool client_node_demarshal_event_event(void *object, void *data, size_t s
|
|||
|
||||
spa_pod_parser_init(&prs, data, size, 0);
|
||||
if (spa_pod_parser_get(&prs, "[ O", &event, NULL) < 0)
|
||||
return false;
|
||||
return -EINVAL;
|
||||
|
||||
pw_proxy_notify(proxy, struct pw_client_node_proxy_events, event, event);
|
||||
return true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static bool client_node_demarshal_command(void *object, void *data, size_t size)
|
||||
static int client_node_demarshal_command(void *object, void *data, size_t size)
|
||||
{
|
||||
struct pw_proxy *proxy = object;
|
||||
struct spa_pod_parser prs;
|
||||
|
|
@ -254,13 +254,13 @@ static bool client_node_demarshal_command(void *object, void *data, size_t size)
|
|||
"["
|
||||
"i", &seq,
|
||||
"O", &command, NULL) < 0)
|
||||
return false;
|
||||
return -EINVAL;
|
||||
|
||||
pw_proxy_notify(proxy, struct pw_client_node_proxy_events, command, seq, command);
|
||||
return true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static bool client_node_demarshal_add_port(void *object, void *data, size_t size)
|
||||
static int client_node_demarshal_add_port(void *object, void *data, size_t size)
|
||||
{
|
||||
struct pw_proxy *proxy = object;
|
||||
struct spa_pod_parser prs;
|
||||
|
|
@ -272,13 +272,13 @@ static bool client_node_demarshal_add_port(void *object, void *data, size_t size
|
|||
"i", &seq,
|
||||
"i", &direction,
|
||||
"i", &port_id, NULL) < 0)
|
||||
return false;
|
||||
return -EINVAL;
|
||||
|
||||
pw_proxy_notify(proxy, struct pw_client_node_proxy_events, add_port, seq, direction, port_id);
|
||||
return true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static bool client_node_demarshal_remove_port(void *object, void *data, size_t size)
|
||||
static int client_node_demarshal_remove_port(void *object, void *data, size_t size)
|
||||
{
|
||||
struct pw_proxy *proxy = object;
|
||||
struct spa_pod_parser prs;
|
||||
|
|
@ -290,13 +290,13 @@ static bool client_node_demarshal_remove_port(void *object, void *data, size_t s
|
|||
"i", &seq,
|
||||
"i", &direction,
|
||||
"i", &port_id, NULL) < 0)
|
||||
return false;
|
||||
return -EINVAL;
|
||||
|
||||
pw_proxy_notify(proxy, struct pw_client_node_proxy_events, remove_port, seq, direction, port_id);
|
||||
return true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static bool client_node_demarshal_port_set_param(void *object, void *data, size_t size)
|
||||
static int client_node_demarshal_port_set_param(void *object, void *data, size_t size)
|
||||
{
|
||||
struct pw_proxy *proxy = object;
|
||||
struct spa_pod_parser prs;
|
||||
|
|
@ -312,14 +312,14 @@ static bool client_node_demarshal_port_set_param(void *object, void *data, size_
|
|||
"I", &id,
|
||||
"i", &flags,
|
||||
"O", ¶m, NULL) < 0)
|
||||
return false;
|
||||
return -EINVAL;
|
||||
|
||||
pw_proxy_notify(proxy, struct pw_client_node_proxy_events, port_set_param,
|
||||
seq, direction, port_id, id, flags, param);
|
||||
return true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static bool client_node_demarshal_port_use_buffers(void *object, void *data, size_t size)
|
||||
static int client_node_demarshal_port_use_buffers(void *object, void *data, size_t size)
|
||||
{
|
||||
struct pw_proxy *proxy = object;
|
||||
struct spa_pod_parser prs;
|
||||
|
|
@ -334,7 +334,7 @@ static bool client_node_demarshal_port_use_buffers(void *object, void *data, siz
|
|||
"i", &direction,
|
||||
"i", &port_id,
|
||||
"i", &n_buffers, NULL) < 0)
|
||||
return false;
|
||||
return -EINVAL;
|
||||
|
||||
buffers = alloca(sizeof(struct pw_client_node_buffer) * n_buffers);
|
||||
for (i = 0; i < n_buffers; i++) {
|
||||
|
|
@ -346,7 +346,7 @@ static bool client_node_demarshal_port_use_buffers(void *object, void *data, siz
|
|||
"i", &buffers[i].size,
|
||||
"i", &buf->id,
|
||||
"i", &buf->n_metas, NULL) < 0)
|
||||
return false;
|
||||
return -EINVAL;
|
||||
|
||||
buf->metas = alloca(sizeof(struct spa_meta) * buf->n_metas);
|
||||
for (j = 0; j < buf->n_metas; j++) {
|
||||
|
|
@ -355,10 +355,10 @@ static bool client_node_demarshal_port_use_buffers(void *object, void *data, siz
|
|||
if (spa_pod_parser_get(&prs,
|
||||
"I", &m->type,
|
||||
"i", &m->size, NULL) < 0)
|
||||
return false;
|
||||
return -EINVAL;
|
||||
}
|
||||
if (spa_pod_parser_get(&prs, "i", &buf->n_datas, NULL) < 0)
|
||||
return false;
|
||||
return -EINVAL;
|
||||
|
||||
buf->datas = alloca(sizeof(struct spa_data) * buf->n_datas);
|
||||
for (j = 0; j < buf->n_datas; j++) {
|
||||
|
|
@ -370,7 +370,7 @@ static bool client_node_demarshal_port_use_buffers(void *object, void *data, siz
|
|||
"i", &d->flags,
|
||||
"i", &d->mapoffset,
|
||||
"i", &d->maxsize, NULL) < 0)
|
||||
return false;
|
||||
return -EINVAL;
|
||||
|
||||
d->data = SPA_UINT32_TO_PTR(data_id);
|
||||
}
|
||||
|
|
@ -379,10 +379,10 @@ static bool client_node_demarshal_port_use_buffers(void *object, void *data, siz
|
|||
direction,
|
||||
port_id,
|
||||
n_buffers, buffers);
|
||||
return true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static bool client_node_demarshal_port_command(void *object, void *data, size_t size)
|
||||
static int client_node_demarshal_port_command(void *object, void *data, size_t size)
|
||||
{
|
||||
struct pw_proxy *proxy = object;
|
||||
struct spa_pod_parser prs;
|
||||
|
|
@ -395,15 +395,15 @@ static bool client_node_demarshal_port_command(void *object, void *data, size_t
|
|||
"i", &direction,
|
||||
"i", &port_id,
|
||||
"O", &command, NULL) < 0)
|
||||
return false;
|
||||
return -EINVAL;
|
||||
|
||||
pw_proxy_notify(proxy, struct pw_client_node_proxy_events, port_command, direction,
|
||||
port_id,
|
||||
command);
|
||||
return true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static bool client_node_demarshal_port_set_io(void *object, void *data, size_t size)
|
||||
static int client_node_demarshal_port_set_io(void *object, void *data, size_t size)
|
||||
{
|
||||
struct pw_proxy *proxy = object;
|
||||
struct spa_pod_parser prs;
|
||||
|
|
@ -419,14 +419,14 @@ static bool client_node_demarshal_port_set_io(void *object, void *data, size_t s
|
|||
"i", &memid,
|
||||
"i", &off,
|
||||
"i", &sz, NULL) < 0)
|
||||
return false;
|
||||
return -EINVAL;
|
||||
|
||||
pw_proxy_notify(proxy, struct pw_client_node_proxy_events, port_set_io,
|
||||
seq,
|
||||
direction, port_id,
|
||||
id, memid,
|
||||
off, sz);
|
||||
return true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -672,7 +672,7 @@ client_node_marshal_port_set_io(void *object,
|
|||
}
|
||||
|
||||
|
||||
static bool client_node_demarshal_done(void *object, void *data, size_t size)
|
||||
static int client_node_demarshal_done(void *object, void *data, size_t size)
|
||||
{
|
||||
struct pw_resource *resource = object;
|
||||
struct spa_pod_parser prs;
|
||||
|
|
@ -683,13 +683,13 @@ static bool client_node_demarshal_done(void *object, void *data, size_t size)
|
|||
"["
|
||||
"i", &seq,
|
||||
"i", &res, NULL) < 0)
|
||||
return false;
|
||||
return -EINVAL;
|
||||
|
||||
pw_resource_do(resource, struct pw_client_node_proxy_methods, done, seq, res);
|
||||
return true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static bool client_node_demarshal_update(void *object, void *data, size_t size)
|
||||
static int client_node_demarshal_update(void *object, void *data, size_t size)
|
||||
{
|
||||
struct pw_resource *resource = object;
|
||||
struct spa_pod_parser prs;
|
||||
|
|
@ -704,22 +704,22 @@ static bool client_node_demarshal_update(void *object, void *data, size_t size)
|
|||
"i", &max_input_ports,
|
||||
"i", &max_output_ports,
|
||||
"i", &n_params, NULL) < 0)
|
||||
return false;
|
||||
return -EINVAL;
|
||||
|
||||
params = alloca(n_params * sizeof(struct spa_pod *));
|
||||
for (i = 0; i < n_params; i++)
|
||||
if (spa_pod_parser_get(&prs, "O", ¶ms[i], NULL) < 0)
|
||||
return false;
|
||||
return -EINVAL;
|
||||
|
||||
pw_resource_do(resource, struct pw_client_node_proxy_methods, update, change_mask,
|
||||
max_input_ports,
|
||||
max_output_ports,
|
||||
n_params,
|
||||
params);
|
||||
return true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static bool client_node_demarshal_port_update(void *object, void *data, size_t size)
|
||||
static int client_node_demarshal_port_update(void *object, void *data, size_t size)
|
||||
{
|
||||
struct pw_resource *resource = object;
|
||||
struct spa_pod_parser prs;
|
||||
|
|
@ -735,15 +735,15 @@ static bool client_node_demarshal_port_update(void *object, void *data, size_t s
|
|||
"i", &port_id,
|
||||
"i", &change_mask,
|
||||
"i", &n_params, NULL) < 0)
|
||||
return false;
|
||||
return -EINVAL;
|
||||
|
||||
params = alloca(n_params * sizeof(struct spa_pod *));
|
||||
for (i = 0; i < n_params; i++)
|
||||
if (spa_pod_parser_get(&prs, "O", ¶ms[i], NULL) < 0)
|
||||
return false;
|
||||
return -EINVAL;
|
||||
|
||||
if (spa_pod_parser_get(&prs, "T", &ipod, NULL) < 0)
|
||||
return false;
|
||||
return -EINVAL;
|
||||
|
||||
if (ipod) {
|
||||
struct spa_pod_parser p2;
|
||||
|
|
@ -754,7 +754,7 @@ static bool client_node_demarshal_port_update(void *object, void *data, size_t s
|
|||
"["
|
||||
"i", &info.flags,
|
||||
"i", &info.rate, NULL) < 0)
|
||||
return false;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
pw_resource_do(resource, struct pw_client_node_proxy_methods, port_update, direction,
|
||||
|
|
@ -762,26 +762,26 @@ static bool client_node_demarshal_port_update(void *object, void *data, size_t s
|
|||
change_mask,
|
||||
n_params,
|
||||
params, infop);
|
||||
return true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static bool client_node_demarshal_set_active(void *object, void *data, size_t size)
|
||||
static int client_node_demarshal_set_active(void *object, void *data, size_t size)
|
||||
{
|
||||
struct pw_resource *resource = object;
|
||||
struct spa_pod_parser prs;
|
||||
bool active;
|
||||
int active;
|
||||
|
||||
spa_pod_parser_init(&prs, data, size, 0);
|
||||
if (spa_pod_parser_get(&prs,
|
||||
"["
|
||||
"b", &active, NULL) < 0)
|
||||
return false;
|
||||
return -EINVAL;
|
||||
|
||||
pw_resource_do(resource, struct pw_client_node_proxy_methods, set_active, active);
|
||||
return true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static bool client_node_demarshal_event_method(void *object, void *data, size_t size)
|
||||
static int client_node_demarshal_event_method(void *object, void *data, size_t size)
|
||||
{
|
||||
struct pw_resource *resource = object;
|
||||
struct spa_pod_parser prs;
|
||||
|
|
@ -791,23 +791,23 @@ static bool client_node_demarshal_event_method(void *object, void *data, size_t
|
|||
if (spa_pod_parser_get(&prs,
|
||||
"["
|
||||
"O", &event, NULL) < 0)
|
||||
return false;
|
||||
return -EINVAL;
|
||||
|
||||
pw_resource_do(resource, struct pw_client_node_proxy_methods, event, event);
|
||||
return true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static bool client_node_demarshal_destroy(void *object, void *data, size_t size)
|
||||
static int client_node_demarshal_destroy(void *object, void *data, size_t size)
|
||||
{
|
||||
struct pw_resource *resource = object;
|
||||
struct spa_pod_parser prs;
|
||||
|
||||
spa_pod_parser_init(&prs, data, size, 0);
|
||||
if (spa_pod_parser_get(&prs, "[", NULL) < 0)
|
||||
return false;
|
||||
return -EINVAL;
|
||||
|
||||
pw_resource_do(resource, struct pw_client_node_proxy_methods, destroy);
|
||||
return true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct pw_client_node_proxy_methods pw_protocol_native_client_node_method_marshal = {
|
||||
|
|
|
|||
|
|
@ -150,6 +150,9 @@ static int next_message(struct pw_client_node_transport *trans, struct pw_client
|
|||
impl->current_index & (INPUT_BUFFER_SIZE - 1),
|
||||
&impl->current, sizeof(struct pw_client_node_message));
|
||||
|
||||
if (avail < SPA_POD_SIZE(&impl->current))
|
||||
return 0;
|
||||
|
||||
*message = impl->current;
|
||||
|
||||
return 1;
|
||||
|
|
|
|||
|
|
@ -752,7 +752,7 @@ static const struct pw_module_events module_events = {
|
|||
.destroy = module_destroy,
|
||||
};
|
||||
|
||||
static bool module_init(struct pw_module *module, struct pw_properties *properties)
|
||||
static int module_init(struct pw_module *module, struct pw_properties *properties)
|
||||
{
|
||||
struct pw_core *core = pw_module_get_core(module);
|
||||
struct impl *impl;
|
||||
|
|
@ -761,6 +761,9 @@ static bool module_init(struct pw_module *module, struct pw_properties *properti
|
|||
dbus_error_init(&error);
|
||||
|
||||
impl = calloc(1, sizeof(struct impl));
|
||||
if (impl == NULL)
|
||||
return -ENOMEM;
|
||||
|
||||
pw_log_debug("module %p: new", impl);
|
||||
|
||||
impl->core = core;
|
||||
|
|
@ -788,27 +791,16 @@ static bool module_init(struct pw_module *module, struct pw_properties *properti
|
|||
|
||||
pw_core_set_permission_callback(core, do_permission, impl);
|
||||
|
||||
return true;
|
||||
return 0;
|
||||
|
||||
error:
|
||||
free(impl);
|
||||
pw_log_error("Failed to connect to system bus: %s", error.message);
|
||||
dbus_error_free(&error);
|
||||
return false;
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
#if 0
|
||||
static void module_destroy(struct impl *impl)
|
||||
{
|
||||
pw_log_debug("module %p: destroy", impl);
|
||||
|
||||
dbus_connection_close(impl->bus);
|
||||
dbus_connection_unref(impl->bus);
|
||||
free(impl);
|
||||
}
|
||||
#endif
|
||||
|
||||
bool pipewire__module_init(struct pw_module *module, const char *args)
|
||||
int pipewire__module_init(struct pw_module *module, const char *args)
|
||||
{
|
||||
return module_init(module, NULL);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,8 +60,6 @@
|
|||
|
||||
int segment_num = 0;
|
||||
|
||||
typedef bool(*demarshal_func_t) (void *object, void *data, size_t size);
|
||||
|
||||
struct socket {
|
||||
int fd;
|
||||
struct sockaddr_un addr;
|
||||
|
|
@ -1504,7 +1502,7 @@ static const struct pw_module_events module_events = {
|
|||
.destroy = module_destroy,
|
||||
};
|
||||
|
||||
static bool module_init(struct pw_module *module, struct pw_properties *properties)
|
||||
static int module_init(struct pw_module *module, struct pw_properties *properties)
|
||||
{
|
||||
struct pw_core *core = pw_module_get_core(module);
|
||||
struct impl *impl;
|
||||
|
|
@ -1512,6 +1510,9 @@ static bool module_init(struct pw_module *module, struct pw_properties *properti
|
|||
bool promiscuous;
|
||||
|
||||
impl = calloc(1, sizeof(struct impl));
|
||||
if (impl == NULL)
|
||||
return -ENOMEM;
|
||||
|
||||
pw_log_debug("protocol-jack %p: new", impl);
|
||||
|
||||
impl->core = core;
|
||||
|
|
@ -1547,14 +1548,14 @@ static bool module_init(struct pw_module *module, struct pw_properties *properti
|
|||
|
||||
pw_module_add_listener(module, &impl->module_listener, &module_events, impl);
|
||||
|
||||
return true;
|
||||
return 0;
|
||||
|
||||
error:
|
||||
free(impl);
|
||||
return false;
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
bool pipewire__module_init(struct pw_module *module, const char *args)
|
||||
int pipewire__module_init(struct pw_module *module, const char *args)
|
||||
{
|
||||
return module_init(module, NULL);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -200,12 +200,15 @@ static const struct pw_module_events module_events = {
|
|||
.destroy = module_destroy,
|
||||
};
|
||||
|
||||
static bool module_init(struct pw_module *module, struct pw_properties *properties)
|
||||
static int module_init(struct pw_module *module, struct pw_properties *properties)
|
||||
{
|
||||
struct pw_core *core = pw_module_get_core(module);
|
||||
struct impl *impl;
|
||||
|
||||
impl = calloc(1, sizeof(struct impl));
|
||||
if (impl == NULL)
|
||||
return -ENOMEM;
|
||||
|
||||
pw_log_debug("module %p: new", impl);
|
||||
|
||||
impl->core = core;
|
||||
|
|
@ -221,10 +224,10 @@ static bool module_init(struct pw_module *module, struct pw_properties *properti
|
|||
|
||||
pw_module_add_listener(module, &impl->module_listener, &module_events, impl);
|
||||
|
||||
return true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool pipewire__module_init(struct pw_module *module, const char *args)
|
||||
int pipewire__module_init(struct pw_module *module, const char *args)
|
||||
{
|
||||
return module_init(module, NULL);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -625,8 +625,8 @@ static void pw_protocol_dbus_destroy(struct impl *impl)
|
|||
}
|
||||
#endif
|
||||
|
||||
bool pipewire__module_init(struct pw_module *module, const char *args)
|
||||
int pipewire__module_init(struct pw_module *module, const char *args)
|
||||
{
|
||||
pw_protocol_dbus_new(module->core, NULL);
|
||||
return TRUE;
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -219,7 +219,7 @@ process_messages(struct client_data *data)
|
|||
if (!pod_remap_data(SPA_POD_TYPE_STRUCT, message, size, &client->types))
|
||||
goto invalid_message;
|
||||
|
||||
if (!demarshal[opcode].func(resource, message, size))
|
||||
if (demarshal[opcode].func(resource, message, size) < 0)
|
||||
goto invalid_message;
|
||||
}
|
||||
return;
|
||||
|
|
@ -587,7 +587,7 @@ on_remote_data(void *data, int fd, enum spa_io mask)
|
|||
continue;
|
||||
}
|
||||
}
|
||||
if (!demarshal[opcode].func(proxy, message, size)) {
|
||||
if (demarshal[opcode].func(proxy, message, size) < 0) {
|
||||
pw_log_error ("protocol-native %p: invalid message received %u for %u", this,
|
||||
opcode, id);
|
||||
continue;
|
||||
|
|
@ -891,7 +891,7 @@ static const struct pw_module_events module_events = {
|
|||
.destroy = module_destroy,
|
||||
};
|
||||
|
||||
static bool module_init(struct pw_module *module, struct pw_properties *properties)
|
||||
static int module_init(struct pw_module *module, struct pw_properties *properties)
|
||||
{
|
||||
struct pw_core *core = pw_module_get_core(module);
|
||||
struct pw_protocol *this;
|
||||
|
|
@ -899,11 +899,11 @@ static bool module_init(struct pw_module *module, struct pw_properties *properti
|
|||
struct protocol_data *d;
|
||||
|
||||
if (pw_core_find_protocol(core, PW_TYPE_PROTOCOL__Native) != NULL)
|
||||
return true;
|
||||
return 0;
|
||||
|
||||
this = pw_protocol_new(core, PW_TYPE_PROTOCOL__Native, sizeof(struct protocol_data));
|
||||
if (this == NULL)
|
||||
return false;
|
||||
return -ENOMEM;
|
||||
|
||||
this->implementation = &protocol_impl;
|
||||
this->extension = &protocol_ext_impl;
|
||||
|
|
@ -922,15 +922,15 @@ static bool module_init(struct pw_module *module, struct pw_properties *properti
|
|||
val = pw_properties_get(pw_core_get_properties(core), PW_CORE_PROP_DAEMON);
|
||||
if (val && pw_properties_parse_bool(val)) {
|
||||
if (impl_add_server(this, core, properties) == NULL)
|
||||
return false;
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
pw_module_add_listener(module, &d->module_listener, &module_events, d);
|
||||
|
||||
return true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool pipewire__module_init(struct pw_module *module, const char *args)
|
||||
int pipewire__module_init(struct pw_module *module, const char *args)
|
||||
{
|
||||
return module_init(module, NULL);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -194,7 +194,7 @@ core_marshal_update_types_client(void *object, uint32_t first_id, const char **t
|
|||
pw_protocol_native_end_proxy(proxy, b);
|
||||
}
|
||||
|
||||
static bool core_demarshal_info(void *object, void *data, size_t size)
|
||||
static int core_demarshal_info(void *object, void *data, size_t size)
|
||||
{
|
||||
struct pw_proxy *proxy = object;
|
||||
struct spa_dict props;
|
||||
|
|
@ -213,7 +213,7 @@ static bool core_demarshal_info(void *object, void *data, size_t size)
|
|||
"s", &info.name,
|
||||
"i", &info.cookie,
|
||||
"i", &props.n_items, NULL) < 0)
|
||||
return false;
|
||||
return -EINVAL;
|
||||
|
||||
info.props = &props;
|
||||
props.items = alloca(props.n_items * sizeof(struct spa_dict_item));
|
||||
|
|
@ -222,13 +222,13 @@ static bool core_demarshal_info(void *object, void *data, size_t size)
|
|||
"s", &props.items[i].key,
|
||||
"s", &props.items[i].value,
|
||||
NULL) < 0)
|
||||
return false;
|
||||
return -EINVAL;
|
||||
}
|
||||
pw_proxy_notify(proxy, struct pw_core_proxy_events, info, &info);
|
||||
return true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static bool core_demarshal_done(void *object, void *data, size_t size)
|
||||
static int core_demarshal_done(void *object, void *data, size_t size)
|
||||
{
|
||||
struct pw_proxy *proxy = object;
|
||||
struct spa_pod_parser prs;
|
||||
|
|
@ -236,13 +236,13 @@ static bool core_demarshal_done(void *object, void *data, size_t size)
|
|||
|
||||
spa_pod_parser_init(&prs, data, size, 0);
|
||||
if (spa_pod_parser_get(&prs, "[ i", &seq, NULL) < 0)
|
||||
return false;
|
||||
return -EINVAL;
|
||||
|
||||
pw_proxy_notify(proxy, struct pw_core_proxy_events, done, seq);
|
||||
return true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static bool core_demarshal_error(void *object, void *data, size_t size)
|
||||
static int core_demarshal_error(void *object, void *data, size_t size)
|
||||
{
|
||||
struct pw_proxy *proxy = object;
|
||||
struct spa_pod_parser prs;
|
||||
|
|
@ -254,13 +254,13 @@ static bool core_demarshal_error(void *object, void *data, size_t size)
|
|||
"[ i", &id,
|
||||
"i", &res,
|
||||
"s", &error, NULL) < 0)
|
||||
return false;
|
||||
return -EINVAL;
|
||||
|
||||
pw_proxy_notify(proxy, struct pw_core_proxy_events, error, id, res, error);
|
||||
return true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static bool core_demarshal_remove_id(void *object, void *data, size_t size)
|
||||
static int core_demarshal_remove_id(void *object, void *data, size_t size)
|
||||
{
|
||||
struct pw_proxy *proxy = object;
|
||||
struct spa_pod_parser prs;
|
||||
|
|
@ -268,13 +268,13 @@ static bool core_demarshal_remove_id(void *object, void *data, size_t size)
|
|||
|
||||
spa_pod_parser_init(&prs, data, size, 0);
|
||||
if (spa_pod_parser_get(&prs, "[ i", &id, NULL) < 0)
|
||||
return false;
|
||||
return -EINVAL;
|
||||
|
||||
pw_proxy_notify(proxy, struct pw_core_proxy_events, remove_id, id);
|
||||
return true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static bool core_demarshal_update_types_client(void *object, void *data, size_t size)
|
||||
static int core_demarshal_update_types_client(void *object, void *data, size_t size)
|
||||
{
|
||||
struct pw_proxy *proxy = object;
|
||||
struct spa_pod_parser prs;
|
||||
|
|
@ -287,15 +287,15 @@ static bool core_demarshal_update_types_client(void *object, void *data, size_t
|
|||
"["
|
||||
" i", &first_id,
|
||||
" i", &n_types, NULL) < 0)
|
||||
return false;
|
||||
return -EINVAL;
|
||||
|
||||
types = alloca(n_types * sizeof(char *));
|
||||
for (i = 0; i < n_types; i++) {
|
||||
if (spa_pod_parser_get(&prs, "s", &types[i], NULL) < 0)
|
||||
return false;
|
||||
return -EINVAL;
|
||||
}
|
||||
pw_proxy_notify(proxy, struct pw_core_proxy_events, update_types, first_id, types, n_types);
|
||||
return true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void core_marshal_info(void *object, struct pw_core_info *info)
|
||||
|
|
@ -396,7 +396,7 @@ core_marshal_update_types_server(void *object, uint32_t first_id, const char **t
|
|||
pw_protocol_native_end_resource(resource, b);
|
||||
}
|
||||
|
||||
static bool core_demarshal_client_update(void *object, void *data, size_t size)
|
||||
static int core_demarshal_client_update(void *object, void *data, size_t size)
|
||||
{
|
||||
struct pw_resource *resource = object;
|
||||
struct spa_dict props;
|
||||
|
|
@ -405,7 +405,7 @@ static bool core_demarshal_client_update(void *object, void *data, size_t size)
|
|||
|
||||
spa_pod_parser_init(&prs, data, size, 0);
|
||||
if (spa_pod_parser_get(&prs, "[ i", &props.n_items, NULL) < 0)
|
||||
return false;
|
||||
return -EINVAL;
|
||||
|
||||
props.items = alloca(props.n_items * sizeof(struct spa_dict_item));
|
||||
for (i = 0; i < props.n_items; i++) {
|
||||
|
|
@ -413,13 +413,13 @@ static bool core_demarshal_client_update(void *object, void *data, size_t size)
|
|||
"s", &props.items[i].key,
|
||||
"s", &props.items[i].value,
|
||||
NULL) < 0)
|
||||
return false;
|
||||
return -EINVAL;
|
||||
}
|
||||
pw_resource_do(resource, struct pw_core_proxy_methods, client_update, &props);
|
||||
return true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static bool core_demarshal_permissions(void *object, void *data, size_t size)
|
||||
static int core_demarshal_permissions(void *object, void *data, size_t size)
|
||||
{
|
||||
struct pw_resource *resource = object;
|
||||
struct spa_dict props;
|
||||
|
|
@ -428,7 +428,7 @@ static bool core_demarshal_permissions(void *object, void *data, size_t size)
|
|||
|
||||
spa_pod_parser_init(&prs, data, size, 0);
|
||||
if (spa_pod_parser_get(&prs, "[ i", &props.n_items, NULL) < 0)
|
||||
return false;
|
||||
return -EINVAL;
|
||||
|
||||
props.items = alloca(props.n_items * sizeof(struct spa_dict_item));
|
||||
for (i = 0; i < props.n_items; i++) {
|
||||
|
|
@ -436,13 +436,13 @@ static bool core_demarshal_permissions(void *object, void *data, size_t size)
|
|||
"s", &props.items[i].key,
|
||||
"s", &props.items[i].value,
|
||||
NULL) < 0)
|
||||
return false;
|
||||
return -EINVAL;
|
||||
}
|
||||
pw_resource_do(resource, struct pw_core_proxy_methods, permissions, &props);
|
||||
return true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static bool core_demarshal_sync(void *object, void *data, size_t size)
|
||||
static int core_demarshal_sync(void *object, void *data, size_t size)
|
||||
{
|
||||
struct pw_resource *resource = object;
|
||||
struct spa_pod_parser prs;
|
||||
|
|
@ -450,13 +450,13 @@ static bool core_demarshal_sync(void *object, void *data, size_t size)
|
|||
|
||||
spa_pod_parser_init(&prs, data, size, 0);
|
||||
if (spa_pod_parser_get(&prs, "[i]", &seq, NULL) < 0)
|
||||
return false;
|
||||
return -EINVAL;
|
||||
|
||||
pw_resource_do(resource, struct pw_core_proxy_methods, sync, seq);
|
||||
return true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static bool core_demarshal_get_registry(void *object, void *data, size_t size)
|
||||
static int core_demarshal_get_registry(void *object, void *data, size_t size)
|
||||
{
|
||||
struct pw_resource *resource = object;
|
||||
struct spa_pod_parser prs;
|
||||
|
|
@ -464,13 +464,13 @@ static bool core_demarshal_get_registry(void *object, void *data, size_t size)
|
|||
|
||||
spa_pod_parser_init(&prs, data, size, 0);
|
||||
if (spa_pod_parser_get(&prs, "[ii]", &version, &new_id, NULL) < 0)
|
||||
return false;
|
||||
return -EINVAL;
|
||||
|
||||
pw_resource_do(resource, struct pw_core_proxy_methods, get_registry, version, new_id);
|
||||
return true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static bool core_demarshal_create_object(void *object, void *data, size_t size)
|
||||
static int core_demarshal_create_object(void *object, void *data, size_t size)
|
||||
{
|
||||
struct pw_resource *resource = object;
|
||||
struct spa_pod_parser prs;
|
||||
|
|
@ -485,24 +485,24 @@ static bool core_demarshal_create_object(void *object, void *data, size_t size)
|
|||
"I", &type,
|
||||
"i", &version,
|
||||
"i", &props.n_items, NULL) < 0)
|
||||
return false;
|
||||
return -EINVAL;
|
||||
|
||||
props.items = alloca(props.n_items * sizeof(struct spa_dict_item));
|
||||
for (i = 0; i < props.n_items; i++) {
|
||||
if (spa_pod_parser_get(&prs, "ss",
|
||||
&props.items[i].key, &props.items[i].value, NULL) < 0)
|
||||
return false;
|
||||
return -EINVAL;
|
||||
}
|
||||
if (spa_pod_parser_get(&prs, "i", &new_id, NULL) < 0)
|
||||
return false;
|
||||
return -EINVAL;
|
||||
|
||||
pw_resource_do(resource, struct pw_core_proxy_methods, create_object, factory_name,
|
||||
type, version,
|
||||
&props, new_id);
|
||||
return true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static bool core_demarshal_create_link(void *object, void *data, size_t size)
|
||||
static int core_demarshal_create_link(void *object, void *data, size_t size)
|
||||
{
|
||||
struct pw_resource *resource = object;
|
||||
struct spa_pod_parser prs;
|
||||
|
|
@ -520,16 +520,16 @@ static bool core_demarshal_create_link(void *object, void *data, size_t size)
|
|||
"i", &input_port_id,
|
||||
"P", &filter,
|
||||
"i", &props.n_items, NULL) < 0)
|
||||
return false;
|
||||
return -EINVAL;
|
||||
|
||||
props.items = alloca(props.n_items * sizeof(struct spa_dict_item));
|
||||
for (i = 0; i < props.n_items; i++) {
|
||||
if (spa_pod_parser_get(&prs, "ss",
|
||||
&props.items[i].key, &props.items[i].value, NULL) < 0)
|
||||
return false;
|
||||
return -EINVAL;
|
||||
}
|
||||
if (spa_pod_parser_get(&prs, "i", &new_id, NULL) < 0)
|
||||
return false;
|
||||
return -EINVAL;
|
||||
|
||||
pw_resource_do(resource, struct pw_core_proxy_methods, create_link, output_node_id,
|
||||
output_port_id,
|
||||
|
|
@ -538,10 +538,10 @@ static bool core_demarshal_create_link(void *object, void *data, size_t size)
|
|||
filter,
|
||||
&props,
|
||||
new_id);
|
||||
return true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static bool core_demarshal_update_types_server(void *object, void *data, size_t size)
|
||||
static int core_demarshal_update_types_server(void *object, void *data, size_t size)
|
||||
{
|
||||
struct pw_resource *resource = object;
|
||||
struct spa_pod_parser prs;
|
||||
|
|
@ -554,15 +554,15 @@ static bool core_demarshal_update_types_server(void *object, void *data, size_t
|
|||
"["
|
||||
"i", &first_id,
|
||||
"i", &n_types, NULL) < 0)
|
||||
return false;
|
||||
return -EINVAL;
|
||||
|
||||
types = alloca(n_types * sizeof(char *));
|
||||
for (i = 0; i < n_types; i++) {
|
||||
if (spa_pod_parser_get(&prs, "s", &types[i], NULL) < 0)
|
||||
return false;
|
||||
return -EINVAL;
|
||||
}
|
||||
pw_resource_do(resource, struct pw_core_proxy_methods, update_types, first_id, types, n_types);
|
||||
return true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void registry_marshal_global(void *object, uint32_t id, uint32_t parent_id, uint32_t permissions,
|
||||
|
|
@ -595,7 +595,7 @@ static void registry_marshal_global_remove(void *object, uint32_t id)
|
|||
pw_protocol_native_end_resource(resource, b);
|
||||
}
|
||||
|
||||
static bool registry_demarshal_bind(void *object, void *data, size_t size)
|
||||
static int registry_demarshal_bind(void *object, void *data, size_t size)
|
||||
{
|
||||
struct pw_resource *resource = object;
|
||||
struct spa_pod_parser prs;
|
||||
|
|
@ -608,10 +608,10 @@ static bool registry_demarshal_bind(void *object, void *data, size_t size)
|
|||
"I", &type,
|
||||
"i", &version,
|
||||
"i", &new_id, NULL) < 0)
|
||||
return false;
|
||||
return -EINVAL;
|
||||
|
||||
pw_resource_do(resource, struct pw_registry_proxy_methods, bind, id, type, version, new_id);
|
||||
return true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void module_marshal_info(void *object, struct pw_module_info *info)
|
||||
|
|
@ -643,7 +643,7 @@ static void module_marshal_info(void *object, struct pw_module_info *info)
|
|||
pw_protocol_native_end_resource(resource, b);
|
||||
}
|
||||
|
||||
static bool module_demarshal_info(void *object, void *data, size_t size)
|
||||
static int module_demarshal_info(void *object, void *data, size_t size)
|
||||
{
|
||||
struct pw_proxy *proxy = object;
|
||||
struct spa_pod_parser prs;
|
||||
|
|
@ -660,17 +660,17 @@ static bool module_demarshal_info(void *object, void *data, size_t size)
|
|||
"s", &info.filename,
|
||||
"s", &info.args,
|
||||
"i", &props.n_items, NULL) < 0)
|
||||
return false;
|
||||
return -EINVAL;
|
||||
|
||||
info.props = &props;
|
||||
props.items = alloca(props.n_items * sizeof(struct spa_dict_item));
|
||||
for (i = 0; i < props.n_items; i++) {
|
||||
if (spa_pod_parser_get(&prs, "ss",
|
||||
&props.items[i].key, &props.items[i].value, NULL) < 0)
|
||||
return false;
|
||||
return -EINVAL;
|
||||
}
|
||||
pw_proxy_notify(proxy, struct pw_module_proxy_events, info, &info);
|
||||
return true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void factory_marshal_info(void *object, struct pw_factory_info *info)
|
||||
|
|
@ -702,7 +702,7 @@ static void factory_marshal_info(void *object, struct pw_factory_info *info)
|
|||
pw_protocol_native_end_resource(resource, b);
|
||||
}
|
||||
|
||||
static bool factory_demarshal_info(void *object, void *data, size_t size)
|
||||
static int factory_demarshal_info(void *object, void *data, size_t size)
|
||||
{
|
||||
struct pw_proxy *proxy = object;
|
||||
struct spa_pod_parser prs;
|
||||
|
|
@ -719,7 +719,7 @@ static bool factory_demarshal_info(void *object, void *data, size_t size)
|
|||
"I", &info.type,
|
||||
"i", &info.version,
|
||||
"i", &props.n_items, NULL) < 0)
|
||||
return false;
|
||||
return -EINVAL;
|
||||
|
||||
info.props = &props;
|
||||
props.items = alloca(props.n_items * sizeof(struct spa_dict_item));
|
||||
|
|
@ -727,10 +727,10 @@ static bool factory_demarshal_info(void *object, void *data, size_t size)
|
|||
if (spa_pod_parser_get(&prs,
|
||||
"s", &props.items[i].key,
|
||||
"s", &props.items[i].value, NULL) < 0)
|
||||
return false;
|
||||
return -EINVAL;
|
||||
}
|
||||
pw_proxy_notify(proxy, struct pw_factory_proxy_events, info, &info);
|
||||
return true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void node_marshal_info(void *object, struct pw_node_info *info)
|
||||
|
|
@ -777,7 +777,7 @@ static void node_marshal_info(void *object, struct pw_node_info *info)
|
|||
pw_protocol_native_end_resource(resource, b);
|
||||
}
|
||||
|
||||
static bool node_demarshal_info(void *object, void *data, size_t size)
|
||||
static int node_demarshal_info(void *object, void *data, size_t size)
|
||||
{
|
||||
struct pw_proxy *proxy = object;
|
||||
struct spa_pod_parser prs;
|
||||
|
|
@ -794,29 +794,29 @@ static bool node_demarshal_info(void *object, void *data, size_t size)
|
|||
"i", &info.max_input_ports,
|
||||
"i", &info.n_input_ports,
|
||||
"i", &info.n_input_params, NULL) < 0)
|
||||
return false;
|
||||
return -EINVAL;
|
||||
|
||||
info.input_params = alloca(info.n_input_params * sizeof(struct spa_pod *));
|
||||
for (i = 0; i < info.n_input_params; i++)
|
||||
if (spa_pod_parser_get(&prs, "P", &info.input_params[i], NULL) < 0)
|
||||
return false;
|
||||
return -EINVAL;
|
||||
|
||||
if (spa_pod_parser_get(&prs,
|
||||
"i", &info.max_output_ports,
|
||||
"i", &info.n_output_ports,
|
||||
"i", &info.n_output_params, NULL) < 0)
|
||||
return false;
|
||||
return -EINVAL;
|
||||
|
||||
info.output_params = alloca(info.n_output_params * sizeof(struct spa_pod *));
|
||||
for (i = 0; i < info.n_output_params; i++)
|
||||
if (spa_pod_parser_get(&prs, "P", &info.output_params[i], NULL) < 0)
|
||||
return false;
|
||||
return -EINVAL;
|
||||
|
||||
if (spa_pod_parser_get(&prs,
|
||||
"i", &info.state,
|
||||
"s", &info.error,
|
||||
"i", &props.n_items, NULL) < 0)
|
||||
return false;
|
||||
return -EINVAL;
|
||||
|
||||
info.props = &props;
|
||||
props.items = alloca(props.n_items * sizeof(struct spa_dict_item));
|
||||
|
|
@ -824,10 +824,10 @@ static bool node_demarshal_info(void *object, void *data, size_t size)
|
|||
if (spa_pod_parser_get(&prs,
|
||||
"s", &props.items[i].key,
|
||||
"s", &props.items[i].value, NULL) < 0)
|
||||
return false;
|
||||
return -EINVAL;
|
||||
}
|
||||
pw_proxy_notify(proxy, struct pw_node_proxy_events, info, &info);
|
||||
return true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void client_marshal_info(void *object, struct pw_client_info *info)
|
||||
|
|
@ -856,7 +856,7 @@ static void client_marshal_info(void *object, struct pw_client_info *info)
|
|||
pw_protocol_native_end_resource(resource, b);
|
||||
}
|
||||
|
||||
static bool client_demarshal_info(void *object, void *data, size_t size)
|
||||
static int client_demarshal_info(void *object, void *data, size_t size)
|
||||
{
|
||||
struct pw_proxy *proxy = object;
|
||||
struct spa_pod_parser prs;
|
||||
|
|
@ -870,7 +870,7 @@ static bool client_demarshal_info(void *object, void *data, size_t size)
|
|||
"i", &info.id,
|
||||
"l", &info.change_mask,
|
||||
"i", &props.n_items, NULL) < 0)
|
||||
return false;
|
||||
return -EINVAL;
|
||||
|
||||
info.props = &props;
|
||||
props.items = alloca(props.n_items * sizeof(struct spa_dict_item));
|
||||
|
|
@ -878,10 +878,10 @@ static bool client_demarshal_info(void *object, void *data, size_t size)
|
|||
if (spa_pod_parser_get(&prs,
|
||||
"s", &props.items[i].key,
|
||||
"s", &props.items[i].value, NULL) < 0)
|
||||
return false;
|
||||
return -EINVAL;
|
||||
}
|
||||
pw_proxy_notify(proxy, struct pw_client_proxy_events, info, &info);
|
||||
return true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void link_marshal_info(void *object, struct pw_link_info *info)
|
||||
|
|
@ -915,7 +915,7 @@ static void link_marshal_info(void *object, struct pw_link_info *info)
|
|||
pw_protocol_native_end_resource(resource, b);
|
||||
}
|
||||
|
||||
static bool link_demarshal_info(void *object, void *data, size_t size)
|
||||
static int link_demarshal_info(void *object, void *data, size_t size)
|
||||
{
|
||||
struct pw_proxy *proxy = object;
|
||||
struct spa_pod_parser prs;
|
||||
|
|
@ -934,7 +934,7 @@ static bool link_demarshal_info(void *object, void *data, size_t size)
|
|||
"i", &info.input_port_id,
|
||||
"P", &info.format,
|
||||
"i", &props.n_items, NULL) < 0)
|
||||
return false;
|
||||
return -EINVAL;
|
||||
|
||||
info.props = &props;
|
||||
props.items = alloca(props.n_items * sizeof(struct spa_dict_item));
|
||||
|
|
@ -942,13 +942,13 @@ static bool link_demarshal_info(void *object, void *data, size_t size)
|
|||
if (spa_pod_parser_get(&prs,
|
||||
"s", &props.items[i].key,
|
||||
"s", &props.items[i].value, NULL) < 0)
|
||||
return false;
|
||||
return -EINVAL;
|
||||
}
|
||||
pw_proxy_notify(proxy, struct pw_link_proxy_events, info, &info);
|
||||
return true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static bool registry_demarshal_global(void *object, void *data, size_t size)
|
||||
static int registry_demarshal_global(void *object, void *data, size_t size)
|
||||
{
|
||||
struct pw_proxy *proxy = object;
|
||||
struct spa_pod_parser prs;
|
||||
|
|
@ -962,13 +962,13 @@ static bool registry_demarshal_global(void *object, void *data, size_t size)
|
|||
"i", &permissions,
|
||||
"I", &type,
|
||||
"i", &version, NULL) < 0)
|
||||
return false;
|
||||
return -EINVAL;
|
||||
|
||||
pw_proxy_notify(proxy, struct pw_registry_proxy_events, global, id, parent_id, permissions, type, version);
|
||||
return true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static bool registry_demarshal_global_remove(void *object, void *data, size_t size)
|
||||
static int registry_demarshal_global_remove(void *object, void *data, size_t size)
|
||||
{
|
||||
struct pw_proxy *proxy = object;
|
||||
struct spa_pod_parser prs;
|
||||
|
|
@ -976,10 +976,10 @@ static bool registry_demarshal_global_remove(void *object, void *data, size_t si
|
|||
|
||||
spa_pod_parser_init(&prs, data, size, 0);
|
||||
if (spa_pod_parser_get(&prs, "[ i", &id, NULL) < 0)
|
||||
return false;
|
||||
return -EINVAL;
|
||||
|
||||
pw_proxy_notify(proxy, struct pw_registry_proxy_events, global_remove, id);
|
||||
return true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void registry_marshal_bind(void *object, uint32_t id,
|
||||
|
|
|
|||
|
|
@ -190,11 +190,14 @@ const struct pw_core_events core_events = {
|
|||
*
|
||||
* Returns: a new #struct impl
|
||||
*/
|
||||
static bool module_init(struct pw_module *module, struct pw_properties *properties)
|
||||
static int module_init(struct pw_module *module, struct pw_properties *properties)
|
||||
{
|
||||
struct impl *impl;
|
||||
|
||||
impl = calloc(1, sizeof(struct impl));
|
||||
if (impl == NULL)
|
||||
return -ENOMEM;
|
||||
|
||||
pw_log_debug("module %p: new", impl);
|
||||
|
||||
impl->core = pw_module_get_core(module);
|
||||
|
|
@ -206,10 +209,10 @@ static bool module_init(struct pw_module *module, struct pw_properties *properti
|
|||
pw_module_add_listener(module, &impl->module_listener, &module_events, impl);
|
||||
pw_core_add_listener(impl->core, &impl->core_listener, &core_events, impl);
|
||||
|
||||
return impl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool pipewire__module_init(struct pw_module *module, const char *args)
|
||||
int pipewire__module_init(struct pw_module *module, const char *args)
|
||||
{
|
||||
return module_init(module, NULL);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@
|
|||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <errno.h>
|
||||
#include <getopt.h>
|
||||
#include <limits.h>
|
||||
|
||||
|
|
@ -51,7 +52,7 @@ const struct pw_module_events module_events = {
|
|||
.destroy = module_destroy,
|
||||
};
|
||||
|
||||
bool pipewire__module_init(struct pw_module *module, const char *args)
|
||||
int pipewire__module_init(struct pw_module *module, const char *args)
|
||||
{
|
||||
const char *dir;
|
||||
char **argv;
|
||||
|
|
@ -73,6 +74,8 @@ bool pipewire__module_init(struct pw_module *module, const char *args)
|
|||
pw_module_get_global(module),
|
||||
dir, argv[0], argv[1], argv[2],
|
||||
sizeof(struct data));
|
||||
if (monitor == NULL)
|
||||
return -ENOMEM;
|
||||
|
||||
data = monitor->user_data;
|
||||
data->monitor = monitor;
|
||||
|
|
@ -81,11 +84,11 @@ bool pipewire__module_init(struct pw_module *module, const char *args)
|
|||
|
||||
pw_module_add_listener(module, &data->module_listener, &module_events, data);
|
||||
|
||||
return true;
|
||||
return 0;
|
||||
|
||||
not_enough_arguments:
|
||||
pw_free_strv(argv);
|
||||
wrong_arguments:
|
||||
pw_log_error("usage: module-spa-monitor <plugin> <factory> <name>");
|
||||
return false;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -148,7 +148,7 @@ static const struct pw_module_events module_events = {
|
|||
.destroy = module_destroy,
|
||||
};
|
||||
|
||||
static bool module_init(struct pw_module *module, struct pw_properties *properties)
|
||||
static int module_init(struct pw_module *module, struct pw_properties *properties)
|
||||
{
|
||||
struct pw_core *core = pw_module_get_core(module);
|
||||
struct pw_type *t = pw_core_get_type(core);
|
||||
|
|
@ -162,7 +162,7 @@ static bool module_init(struct pw_module *module, struct pw_properties *properti
|
|||
NULL,
|
||||
sizeof(*data));
|
||||
if (factory == NULL)
|
||||
return false;
|
||||
return -ENOMEM;
|
||||
|
||||
data = pw_factory_get_user_data(factory);
|
||||
data->this = factory;
|
||||
|
|
@ -178,19 +178,10 @@ static bool module_init(struct pw_module *module, struct pw_properties *properti
|
|||
|
||||
pw_factory_register(factory, NULL, pw_module_get_global(module));
|
||||
|
||||
return true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if 0
|
||||
static void module_destroy(struct impl *impl)
|
||||
{
|
||||
pw_log_debug("module %p: destroy", impl);
|
||||
|
||||
free(impl);
|
||||
}
|
||||
#endif
|
||||
|
||||
bool pipewire__module_init(struct pw_module *module, const char *args)
|
||||
int pipewire__module_init(struct pw_module *module, const char *args)
|
||||
{
|
||||
return module_init(module, NULL);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@
|
|||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <errno.h>
|
||||
#include <getopt.h>
|
||||
#include <limits.h>
|
||||
|
||||
|
|
@ -52,7 +53,7 @@ static const struct pw_module_events module_events = {
|
|||
.destroy = module_destroy,
|
||||
};
|
||||
|
||||
bool pipewire__module_init(struct pw_module *module, const char *args)
|
||||
int pipewire__module_init(struct pw_module *module, const char *args)
|
||||
{
|
||||
struct pw_properties *props = NULL;
|
||||
char **argv;
|
||||
|
|
@ -69,6 +70,8 @@ bool pipewire__module_init(struct pw_module *module, const char *args)
|
|||
goto not_enough_arguments;
|
||||
|
||||
props = pw_properties_new(NULL, NULL);
|
||||
if (props == NULL)
|
||||
return -ENOMEM;
|
||||
|
||||
for (i = 3; i < n_tokens; i++) {
|
||||
char **prop;
|
||||
|
|
@ -92,7 +95,7 @@ bool pipewire__module_init(struct pw_module *module, const char *args)
|
|||
pw_free_strv(argv);
|
||||
|
||||
if (node == NULL)
|
||||
return false;
|
||||
return -ENOMEM;
|
||||
|
||||
data = pw_spa_node_get_user_data(node);
|
||||
data->this = node;
|
||||
|
|
@ -102,11 +105,11 @@ bool pipewire__module_init(struct pw_module *module, const char *args)
|
|||
pw_log_debug("module %p: new", module);
|
||||
pw_module_add_listener(module, &data->module_listener, &module_events, data);
|
||||
|
||||
return true;
|
||||
return 0;
|
||||
|
||||
not_enough_arguments:
|
||||
pw_free_strv(argv);
|
||||
wrong_arguments:
|
||||
pw_log_error("usage: module-spa-node <plugin> <factory> <name> [key=value ...]");
|
||||
return false;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@
|
|||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
|
|
@ -54,7 +55,7 @@ static const struct command_parse parsers[] = {
|
|||
static const char whitespace[] = " \t";
|
||||
/** \endcond */
|
||||
|
||||
static bool
|
||||
static int
|
||||
execute_command_help(struct pw_command *command, struct pw_core *core, char **err)
|
||||
{
|
||||
int i;
|
||||
|
|
@ -63,7 +64,7 @@ execute_command_help(struct pw_command *command, struct pw_core *core, char **er
|
|||
for (i = 0; parsers[i].name; i++)
|
||||
fprintf(stdout, " %20.20s\t%s\n", parsers[i].name, parsers[i].description);
|
||||
|
||||
return true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct pw_command *parse_command_help(const char *line, char **err)
|
||||
|
|
@ -86,7 +87,7 @@ static struct pw_command *parse_command_help(const char *line, char **err)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static bool
|
||||
static int
|
||||
execute_command_module_load(struct pw_command *command, struct pw_core *core, char **err)
|
||||
{
|
||||
struct pw_module *module;
|
||||
|
|
@ -94,9 +95,9 @@ execute_command_module_load(struct pw_command *command, struct pw_core *core, ch
|
|||
module = pw_module_load(core, command->args[1], command->args[2]);
|
||||
if (module == NULL) {
|
||||
asprintf(err, "could not load module \"%s\"", command->args[1]);
|
||||
return false;
|
||||
return -ENOMEM;
|
||||
}
|
||||
return true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct pw_command *parse_command_module_load(const char *line, char **err)
|
||||
|
|
@ -179,14 +180,14 @@ struct pw_command *pw_command_parse(const char *line, char **err)
|
|||
|
||||
/** Run a command
|
||||
*
|
||||
* \param command: A \ref pw_command
|
||||
* \param core: A \ref pw_core
|
||||
* \param err: Return location for an error string, or NULL
|
||||
* \return a result object or NULL when there was an error
|
||||
* \param command A \ref pw_command
|
||||
* \param core A \ref pw_core
|
||||
* \param err Return location for an error string, or NULL
|
||||
* \return 0 on success, < 0 on error
|
||||
*
|
||||
* \memberof pw_command
|
||||
*/
|
||||
bool pw_command_run(struct pw_command *command, struct pw_core *core, char **err)
|
||||
int pw_command_run(struct pw_command *command, struct pw_core *core, char **err)
|
||||
{
|
||||
return command->func(command, core, err);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ pw_command_parse(const char *line, char **err);
|
|||
void
|
||||
pw_command_free(struct pw_command *command);
|
||||
|
||||
bool pw_command_run(struct pw_command *command, struct pw_core *core, char **err);
|
||||
int pw_command_run(struct pw_command *command, struct pw_core *core, char **err);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
|||
|
|
@ -928,12 +928,12 @@ static void output_port_destroy(void *data)
|
|||
on_port_destroy(&impl->this, impl->this.output);
|
||||
}
|
||||
|
||||
bool pw_link_activate(struct pw_link *this)
|
||||
int pw_link_activate(struct pw_link *this)
|
||||
{
|
||||
struct impl *impl = SPA_CONTAINER_OF(this, struct impl, this);
|
||||
|
||||
if (impl->active)
|
||||
return true;
|
||||
return 0;
|
||||
|
||||
impl->active = true;
|
||||
|
||||
|
|
@ -944,7 +944,7 @@ bool pw_link_activate(struct pw_link *this)
|
|||
pw_work_queue_add(impl->work,
|
||||
this, -EBUSY, (pw_work_func_t) check_states, this);
|
||||
|
||||
return true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -956,13 +956,13 @@ do_deactivate_link(struct spa_loop *loop,
|
|||
return 0;
|
||||
}
|
||||
|
||||
bool pw_link_deactivate(struct pw_link *this)
|
||||
int pw_link_deactivate(struct pw_link *this)
|
||||
{
|
||||
struct impl *impl = SPA_CONTAINER_OF(this, struct impl, this);
|
||||
struct pw_node *input_node, *output_node;
|
||||
|
||||
if (!impl->active)
|
||||
return true;
|
||||
return 0;
|
||||
|
||||
impl->active = false;
|
||||
pw_log_debug("link %p: deactivate", this);
|
||||
|
|
@ -999,7 +999,7 @@ bool pw_link_deactivate(struct pw_link *this)
|
|||
this->output->state = PW_PORT_STATE_PAUSED;
|
||||
}
|
||||
|
||||
return true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void link_unbind_func(void *data)
|
||||
|
|
|
|||
|
|
@ -225,7 +225,7 @@ struct pw_module *pw_module_load(struct pw_core *core, const char *name, const c
|
|||
if (this->global != NULL)
|
||||
this->info.id = this->global->id;
|
||||
|
||||
if (!init_func(this, args))
|
||||
if (init_func(this, args) < 0)
|
||||
goto init_failed;
|
||||
|
||||
pw_log_debug("loaded module: %s", this->info.name);
|
||||
|
|
|
|||
|
|
@ -44,14 +44,14 @@ struct pw_module;
|
|||
*
|
||||
* \param module A \ref pw_module
|
||||
* \param args Arguments to the module
|
||||
* \return true on success, false otherwise
|
||||
* \return 0 on success, < 0 otherwise with an errno style error
|
||||
*
|
||||
* A module should provide an init function with this signature. This function
|
||||
* will be called when a module is loaded.
|
||||
*
|
||||
* \memberof pw_module
|
||||
*/
|
||||
typedef bool (*pw_module_init_func_t) (struct pw_module *module, const char *args);
|
||||
typedef int (*pw_module_init_func_t) (struct pw_module *module, const char *args);
|
||||
|
||||
/** Module events added with \ref pw_module_add_listener */
|
||||
struct pw_module_events {
|
||||
|
|
|
|||
|
|
@ -856,7 +856,7 @@ void pw_node_update_state(struct pw_node *node, enum pw_node_state state, char *
|
|||
}
|
||||
}
|
||||
|
||||
bool pw_node_set_active(struct pw_node *node, bool active)
|
||||
int pw_node_set_active(struct pw_node *node, bool active)
|
||||
{
|
||||
bool old = node->active;
|
||||
|
||||
|
|
@ -869,7 +869,7 @@ bool pw_node_set_active(struct pw_node *node, bool active)
|
|||
else
|
||||
pw_node_set_state(node, PW_NODE_STATE_IDLE);
|
||||
}
|
||||
return true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool pw_node_is_active(struct pw_node *node)
|
||||
|
|
|
|||
|
|
@ -161,7 +161,7 @@ struct pw_port * pw_node_get_free_port(struct pw_node *node, enum pw_direction d
|
|||
|
||||
/** Set a node active. This will start negotiation with all linked active
|
||||
* nodes and start data transport */
|
||||
bool pw_node_set_active(struct pw_node *node, bool active);
|
||||
int pw_node_set_active(struct pw_node *node, bool active);
|
||||
|
||||
/** Check is a node is active */
|
||||
bool pw_node_is_active(struct pw_node *node);
|
||||
|
|
|
|||
|
|
@ -282,7 +282,7 @@ static int make_control(void *data, struct spa_pod *param)
|
|||
return 0;
|
||||
}
|
||||
|
||||
bool pw_port_add(struct pw_port *port, struct pw_node *node)
|
||||
int pw_port_add(struct pw_port *port, struct pw_node *node)
|
||||
{
|
||||
uint32_t port_id = port->port_id;
|
||||
struct pw_type *t = &node->core->type;
|
||||
|
|
@ -326,7 +326,7 @@ bool pw_port_add(struct pw_port *port, struct pw_node *node)
|
|||
port_update_state(port, PW_PORT_STATE_CONFIGURE);
|
||||
|
||||
spa_hook_list_call(&node->listener_list, struct pw_node_events, port_added, port);
|
||||
return true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int do_remove_port(struct spa_loop *loop,
|
||||
|
|
@ -480,7 +480,8 @@ int pw_port_set_param(struct pw_port *port, uint32_t id, uint32_t flags,
|
|||
int res;
|
||||
|
||||
res = spa_node_port_set_param(port->node->node, port->direction, port->port_id, id, flags, param);
|
||||
pw_log_debug("port %p: set param %d: %d (%s)", port, id, res, spa_strerror(res));
|
||||
pw_log_debug("port %p: set param %s: %d (%s)", port,
|
||||
spa_type_map_get_type(port->node->core->type.map, id), res, spa_strerror(res));
|
||||
|
||||
if (!SPA_RESULT_IS_ASYNC(res) && id == port->node->core->type.param.idFormat) {
|
||||
if (param == NULL || res < 0) {
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ extern "C" {
|
|||
|
||||
struct pw_command;
|
||||
|
||||
typedef bool (*pw_command_func_t) (struct pw_command *command, struct pw_core *core, char **err);
|
||||
typedef int (*pw_command_func_t) (struct pw_command *command, struct pw_core *core, char **err);
|
||||
|
||||
/** \cond */
|
||||
struct pw_command {
|
||||
|
|
@ -451,7 +451,7 @@ pw_port_new(enum pw_direction direction,
|
|||
void * pw_port_get_user_data(struct pw_port *port);
|
||||
|
||||
/** Add a port to a node \memberof pw_port */
|
||||
bool pw_port_add(struct pw_port *port, struct pw_node *node);
|
||||
int pw_port_add(struct pw_port *port, struct pw_node *node);
|
||||
|
||||
/** Destroy a port \memberof pw_port */
|
||||
void pw_port_destroy(struct pw_port *port);
|
||||
|
|
@ -499,10 +499,10 @@ void pw_node_update_state(struct pw_node *node, enum pw_node_state state, char *
|
|||
/** Activate a link \memberof pw_link
|
||||
* Starts the negotiation of formats and buffers on \a link and then
|
||||
* starts data streaming */
|
||||
bool pw_link_activate(struct pw_link *link);
|
||||
int pw_link_activate(struct pw_link *link);
|
||||
|
||||
/** Deactivate a link \memberof pw_link */
|
||||
bool pw_link_deactivate(struct pw_link *link);
|
||||
int pw_link_deactivate(struct pw_link *link);
|
||||
|
||||
struct pw_control *
|
||||
pw_control_new(struct pw_core *core,
|
||||
|
|
|
|||
|
|
@ -1111,6 +1111,7 @@ client_node_port_set_io(void *object,
|
|||
strerror(errno));
|
||||
return;
|
||||
}
|
||||
pw_log_debug("port %p: set io %s", port, spa_type_map_get_type(core->type.map, id));
|
||||
|
||||
spa_node_port_set_io(port->port->node->node,
|
||||
direction, port_id,
|
||||
|
|
|
|||
|
|
@ -1008,7 +1008,7 @@ static const struct pw_proxy_events proxy_events = {
|
|||
.destroy = on_node_proxy_destroy,
|
||||
};
|
||||
|
||||
bool
|
||||
int
|
||||
pw_stream_connect(struct pw_stream *stream,
|
||||
enum pw_direction direction,
|
||||
const char *port_path,
|
||||
|
|
@ -1040,14 +1040,14 @@ pw_stream_connect(struct pw_stream *stream,
|
|||
PW_VERSION_CLIENT_NODE,
|
||||
&stream->properties->dict, 0);
|
||||
if (impl->node_proxy == NULL)
|
||||
return false;
|
||||
return -ENOMEM;
|
||||
|
||||
pw_client_node_proxy_add_listener(impl->node_proxy, &impl->node_listener, &client_node_events, impl);
|
||||
pw_proxy_add_listener((struct pw_proxy*)impl->node_proxy, &impl->proxy_listener, &proxy_events, impl);
|
||||
|
||||
do_node_init(stream);
|
||||
|
||||
return true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
|
|
@ -1105,7 +1105,7 @@ void pw_stream_set_active(struct pw_stream *stream, bool active)
|
|||
pw_client_node_proxy_set_active(impl->node_proxy, active);
|
||||
}
|
||||
|
||||
bool pw_stream_get_time(struct pw_stream *stream, struct pw_time *time)
|
||||
int pw_stream_get_time(struct pw_stream *stream, struct pw_time *time)
|
||||
{
|
||||
struct stream *impl = SPA_CONTAINER_OF(stream, struct stream, this);
|
||||
int64_t elapsed;
|
||||
|
|
@ -1118,7 +1118,7 @@ bool pw_stream_get_time(struct pw_stream *stream, struct pw_time *time)
|
|||
time->ticks = impl->last_ticks + (elapsed * impl->last_rate) / SPA_USEC_PER_SEC;
|
||||
time->rate = impl->last_rate;
|
||||
|
||||
return true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t pw_stream_get_empty_buffer(struct pw_stream *stream)
|
||||
|
|
@ -1134,13 +1134,13 @@ uint32_t pw_stream_get_empty_buffer(struct pw_stream *stream)
|
|||
return bid->id;
|
||||
}
|
||||
|
||||
bool pw_stream_recycle_buffer(struct pw_stream *stream, uint32_t id)
|
||||
int pw_stream_recycle_buffer(struct pw_stream *stream, uint32_t id)
|
||||
{
|
||||
struct stream *impl = SPA_CONTAINER_OF(stream, struct stream, this);
|
||||
struct buffer_id *bid;
|
||||
|
||||
if ((bid = find_buffer(stream, id)) == NULL || !bid->used)
|
||||
return false;
|
||||
return -EINVAL;
|
||||
|
||||
bid->used = false;
|
||||
spa_list_append(&impl->free, &bid->link);
|
||||
|
|
@ -1156,7 +1156,7 @@ bool pw_stream_recycle_buffer(struct pw_stream *stream, uint32_t id)
|
|||
send_reuse_buffer(stream, id);
|
||||
}
|
||||
|
||||
return true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct spa_buffer *pw_stream_peek_buffer(struct pw_stream *stream, uint32_t id)
|
||||
|
|
@ -1169,7 +1169,7 @@ struct spa_buffer *pw_stream_peek_buffer(struct pw_stream *stream, uint32_t id)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
bool pw_stream_send_buffer(struct pw_stream *stream, uint32_t id)
|
||||
int pw_stream_send_buffer(struct pw_stream *stream, uint32_t id)
|
||||
{
|
||||
struct stream *impl = SPA_CONTAINER_OF(stream, struct stream, this);
|
||||
struct buffer_id *bid;
|
||||
|
|
@ -1177,7 +1177,7 @@ bool pw_stream_send_buffer(struct pw_stream *stream, uint32_t id)
|
|||
if (impl->trans->outputs[0].buffer_id != SPA_ID_INVALID) {
|
||||
pw_log_debug("can't send %u, pending buffer %u", id,
|
||||
impl->trans->outputs[0].buffer_id);
|
||||
return false;
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
if ((bid = find_buffer(stream, id)) && !bid->used) {
|
||||
|
|
@ -1192,5 +1192,5 @@ bool pw_stream_send_buffer(struct pw_stream *stream, uint32_t id)
|
|||
pw_log_debug("stream %p: output %u was used", stream, id);
|
||||
}
|
||||
|
||||
return true;
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -253,12 +253,12 @@ const char *pw_stream_get_name(struct pw_stream *stream);
|
|||
const struct pw_properties *pw_stream_get_properties(struct pw_stream *stream);
|
||||
|
||||
/** Connect a stream for input or output on \a port_path. \memberof pw_stream
|
||||
* \return true on success.
|
||||
* \return 0 on success < 0 on error.
|
||||
*
|
||||
* When \a mode is \ref PW_STREAM_MODE_BUFFER, you should connect to the new-buffer
|
||||
* event and use pw_stream_peek_buffer() to get the latest metadata and
|
||||
* data. */
|
||||
bool
|
||||
int
|
||||
pw_stream_connect(struct pw_stream *stream, /**< a \ref pw_stream */
|
||||
enum pw_direction direction, /**< the stream direction */
|
||||
const char *port_path, /**< the port path to connect to or NULL
|
||||
|
|
@ -295,7 +295,7 @@ pw_stream_finish_format(struct pw_stream *stream, /**< a \ref pw_stream */
|
|||
void pw_stream_set_active(struct pw_stream *stream, bool active);
|
||||
|
||||
/** Query the time on the stream \memberof pw_stream */
|
||||
bool pw_stream_get_time(struct pw_stream *stream, struct pw_time *time);
|
||||
int pw_stream_get_time(struct pw_stream *stream, struct pw_time *time);
|
||||
|
||||
/** Get the id of an empty buffer that can be filled \memberof pw_stream
|
||||
* \return the id of an empty buffer or \ref SPA_ID_INVALID when no buffer is
|
||||
|
|
@ -303,9 +303,9 @@ bool pw_stream_get_time(struct pw_stream *stream, struct pw_time *time);
|
|||
uint32_t pw_stream_get_empty_buffer(struct pw_stream *stream);
|
||||
|
||||
/** Recycle the buffer with \a id \memberof pw_stream
|
||||
* \return true on success, false when \a id is invalid or not a used buffer
|
||||
* \return 0 on success, < 0 when \a id is invalid or not a used buffer
|
||||
* Let the PipeWire server know that it can reuse the buffer with \a id. */
|
||||
bool pw_stream_recycle_buffer(struct pw_stream *stream, uint32_t id);
|
||||
int pw_stream_recycle_buffer(struct pw_stream *stream, uint32_t id);
|
||||
|
||||
/** Get the buffer with \a id from \a stream \memberof pw_stream
|
||||
* \return a \ref spa_buffer or NULL when there is no buffer
|
||||
|
|
@ -315,11 +315,11 @@ struct spa_buffer *
|
|||
pw_stream_peek_buffer(struct pw_stream *stream, uint32_t id);
|
||||
|
||||
/** Send a buffer with \a id to \a stream \memberof pw_stream
|
||||
* \return true when \a id was handled, false on error
|
||||
* \return 0 when \a id was handled, < 0 on error
|
||||
*
|
||||
* For provider or playback streams, this function should be called whenever
|
||||
* there is a new buffer available. */
|
||||
bool pw_stream_send_buffer(struct pw_stream *stream, uint32_t id);
|
||||
int pw_stream_send_buffer(struct pw_stream *stream, uint32_t id);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
|||
|
|
@ -186,7 +186,7 @@ pw_work_queue_add(struct pw_work_queue *queue, void *obj, int res, pw_work_func_
|
|||
*
|
||||
* \memberof pw_work_queue
|
||||
*/
|
||||
void pw_work_queue_cancel(struct pw_work_queue *queue, void *obj, uint32_t id)
|
||||
int pw_work_queue_cancel(struct pw_work_queue *queue, void *obj, uint32_t id)
|
||||
{
|
||||
bool have_work = false;
|
||||
struct work_item *item;
|
||||
|
|
@ -200,19 +200,24 @@ void pw_work_queue_cancel(struct pw_work_queue *queue, void *obj, uint32_t id)
|
|||
have_work = true;
|
||||
}
|
||||
}
|
||||
if (have_work)
|
||||
if (!have_work) {
|
||||
pw_log_debug("work-queue %p: no defered found for object %p", queue, obj);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
pw_loop_signal_event(queue->loop, queue->wakeup);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** Complete a work item
|
||||
* \param queue the work queue
|
||||
* \param obj the owner object
|
||||
* \param seq the sequence number that completed
|
||||
* \param res the result of the completed work
|
||||
* \param res 0 if the item was found, < 0 on error
|
||||
*
|
||||
* \memberof pw_work_queue
|
||||
*/
|
||||
bool pw_work_queue_complete(struct pw_work_queue *queue, void *obj, uint32_t seq, int res)
|
||||
int pw_work_queue_complete(struct pw_work_queue *queue, void *obj, uint32_t seq, int res)
|
||||
{
|
||||
struct work_item *item;
|
||||
bool have_work = false;
|
||||
|
|
@ -228,8 +233,9 @@ bool pw_work_queue_complete(struct pw_work_queue *queue, void *obj, uint32_t seq
|
|||
}
|
||||
if (!have_work) {
|
||||
pw_log_debug("work-queue %p: no defered %d found for object %p", queue, seq, obj);
|
||||
} else {
|
||||
pw_loop_signal_event(queue->loop, queue->wakeup);
|
||||
return -EINVAL;
|
||||
}
|
||||
return have_work;
|
||||
|
||||
pw_loop_signal_event(queue->loop, queue->wakeup);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,10 +45,10 @@ pw_work_queue_add(struct pw_work_queue *queue,
|
|||
void *obj, int res,
|
||||
pw_work_func_t func, void *data);
|
||||
|
||||
void
|
||||
int
|
||||
pw_work_queue_cancel(struct pw_work_queue *queue, void *obj, uint32_t id);
|
||||
|
||||
bool
|
||||
int
|
||||
pw_work_queue_complete(struct pw_work_queue *queue, void *obj, uint32_t seq, int res);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue