lua-users home
lua-l archive

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

My current plans go approximately like this:

Since any Lua script utilizing SDL_Mixer also needs to have an SDL event loop, I'll make SDL_PollEvent responsible for the "lua side" fetching of the callbacks.

	Lua runs..
-> sdl_mixer C side callback -> glua_callback_post -> continue.. (no access of Lua here)
		-> glua_callback_fetch -> Lua callback
		(looping until no callbacks left in queue)

That's fairly simple, and does not need Lua core mods (good so). There's a lot more details, sure, but this should work, be simple, and modular. Also, the dispatcher and fetcher don't need to intimitely know each other.

Thanks for the ideas!

5.4.2005 kello 16:16, Ashwin Hirschi kirjoitti:

The Lua/SDL_mixer integration is having the following problem:

   Lua runs happily, starts to play a tune  ..dam-dam..
   Attaches a callback to get to the rhytm

   Lua continues running..
	--> sdl_mixer gives a C callback -> sdl_mixer module -> Lua call

Now, the callback probably happens in another thread, or otherwise
asynchronously to the main loop, running the Lua stack. How do we deal
with this?

A start to a solution could be organising the way "Lua continues running".

If you're able to switch your current approach to one that runs in brief steps, you're (probably) pretty much nearly there. It certainly makes the (important!) synchronising bit that David mentions fairly trivial.

Then again, I haven't looked at your sdl_mixer code. So I'm not sure how feasible switching is in your situation...

no signature is a signature.