OpenBSD CVS

CVS log for src/usr.bin/aucat/Attic/aproc.c


[BACK] Up to [local] / src / usr.bin / aucat

Request diff between arbitrary revisions


Default branch: MAIN


Revision 1.75, Wed Jan 21 08:43:55 2015 UTC (9 years, 3 months ago) by ratchov
Branch: MAIN
CVS Tags: HEAD
Changes since 1.74: +1 -1 lines
FILE REMOVED

Simplify internals and rewrite file header parsing code:
- remove -M, -t, -w, -C, -x flags that don't make sense anymore
- make "-j off" the default (sndiod already does the job)
- don't limit the number of played/recorded files.
- add support for floating-point encoded files.
- add support for apple .aiff and sun/next .au files

Revision 1.74 / (download) - annotate - [select for diffs], Mon Nov 18 17:37:45 2013 UTC (10 years, 6 months ago) by ratchov
Branch: MAIN
CVS Tags: OPENBSD_5_6_BASE, OPENBSD_5_6, OPENBSD_5_5_BASE, OPENBSD_5_5
Changes since 1.73: +85 -1 lines
Diff to previous 1.73 (colored)

add missing prototypes

Revision 1.73 / (download) - annotate - [select for diffs], Wed May 23 19:12:44 2012 UTC (11 years, 11 months ago) by ratchov
Branch: MAIN
CVS Tags: OPENBSD_5_4_BASE, OPENBSD_5_4, OPENBSD_5_3_BASE, OPENBSD_5_3, OPENBSD_5_2_BASE, OPENBSD_5_2
Changes since 1.72: +22 -14 lines
Diff to previous 1.72 (colored)

Fix wrong arithmetics in channel mapping causing crashes if all of
the recorded or played channels don't exist.
With help from Remco <remco at d-compu.dyndns.org>, thanks!

Revision 1.72 / (download) - annotate - [select for diffs], Wed Apr 11 21:12:55 2012 UTC (12 years, 1 month ago) by ratchov
Branch: MAIN
Changes since 1.71: +7 -1 lines
Diff to previous 1.71 (colored)

flush the log and abort() if we try to destroy a NULL aproc

Revision 1.71 / (download) - annotate - [select for diffs], Wed Apr 11 06:05:43 2012 UTC (12 years, 1 month ago) by ratchov
Branch: MAIN
Changes since 1.70: +62 -61 lines
Diff to previous 1.70 (colored)

Use "unsigned int" rather than "unsigned". No object change.
suggested by deraadt@

Revision 1.70 / (download) - annotate - [select for diffs], Fri Mar 23 11:59:54 2012 UTC (12 years, 1 month ago) by ratchov
Branch: MAIN
Changes since 1.69: +5 -3 lines
Diff to previous 1.69 (colored)

add a MIDI-controlled master volume knob to adjust the mix of
all playback stream, discussed with armani@

Revision 1.69 / (download) - annotate - [select for diffs], Tue Jan 10 08:10:21 2012 UTC (12 years, 4 months ago) by ratchov
Branch: MAIN
CVS Tags: OPENBSD_5_1_BASE, OPENBSD_5_1
Changes since 1.68: +12 -26 lines
Diff to previous 1.68 (colored)

Fix the way the mixer figures out which groups of streams have
common channels and thus need to share their dynamic range. Fixes,
unnecessarily decreased volume in some theoretical cases.

Revision 1.68 / (download) - annotate - [select for diffs], Sun Nov 20 22:54:51 2011 UTC (12 years, 6 months ago) by ratchov
Branch: MAIN
Changes since 1.67: +1 -7 lines
Diff to previous 1.67 (colored)

Move mmc/mtc and volume control bits from struct aproc to struct
dev. Allows volume settings to be saved while the device is kept
closed. Besides that, no behabiour changes.

Revision 1.67 / (download) - annotate - [select for diffs], Wed Nov 16 08:03:34 2011 UTC (12 years, 6 months ago) by ratchov
Branch: MAIN
Changes since 1.66: +3 -1 lines
Diff to previous 1.66 (colored)

consider there's no dependency between two aprocs, if
one of them is NULL

Revision 1.66 / (download) - annotate - [select for diffs], Thu May 26 07:26:36 2011 UTC (12 years, 11 months ago) by ratchov
Branch: MAIN
CVS Tags: OPENBSD_5_0_BASE, OPENBSD_5_0
Changes since 1.65: +8 -3 lines
Diff to previous 1.65 (colored)

make clipping less ugly, from Sviatoslav Chagaev

Revision 1.65 / (download) - annotate - [select for diffs], Thu May 26 07:18:40 2011 UTC (12 years, 11 months ago) by ratchov
Branch: MAIN
Changes since 1.64: +6 -2 lines
Diff to previous 1.64 (colored)

add a new -w flag to control whether master volume is automatically
adjusted when new streams are connected and disconnected. Disabling
automatic volume adjustment makes sense if all streams are recorded
with properly lowered volumes.

Revision 1.64 / (download) - annotate - [select for diffs], Thu Apr 28 07:20:03 2011 UTC (13 years ago) by ratchov
Branch: MAIN
Changes since 1.63: +2 -2 lines
Diff to previous 1.63 (colored)

remove deadcode, use err(1, "%s", str) instead of err(1, str)
from Michael W. Bombardieri <mb at ii.net>, thanks!

Revision 1.63 / (download) - annotate - [select for diffs], Thu Nov 4 17:55:28 2010 UTC (13 years, 6 months ago) by ratchov
Branch: MAIN
CVS Tags: OPENBSD_4_9_BASE, OPENBSD_4_9
Changes since 1.62: +35 -37 lines
Diff to previous 1.62 (colored)

Replace ``short'' by a new ``adata_t'' typedef corresponding to
audio samples and cleanup ADATA_XXX macros. This allows easilly
switching to 24 bit fixed point arithmetic by simply redefining
the adata_t typedef to int and updating ADATA_XXX macros. No
object change.

Revision 1.62 / (download) - annotate - [select for diffs], Thu Oct 21 21:42:46 2010 UTC (13 years, 7 months ago) by ratchov
Branch: MAIN
Changes since 1.61: +15 -9 lines
Diff to previous 1.61 (colored)

When the end of a stream is reached (ie mix_eof() called) other
possibly blocked streams are processed. If during this phase the end
of another stream is reached then stop the processing because the job
will be already finished by the second stream. Otherwise we may end up
running a destroyed stream.

help from Edward Wandasiewicz <w13ntd at googlemail.com>, thanks

Revision 1.61 / (download) - annotate - [select for diffs], Thu Oct 21 19:10:52 2010 UTC (13 years, 7 months ago) by ratchov
Branch: MAIN
Changes since 1.60: +7 -7 lines
Diff to previous 1.60 (colored)

fix style and typos in messages and comments

Revision 1.60 / (download) - annotate - [select for diffs], Thu Oct 21 18:57:42 2010 UTC (13 years, 7 months ago) by ratchov
Branch: MAIN
Changes since 1.59: +5 -36 lines
Diff to previous 1.59 (colored)

use MODE_xxx and XRUN_xxx macros everywhere, and zap corresponding
AMSG_xxx macros, which in turns simplifies the code

Revision 1.59 / (download) - annotate - [select for diffs], Fri May 7 07:15:50 2010 UTC (14 years ago) by ratchov
Branch: MAIN
CVS Tags: OPENBSD_4_8_BASE, OPENBSD_4_8
Changes since 1.58: +1 -10 lines
Diff to previous 1.58 (colored)

remove ``abspos'' counters, from the pre-libsndio era. Since play and
rec direction use the same clock, there's no need to maintain their
absolute position.

Revision 1.58 / (download) - annotate - [select for diffs], Tue May 4 19:40:08 2010 UTC (14 years ago) by ratchov
Branch: MAIN
Changes since 1.57: +2 -2 lines
Diff to previous 1.57 (colored)

make the mixer process data as soon as it's pushed by one of its
inputs, i.e. don't way that the output requests it.

Revision 1.57 / (download) - annotate - [select for diffs], Sun May 2 11:12:31 2010 UTC (14 years ago) by ratchov
Branch: MAIN
Changes since 1.56: +56 -25 lines
Diff to previous 1.56 (colored)

Don't systematically fill with silence the mixer output. This
might result in extra samples being written to the device
when the mixer is closed.

Revision 1.56 / (download) - annotate - [select for diffs], Sun May 2 10:40:48 2010 UTC (14 years ago) by ratchov
Branch: MAIN
Changes since 1.55: +20 -2 lines
Diff to previous 1.55 (colored)

in the resampling code, handle the case ``diff == 0'', to avoid producing
the first sample of the next block in advance.

Revision 1.55 / (download) - annotate - [select for diffs], Sat Apr 24 13:32:21 2010 UTC (14 years ago) by ratchov
Branch: MAIN
Changes since 1.54: +4 -2 lines
Diff to previous 1.54 (colored)

don't increment mixer's ``idle'' counter before truncating the
amount of samples to commit to ``maxwrite''. Overwise uncommitted
samples are accounted as idle, in turn causing the device to be
stopped too early, possibly truncating few blocks at the end of
streams being drained.

