Clean up Region interface, remove Readable stub kludge.

git-svn-id: svn://localhost/ardour2/branches/3.0@4643 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
David Robillard 2009-02-19 21:06:56 +00:00
parent 75c15679bf
commit bed0d89337
9 changed files with 48 additions and 55 deletions

View 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,

View 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;

View 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;
};

View 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;

View 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;
};
}

View 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);
}

View 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);

View 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);
}

View 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);
}