Как воспроизвести звук из системного сервиса на Ubuntu?

Я пытаюсь воспроизвести звук из сервиса на Ubuntu:

tim@timpc:~$ uname -a Linux timpc 5.4.0-91-generic #102-Ubuntu SMP Fri 5 ноября 16:31:28 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

Вот определение сервиса:

tim@timpc:~$ cat /etc/systemd/system/alarmd.service
# Datei /etc/systemd/system/alarmd.service
[Unit]
Description=alarmd service
Wants=sound.target
After=sound.target

[Service]
Type=oneshot
Environment="DISPLAY=:0"
User=tim
;ExecStart=/home/tim/Dokumente/super/alarmd/build/release/dist/alarmd --sound /usr/local/share/alarmd/a.wav
ExecStart=mplayer /usr/local/share/alarmd/a.wav

[Install]
WantedBy=multi-user.target

Я запускаю службу так:

sudo systemctl start alarmd.service

... и получить следующий вывод:

tim@timpc:~$ journalctl -S today -u alarmd.service
-- Logs begin at Wed 2021-08-11 09:41:59 CEST, end at Sun 2021-12-05 16:28:06 CET. --
Dez 05 16:28:06 timpc systemd[1]: Starting alarmd service...
Dez 05 16:28:06 timpc mplayer[13082]: MPlayer 1.3.0 (Debian), built with gcc-9 (C) 2000-2016 MPlayer Team
Dez 05 16:28:06 timpc mplayer[13082]: do_connect: could not connect to socket
Dez 05 16:28:06 timpc mplayer[13082]: connect: No such file or directory
Dez 05 16:28:06 timpc mplayer[13082]: Failed to open LIRC support. You will not be able to use your remote control.
Dez 05 16:28:06 timpc mplayer[13082]: Terminal type `unknown' is not defined.
Dez 05 16:28:06 timpc mplayer[13082]: Playing /usr/local/share/alarmd/a.wav.
Dez 05 16:28:06 timpc mplayer[13082]: libavformat version 58.29.100 (external)
Dez 05 16:28:06 timpc mplayer[13082]: Audio only file format detected.
Dez 05 16:28:06 timpc mplayer[13082]: Load subtitles in /usr/local/share/alarmd/
Dez 05 16:28:06 timpc mplayer[13082]: ==========================================================================
Dez 05 16:28:06 timpc mplayer[13082]: Opening audio decoder: [pcm] Uncompressed PCM audio decoder
Dez 05 16:28:06 timpc mplayer[13082]: AUDIO: 44100 Hz, 2 ch, s16le, 1411.2 kbit/100.00% (ratio: 176400->176400)
Dez 05 16:28:06 timpc mplayer[13082]: Selected audio codec: [pcm] afm: pcm (Uncompressed PCM)
Dez 05 16:28:06 timpc mplayer[13082]: ==========================================================================
Dez 05 16:28:06 timpc mplayer[13082]: AO: [pulse] Init failed: Connection refused
Dez 05 16:28:06 timpc mplayer[13082]: Failed to initialize audio driver 'pulse'
Dez 05 16:28:06 timpc mplayer[13082]: [AO_ALSA] alsa-lib: pcm_hw.c:1715:(snd_pcm_hw_open) open '/dev/snd/pcmC0D0p' failed (-2): No such file or directory
Dez 05 16:28:06 timpc mplayer[13082]: [AO_ALSA] alsa-lib: pcm_dmix.c:1089:(snd_pcm_dmix_open) unable to open slave
Dez 05 16:28:06 timpc mplayer[13082]: [AO_ALSA] Playback open error: No such file or directory
Dez 05 16:28:06 timpc mplayer[13082]: Failed to initialize audio driver 'alsa'
Dez 05 16:28:06 timpc mplayer[13082]: [AO SDL] Samplerate: 44100Hz Channels: Stereo Format s16le
Dez 05 16:28:06 timpc mplayer[13082]: [AO SDL] using aalib audio driver.
Dez 05 16:28:06 timpc mplayer[13082]: [AO SDL] Unable to open audio: No available audio device
Dez 05 16:28:06 timpc mplayer[13082]: Failed to initialize audio driver 'sdl:aalib'
Dez 05 16:28:06 timpc mplayer[13082]: Could not open/initialize audio device -> no sound.
Dez 05 16:28:06 timpc mplayer[13082]: Audio: no sound
Dez 05 16:28:06 timpc mplayer[13082]: Video: no video
Dez 05 16:28:06 timpc mplayer[13082]: Exiting... (End of file)
Dez 05 16:28:06 timpc systemd[1]: alarmd.service: Succeeded.
Dez 05 16:28:06 timpc systemd[1]: Finished alarmd service.

Как определить службу, чтобы звук воспроизводился?

Сама команда работает:

tim@timpc:~$ mplayer /usr/local/share/alarmd/a.wav
MPlayer 1.3.0 (Debian), built with gcc-9 (C) 2000-2016 MPlayer Team
do_connect: could not connect to socket
connect: No such file or directory
Failed to open LIRC support. You will not be able to use your remote control.

Playing /usr/local/share/alarmd/a.wav.
libavformat version 58.29.100 (external)
Audio only file format detected.
Load subtitles in /usr/local/share/alarmd/
==========================================================================
Opening audio decoder: [pcm] Uncompressed PCM audio decoder
AUDIO: 44100 Hz, 2 ch, s16le, 1411.2 kbit/100.00% (ratio: 176400->176400)
Selected audio codec: [pcm] afm: pcm (Uncompressed PCM)
==========================================================================
AO: [pulse] 44100Hz 2ch s16le (2 bytes per sample)
Video: no video
Starting playback...
A:   9.1 (09.1) of 233.0 (03:53.0)  0.0% 


MPlayer interrupted by signal 2 in module: play_audio
A:   9.2 (09.1) of 233.0 (03:53.0)  0.0% 

Exiting... (Quit)
3
задан 5 December 2021 в 15:33

0 ответов

Другие вопросы по тегам:

Похожие вопросы: