duzy / gst-switch

A DVswitch replacement basing on GStreamer -- record video from multiple sources in the network, and switch for showing in PiP mode
Other
11 stars 19 forks source link

Time output should be produced right aligned and backspaced #24

Closed mithro closed 11 years ago

mithro commented 11 years ago

IE The output should look like

BLAH1                                                           (176 seconds)
BLAH1
BLAH2                                                           (176 seconds)
BLAH1
BLAH2
BLAH3                                                           (176 seconds)

This can be calculated by doing the following

int i = atoi(getenv('COLS'))
if (i == 0)
  i = 80;

printf("Blahh\n");
printf("\r%s(%4d seconds)", " "*30, 167);
printf("\r%s(%4d seconds)", " "*30, 165);

$ echo -e '12345\b6' 12346

mithro commented 11 years ago
tansell@tansell-x220-l:~/gst/gst-switch$ git diff
diff --git a/tests/test_switch_server.c b/tests/test_switch_server.c
index 90d2568..765c496 100644
--- a/tests/test_switch_server.c
+++ b/tests/test_switch_server.c
@@ -471,9 +471,17 @@ testcase_second_timer (testcase *t)
 static gpointer
 testcase_run (testcase *t)
 {
+  int cols = 0;
+  if (getenv("COLS") != NULL)
+    cols = atoi(getenv("COLS"));
+  if (cols <= 1)
+    cols = 80;
+
   g_mutex_init (&t->lock);

-  g_print ("Running %s (%d seconds)\n", t->name, t->live_seconds);
+  g_print ("\r%*s                ", cols, " ");
+  g_print ("\rRunning %s\n%*s (%5d seconds)", t->name, cols-16, " ", t->live_seconds);
+
   t->pass = TRUE; // assume everything is ok
   t->mainloop = g_main_loop_new (NULL, TRUE);
   if (testcase_launch_pipeline (t)) {
mithro commented 11 years ago

This patch doesn't work when multiple tests run in parallel.

mithro commented 11 years ago

Moved too https://github.com/timvideos/gst-switch/issues/15