diff core/ReceiveAudioThread.cpp @ 132:e24c531220ee scope-refactoring

Added some sort of synchronization, not working great though
author Giulio Moro <giuliomoro@yahoo.it>
date Thu, 27 Aug 2015 01:42:04 +0100
parents ff28e56e5b7e
children 04b1678614c9
line wrap: on
line diff
--- a/core/ReceiveAudioThread.cpp	Wed Aug 26 02:02:10 2015 +0100
+++ b/core/ReceiveAudioThread.cpp	Thu Aug 27 01:42:04 2015 +0100
@@ -59,6 +59,11 @@
     if(writePointer<0)
         return 0;
     if(socket.waitUntilReady(true, waitForSocketTime)){// TODO: if waitForSocketTime here is >>5, the
+#ifdef USE_JUCE
+#else
+		lastTime=rt_timer_read();
+//        rt_printf("lastTimeread= %llu\n", lastTime);
+#endif /* USE_JUCE */
     	// destructor (always or sometimes) never actually gets called, despite run() returns ...see issue #1381
         pushPayload(writePointer); //backup headerLength samples. This could be skipped if writePointer==0
         //read header+payload
@@ -80,7 +85,6 @@
 //        	printf("I am channel %d, but I received data for channel %d\n", channel, (int)buffer[writePointer]);
         	return -5;
         }
-        static int timestamp=0;
         if(buffer[writePointer+1]!=timestamp+1)
         	printf("missing a timestamp: %d\n",timestamp+1);
         timestamp=buffer[writePointer+1];
@@ -161,6 +165,7 @@
   writePointer=-1;
   readPointer=0;
   sleepTime=payloadLength/(float)44100 /4.0; //set sleepTime so that you do not check too often or too infrequently
+  timestamp=0;
 #ifdef USE_JUCE
   startThread(threadPriority);
 #else
@@ -241,7 +246,13 @@
 bool ReceiveAudioThread::threadShouldExit(){
 	return(gShouldStop || threadIsExiting );
 }
+RTIME ReceiveAudioThread::getLastTime(){
+	return lastTime;
+}
 #endif /* USE_JUCE */
+int ReceiveAudioThread::getTimestamp(){
+	return timestamp;
+}
 void ReceiveAudioThread::run(){
     //  fd2=fopen("buffer.m","w"); //DEBUG
     //  fprintf(fd2, "buf=["); //DEBUG