[Live-devel] "no-blocking fashion" in doGetNextFrame()

Ross Finlayson finlayson at live555.com
Thu Feb 1 08:57:20 PST 2007


>In doGetNextFrame() member fuction of DeviceSource, I want to call 
>"deliverFrame" in a non-blocking fashion,
>
>I wrote my code 
><http://lists.live555.com/pipermail/live-devel/2005-September/003276.html>(follow 
>the example 
><http://lists.live555.com/pipermail/live-devel/2005-September/003276.html.)>http://lists.live555.com/pipermail/live-devel/2005-September/003276.html.)
>
>It works,but another problem came out: it returns immediately when 
>"watchVarible==0"(no data is currntly available),
>
>but it still wait a long time even "watchVarible" already became non-zero.
>
>My purpose is implementing the "deliverFrame" as soon as possible 
>when "watchVarible!=0".
>
>Could anyone help me? Thanks very much!
>
>Here is my code:
>
>void DeviceSource::doGetNextFrame()
>  {
>
>envforH264->taskScheduler().doEventLoop(HasItemForH264); //HasItemForH264 
>is set non-zero in another thread after it filled the buffer      
>
>       deliverFrame();
>   }

The problem with this is that - if no new data is currently available 
- you will be executing the event loop forever, but the 
"HasItemForH264" will never get set, because nothing will ever call 
"deliverFrame()".

Instead, the solution is for your *other* thread - the one that 
handles your H.264 encoding - to be the one that sets the 
"HasItemForH264" variable.

>    usleep(100);

Don't do this - it will delay the whole application for 100ms, and 
nothing else will get done during this time.
-- 

Ross Finlayson
Live Networks, Inc.
http://www.live555.com/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.live555.com/pipermail/live-devel/attachments/20070201/5d7a4497/attachment.html 


More information about the live-devel mailing list