mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-12-19 08:57:14 -05:00
pw-top: handle io
This commit is contained in:
parent
ae8f8b25f6
commit
f28fb692a4
1 changed files with 28 additions and 14 deletions
|
|
@ -35,8 +35,6 @@
|
||||||
#include <extensions/profiler.h>
|
#include <extensions/profiler.h>
|
||||||
|
|
||||||
#define MAX_NAME 128
|
#define MAX_NAME 128
|
||||||
#define MAX_NODES 1024
|
|
||||||
#define MAX_FOLLOWERS 1024
|
|
||||||
|
|
||||||
struct driver {
|
struct driver {
|
||||||
int64_t count;
|
int64_t count;
|
||||||
|
|
@ -247,11 +245,8 @@ static void print_node(struct data *d, struct driver *i, struct node *n)
|
||||||
char buf3[64];
|
char buf3[64];
|
||||||
char buf4[64];
|
char buf4[64];
|
||||||
float waiting, busy, period;
|
float waiting, busy, period;
|
||||||
int row, col;
|
|
||||||
struct spa_fraction frac;
|
struct spa_fraction frac;
|
||||||
|
|
||||||
getmaxyx(d->win,row,col);
|
|
||||||
|
|
||||||
if (n->driver == n)
|
if (n->driver == n)
|
||||||
frac = SPA_FRACTION((uint32_t)(i->clock.duration * i->clock.rate.num), i->clock.rate.denom);
|
frac = SPA_FRACTION((uint32_t)(i->clock.duration * i->clock.rate.num), i->clock.rate.denom);
|
||||||
else
|
else
|
||||||
|
|
@ -277,17 +272,16 @@ static void print_node(struct data *d, struct driver *i, struct node *n)
|
||||||
n->driver == n ? "" : " + ",
|
n->driver == n ? "" : " + ",
|
||||||
n->name);
|
n->name);
|
||||||
|
|
||||||
wprintw(d->win, "%.*s\n", col-1, line);
|
wprintw(d->win, "%.*s\n", COLS, line);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void do_timeout(void *data, uint64_t expirations)
|
static void do_refresh(struct data *d)
|
||||||
{
|
{
|
||||||
struct data *d = data;
|
|
||||||
struct node *n, *t, *f;
|
struct node *n, *t, *f;
|
||||||
|
|
||||||
wclear(d->win);
|
wclear(d->win);
|
||||||
wattron(d->win, A_REVERSE);
|
wattron(d->win, A_REVERSE);
|
||||||
wprintw(d->win, "%-*.*s", COLS-1, COLS-1, "S ID LATENCY WAIT BUSY W/P B/P ERR NAME ");
|
wprintw(d->win, "%-*.*s", COLS, COLS, "S ID PERIOD/RATE WAIT BUSY W/P B/P ERR NAME ");
|
||||||
wattroff(d->win, A_REVERSE);
|
wattroff(d->win, A_REVERSE);
|
||||||
wprintw(d->win, "\n");
|
wprintw(d->win, "\n");
|
||||||
|
|
||||||
|
|
@ -307,6 +301,12 @@ static void do_timeout(void *data, uint64_t expirations)
|
||||||
wrefresh(d->win);
|
wrefresh(d->win);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void do_timeout(void *data, uint64_t expirations)
|
||||||
|
{
|
||||||
|
struct data *d = data;
|
||||||
|
do_refresh(d);
|
||||||
|
}
|
||||||
|
|
||||||
static void profiler_profile(void *data, const struct spa_pod *pod)
|
static void profiler_profile(void *data, const struct spa_pod *pod)
|
||||||
{
|
{
|
||||||
struct data *d = data;
|
struct data *d = data;
|
||||||
|
|
@ -447,7 +447,7 @@ static void show_help(const char *name)
|
||||||
name);
|
name);
|
||||||
}
|
}
|
||||||
|
|
||||||
void terminal_start()
|
static void terminal_start()
|
||||||
{
|
{
|
||||||
initscr();
|
initscr();
|
||||||
cbreak();
|
cbreak();
|
||||||
|
|
@ -455,15 +455,27 @@ void terminal_start()
|
||||||
refresh();
|
refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
void terminal_stop()
|
static void terminal_stop()
|
||||||
{
|
{
|
||||||
endwin();
|
endwin();
|
||||||
}
|
}
|
||||||
|
|
||||||
void resizehandler(int sig)
|
static void do_handle_io(void *data, int fd, uint32_t mask)
|
||||||
{
|
{
|
||||||
terminal_stop();
|
struct data *d = data;
|
||||||
terminal_start();
|
|
||||||
|
if (mask & SPA_IO_IN) {
|
||||||
|
int ch = getch();
|
||||||
|
|
||||||
|
switch(ch) {
|
||||||
|
case 'q':
|
||||||
|
pw_main_loop_quit(d->loop);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
do_refresh(d);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
|
|
@ -557,6 +569,8 @@ int main(int argc, char *argv[])
|
||||||
interval.tv_nsec = 0;
|
interval.tv_nsec = 0;
|
||||||
pw_loop_update_timer(l, data.timer, &value, &interval, false);
|
pw_loop_update_timer(l, data.timer, &value, &interval, false);
|
||||||
|
|
||||||
|
pw_loop_add_io(l, fileno(stdin), SPA_IO_IN, false, do_handle_io, &data);
|
||||||
|
|
||||||
pw_main_loop_run(data.loop);
|
pw_main_loop_run(data.loop);
|
||||||
|
|
||||||
terminal_stop();
|
terminal_stop();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue