X-Git-Url: http://git.code-monkey.de/?a=blobdiff_plain;f=pv%2Fdevices%2Finputfile.cpp;h=935b0c47bdf6e41714bf889a530af61513ccb420;hb=519d0ccbe67d005a9c442795ce3b8255e78ca46d;hp=3ddc8ae00db06042b97f5e10f599560b3d69b22b;hpb=2ad82c2e40b6865481733913a2c32735602f63c4;p=pulseview.git diff --git a/pv/devices/inputfile.cpp b/pv/devices/inputfile.cpp index 3ddc8ae..935b0c4 100644 --- a/pv/devices/inputfile.cpp +++ b/pv/devices/inputfile.cpp @@ -36,19 +36,18 @@ InputFile::InputFile(const std::shared_ptr &context, const std::map &options) : File(file_name), context_(context), - input_(format->create_input(options)), + format_(format), + options_(options), interrupt_(false) { - if (!input_) - throw QString("Failed to create input"); } void InputFile::open() { if (session_) close(); - - session_ = context_->create_session(); + else + session_ = context_->create_session(); } void InputFile::close() @@ -67,10 +66,14 @@ void InputFile::run() bool need_device = true; assert(session_); - assert(input_); + + input_ = format_->create_input(options_); + + if (!input_) + throw QString("Failed to create input"); interrupt_ = false; - std::ifstream f(file_name_); + std::ifstream f(file_name_, std::ios::binary); while (!interrupt_ && f) { f.read(buffer, BufferSize); const std::streamsize size = f.gcount(); @@ -86,6 +89,7 @@ void InputFile::run() break; } + session_->remove_devices(); // Remove instance from previous run session_->add_device(device_); need_device = false; }