[vlc-devel] [PATCH] Global Hotkeys for windows
Hannes Domani
ssbssa at yahoo.de
Tue Jan 13 08:23:34 CET 2009
--- Laurent Aimar <fenrir at via.ecp.fr> wrote on Mo, 12.1.2009:
> Von: Laurent Aimar <fenrir at via.ecp.fr>
> Betreff: Re: [vlc-devel] [PATCH] Global Hotkeys for windows
> An: "Mailing list for VLC media player developers" <vlc-devel at videolan.org>
> Datum: Montag, 12. Januar 2009, 19:52
> 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.
ok
> > > > + /* 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.
ok
> 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.
still ok
> (Do not forget the vlc_savecancel/vlc_restorecancel calls
> in Thread().
i don't really get why those are still necessary if i have another way to tell the thread to return.
regards
Domani Hannes
More information about the vlc-devel
mailing list