Fix #599 by supplying correct length to create_logic_packet()
[pulseview.git] / pv / storesession.cpp
index 1a27e5654dd9e8e66ec96fb0d773a96ad83536f0..e4af5db7bcf40d8b123449a676e472c814f3c9d2 100644 (file)
@@ -137,17 +137,10 @@ bool StoreSession::start()
 
                map<string, Glib::VariantBase> options = options_;
 
-               // If the output has the capability to write files, use it.
-               // Otherwise, open the output stream.
-               const auto opt_list = output_format_->options();
-               if (opt_list.find("filename") != opt_list.end())
-                       options["filename"] =
-                               Glib::Variant<Glib::ustring>::create(file_name_);
-               else
-                       output_stream_.open(file_name_, ios_base::binary |
-                               ios_base::trunc | ios_base::out);
-
-               output_ = output_format_->create_output(device, options);
+               output_stream_.open(file_name_, ios_base::binary |
+                       ios_base::trunc | ios_base::out);
+
+               output_ = output_format_->create_output(file_name_, device, options);
                auto meta = context->create_meta_packet(
                        {{ConfigKey::SAMPLERATE, Glib::Variant<guint64>::create(
                                segment->samplerate())}});
@@ -205,7 +198,7 @@ void StoreSession::store_proc(shared_ptr<data::LogicSegment> segment)
                        start_sample + samples_per_block, sample_count);
                segment->get_samples(data, start_sample, end_sample);
 
-               size_t length = end_sample - start_sample;
+               size_t length = (end_sample - start_sample) * unit_size;
 
                try {
                        const auto context = session_.device_manager().context();