Give Windows devices an identifier, and ask ffmpeg for them once

Three things about the dshow backend, all of them found by reading rather
than by running, so all three want checking on a real Windows machine.

The device listing is parsed in both of the shapes ffmpeg has printed it in:
newer builds mark every device `(audio)` or `(video)`, older ones print a
heading and no marks, and only the first was read. Each pattern is anchored at
both ends now, so the error lines the command ends with, which quote the device
name it was told to look for, are no longer read as a device of that name.

What is stored for a device is the alternative name under it rather than the
friendly one. A laptop with a headset plugged in has two microphones called the
same thing, and `audio=Microphone` reaches the first of them whichever one was
picked; the alternative name is unique. The friendly name stays what is shown,
which is what the (id, description) pair in these lists has always been for.

An unset microphone meant "the first one listed", and the listing costs an
ffmpeg of its own, so every press of the key paid for a process before the
recording started. The last listing is remembered instead, and opening Settings
or running `dikte devices` takes a fresh one.

And a fourth thing, which is about what the interface says rather than what it
does: whether the far side of a meeting can be captured at all is now an entry
in `audio.Sound` instead of being read off an empty device list. The two are not
the same answer. An empty list on Linux means pactl is not installed, which a
user can go and fix; False on Windows means there is no such device and no
driver that would add one. The Meeting tab says so under the empty box, and
starting a meeting says it instead of sending somebody to Settings to pick from
a list that will never have anything in it.
This commit is contained in:
2026-08-16 10:28:43 +03:00
parent 191eef8f8d
commit 8c62795b8b
5 changed files with 250 additions and 30 deletions
+31
View File
@@ -13,6 +13,7 @@ from unittest import mock
from PyQt6.QtWidgets import QApplication, QMessageBox
import audio
import cleanup
import config as cfg
import ggml
@@ -449,6 +450,36 @@ class Overlay(DikteTest):
self.assertFalse(widget.muted)
class MeetingSources(DikteTest):
"""What the Meeting tab says about the far side, per sound system.
The box that picks it is empty on a system that cannot record it, and an
empty box with nothing next to it reads as a list that has not loaded yet.
"""
def notes(self, meetings):
with mock.patch.object(audio, "sound",
return_value=audio.PULSE._replace(
meetings=meetings)), \
only_these_tools(), \
mock.patch.object(settings_ui.SettingsWindow, "_load_models"), \
mock.patch.object(settings_ui.SettingsWindow,
"_load_transcribe_models"):
window = settings_ui.SettingsWindow(cfg.Config())
self.addCleanup(window.deleteLater)
self.addCleanup(window.close)
return " ".join(label.text()
for label in window.findChildren(settings_ui.QLabel))
def test_a_system_that_cannot_record_the_far_side_says_so(self):
self.assertIn("nothing that records what the speakers",
self.notes(meetings=False))
def test_a_system_that_can_says_nothing_of_the_sort(self):
self.assertNotIn("nothing that records what the speakers",
self.notes(meetings=True))
if __name__ == "__main__":
unittest.main()