[vlc-devel] [PATCH]Win32 screensaver disable change part II

Kaarlo Räihä kaarlo.raiha at gmail.com
Tue May 3 14:15:41 CEST 2011


2011/5/3 Juha Jeronen <juha.jeronen at jyu.fi>

>  Hi,
>
>
> On 05/03/2011 10:20 AM, Kaarlo Räihä wrote:
>
>
>
> 2011/5/2 Rémi Denis-Courmont <remi at remlab.net>
>
>> ----- Message d'origine -----
>> > It isn't perfect code wise, since I have NO clue how to create thread
>> > without parameters using vlc thread functions.
>>
>>  That is impossible. If you do not need any parameter, the convention is
>> to pass NULL. That being said, there is almost always need to pass a
>> parameter, some kind of context.
>>
>> > kill_thread(id)
>>
>> Killing a thread makes no sense. Every thread has to be joined, before the
>> plugin is unloaded and before its context data gets invalidated.
>>
>
>  Problem with join is that 50 seconds long sleep function I have since
> AFAIK join needs selfterminating threads. But in Win32 (according to MSDN)
> you are allowed to use ExitThread or similar function to terminate threads
> since VLC is C code.
>
>
> Suggestion:
>
> - Have an instance data struct for the thread, containing only an exit flag
> (initialized to false in the main thread, just before it starts the new
> thread). Malloc it, and pass a pointer as the thread argument. The flag will
> be used for signaling.
> - When the main thread wants to shut down the screensaver prevention
> thread, it sets the exit flag to true.
> - When the thread notices that its exit flag has been set to true, it
> joins.
> - Finally, we need to take care of the 50-second sleep. How about, instead
> of
>
> for( ; ; )
> {
>     PreventScreensaver();
>     sleep(50);
> }
>
> having
>
> for( ; ; )
> {
>     PreventScreensaver();
>
>     for(int i = 0; i < 100; ++i)
>     {
>         sleep(0.5); /* this is what I meant by pseudocode ;) */
>         if( p_data->b_exited )
>             goto _terminated; /* "doublebreak;" :) */
>     }
> }
>
> _terminated:
> /* ...clean up, join... */
>
>
> This is not ideal, as it relies on polling, but it should get the job done
> without a need to kill the thread from the outside.
>
>  -J
>

If this method is allowed, then I can send patch for this.


>
>
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> http://mailman.videolan.org/listinfo/vlc-devel
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20110503/769e2419/attachment.html>


More information about the vlc-devel mailing list