input/InputStream: pass std::span<std::byte> to Read()
This commit is contained in:
@@ -84,7 +84,7 @@ class CdioParanoiaInputStream final : public InputStream {
|
||||
/* virtual methods from InputStream */
|
||||
[[nodiscard]] bool IsEOF() const noexcept override;
|
||||
size_t Read(std::unique_lock<Mutex> &lock,
|
||||
void *ptr, size_t size) override;
|
||||
std::span<std::byte> dest) override;
|
||||
void Seek(std::unique_lock<Mutex> &lock, offset_type offset) override;
|
||||
};
|
||||
|
||||
@@ -305,7 +305,7 @@ CdioParanoiaInputStream::Seek(std::unique_lock<Mutex> &,
|
||||
|
||||
size_t
|
||||
CdioParanoiaInputStream::Read(std::unique_lock<Mutex> &,
|
||||
void *ptr, size_t length)
|
||||
std::span<std::byte> dest)
|
||||
{
|
||||
/* end of track ? */
|
||||
if (IsEOF())
|
||||
@@ -342,10 +342,10 @@ CdioParanoiaInputStream::Read(std::unique_lock<Mutex> &,
|
||||
}
|
||||
|
||||
const size_t maxwrite = CDIO_CD_FRAMESIZE_RAW - diff; //# of bytes pending in current buffer
|
||||
const std::size_t nbytes = std::min(length, maxwrite);
|
||||
const std::size_t nbytes = std::min(dest.size(), maxwrite);
|
||||
|
||||
//skip diff bytes from this lsn
|
||||
memcpy(ptr, ((const char *)rbuf) + diff, nbytes);
|
||||
memcpy(dest.data(), ((const char *)rbuf) + diff, nbytes);
|
||||
|
||||
//update offset
|
||||
offset += nbytes;
|
||||
|
||||
@@ -34,7 +34,7 @@ public:
|
||||
/* virtual methods from InputStream */
|
||||
[[nodiscard]] bool IsEOF() const noexcept override;
|
||||
size_t Read(std::unique_lock<Mutex> &lock,
|
||||
void *ptr, size_t size) override;
|
||||
std::span<std::byte> dest) override;
|
||||
void Seek(std::unique_lock<Mutex> &lock,
|
||||
offset_type offset) override;
|
||||
};
|
||||
@@ -91,13 +91,13 @@ input_ffmpeg_open(const char *uri,
|
||||
|
||||
size_t
|
||||
FfmpegInputStream::Read(std::unique_lock<Mutex> &,
|
||||
void *ptr, size_t read_size)
|
||||
std::span<std::byte> dest)
|
||||
{
|
||||
size_t result;
|
||||
|
||||
{
|
||||
const ScopeUnlock unlock(mutex);
|
||||
result = io.Read(ptr, read_size);
|
||||
result = io.Read(dest);
|
||||
}
|
||||
|
||||
offset += result;
|
||||
|
||||
@@ -33,7 +33,7 @@ public:
|
||||
}
|
||||
|
||||
size_t Read(std::unique_lock<Mutex> &lock,
|
||||
void *ptr, size_t size) override;
|
||||
std::span<std::byte> dest) override;
|
||||
void Seek(std::unique_lock<Mutex> &lock,
|
||||
offset_type offset) override;
|
||||
};
|
||||
@@ -71,14 +71,13 @@ FileInputStream::Seek(std::unique_lock<Mutex> &,
|
||||
}
|
||||
|
||||
size_t
|
||||
FileInputStream::Read(std::unique_lock<Mutex> &,
|
||||
void *ptr, size_t read_size)
|
||||
FileInputStream::Read(std::unique_lock<Mutex> &, std::span<std::byte> dest)
|
||||
{
|
||||
size_t nbytes;
|
||||
|
||||
{
|
||||
const ScopeUnlock unlock(mutex);
|
||||
nbytes = reader.Read({static_cast<std::byte *>(ptr), read_size});
|
||||
nbytes = reader.Read(dest);
|
||||
}
|
||||
|
||||
if (nbytes == 0 && !IsEOF())
|
||||
|
||||
@@ -40,7 +40,7 @@ public:
|
||||
}
|
||||
|
||||
size_t Read(std::unique_lock<Mutex> &lock,
|
||||
void *ptr, size_t size) override;
|
||||
std::span<std::byte> dest) override;
|
||||
void Seek(std::unique_lock<Mutex> &lock, offset_type offset) override;
|
||||
};
|
||||
|
||||
@@ -88,13 +88,13 @@ input_smbclient_open(const char *uri,
|
||||
|
||||
size_t
|
||||
SmbclientInputStream::Read(std::unique_lock<Mutex> &,
|
||||
void *ptr, size_t read_size)
|
||||
std::span<std::byte> dest)
|
||||
{
|
||||
ssize_t nbytes;
|
||||
|
||||
{
|
||||
const ScopeUnlock unlock(mutex);
|
||||
nbytes = ctx.Read(handle, ptr, read_size);
|
||||
nbytes = ctx.Read(handle, dest.data(), dest.size());
|
||||
}
|
||||
|
||||
if (nbytes < 0)
|
||||
|
||||
Reference in New Issue
Block a user