openMSX
MidiInReader.hh
Go to the documentation of this file.
1 #ifndef MIDIINREADER_HH
2 #define MIDIINREADER_HH
3 
4 #include "MidiInDevice.hh"
5 #include "EventListener.hh"
6 #include "FilenameSetting.hh"
7 #include "FileOperations.hh"
8 #include "openmsx.hh"
9 #include "circular_buffer.hh"
10 #include "Poller.hh"
11 #include <mutex>
12 #include <thread>
13 
14 namespace openmsx {
15 
16 class EventDistributor;
17 class Scheduler;
18 class CommandController;
19 
20 class MidiInReader final : public MidiInDevice, private EventListener
21 {
22 public:
23  MidiInReader(EventDistributor& eventDistributor, Scheduler& scheduler,
24  CommandController& commandController);
25  ~MidiInReader() override;
26 
27  // Pluggable
28  void plugHelper(Connector& connector, EmuTime::param time) override;
29  void unplugHelper(EmuTime::param time) override;
30  const std::string& getName() const override;
31  string_view getDescription() const override;
32 
33  // MidiInDevice
34  void signal(EmuTime::param time) override;
35 
36  template<typename Archive>
37  void serialize(Archive& ar, unsigned version);
38 
39 private:
40  void run();
41 
42  // EventListener
43  int signalEvent(const std::shared_ptr<const Event>& event) override;
44 
45  EventDistributor& eventDistributor;
46  Scheduler& scheduler;
47  std::thread thread;
49  cb_queue<byte> queue;
50  std::mutex mutex; // to protect queue
51  Poller poller;
52 
53  FilenameSetting readFilenameSetting;
54 };
55 
56 } // namespace openmsx
57 
58 #endif
MidiInReader(EventDistributor &eventDistributor, Scheduler &scheduler, CommandController &commandController)
Definition: MidiInReader.cc:16
Represents something you can plug devices into.
Definition: Connector.hh:20
~MidiInReader() override
Definition: MidiInReader.cc:28
void signal(EmuTime::param time) override
string_view getDescription() const override
Description for this pluggable.
Definition: MidiInReader.cc:64
void unplugHelper(EmuTime::param time) override
Definition: MidiInReader.cc:51
void serialize(Archive &ar, unsigned version)
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5
const std::string & getName() const override
Name used to identify this pluggable.
Definition: MidiInReader.cc:58
This class implements a (close approximation) of the std::string_view class.
Definition: string_view.hh:16
Polls for events on a given file descriptor.
Definition: Poller.hh:13
void plugHelper(Connector &connector, EmuTime::param time) override
Definition: MidiInReader.cc:34
std::unique_ptr< FILE, FClose > FILE_t