fix infinite loop in MemoryPCMStream if stream is playing with loop=true

This commit is contained in:
MihailRis 2025-11-22 12:30:17 +03:00
parent f1cf5c43e6
commit fc292a57cd

View File

@ -24,12 +24,9 @@ void MemoryPCMStream::close() {
}
size_t MemoryPCMStream::read(char* dst, size_t bufferSize) {
if (!open) {
if (!open || buffer.empty()) {
return PCMStream::ERROR;
}
if (buffer.empty()) {
return 0;
}
size_t count = std::min<size_t>(bufferSize, buffer.size());
std::memcpy(dst, buffer.data(), count);
buffer.erase(buffer.begin(), buffer.begin() + count);