#include <fcntl.h>
#include <cstdlib>
#include <ctime>
+#include <strings.h> // for ffs(3)
#include <sys/stat.h>
#include <sys/mman.h>
seek (_session.transport_frame());
}
- g_atomic_int_set(&_frames_pending_write, 0);
- g_atomic_int_set(&_num_captured_loops, 0);
+ g_atomic_int_set(const_cast<gint*> (&_frames_pending_write), 0);
+ g_atomic_int_set(const_cast<gint*> (&_num_captured_loops), 0);
}
int
}
int
-MidiDiskstream::process (framepos_t transport_frame, pframes_t nframes, framecnt_t& playback_distance)
+MidiDiskstream::process (BufferSet& bufs, framepos_t transport_frame, pframes_t nframes, framecnt_t& playback_distance, bool need_disk_signal)
{
framecnt_t rec_offset = 0;
framecnt_t rec_nframes = 0;
}
_write_source->mark_write_starting_now(
capture_start_frame, capture_captured, loop_length);
- g_atomic_int_set(&_frames_pending_write, 0);
- g_atomic_int_set(&_num_captured_loops, 0);
+ g_atomic_int_set(const_cast<gint*> (&_frames_pending_write), 0);
+ g_atomic_int_set(const_cast<gint*> (&_num_captured_loops), 0);
was_recording = true;
}
}
// Pump entire port buffer into the ring buffer (FIXME: split cycles?)
MidiBuffer& buf = sp->get_midi_buffer(nframes);
+ ChannelMode mode = AllChannels; // _track->get_capture_channel_mode ();
+ uint32_t mask = 0xffff; // _track->get_capture_channel_mask ();
+
for (MidiBuffer::iterator i = buf.begin(); i != buf.end(); ++i) {
- const Evoral::MIDIEvent<MidiBuffer::TimeType> ev(*i, false);
+ Evoral::MIDIEvent<MidiBuffer::TimeType> ev(*i, false);
#ifndef NDEBUG
if (DEBUG::MidiIO & PBD::debug_bits) {
const uint8_t* __data = ev.buffer();
probabl be implemented in the source instead of here.
*/
const framecnt_t loop_offset = _num_captured_loops * loop_length;
- _capture_buf->write(transport_frame + loop_offset + ev.time(),
- ev.type(), ev.size(), ev.buffer());
+
+ switch (mode) {
+ case AllChannels:
+ _capture_buf->write(transport_frame + loop_offset + ev.time(),
+ ev.type(), ev.size(), ev.buffer());
+ break;
+ case FilterChannels:
+ if (ev.is_channel_event()) {
+ if ((1<<ev.channel()) & mask) {
+ _capture_buf->write(transport_frame + loop_offset + ev.time(),
+ ev.type(), ev.size(), ev.buffer());
+ }
+ } else {
+ _capture_buf->write(transport_frame + loop_offset + ev.time(),
+ ev.type(), ev.size(), ev.buffer());
+ }
+ break;
+ case ForceChannel:
+ if (ev.is_channel_event()) {
+ ev.set_channel (ffs(mask) - 1);
+ }
+ _capture_buf->write(transport_frame + loop_offset + ev.time(),
+ ev.type(), ev.size(), ev.buffer());
+ break;
+ }
}
- g_atomic_int_add(&_frames_pending_write, nframes);
+ g_atomic_int_add(const_cast<gint*>(&_frames_pending_write), nframes);
if (buf.size() != 0) {
Glib::Threads::Mutex::Lock lm (_gui_feed_buffer_mutex, Glib::Threads::TRY_LOCK);
}
+ if (need_disk_signal) {
+ /* copy the diskstream data to all output buffers */
+
+ MidiBuffer& mbuf (bufs.get_midi (0));
+ get_playback (mbuf, nframes);
+
+ /* leave the audio count alone */
+ ChanCount cnt (DataType::MIDI, 1);
+ cnt.set (DataType::AUDIO, bufs.count().n_audio());
+ bufs.set_count (cnt);
+ }
+
return 0;
}
+frameoffset_t
+MidiDiskstream::calculate_playback_distance (pframes_t nframes)
+{
+ frameoffset_t playback_distance = nframes;
+
+ /* XXX: should be doing varispeed stuff once it's implemented in ::process() above */
+
+ if (_actual_speed < 0.0) {
+ return -playback_distance;
+ } else {
+ return playback_distance;
+ }
+}
+
bool
MidiDiskstream::commit (framecnt_t playback_distance)
{
return 0;
}
- const framecnt_t total = g_atomic_int_get(&_frames_pending_write);
+ const framecnt_t total = g_atomic_int_get(const_cast<gint*> (&_frames_pending_write));
if (total == 0 ||
_capture_buf->read_space() == 0 ||
}
/* if there are 2+ chunks of disk i/o possible for
- this track, let the caller know so that it can arrange
+ this track), let the caller know so that it can arrange
for us to be called again, ASAP.
if we are forcing a flush, then if there is* any* extra
error << string_compose(_("MidiDiskstream %1: cannot write to disk"), id()) << endmsg;
return -1;
}
- g_atomic_int_add(&_frames_pending_write, -to_write);
+ g_atomic_int_add(const_cast<gint*> (&_frames_pending_write), -to_write);
}
out:
the Source and/or entirely after the capture is finished.
*/
if (was_recording) {
- g_atomic_int_add(&_num_captured_loops, 1);
+ g_atomic_int_add(const_cast<gint*> (&_num_captured_loops), 1);
}
}
boost::shared_ptr<MidiPort> sp = _source_port.lock ();
if (sp && Config->get_monitoring_model() == HardwareMonitoring) {
- sp->request_jack_monitors_input (!(_session.config.get_auto_input() && rolling));
+ sp->request_input_monitoring (!(_session.config.get_auto_input() && rolling));
}
return true;
char buf[64];
LocaleGuard lg (X_("POSIX"));
- node.add_property("channel-mode", enum_2_string(get_channel_mode()));
- snprintf (buf, sizeof(buf), "0x%x", get_channel_mask());
- node.add_property("channel-mask", buf);
-
if (_write_source && _session.get_record_enabled()) {
XMLNode* cs_child = new XMLNode (X_("CapturingSources"));
int
MidiDiskstream::set_state (const XMLNode& node, int version)
{
- const XMLProperty* prop;
XMLNodeList nlist = node.children();
XMLNodeIterator niter;
XMLNode* capture_pending_node = 0;
return -1;
}
- ChannelMode channel_mode = AllChannels;
- if ((prop = node.property ("channel-mode")) != 0) {
- channel_mode = ChannelMode (string_2_enum(prop->value(), channel_mode));
- }
-
- unsigned int channel_mask = 0xFFFF;
- if ((prop = node.property ("channel-mask")) != 0) {
- sscanf (prop->value().c_str(), "0x%x", &channel_mask);
- if (channel_mask & (~0xFFFF)) {
- warning << _("MidiDiskstream: XML property channel-mask out of range") << endmsg;
- }
- }
-
-
if (capture_pending_node) {
use_pending_capture_data (*capture_pending_node);
}
- set_channel_mode (channel_mode, channel_mask);
-
in_set_state = false;
return 0;
}
void
-MidiDiskstream::ensure_jack_monitors_input (bool yn)
+MidiDiskstream::ensure_input_monitoring (bool yn)
{
boost::shared_ptr<MidiPort> sp = _source_port.lock ();
if (sp) {
- sp->ensure_jack_monitors_input (yn);
+ sp->ensure_input_monitoring (yn);
}
}