[vlc-devel] [PATCH] Global Hotkeys for windows
Laurent Aimar
fenrir at via.ecp.fr
Mon Jan 12 19:52:38 CET 2009
On Mon, Jan 12, 2009, Hannes Domani wrote:
> > > + i_key = config_GetInt( p_intf, psz_hotkey );
> > I think var_CreateGetInteger is prefered here.
> why is the Create needed?
Mmh, it is not done in the standard hotkey module, so for the time
being, you should probably keep config_GetInt, sorry.
> > > + /* Main loop */
> > > + while( 1 )
> > > + {
> > > + if( !PeekMessage( &message, NULL, 0, 0, 0
> > ) )
> > > + {
> > > + vlc_restorecancel( canc );
> > > +
> > > + /* Sleep a bit */
> > > + msleep( INTF_IDLE_SLEEP );
> > > +
> > > + canc = vlc_savecancel();
> > > +
> > > + continue;
> > > + }
> > > +
> > > + if( !GetMessage( &message, NULL, 0, 0 ) )
> > break;
> > > + DispatchMessage( &message );
> > > + }
> > Mhh I really don't like the msleep part (useless
> > thread wakeup).
> >
> > Would there be a way from another thread to make
> > GetMessage return
> > a special value, or a special indentifiable message or at
> > least to stop waiting ?
> >
> > If so, a clean way can be found:
> > - Open create the thread itself and does *not* set pf_run.
> > - Close will do what is needed for the GetMessage to
> > behave as above, and will
> > terminate the thread.
> > - RunIntf will then be changed to have something like:
> > for( ;; )
> > {
> > GetMessage();
> > if( condition in which we terminate )
> > break;
> > DispatchMessage();
> > }
> i think that's doable (is this an english word?). if you could point me to a file where thread creation and closure was used directly (just for reference).
You could do:
vlc_thread_t thread;
if( vlc_clone( &thread, Thread, p_intf, VLC_THREAD_PRIORITY_LOW ) )
{
error path;
}
with
static void *Thread ( void * );
to create a new thread that will launch Thread function (the old RuntIntf).
and
vlc_join (thread, NULL);
to join the thread in the Close function.
As you don't have cancellation point, you cannot use vlc_cancel, and so you need
to have a way to tell the thread to return before calling it.
(Do not forget the vlc_savecancel/vlc_restorecancel calls in Thread().
--
fenrir
More information about the vlc-devel
mailing list