Initial revision

This commit is contained in:
Jaroslav Kysela 1998-08-13 15:43:39 +00:00
commit fbb20e85ec
33 changed files with 5627 additions and 0 deletions

19
CHANGELOG Normal file
View file

@ -0,0 +1,19 @@
0.0.3 -> 0.0.4
* added check for alsa-lib package
* added spec file for RPM
0.0.2 -> 0.0.3
* included great ncurses alsamixer from Tim Janik <timj@gtk.org>
* enhanced Mixer from Andy Lo A Foe <arloafoe@cs.vu.nl> renamed to amixer
0.0.1 -> 0.0.2
* fixed small bug in aplay in command line parsing
* fixed fragment size allocation for low rate files in aplay
* a little bit corrected output from Mixer
0.0.1
* initial release (aplay, broken Mixer)

340
COPYING Normal file
View file

@ -0,0 +1,340 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
675 Mass Ave, Cambridge, MA 02139, USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
Appendix: How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) 19yy <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) 19yy name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Library General
Public License instead of this License.

46
Makefile Normal file
View file

@ -0,0 +1,46 @@
#
# Makefile for ALSA Utilities
# Copyright (c) 1994-98 by Jaroslav Kysela <perex@jcu.cz>
#
ifeq (Makefile.conf,$(wildcard Makefile.conf))
include Makefile.conf
else
dummy:
@echo
@echo "Please, run configure script as first..."
@echo
endif
all:
$(MAKE) -C aplay
$(MAKE) -C amixer
$(MAKE) -C alsamixer
@echo
@echo "ALSA Utilities were sucessfully compiled."
@echo
install: all
$(INSTALL) -s -m 755 -o root -g root aplay/aplay ${bindir}
ln -sf aplay ${bindir}/arecord
$(INSTALL) -s -m 755 -o root -g root amixer/amixer ${bindir}
$(INSTALL) -s -m 755 -o root -g root alsamixer/alsamixer ${bindir}
clean:
$(MAKE) -C include clean
$(MAKE) -C aplay clean
$(MAKE) -C amixer clean
$(MAKE) -C alsamixer clean
$(MAKE) -C utils clean
rm -f core .depend *.o *.orig *~
rm -f `find . -name "out.txt"`
pack: clean
rm -f config.cache config.log config.status Makefile.conf
chown -R root.root ../alsa-utils
tar cvz -C .. -f ../alsa-utils-$(SND_UTIL_VERSION).tar.gz alsa-utils
publish: pack
cat ../alsa-utils-$(SND_UTIL_VERSION).tar.gz | \
ssh -l root zarquon.jcu.cz /home/alsa/publishutils alsa-utils-$(SND_UTIL_VERSION).tar.gz

29
Makefile.conf Normal file
View file

@ -0,0 +1,29 @@
# Generated automatically from Makefile.conf.in by configure.
#
# Configuration Makefile for ALSA Utilities
# Copyright (c) 1994-98 by Jaroslav Kysela <perex@jcu.cz>
#
srcdir=.
prefix=/usr
exec_prefix=${prefix}
includedir=${prefix}/include
bindir=${exec_prefix}/bin
libdir=${exec_prefix}/lib
c_opts=-I/usr/include
INSTALL=/usr/bin/install -c
SND_UTIL_VERSION=0.0.4
SND_UTIL_MAJOR=0
SND_UTIL_MINOR=0
SND_UTIL_SUBMINOR=4
CC=gcc
CPP=gcc
INCLUDE=-I/usr/local/include -I$(TOPDIR)/include
COPTS = $(c_opts)
COPTS += -Wall -Wstrict-prototypes -fomit-frame-pointer -pipe
LINKER=ld
SNDLIB=-lsound
NCURSESINC="<ncurses.h>"
NCURSESLIB=-lncurses
LN_S=@LN_S@

29
Makefile.conf.in Normal file
View file

@ -0,0 +1,29 @@
#
# Configuration Makefile for ALSA Utilities
# Copyright (c) 1994-98 by Jaroslav Kysela <perex@jcu.cz>
#
srcdir=@srcdir@
VPATH=@srcdir@
prefix=@prefix@
exec_prefix=@exec_prefix@
includedir=@includedir@
bindir=@bindir@
libdir=@libdir@
c_opts=@CFLAGS@
INSTALL=@INSTALL@
SND_UTIL_VERSION=@SND_UTIL_VERSION@
SND_UTIL_MAJOR=@SND_UTIL_MAJOR@
SND_UTIL_MINOR=@SND_UTIL_MINOR@
SND_UTIL_SUBMINOR=@SND_UTIL_SUBMINOR@
CC=gcc
CPP=gcc
INCLUDE=-I/usr/local/include -I$(TOPDIR)/include
COPTS = $(c_opts)
COPTS += -Wall -Wstrict-prototypes -fomit-frame-pointer -pipe
LINKER=ld
SNDLIB=-lsound
NCURSESINC="<ncurses.h>"
NCURSESLIB=-lncurses
LN_S=@LN_S@

15
README Normal file
View file

@ -0,0 +1,15 @@
Advanced Linux Sound Architecture - Utilities
=============================================
This packages contains command line utilities for the ALSA project.
Package should be compiled only with installed ALSA driver and
ALSA C library.
aplay/arecord - utility for playback / record of .wav,.voc,.au files
amixer - a command line mixer
alsamixer - ncurses mixer
You should look for more info about ALSA project to http://alsa.jcu.cz.
Jaroslav Kysela <perex@jcu.cz>

23
alsamixer/Makefile Normal file
View file

@ -0,0 +1,23 @@
#
# Makefile for Alsa Mixer
#
TOPDIR = ..
include $(TOPDIR)/Makefile.conf
OBJECTS = alsamixer.o
.SUFFIXES:
.SUFFIXES: .o .cpp .c .s .S
.c.o:
$(CC) $(COPTS) $(INCLUDE) -DNCURSESINC=$(NCURSESINC) -c -o $*.o $<
all: alsamixer
alsamixer: $(OBJECTS)
$(CPP) -o alsamixer $(OBJECTS) $(SNDLIB) $(NCURSESLIB)
clean:
rm -f *.o alsamixer *~

870
alsamixer/alsamixer.c Normal file
View file

