diff --git a/dev/scripts/get_linux_outputs.py b/dev/scripts/get_linux_outputs.py index 323b6f2..6449302 100644 --- a/dev/scripts/get_linux_outputs.py +++ b/dev/scripts/get_linux_outputs.py @@ -5,7 +5,7 @@ os.putenv('SDL_AUDIODRIVER', 'pulseaudio') import pygame._sdl2 as sdl2 import pygame from pygame import mixer -#pygame.init() +pygame.init() import time mixer.init(44100, -16, 2, 1024) is_capture = 0 # zero to request playback devices, non-zero to request recording devices diff --git a/helpers/device_manager.py b/helpers/device_manager.py index a7871f9..aa5a7b0 100644 --- a/helpers/device_manager.py +++ b/helpers/device_manager.py @@ -1,6 +1,12 @@ from typing import Any, Dict, List, Optional, Tuple import sounddevice as sd from helpers.os_environment import isLinux, isMacOS, isWindows +import os + +os.environ["PYGAME_HIDE_SUPPORT_PROMPT"] = "hide" +os.putenv('SDL_AUDIODRIVER', 'pulseaudio') +import pygame._sdl2 as sdl2 +from pygame import mixer import glob if isWindows(): @@ -53,6 +59,15 @@ class DeviceManager: return host_apis + @classmethod + def getAudioDevices(cls) -> List[str]: + mixer.init(44100, -16, 2, 1024) + is_capture = 0 # zero to request playback devices, non-zero to request recording devices + num = sdl2.get_num_audio_devices(is_capture) + names = [str(sdl2.get_audio_device_name(i, is_capture), encoding="utf-8") for i in range(num)] + mixer.quit() + return names + @classmethod def getSerialPorts(cls) -> List[Optional[str]]: """Lists serial port names diff --git a/ui-templates/config_player.html b/ui-templates/config_player.html index 78d2c79..6ddbfd3 100644 --- a/ui-templates/config_player.html +++ b/ui-templates/config_player.html @@ -33,6 +33,26 @@ Set for: Default Audio Output
+{% if data.sdl_direct %} +Linux (Pulse Audio) +
+{% for output in data.outputs %}
+Set for:
+ {% for channel in data.channels %}
+ {% if not channel %}
+ Player {{loop.index0}}
+ {% elif channel.output == output %}
+ Player {{channel.channel}}
+ {% else %}
+ Player {{channel.channel}}
+ {% endif %}
+ /
+ {% endfor %}
+{% if output %}{{output}}{% else %}System Default Output{% endif %}
+{% endfor %}
+
+{% else %}
{% for host_api in data.outputs %}
{{host_api.name}}