From: Jaroslav Kysela Date: Thu, 13 Aug 1998 15:43:39 +0000 (+0000) Subject: Initial revision X-Git-Tag: v1.0.3~571 X-Git-Url: https://git.alsa-project.org/?a=commitdiff_plain;h=fbb20e85ecb0419c4cb8143e3a3fcd0a6f31d9c4;p=alsa-utils.git Initial revision --- fbb20e85ecb0419c4cb8143e3a3fcd0a6f31d9c4 diff --git a/CHANGELOG b/CHANGELOG new file mode 100644 index 0000000..0fd93d5 --- /dev/null +++ b/CHANGELOG @@ -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 +* enhanced Mixer from Andy Lo A Foe 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) diff --git a/COPYING b/COPYING new file mode 100644 index 0000000..dc63aac --- /dev/null +++ b/COPYING @@ -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. + + + Copyright (C) 19yy + + 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. + + , 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. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..e89c839 --- /dev/null +++ b/Makefile @@ -0,0 +1,46 @@ +# +# Makefile for ALSA Utilities +# Copyright (c) 1994-98 by Jaroslav Kysela +# + +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 diff --git a/Makefile.conf b/Makefile.conf new file mode 100644 index 0000000..306246e --- /dev/null +++ b/Makefile.conf @@ -0,0 +1,29 @@ +# Generated automatically from Makefile.conf.in by configure. +# +# Configuration Makefile for ALSA Utilities +# Copyright (c) 1994-98 by Jaroslav Kysela +# + +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="" +NCURSESLIB=-lncurses +LN_S=@LN_S@ diff --git a/Makefile.conf.in b/Makefile.conf.in new file mode 100644 index 0000000..ed8edb9 --- /dev/null +++ b/Makefile.conf.in @@ -0,0 +1,29 @@ +# +# Configuration Makefile for ALSA Utilities +# Copyright (c) 1994-98 by Jaroslav Kysela +# + +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="" +NCURSESLIB=-lncurses +LN_S=@LN_S@ diff --git a/README b/README new file mode 100644 index 0000000..ecf5a00 --- /dev/null +++ b/README @@ -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 diff --git a/alsamixer/Makefile b/alsamixer/Makefile new file mode 100644 index 0000000..09db3b7 --- /dev/null +++ b/alsamixer/Makefile @@ -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 *~ diff --git a/alsamixer/alsamixer.c b/alsamixer/alsamixer.c new file mode 100644 index 0000000..377ff71 --- /dev/null +++ b/alsamixer/alsamixer.c @@ -0,0 +1,870 @@ +/* AlsaMixer - Commandline mixer for the ALSA project + * Copyright (C) 1998 Jaroslav Kysela & Tim Janik + * + * 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 +#include +#include +#include +#include + +#include + +#include +#include +#include +#include + +#ifndef NCURSESINC +#include +#else +#include NCURSESINC +#endif +#include + +#include + +/* 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 ] [-m ]\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, ""); +}; diff --git a/amixer/Makefile b/amixer/Makefile new file mode 100644 index 0000000..1f82b6f --- /dev/null +++ b/amixer/Makefile @@ -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 *~ + diff --git a/amixer/README.first b/amixer/README.first new file mode 100644 index 0000000..daf520a --- /dev/null +++ b/amixer/README.first @@ -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 + + +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 diff --git a/amixer/amain.cpp b/amixer/amain.cpp new file mode 100644 index 0000000..761a56a --- /dev/null +++ b/amixer/amain.cpp @@ -0,0 +1,256 @@ +/* + * Copyright 1998, Andy Lo A Foe + * + * 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 +#include +#include +#include +#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 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; +} diff --git a/amixer/amixer b/amixer/amixer new file mode 100644 index 0000000..202cbc7 Binary files /dev/null and b/amixer/amixer differ diff --git a/amixer/amixer.cpp b/amixer/amixer.cpp new file mode 100644 index 0000000..af7f925 --- /dev/null +++ b/amixer/amixer.cpp @@ -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 +#include +#include +#include +#include +#include +#include +#include +#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? */ + } +} + diff --git a/amixer/amixer.h b/amixer/amixer.h new file mode 100644 index 0000000..84600ff --- /dev/null +++ b/amixer/amixer.h @@ -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; +}; diff --git a/amixer/atypes.h b/amixer/atypes.h new file mode 100644 index 0000000..8ccd461 --- /dev/null +++ b/amixer/atypes.h @@ -0,0 +1 @@ +typedef int int32; diff --git a/aplay/Makefile b/aplay/Makefile new file mode 100644 index 0000000..f797589 --- /dev/null +++ b/aplay/Makefile @@ -0,0 +1,34 @@ +# +# Makefile for aplay program +# Copyright (c) 1994-98 by Jaroslav Kysela +# + +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 diff --git a/aplay/aplay b/aplay/aplay new file mode 100644 index 0000000..6758688 Binary files /dev/null and b/aplay/aplay differ diff --git a/aplay/aplay.c b/aplay/aplay.c new file mode 100644 index 0000000..f50ef63 --- /dev/null +++ b/aplay/aplay.c @@ -0,0 +1,1153 @@ +/* + * aplay.c - plays and records + * + * CREATIVE LABS VOICE-files + * Microsoft WAVE-files + * SPARC AUDIO .AU-files + * Raw Data + * + * Copyright (c) by Jaroslav Kysela + * Based on vplay program by Michael Beck + * + * + * 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include "config.h" +#include "formats.h" + +#define DEFAULT_SPEED 8000 + +#define FORMAT_DEFAULT -1 +#define FORMAT_RAW 0 +#define FORMAT_VOC 1 +#define FORMAT_WAVE 2 +#define FORMAT_AU 3 + +/* global data */ + +char *command; +void *pcm_handle; +struct snd_pcm_playback_info pinfo; +struct snd_pcm_record_info rinfo; +snd_pcm_format_t rformat, format; +int timelimit = 0; +int quiet_mode = 0; +int verbose_mode = 0; +int active_format = FORMAT_DEFAULT; +int direction = SND_PCM_OPEN_PLAYBACK; +char *audiobuf = NULL; +int buffer_size = -1; + +int count; +int vocmajor, vocminor; + +/* needed prototypes */ + +static void playback( char *filename ); +static void record( char *filename ); + +static void begin_voc( int fd, u_long count ); +static void end_voc( int fd ); +static void begin_wave( int fd, u_long count ); +static void end_wave( int fd ); +static void begin_au( int fd, u_long count ); + +struct fmt_record { + void (*start)(int fd, u_long count); + void (*end) (int fd); + char *what; +} fmt_rec_table[] = { + { NULL, end_wave, "raw data" }, + { begin_voc, end_voc, "VOC" }, + { begin_wave, end_wave, "WAVE" }, + { begin_au, end_wave, "Sparc Audio" } +}; + +static char *get_format( int format ) +{ + static char *formats[] = { + "Mu-Law", + "A-Law", + "Ima-ADPCM", + "Unsigned 8-bit", + "Signed 16-bit Little Endian", + "Signed 16-bit Big Endian", + "Signed 8-bit", + "Unsigned 16-bit Little Endian", + "Unsigned 16-bit Big Endian", + "MPEG", + "GSM" + }; + if ( format < 0 || format > SND_PCM_SFMT_GSM ) + return "Unknown"; + return formats[ format ]; +} + +static void check_new_format( snd_pcm_format_t *format ) +{ + if ( direction == SND_PCM_OPEN_PLAYBACK ) { + if ( pinfo.min_rate > format -> rate || pinfo.max_rate < format -> rate ) { + fprintf( stderr, "%s: unsupported rate %iHz for playback (valid range is %iHz-%iHz)\n", command, format -> rate, pinfo.min_rate, pinfo.max_rate ); + exit( 1 ); + } + if ( format -> format != SND_PCM_SFMT_MU_LAW ) + if ( !(pinfo.formats & (1 << format -> format)) ) { + fprintf( stderr, "%s: requested format %s isn't supported with hardware\n", command, get_format( format -> format ) ); + exit( 1 ); + } + } else { + if ( rinfo.min_rate > format -> rate || rinfo.max_rate < format -> rate ) { + fprintf( stderr, "%s: unsupported rate %iHz for record (valid range is %iHz-%iHz)\n", command, format -> rate, rinfo.min_rate, rinfo.max_rate ); + exit( 1 ); + } + if ( format -> format != SND_PCM_SFMT_MU_LAW ) + if ( !(rinfo.formats & (1 << format -> format)) ) { + fprintf( stderr, "%s: requested format %s isn't supported with hardware\n", command, get_format( rformat.format ) ); + exit( 1 ); + } + } +} + +static void usage( char *command ) +{ + fprintf (stderr, +"Usage: %s [switches] [filename] ...\n" +"Available switches:\n" +"\n" +" -h,--help help\n" +" -V,--version print current version\n" +" -l list all soundcards and digital audio devices\n" +" -c select card # or card id (1-%i), defaults to 1\n" +" -d select device #, defaults to 0\n" +" -q quiet mode\n" +" -v file format Voc\n" +" -u file format Sparc Audio (.au)\n" +" -w file format Wave\n" +" -r file format Raw\n" +" -S stereo\n" +" -t timelimit (seconds)\n" +" -s speed (Hz)\n" +" -b sample size (8,16 bits)\n" +" -m set CD-ROM quality (44100Hz,stereo,16-bit linear)\n" +" -M set DAT quality (48000Hz,stereo,16-bit linear)\n" +" -p compression type (alaw, ulaw, adpcm)\n" +, command, snd_cards() ); +} + +static void device_list( void ) +{ + void *handle; + int card, err, dev, idx; + unsigned int mask; + struct snd_ctl_hw_info info; + snd_pcm_info_t pcminfo; + snd_pcm_playback_info_t playinfo; + snd_pcm_record_info_t recinfo; + + mask = snd_cards_mask(); + if ( !mask ) { + printf( "%s: no soundcards found...\n", command ); + return; + } + for ( card = 0; card < SND_CARDS; card++ ) { + if ( !(mask & (1 << card)) ) continue; + if ( (err = snd_ctl_open( &handle, card )) < 0 ) { + printf( "Error: control open (%i): %s\n", card, snd_strerror( err ) ); + continue; + } + if ( (err = snd_ctl_hw_info( handle, &info )) < 0 ) { + printf( "Error: control hardware info (%i): %s\n", card, snd_strerror( err ) ); + snd_ctl_close( handle ); + continue; + } + for ( dev = 0; dev < info.pcmdevs; dev++ ) { + if ( (err = snd_ctl_pcm_info( handle, dev, &pcminfo )) < 0 ) { + printf( "Error: control digital audio info (%i): %s\n", card, snd_strerror( err ) ); + continue; + } + printf( "%s: %i [%s] / #%i: %s\n", + info.name, + card + 1, + info.id, + dev, + pcminfo.name ); + printf( " Directions: %s%s%s\n", + pcminfo.flags & SND_PCM_INFO_PLAYBACK ? "playback " : "", + pcminfo.flags & SND_PCM_INFO_RECORD ? "record " : "", + pcminfo.flags & SND_PCM_INFO_DUPLEX ? "duplex " : "" ); + if ( (err = snd_ctl_pcm_playback_info( handle, dev, &playinfo )) < 0 ) { + printf( "Error: control digital audio playback info (%i): %s\n", card, snd_strerror( err ) ); + continue; + } + if ( pcminfo.flags & SND_PCM_INFO_PLAYBACK ) { + printf( " Playback:\n" ); + printf( " Speed range: %iHz-%iHz\n", playinfo.min_rate, playinfo.max_rate ); + printf( " Voices range: %i-%i\n", playinfo.min_channels, playinfo.max_channels ); + printf( " Formats:\n" ); + for ( idx = 0; idx < SND_PCM_SFMT_GSM; idx++ ) { + if ( playinfo.formats & (1 << idx) ) + printf( " %s\n", get_format( idx ) ); + } + if ( (err = snd_ctl_pcm_record_info( handle, dev, &recinfo )) < 0 ) { + printf( "Error: control digital audio record info (%i): %s\n", card, snd_strerror( err ) ); + continue; + } + } + if ( pcminfo.flags & SND_PCM_INFO_RECORD ) { + printf( " Record:\n" ); + printf( " Speed range: %iHz-%iHz\n", recinfo.min_rate, recinfo.max_rate ); + printf( " Voices range: %i-%i\n", recinfo.min_channels, recinfo.max_channels ); + printf( " Formats:\n" ); + for ( idx = 0; idx < SND_PCM_SFMT_GSM; idx++ ) { + if ( recinfo.formats & (1 << idx) ) + printf( " %s\n", get_format( idx ) ); + } + } + } + snd_ctl_close( handle ); + } +} + +static void version( void ) +{ + printf( "%s: version " SND_UTIL_VERSION " by Jaroslav Kysela \n", command ); +} + +int main( int argc, char *argv[] ) +{ + int card, dev, tmp, err, c; + + card = 0; + dev = 0; + command = argv[0]; + active_format = FORMAT_DEFAULT; + if ( strstr( argv[0], "arecord" ) ) { + direction = SND_PCM_OPEN_RECORD; + active_format = FORMAT_WAVE; + command = "Arecord"; + } else if ( strstr( argv[0], "aplay" ) ) { + direction = SND_PCM_OPEN_PLAYBACK; + command = "Aplay"; + } else { + fprintf( stderr, "Error: command should be named either arecord or aplay\n"); + return 1; + } + + buffer_size = -1; + memset( &rformat, 0, sizeof( rformat ) ); + rformat.format = SND_PCM_SFMT_U8; + rformat.rate = DEFAULT_SPEED; + rformat.channels = 1; + + if ( argc > 1 && !strcmp( argv[1], "--help" ) ) { + usage( command ); + return 0; + } + if ( argc > 1 && !strcmp( argv[1], "--version" ) ) { + version(); + return 0; + } + while ( (c = getopt( argc, argv, "hlc:d:qs:So:t:b:vrwuxB:c:p:mM" )) != EOF ) + switch ( c ) { + case 'h': + usage( command ); + return 0; + case 'l': + device_list(); + return 0; + case 'c': + card = snd_card_name( optarg ); + if ( card < 0 ) { + fprintf( stderr, "Error: soundcard '%s' not found\n", optarg ); + return 1; + } + break; + case 'd': + dev = atoi( optarg ); + if ( dev < 0 || dev > 32 ) { + fprintf( stderr, "Error: device %i is invalid\n", dev ); + return 1; + } + break; + case 'S': + rformat.channels = 2; + break; + case 'o': + tmp = atoi( optarg ); + if ( tmp < 1 || tmp > 32 ) { + fprintf( stderr, "Error: value %i for channels is invalid\n", tmp ); + return 1; + } + break; + case 'q': + quiet_mode = 1; + break; + case 'r': + active_format = FORMAT_RAW; + break; + case 'v': + active_format = FORMAT_VOC; + break; + case 'w': + active_format = FORMAT_WAVE; + break; + case 'u': + active_format = FORMAT_AU; + rformat.format = SND_PCM_SFMT_MU_LAW; + break; + case 's': + tmp = atoi( optarg ); + if ( tmp < 300 ) + tmp *= 1000; + rformat.rate = tmp; + if ( tmp < 2000 || tmp > 128000 ) { + fprintf( stderr, "Error: bad speed value %i\n", tmp ); + return 1; + } + break; + case 't': + timelimit = atoi( optarg ); + break; + case 'b': + tmp = atoi( optarg ); + switch( tmp ) { + case 8: + rformat.format = SND_PCM_SFMT_U8; + break; + case 16: + rformat.format = SND_PCM_SFMT_S16_LE; + break; + } + break; + case 'x': + verbose_mode = 1; quiet_mode = 0; + break; + case 'p': + if ( !strcmp( optarg, "alaw" ) ) { + rformat.format = SND_PCM_SFMT_A_LAW; + active_format = FORMAT_RAW; + break; + } else if ( !strcmp( optarg, "ulaw" ) || !strcmp( optarg, "mulaw" ) ) { + rformat.format = SND_PCM_SFMT_MU_LAW; + active_format = FORMAT_RAW; + break; + } if ( !strcmp( optarg, "adpcm" ) ) { + rformat.format = SND_PCM_SFMT_IMA_ADPCM; + active_format = FORMAT_RAW; + break; + } + fprintf( stderr, "Error: wrong extended format '%s'\n", optarg ); + return 1; + case 'm': + case 'M': + rformat.format = SND_PCM_SFMT_S16_LE; + rformat.rate = c == 'M' ? 48000 : 44100; + rformat.channels = 2; + break; + case 'V': + version(); + return 0; + default: + usage( command ); + return 1; + } + + if ( !quiet_mode ) + version(); + + if ( (err = snd_pcm_open( &pcm_handle, card, dev, direction )) < 0 ) { + fprintf( stderr, "Error: audio open error: %s\n", snd_strerror( err ) ); + return 1; + } + + if ( direction == SND_PCM_OPEN_PLAYBACK ) { + if ( (err = snd_pcm_playback_info( pcm_handle, &pinfo )) < 0 ) { + fprintf( stderr, "Error: playback info error: %s\n", snd_strerror( err ) ); + return 1; + } + tmp = pinfo.buffer_size; + tmp /= 4; /* 4 fragments are best */ + } else { + if ( (err = snd_pcm_record_info( pcm_handle, &rinfo )) < 0 ) { + fprintf( stderr, "Error: record info error: %s\n", snd_strerror( err ) ); + return 1; + } + tmp = rinfo.buffer_size; + tmp /= 8; /* 8 fragments are best */ + } + + buffer_size = tmp; + if (buffer_size < 512 || buffer_size > 16L * 1024L * 1024L ) { + fprintf( stderr, "Error: Invalid audio buffer size %d\n", buffer_size ); + return 1; + } + + check_new_format( &rformat ); + format = rformat; + + if ( (audiobuf = malloc( buffer_size )) == NULL ) { + fprintf( stderr, "%s: unable to allocate input/output buffer\n", command ); + return 1; + } + + if ( optind > argc - 1 ) { + if ( direction == SND_PCM_OPEN_PLAYBACK ) + playback( NULL ); + else + record( NULL ); + } else { + while ( optind <= argc - 1 ) { + if ( direction == SND_PCM_OPEN_PLAYBACK ) + playback( argv[optind++] ); + else + record( argv[optind++] ); + } + } + snd_pcm_close( pcm_handle ); + return 0; +} + +/* + * Test, if it is a .VOC file and return >=0 if ok (this is the length of rest) + * < 0 if not + */ +static int test_vocfile(void *buffer) +{ + VocHeader *vp = buffer; + + if (strstr(vp->magic, VOC_MAGIC_STRING) ) { + vocminor = vp->version & 0xFF; + vocmajor = vp->version / 256; + if (vp->version != (0x1233 - vp->coded_ver) ) + return -2; /* coded version mismatch */ + return vp->headerlen - sizeof(VocHeader); /* 0 mostly */ + } + return -1; /* magic string fail */ +} + +/* + * test, if it's a .WAV file, 0 if ok (and set the speed, stereo etc.) + * < 0 if not + */ +static int test_wavefile( void *buffer ) +{ + WaveHeader *wp = buffer; + + if (wp->main_chunk == WAV_RIFF && wp->chunk_type == WAV_WAVE && + wp->sub_chunk == WAV_FMT && wp->data_chunk == WAV_DATA) { + if (wp->format != WAV_PCM_CODE) { + fprintf( stderr, "%s: can't play not PCM-coded WAVE-files\n", command); + exit( 1 ); + } + if (wp -> modus < 1 || wp->modus > 32) { + fprintf(stderr, "%s: can't play WAVE-files with %d tracks\n", + command, wp->modus); + exit( 1 ); + } + format.channels = wp->modus; + switch ( wp->bit_p_spl ) { + case 8: + format.format = SND_PCM_SFMT_U8; + break; + case 16: + format.format = SND_PCM_SFMT_S16_LE; + break; + default: + fprintf(stderr, "%s: can't play WAVE-files with sample %d bits wide\n", + command, wp->bit_p_spl); + } + format.rate = wp -> sample_fq; + count = wp -> data_length; + check_new_format( &format ); + return 0; + } + return -1; +} + +/* + * + */ + +static int test_au( int fd, void *buffer ) +{ + AuHeader *ap = buffer; + + if ( ntohl( ap -> magic ) != AU_MAGIC ) + return -1; + if ( ntohl( ap -> hdr_size ) > 128 || ntohl( ap -> hdr_size ) < 24 ) + return -1; + count = ntohl( ap -> data_size ); + switch ( ntohl( ap -> encoding ) ) { + case AU_FMT_ULAW: + format.format = SND_PCM_SFMT_MU_LAW; + break; + case AU_FMT_LIN8: + format.format = SND_PCM_SFMT_U8; + break; + case AU_FMT_LIN16: + format.format = SND_PCM_SFMT_U16_LE; + break; + default: + return -1; + } + format.rate = ntohl( ap -> sample_rate ); + if ( format.rate < 2000 || format.rate > 256000 ) return -1; + format.channels = ntohl( ap -> channels ); + if ( format.channels < 1 || format.channels > 128 ) return -1; + if ( read( fd, buffer + sizeof( AuHeader ), ntohl( ap -> hdr_size ) - sizeof( AuHeader ) ) < 0 ) { + fprintf( stderr, "%s: read error\n", command ); + exit( 1 ); + } + check_new_format( &format ); + return 0; +} + +/* + * writing zeros from the zerobuf to simulate silence, + * perhaps it's enough to use a long var instead of zerobuf ? + */ +static void write_zeros( unsigned x ) +{ + unsigned l; + char *buf; + + buf = (char *)malloc( buffer_size ); + if ( !buf ) { + fprintf( stderr, "%s: can allocate buffer for zeros\n", command ); + return; /* not fatal error */ + } + memset( buf, 128, buffer_size ); + while ( x > 0 ) { + l = x; + if ( l > buffer_size ) l = buffer_size; + if ( snd_pcm_write( pcm_handle, buf, l ) != l ) { + fprintf( stderr, "%s: write error\n", command ); + exit( 1 ); + } + x -= l; + } +} + +static void set_format(void) +{ + unsigned int bps; /* bytes per second */ + unsigned int size; /* fragment size */ + struct snd_pcm_playback_params pparams; + struct snd_pcm_record_params rparams; + + bps = format.rate * format.channels; + switch ( format.format ) { + case SND_PCM_SFMT_U16_LE: + case SND_PCM_SFMT_U16_BE: + bps <<= 1; + break; + case SND_PCM_SFMT_IMA_ADPCM: + bps >>= 2; + break; + } + bps >>= 2; /* ok.. this buffer should be 0.25 sec */ + if ( bps < 16 ) bps = 16; + size = buffer_size; + while ( size > bps ) size >>= 1; + if ( size < 16 ) size = 16; + + if ( direction == SND_PCM_OPEN_PLAYBACK ) { + if ( snd_pcm_playback_format( pcm_handle, &format ) < 0 ) { + fprintf( stderr, "%s: unable to set playback format %s, %iHz, %i voices\n", command, get_format( format.format ), format.rate, format.channels ); + exit( 1 ); + } + memset( &pparams, 0, sizeof( pparams ) ); + pparams.fragment_size = size; + pparams.fragments_max = -1; /* little trick */ + pparams.fragments_room = 1; + if ( snd_pcm_playback_params( pcm_handle, &pparams ) < 0 ) { + fprintf( stderr, "%s: unable to set playback params\n", command ); + exit( 1 ); + } + } else { + if ( snd_pcm_record_format( pcm_handle, &format ) < 0 ) { + fprintf( stderr, "%s: unable to set record format %s, %iHz, %i voices\n", command, get_format( format.format ), format.rate, format.channels ); + exit( 1 ); + } + memset( &rparams, 0, sizeof( rparams ) ); + rparams.fragment_size = size; + rparams.fragments_min = 1; + if ( snd_pcm_record_params( pcm_handle, &rparams ) < 0 ) { + fprintf( stderr, "%s: unable to set record params\n", command ); + exit( 1 ); + } + } +} + +/* + * ok, let's play a .voc file + */ + +static void voc_play( int fd, int ofs, char *name ) +{ + int l; + VocBlockType *bp; + VocVoiceData *vd; + VocExtBlock *eb; + u_long nextblock, in_buffer; + u_char *data = audiobuf; + char was_extended = 0, output = 0; + u_short *sp, repeat = 0; + u_long silence; + int filepos = 0; + +#define COUNT(x) nextblock -= x; in_buffer -=x ;data += x +#define COUNT1(x) in_buffer -=x ;data += x + + if ( !quiet_mode ) { + fprintf( stderr, "Playing Creative Labs Voice file '%s'...\n", name ); + } + + /* first we waste the rest of header, ugly but we don't need seek */ + while ( ofs > buffer_size ) { + if ( read( fd, audiobuf, buffer_size ) != buffer_size ) { + fprintf( stderr, "%s: read error\n", command ); + exit( 1 ); + } + ofs -= buffer_size; + } + if (ofs) + if ( read( fd, audiobuf, ofs ) != ofs ) { + fprintf( stderr, "%s: read error\n", command ); + exit( 1 ); + } + + format.format = SND_PCM_SFMT_U8; + format.channels = 1; + format.rate = DEFAULT_SPEED; + set_format(); + + in_buffer = nextblock = 0; + while (1) { + Fill_the_buffer: /* need this for repeat */ + if ( in_buffer < 32 ) { + /* move the rest of buffer to pos 0 and fill the audiobuf up */ + if (in_buffer) + memcpy (audiobuf, data, in_buffer); + data = audiobuf; + if ((l = read (fd, audiobuf + in_buffer, buffer_size - in_buffer) ) > 0) + in_buffer += l; + else if (! in_buffer) { + /* the file is truncated, so simulate 'Terminator' + and reduce the datablock for save landing */ + nextblock = audiobuf[0] = 0; + if (l == -1) { + perror (name); + exit (-1); + } + } + } + while (! nextblock) { /* this is a new block */ + if (in_buffertype) { + case 0: +#if 0 + d_printf ("Terminator\n"); +#endif + return; /* VOC-file stop */ + case 1: + vd = (VocVoiceData *)data; COUNT1(sizeof(VocVoiceData)); + /* we need a SYNC, before we can set new SPEED, STEREO ... */ + + if (! was_extended) { + format.rate = (int)(vd->tc); + format.rate = 1000000 / (256 - format.rate); +#if 0 + d_printf ("Voice data %d Hz\n", dsp_speed); +#endif + if (vd->pack) { /* /dev/dsp can't it */ + fprintf (stderr, "%s: can't play packed .voc files\n", command); + return; + } + if (format.channels == 2) { /* if we are in Stereo-Mode, switch back */ + format.channels = 1; + set_format(); + } + } + else { /* there was extended block */ + format.channels = 2; + was_extended = 0; + } + set_format(); + break; + case 2: /* nothing to do, pure data */ +#if 0 + d_printf ("Voice continuation\n"); +#endif + break; + case 3: /* a silence block, no data, only a count */ + sp = (u_short *)data; COUNT1(sizeof(u_short)); + format.rate = (int)(*data); COUNT1(1); + format.rate = 1000000 / (256 - format.rate); + set_format(); + silence = ( ((u_long)*sp) * 1000) / format.rate; +#if 0 + d_printf ("Silence for %d ms\n", (int)silence); +#endif + write_zeros (*sp); + snd_pcm_flush_playback( pcm_handle ); + break; + case 4: /* a marker for syncronisation, no effect */ + sp = (u_short *)data; COUNT1(sizeof(u_short)); +#if 0 + d_printf ("Marker %d\n", *sp); +#endif + break; + case 5: /* ASCII text, we copy to stderr */ + output = 1; +#if 0 + d_printf ("ASCII - text :\n"); +#endif + break; + case 6: /* repeat marker, says repeatcount */ + /* my specs don't say it: maybe this can be recursive, but + I don't think somebody use it */ + repeat = *(u_short *)data; COUNT1(sizeof(u_short)); +#if 0 + d_printf ("Repeat loop %d times\n", repeat); +#endif + if (filepos >= 0) /* if < 0, one seek fails, why test another */ + if ( (filepos = lseek (fd, 0, 1)) < 0 ) { + fprintf(stderr, "%s: can't play loops; %s isn't seekable\n", + command, name); + repeat = 0; + } + else + filepos -= in_buffer; /* set filepos after repeat */ + else + repeat = 0; + break; + case 7: /* ok, lets repeat that be rewinding tape */ + if (repeat) { + if (repeat != 0xFFFF) { +#if 0 + d_printf ("Repeat loop %d\n", repeat); +#endif + --repeat; + } +#if 0 + else + d_printf ("Neverending loop\n"); +#endif + lseek (fd, filepos, 0); + in_buffer = 0; /* clear the buffer */ + goto Fill_the_buffer; + } +#if 0 + else + d_printf ("End repeat loop\n"); +#endif + break; + case 8: /* the extension to play Stereo, I have SB 1.0 :-( */ + was_extended = 1; + eb = (VocExtBlock *)data; COUNT1(sizeof(VocExtBlock)); + format.rate = (int)(eb->tc); + format.rate = 256000000L / (65536 - format.rate); + format.channels = eb->mode == VOC_MODE_STEREO ? 2 : 1; + if (format.channels == 2) + format.rate = format.rate >> 1; + if (eb->pack) { /* /dev/dsp can't it */ + fprintf (stderr, "%s: can't play packed .voc files\n", command); + return; + } +#if 0 + d_printf ("Extended block %s %d Hz\n", + (eb->mode ? "Stereo" : "Mono"), dsp_speed); +#endif + break; + default: + fprintf (stderr, "%s: unknown blocktype %d. terminate.\n", + command, bp->type); + return; + } /* switch (bp->type) */ + } /* while (! nextblock) */ + /* put nextblock data bytes to dsp */ + l = in_buffer; + if ( nextblock < l ) l = nextblock; + if (l) { + if (output && !quiet_mode) { + if ( write( 2, data, l) != l ) { /* to stderr */ + fprintf( stderr, "%s: write error\n", command ); + exit(1); + } + } else { + if (snd_pcm_write(pcm_handle, data, l) != l) { + fprintf( stderr, "%s: write error\n", command ); + exit(1); + } + } + COUNT(l); + } + } /* while(1) */ +} +/* that was a big one, perhaps somebody split it :-) */ + +/* setting the globals for playing raw data */ +static void init_raw_data(void) +{ + format = rformat; +} + +/* calculate the data count to read from/to dsp */ +static u_long calc_count(void) +{ + u_long count; + + if (!timelimit) + count = 0x7fffffff; + else { + count = timelimit * format.rate * format.channels; + switch ( format.format ) { + case SND_PCM_SFMT_S16_LE: + case SND_PCM_SFMT_S16_BE: + case SND_PCM_SFMT_U16_LE: + case SND_PCM_SFMT_U16_BE: + count *= 2; + break; + case SND_PCM_SFMT_IMA_ADPCM: + count /= 4; + break; + } + } + return count; +} + +/* write a .VOC-header */ +static void begin_voc( int fd, u_long cnt ) +{ + VocHeader vh; + VocBlockType bt; + VocVoiceData vd; + VocExtBlock eb; + + strncpy( vh.magic, VOC_MAGIC_STRING, 20 ); + vh.magic[19] = 0x1A; + vh.headerlen = sizeof( VocHeader ); + vh.version = VOC_ACTUAL_VERSION; + vh.coded_ver = 0x1233 - VOC_ACTUAL_VERSION; + + if ( write( fd, &vh, sizeof(VocHeader) ) != sizeof(VocHeader) ) { + fprintf( stderr, "%s: write error\n", command ); + exit(1); + } + + if (format.channels > 1) { + /* write a extended block */ + bt.type = 8; + bt.datalen = 4; + bt.datalen_m = bt.datalen_h = 0; + if ( write (fd, &bt, sizeof(VocBlockType)) != sizeof( VocBlockType ) ) { + fprintf( stderr, "%s: write error\n", command ); + exit(1); + } + eb.tc = (u_short)(65536 - 256000000L / (format.rate << 1)); + eb.pack = 0; + eb.mode = 1; + if ( write(fd, &eb, sizeof(VocExtBlock)) != sizeof(VocExtBlock) ) { + fprintf( stderr, "%s: write error\n", command ); + exit(1); + } + } + bt.type = 1; + cnt += sizeof(VocVoiceData); /* Voice_data block follows */ + bt.datalen = (u_char) (cnt & 0xFF); + bt.datalen_m = (u_char)( (cnt & 0xFF00) >> 8 ); + bt.datalen_h = (u_char)( (cnt & 0xFF0000) >> 16 ); + if ( write (fd, &bt, sizeof(VocBlockType)) != sizeof( VocBlockType ) ) { + fprintf( stderr, "%s: write error\n", command ); + exit(1); + } + vd.tc = (u_char)(256 - (1000000 / format.rate) ); + vd.pack = 0; + if ( write (fd, &vd, sizeof(VocVoiceData) ) != sizeof( VocVoiceData ) ) { + fprintf( stderr, "%s: write error\n", command ); + exit(1); + } +} + +/* write a WAVE-header */ +static void begin_wave(int fd, u_long cnt) +{ + WaveHeader wh; + int bits; + + switch ( format.format ) { + case SND_PCM_SFMT_U8: + bits = 8; + break; + case SND_PCM_SFMT_S16_LE: + bits = 16; + break; + default: + fprintf( stderr, "%s: Wave doesn't support %s format...\n", command, get_format( format.format ) ); + exit( 1 ); + } + wh.main_chunk = WAV_RIFF; + wh.length = cnt + sizeof(WaveHeader) - 8; + wh.chunk_type = WAV_WAVE; + wh.sub_chunk = WAV_FMT; + wh.sc_len = 16; + wh.format = WAV_PCM_CODE; + wh.modus = format.channels; + wh.sample_fq = format.rate; +#if 0 + wh.byte_p_spl = (samplesize == 8) ? 1 : 2; + wh.byte_p_sec = dsp_speed * wh.modus * wh.byte_p_spl; +#else + wh.byte_p_spl = wh.modus * ((bits + 7) / 8); + wh.byte_p_sec = wh.byte_p_spl * format.rate; +#endif + wh.bit_p_spl = bits; + wh.data_chunk = WAV_DATA; + wh.data_length= cnt; + if ( write (fd, &wh, sizeof(WaveHeader)) != sizeof( WaveHeader ) ) { + fprintf( stderr, "%s: write error\n", command ); + exit(1); + } +} + +/* write a Au-header */ +static void begin_au(int fd, u_long cnt) +{ + AuHeader ah; + + ah.magic = htonl( AU_MAGIC ); + ah.hdr_size = htonl( 24 ); + ah.data_size = htonl( cnt ); + switch ( format.format ) { + case SND_PCM_SFMT_MU_LAW: + ah.encoding = htonl( AU_FMT_ULAW ); + break; + case SND_PCM_SFMT_U8: + ah.encoding = htonl( AU_FMT_LIN8 ); + break; + case SND_PCM_SFMT_U16_LE: + ah.encoding = htonl( AU_FMT_LIN16 ); + break; + default: + fprintf( stderr, "%s: Sparc Audio doesn't support %s format...\n", command, get_format( format.format ) ); + exit( 1 ); + } + ah.sample_rate = htonl( format.rate ); + ah.channels = htonl( format.channels ); + if ( write (fd, &ah, sizeof(AuHeader)) != sizeof( AuHeader ) ) { + fprintf( stderr, "%s: write error\n", command ); + exit(1); + } +} + +/* closing .VOC */ +static void end_voc(int fd) +{ + char dummy = 0; /* Write a Terminator */ + if ( write (fd, &dummy, 1) != 1 ) { + fprintf( stderr, "%s: write error", command ); + exit( 1 ); + } + if (fd != 1) + close (fd); +} + +static void end_wave(int fd) +{ /* only close output */ + if (fd != 1) + close (fd); +} + +static void header( int rtype, char *name ) +{ + if (!quiet_mode) { + fprintf (stderr, "%s %s '%s' : ", + (direction == SND_PCM_OPEN_PLAYBACK) ? "Playing" : "Recording", + fmt_rec_table[rtype].what, + name ); + fprintf (stderr, "%s, ", get_format( format.format ) ); + fprintf (stderr, "Speed %d Hz, ", format.rate); + if ( format.channels == 1 ) + fprintf (stderr, "Mono" ); + else if ( format.channels == 2 ) + fprintf (stderr, "Stereo" ); + else fprintf (stderr, "Voices %i", format.channels); + fprintf (stderr, "\n" ); + } +} + +/* playing raw data */ + +void playback_go (int fd, int loaded, u_long count, int rtype, char *name) +{ + int l; + u_long c; + + header( rtype, name ); + set_format(); + + while (count) { + c = count; + + if (c > buffer_size) + c = buffer_size; + + if ((l = read (fd, audiobuf + loaded, c - loaded)) > 0) { + l += loaded; loaded = 0; /* correct the count; ugly but ... */ +#if 0 + sleep( 1 ); +#endif + if (snd_pcm_write(pcm_handle, audiobuf, l) != l) { + fprintf( stderr, "write error\n" ); + exit (1); + } + count -= l; + } else { + if (l == -1) { + perror (name); + exit (-1); + } + count = 0; /* Stop */ + } + } /* while (count) */ +} + +/* recording raw data, this proc handels WAVE files and .VOCs (as one block) */ + +void record_go(int fd, int loaded, u_long count, int rtype, char *name) +{ + int l; + u_long c; + + header( rtype, name ); + set_format(); + + while (count) { + c = count; + if (c > buffer_size) + c = buffer_size; + + if ((l = snd_pcm_read(pcm_handle, audiobuf, c)) > 0) { + if (write (fd, audiobuf, l) != l) { + perror (name); + exit (-1); + } + count -= l; + } + + if (l == -1) { + fprintf( stderr, "read error\n" ); + exit (-1); + } + } +} + +/* + * let's play or record it (record_type says VOC/WAVE/raw) + */ + +static void playback(char *name) +{ + int fd, ofs; + + snd_pcm_flush_playback( pcm_handle ); + if (!name) { + fd = 0; + name = "stdin"; + } else { + if ((fd = open (name, O_RDONLY, 0)) == -1) { + perror (name); + exit(1); + } + } + /* read the file header */ + if ( read( fd, audiobuf, sizeof(AuHeader) ) != sizeof( AuHeader ) ) { + fprintf( stderr, "%s: read error", command ); + exit( 1 ); + } + if ( test_au( fd, audiobuf ) >= 0 ) { + playback_go( fd, 0, count, FORMAT_AU, name ); + goto __end; + } + if ( read( fd, audiobuf + sizeof(AuHeader), + sizeof(VocHeader)-sizeof(AuHeader) ) != + sizeof(VocHeader)-sizeof(AuHeader) ) { + fprintf( stderr, "%s: read error", command ); + exit( 1 ); + } + if ( (ofs = test_vocfile (audiobuf) ) >= 0) { + voc_play (fd, ofs, name); + goto __end; + } + /* read bytes for WAVE-header */ + if ( read (fd, audiobuf + sizeof(VocHeader), + sizeof(WaveHeader) - sizeof(VocHeader) ) != + sizeof(WaveHeader) - sizeof(VocHeader) ) { + fprintf( stderr, "%s: read error", command ); + exit( 1 ); + } + if (test_wavefile (audiobuf) >= 0) { + playback_go(fd, 0, count, FORMAT_WAVE, name); + } else { + /* should be raw data */ + init_raw_data(); + count = calc_count(); + playback_go(fd, sizeof(WaveHeader), count, FORMAT_RAW, name); + } + __end: + if (fd != 0) + close(fd); +} + +static void record(char *name) +{ + int fd; + + snd_pcm_flush_record( pcm_handle ); + if (!name) { + fd = 1; + name = "stdout"; + } else { + remove( name ); + if ((fd = open (name, O_WRONLY | O_CREAT, 0644)) == -1) { + perror (name); + exit(1); + } + } + count = calc_count() & 0xFFFFFFFE; + /* WAVE-file should be even (I'm not sure), but wasting one byte + isn't a problem (this can only be in 8 bit mono) */ + if (fmt_rec_table[active_format].start) + fmt_rec_table[active_format].start(fd, count); + record_go( fd, 0, count, active_format, name); + fmt_rec_table[active_format].end(fd); +} diff --git a/aplay/formats.h b/aplay/formats.h new file mode 100644 index 0000000..57f4277 --- /dev/null +++ b/aplay/formats.h @@ -0,0 +1,91 @@ +#ifndef FORMATS_H +#define FORMATS_H 1 + +#include + +/* 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 */ diff --git a/config.cache b/config.cache new file mode 100644 index 0000000..59c297d --- /dev/null +++ b/config.cache @@ -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'} diff --git a/config.log b/config.log new file mode 100644 index 0000000..018e5ab --- /dev/null +++ b/config.log @@ -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 diff --git a/config.status b/config.status new file mode 100644 index 0000000..8e745dc --- /dev/null +++ b/config.status @@ -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 < conftest.out + rm -f conftest.in + mv conftest.out conftest.in + + cat > conftest.frag < 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 diff --git a/configure b/configure new file mode 100644 index 0000000..b92a8f0 --- /dev/null +++ b/configure @@ -0,0 +1,1622 @@ +#! /bin/sh + +# Guess values for system-dependent variables and create Makefiles. +# Generated automatically using autoconf version 2.12 +# Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc. +# +# This configure script is free software; the Free Software Foundation +# gives unlimited permission to copy, distribute and modify it. + +# Defaults: +ac_help= +ac_default_prefix=/usr/local +# Any additions from configure.in: +ac_default_prefix=/usr + +# Initialize some variables set by options. +# The variables have the same names as the options, with +# dashes changed to underlines. +build=NONE +cache_file=./config.cache +exec_prefix=NONE +host=NONE +no_create= +nonopt=NONE +no_recursion= +prefix=NONE +program_prefix=NONE +program_suffix=NONE +program_transform_name=s,x,x, +silent= +site= +srcdir= +target=NONE +verbose= +x_includes=NONE +x_libraries=NONE +bindir='${exec_prefix}/bin' +sbindir='${exec_prefix}/sbin' +libexecdir='${exec_prefix}/libexec' +datadir='${prefix}/share' +sysconfdir='${prefix}/etc' +sharedstatedir='${prefix}/com' +localstatedir='${prefix}/var' +libdir='${exec_prefix}/lib' +includedir='${prefix}/include' +oldincludedir='/usr/include' +infodir='${prefix}/info' +mandir='${prefix}/man' + +# Initialize some other variables. +subdirs= +MFLAGS= MAKEFLAGS= +# Maximum number of lines to put in a shell here document. +ac_max_here_lines=12 + +ac_prev= +for ac_option +do + + # If the previous option needs an argument, assign it. + if test -n "$ac_prev"; then + eval "$ac_prev=\$ac_option" + ac_prev= + continue + fi + + case "$ac_option" in + -*=*) ac_optarg=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;; + *) ac_optarg= ;; + esac + + # Accept the important Cygnus configure options, so we can diagnose typos. + + case "$ac_option" in + + -bindir | --bindir | --bindi | --bind | --bin | --bi) + ac_prev=bindir ;; + -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) + bindir="$ac_optarg" ;; + + -build | --build | --buil | --bui | --bu) + ac_prev=build ;; + -build=* | --build=* | --buil=* | --bui=* | --bu=*) + build="$ac_optarg" ;; + + -cache-file | --cache-file | --cache-fil | --cache-fi \ + | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) + ac_prev=cache_file ;; + -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ + | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) + cache_file="$ac_optarg" ;; + + -datadir | --datadir | --datadi | --datad | --data | --dat | --da) + ac_prev=datadir ;; + -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \ + | --da=*) + datadir="$ac_optarg" ;; + + -disable-* | --disable-*) + ac_feature=`echo $ac_option|sed -e 's/-*disable-//'` + # Reject names that are not valid shell variable names. + if test -n "`echo $ac_feature| sed 's/[-a-zA-Z0-9_]//g'`"; then + { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; } + fi + ac_feature=`echo $ac_feature| sed 's/-/_/g'` + eval "enable_${ac_feature}=no" ;; + + -enable-* | --enable-*) + ac_feature=`echo $ac_option|sed -e 's/-*enable-//' -e 's/=.*//'` + # Reject names that are not valid shell variable names. + if test -n "`echo $ac_feature| sed 's/[-_a-zA-Z0-9]//g'`"; then + { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; } + fi + ac_feature=`echo $ac_feature| sed 's/-/_/g'` + case "$ac_option" in + *=*) ;; + *) ac_optarg=yes ;; + esac + eval "enable_${ac_feature}='$ac_optarg'" ;; + + -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ + | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ + | --exec | --exe | --ex) + ac_prev=exec_prefix ;; + -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ + | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ + | --exec=* | --exe=* | --ex=*) + exec_prefix="$ac_optarg" ;; + + -gas | --gas | --ga | --g) + # Obsolete; use --with-gas. + with_gas=yes ;; + + -help | --help | --hel | --he) + # Omit some internal or obsolete options to make the list less imposing. + # This message is too long to be a string in the A/UX 3.1 sh. + cat << EOF +Usage: configure [options] [host] +Options: [defaults in brackets after descriptions] +Configuration: + --cache-file=FILE cache test results in FILE + --help print this message + --no-create do not create output files + --quiet, --silent do not print \`checking...' messages + --version print the version of autoconf that created configure +Directory and file names: + --prefix=PREFIX install architecture-independent files in PREFIX + [$ac_default_prefix] + --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX + [same as prefix] + --bindir=DIR user executables in DIR [EPREFIX/bin] + --sbindir=DIR system admin executables in DIR [EPREFIX/sbin] + --libexecdir=DIR program executables in DIR [EPREFIX/libexec] + --datadir=DIR read-only architecture-independent data in DIR + [PREFIX/share] + --sysconfdir=DIR read-only single-machine data in DIR [PREFIX/etc] + --sharedstatedir=DIR modifiable architecture-independent data in DIR + [PREFIX/com] + --localstatedir=DIR modifiable single-machine data in DIR [PREFIX/var] + --libdir=DIR object code libraries in DIR [EPREFIX/lib] + --includedir=DIR C header files in DIR [PREFIX/include] + --oldincludedir=DIR C header files for non-gcc in DIR [/usr/include] + --infodir=DIR info documentation in DIR [PREFIX/info] + --mandir=DIR man documentation in DIR [PREFIX/man] + --srcdir=DIR find the sources in DIR [configure dir or ..] + --program-prefix=PREFIX prepend PREFIX to installed program names + --program-suffix=SUFFIX append SUFFIX to installed program names + --program-transform-name=PROGRAM + run sed PROGRAM on installed program names +EOF + cat << EOF +Host type: + --build=BUILD configure for building on BUILD [BUILD=HOST] + --host=HOST configure for HOST [guessed] + --target=TARGET configure for TARGET [TARGET=HOST] +Features and packages: + --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) + --enable-FEATURE[=ARG] include FEATURE [ARG=yes] + --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] + --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) + --x-includes=DIR X include files are in DIR + --x-libraries=DIR X library files are in DIR +EOF + if test -n "$ac_help"; then + echo "--enable and --with options recognized:$ac_help" + fi + exit 0 ;; + + -host | --host | --hos | --ho) + ac_prev=host ;; + -host=* | --host=* | --hos=* | --ho=*) + host="$ac_optarg" ;; + + -includedir | --includedir | --includedi | --included | --include \ + | --includ | --inclu | --incl | --inc) + ac_prev=includedir ;; + -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ + | --includ=* | --inclu=* | --incl=* | --inc=*) + includedir="$ac_optarg" ;; + + -infodir | --infodir | --infodi | --infod | --info | --inf) + ac_prev=infodir ;; + -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) + infodir="$ac_optarg" ;; + + -libdir | --libdir | --libdi | --libd) + ac_prev=libdir ;; + -libdir=* | --libdir=* | --libdi=* | --libd=*) + libdir="$ac_optarg" ;; + + -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ + | --libexe | --libex | --libe) + ac_prev=libexecdir ;; + -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ + | --libexe=* | --libex=* | --libe=*) + libexecdir="$ac_optarg" ;; + + -localstatedir | --localstatedir | --localstatedi | --localstated \ + | --localstate | --localstat | --localsta | --localst \ + | --locals | --local | --loca | --loc | --lo) + ac_prev=localstatedir ;; + -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ + | --localstate=* | --localstat=* | --localsta=* | --localst=* \ + | --locals=* | --local=* | --loca=* | --loc=* | --lo=*) + localstatedir="$ac_optarg" ;; + + -mandir | --mandir | --mandi | --mand | --man | --ma | --m) + ac_prev=mandir ;; + -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) + mandir="$ac_optarg" ;; + + -nfp | --nfp | --nf) + # Obsolete; use --without-fp. + with_fp=no ;; + + -no-create | --no-create | --no-creat | --no-crea | --no-cre \ + | --no-cr | --no-c) + no_create=yes ;; + + -no-recursion | --no-recursion | --no-recursio | --no-recursi \ + | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) + no_recursion=yes ;; + + -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ + | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ + | --oldin | --oldi | --old | --ol | --o) + ac_prev=oldincludedir ;; + -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ + | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ + | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) + oldincludedir="$ac_optarg" ;; + + -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) + ac_prev=prefix ;; + -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) + prefix="$ac_optarg" ;; + + -program-prefix | --program-prefix | --program-prefi | --program-pref \ + | --program-pre | --program-pr | --program-p) + ac_prev=program_prefix ;; + -program-prefix=* | --program-prefix=* | --program-prefi=* \ + | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) + program_prefix="$ac_optarg" ;; + + -program-suffix | --program-suffix | --program-suffi | --program-suff \ + | --program-suf | --program-su | --program-s) + ac_prev=program_suffix ;; + -program-suffix=* | --program-suffix=* | --program-suffi=* \ + | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) + program_suffix="$ac_optarg" ;; + + -program-transform-name | --program-transform-name \ + | --program-transform-nam | --program-transform-na \ + | --program-transform-n | --program-transform- \ + | --program-transform | --program-transfor \ + | --program-transfo | --program-transf \ + | --program-trans | --program-tran \ + | --progr-tra | --program-tr | --program-t) + ac_prev=program_transform_name ;; + -program-transform-name=* | --program-transform-name=* \ + | --program-transform-nam=* | --program-transform-na=* \ + | --program-transform-n=* | --program-transform-=* \ + | --program-transform=* | --program-transfor=* \ + | --program-transfo=* | --program-transf=* \ + | --program-trans=* | --program-tran=* \ + | --progr-tra=* | --program-tr=* | --program-t=*) + program_transform_name="$ac_optarg" ;; + + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + silent=yes ;; + + -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) + ac_prev=sbindir ;; + -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ + | --sbi=* | --sb=*) + sbindir="$ac_optarg" ;; + + -sharedstatedir | --sharedstatedir | --sharedstatedi \ + | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ + | --sharedst | --shareds | --shared | --share | --shar \ + | --sha | --sh) + ac_prev=sharedstatedir ;; + -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ + | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ + | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ + | --sha=* | --sh=*) + sharedstatedir="$ac_optarg" ;; + + -site | --site | --sit) + ac_prev=site ;; + -site=* | --site=* | --sit=*) + site="$ac_optarg" ;; + + -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) + ac_prev=srcdir ;; + -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) + srcdir="$ac_optarg" ;; + + -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ + | --syscon | --sysco | --sysc | --sys | --sy) + ac_prev=sysconfdir ;; + -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ + | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) + sysconfdir="$ac_optarg" ;; + + -target | --target | --targe | --targ | --tar | --ta | --t) + ac_prev=target ;; + -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) + target="$ac_optarg" ;; + + -v | -verbose | --verbose | --verbos | --verbo | --verb) + verbose=yes ;; + + -version | --version | --versio | --versi | --vers) + echo "configure generated by autoconf version 2.12" + exit 0 ;; + + -with-* | --with-*) + ac_package=`echo $ac_option|sed -e 's/-*with-//' -e 's/=.*//'` + # Reject names that are not valid shell variable names. + if test -n "`echo $ac_package| sed 's/[-_a-zA-Z0-9]//g'`"; then + { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; } + fi + ac_package=`echo $ac_package| sed 's/-/_/g'` + case "$ac_option" in + *=*) ;; + *) ac_optarg=yes ;; + esac + eval "with_${ac_package}='$ac_optarg'" ;; + + -without-* | --without-*) + ac_package=`echo $ac_option|sed -e 's/-*without-//'` + # Reject names that are not valid shell variable names. + if test -n "`echo $ac_package| sed 's/[-a-zA-Z0-9_]//g'`"; then + { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; } + fi + ac_package=`echo $ac_package| sed 's/-/_/g'` + eval "with_${ac_package}=no" ;; + + --x) + # Obsolete; use --with-x. + with_x=yes ;; + + -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ + | --x-incl | --x-inc | --x-in | --x-i) + ac_prev=x_includes ;; + -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ + | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) + x_includes="$ac_optarg" ;; + + -x-libraries | --x-libraries | --x-librarie | --x-librari \ + | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) + ac_prev=x_libraries ;; + -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ + | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) + x_libraries="$ac_optarg" ;; + + -*) { echo "configure: error: $ac_option: invalid option; use --help to show usage" 1>&2; exit 1; } + ;; + + *) + if test -n "`echo $ac_option| sed 's/[-a-z0-9.]//g'`"; then + echo "configure: warning: $ac_option: invalid host type" 1>&2 + fi + if test "x$nonopt" != xNONE; then + { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; } + fi + nonopt="$ac_option" + ;; + + esac +done + +if test -n "$ac_prev"; then + { echo "configure: error: missing argument to --`echo $ac_prev | sed 's/_/-/g'`" 1>&2; exit 1; } +fi + +trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15 + +# File descriptor usage: +# 0 standard input +# 1 file creation +# 2 errors and warnings +# 3 some systems may open it to /dev/tty +# 4 used on the Kubota Titan +# 6 checking for... messages and results +# 5 compiler messages saved in config.log +if test "$silent" = yes; then + exec 6>/dev/null +else + exec 6>&1 +fi +exec 5>./config.log + +echo "\ +This file contains any messages produced by compilers while +running configure, to aid debugging if configure makes a mistake. +" 1>&5 + +# Strip out --no-create and --no-recursion so they do not pile up. +# Also quote any args containing shell metacharacters. +ac_configure_args= +for ac_arg +do + case "$ac_arg" in + -no-create | --no-create | --no-creat | --no-crea | --no-cre \ + | --no-cr | --no-c) ;; + -no-recursion | --no-recursion | --no-recursio | --no-recursi \ + | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) ;; + *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*) + ac_configure_args="$ac_configure_args '$ac_arg'" ;; + *) ac_configure_args="$ac_configure_args $ac_arg" ;; + esac +done + +# NLS nuisances. +# Only set these to C if already set. These must not be set unconditionally +# because not all systems understand e.g. LANG=C (notably SCO). +# Fixing LC_MESSAGES prevents Solaris sh from translating var values in `set'! +# Non-C LC_CTYPE values break the ctype check. +if test "${LANG+set}" = set; then LANG=C; export LANG; fi +if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi +if test "${LC_MESSAGES+set}" = set; then LC_MESSAGES=C; export LC_MESSAGES; fi +if test "${LC_CTYPE+set}" = set; then LC_CTYPE=C; export LC_CTYPE; fi + +# confdefs.h avoids OS command line length limits that DEFS can exceed. +rm -rf conftest* confdefs.h +# AIX cpp loses on an empty file, so make sure it contains at least a newline. +echo > confdefs.h + +# A filename unique to this package, relative to the directory that +# configure is in, which we can look for to find out if srcdir is correct. +ac_unique_file=Makefile.conf.in + +# Find the source files, if location was not specified. +if test -z "$srcdir"; then + ac_srcdir_defaulted=yes + # Try the directory containing this script, then its parent. + ac_prog=$0 + ac_confdir=`echo $ac_prog|sed 's%/[^/][^/]*$%%'` + test "x$ac_confdir" = "x$ac_prog" && ac_confdir=. + srcdir=$ac_confdir + if test ! -r $srcdir/$ac_unique_file; then + srcdir=.. + fi +else + ac_srcdir_defaulted=no +fi +if test ! -r $srcdir/$ac_unique_file; then + if test "$ac_srcdir_defaulted" = yes; then + { echo "configure: error: can not find sources in $ac_confdir or .." 1>&2; exit 1; } + else + { echo "configure: error: can not find sources in $srcdir" 1>&2; exit 1; } + fi +fi +srcdir=`echo "${srcdir}" | sed 's%\([^/]\)/*$%\1%'` + +# Prefer explicitly selected file to automatically selected ones. +if test -z "$CONFIG_SITE"; then + if test "x$prefix" != xNONE; then + CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site" + else + CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site" + fi +fi +for ac_site_file in $CONFIG_SITE; do + if test -r "$ac_site_file"; then + echo "loading site script $ac_site_file" + . "$ac_site_file" + fi +done + +if test -r "$cache_file"; then + echo "loading cache $cache_file" + . $cache_file +else + echo "creating cache $cache_file" + > $cache_file +fi + +ac_ext=c +# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. +ac_cpp='$CPP $CPPFLAGS' +ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' +ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' +cross_compiling=$ac_cv_prog_cc_cross + +if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then + # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu. + if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then + ac_n= ac_c=' +' ac_t=' ' + else + ac_n=-n ac_c= ac_t= + fi +else + ac_n= ac_c='\c' ac_t= +fi + + + + +# Extract the first word of "gcc", so it can be a program name with args. +set dummy gcc; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:528: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" + for ac_dir in $PATH; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_CC="gcc" + break + fi + done + IFS="$ac_save_ifs" +fi +fi +CC="$ac_cv_prog_CC" +if test -n "$CC"; then + echo "$ac_t""$CC" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + +if test -z "$CC"; then + # Extract the first word of "cc", so it can be a program name with args. +set dummy cc; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:557: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" + ac_prog_rejected=no + for ac_dir in $PATH; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then + ac_prog_rejected=yes + continue + fi + ac_cv_prog_CC="cc" + break + fi + done + IFS="$ac_save_ifs" +if test $ac_prog_rejected = yes; then + # We found a bogon in the path, so make sure we never use it. + set dummy $ac_cv_prog_CC + shift + if test $# -gt 0; then + # We chose a different compiler from the bogus one. + # However, it has the same basename, so the bogon will be chosen + # first if we set CC to just the basename; use the full file name. + shift + set dummy "$ac_dir/$ac_word" "$@" + shift + ac_cv_prog_CC="$@" + fi +fi +fi +fi +CC="$ac_cv_prog_CC" +if test -n "$CC"; then + echo "$ac_t""$CC" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + + test -z "$CC" && { echo "configure: error: no acceptable cc found in \$PATH" 1>&2; exit 1; } +fi + +echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6 +echo "configure:605: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 + +ac_ext=c +# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. +ac_cpp='$CPP $CPPFLAGS' +ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' +ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' +cross_compiling=$ac_cv_prog_cc_cross + +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then + ac_cv_prog_cc_works=yes + # If we can't run a trivial program, we are probably using a cross compiler. + if (./conftest; exit) 2>/dev/null; then + ac_cv_prog_cc_cross=no + else + ac_cv_prog_cc_cross=yes + fi +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + ac_cv_prog_cc_works=no +fi +rm -fr conftest* + +echo "$ac_t""$ac_cv_prog_cc_works" 1>&6 +if test $ac_cv_prog_cc_works = no; then + { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; } +fi +echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6 +echo "configure:639: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 +echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6 +cross_compiling=$ac_cv_prog_cc_cross + +echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6 +echo "configure:644: checking whether we are using GNU C" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.c <&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then + ac_cv_prog_gcc=yes +else + ac_cv_prog_gcc=no +fi +fi + +echo "$ac_t""$ac_cv_prog_gcc" 1>&6 + +if test $ac_cv_prog_gcc = yes; then + GCC=yes + ac_test_CFLAGS="${CFLAGS+set}" + ac_save_CFLAGS="$CFLAGS" + CFLAGS= + echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6 +echo "configure:668: checking whether ${CC-cc} accepts -g" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + echo 'void f(){}' > conftest.c +if test -z "`${CC-cc} -g -c conftest.c 2>&1`"; then + ac_cv_prog_cc_g=yes +else + ac_cv_prog_cc_g=no +fi +rm -f conftest* + +fi + +echo "$ac_t""$ac_cv_prog_cc_g" 1>&6 + if test "$ac_test_CFLAGS" = set; then + CFLAGS="$ac_save_CFLAGS" + elif test $ac_cv_prog_cc_g = yes; then + CFLAGS="-g -O2" + else + CFLAGS="-O2" + fi +else + GCC= + test "${CFLAGS+set}" = set || CFLAGS="-g" +fi + +# Extract the first word of "ranlib", so it can be a program name with args. +set dummy ranlib; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:698: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$RANLIB"; then + ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" + for ac_dir in $PATH; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_RANLIB="ranlib" + break + fi + done + IFS="$ac_save_ifs" + test -z "$ac_cv_prog_RANLIB" && ac_cv_prog_RANLIB=":" +fi +fi +RANLIB="$ac_cv_prog_RANLIB" +if test -n "$RANLIB"; then + echo "$ac_t""$RANLIB" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + +ac_aux_dir= +for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do + if test -f $ac_dir/install-sh; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install-sh -c" + break + elif test -f $ac_dir/install.sh; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install.sh -c" + break + fi +done +if test -z "$ac_aux_dir"; then + { echo "configure: error: can not find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." 1>&2; exit 1; } +fi +ac_config_guess=$ac_aux_dir/config.guess +ac_config_sub=$ac_aux_dir/config.sub +ac_configure=$ac_aux_dir/configure # This should be Cygnus configure. + +# Find a good install program. We prefer a C program (faster), +# so one script is as good as another. But avoid the broken or +# incompatible versions: +# SysV /etc/install, /usr/sbin/install +# SunOS /usr/etc/install +# IRIX /sbin/install +# AIX /bin/install +# AFS /usr/afsws/bin/install, which mishandles nonexistent args +# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" +# ./install, which can be erroneously created by make from ./install.sh. +echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6 +echo "configure:754: checking for a BSD compatible install" >&5 +if test -z "$INSTALL"; then +if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS="${IFS}:" + for ac_dir in $PATH; do + # Account for people who put trailing slashes in PATH elements. + case "$ac_dir/" in + /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;; + *) + # OSF1 and SCO ODT 3.0 have their own names for install. + for ac_prog in ginstall installbsd scoinst install; do + if test -f $ac_dir/$ac_prog; then + if test $ac_prog = install && + grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then + # AIX install. It has an incompatible calling convention. + # OSF/1 installbsd also uses dspmsg, but is usable. + : + else + ac_cv_path_install="$ac_dir/$ac_prog -c" + break 2 + fi + fi + done + ;; + esac + done + IFS="$ac_save_IFS" + +fi + if test "${ac_cv_path_install+set}" = set; then + INSTALL="$ac_cv_path_install" + else + # As a last resort, use the slow shell script. We don't cache a + # path for INSTALL within a source directory, because that will + # break other packages using the cache if that directory is + # removed, or if the path is relative. + INSTALL="$ac_install_sh" + fi +fi +echo "$ac_t""$INSTALL" 1>&6 + +# Use test -z because SunOS4 sh mishandles braces in ${var-val}. +# It thinks the first close brace ends the variable substitution. +test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' + +test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' + + +echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6 +echo "configure:805: checking how to run the C preprocessor" >&5 +# On Suns, sometimes $CPP names a directory. +if test -n "$CPP" && test -d "$CPP"; then + CPP= +fi +if test -z "$CPP"; then +if eval "test \"`echo '$''{'ac_cv_prog_CPP'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + # This must be in double quotes, not single quotes, because CPP may get + # substituted into the Makefile and "${CC-cc}" will confuse make. + CPP="${CC-cc} -E" + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. + cat > conftest.$ac_ext < +Syntax Error +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:826: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out` +if test -z "$ac_err"; then + : +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + CPP="${CC-cc} -E -traditional-cpp" + cat > conftest.$ac_ext < +Syntax Error +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:843: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out` +if test -z "$ac_err"; then + : +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + CPP=/lib/cpp +fi +rm -f conftest* +fi +rm -f conftest* + ac_cv_prog_CPP="$CPP" +fi + CPP="$ac_cv_prog_CPP" +else + ac_cv_prog_CPP="$CPP" +fi +echo "$ac_t""$CPP" 1>&6 + +echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6 +echo "configure:866: checking for ANSI C header files" >&5 +if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +#include +#include +#include +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:879: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out` +if test -z "$ac_err"; then + rm -rf conftest* + ac_cv_header_stdc=yes +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + ac_cv_header_stdc=no +fi +rm -f conftest* + +if test $ac_cv_header_stdc = yes; then + # SunOS 4.x string.h does not declare mem*, contrary to ANSI. +cat > conftest.$ac_ext < +EOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + egrep "memchr" >/dev/null 2>&1; then + : +else + rm -rf conftest* + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. +cat > conftest.$ac_ext < +EOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + egrep "free" >/dev/null 2>&1; then + : +else + rm -rf conftest* + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. +if test "$cross_compiling" = yes; then + : +else + cat > conftest.$ac_ext < +#define ISLOWER(c) ('a' <= (c) && (c) <= 'z') +#define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) +#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) +int main () { int i; for (i = 0; i < 256; i++) +if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2); +exit (0); } + +EOF +if { (eval echo configure:946: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +then + : +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -fr conftest* + ac_cv_header_stdc=no +fi +rm -fr conftest* +fi + +fi +fi + +echo "$ac_t""$ac_cv_header_stdc" 1>&6 +if test $ac_cv_header_stdc = yes; then + cat >> confdefs.h <<\EOF +#define STDC_HEADERS 1 +EOF + +fi + + +for ac_hdr in linux/sound.h sys/soundlib.h +do +ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` +echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 +echo "configure:974: checking for $ac_hdr" >&5 +if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:984: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out` +if test -z "$ac_err"; then + rm -rf conftest* + eval "ac_cv_header_$ac_safe=yes" +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_header_$ac_safe=no" +fi +rm -f conftest* +fi +if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` + cat >> confdefs.h <&6 +fi +done + + +echo $ac_n "checking for working const""... $ac_c" 1>&6 +echo "configure:1012: checking for working const" >&5 +if eval "test \"`echo '$''{'ac_cv_c_const'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <j = 5; +} +{ /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */ + const int foo = 10; +} + +; return 0; } +EOF +if { (eval echo configure:1066: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + ac_cv_c_const=yes +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + ac_cv_c_const=no +fi +rm -f conftest* +fi + +echo "$ac_t""$ac_cv_c_const" 1>&6 +if test $ac_cv_c_const = no; then + cat >> confdefs.h <<\EOF +#define const +EOF + +fi + +echo $ac_n "checking for inline""... $ac_c" 1>&6 +echo "configure:1087: checking for inline" >&5 +if eval "test \"`echo '$''{'ac_cv_c_inline'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_cv_c_inline=no +for ac_kw in inline __inline__ __inline; do + cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + ac_cv_c_inline=$ac_kw; break +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 +fi +rm -f conftest* +done + +fi + +echo "$ac_t""$ac_cv_c_inline" 1>&6 +case "$ac_cv_c_inline" in + inline | yes) ;; + no) cat >> confdefs.h <<\EOF +#define inline +EOF + ;; + *) cat >> confdefs.h <&6 +echo "configure:1127: checking whether time.h and sys/time.h may both be included" >&5 +if eval "test \"`echo '$''{'ac_cv_header_time'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +#include +#include +int main() { +struct tm *tp; +; return 0; } +EOF +if { (eval echo configure:1141: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + ac_cv_header_time=yes +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + ac_cv_header_time=no +fi +rm -f conftest* +fi + +echo "$ac_t""$ac_cv_header_time" 1>&6 +if test $ac_cv_header_time = yes; then + cat >> confdefs.h <<\EOF +#define TIME_WITH_SYS_TIME 1 +EOF + +fi + + +if test $ac_cv_prog_gcc = yes; then + echo $ac_n "checking whether ${CC-cc} needs -traditional""... $ac_c" 1>&6 +echo "configure:1164: checking whether ${CC-cc} needs -traditional" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_gcc_traditional'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_pattern="Autoconf.*'x'" + cat > conftest.$ac_ext < +Autoconf TIOCGETP +EOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + egrep "$ac_pattern" >/dev/null 2>&1; then + rm -rf conftest* + ac_cv_prog_gcc_traditional=yes +else + rm -rf conftest* + ac_cv_prog_gcc_traditional=no +fi +rm -f conftest* + + + if test $ac_cv_prog_gcc_traditional = no; then + cat > conftest.$ac_ext < +Autoconf TCGETA +EOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + egrep "$ac_pattern" >/dev/null 2>&1; then + rm -rf conftest* + ac_cv_prog_gcc_traditional=yes +fi +rm -f conftest* + + fi +fi + +echo "$ac_t""$ac_cv_prog_gcc_traditional" 1>&6 + if test $ac_cv_prog_gcc_traditional = yes; then + CC="$CC -traditional" + fi +fi + + +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" +echo $ac_n "checking for alsa-lib package""... $ac_c" 1>&6 +echo "configure:1219: checking for alsa-lib package" >&5 +if test "$cross_compiling" = yes; then + echo "$ac_t"""not supported"" 1>&6; echo "Fatal error: Cross-compiling isn't supported..."; exit 1; + +else + cat > conftest.$ac_ext < +void main(void) +{ + snd_cards(); + exit(0); +} + +EOF +if { (eval echo configure:1236: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +then + echo "$ac_t"""present"" 1>&6 +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -fr conftest* + echo "$ac_t"""not found"" 1>&6; echo "Fatal error: Install alsa-lib package at first..."; exit 1; +fi +rm -fr conftest* +fi + + +echo $ac_n "checking for alsa-utils version""... $ac_c" 1>&6 +echo "configure:1250: checking for alsa-utils version" >&5 +SND_UTIL_VERSION=`cat $srcdir/version` +cat >> confdefs.h <&6 + +trap '' 1 2 15 +cat > confcache <<\EOF +# 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. +# +EOF +# The following way of writing the cache mishandles newlines in values, +# but we know of no workaround that is simple, portable, and efficient. +# So, don't put newlines in cache variables' values. +# Ultrix sh set writes to stderr and can't be redirected directly, +# and sets the high bit in the cache file unless we assign to the vars. +(set) 2>&1 | + case `(ac_space=' '; set) 2>&1` in + *ac_space=\ *) + # `set' does not quote correctly, so add quotes (double-quote substitution + # turns \\\\ into \\, and sed turns \\ into \). + sed -n \ + -e "s/'/'\\\\''/g" \ + -e "s/^\\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\\)=\\(.*\\)/\\1=\${\\1='\\2'}/p" + ;; + *) + # `set' quotes correctly as required by POSIX, so do not add quotes. + sed -n -e 's/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/\1=${\1=\2}/p' + ;; + esac >> confcache +if cmp -s $cache_file confcache; then + : +else + if test -w $cache_file; then + echo "updating cache $cache_file" + cat confcache > $cache_file + else + echo "not updating unwritable cache $cache_file" + fi +fi +rm -f confcache + +trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15 + +test "x$prefix" = xNONE && prefix=$ac_default_prefix +# Let make expand exec_prefix. +test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' + +# Any assignment to VPATH causes Sun make to only execute +# the first set of double-colon rules, so remove it if not needed. +# If there is a colon in the path, we need to keep it. +if test "x$srcdir" = x.; then + ac_vpsub='/^[ ]*VPATH[ ]*=[^:]*$/d' +fi + +trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15 + +DEFS=-DHAVE_CONFIG_H + +# Without the "./", some shells look in PATH for config.status. +: ${CONFIG_STATUS=./config.status} + +echo creating $CONFIG_STATUS +rm -f $CONFIG_STATUS +cat > $CONFIG_STATUS </dev/null | sed 1q`: +# +# $0 $ac_configure_args +# +# 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} $0 $ac_configure_args --no-create --no-recursion" + exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --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=$srcdir +ac_given_INSTALL="$INSTALL" + +trap 'rm -fr `echo "Makefile.conf utils/alsa-utils.spec include/config.h" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15 +EOF +cat >> $CONFIG_STATUS < conftest.subs <<\\CEOF +$ac_vpsub +$extrasub +s%@CFLAGS@%$CFLAGS%g +s%@CPPFLAGS@%$CPPFLAGS%g +s%@CXXFLAGS@%$CXXFLAGS%g +s%@DEFS@%$DEFS%g +s%@LDFLAGS@%$LDFLAGS%g +s%@LIBS@%$LIBS%g +s%@exec_prefix@%$exec_prefix%g +s%@prefix@%$prefix%g +s%@program_transform_name@%$program_transform_name%g +s%@bindir@%$bindir%g +s%@sbindir@%$sbindir%g +s%@libexecdir@%$libexecdir%g +s%@datadir@%$datadir%g +s%@sysconfdir@%$sysconfdir%g +s%@sharedstatedir@%$sharedstatedir%g +s%@localstatedir@%$localstatedir%g +s%@libdir@%$libdir%g +s%@includedir@%$includedir%g +s%@oldincludedir@%$oldincludedir%g +s%@infodir@%$infodir%g +s%@mandir@%$mandir%g +s%@CC@%$CC%g +s%@RANLIB@%$RANLIB%g +s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g +s%@INSTALL_DATA@%$INSTALL_DATA%g +s%@CPP@%$CPP%g +s%@SND_UTIL_VERSION@%$SND_UTIL_VERSION%g +s%@SND_UTIL_MAJOR@%$SND_UTIL_MAJOR%g +s%@SND_UTIL_MINOR@%$SND_UTIL_MINOR%g +s%@SND_UTIL_SUBMINOR@%$SND_UTIL_SUBMINOR%g + +CEOF +EOF + +cat >> $CONFIG_STATUS <<\EOF + +# 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 +EOF + +cat >> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF +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 +EOF +cat >> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF +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 + +EOF + +# Transform confdefs.h into a sed script conftest.vals that substitutes +# the proper values into config.h.in to produce config.h. And first: +# Protect against being on the right side of a sed subst in config.status. +# Protect against being in an unquoted here document in config.status. +rm -f conftest.vals +cat > conftest.hdr <<\EOF +s/[\\&%]/\\&/g +s%[\\$`]%\\&%g +s%#define \([A-Za-z_][A-Za-z0-9_]*\) *\(.*\)%${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD}%gp +s%ac_d%ac_u%gp +s%ac_u%ac_e%gp +EOF +sed -n -f conftest.hdr confdefs.h > conftest.vals +rm -f conftest.hdr + +# This sed command replaces #undef with comments. This is necessary, for +# example, in the case of _POSIX_SOURCE, which is predefined and required +# on some systems where configure will not decide to define it. +cat >> conftest.vals <<\EOF +s%^[ ]*#[ ]*undef[ ][ ]*[a-zA-Z_][a-zA-Z_0-9]*%/* & */% +EOF + +# Break up conftest.vals because some shells have a limit on +# the size of here documents, and old seds have small limits too. + +rm -f conftest.tail +while : +do + ac_lines=`grep -c . conftest.vals` + # grep -c gives empty output for an empty file on some AIX systems. + if test -z "$ac_lines" || test "$ac_lines" -eq 0; then break; fi + # Write a limited-size here document to conftest.frag. + echo ' cat > conftest.frag <> $CONFIG_STATUS + sed ${ac_max_here_lines}q conftest.vals >> $CONFIG_STATUS + echo 'CEOF + sed -f conftest.frag conftest.in > conftest.out + rm -f conftest.in + mv conftest.out conftest.in +' >> $CONFIG_STATUS + sed 1,${ac_max_here_lines}d conftest.vals > conftest.tail + rm -f conftest.vals + mv conftest.tail conftest.vals +done +rm -f conftest.vals + +cat >> $CONFIG_STATUS <<\EOF + 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 + +EOF +cat >> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF + +exit 0 +EOF +chmod +x $CONFIG_STATUS +rm -fr confdefs* $ac_clean_files +test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1 + diff --git a/configure.in b/configure.in new file mode 100644 index 0000000..eed6393 --- /dev/null +++ b/configure.in @@ -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 +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) diff --git a/include/Makefile b/include/Makefile new file mode 100644 index 0000000..e1e5789 --- /dev/null +++ b/include/Makefile @@ -0,0 +1,10 @@ +# +# Makefile for ALSA utils package +# Copyright (c) 1994-98 by Jaroslav Kysela +# + +include ../Makefile.conf + +clean: + rm -f core .depend *.o *.orig *~ + diff --git a/include/config.h b/include/config.h new file mode 100644 index 0000000..5c7c548 --- /dev/null +++ b/include/config.h @@ -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" diff --git a/include/config.h.in b/include/config.h.in new file mode 100644 index 0000000..5e078f9 --- /dev/null +++ b/include/config.h.in @@ -0,0 +1,5 @@ +/* + * Configuration header file for compilation of the ALSA utilities + */ + +#undef SND_UTIL_VERSION diff --git a/install-sh b/install-sh new file mode 100644 index 0000000..ebc6691 --- /dev/null +++ b/install-sh @@ -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 diff --git a/utils/Makefile b/utils/Makefile new file mode 100644 index 0000000..e1e5789 --- /dev/null +++ b/utils/Makefile @@ -0,0 +1,10 @@ +# +# Makefile for ALSA utils package +# Copyright (c) 1994-98 by Jaroslav Kysela +# + +include ../Makefile.conf + +clean: + rm -f core .depend *.o *.orig *~ + diff --git a/utils/alsa-utils.spec b/utils/alsa-utils.spec new file mode 100644 index 0000000..cd306d0 --- /dev/null +++ b/utils/alsa-utils.spec @@ -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 +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 + +- 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/* diff --git a/utils/alsa-utils.spec.in b/utils/alsa-utils.spec.in new file mode 100644 index 0000000..f753e27 --- /dev/null +++ b/utils/alsa-utils.spec.in @@ -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 +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 + +- 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/* diff --git a/utils/buildrpm b/utils/buildrpm new file mode 100644 index 0000000..95606e1 --- /dev/null +++ b/utils/buildrpm @@ -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 diff --git a/version b/version new file mode 100644 index 0000000..bbdeab6 --- /dev/null +++ b/version @@ -0,0 +1 @@ +0.0.5