Retire -C, do all the ioctls on same audio device we do i/o
This commit is contained in:
parent
4aa2e3fde7
commit
ef0bbb2a55
@ -1,4 +1,4 @@
|
||||
.\" $NetBSD: audioplay.1,v 1.15 2002/01/15 09:21:35 wiz Exp $
|
||||
.\" $NetBSD: audioplay.1,v 1.16 2002/02/02 20:20:23 jdolecek Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1998-2002 Matthew R. Green
|
||||
.\" All rights reserved.
|
||||
@ -39,7 +39,6 @@
|
||||
.Op Fl b Ar balance
|
||||
.Op Fl p Ar port
|
||||
.Op Fl d Ar device
|
||||
.Op Fl C Ar ctl
|
||||
.Oo
|
||||
.Fl f
|
||||
.Op Fl c Ar channels
|
||||
@ -90,11 +89,6 @@ Set the audio device to be
|
||||
.Ar device .
|
||||
The default is
|
||||
.Pa /dev/audio0 .
|
||||
.It Fl C
|
||||
Set the audio control device to be
|
||||
.Ar ctl .
|
||||
The default is
|
||||
.Pa /dev/audioctl0 .
|
||||
.It Fl f
|
||||
Force playing, even if the format is unknown. The
|
||||
.Fl f
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: play.c,v 1.33 2002/01/31 00:33:10 augustss Exp $ */
|
||||
/* $NetBSD: play.c,v 1.34 2002/02/02 20:20:24 jdolecek Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1999 Matthew R. Green
|
||||
@ -68,7 +68,7 @@ int channels;
|
||||
|
||||
char const *play_errstring = NULL;
|
||||
size_t bufsize;
|
||||
int audiofd, ctlfd;
|
||||
int audiofd;
|
||||
int exitstatus = EXIT_SUCCESS;
|
||||
|
||||
int
|
||||
@ -80,7 +80,6 @@ main(argc, argv)
|
||||
int ch;
|
||||
int iflag = 0;
|
||||
const char *device = NULL;
|
||||
const char *ctldev = NULL;
|
||||
|
||||
while ((ch = getopt(argc, argv, "b:C:c:d:e:fhip:P:qs:Vv:")) != -1) {
|
||||
switch (ch) {
|
||||
@ -95,7 +94,7 @@ main(argc, argv)
|
||||
errx(1, "channels must be positive");
|
||||
break;
|
||||
case 'C':
|
||||
ctldev = optarg;
|
||||
/* Ignore, compatibility */
|
||||
break;
|
||||
case 'd':
|
||||
device = optarg;
|
||||
@ -163,23 +162,17 @@ main(argc, argv)
|
||||
if (device == NULL && (device = getenv("AUDIODEVICE")) == NULL &&
|
||||
(device = getenv("AUDIODEV")) == NULL) /* Sun compatibility */
|
||||
device = _PATH_SOUND;
|
||||
if (ctldev == NULL && (ctldev = getenv("AUDIOCTLDEVICE")) == NULL)
|
||||
ctldev = _PATH_AUDIOCTL;
|
||||
|
||||
audiofd = open(device, O_WRONLY);
|
||||
if (audiofd < 0 && device == _PATH_SOUND) {
|
||||
device = _PATH_SOUND0;
|
||||
ctldev = _PATH_AUDIOCTL0;
|
||||
audiofd = open(device, O_WRONLY);
|
||||
}
|
||||
|
||||
if (audiofd < 0)
|
||||
err(1, "failed to open %s", device);
|
||||
ctlfd = open(ctldev, O_RDWR);
|
||||
if (ctlfd < 0)
|
||||
err(1, "failed to open %s", ctldev);
|
||||
|
||||
if (ioctl(ctlfd, AUDIO_GETINFO, &info) < 0)
|
||||
if (ioctl(audiofd, AUDIO_GETINFO, &info) < 0)
|
||||
err(1, "failed to get audio info");
|
||||
bufsize = info.play.buffer_size;
|
||||
if (bufsize < 32 * 1024)
|
||||
@ -206,7 +199,7 @@ cleanup(signo)
|
||||
|
||||
close(audiofd);
|
||||
(void)ioctl(audiofd, AUDIO_FLUSH, NULL);
|
||||
(void)ioctl(ctlfd, AUDIO_SETINFO, &info);
|
||||
(void)ioctl(audiofd, AUDIO_SETINFO, &info);
|
||||
exit(exitstatus);
|
||||
}
|
||||
|
||||
@ -264,7 +257,7 @@ play(file)
|
||||
* get the header length and set up the audio device
|
||||
*/
|
||||
if ((hdrlen = audioctl_write_fromhdr(addr,
|
||||
(size_t)filesize, ctlfd, &datasize)) < 0) {
|
||||
(size_t)filesize, audiofd, &datasize)) < 0) {
|
||||
if (play_errstring)
|
||||
errx(1, "%s: %s", play_errstring, file);
|
||||
else
|
||||
@ -320,7 +313,7 @@ play_fd(file, fd)
|
||||
return;
|
||||
err(1, "unexpected EOF");
|
||||
}
|
||||
hdrlen = audioctl_write_fromhdr(buffer, nr, ctlfd, &datasize);
|
||||
hdrlen = audioctl_write_fromhdr(buffer, nr, audiofd, &datasize);
|
||||
if (hdrlen < 0) {
|
||||
if (play_errstring)
|
||||
errx(1, "%s: %s", play_errstring, file);
|
||||
|
@ -1,4 +1,4 @@
|
||||
.\" $NetBSD: audiorecord.1,v 1.22 2002/01/25 15:35:32 mrg Exp $
|
||||
.\" $NetBSD: audiorecord.1,v 1.23 2002/02/02 20:20:25 jdolecek Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1998-1999 Matthew R. Green
|
||||
.\" All rights reserved.
|
||||
@ -36,7 +36,6 @@
|
||||
.Nm
|
||||
.Op Fl afhV
|
||||
.Op Fl b Ar balance
|
||||
.Op Fl C Ar ctl
|
||||
.Op Fl F Ar format
|
||||
.Op Fl c Ar channels
|
||||
.Op Fl d Ar device
|
||||
@ -69,11 +68,6 @@ Append to the specified file, rather than overwriting.
|
||||
Set the balance to
|
||||
.Ar balance .
|
||||
This value must be between 0 and 63.
|
||||
.It Fl C
|
||||
Set the audio control device to be
|
||||
.Ar ctl .
|
||||
The default is
|
||||
.Pa /dev/audioctl0 .
|
||||
.It Fl F
|
||||
Set the output header format to
|
||||
.Ar format .
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: record.c,v 1.22 2002/01/31 00:03:24 augustss Exp $ */
|
||||
/* $NetBSD: record.c,v 1.23 2002/02/02 20:20:26 jdolecek Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1999 Matthew R. Green
|
||||
@ -53,11 +53,10 @@
|
||||
audio_info_t info, oinfo;
|
||||
ssize_t total_size = -1;
|
||||
const char *device;
|
||||
const char *ctldev;
|
||||
int format = AUDIO_FORMAT_SUN;
|
||||
char *header_info;
|
||||
char default_info[8] = { '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0' };
|
||||
int audiofd, ctlfd, outfd;
|
||||
int audiofd, outfd;
|
||||
int qflag, aflag, fflag;
|
||||
int verbose;
|
||||
int monitor_gain, omonitor_gain;
|
||||
@ -103,7 +102,7 @@ main(argc, argv)
|
||||
errx(1, "balance must be between 0 and 63\n");
|
||||
break;
|
||||
case 'C':
|
||||
ctldev = optarg;
|
||||
/* Ignore, compatibility */
|
||||
break;
|
||||
case 'F':
|
||||
format = audio_format_from_str(optarg);
|
||||
@ -189,26 +188,20 @@ main(argc, argv)
|
||||
if (device == NULL && (device = getenv("AUDIODEVICE")) == NULL &&
|
||||
(device = getenv("AUDIODEV")) == NULL) /* Sun compatibility */
|
||||
device = _PATH_SOUND;
|
||||
if (ctldev == NULL && (ctldev = getenv("AUDIOCTLDEVICE")) == NULL)
|
||||
ctldev = _PATH_AUDIOCTL;
|
||||
|
||||
audiofd = open(device, O_RDONLY);
|
||||
if (audiofd < 0 && device == _PATH_SOUND) {
|
||||
device = _PATH_SOUND0;
|
||||
ctldev = _PATH_AUDIOCTL0;
|
||||
audiofd = open(device, O_WRONLY);
|
||||
}
|
||||
if (audiofd < 0)
|
||||
err(1, "failed to open %s", device);
|
||||
ctlfd = open(ctldev, O_RDWR);
|
||||
if (ctlfd < 0)
|
||||
err(1, "failed to open %s", ctldev);
|
||||
|
||||
/*
|
||||
* work out the buffer size to use, and allocate it. also work out
|
||||
* what the old monitor gain value is, so that we can reset it later.
|
||||
*/
|
||||
if (ioctl(ctlfd, AUDIO_GETINFO, &oinfo) < 0)
|
||||
if (ioctl(audiofd, AUDIO_GETINFO, &oinfo) < 0)
|
||||
err(1, "failed to get audio info");
|
||||
bufsize = oinfo.record.buffer_size;
|
||||
if (bufsize < 32 * 1024)
|
||||
@ -266,7 +259,7 @@ main(argc, argv)
|
||||
monitor_gain = oinfo.monitor_gain;
|
||||
|
||||
info.mode = AUMODE_RECORD;
|
||||
if (ioctl(ctlfd, AUDIO_SETINFO, &info) < 0)
|
||||
if (ioctl(audiofd, AUDIO_SETINFO, &info) < 0)
|
||||
err(1, "failed to reset audio info");
|
||||
|
||||
signal(SIGINT, cleanup);
|
||||
@ -305,16 +298,15 @@ cleanup(signo)
|
||||
int signo;
|
||||
{
|
||||
|
||||
close(audiofd);
|
||||
rewrite_header();
|
||||
close(outfd);
|
||||
if (omonitor_gain) {
|
||||
AUDIO_INITINFO(&info);
|
||||
info.monitor_gain = omonitor_gain;
|
||||
if (ioctl(ctlfd, AUDIO_SETINFO, &info) < 0)
|
||||
if (ioctl(audiofd, AUDIO_SETINFO, &info) < 0)
|
||||
err(1, "failed to reset audio info");
|
||||
}
|
||||
close(ctlfd);
|
||||
close(audiofd);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
@ -655,7 +647,6 @@ usage()
|
||||
fprintf(stderr, "Usage: %s [-afhqV] [options] {files ...|-}\n",
|
||||
getprogname());
|
||||
fprintf(stderr, "Options:\n\t"
|
||||
"-C audio control device\n\t"
|
||||
"-F format\n\t"
|
||||
"-b balance (0-63)\n\t"
|
||||
"-c channels\n\t"
|
||||
|
Loading…
Reference in New Issue
Block a user