[vlc-devel] [PATCH v2 2/4] macosx: wait until the View is removed from its parent in Close

Marvin Scholz epirat07 at gmail.com
Tue Nov 3 10:50:20 CET 2020


Hi,

On 3 Nov 2020, at 8:46, Steve Lhomme wrote:

> ---
>  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);
> +}
> +

Won't this deadlock, just like using a dispatch sync would deadlock?
As during close vlc blocks the main thread waiting for the Close to finish,
but close waits for an action that needs to happen on the main thread,
which can never happen, leading to waiting forever on the semaphore.

>  - (void)setVoutWindow:(vout_window_t *)aWindow
>  {
> +    vlc_sem_init(&removed, 1);
>      window = aWindow;
>  }
>
> -- 
> 2.26.2
>
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel


More information about the vlc-devel mailing list