_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
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;
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);
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);
ptr += _info.channels;
}
- _read_data_count = cnt * sizeof(float);
-
_descriptor->release ();
return nread;
}
compute_and_write_peaks (data, frame_pos, cnt, false, true);
}
- _write_data_count = cnt;
-
return cnt;
}