@ -0,0 +1,870 @@
/* AlsaMixer - Commandline mixer for the ALSA project
* Copyright (C) 1998 Jaroslav Kysela <perex@jcu.cz> & Tim Janik <timj@gtk.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*/
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <linux/sound.h>
#include <errno.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/signal.h>
#ifndef NCURSESINC
#include <ncurses.h>
#else
#include NCURSESINC
#endif
#include <time.h>
#include <sys/soundlib.h>
/* example compilation commandline:
* clear; gcc -Wall -pipe -O2 alsamixer.c -o alsamixer -lncurses
*/
/* --- defines --- */
#define PRGNAME "alsamixer"
#define PRGNAME_UPPER "AlsaMixer"
#define VERSION "v0.9"
#undef MAX
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
#undef MIN
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#undef ABS
#define ABS(a) (((a) < 0) ? -(a) : (a))
#undef CLAMP
#define CLAMP(x, low, high) (((x) > (high)) ? (high) : (((x) < (low)) ? (low) : (x)))
#define MIXER_MIN_X (23) /* minimum: 23 */
#define MIXER_MIN_Y (19) /* minimum: 19 */
#define MIXER_BLACK (COLOR_BLACK)
#define MIXER_DARK_RED (COLOR_RED)
#define MIXER_RED (COLOR_RED | A_BOLD)
#define MIXER_GREEN (COLOR_GREEN | A_BOLD)
#define MIXER_ORANGE (COLOR_YELLOW)
#define MIXER_YELLOW (COLOR_YELLOW | A_BOLD)
#define MIXER_MARIN (COLOR_BLUE)
#define MIXER_BLUE (COLOR_BLUE | A_BOLD)
#define MIXER_MAGENTA (COLOR_MAGENTA)
#define MIXER_DARK_CYAN (COLOR_CYAN)
#define MIXER_CYAN (COLOR_CYAN | A_BOLD)
#define MIXER_GREY (COLOR_WHITE)
#define MIXER_GRAY (MIXER_GREY)
#define MIXER_WHITE (COLOR_WHITE | A_BOLD)
/* --- variables --- */
static WINDOW *mixer_window = NULL;
static int mixer_max_x = 0;
static int mixer_max_y = 0;
static int mixer_ofs_x = 0;
static float mixer_extra_space = 0;
static int mixer_ofs_y = 0;
static int mixer_cbar_height = 0;
static int card_id = 0;
static int mixer_id = 0;
static void *mixer_handle;
static char *mixer_card_name = NULL;
static char *mixer_device_name = NULL;
static int mixer_n_channels = 0;
static int mixer_n_vis_channels = 0;
static int mixer_first_vis_channel = 0;
static int mixer_focus_channel = 0;
static int mixer_exact = 0;
static int mixer_lvolume_delta = 0;
static int mixer_rvolume_delta = 0;
static int mixer_balance_volumes = 0;
static int mixer_toggle_mute_left = 0;
static int mixer_toggle_mute_right = 0;
static int mixer_toggle_record = 0;
/* --- draw contexts --- */
enum
{
DC_DEFAULT,
DC_BACK,
DC_TEXT,
DC_PROMPT,
DC_CBAR_MUTE,
DC_CBAR_NOMUTE,
DC_CBAR_RECORD,
DC_CBAR_NORECORD,
DC_CBAR_EMPTY,
DC_CBAR_FULL_1,
DC_CBAR_FULL_2,
DC_CBAR_FULL_3,
DC_CBAR_LABEL,
DC_CBAR_FOCUS_LABEL,
DC_FOCUS,
DC_LAST
};
static int dc_fg[DC_LAST] = { 0 };
static int dc_attrib[DC_LAST] = { 0 };
static int dc_char[DC_LAST] = { 0 };
static int mixer_do_color = 1;
static void
mixer_init_dc (int c,
int n,
int f,
int b,
int a)
{
dc_fg[n] = f;
dc_attrib[n] = a;
dc_char[n] = c;
if (n > 0)
init_pair (n, dc_fg[n] & 0xf, b & 0x0f);
}
static int
mixer_dc (int n)
{
if (mixer_do_color)
attrset (COLOR_PAIR (n) | (dc_fg[n] & 0xfffffff0));
else
attrset (dc_attrib[n]);
return dc_char[n];
}
static void
mixer_init_draw_contexts (void)
{
start_color ();
mixer_init_dc ('.', DC_BACK, MIXER_WHITE, MIXER_BLACK, A_NORMAL);
mixer_init_dc ('.', DC_TEXT, MIXER_YELLOW, MIXER_BLACK, A_BOLD);
mixer_init_dc ('.', DC_PROMPT, MIXER_DARK_CYAN, MIXER_BLACK, A_NORMAL);
mixer_init_dc ('M', DC_CBAR_MUTE, MIXER_CYAN, MIXER_BLACK, A_BOLD);
mixer_init_dc ('-', DC_CBAR_NOMUTE, MIXER_CYAN, MIXER_BLACK, A_NORMAL);
mixer_init_dc ('x', DC_CBAR_RECORD, MIXER_DARK_RED, MIXER_BLACK, A_BOLD);
mixer_init_dc ('-', DC_CBAR_NORECORD, MIXER_GRAY, MIXER_BLACK, A_NORMAL);
mixer_init_dc (' ', DC_CBAR_EMPTY, MIXER_GRAY, MIXER_BLACK, A_DIM);
mixer_init_dc ('#', DC_CBAR_FULL_1, MIXER_WHITE, MIXER_BLACK, A_BOLD);
mixer_init_dc ('#', DC_CBAR_FULL_2, MIXER_GREEN, MIXER_BLACK, A_BOLD);
mixer_init_dc ('#', DC_CBAR_FULL_3, MIXER_RED, MIXER_BLACK, A_BOLD);
mixer_init_dc ('.', DC_CBAR_LABEL, MIXER_WHITE, MIXER_BLUE, A_REVERSE | A_BOLD);
mixer_init_dc ('.', DC_CBAR_FOCUS_LABEL, MIXER_RED, MIXER_BLUE, A_REVERSE | A_BOLD);
mixer_init_dc ('.', DC_FOCUS, MIXER_RED, MIXER_BLACK, A_BOLD);
}
#define DC_CBAR_FRAME (DC_CBAR_MUTE)
#define DC_FRAME (DC_PROMPT)
/* --- error types --- */
typedef enum
{
ERR_NONE,
ERR_OPEN,
ERR_FCN,
ERR_SIGNAL,
ERR_WINSIZE,
} ErrType;
/* --- prototypes --- */
static void mixer_abort (ErrType error,
const char *err_string)
__attribute__
((noreturn));
/* --- functions --- */
static void
mixer_clear (void)
{
int x, y;
mixer_dc (DC_BACK);
clear ();
/* buggy ncurses doesn't really write spaces with the specified
* color into the screen on clear ();
*/
for (x = 0; x < mixer_max_x; x++)
for (y = 0; y < mixer_max_y; y++)
mvaddch (y, x, ' ');
refresh ();
}
static void
mixer_abort (ErrType error,
const char *err_string)
{
if (mixer_window)
{
mixer_clear ();
endwin ();
mixer_window = NULL;
}
printf ("\n");
switch (error)
{
case ERR_OPEN:
fprintf (stderr,
PRGNAME ": failed to open mixer #%i/#%i: %s\n",
card_id,
mixer_id,
snd_strerror(errno));
break;
case ERR_FCN:
fprintf (stderr,
PRGNAME ": function %s failed: %s\n",
err_string,
snd_strerror(errno));
break;
case ERR_SIGNAL:
fprintf (stderr,
PRGNAME ": aborting due to signal `%s'\n",
err_string);
break;
case ERR_WINSIZE:
fprintf (stderr,
PRGNAME ": screen size too small (%dx%d)\n",
mixer_max_x,
mixer_max_y);
break;
default:
break;
}
exit (error);
}
static int
mixer_cbar_get_pos (int channel_index,
int *x_p,
int *y_p)
{
int x;
int y;
if (channel_index < mixer_first_vis_channel ||
channel_index - mixer_first_vis_channel >= mixer_n_vis_channels)
return FALSE;
channel_index -= mixer_first_vis_channel;
x = mixer_ofs_x + 1;
y = mixer_ofs_y;
x += channel_index * (3 + 2 + 3 + 1 + mixer_extra_space);
y += mixer_max_y / 2;
y += mixer_cbar_height / 2 + 1;
if (x_p)
*x_p = x;
if (y_p)
*y_p = y;
return TRUE;
}
static void
mixer_update_cbar (int channel_index)
{
char string[64];
char c;
snd_mixer_channel_info_t cinfo = { 0 };
snd_mixer_channel_t cdata = { 0 };
int vleft, vright;
int x, y, i;
/* set specified EXACT mode
*/
if (snd_mixer_exact_mode(mixer_handle, mixer_exact)<0)
mixer_abort (ERR_FCN, "snd_mixer_exact");
/* set new channel indices and read info
*/
if (snd_mixer_channel_info(mixer_handle, channel_index, &cinfo)<0)
mixer_abort (ERR_FCN, "snd_mixer_channel_info");
/* set new channel values
*/
if (channel_index == mixer_focus_channel &&
(mixer_lvolume_delta || mixer_rvolume_delta ||
mixer_toggle_mute_left || mixer_toggle_mute_right ||
mixer_balance_volumes ||
mixer_toggle_record))
{
if (snd_mixer_channel_read(mixer_handle, channel_index, &cdata)<0)
mixer_abort (ERR_FCN, "snd_mixer_channel_read");
cdata.flags &= ~SND_MIXER_FLG_DECIBEL;
cdata.left = CLAMP (cdata.left + mixer_lvolume_delta, cinfo.min, cinfo.max);
cdata.right = CLAMP (cdata.right + mixer_rvolume_delta, cinfo.min, cinfo.max);
mixer_lvolume_delta = mixer_rvolume_delta = 0;
if (mixer_balance_volumes)
{
cdata.left = (cdata.left + cdata.right) / 2;
cdata.right = cdata.left;
mixer_balance_volumes = 0;
}
if (mixer_toggle_mute_left)
{
if (cdata.flags & SND_MIXER_FLG_MUTE_LEFT)
cdata.flags &= ~SND_MIXER_FLG_MUTE_LEFT;
else
cdata.flags |= SND_MIXER_FLG_MUTE_LEFT;
}
if (mixer_toggle_mute_right)
{
if (cdata.flags & SND_MIXER_FLG_MUTE_RIGHT)
cdata.flags &= ~SND_MIXER_FLG_MUTE_RIGHT;
else
cdata.flags |= SND_MIXER_FLG_MUTE_RIGHT;
}
mixer_toggle_mute_left = mixer_toggle_mute_right = 0;
if (mixer_toggle_record)
{
if (cdata.flags & SND_MIXER_FLG_RECORD)
cdata.flags &= ~SND_MIXER_FLG_RECORD;
else
cdata.flags |= SND_MIXER_FLG_RECORD;
}
mixer_toggle_record = 0;
if (snd_mixer_channel_write(mixer_handle, channel_index, &cdata)<0)
mixer_abort (ERR_FCN, "snd_mixer_channel_write");
}
/* first, read values for the numbers to be displayed in
* specified EXACT mode
*/
if (snd_mixer_channel_read(mixer_handle, channel_index, &cdata)<0)
mixer_abort (ERR_FCN, "snd_mixer_ioctl_channel_read");
vleft = cdata.left;
vright = cdata.right;
/* then, always use percentage values for the bars. if we don't do
* this, we will see aliasing effects on specific circumstances.
* (actually they don't really dissapear, but they are transfered
* to bar<->smaller-scale ambiguities).
*/
if (mixer_exact)
{
i = 0;
if (snd_mixer_exact_mode(mixer_handle, 0)<0)
mixer_abort (ERR_FCN, "snd_mixer_exact");
if (snd_mixer_channel_read(mixer_handle, channel_index, &cdata)<0)
mixer_abort (ERR_FCN, "snd_mixer_channel_read");
}
/* get channel bar position
*/
if (!mixer_cbar_get_pos (channel_index, &x, &y))
return;
/* channel bar name
*/
mixer_dc (channel_index == mixer_focus_channel ? DC_CBAR_FOCUS_LABEL : DC_CBAR_LABEL);
cinfo.name[8] = 0;
for (i = 0; i < 8; i++)
{
string[i] = ' ';
}
sprintf(string + (8 - strlen (cinfo.name)) / 2, "%s ", cinfo.name);
string[8] = 0;
mvaddstr (y, x, string);
y--;
/* current channel values
*/
mixer_dc (DC_BACK);
mvaddstr (y, x, " ");
mixer_dc (DC_TEXT);
sprintf (string, "%d", vleft);
mvaddstr (y, x + 3 - strlen (string), string);
mixer_dc (DC_CBAR_FRAME);
mvaddch (y, x + 3, '<');
mvaddch (y, x + 4, '>');
mixer_dc (DC_TEXT);
sprintf (string, "%d", vright);
mvaddstr (y, x + 5, string);
y--;
/* left/right bar
*/
mixer_dc (DC_CBAR_FRAME);
mvaddstr (y, x, " ");
mvaddch (y, x + 2, ACS_LLCORNER);
mvaddch (y, x + 3, ACS_HLINE);
mvaddch (y, x + 4, ACS_HLINE);
mvaddch (y, x + 5, ACS_LRCORNER);
y--;
for (i = 0; i < mixer_cbar_height; i++)
{
mvaddstr (y - i, x, " ");
mvaddch (y - i, x + 2, ACS_VLINE);
mvaddch (y - i, x + 5, ACS_VLINE);
}
string[2] = 0;
for (i = 0; i < mixer_cbar_height; i++)
{
int dc;
if (i + 1 >= 0.8 * mixer_cbar_height)
dc = DC_CBAR_FULL_3;
else if (i + 1 >= 0.4 * mixer_cbar_height)
dc = DC_CBAR_FULL_2;
else
dc = DC_CBAR_FULL_1;
mvaddch (y, x + 3, mixer_dc (cdata.left > i * 100 / mixer_cbar_height ? dc : DC_CBAR_EMPTY));
mvaddch (y, x + 4, mixer_dc (cdata.right > i * 100 / mixer_cbar_height ? dc : DC_CBAR_EMPTY));
y--;
}
/* muted?
*/
mixer_dc (DC_BACK);
mvaddstr (y, x, " ");
c = cinfo.caps & SND_MIXER_CINFO_CAP_MUTE ? '-' : ' ';
mixer_dc (DC_CBAR_FRAME);
mvaddch (y, x + 2, ACS_ULCORNER);
mvaddch (y, x + 3, mixer_dc (cdata.flags & SND_MIXER_FLG_MUTE_LEFT ?
DC_CBAR_MUTE : DC_CBAR_NOMUTE));
mvaddch (y, x + 4, mixer_dc (cdata.flags & SND_MIXER_FLG_MUTE_RIGHT ?
DC_CBAR_MUTE : DC_CBAR_NOMUTE));
mixer_dc (DC_CBAR_FRAME);
mvaddch (y, x + 5, ACS_URCORNER);
y--;
/* record input?
*/
if (cdata.flags & SND_MIXER_FLG_RECORD)
{
mixer_dc (DC_CBAR_RECORD);
mvaddstr (y, x + 1, "RECORD");
}
else if (cinfo.caps & SND_MIXER_CINFO_CAP_RECORD)
for (i = 0; i < 6; i++)
mvaddch (y, x + 1 + i, mixer_dc (DC_CBAR_NORECORD));
else
{
mixer_dc (DC_BACK);
mvaddstr (y, x, " ");
}
y--;
}
static void
mixer_update_cbars (void)
{
static int o_x = 0;
static int o_y = 0;
int i, x, y;
if (!mixer_cbar_get_pos (mixer_focus_channel, &x, &y))
{
if (mixer_focus_channel < mixer_first_vis_channel)
mixer_first_vis_channel = mixer_focus_channel;
else if (mixer_focus_channel >= mixer_first_vis_channel + mixer_n_vis_channels)
mixer_first_vis_channel = mixer_focus_channel - mixer_n_vis_channels + 1;
mixer_cbar_get_pos (mixer_focus_channel, &x, &y);
}
for (i = 0; i < mixer_n_vis_channels; i++)
mixer_update_cbar (i + mixer_first_vis_channel);
/* draw focused cbar
*/
mixer_dc (DC_BACK);
mvaddstr (o_y, o_x, " ");
mvaddstr (o_y, o_x + 9, " ");
o_x = x - 1;
o_y = y;
mixer_dc (DC_FOCUS);
mvaddstr (o_y, o_x, "<");
mvaddstr (o_y, o_x + 9, ">");
}
static void
mixer_draw_frame (void)
{
char string[128];
int i;
int max_len;
mixer_dc (DC_FRAME);
/* corners
*/
mvaddch (0, 0, ACS_ULCORNER);
mvaddch (mixer_max_y - 1, 0, ACS_LLCORNER);
mvaddch (mixer_max_y - 1, mixer_max_x - 1, ACS_LRCORNER);
mvaddch (0, mixer_max_x - 1, ACS_URCORNER);
/* lines
*/
for (i = 1; i < mixer_max_y - 1; i++)
{
mvaddch (i, 0, ACS_VLINE);
mvaddch (i, mixer_max_x - 1, ACS_VLINE);
}
for (i = 1; i < mixer_max_x - 1; i++)
{
mvaddch (0, i, ACS_HLINE);
mvaddch (mixer_max_y - 1, i, ACS_HLINE);
}
/* program title
*/
sprintf (string, "%s %s", PRGNAME_UPPER, VERSION);
max_len = strlen (string);
mvaddch (0, mixer_max_x / 2 - max_len / 2 - 1, '[');
mvaddch (0, mixer_max_x / 2 - max_len / 2 + max_len, ']');
mixer_dc (DC_TEXT);
mvaddstr (0, mixer_max_x / 2 - max_len / 2, string);
/* card name
*/
mixer_dc (DC_PROMPT);
mvaddstr (1, 2, "Card:");
mixer_dc (DC_TEXT);
sprintf (string, "%s", mixer_card_name);
max_len = mixer_max_x - 2 - 6 - 2;
if (strlen (string) > max_len)
string[max_len] = 0;
mvaddstr (1, 2 + 6, string);
/* device name
*/
mixer_dc (DC_PROMPT);
mvaddstr (2, 2, "Chip: ");
mixer_dc (DC_TEXT);
sprintf (string, "%s", mixer_device_name);
max_len = mixer_max_x - 2 - 6 - 2;
if (strlen (string) > max_len)
string[max_len] = 0;
mvaddstr (2, 2 + 6, string);
}
static void
mixer_init (void)
{
static snd_mixer_info_t mixer_info = { 0 };
static struct snd_ctl_hw_info hw_info;
void *ctl_handle;
if (snd_ctl_open( &ctl_handle, card_id ) < 0 )
mixer_abort (ERR_OPEN, "snd_ctl_open" );
if (snd_ctl_hw_info( ctl_handle, &hw_info ) < 0 )
mixer_abort (ERR_FCN, "snd_ctl_hw_info" );
snd_ctl_close( ctl_handle );
/* open mixer device
*/
if (snd_mixer_open( &mixer_handle, card_id, mixer_id ) < 0)
mixer_abort (ERR_OPEN, "snd_mixer_open" );
/* setup global variables
*/
if (snd_mixer_info( mixer_handle, &mixer_info) < 0)
mixer_abort (ERR_FCN, "snd_mixer_info" );
mixer_n_channels = mixer_info.channels;
mixer_card_name = hw_info.name;
mixer_device_name = mixer_info.name;
}
static void
mixer_iteration_update(void *dummy, int channel)
{
mixer_update_cbar(channel);
refresh ();
}
static int
mixer_iteration (void)
{
static snd_mixer_callbacks_t callbacks = {
NULL,
mixer_iteration_update,
};
int key;
int finished = 0;
int mixer_fd;
fd_set in;
mixer_fd = snd_mixer_file_descriptor( mixer_handle );
while ( 1 ) {
FD_ZERO(&in);
FD_SET(fileno(stdin), &in);
FD_SET(mixer_fd, &in);
if (select(mixer_fd+1, &in, NULL, NULL, NULL)<=0)
return 1;
if (FD_ISSET(mixer_fd, &in))
snd_mixer_read(mixer_handle, &callbacks);
if (FD_ISSET(fileno(stdin), &in)) break;
}
key = getch ();
switch (key)
{
case 27: /* Escape */
finished = 1;
break;
case 9: /* Tab */
mixer_exact = !mixer_exact;
break;
case KEY_RIGHT:
case 'n':
mixer_focus_channel += 1;
break;
case KEY_LEFT:
case 'p':
mixer_focus_channel -= 1;
break;
case KEY_PPAGE:
if (mixer_exact)
{
mixer_lvolume_delta = 8;
mixer_rvolume_delta = 8;
}
else
{
mixer_lvolume_delta = 10;
mixer_rvolume_delta = 10;
}
break;
case KEY_NPAGE:
if (mixer_exact)
{
mixer_lvolume_delta = -8;
mixer_rvolume_delta = -8;
}
else
{
mixer_lvolume_delta = -10;
mixer_rvolume_delta = -10;
}
break;
case KEY_BEG:
case KEY_HOME:
mixer_lvolume_delta = 512;
mixer_rvolume_delta = 512;
break;
case KEY_LL:
case KEY_END:
mixer_lvolume_delta = -512;
mixer_rvolume_delta = -512;
break;
case '+':
mixer_lvolume_delta = 1;
mixer_rvolume_delta = 1;
break;
case '-':
mixer_lvolume_delta = -1;
mixer_rvolume_delta = -1;
break;
case 'w':
case KEY_UP:
mixer_lvolume_delta = 1;
mixer_rvolume_delta = 1;
case 'W':
mixer_lvolume_delta += 1;
mixer_rvolume_delta += 1;
break;
case 'x':
case KEY_DOWN:
mixer_lvolume_delta = -1;
mixer_rvolume_delta = -1;
case 'X':
mixer_lvolume_delta += -1;
mixer_rvolume_delta += -1;
break;
case 'q':
mixer_lvolume_delta = 1;
case 'Q':
mixer_lvolume_delta += 1;
break;
case 'y':
case 'z':
mixer_lvolume_delta = -1;
case 'Y':
case 'Z':
mixer_lvolume_delta += -1;
break;
case 'e':
mixer_rvolume_delta = 1;
case 'E':
mixer_rvolume_delta += 1;
break;
case 'c':
mixer_rvolume_delta = -1;
case 'C':
mixer_rvolume_delta += -1;
break;
case 'm':
case 'M':
mixer_toggle_mute_left = 1;
mixer_toggle_mute_right = 1;
break;
case 'b':
case 'B':
case '=':
mixer_balance_volumes = 1;
break;
case '<':
case ',':
mixer_toggle_mute_left = 1;
break;
case '>':
case '.':
mixer_toggle_mute_right = 1;
break;
case 'R':
case 'r':
case 'L':
case 'l':
mixer_clear ();
break;
case ' ':
mixer_toggle_record = 1;
break;
}
mixer_focus_channel = CLAMP (mixer_focus_channel, 0, mixer_n_channels - 1);
return finished;
}
static void
mixer_init_screen (void)
{
signal (SIGWINCH, (void *)mixer_init_screen);
getmaxyx (mixer_window, mixer_max_y, mixer_max_x);
mixer_clear ();
mixer_max_x = MAX (MIXER_MIN_X, mixer_max_x);
mixer_max_y = MAX (MIXER_MIN_Y, mixer_max_y);
mixer_clear ();
mixer_ofs_x = 2;
mixer_ofs_y = 2;
mixer_extra_space = 0;
mixer_n_vis_channels = MIN ((mixer_max_x - 2 * mixer_ofs_x + 1) / (9 + mixer_extra_space),
mixer_n_channels);
mixer_extra_space = ((mixer_max_x - 2 * mixer_ofs_x - 1 - mixer_n_vis_channels * 9.0) /
(mixer_n_vis_channels - 1));
if (mixer_n_vis_channels < mixer_n_channels)
{
/* recalc
*/
mixer_extra_space = MAX (mixer_extra_space, 1);
mixer_n_vis_channels = MIN ((mixer_max_x - 2 * mixer_ofs_x + 1) / (9 + mixer_extra_space),
mixer_n_channels);
mixer_extra_space = ((mixer_max_x - 2 * mixer_ofs_x - 1 - mixer_n_vis_channels * 9.0) /
(mixer_n_vis_channels - 1));
}
mixer_first_vis_channel = 0;
mixer_cbar_height = 10 + MAX (0, (mixer_max_y - MIXER_MIN_Y - 1)) / 2;
}
static void
mixer_signal_handler (int signal)
{
mixer_abort (ERR_SIGNAL, sys_siglist[signal]);
}
int
main (int argc,
char **argv)
{
int opt;
/* parse args
*/
do
{
opt = getopt (argc, argv, "c:m:ehg" );
switch (opt)
{
case '?':
case 'h':
fprintf (stderr, "%s %s\n", PRGNAME_UPPER, VERSION);
fprintf (stderr, "Usage: %s [-e] [-c <card: 1..%i>] [-m <mixer: 0..1>]\n", PRGNAME, snd_cards() );
mixer_abort (ERR_NONE, "");
case 'c':
card_id = snd_card_name( optarg );
break;
case 'e':
mixer_exact = !mixer_exact;
break;
case 'g':
mixer_do_color = !mixer_do_color;
break;
case 'm':
mixer_id = CLAMP (optarg[0], '0', '1');
break;
}
}
while (opt > 0);
/* initialize mixer
*/
mixer_init ();
/* setup signal handlers
*/
signal (SIGINT, mixer_signal_handler);
signal (SIGTRAP, mixer_signal_handler);
signal (SIGABRT, mixer_signal_handler);
signal (SIGQUIT, mixer_signal_handler);
signal (SIGBUS, mixer_signal_handler);
signal (SIGSEGV, mixer_signal_handler);
signal (SIGPIPE, mixer_signal_handler);
signal (SIGTERM, mixer_signal_handler);
/* initialize ncurses
*/
mixer_window = initscr ();
if (mixer_do_color)
mixer_do_color = has_colors ();
mixer_init_draw_contexts ();
mixer_init_screen ();
if (mixer_max_x < MIXER_MIN_X ||
mixer_max_y < MIXER_MIN_Y)
mixer_abort (ERR_WINSIZE, "");
/* react on key presses
* and draw window
*/
keypad (mixer_window, TRUE);
leaveok (mixer_window, TRUE);
cbreak ();
noecho ();
do
{
mixer_update_cbars ();
mixer_draw_frame ();
refresh ();
}
while (!mixer_iteration ());
mixer_abort (ERR_NONE, "");
};

29
amixer/Makefile Normal file
View file

@ -0,0 +1,29 @@
#
# Makefile for Mixer
#
TOPDIR = ..
include $(TOPDIR)/Makefile.conf
OBJECTS = amixer.o amain.o
.SUFFIXES:
.SUFFIXES: .o .cpp .c .s .S
.cpp.o:
$(CXX) $(COPTS) $(INCLUDE) -c -o $*.o $<
all: amixer
amixer.o: amixer.cpp
$(CXX) $(COPTS) $(INCLUDE) -c -o amixer.o amixer.cpp
amain.o: amain.cpp
$(CXX) $(COPTS) $(INCLUDE) -c -o amain.o amain.cpp
amixer: $(OBJECTS)
$(CXX) -o amixer $(SNDLIB) $(OBJECTS)
clean:
rm -f *.o amixer *~

39
amixer/README.first Normal file
View file

@ -0,0 +1,39 @@
Intro
-----
This is a quick mixer program for the ALSA project. It will grow out
to include a GTK interface eventually, if noone beats me to it :)
Building
--------
Edit the Makefile where the -I (include option) is. This should
point to the directory where the alsadriver is located. Then
type "make" and it should build without complaining. If you have
trouble with it please mail me at <arloafoe@cs.vu.nl>
Running
-------
amixer -h should display the syntax
Bugs & Todo
-----------
A lot, let me know..
Changes
-------
v0.001 March 20 1998 - Initial code
v0.1 Apr 21 1997 - Actually useful now
Contact
-------
Andy Lo A Foe
arloafoe@cs.vu.nl

