/*
  This (simple) code was written by Iain Thomas, and is therefore Copyright 2000, Iain Thomas.
  This code may be used subject to the terms of the GNU General Public Licence.
  Visit http://www.gnu.org for more information, and a copy of the licence.
  This code is supplied in the hope that it might be useful to others, however, I provide NO WARRANTIES
  whatsoever, nor do I claim it actually does anything useful.
  It's not particularly clean, but seems to work.

  Notes: Only works on Solaris 8 (it may work on other versions).
         Only tested on Sun Ultra 5 hardware (I can't say it'll even run on other hardware).
  Purpose: Sets volume to n, where n is from 0 to 255. No error checking is done. (so it's probably UNSAFE)
  Use: vol n > /dev/audioctl
  Compile: gcc -o vol vol.c
  Other info: man audio (under Solaris).
              Extending this can be your project- it does what I need, namely set the main output level in a
scriptable sense, and directs the ioctl at stdout.
*/

#include <sys/audioio.h>

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

  if(argc <= 1 || argc > 2)
    {
      printf("Use %s (0-255)\n", argv[0]);
      return 1;
    }
  else
    {
      audio_info_t    info;
      AUDIO_INITINFO(&info);
      info.play.gain = atoi(argv[1]);
      errorCode = ioctl(1, AUDIO_SETINFO, &info);
      return errorCode;
    }
}
