tizen/src/maru_sdl.c: Fix improper operations with SDL surfaces.
authorEvgeny Voevodin <e.voevodin@samsung.com>
Wed, 11 Jul 2012 10:09:23 +0000 (14:09 +0400)
committerEvgeny Voevodin <e.voevodin@samsung.com>
Fri, 13 Jul 2012 05:28:00 +0000 (09:28 +0400)
commit05a41aaa61593a6fbc7d6e7ffde2b62b9f1e1d20
treeb5d64a597ed83488b1c0095c736f5188f64e8436
parent4e678ff1a5e4334114f050bfc9855b02eb4b0a0b
tizen/src/maru_sdl.c: Fix improper operations with SDL surfaces.

The bug is that vga_hw_update() invokes dpy_update() where
qemu_ds_update() is called.
qemu_ds_update() sends a signal to thread run_qemu_update() waiting
to be released and to invoke qemu_update().
After this happens there are two ways possible:
1. run_qemu_update() is released, got mutex and qemu_update() is called.
   Simultaneously qemu_ds_refresh() is waiting on the mutex to perform
   SDL_SetVideoMode(). This is most common way.
2. If we unlucky,
   vga_hw_update() returns and qemu_ds_refresh() gets mutex before
   run_qemu_update() is released. In this way SDL_SetVideoMode() is called
   before qemu_update() is invoked. This leads qemu_update() to operate on
   invalidated surface_qemu.
So, to solve this problem we can add a flag indicating that qemu_update()
finished it's work and that we free to invoke SDL_SetVideoMode().
Or we can simply move vga_hw_update() invocation after SDL_SetVideoMode() call.
We chose the second variant as more efficient.

Signed-off-by: Evgeny Voevodin <e.voevodin@samsung.com>
tizen/src/maru_sdl.c