Clean up Region interface, remove Readable stub kludge.
authorDavid Robillard <d@drobilla.net>
Thu, 19 Feb 2009 21:06:56 +0000 (21:06 +0000)
committerDavid Robillard <d@drobilla.net>
Thu, 19 Feb 2009 21:06:56 +0000 (21:06 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@4643 d708f5d6-7413-0410-9779-e7cbd77b26cf

libs/ardour/ardour/audioregion.h
libs/ardour/ardour/audiosource.h
libs/ardour/ardour/crossfade.h
libs/ardour/ardour/midi_region.h
libs/ardour/ardour/readable.h
libs/ardour/audioregion.cc
libs/ardour/audiosource.cc
libs/ardour/crossfade.cc
libs/ardour/midi_region.cc

index b259a132295b2d0039c8536e8049fbd1494fddfe..9be2defaa7f01c58b20b9d8a47b731338e89b562 100644 (file)
@@ -92,21 +92,21 @@ class AudioRegion : public Region
                ReadOpsFades = 0x8
        };
        
-       virtual nframes64_t read (Sample*, nframes64_t pos, nframes64_t cnt, int channel) const;
-       virtual nframes64_t read_with_ops (Sample*, nframes64_t pos, nframes64_t cnt, int channel, ReadOps rops) const;
+       virtual nframes_t read (Sample*, sframes_t pos, nframes_t cnt, int channel) const;
+       virtual nframes_t read_with_ops (Sample*, sframes_t pos, nframes_t cnt, int channel, ReadOps rops) const;
        virtual nframes64_t readable_length() const { return length(); }
 
-       virtual nframes_t read_at (Sample *buf, Sample *mixdown_buf,
-                       float *gain_buf, nframes_t position, nframes_t cnt, 
+       virtual nframes_t read_at (Sample *buf, Sample *mixdown_buf, float *gain_buf,
+                       sframes_t position,
+                       nframes_t cnt,
                        uint32_t  chan_n      = 0,
                        nframes_t read_frames = 0,
                        nframes_t skip_frames = 0) const;
        
-       virtual nframes_t master_read_at (Sample *buf, Sample *mixdown_buf, 
-                                         float *gain_buf,
-                                         nframes_t position, nframes_t cnt, uint32_t chan_n=0) const;
+       virtual nframes_t master_read_at (Sample *buf, Sample *mixdown_buf, float *gain_buf,
+                       sframes_t position, nframes_t cnt, uint32_t chan_n=0) const;
        
-       virtual nframes_t read_raw_internal (Sample*, nframes_t, nframes_t) const;
+       virtual nframes_t read_raw_internal (Sample*, sframes_t, nframes_t) const;
 
        XMLNode& state (bool);
        int      set_state (const XMLNode&);
@@ -186,8 +186,8 @@ class AudioRegion : public Region
        void recompute_gain_at_start ();
 
        nframes_t _read_at (const SourceList&, nframes_t limit,
-                           Sample *buf, Sample *mixdown_buffer, 
-                           float *gain_buffer, nframes_t position, nframes_t cnt, 
+                           Sample *buf, Sample *mixdown_buffer, float *gain_buffer,
+                               sframes_t position, nframes_t cnt, 
                            uint32_t chan_n = 0,
                            nframes_t read_frames = 0,
                            nframes_t skip_frames = 0,
index 0ed621c6acbb5eb2e35c0e07985e655607c93c67..08435bf3b1a422aee9552ca469dce9ba3615310b 100644 (file)
@@ -57,15 +57,7 @@ class AudioSource : virtual public Source,
 
        virtual nframes_t available_peaks (double zoom) const;
 
-       /** Stopgap for Readable until nframes_t becomes nframes64_t. */
-       virtual nframes64_t read (Sample *dst, nframes64_t start, nframes64_t cnt, int channel) const {
-               /* XXX currently ignores channel, assuming that source is always mono, which
-                  historically has been true.
-               */
-               return read (dst, (nframes_t) start, (nframes_t) cnt);
-       }
-
-       virtual nframes_t read (Sample *dst, sframes_t start, nframes_t cnt) const;
+       virtual nframes_t read (Sample *dst, sframes_t start, nframes_t cnt, int channel=0) const;
        virtual nframes_t write (Sample *src, nframes_t cnt);
 
        virtual float sample_rate () const = 0;
index b0785a6e594e1d2d29acdf04a27131d43b0e290d..2b893478d46b7728740684f879802abdd635812e 100644 (file)
@@ -81,7 +81,7 @@ class Crossfade : public ARDOUR::AudioRegion
        boost::shared_ptr<ARDOUR::AudioRegion> out() const { return _out; }
        
        nframes_t read_at (Sample *buf, Sample *mixdown_buffer, 
-                               float *gain_buffer, nframes_t position, nframes_t cnt, 
+                               float *gain_buffer, sframes_t position, nframes_t cnt, 
                                uint32_t chan_n,
                                nframes_t read_frames = 0,
                                nframes_t skip_frames = 0) const;
@@ -170,7 +170,7 @@ class Crossfade : public ARDOUR::AudioRegion
        bool update ();
 
   protected:
-       nframes_t read_raw_internal (Sample*, nframes_t, nframes_t) const;      
+       nframes_t read_raw_internal (Sample*, sframes_t, nframes_t) const;      
 };
 
 
index dc95fccdb4ab227d87f476b0e3a8aacc34d7d16c..0760fb7268603bca0590a436fe86ebba1d88a91e 100644 (file)
@@ -54,17 +54,17 @@ class MidiRegion : public Region
        boost::shared_ptr<MidiSource> midi_source (uint32_t n=0) const;
        
        /* Stub Readable interface */
-       virtual nframes64_t read (Sample*, nframes64_t pos, nframes64_t cnt, int channel) const { return 0; }
-       virtual nframes64_t readable_length() const { return length(); }
+       virtual nframes_t read (Sample*, sframes_t pos, nframes_t cnt, int channel) const { return 0; }
+       virtual sframes_t readable_length() const { return length(); }
 
        nframes_t read_at (MidiRingBuffer<nframes_t>& dst,
-                          nframes_t position,
-                          nframes_t dur, 
-                          uint32_t  chan_n = 0,
-                          NoteMode  mode = Sustained) const;
+                       sframes_t position,
+                       nframes_t dur, 
+                       uint32_t  chan_n = 0,
+                       NoteMode  mode = Sustained) const;
 
        nframes_t master_read_at (MidiRingBuffer<nframes_t>& dst,
-                       nframes_t position,
+                       sframes_t position,
                        nframes_t dur,
                        uint32_t  chan_n = 0,
                        NoteMode  mode = Sustained) const;
