encoder/interface: make Read() `noexcept` (all implementations are)

This commit is contained in:
Max Kellermann 2022-07-12 10:04:17 +02:00
parent 31d89b36cf
commit e861d4f83d
5 changed files with 8 additions and 14 deletions

View File

@ -102,7 +102,7 @@ public:
* @param length the maximum length of the destination buffer
* @return the number of bytes written to #dest
*/
virtual std::size_t Read(void *dest, std::size_t length) = 0;
virtual std::size_t Read(void *dest, std::size_t length) noexcept = 0;
};
class PreparedEncoder {

View File

@ -33,7 +33,7 @@ public:
buffer.Append({(const std::byte *)data, length});
}
size_t Read(void *dest, size_t length) override {
size_t Read(void *dest, size_t length) noexcept override {
return buffer.Read((std::byte *)dest, length);
}
};

View File

@ -233,7 +233,7 @@ public:
* Reads data from the encoder (as much as available) and
* returns it as a new #page object.
*/
PagePtr ReadPage();
PagePtr ReadPage() noexcept;
/**
* Broadcasts a page struct to all clients.
@ -247,7 +247,7 @@ public:
*
* Mutext must not be locked.
*/
void BroadcastFromEncoder();
void BroadcastFromEncoder() noexcept;
/**
* Mutext must not be locked.

View File

@ -142,7 +142,7 @@ HttpdOutput::OnAccept(UniqueSocketDescriptor fd,
}
PagePtr
HttpdOutput::ReadPage()
HttpdOutput::ReadPage() noexcept
{
if (unflushed_input >= 65536) {
/* we have fed a lot of input into the encoder, but it
@ -277,7 +277,7 @@ HttpdOutput::BroadcastPage(PagePtr page) noexcept
}
void
HttpdOutput::BroadcastFromEncoder()
HttpdOutput::BroadcastFromEncoder() noexcept
{
/* synchronize with the IOThread */
{

View File

@ -124,7 +124,7 @@ SnapcastOutput::OnAccept(UniqueSocketDescriptor fd,
}
static AllocatedArray<std::byte>
ReadEncoder(Encoder &encoder)
ReadEncoder(Encoder &encoder) noexcept
{
std::byte buffer[4096];
@ -137,13 +137,7 @@ inline void
SnapcastOutput::OpenEncoder(AudioFormat &audio_format)
{
encoder = prepared_encoder->Open(audio_format);
try {
codec_header = ReadEncoder(*encoder);
} catch (...) {
delete encoder;
throw;
}
codec_header = ReadEncoder(*encoder);
unflushed_input = 0;
}