more audio BS

This commit is contained in:
Ryzerth 2021-04-02 18:40:57 +02:00
parent 7b6d0c1acd
commit aeab33127d

View File

@ -180,45 +180,4 @@ namespace dsp {
};
template <class T>
class Throttle : public generic_block<Throttle<T>> {
public:
Throttle() {}
Throttle(stream<T>* in) { init(in); }
void init(stream<T>* in) {
_in = in;
generic_block<Throttle>::registerInput(_in);
}
void setInput(stream<T>* in) {
std::lock_guard<std::mutex> lck(generic_block<Throttle>::ctrlMtx);
generic_block<Throttle>::tempStop();
generic_block<Throttle>::unregisterInput(_in);
_in = in;
generic_block<Throttle>::registerInput(_in);
generic_block<Throttle>::tempStart();
}
stream<T> out;
private:
int run() {
// TODO: If too slow, buffering might be necessary
int count = _in->read();
if (count < 0) { return -1; }
auto now = std::chrono::high_resolution_clock::now();
_in->flush();
out.swap(count);
return count;
}
std::chrono::time_point<std::chrono::high_resolution_clock> last;
stream<T>* _in;
};
}