From 9a190b8d2b6e78658ea625322323728ad1c9929b Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Sun, 26 Jan 2014 00:46:39 +0100 Subject: [PATCH 01/11] fix crash when removing synth from midi-track (and there are bypassed audio-plugins after said synth) --- libs/ardour/plugin_insert.cc | 32 ++++++++++++-------------------- 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/libs/ardour/plugin_insert.cc b/libs/ardour/plugin_insert.cc index f2689bf998..2f90017498 100644 --- a/libs/ardour/plugin_insert.cc +++ b/libs/ardour/plugin_insert.cc @@ -464,39 +464,31 @@ PluginInsert::run (BufferSet& bufs, framepos_t /*start_frame*/, framepos_t /*end } } else { - if (has_no_audio_inputs()) { + uint32_t in = input_streams ().n_audio (); + uint32_t out = output_streams().n_audio (); + + if (has_no_audio_inputs() || in == 0) { /* silence all (audio) outputs. Should really declick * at the transitions of "active" */ - uint32_t out = output_streams().n_audio (); - for (uint32_t n = 0; n < out; ++n) { bufs.get_audio (n).silence (nframes); } - bufs.count().set_audio (out); + } else if (out > in) { - } else { + /* not active, but something has make up for any channel count increase */ - /* does this need to be done with MIDI? it appears not */ - - uint32_t in = input_streams ().n_audio (); - uint32_t out = output_streams().n_audio (); - - if (out > in) { - - /* not active, but something has make up for any channel count increase */ - - // TODO: option round-robin (n % in) or silence additional buffers ?? - for (uint32_t n = in; n < out; ++n) { - bufs.get_audio(n).read_from(bufs.get_audio(in - 1), nframes); - } + // TODO: option round-robin (n % in) or silence additional buffers ?? + // for now , simply replicate last buffer + for (uint32_t n = in; n < out; ++n) { + bufs.get_audio(n).read_from(bufs.get_audio(in - 1), nframes); } - - bufs.count().set_audio (out); } + + bufs.count().set_audio (out); } _active = _pending_active; From 249ee47296fdaf000c2820e9922d8b429020759e Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Sun, 26 Jan 2014 01:21:28 +0100 Subject: [PATCH 02/11] fix routing display for mono synths and midi-tracks w/o synth --- gtk2_ardour/processor_box.cc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/gtk2_ardour/processor_box.cc b/gtk2_ardour/processor_box.cc index c2421dcabf..cb72162773 100644 --- a/gtk2_ardour/processor_box.cc +++ b/gtk2_ardour/processor_box.cc @@ -844,6 +844,13 @@ ProcessorEntry::RoutingIcon::on_expose_event (GdkEventExpose* ev) cairo_move_to (cr, si_x, height); cairo_line_to (cr, si_x, 0); cairo_stroke (cr); + } else if (midi_sources == 1 && midi_sinks == 1) { + /* unusual cases -- removed synth, midi-track w/audio plugins */ + const float si_x = rintf(width * (sinks > 1 ? .2f : .5f)) + .5f; + const float si_x0 = rintf(width * (sources > 1 ? .2f : .5f)) + .5f; + cairo_move_to (cr, si_x, height); + cairo_curve_to (cr, si_x, 0, si_x0, height, si_x0, 0); + cairo_stroke (cr); } /* AUDIO */ @@ -855,8 +862,10 @@ ProcessorEntry::RoutingIcon::on_expose_event (GdkEventExpose* ev) UINT_RGBA_B_FLT(audio_port_color)); if (_splitting) { + assert(audio_sources < 2); assert(audio_sinks > 1); - const float si_x0 = rintf(width * .5f) + .5f; + /* assume there is only ever one MIDI port */ + const float si_x0 = rintf(width * (midi_sources > 0 ? .8f : .5f)) + .5f; for (uint32_t i = midi_sinks; i < sinks; ++i) { const float si_x = rintf(width * (.2f + .6f * i / (sinks - 1.f))) + .5f; cairo_move_to (cr, si_x, height); From 241c1aaaede2db1e4444070ec498730009b8ab7b Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Sun, 26 Jan 2014 19:11:54 +0100 Subject: [PATCH 03/11] fix #5840 ; redefinition of typedef 'VstTimeInfo' --- libs/ardour/ardour/vestige/aeffectx.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/libs/ardour/ardour/vestige/aeffectx.h b/libs/ardour/ardour/vestige/aeffectx.h index bd2e3a1479..4007ecf5ef 100644 --- a/libs/ardour/ardour/vestige/aeffectx.h +++ b/libs/ardour/ardour/vestige/aeffectx.h @@ -270,8 +270,6 @@ typedef struct _VstTimeInfo } VstTimeInfo; -typedef struct _VstTimeInfo VstTimeInfo; - typedef intptr_t (* audioMasterCallback) (AEffect *, int32_t, int32_t, intptr_t, void *, float); #endif From b8d31a370ad1473690f95ad92af6a4ef6bd774bd Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Mon, 27 Jan 2014 13:52:48 -0500 Subject: [PATCH 04/11] comment unused function argument --- gtk2_ardour/sfdb_ui.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gtk2_ardour/sfdb_ui.cc b/gtk2_ardour/sfdb_ui.cc index 39b7a33525..4b89cd51fe 100644 --- a/gtk2_ardour/sfdb_ui.cc +++ b/gtk2_ardour/sfdb_ui.cc @@ -116,7 +116,7 @@ importmode2string (ImportMode mode) return _("as new tracks"); } -SoundFileBox::SoundFileBox (bool persistent) +SoundFileBox::SoundFileBox (bool /*persistent*/) : table (6, 2), length_clock ("sfboxLengthClock", true, "", false, false, true, false), timecode_clock ("sfboxTimecodeClock", true, "", false, false, false, false), From 10d577146ae096b89065829f7ea9c5bbbc70a31a Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Mon, 27 Jan 2014 13:53:15 -0500 Subject: [PATCH 05/11] replace standards-wobbling variable-length-arrays with alloca() --- libs/panners/vbap/vbap_speakers.cc | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/libs/panners/vbap/vbap_speakers.cc b/libs/panners/vbap/vbap_speakers.cc index 313fe7a5cd..6b50e34d5a 100644 --- a/libs/panners/vbap/vbap_speakers.cc +++ b/libs/panners/vbap/vbap_speakers.cc @@ -34,6 +34,7 @@ #include #include #include +#include #include "pbd/cartesian.h" @@ -115,10 +116,14 @@ VBAPSpeakers::choose_speaker_triplets(struct ls_triplet_chain **ls_triplets) int i,j,k,l,table_size; int n_speakers = _speakers.size (); - int connections[n_speakers][n_speakers]; - float distance_table[((n_speakers * (n_speakers - 1)) / 2)]; - int distance_table_i[((n_speakers * (n_speakers - 1)) / 2)]; - int distance_table_j[((n_speakers * (n_speakers - 1)) / 2)]; + /* variable length arrays arrived in C99, became optional in C11, and + are only planned for C++14. Use alloca which is functionally + identical (but uglier to read). + */ + int** connections = (int**) alloca (sizeof (int) * n_speakers * n_speakers); + float* distance_table = (float *) alloca (sizeof (float) * ((n_speakers * (n_speakers - 1)) / 2)); + int* distance_table_i = (int *) alloca (sizeof (int) * ((n_speakers * (n_speakers - 1)) / 2)); + int* distance_table_j = (int *) alloca (sizeof (int) * ((n_speakers * (n_speakers - 1)) / 2)); float distance; struct ls_triplet_chain *trip_ptr, *prev, *tmp_ptr; @@ -527,9 +532,13 @@ VBAPSpeakers::choose_speaker_pairs (){ */ const int n_speakers = _speakers.size(); const double AZIMUTH_DELTA_THRESHOLD_DEGREES = (180.0/M_PI) * (M_PI - 0.175); - int sorted_speakers[n_speakers]; - bool exists[n_speakers]; - double inverse_matrix[n_speakers][4]; + /* variable length arrays arrived in C99, became optional in C11, and + are only planned for C++14. Use alloca which is functionally + identical (but uglier to read). + */ + int* sorted_speakers = (int*) alloca (sizeof (int) * n_speakers); + bool* exists = (bool*) alloca (sizeof(bool) * n_speakers); + double** inverse_matrix = (double**) alloca (sizeof (double) * n_speakers * 4); int expected_pairs = 0; int pair; int speaker; From f8737f701264c8514006c7dbbf26025b62f98e39 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Mon, 27 Jan 2014 14:55:58 -0500 Subject: [PATCH 06/11] add new folders to linux vst search path to help out AVLinux and some other specialized distros --- libs/ardour/plugin_manager.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libs/ardour/plugin_manager.cc b/libs/ardour/plugin_manager.cc index 90522a7e06..a10f27be1e 100644 --- a/libs/ardour/plugin_manager.cc +++ b/libs/ardour/plugin_manager.cc @@ -646,7 +646,8 @@ PluginManager::lxvst_refresh () } if (lxvst_path.length() == 0) { - lxvst_path = "/usr/local/lib64/lxvst:/usr/local/lib/lxvst:/usr/lib64/lxvst:/usr/lib/lxvst"; + lxvst_path = "/usr/local/lib64/lxvst:/usr/local/lib/lxvst:/usr/lib64/lxvst:/usr/lib/lxvst" + "/usr/local/lib64/linux_vst:/usr/local/lib/linux_vst:/usr/lib64/linux_vst:/usr/lib/linux_vst"; } lxvst_discover_from_path (lxvst_path); From 41001ae702c1f920b0e069de8ea6b4be60521101 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Mon, 27 Jan 2014 20:36:09 -0500 Subject: [PATCH 07/11] prevent a strange crash while iterating over tracks (now, and maybe in the future) --- gtk2_ardour/ardour_ui.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gtk2_ardour/ardour_ui.cc b/gtk2_ardour/ardour_ui.cc index b5fe18e91f..bf90ff3c54 100644 --- a/gtk2_ardour/ardour_ui.cc +++ b/gtk2_ardour/ardour_ui.cc @@ -3264,7 +3264,7 @@ ARDOUR_UI::setup_order_hint () } else { for (TrackSelection::iterator s = editor->get_selection().tracks.begin(); s != editor->get_selection().tracks.end(); ++s) { RouteTimeAxisView* tav = dynamic_cast (*s); - if (tav->route()->order_key() > order_hint) { + if (tav && tav->route() && tav->route()->order_key() > order_hint) { order_hint = tav->route()->order_key(); } } From a754a7cc0df1d8ab2e38d3bf51cbd1ad55c59369 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Mon, 27 Jan 2014 20:37:17 -0500 Subject: [PATCH 08/11] fix up the abomination caused by moving from variable length (multidimensional) arrays to alloca'ed arrays, specifically access to arr[a][b]. This needs checking by an actual VBAP+multispeaker user. --- libs/panners/vbap/vbap_speakers.cc | 60 +++++++++++++++--------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/libs/panners/vbap/vbap_speakers.cc b/libs/panners/vbap/vbap_speakers.cc index 6b50e34d5a..af690af32c 100644 --- a/libs/panners/vbap/vbap_speakers.cc +++ b/libs/panners/vbap/vbap_speakers.cc @@ -120,7 +120,7 @@ VBAPSpeakers::choose_speaker_triplets(struct ls_triplet_chain **ls_triplets) are only planned for C++14. Use alloca which is functionally identical (but uglier to read). */ - int** connections = (int**) alloca (sizeof (int) * n_speakers * n_speakers); + int* connections = (int*) alloca (sizeof (int) * n_speakers * n_speakers); float* distance_table = (float *) alloca (sizeof (float) * ((n_speakers * (n_speakers - 1)) / 2)); int* distance_table_i = (int *) alloca (sizeof (int) * ((n_speakers * (n_speakers - 1)) / 2)); int* distance_table_j = (int *) alloca (sizeof (int) * ((n_speakers * (n_speakers - 1)) / 2)); @@ -135,12 +135,12 @@ VBAPSpeakers::choose_speaker_triplets(struct ls_triplet_chain **ls_triplets) for (j = i+1; j < n_speakers; j++) { for(k = j+1; k < n_speakers; k++) { if (vol_p_side_lgth(i, j, k, _speakers) > MIN_VOL_P_SIDE_LGTH) { - connections[i][j]=1; - connections[j][i]=1; - connections[i][k]=1; - connections[k][i]=1; - connections[j][k]=1; - connections[k][j]=1; + connections[(i*n_speakers)+j]=1; + connections[(j*n_speakers)+i]=1; + connections[(i*n_speakers)+k]=1; + connections[(k*n_speakers)+i]=1; + connections[(j*n_speakers)+k]=1; + connections[(k*n_speakers)+j]=1; add_ldsp_triplet(i,j,k,ls_triplets); } } @@ -155,7 +155,7 @@ VBAPSpeakers::choose_speaker_triplets(struct ls_triplet_chain **ls_triplets) for (i = 0;i < n_speakers; i++) { for (j = i+1; j < n_speakers; j++) { - if (connections[i][j] == 1) { + if (connections[(i*n_speakers)+j] == 1) { distance = fabs(vec_angle(_speakers[i].coords(),_speakers[j].coords())); k=0; while(distance_table[k] < distance) { @@ -180,13 +180,13 @@ VBAPSpeakers::choose_speaker_triplets(struct ls_triplet_chain **ls_triplets) for (i = 0; i < table_size; i++) { int fst_ls = distance_table_i[i]; int sec_ls = distance_table_j[i]; - if (connections[fst_ls][sec_ls] == 1) { + if (connections[(fst_ls*n_speakers)+sec_ls] == 1) { for (j = 0; j < n_speakers; j++) { for (k = j+1; k < n_speakers; k++) { if ((j != fst_ls) && (k != sec_ls) && (k != fst_ls) && (j != sec_ls)) { if (lines_intersect(fst_ls, sec_ls, j, k) == 1){ - connections[j][k] = 0; - connections[k][j] = 0; + connections[(j*n_speakers)+k] = 0; + connections[(k*n_speakers)+j] = 0; } } } @@ -202,9 +202,9 @@ VBAPSpeakers::choose_speaker_triplets(struct ls_triplet_chain **ls_triplets) i = trip_ptr->ls_nos[0]; j = trip_ptr->ls_nos[1]; k = trip_ptr->ls_nos[2]; - if (connections[i][j] == 0 || - connections[i][k] == 0 || - connections[j][k] == 0 || + if (connections[(i*n_speakers)+j] == 0 || + connections[(i*n_speakers)+k] == 0 || + connections[(j*n_speakers)+k] == 0 || any_ls_inside_triplet(i,j,k) == 1 ){ if (prev != 0) { prev->next = trip_ptr->next; @@ -531,6 +531,11 @@ VBAPSpeakers::choose_speaker_pairs (){ matrices and stores the data to a global array */ const int n_speakers = _speakers.size(); + + if (n_speakers == 0) { + return; + } + const double AZIMUTH_DELTA_THRESHOLD_DEGREES = (180.0/M_PI) * (M_PI - 0.175); /* variable length arrays arrived in C99, became optional in C11, and are only planned for C++14. Use alloca which is functionally @@ -538,16 +543,11 @@ VBAPSpeakers::choose_speaker_pairs (){ */ int* sorted_speakers = (int*) alloca (sizeof (int) * n_speakers); bool* exists = (bool*) alloca (sizeof(bool) * n_speakers); - double** inverse_matrix = (double**) alloca (sizeof (double) * n_speakers * 4); + double* inverse_matrix = (double*) alloca (sizeof (double) * n_speakers * 4); int expected_pairs = 0; int pair; int speaker; - - if (n_speakers == 0) { - return; - } - for (speaker = 0; speaker < n_speakers; ++speaker) { exists[speaker] = false; } @@ -562,7 +562,7 @@ VBAPSpeakers::choose_speaker_pairs (){ _speakers[sorted_speakers[speaker]].angles().azi) <= AZIMUTH_DELTA_THRESHOLD_DEGREES) { if (calc_2D_inv_tmatrix( _speakers[sorted_speakers[speaker]].angles().azi, _speakers[sorted_speakers[speaker+1]].angles().azi, - inverse_matrix[speaker]) != 0){ + &inverse_matrix[4 * speaker]) != 0){ exists[speaker] = true; expected_pairs++; } @@ -573,7 +573,7 @@ VBAPSpeakers::choose_speaker_pairs (){ +_speakers[sorted_speakers[0]].angles().azi) <= AZIMUTH_DELTA_THRESHOLD_DEGREES) { if (calc_2D_inv_tmatrix(_speakers[sorted_speakers[n_speakers-1]].angles().azi, _speakers[sorted_speakers[0]].angles().azi, - inverse_matrix[n_speakers-1]) != 0) { + &inverse_matrix[(4*n_speakers)-1]) != 0) { exists[n_speakers-1] = true; expected_pairs++; } @@ -591,10 +591,10 @@ VBAPSpeakers::choose_speaker_pairs (){ for (speaker = 0; speaker < n_speakers - 1; speaker++) { if (exists[speaker]) { - _matrices[pair][0] = inverse_matrix[speaker][0]; - _matrices[pair][1] = inverse_matrix[speaker][1]; - _matrices[pair][2] = inverse_matrix[speaker][2]; - _matrices[pair][3] = inverse_matrix[speaker][3]; + _matrices[pair][0] = inverse_matrix[(speaker*n_speakers)+0]; + _matrices[pair][1] = inverse_matrix[(speaker*n_speakers)+1]; + _matrices[pair][2] = inverse_matrix[(speaker*n_speakers)+2]; + _matrices[pair][3] = inverse_matrix[(speaker*n_speakers)+3]; _speaker_tuples[pair][0] = sorted_speakers[speaker]; _speaker_tuples[pair][1] = sorted_speakers[speaker+1]; @@ -604,10 +604,10 @@ VBAPSpeakers::choose_speaker_pairs (){ } if (exists[n_speakers-1]) { - _matrices[pair][0] = inverse_matrix[speaker][0]; - _matrices[pair][1] = inverse_matrix[speaker][1]; - _matrices[pair][2] = inverse_matrix[speaker][2]; - _matrices[pair][3] = inverse_matrix[speaker][3]; + _matrices[pair][0] = inverse_matrix[(speaker*n_speakers)+0]; + _matrices[pair][1] = inverse_matrix[(speaker*n_speakers)+1]; + _matrices[pair][2] = inverse_matrix[(speaker*n_speakers)+2]; + _matrices[pair][3] = inverse_matrix[(speaker*n_speakers)+3]; _speaker_tuples[pair][0] = sorted_speakers[n_speakers-1]; _speaker_tuples[pair][1] = sorted_speakers[0]; From eadafdd6de3d773df91e23660f4b47f6fe660ecc Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Tue, 28 Jan 2014 13:50:41 +0100 Subject: [PATCH 09/11] fix thinko. custom panner URL is remembered for later when port-count/panner changes --- gtk2_ardour/panner_ui.cc | 3 --- 1 file changed, 3 deletions(-) diff --git a/gtk2_ardour/panner_ui.cc b/gtk2_ardour/panner_ui.cc index 2a6568992b..9ea2b357eb 100644 --- a/gtk2_ardour/panner_ui.cc +++ b/gtk2_ardour/panner_ui.cc @@ -392,9 +392,6 @@ PannerUI::build_pan_menu () RadioMenuItem::Group group; items.push_back (SeparatorElem()); - assert(_panshell->user_selected_panner_uri() == "" - || _panshell->user_selected_panner_uri() == _panshell->current_panner_uri()); - _suspend_menu_callbacks = true; for (std::map::const_iterator p = _panner_list.begin(); p != _panner_list.end(); ++p) { items.push_back (RadioMenuElem (group, p->second, From 2d8352123a656bb0478008876340352c158ceacf Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Wed, 29 Jan 2014 21:45:13 +0100 Subject: [PATCH 10/11] fix vbap-speaker calculations to work with alloca() --- libs/panners/vbap/vbap_speakers.cc | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/libs/panners/vbap/vbap_speakers.cc b/libs/panners/vbap/vbap_speakers.cc index af690af32c..79f5b230f7 100644 --- a/libs/panners/vbap/vbap_speakers.cc +++ b/libs/panners/vbap/vbap_speakers.cc @@ -127,6 +127,10 @@ VBAPSpeakers::choose_speaker_triplets(struct ls_triplet_chain **ls_triplets) float distance; struct ls_triplet_chain *trip_ptr, *prev, *tmp_ptr; + for (i = 0; i < n_speakers * n_speakers; i++) { + connections[i] = 0; + } + if (n_speakers == 0) { return; } @@ -573,7 +577,7 @@ VBAPSpeakers::choose_speaker_pairs (){ +_speakers[sorted_speakers[0]].angles().azi) <= AZIMUTH_DELTA_THRESHOLD_DEGREES) { if (calc_2D_inv_tmatrix(_speakers[sorted_speakers[n_speakers-1]].angles().azi, _speakers[sorted_speakers[0]].angles().azi, - &inverse_matrix[(4*n_speakers)-1]) != 0) { + &inverse_matrix[4*(n_speakers-1)]) != 0) { exists[n_speakers-1] = true; expected_pairs++; } @@ -591,10 +595,10 @@ VBAPSpeakers::choose_speaker_pairs (){ for (speaker = 0; speaker < n_speakers - 1; speaker++) { if (exists[speaker]) { - _matrices[pair][0] = inverse_matrix[(speaker*n_speakers)+0]; - _matrices[pair][1] = inverse_matrix[(speaker*n_speakers)+1]; - _matrices[pair][2] = inverse_matrix[(speaker*n_speakers)+2]; - _matrices[pair][3] = inverse_matrix[(speaker*n_speakers)+3]; + _matrices[pair][0] = inverse_matrix[(speaker*4)+0]; + _matrices[pair][1] = inverse_matrix[(speaker*4)+1]; + _matrices[pair][2] = inverse_matrix[(speaker*4)+2]; + _matrices[pair][3] = inverse_matrix[(speaker*4)+3]; _speaker_tuples[pair][0] = sorted_speakers[speaker]; _speaker_tuples[pair][1] = sorted_speakers[speaker+1]; @@ -604,10 +608,10 @@ VBAPSpeakers::choose_speaker_pairs (){ } if (exists[n_speakers-1]) { - _matrices[pair][0] = inverse_matrix[(speaker*n_speakers)+0]; - _matrices[pair][1] = inverse_matrix[(speaker*n_speakers)+1]; - _matrices[pair][2] = inverse_matrix[(speaker*n_speakers)+2]; - _matrices[pair][3] = inverse_matrix[(speaker*n_speakers)+3]; + _matrices[pair][0] = inverse_matrix[(speaker*4)+0]; + _matrices[pair][1] = inverse_matrix[(speaker*4)+1]; + _matrices[pair][2] = inverse_matrix[(speaker*4)+2]; + _matrices[pair][3] = inverse_matrix[(speaker*4)+3]; _speaker_tuples[pair][0] = sorted_speakers[n_speakers-1]; _speaker_tuples[pair][1] = sorted_speakers[0]; From 66d02411182bec7871a6cb53e4476042f31f72c0 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Wed, 29 Jan 2014 15:50:17 -0500 Subject: [PATCH 11/11] move check for n_speakers so that we avoid needless work --- libs/panners/vbap/vbap_speakers.cc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/libs/panners/vbap/vbap_speakers.cc b/libs/panners/vbap/vbap_speakers.cc index 79f5b230f7..1cf78797b7 100644 --- a/libs/panners/vbap/vbap_speakers.cc +++ b/libs/panners/vbap/vbap_speakers.cc @@ -116,6 +116,11 @@ VBAPSpeakers::choose_speaker_triplets(struct ls_triplet_chain **ls_triplets) int i,j,k,l,table_size; int n_speakers = _speakers.size (); + + if (n_speakers == 0) { + return; + } + /* variable length arrays arrived in C99, became optional in C11, and are only planned for C++14. Use alloca which is functionally identical (but uglier to read). @@ -131,10 +136,6 @@ VBAPSpeakers::choose_speaker_triplets(struct ls_triplet_chain **ls_triplets) connections[i] = 0; } - if (n_speakers == 0) { - return; - } - for (i = 0; i < n_speakers; i++) { for (j = i+1; j < n_speakers; j++) { for(k = j+1; k < n_speakers; k++) {