add finite state machine to control/manage transport state
[ardour.git] / libs / ardour / ardour / export_status.h
1 /*
2  * Copyright (C) 2008-2012 Sakari Bergen <sakari.bergen@beatwaves.net>
3  * Copyright (C) 2008-2017 Paul Davis <paul@linuxaudiosystems.com>
4  * Copyright (C) 2008 Nick Mainsbridge <mainsbridge@gmail.com>
5  * Copyright (C) 2009-2012 David Robillard <d@drobilla.net>
6  * Copyright (C) 2016-2019 Robin Gareus <robin@gareus.org>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License along
19  * with this program; if not, write to the Free Software Foundation, Inc.,
20  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21  */
22
23 #ifndef __ardour_export_status_h__
24 #define __ardour_export_status_h__
25
26 #include <stdint.h>
27
28 #include "ardour/libardour_visibility.h"
29 #include "ardour/export_analysis.h"
30 #include "ardour/types.h"
31
32 #include "pbd/signals.h"
33
34 namespace ARDOUR
35 {
36
37 class LIBARDOUR_API ExportStatus {
38   public:
39         ExportStatus ();
40         void init ();
41
42         /* Status info */
43
44         volatile bool           stop;
45
46         void abort (bool error_occurred = false);
47         bool aborted () const { return _aborted; }
48         bool errors () const { return _errors; }
49         bool running () const { return _running; }
50
51         void set_running (bool r) {
52                 assert (!_run_lock.trylock()); // must hold lock
53                 _running = r;
54         }
55         Glib::Threads::Mutex& lock () { return _run_lock; }
56
57         PBD::Signal1<void,TransportRequestSource> Finished;
58         void finish (TransportRequestSource);
59
60         void cleanup ();
61
62         /* Progress info */
63
64         volatile enum Progress {
65                 Exporting,
66                 Normalizing,
67                 Encoding,
68                 Tagging,
69                 Uploading,
70                 Command }
71                                 active_job;
72
73         volatile uint32_t       total_timespans;
74         volatile uint32_t       timespan;
75         std::string             timespan_name;
76
77         volatile samplecnt_t    total_samples;
78         volatile samplecnt_t    processed_samples;
79
80         volatile samplecnt_t    total_samples_current_timespan;
81         volatile samplecnt_t    processed_samples_current_timespan;
82
83         volatile uint32_t       total_postprocessing_cycles;
84         volatile uint32_t       current_postprocessing_cycle;
85
86         AnalysisResults         result_map;
87
88   private:
89         volatile bool          _aborted;
90         volatile bool          _errors;
91         volatile bool          _running;
92
93         Glib::Threads::Mutex   _run_lock;
94 };
95
96 } // namespace ARDOUR
97
98 #endif /* __ardour_export_status_h__ */