diff options
Diffstat (limited to 'src/encoder.cc')
-rw-r--r-- | src/encoder.cc | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/encoder.cc b/src/encoder.cc index 52a7f93..c304b5a 100644 --- a/src/encoder.cc +++ b/src/encoder.cc @@ -26,6 +26,8 @@ #include "encoder.h" +#include <time.h> + Encoder::Encoder(Error* err, const char *gip, const int gport, @@ -144,9 +146,22 @@ void Encoder::start() { void Encoder::stop(n_savestate save) { + struct timespec ts; // TODO: set save state in package header. - // TODO: Flush not yet sent video packages. + + // Lock the queue and wait until all elements are sent on the network. + queue->lock(); + while(queue->peek()) { + /* Remove any late buffer */ + /* We don't care, the encoder finishes them all */ + ts.tv_sec = 0; + ts.tv_nsec = 100000000L; // 100ms + nanosleep(&ts, NULL); + } + record = 0; + + queue->unlock(); if(s) { if(n) delete n; delete s; |