diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2007-01-25 17:42:19 +0000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2007-01-25 17:42:19 +0000 |
commit | 5ee3e58718f65ef9eb62a1b90d424dac68e770ff (patch) | |
tree | 10c4b9215d32e108878141124b07f6320f7d70e3 /libs/ardour/audiofilesource.cc | |
parent | 1c61d4007a2fb3b6ea1a84ced86338cb65a66363 (diff) |
fix import/embed of multichannel audiofiles, as per #1433
git-svn-id: svn://localhost/ardour2/trunk@1386 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/audiofilesource.cc')
-rw-r--r-- | libs/ardour/audiofilesource.cc | 35 |
1 files changed, 25 insertions, 10 deletions
diff --git a/libs/ardour/audiofilesource.cc b/libs/ardour/audiofilesource.cc index 95fc0d2766..b74f6b370f 100644 --- a/libs/ardour/audiofilesource.cc +++ b/libs/ardour/audiofilesource.cc @@ -63,20 +63,22 @@ uint64_t AudioFileSource::header_position_offset = 0; /* XXX maybe this too */ char AudioFileSource::bwf_serial_number[13] = "000000000000"; -AudioFileSource::AudioFileSource (Session& s, string idstr, Flag flags) - : AudioSource (s, idstr), _flags (flags) +AudioFileSource::AudioFileSource (Session& s, string path, Flag flags) + : AudioSource (s, path), _flags (flags), + channel (0) { /* constructor used for existing external to session files. file must exist already */ - _is_embedded = AudioFileSource::determine_embeddedness (idstr); + _is_embedded = AudioFileSource::determine_embeddedness (path); - if (init (idstr, true)) { + if (init (path, true)) { throw failed_constructor (); } } AudioFileSource::AudioFileSource (Session& s, std::string path, Flag flags, SampleFormat samp_format, HeaderFormat hdr_format) - : AudioSource (s, path), _flags (flags) + : AudioSource (s, path), _flags (flags), + channel (0) { /* constructor used for new internal-to-session files. file cannot exist */ _is_embedded = false; @@ -88,6 +90,7 @@ AudioFileSource::AudioFileSource (Session& s, std::string path, Flag flags, Samp AudioFileSource::AudioFileSource (Session& s, const XMLNode& node) : AudioSource (s, node), _flags (Flag (Writable|CanRename)) + /* channel is set in set_state() */ { /* constructor used for existing internal-to-session files. file must exist */ @@ -195,7 +198,10 @@ XMLNode& AudioFileSource::get_state () { XMLNode& root (AudioSource::get_state()); - root.add_property ("flags", enum_2_string (_flags)); + char buf[32]; + root.add_property (X_("flags"), enum_2_string (_flags)); + snprintf (buf, sizeof (buf), "%d", channel); + root.add_property (X_("channel"), buf); return root; } @@ -209,15 +215,18 @@ AudioFileSource::set_state (const XMLNode& node) } if ((prop = node.property (X_("flags"))) != 0) { - _flags = Flag (string_2_enum (prop->value(), _flags)); - } else { - _flags = Flag (0); } + if ((prop = node.property (X_("channel"))) != 0) { + channel = atoi (prop->value()); + } else { + channel = 0; + } + if ((prop = node.property (X_("name"))) != 0) { _is_embedded = AudioFileSource::determine_embeddedness (prop->value()); } else { @@ -527,7 +536,7 @@ bool AudioFileSource::is_empty (Session& s, string path) { bool ret = false; - boost::shared_ptr<AudioFileSource> afs = boost::dynamic_pointer_cast<AudioFileSource> (SourceFactory::createReadable (s, path, NoPeakFile, false)); + boost::shared_ptr<AudioFileSource> afs = boost::dynamic_pointer_cast<AudioFileSource> (SourceFactory::createReadable (s, path, 0, NoPeakFile, false)); if (afs) { ret = (afs->length() == 0); @@ -568,3 +577,9 @@ AudioFileSource::safe_file_extension(string file) #endif // HAVE_COREAUDIO file.rfind(".voc") == string::npos); } + +void +AudioFileSource::mark_immutable () +{ + _flags = Flag (_flags & ~(Writable|Removable|RemovableIfEmpty|RemoveAtDestroy|CanRename)); +} |