#include <sys/mman.h>
#include <pbd/error.h>
-#include <pbd/basename.h>
#include <glibmm/thread.h>
#include <pbd/xml++.h>
#include <pbd/memento_command.h>
#include <ardour/ardour.h>
#include <ardour/audioengine.h>
+#include <ardour/analyser.h>
#include <ardour/audio_diskstream.h>
#include <ardour/utils.h>
#include <ardour/configuration.h>
}
}
+void
+AudioDiskstream::non_realtime_locate (nframes_t location)
+{
+ /* now refill channel buffers */
+
+ if (speed() != 1.0f || speed() != -1.0f) {
+ seek ((nframes_t) (location * (double) speed()));
+ } else {
+ seek (location);
+ }
+}
+
void
AudioDiskstream::get_input_sources ()
{
uint32_t n;
ChannelList::iterator chan;
uint32_t ni = _io->n_inputs().n_audio();
+ vector<string> connections;
for (n = 0, chan = c->begin(); chan != c->end() && n < ni; ++chan, ++n) {
- const char **connections = _io->input(n)->get_connections ();
+ connections.clear ();
+
+ if (_io->input(n)->get_connections (connections) == 0) {
- if (connections == 0 || connections[0] == 0) {
-
if ((*chan)->source) {
// _source->disable_metering ();
}
(*chan)->source = 0;
} else {
- (*chan)->source = dynamic_cast<AudioPort*>(
- _session.engine().get_port_by_name (connections[0]) );
- }
-
- if (connections) {
- free (connections);
+ (*chan)->source = dynamic_cast<AudioPort*>(_session.engine().get_port_by_name (connections[0]) );
}
}
}
{
string newname;
boost::shared_ptr<AudioPlaylist> playlist;
-
+
if (!in_set_state && destructive()) {
return 0;
}
/* if per-track or global rec-enable turned on while the other was already on, we've started recording */
- if ((change & track_rec_enabled) && record_enabled() && (!(change & global_rec_enabled) && can_record) ||
+ if (((change & track_rec_enabled) && record_enabled() && (!(change & global_rec_enabled) && can_record)) ||
((change & global_rec_enabled) && can_record && (!(change & track_rec_enabled) && record_enabled()))) {
/* starting to record: compute first+last frames */
commit_should_unlock = false;
+ if (!_io || !_io->active()) {
+ _processed = true;
+ return 0;
+ }
+
check_record_status (transport_frame, nframes, can_record);
nominally_recording = (can_record && re);
AudioPort* const ap = _io->audio_input(n);
assert(ap);
- assert(rec_nframes <= ap->get_audio_buffer().capacity());
- memcpy (chaninfo->current_capture_buffer, ap->get_audio_buffer().data(rec_nframes, offset + rec_offset), sizeof (Sample) * rec_nframes);
+ assert(rec_nframes <= ap->get_audio_buffer( nframes, offset ).capacity());
+ memcpy (chaninfo->current_capture_buffer, ap->get_audio_buffer( nframes, offset ).data(rec_nframes, offset + rec_offset), sizeof (Sample) * rec_nframes);
} else {
AudioPort* const ap = _io->audio_input(n);
assert(ap);
- Sample* buf = ap->get_audio_buffer().data(nframes, offset);
+ Sample* buf = ap->get_audio_buffer( nframes, offset ).data(nframes, offset);
nframes_t first = chaninfo->capture_vector.len[0];
memcpy (chaninfo->capture_wrap_buffer, buf, sizeof (Sample) * first);
nframes_t total = chaninfo->playback_vector.len[0] + chaninfo->playback_vector.len[1];
if (necessary_samples > total) {
+ cerr << "underrun for " << _name << endl;
DiskUnderrun ();
goto out;
if (rec_nframes == 0 && _actual_speed != 1.0f && _actual_speed != -1.0f) {
uint64_t phase = last_phase;
+ int64_t phi_delta;
nframes_t i = 0;
// Linearly interpolate into the alt buffer
// using 40.24 fixp maths (swh)
+ if (phi != target_phi) {
+ phi_delta = ((int64_t)(target_phi - phi)) / nframes;
+ } else {
+ phi_delta = 0;
+ }
+
for (chan = c->begin(); chan != c->end(); ++chan) {
float fr;
chaninfo->speed_buffer[outsample] =
chaninfo->current_playback_buffer[i] * (1.0f - fr) +
chaninfo->current_playback_buffer[i+1] * fr;
- phase += phi;
+ phase += phi + phi_delta;
}
chaninfo->current_playback_buffer = chaninfo->speed_buffer;
}
- playback_distance = i + 1;
+ playback_distance = i; // + 1;
last_phase = (phase & 0xFFFFFF);
} else {
playback_distance = nframes;
}
+ phi = target_phi;
+
}
ret = 0;
{
bool need_butler = false;
+ if (!_io || !_io->active()) {
+ return false;
+ }
+
if (_actual_speed < 0.0) {
playback_sample -= playback_distance;
} else {
}
if (_slaved) {
- need_butler = c->front()->playback_buf->write_space() >= c->front()->playback_buf->bufsize() / 2;
+ if (_io && _io->active()) {
+ need_butler = c->front()->playback_buf->write_space() >= c->front()->playback_buf->bufsize() / 2;
+ } else {
+ need_butler = false;
+ }
} else {
- need_butler = c->front()->playback_buf->write_space() >= disk_io_chunk_frames
- || c->front()->capture_buf->read_space() >= disk_io_chunk_frames;
+ if (_io && _io->active()) {
+ need_butler = c->front()->playback_buf->write_space() >= disk_io_chunk_frames
+ || c->front()->capture_buf->read_space() >= disk_io_chunk_frames;
+ } else {
+ need_butler = c->front()->capture_buf->read_space() >= disk_io_chunk_frames;
+ }
}
if (commit_should_unlock) {
s->update_header (capture_info.front()->start, when, twhen);
s->set_captured_for (_name);
s->mark_immutable ();
+ if (Config->get_auto_analyse_audio()) {
+ Analyser::queue_source_for_analysis (s, true);
+ }
}
}
capture_info.push_back (ci);
capture_captured = 0;
+
+ /* now we've finished a capture, reset first_recordable_frame for next time */
+ first_recordable_frame = max_frames;
}
void
{
g_atomic_int_set (&_record_enabled, 0);
boost::shared_ptr<ChannelList> c = channels.reader();
- for (ChannelList::iterator chan = c->begin(); chan != c->end(); ++chan) {
- if (Config->get_monitoring_model() == HardwareMonitoring) {
+ if (Config->get_monitoring_model() == HardwareMonitoring) {
+ for (ChannelList::iterator chan = c->begin(); chan != c->end(); ++chan) {
if ((*chan)->source) {
(*chan)->source->ensure_monitor_input (false);
}
if (nchans > _n_channels.n_audio()) {
add_channel (nchans - _n_channels.n_audio());
+ IO::PortCountChanged(_n_channels);
} else if (nchans < _n_channels.n_audio()) {
up of the IO that owns this DS (::non_realtime_input_change())
*/
- in_set_state = false;
-
return 0;
}
AudioDiskstream::add_channel_to (boost::shared_ptr<ChannelList> c, uint32_t how_many)
{
while (how_many--) {
- c->push_back (new ChannelInfo(_session.diskstream_buffer_size(), speed_buffer_size, wrap_buffer_size));
+ c->push_back (new ChannelInfo(_session.audio_diskstream_buffer_size(), speed_buffer_size, wrap_buffer_size));
}
_n_channels.set(DataType::AUDIO, c->size());
int
AudioDiskstream::remove_channel_from (boost::shared_ptr<ChannelList> c, uint32_t how_many)
{
- while (--how_many && !c->empty()) {
+ while (how_many-- && !c->empty()) {
delete c->back();
c->pop_back();
}
write_source.reset ();
}
- if (speed_buffer) {
- delete [] speed_buffer;
- speed_buffer = 0;
- }
+ delete [] speed_buffer;
+ speed_buffer = 0;
- if (playback_wrap_buffer) {
- delete [] playback_wrap_buffer;
- playback_wrap_buffer = 0;
- }
+ delete [] playback_wrap_buffer;
+ playback_wrap_buffer = 0;
- if (capture_wrap_buffer) {
- delete [] capture_wrap_buffer;
- capture_wrap_buffer = 0;
- }
+ delete [] capture_wrap_buffer;
+ capture_wrap_buffer = 0;
- if (playback_buf) {
- delete playback_buf;
- playback_buf = 0;
- }
+ delete playback_buf;
+ playback_buf = 0;
- if (capture_buf) {
- delete capture_buf;
- capture_buf = 0;
- }
+ delete capture_buf;
+ capture_buf = 0;
- if (capture_transition_buf) {
- delete capture_transition_buf;
- capture_transition_buf = 0;
- }
+ delete capture_transition_buf;
+ capture_transition_buf = 0;
}