From 92488ec24a99f1280c30966ead9dd99f7125c92d Mon Sep 17 00:00:00 2001 From: Janne Mareike Koschinski Date: Fri, 10 Jan 2025 02:46:40 +0100 Subject: [PATCH] Fix issue where channel order was unstable We used to order channels using enumerate(set(t.split("+"))). In Python, the iteration order for sets is random and changes with every run. This commit uses a stable order (as specified in the config) instead --- vocto/audio_streams.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/vocto/audio_streams.py b/vocto/audio_streams.py index 9fb8c39f..74184b7d 100644 --- a/vocto/audio_streams.py +++ b/vocto/audio_streams.py @@ -25,7 +25,7 @@ def configure_source(self, cfg, source, use_source_as_name=False): # search for entrys like 'audio.*' r = re.match(r'^audio\.([\w\-_]+)$', t_name) if r: - for i, channel in enumerate(set(t.split("+"))): + for i, channel in enumerate(self.channels(t)): name = source if use_source_as_name else r.group(1) if self.has_stream(name): log.error("input audio stream name '%s' can't be addressed a second time within source '%s'", @@ -34,6 +34,14 @@ def configure_source(self, cfg, source, use_source_as_name=False): audiostreams.append(AudioStream(source, i, name, channel)) self.extend(audiostreams) + @staticmethod + def channels(channel_positions: str) -> list[str]: + channels = [] + for entry in channel_positions.split("+"): + if entry not in channels: + channels.append(entry) + return channels + def has_stream(self, name, channel=None): for s in self: if s.name == name: