(Messy merge fixes)
[ardour.git] / libs / ardour / ardour / diskstream.h
index 3c9aa0e0f62223434fef3d8dee4ae4bccefd1f7a..316daba52f7708190d050117e2176da6d7eff9dc 100644 (file)
@@ -33,7 +33,7 @@
 
 #include <pbd/fastlog.h>
 #include <pbd/ringbufferNPT.h>
-#include <pbd/atomic.h>
 
 #include <ardour/ardour.h>
 #include <ardour/configuration.h>
@@ -60,7 +60,8 @@ class DiskStream : public Stateful, public sigc::trackable
   public:
        enum Flag {
                Recordable = 0x1,
-               Hidden = 0x2
+               Hidden = 0x2,
+               Destructive = 0x4
        };
 
        DiskStream (Session &, const string& name, Flag f = Recordable);
@@ -92,11 +93,14 @@ class DiskStream : public Stateful, public sigc::trackable
 
        bool hidden() const { return _flags & Hidden; }
        bool recordable() const { return _flags & Recordable; }
+       bool destructive() const { return _flags & Destructive; }
+
+       void set_destructive (bool yn);
 
        jack_nframes_t roll_delay() const { return _roll_delay; }
        void set_roll_delay (jack_nframes_t);
 
-       void set_name (string str, void* src);
+       int set_name (string str, void* src);
 
        string input_source (uint32_t n=0) const {
                if (n < channels.size()) {
@@ -111,7 +115,7 @@ class DiskStream : public Stateful, public sigc::trackable
        }
 
        void set_record_enabled (bool yn, void *src);
-       bool record_enabled() const { return atomic_read (&_record_enabled); }
+       bool record_enabled() const { return g_atomic_int_get (&_record_enabled); }
        void punch_in ();
        void punch_out ();
 
@@ -150,11 +154,6 @@ class DiskStream : public Stateful, public sigc::trackable
 
        AudioPlaylist *playlist () { return _playlist; }
 
-       FileSource *fades_source (uint32_t n=0) {
-               if (n < channels.size())
-                       return channels[n].fades_source;
-               return 0;
-       }
        FileSource *write_source (uint32_t n=0) {
                if (n < channels.size())
                        return channels[n].write_source;
@@ -186,7 +185,6 @@ class DiskStream : public Stateful, public sigc::trackable
        static sigc::signal<void> DiskOverrun;
        static sigc::signal<void> DiskUnderrun;
        static sigc::signal<void,DiskStream*> DiskStreamCreated;   // XXX use a ref with sigc2
-       static sigc::signal<void,DiskStream*> CannotRecordNoInput; // XXX use a ref with sigc2
        static sigc::signal<void,list<Source*>*> DeleteSources;
 
        /* stateful */
@@ -245,7 +243,8 @@ class DiskStream : public Stateful, public sigc::trackable
        void set_block_size (jack_nframes_t);
        int  internal_playback_seek (jack_nframes_t distance);
        int  can_internal_playback_seek (jack_nframes_t distance);
-       void reset_write_sources (bool);
+       int  rename_write_sources ();
+       void reset_write_sources (bool, bool force = false);
        void non_realtime_input_change ();
 
        uint32_t read_data_count() const { return _read_data_count; }
@@ -269,6 +268,18 @@ class DiskStream : public Stateful, public sigc::trackable
 
        ~DiskStream();
 
+       enum TransitionType {
+               CaptureStart = 0,
+               CaptureEnd
+       };
+       
+       struct CaptureTransition {
+
+               TransitionType   type;
+               // the start or end file frame pos
+               jack_nframes_t   capture_val;
+       };
+       
        struct ChannelInfo {
 
                Sample     *playback_wrap_buffer;
@@ -293,10 +304,15 @@ class DiskStream : public Stateful, public sigc::trackable
 
                RingBufferNPT<Sample>::rw_vector playback_vector;
                RingBufferNPT<Sample>::rw_vector capture_vector;
+
+               RingBufferNPT<CaptureTransition> * capture_transition_buf;
+               // the following are used in the butler thread only
+               jack_nframes_t                     curr_capture_cnt;
        };
 
        typedef vector<ChannelInfo> ChannelList;
 
+
        string            _name;
        ARDOUR::Session&  _session;
        ARDOUR::IO*       _io;
@@ -304,8 +320,7 @@ class DiskStream : public Stateful, public sigc::trackable
        uint32_t      _n_channels;
        id_t              _id;
 
-       atomic_t                 _record_enabled;
-       bool                      rec_monitoring_off_for_roll;
+       mutable gint             _record_enabled;
        AudioPlaylist*           _playlist;
        double                   _visible_speed;
        double                   _actual_speed;
@@ -350,7 +365,7 @@ class DiskStream : public Stateful, public sigc::trackable
        AlignStyle               _persistent_alignment_style;
        bool                      first_input_change;
 
-       PBD::NonBlockingLock  state_lock;
+       Glib::Mutex  state_lock;
 
        jack_nframes_t scrub_start;
        jack_nframes_t scrub_buffer_size;
@@ -364,10 +379,10 @@ class DiskStream : public Stateful, public sigc::trackable
 
        /* the two central butler operations */
 
-       int do_flush (bool force = false);
-       int do_refill (Sample *mixdown_buffer, float *gain_buffer);
+       int do_flush (char * workbuf, bool force = false);
+       int do_refill (Sample *mixdown_buffer, float *gain_buffer, char *workbuf);
 
-       int read (Sample* buf, Sample* mixdown_buffer, float* gain_buffer, jack_nframes_t& start, jack_nframes_t cnt, 
+       int read (Sample* buf, Sample* mixdown_buffer, float* gain_buffer, char * workbuf, jack_nframes_t& start, jack_nframes_t cnt, 
                  ChannelInfo& channel_info, int channel, bool reversed);
 
        uint32_t i_am_the_modifier;
@@ -389,7 +404,7 @@ class DiskStream : public Stateful, public sigc::trackable
        };
 
        vector<CaptureInfo*> capture_info;
-       PBD::Lock  capture_info_lock;
+       Glib::Mutex  capture_info_lock;
        
        void init (Flag);
 
@@ -421,11 +436,10 @@ class DiskStream : public Stateful, public sigc::trackable
        int use_pending_capture_data (XMLNode& node);
 
        void get_input_sources ();
-       
        void check_record_status (jack_nframes_t transport_frame, jack_nframes_t nframes, bool can_record);
-
        void set_align_style_from_io();
-
+       void setup_destructive_playlist ();
+       void use_destructive_playlist ();
 };
 
 }; /* namespace ARDOUR */