<!DOCTYPE html><html><head><title></title><style type="text/css">p.MsoNormal,p.MsoNoSpacing{margin:0}</style></head><body><div>On Sun, May 23, 2021, at 5:31 PM, Eric Branlund wrote:<br></div><blockquote type="cite" id="qt" style=""><div>The apparent cause of that are these lines in audio/mpegtoraw.cpp's Decode_MPEGaudio():<br></div><div><br></div><div>            if((Uint32)audio->rawdatawriteoffset*2 <= audio->ring->BufferSize())<br></div><div>              audio->ring->WriteDone(audio->rawdatawriteoffset*2, timestamp);<br></div><div><br></div><div>Those lines haven't changed between 0.4.4 and the current version on svn.icculus.org.  Changing them to<br></div><div><br></div><div>            assert(audio->rawdatawriteoffset <= audio->ring->BufferSize());<br></div><div>            audio->ring->WriteDone(audio->rawdatawriteoffset, timestamp);<br></div><div><br></div><div>avoids the hang.  That change is attached as a patch (computed against revision 413 of audio/mpegtoraw.cpp).<br></div></blockquote><div><br></div><div>On looking at it some more the problem is not with those lines but with one of OpenBSD's patches to smpeg:  with their patches the number of samples computed doesn't account for the conversion of these monaural files to stereo (forcetostereoflag is on triggering the duplication of the one channel in audio/mpegtoraw.cpp).  That can be worked around by this change (computed relative to the 0.4.4 sources they use as a base):<br></div><div><br></div><p style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-style:normal;font-variant-caps:normal;font-weight:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0, 0, 0);"><span style="font-variant-ligatures:no-common-ligatures;">--- old/audio/MPEGaudio.cpp <span class="Apple-converted-space">    </span>2001-04-04 13:42:40.000000000 -0700</span><br></p><p style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-style:normal;font-variant-caps:normal;font-weight:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0, 0, 0);"><span style="font-variant-ligatures:no-common-ligatures;">+++ new/audio/MPEGaudio.cpp <span class="Apple-converted-space">    </span>2021-05-24 09:09:56.000000000 -0700</span><br></p><p style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-style:normal;font-variant-caps:normal;font-weight:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0, 0, 0);"><span style="font-variant-ligatures:no-common-ligatures;">@@ -98,7 +98,7 @@</span><br></p><p style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-style:normal;font-variant-caps:normal;font-weight:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0, 0, 0);"><span style="font-variant-ligatures:no-common-ligatures;"><span class="Apple-converted-space"> </span>#else</span><br></p><p style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-style:normal;font-variant-caps:normal;font-weight:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0, 0, 0);"><span style="font-variant-ligatures:no-common-ligatures;"><span class="Apple-converted-space">     </span>wanted->format = AUDIO_S16MSB;</span><br></p><p style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-style:normal;font-variant-caps:normal;font-weight:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0, 0, 0);"><span style="font-variant-ligatures:no-common-ligatures;"><span class="Apple-converted-space"> </span>#endif</span><br></p><p style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-style:normal;font-variant-caps:normal;font-weight:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0, 0, 0);"><span style="font-variant-ligatures:no-common-ligatures;">-<span class="Apple-converted-space">    </span>if ( outputstereo ) {</span><br></p><p style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-style:normal;font-variant-caps:normal;font-weight:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0, 0, 0);"><span style="font-variant-ligatures:no-common-ligatures;">+<span class="Apple-converted-space">    </span>if ( outputstereo || forcetostereoflag ) {</span><br></p><p style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-style:normal;font-variant-caps:normal;font-weight:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0, 0, 0);"><span style="font-variant-ligatures:no-common-ligatures;"><span class="Apple-converted-space">         </span>wanted->channels = 2;</span><br></p><p style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-style:normal;font-variant-caps:normal;font-weight:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0, 0, 0);"><span style="font-variant-ligatures:no-common-ligatures;"><span class="Apple-converted-space">     </span>} else {</span><br></p><p style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-style:normal;font-variant-caps:normal;font-weight:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0, 0, 0);"><span style="font-variant-ligatures:no-common-ligatures;"><span class="Apple-converted-space">         </span>wanted->channels = 1;</span><br></p><p style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-style:normal;font-variant-caps:normal;font-weight:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0, 0, 0);"><span style="font-variant-ligatures:no-common-ligatures;">@@ -116,7 +116,7 @@</span><br></p><p style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-style:normal;font-variant-caps:normal;font-weight:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0, 0, 0);"><span style="font-variant-ligatures:no-common-ligatures;"><span class="Apple-converted-space">     </span>if ( actual->channels == 1 && outputstereo ) {</span><br></p><p style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-style:normal;font-variant-caps:normal;font-weight:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0, 0, 0);"><span style="font-variant-ligatures:no-common-ligatures;"><span class="Apple-converted-space">         </span>forcetomonoflag = true;</span><br></p><p style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-style:normal;font-variant-caps:normal;font-weight:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0, 0, 0);"><span style="font-variant-ligatures:no-common-ligatures;"><span class="Apple-converted-space">     </span>}</span><br></p><p style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-style:normal;font-variant-caps:normal;font-weight:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0, 0, 0);"><span style="font-variant-ligatures:no-common-ligatures;">-<span class="Apple-converted-space">    </span>if ( actual->channels == 2 && !outputstereo ) {</span><br></p><p style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-style:normal;font-variant-caps:normal;font-weight:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0, 0, 0);"><span style="font-variant-ligatures:no-common-ligatures;">+<span class="Apple-converted-space">    </span>if ( actual->channels == 2 && !outputstereo && !forcetostereoflag ) {</span><br></p><p style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-style:normal;font-variant-caps:normal;font-weight:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0, 0, 0);"><span style="font-variant-ligatures:no-common-ligatures;"><span class="Apple-converted-space">         </span>forcetostereoflag = true;</span><br></p><p style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-style:normal;font-variant-caps:normal;font-weight:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0, 0, 0);"><span style="font-variant-ligatures:no-common-ligatures;"><span class="Apple-converted-space">         </span>samplesperframe *= 2;</span><br></p><p style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-style:normal;font-variant-caps:normal;font-weight:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0, 0, 0);"><span style="font-variant-ligatures:no-common-ligatures;"><span class="Apple-converted-space">     </span>}</span><br></p><div><span style="font-variant-ligatures:no-common-ligatures;"></span><br></div><div>Sorry for the noise.<br></div><div><br></div><div><br></div><div>Eric Branlund<br></div><div><br></div></body></html>