X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fardour%2Fsndfilesource.cc;h=3759057dc55581e491e250fddf6a63c4ec1ed9f9;hb=dba601eeab9054ca4fac811c6c5e414d59fdc460;hp=e5ba83015d9814ee1b4d2a5bb6e9e98bc7792c91;hpb=cd17e05e3a22614387050736c89a4727c4da0d61;p=ardour.git diff --git a/libs/ardour/sndfilesource.cc b/libs/ardour/sndfilesource.cc index e5ba83015d..3759057dc5 100644 --- a/libs/ardour/sndfilesource.cc +++ b/libs/ardour/sndfilesource.cc @@ -144,8 +144,14 @@ SndFileSource::SndFileSource (Session& s, const string& path, const string& orig _info.samplerate = rate; _info.format = fmt; - /* do not open the file here - do that in write_unlocked() as needed - */ + if (_flags & Destructive) { + if (open()) { + throw failed_constructor(); + } + } else { + /* normal mode: do not open the file here - do that in write_unlocked() as needed + */ + } } void @@ -269,6 +275,8 @@ SndFileSource::sample_rate () const framecnt_t SndFileSource::read_unlocked (Sample *dst, framepos_t start, framecnt_t cnt) const { + assert (cnt >= 0); + int32_t nread; float *ptr; uint32_t real_cnt; @@ -306,6 +314,8 @@ SndFileSource::read_unlocked (Sample *dst, framepos_t start, framecnt_t cnt) con file_cnt = cnt; } + assert (file_cnt >= 0); + if (file_cnt != cnt) { framepos_t delta = cnt - file_cnt; memset (dst+file_cnt, 0, sizeof (Sample) * delta); @@ -323,7 +333,6 @@ SndFileSource::read_unlocked (Sample *dst, framepos_t start, framecnt_t cnt) con if (_info.channels == 1) { framecnt_t ret = sf_read_float (sf, dst, file_cnt); - _read_data_count = ret * sizeof(float); if (ret != file_cnt) { char errbuf[256]; sf_error_str (0, errbuf, sizeof (errbuf) - 1); @@ -349,8 +358,6 @@ SndFileSource::read_unlocked (Sample *dst, framepos_t start, framecnt_t cnt) con ptr += _info.channels; } - _read_data_count = cnt * sizeof(float); - _descriptor->release (); return nread; } @@ -397,8 +404,6 @@ SndFileSource::nondestructive_write_unlocked (Sample *data, framecnt_t cnt) compute_and_write_peaks (data, frame_pos, cnt, false, true); } - _write_data_count = cnt; - return cnt; }