mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-10 16:46:35 +01:00
NO-OP: return early, remove scope
This commit is contained in:
parent
3ce2cf937e
commit
576840c09e
1 changed files with 71 additions and 71 deletions
|
|
@ -267,98 +267,98 @@ MidiPort::resolve_notes (void* port_buffer, MidiBuffer::TimeType when)
|
||||||
void
|
void
|
||||||
MidiPort::flush_buffers (pframes_t nframes)
|
MidiPort::flush_buffers (pframes_t nframes)
|
||||||
{
|
{
|
||||||
if (sends_output ()) {
|
if (!sends_output ()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
void* port_buffer = 0;
|
void* port_buffer = 0;
|
||||||
|
|
||||||
if (_resolve_required) {
|
if (_resolve_required) {
|
||||||
port_buffer = port_engine.get_buffer (_port_handle, nframes);
|
port_buffer = port_engine.get_buffer (_port_handle, nframes);
|
||||||
/* resolve all notes at the start of the buffer */
|
/* resolve all notes at the start of the buffer */
|
||||||
resolve_notes (port_buffer, _global_port_buffer_offset);
|
resolve_notes (port_buffer, _global_port_buffer_offset);
|
||||||
_resolve_required = false;
|
_resolve_required = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_buffer->empty()) {
|
if (_buffer->empty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!port_buffer) {
|
if (!port_buffer) {
|
||||||
port_buffer = port_engine.get_buffer (_port_handle, nframes);
|
port_buffer = port_engine.get_buffer (_port_handle, nframes);
|
||||||
}
|
}
|
||||||
|
|
||||||
double speed_ratio = (flags () & TransportGenerator) ? 1.0 : resample_ratio ();
|
double speed_ratio = (flags () & TransportGenerator) ? 1.0 : resample_ratio ();
|
||||||
|
|
||||||
for (MidiBuffer::iterator i = _buffer->begin(); i != _buffer->end(); ++i) {
|
std::shared_ptr<MIDI::Parser> trace_parser = _trace_parser.lock ();
|
||||||
|
|
||||||
const Evoral::Event<MidiBuffer::TimeType> ev (*i, false);
|
for (MidiBuffer::iterator i = _buffer->begin(); i != _buffer->end(); ++i) {
|
||||||
|
|
||||||
const samplepos_t adjusted_time = ev.time() + _global_port_buffer_offset;
|
const Evoral::Event<MidiBuffer::TimeType> ev (*i, false);
|
||||||
|
|
||||||
if (sends_output()) {
|
/* event times are in samples, relative to cycle start */
|
||||||
std::shared_ptr<MIDI::Parser> trace_parser = _trace_parser.lock ();
|
const samplepos_t adjusted_time = ev.time() + _global_port_buffer_offset;
|
||||||
if (trace_parser) {
|
|
||||||
uint8_t const * const buf = ev.buffer();
|
|
||||||
const samplepos_t now = AudioEngine::instance()->sample_time_at_cycle_start();
|
|
||||||
|
|
||||||
trace_parser->set_timestamp (now + adjusted_time / speed_ratio);
|
/* MIDI Tracer */
|
||||||
|
if (trace_parser) {
|
||||||
|
uint8_t const * const buf = ev.buffer();
|
||||||
|
const samplepos_t now = AudioEngine::instance()->sample_time_at_cycle_start();
|
||||||
|
|
||||||
uint32_t limit = ev.size();
|
trace_parser->set_timestamp (now + adjusted_time / speed_ratio);
|
||||||
|
|
||||||
for (size_t n = 0; n < limit; ++n) {
|
uint32_t limit = ev.size();
|
||||||
trace_parser->scanner (buf[n]);
|
|
||||||
}
|
for (size_t n = 0; n < limit; ++n) {
|
||||||
}
|
trace_parser->scanner (buf[n]);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// event times are in samples, relative to cycle start
|
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
if (DEBUG_ENABLED (DEBUG::MidiIO)) {
|
if (DEBUG_ENABLED (DEBUG::MidiIO)) {
|
||||||
const Session* s = AudioEngine::instance()->session();
|
const Session* s = AudioEngine::instance()->session();
|
||||||
const samplepos_t now = (s ? s->transport_sample() : 0);
|
const samplepos_t now = (s ? s->transport_sample() : 0);
|
||||||
DEBUG_STR_DECL(a);
|
DEBUG_STR_DECL(a);
|
||||||
DEBUG_STR_APPEND(a, string_compose ("MidiPort %7 %1 pop event @ %2[%7] (global %4, within %5 gpbo %6 sz %3 ", _buffer, adjusted_time, ev.size(),
|
DEBUG_STR_APPEND(a, string_compose ("MidiPort %7 %1 pop event @ %2[%7] (global %4, within %5 gpbo %6 sz %3 ", _buffer, adjusted_time, ev.size(),
|
||||||
now + adjusted_time, nframes, _global_port_buffer_offset, name(), ev.time()));
|
now + adjusted_time, nframes, _global_port_buffer_offset, name(), ev.time()));
|
||||||
for (size_t i=0; i < ev.size(); ++i) {
|
for (size_t i=0; i < ev.size(); ++i) {
|
||||||
DEBUG_STR_APPEND(a,hex);
|
DEBUG_STR_APPEND(a,hex);
|
||||||
DEBUG_STR_APPEND(a,"0x");
|
DEBUG_STR_APPEND(a,"0x");
|
||||||
DEBUG_STR_APPEND(a,(int)(ev.buffer()[i]));
|
DEBUG_STR_APPEND(a,(int)(ev.buffer()[i]));
|
||||||
DEBUG_STR_APPEND(a,' ');
|
DEBUG_STR_APPEND(a,' ');
|
||||||
}
|
|
||||||
DEBUG_STR_APPEND(a,'\n');
|
|
||||||
DEBUG_TRACE (DEBUG::MidiIO, DEBUG_STR(a).str());
|
|
||||||
}
|
}
|
||||||
|
DEBUG_STR_APPEND(a,'\n');
|
||||||
|
DEBUG_TRACE (DEBUG::MidiIO, DEBUG_STR(a).str());
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// XXX consider removing this check for optimized builds
|
// XXX consider removing this check for optimized builds
|
||||||
// and just send 'em all, at cycle_end
|
// and just send 'em all, at cycle_end
|
||||||
// see AudioEngine::split_cycle (), PortManager::cycle_end()
|
// see AudioEngine::split_cycle (), PortManager::cycle_end()
|
||||||
if ((adjusted_time >= _global_port_buffer_offset) && (adjusted_time < _global_port_buffer_offset + nframes)) {
|
if ((adjusted_time >= _global_port_buffer_offset) && (adjusted_time < _global_port_buffer_offset + nframes)) {
|
||||||
pframes_t tme = floor (adjusted_time / speed_ratio);
|
pframes_t tme = floor (adjusted_time / speed_ratio);
|
||||||
if (port_engine.midi_event_put (port_buffer, tme, ev.buffer(), ev.size()) != 0) {
|
if (port_engine.midi_event_put (port_buffer, tme, ev.buffer(), ev.size()) != 0) {
|
||||||
cerr << "write failed, dropped event, time " << adjusted_time << '/' << ev.time() << endl;
|
cerr << "write failed, dropped event, time " << adjusted_time << '/' << ev.time() << endl;
|
||||||
}
|
|
||||||
} else {
|
|
||||||
pframes_t tme = floor (adjusted_time / speed_ratio);
|
|
||||||
cerr << "Dropped outgoing MIDI event. time " << adjusted_time
|
|
||||||
<< " (" << ev.time() << ") @" << speed_ratio << " = " << tme
|
|
||||||
<< " out of range [" << _global_port_buffer_offset
|
|
||||||
<< " .. " << _global_port_buffer_offset + nframes
|
|
||||||
<< "]";
|
|
||||||
for (size_t xx = 0; xx < ev.size(); ++xx) {
|
|
||||||
cerr << ' ' << hex << (int) ev.buffer()[xx];
|
|
||||||
}
|
|
||||||
cerr << dec << endl;
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
pframes_t tme = floor (adjusted_time / speed_ratio);
|
||||||
|
cerr << "Dropped outgoing MIDI event. time " << adjusted_time
|
||||||
|
<< " (" << ev.time() << ") @" << speed_ratio << " = " << tme
|
||||||
|
<< " out of range [" << _global_port_buffer_offset
|
||||||
|
<< " .. " << _global_port_buffer_offset + nframes
|
||||||
|
<< "]";
|
||||||
|
for (size_t xx = 0; xx < ev.size(); ++xx) {
|
||||||
|
cerr << ' ' << hex << (int) ev.buffer()[xx];
|
||||||
|
}
|
||||||
|
cerr << dec << endl;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* done.. the data has moved to the port buffer, mark it so,
|
/* done.. the data has moved to the port buffer, mark it so,
|
||||||
* unless we're exporting in which PortExportMIDI::read
|
* unless we're exporting in which PortExportMIDI::read
|
||||||
* needs to read it at the end of a process cycle.
|
* needs to read it at the end of a process cycle.
|
||||||
*/
|
*/
|
||||||
if (!AudioEngine::instance()->session()->exporting ()) {
|
if (!AudioEngine::instance()->session()->exporting ()) {
|
||||||
_buffer->clear ();
|
_buffer->clear ();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue