Skip to content

Commit d8fb520

Browse files
committed
Corrections on mod-monitor client code
Signed-off-by: falkTX <falktx@falktx.com>
1 parent 7dd4698 commit d8fb520

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

src/monitor/monitor-client.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,12 @@ static int ProcessMonitor(jack_nframes_t nframes, void *arg)
298298
for (uint32_t i=0; i < mon->numports; ++i)
299299
memset(jack_port_get_buffer(mon->out_ports[i], nframes), 0, sizeof(float)*nframes);
300300

301+
if (atomic_exchange(&mon->wait_proc, false))
302+
sem_post(&mon->wait_proc_sem);
303+
304+
if (atomic_exchange(&mon->wait_volume, false))
305+
sem_post(&mon->wait_volume_sem);
306+
301307
return 0;
302308
}
303309

@@ -362,6 +368,7 @@ static int ProcessMonitor(jack_nframes_t nframes, void *arg)
362368
}
363369
#endif
364370

371+
// we use `floats_differ_enough` here as a safe `!=` float value comparison
365372
mon->apply_volume = floats_differ_enough(smooth_volume, 1.0f);
366373
mon->smooth_volume = smooth_volume;
367374
mon->muted = smooth_volume <= db2lin(MOD_MONITOR_VOLUME_MUTE) ||
@@ -370,6 +377,8 @@ static int ProcessMonitor(jack_nframes_t nframes, void *arg)
370377
if (atomic_exchange(&mon->wait_proc, false))
371378
sem_post(&mon->wait_proc_sem);
372379

380+
// now we manually specify a very low value instead of using `floats_differ_enough`
381+
// due to smooth filtering the final value is never reached
373382
if (atomic_load(&mon->wait_volume) && fabsf(volume - smooth_volume) < 0.000001f)
374383
{
375384
atomic_store(&mon->wait_volume, false);
@@ -715,6 +724,8 @@ bool monitor_client_setup_volume(float volume)
715724
mon->step_volume = step_volume;
716725
mon->apply_volume = apply_volume;
717726

727+
atomic_thread_fence(memory_order_seq_cst);
728+
718729
if (unmute)
719730
mon->muted = false;
720731

0 commit comments

Comments
 (0)