From d9aa5ddb7a8f7324e4281e3f35fbc108db605c9c Mon Sep 17 00:00:00 2001 From: Gildas Bazin Date: Mon, 29 Nov 2004 15:38:01 +0000 Subject: [PATCH] * mozilla/vlcshell.cpp: nasty hack on win32 to avoid a deadlock on plugin destruction. --- mozilla/vlcshell.cpp | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/mozilla/vlcshell.cpp b/mozilla/vlcshell.cpp index 62a021c29a..03760362d7 100644 --- a/mozilla/vlcshell.cpp +++ b/mozilla/vlcshell.cpp @@ -414,6 +414,37 @@ NPError NPP_New( NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc, return NPERR_NO_ERROR; } +#ifdef XP_WIN +/* This is really ugly but there is a deadlock when stopping a stream + * (in VLC_CleanUp()) because the video output is a child of the drawable but + * is in a different thread. */ +static void HackStopVout( VlcPlugin* p_plugin ) +{ + MSG msg; + HWND hwnd; + vlc_value_t value; + + VLC_VariableGet( p_plugin->i_vlc, "drawable", &value ); + + hwnd = FindWindowEx( (HWND)value.i_int, 0, 0, 0 ); + if( !hwnd ) return; + + PostMessage( hwnd, WM_CLOSE, 0, 0 ); + + do + { + fprintf( stderr, "FindWindow: %p\n", hwnd ); + while( PeekMessage( &msg, (HWND)value.i_int, 0, 0, PM_REMOVE ) ) + { + TranslateMessage(&msg); + DispatchMessage(&msg); + } + if( FindWindowEx( (HWND)value.i_int, 0, 0, 0 ) ) Sleep( 10 ); + } + while( (hwnd = FindWindowEx( (HWND)value.i_int, 0, 0, 0 )) ); +} +#endif + NPError NPP_Destroy( NPP instance, NPSavedData** save ) { if( instance == NULL ) @@ -428,6 +459,9 @@ NPError NPP_Destroy( NPP instance, NPSavedData** save ) if( p_plugin->i_vlc ) { #if USE_LIBVLC +# ifdef XP_WIN + HackStopVout( p_plugin ); +# endif VLC_CleanUp( p_plugin->i_vlc ); VLC_Destroy( p_plugin->i_vlc ); #endif -- 2.39.2