Revision e8a50634 server/src/AudioPlayerLibAO.cpp
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! |
Also available in: Unified diff