Hi,
> general abstract sound server bits
> | |
> | ------> polled version of sound server
> | | | |
> | UNIX SDL etc...
> |
> ----------> event-driven version of sound server
> | |
> Win32 cross-platform?
Actually, it's possible to emulate an event-driver version of the sound
server (with the functions process_command() and process_midi()) by doing
roughly about this:
void forked_loop()
{
time_t next_event = current_time();
int status = 1;
while (status) {
time = next_event - current_time();
int got_command = select(cmd_pipes, 0, 0, &time);
if (got_command) {
command = read_command(cmd_pipes);
process_command(command);
}
if (current_time() >= next_event)
next_event = process_midi(&status);
}
}
This would mean that the difference between polled and message-oriented
sound servers could be kept down to a minimum.
> What do you think?
It would only help Win32. Right now, I don't see where we could be sharing
code with a potential MacOS or forked/execve'd timidity implementation
(except perhaps by means of an SCI song iterator object which returns
"event" or "loop" or "MIDI command" while processing song data- this would
make the sound server code quite a bit more readable and could be used in
a re-implementation of makeMIDI0()).
So we'd have a two-stage approach:
- Migration from loop-based to event-based (helps Win32)
- Abstract out song data parsing (clean-up, helps SCI01/SCI1 and
General MIDI file generation).
The second step needs some more thought, though- as indicated, MIDI
transformations (e.g. MT32->GM) could be called from there.
The thing would then look approximately like this (in the long run):
--------------------
song data
--------------------
| |
| |
v v
SCI0 song SCI01 song
decoder__ __decoder
/ | \ --___-- / | \
/ | X-- --X__ | \
v _|-- v v --|_ v
Song<-- | Song | --> Song
Target | Target | Target
MT-32 | GM | Adlib
\ | | | /
\ | | | /
v v v v v
Song iterator object (returns time
index, translated song data, cues,
loop instructions, EOTs)
What do you think? It's mostly clean-up, of course...
llap,
Christoph