[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-smalltalk] (long) DLD help / SDL bindings for GNU Smalltalk
From: |
Paolo Bonzini |
Subject: |
Re: [Help-smalltalk] (long) DLD help / SDL bindings for GNU Smalltalk |
Date: |
Wed, 02 May 2001 18:39:47 +0200 |
> What SDL has an audio library which fires off a
> callback whenever its audio out buffer is empty.
This *will* work as long as the (C) thread executing the
call-in is the same that executes the code. You can
process events from C in Smalltalk, like Blox does: it
preempts whatever is happening on the current Smalltalk
Process, then returns control to the C program
when the Smalltalk code completed its evaluation. This
is a synchronous operation; you can trigger asynchronous
operations by using Semaphores and Processes (possibly
running at higher priorities than the userSchedulingPriority);
asyncSignal is exported through the VMProxy as well.
However, it seems like you want a fast response from the
interpreter. Be careful!
> tried passing it as a (ptr
> byte), but that made it through to the C as null).
Hmmm... making it a #{CObject} should do as well as
a (ptr byte). I guess you are using something like
CStruct subclass: #SDLAudio
declaration: #( ... (cCallback #{CObject}) ... )
...
and then doing
anSDLAudio cCallback
In that case, you will obtain a pointer to the field,
not the value of the field! You will need
anSDLAudio cCallback value: (DLD getFunc: ...)
to set what in C would be anSDLAudio->cCallback.
I fail to remember exactly the semantics of CStructs, and
it was indeed a quest to understand them when I brought
GDBM back to life (I did not write CStructs), but the basic
rule is that you always need an extra #value or #value:
method send; and remember that CStructs have no setters!
Paolo
ps: write to help-smalltalk, not to me!