OXYGENHUB
◆ main openmsx / src / sound / ResampleAlgo.hh
839 B · C++ · last changed chore(): initial commit 1 month ago source blame history raw
1
#ifndef RESAMPLEALGO_HH
2
#define RESAMPLEALGO_HH
3
4
#include "EmuTime.hh"
5
#include "ResampledSoundDevice.hh"
6
7
namespace openmsx {
8
9
class DynamicClock;
10
11
class ResampleAlgo
12
{
13
public:
14
	virtual ~ResampleAlgo() = default;
15
16
	bool generateOutput(float* dataOut, size_t num, EmuTime time)
17
	{
18
		bool result = generateOutputImpl(dataOut, num, time);
19
		const auto& emuClk = getEmuClock(); (void)emuClk;
20
		assert(emuClk.getTime() <= time);
21
		assert(emuClk.getFastAdd(1) > time);
22
		return result;
23
	}
24
25
protected:
26
	explicit ResampleAlgo(ResampledSoundDevice& input_) : input(input_) {}
27
	[[nodiscard]] DynamicClock& getEmuClock() const { return input.getEmuClock(); }
28
	virtual bool generateOutputImpl(float* dataOut, size_t num,
29
	                                EmuTime time) = 0;
30
31
protected:
32
	ResampledSoundDevice& input;
33
};
34
35
} // namespace openmsx
36
37
#endif