256
amixer/amain.cpp Normal file
View file

@ -0,0 +1,256 @@
/*
* Copyright 1998, Andy Lo A Foe <arloafoe@cs.vu.nl>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/soundlib.h>
#include "amixer.h"
#define MIXER_RC ".amixerrc"
char *rc_file(void)
{
static char rc_path[1024];
char *p;
p = getenv("HOME");
if (p) {
sprintf(rc_path, "%s/%s", p, MIXER_RC);
} else {
printf("Error reading HOME env. variable\n");
return NULL;
}
return rc_path;
}
void copyright()
{
printf("CLI ALSA Mixer v0.11 (c) 1998 Adnans\n\n");
}
void usage()
{
printf("\n"
"Usage: amixer [-c card] [-d dev] device [vol|L:R] [mute|unmute] [rec|norec]\n\n"
" amixer [-p path] -r\tRead %s or <path> settings\n"
" amixer -w\t\tWrite %s settings\n"
" amixer -q ...\t\tQuiet mode\n"
" amixer -h\t\tHelp\n\n"
"Example: amixer line-out 80:50 unmute rec\n\n", rc_file(), rc_file());
}
void read_config(Mixer *mix, const char *path)
{
FILE *rc;
char buf[1024];
int opt1;
int opt2;
int left, right;
int dev;
int count = 0;
int flags;
if ((rc = fopen(path ? path : rc_file(), "r")) == NULL) {
printf("Mixer values not read\n");
return;
}
while (!feof(rc) && fgets(buf, 1024, rc)) {
count++;
if (buf[0] == '\n')
continue;
if (buf[0] == '#' || strlen(buf) == 0)
continue;
if (sscanf(buf, "%d %d:%d %d %d\n", &dev, &left, &right, &opt1, &opt2) != 5) {
printf("WARNING: unable to make out line %d of .rc file -> \"%s\"\n", count, buf);
continue;
}
flags = 0;
if (opt1) flags |= E_MIXER_MUTE;
if (opt2) flags |= E_MIXER_RECORD;
// Set mixer settings
mix->DeviceSet(dev);
mix->Write(left, right, flags);
}
fclose(rc);
return;
}
void write_config(Mixer *mix)
{
FILE *rc;
int32 left, right, flags;
if ((rc = fopen(rc_file(), "w+")) == NULL) {
printf("Mixer values not written\n");
return;
}
fprintf(rc, "# CLI ALSA mixer settings file. Autogenerated\n"
"# Modify at your own risk :)\n\n");
for (int i=0; i < mix->NumDevices(); i++) {
mix->DeviceSet(i);
mix->Read(&left, &right, &flags);
fprintf(rc, "%d %d:%d %d %d\n", i, mix->Left(), mix->Right(), flags & E_MIXER_MUTE ? 1 : 0, flags & E_MIXER_RECORD ? 1 : 0);
}
fclose(rc);
return;
}
int main(int argc, char **argv)
{
int card = 0, device = 0;
char device_name[64] = "";
int32 exact, mute, unmute, norec, rec, left, right, flags, device_index;
int32 left_dB, right_dB;
int32 cur_left, cur_right, cur_flags;
int count, quiet = 0;
int i,add;
int pathind = 0;
Mixer *the_mixer;
exact = mute = rec = norec = unmute = device_index = left = right = -1;
left_dB = right_dB = -1;
for (add = 0; add + 1 < argc; i++) {
if (!strcmp(argv[add+1],"--help")) {
usage();
return 0;
}
if (argv[add+1][0] == '-') {
add++;
if (argv[add][1] == 'c') {
card = snd_card_name(argv[++add]);
if (card < 0) {
fprintf(stderr, "Invalid card: %s\n",argv[2]);
exit(1);
}
} else if (argv[add][1] == 'd') {
device = atoi(argv[++add]);
if (device < 0 || device > 128) {
fprintf(stderr, "Invalid device: %s\n",argv[2]);
exit(1);
}
} else if (argv[add][1] == 'h') {
usage();
return 0;
} else if (argv[add][1] == 'p') {
pathind = ++add;
} else if (argv[add][1] == 'r') {
the_mixer = new Mixer(card,device);
if (the_mixer && the_mixer->Init()) read_config(the_mixer, pathind ? argv[pathind] : (const char *)NULL);
delete the_mixer;
return 0;
} else if (argv[add][1] == 'w') {
the_mixer = new Mixer(card,device);
if (the_mixer && the_mixer->Init()) write_config(the_mixer);
delete the_mixer;
return 0;
} else if (argv[add][1] == 'q') {
quiet = 1;
} else {
fprintf(stderr, "Invalid option: %s\n", argv[add]+1);
return 1;
}
} else {
break;
}
}
for (i=1+add; i < argc; i++) {
if (strcmp(argv[i],"exact")==0) {
exact = 1;
} else if (strcmp(argv[i],"mute")==0) {
mute = 1;
} else if (strcmp(argv[i],"unmute")==0) {
unmute = 1;
} else if (strcmp(argv[i],"rec")==0) {
rec = 1;
} else if (strcmp(argv[i],"norec")==0) {
norec = 1;
} else if (sscanf(argv[i], "%d:%d", &left, &right)==2) {
} else if (sscanf(argv[i], "%d", &left)==1) {
right = left;
} else if (sscanf(argv[i], "%s", device_name)==1) {
} else {
fprintf(stderr, "Wrong keyword: %s\n", argv[i]);
exit(1);
}
}
Mixer mixer(card,device);
if (mixer.Init() == false) {
fprintf(stderr, "Failed to open mixer device\n");
return 1;
}
count = mixer.NumDevices();
for (i=0; i < count; i++) {
mixer.DeviceSet(i);
if (strcasecmp(device_name, mixer.Name())==0)
device_index = i;
}
if ( !quiet )
copyright();
if (device_index >= 0) {
mixer.DeviceSet(device_index);
mixer.Read(&cur_left, &cur_right, &cur_flags);
if (left >= 0) cur_left = left;
if (right >= 0) cur_right = right;
if (rec == 1) cur_flags |= E_MIXER_RECORD;
else if (norec == 1) cur_flags &= ~E_MIXER_RECORD;
if (mute == 1) cur_flags |= E_MIXER_MUTE;
else if (unmute == 1) cur_flags &= ~E_MIXER_MUTE;
if (left != -1 || rec != -1 || norec != -1 || mute != -1 || unmute != -1) {
mixer.Write(cur_left, cur_right, cur_flags);
}
if ( !quiet ) {
printf("%-16s", mixer.Name());
mixer.Read(&left, &right, &flags);
mixer.Read_dB(&left_dB, &right_dB);
printf("%-3d%% (%6.2fdB) : %-3d%% (%6.2fdB) %s %s\n\n",
left, ((float)left_dB) / 100.0,
right, ((float)right_dB) / 100.0,
(flags & E_MIXER_MUTE) ? "Mute" : " ",
(flags & E_MIXER_RECORD) ? "Rec" : " " );
}
} else {
if (quiet) {
usage();
return 1;
}
if (strlen(device_name))
printf("Device not found: %s\n\n", device_name);
for (i=0; i < count; i++) {
mixer.DeviceSet(i);
printf("%-16s", mixer.Name());
mixer.Read(&left, &right, &flags);
mixer.Read_dB(&left_dB, &right_dB);
printf("%-3d%% (%6.2fdB) : %-3d%% (%6.2fdB) %s %s\n",
left, ((float)left_dB)/100.0, right, ((float)right_dB)/100.0,
(flags & E_MIXER_MUTE) ? "Mute" : " ",
(flags & E_MIXER_RECORD) ? "Rec" : " ");
}
return 0;
}
return 0;
}

BIN
amixer/amixer Normal file

Binary file not shown.

128
amixer/amixer.cpp Normal file
View file

@ -0,0 +1,128 @@
/*
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*/
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <unistd.h>
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <sys/soundlib.h>
#include "amixer.h"
Mixer::Mixer(int card, int device)
{
mixer_handle = NULL;
if (snd_mixer_open(&mixer_handle, card, device) < 0) {
fprintf(stderr, "Can't access mixer %i/%i\n", card+1, device);
mixer_status = ~E_MIXER_SUCCESS;
return;
}
mixer_status = E_MIXER_SUCCESS;
mixer_status |= E_MIXER_NEED_CLOSE;
}
bool Mixer::Open(int card, int device)
{
Close();
if (snd_mixer_open(&mixer_handle, card, device) < 0) {
fprintf(stderr, "Can't access mixer %i/%i\n", card + 1, device);
mixer_status = ~E_MIXER_SUCCESS;
} else{
mixer_status = E_MIXER_SUCCESS;
mixer_status |= E_MIXER_NEED_CLOSE;
}
return Init();
}
void Mixer::Close()
{
if (mixer_handle != NULL && mixer_status & E_MIXER_NEED_CLOSE) {
snd_mixer_close(mixer_handle);
}
mixer_handle = NULL;
mixer_status = ~E_MIXER_SUCCESS;
}
Mixer::~Mixer()
{
Close();
}
bool Mixer::Init()
{
if (!(mixer_status & E_MIXER_SUCCESS))
return false;
if ((nr_devices = snd_mixer_channels(mixer_handle)) < 0)
return false;
return true;
}
char* Mixer::Name()
{
return Name(current_device);
}
char* Mixer::Name(int32 device)
{
if (snd_mixer_channel_info(mixer_handle,device,&ch_info) < 0)
return "Unknown";
return (char *)ch_info.name;
}
void Mixer::Update()
{
if(snd_mixer_channel_read(mixer_handle, current_device, &ch_data) < 0) {
fprintf(stderr, "Can't read data from channel %i\n", current_device);
return; /* No fail code? */
}
}
void Mixer::DeviceRead(int32 device, int32 *left, int32 *right, int32 *flags)
{
current_device = device;
Update();
*left = ch_data.left;
*right = ch_data.right;
*flags = ch_data.flags;
}
void Mixer::DeviceWrite(int32 device, int32 left, int32 right, int32 flags)
{
current_device = device;
ch_data.channel = device;
ch_data.left = left;
ch_data.right = right;
ch_data.flags = flags;
if(snd_mixer_channel_write(mixer_handle, device, &ch_data) < 0) {
fprintf(stderr, "Can't write data to channel %i\n", device);
return; /* No fail code? */
}
}

