File: async1.c

package info (click to toggle)
rplay 3.3.1-2
  • links: PTS
  • area: main
  • in suites: slink
  • size: 3,460 kB
  • ctags: 3,466
  • sloc: ansic: 41,361; makefile: 1,171; perl: 709; tcl: 345; sh: 294; java: 220
file content (44 lines) | stat: -rw-r--r-- 907 bytes parent folder | download
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
39
40
41
42
43
44
/* $Id: async1.c,v 1.2 1998/08/13 06:13:23 boyns Exp $ */

#include <rplay.h>

static void event_callback (int fd, int event, char *line);

main (int argc, char **argv)
{
    char buf[RPTP_MAX_LINE];
    int fd;

    fd = rptp_open (rplay_default_host (), RPTP_PORT, buf, sizeof (buf));

    rptp_async_notify (fd,
	RPTP_EVENT_PLAY|RPTP_EVENT_PAUSE|RPTP_EVENT_DONE|RPTP_EVENT_CONTINUE,
	event_callback);

    rptp_main_loop ();

    exit (0);
}

static void 
event_callback (int fd, int event, char *line)
{
    switch (event)
    {
    case RPTP_EVENT_PLAY:
	printf ("%s is playing\n", rptp_parse (line, "sound"));
	break;

    case RPTP_EVENT_PAUSE:
	printf ("%s is paused\n", rptp_parse (line, "sound"));
	break;

    case RPTP_EVENT_DONE:
	printf ("%s is done\n", rptp_parse (line, "sound"));
	break;

    case RPTP_EVENT_CONTINUE:
	printf ("%s continue\n", rptp_parse (line, "sound"));
	break;
    }
}