pax_global_header00006660000000000000000000000064151221603310014504gustar00rootroot0000000000000052 comment=5a5364ea881f48885343ab60a20ea3984b6984c1 adplug-adplay-unix-5a5364e/000077500000000000000000000000001512216033100155475ustar00rootroot00000000000000adplug-adplay-unix-5a5364e/.gitignore000066400000000000000000000005151512216033100175400ustar00rootroot00000000000000aclocal.m4 config.cache config.guess config.log config.status config.sub configure depcomp install-sh Makefile Makefile.in missing mkinstalldirs INSTALL autom4te.cache libtool ltmain.sh *.o stamp-h1 .deps compile m4/libtool.m4 m4/ltoptions.m4 m4/ltsugar.m4 m4/ltversion.m4 m4/lt~obsolete.m4 src/adplay src/config.h* src/.libs/ *.exe adplug-adplay-unix-5a5364e/AUTHORS000066400000000000000000000006611512216033100166220ustar00rootroot00000000000000Main Development: ----------------- Simon Peter Additional Credits: ------------------- Goetz Waschk : - Mandrake Linux packages - Red Hat RPM spec file Mike Gorchak : - QNX Sound Architecture (QSA) output driver - Simple Directmedia Layer (SDL) output driver - QNX packages - QNX qpg file Michael Guntsche : - libao output driver adplug-adplay-unix-5a5364e/COPYING000066400000000000000000000431101512216033100166010ustar00rootroot00000000000000 GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 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 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) 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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) year 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. adplug-adplay-unix-5a5364e/ChangeLog000066400000000000000000000000711512216033100173170ustar00rootroot00000000000000See https://github.com/adplug/adplay-unix/commits/master adplug-adplay-unix-5a5364e/Makefile.am000066400000000000000000000001551512216033100176040ustar00rootroot00000000000000SUBDIRS = src doc EXTRA_DIST = adplay.spec adplay.qpg AUTOMAKE_OPTIONS = dist-bzip2 ACLOCAL_AMFLAGS=-I m4 adplug-adplay-unix-5a5364e/NEWS000066400000000000000000000033541512216033100162530ustar00rootroot00000000000000This is a brief overview of user-visible changes in adplay. Changes for version 1.9: ------------------------ - Tie in with AdPlug 2.4 - SDL2 compilation support - Fix a subsong playback corner case - RAW file writer Changes for version 1.8.1: -------------------------- - Tie in with AdPlug 2.3.2 - Add surround effect support for NukedOPL Changes for version 1.8: ------------------------ - Tie in with AdPlug 2.3 release - Support for NukedOPL emulator - Various bug fixes Changes for version 1.7: ------------------------ - Changed default subsong to default subsong of file. - ALSA playback works better with recent ALSA releases - Surround/harmonic synth is now default (use --mono for old behaviour) Changes for version 1.6: ------------------------ - Added the following output mechanisms: - libao: libao driver Changes for version 1.5: ------------------------ - Made compatible with AdPlug 2.0. Changes for version 1.4: ------------------------ - Added the following output mechanisms: - alsa: Advanced Linux Sound Architecture (ALSA) driver Changes for version 1.3: ------------------------ - Disk writer now writes proper files on big endian machines. - AdPlug Database support. - Added verbosity level options. - Added the following output mechanisms: - esound: EsounD (ESD) driver - qsa: QNX Sound Architecture (QSA) driver - sdl: Simple Directmedia Layer (SDL) driver Changes for version 1.2: ------------------------ - Updated man page. - Many build fixes. - Modularized output system. - Added the following output mechanisms: - oss: Open Sound System (OSS) driver - null: Null (silent) output - disk: Disk writer Changes for version 1.1: ------------------------ - Rewrote using GNU autotools. - Wrote man page. - FreeBSD fixes. adplug-adplay-unix-5a5364e/README000066400000000000000000000025211512216033100164270ustar00rootroot00000000000000AdPlay/UNIX - UNIX console-based OPL2 audio player Copyright (C) 2001 - 2025 Simon Peter Description ----------- AdPlay/UNIX is AdPlug's UNIX console-based frontend. AdPlug is a free, universal OPL2 audio playback library. AdPlay/UNIX supports the full range of AdPlug's file format playback features. Despite this, at the moment, only emulated OPL2 output is supported by AdPlay/UNIX, but this on a wide range of output devices. Prerequisites ------------- The following libraries are needed in order to compile this program: Library Version ------- ------- AdPlug >= 1.4, or >= 2.2 for full feature support git --- If you checked out from git, first run: autoreconf --install to generate the build cruft and get the configure script. You need recent versions of autoconf, automake and libtool to do this. If autoreconf fails for any reason or you are hacking on the build system, you can run each step manually instead of using autoreconf: libtoolize -c -f --install aclocal -I m4 autoheader automake -a -c autoconf Usage ----- Start AdPlay/UNIX with at least one file to be played as parameter. Additional commandline parameters are explained by typing: adplay --help Or by reading the man page. A more detailed doc will follow when i get the time to write one. Any help is greatly appreciated! - Simon Peter adplug-adplay-unix-5a5364e/RELEASE000066400000000000000000000011271512216033100165530ustar00rootroot00000000000000Release procedure ----------------- Before release: * Ensure version numbers are correct in configure.ac, adplay.qpg, doc/adplay.1. They should already be set to the version number of the next release, but may need altering e.g. if an unplanned bugfix release is made. * Update file list in adplug.qpg * Update NEWS with changes since last release * Create new tag: `git tag v1.2.3` and `git push origin v1.2.3` After release: * Update version numbers as above to match the "next" release. This means the git code will always compile as the version number of the next release. adplug-adplay-unix-5a5364e/TODO000066400000000000000000000002261512216033100162370ustar00rootroot00000000000000AdPlay/UNIX To Do List: ----------------------- - Remove warning about Ken's synth not working in surround mode once it has been fixed in AdPlug. adplug-adplay-unix-5a5364e/adplay.qpg000066400000000000000000000116061512216033100175360ustar00rootroot00000000000000 QNX.ORG.RU Community QNX.ORG.RU Team Mike Gorchak mike@malva.ua Application adplay 1 http://qnx.org.ru/repository 1.01 adplay adplay dn.tlp@gmx.net Public public http://adplug.github.io dn.tlp@gmx.net Simon Peter http://adplug.github.io dn.tlp@gmx.net AdPlay/UNIX is AdPlug's UNIX console-based frontend. AdPlug is a free, universal OPL2 audio playback library. AdPlay/UNIX supports the full range of AdPlug's file format playback features. AdPlay/UNIX is AdPlug's UNIX console-based frontend. AdPlug is a free, universal OPL2 audio playback library. AdPlay/UNIX supports the full range of AdPlug's file format playback features. Despite this, at the moment, only emulated OPL2 output is supported by AdPlay/UNIX, but this on a wide range of output devices. http://adplug.github.io 1.9 Medium Stable 1 GNU General Public License Multimedia/Music and Audio/Audio Media Players FM, Tracker, Music, Adlib, OPL2, Player Console User repdata://LicenseUrl/COPYING adplug-adplay-unix-5a5364e/adplay.spec000066400000000000000000000022371512216033100177010ustar00rootroot00000000000000%define name adplay %define version 1.7 %define release 1 Summary: AdLib music player for the command line Name: %{name} Version: %{version} Release: %{release} Source0: %{name}-%{version}.tar.bz2 License: GPL Group: Applications/Multimedia URL: http://adplug.github.io BuildRoot: %{_tmppath}/%{name}-buildroot Prefix: %{_prefix} BuildRequires: adplug-devel >= 1.4 Requires: adplug >= 1.4 %description AdPlay/UNIX is AdPlug's UNIX console-based frontend. AdPlug is a free, universal OPL2 audio playback library. AdPlay/UNIX supports the full range of AdPlug's file format playback features. Despite this, at the moment, only emulated OPL2 output is supported by AdPlay/UNIX, but this on a wide range of output devices. %prep %setup -q %build %configure make %install rm -rf $RPM_BUILD_ROOT %makeinstall %clean rm -rf $RPM_BUILD_ROOT %files %defattr(-,root,root) %doc README NEWS TODO AUTHORS ChangeLog %_bindir/adplay %_mandir/man1/adplay.1* %changelog * Tue Mar 4 2003 Götz Waschk 1.3-1 - requires new adplug libraries - fix group for RH standard - new version * Tue Nov 26 2002 Götz Waschk 1.2-1 - initial package adplug-adplay-unix-5a5364e/adplug.desktop000066400000000000000000000005601512216033100204170ustar00rootroot00000000000000[Desktop Entry] Name=adplug Comment=adlib sound player Exec=adplug %f Icon=adplug Terminal=true Type=Application Categories=AudioVideo;AudioVideoEditing Keywords=music;playing; MimeTypes=audio/a2m;audio/adl;audio/amd;audio/cff;audio/cmf;audio/d00;audio/dtm;audio/hsc;audio/hsp;audio/laa;audio/lds;audio/rad;audio/raw;audio/sa2;audio/sng;audio/xad;audio/xms;audio/xsm; adplug-adplay-unix-5a5364e/configure.ac000066400000000000000000000210711512216033100200360ustar00rootroot00000000000000# Tell autoconf we're compiling a C++ program using automake and libtool. AC_INIT([adplay],[1.9]) AC_CONFIG_SRCDIR(src/adplay.cc) AC_CONFIG_FILES(Makefile src/Makefile doc/Makefile) AC_CANONICAL_TARGET AM_INIT_AUTOMAKE AC_CONFIG_MACRO_DIRS([m4]) AC_CONFIG_HEADERS([src/config.h]) LT_INIT AC_LANG(C++) # Check if we got a sane C/C++ compilation environment. AC_PROG_INSTALL AC_PROG_CC AC_PROG_CXX AC_PROG_CPP AC_PROG_CXXCPP # Nothing works without these libraries... AC_CHECK_LIB(stdc++,main,,AC_MSG_ERROR([libstdc++ not installed])) PKG_CHECK_MODULES([adplug], [adplug >= 2.0],,[ AC_MSG_WARN([You seem to be using a version of AdPlug prior to 2.0. \ I will try to do the old-style library search for which i cannot check \ versions. Please bear in mind that i am requiring at least version 1.4.]) AC_CHECK_LIB(adplug,main,,AC_MSG_ERROR([*** AdPlug not installed ***]))]) # Check if getopt header is installed on this system AC_CHECK_HEADERS([getopt.h], , AC_SUBST(GETOPT_SOURCES, [getopt.c getopt1.c getopt.h])) # Save compiler flags and set up for compiling test programs oldlibs="$LIBS" oldcppflags="$CPPFLAGS" LIBS="$LDFLAGS $adplug_LIBS" CPPFLAGS="$CPPFLAGS $adplug_CFLAGS" # Check if AdPlug is installed and linked correctly AC_MSG_CHECKING([whether AdPlug is linked correctly]) AC_LINK_IFELSE([AC_LANG_PROGRAM([#include class Testplayer: public CPlayer { public: Testplayer(): CPlayer(NULL) {} bool load(const std::string &f, const CFileProvider &fp) { return false; } bool update() { return false; } float getrefresh() { return 0; } std::string gettype() { return std::string(); } void rewind(int s) {} }; Testplayer p;], [p.getrefresh();])], AC_MSG_RESULT([yes]), AC_MSG_RESULT([no]); AC_MSG_ERROR([Unable to compile a program using AdPlug. Please check to ensure AdPlug is installed correctly.]) ) # Check if AdPlug supports the new getsubsong() method AC_MSG_CHECKING([whether AdPlug supports the getsubsong() method]) AC_LINK_IFELSE([AC_LANG_PROGRAM([#include class Testplayer: public CPlayer { public: Testplayer(): CPlayer(NULL) {} bool load(const std::string &f, const CFileProvider &fp) { return false; } bool update() { return false; } float getrefresh() { return 0; } std::string gettype() { return std::string(); } void rewind(int s) {} }; Testplayer p;], [p.getsubsong();])], AC_DEFINE(HAVE_ADPLUG_GETSUBSONG,, [Defined if AdPlug supports the getsubsong() method]) AC_MSG_RESULT([yes]), AC_MSG_RESULT([no])) # Check if AdPlug supports the new surround/harmonic synth AC_MSG_CHECKING([whether AdPlug supports the surround/harmonic synth]) AC_LINK_IFELSE([AC_LANG_PROGRAM([#include ], [CSurroundopl *dummy;])], AC_DEFINE(HAVE_ADPLUG_SURROUND,, [Defined if AdPlug supports the surround/harmonic synth]) AC_MSG_RESULT([yes]), AC_MSG_RESULT([no - AdPlug >= 2.2 required])) # Check if AdPlug supports NukedOPL AC_MSG_CHECKING([whether AdPlug supports the NukedOPL synth]) AC_LINK_IFELSE([AC_LANG_PROGRAM([#include ], [CNemuopl *dummy;])], AC_DEFINE(HAVE_ADPLUG_NUKEDOPL,, [Defined if AdPlug supports the NukedOPL synth]) AC_MSG_RESULT([yes]), AC_MSG_RESULT([no - AdPlug >= 2.3 required])) # Restore flags after compiling test programs LIBS="$oldlibs" CPPFLAGS="$oldcppflags" ##### Output mechanism checks ##### # These checks enable or disable certain output mechanisms, # depending on system facilities and user requests. # Define user option arguments AC_ARG_ENABLE([output-oss],AS_HELP_STRING([--disable-output-oss],[Disable OSS output])) AC_ARG_ENABLE([output-null],AS_HELP_STRING([--disable-output-null],[Disable null output])) AC_ARG_ENABLE([output-raw],AS_HELP_STRING([--disable-output-raw],[Disable RAW file writer])) AC_ARG_ENABLE([output-disk],AS_HELP_STRING([--disable-output-disk],[Disable disk writer])) AC_ARG_ENABLE([output-esound],AS_HELP_STRING([--disable-output-esound],[Disable EsounD output])) AC_ARG_ENABLE([output-qsa],AS_HELP_STRING([--disable-output-qsa],[Disable QSA output])) AC_ARG_ENABLE([output-sdl],AS_HELP_STRING([--disable-output-sdl],[Disable SDL output])) AC_ARG_ENABLE([output-alsa],AS_HELP_STRING([--disable-output-alsa],[Disable ALSA output])) AC_ARG_ENABLE([output-ao],AS_HELP_STRING([--disable-output-ao],[Disable AO output])) # Check if we can compile the enabled drivers: # OSS driver if test ${enable_output_oss:=yes} = yes; then AC_MSG_CHECKING([for OSS headers]) AC_PREPROC_IFELSE([AC_LANG_SOURCE([[ #include #include #include ]])],[ AC_DEFINE(DRIVER_OSS,1,[Build OSS driver]) drivers=$drivers' oss.$(OBJEXT)' AC_MSG_RESULT([found]) ],[ enable_output_oss=no AC_MSG_RESULT([not found -- OSS output disabled]) ]) fi # AO output if test ${enable_output_ao:=yes} = yes; then XIPH_PATH_AO(AC_DEFINE(DRIVER_AO,1,[Build AO output]) drivers=$drivers' ao.${OBJEXT}', enable_output_ao=no AC_MSG_RESULT([*** AO (libao) not installed ***])) fi # Null output if test ${enable_output_null:=yes} = yes; then AC_DEFINE(DRIVER_NULL,1,[Build null output]) fi # Disk writer if test ${enable_output_disk:=yes} = yes; then AC_DEFINE(DRIVER_DISK,1,[Build disk writer]) drivers=$drivers' disk.$(OBJEXT)' fi # RAW file writer if test ${enable_output_raw:=yes} = yes; then AC_DEFINE(DRIVER_RAW,1,[Build disk writer]) fi # EsounD output if test ${enable_output_esound:=yes} = yes; then AM_PATH_ESD(0.2.8, AC_DEFINE(DRIVER_ESOUND,1,[Build EsounD output]) drivers=$drivers' esound.$(OBJEXT)', enable_output_esound=no AC_MSG_RESULT([*** EsounD (libesd) >= 0.2.8 not installed ***])) fi # QSA driver if test ${enable_output_qsa:=yes} = yes; then AC_MSG_CHECKING([for QSA headers]) AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include #include ]], [[ int arg=snd_pcm_open_preferred(NULL, NULL, NULL, 0); ]])],[ have_qsa=yes ],[]) if test x$have_qsa = xyes; then AC_DEFINE(DRIVER_QSA,1,[Build QSA driver]) drivers=$drivers' qsa.$(OBJEXT)' QSA_LIBS=-lasound AC_SUBST(QSA_LIBS) AC_MSG_RESULT([found]) else enable_output_qsa=no QSA_LIBS="" AC_SUBST(QSA_LIBS) AC_MSG_RESULT([not found -- QSA output disabled]) fi fi # SDL output if test ${enable_output_sdl:=yes} = yes; then AC_LANG_PUSH(C) AM_PATH_SDL2(["2.0.0"], AC_DEFINE(HAVE_SDL_H, 1, [Define to 1 if you have the "SDL.h" header file]) AC_DEFINE(DRIVER_SDL, 1, [Build SDL2 output]) drivers=$drivers' sdl.$(OBJEXT)', try_sdl12=yes AC_MSG_RESULT([*** SDL libsdl2 >= 2.0.0 not installed ***]) ) AC_LANG_POP(C) dnl we can not put AM_PATH_SDL directly into the ACTION-IF-NOT-FOUND of AM_PATH_SDL2 dnl due to some m4 macro recursion causing a bad ./configure script to be generated if test ${try_sdl12:=no} = yes; then AC_LANG_PUSH(C) AM_PATH_SDL(["1.2.0"], AC_DEFINE(HAVE_SDL_H, 1, [Define to 1 if you have the "SDL.h" header file]) AC_DEFINE(DRIVER_SDL, 1, [Build SDL1.x output]) drivers=$drivers' sdl.$(OBJEXT)', enable_output_sdl=no AC_MSG_RESULT([*** SDL libsdl >= 1.2.0 not installed ***]) ) AC_LANG_POP(C) fi dnl strip away options that would turn our application from console to a windows GUI application SDL_CFLAGS=`echo $SDL_CFLAGS |sed -e 's/-Dmain=SDL_main//g'` SDL_LIBS=`echo $SDL_LIBS | sed -e 's/-mwindows/-mconsole/g' -e 's/-lSDLmain//g' -e 's/-lSDL2main//g'` fi # ALSA output if test ${enable_output_alsa:=yes} = yes; then AM_PATH_ALSA(0.9.1, AC_DEFINE(DRIVER_ALSA,1,[Build ALSA output]) drivers=$drivers' alsa.${OBJEXT}', enable_output_alsa=no AC_MSG_RESULT([*** ALSA (libasound) >= 0.9.1 not installed ***])) fi AC_SUBST([drivers]) AC_OUTPUT # Display user informative configuration output echo "" echo "Configuration:" echo "Install path: ${prefix}" echo "" echo "Build output mechanisms:" echo "OSS output (oss): ${enable_output_oss}" echo "Null output (null): ${enable_output_null}" echo "RAW file writer (raw): ${enable_output_raw}" echo "Disk writer (disk): ${enable_output_disk}" echo "EsounD output (esound): ${enable_output_esound}" echo "QSA output (qsa): ${enable_output_qsa}" echo "SDL output (sdl): ${enable_output_sdl}" echo "ALSA output (alsa): ${enable_output_alsa}" echo "Libao output (ao): ${enable_output_ao}" adplug-adplay-unix-5a5364e/doc/000077500000000000000000000000001512216033100163145ustar00rootroot00000000000000adplug-adplay-unix-5a5364e/doc/Makefile.am000066400000000000000000000000561512216033100203510ustar00rootroot00000000000000man_MANS = adplay.1 EXTRA_DIST = $(man_MANS) adplug-adplay-unix-5a5364e/doc/adplay.1000066400000000000000000000146271512216033100176620ustar00rootroot00000000000000.\" -*- nroff -*- .\" adplay 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; see the file COPYING. If not, write to .\" the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. .\" .TH ADPLAY 1 "December 21, 2025" "AdPlay/UNIX 1.9" "User Commands" .SH NAME adplay \- AdPlay/UNIX console-based OPL2 audio player .SH SYNOPSIS .B adplay .RI "[OPTION]... FILE..." .SH DESCRIPTION AdPlay/UNIX is AdPlug's UNIX console-based frontend. It tries to play back all given FILEs, using one of many available output mechanisms. .PP AdPlay/UNIX plays endlessly, if only one file is given. With multiple files, it plays them in a sequence and exits after the last file. The same can also be accomplished with only one file, by using the \fB-o\fP option. When using the disk writer, \fB-o\fP is implied. .SH EXIT STATUS \fBadplay\fP returns 0 on successful operation. 1 is returned otherwise. .SH OUTPUT MECHANISMS .PP AdPlay/UNIX can play back using many different output mechanisms, which can be selected with the \fB-O\fP argument. The availability of a method depends on compile-time settings. Available methods are printed out after the help text, displayed with \fB--help\fP. .PP Next is a brief description of all output mechanisms, following their abbreviations: .SS oss -- Open Sound System (OSS) driver .PP This output method is available on most Linux and other UNIX systems. .SS null -- Total silence .PP Discards anything sent to it. It can be useful for testing purposes. .SS disk -- Disk writer .PP Writes its output to a file in Microsoft RIFF WAVE format. .SS esound -- EsounD output .PP Creates a socket connection to an EsounD server and streams the audio to it. .SS qsa -- QNX Sound Architecture (QSA) driver .PP Uses the QNX system's standard output method. .SS sdl -- Simple Directmedia Layer (SDL) driver .PP Uses the SDL library for sound output. The library has a broader platform support than any of the other output methods. Thus, it could be useful on some exotic systems. .SS alsa -- Advanced Linux Sound Architecture (ALSA) driver .PP Uses the standard output method on newer Linux systems. .SS ao -- libao driver .PP Libao is a cross-platform audio library with very broad platform support. Might be useful on systems, where SDL is not available, and generally to do tricky things. .SH OPTIONS .PP The order of the option commandline parameters is not important, except for the \fB-d\fP option, which always has to be specified after an \fB-O\fP option. .SS "Output selection:" .TP .B -O, --output=OUTPUT Specify output mechanism. Available mechanisms depend on compilation settings and are printed on \fB--help\fP output. A reasonable default is automatically selected, based on the availability of the output mechanisms. .SS "OSS driver (oss) specific:" .TP .B -d --device=FILE Set sound output device file to FILE. This is \fB/dev/dsp\fP by default. .SS "Disk writer (disk) specific:" .TP .B -d --device=FILE Write sound data to FILE. The data is written in Microsoft RIFF WAVE format (little-endian). You can specify a single '-' to write to stdout instead. This option has no default and must be specified when the disk writer is to be used! .SS "EsounD output (esound) specific:" .TP .B -d --device=URL Connect to "hostname:port" combination in URL. Example: "myhost.sound.net:1234". The default is "localhost:16001". .SS "ALSA driver (alsa) specific:" .TP .B -d --device=DEVICE Set sound output device to DEVICE. This is \fBplughw:0,0\fP by default. .SS "Playback quality:" .TP .B -8, --8bit Use only 8-bit samples for playback. .TP .B --16bit Use only 16-bit samples for playback (default). .TP .B -f, --freq=FREQ Set playback frequency to FREQ, in Hz. This is 44100Hz by default. .TP .B --stereo Use only stereo samples for playback. The sound stream is just doubled, no further audio processing is done. This option is pretty useless unless you have very obscure audio hardware that only accepts stereo streams. AdPlug only generates mono streams because the OPL2 only generates mono sound. .TP .B --mono Use only mono samples for playback (default if AdPlug <= 2.1.) .TP .B --surround Use only stereo samples for playback, but generate them from two mono OPL2 chips. One OPL2 chip is very slightly transposed to produce a pleasant harmonic/surround sound effect (default if AdPlug >= 2.2.) .TP .B -b --buffer=SIZE Set sound buffer size to SIZE samples. If you notice sound skipping with the default setting, try a greater buffer size. Note that this is measured in samples, not bytes! This is 2048 samples by default. Only the OSS, SDL, ALSA and libao output drivers support this option. .SS "Informative output:" .TP .B -i --instruments Display instrument names (if available). .TP .B -r --realtime Display realtime playback information, while playing. This will display a one-line status bar, containing essential playback information. .TP .B -m --message Display the song message (if available). .SS "Playback:" .TP .B -s --subsong=N Play subsong number N, instead of the default subsong of the file. Only useful for file formats that support multiple subsongs. .TP .B -o --once Don't loop endlessly. This will exit \fBadplay\fP after the song ended. This is the default when multiple \fBFILEs\fP are given. .TP .B -l --loop=N Loop N times then stop. Due to technical limitations of the adplug library, a "loop" is considered to be the time between the start of playback and when looping first occurs. Accordingly, playback may actually halt at an unexpected point, especially when combined with \fB-s\fR. This implies \fB-o\fR. .SS "Miscellaneous:" .TP .B -D, --database=FILE Additionally use database file FILE. This option may be specified multiple times. Each database file is additionally merged with the others, creating one large database on the fly. .TP .B -q, --quiet Be more quiet. .TP .B -v, --verbose Be more verbose. .TP .B -h, --help Show summary of options. .TP .B -V, --version Show version of program. .SH AUTHOR Simon Peter adplug-adplay-unix-5a5364e/m4/000077500000000000000000000000001512216033100160675ustar00rootroot00000000000000adplug-adplay-unix-5a5364e/m4/alsa.m4000066400000000000000000000137041512216033100172560ustar00rootroot00000000000000dnl Configure Paths for Alsa dnl Some modifications by Richard Boulton dnl Christopher Lansdown dnl Jaroslav Kysela dnl Last modification: $Id: alsa.m4,v 1.24 2004/09/15 18:48:07 tiwai Exp $ dnl dnl AM_PATH_ALSA([MINIMUM-VERSION [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]]) dnl Test for libasound, and define ALSA_CFLAGS, ALSA_LIBS and dnl ALSA_TOPOLOGY_LIBS as appropriate. dnl dnl enables arguments --with-alsa-prefix= dnl --with-alsa-inc-prefix= dnl --disable-alsatest dnl dnl For backwards compatibility, if ACTION_IF_NOT_FOUND is not specified, dnl and the alsa libraries are not found, a fatal AC_MSG_ERROR() will result. dnl AC_DEFUN([AM_PATH_ALSA], [dnl Save the original CFLAGS, LDFLAGS, and LIBS alsa_save_CFLAGS="$CFLAGS" alsa_save_LDFLAGS="$LDFLAGS" alsa_save_LIBS="$LIBS" alsa_found=yes alsa_topology_found=no dnl dnl Get the cflags and libraries for alsa dnl AC_ARG_WITH(alsa-prefix, AS_HELP_STRING([--with-alsa-prefix=PFX], [Prefix where Alsa library is installed(optional)]), [alsa_prefix="$withval"], [alsa_prefix=""]) AC_ARG_WITH(alsa-inc-prefix, AS_HELP_STRING([--with-alsa-inc-prefix=PFX], [Prefix where include libraries are (optional)]), [alsa_inc_prefix="$withval"], [alsa_inc_prefix=""]) AC_ARG_ENABLE(alsa-topology, AS_HELP_STRING([--enable-alsatopology], [Force to use the Alsa topology library]), [enable_atopology="$enableval"], [enable_atopology=no]) AC_ARG_ENABLE(alsatest, AS_HELP_STRING([--disable-alsatest], [Do not try to compile and run a test Alsa program]), [enable_alsatest="$enableval"], [enable_alsatest=yes]) dnl Add any special include directories AC_MSG_CHECKING(for ALSA CFLAGS) if test "$alsa_inc_prefix" != "" ; then ALSA_CFLAGS="$ALSA_CFLAGS -I$alsa_inc_prefix" CFLAGS="$CFLAGS -I$alsa_inc_prefix" fi AC_MSG_RESULT($ALSA_CFLAGS) AC_CHECK_LIB(c, dlopen, LIBDL="", [AC_CHECK_LIB(dl, dlopen, LIBDL="-ldl")]) dnl add any special lib dirs AC_MSG_CHECKING(for ALSA LDFLAGS) if test "$alsa_prefix" != "" ; then ALSA_LIBS="$ALSA_LIBS -L$alsa_prefix" LDFLAGS="$LDFLAGS $ALSA_LIBS" fi dnl add the alsa library ALSA_LIBS="$ALSA_LIBS -lasound -lm $LIBDL -lpthread" LIBS="$ALSA_LIBS $LIBS" AC_MSG_RESULT($ALSA_LIBS) dnl Check for a working version of libasound that is of the right version. if test "x$enable_alsatest" = "xyes"; then AC_MSG_CHECKING([required libasound headers version]) min_alsa_version=ifelse([$1], , 0.1.1, $1) no_alsa="" alsa_min_major_version=`echo $min_alsa_version | \ sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` alsa_min_minor_version=`echo $min_alsa_version | \ sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` alsa_min_micro_version=`echo $min_alsa_version | \ sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` AC_MSG_RESULT($alsa_min_major_version.$alsa_min_minor_version.$alsa_min_micro_version) AC_LANG_PUSH([C]) AC_MSG_CHECKING([for libasound headers version >= $alsa_min_major_version.$alsa_min_minor_version.$alsa_min_micro_version ($min_alsa_version)]) AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include #include ]], [[ /* ensure backward compatibility */ #if !defined(SND_LIB_MAJOR) && defined(SOUNDLIB_VERSION_MAJOR) #define SND_LIB_MAJOR SOUNDLIB_VERSION_MAJOR #endif #if !defined(SND_LIB_MINOR) && defined(SOUNDLIB_VERSION_MINOR) #define SND_LIB_MINOR SOUNDLIB_VERSION_MINOR #endif #if !defined(SND_LIB_SUBMINOR) && defined(SOUNDLIB_VERSION_SUBMINOR) #define SND_LIB_SUBMINOR SOUNDLIB_VERSION_SUBMINOR #endif # if(SND_LIB_MAJOR > $alsa_min_major_version) exit(0); # else # if(SND_LIB_MAJOR < $alsa_min_major_version) # error not present # endif # if(SND_LIB_MINOR > $alsa_min_minor_version) exit(0); # else # if(SND_LIB_MINOR < $alsa_min_minor_version) # error not present # endif # if(SND_LIB_SUBMINOR < $alsa_min_micro_version) # error not present # endif # endif # endif exit(0); ]])], [AC_MSG_RESULT(found.)], [AC_MSG_RESULT(not present.) ifelse([$3], , [AC_MSG_ERROR(Sufficiently new version of libasound not found.)]) alsa_found=no] ) AC_LANG_POP([C]) AC_LANG_PUSH([C]) AC_MSG_CHECKING([for libatopology (sound headers version > 1.1.9)]) AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include #include #include ]], [[ /* ensure backward compatibility */ #if !defined(SND_LIB_VERSION) #define SND_LIB_VERSION 0 #endif #if SND_LIB_VERSION > 0x00010109 exit(0); #else # error not present #endif exit(0); ]])], [AC_MSG_RESULT(yes) enable_atopology="yes"], [AC_MSG_RESULT(no)] ) AC_LANG_POP([C]) fi dnl Now that we know that we have the right version, let's see if we have the library and not just the headers. if test "x$enable_alsatest" = "xyes"; then AC_CHECK_LIB([asound], [snd_ctl_open],, [ifelse([$3], , [AC_MSG_ERROR(No linkable libasound was found.)]) alsa_found=no] ) if test "x$enable_atopology" = "xyes"; then alsa_topology_found=yes alsa_save_LIBS2="$LIBS" AC_CHECK_LIB([atopology], [snd_tplg_new],, [ifelse([$3], , [AC_MSG_ERROR(No linkable libatopology was found.)]) alsa_topology_found=no, ] ) LIBS="$alsa_save_LIBS2" fi else if test "x$enable_atopology" = "xyes"; then alsa_topology_found=yes fi fi if test "x$alsa_found" = "xyes" ; then ifelse([$2], , :, [$2]) LIBS=`echo $LIBS | sed 's/-lasound//g'` LIBS=`echo $LIBS | sed 's/ //'` LIBS="-lasound $LIBS" fi if test "x$alsa_found" = "xno" ; then ifelse([$3], , :, [$3]) CFLAGS="$alsa_save_CFLAGS" LDFLAGS="$alsa_save_LDFLAGS" LIBS="$alsa_save_LIBS" ALSA_CFLAGS="" ALSA_LIBS="" ALSA_TOPOLOGY_LIBS="" fi dnl add the alsa topology library; must be at the end AC_MSG_CHECKING(for ALSA topology LDFLAGS) if test "x$alsa_topology_found" = "xyes"; then ALSA_TOPOLOGY_LIBS="$ALSA_TOPOLOGY_LIBS -latopology" fi AC_MSG_RESULT($ALSA_TOPOLOGY_LIBS) dnl That should be it. Now just export out symbols: AC_SUBST(ALSA_CFLAGS) AC_SUBST(ALSA_LIBS) AC_SUBST(ALSA_TOPOLOGY_LIBS) ]) adplug-adplay-unix-5a5364e/m4/ao.m4000066400000000000000000000072611512216033100167360ustar00rootroot00000000000000# ao.m4 # Configure paths for libao # Jack Moffitt 10-21-2000 # Shamelessly stolen from Owen Taylor and Manish Singh # AdPlay/Unix updated some usage of deprecated macros dnl XIPH_PATH_AO([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]) dnl Test for libao, and define AO_CFLAGS and AO_LIBS dnl AC_DEFUN([XIPH_PATH_AO], [dnl dnl Get the cflags and libraries dnl AC_ARG_WITH(ao,[ --with-ao=PFX Prefix where libao is installed (optional)], ao_prefix="$withval", ao_prefix="") AC_ARG_WITH(ao-libraries,[ --with-ao-libraries=DIR Directory where libao library is installed (optional)], ao_libraries="$withval", ao_libraries="") AC_ARG_WITH(ao-includes,[ --with-ao-includes=DIR Directory where libao header files are installed (optional)], ao_includes="$withval", ao_includes="") AC_ARG_ENABLE(aotest, [ --disable-aotest Do not try to compile and run a test ao program],, enable_aotest=yes) if test "x$ao_libraries" != "x" ; then AO_LIBS="-L$ao_libraries" elif test "x$ao_prefix" != "x"; then AO_LIBS="-L$ao_prefix/lib" elif test "x$prefix" != "xNONE"; then AO_LIBS="-L$prefix/lib" fi if test "x$ao_includes" != "x" ; then AO_CFLAGS="-I$ao_includes" elif test "x$ao_prefix" != "x"; then AO_CFLAGS="-I$ao_prefix/include" elif test "x$prefix" != "xNONE"; then AO_CFLAGS="-I$prefix/include" fi # see where dl* and friends live AC_CHECK_FUNCS(dlopen, [AO_DL_LIBS=""], [ AC_CHECK_LIB(dl, dlopen, [AO_DL_LIBS="-ldl"], [ AC_MSG_WARN([could not find dlopen() needed by libao sound drivers your system may not be supported.]) ]) ]) AO_LIBS="$AO_LIBS -lao $AO_DL_LIBS" AC_MSG_CHECKING(for ao) no_ao="" if test "x$enable_aotest" = "xyes" ; then ac_save_CFLAGS="$CFLAGS" ac_save_LIBS="$LIBS" CFLAGS="$CFLAGS $AO_CFLAGS" LIBS="$LIBS $AO_LIBS" dnl dnl Now check if the installed ao is sufficiently new. dnl rm -f conf.aotest AC_RUN_IFELSE([AC_LANG_PROGRAM([[ #include #include #include #include ]],[[ system("touch conf.aotest"); return 0; ]])],, no_ao=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"]) CFLAGS="$ac_save_CFLAGS" LIBS="$ac_save_LIBS" fi if test "x$no_ao" = "x" ; then AC_MSG_RESULT(yes) ifelse([$1], , :, [$1]) else AC_MSG_RESULT(no) if test -f conf.aotest ; then : else echo "*** Could not run ao test program, checking why..." CFLAGS="$CFLAGS $AO_CFLAGS" LIBS="$LIBS $AO_LIBS" AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #include #include ]],[[ return 0; ]])], [ echo "*** The test program compiled, but did not run. This usually means" echo "*** that the run-time linker is not finding ao or finding the wrong" echo "*** version of ao. If it is not finding ao, you'll need to set your" echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" echo "*** to the installed location Also, make sure you have run ldconfig if that" echo "*** is required on your system" echo "***" echo "*** If you have an old version installed, it is best to remove it, although" echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"], [ echo "*** The test program failed to compile or link. See the file config.log for the" echo "*** exact error that occured. This usually means ao was incorrectly installed" echo "*** or that you have moved ao since it was installed." ]) CFLAGS="$ac_save_CFLAGS" LIBS="$ac_save_LIBS" fi AO_CFLAGS="" AO_LIBS="" ifelse([$2], , :, [$2]) fi AC_SUBST(AO_CFLAGS) AC_SUBST(AO_LIBS) rm -f conf.aotest ]) adplug-adplay-unix-5a5364e/m4/esd.m4000066400000000000000000000154711512216033100171140ustar00rootroot00000000000000# Configure paths for ESD # Manish Singh 98-9-30 # stolen back from Frank Belew # stolen from Manish Singh # Shamelessly stolen from Owen Taylor # AdPlay/Unix updated some usage of deprecated macros dnl AM_PATH_ESD([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]]) dnl Test for ESD, and define ESD_CFLAGS and ESD_LIBS dnl AC_DEFUN([AM_PATH_ESD], [dnl dnl Get the cflags and libraries from the esd-config script dnl AC_ARG_WITH(esd-prefix,[ --with-esd-prefix=PFX Prefix where ESD is installed (optional)], esd_prefix="$withval", esd_prefix="") AC_ARG_WITH(esd-exec-prefix,[ --with-esd-exec-prefix=PFX Exec prefix where ESD is installed (optional)], esd_exec_prefix="$withval", esd_exec_prefix="") AC_ARG_ENABLE(esdtest, [ --disable-esdtest Do not try to compile and run a test ESD program], , enable_esdtest=yes) if test x$esd_exec_prefix != x ; then esd_args="$esd_args --exec-prefix=$esd_exec_prefix" if test x${ESD_CONFIG+set} != xset ; then ESD_CONFIG=$esd_exec_prefix/bin/esd-config fi fi if test x$esd_prefix != x ; then esd_args="$esd_args --prefix=$esd_prefix" if test x${ESD_CONFIG+set} != xset ; then ESD_CONFIG=$esd_prefix/bin/esd-config fi fi AC_PATH_PROG(ESD_CONFIG, esd-config, no) min_esd_version=ifelse([$1], ,0.2.7,$1) AC_MSG_CHECKING(for ESD - version >= $min_esd_version) no_esd="" if test "$ESD_CONFIG" = "no" ; then no_esd=yes else AC_LANG_SAVE AC_LANG([C]) ESD_CFLAGS=`$ESD_CONFIG $esdconf_args --cflags` ESD_LIBS=`$ESD_CONFIG $esdconf_args --libs` esd_major_version=`$ESD_CONFIG $esd_args --version | \ sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` esd_minor_version=`$ESD_CONFIG $esd_args --version | \ sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` esd_micro_version=`$ESD_CONFIG $esd_config_args --version | \ sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` if test "x$enable_esdtest" = "xyes" ; then ac_save_CFLAGS="$CFLAGS" ac_save_LIBS="$LIBS" CFLAGS="$CFLAGS $ESD_CFLAGS" LIBS="$LIBS $ESD_LIBS" dnl dnl Now check if the installed ESD is sufficiently new. (Also sanity dnl checks the results of esd-config to some extent dnl rm -f conf.esdtest AC_RUN_IFELSE([AC_LANG_PROGRAM([[ #include #include #include #include ]],[[ char* my_strdup (char *str) { char *new_str; if (str) { new_str = malloc ((strlen (str) + 1) * sizeof(char)); strcpy (new_str, str); } else new_str = NULL; return new_str; } int main () { int major, minor, micro; char *tmp_version; system ("touch conf.esdtest"); /* HP/UX 9 (%@#!) writes to sscanf strings */ tmp_version = my_strdup("$min_esd_version"); if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) { printf("%s, bad version string\n", "$min_esd_version"); exit(1); } if (($esd_major_version > major) || (($esd_major_version == major) && ($esd_minor_version > minor)) || (($esd_major_version == major) && ($esd_minor_version == minor) && ($esd_micro_version >= micro))) { return 0; } else { printf("\n*** 'esd-config --version' returned %d.%d.%d, but the minimum version\n", $esd_major_version, $esd_minor_version, $esd_micro_version); printf("*** of ESD required is %d.%d.%d. If esd-config is correct, then it is\n", major, minor, micro); printf("*** best to upgrade to the required version.\n"); printf("*** If esd-config was wrong, set the environment variable ESD_CONFIG\n"); printf("*** to point to the correct copy of esd-config, and remove the file\n"); printf("*** config.cache before re-running configure\n"); return 1; } } ]])],, no_esd=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"]) CFLAGS="$ac_save_CFLAGS" LIBS="$ac_save_LIBS" AC_LANG_RESTORE fi fi if test "x$no_esd" = x ; then AC_MSG_RESULT(yes) ifelse([$2], , :, [$2]) else AC_MSG_RESULT(no) if test "$ESD_CONFIG" = "no" ; then echo "*** The esd-config script installed by ESD could not be found" echo "*** If ESD was installed in PREFIX, make sure PREFIX/bin is in" echo "*** your path, or set the ESD_CONFIG environment variable to the" echo "*** full path to esd-config." else if test -f conf.esdtest ; then : else echo "*** Could not run ESD test program, checking why..." CFLAGS="$CFLAGS $ESD_CFLAGS" LIBS="$LIBS $ESD_LIBS" AC_LANG_SAVE AC_LANG([C]) AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #include #include ]],[[ return 0; ]])], [ echo "*** The test program compiled, but did not run. This usually means" echo "*** that the run-time linker is not finding ESD or finding the wrong" echo "*** version of ESD. If it is not finding ESD, you'll need to set your" echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" echo "*** to the installed location Also, make sure you have run ldconfig if that" echo "*** is required on your system" echo "***" echo "*** If you have an old version installed, it is best to remove it, although" echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"], [ echo "*** The test program failed to compile or link. See the file config.log for the" echo "*** exact error that occured. This usually means ESD was incorrectly installed" echo "*** or that you have moved ESD since it was installed. In the latter case, you" echo "*** may want to edit the esd-config script: $ESD_CONFIG" ]) CFLAGS="$ac_save_CFLAGS" LIBS="$ac_save_LIBS" AC_LANG_RESTORE fi fi ESD_CFLAGS="" ESD_LIBS="" ifelse([$3], , :, [$3]) fi AC_SUBST(ESD_CFLAGS) AC_SUBST(ESD_LIBS) rm -f conf.esdtest ]) dnl AM_ESD_SUPPORTS_MULTIPLE_RECORD([ACTION-IF-SUPPORTS [, ACTION-IF-NOT-SUPPORTS]]) dnl Test, whether esd supports multiple recording clients (version >=0.2.21) dnl AC_DEFUN([AM_ESD_SUPPORTS_MULTIPLE_RECORD], [dnl AC_MSG_NOTICE([whether installed esd version supports multiple recording clients]) ac_save_ESD_CFLAGS="$ESD_CFLAGS" ac_save_ESD_LIBS="$ESD_LIBS" AM_PATH_ESD(0.2.21, ifelse([$1], , [ AM_CONDITIONAL(ESD_SUPPORTS_MULTIPLE_RECORD, true) AC_DEFINE(ESD_SUPPORTS_MULTIPLE_RECORD, 1, [Define if you have esound with support of multiple recording clients.])], [$1]), ifelse([$2], , [AM_CONDITIONAL(ESD_SUPPORTS_MULTIPLE_RECORD, false)], [$2]) if test "x$ac_save_ESD_CFLAGS" != x ; then ESD_CFLAGS="$ac_save_ESD_CFLAGS" fi if test "x$ac_save_ESD_LIBS" != x ; then ESD_LIBS="$ac_save_ESD_LIBS" fi ) ]) adplug-adplay-unix-5a5364e/m4/pkg.m4000066400000000000000000000306511512216033100171170ustar00rootroot00000000000000# pkg.m4 - Macros to locate and use pkg-config. -*- Autoconf -*- # serial 12 (pkg-config-0.29.2) dnl Copyright Š 2004 Scott James Remnant . dnl Copyright Š 2012-2015 Dan Nicholson dnl dnl This program is free software; you can redistribute it and/or modify dnl it under the terms of the GNU General Public License as published by dnl the Free Software Foundation; either version 2 of the License, or dnl (at your option) any later version. dnl dnl This program is distributed in the hope that it will be useful, but dnl WITHOUT ANY WARRANTY; without even the implied warranty of dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU dnl General Public License for more details. dnl dnl You should have received a copy of the GNU General Public License dnl along with this program; if not, write to the Free Software dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA dnl 02111-1307, USA. dnl dnl As a special exception to the GNU General Public License, if you dnl distribute this file as part of a program that contains a dnl configuration script generated by Autoconf, you may include it under dnl the same distribution terms that you use for the rest of that dnl program. dnl PKG_PREREQ(MIN-VERSION) dnl ----------------------- dnl Since: 0.29 dnl dnl Verify that the version of the pkg-config macros are at least dnl MIN-VERSION. Unlike PKG_PROG_PKG_CONFIG, which checks the user's dnl installed version of pkg-config, this checks the developer's version dnl of pkg.m4 when generating configure. dnl dnl To ensure that this macro is defined, also add: dnl m4_ifndef([PKG_PREREQ], dnl [m4_fatal([must install pkg-config 0.29 or later before running autoconf/autogen])]) dnl dnl See the "Since" comment for each macro you use to see what version dnl of the macros you require. m4_defun([PKG_PREREQ], [m4_define([PKG_MACROS_VERSION], [0.29.2]) m4_if(m4_version_compare(PKG_MACROS_VERSION, [$1]), -1, [m4_fatal([pkg.m4 version $1 or higher is required but ]PKG_MACROS_VERSION[ found])]) ])dnl PKG_PREREQ dnl PKG_PROG_PKG_CONFIG([MIN-VERSION]) dnl ---------------------------------- dnl Since: 0.16 dnl dnl Search for the pkg-config tool and set the PKG_CONFIG variable to dnl first found in the path. Checks that the version of pkg-config found dnl is at least MIN-VERSION. If MIN-VERSION is not specified, 0.9.0 is dnl used since that's the first version where most current features of dnl pkg-config existed. AC_DEFUN([PKG_PROG_PKG_CONFIG], [m4_pattern_forbid([^_?PKG_[A-Z_]+$]) m4_pattern_allow([^PKG_CONFIG(_(PATH|LIBDIR|SYSROOT_DIR|ALLOW_SYSTEM_(CFLAGS|LIBS)))?$]) m4_pattern_allow([^PKG_CONFIG_(DISABLE_UNINSTALLED|TOP_BUILD_DIR|DEBUG_SPEW)$]) AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility]) AC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path]) AC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path]) if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then AC_PATH_TOOL([PKG_CONFIG], [pkg-config]) fi if test -n "$PKG_CONFIG"; then _pkg_min_version=m4_default([$1], [0.9.0]) AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version]) if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) PKG_CONFIG="" fi fi[]dnl ])dnl PKG_PROG_PKG_CONFIG dnl PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) dnl ------------------------------------------------------------------- dnl Since: 0.18 dnl dnl Check to see whether a particular set of modules exists. Similar to dnl PKG_CHECK_MODULES(), but does not set variables or print errors. dnl dnl Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG]) dnl only at the first occurrence in configure.ac, so if the first place dnl it's called might be skipped (such as if it is within an "if", you dnl have to call PKG_CHECK_EXISTS manually AC_DEFUN([PKG_CHECK_EXISTS], [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl if test -n "$PKG_CONFIG" && \ AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then m4_default([$2], [:]) m4_ifvaln([$3], [else $3])dnl fi]) dnl _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES]) dnl --------------------------------------------- dnl Internal wrapper calling pkg-config via PKG_CONFIG and setting dnl pkg_failed based on the result. m4_define([_PKG_CONFIG], [if test -n "$$1"; then pkg_cv_[]$1="$$1" elif test -n "$PKG_CONFIG"; then PKG_CHECK_EXISTS([$3], [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes ], [pkg_failed=yes]) else pkg_failed=untried fi[]dnl ])dnl _PKG_CONFIG dnl _PKG_SHORT_ERRORS_SUPPORTED dnl --------------------------- dnl Internal check to see if pkg-config supports short errors. AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED], [AC_REQUIRE([PKG_PROG_PKG_CONFIG]) if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes else _pkg_short_errors_supported=no fi[]dnl ])dnl _PKG_SHORT_ERRORS_SUPPORTED dnl PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND], dnl [ACTION-IF-NOT-FOUND]) dnl -------------------------------------------------------------- dnl Since: 0.4.0 dnl dnl Note that if there is a possibility the first call to dnl PKG_CHECK_MODULES might not happen, you should be sure to include an dnl explicit call to PKG_PROG_PKG_CONFIG in your configure.ac AC_DEFUN([PKG_CHECK_MODULES], [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl pkg_failed=no AC_MSG_CHECKING([for $2]) _PKG_CONFIG([$1][_CFLAGS], [cflags], [$2]) _PKG_CONFIG([$1][_LIBS], [libs], [$2]) m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS and $1[]_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details.]) if test $pkg_failed = yes; then AC_MSG_RESULT([no]) _PKG_SHORT_ERRORS_SUPPORTED if test $_pkg_short_errors_supported = yes; then $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$2" 2>&1` else $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD m4_default([$4], [AC_MSG_ERROR( [Package requirements ($2) were not met: $$1_PKG_ERRORS Consider adjusting the PKG_CONFIG_PATH environment variable if you installed software in a non-standard prefix. _PKG_TEXT])[]dnl ]) elif test $pkg_failed = untried; then AC_MSG_RESULT([no]) m4_default([$4], [AC_MSG_FAILURE( [The pkg-config script could not be found or is too old. Make sure it is in your PATH or set the PKG_CONFIG environment variable to the full path to pkg-config. _PKG_TEXT To get pkg-config, see .])[]dnl ]) else $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS $1[]_LIBS=$pkg_cv_[]$1[]_LIBS AC_MSG_RESULT([yes]) $3 fi[]dnl ])dnl PKG_CHECK_MODULES dnl PKG_CHECK_MODULES_STATIC(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND], dnl [ACTION-IF-NOT-FOUND]) dnl --------------------------------------------------------------------- dnl Since: 0.29 dnl dnl Checks for existence of MODULES and gathers its build flags with dnl static libraries enabled. Sets VARIABLE-PREFIX_CFLAGS from --cflags dnl and VARIABLE-PREFIX_LIBS from --libs. dnl dnl Note that if there is a possibility the first call to dnl PKG_CHECK_MODULES_STATIC might not happen, you should be sure to dnl include an explicit call to PKG_PROG_PKG_CONFIG in your dnl configure.ac. AC_DEFUN([PKG_CHECK_MODULES_STATIC], [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl _save_PKG_CONFIG=$PKG_CONFIG PKG_CONFIG="$PKG_CONFIG --static" PKG_CHECK_MODULES($@) PKG_CONFIG=$_save_PKG_CONFIG[]dnl ])dnl PKG_CHECK_MODULES_STATIC dnl PKG_INSTALLDIR([DIRECTORY]) dnl ------------------------- dnl Since: 0.27 dnl dnl Substitutes the variable pkgconfigdir as the location where a module dnl should install pkg-config .pc files. By default the directory is dnl $libdir/pkgconfig, but the default can be changed by passing dnl DIRECTORY. The user can override through the --with-pkgconfigdir dnl parameter. AC_DEFUN([PKG_INSTALLDIR], [m4_pushdef([pkg_default], [m4_default([$1], ['${libdir}/pkgconfig'])]) m4_pushdef([pkg_description], [pkg-config installation directory @<:@]pkg_default[@:>@]) AC_ARG_WITH([pkgconfigdir], [AS_HELP_STRING([--with-pkgconfigdir], pkg_description)],, [with_pkgconfigdir=]pkg_default) AC_SUBST([pkgconfigdir], [$with_pkgconfigdir]) m4_popdef([pkg_default]) m4_popdef([pkg_description]) ])dnl PKG_INSTALLDIR dnl PKG_NOARCH_INSTALLDIR([DIRECTORY]) dnl -------------------------------- dnl Since: 0.27 dnl dnl Substitutes the variable noarch_pkgconfigdir as the location where a dnl module should install arch-independent pkg-config .pc files. By dnl default the directory is $datadir/pkgconfig, but the default can be dnl changed by passing DIRECTORY. The user can override through the dnl --with-noarch-pkgconfigdir parameter. AC_DEFUN([PKG_NOARCH_INSTALLDIR], [m4_pushdef([pkg_default], [m4_default([$1], ['${datadir}/pkgconfig'])]) m4_pushdef([pkg_description], [pkg-config arch-independent installation directory @<:@]pkg_default[@:>@]) AC_ARG_WITH([noarch-pkgconfigdir], [AS_HELP_STRING([--with-noarch-pkgconfigdir], pkg_description)],, [with_noarch_pkgconfigdir=]pkg_default) AC_SUBST([noarch_pkgconfigdir], [$with_noarch_pkgconfigdir]) m4_popdef([pkg_default]) m4_popdef([pkg_description]) ])dnl PKG_NOARCH_INSTALLDIR dnl PKG_CHECK_VAR(VARIABLE, MODULE, CONFIG-VARIABLE, dnl [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) dnl ------------------------------------------- dnl Since: 0.28 dnl dnl Retrieves the value of the pkg-config variable for the given module. AC_DEFUN([PKG_CHECK_VAR], [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl AC_ARG_VAR([$1], [value of $3 for $2, overriding pkg-config])dnl _PKG_CONFIG([$1], [variable="][$3]["], [$2]) AS_VAR_COPY([$1], [pkg_cv_][$1]) AS_VAR_IF([$1], [""], [$5], [$4])dnl ])dnl PKG_CHECK_VAR dnl PKG_WITH_MODULES(VARIABLE-PREFIX, MODULES, dnl [ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND], dnl [DESCRIPTION], [DEFAULT]) dnl ------------------------------------------ dnl dnl Prepare a "--with-" configure option using the lowercase dnl [VARIABLE-PREFIX] name, merging the behaviour of AC_ARG_WITH and dnl PKG_CHECK_MODULES in a single macro. AC_DEFUN([PKG_WITH_MODULES], [ m4_pushdef([with_arg], m4_tolower([$1])) m4_pushdef([description], [m4_default([$5], [build with ]with_arg[ support])]) m4_pushdef([def_arg], [m4_default([$6], [auto])]) m4_pushdef([def_action_if_found], [AS_TR_SH([with_]with_arg)=yes]) m4_pushdef([def_action_if_not_found], [AS_TR_SH([with_]with_arg)=no]) m4_case(def_arg, [yes],[m4_pushdef([with_without], [--without-]with_arg)], [m4_pushdef([with_without],[--with-]with_arg)]) AC_ARG_WITH(with_arg, AS_HELP_STRING(with_without, description[ @<:@default=]def_arg[@:>@]),, [AS_TR_SH([with_]with_arg)=def_arg]) AS_CASE([$AS_TR_SH([with_]with_arg)], [yes],[PKG_CHECK_MODULES([$1],[$2],$3,$4)], [auto],[PKG_CHECK_MODULES([$1],[$2], [m4_n([def_action_if_found]) $3], [m4_n([def_action_if_not_found]) $4])]) m4_popdef([with_arg]) m4_popdef([description]) m4_popdef([def_arg]) ])dnl PKG_WITH_MODULES dnl PKG_HAVE_WITH_MODULES(VARIABLE-PREFIX, MODULES, dnl [DESCRIPTION], [DEFAULT]) dnl ----------------------------------------------- dnl dnl Convenience macro to trigger AM_CONDITIONAL after PKG_WITH_MODULES dnl check._[VARIABLE-PREFIX] is exported as make variable. AC_DEFUN([PKG_HAVE_WITH_MODULES], [ PKG_WITH_MODULES([$1],[$2],,,[$3],[$4]) AM_CONDITIONAL([HAVE_][$1], [test "$AS_TR_SH([with_]m4_tolower([$1]))" = "yes"]) ])dnl PKG_HAVE_WITH_MODULES dnl PKG_HAVE_DEFINE_WITH_MODULES(VARIABLE-PREFIX, MODULES, dnl [DESCRIPTION], [DEFAULT]) dnl ------------------------------------------------------ dnl dnl Convenience macro to run AM_CONDITIONAL and AC_DEFINE after dnl PKG_WITH_MODULES check. HAVE_[VARIABLE-PREFIX] is exported as make dnl and preprocessor variable. AC_DEFUN([PKG_HAVE_DEFINE_WITH_MODULES], [ PKG_HAVE_WITH_MODULES([$1],[$2],[$3],[$4]) AS_IF([test "$AS_TR_SH([with_]m4_tolower([$1]))" = "yes"], [AC_DEFINE([HAVE_][$1], 1, [Enable ]m4_tolower([$1])[ support])]) ])dnl PKG_HAVE_DEFINE_WITH_MODULES adplug-adplay-unix-5a5364e/m4/sdl.m4000066400000000000000000000146531512216033100171240ustar00rootroot00000000000000# Configure paths for SDL # Sam Lantinga 9/21/99 # stolen from Manish Singh # stolen back from Frank Belew # stolen from Manish Singh # Shamelessly stolen from Owen Taylor # serial 2 dnl AM_PATH_SDL([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]]) dnl Test for SDL, and define SDL_CFLAGS and SDL_LIBS dnl AC_DEFUN([AM_PATH_SDL], [dnl dnl Get the cflags and libraries from the sdl-config script dnl AC_ARG_WITH(sdl-prefix,[ --with-sdl-prefix=PFX Prefix where SDL is installed (optional)], sdl_prefix="$withval", sdl_prefix="") AC_ARG_WITH(sdl-exec-prefix,[ --with-sdl-exec-prefix=PFX Exec prefix where SDL is installed (optional)], sdl_exec_prefix="$withval", sdl_exec_prefix="") AC_ARG_ENABLE(sdltest, [ --disable-sdltest Do not try to compile and run a test SDL program], , enable_sdltest=yes) min_sdl_version=ifelse([$1], ,1.2.0,$1) if test "x$sdl_prefix$sdl_exec_prefix" = x ; then PKG_CHECK_MODULES([SDL], [sdl >= $min_sdl_version], [sdl_pc=yes], [sdl_pc=no]) else sdl_pc=no if test x$sdl_exec_prefix != x ; then sdl_config_args="$sdl_config_args --exec-prefix=$sdl_exec_prefix" if test x${SDL_CONFIG+set} != xset ; then SDL_CONFIG=$sdl_exec_prefix/bin/sdl-config fi fi if test x$sdl_prefix != x ; then sdl_config_args="$sdl_config_args --prefix=$sdl_prefix" if test x${SDL_CONFIG+set} != xset ; then SDL_CONFIG=$sdl_prefix/bin/sdl-config fi fi fi if test "x$sdl_pc" = xyes ; then no_sdl="" SDL_CONFIG="pkg-config sdl" else as_save_PATH="$PATH" if test "x$prefix" != xNONE && test "$cross_compiling" != yes; then PATH="$prefix/bin:$prefix/usr/bin:$PATH" fi AC_PATH_PROG(SDL_CONFIG, sdl-config, no, [$PATH]) PATH="$as_save_PATH" AC_MSG_CHECKING(for SDL - version >= $min_sdl_version) no_sdl="" if test "$SDL_CONFIG" = "no" ; then no_sdl=yes else SDL_CFLAGS=`$SDL_CONFIG $sdl_config_args --cflags` SDL_LIBS=`$SDL_CONFIG $sdl_config_args --libs` sdl_major_version=`$SDL_CONFIG $sdl_config_args --version | \ sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` sdl_minor_version=`$SDL_CONFIG $sdl_config_args --version | \ sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` sdl_micro_version=`$SDL_CONFIG $sdl_config_args --version | \ sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` if test "x$enable_sdltest" = "xyes" ; then ac_save_CFLAGS="$CFLAGS" ac_save_CXXFLAGS="$CXXFLAGS" ac_save_LIBS="$LIBS" CFLAGS="$CFLAGS $SDL_CFLAGS" CXXFLAGS="$CXXFLAGS $SDL_CFLAGS" LIBS="$LIBS $SDL_LIBS" dnl dnl Now check if the installed SDL is sufficiently new. (Also sanity dnl checks the results of sdl-config to some extent dnl rm -f conf.sdltest AC_RUN_IFELSE([AC_LANG_SOURCE([[ #include #include #include "SDL.h" int main (int argc, char *argv[]) { int major, minor, micro; FILE *fp = fopen("conf.sdltest", "w"); if (fp) fclose(fp); if (sscanf("$min_sdl_version", "%d.%d.%d", &major, &minor, µ) != 3) { printf("%s, bad version string\n", "$min_sdl_version"); exit(1); } if (($sdl_major_version > major) || (($sdl_major_version == major) && ($sdl_minor_version > minor)) || (($sdl_major_version == major) && ($sdl_minor_version == minor) && ($sdl_micro_version >= micro))) { return 0; } else { printf("\n*** 'sdl-config --version' returned %d.%d.%d, but the minimum version\n", $sdl_major_version, $sdl_minor_version, $sdl_micro_version); printf("*** of SDL required is %d.%d.%d. If sdl-config is correct, then it is\n", major, minor, micro); printf("*** best to upgrade to the required version.\n"); printf("*** If sdl-config was wrong, set the environment variable SDL_CONFIG\n"); printf("*** to point to the correct copy of sdl-config, and remove the file\n"); printf("*** config.cache before re-running configure\n"); return 1; } } ]])], [], [no_sdl=yes], [echo $ac_n "cross compiling; assumed OK... $ac_c"]) CFLAGS="$ac_save_CFLAGS" CXXFLAGS="$ac_save_CXXFLAGS" LIBS="$ac_save_LIBS" fi fi if test "x$no_sdl" = x ; then AC_MSG_RESULT(yes) else AC_MSG_RESULT(no) fi fi if test "x$no_sdl" = x ; then ifelse([$2], , :, [$2]) else if test "$SDL_CONFIG" = "no" ; then echo "*** The sdl-config script installed by SDL could not be found" echo "*** If SDL was installed in PREFIX, make sure PREFIX/bin is in" echo "*** your path, or set the SDL_CONFIG environment variable to the" echo "*** full path to sdl-config." else if test -f conf.sdltest ; then : else echo "*** Could not run SDL test program, checking why..." CFLAGS="$CFLAGS $SDL_CFLAGS" CXXFLAGS="$CXXFLAGS $SDL_CFLAGS" LIBS="$LIBS $SDL_LIBS" AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #include #include "SDL.h" int main(int argc, char *argv[]) { return 0; } #undef main #define main K_and_R_C_main ]], [[ return 0; ]])], [ echo "*** The test program compiled, but did not run. This usually means" echo "*** that the run-time linker is not finding SDL or finding the wrong" echo "*** version of SDL. If it is not finding SDL, you'll need to set your" echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" echo "*** to the installed location Also, make sure you have run ldconfig if that" echo "*** is required on your system" echo "***" echo "*** If you have an old version installed, it is best to remove it, although" echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"], [ echo "*** The test program failed to compile or link. See the file config.log for the" echo "*** exact error that occured. This usually means SDL was incorrectly installed" echo "*** or that you have moved SDL since it was installed. In the latter case, you" echo "*** may want to edit the sdl-config script: $SDL_CONFIG" ]) CFLAGS="$ac_save_CFLAGS" CXXFLAGS="$ac_save_CXXFLAGS" LIBS="$ac_save_LIBS" fi fi SDL_CFLAGS="" SDL_LIBS="" ifelse([$3], , :, [$3]) fi AC_SUBST(SDL_CFLAGS) AC_SUBST(SDL_LIBS) rm -f conf.sdltest ]) adplug-adplay-unix-5a5364e/m4/sdl2.m4000066400000000000000000000171431512216033100172030ustar00rootroot00000000000000# Configure paths for SDL # Sam Lantinga 9/21/99 # stolen from Manish Singh # stolen back from Frank Belew # stolen from Manish Singh # Shamelessly stolen from Owen Taylor # # Changelog: # * also look for SDL2.framework under Mac OS X # * removed HP/UX 9 support. # * updated for newer autoconf. # serial 2 dnl AM_PATH_SDL2([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]]) dnl Test for SDL, and define SDL_CFLAGS and SDL_LIBS dnl AC_DEFUN([AM_PATH_SDL2], [dnl dnl Get the cflags and libraries from the sdl2-config script dnl AC_ARG_WITH(sdl-prefix,[ --with-sdl-prefix=PFX Prefix where SDL is installed (optional)], sdl_prefix="$withval", sdl_prefix="") AC_ARG_WITH(sdl-exec-prefix,[ --with-sdl-exec-prefix=PFX Exec prefix where SDL is installed (optional)], sdl_exec_prefix="$withval", sdl_exec_prefix="") AC_ARG_ENABLE(sdltest, [ --disable-sdltest Do not try to compile and run a test SDL program], , enable_sdltest=yes) AC_ARG_ENABLE(sdlframework, [ --disable-sdlframework Do not search for SDL2.framework], , search_sdl_framework=yes) AC_ARG_VAR(SDL2_FRAMEWORK, [Path to SDL2.framework]) min_sdl_version=ifelse([$1], ,2.0.0,$1) if test "x$sdl_prefix$sdl_exec_prefix" = x ; then PKG_CHECK_MODULES([SDL], [sdl2 >= $min_sdl_version], [sdl_pc=yes], [sdl_pc=no]) else sdl_pc=no if test x$sdl_exec_prefix != x ; then sdl_config_args="$sdl_config_args --exec-prefix=$sdl_exec_prefix" if test x${SDL2_CONFIG+set} != xset ; then SDL2_CONFIG=$sdl_exec_prefix/bin/sdl2-config fi fi if test x$sdl_prefix != x ; then sdl_config_args="$sdl_config_args --prefix=$sdl_prefix" if test x${SDL2_CONFIG+set} != xset ; then SDL2_CONFIG=$sdl_prefix/bin/sdl2-config fi fi fi if test "x$sdl_pc" = xyes ; then no_sdl="" SDL2_CONFIG="pkg-config sdl2" else as_save_PATH="$PATH" if test "x$prefix" != xNONE && test "$cross_compiling" != yes; then PATH="$prefix/bin:$prefix/usr/bin:$PATH" fi AC_PATH_PROG(SDL2_CONFIG, sdl2-config, no, [$PATH]) PATH="$as_save_PATH" no_sdl="" if test "$SDL2_CONFIG" = "no" -a "x$search_sdl_framework" = "xyes"; then AC_MSG_CHECKING(for SDL2.framework) if test "x$SDL2_FRAMEWORK" != x; then sdl_framework=$SDL2_FRAMEWORK else for d in / ~/ /System/; do if test -d "${d}Library/Frameworks/SDL2.framework"; then sdl_framework="${d}Library/Frameworks/SDL2.framework" fi done fi if test x"$sdl_framework" != x && test -d "$sdl_framework"; then AC_MSG_RESULT($sdl_framework) sdl_framework_dir=`dirname $sdl_framework` SDL_CFLAGS="-F$sdl_framework_dir -Wl,-framework,SDL2 -I$sdl_framework/include" SDL_LIBS="-F$sdl_framework_dir -Wl,-framework,SDL2" else no_sdl=yes fi fi if test "$SDL2_CONFIG" != "no"; then if test "x$sdl_pc" = "xno"; then AC_MSG_CHECKING(for SDL - version >= $min_sdl_version) SDL_CFLAGS=`$SDL2_CONFIG $sdl_config_args --cflags` SDL_LIBS=`$SDL2_CONFIG $sdl_config_args --libs` fi sdl_major_version=`$SDL2_CONFIG $sdl_config_args --version | \ sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` sdl_minor_version=`$SDL2_CONFIG $sdl_config_args --version | \ sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` sdl_micro_version=`$SDL2_CONFIG $sdl_config_args --version | \ sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` if test "x$enable_sdltest" = "xyes" ; then ac_save_CFLAGS="$CFLAGS" ac_save_CXXFLAGS="$CXXFLAGS" ac_save_LIBS="$LIBS" CFLAGS="$CFLAGS $SDL_CFLAGS" CXXFLAGS="$CXXFLAGS $SDL_CFLAGS" LIBS="$LIBS $SDL_LIBS" dnl dnl Now check if the installed SDL is sufficiently new. (Also sanity dnl checks the results of sdl2-config to some extent dnl rm -f conf.sdltest AC_RUN_IFELSE([AC_LANG_SOURCE([[ #include #include #include "SDL.h" int main (int argc, char *argv[]) { int major, minor, micro; FILE *fp = fopen("conf.sdltest", "w"); if (fp) fclose(fp); if (sscanf("$min_sdl_version", "%d.%d.%d", &major, &minor, µ) != 3) { printf("%s, bad version string\n", "$min_sdl_version"); exit(1); } if (($sdl_major_version > major) || (($sdl_major_version == major) && ($sdl_minor_version > minor)) || (($sdl_major_version == major) && ($sdl_minor_version == minor) && ($sdl_micro_version >= micro))) { return 0; } else { printf("\n*** 'sdl2-config --version' returned %d.%d.%d, but the minimum version\n", $sdl_major_version, $sdl_minor_version, $sdl_micro_version); printf("*** of SDL required is %d.%d.%d. If sdl2-config is correct, then it is\n", major, minor, micro); printf("*** best to upgrade to the required version.\n"); printf("*** If sdl2-config was wrong, set the environment variable SDL2_CONFIG\n"); printf("*** to point to the correct copy of sdl2-config, and remove the file\n"); printf("*** config.cache before re-running configure\n"); return 1; } } ]])], [], [no_sdl=yes], [echo $ac_n "cross compiling; assumed OK... $ac_c"]) CFLAGS="$ac_save_CFLAGS" CXXFLAGS="$ac_save_CXXFLAGS" LIBS="$ac_save_LIBS" fi if test "x$sdl_pc" = "xno"; then if test "x$no_sdl" = "xyes"; then AC_MSG_RESULT(no) else AC_MSG_RESULT(yes) fi fi fi fi if test "x$no_sdl" = x ; then ifelse([$2], , :, [$2]) else if test "$SDL2_CONFIG" = "no" ; then echo "*** The sdl2-config script installed by SDL could not be found" echo "*** If SDL was installed in PREFIX, make sure PREFIX/bin is in" echo "*** your path, or set the SDL2_CONFIG environment variable to the" echo "*** full path to sdl2-config." else if test -f conf.sdltest ; then : else echo "*** Could not run SDL test program, checking why..." CFLAGS="$CFLAGS $SDL_CFLAGS" CXXFLAGS="$CXXFLAGS $SDL_CFLAGS" LIBS="$LIBS $SDL_LIBS" AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #include #include "SDL.h" int main(int argc, char *argv[]) { return 0; } #undef main #define main K_and_R_C_main ]], [[ return 0; ]])], [ echo "*** The test program compiled, but did not run. This usually means" echo "*** that the run-time linker is not finding SDL or finding the wrong" echo "*** version of SDL. If it is not finding SDL, you'll need to set your" echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" echo "*** to the installed location Also, make sure you have run ldconfig if that" echo "*** is required on your system" echo "***" echo "*** If you have an old version installed, it is best to remove it, although" echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"], [ echo "*** The test program failed to compile or link. See the file config.log for the" echo "*** exact error that occured. This usually means SDL was incorrectly installed" echo "*** or that you have moved SDL since it was installed. In the latter case, you" echo "*** may want to edit the sdl2-config script: $SDL2_CONFIG" ]) CFLAGS="$ac_save_CFLAGS" CXXFLAGS="$ac_save_CXXFLAGS" LIBS="$ac_save_LIBS" fi fi SDL_CFLAGS="" SDL_LIBS="" ifelse([$3], , :, [$3]) fi AC_SUBST(SDL_CFLAGS) AC_SUBST(SDL_LIBS) rm -f conf.sdltest ]) adplug-adplay-unix-5a5364e/src/000077500000000000000000000000001512216033100163365ustar00rootroot00000000000000adplug-adplay-unix-5a5364e/src/Makefile.am000066400000000000000000000011271512216033100203730ustar00rootroot00000000000000bin_PROGRAMS = adplay adplay_SOURCES = adplay.cc output.cc output.h players.h defines.h EXTRA_adplay_SOURCES = oss.cc oss.h null.h disk.cc disk.h esound.cc esound.h \ qsa.cc qsa.h sdl.cc sdl_driver.h alsa.cc alsa.h ao.cc ao.h getopt.c \ getopt1.c getopt.h diskraw.h adplay_LDADD = $(drivers) $(adplug_LIBS) @ESD_LIBS@ @QSA_LIBS@ @SDL_LIBS@ \ @ALSA_LIBS@ @AO_LIBS@ $(GETOPT_SOURCES) adplay_DEPENDENCIES = $(drivers) $(GETOPT_SOURCES) adplug_data_dir = $(sharedstatedir)/adplug AM_CPPFLAGS = $(adplug_CFLAGS) @ESD_CFLAGS@ @SDL_CFLAGS@ @ALSA_CFLAGS@ \ -DADPLUG_DATA_DIR=\"$(adplug_data_dir)\" adplug-adplay-unix-5a5364e/src/adplay.cc000066400000000000000000000431671512216033100201320ustar00rootroot00000000000000/* * AdPlay/UNIX - OPL2 audio player * Copyright (C) 2001 - 2017, 2024 Simon Peter * * 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, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include #include #include #include #include #include #include #include #include #include /* * Sun systems declare getopt in unistd.h, * other systems (Linux, Apple) use getopt.h. */ #if (defined(__SVR4) && defined(__sun)) # include #else # ifdef HAVE_GETOPT_H # include # else # include "getopt.h" // ALSA now includes the system-wide getopt under Linux, so stop this # define _GETOPT_POSIX_H 1 # endif #endif #include "defines.h" #ifdef HAVE_ADPLUG_NUKEDOPL #include #endif #ifdef HAVE_ADPLUG_SURROUND #include #endif #include "output.h" #include "players.h" /***** Defines *****/ // Default file name of AdPlug's database file #define ADPLUGDB_FILE "adplug.db" // Default AdPlug user's configuration subdirectory #define ADPLUG_CONFDIR ".adplug" // Default path to AdPlug's system-wide database file #ifdef ADPLUG_DATA_DIR # define ADPLUGDB_PATH ADPLUG_DATA_DIR "/" ADPLUGDB_FILE #else # define ADPLUGDB_PATH ADPLUGDB_FILE #endif /***** Typedefs *****/ typedef enum { Emu_Satoh, Emu_Ken, Emu_Woody, #ifdef HAVE_ADPLUG_NUKEDOPL Emu_Nuked, #endif } EmuType; /***** Global variables *****/ static const char *program_name; static Player *player = 0; // global player object static CAdPlugDatabase mydb; static Copl *opl = 0; /***** Configuration (and defaults) *****/ static struct { int buf_size, freq, channels, bits, harmonic, message_level; unsigned int subsong, loops; const char *device; char *userdb; bool endless, showinsts, songinfo, songmessage; EmuType emutype; Outputs output; } cfg = { 2048, 44100, #ifdef HAVE_ADPLUG_SURROUND 2, 16, 1, // Default to surround if available #else 1, 16, 0, // Else default to mono (until stereo w/ single OPL is fixed) #endif MSG_NOTE, (unsigned int)-1, 1, NULL, NULL, true, false, false, false, Emu_Woody, DEFAULT_DRIVER }; /***** Global functions *****/ void message(int level, const char *fmt, ...) { va_list argptr; if(cfg.message_level < level) return; fprintf(stderr, "%s: ", program_name); va_start(argptr, fmt); vfprintf(stderr, fmt, argptr); va_end(argptr); fprintf(stderr, "\n"); } /***** Local functions *****/ static void usage() /* Print usage information. */ { printf("Usage: %s [OPTION]... FILE...\n\n" "Output selection:\n" " -e, --emulator=EMULATOR specify emulator to use\n" " -O, --output=OUTPUT specify output mechanism\n\n" #ifdef DRIVER_OSS "OSS driver (oss) specific:\n" " -d, --device=FILE set sound device file to FILE\n" " -b, --buffer=SIZE set output buffer size to SIZE\n\n" #endif #ifdef DRIVER_DISK "Disk writer (disk) specific:\n" " -d, --device=FILE output to FILE ('-' is stdout)\n\n" #endif #ifdef DRIVER_ESOUND "EsounD driver (esound) specific:\n" " -d, --device=URL URL to EsounD server host (hostname:port)\n\n" #endif #ifdef DRIVER_SDL "SDL driver (sdl) specific:\n" " -b, --buffer=SIZE set output buffer size to SIZE\n\n" #endif #ifdef DRIVER_ALSA "ALSA driver (alsa) specific:\n" " -d, --device=DEVICE set sound device to DEVICE\n" " -b, --buffer=SIZE set output buffer size to SIZE\n\n" #endif #ifdef DRIVER_RAW "RAW file writer (raw) specific:\n" " -d, --device=FILE output to FILE\n\n" #endif "Playback quality:\n" " -8, --8bit 8-bit sample quality\n" " --16bit 16-bit sample quality\n" " -f, --freq=FREQ set sample frequency to FREQ\n" " --surround stereo/surround stream\n" " --stereo stereo stream\n" " --mono mono stream\n\n" "Informative output:\n" " -i, --instruments display instrument names\n" " -r, --realtime display realtime song info\n" " -m, --message display song message\n\n" "Playback:\n" " -s, --subsong=N play subsong number N\n" " -o, --once play only once, don't loop\n" " -l, --loop=N loop exactly N times\n\n" "Generic:\n" " -D, --database=FILE additionally use database file FILE\n" " -q, --quiet be more quiet\n" " -v, --verbose be more verbose\n" " -h, --help display this help and exit\n" " -V, --version output version information and exit\n\n", program_name); // Print list of available output mechanisms printf("Available emulators: satoh ken woody"); #ifdef HAVE_ADPLUG_NUKEDOPL printf(" nuked"); #endif printf("\n"); printf("Available output mechanisms:" #ifdef DRIVER_OSS " oss" #endif #ifdef DRIVER_NULL " null" #endif #ifdef DRIVER_DISK " disk" #endif #ifdef DRIVER_ESOUND " esound" #endif #ifdef DRIVER_QSA " qsa" #endif #ifdef DRIVER_SDL " sdl" #endif #ifdef DRIVER_AO " ao" #endif #ifdef DRIVER_ALSA " alsa" #endif #ifdef DRIVER_RAW " raw" #endif "\n"); } static int decode_switches(int argc, char **argv) /* * Set all the option flags according to the switches specified. * Return the index of the first non-option argument. */ { int c; struct option const long_options[] = { {"8bit", no_argument, NULL, '8'}, // 8-bit replay {"16bit", no_argument, NULL, '1'}, // 16-bit replay {"freq", required_argument, NULL, 'f'}, // set frequency {"surround", no_argument, NULL, '4'}, // stereo/harmonic replay {"stereo", no_argument, NULL, '3'}, // stereo replay {"mono", no_argument, NULL, '2'}, // mono replay {"buffer", required_argument, NULL, 'b'}, // buffer size {"device", required_argument, NULL, 'd'}, // device file {"instruments", no_argument, NULL, 'i'}, // show instruments {"realtime", no_argument, NULL, 'r'}, // realtime song info {"message", no_argument, NULL, 'm'}, // song message {"subsong", no_argument, NULL, 's'}, // play subsong {"once", no_argument, NULL, 'o'}, // don't loop {"loop", required_argument, NULL, 'l'}, // loop count {"help", no_argument, NULL, 'h'}, // display help {"version", no_argument, NULL, 'V'}, // version information {"emulator", required_argument, NULL, 'e'}, // emulator to use {"output", required_argument, NULL, 'O'}, // output mechanism {"database", required_argument, NULL, 'D'}, // different database {"quiet", no_argument, NULL, 'q'}, // be more quiet {"verbose", no_argument, NULL, 'v'}, // be more verbose {NULL, 0, NULL, 0} // end of options }; while ((c = getopt_long(argc, argv, "8f:b:d:irms:ol:hVe:O:D:qv", long_options, (int *)0)) != EOF) { switch (c) { case '8': cfg.bits = 8; break; case '1': cfg.bits = 16; break; case 'f': cfg.freq = atoi(optarg); break; case '4': cfg.channels = 2; cfg.harmonic = 1; break; case '3': cfg.channels = 2; cfg.harmonic = 0; break; case '2': cfg.channels = 1; cfg.harmonic = 0; break; case 'b': cfg.buf_size = atoi(optarg); break; case 'd': cfg.device = optarg; break; case 'i': cfg.showinsts = true; break; case 'r': cfg.songinfo = true; break; case 'm': cfg.songmessage = true; break; case 's': cfg.subsong = atoi(optarg); break; case 'o': cfg.endless = false; break; case 'l': cfg.endless = false; cfg.loops = atoi(optarg); break; case 'V': puts(ADPLAY_VERSION); exit(EXIT_SUCCESS); case 'h': usage(); exit(EXIT_SUCCESS); break; case 'D': if(!mydb.load(optarg)) message(MSG_WARN, "could not open database -- %s", optarg); break; case 'O': #ifdef DRIVER_OSS if(!strcmp(optarg,"oss")) cfg.output = oss; else #endif #ifdef DRIVER_NULL if(!strcmp(optarg,"null")) cfg.output = null; else #endif #ifdef DRIVER_DISK if(!strcmp(optarg,"disk")) { cfg.output = disk; cfg.endless = false; // endless output is almost never desired here } else #endif #ifdef DRIVER_ESOUND if(!strcmp(optarg,"esound")) cfg.output = esound; else #endif #ifdef DRIVER_QSA if(!strcmp(optarg,"qsa")) cfg.output = qsa; else #endif #ifdef DRIVER_ALSA if(!strcmp(optarg,"alsa")) cfg.output = alsa; else #endif #ifdef DRIVER_SDL if(!strcmp(optarg,"sdl")) cfg.output = sdl; else #endif #ifdef DRIVER_AO if(!strcmp(optarg,"ao")) cfg.output = ao; else #endif #ifdef DRIVER_RAW if(!strcmp(optarg,"raw")) { cfg.output = raw; cfg.endless = false; // endless output is almost never desired here } else #endif { message(MSG_ERROR, "unknown output method -- %s", optarg); exit(EXIT_FAILURE); } break; case 'e': if(!strcmp(optarg, "satoh")) cfg.emutype = Emu_Satoh; else if(!strcmp(optarg, "ken")) cfg.emutype = Emu_Ken; else if(!strcmp(optarg, "woody")) cfg.emutype = Emu_Woody; #ifdef HAVE_ADPLUG_NUKEDOPL else if(!strcmp(optarg, "nuked")) cfg.emutype = Emu_Nuked; #endif else { message(MSG_ERROR, "unknown emulator -- %s", optarg); exit(EXIT_FAILURE); } case 'q': if(cfg.message_level) cfg.message_level--; break; case 'v': cfg.message_level++; break; } } if (!cfg.loops) cfg.loops = 1; return optind; } static void play(const char *fn, Player *pl, int subsong = -1) /* * Start playback of subsong 'subsong' of file 'fn', using player * 'player'. If 'subsong' is not given or -1, start playback of * default subsong of file. */ { unsigned long i; unsigned long s = 0; unsigned long ls = 0; unsigned int loops = 0; // initialize output & player pl->get_opl()->init(); delete pl->p; pl->reset(); pl->p = CAdPlug::factory(fn,pl->get_opl()); if(!pl->p) { message(MSG_WARN, "unknown filetype -- %s", fn); return; } if(subsong != -1) pl->p->rewind(subsong); #ifdef HAVE_ADPLUG_GETSUBSONG else subsong = pl->p->getsubsong(); #endif fprintf(stderr, "Playing '%s'...\n" "Type : %s\n" "Title : %s\n" "Author: %s\n\n", fn, pl->p->gettype().c_str(), pl->p->gettitle().c_str(), pl->p->getauthor().c_str()); if(cfg.showinsts) { // display instruments fprintf(stderr, "Instrument names:\n"); for(i = 0;i < pl->p->getinstruments(); i++) fprintf(stderr, "%2lu: %s\n", i, pl->p->getinstrument(i).c_str()); fprintf(stderr, "\n"); } if(cfg.songmessage) // display song message fprintf(stderr, "Song message:\n%s\n\n", pl->p->getdesc().c_str()); // play loop do { if(cfg.songinfo) // display song info fprintf(stderr, "Subsong: %d/%d, Order: %d/%d, Pattern: %d/%d, Row: %d, " "Speed: %d, Timer: %.2fHz \r", subsong, pl->p->getsubsongs()-1, pl->p->getorder(), pl->p->getorders(), pl->p->getpattern(), pl->p->getpatterns(), pl->p->getrow(), pl->p->getspeed(), pl->p->getrefresh()); pl->frame(); ++s; if (!pl->playing) { if (!ls) ls = s; if (s == ls) { ++loops; s = 0; } } } while(cfg.endless || loops < cfg.loops); } static void shutdown(void) /* General deinitialization handler. */ { if(player) delete player; if(opl) delete opl; } static void sighandler(int signal) /* Handles all kinds of signals. */ { switch(signal) { case SIGINT: // Try to properly reposition terminal cursor, if Ctrl+C is used to exit. printf("\n\n"); case SIGTERM: exit(EXIT_SUCCESS); } } /***** Main program *****/ int main(int argc, char **argv) { int optind, i; const char *homedir; char *userdb = NULL; // init program_name = argv[0]; atexit(shutdown); signal(SIGINT, sighandler); signal(SIGTERM, sighandler); // Try user's home directory first, before trying the default location. homedir = getenv("HOME"); if(homedir) { userdb = (char *)malloc(strlen(homedir) + strlen(ADPLUG_CONFDIR) + strlen(ADPLUGDB_FILE) + 3); strcpy(userdb, homedir); strcat(userdb, "/" ADPLUG_CONFDIR "/"); strcat(userdb, ADPLUGDB_FILE); } // parse commandline optind = decode_switches(argc,argv); if(optind == argc) { // no filename given fprintf(stderr, "%s: need at least one file for playback\n", program_name); fprintf(stderr, "Try '%s --help' for more information.\n", program_name); if(userdb) free(userdb); exit(EXIT_FAILURE); } if(argc - optind > 1) cfg.endless = false; // more than 1 file given // init emulator switch(cfg.emutype) { case Emu_Satoh: if (cfg.harmonic) { #ifdef HAVE_ADPLUG_SURROUND COPLprops a, b; a.use16bit = b.use16bit = cfg.bits == 16; a.stereo = b.stereo = false; a.opl = new CEmuopl(cfg.freq, a.use16bit, a.stereo); b.opl = new CEmuopl(cfg.freq, b.use16bit, b.stereo); opl = new CSurroundopl(&a, &b, cfg.bits == 16); // CSurroundopl now owns a.opl and b.opl and will free upon destruction #else fprintf(stderr, "Surround requires AdPlug v2.2 or newer. Use --mono " "or upgrade and recompile AdPlay.\n"); if(userdb) free(userdb); exit(EXIT_FAILURE); #endif } else { opl = new CEmuopl(cfg.freq, cfg.bits == 16, cfg.channels == 2); } break; case Emu_Ken: if (cfg.harmonic) { #ifdef HAVE_ADPLUG_SURROUND #ifndef CKEMUOPL_MULTIINSTANCE fprintf(stderr, "%s: Sorry, Ken's emulator only supports one instance " "so does not work properly in surround mode in old versions of " "the adplug library.\n", program_name); #endif COPLprops a, b; a.use16bit = b.use16bit = cfg.bits == 16; a.stereo = b.stereo = false; a.opl = new CKemuopl(cfg.freq, a.use16bit, a.stereo); b.opl = new CKemuopl(cfg.freq, b.use16bit, b.stereo); opl = new CSurroundopl(&a, &b, cfg.bits == 16); // CSurroundopl now owns a and b and will free upon destruction #else fprintf(stderr, "Surround requires AdPlug v2.2 or newer. Use --mono " "or upgrade and recompile AdPlay.\n"); if(userdb) free(userdb); exit(EXIT_FAILURE); #endif } else { opl = new CKemuopl(cfg.freq, cfg.bits == 16, cfg.channels == 2); } break; case Emu_Woody: if (cfg.harmonic) { #ifdef HAVE_ADPLUG_SURROUND COPLprops a, b; a.use16bit = b.use16bit = cfg.bits == 16; a.stereo = b.stereo = false; a.opl = new CWemuopl(cfg.freq, a.use16bit, a.stereo); b.opl = new CWemuopl(cfg.freq, b.use16bit, b.stereo); opl = new CSurroundopl(&a, &b, cfg.bits == 16); // CSurroundopl now owns a and b and will free upon destruction #else fprintf(stderr, "Surround requires AdPlug v2.2 or newer. Use --mono " "or upgrade and recompile AdPlay.\n"); if(userdb) free(userdb); exit(EXIT_FAILURE); #endif } else { opl = new CWemuopl(cfg.freq, cfg.bits == 16, cfg.channels == 2); } break; #ifdef HAVE_ADPLUG_NUKEDOPL case Emu_Nuked: if (cfg.harmonic) { COPLprops a, b; a.use16bit = b.use16bit = true; // Nuked only supports 16-bit a.stereo = b.stereo = true; // Nuked only supports stereo a.opl = new CNemuopl(cfg.freq); b.opl = new CNemuopl(cfg.freq); opl = new CSurroundopl(&a, &b, cfg.bits == 16); // SurroundOPL can convert to 8-bit though // CSurroundopl now owns a and b and will free upon destruction } else { if(cfg.bits != 16 || cfg.channels != 2) { fprintf(stderr, "Sorry, Nuked OPL3 emulator only works in stereo 16 bits. " "Use --stereo and --16bit options.\n"); if(userdb) free(userdb); exit(EXIT_FAILURE); } else { opl = new CNemuopl(cfg.freq); } } break; #endif } // init player switch(cfg.output) { case none: message(MSG_PANIC, "no output methods compiled in"); exit(EXIT_FAILURE); #ifdef DRIVER_OSS case oss: player = new OSSPlayer(opl, cfg.device, cfg.bits, cfg.channels, cfg.freq, cfg.buf_size); break; #endif #ifdef DRIVER_NULL case null: player = new NullOutput(); break; #endif #ifdef DRIVER_DISK case disk: player = new DiskWriter(opl, cfg.device, cfg.bits, cfg.channels, cfg.freq); break; #endif #ifdef DRIVER_ESOUND case esound: player = new EsoundPlayer(opl, cfg.bits, cfg.channels, cfg.freq, cfg.device); break; #endif #ifdef DRIVER_QSA case qsa: player = new QSAPlayer(opl, cfg.bits, cfg.channels, cfg.freq); break; #endif #ifdef DRIVER_AO case ao: player = new AOPlayer(opl, cfg.device, cfg.bits, cfg.channels, cfg.freq, cfg.buf_size); break; #endif #ifdef DRIVER_SDL case sdl: player = new SDLPlayer(opl, cfg.bits, cfg.channels, cfg.freq, cfg.buf_size); break; #endif #ifdef DRIVER_ALSA case alsa: player = new ALSAPlayer(opl, cfg.device, cfg.bits, cfg.channels, cfg.freq, cfg.buf_size); break; #endif #ifdef DRIVER_RAW case raw: player = new DiskRawWriter(new CDiskopl(cfg.device)); break; #endif default: message(MSG_ERROR, "output method not available"); exit(EXIT_FAILURE); } // load database if(userdb) { mydb.load(userdb); free(userdb); } mydb.load(ADPLUGDB_PATH); CAdPlug::set_database(&mydb); // play all files from commandline for(i=optind;i * * 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, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "defines.h" #include "alsa.h" #define DEFAULT_DEVICE "default" // Default ALSA output device ALSAPlayer::ALSAPlayer(Copl *nopl, const char *device, unsigned char bits, int channels, int freq, unsigned long bufsize) : EmuPlayer(nopl, bits, channels, freq, bufsize) { snd_pcm_hw_params_t *hwparams; unsigned int nfreq = freq; unsigned long nbufsize; if(!device) device = DEFAULT_DEVICE; snd_pcm_hw_params_malloc(&hwparams); // Try to open audio device if(snd_pcm_open(&pcm_handle, device, SND_PCM_STREAM_PLAYBACK, 0) < 0) { message(MSG_ERROR, "error opening PCM device -- %s", device); exit(EXIT_FAILURE); } // Init hwparams with full configuration space if(snd_pcm_hw_params_any(pcm_handle, hwparams) < 0) { message(MSG_ERROR, "cannot configure this PCM device -- %s", device); exit(EXIT_FAILURE); } // Set access type if(snd_pcm_hw_params_set_access(pcm_handle, hwparams, SND_PCM_ACCESS_RW_INTERLEAVED) < 0) { message(MSG_ERROR, "error setting access type"); exit(EXIT_FAILURE); } // Set sample format if (snd_pcm_hw_params_set_format(pcm_handle, hwparams, bits == 16 ? SND_PCM_FORMAT_S16 : SND_PCM_FORMAT_U8) < 0) { message(MSG_ERROR, "error setting format"); exit(EXIT_FAILURE); } // Set sample rate (nearest possible) if(snd_pcm_hw_params_set_rate_near(pcm_handle, hwparams, &nfreq, 0) < 0) { message(MSG_ERROR, "error setting sample rate"); exit(EXIT_FAILURE); } if(nfreq != (unsigned int)freq) message(MSG_NOTE, "%d Hz sample rate not supported by your hardware, using " "%d Hz instead", freq, nfreq); // Set number of channels if(snd_pcm_hw_params_set_channels(pcm_handle, hwparams, channels) < 0) { message(MSG_ERROR, "error setting channels"); exit(EXIT_FAILURE); } // Set number of periods if(snd_pcm_hw_params_set_periods(pcm_handle, hwparams, 4, 0) < 0) { message(MSG_ERROR, "error setting periods"); exit(EXIT_FAILURE); } // Set the preferred buffer size (in samples) if(snd_pcm_hw_params_set_buffer_size(pcm_handle, hwparams, 4*bufsize / getsampsize()) < 0) { if (snd_pcm_hw_params_get_buffer_size(hwparams, &nbufsize) < 0) { message(MSG_ERROR, "error setting and getting buffer size"); exit(EXIT_FAILURE); } setbufsize(nbufsize); message(MSG_NOTE, "couldn't set buffersize to %ld, using default of %ld instead", bufsize, nbufsize); } // Apply HW parameter settings to PCM device and prepare device if(snd_pcm_hw_params(pcm_handle, hwparams) < 0) { message(MSG_ERROR, "error setting HW params"); exit(EXIT_FAILURE); } snd_pcm_hw_params_free(hwparams); } ALSAPlayer::~ALSAPlayer() { // stop playback immediately snd_pcm_drop(pcm_handle); snd_pcm_close(pcm_handle); } void ALSAPlayer::output(const void *buf, unsigned long size) { if(snd_pcm_writei(pcm_handle, buf, size / getsampsize()) < 0) snd_pcm_prepare(pcm_handle); } adplug-adplay-unix-5a5364e/src/alsa.h000066400000000000000000000023151512216033100174300ustar00rootroot00000000000000/* * AdPlay/UNIX - OPL2 audio player * Copyright (C) 2001 - 2003 Simon Peter * * 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, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef H_ALSA #define H_ALSA #define ALSA_PCM_NEW_HW_PARAMS_API #include #include "output.h" class ALSAPlayer: public EmuPlayer { public: ALSAPlayer(Copl *nopl, const char *device, unsigned char bits, int channels, int freq, unsigned long bufsize); virtual ~ALSAPlayer(); protected: virtual void output(const void *buf, unsigned long size); private: snd_pcm_t *pcm_handle; }; #endif adplug-adplay-unix-5a5364e/src/ao.cc000066400000000000000000000037151512216033100172520ustar00rootroot00000000000000/* * AdPlay/UNIX - OPL2 audio player * Copyright (C) 2001 - 2003, 2024 Simon Peter * * 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, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include #include #include #include #include #include #include #include "ao.h" AOPlayer::AOPlayer(Copl *nopl, const char *device, unsigned char bits, int channels, int freq, unsigned long bufsize) : EmuPlayer(nopl, bits, channels, freq, bufsize) { ao_sample_format format = {0}; int default_driver; ao_initialize(); default_driver = ao_default_driver_id(); format.bits = bits; format.channels = channels; format.rate = freq; format.byte_format = AO_FMT_NATIVE; aodevice = ao_open_live(default_driver, &format, NULL); } AOPlayer::~AOPlayer() { // We're skipping this here, even though we should call ao_close() // on exit. Unfortunately, the pulseaudio backend in ao has a race // condition where it fails if we call ao_close() while ao_play() is // running. This happens easily due to adplay's use of SIGINT to // exit and ao uses multiple threads for playback. // if(aodevice != NULL) { // ao_close(aodevice); // } // ao_shutdown(); } void AOPlayer::output(const void *buf, unsigned long size) { ao_play(aodevice, (char *)buf, (uint_32)size); } adplug-adplay-unix-5a5364e/src/ao.h000066400000000000000000000022331512216033100171060ustar00rootroot00000000000000/* * AdPlay/UNIX - OPL2 audio player * Copyright (C) 2001 - 2003, 2024 Simon Peter * * 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, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef H_AO_ #define H_AO_ #include #include "output.h" class AOPlayer: public EmuPlayer { public: AOPlayer(Copl *nopl, const char *device, unsigned char bits, int channels, int freq, unsigned long bufsize); virtual ~AOPlayer(); protected: virtual void output(const void *buf, unsigned long size); private: ao_device *aodevice; }; #endif adplug-adplay-unix-5a5364e/src/defines.h000066400000000000000000000024451512216033100201310ustar00rootroot00000000000000/* * AdPlay/UNIX - OPL2 audio player * Copyright (C) 2001, 2002 Simon Peter * * 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, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef H_DEFINES #define H_DEFINES #include "config.h" /***** Defines *****/ // AdPlay/UNIX version string #define ADPLAY_VERSION "AdPlay/UNIX " VERSION // Message urgency levels #define MSG_PANIC 0 // Unmaskable #define MSG_ERROR 1 #define MSG_WARN 2 #define MSG_NOTE 3 #define MSG_DEBUG 4 #ifndef MIN # define MIN(a,b) (((a) < (b)) ? (a) : (b)) #endif #ifndef MAX # define MAX(a,b) (((a) > (b)) ? (a) : (b)) #endif /***** Global functions *****/ void message(int level, const char *fmt, ...); #endif adplug-adplay-unix-5a5364e/src/disk.cc000066400000000000000000000053301512216033100176000ustar00rootroot00000000000000/* * AdPlay/UNIX - OPL2 audio player * Copyright (C) 2001 - 2003 Simon Peter * * 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, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include #include #include #include #include #include #include "defines.h" #include "disk.h" #define BUFSIZE 512 DiskWriter::DiskWriter(Copl *nopl, const char *filename, unsigned char nbits, unsigned char nchannels, unsigned long nfreq) : EmuPlayer(nopl, nbits, nchannels, nfreq, BUFSIZE), f(0), samplesize(0) { if(!filename) { message(MSG_ERROR, "no output filename specified"); exit(EXIT_FAILURE); } // If filename is '-', output to stdout if(strcmp(filename, "-")) f = new binofstream(filename); else f = new binowstream(&std::cout); // not very good to mix cout with stdout if(!f || f->error()) { message(MSG_ERROR, "cannot open file for output -- %s", filename); if(f) delete f; exit(EXIT_FAILURE); } f->setFlag(binio::BigEndian, false); // Write Microsoft RIFF WAVE header f->writeString("RIFF", 4); f->writeInt(36, 4); f->writeString("WAVEfmt ", 8); f->writeInt(16, 4); f->writeInt(1, 2); f->writeInt(nchannels, 2); f->writeInt(nfreq, 4); f->writeInt(nfreq * getsampsize(), 4); f->writeInt(getsampsize(), 2); f->writeInt(nbits, 2); f->writeString("data", 4); f->writeInt(0, 4); } DiskWriter::~DiskWriter() { if(!f) return; if(samplesize % 2) { // Wave data must end on an even byte boundary f->writeInt(0, 1); samplesize++; } // Write file sizes f->seek(40); f->writeInt(samplesize, 4); samplesize += 36; // make absolute filesize (add header size) f->seek(4); f->writeInt(samplesize, 4); // end disk writing delete f; } void DiskWriter::output(const void *buf, unsigned long size) { char *b = (char *)buf; unsigned long i, ssize = getsampsize(); for(i = 0; i < size; i += ssize) switch(ssize) { case 1: f->writeInt(*(b + i), 1); break; case 2: f->writeInt(*(short *)(b + i), 2); break; case 4: f->writeInt(*(long *)(b + i), 4); break; } samplesize += size; } adplug-adplay-unix-5a5364e/src/disk.h000066400000000000000000000022651512216033100174460ustar00rootroot00000000000000/* * AdPlay/UNIX - OPL2 audio player * Copyright (C) 2001, 2002 Simon Peter * * 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, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef H_DISK #define H_DISK #include #include "output.h" class DiskWriter: public EmuPlayer { public: DiskWriter(Copl *nopl, const char *filename, unsigned char nbits, unsigned char nchannels, unsigned long nfreq); virtual ~DiskWriter(); protected: virtual void output(const void *buf, unsigned long size); private: binostream *f; unsigned long samplesize; }; #endif adplug-adplay-unix-5a5364e/src/diskraw.h000066400000000000000000000022021512216033100201470ustar00rootroot00000000000000/* * AdPlay/UNIX - OPL2 audio player * Copyright (C) 2001, 2002 Simon Peter * * 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, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef H_DISKRAW #define H_DISKRAW #include "output.h" /* pairs up to AdPlay CDiskopl */ class DiskRawWriter: public Player { public: DiskRawWriter(CDiskopl *nopl) :opl(nopl) { } virtual void frame() { playing = p->update(); opl->update(p); } virtual Copl *get_opl() { return opl; } private: CDiskopl *opl; }; #endif adplug-adplay-unix-5a5364e/src/esound.cc000066400000000000000000000027341512216033100201500ustar00rootroot00000000000000/* * AdPlay/UNIX - OPL2 audio player * Copyright (C) 2001, 2002 Simon Peter * * 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, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include #include #include #include "defines.h" #include "esound.h" EsoundPlayer::EsoundPlayer(Copl *nopl, unsigned char bits, int channels, int freq, const char *url) : EmuPlayer(nopl, bits, channels, freq, ESD_BUF_SIZE) { socket = esd_play_stream((bits == 16 ? ESD_BITS16 : ESD_BITS8) | (channels == 2 ? ESD_STEREO : ESD_MONO) | ESD_STREAM | ESD_PLAY, freq, url, ADPLAY_VERSION); // on error, just exit here. esd_play_stream() does perror() already... if(socket < 0) exit(EXIT_FAILURE); } EsoundPlayer::~EsoundPlayer() { close(socket); } void EsoundPlayer::output(const void *buf, unsigned long size) { write(socket, buf, size); } adplug-adplay-unix-5a5364e/src/esound.h000066400000000000000000000021661512216033100200110ustar00rootroot00000000000000/* * AdPlay/UNIX - OPL2 audio player * Copyright (C) 2001, 2002 Simon Peter * * 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, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef H_ESOUND #define H_ESOUND #include "output.h" class EsoundPlayer: public EmuPlayer { public: EsoundPlayer(Copl *nopl, unsigned char bits, int channels, int freq, const char *url = 0); virtual ~EsoundPlayer(); protected: virtual void output(const void *buf, unsigned long size); private: int socket; }; #endif adplug-adplay-unix-5a5364e/src/getopt.c000066400000000000000000000730041512216033100200100ustar00rootroot00000000000000/* Getopt for GNU. NOTE: getopt is now part of the C library, so if you don't know what "Keep this file name-space clean" means, talk to drepper@gnu.org before changing it! Copyright (C) 1987, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 2000 Free Software Foundation, Inc. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. The GNU C Library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with the GNU C Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* This tells Alpha OSF/1 not to define a getopt prototype in . Ditto for AIX 3.2 and . */ #ifndef _NO_PROTO # define _NO_PROTO #endif #ifdef HAVE_CONFIG_H # include #endif #if !defined __STDC__ || !__STDC__ /* This is a separate conditional since some stdc systems reject `defined (const)'. */ # ifndef const # define const # endif #endif #include /* Comment out all this code if we are using the GNU C Library, and are not actually compiling the library itself. This code is part of the GNU C Library, but also included in many other GNU distributions. Compiling and linking in this code is a waste when using the GNU C library (especially if it is a shared library). Rather than having every GNU program understand `configure --with-gnu-libc' and omit the object files, it is simpler to just do this in the source for each such file. */ #define GETOPT_INTERFACE_VERSION 2 #if !defined _LIBC && defined __GLIBC__ && __GLIBC__ >= 2 # include # if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION # define ELIDE_CODE # endif #endif #ifndef ELIDE_CODE /* This needs to come after some library #include to get __GNU_LIBRARY__ defined. */ #ifdef __GNU_LIBRARY__ /* Don't include stdlib.h for non-GNU C libraries because some of them contain conflicting prototypes for getopt. */ # include # include #endif /* GNU C library. */ #ifdef VMS # include # if HAVE_STRING_H - 0 # include # endif #endif #ifndef _ /* This is for other GNU distributions with internationalized messages. When compiling libc, the _ macro is predefined. */ # ifdef HAVE_LIBINTL_H # include # define _(msgid) gettext (msgid) # else # define _(msgid) (msgid) # endif #endif /* This version of `getopt' appears to the caller like standard Unix `getopt' but it behaves differently for the user, since it allows the user to intersperse the options with the other arguments. As `getopt' works, it permutes the elements of ARGV so that, when it is done, all the options precede everything else. Thus all application programs are extended to handle flexible argument order. Setting the environment variable POSIXLY_CORRECT disables permutation. Then the behavior is completely standard. GNU application programs can use a third alternative mode in which they can distinguish the relative order of options and other arguments. */ #include "getopt.h" /* For communication from `getopt' to the caller. When `getopt' finds an option that takes an argument, the argument value is returned here. Also, when `ordering' is RETURN_IN_ORDER, each non-option ARGV-element is returned here. */ char *optarg; /* Index in ARGV of the next element to be scanned. This is used for communication to and from the caller and for communication between successive calls to `getopt'. On entry to `getopt', zero means this is the first call; initialize. When `getopt' returns -1, this is the index of the first of the non-option elements that the caller should itself scan. Otherwise, `optind' communicates from one call to the next how much of ARGV has been scanned so far. */ /* 1003.2 says this must be 1 before any call. */ int optind = 1; /* Formerly, initialization of getopt depended on optind==0, which causes problems with re-calling getopt as programs generally don't know that. */ int __getopt_initialized; /* The next char to be scanned in the option-element in which the last option character we returned was found. This allows us to pick up the scan where we left off. If this is zero, or a null string, it means resume the scan by advancing to the next ARGV-element. */ static char *nextchar; /* Callers store zero here to inhibit the error message for unrecognized options. */ int opterr = 1; /* Set to an option character which was unrecognized. This must be initialized on some systems to avoid linking in the system's own getopt implementation. */ int optopt = '?'; /* Describe how to deal with options that follow non-option ARGV-elements. If the caller did not specify anything, the default is REQUIRE_ORDER if the environment variable POSIXLY_CORRECT is defined, PERMUTE otherwise. REQUIRE_ORDER means don't recognize them as options; stop option processing when the first non-option is seen. This is what Unix does. This mode of operation is selected by either setting the environment variable POSIXLY_CORRECT, or using `+' as the first character of the list of option characters. PERMUTE is the default. We permute the contents of ARGV as we scan, so that eventually all the non-options are at the end. This allows options to be given in any order, even with programs that were not written to expect this. RETURN_IN_ORDER is an option available to programs that were written to expect options and other ARGV-elements in any order and that care about the ordering of the two. We describe each non-option ARGV-element as if it were the argument of an option with character code 1. Using `-' as the first character of the list of option characters selects this mode of operation. The special argument `--' forces an end of option-scanning regardless of the value of `ordering'. In the case of RETURN_IN_ORDER, only `--' can cause `getopt' to return -1 with `optind' != ARGC. */ static enum { REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER } ordering; /* Value of POSIXLY_CORRECT environment variable. */ static char *posixly_correct; #ifdef __GNU_LIBRARY__ /* We want to avoid inclusion of string.h with non-GNU libraries because there are many ways it can cause trouble. On some systems, it contains special magic macros that don't work in GCC. */ # include # define my_index strchr #else # if HAVE_STRING_H # include # else # include # endif /* Avoid depending on library functions or files whose names are inconsistent. */ #ifndef getenv extern char *getenv (); #endif static char * my_index (str, chr) const char *str; int chr; { while (*str) { if (*str == chr) return (char *) str; str++; } return 0; } /* If using GCC, we can safely declare strlen this way. If not using GCC, it is ok not to declare it. */ #ifdef __GNUC__ /* Note that Motorola Delta 68k R3V7 comes with GCC but not stddef.h. That was relevant to code that was here before. */ # if (!defined __STDC__ || !__STDC__) && !defined strlen /* gcc with -traditional declares the built-in strlen to return int, and has done so at least since version 2.4.5. -- rms. */ extern int strlen (const char *); # endif /* not __STDC__ */ #endif /* __GNUC__ */ #endif /* not __GNU_LIBRARY__ */ /* Handle permutation of arguments. */ /* Describe the part of ARGV that contains non-options that have been skipped. `first_nonopt' is the index in ARGV of the first of them; `last_nonopt' is the index after the last of them. */ static int first_nonopt; static int last_nonopt; #ifdef _LIBC /* Bash 2.0 gives us an environment variable containing flags indicating ARGV elements that should not be considered arguments. */ /* Defined in getopt_init.c */ extern char *__getopt_nonoption_flags; static int nonoption_flags_max_len; static int nonoption_flags_len; static int original_argc; static char *const *original_argv; /* Make sure the environment variable bash 2.0 puts in the environment is valid for the getopt call we must make sure that the ARGV passed to getopt is that one passed to the process. */ static void __attribute__ ((unused)) store_args_and_env (int argc, char *const *argv) { /* XXX This is no good solution. We should rather copy the args so that we can compare them later. But we must not use malloc(3). */ original_argc = argc; original_argv = argv; } # ifdef text_set_element text_set_element (__libc_subinit, store_args_and_env); # endif /* text_set_element */ # define SWAP_FLAGS(ch1, ch2) \ if (nonoption_flags_len > 0) \ { \ char __tmp = __getopt_nonoption_flags[ch1]; \ __getopt_nonoption_flags[ch1] = __getopt_nonoption_flags[ch2]; \ __getopt_nonoption_flags[ch2] = __tmp; \ } #else /* !_LIBC */ # define SWAP_FLAGS(ch1, ch2) #endif /* _LIBC */ /* Exchange two adjacent subsequences of ARGV. One subsequence is elements [first_nonopt,last_nonopt) which contains all the non-options that have been skipped so far. The other is elements [last_nonopt,optind), which contains all the options processed since those non-options were skipped. `first_nonopt' and `last_nonopt' are relocated so that they describe the new indices of the non-options in ARGV after they are moved. */ #if defined __STDC__ && __STDC__ static void exchange (char **); #endif static void exchange (argv) char **argv; { int bottom = first_nonopt; int middle = last_nonopt; int top = optind; char *tem; /* Exchange the shorter segment with the far end of the longer segment. That puts the shorter segment into the right place. It leaves the longer segment in the right place overall, but it consists of two parts that need to be swapped next. */ #ifdef _LIBC /* First make sure the handling of the `__getopt_nonoption_flags' string can work normally. Our top argument must be in the range of the string. */ if (nonoption_flags_len > 0 && top >= nonoption_flags_max_len) { /* We must extend the array. The user plays games with us and presents new arguments. */ char *new_str = malloc (top + 1); if (new_str == NULL) nonoption_flags_len = nonoption_flags_max_len = 0; else { memset (__mempcpy (new_str, __getopt_nonoption_flags, nonoption_flags_max_len), '\0', top + 1 - nonoption_flags_max_len); nonoption_flags_max_len = top + 1; __getopt_nonoption_flags = new_str; } } #endif while (top > middle && middle > bottom) { if (top - middle > middle - bottom) { /* Bottom segment is the short one. */ int len = middle - bottom; register int i; /* Swap it with the top part of the top segment. */ for (i = 0; i < len; i++) { tem = argv[bottom + i]; argv[bottom + i] = argv[top - (middle - bottom) + i]; argv[top - (middle - bottom) + i] = tem; SWAP_FLAGS (bottom + i, top - (middle - bottom) + i); } /* Exclude the moved bottom segment from further swapping. */ top -= len; } else { /* Top segment is the short one. */ int len = top - middle; register int i; /* Swap it with the bottom part of the bottom segment. */ for (i = 0; i < len; i++) { tem = argv[bottom + i]; argv[bottom + i] = argv[middle + i]; argv[middle + i] = tem; SWAP_FLAGS (bottom + i, middle + i); } /* Exclude the moved top segment from further swapping. */ bottom += len; } } /* Update records for the slots the non-options now occupy. */ first_nonopt += (optind - last_nonopt); last_nonopt = optind; } /* Initialize the internal data when the first call is made. */ #if defined __STDC__ && __STDC__ static const char *_getopt_initialize (int, char *const *, const char *); #endif static const char * _getopt_initialize (argc, argv, optstring) int argc; char *const *argv; const char *optstring; { /* Start processing options with ARGV-element 1 (since ARGV-element 0 is the program name); the sequence of previously skipped non-option ARGV-elements is empty. */ first_nonopt = last_nonopt = optind; nextchar = NULL; posixly_correct = getenv ("POSIXLY_CORRECT"); /* Determine how to handle the ordering of options and nonoptions. */ if (optstring[0] == '-') { ordering = RETURN_IN_ORDER; ++optstring; } else if (optstring[0] == '+') { ordering = REQUIRE_ORDER; ++optstring; } else if (posixly_correct != NULL) ordering = REQUIRE_ORDER; else ordering = PERMUTE; #ifdef _LIBC if (posixly_correct == NULL && argc == original_argc && argv == original_argv) { if (nonoption_flags_max_len == 0) { if (__getopt_nonoption_flags == NULL || __getopt_nonoption_flags[0] == '\0') nonoption_flags_max_len = -1; else { const char *orig_str = __getopt_nonoption_flags; int len = nonoption_flags_max_len = strlen (orig_str); if (nonoption_flags_max_len < argc) nonoption_flags_max_len = argc; __getopt_nonoption_flags = (char *) malloc (nonoption_flags_max_len); if (__getopt_nonoption_flags == NULL) nonoption_flags_max_len = -1; else memset (__mempcpy (__getopt_nonoption_flags, orig_str, len), '\0', nonoption_flags_max_len - len); } } nonoption_flags_len = nonoption_flags_max_len; } else nonoption_flags_len = 0; #endif return optstring; } /* Scan elements of ARGV (whose length is ARGC) for option characters given in OPTSTRING. If an element of ARGV starts with '-', and is not exactly "-" or "--", then it is an option element. The characters of this element (aside from the initial '-') are option characters. If `getopt' is called repeatedly, it returns successively each of the option characters from each of the option elements. If `getopt' finds another option character, it returns that character, updating `optind' and `nextchar' so that the next call to `getopt' can resume the scan with the following option character or ARGV-element. If there are no more option characters, `getopt' returns -1. Then `optind' is the index in ARGV of the first ARGV-element that is not an option. (The ARGV-elements have been permuted so that those that are not options now come last.) OPTSTRING is a string containing the legitimate option characters. If an option character is seen that is not listed in OPTSTRING, return '?' after printing an error message. If you set `opterr' to zero, the error message is suppressed but we still return '?'. If a char in OPTSTRING is followed by a colon, that means it wants an arg, so the following text in the same ARGV-element, or the text of the following ARGV-element, is returned in `optarg'. Two colons mean an option that wants an optional arg; if there is text in the current ARGV-element, it is returned in `optarg', otherwise `optarg' is set to zero. If OPTSTRING starts with `-' or `+', it requests different methods of handling the non-option ARGV-elements. See the comments about RETURN_IN_ORDER and REQUIRE_ORDER, above. Long-named options begin with `--' instead of `-'. Their names may be abbreviated as long as the abbreviation is unique or is an exact match for some defined option. If they have an argument, it follows the option name in the same ARGV-element, separated from the option name by a `=', or else the in next ARGV-element. When `getopt' finds a long-named option, it returns 0 if that option's `flag' field is nonzero, the value of the option's `val' field if the `flag' field is zero. The elements of ARGV aren't really const, because we permute them. But we pretend they're const in the prototype to be compatible with other systems. LONGOPTS is a vector of `struct option' terminated by an element containing a name which is zero. LONGIND returns the index in LONGOPT of the long-named option found. It is only valid when a long-named option has been found by the most recent call. If LONG_ONLY is nonzero, '-' as well as '--' can introduce long-named options. */ int _getopt_internal (argc, argv, optstring, longopts, longind, long_only) int argc; char *const *argv; const char *optstring; const struct option *longopts; int *longind; int long_only; { int print_errors = opterr; if (optstring[0] == ':') print_errors = 0; optarg = NULL; if (optind == 0 || !__getopt_initialized) { if (optind == 0) optind = 1; /* Don't scan ARGV[0], the program name. */ optstring = _getopt_initialize (argc, argv, optstring); __getopt_initialized = 1; } /* Test whether ARGV[optind] points to a non-option argument. Either it does not have option syntax, or there is an environment flag from the shell indicating it is not an option. The later information is only used when the used in the GNU libc. */ #ifdef _LIBC # define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0' \ || (optind < nonoption_flags_len \ && __getopt_nonoption_flags[optind] == '1')) #else # define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0') #endif if (nextchar == NULL || *nextchar == '\0') { /* Advance to the next ARGV-element. */ /* Give FIRST_NONOPT & LAST_NONOPT rational values if OPTIND has been moved back by the user (who may also have changed the arguments). */ if (last_nonopt > optind) last_nonopt = optind; if (first_nonopt > optind) first_nonopt = optind; if (ordering == PERMUTE) { /* If we have just processed some options following some non-options, exchange them so that the options come first. */ if (first_nonopt != last_nonopt && last_nonopt != optind) exchange ((char **) argv); else if (last_nonopt != optind) first_nonopt = optind; /* Skip any additional non-options and extend the range of non-options previously skipped. */ while (optind < argc && NONOPTION_P) optind++; last_nonopt = optind; } /* The special ARGV-element `--' means premature end of options. Skip it like a null option, then exchange with previous non-options as if it were an option, then skip everything else like a non-option. */ if (optind != argc && !strcmp (argv[optind], "--")) { optind++; if (first_nonopt != last_nonopt && last_nonopt != optind) exchange ((char **) argv); else if (first_nonopt == last_nonopt) first_nonopt = optind; last_nonopt = argc; optind = argc; } /* If we have done all the ARGV-elements, stop the scan and back over any non-options that we skipped and permuted. */ if (optind == argc) { /* Set the next-arg-index to point at the non-options that we previously skipped, so the caller will digest them. */ if (first_nonopt != last_nonopt) optind = first_nonopt; return -1; } /* If we have come to a non-option and did not permute it, either stop the scan or describe it to the caller and pass it by. */ if (NONOPTION_P) { if (ordering == REQUIRE_ORDER) return -1; optarg = argv[optind++]; return 1; } /* We have found another option-ARGV-element. Skip the initial punctuation. */ nextchar = (argv[optind] + 1 + (longopts != NULL && argv[optind][1] == '-')); } /* Decode the current option-ARGV-element. */ /* Check whether the ARGV-element is a long option. If long_only and the ARGV-element has the form "-f", where f is a valid short option, don't consider it an abbreviated form of a long option that starts with f. Otherwise there would be no way to give the -f short option. On the other hand, if there's a long option "fubar" and the ARGV-element is "-fu", do consider that an abbreviation of the long option, just like "--fu", and not "-f" with arg "u". This distinction seems to be the most useful approach. */ if (longopts != NULL && (argv[optind][1] == '-' || (long_only && (argv[optind][2] || !my_index (optstring, argv[optind][1]))))) { char *nameend; const struct option *p; const struct option *pfound = NULL; int exact = 0; int ambig = 0; int indfound = -1; int option_index; for (nameend = nextchar; *nameend && *nameend != '='; nameend++) /* Do nothing. */ ; /* Test all long options for either exact match or abbreviated matches. */ for (p = longopts, option_index = 0; p->name; p++, option_index++) if (!strncmp (p->name, nextchar, nameend - nextchar)) { if ((unsigned int) (nameend - nextchar) == (unsigned int) strlen (p->name)) { /* Exact match found. */ pfound = p; indfound = option_index; exact = 1; break; } else if (pfound == NULL) { /* First nonexact match found. */ pfound = p; indfound = option_index; } else /* Second or later nonexact match found. */ ambig = 1; } if (ambig && !exact) { if (print_errors) fprintf (stderr, _("%s: option `%s' is ambiguous\n"), argv[0], argv[optind]); nextchar += strlen (nextchar); optind++; optopt = 0; return '?'; } if (pfound != NULL) { option_index = indfound; optind++; if (*nameend) { /* Don't test has_arg with >, because some C compilers don't allow it to be used on enums. */ if (pfound->has_arg) optarg = nameend + 1; else { if (print_errors) { if (argv[optind - 1][1] == '-') /* --option */ fprintf (stderr, _("%s: option `--%s' doesn't allow an argument\n"), argv[0], pfound->name); else /* +option or -option */ fprintf (stderr, _("%s: option `%c%s' doesn't allow an argument\n"), argv[0], argv[optind - 1][0], pfound->name); } nextchar += strlen (nextchar); optopt = pfound->val; return '?'; } } else if (pfound->has_arg == 1) { if (optind < argc) optarg = argv[optind++]; else { if (print_errors) fprintf (stderr, _("%s: option `%s' requires an argument\n"), argv[0], argv[optind - 1]); nextchar += strlen (nextchar); optopt = pfound->val; return optstring[0] == ':' ? ':' : '?'; } } nextchar += strlen (nextchar); if (longind != NULL) *longind = option_index; if (pfound->flag) { *(pfound->flag) = pfound->val; return 0; } return pfound->val; } /* Can't find it as a long option. If this is not getopt_long_only, or the option starts with '--' or is not a valid short option, then it's an error. Otherwise interpret it as a short option. */ if (!long_only || argv[optind][1] == '-' || my_index (optstring, *nextchar) == NULL) { if (print_errors) { if (argv[optind][1] == '-') /* --option */ fprintf (stderr, _("%s: unrecognized option `--%s'\n"), argv[0], nextchar); else /* +option or -option */ fprintf (stderr, _("%s: unrecognized option `%c%s'\n"), argv[0], argv[optind][0], nextchar); } nextchar = (char *) ""; optind++; optopt = 0; return '?'; } } /* Look at and handle the next short option-character. */ { char c = *nextchar++; char *temp = my_index (optstring, c); /* Increment `optind' when we start to process its last character. */ if (*nextchar == '\0') ++optind; if (temp == NULL || c == ':') { if (print_errors) { if (posixly_correct) /* 1003.2 specifies the format of this message. */ fprintf (stderr, _("%s: illegal option -- %c\n"), argv[0], c); else fprintf (stderr, _("%s: invalid option -- %c\n"), argv[0], c); } optopt = c; return '?'; } /* Convenience. Treat POSIX -W foo same as long option --foo */ if (temp[0] == 'W' && temp[1] == ';') { char *nameend; const struct option *p; const struct option *pfound = NULL; int exact = 0; int ambig = 0; int indfound = 0; int option_index; /* This is an option that requires an argument. */ if (*nextchar != '\0') { optarg = nextchar; /* If we end this ARGV-element by taking the rest as an arg, we must advance to the next element now. */ optind++; } else if (optind == argc) { if (print_errors) { /* 1003.2 specifies the format of this message. */ fprintf (stderr, _("%s: option requires an argument -- %c\n"), argv[0], c); } optopt = c; if (optstring[0] == ':') c = ':'; else c = '?'; return c; } else /* We already incremented `optind' once; increment it again when taking next ARGV-elt as argument. */ optarg = argv[optind++]; /* optarg is now the argument, see if it's in the table of longopts. */ for (nextchar = nameend = optarg; *nameend && *nameend != '='; nameend++) /* Do nothing. */ ; /* Test all long options for either exact match or abbreviated matches. */ for (p = longopts, option_index = 0; p->name; p++, option_index++) if (!strncmp (p->name, nextchar, nameend - nextchar)) { if ((unsigned int) (nameend - nextchar) == strlen (p->name)) { /* Exact match found. */ pfound = p; indfound = option_index; exact = 1; break; } else if (pfound == NULL) { /* First nonexact match found. */ pfound = p; indfound = option_index; } else /* Second or later nonexact match found. */ ambig = 1; } if (ambig && !exact) { if (print_errors) fprintf (stderr, _("%s: option `-W %s' is ambiguous\n"), argv[0], argv[optind]); nextchar += strlen (nextchar); optind++; return '?'; } if (pfound != NULL) { option_index = indfound; if (*nameend) { /* Don't test has_arg with >, because some C compilers don't allow it to be used on enums. */ if (pfound->has_arg) optarg = nameend + 1; else { if (print_errors) fprintf (stderr, _("\ %s: option `-W %s' doesn't allow an argument\n"), argv[0], pfound->name); nextchar += strlen (nextchar); return '?'; } } else if (pfound->has_arg == 1) { if (optind < argc) optarg = argv[optind++]; else { if (print_errors) fprintf (stderr, _("%s: option `%s' requires an argument\n"), argv[0], argv[optind - 1]); nextchar += strlen (nextchar); return optstring[0] == ':' ? ':' : '?'; } } nextchar += strlen (nextchar); if (longind != NULL) *longind = option_index; if (pfound->flag) { *(pfound->flag) = pfound->val; return 0; } return pfound->val; } nextchar = NULL; return 'W'; /* Let the application handle it. */ } if (temp[1] == ':') { if (temp[2] == ':') { /* This is an option that accepts an argument optionally. */ if (*nextchar != '\0') { optarg = nextchar; optind++; } else optarg = NULL; nextchar = NULL; } else { /* This is an option that requires an argument. */ if (*nextchar != '\0') { optarg = nextchar; /* If we end this ARGV-element by taking the rest as an arg, we must advance to the next element now. */ optind++; } else if (optind == argc) { if (print_errors) { /* 1003.2 specifies the format of this message. */ fprintf (stderr, _("%s: option requires an argument -- %c\n"), argv[0], c); } optopt = c; if (optstring[0] == ':') c = ':'; else c = '?'; } else /* We already incremented `optind' once; increment it again when taking next ARGV-elt as argument. */ optarg = argv[optind++]; nextchar = NULL; } } return c; } } int getopt (argc, argv, optstring) int argc; char *const *argv; const char *optstring; { return _getopt_internal (argc, argv, optstring, (const struct option *) 0, (int *) 0, 0); } #endif /* Not ELIDE_CODE. */ #ifdef TEST /* Compile with -DTEST to make an executable for use in testing the above definition of `getopt'. */ int main (argc, argv) int argc; char **argv; { int c; int digit_optind = 0; while (1) { int this_option_optind = optind ? optind : 1; c = getopt (argc, argv, "abc:d:0123456789"); if (c == -1) break; switch (c) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': if (digit_optind != 0 && digit_optind != this_option_optind) printf ("digits occur in two different argv-elements.\n"); digit_optind = this_option_optind; printf ("option %c\n", c); break; case 'a': printf ("option a\n"); break; case 'b': printf ("option b\n"); break; case 'c': printf ("option c with value `%s'\n", optarg); break; case '?': break; default: printf ("?? getopt returned character code 0%o ??\n", c); } } if (optind < argc) { printf ("non-option ARGV-elements: "); while (optind < argc) printf ("%s ", argv[optind++]); printf ("\n"); } exit (0); } #endif /* TEST */ adplug-adplay-unix-5a5364e/src/getopt.h000066400000000000000000000134551512216033100200210ustar00rootroot00000000000000/* Declarations for getopt. Copyright (C) 1989,90,91,92,93,94,96,97,98 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. The GNU C Library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with the GNU C Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef _GETOPT_H #ifndef __need_getopt # define _GETOPT_H 1 #endif #ifdef __cplusplus extern "C" { #endif // in mingw, __argc and __argv are special #undef __argc #undef __argv /* For communication from `getopt' to the caller. When `getopt' finds an option that takes an argument, the argument value is returned here. Also, when `ordering' is RETURN_IN_ORDER, each non-option ARGV-element is returned here. */ extern char *optarg; /* Index in ARGV of the next element to be scanned. This is used for communication to and from the caller and for communication between successive calls to `getopt'. On entry to `getopt', zero means this is the first call; initialize. When `getopt' returns -1, this is the index of the first of the non-option elements that the caller should itself scan. Otherwise, `optind' communicates from one call to the next how much of ARGV has been scanned so far. */ extern int optind; /* Callers store zero here to inhibit the error message `getopt' prints for unrecognized options. */ extern int opterr; /* Set to an option character which was unrecognized. */ extern int optopt; #ifndef __need_getopt /* Describe the long-named options requested by the application. The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector of `struct option' terminated by an element containing a name which is zero. The field `has_arg' is: no_argument (or 0) if the option does not take an argument, required_argument (or 1) if the option requires an argument, optional_argument (or 2) if the option takes an optional argument. If the field `flag' is not NULL, it points to a variable that is set to the value given in the field `val' when the option is found, but left unchanged if the option is not found. To have a long-named option do something other than set an `int' to a compiled-in constant, such as set a value from `optarg', set the option's `flag' field to zero and its `val' field to a nonzero value (the equivalent single-letter option character, if there is one). For long options that have a zero `flag' field, `getopt' returns the contents of the `val' field. */ struct option { # if defined __STDC__ && __STDC__ const char *name; # else char *name; # endif /* has_arg can't be an enum because some compilers complain about type mismatches in all the code that assumes it is an int. */ int has_arg; int *flag; int val; }; /* Names for the values of the `has_arg' field of `struct option'. */ # define no_argument 0 # define required_argument 1 # define optional_argument 2 #endif /* need getopt */ /* Get definitions and prototypes for functions to process the arguments in ARGV (ARGC of them, minus the program name) for options given in OPTS. Return the option character from OPTS just read. Return -1 when there are no more options. For unrecognized options, or options missing arguments, `optopt' is set to the option letter, and '?' is returned. The OPTS string is a list of characters which are recognized option letters, optionally followed by colons, specifying that that letter takes an argument, to be placed in `optarg'. If a letter in OPTS is followed by two colons, its argument is optional. This behavior is specific to the GNU `getopt'. The argument `--' causes premature termination of argument scanning, explicitly telling `getopt' that there are no more options. If OPTS begins with `--', then non-option arguments are treated as arguments to the option '\0'. This behavior is specific to the GNU `getopt'. */ #if defined __STDC__ && __STDC__ # ifdef __GNU_LIBRARY__ /* Many other libraries have conflicting prototypes for getopt, with differences in the consts, in stdlib.h. To avoid compilation errors, only prototype getopt for the GNU C library. */ extern int getopt (int __argc, char *const *__argv, const char *__shortopts); # else /* not __GNU_LIBRARY__ */ extern int getopt (); # endif /* __GNU_LIBRARY__ */ # ifndef __need_getopt extern int getopt_long (int __argc, char *const *__argv, const char *__shortopts, const struct option *__longopts, int *__longind); extern int getopt_long_only (int __argc, char *const *__argv, const char *__shortopts, const struct option *__longopts, int *__longind); /* Internal only. Users should not call this directly. */ extern int _getopt_internal (int __argc, char *const *__argv, const char *__shortopts, const struct option *__longopts, int *__longind, int __long_only); # endif #else /* not __STDC__ */ extern int getopt (); # ifndef __need_getopt extern int getopt_long (); extern int getopt_long_only (); extern int _getopt_internal (); # endif #endif /* __STDC__ */ #ifdef __cplusplus } #endif /* Make sure we later can get all the definitions and declarations. */ #undef __need_getopt #endif /* getopt.h */ adplug-adplay-unix-5a5364e/src/getopt1.c000066400000000000000000000107061512216033100200710ustar00rootroot00000000000000/* getopt_long and getopt_long_only entry points for GNU getopt. Copyright (C) 1987,88,89,90,91,92,93,94,96,97,98 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. The GNU C Library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with the GNU C Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifdef HAVE_CONFIG_H #include #endif #include "getopt.h" #if !defined __STDC__ || !__STDC__ /* This is a separate conditional since some stdc systems reject `defined (const)'. */ #ifndef const #define const #endif #endif #include /* Comment out all this code if we are using the GNU C Library, and are not actually compiling the library itself. This code is part of the GNU C Library, but also included in many other GNU distributions. Compiling and linking in this code is a waste when using the GNU C library (especially if it is a shared library). Rather than having every GNU program understand `configure --with-gnu-libc' and omit the object files, it is simpler to just do this in the source for each such file. */ #define GETOPT_INTERFACE_VERSION 2 #if !defined _LIBC && defined __GLIBC__ && __GLIBC__ >= 2 #include #if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION #define ELIDE_CODE #endif #endif #ifndef ELIDE_CODE /* This needs to come after some library #include to get __GNU_LIBRARY__ defined. */ #ifdef __GNU_LIBRARY__ #include #endif #ifndef NULL #define NULL 0 #endif int getopt_long (argc, argv, options, long_options, opt_index) int argc; char *const *argv; const char *options; const struct option *long_options; int *opt_index; { return _getopt_internal (argc, argv, options, long_options, opt_index, 0); } /* Like getopt_long, but '-' as well as '--' can indicate a long option. If an option that starts with '-' (not '--') doesn't match a long option, but does match a short option, it is parsed as a short option instead. */ int getopt_long_only (argc, argv, options, long_options, opt_index) int argc; char *const *argv; const char *options; const struct option *long_options; int *opt_index; { return _getopt_internal (argc, argv, options, long_options, opt_index, 1); } #endif /* Not ELIDE_CODE. */ #ifdef TEST #include int main (argc, argv) int argc; char **argv; { int c; int digit_optind = 0; while (1) { int this_option_optind = optind ? optind : 1; int option_index = 0; static struct option long_options[] = { {"add", 1, 0, 0}, {"append", 0, 0, 0}, {"delete", 1, 0, 0}, {"verbose", 0, 0, 0}, {"create", 0, 0, 0}, {"file", 1, 0, 0}, {0, 0, 0, 0} }; c = getopt_long (argc, argv, "abc:d:0123456789", long_options, &option_index); if (c == -1) break; switch (c) { case 0: printf ("option %s", long_options[option_index].name); if (optarg) printf (" with arg %s", optarg); printf ("\n"); break; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': if (digit_optind != 0 && digit_optind != this_option_optind) printf ("digits occur in two different argv-elements.\n"); digit_optind = this_option_optind; printf ("option %c\n", c); break; case 'a': printf ("option a\n"); break; case 'b': printf ("option b\n"); break; case 'c': printf ("option c with value `%s'\n", optarg); break; case 'd': printf ("option d with value `%s'\n", optarg); break; case '?': break; default: printf ("?? getopt returned character code 0%o ??\n", c); } } if (optind < argc) { printf ("non-option ARGV-elements: "); while (optind < argc) printf ("%s ", argv[optind++]); printf ("\n"); } exit (0); } #endif /* TEST */ adplug-adplay-unix-5a5364e/src/null.h000066400000000000000000000020261512216033100174610ustar00rootroot00000000000000/* * AdPlay/UNIX - OPL2 audio player * Copyright (C) 2001, 2002 Simon Peter * * 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, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef H_NULL #define H_NULL #include #include "output.h" class NullOutput: public Player { public: virtual void frame() { } virtual Copl *get_opl() { return &opl; } private: CSilentopl opl; }; #endif adplug-adplay-unix-5a5364e/src/oss.cc000066400000000000000000000033561512216033100174600ustar00rootroot00000000000000/* * AdPlay/UNIX - OPL2 audio player * Copyright (C) 2001 - 2003 Simon Peter * * 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, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include #include #include #include #include #include #include #include "oss.h" #define DEFAULT_DEVICE "/dev/dsp" // Default output device file OSSPlayer::OSSPlayer(Copl *nopl, const char *device, unsigned char bits, int channels, int freq, unsigned long bufsize) : EmuPlayer(nopl, bits, channels, freq, bufsize) { int format = (bits == 16 ? AFMT_S16_LE : AFMT_S8); // Set to default if no device given if(!device) device = DEFAULT_DEVICE; // open OSS audio device if((audio_fd = open(device, O_WRONLY, 0)) == -1) { perror(device); exit(EXIT_FAILURE); } ioctl(audio_fd, SNDCTL_DSP_SETFMT, &format); ioctl(audio_fd, SOUND_PCM_WRITE_CHANNELS, &channels); ioctl(audio_fd, SNDCTL_DSP_SPEED, &freq); } OSSPlayer::~OSSPlayer() { close(audio_fd); } void OSSPlayer::output(const void *buf, unsigned long size) { write(audio_fd, buf, size); } adplug-adplay-unix-5a5364e/src/oss.h000066400000000000000000000023101512216033100173070ustar00rootroot00000000000000/* * AdPlay/UNIX - OPL2 audio player * Copyright (C) 2001 - 2003 Simon Peter * * 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, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef H_OSS #define H_OSS #include "output.h" class OSSPlayer: public EmuPlayer { public: OSSPlayer(Copl *nopl, const char *device, unsigned char bits, int channels, int freq, unsigned long bufsize); virtual ~OSSPlayer(); protected: virtual void output(const void *buf, unsigned long size); private: int audio_fd; // audio device file unsigned long size; // audio buffer size in bytes }; #endif adplug-adplay-unix-5a5364e/src/output.cc000066400000000000000000000042101512216033100202020ustar00rootroot00000000000000/* * AdPlay/UNIX - OPL2 audio player * Copyright (C) 2001 - 2003 Simon Peter * * 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, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include #include #include #include "output.h" #include "defines.h" /***** Player *****/ Player::Player() : p(0), playing(false) { } Player::~Player() { if(p) delete p; } /***** EmuPlayer *****/ long EmuPlayer::minicnt = 0; EmuPlayer::EmuPlayer(Copl *nopl, unsigned char nbits, unsigned char nchannels, unsigned long nfreq, unsigned long nbufsize) : opl(nopl), buf_size(nbufsize), freq(nfreq), bits(nbits), channels(nchannels) { audiobuf = new char [buf_size * getsampsize()]; } EmuPlayer::~EmuPlayer() { delete [] audiobuf; } // Some output plugins (ALSA) need to change the buffer size mid-init void EmuPlayer::setbufsize(unsigned long nbufsize) { delete [] audiobuf; buf_size = nbufsize; audiobuf = new char [buf_size * getsampsize()]; } void EmuPlayer::frame() { long i, towrite = buf_size; char *pos = audiobuf; // Prepare audiobuf with emulator output while(towrite > 0) { while(minicnt < 0) { minicnt += freq; playing = p->update(); } i = MIN(towrite, (long)(minicnt / p->getrefresh() + 4) & ~3); opl->update((short *)pos, i); pos += i * getsampsize(); towrite -= i; i = (long)(p->getrefresh() * i); minicnt -= MAX(1, i); } // call output driver output(audiobuf, buf_size * getsampsize()); } void EmuPlayer::reset() { minicnt = 0; } adplug-adplay-unix-5a5364e/src/output.h000066400000000000000000000034151512216033100200520ustar00rootroot00000000000000/* * AdPlay/UNIX - OPL2 audio player * Copyright (C) 2001 - 2003 Simon Peter * * 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, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef H_OUTPUT #define H_OUTPUT #include class Player { public: CPlayer *p; bool playing; Player(); virtual ~Player(); virtual void frame() = 0; virtual Copl *get_opl() = 0; virtual void reset() {}; }; class EmuPlayer: public Player { private: Copl *opl; char *audiobuf; unsigned long buf_size, freq; unsigned char bits, channels; public: EmuPlayer(Copl *nopl, unsigned char nbits, unsigned char nchannels, unsigned long nfreq, unsigned long nbufsize); virtual ~EmuPlayer(); virtual void setbufsize(unsigned long nbufsize); virtual void frame(); virtual Copl *get_opl() { return opl; } virtual void reset(); protected: virtual void output(const void *buf, unsigned long size) = 0; // The output buffer is always of the size requested through the constructor. // This time, size is measured in bytes, not samples! unsigned char getsampsize() { return (channels * (bits / 8)); } private: static long minicnt; }; #endif adplug-adplay-unix-5a5364e/src/players.h000066400000000000000000000041301512216033100201640ustar00rootroot00000000000000/* * AdPlay/UNIX - OPL2 audio player * Copyright (C) 2001 - 2006 Simon Peter * * 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, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* * players.h - This header conditionally includes AdPlay's output drivers * and sets a reasonable default. */ #ifndef H_PLAYERS #define H_PLAYERS #include "config.h" // Enumerate ALL outputs (regardless of availability) enum Outputs {none, null, ao, oss, disk, esound, qsa, sdl, alsa, raw}; #define DEFAULT_DRIVER none // Null (silent) output #ifdef DRIVER_NULL #include "null.h" #undef DEFAULT_DRIVER #define DEFAULT_DRIVER null #endif // RAW driver #ifdef DRIVER_RAW #include "diskraw.h" #undef DEFAULT_DRIVER #define DEFAULT_DRIVER raw #endif // Disk writer #ifdef DRIVER_DISK #include "disk.h" #undef DEFAULT_DRIVER #define DEFAULT_DRIVER disk #endif // EsounD driver #ifdef DRIVER_ESOUND #include "esound.h" #undef DEFAULT_DRIVER #define DEFAULT_DRIVER esound #endif // SDL driver #ifdef DRIVER_SDL #include "sdl_driver.h" #undef DEFAULT_DRIVER #define DEFAULT_DRIVER sdl #endif // AO driver #ifdef DRIVER_AO #include "ao.h" #undef DEFAULT_DRIVER #define DEFAULT_DRIVER ao #endif // OSS driver #ifdef DRIVER_OSS #include "oss.h" #undef DEFAULT_DRIVER #define DEFAULT_DRIVER oss #endif // ALSA driver #ifdef DRIVER_ALSA #include "alsa.h" #undef DEFAULT_DRIVER #define DEFAULT_DRIVER alsa #endif // QSA driver #ifdef DRIVER_QSA #include "qsa.h" #undef DEFAULT_DRIVER #define DEFAULT_DRIVER qsa #endif #endif adplug-adplay-unix-5a5364e/src/qsa.cc000066400000000000000000000061501512216033100174330ustar00rootroot00000000000000/* * AdPlay/UNIX - OPL2 audio player * Copyright (C) 2001, 2002 Simon Peter * * 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, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "qsa.h" #include QSAPlayer::QSAPlayer(unsigned char bits, int channels, int freq) : EmuPlayer(bits, channels, freq, QSA_FRAG_SIZE) { int rval; snd_pcm_channel_params_t cparams; audio_handle=NULL; rval = snd_pcm_open_preferred(&audio_handle, NULL, NULL, SND_PCM_OPEN_PLAYBACK); if (rval < 0) { exit(EXIT_FAILURE); } memset(&cparams, 0, sizeof(snd_pcm_channel_params_t)); cparams.channel = SND_PCM_CHANNEL_PLAYBACK; cparams.mode = SND_PCM_MODE_BLOCK; cparams.start_mode = SND_PCM_START_FULL; cparams.stop_mode = SND_PCM_STOP_STOP; if (bits==16) { cparams.format.format = SND_PCM_SFMT_S16_LE; } else { cparams.format.format = SND_PCM_SFMT_U8; } cparams.format.interleave = 1; cparams.format.rate = freq; cparams.format.voices = channels; cparams.buf.block.frag_size = QSA_FRAG_SIZE; cparams.buf.block.frags_min = 4; cparams.buf.block.frags_max = 8; rval = snd_pcm_plugin_params(audio_handle, &cparams); if (rval < 0) { exit(EXIT_FAILURE); } rval = snd_pcm_plugin_prepare(audio_handle, SND_PCM_CHANNEL_PLAYBACK); if (rval < 0) { exit(EXIT_FAILURE); } } QSAPlayer::~QSAPlayer() { int rval; if (audio_handle != NULL) { rval = snd_pcm_plugin_flush(audio_handle, SND_PCM_CHANNEL_PLAYBACK); rval = snd_pcm_close(audio_handle); audio_handle = NULL; } } void QSAPlayer::output(const void *buf, unsigned long size) { int rval; unsigned long written; unsigned long towrite; snd_pcm_channel_status_t cstatus; towrite=size; do { written = snd_pcm_plugin_write(audio_handle, buf, towrite); if (written != towrite) { if((errno == EINVAL) || (errno == EIO)) { memset(&cstatus, 0, sizeof(cstatus)); if (snd_pcm_plugin_status(audio_handle, &cstatus) < 0 ) { return; } if ((cstatus.status == SND_PCM_STATUS_UNDERRUN) || (cstatus.status == SND_PCM_STATUS_READY)) { if (snd_pcm_plugin_prepare (audio_handle, SND_PCM_CHANNEL_PLAYBACK) < 0 ) { return; } } continue; } } else { break; } } while (1); } adplug-adplay-unix-5a5364e/src/qsa.h000066400000000000000000000022321512216033100172720ustar00rootroot00000000000000/* * AdPlay/UNIX - OPL2 audio player * Copyright (C) 2001, 2002 Simon Peter * * 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, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef H_QSA #define H_QSA #include "output.h" #include #define QSA_FRAG_SIZE 4096 class QSAPlayer: public EmuPlayer { public: QSAPlayer(unsigned char bits, int channels, int freq); virtual ~QSAPlayer(); protected: virtual void output(const void *buf, unsigned long size); private: snd_pcm_t* audio_handle; // audio device handle }; #endif adplug-adplay-unix-5a5364e/src/sdl.cc000066400000000000000000000046701512216033100174360ustar00rootroot00000000000000/* * AdPlay/UNIX - OPL2 audio player * Copyright (C) 2001 - 2003 Simon Peter * * 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, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include #include #include #include "sdl_driver.h" #include "defines.h" SDLPlayer::SDLPlayer(Copl *nopl, unsigned char bits, int channels, int freq, unsigned long bufsize) : opl(nopl) { memset(&spec, 0x00, sizeof(SDL_AudioSpec)); if(SDL_Init(SDL_INIT_AUDIO) < 0) { message(MSG_ERROR, "unable to initialize SDL -- %s", SDL_GetError()); exit(EXIT_FAILURE); } spec.freq = freq; if(bits == 16) spec.format = AUDIO_S16SYS; else spec.format = AUDIO_U8; spec.channels = channels; spec.samples = bufsize; spec.callback = SDLPlayer::callback; spec.userdata = this; if(SDL_OpenAudio(&spec, NULL) < 0) { message(MSG_ERROR, "unable to open audio -- %s", SDL_GetError()); exit(EXIT_FAILURE); } message(MSG_DEBUG, "got audio buffer size -- %d", spec.size); } SDLPlayer::~SDLPlayer() { if(!SDL_WasInit(SDL_INIT_AUDIO)) return; SDL_CloseAudio(); SDL_Quit(); } void SDLPlayer::frame() { SDL_PauseAudio(0); SDL_Delay(1000 * spec.freq / (spec.size / getsampsize())); } void SDLPlayer::callback(void *userdata, Uint8 *audiobuf, int len) { SDLPlayer *self = (SDLPlayer *)userdata; static long minicnt = 0; long i, towrite = len / self->getsampsize(); char *pos = (char *)audiobuf; // Prepare audiobuf with emulator output while(towrite > 0) { while(minicnt < 0) { minicnt += self->spec.freq; self->playing = self->p->update(); } i = MIN(towrite, (long)(minicnt / self->p->getrefresh() + 4) & ~3); self->opl->update((short *)pos, i); pos += i * self->getsampsize(); towrite -= i; minicnt -= (long)(self->p->getrefresh() * i); } } adplug-adplay-unix-5a5364e/src/sdl_driver.h000066400000000000000000000024621512216033100206500ustar00rootroot00000000000000/* * AdPlay/UNIX - OPL2 audio player * Copyright (C) 2001 - 2003 Simon Peter * * 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, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef H_SDL #define H_SDL #define SDL_MAIN_HANDLED 1 #include #include "output.h" class SDLPlayer: public Player { private: Copl *opl; SDL_AudioSpec spec; static void callback(void *, Uint8 *, int); unsigned char getsampsize() { return spec.channels * (spec.format == AUDIO_U8 ? 1 : 2); } public: SDLPlayer(Copl *nopl, unsigned char bits, int channels, int freq, unsigned long bufsize); virtual ~SDLPlayer(); virtual void frame(); virtual Copl *get_opl() { return opl; } }; #endif