#include <sys/stat.h>
#include <sys/mman.h>
-#include <sigc++/bind.h>
#include "pbd/error.h"
#include "pbd/basename.h"
#include "ardour/ardour.h"
#include "ardour/audioengine.h"
+#include "ardour/debug.h"
#include "ardour/diskstream.h"
#include "ardour/utils.h"
#include "ardour/configuration.h"
*/
ARDOUR::nframes_t Diskstream::disk_io_chunk_frames = 1024 * 256;
-sigc::signal<void> Diskstream::DiskOverrun;
-sigc::signal<void> Diskstream::DiskUnderrun;
+PBD::Signal0<void> Diskstream::DiskOverrun;
+PBD::Signal0<void> Diskstream::DiskUnderrun;
Diskstream::Diskstream (Session &sess, const string &name, Flag flag)
: SessionObject(sess, name)
Diskstream::~Diskstream ()
{
- if (_playlist)
+ DEBUG_TRACE (DEBUG::Destruction, string_compose ("Diskstream %1 deleted\n", _name));
+
+ if (_playlist) {
_playlist->release ();
+ }
}
void
{
_route = &r;
_io = _route->input();
+
+ ic_connection.disconnect();
+ _io->changed.connect_same_thread (ic_connection, boost::bind (&Diskstream::handle_input_change, this, _1, _2));
+
input_change_pending = ConfigurationChanged;
non_realtime_input_change ();
set_align_style_from_io ();
- _route->GoingAway.connect (mem_fun (*this, &Diskstream::route_going_away));
+ _route->Destroyed.connect_same_thread (*this, boost::bind (&Diskstream::route_going_away, this));
}
void
if (capture_info.size() > n) {
return capture_info[n]->frames;
}
- else {
+ else {
return capture_captured;
}
}
return 0;
}
- plmod_connection.disconnect ();
- plgone_connection.disconnect ();
- plregion_connection.disconnect ();
+ playlist_connections.drop_connections ();
if (_playlist) {
_playlist->release();
reset_write_sources (false);
}
- plmod_connection = _playlist->Modified.connect (mem_fun (*this, &Diskstream::playlist_modified));
- plgone_connection = _playlist->GoingAway.connect (bind (mem_fun (*this, &Diskstream::playlist_deleted), boost::weak_ptr<Playlist>(_playlist)));
- plregion_connection = _playlist->RangesMoved.connect (mem_fun (*this, &Diskstream::playlist_ranges_moved));
+ _playlist->ContentsChanged.connect_same_thread (playlist_connections, boost::bind (&Diskstream::playlist_modified, this));
+ _playlist->DropReferences.connect_same_thread (playlist_connections, boost::bind (&Diskstream::playlist_deleted, this, boost::weak_ptr<Playlist>(_playlist)));
+ _playlist->RangesMoved.connect_same_thread (playlist_connections, boost::bind (&Diskstream::playlist_ranges_moved, this, _1));
}
/* don't do this if we've already asked for it *or* if we are setting up
bool
Diskstream::set_name (const string& str)
{
- if (str != _name) {
+ if (_name != str) {
assert(playlist());
playlist()->set_name (str);
}
/* move processor automation */
- _route->foreach_processor (sigc::bind (sigc::mem_fun (*this, &Diskstream::move_processor_automation), movements_frames));
+ _route->foreach_processor (boost::bind (&Diskstream::move_processor_automation, this, _1, movements_frames));
}
void
-Diskstream::move_processor_automation (boost::weak_ptr<Processor> p,
- list< Evoral::RangeMove<nframes_t> > const & movements_frames)
+Diskstream::move_processor_automation (boost::weak_ptr<Processor> p, list< Evoral::RangeMove<nframes_t> > const & movements_frames)
{
boost::shared_ptr<Processor> processor (p.lock ());
if (!processor) {
/* was stopped, now rolling (and recording) */
if (_alignment_style == ExistingMaterial) {
+
first_recordable_frame += _session.worst_output_latency();
+
+ DEBUG_TRACE (DEBUG::Latency, string_compose ("Offset rec from stop. Capture offset: %1 Worst O/P Latency: %2 Roll Delay: %3 First Recordable Frame: %4 Transport Frame: %5\n",
+ _capture_offset, _session.worst_output_latency(), _roll_delay, first_recordable_frame, transport_frame));
} else {
first_recordable_frame += _roll_delay;
}
if (_alignment_style == ExistingMaterial) {
-
- if (!_session.config.get_punch_in()) {
-
- /* manual punch in happens at the correct transport frame
- because the user hit a button. but to get alignment correct
- we have to back up the position of the new region to the
- appropriate spot given the roll delay.
- */
-
- capture_start_frame -= _roll_delay;
-
- /* XXX paul notes (august 2005): i don't know why
- this is needed.
- */
-
- first_recordable_frame += _capture_offset;
-
- } else {
-
- /* autopunch toggles recording at the precise
- transport frame, and then the DS waits
- to start recording for a time that depends
- on the output latency.
- */
-
- first_recordable_frame += _session.worst_output_latency();
- }
-
+ /* manual punch in happens at the correct transport frame
+ because the user hit a button. but to get alignment correct
+ we have to back up the position of the new region to the
+ appropriate spot given the roll delay.
+ */
+
+
+ /* autopunch toggles recording at the precise
+ transport frame, and then the DS waits
+ to start recording for a time that depends
+ on the output latency.
+ */
+
+ first_recordable_frame += _session.worst_output_latency();
+
+ DEBUG_TRACE (DEBUG::Latency, string_compose ("Punch in manual/auto. Capture offset: %1 Worst O/P Latency: %2 Roll Delay: %3 First Recordable Frame: %4 Transport Frame: %5\n",
+ _capture_offset, _session.worst_output_latency(), _roll_delay, first_recordable_frame, transport_frame));
} else {
if (_session.config.get_punch_in()) {
} else {
last_recordable_frame += _roll_delay;
}
+
+ //first_recordable_frame = max_frames;
+
+ DEBUG_TRACE (DEBUG::Latency, string_compose ("Stop record - %6 | %7. Capture offset: %1 Worst O/P Latency: %2 Roll Delay: %3 First Recordable Frame: %4 Transport Frame: %5\n",
+ _capture_offset, _session.worst_output_latency(), _roll_delay, first_recordable_frame, transport_frame,
+ can_record, record_enabled()));
}
last_possibly_recording = possibly_recording;
{
_io.reset ();
}
+
+void
+Diskstream::calculate_record_range(OverlapType ot, sframes_t transport_frame, nframes_t nframes,
+ nframes_t& rec_nframes, nframes_t& rec_offset)
+{
+ switch (ot) {
+ case OverlapNone:
+ rec_nframes = 0;
+ break;
+
+ case OverlapInternal:
+ /* ---------- recrange
+ |---| transrange
+ */
+ rec_nframes = nframes;
+ rec_offset = 0;
+ break;
+
+ case OverlapStart:
+ /* |--------| recrange
+ -----| transrange
+ */
+ rec_nframes = transport_frame + nframes - first_recordable_frame;
+ if (rec_nframes) {
+ rec_offset = first_recordable_frame - transport_frame;
+ }
+ break;
+
+ case OverlapEnd:
+ /* |--------| recrange
+ |-------- transrange
+ */
+ rec_nframes = last_recordable_frame - transport_frame;
+ rec_offset = 0;
+ break;
+
+ case OverlapExternal:
+ /* |--------| recrange
+ -------------- transrange
+ */
+ rec_nframes = last_recordable_frame - first_recordable_frame;
+ rec_offset = first_recordable_frame - transport_frame;
+ break;
+ }
+}