[smpeg] THREADED_AUDIO decoding
Eric Branlund
ebranlund at fastmail.com
Mon May 24 12:16:46 EDT 2021
On Sun, May 23, 2021, at 5:31 PM, Eric Branlund wrote:
> The apparent cause of that are these lines in audio/mpegtoraw.cpp's Decode_MPEGaudio():
>
> if((Uint32)audio->rawdatawriteoffset*2 <= audio->ring->BufferSize())
> audio->ring->WriteDone(audio->rawdatawriteoffset*2, timestamp);
>
> Those lines haven't changed between 0.4.4 and the current version on svn.icculus.org. Changing them to
>
> assert(audio->rawdatawriteoffset <= audio->ring->BufferSize());
> audio->ring->WriteDone(audio->rawdatawriteoffset, timestamp);
>
> avoids the hang. That change is attached as a patch (computed against revision 413 of audio/mpegtoraw.cpp).
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):
--- old/audio/MPEGaudio.cpp 2001-04-04 13:42:40.000000000 -0700
+++ new/audio/MPEGaudio.cpp 2021-05-24 09:09:56.000000000 -0700
@@ -98,7 +98,7 @@
#else
wanted->format = AUDIO_S16MSB;
#endif
- if ( outputstereo ) {
+ if ( outputstereo || forcetostereoflag ) {
wanted->channels = 2;
} else {
wanted->channels = 1;
@@ -116,7 +116,7 @@
if ( actual->channels == 1 && outputstereo ) {
forcetomonoflag = true;
}
- if ( actual->channels == 2 && !outputstereo ) {
+ if ( actual->channels == 2 && !outputstereo && !forcetostereoflag ) {
forcetostereoflag = true;
samplesperframe *= 2;
}
Sorry for the noise.
Eric Branlund
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://icculus.org/pipermail/smpeg/attachments/20210524/0d5518fa/attachment.htm>
More information about the smpeg
mailing list