<!doctype html public "-//W3C//DTD W3 HTML//EN">
<html><head><style type="text/css"><!--
blockquote, dl, ul, ol, li { padding-top: 0 ; padding-bottom: 0 }
 --></style><title>Re: [Live-devel] &quot;no-blocking fashion&quot; in
doGetNextFrame()</title></head><body>
<blockquote type="cite" cite>In doGetNextFrame() member fuction of
DeviceSource, I want to call &quot;deliverFrame&quot; in a
non-blocking fashion,<br>
&nbsp;</blockquote>
<blockquote type="cite" cite>I wrote my code <a
href=
"http://lists.live555.com/pipermail/live-devel/2005-September/003276.html"
>(follow the example</a> <a
href=
"http://lists.live555.com/pipermail/live-devel/2005-September/003276.html.)"
><font
color="#800080"><u
>http://lists.live555.com/pipermail/live-devel/2005-September/003276.<span
></span>html</u></font></a>.)<br>
&nbsp;<br>
It works,but another problem came out: it returns immediately when
&quot;watchVarible==0&quot;(no data is currntly available),<br>
&nbsp;<br>
but it still wait&nbsp;a long time&nbsp;even &quot;watchVarible&quot;
already became non-zero.<br>
&nbsp;<br>
My purpose is implementing the &quot;deliverFrame&quot; as soon as
possible when &quot;watchVarible!=0&quot;.<br>
&nbsp;<br>
Could anyone help me? Thanks very much!<br>
&nbsp;<br>
Here is my code:<br>
&nbsp;<br>
void DeviceSource::doGetNextFrame()<br>
&nbsp;{<br>
&nbsp;<br>
envforH264-&gt;taskScheduler().doEventLoop(HasItemForH264);&nbsp;//Ha<span
></span>sItemForH264 is set non-zero&nbsp;in another thread&nbsp;after
it&nbsp;filled the buffer&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; deliverFrame();</blockquote>
<blockquote type="cite" cite>&nbsp;&nbsp;}</blockquote>
<div><br></div>
<div>The problem with this is that - if no new data is currently
available - you will be executing the event loop forever, but the
&quot;HasItemForH264&quot; will never get set, because nothing will
ever call &quot;deliverFrame()&quot;.</div>
<div><br></div>
<div>Instead, the solution is for your *other* thread - the one that
handles your H.264 encoding - to be the one that sets the
&quot;HasItemForH264&quot; variable.</div>
<div><br></div>
<blockquote type="cite" cite>&nbsp;&nbsp; usleep(100);</blockquote>
<div><br></div>
<div>Don't do this - it will delay the whole application for 100ms,
and nothing else will get done during this time.</div>
<x-sigsep><pre>-- 
</pre></x-sigsep>
<div><br>
Ross Finlayson<br>
Live Networks, Inc.<br>
http://www.live555.com/</div>
</body>
</html>