[SDL] Android SDL_RWops safety - how should it be fixed?
masonwheeler at yahoo.com
Sun Apr 8 16:46:24 PDT 2012
Well, the "proper solution" is to fix Android so it isn't limited to only doing I/O on the main thread. That's where the real problem lies. And if you can't do that, I don't know if there is a better workaround. Maybe there's room for improvement in your specific implementation of it, but conceptually I don't think there's a better way.
From: MrJones <contact at eloxoph.com>
To: sdl at lists.libsdl.org
Sent: Sunday, April 8, 2012 1:52 PM
Subject: Re: [SDL] Android SDL_RWops safety - how should it be fixed?
Mason Wheeler wrote:
Well, if this was Delphi, I'd do it with a call to Synchronize. That pushes an event containing a function pointer onto the event queue for the main Application object's poll loop (which runs on the main thread) to pick up and execute the associated function, and the Synchronize call blocks until the main thread is finished with it. Not sure if JNI or the Android NDK has something similar built in, but it wouldn't surprise me.
That was what I am basically doing for application-side fix. Believe me: it is the biggest. hack. ever. Right now I am using mutexes which is probably the wrong tool for the job and making performance a bit worse even, but it doesn't really matter since I think it's the wrong point to fix it anyway - it will never work well that way. Mainly since, obviously, the main thread might have better things to do than read stuff for the sound thread.
Mason Wheeler wrote:
There are two tricky aspects here, though. The first is that trying something like Synchronize when you're already on the main thread can deadlock your program
Oh yes. And finding out and tracing through all the code if you are on the main thread was a HUGE effort and I spend lots of wasted code lines on this.
There should be a proper solution, so a hack as you suggest (and which I implemented in a pretty much similar way I suppose) isn't needed.
My Blog: http://gamedev-couch.blogspot.com/
SDL mailing list
SDL at lists.libsdl.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the SDL