move SYNC_PAINT define to right place
[enigma2.git] / lib / gdi / grc.cpp
index de6761e810d4f0f335a4f338c95489c6e9339e53..19a32b62b5c379ea095089c4131ec90b6564c450 100644 (file)
@@ -1,10 +1,4 @@
-// for debugging use:
-// #define SYNC_PAINT
 #include <unistd.h>
-#ifndef SYNC_PAINT
-#include <pthread.h>
-#endif
-
 #include <lib/gdi/grc.h>
 #include <lib/gdi/font.h>
 #include <lib/base/init.h>
@@ -84,10 +78,10 @@ void gRC::submit(const gOpcode &o)
                queue[wp++]=o;
                if ( wp == MAXSIZE )
                        wp = 0;
-               pthread_mutex_unlock(&mutex);
                if (o.opcode==gOpcode::flush||o.opcode==gOpcode::shutdown||o.opcode==gOpcode::notify)
 #ifndef SYNC_PAINT
                        pthread_cond_signal(&cond);  // wakeup gdi thread
+               pthread_mutex_unlock(&mutex);
 #else
                        thread(); // paint
 #endif
@@ -105,13 +99,17 @@ void *gRC::thread()
        while (rp != wp)
        {
 #endif
+#ifndef SYNC_PAINT
                pthread_mutex_lock(&mutex);
+#endif
                if ( rp != wp )
                {
                        gOpcode o(queue[rp++]);
                        if ( rp == MAXSIZE )
                                rp=0;
+#ifndef SYNC_PAINT
                        pthread_mutex_unlock(&mutex);
+#endif
                        if (o.opcode==gOpcode::shutdown)
                                break;
                        else if (o.opcode==gOpcode::notify)
@@ -128,6 +126,7 @@ void *gRC::thread()
                        }
 #ifndef SYNC_PAINT
                        pthread_cond_wait(&cond, &mutex);
+                       pthread_mutex_unlock(&mutex);
 #endif
                }
        }