Mplayer not recognizing sound card when running as a systemd daemon

Clash Royale CLAN TAG#URR8PPP up vote
0
down vote
favorite
I've been able to setup a shairport and mplayer for my home Ubuntu machine. It works well if I launch them from command line. Shairport outputs into a fifo file, so its details are not related to the question probably.
And mplayer is launched as:
/bin/bash -c 'while true; do mplayer -rawaudio samplesize=2:channels=1:rate=88200 -demuxer rawaudio /home/kb/workspace/shairport/music; sleep 1; done'
Now, I wanted to put their commands into the systemd services so that I don't need to launch them manually every time I boot. Worked well for shairport. For mplayer I've made this service:
â ~ cat /etc/systemd/system/mplayer-shairport.service
[Unit]
Description=Mplayer-Shairport
[Service]
ExecStart=/bin/bash -c 'while true; do mplayer -rawaudio samplesize=2:channels=1:rate=88200 -demuxer rawaudio /home/kb/workspace/shairport/music; sleep 1; done'
[Install]
WantedBy=multi-user.target
What I get as a result is that when I launch mplayer from the command-line, it outputs the sound via my USB card into speakers. But when I launch it from the systemd service, it outputs into the built-in PC speaker. What is the reason behind this auto-detection failure?
Additional Info
In case this is helpful:
â ~ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: PCH [HDA Intel PCH], device 0: ALC221 Analog [ALC221 Analog]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: USB [AudioBox USB], device 0: USB Audio [USB Audio]
Subdevices: 0/1
Subdevice #0: subdevice #0
card 2: NVidia [HDA NVidia], device 3: HDMI 0 [HDMI 0]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 2: NVidia [HDA NVidia], device 7: HDMI 1 [HDMI 1]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 2: NVidia [HDA NVidia], device 8: HDMI 2 [HDMI 2]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 2: NVidia [HDA NVidia], device 9: HDMI 3 [HDMI 3]
Subdevices: 1/1
Subdevice #0: subdevice #0
sound systemd mplayer
add a comment |Â
up vote
0
down vote
favorite
I've been able to setup a shairport and mplayer for my home Ubuntu machine. It works well if I launch them from command line. Shairport outputs into a fifo file, so its details are not related to the question probably.
And mplayer is launched as:
/bin/bash -c 'while true; do mplayer -rawaudio samplesize=2:channels=1:rate=88200 -demuxer rawaudio /home/kb/workspace/shairport/music; sleep 1; done'
Now, I wanted to put their commands into the systemd services so that I don't need to launch them manually every time I boot. Worked well for shairport. For mplayer I've made this service:
â ~ cat /etc/systemd/system/mplayer-shairport.service
[Unit]
Description=Mplayer-Shairport
[Service]
ExecStart=/bin/bash -c 'while true; do mplayer -rawaudio samplesize=2:channels=1:rate=88200 -demuxer rawaudio /home/kb/workspace/shairport/music; sleep 1; done'
[Install]
WantedBy=multi-user.target
What I get as a result is that when I launch mplayer from the command-line, it outputs the sound via my USB card into speakers. But when I launch it from the systemd service, it outputs into the built-in PC speaker. What is the reason behind this auto-detection failure?
Additional Info
In case this is helpful:
â ~ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: PCH [HDA Intel PCH], device 0: ALC221 Analog [ALC221 Analog]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: USB [AudioBox USB], device 0: USB Audio [USB Audio]
Subdevices: 0/1
Subdevice #0: subdevice #0
card 2: NVidia [HDA NVidia], device 3: HDMI 0 [HDMI 0]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 2: NVidia [HDA NVidia], device 7: HDMI 1 [HDMI 1]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 2: NVidia [HDA NVidia], device 8: HDMI 2 [HDMI 2]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 2: NVidia [HDA NVidia], device 9: HDMI 3 [HDMI 3]
Subdevices: 1/1
Subdevice #0: subdevice #0
sound systemd mplayer
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I've been able to setup a shairport and mplayer for my home Ubuntu machine. It works well if I launch them from command line. Shairport outputs into a fifo file, so its details are not related to the question probably.
And mplayer is launched as:
/bin/bash -c 'while true; do mplayer -rawaudio samplesize=2:channels=1:rate=88200 -demuxer rawaudio /home/kb/workspace/shairport/music; sleep 1; done'
Now, I wanted to put their commands into the systemd services so that I don't need to launch them manually every time I boot. Worked well for shairport. For mplayer I've made this service:
â ~ cat /etc/systemd/system/mplayer-shairport.service
[Unit]
Description=Mplayer-Shairport
[Service]
ExecStart=/bin/bash -c 'while true; do mplayer -rawaudio samplesize=2:channels=1:rate=88200 -demuxer rawaudio /home/kb/workspace/shairport/music; sleep 1; done'
[Install]
WantedBy=multi-user.target
What I get as a result is that when I launch mplayer from the command-line, it outputs the sound via my USB card into speakers. But when I launch it from the systemd service, it outputs into the built-in PC speaker. What is the reason behind this auto-detection failure?
Additional Info
In case this is helpful:
â ~ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: PCH [HDA Intel PCH], device 0: ALC221 Analog [ALC221 Analog]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: USB [AudioBox USB], device 0: USB Audio [USB Audio]
Subdevices: 0/1
Subdevice #0: subdevice #0
card 2: NVidia [HDA NVidia], device 3: HDMI 0 [HDMI 0]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 2: NVidia [HDA NVidia], device 7: HDMI 1 [HDMI 1]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 2: NVidia [HDA NVidia], device 8: HDMI 2 [HDMI 2]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 2: NVidia [HDA NVidia], device 9: HDMI 3 [HDMI 3]
Subdevices: 1/1
Subdevice #0: subdevice #0
sound systemd mplayer
I've been able to setup a shairport and mplayer for my home Ubuntu machine. It works well if I launch them from command line. Shairport outputs into a fifo file, so its details are not related to the question probably.
And mplayer is launched as:
/bin/bash -c 'while true; do mplayer -rawaudio samplesize=2:channels=1:rate=88200 -demuxer rawaudio /home/kb/workspace/shairport/music; sleep 1; done'
Now, I wanted to put their commands into the systemd services so that I don't need to launch them manually every time I boot. Worked well for shairport. For mplayer I've made this service:
â ~ cat /etc/systemd/system/mplayer-shairport.service
[Unit]
Description=Mplayer-Shairport
[Service]
ExecStart=/bin/bash -c 'while true; do mplayer -rawaudio samplesize=2:channels=1:rate=88200 -demuxer rawaudio /home/kb/workspace/shairport/music; sleep 1; done'
[Install]
WantedBy=multi-user.target
What I get as a result is that when I launch mplayer from the command-line, it outputs the sound via my USB card into speakers. But when I launch it from the systemd service, it outputs into the built-in PC speaker. What is the reason behind this auto-detection failure?
Additional Info
In case this is helpful:
â ~ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: PCH [HDA Intel PCH], device 0: ALC221 Analog [ALC221 Analog]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: USB [AudioBox USB], device 0: USB Audio [USB Audio]
Subdevices: 0/1
Subdevice #0: subdevice #0
card 2: NVidia [HDA NVidia], device 3: HDMI 0 [HDMI 0]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 2: NVidia [HDA NVidia], device 7: HDMI 1 [HDMI 1]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 2: NVidia [HDA NVidia], device 8: HDMI 2 [HDMI 2]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 2: NVidia [HDA NVidia], device 9: HDMI 3 [HDMI 3]
Subdevices: 1/1
Subdevice #0: subdevice #0
sound systemd mplayer
sound systemd mplayer
asked Feb 28 at 9:33
Kostiantyn Rybnikov
1465
1465
add a comment |Â
add a comment |Â
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1010576%2fmplayer-not-recognizing-sound-card-when-running-as-a-systemd-daemon%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password