Skip to content
Snippets Groups Projects
Commit f4dea508 authored by Sjoerd Simons's avatar Sjoerd Simons
Browse files

Automatically detect output audio nodes


Rather then hardcoding the output node names detect them on startup.
This assumes there will be at least 2 nodes ofcourse otherwise it will
crash later

Signed-off-by: default avatarSjoerd Simons <sjoerd@collabora.com>
parent 3959a41f
Branches main
1 merge request!2Automatically detect output audio nodes
Pipeline #624986 passed
......@@ -8,13 +8,14 @@ import sys
import time
def pw_dump(name):
def pw_dump(name = None ):
cmd_pw_dump = ["pw-dump"]
p = subprocess.run(cmd_pw_dump, stdout=subprocess.PIPE)
my_pw_dump = json.loads(p.stdout)
with open(name, "w") as f:
json.dump(my_pw_dump, f, indent=2)
if name != None:
with open(name, "w") as f:
json.dump(my_pw_dump, f, indent=2)
return my_pw_dump
......@@ -284,14 +285,24 @@ def start_moving_sink(my_sink_name, my_wav, my_cards, my_id_used=None):
break
def find_outputs():
dump = pw_dump()
outputs = []
for obj in dump:
if obj["type"] != "PipeWire:Interface:Node":
continue
if obj["info"]["props"].get("media.class") != "Audio/Sink":
continue
outputs.append(obj["info"]["props"]["node.name"])
return outputs
if __name__ == "__main__":
print("Run test-case 1")
# To avoid interference from previous run
kill_my_sinks()
my_sound_cards = ["alsa_output.usb-0d8c_USB_Sound_Device-00.analog-stereo",
"alsa_output.platform-sound.stereo-fallback"]
my_sound_cards = find_outputs()
# Make sound with USB sound card
my_jackplay_id_used_A = start_sink("my-sink-A", "test300.wav", my_sound_cards[0])
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment