Eric,When I trace VLC source codes, I found it hangs at GetMessage, EventThread() in modules/video_output/msw/events.c.
I found that if i do not let Vlc get any message (including Mouse, Keyboard), VLC will "not hang" any more.
Could someone help me? I will appreciate very much.
PS. VLC VERSION: 0.9.8a
Code: Select all
while( vlc_object_alive (p_event) )
{
// Sleep to keep thread from being greedy
Sleep( 20 );
} /* End Main loop */
Code: Select all
#define WM_VLCWND_ASYNC (WM_USER + 5)
Code: Select all
void* EventThread( vlc_object_t *p_this )
{
event_thread_t *p_event = (event_thread_t *)p_this;
MSG msg;
POINT old_mouse_pos = {0,0}, mouse_pos;
vlc_value_t val;
unsigned int i_width, i_height, i_x, i_y;
HMODULE hkernel32;
/* Initialisation */
p_event->p_vout->pf_control = Control;
p_event->b_ready = FALSE;
p_event->p_vout->p_sys->hparent =
vout_RequestWindow( p_event->p_vout, &p_event->p_vout->p_sys->i_window_x,
&p_event->p_vout->p_sys->i_window_y,
&p_event->p_vout->p_sys->i_window_width,
&p_event->p_vout->p_sys->i_window_height );
#ifndef UNDER_CE
/* Set power management stuff */
if( (hkernel32 = GetModuleHandle( _T("KERNEL32") ) ) )
{
ULONG (WINAPI* OurSetThreadExecutionState)( ULONG );
OurSetThreadExecutionState = (ULONG (WINAPI*)( ULONG ))
GetProcAddress( hkernel32, _T("SetThreadExecutionState") );
if( OurSetThreadExecutionState )
/* Prevent monitor from powering off */
OurSetThreadExecutionState( ES_DISPLAY_REQUIRED | ES_CONTINUOUS );
else
msg_Dbg( p_event, "no support for SetThreadExecutionState()" );
}
#endif
if ( p_event->p_vout->p_sys->hparent )
{
PostMessage( p_event->p_vout->p_sys->hparent,
WM_VLCWND_ASYNC,
(WPARAM) &CreateChildWindowsProc,
(LPARAM) p_event );
while ( !p_event->b_ready )
{
msleep( 20000 );
}
/* Signal the creation of the window */
vlc_thread_ready( p_event );
while( vlc_object_alive (p_event) )
{
msleep( 50000 );
}
/* clear the changes formerly signaled */
p_event->p_vout->p_sys->i_changes = 0;
SetWindowLongPtr( p_event->p_vout->p_sys->hwnd, GWLP_USERDATA, NULL );
SetWindowLongPtr( p_event->p_vout->p_sys->hvideownd, GWLP_USERDATA, NULL );
SetWindowLongPtr( p_event->p_vout->p_sys->hparent, GWLP_USERDATA, NULL );
PostMessage( p_event->p_vout->p_sys->hparent,
WM_VLCWND_ASYNC,
(WPARAM) &DeleteChildWindowsProc,
(LPARAM) p_event->p_vout->p_sys->hwnd );
p_event->p_vout->p_sys->hwnd = NULL;
if( p_event->p_vout->p_sys->hfswnd )
{
PostMessage( p_event->p_vout->p_sys->hparent,
WM_VLCWND_ASYNC,
(WPARAM) &DeleteChildWindowsProc,
(LPARAM) p_event->p_vout->p_sys->hfswnd );
p_event->p_vout->p_sys->hfswnd = NULL;
}
if( p_event->p_vout->p_sys->hparent )
vout_ReleaseWindow( p_event->p_vout, (void *)p_event->p_vout->p_sys->hparent );
}
else
{
if( DirectXCreateWindow( p_event->p_vout ) )
p_event->b_dead = true;
/* Signal the creation of the window */
vlc_thread_ready( p_event );
/* Main loop */
/* GetMessage will sleep if there's no message in the queue */
while( vlc_object_alive (p_event) && GetMessage( &msg, 0, 0, 0 ) )
...
Code: Select all
/*****************************************************************************
* CreateChildWindowsProc: callback procedure to setup windows in case of
* specified parent window.
*****************************************************************************
* We need to create child windows in the same thread as parent to ensure
* we don't get arbitrary locks when stopping video threads.
*****************************************************************************/
static long FAR PASCAL CreateChildWindowsProc( HWND hWnd, UINT Msg, ULONG_PTR dwData, LRESULT lResult )
{
event_thread_t * p_event = (event_thread_t *) dwData;
DirectXCreateWindow( p_event->p_vout );
p_event->b_ready = TRUE;
return 0;
}
/*****************************************************************************
* DeleteChildWindowsProc: callback procedure to remove windows.
*****************************************************************************
* We need to destroy child windows in the same thread as parent to ensure
* we don't get arbitrary locks when stopping video threads.
*****************************************************************************/
static long FAR PASCAL DeleteChildWindowsProc( HWND hWnd, UINT Msg, ULONG_PTR dwData, LRESULT lResult )
{
HWND myHwnd = (HWND) dwData;
if( myHwnd && IsWindow( myHwnd ) )
{
DestroyWindow( myHwnd );
}
return 0;
}
Code: Select all
LRESULT CVLCTest::OnVlcAsync(WPARAM wParam, LPARAM lParam)
{
SENDASYNCPROC proc_async = (SENDASYNCPROC) wParam;
proc_async(0, 0, (ULONG_PTR)lParam, 0);
return 0;
}
Return to “Development around libVLC”
Users browsing this forum: No registered users and 56 guests