[vlc-devel] [PATCH v2 2/4] macosx: wait until the View is removed from its parent in Close
Steve Lhomme
robux4 at ycbcr.xyz
Tue Nov 3 08:46:45 CET 2020
---
modules/video_output/macosx.m | 22 +++++++++++++++++++++-
1 file changed, 21 insertions(+), 1 deletion(-)
diff --git a/modules/video_output/macosx.m b/modules/video_output/macosx.m
index bcb71579d68..7143c2528fd 100644
--- a/modules/video_output/macosx.m
+++ b/modules/video_output/macosx.m
@@ -46,6 +46,7 @@
#include <vlc_vout_display.h>
#include <vlc_opengl.h>
#include <vlc_dialog.h>
+#include <vlc_threads.h>
#include "opengl/filter_draw.h"
#include "opengl/renderer.h"
#include "opengl/vout_helper.h"
@@ -98,9 +99,12 @@ vlc_module_end ()
vout_display_t *vd;
vout_window_t *window;
BOOL _hasPendingReshape;
+ vlc_sem_t removed;
}
- (void)setVoutWindow:(vout_window_t *)aWindow;
- (void)setVoutDisplay:(vout_display_t *)vd;
+- (void)didMoveToSuperview;
+- (void)waitRemoved;
- (void)setVoutFlushing:(BOOL)flushing;
@end
@@ -303,9 +307,11 @@ static void Close(vout_display_t *vd)
/* release on main thread as explained in Open() */
[viewContainer release];
[glView removeFromSuperview];
- [glView release];
});
+ [glView waitRemoved];
+ [glView release];
+
free (sys);
}
}
@@ -531,8 +537,22 @@ static void OpenglSwap (vlc_gl_t *gl)
[self setFrame:[parentView bounds]];
}
+- (void)didMoveToSuperview:
+{
+ if (superview != nil)
+ vlc_sem_wait(&removed); // not removed anymore
+ else
+ vlc_sem_post(&removed); // removed again
+}
+
+- (void)waitRemoved:
+{
+ vlc_sem_wait(&removed);
+}
+
- (void)setVoutWindow:(vout_window_t *)aWindow
{
+ vlc_sem_init(&removed, 1);
window = aWindow;
}
--
2.26.2
More information about the vlc-devel
mailing list