Skip to content

Commit 9406e6a

Browse files
committed
CHANGES:
- Music: debug added for SRS audio player
1 parent 649f835 commit 9406e6a

File tree

3 files changed

+20
-4
lines changed

3 files changed

+20
-4
lines changed

services/music/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ DEFAULT:
1919
popup: Now playing {song} on {frequency}{modulation} # optional - popup message when a song starts to play
2020
chat: Now playing {song} on {frequency}{modulation} # optional - chat message when a song starts to play
2121
pause_without_players: false # Pause music, when no player is active (default: true)
22+
debug: true # Put the output of DCS-SR-ExternalAudio.exe to the dcssb*.log
2223
radios:
2324
Radio 1: # Name of the radio, can be anything
2425
type: SRSRadio # we currently only support SRS, so this has to be in

services/music/radios/srs.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
from core import Server, Status, Coalition, utils
66
from packaging.version import parse
7+
from threading import Thread
78
from typing import Optional
8-
99
from services.music.radios.base import RadioInitError, Radio
1010
from plugins.music.utils import get_tag
1111

@@ -41,8 +41,16 @@ def exe_path() -> str:
4141
else:
4242
return os.path.join(srs_inst, "DCS-SR-ExternalAudio.exe")
4343

44-
def run_subprocess():
45-
return subprocess.Popen([
44+
def run_subprocess() -> subprocess.Popen:
45+
def _log_output(self, p: subprocess.Popen):
46+
for line in iter(p.stdout.readline, b''):
47+
self.log.debug(line.decode('utf-8').rstrip())
48+
49+
debug = self.service.get_config().get('debug', False)
50+
out = subprocess.PIPE if debug else subprocess.DEVNULL
51+
err = subprocess.PIPE if debug else subprocess.DEVNULL
52+
53+
args = [
4654
exe_path(),
4755
"-f", str(self.config['frequency']),
4856
"-m", self.config['modulation'],
@@ -51,7 +59,13 @@ def run_subprocess():
5159
"-p", str(srs_port),
5260
"-n", self.config.get('display_name', 'DCSSB MusicBox'),
5361
"-i", file
54-
], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
62+
]
63+
if debug:
64+
self.log.debug(f"Running {' '.join(args)}")
65+
p = subprocess.Popen(args, stdout=out, stderr=err)
66+
if debug:
67+
Thread(target=_log_output, args=(p,), daemon=True).start()
68+
return p
5569

5670
self.process = await asyncio.to_thread(run_subprocess)
5771
coalition = Coalition.BLUE if int(self.config['coalition']) == 2 else Coalition.RED

services/music/schemas/music_schema.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ schema;element_schema:
1515
popup: {type: str, nullable: false, range: {min: 1}}
1616
chat: {type: str, nullable: false, range: {min: 1}}
1717
pause_without_players: {type: bool, nullable: false}
18+
debug: {type: bool, nullable: false}
1819
radios:
1920
type: map
2021
nullable: false

0 commit comments

Comments
 (0)