/*
* Check for accessibility of a sound device
*/

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <sys/soundcard.h>

int main(int argc, char **argv)
{
   int fd;

   if (argc == 1) {
       fprintf(stderr, "usage: chkdsp device\n");
       return 1;
   }

   while ((fd = open(argv[1], O_WRONLY, 0)) < 0) {
       printf("0\n");
       usleep(100000);
   }

   close(fd);
   printf("1\n");
   return 0;
}