MusicChunk: use std::span
This commit is contained in:
parent
b50173ae8b
commit
f66315d2de
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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 */
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include "MusicPipe.hxx"
|
||||
#include "MusicChunk.hxx"
|
||||
#include "util/Compiler.h"
|
||||
#include "util/ConstBuffer.hxx"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
|
|
Loading…
Reference in New Issue