diff options
author | deva <deva> | 2006-05-24 09:15:57 +0000 |
---|---|---|
committer | deva <deva> | 2006-05-24 09:15:57 +0000 |
commit | 7d547a29164cf9318a7eca918705bbc30e93b81d (patch) | |
tree | b78b9e756c40766d2c85e7dc35aa6c932b7bf747 /client/networksender.cc | |
parent | dd8e7832c69a5ef484a2f3b6054a482d29275f85 (diff) |
*** empty log message ***
Diffstat (limited to 'client/networksender.cc')
-rw-r--r-- | client/networksender.cc | 37 |
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 } |