Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/audio add a new "-B buffersize" flag to both audiopl...
details: https://anonhg.NetBSD.org/src/rev/94618103d712
branches: trunk
changeset: 760157:94618103d712
user: mrg <mrg%NetBSD.org@localhost>
date: Wed Dec 29 13:09:03 2010 +0000
description:
add a new "-B buffersize" flag to both audioplay and audiorecord.
suggested by jmcneill@.
sort audioplay manual some.
diffstat:
usr.bin/audio/play/audioplay.1 | 59 ++++++++++++++++++++-----------------
usr.bin/audio/play/play.c | 23 ++++++++------
usr.bin/audio/record/audiorecord.1 | 11 +++++-
usr.bin/audio/record/record.c | 24 ++++++++-------
4 files changed, 66 insertions(+), 51 deletions(-)
diffs (truncated from 318 to 300 lines):
diff -r 8efed1bad2f4 -r 94618103d712 usr.bin/audio/play/audioplay.1
--- a/usr.bin/audio/play/audioplay.1 Wed Dec 29 13:05:42 2010 +0000
+++ b/usr.bin/audio/play/audioplay.1 Wed Dec 29 13:09:03 2010 +0000
@@ -1,6 +1,6 @@
-.\" $NetBSD: audioplay.1,v 1.21 2008/05/29 14:51:27 mrg Exp $
+.\" $NetBSD: audioplay.1,v 1.22 2010/12/29 13:09:03 mrg Exp $
.\"
-.\" Copyright (c) 1998-2002 Matthew R. Green
+.\" Copyright (c) 1998, 1999, 2002, 2010 Matthew R. Green
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
@@ -24,7 +24,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd January 13, 2002
+.Dd December 30, 2010
.Dt AUDIOPLAY 1
.Os
.Sh NAME
@@ -32,11 +32,12 @@
.Nd play audio files
.Sh SYNOPSIS
.Nm
-.Op Fl iqVh
-.Op Fl v Ar volume
+.Op Fl hiqV
.Op Fl b Ar balance
+.Op Fl B Ar buffersize
+.Op Fl d Ar device
.Op Fl p Ar port
-.Op Fl d Ar device
+.Op Fl v Ar volume
.Oo
.Fl f
.Op Fl c Ar channels
@@ -58,22 +59,23 @@
.Sh OPTIONS
The following options are available:
.Bl -tag -width 123456
-.It Fl i
-If the audio device cannot be opened, exit now rather than wait for it.
-.It Fl q
-Be quiet.
-.It Fl V
-Be verbose.
-.It Fl h
-Print a help message.
-.It Fl v
-Set the volume (gain) to
-.Ar volume .
-This value must be between 0 and 255.
.It Fl b
Set the balance to
.Ar balance .
This value must be between 0 and 63.
+.It Fl B
+Set the write block size to
+.Ar buffersize .
+The default value is the play.buffer_size of the audio device.
+.It Fl d
+Set the audio device to be
+.Ar device .
+The default is
+.Pa /dev/sound .
+.It Fl h
+Print a help message.
+.It Fl i
+If the audio device cannot be opened, exit now rather than wait for it.
.It Fl p
Set the output port to
.Ar port .
@@ -84,11 +86,14 @@
.Dq headphone
and
.Dq line .
-.It Fl d
-Set the audio device to be
-.Ar device .
-The default is
-.Pa /dev/sound .
+.It Fl q
+Be quiet.
+.It Fl v
+Set the volume (gain) to
+.Ar volume .
+This value must be between 0 and 255.
+.It Fl V
+Be verbose.
.It Fl f
Force playing, even if the format is unknown.
The
@@ -97,11 +102,11 @@
change the number of channels, encoding, precision and
sample rate.
.It Fl c
-when combined with the
+When combined with the
.Fl f
option, sets the number of channels to its argument.
.It Fl e
-when combined with the
+When combined with the
.Fl f
option, sets the encoding to its argument.
Possible values are
@@ -127,12 +132,12 @@
and
.Cm mpeg_l2_system .
.It Fl P
-when combined with the
+When combined with the
.Fl f
option, sets the precision to its argument.
This value must be either 4, 8, 16, 24 or 32.
.It Fl s
-when combined with the
+When combined with the
.Fl f
option, sets the sample rate to its argument.
This value must be a valid value for the audio device or an error will
diff -r 8efed1bad2f4 -r 94618103d712 usr.bin/audio/play/play.c
--- a/usr.bin/audio/play/play.c Wed Dec 29 13:05:42 2010 +0000
+++ b/usr.bin/audio/play/play.c Wed Dec 29 13:09:03 2010 +0000
@@ -1,7 +1,7 @@
-/* $NetBSD: play.c,v 1.50 2009/04/11 10:43:09 lukem Exp $ */
+/* $NetBSD: play.c,v 1.51 2010/12/29 13:09:03 mrg Exp $ */
/*
- * Copyright (c) 1999 Matthew R. Green
+ * Copyright (c) 1999, 2000, 2001, 2002, 2010 Matthew R. Green
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -28,7 +28,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: play.c,v 1.50 2009/04/11 10:43:09 lukem Exp $");
+__RCSID("$NetBSD: play.c,v 1.51 2010/12/29 13:09:03 mrg Exp $");
#endif
@@ -87,13 +87,17 @@
const char *defdevice = _PATH_SOUND;
const char *device = NULL;
- while ((ch = getopt(argc, argv, "b:C:c:d:e:fhip:P:qs:Vv:")) != -1) {
+ while ((ch = getopt(argc, argv, "b:B:C:c:d:e:fhip:P:qs:Vv:")) != -1) {
switch (ch) {
case 'b':
decode_int(optarg, &balance);
if (balance < 0 || balance > 64)
errx(1, "balance must be between 0 and 63");
break;
+ case 'B':
+ bufsize = strsuftoll("write buffer size", optarg,
+ 1, UINT_MAX);
+ break;
case 'c':
decode_int(optarg, &channels);
if (channels < 0)
@@ -180,7 +184,8 @@
if (ioctl(audiofd, AUDIO_GETINFO, &info) < 0)
err(1, "failed to get audio info");
- bufsize = info.play.buffer_size;
+ if (bufsize == 0)
+ bufsize = info.play.buffer_size;
if (bufsize < 32 * 1024)
bufsize = 32 * 1024;
@@ -258,11 +263,9 @@
/*
* give the VM system a bit of a hint about the type
- * of accesses we will make.
+ * of accesses we will make. we don't care about errors.
*/
- if (madvise(addr, sizet_filesize, MADV_SEQUENTIAL) < 0 &&
- !qflag)
- warn("madvise failed, ignoring");
+ madvise(addr, sizet_filesize, MADV_SEQUENTIAL);
/*
* get the header length and set up the audio device
@@ -470,8 +473,8 @@
fprintf(stderr, "Usage: %s [-hiqV] [options] files\n", getprogname());
fprintf(stderr, "Options:\n\t"
- "-C audio control device\n\t"
"-b balance (0-63)\n\t"
+ "-B buffer size\n\t"
"-d audio device\n\t"
"-f force settings\n\t"
"\t-c forced channels\n\t"
diff -r 8efed1bad2f4 -r 94618103d712 usr.bin/audio/record/audiorecord.1
--- a/usr.bin/audio/record/audiorecord.1 Wed Dec 29 13:05:42 2010 +0000
+++ b/usr.bin/audio/record/audiorecord.1 Wed Dec 29 13:09:03 2010 +0000
@@ -1,6 +1,6 @@
-.\" $NetBSD: audiorecord.1,v 1.38 2009/07/02 04:45:27 mrg Exp $
+.\" $NetBSD: audiorecord.1,v 1.39 2010/12/29 13:09:03 mrg Exp $
.\"
-.\" Copyright (c) 1998-1999 Matthew R. Green
+.\" Copyright (c) 1998, 1999, 2001, 2002, 2010 Matthew R. Green
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
@@ -24,7 +24,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd October 13, 2002
+.Dd December 30, 2010
.Dt AUDIORECORD 1
.Os
.Sh NAME
@@ -34,6 +34,7 @@
.Nm
.Op Fl afhqV
.Op Fl b Ar balance
+.Op Fl B Ar buffersize
.Op Fl c Ar channels
.Op Fl d Ar device
.Op Fl e Ar encoding
@@ -73,6 +74,10 @@
Set the balance to
.Ar balance .
This value must be between 0 and 63.
+.It Fl B Ar buffersize
+Set the audio device read buffer size to
+.Ar buffersize .
+The default value is the record.buffer_size of the audio device.
.It Fl c Ar channels
Set number of channels to
.Ar channels .
diff -r 8efed1bad2f4 -r 94618103d712 usr.bin/audio/record/record.c
--- a/usr.bin/audio/record/record.c Wed Dec 29 13:05:42 2010 +0000
+++ b/usr.bin/audio/record/record.c Wed Dec 29 13:09:03 2010 +0000
@@ -1,7 +1,7 @@
-/* $NetBSD: record.c,v 1.47 2009/04/11 10:43:10 lukem Exp $ */
+/* $NetBSD: record.c,v 1.48 2010/12/29 13:09:03 mrg Exp $ */
/*
- * Copyright (c) 1999, 2002 Matthew R. Green
+ * Copyright (c) 1999, 2002, 2003, 2005, 2010 Matthew R. Green
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -32,11 +32,11 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: record.c,v 1.47 2009/04/11 10:43:10 lukem Exp $");
+__RCSID("$NetBSD: record.c,v 1.48 2010/12/29 13:09:03 mrg Exp $");
#endif
-#include <sys/types.h>
+#include <sys/param.h>
#include <sys/audioio.h>
#include <sys/ioctl.h>
#include <sys/time.h>
@@ -93,11 +93,11 @@
char *argv[];
{
u_char *buffer;
- size_t len, bufsize;
+ size_t len, bufsize = 0;
int ch, no_time_limit = 1;
const char *defdevice = _PATH_SOUND;
- while ((ch = getopt(argc, argv, "ab:C:F:c:d:e:fhi:m:P:p:qt:s:Vv:")) != -1) {
+ while ((ch = getopt(argc, argv, "ab:B:C:F:c:d:e:fhi:m:P:p:qt:s:Vv:")) != -1) {
switch (ch) {
case 'a':
aflag++;
@@ -107,6 +107,10 @@
if (balance < 0 || balance > 63)
errx(1, "balance must be between 0 and 63");
break;
+ case 'B':
+ bufsize = strsuftoll("read buffer size", optarg,
+ 1, UINT_MAX);
+ break;
case 'C':
/* Ignore, compatibility */
break;
@@ -199,10 +203,6 @@
if (encoding == -1)
errx(1, "unknown encoding, bailing...");
}
-#if 0
- else
- encoding = AUDIO_ENCODING_ULAW;
-#endif
/*
* open the output file
Home |
Main Index |
Thread Index |
Old Index