[REBOL] using 'wait with your own port handler?
From: d95-mjo::nada::kth::se at: 24-Jun-2001 21:24
Hi!
I read the following article earlier today:
> Writing your own Protocol Handler by Jeff Kreis.
> http://www.rebolforces.com/articles/protocols.html
and I thought it was very interesting. I tried to use this approach on a
little project I'm doing, but I'm no longer sure if I can get it to do
what I want it to do. This is what I'm trying to do:
Using View/Pro and a DLL, I've been able to play MP3 files by calling
functions in the DLL from REBOL. What I'd like to do is to create a
port interface for my MP3 routines that works like the sound://
port. It would look something like this:
;-- Open mp3 port (load DLL etc)
mp3-port: open mp3://
;-- Play mp3 file (by calling DLL function)
insert mp3-port %nameofsong.mp3
;-- Wait for mp3 to finish (somehow)
wait mp3-port
;-- Close mp3 port (free DLL etc)
close mp3-port
This all seems to work, EXCEPT for 'wait. So, my question is this: Is it
at all possible to write your own port handler that you can wait for using
'wait? If so, how would I do that? I've used the make root-protocol
approach and I can't really figure it out. I tried using 'wait on my
port, just to see what would happen, and it crashed REBOL. :-) The reason
I want to use 'wait is that I would like to be able to wait for other
ports at the same time. I have a feeling that 'wait is a bit too
tied to low level port internals to work with my higher level port
handler. Anyway, if anyone has any suggestions or ideas about how to make
this work (or why it won't work), I'd be very grateful if you'd like
to share this information on the mailing list. :-)
(I forgot to mention that I haven't really thought about exactly HOW to do
the actual wait-for-mp3 function, because first I'd need to understand how
to use 'wait on my own port, in general. At the moment, it seems like
I'd have to use some kind of poll loop.)
TIA,
Martin Johannesson
[d95-mjo--nada--kth--se]