X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fsession.cpp;h=c18f809446a037475f4106e10576f3a89d5c1688;hp=a1a078788c4e49631e7d00df1ab5e82646a6cbe3;hb=dc4ada2bfd5d9f4386661ffbf7ff3ad000b6bfb5;hpb=12ea3616767553ee0a615f14bbcb8ec614589e34 diff --git a/pv/session.cpp b/pv/session.cpp index a1a07878..c18f8094 100644 --- a/pv/session.cpp +++ b/pv/session.cpp @@ -17,32 +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 #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" @@ -62,10 +55,6 @@ #include #endif -using boost::shared_lock; -using boost::shared_mutex; -using boost::unique_lock; - using std::bad_alloc; using std::dynamic_pointer_cast; using std::find_if; @@ -81,9 +70,9 @@ using std::mutex; using std::pair; using std::recursive_mutex; using std::runtime_error; -using std::set; using std::shared_ptr; using std::string; +using std::unique_ptr; using std::unordered_set; using std::vector; @@ -92,18 +81,13 @@ using sigrok::Channel; using sigrok::ConfigKey; using sigrok::DatafeedCallbackFunction; using sigrok::Error; -using sigrok::Header; using sigrok::InputFormat; using sigrok::Logic; using sigrok::Meta; -using sigrok::OutputFormat; using sigrok::Packet; -using sigrok::PacketPayload; using sigrok::Session; -using sigrok::SessionDevice; using Glib::VariantBase; -using Glib::Variant; namespace pv { Session::Session(DeviceManager &device_manager, QString name) : @@ -822,7 +806,7 @@ void Session::update_signals() } default: - assert(0); + assert(false); break; } } @@ -865,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 @@ -993,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; @@ -1032,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); } @@ -1047,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;