File: seq1.c

package info (click to toggle)
alsa-driver 1.0.23%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 28,448 kB
  • ctags: 77,491
  • sloc: ansic: 473,525; sh: 3,307; makefile: 2,661; python: 1,527; perl: 1,316; awk: 66
file content (25 lines) | stat: -rw-r--r-- 568 bytes parent folder | download | duplicates (5)
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
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <sys/time.h>
#include <linux/soundcard.h>

#define DEVICE "/dev/sequencer"

int main(void)
{
	int fd;
	ssize_t res;
	unsigned char ev[4];

	fd = open(DEVICE, O_RDWR);
	if (fd < 0) { perror( "open (" DEVICE ")" ); return EXIT_FAILURE; }
	while ((res = read(fd, &ev, sizeof(ev))) == sizeof(ev)) {
	  	printf("read event: bytes = 0x%x,0x%x,0x%x,0x%x\n", ev[0], ev[1], ev[2], ev[3]);
	}
	printf("end res = %li\n", (long)res);
	close(fd);
	return EXIT_SUCCESS;
}