Extract freewheel processing in PortAudioBackend into new method
This commit is contained in:
parent
cf81caa798
commit
f27d8e1e23
@ -1574,29 +1574,10 @@ PortAudioBackend::main_blocking_process_thread ()
|
||||
}
|
||||
|
||||
} else {
|
||||
// Freewheelin'
|
||||
|
||||
// zero audio input buffers
|
||||
for (std::vector<PamPort*>::const_iterator it = _system_inputs.begin (); it != _system_inputs.end (); ++it) {
|
||||
memset ((*it)->get_buffer (_samples_per_period), 0, _samples_per_period * sizeof (Sample));
|
||||
}
|
||||
|
||||
// TODO clear midi or stop midi recv when entering fwheelin'
|
||||
|
||||
if (engine.process_callback (_samples_per_period)) {
|
||||
_pcmio->close_stream();
|
||||
_active = false;
|
||||
if (!blocking_process_freewheel()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// drop all outgoing MIDI messages
|
||||
for (std::vector<PamPort*>::const_iterator it = _system_midi_out.begin (); it != _system_midi_out.end (); ++it) {
|
||||
void *bptr = (*it)->get_buffer(0);
|
||||
midi_clear(bptr);
|
||||
}
|
||||
|
||||
_dsp_load = 1.0;
|
||||
Glib::usleep (100); // don't hog cpu
|
||||
}
|
||||
|
||||
process_port_connection_changes();
|
||||
@ -1614,6 +1595,39 @@ PortAudioBackend::main_blocking_process_thread ()
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool
|
||||
PortAudioBackend::blocking_process_freewheel ()
|
||||
{
|
||||
// zero audio input buffers
|
||||
for (std::vector<PamPort*>::const_iterator it = _system_inputs.begin();
|
||||
it != _system_inputs.end();
|
||||
++it) {
|
||||
memset((*it)->get_buffer(_samples_per_period),
|
||||
0,
|
||||
_samples_per_period * sizeof(Sample));
|
||||
}
|
||||
|
||||
// TODO clear midi or stop midi recv when entering fwheelin'
|
||||
|
||||
if (engine.process_callback(_samples_per_period)) {
|
||||
_pcmio->close_stream();
|
||||
_active = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
// drop all outgoing MIDI messages
|
||||
for (std::vector<PamPort*>::const_iterator it = _system_midi_out.begin();
|
||||
it != _system_midi_out.end();
|
||||
++it) {
|
||||
void* bptr = (*it)->get_buffer(0);
|
||||
midi_clear(bptr);
|
||||
}
|
||||
|
||||
_dsp_load = 1.0;
|
||||
Glib::usleep(100); // don't hog cpu
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
PortAudioBackend::process_port_connection_changes ()
|
||||
{
|
||||
|
@ -322,9 +322,11 @@ class PortAudioBackend : public AudioBackend {
|
||||
private: // Methods
|
||||
bool start_blocking_process_thread ();
|
||||
bool stop_blocking_process_thread ();
|
||||
bool blocking_process_freewheel ();
|
||||
|
||||
void process_port_connection_changes ();
|
||||
|
||||
|
||||
private:
|
||||
std::string _instance_name;
|
||||
PortAudioIO *_pcmio;
|
||||
|
Loading…
Reference in New Issue
Block a user