]> git.sesse.net Git - nageru/blobdiff - ref_counted_gl_sync.h
Support audio-only FFmpeg inputs. Somewhat wonky, though.
[nageru] / ref_counted_gl_sync.h
index 5e23752dd2c3ea80e75321cc6e4453e0f5d7e884..8b6db680a2c31ffa66ce36c799f1475769937033 100644 (file)
@@ -6,8 +6,9 @@
 // places. (We could set two fences at the same time, but they are not an
 // unlimited hardware resource, so it would be a bit wasteful.)
 
-#include <GL/gl.h>
+#include <epoxy/gl.h>
 #include <memory>
+#include <mutex>
 
 typedef std::shared_ptr<__GLsync> RefCountedGLsyncBase;
 
@@ -16,7 +17,23 @@ public:
        RefCountedGLsync() {}
 
        RefCountedGLsync(GLenum condition, GLbitfield flags) 
-               : RefCountedGLsyncBase(glFenceSync(condition, flags), glDeleteSync) {}
+               : RefCountedGLsyncBase(locked_glFenceSync(condition, flags), glDeleteSync) {}
+
+private:
+       // These are to work around apitrace bug #446.
+       static GLsync locked_glFenceSync(GLenum condition, GLbitfield flags)
+       {
+               std::lock_guard<std::mutex> lock(fence_lock);
+               return glFenceSync(condition, flags);
+       }
+
+       static void locked_glDeleteSync(GLsync sync)
+       {
+               std::lock_guard<std::mutex> lock(fence_lock);
+               glDeleteSync(sync);
+       }
+
+       static std::mutex fence_lock;
 };
 
 #endif  // !defined(_REF_COUNTED_GL_SYNC_H)