projects
/
pulseview.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Android: Bundle Qt libs with the APK
[pulseview.git]
/
pv
/
sigsession.cpp
diff --git
a/pv/sigsession.cpp
b/pv/sigsession.cpp
index 282b7ec5c691959f432fe2627a60b1eddde69754..90854c7dbaf2b9d2cc26f6fc3d82e4b26bf44c61 100644
(file)
--- a/
pv/sigsession.cpp
+++ b/
pv/sigsession.cpp
@@
-39,22
+39,22
@@
#include "view/decodetrace.h"
#include "view/logicsignal.h"
#include "view/decodetrace.h"
#include "view/logicsignal.h"
-#include <
assert.h
>
-
+#include <
cassert
>
+#include <mutex>
#include <stdexcept>
#include <sys/stat.h>
#include <QDebug>
#include <stdexcept>
#include <sys/stat.h>
#include <QDebug>
-using boost::dynamic_pointer_cast;
-using boost::function;
-using boost::lock_guard;
-using boost::mutex;
-using boost::shared_ptr;
+using std::dynamic_pointer_cast;
+using std::function;
+using std::lock_guard;
+using std::mutex;
using std::list;
using std::map;
using std::set;
using std::list;
using std::map;
using std::set;
+using std::shared_ptr;
using std::string;
using std::vector;
using std::string;
using std::vector;
@@
-63,6
+63,9
@@
namespace pv {
// TODO: This should not be necessary
SigSession* SigSession::_session = NULL;
// TODO: This should not be necessary
SigSession* SigSession::_session = NULL;
+// TODO: This should not be necessary
+struct sr_session *SigSession::_sr_session = NULL;
+
SigSession::SigSession(DeviceManager &device_manager) :
_device_manager(device_manager),
_capture_state(Stopped)
SigSession::SigSession(DeviceManager &device_manager) :
_device_manager(device_manager),
_capture_state(Stopped)
@@
-77,12
+80,11
@@
SigSession::~SigSession()
{
using pv::device::Device;
{
using pv::device::Device;
+ // Stop and join to the thread
stop_capture();
stop_capture();
- if (_sampling_thread.joinable())
- _sampling_thread.join();
-
- _dev_inst->release();
+ if (_dev_inst)
+ _dev_inst->release();
// TODO: This should not be necessary
_session = NULL;
// TODO: This should not be necessary
_session = NULL;
@@
-98,11
+100,14
@@
void SigSession::set_device(
{
using pv::device::Device;
{
using pv::device::Device;
+ if (!dev_inst)
+ return;
+
// Ensure we are not capturing before setting the device
stop_capture();
if (_dev_inst) {
// Ensure we are not capturing before setting the device
stop_capture();
if (_dev_inst) {
- sr_session_datafeed_callback_remove_all();
+ sr_session_datafeed_callback_remove_all(
_sr_session
);
_dev_inst->release();
}
_dev_inst->release();
}
@@
-111,7
+116,7
@@
void SigSession::set_device(
if (dev_inst) {
dev_inst->use(this);
if (dev_inst) {
dev_inst->use(this);
- sr_session_datafeed_callback_add(data_feed_in_proc, NULL);
+ sr_session_datafeed_callback_add(
_sr_session,
data_feed_in_proc, NULL);
update_signals(dev_inst);
}
}
update_signals(dev_inst);
}
}
@@
-173,12
+178,12
@@
void SigSession::start_capture(function<void (const QString)> error_handler)
assert(_dev_inst->dev_inst());
assert(_dev_inst->dev_inst());
- // Check that at least one
probe
is enabled
+ // Check that at least one
channel
is enabled
const GSList *l;
for (l = _dev_inst->dev_inst()->channels; l; l = l->next) {
const GSList *l;
for (l = _dev_inst->dev_inst()->channels; l; l = l->next) {
- sr_channel *const
probe
= (sr_channel*)l->data;
- assert(
probe
);
- if (
probe
->enabled)
+ sr_channel *const
channel
= (sr_channel*)l->data;
+ assert(
channel
);
+ if (
channel
->enabled)
break;
}
break;
}
@@
-188,17
+193,15
@@
void SigSession::start_capture(function<void (const QString)> error_handler)
}
// Begin the session
}
// Begin the session
- _sampling_thread =
boost
::thread(
+ _sampling_thread =
std
::thread(
&SigSession::sample_thread_proc, this, _dev_inst,
error_handler);
}
void SigSession::stop_capture()
{
&SigSession::sample_thread_proc, this, _dev_inst,
error_handler);
}
void SigSession::stop_capture()
{
- if (get_capture_state() == Stopped)
- return;
-
- sr_session_stop();
+ if (get_capture_state() != Stopped)
+ sr_session_stop(_sr_session);
// Check that sampling stopped
if (_sampling_thread.joinable())
// Check that sampling stopped
if (_sampling_thread.joinable())
@@
-226,7
+229,7
@@
vector< shared_ptr<view::Signal> > SigSession::get_signals() const
#ifdef ENABLE_DECODE
bool SigSession::add_decoder(srd_decoder *const dec)
{
#ifdef ENABLE_DECODE
bool SigSession::add_decoder(srd_decoder *const dec)
{
- map<const srd_channel*, shared_ptr<view::LogicSignal> >
probe
s;
+ map<const srd_channel*, shared_ptr<view::LogicSignal> >
channel
s;
shared_ptr<data::DecoderStack> decoder_stack;
try
shared_ptr<data::DecoderStack> decoder_stack;
try
@@
-237,15
+240,15
@@
bool SigSession::add_decoder(srd_decoder *const dec)
decoder_stack = shared_ptr<data::DecoderStack>(
new data::DecoderStack(*this, dec));
decoder_stack = shared_ptr<data::DecoderStack>(
new data::DecoderStack(*this, dec));
- // Make a list of all the
probe
s
- std::vector<const srd_channel*> all_
probe
s;
+ // Make a list of all the
channel
s
+ std::vector<const srd_channel*> all_
channel
s;
for(const GSList *i = dec->channels; i; i = i->next)
for(const GSList *i = dec->channels; i; i = i->next)
- all_
probe
s.push_back((const srd_channel*)i->data);
+ all_
channel
s.push_back((const srd_channel*)i->data);
for(const GSList *i = dec->opt_channels; i; i = i->next)
for(const GSList *i = dec->opt_channels; i; i = i->next)
- all_
probe
s.push_back((const srd_channel*)i->data);
+ all_
channel
s.push_back((const srd_channel*)i->data);
- // Auto select the initial
probe
s
- for (const srd_channel *pdch : all_
probe
s)
+ // Auto select the initial
channel
s
+ for (const srd_channel *pdch : all_
channel
s)
for (shared_ptr<view::Signal> s : _signals)
{
shared_ptr<view::LogicSignal> l =
for (shared_ptr<view::Signal> s : _signals)
{
shared_ptr<view::LogicSignal> l =
@@
-253,13
+256,13
@@
bool SigSession::add_decoder(srd_decoder *const dec)
if (l && QString::fromUtf8(pdch->name).
toLower().contains(
l->get_name().toLower()))
if (l && QString::fromUtf8(pdch->name).
toLower().contains(
l->get_name().toLower()))
-
probe
s[pdch] = l;
+
channel
s[pdch] = l;
}
assert(decoder_stack);
assert(!decoder_stack->stack().empty());
assert(decoder_stack->stack().front());
}
assert(decoder_stack);
assert(!decoder_stack->stack().empty());
assert(decoder_stack->stack().front());
- decoder_stack->stack().front()->set_
probes(probe
s);
+ decoder_stack->stack().front()->set_
channels(channel
s);
// Create the decode signal
shared_ptr<view::DecodeTrace> d(
// Create the decode signal
shared_ptr<view::DecodeTrace> d(
@@
-312,7
+315,7
@@
void SigSession::update_signals(shared_ptr<device::DevInst> dev_inst)
assert(dev_inst);
assert(_capture_state == Stopped);
assert(dev_inst);
assert(_capture_state == Stopped);
- unsigned int logic_
probe
_count = 0;
+ unsigned int logic_
channel
_count = 0;
// Clear the decode traces
_decode_traces.clear();
// Clear the decode traces
_decode_traces.clear();
@@
-322,13
+325,13
@@
void SigSession::update_signals(shared_ptr<device::DevInst> dev_inst)
assert(dev_inst->dev_inst());
for (const GSList *l = dev_inst->dev_inst()->channels;
l; l = l->next) {
assert(dev_inst->dev_inst());
for (const GSList *l = dev_inst->dev_inst()->channels;
l; l = l->next) {
- const sr_channel *const
probe
= (const sr_channel *)l->data;
- if (!
probe
->enabled)
+ const sr_channel *const
channel
= (const sr_channel *)l->data;
+ if (!
channel
->enabled)
continue;
continue;
- switch(
probe
->type) {
+ switch(
channel
->type) {
case SR_CHANNEL_LOGIC:
case SR_CHANNEL_LOGIC:
- logic_
probe
_count++;
+ logic_
channel
_count++;
break;
}
}
break;
}
}
@@
-339,9
+342,9
@@
void SigSession::update_signals(shared_ptr<device::DevInst> dev_inst)
lock_guard<mutex> data_lock(_data_mutex);
_logic_data.reset();
lock_guard<mutex> data_lock(_data_mutex);
_logic_data.reset();
- if (logic_
probe
_count != 0) {
+ if (logic_
channel
_count != 0) {
_logic_data.reset(new data::Logic(
_logic_data.reset(new data::Logic(
- logic_
probe
_count));
+ logic_
channel
_count));
assert(_logic_data);
}
}
assert(_logic_data);
}
}
@@
-359,14
+362,14
@@
void SigSession::update_signals(shared_ptr<device::DevInst> dev_inst)
for (const GSList *l = dev_inst->dev_inst()->channels;
l; l = l->next) {
shared_ptr<view::Signal> signal;
for (const GSList *l = dev_inst->dev_inst()->channels;
l; l = l->next) {
shared_ptr<view::Signal> signal;
- sr_channel *const
probe
= (sr_channel *)l->data;
- assert(
probe
);
+ sr_channel *const
channel
= (sr_channel *)l->data;
+ assert(
channel
);
- switch(
probe
->type) {
+ switch(
channel
->type) {
case SR_CHANNEL_LOGIC:
signal = shared_ptr<view::Signal>(
new view::LogicSignal(dev_inst,
case SR_CHANNEL_LOGIC:
signal = shared_ptr<view::Signal>(
new view::LogicSignal(dev_inst,
-
probe
, _logic_data));
+
channel
, _logic_data));
break;
case SR_CHANNEL_ANALOG:
break;
case SR_CHANNEL_ANALOG:
@@
-375,7
+378,7
@@
void SigSession::update_signals(shared_ptr<device::DevInst> dev_inst)
new data::Analog());
signal = shared_ptr<view::Signal>(
new view::AnalogSignal(dev_inst,
new data::Analog());
signal = shared_ptr<view::Signal>(
new view::AnalogSignal(dev_inst,
-
probe
, data));
+
channel
, data));
break;
}
break;
}
@@
-393,13
+396,13
@@
void SigSession::update_signals(shared_ptr<device::DevInst> dev_inst)
signals_changed();
}
signals_changed();
}
-shared_ptr<view::Signal> SigSession::signal_from_
probe
(
- const sr_channel *
probe
) const
+shared_ptr<view::Signal> SigSession::signal_from_
channel
(
+ const sr_channel *
channel
) const
{
lock_guard<mutex> lock(_signals_mutex);
for (shared_ptr<view::Signal> sig : _signals) {
assert(sig);
{
lock_guard<mutex> lock(_signals_mutex);
for (shared_ptr<view::Signal> sig : _signals) {
assert(sig);
- if (sig->
probe() == probe
)
+ if (sig->
channel() == channel
)
return sig;
}
return shared_ptr<view::Signal>();
return sig;
}
return shared_ptr<view::Signal>();
@@
-448,7
+451,7
@@
void SigSession::sample_thread_proc(shared_ptr<device::DevInst> dev_inst,
return;
}
return;
}
- set_capture_state(
dev_inst->is_trigger_enabled(
) ?
+ set_capture_state(
sr_session_trigger_get(_sr_session
) ?
AwaitingTrigger : Running);
dev_inst->run();
AwaitingTrigger : Running);
dev_inst->run();
@@
-533,8
+536,8
@@
void SigSession::feed_in_analog(const sr_datafeed_analog &analog)
{
lock_guard<mutex> lock(_data_mutex);
{
lock_guard<mutex> lock(_data_mutex);
- const unsigned int
probe
_count = g_slist_length(analog.channels);
- const size_t sample_count = analog.num_samples /
probe
_count;
+ const unsigned int
channel
_count = g_slist_length(analog.channels);
+ const size_t sample_count = analog.num_samples /
channel
_count;
const float *data = analog.data;
bool sweep_beginning = false;
const float *data = analog.data;
bool sweep_beginning = false;
@@
-542,12
+545,12
@@
void SigSession::feed_in_analog(const sr_datafeed_analog &analog)
{
shared_ptr<data::AnalogSnapshot> snapshot;
{
shared_ptr<data::AnalogSnapshot> snapshot;
- sr_channel *const
probe
= (sr_channel*)p->data;
- assert(
probe
);
+ sr_channel *const
channel
= (sr_channel*)p->data;
+ assert(
channel
);
- // Try to get the snapshot of the
probe
+ // Try to get the snapshot of the
channel
const map< const sr_channel*, shared_ptr<data::AnalogSnapshot> >::
const map< const sr_channel*, shared_ptr<data::AnalogSnapshot> >::
- iterator iter = _cur_analog_snapshots.find(
probe
);
+ iterator iter = _cur_analog_snapshots.find(
channel
);
if (iter != _cur_analog_snapshots.end())
snapshot = (*iter).second;
else
if (iter != _cur_analog_snapshots.end())
snapshot = (*iter).second;
else
@@
-557,15
+560,15
@@
void SigSession::feed_in_analog(const sr_datafeed_analog &analog)
// in the sweep containing this snapshot.
sweep_beginning = true;
// in the sweep containing this snapshot.
sweep_beginning = true;
- // Create a snapshot, keep it in the maps of
probe
s
+ // Create a snapshot, keep it in the maps of
channel
s
snapshot = shared_ptr<data::AnalogSnapshot>(
new data::AnalogSnapshot(_dev_inst->get_sample_limit()));
snapshot = shared_ptr<data::AnalogSnapshot>(
new data::AnalogSnapshot(_dev_inst->get_sample_limit()));
- _cur_analog_snapshots[
probe
] = snapshot;
+ _cur_analog_snapshots[
channel
] = snapshot;
- // Find the annalog data associated with the
probe
+ // Find the annalog data associated with the
channel
shared_ptr<view::AnalogSignal> sig =
dynamic_pointer_cast<view::AnalogSignal>(
shared_ptr<view::AnalogSignal> sig =
dynamic_pointer_cast<view::AnalogSignal>(
- signal_from_
probe(probe
));
+ signal_from_
channel(channel
));
assert(sig);
shared_ptr<data::Analog> data(sig->analog_data());
assert(sig);
shared_ptr<data::Analog> data(sig->analog_data());
@@
-579,7
+582,7
@@
void SigSession::feed_in_analog(const sr_datafeed_analog &analog)
// Append the samples in the snapshot
snapshot->append_interleaved_samples(data++, sample_count,
// Append the samples in the snapshot
snapshot->append_interleaved_samples(data++, sample_count,
-
probe
_count);
+
channel
_count);
}
if (sweep_beginning) {
}
if (sweep_beginning) {
@@
-631,6
+634,8
@@
void SigSession::data_feed_in(const struct sr_dev_inst *sdi,
frame_ended();
break;
}
frame_ended();
break;
}
+ default:
+ break;
}
}
}
}