Windows: stream.start() fails with "Unanticipated host error -9999 / WdmSyncIoctl" because the audio executor thread never initializes COM
Maintainer antworten meist innerhalb von 4 Tagen
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 2/5
- Geschätzter Aufwand
- 1-3 Stunden
- Anfängerfreundlichkeit
- 62/100
- Issue-Typ
- Bug
- Klarheit
- Klar beschrieben
- Aktivitätsstatus
- Aktiv
- Tech-Stack
- python
- Bereich
- audio-video-rtc, cli
Rechercherichtung
Der Fix gehört in AudioPlayer.__init__ in sendspin/audio.py, wo _stream_executor ohne Initializer erzeugt wird. Lies nach, wie start, stop und close an diesen Executor übergeben werden, und ergänze dann eine nur unter Windows ausgeführte COM-Initialisierung für dessen Worker-Thread. Fertig ist es, wenn stream.start() auf einem WASAPI-Gerät nicht mehr PaErrorCode -9999 auslöst; das muss auf einem Windows-Rechner bestätigt werden. Die Notiz zur Reconnect-Schleife im Bericht ist ein separates Problem und sollte nicht in diesen Fix aufgenommen werden.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Environment
Windows 11, Python 3.12.10 (venv), sendspin 7.6.0 (installed from the 7.6.0 tag), aiosendspin 9.1.1, sounddevice 0.5.6
Output device: a Realtek "Speakers" endpoint, host API "Windows WASAPI", 48 kHz
Server: Music Assistant 2.10.6 (Sendspin provider)
What happens sendspin daemon --url ws://:8927/sendspin --audio-device 12 connects and pairs fine, but as soon as playback starts:
INFO:sendspin.audio:Stream STARTED: 3 chunks, 0.29 seconds buffered
ERROR:sendspin.audio:Stream operation start failed
sounddevice.PortAudioError: Error starting stream: Unanticipated host error [PaErrorCode -9999]:
'WdmSyncIoctl: DeviceIoControl GLE = 0x00000490 ...' [Windows WDM-KS error 0]
(The WDM-KS text is the generic "last host error", the device itself is a WASAPI one.) Nothing is heard.
Isolated reproduction (no Sendspin involved) Same device, RawOutputStream(samplerate=48000, channels=2, dtype="int24", blocksize=2048, latency="high"):
create + start + stop in the main thread: works
create in main thread, start() in another thread: fails with the error above
create and start() both inside a secondary thread: fails
same, but calling ctypes.windll.ole32.CoInitializeEx(None, 0) at the beginning of that thread: works
So PortAudio's WASAPI backend needs COM initialized on the thread that opens/starts the stream, and AudioPlayer._stream_executor (a 1-worker ThreadPoolExecutor) never does that; stream.start()/stop()/close() are all submitted to it.
Fix that works for me (sendspin/audio.py, AudioPlayer.init):
def _com_init() -> None:
if sys.platform == "win32":
import ctypes
ctypes.windll.ole32.CoInitializeEx(None, 0) # COINIT_MULTITHREADED
self._stream_executor = concurrent.futures.ThreadPoolExecutor(
max_workers=1, thread_name_prefix="sendspin-audio", initializer=_com_init
)
With this, a 3-beep test file played from Music Assistant through the Sendspin daemon comes out of the speakers correctly.
Happy to open a PR if you prefer.
Also noticed (minor): running two daemons with the same identity makes them kick each other in a tight reconnect loop (thousands of connect/disconnect lines per second). A backoff on "replaced by a new connection" would avoid log floods.
- Vorherrschende Sprache
- Python
- Sterne
- 198
- Forks
- 40
- Ø Merge
- 4 T. 11 Std.
- Gemergte PRs (30 T.)
- 10
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Kein Beitragsleitfaden
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus Sendspin/sendspin-python-cli
-
Logging error: "TypeError: %d format: a real number is required, not str"Evtl. vergeben @mill1000 hat das heute übernommen. Offen
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 88/100
Sendspin/sendspin-python-cli#294 ·
Maintainer antworten meist innerhalb von 4 Tagen
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
Sendspin/sendspin-python-cli#280 · 1 Kommentar · 1 Reaktion ·
Maintainer antworten meist innerhalb von 4 Tagen
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 74/100
Sendspin/sendspin-python-cli#278 · 2 Kommentare · 5 Reaktionen ·
Maintainer antworten meist innerhalb von 4 Tagen
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
Sendspin/sendspin-python-cli#257 ·
Maintainer antworten meist innerhalb von 4 Tagen
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
Sendspin/sendspin-python-cli#256 ·
Maintainer antworten meist innerhalb von 4 Tagen
Alle Issues in Sendspin/sendspin-python-cli
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 62/100
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 70/100
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
topoteretes/cognee#5773 ·
Maintainer antworten meist innerhalb von 1 Tag
-
MiKTeX: a failed build reports no errors because texify --quiet switches the log to file:line: styleOffen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 74/100
SublimeText/LaTeXTools#1718 ·