73
amixer/amixer.h Normal file
View file

@ -0,0 +1,73 @@
/*
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*/
#include "atypes.h"
#define E_MIXER_SUCCESS 1
#define E_MIXER_NEED_CLOSE 2
#define E_MIXER_RECORD SND_MIXER_FLG_RECORD
#define E_MIXER_MUTE_LEFT SND_MIXER_FLG_MUTE_LEFT
#define E_MIXER_MUTE_RIGHT SND_MIXER_FLG_MUTE_RIGHT
#define E_MIXER_MUTE SND_MIXER_FLG_MUTE
class Mixer
{
public:
Mixer(int card = 0, int device = 0);
~Mixer();
bool Init();
bool Open(int card, int device);
void Close();
void DeviceSet(int32 device) {
current_device = device;
Update();
}
char* Name(int32 device);
char* Name();
int32 NumDevices() { return nr_devices; }
void Update();
void DeviceRead(int32 device, int32 *left, int32 *right, int32 *flag);
void DeviceWrite(int32 device, int32 left, int32 right, int32 flag);
void Read(int32 *left, int32 *right, int32 *flags) {
DeviceRead(current_device, left, right, flags);
}
void Read_dB(int32 *left_dB, int32 *right_dB) {
*left_dB = ch_data.left_dB;
*right_dB = ch_data.right_dB;
}
void Write(int32 left, int32 right, int32 flags) {
DeviceWrite(current_device, left, right, flags);
}
int Left() { return ch_data.left; }
int Right() { return ch_data.right; }
Mixer& operator[](int32 device) {
DeviceSet(device);
return (*this);
}
private:
snd_mixer_info_t info;
snd_mixer_channel_t ch_data;
snd_mixer_channel_info_t ch_info;
void * mixer_handle;
int32 mixer_status;
int32 current_device;
int32 nr_devices;
};

1
amixer/atypes.h Normal file
View file

@ -0,0 +1 @@
typedef int int32;

34
aplay/Makefile Normal file
View file

@ -0,0 +1,34 @@
#
# Makefile for aplay program
# Copyright (c) 1994-98 by Jaroslav Kysela <perex@jcu.cz>
#
TOPDIR=..
include $(TOPDIR)/Makefile.conf
TARGET=aplay
TARGET1=arecord
OBJECTS=aplay.o
.c.o:
$(CC) $(COPTS) $(INCLUDE) -c -o $*.o $<
all: $(TARGET)
$(TARGET): .depend $(OBJECTS)
$(CC) $(SNDLIB) $(OBJECTS) -o $(TARGET)
ln -sf $(TARGET) $(TARGET1)
clean:
rm -f core .depend *.o *.orig *~
.depend:
$(CPP) $(COPTS) $(INCLUDE) -M *.c > .depend
#
# include a dependency file if one exists
#
ifeq (.depend,$(wildcard .depend))
include .depend
endif

BIN
aplay/aplay Normal file

Binary file not shown.

1153
aplay/aplay.c Normal file

File diff suppressed because it is too large Load diff

91
aplay/formats.h Normal file
View file

@ -0,0 +1,91 @@
#ifndef FORMATS_H
#define FORMATS_H 1
#include <sys/types.h>
/* Definitions for .VOC files */
#define VOC_MAGIC_STRING "Creative Voice File\0x1A"
#define VOC_ACTUAL_VERSION 0x010A
#define VOC_SAMPLESIZE 8
#define VOC_MODE_MONO 0
#define VOC_MODE_STEREO 1
#define VOC_DATALEN(bp) ((u_long)(bp->datalen) | \
((u_long)(bp->datalen_m) << 8) | \
((u_long)(bp->datalen_h) << 16) )
typedef struct voc_header {
u_char magic[20]; /* must be MAGIC_STRING */
u_short headerlen; /* Headerlength, should be 0x1A */
u_short version; /* VOC-file version */
u_short coded_ver; /* 0x1233-version */
} VocHeader;
typedef struct voc_blocktype {
u_char type;
u_char datalen; /* low-byte */
u_char datalen_m; /* medium-byte */
u_char datalen_h; /* high-byte */
} VocBlockType;
typedef struct voc_voice_data {
u_char tc;
u_char pack;
} VocVoiceData;
typedef struct voc_ext_block {
u_short tc;
u_char pack;
u_char mode;
} VocExtBlock;
/* Definitions for Microsoft WAVE format */
#define WAV_RIFF 0x46464952
#define WAV_WAVE 0x45564157
#define WAV_FMT 0x20746D66
#define WAV_DATA 0x61746164
#define WAV_PCM_CODE 1
/* it's in chunks like .voc and AMIGA iff, but my source say there
are in only in this combination, so I combined them in one header;
it works on all WAVE-file I have
*/
typedef struct wav_header {
u_int main_chunk; /* 'RIFF' */
u_int length; /* filelen */
u_int chunk_type; /* 'WAVE' */
u_int sub_chunk; /* 'fmt ' */
u_int sc_len; /* length of sub_chunk, =16 */
u_short format; /* should be 1 for PCM-code */
u_short modus; /* 1 Mono, 2 Stereo */
u_int sample_fq; /* frequence of sample */
u_int byte_p_sec;
u_short byte_p_spl; /* samplesize; 1 or 2 bytes */
u_short bit_p_spl; /* 8, 12 or 16 bit */
u_int data_chunk; /* 'data' */
u_int data_length; /* samplecount */
} WaveHeader;
/* Definitions for Sparc .au header */
#define AU_MAGIC 0x2e736e64
#define AU_FMT_ULAW 1
#define AU_FMT_LIN8 2
#define AU_FMT_LIN16 3
typedef struct au_header {
u_int magic; /* magic '.snd' */
u_int hdr_size; /* size of header (min 24) */
u_int data_size; /* size of data */
u_int encoding; /* see to AU_FMT_XXXX */
u_int sample_rate; /* sample rate */
u_int channels; /* number of channels (voices) */
} AuHeader;
#endif /* FORMATS */

