summaryrefslogtreecommitdiff
path: root/client/networksender.cc
diff options
context:
space:
mode:
Diffstat (limited to 'client/networksender.cc')
-rw-r--r--client/networksender.cc37
1 files changed, 35 insertions, 2 deletions
diff --git a/client/networksender.cc b/client/networksender.cc
index 675bdb9..2f1d8b0 100644
--- a/client/networksender.cc
+++ b/client/networksender.cc
@@ -28,17 +28,28 @@
#include "info.h"
+#include <util.h>
+
NetworkSender::NetworkSender(QString cpr)
{
ip = "192.168.0.10";
port = 6666;
// Connect
+ // sleep(1);
+
+ fprintf(stderr, "Connect [%p]\n", this);
}
NetworkSender::~NetworkSender()
{
// Disconnect
+ sleep_1_frame();
+ sleep_1_frame();
+ sleep_1_frame();
+ sleep_1_frame();
+
+ fprintf(stderr, "Disconnect [%p]\n", this);
}
void NetworkSender::pushFrame(char* framedata, bool freeze, bool snapshot)
@@ -54,10 +65,21 @@ void NetworkSender::pushFrame(char* framedata, bool freeze, bool snapshot)
semaphore.release();
}
+unsigned int NetworkSender::queueSize()
+{
+ unsigned int sz;
+
+ mutex.lock();
+ sz = framelist.size();
+ mutex.unlock();
+
+ return sz;
+}
+
void NetworkSender::run()
{
while(running) {
- semaphore.acquire();
+ if(queueSize()) semaphore.acquire();
Frame *frame = NULL;
mutex.lock();
@@ -66,8 +88,19 @@ void NetworkSender::run()
if(frame) {
// TODO: Send it over the network
-
+ sleep_1_frame();
+ sleep_1_frame();
+ sleep_1_frame();
+ sleep_1_frame();
delete frame;
}
}
+ terminatesemaphore.release(); // Signal the stop method that the thread has stopped running.
+}
+
+void NetworkSender::stop()
+{
+ running = false;
+ semaphore.release(); // Kick the thread active
+ terminatesemaphore.acquire(); // Wait for the thread to stop
}