Commit Graph

247 Commits

Author SHA1 Message Date
Alexandre Ratchov c4b354abd7 Fix off-by-one array access when 64 channel stream is resampled 2021-07-05 14:18:53 +02:00
Alexandre Ratchov 1f42a21368 Drop assembly for 24-bit fixed-point operations
Now i386 compiler is smart enough to generate a single imul
instruction per fixed-point multiplication. This change also allows
24-bit precision to be used on all archs (if -DADATA_BITS=24 is used).

Tested on arm64 by Doug Moss <dougmoss710 at yahoo.com>, thanks

Suggested and ok naddy@
2021-05-31 15:08:02 +02:00
Alexandre Ratchov b1c2df5d9c aucat, sndiod: const-ify lookup tables
From naddy@
2021-01-13 17:30:19 +01:00
Alexandre Ratchov 21580f56b5 Clip 16-bit resampled signal as there's no room for filter overshoots 2021-01-11 14:46:32 +01:00
Alexandre Ratchov 2996dcdc03 Use a 8-th order FIR low-pass filter for resampling 2020-12-20 11:01:27 +01:00
Alexandre Ratchov 40cdc42e22 Check sample signedness when setting up format conversions.
Fixes confusion between s16 and u16 found in aucat and analysed by
James Cook <falsifian at falsifian.org>. Thanks.
2020-12-10 22:05:56 +01:00
Alexandre Ratchov 0f21b42d41 mixerctl and audioctl moved to section 8 2020-04-24 08:56:27 +02:00
Alexandre Ratchov 3be156f2f0 Rename WAV_H "include guard" macro of afile.h to AFILE_H
Fix from Jan Stary <hans at stare.cz>, thanks.
2020-02-09 23:47:30 +01:00
Alexandre Ratchov 50ccf31dd8 Crank max number of channels to 64. 2019-07-28 11:23:56 +02:00
Alexandre Ratchov 98d4c00b6a Fix comments and few debug printfs in utils.c. 2019-07-02 08:09:31 +02:00
Alexandre Ratchov 42a25f2ca4 Factor audio buffer allocation into a dedicated allocbuf routine. 2019-07-01 09:20:33 +02:00
Alexandre Ratchov 934e1611e8 Check return values of syscalls against -1, from deraadt@. 2019-07-01 09:20:22 +02:00
Alexandre Ratchov e6587d3b97 Fix integer multiplication overflow in block size calculation. 2019-05-17 07:25:16 +02:00
Alexandre Ratchov d428027573 Tweak a space to reduce diff with OpenBSD. 2019-02-21 07:42:20 +01:00
Alexandre Ratchov 2799f8975e aucat: Fix clipping during float to integer conversions.
From Jari Vetoniemi <mailroxas at gmail.com>. Thanks!
2018-11-07 22:23:18 +01:00
Alexandre Ratchov 471495bd21 Clear resamp state array with memset. From miko@. 2018-09-26 13:36:42 +02:00
Alexandre Ratchov 99357b1841 aucat: remove useless variable assignments in .au header parsing code.
From Michael W. Bombardieri, thanks.
2017-11-23 07:32:25 +01:00
Alexandre Ratchov bb63198e8b prefill with silence the buffer when cmap_copy() stores samples
rather than the slot/client buffer. Fixes initialized data being
treated as recorded samples when resampling and/or format
conversions are involved.
2017-11-07 12:26:46 +01:00
Alexandre Ratchov b06285beda Prefill with silence rec buffer.
This is necessary as certain channels may not receive samples,
for instance when mono->stereo conversion is disabled.
2017-11-03 16:10:48 +01:00
Alexandre Ratchov 98b2feaca0 Fix typos. From Michael W. Bombardieri <mb at ii.net>. Thanks! 2017-07-20 12:49:31 +02:00
Alexandre Ratchov 258faa30f7 Fix int overflow that causes >12hour files to not properly relocate. 2017-07-20 11:10:13 +02:00
Alexandre Ratchov f6579c4341 Use the right header sizes for reading .aiff and .au files.
From nicm@.
2017-03-27 13:58:46 +02:00
Alexandre Ratchov 2f5165d92f sync utils.c to sndiod one 2017-01-03 08:20:49 +01:00
Alexandre Ratchov 6c1c0d3ff6 Remove unnecessary includes. From Michael W. Bombardieri <mb at ii.net>. 2017-01-03 08:05:41 +01:00
Alexandre Ratchov 474ac8d426 log file volume 2017-01-03 07:28:52 +01:00
Alexandre Ratchov 7061de0250 Set device rate to calculated rate. 2016-09-30 11:01:25 +02:00
Alexandre Ratchov 2a451f9623 Fix many typos, from Michael W. Bombardieri <mb at ii.net>, thanks 2016-09-27 14:18:43 +02:00
Alexandre Ratchov 7ddb1a5fe5 Don't rely on the resampling code to calculate the number of samples
to process, as it may produce one extra sample (to handle accumulation
of fractional samples), which would cause access to one sample past
the end of the buffer and crash aucat. Fix this by limiting the number
of samples processed to a single block.

