[hatari-devel] missing SDL_Lock in png snapshot ?
Eero Tamminen
eerot at users.berlios.de
Thu Sep 24 22:05:08 CEST 2009
Hi,
On Thursday 24 September 2009, npomarede at corp.free.fr wrote:
> looking at the png screenshot's code, I see a call to SDL_UnlockSurface
> after processing each row, but I don't see the corresponding
> SDL_LockSurface.
Thanks, fixed.
> Am I missing something or is this really an (harmless) error?
Doesn't seem to have done any harm, but according to SDL documentation
Un/LockSurface() should be used.
It's possible that with current Hatari SDL surfaces locking isn't needed
(not HW surfaces) and that's why it's harmless.
> Why is a lock required for each row, would it be enough to
> lock at start and unlock when whole screen was saved as png ?
According to SDL documentation:
http://www.libsdl.org/docs/html/sdllocksurface.html
Locks should be released before doing any syscalls:
"No operating system or library calls should be made between lock/unlock
pairs, as critical system locks may be held during this time."
I would assume that libpng uses just write() which is safe even in
signal context (or fwrite() which isn't safe in signal context).
> Eero, any idea ? (I think you're the one who wrote png support)
You could ask on the SDL mailing list why Unlocking is needed for
syscalls.
Maybe it's important on Windows? Or when using OpenGL?
- Eero
More information about the hatari-devel
mailing list