subtle bug spotted and analysed by Thomas Pfaff, thanks

Revision 1.54 / (download) - annotate - [select for diffs], Sat Apr 24 06:18:23 2010 UTC (14 years ago) by ratchov
Branch: MAIN
Changes since 1.53: +58 -58 lines
Diff to previous 1.53 (colored)

rename ibuflist/obuflist -> ins/outs to cut long lines
from Thomas Pfaff, thanks

Revision 1.53 / (download) - annotate - [select for diffs], Wed Apr 21 06:13:07 2010 UTC (14 years, 1 month ago) by ratchov
Branch: MAIN
Changes since 1.52: +146 -1 lines
Diff to previous 1.52 (colored)

adds the necessary bits to join channels (ex stereo->mono) or
expand channels (ex mono->stereo).  It's switched on/off with
the ``-j'' option, (default is "on").

Revision 1.52 / (download) - annotate - [select for diffs], Sat Apr 17 09:16:57 2010 UTC (14 years, 1 month ago) by ratchov
Branch: MAIN
Changes since 1.51: +28 -155 lines
Diff to previous 1.51 (colored)

Allow the mixer to handle inputs with channel ranges outside
the device channel range. This makes the channel mapping code
no longer usefuli, so remove it. No behaviour change.

Revision 1.51 / (download) - annotate - [select for diffs], Tue Apr 6 20:07:01 2010 UTC (14 years, 1 month ago) by ratchov
Branch: MAIN
Changes since 1.50: +572 -157 lines
Diff to previous 1.50 (colored)

aucat (server):

  - make the ``-m mode'' option per subdevice, allowing
    subdevices to be play-only or rec-only even if the
    server is full-duplex

  - add ``monitoring'' mode (with ``-m mon''). This is a
    record-only stream from which played streams can be
    recorded (kind of ``record what you hear'').

  - allow MIDI devices to be subscribed to the controlling
    MIDI port of the server, ie what midicat does (with -f
    option), but using the -q option.

  - add flow control to the protocol, and serialize clock
    ticks (sio_onmove() calls) and data chunks.  This should
    fix certain full-duplex programs, broken with ``magic''
    block/buffer size combinations.

  - enable 3 block latency which is the minimum theoretical.
    Make -z and -b options correspond to device parameters.

  - make sio_getcap(3) the same for aucat and sun backends,
    ie return whatever is supported (``everything'' in the
    aucat case, since everything is actulally supported).

aucat (player):

  - enable ``-m mode'' option  to select between monitoring
    and recording when ``-o file'' is used.

  - plug MIDI code to non-server codepath. The MIDI control
    device is specified with the ``-q device'' option, as in
    server mode.

  - impliment lseek()'ing within files (controlled
    through MIDI). Necessary to use aucat with a MIDI
    sequencer.

midicat (thrubox):

  - rename ``-f'' flag to ``-q'', so it has the
    same name as in aucat (-f is still working)

ok jakemsr@, tweaks from jmc@

Revision 1.50 / (download) - annotate - [select for diffs], Sat Apr 3 17:59:17 2010 UTC (14 years, 1 month ago) by ratchov
Branch: MAIN
Changes since 1.49: +156 -571 lines
Diff to previous 1.49 (colored)

backout last change, committed by mistake, sorry...

Revision 1.49 / (download) - annotate - [select for diffs], Sat Apr 3 17:40:33 2010 UTC (14 years, 1 month ago) by ratchov
Branch: MAIN
Changes since 1.48: +572 -157 lines
Diff to previous 1.48 (colored)

doc fixes from jmc

Revision 1.48 / (download) - annotate - [select for diffs], Sun Jan 17 19:17:23 2010 UTC (14 years, 4 months ago) by ratchov
Branch: MAIN
CVS Tags: OPENBSD_4_7_BASE, OPENBSD_4_7
Changes since 1.47: +6 -8 lines
Diff to previous 1.47 (colored)

While resampling, if input samples are available but output
is blocked don't start processing input. Similarly don't
produce output if input is blocked. This is to ensure that
to each output block corresponds exactly one input block.
This is necessary for full-duplex clients using block-based
i/o and very small buffers.

Revision 1.47 / (download) - annotate - [select for diffs], Sun Jan 17 16:09:30 2010 UTC (14 years, 4 months ago) by ratchov
Branch: MAIN
Changes since 1.46: +3 -15 lines
Diff to previous 1.46 (colored)

fix quality degradation when resampling

