diff options
-rw-r--r-- | src/encoder.cc | 45 |
1 files changed, 26 insertions, 19 deletions
diff --git a/src/encoder.cc b/src/encoder.cc index fc66e27..878c97d 100644 --- a/src/encoder.cc +++ b/src/encoder.cc @@ -75,27 +75,34 @@ void Encoder::encode() pthread_mutex_lock(mutex); frame = queue->pop(); - queue->plength(); - pthread_mutex_unlock(mutex); + // queue->plength(); + // pthread_mutex_unlock(mutex); - if((frame && record) || - (freeze_request != freeze_value) || - (shoot_request != shoot_value)) { - n_header h; - - h.header_type = DATA_HEADER; - sprintf(h.header.h_data.cpr, cpr); - h.header.h_data.freeze = (freeze_request != freeze_value); - h.header.h_data.snapshot = (shoot_request != shoot_value); - h.header.h_data.record = record; - h.header.h_data.savestate = NO_CHANGE; - - if(freeze_request != freeze_value) freeze_value = freeze_request; - if(shoot_request != shoot_value) shoot_value = shoot_request; - - n->sendPackage(&h, frame->data, frame->size); + while(frame) { + if(record || + (freeze_request != freeze_value) || + (shoot_request != shoot_value)) { + n_header h; + + h.header_type = DATA_HEADER; + sprintf(h.header.h_data.cpr, cpr); + h.header.h_data.freeze = (freeze_request != freeze_value); + h.header.h_data.snapshot = (shoot_request != shoot_value); + h.header.h_data.record = record; + h.header.h_data.savestate = NO_CHANGE; + + if(freeze_request != freeze_value) freeze_value = freeze_request; + if(shoot_request != shoot_value) shoot_value = shoot_request; + + n->sendPackage(&h, frame->data, frame->size); + } + if(frame) delete frame; + + // pthread_mutex_lock(mutex); + frame = queue->pop(); + // queue->plength(); } - if(frame) delete frame; + pthread_mutex_unlock(mutex); } } |