diff options
author | Daniil Cherednik <dan.cherednik@gmail.com> | 2019-12-09 00:37:23 +0300 |
---|---|---|
committer | Daniil Cherednik <dan.cherednik@gmail.com> | 2019-12-09 00:37:23 +0300 |
commit | b58f4dd8353121094acdb41ad96fbdec4a580d79 (patch) | |
tree | eb15d93b4ed63729541bf19cdea95f4389e1c0de /src/wav.h | |
parent | 8b0e9c515ec0872bd24ea4563a733ca743fe7d1f (diff) | |
download | atracdenc-b58f4dd8353121094acdb41ad96fbdec4a580d79.tar.gz |
Stop encoding if case of pipe input and no writer
Diffstat (limited to 'src/wav.h')
-rw-r--r-- | src/wav.h | 24 |
1 files changed, 7 insertions, 17 deletions
@@ -26,22 +26,9 @@ #include "pcmengin.h" class TFileAlreadyExists : public std::exception { - }; -class TWavIOError : public std::exception { - const int ErrNum = 0; - const char* Text; -public: - TWavIOError(const char* str, int err) - : ErrNum(err) - , Text(str) - { - (void)ErrNum; - } - virtual const char* what() const throw() { - return Text; - } +class TNoDataToRead : public std::exception { }; template<class T> @@ -109,9 +96,12 @@ IPCMReader<T>* TWav::GetPCMReader() const { return new TWavPcmReader<T>([this](TPCMBuffer<T>& data, const uint32_t size) { if (data.Channels() != Impl->GetChannelsNum()) throw TWrongReadBuffer(); - if (size_t read = Impl->Read(data, size) != size) { - assert(read < size); - //fprintf(stderr, "to zero: %d\n", size-read); + + size_t read; + if ((read = Impl->Read(data, size)) != size) { + if (!read) + throw TNoDataToRead(); + data.Zero(read, size - read); } }); |