Browse Source

Midi-Mapper: Close gracefully on sigterm.

tags/non-daw-v1.2.0
Jonathan Moore Liles 11 years ago
parent
commit
d1c4fe418b
1 changed files with 25 additions and 1 deletions
  1. +25
    -1
      mixer/src/midi-mapper.C

+ 25
- 1
mixer/src/midi-mapper.C View File

@@ -37,6 +37,7 @@ using namespace MIDI;
#include <map> #include <map>
#include <string> #include <string>


#include <signal.h>
#include <unistd.h> /* usleep */ #include <unistd.h> /* usleep */
/* simple program to translate from MIDI<->OSC Signals using a fixed mapping */ /* simple program to translate from MIDI<->OSC Signals using a fixed mapping */


@@ -129,6 +130,10 @@ public:
midi_output_port = 0; midi_output_port = 0;
} }


virtual ~Engine ( )
{
deactivate();
}
int process ( nframes_t nframes ) int process ( nframes_t nframes )
{ {
@@ -645,11 +650,24 @@ decode_nrpn ( nrpn_state *state, midievent e, int *take_action )
return NULL; return NULL;
} }



static volatile int got_sigterm = 0;

void
sigterm_handler ( int )
{
got_sigterm = 1;
}

int int
main ( int argc, char **argv ) main ( int argc, char **argv )
{ {
nrpn_state nrpn_state[16]; nrpn_state nrpn_state[16];


signal( SIGTERM, sigterm_handler );
signal( SIGHUP, sigterm_handler );
signal( SIGINT, sigterm_handler );

nsm = nsm_new(); nsm = nsm_new();
// set_nsm_callbacks( nsm ); // set_nsm_callbacks( nsm );
@@ -686,7 +704,7 @@ main ( int argc, char **argv )


jack_midi_event_t ev; jack_midi_event_t ev;
midievent e; midievent e;
while ( true )
while ( ! got_sigterm )
{ {
osc->wait(20); osc->wait(20);
check_nsm(); check_nsm();
@@ -786,6 +804,12 @@ main ( int argc, char **argv )
} }
// e.pretty_print(); // e.pretty_print();
} }


// usleep( 500 ); // usleep( 500 );
} }

delete engine;

return 0;
} }

Loading…
Cancel
Save