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
|
||||
def path_extern_pulse(self) -> Path:
|
||||
"""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
|
||||
def path_extern_asound(self) -> Path:
|
||||
|
@ -157,8 +157,6 @@ 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
|
||||
|
@ -169,8 +167,6 @@ 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.
|
||||
|
||||
|
@ -221,22 +217,3 @@ 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)
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
{% if default_sink %}default-sink = {{ default_sink }}{% 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 =
|
||||
|
||||
autospawn = no
|
||||
|
|
|
@ -298,7 +298,7 @@ class DockerAddon(DockerInterface):
|
|||
|
||||
# Host D-Bus system
|
||||
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
|
||||
if self.addon.with_audio:
|
||||
|
@ -309,8 +309,8 @@ class DockerAddon(DockerInterface):
|
|||
"mode": "ro",
|
||||
},
|
||||
str(self.sys_audio.path_extern_pulse): {
|
||||
"bind": "/run/pulse.sock",
|
||||
"mode": "rw",
|
||||
"bind": "/run/audio",
|
||||
"mode": "ro",
|
||||
},
|
||||
str(self.sys_audio.path_extern_asound): {
|
||||
"bind": "/etc/asound.conf",
|
||||
|
|
Loading…
Reference in New Issue