<br><br><div class="gmail_quote">2011/5/3 Juha Jeronen <span dir="ltr"><<a href="mailto:juha.jeronen@jyu.fi">juha.jeronen@jyu.fi</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div text="#000000" bgcolor="#ffffff">
Hi,<div class="im"><br>
<br>
On 05/03/2011 10:20 AM, Kaarlo Räihä wrote:
<blockquote type="cite"><br>
<br>
<div class="gmail_quote">2011/5/2 Rémi Denis-Courmont <span dir="ltr"><<a href="mailto:remi@remlab.net" target="_blank">remi@remlab.net</a>></span><br>
<blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204, 204, 204);padding-left:1ex">
----- Message d'origine -----<br>
<div>> It isn't perfect code wise, since I have
NO clue how to create thread<br>
> without parameters using vlc thread functions.<br>
<br>
</div>
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.<br>
<br>
> kill_thread(id)<br>
<br>
Killing a thread makes no sense. Every thread has to be
joined, before the plugin is unloaded and before its context
data gets invalidated.<br>
</blockquote>
<div><br>
</div>
<div>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. <br>
</div>
</div>
</blockquote>
<br></div>
Suggestion:<br>
<br>
- 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.<br>
- When the main thread wants to shut down the screensaver prevention
thread, it sets the exit flag to true.<br>
- When the thread notices that its exit flag has been set to true,
it joins.<br>
- Finally, we need to take care of the 50-second sleep. How about,
instead of<br>
<br>
for( ; ; )<br>
{<br>
PreventScreensaver();<br>
sleep(50);<br>
}<br>
<br>
having<br>
<br>
for( ; ; )<br>
{<br>
PreventScreensaver();<br>
<br>
for(int i = 0; i < 100; ++i)<br>
{<br>
sleep(0.5); /* this is what I meant by pseudocode ;) */<br>
if( p_data->b_exited )<br>
goto _terminated; /* "doublebreak;" :) */<br>
}<br>
}<br>
<br>
_terminated:<br>
/* ...clean up, join... */<br>
<br>
<br>
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.<br>
<br>
-J<br></div></blockquote><div><br></div><div>If this method is allowed, then I can send patch for this.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div text="#000000" bgcolor="#ffffff">
<br>
</div>
<br>_______________________________________________<br>
vlc-devel mailing list<br>
To unsubscribe or modify your subscription options:<br>
<a href="http://mailman.videolan.org/listinfo/vlc-devel" target="_blank">http://mailman.videolan.org/listinfo/vlc-devel</a><br>
<br></blockquote></div><br>