Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package cava for openSUSE:Factory checked in 
at 2024-05-15 21:27:33
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/cava (Old)
 and      /work/SRC/openSUSE:Factory/.cava.new.1880 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "cava"

Wed May 15 21:27:33 2024 rev:19 rq:1174078 version:0.10.2

Changes:
--------
--- /work/SRC/openSUSE:Factory/cava/cava.changes        2024-02-04 
19:07:55.745857351 +0100
+++ /work/SRC/openSUSE:Factory/.cava.new.1880/cava.changes      2024-05-15 
21:28:09.172971560 +0200
@@ -1,0 +2,9 @@
+Tue May 14 19:34:12 UTC 2024 - Michael Vetter <mvet...@suse.com>
+
+- Update to 0.10.2:
+  * fix source being ignored when using pipewire #557
+  * fix stdlib.h not being included after iniparser upgrade #560
+  * add waveform visualization #484
+  * exit with error if pipewire loop creation fails #561
+
+-------------------------------------------------------------------

Old:
----
  0.10.1.tar.gz

New:
----
  0.10.2.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ cava.spec ++++++
--- /var/tmp/diff_new_pack.VeBgOY/_old  2024-05-15 21:28:09.592986762 +0200
+++ /var/tmp/diff_new_pack.VeBgOY/_new  2024-05-15 21:28:09.596986907 +0200
@@ -17,7 +17,7 @@
 
 
 Name:           cava
-Version:        0.10.1
+Version:        0.10.2
 Release:        0
 Summary:        Console-based Audio Visualizer for Alsa
 License:        MIT

++++++ 0.10.1.tar.gz -> 0.10.2.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cava-0.10.1/.github/workflows/build-and-test.yml 
new/cava-0.10.2/.github/workflows/build-and-test.yml
--- old/cava-0.10.1/.github/workflows/build-and-test.yml        2024-02-02 
18:47:27.000000000 +0100
+++ new/cava-0.10.2/.github/workflows/build-and-test.yml        2024-05-14 
20:24:24.000000000 +0200
@@ -52,12 +52,10 @@
         brew install fftw ncurses libtool automake autoconf-archive portaudio 
iniparser sdl2
         ln -s /usr/local/bin/glibtoolize /usr/local/bin/libtoolize
     - name: Generate configure
-      run: ./autogen.sh
+      run: PATH="/opt/homebrew/opt/libtool/libexec/gnubin:$PATH" ./autogen.sh
     - name: Run ./configure
-      run: LDFLAGS="-L/usr/local/opt/ncurses/lib" 
CPPFLAGS="-I/usr/local/opt/ncurses/include" ./configure
+      run: LDFLAGS="-L/opt/homebrew/lib" CPPFLAGS="-I/opt/homebrew/include" 
./configure
     - name: Run make
       run: make CFLAGS='-Werror'
     - name: run non zero test
       run: ./cava -p example_files/test_configs/non_zero_test > /dev/null
-    - name: run portaudio test
-      run: ./cava -p example_files/test_configs/portaudio_zero_test > /dev/null
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cava-0.10.1/autogen.sh new/cava-0.10.2/autogen.sh
--- old/cava-0.10.1/autogen.sh  2024-02-02 18:47:27.000000000 +0100
+++ new/cava-0.10.2/autogen.sh  2024-05-14 20:24:24.000000000 +0200
@@ -3,7 +3,7 @@
 if [ -d .git ]; then
   git describe --always --tags --dirty > version # get version from git
 else
-  echo 0.10.1 > version # hard coded versions
+  echo 0.10.2 > version # hard coded versions
 fi
 
 libtoolize
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cava-0.10.1/cava.c new/cava-0.10.2/cava.c
--- old/cava-0.10.1/cava.c      2024-02-02 18:47:27.000000000 +0100
+++ new/cava-0.10.2/cava.c      2024-05-14 20:24:24.000000000 +0200
@@ -667,7 +667,10 @@
                 if (number_of_bars % 2 != 0)
                     number_of_bars--;
             }
-
+            int raw_number_of_bars = (number_of_bars / output_channels) * 
audio_channels;
+            if (p.waveform) {
+                raw_number_of_bars = number_of_bars;
+            }
             // checks if there is stil extra room, will use this to center
             remainder = (*dimension_bar - number_of_bars * p.bar_width -
                          number_of_bars * p.bar_spacing + p.bar_spacing) /
