From 1c23e26f93d236ed7c674608d57945ba52251b84 Mon Sep 17 00:00:00 2001 From: Pascal Vizeli Date: Sat, 29 Feb 2020 23:45:37 +0100 Subject: [PATCH] Check if SND is loaded (#1552) * Check if SND is loaded * add warning --- supervisor/docker/audio.py | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/supervisor/docker/audio.py b/supervisor/docker/audio.py index a7c0e8654..520c1675a 100644 --- a/supervisor/docker/audio.py +++ b/supervisor/docker/audio.py @@ -1,6 +1,8 @@ """Audio docker object.""" from contextlib import suppress import logging +from pathlib import Path +from typing import Dict from ..const import ENV_TIME from ..coresys import CoreSysAttributes @@ -25,6 +27,22 @@ class DockerAudio(DockerInterface, CoreSysAttributes): """Return name of Docker container.""" return AUDIO_DOCKER_NAME + @property + def volumes(self) -> Dict[str, Dict[str, str]]: + """Return Volumes for the mount.""" + volumes = { + str(self.sys_config.path_extern_audio): {"bind": "/data", "mode": "rw"}, + "/etc/group": {"bind": "/host/group", "mode": "ro"}, + } + + # SND support + if Path("/dev/snd").exists(): + volumes.update({"/dev/snd": {"bind": "/dev/snd", "mode": "rw"}}) + else: + _LOGGER.warning("Kernel have no audio support in") + + return volumes + def _run(self) -> None: """Run Docker image. @@ -48,14 +66,7 @@ class DockerAudio(DockerInterface, CoreSysAttributes): detach=True, privileged=True, environment={ENV_TIME: self.sys_timezone}, - volumes={ - str(self.sys_config.path_extern_audio): { - "bind": "/data", - "mode": "rw", - }, - "/dev/snd": {"bind": "/dev/snd", "mode": "rw"}, - "/etc/group": {"bind": "/host/group", "mode": "ro"}, - }, + volumes=self.volumes, ) self._meta = docker_container.attrs