mirror of
https://git.quad4.io/RNS-Things/MeshChatX.git
synced 2026-09-17 03:24:23 +00:00
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:
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user