title: Linux Can't play sound at the begining of system start in an auto-start process using SDL_Mixer
body: <p>I've used SDL2_Mixer to play sound on Linux Ubuntu 16.04.
  Here is my class code.</p>
  <pre class="lang-cpp prettyprint-override"><code>bool SoundPlayer::init()
  {
      if (SDL_Init(SDL_INIT_AUDIO) &lt; 0)
      {
          LOG(ERROR)&lt;&lt;&quot;init failed.\n&quot;;
      }
  
      LOG(INFO)&lt;&lt;&quot;Speaker SDL init succeeded.&quot;;
  
      volume = DEFAULT_VOLUME;
  
      if(Mix_OpenAudio(MIX_DEFAULT_FREQUENCY, MIX_DEFAULT_FORMAT, 2, 4096) == -1)
      {
          LOG(ERROR)&lt;&lt;&quot;audio not found,&quot;&lt;&lt;Mix_GetError();    
          is_init = false;
      }
      else
      {
          is_init = true;
      }
      return is_init;
  }
  </code></pre>
  <p><strong>Starting Procedure</strong></p>
  <ul>
  <li>Process A staticly declared a SoundPlayer class.</li>
  <li>Process A is started by another Process B.</li>
  <li>Process B is started by system process management tool <code>supervisord</code> right after system start.</li>
  </ul>
  <p><strong>Problem Description</strong></p>
  <ul>
  <li><p>Right after system started, process A cound not play sound successfully, coming with <code>ALSA: Couldn't open audio device: No such file or directory</code>.</p>
  </li>
  <li><p>However, after I login my system remotely with teamviewer, the sound plays good. Process A never restarted but <code>SoundPlayer</code> class inited again</p>
  </li>
  <li><p>Another scenario is, after system started, when I compiled a test program to play sound and mannually started it in a terminal, the sound plays good too.</p>
  </li>
  </ul>
  <p>I'm so confused and wondering if I missed something after system start or something else?</p>