Ardour  8.12
ardour/ardour/source.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2014 David Robillard <d@drobilla.net>
3  * Copyright (C) 2006-2017 Paul Davis <paul@linuxaudiosystems.com>
4  * Copyright (C) 2009-2012 Carl Hetherington <carl@carlh.net>
5  * Copyright (C) 2016-2019 Robin Gareus <robin@gareus.org>
6  * Copyright (C) 2018-2019 Ben Loftis <ben@harrisonconsoles.com>
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_source_h__
24 #define __ardour_source_h__
25 
26 #include <atomic>
27 #include <memory>
28 #include <string>
29 #include <set>
30 
31 #include <glibmm/threads.h>
32 
34 
35 #include "ardour/ardour.h"
36 #include "ardour/session_object.h"
37 #include "ardour/data_type.h"
39 
40 namespace ARDOUR {
41 
42 class Session;
43 
45  public std::enable_shared_from_this<ARDOUR::Source>
46 {
47 public:
48  enum Flag {
49  Writable = 0x1,
50  CanRename = 0x2,
51  Broadcast = 0x4,
52  Removable = 0x8,
53  RemovableIfEmpty = 0x10,
54  RemoveAtDestroy = 0x20,
55  NoPeakFile = 0x40,
56  /* No longer in use but kept to allow loading of older sessions */
57  Destructive = 0x80,
58  Empty = 0x100, /* used for MIDI only */
59  RF64_RIFF = 0x200,
60  Missing = 0x400, /* used for MIDI only */
61  };
62 
63  typedef Glib::Threads::RWLock::ReaderLock ReaderLock;
64  typedef Glib::Threads::RWLock::WriterLock WriterLock;
65 
66  Source (Session&, DataType type, const std::string& name, Flag flags=Flag(0));
67  Source (Session&, const XMLNode&);
68 
69  virtual ~Source ();
70 
71  DataType type() { return _type; }
72 
73  time_t timestamp() const { return _timestamp; }
74  void stamp (time_t when) { _timestamp = when; }
75 
76  virtual timepos_t length() const { return _length; }
77 
78  virtual bool empty () const;
79  virtual void update_length (timepos_t const & dur) {}
80 
81  void set_take_id (std::string id) { _take_id =id; }
82  const std::string& take_id () const { return _take_id; }
83 
85 
86  virtual void mark_streaming_write_started (const WriterLock& lock) {}
87  virtual void mark_streaming_write_completed (const WriterLock& lock) = 0;
88 
89  virtual void session_saved() {}
90 
91  XMLNode& get_state () const;
92  int set_state (XMLNode const &, int version);
93 
94  bool writable () const;
95 
96  virtual bool length_mutable() const { return false; }
97 
98  static PBD::Signal1<void,Source*> SourceCreated;
99 
100  bool has_been_analysed() const;
101  virtual bool can_be_analysed() const { return false; }
102  virtual void set_been_analysed (bool yn);
104 
105  PBD::Signal0<void> AnalysisChanged;
106 
108  std::string get_transients_path() const;
109  int load_transients (const std::string&);
110 
111  size_t n_captured_xruns () const { return _xruns.size (); }
112  XrunPositions const& captured_xruns () const { return _xruns; }
113  void set_captured_xruns (XrunPositions const& xruns) { _xruns = xruns; }
114  void set_captured_marks (CueMarkers const& marks);
115 
116  CueMarkers const & cue_markers() const { return _cue_markers; }
117  bool add_cue_marker (CueMarker const &);
118  bool move_cue_marker (CueMarker const &, timepos_t const & source_relative_position);
119  bool remove_cue_marker (CueMarker const &);
120  bool rename_cue_marker (CueMarker&, std::string const &);
122  PBD::Signal0<void> CueMarkersChanged;
123 
124  virtual timepos_t natural_position() const { return _natural_position; }
125  virtual void set_natural_position (timepos_t const & pos);
126 
127  bool have_natural_position() const { return _have_natural_position; }
128 
129  /* This method is only for use during a capture pass. It makes no sense
130  * in any other context.
131  */
133 
135 
136  Glib::Threads::RWLock& mutex() { return _lock; }
137  Flag flags() const { return _flags; }
138 
139  virtual void inc_use_count ();
140  virtual void dec_use_count ();
141  int use_count() const { return _use_count.load(); }
142  bool used() const { return use_count() > 0; }
143 
144  uint32_t level() const { return _level; }
145 
146  std::string ancestor_name() { return _ancestor_name.empty() ? name() : _ancestor_name; }
147  void set_ancestor_name(const std::string& name) { _ancestor_name = name; }
148 
149  void set_captured_for (std::string str) { _captured_for = str; }
150  std::string captured_for() const { return _captured_for; }
151 
154 
155  protected:
158  time_t _timestamp;
159  std::string _take_id;
162  bool _analysed;
163  std::atomic<int> _use_count;
164  uint32_t _level; /* how deeply nested is this source w.r.t a disk file */
165  std::string _ancestor_name;
166  std::string _captured_for;
170 
171  typedef std::vector<SegmentDescriptor> SegmentDescriptors;
173 
174  mutable Glib::Threads::RWLock _lock;
175  mutable Glib::Threads::Mutex _analysis_lock;
176 
177  private:
179 
181  int set_cue_state (XMLNode const &, int);
182 };
183 
184 }
185 
186 #endif /* __ardour_source_h__ */
uint32_t level() const
size_t n_captured_xruns() const
virtual timepos_t length() const
Source(Session &, DataType type, const std::string &name, Flag flags=Flag(0))
std::vector< SegmentDescriptor > SegmentDescriptors
AnalysisFeatureList transients
const std::string & take_id() const
void mark_for_remove()
virtual ~Source()
std::atomic< int > _use_count
virtual void set_been_analysed(bool yn)
void set_ancestor_name(const std::string &name)
bool has_been_analysed() const
Glib::Threads::Mutex _analysis_lock
static PBD::Signal1< void, Source * > SourceCreated
bool move_cue_marker(CueMarker const &, timepos_t const &source_relative_position)
bool remove_cue_marker(CueMarker const &)
bool rename_cue_marker(CueMarker &, std::string const &)
timecnt_t time_since_capture_start(timepos_t const &pos)
XMLNode & get_state() const
int set_state(XMLNode const &, int version)
time_t timestamp() const
void set_allow_remove_if_empty(bool yn)
bool have_natural_position() const
virtual bool can_be_analysed() const
void stamp(time_t when)
void fix_writable_flags()
void set_captured_for(std::string str)
std::string ancestor_name()
bool get_segment_descriptor(TimelineRange const &, SegmentDescriptor &)
Glib::Threads::RWLock _lock
virtual void mark_streaming_write_completed(const WriterLock &lock)=0
void set_captured_marks(CueMarkers const &marks)
std::string _ancestor_name
Glib::Threads::RWLock::ReaderLock ReaderLock
void set_captured_xruns(XrunPositions const &xruns)
CueMarkers const & cue_markers() const
bool clear_cue_markers()
virtual bool empty() const
virtual void inc_use_count()
XrunPositions _xruns
int set_cue_state(XMLNode const &, int)
int set_segment_descriptor(SegmentDescriptor const &)
PBD::Signal0< void > CueMarkersChanged
virtual void set_natural_position(timepos_t const &pos)
Glib::Threads::RWLock::WriterLock WriterLock
virtual timepos_t natural_position() const
Source(Session &, const XMLNode &)
virtual bool check_for_analysis_data_on_disk()
virtual void update_length(timepos_t const &dur)
XMLNode & get_cue_state() const
bool writable() const
virtual void dec_use_count()
bool add_cue_marker(CueMarker const &)
SegmentDescriptors segment_descriptors
std::string _captured_for
virtual bool length_mutable() const
void set_take_id(std::string id)
virtual void session_saved()
int load_transients(const std::string &)
std::string get_transients_path() const
XrunPositions const & captured_xruns() const
virtual void mark_streaming_write_started(const WriterLock &lock)
PBD::Signal0< void > AnalysisChanged
std::string captured_for() const
Glib::Threads::RWLock & mutex()
Definition: xml++.h:114
GtkImageIconNameData name
Definition: gtkimage.h:6
#define LIBARDOUR_API
std::list< samplepos_t > AnalysisFeatureList
std::set< CueMarker > CueMarkers
std::vector< samplepos_t > XrunPositions