[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [sc-dev] on the nature of server crashes and restarts



pete moss wrote:
> if you get that working it would be great, but i have tried and failed.
>    i could find no way to get it to work as a plugin without crashing
> the server or delaying the start so that the server would fail.  maybe
> when SC4 comes along with its plugin primitives, it could work, but for
> now plugins need to be simple.

that's not true. you can do pretty complex things, but you need to defer
non-realtime-safe operations to the nrt thread via asynchronous
commands. have a look at SC_SequencedCommand.cpp, at the bottom.

you spawn an async command with the macro

DoAsynchronousCommand

and pass a structure with the information you need and various 'stage'
callbacks.

stage 2 is executed in the nrt thread, you can e.g. do device
initialization there

stage 3 is executed in the rt thread, here you can pass back the device
handle to the audio thread and execute completion messages

stage 4 is executed in nrt for cleanup

cleanup is executed in rt for cleanup

you probably need to do the same when closing the device.

hth,
<sk>