diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2006-02-17 16:03:04 +0000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2006-02-17 16:03:04 +0000 |
commit | 463b5daed0cfa489366da659a8edd94a03fcec94 (patch) | |
tree | 0f47e9567df126c1f4e826ad2d5e3ee990b18634 /libs/ardour/filesource.cc | |
parent | 5c47492d880e07c687a6f5ce542d4a57c822f81c (diff) |
don't do system reads beyond the apparent data end of a file; single region for destructive tracks
git-svn-id: svn://localhost/trunk/ardour2@337 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/filesource.cc')
-rw-r--r-- | libs/ardour/filesource.cc | 33 |
1 files changed, 30 insertions, 3 deletions
diff --git a/libs/ardour/filesource.cc b/libs/ardour/filesource.cc index 5c97cd8dee..303113174d 100644 --- a/libs/ardour/filesource.cc +++ b/libs/ardour/filesource.cc @@ -967,9 +967,36 @@ FileSource::read (Sample *dst, jack_nframes_t start, jack_nframes_t cnt, char * jack_nframes_t FileSource::read_unlocked (Sample *dst, jack_nframes_t start, jack_nframes_t cnt, char * workbuf) const { - - if (file_read(dst, start, cnt, workbuf) != (ssize_t) cnt) { - return 0; + jack_nframes_t file_cnt; + + if (start > _length) { + + /* read starts beyond end of data, just memset to zero */ + + file_cnt = 0; + + } else if (start + cnt > _length) { + + /* read ends beyond end of data, read some, memset the rest */ + + file_cnt = _length - start; + + } else { + + /* read is entirely within data */ + + file_cnt = cnt; + } + + if (file_cnt) { + if (file_read(dst, start, file_cnt, workbuf) != (ssize_t) cnt) { + return 0; + } + } + + if (file_cnt != cnt) { + jack_nframes_t delta = cnt - file_cnt; + memset (dst+file_cnt, 0, sizeof (Sample) * delta); } return cnt; |