summaryrefslogtreecommitdiff
path: root/src/inputstreamer.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/inputstreamer.cc')
-rw-r--r--src/inputstreamer.cc40
1 files changed, 26 insertions, 14 deletions
diff --git a/src/inputstreamer.cc b/src/inputstreamer.cc
index 04edc7b..deffa71 100644
--- a/src/inputstreamer.cc
+++ b/src/inputstreamer.cc
@@ -67,6 +67,11 @@ InputStreamer::InputStreamer(QHostAddress addr, quint16 port)
running = true;
start();
}
+int interrupted;
+
+void handle_int(int num) {
+ interrupted = 1;
+}
InputStreamer::~InputStreamer()
{
@@ -93,28 +98,33 @@ void InputStreamer::run()
char packet[64*1024];
while(running) {
- /*
- if(!socket.hasPendingDatagrams()) {
- qApp->processEvents();
- usleep(2000); // sleep 2ms
- continue;
- }
- qint64 packetsize =
- socket.readDatagram(packet, (quint64)sizeof(packet), 0, 0);
- if(packetsize < 1) {
- continue;
+ ssize_t packetsize;
+
+ {
+ int fd = sock;
+ fd_set fds;
+ struct timeval timeout;
+
+ timeout.tv_sec = 0;
+ timeout.tv_usec = 1000;
+ FD_ZERO(&fds);
+ FD_SET(fd, &fds);
+ if(select(fd + 1, &fds, NULL, NULL, &timeout) > 0) {
+ packetsize = recv(sock, (char*)packet, sizeof(packet), 0);
+ } else {
+ // timeout
+ continue;
+ }
}
- */
- ssize_t packetsize = recv(sock, (char*)packet, sizeof(packet), 0);
if(packetsize == -1) {
perror("recv()");
- usleep(100); // sleep 2ms
+ usleep(1000);
continue;
}
if(packetsize == 0) {
- usleep(100); // sleep 2ms
+ usleep(1000);
continue;
}
@@ -149,6 +159,8 @@ void InputStreamer::run()
}
}
+ printf("done\n");
+
status = lrtp_destroy_profile(lrtp, CSRC_V);
if(status != LRTP_OK) printf("O:lrtp_destroy_profile (v) err: %d\n", status);