3 #include "globalwrap.hpp"
7 globalwrap
<std::list
<av_snooper
*>> snoopers
;
8 std::list
<av_snooper::dump_notification
*> notifiers
;
9 std::string s_gamename
;
10 std::string s_rerecords
;
12 std::list
<std::pair
<std::string
, std::string
>> s_authors
;
18 av_snooper::av_snooper() throw(std::bad_alloc
)
20 snoopers().push_back(this);
21 for(auto i
: notifiers
)
25 av_snooper::~av_snooper() throw()
27 for(auto i
= snoopers().begin(); i
!= snoopers().end(); i
++)
32 for(auto i
: notifiers
)
36 void av_snooper::set_sound_rate(uint32_t rate_n
, uint32_t rate_d
)
40 uint32_t g
= gcd(srate_n
, srate_d
);
45 std::pair
<uint32_t, uint32_t> av_snooper::get_sound_rate()
47 return std::make_pair(srate_n
, srate_d
);
50 void av_snooper::frame(struct lcscreen
& _frame
, uint32_t fps_n
, uint32_t fps_d
, bool dummy
) throw(std::bad_alloc
)
52 for(auto i
: snoopers())
54 i
->frame(_frame
, fps_n
, fps_d
);
55 } catch(std::bad_alloc
& e
) {
57 } catch(std::exception
& e
) {
59 messages
<< "Error dumping frame: " << e
.what() << std::endl
;
65 void av_snooper::sample(short l
, short r
, bool dummy
) throw(std::bad_alloc
)
67 for(auto i
: snoopers())
70 } catch(std::bad_alloc
& e
) {
72 } catch(std::exception
& e
) {
74 messages
<< "Error dumping sample: " << e
.what() << std::endl
;
80 void av_snooper::end(bool dummy
) throw(std::bad_alloc
)
82 for(auto i
: snoopers())
85 } catch(std::bad_alloc
& e
) {
87 } catch(std::exception
& e
) {
89 messages
<< "Error ending dump: " << e
.what() << std::endl
;
95 void av_snooper::gameinfo(const std::string
& gamename
, const std::list
<std::pair
<std::string
, std::string
>>&
96 authors
, double gametime
, const std::string
& rerecords
, bool dummy
) throw(std::bad_alloc
)
98 s_gamename
= gamename
;
100 s_gametime
= gametime
;
101 s_rerecords
= rerecords
;
103 for(auto i
: snoopers())
107 void av_snooper::send_gameinfo() throw()
111 gameinfo(s_gamename
, s_authors
, s_gametime
, s_rerecords
);
116 bool av_snooper::dump_in_progress() throw()
118 return !snoopers().empty();
121 av_snooper::dump_notification::~dump_notification() throw()
125 void av_snooper::dump_notification::dump_starting() throw()
129 void av_snooper::dump_notification::dump_ending() throw()
133 void av_snooper::add_dump_notifier(av_snooper::dump_notification
& notifier
) throw(std::bad_alloc
)
135 notifiers
.push_back(¬ifier
);
138 void av_snooper::remove_dump_notifier(av_snooper::dump_notification
& notifier
) throw()
140 for(auto i
= notifiers
.begin(); i
!= notifiers
.end(); i
++)
141 if(*i
== ¬ifier
) {