diff options
| author | Adam Avramov <fallenblood@gmail.com> | 2015-05-13 21:21:55 +0300 |
|---|---|---|
| committer | Adam Avramov <fallenblood@gmail.com> | 2015-05-13 21:26:39 +0300 |
| commit | 6a06b40251823c27aa444979829621baef1ad433 (patch) | |
| tree | 5ffc314cd9190b118e60bc0c5f676854bdd41a8a | |
| parent | 28321c051ed849b0fbd1f7b1aaee19b8ca807390 (diff) | |
Always allocate JACK ringbuffers.
This makes sure a program using this library would not segfault
while waiting for a stopped JACK server to autostart.
| -rw-r--r-- | RtMidi.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
@@ -2678,6 +2678,10 @@ void MidiOutJack :: connect() JackMidiData *data = static_cast<JackMidiData *> (apiData_); if ( data->client ) return; + + // Initialize output ringbuffers + data->buffSize = jack_ringbuffer_create( JACK_RINGBUFFER_SIZE ); + data->buffMessage = jack_ringbuffer_create( JACK_RINGBUFFER_SIZE ); // Initialize JACK client if (( data->client = jack_client_open( clientName.c_str(), JackNoStartServer, NULL )) == 0) { @@ -2687,8 +2691,6 @@ void MidiOutJack :: connect() } jack_set_process_callback( data->client, jackProcessOut, data ); - data->buffSize = jack_ringbuffer_create( JACK_RINGBUFFER_SIZE ); - data->buffMessage = jack_ringbuffer_create( JACK_RINGBUFFER_SIZE ); jack_activate( data->client ); } @@ -2696,12 +2698,12 @@ MidiOutJack :: ~MidiOutJack() { JackMidiData *data = static_cast<JackMidiData *> (apiData_); closePort(); - + + // Cleanup + jack_ringbuffer_free( data->buffSize ); + jack_ringbuffer_free( data->buffMessage ); if ( data->client ) { - // Cleanup jack_client_close( data->client ); - jack_ringbuffer_free( data->buffSize ); - jack_ringbuffer_free( data->buffMessage ); } delete data; |
