add a pure virtual FileSource::close() method so that FileSource::set_path() can ensure we no longer have a handle open
This commit is contained in:
parent
d263cf7ded
commit
d5be54080f
|
@ -48,6 +48,7 @@ class LIBARDOUR_API CoreAudioSource : public AudioFileSource {
|
|||
static int get_soundfile_info (string path, SoundFileInfo& _info, string& error_msg);
|
||||
|
||||
protected:
|
||||
void close ();
|
||||
framecnt_t read_unlocked (Sample *dst, framepos_t start, framecnt_t cnt) const;
|
||||
framecnt_t write_unlocked (Sample *, framecnt_t) { return 0; }
|
||||
|
||||
|
|
|
@ -89,9 +89,9 @@ public:
|
|||
*/
|
||||
int rename (const std::string& name);
|
||||
|
||||
virtual void release_descriptor () {}
|
||||
virtual void close () = 0;
|
||||
|
||||
protected:
|
||||
protected:
|
||||
FileSource (Session& session, DataType type,
|
||||
const std::string& path,
|
||||
const std::string& origin,
|
||||
|
|
|
@ -40,6 +40,7 @@ public:
|
|||
bool clamped_at_unity() const { return false; }
|
||||
|
||||
protected:
|
||||
void close() {}
|
||||
friend class SourceFactory;
|
||||
|
||||
SilentFileSource (Session& s, const XMLNode& x, framecnt_t len, float srate)
|
||||
|
|
|
@ -72,6 +72,7 @@ public:
|
|||
void prevent_deletion ();
|
||||
|
||||
protected:
|
||||
void close ();
|
||||
void set_path (const std::string& newpath);
|
||||
void flush_midi (const Lock& lock);
|
||||
|
||||
|
|
|
@ -75,6 +75,8 @@ class LIBARDOUR_API SndFileSource : public AudioFileSource {
|
|||
static int get_soundfile_info (const std::string& path, SoundFileInfo& _info, std::string& error_msg);
|
||||
|
||||
protected:
|
||||
void close ();
|
||||
|
||||
void set_path (const std::string& p);
|
||||
void set_header_timeline_position ();
|
||||
|
||||
|
|
|
@ -52,6 +52,7 @@ public:
|
|||
bool clamped_at_unity() const { return false; }
|
||||
|
||||
protected:
|
||||
void close ();
|
||||
framecnt_t read_unlocked (Sample *dst, framepos_t start, framecnt_t cnt) const;
|
||||
framecnt_t write_unlocked (Sample */*dst*/, framecnt_t /*cnt*/) { return 0; }
|
||||
|
||||
|
|
|
@ -104,6 +104,12 @@ CoreAudioSource::~CoreAudioSource ()
|
|||
{
|
||||
}
|
||||
|
||||
void
|
||||
CoreAudioSource::close ()
|
||||
{
|
||||
af.Close ();
|
||||
}
|
||||
|
||||
int
|
||||
CoreAudioSource::safe_read (Sample* dst, framepos_t start, framecnt_t cnt, AudioBufferList& abl) const
|
||||
{
|
||||
|
|
|
@ -544,6 +544,7 @@ FileSource::set_within_session_from_path (const std::string& path)
|
|||
void
|
||||
FileSource::set_path (const std::string& newpath)
|
||||
{
|
||||
close ();
|
||||
_path = newpath;
|
||||
set_within_session_from_path (newpath);
|
||||
if (_within_session) {
|
||||
|
|
|
@ -202,6 +202,12 @@ SMFSource::open_for_write ()
|
|||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
SMFSource::close ()
|
||||
{
|
||||
/* nothing to do: file descriptor is never kept open */
|
||||
}
|
||||
|
||||
/** All stamps in audio frames */
|
||||
framecnt_t
|
||||
SMFSource::read_unlocked (const Lock& lock,
|
||||
|
|
|
@ -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) {
|
||||
|
||||
|
|
|
@ -84,6 +84,15 @@ SrcFileSource::~SrcFileSource ()
|
|||
delete [] _src_buffer;
|
||||
}
|
||||
|
||||
void
|
||||
SrcFileSource::close ()
|
||||
{
|
||||
boost::shared_ptr<FileSource> fs = boost::dynamic_pointer_cast<FileSource> (_source);
|
||||
if (fs) {
|
||||
fs->close ();
|
||||
}
|
||||
}
|
||||
|
||||
framecnt_t
|
||||
SrcFileSource::read_unlocked (Sample *dst, framepos_t start, framecnt_t cnt) const
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue
Block a user