我正在使用超级强大的 sdk 来播放音频文件。我需要等待 SuperpoweredAdvancedAudioPlayer 缓存文件。这是我尝试过的伪代码:
void loading (shared_ptr<SuperpoweredAdvancedAudioPlayer> player, string path)
{
player->open(path.c_str());
player->cachePosition(0, 0);
}
int main ()
{
string filePath = "/path/file.wav";
shared_ptr<SuperpoweredAdvancedAudioPlayer> player;
player = make_shared<SuperpoweredAdvancedAudioPlayer>(nullptr, nullptr, 44100, 10, 2, 0);
thread Loading(loading, player, filePath);
char *tmp = (char*)&player->waitingForBuffering;
Loading.join();
while (*tmp) {usleep(10000);}
return 0;
}
它对我不起作用。waitingForBuffering 始终为真。什么是有效的等待方式?