File: ripperX_plugin-mp3enc.c

package info (click to toggle)
ripperx 2.8.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster
  • size: 1,960 kB
  • sloc: ansic: 8,396; sh: 4,362; makefile: 87; sed: 16
file content (38 lines) | stat: -rw-r--r-- 742 bytes parent folder | download | duplicates (10)
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
31
32
33
34
35
36
37
38

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <ctype.h>

#define OUTPUT_BUF_LENGTH  1024


#define PRINTOUT_INTERVAL       0.5

int
read_stat (unsigned int *current, unsigned int *length)
{
	char temp[OUTPUT_BUF_LENGTH];
	int bytes_read;
	/* Grab new ouput from 'gogo'  */
	bytes_read = read (0, (void *) temp, sizeof (temp));
	if (bytes_read) {
		sscanf (temp, "%u / %u", current, length);
		return (0);
	}
	return (-1);
}

int
main (int argc, char **argv)
{
	unsigned int length = 1;
	unsigned int current = 0;

	while (1) {
		if (read_stat (&current, &length) == 0)
			/* print message in form [P 0.xxxxx]\n */
			printf ("[P %f]\n", (double) current / (double) length);
		usleep (PRINTOUT_INTERVAL * 1000000);
	}
}