Revision 1.46 / (download) - annotate - [select for diffs], Fri Jan 15 22:17:10 2010 UTC (14 years, 4 months ago) by ratchov
Branch: MAIN
Changes since 1.45: +22 -6 lines
Diff to previous 1.45 (colored)

Fix resampling algorithm to always produce integer block sizes.

Revision 1.45 / (download) - annotate - [select for diffs], Thu Jan 14 17:57:47 2010 UTC (14 years, 4 months ago) by ratchov
Branch: MAIN
Changes since 1.44: +8 -16 lines
Diff to previous 1.44 (colored)

Use a more accurate algorithm to calculate clock tick duration
when resampling is involved. Removes single sample jitter, which
could confuse programs expecting fixed block size.

Revision 1.44 / (download) - annotate - [select for diffs], Tue Jan 12 21:42:59 2010 UTC (14 years, 4 months ago) by ratchov
Branch: MAIN
Changes since 1.43: +1 -11 lines
Diff to previous 1.43 (colored)

check for bogus clock ticks sent by the device; helps tracking
bugs in device drivers.

Revision 1.43 / (download) - annotate - [select for diffs], Mon Jan 11 13:06:32 2010 UTC (14 years, 4 months ago) by ratchov
Branch: MAIN
Changes since 1.42: +52 -9 lines
Diff to previous 1.42 (colored)

When resuming from suspend, prime play buffers with silence,
otherwise the client would underrun by more than its own buffer
size, which currently is not allowed (causes the client to
deadlock).

Set the minimum client buffer size to two blocks. Single block
buffers don't work properly yet.

with help from jakemsr

Revision 1.42 / (download) - annotate - [select for diffs], Sun Jan 10 21:47:41 2010 UTC (14 years, 4 months ago) by ratchov
Branch: MAIN
Changes since 1.41: +367 -1 lines
Diff to previous 1.41 (colored)

Add traces to help tracking subtle timing bugs often causing
underuns and overruns; such bugs are hard to debug with ktrace
or a debugger. They are also handy to debug or monitor code
using aucat.

To enable traces, compile aucat with ``make DEBUG=-DDEBUG'' and
use the -d option multiple times.

ok jakemsr

Revision 1.41 / (download) - annotate - [select for diffs], Tue Jan 5 10:18:12 2010 UTC (14 years, 4 months ago) by ratchov
Branch: MAIN
Changes since 1.40: +27 -27 lines
Diff to previous 1.40 (colored)

Make the way .wav files are handled closer to the way sockets are
handled, which is conceptually simpler. No behaviour changes.

Revision 1.40 / (download) - annotate - [select for diffs], Sun Nov 15 21:44:09 2009 UTC (14 years, 6 months ago) by ratchov
Branch: MAIN
Changes since 1.39: +23 -8 lines
Diff to previous 1.39 (colored)

If two (or more) inputs use channel ranges having no intersection,
then don't reduce their dynamic range to ``share the volume''.

Revision 1.39 / (download) - annotate - [select for diffs], Thu Nov 5 08:36:48 2009 UTC (14 years, 6 months ago) by ratchov
Branch: MAIN
Changes since 1.38: +17 -1 lines
Diff to previous 1.38 (colored)

in rpipe_done (wpipe_done), all buffers must be detached
before deleting the writer (reader) otherwise the later
could trigger rpipe_done again.

Revision 1.38 / (download) - annotate - [select for diffs], Tue Nov 3 21:31:37 2009 UTC (14 years, 6 months ago) by ratchov
Branch: MAIN
Changes since 1.37: +19 -14 lines
Diff to previous 1.37 (colored)

Allow any program using aucat to act as MMC slave and MTC master
transparently.  Multiple audio applications can be started
synchronously from external software/hardware supporting the
standard Start/Stop/Relocate messages. The server clock is exposed
through MTC, allowing non-audio software/hardware to be
synchronized to audio applications.

Revision 1.37 / (download) - annotate - [select for diffs], Sat Oct 10 09:54:05 2009 UTC (14 years, 7 months ago) by ratchov
Branch: MAIN
Changes since 1.36: +9 -5 lines
Diff to previous 1.36 (colored)

We don't need independent file reader and writer anymore. So,
destroy reader when writer terminates and destroy writer when
reader terminates. This simplifies a lot the way we drain
audio devices and will help simplifying other parts.

Revision 1.36 / (download) - annotate - [select for diffs], Fri Oct 9 16:49:48 2009 UTC (14 years, 7 months ago) by ratchov
Branch: MAIN
Changes since 1.35: +54 -54 lines
Diff to previous 1.35 (colored)

Make abuf structure smaller:
 - put aproc-specific parameters into unions since they are never
   used together
 - remove constant ``data'' pointer always pointing the end of the
   abuf structure

