supercollider/supercollider — pull request #914 by ventosus (2013-07-17 10:17:48+00:00)
Title: scsynth: support for receiving nested OSC bundles.

I'm sending messages directly to scsynth from microcontrollers and want to pack
as much messages into a single UDP packet as possible to save cycles and bandwith.

My messages don't have all the same timestamp. Some need to be executed immediately,
other later.

To be able to pack messages with different timestamps into the same UDP packet,
I make use of nested OSC bundles. This patch adds support to scsynth to handle nested OSC
bundles, as it cannot handle them right now.

As this enhances a sensible part of scsynth, I propose that this patch needs some thorough review...
--------------------------------

scsynth right now cannot receive nested OSC bundles, this patch adds
support for it. To play nicely with the current way of scheduling
bundles, it does so by unrolling(unnesting) nested bundles before
handing them over via the FIFO to the realtime thread.

the example incoming packet with nested bundles:

[ #bundle IMMEDIATE
[ /tick, 13]
[ #bundle IMMEDIATE
[ /s_new, 1000, ...]
]
[ /tock, 14]
[ #bundle +1ms
[ /n_set, 1000, 'gate', 1, ...]
]
]

is unrolled to three individual packets each consisting of a single bundle:

[ #bundle IMMEDIATE
[ /tick, 13]
[ /tock, 14]
]

[ #bundle IMMEDIATE
[ /s_new, 1000, ...]
]

[ #bundle +1ms
[ /n_set, 1000, 'gate', 1, ...]
]

Signed-off-by: Hanspeter Portner