mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-07-26 02:26:30 +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
|
from contextlib import suppress
|
||||||
import logging
|
import logging
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Awaitable, Optional
|
|
||||||
import shutil
|
import shutil
|
||||||
|
from typing import Awaitable, List, Optional
|
||||||
|
|
||||||
import jinja2
|
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 .coresys import CoreSys, CoreSysAttributes
|
||||||
from .docker.audio import DockerAudio
|
from .docker.audio import DockerAudio
|
||||||
from .docker.stats import DockerStats
|
from .docker.stats import DockerStats
|
||||||
@ -157,6 +157,8 @@ class Audio(JsonConfig, CoreSysAttributes):
|
|||||||
_LOGGER.error("Can't start Audio plugin")
|
_LOGGER.error("Can't start Audio plugin")
|
||||||
raise AudioError() from None
|
raise AudioError() from None
|
||||||
|
|
||||||
|
await self._restart_audio_addons()
|
||||||
|
|
||||||
async def start(self) -> None:
|
async def start(self) -> None:
|
||||||
"""Run CoreDNS."""
|
"""Run CoreDNS."""
|
||||||
# Start Instance
|
# Start Instance
|
||||||
@ -167,6 +169,8 @@ class Audio(JsonConfig, CoreSysAttributes):
|
|||||||
_LOGGER.error("Can't start Audio plugin")
|
_LOGGER.error("Can't start Audio plugin")
|
||||||
raise AudioError() from None
|
raise AudioError() from None
|
||||||
|
|
||||||
|
await self._restart_audio_addons()
|
||||||
|
|
||||||
def logs(self) -> Awaitable[bytes]:
|
def logs(self) -> Awaitable[bytes]:
|
||||||
"""Get CoreDNS docker logs.
|
"""Get CoreDNS docker logs.
|
||||||
|
|
||||||
@ -217,3 +221,22 @@ class Audio(JsonConfig, CoreSysAttributes):
|
|||||||
default_source=input_profile,
|
default_source=input_profile,
|
||||||
default_sink=output_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