const std::map<std::string, Glib::VariantBase> &options) :
File(file_name),
context_(context),
- input_(format->create_input(options)),
- interrupt_(false) {
- if (!input_)
- throw QString("Failed to create input");
+ format_(format),
+ options_(options),
+ interrupt_(false)
+{
}
-void InputFile::open() {
+void InputFile::open()
+{
if (session_)
close();
-
- session_ = context_->create_session();
+ else
+ session_ = context_->create_session();
}
-void InputFile::close() {
+void InputFile::close()
+{
if (session_)
session_->remove_devices();
}
-void InputFile::start() {
+void InputFile::start()
+{
}
-void InputFile::run() {
+void InputFile::run()
+{
char buffer[BufferSize];
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();
break;
}
+ session_->remove_devices(); // Remove instance from previous run
session_->add_device(device_);
need_device = false;
}
input_->end();
}
-void InputFile::stop() {
+void InputFile::stop()
+{
interrupt_ = true;
}