29
config.cache Normal file
View file

@ -0,0 +1,29 @@
# This file is a shell script that caches the results of configure
# tests run on this system so they can be shared between configure
# scripts and configure runs. It is not useful on other systems.
# If it contains results you don't want to keep, you may remove or edit it.
#
# By default, configure uses ./config.cache as the cache file,
# creating it if it does not exist already. You can give configure
# the --cache-file=FILE option to use a different cache file; that is
# what configure does when it calls configure scripts in
# subdirectories, so they share the cache.
# Giving --cache-file=/dev/null disables caching, for debugging configure.
# config.status only pays attention to the cache file if you give it the
# --recheck option to rerun configure.
#
ac_cv_c_const=${ac_cv_c_const='yes'}
ac_cv_c_inline=${ac_cv_c_inline='inline'}
ac_cv_header_linux_sound_h=${ac_cv_header_linux_sound_h='yes'}
ac_cv_header_stdc=${ac_cv_header_stdc='yes'}
ac_cv_header_sys_soundlib_h=${ac_cv_header_sys_soundlib_h='yes'}
ac_cv_header_time=${ac_cv_header_time='yes'}
ac_cv_path_install=${ac_cv_path_install='/usr/bin/install -c'}
ac_cv_prog_CC=${ac_cv_prog_CC='gcc'}
ac_cv_prog_CPP=${ac_cv_prog_CPP='gcc -E'}
ac_cv_prog_RANLIB=${ac_cv_prog_RANLIB='ranlib'}
ac_cv_prog_cc_cross=${ac_cv_prog_cc_cross='no'}
ac_cv_prog_cc_g=${ac_cv_prog_cc_g='yes'}
ac_cv_prog_cc_works=${ac_cv_prog_cc_works='yes'}
ac_cv_prog_gcc=${ac_cv_prog_gcc='yes'}
ac_cv_prog_gcc_traditional=${ac_cv_prog_gcc_traditional='no'}

32
config.log Normal file
View file

@ -0,0 +1,32 @@
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
configure:528: checking for gcc
configure:605: checking whether the C compiler (gcc ) works
configure:619: gcc -o conftest conftest.c 1>&5
configure:639: checking whether the C compiler (gcc ) is a cross-compiler
configure:644: checking whether we are using GNU C
configure:653: gcc -E conftest.c
configure:668: checking whether gcc accepts -g
configure:698: checking for ranlib
configure:754: checking for a BSD compatible install
configure:805: checking how to run the C preprocessor
configure:826: gcc -E conftest.c >/dev/null 2>conftest.out
configure:866: checking for ANSI C header files
configure:879: gcc -E conftest.c >/dev/null 2>conftest.out
configure:946: gcc -o conftest -g -O2 conftest.c 1>&5
configure:974: checking for linux/sound.h
configure:984: gcc -E conftest.c >/dev/null 2>conftest.out
configure:974: checking for sys/soundlib.h
configure:984: gcc -E conftest.c >/dev/null 2>conftest.out
configure:1012: checking for working const
configure:1066: gcc -c -g -O2 conftest.c 1>&5
configure:1087: checking for inline
configure:1101: gcc -c -g -O2 conftest.c 1>&5
configure:1127: checking whether time.h and sys/time.h may both be included
configure:1141: gcc -c -g -O2 conftest.c 1>&5
configure:1164: checking whether gcc needs -traditional
configure:1171: sgtty.h: No such file or directory
configure:1219: checking for alsa-lib package
configure:1236: gcc -o conftest -I/usr/include conftest.c -L/usr/lib -lsound 1>&5
configure:1250: checking for alsa-utils version

245
config.status Normal file
View file

@ -0,0 +1,245 @@
#! /bin/sh
# Generated automatically by configure.
# Run this file to recreate the current configuration.
# This directory was configured as follows,
# on host entry.jcu.cz:
#
# ./configure
#
# Compiler output produced by configure, useful for debugging
# configure, is in ./config.log if it exists.
ac_cs_usage="Usage: ./config.status [--recheck] [--version] [--help]"
for ac_option
do
case "$ac_option" in
-recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
echo "running ${CONFIG_SHELL-/bin/sh} ./configure --no-create --no-recursion"
exec ${CONFIG_SHELL-/bin/sh} ./configure --no-create --no-recursion ;;
-version | --version | --versio | --versi | --vers | --ver | --ve | --v)
echo "./config.status generated by autoconf version 2.12"
exit 0 ;;
-help | --help | --hel | --he | --h)
echo "$ac_cs_usage"; exit 0 ;;
*) echo "$ac_cs_usage"; exit 1 ;;
esac
done
ac_given_srcdir=.
ac_given_INSTALL="/usr/bin/install -c"
trap 'rm -fr Makefile.conf utils/alsa-utils.spec include/config.h conftest*; exit 1' 1 2 15
# Protect against being on the right side of a sed subst in config.status.
sed 's/%@/@@/; s/@%/@@/; s/%g$/@g/; /@g$/s/[\\&%]/\\&/g;
s/@@/%@/; s/@@/@%/; s/@g$/%g/' > conftest.subs <<\CEOF
/^[ ]*VPATH[ ]*=[^:]*$/d
s%@CFLAGS@%-I/usr/include%g
s%@CPPFLAGS@%%g
s%@CXXFLAGS@%%g
s%@DEFS@%-DHAVE_CONFIG_H%g
s%@LDFLAGS@%%g
s%@LIBS@%-L/usr/lib -lsound%g
s%@exec_prefix@%${prefix}%g
s%@prefix@%/usr%g
s%@program_transform_name@%s,x,x,%g
s%@bindir@%${exec_prefix}/bin%g
s%@sbindir@%${exec_prefix}/sbin%g
s%@libexecdir@%${exec_prefix}/libexec%g
s%@datadir@%${prefix}/share%g
s%@sysconfdir@%${prefix}/etc%g
s%@sharedstatedir@%${prefix}/com%g
s%@localstatedir@%${prefix}/var%g
s%@libdir@%${exec_prefix}/lib%g
s%@includedir@%${prefix}/include%g
s%@oldincludedir@%/usr/include%g
s%@infodir@%${prefix}/info%g
s%@mandir@%${prefix}/man%g
s%@CC@%gcc%g
s%@RANLIB@%ranlib%g
s%@INSTALL_PROGRAM@%${INSTALL}%g
s%@INSTALL_DATA@%${INSTALL} -m 644%g
s%@CPP@%gcc -E%g
s%@SND_UTIL_VERSION@%0.0.4%g
s%@SND_UTIL_MAJOR@%0%g
s%@SND_UTIL_MINOR@%0%g
s%@SND_UTIL_SUBMINOR@%4%g
CEOF
# Split the substitutions into bite-sized pieces for seds with
# small command number limits, like on Digital OSF/1 and HP-UX.
ac_max_sed_cmds=90 # Maximum number of lines to put in a sed script.
ac_file=1 # Number of current file.
ac_beg=1 # First line for current file.
ac_end=$ac_max_sed_cmds # Line after last line for current file.
ac_more_lines=:
ac_sed_cmds=""
while $ac_more_lines; do
if test $ac_beg -gt 1; then
sed "1,${ac_beg}d; ${ac_end}q" conftest.subs > conftest.s$ac_file
else
sed "${ac_end}q" conftest.subs > conftest.s$ac_file
fi
if test ! -s conftest.s$ac_file; then
ac_more_lines=false
rm -f conftest.s$ac_file
else
if test -z "$ac_sed_cmds"; then
ac_sed_cmds="sed -f conftest.s$ac_file"
else
ac_sed_cmds="$ac_sed_cmds | sed -f conftest.s$ac_file"
fi
ac_file=`expr $ac_file + 1`
ac_beg=$ac_end
ac_end=`expr $ac_end + $ac_max_sed_cmds`
fi
done
if test -z "$ac_sed_cmds"; then
ac_sed_cmds=cat
fi
CONFIG_FILES=${CONFIG_FILES-"Makefile.conf utils/alsa-utils.spec"}
for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then
# Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
case "$ac_file" in
*:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'`
ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
*) ac_file_in="${ac_file}.in" ;;
esac
# Adjust a relative srcdir, top_srcdir, and INSTALL for subdirectories.
# Remove last slash and all that follows it. Not all systems have dirname.
ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'`
if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then
# The file is in a subdirectory.
test ! -d "$ac_dir" && mkdir "$ac_dir"
ac_dir_suffix="/`echo $ac_dir|sed 's%^\./%%'`"
# A "../" for each directory in $ac_dir_suffix.
ac_dots=`echo $ac_dir_suffix|sed 's%/[^/]*%../%g'`
else
ac_dir_suffix= ac_dots=
fi
case "$ac_given_srcdir" in
.) srcdir=.
if test -z "$ac_dots"; then top_srcdir=.
else top_srcdir=`echo $ac_dots|sed 's%/$%%'`; fi ;;
/*) srcdir="$ac_given_srcdir$ac_dir_suffix"; top_srcdir="$ac_given_srcdir" ;;
*) # Relative path.
srcdir="$ac_dots$ac_given_srcdir$ac_dir_suffix"
top_srcdir="$ac_dots$ac_given_srcdir" ;;
esac
case "$ac_given_INSTALL" in
[/$]*) INSTALL="$ac_given_INSTALL" ;;
*) INSTALL="$ac_dots$ac_given_INSTALL" ;;
esac
echo creating "$ac_file"
rm -f "$ac_file"
configure_input="Generated automatically from `echo $ac_file_in|sed 's%.*/%%'` by configure."
case "$ac_file" in
*Makefile*) ac_comsub="1i\\
# $configure_input" ;;
*) ac_comsub= ;;
esac
ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"`
sed -e "$ac_comsub
s%@configure_input@%$configure_input%g
s%@srcdir@%$srcdir%g
s%@top_srcdir@%$top_srcdir%g
s%@INSTALL@%$INSTALL%g
" $ac_file_inputs | (eval "$ac_sed_cmds") > $ac_file
fi; done
rm -f conftest.s*
# These sed commands are passed to sed as "A NAME B NAME C VALUE D", where
# NAME is the cpp macro being defined and VALUE is the value it is being given.
#
# ac_d sets the value in "#define NAME VALUE" lines.
ac_dA='s%^\([ ]*\)#\([ ]*define[ ][ ]*\)'
ac_dB='\([ ][ ]*\)[^ ]*%\1#\2'
ac_dC='\3'
ac_dD='%g'
# ac_u turns "#undef NAME" with trailing blanks into "#define NAME VALUE".
ac_uA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)'
ac_uB='\([ ]\)%\1#\2define\3'
ac_uC=' '
ac_uD='\4%g'
# ac_e turns "#undef NAME" without trailing blanks into "#define NAME VALUE".
ac_eA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)'
ac_eB='$%\1#\2define\3'
ac_eC=' '
ac_eD='%g'
if test "${CONFIG_HEADERS+set}" != set; then
CONFIG_HEADERS="include/config.h"
fi
for ac_file in .. $CONFIG_HEADERS; do if test "x$ac_file" != x..; then
# Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
case "$ac_file" in
*:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'`
ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
*) ac_file_in="${ac_file}.in" ;;
esac
echo creating $ac_file
rm -f conftest.frag conftest.in conftest.out
ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"`
cat $ac_file_inputs > conftest.in
cat > conftest.frag <<CEOF
${ac_dA}STDC_HEADERS${ac_dB}STDC_HEADERS${ac_dC}1${ac_dD}
${ac_uA}STDC_HEADERS${ac_uB}STDC_HEADERS${ac_uC}1${ac_uD}
${ac_eA}STDC_HEADERS${ac_eB}STDC_HEADERS${ac_eC}1${ac_eD}
${ac_dA}HAVE_LINUX_SOUND_H${ac_dB}HAVE_LINUX_SOUND_H${ac_dC}1${ac_dD}
${ac_uA}HAVE_LINUX_SOUND_H${ac_uB}HAVE_LINUX_SOUND_H${ac_uC}1${ac_uD}
${ac_eA}HAVE_LINUX_SOUND_H${ac_eB}HAVE_LINUX_SOUND_H${ac_eC}1${ac_eD}
${ac_dA}HAVE_SYS_SOUNDLIB_H${ac_dB}HAVE_SYS_SOUNDLIB_H${ac_dC}1${ac_dD}
${ac_uA}HAVE_SYS_SOUNDLIB_H${ac_uB}HAVE_SYS_SOUNDLIB_H${ac_uC}1${ac_uD}
${ac_eA}HAVE_SYS_SOUNDLIB_H${ac_eB}HAVE_SYS_SOUNDLIB_H${ac_eC}1${ac_eD}
${ac_dA}TIME_WITH_SYS_TIME${ac_dB}TIME_WITH_SYS_TIME${ac_dC}1${ac_dD}
${ac_uA}TIME_WITH_SYS_TIME${ac_uB}TIME_WITH_SYS_TIME${ac_uC}1${ac_uD}
${ac_eA}TIME_WITH_SYS_TIME${ac_eB}TIME_WITH_SYS_TIME${ac_eC}1${ac_eD}
CEOF
sed -f conftest.frag conftest.in > conftest.out
rm -f conftest.in
mv conftest.out conftest.in
cat > conftest.frag <<CEOF
${ac_dA}SND_UTIL_VERSION${ac_dB}SND_UTIL_VERSION${ac_dC}"0.0.4"${ac_dD}
${ac_uA}SND_UTIL_VERSION${ac_uB}SND_UTIL_VERSION${ac_uC}"0.0.4"${ac_uD}
${ac_eA}SND_UTIL_VERSION${ac_eB}SND_UTIL_VERSION${ac_eC}"0.0.4"${ac_eD}
s%^[ ]*#[ ]*undef[ ][ ]*[a-zA-Z_][a-zA-Z_0-9]*%/* & */%
CEOF
sed -f conftest.frag conftest.in > conftest.out
rm -f conftest.in
mv conftest.out conftest.in
rm -f conftest.frag conftest.h
echo "/* $ac_file. Generated automatically by configure. */" > conftest.h
cat conftest.in >> conftest.h
rm -f conftest.in
if cmp -s $ac_file conftest.h 2>/dev/null; then
echo "$ac_file is unchanged"
rm -f conftest.h
else
# Remove last slash and all that follows it. Not all systems have dirname.
ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'`
if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then
# The file is in a subdirectory.
test ! -d "$ac_dir" && mkdir "$ac_dir"
fi
rm -f $ac_file
mv conftest.h $ac_file
fi
fi; done
exit 0

1622
configure vendored Normal file

File diff suppressed because it is too large Load diff

61
configure.in Normal file
View file

@ -0,0 +1,61 @@
dnl Process this file with autoconf to produce a configure script.
AC_INIT(Makefile.conf.in)
AC_PREFIX_DEFAULT(/usr)
dnl Checks for programs.
AC_PROG_CC
AC_PROG_RANLIB
AC_PROG_INSTALL
AC_PROG_LN_S
dnl Checks for header files.
AC_HEADER_STDC
AC_CONFIG_HEADER(include/config.h)
AC_CHECK_HEADERS(linux/sound.h sys/soundlib.h)
dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_C_INLINE
AC_HEADER_TIME
dnl Checks for library functions.
AC_PROG_GCC_TRADITIONAL
dnl Check for ALSA library package.
myprefix=$prefix
if test "$myprefix" = "NONE"; then
myprefix=$ac_default_prefix
fi
CFLAGS="-I$myprefix/include"
LIBS="-L$myprefix/lib -lsound"
#echo "CFLAGS=$CFLAGS"
#echo "LIBS=$LIBS"
AC_MSG_CHECKING(for alsa-lib package)
AC_TRY_RUN([
#include <sys/soundlib.h>
void main(void)
{
snd_cards();
exit(0);
}
],
AC_MSG_RESULT("present"),
AC_MSG_RESULT("not found"); echo "Fatal error: Install alsa-lib package at first..."; exit 1;,
AC_MSG_RESULT("not supported"); echo "Fatal error: Cross-compiling isn't supported..."; exit 1;
)
dnl Check for version...
AC_MSG_CHECKING(for alsa-utils version)
SND_UTIL_VERSION=`cat $srcdir/version`
AC_DEFINE_UNQUOTED(SND_UTIL_VERSION, "$SND_UTIL_VERSION")
AC_SUBST(SND_UTIL_VERSION)
SND_UTIL_MAJOR=`echo $SND_UTIL_VERSION | cut -d . -f 1`
AC_SUBST(SND_UTIL_MAJOR)
SND_UTIL_MINOR=`echo $SND_UTIL_VERSION | cut -d . -f 2`
AC_SUBST(SND_UTIL_MINOR)
SND_UTIL_SUBMINOR=`echo $SND_UTIL_VERSION | cut -d . -f 3`
AC_SUBST(SND_UTIL_SUBMINOR)
AC_MSG_RESULT($SND_UTIL_VERSION)
AC_OUTPUT(Makefile.conf utils/alsa-utils.spec)

10
include/Makefile Normal file
View file

@ -0,0 +1,10 @@
#
# Makefile for ALSA utils package
# Copyright (c) 1994-98 by Jaroslav Kysela <perex@jcu.cz>
#
include ../Makefile.conf
clean:
rm -f core .depend *.o *.orig *~

6
include/config.h Normal file
View file

@ -0,0 +1,6 @@
/* include/config.h. Generated automatically by configure. */
/*
* Configuration header file for compilation of the ALSA utilities
*/
#define SND_UTIL_VERSION "0.0.4"

5
include/config.h.in Normal file
View file

@ -0,0 +1,5 @@
/*
* Configuration header file for compilation of the ALSA utilities
*/
#undef SND_UTIL_VERSION

250
install-sh Normal file
View file

