pw_core -> pw_context

The proxy API is the one that we would like to expose for applications
and the other API is used internally when implementing modules or
factories.

The current pw_core object is really a context for all objects so
name it that way. It also makes it possible to rename pw_core_proxy
to pw_proxy later.
This commit is contained in:
Wim Taymans 2019-12-10 18:19:56 +01:00
parent 42103a8218
commit 8ea78c2e3f
113 changed files with 905 additions and 906 deletions

View file

@ -68,7 +68,7 @@ static const char whitespace[] = " \t";
/** \endcond */
static int
execute_command_help(struct pw_command *command, struct pw_core *core, char **err)
execute_command_help(struct pw_command *command, struct pw_context *context, char **err)
{
int i;
@ -100,7 +100,7 @@ no_mem:
}
static int
execute_command_set_prop(struct pw_command *command, struct pw_core *core, char **err)
execute_command_set_prop(struct pw_command *command, struct pw_context *context, char **err)
{
return 0;
}
@ -136,11 +136,11 @@ error_alloc:
}
static int
execute_command_add_spa_lib(struct pw_command *command, struct pw_core *core, char **err)
execute_command_add_spa_lib(struct pw_command *command, struct pw_context *context, char **err)
{
int res;
res = pw_core_add_spa_lib(core, command->args[1], command->args[2]);
res = pw_context_add_spa_lib(context, command->args[1], command->args[2]);
if (res < 0) {
asprintf(err, "could not add spa library \"%s\"", command->args[1]);
return res;
@ -176,11 +176,11 @@ no_mem:
}
static int
execute_command_module_load(struct pw_command *command, struct pw_core *core, char **err)
execute_command_module_load(struct pw_command *command, struct pw_context *context, char **err)
{
struct pw_module *module;
module = pw_module_load(core, command->args[1], command->args[2], NULL);
module = pw_module_load(context, command->args[1], command->args[2], NULL);
if (module == NULL) {
asprintf(err, "could not load module \"%s\": %m", command->args[1]);
return -errno;
@ -216,7 +216,7 @@ no_mem:
}
static int
execute_command_exec(struct pw_command *command, struct pw_core *core, char **err)
execute_command_exec(struct pw_command *command, struct pw_context *context, char **err)
{
int pid;
@ -315,14 +315,14 @@ out:
/** Run a command
*
* \param command A \ref pw_command
* \param core A \ref pw_core
* \param context A \ref pw_context
* \param err Return location for an error string, or NULL
* \return 0 on success, < 0 on error
*
* \memberof pw_command
*/
SPA_EXPORT
int pw_command_run(struct pw_command *command, struct pw_core *core, char **err)
int pw_command_run(struct pw_command *command, struct pw_context *context, char **err)
{
return command->func(command, core, err);
return command->func(command, context, err);
}

View file

@ -30,11 +30,11 @@
extern "C" {
#endif
#include <pipewire/core.h>
#include <pipewire/context.h>
struct pw_command;
typedef int (*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_context *context, char **err);
/** \class pw_command
*
@ -54,7 +54,7 @@ pw_command_parse(struct pw_properties *properties, const char *line, char **err)
void
pw_command_free(struct pw_command *command);
int pw_command_run(struct pw_command *command, struct pw_core *core, char **err);
int pw_command_run(struct pw_command *command, struct pw_context *context, char **err);
#ifdef __cplusplus
}

View file

@ -186,21 +186,21 @@ int pw_daemon_config_load(struct pw_daemon_config *config, char **err)
/**
* pw_daemon_config_run_commands:
* @config: A #struct pw_daemon_config
* @core: A #struct pw_core
* @context: A #struct pw_context
*
* Run all commands that have been parsed. The list of commands will be cleared
* when this function has been called.
*
* Returns: 0 if all commands where executed with success, otherwise < 0.
*/
int 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_context *context)
{
char *err = NULL;
int ret = 0;
struct pw_command *command;
spa_list_for_each(command, &config->commands, link) {
if ((ret = pw_command_run(command, core, &err)) < 0) {
if ((ret = pw_command_run(command, context, &err)) < 0) {
pw_log_warn("could not run command %s: %s", command->args[0], err);
free(err);
break;

View file

@ -30,7 +30,7 @@
extern "C" {
#endif
#include <pipewire/core.h>
#include <pipewire/context.h>
struct pw_daemon_config {
struct spa_list commands;
@ -45,7 +45,7 @@ int pw_daemon_config_load_file(struct pw_daemon_config *config, const char *file
int pw_daemon_config_load(struct pw_daemon_config *config, char **err);
int 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_context *context);
#ifdef __cplusplus
}

View file

@ -28,7 +28,7 @@
#include <spa/utils/result.h>
#include <pipewire/pipewire.h>
#include <pipewire/core.h>
#include <pipewire/context.h>
#include <pipewire/module.h>
#include "config.h"
@ -54,7 +54,7 @@ static void show_help(const char *name)
int main(int argc, char *argv[])
{
struct pw_core *core;
struct pw_context *context;
struct pw_main_loop *loop;
struct pw_daemon_config *config;
struct pw_properties *properties;
@ -114,15 +114,15 @@ int main(int argc, char *argv[])
pw_loop_add_signal(pw_main_loop_get_loop(loop), SIGINT, do_quit, loop);
pw_loop_add_signal(pw_main_loop_get_loop(loop), SIGTERM, do_quit, loop);
core = pw_core_new(pw_main_loop_get_loop(loop),
context = pw_context_new(pw_main_loop_get_loop(loop),
properties, 0);
if (core == NULL) {
pw_log_error("failed to create core: %m");
if (context == NULL) {
pw_log_error("failed to create context: %m");
return -1;
}
if ((res = pw_daemon_config_run_commands(config, core)) < 0) {
if ((res = pw_daemon_config_run_commands(config, context)) < 0) {
pw_log_error("failed to run config commands: %s", spa_strerror(res));
return -1;
}
@ -132,7 +132,7 @@ int main(int argc, char *argv[])
pw_log_info("leave main loop");
pw_daemon_config_free(config);
pw_core_destroy(core);
pw_context_destroy(context);
pw_main_loop_destroy(loop);
return 0;