Revision 1.35 / (download) - annotate - [select for diffs], Tue Oct 6 18:06:55 2009 UTC (14 years, 7 months ago) by ratchov
Branch: MAIN
Changes since 1.34: +17 -17 lines
Diff to previous 1.34 (colored)

prevent aproc structures to be deleted twice. Doesn't change anything
for now but will be used in future code.

Revision 1.34 / (download) - annotate - [select for diffs], Sun Sep 27 11:51:20 2009 UTC (14 years, 7 months ago) by ratchov
Branch: MAIN
Changes since 1.33: +11 -152 lines
Diff to previous 1.33 (colored)

remove all debug traces

Revision 1.33 / (download) - annotate - [select for diffs], Sat Jul 25 10:52:18 2009 UTC (14 years, 9 months ago) by ratchov
Branch: MAIN
Changes since 1.32: +13 -13 lines
Diff to previous 1.32 (colored)

fix comments, remove no longer needed declaration, reorder includes
from Thomas Pfaff

Revision 1.32 / (download) - annotate - [select for diffs], Sat Jul 25 08:44:27 2009 UTC (14 years, 9 months ago) by ratchov
Branch: MAIN
Changes since 1.31: +17 -3 lines
Diff to previous 1.31 (colored)

Currently midi capable programs can control midi hardware, but
cannot cooperate with other programs.  The aim of this change is
to allow any program to send midi data to other programs as they
were midi hardware. For instance, this change should solve the
longstanding problem of using a midi sequencer with software
synthesizers. More precisely:

 - new midicat(1) utility (actually hardlink to aucat(1)).
   it creates software midi thru boxes, allowing programs
   to send midi messages to other programs as they were
   midi(4) hardware.

 - new midi api in libsndio (see mio_open(3)), to access
   midi(4) devices and midicat(1) sockets in a uniform way.

 - new device naming scheme <service>:<unit>[.<option>],
   common to audio and midi.

 - new sndio(7) manual describing concepts and naming

The current audio device naming still works, but people having
scripts or configuration files containing device names could read
the sndio(7) man page and slowly start updating device names.

discussed with jakemsr@ and deraadt@, help form jmc@

Revision 1.31 / (download) - annotate - [select for diffs], Fri Jan 23 17:38:15 2009 UTC (15 years, 3 months ago) by ratchov
Branch: MAIN
CVS Tags: OPENBSD_4_6_BASE, OPENBSD_4_6, OPENBSD_4_5_BASE, OPENBSD_4_5
Changes since 1.30: +13 -13 lines
Diff to previous 1.30 (colored)

spacing + typo fix from Matt Jibson <matt.jibson(at)gmail.com>

Revision 1.30 / (download) - annotate - [select for diffs], Mon Dec 29 17:59:08 2008 UTC (15 years, 4 months ago) by ratchov
Branch: MAIN
Changes since 1.29: +12 -1 lines
Diff to previous 1.29 (colored)

make the code "more correct": add reference counters to aproc
structures so we can keep a pointer to the device. Beside some
simplifications, this allows to easily handle the situation
where the audio device desappears. No change in the behaviour.

Revision 1.29 / (download) - annotate - [select for diffs], Sat Dec 27 17:02:13 2008 UTC (15 years, 4 months ago) by ratchov
Branch: MAIN
Changes since 1.28: +4 -5 lines
Diff to previous 1.28 (colored)

fix a bug in resampling code, resulting in joined stereo and/or
high frequency attenuation, intruduced in aproc.c rev 1.27.
Hints from Alf Schlichting <a.schlichting(at)lemarit.com>, thanks!

Revision 1.28 / (download) - annotate - [select for diffs], Sat Dec 27 16:10:39 2008 UTC (15 years, 4 months ago) by ratchov
Branch: MAIN
Changes since 1.27: +225 -159 lines
Diff to previous 1.27 (colored)

simplify the mixer and the demultiplexer code; no change in the
behaviour. This also, fixes incorrect constructs that are currently
harmless

Revision 1.27 / (download) - annotate - [select for diffs], Fri Dec 19 08:01:06 2008 UTC (15 years, 5 months ago) by ratchov
Branch: MAIN
Changes since 1.26: +30 -26 lines
Diff to previous 1.26 (colored)

use simple linear interpolation in the resampling code.
This partially removes the ``metallic'' noise audible
especially when upsampling 8k -> 44.1k.

Revision 1.26 / (download) - annotate - [select for diffs], Sun Dec 7 17:10:41 2008 UTC (15 years, 5 months ago) by ratchov
Branch: MAIN
Changes since 1.25: +16 -19 lines
Diff to previous 1.25 (colored)

