#include <stdlib.h>
#include <string.h>
+using namespace boost;
+
namespace pv {
DataSnapshot::DataSnapshot(int unit_size) :
_sample_count(0),
_unit_size(unit_size)
{
+ lock_guard<recursive_mutex> lock(_mutex);
assert(_unit_size > 0);
}
DataSnapshot::~DataSnapshot()
{
+ lock_guard<recursive_mutex> lock(_mutex);
free(_data);
}
uint64_t DataSnapshot::get_sample_count()
{
+ lock_guard<recursive_mutex> lock(_mutex);
return _sample_count;
}
void DataSnapshot::append_data(void *data, uint64_t samples)
{
+ lock_guard<recursive_mutex> lock(_mutex);
_data = realloc(_data, (_sample_count + samples) * _unit_size);
memcpy((uint8_t*)_data + _sample_count * _unit_size,
data, samples * _unit_size);
#include <libsigrok/libsigrok.h>
}
+#include <boost/thread.hpp>
+
namespace pv {
class DataSnapshot
void append_data(void *data, uint64_t samples);
protected:
+ mutable boost::recursive_mutex _mutex;
void *_data;
uint64_t _sample_count;
int _unit_size;
#include "logicdatasnapshot.h"
+using namespace boost;
using namespace std;
namespace pv {
DataSnapshot(logic.unitsize),
_last_append_sample(0)
{
+ lock_guard<recursive_mutex> lock(_mutex);
memset(_mip_map, 0, sizeof(_mip_map));
append_payload(logic);
}
LogicDataSnapshot::~LogicDataSnapshot()
{
+ lock_guard<recursive_mutex> lock(_mutex);
BOOST_FOREACH(MipMapLevel &l, _mip_map)
free(l.data);
}
{
assert(_unit_size == logic.unitsize);
+ lock_guard<recursive_mutex> lock(_mutex);
+
append_data(logic.data, logic.length);
// Generate the first mip-map from the data
assert(sig_index >= 0);
assert(sig_index < SR_MAX_NUM_PROBES);
+ lock_guard<recursive_mutex> lock(_mutex);
+
const uint64_t block_length = (uint64_t)max(min_length, 1.0f);
const unsigned int min_level = max((int)floorf(logf(min_length) /
LogMipMapScaleFactor) - 1, 0);