我正在尝试使用SFML创建语音聊天。 程序使用SoundbufferRecorder记录1个长度的部分。
当我测试下面的代码时,控制台会显示: 无法从内存中加载声音文件
void receiveData()
{
received_data = false;
unsigned short port;
if (serwer) port = s_port;
else port = k_port;
Packet p;
socket.receive(p, ip, port);
bufferfrommemory.loadFromMemory(p.getData(), p.getDataSize());
received_data= true;
}
void sendData()
{
unsigned short port;
if (serwer) port = k_port;
else port = s_port;
const sf::SoundBuffer& buffer = recorder.getBuffer();
const sf::Int16* samples = buffer.getSamples();
std::size_t count = buffer.getSampleCount();
Packet p;
p.append(samples, count);
socket.send(p, ip, port);
}
void playIt()
{
Sound g;
g.setBuffer(bufferfrommemory);
g.play();
}
提前感谢您的帮助。