mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-08 13:30:08 -05:00
core_proxy: prepare to rename pw_remote -> pw_core_proxy
The pw_remote object is really a wrapper around the pw_core_proxy. The events it emits are also available in the core proxy and are generally awkward to use. With some clever new pw_core_proxy_* methods and a pw_core_connect to create the core_proxy, we can convert all code away from pw_remote. This is a first step in this conversion, using the pw_remote behind the scenes. It leaks into some places because it really needs to become its own struct in a next step.
This commit is contained in:
parent
f8aabe69fe
commit
8a959ea7a1
37 changed files with 919 additions and 1185 deletions
|
|
@ -26,6 +26,7 @@
|
|||
#include <signal.h>
|
||||
#include <getopt.h>
|
||||
|
||||
#include <spa/utils/result.h>
|
||||
#include <spa/debug/pod.h>
|
||||
#include <spa/debug/format.h>
|
||||
#include <spa/debug/types.h>
|
||||
|
|
@ -48,9 +49,6 @@ struct data {
|
|||
struct pw_main_loop *loop;
|
||||
struct pw_core *core;
|
||||
|
||||
struct pw_remote *remote;
|
||||
struct spa_hook remote_listener;
|
||||
|
||||
struct pw_core_proxy *core_proxy;
|
||||
struct spa_hook core_listener;
|
||||
|
||||
|
|
@ -711,42 +709,22 @@ static void on_core_done(void *data, uint32_t id, int seq)
|
|||
pw_main_loop_quit(d->loop);
|
||||
}
|
||||
|
||||
static const struct pw_core_proxy_events core_events = {
|
||||
PW_VERSION_CORE_EVENTS,
|
||||
.done = on_core_done,
|
||||
};
|
||||
|
||||
static void on_state_changed(void *_data, enum pw_remote_state old,
|
||||
enum pw_remote_state state, const char *error)
|
||||
static void on_core_error(void *data, uint32_t id, int seq, int res, const char *message)
|
||||
{
|
||||
struct data *data = _data;
|
||||
struct data *d = data;
|
||||
|
||||
switch (state) {
|
||||
case PW_REMOTE_STATE_ERROR:
|
||||
printf("remote error: %s\n", error);
|
||||
pw_main_loop_quit(data->loop);
|
||||
break;
|
||||
pw_log_error("error id:%u seq:%d res:%d (%s): %s",
|
||||
id, seq, res, spa_strerror(res), message);
|
||||
|
||||
case PW_REMOTE_STATE_CONNECTED:
|
||||
data->core_proxy = pw_remote_get_core_proxy(data->remote);
|
||||
pw_core_proxy_add_listener(data->core_proxy,
|
||||
&data->core_listener,
|
||||
&core_events, data);
|
||||
data->registry_proxy = pw_core_proxy_get_registry(data->core_proxy,
|
||||
PW_VERSION_REGISTRY_PROXY, 0);
|
||||
pw_registry_proxy_add_listener(data->registry_proxy,
|
||||
&data->registry_listener,
|
||||
®istry_events, data);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
if (id == 0) {
|
||||
pw_main_loop_quit(d->loop);
|
||||
}
|
||||
}
|
||||
|
||||
static const struct pw_remote_events remote_events = {
|
||||
PW_VERSION_REMOTE_EVENTS,
|
||||
.state_changed = on_state_changed,
|
||||
static const struct pw_core_proxy_events core_events = {
|
||||
PW_VERSION_CORE_PROXY_EVENTS,
|
||||
.done = on_core_done,
|
||||
.error = on_core_error,
|
||||
};
|
||||
|
||||
static void do_quit(void *data, int signal_number)
|
||||
|
|
@ -843,12 +821,8 @@ int main(int argc, char *argv[])
|
|||
if (remote_name)
|
||||
props = pw_properties_new(PW_KEY_REMOTE_NAME, remote_name, NULL);
|
||||
|
||||
data.remote = pw_remote_new(data.core, props, 0);
|
||||
if (data.remote == NULL)
|
||||
return -1;
|
||||
|
||||
pw_remote_add_listener(data.remote, &data.remote_listener, &remote_events, &data);
|
||||
if (pw_remote_connect(data.remote) < 0)
|
||||
data.core_proxy = pw_core_connect(data.core, props, 0);
|
||||
if (data.core_proxy == NULL)
|
||||
return -1;
|
||||
|
||||
data.dot_str = dot_str_new();
|
||||
|
|
@ -857,12 +831,20 @@ int main(int argc, char *argv[])
|
|||
|
||||
spa_list_init(&data.globals);
|
||||
|
||||
pw_core_proxy_add_listener(data.core_proxy,
|
||||
&data.core_listener,
|
||||
&core_events, &data);
|
||||
data.registry_proxy = pw_core_proxy_get_registry(data.core_proxy,
|
||||
PW_VERSION_REGISTRY_PROXY, 0);
|
||||
pw_registry_proxy_add_listener(data.registry_proxy,
|
||||
&data.registry_listener,
|
||||
®istry_events, &data);
|
||||
|
||||
pw_main_loop_run(data.loop);
|
||||
|
||||
draw_graph(&data, dot_path);
|
||||
|
||||
dot_str_clear(&data.dot_str);
|
||||
pw_remote_destroy(data.remote);
|
||||
pw_core_destroy(data.core);
|
||||
pw_main_loop_destroy(data.loop);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue