File: time.c

package info (click to toggle)
alsaplayer 0.99.82-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,892 kB
  • sloc: ansic: 40,741; cpp: 14,400; makefile: 983; sh: 796; lex: 751; asm: 45; python: 29; sed: 16
file content (30 lines) | stat: -rw-r--r-- 637 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include <stdio.h>
#include <unistd.h>
#include <alsaplayer/control.h>

int main (int argc, char *argv[])
{
	int pos_block, pos_sec;
	int length_block, length_sec;

	puts("");
	while (ap_session_running(0)) {
		// Totals
		ap_get_blocks(0, &length_block);
		ap_get_length(0, &length_sec);

		// Current position
		ap_get_block(0, &pos_block);
		ap_get_position(0, &pos_sec);

		printf("Run: %5d / %5d = %.2f <-> %5d / %5d = %.2f   \r",
			pos_block, length_block,
			(float)pos_block / (float)length_block,
			pos_sec, length_sec,
			(float)pos_sec / (float)length_sec);
		fflush(stdout);
		usleep(50000);
	}
	puts("done");
	return 0;
}