~kennylevinsen/wlavu

665d39e70c16521cb6f883f25b8c5c4eeb863d44 — Kenny Levinsen 2 years ago 559b181
Move peak_decay to input side
1 files changed, 7 insertions(+), 12 deletions(-)

M main.c
M main.c => main.c +7 -12
@@ 32,7 32,7 @@
#include "wlr-layer-shell-unstable-v1-client-protocol.h"
#include "xdg-shell-client-protocol.h"

#define PEAK_DURATION 20
#define PEAK_DURATION 15
#define HYSTERESIS 0.0005

enum event_loop_fd {


@@ 196,7 196,7 @@ struct context {
	double peak;
	double last_val;
	double last_peak;
	double peak_decay;
	int peak_decay;
};

static void layer_surface_configure(void *data,


@@ 418,11 418,6 @@ static int draw(struct context *ctx) {
	}

	shm_buf_acquire(buf);

	struct wl_callback *callback = wl_surface_frame(ctx->surface);
	wl_callback_add_listener(callback, &frame_listener, ctx);
	ctx->pending = true;

	if (buf->height > buf->width) {
		int extend = draw_vert(ctx, buf);
		wl_surface_damage_buffer(ctx->surface,


@@ 437,12 432,12 @@ static int draw(struct context *ctx) {
		ctx->last_extend = extend;
	}

	struct wl_callback *callback = wl_surface_frame(ctx->surface);
	wl_callback_add_listener(callback, &frame_listener, ctx);
	ctx->pending = true;

	wl_surface_attach(ctx->surface, buf->buffer, 0, 0);
	wl_surface_commit(ctx->surface);

	if (ctx->peak_decay != 0) {
		ctx->peak_decay--;
	}
	return 0;
}



@@ 478,7 473,7 @@ static void on_process(void *userdata) {
	p += offset;

	ctx->val = max_f32(p, size / (4 * ctx->channels));
	if (ctx->peak_decay == 0 || ctx->val > ctx->peak) {
	if (ctx->peak_decay-- == 0 || ctx->val > ctx->peak) {
		ctx->peak = ctx->val;
		ctx->peak_decay = PEAK_DURATION;
	}