Mplayer not recognizing sound card when running as a systemd daemon

The name of the pictureThe name of the pictureThe name of the pictureClash 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









share|improve this question

























    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









    share|improve this question























      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









      share|improve this question













      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






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Feb 28 at 9:33









      Kostiantyn Rybnikov

      1465




      1465

























          active

          oldest

          votes











          Your Answer







          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "89"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: false,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













           

          draft saved


          draft discarded


















          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



































          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes















           

          draft saved


          draft discarded















































           


          draft saved


          draft discarded














          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













































































          Popular posts from this blog

          Trouble downloading packages list due to a “Hash sum mismatch” error

          How do so many people here on Academia.SE, and in general, afford lavish higher education programs?

          How do I move numbers in filenames, in a batch renaming operation?