Found by and help from Michael W. Bombardieri <mb at ii.net>. Thanks.
2016-09-27 09:01:21 +02:00
Alexandre Ratchov 61005799d9 simpler resampler 2016-06-09 16:50:56 +02:00
Alexandre Ratchov 10f6027f0f remove unused fields of resamp structure 2016-06-09 16:43:47 +02:00
Alexandre Ratchov 00ffc8f5ab Add resamp_getcnt() routine to calculate the exact number of samples
that would be consumed and produced by the sampler rate converter. Use
it to avoid partial samples that are not properly handled. Fixes
last samples of certain files causing aucat to abort.
2016-06-07 08:11:46 +02:00
Alexandre Ratchov 2562fa7eb4 add -g and -p option to control device and file start position 2016-06-02 18:14:10 +02:00
Alexandre Ratchov a6fdc3b5ed remove forgotten debug printfs 2016-06-02 07:30:30 +02:00
Alexandre Ratchov 474f0ce009 set exit status to 1 if -n is used without -i and -o 2016-06-02 07:07:58 +02:00
Alexandre Ratchov c22cfa6294 sync to openbsd: remove again intermediate conversion to mtc time 2016-06-02 06:55:59 +02:00
Alexandre Ratchov aaf9583451 backout latest 2016-05-31 23:25:38 +02:00
Alexandre Ratchov 751fe73f18 backout mtc units removal 2016-05-31 23:21:15 +02:00
Alexandre Ratchov 2ce73a1421 Pass hr:min:sec:frame.cent to dev_mmcloc() and remove useless
intermediate conversion to 2400-th of second.
2016-05-31 11:24:42 +02:00
Alexandre Ratchov 0798868306 To store MMC position, use samples (at device rate) as time units
instead of 2400-ths of second. No behaviour change.
2016-05-31 10:37:17 +02:00
Alexandre Ratchov e606351421 Fix file block size rounding and ensure it's large enough to store a
full audio block.
2016-05-28 09:28:57 +02:00
Alexandre Ratchov 028bb6e60d When resampling, use the exact resampling factor instead of the ration
between input and output block sizes.  This was inherited from sndion,
but is not required for files because they are continuous streams of
samples and do not need to be split in blocks of equal duration.

This change makes playback/recording rate match exactly the requested
sample rate.
2016-05-27 18:17:05 +02:00
Alexandre Ratchov b347c52869 Flush rec buffer if there's less than one block space left and fill
play buffer if there's less than one block of data left. No behaviour
change, as all input/output are still block-aligned.
2016-05-27 18:00:23 +02:00
Alexandre Ratchov 06c8f4e89f Simplify slot_fill() and slot_flush(). No behaviour change 2016-05-27 17:46:09 +02:00
Alexandre Ratchov 4772005ac1 Give the resamp_do() the exact number input and output samples and
provide routines to calculate them. This way we don't rely on it
anymore to calculate the bytes procuded/consumed. No behaviour change.
2016-05-27 17:36:53 +02:00
Alexandre Ratchov a6ea35ebb3 Make format conversion routines return the number of frames
consumed on both input and output. No behaviour change.
2016-05-26 08:16:17 +02:00
Alexandre Ratchov d6bc5ae04f Check that byte order is native only if we're using more than one
byte per sample, check the samples are lsb-aligned only if there's
padding.
2016-01-29 17:20:34 +01:00
Alexandre Ratchov 6436780b57 fit in 80 columns, trailing spaces, tabs 2016-01-09 09:49:55 +01:00
Alexandre Ratchov 97bf660690 fit in 80 columns, trailing spaces, tabs 2016-01-09 09:35:54 +01:00
Alexandre Ratchov aa4fc43964 move sndiod manual to sec 8 2016-01-07 17:48:47 +01:00
Alexandre Ratchov 56540a0d18 unexpand $OpenBSD$ 2015-10-20 09:16:31 +02:00