/* * Purpose: Utility to control the vmix subsystem of Open Sound System */ /* * * This file is part of Open Sound System. * * Copyright (C) 4Front Technologies 1996-2008. * * This this source file is released under GPL v2 license (no other versions). * See the COPYING file included in the main directory of this source * distribution for the license terms and conditions. * */ #include #include #include #include #include #include #include #include #include char *cmdname=NULL; #ifndef CONFIG_OSS_VMIX int main(int argc, char *argv[]) { fprintf (stderr, "%s: Virtual mixer is not included in this version of OSS\n", argv[0]); exit(1); } #else static void usage(void) { fprintf (stdout, "Usage:\n"); fprintf (stdout, "%s attach [attach_options...] devname\n", cmdname); fprintf (stdout, "%s attach [attach_options...] devname inputdev\n", cmdname); fprintf (stdout, "%s detach devname\n", cmdname); fprintf (stdout, "%s rate devname samplerate\n", cmdname); fprintf (stdout, "%s remap devname channels\n", cmdname); fprintf (stdout, "\n"); fprintf (stdout, "Use ossinfo -a to find out the devname and inputdev parameters\n"); fprintf (stdout, "Use ossinfo -a -v2 to find out a suitable sample rate.\n"); fprintf (stdout, "\n"); fprintf (stdout, "attach_options:\n"); fprintf (stdout, "\n"); fprintf (stdout, "\t-r\tDisable recording\n"); fprintf (stdout, "\t-p\tDo not preallocate client engines\n"); fprintf (stdout, "\t-M\tUse more fragments\n"); fprintf (stdout, "\t-V\tMake clients visible by creating device files for them.\n"); fprintf (stdout, "\t-c\tPrecreate client engines (see -p).\n"); exit(-1); } static int find_audiodev(char *fname, int mode, int *fd_) { int fd; oss_audioinfo ai; if ((fd=*fd_=open(fname, mode | O_EXCL, 0))==-1) { perror(fname); exit(-1); } ai.dev=-1; if (ioctl(fd, SNDCTL_ENGINEINFO, &ai)==-1) { perror("SNDCTL_ENGINEINFO"); fprintf (stderr, "Cannot get engine info for %s\n", fname); exit(-1); } return ai.dev; } static int vmix_attach(int argc, char **argv) { int masterfd, inputfd=-1; int masterdev, inputdev=-1; int c, n; int relink_devices = 0; extern int optind; extern char * optarg; vmixctl_attach_t att={0}; att.attach_flags = VMIX_INSTALL_MANUAL; /* * Simple command line switch handling. */ argv++;argc--; /* Skip the initial command ("attach") */ while ((c = getopt (argc, argv, "MVc:pr")) != EOF) { switch (c) { case 'r': /* No input */ att.attach_flags |= VMIX_INSTALL_NOINPUT; break; case 'p': /* No client engine preallocation */ att.attach_flags |= VMIX_INSTALL_NOPREALLOC; break; case 'V': /* Allocate private device files for all clients */ att.attach_flags |= VMIX_INSTALL_VISIBLE; relink_devices=1; break; case 'M': /* Use more fragments */ att.attach_flags |= VMIX_MULTIFRAG; break; case 'c': /* Force prealloc of N client devices */ n = atoi(optarg); if (n>255)n=255; if (n<0)n=0; att.attach_flags |= n; break; default: usage(); } } if (optind >= argc) usage(); masterdev=find_audiodev(argv[optind], O_WRONLY, &masterfd); optind++; if (optind