summaryrefslogtreecommitdiff
path: root/src/encoder.cc
diff options
context:
space:
mode:
authordeva <deva>2005-04-28 18:39:31 +0000
committerdeva <deva>2005-04-28 18:39:31 +0000
commit876299a73bd4517e070ee3b349d41d37d1fd7957 (patch)
tree8238ee29d469b581902864364c17baaa81fda3c8 /src/encoder.cc
parenta420994fe53199747e6d0ba0af473ecc4f940258 (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.cc17
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;