aboutsummaryrefslogtreecommitdiffstats
path: root/src/wav.h
diff options
context:
space:
mode:
authorDaniil Cherednik <dan.cherednik@gmail.com>2019-12-09 00:37:23 +0300
committerDaniil Cherednik <dan.cherednik@gmail.com>2019-12-09 00:37:23 +0300
commitb58f4dd8353121094acdb41ad96fbdec4a580d79 (patch)
treeeb15d93b4ed63729541bf19cdea95f4389e1c0de /src/wav.h
parent8b0e9c515ec0872bd24ea4563a733ca743fe7d1f (diff)
downloadatracdenc-b58f4dd8353121094acdb41ad96fbdec4a580d79.tar.gz
Stop encoding if case of pipe input and no writer
Diffstat (limited to 'src/wav.h')
-rw-r--r--src/wav.h24
1 files changed, 7 insertions, 17 deletions
diff --git a/src/wav.h b/src/wav.h
index 06c6bfe..e3daf7d 100644
--- a/src/wav.h
+++ b/src/wav.h
@@ -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);
}
});