const int64_t sample_count, const unsigned int unit_size,
srd_session *const session)
{
- uint8_t chunk[DecodeChunkLength];
-
const unsigned int chunk_sample_count =
DecodeChunkLength / segment_->unit_size();
const int64_t chunk_end = min(
i + chunk_sample_count, sample_count);
- segment_->get_samples(chunk, i, chunk_end);
+ const uint8_t* chunk = segment_->get_samples(i, chunk_end);
if (srd_session_send(session, i, chunk_end, chunk,
(chunk_end - i) * unit_size, unit_size) != SRD_OK) {
append_payload_to_mipmap();
}
-void LogicSegment::get_samples(uint8_t *const data,
- int64_t start_sample, int64_t end_sample) const
+const uint8_t* LogicSegment::get_samples(int64_t start_sample,
+ int64_t end_sample) const
{
- assert(data);
assert(start_sample >= 0);
assert(start_sample <= (int64_t)sample_count_);
assert(end_sample >= 0);
lock_guard<recursive_mutex> lock(mutex_);
+ uint8_t* data = new uint8_t[end_sample - start_sample];
const size_t size = (end_sample - start_sample) * unit_size_;
- memcpy(data, (const uint8_t*)data_.data() + start_sample * unit_size_, size);
+ memcpy(data, (uint8_t*)data_.data() + start_sample * unit_size_, size);
+ return data;
}
void LogicSegment::reallocate_mipmap_level(MipMapLevel &m)
void append_payload(std::shared_ptr<sigrok::Logic> logic);
- void get_samples(uint8_t *const data,
- int64_t start_sample, int64_t end_sample) const;
+ const uint8_t* get_samples(int64_t start_sample, int64_t end_sample) const;
private:
uint64_t unpack_sample(const uint8_t *ptr) const;
{
unsigned progress_scale = 0;
- /// TODO: Wrap this in a std::unique_ptr when we transition to C++11
- uint8_t *const ldata = new uint8_t[BlockSize];
- assert(ldata);
-
int aunit_size = 0;
int lunit_size = 0;
unsigned int lsamples_per_block = INT_MAX;
}
if (lsegment) {
- lsegment->get_samples(ldata, start_sample_, start_sample_ + packet_len);
+ const uint8_t* ldata =
+ lsegment->get_samples(start_sample_, start_sample_ + packet_len);
const size_t length = packet_len * lunit_size;
- auto logic = context->create_logic_packet(ldata, length, lunit_size);
+ auto logic = context->create_logic_packet((void*)ldata, length, lunit_size);
const string ldata_str = output_->receive(logic);
if (output_stream_.is_open())
output_stream_ << ldata_str;
+
+ delete[] ldata;
}
} catch (Error error) {
error_ = tr("Error while saving: ") + error.what();
output_.reset();
output_stream_.close();
-
- delete[] ldata;
}
} // pv