Remove obsolete input module support.
authorBert Vermeulen <bert@biot.com>
Mon, 25 Aug 2014 15:29:40 +0000 (17:29 +0200)
committerBert Vermeulen <bert@biot.com>
Thu, 28 Aug 2014 10:35:49 +0000 (12:35 +0200)
This no longer works against libsigrok, which has an entirely new
API for input modules.

CMakeLists.txt
pv/device/file.cpp
pv/device/inputfile.cpp [deleted file]
pv/device/inputfile.h [deleted file]
pv/dialogs/about.cpp
pv/sigsession.cpp
pv/sigsession.h

index a8cd6c7bfec8aaf7ab60a0d9b69d30ec598e3091..2c1faddc10c9a0f5d8210fec5f571caa9e5b79b0 100644 (file)
@@ -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
index 0286a2581471225fae43fa0ea4f793b23e1ee1af..edc2da2bdd96cad6ba3a56eb39d13c2a1a2b2e4e 100644 (file)
@@ -19,7 +19,6 @@
  */
 
 #include "file.h"
-#include "inputfile.h"
 #include "sessionfile.h"
 
 #include <boost/filesystem.hpp>
@@ -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 (file)
index 61aa85a..0000000
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * This file is part of the PulseView project.
- *
- * Copyright (C) 2014 Joel Holdsworth <joel@airwebreathe.org.uk>
- *
- * 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 <cassert>
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
-
-#include "inputfile.h"
-
-#include <libsigrok/libsigrok.h>
-
-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 (file)
index 150418d..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * This file is part of the PulseView project.
- *
- * Copyright (C) 2014 Joel Holdsworth <joel@airwebreathe.org.uk>
- *
- * 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 <string>
-
-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
index c4827962c59afda9891b62a99cd2268ae8c44234..f8394f2ae6f3784bdd72ef84089ac26e3dcd3711 100644 (file)
@@ -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><td colspan=\"2\"><b>" +
-               tr("Supported input formats:") +
-               "</b></td></tr>");
-       inputs = sr_input_list();
-       for (int i = 0; inputs[i]; ++i) {
-               s.append(QString("<tr><td><i>%1</i></td><td>%2</td></tr>")
-                        .arg(QString::fromUtf8(inputs[i]->id))
-                        .arg(QString::fromUtf8(inputs[i]->description)));
-       }
-
 #ifdef ENABLE_DECODE
        s.append("<tr><td colspan=\"2\"><b>" +
                tr("Supported protocol decoders:") +
index 201892889abf97d05823529d8d3cf7e191eb0a2b..ac9c052b3bf9b8d50e66adac02efc670359fac4d 100644 (file)
@@ -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();
 
index a06de7e14db9ae7e83813932d95c7fec1ae8a5cc..a4e14d9cd099e8a6755ace39ddd26fd9d3bd21b5 100644 (file)
@@ -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<void (const QString)> error_handler,
-               sr_input_format *format = NULL);
-
        void sample_thread_proc(std::shared_ptr<device::DevInst> dev_inst,
                std::function<void (const QString)> error_handler);