|
1
|
1 #include "foobar2000-sdk-pch.h"
|
|
|
2 #include "packet_decoder.h"
|
|
|
3 #include <exception>
|
|
|
4
|
|
|
5 void packet_decoder::g_open(service_ptr_t<packet_decoder> & p_out,bool p_decode,const GUID & p_owner,t_size p_param1,const void * p_param2,t_size p_param2size,abort_callback & p_abort)
|
|
|
6 {
|
|
|
7 std::exception_ptr rethrow;
|
|
|
8 bool havePartial = false, tryingPartial = false;
|
|
|
9 for ( ;; ) {
|
|
|
10 for (auto ptr : packet_decoder_entry::enumerate()) {
|
|
|
11 p_abort.check();
|
|
|
12 if (ptr->is_our_setup(p_owner, p_param1, p_param2, p_param2size)) {
|
|
|
13 if (!tryingPartial && ptr->is_supported_partially_(p_owner, p_param1, p_param2, p_param2size)) {
|
|
|
14 havePartial = true;
|
|
|
15 } else {
|
|
|
16 try {
|
|
|
17 ptr->open(p_out, p_decode, p_owner, p_param1, p_param2, p_param2size, p_abort);
|
|
|
18 return;
|
|
|
19 } catch (exception_io_data const &) {
|
|
|
20 rethrow = std::current_exception();
|
|
|
21 }
|
|
|
22 }
|
|
|
23 }
|
|
|
24 }
|
|
|
25
|
|
|
26 if (!havePartial || tryingPartial) break;
|
|
|
27 tryingPartial = true;
|
|
|
28 }
|
|
|
29
|
|
|
30 if (rethrow) std::rethrow_exception(rethrow);
|
|
|
31 throw exception_io_data();
|
|
|
32 }
|
|
|
33
|
|
|
34 size_t packet_decoder::initPadding() {
|
|
|
35 size_t v = this->set_stream_property(property_bufferpadding, 0, NULL, 0);
|
|
|
36 if (v > 0) {
|
|
|
37 this->set_stream_property(property_bufferpadding, v, NULL, 0);
|
|
|
38 }
|
|
|
39 return v;
|
|
|
40 }
|
|
|
41
|
|
|
42 void packet_decoder::setEventLogger(event_logger::ptr logger) {
|
|
|
43 this->set_stream_property(property_eventlogger, 0, logger.get_ptr(), 0);
|
|
|
44 }
|
|
|
45
|
|
|
46 void packet_decoder::setCheckingIntegrity(bool checkingIntegrity) {
|
|
|
47 this->set_stream_property(property_checkingintegrity, checkingIntegrity ? 1 : 0, NULL, 0);
|
|
|
48 }
|
|
|
49
|
|
|
50 void packet_decoder::setAllowDelayed( bool bAllow ) {
|
|
|
51 this->set_stream_property( property_allow_delayed_output, bAllow ? 1 : 0, NULL, 0);
|
|
|
52 }
|
|
|
53
|
|
|
54 bool packet_decoder_entry::is_supported_partially_(const GUID& p_owner, t_size p_param1, const void* p_param2, t_size p_param2size) {
|
|
|
55 bool ret = false;
|
|
|
56 packet_decoder_entry_v2::ptr v2;
|
|
|
57 if (v2 &= this) {
|
|
|
58 ret = v2->is_supported_partially(p_owner, p_param1, p_param2, p_param2size);
|
|
|
59 }
|
|
|
60 return ret;
|
|
|
61 }
|