index e072a1c95e15aa91234b7cece3ee2cf3d3c548cb..a65af23312661c81e301eb6320840dc88e4549d3 100644 (file)
@@ -10,9 +10,9 @@ class Readable {
        Readable () {}
        virtual ~Readable() {}
 
-       virtual nframes64_t read (Sample*, nframes64_t pos, nframes64_t cnt, int channel) const = 0;
-       virtual nframes64_t readable_length() const = 0;
-       virtual uint32_t    n_channels () const = 0;
+       virtual nframes_t read (Sample*, sframes_t pos, nframes_t cnt, int channel) const = 0;
+       virtual sframes_t readable_length() const = 0;
+       virtual uint32_t  n_channels () const = 0;
 };
 
 }
index e48f2ae586cd84813f8b83528339eb4331e56cdf..aafa67e7d3da8b63e91482205ee7e2385faa4c11 100644 (file)
@@ -76,7 +76,7 @@ AudioRegion::init ()
        listen_to_my_sources ();
 }
 
-/* constructor for use by derived types only */
+/** Constructor for use by derived types only */
 AudioRegion::AudioRegion (Session& s, nframes_t start, nframes_t length, string name)
        : Region (s, start, length, name, DataType::AUDIO)
        , _automatable(s)
@@ -119,7 +119,7 @@ AudioRegion::AudioRegion (boost::shared_ptr<AudioSource> src, nframes_t start, n
        init ();
 }
 
-/* Basic AudioRegion constructor (many channels) */
+/** Basic AudioRegion constructor (many channels) */
 AudioRegion::AudioRegion (const SourceList& srcs, nframes_t start, nframes_t length, const string& name, layer_t layer, Flag flags)
        : Region (srcs, start, length, name, DataType::AUDIO, layer, flags)
        , _automatable(srcs[0]->session())
@@ -329,43 +329,43 @@ AudioRegion::read_peaks (PeakData *buf, nframes_t npeaks, nframes_t offset, nfra
        }
 }
 
-nframes64_t
-AudioRegion::read (Sample* buf, nframes64_t timeline_position, nframes64_t cnt, int channel) const
+nframes_t
+AudioRegion::read (Sample* buf, sframes_t timeline_position, nframes_t cnt, int channel) const
 {
        /* raw read, no fades, no gain, nada */
        return _read_at (_sources, _length, buf, 0, 0, _position + timeline_position, cnt, channel, 0, 0, ReadOps (0));
 }
 
-nframes64_t
-AudioRegion::read_with_ops (Sample* buf, nframes64_t file_position, nframes64_t cnt, int channel, ReadOps rops) const
+nframes_t
+AudioRegion::read_with_ops (Sample* buf, sframes_t file_position, nframes_t cnt, int channel, ReadOps rops) const
 {
        return _read_at (_sources, _length, buf, 0, 0, file_position, cnt, channel, 0, 0, rops);
 }
 
 nframes_t
-AudioRegion::read_at (Sample *buf, Sample *mixdown_buffer, float *gain_buffer, nframes_t file_position, 
-                     nframes_t cnt, 
-                     uint32_t chan_n, nframes_t read_frames, nframes_t skip_frames) const
+AudioRegion::read_at (Sample *buf, Sample *mixdown_buffer, float *gain_buffer,
+               sframes_t file_position, nframes_t cnt, uint32_t chan_n,
+               nframes_t read_frames, nframes_t skip_frames) const
 {
        /* regular diskstream/butler read complete with fades etc */
        return _read_at (_sources, _length, buf, mixdown_buffer, gain_buffer, file_position, cnt, chan_n, read_frames, skip_frames, ReadOps (~0));
 }
 
 nframes_t
