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
;
16 av_snooper::av_snooper() throw(std::bad_alloc
)
18 snoopers().push_back(this);
19 for(auto i
= notifiers
.begin(); i
!= notifiers
.end(); i
++)
20 (*i
)->dump_starting();
23 av_snooper::~av_snooper() throw()
25 for(auto i
= snoopers().begin(); i
!= snoopers().end(); i
++)
30 for(auto i
= notifiers
.begin(); i
!= notifiers
.end(); i
++)
34 void av_snooper::frame(struct lcscreen
& _frame
, uint32_t fps_n
, uint32_t fps_d
, bool dummy
) throw(std::bad_alloc
)
36 for(auto i
= snoopers().begin(); i
!= snoopers().end(); i
++)
38 (*i
)->frame(_frame
, fps_n
, fps_d
);
39 } catch(std::bad_alloc
& e
) {
41 } catch(std::exception
& e
) {
43 messages
<< "Error dumping frame: " << e
.what() << std::endl
;
49 void av_snooper::sample(short l
, short r
, bool dummy
) throw(std::bad_alloc
)
51 for(auto i
= snoopers().begin(); i
!= snoopers().end(); i
++)
54 } catch(std::bad_alloc
& e
) {
56 } catch(std::exception
& e
) {
58 messages
<< "Error dumping sample: " << e
.what() << std::endl
;
64 void av_snooper::end(bool dummy
) throw(std::bad_alloc
)
66 for(auto i
= snoopers().begin(); i
!= snoopers().end(); i
++)
69 } catch(std::bad_alloc
& e
) {
71 } catch(std::exception
& e
) {
73 messages
<< "Error ending dump: " << e
.what() << std::endl
;
79 void av_snooper::gameinfo(const std::string
& gamename
, const std::list
<std::pair
<std::string
, std::string
>>&
80 authors
, double gametime
, const std::string
& rerecords
, bool dummy
) throw(std::bad_alloc
)
82 s_gamename
= gamename
;
84 s_gametime
= gametime
;
85 s_rerecords
= rerecords
;
87 for(auto i
= snoopers().begin(); i
!= snoopers().end(); i
++)
88 (*i
)->send_gameinfo();
91 void av_snooper::send_gameinfo() throw()
95 gameinfo(s_gamename
, s_authors
, s_gametime
, s_rerecords
);
100 bool av_snooper::dump_in_progress() throw()
102 return !snoopers().empty();
105 av_snooper::dump_notification::~dump_notification() throw()
109 void av_snooper::dump_notification::dump_starting() throw()
113 void av_snooper::dump_notification::dump_ending() throw()
117 void av_snooper::add_dump_notifier(av_snooper::dump_notification
& notifier
) throw(std::bad_alloc
)
119 notifiers
.push_back(¬ifier
);
122 void av_snooper::remove_dump_notifier(av_snooper::dump_notification
& notifier
) throw()
124 for(auto i
= notifiers
.begin(); i
!= notifiers
.end(); i
++)
125 if(*i
== ¬ifier
) {