diff options
author | David Robillard <d@drobilla.net> | 2007-01-28 17:44:13 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2007-01-28 17:44:13 +0000 |
commit | f9f5ec85fbfd15d0008f70d4185a84eeadfd3891 (patch) | |
tree | adb7e13707b1361604c1ec57c0ea405125a4e98e /libs/ardour | |
parent | cd37c36326a165ddf6eb83c176213b0732a6db0d (diff) |
Merged with trunk R1393.
git-svn-id: svn://localhost/ardour2/branches/midi@1395 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour')
27 files changed, 183 insertions, 140 deletions
diff --git a/libs/ardour/SConscript b/libs/ardour/SConscript index 68d9112caf..878b41e82a 100644 --- a/libs/ardour/SConscript +++ b/libs/ardour/SConscript @@ -44,7 +44,6 @@ buffer_set.cc meter.cc amp.cc panner.cc -destructive_filesource.cc audiofilesource.cc audiofilter.cc audioregion.cc diff --git a/libs/ardour/ardour/audiofilesource.h b/libs/ardour/ardour/audiofilesource.h index c1dc7d1e93..0e1caf5245 100644 --- a/libs/ardour/ardour/audiofilesource.h +++ b/libs/ardour/ardour/audiofilesource.h @@ -101,6 +101,10 @@ class AudioFileSource : public AudioSource { bool destructive() const { return (_flags & Destructive); } virtual bool set_destructive (bool yn) { return false; } + Flag flags() const { return _flags; } + + void mark_immutable (); + /* this should really be protected, but C++ is getting stricter and creating slots from protected member functions is starting to cause issues. @@ -125,12 +129,12 @@ class AudioFileSource : public AudioSource { int init (string idstr, bool must_exist); - uint16_t channel; string _path; Flag _flags; string _take_id; int64_t timeline_position; bool file_is_new; + uint16_t channel; bool _is_embedded; static bool determine_embeddedness(string path); diff --git a/libs/ardour/ardour/audioregion.h b/libs/ardour/ardour/audioregion.h index 53c7e68b82..e3c5db561d 100644 --- a/libs/ardour/ardour/audioregion.h +++ b/libs/ardour/ardour/audioregion.h @@ -112,7 +112,7 @@ class AudioRegion : public Region void set_envelope_active (bool yn); void set_default_envelope (); - int separate_by_channel (ARDOUR::Session&, vector<AudioRegion*>&) const; + int separate_by_channel (ARDOUR::Session&, vector<boost::shared_ptr<AudioRegion> >&) const; /* filter */ diff --git a/libs/ardour/ardour/configuration_variable.h b/libs/ardour/ardour/configuration_variable.h index 6f0a8a3571..8710369a64 100644 --- a/libs/ardour/ardour/configuration_variable.h +++ b/libs/ardour/ardour/configuration_variable.h @@ -27,9 +27,13 @@ class ConfigVariableBase { virtual void add_to_node (XMLNode& node) = 0; virtual bool set_from_node (const XMLNode& node, Owner owner) = 0; + protected: std::string _name; Owner _owner; + + void notify (); + void miss (); }; template<class T> @@ -41,10 +45,12 @@ class ConfigVariable : public ConfigVariableBase virtual bool set (T val, Owner owner) { if (val == value) { + miss (); return false; } value = val; _owner = (ConfigVariableBase::Owner)(_owner |owner); + notify (); return true; } @@ -55,6 +61,7 @@ class ConfigVariable : public ConfigVariableBase void add_to_node (XMLNode& node) { std::stringstream ss; ss << value; + cerr << "Config variable " << _name << " stored as " << ss.str() << endl; XMLNode* child = new XMLNode ("Option"); child->add_property ("name", _name); child->add_property ("value", ss.str()); diff --git a/libs/ardour/ardour/configuration_vars.h b/libs/ardour/ardour/configuration_vars.h index c520477c55..703352b305 100644 --- a/libs/ardour/ardour/configuration_vars.h +++ b/libs/ardour/ardour/configuration_vars.h @@ -36,7 +36,6 @@ CONFIG_VARIABLE (HeaderFormat, native_file_header_format, "native-file-header-f CONFIG_VARIABLE (uint32_t, osc_port, "osc-port", 3819) CONFIG_VARIABLE (bool, use_osc, "use-osc", true) -CONFIG_VARIABLE (bool, use_overlap_equivalency, "use-overlap-equivalency", true) /* crossfades */ @@ -115,6 +114,7 @@ CONFIG_VARIABLE (bool, no_new_session_dialog, "no-new-session-dialog", false) CONFIG_VARIABLE (bool, use_vst, "use-vst", true) CONFIG_VARIABLE (uint32_t, subframes_per_frame, "subframes-per-frame", 100) CONFIG_VARIABLE (uint32_t, saved_history_depth, "save-history-depth", 100) +CONFIG_VARIABLE (bool, use_overlap_equivalency, "use-overlap-equivalency", false) /* BWAV */ diff --git a/libs/ardour/ardour/coreaudiosource.h b/libs/ardour/ardour/coreaudiosource.h index bd69c78e18..63c50d7cfb 100644 --- a/libs/ardour/ardour/coreaudiosource.h +++ b/libs/ardour/ardour/coreaudiosource.h @@ -29,7 +29,7 @@ namespace ARDOUR { class CoreAudioSource : public AudioFileSource { public: CoreAudioSource (ARDOUR::Session&, const XMLNode&); - CoreAudioSource (ARDOUR::Session&, const string& path_plus_channel, Flag); + CoreAudioSource (ARDOUR::Session&, const string& path, int chn, Flag); ~CoreAudioSource (); float sample_rate() const; diff --git a/libs/ardour/ardour/crossfade.h b/libs/ardour/ardour/crossfade.h index 62ab1f775d..3eafed818c 100644 --- a/libs/ardour/ardour/crossfade.h +++ b/libs/ardour/ardour/crossfade.h @@ -167,8 +167,6 @@ class Crossfade : public PBD::StatefulDestructible, public boost::enable_shared_ void initialize (); int compute (boost::shared_ptr<ARDOUR::AudioRegion>, boost::shared_ptr<ARDOUR::AudioRegion>, CrossfadeModel); bool update (); - - void member_changed (ARDOUR::Change); }; diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h index 1c1ea9e62c..63fa608499 100644 --- a/libs/ardour/ardour/session.h +++ b/libs/ardour/ardour/session.h @@ -1702,7 +1702,6 @@ class Session : public PBD::StatefulDestructible void config_changed (const char*); - void add_control_protocol (const ControlProtocolInfo* const, XMLNode*); XMLNode& get_control_protocol_state (); }; diff --git a/libs/ardour/ardour/sndfilesource.h b/libs/ardour/ardour/sndfilesource.h index 1d07f6888d..a5000a4b63 100644 --- a/libs/ardour/ardour/sndfilesource.h +++ b/libs/ardour/ardour/sndfilesource.h @@ -31,7 +31,7 @@ class SndFileSource : public AudioFileSource { public: /* constructor to be called for existing external-to-session files */ - SndFileSource (Session&, std::string path, Flag flags); + SndFileSource (Session&, std::string path, int chn, Flag flags); /* constructor to be called for new in-session files */ @@ -78,7 +78,7 @@ class SndFileSource : public AudioFileSource { mutable float *interleave_buf; mutable nframes_t interleave_bufsize; - void init (string str); + void init (); int open(); void close(); int setup_broadcast_info (nframes_t when, struct tm&, time_t); diff --git a/libs/ardour/ardour/source_factory.h b/libs/ardour/ardour/source_factory.h index be1551f518..b69645b031 100644 --- a/libs/ardour/ardour/source_factory.h +++ b/libs/ardour/ardour/source_factory.h @@ -22,7 +22,7 @@ class SourceFactory { static boost::shared_ptr<Source> create (Session&, const XMLNode& node); // MIDI sources will have to be hacked in here somehow - static boost::shared_ptr<Source> createReadable (DataType type, Session&, std::string idstr, AudioFileSource::Flag flags, bool announce = true); + static boost::shared_ptr<Source> createReadable (DataType type, Session&, std::string path, int chn, AudioFileSource::Flag flags, bool announce = true); static boost::shared_ptr<Source> createWritable (DataType type, Session&, std::string name, bool destructive, nframes_t rate, bool announce = true); private: diff --git a/libs/ardour/audiofilesource.cc b/libs/ardour/audiofilesource.cc index af41094748..fa38cca0a0 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 { @@ -537,8 +546,7 @@ AudioFileSource::is_empty (Session& s, string path) { bool ret = false; - boost::shared_ptr<AudioFileSource> afs = boost::dynamic_pointer_cast<AudioFileSource> ( - SourceFactory::createReadable (DataType::AUDIO, s, path, NoPeakFile, false)); + boost::shared_ptr<AudioFileSource> afs = boost::dynamic_pointer_cast<AudioFileSource> (SourceFactory::createReadable (DataType::AUDIO, s, path, 0, NoPeakFile, false)); if (afs) { ret = (afs->length() == 0); @@ -579,3 +587,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)); +} diff --git a/libs/ardour/audioregion.cc b/libs/ardour/audioregion.cc index 8b533deda3..38f8ed3652 100644 --- a/libs/ardour/audioregion.cc +++ b/libs/ardour/audioregion.cc @@ -42,6 +42,7 @@ #include <ardour/audiofilter.h> #include <ardour/audiofilesource.h> #include <ardour/destructive_filesource.h> +#include <ardour/region_factory.h> #include "i18n.h" #include <locale.h> @@ -327,7 +328,7 @@ AudioRegion::_read_at (const SourceList& srcs, Sample *buf, Sample *mixdown_buff nframes_t position, nframes_t cnt, uint32_t chan_n, nframes_t read_frames, nframes_t skip_frames) const { - //cerr << _name << "._read_at(" << position << ") - " << _position << endl; + cerr << _name << "._read_at(" << position << ") - " << _position << endl; nframes_t internal_offset; nframes_t buf_offset; @@ -901,25 +902,44 @@ AudioRegion::recompute_at_start () } int -AudioRegion::separate_by_channel (Session& session, vector<AudioRegion*>& v) const +AudioRegion::separate_by_channel (Session& session, vector<boost::shared_ptr<AudioRegion> >& v) const { SourceList srcs; string new_name; + int n; - for (SourceList::const_iterator i = _master_sources.begin(); i != _master_sources.end(); ++i) { + if (_sources.size() < 2) { + return 0; + } + + n = 0; + + for (SourceList::const_iterator i = _sources.begin(); i != _sources.end(); ++i) { srcs.clear (); srcs.push_back (*i); - /* generate a new name */ - - if (session.region_name (new_name, _name)) { - return -1; + new_name = _name; + + if (_sources.size() == 2) { + if (n == 0) { + new_name += "-L"; + } else { + new_name += "-R"; + } + } else { + new_name += '-'; + new_name += ('0' + n + 1); } /* create a copy with just one source */ - v.push_back (new AudioRegion (srcs, _start, _length, new_name, _layer, _flags)); + boost::shared_ptr<Region> r = RegionFactory::create (srcs, _start, _length, new_name, _layer, _flags); + boost::shared_ptr<AudioRegion> ar = boost::dynamic_pointer_cast<AudioRegion> (r); + + v.push_back (ar); + + ++n; } return 0; diff --git a/libs/ardour/configuration.cc b/libs/ardour/configuration.cc index eb3d879447..a0f2b5e036 100644 --- a/libs/ardour/configuration.cc +++ b/libs/ardour/configuration.cc @@ -317,3 +317,16 @@ Configuration::map_parameters (sigc::slot<void,const char*> theSlot) #undef CONFIG_VARIABLE #undef CONFIG_VARIABLE_SPECIAL } + +void +ConfigVariableBase::notify () +{ + // placeholder for any debugging desired when a config variable is modified +} + +void +ConfigVariableBase::miss () +{ + // placeholder for any debugging desired when a config variable + // is set but to the same value as it already has +} diff --git a/libs/ardour/control_protocol_manager.cc b/libs/ardour/control_protocol_manager.cc index de177d0e3d..72f56794d7 100644 --- a/libs/ardour/control_protocol_manager.cc +++ b/libs/ardour/control_protocol_manager.cc @@ -324,10 +324,25 @@ ControlProtocolManager::get_state (void) Glib::Mutex::Lock lm (protocols_lock); for (list<ControlProtocolInfo*>::iterator i = control_protocol_info.begin(); i != control_protocol_info.end(); ++i) { - XMLNode* child = new XMLNode (X_("Protocol")); - child->add_property (X_("name"), (*i)->name); - child->add_property (X_("active"), (*i)->protocol ? "yes" : "no"); - root->add_child_nocopy (*child); + + XMLNode * child; + + if ((*i)->protocol) { + child = &((*i)->protocol->get_state()); + child->add_property (X_("active"), "yes"); + // should we update (*i)->state here? probably. + root->add_child_nocopy (*child); + } + else if ((*i)->state) { + // keep ownership clear + root->add_child_copy (*(*i)->state); + } + else { + child = new XMLNode (X_("Protocol")); + child->add_property (X_("name"), (*i)->name); + child->add_property (X_("active"), "no"); + root->add_child_nocopy (*child); + } } return *root; diff --git a/libs/ardour/coreaudiosource.cc b/libs/ardour/coreaudiosource.cc index 3c81b18fd4..572fd9ef81 100644 --- a/libs/ardour/coreaudiosource.cc +++ b/libs/ardour/coreaudiosource.cc @@ -19,6 +19,7 @@ #include <pbd/error.h> #include <ardour/coreaudiosource.h> +#include <ardour/utils.h> #include <appleutility/CAAudioFile.h> #include <appleutility/CAStreamBasicDescription.h> @@ -33,33 +34,22 @@ using namespace PBD; CoreAudioSource::CoreAudioSource (Session& s, const XMLNode& node) : AudioFileSource (s, node) { - init (_name); + init (); } -CoreAudioSource::CoreAudioSource (Session& s, const string& idstr, Flag flags) - : AudioFileSource(s, idstr, flags) +CoreAudioSource::CoreAudioSource (Session& s, const string& path, int chn, Flag flags) + : AudioFileSource(s, path, flags), { - init (idstr); + channel = chn; + init (); } void -CoreAudioSource::init (string idstr) +CoreAudioSource::init () { - string::size_type pos; - tmpbuf = 0; tmpbufsize = 0; - _name = idstr; - - if ((pos = idstr.find_last_of (':')) == string::npos) { - channel = 0; - _path = idstr; - } else { - channel = atoi (idstr.substr (pos+1).c_str()); - _path = idstr.substr (0, pos); - } - cerr << "CoreAudioSource::init() " << name() << endl; /* note that we temporarily truncated _id at the colon */ diff --git a/libs/ardour/crossfade.cc b/libs/ardour/crossfade.cc index bd5f908380..66d1e099da 100644 --- a/libs/ardour/crossfade.cc +++ b/libs/ardour/crossfade.cc @@ -225,9 +225,6 @@ Crossfade::initialize () _fade_in.add (_length, 1.0); _fade_in.thaw (); - // _in->StateChanged.connect (sigc::mem_fun (*this, &Crossfade::member_changed)); - // _out->StateChanged.connect (sigc::mem_fun (*this, &Crossfade::member_changed)); - overlap_type = _in->coverage (_out->position(), _out->last_frame()); layer_relation = (int32_t) (_in->layer() - _out->layer()); } @@ -597,26 +594,6 @@ Crossfade::compute (boost::shared_ptr<AudioRegion> a, boost::shared_ptr<AudioReg return 0; } -void -Crossfade::member_changed (Change what_changed) -{ - Change what_we_care_about = Change (Region::MuteChanged| - Region::LayerChanged| - BoundsChanged); - - if (what_changed & what_we_care_about) { - try { - if (what_changed & what_we_care_about) { - refresh (); - } - } - - catch (NoCrossfadeHere& err) { - // relax, Invalidated inside refresh() - } - } -} - XMLNode& Crossfade::get_state () { diff --git a/libs/ardour/destructive_filesource.cc b/libs/ardour/destructive_filesource.cc index fcd85bfe8f..5eada195cd 100644 --- a/libs/ardour/destructive_filesource.cc +++ b/libs/ardour/destructive_filesource.cc @@ -410,7 +410,7 @@ DestructiveFileSource::handle_header_position_change () } void -DestructiveFileSource::set_timeline_position (int64_t) +DestructiveFileSource::set_timeline_position (int64_t pos) { //destructive track timeline postion does not change except at instantion or when header_position_offset (session start) changes } diff --git a/libs/ardour/io.cc b/libs/ardour/io.cc index 7ed6158b85..b7472781a8 100644 --- a/libs/ardour/io.cc +++ b/libs/ardour/io.cc @@ -1354,8 +1354,10 @@ IO::set_state (const XMLNode& node) set_automation_state (*(*iter)->children().front()); } - if ((*iter)->name() == X_("gaincontrol")) { - _gain_control.set_state (**iter); + if ((*iter)->name() == X_("controllable")) { + if ((prop = (*iter)->property("name")) != 0 && prop->value() == "gaincontrol") { + _gain_control.set_state (**iter); + } } } diff --git a/libs/ardour/midi_region.cc b/libs/ardour/midi_region.cc index d33d19ce67..cc914cac38 100644 --- a/libs/ardour/midi_region.cc +++ b/libs/ardour/midi_region.cc @@ -129,7 +129,7 @@ MidiRegion::_read_at (const SourceList& srcs, MidiRingBuffer& dst, uint32_t chan_n, jack_nframes_t read_frames, jack_nframes_t skip_frames) const { - //cerr << _name << "._read_at(" << position << ") - " << _position << endl; + cerr << _name << "._read_at(" << position << ") - " << _position << endl; jack_nframes_t internal_offset = 0; jack_nframes_t src_offset = 0; diff --git a/libs/ardour/panner.cc b/libs/ardour/panner.cc index c69bd84402..8ba662aaf4 100644 --- a/libs/ardour/panner.cc +++ b/libs/ardour/panner.cc @@ -545,9 +545,10 @@ EqualPowerStereoPanner::set_state (const XMLNode& node) for (XMLNodeConstIterator iter = node.children().begin(); iter != node.children().end(); ++iter) { - if ((*iter)->name() == X_("panner")) { - - _control.set_state (**iter); + if ((*iter)->name() == X_("controllable")) { + if ((prop = (*iter)->property("name")) != 0 && prop->value() == "panner") { + _control.set_state (**iter); + } } else if ((*iter)->name() == X_("Automation")) { diff --git a/libs/ardour/playlist.cc b/libs/ardour/playlist.cc index 099b4dabbb..db84b015bb 100644 --- a/libs/ardour/playlist.cc +++ b/libs/ardour/playlist.cc @@ -606,11 +606,15 @@ Playlist::remove_region_internal (boost::shared_ptr<Region>region) void Playlist::get_equivalent_regions (boost::shared_ptr<Region> other, vector<boost::shared_ptr<Region> >& results) { - for (RegionList::iterator i = regions.begin(); i != regions.end(); ++i) { - if (Config->get_use_overlap_equivalency()) { + if (Config->get_use_overlap_equivalency()) { + for (RegionList::iterator i = regions.begin(); i != regions.end(); ++i) { if ((*i)->overlap_equivalent (other)) { results.push_back ((*i)); - } else if ((*i)->equivalent (other)) { + } + } + } else { + for (RegionList::iterator i = regions.begin(); i != regions.end(); ++i) { + if ((*i)->equivalent (other)) { results.push_back ((*i)); } } diff --git a/libs/ardour/route.cc b/libs/ardour/route.cc index a2bc65407c..d415741831 100644 --- a/libs/ardour/route.cc +++ b/libs/ardour/route.cc @@ -1647,13 +1647,19 @@ Route::_set_state (const XMLNode& node, bool call_base) _comment = cmt->content(); } else if (child->name() == X_("extra")) { + _extra_xml = new XMLNode (*child); - } else if (child->name() == X_("solo")) { - _solo_control.set_state (*child); - _session.add_controllable (&_solo_control); - } else if (child->name() == X_("mute")) { - _mute_control.set_state (*child); - _session.add_controllable (&_mute_control); + + } else if (child->name() == X_("controllable") && (prop = child->property("name")) != 0) { + + if (prop->value() == "solo") { + _solo_control.set_state (*child); + _session.add_controllable (&_solo_control); + } + else if (prop->value() == "mute") { + _mute_control.set_state (*child); + _session.add_controllable (&_mute_control); + } } } diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index c4a5e5fe0a..764b25dc9b 100644 --- a/libs/ardour/session.cc +++ b/libs/ardour/session.cc @@ -382,7 +382,6 @@ Session::Session (AudioEngine &eng, if (master_out_channels) { shared_ptr<Route> r (new Route (*this, _("master"), -1, master_out_channels, -1, master_out_channels, Route::MasterOut)); r->set_remote_control_id (control_id); - cerr << "master bus has remote control ID " << r->remote_control_id() << endl; rl.push_back (r); } else { @@ -410,6 +409,8 @@ Session::Session (AudioEngine &eng, _state_of_the_state = StateOfTheState (_state_of_the_state & ~Dirty); + Config->ParameterChanged.connect (mem_fun (*this, &Session::config_changed)); + if (was_dirty) { DirtyChanged (); /* EMIT SIGNAL */ } @@ -1793,6 +1794,10 @@ Session::new_audio_track (int input_channels, int output_channels, TrackMode mod track->set_control_outs (cports); } + + // assert (current_thread != RT_thread) + + track->audio_diskstream()->non_realtime_input_change(); track->DiskstreamChanged.connect (mem_fun (this, &Session::resort_routes)); track->set_remote_control_id (control_id); @@ -3163,14 +3168,16 @@ Session::midi_path_from_name (string name) for (i = session_dirs.begin(); i != session_dirs.end(); ++i) { + spath = (*i).path; + // FIXME: different directory from audio? - spath = (*i).path + sound_dir_name + "/" + legalized; + spath += sound_dir(false) + "/" + legalized; snprintf (buf, sizeof(buf), "%s-%u.mid", spath.c_str(), cnt); - if (access (buf, F_OK) == 0) { + if (g_file_test (buf, G_FILE_TEST_EXISTS)) { existing++; - } + } } if (existing == 0) { @@ -3191,6 +3198,7 @@ Session::midi_path_from_name (string name) // FIXME: different directory than audio? spath = discover_best_sound_dir (); + spath += '/'; string::size_type pos = foo.find_last_of ('/'); @@ -3618,7 +3626,7 @@ Session::remove_redirect (Redirect* redirect) nframes_t Session::available_capture_duration () { - float sample_bytes_on_disk; + float sample_bytes_on_disk = 4.0; // keep gcc happy switch (Config->get_native_file_data_format()) { case FormatFloat: diff --git a/libs/ardour/session_command.cc b/libs/ardour/session_command.cc index 9d054c22fd..7cf52b741f 100644 --- a/libs/ardour/session_command.cc +++ b/libs/ardour/session_command.cc @@ -30,7 +30,7 @@ Session::memento_command_factory(XMLNode *n) { PBD::ID id; XMLNode *before = 0, *after = 0; - XMLNode *child; + XMLNode *child = 0; /* get id */ id = PBD::ID(n->property("obj_id")->value()); diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc index 37f7b2c32f..c8a81be4d4 100644 --- a/libs/ardour/session_state.cc +++ b/libs/ardour/session_state.cc @@ -1059,19 +1059,7 @@ XMLNode& Session::get_control_protocol_state () { ControlProtocolManager& cpm (ControlProtocolManager::instance()); - XMLNode* node = new XMLNode (X_("ControlProtocols")); - - cpm.foreach_known_protocol (bind (mem_fun (*this, &Session::add_control_protocol), node)); - - return *node; -} - -void -Session::add_control_protocol (const ControlProtocolInfo* const cpi, XMLNode* node) -{ - if (cpi->protocol) { - node->add_child_nocopy (cpi->protocol->get_state()); - } + return cpm.get_state(); } int diff --git a/libs/ardour/sndfilesource.cc b/libs/ardour/sndfilesource.cc index 8e90eac6ab..2885240a51 100644 --- a/libs/ardour/sndfilesource.cc +++ b/libs/ardour/sndfilesource.cc @@ -48,30 +48,34 @@ const AudioFileSource::Flag SndFileSource::default_writable_flags = AudioFileSou SndFileSource::SndFileSource (Session& s, const XMLNode& node) : AudioFileSource (s, node) { - init (_name); + init (); + + cerr << "SndFileSource @ " << _path << " channel = " << channel << endl; if (open()) { throw failed_constructor (); } } -SndFileSource::SndFileSource (Session& s, string idstr, Flag flags) - /* files created this way are never writable or removable */ - : AudioFileSource (s, idstr, Flag (flags & ~(Writable|Removable|RemovableIfEmpty|RemoveAtDestroy))) +SndFileSource::SndFileSource (Session& s, string path, int chn, Flag flags) + /* files created this way are never writable or removable */ + : AudioFileSource (s, path, Flag (flags & ~(Writable|Removable|RemovableIfEmpty|RemoveAtDestroy))) { - init (idstr); + channel = chn; + + init (); if (open()) { throw failed_constructor (); } } -SndFileSource::SndFileSource (Session& s, string idstr, SampleFormat sfmt, HeaderFormat hf, nframes_t rate, Flag flags) - : AudioFileSource (s, idstr, flags, sfmt, hf) +SndFileSource::SndFileSource (Session& s, string path, SampleFormat sfmt, HeaderFormat hf, nframes_t rate, Flag flags) + : AudioFileSource (s, path, flags, sfmt, hf) { int fmt = 0; - init (idstr); + init (); /* this constructor is used to construct new files, not open existing ones. @@ -174,9 +178,8 @@ SndFileSource::SndFileSource (Session& s, string idstr, SampleFormat sfmt, Heade } void -SndFileSource::init (string idstr) +SndFileSource::init () { - string::size_type pos; string file; // lets try to keep the object initalizations here at the top @@ -186,20 +189,10 @@ SndFileSource::init (string idstr) sf = 0; _broadcast_info = 0; - string tmp_name; - - if ((pos = idstr.find_last_of (':')) == string::npos) { - channel = 0; - tmp_name = idstr; - } else { - channel = atoi (idstr.substr (pos+1).c_str()); - tmp_name = idstr.substr (0, pos); - } - if (is_embedded()) { - _name = tmp_name; + _name = _path; } else { - _name = Glib::path_get_basename (tmp_name); + _name = Glib::path_get_basename (_path); } /* although libsndfile says we don't need to set this, @@ -385,6 +378,7 @@ nframes_t SndFileSource::nondestructive_write_unlocked (Sample *data, nframes_t cnt) { if (!writable()) { + warning << string_compose (_("attempt to write a non-writable audio file source (%1)"), _path) << endmsg; return 0; } @@ -440,6 +434,7 @@ SndFileSource::destructive_write_unlocked (Sample* data, nframes_t cnt) nframes_t old_file_pos; if (!writable()) { + warning << string_compose (_("attempt to write a non-writable audio file source (%1)"), _path) << endmsg; return 0; } @@ -563,6 +558,7 @@ int SndFileSource::flush_header () { if (!writable() || (sf == 0)) { + warning << string_compose (_("attempt to flush a non-writable audio file source (%1)"), _path) << endmsg; return -1; } return (sf_command (sf, SFC_UPDATE_HEADER_NOW, 0, 0) != SF_TRUE); @@ -572,6 +568,7 @@ int SndFileSource::setup_broadcast_info (nframes_t when, struct tm& now, time_t tnow) { if (!writable()) { + warning << string_compose (_("attempt to store broadcast info in a non-writable audio file source (%1)"), _path) << endmsg; return -1; } diff --git a/libs/ardour/source_factory.cc b/libs/ardour/source_factory.cc index ad01bf6171..560bf03e7f 100644 --- a/libs/ardour/source_factory.cc +++ b/libs/ardour/source_factory.cc @@ -131,14 +131,13 @@ SourceFactory::create (Session& s, const XMLNode& node) #ifdef HAVE_COREAUDIO boost::shared_ptr<Source> -SourceFactory::createReadable (DataType type, Session& s, string idstr, AudioFileSource::Flag flags, bool announce) +SourceFactory::createReadable (DataType type, Session& s, string path, int chn, AudioFileSource::Flag flags, bool announce) { if (type == DataType::AUDIO) { - if (!(flags & Destructive)) { try { - boost::shared_ptr<Source> ret (new CoreAudioSource (s, idstr, flags)); + boost::shared_ptr<Source> ret (new CoreAudioSource (s, path, chn, flags)); if (setup_peakfile (ret)) { return boost::shared_ptr<Source>(); } @@ -149,7 +148,7 @@ SourceFactory::createReadable (DataType type, Session& s, string idstr, AudioFil } catch (failed_constructor& err) { - boost::shared_ptr<Source> ret (new SndFileSource (s, idstr, flags)); + boost::shared_ptr<Source> ret (new SndFileSource (s, path, chn, flags)); if (setup_peakfile (ret)) { return boost::shared_ptr<Source>(); } @@ -161,7 +160,7 @@ SourceFactory::createReadable (DataType type, Session& s, string idstr, AudioFil } else { - boost::shared_ptr<Source> ret (new SndFileSource (s, idstr, flags)); + boost::shared_ptr<Source> ret (new SndFileSource (s, path, chn, flags)); if (setup_peakfile (ret)) { return boost::shared_ptr<Source>(); } @@ -171,6 +170,7 @@ SourceFactory::createReadable (DataType type, Session& s, string idstr, AudioFil return ret; } + return boost::shared_ptr<Source>(); } else if (type == DataType::MIDI) { boost::shared_ptr<Source> ret (new SMFSource (s, node)); @@ -187,11 +187,11 @@ SourceFactory::createReadable (DataType type, Session& s, string idstr, AudioFil #else boost::shared_ptr<Source> -SourceFactory::createReadable (DataType type, Session& s, string idstr, AudioFileSource::Flag flags, bool announce) +SourceFactory::createReadable (DataType type, Session& s, string path, int chn, AudioFileSource::Flag flags, bool announce) { if (type == DataType::AUDIO) { - - boost::shared_ptr<Source> ret (new SndFileSource (s, idstr, flags)); + + boost::shared_ptr<Source> ret (new SndFileSource (s, path, chn, flags)); if (setup_peakfile (ret)) { return boost::shared_ptr<Source>(); @@ -203,10 +203,11 @@ SourceFactory::createReadable (DataType type, Session& s, string idstr, AudioFil return ret; + } else if (type == DataType::MIDI) { // FIXME: flags? - boost::shared_ptr<Source> ret (new SMFSource (s, idstr, SMFSource::Flag(0))); + boost::shared_ptr<Source> ret (new SMFSource (s, path, SMFSource::Flag(0))); if (announce) { SourceCreated (ret); |