-AudioRegion::master_read_at (Sample *buf, Sample *mixdown_buffer, float *gain_buffer, nframes_t position, 
-                            nframes_t cnt, uint32_t chan_n) const
+AudioRegion::master_read_at (Sample *buf, Sample *mixdown_buffer, float *gain_buffer,
+               sframes_t position, nframes_t cnt, uint32_t chan_n) const
 {
        return _read_at (_master_sources, _master_sources.front()->length(), buf, mixdown_buffer, gain_buffer, position, cnt, chan_n, 0, 0);
 }
 
 nframes_t
 AudioRegion::_read_at (const SourceList& srcs, nframes_t limit,
-                      Sample *buf, Sample *mixdown_buffer, float *gain_buffer,
-                      nframes_t position, nframes_t cnt, 
-                      uint32_t chan_n, 
-                      nframes_t read_frames, 
-                      nframes_t skip_frames,
-                      ReadOps rops) const
+               Sample *buf, Sample *mixdown_buffer, float *gain_buffer,
+               sframes_t position, nframes_t cnt, 
+               uint32_t chan_n, 
+               nframes_t read_frames, 
+               nframes_t skip_frames,
+               ReadOps rops) const
 {
        nframes_t internal_offset;
        nframes_t buf_offset;
@@ -1058,7 +1058,7 @@ AudioRegion::separate_by_channel (Session& session, vector<boost::shared_ptr<Reg
 }
 
 nframes_t
-AudioRegion::read_raw_internal (Sample* buf, nframes_t pos, nframes_t cnt) const
+AudioRegion::read_raw_internal (Sample* buf, sframes_t pos, nframes_t cnt) const
 {
        return audio_source()->read  (buf, pos, cnt);
 }
index a25a2dc8abaa5648a13340c498f55690b5021a08..15f35bf1f1cd76a8429161d7766940e2cd6e933f 100644 (file)
@@ -247,7 +247,7 @@ AudioSource::initialize_peakfile (bool newfile, ustring audio_path)
 }
 
 nframes_t
-AudioSource::read (Sample *dst, sframes_t start, nframes_t cnt) const
+AudioSource::read (Sample *dst, sframes_t start, nframes_t cnt, int channel) const
 {
        Glib::Mutex::Lock lm (_lock);
        return read_unlocked (dst, start, cnt);
index 70790787c36b36241b36385bfe586c96e6d7c973..5d180ceccc9dcaa3861285f989fcae62c9a56939 100644 (file)
@@ -271,8 +271,9 @@ Crossfade::initialize ()
 }      
 
 nframes_t 
-Crossfade::read_raw_internal (Sample* buf, nframes_t start, nframes_t cnt) const
+Crossfade::read_raw_internal (Sample* buf, sframes_t start, nframes_t cnt) const
 {
+       // FIXME: Why is this disabled?
 #if 0
        Sample* mixdown = new Sample[cnt];
        float* gain = new float[cnt];
@@ -290,7 +291,7 @@ Crossfade::read_raw_internal (Sample* buf, nframes_t start, nframes_t cnt) const
 
 nframes_t 
 Crossfade::read_at (Sample *buf, Sample *mixdown_buffer, 
-                   float *gain_buffer, nframes_t start, nframes_t cnt, uint32_t chan_n,
+                   float *gain_buffer, sframes_t start, nframes_t cnt, uint32_t chan_n,
                    nframes_t read_frames, nframes_t skip_frames) const
 {
        nframes_t offset;
@@ -320,7 +321,7 @@ Crossfade::read_at (Sample *buf, Sample *mixdown_buffer,
 
        } else {
                
-               to_write = min (_length - (start - _position), cnt);
+               to_write = min (nframes_t(_length - (start - _position)), cnt);
                
        }
 
index 1ce4bbdb7fc45f676673ac81edac6d5c257c9b35..5eea77ebcacd985895ba9fe34b9172177ea40930 100644 (file)
@@ -117,13 +117,13 @@ MidiRegion::~MidiRegion ()
 }
 
 nframes_t
-MidiRegion::read_at (MidiRingBuffer<nframes_t>& out, nframes_t position, nframes_t dur, uint32_t chan_n, NoteMode mode) const
+MidiRegion::read_at (MidiRingBuffer<nframes_t>& out, sframes_t position, nframes_t dur, uint32_t chan_n, NoteMode mode) const
 {
        return _read_at (_sources, out, position, dur, chan_n, mode);
 }
 
 nframes_t
-MidiRegion::master_read_at (MidiRingBuffer<nframes_t>& out, nframes_t position, nframes_t dur, uint32_t chan_n, NoteMode mode) const
+MidiRegion::master_read_at (MidiRingBuffer<nframes_t>& out, sframes_t position, nframes_t dur, uint32_t chan_n, NoteMode mode) const
 {
        return _read_at (_master_sources, out, position, dur, chan_n, mode);
 }