2 * This file is part of the PulseView project.
4 * Copyright (C) 2012-14 Joel Holdsworth <joel@airwebreathe.org.uk>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, see <http://www.gnu.org/licenses/>.
30 #include "devicemanager.hpp"
31 #include "session.hpp"
33 #include "data/analog.hpp"
34 #include "data/analogsegment.hpp"
35 #include "data/decode/decoder.hpp"
36 #include "data/logic.hpp"
37 #include "data/logicsegment.hpp"
38 #include "data/signalbase.hpp"
40 #include "devices/hardwaredevice.hpp"
41 #include "devices/inputfile.hpp"
42 #include "devices/sessionfile.hpp"
44 #include "toolbars/mainbar.hpp"
46 #include "views/trace/analogsignal.hpp"
47 #include "views/trace/decodetrace.hpp"
48 #include "views/trace/logicsignal.hpp"
49 #include "views/trace/signal.hpp"
50 #include "views/trace/view.hpp"
52 #include <libsigrokcxx/libsigrokcxx.hpp>
55 #include <libsigrokdecode/libsigrokdecode.h>
56 #include "data/decodesignal.hpp"
60 using std::dynamic_pointer_cast;
63 using std::lock_guard;
66 using std::make_shared;
72 using std::recursive_mutex;
73 using std::runtime_error;
74 using std::shared_ptr;
76 using std::unique_ptr;
77 using std::unordered_set;
81 using sigrok::Channel;
82 using sigrok::ConfigKey;
83 using sigrok::DatafeedCallbackFunction;
85 using sigrok::InputFormat;
89 using sigrok::Session;
91 using Glib::VariantBase;
94 Session::Session(DeviceManager &device_manager, QString name) :
95 device_manager_(device_manager),
98 capture_state_(Stopped),
106 // Stop and join to the thread
110 DeviceManager& Session::device_manager()
112 return device_manager_;
115 const DeviceManager& Session::device_manager() const
117 return device_manager_;
120 shared_ptr<sigrok::Session> Session::session() const
123 return shared_ptr<sigrok::Session>();
124 return device_->session();
127 shared_ptr<devices::Device> Session::device() const
132 QString Session::name() const
137 void Session::set_name(QString name)
139 if (default_name_.isEmpty())
140 default_name_ = name;
147 const list< shared_ptr<views::ViewBase> > Session::views() const
152 shared_ptr<views::ViewBase> Session::main_view() const
157 void Session::set_main_bar(shared_ptr<pv::toolbars::MainBar> main_bar)
159 main_bar_ = main_bar;
162 shared_ptr<pv::toolbars::MainBar> Session::main_bar() const
167 bool Session::data_saved() const
172 void Session::save_settings(QSettings &settings) const
174 map<string, string> dev_info;
175 list<string> key_list;
176 int decode_signals = 0, views = 0;
179 shared_ptr<devices::HardwareDevice> hw_device =
180 dynamic_pointer_cast< devices::HardwareDevice >(device_);
183 settings.setValue("device_type", "hardware");
184 settings.beginGroup("device");
186 key_list.emplace_back("vendor");
187 key_list.emplace_back("model");
188 key_list.emplace_back("version");
189 key_list.emplace_back("serial_num");
190 key_list.emplace_back("connection_id");
192 dev_info = device_manager_.get_device_info(device_);
194 for (string key : key_list) {
195 if (dev_info.count(key))
196 settings.setValue(QString::fromUtf8(key.c_str()),
197 QString::fromUtf8(dev_info.at(key).c_str()));
199 settings.remove(QString::fromUtf8(key.c_str()));
205 shared_ptr<devices::SessionFile> sessionfile_device =
206 dynamic_pointer_cast< devices::SessionFile >(device_);
208 if (sessionfile_device) {
209 settings.setValue("device_type", "sessionfile");
210 settings.beginGroup("device");
211 settings.setValue("filename", QString::fromStdString(
212 sessionfile_device->full_name()));
216 // Save channels and decoders
217 for (shared_ptr<data::SignalBase> base : signalbases_) {
219 if (base->is_decode_signal()) {
220 settings.beginGroup("decode_signal" + QString::number(decode_signals++));
221 base->save_settings(settings);
226 settings.beginGroup(base->internal_name());
227 base->save_settings(settings);
232 settings.setValue("decode_signals", decode_signals);
234 // Save view states and their signal settings
235 // Note: main_view must be saved as view0
236 settings.beginGroup("view" + QString::number(views++));
237 main_view_->save_settings(settings);
240 for (shared_ptr<views::ViewBase> view : views_) {
241 if (view != main_view_) {
242 settings.beginGroup("view" + QString::number(views++));
243 view->save_settings(settings);
248 settings.setValue("views", views);
252 void Session::restore_settings(QSettings &settings)
254 shared_ptr<devices::Device> device;
256 QString device_type = settings.value("device_type").toString();
258 if (device_type == "hardware") {
259 map<string, string> dev_info;
260 list<string> key_list;
262 // Re-select last used device if possible but only if it's not demo
263 settings.beginGroup("device");
264 key_list.emplace_back("vendor");
265 key_list.emplace_back("model");
266 key_list.emplace_back("version");
267 key_list.emplace_back("serial_num");
268 key_list.emplace_back("connection_id");
270 for (string key : key_list) {
271 const QString k = QString::fromStdString(key);
272 if (!settings.contains(k))
275 const string value = settings.value(k).toString().toStdString();
277 dev_info.insert(make_pair(key, value));
280 if (dev_info.count("model") > 0)
281 device = device_manager_.find_device_from_info(dev_info);
289 if (device_type == "sessionfile") {
290 settings.beginGroup("device");
291 QString filename = settings.value("filename").toString();
294 if (QFileInfo(filename).isReadable()) {
295 device = make_shared<devices::SessionFile>(device_manager_.context(),
296 filename.toStdString());
299 // TODO Perform error handling
300 start_capture([](QString infoMessage) { (void)infoMessage; });
302 set_name(QFileInfo(filename).fileName());
308 for (shared_ptr<data::SignalBase> base : signalbases_) {
309 settings.beginGroup(base->internal_name());
310 base->restore_settings(settings);
316 int decode_signals = settings.value("decode_signals").toInt();
318 for (int i = 0; i < decode_signals; i++) {
319 settings.beginGroup("decode_signal" + QString::number(i++));
320 // TODO Split up add_decoder() into add_decode_signal() and add_decoder(),
321 // then call add_decode_signal() and signal->restore_settings() here
327 int views = settings.value("views").toInt();
329 for (int i = 0; i < views; i++) {
330 settings.beginGroup("view" + QString::number(i));
333 views::ViewType type = (views::ViewType)settings.value("type").toInt();
334 add_view(name_, type, this);
335 views_.back()->restore_settings(settings);
337 main_view_->restore_settings(settings);
344 void Session::select_device(shared_ptr<devices::Device> device)
350 set_default_device();
351 } catch (const QString &e) {
352 main_bar_->session_error(tr("Failed to Select Device"),
353 tr("Failed to Select Device"));
357 void Session::set_device(shared_ptr<devices::Device> device)
361 // Ensure we are not capturing before setting the device
369 // Revert name back to default name (e.g. "Session 1") as the data is gone
370 name_ = default_name_;
373 // Remove all stored data
374 for (shared_ptr<views::ViewBase> view : views_) {
375 view->clear_signals();
377 view->clear_decode_signals();
380 for (const shared_ptr<data::SignalData> d : all_signal_data_)
382 all_signal_data_.clear();
383 signalbases_.clear();
384 cur_logic_segment_.reset();
386 for (auto entry : cur_analog_segments_) {
387 shared_ptr<sigrok::Channel>(entry.first).reset();
388 shared_ptr<data::AnalogSegment>(entry.second).reset();
395 device_ = move(device);
399 } catch (const QString &e) {
404 device_->session()->add_datafeed_callback([=]
405 (shared_ptr<sigrok::Device> device, shared_ptr<Packet> packet) {
406 data_feed_in(device, packet);
415 void Session::set_default_device()
417 const list< shared_ptr<devices::HardwareDevice> > &devices =
418 device_manager_.devices();
423 // Try and find the demo device and select that by default
424 const auto iter = find_if(devices.begin(), devices.end(),
425 [] (const shared_ptr<devices::HardwareDevice> &d) {
426 return d->hardware_device()->driver()->name() == "demo"; });
427 set_device((iter == devices.end()) ? devices.front() : *iter);
431 * Convert generic options to data types that are specific to InputFormat.
433 * @param[in] user_spec Vector of tokenized words, string format.
434 * @param[in] fmt_opts Input format's options, result of InputFormat::options().
436 * @return Map of options suitable for InputFormat::create_input().
438 map<string, Glib::VariantBase>
439 Session::input_format_options(vector<string> user_spec,
440 map<string, shared_ptr<Option>> fmt_opts)
442 map<string, Glib::VariantBase> result;
444 for (auto entry : user_spec) {
446 * Split key=value specs. Accept entries without separator
447 * (for simplified boolean specifications).
450 size_t pos = entry.find("=");
451 if (pos == std::string::npos) {
455 key = entry.substr(0, pos);
456 val = entry.substr(pos + 1);
460 * Skip user specifications that are not a member of the
461 * format's set of supported options. Have the text input
462 * spec converted to the required input format specific
465 auto found = fmt_opts.find(key);
466 if (found == fmt_opts.end())
468 shared_ptr<Option> opt = found->second;
469 result[key] = opt->parse_string(val);
475 void Session::load_init_file(const string &file_name, const string &format)
477 shared_ptr<InputFormat> input_format;
478 map<string, Glib::VariantBase> input_opts;
480 if (!format.empty()) {
481 const map<string, shared_ptr<InputFormat> > formats =
482 device_manager_.context()->input_formats();
483 auto user_opts = pv::util::split_string(format, ":");
484 string user_name = user_opts.front();
485 user_opts.erase(user_opts.begin());
486 const auto iter = find_if(formats.begin(), formats.end(),
487 [&](const pair<string, shared_ptr<InputFormat> > f) {
488 return f.first == user_name; });
489 if (iter == formats.end()) {
490 main_bar_->session_error(tr("Error"),
491 tr("Unexpected input format: %s").arg(QString::fromStdString(format)));
494 input_format = (*iter).second;
495 input_opts = input_format_options(user_opts,
496 input_format->options());
499 load_file(QString::fromStdString(file_name), input_format, input_opts);
502 void Session::load_file(QString file_name,
503 shared_ptr<sigrok::InputFormat> format,
504 const map<string, Glib::VariantBase> &options)
506 const QString errorMessage(
507 QString("Failed to load file %1").arg(file_name));
511 set_device(shared_ptr<devices::Device>(
512 new devices::InputFile(
513 device_manager_.context(),
514 file_name.toStdString(),
517 set_device(shared_ptr<devices::Device>(
518 new devices::SessionFile(
519 device_manager_.context(),
520 file_name.toStdString())));
522 main_bar_->session_error(tr("Failed to load ") + file_name, e.what());
523 set_default_device();
524 main_bar_->update_device_list();
528 main_bar_->update_device_list();
530 start_capture([&, errorMessage](QString infoMessage) {
531 main_bar_->session_error(errorMessage, infoMessage); });
533 set_name(QFileInfo(file_name).fileName());
536 Session::capture_state Session::get_capture_state() const
538 lock_guard<mutex> lock(sampling_mutex_);
539 return capture_state_;
542 void Session::start_capture(function<void (const QString)> error_handler)
545 error_handler(tr("No active device set, can't start acquisition."));
551 // Check that at least one channel is enabled
552 const shared_ptr<sigrok::Device> sr_dev = device_->device();
554 const auto channels = sr_dev->channels();
555 if (!any_of(channels.begin(), channels.end(),
556 [](shared_ptr<Channel> channel) {
557 return channel->enabled(); })) {
558 error_handler(tr("No channels enabled."));
564 for (const shared_ptr<data::SignalData> d : all_signal_data_)
567 // Revert name back to default name (e.g. "Session 1") for real devices
568 // as the (possibly saved) data is gone. File devices keep their name.
569 shared_ptr<devices::HardwareDevice> hw_device =
570 dynamic_pointer_cast< devices::HardwareDevice >(device_);
573 name_ = default_name_;
578 sampling_thread_ = std::thread(
579 &Session::sample_thread_proc, this, error_handler);
582 void Session::stop_capture()
584 if (get_capture_state() != Stopped)
587 // Check that sampling stopped
588 if (sampling_thread_.joinable())
589 sampling_thread_.join();
592 void Session::register_view(shared_ptr<views::ViewBase> view)
594 if (views_.empty()) {
598 views_.push_back(view);
600 // Add all device signals
603 // Add all other signals
604 unordered_set< shared_ptr<data::SignalBase> > view_signalbases =
607 views::trace::View *trace_view =
608 qobject_cast<views::trace::View*>(view.get());
611 for (shared_ptr<data::SignalBase> signalbase : signalbases_) {
612 const int sb_exists = count_if(
613 view_signalbases.cbegin(), view_signalbases.cend(),
614 [&](const shared_ptr<data::SignalBase> &sb) {
615 return sb == signalbase;
617 // Add the signal to the view as it doesn't have it yet
619 switch (signalbase->type()) {
620 case data::SignalBase::AnalogChannel:
621 case data::SignalBase::LogicChannel:
622 case data::SignalBase::A2LChannel:
624 case data::SignalBase::DecodeChannel:
626 trace_view->add_decode_signal(
627 dynamic_pointer_cast<data::DecodeSignal>(signalbase));
630 case data::SignalBase::MathChannel:
640 void Session::deregister_view(shared_ptr<views::ViewBase> view)
642 views_.remove_if([&](shared_ptr<views::ViewBase> v) { return v == view; });
644 if (views_.empty()) {
647 // Without a view there can be no main bar
652 bool Session::has_view(shared_ptr<views::ViewBase> view)
654 for (shared_ptr<views::ViewBase> v : views_)
661 double Session::get_samplerate() const
663 double samplerate = 0.0;
665 for (const shared_ptr<pv::data::SignalData> d : all_signal_data_) {
667 const vector< shared_ptr<pv::data::Segment> > segments =
669 for (const shared_ptr<pv::data::Segment> &s : segments)
670 samplerate = max(samplerate, s->samplerate());
672 // If there is no sample rate given we use samples as unit
673 if (samplerate == 0.0)
679 const unordered_set< shared_ptr<data::SignalBase> > Session::signalbases() const
685 bool Session::add_decoder(srd_decoder *const dec)
691 // Create the decode signal
692 shared_ptr<data::DecodeSignal> signal =
693 make_shared<data::DecodeSignal>(*this);
695 signalbases_.insert(signal);
697 // Add the decode signal to all views
698 for (shared_ptr<views::ViewBase> view : views_)
699 view->add_decode_signal(signal);
702 signal->stack_decoder(dec);
703 } catch (runtime_error e) {
712 void Session::remove_decode_signal(shared_ptr<data::DecodeSignal> signal)
714 signalbases_.erase(signal);
716 for (shared_ptr<views::ViewBase> view : views_)
717 view->remove_decode_signal(signal);
723 void Session::set_capture_state(capture_state state)
728 lock_guard<mutex> lock(sampling_mutex_);
729 changed = capture_state_ != state;
730 capture_state_ = state;
734 capture_state_changed(state);
737 void Session::update_signals()
740 signalbases_.clear();
742 for (shared_ptr<views::ViewBase> view : views_) {
743 view->clear_signals();
745 view->clear_decode_signals();
751 lock_guard<recursive_mutex> lock(data_mutex_);
753 const shared_ptr<sigrok::Device> sr_dev = device_->device();
755 signalbases_.clear();
757 for (shared_ptr<views::ViewBase> view : views_) {
758 view->clear_signals();
760 view->clear_decode_signals();
766 // Detect what data types we will receive
767 auto channels = sr_dev->channels();
768 unsigned int logic_channel_count = count_if(
769 channels.begin(), channels.end(),
770 [] (shared_ptr<Channel> channel) {
771 return channel->type() == sigrok::ChannelType::LOGIC; });
773 // Create data containers for the logic data segments
775 lock_guard<recursive_mutex> data_lock(data_mutex_);
777 if (logic_channel_count == 0) {
779 } else if (!logic_data_ ||
780 logic_data_->num_channels() != logic_channel_count) {
781 logic_data_.reset(new data::Logic(
782 logic_channel_count));
787 // Make the signals list
788 for (shared_ptr<views::ViewBase> viewbase : views_) {
789 views::trace::View *trace_view =
790 qobject_cast<views::trace::View*>(viewbase.get());
793 unordered_set< shared_ptr<views::trace::Signal> >
794 prev_sigs(trace_view->signals());
795 trace_view->clear_signals();
797 for (auto channel : sr_dev->channels()) {
798 shared_ptr<data::SignalBase> signalbase;
799 shared_ptr<views::trace::Signal> signal;
801 // Find the channel in the old signals
802 const auto iter = find_if(
803 prev_sigs.cbegin(), prev_sigs.cend(),
804 [&](const shared_ptr<views::trace::Signal> &s) {
805 return s->base()->channel() == channel;
807 if (iter != prev_sigs.end()) {
808 // Copy the signal from the old set to the new
810 trace_view->add_signal(signal);
812 // Find the signalbase for this channel if possible
814 for (const shared_ptr<data::SignalBase> b : signalbases_)
815 if (b->channel() == channel)
818 switch(channel->type()->id()) {
819 case SR_CHANNEL_LOGIC:
821 signalbase = make_shared<data::SignalBase>(channel,
822 data::SignalBase::LogicChannel);
823 signalbases_.insert(signalbase);
825 all_signal_data_.insert(logic_data_);
826 signalbase->set_data(logic_data_);
828 connect(this, SIGNAL(capture_state_changed(int)),
829 signalbase.get(), SLOT(on_capture_state_changed(int)));
832 signal = shared_ptr<views::trace::Signal>(
833 new views::trace::LogicSignal(*this,
834 device_, signalbase));
835 trace_view->add_signal(signal);
838 case SR_CHANNEL_ANALOG:
841 signalbase = make_shared<data::SignalBase>(channel,
842 data::SignalBase::AnalogChannel);
843 signalbases_.insert(signalbase);
845 shared_ptr<data::Analog> data(new data::Analog());
846 all_signal_data_.insert(data);
847 signalbase->set_data(data);
849 connect(this, SIGNAL(capture_state_changed(int)),
850 signalbase.get(), SLOT(on_capture_state_changed(int)));
853 signal = shared_ptr<views::trace::Signal>(
854 new views::trace::AnalogSignal(
856 trace_view->add_signal(signal);
872 shared_ptr<data::SignalBase> Session::signalbase_from_channel(
873 shared_ptr<sigrok::Channel> channel) const
875 for (shared_ptr<data::SignalBase> sig : signalbases_) {
877 if (sig->channel() == channel)
880 return shared_ptr<data::SignalBase>();
883 void Session::sample_thread_proc(function<void (const QString)> error_handler)
885 assert(error_handler);
890 cur_samplerate_ = device_->read_config<uint64_t>(ConfigKey::SAMPLERATE);
892 out_of_memory_ = false;
897 error_handler(e.what());
901 set_capture_state(device_->session()->trigger() ?
902 AwaitingTrigger : Running);
907 error_handler(e.what());
908 set_capture_state(Stopped);
912 set_capture_state(Stopped);
914 // Confirm that SR_DF_END was received
915 if (cur_logic_segment_) {
916 qDebug("SR_DF_END was not received.");
920 // Optimize memory usage
921 free_unused_memory();
923 // We now have unsaved data unless we just "captured" from a file
924 shared_ptr<devices::File> file_device =
925 dynamic_pointer_cast<devices::File>(device_);
931 error_handler(tr("Out of memory, acquisition stopped."));
934 void Session::free_unused_memory()
936 for (shared_ptr<data::SignalData> data : all_signal_data_) {
937 const vector< shared_ptr<data::Segment> > segments = data->segments();
939 for (shared_ptr<data::Segment> segment : segments) {
940 segment->free_unused_memory();
945 void Session::feed_in_header()
947 cur_samplerate_ = device_->read_config<uint64_t>(ConfigKey::SAMPLERATE);
950 void Session::feed_in_meta(shared_ptr<Meta> meta)
952 for (auto entry : meta->config()) {
953 switch (entry.first->id()) {
954 case SR_CONF_SAMPLERATE:
955 // We can't rely on the header to always contain the sample rate,
956 // so in case it's supplied via a meta packet, we use it.
957 if (!cur_samplerate_)
958 cur_samplerate_ = g_variant_get_uint64(entry.second.gobj());
960 /// @todo handle samplerate changes
963 // Unknown metadata is not an error.
971 void Session::feed_in_trigger()
973 // The channel containing most samples should be most accurate
974 uint64_t sample_count = 0;
977 for (const shared_ptr<pv::data::SignalData> d : all_signal_data_) {
979 uint64_t temp_count = 0;
981 const vector< shared_ptr<pv::data::Segment> > segments =
983 for (const shared_ptr<pv::data::Segment> &s : segments)
984 temp_count += s->get_sample_count();
986 if (temp_count > sample_count)
987 sample_count = temp_count;
991 trigger_event(sample_count / get_samplerate());
994 void Session::feed_in_frame_begin()
996 if (cur_logic_segment_ || !cur_analog_segments_.empty())
1000 void Session::feed_in_logic(shared_ptr<Logic> logic)
1002 lock_guard<recursive_mutex> lock(data_mutex_);
1005 // The only reason logic_data_ would not have been created is
1006 // if it was not possible to determine the signals when the
1007 // device was created.
1011 if (!cur_logic_segment_) {
1012 // This could be the first packet after a trigger
1013 set_capture_state(Running);
1015 // Create a new data segment
1016 cur_logic_segment_ = make_shared<data::LogicSegment>(
1017 *logic_data_, logic->unit_size(), cur_samplerate_);
1018 logic_data_->push_segment(cur_logic_segment_);
1020 // @todo Putting this here means that only listeners querying
1021 // for logic will be notified. Currently the only user of
1022 // frame_began is DecoderStack, but in future we need to signal
1023 // this after both analog and logic sweeps have begun.
1027 cur_logic_segment_->append_payload(logic);
1032 void Session::feed_in_analog(shared_ptr<Analog> analog)
1034 lock_guard<recursive_mutex> lock(data_mutex_);
1036 const vector<shared_ptr<Channel>> channels = analog->channels();
1037 const unsigned int channel_count = channels.size();
1038 const size_t sample_count = analog->num_samples() / channel_count;
1039 bool sweep_beginning = false;
1041 unique_ptr<float> data(new float[analog->num_samples()]);
1042 analog->get_data_as_float(data.get());
1044 if (signalbases_.empty())
1047 float *channel_data = data.get();
1048 for (auto channel : channels) {
1049 shared_ptr<data::AnalogSegment> segment;
1051 // Try to get the segment of the channel
1052 const map< shared_ptr<Channel>, shared_ptr<data::AnalogSegment> >::
1053 iterator iter = cur_analog_segments_.find(channel);
1054 if (iter != cur_analog_segments_.end())
1055 segment = (*iter).second;
1057 // If no segment was found, this means we haven't
1058 // created one yet. i.e. this is the first packet
1059 // in the sweep containing this segment.
1060 sweep_beginning = true;
1062 // Find the analog data associated with the channel
1063 shared_ptr<data::SignalBase> base = signalbase_from_channel(channel);
1066 shared_ptr<data::Analog> data(base->analog_data());
1069 // Create a segment, keep it in the maps of channels
1070 segment = make_shared<data::AnalogSegment>(
1071 *data, cur_samplerate_);
1072 cur_analog_segments_[channel] = segment;
1074 // Push the segment into the analog data.
1075 data->push_segment(segment);
1080 // Append the samples in the segment
1081 segment->append_interleaved_samples(channel_data++, sample_count,
1085 if (sweep_beginning) {
1086 // This could be the first packet after a trigger
1087 set_capture_state(Running);
1093 void Session::data_feed_in(shared_ptr<sigrok::Device> device,
1094 shared_ptr<Packet> packet)
1096 static bool frame_began = false;
1101 assert(device == device_->device());
1104 switch (packet->type()->id()) {
1110 feed_in_meta(dynamic_pointer_cast<Meta>(packet->payload()));
1117 case SR_DF_FRAME_BEGIN:
1118 feed_in_frame_begin();
1124 feed_in_logic(dynamic_pointer_cast<Logic>(packet->payload()));
1125 } catch (bad_alloc) {
1126 out_of_memory_ = true;
1133 feed_in_analog(dynamic_pointer_cast<Analog>(packet->payload()));
1134 } catch (bad_alloc) {
1135 out_of_memory_ = true;
1140 case SR_DF_FRAME_END:
1144 lock_guard<recursive_mutex> lock(data_mutex_);
1145 cur_logic_segment_.reset();
1146 cur_analog_segments_.clear();
1149 frame_began = false;
1159 void Session::on_data_saved()