projects
/
ardour.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Show an example filename in the main export dialog
[ardour.git]
/
libs
/
ardour
/
sndfilesource.cc
diff --git
a/libs/ardour/sndfilesource.cc
b/libs/ardour/sndfilesource.cc
index e5ba83015d9814ee1b4d2a5bb6e9e98bc7792c91..3759057dc55581e491e250fddf6a63c4ec1ed9f9 100644
(file)
--- 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;
_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
}
void
@@
-269,6
+275,8
@@
SndFileSource::sample_rate () const
framecnt_t
SndFileSource::read_unlocked (Sample *dst, framepos_t start, framecnt_t cnt) 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;
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;
}
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 (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);
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);
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;
}
ptr += _info.channels;
}
- _read_data_count = cnt * sizeof(float);
-
_descriptor->release ();
return nread;
}
_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);
}
compute_and_write_peaks (data, frame_pos, cnt, false, true);
}
- _write_data_count = cnt;
-
return cnt;
}
return cnt;
}