]> sigrok.org Git - pulseview.git/commitdiff
Session: Record acquisition start time and use it when saving
authorSoeren Apel <redacted>
Sat, 21 Oct 2023 20:28:10 +0000 (22:28 +0200)
committerSoeren Apel <redacted>
Sat, 21 Oct 2023 20:28:10 +0000 (22:28 +0200)
pv/session.cpp
pv/session.hpp
pv/storesession.cpp

index 0e17a07bb05f9c663c139d5ed17ad6c965e8939e..f1a153e7e44932518b34566c3cdfac2d77001b99 100644 (file)
@@ -829,6 +829,8 @@ void Session::start_capture(function<void (const QString)> error_handler)
                name_changed();
        }
 
+       acq_start_time_ = Glib::DateTime::create_now_local();
+
        // Begin the session
        sampling_thread_ = std::thread(&Session::sample_thread_proc, this, error_handler);
 }
@@ -923,6 +925,11 @@ double Session::get_samplerate() const
        return samplerate;
 }
 
+Glib::DateTime Session::get_acquisition_start_time() const
+{
+       return acq_start_time_;
+}
+
 uint32_t Session::get_highest_segment_id() const
 {
        return highest_segment_id_;
index ba48a4074d555de95d9c10ea17b00a836f006cf9..94338c20e259144a7bb9ae3bad96edc9ef4c44f5 100644 (file)
@@ -35,6 +35,8 @@
 #include <thread>
 #include <vector>
 
+#include <glibmm/datetime.h>
+
 #include <QObject>
 #include <QSettings>
 #include <QString>
@@ -185,6 +187,7 @@ public:
        void stop_capture();
 
        double get_samplerate() const;
+       Glib::DateTime get_acquisition_start_time() const;
 
        uint32_t get_highest_segment_id() const;
        uint64_t get_segment_sample_count(uint32_t segment_id) const;
@@ -312,6 +315,7 @@ private:
        bool frame_began_;
 
        QElapsedTimer acq_time_;
+       Glib::DateTime acq_start_time_;
 
        MetadataObjManager metadata_obj_manager_;
 
index 8aaeff6ff4e5888714ef3096deb9059605cfe133..5eb6a8ad25aacbec2085500ad95a6ec9363a0ad1 100644 (file)
@@ -185,8 +185,7 @@ bool StoreSession::start()
                                any_segment->samplerate())}});
                output_->receive(meta);
 
-               Glib::DateTime start_time;
-               auto header = context->create_header_packet(start_time);
+               auto header = context->create_header_packet(session_.get_acquisition_start_time());
                output_->receive(header);
        } catch (Error& error) {
                error_ = tr("Error while saving: ") + error.what();