From: Bert Vermeulen Date: Mon, 25 Aug 2014 15:29:40 +0000 (+0200) Subject: Remove obsolete input module support. X-Git-Tag: pulseview-0.3.0~555 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=ab973f4729258b729d2aa84abfa14b61609fa35e;p=pulseview.git Remove obsolete input module support. This no longer works against libsigrok, which has an entirely new API for input modules. --- diff --git a/CMakeLists.txt b/CMakeLists.txt index a8cd6c7b..2c1faddc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -138,7 +138,6 @@ set(pulseview_SOURCES pv/device/device.cpp pv/device/file.cpp pv/device/devinst.cpp - pv/device/inputfile.cpp pv/device/sessionfile.cpp pv/dialogs/about.cpp pv/dialogs/connect.cpp diff --git a/pv/device/file.cpp b/pv/device/file.cpp index 0286a258..edc2da2b 100644 --- a/pv/device/file.cpp +++ b/pv/device/file.cpp @@ -19,7 +19,6 @@ */ #include "file.h" -#include "inputfile.h" #include "sessionfile.h" #include @@ -59,7 +58,7 @@ File* File::create(const string &name) } } - return new InputFile(name); + return NULL; } } // device diff --git a/pv/device/inputfile.cpp b/pv/device/inputfile.cpp deleted file mode 100644 index 61aa85a1..00000000 --- a/pv/device/inputfile.cpp +++ /dev/null @@ -1,143 +0,0 @@ -/* - * This file is part of the PulseView project. - * - * Copyright (C) 2014 Joel Holdsworth - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include - -#include -#include -#include - -#include "inputfile.h" - -#include - -using std::string; - -namespace pv { -namespace device { - -InputFile::InputFile(const std::string &path) : - File(path), - _input(NULL) -{ -} - -sr_dev_inst* InputFile::dev_inst() const -{ - assert(_input); - return _input->sdi; -} - -void InputFile::use(SigSession *owner) throw(QString) -{ - assert(!_input); - - _input = load_input_file_format(_path, NULL); - File::use(owner); - - sr_session_new(&SigSession::_sr_session); - - if (sr_session_dev_add(SigSession::_sr_session, _input->sdi) != SR_OK) - throw tr("Failed to add session device."); -} - -void InputFile::release() -{ - if (!_owner) - return; - - assert(_input); - File::release(); - sr_dev_close(_input->sdi); - sr_session_destroy(SigSession::_sr_session); - _input = NULL; -} - -sr_input_format* InputFile::determine_input_file_format( - const string &filename) -{ - int i; - - /* If there are no input formats, return NULL right away. */ - sr_input_format *const *const inputs = sr_input_list(); - if (!inputs) { - g_critical("No supported input formats available."); - return NULL; - } - - /* Otherwise, try to find an input module that can handle this file. */ - for (i = 0; inputs[i]; i++) { - if (inputs[i]->format_match(filename.c_str())) - break; - } - - /* Return NULL if no input module wanted to touch this. */ - if (!inputs[i]) { - g_critical("Error: no matching input module found."); - return NULL; - } - - return inputs[i]; -} - -sr_input* InputFile::load_input_file_format(const string &filename, - sr_input_format *format) -{ - struct stat st; - sr_input *in; - - if (!format && !(format = - determine_input_file_format(filename.c_str()))) { - /* The exact cause was already logged. */ - throw tr("Failed to load file"); - } - - if (stat(filename.c_str(), &st) == -1) - throw tr("Failed to load file"); - - /* Initialize the input module. */ - if (!(in = new sr_input)) { - throw tr("Failed to allocate input module."); - } - - in->format = format; - in->param = NULL; - if (in->format->init && - in->format->init(in, filename.c_str()) != SR_OK) { - throw tr("Failed to load file"); - } - - return in; -} - -void InputFile::start() -{ -} - -void InputFile::run() -{ - assert(_input); - assert(_input->format); - assert(_input->format->loadfile); - _input->format->loadfile(_input, _path.c_str()); -} - -} // device -} // pv diff --git a/pv/device/inputfile.h b/pv/device/inputfile.h deleted file mode 100644 index 150418d5..00000000 --- a/pv/device/inputfile.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * This file is part of the PulseView project. - * - * Copyright (C) 2014 Joel Holdsworth - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef PULSEVIEW_PV_DEVICE_INPUTFILE_H -#define PULSEVIEW_PV_DEVICE_INPUTFILE_H - -#include "file.h" - -#include - -struct sr_input; -struct sr_input_format; - -namespace pv { -namespace device { - -class InputFile : public File -{ -public: - InputFile(const std::string &path); - - sr_dev_inst* dev_inst() const; - - virtual void use(SigSession *owner) throw(QString); - - virtual void release(); - - virtual void start(); - - virtual void run(); - -private: - /** - * Attempts to autodetect the format. Failing that - * @param filename The filename of the input file. - * @return A pointer to the 'struct sr_input_format' that should be used, - * or NULL if no input format was selected or auto-detected. - */ - static sr_input_format* determine_input_file_format( - const std::string &filename); - - static sr_input* load_input_file_format(const std::string &filename, - sr_input_format *format); -private: - sr_input *_input; -}; - -} // device -} // pv - -#endif // PULSEVIEW_PV_DEVICE_INPUTFILE_H diff --git a/pv/dialogs/about.cpp b/pv/dialogs/about.cpp index c4827962..f8394f2a 100644 --- a/pv/dialogs/about.cpp +++ b/pv/dialogs/about.cpp @@ -41,7 +41,6 @@ About::About(QWidget *parent) : ui(new Ui::About) { struct sr_dev_driver **drivers; - struct sr_input_format **inputs; #ifdef ENABLE_DECODE struct srd_decoder *dec; @@ -72,16 +71,6 @@ About::About(QWidget *parent) : .arg(QString::fromUtf8(drivers[i]->longname))); } - s.append("" + - tr("Supported input formats:") + - ""); - inputs = sr_input_list(); - for (int i = 0; inputs[i]; ++i) { - s.append(QString("%1%2") - .arg(QString::fromUtf8(inputs[i]->id)) - .arg(QString::fromUtf8(inputs[i]->description))); - } - #ifdef ENABLE_DECODE s.append("" + tr("Supported protocol decoders:") + diff --git a/pv/sigsession.cpp b/pv/sigsession.cpp index 20189288..ac9c052b 100644 --- a/pv/sigsession.cpp +++ b/pv/sigsession.cpp @@ -100,6 +100,9 @@ void SigSession::set_device( { using pv::device::Device; + if (!dev_inst) + return; + // Ensure we are not capturing before setting the device stop_capture(); diff --git a/pv/sigsession.h b/pv/sigsession.h index a06de7e1..a4e14d9c 100644 --- a/pv/sigsession.h +++ b/pv/sigsession.h @@ -121,21 +121,6 @@ private: void read_sample_rate(const sr_dev_inst *const sdi); private: - /** - * Attempts to autodetect the format. Failing that - * @param filename The filename of the input file. - * @return A pointer to the 'struct sr_input_format' that should be - * used, or NULL if no input format was selected or - * auto-detected. - */ - static sr_input_format* determine_input_file_format( - const std::string &filename); - - static sr_input* load_input_file_format( - const std::string &filename, - std::function error_handler, - sr_input_format *format = NULL); - void sample_thread_proc(std::shared_ptr dev_inst, std::function error_handler);