I've been playing around with using avirec for recording TV shows, but
it had a nasty habit of dropping the first 6-8 frames when recording at
640x480, and the first 3-4 when recording at lower resolutions.
I made this patch which seems to fix this problem (consistently drops 1
frame at the start of recording, can't seem to get rid of that one). It
simply blocks all the threads until everything is created and ready to
go, then sends a signal to them all to start up (and sets the starttime
immediately prior to doing so).
This patch is to capproc.cpp, and should also improve the performance of
avicap as well.
-Dave
[EMAIL PROTECTED]
25a26,41
>
> /*
> Construction delay from the creation of the threads causes sync loss at the start.
> These mutexes are used to allow all the processes to start in a synchronized
>fashion.
> */
> pthread_mutex_t syncmut = PTHREAD_MUTEX_INITIALIZER;
> pthread_cond_t synccond = PTHREAD_COND_INITIALIZER;
> int synccount = 0;
>
> void syncBlock() {
> pthread_mutex_lock(&syncmut);
> synccount++; // so we know when all threads done
> pthread_cond_wait(&synccond, &syncmut);
> pthread_mutex_unlock(&syncmut);
> }
>
240c256
< starttime=longcount();
---
>
307a324,335
>
> // allow threads to continue once all are created
> pthread_mutex_lock(&syncmut);
> while(synccount < 3) {
> pthread_mutex_unlock(&syncmut);
> avm_usleep(100000);
> pthread_mutex_lock(&syncmut);
> }
> starttime=longcount();
> pthread_cond_broadcast(&synccond);
> pthread_mutex_unlock(&syncmut);
>
377c405,406
< const float fps=m_conf.fps;
---
> syncBlock();
> const float fps=m_conf.fps;
380c409
<
---
> bool first = true;
460a490
> syncBlock();
583a614
> syncBlock();