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  std::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
openmsx::MidiInReader::signal
void signal(EmuTime::param time) override
Definition: MidiInReader.cc:101
openmsx.hh
openmsx::Scheduler
Definition: Scheduler.hh:33
openmsx::CommandController
Definition: CommandController.hh:17
openmsx::FileOperations::FILE_t
std::unique_ptr< FILE, FClose > FILE_t
Definition: FileOperations.hh:16
openmsx::FilenameSetting
Definition: FilenameSetting.hh:8
EventListener.hh
MidiInDevice.hh
openmsx::MidiInDevice
Definition: MidiInDevice.hh:8
openmsx::EventDistributor
Definition: EventDistributor.hh:16
openmsx::MidiInReader::getDescription
std::string_view getDescription() const override
Description for this pluggable.
Definition: MidiInReader.cc:64
cb_queue< byte >
openmsx::Poller
Polls for events on a given file descriptor.
Definition: Poller.hh:13
openmsx::MidiInReader::serialize
void serialize(Archive &ar, unsigned version)
Definition: MidiInReader.cc:136
FilenameSetting.hh
openmsx::MidiInReader::unplugHelper
void unplugHelper(EmuTime::param time) override
Definition: MidiInReader.cc:51
openmsx::MidiInReader
Definition: MidiInReader.hh:20
openmsx::EventListener
Definition: EventListener.hh:10
Poller.hh
FileOperations.hh
openmsx::MidiInReader::getName
const std::string & getName() const override
Name used to identify this pluggable.
Definition: MidiInReader.cc:58
openmsx::MidiInReader::plugHelper
void plugHelper(Connector &connector, EmuTime::param time) override
Definition: MidiInReader.cc:34
openmsx::MidiInReader::~MidiInReader
~MidiInReader() override
Definition: MidiInReader.cc:28
openmsx::Connector
Represents something you can plug devices into.
Definition: Connector.hh:20
openmsx::Scheduler
Scheduler
Definition: Scheduler.cc:133
openmsx::MidiInReader::MidiInReader
MidiInReader(EventDistributor &eventDistributor, Scheduler &scheduler, CommandController &commandController)
Definition: MidiInReader.cc:16
circular_buffer.hh
openmsx
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5