File: time.c

package info (click to toggle)
alsaplayer 0.99.76-9%2Betch1
  • links: PTS
  • area: main
  • in suites: etch
  • size: 4,752 kB
  • ctags: 2,970
  • sloc: ansic: 16,775; sh: 10,709; cpp: 9,442; makefile: 694
file content (30 lines) | stat: -rw-r--r-- 638 bytes parent folder | download | duplicates (8)
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_frame, pos_sec;
	int length_frame, length_sec;

	puts("");
	while (ap_session_running(0)) {
		// Totals
		ap_get_frames(0, &length_frame);
		ap_get_length(0, &length_sec);

		// Current position
		ap_get_frame(0, &pos_frame);
		ap_get_position(0, &pos_sec);

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