[Vm-dev] MPEG3Plugin code appears broken when generated?
Eliot Miranda
eliot.miranda at gmail.com
Wed Dec 16 03:42:04 UTC 2020
Hi Tim,
On Sat, Dec 12, 2020 at 6:07 PM tim Rowledge <tim at rowledge.org> wrote:
>
> 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.
>
> 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.
>
> 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.
>
> Current code on opensmalltalk git -
>
> /* int mpeg3_read_audio(mpeg3_t *file,
> float *output_f,
> short *output_i,
> int channel,
> long samples,
> int stream) */
>
> /*
> Mpeg3Plugin>>#primitiveMPEG3ReadAudio:shortArray:channel:samples:stream: */
> EXPORT(sqInt)
> primitiveMPEG3ReadAudio(void)
> {
> sqInt aChannelNumber;
> sqInt aNumber;
> sqInt *anArray;
> short *arrayBase;
> sqInt aSampleNumber;
> mpeg3_t *file;
> sqInt fileHandle;
> sqInt result;
>
> result = 0;
> if (!(((isPointers(stackValue(3)))
> && (isIndexable(stackValue(3))))
> && ((isIntegerObject((aChannelNumber = stackValue(2))))
> && ((isIntegerObject((aSampleNumber = stackValue(1))))
> && (isIntegerObject((aNumber = stackValue(0)))))))) {
> primitiveFailFor(PrimErrBadArgument);
> return null;
> }
>
> The two interesting things I have remaining energy to point out today -
> The Slang does explicitly and wrongly declare it as
>
> self primitive: 'primitiveMPEG3ReadAudio' parameters: #(Oop Array
> SmallInteger SmallInteger SmallInteger).
>
> .. which clearly doesn't help. It has, however, been that way since 2006.
>
> And the old C file from Back Then has
>
> result = 0;
> fileHandle = stackValue(4);
> success(isIndexable(stackValue(3)));
> anArray = ((sqInt *) (firstIndexableField(stackValue(3))));
> aChannelNumber = stackIntegerValue(2);
> aSampleNumber = stackIntegerValue(1);
> aNumber = stackIntegerValue(0);
> if (failed()) {
> return null;
> }
> .. and so it makes kinda sense why it worked Back Then.
>
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.
> 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.
>
Exactly. Spur requires the extra zealousness.
> More when awake.
>
> tim
> --
> tim Rowledge; tim at rowledge.org; http://www.rowledge.org/tim
> Strange OpCodes: STOP: No Op
>
>
>
--
_,,,^..^,,,_
best, Eliot
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20201215/5e5b30cf/attachment-0001.html>
More information about the Vm-dev
mailing list