Revision e8a50634

View differences:

client/cpp/examples/random_gaze/main.cpp
28 28

  
29 29
#include "RobotController.h"
30 30
#include "RobotGaze.h"
31
#include <unistd.h>
31
#include <thread>
32
#include <chrono>
32 33

  
33 34
float rand_float(float min, float max) {
34 35
	float f = (float)rand() / RAND_MAX;
......
68 69
		}
69 70

  
70 71
		robot_controller->set_gaze_target(gaze);
71
		usleep(1000 / 50 * 1000);
72
		std::this_thread::sleep_for(std::chrono::milliseconds(1000 / 50));
72 73
	}
73 74
}
client/cpp/examples/speech_test/main.cpp
27 27
 */
28 28

  
29 29
#include "RobotController.h"
30
#include <unistd.h>
30
#include <thread>
31
#include <chrono>
31 32

  
32 33
#define BLOCKING true
33 34

  
......
38 39

  
39 40
	printf("> speech test starting.\n");
40 41

  
41
	robot_controller->set_speak("i will start counting now.\n", BLOCKING);
42
	robot_controller->set_speak("I will start counting now.\n", BLOCKING);
42 43
	while (1) {
43 44
		std::string text = std::to_string(count++);
44 45
		printf("> saying '%s'\n", text.c_str());
45 46
		robot_controller->set_speak(text, BLOCKING);
46
		sleep(1);
47
		std::this_thread::sleep_for(std::chrono::seconds(1));
47 48
	}
48 49
}
server/src/Arbiter.cpp
147 147

  
148 148
	// block until ani was played back
149 149
	while (incoming_animation->is_active()) {
150
		// printf("A"); fflush(stdout);
151
		usleep(1 * 1000); // 1ms, save cpu cycles
150
		std::this_thread::sleep_for(std::chrono::milliseconds(1)); // save cpu cycles
152 151
	}
153 152

  
154 153
	// ok, it finished. we can safely remove it now:
......
189 188
	if (audio_player != NULL) {
190 189
		while (audio_player->is_playing()) {
191 190
			// save some cpu cycles:
192
			usleep(1 * 1000); // 1ms
191
			std::this_thread::sleep_for(std::chrono::milliseconds(1)); // 1ms
193 192
		}
194 193
	}
195 194

  
......
197 196
	// so check now if the utterance finished as well:
198 197
	while (utterance->is_playing()) {
199 198
		// save some cpu cycles:
200
		usleep(1 * 1000); // 1ms
199
		std::this_thread::sleep_for(std::chrono::milliseconds(1));
201 200
	}
202 201
}
203 202

  
server/src/AudioPlayer.cpp
27 27
 */
28 28

  
29 29
#include "AudioPlayer.h"
30
#include <thread>
31
#include <chrono>
30 32

  
31 33
using namespace std;
32 34

  
......
49 51

  
50 52
	while (playback_state != CLOSED) {
51 53
		printf("> waiting for end of audio playback\n");
52
		usleep(1000);
54
		std::this_thread::sleep_for(std::chrono::milliseconds(1));
53 55
	}
54 56
}
server/src/AudioPlayerLibAO.cpp
27 27
 */
28 28

  
29 29
#include "AudioPlayerLibAO.h"
30
#include <thread>
31
#include <chrono>
30 32

  
31 33
using namespace std;
32
using namespace boost;
33 34

  
34 35
// new audio player with gievn device type (default is pulse)
35 36
AudioPlayerLibAO::AudioPlayerLibAO(string driver) : AudioPlayer(driver) {
......
66 67
	// check if we can play this file:
67 68
	while (playback_state != IDLE) {
68 69
		printf("> player not ready yet, waiting for 10ms\n");
69
		usleep(10 * 1000);
70
		std::this_thread::sleep_for(std::chrono::milliseconds(10));
70 71
	}
71 72

  
72 73
	audio_format = extract_ao_format(audio_data);
......
76 77
	// wait for playback to start:
77 78
	printf("> waiting for playback start...\n");
78 79
	while (playback_requested) {
79
		usleep(1 * 1000);
80
		std::this_thread::sleep_for(std::chrono::milliseconds(1));
80 81
	}
81 82
	printf("> playback running.\n");
82 83
}
......
179 180
		}
180 181

  
181 182
		// 1ms delay to safe cpu time
182
		usleep(1000);
183
		std::this_thread::sleep_for(std::chrono::milliseconds(1));
183 184
	}
184 185

  
185 186
	// shutdown audio!
server/src/AudioPlayerRSB.cpp
69 69
	// check if we can play this file:
70 70
	while (playback_state != IDLE) {
71 71
		printf("> player not ready yet, waiting for 10ms\n");
72
		usleep(10 * 1000);
72
		std::this_thread::sleep_for(std::chrono::milliseconds(10));
73 73
	}
74 74

  
75 75
	// ok, we can play the audio. copy/setup data:
......
113 113
				}
114 114

  
115 115
				// add some delay to meet the delay until playback starts (FIXME: this should be determined!)
116
				// usleep(100*1000); //100ms
116
				// std::this_thread::sleep_for(std::chrono::milliseconds(100));
117 117

  
118 118
				// ok we can now play the data
119 119
				printf("> AudioPlayer: playback started\n");
......
147 147
		}
148 148

  
149 149
		// 1ms delay to safe cpu time
150
		usleep(1000);
150
		std::this_thread::sleep_for(std::chrono::milliseconds(1));
151 151
	}
152 152

  
153 153
	// done

Also available in: Unified diff