when a region has less channels than its diskstream needs, read a relevant channel instead (this makes mono regions in stereo tracks become effectively multi-mono)

git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@6915 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Paul Davis 2010-04-16 15:14:59 +00:00
parent 538f2d6aff
commit 417f23ba4f
3 changed files with 23 additions and 3 deletions

View file

@ -90,6 +90,7 @@ class AudioSource : public Source, public boost::enable_shared_from_this<ARDOUR:
uint32_t read_data_count() const { return _read_data_count; }
uint32_t write_data_count() const { return _write_data_count; }
void dec_read_data_count(nframes_t);
int read_peaks (PeakData *peaks, nframes_t npeaks, nframes_t start, nframes_t cnt, double samples_per_visual_peak) const;

View file

@ -583,11 +583,18 @@ AudioRegion::_read_at (const SourceList& srcs, nframes_t limit,
} else {
/* track is N-channel, this region has less channels; silence the ones
we don't have.
/* track is N-channel, this region has less channels, so use a relevant channel
*/
memset (mixdown_buffer, 0, sizeof (Sample) * cnt);
uint32_t channel = n_channels() % chan_n;
if (srcs[channel]->read (mixdown_buffer, _start + internal_offset, to_read) != to_read) {
return 0; /* "read nothing" */
}
/* adjust read data count appropriately since this was a duplicate read */
srcs[channel]->dec_read_data_count (to_read);
}
if (rops & ReadOpsFades) {

View file

@ -1015,3 +1015,15 @@ AudioSource::check_for_analysis_data_on_disk ()
return ok;
}
void
AudioSource::dec_read_data_count (nframes_t cnt)
{
uint32_t val = cnt * sizeof (Sample);
if (val < _read_data_count) {
_read_data_count -= val;
} else {
_read_data_count = 0;
}
}