diff options
author | Thomas Martitz <kugel@rockbox.org> | 2010-12-13 02:01:47 +0000 |
---|---|---|
committer | Thomas Martitz <kugel@rockbox.org> | 2010-12-13 02:01:47 +0000 |
commit | 36da28bbc7da550b61bac22fd5db7348142d72f3 (patch) | |
tree | 5e77fa706d896dbcb58fb02a685f94e0b33f1d80 /firmware/target/hosted/android | |
parent | 866a822ac615e85bbcb6315c99ce502569f2a3ae (diff) | |
download | rockbox-36da28bbc7da550b61bac22fd5db7348142d72f3.tar.gz rockbox-36da28bbc7da550b61bac22fd5db7348142d72f3.zip |
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
Diffstat (limited to 'firmware/target/hosted/android')
-rw-r--r-- | firmware/target/hosted/android/lcd-android.c | 6 |
1 files changed, 6 insertions, 0 deletions
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); } } |