From ad0aef7dce247ac69fc9c86554d0acbe6c3045bd Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Wed, 21 Sep 2016 03:42:06 +0200 Subject: [PATCH] add API to change FileSource path in-place This allows to retain IDs and References of a FileSource, while changing the actual file under the hood (e.g. from .wav to .flac) --- libs/ardour/ardour/file_source.h | 1 + libs/ardour/file_source.cc | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/libs/ardour/ardour/file_source.h b/libs/ardour/ardour/file_source.h index 00fb74b426..9b4c2ccffc 100644 --- a/libs/ardour/ardour/file_source.h +++ b/libs/ardour/ardour/file_source.h @@ -79,6 +79,7 @@ public: const std::string& origin() const { return _origin; } virtual void set_path (const std::string&); + void replace_file (const std::string&); static PBD::Signal2 > AmbiguousFileName; diff --git a/libs/ardour/file_source.cc b/libs/ardour/file_source.cc index 32f8a1b124..726b223273 100644 --- a/libs/ardour/file_source.cc +++ b/libs/ardour/file_source.cc @@ -556,6 +556,15 @@ FileSource::set_path (const std::string& newpath) } } + +void +FileSource::replace_file (const std::string& newpath) +{ + close (); + _path = newpath; + _name = Glib::path_get_basename (newpath); +} + void FileSource::inc_use_count () {