Evdev joystick plugin
[lsnes.git] / generic / avsnoop.hpp
blob039a6cafd039f6bb374cae79129a9c4b6577001a
1 #ifndef _avsnoop__hpp__included__
2 #define _avsnoop__hpp__included__
4 #include "render.hpp"
5 #include <list>
6 #include <string>
7 #include <stdexcept>
9 /**
10 * A/V snooper. A/V snoopers allow code to snoop on audio samples and video frames, usually for purpose of dumping
11 * them to video file.
13 class av_snooper
15 public:
16 /**
17 * Create new A/V snooper.
19 * throws std::bad_alloc: Not enough memory.
21 av_snooper() throw(std::bad_alloc);
23 /**
24 * Destroy A/V snooper. This will not call end method.
26 ~av_snooper() throw();
28 /**
29 * Dump a frame.
31 * parameter _frame: The frame to dump.
32 * parameter fps_n: Current fps numerator.
33 * parameter fps_d: Current fps denomerator.
34 * throws std::bad_alloc: Not enough memory.
35 * throws std::runtime_error: Error dumping frame.
37 virtual void frame(struct lcscreen& _frame, uint32_t fps_n, uint32_t fps_d) throw(std::bad_alloc,
38 std::runtime_error) = 0;
40 /**
41 * Call frame() on all known A/V snoopers.
43 * parameter _frame: The frame to dump.
44 * parameter fps_n: Current fps numerator.
45 * parameter fps_d: Current fps denomerator.
46 * throws std::bad_alloc: Not enough memory.
48 static void frame(struct lcscreen& _frame, uint32_t fps_n, uint32_t fps_d, bool dummy)
49 throw(std::bad_alloc);
51 /**
52 * Dump a sample.
54 * parameter l: Left channel sample.
55 * parameter r: Right channel sample.
56 * throws std::bad_alloc: Not enough memory.
57 * throws std::runtime_error: Error dumping sample.
59 virtual void sample(short l, short r) throw(std::bad_alloc, std::runtime_error) = 0;
61 /**
62 * Call sample() on all known A/V snoopers.
64 * parameter l: Left channel sample.
65 * parameter r: Right channel sample.
66 * throws std::bad_alloc: Not enough memory.
68 static void sample(short l, short r, bool dummy) throw(std::bad_alloc);
70 /**
71 * End dump.
73 * throws std::bad_alloc: Not enough memory.
74 * throws std::runtime_error: Error dumping sample.
76 virtual void end() throw(std::bad_alloc, std::runtime_error) = 0;
78 /**
79 * Set sound rate.
82 /**
83 * Call end() on all known A/V snoopers.
85 * throws std::bad_alloc: Not enough memory.
87 static void end(bool dummy) throw(std::bad_alloc);
89 /**
90 * Set sound sampling rate.
92 * parameter rate_n: Numerator of sampling rate.
93 * parameter rate_d: Denomerator of sampling rate.
95 static void set_sound_rate(uint32_t rate_n, uint32_t rate_d);
97 /**
98 * Get sound sampling rate.
100 std::pair<uint32_t, uint32_t> get_sound_rate();
103 * Notify game information.
105 * parameter gamename: Name of the game.
106 * parameter authors: Authors of the run.
107 * parameter gametime: Game time.
108 * parameter rercords: Rerecord count.
109 * throws std::bad_alloc: Not enough memory.
110 * throws std::runtime_error: Error recording this info.
112 virtual void gameinfo(const std::string& gamename, const std::list<std::pair<std::string, std::string>>&
113 authors, double gametime, const std::string& rerecords) throw(std::bad_alloc, std::runtime_error) = 0;
116 * Call gameinfo() on all known A/V snoopers. Also records the gameinfo.
118 * parameter gamename: Name of the game.
119 * parameter authors: Authors of the run.
120 * parameter gametime: Game time.
121 * parameter rercords: Rerecord count.
122 * throws std::bad_alloc Not enough memory.
124 static void gameinfo(const std::string& gamename, const std::list<std::pair<std::string, std::string>>&
125 authors, double gametime, const std::string& rerecords, bool dummy) throw(std::bad_alloc);
128 * Send game info. If av_snooper::gameinfo() has been called, this causes gameinfo() method of this object to be
129 * called with previously recorded information.
131 void send_gameinfo() throw();
134 * Is there at least one known A/V snooper?
136 * returns: True if there is at least one known A/V snooper, false if there are none.
138 static bool dump_in_progress() throw();
141 * Notifier for dumps starting/ending.
143 class dump_notification
145 public:
147 * Destructor.
149 virtual ~dump_notification() throw();
151 * Called on new dump starting.
153 virtual void dump_starting() throw();
155 * Called on dump ending.
157 virtual void dump_ending() throw();
161 * Add a notifier for dumps starting/ending.
163 * parameter notifier: New notifier to add.
165 static void add_dump_notifier(dump_notification& notifier) throw(std::bad_alloc);
168 * Remove a notifier for dumps starting/ending.
170 * parameter notifier: Existing notifier to remove.
172 static void remove_dump_notifier(dump_notification& notifier) throw();
175 #endif