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

chenjun zjuchenjun at hotmail.com
Thu Feb 1 19:45:46 PST 2007


Hi Ross,
 
Maybe you have misunderstood, In fact my "HasItemForH264" variable is set in another thread - the one that handles your H.264 encoding(I mentioned it 
 
in my code).
 
My problem is "HasItemForH264" variable is set to be non-zero in another thread, but event loop seems not respond immediately, it delay some time ,then
 
implemented "deliverFrame".
 
My purpose is implementing the "deliverFrame" as soon as possible when "HasItemForH264!=0".
 
Thanks for your help :)
 
 
 


Date: Thu, 1 Feb 2007 08:57:20 -0800To: live-devel at ns.live555.comFrom: finlayson at live555.comSubject: Re: [Live-devel] "no-blocking fashion" in doGetNextFrame()



In doGetNextFrame() member fuction of DeviceSource, I want to call "deliverFrame" in a non-blocking fashion, 
I wrote my code (follow the example 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 FinlaysonLive Networks, Inc.http://www.live555.com/
_________________________________________________________________
率先尝试 Windows Live Mail。
http://ideas.live.com/programpage.aspx?versionId=5d21c51a-b161-4314-9b0e-4911fb2b2e6d
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.live555.com/pipermail/live-devel/attachments/20070201/a7034c65/attachment.html 


More information about the live-devel mailing list