| 158 | } |
| 159 | |
| 160 | srd_decoder_inst* Decoder::create_decoder_inst(srd_session *session) |
| 161 | { |
| 162 | GHashTable *const opt_hash = g_hash_table_new_full(g_str_hash, |
| 163 | g_str_equal, g_free, (GDestroyNotify)g_variant_unref); |
| 164 | |
| 165 | for (auto i = _options.begin(); i != _options.end(); i++) |
| 166 | { |
| 167 | GVariant *const value = (*i).second; |
| 168 | g_variant_ref(value); |
| 169 | g_hash_table_replace(opt_hash, (void*)g_strdup( |
| 170 | (*i).first.c_str()), value); |
| 171 | } |
| 172 | |
| 173 | srd_decoder_inst *const decoder_inst = srd_inst_new( |
| 174 | session, _decoder->id, opt_hash); |
| 175 | g_hash_table_destroy(opt_hash); |
| 176 | |
| 177 | if(!decoder_inst) |
| 178 | return NULL; |
| 179 | |
| 180 | // Setup the probes |
| 181 | GHashTable *const probes = g_hash_table_new_full(g_str_hash, |
| 182 | g_str_equal, g_free, (GDestroyNotify)g_variant_unref); |
| 183 | |
| 184 | for(auto it = _probes.begin(); it != _probes.end(); it++) |
| 185 | { |
| 186 | GVariant *const gvar = g_variant_new_int32((*it).second); |
| 187 | g_variant_ref_sink(gvar); |
| 188 | g_hash_table_insert(probes, (*it).first->id, gvar); |
| 189 | } |
| 190 | |
| 191 | srd_inst_channel_set_all(decoder_inst, probes); |
| 192 | |
| 193 | return decoder_inst; |
| 194 | } |
| 195 | |
| 196 | |
| 197 | } // decode |
no test coverage detected