static void srd_inst_join_decode_thread(struct srd_decoder_inst *di);
static void srd_inst_reset_state(struct srd_decoder_inst *di);
+SRD_PRIV void oldpins_array_seed(struct srd_decoder_inst *di);
SRD_PRIV void oldpins_array_free(struct srd_decoder_inst *di);
/** @endcond */
}
/* Default to the initial pins being the same as in sample 0. */
- di->old_pins_array = g_array_sized_new(FALSE, TRUE, sizeof(uint8_t),
- di->dec_num_channels);
- g_array_set_size(di->old_pins_array, di->dec_num_channels);
- memset(di->old_pins_array->data, SRD_INITIAL_PIN_SAME_AS_SAMPLE0,
- di->dec_num_channels);
+ oldpins_array_seed(di);
gstate = PyGILState_Ensure();
}
s = g_string_sized_new(100);
+ oldpins_array_seed(di);
for (i = 0; i < di->dec_num_channels; i++) {
di->old_pins_array->data[i] = initial_pins->data[i];
g_string_append_printf(s, "%d, ", di->old_pins_array->data[i]);
return SRD_OK;
}
+/** @private */
+SRD_PRIV void oldpins_array_seed(struct srd_decoder_inst *di)
+{
+ size_t count;
+ GArray *arr;
+
+ if (!di)
+ return;
+ if (di->old_pins_array)
+ return;
+
+ srd_dbg("%s: Seeding old pins, %s().", di->inst_id, __func__);
+ count = di->dec_num_channels;
+ arr = g_array_sized_new(FALSE, TRUE, sizeof(uint8_t), count);
+ g_array_set_size(arr, count);
+ memset(arr->data, SRD_INITIAL_PIN_SAME_AS_SAMPLE0, count);
+ di->old_pins_array = arr;
+}
+
/** @private */
SRD_PRIV void oldpins_array_free(struct srd_decoder_inst *di)
{
if (!di || !di->dec_channelmap || !sample_pos)
return;
+ oldpins_array_seed(di);
for (i = 0; i < di->dec_num_channels; i++) {
byte_offset = di->dec_channelmap[i] / 8;
bit_offset = di->dec_channelmap[i] % 8;
sample_pos = di->inbuf + ((di->abs_cur_samplenum - di->abs_start_samplenum) * di->data_unitsize);
+ oldpins_array_seed(di);
for (i = 0; i < di->dec_num_channels; i++) {
if (di->old_pins_array->data[i] != SRD_INITIAL_PIN_SAME_AS_SAMPLE0)
continue;