X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fardour%2Fauditioner.cc;h=0c5e8bc6a288ce5ca5fc2ec2f63b7958270f4a93;hb=1bd4c5b3a212460eed1773f6b049d18c89625565;hp=2f0b943c0e68e95827a4476b64c35946d02205d4;hpb=b09ab546542040b1d468c9925c60bda2dfd80da8;p=ardour.git diff --git a/libs/ardour/auditioner.cc b/libs/ardour/auditioner.cc index 2f0b943c0e..0c5e8bc6a2 100644 --- a/libs/ardour/auditioner.cc +++ b/libs/ardour/auditioner.cc @@ -20,6 +20,8 @@ #include +#include + #include #include #include @@ -27,9 +29,14 @@ #include #include #include +#include +#include using namespace std; using namespace ARDOUR; +using namespace PBD; + +#include "i18n.h" Auditioner::Auditioner (Session& s) : AudioTrack (s, "auditioner", Route::Hidden) @@ -44,19 +51,19 @@ Auditioner::Auditioner (Session& s) defer_pan_reset (); if (left.length()) { - add_output_port (left, this); + add_output_port (left, this, DataType::AUDIO); } if (right.length()) { - disk_stream().add_channel(); - add_output_port (right, this); + audio_diskstream()->add_channel(); + add_output_port (right, this, DataType::AUDIO); } allow_pan_reset (); IO::output_changed.connect (mem_fun (*this, &Auditioner::output_changed)); - the_region = 0; + the_region.reset ((AudioRegion*) 0); g_atomic_int_set (&_active, 0); } @@ -67,8 +74,12 @@ Auditioner::~Auditioner () AudioPlaylist& Auditioner::prepare_playlist () { - diskstream->playlist()->clear (false, false); - return *diskstream->playlist(); + // FIXME auditioner is still audio-only + AudioPlaylist* const apl = dynamic_cast(_diskstream->playlist()); + assert(apl); + + apl->clear (); + return *apl; } void @@ -82,19 +93,19 @@ Auditioner::audition_current_playlist () } Glib::Mutex::Lock lm (lock); - diskstream->seek (0); - length = diskstream->playlist()->get_maximum_extent(); + _diskstream->seek (0); + length = _diskstream->playlist()->get_maximum_extent(); current_frame = 0; /* force a panner reset now that we have all channels */ - _panner->reset (n_outputs(), diskstream->n_channels()); + _panner->reset (n_outputs(), _diskstream->n_channels()); g_atomic_int_set (&_active, 1); } void -Auditioner::audition_region (AudioRegion& region) +Auditioner::audition_region (boost::shared_ptr region) { if (g_atomic_int_get (&_active)) { /* don't go via session for this, because we are going @@ -103,37 +114,44 @@ Auditioner::audition_region (AudioRegion& region) cancel_audition (); } + if (boost::dynamic_pointer_cast(region) == 0) { + error << _("Auditioning of non-audio regions not yet supported") << endmsg; + return; + } + Glib::Mutex::Lock lm (lock); - the_region = new AudioRegion (region); + /* copy it */ + + boost::shared_ptr the_region (boost::dynamic_pointer_cast (RegionFactory::create (region))); the_region->set_position (0, this); - diskstream->playlist()->clear (true, false); - diskstream->playlist()->add_region (*the_region, 0, 1, false); + _diskstream->playlist()->clear (); + _diskstream->playlist()->add_region (the_region, 0, 1); - while (diskstream->n_channels() < the_region->n_channels()) { - diskstream->add_channel (); + while (_diskstream->n_channels() < the_region->n_channels()) { + audio_diskstream()->add_channel (); } - while (diskstream->n_channels() > the_region->n_channels()) { - diskstream->remove_channel (); + while (_diskstream->n_channels() > the_region->n_channels()) { + audio_diskstream()->remove_channel (); } /* force a panner reset now that we have all channels */ - _panner->reset (n_outputs(), diskstream->n_channels()); + _panner->reset (n_outputs(), _diskstream->n_channels()); length = the_region->length(); - diskstream->seek (0); + _diskstream->seek (0); current_frame = 0; g_atomic_int_set (&_active, 1); } int -Auditioner::play_audition (jack_nframes_t nframes) +Auditioner::play_audition (nframes_t nframes) { bool need_butler; - jack_nframes_t this_nframes; + nframes_t this_nframes; int ret; if (g_atomic_int_get (&_active) == 0) { @@ -143,14 +161,14 @@ Auditioner::play_audition (jack_nframes_t nframes) this_nframes = min (nframes, length - current_frame); - diskstream->prepare (); + _diskstream->prepare (); if ((ret = roll (this_nframes, current_frame, current_frame + nframes, 0, false, false, false)) != 0) { silence (nframes, 0); return ret; } - need_butler = diskstream->commit (this_nframes); + need_butler = _diskstream->commit (this_nframes); current_frame += this_nframes; if (current_frame >= length) {