Revision 498cd9cd 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 |
} |
... | ... | |
177 | 178 |
} |
178 | 179 |
|
179 | 180 |
//1ms delay to safe cpu time |
180 |
usleep(1000);
|
|
181 |
std::this_thread::sleep_for(std::chrono::milliseconds(1));
|
|
181 | 182 |
} |
182 | 183 |
|
183 | 184 |
//shutdown audio! |
Also available in: Unified diff