diff options
author | Daniil Cherednik <dan.cherednik@gmail.com> | 2024-08-19 23:41:16 +0200 |
---|---|---|
committer | Daniil Cherednik <dan.cherednik@gmail.com> | 2024-08-19 23:41:16 +0200 |
commit | 88deefbaecdbf6cfd9e74826b3962dc607c44f78 (patch) | |
tree | 077e950aa4ba6df65fc0e179e9e469906f2063d9 /src/wav.h | |
parent | a62963044e8d9230375c2f8b7022fa017616fe9f (diff) | |
download | atracdenc-88deefbaecdbf6cfd9e74826b3962dc607c44f78.tar.gz |
Possibility to "look ahead" during encoding
Diffstat (limited to 'src/wav.h')
-rw-r--r-- | src/wav.h | 15 |
1 files changed, 7 insertions, 8 deletions
@@ -28,19 +28,16 @@ class TFileAlreadyExists : public std::exception { }; -class TNoDataToRead : public std::exception { -}; - template<class T> class TWavPcmReader : public IPCMReader<T> { public: - typedef std::function<void(TPCMBuffer<T>& data, const uint32_t size)> TLambda; + typedef std::function<bool(TPCMBuffer<T>& data, const uint32_t size)> TLambda; TLambda Lambda; TWavPcmReader(TLambda lambda) : Lambda(lambda) {} - void Read(TPCMBuffer<T>& data , const uint32_t size) const override { - Lambda(data, size); + bool Read(TPCMBuffer<T>& data , const uint32_t size) const override { + return Lambda(data, size); } }; @@ -93,17 +90,19 @@ typedef std::unique_ptr<TWav> TWavPtr; template<class T> IPCMReader<T>* TWav::GetPCMReader() const { - return new TWavPcmReader<T>([this](TPCMBuffer<T>& data, const uint32_t size) { + return new TWavPcmReader<T>([this](TPCMBuffer<T>& data, const uint32_t size) -> bool { if (data.Channels() != Impl->GetChannelsNum()) throw TWrongReadBuffer(); size_t read; if ((read = Impl->Read(data, size)) != size) { if (!read) - throw TNoDataToRead(); + return false; data.Zero(read, size - read); } + + return true; }); } |