2017-05-23 19:15:33 +02:00
|
|
|
/* PipeWire
|
2015-04-16 16:58:33 +02:00
|
|
|
*
|
2018-11-05 17:48:52 +01:00
|
|
|
* Copyright © 2018 Wim Taymans
|
2015-04-16 16:58:33 +02:00
|
|
|
*
|
2018-11-05 17:48:52 +01:00
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
|
|
|
* to deal in the Software without restriction, including without limitation
|
|
|
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
|
* Software is furnished to do so, subject to the following conditions:
|
2015-04-16 16:58:33 +02:00
|
|
|
*
|
2018-11-05 17:48:52 +01:00
|
|
|
* The above copyright notice and this permission notice (including the next
|
|
|
|
|
* paragraph) shall be included in all copies or substantial portions of the
|
|
|
|
|
* Software.
|
|
|
|
|
*
|
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
|
|
|
* DEALINGS IN THE SOFTWARE.
|
2015-04-16 16:58:33 +02:00
|
|
|
*/
|
|
|
|
|
|
2016-11-24 17:00:42 +01:00
|
|
|
#include <stdio.h>
|
2017-09-11 09:48:13 +02:00
|
|
|
#include <signal.h>
|
2016-11-24 17:00:42 +01:00
|
|
|
|
2018-08-14 13:05:10 +02:00
|
|
|
#include <spa/debug/pod.h>
|
2018-08-14 12:33:53 +02:00
|
|
|
#include <spa/debug/format.h>
|
2018-08-23 17:47:57 +02:00
|
|
|
#include <spa/debug/types.h>
|
2016-11-24 17:00:42 +01:00
|
|
|
|
2017-07-11 15:57:20 +02:00
|
|
|
#include <pipewire/pipewire.h>
|
2017-07-12 18:04:00 +02:00
|
|
|
#include <pipewire/interfaces.h>
|
|
|
|
|
#include <pipewire/type.h>
|
2017-07-11 15:57:20 +02:00
|
|
|
|
2018-02-20 10:31:55 +01:00
|
|
|
struct proxy_data;
|
|
|
|
|
|
|
|
|
|
typedef void (*print_func_t) (struct proxy_data *data);
|
|
|
|
|
|
2017-05-23 19:15:33 +02:00
|
|
|
struct data {
|
2017-09-11 09:48:13 +02:00
|
|
|
struct pw_main_loop *loop;
|
2017-07-11 12:24:03 +02:00
|
|
|
struct pw_core *core;
|
2017-08-04 10:18:54 +02:00
|
|
|
|
2017-07-11 12:24:03 +02:00
|
|
|
struct pw_remote *remote;
|
2017-08-08 16:56:29 +02:00
|
|
|
struct spa_hook remote_listener;
|
2015-04-16 16:58:33 +02:00
|
|
|
|
2017-08-04 10:18:54 +02:00
|
|
|
struct pw_core_proxy *core_proxy;
|
|
|
|
|
|
|
|
|
|
struct pw_registry_proxy *registry_proxy;
|
2017-08-08 16:56:29 +02:00
|
|
|
struct spa_hook registry_listener;
|
2018-02-20 10:31:55 +01:00
|
|
|
|
|
|
|
|
uint32_t seq;
|
|
|
|
|
struct spa_list pending_list;
|
2017-07-11 12:24:03 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct proxy_data {
|
2017-09-18 09:35:00 +02:00
|
|
|
struct data *data;
|
2018-02-20 10:31:55 +01:00
|
|
|
bool first;
|
2017-08-04 10:18:54 +02:00
|
|
|
struct pw_proxy *proxy;
|
2017-07-13 15:21:52 +02:00
|
|
|
uint32_t id;
|
2017-07-18 14:58:14 +02:00
|
|
|
uint32_t parent_id;
|
2017-08-01 17:09:57 +02:00
|
|
|
uint32_t permissions;
|
2017-07-13 15:21:52 +02:00
|
|
|
uint32_t version;
|
2017-08-04 10:18:54 +02:00
|
|
|
uint32_t type;
|
2017-07-11 12:24:03 +02:00
|
|
|
void *info;
|
2017-08-04 10:18:54 +02:00
|
|
|
pw_destroy_t destroy;
|
2017-08-08 16:56:29 +02:00
|
|
|
struct spa_hook proxy_listener;
|
|
|
|
|
struct spa_hook proxy_proxy_listener;
|
2018-02-20 10:31:55 +01:00
|
|
|
uint32_t pending_seq;
|
|
|
|
|
struct spa_list pending_link;
|
|
|
|
|
print_func_t print_func;
|
|
|
|
|
uint32_t n_params;
|
|
|
|
|
struct spa_pod **params;
|
2017-05-23 19:15:33 +02:00
|
|
|
};
|
2015-04-16 16:58:33 +02:00
|
|
|
|
2018-02-20 10:31:55 +01:00
|
|
|
static void add_pending(struct proxy_data *pd)
|
|
|
|
|
{
|
|
|
|
|
struct data *d = pd->data;
|
|
|
|
|
|
|
|
|
|
spa_list_append(&d->pending_list, &pd->pending_link);
|
|
|
|
|
pd->pending_seq = ++d->seq;
|
|
|
|
|
pw_core_proxy_sync(d->core_proxy, pd->pending_seq);
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-19 20:02:06 +02:00
|
|
|
static void remove_pending(struct proxy_data *pd)
|
|
|
|
|
{
|
|
|
|
|
if (pd->pending_seq != SPA_ID_INVALID) {
|
|
|
|
|
spa_list_remove(&pd->pending_link);
|
|
|
|
|
pd->pending_seq = SPA_ID_INVALID;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-20 10:31:55 +01:00
|
|
|
static void on_sync_reply(void *data, uint32_t seq)
|
|
|
|
|
{
|
|
|
|
|
struct data *d = data;
|
2018-04-19 20:02:06 +02:00
|
|
|
struct proxy_data *pd, *t;
|
2018-02-20 10:31:55 +01:00
|
|
|
|
2018-04-19 20:02:06 +02:00
|
|
|
spa_list_for_each_safe(pd, t, &d->pending_list, pending_link) {
|
2018-02-20 10:31:55 +01:00
|
|
|
if (pd->pending_seq == seq) {
|
2018-04-19 20:02:06 +02:00
|
|
|
remove_pending(pd);
|
2018-02-20 10:31:55 +01:00
|
|
|
pd->print_func(pd);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void clear_params(struct proxy_data *data)
|
|
|
|
|
{
|
2019-01-07 15:52:42 +01:00
|
|
|
uint32_t i;
|
2018-02-20 10:31:55 +01:00
|
|
|
|
|
|
|
|
for (i = 0; i < data->n_params; i++)
|
|
|
|
|
free(data->params[i]);
|
|
|
|
|
free(data->params);
|
|
|
|
|
|
|
|
|
|
data->n_params = 0;
|
|
|
|
|
data->params = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void add_param(struct proxy_data *data, const struct spa_pod *param)
|
|
|
|
|
{
|
|
|
|
|
uint32_t idx = data->n_params++;
|
|
|
|
|
|
|
|
|
|
data->params = realloc(data->params, sizeof(struct spa_pod *) * data->n_params);
|
|
|
|
|
data->params[idx] = pw_spa_pod_copy(param);
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-19 11:18:17 +01:00
|
|
|
static void print_properties(const struct spa_dict *props, char mark)
|
2015-07-28 17:05:03 +02:00
|
|
|
{
|
2017-09-07 19:55:22 +02:00
|
|
|
const struct spa_dict_item *item;
|
2015-07-28 17:05:03 +02:00
|
|
|
|
2017-08-27 17:58:25 +02:00
|
|
|
printf("%c\tproperties:\n", mark);
|
|
|
|
|
if (props == NULL || props->n_items == 0) {
|
|
|
|
|
printf("\t\tnone\n");
|
2017-05-26 08:05:01 +02:00
|
|
|
return;
|
2017-08-27 17:58:25 +02:00
|
|
|
}
|
2016-02-01 16:29:56 +01:00
|
|
|
|
2017-05-26 08:05:01 +02:00
|
|
|
spa_dict_for_each(item, props) {
|
2017-10-17 12:16:53 +02:00
|
|
|
if (item->value)
|
|
|
|
|
printf("%c\t\t%s = \"%s\"\n", mark, item->key, item->value);
|
|
|
|
|
else
|
|
|
|
|
printf("%c\t\t%s = (null)\n", mark, item->key);
|
2017-05-26 08:05:01 +02:00
|
|
|
}
|
2016-01-07 12:15:57 +01:00
|
|
|
}
|
|
|
|
|
|
2017-07-11 12:24:03 +02:00
|
|
|
#define MARK_CHANGE(f) ((print_mark && ((info)->change_mask & (1 << (f)))) ? '*' : ' ')
|
2016-02-01 16:29:56 +01:00
|
|
|
|
2017-08-04 10:18:54 +02:00
|
|
|
static void on_info_changed(void *data, const struct pw_core_info *info)
|
2016-01-07 12:15:57 +01:00
|
|
|
{
|
2017-07-11 12:24:03 +02:00
|
|
|
bool print_all = true, print_mark = false;
|
2017-05-26 08:05:01 +02:00
|
|
|
|
2018-11-22 13:35:30 +01:00
|
|
|
printf("\ttype: %s\n", spa_debug_type_find_name(pw_type_info(), PW_TYPE_INTERFACE_Core));
|
2017-07-11 12:24:03 +02:00
|
|
|
if (print_all) {
|
2017-05-26 08:05:01 +02:00
|
|
|
printf("%c\tuser-name: \"%s\"\n", MARK_CHANGE(0), info->user_name);
|
|
|
|
|
printf("%c\thost-name: \"%s\"\n", MARK_CHANGE(1), info->host_name);
|
|
|
|
|
printf("%c\tversion: \"%s\"\n", MARK_CHANGE(2), info->version);
|
|
|
|
|
printf("%c\tname: \"%s\"\n", MARK_CHANGE(3), info->name);
|
|
|
|
|
printf("%c\tcookie: %u\n", MARK_CHANGE(4), info->cookie);
|
|
|
|
|
print_properties(info->props, MARK_CHANGE(5));
|
|
|
|
|
}
|
2016-12-02 13:38:43 +01:00
|
|
|
}
|
|
|
|
|
|
2019-01-09 17:49:45 +01:00
|
|
|
static void module_event_info(void *object, const struct pw_module_info *info)
|
2016-12-02 13:38:43 +01:00
|
|
|
{
|
2017-09-18 09:35:00 +02:00
|
|
|
struct proxy_data *data = object;
|
2017-07-11 12:24:03 +02:00
|
|
|
bool print_all, print_mark;
|
2016-12-02 13:38:43 +01:00
|
|
|
|
2017-07-11 12:24:03 +02:00
|
|
|
print_all = true;
|
|
|
|
|
if (data->info == NULL) {
|
|
|
|
|
printf("added:\n");
|
|
|
|
|
print_mark = false;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
printf("changed:\n");
|
|
|
|
|
print_mark = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
info = data->info = pw_module_info_update(data->info, info);
|
2016-12-02 13:38:43 +01:00
|
|
|
|
2017-07-13 15:21:52 +02:00
|
|
|
printf("\tid: %d\n", data->id);
|
2017-07-18 14:58:14 +02:00
|
|
|
printf("\tparent_id: %d\n", data->parent_id);
|
2017-08-01 17:09:57 +02:00
|
|
|
printf("\tpermissions: %c%c%c\n", data->permissions & PW_PERM_R ? 'r' : '-',
|
|
|
|
|
data->permissions & PW_PERM_W ? 'w' : '-',
|
|
|
|
|
data->permissions & PW_PERM_X ? 'x' : '-');
|
2018-11-22 13:35:30 +01:00
|
|
|
printf("\ttype: %s (version %d)\n",
|
|
|
|
|
spa_debug_type_find_name(pw_type_info(), data->type), data->version);
|
2017-07-11 12:24:03 +02:00
|
|
|
if (print_all) {
|
|
|
|
|
printf("%c\tname: \"%s\"\n", MARK_CHANGE(0), info->name);
|
|
|
|
|
printf("%c\tfilename: \"%s\"\n", MARK_CHANGE(1), info->filename);
|
|
|
|
|
printf("%c\targs: \"%s\"\n", MARK_CHANGE(2), info->args);
|
|
|
|
|
print_properties(info->props, MARK_CHANGE(3));
|
2017-05-26 08:05:01 +02:00
|
|
|
}
|
2015-07-28 17:05:03 +02:00
|
|
|
}
|
|
|
|
|
|
2017-08-04 16:49:13 +02:00
|
|
|
static const struct pw_module_proxy_events module_events = {
|
|
|
|
|
PW_VERSION_MODULE_PROXY_EVENTS,
|
2017-08-04 10:18:54 +02:00
|
|
|
.info = module_event_info,
|
2017-07-11 12:24:03 +02:00
|
|
|
};
|
|
|
|
|
|
2018-02-20 10:31:55 +01:00
|
|
|
static void print_node(struct proxy_data *data)
|
2016-07-20 17:55:02 +02:00
|
|
|
{
|
2018-02-20 10:31:55 +01:00
|
|
|
struct pw_node_info *info = data->info;
|
2017-07-11 12:24:03 +02:00
|
|
|
bool print_all, print_mark;
|
2017-05-26 08:05:01 +02:00
|
|
|
|
2017-07-11 12:24:03 +02:00
|
|
|
print_all = true;
|
2018-02-20 10:31:55 +01:00
|
|
|
if (data->first) {
|
2017-07-11 12:24:03 +02:00
|
|
|
printf("added:\n");
|
|
|
|
|
print_mark = false;
|
2018-02-20 10:31:55 +01:00
|
|
|
data->first = false;
|
2017-05-26 08:05:01 +02:00
|
|
|
}
|
2017-07-11 12:24:03 +02:00
|
|
|
else {
|
|
|
|
|
printf("changed:\n");
|
|
|
|
|
print_mark = true;
|
|
|
|
|
}
|
|
|
|
|
|
2017-07-13 15:21:52 +02:00
|
|
|
printf("\tid: %d\n", data->id);
|
2017-07-18 14:58:14 +02:00
|
|
|
printf("\tparent_id: %d\n", data->parent_id);
|
2017-08-01 17:09:57 +02:00
|
|
|
printf("\tpermissions: %c%c%c\n", data->permissions & PW_PERM_R ? 'r' : '-',
|
|
|
|
|
data->permissions & PW_PERM_W ? 'w' : '-',
|
|
|
|
|
data->permissions & PW_PERM_X ? 'x' : '-');
|
2018-11-22 13:35:30 +01:00
|
|
|
printf("\ttype: %s (version %d)\n",
|
|
|
|
|
spa_debug_type_find_name(pw_type_info(), data->type), data->version);
|
2017-07-11 12:24:03 +02:00
|
|
|
if (print_all) {
|
2019-01-07 15:52:42 +01:00
|
|
|
uint32_t i;
|
2017-05-26 08:05:01 +02:00
|
|
|
|
|
|
|
|
printf("%c\tname: \"%s\"\n", MARK_CHANGE(0), info->name);
|
2018-02-20 10:31:55 +01:00
|
|
|
printf("%c\tparams:\n", MARK_CHANGE(5));
|
|
|
|
|
for (i = 0; i < data->n_params; i++) {
|
2018-08-27 15:03:11 +02:00
|
|
|
if (spa_pod_is_object_type(data->params[i], SPA_TYPE_OBJECT_Format))
|
2018-08-29 18:08:52 +02:00
|
|
|
spa_debug_format(10, NULL, data->params[i]);
|
2018-08-14 12:33:53 +02:00
|
|
|
else
|
2018-08-30 12:01:52 +02:00
|
|
|
spa_debug_pod(10, NULL, data->params[i]);
|
2017-11-07 17:39:31 +01:00
|
|
|
}
|
2018-02-20 10:31:55 +01:00
|
|
|
printf("%c\tinput ports: %u/%u\n", MARK_CHANGE(1),
|
|
|
|
|
info->n_input_ports, info->max_input_ports);
|
|
|
|
|
printf("%c\toutput ports: %u/%u\n", MARK_CHANGE(2),
|
|
|
|
|
info->n_output_ports, info->max_output_ports);
|
|
|
|
|
printf("%c\tstate: \"%s\"", MARK_CHANGE(3), pw_node_state_as_string(info->state));
|
2017-05-26 08:05:01 +02:00
|
|
|
if (info->state == PW_NODE_STATE_ERROR && info->error)
|
|
|
|
|
printf(" \"%s\"\n", info->error);
|
|
|
|
|
else
|
|
|
|
|
printf("\n");
|
2018-02-20 10:31:55 +01:00
|
|
|
print_properties(info->props, MARK_CHANGE(4));
|
|
|
|
|
|
|
|
|
|
|
2017-05-26 08:05:01 +02:00
|
|
|
}
|
2016-07-20 17:55:02 +02:00
|
|
|
}
|
|
|
|
|
|
2019-01-09 17:49:45 +01:00
|
|
|
static void node_event_info(void *object, const struct pw_node_info *info)
|
2018-02-20 10:31:55 +01:00
|
|
|
{
|
|
|
|
|
struct proxy_data *data = object;
|
2018-11-28 17:31:00 +01:00
|
|
|
bool is_new = data->info == NULL;
|
2018-02-20 10:31:55 +01:00
|
|
|
|
|
|
|
|
data->info = pw_node_info_update(data->info, info);
|
|
|
|
|
|
2018-11-28 17:31:00 +01:00
|
|
|
if (is_new) {
|
2018-02-20 10:31:55 +01:00
|
|
|
pw_node_proxy_enum_params((struct pw_node_proxy*)data->proxy,
|
2018-08-25 12:08:29 +02:00
|
|
|
SPA_PARAM_List, 0, 0, NULL);
|
2018-02-20 10:31:55 +01:00
|
|
|
add_pending(data);
|
|
|
|
|
}
|
|
|
|
|
if (data->pending_seq == SPA_ID_INVALID)
|
|
|
|
|
data->print_func(data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void node_event_param(void *object, uint32_t id, uint32_t index, uint32_t next,
|
|
|
|
|
const struct spa_pod *param)
|
|
|
|
|
{
|
|
|
|
|
struct proxy_data *data = object;
|
|
|
|
|
add_param(data, param);
|
|
|
|
|
}
|
|
|
|
|
|
2017-08-04 16:49:13 +02:00
|
|
|
static const struct pw_node_proxy_events node_events = {
|
|
|
|
|
PW_VERSION_NODE_PROXY_EVENTS,
|
2018-02-20 10:31:55 +01:00
|
|
|
.info = node_event_info,
|
|
|
|
|
.param = node_event_param
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static void print_port(struct proxy_data *data)
|
|
|
|
|
{
|
|
|
|
|
struct pw_port_info *info = data->info;
|
|
|
|
|
bool print_all, print_mark;
|
|
|
|
|
|
|
|
|
|
print_all = true;
|
|
|
|
|
if (data->first) {
|
|
|
|
|
printf("added:\n");
|
|
|
|
|
print_mark = false;
|
|
|
|
|
data->first = false;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
printf("changed:\n");
|
|
|
|
|
print_mark = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
printf("\tid: %d\n", data->id);
|
|
|
|
|
printf("\tparent_id: %d\n", data->parent_id);
|
|
|
|
|
printf("\tpermissions: %c%c%c\n", data->permissions & PW_PERM_R ? 'r' : '-',
|
|
|
|
|
data->permissions & PW_PERM_W ? 'w' : '-',
|
|
|
|
|
data->permissions & PW_PERM_X ? 'x' : '-');
|
2018-11-22 13:35:30 +01:00
|
|
|
printf("\ttype: %s (version %d)\n",
|
|
|
|
|
spa_debug_type_find_name(pw_type_info(), data->type), data->version);
|
2018-02-20 10:31:55 +01:00
|
|
|
if (print_all) {
|
2019-01-07 15:52:42 +01:00
|
|
|
uint32_t i;
|
2018-09-13 17:03:56 +02:00
|
|
|
printf(" \tdirection: \"%s\"\n", pw_direction_as_string(info->direction));
|
2018-10-04 15:18:31 +02:00
|
|
|
printf("%c\tparams:\n", MARK_CHANGE(2));
|
2018-02-20 10:31:55 +01:00
|
|
|
for (i = 0; i < data->n_params; i++) {
|
2018-08-27 15:03:11 +02:00
|
|
|
if (spa_pod_is_object_type(data->params[i], SPA_TYPE_OBJECT_Format))
|
2018-08-29 18:08:52 +02:00
|
|
|
spa_debug_format(12, NULL, data->params[i]);
|
2018-08-14 12:33:53 +02:00
|
|
|
else
|
2018-08-30 12:01:52 +02:00
|
|
|
spa_debug_pod(12, NULL, data->params[i]);
|
2018-02-20 10:31:55 +01:00
|
|
|
}
|
|
|
|
|
print_properties(info->props, MARK_CHANGE(1));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-09 17:49:45 +01:00
|
|
|
static void port_event_info(void *object, const struct pw_port_info *info)
|
2018-02-20 10:31:55 +01:00
|
|
|
{
|
|
|
|
|
|
|
|
|
|
struct proxy_data *data = object;
|
2018-11-28 17:31:00 +01:00
|
|
|
bool is_new = data->info == NULL;
|
2018-02-20 10:31:55 +01:00
|
|
|
|
|
|
|
|
data->info = pw_port_info_update(data->info, info);
|
|
|
|
|
|
2018-11-28 17:31:00 +01:00
|
|
|
if (is_new) {
|
2018-02-20 10:31:55 +01:00
|
|
|
pw_port_proxy_enum_params((struct pw_port_proxy*)data->proxy,
|
2018-08-25 12:08:29 +02:00
|
|
|
SPA_PARAM_EnumFormat, 0, 0, NULL);
|
2018-02-20 10:31:55 +01:00
|
|
|
add_pending(data);
|
|
|
|
|
}
|
|
|
|
|
if (data->pending_seq == SPA_ID_INVALID)
|
|
|
|
|
data->print_func(data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void port_event_param(void *object, uint32_t id, uint32_t index, uint32_t next,
|
|
|
|
|
const struct spa_pod *param)
|
|
|
|
|
{
|
|
|
|
|
struct proxy_data *data = object;
|
|
|
|
|
add_param(data, param);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static const struct pw_port_proxy_events port_events = {
|
|
|
|
|
PW_VERSION_PORT_PROXY_EVENTS,
|
|
|
|
|
.info = port_event_info,
|
|
|
|
|
.param = port_event_param
|
2017-07-11 12:24:03 +02:00
|
|
|
};
|
|
|
|
|
|
2019-01-09 17:49:45 +01:00
|
|
|
static void factory_event_info(void *object, const struct pw_factory_info *info)
|
2017-09-18 09:35:00 +02:00
|
|
|
{
|
|
|
|
|
struct proxy_data *data = object;
|
|
|
|
|
bool print_all, print_mark;
|
|
|
|
|
|
|
|
|
|
print_all = true;
|
|
|
|
|
if (data->info == NULL) {
|
|
|
|
|
printf("added:\n");
|
|
|
|
|
print_mark = false;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
printf("changed:\n");
|
|
|
|
|
print_mark = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
info = data->info = pw_factory_info_update(data->info, info);
|
|
|
|
|
|
|
|
|
|
printf("\tid: %d\n", data->id);
|
|
|
|
|
printf("\tparent_id: %d\n", data->parent_id);
|
|
|
|
|
printf("\tpermissions: %c%c%c\n", data->permissions & PW_PERM_R ? 'r' : '-',
|
|
|
|
|
data->permissions & PW_PERM_W ? 'w' : '-',
|
|
|
|
|
data->permissions & PW_PERM_X ? 'x' : '-');
|
2018-11-22 13:35:30 +01:00
|
|
|
printf("\ttype: %s (version %d)\n",
|
|
|
|
|
spa_debug_type_find_name(pw_type_info(), data->type), data->version);
|
2017-09-18 09:35:00 +02:00
|
|
|
printf("\tname: \"%s\"\n", info->name);
|
2018-10-31 16:05:58 +00:00
|
|
|
printf("\tobject-type: %s/%d\n", spa_debug_type_find_name(pw_type_info(), info->type), info->version);
|
2017-09-18 09:35:00 +02:00
|
|
|
if (print_all) {
|
|
|
|
|
print_properties(info->props, MARK_CHANGE(0));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static const struct pw_factory_proxy_events factory_events = {
|
|
|
|
|
PW_VERSION_FACTORY_PROXY_EVENTS,
|
|
|
|
|
.info = factory_event_info
|
|
|
|
|
};
|
|
|
|
|
|
2019-01-09 17:49:45 +01:00
|
|
|
static void client_event_info(void *object, const struct pw_client_info *info)
|
2015-07-28 17:05:03 +02:00
|
|
|
{
|
2017-09-18 09:35:00 +02:00
|
|
|
struct proxy_data *data = object;
|
2017-07-11 12:24:03 +02:00
|
|
|
bool print_all, print_mark;
|
2017-05-26 08:05:01 +02:00
|
|
|
|
2017-07-11 12:24:03 +02:00
|
|
|
print_all = true;
|
|
|
|
|
if (data->info == NULL) {
|
|
|
|
|
printf("added:\n");
|
|
|
|
|
print_mark = false;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
printf("changed:\n");
|
|
|
|
|
print_mark = true;
|
2017-05-26 08:05:01 +02:00
|
|
|
}
|
|
|
|
|
|
2017-07-11 12:24:03 +02:00
|
|
|
info = data->info = pw_client_info_update(data->info, info);
|
|
|
|
|
|
2017-07-13 15:21:52 +02:00
|
|
|
printf("\tid: %d\n", data->id);
|
2017-07-18 14:58:14 +02:00
|
|
|
printf("\tparent_id: %d\n", data->parent_id);
|
2017-08-01 17:09:57 +02:00
|
|
|
printf("\tpermissions: %c%c%c\n", data->permissions & PW_PERM_R ? 'r' : '-',
|
|
|
|
|
data->permissions & PW_PERM_W ? 'w' : '-',
|
|
|
|
|
data->permissions & PW_PERM_X ? 'x' : '-');
|
2018-11-22 13:35:30 +01:00
|
|
|
printf("\ttype: %s (version %d)\n",
|
|
|
|
|
spa_debug_type_find_name(pw_type_info(), data->type), data->version);
|
2017-07-11 12:24:03 +02:00
|
|
|
if (print_all) {
|
|
|
|
|
print_properties(info->props, MARK_CHANGE(0));
|
2017-05-26 08:05:01 +02:00
|
|
|
}
|
2015-07-28 17:05:03 +02:00
|
|
|
}
|
|
|
|
|
|
2017-08-04 16:49:13 +02:00
|
|
|
static const struct pw_client_proxy_events client_events = {
|
|
|
|
|
PW_VERSION_CLIENT_PROXY_EVENTS,
|
2017-08-04 10:18:54 +02:00
|
|
|
.info = client_event_info
|
2017-07-11 12:24:03 +02:00
|
|
|
};
|
|
|
|
|
|
2019-01-09 17:49:45 +01:00
|
|
|
static void link_event_info(void *object, const struct pw_link_info *info)
|
2016-07-20 17:55:02 +02:00
|
|
|
{
|
2017-09-18 09:35:00 +02:00
|
|
|
struct proxy_data *data = object;
|
2017-07-11 12:24:03 +02:00
|
|
|
bool print_all, print_mark;
|
2017-05-26 08:05:01 +02:00
|
|
|
|
2017-07-11 12:24:03 +02:00
|
|
|
print_all = true;
|
|
|
|
|
if (data->info == NULL) {
|
|
|
|
|
printf("added:\n");
|
|
|
|
|
print_mark = false;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
printf("changed:\n");
|
|
|
|
|
print_mark = true;
|
2017-05-26 08:05:01 +02:00
|
|
|
}
|
|
|
|
|
|
2017-07-11 12:24:03 +02:00
|
|
|
info = data->info = pw_link_info_update(data->info, info);
|
|
|
|
|
|
2017-07-13 15:21:52 +02:00
|
|
|
printf("\tid: %d\n", data->id);
|
2017-07-18 14:58:14 +02:00
|
|
|
printf("\tparent_id: %d\n", data->parent_id);
|
2017-08-01 17:09:57 +02:00
|
|
|
printf("\tpermissions: %c%c%c\n", data->permissions & PW_PERM_R ? 'r' : '-',
|
|
|
|
|
data->permissions & PW_PERM_W ? 'w' : '-',
|
|
|
|
|
data->permissions & PW_PERM_X ? 'x' : '-');
|
2018-11-22 13:35:30 +01:00
|
|
|
printf("\ttype: %s (version %d)\n",
|
|
|
|
|
spa_debug_type_find_name(pw_type_info(), data->type), data->version);
|
2017-07-11 12:24:03 +02:00
|
|
|
if (print_all) {
|
2017-05-26 08:05:01 +02:00
|
|
|
printf("%c\toutput-node-id: %u\n", MARK_CHANGE(0), info->output_node_id);
|
2017-08-20 18:33:07 +02:00
|
|
|
printf("%c\toutput-port-id: %u\n", MARK_CHANGE(0), info->output_port_id);
|
|
|
|
|
printf("%c\tinput-node-id: %u\n", MARK_CHANGE(1), info->input_node_id);
|
|
|
|
|
printf("%c\tinput-port-id: %u\n", MARK_CHANGE(1), info->input_port_id);
|
2018-10-03 19:29:11 +02:00
|
|
|
printf("%c\tstate: \"%s\"", MARK_CHANGE(2), pw_link_state_as_string(info->state));
|
|
|
|
|
if (info->state == PW_LINK_STATE_ERROR && info->error)
|
|
|
|
|
printf(" \"%s\"\n", info->error);
|
|
|
|
|
else
|
|
|
|
|
printf("\n");
|
|
|
|
|
printf("%c\tformat:\n", MARK_CHANGE(3));
|
2017-06-02 10:40:43 +02:00
|
|
|
if (info->format)
|
2018-08-23 17:47:57 +02:00
|
|
|
spa_debug_format(2, NULL, info->format);
|
2017-06-02 10:40:43 +02:00
|
|
|
else
|
2017-08-27 17:58:25 +02:00
|
|
|
printf("\t\tnone\n");
|
2018-10-03 19:29:11 +02:00
|
|
|
print_properties(info->props, MARK_CHANGE(4));
|
2017-05-26 08:05:01 +02:00
|
|
|
}
|
2015-07-28 17:05:03 +02:00
|
|
|
}
|
|
|
|
|
|
2017-08-04 16:49:13 +02:00
|
|
|
static const struct pw_link_proxy_events link_events = {
|
|
|
|
|
PW_VERSION_LINK_PROXY_EVENTS,
|
2017-08-04 10:18:54 +02:00
|
|
|
.info = link_event_info
|
2017-07-11 12:24:03 +02:00
|
|
|
};
|
|
|
|
|
|
2018-11-23 12:43:47 +01:00
|
|
|
|
|
|
|
|
|
2019-01-09 17:49:45 +01:00
|
|
|
static void device_event_info(void *object, const struct pw_device_info *info)
|
2018-11-23 12:43:47 +01:00
|
|
|
{
|
|
|
|
|
struct proxy_data *data = object;
|
|
|
|
|
bool print_all, print_mark;
|
|
|
|
|
|
|
|
|
|
print_all = true;
|
|
|
|
|
if (data->info == NULL) {
|
|
|
|
|
printf("added:\n");
|
|
|
|
|
print_mark = false;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
printf("changed:\n");
|
|
|
|
|
print_mark = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
info = data->info = pw_device_info_update(data->info, info);
|
|
|
|
|
|
|
|
|
|
printf("\tid: %d\n", data->id);
|
|
|
|
|
printf("\tparent_id: %d\n", data->parent_id);
|
|
|
|
|
printf("\tpermissions: %c%c%c\n", data->permissions & PW_PERM_R ? 'r' : '-',
|
|
|
|
|
data->permissions & PW_PERM_W ? 'w' : '-',
|
|
|
|
|
data->permissions & PW_PERM_X ? 'x' : '-');
|
|
|
|
|
printf("\ttype: %s (version %d)\n",
|
|
|
|
|
spa_debug_type_find_name(pw_type_info(), data->type), data->version);
|
|
|
|
|
if (print_all) {
|
|
|
|
|
print_properties(info->props, MARK_CHANGE(0));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static const struct pw_device_proxy_events device_events = {
|
|
|
|
|
PW_VERSION_DEVICE_PROXY_EVENTS,
|
|
|
|
|
.info = device_event_info
|
|
|
|
|
};
|
|
|
|
|
|
2015-07-28 17:05:03 +02:00
|
|
|
static void
|
2017-07-11 12:24:03 +02:00
|
|
|
destroy_proxy (void *data)
|
2015-07-28 17:05:03 +02:00
|
|
|
{
|
2018-04-19 20:02:06 +02:00
|
|
|
struct proxy_data *pd = data;
|
2017-07-11 12:24:03 +02:00
|
|
|
|
2018-04-19 20:02:06 +02:00
|
|
|
clear_params(pd);
|
|
|
|
|
remove_pending(pd);
|
2018-02-20 10:31:55 +01:00
|
|
|
|
2018-04-19 20:02:06 +02:00
|
|
|
if (pd->info == NULL)
|
2017-07-11 12:24:03 +02:00
|
|
|
return;
|
|
|
|
|
|
2018-04-19 20:02:06 +02:00
|
|
|
if (pd->destroy)
|
|
|
|
|
pd->destroy(pd->info);
|
|
|
|
|
pd->info = NULL;
|
2017-07-11 12:24:03 +02:00
|
|
|
}
|
2016-12-02 13:38:43 +01:00
|
|
|
|
2017-08-04 16:49:13 +02:00
|
|
|
static const struct pw_proxy_events proxy_events = {
|
|
|
|
|
PW_VERSION_PROXY_EVENTS,
|
2017-08-04 10:18:54 +02:00
|
|
|
.destroy = destroy_proxy,
|
|
|
|
|
};
|
2017-01-10 17:12:53 +01:00
|
|
|
|
2017-08-04 10:18:54 +02:00
|
|
|
static void registry_event_global(void *data, uint32_t id, uint32_t parent_id,
|
2018-01-19 11:18:17 +01:00
|
|
|
uint32_t permissions, uint32_t type, uint32_t version,
|
|
|
|
|
const struct spa_dict *props)
|
2017-07-11 12:24:03 +02:00
|
|
|
{
|
2017-08-04 10:18:54 +02:00
|
|
|
struct data *d = data;
|
|
|
|
|
struct pw_proxy *proxy;
|
2017-07-11 18:41:22 +02:00
|
|
|
uint32_t client_version;
|
2017-07-13 15:21:52 +02:00
|
|
|
const void *events;
|
|
|
|
|
struct proxy_data *pd;
|
2017-08-04 10:18:54 +02:00
|
|
|
pw_destroy_t destroy;
|
2018-02-20 10:31:55 +01:00
|
|
|
print_func_t print_func = NULL;
|
2017-07-11 12:24:03 +02:00
|
|
|
|
2018-11-22 13:35:30 +01:00
|
|
|
switch (type) {
|
|
|
|
|
case PW_TYPE_INTERFACE_Node:
|
2017-07-13 15:21:52 +02:00
|
|
|
events = &node_events;
|
|
|
|
|
client_version = PW_VERSION_NODE;
|
2017-08-04 10:18:54 +02:00
|
|
|
destroy = (pw_destroy_t) pw_node_info_free;
|
2018-02-20 10:31:55 +01:00
|
|
|
print_func = print_node;
|
2018-11-22 13:35:30 +01:00
|
|
|
break;
|
|
|
|
|
case PW_TYPE_INTERFACE_Port:
|
2018-02-20 10:31:55 +01:00
|
|
|
events = &port_events;
|
|
|
|
|
client_version = PW_VERSION_PORT;
|
|
|
|
|
destroy = (pw_destroy_t) pw_port_info_free;
|
|
|
|
|
print_func = print_port;
|
2018-11-22 13:35:30 +01:00
|
|
|
break;
|
|
|
|
|
case PW_TYPE_INTERFACE_Module:
|
2017-07-13 15:21:52 +02:00
|
|
|
events = &module_events;
|
|
|
|
|
client_version = PW_VERSION_MODULE;
|
2017-08-04 10:18:54 +02:00
|
|
|
destroy = (pw_destroy_t) pw_module_info_free;
|
2018-11-22 13:35:30 +01:00
|
|
|
break;
|
2018-11-23 12:43:47 +01:00
|
|
|
case PW_TYPE_INTERFACE_Device:
|
|
|
|
|
events = &device_events;
|
|
|
|
|
client_version = PW_VERSION_DEVICE;
|
|
|
|
|
destroy = (pw_destroy_t) pw_device_info_free;
|
|
|
|
|
break;
|
2018-11-22 13:35:30 +01:00
|
|
|
case PW_TYPE_INTERFACE_Factory:
|
2017-09-18 09:35:00 +02:00
|
|
|
events = &factory_events;
|
|
|
|
|
client_version = PW_VERSION_FACTORY;
|
|
|
|
|
destroy = (pw_destroy_t) pw_factory_info_free;
|
2018-11-22 13:35:30 +01:00
|
|
|
break;
|
|
|
|
|
case PW_TYPE_INTERFACE_Client:
|
2017-07-13 15:21:52 +02:00
|
|
|
events = &client_events;
|
|
|
|
|
client_version = PW_VERSION_CLIENT;
|
2017-08-04 10:18:54 +02:00
|
|
|
destroy = (pw_destroy_t) pw_client_info_free;
|
2018-11-22 13:35:30 +01:00
|
|
|
break;
|
|
|
|
|
case PW_TYPE_INTERFACE_Link:
|
2017-07-13 15:21:52 +02:00
|
|
|
events = &link_events;
|
|
|
|
|
client_version = PW_VERSION_LINK;
|
2017-08-04 10:18:54 +02:00
|
|
|
destroy = (pw_destroy_t) pw_link_info_free;
|
2018-11-22 13:35:30 +01:00
|
|
|
break;
|
|
|
|
|
default:
|
2017-07-13 15:21:52 +02:00
|
|
|
printf("added:\n");
|
|
|
|
|
printf("\tid: %u\n", id);
|
2017-07-18 14:58:14 +02:00
|
|
|
printf("\tparent_id: %d\n", parent_id);
|
2017-08-01 17:09:57 +02:00
|
|
|
printf("\tpermissions: %c%c%c\n", permissions & PW_PERM_R ? 'r' : '-',
|
|
|
|
|
permissions & PW_PERM_W ? 'w' : '-',
|
|
|
|
|
permissions & PW_PERM_X ? 'x' : '-');
|
2018-10-31 16:05:58 +00:00
|
|
|
printf("\ttype: %s (version %d)\n", spa_debug_type_find_name(pw_type_info(), type), version);
|
2018-01-19 11:18:17 +01:00
|
|
|
print_properties(props, ' ');
|
2017-07-13 15:21:52 +02:00
|
|
|
return;
|
|
|
|
|
}
|
2017-07-11 12:24:03 +02:00
|
|
|
|
2017-08-04 10:18:54 +02:00
|
|
|
proxy = pw_registry_proxy_bind(d->registry_proxy, id, type,
|
|
|
|
|
client_version,
|
|
|
|
|
sizeof(struct proxy_data));
|
2017-07-11 12:24:03 +02:00
|
|
|
if (proxy == NULL)
|
|
|
|
|
goto no_mem;
|
|
|
|
|
|
2017-08-04 10:18:54 +02:00
|
|
|
pd = pw_proxy_get_user_data(proxy);
|
2017-09-18 09:35:00 +02:00
|
|
|
pd->data = d;
|
2018-02-20 10:31:55 +01:00
|
|
|
pd->first = true;
|
2017-08-04 10:18:54 +02:00
|
|
|
pd->proxy = proxy;
|
2017-07-13 15:21:52 +02:00
|
|
|
pd->id = id;
|
2017-07-18 14:58:14 +02:00
|
|
|
pd->parent_id = parent_id;
|
2017-08-01 17:09:57 +02:00
|
|
|
pd->permissions = permissions;
|
2017-07-13 15:21:52 +02:00
|
|
|
pd->version = version;
|
2018-11-22 13:35:30 +01:00
|
|
|
pd->type = type;
|
2017-08-04 10:18:54 +02:00
|
|
|
pd->destroy = destroy;
|
2018-02-20 10:31:55 +01:00
|
|
|
pd->pending_seq = SPA_ID_INVALID;
|
|
|
|
|
pd->print_func = print_func;
|
2017-08-04 16:49:13 +02:00
|
|
|
pw_proxy_add_proxy_listener(proxy, &pd->proxy_proxy_listener, events, pd);
|
|
|
|
|
pw_proxy_add_listener(proxy, &pd->proxy_listener, &proxy_events, pd);
|
2017-07-11 12:24:03 +02:00
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
no_mem:
|
|
|
|
|
printf("failed to create proxy");
|
|
|
|
|
return;
|
2015-04-27 09:05:14 +02:00
|
|
|
}
|
|
|
|
|
|
2017-07-11 12:24:03 +02:00
|
|
|
static void registry_event_global_remove(void *object, uint32_t id)
|
2015-04-16 16:58:33 +02:00
|
|
|
{
|
2017-07-11 12:24:03 +02:00
|
|
|
printf("removed:\n");
|
|
|
|
|
printf("\tid: %u\n", id);
|
2015-04-16 16:58:33 +02:00
|
|
|
}
|
|
|
|
|
|
2017-08-04 16:49:13 +02:00
|
|
|
static const struct pw_registry_proxy_events registry_events = {
|
|
|
|
|
PW_VERSION_REGISTRY_PROXY_EVENTS,
|
2017-08-04 10:18:54 +02:00
|
|
|
.global = registry_event_global,
|
|
|
|
|
.global_remove = registry_event_global_remove,
|
2017-07-11 12:24:03 +02:00
|
|
|
};
|
|
|
|
|
|
2017-08-04 10:18:54 +02:00
|
|
|
static void on_state_changed(void *_data, enum pw_remote_state old,
|
|
|
|
|
enum pw_remote_state state, const char *error)
|
2015-04-16 16:58:33 +02:00
|
|
|
{
|
2017-08-04 10:18:54 +02:00
|
|
|
struct data *data = _data;
|
2017-05-26 08:05:01 +02:00
|
|
|
|
2017-08-04 10:18:54 +02:00
|
|
|
switch (state) {
|
2017-07-11 15:57:20 +02:00
|
|
|
case PW_REMOTE_STATE_ERROR:
|
2017-08-04 10:18:54 +02:00
|
|
|
printf("remote error: %s\n", error);
|
2017-09-11 09:48:13 +02:00
|
|
|
pw_main_loop_quit(data->loop);
|
2017-05-26 08:05:01 +02:00
|
|
|
break;
|
|
|
|
|
|
2017-07-11 15:57:20 +02:00
|
|
|
case PW_REMOTE_STATE_CONNECTED:
|
2017-08-04 10:18:54 +02:00
|
|
|
printf("remote state: \"%s\"\n", pw_remote_state_as_string(state));
|
2017-07-11 12:24:03 +02:00
|
|
|
|
2017-08-04 10:18:54 +02:00
|
|
|
data->core_proxy = pw_remote_get_core_proxy(data->remote);
|
|
|
|
|
data->registry_proxy = pw_core_proxy_get_registry(data->core_proxy,
|
2018-08-27 15:03:11 +02:00
|
|
|
PW_TYPE_INTERFACE_Registry,
|
2017-08-04 10:18:54 +02:00
|
|
|
PW_VERSION_REGISTRY, 0);
|
2017-07-13 15:21:52 +02:00
|
|
|
pw_registry_proxy_add_listener(data->registry_proxy,
|
2017-08-04 10:18:54 +02:00
|
|
|
&data->registry_listener,
|
|
|
|
|
®istry_events, data);
|
2017-07-11 12:24:03 +02:00
|
|
|
break;
|
|
|
|
|
|
2017-05-26 08:05:01 +02:00
|
|
|
default:
|
2017-08-04 10:18:54 +02:00
|
|
|
printf("remote state: \"%s\"\n", pw_remote_state_as_string(state));
|
2017-05-26 08:05:01 +02:00
|
|
|
break;
|
|
|
|
|
}
|
2015-04-16 16:58:33 +02:00
|
|
|
}
|
|
|
|
|
|
2017-08-04 16:49:13 +02:00
|
|
|
static const struct pw_remote_events remote_events = {
|
|
|
|
|
PW_VERSION_REMOTE_EVENTS,
|
2017-08-04 10:18:54 +02:00
|
|
|
.info_changed = on_info_changed,
|
|
|
|
|
.state_changed = on_state_changed,
|
2018-02-20 10:31:55 +01:00
|
|
|
.sync_reply = on_sync_reply,
|
2017-08-04 10:18:54 +02:00
|
|
|
};
|
|
|
|
|
|
2017-09-11 09:48:13 +02:00
|
|
|
static void do_quit(void *data, int signal_number)
|
|
|
|
|
{
|
|
|
|
|
struct data *d = data;
|
|
|
|
|
pw_main_loop_quit(d->loop);
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-26 08:05:01 +02:00
|
|
|
int main(int argc, char *argv[])
|
2015-04-16 16:58:33 +02:00
|
|
|
{
|
2017-07-11 12:24:03 +02:00
|
|
|
struct data data = { 0 };
|
2017-09-11 09:48:13 +02:00
|
|
|
struct pw_loop *l;
|
2017-09-19 10:19:53 +02:00
|
|
|
struct pw_properties *props = NULL;
|
2015-04-16 16:58:33 +02:00
|
|
|
|
2017-05-26 08:05:01 +02:00
|
|
|
pw_init(&argc, &argv);
|
2015-04-16 16:58:33 +02:00
|
|
|
|
2017-09-11 09:48:13 +02:00
|
|
|
data.loop = pw_main_loop_new(NULL);
|
2017-09-18 11:54:25 +02:00
|
|
|
if (data.loop == NULL)
|
|
|
|
|
return -1;
|
|
|
|
|
|
2017-09-11 09:48:13 +02:00
|
|
|
l = pw_main_loop_get_loop(data.loop);
|
|
|
|
|
pw_loop_add_signal(l, SIGINT, do_quit, &data);
|
|
|
|
|
pw_loop_add_signal(l, SIGTERM, do_quit, &data);
|
|
|
|
|
|
2019-01-08 17:30:12 +01:00
|
|
|
data.core = pw_core_new(l, NULL, 0);
|
2017-09-18 11:54:25 +02:00
|
|
|
if (data.core == NULL)
|
|
|
|
|
return -1;
|
|
|
|
|
|
2017-09-19 10:19:53 +02:00
|
|
|
if (argc > 1)
|
|
|
|
|
props = pw_properties_new(PW_REMOTE_PROP_REMOTE_NAME, argv[1], NULL);
|
|
|
|
|
|
|
|
|
|
data.remote = pw_remote_new(data.core, props, 0);
|
2017-09-18 11:54:25 +02:00
|
|
|
if (data.remote == NULL)
|
|
|
|
|
return -1;
|
2015-04-16 16:58:33 +02:00
|
|
|
|
2017-08-04 16:49:13 +02:00
|
|
|
pw_remote_add_listener(data.remote, &data.remote_listener, &remote_events, &data);
|
2017-09-18 11:54:25 +02:00
|
|
|
if (pw_remote_connect(data.remote) < 0)
|
|
|
|
|
return -1;
|
2016-11-24 17:00:42 +01:00
|
|
|
|
2018-02-20 10:31:55 +01:00
|
|
|
data.seq = 1;
|
|
|
|
|
spa_list_init(&data.pending_list);
|
|
|
|
|
|
2017-09-11 09:48:13 +02:00
|
|
|
pw_main_loop_run(data.loop);
|
2015-04-16 16:58:33 +02:00
|
|
|
|
2017-07-11 12:24:03 +02:00
|
|
|
pw_remote_destroy(data.remote);
|
2017-09-11 09:48:13 +02:00
|
|
|
pw_core_destroy(data.core);
|
|
|
|
|
pw_main_loop_destroy(data.loop);
|
2015-04-16 16:58:33 +02:00
|
|
|
|
2017-05-26 08:05:01 +02:00
|
|
|
return 0;
|
2015-04-16 16:58:33 +02:00
|
|
|
}
|