Commit 38553e72 authored by Simon Morlat's avatar Simon Morlat
Browse files

V4L2: remove conditional because it slows the FPS to 10 maximum.

The condition for waking up the V4L2 thread is not good. mblk_t become free when the last filter in the chain no longer uses them.
Furthermore the signal() was done only at fps rate in process method, which was not sufficient.
In order to prevent busy loop in case all buffers are used, an usleep() was added.
parent 6114af4d
...@@ -71,7 +71,6 @@ typedef struct V4l2State{ ...@@ -71,7 +71,6 @@ typedef struct V4l2State{
bool_t thread_run; bool_t thread_run;
queue_t rq; queue_t rq;
ms_mutex_t mutex; ms_mutex_t mutex;
ms_cond_t cond;
char *dev; char *dev;
char *mmapdbuf; char *mmapdbuf;
int msize;/*mmapped size*/ int msize;/*mmapped size*/
...@@ -476,13 +475,8 @@ static mblk_t * v4lv2_grab_image(V4l2State *s, int poll_timeout_ms){ ...@@ -476,13 +475,8 @@ static mblk_t * v4lv2_grab_image(V4l2State *s, int poll_timeout_ms){
if (s->queued){ if (s->queued){
ret=v4l2_dequeue_ready_buffer(s,poll_timeout_ms); ret=v4l2_dequeue_ready_buffer(s,poll_timeout_ms);
} }else if (no_slot_available){
ms_usleep(100000);
if (no_slot_available) {
ms_mutex_lock(&s->mutex);
if (s->thread_run)
ms_cond_wait(&s->cond, &s->mutex);
ms_mutex_unlock(&s->mutex);
} }
return ret; return ret;
} }
...@@ -516,7 +510,6 @@ static void msv4l2_init(MSFilter *f){ ...@@ -516,7 +510,6 @@ static void msv4l2_init(MSFilter *f){
s->vsize=MS_VIDEO_SIZE_CIF; s->vsize=MS_VIDEO_SIZE_CIF;
s->fps=15; s->fps=15;
s->configured=FALSE; s->configured=FALSE;
ms_cond_init(&s->cond, NULL);
f->data=s; f->data=s;
qinit(&s->rq); qinit(&s->rq);
} }
...@@ -526,7 +519,6 @@ static void msv4l2_uninit(MSFilter *f){ ...@@ -526,7 +519,6 @@ static void msv4l2_uninit(MSFilter *f){
ms_free(s->dev); ms_free(s->dev);
flushq(&s->rq,0); flushq(&s->rq,0);
ms_mutex_destroy(&s->mutex); ms_mutex_destroy(&s->mutex);
ms_cond_destroy(&s->cond);
ms_free(s); ms_free(s);
} }
...@@ -613,7 +605,6 @@ static void msv4l2_process(MSFilter *f){ ...@@ -613,7 +605,6 @@ static void msv4l2_process(MSFilter *f){
om=tmp; om=tmp;
} }
} }
ms_cond_signal(&s->cond);
ms_mutex_unlock(&s->mutex); ms_mutex_unlock(&s->mutex);
if (om!=NULL){ if (om!=NULL){
timestamp=f->ticker->time*90;/* rtp uses a 90000 Hz clockrate for video*/ timestamp=f->ticker->time*90;/* rtp uses a 90000 Hz clockrate for video*/
...@@ -642,9 +633,6 @@ static void msv4l2_postprocess(MSFilter *f){ ...@@ -642,9 +633,6 @@ static void msv4l2_postprocess(MSFilter *f){
s->thread_run = FALSE; s->thread_run = FALSE;
if(s->thread) { if(s->thread) {
ms_mutex_lock(&s->mutex);
ms_cond_signal(&s->cond);
ms_mutex_unlock(&s->mutex);
ms_thread_join(s->thread,NULL); ms_thread_join(s->thread,NULL);
ms_message("msv4l2 thread has joined."); ms_message("msv4l2 thread has joined.");
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment