From 2f0d7300ebd0e3ba8f466a661c51d71f671dce91 Mon Sep 17 00:00:00 2001
From: Ramakrishnan Muthukrishnan <ram@rkrishnan.org>
Date: Sat, 29 Jul 2023 23:20:22 +0530
Subject: [PATCH] obtain display mutex while painting the pixbuf

---
 waterfall.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/waterfall.c b/waterfall.c
index 03e133f..f17224b 100644
--- a/waterfall.c
+++ b/waterfall.c
@@ -78,8 +78,10 @@ static gboolean waterfall_configure_event_cb(GtkWidget *widget,
 static gboolean waterfall_draw_cb(GtkWidget *widget, cairo_t *cr,
                                   gpointer data) {
     RECEIVER *rx = (RECEIVER *)data;
+    g_mutex_lock(&rx->display_mutex);
     gdk_cairo_set_source_pixbuf(cr, rx->pixbuf, 0, 0);
     cairo_paint(cr);
+    g_mutex_unlock(&rx->display_mutex);
     return FALSE;
 }
 
@@ -108,7 +110,6 @@ static gboolean waterfall_scroll_event_cb(GtkWidget *widget,
 }
 
 void waterfall_update(RECEIVER *rx) {
-
     int i;
 
     float *samples;
-- 
2.45.2