<div dir="ltr">SDL_mixer seems to work differently on the emulator from the device.<div><br></div><div>Using the emulator I can play both .wav and .ogg files without a problem using SDL_mixer, but on my device no sound comes out.</div>

<div><br></div><div>My sound initialisation function:</div><div><br></div><div><pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(128,128,0)">void</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">InitSound</span><span style="color:rgb(0,0,0)">()</span></pre>


<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(0,0,0)">{</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">     </span><span style="color:rgb(128,128,0)">const</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,128,0)">int</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">NUM_CHANNELS</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">=</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">16</span><span style="color:rgb(0,0,0)">;</span></pre>


<pre style="margin-top:0px;margin-bottom:0px"><br></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">     </span><span style="color:rgb(128,128,0)">int</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">rate</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">=</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">44100</span><span style="color:rgb(0,0,0)">;</span></pre>


<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">     </span>Uint16<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">format</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">=</span><span style="color:rgb(192,192,192)"> </span>AUDIO_S16SYS<span style="color:rgb(0,0,0)">;</span></pre>


<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">     </span><span style="color:rgb(128,128,0)">int</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">channels</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">=</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">2</span><span style="color:rgb(0,0,0)">;</span></pre>


<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">     </span><span style="color:rgb(128,128,0)">int</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">bufferSize</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">=</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">1024</span><span style="color:rgb(0,0,0)">;</span></pre>


<pre style="margin-top:0px;margin-bottom:0px"><br></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">     </span><span style="color:rgb(128,128,0)">if</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">(</span><span style="color:rgb(192,192,192)"> </span>Mix_OpenAudio<span style="color:rgb(0,0,0)">(</span><span style="color:rgb(0,0,0)">rate</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">format</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">channels</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">bufferSize</span><span style="color:rgb(0,0,0)">)</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">==</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">0</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">)</span></pre>


<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">             </span>Mix_AllocateChannels<span style="color:rgb(0,0,0)">(</span><span style="color:rgb(0,0,0)">NUM_CHANNELS</span><span style="color:rgb(0,0,0)">);</span></pre>


<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">    </span><span style="color:rgb(128,128,0)">else</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">        </span>Debug<span style="color:rgb(0,0,0)">::</span>DbgOutF<span style="color:rgb(0,0,0)">(</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">"Mix_OpenAudio:</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">%s\n"</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(192,192,192)"> </span>Mix_GetError<span style="color:rgb(0,0,0)">()</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">);</span></pre>


<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(0,0,0)">}</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><br></pre><pre style="margin-top:0px;margin-bottom:0px"><br></pre><pre style="margin-top:0px;margin-bottom:0px">My call for playing:</pre><pre style="margin-top:0px;margin-bottom:0px">

<br></pre><pre style="margin-top:0px;margin-bottom:0px">Mix_Music<span style="color:rgb(0,0,0)">*</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,0)">pMusic = </span><span style="font-family:arial">Mix_LoadMUS</span><span style="font-family:arial;color:rgb(0,0,0)">(</span><span style="font-family:arial;color:rgb(192,192,192)"> </span><span style="font-family:arial;color:rgb(0,0,0)">filename</span><span style="font-family:arial;color:rgb(192,192,192)"> </span><span style="font-family:arial;color:rgb(0,0,0)">);</span><span style="color:rgb(0,0,0);font-family:arial">              <-   for .ogg and other music files</span></pre>

<pre style="margin-top:0px;margin-bottom:0px">Mix_Chunk<span style="color:rgb(0,0,0)">*</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,0)">pSound = </span><span style="font-family:arial">Mix_LoadWAV</span><span style="font-family:arial;color:rgb(0,0,0)">(</span><span style="font-family:arial;color:rgb(192,192,192)"> </span><span style="font-family:arial;color:rgb(0,0,0)">filename</span><span style="font-family:arial;color:rgb(192,192,192)"> </span><span style="font-family:arial;color:rgb(0,0,0)">)</span><span style="color:rgb(0,0,0);font-family:arial">;             </span><span style="color:rgb(0,0,0);font-family:arial"><-   for .wav files</span></pre>

<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(0,0,0);font-family:arial"><br></span></pre><pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(0,0,0);font-family:arial">And then I call different SDL_mixer function for playing the above files</span></pre>

<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(128,128,0)">bool</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">repeat;    <-  true or false depending if I want one time play or infinite</span></pre>

<pre style="margin-top:0px;margin-bottom:0px">Mix_PlayMusic<span style="color:rgb(0,0,0)">(</span><span style="color:rgb(128,0,0)">pMusic</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">repeat</span><span style="color:rgb(0,0,0)">?-</span><span style="color:rgb(0,0,128)">1</span><span style="color:rgb(0,0,0)">:</span><span style="color:rgb(0,0,128)">0);                </span><span style="color:rgb(0,0,0);font-family:arial"><-   for .ogg and other music files</span></pre>

<pre style="margin-top:0px;margin-bottom:0px">Mix_PlayChannel<span style="color:rgb(0,0,0)">(-</span><span style="color:rgb(0,0,128)">1</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,0)">pSound</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">repeat</span><span style="color:rgb(0,0,0)">?-</span><span style="color:rgb(0,0,128)">1</span><span style="color:rgb(0,0,0)">:</span><span style="color:rgb(0,0,128)">0</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">)          </span><span style="color:rgb(0,0,0);font-family:arial"><-   for .wav files</span></pre>

<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(0,0,0);font-family:arial"><br></span></pre><pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(0,0,0);font-family:arial"><br></span></pre>

<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(0,0,0);font-family:arial">For code clarity above I haven't included my checks if pointers and return value of SDL_mixer calls are valid, but in my actual game I check that either pMusic or pSound are not NULL depending on my sound file and that the return value of the Mix_* calls is 0 according to the documentation.</span></pre>

<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(0,0,0);font-family:arial"><br></span></pre><pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(0,0,0);font-family:arial">I haven't tested the sample from </span><font color="#000000" face="arial"><a href="https://github.com/thp/sdl2-opengles-test">https://github.com/thp/sdl2-opengles-test</a> </font><span style="color:rgb(0,0,0);font-family:arial">yet, but don't expect different results.</span></pre>

<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(0,0,0);font-family:arial"><br></span></pre></div></div>