diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2015-04-20 16:31:06 -0400 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2015-04-20 16:31:06 -0400 |
commit | d5be54080fa25e45e8bf441e9c72e53ffa3daa72 (patch) | |
tree | efec66f75e66c64b8e36a2625c04b8a0b798ddf9 /libs/ardour/sndfilesource.cc | |
parent | d263cf7ded76d510addd90b036befd4bb7eea9d1 (diff) |
add a pure virtual FileSource::close() method so that FileSource::set_path() can ensure we no longer have a handle open
Diffstat (limited to 'libs/ardour/sndfilesource.cc')
-rw-r--r-- | libs/ardour/sndfilesource.cc | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/libs/ardour/sndfilesource.cc b/libs/ardour/sndfilesource.cc index cc6cfdb4be..5acfe7b119 100644 --- a/libs/ardour/sndfilesource.cc +++ b/libs/ardour/sndfilesource.cc @@ -180,7 +180,7 @@ SndFileSource::SndFileSource (Session& s, const string& path, const string& orig throw failed_constructor(); } } else { - /* normal mode: do not open the file here - do that in write_unlocked() as needed + /* normal mode: do not open the file here - do that in {read,write}_unlocked() as needed */ } } @@ -230,6 +230,15 @@ SndFileSource::init_sndfile () AudioFileSource::HeaderPositionOffsetChanged.connect_same_thread (header_position_connection, boost::bind (&SndFileSource::handle_header_position_change, this)); } +void +SndFileSource::close () +{ + if (_sndfile) { + sf_close (_sndfile); + _sndfile = 0; + } +} + int SndFileSource::open () { @@ -334,10 +343,7 @@ SndFileSource::open () SndFileSource::~SndFileSource () { - if (_sndfile) { - sf_close (_sndfile); - _sndfile = 0; - } + close (); delete _broadcast_info; delete [] xfade_buf; } @@ -364,10 +370,10 @@ SndFileSource::read_unlocked (Sample *dst, framepos_t start, framecnt_t cnt) con return cnt; } - if (_sndfile == 0) { - error << string_compose (_("could not allocate file %1 for reading."), _path) << endmsg; + if (const_cast<SndFileSource*>(this)->open()) { + error << string_compose (_("could not open file %1 for reading."), _path) << endmsg; return 0; - } + } if (start > _length) { |