summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--TODO4
-rw-r--r--examples/threaded15
2 files changed, 11 insertions, 8 deletions
diff --git a/TODO b/TODO
index f511f29..cf27481 100644
--- a/TODO
+++ b/TODO
@@ -10,8 +10,4 @@ Medium priority:
Low priority:
Add wayland support
Add mir support
- Add DRM (Direct Rendering Manager) support
- It looks like this can be used to get/set the gamma ramps
- without a display server running. It can also get physical
- size and probably other data currently support under X.
diff --git a/examples/threaded b/examples/threaded
index 7b37cce..e70d33e 100644
--- a/examples/threaded
+++ b/examples/threaded
@@ -22,7 +22,7 @@ gamma_green = [1.15, 1.16]
gamma_blue = [1.11, 1.10]
-# Make colour curves thread local
+# Make colour curves thread local.
class threadlocal:
def __init__(self, obj):
self.default = obj
@@ -56,19 +56,24 @@ r_curve = threadlocal([i / (i_size - 1) for i in range(i_size)])
g_curve = threadlocal([i / (i_size - 1) for i in range(i_size)])
b_curve = threadlocal([i / (i_size - 1) for i in range(i_size)])
-## cmf_10deg uses non-thread safe cache, run once in advance so it is not done by the threads
+## cmf_10deg uses non-thread safe cache, run once in advance so it is not done by the threads.
cmf_10deg(0)
-# Thread synchronisation barrier
+# Thread synchronisation barrier.
barrier = threading.Barrier(len(gamma_red) + 1)
# Help functions for colour interpolation.
interpol, purify = None, None
-# Parameters in `periodically`
+# Parameters in `periodically`.
fade_ = None
+# randr is not threadsafe, and absolutely not if you have multiple screens.
+# This semaphore is used to make sure that two threads are not accessing randr at the same time.
+flush_semaphore = threading.Semaphore()
+
+
def adjust(m):
'''
Adjust monitor colours
@@ -97,7 +102,9 @@ def adjust(m):
gamma(gamma_red[m], gamma_green[m], gamma_blue[m])
# Flush settings to monitor.
+ flush_semaphore.acquire()
randr(m)
+ flush_semaphore.release()
# Signal thread completion.
barrier.wait()