aboutsummaryrefslogtreecommitdiffstats
path: root/src/wav.h
diff options
context:
space:
mode:
authorDaniil Cherednik <dan.cherednik@gmail.com>2024-08-19 23:41:16 +0200
committerDaniil Cherednik <dan.cherednik@gmail.com>2024-08-19 23:41:16 +0200
commit88deefbaecdbf6cfd9e74826b3962dc607c44f78 (patch)
tree077e950aa4ba6df65fc0e179e9e469906f2063d9 /src/wav.h
parenta62963044e8d9230375c2f8b7022fa017616fe9f (diff)
downloadatracdenc-88deefbaecdbf6cfd9e74826b3962dc607c44f78.tar.gz
Possibility to "look ahead" during encoding
Diffstat (limited to 'src/wav.h')
-rw-r--r--src/wav.h15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/wav.h b/src/wav.h
index e3daf7d..55e6d38 100644
--- a/src/wav.h
+++ b/src/wav.h
@@ -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;
});
}