From 7d547a29164cf9318a7eca918705bbc30e93b81d Mon Sep 17 00:00:00 2001 From: deva Date: Wed, 24 May 2006 09:15:57 +0000 Subject: *** empty log message *** --- client/networksender.cc | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) (limited to 'client/networksender.cc') 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 + 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 } -- cgit v1.2.3