| 1 |
|
| #include "EXTERN.h" |
| 2 |
|
| #include "perl.h" |
| 3 |
|
| #include "XSUB.h" |
| 4 |
|
| |
| 5 |
|
| #include "ppport.h" |
| 6 |
|
| |
| 7 |
|
| #include "saleaeinterface.h" |
| 8 |
|
| |
| 9 |
|
| volatile int saleaeinterface_internal_verbosity = 0; |
| 10 |
|
| |
| 11 |
0 |
| void saleaeinterface_internal_on_connect(saleaeinterface_t *obj, unsigned int id) |
| 12 |
|
| { |
| 13 |
0 |
▶ | if (!obj || !obj->perl) |
Branch: 2 branches
| Branch | True | False | Total |
| if (!obj || !obj->perl) |
0 |
0 |
0 |
| if (!obj || !obj->perl) |
0 |
0 |
0 |
|
| 14 |
0 |
| return; |
| 15 |
0 |
| PERL_SET_CONTEXT(obj->perl); |
| 16 |
0 |
▶ | if (SvOK((SV *)obj->parent) && SvOK((SV *)obj->on_connect)) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (SvOK((SV *)obj->parent) && SvOK((SV *)obj->on_connect)) { |
0 |
0 |
0 |
| if (SvOK((SV *)obj->parent) && SvOK((SV *)obj->on_connect)) { |
0 |
0 |
0 |
|
| 17 |
0 |
| dSP; |
| 18 |
0 |
| ENTER; |
| 19 |
0 |
| SAVETMPS; |
| 20 |
0 |
▶ | PUSHMARK(SP); |
Branch: 1 branch
| Branch | True | False | Total |
| PUSHMARK(SP); |
0 |
0 |
0 |
|
| 21 |
0 |
▶ | XPUSHs((SV *)obj->parent); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs((SV *)obj->parent); |
0 |
0 |
0 |
|
| 22 |
0 |
▶ | XPUSHs(sv_2mortal(newSVuv(id))); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(newSVuv(id))); |
0 |
0 |
0 |
|
| 23 |
0 |
| PUTBACK; |
| 24 |
0 |
| call_sv((SV *)obj->on_connect, G_DISCARD); |
| 25 |
0 |
▶ | FREETMPS; |
Branch: 1 branch
| Branch | True | False | Total |
| FREETMPS; |
0 |
0 |
0 |
|
| 26 |
0 |
| LEAVE; |
| 27 |
|
| } |
| 28 |
|
| } |
| 29 |
0 |
| void saleaeinterface_internal_on_disconnect(saleaeinterface_t *obj, unsigned int id) |
| 30 |
|
| { |
| 31 |
0 |
▶ | if (!obj || !obj->perl) |
Branch: 2 branches
| Branch | True | False | Total |
| if (!obj || !obj->perl) |
0 |
0 |
0 |
| if (!obj || !obj->perl) |
0 |
0 |
0 |
|
| 32 |
0 |
| return; |
| 33 |
0 |
| PERL_SET_CONTEXT(obj->perl); |
| 34 |
0 |
▶ | if (SvOK((SV *)obj->parent) && SvOK((SV *)obj->on_disconnect)) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (SvOK((SV *)obj->parent) && SvOK((SV *)obj->on_disconnect)) { |
0 |
0 |
0 |
| if (SvOK((SV *)obj->parent) && SvOK((SV *)obj->on_disconnect)) { |
0 |
0 |
0 |
|
| 35 |
0 |
| dSP; |
| 36 |
0 |
| ENTER; |
| 37 |
0 |
| SAVETMPS; |
| 38 |
0 |
▶ | PUSHMARK(SP); |
Branch: 1 branch
| Branch | True | False | Total |
| PUSHMARK(SP); |
0 |
0 |
0 |
|
| 39 |
0 |
▶ | XPUSHs((SV *)obj->parent); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs((SV *)obj->parent); |
0 |
0 |
0 |
|
| 40 |
0 |
▶ | XPUSHs(sv_2mortal(newSVuv(id))); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(newSVuv(id))); |
0 |
0 |
0 |
|
| 41 |
0 |
| PUTBACK; |
| 42 |
0 |
| call_sv((SV *)obj->on_disconnect, G_DISCARD); |
| 43 |
0 |
▶ | FREETMPS; |
Branch: 1 branch
| Branch | True | False | Total |
| FREETMPS; |
0 |
0 |
0 |
|
| 44 |
0 |
| LEAVE; |
| 45 |
|
| } |
| 46 |
|
| } |
| 47 |
0 |
| void saleaeinterface_internal_on_error(saleaeinterface_t *obj, unsigned int id) |
| 48 |
|
| { |
| 49 |
0 |
▶ | if (!obj || !obj->perl) |
Branch: 2 branches
| Branch | True | False | Total |
| if (!obj || !obj->perl) |
0 |
0 |
0 |
| if (!obj || !obj->perl) |
0 |
0 |
0 |
|
| 50 |
0 |
| return; |
| 51 |
0 |
| PERL_SET_CONTEXT(obj->perl); |
| 52 |
0 |
▶ | if (SvOK((SV *)obj->parent) && SvOK((SV *)obj->on_error)) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (SvOK((SV *)obj->parent) && SvOK((SV *)obj->on_error)) { |
0 |
0 |
0 |
| if (SvOK((SV *)obj->parent) && SvOK((SV *)obj->on_error)) { |
0 |
0 |
0 |
|
| 53 |
0 |
| dSP; |
| 54 |
0 |
| ENTER; |
| 55 |
0 |
| SAVETMPS; |
| 56 |
0 |
▶ | PUSHMARK(SP); |
Branch: 1 branch
| Branch | True | False | Total |
| PUSHMARK(SP); |
0 |
0 |
0 |
|
| 57 |
0 |
▶ | XPUSHs((SV *)obj->parent); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs((SV *)obj->parent); |
0 |
0 |
0 |
|
| 58 |
0 |
▶ | XPUSHs(sv_2mortal(newSVuv(id))); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(newSVuv(id))); |
0 |
0 |
0 |
|
| 59 |
0 |
| PUTBACK; |
| 60 |
0 |
| call_sv((SV *)obj->on_error, G_DISCARD); |
| 61 |
0 |
▶ | FREETMPS; |
Branch: 1 branch
| Branch | True | False | Total |
| FREETMPS; |
0 |
0 |
0 |
|
| 62 |
0 |
| LEAVE; |
| 63 |
|
| } |
| 64 |
|
| } |
| 65 |
0 |
| void saleaeinterface_internal_on_readdata(saleaeinterface_t *obj, unsigned int id, |
| 66 |
|
| unsigned char *data, unsigned int len) |
| 67 |
|
| { |
| 68 |
0 |
▶ | if (!obj || !obj->perl) |
Branch: 2 branches
| Branch | True | False | Total |
| if (!obj || !obj->perl) |
0 |
0 |
0 |
| if (!obj || !obj->perl) |
0 |
0 |
0 |
|
| 69 |
0 |
| return; |
| 70 |
0 |
| PERL_SET_CONTEXT(obj->perl); |
| 71 |
0 |
▶ | if (SvOK((SV *)obj->parent) && SvOK((SV *)obj->on_readdata)) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (SvOK((SV *)obj->parent) && SvOK((SV *)obj->on_readdata)) { |
0 |
0 |
0 |
| if (SvOK((SV *)obj->parent) && SvOK((SV *)obj->on_readdata)) { |
0 |
0 |
0 |
|
| 72 |
0 |
| dSP; |
| 73 |
0 |
| ENTER; |
| 74 |
0 |
| SAVETMPS; |
| 75 |
0 |
▶ | PUSHMARK(SP); |
Branch: 1 branch
| Branch | True | False | Total |
| PUSHMARK(SP); |
0 |
0 |
0 |
|
| 76 |
0 |
▶ | XPUSHs((SV *)obj->parent); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs((SV *)obj->parent); |
0 |
0 |
0 |
|
| 77 |
0 |
▶ | XPUSHs(sv_2mortal(newSVuv(id))); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(newSVuv(id))); |
0 |
0 |
0 |
|
| 78 |
0 |
▶ | XPUSHs(sv_2mortal(newSVpvn(data, len))); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(newSVpvn(data, len))); |
0 |
0 |
0 |
|
| 79 |
0 |
▶ | XPUSHs(sv_2mortal(newSVuv(len))); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(newSVuv(len))); |
0 |
0 |
0 |
|
| 80 |
0 |
| PUTBACK; |
| 81 |
0 |
| call_sv((SV *)obj->on_readdata, G_DISCARD); |
| 82 |
0 |
▶ | FREETMPS; |
Branch: 1 branch
| Branch | True | False | Total |
| FREETMPS; |
0 |
0 |
0 |
|
| 83 |
0 |
| LEAVE; |
| 84 |
|
| } |
| 85 |
|
| } |
| 86 |
0 |
| void saleaeinterface_internal_on_writedata(saleaeinterface_t *obj, unsigned int id, |
| 87 |
|
| unsigned char *data, unsigned int len) |
| 88 |
|
| { |
| 89 |
0 |
▶ | if (!obj || !obj->perl) |
Branch: 2 branches
| Branch | True | False | Total |
| if (!obj || !obj->perl) |
0 |
0 |
0 |
| if (!obj || !obj->perl) |
0 |
0 |
0 |
|
| 90 |
0 |
| return; |
| 91 |
0 |
| PERL_SET_CONTEXT(obj->perl); |
| 92 |
0 |
▶ | if (SvOK((SV *)obj->parent) && SvOK((SV *)obj->on_writedata)) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (SvOK((SV *)obj->parent) && SvOK((SV *)obj->on_writedata)) { |
0 |
0 |
0 |
| if (SvOK((SV *)obj->parent) && SvOK((SV *)obj->on_writedata)) { |
0 |
0 |
0 |
|
| 93 |
0 |
| dSP; |
| 94 |
0 |
| ENTER; |
| 95 |
0 |
| SAVETMPS; |
| 96 |
0 |
▶ | PUSHMARK(SP); |
Branch: 1 branch
| Branch | True | False | Total |
| PUSHMARK(SP); |
0 |
0 |
0 |
|
| 97 |
|
| /* FIXME: this is a wrong implementation */ |
| 98 |
0 |
| SV *psv = newSV(0); |
| 99 |
0 |
| SvPVX(psv) = data; |
| 100 |
0 |
| SvCUR(psv) = len; |
| 101 |
0 |
| SvLEN(psv) = 0; |
| 102 |
0 |
▶ | XPUSHs((SV *)obj->parent); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs((SV *)obj->parent); |
0 |
0 |
0 |
|
| 103 |
0 |
▶ | XPUSHs(sv_2mortal(newSVuv(id))); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(newSVuv(id))); |
0 |
0 |
0 |
|
| 104 |
0 |
▶ | XPUSHs(psv); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(psv); |
0 |
0 |
0 |
|
| 105 |
0 |
▶ | XPUSHs(sv_2mortal(newSVuv(len))); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(newSVuv(len))); |
0 |
0 |
0 |
|
| 106 |
0 |
| PUTBACK; |
| 107 |
0 |
| call_sv((SV *)obj->on_writedata, G_DISCARD); |
| 108 |
0 |
▶ | FREETMPS; |
Branch: 1 branch
| Branch | True | False | Total |
| FREETMPS; |
0 |
0 |
0 |
|
| 109 |
0 |
| LEAVE; |
| 110 |
|
| } |
| 111 |
|
| } |
| 112 |
|
| |
| 113 |
|
| MODULE = Device::SaleaeLogic PACKAGE = Device::SaleaeLogic |
| 114 |
|
| |
| 115 |
|
| PROTOTYPES: ENABLE |
| 116 |
|
| |
| 117 |
|
| void |
| 118 |
|
| saleaeinterface_begin_connect(obj) |
| 119 |
|
| saleaeinterface_t *obj |
| 120 |
|
| |
| 121 |
|
| void |
| 122 |
|
| saleaeinterface_register_on_connect(obj, cb) |
| 123 |
|
| saleaeinterface_t *obj |
| 124 |
|
| SV* cb |
| 125 |
|
| CODE: |
| 126 |
|
| /* save a copy of the callback */ |
| 127 |
0 |
▶ | IAMHERE_ENTRY; |
Branch: 1 branch
| Branch | True | False | Total |
| IAMHERE_ENTRY; |
0 |
0 |
0 |
|
| 128 |
0 |
▶ | if (obj && !obj->on_connect) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (obj && !obj->on_connect) { |
0 |
0 |
0 |
| if (obj && !obj->on_connect) { |
0 |
0 |
0 |
|
| 129 |
0 |
| obj->on_connect = newSVsv(cb); |
| 130 |
|
| } else { |
| 131 |
0 |
▶ | SvSetSV((SV *)obj->on_connect, cb); |
Branch: 1 branch
| Branch | True | False | Total |
| SvSetSV((SV *)obj->on_connect, cb); |
0 |
0 |
0 |
|
| 132 |
|
| } |
| 133 |
0 |
▶ | IAMHERE_EXIT; |
Branch: 1 branch
| Branch | True | False | Total |
| IAMHERE_EXIT; |
0 |
0 |
0 |
|
| 134 |
|
| |
| 135 |
|
| void |
| 136 |
|
| saleaeinterface_register_on_disconnect(obj, cb) |
| 137 |
|
| saleaeinterface_t *obj |
| 138 |
|
| SV* cb |
| 139 |
|
| CODE: |
| 140 |
|
| /* save a copy of the callback */ |
| 141 |
0 |
▶ | IAMHERE_ENTRY; |
Branch: 1 branch
| Branch | True | False | Total |
| IAMHERE_ENTRY; |
0 |
0 |
0 |
|
| 142 |
0 |
▶ | if (obj && !obj->on_disconnect) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (obj && !obj->on_disconnect) { |
0 |
0 |
0 |
| if (obj && !obj->on_disconnect) { |
0 |
0 |
0 |
|
| 143 |
0 |
| obj->on_disconnect = newSVsv(cb); |
| 144 |
0 |
▶ | } else if (obj) { |
Branch: 1 branch
| Branch | True | False | Total |
| } else if (obj) { |
0 |
0 |
0 |
|
| 145 |
0 |
▶ | SvSetSV((SV *)obj->on_disconnect, cb); |
Branch: 1 branch
| Branch | True | False | Total |
| SvSetSV((SV *)obj->on_disconnect, cb); |
0 |
0 |
0 |
|
| 146 |
|
| } |
| 147 |
0 |
▶ | IAMHERE_EXIT; |
Branch: 1 branch
| Branch | True | False | Total |
| IAMHERE_EXIT; |
0 |
0 |
0 |
|
| 148 |
|
| |
| 149 |
|
| void |
| 150 |
|
| saleaeinterface_register_on_readdata(obj, cb) |
| 151 |
|
| saleaeinterface_t *obj |
| 152 |
|
| SV* cb |
| 153 |
|
| CODE: |
| 154 |
|
| /* save a copy of the callback */ |
| 155 |
0 |
▶ | if (obj && !obj->on_readdata) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (obj && !obj->on_readdata) { |
0 |
0 |
0 |
| if (obj && !obj->on_readdata) { |
0 |
0 |
0 |
|
| 156 |
0 |
| obj->on_readdata = newSVsv(cb); |
| 157 |
0 |
▶ | } else if (obj) { |
Branch: 1 branch
| Branch | True | False | Total |
| } else if (obj) { |
0 |
0 |
0 |
|
| 158 |
0 |
▶ | SvSetSV((SV *)obj->on_readdata, cb); |
Branch: 1 branch
| Branch | True | False | Total |
| SvSetSV((SV *)obj->on_readdata, cb); |
0 |
0 |
0 |
|
| 159 |
|
| } |
| 160 |
|
| |
| 161 |
|
| void |
| 162 |
|
| saleaeinterface_register_on_writedata(obj, cb) |
| 163 |
|
| saleaeinterface_t *obj |
| 164 |
|
| SV* cb |
| 165 |
|
| CODE: |
| 166 |
|
| /* save a copy of the callback */ |
| 167 |
0 |
▶ | if (obj && !obj->on_writedata) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (obj && !obj->on_writedata) { |
0 |
0 |
0 |
| if (obj && !obj->on_writedata) { |
0 |
0 |
0 |
|
| 168 |
0 |
| obj->on_writedata = newSVsv(cb); |
| 169 |
0 |
▶ | } else if (obj) { |
Branch: 1 branch
| Branch | True | False | Total |
| } else if (obj) { |
0 |
0 |
0 |
|
| 170 |
0 |
▶ | SvSetSV((SV *)obj->on_writedata, cb); |
Branch: 1 branch
| Branch | True | False | Total |
| SvSetSV((SV *)obj->on_writedata, cb); |
0 |
0 |
0 |
|
| 171 |
|
| } |
| 172 |
|
| |
| 173 |
|
| void |
| 174 |
|
| saleaeinterface_register_on_error(obj, cb) |
| 175 |
|
| saleaeinterface_t *obj |
| 176 |
|
| SV* cb |
| 177 |
|
| CODE: |
| 178 |
|
| /* save a copy of the callback */ |
| 179 |
0 |
▶ | if (obj && !obj->on_error) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (obj && !obj->on_error) { |
0 |
0 |
0 |
| if (obj && !obj->on_error) { |
0 |
0 |
0 |
|
| 180 |
0 |
| obj->on_error = newSVsv(cb); |
| 181 |
0 |
▶ | } else if (obj) { |
Branch: 1 branch
| Branch | True | False | Total |
| } else if (obj) { |
0 |
0 |
0 |
|
| 182 |
0 |
▶ | SvSetSV((SV *)obj->on_error, cb); |
Branch: 1 branch
| Branch | True | False | Total |
| SvSetSV((SV *)obj->on_error, cb); |
0 |
0 |
0 |
|
| 183 |
|
| } |
| 184 |
|
| |
| 185 |
|
| saleaeinterface_t * |
| 186 |
|
| saleaeinterface_new(parent) |
| 187 |
|
| SV *parent |
| 188 |
|
| CODE: |
| 189 |
0 |
| RETVAL = (saleaeinterface_t *)malloc(sizeof(saleaeinterface_t)); |
| 190 |
0 |
▶ | if (RETVAL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (RETVAL) { |
0 |
0 |
0 |
|
| 191 |
0 |
| memset(RETVAL, 0, sizeof(saleaeinterface_t)); |
| 192 |
0 |
| RETVAL->begun = 0; |
| 193 |
0 |
| RETVAL->perl = Perl_get_context(); |
| 194 |
0 |
| RETVAL->interface_count = 0; |
| 195 |
0 |
| RETVAL->interface_map = saleaeinterface_map_create(); |
| 196 |
0 |
| RETVAL->id_map = saleaeinterface_id_map_create(); |
| 197 |
|
| /* make a reference to the parent calling object */ |
| 198 |
0 |
| RETVAL->parent = (void *)SvREFCNT_inc(parent); |
| 199 |
|
| } else { |
| 200 |
0 |
| Perl_croak(aTHX_ "No memory to allocate saleaeinterface_t object\n"); |
| 201 |
|
| } |
| 202 |
|
| OUTPUT: |
| 203 |
|
| RETVAL |
| 204 |
|
| |
| 205 |
|
| void |
| 206 |
|
| saleaeinterface_DESTROY(obj) |
| 207 |
|
| saleaeinterface_t *obj |
| 208 |
|
| CODE: |
| 209 |
0 |
▶ | IAMHERE_ENTRY; |
Branch: 1 branch
| Branch | True | False | Total |
| IAMHERE_ENTRY; |
0 |
0 |
0 |
|
| 210 |
0 |
▶ | if (obj) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (obj) { |
0 |
0 |
0 |
|
| 211 |
0 |
| SV* parent = obj->parent; |
| 212 |
0 |
| SvREFCNT_dec(parent); |
| 213 |
0 |
| saleaeinterface_map_delete(obj->interface_map); |
| 214 |
0 |
| saleaeinterface_id_map_delete(obj->id_map); |
| 215 |
0 |
| free(obj); |
| 216 |
0 |
| obj = NULL; |
| 217 |
|
| } |
| 218 |
0 |
▶ | IAMHERE_EXIT; |
Branch: 1 branch
| Branch | True | False | Total |
| IAMHERE_EXIT; |
0 |
0 |
0 |
|
| 219 |
|
| |
| 220 |
|
| unsigned int |
| 221 |
|
| saleaeinterface_is_usb2(obj, id) |
| 222 |
|
| saleaeinterface_t *obj |
| 223 |
|
| unsigned int id |
| 224 |
|
| CODE: |
| 225 |
0 |
| RETVAL = saleaeinterface_isusb2(obj, id); |
| 226 |
|
| OUTPUT: |
| 227 |
|
| RETVAL |
| 228 |
|
| |
| 229 |
|
| unsigned int |
| 230 |
|
| saleaeinterface_is_streaming(obj, id) |
| 231 |
|
| saleaeinterface_t *obj |
| 232 |
|
| unsigned int id |
| 233 |
|
| CODE: |
| 234 |
0 |
| RETVAL = saleaeinterface_isstreaming(obj, id); |
| 235 |
|
| OUTPUT: |
| 236 |
|
| RETVAL |
| 237 |
|
| |
| 238 |
|
| unsigned int |
| 239 |
|
| saleaeinterface_get_channel_count(obj, id) |
| 240 |
|
| saleaeinterface_t *obj |
| 241 |
|
| unsigned int id |
| 242 |
|
| CODE: |
| 243 |
0 |
| RETVAL = saleaeinterface_getchannelcount(obj, id); |
| 244 |
|
| OUTPUT: |
| 245 |
|
| RETVAL |
| 246 |
|
| |
| 247 |
|
| unsigned int |
| 248 |
|
| saleaeinterface_get_sample_rate(obj, id) |
| 249 |
|
| saleaeinterface_t *obj |
| 250 |
|
| unsigned int id |
| 251 |
|
| CODE: |
| 252 |
0 |
| RETVAL = saleaeinterface_getsamplerate(obj, id); |
| 253 |
|
| OUTPUT: |
| 254 |
|
| RETVAL |
| 255 |
|
| |
| 256 |
|
| void saleaeinterface_set_sample_rate(obj, id, hz) |
| 257 |
|
| saleaeinterface_t *obj |
| 258 |
|
| unsigned int id |
| 259 |
|
| unsigned int hz |
| 260 |
|
| CODE: |
| 261 |
0 |
▶ | if (hz > 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (hz > 0) { |
0 |
0 |
0 |
|
| 262 |
0 |
| saleaeinterface_setsamplerate(obj, id, hz); |
| 263 |
|
| } |
| 264 |
|
| |
| 265 |
|
| SV * |
| 266 |
|
| saleaeinterface_get_supported_sample_rates(obj, id) |
| 267 |
|
| saleaeinterface_t *obj |
| 268 |
|
| unsigned int id |
| 269 |
|
| PREINIT: |
| 270 |
|
| AV *results; |
| 271 |
0 |
| unsigned int *buf = NULL; |
| 272 |
0 |
| unsigned int blen = 32; |
| 273 |
0 |
| int outlen = 0; |
| 274 |
0 |
▶ | int i = 0; |
Branch: 1 branch
| Branch | True | False | Total |
| int i = 0; |
0 |
0 |
0 |
|
| 275 |
|
| CODE: |
| 276 |
0 |
| buf = malloc(blen * sizeof(unsigned int)); |
| 277 |
0 |
▶ | if (!buf) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!buf) { |
0 |
0 |
0 |
|
| 278 |
0 |
| Perl_croak(aTHX_ "No memory to allocate 32 array of integers\n"); |
| 279 |
|
| XSRETURN_UNDEF; |
| 280 |
|
| } else { |
| 281 |
0 |
| memset(buf, 0, blen * sizeof(unsigned int)); |
| 282 |
|
| } |
| 283 |
0 |
| results = newAV(); |
| 284 |
0 |
| outlen = saleaeinterface_getsupportedsamplerates(obj, id, buf, blen); |
| 285 |
0 |
▶ | if (outlen > 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (outlen > 0) { |
0 |
0 |
0 |
|
| 286 |
0 |
▶ | for (i = 0; i < outlen && i < blen; ++i) { |
Branch: 2 branches
| Branch | True | False | Total |
| for (i = 0; i < outlen && i < blen; ++i) { |
0 |
0 |
0 |
| for (i = 0; i < outlen && i < blen; ++i) { |
0 |
0 |
0 |
|
| 287 |
0 |
▶ | if (saleaeinterface_internal_verbosity) |
Branch: 1 branch
| Branch | True | False | Total |
| if (saleaeinterface_internal_verbosity) |
0 |
0 |
0 |
|
| 288 |
0 |
| fprintf(stderr, "[%s:%d] sample[%d]: %u\n", __func__, __LINE__, i, buf[i]); |
| 289 |
0 |
| av_push(results, newSVuv(buf[i])); |
| 290 |
|
| } |
| 291 |
|
| } |
| 292 |
0 |
| RETVAL = newRV_noinc((SV *)results); |
| 293 |
0 |
▶ | if (buf) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (buf) { |
0 |
0 |
0 |
|
| 294 |
0 |
| free(buf); |
| 295 |
|
| } |
| 296 |
|
| OUTPUT: |
| 297 |
|
| RETVAL |
| 298 |
|
| |
| 299 |
|
| unsigned int |
| 300 |
|
| saleaeinterface_is_logic16(obj, id) |
| 301 |
|
| saleaeinterface_t *obj |
| 302 |
|
| unsigned int id |
| 303 |
|
| CODE: |
| 304 |
0 |
| RETVAL = saleaeinterface_islogic16(obj, id); |
| 305 |
|
| OUTPUT: |
| 306 |
|
| RETVAL |
| 307 |
|
| |
| 308 |
|
| unsigned int |
| 309 |
|
| saleaeinterface_is_logic(obj, id) |
| 310 |
|
| saleaeinterface_t *obj |
| 311 |
|
| unsigned int id |
| 312 |
|
| CODE: |
| 313 |
0 |
| RETVAL = saleaeinterface_islogic(obj, id); |
| 314 |
|
| OUTPUT: |
| 315 |
|
| RETVAL |
| 316 |
|
| |
| 317 |
|
| SV* |
| 318 |
|
| saleaeinterface_get_device_id(obj, id) |
| 319 |
|
| saleaeinterface_t *obj |
| 320 |
|
| unsigned int id |
| 321 |
|
| PREINIT: |
| 322 |
|
| size_t sdk_len; |
| 323 |
|
| CODE: |
| 324 |
0 |
| sdk_len = saleaeinterface_get_sdk_id(obj, id, NULL, 0); |
| 325 |
0 |
▶ | if (sdk_len > 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (sdk_len > 0) { |
0 |
0 |
0 |
|
| 326 |
0 |
| char *sdk_id = malloc((sdk_len + 1) * sizeof(unsigned char)); |
| 327 |
0 |
▶ | if (sdk_id) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (sdk_id) { |
0 |
0 |
0 |
|
| 328 |
0 |
| memset(sdk_id, 0, (sdk_len + 1) * sizeof(unsigned char)); |
| 329 |
0 |
| sdk_len = saleaeinterface_get_sdk_id(obj, id, sdk_id, sdk_len + 1); |
| 330 |
0 |
▶ | if (sdk_len > 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (sdk_len > 0) { |
0 |
0 |
0 |
|
| 331 |
0 |
| RETVAL = newSVpv(sdk_id, (STRLEN)sdk_len); |
| 332 |
|
| } |
| 333 |
0 |
| free(sdk_id); |
| 334 |
|
| } else { |
| 335 |
0 |
| Perl_croak(aTHX_ "No memory to allocate string\n"); |
| 336 |
|
| } |
| 337 |
|
| } else { |
| 338 |
0 |
| XSRETURN_UNDEF; |
| 339 |
|
| } |
| 340 |
|
| OUTPUT: |
| 341 |
|
| RETVAL |
| 342 |
|
| |
| 343 |
|
| void |
| 344 |
|
| saleaeinterface_verbose() |
| 345 |
|
| CODE: |
| 346 |
0 |
| saleaeinterface_internal_verbosity = 1; |
| 347 |
|
| |
| 348 |
|
| void |
| 349 |
|
| saleaeinterface_read_start(obj, id) |
| 350 |
|
| saleaeinterface_t *obj |
| 351 |
|
| unsigned int id |
| 352 |
|
| CODE: |
| 353 |
0 |
| saleaeinterface_read_start(obj, id); |
| 354 |
|
| |
| 355 |
|
| void |
| 356 |
|
| saleaeinterface_write_start(obj, id) |
| 357 |
|
| saleaeinterface_t *obj |
| 358 |
|
| unsigned int id |
| 359 |
|
| CODE: |
| 360 |
0 |
| saleaeinterface_write_start(obj, id); |
| 361 |
|
| |
| 362 |
|
| void |
| 363 |
|
| saleaeinterface_stop(obj, id) |
| 364 |
|
| saleaeinterface_t *obj |
| 365 |
|
| unsigned int id |
| 366 |
|
| CODE: |
| 367 |
0 |
| saleaeinterface_stop(obj, id); |
| 368 |
|
| |
| 369 |
|
| void |
| 370 |
|
| saleaeinterface_set_use5volts(obj, id, flag) |
| 371 |
|
| saleaeinterface_t *obj |
| 372 |
|
| unsigned int id |
| 373 |
|
| unsigned int flag |
| 374 |
|
| CODE: |
| 375 |
0 |
| saleaeinterface_setuse5volts(obj, id, flag); |
| 376 |
|
| |
| 377 |
|
| int |
| 378 |
|
| saleaeinterface_get_use5volts(obj, id) |
| 379 |
|
| saleaeinterface_t *obj |
| 380 |
|
| unsigned int id |
| 381 |
|
| CODE: |
| 382 |
0 |
| RETVAL = saleaeinterface_getuse5volts(obj, id); |
| 383 |
|
| OUTPUT: |
| 384 |
|
| RETVAL |
| 385 |
|
| |
| 386 |
|
| SV * |
| 387 |
|
| saleaeinterface_get_active_channels(obj, id) |
| 388 |
|
| saleaeinterface_t *obj |
| 389 |
|
| unsigned int id |
| 390 |
|
| PREINIT: |
| 391 |
|
| AV *results; |
| 392 |
0 |
| unsigned int *buf = NULL; |
| 393 |
0 |
| unsigned int blen = 16; |
| 394 |
0 |
| int outlen = 0; |
| 395 |
0 |
▶ | int i = 0; |
Branch: 1 branch
| Branch | True | False | Total |
| int i = 0; |
0 |
0 |
0 |
|
| 396 |
|
| CODE: |
| 397 |
0 |
| buf = malloc(blen * sizeof(unsigned int)); |
| 398 |
0 |
▶ | if (!buf) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!buf) { |
0 |
0 |
0 |
|
| 399 |
0 |
| Perl_croak(aTHX_ "No memory to allocate 16 array of integers\n"); |
| 400 |
|
| XSRETURN_UNDEF; |
| 401 |
|
| } else { |
| 402 |
0 |
| memset(buf, 0, blen * sizeof(unsigned int)); |
| 403 |
|
| } |
| 404 |
0 |
| results = newAV(); |
| 405 |
0 |
| outlen = saleaeinterface_getactivechannels(obj, id, buf, blen); |
| 406 |
0 |
▶ | if (outlen > 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (outlen > 0) { |
0 |
0 |
0 |
|
| 407 |
0 |
▶ | for (i = 0; i < outlen && i < blen; ++i) { |
Branch: 2 branches
| Branch | True | False | Total |
| for (i = 0; i < outlen && i < blen; ++i) { |
0 |
0 |
0 |
| for (i = 0; i < outlen && i < blen; ++i) { |
0 |
0 |
0 |
|
| 408 |
0 |
▶ | if (saleaeinterface_internal_verbosity) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (saleaeinterface_internal_verbosity) { |
0 |
0 |
0 |
|
| 409 |
0 |
| fprintf(stderr, "[%s:%d] channel[%d]: %u\n", |
| 410 |
0 |
| __func__, __LINE__, i, buf[i]); |
| 411 |
|
| } |
| 412 |
0 |
| av_push(results, newSVuv(buf[i])); |
| 413 |
|
| } |
| 414 |
|
| } |
| 415 |
0 |
| RETVAL = newRV_noinc((SV *)results); |
| 416 |
0 |
▶ | if (buf) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (buf) { |
0 |
0 |
0 |
|
| 417 |
0 |
| free(buf); |
| 418 |
|
| } |
| 419 |
|
| OUTPUT: |
| 420 |
|
| RETVAL |
| 421 |
|
| |
| 422 |
|
| void |
| 423 |
|
| saleaeinterface_set_active_channels(obj, id, chnls) |
| 424 |
|
| saleaeinterface_t *obj |
| 425 |
|
| unsigned int id |
| 426 |
|
| SV* chnls |
| 427 |
|
| PREINIT: |
| 428 |
|
| AV *channels; |
| 429 |
0 |
| unsigned int *buf = NULL; |
| 430 |
0 |
| unsigned int blen = 0; |
| 431 |
0 |
| int i = 0; |
| 432 |
0 |
▶ | if ((!SvROK(chnls)) || (SvTYPE(SvRV(chnls)) != SVt_PVAV) || |
Branch: 2 branches
| Branch | True | False | Total |
| if ((!SvROK(chnls)) || (SvTYPE(SvRV(chnls)) != SVt_PVAV) || |
0 |
0 |
0 |
| if ((!SvROK(chnls)) || (SvTYPE(SvRV(chnls)) != SVt_PVAV) || |
0 |
0 |
0 |
|
| 433 |
0 |
▶ | ((blen = av_len((AV *)SvRV(chnls)))) <= 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| ((blen = av_len((AV *)SvRV(chnls)))) <= 0) { |
0 |
0 |
0 |
|
| 434 |
0 |
| XSRETURN_UNDEF; |
| 435 |
|
| } |
| 436 |
|
| CODE: |
| 437 |
0 |
| buf = malloc(blen * sizeof(unsigned int)); |
| 438 |
0 |
▶ | if (!buf) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!buf) { |
0 |
0 |
0 |
|
| 439 |
0 |
| Perl_croak(aTHX_ "No memory to allocate %u array of integers\n", blen); |
| 440 |
|
| XSRETURN_UNDEF; |
| 441 |
|
| } else { |
| 442 |
0 |
| memset(buf, 0, blen * sizeof(unsigned int)); |
| 443 |
|
| } |
| 444 |
0 |
▶ | for (i = 0; i < blen; ++i) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (i = 0; i < blen; ++i) { |
0 |
0 |
0 |
|
| 445 |
0 |
| buf[i] = SvUV(*av_fetch((AV *)SvRV(chnls), i, 0)); |
| 446 |
0 |
▶ | if (saleaeinterface_internal_verbosity) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (saleaeinterface_internal_verbosity) { |
0 |
0 |
0 |
|
| 447 |
0 |
| fprintf(stderr, "[%s:%d] channel[%d]: %u\n", |
| 448 |
0 |
| __func__, __LINE__, i, buf[i]); |
| 449 |
|
| } |
| 450 |
|
| } |
| 451 |
0 |
| saleaeinterface_setactivechannels(obj, id, buf, blen); |
| 452 |
0 |
▶ | if (buf) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (buf) { |
0 |
0 |
0 |
|
| 453 |
0 |
| free(buf); |
| 454 |
|
| } |