diff --git a/src/tools/pipewire-cli.c b/src/tools/pipewire-cli.c index 83a4ad67b..2605a8c5a 100644 --- a/src/tools/pipewire-cli.c +++ b/src/tools/pipewire-cli.c @@ -172,9 +172,8 @@ static bool do_list_remotes(struct data *data, const char *cmd, char *args, char static bool do_switch_remote(struct data *data, const char *cmd, char *args, char **error); static bool do_info(struct data *data, const char *cmd, char *args, char **error); static bool do_create_node(struct data *data, const char *cmd, char *args, char **error); -static bool do_destroy_node(struct data *data, const char *cmd, char *args, char **error); +static bool do_destroy(struct data *data, const char *cmd, char *args, char **error); static bool do_create_link(struct data *data, const char *cmd, char *args, char **error); -static bool do_destroy_link(struct data *data, const char *cmd, char *args, char **error); static bool do_export_node(struct data *data, const char *cmd, char *args, char **error); static struct command command_list[] = { @@ -188,9 +187,8 @@ static struct command command_list[] = { { "list-objects", "List objects or current remote.", do_list_objects }, { "info", "Get info about an object. |all", do_info }, { "create-node", "Create a node from a factory. []", do_create_node }, - { "destroy-node", "Destroy a node. ", do_destroy_node }, + { "destroy", "Destroy a global object. ", do_destroy }, { "create-link", "Create a link between nodes. []", do_create_link }, - { "destroy-link", "Destroy a link. ", do_destroy_link }, { "export-node", "Export a local node to the current remote. [remote-var]", do_export_node }, }; @@ -920,10 +918,28 @@ static bool do_create_node(struct data *data, const char *cmd, char *args, char return true; } -static bool do_destroy_node(struct data *data, const char *cmd, char *args, char **error) +static bool do_destroy(struct data *data, const char *cmd, char *args, char **error) { - asprintf(error, "Command \"%s\" not yet implemented", cmd); - return false; + struct remote_data *rd = data->current; + char *a[1]; + int n; + uint32_t id; + struct global *global; + + n = pw_split_ip(args, WHITESPACE, 1, a); + if (n < 1) { + asprintf(error, "%s ", cmd); + return false; + } + id = atoi(a[0]); + global = pw_map_lookup(&rd->globals, id); + if (global == NULL) { + asprintf(error, "%s: unknown global %d", cmd, id); + return false; + } + pw_core_proxy_destroy(rd->core_proxy, id); + + return true; } static bool do_create_link(struct data *data, const char *cmd, char *args, char **error) @@ -972,12 +988,6 @@ static bool do_create_link(struct data *data, const char *cmd, char *args, char return true; } -static bool do_destroy_link(struct data *data, const char *cmd, char *args, char **error) -{ - asprintf(error, "Command \"%s\" not yet implemented", cmd); - return false; -} - static bool do_export_node(struct data *data, const char *cmd, char *args, char **error) { struct pw_type *t = data->t;