From a48d673e0306223da0df499aa561a2c5d4c1870c Mon Sep 17 00:00:00 2001 From: Philip Linde Date: Sun, 22 Sep 2024 23:44:31 +0200 Subject: [PATCH 1/2] Support multi-channel interfaces Prior to this commit, if a device with more than eight channels appeared in a device list, only the first eight channels were actually displayed. Devices below the multi-channel device were not displayed. The issue relates to the naming of channels; they were given names depending on their channel number, which works well for up to eight channels. When the 9th channel appeared, it was considered to be Bar.NONE, which caused its name to be displayed in the center of the screen. Then, retreiving the name caused an exception, which caused the remaining devices not to be displayed. The solution is to give Bar.NONE a value that can't possibly be confused for a channel index, and to default to displaying the channel number if there is no name for the channel. --- pulsemixer | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pulsemixer b/pulsemixer index 6b0c8c6..19db76e 100755 --- a/pulsemixer +++ b/pulsemixer @@ -930,7 +930,7 @@ class PulseVolume(DebugMixin): class Bar(): # should be in correct order - LEFT, RIGHT, RLEFT, RRIGHT, CENTER, SUB, SLEFT, SRIGHT, NONE = range(9) + NONE, LEFT, RIGHT, RLEFT, RRIGHT, CENTER, SUB, SLEFT, SRIGHT = range(-1, 8) def __init__(self, pa): if type(pa) is str: @@ -1170,7 +1170,7 @@ class Screen(): if side is Bar.NONE: self.info = str return - side = 'All' if bar.locked else 'Mono' if bar.channels == 1 else self.SIDES[side] + side = 'All' if bar.locked else 'Mono' if bar.channels == 1 else self.SIDES.get(side, str(side)) more = '↕' if bottom < self.n_lines and self.top_line_num > 0 else '↑' if self.top_line_num > 0 else '↓' if bottom < self.n_lines else ' ' name = '{}: {}'.format(bar.name, side) if len(name) > self.cols - 8: From 6007740ac6660b1e0224a0d93d799c4ceaa47c5e Mon Sep 17 00:00:00 2001 From: Philip Linde Date: Sun, 22 Sep 2024 23:57:28 +0200 Subject: [PATCH 2/2] Always display non-mono channel numbers Prior to this commit, channel numbers were only displayed if there was no name for the channel, defined in Screen.SIDES. In reality, channels numbers don't necessarily correspond to a speaker function, e.g. in a music studio context. Then it's more useful to know the actual channel number. With this commit, channel numbers are always displayed, with the speaker side name displayed if available. --- pulsemixer | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pulsemixer b/pulsemixer index 19db76e..e015f9c 100755 --- a/pulsemixer +++ b/pulsemixer @@ -1159,6 +1159,11 @@ class Screen(): selected = 'output' if type(self.selected[0].pa) is PulseSinkInputInfo else 'input' self.menu = "Select new {} device:|{}".format(selected, curses.A_NORMAL) + @staticmethod + def format_side(side): + name = Screen.SIDES.get(side, None) + return '%d (%s)' % (side, name) if name is not None else str(side) + def update_info(self): focus, bottom = self.focus_line_num + self.top_line_num + 1, self.top_line_num + self.lines try: @@ -1170,7 +1175,7 @@ class Screen(): if side is Bar.NONE: self.info = str return - side = 'All' if bar.locked else 'Mono' if bar.channels == 1 else self.SIDES.get(side, str(side)) + side = 'All' if bar.locked else 'Mono' if bar.channels == 1 else Screen.format_side(side) more = '↕' if bottom < self.n_lines and self.top_line_num > 0 else '↑' if self.top_line_num > 0 else '↓' if bottom < self.n_lines else ' ' name = '{}: {}'.format(bar.name, side) if len(name) > self.cols - 8: