X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fsession.cpp;h=7df73d63d5ba43660eb666ec1a91322046002442;hp=50e89e567041c2ec186e47e0d387457808f452a3;hb=f8a8811b634642c792342c5e69cd1a11231cce9f;hpb=d7168e582c71ebcc359b12efed83daa2a6b6f28e diff --git a/pv/session.cpp b/pv/session.cpp index 50e89e56..7df73d63 100644 --- a/pv/session.cpp +++ b/pv/session.cpp @@ -207,7 +207,7 @@ void Session::save_settings(QSettings &settings) const } shared_ptr sessionfile_device = - dynamic_pointer_cast< devices::SessionFile >(device_); + dynamic_pointer_cast(device_); if (sessionfile_device) { settings.setValue("device_type", "sessionfile"); @@ -217,6 +217,16 @@ void Session::save_settings(QSettings &settings) const settings.endGroup(); } + shared_ptr inputfile_device = + dynamic_pointer_cast(device_); + + if (inputfile_device) { + settings.setValue("device_type", "inputfile"); + settings.beginGroup("device"); + inputfile_device->save_meta_to_settings(settings); + settings.endGroup(); + } + // Save channels and decoders for (shared_ptr base : signalbases_) { #ifdef ENABLE_DECODE @@ -290,21 +300,34 @@ void Session::restore_settings(QSettings &settings) settings.endGroup(); } - if (device_type == "sessionfile") { - settings.beginGroup("device"); - QString filename = settings.value("filename").toString(); - settings.endGroup(); + if ((device_type == "sessionfile") || (device_type == "inputfile")) { + if (device_type == "sessionfile") { + settings.beginGroup("device"); + QString filename = settings.value("filename").toString(); + settings.endGroup(); - if (QFileInfo(filename).isReadable()) { - device = make_shared(device_manager_.context(), - filename.toStdString()); + if (QFileInfo(filename).isReadable()) { + device = make_shared(device_manager_.context(), + filename.toStdString()); + } + } + + if (device_type == "inputfile") { + settings.beginGroup("device"); + device = make_shared(device_manager_.context(), + settings); + settings.endGroup(); + } + + if (device) { set_device(device); start_capture([](QString infoMessage) { // TODO Emulate noquote() qDebug() << "Session error:" << infoMessage; }); - set_name(QFileInfo(filename).fileName()); + set_name(QString::fromStdString( + dynamic_pointer_cast(device)->display_name(device_manager_))); } } @@ -483,7 +506,6 @@ void Session::load_init_file(const string &file_name, const string &format) map input_opts; if (!format.empty()) { - // Got a user provided input format spec. const map > formats = device_manager_.context()->input_formats(); auto user_opts = pv::util::split_string(format, ":"); @@ -500,11 +522,6 @@ void Session::load_init_file(const string &file_name, const string &format) input_format = (*iter).second; input_opts = input_format_options(user_opts, input_format->options()); - } else { - // (Try to) auto detect the input format. Lookup failure - // is not fatal, when no input module claimed responsibility, - // then a session file gets loaded. - input_format = device_manager_.context()->input_format_match(file_name); } load_file(QString::fromStdString(file_name), input_format, input_opts); @@ -517,6 +534,10 @@ void Session::load_file(QString file_name, const QString errorMessage( QString("Failed to load file %1").arg(file_name)); + // In the absence of a caller's format spec, try to auto detect. + // Assume "sigrok session file" upon lookup miss. + if (!format) + format = device_manager_.context()->input_format_match(file_name.toStdString()); try { if (format) set_device(shared_ptr( @@ -1050,15 +1071,10 @@ void Session::feed_in_meta(shared_ptr meta) for (auto entry : meta->config()) { switch (entry.first->id()) { case SR_CONF_SAMPLERATE: - // We can't rely on the header to always contain the sample rate, - // so in case it's supplied via a meta packet, we use it. - if (!cur_samplerate_) - cur_samplerate_ = g_variant_get_uint64(entry.second.gobj()); - - /// @todo handle samplerate changes + cur_samplerate_ = g_variant_get_uint64(entry.second.gobj()); break; default: - // Unknown metadata is not an error. + qDebug() << "Received meta data key" << entry.first->id() << ", ignoring."; break; } }