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 | |
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
-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; | |||
39 | static int dpi; | 39 | static int dpi; |
40 | static int scroll_threshold; | 40 | static int scroll_threshold; |
41 | static struct wakeup lcd_wakeup; | 41 | static struct wakeup lcd_wakeup; |
42 | static struct mutex lcd_mtx; | ||
42 | 43 | ||
43 | void lcd_init_device(void) | 44 | void lcd_init_device(void) |
44 | { | 45 | { |
45 | JNIEnv e = *env_ptr; | 46 | JNIEnv e = *env_ptr; |
46 | wakeup_init(&lcd_wakeup); | 47 | wakeup_init(&lcd_wakeup); |
48 | mutex_init(&lcd_mtx); | ||
47 | RockboxFramebuffer_class = e->FindClass(env_ptr, | 49 | RockboxFramebuffer_class = e->FindClass(env_ptr, |
48 | "org/rockbox/RockboxFramebuffer"); | 50 | "org/rockbox/RockboxFramebuffer"); |
49 | /* instantiate a RockboxFramebuffer instance | 51 | /* instantiate a RockboxFramebuffer instance |
@@ -114,8 +116,10 @@ void lcd_update(void) | |||
114 | /* tell the system we're ready for drawing */ | 116 | /* tell the system we're ready for drawing */ |
115 | if (display_on) | 117 | if (display_on) |
116 | { | 118 | { |
119 | mutex_lock(&lcd_mtx); | ||
117 | (*env_ptr)->CallVoidMethod(env_ptr, RockboxFramebuffer_instance, postInvalidate1); | 120 | (*env_ptr)->CallVoidMethod(env_ptr, RockboxFramebuffer_instance, postInvalidate1); |
118 | wakeup_wait(&lcd_wakeup, TIMEOUT_BLOCK); | 121 | wakeup_wait(&lcd_wakeup, TIMEOUT_BLOCK); |
122 | mutex_unlock(&lcd_mtx); | ||
119 | } | 123 | } |
120 | } | 124 | } |
121 | 125 | ||
@@ -123,9 +127,11 @@ void lcd_update_rect(int x, int y, int width, int height) | |||
123 | { | 127 | { |
124 | if (display_on) | 128 | if (display_on) |
125 | { | 129 | { |
130 | mutex_lock(&lcd_mtx); | ||
126 | (*env_ptr)->CallVoidMethod(env_ptr, RockboxFramebuffer_instance, postInvalidate2, | 131 | (*env_ptr)->CallVoidMethod(env_ptr, RockboxFramebuffer_instance, postInvalidate2, |
127 | (jint)x, (jint)y, (jint)x+width, (jint)y+height); | 132 | (jint)x, (jint)y, (jint)x+width, (jint)y+height); |
128 | wakeup_wait(&lcd_wakeup, TIMEOUT_BLOCK); | 133 | wakeup_wait(&lcd_wakeup, TIMEOUT_BLOCK); |
134 | mutex_unlock(&lcd_mtx); | ||
129 | } | 135 | } |
130 | } | 136 | } |
131 | 137 | ||