mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-07-25 18:16:32 +00:00
Make audio socket RO and aware of restarts (#1545)
This commit is contained in:
parent
d3a21303d9
commit
d4f486864f
@ -35,7 +35,7 @@ class Audio(JsonConfig, CoreSysAttributes):
|
|||||||
@property
|
@property
|
||||||
def path_extern_pulse(self) -> Path:
|
def path_extern_pulse(self) -> Path:
|
||||||
"""Return path of pulse socket file."""
|
"""Return path of pulse socket file."""
|
||||||
return self.sys_config.path_extern_audio.joinpath("external/pulse.sock")
|
return self.sys_config.path_extern_audio.joinpath("external")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def path_extern_asound(self) -> Path:
|
def path_extern_asound(self) -> Path:
|
||||||
@ -157,8 +157,6 @@ 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
|
||||||
@ -169,8 +167,6 @@ 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.
|
||||||
|
|
||||||
@ -221,22 +217,3 @@ 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)
|
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
{% if default_sink %}default-sink = {{ default_sink }}{% endif %}
|
{% if default_sink %}default-sink = {{ default_sink }}{% endif %}
|
||||||
{% if default_source %}default-source = {{ default_source }}{% endif %}
|
{% if default_source %}default-source = {{ default_source }}{% endif %}
|
||||||
|
|
||||||
default-server = unix://run/pulse.sock
|
default-server = unix://run/audio/pulse.sock
|
||||||
; default-dbus-server =
|
; default-dbus-server =
|
||||||
|
|
||||||
autospawn = no
|
autospawn = no
|
||||||
|
@ -298,7 +298,7 @@ class DockerAddon(DockerInterface):
|
|||||||
|
|
||||||
# Host D-Bus system
|
# Host D-Bus system
|
||||||
if self.addon.host_dbus:
|
if self.addon.host_dbus:
|
||||||
volumes.update({"/run/dbus": {"bind": "/run/dbus", "mode": "rw"}})
|
volumes.update({"/run/dbus": {"bind": "/run/dbus", "mode": "ro"}})
|
||||||
|
|
||||||
# Configuration Audio
|
# Configuration Audio
|
||||||
if self.addon.with_audio:
|
if self.addon.with_audio:
|
||||||
@ -309,8 +309,8 @@ class DockerAddon(DockerInterface):
|
|||||||
"mode": "ro",
|
"mode": "ro",
|
||||||
},
|
},
|
||||||
str(self.sys_audio.path_extern_pulse): {
|
str(self.sys_audio.path_extern_pulse): {
|
||||||
"bind": "/run/pulse.sock",
|
"bind": "/run/audio",
|
||||||
"mode": "rw",
|
"mode": "ro",
|
||||||
},
|
},
|
||||||
str(self.sys_audio.path_extern_asound): {
|
str(self.sys_audio.path_extern_asound): {
|
||||||
"bind": "/etc/asound.conf",
|
"bind": "/etc/asound.conf",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user