Fix MIDI playback.

git-svn-id: svn://localhost/ardour2/trunk@2905 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
David Robillard 2008-01-13 00:27:13 +00:00
parent e92c1669c1
commit c78c44ccd7
4 changed files with 26 additions and 24 deletions

View file

@ -34,6 +34,7 @@ class MidiPort : public BaseMidiPort, public PortFacade {
void reset (); void reset ();
void cycle_start (nframes_t nframes, nframes_t offset); void cycle_start (nframes_t nframes, nframes_t offset);
void cycle_end (nframes_t nframes, nframes_t offset);
protected: protected:
friend class AudioEngine; friend class AudioEngine;

View file

@ -337,11 +337,6 @@ AudioEngine::process_callback (nframes_t nframes)
if (session) { if (session) {
session->process (nframes); session->process (nframes);
} }
if (!_running) {
_processed_frames = next_processed_frames;
return 0;
}
// Finalize ports (ie write data if necessary) // Finalize ports (ie write data if necessary)
@ -349,6 +344,11 @@ AudioEngine::process_callback (nframes_t nframes)
(*i)->cycle_end (nframes, 0); (*i)->cycle_end (nframes, 0);
} }
if (!_running) {
_processed_frames = next_processed_frames;
return 0;
}
if (last_monitor_check + monitor_check_interval < next_processed_frames) { if (last_monitor_check + monitor_check_interval < next_processed_frames) {
boost::shared_ptr<Ports> p = ports.reader(); boost::shared_ptr<Ports> p = ports.reader();

View file

@ -25,31 +25,22 @@ JackMidiPort::JackMidiPort (const std::string& name, Flags flgs, MidiBuffer* buf
, JackPort (name, DataType::MIDI, flgs) , JackPort (name, DataType::MIDI, flgs)
, BaseMidiPort (name, flgs) , BaseMidiPort (name, flgs)
{ {
if (buf) { // MIDI ports always need a buffer since jack buffer format is different
assert(buf);
cout << name << " BUFFER" << endl; _buffer = buf;
_own_buffer = false;
_buffer = buf;
_own_buffer = false;
} else {
cout << name << " NO BUFFER" << endl;
/* data space will be provided by JACK */
_buffer = new MidiBuffer (0);
_own_buffer = true;
}
} }
void void
JackMidiPort::cycle_start (nframes_t nframes, nframes_t offset_ignored_but_probably_should_not_be) JackMidiPort::cycle_start (nframes_t nframes, nframes_t offset)
{ {
/* FIXME: offset */
_buffer->clear(); _buffer->clear();
assert(_buffer->size() == 0); assert(_buffer->size() == 0);
if (_flags & IsOutput) { if (_flags & IsOutput) {
// no buffer, nothing to do
return; return;
} }
@ -76,8 +67,10 @@ JackMidiPort::cycle_start (nframes_t nframes, nframes_t offset_ignored_but_proba
} }
void void
JackMidiPort::cycle_end (nframes_t nframes, nframes_t offset_ignored_but_probably_should_not_be) JackMidiPort::cycle_end (nframes_t nframes, nframes_t offset)
{ {
/* FIXME: offset */
if (_flags & IsInput) { if (_flags & IsInput) {
return; return;
} }

View file

@ -67,8 +67,6 @@ MidiPort::reset()
void void
MidiPort::cycle_start (nframes_t nframes, nframes_t offset) MidiPort::cycle_start (nframes_t nframes, nframes_t offset)
{ {
/* caller must hold process lock */
if (_ext_port) { if (_ext_port) {
_ext_port->cycle_start (nframes, offset); _ext_port->cycle_start (nframes, offset);
} }
@ -99,3 +97,13 @@ MidiPort::cycle_start (nframes_t nframes, nframes_t offset)
_buffer->silence (nframes, offset); _buffer->silence (nframes, offset);
} }
} }
void
MidiPort::cycle_end (nframes_t nframes, nframes_t offset)
{
if (_ext_port) {
_ext_port->cycle_end (nframes, offset);
}
}