<div dir="ltr"><div dir="ltr"><div class="gmail_default" style="font-size:large">Hi Tim,</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Dec 12, 2020 at 6:07 PM tim Rowledge <<a href="mailto:tim@rowledge.org">tim@rowledge.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"> <br>
Is anybody else doing anything with MP3 files? It looks like we haven't included any image-side support for them for several releases now (I've look back to 4.5) but it is/was working just fine for the work I did on Pi Scratch. That was, admittedly, quite a while ago.<br>
<br>
In the current system I can load much of Scratch without too many issues - sounds are really messed up in various places, some morph building is broken etc - but today I'm trying to see why mp3 sounds don't.<br>
<br>
It seems that the code for the src/plugins/Mpeg3Plugin.c is broken. The autogenerated checks for the types of the arguments is insisting that be indexable pointers, when is is in fact a variable word array. That at least explains why the prim fails, which is at least a step forward.<br>
<br>
Current code on opensmalltalk git - <br>
<br>
/*      int mpeg3_read_audio(mpeg3_t *file, <br>
        float *output_f, <br>
        short *output_i, <br>
        int channel, <br>
        long samples,<br>
        int stream) */<br>
<br>
        /* Mpeg3Plugin>>#primitiveMPEG3ReadAudio:shortArray:channel:samples:stream: */<br>
EXPORT(sqInt)<br>
primitiveMPEG3ReadAudio(void)<br>
{<br>
        sqInt aChannelNumber;<br>
        sqInt aNumber;<br>
        sqInt *anArray;<br>
        short *arrayBase;<br>
        sqInt aSampleNumber;<br>
        mpeg3_t *file;<br>
        sqInt fileHandle;<br>
        sqInt result;<br>
<br>
        result = 0;<br>
        if (!(((isPointers(stackValue(3)))<br>
                 && (isIndexable(stackValue(3))))<br>
                 && ((isIntegerObject((aChannelNumber = stackValue(2))))<br>
                 && ((isIntegerObject((aSampleNumber = stackValue(1))))<br>
                 && (isIntegerObject((aNumber = stackValue(0)))))))) {<br>
                primitiveFailFor(PrimErrBadArgument);<br>
                return null;<br>
        }<br>
<br>
The two interesting things I have remaining energy to point out today -<br>
The Slang does explicitly and wrongly declare it as <br>
<br>
self primitive: 'primitiveMPEG3ReadAudio' parameters: #(Oop Array SmallInteger SmallInteger SmallInteger).<br>
<br>
.. which clearly doesn't help. It has, however, been that way since 2006.<br>
<br>
And the old C file from Back Then has <br>
<br>
        result = 0;<br>
        fileHandle = stackValue(4);<br>
        success(isIndexable(stackValue(3)));<br>
        anArray = ((sqInt *) (firstIndexableField(stackValue(3))));<br>
        aChannelNumber = stackIntegerValue(2);<br>
        aSampleNumber = stackIntegerValue(1);<br>
        aNumber = stackIntegerValue(0);<br>
        if (failed()) {<br>
                return null;<br>
        }<br>
.. and so it makes kinda sense why it worked Back Then.<br></blockquote><div><br></div><div class="gmail_default">Ah, thank you.  That explains things.  I had to change the checking to be more aggressive so that Spur's lazy forwarding would work.  I had to arrange that such code would fail for forwarders.  So I had to change the generated Slang so that it tested for a particular kind of array, rather than not testing at all and hence potentially passing a pointer to a forwarder.</div><div class="gmail_default"><br></div><div class="gmail_default"><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">
<br>
Thus I am inclined (and not just because I'm falling asleep) to think that some change in how the prologue stuff is generated might have started to note the Array declaration and become more zealous.<br></blockquote><div><br></div><div class="gmail_default">Exactly.  Spur requires the extra zealousness.</div><div class="gmail_default"><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">
<br>
More when awake.<br>
<br>
tim<br>
--<br>
tim Rowledge; <a href="mailto:tim@rowledge.org" target="_blank">tim@rowledge.org</a>; <a href="http://www.rowledge.org/tim" rel="noreferrer" target="_blank">http://www.rowledge.org/tim</a><br>
Strange OpCodes: STOP: No Op<br>
<br>
<br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><span style="font-size:small;border-collapse:separate"><div>_,,,^..^,,,_<br></div><div>best, Eliot</div></span></div></div></div></div>