Update __main__.py

Fix MpvMediaPlayer Race Condition
Goal: The mpv library runs in its own thread. When a track finishes, its callback (_on_idle_active) runs in that thread and tries to modify the satellite's state, creating a race condition. We will fix this by "marshaling" that callback onto the main asyncio loop.

added loop=loop to the MpvMediaPlayer constructors
This commit is contained in:
imonlinux
2025-11-17 14:40:42 -08:00
committed by GitHub
parent 61bf13ca98
commit 943a8a0d5c
+10 -2
View File
@@ -213,8 +213,16 @@ async def main() -> None:
break break
assert stop_model is not None assert stop_model is not None
music_player = MpvMediaPlayer(device=args.audio_output_device, initial_volume=preferences.volume_level) music_player = MpvMediaPlayer(
tts_player = MpvMediaPlayer(device=args.audio_output_device, initial_volume=preferences.volume_level) loop=loop, # <-- MODIFIED
device=args.audio_output_device,
initial_volume=preferences.volume_level
)
tts_player = MpvMediaPlayer(
loop=loop, # <-- MODIFIED
device=args.audio_output_device,
initial_volume=preferences.volume_level
)
state = ServerState( state = ServerState(
name=args.name, name=args.name,