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

chenjun zjuchenjun at hotmail.com
Thu Feb 1 04:12:31 PST 2007


Hi,
 
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();  }
 
 
void  DeviceSource::deliverFrame(){    if (!isCurrentlyAwaitingData()) return; // we're not ready for the data yet
 
pthread_mutex_lock(mutexforH264);
  if(*HasItemForH264==99) {
          fFrameSize=*LengthForH264;         //LengthForH264 is defined in another thread             if (fFrameSize > fMaxSize) {   fNumTruncatedBytes = fFrameSize - fMaxSize;   fFrameSize = fMaxSize;    }
          memcpy(fTo, BufferForH264, fFrameSize);     //BufferForH264 is defined in another thread        * HasItemForH264=0;
    
  } pthread_mutex_unlock(mutexforH264);        usleep(100);
   // After delivering the data, inform the reader that it is now available:  
FramedSource::afterGetting(this);  printf ("deliverFrame() is end !\n");}
 
_________________________________________________________________
率先尝试 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/70a10a79/attachment.html 


More information about the live-devel mailing list