mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-04 13:30:12 -05:00
pw-link: do argument check before sync
This commit is contained in:
parent
e362a66880
commit
8cf5bbf658
1 changed files with 20 additions and 7 deletions
|
|
@ -453,6 +453,9 @@ static int create_link_proxies(struct data *data)
|
||||||
struct object *n, *p;
|
struct object *n, *p;
|
||||||
struct object *in_node = NULL, *out_node = NULL;
|
struct object *in_node = NULL, *out_node = NULL;
|
||||||
|
|
||||||
|
spa_assert(data->opt_output);
|
||||||
|
spa_assert(data->opt_input);
|
||||||
|
|
||||||
spa_list_for_each(n, &data->objects, link) {
|
spa_list_for_each(n, &data->objects, link) {
|
||||||
if (n->type != OBJECT_NODE)
|
if (n->type != OBJECT_NODE)
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -523,6 +526,8 @@ static int do_unlink_ports(struct data *data)
|
||||||
bool found_any = false;
|
bool found_any = false;
|
||||||
struct object *in_node = NULL, *out_node = NULL;
|
struct object *in_node = NULL, *out_node = NULL;
|
||||||
|
|
||||||
|
spa_assert(data->opt_output);
|
||||||
|
|
||||||
if (data->opt_input != NULL) {
|
if (data->opt_input != NULL) {
|
||||||
/* 2 args, check if they are node names */
|
/* 2 args, check if they are node names */
|
||||||
spa_list_for_each(n, &data->objects, link) {
|
spa_list_for_each(n, &data->objects, link) {
|
||||||
|
|
@ -966,10 +971,22 @@ static int run(int argc, char *argv[])
|
||||||
if (optind < argc)
|
if (optind < argc)
|
||||||
data.opt_input = argv[optind++];
|
data.opt_input = argv[optind++];
|
||||||
|
|
||||||
if (data.opt_mode == MODE_CONNECT && (data.opt_output == NULL || data.opt_input == NULL)) {
|
switch (data.opt_mode) {
|
||||||
|
case MODE_LIST:
|
||||||
|
break;
|
||||||
|
case MODE_DISCONNECT:
|
||||||
|
if (data.opt_output == NULL) {
|
||||||
|
fprintf(stderr, "missing link-id or output and input port names to disconnect\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case MODE_CONNECT:
|
||||||
|
if (data.opt_output == NULL || data.opt_input == NULL) {
|
||||||
fprintf(stderr, "missing output and input port names to connect\n");
|
fprintf(stderr, "missing output and input port names to connect\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
data.loop = pw_main_loop_new(NULL);
|
data.loop = pw_main_loop_new(NULL);
|
||||||
if (data.loop == NULL) {
|
if (data.loop == NULL) {
|
||||||
|
|
@ -1031,10 +1048,6 @@ static int run(int argc, char *argv[])
|
||||||
do_list(&data);
|
do_list(&data);
|
||||||
break;
|
break;
|
||||||
case MODE_DISCONNECT:
|
case MODE_DISCONNECT:
|
||||||
if (data.opt_output == NULL) {
|
|
||||||
fprintf(stderr, "missing link-id or output and input port names to disconnect\n");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if ((res = do_unlink_ports(&data)) < 0) {
|
if ((res = do_unlink_ports(&data)) < 0) {
|
||||||
fprintf(stderr, "failed to unlink ports: %s\n", spa_strerror(res));
|
fprintf(stderr, "failed to unlink ports: %s\n", spa_strerror(res));
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue