audio_clean.c revision 7883e825152992a0f20c3f52f7c4bb902a56205c
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* audio_clean - Clear any residual data that may be residing in the in the
* audio device driver or chip.
*
* Usage: audio_clean [-Iisf] device_name
*
* Note: The same operation is performed for any of the "ifs" flags.
* The "I" flag is a silent form of "i". Support for the flags
* is provided so that the framework is place if added
* functionality is required.
*
* Note: The AUDIO_SETINFO ioctl is used instead of the low level
* AUDIOSETREG command which is used to perform low level
* operations on the device. If a process had previously used
* AUDIOSETREG to monkey with the device, then the driver would
* have reset the chip when the process performed a close,
* so this can just clear the info structure.
*/
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
#include <libintl.h>
#include <locale.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stropts.h>
#include <unistd.h>
#ifndef TEXT_DOMAIN
#define TEXT_DOMAIN "SUNW_OST_OSCMD"
#endif
#define BUF_SIZE 512
#ifdef DEBUG
static void print_info(audio_info_t *);
static void print_prinfo(audio_prinfo_t *);
#endif /* DEBUG */
static void
{
if (verbose)
}
/*
* Return the first substring in string before the ':' in "item"
*/
static void
{
while (*item != ':')
item++;
*item = 0;
}
int
{
int err = 0;
int i;
char *prog;
int Audio_fd;
int forced = 0; /* Command line options */
int initial = 0;
int standard = 0;
(void) textdomain(TEXT_DOMAIN);
/*
* Parse arguments. Currently i, s and f all do the
* the same thing.
*/
switch (i) {
case 'I':
verbose = 0;
initial++;
err++;
break;
case 'i':
initial++;
err++;
break;
case 's':
standard++;
err++;
break;
case 'f':
forced++;
err++;
break;
case '?':
err++;
break;
}
if (err) {
exit(1);
}
}
exit(1);
}
argv[0]);
exit(1);
}
if (verbose)
cmd_str);
exit(1);
}
if (verbose)
cmd_str);
exit(1);
}
/*
* Validate and open the audio device
*/
if (err < 0) {
if (verbose) {
prog);
perror("audio_clean");
}
exit(1);
}
if (verbose)
exit(1);
}
/*
* using it we check to see if we're going to hang before we
* do anything.
*/
/* Try it quickly, first */
if (verbose)
/* Now hang until it's open */
if (Audio_fd < 0) {
if (verbose)
exit(1);
}
} else if (Audio_fd < 0) {
if (verbose) {
prog);
}
exit(1);
}
#ifdef DEBUG
/*
* Read the audio_info structure.
*/
perror("Ioctl AUDIO_GETINFO error");
exit(1);
}
print_info(&info);
#endif /* DEBUG */
/* LINTED */
if (verbose)
exit(1);
}
#ifdef DEBUG
perror("Ioctl AUDIO_GETINFO-2 error");
exit(1);
}
print_info(&info);
#endif /* DEBUG */
return (0);
}
#ifdef DEBUG
void
{
}
void
{
/* The following values decribe audio data encoding: */
/* The following values control audio device configuration */
/* These are Reserved for future use, but we clear them */
/* The following values describe driver state */
/* The following values are read-only state flags */
}
#endif /* DEBUG */