When resampling, don't require the sample frequency to be an integer.
This removes the arithmetic constraint between the sample frequency
and the block size and all the associated code. Now aucat can work
in server mode with any block size.
ok jakemsr

Revision 1.25 / (download) - annotate - [select for diffs], Sun Nov 16 17:08:32 2008 UTC (15 years, 6 months ago) by ratchov
Branch: MAIN
Changes since 1.24: +13 -5 lines
Diff to previous 1.24 (colored)

make aucat compile without DEBUG defined (still defined by default)

Revision 1.24 / (download) - annotate - [select for diffs], Sun Nov 16 16:30:22 2008 UTC (15 years, 6 months ago) by ratchov
Branch: MAIN
Changes since 1.23: +14 -6 lines
Diff to previous 1.23 (colored)

Make clients inherit the volume parameter when the -v option is used in
server mode. It gives the maximum volume a client may have. This wastes
dynamic range, but allows volume to stay constant when other clients
connect or disconnect.

Revision 1.23 / (download) - annotate - [select for diffs], Mon Nov 10 23:25:37 2008 UTC (15 years, 6 months ago) by ratchov
Branch: MAIN
Changes since 1.22: +6 -4 lines
Diff to previous 1.22 (colored)

add a per-stream ``soft volume'' knob and the corresponding -v option.
The code will be useful later for the volume knob in the sndio API.

Revision 1.22 / (download) - annotate - [select for diffs], Sun Nov 9 16:26:07 2008 UTC (15 years, 6 months ago) by ratchov
Branch: MAIN
Changes since 1.21: +29 -1 lines
Diff to previous 1.21 (colored)

make aucat(1) stop automatically the audio(1) device if it's idle. This
way, when in server mode, it consumes no CPU if there are no clients.
Later, this will allow to start aucat(1) at session or system startup.

Revision 1.21 / (download) - annotate - [select for diffs], Fri Nov 7 21:01:15 2008 UTC (15 years, 6 months ago) by ratchov
Branch: MAIN
Changes since 1.20: +2 -1 lines
Diff to previous 1.20 (colored)

expose the block size in the sndio API by making par->round writable
and thus remove the ugly rate <-> block-size table from
sio_setpar(3). Handle the block size negociation in aucat(1), since
it has few constrains the code is overally simpler.
ok jakemsr@, major crank suggested by deraadt@

Revision 1.20 / (download) - annotate - [select for diffs], Thu Nov 6 17:47:52 2008 UTC (15 years, 6 months ago) by ratchov
Branch: MAIN
Changes since 1.19: +19 -19 lines
Diff to previous 1.19 (colored)

drop/silence calculation is wrong when xrun occurs and client and
device number of channels are not the same. The bug was hidden until
now, because mixer and demux input and outputs used to have the same
frame size.

Revision 1.19 / (download) - annotate - [select for diffs], Tue Nov 4 22:18:12 2008 UTC (15 years, 6 months ago) by ratchov
Branch: MAIN
Changes since 1.18: +317 -201 lines
Diff to previous 1.18 (colored)

split code that converts any->any in two parts: one to encode
native->any and one to decode any->native. It is simpler and
faster this way.

Revision 1.18 / (download) - annotate - [select for diffs], Tue Nov 4 18:24:06 2008 UTC (15 years, 6 months ago) by ratchov
Branch: MAIN
Changes since 1.17: +39 -40 lines
Diff to previous 1.17 (colored)

cleanup: remove channel mapping bits from encoding conversion code.
As a side effect, reduce CPU usage by ~10% on envy(4) devices.

Revision 1.17 / (download) - annotate - [select for diffs], Tue Nov 4 17:51:46 2008 UTC (15 years, 6 months ago) by ratchov
Branch: MAIN
Changes since 1.16: +126 -1 lines
Diff to previous 1.16 (colored)

add "new" conversion code to map any channel range into any other
channel range (based on the encoding conversion code). Will allow to
unentangle channel mapping from encoding conversion. As a side effect,
greatly reduces CPU usage for channel mapping. No functionnal change.

Revision 1.16 / (download) - annotate - [select for diffs], Tue Nov 4 15:22:40 2008 UTC (15 years, 6 months ago) by ratchov
Branch: MAIN
Changes since 1.15: +41 -105 lines
Diff to previous 1.15 (colored)

cleanup: resample stream while in native format and remove resampling
bits from the encoding conversion code. As a side effect this reduces
CPU usage by 30% on envy(4).

