MusicChunk: add method ReadData()

This commit is contained in:
Max Kellermann 2024-11-05 12:32:16 +01:00
parent 4beedec3ad
commit f59f17013d
2 changed files with 5 additions and 1 deletions

View File

@ -127,6 +127,10 @@ struct MusicChunk : MusicChunkInfo {
* @return true if the chunk is full
*/
bool Expand(AudioFormat af, size_t length) noexcept;
std::span<const std::byte> ReadData() const noexcept {
return {data, length};
}
};
static_assert(sizeof(MusicChunk) == CHUNK_SIZE, "Wrong size");

View File

@ -122,7 +122,7 @@ AudioOutputSource::GetChunkData(const MusicChunk &chunk,
assert(!chunk.IsEmpty());
assert(chunk.CheckFormat(in_audio_format));
std::span<const std::byte> data(chunk.data, chunk.length);
auto data = chunk.ReadData();
assert(data.size() % in_audio_format.GetFrameSize() == 0);