MusicChunk: use std::span

This commit is contained in:
Max Kellermann 2022-05-20 11:05:48 +02:00
parent b50173ae8b
commit f66315d2de
4 changed files with 7 additions and 6 deletions

View File

@ -36,7 +36,7 @@ MusicChunkInfo::CheckFormat(const AudioFormat other_format) const noexcept
}
#endif
WritableBuffer<void>
std::span<std::byte>
MusicChunk::Write(const AudioFormat af,
SongTime data_time, uint16_t _bit_rate) noexcept
{

View File

@ -23,7 +23,6 @@
#include "MusicChunkPtr.hxx"
#include "Chrono.hxx"
#include "tag/ReplayGainInfo.hxx"
#include "util/WritableBuffer.hxx"
#ifndef NDEBUG
#include "pcm/AudioFormat.hxx"
@ -32,6 +31,7 @@
#include <cstddef>
#include <cstdint>
#include <memory>
#include <span>
static constexpr size_t CHUNK_SIZE = 4096;
@ -116,7 +116,7 @@ struct MusicChunkInfo {
*/
struct MusicChunk : MusicChunkInfo {
/** the data (probably PCM) */
uint8_t data[CHUNK_SIZE - sizeof(MusicChunkInfo)];
std::byte data[CHUNK_SIZE - sizeof(MusicChunkInfo)];
/**
* Prepares appending to the music chunk. Returns a buffer
@ -129,7 +129,7 @@ struct MusicChunk : MusicChunkInfo {
* @param bit_rate the current bit rate of the source file
* @return a writable buffer, or nullptr if the chunk is full
*/
WritableBuffer<void> Write(AudioFormat af,
std::span<std::byte> Write(AudioFormat af,
SongTime data_time,
uint16_t bit_rate) noexcept;

View File

@ -545,11 +545,11 @@ DecoderBridge::SubmitData(InputStream *is,
continue;
}
const size_t nbytes = std::min(dest.size, length);
const size_t nbytes = std::min(dest.size(), length);
/* copy the buffer */
memcpy(dest.data, data, nbytes);
memcpy(dest.data(), data, nbytes);
/* expand the music pipe chunk */

View File

@ -23,6 +23,7 @@
#include "MusicPipe.hxx"
#include "MusicChunk.hxx"
#include "util/Compiler.h"
#include "util/ConstBuffer.hxx"
#include <stdio.h>