util/*FifoBuffer: migrate from WritableBuffer to std::span
This commit is contained in:

committed by
Max Kellermann

parent
570755f05a
commit
bb7be9a4cd
@@ -93,7 +93,7 @@ adts_find_frame(DecoderBuffer &buffer)
|
||||
continue;
|
||||
}
|
||||
|
||||
if (buffer.Need(frame_length).IsNull()) {
|
||||
if (buffer.Need(frame_length).empty()) {
|
||||
/* not enough data; discard this frame to
|
||||
prevent a possible buffer overflow */
|
||||
buffer.Clear();
|
||||
|
@@ -237,11 +237,11 @@ HybridDsdDecode(DecoderClient &client, InputStream &input)
|
||||
auto w = buffer.Write();
|
||||
if (!w.empty()) {
|
||||
if (remaining_bytes < (1<<30ULL) &&
|
||||
w.size > size_t(remaining_bytes))
|
||||
w.size = remaining_bytes;
|
||||
w.size() > size_t(remaining_bytes))
|
||||
w = w.first(remaining_bytes);
|
||||
|
||||
const size_t nbytes = client.Read(input,
|
||||
w.data, w.size);
|
||||
w.data(), w.size());
|
||||
if (nbytes == 0)
|
||||
return;
|
||||
|
||||
@@ -251,9 +251,9 @@ HybridDsdDecode(DecoderClient &client, InputStream &input)
|
||||
|
||||
/* submit the buffer to our client */
|
||||
auto r = buffer.Read();
|
||||
auto n_frames = r.size / frame_size;
|
||||
auto n_frames = r.size() / frame_size;
|
||||
if (n_frames > 0) {
|
||||
cmd = client.SubmitData(input, r.data,
|
||||
cmd = client.SubmitData(input, r.data(),
|
||||
n_frames * frame_size,
|
||||
kbit_rate);
|
||||
buffer.Consume(n_frames * frame_size);
|
||||
|
@@ -51,7 +51,7 @@ FillBuffer(DecoderClient &client, InputStream &is, B &buffer)
|
||||
if (w.empty())
|
||||
return true;
|
||||
|
||||
size_t nbytes = decoder_read(client, is, w.data, w.size);
|
||||
size_t nbytes = decoder_read(client, is, w.data(), w.size());
|
||||
if (nbytes == 0 && is.LockIsEOF())
|
||||
return false;
|
||||
|
||||
@@ -188,25 +188,28 @@ pcm_stream_decode(DecoderClient &client, InputStream &is)
|
||||
/* round down to the nearest frame size, because we
|
||||
must not pass partial frames to
|
||||
DecoderClient::SubmitData() */
|
||||
r.size -= r.size % in_frame_size;
|
||||
buffer.Consume(r.size);
|
||||
r = r.first(r.size() - r.size() % in_frame_size);
|
||||
buffer.Consume(r.size());
|
||||
|
||||
if (reverse_endian)
|
||||
/* make sure we deliver samples in host byte order */
|
||||
reverse_bytes_16((uint16_t *)r.data,
|
||||
(uint16_t *)r.data,
|
||||
(uint16_t *)(r.data + r.size));
|
||||
reverse_bytes_16((uint16_t *)r.data(),
|
||||
(uint16_t *)r.data(),
|
||||
(uint16_t *)(r.data() + r.size()));
|
||||
else if (l24) {
|
||||
/* convert big-endian packed 24 bit
|
||||
(audio/L24) to native-endian 24 bit (in 32
|
||||
bit integers) */
|
||||
pcm_unpack_24be(unpack_buffer, r.begin(), r.end());
|
||||
r.data = (uint8_t *)&unpack_buffer[0];
|
||||
r.size = (r.size / 3) * 4;
|
||||
pcm_unpack_24be(unpack_buffer,
|
||||
r.data(), r.data() + r.size());
|
||||
r = {
|
||||
(uint8_t *)&unpack_buffer[0],
|
||||
(r.size() / 3) * 4,
|
||||
};
|
||||
}
|
||||
|
||||
cmd = !r.empty()
|
||||
? client.SubmitData(is, r.data, r.size, 0)
|
||||
? client.SubmitData(is, r.data(), r.size(), 0)
|
||||
: client.GetCommand();
|
||||
if (cmd == DecoderCommand::SEEK) {
|
||||
uint64_t frame = client.GetSeekFrame();
|
||||
|
Reference in New Issue
Block a user