mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-07-24 09:36:31 +00:00
Restart add-ons attach to audio with update pulse (#1540)
This commit is contained in:
parent
ae6f8bd345
commit
87170a4497
@ -3,12 +3,12 @@ import asyncio
|
||||
from contextlib import suppress
|
||||
import logging
|
||||
from pathlib import Path
|
||||
from typing import Awaitable, Optional
|
||||
import shutil
|
||||
from typing import Awaitable, List, Optional
|
||||
|
||||
import jinja2
|
||||
|
||||
from .const import ATTR_VERSION, FILE_HASSIO_AUDIO
|
||||
from .const import ATTR_VERSION, FILE_HASSIO_AUDIO, STATE_STARTED
|
||||
from .coresys import CoreSys, CoreSysAttributes
|
||||
from .docker.audio import DockerAudio
|
||||
from .docker.stats import DockerStats
|
||||
@ -157,6 +157,8 @@ class Audio(JsonConfig, CoreSysAttributes):
|
||||
_LOGGER.error("Can't start Audio plugin")
|
||||
raise AudioError() from None
|
||||
|
||||
await self._restart_audio_addons()
|
||||
|
||||
async def start(self) -> None:
|
||||
"""Run CoreDNS."""
|
||||
# Start Instance
|
||||
@ -167,6 +169,8 @@ class Audio(JsonConfig, CoreSysAttributes):
|
||||
_LOGGER.error("Can't start Audio plugin")
|
||||
raise AudioError() from None
|
||||
|
||||
await self._restart_audio_addons()
|
||||
|
||||
def logs(self) -> Awaitable[bytes]:
|
||||
"""Get CoreDNS docker logs.
|
||||
|
||||
@ -217,3 +221,22 @@ class Audio(JsonConfig, CoreSysAttributes):
|
||||
default_source=input_profile,
|
||||
default_sink=output_profile,
|
||||
)
|
||||
|
||||
async def _restart_audio_addons(self):
|
||||
"""Restart all Add-ons they can be connect to unix socket."""
|
||||
tasks: List[Awaitable[None]] = []
|
||||
|
||||
# Find all Add-ons running with audio
|
||||
for addon in self.sys_addons.installed:
|
||||
if not addon.with_audio:
|
||||
continue
|
||||
if await addon.state() != STATE_STARTED:
|
||||
continue
|
||||
tasks.append(addon.restart())
|
||||
|
||||
if not tasks:
|
||||
return
|
||||
|
||||
# restart
|
||||
_LOGGER.info("Restart all Add-ons attach to pulse server: %d", len(tasks))
|
||||
await asyncio.wait(tasks)
|
||||
|
Loading…
x
Reference in New Issue
Block a user