From 02583c300f1a909c031b75e9e264696cce0a53e2 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 25 Mar 2010 03:40:07 +0000 Subject: would you look at that! all those changes just to make the auditioner work again .... git-svn-id: svn://localhost/ardour2/branches/3.0@6794 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/ardour/ardour/audio_track.h | 6 +- libs/ardour/ardour/auditioner.h | 8 ++- libs/ardour/ardour/midi_track.h | 6 +- libs/ardour/ardour/route.h | 7 +- libs/ardour/ardour/track.h | 7 +- libs/ardour/audio_diskstream.cc | 3 +- libs/ardour/audio_track.cc | 137 +++++++++------------------------------ libs/ardour/auditioner.cc | 38 +++++++---- libs/ardour/delivery.cc | 1 + libs/ardour/midi_track.cc | 72 +------------------- libs/ardour/route.cc | 104 ++++++++++++++--------------- libs/ardour/session.cc | 34 +++++++++- libs/ardour/session_process.cc | 8 ++- libs/ardour/session_state.cc | 80 +++++++++++++++++++---- libs/ardour/session_transport.cc | 2 +- libs/ardour/track.cc | 18 +++-- 16 files changed, 243 insertions(+), 288 deletions(-) diff --git a/libs/ardour/ardour/audio_track.h b/libs/ardour/ardour/audio_track.h index faae97d85a..11c1090a63 100644 --- a/libs/ardour/ardour/audio_track.h +++ b/libs/ardour/ardour/audio_track.h @@ -43,8 +43,8 @@ class AudioTrack : public Track boost::shared_ptr audio_diskstream() const; - int use_diskstream (std::string name); - int use_diskstream (const PBD::ID& id); + void use_new_diskstream (); + void set_diskstream (boost::shared_ptr); int export_stuff (BufferSet& bufs, sframes_t start_frame, nframes_t nframes, bool enable_processing = true); @@ -62,9 +62,7 @@ class AudioTrack : public Track int _set_state (const XMLNode&, int, bool call_base); private: - int set_diskstream (boost::shared_ptr, void *); int deprecated_use_diskstream_connections (); - void use_new_diskstream (); void set_state_part_two (); void set_state_part_three (); }; diff --git a/libs/ardour/ardour/auditioner.h b/libs/ardour/ardour/auditioner.h index aa525b68c9..f779fa8457 100644 --- a/libs/ardour/ardour/auditioner.h +++ b/libs/ardour/ardour/auditioner.h @@ -39,6 +39,8 @@ class Auditioner : public AudioTrack Auditioner (Session&); ~Auditioner (); + int init (); + void audition_region (boost::shared_ptr); ARDOUR::AudioPlaylist& prepare_playlist (); @@ -47,15 +49,15 @@ class Auditioner : public AudioTrack int play_audition (nframes_t nframes); void cancel_audition () { - g_atomic_int_set (&_active, 0); + g_atomic_int_set (&_auditioning, 0); } - bool active() const { return g_atomic_int_get (&_active); } + bool auditioning() const { return g_atomic_int_get (&_auditioning); } private: boost::shared_ptr the_region; nframes_t current_frame; - mutable gint _active; + mutable gint _auditioning; Glib::Mutex lock; nframes_t length; diff --git a/libs/ardour/ardour/midi_track.h b/libs/ardour/ardour/midi_track.h index 1d77889d39..133db881fb 100644 --- a/libs/ardour/ardour/midi_track.h +++ b/libs/ardour/ardour/midi_track.h @@ -45,8 +45,8 @@ public: boost::shared_ptr midi_diskstream() const; - int use_diskstream (string name); - int use_diskstream (const PBD::ID& id); + void use_new_diskstream (); + void set_diskstream (boost::shared_ptr); void set_latency_delay (nframes_t); @@ -98,8 +98,6 @@ protected: private: void write_out_of_band_data (BufferSet& bufs, sframes_t start_frame, sframes_t end_frame, nframes_t nframes); - int set_diskstream (boost::shared_ptr ds); - void use_new_diskstream (); void set_state_part_two (); void set_state_part_three (); diff --git a/libs/ardour/ardour/route.h b/libs/ardour/ardour/route.h index 681d8b7681..2696b500ac 100644 --- a/libs/ardour/ardour/route.h +++ b/libs/ardour/ardour/route.h @@ -71,6 +71,8 @@ class Route : public SessionObject, public AutomatableControls, public RouteGrou Route (Session&, std::string name, Flag flags = Flag(0), DataType default_type = DataType::AUDIO); virtual ~Route(); + virtual int init (); + boost::shared_ptr input() const { return _input; } boost::shared_ptr output() const { return _output; } @@ -393,9 +395,10 @@ class Route : public SessionObject, public AutomatableControls, public RouteGrou virtual ChanCount input_streams () const; protected: - virtual XMLNode& state(bool); + int configure_processors (ProcessorStreams*); + void passthru_silence (sframes_t start_frame, sframes_t end_frame, nframes_t nframes, int declick); @@ -413,7 +416,6 @@ class Route : public SessionObject, public AutomatableControls, public RouteGrou boost::shared_ptr _meter; private: - void init (); int _set_state_2X (const XMLNode&, int); void set_processor_state_2X (XMLNodeList const &, int); @@ -427,7 +429,6 @@ class Route : public SessionObject, public AutomatableControls, public RouteGrou bool _in_configure_processors; - int configure_processors (ProcessorStreams*); int configure_processors_unlocked (ProcessorStreams*); bool add_processor_from_xml (const XMLNode&, ProcessorList::iterator iter); diff --git a/libs/ardour/ardour/track.h b/libs/ardour/ardour/track.h index 2b6704a1cb..21428f4d21 100644 --- a/libs/ardour/ardour/track.h +++ b/libs/ardour/ardour/track.h @@ -35,9 +35,10 @@ class Track : public Route { public: Track (Session&, std::string name, Route::Flag f = Route::Flag (0), TrackMode m = Normal, DataType default_type = DataType::AUDIO); - virtual ~Track (); + int init (); + bool set_name (const std::string& str); TrackMode mode () const { return _mode; } @@ -60,8 +61,8 @@ class Track : public Route boost::shared_ptr diskstream() const { return _diskstream; } - virtual int use_diskstream (std::string name) = 0; - virtual int use_diskstream (const PBD::ID& id) = 0; + virtual void use_new_diskstream () = 0; + virtual void set_diskstream (boost::shared_ptr) = 0; nframes_t update_total_latency(); void set_latency_delay (nframes_t); diff --git a/libs/ardour/audio_diskstream.cc b/libs/ardour/audio_diskstream.cc index e5dfb238db..b9cc41d7c5 100644 --- a/libs/ardour/audio_diskstream.cc +++ b/libs/ardour/audio_diskstream.cc @@ -498,7 +498,6 @@ AudioDiskstream::process (nframes_t transport_frame, nframes_t nframes, bool can } } - if (can_record && !_last_capture_regions.empty()) { _last_capture_regions.clear (); } @@ -666,7 +665,7 @@ AudioDiskstream::process (nframes_t transport_frame, nframes_t nframes, bool can _speed = _target_speed; - } + } ret = 0; diff --git a/libs/ardour/audio_track.cc b/libs/ardour/audio_track.cc index cbfef29b17..2f43634447 100644 --- a/libs/ardour/audio_track.cc +++ b/libs/ardour/audio_track.cc @@ -52,7 +52,6 @@ using namespace PBD; AudioTrack::AudioTrack (Session& sess, string name, Route::Flag flag, TrackMode mode) : Track (sess, name, flag, mode) { - use_new_diskstream (); } AudioTrack::~AudioTrack () @@ -81,7 +80,36 @@ AudioTrack::use_new_diskstream () _session.add_diskstream (ds); - set_diskstream (boost::dynamic_pointer_cast (ds), this); + set_diskstream (ds); +} + +void +AudioTrack::set_diskstream (boost::shared_ptr ds) +{ + _diskstream = ds; + _diskstream->set_route (*this); + _diskstream->set_destructive (_mode == Destructive); + _diskstream->set_non_layered (_mode == NonLayered); + + if (audio_diskstream()->deprecated_io_node) { + + if (!IO::connecting_legal) { + IO::ConnectingLegal.connect_same_thread (*this, boost::bind (&AudioTrack::deprecated_use_diskstream_connections, this)); + } else { + deprecated_use_diskstream_connections (); + } + } + + _diskstream->set_record_enabled (false); + _diskstream->monitor_input (false); + + DiskstreamChanged (); /* EMIT SIGNAL */ +} + +boost::shared_ptr +AudioTrack::audio_diskstream() const +{ + return boost::dynamic_pointer_cast(_diskstream); } int @@ -165,63 +193,6 @@ AudioTrack::deprecated_use_diskstream_connections () return 0; } -int -AudioTrack::set_diskstream (boost::shared_ptr ds, void * /*src*/) -{ - _diskstream = ds; - _diskstream->set_route (*this); - _diskstream->set_destructive (_mode == Destructive); - _diskstream->set_non_layered (_mode == NonLayered); - - if (audio_diskstream()->deprecated_io_node) { - - if (!IO::connecting_legal) { - IO::ConnectingLegal.connect_same_thread (*this, boost::bind (&AudioTrack::deprecated_use_diskstream_connections, this)); - } else { - deprecated_use_diskstream_connections (); - } - } - - _diskstream->set_record_enabled (false); - _diskstream->monitor_input (false); - - DiskstreamChanged (); /* EMIT SIGNAL */ - - return 0; -} - -int -AudioTrack::use_diskstream (string name) -{ - boost::shared_ptr dstream; - - if ((dstream = boost::dynamic_pointer_cast(_session.diskstream_by_name (name))) == 0) { - error << string_compose(_("AudioTrack: audio diskstream \"%1\" not known by session"), name) << endmsg; - return -1; - } - - return set_diskstream (dstream, this); -} - -int -AudioTrack::use_diskstream (const PBD::ID& id) -{ - boost::shared_ptr dstream; - - if ((dstream = boost::dynamic_pointer_cast (_session.diskstream_by_id (id))) == 0) { - error << string_compose(_("AudioTrack: audio diskstream \"%1\" not known by session"), id) << endmsg; - return -1; - } - - return set_diskstream (dstream, this); -} - -boost::shared_ptr -AudioTrack::audio_diskstream() const -{ - return boost::dynamic_pointer_cast(_diskstream); -} - int AudioTrack::set_state (const XMLNode& node, int version) { @@ -246,41 +217,6 @@ AudioTrack::_set_state (const XMLNode& node, int version, bool call_base) _mode = Normal; } - if ((prop = node.property ("diskstream-id")) == 0) { - - /* some old sessions use the diskstream name rather than the ID */ - - if ((prop = node.property ("diskstream")) == 0) { - fatal << _("programming error: AudioTrack given state without diskstream!") << endmsg; - /*NOTREACHED*/ - return -1; - } - - if (use_diskstream (prop->value())) { - return -1; - } - - } else { - - PBD::ID id (prop->value()); - PBD::ID zero ("0"); - - /* this wierd hack is used when creating tracks from a template. there isn't - a particularly good time to interpose between setting the first part of - the track state (notably Route::set_state() and the track mode), and the - second part (diskstream stuff). So, we have a special ID for the diskstream - that means "you should create a new diskstream here, not look for - an old one. - */ - - if (id == zero) { - use_new_diskstream (); - } else if (use_diskstream (id)) { - return -1; - } - } - - XMLNodeList nlist; XMLNodeConstIterator niter; XMLNode *child; @@ -512,24 +448,13 @@ AudioTrack::roll (nframes_t nframes, sframes_t start_frame, sframes_t end_frame, /* copy the diskstream data to all output buffers */ - size_t limit = _input->n_ports().n_audio(); + size_t limit = input_streams ().n_audio(); BufferSet& bufs = _session.get_scratch_buffers (); const size_t blimit = bufs.count().n_audio(); - if (limit == 0) { - /* no inputs, try for diskstream channel count */ - limit = diskstream->n_channels().n_audio(); - } - uint32_t n; uint32_t i; - cerr << _name << " Input = " << _input->n_ports() - << " Output " << _output->n_ports () - << " limit " << limit - << " blimit " << blimit - << endl; - if (limit > blimit) { /* example case: auditioner configured for stereo output, diff --git a/libs/ardour/auditioner.cc b/libs/ardour/auditioner.cc index dec9452977..f955c75ea4 100644 --- a/libs/ardour/auditioner.cc +++ b/libs/ardour/auditioner.cc @@ -43,6 +43,15 @@ using namespace PBD; Auditioner::Auditioner (Session& s) : AudioTrack (s, "auditioner", Route::Hidden) { +} + +int +Auditioner::init () +{ + if (Track::init ()) { + return -1; + } + string left = _session.config.get_auditioner_output_left(); string right = _session.config.get_auditioner_output_right(); @@ -64,19 +73,16 @@ Auditioner::Auditioner (Session& s) if ((left.length() == 0) && (right.length() == 0)) { warning << _("no outputs available for auditioner - manual connection required") << endmsg; - return; + return -1; } _main_outs->defer_pan_reset (); - cerr << "Aud connect " << left << " + " << right << endl; - if (left.length()) { _output->add_port (left, this, DataType::AUDIO); } if (right.length()) { - audio_diskstream()->add_channel (1); _output->add_port (right, this, DataType::AUDIO); } @@ -86,7 +92,9 @@ Auditioner::Auditioner (Session& s) _output->changed.connect_same_thread (*this, boost::bind (&Auditioner::output_changed, this, _1, _2)); the_region.reset ((AudioRegion*) 0); - g_atomic_int_set (&_active, 0); + g_atomic_int_set (&_auditioning, 0); + + return 0; } Auditioner::~Auditioner () @@ -107,7 +115,7 @@ Auditioner::prepare_playlist () void Auditioner::audition_current_playlist () { - if (g_atomic_int_get (&_active)) { + if (g_atomic_int_get (&_auditioning)) { /* don't go via session for this, because we are going to remain active. */ @@ -123,13 +131,13 @@ Auditioner::audition_current_playlist () _main_outs->panner()->reset (n_outputs().n_audio(), _diskstream->n_channels().n_audio()); - g_atomic_int_set (&_active, 1); + g_atomic_int_set (&_auditioning, 1); } void Auditioner::audition_region (boost::shared_ptr region) { - if (g_atomic_int_get (&_active)) { + if (g_atomic_int_get (&_auditioning)) { /* don't go via session for this, because we are going to remain active. */ @@ -157,6 +165,13 @@ Auditioner::audition_region (boost::shared_ptr region) audio_diskstream()->remove_channel (_diskstream->n_channels().n_audio() - the_region->n_channels()); } + ProcessorStreams ps; + if (configure_processors (&ps)) { + error << string_compose (_("Cannot setup auditioner processing flow for %1 channels"), + _diskstream->n_channels()) << endmsg; + return; + } + /* force a panner reset now that we have all channels */ _main_outs->reset_panner(); @@ -175,7 +190,7 @@ Auditioner::audition_region (boost::shared_ptr region) _diskstream->seek (offset); current_frame = offset; - g_atomic_int_set (&_active, 1); + g_atomic_int_set (&_auditioning, 1); } int @@ -185,7 +200,7 @@ Auditioner::play_audition (nframes_t nframes) nframes_t this_nframes; int ret; - if (g_atomic_int_get (&_active) == 0) { + if (g_atomic_int_get (&_auditioning) == 0) { silence (nframes); return 0; } @@ -194,10 +209,7 @@ Auditioner::play_audition (nframes_t nframes) _diskstream->prepare (); - cerr << "Auditioner rolls, gain = " << gain_control()->get_value() << endl; - if ((ret = roll (this_nframes, current_frame, current_frame + nframes, false, false, false)) != 0) { - cerr << "\troll failed\n"; silence (nframes); return ret; } diff --git a/libs/ardour/delivery.cc b/libs/ardour/delivery.cc index eaf58c0a9b..50ca18cb6d 100644 --- a/libs/ardour/delivery.cc +++ b/libs/ardour/delivery.cc @@ -290,6 +290,7 @@ Delivery::run (BufferSet& bufs, sframes_t start_frame, sframes_t end_frame, nfra } } else { + // Do a 1:1 copy of data to output ports if (bufs.count().n_audio() > 0 && ports.count().n_audio () > 0) { diff --git a/libs/ardour/midi_track.cc b/libs/ardour/midi_track.cc index 8d04610d0a..15a749d051 100644 --- a/libs/ardour/midi_track.cc +++ b/libs/ardour/midi_track.cc @@ -57,12 +57,6 @@ MidiTrack::MidiTrack (Session& sess, string name, Route::Flag flag, TrackMode mo , _default_channel (0) , _midi_thru (true) { - use_new_diskstream (); - - _declickable = true; - _freeze_record.state = NoFreeze; - _saved_meter_point = _meter_point; - _mode = mode; } MidiTrack::~MidiTrack () @@ -88,8 +82,8 @@ MidiTrack::use_new_diskstream () set_diskstream (boost::dynamic_pointer_cast (ds)); } -int -MidiTrack::set_diskstream (boost::shared_ptr ds) +void +MidiTrack::set_diskstream (boost::shared_ptr ds) { _diskstream = ds; _diskstream->set_route (*this); @@ -99,34 +93,6 @@ MidiTrack::set_diskstream (boost::shared_ptr ds) //_diskstream->monitor_input (false); DiskstreamChanged (); /* EMIT SIGNAL */ - - return 0; -} - -int -MidiTrack::use_diskstream (string name) -{ - boost::shared_ptr dstream; - - if ((dstream = boost::dynamic_pointer_cast(_session.diskstream_by_name (name))) == 0) { - error << string_compose(_("MidiTrack: midi diskstream \"%1\" not known by session"), name) << endmsg; - return -1; - } - - return set_diskstream (dstream); -} - -int -MidiTrack::use_diskstream (const PBD::ID& id) -{ - boost::shared_ptr dstream; - - if ((dstream = boost::dynamic_pointer_cast (_session.diskstream_by_id (id))) == 0) { - error << string_compose(_("MidiTrack: midi diskstream \"%1\" not known by session"), id) << endmsg; - return -1; - } - - return set_diskstream (dstream); } boost::shared_ptr @@ -168,40 +134,6 @@ MidiTrack::_set_state (const XMLNode& node, int version, bool call_base) set_default_channel ((uint8_t) atoi (prop->value())); } - if ((prop = node.property ("diskstream-id")) == 0) { - - /* some old sessions use the diskstream name rather than the ID */ - - if ((prop = node.property ("diskstream")) == 0) { - fatal << _("programming error: MidiTrack given state without diskstream!") << endmsg; - /*NOTREACHED*/ - return -1; - } - - if (use_diskstream (prop->value())) { - return -1; - } - - } else { - - PBD::ID id (prop->value()); - PBD::ID zero ("0"); - - /* this wierd hack is used when creating tracks from a template. there isn't - a particularly good time to interpose between setting the first part of - the track state (notably Route::set_state() and the track mode), and the - second part (diskstream stuff). So, we have a special ID for the diskstream - that means "you should create a new diskstream here, not look for - an old one. - */ - - if (id == zero) { - use_new_diskstream (); - } else if (use_diskstream (id)) { - return -1; - } - } - XMLNodeList nlist; XMLNodeConstIterator niter; XMLNode *child; diff --git a/libs/ardour/route.cc b/libs/ardour/route.cc index f0c52daa6f..aee3bdf2c3 100644 --- a/libs/ardour/route.cc +++ b/libs/ardour/route.cc @@ -72,14 +72,57 @@ PBD::Signal0 Route::RemoteControlIDChange; Route::Route (Session& sess, string name, Flag flg, DataType default_type) : SessionObject (sess, name) , AutomatableControls (sess) + , _active (true) + , _initial_delay (0) + , _roll_delay (0) , _flags (flg) + , _pending_declick (true) + , _meter_point (MeterPostFader) + , _phase_invert (0) + , _self_solo (false) + , _soloed_by_others (0) + , _solo_isolated (0) + , _denormal_protection (false) + , _recordable (true) + , _silent (false) + , _declickable (false) , _solo_control (new SoloControllable (X_("solo"), *this)) , _mute_control (new MuteControllable (X_("mute"), *this)) , _mute_master (new MuteMaster (sess, name)) + , _mute_points (MuteMaster::AllPoints) + , _have_internal_generator (false) + , _solo_safe (false) , _default_type (default_type) + , _remote_control_id (0) + , _in_configure_processors (false) +{ + processor_max_streams.reset(); + order_keys[N_("signal")] = order_key_cnt++; +} +int +Route::init () { - init (); + /* add standard controls */ + + _solo_control->set_flags (Controllable::Flag (_solo_control->flags() | Controllable::Toggle)); + _mute_control->set_flags (Controllable::Flag (_solo_control->flags() | Controllable::Toggle)); + + add_control (_solo_control); + add_control (_mute_control); + + /* input and output objects */ + + _input.reset (new IO (_session, _name, IO::Input, _default_type)); + _output.reset (new IO (_session, _name, IO::Output, _default_type)); + + _input->changed.connect_same_thread (*this, boost::bind (&Route::input_change_handler, this, _1, _2)); + _output->changed.connect_same_thread (*this, boost::bind (&Route::output_change_handler, this, _1, _2)); + + /* add amp processor */ + + _amp.reset (new Amp (_session, _mute_master)); + add_processor (_amp, PostFader); /* add standard processors other than amp (added by ::init()) */ @@ -119,53 +162,8 @@ Route::Route (Session& sess, string name, Flag flg, DataType default_type) /* now that we have _meter, its safe to connect to this */ Metering::Meter.connect_same_thread (*this, (boost::bind (&Route::meter, this))); -} -void -Route::init () -{ - _self_solo = false; - _soloed_by_others = 0; - _solo_isolated = 0; - _solo_safe = false; - _active = true; - processor_max_streams.reset(); - _recordable = true; - order_keys[N_("signal")] = order_key_cnt++; - _silent = false; - _meter_point = MeterPostFader; - _initial_delay = 0; - _roll_delay = 0; - _have_internal_generator = false; - _declickable = false; - _pending_declick = true; - _remote_control_id = 0; - _in_configure_processors = false; - _mute_points = MuteMaster::AllPoints; - - _phase_invert = 0; - _denormal_protection = false; - - /* add standard controls */ - - _solo_control->set_flags (Controllable::Flag (_solo_control->flags() | Controllable::Toggle)); - _mute_control->set_flags (Controllable::Flag (_solo_control->flags() | Controllable::Toggle)); - - add_control (_solo_control); - add_control (_mute_control); - - /* input and output objects */ - - _input.reset (new IO (_session, _name, IO::Input, _default_type)); - _output.reset (new IO (_session, _name, IO::Output, _default_type)); - - _input->changed.connect_same_thread (*this, boost::bind (&Route::input_change_handler, this, _1, _2)); - _output->changed.connect_same_thread (*this, boost::bind (&Route::output_change_handler, this, _1, _2)); - - /* add amp processor */ - - _amp.reset (new Amp (_session, _mute_master)); - add_processor (_amp, PostFader); + return 0; } Route::~Route () @@ -455,7 +453,7 @@ Route::process_output_buffers (BufferSet& bufs, << endl; } assert (bufs.count() == (*i)->input_streams()); - + (*i)->run (bufs, start_frame, end_frame, nframes, *i != _processors.back()); bufs.set_count ((*i)->output_streams()); } @@ -475,15 +473,15 @@ Route::passthru (sframes_t start_frame, sframes_t end_frame, nframes_t nframes, _silent = false; - assert (bufs.available() >= _input->n_ports()); + assert (bufs.available() >= input_streams()); if (_input->n_ports() == ChanCount::ZERO) { silence (nframes); } - bufs.set_count (_input->n_ports()); + bufs.set_count (input_streams()); - if (is_monitor() && _session.listening()) { + if (is_monitor() && _session.listening() && !_session.is_auditioning()) { /* control/monitor bus ignores input ports when something is feeding the listen "stream". data will "arrive" into the @@ -1547,7 +1545,6 @@ Route::configure_processors (ProcessorStreams* err) ChanCount Route::input_streams () const { - cerr << "!!!!!!!!!" << _name << " ::input_streams()\n"; return _input->n_ports (); } @@ -1564,9 +1561,6 @@ Route::configure_processors_unlocked (ProcessorStreams* err) _in_configure_processors = true; // Check each processor in order to see if we can configure as requested - if (_name == "auditioner") { - cerr << "AUD conf\n"; - } ChanCount in = input_streams (); ChanCount out; list< pair > configuration; diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index 398c125935..c29a6fe675 100644 --- a/libs/ardour/session.cc +++ b/libs/ardour/session.cc @@ -638,7 +638,13 @@ Session::hookup_io () */ try { - auditioner.reset (new Auditioner (*this)); + Auditioner* a = new Auditioner (*this); + if (a->init()) { + delete a; + throw failed_constructor(); + } + a->use_new_diskstream (); + auditioner.reset (a); } catch (failed_constructor& err) { @@ -1454,6 +1460,14 @@ Session::new_midi_track (TrackMode mode, RouteGroup* route_group, uint32_t how_m try { MidiTrack* mt = new MidiTrack (*this, track_name, Route::Flag (0), mode); + + if (mt->init ()) { + delete mt; + goto failed; + } + + mt->use_new_diskstream(); + boost_debug_shared_ptr_mark_interesting (mt, "Track"); track = boost::shared_ptr(mt); @@ -1630,6 +1644,14 @@ Session::new_audio_track (int input_channels, int output_channels, TrackMode mod try { AudioTrack* at = new AudioTrack (*this, track_name, Route::Flag (0), mode); + + if (at->init ()) { + delete at; + goto failed; + } + + at->use_new_diskstream(); + boost_debug_shared_ptr_mark_interesting (at, "Track"); track = boost::shared_ptr(at); @@ -1762,6 +1784,12 @@ Session::new_audio_route (bool aux, int input_channels, int output_channels, Rou try { Route* rt = new Route (*this, bus_name, Route::Flag(0), DataType::AUDIO); + + if (rt->init ()) { + delete rt; + goto failure; + } + boost_debug_shared_ptr_mark_interesting (rt, "Route"); shared_ptr bus (rt); @@ -3154,7 +3182,7 @@ Session::audition_region (boost::shared_ptr r) void Session::cancel_audition () { - if (auditioner->active()) { + if (auditioner->auditioning()) { auditioner->cancel_audition (); AuditionActive (false); /* EMIT SIGNAL */ } @@ -3213,7 +3241,7 @@ Session::is_auditioning () const { /* can be called before we have an auditioner object */ if (auditioner) { - return auditioner->active(); + return auditioner->auditioning(); } else { return false; } diff --git a/libs/ardour/session_process.cc b/libs/ardour/session_process.cc index 9baa0aea9e..306df524a8 100644 --- a/libs/ardour/session_process.cc +++ b/libs/ardour/session_process.cc @@ -878,6 +878,12 @@ Session::process_audition (nframes_t nframes) _butler->summon (); } + /* if using a monitor section, run it because otherwise we don't hear anything */ + + if (_monitor_out) { + _monitor_out->passthru (_transport_frame, _transport_frame + nframes, nframes, false); + } + /* handle pending events */ while (pending_events.read (&ev, 1) == 1) { @@ -895,7 +901,7 @@ Session::process_audition (nframes_t nframes) process_event (ev); } - if (!auditioner->active()) { + if (!auditioner->auditioning()) { /* auditioner no longer active, so go back to the normal process callback */ process_function = &Session::process_with_events; } diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc index 40cbe53389..4c0dcfd72d 100644 --- a/libs/ardour/session_state.cc +++ b/libs/ardour/session_state.cc @@ -561,6 +561,10 @@ Session::create (const string& mix_template, nframes_t initial_length, BusProfil if (bus_profile->master_out_channels) { Route* rt = new Route (*this, _("master"), Route::MasterOut, DataType::AUDIO); + if (rt->init ()) { + delete rt; + return -1; + } boost_debug_shared_ptr_mark_interesting (rt, "Route"); boost::shared_ptr r (rt); r->input()->ensure_io (count, false, this); @@ -571,6 +575,10 @@ Session::create (const string& mix_template, nframes_t initial_length, BusProfil if (Config->get_use_monitor_bus()) { Route* rt = new Route (*this, _("monitor"), Route::MonitorOut, DataType::AUDIO); + if (rt->init ()) { + delete rt; + return -1; + } boost_debug_shared_ptr_mark_interesting (rt, "Route"); boost::shared_ptr r (rt); r->input()->ensure_io (count, false, this); @@ -1425,8 +1433,12 @@ Session::XMLRouteFactory (const XMLNode& node, int version) return ret; } - bool has_diskstream = (node.property ("diskstream") != 0 || node.property ("diskstream-id") != 0); + const XMLProperty* dsprop; + if ((dsprop = node.property (X_("diskstream-id"))) == 0) { + dsprop = node.property (X_("diskstream")); + } + DataType type = DataType::AUDIO; const XMLProperty* prop = node.property("default-type"); @@ -1436,25 +1448,65 @@ Session::XMLRouteFactory (const XMLNode& node, int version) assert (type != DataType::NIL); - if (has_diskstream) { - if (type == DataType::AUDIO) { - AudioTrack* at = new AudioTrack (*this, X_("toBeResetFroXML")); - if (at->set_state (node, version) == 0) { - boost_debug_shared_ptr_mark_interesting (at, "Track"); - ret.reset (at); + if (dsprop) { + + boost::shared_ptr ds; + PBD::ID diskstream_id (dsprop->value()); + PBD::ID zero ("0"); + + /* this wierd hack is used when creating + tracks from a template. We have a special + ID for the diskstream that means "you + should create a new diskstream here, not + look for an old one." + */ + + if (diskstream_id != zero) { + + ds = diskstream_by_id (diskstream_id); + + if (!ds) { + error << string_compose (_("cannot find diskstream ID %1"), diskstream_id.to_s()) << endmsg; + return ret; } + } + + Track* track; + + if (type == DataType::AUDIO) { + track = new AudioTrack (*this, X_("toBeResetFroXML")); - } else { - MidiTrack* mt = new MidiTrack (*this, X_("toBeResetFroXML")); - if (mt->set_state (node, version) == 0) { - ret.reset (mt); - } - } + } else { + track = new MidiTrack (*this, X_("toBeResetFroXML")); + } + + if (track->init()) { + delete track; + return ret; + } + + if (ds) { + track->set_diskstream (ds); + } else { + track->use_new_diskstream (); + } + + if (track->set_state (node, version)) { + delete track; + return ret; + } + + boost_debug_shared_ptr_mark_interesting (track, "Track"); + ret.reset (track); + } else { Route* rt = new Route (*this, X_("toBeResetFroXML")); - if (rt->set_state (node, version) == 0) { + + if (rt->init () == 0 && rt->set_state (node, version) == 0) { boost_debug_shared_ptr_mark_interesting (rt, "Route"); ret.reset (rt); + } else { + delete rt; } } diff --git a/libs/ardour/session_transport.cc b/libs/ardour/session_transport.cc index 7d08c62113..db06a2d703 100644 --- a/libs/ardour/session_transport.cc +++ b/libs/ardour/session_transport.cc @@ -1106,7 +1106,7 @@ Session::post_transport () PostTransportWork ptw = post_transport_work (); if (ptw & PostTransportAudition) { - if (auditioner && auditioner->active()) { + if (auditioner && auditioner->auditioning()) { process_function = &Session::process_audition; } else { process_function = &Session::process_with_events; diff --git a/libs/ardour/track.cc b/libs/ardour/track.cc index 92b776f7f2..7929640b64 100644 --- a/libs/ardour/track.cc +++ b/libs/ardour/track.cc @@ -41,12 +41,12 @@ using namespace PBD; Track::Track (Session& sess, string name, Route::Flag flag, TrackMode mode, DataType default_type) : Route (sess, name, flag, default_type) + , _saved_meter_point (_meter_point) + , _mode (mode) , _rec_enable_control (new RecEnableControllable(*this)) { - _declickable = true; _freeze_record.state = NoFreeze; - _saved_meter_point = _meter_point; - _mode = mode; + _declickable = true; } Track::~Track () @@ -54,6 +54,15 @@ Track::~Track () DEBUG_TRACE (DEBUG::Destruction, string_compose ("track %1 destructor\n", _name)); } +int +Track::init () +{ + if (Route::init ()) { + return -1; + } + + return 0; +} XMLNode& Track::get_state () { @@ -345,10 +354,7 @@ Track::input_streams () const { ChanCount cc = _input->n_ports (); - cerr << "**************" << _name << " IS = " << cc << endl; - if (cc.n_total() == 0 && _diskstream) { - cerr << "*******" << _name << " use diskstream channel count\n"; return cc = _diskstream->n_channels(); } -- cgit v1.2.3