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 "circular_buffer.hh"
9#include "Poller.hh"
10#include <cstdint>
11#include <mutex>
12#include <thread>
13
14namespace openmsx {
15
16class EventDistributor;
17class Scheduler;
18class CommandController;
19
20class MidiInReader final : public MidiInDevice, private EventListener
21{
22public:
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 [[nodiscard]] std::string_view getName() const override;
31 [[nodiscard]] 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
39private:
40 void run();
41
42 // EventListener
43 int signalEvent(const Event& event) override;
44
45private:
46 EventDistributor& eventDistributor;
47 Scheduler& scheduler;
48 std::thread thread;
51 std::mutex mutex; // to protect queue
52 Poller poller;
53
54 FilenameSetting readFilenameSetting;
55};
56
57} // namespace openmsx
58
59#endif
This implements a queue on top of circular_buffer (not part of boost).
Represents something you can plug devices into.
Definition Connector.hh:21
void serialize(Archive &ar, unsigned version)
std::string_view getName() const override
Name used to identify this pluggable.
void plugHelper(Connector &connector, EmuTime::param time) override
std::string_view getDescription() const override
Description for this pluggable.
void unplugHelper(EmuTime::param time) override
void signal(EmuTime::param time) override
Polls for events on a given file descriptor.
Definition Poller.hh:15
std::unique_ptr< FILE, FClose > FILE_t
This file implemented 3 utility functions:
Definition Autofire.cc:9
std::variant< KeyUpEvent, KeyDownEvent, MouseMotionEvent, MouseButtonUpEvent, MouseButtonDownEvent, MouseWheelEvent, JoystickAxisMotionEvent, JoystickHatEvent, JoystickButtonUpEvent, JoystickButtonDownEvent, OsdControlReleaseEvent, OsdControlPressEvent, WindowEvent, TextEvent, FileDropEvent, QuitEvent, FinishFrameEvent, CliCommandEvent, GroupEvent, BootEvent, FrameDrawnEvent, BreakEvent, SwitchRendererEvent, TakeReverseSnapshotEvent, AfterTimedEvent, MachineLoadedEvent, MachineActivatedEvent, MachineDeactivatedEvent, MidiInReaderEvent, MidiInWindowsEvent, MidiInCoreMidiEvent, MidiInCoreMidiVirtualEvent, MidiInALSAEvent, Rs232TesterEvent, Rs232NetEvent, ImGuiDelayedActionEvent, ImGuiActiveEvent > Event
Definition Event.hh:454