Revision 1.15 / (download) - annotate - [select for diffs], Tue Nov 4 14:16:09 2008 UTC (15 years, 6 months ago) by ratchov
Branch: MAIN
Changes since 1.14: +200 -1 lines
Diff to previous 1.14 (colored)

optimization: add "new" resampling code (actually based on the existing
conversion bits) and use it when resampling only is required (ie for
clients using s16 encoding), this is the most common case. Reduces CPU
usage by ~50%. No functional change.

Revision 1.14 / (download) - annotate - [select for diffs], Mon Nov 3 22:55:34 2008 UTC (15 years, 6 months ago) by ratchov
Branch: MAIN
Changes since 1.13: +46 -46 lines
Diff to previous 1.13 (colored)

rename mixxxx and subxxx fields of struct abuf to avoid confusion:
Add ``i'' to offsets in the input buffer and ``o'' to offsets
in the output buffer. This is necessary because input and output
use no more the same frame size.

Revision 1.13 / (download) - annotate - [select for diffs], Mon Nov 3 22:25:13 2008 UTC (15 years, 6 months ago) by ratchov
Branch: MAIN
Changes since 1.12: +52 -20 lines
Diff to previous 1.12 (colored)

A small optimization: handle most N-channel <-> M-channel conversions
inside the mixer and the demultiplexer. This way, aucat will not
trigger the heavy conversion code when only channel conversions are
required. Cuts ~50% of the CPU usage on envy(4) devices, can improve
surround 4.0, 5.1 and 7.1 capable devices. No functionnal change.

Revision 1.12 / (download) - annotate - [select for diffs], Sun Oct 26 08:49:43 2008 UTC (15 years, 6 months ago) by ratchov
Branch: MAIN
Changes since 1.11: +278 -131 lines
Diff to previous 1.11 (colored)

add minimal server capability to aucat(1). When started in server
mode, it listens on an unix socket and mixes/demultiplexes any number
of full-duplex streams, doing necessary format conversions and
resampling on the fly.

programs can use the new libsa(3) library to play and record audio.
The library provides a very simple API to connect to the audio server;
if aucat(1) isn't running, it uses the audio(4) driver transparently
instead.

Revision 1.11 / (download) - annotate - [select for diffs], Wed Aug 20 14:22:50 2008 UTC (15 years, 9 months ago) by ratchov
Branch: MAIN
Changes since 1.10: +2 -2 lines
Diff to previous 1.10 (colored)

abuf_flush() must be called only from the ``xxx_in()'' routines (ie
triggered by POLLIN condition).

mix_pushzero() is not called from the ``xxx_in()'' chain, but calls
abuf_flush() resulting in bad initialization of the mixer, which
will lead to a deadlock at some point.

ok jakemsr

Revision 1.10 / (download) - annotate - [select for diffs], Thu Aug 14 09:58:55 2008 UTC (15 years, 9 months ago) by ratchov
Branch: MAIN
Changes since 1.9: +28 -1 lines
Diff to previous 1.9 (colored)

move all device related stuff from aucat.c to a new dev.c file.
The new dev_xxx() routines expose a "high level" self-contained
interface to the device. At initialization, the device is opened
and two chains of aproc structures are created:

 * a playback chain that exposes a (initially) empty mix
   aproc to which the rest of the code can attach new
   streams to be played

 * record chain that exposes a (initially) empty sub aproc
   to which the rest of the code can attach new stream to
   to record

The rest of the code, has just to use dev_attach() routine to
attach streams. While we're at it, add a ``devops'' structure
containing pointers to the device-specific routines. This will
allow later to add support for other type of device than the
Sun API.

Also, write the .wav headers in file_del(), so put all header
related data in the file strucuture. This allows to close() the
file, as soon as wpipe_xxx() aproc terminates. This will be
useful for the server, because it will need to close() descripts
of closed connections immediately.

add mix_pushzero() routine to fill the mixer with silence. It
will be used to avoid the mixer to underrun when there are no
input streams. Since we always have at least one input stream
there's no behaviour change.

ok jakemsr

Revision 1.9 / (download) - annotate - [select for diffs], Thu Aug 14 09:47:51 2008 UTC (15 years, 9 months ago) by ratchov
Branch: MAIN
Changes since 1.8: +3 -3 lines
Diff to previous 1.8 (colored)

add an "AUTOQUIT" flag to mix and sub aprocs. If the flag is
set, the mix aproc will exit once there are no more input
streams, similarly the sub aproc will exit once there are no
more ouput streams. If the flag is not set, the mix aproc will
generate silence, and the sub aproc will drop samples. By
default this flag is set, so no behaviour change.

ok jakemsr

