forked from len0rd/rockbox
Android: Protect lcd updates with a mutex.
The scrolling engine could lock out the main thread which may be waiting for its update to finish (wakeups are not reentrant). git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28821 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
866a822ac6
commit
36da28bbc7
1 changed files with 6 additions and 0 deletions
|
@ -39,11 +39,13 @@ static bool display_on;
|
||||||
static int dpi;
|
static int dpi;
|
||||||
static int scroll_threshold;
|
static int scroll_threshold;
|
||||||
static struct wakeup lcd_wakeup;
|
static struct wakeup lcd_wakeup;
|
||||||
|
static struct mutex lcd_mtx;
|
||||||
|
|
||||||
void lcd_init_device(void)
|
void lcd_init_device(void)
|
||||||
{
|
{
|
||||||
JNIEnv e = *env_ptr;
|
JNIEnv e = *env_ptr;
|
||||||
wakeup_init(&lcd_wakeup);
|
wakeup_init(&lcd_wakeup);
|
||||||
|
mutex_init(&lcd_mtx);
|
||||||
RockboxFramebuffer_class = e->FindClass(env_ptr,
|
RockboxFramebuffer_class = e->FindClass(env_ptr,
|
||||||
"org/rockbox/RockboxFramebuffer");
|
"org/rockbox/RockboxFramebuffer");
|
||||||
/* instantiate a RockboxFramebuffer instance
|
/* instantiate a RockboxFramebuffer instance
|
||||||
|
@ -114,8 +116,10 @@ void lcd_update(void)
|
||||||
/* tell the system we're ready for drawing */
|
/* tell the system we're ready for drawing */
|
||||||
if (display_on)
|
if (display_on)
|
||||||
{
|
{
|
||||||
|
mutex_lock(&lcd_mtx);
|
||||||
(*env_ptr)->CallVoidMethod(env_ptr, RockboxFramebuffer_instance, postInvalidate1);
|
(*env_ptr)->CallVoidMethod(env_ptr, RockboxFramebuffer_instance, postInvalidate1);
|
||||||
wakeup_wait(&lcd_wakeup, TIMEOUT_BLOCK);
|
wakeup_wait(&lcd_wakeup, TIMEOUT_BLOCK);
|
||||||
|
mutex_unlock(&lcd_mtx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,9 +127,11 @@ void lcd_update_rect(int x, int y, int width, int height)
|
||||||
{
|
{
|
||||||
if (display_on)
|
if (display_on)
|
||||||
{
|
{
|
||||||
|
mutex_lock(&lcd_mtx);
|
||||||
(*env_ptr)->CallVoidMethod(env_ptr, RockboxFramebuffer_instance, postInvalidate2,
|
(*env_ptr)->CallVoidMethod(env_ptr, RockboxFramebuffer_instance, postInvalidate2,
|
||||||
(jint)x, (jint)y, (jint)x+width, (jint)y+height);
|
(jint)x, (jint)y, (jint)x+width, (jint)y+height);
|
||||||
wakeup_wait(&lcd_wakeup, TIMEOUT_BLOCK);
|
wakeup_wait(&lcd_wakeup, TIMEOUT_BLOCK);
|
||||||
|
mutex_unlock(&lcd_mtx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue