diff options
author | deva <deva> | 2005-04-28 18:39:31 +0000 |
---|---|---|
committer | deva <deva> | 2005-04-28 18:39:31 +0000 |
commit | 876299a73bd4517e070ee3b349d41d37d1fd7957 (patch) | |
tree | 8238ee29d469b581902864364c17baaa81fda3c8 /src/encoder.cc | |
parent | a420994fe53199747e6d0ba0af473ecc4f940258 (diff) |
Added locking to the queue and locked queue in encoder to empty it before stopping network stream.
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; |