Revision 1.8 / (download) - annotate - [select for diffs], Thu Aug 14 09:45:23 2008 UTC (15 years, 9 months ago) by ratchov
Branch: MAIN
Changes since 1.7: +21 -33 lines
Diff to previous 1.7 (colored)

add a xxx_done() method to aproc structures, that cleans up just
before free()ing the aproc structure, this is cleaner and will
allow to reuse wpipe_xxx() and rpipe_xxx() when defining new
aprocs. No behaviour change.

ok jakemsr

Revision 1.7 / (download) - annotate - [select for diffs], Thu Aug 14 09:44:15 2008 UTC (15 years, 9 months ago) by ratchov
Branch: MAIN
Changes since 1.6: +7 -43 lines
Diff to previous 1.6 (colored)

move mix/sub underrun/overrun handling code and data in the
generic abuf structure, so it can reused. Required for an audio
server. No behaviour change.

ok jakemsr

Revision 1.6 / (download) - annotate - [select for diffs], Thu Aug 14 09:39:16 2008 UTC (15 years, 9 months ago) by ratchov
Branch: MAIN
Changes since 1.5: +28 -42 lines
Diff to previous 1.5 (colored)

factor code that discards data from abuf strucure into a single
abuf_rdiscard() routine. Similarly add abuf_wcommit() routine for
writing. The purpose is to stop manupulating FIFO pointers in
various places outiside abuf.c, its too error prone.
No behaviour change.

ok jakemsr

Revision 1.5 / (download) - annotate - [select for diffs], Mon Jun 2 17:06:36 2008 UTC (15 years, 11 months ago) by ratchov
Branch: MAIN
CVS Tags: OPENBSD_4_4_BASE, OPENBSD_4_4
Changes since 1.4: +34 -14 lines
Diff to previous 1.4 (colored)

allow the user to choose the aucat behaviour when underruns/overruns
occur on a per-stream basis, using -Xx flags.  There are 3 possible
policies:

 - ignore : ignores underruns/overruns, for instance, this mode
   could be used for creating simple pipes with utilities; like in
   your last cdio diff.

 - sync : insert/discard samples in order to keep all streams in
   sync, useful for multi-tracker-like apps and/or to sync
   midi/video/whatever on audio streams (this was the previous
   behaviour)

 - error : if overruns/underruns occur, consider it as fatal error
   and kill the corresponding stream (without disturbing others).
   Useful, for reliable recordings (and/or debugging aucat
   itself:).

ok jakemsr

Revision 1.4 / (download) - annotate - [select for diffs], Mon Jun 2 17:05:12 2008 UTC (15 years, 11 months ago) by ratchov
Branch: MAIN
Changes since 1.3: +1 -9 lines
Diff to previous 1.3 (colored)

since underruns/overruns are handled outside devices, remove code that
check for xruns in devices.

ok jakemsr

Revision 1.3 / (download) - annotate - [select for diffs], Mon Jun 2 17:03:25 2008 UTC (15 years, 11 months ago) by ratchov
Branch: MAIN
Changes since 1.2: +53 -10 lines
Diff to previous 1.2 (colored)

Allows any input/output stream to underrun/overrun without disturbing
other streams. Beside making aucat usable with slow apps (eg. cdio),
this change will ease turning aucat into an audio server later

if one of the input buffers underruns, then silence is generated in
place of the missing samples. Later, as many samples are dropped in
order to maintain the stream in sync with the rest

if one of the output buffers overruns then newer samples are
discarded. Later silence is generated in order to maintain the
stream in sync with the rest.

ok jakemsr

Revision 1.2 / (download) - annotate - [select for diffs], Sun May 25 21:16:37 2008 UTC (15 years, 11 months ago) by ratchov
Branch: MAIN
Changes since 1.1: +5 -5 lines
Diff to previous 1.1 (colored)

give argument to LIST_END(), don't use variable lenght arrays as last
field of structures.

from deraadt@

Revision 1.1 / (download) - annotate - [select for diffs], Fri May 23 07:15:46 2008 UTC (16 years ago) by ratchov
Branch: MAIN

add support for:
 - recording, full-duplex operation
 - format conversions and resampling on the fly
 - mixing on the fly of multiple inputs of different formats
 - up to 16 channels, simplistic "routing" of channel ranges
 - more linear encodings (in raw and wav files)
the old behaviour is fully preserved if none of the new -i and -o
options are used.

code and fixes from jakemsr@ and eric@, suggestions by others.
ok "go ahead" deraadt@

This form allows you to request diff's between any two revisions of a file. You may select a symbolic revision name using the selection box or you may type in a numeric name using the type-in text box.