X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fsession.cpp;h=aa528d191fe6750958bd2cbf8491fe8bb35383d0;hp=0fef9c91764bc75366bc8db57cfd6880783465b3;hb=f23c46921d031dba4c96062164cc9f3ca3c4809c;hpb=83b1c8d251386ac1980284c4668cbdd8e425550f diff --git a/pv/session.cpp b/pv/session.cpp index 0fef9c91..aa528d19 100644 --- a/pv/session.cpp +++ b/pv/session.cpp @@ -17,30 +17,25 @@ * along with this program; if not, see . */ -#ifdef _WIN32 -// Windows: Avoid boost/thread namespace pollution (which includes windows.h). -#define NOGDI -#define NORESOURCE -#endif - #include #include +#include #include #include #include -#include "session.hpp" #include "devicemanager.hpp" +#include "session.hpp" #include "data/analog.hpp" #include "data/analogsegment.hpp" +#include "data/decode/decoder.hpp" #include "data/decoderstack.hpp" #include "data/logic.hpp" #include "data/logicsegment.hpp" #include "data/signalbase.hpp" -#include "data/decode/decoder.hpp" #include "devices/hardwaredevice.hpp" #include "devices/inputfile.hpp" @@ -48,11 +43,11 @@ #include "toolbars/mainbar.hpp" -#include "view/analogsignal.hpp" -#include "view/decodetrace.hpp" -#include "view/logicsignal.hpp" -#include "view/signal.hpp" -#include "view/view.hpp" +#include "views/trace/analogsignal.hpp" +#include "views/trace/decodetrace.hpp" +#include "views/trace/logicsignal.hpp" +#include "views/trace/signal.hpp" +#include "views/trace/view.hpp" #include @@ -77,6 +72,7 @@ using std::recursive_mutex; using std::runtime_error; using std::shared_ptr; using std::string; +using std::unique_ptr; using std::unordered_set; using std::vector; @@ -738,22 +734,22 @@ void Session::update_signals() // Make the signals list for (shared_ptr viewbase : views_) { - views::TraceView::View *trace_view = - qobject_cast(viewbase.get()); + views::trace::View *trace_view = + qobject_cast(viewbase.get()); if (trace_view) { - unordered_set< shared_ptr > + unordered_set< shared_ptr > prev_sigs(trace_view->signals()); trace_view->clear_signals(); for (auto channel : sr_dev->channels()) { shared_ptr signalbase; - shared_ptr signal; + shared_ptr signal; // Find the channel in the old signals const auto iter = find_if( prev_sigs.cbegin(), prev_sigs.cend(), - [&](const shared_ptr &s) { + [&](const shared_ptr &s) { return s->base()->channel() == channel; }); if (iter != prev_sigs.end()) { @@ -781,8 +777,8 @@ void Session::update_signals() signalbase.get(), SLOT(on_capture_state_changed(int))); } - signal = shared_ptr( - new views::TraceView::LogicSignal(*this, + signal = shared_ptr( + new views::trace::LogicSignal(*this, device_, signalbase)); trace_view->add_signal(signal); break; @@ -802,15 +798,15 @@ void Session::update_signals() signalbase.get(), SLOT(on_capture_state_changed(int))); } - signal = shared_ptr( - new views::TraceView::AnalogSignal( + signal = shared_ptr( + new views::trace::AnalogSignal( *this, signalbase)); trace_view->add_signal(signal); break; } default: - assert(0); + assert(false); break; } } @@ -853,13 +849,20 @@ void Session::sample_thread_proc(function error_handler) set_capture_state(device_->session()->trigger() ? AwaitingTrigger : Running); - device_->run(); + try { + device_->run(); + } catch (Error e) { + error_handler(e.what()); + set_capture_state(Stopped); + return; + } + set_capture_state(Stopped); // Confirm that SR_DF_END was received if (cur_logic_segment_) { qDebug("SR_DF_END was not received."); - assert(0); + assert(false); } // Optimize memory usage @@ -981,12 +984,15 @@ void Session::feed_in_analog(shared_ptr analog) const vector> channels = analog->channels(); const unsigned int channel_count = channels.size(); const size_t sample_count = analog->num_samples() / channel_count; - const float *data = static_cast(analog->data_pointer()); bool sweep_beginning = false; + unique_ptr data(new float[analog->num_samples()]); + analog->get_data_as_float(data.get()); + if (signalbases_.empty()) update_signals(); + float *channel_data = data.get(); for (auto channel : channels) { shared_ptr segment; @@ -1020,7 +1026,7 @@ void Session::feed_in_analog(shared_ptr analog) assert(segment); // Append the samples in the segment - segment->append_interleaved_samples(data++, sample_count, + segment->append_interleaved_samples(channel_data++, sample_count, channel_count); } @@ -1035,7 +1041,7 @@ void Session::feed_in_analog(shared_ptr analog) void Session::data_feed_in(shared_ptr device, shared_ptr packet) { - static bool frame_began=false; + static bool frame_began = false; (void)device;