Added locking functions to libdebug, to avoid printf race conditions
This commit is contained in:
@@ -60,12 +60,14 @@ void display_iq_on(int on)
|
||||
if (iq_on) {
|
||||
memset(&screen, ' ', sizeof(screen));
|
||||
memset(&screen_history, 0, sizeof(screen_history));
|
||||
lock_debug();
|
||||
printf("\0337\033[H");
|
||||
for (j = 0; j < SIZE; j++) {
|
||||
screen[j][w] = '\0';
|
||||
puts(screen[j]);
|
||||
}
|
||||
printf("\0338"); fflush(stdout);
|
||||
unlock_debug();
|
||||
}
|
||||
|
||||
if (on < 0) {
|
||||
@@ -114,6 +116,8 @@ void display_iq(float *samples, int length)
|
||||
if (!iq_on)
|
||||
return;
|
||||
|
||||
lock_debug();
|
||||
|
||||
get_win_size(&width, &h);
|
||||
if (width > MAX_DISPLAY_WIDTH - 1)
|
||||
width = MAX_DISPLAY_WIDTH - 1;
|
||||
@@ -271,6 +275,8 @@ cont:
|
||||
}
|
||||
|
||||
disp.interval_pos = pos;
|
||||
|
||||
unlock_debug();
|
||||
}
|
||||
|
||||
|
||||
|
@@ -110,6 +110,8 @@ static void print_measurements(int on)
|
||||
if (bar_width < 1)
|
||||
return;
|
||||
|
||||
lock_debug();
|
||||
|
||||
lines_total = 0;
|
||||
color = -1;
|
||||
printf("\0337\033[H");
|
||||
@@ -252,6 +254,8 @@ static void print_measurements(int on)
|
||||
printf("\033[0;39m\0338"); fflush(stdout);
|
||||
|
||||
debug_limit_scroll = lines_total;
|
||||
|
||||
unlock_debug();
|
||||
}
|
||||
|
||||
void display_measurements_on(int on)
|
||||
|
@@ -101,12 +101,14 @@ void display_spectrum_on(int on)
|
||||
if (spectrum_on) {
|
||||
memset(&screen, ' ', sizeof(screen));
|
||||
memset(&buffer_hold, 0, sizeof(buffer_hold));
|
||||
lock_debug();
|
||||
printf("\0337\033[H");
|
||||
for (j = 0; j < HEIGHT; j++) {
|
||||
screen[j][w] = '\0';
|
||||
puts(screen[j]);
|
||||
}
|
||||
printf("\0338"); fflush(stdout);
|
||||
unlock_debug();
|
||||
}
|
||||
|
||||
if (on < 0) {
|
||||
@@ -140,6 +142,8 @@ void display_spectrum(float *samples, int length)
|
||||
if (!spectrum_on)
|
||||
return;
|
||||
|
||||
lock_debug();
|
||||
|
||||
get_win_size(&width, &h);
|
||||
if (width > MAX_DISPLAY_WIDTH - 1)
|
||||
width = MAX_DISPLAY_WIDTH - 1;
|
||||
@@ -403,6 +407,8 @@ void display_spectrum(float *samples, int length)
|
||||
}
|
||||
|
||||
disp.interval_pos = pos;
|
||||
|
||||
unlock_debug();
|
||||
}
|
||||
|
||||
|
||||
|
@@ -46,6 +46,7 @@ static void print_status(int on)
|
||||
if (h > lines_total)
|
||||
h = lines_total;
|
||||
|
||||
lock_debug();
|
||||
printf("\0337\033[H\033[1;37m");
|
||||
for (i = 0; i < h; i++) {
|
||||
j = 0;
|
||||
@@ -59,6 +60,7 @@ static void print_status(int on)
|
||||
putchar('\n');
|
||||
}
|
||||
printf("\0338"); fflush(stdout);
|
||||
unlock_debug();
|
||||
}
|
||||
|
||||
void display_status_on(int on)
|
||||
|
@@ -52,6 +52,7 @@ void display_wave_on(int on)
|
||||
|
||||
if (wave_on) {
|
||||
memset(&screen, ' ', sizeof(screen));
|
||||
lock_debug();
|
||||
printf("\0337\033[H");
|
||||
for (i = 0; i < num_sender; i++) {
|
||||
for (j = 0; j < HEIGHT; j++) {
|
||||
@@ -60,6 +61,7 @@ void display_wave_on(int on)
|
||||
}
|
||||
}
|
||||
printf("\0338"); fflush(stdout);
|
||||
unlock_debug();
|
||||
}
|
||||
|
||||
if (on < 0)
|
||||
@@ -102,6 +104,8 @@ void display_wave(dispwav_t *disp, sample_t *samples, int length, double range)
|
||||
if (!wave_on)
|
||||
return;
|
||||
|
||||
lock_debug();
|
||||
|
||||
get_win_size(&width, &h);
|
||||
if (width > MAX_DISPLAY_WIDTH - 1)
|
||||
width = MAX_DISPLAY_WIDTH - 1;
|
||||
@@ -241,6 +245,8 @@ void display_wave(dispwav_t *disp, sample_t *samples, int length, double range)
|
||||
}
|
||||
|
||||
disp->interval_pos = pos;
|
||||
|
||||
unlock_debug();
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user