shared_ptr<Logic> logic_data = make_shared<Logic>(logic_channels.size());
logic_data->set_samplerate(get_samplerate());
output_logic_[dec->get_srd_decoder()] = logic_data;
+ output_logic_muxed_data_[dec->get_srd_decoder()] = vector<uint8_t>();
shared_ptr<LogicSegment> logic_segment = make_shared<data::LogicSegment>(
*logic_data, 0, (logic_data->num_channels() + 7) / 8, get_samplerate());
for (unsigned int i = pdata->start_sample; i < pdata->end_sample; i++)
data.emplace_back(*((uint8_t*)pdl->data));
- last_segment->append_subsignal_payload(pdl->logic_class, data.data(), data.size());
+ last_segment->append_subsignal_payload(pdl->logic_class, data.data(),
+ data.size(), ds->output_logic_muxed_data_.at(decc));
qInfo() << "Received logic output state change for class" << pdl->logic_class << "from decoder" \
<< QString::fromUtf8(decc->name) << "from" << pdata->start_sample << "to" << pdata->end_sample;
bool decode_paused_;
map<const srd_decoder*, shared_ptr<Logic>> output_logic_;
+ map<const srd_decoder*, vector<uint8_t>> output_logic_muxed_data_;
vector< shared_ptr<SignalBase>> output_signals_;
};
prev_sample_count + 1, prev_sample_count + 1);
}
-void LogicSegment::append_subsignal_payload(unsigned int index, void *data, uint64_t data_size)
+void LogicSegment::append_subsignal_payload(unsigned int index, void *data,
+ uint64_t data_size, vector<uint8_t>& destination)
{
- static vector<uint8_t> merged_data; // To preserve intermediate data across calls
-
if (index == 0)
- for (uint64_t i = 0; i < data_size * unit_size_; i++)
- merged_data.emplace_back(0);
+ destination.resize(data_size * unit_size_, 0);
// Set the bits for this sub-signal where needed
// Note: the bytes in *data must either be 0 or 1, nothing else
unsigned int index_byte_offs = index / 8;
- uint8_t* output_data = merged_data.data() + index_byte_offs;
+ uint8_t* output_data = destination.data() + index_byte_offs;
uint8_t* input_data = (uint8_t*)data;
for (uint64_t i = 0; i < data_size; i++) {
- assert((i * unit_size_ + index_byte_offs) < merged_data.size());
+ assert((i * unit_size_ + index_byte_offs) < destination.size());
*output_data |= (input_data[i] << index);
output_data += unit_size_;
}
if (index == owner_.num_channels() - 1) {
// We gathered sample data of all sub-signals, let's append it
- append_payload(merged_data.data(), merged_data.size());
- merged_data.clear();
+ append_payload(destination.data(), destination.size());
+ destination.clear();
}
}
* is constant for every invokation for 0..n. The number of samples
* hence may only change when index is 0.
*/
- void append_subsignal_payload(unsigned int index, void *data, uint64_t data_size);
+ void append_subsignal_payload(unsigned int index, void *data,
+ uint64_t data_size, vector<uint8_t>& destination);
void get_samples(int64_t start_sample, int64_t end_sample, uint8_t* dest) const;