daemon: make flags parse like an array

This commit is contained in:
Wim Taymans 2021-02-08 17:30:26 +01:00
parent ecd1d3e1d7
commit 085fd536be
2 changed files with 9 additions and 5 deletions

View file

@ -171,7 +171,11 @@ static int parse_modules(struct data *d, const char *str)
args = malloc(alen + 1); args = malloc(alen + 1);
spa_json_parse_string(aval, alen, args); spa_json_parse_string(aval, alen, args);
} else if (strcmp(arg, "flags") == 0) { } else if (strcmp(arg, "flags") == 0) {
flags = strndup(aval, alen); if (spa_json_is_container(aval, alen))
alen = spa_json_container_len(&it[2], aval, alen);
flags = malloc(alen + 1);
spa_json_parse_string(aval, alen, flags);
} }
} }
} }

View file

@ -42,7 +42,7 @@ spa-libs = {
modules = { modules = {
## <module-name> = { [args = { <key>=<value> ... }] ## <module-name> = { [args = { <key>=<value> ... }]
# [flags = "[ifexists]|[nofail]"} # [flags = [ [ifexists] [nofail] ]}
# #
# Loads a module with the given parameters. # Loads a module with the given parameters.
# If ifexists is given, the module is ignoed when it is not found. # If ifexists is given, the module is ignoed when it is not found.
@ -57,7 +57,7 @@ modules = {
#rt.time.soft = 200000 #rt.time.soft = 200000
#rt.time.hard = 200000 #rt.time.hard = 200000
} }
flags = "ifexists|nofail" flags = [ ifexists nofail ]
} }
# The native communication protocol # The native communication protocol
@ -129,13 +129,13 @@ modules = {
objects = { objects = {
## <factory-name> = { [args = { <key>=<value> ... } ] ## <factory-name> = { [args = { <key>=<value> ... } ]
# [flags = "nofail"] } # [flags = [ [nofail] ] }
# #
# Creates an object from a PipeWire factory with the given parameters. # Creates an object from a PipeWire factory with the given parameters.
# If nofail is given, errors are ignored (and no object is created) # If nofail is given, errors are ignored (and no object is created)
# #
#spa-node-factory = { args = "factory.name=videotestsrc node.name=videotestsrc Spa:Pod:Object:Param:Props:patternType=1" } #spa-node-factory = { args = "factory.name=videotestsrc node.name=videotestsrc Spa:Pod:Object:Param:Props:patternType=1" }
#spa-device-factory = { args = "factory.name=api.jack.device foo=bar" flags = nofail } #spa-device-factory = { args = "factory.name=api.jack.device foo=bar" flags = [ nofail ] }
#spa-device-factory = { args = "factory.name=api.alsa.enum.udev" } #spa-device-factory = { args = "factory.name=api.alsa.enum.udev" }
#spa-device-factory = { args = "factory.name=api.alsa.seq.bridge node.name=Internal-MIDI-Bridge" } #spa-device-factory = { args = "factory.name=api.alsa.seq.bridge node.name=Internal-MIDI-Bridge" }
#adapter = { args = "factory.name=audiotestsrc node.name=my-test" } #adapter = { args = "factory.name=audiotestsrc node.name=my-test" }