mirror of
https://github.com/badaix/snapcast.git
synced 2025-06-05 04:11:50 +02:00
Silence the PCM buffer if no chunk is available
This commit is contained in:
parent
147e4e9b7e
commit
168bc3f98b
7 changed files with 31 additions and 11 deletions
|
@ -85,20 +85,21 @@ void FilePlayer::requestAudio()
|
|||
if (buffer_.size() < needed)
|
||||
buffer_.resize(needed);
|
||||
|
||||
if (!stream_->getPlayerChunk(buffer_.data(), 10ms, numFrames))
|
||||
if (!stream_->getPlayerChunkOrSilence(buffer_.data(), 10ms, numFrames))
|
||||
{
|
||||
// LOG(INFO, LOG_TAG) << "Failed to get chunk. Playing silence.\n";
|
||||
memset(buffer_.data(), 0, needed);
|
||||
}
|
||||
else
|
||||
{
|
||||
adjustVolume(static_cast<char*>(buffer_.data()), numFrames);
|
||||
}
|
||||
|
||||
if (file_)
|
||||
{
|
||||
fwrite(buffer_.data(), 1, needed, file_.get());
|
||||
fflush(file_.get());
|
||||
}
|
||||
|
||||
loop();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue