@@ -189,64 +189,64 @@ void globalCallback::worker()
189189 if (!response.size () || (response.size () == 1 )) {
190190 goto do_sleep;
191191 }
192-
193- // Separate scope to avoid "jump bypasses variable initialization" compiler error
194- {
195- uint32_t index = 1 ;
196-
197- SourceSizeInfoData *data = new SourceSizeInfoData{{}};
198- for (uint32_t i = 2 ; i < (response[1 ].value_union .ui32 * 4 ) + 2 ; i++) {
199- SourceSizeInfo *item = new SourceSizeInfo;
200-
201- item->name = response[i++].value_str ;
202- item->width = response[i++].value_union .ui32 ;
203- item->height = response[i++].value_union .ui32 ;
204- item->flags = response[i].value_union .ui32 ;
205- data->items .emplace_back (item);
206- index = i;
207- }
208-
209- if (data->items .size () > 0 ) {
210- napi_status status = js_source_callback.NonBlockingCall (data, sources_callback);
211- if (status != napi_ok) {
212- delete data;
213- }
214- }
215-
216- index++;
217-
218- auto volmeterDataArray = new VolmeterDataArray;
219- while (volmeters_size--) {
220- VolmeterData *item = new VolmeterData{{}, {}, {}};
221-
222- item->source_name = response[index++].value_str ;
223-
224- size_t channels = response[index++].value_union .i32 ;
225- bool isMuted = response[index++].value_union .i32 ;
226-
227- if (!isMuted) {
228- item->magnitude .resize (channels);
229- item->peak .resize (channels);
230- item->input_peak .resize (channels);
231- for (size_t ch = 0 ; ch < channels; ch++) {
232- item->magnitude [ch] = response[index + ch * 3 + 0 ].value_union .fp32 ;
233- item->peak [ch] = response[index + ch * 3 + 1 ].value_union .fp32 ;
234- item->input_peak [ch] = response[index + ch * 3 + 2 ].value_union .fp32 ;
235- }
236-
237- index += static_cast <uint32_t >((3 * channels));
238-
239- volmeterDataArray->items .emplace_back (item);
240- }
241- }
242-
243- if (js_volmeter_callback) {
244- napi_status status = js_volmeter_callback.NonBlockingCall (volmeterDataArray, volmeter_callback);
245- if (status != napi_ok) {
246- delete volmeterDataArray;
247- }
248- }
249- }
192+
193+ // Separate scope to avoid "jump bypasses variable initialization" compiler error
194+ {
195+ uint32_t index = 1 ;
196+
197+ SourceSizeInfoData *data = new SourceSizeInfoData{{}};
198+ for (uint32_t i = 2 ; i < (response[1 ].value_union .ui32 * 4 ) + 2 ; i++) {
199+ SourceSizeInfo *item = new SourceSizeInfo;
200+
201+ item->name = response[i++].value_str ;
202+ item->width = response[i++].value_union .ui32 ;
203+ item->height = response[i++].value_union .ui32 ;
204+ item->flags = response[i].value_union .ui32 ;
205+ data->items .emplace_back (item);
206+ index = i;
207+ }
208+
209+ if (data->items .size () > 0 ) {
210+ napi_status status = js_source_callback.NonBlockingCall (data, sources_callback);
211+ if (status != napi_ok) {
212+ delete data;
213+ }
214+ }
215+
216+ index++;
217+
218+ auto volmeterDataArray = new VolmeterDataArray;
219+ while (volmeters_size--) {
220+ VolmeterData *item = new VolmeterData{{}, {}, {}};
221+
222+ item->source_name = response[index++].value_str ;
223+
224+ size_t channels = response[index++].value_union .i32 ;
225+ bool isMuted = response[index++].value_union .i32 ;
226+
227+ if (!isMuted) {
228+ item->magnitude .resize (channels);
229+ item->peak .resize (channels);
230+ item->input_peak .resize (channels);
231+ for (size_t ch = 0 ; ch < channels; ch++) {
232+ item->magnitude [ch] = response[index + ch * 3 + 0 ].value_union .fp32 ;
233+ item->peak [ch] = response[index + ch * 3 + 1 ].value_union .fp32 ;
234+ item->input_peak [ch] = response[index + ch * 3 + 2 ].value_union .fp32 ;
235+ }
236+
237+ index += static_cast <uint32_t >((3 * channels));
238+
239+ volmeterDataArray->items .emplace_back (item);
240+ }
241+ }
242+
243+ if (js_volmeter_callback) {
244+ napi_status status = js_volmeter_callback.NonBlockingCall (volmeterDataArray, volmeter_callback);
245+ if (status != napi_ok) {
246+ delete volmeterDataArray;
247+ }
248+ }
249+ }
250250 }
251251
252252 do_sleep:
0 commit comments