aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/engine/JackDriver.cpp22
-rw-r--r--src/engine/SMFWriter.cpp2
2 files changed, 11 insertions, 13 deletions
diff --git a/src/engine/JackDriver.cpp b/src/engine/JackDriver.cpp
index 8eada7c..2bf24de 100644
--- a/src/engine/JackDriver.cpp
+++ b/src/engine/JackDriver.cpp
@@ -111,6 +111,11 @@ JackDriver::attach(const std::string& client_name)
void
JackDriver::detach()
{
+ if (_is_activated) {
+ _is_activated = false;
+ _stop.timed_wait(1000);
+ }
+
if (_input_port) {
jack_port_unregister(jack_client(), _input_port);
_input_port = NULL;
@@ -294,14 +299,15 @@ JackDriver::write_event(Raul::TimeStamp time,
void
JackDriver::on_process(jack_nframes_t nframes)
{
+ if (!_is_activated) {
+ _stop.post();
+ return;
+ }
+
_context.time().set_bpm(_bpm.get());
assert(_output_port);
-#ifdef JACK_MIDI_NEEDS_NFRAMES
- jack_midi_clear_buffer(jack_port_get_buffer(_output_port, nframes), nframes);
-#else
jack_midi_clear_buffer(jack_port_get_buffer(_output_port, nframes));
-#endif
TimeStamp length_ticks(TimeStamp(_context.time().ticks_unit(), nframes));
TimeStamp length_beats(_context.time().ticks_to_beats(length_ticks));
@@ -325,7 +331,7 @@ JackDriver::on_process(jack_nframes_t nframes)
if (!machine) {
_last_machine = machine;
- return;
+ goto end;
}
if (_stop_flag) {
@@ -455,11 +461,7 @@ int
JackDriver::jack_process_cb(jack_nframes_t nframes, void* jack_driver)
{
JackDriver* me = reinterpret_cast<JackDriver*>(jack_driver);
-
- assert(me);
-
me->on_process(nframes);
-
return 0;
}
@@ -467,8 +469,6 @@ void
JackDriver::jack_shutdown_cb(void* jack_driver)
{
JackDriver* me = reinterpret_cast<JackDriver*>(jack_driver);
- assert(me);
-
me->_client = NULL;
}
diff --git a/src/engine/SMFWriter.cpp b/src/engine/SMFWriter.cpp
index 951e78c..f632bca 100644
--- a/src/engine/SMFWriter.cpp
+++ b/src/engine/SMFWriter.cpp
@@ -162,8 +162,6 @@ SMFWriter::write_header()
{
std::cout << "SMF Flushing header\n";
- assert(_fd);
-
const uint16_t type = GUINT16_TO_BE(0); // SMF Type 0 (single track)
const uint16_t ntracks = GUINT16_TO_BE(1); // Number of tracks (always 1 for Type 0)
const uint16_t division = GUINT16_TO_BE(_unit.ppt()); // PPQN