commit e8a50634bee9c2128716e30ed4d13d331328f0c9
Author: Robert Haschke <rhaschke@techfak.uni-bielefeld.de>
Date:   Mon Oct 26 20:18:50 2020 +0100

    Replace usleep -> std::this_thread::sleep_for

diff --git a/client/cpp/examples/random_gaze/main.cpp b/client/cpp/examples/random_gaze/main.cpp
index 4c3116a..7321375 100644
--- a/client/cpp/examples/random_gaze/main.cpp
+++ b/client/cpp/examples/random_gaze/main.cpp
@@ -28,7 +28,8 @@
 
 #include "RobotController.h"
 #include "RobotGaze.h"
-#include <unistd.h>
+#include <thread>
+#include <chrono>
 
 float rand_float(float min, float max) {
 	float f = (float)rand() / RAND_MAX;
@@ -68,6 +69,6 @@ int main(int argc, char** argv) {
 		}
 
 		robot_controller->set_gaze_target(gaze);
-		usleep(1000 / 50 * 1000);
+		std::this_thread::sleep_for(std::chrono::milliseconds(1000 / 50));
 	}
 }
diff --git a/client/cpp/examples/speech_test/main.cpp b/client/cpp/examples/speech_test/main.cpp
index 25be60f..4fb7aec 100644
--- a/client/cpp/examples/speech_test/main.cpp
+++ b/client/cpp/examples/speech_test/main.cpp
@@ -27,7 +27,8 @@
  */
 
 #include "RobotController.h"
-#include <unistd.h>
+#include <thread>
+#include <chrono>
 
 #define BLOCKING true
 
@@ -38,11 +39,11 @@ int main(int argc, char** argv) {
 
 	printf("> speech test starting.\n");
 
-	robot_controller->set_speak("i will start counting now.\n", BLOCKING);
+	robot_controller->set_speak("I will start counting now.\n", BLOCKING);
 	while (1) {
 		std::string text = std::to_string(count++);
 		printf("> saying '%s'\n", text.c_str());
 		robot_controller->set_speak(text, BLOCKING);
-		sleep(1);
+		std::this_thread::sleep_for(std::chrono::seconds(1));
 	}
 }
diff --git a/server/src/Arbiter.cpp b/server/src/Arbiter.cpp
index 4d201f5..a031839 100644
--- a/server/src/Arbiter.cpp
+++ b/server/src/Arbiter.cpp
@@ -147,8 +147,7 @@ void Arbiter::play_animation(boost::shared_ptr<Animation> incoming_animation) {
 
 	// block until ani was played back
 	while (incoming_animation->is_active()) {
-		// printf("A"); fflush(stdout);
-		usleep(1 * 1000); // 1ms, save cpu cycles
+		std::this_thread::sleep_for(std::chrono::milliseconds(1)); // save cpu cycles
 	}
 
 	// ok, it finished. we can safely remove it now:
@@ -189,7 +188,7 @@ void Arbiter::speak(
 	if (audio_player != NULL) {
 		while (audio_player->is_playing()) {
 			// save some cpu cycles:
-			usleep(1 * 1000); // 1ms
+			std::this_thread::sleep_for(std::chrono::milliseconds(1)); // 1ms
 		}
 	}
 
@@ -197,7 +196,7 @@ void Arbiter::speak(
 	// so check now if the utterance finished as well:
 	while (utterance->is_playing()) {
 		// save some cpu cycles:
-		usleep(1 * 1000); // 1ms
+		std::this_thread::sleep_for(std::chrono::milliseconds(1));
 	}
 }
 
diff --git a/server/src/AudioPlayer.cpp b/server/src/AudioPlayer.cpp
index d126c8b..ea7f6c1 100644
--- a/server/src/AudioPlayer.cpp
+++ b/server/src/AudioPlayer.cpp
@@ -27,6 +27,8 @@
  */
 
 #include "AudioPlayer.h"
+#include <thread>
+#include <chrono>
 
 using namespace std;
 
@@ -49,6 +51,6 @@ AudioPlayer::~AudioPlayer() {
 
 	while (playback_state != CLOSED) {
 		printf("> waiting for end of audio playback\n");
-		usleep(1000);
+		std::this_thread::sleep_for(std::chrono::milliseconds(1));
 	}
 }
diff --git a/server/src/AudioPlayerLibAO.cpp b/server/src/AudioPlayerLibAO.cpp
index 77934a2..b46632a 100644
--- a/server/src/AudioPlayerLibAO.cpp
+++ b/server/src/AudioPlayerLibAO.cpp
@@ -27,9 +27,10 @@
  */
 
 #include "AudioPlayerLibAO.h"
+#include <thread>
+#include <chrono>
 
 using namespace std;
-using namespace boost;
 
 // new audio player with gievn device type (default is pulse)
 AudioPlayerLibAO::AudioPlayerLibAO(string driver) : AudioPlayer(driver) {
@@ -66,7 +67,7 @@ void AudioPlayerLibAO::play(boost::shared_ptr<AudioData> audio) {
 	// check if we can play this file:
 	while (playback_state != IDLE) {
 		printf("> player not ready yet, waiting for 10ms\n");
-		usleep(10 * 1000);
+		std::this_thread::sleep_for(std::chrono::milliseconds(10));
 	}
 
 	audio_format = extract_ao_format(audio_data);
@@ -76,7 +77,7 @@ void AudioPlayerLibAO::play(boost::shared_ptr<AudioData> audio) {
 	// wait for playback to start:
 	printf("> waiting for playback start...\n");
 	while (playback_requested) {
-		usleep(1 * 1000);
+		std::this_thread::sleep_for(std::chrono::milliseconds(1));
 	}
 	printf("> playback running.\n");
 }
@@ -179,7 +180,7 @@ void AudioPlayerLibAO::playback_thread() {
 		}
 
 		// 1ms delay to safe cpu time
-		usleep(1000);
+		std::this_thread::sleep_for(std::chrono::milliseconds(1));
 	}
 
 	// shutdown audio!
diff --git a/server/src/AudioPlayerRSB.cpp b/server/src/AudioPlayerRSB.cpp
index 3d58f08..3ed55d1 100644
--- a/server/src/AudioPlayerRSB.cpp
+++ b/server/src/AudioPlayerRSB.cpp
@@ -69,7 +69,7 @@ void AudioPlayerRSB::play(boost::shared_ptr<AudioData> _audio_data) {
 	// check if we can play this file:
 	while (playback_state != IDLE) {
 		printf("> player not ready yet, waiting for 10ms\n");
-		usleep(10 * 1000);
+		std::this_thread::sleep_for(std::chrono::milliseconds(10));
 	}
 
 	// ok, we can play the audio. copy/setup data:
@@ -113,7 +113,7 @@ void AudioPlayerRSB::playback_thread() {
 				}
 
 				// add some delay to meet the delay until playback starts (FIXME: this should be determined!)
-				// usleep(100*1000); //100ms
+				// std::this_thread::sleep_for(std::chrono::milliseconds(100));
 
 				// ok we can now play the data
 				printf("> AudioPlayer: playback started\n");
@@ -147,7 +147,7 @@ void AudioPlayerRSB::playback_thread() {
 		}
 
 		// 1ms delay to safe cpu time
-		usleep(1000);
+		std::this_thread::sleep_for(std::chrono::milliseconds(1));
 	}
 
 	// done
