summaryrefslogtreecommitdiffstats
path: root/video/out/cocoa_common.h
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-05-13 22:00:34 +0200
committerwm4 <wm4@nowhere>2015-05-13 22:00:34 +0200
commitd89eb74cb757ab3bc864a7cd7fc05e3c96104ac9 (patch)
tree74aaf9e064dfdaab375615c485a6fabfdc1f125c /video/out/cocoa_common.h
parent7e21f6fd0049e14e384758237fcfe3ef03d93d1f (diff)
downloadmpv-d89eb74cb757ab3bc864a7cd7fc05e3c96104ac9.tar.bz2
mpv-d89eb74cb757ab3bc864a7cd7fc05e3c96104ac9.tar.xz
cocoa: redo synchronization
Before this change, Cocoa state was accessed from both the VO and the Cocoa main thread. This was probably not a good idea. There was some locking as well as implicit synchronization using the dispatch mechanism, but it wasn't watertight. Change this completely. Now Cocoa things are always accessed from the main thread only. The old mutex falls away, as well as the vo_cocoa_set_current_context() function, which implicitly used the lock to coordinate VO accesses. With the new code, the VO thread generally has to wait for the main thread, while the main thread never waits for the VO and rarely accesses it. Fortunately, this is rather straight forward, and most of this is achieved by making vo_cocoa_control() run on the main thread. The logic of the code does generally not change. Some aspects are trickier. Apparently we can't access the NSOpenGLContext from the VO thread, because this object is not thread- safe. We use some CGLContextObj functions instead, such as for making the context current and swapping the buffers.
Diffstat (limited to 'video/out/cocoa_common.h')
-rw-r--r--video/out/cocoa_common.h12
1 files changed, 6 insertions, 6 deletions
diff --git a/video/out/cocoa_common.h b/video/out/cocoa_common.h
index 9adae029c7..0427fc9de5 100644
--- a/video/out/cocoa_common.h
+++ b/video/out/cocoa_common.h
@@ -20,8 +20,11 @@
#ifndef MPLAYER_COCOA_COMMON_H
#define MPLAYER_COCOA_COMMON_H
-#include "vo.h"
+#include <stdbool.h>
+#include <stdint.h>
+#include <OpenGL/OpenGL.h>
+struct vo;
struct vo_cocoa_state;
int vo_cocoa_init(struct vo *vo);
@@ -29,12 +32,9 @@ void vo_cocoa_uninit(struct vo *vo);
int vo_cocoa_config_window(struct vo *vo, uint32_t flags);
-void vo_cocoa_set_current_context(struct vo *vo, bool current);
-void vo_cocoa_swap_buffers(struct vo *vo);
-int vo_cocoa_check_events(struct vo *vo);
int vo_cocoa_control(struct vo *vo, int *events, int request, void *arg);
-void vo_cocoa_create_nsgl_ctx(struct vo *vo, void *ctx);
-void vo_cocoa_release_nsgl_ctx(struct vo *vo);
+void vo_cocoa_swap_buffers(struct vo *vo);
+void vo_cocoa_set_opengl_ctx(struct vo *vo, CGLContextObj ctx);
#endif /* MPLAYER_COCOA_COMMON_H */