Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions apps/whispering/src/lib/services/desktop/recorder/ffmpeg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,9 @@ const enumerateDevices = async (): Promise<Result<Device[], RecorderError>> => {
}

// FFmpeg lists devices to stderr, not stdout
const output = result.stderr;
const output = DESKTOP_PLATFORM !== 'linux'
? result.stderr
: result.stdout;

const devices = parseDevices(output);

Expand Down Expand Up @@ -572,10 +574,15 @@ function parseDevices(output: string): Device[] {
},
linux: {
// Linux ALSA format: hw:0,0 Device Name
regex: /^(hw:\d+,\d+)\s+(.+)/,
// Linux arecord format: card X: <card name>, device Y: <device name\>
regex: /^card (\d+).+device (\d+): (.+)(?: \[.+\])*/,
extractDevice: (match) => ({
id: asDeviceIdentifier(match[1] ?? ''),
label: match[2]?.trim() ?? '',
id: asDeviceIdentifier(
match[1] && match[2]
? `hw:${match[1]},${match[2]}`
: ''
),
label: match[3]?.trim() ?? '',
}),
},
} satisfies Record<
Expand Down
Loading