mirror of
https://github.com/AlexandreRouma/SDRPlusPlus.git
synced 2025-01-12 19:27:11 +01:00
more audio BS
This commit is contained in:
parent
7b6d0c1acd
commit
aeab33127d
@ -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;
|
|
||||||
};
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user