From f186cc8b54f47d7f21d1f1bb668903839914e907 Mon Sep 17 00:00:00 2001 From: "Robin E.R. Davies" Date: Mon, 8 Jun 2026 00:43:30 -0400 Subject: [PATCH] Improve names of USB devices in AudioDeviceDialog. --- vite/src/pipedal/AlsaDeviceInfo.tsx | 8 ++++++++ vite/src/pipedal/AudioDeviceDialog.tsx | 8 ++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/vite/src/pipedal/AlsaDeviceInfo.tsx b/vite/src/pipedal/AlsaDeviceInfo.tsx index 2620eba..b59d136 100644 --- a/vite/src/pipedal/AlsaDeviceInfo.tsx +++ b/vite/src/pipedal/AlsaDeviceInfo.tsx @@ -83,6 +83,14 @@ export default class AlsaDeviceInfo { } return result; } + shortDeviceName() : string { + // The best device names for USB devices are buried in the long name, so we try to extract them if we can. + let pos = this.longName.indexOf(" at usb-"); + if (pos > 0) { + return this.longName.substring(0, pos); + } + return this.name; + } cardId: number = -1; id: string = ""; diff --git a/vite/src/pipedal/AudioDeviceDialog.tsx b/vite/src/pipedal/AudioDeviceDialog.tsx index 7ee5acd..d96151b 100644 --- a/vite/src/pipedal/AudioDeviceDialog.tsx +++ b/vite/src/pipedal/AudioDeviceDialog.tsx @@ -67,7 +67,7 @@ function sortDevices(devices: AlsaDeviceInfo[]): AlsaDeviceInfo[] { let ca = category(a); let cb = category(b); if (ca !== cb) return ca - cb; - return a.name.localeCompare(b.name); + return a.shortDeviceName().localeCompare(b.shortDeviceName()); }); return copy; } @@ -584,7 +584,7 @@ const AudioDeviceDialog = withStyles( if (!this.state.alsaDevices) return deviceId; for (let i = 0; i < this.state.alsaDevices.length; ++i) { if (this.state.alsaDevices[i].id === deviceId) { - return this.state.alsaDevices[i].name; + return this.state.alsaDevices[i].shortDeviceName(); } } return deviceId; @@ -673,7 +673,7 @@ const AudioDeviceDialog = withStyles( {d.name} + >{d.shortDeviceName()} ))} @@ -695,7 +695,7 @@ const AudioDeviceDialog = withStyles( {d.name} + >{d.shortDeviceName()} ))}