Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/audio rename struct write_info as struct track_info, ...
details: https://anonhg.NetBSD.org/src/rev/71821180ba94
branches: trunk
changeset: 339709:71821180ba94
user: mrg <mrg%NetBSD.org@localhost>
date: Wed Aug 05 06:54:39 2015 +0000
description:
rename struct write_info as struct track_info, and the variable name 'wi'
as 'ti', as this info is useful for reading as well.
diffstat:
usr.bin/audio/common/audio.c | 28 +++++++-------
usr.bin/audio/common/libaudio.h | 22 ++++++------
usr.bin/audio/common/sun.c | 62 +++++++++++++++++-----------------
usr.bin/audio/common/wav.c | 68 ++++++++++++++++++------------------
usr.bin/audio/play/play.c | 24 ++++++------
usr.bin/audio/record/record.c | 74 ++++++++++++++++++++--------------------
6 files changed, 139 insertions(+), 139 deletions(-)
diffs (truncated from 823 to 300 lines):
diff -r 7fac1675ca45 -r 71821180ba94 usr.bin/audio/common/audio.c
--- a/usr.bin/audio/common/audio.c Wed Aug 05 06:50:44 2015 +0000
+++ b/usr.bin/audio/common/audio.c Wed Aug 05 06:54:39 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: audio.c,v 1.24 2015/06/21 06:06:01 mrg Exp $ */
+/* $NetBSD: audio.c,v 1.25 2015/08/05 06:54:39 mrg Exp $ */
/*
* Copyright (c) 1999 Matthew R. Green
@@ -32,7 +32,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: audio.c,v 1.24 2015/06/21 06:06:01 mrg Exp $");
+__RCSID("$NetBSD: audio.c,v 1.25 2015/08/05 06:54:39 mrg Exp $");
#endif
@@ -178,21 +178,21 @@
}
void
-write_header(struct write_info *wi)
+write_header(struct track_info *ti)
{
struct iovec iv[3];
int veclen, left, tlen;
void *hdr;
size_t hdrlen;
- switch (wi->format) {
+ switch (ti->format) {
case AUDIO_FORMAT_DEFAULT:
case AUDIO_FORMAT_SUN:
- if (sun_prepare_header(wi, &hdr, &hdrlen, &left) != 0)
+ if (sun_prepare_header(ti, &hdr, &hdrlen, &left) != 0)
return;
break;
case AUDIO_FORMAT_WAV:
- if (wav_prepare_header(wi, &hdr, &hdrlen, &left) != 0)
+ if (wav_prepare_header(ti, &hdr, &hdrlen, &left) != 0)
return;
break;
case AUDIO_FORMAT_NONE:
@@ -209,9 +209,9 @@
iv[veclen].iov_len = hdrlen;
tlen += iv[veclen++].iov_len;
}
- if (wi->header_info) {
- iv[veclen].iov_base = wi->header_info;
- iv[veclen].iov_len = (int)strlen(wi->header_info) + 1;
+ if (ti->header_info) {
+ iv[veclen].iov_base = ti->header_info;
+ iv[veclen].iov_len = (int)strlen(ti->header_info) + 1;
tlen += iv[veclen++].iov_len;
}
if (left) {
@@ -223,20 +223,20 @@
if (tlen == 0)
return;
- if (writev(wi->outfd, iv, veclen) != tlen)
+ if (writev(ti->outfd, iv, veclen) != tlen)
err(1, "could not write audio header");
}
write_conv_func
-write_get_conv_func(struct write_info *wi)
+write_get_conv_func(struct track_info *ti)
{
- switch (wi->format) {
+ switch (ti->format) {
case AUDIO_FORMAT_DEFAULT:
case AUDIO_FORMAT_SUN:
- return sun_write_get_conv_func(wi);
+ return sun_write_get_conv_func(ti);
case AUDIO_FORMAT_WAV:
- return wav_write_get_conv_func(wi);
+ return wav_write_get_conv_func(ti);
case AUDIO_FORMAT_NONE:
return NULL;
default:
diff -r 7fac1675ca45 -r 71821180ba94 usr.bin/audio/common/libaudio.h
--- a/usr.bin/audio/common/libaudio.h Wed Aug 05 06:50:44 2015 +0000
+++ b/usr.bin/audio/common/libaudio.h Wed Aug 05 06:54:39 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: libaudio.h,v 1.19 2014/12/30 01:22:09 mrg Exp $ */
+/* $NetBSD: libaudio.h,v 1.20 2015/08/05 06:54:39 mrg Exp $ */
/*
* Copyright (c) 1999, 2009 Matthew R. Green
@@ -157,7 +157,7 @@
} __packed wav_audiohdrextensible;
/* returns size of header, or -ve for failure */
-ssize_t audio_wav_parse_hdr (void *, size_t, u_int *, u_int *, u_int *, u_int *, size_t *);
+ssize_t audio_wav_parse_hdr (void *, size_t, u_int *, u_int *, u_int *, u_int *, off_t *);
extern int verbose;
@@ -185,34 +185,34 @@
void decode_encoding (const char *, int *);
/*
- * Write a sun/wav header, shared between record and merge.
+ * Track info, for reading/writing sun/wav header.
*
* Note that write_header() may change the values of format,
* encoding.
*/
-struct write_info {
+struct track_info {
int outfd;
char *header_info;
int format;
int encoding;
int precision;
int qflag;
- ssize_t total_size;
+ off_t total_size;
int sample_rate;
int channels;
};
typedef void (*write_conv_func) (u_char *, int);
-void write_header (struct write_info *);
-write_conv_func write_get_conv_func(struct write_info *);
+void write_header (struct track_info *);
+write_conv_func write_get_conv_func(struct track_info *);
/* backends for the above */
-int sun_prepare_header(struct write_info *wi, void **hdrp, size_t *lenp, int *leftp);
-int wav_prepare_header(struct write_info *wi, void **hdrp, size_t *lenp, int *leftp);
-write_conv_func sun_write_get_conv_func(struct write_info *wi);
-write_conv_func wav_write_get_conv_func(struct write_info *wi);
+int sun_prepare_header(struct track_info *ti, void **hdrp, size_t *lenp, int *leftp);
+int wav_prepare_header(struct track_info *ti, void **hdrp, size_t *lenp, int *leftp);
+write_conv_func sun_write_get_conv_func(struct track_info *ti);
+write_conv_func wav_write_get_conv_func(struct track_info *ti);
extern char audio_default_info[8];
diff -r 7fac1675ca45 -r 71821180ba94 usr.bin/audio/common/sun.c
--- a/usr.bin/audio/common/sun.c Wed Aug 05 06:50:44 2015 +0000
+++ b/usr.bin/audio/common/sun.c Wed Aug 05 06:54:39 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sun.c,v 1.8 2013/08/30 20:57:26 mrg Exp $ */
+/* $NetBSD: sun.c,v 1.9 2015/08/05 06:54:39 mrg Exp $ */
/*
* Copyright (c) 2002 Matthew R. Green
@@ -32,7 +32,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: sun.c,v 1.8 2013/08/30 20:57:26 mrg Exp $");
+__RCSID("$NetBSD: sun.c,v 1.9 2015/08/05 06:54:39 mrg Exp $");
#endif
@@ -110,76 +110,76 @@
}
int
-sun_prepare_header(struct write_info *wi, void **hdrp, size_t *lenp, int *leftp)
+sun_prepare_header(struct track_info *ti, void **hdrp, size_t *lenp, int *leftp)
{
static int warned = 0;
static sun_audioheader auh;
- int sunenc, oencoding = wi->encoding;
+ int sunenc, oencoding = ti->encoding;
/* only perform conversions if we don't specify the encoding */
- switch (wi->encoding) {
+ switch (ti->encoding) {
case AUDIO_ENCODING_ULINEAR_LE:
#if BYTE_ORDER == LITTLE_ENDIAN
case AUDIO_ENCODING_ULINEAR:
#endif
- if (wi->precision == 16 || wi->precision == 32)
- wi->encoding = AUDIO_ENCODING_SLINEAR_BE;
+ if (ti->precision == 16 || ti->precision == 32)
+ ti->encoding = AUDIO_ENCODING_SLINEAR_BE;
break;
case AUDIO_ENCODING_ULINEAR_BE:
#if BYTE_ORDER == BIG_ENDIAN
case AUDIO_ENCODING_ULINEAR:
#endif
- if (wi->precision == 16 || wi->precision == 32)
- wi->encoding = AUDIO_ENCODING_SLINEAR_BE;
+ if (ti->precision == 16 || ti->precision == 32)
+ ti->encoding = AUDIO_ENCODING_SLINEAR_BE;
break;
case AUDIO_ENCODING_SLINEAR_LE:
#if BYTE_ORDER == LITTLE_ENDIAN
case AUDIO_ENCODING_SLINEAR:
#endif
- if (wi->precision == 16 || wi->precision == 32)
- wi->encoding = AUDIO_ENCODING_SLINEAR_BE;
+ if (ti->precision == 16 || ti->precision == 32)
+ ti->encoding = AUDIO_ENCODING_SLINEAR_BE;
break;
#if BYTE_ORDER == BIG_ENDIAN
case AUDIO_ENCODING_SLINEAR:
- wi->encoding = AUDIO_ENCODING_SLINEAR_BE;
+ ti->encoding = AUDIO_ENCODING_SLINEAR_BE;
break;
#endif
}
/* if we can't express this as a Sun header, don't write any */
- if (audio_encoding_to_sun(wi->encoding, wi->precision, &sunenc) != 0) {
- if (!wi->qflag && !warned) {
+ if (audio_encoding_to_sun(ti->encoding, ti->precision, &sunenc) != 0) {
+ if (!ti->qflag && !warned) {
const char *s = audio_enc_from_val(oencoding);
if (s == NULL)
s = "(unknown)";
warnx("failed to convert to sun encoding from %s "
"(precision %d);\nSun audio header not written",
- s, wi->precision);
+ s, ti->precision);
}
- wi->format = AUDIO_FORMAT_NONE;
+ ti->format = AUDIO_FORMAT_NONE;
warned = 1;
return -1;
}
auh.magic = htonl(AUDIO_FILE_MAGIC);
- if (wi->outfd == STDOUT_FILENO)
+ if (ti->outfd == STDOUT_FILENO)
auh.data_size = htonl(AUDIO_UNKNOWN_SIZE);
- else if (wi->total_size != -1)
- auh.data_size = htonl(wi->total_size);
+ else if (ti->total_size != -1)
+ auh.data_size = htonl(ti->total_size);
else
auh.data_size = 0;
auh.encoding = htonl(sunenc);
- auh.sample_rate = htonl(wi->sample_rate);
- auh.channels = htonl(wi->channels);
- if (wi->header_info) {
+ auh.sample_rate = htonl(ti->sample_rate);
+ auh.channels = htonl(ti->channels);
+ if (ti->header_info) {
int len, infolen;
- infolen = ((len = strlen(wi->header_info)) + 7) & 0xfffffff8;
+ infolen = ((len = strlen(ti->header_info)) + 7) & 0xfffffff8;
*leftp = infolen - len;
auh.hdr_size = htonl(sizeof(auh) + infolen);
} else {
@@ -192,20 +192,20 @@
}
write_conv_func
-sun_write_get_conv_func(struct write_info *wi)
+sun_write_get_conv_func(struct track_info *ti)
{
write_conv_func conv_func = NULL;
/* only perform conversions if we don't specify the encoding */
- switch (wi->encoding) {
+ switch (ti->encoding) {
case AUDIO_ENCODING_ULINEAR_LE:
#if BYTE_ORDER == LITTLE_ENDIAN
case AUDIO_ENCODING_ULINEAR:
#endif
- if (wi->precision == 16)
+ if (ti->precision == 16)
conv_func = change_sign16_swap_bytes_le;
- else if (wi->precision == 32)
+ else if (ti->precision == 32)
conv_func = change_sign32_swap_bytes_le;
break;
@@ -213,9 +213,9 @@
#if BYTE_ORDER == BIG_ENDIAN
case AUDIO_ENCODING_ULINEAR:
#endif
- if (wi->precision == 16)
+ if (ti->precision == 16)
conv_func = change_sign16_be;
- else if (wi->precision == 32)
+ else if (ti->precision == 32)
conv_func = change_sign32_be;
break;
@@ -223,9 +223,9 @@
#if BYTE_ORDER == LITTLE_ENDIAN
Home |
Main Index |
Thread Index |
Old Index