@@ -910,99 +913,126 @@
 
                 // process: execute cava
                 pthread_mutex_lock(&audio.lock);
-                cava_execute(audio.cava_in, audio.samples_counter, cava_out, 
plan);
+                if (p.waveform) {
+                    for (int n = 0; n < audio.samples_counter; n++) {
+
+                        for (int i = number_of_bars - 1; i > 0; i--) {
+                            cava_out[i] = cava_out[i - 1];
+                        }
+                        if (audio_channels == 2) {
+                            cava_out[0] =
+                                p.sens * (audio.cava_in[n] / 2 + 
audio.cava_in[n + 1] / 2);
+                            n++;
+                        } else {
+                            cava_out[0] = p.sens * audio.cava_in[n];
+                        }
+                    }
+                } else {
+                    cava_execute(audio.cava_in, audio.samples_counter, 
cava_out, plan);
+                }
                 if (audio.samples_counter > 0) {
                     audio.samples_counter = 0;
                 }
                 pthread_mutex_unlock(&audio.lock);
 
-                for (int n = 0; n < (number_of_bars / output_channels) * 
audio_channels; n++) {
+                for (int n = 0; n < raw_number_of_bars; n++) {
 
-                    if (output_mode != OUTPUT_SDL_GLSL) {
-                        cava_out[n] *= *dimension_value;
+                    if (!p.waveform) {
+                        cava_out[n] *= p.sens;
+                    } else {
+                        if (cava_out[n] > 1.0)
+                            p.sens *= 0.999;
+                        else
+                            p.sens *= 1.00001;
+                        cava_out[n] = (cava_out[n] + 1.0) / 2.0;
                     }
 
-                    cava_out[n] *= p.sens;
-
                     if (output_mode == OUTPUT_SDL_GLSL) {
                         if (cava_out[n] > 1.0)
                             cava_out[n] = 1.0;
                         else if (cava_out[n] < 0.0)
                             cava_out[n] = 0.0;
+                    } else {
+                        cava_out[n] *= *dimension_value;
                     }
-                }
-
-                if (audio_channels == 2) {
-                    for (int n = 0; n < number_of_bars / output_channels; n++) 
{
-                        if (p.userEQ_enabled)
-                            cava_out[n] *=
-                                p.userEQ[(int)floor(((double)n) * 
userEQ_keys_to_bars_ratio)];
-                        bars_left[n] = cava_out[n];
-                    }
-                    for (int n = 0; n < number_of_bars / output_channels; n++) 
{
-                        if (p.userEQ_enabled)
-                            cava_out[n + number_of_bars / output_channels] *=
-                                p.userEQ[(int)floor(((double)n) * 
userEQ_keys_to_bars_ratio)];
-                        bars_right[n] = cava_out[n + number_of_bars / 
output_channels];
-                    }
-                } else {
-                    for (int n = 0; n < number_of_bars; n++) {
-                        if (p.userEQ_enabled)
-                            cava_out[n] *=
-                                p.userEQ[(int)floor(((double)n) * 
userEQ_keys_to_bars_ratio)];
+                    if (p.waveform) {
                         bars_raw[n] = cava_out[n];
                     }
                 }
-
-                // process [filter]
-                if (p.monstercat) {
+                if (!p.waveform) {
                     if (audio_channels == 2) {
-                        bars_left = monstercat_filter(bars_left, 
number_of_bars / output_channels,
-                                                      p.waves, p.monstercat);
-                        bars_right = monstercat_filter(bars_right, 
number_of_bars / output_channels,
-                                                       p.waves, p.monstercat);
+                        for (int n = 0; n < number_of_bars / output_channels; 
n++) {
+                            if (p.userEQ_enabled)
+                                cava_out[n] *=
+                                    p.userEQ[(int)floor(((double)n) * 
userEQ_keys_to_bars_ratio)];
+                            bars_left[n] = cava_out[n];
+                        }
+                        for (int n = 0; n < number_of_bars / output_channels; 
n++) {
+                            if (p.userEQ_enabled)
+                                cava_out[n + number_of_bars / output_channels] 
*=
+                                    p.userEQ[(int)floor(((double)n) * 
userEQ_keys_to_bars_ratio)];
+                            bars_right[n] = cava_out[n + number_of_bars / 
output_channels];
+                        }
                     } else {
-                        bars_raw =
-                            monstercat_filter(bars_raw, number_of_bars, 
p.waves, p.monstercat);
-                    }
-                }
-                if (audio_channels == 2) {
-                    if (p.stereo) {
-                        // mirroring stereo channels
                         for (int n = 0; n < number_of_bars; n++) {
-                            if (n < number_of_bars / 2) {
-                                if (p.reverse) {
-                                    bars_raw[n] = bars_left[n];
+                            if (p.userEQ_enabled)
+                                cava_out[n] *=
+                                    p.userEQ[(int)floor(((double)n) * 
userEQ_keys_to_bars_ratio)];
+                            bars_raw[n] = cava_out[n];
+                        }
+                    }
+
+                    // process [filter]
+                    if (p.monstercat) {
+                        if (audio_channels == 2) {
+                            bars_left = monstercat_filter(
+                                bars_left, number_of_bars / output_channels, 
p.waves, p.monstercat);
+                            bars_right =
+                                monstercat_filter(bars_right, number_of_bars / 
output_channels,
+                                                  p.waves, p.monstercat);
+                        } else {
+                            bars_raw =
+                                monstercat_filter(bars_raw, number_of_bars, 
p.waves, p.monstercat);
+                        }
+                    }
+                    if (audio_channels == 2) {
+                        if (p.stereo) {
+                            // mirroring stereo channels
+                            for (int n = 0; n < number_of_bars; n++) {
+                                if (n < number_of_bars / 2) {
+                                    if (p.reverse) {
+                                        bars_raw[n] = bars_left[n];
+                                    } else {
+                                        bars_raw[n] = bars_left[number_of_bars 
/ 2 - n - 1];
+                                    }
                                 } else {
-                                    bars_raw[n] = bars_left[number_of_bars / 2 
- n - 1];
+                                    if (p.reverse) {
+                                        bars_raw[n] = 
bars_right[number_of_bars - n - 1];
+                                    } else {
+                                        bars_raw[n] = bars_right[n - 
number_of_bars / 2];
+                                    }
                                 }
-                            } else {
+                            }
+                        } else {
+                            // stereo mono output
+                            for (int n = 0; n < number_of_bars; n++) {
                                 if (p.reverse) {
-                                    bars_raw[n] = bars_right[number_of_bars - 
n - 1];
+                                    if (p.mono_opt == AVERAGE) {
+                                        bars_raw[number_of_bars - n - 1] =
+                                            (bars_left[n] + bars_right[n]) / 2;
+                                    } else if (p.mono_opt == LEFT) {
+                                        bars_raw[number_of_bars - n - 1] = 
bars_left[n];
+                                    } else if (p.mono_opt == RIGHT) {
+                                        bars_raw[number_of_bars - n - 1] = 
bars_right[n];
+                                    }
                                 } else {
-                                    bars_raw[n] = bars_right[n - 
number_of_bars / 2];
-                                }
-                            }
-                        }
-                    } else {
-                        // stereo mono output
-                        for (int n = 0; n < number_of_bars; n++) {
-                            if (p.reverse) {
-                                if (p.mono_opt == AVERAGE) {
-                                    bars_raw[number_of_bars - n - 1] =
-                                        (bars_left[n] + bars_right[n]) / 2;
-                                } else if (p.mono_opt == LEFT) {
-                                    bars_raw[number_of_bars - n - 1] = 
bars_left[n];
-                                } else if (p.mono_opt == RIGHT) {
-                                    bars_raw[number_of_bars - n - 1] = 
bars_right[n];
-                                }
-                            } else {
-                                if (p.mono_opt == AVERAGE) {
-                                    bars_raw[n] = (bars_left[n] + 
bars_right[n]) / 2;
-                                } else if (p.mono_opt == LEFT) {
-                                    bars_raw[n] = bars_left[n];
-                                } else if (p.mono_opt == RIGHT) {
-                                    bars_raw[n] = bars_right[n];
+                                    if (p.mono_opt == AVERAGE) {
+                                        bars_raw[n] = (bars_left[n] + 
bars_right[n]) / 2;
+                                    } else if (p.mono_opt == LEFT) {
+                                        bars_raw[n] = bars_left[n];
+                                    } else if (p.mono_opt == RIGHT) {
+                                        bars_raw[n] = bars_right[n];
+                                    }
                                 }
                             }
                         }
@@ -1013,8 +1043,9 @@
 #endif
                 for (int n = 0; n < number_of_bars; n++) {
                     bars[n] = bars_raw[n];
-                    // zero values causes divided by zero segfault (if not raw)
-                    if (output_mode != OUTPUT_RAW && output_mode != 
OUTPUT_NORITAKE && bars[n] < 1)
+                    // show idle bar heads
+                    if (output_mode != OUTPUT_RAW && output_mode != 
OUTPUT_NORITAKE &&
+                        bars[n] < 1 && p.waveform == 0 && 
p.show_idle_bar_heads == 1)
                         bars[n] = 1;
 #ifdef SDL_GLSL
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cava-0.10.1/config.c new/cava-0.10.2/config.c
--- old/cava-0.10.1/config.c    2024-02-02 18:47:27.000000000 +0100
+++ new/cava-0.10.2/config.c    2024-05-14 20:24:24.000000000 +0200
@@ -14,6 +14,8 @@
 
 #include <stdarg.h>
 #include <stdbool.h>
+#include <stdlib.h>
+
 #include <sys/stat.h>
 
 #define NUMBER_OF_SHADERS 3
@@ -654,6 +656,10 @@
 
     p->disable_blanking = iniparser_getint(ini, "output:disable_blanking", 0);
 
+    p->show_idle_bar_heads = iniparser_getint(ini, 
"output:show_idle_bar_heads", 1);
+
+    p->waveform = iniparser_getint(ini, "output:waveform", 0);
+
     p->sync_updates = iniparser_getint(ini, "output:alacritty_sync", 0);
 
     vertexShader = strdup(iniparser_getstring(ini, "output:vertex_shader", 
"pass_through.vert"));
@@ -800,6 +806,8 @@
     p->sdl_y = GetPrivateProfileInt("output", "sdl_y", -1, configPath);
 
     p->sync_updates = GetPrivateProfileInt("output", "alacritty_sync", 0, 
configPath);
+    p->show_idle_bar_heads = GetPrivateProfileInt("output", 
"show_idle_bar_heads", 1, configPath);
+    p->waveform = GetPrivateProfileInt("output", "waveform", 0, configPath);
 
     p->userEQ_enabled = 0;
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cava-0.10.1/config.h new/cava-0.10.2/config.h
--- old/cava-0.10.1/config.h    2024-02-02 18:47:27.000000000 +0100
+++ new/cava-0.10.2/config.h    2024-05-14 20:24:24.000000000 +0200
@@ -113,7 +113,8 @@
         bit_format, gradient, gradient_count, fixedbars, framerate, bar_width, 
bar_spacing,
         bar_height, autosens, overshoot, waves, samplerate, samplebits, 
channels, autoconnect,
         sleep_timer, sdl_width, sdl_height, sdl_x, sdl_y, sdl_full_screen, 
draw_and_quit, zero_test,
-        non_zero_test, reverse, sync_updates, continuous_rendering, 
disable_blanking;
+        non_zero_test, reverse, sync_updates, continuous_rendering, 
disable_blanking,
+        show_idle_bar_heads, waveform;
 };
 
 struct error_s {
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cava-0.10.1/configure.ac new/cava-0.10.2/configure.ac
--- old/cava-0.10.1/configure.ac        2024-02-02 18:47:27.000000000 +0100
+++ new/cava-0.10.2/configure.ac        2024-05-14 20:24:24.000000000 +0200
@@ -46,13 +46,13 @@
 dnl checking if debug is enabled
 dnl ############################
 
-AC_ARG_ENABLE([debug],
-  AS_HELP_STRING([--enable-debug],
+AC_ARG_ENABLE([debug-output],
+  AS_HELP_STRING([--enable-debug-output],
     [enable debug messages and frequency table output])
 )
 
-AS_IF([test "x$enable_debug" != "xyes"], [
-  dnl enabling debug mode
+AS_IF([test "x$enable_debug_output" != "xyes"], [
+  dnl enabling debug output mode
   CPPFLAGS="$CPPFLAGS -DNDEBUG"
 ])
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cava-0.10.1/example_files/config 
new/cava-0.10.2/example_files/config
--- old/cava-0.10.1/example_files/config        2024-02-02 18:47:27.000000000 
+0100
+++ new/cava-0.10.2/example_files/config        2024-05-14 20:24:24.000000000 
+0200
@@ -204,6 +204,12 @@
 # (Not supported on FreeBSD)
 ; disable_blanking = 0
 
+# show a flat bar at the bottom of the screen when idle, 1 = on, 0 = off
+; show_idle_bar_heads = 1
+
+# show waveform instead of frequency spectrum, 1 = on, 0 = off
+; waveform = 0
+
 [color]
 
 # Colors can be one of seven predefined: black, blue, cyan, green, magenta, 
red, white, yellow.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cava-0.10.1/input/pipewire.c 
new/cava-0.10.2/input/pipewire.c
--- old/cava-0.10.1/input/pipewire.c    2024-02-02 18:47:27.000000000 +0100
+++ new/cava-0.10.2/input/pipewire.c    2024-05-14 20:24:24.000000000 +0200
@@ -64,6 +64,13 @@
     .process = on_process,
 };
 
+static void do_quit(void *userdata, int signal_number) {
+    struct pw_data *data = userdata;
+    data->cava_audio->terminate = 1;
+    pw_log_warn("pw quit signal %d received, terminating...", signal_number);
+    pw_main_loop_quit(data->loop);
+}
+
 void *input_pipewire(void *audiodata) {
     struct pw_data data = {
         0,
@@ -74,20 +81,34 @@
     uint8_t buffer[data.cava_audio->input_buffer_size];
     struct pw_properties *props;
     struct spa_pod_builder b = SPA_POD_BUILDER_INIT(buffer, sizeof(buffer));
-    char **argv;
     uint32_t nom;
     nom = nearbyint((10000 * data.cava_audio->rate) / 1000000.0);
 
-    pw_init(0, &argv);
+    pw_init(0, 0);
 
     data.loop = pw_main_loop_new(NULL);
+    if (data.loop == NULL) {
+        data.cava_audio->terminate = 1;
+        sprintf(data.cava_audio->error_message,
+                __FILE__ ": Could not create main loop. Is your system running 
pipewire? Maybe try "
+                         "pulse input method instead.");
+        return 0;
+    }
+
+    pw_loop_add_signal(pw_main_loop_get_loop(data.loop), SIGINT, do_quit, 
&data);
+    pw_loop_add_signal(pw_main_loop_get_loop(data.loop), SIGTERM, do_quit, 
&data);
 
     props = pw_properties_new(PW_KEY_MEDIA_TYPE, "Audio", 
PW_KEY_MEDIA_CATEGORY, "Capture",
                               PW_KEY_MEDIA_ROLE, "Music", NULL);
 
-    pw_properties_set(props, PW_KEY_TARGET_OBJECT, data.cava_audio->source);
-    pw_properties_set(props, PW_KEY_STREAM_CAPTURE_SINK, "true");
+    const char *source = data.cava_audio->source;
+    if (strcmp(source, "auto") == 0) {
+        pw_properties_set(props, PW_KEY_STREAM_CAPTURE_SINK, "true");
+    } else {
+        pw_properties_set(props, PW_KEY_TARGET_OBJECT, source);
+    }
     pw_properties_setf(props, PW_KEY_NODE_LATENCY, "%u/%u", nom, 
data.cava_audio->rate);
+    pw_properties_set(props, PW_KEY_NODE_ALWAYS_PROCESS, "true");
 
     data.stream = pw_stream_new_simple(pw_main_loop_get_loop(data.loop), 
"cava", props,
                                        &stream_events, &data);
@@ -124,4 +145,4 @@
     pw_main_loop_destroy(data.loop);
     pw_deinit();
     return 0;
-}
\ No newline at end of file
+}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cava-0.10.1/input/pulse.c 
new/cava-0.10.2/input/pulse.c
--- old/cava-0.10.1/input/pulse.c       2024-02-02 18:47:27.000000000 +0100
+++ new/cava-0.10.2/input/pulse.c       2024-05-14 20:24:24.000000000 +0200
@@ -101,17 +101,14 @@
 void *input_pulse(void *data) {
 
     struct audio_data *audio = (struct audio_data *)data;
-    uint16_t frames = audio->input_buffer_size / audio->channels;
-    unsigned char buf[audio->input_buffer_size * audio->format / 8];
+    uint16_t buffer_size = audio->input_buffer_size * audio->format / 8;
+    unsigned char buf[buffer_size];
 
     /* The sample type to use */
     static const pa_sample_spec ss = {.format = PA_SAMPLE_S16LE, .rate = 
44100, .channels = 2};
 
-    const int frag_size = frames * audio->channels * audio->format / 8 *
-                          2; // we double this because of cpu performance 
issues with pulseaudio
-
     pa_buffer_attr pb = {.maxlength = (uint32_t)-1, // BUFSIZE * 2,
-                         .fragsize = frag_size};
+                         .fragsize = buffer_size};
 
     pa_simple *s = NULL;
     int error;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cava-0.10.1/output/terminal_ncurses.c 
new/cava-0.10.2/output/terminal_ncurses.c
--- old/cava-0.10.1/output/terminal_ncurses.c   2024-02-02 18:47:27.000000000 
+0100
+++ new/cava-0.10.2/output/terminal_ncurses.c   2024-05-14 20:24:24.000000000 
+0200
@@ -77,24 +77,24 @@
     return return_color_number;
 }
 
-static void get_screen_coords(int val, int col, int max_value, enum 
orientation orientation, int *x,
-                              int *y) {
+static void get_screen_coords(int line, int col, int max_value, enum 
orientation orientation,
+                              int *x, int *y) {
     switch (orientation) {
     case ORIENT_LEFT:
-        *x = val;
+        *x = line;
         *y = col;
         break;
     case ORIENT_RIGHT:
-        *x = max_value - val;
+        *x = max_value - line;
         *y = col;
         break;
     case ORIENT_TOP:
         *x = col;
-        *y = val;
+        *y = line;
         break;
     default:
         *x = col;
-        *y = max_value - val;
+        *y = max_value - line;
         break;
     }
 }
@@ -254,9 +254,9 @@
 
     max_update_value = (max_update_value + num_bar_heights) / num_bar_heights;
 
-    for (int val = 0; val < max_update_value; val++) {
+    for (int line = 0; line < max_update_value; line++) {
         if (gradient) {
-            change_colors(val, max_value);
+            change_colors(line, max_value);
         }
 
         for (int bar = 0; bar < bars_count; bar++) {
@@ -265,17 +265,17 @@
             }
 
             int cur_col = bar * bar_width + bar * bar_spacing + rest;
-            int f_cell = (bars[bar] - 1) / num_bar_heights;
-            int f_last_cell = (previous_frame[bar] - 1) / num_bar_heights;
+            int bar_line_height = bars[bar] / num_bar_heights;
+            int previous_bar_line_heigh = previous_frame[bar] / 
num_bar_heights;
 
-            if (f_cell >= val) {
+            if (bars[bar] >= line * num_bar_heights + 1) {
                 int bar_step;
 
-                if (f_cell == val) {
-                    // The "cap" of the bar occurs at this [val].
-                    bar_step = (bars[bar] - 1) % num_bar_heights;
-                } else if (f_last_cell <= val) {
-                    // The bar is full at this [val].
+                if (bar_line_height == line) {
+                    // The "cap" of the bar occurs at this [line].
+                    bar_step = bars[bar] % num_bar_heights - 1;
+                } else if (previous_bar_line_heigh <= line) {
+                    // The bar is full at this line and wasn't before.
                     bar_step = num_bar_heights - 1;
                 } else {
                     // No update necessary since last frame.
@@ -284,7 +284,7 @@
 
                 for (int col = cur_col, i = 0; i < bar_width; i++, col++) {
                     int x, y;
-                    get_screen_coords(val, col, max_value, orientation, &x, 
&y);
+                    get_screen_coords(line, col, max_value, orientation, &x, 
&y);
 
                     if (is_tty) {
                         mvaddch(y, x, 0x41 + bar_step);
@@ -292,12 +292,12 @@
                         mvaddwstr(y, x, bar_heights[orientation][bar_step]);
                     }
                 }
-            } else if (f_last_cell >= val) {
+            } else if (previous_bar_line_heigh >= line) {
                 // This bar was taller during the last frame than during this 
frame, so
                 // clear the excess characters.
                 for (int col = cur_col, i = 0; i < bar_width; i++, col++) {
                     int x, y;
-                    get_screen_coords(val, col, max_value, orientation, &x, 
&y);
+                    get_screen_coords(line, col, max_value, orientation, &x, 
&y);
                     mvaddch(y, x, ' ');
                 }
             }

Reply via email to