filter/Filter: add method ReadMore()

This allows FilterPCM() to return more data, which some
implementations may need to do (e.g. FFmpeg).
This commit is contained in:
Max Kellermann
2021-08-26 14:20:36 +02:00
committed by Max Kellermann
parent d8bb833ba3
commit 849c4012c0
8 changed files with 84 additions and 10 deletions

View File

@@ -138,6 +138,8 @@ AudioOutputSource::GetChunkData(const MusicChunk &chunk,
*replay_gain_serial_p = chunk.replay_gain_serial;
}
/* note: the ReplayGainFilter doesn't have a
ReadMore() method */
data = current_replay_gain_filter->FilterPCM(data);
}
@@ -231,10 +233,18 @@ AudioOutputSource::Fill(Mutex &mutex)
void
AudioOutputSource::ConsumeData(size_t nbytes) noexcept
{
assert(filter);
pending_data = pending_data.subspan(nbytes);
if (pending_data.empty())
DropCurrentChunk();
if (pending_data.empty()) {
/* give the filter a chance to return more data in
another buffer */
pending_data = filter->ReadMore();
if (pending_data.empty())
DropCurrentChunk();
}
}
std::span<const std::byte>