@ -0,0 +1,250 @@
#! /bin/sh
#
# install - install a program, script, or datafile
# This comes from X11R5 (mit/util/scripts/install.sh).
#
# Copyright 1991 by the Massachusetts Institute of Technology
#
# Permission to use, copy, modify, distribute, and sell this software and its
# documentation for any purpose is hereby granted without fee, provided that
# the above copyright notice appear in all copies and that both that
# copyright notice and this permission notice appear in supporting
# documentation, and that the name of M.I.T. not be used in advertising or
# publicity pertaining to distribution of the software without specific,
# written prior permission. M.I.T. makes no representations about the
# suitability of this software for any purpose. It is provided "as is"
# without express or implied warranty.
#
# Calling this script install-sh is preferred over install.sh, to prevent
# `make' implicit rules from creating a file called install from it
# when there is no Makefile.
#
# This script is compatible with the BSD install script, but was written
# from scratch. It can only install one file at a time, a restriction
# shared with many OS's install programs.
# set DOITPROG to echo to test this script
# Don't use :- since 4.3BSD and earlier shells don't like it.
doit="${DOITPROG-}"
# put in absolute paths if you don't have them in your path; or use env. vars.
mvprog="${MVPROG-mv}"
cpprog="${CPPROG-cp}"
chmodprog="${CHMODPROG-chmod}"
chownprog="${CHOWNPROG-chown}"
chgrpprog="${CHGRPPROG-chgrp}"
stripprog="${STRIPPROG-strip}"
rmprog="${RMPROG-rm}"
mkdirprog="${MKDIRPROG-mkdir}"
transformbasename=""
transform_arg=""
instcmd="$mvprog"
chmodcmd="$chmodprog 0755"
chowncmd=""
chgrpcmd=""
stripcmd=""
rmcmd="$rmprog -f"
mvcmd="$mvprog"
src=""
dst=""
dir_arg=""
while [ x"$1" != x ]; do
case $1 in
-c) instcmd="$cpprog"
shift
continue;;
-d) dir_arg=true
shift
continue;;
-m) chmodcmd="$chmodprog $2"
shift
shift
continue;;
-o) chowncmd="$chownprog $2"
shift
shift
continue;;
-g) chgrpcmd="$chgrpprog $2"
shift
shift
continue;;
-s) stripcmd="$stripprog"
shift
continue;;
-t=*) transformarg=`echo $1 | sed 's/-t=//'`
shift
continue;;
-b=*) transformbasename=`echo $1 | sed 's/-b=//'`
shift
continue;;
*) if [ x"$src" = x ]
then
src=$1
else
# this colon is to work around a 386BSD /bin/sh bug
:
dst=$1
fi
shift
continue;;
esac
done
if [ x"$src" = x ]
then
echo "install: no input file specified"
exit 1
else
true
fi
if [ x"$dir_arg" != x ]; then
dst=$src
src=""
if [ -d $dst ]; then
instcmd=:
else
instcmd=mkdir
fi
else
# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
# might cause directories to be created, which would be especially bad
# if $src (and thus $dsttmp) contains '*'.
if [ -f $src -o -d $src ]
then
true
else
echo "install: $src does not exist"
exit 1
fi
if [ x"$dst" = x ]
then
echo "install: no destination specified"
exit 1
else
true
fi
# If destination is a directory, append the input filename; if your system
# does not like double slashes in filenames, you may need to add some logic
if [ -d $dst ]
then
dst="$dst"/`basename $src`
else
true
fi
fi
## this sed command emulates the dirname command
dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
# Make sure that the destination directory exists.
# this part is taken from Noah Friedman's mkinstalldirs script
# Skip lots of stat calls in the usual case.
if [ ! -d "$dstdir" ]; then
defaultIFS='
'
IFS="${IFS-${defaultIFS}}"
oIFS="${IFS}"
# Some sh's can't handle IFS=/ for some reason.
IFS='%'
set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
IFS="${oIFS}"
pathcomp=''
while [ $# -ne 0 ] ; do
pathcomp="${pathcomp}${1}"
shift
if [ ! -d "${pathcomp}" ] ;
then
$mkdirprog "${pathcomp}"
else
true
fi
pathcomp="${pathcomp}/"
done
fi
if [ x"$dir_arg" != x ]
then
$doit $instcmd $dst &&
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
else
# If we're going to rename the final executable, determine the name now.
if [ x"$transformarg" = x ]
then
dstfile=`basename $dst`
else
dstfile=`basename $dst $transformbasename |
sed $transformarg`$transformbasename
fi
# don't allow the sed command to completely eliminate the filename
if [ x"$dstfile" = x ]
then
dstfile=`basename $dst`
else
true
fi
# Make a temp file name in the proper directory.
dsttmp=$dstdir/#inst.$$#
# Move or copy the file name to the temp name
$doit $instcmd $src $dsttmp &&
trap "rm -f ${dsttmp}" 0 &&
# and set any options; do chmod last to preserve setuid bits
# If any of these fail, we abort the whole thing. If we want to
# ignore errors from any of these, just make sure not to ignore
# errors from the above "$doit $instcmd $src $dsttmp" command.
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
# Now rename the file to the real destination.
$doit $rmcmd -f $dstdir/$dstfile &&
$doit $mvcmd $dsttmp $dstdir/$dstfile
fi &&
exit 0

10
utils/Makefile Normal file
View file

@ -0,0 +1,10 @@
#
# Makefile for ALSA utils package
# Copyright (c) 1994-98 by Jaroslav Kysela <perex@jcu.cz>
#
include ../Makefile.conf
clean:
rm -f core .depend *.o *.orig *~

73
utils/alsa-utils.spec Normal file
View file

@ -0,0 +1,73 @@
%define ver 0.0.4
%define rel 1
%define prefix /
Summary: Advanced Linux Sound Architecture (ALSA) - Utils
Name: alsa-utils
Version: %ver
Release: %rel
Copyright: GPL
Group: System/Libraries
Source: ftp://alsa.jcu.cz/pub/utils/alsa-utils-%{ver}.tar.gz
BuildRoot: /tmp/alsa-utils-%{ver}
Packager: Helge Jensen <slog@slog.dk>
URL: http://alsa.jcu.cz
Docdir: %{prefix}/usr/doc
Requires: alsa-lib alsa-driver
%description
Advanced Linux Sound Architecture (ALSA) - Utils
Features
========
* general
- modularized architecture with support for 2.0 and latest 2.1 kernels
- support for versioned and exported symbols
- full proc filesystem support - /proc/sound
* ISA soundcards
- support for 128k ISA DMA buffer
* mixer
- new enhanced API for applications
- support for unlimited number of channels
- volume can be set in three ways (percentual (0-100), exact and decibel)
- support for mute (and hardware mute if hardware supports it)
- support for mixer events
- this allows two or more applications to be synchronized
* digital audio (PCM)
- new enhanced API for applications
- full real duplex support
- full duplex support for SoundBlaster 16/AWE soundcards
- digital audio data for playback and record should be read back using
proc filesystem
* OSS/Lite compatibility
- full mixer compatibity
- full PCM (/dev/dsp) compatibility
%changelog
* Mon May 28 1998 Helge Jensen <slog@slog.dk>
- Made SPEC file
%prep
%setup -n alsa-utils
%build
./configure --prefix=/usr
make
%install
mkdir -p $RPM_BUILD_ROOT/usr/bin
make prefix="$RPM_BUILD_ROOT/usr" install
%clean
rm -rf $RPM_BUILD_ROOT
%files
%defattr(-, root, root)
%doc CHANGELOG COPYING README config.status
%{prefix}/usr/bin/*

73
utils/alsa-utils.spec.in Normal file
View file

@ -0,0 +1,73 @@
%define ver @SND_UTIL_VERSION@
%define rel 1
%define prefix /
Summary: Advanced Linux Sound Architecture (ALSA) - Utils
Name: alsa-utils
Version: %ver
Release: %rel
Copyright: GPL
Group: System/Libraries
Source: ftp://alsa.jcu.cz/pub/utils/alsa-utils-%{ver}.tar.gz
BuildRoot: /tmp/alsa-utils-%{ver}
Packager: Helge Jensen <slog@slog.dk>
URL: http://alsa.jcu.cz
Docdir: %{prefix}/usr/doc
Requires: alsa-lib alsa-driver
%description
Advanced Linux Sound Architecture (ALSA) - Utils
Features
========
* general
- modularized architecture with support for 2.0 and latest 2.1 kernels
- support for versioned and exported symbols
- full proc filesystem support - /proc/sound
* ISA soundcards
- support for 128k ISA DMA buffer
* mixer
- new enhanced API for applications
- support for unlimited number of channels
- volume can be set in three ways (percentual (0-100), exact and decibel)
- support for mute (and hardware mute if hardware supports it)
- support for mixer events
- this allows two or more applications to be synchronized
* digital audio (PCM)
- new enhanced API for applications
- full real duplex support
- full duplex support for SoundBlaster 16/AWE soundcards
- digital audio data for playback and record should be read back using
proc filesystem
* OSS/Lite compatibility
- full mixer compatibity
- full PCM (/dev/dsp) compatibility
%changelog
* Mon May 28 1998 Helge Jensen <slog@slog.dk>
- Made SPEC file
%prep
%setup -n alsa-utils
%build
./configure --prefix=/usr
make
%install
mkdir -p $RPM_BUILD_ROOT/usr/bin
make prefix="$RPM_BUILD_ROOT/usr" install
%clean
rm -rf $RPM_BUILD_ROOT
%files
%defattr(-, root, root)
%doc CHANGELOG COPYING README config.status
%{prefix}/usr/bin/*

35
utils/buildrpm Normal file
View file

@ -0,0 +1,35 @@
#!/bin/bash
source=.
version=`cat $source/../version`
package=$source/../../alsa-utils-$version.tar.gz
if [ ! -r $package ]; then
echo "Error: wrong package: $package"
exit 1
fi
make -C .. pack
cp -fv $package /usr/src/redhat/SOURCES
if [ ! -r $source/buildrpm ]; then
echo "Error: invalid directory: $source"
exit 1
fi
if [ ! -d /usr/src/redhat ]; then
echo "Error: /usr/src/redhat directory not found"
exit 1
fi
if [ ! -r $source/alsadriver.spec ]; then
cd $source/..
./configure
cd utils
fi
cp -fv $source/alsa-utils.spec /usr/src/redhat/SPECS
cd /usr/src/redhat/SPECS
rpm -ba alsa-utils.spec
cd /usr/src/redhat

1
version Normal file
View file

@ -0,0 +1 @@
0.0.5