From 36da28bbc7da550b61bac22fd5db7348142d72f3 Mon Sep 17 00:00:00 2001 From: Thomas Martitz Date: Mon, 13 Dec 2010 02:01:47 +0000 Subject: 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 --- firmware/target/hosted/android/lcd-android.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'firmware/target/hosted/android') diff --git a/firmware/target/hosted/android/lcd-android.c b/firmware/target/hosted/android/lcd-android.c index 2bc6d04b9e..92e8f5b96f 100644 --- a/firmware/target/hosted/android/lcd-android.c +++ b/firmware/target/hosted/android/lcd-android.c @@ -39,11 +39,13 @@ static bool display_on; static int dpi; static int scroll_threshold; static struct wakeup lcd_wakeup; +static struct mutex lcd_mtx; void lcd_init_device(void) { JNIEnv e = *env_ptr; wakeup_init(&lcd_wakeup); + mutex_init(&lcd_mtx); RockboxFramebuffer_class = e->FindClass(env_ptr, "org/rockbox/RockboxFramebuffer"); /* instantiate a RockboxFramebuffer instance @@ -114,8 +116,10 @@ void lcd_update(void) /* tell the system we're ready for drawing */ if (display_on) { + mutex_lock(&lcd_mtx); (*env_ptr)->CallVoidMethod(env_ptr, RockboxFramebuffer_instance, postInvalidate1); 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) { + mutex_lock(&lcd_mtx); (*env_ptr)->CallVoidMethod(env_ptr, RockboxFramebuffer_instance, postInvalidate2, (jint)x, (jint)y, (jint)x+width, (jint)y+height); wakeup_wait(&lcd_wakeup, TIMEOUT_BLOCK); + mutex_unlock(&lcd_mtx); } } -- cgit v1.2.3