#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/time.h>
#include "../include/asoundlib.h"
void show_status(void *handle)
{
int err;
fprintf(stderr,
"timer status %i (%s)\n", err,
snd_strerror(err));
return;
}
printf("STATUS:\n");
}
void read_loop(void *handle, int master_ticks, int timeout)
{
int count, err;
struct pollfd *fds;
fds = calloc(count, sizeof(struct pollfd));
if (fds == NULL) {
fprintf(stderr, "malloc error\n");
exit(EXIT_FAILURE);
}
while (master_ticks-- > 0) {
fprintf(stderr,
"snd_timer_poll_descriptors error: %s\n",
snd_strerror(err));
exit(EXIT_FAILURE);
}
if ((err = poll(fds, count, timeout)) < 0) {
fprintf(stderr, "poll error %i (%s)\n", err, strerror(err));
exit(EXIT_FAILURE);
}
if (err == 0) {
fprintf(stderr, "timer time out!!\n");
exit(EXIT_FAILURE);
}
printf("TIMER: resolution = %uns, ticks = %u\n",
}
}
free(fds);
}
{
printf("TIMER: resolution = %uns, ticks = %u\n",
}
(*acount)++;
}
int main(int argc, char *argv[])
{
int idx, err;
int card = 0;
int subdevice = 0;
int list = 0;
int async = 0;
int acount = 0;
char timername[64];
idx = 1;
while (idx < argc) {
if (!strncmp(argv[idx], "class=", 5)) {
class = atoi(argv[idx]+6);
} else if (!strncmp(argv[idx], "sclass=", 6)) {
sclass = atoi(argv[idx]+7);
} else if (!strncmp(argv[idx], "card=", 5)) {
card = atoi(argv[idx]+5);
} else if (!strncmp(argv[idx], "device=", 7)) {
device = atoi(argv[idx]+7);
} else if (!strncmp(argv[idx], "subdevice=", 10)) {
subdevice = atoi(argv[idx]+10);
} else if (!strcmp(argv[idx], "list")) {
list = 1;
} else if (!strcmp(argv[idx], "async")) {
async = 1;
}
idx++;
}
fprintf(stderr, "slave class is not set\n");
exit(EXIT_FAILURE);
}
if (list) {
fprintf(stderr,
"snd_timer_query_open error: %s\n",
snd_strerror(err));
exit(EXIT_FAILURE);
}
while (1) {
fprintf(stderr,
"timer next device error: %s\n",
snd_strerror(err));
break;
}
break;
printf("Timer device: class %i, sclass %i, card %i, device %i, subdevice %i\n",
}
exit(EXIT_SUCCESS);
}
sprintf(timername, "hw:CLASS=%i,SCLASS=%i,CARD=%i,DEV=%i,SUBDEV=%i", class, sclass, card, device, subdevice);
fprintf(stderr,
"timer open %i (%s)\n", err,
snd_strerror(err));
exit(EXIT_FAILURE);
}
printf("Using timer class %i, slave class %i, card %i, device %i, subdevice %i\n", class, sclass, card, device, subdevice);
fprintf(stderr,
"timer info %i (%s)\n", err,
snd_strerror(err));
exit(0);
}
printf("Timer info:\n");
} else {
}
fprintf(stderr,
"timer params %i (%s)\n", err,
snd_strerror(err));
exit(0);
}
show_status(handle);
if (async) {
if (err < 0) {
fprintf(stderr,
"unable to add async handler %i (%s)\n", err,
snd_strerror(err));
exit(EXIT_FAILURE);
}
}
fprintf(stderr,
"timer start %i (%s)\n", err,
snd_strerror(err));
exit(EXIT_FAILURE);
}
if (async) {
while (acount < 25)
sleep(1);
} else {
}
show_status(handle);
printf("Done\n");
return EXIT_SUCCESS;
}