Fix WebAudioBridge to manage event loop retrieval

- Introduced a property for accessing the event loop, allowing for better handling of both running and fallback scenarios.
- Updated the internal loop management to improve compatibility with asynchronous operations.
This commit is contained in:
Sudo-Ivan
2026-01-14 17:45:20 -06:00
parent ca3ef05f75
commit 6a4ed6a048
+16 -1
View File
@@ -91,9 +91,24 @@ class WebAudioBridge:
self.tx_source: WebAudioSource | None = None
self.rx_sink: WebAudioSink | None = None
self.rx_tee: Tee | None = None
self.loop = asyncio.get_event_loop()
self._loop = None
self.lock = threading.Lock()
@property
def loop(self):
if self._loop:
return self._loop
try:
self._loop = asyncio.get_running_loop()
except RuntimeError:
# Fallback to finding it via AsyncUtils if possible
from .async_utils import AsyncUtils
self._loop = AsyncUtils.main_loop
return self._loop
def _tele(self):
return getattr(self.telephone_manager, "telephone", None)