using namespace ARDOUR;
using namespace PBD;
-nframes_t MidiDiskstream::midi_readahead = 4096;
+framecnt_t MidiDiskstream::midi_readahead = 4096;
MidiDiskstream::MidiDiskstream (Session &sess, const string &name, Diskstream::Flag flag)
: Diskstream(sess, name, flag)
allocate_temporary_buffers ();
const size_t size = _session.butler()->midi_diskstream_buffer_size();
- _playback_buf = new MidiRingBuffer<nframes_t>(size);
- _capture_buf = new MidiRingBuffer<nframes_t>(size);
+ _playback_buf = new MidiRingBuffer<framepos_t>(size);
+ _capture_buf = new MidiRingBuffer<framepos_t>(size);
_n_channels = ChanCount(DataType::MIDI, 1);
#endif
int
-MidiDiskstream::process (framepos_t transport_frame, nframes_t nframes, bool can_record, bool rec_monitors_input, bool& need_butler)
+MidiDiskstream::process (framepos_t transport_frame, pframes_t nframes, bool can_record, bool rec_monitors_input, bool& need_butler)
{
int ret = -1;
- nframes_t rec_offset = 0;
- nframes_t rec_nframes = 0;
+ framecnt_t rec_offset = 0;
+ framecnt_t rec_nframes = 0;
bool nominally_recording;
bool re = record_enabled ();
playback_distance = 0;
- check_record_status (transport_frame, nframes, can_record);
+ check_record_status (transport_frame, can_record);
nominally_recording = (can_record && re);
_capture_buf->write(ev.time() + transport_frame, ev.type(), ev.size(), ev.buffer());
}
+ if (buf.size() != 0) {
+ /* Make a copy of this data and emit it for the GUI to see */
+ boost::shared_ptr<MidiBuffer> copy (new MidiBuffer (buf.capacity ()));
+ for (MidiBuffer::iterator i = buf.begin(); i != buf.end(); ++i) {
+ copy->push_back ((*i).time() + transport_frame, (*i).size(), (*i).buffer());
+ }
+
+ DataRecorded (copy, _write_source); /* EMIT SIGNAL */
+ }
+
} else {
if (was_recording) {
}
bool
-MidiDiskstream::commit (nframes_t nframes)
+MidiDiskstream::commit (framecnt_t nframes)
{
bool need_butler = false;
int
MidiDiskstream::overwrite_existing_buffers ()
{
+ /* This is safe as long as the butler thread is suspended, which it should be */
+ _playback_buf->reset ();
+
+ g_atomic_int_set (&_frames_read_from_ringbuffer, 0);
+ g_atomic_int_set (&_frames_written_to_ringbuffer, 0);
+
read (overwrite_frame, disk_io_chunk_frames, false);
overwrite_queued = false;
_pending_overwrite = false;
/** @a start is set to the new frame position (TIME) read up to */
int
-MidiDiskstream::read (framepos_t& start, nframes_t dur, bool reversed)
+MidiDiskstream::read (framepos_t& start, framecnt_t dur, bool reversed)
{
- nframes_t this_read = 0;
+ framecnt_t this_read = 0;
bool reloop = false;
framepos_t loop_end = 0;
framepos_t loop_start = 0;
return 0;
}
- nframes_t to_read = midi_readahead - (frames_written - frames_read);
+ framecnt_t to_read = midi_readahead - (frames_written - frames_read);
//cout << "MDS read for midi_readahead " << to_read << " rb_contains: "
// << frames_written - frames_read << endl;
- to_read = (nframes_t) min ((framecnt_t) to_read, (framecnt_t) (max_framepos - file_frame));
+ to_read = (framecnt_t) min ((framecnt_t) to_read, (framecnt_t) (max_framepos - file_frame));
if (read (file_frame, to_read, reversed)) {
ret = -1;
{
uint32_t to_write;
int32_t ret = 0;
- nframes_t total;
+ framecnt_t total;
_write_data_count = 0;
total = _session.transport_frame() - _last_flush_frame;
- if (_last_flush_frame > _session.transport_frame()
- || _last_flush_frame < capture_start_frame) {
+ if (_last_flush_frame > _session.transport_frame() || _last_flush_frame < capture_start_frame) {
_last_flush_frame = _session.transport_frame();
}
if (record_enabled() &&
((_session.transport_frame() - _last_flush_frame > disk_io_chunk_frames) ||
force_flush)) {
- if ((!_write_source) || _write_source->midi_write (*_capture_buf, capture_start_frame, to_write) != to_write) {
+ if ((!_write_source) || _write_source->midi_write (*_capture_buf, get_capture_start_frame (0), to_write) != to_write) {
error << string_compose(_("MidiDiskstream %1: cannot write to disk"), _id) << endmsg;
return -1;
} else {
assert(_write_source);
- nframes_t total_capture = 0;
+ framecnt_t total_capture = 0;
for (ci = capture_info.begin(); ci != capture_info.end(); ++ci) {
total_capture += (*ci)->frames;
}
_playlist->clear_changes ();
_playlist->freeze ();
- uint32_t buffer_position = 0;
- for (buffer_position = 0, ci = capture_info.begin(); ci != capture_info.end(); ++ci) {
+ /* Session frame time of the initial capture in this pass, which is where the source starts */
+ framepos_t initial_capture = 0;
+ if (!capture_info.empty()) {
+ initial_capture = capture_info.front()->start;
+ }
+
+ for (ci = capture_info.begin(); ci != capture_info.end(); ++ci) {
string region_name;
try {
PropertyList plist;
-
- plist.add (Properties::start, buffer_position);
+
+ /* start of this region is the offset between the start of its capture and the start of the whole pass */
+ plist.add (Properties::start, (*ci)->start - initial_capture);
plist.add (Properties::length, (*ci)->frames);
plist.add (Properties::name, region_name);
i_am_the_modifier++;
_playlist->add_region (region, (*ci)->start);
i_am_the_modifier--;
-
- buffer_position += (*ci)->frames;
}
_playlist->thaw ();
void
MidiDiskstream::engage_record_enable ()
{
- bool rolling = _session.transport_speed() != 0.0f;
+ bool const rolling = _session.transport_speed() != 0.0f;
g_atomic_int_set (&_record_enabled, 1);
_source_port->request_monitor_input (!(_session.config.get_auto_input() && rolling));
}
- _write_source->mark_streaming_midi_write_started (_note_mode, _session.transport_frame());
-
RecordEnableChanged (); /* EMIT SIGNAL */
}
}
void
-MidiDiskstream::set_block_size (nframes_t /*nframes*/)
+MidiDiskstream::set_block_size (pframes_t /*nframes*/)
{
}