diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2010-04-16 15:14:59 +0000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2010-04-16 15:14:59 +0000 |
commit | 417f23ba4f8f625cff3a0cdc8a7b01d10415cece (patch) | |
tree | 4277de720a8bde76a8045500953ced7516f562a0 /libs | |
parent | 538f2d6afff839ad511defabab152c9cb2c43a67 (diff) |
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
Diffstat (limited to 'libs')
-rw-r--r-- | libs/ardour/ardour/audiosource.h | 1 | ||||
-rw-r--r-- | libs/ardour/audioregion.cc | 13 | ||||
-rw-r--r-- | libs/ardour/audiosource.cc | 12 |
3 files changed, 23 insertions, 3 deletions
diff --git a/libs/ardour/ardour/audiosource.h b/libs/ardour/ardour/audiosource.h index 20acd9fcd8..ef455f9735 100644 --- a/libs/ardour/ardour/audiosource.h +++ b/libs/ardour/ardour/audiosource.h @@ -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; diff --git a/libs/ardour/audioregion.cc b/libs/ardour/audioregion.cc index 373f9fced7..a25ac839be 100644 --- a/libs/ardour/audioregion.cc +++ b/libs/ardour/audioregion.cc @@ -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) { diff --git a/libs/ardour/audiosource.cc b/libs/ardour/audiosource.cc index fbac57dc7c..2fc7fd18cd 100644 --- a/libs/ardour/audiosource.cc +++ b/libs/ardour/audiosource.cc @@ -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; + } +} |