decoder/Client: pass std::span to SubmitData()

This commit is contained in:
Max Kellermann
2022-07-11 18:03:06 +02:00
parent 329c448d30
commit c34f6ed8c0
30 changed files with 138 additions and 116 deletions

View File

@@ -63,23 +63,21 @@ ChromaprintDecoderClient::Ready(AudioFormat audio_format, bool,
}
DecoderCommand
ChromaprintDecoderClient::SubmitData(InputStream *,
const void *_data, size_t length,
uint16_t) noexcept
ChromaprintDecoderClient::SubmitAudio(InputStream *,
std::span<const std::byte> audio,
uint16_t) noexcept
{
assert(ready);
if (length > remaining_bytes)
if (audio.size() > remaining_bytes)
remaining_bytes = 0;
else
remaining_bytes -= length;
std::span<const std::byte> src{(const std::byte *)_data, length};
remaining_bytes -= audio.size();
if (convert)
src = convert->Convert(src);
audio = convert->Convert(audio);
chromaprint.Feed(FromBytesStrict<const int16_t>(src));
chromaprint.Feed(FromBytesStrict<const int16_t>(audio));
return GetCommand();
}

View File

@@ -93,9 +93,9 @@ public:
void *buffer, size_t length) noexcept override;
void SubmitTimestamp(FloatDuration) noexcept override {}
DecoderCommand SubmitData(InputStream *is,
const void *data, size_t length,
uint16_t kbit_rate) noexcept override;
DecoderCommand SubmitAudio(InputStream *is,
std::span<const std::byte> audio,
uint16_t kbit_rate) noexcept override;
DecoderCommand SubmitTag(InputStream *, Tag &&) noexcept override {
return GetCommand();