Initial commit of mpg123-1.29.3

This commit is contained in:
Sam Lantinga
2022-05-07 15:47:18 -07:00
commit 01b6013145
352 changed files with 159933 additions and 0 deletions

176
AUTHORS Normal file
View File

@@ -0,0 +1,176 @@
This is an attempt to give credit to the people who contributed in some way to the mpg123 project.
There are names and email addresses listed. Please use these addresses only to contact contributors with some question about their mpg123 contribution.
You are explicitly not allowed to send them unwanted business offers or to question the quality of their sex life.
--------------------
Being on the list of contributing authors not necessarily means that there
is significant copyright in parts of the source code. There are obviously
contributions of differing complexity. I try to mention people who motivated
changes at least by suggesting some definite code changes, even if their
code did not enter the mpg123 source verbatim. Trivial changes like pointing
out ovbious syntax errors that make compilers cry do not land here.
--------------------
Current maintainers with various sorts of contributions:
Thomas Orgis <thomas@orgis.org>
Patrick Dehne <patrick@steidle.net>
Jonathan Yong <10walls@gmail.com>
Taihei Momma <tmkk@mac.com>
Co-initiator of the revived mpg123 project, but not that involved anymore:
Nicholas J Humfrey <njh@ecs.soton.ac.uk>
Special thanks go to Taihei, the person who keeps the assembly optimisations alive
and takes care of portability to OSX/iOS platforms.
Generic address pointing to the current maintainer (hopefully still works in future in case maintainership will change again): <maintainer@mpg123.org>
The creator: Michael Hipp (email: hippm@informatik.uni-tuebingen.de - please bother maintainers first)
Contributions/ideas Thomas Orgis era (includes backports from mhipp trunk):
Vitaly Kirsanov <krokoziabla@gmail.com>: ports/cmake (optional CMake build)
Won-Kyu Park <wkpark@gmail.com>: patch to get rid of asm textrels (x86 PIC)
Michael Weiser <michaelweiser@users.sf.net>: update of coreaudio output to AudioComponents API
Bent Bisballe Nyeng <bbn@dynastrom.com>: patch for MPG123_NO_PEEK_END and MPG123_FORCE_SEEKABLE
Eric S. Raymond <esr@thyrsus.com>: man page fixes
Tobias Weber <tobiw@suprafluid.com>: patch for --disable-equalizer
Hans de Goede <j.w.r.degoede@gmail.com>: patch to skip APE tags
Stephan Vedder <stephan.vedder@gmail.com>: MSVC++ 2013 port update
Rajeev V. Pillai <rajeevvp@users.sf.net>: pointing out/patching issues in HTTP code and behaviour of mpg123 remote/terminal control
Jarno Lehtinen <lehtinen@sci.fi>: tinyalsa output
Anthony Wells <borgboyone@yahoo.com>: initial version of ID3v2 APIC patch
David Wohlferd <limegreensocks@yahoo.com>: Win32 WaveOut buffer destructor fix.
Mike Gorchak <mike.gorchak.qnx@gmail.com>: QNX native audio output (QSA)
Dan McGee <dpmcgee@gmail.com>: various patches (also for test suite)
Jonathan Yong (jon_y) <10walls@gmail.com>: win32 hacking, win32 wasapi audio.
Malcolm Boczek <MBoczek@terraindustries.com>: Common language runtime wrapper
Elbert Pol (TeLLie) <elbert.pol@gmail.com>: OS/2 port fixup
Jeroen Valkonet <jvalkon@xs4all.nl>: motivate pitch control, suggestive patch for pitch command in generic control interface
Andy Hefner <ahefner@gmail.com>: patch for that second UTF16 issue
Taihei Monma <tmkk@mac.com>: A whole lot of new/improved assembler code, including Altivec!
Christian Weisgerber <naddy@openbsd.org>, Brad Smith: sndio output
Patrick Dehne (P4tr3ck) <patrick@steidle.net>: more MSVC++ porting, patch to handle missing bit reservoirs
Thorsten Glaser <tg@mirbsd.de>: icy2utf8, suggest utf8 locale stuff
Dan Smith <dan@algenta.com>: ABI fixes for ensuring stack alignment (esp. for MinGW-built DLL with MSVC)
Michael Ryzhykh <mclroy@gmail.com>: mpg123.spec.in
Stefan Lenselink <Stefan@lenselink.org>: initial aRts output
Sergej Kvachonok <ravenexp@gmail.com>: win32 audio rewrite
Winston: SunOS-4.1.4/gcc-2.7.0 testing and suggestions for fixes (legacy Makefile, integer type headers)
Mika Tiainen: pointing out the fix for the UTF to ASCII filtering of tags to actually work
Nick Kurshev <nickols_k@mail.ru>: extended 3dnow (from mplayer)
Zuxy Meng <zuxy.meng@gmail.com>: SSE (from mplayer)
Honza <cundrak@quick.cz>: idea and prototype patch for ICY meta data support
Petr Baudis <pasky@ucw.cz>: patches: term sigcont, id3 display unicode fallback and condensed output
Petr Salinger <Petr.Salinger@seznam.cz>: i486 enhancement
mpdavig@users.sourceforge.net: linux-ppc-nas Makefile.legacy entry
Adrian Bacon <adrian.bacon@xs4all.nl>: patched decode_i586_dither (noise shaped float/int rounding)
Cool Feet Audio project <nutcase@dtfm.org>: realtime equalizer control
Steve Grundell <www@grundell.u-net.com>: clean stdout in control mode with stdout decoding
Romain Dolbeau <romain@dolbeau.org>: Altivec support (taken from mplayer)
higway <higway@mednet.md>: MMX Patch
Clemens Ladisch <clemens@ladisch.de>: ALSA 0.9/1.0 support
Debian Daniel Kobras <kobras@debian.org> era:
Steve Kemp <skx@debian.org>
Dan Olson <theoddone33@icculus.org>
Syuuhei Kashiyama <squash@mb.kcom.ne.jp>
Rupert Levene <rupert.debian@hotpop.com>
Andreas Dilger <adilger@turbolinux.com>
Erik B. Andersen <andersee@debian.org>
Chris Butler <chrisb@debian.org>
Martin Sjogren <md9ms@mdstud.chalmers.se>
Chet Hosey <chosey@budapress.com>
Roland Rosenfeld <roland@spinnaker.de>
Debian Colin Watson <cjwatson@debian.org> era:
Helge Deller <deller@gmx.de>
Chet Hosey <chosey@budapress.com>
Christopher C. Chimelis <chris@debian.org>
Roland Rosenfeld <roland@spinnaker.de>
Marcelo E. Magallon <mmagallo@debian.org>
Initial Debianers:
Tommi Virtanen <tv@debian.org>
Paul Haggart <phaggart@debian.org>
Contributions/ideas Michael Hipp era:
Mikko Tommila: DCT9
Oliver Fromme <oliver.fromme@heim3.tu-clausthal.de>
MPEG Software Simulation Group: reference decoder package
Tobias Bading: idea for DCT64 in subband synthesis from maplay package
Jeff Tsay and Mikko Tommila: MDCT36 from maplay package
Philipp Knirsch <phil@mpik-tueb.mpg.de>: DCT36/manual unroll idea
Thomas Woerner: SGI Audio
Damien Clermonte: HP-UX audio fixes
Niclas Lindstrom <nil@wineasy.se>: OS2 port
Stefan Bieschewski <stb@acm.org>: Pentium optimizations, decode_i586.s
Martin Denn <mdenn@unix-ag.uni-kl.de>: NAS port
Niklas Beisert <nbeisert@physik.tu-muenchen.de>: MPEG 2.5 tables
<mycroft@NetBSD.ORG> and <augustss@cs.chalmers.se>: NetBSD Patch(es)
Kevin Brintnall <kbrint@visi.com>: BSD patch
Tony Million: win32 port
Steven Tiger Lang: advanced shuffle
Eric B. Mitchell: esd port
Ryan R. Prosser <prosser@geocities.com>: esd port for Solaris
Andreas Neuhaus: initial generic control interface
(additionally fetched from changelog:)
Ralf Hildebrandt <R.Hildebrandt@TU-BS.DE>: audio_alib changes
<sms@moe.2bsd.com>: BSDOS 4.0 with gcc added to Makefile
Bertrand Petit <elrond@phoe.netdev.net>: frontend changes
Erik Mouw <J.A.K.Mouw@its.tudelft.nl>: SGI audio fix for non RAD machines
Daniel O'Connor <darius@guppy.dons.net.au>: freebsd-esd make-entry
D. Skarda <0rfelyus@atrey.karlin.mff.cuni.cz>: enhanced head_check
Wilson, Jeff D <jeff.wilson@wilcom.com>: xterm-title
Robert Bihlmeyer <robbe@orcus.priv.at>: esd changes
Hannu Napari's <Hannu.Napari@hut.fi>: SGI audio patches
<Juergen.Schoew@unix-ag.uni-siegen.de>: native AIX support
<psst@euskalnet.net>: playlist patch
Gilles Zunino <Gilles.Zunino@hei.fupl.asso.fr>: SGI audio patches
Matthew Parslow <roy@alpha.alphalink.com.au>: esdserver patch
<dlux@dlux.sch.bme.hu>: equalizer patch (equalfile setting)
Ducroquet Erwan <ducroque@ufr-info-p7.ibp.fr>: HPUX/ALib support
Shane Wegner <shane@CM.NU>: genrepatch
Samuel Audet <guardia@step.polymtl.ca>: wav-File patch
"J. Dean Brederson" <jdb@cs.utah.edu>: SGI-RAD support
Chou Ye-chi <is84002@cis.nctu.edu.tw>: sajberplay/FreeBSD patch
Fabrice Bellard <bellard@email.enst.fr>: 486 optimizations
A. Hermansen <ahermans@vf.telia.no> and J. Kysela <perex@jcu.cz>: ALSA output
KIMURA Takuhiro <kim@hannah.ipc.miyakyo-u.ac.jp>: K6-3DNow
Petr Stehlik <stehlik@cas3.zlin.vutbr.cz>: MINT
Andy <andy@snoogie.demon.co.uk>: float2int speed up proposal
Brian Foutz <foutz@anise.ee.cornell.edu>: TK3Play
Thomas Niederreiter <tn@tarantel.rz.fh-muenchen.de>: RIFF header fix
Stefan Gybas <cab@studbox.uni-stuttgart.de>: m68k patch
Grant Erickson <eric0139@tc.umn.edu>: Linux PPC patch
Peter Berger <peterb@hoopoe.psc.edu>: BSDi patch
Henrik P Johnson <king@one.se>: HTTP auth
Steven Tiger Lang <tiger@tyger.org>: advanced shuffle
"Brian J. Swetland" <swetland@uiuc.edu>: front-end (remote) patch
<leo@zycad.com>
Tillmann Steinbrecher <tst@gmx.de>: shuffle patch
M.Stekelenburg <m.stekelenburg@student.utwente.nl>: i386-getbits
Antti Andreimann <anttix@cyberix.edu.ee>: outburst patch
Hur TaeSung <saturn@arari.snu.ac.kr>: 'http accept' patch
(from post-0.59 changes that yet have to go into new trunk:)
Hans Schwengeler <schweng@astro.unibas.ch>: audio_dec additions
Wojciech Barañski's Mp3Play (check the tools folder): Mp3Play frontend
Daniel Koukola: audio_oss.c patch
Munechika SUMIKAWA <sumikawa@ebina.hitachi.co.jp>: IPv6
TEMNOTA <temnota@kmv.ru>: HTTP,FTP patch/playlist fix
Peter Surda <shurdeek@panorama.sth.ac.at>: VBR patch
Ben <ben@blaukopf.com>: ARM startup time improvements
Dave MacKenzie <djm@pix.net>: init_output() patch
pasky's <pasky@ju.cz>: close-on-stop patch

772
COPYING Normal file
View File

@@ -0,0 +1,772 @@
This is the file that contains the terms of use, copying, etc. for the mpg123 distribution package.
Main message, to include in "About ..." boxes, etc:
Copyright (c) 1995-2020 by Michael Hipp and others,
free software under the terms of the LGPL v2.1
There is an attempt to cover the actual list of authors in the AUTHORS file.
Project maintainer since 2006 is Thomas Orgis and many people have contributed
since the Michael Hipp era, but he stays the initial source and it would
be impractical to count them all individually, so it's "and others".
Source files contain the phrase "the mpg123 project" to the same effect
in their license boilerplate; especially those that were added after
maintainership changed. The person mainly responsible for the first version
is usually named in the phrase "initially written by ...".
All files in the distribution that don't carry a license note on their own are
licensed under the terms of the LGPL 2.1; exceptions may apply, especially to
files not in the official distribution but in the revision control repository.
The formal license text follows.
=======================
1. The LGPL version 2.1
=======================
GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
[This is the first released version of the Lesser GPL. It also counts
as the successor of the GNU Library Public License, version 2, hence
the version number 2.1.]
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.
This license, the Lesser General Public License, applies to some
specially designated software packages--typically libraries--of the
Free Software Foundation and other authors who decide to use it. You
can use it too, but we suggest you first think carefully about whether
this license or the ordinary General Public License is the better
strategy to use in any particular case, based on the explanations below.
When we speak of free software, we are referring to freedom of use,
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 and use pieces of
it in new free programs; and that you are informed that you can do
these things.
To protect your rights, we need to make restrictions that forbid
distributors to deny you these rights or to ask you to surrender these
rights. These restrictions translate to certain responsibilities for
you if you distribute copies of the library or if you modify it.
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link other code with the library, you must provide
complete object files to the recipients, so that they can relink them
with the library after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
We protect your rights with a two-step method: (1) we copyright the
library, and (2) we offer you this license, which gives you legal
permission to copy, distribute and/or modify the library.
To protect each distributor, we want to make it very clear that
there is no warranty for the free library. Also, if the library is
modified by someone else and passed on, the recipients should know
that what they have is not the original version, so that the original
author's reputation will not be affected by problems that might be
introduced by others.
Finally, software patents pose a constant threat to the existence of
any free program. We wish to make sure that a company cannot
effectively restrict the users of a free program by obtaining a
restrictive license from a patent holder. Therefore, we insist that
any patent license obtained for a version of the library must be
consistent with the full freedom of use specified in this license.
Most GNU software, including some libraries, is covered by the
ordinary GNU General Public License. This license, the GNU Lesser
General Public License, applies to certain designated libraries, and
is quite different from the ordinary General Public License. We use
this license for certain libraries in order to permit linking those
libraries into non-free programs.
When a program is linked with a library, whether statically or using
a shared library, the combination of the two is legally speaking a
combined work, a derivative of the original library. The ordinary
General Public License therefore permits such linking only if the
entire combination fits its criteria of freedom. The Lesser General
Public License permits more lax criteria for linking other code with
the library.
We call this license the "Lesser" General Public License because it
does Less to protect the user's freedom than the ordinary General
Public License. It also provides other free software developers Less
of an advantage over competing non-free programs. These disadvantages
are the reason we use the ordinary General Public License for many
libraries. However, the Lesser license provides advantages in certain
special circumstances.
For example, on rare occasions, there may be a special need to
encourage the widest possible use of a certain library, so that it becomes
a de-facto standard. To achieve this, non-free programs must be
allowed to use the library. A more frequent case is that a free
library does the same job as widely used non-free libraries. In this
case, there is little to gain by limiting the free library to free
software only, so we use the Lesser General Public License.
In other cases, permission to use a particular library in non-free
programs enables a greater number of people to use a large body of
free software. For example, permission to use the GNU C Library in
non-free programs enables many more people to use the whole GNU
operating system, as well as its variant, the GNU/Linux operating
system.
Although the Lesser General Public License is Less protective of the
users' freedom, it does ensure that the user of a program that is
linked with the Library has the freedom and the wherewithal to run
that program using a modified version of the Library.
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, whereas the latter must
be combined with the library in order to run.
GNU LESSER GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library or other
program which contains a notice placed by the copyright holder or
other authorized party saying it may be distributed under the terms of
this Lesser General Public License (also called "this License").
Each licensee is addressed as "you".
A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
The "Library", below, refers to any such software library or work
which has been distributed under these terms. A "work based on the
Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for
making modifications to it. For a library, 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 library.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete 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 distribute a copy of this License along with the
Library.
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 Library or any portion
of it, thus forming a work based on the Library, 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) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
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 Library, 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 Library.
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
4. You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you 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.
If distribution of 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 satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library". Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
When a "work that uses the Library" uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also combine or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
a) Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable "work that
uses the Library", as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
b) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (1) uses at run time a
copy of the library already present on the user's computer system,
rather than copying library functions into the executable, and (2)
will operate properly with a modified version of the library, if
the user installs one, as long as the modified version is
interface-compatible with the version that the work was made with.
c) Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
d) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
e) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the materials to be 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.
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities. This must be distributed under the terms of the
Sections above.
b) Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library 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.
9. 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 Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
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 with
this License.
11. 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 Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library 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 Library.
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.
12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library 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.
13. The Free Software Foundation may publish revised and/or new
versions of the Lesser 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 Library
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 Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
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
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY "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
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. 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 LIBRARY 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
LIBRARY (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 LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
END OF TERMS AND CONDITIONS
====================
2. The GPL version 2
====================
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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 Lesser 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

3
ChangeLog Normal file
View File

@@ -0,0 +1,3 @@
This is a dummy file. If you want to see the change log, use subversion:
svn log -v svn://orgis.org/mpg123

176
INSTALL Normal file
View File

@@ -0,0 +1,176 @@
mpg123 install hints
--------------------
0. Prerequesites
You really need:
- a C compiler; we try to keep the code ANSI C89/ISO C90 compatible
gcc from 2.95 on should work, others, too - please report any issues
Actually, we have a confirmed working build (svn trunk leading to
release 0.67) on SunOS 4.1.4 with gcc-2.7.0 .
- an (UNIX-like) operating system with standard tools; MinGW32 and
Cygwin are working for Microsoft Windows, too. We also have users happily
on OS/2.
- For the library only, you may get lucky with MSVC++ using the project
files under ports/
- For other exotic platforms, also see ports/
- If building from direct SCM checkout, you need GNU autotools installed
(see below).
You want:
- working assembler (recent GNU binutils) if using certain CPU
optimizations
- headers and lib for certain audio output drivers (libasound for alsa,
sdl for sdl...)
1. Build
There is one main supported way to get your mpg123 installation
consisting of
a) the mpg123, mpg123-strip, out123 program binaries
- with libmpg123, libout123, and libsyn123 as shared libraries or
statically linked
- with audio output plugins for libout123, or one statically linked
b) man pages
(you may want to copy some of the documentation - README, etc - to
/usr/share/doc/mpg123 or the like, too)
This way is the usual GNU 3-step procedure:
./configure
make
make install
Run
./configure --help
for a list of possible parameters you can specify in the configuration
step. The obvious are --prefix and the normal GNU autotool bunch, but
others include what audio subsystem to use and what CPU optimizations
to build in.
For the optimizations (decoder choice), the default is a build that
combines all usable optimizations for the platform and chooses one at
runtime (see --cpu, --list-cpu and --test-cpu parameters).
There are various parameters you can tune, but of course the defaults
are what is mainly tested.
Also, various library features can be left out via --disable options
(like output formats, resampling modes). That way, you can strive for a
minimal build that only does what you really need. Not every combination
of library features is tested regularily, so you might hit some speed
bumps, but usually stuff that is easily worked out (at least for the
mpg123 team when you report it).
An example (working on mpg123 trunk r3062):
CFLAGS="-Os -s" ./configure --with-cpu=generic --disable-id3v2
--disable-lfs-alias --disable-feature-report --with-seektable=0
--disable-16bit --disable-32bit --disable-8bit --disable-messages
--disable-feeder --disable-ntom --disable-downsample --disable-icy
&& make
That, and further application of `strip --strip-unneeded`, yields a lean
93 KiB shared library for MPEG layer I/II/III decoding to floating point
on my x86-64 system (it should be a bit smaller on 32 bit systems). When
disabling layers I and II, too, that goes down to 81 KiB.
The shared library of a full build weighs 170 KiB after stripping.
2. Developer build
This project uses GNU autotools (no specific version, but they should
be fairly recent), also libtool. You need to have those installed, as
it is usually the case for build environments based on the GNU toolchain.
One a fresh SCM checkout, or after changing things in configure.ac,
you need to run
autoreconf -iv
to prepare the configure script. Then you can build as per point 1.
3. Library-only build
Mpg123 uses a non-recursive build. If you want to build only one of the
libraries, specify it as a target:
./configure
make src/libmpg123/libmpg123.la
make src/libsyn123/libsyn123.la
make src/libout123/libout123.la
You can then find the library itself under src/lib*123/.libs (libtool
likes to hide things there).
4. Exotic platforms
See the ports/ directory for some help for building at least libmpg123
without the UNIX shell / autotools. The main strategy is to write
a config.h to replace what configure would generate and then have a
correct listing of all source files involved in that configuration
(there are optional files for different decoder choices, for example).
Then compile objects, link.
Instead of manually curated MSVC project files, there is a CMake port
now in ports/cmake to build mpg123 with the MS compilers. It might be
helpful for other platforms, too. But the main build system for
POSIX-like systems is the autotools one.
4a. Preparing Win32 binary packages.
Caution: You should make sure to use some gcc >= 4.2.0, even if it's
still the experimental package for MinGW32.
This helps preventing incompatibilities between generated DLL files and
other compilers (it's about stack alignment).
Get MinGW/MSYS installed, run the MSYS shell.
Enter the mpg123 source directory.
Execute sh ./windows-builds.sh .
After some time, you should have some relevant files under releases/
(or releases\, for Windows people;-).
You don't just get one build -- there are several variants, corresponding
to what usually is to be found under http://mpg123.org/download/win32 .
5. Note on large file support
The libmpg123 API includes the generic off_t type for file offsets and
thus is subject to shape-shifting on systems that change off_t depending
on build flags.
To deal with the incompatibilities that can cause, the library needs to
separate code paths for small and large off_t.
Since version 1.12.0, a large-file-enabled libmpg123 (the default set
by configure) provides a dual-mode ABI. Depending on _FILE_OFFSET_BITS,
the mpg123.h header file selects different library symbols to use for
your app.
In both large-file and normal mode, the library should just work for
your app.
6. Security
If you consider installing the mpg123 binary or any program using
libout123 as suid root, please don't. Apart from evaluating MPG123_MODDIR
from the environment and thus possibly loading any code, the purpose of
libout123 is to write audio data to somewhere. That includes writing raw
data to files. Any files you specify to the program. You do not install
dd or gzip suid root, do you?
Programs using libmpg123 should be fine, as that one does not load runtime
modules and also only has code to read files, not write them. Still,
if your task involves decoding random MPEG audio files from anywhere,
it is only sensible to limit the damage of a possible bug triggered by
certain crafted files. This is not specific to libmpg123 but generally
a good idea working with data from untrusted sources.

82
Makefile.am Normal file
View File

@@ -0,0 +1,82 @@
## Makefile.am: produce Makefile.in from this
## copyright by the mpg123 project - free software under the terms of the LGPL 2.1
## see COPYING and AUTHORS files in distribution or http://mpg123.org
## initially written by Nicholas J. Humfrey
## reworked for non-recursive make by Thomas Orgis
# Mention all global variables first before including Make modules.
ACLOCAL_AMFLAGS = -I m4
bin_PROGRAMS =
EXTRA_PROGRAMS =
EXTRA_DIST =
pkglib_LTLIBRARIES =
lib_LTLIBRARIES =
noinst_LIBRARIES =
noinst_LTLIBRARIES =
nodist_include_HEADERS =
include_HEADERS =
dist_man_MANS =
CLEANFILES =
TESTS =
XFAIL_TESTS =
check_PROGRAMS =
AM_CPPFLAGS = -DPKGLIBDIR="\"$(pkglibdir)\""
# That can be trimmed down later when adapting the sources to
# use relative paths for includes.
# Watch out for generated headers (that's why top_builddir is also present).
AM_CPPFLAGS += \
$(LTDLINCL) \
-I$(top_srcdir)/src \
-I$(top_srcdir)/src/compat \
-I$(top_srcdir)/src/libmpg123 \
-I$(top_srcdir)/src/libout123 \
-I$(top_builddir)/src/libmpg123 \
-I$(top_builddir)/src/libsyn123 \
-I$(top_builddir)/src/libout123
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA =
# Include Make modules from subdirectories.
include src/Makemodule.am
include doc/Makemodule.am
# Stuff from this directory.
pkgconfig_DATA += libmpg123.pc libout123.pc libsyn123.pc
dist_man_MANS += man1/mpg123.1 man1/out123.1
# mpg123.spec is autogenerated but needs to be present in tarball!
EXTRA_DIST += \
mpg123.spec \
makedll.sh \
windows-builds.sh \
equalize.dat \
NEWS.libmpg123 \
NEWS.libout123 \
NEWS.libsyn123 \
ports/cmake/CMakeLists.txt \
ports/cmake/mpg123-config.cmake.in \
ports/cmake/cmake/search_libs.cmake \
ports/cmake/cmake/read_api_version.cmake \
ports/cmake/cmake/CheckCPUArch.cmake \
ports/cmake/cmake/CheckCPUArch.c.in \
ports/cmake/src/CMakeLists.txt \
ports/cmake/src/config.cmake.h.in \
ports/cmake/src/libmpg123/CMakeLists.txt \
ports/cmake/src/libout123/modules/CMakeLists.txt \
ports/cmake/src/libout123/CMakeLists.txt \
ports/cmake/src/libsyn123/CMakeLists.txt \
ports/cmake/src/tests/CMakeLists.txt \
ports/cmake/src/compat/CMakeLists.txt \
ports/README \
ports/Sony_PSP/config.h \
ports/Sony_PSP/README \
ports/Sony_PSP/Makefile.psp \
ports/Sony_PSP/readers.c.patch \
scripts/benchmark-cpu.pl \
scripts/tag_lyrics.py \
scripts/conplay \
scripts/mpg123info

5857
Makefile.in Normal file

File diff suppressed because it is too large Load Diff

2436
NEWS Normal file

File diff suppressed because it is too large Load Diff

233
NEWS.libmpg123 Normal file
View File

@@ -0,0 +1,233 @@
Changes in libmpg123 libtool interface versions...
46.0.46
- Functions mpg123_init() and mpg123_exit() are really no-ops now.
There is no need to call them, and no harm done calling them in
parallel. The latter used to be the case before, too, but only in
practice, not in theory.
- Common tables provided in precomputed form now, both float and fixed.
- There are enum-less variants of all API entry points now, mapped to
by default unless MPG123_ENUM_API is defined.
45.0.45
- mpg123_read(), mpg123_decode(), and mpg123_replace_buffer() now taking
void* for output buffers
- value 0 for any rate in mpg123_format()/mpg123_fmt()
- use of mpg123_decoder() after track open supported
(also as hack to trigger renegotiation of output format,
which will not be communicated as it only happens by users's
intention)
- added struct mpg123_moreinfo and mpg123_set_moreinfo()
- officially declared mpg123_exit() as superfluous
- added MPG123_ENC_DELAY, MPG123_ENC_PADDING, MPG123_DEC_DELAY
- added MPG123_STORE_RAW_ID3 and mpg123_id3_raw()
- added mpg123_new_string() and mpg123_delete_string()
- added MPG123_FORCE_ENDIAN and MPG123_BIG_ENDIAN
- added MPG123_NO_READAHEAD and MPG123_FREEFORMAT_SIZE
- changed format logic to search all possible encodings
and channel counts for a rate first, then trying different
rates (rate > channel > encoding)
- included float and >16 bit integer encodings in default
format search
- added MPG123_FLOAT_FALLBACK
- added MPG123_NO_FRANKENSTEIN
- added mpg123_feature2(), added MPG123_FEATURE_OUTPUT_FLOAT32 and
MPG123_FEATURE_OUTPUT_FLOAT32
- added mpg123_open_fixed()
44.0.44
- added mpg123_getformat2()
43.0.43
- added MPG123_NO_PEEK_END and MPG123_FORCE_SEEKABLE
42.0.42
- added mpg123_framelength()
Now mpg123_position() is truly obsolete!
- hardened string API to not crash if given NULL pointers
(except mpg123_init_string())
- equalizer feature optional
41.0.41
- Add checks for NULL handles in some API functions that missed that, changed return value in others to MPG123_BAD_HANDLE where appropriate:
- mpg123_format_none(NULL) == MPG123_BAD_HANDLE (was: MPG123_ERR)
- mpg123_format_all(NULL) == MPG123_BAD_HANDLE (was: MPG123_ERR)
- mpg123_format(NULL, ...) == MPG123_BAD_HANDLE (was: MPG123_ERR)
- mpg123_reset_eq(NULL) == MPG123_BAD_HANDLE (was: undefined)
- mpg123_replace_buffer(NULL, ...) == MPG123_BAD_HANDLE (was: undefined)
- mpg123_framedata(NULL, ...) == MPG123_BAD_HANDLE (was: MPG123_ERR)
- mpg123_decoder(NULL, ...) == MPG123_BAD_HANDLE (was: MPG123_ERR)
- mpg123_param(NULL, ...) == MPG123_BAD_HANDLE (was: MPG123_ERR)
- mpg123_getparam(NULL, ...) == MPG123_BAD_HANDLE (was: MPG123_ERR)
- mpg123_getstate(NULL, ...) == MPG123_BAD_HANDLE (was: MPG123_ERR)
- mpg123_eq(NULL, ...) == MPG123_BAD_HANDLE (was: MPG123_ERR)
- mpg123_open(NULL, ...) == MPG123_BAD_HANDLE (was: MPG123_ERR)
- mpg123_open_handle(NULL, ...) == MPG123_BAD_HANDLE (was: MPG123_ERR)
- mpg123_open_feed(NULL, ...) == MPG123_BAD_HANDLE (was: MPG123_ERR)
- mpg123_replace_reader(NULL, ...) == MPG123_BAD_HANDLE (was: MPG123_ERR)
- mpg123_replace_reader_handle(NULL, ...) == MPG123_BAD_HANDLE (was: MPG123_ERR)
- mpg123_decode_frame(NULL, ...) == MPG123_BAD_HANDLE (was: MPG123_ERR)
- mpg123_feed(NULL, ...) == MPG123_BAD_HANDLE (was: MPG123_ERR)
- mpg123_decode(NULL, ...) == MPG123_BAD_HANDLE (was: MPG123_ERR)
- mpg123_info(NULL, ...) == MPG123_BAD_HANDLE (was: MPG123_ERR)
- mpg123_getformat(NULL, ...) == MPG123_BAD_HANDLE (was: MPG123_ERR)
- mpg123_set_filesize(NULL, ...) == MPG123_BAD_HANDLE (was: MPG123_ERR)
- mpg123_scan(NULL) == MPG123_BAD_HANDLE (was: MPG123_ERR)
- mpg123_id3(NULL, ...) == MPG123_BAD_HANDLE (was: MPG123_ERR)
- mpg123_icy(NULL, ...) == MPG123_BAD_HANDLE (was: MPG123_ERR)
- mpg123_index(NULL, ...) == MPG123_BAD_HANDLE (was: MPG123_ERR)
- mpg123_set_index(NULL, ...) == MPG123_BAD_HANDLE (was: MPG123_ERR)
- mpg123_close(NULL, ...) == MPG123_BAD_HANDLE (was: MPG123_ERR)
- Changed return value of mpg123_geteq() to 0 for NULL handle to be consistent with itself.
40.0.40
- Bump for marking the first actual implementation of A-Law encoding.
Not that it matters to anyone, though --- I wonder why not even the
Asterisk users wanted this. It's for telephony, dammit!
- Added arm_fpu decoder for runtime switch between NEON and generic fpu.
39.2.39
- Added more elaborate post-processing to enable 32 and 24 bit output also with low-precision decoder (16 bit, fixed-point).
39.0.39
- Added MPG123_FRESH_DECODER.
- Also containing several regression fixes.
38.0.38
- Added MPG123_PICTURE and associated addition to mpg123_id3v2 struct.
37.0.37
- Added mpg123_chomp_string.
36.0.36
- Extended MPG123_RESYNC_LIMIT to initial header search.
- Not cutting decoder delay unconditionally anymore (only in combination with known encoder delay / padding).
35.0.35
- Added mpg123_meta_free().
34.0.34
- Added flag MPG123_AUTO_RESAMPLE.
- Changed (improved;-) outbuffer behaviour.
33.0.33
- Added MPG123_BUFFERFILL.
32.0.32
- Added mpg123_framepos()
31.0.31
- Added mpg123_framedata() and MPG123_IGNORE_INFOFRAME.
30.0.30
- Added MPG123_FEEDPOOL and MPG123_FEEDBUFFER.
29.0.29
- New decoder: ARM neon.
- Added support for 24 bit output (dumb byte-chopping of 32 bit output).
28.0.28
- Add mpg123_strlen().
27.0.27
- Implictly disable seeking on streams when client enforced ICY parsing.
This helps debugging dumps of http streams.
26.0.26
- Added mpg123_encsize().
- Added flag MPG123_SKIP_ID3V2.
25.0.25
- Version increase to mark the point where the split between normal and large-file-enabled library vanishes again. The world did not like it.
Now Thomas lost some days of recreation and sleep to give it a dual-mode libmpg123 on large-file-sensitive systems.
24.0.24
- Introduce mpg123_replace_reader_handle() and mpg123_open_handle()
... this is also in preparation for the next version which will drop the separated large-file library again, due to public display of dismay.
- Add the experimental mpg123_framebyframe_decode to the off_t-sensitive functions.
23.0.23
- Version increase to mark the point where the explicit split between normal and large-file-enabled library has been introduced.
22.0.22
- Experimental framebyframe API added.
21.0.21
- Added support of unicode file names under windows via UTF-8 argument to mpg123_open.
- Added mpg123_feature(), for example to test for the above behaviour.
20.0.20
- New flag: MPG123_PLAIN_ID3TEXT
- Corresponding text encoding handling API added:
mpg123_enc_from_id3, mpg123_store_utf8
19.0.19
- Hm, what was it exactly now... there are candidates:
- runtime dithering
- free format
- ARM optimizations
18.0.18
- new parameter: MPG123_PREFRAMES is now tunable (the number of frames to decode and skip before a seek point), also default value increased
17.0.17
- introduction optimized stereo synths
16.0.16
- introducing floating point x86-64 SSE synth
15.0.15
- first addition of x86-64 SSE optimizations
14.0.14
- the first libmpg123 with actually working MPG123_UPSPEED
- also important regression fix concerning skipping of frames
13.0.13
- The whole set of output formats is generally available (8, 16 and 32 bit integer, signed/unsigned, float)
- Many features can be absent from libary as build decision (minimize binary size).
12.0.12
- added mpg123_current_decoder
- fixed value of MPG123_ENC_FLOAT
- float output now is a real runtime option
11.0.11
- added mpg123_getstate
- run-time tunable frame index
- officially configured with largefile support where available
10.0.10
- new flag MPG123_FUZZY (along with the fuzzy seek functionality)
9.0.9
- added mpg123_tell_stream
8.0.8
- added mpg123_get_eq
7.0.7
- added mpg123_set_filesize
6.0.6
- added mpg123_icy2utf8
5.0.5
- added mpg123_feed
- input buffers now const
4.0.4
- extended mpg123_string api (mpg123_add_substring, mpg123_grow_string)
3.0.3
- Initial floating point support as compile-time option.
2.0.2
- New flag MPG123_SEEKBUFFER.
1.0.1
- Added MPG123_RESYNC_LIMIT parameter.
- Added MPG123_OUT_OF_SYNC and MPG123_RESYNC_FAIL error codes.
- Fix for uninitialized framesize value in handle.

15
NEWS.libout123 Normal file
View File

@@ -0,0 +1,15 @@
4.0.4
- added enum-less variants out123_param2() and out123_getparam2(), replacing
the enum variants unless MPG123_ENUM_API is defined
- added out123_devices()
- added out123_stringlists_free()
- module API version 3 with enumeration and void deinit()
3.0.3
- added out123_free()
2.0.2
- added OUT123_BINDIR
1.0.1
- initial version

3
NEWS.libsyn123 Normal file
View File

@@ -0,0 +1,3 @@
1.0.1
- initial version

209
README Normal file
View File

@@ -0,0 +1,209 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * *
* mpg123 - MPEG 1.0/2.0/2.5 audio player *
* README for version 1.x.y, dated at 14.06.2009 *
* *
* ...still the fastest MPEG audio player for UNIX ;) *
* * * * * * * * * * * * * * * * * * * * * * * * * * * *
(This file has very long lines - die-hard terminal nostalgists can be satisfied by `fmt -s -w 75 < README | less`. I think it's better to let the reader's preference rule than to preformat the stuff to some arbitrary width.)
0. Stuff
For building/installation info see INSTALL.
The mpg123 project was started by Michel Hipp and is now being maintained by Thomas Orgis and Nicholas J. Humfrey, who initiated the Sourceforge project.
The source code contains contributions from quite a few people - see AUTHORS for more info.
It is Open Source software licensed mostly under the LGPL with some parts restricted to GPL. See COPYING for details.
As for every mp3 player, some of mpg123's functionality may be covered by patents in a country where these are valid. See PATENTS for details.
Project's official website URL is
http://mpg123.org
(or http://mpg123.orgis.org as fallback address if there is a problem with the DNS forwarding)
for the traditional home page and
http://sourceforge.net/projects/mpg123
for sourceforge.net based services like download mirrors, mailing lists and bug/feature trackers.
Please use the sourceforge download mirrors when possible to minimize load on the mpg123.org server.
1. Introduction
This is a console based decoder/player for mono/stereo mpeg audio files, probably more familiar as MP3 or MP2 files.
It's focus is speed. We still need some low-end benchmarks for the current version, but playback should be possible even on i486 CPUs. There is hand-optimized assembly code for i586, MMX, 3DNow, SEE and 3DNowExt instructions, while generic code runs on a variety of different platforms and CPUs.
It can play MPEG1.0/2.0/2.5 layer I, II, II (1, 2, 3;-) files (VBR files are fine, too) and produce output on a number of different ways: raw data to stdout and different sound systems depending on your platform (see INSTALL).
Most tested are Linux on x86 and Alpha/AXP and MacOSX on ppc as the environments the current developers work in.
We are always thankful for user reports on success (and failure) on any platform!
2. Contact
short:
mpg123-devel@lists.sourceforge.net
mpg123-users@lists.sourceforge.net
or
maintainer@mpg123.org
long: see doc/CONTACT
3. Interface/Usage
Please consult the manpage mpg123(1). Some starter info follows.
3.1 Simple Console Usage
Mpg123 is a console program - normally it just plays a list of files you specify on command line and that's it. See the included manpage or
mpg123 --help
or, for the full story,
mpg123 --longhelp
on command line syntax/options. I encourage you to check out the --gapless and --rva-album/--rva-mix options:-)
In the simple "mpg123 file1.mp3 file2.mp3" mode, the only thing you can do to interact is to press Ctrl+C to skip to next track or end the whole playback if pressing it twice.
Note that this Ctrl+C behaviour is special to this mode; when any of the following is activated, Ctrl+C will just kill the program like you would expect normally (this changed from earlier versions).
3.2 Advanced Console Usage
You can specify the option -C to enable a terminal control interface enabling to influence playback on current title/playlist by pressing some key:
-= terminal control keys =-
[s] or [ ] interrupt/restart playback (i.e. '(un)pause')
[f] next track
[d] previous track
[]] next directory (next track until directory part changes)
[[] previous directory (previous track until directory part changes)
[b] back to beginning of track
[p] loop around current position (don't combine with output buffer)
[.] forward
[,] rewind
[:] fast forward
[;] fast rewind
[>] fine forward
[<] fine rewind
[+] volume up
[-] volume down
[u] (un)mute volume
[r] RVA switch
[v] verbose switch
[l] list current playlist, indicating current track there
[t] display tag info (again)
[m] print MPEG header info (again)
[c] or [C] pitch up (small step, big step)
[x] or [X] pitch down (small step, big step)
[w] reset pitch to zero
[k] print out current position in playlist and track, for the benefit of some external tool to store bookmarks
[h] this help
[q] quit
You can change these bindings to key to your liking by modifying term.h .
Note: This interface needs not to be available on _every_ platform/build.
Another note: The volume up and down is performed by changing the scale factor (like the -f parameter) ... so the audio is scaled digitally in the given range of the output format (usually 16bits). That means the lowering the volume will decrease the dynamic range and possibly lessen the quality while increasing volume can in fact increase the dynamic range and thus make it better, if you deal with a silent source and no clipping is necessary.
It is a good idea to use RVA values stored in the file for adjusting low volume files, though - mpg123 handles that in addition to your volume setting.
3.3 Control Interface for Frontends
There used to be several interfaces for frontends left over from that past, but only one of them remains for the present and future:
The Generic Control Interface
It contains of communication of textual messages via standard input to mpg123 and responses to standard output unless the -s switch for output of audio data on stdout is used - then the responses come via stderr.
See doc/README.remote for usage.
4. Speed
mpg123 is fast. Any faster software player is probably based on some hacked mpg123;-)
MPlayer included mpg123 source code in it's mp3lib and we have to be thankful for the MPlayer folks adding SSE, 3DNowExt and AltiVec optimizations over the years, which we were able to backport.
mpg123 includes the AltiVec optimization since version 0.61 and the SSE and 3DNowExt optimizations since 0.66 .
Also, version 0.66 adds the merged x86 optimization build, which includes every applicable optimization for x86 cpus except the one for i486, wich is a bit special.
Now mpg123 catched up with MPlayer's mp3lib concerning decoding speed on my Pentium M (which supports SSE):
Decoding a certain album (Queensryche's Rage for Order) to /dev/null took 22.4s user time with mpg123-0.66 compared to 24.7s with MPlayer-1.0rc1 .
Also, beginning with mpg123 1.8.0, there are fresh x86-64 SSE optimizations (provided by Taihei Monma) which make mpg123 the fastest MPEG audio decoder in my knowledge also on current 64bit x86 systems.
5. Accuracy
The mpg123 engine is able to decode in full compliance to ISO/IEC 11172-3, for all three layers, using floating point or integer math (the latter since 1.8.1).
Accuracy of 16bit output depends on specific optimization in use and compile-time choice about the rounding mode (which is performance relevant).
The ISO test suite is incorporated in the mpg123 subversion repository under svn://orgis.org/mpg123/test, nightly tests of a build (with high-quality 16bit rounding) are published on the mpg123 website.
Dithered 16bit output is available as an option (the --cpu choices ending with _dither). See
http://dither123.dyndns.org
on the whereabouts.
6. History
A looooong time ago (mid-90s), Michael Hipp wrote some initial mpg123 and made it _the_ Unix console mp3 player in the following years.
The exact date of birth is fuzzy in human memory, but according to the master himself (Michael) mpg123 started in 1994 as an MP2 player which a year later, 1995, gained MP3 ability.
The core decoder files have mostly 1995 as their birth year listed, so one can say that mpg123 as the layer1,2,3 player was born in 1995.
In any case, that is a looooong time ago for a media player - especially for one that is still alive!
This is the historic description:
This isn't a new player. It's a fully rewritten version originally based
on the mpegaudio (FHG-version) package. The DCT algorithm in the
synthesis filter is a rewritten version of the DCT first seen in the maplay
package, which was written by Tobias Bading (bading@cs.tu-berlin.de). The
rewrite was necessary, because the GPL may not allow this copyright mix.
The mpegaudio package was written by various people from the MPEG/audio
software simulation group. The maplay is under GPL .. You can find the
original source code and the mpegaudio package on: ftp.tnt.uni-hannover.de.
Especially layer3.c common.c and mpg123.h is based on the dist10 package.
The code is fully rewritten but I'm using sometimes the
same variable names or similar function names as in the
original package.
In the current layer3.c I'm using a DCT36 first seen in Jeff Tsay's
(ctsay@pasteur.eecs.berkeley.edu) maplay 1.2+ package. His code is
under GPL .. I also tried the enhancement from Mikko Tommila. His
code is also in layer3.c (but it's disabled at the moment, because
it was slightly slower than the unrolled 9 point DCT (at least on
_my_ system)). Theoretically it should be faster. You may try it on
your system.
Well, that's how it started...
Official development ceased due to the typical lack-of-time syndrome around 2002 and the free-floating patches began to seize the day.
But before that, Michael wrote or rewrote the essential code; others contributed their bits.
The main message is:
Code is copyrighted by Michael Hipp, who made it free software under the terms of the LGPL 2.1.
Please see doc/ROAD_TO_LGPL, COPYING and AUTHORS for details on that. Note that the only notable legacy non-LGPL file was the old alsa output that didn't work with alsa 0.9/1.0 anymore.
Also, there has been a libao output in the betas 0.60 for a short period. Libao being generally problematic for us because of its GPL license, this output is not distributed anymore in the release packages. There is now a new, LGPLed alsa output that made both the old alsa and libao obsolete for our purposes.
So, the distributed mpg123 releases actually only contain LGPL code, but you get the other files from our subversion repository if you checkout the trunk / version tags.
There has been quite some confusion about the licensing and "freeness" of mpg123 in the past.
The initial "free for private use, ask me when you want to do something commercial" license caused some people to avoid mpg123 and even to write a replacement mimicking the interface but using a different decoding engine - what was not actively developed for too long but entered the "free" software sections.
The Debian (non-free section) and Gentoo distributions cared about the last stable and the last development release of mpg123 over the years with mainly applying security fixes. Thanks go to the distribution maintainers for not letting it alone to bitrot over the years.
Thomas Orgis started to hack on mpg123 in 2004 while working on his personal audio experience with mixplayd and later DerMixD, utilizing the generic control interface. In Feb 2005, he crammed control interface improvements together with Debian's r19 fixes and released the personal fork/patch named mpg123-thor.
Little later that year, Nicholas J. Humphrey independently created the sourceforge project and released an autotooled 0.59r under official GPL flag with Debian and MacOSX fixes.
In the beginning of 2006, Thomas finally decided that he could work "officially" on mpg123 and contacted Michael Hipp for taking over maintainership.
Michael was all-positive about letting mpg123 really live again (and perhaps see version 1.0 some time;-) and also pointed at the sourceforge project that didn't see much activity since the initial release.
A lot of emails and some weeks later there was the two-developer team of Nicholas and Thomas working on merging their mpg123 variants as well as adding some features and fixes to let it shine again.
And there we are now...
7. End
Have fun!
____________
Thomas Orgis

46
TODO Normal file
View File

@@ -0,0 +1,46 @@
Things that need to be done...
... as always, mostly outdated.
0. Fix that ugly crash that happens sometimes when Ctrl+C-ing with jack output active:
Program terminated with signal 11, Segmentation fault.
[New process 6293]
[New process 6291]
[New process 6292]
[New process 6284]
#0 0x00002aced607695b in memcpy () from /lib/libc.so.6
(gdb) bt
#0 0x00002aced607695b in memcpy () from /lib/libc.so.6
#1 0x00002aced5b4f092 in jack_ringbuffer_read () from /usr/lib/libjack.so.0
#2 0x00000000004151dd in process_callback ()
#3 0x00002aced5b4bf40 in Jack::JackClient::Execute () from /usr/lib/libjack.so.0
#4 0x00002aced5b5f8da in Jack::JackPosixThread::ThreadHandler () from /usr/lib/libjack.so.0
#5 0x00002aced6354fa7 in start_thread () from /lib/libpthread.so.0
#6 0x00002aced60c802d in clone () from /lib/libc.so.6
1. mpg123 could pick up new sample rates suggested by the output modules (like a jack server fixed to 96kHz) and adapt to that.
Also, the libsyn123 resampler should be employed. Just generally, libsyn123
could also provide encoding conversions for formats not directly supported
by accelerated decoders. See out123, which is the
2. What's about SINGLE_MIX?
Check what is _really_ happening there, make some test file...
3. Add playback of WAV files in mpg123 and out123.
Parsing the standard 44-byte header really is no big issue. WAV64 is
not really a thing, is it? Anyway, mpg123/out123 will probably just ignore
the length in the header. Also, both programs need a switch to enable
treating input as WAV, though out123 might get away with a default
mode of looking out for a header unless format options were given. Yes,
that makes sense. And perhaps I really should limit this to out123.
4. Enable some way to avoid libmpg123 messages (Note: …) messing up display
of the progress bar.
- cleanup callback from app
- fprintf callback from app
- log buffer

2346
aclocal.m4 vendored Normal file

File diff suppressed because it is too large Load Diff

348
build/compile Executable file
View File

@@ -0,0 +1,348 @@
#! /bin/sh
# Wrapper for compilers which do not understand '-c -o'.
scriptversion=2018-03-07.03; # UTC
# Copyright (C) 1999-2018 Free Software Foundation, Inc.
# Written by Tom Tromey <tromey@cygnus.com>.
#
# 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, see <https://www.gnu.org/licenses/>.
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
# This file is maintained in Automake, please report
# bugs to <bug-automake@gnu.org> or send patches to
# <automake-patches@gnu.org>.
nl='
'
# We need space, tab and new line, in precisely that order. Quoting is
# there to prevent tools from complaining about whitespace usage.
IFS=" "" $nl"
file_conv=
# func_file_conv build_file lazy
# Convert a $build file to $host form and store it in $file
# Currently only supports Windows hosts. If the determined conversion
# type is listed in (the comma separated) LAZY, no conversion will
# take place.
func_file_conv ()
{
file=$1
case $file in
/ | /[!/]*) # absolute file, and not a UNC file
if test -z "$file_conv"; then
# lazily determine how to convert abs files
case `uname -s` in
MINGW*)
file_conv=mingw
;;
CYGWIN*)
file_conv=cygwin
;;
*)
file_conv=wine
;;
esac
fi
case $file_conv/,$2, in
*,$file_conv,*)
;;
mingw/*)
file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'`
;;
cygwin/*)
file=`cygpath -m "$file" || echo "$file"`
;;
wine/*)
file=`winepath -w "$file" || echo "$file"`
;;
esac
;;
esac
}
# func_cl_dashL linkdir
# Make cl look for libraries in LINKDIR
func_cl_dashL ()
{
func_file_conv "$1"
if test -z "$lib_path"; then
lib_path=$file
else
lib_path="$lib_path;$file"
fi
linker_opts="$linker_opts -LIBPATH:$file"
}
# func_cl_dashl library
# Do a library search-path lookup for cl
func_cl_dashl ()
{
lib=$1
found=no
save_IFS=$IFS
IFS=';'
for dir in $lib_path $LIB
do
IFS=$save_IFS
if $shared && test -f "$dir/$lib.dll.lib"; then
found=yes
lib=$dir/$lib.dll.lib
break
fi
if test -f "$dir/$lib.lib"; then
found=yes
lib=$dir/$lib.lib
break
fi
if test -f "$dir/lib$lib.a"; then
found=yes
lib=$dir/lib$lib.a
break
fi
done
IFS=$save_IFS
if test "$found" != yes; then
lib=$lib.lib
fi
}
# func_cl_wrapper cl arg...
# Adjust compile command to suit cl
func_cl_wrapper ()
{
# Assume a capable shell
lib_path=
shared=:
linker_opts=
for arg
do
if test -n "$eat"; then
eat=
else
case $1 in
-o)
# configure might choose to run compile as 'compile cc -o foo foo.c'.
eat=1
case $2 in
*.o | *.[oO][bB][jJ])
func_file_conv "$2"
set x "$@" -Fo"$file"
shift
;;
*)
func_file_conv "$2"
set x "$@" -Fe"$file"
shift
;;
esac
;;
-I)
eat=1
func_file_conv "$2" mingw
set x "$@" -I"$file"
shift
;;
-I*)
func_file_conv "${1#-I}" mingw
set x "$@" -I"$file"
shift
;;
-l)
eat=1
func_cl_dashl "$2"
set x "$@" "$lib"
shift
;;
-l*)
func_cl_dashl "${1#-l}"
set x "$@" "$lib"
shift
;;
-L)
eat=1
func_cl_dashL "$2"
;;
-L*)
func_cl_dashL "${1#-L}"
;;
-static)
shared=false
;;
-Wl,*)
arg=${1#-Wl,}
save_ifs="$IFS"; IFS=','
for flag in $arg; do
IFS="$save_ifs"
linker_opts="$linker_opts $flag"
done
IFS="$save_ifs"
;;
-Xlinker)
eat=1
linker_opts="$linker_opts $2"
;;
-*)
set x "$@" "$1"
shift
;;
*.cc | *.CC | *.cxx | *.CXX | *.[cC]++)
func_file_conv "$1"
set x "$@" -Tp"$file"
shift
;;
*.c | *.cpp | *.CPP | *.lib | *.LIB | *.Lib | *.OBJ | *.obj | *.[oO])
func_file_conv "$1" mingw
set x "$@" "$file"
shift
;;
*)
set x "$@" "$1"
shift
;;
esac
fi
shift
done
if test -n "$linker_opts"; then
linker_opts="-link$linker_opts"
fi
exec "$@" $linker_opts
exit 1
}
eat=
case $1 in
'')
echo "$0: No command. Try '$0 --help' for more information." 1>&2
exit 1;
;;
-h | --h*)
cat <<\EOF
Usage: compile [--help] [--version] PROGRAM [ARGS]
Wrapper for compilers which do not understand '-c -o'.
Remove '-o dest.o' from ARGS, run PROGRAM with the remaining
arguments, and rename the output as expected.
If you are trying to build a whole package this is not the
right script to run: please start by reading the file 'INSTALL'.
Report bugs to <bug-automake@gnu.org>.
EOF
exit $?
;;
-v | --v*)
echo "compile $scriptversion"
exit $?
;;
cl | *[/\\]cl | cl.exe | *[/\\]cl.exe | \
icl | *[/\\]icl | icl.exe | *[/\\]icl.exe )
func_cl_wrapper "$@" # Doesn't return...
;;
esac
ofile=
cfile=
for arg
do
if test -n "$eat"; then
eat=
else
case $1 in
-o)
# configure might choose to run compile as 'compile cc -o foo foo.c'.
# So we strip '-o arg' only if arg is an object.
eat=1
case $2 in
*.o | *.obj)
ofile=$2
;;
*)
set x "$@" -o "$2"
shift
;;
esac
;;
*.c)
cfile=$1
set x "$@" "$1"
shift
;;
*)
set x "$@" "$1"
shift
;;
esac
fi
shift
done
if test -z "$ofile" || test -z "$cfile"; then
# If no '-o' option was seen then we might have been invoked from a
# pattern rule where we don't need one. That is ok -- this is a
# normal compilation that the losing compiler can handle. If no
# '.c' file was seen then we are probably linking. That is also
# ok.
exec "$@"
fi
# Name of file we expect compiler to create.
cofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'`
# Create the lock directory.
# Note: use '[/\\:.-]' here to ensure that we don't use the same name
# that we are using for the .o file. Also, base the name on the expected
# object file name, since that is what matters with a parallel build.
lockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d
while true; do
if mkdir "$lockdir" >/dev/null 2>&1; then
break
fi
sleep 1
done
# FIXME: race condition here if user kills between mkdir and trap.
trap "rmdir '$lockdir'; exit 1" 1 2 15
# Run the compile.
"$@"
ret=$?
if test -f "$cofile"; then
test "$cofile" = "$ofile" || mv "$cofile" "$ofile"
elif test -f "${cofile}bj"; then
test "${cofile}bj" = "$ofile" || mv "${cofile}bj" "$ofile"
fi
rmdir "$lockdir"
exit $ret
# Local Variables:
# mode: shell-script
# sh-indentation: 2
# eval: (add-hook 'before-save-hook 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-time-zone: "UTC0"
# time-stamp-end: "; # UTC"
# End:

1480
build/config.guess vendored Executable file

File diff suppressed because it is too large Load Diff

1801
build/config.sub vendored Executable file

File diff suppressed because it is too large Load Diff

791
build/depcomp Executable file
View File

@@ -0,0 +1,791 @@
#! /bin/sh
# depcomp - compile a program generating dependencies as side-effects
scriptversion=2018-03-07.03; # UTC
# Copyright (C) 1999-2018 Free Software Foundation, Inc.
# 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, see <https://www.gnu.org/licenses/>.
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
case $1 in
'')
echo "$0: No command. Try '$0 --help' for more information." 1>&2
exit 1;
;;
-h | --h*)
cat <<\EOF
Usage: depcomp [--help] [--version] PROGRAM [ARGS]
Run PROGRAMS ARGS to compile a file, generating dependencies
as side-effects.
Environment variables:
depmode Dependency tracking mode.
source Source file read by 'PROGRAMS ARGS'.
object Object file output by 'PROGRAMS ARGS'.
DEPDIR directory where to store dependencies.
depfile Dependency file to output.
tmpdepfile Temporary file to use when outputting dependencies.
libtool Whether libtool is used (yes/no).
Report bugs to <bug-automake@gnu.org>.
EOF
exit $?
;;
-v | --v*)
echo "depcomp $scriptversion"
exit $?
;;
esac
# Get the directory component of the given path, and save it in the
# global variables '$dir'. Note that this directory component will
# be either empty or ending with a '/' character. This is deliberate.
set_dir_from ()
{
case $1 in
*/*) dir=`echo "$1" | sed -e 's|/[^/]*$|/|'`;;
*) dir=;;
esac
}
# Get the suffix-stripped basename of the given path, and save it the
# global variable '$base'.
set_base_from ()
{
base=`echo "$1" | sed -e 's|^.*/||' -e 's/\.[^.]*$//'`
}
# If no dependency file was actually created by the compiler invocation,
# we still have to create a dummy depfile, to avoid errors with the
# Makefile "include basename.Plo" scheme.
make_dummy_depfile ()
{
echo "#dummy" > "$depfile"
}
# Factor out some common post-processing of the generated depfile.
# Requires the auxiliary global variable '$tmpdepfile' to be set.
aix_post_process_depfile ()
{
# If the compiler actually managed to produce a dependency file,
# post-process it.
if test -f "$tmpdepfile"; then
# Each line is of the form 'foo.o: dependency.h'.
# Do two passes, one to just change these to
# $object: dependency.h
# and one to simply output
# dependency.h:
# which is needed to avoid the deleted-header problem.
{ sed -e "s,^.*\.[$lower]*:,$object:," < "$tmpdepfile"
sed -e "s,^.*\.[$lower]*:[$tab ]*,," -e 's,$,:,' < "$tmpdepfile"
} > "$depfile"
rm -f "$tmpdepfile"
else
make_dummy_depfile
fi
}
# A tabulation character.
tab=' '
# A newline character.
nl='
'
# Character ranges might be problematic outside the C locale.
# These definitions help.
upper=ABCDEFGHIJKLMNOPQRSTUVWXYZ
lower=abcdefghijklmnopqrstuvwxyz
digits=0123456789
alpha=${upper}${lower}
if test -z "$depmode" || test -z "$source" || test -z "$object"; then
echo "depcomp: Variables source, object and depmode must be set" 1>&2
exit 1
fi
# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
depfile=${depfile-`echo "$object" |
sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
rm -f "$tmpdepfile"
# Avoid interferences from the environment.
gccflag= dashmflag=
# Some modes work just like other modes, but use different flags. We
# parameterize here, but still list the modes in the big case below,
# to make depend.m4 easier to write. Note that we *cannot* use a case
# here, because this file can only contain one case statement.
if test "$depmode" = hp; then
# HP compiler uses -M and no extra arg.
gccflag=-M
depmode=gcc
fi
if test "$depmode" = dashXmstdout; then
# This is just like dashmstdout with a different argument.
dashmflag=-xM
depmode=dashmstdout
fi
cygpath_u="cygpath -u -f -"
if test "$depmode" = msvcmsys; then
# This is just like msvisualcpp but w/o cygpath translation.
# Just convert the backslash-escaped backslashes to single forward
# slashes to satisfy depend.m4
cygpath_u='sed s,\\\\,/,g'
depmode=msvisualcpp
fi
if test "$depmode" = msvc7msys; then
# This is just like msvc7 but w/o cygpath translation.
# Just convert the backslash-escaped backslashes to single forward
# slashes to satisfy depend.m4
cygpath_u='sed s,\\\\,/,g'
depmode=msvc7
fi
if test "$depmode" = xlc; then
# IBM C/C++ Compilers xlc/xlC can output gcc-like dependency information.
gccflag=-qmakedep=gcc,-MF
depmode=gcc
fi
case "$depmode" in
gcc3)
## gcc 3 implements dependency tracking that does exactly what
## we want. Yay! Note: for some reason libtool 1.4 doesn't like
## it if -MD -MP comes after the -MF stuff. Hmm.
## Unfortunately, FreeBSD c89 acceptance of flags depends upon
## the command line argument order; so add the flags where they
## appear in depend2.am. Note that the slowdown incurred here
## affects only configure: in makefiles, %FASTDEP% shortcuts this.
for arg
do
case $arg in
-c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;;
*) set fnord "$@" "$arg" ;;
esac
shift # fnord
shift # $arg
done
"$@"
stat=$?
if test $stat -ne 0; then
rm -f "$tmpdepfile"
exit $stat
fi
mv "$tmpdepfile" "$depfile"
;;
gcc)
## Note that this doesn't just cater to obsosete pre-3.x GCC compilers.
## but also to in-use compilers like IMB xlc/xlC and the HP C compiler.
## (see the conditional assignment to $gccflag above).
## There are various ways to get dependency output from gcc. Here's
## why we pick this rather obscure method:
## - Don't want to use -MD because we'd like the dependencies to end
## up in a subdir. Having to rename by hand is ugly.
## (We might end up doing this anyway to support other compilers.)
## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
## -MM, not -M (despite what the docs say). Also, it might not be
## supported by the other compilers which use the 'gcc' depmode.
## - Using -M directly means running the compiler twice (even worse
## than renaming).
if test -z "$gccflag"; then
gccflag=-MD,
fi
"$@" -Wp,"$gccflag$tmpdepfile"
stat=$?
if test $stat -ne 0; then
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
echo "$object : \\" > "$depfile"
# The second -e expression handles DOS-style file names with drive
# letters.
sed -e 's/^[^:]*: / /' \
-e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
## This next piece of magic avoids the "deleted header file" problem.
## The problem is that when a header file which appears in a .P file
## is deleted, the dependency causes make to die (because there is
## typically no way to rebuild the header). We avoid this by adding
## dummy dependencies for each header file. Too bad gcc doesn't do
## this for us directly.
## Some versions of gcc put a space before the ':'. On the theory
## that the space means something, we add a space to the output as
## well. hp depmode also adds that space, but also prefixes the VPATH
## to the object. Take care to not repeat it in the output.
## Some versions of the HPUX 10.20 sed can't process this invocation
## correctly. Breaking it into two sed invocations is a workaround.
tr ' ' "$nl" < "$tmpdepfile" \
| sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \
| sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
hp)
# This case exists only to let depend.m4 do its work. It works by
# looking at the text of this script. This case will never be run,
# since it is checked for above.
exit 1
;;
sgi)
if test "$libtool" = yes; then
"$@" "-Wp,-MDupdate,$tmpdepfile"
else
"$@" -MDupdate "$tmpdepfile"
fi
stat=$?
if test $stat -ne 0; then
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files
echo "$object : \\" > "$depfile"
# Clip off the initial element (the dependent). Don't try to be
# clever and replace this with sed code, as IRIX sed won't handle
# lines with more than a fixed number of characters (4096 in
# IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines;
# the IRIX cc adds comments like '#:fec' to the end of the
# dependency line.
tr ' ' "$nl" < "$tmpdepfile" \
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' \
| tr "$nl" ' ' >> "$depfile"
echo >> "$depfile"
# The second pass generates a dummy entry for each header file.
tr ' ' "$nl" < "$tmpdepfile" \
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
>> "$depfile"
else
make_dummy_depfile
fi
rm -f "$tmpdepfile"
;;
xlc)
# This case exists only to let depend.m4 do its work. It works by
# looking at the text of this script. This case will never be run,
# since it is checked for above.
exit 1
;;
aix)
# The C for AIX Compiler uses -M and outputs the dependencies
# in a .u file. In older versions, this file always lives in the
# current directory. Also, the AIX compiler puts '$object:' at the
# start of each line; $object doesn't have directory information.
# Version 6 uses the directory in both cases.
set_dir_from "$object"
set_base_from "$object"
if test "$libtool" = yes; then
tmpdepfile1=$dir$base.u
tmpdepfile2=$base.u
tmpdepfile3=$dir.libs/$base.u
"$@" -Wc,-M
else
tmpdepfile1=$dir$base.u
tmpdepfile2=$dir$base.u
tmpdepfile3=$dir$base.u
"$@" -M
fi
stat=$?
if test $stat -ne 0; then
rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
exit $stat
fi
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
do
test -f "$tmpdepfile" && break
done
aix_post_process_depfile
;;
tcc)
# tcc (Tiny C Compiler) understand '-MD -MF file' since version 0.9.26
# FIXME: That version still under development at the moment of writing.
# Make that this statement remains true also for stable, released
# versions.
# It will wrap lines (doesn't matter whether long or short) with a
# trailing '\', as in:
#
# foo.o : \
# foo.c \
# foo.h \
#
# It will put a trailing '\' even on the last line, and will use leading
# spaces rather than leading tabs (at least since its commit 0394caf7
# "Emit spaces for -MD").
"$@" -MD -MF "$tmpdepfile"
stat=$?
if test $stat -ne 0; then
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
# Each non-empty line is of the form 'foo.o : \' or ' dep.h \'.
# We have to change lines of the first kind to '$object: \'.
sed -e "s|.*:|$object :|" < "$tmpdepfile" > "$depfile"
# And for each line of the second kind, we have to emit a 'dep.h:'
# dummy dependency, to avoid the deleted-header problem.
sed -n -e 's|^ *\(.*\) *\\$|\1:|p' < "$tmpdepfile" >> "$depfile"
rm -f "$tmpdepfile"
;;
## The order of this option in the case statement is important, since the
## shell code in configure will try each of these formats in the order
## listed in this file. A plain '-MD' option would be understood by many
## compilers, so we must ensure this comes after the gcc and icc options.
pgcc)
# Portland's C compiler understands '-MD'.
# Will always output deps to 'file.d' where file is the root name of the
# source file under compilation, even if file resides in a subdirectory.
# The object file name does not affect the name of the '.d' file.
# pgcc 10.2 will output
# foo.o: sub/foo.c sub/foo.h
# and will wrap long lines using '\' :
# foo.o: sub/foo.c ... \
# sub/foo.h ... \
# ...
set_dir_from "$object"
# Use the source, not the object, to determine the base name, since
# that's sadly what pgcc will do too.
set_base_from "$source"
tmpdepfile=$base.d
# For projects that build the same source file twice into different object
# files, the pgcc approach of using the *source* file root name can cause
# problems in parallel builds. Use a locking strategy to avoid stomping on
# the same $tmpdepfile.
lockdir=$base.d-lock
trap "
echo '$0: caught signal, cleaning up...' >&2
rmdir '$lockdir'
exit 1
" 1 2 13 15
numtries=100
i=$numtries
while test $i -gt 0; do
# mkdir is a portable test-and-set.
if mkdir "$lockdir" 2>/dev/null; then
# This process acquired the lock.
"$@" -MD
stat=$?
# Release the lock.
rmdir "$lockdir"
break
else
# If the lock is being held by a different process, wait
# until the winning process is done or we timeout.
while test -d "$lockdir" && test $i -gt 0; do
sleep 1
i=`expr $i - 1`
done
fi
i=`expr $i - 1`
done
trap - 1 2 13 15
if test $i -le 0; then
echo "$0: failed to acquire lock after $numtries attempts" >&2
echo "$0: check lockdir '$lockdir'" >&2
exit 1
fi
if test $stat -ne 0; then
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
# Each line is of the form `foo.o: dependent.h',
# or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
# Do two passes, one to just change these to
# `$object: dependent.h' and one to simply `dependent.h:'.
sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
# Some versions of the HPUX 10.20 sed can't process this invocation
# correctly. Breaking it into two sed invocations is a workaround.
sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" \
| sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
hp2)
# The "hp" stanza above does not work with aCC (C++) and HP's ia64
# compilers, which have integrated preprocessors. The correct option
# to use with these is +Maked; it writes dependencies to a file named
# 'foo.d', which lands next to the object file, wherever that
# happens to be.
# Much of this is similar to the tru64 case; see comments there.
set_dir_from "$object"
set_base_from "$object"
if test "$libtool" = yes; then
tmpdepfile1=$dir$base.d
tmpdepfile2=$dir.libs/$base.d
"$@" -Wc,+Maked
else
tmpdepfile1=$dir$base.d
tmpdepfile2=$dir$base.d
"$@" +Maked
fi
stat=$?
if test $stat -ne 0; then
rm -f "$tmpdepfile1" "$tmpdepfile2"
exit $stat
fi
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2"
do
test -f "$tmpdepfile" && break
done
if test -f "$tmpdepfile"; then
sed -e "s,^.*\.[$lower]*:,$object:," "$tmpdepfile" > "$depfile"
# Add 'dependent.h:' lines.
sed -ne '2,${
s/^ *//
s/ \\*$//
s/$/:/
p
}' "$tmpdepfile" >> "$depfile"
else
make_dummy_depfile
fi
rm -f "$tmpdepfile" "$tmpdepfile2"
;;
tru64)
# The Tru64 compiler uses -MD to generate dependencies as a side
# effect. 'cc -MD -o foo.o ...' puts the dependencies into 'foo.o.d'.
# At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
# dependencies in 'foo.d' instead, so we check for that too.
# Subdirectories are respected.
set_dir_from "$object"
set_base_from "$object"
if test "$libtool" = yes; then
# Libtool generates 2 separate objects for the 2 libraries. These
# two compilations output dependencies in $dir.libs/$base.o.d and
# in $dir$base.o.d. We have to check for both files, because
# one of the two compilations can be disabled. We should prefer
# $dir$base.o.d over $dir.libs/$base.o.d because the latter is
# automatically cleaned when .libs/ is deleted, while ignoring
# the former would cause a distcleancheck panic.
tmpdepfile1=$dir$base.o.d # libtool 1.5
tmpdepfile2=$dir.libs/$base.o.d # Likewise.
tmpdepfile3=$dir.libs/$base.d # Compaq CCC V6.2-504
"$@" -Wc,-MD
else
tmpdepfile1=$dir$base.d
tmpdepfile2=$dir$base.d
tmpdepfile3=$dir$base.d
"$@" -MD
fi
stat=$?
if test $stat -ne 0; then
rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
exit $stat
fi
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
do
test -f "$tmpdepfile" && break
done
# Same post-processing that is required for AIX mode.
aix_post_process_depfile
;;
msvc7)
if test "$libtool" = yes; then
showIncludes=-Wc,-showIncludes
else
showIncludes=-showIncludes
fi
"$@" $showIncludes > "$tmpdepfile"
stat=$?
grep -v '^Note: including file: ' "$tmpdepfile"
if test $stat -ne 0; then
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
echo "$object : \\" > "$depfile"
# The first sed program below extracts the file names and escapes
# backslashes for cygpath. The second sed program outputs the file
# name when reading, but also accumulates all include files in the
# hold buffer in order to output them again at the end. This only
# works with sed implementations that can handle large buffers.
sed < "$tmpdepfile" -n '
/^Note: including file: *\(.*\)/ {
s//\1/
s/\\/\\\\/g
p
}' | $cygpath_u | sort -u | sed -n '
s/ /\\ /g
s/\(.*\)/'"$tab"'\1 \\/p
s/.\(.*\) \\/\1:/
H
$ {
s/.*/'"$tab"'/
G
p
}' >> "$depfile"
echo >> "$depfile" # make sure the fragment doesn't end with a backslash
rm -f "$tmpdepfile"
;;
msvc7msys)
# This case exists only to let depend.m4 do its work. It works by
# looking at the text of this script. This case will never be run,
# since it is checked for above.
exit 1
;;
#nosideeffect)
# This comment above is used by automake to tell side-effect
# dependency tracking mechanisms from slower ones.
dashmstdout)
# Important note: in order to support this mode, a compiler *must*
# always write the preprocessed file to stdout, regardless of -o.
"$@" || exit $?
# Remove the call to Libtool.
if test "$libtool" = yes; then
while test "X$1" != 'X--mode=compile'; do
shift
done
shift
fi
# Remove '-o $object'.
IFS=" "
for arg
do
case $arg in
-o)
shift
;;
$object)
shift
;;
*)
set fnord "$@" "$arg"
shift # fnord
shift # $arg
;;
esac
done
test -z "$dashmflag" && dashmflag=-M
# Require at least two characters before searching for ':'
# in the target name. This is to cope with DOS-style filenames:
# a dependency such as 'c:/foo/bar' could be seen as target 'c' otherwise.
"$@" $dashmflag |
sed "s|^[$tab ]*[^:$tab ][^:][^:]*:[$tab ]*|$object: |" > "$tmpdepfile"
rm -f "$depfile"
cat < "$tmpdepfile" > "$depfile"
# Some versions of the HPUX 10.20 sed can't process this sed invocation
# correctly. Breaking it into two sed invocations is a workaround.
tr ' ' "$nl" < "$tmpdepfile" \
| sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \
| sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
dashXmstdout)
# This case only exists to satisfy depend.m4. It is never actually
# run, as this mode is specially recognized in the preamble.
exit 1
;;
makedepend)
"$@" || exit $?
# Remove any Libtool call
if test "$libtool" = yes; then
while test "X$1" != 'X--mode=compile'; do
shift
done
shift
fi
# X makedepend
shift
cleared=no eat=no
for arg
do
case $cleared in
no)
set ""; shift
cleared=yes ;;
esac
if test $eat = yes; then
eat=no
continue
fi
case "$arg" in
-D*|-I*)
set fnord "$@" "$arg"; shift ;;
# Strip any option that makedepend may not understand. Remove
# the object too, otherwise makedepend will parse it as a source file.
-arch)
eat=yes ;;
-*|$object)
;;
*)
set fnord "$@" "$arg"; shift ;;
esac
done
obj_suffix=`echo "$object" | sed 's/^.*\././'`
touch "$tmpdepfile"
${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
rm -f "$depfile"
# makedepend may prepend the VPATH from the source file name to the object.
# No need to regex-escape $object, excess matching of '.' is harmless.
sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile"
# Some versions of the HPUX 10.20 sed can't process the last invocation
# correctly. Breaking it into two sed invocations is a workaround.
sed '1,2d' "$tmpdepfile" \
| tr ' ' "$nl" \
| sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \
| sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile" "$tmpdepfile".bak
;;
cpp)
# Important note: in order to support this mode, a compiler *must*
# always write the preprocessed file to stdout.
"$@" || exit $?
# Remove the call to Libtool.
if test "$libtool" = yes; then
while test "X$1" != 'X--mode=compile'; do
shift
done
shift
fi
# Remove '-o $object'.
IFS=" "
for arg
do
case $arg in
-o)
shift
;;
$object)
shift
;;
*)
set fnord "$@" "$arg"
shift # fnord
shift # $arg
;;
esac
done
"$@" -E \
| sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
-e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
| sed '$ s: \\$::' > "$tmpdepfile"
rm -f "$depfile"
echo "$object : \\" > "$depfile"
cat < "$tmpdepfile" >> "$depfile"
sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
msvisualcpp)
# Important note: in order to support this mode, a compiler *must*
# always write the preprocessed file to stdout.
"$@" || exit $?
# Remove the call to Libtool.
if test "$libtool" = yes; then
while test "X$1" != 'X--mode=compile'; do
shift
done
shift
fi
IFS=" "
for arg
do
case "$arg" in
-o)
shift
;;
$object)
shift
;;
"-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
set fnord "$@"
shift
shift
;;
*)
set fnord "$@" "$arg"
shift
shift
;;
esac
done
"$@" -E 2>/dev/null |
sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile"
rm -f "$depfile"
echo "$object : \\" > "$depfile"
sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::'"$tab"'\1 \\:p' >> "$depfile"
echo "$tab" >> "$depfile"
sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile"
rm -f "$tmpdepfile"
;;
msvcmsys)
# This case exists only to let depend.m4 do its work. It works by
# looking at the text of this script. This case will never be run,
# since it is checked for above.
exit 1
;;
none)
exec "$@"
;;
*)
echo "Unknown depmode $depmode" 1>&2
exit 1
;;
esac
exit 0
# Local Variables:
# mode: shell-script
# sh-indentation: 2
# eval: (add-hook 'before-save-hook 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-time-zone: "UTC0"
# time-stamp-end: "; # UTC"
# End:

518
build/install-sh Executable file
View File

@@ -0,0 +1,518 @@
#!/bin/sh
# install - install a program, script, or datafile
scriptversion=2018-03-11.20; # UTC
# This originates from X11R5 (mit/util/scripts/install.sh), which was
# later released in X11R6 (xc/config/util/install.sh) with the
# following copyright and license.
#
# Copyright (C) 1994 X Consortium
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to
# deal in the Software without restriction, including without limitation the
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
# sell copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
# Except as contained in this notice, the name of the X Consortium shall not
# be used in advertising or otherwise to promote the sale, use or other deal-
# ings in this Software without prior written authorization from the X Consor-
# tium.
#
#
# FSF changes to this file are in the public domain.
#
# Calling this script install-sh is preferred over install.sh, to prevent
# 'make' implicit rules from creating a file called install from it
# when there is no Makefile.
#
# This script is compatible with the BSD install script, but was written
# from scratch.
tab=' '
nl='
'
IFS=" $tab$nl"
# Set DOITPROG to "echo" to test this script.
doit=${DOITPROG-}
doit_exec=${doit:-exec}
# Put in absolute file names if you don't have them in your path;
# or use environment vars.
chgrpprog=${CHGRPPROG-chgrp}
chmodprog=${CHMODPROG-chmod}
chownprog=${CHOWNPROG-chown}
cmpprog=${CMPPROG-cmp}
cpprog=${CPPROG-cp}
mkdirprog=${MKDIRPROG-mkdir}
mvprog=${MVPROG-mv}
rmprog=${RMPROG-rm}
stripprog=${STRIPPROG-strip}
posix_mkdir=
# Desired mode of installed file.
mode=0755
chgrpcmd=
chmodcmd=$chmodprog
chowncmd=
mvcmd=$mvprog
rmcmd="$rmprog -f"
stripcmd=
src=
dst=
dir_arg=
dst_arg=
copy_on_change=false
is_target_a_directory=possibly
usage="\
Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
or: $0 [OPTION]... SRCFILES... DIRECTORY
or: $0 [OPTION]... -t DIRECTORY SRCFILES...
or: $0 [OPTION]... -d DIRECTORIES...
In the 1st form, copy SRCFILE to DSTFILE.
In the 2nd and 3rd, copy all SRCFILES to DIRECTORY.
In the 4th, create DIRECTORIES.
Options:
--help display this help and exit.
--version display version info and exit.
-c (ignored)
-C install only if different (preserve the last data modification time)
-d create directories instead of installing files.
-g GROUP $chgrpprog installed files to GROUP.
-m MODE $chmodprog installed files to MODE.
-o USER $chownprog installed files to USER.
-s $stripprog installed files.
-t DIRECTORY install into DIRECTORY.
-T report an error if DSTFILE is a directory.
Environment variables override the default commands:
CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG
RMPROG STRIPPROG
"
while test $# -ne 0; do
case $1 in
-c) ;;
-C) copy_on_change=true;;
-d) dir_arg=true;;
-g) chgrpcmd="$chgrpprog $2"
shift;;
--help) echo "$usage"; exit $?;;
-m) mode=$2
case $mode in
*' '* | *"$tab"* | *"$nl"* | *'*'* | *'?'* | *'['*)
echo "$0: invalid mode: $mode" >&2
exit 1;;
esac
shift;;
-o) chowncmd="$chownprog $2"
shift;;
-s) stripcmd=$stripprog;;
-t)
is_target_a_directory=always
dst_arg=$2
# Protect names problematic for 'test' and other utilities.
case $dst_arg in
-* | [=\(\)!]) dst_arg=./$dst_arg;;
esac
shift;;
-T) is_target_a_directory=never;;
--version) echo "$0 $scriptversion"; exit $?;;
--) shift
break;;
-*) echo "$0: invalid option: $1" >&2
exit 1;;
*) break;;
esac
shift
done
# We allow the use of options -d and -T together, by making -d
# take the precedence; this is for compatibility with GNU install.
if test -n "$dir_arg"; then
if test -n "$dst_arg"; then
echo "$0: target directory not allowed when installing a directory." >&2
exit 1
fi
fi
if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
# When -d is used, all remaining arguments are directories to create.
# When -t is used, the destination is already specified.
# Otherwise, the last argument is the destination. Remove it from $@.
for arg
do
if test -n "$dst_arg"; then
# $@ is not empty: it contains at least $arg.
set fnord "$@" "$dst_arg"
shift # fnord
fi
shift # arg
dst_arg=$arg
# Protect names problematic for 'test' and other utilities.
case $dst_arg in
-* | [=\(\)!]) dst_arg=./$dst_arg;;
esac
done
fi
if test $# -eq 0; then
if test -z "$dir_arg"; then
echo "$0: no input file specified." >&2
exit 1
fi
# It's OK to call 'install-sh -d' without argument.
# This can happen when creating conditional directories.
exit 0
fi
if test -z "$dir_arg"; then
if test $# -gt 1 || test "$is_target_a_directory" = always; then
if test ! -d "$dst_arg"; then
echo "$0: $dst_arg: Is not a directory." >&2
exit 1
fi
fi
fi
if test -z "$dir_arg"; then
do_exit='(exit $ret); exit $ret'
trap "ret=129; $do_exit" 1
trap "ret=130; $do_exit" 2
trap "ret=141; $do_exit" 13
trap "ret=143; $do_exit" 15
# Set umask so as not to create temps with too-generous modes.
# However, 'strip' requires both read and write access to temps.
case $mode in
# Optimize common cases.
*644) cp_umask=133;;
*755) cp_umask=22;;
*[0-7])
if test -z "$stripcmd"; then
u_plus_rw=
else
u_plus_rw='% 200'
fi
cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;;
*)
if test -z "$stripcmd"; then
u_plus_rw=
else
u_plus_rw=,u+rw
fi
cp_umask=$mode$u_plus_rw;;
esac
fi
for src
do
# Protect names problematic for 'test' and other utilities.
case $src in
-* | [=\(\)!]) src=./$src;;
esac
if test -n "$dir_arg"; then
dst=$src
dstdir=$dst
test -d "$dstdir"
dstdir_status=$?
else
# Waiting for this to be detected by the "$cpprog $src $dsttmp" command
# might cause directories to be created, which would be especially bad
# if $src (and thus $dsttmp) contains '*'.
if test ! -f "$src" && test ! -d "$src"; then
echo "$0: $src does not exist." >&2
exit 1
fi
if test -z "$dst_arg"; then
echo "$0: no destination specified." >&2
exit 1
fi
dst=$dst_arg
# If destination is a directory, append the input filename.
if test -d "$dst"; then
if test "$is_target_a_directory" = never; then
echo "$0: $dst_arg: Is a directory" >&2
exit 1
fi
dstdir=$dst
dstbase=`basename "$src"`
case $dst in
*/) dst=$dst$dstbase;;
*) dst=$dst/$dstbase;;
esac
dstdir_status=0
else
dstdir=`dirname "$dst"`
test -d "$dstdir"
dstdir_status=$?
fi
fi
case $dstdir in
*/) dstdirslash=$dstdir;;
*) dstdirslash=$dstdir/;;
esac
obsolete_mkdir_used=false
if test $dstdir_status != 0; then
case $posix_mkdir in
'')
# Create intermediate dirs using mode 755 as modified by the umask.
# This is like FreeBSD 'install' as of 1997-10-28.
umask=`umask`
case $stripcmd.$umask in
# Optimize common cases.
*[2367][2367]) mkdir_umask=$umask;;
.*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;;
*[0-7])
mkdir_umask=`expr $umask + 22 \
- $umask % 100 % 40 + $umask % 20 \
- $umask % 10 % 4 + $umask % 2
`;;
*) mkdir_umask=$umask,go-w;;
esac
# With -d, create the new directory with the user-specified mode.
# Otherwise, rely on $mkdir_umask.
if test -n "$dir_arg"; then
mkdir_mode=-m$mode
else
mkdir_mode=
fi
posix_mkdir=false
case $umask in
*[123567][0-7][0-7])
# POSIX mkdir -p sets u+wx bits regardless of umask, which
# is incompatible with FreeBSD 'install' when (umask & 300) != 0.
;;
*)
# Note that $RANDOM variable is not portable (e.g. dash); Use it
# here however when possible just to lower collision chance.
tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
trap 'ret=$?; rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" 2>/dev/null; exit $ret' 0
# Because "mkdir -p" follows existing symlinks and we likely work
# directly in world-writeable /tmp, make sure that the '$tmpdir'
# directory is successfully created first before we actually test
# 'mkdir -p' feature.
if (umask $mkdir_umask &&
$mkdirprog $mkdir_mode "$tmpdir" &&
exec $mkdirprog $mkdir_mode -p -- "$tmpdir/a/b") >/dev/null 2>&1
then
if test -z "$dir_arg" || {
# Check for POSIX incompatibilities with -m.
# HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
# other-writable bit of parent directory when it shouldn't.
# FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
test_tmpdir="$tmpdir/a"
ls_ld_tmpdir=`ls -ld "$test_tmpdir"`
case $ls_ld_tmpdir in
d????-?r-*) different_mode=700;;
d????-?--*) different_mode=755;;
*) false;;
esac &&
$mkdirprog -m$different_mode -p -- "$test_tmpdir" && {
ls_ld_tmpdir_1=`ls -ld "$test_tmpdir"`
test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
}
}
then posix_mkdir=:
fi
rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir"
else
# Remove any dirs left behind by ancient mkdir implementations.
rmdir ./$mkdir_mode ./-p ./-- "$tmpdir" 2>/dev/null
fi
trap '' 0;;
esac;;
esac
if
$posix_mkdir && (
umask $mkdir_umask &&
$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
)
then :
else
# The umask is ridiculous, or mkdir does not conform to POSIX,
# or it failed possibly due to a race condition. Create the
# directory the slow way, step by step, checking for races as we go.
case $dstdir in
/*) prefix='/';;
[-=\(\)!]*) prefix='./';;
*) prefix='';;
esac
oIFS=$IFS
IFS=/
set -f
set fnord $dstdir
shift
set +f
IFS=$oIFS
prefixes=
for d
do
test X"$d" = X && continue
prefix=$prefix$d
if test -d "$prefix"; then
prefixes=
else
if $posix_mkdir; then
(umask=$mkdir_umask &&
$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
# Don't fail if two instances are running concurrently.
test -d "$prefix" || exit 1
else
case $prefix in
*\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
*) qprefix=$prefix;;
esac
prefixes="$prefixes '$qprefix'"
fi
fi
prefix=$prefix/
done
if test -n "$prefixes"; then
# Don't fail if two instances are running concurrently.
(umask $mkdir_umask &&
eval "\$doit_exec \$mkdirprog $prefixes") ||
test -d "$dstdir" || exit 1
obsolete_mkdir_used=true
fi
fi
fi
if test -n "$dir_arg"; then
{ test -z "$chowncmd" || $doit $chowncmd "$dst"; } &&
{ test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } &&
{ test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false ||
test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1
else
# Make a couple of temp file names in the proper directory.
dsttmp=${dstdirslash}_inst.$$_
rmtmp=${dstdirslash}_rm.$$_
# Trap to clean up those temp files at exit.
trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
# Copy the file name to the temp name.
(umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") &&
# and set any options; do chmod last to preserve setuid bits.
#
# If any of these fail, we abort the whole thing. If we want to
# ignore errors from any of these, just make sure not to ignore
# errors from the above "$doit $cpprog $src $dsttmp" command.
#
{ test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } &&
{ test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } &&
{ test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } &&
{ test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } &&
# If -C, don't bother to copy if it wouldn't change the file.
if $copy_on_change &&
old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` &&
new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` &&
set -f &&
set X $old && old=:$2:$4:$5:$6 &&
set X $new && new=:$2:$4:$5:$6 &&
set +f &&
test "$old" = "$new" &&
$cmpprog "$dst" "$dsttmp" >/dev/null 2>&1
then
rm -f "$dsttmp"
else
# Rename the file to the real destination.
$doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null ||
# The rename failed, perhaps because mv can't rename something else
# to itself, or perhaps because mv is so ancient that it does not
# support -f.
{
# Now remove or move aside any old file at destination location.
# We try this two ways since rm can't unlink itself on some
# systems and the destination file might be busy for other
# reasons. In this case, the final cleanup might fail but the new
# file should still install successfully.
{
test ! -f "$dst" ||
$doit $rmcmd -f "$dst" 2>/dev/null ||
{ $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
{ $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }
} ||
{ echo "$0: cannot unlink or rename $dst" >&2
(exit 1); exit 1
}
} &&
# Now rename the file to the real destination.
$doit $mvcmd "$dsttmp" "$dst"
}
fi || exit 1
trap '' 0
fi
done
# Local variables:
# eval: (add-hook 'before-save-hook 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-time-zone: "UTC0"
# time-stamp-end: "; # UTC"
# End:

11251
build/ltmain.sh Normal file

File diff suppressed because it is too large Load Diff

215
build/missing Executable file
View File

@@ -0,0 +1,215 @@
#! /bin/sh
# Common wrapper for a few potentially missing GNU programs.
scriptversion=2018-03-07.03; # UTC
# Copyright (C) 1996-2018 Free Software Foundation, Inc.
# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
# 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, see <https://www.gnu.org/licenses/>.
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
if test $# -eq 0; then
echo 1>&2 "Try '$0 --help' for more information"
exit 1
fi
case $1 in
--is-lightweight)
# Used by our autoconf macros to check whether the available missing
# script is modern enough.
exit 0
;;
--run)
# Back-compat with the calling convention used by older automake.
shift
;;
-h|--h|--he|--hel|--help)
echo "\
$0 [OPTION]... PROGRAM [ARGUMENT]...
Run 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due
to PROGRAM being missing or too old.
Options:
-h, --help display this help and exit
-v, --version output version information and exit
Supported PROGRAM values:
aclocal autoconf autoheader autom4te automake makeinfo
bison yacc flex lex help2man
Version suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and
'g' are ignored when checking the name.
Send bug reports to <bug-automake@gnu.org>."
exit $?
;;
-v|--v|--ve|--ver|--vers|--versi|--versio|--version)
echo "missing $scriptversion (GNU Automake)"
exit $?
;;
-*)
echo 1>&2 "$0: unknown '$1' option"
echo 1>&2 "Try '$0 --help' for more information"
exit 1
;;
esac
# Run the given program, remember its exit status.
"$@"; st=$?
# If it succeeded, we are done.
test $st -eq 0 && exit 0
# Also exit now if we it failed (or wasn't found), and '--version' was
# passed; such an option is passed most likely to detect whether the
# program is present and works.
case $2 in --version|--help) exit $st;; esac
# Exit code 63 means version mismatch. This often happens when the user
# tries to use an ancient version of a tool on a file that requires a
# minimum version.
if test $st -eq 63; then
msg="probably too old"
elif test $st -eq 127; then
# Program was missing.
msg="missing on your system"
else
# Program was found and executed, but failed. Give up.
exit $st
fi
perl_URL=https://www.perl.org/
flex_URL=https://github.com/westes/flex
gnu_software_URL=https://www.gnu.org/software
program_details ()
{
case $1 in
aclocal|automake)
echo "The '$1' program is part of the GNU Automake package:"
echo "<$gnu_software_URL/automake>"
echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:"
echo "<$gnu_software_URL/autoconf>"
echo "<$gnu_software_URL/m4/>"
echo "<$perl_URL>"
;;
autoconf|autom4te|autoheader)
echo "The '$1' program is part of the GNU Autoconf package:"
echo "<$gnu_software_URL/autoconf/>"
echo "It also requires GNU m4 and Perl in order to run:"
echo "<$gnu_software_URL/m4/>"
echo "<$perl_URL>"
;;
esac
}
give_advice ()
{
# Normalize program name to check for.
normalized_program=`echo "$1" | sed '
s/^gnu-//; t
s/^gnu//; t
s/^g//; t'`
printf '%s\n' "'$1' is $msg."
configure_deps="'configure.ac' or m4 files included by 'configure.ac'"
case $normalized_program in
autoconf*)
echo "You should only need it if you modified 'configure.ac',"
echo "or m4 files included by it."
program_details 'autoconf'
;;
autoheader*)
echo "You should only need it if you modified 'acconfig.h' or"
echo "$configure_deps."
program_details 'autoheader'
;;
automake*)
echo "You should only need it if you modified 'Makefile.am' or"
echo "$configure_deps."
program_details 'automake'
;;
aclocal*)
echo "You should only need it if you modified 'acinclude.m4' or"
echo "$configure_deps."
program_details 'aclocal'
;;
autom4te*)
echo "You might have modified some maintainer files that require"
echo "the 'autom4te' program to be rebuilt."
program_details 'autom4te'
;;
bison*|yacc*)
echo "You should only need it if you modified a '.y' file."
echo "You may want to install the GNU Bison package:"
echo "<$gnu_software_URL/bison/>"
;;
lex*|flex*)
echo "You should only need it if you modified a '.l' file."
echo "You may want to install the Fast Lexical Analyzer package:"
echo "<$flex_URL>"
;;
help2man*)
echo "You should only need it if you modified a dependency" \
"of a man page."
echo "You may want to install the GNU Help2man package:"
echo "<$gnu_software_URL/help2man/>"
;;
makeinfo*)
echo "You should only need it if you modified a '.texi' file, or"
echo "any other file indirectly affecting the aspect of the manual."
echo "You might want to install the Texinfo package:"
echo "<$gnu_software_URL/texinfo/>"
echo "The spurious makeinfo call might also be the consequence of"
echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might"
echo "want to install GNU make:"
echo "<$gnu_software_URL/make/>"
;;
*)
echo "You might have modified some files without having the proper"
echo "tools for further handling them. Check the 'README' file, it"
echo "often tells you about the needed prerequisites for installing"
echo "this package. You may also peek at any GNU archive site, in"
echo "case some other package contains this missing '$1' program."
;;
esac
}
give_advice "$1" | sed -e '1s/^/WARNING: /' \
-e '2,$s/^/ /' >&2
# Propagate the correct exit status (expected to be 127 for a program
# not found, 63 for a program that failed due to version mismatch).
exit $st
# Local variables:
# eval: (add-hook 'before-save-hook 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-time-zone: "UTC0"
# time-stamp-end: "; # UTC"
# End:

148
build/test-driver Executable file
View File

@@ -0,0 +1,148 @@
#! /bin/sh
# test-driver - basic testsuite driver script.
scriptversion=2018-03-07.03; # UTC
# Copyright (C) 2011-2018 Free Software Foundation, Inc.
#
# 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, see <https://www.gnu.org/licenses/>.
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
# This file is maintained in Automake, please report
# bugs to <bug-automake@gnu.org> or send patches to
# <automake-patches@gnu.org>.
# Make unconditional expansion of undefined variables an error. This
# helps a lot in preventing typo-related bugs.
set -u
usage_error ()
{
echo "$0: $*" >&2
print_usage >&2
exit 2
}
print_usage ()
{
cat <<END
Usage:
test-driver --test-name=NAME --log-file=PATH --trs-file=PATH
[--expect-failure={yes|no}] [--color-tests={yes|no}]
[--enable-hard-errors={yes|no}] [--]
TEST-SCRIPT [TEST-SCRIPT-ARGUMENTS]
The '--test-name', '--log-file' and '--trs-file' options are mandatory.
END
}
test_name= # Used for reporting.
log_file= # Where to save the output of the test script.
trs_file= # Where to save the metadata of the test run.
expect_failure=no
color_tests=no
enable_hard_errors=yes
while test $# -gt 0; do
case $1 in
--help) print_usage; exit $?;;
--version) echo "test-driver $scriptversion"; exit $?;;
--test-name) test_name=$2; shift;;
--log-file) log_file=$2; shift;;
--trs-file) trs_file=$2; shift;;
--color-tests) color_tests=$2; shift;;
--expect-failure) expect_failure=$2; shift;;
--enable-hard-errors) enable_hard_errors=$2; shift;;
--) shift; break;;
-*) usage_error "invalid option: '$1'";;
*) break;;
esac
shift
done
missing_opts=
test x"$test_name" = x && missing_opts="$missing_opts --test-name"
test x"$log_file" = x && missing_opts="$missing_opts --log-file"
test x"$trs_file" = x && missing_opts="$missing_opts --trs-file"
if test x"$missing_opts" != x; then
usage_error "the following mandatory options are missing:$missing_opts"
fi
if test $# -eq 0; then
usage_error "missing argument"
fi
if test $color_tests = yes; then
# Keep this in sync with 'lib/am/check.am:$(am__tty_colors)'.
red='' # Red.
grn='' # Green.
lgn='' # Light green.
blu='' # Blue.
mgn='' # Magenta.
std='' # No color.
else
red= grn= lgn= blu= mgn= std=
fi
do_exit='rm -f $log_file $trs_file; (exit $st); exit $st'
trap "st=129; $do_exit" 1
trap "st=130; $do_exit" 2
trap "st=141; $do_exit" 13
trap "st=143; $do_exit" 15
# Test script is run here.
"$@" >$log_file 2>&1
estatus=$?
if test $enable_hard_errors = no && test $estatus -eq 99; then
tweaked_estatus=1
else
tweaked_estatus=$estatus
fi
case $tweaked_estatus:$expect_failure in
0:yes) col=$red res=XPASS recheck=yes gcopy=yes;;
0:*) col=$grn res=PASS recheck=no gcopy=no;;
77:*) col=$blu res=SKIP recheck=no gcopy=yes;;
99:*) col=$mgn res=ERROR recheck=yes gcopy=yes;;
*:yes) col=$lgn res=XFAIL recheck=no gcopy=yes;;
*:*) col=$red res=FAIL recheck=yes gcopy=yes;;
esac
# Report the test outcome and exit status in the logs, so that one can
# know whether the test passed or failed simply by looking at the '.log'
# file, without the need of also peaking into the corresponding '.trs'
# file (automake bug#11814).
echo "$res $test_name (exit status: $estatus)" >>$log_file
# Report outcome to console.
echo "${col}${res}${std}: $test_name"
# Register the test result, and other relevant metadata.
echo ":test-result: $res" > $trs_file
echo ":global-test-result: $res" >> $trs_file
echo ":recheck: $recheck" >> $trs_file
echo ":copy-in-global-log: $gcopy" >> $trs_file
# Local Variables:
# mode: shell-script
# sh-indentation: 2
# eval: (add-hook 'before-save-hook 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-time-zone: "UTC0"
# time-stamp-end: "; # UTC"
# End:

22288
configure vendored Executable file

File diff suppressed because it is too large Load Diff

2706
configure.ac Normal file

File diff suppressed because it is too large Load Diff

2
doc/ACCURACY Normal file
View File

@@ -0,0 +1,2 @@
We do regular testing of ISO MPEG compliant decoder accuracy, automatic with snapshot generation each night at least, with results shown on the front page of http://mpg123.org .
Since version 1.8.0, mpg123 really looks fine in that area... it's fast and sounds good;-)

110
doc/BENCHMARKING Normal file
View File

@@ -0,0 +1,110 @@
O-tone Michael Hipp: The mp3 benchmarking lie?
----------------------------------------------
Let's write a few notes about benchmarking the different mp3 decoders,
which are available. 'top' is NOT a benchmark, it's a simple check
how a program performs. The sad thing with 'top' is, that it has some
problems with the measurement of threaded programs of programs only
requesting short chunks of processor time. So, the only real test is
probably decoding a stream without threads with 100% CPU time and
measure the time how long your machine needs for it.
You can do this with mpg123 by doing a
time mpg123 -t mp3stream.mp3
or
time mpg123 -s mp3stream.mp3 > /dev/null
if you additionally want to measure the I/O time.
If you find a player, which claims to be 10 or even more times faster than the
current players: just don't believe it. A factor of 2 MAY BE possible.
Thomas's mpg123 decision process
--------------------------------
I made some tests back then when I wondered if there is a point in using another "modern" mp3 decoder for my mixing daemon. This was around Dec. 2004 till Feb. 2005 with current versions (0.59r-thorX in the case of mpg123). What follows is a copy of the DECODERS file in the dermixd distribution:
What decoder should one use?
-----
MP3
-----
mpg123 is the old-fashioned way, uncertain license, may have some problems with extraordinary files (huge id3v2 tags, other specialities?), but fast. Has EQ control; interactive frontend interface (in parts hacked by me...).
mpg321: is popular these days... interface? speed?
madplay: is becoming popular these days, handles RVA2 by itself... can't provide an interface nor EQ
speed:
decoding Dirty Guitar with NULL output, pentium-optimized (not more):
decoder user time/s
mpg123 23
madplay(hq) 46
madplay(speed) 34
mpg321(hq) 62
mpg321(speed) 49
So, there is still a strong technical point in using mpg123... even when my 366MHz-Laptop can easily handle several decoders at once with either of the programs, every percent cpu usage drags on the battery... and takes the cpu time from the real work
-----
OGG
-----
7,9M /tmp/dirty_guitar-q3.ogg
11M /tmp/dirty_guitar-q5.ogg
13M /tmp/dirty_guitar-q6.ogg
15M /tmp/dirty_guitar-q7.ogg
22M /tmp/dirty_guitar-q9.ogg
29M /tmp/dirty_guitar-q10.ogg
14M /tmp/dirty_guitar-std.mp3
101M /tmp/dirty_guitar.wav
speed of ogg123:
quality user time/s
3 31
5 36
6 38
7 39
10 55
So, with similar care as mpg123 concerning some (assembler?) optimization, ogg could well come close to "fast" mp3 decoding.
Does ist sound better, then?
A review from the new maintainer
--------------------------------
Now it's 2006, 23th of July. Still the same laptop, still the same mp3 file.
I just want to update the number for current mpg123 with the mmx optimization.
I should also see if competition (well, ogg, at least?) improved in the year that passed... but looking only at mp3, that reduces to the question if mpg123 got faster or slower.
Neither on the mpg321 site or the MAD site (ftp dir) did I find any new version. MAD is still 0.15.1b (0.15.2b for madplay), mpg321 still 0.2.10 .
Well, I can look at mplayer's mpg123 spawn called mp3lib that has been taken care for over the time.
But apart from that, will mpg123 stand alone on the field of console mp3 engines that are actively maintained???
To have at least some twist, I now measured the output of raw data to stdout (to /dev/null) instead of decoding alone. The hardware and largely the software is still the same (now kernel 2.6.11 instead of 2.6.?).
I've only used the "high quality" mad players - the earlier measurements give a hint about the difference to the "speed" variant.
mpg123-0.60-beta1, underworld_@_dirty_guitar.mp3
gcc-3.3.3
CFLAGS=-O2 -finline-functions -march=pentium2
built with the new autoconf/make system
machine in X11 running fluxbox, no active load (like a year ago)
measuring second run (with cached file)
time for -s > /dev/null decode...
pentium: 24s
pentium, MMX: 19s
pentium, MMX, gapless (runtime-disabled): 19s
pentium, MMX, gapless (also runtime-enabled): 19s
mpg321 0.2.10, high quality: 64s
madplay 0.15.2b, high quality: 56s
With the file length being m:s 9:58 (598s), for mpg123 that makes theoretical realtime cpu 3-4% for the PII-366.
Incidentally, `top` agrees there: it shows 3.0-3.3% CPU usage for the MMX/gapless binary during normal OSS playback.
I feel unable to benchmark the mp3 playback of mplayer - I don't see an option to make it decode audio as fast as possible (I only know -benhcmark and -noaudio; with esp. the latter not helping me there).

3
doc/BUGS Normal file
View File

@@ -0,0 +1,3 @@
If you find a bug, please check for and report it in the sourceforge bug tracking system:
http://sourceforge.net/tracker/?atid=733194&group_id=135704&func=browse

17
doc/CONTACT Normal file
View File

@@ -0,0 +1,17 @@
If you have a problem with some mp3 file or with your platform that should be supported by mpg123, please post on the mpg123 user mailing list
mpg123-users@lists.sourceforge.net
Any ideas for feature improvements or any other suggestions concerning development may be better placed at
mpg123-devel@lists.sourceforge.net
If you don't want to subscribe to these, you can also drop a note to
maintainer@mpg123.org
But if you want to subscribe and participate in the open discussion or just browse the mailing list archives, see
http://sourceforge.net/mail/?group_id=135704
(or just http://sourceforge.net/projects/mpg123 and click through).

82
doc/LARGEFILE Normal file
View File

@@ -0,0 +1,82 @@
Regarding largefile setup, client apps can be built three ways:
1. _FILE_OFFSET_BITS == 64 (header maps to mpg123_open_64)
2. _FILE_OFFSET_BITS == 32 (header maps to mpg123_open_32)
3. _FILE_OFFSET_BITS == <nothing> (header maps to mpg123_open)
The libmpg123 build needs to be prepared for everything. Also, it needs to keep
in mind the days before introducing large file support --- binaries should still
work with updated libmpg123. So, mpg123_open should always match what is the
default build on a platform without added settings. Those are the platform
variants:
1. 64 bit native system, long == off_t
libmpg123: mpg123_open
lfs_alias: mpg123_open_64 -> mpg123_open
lfs_wrap: <none>
2. largefile-sensitive, long = 32, off_t = 64 (if enabled)
libmpg123: mpg123_open_64
lfs_alias: mpg123_open_32 -> mpg123_open
lfs_wrap: mpg123_open -> mpg123_open_64
3. largefile, long = 32, off_t = 64 (FreeBSD)
libmpg123: mpg123_open
lfs_alias: mpg123_open_64 -> mpg123_open
lfs_wrap: <none>
This is what mpg123 does in version 1.15.4 and it works. Well, for cases 1
(Linux/Solaris x86-64) and 2 (Linux/Solaris x86). Case 3 needs to be added
properly. Actually, let's have a second look at case 2: When mpg123 is built
with --disable-largefile:
2a. largefile-sensitive, mpg123 built with off_t = 32 == long
libmpg123: mpg123_open
lfs_alias: mpg123_open_32 -> mpg123_open
lfs_wrap: <none>
So, this is still correct. Now, what about case 3? What does mpg123 do
currently, as of 1.15.4?
3a. largefile, long = 32, off_t = 64 (... and mpg123 not really aware of that)
libmpg123: mpg123_open
lfs_alias: mpg123_open_32(long) -> mpg123_open(off_t)
lfs_wrap: <none>
This is _wrong_. Luckily, this does not cause binary compatibility issues, as
mpg123_open_32 won't be called by anyone unless that someone tries to define
_FILE_OFFSET_BITS=32, which is nonsense. Perhaps old FreeBSD binaries before
LFS times? Well, back then, there was no libmpg123. So let's ignore that case.
The issue at hand is that the alias should be from mpg123_open_64 to
mpg123_open, for clients that insist on defining _FILE_OFFSET_BITS=64.
The change needed now is to fix the naming and also change the type the
alias functions use: It is not long int anymore!
Let's revisit case 1 for a moment: My old lfs_alias.c provides for the case
lfs_alias: mpg123_open -> mpg123_open_64. Is that actually possible?
What means enforcing _FILE_OFFSET_BITS=64 from the outside, which _could_
happen when libmpg123 is included someplace and folks are on the wrong side
of paranoid regarding this. So, there is
1a. 64 bit native system, long == off_t = 64 and _FILE_OFFSET_BITS=64
libmpg123: mpg123_open_64
lfs_alias: mpg123_open -> mpg123_open_64
lfs_wrap: <none>
(Works also for any system with long == off_t in any width)
Likewise, there is largefile-sensitive system with enforced 32 bits:
2b. largefile-sensitive, mpg123 with enforced _FILE_OFFSET_BITS=32
libmpg123: mpg123_open_32
lfs_alias: mpg123_open -> mpg123_open_32
lfs_wrap: <none>
All cases are supported with this significant change from 1.15.4:
Make the aliases use a defined lfs_alias_t, which can be long or off_t,
depending on what is the default type for offsets on the platform.
Folks who try _FILE_OFFSET_BITS=32 on a system that only supports
64 bit get a linking error during mpg123 build (from the _64 aliases),
which I consider to be a feature.
I salute anyone who is not confused after reading this.

22
doc/LICENSE Normal file
View File

@@ -0,0 +1,22 @@
GNU says that the license terms go into a file called COPYING.
Go over to COPYING to read the license, then.
Or...
You stay a bit with me here and read some not really important text.
You could imagine that there was some important text here, though.
You could also imagine that you were not sitting
in your office / living room / bathroom
in front of one of these evil electronic brains
(you didn't _print_ this file, did you?)
but being at some happy place, far, far away.
You could also imagine being at some unhappy place.
If you indeed are at such an unhappy place, imagine you were sitting
in your office / living room / bathroom
in front of this shiny, though evil, electronic brain.
Reading this pointless text.
Wondering about what you could have achieved in the past moments
if you wouldn't have continued reading this pointless text.
Wondering if anything is worth being achieved at all.
Or if it all is just...
pointless.

29
doc/Makemodule.am Normal file
View File

@@ -0,0 +1,29 @@
# Module for non-recursive mpg123 build system.
EXTRA_DIST += \
doc/BENCHMARKING \
doc/BUGS \
doc/CONTACT \
doc/PATENTS \
doc/README.3DNOW \
doc/README.gain \
doc/README.remote \
doc/ROAD_TO_LGPL \
doc/TODO \
doc/LICENSE \
doc/THANKS \
doc/ACCURACY \
doc/LARGEFILE \
doc/libmpg123_speed.txt \
doc/doxyhead.xhtml \
doc/doxyfoot.xhtml \
doc/doxy_examples.c \
doc/doxygen.conf \
doc/examples/mpg123_to_out123.c \
doc/examples/scan.c \
doc/examples/mpglib.c \
doc/examples/id3dump.c \
doc/examples/feedseek.c \
doc/examples/dump_seekindex.c \
doc/examples/extract_frames.c \
doc/examples/Makefile

39
doc/PATENTS Normal file
View File

@@ -0,0 +1,39 @@
Some notes about patents and mpg123 by Thomas Orgis
---------------------------------------------------
There has been a lot of confusion over mp3 (or more generic mpeg audio) patents and licensing issues due to the patents held by Fraunhofer and marketed by Thomson.
So, yes, there are patents held by Fraunhofer that are claimed to cover mpeg audio technology. There are also claims that they cover any similar technology (like OGG).
You may argue if these patents are valid at all (being illegal software patents, or being preceeded by known scientific publications), but they are internationally accepted by patent authorities and if you want to use mp3 commercially you should check
http://www.mp3licensing.org
for the Fraunhofer/Thomson opinion and their terms.
Since mpg123 is only a mpeg audio player, a good deal of patents that describe the encoding process (the tricky part) will not apply.
Also, statements from the patent holders up to now always allowed the non-commercial distribution of mpeg audio decoders without any fee.
They want you to pay for a license when you want to make money by selling a decoder, though. We don't sell mpg123.
Additionally, one should not forget the fact that the ideas are getting old; the basic (funded by government, btw.) research was somewhen back around the 80s and many patents are going to expire soon, best example in Germany:
P/DE 35 06 912 Method of transmission of an audio signal using grouping of amplitude values
Application was 22.02.1986 in Germany (and around Europe in the same time Jan/Feb 1986).
German patents last 20 years... now we have 24.07.2006. Time has come...
The idea of a patent is to make the inventor open the invention to the public by giving him some safe time to turn this invention into economical benefit.
People using (and improving!) the technology freely after that time is _the_ most important aspect of that idea.
Oh, I should mention the "core" mp3 patent (from http://gauss.ffii.org/PatentView/EP287578):
DE 3629434 / EP287578 Digital coding process
Application date in Germany was 29.08.1986 - that means that in a month from now (remember: 24.07.2006) this patent finds its natural end.
Then, there are other patents listed on the Fraunhofer/Thomson website that came very late... The one about join stereo coding was aplied for in Feb 1995. Did mpg123 implement that already back then? History is a bit blurry there...
There is a patent applied for in 1997, but probably covering encoding only. Still, even if that weren't the case - the basic decoding functionality of mpg123 didn't change that much after 1997; and they couldn't have patented existing functionality.
In general, few patents seem to cover decoders at all. Of course, with me being no lawyer, that statement is not trustworthy...
Bottom line is:
While Fraunhofer/Thomson don't want to charge free software players - they said that a long time ago, the time for they being able to place such charges is expiring or has already expired. One should really think before adding mp3pro/surround support to mpg123, though, since there are for sure more recent patents for that.
And don't forget: The progress bar is covered by a patent, too.

56
doc/README.3DNOW Normal file
View File

@@ -0,0 +1,56 @@
************************************************************************
* 3DNow! support by KIMURA Takuhiro <kim@hannah.ipc.miyakyo-u.ac.jp> *
* <kim@comtec.co.jp> *
* (http://hannah.ipc.miyakyo-u.ac.jp/kim/) *
* Syuuhei Kashiyama <squash@mb.kcom.ne.jp> *
* (http://user.ecc.u-tokyo.ac.jp/~g810370/)*
************************************************************************
-----------------------------
What's new in patch for 0.59r
-----------------------------
- 3DNow! optimized decode routine (decode_3dnow.s,dct36_3dnow.s ;
these code based Syuuhei Kashiyama's 3DNow! patch for mpg123-0.59o)
- 3DNow! optimized equalizer (equalizer_3dnow.s ; do_equalizer() only)
- target "linux-3dnow-alsa" "linux-3dnow-esd" added (untested)
- automatic detect 3DNow! support CPU from CPUFLAGS (getcpuflags.s)
(i.e. use floating-pointer decode routine if your CPU isn't support
3DNow! or MMX instructions)
-------------
Added options
-------------
"--test-3dnow" : display result of autodetect and exit
"--force-3dnow" : force use of 3DNow! optimized decoder
(it will cause SIGILL if your CPU isn't support 3DNow! or MMX
instructions)
"--no-3dnow" : force use of floating-pointer decoder
-----------
How to make
-----------
[1] To make 3DNow! optimized mpg123,you need binutils-2.9.1.0.15 or later.
You can find the most recent binutils (2.9.1.0.25 until 23.Jun.1999) at
- kernel.org (and mirrors) : /pub/linux/devel/gcc/
- http://hannah.ipc.miyakyo-u.ac.jp/kim/Linux/binutils/
(Takuhiro's local copy)
etc.
[2] Type "make linux-3dnow" (OSS)
or "make linux-3dnow-alsa" (ALSA).
[3] Enjoy!
------------------
Precompiled binary
------------------
You can get precompiled binary of mpg123 (with 3DNow! support) from
http://hannah.ipc.miyakyo-u.ac.jp/kim/Linux/mpg123/
----------
References
----------
Useful sources of information on optimizing 3DNow! code include:
- AMD 3DNow! Technology Manual (Publication #21928)
English: http://www.amd.com/K6/k6docs/pdf/21928d.pdf
(Japanese: http://www.amd.com/japan/K6/k6docs/j21928c.pdf)
- AMD-K6-2 Processor Code Optimization Application Note (Publication #21924)
English: http://www.amd.com/K6/k6docs/pdf/21924b.pdf

171
doc/README.gain Normal file
View File

@@ -0,0 +1,171 @@
Thomas Orgis on RVA, Gain and Pain
Ok, so I'm going to add RVA/ReplayGain support... the problem there is not to read these valus from ID3 or Lame, not even to do the adjustment itself.
The problem is more to figure out how to interpret the dB values one gets there.
Main players in the field of relative volume adjustment / soft gain (without modifying actual audio data):
http://www1.cs.columbia.edu/~cvaill/normalize/
...writing RVA2 ID3v2tags for dB offset to user target amplitude, default being -12dB(FS)
http://www.replaygain.org/
...store the difference to reference of 83dB(SPL) ... somewhere
Both calculate some running RMS and do statistics with this - the main difference is the potentially different target level.
Also both know two basic types of adjustment: Per track to make all tracks sound at the same sevel (track / radio) and the one with default meaning to keep the loudness relations over albums (batch / audiophile).
dB can mean many things and also the raw value of a PCM sample doesn't equal directly to loudness (power of a wave != amplitude).
So that says the ReplayGain about applying the adjustment:
scale=10.^(replay_gain/20);
luckily, this is the same that I worked out on my own for the normalize RVA values in my mixplayer script:
return 10**($s/20);
I'll take that interpretaion of dB -> linear scale factor for samples for granted, then.
The replay_gain value is meant in the standard to represent the offset to 83dB(SPL - depending on your amplifier...), having in mind that actual most wanted average playback level should be 83dB(SPL) (defined by movie ppl as the loudness of a -20dB(FS) signal, leaving room for louder stuff).
But then there is the proposal to add 6dB preamp for pop music - am I judging music types with mpg123??
These 6dB are in fact the real world since lots of programs use 89dB(SPL...) as reference.
Thus, lame since 3.95.1 (according to MADplay's Rob Leslie who discussed with Lame ppl, verified in 3.96 source) stores the adjustment to 89dB.
To make that all sound the same, one should add 6bB to lame <3.95.1 ReplayGain values and use later ones verbatim - achieving 89dB everytime, whatever that may mean in reality out of my speakers (my Marantz' volume knob doesn't have a scale at all - be it dB or percent;-).
A funny aspect of this 6dB issue is to tell lame 3.95.1 from lame 3.95
As for normalize... the desired playback level is essentially undefined. Ignoring that and realizing that mpg123 has no way to determine real world sound power anyway, one has to just take the provided dB values and apply with the formula above.
The user is responsible for providing files with his desired settings... for that reason I also won't follow the ReplayGain demand/suggestion that a player should apply an average of gains of previous tracks if the current one lacks a setting.
So, well. Considering that ReplayGain (at least the radio one) being stored by current lame on encoding, I suppose that if there are RVA2 values in ID3v2 tags, these were added by a conscious user act and are overriding the ReplayGain ones.
I already read ReplayGain entries in Lame tag... should add ID3v2 parsing. Especially since the lame tag is ambignous because of the 6dB issue... I cannot distinguish 3.95.1 from 3.95 by reading the tag - frick!
But wait... 6dB?
[thomas@thorvas /home/thomas-data/mpg123-neu/lame-3.96.1]$ frontend/lame --cbr -T /mnt/knecht_mp3/music/covenant/2006_skyshaper/03-happy_man.mp3 ../testfiles/happy_man_lame-3.96.1.mp3
ID3v2 found. Be aware that the ID3 tag is currently lost when transcoding.
LAME version 3.96.1 (http://lame.sourceforge.net/)
Using polyphase lowpass filter, transition band: 17249 Hz - 17782 Hz
Encoding /mnt/knecht_mp3/music/covenant/2006_skyshaper/03-happy_man.mp3
to ../testfiles/happy_man_lame-3.96.1.mp3
Encoding as 44.1 kHz 128 kbps j-stereo MPEG-1 Layer III (11x) qval=3
Frame | CPU time/estim | REAL time/estim | play/CPU | ETA
6371/6374 (100%)| 1:41/ 1:41| 1:47/ 1:47| 1.6353x| 0:00
average: 128.0 kbps LR: 754 (11.83%) MS: 5620 (88.17%)
Writing LAME Tag...done
ReplayGain: -7.4dB
revmethod = 1
encoder padding: 1728
[thomas@thorvas /home/thomas-data/mpg123-neu/lame-3.95.1]$ frontend/lame --cbr -T /mnt/knecht_mp3/music/covenant/2006_skyshaper/03-happy_man.mp3 ../testfiles/happy_man.mp3
ID3v2 found. Be aware that the ID3 tag is currently lost when transcoding.
LAME version 3.95 (http://www.mp3dev.org/)
Using polyphase lowpass filter, transition band: 17249 Hz - 17782 Hz
Encoding /mnt/knecht_mp3/music/covenant/2006_skyshaper/03-happy_man.mp3
to ../testfiles/happy_man.mp3
Encoding as 44.1 kHz 128 kbps j-stereo MPEG-1 Layer III (11x) qval=3
Frame | CPU time/estim | REAL time/estim | play/CPU | ETA
6371/6374 (100%)| 1:36/ 1:36| 1:48/ 1:48| 1.7289x| 0:00
average: 128.0 kbps LR: 759 (11.91%) MS: 5615 (88.09%)
Writing LAME Tag...done
ReplayGain: -7.4dB
[thomas@thorvas /home/thomas-data/mpg123-neu/lame-3.95]$ frontend/lame --cbr -T /mnt/knecht_mp3/music/covenant/2006_skyshaper/03-happy_man.mp3 ../testfiles/happy_man_lame-3.95.mp3
ID3v2 found. Be aware that the ID3 tag is currently lost when transcoding.
LAME version 3.95 (http://www.mp3dev.org/)
Using polyphase lowpass filter, transition band: 17249 Hz - 17782 Hz
Encoding /mnt/knecht_mp3/music/covenant/2006_skyshaper/03-happy_man.mp3
to ../testfiles/happy_man_lame-3.95.mp3
Encoding as 44.1 kHz 128 kbps j-stereo MPEG-1 Layer III (11x) qval=3
Frame | CPU time/estim | REAL time/estim | play/CPU | ETA
6371/6374 (100%)| 1:37/ 1:37| 1:43/ 1:43| 1.7041x| 0:00
average: 128.0 kbps LR: 759 (11.91%) MS: 5615 (88.09%)
Writing LAME Tag...done
ReplayGain: -13.4dB
Together with the gain values read from tags:
3.96.1: -1.0dB (claimed -7.4dB)
3.95: -1.0dB (claimed -7.4dB)
3.95: -0.6dB (claimed -13.4dB)
So, the difference of 6dB shows in the values lame prints on the command line... but the lame tags only have 0.4dB difference and are much lower anyway - do I parse them correctly?
Opinion of normalize of these files: -2dB. Great. I guess the -1 is what lame really meant, then...
Storage places
==============
Points 1, 2 and 4 implemented to some respect.
1. Lame/Info tag
supposedly in format according to the proposed standard - but I yet have to verify if Lame really does this.
see http://gabriel.mp3-tech.org/mp3infotag.html
2. ID3v2 RVA2 frame(s)
Normalize does that. Rare is the software reading that.
I've never seen those frames since id3v2 -l doesn't know them.
3. APE tags
Gah, another Tag format. Foobar2000 uses this as default.
It's getting real-hy messy folks
4. Per convention in ID3 tags
Well, I myself once used the ID3v1 comment field for storing the mix rva value (textual) ... but that is a tad too unspecific.
I then also used user-defined ID3v2 comments like that:
[thomas@thorvas /home/thomas-data/mpg123-neu/svn/trunk]$ id3v2 -l /mnt/knecht_mp3/music/underworld/second_toughest_in_the_infants/02-banstyle_sappys_curry.mp3
id3v1 tag info for /mnt/knecht_mp3/music/underworld/second_toughest_in_the_infants/02-banstyle_sappys_curry.mp3:
Title : banstyle sappys curry Artist: underworld
Album : second toughest in the infants Year: 0 , Genre: Other (12)
Comment: Created by Grip Track: 2
id3v2 tag info for /mnt/knecht_mp3/music/underworld/second_toughest_in_the_infants/02-banstyle_sappys_curry.mp3:
TYER (Year): 0
TRCK (Track number/Position in set): 2
COMM (Comments): (ID3v1 Comment)[XXX]: Created by Grip
TCON (Content type): Other (12)
TPE1 (Lead performer(s)/Soloist(s)): underworld
TALB (Album/Movie/Show title): second toughest in the infants
TIT2 (Title/songname/content description): banstyle sappys curry
COMM (Comments): (RVA)[]: 4.3291
COMM (Comments): (RVA_ALBUM)[]: 3.666101
That still doesn't look like a bad Idea to me. Not bothering with byte ordering and whatnot. Just atof(id3v2_comm_rva).
One could still add dB, though.
Another convention is (rockbox mailinglist, not checked myself) used by Foobar:
TXXX (User defined text information): (replaygain_track_gain): -7.17 dB
TXXX (User defined text information): (replaygain_track_peak): 1.057122
TXXX (User defined text information): (replaygain_album_gain): -6.53 dB
TXXX (User defined text information): (replaygain_album_peak): 1.107456
So what are custom comment fields for when there are also custom text fields? They look very similar to me.
5. Leave the haunted music file alone and store metadata externally.
That's the only sane way for stuff like album art... and it's the way I do it in my music archive. the wrapper script reads the adjustment values and then sets an adjusted volume.
That's fine for my mixing daemon that manupulates the pcm data anyway, but it would be nice to have this functionality in the minimalist console mode. too.
Even more since it can be done without additional cpu power during decoding (well, one-time set up of the decode tables is needed for every track) similar to the equalizer.
I could simply start with text files with lines like
RVA_MIX: 3.4dB
RVA_ALBUM: 1.7dB
Prob here is that the effort to open and parse that extra file may hinder gapless decoding between tracks...
Well, one could parse all metadata files for a list of tracks before playback starts.
But all this won't work for streams via stdin (hm, one could argue if the stream needs RVA at all).

250
doc/README.remote Normal file
View File

@@ -0,0 +1,250 @@
Control interface to generic frontends
The generic remote interface allows frontends to easily control
mpg123 by commands through stdin/stdout. To start the generic
remote interface, start mpg123 with parameter -R.
In case of a frontend that starts mpg123 with the -s option to read the audio from stdout, the --remote-err option is automatically activated to send responses to stderr so that stdout stays clean for audio.
(Still the case?)
As an example it's used by IRMP3, a tool that allows you to
control mpg123 with a standard infrared remote control. See
http://www.fasta.fh-dortmund.de/users/andy/irmp3/ for more
information.
You can also specify --fifo <path> to create a named pipe at <path> and listen on that for commands instead stdin.
That way, you can deliberately control mpg123 by echoing into the named pipe from any terminal / program.
The command respones are still sent to standard out or standard error (depending on -s or --remote-err switches).
COMMAND CODES
-------------
You can get this info via the control command "help".
HELP/H: command listing (LONG/SHORT forms), command case insensitve
LOAD/L <trackname>: load and start playing resource <trackname>
LOADPAUSED/LP <trackname>: load but do not start playing resource <trackname>
LOADLIST/LL <entry> <url>: load a playlist from given <url>, and display its entries, optionally load and play one of these specificed by the integer <entry> (<0: just list, 0: play last track, >0:play track with that position in list)
PAUSE/P: pause playback
STOP/S: stop playback (closes file)
JUMP/J <frame>|<+offset>|<-offset>|<[+|-]seconds>s: jump to mpeg frame <frame> or change position by offset, same in seconds if number followed by "s"
VOLUME/V <percent>: set volume in % (0..100...); float value
MUTE: turn on software mute in output
UNMUTE: turn off software mute in output
RVA off|(mix|radio)|(album|audiophile): set rva mode
EQ/E <channel> <band> <value>: set equalizer value for frequency band 0 to 31 on channel 1 (left) or 2 (right) or 3 (both)
EQFILE <filename>: load EQ settings from a file
SHOWEQ: show all equalizer settings (as <channel> <band> <value> lines in a SHOWEQ block (like TAG))
SEEK/K <sample>|<+offset>|<-offset>: jump to output sample position <samples> or change position by offset
SCAN: scan through the file, building seek index
SAMPLE: print out the sample position and total number of samples
FORMAT: print out sampling rate in Hz and channel count
SEQ <bass> <mid> <treble>: simple eq setting...
PITCH <[+|-]value>: adjust playback speed (+0.01 is 1 % faster)
SILENCE: be silent during playback (meaning silence in text form)
STATE: Print auxiliary state info in several lines (just try it to see what info is there).
TAG/T: Print all available (ID3) tag info, for ID3v2 that gives output of all collected text fields, using the ID3v2.3/4 4-character names. NOTE: ID3v2 data will be deleted on non-forward seeks.
The output is multiple lines, begin marked by "@T {", end by "@T }".
ID3v1 data is like in the @I info lines (see below), just with "@T" in front.
An ID3v2 data field is introduced via ([ ... ] means optional):
@T ID3v2.<NAME>[ [lang(<LANG>)] desc(<description>)]:
The lines of data follow with "=" prefixed:
@T =<one line of content in UTF-8 encoding>
meaning of the @S stream info:
S <mpeg-version> <layer> <sampling freq> <mode(stereo/mono/...)> <mode_ext> <framesize> <stereo> <copyright> <error_protected> <emphasis> <bitrate> <extension> <vbr(0/1=yes/no)>
The @I lines after loading a track give some ID3 info, the format:
@I ID3:artist album year comment genretext
where artist,album and comment are exactly 30 characters each, year is 4 characters, genre text unspecified.
You will encounter "@I ID3.genre:<number>" and "@I ID3.track:<number>".
Then, there is an excerpt of ID3v2 info in the structure
@I ID3v2.title:Blabla bla Bla
for every line of the "title" data field. Likewise for other fields (author, album, etc).
RESPONSE CODES
--------------
Note: mpg123 returns errors on stderr, so your frontend should
look not only at stdout but also at stderr for responses.
It is a good idea to use --remote-err and just look at stderr.
@R MPG123 (ThOr) v7
Startup version message. Everything after MPG123 is auxilliary information about behaviour and command support, ID3v2 tag support is new in v3.
@I ID3:<a><b><c>
Status message after loading a song (ID3 song info)
a = title (exactly 30 chars)
b = artist (exactly 30 chars)
c = album (exactly 30 chars)
d = year (exactly 4 chars)
e = comment (exactly 30 chars)
f = genre (string)
@I ID3.genre:<number>
@I ID3.track:<number>
Optional lines with additional ID3v1 info (if present): Genre ID and track number in set.
@I ID3v2.title:<text>
After loading a track with ID3v2 info, such lines occur for every line of the "title" data field and likewise for other fields (author, album, etc).
Since version 9, ID3 info is wrapped in
@I {
...
@I }
to guide parsers.
@I <a>
Status message after loading a song (no ID3 song info)
a = filename without path and extension
@I LISTENTRY <n>: <url>
printout of playlists loaded with LOADLIST
Since version 9, list printout is wrapped in
@I {
...
@I }
to help parsers decide if they got the whole list.
@S <a> <b> ...
Stream info at beginning of playback, meaning
S <mpeg-version> <layer> <sampling freq> <mode(stereo/mono/...)> <mode_ext> <framesize> <stereo> <copyright> <error_protected> <emphasis> <bitrate> <extension> <vbr(0/1=yes/no)>
@S <a> <b> <c> <d> <e> <f> <g> <h> <i> <j> <k> <l>
Status message after loading a song (stream info)
a = mpeg type (string)
b = layer (int)
c = sampling frequency (int)
d = mode (string)
e = mode extension (int)
f = framesize (int)
g = stereo (int)
h = copyright (int)
i = error protection (int)
j = emphasis (int)
k = bitrate (int)
l = extension (int)
@F <a> <b> <c> <d>
Status message during playing (frame info)
a = framecount (int)
b = frames left this song (int)
c = seconds (float)
d = seconds left (float)
@P <a>
Playing status
a = 0: playing stopped
a = 1: playing paused
a = 2: playing unpaused
@E <a>
An error occured
Errors may be also reported by mpg123 through
stderr (without @E)
a = error message (string)
@J <n>
Jumped to frame n.
@RVA <mode>
Switched to specified RVA mode.
@V <volume>%
Set volume to specified value (float, percent).
@<x> : <y> : <z>
Set equalizer value z for band y of channel x.
@bass: <b> mid: <m> treble: <t>
Set simple equalizer control for bass, mid, treble.
@T <response from TAG command>
The output is multiple lines, begin marked by "@T {", end by "@T }".
ID3v1 data is like in the @I info lines, just with "@T" in front.
An ID3v2 data field is introduced via ([ ... ] means optional):
@T ID3v2.<NAME>[ [lang(<LANG>)] desc(<description>)]:
The lines of data follow with "=" prefixed:
@T =<one line of content in UTF-8 encoding>
EQUALIZER CONTROL (History)
---------------------------
WARNING: The interpretation of the command arguments changed. The channel is either 1 or 2 or 3 (left, right, both).
It used to be 0 or 1 for left or right but the change slipped through during libmpg123 work and now it is a fact.
Sorry.
Cold Feet Audio Patch for MPG123
10.07.2002
This is a dirty little hack to enable the equalizer in mpg123's
generic_control interface. It works like this, there are two
different channels on the equalizer and 32 frequencys.
The hack just enables mpg123's built in equalizer to run real-time.
We haven't built in any capability to save the eq, you're frontend
will have to handle that part, and init the eq on the startup of
mpg123.
K, it works like this:
#./mpg123 -R - <---- This command will start mpg123 in 'frontend' mode.
If you want to send it some eq values you'd send it:
eq X Y V[ENTER]
X = The channel. It can be either 0 or 1. I haven't put any error checking
in, so it probably wouldn't be a good idea to go out of bounds. (integer)
Y = This is the frequency, it can be 0 to 31. 0 being closer to treble and
31 being closer to bass. (integer)
V = The raw value of your equalizer setting. I've found that the values work
best between 0.00 and 3.00. When mpg123 starts up, all of them are set
to 1.00.
OK, have fun! If you have any questions or found some bugs, please contact
nutcase@dtmf.org
Thanks,
nut
Note by Thomas Orgis: The contact appears to be dead.

270
doc/ROAD_TO_LGPL Normal file
View File

@@ -0,0 +1,270 @@
The License of mpg123
=====================
by Thomas Orgis <thomas@orgis.org>
1. Story: The Odyssey, The Decision
-----------------------------------
This is the 17th of July in the year 2006, after half a year of preparation and the contributor email campaign running for over 3 months, I'm going to draw a conclusion about the licensing of the mpg123 project.
The license conditions of mpg123 have been subject to dispute and rejection by parts of the free software world in the past...
We want to have it straight now.
Michael doesn't have much freetime to maintain the code and bother with requests by companies wanting to use mpglib.
So, he already decided to place mpglib under LGPL and mpg123 under GPL in the past.
Now, after I applied for taking over maintainership we decided on placing as much code of the whole project as possible under LGPL to ease future code migration and merging between mpg123 and mpglib.
That decision was followed by a lot of work to track down as many contributors to both Michael's development tree and my -thor one as possible to ask them for explicit LGPL support statements.
I wrote to every Name/eMail address I could track down (including internet search for new addresses), regardless of the question if there indeed is some code left by that person.
I asked them to utter any problem they may have with LGPL license as well as contacting me if there are _no_ issues.
Of course, without having to ask again, supporters of LGPL are the initial author and the two current maintainers:
Michael Hipp
Nicholas J. Humfrey
Thomas Orgis
Also, new stuff was included with explicit LGPL permission from
Adrian Bacon
Romain Dolbeau
Guillaume Outters
Plus there is stuff pending with permission from
Zuxy Meng
Now for the folks having made suggestions and contributions over the years...
In the first round starting in March 2006 I wrote the initial mail to anyone I could get. That resulted in some positive responses - examples:
"I don't remember what I did, but LGPL is fine by me."
"No problem for me."
"Any code I may have contributed to the mpg123 project at any time in the
past are hereby licensed to you under the GNU Lesser General Public"
"it's fine with me if mpg123 goes LGPL.
However, my contribution to mpg123 was very minor, and I'm not even sure if
any of my code is still in the current version."
A good number of eMail addresses is just broken (years have passed...) and another good number of addresses are either totally unknown or not known to be good or bad since no response (not even bounce - thanks, spam!) came back in over 3 months.
Some statistics for the first run: 86 total , 15 positive, 37 broken email, 34 unknown
Positive:
Andreas Neuhaus
Chris Butler
Colin Watson
Daniel Kobras
Daniel O'Connor
Daniel Skarda
Erik B. Andersen
Helge Deller
Juergen Schoew
Martin Denn
Munechika SUMIKAWA
Oliver Fromme
Petr Stehlik
Robert Bihlmeyer
Samuel Audet
Shane Wegner
Stefan Bieschewski
Steven Schultz
Tillmann Steinbrecher
Tomas Oegren
Tommi Virtanen
Then, an investigation of the code revealed a core of people having actually left traces in the code.
Some more effort was put in tracking them down, with the partial success of having found some new, working email addresses and thus having some more positive responses .
But also, it showed that the main number of people is not reachable anymore.
Creators (of a whole file, driver...): 16 total, 5 positive, 2 broken email, 9 unknown
Positive:
Andreas Neuhaus
Juergen Schoew
Oliver Fromme
Petr Stehlik
Samuel Audet
Modders: 7 total, 1 positive, 2 broken mail, 4 unknown
Positive:
Tomas Oegren
That shows two things:
1. It's impossible to get a response from everyone having contributed in some way.
2. Everyone who I reached supports the license change to LGPL
So, for the sake of getting a reasonable step forward, I'm going to close the case.
There are three categories of code:
1. written by Michael or some other contributor who explicitly supports LGPL
Clear case: LGPL
2. contributed years ago without license notice
The grounded assumption of can be made that the contributor accepted Michael's conditions, esp. the part about the software being available without cost.
Furthermore they gave the code into Michael's hands or placed patches in the internet without any claims concerning commercial uses - wich were not covered by the old COPYING file.
Based on the assumption of acceptance for the mpg123 COPYING file and the included rule of Michael's decision for any further use, this code is to be placed under LGPL by Michael's decision.
3. contributed with notice
Some code includes a note about it being GPL. Well, one has to respect that.
That results in the bulk of mpg123 being LGPL and possibly some parts GPL only.
2. The Inventory
----------------
I will now examine the files of the mpg123 svn trunk as of 17.07.2006 with their respective legal status:
Stuff added by current maintainers, thus being LGPL:
scripts/debugdef.pl
AUTHORS
autogen.sh
configure.ac
Makefile.am
MakeLegacy.sh
src/audio_jack.c
src/audio_libao.c
src/Makefile.am
src/audio_alsa09.c
src/config.h.legacy
src/debug.h
src/layer3.h
Non-Code files from Michael, maintainers or just trivial content (safely LGPL, then):
BENCHMARKING
BUGS
CHANGES
equalize.dat
INSTALL
mpg123.1
COPYING
TODO
README
README.3DNOW
README.cfa
README.new
README.remote
README.thor
README.WIN32
test.pl
BENCHMARKING.thor
CONTACT
sources under LGPLv2.1:
by Michael:
audio.c
audio_dummy.c
audio.h
audio_hp.c
audio_oss.c
audio_sun.c
common.c
common.h
dct64.c
dct64_i386.c
decode_2to1.c
decode_4to1.c
decode.c
decode_i386.c
decode_ntom.c
Makefile.legacy
equalizer.c
getbits.c
getbits.h
huffman.h
l2tables.h
layer1.c
layer2.c
layer3.c
mpg123.c
mpg123.h
readers.c
system.c
tabinit.c
term.c
term.h
by contributors:
audio_aix.c: Juergen Schoew, Tomas Oegren, Niklas Edmundsson
audio_alib.c: Erwan Ducroquet
audio_esd.c: Eric B. Mitchell
audio_macosx.c: Guillaume Outters
audio_mint.c: Petr Stehlik
audio_nas.c: Martin Denn
audio_os2.c: Samuel Audet
audio_sgi.c: Thomas Woerner
audio_win32.c: Tony Million
buffer.c: Oliver Fromme
buffer.h: Daniel Kobras / Oliver Fromme
control_generic.c: Andreas Neuhaus, Michael Hipp, Thomas Orgis
dct36_3dnow.s: Syuuhei Kashiyama
dct64_3dnow.s: Syuuhei Kashiyama
dct64_altivec.c: Romain Dolbeau
dct64_i486.c: Fabrice Bellard
decode_3dnow.s: Syuuhei Kashiyama
decode_i486.c: Fabrice Bellard
decode_i586_dither.s: Stefan Bieschewski, Adrian Bacon
decode_i586.s: Stefan Bieschewski
decode_MMX.s: higway
dct64_MMX.s: higway
tabinit_MMX.s: higway
equalizer_3dnow.s: KIMURA Takuhiro
genre.h: Shane Wegner
getcpuflags.s: KIMURA Takuhiro
getlopt.c: Oliver Fromme
getlopt.h: Oliver Fromme
httpget.c: Oliver Fromme
wav.c: Samuel Audet
xfermem.c: Oliver Fromme
xfermem.h: Oliver Fromme
Makefile.win32: Michael Hipp / Tony Million
GPLv2
audio_alsa.c: by Anders Semb Hermansen, Jaroslav Kysela, Ville Syrjala
To be removed from distribution and thus not licensed in any special way:
precompiled/
tools/
The mpglib source is not part of the core mpg123 distribution anymore - it's written by Michael, it's LGPL, it shall become a real library with own distribution and be married to mpg123 again.
3. Conclusion
-------------
The decoder core Michael's work and under LGPL without question.
Oliver Fromme is more of a co-author than "just" a project contributor, but he explicitly agreed to LGPL anyway.
So, the core functionality is really safe without doubt.
Contributors added mainly output drivers (perhaps coming from some freely available reference implementation) and CPU optimizations.
Having explicit permission from a good deal of major contributors, the LGPL is quite comfortable here, too.
I won't hide that there are explicit statements missing for MMX and 3DNow! optimizations (and the i486 opt, for that matter) due to unreachable authors.
But I feel safe to make it LGPL there, too, because of the argument of them having given the code to Michael to incorporate it into mpg123 - without any own terms, implying that they agree to Michael's terms.
There is one file left that carries an explicit GPL (_no_ LGPL) statement: the old alsa output. This file won't work on current Linux systems, anyway.
Alsa is available through libao. There will probably be a new alsa output.
So, even that one GPL exception may vanish in future, but I'll keep it for now as there may be someone who still has an alsa installation for that it works.
For now that means mpg123 is LGPL with the exception of one file that is GPL only.
End.

13
doc/THANKS Normal file
View File

@@ -0,0 +1,13 @@
There are authors who write code and there are people who point us to what code to write, show us our errors and generally are trying hard to compensate the time the developers spent coding and not actually using the software.
These people are very valuable, indeed - let's thank our
Testers (alphapetical):
- Gabor Z. Papp
- "Gates Fan"
- JonY
- Serge Simon and the R.O.M. 106.5 FM Team (http://www.rom.lu/)
who motivated the --loop and --timeout modes and furthermore supported the maintainer with a donation on sf.net and a real bottle of wine from Luxembourg!
- Willy Tarreau
Heck, let's thank all of you who contributed bug reports, suggestions... those who took mpg123 source and compiled it on uncommon platforms.

8
doc/TODO Normal file
View File

@@ -0,0 +1,8 @@
From Michael (some time after/around pre-0.59s):
- add CRC check.
- optimize layer2.c:
step_two: fraction as pointer ..
process first channel 0 than channel 1
copy channel 0 to channel 1 for: i >= jsbound
- MPEG system stream decoder

21
doc/doxy_examples.c Normal file
View File

@@ -0,0 +1,21 @@
/** \defgroup mpg123_examples example programs using libmpg123 and libout123
@{ */
/** \file mpg123_to_out123.c A simple MPEG audio to WAV converter using libmpg123 (read) and libout123 (write).
...an excersize on two simple APIs. */
/** \file mpglib.c Example program mimicking the old mpglib test program.
It takes an MPEG bitstream from standard input and writes raw audio to standard output.
This is an use case of the mpg123_decode() in and out function in the feeder mode, quite close to classic mpglib usage and thus a template to convert from that to libmpg123.
*/
/** \file scan.c Example program that examines the exact length of an MPEG file.
It opens a list of files and does mpg123_scan() on each and reporting the mpg123_length() before and after that. */
/** \file id3dump.c Parse ID3 info and print to standard output. */
/** \file extract_frames.c Parse stream and extract only the valid MPEG frames to standard output. */
/** \file feedseek.c Fuzzy feeder seeking. */
/** @} */

1
doc/doxyfoot.xhtml Normal file
View File

@@ -0,0 +1 @@
<!--#include virtual="/footer.html" -->

53
doc/doxygen.conf Normal file
View File

@@ -0,0 +1,53 @@
# This file describes the settings to be used by the documentation system
# doxygen (www.doxygen.org) for a project
#
PROJECT_NAME = "mpg123 library family"
OUTPUT_DIRECTORY = .
CREATE_SUBDIRS = NO
OUTPUT_LANGUAGE = English
FULL_PATH_NAMES = NO
INPUT = \
doxy_examples.c \
examples/mpg123_to_out123.c \
examples/mpglib.c \
examples/scan.c \
examples/feedseek.c \
examples/extract_frames.c \
examples/id3dump.c \
../src/libmpg123/mpg123.h \
../src/libmpg123/fmt123.h \
../src/libout123/out123.h \
../src/libsyn123/syn123.h \
#OPTIMIZE_OUTPUT_FOR_C = YES
EXTRACT_ALL = NO
HIDE_UNDOC_MEMBERS = NO
QUIET = YES
WARNINGS = YES
SOURCE_BROWSER = YES
GENERATE_HTML = YES
HTML_OUTPUT = html
DISABLE_INDEX = YES
SORT_MEMBER_DOCS = NO
SORT_BRIEF_DOCS = NO
ENUM_VALUES_PER_LINE = 2
ENABLE_PREPROCESSING = YES
MACRO_EXPANSION = YES
EXPAND_ONLY_PREDEF = YES
PREDEFINED = EXPORT= MPG123_ENUM_API
GENERATE_HTML = YES
GENERATE_LATEX = YES
GENERATE_RTF = NO
GENERATE_MAN = YES
MAN_LINKS = YES
GENERATE_XML = NO
HTML_HEADER = doxyhead.xhtml
HTML_FOOTER = doxyfoot.xhtml
HTML_FILE_EXTENSION = .shtml

18
doc/doxyhead.xhtml Normal file
View File

@@ -0,0 +1,18 @@
<!--#include virtual="/header.html" -->
<title>$title</title>
<link href="/doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<!--#include virtual="/top.shtml" -->
<h1>API documentation for libmpg123, libout123, and libsyn123</h1>
<div style="padding:1em;">
<strong>Note:</strong>
This API doc is automatically generated from the current development version that you can get via Subversion or as a daily snapshot from <a href="http://mpg123.org/snapshot">http://mpg123.org/snapshot</a>.
There may be differences (additions) compared to the latest stable release. See
<a href="http://mpg123.org/cgi-bin/viewvc.cgi/trunk/NEWS.libmpg123?view=markup">NEWS.libmpg123</a>,
<a href="http://mpg123.org/cgi-bin/viewvc.cgi/trunk/NEWS.libout123?view=markup">NEWS.libout123</a>,
<a href="http://mpg123.org/cgi-bin/viewvc.cgi/trunk/NEWS.libsyn123?view=markup">NEWS.libsyn123</a>,
and the overall <a href="http://mpg123.org/cgi-bin/viewvc.cgi/trunk/NEWS?view=markup">NEWS</a> file on libmpg123 versions and important changes between them.<br />
Let me emphasize that the policy for the lib*123 family is to always stay backwards compatible -- only <em>additions</em> are planned (and it's not yet planned to change the plans;-).
</div>
<div> <!-- for some reason, doxygen closes a div where non is open, bug in my version? -->

62
doc/examples/Makefile Normal file
View File

@@ -0,0 +1,62 @@
targets = \
feedseek \
mpg123_to_out123 \
mpg123_to_wav_replaced_io \
scan \
id3dump \
mpglib \
dump_seekindex \
extract_frames
all: $(targets)
# On largefile-aware systems you might want to use these instead:
#MPG123_CFLAGS := $(shell pkg-config --cflags libmpg123_64)
#MPG123_LDFLAGS := $(shell pkg-config --libs libmpg123_64)
# This works on sane setups where off_t is off_t, and just that.
ifeq ($(MPG123_PREFIX),)
MPG123_CFLAGS := $(shell pkg-config --cflags libmpg123)
MPG123_LDFLAGS := $(shell pkg-config --libs libmpg123)
OUT123_CFLAGS := $(shell pkg-config --cflags libout123)
OUT123_LDFLAGS := $(shell pkg-config --libs libout123)
else # Yeah, that's with GNU/Linux in mind, at least GNU ld ...
MPG123_CFLAGS := -I$(MPG123_PREFIX)/include
MPG123_LDFLAGS := -L$(MPG123_PREFIX)/lib -Wl,-rpath $(MPG123_PREFIX)/lib -lmpg123
OUT123_CFLAGS := -I$(MPG123_PREFIX)/include
OUT123_LDFLAGS := -L$(MPG123_PREFIX)/lib -Wl,-rpath $(MPG123_PREFIX)/lib -lout123
endif
# Define to any C99 compiler.
CC = cc -std=c99
CFLAGS = -O
# Oder of libs not that important here...
compile = $(CC) $(CPPFLAGS) $(CFLAGS) $(MPG123_CFLAGS)
linkflags = $(MPG123_LDFLAGS) $(LDFLAGS)
mpg123_to_out123: mpg123_to_out123.c
$(compile) -o $@ $< $(OUT123_CFLAGS) $(OUT123_LDFLAGS) $(linkflags)
mpg123_to_wav_replaced_io: mpg123_to_wav_replaced_io.c
$(compile) -o $@ $< $(OUT123_CFLAGS) $(OUT123_LDFLAGS) $(linkflags)
feedseek: feedseek.c
$(compile) -o feedseek feedseek.c $(OUT123_CFLAGS) $(OUT123_LDFLAGS) $(linkflags)
scan: scan.c
$(compile) -o scan scan.c $(linkflags)
id3dump:id3dump.c
$(compile) -o id3dump id3dump.c $(linkflags)
dump_seekindex: dump_seekindex.c
$(compile) -o dump_seekindex dump_seekindex.c $(linkflags)
mpglib: mpglib.c
$(compile) -o mpglib mpglib.c $(linkflags)
extract_frames: extract_frames.c
$(compile) -o $@ $< $(linkflags)
clean:
rm -vf $(targets)

View File

@@ -0,0 +1,44 @@
/*
dump_seekindex: Scan a mpeg file and dump its seek index.
This is example code only sensible to be considered in the public domain.
Initially written by Patrick Dehne.
*/
#include <mpg123.h>
#include <stdio.h>
#include <inttypes.h>
int main(int argc, char **argv)
{
mpg123_handle *m;
off_t* offsets;
off_t step;
size_t fill, i;
if(argc != 2)
{
fprintf(stderr, "\nI will dump the frame index of an MPEG audio file.\n");
fprintf(stderr, "\nUsage: %s <mpeg audio file>\n\n", argv[0]);
return -1;
}
#if MPG123_API_VERSION < 46
// Newer versions of the library don't need that anymore, but it is safe
// to have the no-op call present for compatibility with old versions.
mpg123_init();
#endif
m = mpg123_new(NULL, NULL);
mpg123_param(m, MPG123_RESYNC_LIMIT, -1, 0);
mpg123_param(m, MPG123_INDEX_SIZE, -1, 0);
mpg123_open(m, argv[1]);
mpg123_scan(m);
mpg123_index(m, &offsets, &step, &fill);
for(i=0; i<fill;i++) {
printf("Frame number %"PRIiMAX": file offset %"PRIiMAX"\n", (intmax_t)(i * step), (intmax_t)offsets[i]);
}
mpg123_close(m);
mpg123_delete(m);
return 0;
}

View File

@@ -0,0 +1,97 @@
/*
extract_frams: utlize the framebyframe API and mpg123_framedata to extract the MPEG frames out of a stream (strip off anything else).
This is example code only sensible to be considered in the public domain.
Initially written by Thomas Orgis.
*/
#include <mpg123.h>
/* unistd.h is not available under MSVC,
io.h defines the read and write functions */
#ifndef _MSC_VER
#include <unistd.h>
#else
#include <io.h>
#endif
#include <stdio.h>
#include <string.h>
/** The actual work on the existing handle. */
int do_work(mpg123_handle *m);
/** The main program. */
int main(int argc, char **argv)
{
int ret = 0;
mpg123_handle *m;
#if MPG123_API_VERSION < 46
// Newer versions of the library don't need that anymore, but it is safe
// to have the no-op call present for compatibility with old versions.
mpg123_init();
#endif
m = mpg123_new(NULL, &ret);
if(m == NULL)
{
fprintf(stderr, "Cannot create handle: %s", mpg123_plain_strerror(ret));
}
else
{
fprintf(stderr, "I'll take your dirty MPEG audio from standard input and will write the extracted pure MPEG data to standard output.\n");
if(argc > 1 && strcmp(argv[1], "--noinfo") == 0)
{
fprintf(stderr, "Enabling parsing/consuming of the Info frame so that it will not appear in output.\n");
ret = mpg123_param(m, MPG123_REMOVE_FLAGS, MPG123_IGNORE_INFOFRAME, 0.);
}
else
{
fprintf(stderr, "If you'd have given --noinfo as argument, I would omit a LAME/Xing info frame.\n");
ret = mpg123_param(m, MPG123_ADD_FLAGS, MPG123_IGNORE_INFOFRAME, 0.);
}
if(ret == 0) ret = do_work(m);
if(ret != 0) fprintf(stderr, "Some error occured: %s\n", mpg123_strerror(m));
mpg123_delete(m); /* Closes, too. */
}
return ret;
}
int do_work(mpg123_handle *m)
{
int ret;
size_t count = 0;
ret = mpg123_open_fd(m, STDIN_FILENO);
if(ret != MPG123_OK) return ret;
while( (ret = mpg123_framebyframe_next(m)) == MPG123_OK || ret == MPG123_NEW_FORMAT )
{
unsigned long header;
unsigned char *bodydata;
size_t bodybytes;
if(mpg123_framedata(m, &header, &bodydata, &bodybytes) == MPG123_OK)
{
/* Need to extract the 4 header bytes from the native storage in the correct order. */
unsigned char hbuf[4];
int i;
for(i=0; i<4; ++i) hbuf[i] = (unsigned char) ((header >> ((3-i)*8)) & 0xff);
/* Now write out both header and data, fire and forget. */
write(STDOUT_FILENO, hbuf, 4);
write(STDOUT_FILENO, bodydata, bodybytes);
fprintf(stderr, "%zu: header 0x%08lx, %zu body bytes\n", ++count, header, bodybytes);
}
}
if(ret != MPG123_DONE)
fprintf(stderr, "Some error occured (non-fatal?): %s\n", mpg123_strerror(m));
fprintf(stderr, "Done with %zu MPEG frames.\n", count);
return 0;
}

164
doc/examples/feedseek.c Normal file
View File

@@ -0,0 +1,164 @@
/*
feedseek: test program for libmpg123, showing how to use fuzzy seeking in feeder mode
This is example code only sensible to be considered in the public domain.
It takes MPEG data from standard input and feeds that to libmpg123, combined
with a fuzzy seek. Libmpg123 could access stdin in other ways directly, but
usage of the feeder API is the point here.
*/
#define _POSIX_C_SOURCE 200112L /**< POSIX standard for ftello. */
#include <mpg123.h>
#include <out123.h>
#include <stdlib.h>
#include <stdio.h>
#define INBUFF 16384 * 2 * 2 /**< input buffer size */
/** Error handling helper, end program if condition is not met.
* Yes, a goto for error handling. Controlled cleanup in a final section instead
* of just jumping out of the program.
*/
#define CHECK(cond, ...) if(!(cond)){ fprintf(stderr, __VA_ARGS__); goto bad_end; }
/** The whole operation. */
int main(int argc, char **argv)
{
unsigned char buf[INBUFF];
mpg123_handle *m = NULL;
out123_handle *o = NULL;
const char *driver = NULL;
char *device = NULL;
int ret = 0;
off_t inoffset;
off_t cur_inoffset;
off_t seek_point = 0;
off_t seek_target;
// 0. Argument parsing.
if(argc < 2)
{
fprintf(stderr, "Usage:\n\n %s <offset> [outfile] < <MPEG input data>\n", argv[0]);
fprintf( stderr, "\n"
"This will decode standard input to the default audio device or the\n"
"given output file as decoded WAV after seeking to the given PCM sample\n"
"offset to demonstrate fuzzy seeking\n" );
return 1;
}
seek_point = atol(argv[1]);
CHECK(seek_point >= 0, "No negative offset, please.\n")
if(argc >= 3)
{
driver = "wav";
device = argv[2];
}
// 1. Initialize libmpg123 and libout123 handles.
#if MPG123_API_VERSION < 46
// Newer versions of the library don't need that anymore, but it is safe
// to have the no-op call present for compatibility with old versions.
mpg123_init();
#endif
m = mpg123_new(NULL, &ret);
CHECK(m != NULL, "Unable to create mpg123 handle: %s\n", mpg123_plain_strerror(ret))
o = out123_new();
CHECK(o != NULL, "Unable to create out123 handle.\n")
ret = out123_open(o, driver, device);
CHECK(ret == OUT123_OK, "Failed to open output device: %s\n", out123_strerror(o))
mpg123_param(m, MPG123_VERBOSE, 2, 0);
mpg123_param(m, MPG123_FLAGS, MPG123_FUZZY | MPG123_SEEKBUFFER | MPG123_GAPLESS, 0);
CHECK(ret == MPG123_OK, "Unable to set library options: %s\n", mpg123_plain_strerror(ret))
// 2. Open the feeder, feed data until libmpg123 can tell us where to go in the input
// for the desired output offset.
ret = mpg123_open_feed(m);
CHECK(ret == MPG123_OK, "Unable open feed: %s\n", mpg123_plain_strerror(ret))
fprintf(stderr, "\nDetermining input offset for seek ...\n");
/* That condition is tricky... parentheses are crucial... */
while( (seek_target = mpg123_feedseek(m, seek_point, SEEK_SET, &inoffset))
== MPG123_NEED_MORE )
{
fprintf(stderr, " *** need more data before deciding on fuzzy input offset ***\n");
size_t len = fread(buf, 1, INBUFF, stdin);
if(len < 0 || (len == 0 && (feof(stdin) || ferror(stdin))))
break;
ret = mpg123_feed(m, buf, len);
CHECK(ret == MPG123_OK, "Error feeding the decoder: %s", mpg123_strerror(m))
}
CHECK(ret == MPG123_OK, "Feedseek failed: %s\n", mpg123_strerror(m))
fprintf( stderr, "Fuzzy seek to %lld, actually to %lld.\n"
, (long long)seek_point, (long long)seek_target );
CHECK(inoffset >=0 , "Bogus input offset: %lld\n", (long long)inoffset)
// 3. Go to the indicated input offset.
fprintf(stderr, "\nSeeking to input offset ...\n");
// In a normal file, we would call fseek() here, for stdin, we just consume data.
while( (cur_inoffset=ftello(stdin)) < inoffset && !ferror(stdin) )
{
CHECK(cur_inoffset >= 0, "Cannot tell input position.\n")
off_t block = inoffset - cur_inoffset;
if(block > INBUFF)
block = INBUFF;
if(fread(buf, 1, block, stdin) == 0 && feof(stdin))
break;
}
CHECK( ftello(stdin) == inoffset, "Input seeking failed: %lld != %lld\n"
, (long long)ftello(stdin), (long long)inoffset )
// 4. Feed the decoder from that point on and get the decoded audio.
fprintf(stderr, "\nStarting decode...\n");
while(1)
{
size_t len = fread(buf, sizeof(unsigned char), INBUFF, stdin);
if(len <= 0)
break;
ret = mpg123_feed(m, buf, len);
while(ret != MPG123_ERR && ret != MPG123_NEED_MORE)
{
off_t num;
unsigned char *audio;
size_t bytes;
ret = mpg123_decode_frame(m, &num, &audio, &bytes);
if(ret == MPG123_NEW_FORMAT)
{
long rate;
int channels, enc;
mpg123_getformat(m, &rate, &channels, &enc);
fprintf(stderr
, "New format: %li Hz, %i channels, encoding value %i\n"
, rate, channels, enc );
ret = out123_start(o, rate, channels, enc);
CHECK(ret == OUT123_OK, "Cannot (re)start audio output with given format.\n")
}
CHECK(out123_play(o, audio, bytes) == bytes, "Output error: %s", out123_strerror(o))
}
CHECK(ret != MPG123_ERR, "Error: %s", mpg123_strerror(m))
}
fprintf(stderr, "Finished\n");
good_end: // Everything went fine: go directly to the cleanup section.
goto end;
bad_end: // Some unspecified error, set error state and clean up.
ret = -1;
end: // Clean up and return.
out123_del(o);
mpg123_delete(m);
return ret ? EXIT_FAILURE : EXIT_SUCCESS;
}

181
doc/examples/id3dump.c Normal file
View File

@@ -0,0 +1,181 @@
/*
id3dump: Print ID3 tags of files, scanned using libmpg123.
This is example code only sensible to be considered in the public domain.
Initially written by Thomas Orgis.
*/
#include "mpg123.h"
#include <string.h>
#include "stdio.h"
#include "sys/types.h"
/** Helper for v1 printing, get these strings their zero byte. */
void safe_print(char* name, char *data, size_t size)
{
char safe[31];
if(size>30) return;
memcpy(safe, data, size);
safe[size] = 0;
printf("%s: %s\n", name, safe);
}
/** Print out ID3v1 info. */
void print_v1(mpg123_id3v1 *v1)
{
safe_print("Title", v1->title, sizeof(v1->title));
safe_print("Artist", v1->artist, sizeof(v1->artist));
safe_print("Album", v1->album, sizeof(v1->album));
safe_print("Year", v1->year, sizeof(v1->year));
safe_print("Comment", v1->comment, sizeof(v1->comment));
printf("Genre: %i", v1->genre);
}
/** Split up a number of lines separated by \\n, \\r, both or just zero byte
and print out each line with specified prefix. */
void print_lines(const char* prefix, mpg123_string *inlines)
{
size_t i;
int hadcr = 0, hadlf = 0;
char *lines = NULL;
char *line = NULL;
size_t len = 0;
if(inlines != NULL && inlines->fill)
{
lines = inlines->p;
len = inlines->fill;
}
else return;
line = lines;
for(i=0; i<len; ++i)
{
if(lines[i] == '\n' || lines[i] == '\r' || lines[i] == 0)
{
char save = lines[i]; /* saving, changing, restoring a byte in the data */
if(save == '\n') ++hadlf;
if(save == '\r') ++hadcr;
if((hadcr || hadlf) && hadlf % 2 == 0 && hadcr % 2 == 0) line = "";
if(line)
{
lines[i] = 0;
printf("%s%s\n", prefix, line);
line = NULL;
lines[i] = save;
}
}
else
{
hadlf = hadcr = 0;
if(line == NULL) line = lines+i;
}
}
}
/** Print out the named ID3v2 fields. */
void print_v2(mpg123_id3v2 *v2)
{
print_lines("Title: ", v2->title);
print_lines("Artist: ", v2->artist);
print_lines("Album: ", v2->album);
print_lines("Year: ", v2->year);
print_lines("Comment: ", v2->comment);
print_lines("Genre: ", v2->genre);
}
/** Print out all stored ID3v2 fields with their 4-character IDs. */
void print_raw_v2(mpg123_id3v2 *v2)
{
size_t i;
for(i=0; i<v2->texts; ++i)
{
char id[5];
char lang[4];
memcpy(id, v2->text[i].id, 4);
id[4] = 0;
memcpy(lang, v2->text[i].lang, 3);
lang[3] = 0;
if(v2->text[i].description.fill)
printf("%s language(%s) description(%s)\n", id, lang, v2->text[i].description.p);
else printf("%s language(%s)\n", id, lang);
print_lines(" ", &v2->text[i].text);
}
for(i=0; i<v2->extras; ++i)
{
char id[5];
memcpy(id, v2->extra[i].id, 4);
id[4] = 0;
printf( "%s description(%s)\n",
id,
v2->extra[i].description.fill ? v2->extra[i].description.p : "" );
print_lines(" ", &v2->extra[i].text);
}
for(i=0; i<v2->comments; ++i)
{
char id[5];
char lang[4];
memcpy(id, v2->comment_list[i].id, 4);
id[4] = 0;
memcpy(lang, v2->comment_list[i].lang, 3);
lang[3] = 0;
printf( "%s description(%s) language(%s): \n",
id,
v2->comment_list[i].description.fill ? v2->comment_list[i].description.p : "",
lang );
print_lines(" ", &v2->comment_list[i].text);
}
}
/** The whole operation. */
int main(int argc, char **argv)
{
int i;
mpg123_handle* m;
if(argc < 2)
{
fprintf(stderr, "\nI will print some ID3 tag fields of MPEG audio files.\n");
fprintf(stderr, "\nUsage: %s <mpeg audio file list>\n\n", argv[0]);
return -1;
}
#if MPG123_API_VERSION < 46
// Newer versions of the library don't need that anymore, but it is safe
// to have the no-op call present for compatibility with old versions.
mpg123_init();
#endif
m = mpg123_new(NULL, NULL);
for(i=1; i < argc; ++i)
{
mpg123_id3v1 *v1;
mpg123_id3v2 *v2;
int meta;
if(mpg123_open(m, argv[i]) != MPG123_OK)
{
fprintf(stderr, "Cannot open %s: %s\n", argv[i], mpg123_strerror(m));
continue;
}
mpg123_scan(m);
meta = mpg123_meta_check(m);
if(meta & MPG123_ID3 && mpg123_id3(m, &v1, &v2) == MPG123_OK)
{
printf("Tag data on %s:\n", argv[i]);
printf("\n==== ID3v1 ====\n");
if(v1 != NULL) print_v1(v1);
printf("\n==== ID3v2 ====\n");
if(v2 != NULL) print_v2(v2);
printf("\n==== ID3v2 Raw frames ====\n");
if(v2 != NULL) print_raw_v2(v2);
}
else printf("Nothing found for %s.\n", argv[i]);
mpg123_close(m);
}
mpg123_delete(m);
return 0;
}

View File

@@ -0,0 +1,169 @@
/*
mpg123_to_wav.c
This is example code only sensible to be considered in the public domain.
Initially written by Nicholas Humfrey.
The most complicated part is about the choices to make about output format,
and prepare for the unlikely case a bastard mp3 might file change it.
*/
#include <out123.h>
#include <mpg123.h>
#include <stdio.h>
#include <strings.h>
/** Print usage info. */
void usage(const char *cmd)
{
printf("Usage: %s <input> [<driver> [<output> [encoding [buffersize]]]]\n"
, cmd);
printf( "\nPlay MPEG audio from intput file to output file/device using\n"
"specified out123 driver, sample encoding and buffer size optional.\n\n" );
exit(99);
}
/** Free handles. */
void cleanup(mpg123_handle *mh, out123_handle *ao)
{
out123_del(ao);
/* It's really to late for error checks here;-) */
mpg123_close(mh);
mpg123_delete(mh);
}
/** The whole operation. */
int main(int argc, char *argv[])
{
mpg123_handle *mh = NULL;
out123_handle *ao = NULL;
char *infile = NULL;
char *driver = NULL;
char *outfile = NULL;
unsigned char* buffer = NULL;
const char *encname;
size_t buffer_size = 0;
size_t done = 0;
int channels = 0;
int encoding = 0;
int framesize = 1;
long rate = 0;
int err = MPG123_OK;
off_t samples = 0;
if(argc<2)
usage(argv[0]);
infile = argv[1];
if(argc >= 3)
driver = argv[2];
if(argc >= 4)
outfile = argv[3];
printf("Input file: %s\n", infile);
printf("Output driver: %s\n", driver ? driver : "<nil> (default)");
printf("Output file: %s\n", outfile ? outfile : "<nil> (default)");
#if MPG123_API_VERSION < 46
// Newer versions of the library don't need that anymore, but it is safe
// to have the no-op call present for compatibility with old versions.
err = mpg123_init();
#endif
if(err != MPG123_OK || (mh = mpg123_new(NULL, &err)) == NULL)
{
fprintf(stderr, "Basic setup goes wrong: %s", mpg123_plain_strerror(err));
cleanup(mh, ao);
return -1;
}
ao = out123_new();
if(!ao)
{
fprintf(stderr, "Cannot create output handle.\n");
cleanup(mh, ao);
return -1;
}
if(argc >= 5)
{ /* Make mpg123 support the desired encoding only for all rates. */
const long *rates;
size_t rate_count;
size_t i;
int enc;
/* If that is zero, you'll get the error soon enough from mpg123. */
enc = out123_enc_byname(argv[4]);
mpg123_format_none(mh);
mpg123_rates(&rates, &rate_count);
for(i=0; i<rate_count; ++i)
mpg123_format(mh, rates[i], MPG123_MONO|MPG123_STEREO, enc);
}
/* Let mpg123 work with the file, that excludes MPG123_NEED_MORE messages. */
if( mpg123_open(mh, infile) != MPG123_OK
/* Peek into track and get first output format. */
|| mpg123_getformat(mh, &rate, &channels, &encoding) != MPG123_OK )
{
fprintf( stderr, "Trouble with mpg123: %s\n", mpg123_strerror(mh) );
cleanup(mh, ao);
return -1;
}
if(out123_open(ao, driver, outfile) != OUT123_OK)
{
fprintf(stderr, "Trouble with out123: %s\n", out123_strerror(ao));
cleanup(mh, ao);
return -1;
}
/* It makes no sense for that to give an error now. */
out123_driver_info(ao, &driver, &outfile);
printf("Effective output driver: %s\n", driver ? driver : "<nil> (default)");
printf("Effective output file: %s\n", outfile ? outfile : "<nil> (default)");
/* Ensure that this output format will not change
(it might, when we allow it). */
mpg123_format_none(mh);
mpg123_format(mh, rate, channels, encoding);
encname = out123_enc_name(encoding);
printf( "Playing with %i channels and %li Hz, encoding %s.\n"
, channels, rate, encname ? encname : "???" );
if( out123_start(ao, rate, channels, encoding)
|| out123_getformat(ao, NULL, NULL, NULL, &framesize) )
{
fprintf(stderr, "Cannot start output / get framesize: %s\n"
, out123_strerror(ao));
cleanup(mh, ao);
return -1;
}
/* Buffer could be almost any size here, mpg123_outblock() is just some
recommendation. The size should be a multiple of the PCM frame size. */
buffer_size = argc >= 6 ? atol(argv[5]) : mpg123_outblock(mh);
buffer = malloc( buffer_size );
do
{
size_t played;
err = mpg123_read( mh, buffer, buffer_size, &done );
played = out123_play(ao, buffer, done);
if(played != done)
{
fprintf(stderr
, "Warning: written less than gotten from libmpg123: %li != %li\n"
, (long)played, (long)done);
}
samples += played/framesize;
/* We are not in feeder mode, so MPG123_OK, MPG123_ERR and
MPG123_NEW_FORMAT are the only possibilities.
We do not handle a new format, MPG123_DONE is the end... so
abort on anything not MPG123_OK. */
} while (done && err==MPG123_OK);
free(buffer);
if(err != MPG123_DONE)
fprintf( stderr, "Warning: Decoding ended prematurely because: %s\n",
err == MPG123_ERR ? mpg123_strerror(mh) : mpg123_plain_strerror(err) );
printf("%li samples written.\n", (long)samples);
cleanup(mh, ao);
return 0;
}

97
doc/examples/mpglib.c Normal file
View File

@@ -0,0 +1,97 @@
/*
mpglib: test program for libmpg123, in the style of the legacy mpglib test program
This is example code only sensible to be considered in the public domain.
Initially written by Thomas Orgis.
*/
#include <mpg123.h>
/* unistd.h is not available under MSVC,
io.h defines the read and write functions */
#ifndef _MSC_VER
#include <unistd.h>
#else
#include <io.h>
#endif
#ifdef _WIN32
#include <fcntl.h>
#endif
#include <stdio.h>
#define INBUFF 16384 /**< input buffer size */
#define OUTBUFF 32768 /**< output buffer size */
/** The whole operation. */
int main(int argc, char **argv)
{
size_t size;
unsigned char buf[INBUFF]; /* input buffer */
unsigned char out[OUTBUFF]; /* output buffer */
ssize_t len;
int ret;
size_t in = 0, outc = 0;
mpg123_handle *m;
#ifdef _WIN32
_setmode(_fileno(stdin),_O_BINARY);
_setmode(_fileno(stdout),_O_BINARY);
#endif
#if MPG123_API_VERSION < 46
// Newer versions of the library don't need that anymore, but it is safe
// to have the no-op call present for compatibility with old versions.
mpg123_init();
#endif
m = mpg123_new(argc > 1 ? argv[1] : NULL, &ret);
if(m == NULL)
{
fprintf(stderr,"Unable to create mpg123 handle: %s\n", mpg123_plain_strerror(ret));
return -1;
}
mpg123_param(m, MPG123_VERBOSE, 2, 0); /* Brabble a bit about the parsing/decoding. */
/* Now mpg123 is being prepared for feeding. The main loop will read chunks from stdin and feed them to mpg123;
then take decoded data as available to write to stdout. */
mpg123_open_feed(m);
if(m == NULL) return -1;
fprintf(stderr, "Feed me some MPEG audio to stdin, I will decode to stdout.\n");
while(1) /* Read and write until everything is through. */
{
len = read(0,buf,INBUFF);
if(len <= 0)
{
fprintf(stderr, "input data end\n");
break;
}
in += len;
/* Feed input chunk and get first chunk of decoded audio. */
ret = mpg123_decode(m,buf,len,out,OUTBUFF,&size);
if(ret == MPG123_NEW_FORMAT)
{
long rate;
int channels, enc;
mpg123_getformat(m, &rate, &channels, &enc);
fprintf(stderr, "New format: %li Hz, %i channels, encoding value %i\n", rate, channels, enc);
}
if(write(1,out,size) != size)
fprintf(stderr, "Output truncated.\n");
outc += size;
while(ret != MPG123_ERR && ret != MPG123_NEED_MORE)
{ /* Get all decoded audio that is available now before feeding more input. */
ret = mpg123_decode(m,NULL,0,out,OUTBUFF,&size);
if(write(1,out,size) != size)
fprintf(stderr, "Output truncated.\n");
outc += size;
}
if(ret == MPG123_ERR){ fprintf(stderr, "some error: %s", mpg123_strerror(m)); break; }
}
fprintf(stderr, "%lu bytes in, %lu bytes out\n", (unsigned long)in, (unsigned long)outc);
/* Done decoding, now just clean up and leave. */
mpg123_delete(m);
return 0;
}

48
doc/examples/scan.c Normal file
View File

@@ -0,0 +1,48 @@
/*
scan: Estimate length (sample count) of a mpeg file and compare to length from exact scan.
This is example code only sensible to be considered in the public domain.
Initially written by Thomas Orgis
*/
/* Note the lack of error checking here.
While it would be nicer to inform the user about troubles, libmpg123 is designed _not_ to bite you on operations with invalid handles , etc.
You just jet invalid results on invalid operations... */
#include <mpg123.h>
#include <stdio.h>
/** The whole operation. */
int main(int argc, char **argv)
{
mpg123_handle *m;
int i;
if(argc < 2)
{
fprintf(stderr, "\nI will give you the estimated and exact sample lengths of MPEG audio files.\n");
fprintf(stderr, "\nUsage: %s <mpeg audio file list>\n\n", argv[0]);
return -1;
}
#if MPG123_API_VERSION < 46
mpg123_init();
#endif
m = mpg123_new(NULL, NULL);
mpg123_param(m, MPG123_RESYNC_LIMIT, -1, 0); /* New in library version 0.0.1 . */
for(i = 1; i < argc; ++i)
{
off_t a, b;
mpg123_open(m, argv[i]);
a = mpg123_length(m);
mpg123_scan(m);
b = mpg123_length(m);
mpg123_close(m);
printf("File %i: estimated %li vs. scanned %li\n", i, (long)a, (long)b);
}
mpg123_delete(m);
return 0;
}

84
doc/libmpg123_speed.txt Normal file
View File

@@ -0,0 +1,84 @@
This is historic... one should make a new investigation.
What I can say that a quick test of pre0.59s versus 1.7.3 with generic decoder on my x86-64 GNU/Linux box is not able to call a winner (or looser, for that matter).
Though, 1.8.0 will make the new libmpg123 a winner, because there is new optimization code going on!
The move to libmpg123 means some more code separation / interfacing and especially the move of any local static variables into the mpg123_handle to make multiple stream handling possible.
That may very well have an impact on performance of the mpg123 decoder.
I made some tests, even using gcc's -pg option and gprof, with mixed result: SSE and MMX on my Thinkpad X31 are slower, especially the asm synth funtion, while the generic code is fine.
On the other hand, on a K6-3+ using the same gcc version 4.1.2, the library based mpg123 is _faster_ for MMX and 3DNowExt.
Epecially the mmx synth is faster... while the 3DNowExt synth is slower, too (it's the same code as SSE synth, just calling different dct64) - but speedups in other regions still make 3DNowExt of the library mpg123 more efficient.
What I can clearly say is that dropping the multi-cpu support via ./configure --with-cpu does help in for both monolithic and library mpg123, but that is no wonder as it removes indirection.
The main point stays, though: On my Thinkpad the library is slow, on the K6-3+ it's fast.
What's the point to get here? I am not sure. We're depending on the compiler optimization (btw: Intel Compiler doesn't change the relation for the Thinkpad; not tested on the K6).
I guess that for my Thinkpad another gcc version could invert the picture again...
Also, I am not sure how far I should trust the gprof analysis... but it can be right; even when there is no apparent cause for the speed difference in the code itself, it could be some effect of cache and memory access.
Some reordering of instructions and data... for sure that happened.
I'll need further numbers to conclude anything about the (positive/negative) impact my code changes have.
OK, ran the test of trunk against branches/mpg123lib on my media box with AMD Geode (AthlonXP, actually):
thomas@kiste:~$ for i in mpg123-lib mpg123-trunk; do for cpu in mmx 3dnowext sse; do echo $i $cpu; time $i/src/mpg123 --cpu $cpu -q -t /thorma/var/music/metallica/ride_the_lightning/*.mp3; done; done
mpg123-lib mmx
real 0m25.949s
user 0m25.395s
sys 0m0.534s
mpg123-lib 3dnowext
real 0m25.442s
user 0m24.863s
sys 0m0.558s
mpg123-lib sse
real 0m25.794s
user 0m25.214s
sys 0m0.562s
mpg123-trunk mmx
real 0m26.650s
user 0m26.004s
sys 0m0.626s
mpg123-trunk 3dnowext
real 0m25.886s
user 0m25.262s
sys 0m0.600s
mpg123-trunk sse
real 0m25.695s
user 0m25.136s
sys 0m0.539s
thomas@kiste:~$ for i in mpg123-lib mpg123-trunk; do for cpu in 3dnow; do echo $i $cpu; time $i/src/mpg123 --cpu $cpu -q -t /thorma/var/music/metallica/ride_the_lightning/*.mp3; done; done
mpg123-lib 3dnow
real 0m33.011s
user 0m32.365s
sys 0m0.621s
mpg123-trunk 3dnow
real 0m32.830s
user 0m32.192s
sys 0m0.619s
You can't really make a decision there. It's tight.
What worries me a bit is the total loose of 3DNow against MMX - should it be that drastic?
Well, it's higher quality, at least.
Addendum: The game on an K6-3+
On mpg123 < 1.8.0, he 3DNowExt decoder used to be slower than the 3DNow decoder. Only recently it has been observed, that the simplification of the runtime decoder choice code sped up that one significantly, towards the same performance level as the single-decoder build of mpg123 1.6.4 (-with-cpu=3dnowext_alone having broken build in later versions:-/).
We are talking about a difference of 20% here... there is something special about the K6-3+ that makes is that sensitive to how the function pointers get thrown around.
Example numbers: Dynamic x86 build of 1.6.4, 3DNowExt needs 5.9 s, 3DNow 5.6 s.
3DNowExt-only build: 4.9 s
3DNow-only build: 5.6 s
Now... dynamic build of mpg123 trunk of 2010-05-24: 3DNowExt 4.9 s, 3DNow 5.6 s. That's how it should be. One might investigate how exactly the old ways before mpg123 1.8 worked against the K6-3+ ... possibly helping performance issues seen with the mpg123 coded for MPlayer on that CPU.
--
Thomas.

37
equalize.dat Normal file
View File

@@ -0,0 +1,37 @@
# in every line, there are two values. One for the left
# and one for the right cahnnel.
# the first line is the multiplicator for the lowest frequency band
# the 32th line for the highest freq. band
#
1.0 1.0
1.0 1.0
1.0 1.0
1.0 1.0
1.0 1.0
1.0 1.0
1.0 1.0
1.0 1.0
1.0 1.0
1.0 1.0
1.0 1.0
1.0 1.0
1.0 1.0
1.0 1.0
1.0 1.0
1.0 1.0
1.0 1.0
1.0 1.0
1.0 1.0
1.0 1.0
1.0 1.0
1.0 1.0
1.0 1.0
1.0 1.0
1.0 1.0
1.0 1.0
1.0 1.0
1.0 1.0
1.0 1.0
1.0 1.0
1.0 1.0
1.0 1.0

12
libmpg123.pc.in Normal file
View File

@@ -0,0 +1,12 @@
prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@
Name: libmpg123
Description: An optimised MPEG Audio decoder
Requires:
Version: @PACKAGE_VERSION@
Libs: -L${libdir} -lmpg123
Libs.private: @LIBMPG123_LIBS@
Cflags: -I${includedir}

12
libout123.pc.in Normal file
View File

@@ -0,0 +1,12 @@
prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@
Name: libout123
Description: A streaming audio output API derived from mpg123
Requires:
Version: @PACKAGE_VERSION@
Libs: -L${libdir} -lout123
Libs.private: @LIBOUT123_LIBS@ @LIBDL@
Cflags: -I${includedir}

12
libsyn123.pc.in Normal file
View File

@@ -0,0 +1,12 @@
prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@
Name: libsyn123
Description: A signal synthesis library accompanying mpg123
Requires:
Version: @PACKAGE_VERSION@
Libs: -L${libdir} -lsyn123
Libs.private: @LIBSYN123_LIBS@
Cflags: -I${includedir}

8394
m4/libtool.m4 vendored Normal file

File diff suppressed because it is too large Load Diff

437
m4/ltoptions.m4 vendored Normal file
View File

@@ -0,0 +1,437 @@
# Helper functions for option handling. -*- Autoconf -*-
#
# Copyright (C) 2004-2005, 2007-2009, 2011-2015 Free Software
# Foundation, Inc.
# Written by Gary V. Vaughan, 2004
#
# This file is free software; the Free Software Foundation gives
# unlimited permission to copy and/or distribute it, with or without
# modifications, as long as this notice is preserved.
# serial 8 ltoptions.m4
# This is to help aclocal find these macros, as it can't see m4_define.
AC_DEFUN([LTOPTIONS_VERSION], [m4_if([1])])
# _LT_MANGLE_OPTION(MACRO-NAME, OPTION-NAME)
# ------------------------------------------
m4_define([_LT_MANGLE_OPTION],
[[_LT_OPTION_]m4_bpatsubst($1__$2, [[^a-zA-Z0-9_]], [_])])
# _LT_SET_OPTION(MACRO-NAME, OPTION-NAME)
# ---------------------------------------
# Set option OPTION-NAME for macro MACRO-NAME, and if there is a
# matching handler defined, dispatch to it. Other OPTION-NAMEs are
# saved as a flag.
m4_define([_LT_SET_OPTION],
[m4_define(_LT_MANGLE_OPTION([$1], [$2]))dnl
m4_ifdef(_LT_MANGLE_DEFUN([$1], [$2]),
_LT_MANGLE_DEFUN([$1], [$2]),
[m4_warning([Unknown $1 option '$2'])])[]dnl
])
# _LT_IF_OPTION(MACRO-NAME, OPTION-NAME, IF-SET, [IF-NOT-SET])
# ------------------------------------------------------------
# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise.
m4_define([_LT_IF_OPTION],
[m4_ifdef(_LT_MANGLE_OPTION([$1], [$2]), [$3], [$4])])
# _LT_UNLESS_OPTIONS(MACRO-NAME, OPTION-LIST, IF-NOT-SET)
# -------------------------------------------------------
# Execute IF-NOT-SET unless all options in OPTION-LIST for MACRO-NAME
# are set.
m4_define([_LT_UNLESS_OPTIONS],
[m4_foreach([_LT_Option], m4_split(m4_normalize([$2])),
[m4_ifdef(_LT_MANGLE_OPTION([$1], _LT_Option),
[m4_define([$0_found])])])[]dnl
m4_ifdef([$0_found], [m4_undefine([$0_found])], [$3
])[]dnl
])
# _LT_SET_OPTIONS(MACRO-NAME, OPTION-LIST)
# ----------------------------------------
# OPTION-LIST is a space-separated list of Libtool options associated
# with MACRO-NAME. If any OPTION has a matching handler declared with
# LT_OPTION_DEFINE, dispatch to that macro; otherwise complain about
# the unknown option and exit.
m4_defun([_LT_SET_OPTIONS],
[# Set options
m4_foreach([_LT_Option], m4_split(m4_normalize([$2])),
[_LT_SET_OPTION([$1], _LT_Option)])
m4_if([$1],[LT_INIT],[
dnl
dnl Simply set some default values (i.e off) if boolean options were not
dnl specified:
_LT_UNLESS_OPTIONS([LT_INIT], [dlopen], [enable_dlopen=no
])
_LT_UNLESS_OPTIONS([LT_INIT], [win32-dll], [enable_win32_dll=no
])
dnl
dnl If no reference was made to various pairs of opposing options, then
dnl we run the default mode handler for the pair. For example, if neither
dnl 'shared' nor 'disable-shared' was passed, we enable building of shared
dnl archives by default:
_LT_UNLESS_OPTIONS([LT_INIT], [shared disable-shared], [_LT_ENABLE_SHARED])
_LT_UNLESS_OPTIONS([LT_INIT], [static disable-static], [_LT_ENABLE_STATIC])
_LT_UNLESS_OPTIONS([LT_INIT], [pic-only no-pic], [_LT_WITH_PIC])
_LT_UNLESS_OPTIONS([LT_INIT], [fast-install disable-fast-install],
[_LT_ENABLE_FAST_INSTALL])
_LT_UNLESS_OPTIONS([LT_INIT], [aix-soname=aix aix-soname=both aix-soname=svr4],
[_LT_WITH_AIX_SONAME([aix])])
])
])# _LT_SET_OPTIONS
## --------------------------------- ##
## Macros to handle LT_INIT options. ##
## --------------------------------- ##
# _LT_MANGLE_DEFUN(MACRO-NAME, OPTION-NAME)
# -----------------------------------------
m4_define([_LT_MANGLE_DEFUN],
[[_LT_OPTION_DEFUN_]m4_bpatsubst(m4_toupper([$1__$2]), [[^A-Z0-9_]], [_])])
# LT_OPTION_DEFINE(MACRO-NAME, OPTION-NAME, CODE)
# -----------------------------------------------
m4_define([LT_OPTION_DEFINE],
[m4_define(_LT_MANGLE_DEFUN([$1], [$2]), [$3])[]dnl
])# LT_OPTION_DEFINE
# dlopen
# ------
LT_OPTION_DEFINE([LT_INIT], [dlopen], [enable_dlopen=yes
])
AU_DEFUN([AC_LIBTOOL_DLOPEN],
[_LT_SET_OPTION([LT_INIT], [dlopen])
AC_DIAGNOSE([obsolete],
[$0: Remove this warning and the call to _LT_SET_OPTION when you
put the 'dlopen' option into LT_INIT's first parameter.])
])
dnl aclocal-1.4 backwards compatibility:
dnl AC_DEFUN([AC_LIBTOOL_DLOPEN], [])
# win32-dll
# ---------
# Declare package support for building win32 dll's.
LT_OPTION_DEFINE([LT_INIT], [win32-dll],
[enable_win32_dll=yes
case $host in
*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-cegcc*)
AC_CHECK_TOOL(AS, as, false)
AC_CHECK_TOOL(DLLTOOL, dlltool, false)
AC_CHECK_TOOL(OBJDUMP, objdump, false)
;;
esac
test -z "$AS" && AS=as
_LT_DECL([], [AS], [1], [Assembler program])dnl
test -z "$DLLTOOL" && DLLTOOL=dlltool
_LT_DECL([], [DLLTOOL], [1], [DLL creation program])dnl
test -z "$OBJDUMP" && OBJDUMP=objdump
_LT_DECL([], [OBJDUMP], [1], [Object dumper program])dnl
])# win32-dll
AU_DEFUN([AC_LIBTOOL_WIN32_DLL],
[AC_REQUIRE([AC_CANONICAL_HOST])dnl
_LT_SET_OPTION([LT_INIT], [win32-dll])
AC_DIAGNOSE([obsolete],
[$0: Remove this warning and the call to _LT_SET_OPTION when you
put the 'win32-dll' option into LT_INIT's first parameter.])
])
dnl aclocal-1.4 backwards compatibility:
dnl AC_DEFUN([AC_LIBTOOL_WIN32_DLL], [])
# _LT_ENABLE_SHARED([DEFAULT])
# ----------------------------
# implement the --enable-shared flag, and supports the 'shared' and
# 'disable-shared' LT_INIT options.
# DEFAULT is either 'yes' or 'no'. If omitted, it defaults to 'yes'.
m4_define([_LT_ENABLE_SHARED],
[m4_define([_LT_ENABLE_SHARED_DEFAULT], [m4_if($1, no, no, yes)])dnl
AC_ARG_ENABLE([shared],
[AS_HELP_STRING([--enable-shared@<:@=PKGS@:>@],
[build shared libraries @<:@default=]_LT_ENABLE_SHARED_DEFAULT[@:>@])],
[p=${PACKAGE-default}
case $enableval in
yes) enable_shared=yes ;;
no) enable_shared=no ;;
*)
enable_shared=no
# Look at the argument we got. We use all the common list separators.
lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR,
for pkg in $enableval; do
IFS=$lt_save_ifs
if test "X$pkg" = "X$p"; then
enable_shared=yes
fi
done
IFS=$lt_save_ifs
;;
esac],
[enable_shared=]_LT_ENABLE_SHARED_DEFAULT)
_LT_DECL([build_libtool_libs], [enable_shared], [0],
[Whether or not to build shared libraries])
])# _LT_ENABLE_SHARED
LT_OPTION_DEFINE([LT_INIT], [shared], [_LT_ENABLE_SHARED([yes])])
LT_OPTION_DEFINE([LT_INIT], [disable-shared], [_LT_ENABLE_SHARED([no])])
# Old names:
AC_DEFUN([AC_ENABLE_SHARED],
[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[shared])
])
AC_DEFUN([AC_DISABLE_SHARED],
[_LT_SET_OPTION([LT_INIT], [disable-shared])
])
AU_DEFUN([AM_ENABLE_SHARED], [AC_ENABLE_SHARED($@)])
AU_DEFUN([AM_DISABLE_SHARED], [AC_DISABLE_SHARED($@)])
dnl aclocal-1.4 backwards compatibility:
dnl AC_DEFUN([AM_ENABLE_SHARED], [])
dnl AC_DEFUN([AM_DISABLE_SHARED], [])
# _LT_ENABLE_STATIC([DEFAULT])
# ----------------------------
# implement the --enable-static flag, and support the 'static' and
# 'disable-static' LT_INIT options.
# DEFAULT is either 'yes' or 'no'. If omitted, it defaults to 'yes'.
m4_define([_LT_ENABLE_STATIC],
[m4_define([_LT_ENABLE_STATIC_DEFAULT], [m4_if($1, no, no, yes)])dnl
AC_ARG_ENABLE([static],
[AS_HELP_STRING([--enable-static@<:@=PKGS@:>@],
[build static libraries @<:@default=]_LT_ENABLE_STATIC_DEFAULT[@:>@])],
[p=${PACKAGE-default}
case $enableval in
yes) enable_static=yes ;;
no) enable_static=no ;;
*)
enable_static=no
# Look at the argument we got. We use all the common list separators.
lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR,
for pkg in $enableval; do
IFS=$lt_save_ifs
if test "X$pkg" = "X$p"; then
enable_static=yes
fi
done
IFS=$lt_save_ifs
;;
esac],
[enable_static=]_LT_ENABLE_STATIC_DEFAULT)
_LT_DECL([build_old_libs], [enable_static], [0],
[Whether or not to build static libraries])
])# _LT_ENABLE_STATIC
LT_OPTION_DEFINE([LT_INIT], [static], [_LT_ENABLE_STATIC([yes])])
LT_OPTION_DEFINE([LT_INIT], [disable-static], [_LT_ENABLE_STATIC([no])])
# Old names:
AC_DEFUN([AC_ENABLE_STATIC],
[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[static])
])
AC_DEFUN([AC_DISABLE_STATIC],
[_LT_SET_OPTION([LT_INIT], [disable-static])
])
AU_DEFUN([AM_ENABLE_STATIC], [AC_ENABLE_STATIC($@)])
AU_DEFUN([AM_DISABLE_STATIC], [AC_DISABLE_STATIC($@)])
dnl aclocal-1.4 backwards compatibility:
dnl AC_DEFUN([AM_ENABLE_STATIC], [])
dnl AC_DEFUN([AM_DISABLE_STATIC], [])
# _LT_ENABLE_FAST_INSTALL([DEFAULT])
# ----------------------------------
# implement the --enable-fast-install flag, and support the 'fast-install'
# and 'disable-fast-install' LT_INIT options.
# DEFAULT is either 'yes' or 'no'. If omitted, it defaults to 'yes'.
m4_define([_LT_ENABLE_FAST_INSTALL],
[m4_define([_LT_ENABLE_FAST_INSTALL_DEFAULT], [m4_if($1, no, no, yes)])dnl
AC_ARG_ENABLE([fast-install],
[AS_HELP_STRING([--enable-fast-install@<:@=PKGS@:>@],
[optimize for fast installation @<:@default=]_LT_ENABLE_FAST_INSTALL_DEFAULT[@:>@])],
[p=${PACKAGE-default}
case $enableval in
yes) enable_fast_install=yes ;;
no) enable_fast_install=no ;;
*)
enable_fast_install=no
# Look at the argument we got. We use all the common list separators.
lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR,
for pkg in $enableval; do
IFS=$lt_save_ifs
if test "X$pkg" = "X$p"; then
enable_fast_install=yes
fi
done
IFS=$lt_save_ifs
;;
esac],
[enable_fast_install=]_LT_ENABLE_FAST_INSTALL_DEFAULT)
_LT_DECL([fast_install], [enable_fast_install], [0],
[Whether or not to optimize for fast installation])dnl
])# _LT_ENABLE_FAST_INSTALL
LT_OPTION_DEFINE([LT_INIT], [fast-install], [_LT_ENABLE_FAST_INSTALL([yes])])
LT_OPTION_DEFINE([LT_INIT], [disable-fast-install], [_LT_ENABLE_FAST_INSTALL([no])])
# Old names:
AU_DEFUN([AC_ENABLE_FAST_INSTALL],
[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[fast-install])
AC_DIAGNOSE([obsolete],
[$0: Remove this warning and the call to _LT_SET_OPTION when you put
the 'fast-install' option into LT_INIT's first parameter.])
])
AU_DEFUN([AC_DISABLE_FAST_INSTALL],
[_LT_SET_OPTION([LT_INIT], [disable-fast-install])
AC_DIAGNOSE([obsolete],
[$0: Remove this warning and the call to _LT_SET_OPTION when you put
the 'disable-fast-install' option into LT_INIT's first parameter.])
])
dnl aclocal-1.4 backwards compatibility:
dnl AC_DEFUN([AC_ENABLE_FAST_INSTALL], [])
dnl AC_DEFUN([AM_DISABLE_FAST_INSTALL], [])
# _LT_WITH_AIX_SONAME([DEFAULT])
# ----------------------------------
# implement the --with-aix-soname flag, and support the `aix-soname=aix'
# and `aix-soname=both' and `aix-soname=svr4' LT_INIT options. DEFAULT
# is either `aix', `both' or `svr4'. If omitted, it defaults to `aix'.
m4_define([_LT_WITH_AIX_SONAME],
[m4_define([_LT_WITH_AIX_SONAME_DEFAULT], [m4_if($1, svr4, svr4, m4_if($1, both, both, aix))])dnl
shared_archive_member_spec=
case $host,$enable_shared in
power*-*-aix[[5-9]]*,yes)
AC_MSG_CHECKING([which variant of shared library versioning to provide])
AC_ARG_WITH([aix-soname],
[AS_HELP_STRING([--with-aix-soname=aix|svr4|both],
[shared library versioning (aka "SONAME") variant to provide on AIX, @<:@default=]_LT_WITH_AIX_SONAME_DEFAULT[@:>@.])],
[case $withval in
aix|svr4|both)
;;
*)
AC_MSG_ERROR([Unknown argument to --with-aix-soname])
;;
esac
lt_cv_with_aix_soname=$with_aix_soname],
[AC_CACHE_VAL([lt_cv_with_aix_soname],
[lt_cv_with_aix_soname=]_LT_WITH_AIX_SONAME_DEFAULT)
with_aix_soname=$lt_cv_with_aix_soname])
AC_MSG_RESULT([$with_aix_soname])
if test aix != "$with_aix_soname"; then
# For the AIX way of multilib, we name the shared archive member
# based on the bitwidth used, traditionally 'shr.o' or 'shr_64.o',
# and 'shr.imp' or 'shr_64.imp', respectively, for the Import File.
# Even when GNU compilers ignore OBJECT_MODE but need '-maix64' flag,
# the AIX toolchain works better with OBJECT_MODE set (default 32).
if test 64 = "${OBJECT_MODE-32}"; then
shared_archive_member_spec=shr_64
else
shared_archive_member_spec=shr
fi
fi
;;
*)
with_aix_soname=aix
;;
esac
_LT_DECL([], [shared_archive_member_spec], [0],
[Shared archive member basename, for filename based shared library versioning on AIX])dnl
])# _LT_WITH_AIX_SONAME
LT_OPTION_DEFINE([LT_INIT], [aix-soname=aix], [_LT_WITH_AIX_SONAME([aix])])
LT_OPTION_DEFINE([LT_INIT], [aix-soname=both], [_LT_WITH_AIX_SONAME([both])])
LT_OPTION_DEFINE([LT_INIT], [aix-soname=svr4], [_LT_WITH_AIX_SONAME([svr4])])
# _LT_WITH_PIC([MODE])
# --------------------
# implement the --with-pic flag, and support the 'pic-only' and 'no-pic'
# LT_INIT options.
# MODE is either 'yes' or 'no'. If omitted, it defaults to 'both'.
m4_define([_LT_WITH_PIC],
[AC_ARG_WITH([pic],
[AS_HELP_STRING([--with-pic@<:@=PKGS@:>@],
[try to use only PIC/non-PIC objects @<:@default=use both@:>@])],
[lt_p=${PACKAGE-default}
case $withval in
yes|no) pic_mode=$withval ;;
*)
pic_mode=default
# Look at the argument we got. We use all the common list separators.
lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR,
for lt_pkg in $withval; do
IFS=$lt_save_ifs
if test "X$lt_pkg" = "X$lt_p"; then
pic_mode=yes
fi
done
IFS=$lt_save_ifs
;;
esac],
[pic_mode=m4_default([$1], [default])])
_LT_DECL([], [pic_mode], [0], [What type of objects to build])dnl
])# _LT_WITH_PIC
LT_OPTION_DEFINE([LT_INIT], [pic-only], [_LT_WITH_PIC([yes])])
LT_OPTION_DEFINE([LT_INIT], [no-pic], [_LT_WITH_PIC([no])])
# Old name:
AU_DEFUN([AC_LIBTOOL_PICMODE],
[_LT_SET_OPTION([LT_INIT], [pic-only])
AC_DIAGNOSE([obsolete],
[$0: Remove this warning and the call to _LT_SET_OPTION when you
put the 'pic-only' option into LT_INIT's first parameter.])
])
dnl aclocal-1.4 backwards compatibility:
dnl AC_DEFUN([AC_LIBTOOL_PICMODE], [])
## ----------------- ##
## LTDL_INIT Options ##
## ----------------- ##
m4_define([_LTDL_MODE], [])
LT_OPTION_DEFINE([LTDL_INIT], [nonrecursive],
[m4_define([_LTDL_MODE], [nonrecursive])])
LT_OPTION_DEFINE([LTDL_INIT], [recursive],
[m4_define([_LTDL_MODE], [recursive])])
LT_OPTION_DEFINE([LTDL_INIT], [subproject],
[m4_define([_LTDL_MODE], [subproject])])
m4_define([_LTDL_TYPE], [])
LT_OPTION_DEFINE([LTDL_INIT], [installable],
[m4_define([_LTDL_TYPE], [installable])])
LT_OPTION_DEFINE([LTDL_INIT], [convenience],
[m4_define([_LTDL_TYPE], [convenience])])

124
m4/ltsugar.m4 vendored Normal file
View File

@@ -0,0 +1,124 @@
# ltsugar.m4 -- libtool m4 base layer. -*-Autoconf-*-
#
# Copyright (C) 2004-2005, 2007-2008, 2011-2015 Free Software
# Foundation, Inc.
# Written by Gary V. Vaughan, 2004
#
# This file is free software; the Free Software Foundation gives
# unlimited permission to copy and/or distribute it, with or without
# modifications, as long as this notice is preserved.
# serial 6 ltsugar.m4
# This is to help aclocal find these macros, as it can't see m4_define.
AC_DEFUN([LTSUGAR_VERSION], [m4_if([0.1])])
# lt_join(SEP, ARG1, [ARG2...])
# -----------------------------
# Produce ARG1SEPARG2...SEPARGn, omitting [] arguments and their
# associated separator.
# Needed until we can rely on m4_join from Autoconf 2.62, since all earlier
# versions in m4sugar had bugs.
m4_define([lt_join],
[m4_if([$#], [1], [],
[$#], [2], [[$2]],
[m4_if([$2], [], [], [[$2]_])$0([$1], m4_shift(m4_shift($@)))])])
m4_define([_lt_join],
[m4_if([$#$2], [2], [],
[m4_if([$2], [], [], [[$1$2]])$0([$1], m4_shift(m4_shift($@)))])])
# lt_car(LIST)
# lt_cdr(LIST)
# ------------
# Manipulate m4 lists.
# These macros are necessary as long as will still need to support
# Autoconf-2.59, which quotes differently.
m4_define([lt_car], [[$1]])
m4_define([lt_cdr],
[m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])],
[$#], 1, [],
[m4_dquote(m4_shift($@))])])
m4_define([lt_unquote], $1)
# lt_append(MACRO-NAME, STRING, [SEPARATOR])
# ------------------------------------------
# Redefine MACRO-NAME to hold its former content plus 'SEPARATOR''STRING'.
# Note that neither SEPARATOR nor STRING are expanded; they are appended
# to MACRO-NAME as is (leaving the expansion for when MACRO-NAME is invoked).
# No SEPARATOR is output if MACRO-NAME was previously undefined (different
# than defined and empty).
#
# This macro is needed until we can rely on Autoconf 2.62, since earlier
# versions of m4sugar mistakenly expanded SEPARATOR but not STRING.
m4_define([lt_append],
[m4_define([$1],
m4_ifdef([$1], [m4_defn([$1])[$3]])[$2])])
# lt_combine(SEP, PREFIX-LIST, INFIX, SUFFIX1, [SUFFIX2...])
# ----------------------------------------------------------
# Produce a SEP delimited list of all paired combinations of elements of
# PREFIX-LIST with SUFFIX1 through SUFFIXn. Each element of the list
# has the form PREFIXmINFIXSUFFIXn.
# Needed until we can rely on m4_combine added in Autoconf 2.62.
m4_define([lt_combine],
[m4_if(m4_eval([$# > 3]), [1],
[m4_pushdef([_Lt_sep], [m4_define([_Lt_sep], m4_defn([lt_car]))])]]dnl
[[m4_foreach([_Lt_prefix], [$2],
[m4_foreach([_Lt_suffix],
]m4_dquote(m4_dquote(m4_shift(m4_shift(m4_shift($@)))))[,
[_Lt_sep([$1])[]m4_defn([_Lt_prefix])[$3]m4_defn([_Lt_suffix])])])])])
# lt_if_append_uniq(MACRO-NAME, VARNAME, [SEPARATOR], [UNIQ], [NOT-UNIQ])
# -----------------------------------------------------------------------
# Iff MACRO-NAME does not yet contain VARNAME, then append it (delimited
# by SEPARATOR if supplied) and expand UNIQ, else NOT-UNIQ.
m4_define([lt_if_append_uniq],
[m4_ifdef([$1],
[m4_if(m4_index([$3]m4_defn([$1])[$3], [$3$2$3]), [-1],
[lt_append([$1], [$2], [$3])$4],
[$5])],
[lt_append([$1], [$2], [$3])$4])])
# lt_dict_add(DICT, KEY, VALUE)
# -----------------------------
m4_define([lt_dict_add],
[m4_define([$1($2)], [$3])])
# lt_dict_add_subkey(DICT, KEY, SUBKEY, VALUE)
# --------------------------------------------
m4_define([lt_dict_add_subkey],
[m4_define([$1($2:$3)], [$4])])
# lt_dict_fetch(DICT, KEY, [SUBKEY])
# ----------------------------------
m4_define([lt_dict_fetch],
[m4_ifval([$3],
m4_ifdef([$1($2:$3)], [m4_defn([$1($2:$3)])]),
m4_ifdef([$1($2)], [m4_defn([$1($2)])]))])
# lt_if_dict_fetch(DICT, KEY, [SUBKEY], VALUE, IF-TRUE, [IF-FALSE])
# -----------------------------------------------------------------
m4_define([lt_if_dict_fetch],
[m4_if(lt_dict_fetch([$1], [$2], [$3]), [$4],
[$5],
[$6])])
# lt_dict_filter(DICT, [SUBKEY], VALUE, [SEPARATOR], KEY, [...])
# --------------------------------------------------------------
m4_define([lt_dict_filter],
[m4_if([$5], [], [],
[lt_join(m4_quote(m4_default([$4], [[, ]])),
lt_unquote(m4_split(m4_normalize(m4_foreach(_Lt_key, lt_car([m4_shiftn(4, $@)]),
[lt_if_dict_fetch([$1], _Lt_key, [$2], [$3], [_Lt_key ])])))))])[]dnl
])

23
m4/ltversion.m4 vendored Normal file
View File

@@ -0,0 +1,23 @@
# ltversion.m4 -- version numbers -*- Autoconf -*-
#
# Copyright (C) 2004, 2011-2015 Free Software Foundation, Inc.
# Written by Scott James Remnant, 2004
#
# This file is free software; the Free Software Foundation gives
# unlimited permission to copy and/or distribute it, with or without
# modifications, as long as this notice is preserved.
# @configure_input@
# serial 4179 ltversion.m4
# This file is part of GNU Libtool
m4_define([LT_PACKAGE_VERSION], [2.4.6])
m4_define([LT_PACKAGE_REVISION], [2.4.6])
AC_DEFUN([LTVERSION_VERSION],
[macro_version='2.4.6'
macro_revision='2.4.6'
_LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?])
_LT_DECL(, macro_revision, 0)
])

99
m4/lt~obsolete.m4 vendored Normal file
View File

@@ -0,0 +1,99 @@
# lt~obsolete.m4 -- aclocal satisfying obsolete definitions. -*-Autoconf-*-
#
# Copyright (C) 2004-2005, 2007, 2009, 2011-2015 Free Software
# Foundation, Inc.
# Written by Scott James Remnant, 2004.
#
# This file is free software; the Free Software Foundation gives
# unlimited permission to copy and/or distribute it, with or without
# modifications, as long as this notice is preserved.
# serial 5 lt~obsolete.m4
# These exist entirely to fool aclocal when bootstrapping libtool.
#
# In the past libtool.m4 has provided macros via AC_DEFUN (or AU_DEFUN),
# which have later been changed to m4_define as they aren't part of the
# exported API, or moved to Autoconf or Automake where they belong.
#
# The trouble is, aclocal is a bit thick. It'll see the old AC_DEFUN
# in /usr/share/aclocal/libtool.m4 and remember it, then when it sees us
# using a macro with the same name in our local m4/libtool.m4 it'll
# pull the old libtool.m4 in (it doesn't see our shiny new m4_define
# and doesn't know about Autoconf macros at all.)
#
# So we provide this file, which has a silly filename so it's always
# included after everything else. This provides aclocal with the
# AC_DEFUNs it wants, but when m4 processes it, it doesn't do anything
# because those macros already exist, or will be overwritten later.
# We use AC_DEFUN over AU_DEFUN for compatibility with aclocal-1.6.
#
# Anytime we withdraw an AC_DEFUN or AU_DEFUN, remember to add it here.
# Yes, that means every name once taken will need to remain here until
# we give up compatibility with versions before 1.7, at which point
# we need to keep only those names which we still refer to.
# This is to help aclocal find these macros, as it can't see m4_define.
AC_DEFUN([LTOBSOLETE_VERSION], [m4_if([1])])
m4_ifndef([AC_LIBTOOL_LINKER_OPTION], [AC_DEFUN([AC_LIBTOOL_LINKER_OPTION])])
m4_ifndef([AC_PROG_EGREP], [AC_DEFUN([AC_PROG_EGREP])])
m4_ifndef([_LT_AC_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH])])
m4_ifndef([_LT_AC_SHELL_INIT], [AC_DEFUN([_LT_AC_SHELL_INIT])])
m4_ifndef([_LT_AC_SYS_LIBPATH_AIX], [AC_DEFUN([_LT_AC_SYS_LIBPATH_AIX])])
m4_ifndef([_LT_PROG_LTMAIN], [AC_DEFUN([_LT_PROG_LTMAIN])])
m4_ifndef([_LT_AC_TAGVAR], [AC_DEFUN([_LT_AC_TAGVAR])])
m4_ifndef([AC_LTDL_ENABLE_INSTALL], [AC_DEFUN([AC_LTDL_ENABLE_INSTALL])])
m4_ifndef([AC_LTDL_PREOPEN], [AC_DEFUN([AC_LTDL_PREOPEN])])
m4_ifndef([_LT_AC_SYS_COMPILER], [AC_DEFUN([_LT_AC_SYS_COMPILER])])
m4_ifndef([_LT_AC_LOCK], [AC_DEFUN([_LT_AC_LOCK])])
m4_ifndef([AC_LIBTOOL_SYS_OLD_ARCHIVE], [AC_DEFUN([AC_LIBTOOL_SYS_OLD_ARCHIVE])])
m4_ifndef([_LT_AC_TRY_DLOPEN_SELF], [AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF])])
m4_ifndef([AC_LIBTOOL_PROG_CC_C_O], [AC_DEFUN([AC_LIBTOOL_PROG_CC_C_O])])
m4_ifndef([AC_LIBTOOL_SYS_HARD_LINK_LOCKS], [AC_DEFUN([AC_LIBTOOL_SYS_HARD_LINK_LOCKS])])
m4_ifndef([AC_LIBTOOL_OBJDIR], [AC_DEFUN([AC_LIBTOOL_OBJDIR])])
m4_ifndef([AC_LTDL_OBJDIR], [AC_DEFUN([AC_LTDL_OBJDIR])])
m4_ifndef([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH], [AC_DEFUN([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH])])
m4_ifndef([AC_LIBTOOL_SYS_LIB_STRIP], [AC_DEFUN([AC_LIBTOOL_SYS_LIB_STRIP])])
m4_ifndef([AC_PATH_MAGIC], [AC_DEFUN([AC_PATH_MAGIC])])
m4_ifndef([AC_PROG_LD_GNU], [AC_DEFUN([AC_PROG_LD_GNU])])
m4_ifndef([AC_PROG_LD_RELOAD_FLAG], [AC_DEFUN([AC_PROG_LD_RELOAD_FLAG])])
m4_ifndef([AC_DEPLIBS_CHECK_METHOD], [AC_DEFUN([AC_DEPLIBS_CHECK_METHOD])])
m4_ifndef([AC_LIBTOOL_PROG_COMPILER_NO_RTTI], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_NO_RTTI])])
m4_ifndef([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE], [AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE])])
m4_ifndef([AC_LIBTOOL_PROG_COMPILER_PIC], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_PIC])])
m4_ifndef([AC_LIBTOOL_PROG_LD_SHLIBS], [AC_DEFUN([AC_LIBTOOL_PROG_LD_SHLIBS])])
m4_ifndef([AC_LIBTOOL_POSTDEP_PREDEP], [AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP])])
m4_ifndef([LT_AC_PROG_EGREP], [AC_DEFUN([LT_AC_PROG_EGREP])])
m4_ifndef([LT_AC_PROG_SED], [AC_DEFUN([LT_AC_PROG_SED])])
m4_ifndef([_LT_CC_BASENAME], [AC_DEFUN([_LT_CC_BASENAME])])
m4_ifndef([_LT_COMPILER_BOILERPLATE], [AC_DEFUN([_LT_COMPILER_BOILERPLATE])])
m4_ifndef([_LT_LINKER_BOILERPLATE], [AC_DEFUN([_LT_LINKER_BOILERPLATE])])
m4_ifndef([_AC_PROG_LIBTOOL], [AC_DEFUN([_AC_PROG_LIBTOOL])])
m4_ifndef([AC_LIBTOOL_SETUP], [AC_DEFUN([AC_LIBTOOL_SETUP])])
m4_ifndef([_LT_AC_CHECK_DLFCN], [AC_DEFUN([_LT_AC_CHECK_DLFCN])])
m4_ifndef([AC_LIBTOOL_SYS_DYNAMIC_LINKER], [AC_DEFUN([AC_LIBTOOL_SYS_DYNAMIC_LINKER])])
m4_ifndef([_LT_AC_TAGCONFIG], [AC_DEFUN([_LT_AC_TAGCONFIG])])
m4_ifndef([AC_DISABLE_FAST_INSTALL], [AC_DEFUN([AC_DISABLE_FAST_INSTALL])])
m4_ifndef([_LT_AC_LANG_CXX], [AC_DEFUN([_LT_AC_LANG_CXX])])
m4_ifndef([_LT_AC_LANG_F77], [AC_DEFUN([_LT_AC_LANG_F77])])
m4_ifndef([_LT_AC_LANG_GCJ], [AC_DEFUN([_LT_AC_LANG_GCJ])])
m4_ifndef([AC_LIBTOOL_LANG_C_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_C_CONFIG])])
m4_ifndef([_LT_AC_LANG_C_CONFIG], [AC_DEFUN([_LT_AC_LANG_C_CONFIG])])
m4_ifndef([AC_LIBTOOL_LANG_CXX_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_CXX_CONFIG])])
m4_ifndef([_LT_AC_LANG_CXX_CONFIG], [AC_DEFUN([_LT_AC_LANG_CXX_CONFIG])])
m4_ifndef([AC_LIBTOOL_LANG_F77_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_F77_CONFIG])])
m4_ifndef([_LT_AC_LANG_F77_CONFIG], [AC_DEFUN([_LT_AC_LANG_F77_CONFIG])])
m4_ifndef([AC_LIBTOOL_LANG_GCJ_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_GCJ_CONFIG])])
m4_ifndef([_LT_AC_LANG_GCJ_CONFIG], [AC_DEFUN([_LT_AC_LANG_GCJ_CONFIG])])
m4_ifndef([AC_LIBTOOL_LANG_RC_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_RC_CONFIG])])
m4_ifndef([_LT_AC_LANG_RC_CONFIG], [AC_DEFUN([_LT_AC_LANG_RC_CONFIG])])
m4_ifndef([AC_LIBTOOL_CONFIG], [AC_DEFUN([AC_LIBTOOL_CONFIG])])
m4_ifndef([_LT_AC_FILE_LTDLL_C], [AC_DEFUN([_LT_AC_FILE_LTDLL_C])])
m4_ifndef([_LT_REQUIRED_DARWIN_CHECKS], [AC_DEFUN([_LT_REQUIRED_DARWIN_CHECKS])])
m4_ifndef([_LT_AC_PROG_CXXCPP], [AC_DEFUN([_LT_AC_PROG_CXXCPP])])
m4_ifndef([_LT_PREPARE_SED_QUOTE_VARS], [AC_DEFUN([_LT_PREPARE_SED_QUOTE_VARS])])
m4_ifndef([_LT_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_PROG_ECHO_BACKSLASH])])
m4_ifndef([_LT_PROG_F77], [AC_DEFUN([_LT_PROG_F77])])
m4_ifndef([_LT_PROG_FC], [AC_DEFUN([_LT_PROG_FC])])
m4_ifndef([_LT_PROG_CXX], [AC_DEFUN([_LT_PROG_CXX])])

19
makedll.sh Normal file
View File

@@ -0,0 +1,19 @@
#!/bin/sh
if test -e Makefile; then
make clean
fi
options="$@"
echo "using options: $options"
CFLAGS="-march=i686" ./configure --disable-modules --with-cpu=x86_dither $options &&
cd src/libmpg123 &&
make &&
cp .libs/libmpg123-0.dll ../../ &&
cp .libs/libmpg123-0.dll.def ../../libmpg123-0.def
cd ../../ &&
echo "Now run that lib tool... perhaps you want to strip, too.
Hints:
strip --strip-unneeded libmpg123-0.dll
lib /machine:i386 /def:libmpg123-0.def" ||
echo You got some trouble.

637
man1/mpg123.1 Normal file
View File

@@ -0,0 +1,637 @@
.TH mpg123 1 "26 Apr 2020"
.SH NAME
mpg123 \- play audio MPEG 1.0/2.0/2.5 stream (layers 1, 2 and 3)
.SH SYNOPSIS
.B mpg123
[
.I options
]
.IR file-or-URL ...
.SH DESCRIPTION
.B mpg123
reads one or more
.IR file\^ s
(or standard input if ``\-'' is specified) or
.IR URL\^ s
and plays them on the audio device (default) or
outputs them to stdout.
.IR file\^ / URL
is assumed to be an MPEG audio bit stream.
.SH OPERANDS
The following operands are supported:
.TP 8
.IR file (s)
The path name(s) of one or more input files. They must be
valid MPEG-1.0/2.0/2.5 audio layer 1, 2 or 3 bit streams.
If a dash ``\-'' is specified, MPEG data will
be read from the standard input. Furthermore, any name
starting with ``http://'' is recognized as
.I URL
(see next section).
.SH OPTIONS
.B mpg123
options may be either the traditional POSIX one letter options,
or the GNU style long options. POSIX style options start with a
single ``\-'', while GNU long options start with ``\-\^\-''.
Option arguments (if needed) follow separated by whitespace (not ``='').
Note that some options can be absent from your installation when disabled in the build process.
.SH INPUT OPTIONS
.TP
\fB\-k \fInum\fR, \fB\-\^\-skip \fInum
Skip first
.I num
frames. By default the decoding starts at the first frame.
.TP
\fB\-n \fInum\fR, \fB\-\^\-frames \fInum
Decode only
.I num
frames. By default the complete stream is decoded.
.TP
.BR \-\-fuzzy
Enable fuzzy seeks (guessing byte offsets or using approximate seek points from Xing TOC).
Without that, seeks need a first scan through the file before they can jump at positions.
You can decide here: sample-accurate operation with gapless features or faster (fuzzy) seeking.
.TP
.BR \-y ", " \-\^\-no\-resync
Do NOT try to resync and continue decoding if an error occurs in
the input file. Normally,
.B mpg123
tries to keep the playback alive at all costs, including skipping invalid material and searching new header when something goes wrong.
With this switch you can make it bail out on data errors
(and perhaps spare your ears a bad time). Note that this switch has been renamed from \-\-resync.
The old name still works, but is not advertised or recommended to use (subject to removal in future).
.TP
.BR \-F ", " \-\^\-no\-frankenstein
Disable support for Frankenstein streams. Normally, mpg123 stays true to the concept of MPEG audio being
just a concatenation of MPEG frames. It will continue decoding even if the type of MPEG frames varies
wildly. With this switch, it will only decode the input as long as it does not change its character
(from layer I to layer III, changing sampling rate, from mono to stereo), silently assuming end of
stream on such occasion. The switch also stops decoding of compatible MPEG frames if there was an
Info frame (Xing header, Lame tag) that contained a length of the track in MPEG frames.
This comes a bit closer to the notion of a MP3 file as a defined collection
of MPEG frames that belong together, but gets rid of the flexibility that can be fun at times but
mostly is hell for the programmer of the parser and decoder ...
.TP
\fB\-\^-resync\-limit \fIbytes\fR
Set number of bytes to search for valid MPEG data once lost in stream; <0 means search whole stream.
If you know there are huge chunks of invalid data in your files... here is your hammer.
Note: Only since version 1.14 this also increases the amount of junk skipped on beginning.
.TP
\fB\-p \fIURL \fR| \fBnone\fR, \fB\-\^\-proxy \fIURL \fR| \fBnone
The specified
.I proxy
will be used for HTTP requests. It
should be specified as full URL (``http://host.domain:port/''),
but the ``http://'' prefix, the port number and the trailing
slash are optional (the default port is 80). Specifying
.B none
means not to use any proxy, and to retrieve files directly
from the respective servers. See also the
``HTTP SUPPORT'' section.
.TP
\fB\-u \fIauth\fR, \fB\-\^\-auth \fIauth
HTTP authentication to use when receiving files via HTTP.
The format used is user:password.
.TP
\fB\-\^\-ignore\-mime
Ignore MIME types given by HTTP server. If you know better and want mpg123
to decode something the server thinks is image/png, then just do it.
.TP
\fB\-\^\-no\-icy\-meta
Do not accept ICY meta data.
.TP
\fB\-\^-streamdump \fIfilename\fR
Dump a copy of the input data (as read by libmpg123) to the given file.
This enables you to store a web stream to disk while playing, or just create
a concatenation of the local files you play for ... why not?
.TP
\fB\-\^-icy\-interval \fIbytes\fR
This setting enables you to play a stream dump containing ICY metadata at the given
interval in bytes (the value of the icy-metaint HTTP response header). Without it,
such a stream will play, but will cause regular decoding glitches with resync.
.TP
\fB\-\^\-no\-seekbuffer
Disable the default micro-buffering of non-seekable streams that gives the
parser a safer footing.
.TP
\fB\-@ \fIfile\fR, \fB\-\^\-list \fIfile
Read filenames and/or URLs of MPEG audio streams from the specified
.I file
in addition to the ones specified on the command line (if any).
Note that
.I file
can be either an ordinary file, a dash ``\-'' to indicate that
a list of filenames/URLs is to be read from the standard input,
or an URL pointing to a an appropriate list file. Note: only
one
.B \-@
option can be used (if more than one is specified, only the
last one will be recognized).
.TP
\fB\-l \fIn\fR, \fB\-\^\-listentry \fIn
Of the playlist, play specified entry only.
.I n
is the number of entry starting at 1. A value of 0 is the default and means playing the whole list, a negative value means showing of the list of titles with their numbers...
.TP
\fB\-\^\-continue
Enable playlist continuation mode. This changes frame skipping to apply only to the first track and also continues to play following tracks in playlist after the selected one. Also, the option to play a number of frames only applies to the whole playlist. Basically, this tries to treat the playlist more like one big stream (like, an audio book).
The current track number in list (1-based) and frame number (0-based) are printed at exit (useful if you interrupted playback and want to continue later).
Note that the continuation info is printed to standard output unless the switch for piping audio data to standard out is used. Also, it really makes sense to work with actual playlist files instead of lists of file names as arguments, to keep track positions consistent.
.TP
\fB\-\-loop \fItimes\fR
for looping track(s) a certain number of times, < 0 means infinite loop (not with \-\-random!).
.TP
.BR \-\-keep\-open
For remote control mode: Keep loaded file open after reaching end.
.TP
\fB\-\-timeout \fIseconds\fR
Timeout in (integer) seconds before declaring a stream dead (if <= 0, wait forever).
.TP
.BR \-z ", " \-\^\-shuffle
Shuffle play. Randomly shuffles the order of files specified on the command
line, or in the list file.
.TP
.BR \-Z ", " \-\-random
Continuous random play. Keeps picking a random file from the command line
or the play list. Unlike shuffle play above, random play never ends, and
plays individual songs more than once.
.TP
\fB\-i, \-\^-index
Index / scan through the track before playback.
This fills the index table for seeking (if enabled in libmpg123) and may make the operating system cache the file contents for smoother operating on playback.
.TP
\fB\-\-index\-size \fIsize\fR
Set the number of entries in the seek frame index table.
.TP
\fB\-\-preframes \fInum\fR
Set the number of frames to be read as lead-in before a seeked-to position.
This serves to fill the layer 3 bit reservoir, which is needed to faithfully reproduce a certain sample at a certain position.
Note that for layer 3, a minimum of 1 is enforced (because of frame overlap), and for layer 1 and 2, this is limited to 2 (no bit reservoir in that case, but engine spin-up anyway).
.SH OUTPUT and PROCESSING OPTIONS
.TP
\fB\-o \fImodule\fR, \fB\-\^\-output \fImodule\fR
Select audio output module. You can provide a comma-separated list to use the first one that works.
Also see \fB\-a\fR.
.TP
\fB\-\^\-list\-modules
List the available modules.
.TP
\fB\-\^\-list\-devices
List the available output devices for given output module. If there is no functionality
to list devices in the chosen module, an error will be printed and mpg123 will exit with
a non-zero code.
.TP
\fB\-a \fIdev\fR, \fB\-\^\-audiodevice \fIdev
Specify the audio device to use. The default as well as the possible values
depend on the active output. For the JACK output, a comma-separated list
of ports to connect to (for each channel) can be specified.
.TP
.BR \-s ", " \-\^\-stdout
The decoded audio samples are written to standard output,
instead of playing them through the audio device. This
option must be used if your audio hardware is not supported
by
.BR mpg123 .
The output format per default is raw (headerless) linear PCM audio data,
16 bit, stereo, host byte order (you can force mono or 8bit).
.TP
\fB\-O \fIfile\fR, \fB\-\^\-outfile
Write raw output into a file (instead of simply redirecting standard output to a file with the shell).
.TP
\fB\-w \fIfile\fR, \fB\-\^\-wav
Write output as WAV file. This will cause the MPEG stream to be decoded
and saved as file
.I file
, or standard output if
.I -
is used as file name. You can also use
.I --au
and
.I --cdr
for AU and CDR format, respectively. Note that WAV/AU writing to non-seekable files, or redirected stdout, needs some thought. Since 1.16.0, the logic changed to writing the header with the first actual data. This avoids spurious WAV headers in a pipe, for example. The result of decoding nothing to WAV/AU is a file consisting just of the header when it is seekable and really nothing when not (not even a header). Correctly writing data with prophetic headers to stdout is no easy business.
.TP
\fB\-\^\-au \fIfile
Does not play the MPEG file but writes it to
.I file
in SUN audio format. If \- is used as the filename, the AU file is
written to stdout. See paragraph about WAV writing for header fun with non-seekable streams.
.TP
\fB\-\^\-cdr \fIfile
Does not play the MPEG file but writes it to
.I file
as a CDR file. If \- is used as the filename, the CDR file is written
to stdout.
.TP
.BR \-\-reopen
Forces reopen of the audiodevice after ever song
.TP
.BR \-\-cpu\ \fIdecoder\-type
Selects a certain decoder (optimized for specific CPU), for example i586 or MMX.
The list of available decoders can vary; depending on the build and what your CPU supports.
This option is only available when the build actually includes several optimized decoders.
.TP
.BR \-\-test\-cpu
Tests your CPU and prints a list of possible choices for \-\-cpu.
.TP
.BR \-\-list\-cpu
Lists all available decoder choices, regardless of support by your CPU.
.TP
\fB\-g \fIgain\fR, \fB\-\^\-gain \fIgain
[DEPRECATED] Set audio hardware output gain (default: don't change). The unit of the gain value is hardware and output module dependent.
(This parameter is only provided for backwards compatibility and may be removed in the future without prior notice. Use the audio player for playing and a mixer app for mixing, UNIX style!)
.TP
\fB\-f \fIfactor\fR, \fB\-\^\-scale \fIfactor
Change scale factor (default: 32768).
.TP
.BR \-\-rva-mix,\ \-\-rva-radio
Enable RVA (relative volume adjustment) using the values stored for ReplayGain radio mode / mix mode with all tracks roughly equal loudness.
The first valid information found in ID3V2 Tags (Comment named RVA or the RVA2 frame) or ReplayGain header in Lame/Info Tag is used.
.TP
.BR \-\-rva-album,\ \-\-rva-audiophile
Enable RVA (relative volume adjustment) using the values stored for ReplayGain audiophile mode / album mode with usually the effect of adjusting album loudness but keeping relative loudness inside album.
The first valid information found in ID3V2 Tags (Comment named RVA_ALBUM or the RVA2 frame) or ReplayGain header in Lame/Info Tag is used.
.TP
.BR \-0 ", " \-\^\-single0 "; " \-1 ", " \-\^\-single1
Decode only channel 0 (left) or channel 1 (right),
respectively. These options are available for
stereo MPEG streams only.
.TP
.BR \-m ", " \-\^\-mono ", " \-\^\-mix ", " \-\^\-singlemix
Mix both channels / decode mono. It takes less
CPU time than full stereo decoding.
.TP
.BR \-\-stereo
Force stereo output
.TP
\fB\-r \fIrate\fR, \fB\-\^\-rate \fIrate
Set sample rate (default: automatic). You may want to
change this if you need a constant bitrate independent of
the mpeg stream rate. mpg123 automagically converts the
rate. You should then combine this with \-\-stereo or \-\-mono.
.TP
\fB\-\^\-resample \fImethod
Set resampling method to employ if forcing an output rate. Choices (case-insensitive) are NtoM,
dirty, and fine. The fine resampler is the default. It employs libsyn123's low-latency fairly
efficient resampler to postprocess the output from libmpg123 instead of the fast but very crude
NtoM decoder (drop sample method) that mpg123 offers since decades. If you are really low on
CPU time, choose NtoM, as the resampler usually needs more time than the MPEG decoder itself.
The mpg123 program is smart enough to combine the 2to1 or 4to1 downsampling modes with the
postprocessing for extreme downsampling.
.TP
.BR \-2 ", " \-\^\-2to1 "; " \-4 ", " \-\^\-4to1
Performs a downsampling of ratio 2:1 (22 kHz from 44.1 kHz) or 4:1 (11 kHz)
on the output stream, respectively. Saves some CPU cycles, but of course throws away
the high frequencies, as the decoder does not bother producing them.
.TP
.BR \-\-pitch\ \fIvalue
Set a pitch change (speedup/down, 0 is neutral; 0.05 is 5% speedup). When not enforcing an
output rate, this changes the output sampling rate, so it only works in the range your audio
system/hardware supports. When you combine this with a fixed output rate, it modifies a
software resampling ratio instead.
.TP
.BR \-\-8bit
Forces 8bit output
.TP
\fB\-\^\-float
Forces f32 encoding
.TP
\fB\-e \fIenc\fR, \fB\-\^\-encoding \fIenc
Choose output sample encoding. Possible values look like f32 (32-bit floating point), s32 (32-bit signed integer), u32 (32-bit unsigned integer) and the variants with different numbers of bits (s24, u24, s16, u16, s8, u8) and also special variants like ulaw and alaw 8-bit.
See the output of mpg123's longhelp for actually available encodings.
.TP
\fB\-d \fIn\fR, \fB\-\^\-doublespeed \fIn
Only play every
.IR n 'th
frame. This will cause the MPEG stream
to be played
.I n
times faster, which can be used for special
effects. Can also be combined with the
.B \-\^\-halfspeed
option to play 3 out of 4 frames etc. Don't expect great
sound quality when using this option.
.TP
\fB\-h \fIn\fR, \fB\-\^\-halfspeed \fIn
Play each frame
.I n
times. This will cause the MPEG stream
to be played at
.IR 1 / n 'th
speed (n times slower), which can be
used for special effects. Can also be combined with the
.B \-\^\-doublespeed
option to double every third frame or things like that.
Don't expect great sound quality when using this option.
.TP
\fB\-E \fIfile\fR, \fB\-\^\-equalizer
Enables equalization, taken from
.IR file .
The file needs to contain 32 lines of data, additional comment lines may
be prefixed with
.IR # .
Each data line consists of two floating-point entries, separated by
whitespace. They specify the multipliers for left and right channel of
a certain frequency band, respectively. The first line corresponds to the
lowest, the 32nd to the highest frequency band.
Note that you can control the equalizer interactively with the generic control interface.
Also note that these are the 32 bands of the MPEG codec, not spaced like you
would see for a usual graphic equalizer. The upside is that there is zero computational
cost in addition to decoding. The downside is that you roughly have bass in band 0,
(upper) mids in band 1, treble in all others.
.TP
\fB\-\^\-gapless
Enable code that cuts (junk) samples at beginning and end of tracks, enabling gapless transitions between MPEG files when encoder padding and codec delays would prevent it.
This is enabled per default beginning with mpg123 version 1.0.0 .
.TP
\fB\-\^\-no\-gapless
Disable the gapless code. That gives you MP3 decodings that include encoder delay and padding plus mpg123's decoder delay.
.TP
\fB\-\^\-no\-infoframe
Do not parse the Xing/Lame/VBR/Info frame, decode it instead just like a stupid old MP3 hardware player.
This implies disabling of gapless playback as the necessary information is in said metadata frame.
.TP
\fB\-D \fIn\fR, \fB\-\-delay \fIn
Insert a delay of \fIn\fR seconds before each track.
.TP
.BR "\-o h" ", " \-\^\-headphones
Direct audio output to the headphone connector (some hardware only; AIX, HP, SUN).
.TP
.BR "\-o s" ", " \-\^\-speaker
Direct audio output to the speaker (some hardware only; AIX, HP, SUN).
.TP
.BR "\-o l" ", " \-\^\-lineout
Direct audio output to the line-out connector (some hardware only; AIX, HP, SUN).
.TP
\fB\-b \fIsize\fR, \fB\-\^\-buffer \fIsize
Use an audio output buffer of
.I size
Kbytes. This is useful to bypass short periods of heavy
system activity, which would normally cause the audio output
to be interrupted.
You should specify a buffer size of at least 1024
(i.e. 1 Mb, which equals about 6 seconds of audio data) or more;
less than about 300 does not make much sense. The default is 0,
which turns buffering off.
.TP
\fB\-\^\-preload \fIfraction
Wait for the buffer to be filled to
.I fraction
before starting playback (fraction between 0 and 1). You can tune this prebuffering to either get faster sound to your ears or safer uninterrupted web radio.
Default is 0.2 (wait for 20 % of buffer to be full, changed from 1 in version 1.23).
.TP
\fB\-\^\-devbuffer \fIseconds
Set device buffer in seconds; <= 0 means default value. This is the small buffer between the
application and the audio backend, possibly directly related to hardware buffers.
.TP
\fB\-\^\-smooth
Keep buffer over track boundaries -- meaning, do not empty the buffer between tracks for possibly some added smoothness.
.SH MISC OPTIONS
.TP
.BR \-t ", " \-\^\-test
Test mode. The audio stream is decoded, but no output occurs.
.TP
.BR \-c ", " \-\^\-check
Check for filter range violations (clipping), and report them for each frame
if any occur.
.TP
.BR \-v ", " \-\^\-verbose
Increase the verbosity level. For example, displays the frame
numbers during decoding.
.TP
.BR \-q ", " \-\^\-quiet
Quiet. Suppress diagnostic messages.
.TP
.BR \-C ", " \-\^\-control
Enable terminal control keys. This is enabled automatically if a terminal is detected.
By default use 's' or the space bar to stop/restart (pause, unpause) playback, 'f' to jump forward to the next song, 'b' to jump back to the
beginning of the song, ',' to rewind, '.' to fast forward, and 'q' to quit.
Type 'h' for a full list of available controls.
.TP
\fB\-\^\-no\-control
Disable terminal control even if terminal is detected.
.TP
\fB\-\^\-title
In an xterm, rxvt, screen, iris-ansi (compatible, TERM environment variable is examined), change the window's title to the name of song currently
playing.
.TP
\fB\-\^\-name \fIname
Set the name of this instance, possibly used in various places. This sets the client name for JACK output.
.TP
\fB\-\^\-long\-tag
Display ID3 tag info always in long format with one line per item (artist, title, ...)
.TP
.BR \-\-utf8
Regardless of environment, print metadata in UTF-8 (otherwise, when not using UTF-8 locale, you'll get ASCII stripdown).
.TP
.BR \-R ", " \-\^\-remote
Activate generic control interface.
.B mpg123
will then read and execute commands from stdin. Basic usage is ``load <filename> '' to play some file and the obvious ``pause'', ``command.
``jump <frame>'' will jump/seek to a given point (MPEG frame number).
Issue ``help'' to get a full list of commands and syntax.
.TP
.BR \-\^\-remote\-err
Print responses for generic control mode to standard error, not standard out.
This is automatically triggered when using \fB-s\fR.
.TP
\fB\-\-fifo \fIpath
Create a fifo / named pipe on the given path and use that for reading commands instead of standard input.
.TP
\fB\-\^\-aggressive
Tries to get higher priority
.TP
.BR \-T ", " \-\-realtime
Tries to gain realtime priority. This option usually requires root
privileges to have any effect.
.TP
.BR \-? ", " \-\^\-help
Shows short usage instructions.
.TP
.BR \-\^\-longhelp
Shows long usage instructions.
.TP
.BR \-\^\-version
Print the version string.
.SH HTTP SUPPORT
In addition to reading MPEG audio streams from ordinary
files and from the standard input,
.B mpg123
supports retrieval of MPEG audio files or playlists via the HTTP protocol,
which is used in the World Wide Web (WWW). Such files are
specified using a so-called URL, which starts with ``http://''. When a file with
that prefix is encountered,
.B mpg123
attempts to open an HTTP connection to the server in order to
retrieve that file to decode and play it.
.P
It is often useful to retrieve files through a WWW cache or
so-called proxy. To accomplish this,
.B mpg123
examines the environment for variables named
.BR MP3_HTTP_PROXY ", " http_proxy " and " HTTP_PROXY ,
in this order. The value of the first one that is set will
be used as proxy specification. To override this, you can
use the
.B \-p
command line option (see the ``OPTIONS'' section). Specifying
.B "\-p none"
will enforce contacting the server directly without using
any proxy, even if one of the above environment variables
is set.
.P
Note that, in order to play MPEG audio files from a WWW
server, it is necessary that the connection to that server
is fast enough. For example, a 128 kbit/s MPEG file
requires the network connection to be at least 128 kbit/s
(16 kbyte/s) plus protocol overhead. If you suffer from
short network outages, you should try the
.B \-b
option (buffer) to bypass such outages. If your network
connection is generally not fast enough to retrieve MPEG
audio files in realtime, you can first download the files
to your local harddisk (e.g. using
.BR wget (1))
and then play them from there.
.P
If authentication is needed to access the file it can be
specified with the
.BR "\-u user:pass".
.SH INTERRUPT
When in terminal control mode, you can quit via pressing the q key,
while any time you can abort
.B mpg123
by pressing Ctrl-C. If not in terminal control mode, this will
skip to the next file (if any). If you want to abort playing immediately
in that case, press Ctrl-C twice in short succession (within about one second).
.P
Note that the result of quitting
.B mpg123
pressing Ctrl-C might not be audible
immediately, due to audio data buffering in the audio device.
This delay is system dependent, but it is usually not more
than one or two seconds.
.SH PLAYBACK STATUS LINE
In verbose mode, mpg123 updates a line with various information centering around
the current playback position. On any decent terminal, the line also works
as a progress bar in the current file by reversing video for a fraction of the
line according to the current position. An example for a full line is this:
> 0291+0955 00:01.68+00:28.22 [00:05.30] mix 100=085 192 kb/s 576 B acc 18 clip p+0.014
The information consists of, in order:
.TP
.BR >
single-character playback state (``>'' for playing, ``='' for pausing/looping, ``_'' for stopped)
.TP
.BR 0291+0955
current frame offset and number of remaining frames after the plus sign
.TP
.BR 00:01.68+00:28.22
current position from and remaining time in human terms
(hours, minutes, seconds)
.TP
.BR [00:05.30]
fill of the output buffer in terms of playback time, if the buffer is enabled
.TP
.BR mix
selected RVA mode (possible values: mix, alb (album), and \-\^\-\^\- (neutral, off))
.TP
.BR 100=085
set volume and the RVA-modified effective volume after the equal sign
.TP
.BR 192\ kb/s
current bitrate
.TP
.BR 576\ B
size of current frame in bytes
.TP
.BR acc
if positions are accurate, possible values are ``acc'' for accurate positions or ``fuz'' for fuzzy
(with guessed byte offsets using mean frame size)
.TP
.BR 18\ clip
amount of clipped samples, non-zero only if decoder reports that
(generic does, some optimized ones not)
.TP
.BR p+0.014
pitch change (increased/decreased playback sampling rate on user request)
.SH NOTES
MPEG audio decoding requires a good deal of CPU performance,
especially layer-3. To decode it in realtime, you should
have at least an i486DX4, Pentium, Alpha, SuperSparc or equivalent
processor. You can also use the
.B -m
option to decode mono only, which reduces the CPU load
somewhat for layer-3 streams. See also the
.BR \-2 " and " \-4
options.
.P
If everything else fails, have mpg123 decode to a file
and then use an appropriate utility to play that file with less CPU load.
Most probably you can configure mpg123 to produce a format suitable
for your audio device (see above about encodings and sampling rates).
.P
If your system is generally fast enough to decode in
realtime, but there are sometimes periods of heavy
system load (such as cronjobs, users logging in remotely,
starting of ``big'' programs etc.) causing the
audio output to be interrupted, then you should use
the
.B \-b
option to use a buffer of reasonable size (at least 1000 Kbytes).
.SH EXIT CODE
.P
Up to version 1.25.x, mpg123 always returned exit code 0 also for
complete junk on the input side. Fatal errors were only considered
for output. With version 1.26.0, this changed to the behaviour
described below.
.P
When not using the remote control interface (which returns input
errors as text messages), the process exit code is zero (success)
only if all tracks in a playlist had at least one frame parsed,
even if it did not decode cleanly, or
are empty, MPEG-wise (perhaps only metadata, or really an empty file).
When you decode nothing, nothing is the result and that is fine. When
a track later aborts because of parser errors or breakdown of the
network communication, this is treated as end of a track, but does
not make the process as such fail. One really bad (or non-existing)
stream in the playlist results in a non-zero error code, consistent
with other UNIX tools.
.P
An error in audio output results in the process ending with a
non-zero exit code immediately, regardless of how much data has
been successfully played before. The forgiveness is only on the
input side.
.SH BUGS
.P
Mostly MPEG-1 layer 2 and 3 are tested in real life.
Please report any issues and provide test files to help fixing them.
.P
No CRC error checking is performed.
.P
Some platforms lack audio hardware support; you may be able to use the
.B -s
switch to feed the decoded data to a program that can play it on your audio device.
.SH AUTHORS
.TP
Maintainer:
.br
Thomas Orgis <maintainer@mpg123.org>, <thomas@orgis.org>
.TP
Original Creator:
.br
Michael Hipp
.PP
Uses code or ideas from various people, see the AUTHORS file accompanying the source code.
.SH LICENSE
.B mpg123
is licensed under the GNU Lesser/Library General Public License, LGPL, version 2.1 .
.SH WEBSITE
http://www.mpg123.org
.br
http://sourceforge.net/projects/mpg123

335
man1/out123.1 Normal file
View File

@@ -0,0 +1,335 @@
.TH out123 1 "26 Apr 2020"
.SH NAME
out123 \- send raw PCM audio or a waveform pattern to an output device
.SH SYNOPSIS
\fBcat \fRaudio.raw \fR| \fBout123 \fR[ \fR- \fR] [ \fIoptions \fR ]
\fBout123 \fR[ \fIoptions \fR] \fIfilename \fR[ \fIfilename \fR... ]
\fBout123 \fR--wave-freq \fIfreq1\fR[,\fIfreq2\fR,...] [ \fIoptions \fR]
\fBout123 \fR--source \fRgeiger \fR[ \fIoptions \fR]
.SH DESCRIPTION
.B out123
reads raw PCM data (in host byte order) from standard input
and plays it on the audio device specified by given options.
Alternatively, it can generate periodic or random signals for playback
itself.
.SH OPTIONS
.B out123
options may be either the traditional POSIX one letter options,
or the GNU style long options. POSIX style options start with a
single '\-', while GNU long options start with '\-\^\-'.
Option arguments (if needed) follow separated by whitespace (not '=').
Note that some options can be absent from your installation when disabled in the build process.
.TP
\fB\-\^\-name \fIname
Set the name of this instance, possibly used in various places. This sets the client name for JACK output.
.TP
\fB\-o \fImodule\fR, \-\^\-\fBoutput \fImodule\fR
Select audio output module. You can provide a comma-separated list to use the first one that works.
Also see \fB\-a\fR.
.TP
\fB\-\^\-list\-modules
List the available modules.
.TP
\fB\-\^\-list\-devices
List the available output devices for given output module. If there is no functionality
to list devices in the chosen module, an error will be printed and out123 will exit with
a non-zero code.
.TP
\fB\-a \fIdev\fR, \fB\-\^\-audiodevice \fIdev
Specify the audio device to use. The default as well as the possible values
depend on the active output. For the JACK output, a comma-separated list
of ports to connect to (for each channel) can be specified.
.TP
.BR \-s ", " \-\^\-stdout
The audio samples are written to standard output,
instead of playing them through the audio device.
The output format is the same as the input ... so in this mode,
.B out123
acts similar the standard tool \fB cat\fR, possibly with some conversions
involved.
This shortcut is equivalent to '-o raw -a -'.
.TP
.BR \-S ", " \-\^\-STDOUT
This variant additionally writes the data to stdout, while still
playing it on the output device. So it is more like some flavour of
\fBtee\fR than a \fBcat\fR.
.TP
\fB\-O \fIfile\fR, \fB\-\^\-outfile
Write raw output into a file (instead of simply redirecting standard output to a file with the shell).
This shortcut is equivalent to '-o raw -a \fIfile\fR'.
.TP
\fB\-w \fIfile\fR, \fB\-\^\-wav
Write output as WAV file
.I file
, or standard output if
.I -
is or the empty string used as file name. You can also use
.I --au
and
.I --cdr
for AU and CDR format, respectively. Note that WAV/AU writing to non-seekable files or redirected stdout needs some thought. The header is written with the first actual data. The result of decoding nothing to WAV/AU is a file consisting just of the header when it is seekable and really nothing when not (not even a header). Correctly writing data with prophetic headers to stdout is no easy business.
This shortcut is equivalent to '-o wav -a \fIfile\fR'.
.TP
\fB\-\^\-au \fIfile
Write to
.I file
in SUN audio format. If \- or the empty string is used as the filename, the AU file is
written to stdout. See paragraph about WAV writing for header fun with non-seekable streams.
This shortcut is equivalent to '-o au -a \fIfile\fR'.
.TP
\fB\-\^\-cdr \fIfile
Write to
.I file
as a CDR (CD-ROM audio, more correctly CDDA for Compact Disc Digital Audio).
If \- is or the empty string used as the filename, the CDR file is written
to stdout.
This shortcut is equivalent to '-o cdr -a \fIfile\fR'.
.TP
\fB\-r \fIrate\fR, \fB\-\^\-rate \fIrate
Set sample rate in Hz (default: 44100). If this does not match the actual input
sampling rate, you get changed pitch. Might be intentional;-)
.TP
\fB\-R \fIrate\fR, \fB\-\^\-inputrate \fIrate
Set input sample rate to a different value. This triggers resampling if the output
rate is indeed different. See \fB\-\^\-resample\fR.
.TP
\fB\-\^\-speed \fIfactor
Speed up/down playback by that factor using resampling. See \fB\-\^\-resample\fR.
.TP
\fB\-\^\-resample \fImethod
This chooses the method for resampling between differing sampling rates or to apply
a change in tempo. You can choose between two variants of the syn123 resampler: fine
(the default) and dirty. The fine one features 108 dB dynamic range and at worst-case 84%
bandwidth. The dirty one uses a bit less CPU time (not that much, though) by reducing
the dynamic range to 72 dB with worst-case bandwidth of 85%. The exact properties vary
with the sampling rate ratio, as there is interpolation of filter coefficients involved.
.TP
\fB\-c \fIcount\fR, \fB\-\^\-channels \fIcount
Set channel count to given value.
.TP
\fB\-C \fIcount\fR, \fB\-\^\-inputch \fIcount
Set input channel count to a differnt value than for output. This probably means you want
some remixing. Also see \fB\-\^\-mix\fR.
.TP
\fB\-e \fIenc\fR, \fB\-\^\-encoding \fIenc
Choose output sample encoding. Possible values look like f32 (32-bit floating point), s32 (32-bit signed integer), u32 (32-bit unsigned integer) and the variants with different numbers of bits (s24, u24, s16, u16, s8, u8) and also special variants like ulaw and alaw 8-bit.
See the output of \fBout123\fR's longhelp for actually available encodings.
Default is s16.
.TP
\fB\-\^\-endian \fIchoice
Select output endianess (byte order). Choice is big, little, or native, which is the default.
The processing can only work in native mode, so you need to specify input or output byte order
if that does not match your machine. This also sets the input endianess if that is
not set separately. See also \fB\-\^\-inputend\fR and \fB\-\^\-byteswap\fR.
.TP
\fB\-E \fIenc\fR, \fB\-\^\-inputenc \fIenc
Specify input encoding different from output encoding for conversion.
.TP
\fB\-\^\-inputend \fIchoice
Select input endianess (byte order). By default it is the same as output byte order.
See \fB\-\^\-endian\fR.
.TP
.BR \-\^\-byteswap
A switch to trigger swapping of byte order just before output, after any other transformations.
This works on top of any endianess you specify with
.TP
.BR \-m ", " \-\^\-mono "
Set for single-channel audio (default is two channels, stereo).
.TP
.BR \-\-stereo
Select stereo output (2 channels, default).
.TP
.BR \-\^\-list\-encodings
List known encoding short and long names to standard output.
.TP
\fB\-\^\-mix \fImatrix
Specify a mixing matrix between input and output channels as linear factors, comma separated list for
the input channel factors for output channel 1, then output channel 2, and so forth.
The default is a unit matrix if channel counts match, so for 3 channels the equivalent of
'\-\^\-mix 1,0,0,0,1,0,0,0,1'. For stereo to mono conversion, the default is mixing of
both channels with halved amplitude, so '\-\^\-mix 0.5,0.5'. For splitting mono to stereo,
it is '\-\^\-mix 1,1' top keep the symmetry.
.TP
\fB\-\^\-filter \fIcoeff
Apply digital filter(s) before pre-amplification (see \fB\-\^\-preamp\fR) with the coefficient
list coeff as
.ce
b_0,...,b_N,a_0,...,a_N
where a_0=1 is mandatory and perhaps helps orientation a bit. Multiple filters are separated
by ':'.
.TP
\fB\-P \fIdbvalue \fB\-\^\-preamp \fIdbvalue
Enable a pre-amplification stage that amplifies the signal with the given value in dB before output.
.TP
\fB\-\^\-offset \fIvalue
Apply a PCM offset (floating point value scaled in [-1:1] in the pre-amplification stage.
Normally, you would do that to correct a known DC offset in a recording.
.TP
\fB\-\^\-clip \fImode
Select clipping mode: 'soft' or 'hard' for forced clipping also for
floating point output, 'implicit' (default) for implied hard clipping during
conversion where necessary.
.TP
\fB\-\^\-dither
Enable dithering for conversions to integer. If you insist.
This is just some un-spectacular TPDF dither. For some people, that is not fancy enough.
Most people cannot be bothered that way or the other.
.TP
.BR \-\^\-test\-format
Check if given format is supported by given driver and device (in command line before
encountering this), silently returning 0 as exit value if it is the case.
.TP
.BR \-\^\-test\-encodings
Print out the short names of encodings supported with the current setup.
.TP
.BR \-\^\-query\-format
If the selected driver and device communicate some default accepted format, print
out a command line fragment for \fBout123\fR setting that format, always in that order:
\-\^\-rate <r> -\^\-channels <c> -\^\-encoding <e>
.TP
.BR "\-o h" ", " \-\^\-headphones
Direct audio output to the headphone connector (some hardware only; AIX, HP, SUN).
.TP
.BR "\-o s" ", " \-\^\-speaker
Direct audio output to the speaker (some hardware only; AIX, HP, SUN).
.TP
.BR "\-o l" ", " \-\^\-lineout
Direct audio output to the line-out connector (some hardware only; AIX, HP, SUN).
.TP
\fB\-b \fIsize\fR, \fB\-\^\-buffer \fIsize
Use an audio output buffer of
.I size
Kbytes. This is useful to bypass short periods of heavy
system activity, which would normally cause the audio output
to be interrupted.
You should specify a buffer size of at least 1024
(i.e. 1 Mb, which equals about 6 seconds of usual audio data) or more;
less than about 300 does not make much sense. The default is 0,
which turns buffering off.
.TP
\fB\-\^\-preload \fIfraction
Wait for the buffer to be filled to
.I fraction
before starting playback (fraction between 0 and 1). You can tune this prebuffering to either get sound faster to your ears or safer uninterrupted web radio.
Default is 0.2 (changed from 1 since version 1.23).
.TP
\fB\-\^\-devbuffer \fIseconds
Set device buffer in seconds; <= 0 means default value. This is the small buffer between the
application and the audio backend, possibly directly related to hardware buffers.
.TP
\fB\-\^\-timelimit \fIsamples
Set playback time limit in PCM samples if set to a value greater than zero.
\fBout123\fR will stop reading from stdin or playing from the generated wave
table after reaching that number of samples.
.TP
\fB\-\^\-seconds \fIseconds
Set time limit in seconds instead.
.TP
\fB\-\^\-source \fIname
Choose the signal source: 'file' (default) for playback of the given file(s) on the command line
or standard input if there are none, or one of the generators 'wave' (see \fB\-\^\-wave\-freq\fR),
'sweep' (see \fB\-\^\-wave\-sweep\fR), 'pink' (see \fB\-\^\-ping\-rows\fR),
geiger (see \fB\-\^\-geiger\-activity\fR), or just 'white' for some white noise.
.TP
\fB\-\^\-wave\-freq \fIfrequencies
Set wave generator frequency or list of those with comma separation for enabling
a generated test signal instead of standard input. Empty values repeat the
previous one.
.TP
\fB\-\^\-wave\-pat \fIpatterns
Set the waveform patterns of the generated waves as comma-separated list.
Choices include sine, square, triangle, sawtooth, gauss, pulse, and shot.
Empty values repeat the previous one.
.TP
\fB\-\^\-wave\-phase \fIphases
Set waveform phase shift(s) as comma-separated list, negative values
inverting the pattern in time and empty value repeating the previous. There is
also \fB\-\^\-wave\-direction\fR overriding the negative bit.
.TP
\fB\-\^\-wave\-direction\fR
Set wave direction explicitly (the sign counts).
.TP
\fB\-\^\-wave\-sweep \fIfrequency
Sweep a generated wave to the given frequency, from
first one specified for \fB\-\^\-wave\-freq\fR, using the
first wave pattern and direction, too.
.TP
\fB\-\^\-sweep\-time \fIseconds
Set frequency sweep duration in seconds if > 0. This defaults
to the configured time limit if set, otherwise one second, as endless
sweeps are not sensible.
.TP
\fB\-\^\-sweep\-count \fIcount
Set timelimit to exactly produce that many (smooth) sweeps
.TP
\fB\-\^\-sweep\-type \fItype
Set sweep type: lin(ear) for linear, qua(d) (default) for quadratic, or exp(onential)
for an exponential change of frequency with time.
.TP
\fB\-\^\-sweep\-hard
Disable post-sweep smoothing for periodicity.
.TP
\fB\-\^\-genbuffer \fIbytes
Set the buffer size (limit) for signal generators,
if > 0 (default), this enforces a periodic
buffer also for non-periodic signals, benefit:
less runtime CPU overhead, as everything is precomputed as enforced periodic signal.
.TP
\fB\-\^\-wave\-limit \fIsamples
This is an alias for \fB\-\^\-genbuffer\fR.
.TP
\fB\-\^\-pink\-rows \fInumber
Activate pink noise source and choose rows for the algorithm (<1 chooses default).
The generator follows code provided by Phil Burk (http://softsynth.com) and uses
the Gardner method.
.TP
\fB\-\^\-geiger\-activity \fInumber
This configures the simulation of a Geiger-Mueller counter as source, with the given
numer as average events per second. Play with it. It's fun!
.TP
.BR \-t ", " \-\^\-test
Test mode. The audio stream is read, but no output occurs.
.TP
.BR \-v ", " \-\^\-verbose
Increase the verbosity level.
.TP
.BR \-q ", " \-\^\-quiet
Quiet. Suppress diagnostic messages.
.TP
\fB\-\^\-aggressive
Tries to get higher priority
.TP
.BR \-T ", " \-\-realtime
Tries to gain realtime priority. This option usually requires root
privileges to have any effect.
.TP
.BR \-? ", " \-\^\-help
Shows short usage instructions.
.TP
.BR \-\^\-longhelp
Shows long usage instructions.
.TP
.BR \-\^\-version
Print the version string.
.SH AUTHORS
.TP
Maintainer:
.br
Thomas Orgis <maintainer@mpg123.org>, <thomas@orgis.org>
.TP
Creator (ancestry of code inside mpg123):
.br
Michael Hipp
.TP
Uses code or ideas from various people, see the AUTHORS file accompanying the source code.
.SH LICENSE
.B out123
is licensed under the GNU Lesser/Library General Public License, LGPL, version 2.1 .
.SH WEBSITE
http://www.mpg123.org
.br
http://sourceforge.net/projects/mpg123

84
mpg123.spec Normal file
View File

@@ -0,0 +1,84 @@
# This is a generic spec file that should "just work" with rpmbuild on any distro.
# Make sure you have appropriate -devel packes installed:
# - devel packages for alsa, sdl, etc... to build the respective output modules.
Summary: The fast console mpeg audio decoder/player.
Name: mpg123
Version: 1.29.3
Release: 1
URL: http://www.mpg123.org/
License: GPL
Group: Applications/Multimedia
Packager: Michael Ryzhykh <mclroy@gmail.com>
Source: http://www.mpg123.org/download/mpg123-%{version}.tar.bz2
BuildRoot: %_tmppath/%name-%version
Prefix: /usr
%description
This is a console based decoder/player for mono/stereo mpeg audio files,
probably more familiar as MP3 or MP2 files. It's focus is speed.
It can play MPEG1.0/2.0/2.5 layer I, II, II (1, 2, 3;-) files
(VBR files are fine, too) and produce output on a number of different ways:
raw data to stdout and different sound systems depending on your platform.
%package devel
Summary: Files needed for development with libmpg123 or libout123 or libsyn123
Group: Development/Libraries
%description devel
Libraries and header files for development with mpg123.
%prep
%setup -q -n %name-%version
%build
%configure --enable-shared --enable-static
make
%install
%{__rm} -rf %{buildroot}
%makeinstall
%clean
%{__rm} -rf %{buildroot}
%files
%defattr(755,root,root)
%{_bindir}/*
%defattr(644,root,root)
%doc %{_mandir}/*/mpg123.1.gz
%doc %{_mandir}/*/out123.1.gz
%{_libdir}/libmpg123.so.*
%{_libdir}/libout123.so.*
%{_libdir}/libsyn123.so.*
%{_libdir}/mpg123/output_*.so
%files devel
%defattr(644,root,root)
%{_libdir}/pkgconfig/libmpg123.pc
%{_libdir}/pkgconfig/libout123.pc
%{_libdir}/pkgconfig/libsyn123.pc
%{_includedir}/*.h
%{_libdir}/libmpg123.a
%{_libdir}/libmpg123.la
%{_libdir}/libmpg123.so
%{_libdir}/libout123.a
%{_libdir}/libout123.la
%{_libdir}/libout123.so
%{_libdir}/libsyn123.a
%{_libdir}/libsyn123.la
%{_libdir}/libsyn123.so
%changelog
* 2021-05-23 Thomas Orgis <thomas@orgis.org>
- removed output_*.a exclude, because build is fixed
* 2018-02-17 Thomas Orgis <thomas@orgis.org>
- added libsyn123
* 2017-02-27 Thomas Orgis <thomas@orgis.org>
- libltdl and module .la files gone
* Sat Sep 3 2016 Srikanth Rao <srirao@bandwidth.com>
- remove junk added in last edit, add out123 manpage
* Much later Thomas Orgis <thomas@orgis.org>
- some blind update
* Tue Jan 1 2008 Michael Ryzhykh <mclroy@gmail.com>
- Initial Version.

84
mpg123.spec.in Normal file
View File

@@ -0,0 +1,84 @@
# This is a generic spec file that should "just work" with rpmbuild on any distro.
# Make sure you have appropriate -devel packes installed:
# - devel packages for alsa, sdl, etc... to build the respective output modules.
Summary: The fast console mpeg audio decoder/player.
Name: @PACKAGE_NAME@
Version: @PACKAGE_VERSION@
Release: 1
URL: http://www.mpg123.org/
License: GPL
Group: Applications/Multimedia
Packager: Michael Ryzhykh <mclroy@gmail.com>
Source: http://www.mpg123.org/download/mpg123-%{version}.tar.bz2
BuildRoot: %_tmppath/%name-%version
Prefix: /usr
%description
This is a console based decoder/player for mono/stereo mpeg audio files,
probably more familiar as MP3 or MP2 files. It's focus is speed.
It can play MPEG1.0/2.0/2.5 layer I, II, II (1, 2, 3;-) files
(VBR files are fine, too) and produce output on a number of different ways:
raw data to stdout and different sound systems depending on your platform.
%package devel
Summary: Files needed for development with libmpg123 or libout123 or libsyn123
Group: Development/Libraries
%description devel
Libraries and header files for development with mpg123.
%prep
%setup -q -n %name-%version
%build
%configure --enable-shared --enable-static
make
%install
%{__rm} -rf %{buildroot}
%makeinstall
%clean
%{__rm} -rf %{buildroot}
%files
%defattr(755,root,root)
%{_bindir}/*
%defattr(644,root,root)
%doc %{_mandir}/*/mpg123.1.gz
%doc %{_mandir}/*/out123.1.gz
%{_libdir}/libmpg123.so.*
%{_libdir}/libout123.so.*
%{_libdir}/libsyn123.so.*
%{_libdir}/mpg123/output_*.so
%files devel
%defattr(644,root,root)
%{_libdir}/pkgconfig/libmpg123.pc
%{_libdir}/pkgconfig/libout123.pc
%{_libdir}/pkgconfig/libsyn123.pc
%{_includedir}/*.h
%{_libdir}/libmpg123.a
%{_libdir}/libmpg123.la
%{_libdir}/libmpg123.so
%{_libdir}/libout123.a
%{_libdir}/libout123.la
%{_libdir}/libout123.so
%{_libdir}/libsyn123.a
%{_libdir}/libsyn123.la
%{_libdir}/libsyn123.so
%changelog
* 2021-05-23 Thomas Orgis <thomas@orgis.org>
- removed output_*.a exclude, because build is fixed
* 2018-02-17 Thomas Orgis <thomas@orgis.org>
- added libsyn123
* 2017-02-27 Thomas Orgis <thomas@orgis.org>
- libltdl and module .la files gone
* Sat Sep 3 2016 Srikanth Rao <srirao@bandwidth.com>
- remove junk added in last edit, add out123 manpage
* Much later Thomas Orgis <thomas@orgis.org>
- some blind update
* Tue Jan 1 2008 Michael Ryzhykh <mclroy@gmail.com>
- Initial Version.

25
ports/README Normal file
View File

@@ -0,0 +1,25 @@
DISCLAIMER: The contents of the ports directory are included for convenience,
but they usually contain files contributed by various people, not the core
mpg123 team. The stuff is not tested by us. In some cases, it's even
impossible to tell what is really inside. Use at your own risk (well, like
all Free Software, actually;-).
This directory contains some (contributed) works covering usage and/or building
of mpg123/libmpg123 from different programming environments. Note that those
may be a bit outdated (especially when a file is added/removed in libmpg123
sources); as the team lacks resource to test everything. But in any case,
the ports can provide a good starting point on the respective platform, to get
it to work with minimal fuzz.
- cmake: CMake build to get started on non-Unix-like platforms
- Delphi: mpg123_.pas
Unit for linking against libmpg123 (Win32, DLL).
...by Arthur Pires <arthurprs@gmail.com>
- Sony PSP: Sony_PSP/; building libmpg123 for the PSP (used for the MODO player).
...by Bastian Pflieger <wb@illogical.de>
- Xcode contains the project file for building and using libmpg123 with
Xcode for Mac and iOS (arm and simulator builds). Please add the
ports/Xcode folder to the header search path of your project so that
Xcode can find the right mpg123.h and config.h. Then drag the mpg123
Xcode project into your own project. Finally in your build target, build
phases, add mpg123-ios or mpg123-mac to the libraries to link.

View File

@@ -0,0 +1,38 @@
PSPSDK = $(shell psp-config --pspsdk-path)
PSPDIR = $(shell psp-config --psp-prefix)
#DEFINES := PSP OPT_GENERIC REAL_IS_FIXED HAVE_CONFIG_H
DEFINES := PSP OPT_GENERIC REAL_IS_FLOAT HAVE_CONFIG_H
#DEFINES := PSP OPT_GENERIC FLOATOUT REAL_IS_FLOAT HAVE_CONFIG_H
DEFINEFLAGS := $(addprefix -D,$(DEFINES))
INCDIR := ../.
CFLAGS = -g -O2 -Wall -fomit-frame-pointer -funroll-all-loops -finline-functions -ffast-math $(DEFINEFLAGS)
MPG123_OBJS = compat.o parse.o frame.o format.o index.o synth.o synth_8bit.o \
ntom.o icy2utf8.o synth_real.o synth_s32.o\
equalizer.o icy.o id3.o layer1.o layer2.o layer3.o optimize.o readers.o tabinit.o stringbuf.o libmpg123.o dct64.o
MPG123_LIB_FILE = ./libmpg123.a
OBJS = $(MPG123_OBJS)
TARGET_LIB = $(MPG123_LIB_FILE)
include $(PSPSDK)/lib/build.mak
####################
## Makefile rules ##
####################
install: $(MPG123_LIB_FILE)
@echo ""
@echo "**********************************************************************"
@echo "Installing libstsound into $(PSPDIR)"
@mkdir -p $(PSPDIR)/include $(PSPDIR)/lib
@cp -v mpg123.h $(PSPDIR)/include
@cp -v libmpg123.a $(PSPDIR)/lib
@echo "Done"
@echo "**********************************************************************"
@echo ""

11
ports/Sony_PSP/README Normal file
View File

@@ -0,0 +1,11 @@
Hi
* Place Makefile.psp in the directory src/libmpg123.
* Patch readers.c (present in src/libmpg123) using readers.c.patch
* Place Config.h in directory src/
* cd to src/libmpg123 and do "make -f Makefile.psp install"
Tested on mpg123 1.4.x and psptoolchain rev. 2398
Regards
Bastian

368
ports/Sony_PSP/config.h Normal file
View File

@@ -0,0 +1,368 @@
/* src/config.h. Generated from config.h.in by configure. */
/* src/config.h.in. Generated from configure.ac by autoheader. */
/* Define if your architecture wants/needs/can use attribute_align_arg and
alignment checks. It's for 32bit x86... */
#define ABI_ALIGN_FUN 1
/* Define to use proper rounding. */
/* #undef ACCURATE_ROUNDING */
/* Define if .align takes 3 for alignment of 2^3=8 bytes instead of 8. */
/* #undef ASMALIGN_EXP */
/* Define if __attribute__((aligned(16))) shall be used */
/* #undef CCALIGN */
/* Define if checking of stack alignment is wanted. */
#define CHECK_ALIGN 1
/* Define if debugging is enabled. */
/* #undef DEBUG */
/* The default audio output module(s) to use */
#define DEFAULT_OUTPUT_MODULE "alsa,oss,esd,sdl,nas,arts"
/* Define if building with dynamcally linked libmpg123 */
#define DYNAMIC_BUILD 1
/* Define if FIFO support is enabled. */
#define FIFO 1
/* Define if frame index should be used. */
#define FRAME_INDEX 1
/* Define if gapless is enabled. */
#define GAPLESS 1
/* Define to 1 if you have the <Alib.h> header file. */
/* #undef HAVE_ALIB_H */
/* Define to 1 if you have the <arpa/inet.h> header file. */
#define HAVE_ARPA_INET_H 1
/* Define to 1 if you have the <asm/audioio.h> header file. */
/* #undef HAVE_ASM_AUDIOIO_H */
/* Define to 1 if you have the `atoll' function. */
#define HAVE_ATOLL 1
/* Define to 1 if you have the <audios.h> header file. */
/* #undef HAVE_AUDIOS_H */
/* Define to 1 if you have the <AudioToolbox/AudioToolbox.h> header file. */
/* #undef HAVE_AUDIOTOOLBOX_AUDIOTOOLBOX_H */
/* Define to 1 if you have the <AudioUnit/AudioUnit.h> header file. */
/* #undef HAVE_AUDIOUNIT_AUDIOUNIT_H */
/* Define to 1 if you have the <CoreServices/CoreServices.h> header file. */
/* #undef HAVE_CORESERVICES_CORESERVICES_H */
/* Define to 1 if you have the <CUlib.h> header file. */
/* #undef HAVE_CULIB_H */
/* Define to 1 if you have the <dlfcn.h> header file. */
#define HAVE_DLFCN_H 1
/* Define to 1 if you have the `getaddrinfo' function. */
#define HAVE_GETADDRINFO 1
/* Define to 1 if you have the `getpagesize' function. */
#define HAVE_GETPAGESIZE 1
/* Define to 1 if you have the `getuid' function. */
#define HAVE_GETUID 1
/* Define to 1 if you have the <inttypes.h> header file. */
#define HAVE_INTTYPES_H 1
/* Define to 1 if you have the <langinfo.h> header file. */
#define HAVE_LANGINFO_H 1
/* Define to 1 if you have the `m' library (-lm). */
#define HAVE_LIBM 1
/* Define to 1 if you have the `mx' library (-lmx). */
/* #undef HAVE_LIBMX */
/* Define to 1 if you have the <limits.h> header file. */
#define HAVE_LIMITS_H 1
/* Define to 1 if you have the <linux/soundcard.h> header file. */
#define HAVE_LINUX_SOUNDCARD_H 1
/* Define to 1 if you have the <locale.h> header file. */
#define HAVE_LOCALE_H 1
/* Define if libltdl is available */
#define HAVE_LTDL 1
/* Define to 1 if you have the <machine/soundcard.h> header file. */
/* #undef HAVE_MACHINE_SOUNDCARD_H */
/* Define to 1 if you have the <memory.h> header file. */
#define HAVE_MEMORY_H 1
/* Define to 1 if you have the `mkfifo' function. */
#define HAVE_MKFIFO 1
/* Define to 1 if you have a working `mmap' system call. */
#define HAVE_MMAP 1
/* Define to 1 if you have the <netdb.h> header file. */
#define HAVE_NETDB_H 1
/* Define to 1 if you have the <netinet/in.h> header file. */
#define HAVE_NETINET_IN_H 1
/* Define to 1 if you have the <netinet/tcp.h> header file. */
/* #undef HAVE_NETINET_TCP_H */
/* Define to 1 if you have the `nl_langinfo' function. */
#define HAVE_NL_LANGINFO 1
/* Define to 1 if you have the <os2me.h> header file. */
/* #undef HAVE_OS2ME_H */
/* Define to 1 if you have the <os2.h> header file. */
/* #undef HAVE_OS2_H */
/* Define to 1 if you have the `random' function. */
#define HAVE_RANDOM 1
/* Define to 1 if you have the <sched.h> header file. */
#define HAVE_SCHED_H 1
/* Define to 1 if you have the `sched_setscheduler' function. */
#define HAVE_SCHED_SETSCHEDULER 1
/* Define to 1 if you have the `setlocale' function. */
#define HAVE_SETLOCALE 1
/* Define to 1 if you have the `setpriority' function. */
#define HAVE_SETPRIORITY 1
/* Define to 1 if you have the `setuid' function. */
#define HAVE_SETUID 1
/* Define to 1 if you have the <signal.h> header file. */
#define HAVE_SIGNAL_H 1
/* Define to 1 if you have the <sndio.h> header file. */
/* #undef HAVE_SNDIO_H */
/* Define to 1 if you have the <stdint.h> header file. */
#define HAVE_STDINT_H 1
/* Define to 1 if you have the <stdio.h> header file. */
#define HAVE_STDIO_H 1
/* Define to 1 if you have the <stdlib.h> header file. */
#define HAVE_STDLIB_H 1
/* Define to 1 if you have the `strdup' function. */
#define HAVE_STRDUP 1
/* Define to 1 if you have the `strerror' function. */
#define HAVE_STRERROR 1
/* Define to 1 if you have the <strings.h> header file. */
#define HAVE_STRINGS_H 1
/* Define to 1 if you have the <string.h> header file. */
#define HAVE_STRING_H 1
/* Define to 1 if you have the <sun/audioio.h> header file. */
/* #undef HAVE_SUN_AUDIOIO_H */
/* Define to 1 if you have the <sys/audioio.h> header file. */
/* #undef HAVE_SYS_AUDIOIO_H */
/* Define to 1 if you have the <sys/audio.h> header file. */
/* #undef HAVE_SYS_AUDIO_H */
/* Define to 1 if you have the <sys/ioctl.h> header file. */
#define HAVE_SYS_IOCTL_H 1
/* Define to 1 if you have the <sys/param.h> header file. */
#define HAVE_SYS_PARAM_H 1
/* Define to 1 if you have the <sys/resource.h> header file. */
#define HAVE_SYS_RESOURCE_H 1
/* Define to 1 if you have the <sys/signal.h> header file. */
#define HAVE_SYS_SIGNAL_H 1
/* Define to 1 if you have the <sys/socket.h> header file. */
#define HAVE_SYS_SOCKET_H 1
/* Define to 1 if you have the <sys/soundcard.h> header file. */
#define HAVE_SYS_SOUNDCARD_H 1
/* Define to 1 if you have the <sys/stat.h> header file. */
#define HAVE_SYS_STAT_H 1
/* Define to 1 if you have the <sys/time.h> header file. */
#define HAVE_SYS_TIME_H 1
/* Define to 1 if you have the <sys/types.h> header file. */
#define HAVE_SYS_TYPES_H 1
/* Define to 1 if you have the <sys/wait.h> header file. */
#define HAVE_SYS_WAIT_H 1
/* Define this if you have the POSIX termios library */
#define HAVE_TERMIOS 1
/* Define to 1 if you have the <unistd.h> header file. */
#define HAVE_UNISTD_H 1
/* Define to 1 if you have the <windows.h> header file. */
/* #undef HAVE_WINDOWS_H */
/* Define to indicate that float storage follows IEEE754. */
#define IEEE_FLOAT 1
/* size of the frame index seek table */
#define INDEX_SIZE 1000
/* Define if IPV6 support is enabled. */
#define IPV6 1
/* Define to the sub-directory in which libtool stores uninstalled libraries.
*/
#define LT_OBJDIR ".libs/"
/* Define if network support is enabled. */
/* #define NETWORK 1 */
/* Define to disable 16 bit integer output. */
/* #undef NO_16BIT */
/* Define to disable 32 bit integer output. */
/* define NO_32BIT 1 */
/* Define to disable 8 bit integer output. */
/* #undef NO_8BIT */
/* Define to disable downsampled decoding. */
/* #undef NO_DOWNSAMPLE */
/* Define to disable error messages in combination with a return value (the
return is left intact). */
/* #undef NO_ERETURN */
/* Define to disable error messages. */
/* #undef NO_ERRORMSG */
/* Define to disable feeder and buffered readers. */
/* #undef NO_FEEDER */
/* Define to disable ICY handling. */
/* #undef NO_ICY */
/* Define to disable ID3v2 parsing. */
/* #undef NO_ID3V2 */
/* Define to disable layer I. */
/* #undef NO_LAYER1 */
/* Define to disable layer II. */
/* #undef NO_LAYER2 */
/* Define to disable layer III. */
/* #undef NO_LAYER3 */
/* Define to disable ntom resampling. */
/* #undef NO_NTOM */
/* Define to disable real output. */
/* define NO_REAL 1 */
/* Define to disable string functions. */
/* #undef NO_STRING */
/* Define to disable warning messages. */
/* #undef NO_WARNING */
/* Name of package */
#define PACKAGE "mpg123"
/* Define to the address where bug reports for this package should be sent. */
#define PACKAGE_BUGREPORT "mpg123-devel@lists.sourceforge.net"
/* Define to the full name of this package. */
#define PACKAGE_NAME "mpg123"
/* Define to the full name and version of this package. */
#define PACKAGE_STRING "mpg123 1.8rc5"
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "mpg123"
/* Define to the version of this package. */
#define PACKAGE_VERSION "1.8rc5"
/* Define if portaudio v18 API is wanted. */
/* #undef PORTAUDIO18 */
/* The size of `int32_t', as computed by sizeof. */
#define SIZEOF_INT32_T 4
/* The size of `long', as computed by sizeof. */
#define SIZEOF_LONG 4
/* The size of `off_t', as computed by sizeof. */
#define SIZEOF_OFF_T 4
/* The size of `size_t', as computed by sizeof. */
#define SIZEOF_SIZE_T 4
/* The size of `ssize_t', as computed by sizeof. */
#define SIZEOF_SSIZE_T 4
/* Define to 1 if you have the ANSI C header files. */
#define STDC_HEADERS 1
/* Define if modules are enabled */
#define USE_MODULES 1
/* Version number of package */
#define VERSION "1.8rc5"
/* Number of bits in a file offset, on hosts where this is settable. */
/* #undef _FILE_OFFSET_BITS */
/* Define for large files, on AIX-style hosts. */
/* #undef _LARGE_FILES */
/* Define to empty if `const' does not conform to ANSI C. */
/* #undef const */
/* Define to `__inline__' or `__inline' if that's what the C compiler
calls it, or to nothing if 'inline' is not supported under any name. */
#ifndef __cplusplus
/* #undef inline */
#endif
/* Define to `short' if <sys/types.h> does not define. */
/* #undef int16_t */
/* Define to `int' if <sys/types.h> does not define. */
/* #undef int32_t */
/* Define to `long int' if <sys/types.h> does not define. */
/* #undef off_t */
/* Define to `unsigned long' if <sys/types.h> does not define. */
/* #undef size_t */
/* Define to `long' if <sys/types.h> does not define. */
/* #undef ssize_t */
/* Define to `unsigned short' if <sys/types.h> does not define. */
/* #undef uint16_t */
/* Define to `unsigned int' if <sys/types.h> does not define. */
/* #undef uint32_t */

View File

@@ -0,0 +1,2 @@
14a15
> #include <sys/fd_set.h>

View File

@@ -0,0 +1,69 @@
cmake_minimum_required(VERSION 3.12)
include(cmake/read_api_version.cmake)
read_api_version(MPG123_VERSION API_VERSION OUTAPI_VERSION SYNAPI_VERSION)
project(mpg123 VERSION ${MPG123_VERSION} LANGUAGES C ASM)
option(BUILD_LIBOUT123 "build libout123" ON)
if(CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
message(WARNING "Output module is not implemented for '${CMAKE_SYSTEM_NAME}' platform.")
message(WARNING "To prevent build errors 'BUILD_LIBOUT123' option is set to OFF.")
set(BUILD_LIBOUT123 OFF)
endif()
include(cmake/search_libs.cmake)
include(CMakePackageConfigHelpers)
include(GNUInstallDirs)
set(PACKAGE_VERSION ${PROJECT_VERSION})
add_subdirectory("src")
install(
EXPORT targets
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
NAMESPACE MPG123::)
configure_package_config_file(
mpg123-config.cmake.in mpg123-config.cmake
INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
write_basic_package_version_file(
mpg123-config-version.cmake COMPATIBILITY AnyNewerVersion)
install(
FILES
"${CMAKE_CURRENT_BINARY_DIR}/mpg123-config.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/mpg123-config-version.cmake"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
set(prefix "${CMAKE_INSTALL_PREFIX}")
set(exec_prefix "${CMAKE_INSTALL_PREFIX}")
set(libdir "${CMAKE_INSTALL_FULL_LIBDIR}")
set(includedir "${CMAKE_INSTALL_FULL_INCLUDEDIR}")
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/../../libmpg123.pc.in" libmpg123.pc @ONLY)
if(BUILD_LIBOUT123)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/../../libout123.pc.in" libout123.pc @ONLY)
endif()
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/../../libsyn123.pc.in" libsyn123.pc @ONLY)
install(
FILES
"${CMAKE_CURRENT_BINARY_DIR}/libmpg123.pc"
"${CMAKE_CURRENT_BINARY_DIR}/libsyn123.pc"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
if(BUILD_LIBOUT123)
install(
FILES
"${CMAKE_CURRENT_SOURCE_DIR}/../../man1/mpg123.1"
"${CMAKE_CURRENT_SOURCE_DIR}/../../man1/out123.1"
DESTINATION "${CMAKE_INSTALL_MANDIR}")
install(
FILES
"${CMAKE_CURRENT_BINARY_DIR}/libout123.pc"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
install(
FILES
"${CMAKE_CURRENT_SOURCE_DIR}/../../man1/out123.1"
DESTINATION "${CMAKE_INSTALL_MANDIR}")
endif()

View File

@@ -0,0 +1,7 @@
int main(void) {
#if @CHECK_CPU_ARCH_DEFINES@
return 0;
#else
fail
#endif
}

View File

@@ -0,0 +1,31 @@
macro(_CHECK_CPU_ARCH ARCH ARCH_DEFINES VARIABLE)
if(NOT DEFINED HAVE_${VARIABLE})
message(STATUS "Check CPU architecture is ${ARCH}")
set(CHECK_CPU_ARCH_DEFINES ${ARCH_DEFINES})
configure_file(${PROJECT_SOURCE_DIR}/cmake/CheckCPUArch.c.in ${PROJECT_BINARY_DIR}/CMakeFiles/CMakeTmp/CheckCPUArch.c @ONLY)
try_compile(HAVE_${VARIABLE} "${PROJECT_BINARY_DIR}"
"${PROJECT_BINARY_DIR}/CMakeFiles/CMakeTmp/CheckCPUArch.c")
if(HAVE_${VARIABLE})
message(STATUS "Check CPU architecture is ${ARCH} - yes")
set(${VARIABLE} 1 CACHE INTERNAL "Result of CHECK_CPU_ARCH_X64" FORCE)
else ()
message(STATUS "Check CPU architecture is ${ARCH} - no")
endif()
endif ()
endmacro(_CHECK_CPU_ARCH)
macro(CHECK_CPU_ARCH_X64 VARIABLE)
_CHECK_CPU_ARCH(x64 "defined(__amd64__) || defined(__amd64) || defined(__x86_64__) || defined(__x86_64) || defined(_M_X64) || defined(_M_AMD64)" ${VARIABLE})
endmacro()
macro(CHECK_CPU_ARCH_X86 VARIABLE)
_CHECK_CPU_ARCH(x86 "defined(__i386__) || defined(__i486__) || defined(__i586__) || defined(__i686__) ||defined( __i386) || defined(_M_IX86)" ${VARIABLE})
endmacro()
macro(CHECK_CPU_ARCH_ARM32 VARIABLE)
_CHECK_CPU_ARCH(arm32 "defined(__arm__) || defined(_M_ARM)" ${VARIABLE} )
endmacro()
macro(CHECK_CPU_ARCH_ARM64 VARIABLE)
_CHECK_CPU_ARCH(arm64 "defined(__aarch64__) || defined(_M_ARM64)" ${VARIABLE} )
endmacro()

View File

@@ -0,0 +1,17 @@
function(read_api_version project_version api_version outapi_version synapi_version )
file( READ "${CMAKE_SOURCE_DIR}/../../configure.ac" configure_ac )
string( REGEX MATCH "AC_INIT\\(\\[mpg123\\], \\[([0-9\\.]+)" result ${configure_ac} )
set( ${project_version} ${CMAKE_MATCH_1} PARENT_SCOPE )
string( REGEX MATCH "API_VERSION=([0-9]+)" result ${configure_ac} )
set( ${api_version} ${CMAKE_MATCH_1} PARENT_SCOPE )
string( REGEX MATCH "OUTAPI_VERSION=([0-9]+)" result ${configure_ac} )
set( ${outapi_version} ${CMAKE_MATCH_1} PARENT_SCOPE )
string( REGEX MATCH "SYNAPI_VERSION=([0-9]+)" result ${configure_ac} )
set( ${synapi_version} ${CMAKE_MATCH_1} PARENT_SCOPE )
endfunction()

View File

@@ -0,0 +1,14 @@
function(search_libs function output_var)
if(${output_var})
return()
endif()
set(LIBS "" ${ARGN})
foreach(CMAKE_REQUIRED_LIBRARIES IN LISTS ${LIBS})
message(STATUS "######## ${CMAKE_REQUIRED_LIBRARIES} ${HAVE_${function}}")
check_function_exists(${function} HAVE_${function})
if(HAVE_${function})
set(${output_var} ${CMAKE_REQUIRED_LIBRARIES} CACHE INTERNAL "")
return()
endif()
endforeach()
endfunction()

View File

@@ -0,0 +1,3 @@
@PACKAGE_INIT@
include("${CMAKE_CURRENT_LIST_DIR}/targets.cmake")

View File

@@ -0,0 +1,443 @@
cmake_minimum_required(VERSION 3.12)
include(CheckCSourceCompiles)
include(CheckFunctionExists)
include(CheckIncludeFile)
include(CheckIncludeFiles)
include(CheckSymbolExists)
include(CMakeDependentOption)
include(TestBigEndian)
check_include_file("arpa/inet.h" HAVE_ARPA_INET_H)
check_include_file("dirent.h" HAVE_DIRENT_H)
check_include_file("dlfcn.h" HAVE_DLFCN_H)
check_include_file("inttypes.h" HAVE_INTTYPES_H)
check_include_file("langinfo.h" HAVE_LANGINFO_H)
check_include_file("limits.h" HAVE_LIMITS_H)
check_include_file("locale.h" HAVE_LOCALE_H)
check_include_file("netdb.h" HAVE_NETDB_H)
check_include_file("netinet/in.h" HAVE_NETINET_IN_H)
check_include_file("sched.h" HAVE_SCHED_H)
check_include_file("signal.h" HAVE_SIGNAL_H)
check_include_file("stdio.h" HAVE_STDIO_H)
check_include_file("stdint.h" HAVE_STDINT_H)
check_include_file("stdlib.h" HAVE_STDLIB_H)
check_include_file("string.h" HAVE_STRING_H)
check_include_file("sys/ioctl.h" HAVE_SYS_IOCTL_H)
check_include_file("sys/ipc.h" HAVE_SYS_IPC_H)
check_include_file("sys/param.h" HAVE_SYS_PARAM_H)
check_include_file("sys/resource.h" HAVE_SYS_RESOURCE_H)
check_include_file("sys/select.h" HAVE_SYS_SELECT_H)
check_include_file("sys/shm.h" HAVE_SYS_SHM_H)
check_include_file("sys/signal.h" HAVE_SYS_SIGNAL_H)
check_include_file("sys/socket.h" HAVE_SYS_SOCKET_H)
check_include_file("sys/stat.h" HAVE_SYS_STAT_H)
check_include_file("sys/time.h" HAVE_SYS_TIME_H)
check_include_file("sys/types.h" HAVE_SYS_TYPES_H)
check_include_file("sys/wait.h" HAVE_SYS_WAIT_H)
check_include_file("termios.h" HAVE_TERMIOS)
check_include_file("unistd.h" HAVE_UNISTD_H)
check_include_file("windows.h" HAVE_WINDOWS_H)
function(check_m)
set(CMAKE_REQUIRED_LIBRARIES m)
check_function_exists(sin HAVE_M)
endfunction(check_m)
check_m()
check_function_exists(atoll HAVE_ATOLL)
check_function_exists(getaddrinfo HAVE_IPV6)
check_function_exists(mkfifo HAVE_MKFIFO)
check_function_exists(mmap HAVE_MMAP)
check_function_exists(nl_langinfo HAVE_NL_LANGINFO)
check_function_exists(random HAVE_RANDOM)
check_function_exists(setlocale HAVE_SETLOCALE)
check_function_exists(setpriority HAVE_SETPRIORITY)
check_function_exists(shmget HAVE_SHMGET)
check_function_exists(shmat HAVE_SHMAT)
check_function_exists(shmdt HAVE_SHMDT)
check_function_exists(shmctl HAVE_SHMCTL)
check_function_exists(strerror HAVE_STRERROR)
search_libs(gethostbyname GETHOSTBYNAME_LIB nsl socket network)
search_libs(socket SOCKET_LIB socket)
test_big_endian(WORDS_BIGENDIAN)
check_c_source_compiles(
"int main() { __asm__(\".balign 4\"); return 0; }"
ASMALIGN_BALIGN)
check_c_source_compiles(
"int main() { __asm__(\".align 3\"); return 0; }"
ASMALIGN_EXP)
if(NOT ASMALIGN_EXP)
set(ASMALIGN_BYTE ON)
endif()
check_c_source_compiles(
"int main() { __attribute__((aligned(16))) float var; return 0; }"
CCALIGN)
if(MSVC)
# Here, off_t is always 32 bit, the whole machinery doesn't work without explicit
# API for 64 bit file access.
unset(_FILE_OFFSET_BITS)
set(LFS_SENSITIVE OFF)
set(LFS_INSENSITIVE ON)
set(MPG123_LARGE_FILE_SUPPORT OFF)
# We disable all the dynamic naming with MSVC to avoid confusing consumers.
# Maybe it would be more proper to conditionit on LFS_INSENSTIIVE.
set(BUILD_NO_LARGENAME 1)
else()
option(MPG123_LARGE_FILE_SUPPORT "Support large files (define _FILE_OFFSET_BITS)" ON)
if(MPG123_LARGE_FILE_SUPPORT)
set(_FILE_OFFSET_BITS 64)
else()
unset(_FILE_OFFSET_BITS)
endif()
set(BUILD_NO_LARGENAME 0)
endif()
if(NOT LFS_INSENSITIVE)
check_c_source_compiles("
#include <sys/types.h>
/* Check that off_t can represent 2**63 - 1 correctly.
We can't simply define LARGE_OFF_T to be 9223372036854775807,
since some C++ compilers masquerading as C compilers
incorrectly reject 9223372036854775807. */
#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
int off_t_is_large[
(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1];
int main() { return 0; }"
LFS_INSENSITIVE)
endif()
if(NOT LFS_INSENSITIVE)
check_c_source_compiles("
#define _FILE_OFFSET_BITS 64
#include <sys/types.h>
/* Check that off_t can represent 2**63 - 1 correctly.
We can't simply define LARGE_OFF_T to be 9223372036854775807,
since some C++ compilers masquerading as C compilers
incorrectly reject 9223372036854775807. */
#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
int off_t_is_large[
(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1];
int main() { return 0; }"
LFS_SENSITIVE)
endif()
check_type_size(long SIZEOF_LONG)
check_type_size(off_t SIZEOF_OFF_T)
if(LFS_SENSITIVE)
set(LFS_ALIAS_TYPE long)
math(EXPR LFS_ALIAS_BITS "${SIZEOF_LONG} * 8")
elseif(CMAKE_ANDROID_ARCH_ABI)
check_type_size(off64_t SIZEOF_OFF64_T)
set(LFS_ALIAS_TYPE off64_t)
math(EXPR LFS_ALIAS_BITS "${SIZEOF_OFF64_T} * 8")
else()
set(LFS_ALIAS_TYPE off_t)
math(EXPR LFS_ALIAS_BITS "${SIZEOF_OFF_T} * 8")
endif()
if(WIN32 AND HAVE_WINDOWS_H)
check_c_source_compiles("
#include <windows.h>
int main() {
LoadLibraryW(0);
GetProcAddress(0, 0);
FreeLibrary(0);
}"
HAVE_WIN_DL)
else()
function(check_dl)
set(CMAKE_REQUIRED_LIBRARIES dl)
check_symbol_exists(dlopen "dlfcn.h" HAVE_UNIX_DL)
endfunction(check_dl)
check_dl()
endif()
set(DYNAMIC_BUILD ${BUILD_SHARED_LIBS})
if(MSVC)
set(STDERR_FILENO "(_fileno(stderr))")
set(STDIN_FILENO "(_fileno(stdin))")
set(STDOUT_FILENO "(_fileno(stdout))")
endif()
set(HAVE_WIN32_FIFO ${WIN32})
set(WANT_WIN32_UNICODE ${WIN32})
set(WITH_SEEKTABLE 1000)
if(NOT WITH_SEEKTABLE EQUAL 0)
set(FRAME_INDEX 1)
endif()
if(WIN32)
set(HAVE_MKFIFO ON)
endif()
if(HAVE_NETDB_H AND HAVE_SYS_PARAM_H AND HAVE_SYS_SOCKET_H AND HAVE_NETINET_IN_H AND HAVE_ARPA_INET_H)
set(HAVE_NETWORK ON)
endif()
if(NO_MESSAGES)
set(NO_WARNING ON)
set(NO_ERRORMSG ON)
set(NO_ERETURN ON)
endif()
if(WIN32)
set(HAVE_FPU 1)
else()
cmake_host_system_information(RESULT HAVE_FPU QUERY HAS_FPU)
endif()
if(NOT HAVE_FPU)
set(NO_SYNTH32 ON)
endif()
# Modules
if(BUILD_LIBOUT123)
if(CHECK_MODULES)
list(FIND CHECK_MODULES alsa ALSA_REQUIRED)
list(FIND CHECK_MODULES coreaudio COREAUDIO_REQUIRED)
list(FIND CHECK_MODULES pulse PULSE_REQUIRED)
list(FIND CHECK_MODULES jack JACK_REQUIRED)
list(FIND CHECK_MODULES tinyalsa TINYALSA_REQUIRED)
list(FIND CHECK_MODULES win32 WIN32_REQUIRED)
list(FIND CHECK_MODULES win32_wasapi WIN32_WASAPI_REQUIRED)
set(MODULE_NOT_FOUND_MESSAGE "module required but couldn't be found")
endif()
if(NOT CHECK_MODULES OR NOT ALSA_REQUIRED EQUAL -1)
find_package(ALSA)
if(TARGET ALSA::ALSA)
list(APPEND OUTPUT_MODULES alsa)
elseif(CHECK_MODULES AND NOT ALSA_REQUIRED EQUAL -1)
message(FATAL_ERROR "alsa ${MODULE_NOT_FOUND_MESSAGE}")
endif()
endif()
if(NOT CHECK_MODULES OR NOT COREAUDIO_REQUIRED EQUAL -1)
if(APPLE)
find_library(AUDIO_TOOLBOX AudioToolbox)
list(APPEND OUTPUT_MODULES coreaudio)
elseif(CHECK_MODULES AND NOT COREAUDIO_REQUIRED EQUAL -1)
message(FATAL_ERROR "coreaudio ${MODULE_NOT_FOUND_MESSAGE}")
endif()
endif()
find_package(PkgConfig)
if(PKG_CONFIG_FOUND)
if(NOT CHECK_MODULES OR NOT PULSE_REQUIRED EQUAL -1)
pkg_search_module(PULSE libpulse-simple)
if(PULSE_FOUND)
list(APPEND OUTPUT_MODULES pulse)
elseif(CHECK_MODULES AND NOT PULSE_REQUIRED EQUAL -1)
message(FATAL_ERROR "pulse ${MODULE_NOT_FOUND_MESSAGE}")
endif()
endif()
if(NOT CHECK_MODULES OR NOT JACK_REQUIRED EQUAL -1)
pkg_search_module(JACK jack)
if(JACK_FOUND)
list(APPEND OUTPUT_MODULES jack)
elseif(CHECK_MODULES AND NOT JACK_REQUIRED EQUAL -1)
message(FATAL_ERROR "jack ${MODULE_NOT_FOUND_MESSAGE}")
endif()
endif()
if(NOT CHECK_MODULES OR NOT TINYALSA_REQUIRED EQUAL -1)
pkg_search_module(TINYALSA tinyalsa)
if(TINYALSA_FOUND)
list(APPEND OUTPUT_MODULES tinyalsa)
elseif(CHECK_MODULES AND NOT TINYALSA_REQUIRED EQUAL -1)
message(FATAL_ERROR "tinyalsa ${MODULE_NOT_FOUND_MESSAGE}")
endif()
endif()
endif()
if(NOT CHECK_MODULES OR NOT WIN32_REQUIRED EQUAL -1)
if(HAVE_WINDOWS_H)
set(WIN32_LIBRARIES winmm)
list(APPEND OUTPUT_MODULES win32)
elseif(CHECK_MODULES AND NOT WIN32_REQUIRED EQUAL -1)
message(FATAL_ERROR "win32 ${MODULE_NOT_FOUND_MESSAGE}")
endif()
endif()
if(NOT CHECK_MODULES OR NOT WIN32_WASAPI_REQUIRED EQUAL -1)
set(WASAPI_INCLUDES "initguid.h" "audioclient.h" "mmdeviceapi.h" "avrt.h")
check_include_files("${WASAPI_INCLUDES}" HAVE_WASAPI)
if(HAVE_WASAPI)
set(WIN32_WASAPI_LIBRARIES ole32 avrt)
list(APPEND OUTPUT_MODULES win32_wasapi)
elseif(CHECK_MODULES AND NOT WIN32_WASAPI_REQUIRED EQUAL -1)
message(FATAL_ERROR "win32_wasapi ${MODULE_NOT_FOUND_MESSAGE}")
endif()
endif()
if(CHECK_MODULES)
list(REMOVE_AT CHECK_MODULES
${ALSA_REQUIRED}
${COREAUDIO_REQUIRED}
${PULSE_REQUIRED}
${JACK_REQUIRED}
${TINYALSA_REQUIRED}
${WIN32_REQUIRED}
${WIN32_WASAPI_REQUIRED})
list(LENGTH CHECK_MODULES CHECK_MODULES_LENGTH)
if(NOT CHECK_MODULES_LENGTH EQUAL 0)
message(FATAL_ERROR "Dunno how to find modules: ${CHECK_MODULES}")
endif()
endif()
if(NOT OUTPUT_MODULES)
set(DEFAULT_OUTPUT_MODULE dummy)
set(DEFAULT_OUTPUT_MODULES ${DEFAULT_OUTPUT_MODULE})
else()
list(GET OUTPUT_MODULES 0 _DEFAULT_OUTPUT_MODULE)
set(DEFAULT_OUTPUT_MODULE ${_DEFAULT_OUTPUT_MODULE} CACHE STRING "Default output module")
if(BUILD_SHARED_LIBS)
string(REPLACE ";" "," DEFAULT_OUTPUT_MODULES "${OUTPUT_MODULES}")
else()
set(DEFAULT_OUTPUT_MODULES ${DEFAULT_OUTPUT_MODULE})
endif()
set_property(CACHE DEFAULT_OUTPUT_MODULE PROPERTY STRINGS ${OUTPUT_MODULES})
endif()
endif()
option(ACCURATE_ROUNDING "use rounding instead of fast truncation for integer output, where possible" ON)
cmake_dependent_option(FIFO "FIFO support for control interface" ON "HAVE_MKFIFO" OFF)
option(GAPLESS "enable gapless" ON)
option(IEEE_FLOAT "use special hackery relying on IEEE 754 floating point storage format (to accurately round to 16 bit integer at bit more efficiently in generic decoder, enabled by default, disable in case you have a very special computer)" ON)
cmake_dependent_option(IPV6 "IPv6 support (actually any protocol your libc does with getaddrinfo)" ON "HAVE_IPV6" OFF)
if(CMAKE_C_COMPILER_ID MATCHES "GNU|Clang")
option(NAGGING "turn on GCC's pedantic nagging with error on warnings" OFF)
if(NAGGING)
set(CMAKE_C_STANDARD 99)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Werror -pedantic")
endif()
endif()
cmake_dependent_option(NETWORK "network support (http streams / webradio)" ON "HAVE_NETWORK" OFF)
option(NEWOLD_WRITE_SAMPLE "enable new/old WRITE_SAMPLE macro for non-accurate 16 bit output, faster on certain CPUs (default on on x86-32)" OFF)
cmake_dependent_option(NO_BUFFER "enable audio buffer code (default uses system whitelist... proper checks later)" OFF "HAVE_MMAP OR HAVE_SYS_IPC_H AND HAVE_SYS_SHM_H AND HAVE_SHMGET AND HAVE_SHMAT AND HAVE_SHMDT AND HAVE_SHMCTL" ON)
option(NO_DOWNSAMPLE "no downsampled decoding" OFF)
option(NO_EQUALIZER "no equalizer support" OFF)
option(NO_FEEDER "no feeder decoding, no buffered readers" OFF)
if(CYGWIN)
option(NO_LFS_ALIAS "disable alias wrappers for largefile bitness (mpg123_seek_32 or mpg123_seek_64 in addition to mpg123_seek, or the other way around; It is a mess, do not play with this!)" ON)
elseif(MSVC)
set(NO_LFS_ALIAS ON)
else()
option(NO_LFS_ALIAS "disable alias wrappers for largefile bitness (mpg123_seek_32 or mpg123_seek_64 in addition to mpg123_seek, or the other way around; It is a mess, do not play with this!)" OFF)
endif()
option(NO_ICY "ICY metainfo parsing/conversion" OFF)
option(NO_LAYER1 "no layer I decoding" OFF)
option(NO_LAYER2 "no layer II decoding" OFF)
option(NO_LAYER3 "no layer III decoding" OFF)
option(NO_MESSAGES "no error/warning messages on the console" OFF)
option(NO_MOREINFO "no extra information for frame analyzers" OFF)
option(NO_NTOM "no flexible resampling" OFF)
option(NO_16BIT "no 16 bit integer output" OFF)
option(NO_32BIT "no 32 bit integer output (also 24 bit)" OFF)
cmake_dependent_option(NO_8BIT "no 8 bit integer output" OFF "NOT NO_16BIT" ON)
option(NO_REAL "no real (floating point) output" OFF)
option(NO_STRING "no string API (this will disable ID3v2; main mpg123 won't build anymore)" OFF)
cmake_dependent_option(NO_ID3V2 "no ID3v2 parsing" OFF "NOT NO_STRING" ON)
option(SYN123_NO_CASES "include special cases for likely parameter values (channel count, encoding sizes in libsyn123 routines) in the hope of better optimization at the expense of some code bloat (default enabled)" OFF)
cmake_dependent_option(USE_MODULES "dynamically loadable output modules" ON "BUILD_SHARED_LIBS;HAVE_WIN_DL OR HAVE_UNIX_DL" OFF)
option(USE_NEW_HUFFTABLE "use new huffman decoding scheme by Taihei (faster on modern CPUs at least, so on by default)" ON)
configure_file(config.cmake.h.in config.h)
include_directories(
"${CMAKE_CURRENT_SOURCE_DIR}/../../../src/"
"${CMAKE_CURRENT_BINARY_DIR}"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../src/compat"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../src/libmpg123")
add_compile_definitions(
$<$<BOOL:${WIN32}>:_CRT_SECURE_NO_WARNINGS>
$<$<BOOL:${NO_BUFFER}>:NOXFERMEM>
$<$<BOOL:${NEWOLD_WRITE_SAMPLE}>:NEWOLD_WRITE_SAMPLE>)
add_compile_options(
$<$<BOOL:${MSVC}>:/wd4996>)
add_subdirectory("compat")
add_subdirectory("libmpg123")
if(BUILD_LIBOUT123)
add_subdirectory("libout123")
endif()
add_subdirectory("libsyn123")
if(UNIX)
option(BUILD_PROGRAMS "Build programs" ON)
if(BUILD_PROGRAMS)
add_subdirectory("tests")
if(BUILD_LIBOUT123)
add_executable(${PROJECT_NAME}
"${CMAKE_CURRENT_SOURCE_DIR}/../../../src/audio.c"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../src/common.c"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../src/sysutil.c"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../src/control_generic.c"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../src/equalizer.c"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../src/getlopt.c"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../src/httpget.c"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../src/resolver.c"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../src/genre.c"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../src/mpg123.c"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../src/metaprint.c"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../src/local.c"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../src/playlist.c"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../src/streamdump.c"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../src/term.c")
target_link_libraries(${PROJECT_NAME} PRIVATE
compat
lib${PROJECT_NAME}
libout123
libsyn123
${GETHOSTBYNAME_LIB}
${SOCKET_LIB}
$<$<BOOL:${HAVE_M}>:m>)
add_executable(out123
"${CMAKE_CURRENT_SOURCE_DIR}/../../../src/sysutil.c"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../src/getlopt.c"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../src/filters.c"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../src/local.c"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../src/out123.c")
target_link_libraries(out123 PRIVATE
lib${PROJECT_NAME}
libout123
libsyn123)
install(TARGETS ${PROJECT_NAME} out123
EXPORT targets
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}/"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}/"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}/")
endif()
add_executable(${PROJECT_NAME}-id3dump
"${CMAKE_CURRENT_SOURCE_DIR}/../../../src/mpg123-id3dump.c"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../src/getlopt.c")
target_link_libraries(${PROJECT_NAME}-id3dump PRIVATE
lib${PROJECT_NAME})
add_executable(${PROJECT_NAME}-strip
"${CMAKE_CURRENT_SOURCE_DIR}/../../../src/mpg123-strip.c"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../src/getlopt.c")
target_link_libraries(${PROJECT_NAME}-strip PRIVATE
lib${PROJECT_NAME}
libsyn123)
install(TARGETS ${PROJECT_NAME}-id3dump ${PROJECT_NAME}-strip
EXPORT targets
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}/"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}/"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}/")
endif()
endif()

View File

@@ -0,0 +1,13 @@
set(TARGET compat)
add_library(${TARGET} OBJECT
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/compat/compat.c"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/compat/compat_str.c")
set_target_properties(${TARGET} PROPERTIES POSITION_INDEPENDENT_CODE ON)
add_library(${TARGET}_dl OBJECT
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/compat/compat_dl.c")
set_target_properties(${TARGET}_dl PROPERTIES POSITION_INDEPENDENT_CODE ON)
add_library(${TARGET}_str OBJECT
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/compat/compat_str.c")
set_target_properties(${TARGET}_dl PROPERTIES POSITION_INDEPENDENT_CODE ON)

View File

@@ -0,0 +1,169 @@
// Define to use proper rounding.
#cmakedefine ACCURATE_ROUNDING 1
// Define if .balign is present.
#cmakedefine ASMALIGN_BALIGN 1
// Define if .align takes 3 for alignment of 2^3=8 bytes instead of 8.
#cmakedefine ASMALIGN_EXP 1
// Define if .align just takes byte count.
#cmakedefine ASMALIGN_BYTE 1
// Define if __attribute__((aligned(16))) shall be used
#cmakedefine CCALIGN 1
#define DEFAULT_OUTPUT_MODULE "@DEFAULT_OUTPUT_MODULES@"
#cmakedefine DEBUG 1
#cmakedefine DYNAMIC_BUILD 1
// Define if FIFO support is enabled.
#cmakedefine FIFO 1
// Define if frame index should be used.
#cmakedefine FRAME_INDEX 1
#cmakedefine GAPLESS 1
#cmakedefine HAVE_ATOLL 1
#cmakedefine HAVE_DIRENT_H 1
#cmakedefine HAVE_DLFCN_H 1
#cmakedefine HAVE_INTTYPES_H 1
#cmakedefine HAVE_LANGINFO_H 1
#cmakedefine HAVE_LIMITS_H 1
#cmakedefine HAVE_LOCALE_H 1
#cmakedefine HAVE_NL_LANGINFO 1
#cmakedefine HAVE_RANDOM 1
#cmakedefine HAVE_SCHED_H 1
#cmakedefine HAVE_SETLOCALE 1
#cmakedefine HAVE_SETPRIORITY 1
#cmakedefine HAVE_SIGNAL_H 1
#cmakedefine HAVE_STDIO_H 1
#cmakedefine HAVE_STDINT_H 1
#cmakedefine HAVE_STDLIB_H 1
#cmakedefine HAVE_STRERROR 1
#cmakedefine HAVE_STRING_H 1
#cmakedefine HAVE_SYS_IOCTL_H 1
#cmakedefine HAVE_SYS_RESOURCE_H 1
#cmakedefine HAVE_SYS_SELECT_H 1
#cmakedefine HAVE_SYS_SIGNAL_H 1
#cmakedefine HAVE_SYS_STAT_H 1
#cmakedefine HAVE_SYS_TIME_H 1
#cmakedefine HAVE_SYS_TYPES_H 1
#cmakedefine HAVE_SYS_WAIT_H 1
// Define this if you have the POSIX termios library
#cmakedefine HAVE_TERMIOS 1
#cmakedefine HAVE_UNISTD_H 1
#cmakedefine HAVE_WINDOWS_H 1
// Define to indicate that float storage follows IEEE754.
#cmakedefine IEEE_FLOAT 1
#define INDEX_SIZE @WITH_SEEKTABLE@
// Define if IPV6 support is enabled.
#cmakedefine IPV6 1
#define LFS_ALIAS_BITS @LFS_ALIAS_BITS@
#define LT_MODULE_EXT "@CMAKE_SHARED_MODULE_SUFFIX@"
// Define if network support is enabled.
#cmakedefine NETWORK 1
// Define to disable downsampled decoding.
#cmakedefine NO_DOWNSAMPLE 1
// Define to disable equalizer.
#cmakedefine NO_EQUALIZER 1
// Define to disable error messages in combination with a return value (the return is left intact).
#cmakedefine NO_ERETURN 1
// Define to disable error messages.
#cmakedefine NO_ERRORMSG 1
// no feeder decoding, no buffered readers
#cmakedefine NO_FEEDER 1
// Define to disable ICY handling.
#cmakedefine NO_ICY 1
// Define to disable ID3v2 parsing.
#cmakedefine NO_ID3V2 1
// Define to disable layer I.
#cmakedefine NO_LAYER1 1
// Define to disable layer II.
#cmakedefine NO_LAYER2 1
// Define to disable layer III.
#cmakedefine NO_LAYER3 1
// Define to disable analyzer info.
#cmakedefine NO_MOREINFO 1
// Define to disable ntom resampling.
#cmakedefine NO_NTOM 1
// Define to disable 8 bit integer output.
#cmakedefine NO_8BIT 1
// Define to disable 16 bit integer output.
#cmakedefine NO_16BIT 1
// Define to disable 32 bit and 24 bit integer output.
#cmakedefine NO_32BIT 1
// Define to disable real output.
#cmakedefine NO_REAL 1
// Define to disable string functions.
#cmakedefine NO_STRING 1
// Define for post-processed 32 bit formats.
#cmakedefine NO_SYNTH32 1
// Define to disable warning messages.
#cmakedefine NO_WARNING 1
#define PACKAGE_NAME "@PROJECT_NAME@"
#define PACKAGE_VERSION "@PROJECT_VERSION@"
#define PKGLIBDIR "@CMAKE_INSTALL_LIBDIR@/@PROJECT_NAME@"
#define SIZEOF_LONG @SIZEOF_LONG@
#define SIZEOF_OFF_T @SIZEOF_OFF_T@
#cmakedefine STDERR_FILENO @STDERR_FILENO@
#cmakedefine STDIN_FILENO @STDIN_FILENO@
#cmakedefine STDOUT_FILENO @STDOUT_FILENO@
// Define to not duplicate some code for likely cases in libsyn123.
#cmakedefine SYN123_NO_CASES 1
#cmakedefine USE_MODULES 1
// Define for new Huffman decoding scheme.
#cmakedefine USE_NEW_HUFFTABLE 1
// Define to use Unicode for Windows
#cmakedefine WANT_WIN32_UNICODE 1
#if WANT_WIN32_UNICODE == 1
# define strcasecmp _stricmp
# define strncasecmp _strnicmp
#endif
// Define to use Win32 named pipes
#cmakedefine WANT_WIN32_FIFO 1
#cmakedefine WORDS_BIGENDIAN 1
// Number of bits in a file offset, on hosts where this is settable.
#cmakedefine _FILE_OFFSET_BITS @_FILE_OFFSET_BITS@
// Define to the native offset type (long or actually off_t).
#define lfs_alias_t @LFS_ALIAS_TYPE@

View File

@@ -0,0 +1,262 @@
cmake_minimum_required(VERSION 3.12)
option(NO_FEATURE_REPORT "Disable feature report function" OFF)
option(NO_LFS_ALIAS "disable alias wrappers for largefile bitness (mpg123_seek_32 or mpg123_seek_64 in addition to mpg123_seek, or the other way around; It is a mess, do not play with this!)" OFF)
include_directories("${CMAKE_CURRENT_BINARY_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/")
include(../../cmake/CheckCPUArch.cmake)
if(HAVE_STDLIB_H)
set(INCLUDE_STDLIB_H "#include <stdlib.h>")
else()
set(INCLUDE_STDLIB_H "/* #include <stdlib.h> is not available on this system */")
endif()
if(HAVE_SYS_TYPES_H)
set(INCLUDE_SYS_TYPE_H "#include <sys/types.h>")
else()
set(INCLUDE_SYS_TYPE_H "/* #include <sys/types.h> is not available on this system */")
endif()
check_cpu_arch_x86(ARCH_IS_X86)
check_cpu_arch_x64(ARCH_IS_X64)
check_cpu_arch_arm32(ARCH_IS_ARM32)
check_cpu_arch_arm64(ARCH_IS_ARM64)
# PPC with AltiVec is missing. But probably obsolete enough for CMake users.
if(ARCH_IS_X64)
set(MACHINE amd64)
elseif(ARCH_IS_X86)
set(MACHINE x86)
elseif(ARCH_IS_ARM64)
set(MACHINE arm64)
elseif(ARCH_IS_ARM32)
set(MACHINE arm32)
else()
message(WARNING "Unknown processor. Using generic optimizations.")
set(MACHINE generic)
endif()
message(STATUS "Detected machine: ${MACHINE}")
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/mpg123.h.in" mpg123.h)
set(TARGET lib${PROJECT_NAME})
add_library(${TARGET}
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/parse.c"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/frame.c"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/format.c"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/dct64.c"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/equalizer.c"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/id3.c"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/optimize.c"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/readers.c"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/tabinit.c"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/libmpg123.c"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/index.c"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/$<$<NOT:$<BOOL:${NO_ICY}>>:icy.c>"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/$<$<NOT:$<BOOL:${NO_ICY}>>:icy2utf8.c>"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/$<$<NOT:$<BOOL:${NO_LAYER1}>>:layer1.c>"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/$<$<NOT:$<OR:$<BOOL:${NO_LAYER1}>,$<BOOL:${NO_LAYER2}>>>:layer2.c>"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/$<$<NOT:$<BOOL:${NO_LAYER3}>>:layer3.c>"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/$<$<NOT:$<BOOL:${NO_LFS_ALIAS}>>:lfs_alias.c>"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/$<$<NOT:$<BOOL:${NO_NTOM}>>:ntom.c>"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/$<$<NOT:$<BOOL:${NO_8BIT}>>:synth_8bit.c>"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/$<$<NOT:$<BOOL:${NO_16BIT}>>:synth.c>"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/$<$<AND:$<BOOL:${HAVE_FPU}>,$<NOT:$<BOOL:${NO_32BIT}>>>:synth_s32.c>"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/$<$<AND:$<BOOL:${HAVE_FPU}>,$<NOT:$<BOOL:${NO_REAL}>>>:synth_real.c>"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/$<$<NOT:$<BOOL:${NO_STRING}>>:stringbuf.c>"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/$<$<NOT:$<BOOL:${NO_FEATURE_REPORT}>>:feature.c>"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/$<$<BOOL:${LFS_SENSITIVE}>:lfs_wrap.c>"
$<TARGET_OBJECTS:compat>)
if(MACHINE STREQUAL "amd64")
if(HAVE_FPU)
set(PLATFORM_DEFINITIONS OPT_MULTI OPT_X86_64 OPT_AVX OPT_GENERIC OPT_GENERIC_DITHER)
set(PLATFORM_SOURCES
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/dct36_x86_64.S"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/dct64_x86_64_float.S"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/synth_x86_64_float.S"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/synth_x86_64_s32.S"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/synth_stereo_x86_64_float.S"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/synth_stereo_x86_64_s32.S"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/dct36_avx.S"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/dct64_avx_float.S"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/synth_stereo_avx_float.S"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/synth_stereo_avx_s32.S"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/getcpuflags_x86_64.S")
target_sources(${TARGET} PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/dither.c")
if(ACCURATE_ROUNDING)
list(APPEND PLATFORM_SOURCES
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/synth_x86_64_accurate.S"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/synth_stereo_x86_64_accurate.S"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/synth_stereo_avx_accurate.S")
else()
list(APPEND PLATFORM_SOURCES
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/dct64_x86_64.S"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/synth_x86_64.S"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/synth_stereo_x86_64.S"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/synth_stereo_avx.S"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/dct64_avx.S")
endif()
else()
set(PLATFORM_DEFINITIONS OPT_GENERIC)
endif()
elseif(MACHINE STREQUAL "x86")
if(TRUE)
set(PLATFORM_DEFINITIONS OPT_I386)
target_sources(${TARGET} PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/dct64_i386.c")
endif()
cmake_host_system_information(RESULT HAVE_SSE QUERY HAS_SSE)
if(HAVE_SSE)
set(PLATFORM_DEFINITIONS OPT_SSE)
set(PLATFORM_SOURCES
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/tabinit_mmx.S"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/dct36_sse.S"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/dct64_sse_float.S"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/synth_sse_float.S"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/synth_stereo_sse_float.S"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/synth_sse_s32.S"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/synth_stereo_sse_s32.S")
if(ACCURATE_ROUNDING)
list(APPEND PLATFORM_SOURCES
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/synth_sse_accurate.S"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/synth_stereo_sse_accurate.S")
else()
list(APPEND PLATFORM_SOURCES
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/dct64_sse.S"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/synth_sse.S")
endif()
target_sources(${TARGET} PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/dct64_i386.c")
endif()
elseif(MACHINE STREQUAL "arm64")
if(MSVC)
set(PLATFORM_DEFINITIONS OPT_GENERIC)
message(WARNING "Cannot use platform-specific assembly sources on MSVC")
else()
set(PLATFORM_DEFINITIONS OPT_MULTI OPT_GENERIC OPT_GENERIC_DITHER OPT_NEON64)
set(PLATFORM_SOURCES
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/dct36_neon64.S"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/dct64_neon64_float.S"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/synth_neon64_float.S"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/synth_neon64_s32.S"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/synth_stereo_neon64_float.S"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/synth_stereo_neon64_s32.S"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/check_neon.S")
if(ACCURATE_ROUNDING)
list(APPEND PLATFORM_SOURCES
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/synth_neon64_accurate.S"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/synth_stereo_neon64_accurate.S")
else()
list(APPEND PLATFORM_SOURCES
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/synth_neon64.S"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/synth_stereo_neon64.S")
endif()
target_sources(${TARGET} PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/dither.c"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/getcpuflags_arm.c")
endif()
elseif(MACHINE STREQUAL "arm32")
if(HAVE_FPU)
if(MSVC)
set(PLATFORM_DEFINITIONS OPT_GENERIC)
message(WARNING "Cannot use platform-specific assembly sources on MSVC")
else()
set(PLATFORM_DEFINITIONS OPT_MULTI OPT_GENERIC OPT_GENERIC_DITHER OPT_NEON)
set(PLATFORM_SOURCES
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/dct36_neon.S"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/dct64_neon_float.S"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/synth_neon_float.S"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/synth_neon_s32.S"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/synth_stereo_neon_float.S"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/synth_stereo_neon_s32.S"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/check_neon.S")
target_sources(${TARGET} PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/getcpuflags_arm.c")
if(ACCURATE_ROUNDING)
list(APPEND PLATFORM_SOURCES
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/synth_neon_accurate.S"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/synth_stereo_neon_accurate.S")
else()
list(APPEND PLATFORM_SOURCES
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/dct64_neon.S"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/synth_neon.S"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/synth_stereo_neon.S")
endif()
target_sources(${TARGET} PRIVATE ${PLATFORM_SOURCES})
target_sources(${TARGET} PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/dither.c")
endif()
else()
if(MSVC)
set(PLATFORM_DEFINITIONS OPT_GENERIC)
message(WARNING "Cannot use platform-specific assembly sources on MSVC")
else()
set(PLATFORM_DEFINITIONS OPT_ARM)
if(ACCURATE_ROUNDING)
set(PLATFORM_SOURCES
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/synth_arm_accurate.S")
else()
set(PLATFORM_SOURCES
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/synth_arm.S")
endif()
target_sources(${TARGET} PRIVATE ${PLATFORM_SOURCES})
endif()
endif()
elseif(MACHINE STREQUAL "generic")
set(PLATFORM_DEFINITIONS OPT_GENERIC)
endif()
set_target_properties(${TARGET} PROPERTIES OUTPUT_NAME mpg123)
target_compile_definitions(${TARGET} PRIVATE
${PLATFORM_DEFINITIONS}
$<$<BOOL:${HAVE_FPU}>:REAL_IS_FLOAT>
$<$<NOT:$<BOOL:${HAVE_FPU}>>:REAL_IS_FIXED>)
if(MSVC AND MACHINE MATCHES "x86|amd64")
find_program(YASM_ASSEMBLER yasm)
if(NOT YASM_ASSEMBLER)
message(FATAL_ERROR "Couldn't find yasm assembler. Please set YASM_ASSEMBLER variable")
endif()
list(TRANSFORM PLATFORM_DEFINITIONS PREPEND /D)
foreach(FILE ${PLATFORM_SOURCES})
get_filename_component(FILENAME ${FILE} NAME)
add_custom_command(
OUTPUT ${FILENAME}.asm
COMMAND ${CMAKE_C_COMPILER} /DASMALIGN_BALIGN ${PLATFORM_DEFINITIONS}
/I"${PROJECT_SOURCE_DIR}/../../src" /I"${PROJECT_BINARY_DIR}/src" /P /Fi${FILENAME}.asm /Tc "${FILE}"
DEPENDS ${FILE}
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
add_custom_command(
OUTPUT ${FILENAME}.obj
COMMAND ${YASM_ASSEMBLER} -a x86 -m ${MACHINE} -p gas -r raw -f win32 -g null -o ${FILENAME}.obj ${FILENAME}.asm
DEPENDS ${FILENAME}.asm
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
target_sources(${TARGET} PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/${FILENAME}.obj")
endforeach()
else()
target_sources(${TARGET} PRIVATE ${PLATFORM_SOURCES})
endif()
target_link_libraries(${TARGET} PRIVATE
$<$<BOOL:${HAVE_M}>:m>
$<$<BOOL:${WANT_WIN32_UNICODE}>:shlwapi>)
target_include_directories(${TARGET} INTERFACE
"$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>")
install(TARGETS ${TARGET} EXPORT targets
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}/"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}/"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}/")
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/mpg123.h"
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/fmt123.h"
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")

View File

@@ -0,0 +1,37 @@
cmake_minimum_required(VERSION 3.12)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libout123/out123.h.in" out123.h)
include_directories("${CMAKE_CURRENT_BINARY_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libout123/")
add_subdirectory("modules")
set(TARGET libout123)
add_library(${TARGET}
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libout123/libout123.c"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libout123/stringlists.c"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libout123/wav.c"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libout123/hextxt.c"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libout123/$<$<NOT:$<BOOL:${NO_BUFFER}>>:buffer.c>"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libout123/$<$<NOT:$<BOOL:${NO_BUFFER}>>:xfermem.c>"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libout123/$<$<BOOL:${USE_MODULES}>:module.c>"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libout123/$<$<NOT:$<BOOL:${USE_MODULES}>>:legacy_module.c>"
$<TARGET_OBJECTS:compat>
$<$<BOOL:${USE_MODULES}>:$<TARGET_OBJECTS:compat_dl>>)
set_target_properties(${TARGET} PROPERTIES OUTPUT_NAME out123)
target_link_libraries(${TARGET} PRIVATE
$<TARGET_NAME_IF_EXISTS:defaultmodule>
$<$<BOOL:${HAVE_UNIX_DL}>:dl>
$<$<BOOL:${WANT_WIN32_UNICODE}>:shlwapi>)
target_include_directories(${TARGET} INTERFACE
"$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>")
install(TARGETS ${TARGET} EXPORT targets
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}/"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}/"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}/")
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/out123.h"
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")

View File

@@ -0,0 +1,99 @@
if(NOT USE_MODULES)
add_library(defaultmodule STATIC
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/libout123/modules/$<$<STREQUAL:${DEFAULT_OUTPUT_MODULE},dummy>:dummy.c>"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/libout123/modules/$<$<STREQUAL:${DEFAULT_OUTPUT_MODULE},coreaudio>:coreaudio.c>"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/libout123/modules/$<$<STREQUAL:${DEFAULT_OUTPUT_MODULE},alsa>:alsa.c>"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/libout123/modules/$<$<STREQUAL:${DEFAULT_OUTPUT_MODULE},tinyalsa>:tinyalsa.c>"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/libout123/modules/$<$<STREQUAL:${DEFAULT_OUTPUT_MODULE},pulse>:pulse.c>"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/libout123/modules/$<$<STREQUAL:${DEFAULT_OUTPUT_MODULE},jack>:jack.c>"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/libout123/modules/$<$<STREQUAL:${DEFAULT_OUTPUT_MODULE},win32>:win32.c>"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/libout123/modules/$<$<STREQUAL:${DEFAULT_OUTPUT_MODULE},win32_wasapi>:win32_wasapi.c>")
target_link_libraries(defaultmodule PUBLIC
$<$<STREQUAL:${DEFAULT_OUTPUT_MODULE},alsa>:ALSA::ALSA>
$<$<STREQUAL:${DEFAULT_OUTPUT_MODULE},tinyalsa>:${TINYALSA_LIBRARIES}>
$<$<STREQUAL:${DEFAULT_OUTPUT_MODULE},coreaudio>:${AUDIO_TOOLBOX}>
$<$<STREQUAL:${DEFAULT_OUTPUT_MODULE},pulse>:${PULSE_LIBRARIES}>
$<$<STREQUAL:${DEFAULT_OUTPUT_MODULE},jack>:${JACK_LIBRARIES}>
$<$<STREQUAL:${DEFAULT_OUTPUT_MODULE},win32>:${WIN32_LIBRARIES}>
$<$<STREQUAL:${DEFAULT_OUTPUT_MODULE},win32_wasapi>:${WIN32_WASAPI_LIBRARIES}>)
if(DEFAULT_OUTPUT_MODULE STREQUAL "pulse")
target_compile_definitions(defaultmodule PRIVATE ${PULSE_CFLAGS})
elseif(DEFAULT_OUTPUT_MODULE STREQUAL "jack")
target_compile_definitions(defaultmodule PRIVATE ${JACK_CFLAGS})
elseif(DEFAULT_OUTPUT_MODULE STREQUAL "tinyalsa")
target_compile_definitions(defaultmodule PRIVATE ${TINYALSA_CFLAGS})
endif()
if(BUILD_SHARED_LIBS)
set_target_properties(defaultmodule PROPERTIES POSITION_INDEPENDENT_CODE ON)
endif()
else()
set(CMAKE_SHARED_MODULE_PREFIX "")
list(FIND OUTPUT_MODULES coreaudio INDEX)
if(NOT INDEX EQUAL -1)
add_library(output_coreaudio MODULE "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/libout123/modules/coreaudio.c")
target_link_libraries(output_coreaudio PRIVATE ${AUDIO_TOOLBOX})
install(TARGETS output_coreaudio
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}/${PROJECT_NAME}")
endif()
list(FIND OUTPUT_MODULES alsa INDEX)
if(NOT INDEX EQUAL -1)
add_library(output_alsa MODULE "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/libout123/modules/alsa.c")
target_link_libraries(output_alsa PRIVATE ALSA::ALSA)
install(TARGETS output_alsa
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}/${PROJECT_NAME}")
endif()
list(FIND OUTPUT_MODULES pulse INDEX)
if(NOT INDEX EQUAL -1)
add_library(output_pulse MODULE "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/libout123/modules/pulse.c")
target_compile_options(output_pulse PRIVATE ${PULSE_CFLAGS})
target_link_libraries(output_pulse PRIVATE ${PULSE_LIBRARIES})
install(TARGETS output_pulse
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}/${PROJECT_NAME}")
endif()
list(FIND OUTPUT_MODULES jack INDEX)
if(NOT INDEX EQUAL -1)
add_library(output_jack MODULE "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/libout123/modules/jack.c"
$<TARGET_OBJECTS:compat_str>)
target_compile_options(output_jack PRIVATE ${JACK_CFLAGS})
target_link_libraries(output_jack PRIVATE ${JACK_LIBRARIES})
install(TARGETS output_jack
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}/${PROJECT_NAME}")
endif()
list(FIND OUTPUT_MODULES tinyalsa INDEX)
if(NOT INDEX EQUAL -1)
add_library(output_tinyalsa MODULE "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/libout123/modules/tinyalsa.c")
target_compile_options(output_tinyalsa PRIVATE ${TINYALSA_CFLAGS})
target_link_libraries(output_tinyalsa PRIVATE ${TINYALSA_LIBRARIES})
install(TARGETS output_tinyalsa
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}/${PROJECT_NAME}")
endif()
list(FIND OUTPUT_MODULES win32 INDEX)
if(NOT INDEX EQUAL -1)
add_library(output_win32 MODULE "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/libout123/modules/win32.c")
target_link_libraries(output_win32 PRIVATE ${WIN32_LIBRARIES})
install(TARGETS output_win32
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}/${PROJECT_NAME}")
endif()
list(FIND OUTPUT_MODULES win32_wasapi INDEX)
if(NOT INDEX EQUAL -1)
add_library(output_win32_wasapi MODULE "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/libout123/modules/win32_wasapi.c"
$<TARGET_OBJECTS:compat_str>)
target_link_libraries(output_win32_wasapi PRIVATE ${WIN32_WASAPI_LIBRARIES})
install(TARGETS output_win32_wasapi
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}/${PROJECT_NAME}")
endif()
endif()

View File

@@ -0,0 +1,32 @@
cmake_minimum_required(VERSION 3.12)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libsyn123/syn123.h.in" syn123.h)
include_directories("${CMAKE_CURRENT_BINARY_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/../../../src/libsyn123/")
set(TARGET libsyn123)
add_library(${TARGET}
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libsyn123/pinknoise.c"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libsyn123/geiger.c"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libsyn123/libsyn123.c"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libsyn123/volume.c"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libsyn123/resample.c"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libsyn123/filter.c"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libsyn123/sampleconv.c"
$<TARGET_OBJECTS:compat_str>)
set_target_properties(${TARGET} PROPERTIES OUTPUT_NAME syn123)
target_include_directories(${TARGET} INTERFACE
"$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>")
target_link_libraries(${TARGET} PRIVATE
$<$<BOOL:${WANT_WIN32_UNICODE}>:shlwapi>)
install(TARGETS ${TARGET} EXPORT targets
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}/"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}/"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}/")
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/syn123.h"
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")

View File

@@ -0,0 +1,13 @@
add_executable(seek_whence "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/tests/seek_whence.c")
target_link_libraries(seek_whence PRIVATE lib${PROJECT_NAME})
add_executable(noise "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/tests/noise.c")
target_link_libraries(noise PRIVATE lib${PROJECT_NAME})
add_executable(text "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/tests/text.c")
target_link_libraries(text PRIVATE lib${PROJECT_NAME})
add_test(NAME text COMMAND text)
add_executable(plain_id3 "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/tests/plain_id3.c")
target_link_libraries(plain_id3 PRIVATE lib${PROJECT_NAME})
add_test(NAME plain_id3 COMMAND plain_id3)

64
scripts/benchmark-cpu.pl Executable file
View File

@@ -0,0 +1,64 @@
#!/usr/bin/perl
#
# benchmark-cpu.pl: benchmark CPU optimizations of mpg123
#
# initially written by Nicholas J Humfrey <njh@aelius.com>, placed in the public domain
#
use strict;
#use Time::HiRes qw/time/;
my $MPG123_CMD = shift @ARGV;
my @TEST_FILES = @ARGV;
die "Please specify full path to mpg123 >= 1.7.0 and a test MP3 file to decode" if (scalar(@ARGV) < 1);
die "mpg123 command does not exist" unless (-e $MPG123_CMD);
die "mpg123 command is not executable" unless (-x $MPG123_CMD);
for(@TEST_FILES)
{
die "test MP3 file does not exist" unless (-e $_);
}
# Force unbuffed output on STDOUT
#$|=1; # why?
# Check the CPUs available
my $cpulist = `$MPG123_CMD --test-cpu`;
chomp( $cpulist );
die "Failed to get list of available CPU optimizations" unless ($cpulist =~ s/^Supported decoders: //);
my @cpus = split( / /, $cpulist );
my @encs = qw(s16 f32);
printf STDERR ("Found %d CPU optimizations to test...\n\n", scalar(@cpus) );
print "#mpg123 benchmark (user CPU time in seconds for decoding)\n";
print "#decoder";
for(@encs){ print " t_$_/s"; }
print "\n";
my $allret = 0;
foreach my $cpu (@cpus)
{
print "$cpu";
foreach my $e (@encs)
{
# using user CPU time
my @start_time = times();
my $ret = system($MPG123_CMD, '-q', '--cpu', $cpu, '-e', $e, '-t', @TEST_FILES );
my @end_time = times();
my $runtime = $end_time[2] - $start_time[2];
if($ret)
{
print STDERR "Execution of $MPG123_CMD failed with code $ret!\n";
$runtime = 0;
$allret = 1;
}
# third entry is child user time
printf(" %4.2f", $runtime);
}
print("\n");
}
exit($allret);

133
scripts/conplay Executable file
View File

@@ -0,0 +1,133 @@
#!/usr/bin/env perl
# Hacked by Thomas Orgis, use at your leisure.
use strict;
use locale;
use File::Basename qw(basename dirname);
my @mpg123_command = qw(mpg123 --continue -Cv --rva-album);
my $listfile = "conplay.m3u";
my $glob = '*.mp[123]';
my $dir = shift;
unless(defined $dir)
{
print STDERR "\nThis little wrapper runs $mpg123_command[0] on a given directory (hand in '.' for the current one), playing all $glob files therein in terminal control mode. The extra trick is that a playlist file ($listfile by default) is read and updated (created) with the position you left playback at (via 'q' key), to return on next invokation.\n";
print STDERR "\nIf you give an existing file instead of a directory, or some non-existing path, as first and only paramter, it is used as playlist name and the directory part is used as the base directory for playback.\n";
print STDERR "\nThe name stands for CONtinued PLAYback. What did you think?;-)\n\n";
exit;
}
if(-f $dir or (not -e $dir))
{
$listfile = basename($dir);
$dir = dirname($dir);
}
chdir($dir) or die "Cannot enter $dir ($!)!\n";
print STDERR "Playing things in: $dir\n";
my @files;
my $entry = 1;
my $frame = 0;
if(-e $listfile)
{
open(LIST, '<', $listfile) or die "Cannot read playlist ($!)!\n";
while(<LIST>)
{
chomp;
unless(/^#/)
{
push(@files, $_);
}
elsif(/^#\s*current entry:\s*(\d+)$/)
{
$entry = $1;
}
elsif(/^#\s*current frame:\s*(\d+)$/)
{
$frame = $1;
}
}
close(LIST);
}
else
{
@files = get_files($glob);
write_list();
}
unless(@files)
{
print STDERR "There are no files to play.\n";
exit;
}
if($entry < 0 or $entry > @files or $frame < 0)
{
die "You got bad data in your playlist file (mismatch between current entry and total count, bad frame index). Clean that up.\n";
}
push(@mpg123_command, '-k', $frame, '--listentry', $entry, '-@', $listfile);
print STDERR "running player:\n\t@mpg123_command\n\n";
open(MPG123, '-|', @mpg123_command) or die "Cannot run mpg123!";
while(<MPG123>)
{
print STDOUT $_;
if(/^\[CONTINUE\]\s+track\s+(\d+)\s+frame\s+(\d+)/)
{
$entry = $1;
$frame = $2;
}
if(/^\[BOOKMARK\]\s+track\s+(\d+)\s+frame\s+(\d+)/)
{
print STDERR "\nGot bookmark at track $1, frame $2; not yet doing anything with that, besides storing.\n";
$entry = $1;
$frame = $2;
}
}
close(MPG123);
if($entry > @files)
{
$entry = 0;
$frame = 0;
}
print STDERR "Continue point is in track $entry, frame $frame.\n";
write_list();
sub write_list
{
unless(@files)
{
print STDERR "Refusing to write empty playlist.\n";
return;
}
open(LIST, '>', $listfile) or die "Cannot write Playlist";
print LIST "#M3U\n";
print LIST "#current entry: $entry\n";
print LIST "#current frame: $frame\n";
for my $f (@files)
{
print LIST "$f\n";
}
close(LIST);
}
sub get_files
{
my $glob = shift;
my @files;
open(FIND, '-|', 'find', '.', '-type', 'f', '-name', $glob) or die "Cannot exec find to find files: ($!)\n";
@files = <FIND>;
close(FIND);
chomp(@files);
return sort @files;
}

71
scripts/mpg123info Executable file
View File

@@ -0,0 +1,71 @@
#!/bin/bash
if test $# -eq 0; then
echo "Give me some MPEG 1.0/2.0/2.5 layer 1/2/3 audio file name(s) and I give you meta info about it in an easily-parseable format:
name=value
for simple value association and
name.=value
to add another line to existing value (multiline comments)."
fi
for i in "$@"
do
echo lp "$i"
echo tag
echo scan
echo format
echo sample
done |
mpg123 -t -R |
perl -e '
while(<STDIN>)
{
if(/\@T \{/)
{
print "# meta info for: ".(shift @ARGV)."\n";
$field = undef;
%count = ();
%linecount = ();
}
elsif(/\@T ID3:(.*)$/)
{
$field = undef;
print "ID3v1.title=".substr($1, 0, 30)."\n";
print "ID3v1.artist=".substr($1, 30, 30)."\n";
print "ID3v1.album=".substr($1, 60, 30)."\n";
print "ID3v1.year=".substr($1, 90, 4)."\n";
print "ID3v1.comment=".substr($1, 94, 30)."\n";
print "ID3v1.genre=".substr($1, 124)."\n";
}
elsif(/\@T ID3\.([^:]+):(.*)$/)
{
$field = undef;
print "ID3.$1=$2\n";
}
elsif(/\@T (ID3v2\.\S{4})(|\s+lang\(([^\(\)]*)\)\s+desc\(([^\(\)]*)\)):/)
{
$class = $1;
$field = ++$count{$class} > 1 ? "$class$count{$class}" : $class;
print "$field.lang=$3\n" if(defined $3);
print "$field.desc=$4\n" if(defined $4);
}
elsif(/\@T =(.*)$/)
{
next unless defined $field;
print "$field".(++$linecount{$field} > 1 ? ".=" : "=").$1."\n";
}
elsif(/\@FORMAT\s+(\d+)\s+(\d+)/)
{
print "format.rate=$1\n";
print "format.channels=$2\n";
}
elsif(/\@SAMPLE\s+(\d+)\s+(\d+)/)
{
print "samples=$2\n";
}
}
' "$@"

76
scripts/tag_lyrics.py Normal file
View File

@@ -0,0 +1,76 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# needs mutagen
# grabbed from: http://code.activestate.com/recipes/577138-embed-lyrics-into-mp3-files-using-mutagen-uslt-tag/
# simplified to only work on one file and get lyrics from stdin
# I suspect this is public domain code. Just a usage example of the mutagen lib.
import os
import sys
import codecs
from mutagen.mp3 import MP3
from mutagen.id3 import ID3NoHeaderError
from mutagen.id3 import ID3, USLT
TEXT_ENCODING = 'utf8'
TEXT_LANG = 'XXX'
TEXT_DESC = ''
# get workdir from first arg or use current dir
if (len(sys.argv) > 1):
fname = sys.argv[1]
print "fname=" + fname
else:
print 'Give me at least a file name to work on, plus the lyrics from stdin'
print 'Optionally, you can provide the language (3 lowercase letters) of the lyrics and a description'
sys.exit()
if (len(sys.argv) > 2):
TEXT_LANG = sys.argv[2]
if (len(sys.argv) > 3):
TEXT_DESC = sys.argv[3]
print "reading lyrics from standard input ..."
lyrics = sys.stdin.read().strip()
# try to find the right encoding
for enc in ('utf8','iso-8859-1','iso-8859-15','cp1252','cp1251','latin1'):
try:
lyrics = lyrics.decode(enc)
TEXT_DESC = TEXT_DESC.decode(enc)
print enc,
break
except:
pass
print "Adding lyrics to " + fname
print "Language: " + TEXT_LANG
print "Description: " + TEXT_DESC
# create ID3 tag if not exists
try:
tags = ID3(fname)
except ID3NoHeaderError:
print "Adding ID3 header;",
tags = ID3()
# remove old unsychronized lyrics
if len(tags.getall(u"USLT::'"+TEXT_LANG+"'")) != 0:
print "Removing Lyrics."
tags.delall(u"USLT::'"+TEXT_LANG+"'")
#tags.save(fname) # hm, why?
#tags.add(USLT(encoding=3, lang=u'eng', desc=u'desc', text=lyrics))
# apparently the description is important when more than one
# USLT frames are present
#tags[u"USLT::'eng'"] = (USLT(encoding=3, lang=u'eng', desc=u'desc', text=lyrics))
tags[u"USLT::'"+TEXT_LANG+"'"] = (USLT(encoding=3, lang=TEXT_LANG, desc=TEXT_DESC, text=lyrics))
print 'Added USLT frame to', fname
tags.save(fname)
print 'Done'

118
src/Makemodule.am Normal file
View File

@@ -0,0 +1,118 @@
# Module for non-recursive mpg123 build system.
include src/tests/Makemodule.am
include src/compat/Makemodule.am
include src/libmpg123/Makemodule.am
include src/libout123/Makemodule.am
include src/libsyn123/Makemodule.am
bin_PROGRAMS += \
src/mpg123 \
src/out123 \
src/mpg123-id3dump \
src/mpg123-strip
src_mpg123_LDADD = \
src/compat/libcompat.la \
src/libmpg123/libmpg123.la \
src/libout123/libout123.la \
src/libsyn123/libsyn123.la \
@PROG_LIBS@
src_mpg123_LDFLAGS = @EXEC_LT_LDFLAGS@
src_out123_LDADD = \
src/compat/libcompat.la \
src/libsyn123/libsyn123.la \
src/libout123/libout123.la \
@PROG_LIBS@
src_out123_LDFLAGS = @EXEC_LT_LDFLAGS@
EXTRA_DIST += \
src/intsym.h \
src/mpg123-with-modules \
src/out123-with-modules
CLEANFILES += src/*.a
src_mpg123_id3dump_LDADD = \
src/compat/libcompat.la \
src/libmpg123/libmpg123.la \
@PROG_LIBS@
src_mpg123_strip_LDADD = \
src/compat/libcompat.la \
src/libmpg123/libmpg123.la \
@PROG_LIBS@
src_mpg123_SOURCES = \
src/audio.c \
src/audio.h \
src/common.c \
src/common.h \
src/sysutil.c \
src/sysutil.h \
src/control_generic.c \
src/equalizer.c \
src/getlopt.c \
src/getlopt.h \
src/httpget.c \
src/httpget.h \
src/resolver.c \
src/resolver.h \
src/genre.h \
src/genre.c \
src/mpg123.c \
src/mpg123app.h \
src/metaprint.c \
src/metaprint.h \
src/local.h \
src/local.c \
src/playlist.c \
src/playlist.h \
src/streamdump.h \
src/streamdump.c \
src/term.c \
src/term.h \
src/win32_support.h
# Does that finally work to build/link the correct object file?
src_mpg123_SOURCES +=
# Replace common.h by sysutil.h!
src_out123_SOURCES = \
src/sysutil.c \
src/sysutil.h \
src/common.h \
src/getlopt.c \
src/getlopt.h \
src/local.h \
src/local.c \
src/filters.h \
src/filters.c \
src/out123.c \
src/mpg123app.h \
src/win32_support.h
src_mpg123_id3dump_SOURCES = \
src/mpg123-id3dump.c \
src/getlopt.c \
src/getlopt.h
src_mpg123_strip_SOURCES = \
src/mpg123-strip.c \
src/getlopt.c \
src/getlopt.h
if WIN32_CODES
src_mpg123_SOURCES += \
src/win32_support.c \
src/win32_net.c
src_out123_SOURCES+= \
src/win32_support.c
src_mpg123_id3dump_SOURCES += \
src/win32_support.c
endif

651
src/audio.c Normal file
View File

@@ -0,0 +1,651 @@
/*
audio: audio output interface
This wraps a bit of out123 now, with a layer of resampling using syn123.
copyright ?-2020 by the mpg123 project - free software under the terms of the LGPL 2.1
see COPYING and AUTHORS files in distribution or http://mpg123.org
initially written by Michael Hipp
Pitching can work in three ways:
- fixed (native) decoder rate, varied hardware playback rate
- fixed hardware playback rate, any decoder rate, resampler
- pitched NtoM decoder rate, fixed hardware
Just because ...
If you force an output rate, either the NtoM resampler in libmpg123 or the syn123
resampler wrapped here adapts the data.
TODO: If the proper resampler is configured, it should fill in unsupported output
rates automatically ... or not? Right now, I have the rule that you don't get
the expensive resampler unless you forced an output rate. But you do get the
libmpg123 NtoM resampling now if it finds only a working output rate that is
reachable via that. Well, imposing a resampler that needs more CPU time than
the decoder is just something that should not happen without being called for.
So I rather provide a warning to the user that the NtoM resampler has been
triggered. Yes, inform the user.
*/
#include <errno.h>
#include "mpg123app.h"
#include "audio.h"
#include "out123.h"
#include "syn123.h"
#include "common.h"
#include "metaprint.h"
#include "sysutil.h"
#ifdef HAVE_SYS_WAIT_H
#include <sys/wait.h>
#endif
#include "debug.h"
static syn123_handle *sh = NULL;
static struct mpg123_fmt outfmt = { .encoding=0, .rate=0, .channels=0 };
static int outch = 0; // currently used number of output channels
// A convoluted way to say outch*4, for semantic clarity.
#define RESAMPLE_FRAMESIZE(ch) ((ch)*MPG123_SAMPLESIZE(MPG123_ENC_FLOAT_32))
#define OUTPUT_FRAMESIZE(ch) ((ch)*MPG123_SAMPLESIZE(outfmt.encoding))
// Resampler buffers, first for resampling output, then for conversion.
// Instead of sizing them for any possible input rate, I'll try to
// loop in the output wrapper over a fixed buffer size. The syn123 resampler
// can tell me how many samples to feed to avoid exceeding the output buffer.
static char *resample_buffer = NULL;
static char* resample_outbuf = NULL;
static size_t resample_block = 0;
// A good buffer size:
// 1152*48/44.1*2*4 = 10032 ... let's go 16K.
// This should work for final output data, too.
// We'll loop over pieces if the buffer size is not enough for upsampling.
static size_t resample_bytes = 1<<16;
int do_resample = 0;
int do_resample_now = 0; // really apply resampler for current stream.
/* Quick-shot paired table setup with remembering search in it.
this is for storing pairs of output sampling rate and decoding
sampling rate. */
struct ratepair { long a; long b; };
static long *outrates = NULL;
static struct ratepair *unpitch = NULL;
static int audio_capabilities(out123_handle *ao, mpg123_handle *mh);
#define CLEAN_POINTER(p, func) if(p) func(p); p = NULL;
void audio_cleanup(void)
{
CLEAN_POINTER(outrates, free)
CLEAN_POINTER(unpitch, free)
CLEAN_POINTER(sh, syn123_del)
CLEAN_POINTER(resample_outbuf, free)
CLEAN_POINTER(resample_buffer, free)
}
int audio_setup(out123_handle *ao, mpg123_handle *mh)
{
do_resample = (param.force_rate > 0 && param.resample);
resample_block = 0;
// Settle formats.
if(audio_capabilities(ao, mh))
return -1;
// Prepare resample.
// Resampling only for forced rate for now. In future, pitching should
// also be handled.
if(do_resample)
{
int err;
sh = syn123_new(outfmt.rate, 1, outfmt.encoding, 0, &err);
if(!sh)
{
merror("Cannot initialize syn123: %s\n", syn123_strerror(err));
return -1;
}
resample_buffer = malloc(resample_bytes*10);
resample_outbuf = malloc(resample_bytes*10);
if(!resample_buffer || !resample_outbuf)
return -1;
}
return 0;
}
int audio_prepare( out123_handle *ao, mpg123_handle *mh
, long rate, int channels, int encoding )
{
mdebug( "audio_prepare %ld Hz / %ld Hz, %i ch, enc %s"
, rate, outfmt.rate, channels, out123_enc_name(encoding) );
if(do_resample && param.pitch == 0. && rate == outfmt.rate)
{
do_resample_now = 0;
if(param.verbose > 1)
fprintf(stderr, "Note: resampler disabled for native rate\n");
} else if(do_resample)
{
do_resample_now = 1;
// Smooth option could be considered once pitching is implemented with the
// resampler.The existing state might fit the coming data if this is two
// seamless tracks. If not, it's jut the first few samples that differ
// significantly depending on which data went through the resampler
// previously.
int err = syn123_setup_resample( sh, pitch_rate(rate), outfmt.rate, channels
, (param.resample < 2), 0 );
if(err)
{
merror("failed to set up resampler: %s", syn123_strerror(err));
return -1;
}
outch = channels;
// We can store a certain ammount of frames in the resampler buffer
// and the final output buffer after conversion.
size_t frames = resample_bytes / (
RESAMPLE_FRAMESIZE(channels) > OUTPUT_FRAMESIZE(channels)
? RESAMPLE_FRAMESIZE(channels)
: OUTPUT_FRAMESIZE(channels) );
// Minimum amount of input samples to fill the buffer.
resample_block = syn123_resample_fillcount(pitch_rate(rate), outfmt.rate, frames);
if(!resample_block)
return -1; // WTF? No comment.
if(param.verbose > 1)
fprintf(stderr, "Note: resampler setup: %ld Hz -> %ld Hz\n", pitch_rate(rate), outfmt.rate);
rate = outfmt.rate;
encoding = outfmt.encoding;
} else if(outfmt.rate)
rate = outfmt.rate; // That's pitching with NtoM.
else
{
struct mpg123_frameinfo fi;
static int ntom_warn = 0;
if( !ntom_warn && !param.quiet &&
MPG123_OK == mpg123_info(mh, &fi) && fi.rate != rate )
{
fprintf(stderr,
"\nWarning: You triggered the NtoM drop-sample resampler inside libmpg123.\n"
"Warning: You could trade CPU for quality by forcing a supported output rate.\n" );
ntom_warn = 1;
}
rate = pitch_rate(rate); // That's plain hardware pitching.
}
if(param.verbose > 1)
{
const char* encname = out123_enc_name(encoding);
fprintf( stderr // No extra line break, as this is a follow-up note.
, "Note: Hardware output format %li Hz, %i channels, encoding %s.\n"
, rate, channels, encname ? encname : "???" );
}
return out123_start(ao, rate, channels, encoding);
}
// Loop over blocks with the resampler, think about intflag.
size_t audio_play(out123_handle *ao, void *buffer, size_t bytes)
{
if(do_resample_now)
{
int fs = RESAMPLE_FRAMESIZE(outch);
size_t pcmframes = bytes/fs;
size_t done = 0;
while(pcmframes && !intflag)
{
size_t block = resample_block > pcmframes
? pcmframes
: resample_block;
size_t oblock = syn123_resample( sh, (float*)resample_buffer
, (float*)((char*)buffer+done), block );
if(!oblock)
break;
size_t obytes = 0;
if(syn123_conv( resample_outbuf, outfmt.encoding, resample_bytes
, resample_buffer, MPG123_ENC_FLOAT_32, oblock*fs
, &obytes, NULL, sh ))
break;
size_t oplay = out123_play(ao, resample_outbuf, obytes);
if(oplay < obytes)
{
// Need to translate that. How many input samples got played,
// actually? A bit of roundoff error doesn't hurt, so let's just
// wing it. Close is enough.
size_t iframes = (size_t)((double)oplay/obytes*block);
while(iframes >= block)
--iframes;
done += iframes*fs;
break;
}
pcmframes -= block;
done += block*fs;
}
return done;
}
else
return out123_play(ao, buffer, bytes);
}
mpg123_string* audio_enclist(void)
{
int i;
mpg123_string *list;
size_t enc_count = 0;
const int *enc_codes = NULL;
/* Only the encodings supported by libmpg123 build
Those returned by out123_enc_list() are a superset. */
mpg123_encodings(&enc_codes, &enc_count);
if((list = malloc(sizeof(*list))))
mpg123_init_string(list);
/* Further calls to mpg123 string lib are hardened against NULL. */
for(i=0;i<enc_count;++i)
{
if(i>0)
mpg123_add_string(list, " ");
mpg123_add_string(list, out123_enc_name(enc_codes[i]));
}
return list;
}
static void capline(mpg123_handle *mh, long rate, struct mpg123_fmt *outfmt)
{
int enci;
const int *encs;
size_t num_encs;
mpg123_encodings(&encs, &num_encs);
fprintf(stderr," %5ld |", outfmt ? outfmt->rate : rate);
for(enci=0; enci<num_encs; ++enci)
{
int fmt = outfmt
? (encs[enci] == outfmt->encoding ? outfmt->channels : 0)
: mpg123_format_support(mh, rate, encs[enci]);
switch(fmt)
{
case MPG123_MONO: fprintf(stderr, " M "); break;
case MPG123_STEREO: fprintf(stderr, " S "); break;
case MPG123_MONO|MPG123_STEREO: fprintf(stderr, " M/S "); break;
default: fprintf(stderr, " ");
}
}
fprintf(stderr, "\n");
}
void print_capabilities(out123_handle *ao, mpg123_handle *mh)
{
int r,e;
const long *rates;
size_t num_rates;
const int *encs;
size_t num_encs;
char *name;
char *dev;
out123_driver_info(ao, &name, &dev);
mpg123_rates(&rates, &num_rates);
mpg123_encodings(&encs, &num_encs);
fprintf(stderr,"\nAudio driver: %s\nAudio device: ", name);
print_outstr(stderr, dev, 0, stderr_is_term);
fprintf(stderr, "\n");
fprintf( stderr, "%s", "Audio capabilities:\n"
"(matrix of [S]tereo or [M]ono support for sample format and rate in Hz)\n"
"\n"
" rate |" );
for(e=0;e<num_encs;e++)
{
const char *encname = out123_enc_name(encs[e]);
fprintf(stderr," %4s ", encname ? encname : "???");
}
fprintf(stderr,"\n -------");
for(e=0;e<num_encs;e++) fprintf(stderr,"------");
fprintf(stderr, "\n");
for(r=0; r<num_rates; ++r) capline(mh, rates[r], NULL);
if(param.force_rate)
{
fprintf(stderr," -------");
for(e=0;e<num_encs;e++) fprintf(stderr,"------");
fprintf(stderr, "\n");
if(do_resample)
capline(mh, 0, &outfmt);
else
capline(mh, bpitch_rate(param.force_rate), NULL);
}
fprintf(stderr,"\n");
if(do_resample)
{
if(param.pitch != 0.)
fprintf( stderr, "Resampler with pitch: %g\n"
, param.pitch );
else
fprintf(stderr, "Resampler configured.\n");
fprintf( stderr, "%s\n%s\n"
, "Decoding to f32 as intermediate if needed."
, "Resampler output format is in the last line." );
}
else if(param.force_rate)
fprintf( stderr
, "%s rate forced. Resulting format support shown in last line.\n"
, param.pitch != 0. ? "Pitched decoder" : "Decoder" );
else if(param.pitch != 0.)
fprintf( stderr, "Actual output rates adjusted by pitch value %g.\n"
, param.pitch );
}
long brate(struct ratepair *table, long arate, int count, int *last)
{
int i = 0;
int j;
for(j=0; j<2; ++j)
{
i = i ? 0 : *last;
for(; i<count; ++i) if(table[i].a == arate)
{
*last = i;
return table[i].b;
}
}
return 0;
}
// Return one of the given list of encodings matching the mask,
// in order. Zero if none.
static int match_enc(int mask, const int *enc_list, size_t enc_count)
{
int enc = 0;
for(size_t i=0; i<enc_count; ++i)
{
if((enc_list[i] & mask) == enc_list[i])
{
enc = enc_list[i];
break;
}
}
return enc;
}
/* This uses the currently opened audio device, queries its caps.
In case of buffered playback, this works _once_ by querying the buffer for the caps before entering the main loop. */
static int audio_capabilities(out123_handle *ao, mpg123_handle *mh)
{
int force_fmt = 0;
size_t ri;
/* Pitching introduces a difference between decoder rate and playback rate. */
long decode_rate;
const long *rates;
struct mpg123_fmt *outfmts = NULL;
int fmtcount;
size_t num_rates;
if(param.pitch < -0.99)
param.pitch = -0.99;
long ntom_rate = do_resample ? 0 : bpitch_rate(param.force_rate);
outfmt.rate = param.force_rate;
outfmt.channels = 0;
outfmt.encoding = 0;
debug("audio_capabilities");
mpg123_rates(&rates, &num_rates);
mpg123_format_none(mh); /* Start with nothing. */
if(do_resample && param.verbose > 2)
fprintf( stderr
, "Note: decoder always forced to %s encoding for resampler\n"
, out123_enc_name(MPG123_ENC_FLOAT_32) );
if(param.force_encoding != NULL)
{
if(!param.quiet)
fprintf(stderr, "Note: forcing output encoding %s\n", param.force_encoding);
force_fmt = out123_enc_byname(param.force_encoding);
if(!force_fmt)
{
char *fs = NULL;
outstr(&fs, param.force_encoding, 0, stderr_is_term);
error1("Failed to find an encoding to match requested \"%s\"!\n"
, PSTR(fs));
free(fs);
return -1; /* No capabilities at all... */
}
else if(param.verbose > 2)
fprintf(stderr, "Note: forcing encoding code 0x%x (%s)\n"
, (unsigned)force_fmt, out123_enc_name(force_fmt));
}
// A possible optimization for resampling mode is to keep existing output
// format support configured and don't even interrupt the output device at
// all. If you change pitch, you just change a number for the resampler.
// But currently, the idea of re-opening the output device on format
// changes is rather ingrained in mpg123.
if(do_resample)
{
// If really doing the extra resampling, output will always run with
// this setup, regardless of decoder.
int enc1 = out123_encodings(ao, outfmt.rate, 1);
int enc2 = out123_encodings(ao, outfmt.rate, 2);
if(force_fmt)
{
enc1 &= force_fmt;
enc2 &= force_fmt;
} else
{
long propflags = 0;
out123_getparam_int(ao, OUT123_PROPFLAGS, &propflags);
if(!(propflags & OUT123_PROP_LIVE))
{
fmtcount = out123_formats(ao, NULL, 0, 1, 2, &outfmts);
if(fmtcount == 1 && outfmts[0].encoding > 0)
{
const char *encname = out123_enc_name(outfmts[0].encoding);
if(param.verbose > 1)
fprintf( stderr, "Note: honouring non-live default encoding of %s\n"
, encname ? encname : "???" );
enc1 &= outfmts[0].encoding;
enc2 &= outfmts[0].encoding;
}
free(outfmts);
outfmts = NULL;
} else if(param.verbose > 1)
fprintf(stderr, "Note: negotiating the best encoding with live sink\n");
}
mdebug("enc mono=0x%x stereo=0x%x", (unsigned)enc1, (unsigned)enc2);
if(!enc1 && !enc2)
{
error("Output device does not support forced rate and/or encoding.");
return -1;
} else if(enc1 && enc2)
{
// Should be the normal case: Mono and Stereo with the same formats.
// We'll store the common subset, which should normally be all.
outfmt.encoding = enc1 & enc2;
outfmt.channels = MPG123_MONO|MPG123_STEREO;
if(!outfmt.encoding)
{
error("No common decodings for mono and stereo output. Too weird.");
return -1;
}
} else if(enc1)
{ // Mono only.
outfmt.encoding = enc1;
outfmt.channels = 1;
} else
{ // Stereo only.
outfmt.encoding = enc2;
outfmt.channels = 2;
}
int pref_enc[] = { MPG123_ENC_FLOAT_32
, MPG123_ENC_SIGNED_32, MPG123_ENC_UNSIGNED_32
, MPG123_ENC_SIGNED_24, MPG123_ENC_UNSIGNED_24
, MPG123_ENC_SIGNED_16, MPG123_ENC_UNSIGNED_16 };
int nenc = match_enc(outfmt.encoding, pref_enc, sizeof(pref_enc)/sizeof(int));
if(!nenc)
{
const int *encs;
size_t num_encs;
mpg123_encodings(&encs, &num_encs);
nenc = match_enc(outfmt.encoding, encs, num_encs);
}
if(nenc)
outfmt.encoding = nenc;
else
{
merror( "Found no encoding to match mask 0x%08x."
, (unsigned int)outfmt.encoding );
if(force_fmt)
error("Perhaps your forced output encoding is not supported.");
return -1;
}
const char *encname = out123_enc_name(outfmt.encoding);
if(param.verbose > 1)
for(int ch=MPG123_MONO; ch<=MPG123_STEREO; ++ch)
if(outfmt.channels & ch)
fprintf(stderr, "Note: output format %li Hz, %s, %s\n"
, outfmt.rate, ch==MPG123_MONO ? "mono" : "stereo"
, encname ? encname : "???" );
}
// Either enable or disable rate forcing, whith ntom_rate non-zero or not.
if(mpg123_param(mh, MPG123_FORCE_RATE, ntom_rate, 0) != MPG123_OK)
{
merror("Cannot force NtoM rate: %s", mpg123_strerror(mh));
return -1;
}
if(ntom_rate)
{
// Only that one rate is enforced. Nothing else needs to be checked.
// For pitching, ntom_rate has been adjusted. The output uses outfmt.rate.
// Need to tell mpg123 about the forced rate to make it work.
for(int ch=1; ch<=2; ++ch)
{
int fmts = out123_encodings(ao, outfmt.rate, ch);
if(param.verbose > 2)
fprintf( stderr
, "Note: output support for %li Hz, %s: 0x%x\n"
, outfmt.rate, ch==MPG123_MONO ? "mono" : "stereo", fmts );
if(force_fmt)
fmts = ((fmts & force_fmt) == force_fmt) ? force_fmt : 0;
mpg123_format(mh, ntom_rate, ch, fmts);
}
} else if(do_resample)
{
// Support any decoding rate with float output for the resampler and also
// direct decoding to confiugred output format.
// One twist: Disable high rates with signal that the resampler will throw
// away anyway. This includes pitch. 22040 Hz output rate with pitch 0.5
// still wants the full 44100 Hz input data, as original signal up to
// 22040 Hz will be heard as up to 11020 Hz. So we want pitch_rate()
// to be above outfmt.rate. Final resampling ratio not above 2.
for(ri=0; ri<num_rates; ++ri)
{
if(rates[ri] > 12000 && pitch_rate(rates[ri]) > outfmt.rate*2)
break;
int fmt = (param.pitch == 0. && rates[ri] == outfmt.rate)
? outfmt.encoding
: MPG123_ENC_FLOAT_32;
mpg123_format(mh, rates[ri], outfmt.channels, fmt);
}
} else
{
// Finally, the old style, direct decoding to possibly pitched output.
if(!outrates)
outrates = malloc(sizeof(*rates)*num_rates);
if(!unpitch)
unpitch = malloc(sizeof(*unpitch)*num_rates);
if(!outrates || !unpitch)
{
CLEAN_POINTER(outrates, free)
CLEAN_POINTER(unpitch, free)
error("DOOM");
return -1;
}
for(ri = 0; ri<num_rates; ri++)
{
decode_rate = rates[ri];
outrates[ri] = pitch_rate(decode_rate);
unpitch[ri].a = outrates[ri];
unpitch[ri].b = decode_rate;
}
/* Actually query formats possible with given rates. */
fmtcount = out123_formats(ao, outrates, num_rates, 1, 2, &outfmts);
// Remember: First one is a default format, then come my rates.
if(fmtcount > 0)
{
int fi;
int unpitch_i = 0;
if(param.verbose > 1 && outfmts[0].encoding > 0)
{
const char *encname = out123_enc_name(outfmts[0].encoding);
fprintf(stderr, "Note: default format %li Hz, %i channels, %s\n"
, outfmts[0].rate, outfmts[0].channels
, encname ? encname : "???" );
}
for(fi=1; fi<fmtcount; ++fi)
{
int fmts = outfmts[fi].encoding;
if(param.verbose > 2)
fprintf( stderr
, "Note: output support for %li Hz, %i channels: 0x%x\n"
, outfmts[fi].rate, outfmts[fi].channels, outfmts[fi].encoding );
if(force_fmt)
fmts = ((fmts & force_fmt) == force_fmt) ? force_fmt : 0;
decode_rate = brate(unpitch, outfmts[fi].rate, num_rates, &unpitch_i);
mpg123_format(mh, decode_rate, outfmts[fi].channels, fmts);
}
}
free(outfmts);
}
if(param.verbose > 1) print_capabilities(ao, mh);
return 0;
}
int set_pitch(mpg123_handle *fr, out123_handle *ao, double new_pitch)
{
double old_pitch = param.pitch;
long rate;
int channels, format;
int smode = 0;
/* Be safe, check support. */
if(mpg123_getformat(fr, &rate, &channels, &format) != MPG123_OK)
{
/* We might just not have a track handy. */
error("There is no current audio format, cannot apply pitch. This might get fixed in future.");
return 0;
}
if(outfmt.rate && !do_resample)
{
error("Runtime pitching requires either proper resampler or flexible hardware rate.");
return 0;
}
param.pitch = new_pitch;
if(channels == 1) smode = MPG123_MONO;
if(channels == 2) smode = MPG123_STEREO;
out123_stop(ao);
/* Remember: This takes param.pitch into account. */
audio_capabilities(ao, fr);
if(!do_resample && !(mpg123_format_support(fr, rate, format) & smode))
{
/* Note: When using --pitch command line parameter, you can go higher
because a lower decoder sample rate is automagically chosen.
Here, we'd need to switch decoder rate during track... good? */
error("Reached a hardware limit there with pitch!");
param.pitch = old_pitch;
audio_capabilities(ao, fr);
}
else
mpg123_decoder(fr, NULL);
return audio_prepare(ao, fr, rate, channels, format);
}
int set_mute(out123_handle *ao, int mutestate)
{
return out123_param( ao
, mutestate ? OUT123_ADD_FLAGS : OUT123_REMOVE_FLAGS
, OUT123_MUTE, 0, NULL );
}

46
src/audio.h Normal file
View File

@@ -0,0 +1,46 @@
/*
audio: audio output interface
This is what is left after separating out libout123.
copyright ?-2015 by the mpg123 project - free software under the terms of the LGPL 2.1
see COPYING and AUTHORS files in distribution or http://mpg123.org
initially written by Michael Hipp
*/
/*
* Audio 'LIB' defines
*/
#ifndef _MPG123_AUDIO_H_
#define _MPG123_AUDIO_H_
#include "compat.h"
#include "mpg123.h"
#include "out123.h"
#define pitch_rate(rate) (param.pitch == 0 ? (rate) : (long) ((param.pitch+1.0)*(rate)))
#define bpitch_rate(rate) (param.pitch == 0 ? (rate) : (long) ((rate)/(param.pitch+1.0)))
void audio_cleanup(void);
int audio_setup(out123_handle *ao, mpg123_handle *mh);
int audio_prepare( out123_handle *ao, mpg123_handle *mh
, long rate, int channels, int encoding );
size_t audio_play(out123_handle *ao, void *buffer, size_t bytes);
mpg123_string* audio_enclist(void);
void print_capabilities(out123_handle *ao, mpg123_handle *mh);
/*
Twiddle audio output rate to yield speedup/down (pitch) effect.
The actually achieved pitch value is stored in param.pitch.
Returns 1 if pitch setting succeeded, 0 otherwise.
*/
int set_pitch(mpg123_handle *fr, out123_handle *ao, double new_pitch);
// Enable/disable software mute state.
int set_mute(out123_handle *ao, int mutestate);
#endif

406
src/common.c Normal file
View File

@@ -0,0 +1,406 @@
/*
common: misc stuff... audio flush, status display...
copyright ?-2020 by the mpg123 project
free software under the terms of the LGPL 2.1
see COPYING and AUTHORS files in distribution or http://mpg123.org
initially written by Michael Hipp
*/
/* Need snprintf. */
#define _DEFAULT_SOURCE
#define _BSD_SOURCE
#include "mpg123app.h"
#include "out123.h"
#include <sys/stat.h>
#include "common.h"
#include "debug.h"
int stopped = 0;
int paused = 0;
int muted = 0;
const char* rva_name[3] = { "off", "mix", "album" };
static const char* rva_statname[3] = { "---", "mix", "alb" };
static const char *modes[5] = {"Stereo", "Joint-Stereo", "Dual-Channel", "Single-Channel", "Invalid" };
static const char *smodes[5] = { "stereo", "j-s", "dual", "mono", "o.O" };
static const char *layers[4] = { "Unknown" , "I", "II", "III" };
static const char *versions[4] = {"1.0", "2.0", "2.5", "x.x" };
static const int samples_per_frame[4][4] =
{
{ -1,384,1152,1152 }, /* MPEG 1 */
{ -1,384,1152,576 }, /* MPEG 2 */
{ -1,384,1152,576 }, /* MPEG 2.5 */
{ -1,-1,-1,-1 }, /* Unknown */
};
/* concurring to print_rheader... here for control_generic */
const char* remote_header_help = "S <mpeg-version> <layer> <sampling freq> <mode(stereo/mono/...)> <mode_ext> <framesize> <stereo> <copyright> <error_protected> <emphasis> <bitrate> <extension> <vbr(0/1=yes/no)>";
void print_remote_header(mpg123_handle *mh)
{
struct mpg123_frameinfo i;
mpg123_info(mh, &i);
if(i.mode >= 4 || i.mode < 0) i.mode = 4;
if(i.version >= 3 || i.version < 0) i.version = 3;
generic_sendmsg("S %s %d %ld %s %d %d %d %d %d %d %d %d %d",
versions[i.version],
i.layer,
i.rate,
modes[i.mode],
i.mode_ext,
i.framesize,
i.mode == MPG123_M_MONO ? 1 : 2,
i.flags & MPG123_COPYRIGHT ? 1 : 0,
i.flags & MPG123_CRC ? 1 : 0,
i.emphasis,
i.bitrate,
i.flags & MPG123_PRIVATE ? 1 : 0,
i.vbr);
}
void print_header(mpg123_handle *mh)
{
struct mpg123_frameinfo i;
mpg123_info(mh, &i);
if(i.mode > 4 || i.mode < 0) i.mode = 4;
if(i.version > 3 || i.version < 0) i.version = 3;
if(i.layer > 3 || i.layer < 0) i.layer = 0;
fprintf(stderr,"MPEG %s, Layer: %s, Freq: %ld, mode: %s, modext: %d, BPF : %d\n",
versions[i.version],
layers[i.layer], i.rate,
modes[i.mode],i.mode_ext,i.framesize);
fprintf(stderr,"Channels: %d, copyright: %s, original: %s, CRC: %s, emphasis: %d.\n",
i.mode == MPG123_M_MONO ? 1 : 2,i.flags & MPG123_COPYRIGHT ? "Yes" : "No",
i.flags & MPG123_ORIGINAL ? "Yes" : "No", i.flags & MPG123_CRC ? "Yes" : "No",
i.emphasis);
fprintf(stderr,"Bitrate: ");
switch(i.vbr)
{
case MPG123_CBR:
if(i.bitrate) fprintf(stderr, "%d kbit/s", i.bitrate);
else fprintf(stderr, "%d kbit/s (free format)", (int)((double)(i.framesize+4)*8*i.rate*0.001/samples_per_frame[i.version][i.layer]+0.5));
break;
case MPG123_VBR: fprintf(stderr, "VBR"); break;
case MPG123_ABR: fprintf(stderr, "%d kbit/s ABR", i.abr_rate); break;
default: fprintf(stderr, "???");
}
fprintf(stderr, " Extension value: %d\n", i.flags & MPG123_PRIVATE ? 1 : 0);
}
void print_header_compact(mpg123_handle *mh)
{
struct mpg123_frameinfo i;
mpg123_info(mh, &i);
if(i.mode > 4 || i.mode < 0) i.mode = 4;
if(i.version > 3 || i.version < 0) i.version = 3;
if(i.layer > 3 || i.layer < 0) i.layer = 0;
fprintf(stderr,"MPEG %s L %s ", versions[i.version], layers[i.layer]);
switch(i.vbr)
{
case MPG123_CBR:
if(i.bitrate) fprintf(stderr, "cbr%d", i.bitrate);
else fprintf(stderr, "cbr%d", (int)((double)i.framesize*8*i.rate*0.001/samples_per_frame[i.version][i.layer]+0.5));
break;
case MPG123_VBR: fprintf(stderr, "vbr"); break;
case MPG123_ABR: fprintf(stderr, "abr%d", i.abr_rate); break;
default: fprintf(stderr, "???");
}
fprintf(stderr," %ld %s\n", i.rate, smodes[i.mode]);
}
unsigned int roundui(double val)
{
double base = floor(val);
return (unsigned int) ((val-base) < 0.5 ? base : base + 1 );
}
/* Split into mm:ss.xx or hh:mm:ss, depending on value. */
static void settle_time(double tim, unsigned long *times, char *sep)
{
if(tim >= 3600.)
{
*sep = ':';
times[0] = (unsigned long) tim/3600;
tim -= times[0]*3600;
times[1] = (unsigned long) tim/60;
tim -= times[1]*60;
times[2] = (unsigned long) tim;
}
else
{
*sep = '.';
times[0] = (unsigned long) tim/60;
times[1] = (unsigned long) tim%60;
times[2] = (unsigned long) (tim*100)%100;
}
}
/* Print output buffer fill. */
void print_buf(const char* prefix, out123_handle *ao)
{
long rate;
int framesize;
double tim;
unsigned long times[3];
char timesep;
size_t buffsize;
buffsize = out123_buffered(ao);
if(out123_getformat(ao, &rate, NULL, NULL, &framesize))
return;
tim = (double)(buffsize/framesize)/rate;
settle_time(tim, times, &timesep);
fprintf( stderr, "\r%s[%02lu:%02lu%c%02lu]"
, prefix, times[0], times[1], timesep, times[2] );
}
/* Note about position info with buffering:
Negative positions mean that the previous track is still playing from the
buffer. It's a countdown. The frame counter always relates to the last
decoded frame, what entered the buffer right now. */
void print_stat(mpg123_handle *fr, long offset, out123_handle *ao, int draw_bar
, struct parameter *param)
{
size_t buffered;
off_t decoded;
off_t elapsed;
off_t remain;
off_t length;
off_t frame;
off_t frames;
off_t rframes;
int spf;
double basevol, realvol;
char *icy;
long rate;
int framesize;
struct mpg123_frameinfo mi;
char linebuf[256];
char *line = NULL;
#ifndef WIN32
#ifndef GENERIC
/* Only generate new stat line when stderr is ready... don't overfill... */
{
struct timeval t;
fd_set serr;
int n,errfd = fileno(stderr);
t.tv_sec=t.tv_usec=0;
FD_ZERO(&serr);
FD_SET(errfd,&serr);
n = select(errfd+1,NULL,&serr,NULL,&t);
if(n <= 0) return;
}
#endif
#endif
if(out123_getformat(ao, &rate, NULL, NULL, &framesize))
return;
buffered = out123_buffered(ao)/framesize;
decoded = mpg123_tell(fr);
length = mpg123_length(fr);
frame = mpg123_tellframe(fr);
frames = mpg123_framelength(fr);
spf = mpg123_spf(fr);
if(decoded < 0 || length < 0 || frame < 0 || frames <= 0 || spf <= 0)
return;
/* Apply offset. */
frame += offset;
if(frame < 0)
frame = 0;
/* Some sensible logic around offsets and time.
Buffering makes the relationships between the numbers non-trivial. */
rframes = frames-frame;
elapsed = decoded + offset*spf - buffered; /* May be negative, a countdown. */
remain = elapsed > 0 ? length - elapsed : length;
if( MPG123_OK == mpg123_info(fr, &mi)
&& MPG123_OK == mpg123_getvolume(fr, &basevol, &realvol, NULL) )
{
char framefmt[10];
char framestr[2][32];
int linelen;
int maxlen;
int len;
int ti;
/* Deal with overly long times. */
double tim[3];
unsigned long times[3][3];
char timesep[3];
char sign[3] = {' ', ' ', ' '};
/* 255 is enough for the data I prepare, if there is no terminal width to
fill */
maxlen = term_width(STDERR_FILENO);
linelen = maxlen > 0 ? maxlen : (sizeof(linebuf)-1);
line = linelen >= sizeof(linebuf)
? malloc(linelen+1) /* Only malloc if it is a really long line. */
: linebuf; /* Small buffer on stack is enough. */
tim[0] = (double)elapsed/rate;
tim[1] = (double)remain/rate;
tim[2] = (double)buffered/rate;
for(ti=0; ti<3; ++ti)
{
if(tim[ti] < 0.){ sign[ti] = '-'; tim[ti] = -tim[ti]; }
settle_time(tim[ti], times[ti], &timesep[ti]);
}
/* Taking pains to properly size the frame number fields. */
len = snprintf( framefmt, sizeof(framefmt)
, "%%0%d"OFF_P, (int)log10(frames)+1 );
if(len < 0 || len >= sizeof(framefmt))
memcpy(framefmt, "%05"OFF_P, sizeof("%05"OFF_P));
snprintf( framestr[0], sizeof(framestr[0])-1, framefmt, (off_p)frame);
framestr[0][sizeof(framestr[0])-1] = 0;
snprintf( framestr[1], sizeof(framestr[1])-1, framefmt, (off_p)rframes);
framestr[1][sizeof(framestr[1])-1] = 0;
/* Now start with the state line. */
memset(line, 0, linelen+1); /* Always one zero more. */
/* Start with position info. */
len = snprintf( line, linelen
, "%c %s+%s %c%02lu:%02lu%c%02lu+%02lu:%02lu%c%02lu"
, stopped ? '_' : (paused ? '=' : '>')
, framestr[0], framestr[1]
, sign[0]
, times[0][0], times[0][1], timesep[0], times[0][2]
, times[1][0], times[1][1], timesep[1], times[1][2]
);
/* Just cut it. */
if(len >= linelen)
len=linelen;
if(len >= 0 && param->usebuffer && len < linelen )
{ /* Buffer info. */
int len_add = snprintf( line+len, linelen-len
, " [%02lu:%02lu%c%02lu]"
, times[2][0], times[2][1], timesep[2], times[2][2] );
if(len_add > 0)
len += len_add;
}
if(len >= 0 && len < linelen)
{ /* Volume info. */
int len_add = snprintf( line+len, linelen-len
, " %s %03u%c%03u"
, rva_statname[param->rva]
, roundui(basevol*100), muted ? 'm' : '='
, roundui(realvol*100) );
if(len_add > 0)
len += len_add;
}
if(len >= 0 && len < linelen)
{ /* Bitrate. */
int len_add = snprintf( line+len, linelen-len
, " %3d kb/s", mi.bitrate );
if(len_add > 0)
len += len_add;
}
if(len >= 0 && len < linelen)
{ /* Size of frame in bytes. */
int len_add = snprintf( line+len, linelen-len
, " %4d B", mi.framesize );
if(len_add > 0)
len += len_add;
}
if(len >= 0 && len < linelen)
{ /* Size of frame in bytes. */
int len_add = 0;
long res = 0;
if(mpg123_getstate(fr, MPG123_ACCURATE, &res, NULL) == MPG123_OK)
len_add = snprintf( line+len, linelen-len
, " %s", res ? "acc" : "fuz" );
if(len_add > 0)
len += len_add;
}
if(len >= 0 && len < linelen)
{ /* Size of frame in bytes. */
int len_add = 0;
long res = mpg123_clip(fr);
if(res >= 0)
len_add = snprintf( line+len, linelen-len
, " %4ld clip", res );
if(len_add > 0)
len += len_add;
}
if(len >= 0 && len < linelen)
{ /* Size of frame in bytes. */
int len_add = 0;
len_add = snprintf( line+len, linelen-len
, " p%+.3f", param->pitch );
if(len_add > 0)
len += len_add;
}
if(len >= 0)
{
if(maxlen > 0 && len > maxlen)
{
/* Emergency cut to avoid terminal scrolling. */
int i;
/* Blank a word that would have been cut off. */
for(i=maxlen; i>=0; --i)
{
char old = line[i];
line[i] = ' ';
if(old == ' ')
break;
}
line[maxlen] = 0;
len = maxlen;
}
/* Ensure that it is filled with spaces if we got some line length.
Shouldn't we always fill to maxlen? */
if(maxlen > 0)
memset(line+len, ' ', linelen-len);
#ifdef HAVE_TERMIOS
draw_bar = draw_bar && term_have_fun(STDERR_FILENO,param->term_visual);
/* Use inverse color to draw a progress bar. */
if(maxlen > 0 && draw_bar)
{
char old;
int barlen = 0;
if(length > 0 && elapsed > 0)
{
if(elapsed < length)
barlen = (int)((double)elapsed/length * maxlen);
else
barlen = maxlen;
}
old = line[barlen];
fprintf(stderr, "\x1b[7m");
line[barlen] = 0;
fprintf(stderr, "\r%s", line);
line[barlen] = old;
fprintf(stderr, "\x1b[0m");
fprintf(stderr, "%s", line+barlen);
}
else
#endif
fprintf(stderr, "\r%s", line);
}
}
/* Check for changed tags here too? */
if( mpg123_meta_check(fr) & MPG123_NEW_ICY && MPG123_OK == mpg123_icy(fr, &icy) )
{
if(line) /* Clear the inverse video. */
fprintf(stderr, "\r%s", line);
fprintf(stderr, "\nICY-META: %s\n", icy);
}
if(line && line != linebuf)
free(line);
}
void clear_stat()
{
int len = term_width(STDERR_FILENO);
if(len > 0)
{
char fmt[20];
int flen;
if( (flen=snprintf(fmt, sizeof(fmt), "\r%%%ds\r", len)) > 0
&& flen < sizeof(fmt) )
fprintf(stderr, fmt, " ");
}
}

33
src/common.h Normal file
View File

@@ -0,0 +1,33 @@
/*
common: anything can happen here... frame reading, output, messages
copyright ?-2020 by the mpg123 project - free software under the terms of the LGPL 2.1
see COPYING and AUTHORS files in distribution or http://mpg123.org
initially written by Michael Hipp
*/
#ifndef _MPG123_COMMON_H_
#define _MPG123_COMMON_H_
#include "mpg123app.h"
#include "out123.h"
extern int stopped;
extern int paused;
extern int muted;
void print_header(mpg123_handle *);
void print_header_compact(mpg123_handle *);
void print_stat(mpg123_handle *fr, long offset, out123_handle *ao, int draw_bar
, struct parameter *param);
void print_buf(const char* prefix, out123_handle *ao);
void clear_stat();
/* for control_generic */
extern const char* remote_header_help;
void print_remote_header(mpg123_handle *mh);
void generic_sendmsg (const char *fmt, ...);
extern const char* rva_name[3];
#endif

24
src/compat/Makemodule.am Normal file
View File

@@ -0,0 +1,24 @@
noinst_LTLIBRARIES += src/compat/libcompat.la
noinst_LTLIBRARIES += src/compat/libcompat_str.la
noinst_LTLIBRARIES += src/compat/libcompat_dl.la
src_compat_libcompat_la_SOURCES = \
src/compat/compat_str.c \
src/compat/compat.c \
src/compat/wpathconv.h \
src/compat/compat.h
# A smaller one for the output modules. Do not want to grow them
# unnecessarily with unused code.
src_compat_libcompat_str_la_SOURCES = \
src/compat/compat_str.c \
src/compat/compat.h
# A separate lib for the dlopen stuff, less linker noise.
src_compat_libcompat_dl_la_SOURCES = \
src/compat/compat_dl.c \
src/compat/wpathconv.h \
src/compat/compat.h
src_compat_libcompat_dl_la_LIBADD = @LIBDL@

508
src/compat/compat.c Normal file
View File

@@ -0,0 +1,508 @@
/*
compat: Some compatibility functions (basic memory & string stuff in separate file)
The mpg123 code is determined to keep it's legacy. A legacy of old, old UNIX.
So anything possibly somewhat advanced should be considered to be put here, with proper #ifdef;-)
copyright 2007-2020 by the mpg123 project - free software under the terms of the LGPL 2.1
see COPYING and AUTHORS files in distribution or http://mpg123.org
initially written by Thomas Orgis, Windows Unicode stuff by JonY.
*/
#include "config.h"
/* This source file does need _POSIX_SOURCE to get some sigaction. */
#define _POSIX_SOURCE
#include "compat.h"
#ifdef _MSC_VER
#include <io.h>
#if(defined(WINAPI_FAMILY) && (WINAPI_FAMILY==WINAPI_FAMILY_APP))
#define WINDOWS_UWP
#endif
#endif
#ifdef HAVE_SYS_STAT_H
# include <sys/stat.h>
#endif
#ifdef HAVE_DIRENT_H
# include <dirent.h>
#endif
/* Win32 is only supported with unicode now. These headers also cover
module stuff. The WANT_WIN32_UNICODE macro is synonymous with
"want windows-specific API, and only the unicode variants of which". */
#ifdef WANT_WIN32_UNICODE
#include <wchar.h>
#include <windows.h>
#include <winnls.h>
#include <shlwapi.h>
#endif
#include "debug.h"
#ifndef WINDOWS_UWP
char *compat_getenv(const char* name)
{
char *ret = NULL;
#ifdef WANT_WIN32_UNICODE
wchar_t *env;
wchar_t *wname = NULL;
if(win32_utf8_wide(name, &wname, NULL) > 0)
{
env = _wgetenv(wname);
free(wname);
if(env)
win32_wide_utf8(env, &ret, NULL);
}
#else
ret = getenv(name);
if(ret)
ret = compat_strdup(ret);
#endif
return ret;
}
#endif
#include "wpathconv.h"
/* Always add a default permission mask in case of flags|O_CREAT. */
int compat_open(const char *filename, int flags)
{
int ret;
#if defined (WANT_WIN32_UNICODE)
wchar_t *frag = NULL;
frag = u2wlongpath(filename);
/* Fallback to plain open when ucs-2 conversion fails */
if(!frag)
goto open_fallback;
/*Try _wopen */
ret = _wopen(frag, flags|_O_BINARY, _S_IREAD | _S_IWRITE);
if(ret != -1 )
goto open_ok; /* msdn says -1 means failure */
open_fallback:
#endif
#if (defined(WIN32) && !defined (__CYGWIN__))
/* MSDN says POSIX function is deprecated beginning in Visual C++ 2005 */
/* Try plain old _open(), if it fails, do nothing */
ret = _open(filename, flags|_O_BINARY, _S_IREAD | _S_IWRITE);
#else
ret = open(filename, flags, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH);
#endif
#if defined (WANT_WIN32_UNICODE)
open_ok:
free(frag);
#endif
return ret;
}
/* Moved over from wav.c, logic with fallbacks added from the
example of compat_open(). */
FILE* compat_fopen(const char *filename, const char *mode)
{
FILE* stream = NULL;
#ifdef WANT_WIN32_UNICODE
int cnt = 0;
wchar_t *wname = NULL;
wchar_t *wmode = NULL;
wname = u2wlongpath(filename);
if(!wname)
goto fopen_fallback;
cnt = win32_utf8_wide(mode, &wmode, NULL);
if( (wmode == NULL) || (cnt == 0))
goto fopen_fallback;
stream = _wfopen(wname, wmode);
if(stream) goto fopen_ok;
fopen_fallback:
#endif
stream = fopen(filename, mode);
#ifdef WANT_WIN32_UNICODE
fopen_ok:
free(wmode);
free(wname);
#endif
return stream;
}
FILE* compat_fdopen(int fd, const char *mode)
{
return fdopen(fd, mode);
}
int compat_close(int infd)
{
#if (defined(WIN32) && !defined (__CYGWIN__)) /* MSDN says POSIX function is deprecated beginning in Visual C++ 2005 */
return _close(infd);
#else
return close(infd);
#endif
}
int compat_fclose(FILE *stream)
{
return fclose(stream);
}
#ifndef WINDOWS_UWP
/*
The Windows file and path stuff is an extract of jon_y's win32 loader
prototype from the loader_rework branch. It's been divided in to
reusable functons by ThOr in the hope to work out some generic-looking
loader code for both POSIX and Windows. The routines might be
helpful for consistent path work in other parts of mpg123, too.
This all is about getting some working code on a wide range of
systems while staying somewhat sane. If it does ridiculously inefficient
things with extraneous copies and grabbing of functions that made
it late to some official APIs, that's still fine with us.
*/
char* compat_catpath(const char *prefix, const char* path)
{
char *ret = NULL;
#ifdef WANT_WIN32_UNICODE
wchar_t *wprefix = NULL; /* Wide windows versions of */
wchar_t *wpath = NULL; /* input arguments. */
wchar_t *locwret = NULL; /* Tmp return value from LocalAlloc */
/*
This variation of combinepath can work with long and UNC paths, but
is not officially exposed in any DLLs, It also allocates all its buffers
internally via LocalAlloc, avoiding buffer overflow problems.
ThOr: I presume this hack is for supporting pre-8 Windows, as
from Windows 8 on, this is documented in the API.
*/
HRESULT (__stdcall *mypac)( const wchar_t *in, const wchar_t* more
, unsigned long flags, wchar_t **out ) = NULL;
HMODULE pathcch = NULL;
if(!prefix && !path)
goto catpath_end;
wprefix = u2wpath(prefix);
wpath = u2wpath(path);
if((prefix && !wprefix) || (path && !wpath))
goto catpath_end;
/* Again: I presume this whole fun is to get at PathAllocCombine
even when pathcch.h is not available (like in MinGW32). */
if( (pathcch = GetModuleHandleA("kernelbase")) )
mypac = (void *)GetProcAddress(pathcch, "PathAllocCombine");
if(mypac) /* PATHCCH_ALLOW_LONG_PATH = 1 per API docs */
{
debug("Actually calling PathAllocCombine!");
mypac(wprefix, wpath, 1, &locwret);
}
else
{
/* Playing safe, if we'd care much about performance, this would be on
the stack. */
locwret = LocalAlloc(LPTR, sizeof(wchar_t)*MAX_PATH);
if(locwret)
PathCombineW(locwret, wprefix, wpath);
}
ret = w2upath(locwret);
catpath_end:
LocalFree(locwret);
free(wprefix);
free(wpath);
#else
size_t len, prelen, patlen;
if(path && path[0] == '/')
prefix = NULL; /* Absolute path stays as it is. */
prelen = prefix ? strlen(prefix) : 0;
patlen = path ? strlen(path) : 0;
/* Concatenate the two, put a / in between if both present. */
len = ((prefix && path) ? 1 : 0) + prelen + patlen;
ret = malloc(len+1);
if(ret)
{
size_t off=0;
memcpy(ret, prefix, prelen);
if(prefix && path)
ret[prelen+(off++)] = '/';
memcpy(ret+prelen+off, path, patlen);
ret[len] = 0;
}
#endif
return ret;
}
int compat_isdir(const char *path)
{
int ret = 0;
#ifdef WANT_WIN32_UNICODE
wchar_t *wpath;
wpath = u2wlongpath(path);
if(wpath)
{
DWORD attr = GetFileAttributesW(wpath);
if(attr != INVALID_FILE_ATTRIBUTES && attr & FILE_ATTRIBUTE_DIRECTORY)
ret=1;
free(wpath);
}
#else
struct stat sb;
if(path && !stat(path, &sb))
{
if(S_ISDIR(sb.st_mode))
ret=1;
}
#endif
return ret;
}
struct compat_dir
{
char *path;
#ifdef WANT_WIN32_UNICODE
int gotone; /* Got a result stored from FindFirstFileW. */
WIN32_FIND_DATAW d;
HANDLE ffn;
#else
DIR* dir;
#endif
};
struct compat_dir* compat_diropen(char *path)
{
struct compat_dir *cd;
if(!path)
return NULL;
cd = malloc(sizeof(*cd));
if(!cd)
return NULL;
#ifdef WANT_WIN32_UNICODE
cd->gotone = 0;
{
char *pattern;
wchar_t *wpattern;
pattern = compat_catpath(path, "*");
wpattern = u2wlongpath(pattern);
if(wpattern)
{
cd->ffn = FindFirstFileW(wpattern, &(cd->d));
if(cd->ffn == INVALID_HANDLE_VALUE)
{
/* FindClose() only needed after successful first find, right? */
free(cd);
cd = NULL;
}
else
cd->gotone = 1;
}
free(wpattern);
free(pattern);
}
#else
cd->dir = opendir(path);
if(!cd->dir)
{
free(cd);
cd = NULL;
}
#endif
if(cd)
{
cd->path = compat_strdup(path);
if(!cd->path)
{
compat_dirclose(cd);
cd = NULL;
}
}
return cd;
}
void compat_dirclose(struct compat_dir *cd)
{
if(cd)
{
free(cd->path);
#ifdef WANT_WIN32_UNICODE
FindClose(cd->ffn);
#else
closedir(cd->dir);
#endif
free(cd);
}
}
char* compat_nextfile(struct compat_dir *cd)
{
if(!cd)
return NULL;
#ifdef WANT_WIN32_UNICODE
while(cd->gotone || FindNextFileW(cd->ffn, &(cd->d)))
{
cd->gotone = 0;
if(!(cd->d.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
{
char *ret;
win32_wide_utf8(cd->d.cFileName, &ret, NULL);
return ret;
}
}
#else
{
struct dirent *dp;
while((dp = readdir(cd->dir)))
{
struct stat fst;
char *fullpath = compat_catpath(cd->path, dp->d_name);
if(fullpath && !stat(fullpath, &fst) && S_ISREG(fst.st_mode))
{
free(fullpath);
return compat_strdup(dp->d_name);
}
free(fullpath);
}
}
#endif
return NULL;
}
char* compat_nextdir(struct compat_dir *cd)
{
if(!cd)
return NULL;
#ifdef WANT_WIN32_UNICODE
while(cd->gotone || FindNextFileW(cd->ffn, &(cd->d)))
{
cd->gotone = 0;
if(cd->d.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
{
char *ret;
win32_wide_utf8(cd->d.cFileName, &ret, NULL);
return ret;
}
}
#else
{
struct dirent *dp;
while((dp = readdir(cd->dir)))
{
struct stat fst;
char *fullpath = compat_catpath(cd->path, dp->d_name);
if(fullpath && !stat(fullpath, &fst) && S_ISDIR(fst.st_mode))
{
free(fullpath);
return compat_strdup(dp->d_name);
}
free(fullpath);
}
}
#endif
return NULL;
}
#endif
// Revisit logic of write():
// Return -1 if interrupted before any data was written,
// set errno to EINTR. Any other error value is serious
// for blocking I/O, which we assume here. EAGAIN should be
// handed through.
// Reaction to zero-sized write attempts could also be funky, so avoid that.
// May return short count for various reasons. I assume that
// any serious condition will show itself as return value -1
// eventually.
// These uninterruptible write/read functions shall persist as long as
// possible to finish the desired operation. A short byte count is short
// because of a serious reason (maybe EOF, maybe out of disk space). You
// can inspect errno.
size_t unintr_write(int fd, void const *buffer, size_t bytes)
{
size_t written = 0;
errno = 0;
while(bytes)
{
errno = 0;
ssize_t part = write(fd, (char*)buffer+written, bytes);
// Just on short writes, we do not abort. Only when
// there was no successful operation (even zero write) at all.
// Any other error than EINTR ends things here.
if(part >= 0)
{
bytes -= part;
written += part;
} else if(errno != EINTR)
break;
}
return written;
}
/* Same for reading the data. */
size_t unintr_read(int fd, void *buffer, size_t bytes)
{
size_t got = 0;
errno = 0;
while(bytes)
{
errno = 0;
ssize_t part = read(fd, (char*)buffer+got, bytes);
if(part >= 0)
{
bytes -= part;
got += part;
} else if(errno != EINTR)
break;
}
return got;
}
// and again for streams
size_t unintr_fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream)
{
size_t written = 0;
errno = 0;
while(size && nmemb)
{
errno = 0;
size_t part = fwrite((char*)ptr+written*size, size, nmemb, stream);
if(part > 0)
{
nmemb -= part;
written += part;
} else if(errno != EINTR)
break;
}
return written;
}
#ifndef NO_CATCHSIGNAL
#if (!defined(WIN32) || defined (__CYGWIN__)) && defined(HAVE_SIGNAL_H)
void (*catchsignal(int signum, void(*handler)()))()
{
struct sigaction new_sa;
struct sigaction old_sa;
#ifdef DONT_CATCH_SIGNALS
fprintf (stderr, "Not catching any signals.\n");
return ((void (*)()) -1);
#endif
new_sa.sa_handler = handler;
sigemptyset(&new_sa.sa_mask);
new_sa.sa_flags = 0;
if(sigaction(signum, &new_sa, &old_sa) == -1)
return ((void (*)()) -1);
return (old_sa.sa_handler);
}
#endif
#endif

301
src/compat/compat.h Normal file
View File

@@ -0,0 +1,301 @@
/*
compat: Some compatibility functions and header inclusions.
Basic standard C stuff, that may barely be above/around C89.
The mpg123 code is determined to keep it's legacy. A legacy of old, old UNIX.
It is envisioned to include this compat header instead of any of the "standard" headers, to catch compatibility issues.
So, don't include stdlib.h or string.h ... include compat.h.
copyright 2007-21 by the mpg123 project - free software under the terms of the LGPL 2.1
see COPYING and AUTHORS files in distribution or http://mpg123.org
initially written by Thomas Orgis
*/
#ifndef MPG123_COMPAT_H
#define MPG123_COMPAT_H
#include "config.h"
// We are using C99 now, including possibly single-precision math.
#define _ISO_C99_SOURCE
#include <errno.h>
#ifdef HAVE_STDLIB_H
/* realloc, size_t */
#include <stdlib.h>
#endif
#include <stdio.h>
#include <math.h>
#ifdef HAVE_SIGNAL_H
#include <signal.h>
#else
#ifdef HAVE_SYS_SIGNAL_H
#include <sys/signal.h>
#endif
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
/* Types, types, types. */
/* Do we actually need these two in addition to sys/types.h? As replacement? */
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_INTTYPES_H
#include <inttypes.h>
#endif
#ifdef HAVE_STDINT_H
#include <stdint.h>
#endif
/* We want SIZE_MAX, etc. */
#ifdef HAVE_LIMITS_H
#include <limits.h>
#endif
#ifndef SIZE_MAX
#define SIZE_MAX ((size_t)-1)
#endif
#ifndef SSIZE_MAX
#define SSIZE_MAX ((size_t)-1/2)
#endif
#ifndef ULONG_MAX
#define ULONG_MAX ((unsigned long)-1)
#endif
#ifdef HAVE_STRING_H
#include <string.h>
#endif
#ifdef HAVE_STRINGS_H
#include <strings.h>
#endif
#ifdef OS2
#include <float.h>
#endif
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
/* For select(), I need select.h according to POSIX 2001, else: sys/time.h sys/types.h unistd.h */
#ifdef HAVE_SYS_SELECT_H
#include <sys/select.h>
#endif
/* compat_open makes little sense without */
#include <fcntl.h>
/* To parse big numbers... */
#ifdef HAVE_ATOLL
#define atobigint atoll
#else
#define atobigint atol
#endif
typedef unsigned char byte;
#if defined(_MSC_VER)
// For _setmode(), at least.
#include <io.h>
#if !defined(MPG123_DEF_SSIZE_T)
#define MPG123_DEF_SSIZE_T
#include <stddef.h>
typedef ptrdiff_t ssize_t;
#endif
#endif
// Not too early, leave system headers alone (strerror).
#include "intsym.h"
/* A safe realloc also for very old systems where realloc(NULL, size) returns NULL. */
void *safe_realloc(void *ptr, size_t size);
// Also freeing ptr if result is NULL. You can do
// ptr = safer_realloc(ptr, size)
// Also, ptr = safer_realloc(ptr, 0) will do free(ptr); ptr=NULL;.
void *safer_realloc(void *ptr, size_t size);
#ifndef HAVE_STRERROR
const char *strerror(int errnum);
#endif
/* Roll our own strdup() that does not depend on libc feature test macros
and returns NULL on NULL input instead of crashing. */
char* compat_strdup(const char *s);
/* If we have the size checks enabled, try to derive some sane printfs.
Simple start: Use max integer type and format if long is not big enough.
I am hesitating to use %ll without making sure that it's there... */
#if (defined SIZEOF_OFF_T) && (SIZEOF_OFF_T > SIZEOF_LONG) && (defined PRIiMAX)
# define OFF_P PRIiMAX
typedef intmax_t off_p;
#else
# define OFF_P "li"
typedef long off_p;
#endif
#if (defined SIZEOF_SIZE_T) && (SIZEOF_SIZE_T > SIZEOF_LONG) && (defined PRIuMAX)
# define SIZE_P PRIuMAX
typedef uintmax_t size_p;
#else
# define SIZE_P "lu"
typedef unsigned long size_p;
#endif
#if (defined SIZEOF_SSIZE_T) && (SIZEOF_SSIZE_T > SIZEOF_LONG) && (defined PRIiMAX)
# define SSIZE_P PRIuMAX
typedef intmax_t ssize_p;
#else
# define SSIZE_P "li"
typedef long ssize_p;
#endif
/* Get an environment variable, possibly converted to UTF-8 from wide string.
The return value is a copy that you shall free. */
char *compat_getenv(const char* name);
/**
* Opening a file handle can be different.
* This function here is defined to take a path in native encoding (ISO8859 / UTF-8 / ...), or, when MS Windows Unicode support is enabled, an UTF-8 string that will be converted back to native UCS-2 (wide character) before calling the system's open function.
* @param[in] wptr Pointer to wide string.
* @param[in] mbptr Pointer to multibyte string.
* @return file descriptor (>=0) or error code.
*/
int compat_open(const char *filename, int flags);
FILE* compat_fopen(const char *filename, const char *mode);
/**
* Also fdopen to avoid having to define POSIX macros in various source files.
*/
FILE* compat_fdopen(int fd, const char *mode);
/**
* Closing a file handle can be platform specific.
* This function takes a file descriptor that is to be closed.
* @param[in] infd File descriptor to be closed.
* @return 0 if the file was successfully closed. A return value of -1 indicates an error.
*/
int compat_close(int infd);
int compat_fclose(FILE* stream);
/* Those do make sense in a separate file, but I chose to include them in compat.c because that's the one source whose object is shared between mpg123 and libmpg123 -- and both need the functionality internally. */
#ifdef WANT_WIN32_UNICODE
/**
* win32_uni2mbc
* Converts a null terminated UCS-2 string to a multibyte (UTF-8) equivalent.
* Caller is supposed to free allocated buffer.
* @param[in] wptr Pointer to wide string.
* @param[out] mbptr Pointer to multibyte string.
* @param[out] buflen Optional parameter for length of allocated buffer.
* @return status of WideCharToMultiByte conversion.
*
* WideCharToMultiByte - http://msdn.microsoft.com/en-us/library/dd374130(VS.85).aspx
*/
int win32_wide_utf8(const wchar_t * const wptr, char **mbptr, size_t * buflen);
/**
* win32_mbc2uni
* Converts a null terminated UTF-8 string to a UCS-2 equivalent.
* Caller is supposed to free allocated buffer.
* @param[in] mbptr Pointer to multibyte string.
* @param[out] wptr Pointer to wide string.
* @param[out] buflen Optional parameter for length of allocated buffer.
* @return status of WideCharToMultiByte conversion.
*
* MultiByteToWideChar - http://msdn.microsoft.com/en-us/library/dd319072(VS.85).aspx
*/
int win32_utf8_wide(const char *const mbptr, wchar_t **wptr, size_t *buflen);
#endif
/*
A little bit of path abstraction: We always work with plain char strings
that usually represent POSIX-ish UTF-8 paths (something like c:/some/file
might appear). For Windows, those are converted to wide strings with \
instead of / and possible fun is had with prefixes to get around the old
path length limit. Outside of the compat library, that stuff should not
matter, although something like //?/UNC/server/some/file could be thrown
around as UTF-8 string, to be converted to a wide \\?\UNC\server\some\file
just before handing it to Windows API.
There is a lot of unnecessary memory allocation and string copying because
of this, but this filesystem stuff is not really relevant to mpg123
performance, so the goal is to keep the code outside the compatibility layer
simple.
*/
/*
Concatenate a prefix and a path, one of them alowed to be NULL.
If the path is already absolute, the prefix is ignored. Relative
parts (like /..) are resolved if this is sensible for the platform
(meaning: for Windows), else they are preserved (on POSIX, actual
file system access would be needed because of symlinks).
*/
char* compat_catpath(const char *prefix, const char* path);
/* Return 1 if the given path indicates an existing directory,
0 otherwise. */
int compat_isdir(const char *path);
/*
Directory traversal. This talks ASCII/UTF-8 paths externally, converts
to/from wchar_t internally if the platform wants that. Returning NULL
means failure to open/end of listing.
There is no promise about sorting entries.
*/
struct compat_dir;
/* Returns NULL if either directory failed to open or listing is empty.
Listing can still be empty even if non-NULL, so always rely on the
nextfile/nextdir functions. */
struct compat_dir* compat_diropen(char *path);
void compat_dirclose(struct compat_dir*);
/* Get the next entry that is a file (or symlink to one).
The returned string is a copy that needs to be freed after use. */
char* compat_nextfile(struct compat_dir*);
/* Get the next entry that is a directory (or symlink to one).
The returned string is a copy that needs to be freed after use. */
char* compat_nextdir (struct compat_dir*);
#ifdef USE_MODULES
/*
For keeping the path mess local, a system-specific dlopen() variant
is contained in here, too. This is very thin wrapping, even sparing
definition of a handle type, just using void pointers.
Use of absolute paths is a good idea if you want to be sure which
file is openend, as default search paths vary.
*/
void *compat_dlopen (const char *path);
void *compat_dlsym (void *handle, const char* name);
void compat_dlclose(void *handle);
#endif
/* Blocking write/read of data with signal resilience.
They continue after being interrupted by signals and always return the
amount of processed data (shortage indicating actual problem or EOF). */
size_t unintr_write(int fd, void const *buffer, size_t bytes);
size_t unintr_read (int fd, void *buffer, size_t bytes);
size_t unintr_fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream);
/* That one comes from Tellie on OS/2, needed in resolver. */
#ifdef __KLIBC__
typedef int socklen_t;
#endif
/* OSX SDK defines an enum with "normal" as value. That clashes with
optimize.h */
#ifdef __APPLE__
#define normal mpg123_normal
#endif
#include "true.h"
#if (!defined(WIN32) || defined (__CYGWIN__)) && defined(HAVE_SIGNAL_H)
void (*catchsignal(int signum, void(*handler)()))();
#endif
#endif

108
src/compat/compat_dl.c Normal file
View File

@@ -0,0 +1,108 @@
/*
compat_dl: dynamic loading of shared libs
This is a separate libcompat to avoid needlessly linking all mpg123 code
with libdl on Unix.
copyright 2007-2019 by the mpg123 project - free software under the terms of the LGPL 2.1
see COPYING and AUTHORS files in distribution or http://mpg123.org
initially written by Thomas Orgis, Windows Unicode stuff by JonY.
*/
#include "config.h"
/* This source file does need _POSIX_SOURCE to get some sigaction. */
#define _POSIX_SOURCE
#include "compat.h"
#ifdef _MSC_VER
#include <io.h>
#if(defined(WINAPI_FAMILY) && (WINAPI_FAMILY==WINAPI_FAMILY_APP))
#define WINDOWS_UWP
#endif
#endif
#ifdef HAVE_SYS_STAT_H
# include <sys/stat.h>
#endif
#ifdef HAVE_DIRENT_H
# include <dirent.h>
#endif
/* Win32 is only supported with unicode now. These headers also cover
module stuff. The WANT_WIN32_UNICODE macro is synonymous with
"want windows-specific API, and only the unicode variants of which". */
#ifdef WANT_WIN32_UNICODE
#include <wchar.h>
#include <windows.h>
#include <winnls.h>
#include <shlwapi.h>
#endif
#ifdef USE_MODULES
# ifdef HAVE_DLFCN_H
# include <dlfcn.h>
# endif
#endif
#include "debug.h"
#include "wpathconv.h"
#ifdef USE_MODULES
/*
This is what I expected the platform-specific dance for dynamic module
support to be. Little did I know about the peculiarities of (long)
paths and directory/file search on Windows.
LoadLibrary throws GUI error boxes, use SetThreadErrorMode to suppress.
It needs to be done on per-thread basis to avoid race conditions
clobbering each other when setting/restoring across different threads.
*/
void *compat_dlopen(const char *path)
{
void *handle = NULL;
#ifdef WANT_WIN32_UNICODE
wchar_t *wpath;
wpath = u2wlongpath(path);
if(wpath) {
DWORD emode = GetThreadErrorMode();
int mode_ok = SetThreadErrorMode(emode | SEM_FAILCRITICALERRORS, NULL);
handle = LoadLibraryW(wpath);
if(mode_ok) {
SetThreadErrorMode(emode, NULL);
}
}
free(wpath);
#else
handle = dlopen(path, RTLD_NOW);
#endif
return handle;
}
void *compat_dlsym(void *handle, const char *name)
{
void *sym = NULL;
if(!handle)
return NULL;
#ifdef WANT_WIN32_UNICODE
sym = GetProcAddress(handle, name);
#else
sym = dlsym(handle, name);
#endif
return sym;
}
void compat_dlclose(void *handle)
{
if(!handle)
return;
#ifdef WANT_WIN32_UNICODE
FreeLibrary(handle);
#else
dlclose(handle);
#endif
}
#endif /* USE_MODULES */

105
src/compat/compat_str.c Normal file
View File

@@ -0,0 +1,105 @@
/*
compat: Some compatibility functions (basic memory and string stuff)
The mpg123 code is determined to keep it's legacy. A legacy of old, old UNIX.
So anything possibly somewhat advanced should be considered to be put here, with proper #ifdef;-)
copyright 2007-2016 by the mpg123 project - free software under the terms of the LGPL 2.1
see COPYING and AUTHORS files in distribution or http://mpg123.org
initially written by Thomas Orgis, Windows Unicode stuff by JonY.
*/
#include "compat.h"
/* Win32 is only supported with unicode now. These headers also cover
module stuff. The WANT_WIN32_UNICODE macro is synonymous with
"want windows-specific API, and only the unicode variants of which". */
#ifdef WANT_WIN32_UNICODE
#include <wchar.h>
#include <windows.h>
#include <winnls.h>
#endif
#include "debug.h"
/* A safe realloc also for very old systems where realloc(NULL, size) returns NULL. */
void *safe_realloc(void *ptr, size_t size)
{
if(ptr == NULL) return malloc(size);
else return realloc(ptr, size);
}
// A more sensible variant of realloc: It deallocates the original memory if
// realloc fails or if size zero was requested.
void *safer_realloc(void *ptr, size_t size)
{
void *nptr = size ? safe_realloc(ptr, size) : NULL;
if(!nptr && ptr)
free(ptr);
return nptr;
}
#ifndef HAVE_STRERROR
const char *strerror(int errnum)
{
extern int sys_nerr;
extern char *sys_errlist[];
return (errnum < sys_nerr) ? sys_errlist[errnum] : "";
}
#endif
char* compat_strdup(const char *src)
{
char *dest = NULL;
if(src)
{
size_t len;
len = strlen(src)+1;
if((dest = malloc(len)))
memcpy(dest, src, len);
}
return dest;
}
/* Windows Unicode stuff */
#ifdef WANT_WIN32_UNICODE
int win32_wide_utf8(const wchar_t * const wptr, char **mbptr, size_t * buflen)
{
size_t len;
char *buf;
int ret = 0;
len = WideCharToMultiByte(CP_UTF8, 0, wptr, -1, NULL, 0, NULL, NULL); /* Get utf-8 string length */
buf = calloc(len + 1, sizeof (char)); /* Can we assume sizeof char always = 1? */
if(!buf) len = 0;
else {
if (len != 0) ret = WideCharToMultiByte(CP_UTF8, 0, wptr, -1, buf, len, NULL, NULL); /*Do actual conversion*/
buf[len] = '0'; /* Must terminate */
}
*mbptr = buf; /* Set string pointer to allocated buffer */
if(buflen != NULL) *buflen = (len) * sizeof (char); /* Give length of allocated memory if needed. */
return ret;
}
int win32_utf8_wide(const char *const mbptr, wchar_t **wptr, size_t *buflen)
{
size_t len;
wchar_t *buf;
int ret = 0;
len = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, mbptr, -1, NULL, 0); /* Get converted size */
buf = calloc(len + 1, sizeof (wchar_t)); /* Allocate memory accordingly */
if(!buf) len = 0;
else {
if (len != 0) ret = MultiByteToWideChar (CP_UTF8, MB_ERR_INVALID_CHARS, mbptr, -1, buf, len); /* Do conversion */
buf[len] = L'0'; /* Must terminate */
}
*wptr = buf; /* Set string pointer to allocated buffer */
if (buflen != NULL) *buflen = len * sizeof (wchar_t); /* Give length of allocated memory if needed. */
return ret; /* Number of characters written */
}
#endif

120
src/compat/wpathconv.h Normal file
View File

@@ -0,0 +1,120 @@
/*
wpathconv: static functions for windows file path conversions
This file is intended to be included in libcompat sources for internal use.
It is separated out to be able to split off the dlopen functions into a
separate libcompat. It is just a code fragment.
copyright 2007-2019 by the mpg123 project - free software under the terms of the LGPL 2.1
see COPYING and AUTHORS files in distribution or http://mpg123.org
initially written by JonY
*/
#ifndef WINDOWS_UWP
#ifdef WANT_WIN32_UNICODE
/* Convert unix UTF-8 (or ASCII) paths to Windows wide character paths. */
static wchar_t* u2wpath(const char *upath)
{
wchar_t* wpath, *p;
if(!upath || win32_utf8_wide(upath, &wpath, NULL) < 1)
return NULL;
for(p=wpath; *p; ++p)
if(*p == L'/')
*p = L'\\';
return wpath;
}
/* Convert Windows wide character paths to unix UTF-8. */
static char* w2upath(const wchar_t *wpath)
{
char* upath, *p;
if(!wpath || win32_wide_utf8(wpath, &upath, NULL) < 1)
return NULL;
for(p=upath; *p; ++p)
if(*p == '\\')
*p = '/';
return upath;
}
/* An absolute path that is too long and not already marked with
\\?\ can be marked as a long one and still work. */
static int wpath_need_elongation(wchar_t *wpath)
{
if( wpath && !PathIsRelativeW(wpath)
&& wcslen(wpath) > MAX_PATH-1
&& wcsncmp(L"\\\\?\\", wpath, 4) )
return 1;
else
return 0;
}
/* Take any wide windows path and turn it into a path that is allowed
to be longer than MAX_PATH, if it is not already. */
static wchar_t* wlongpath(wchar_t *wpath)
{
size_t len, plen;
const wchar_t *prefix = L"";
wchar_t *wlpath = NULL;
if(!wpath)
return NULL;
/* Absolute paths that do not start with \\?\ get that prepended
to allow them being long. */
if(!PathIsRelativeW(wpath) && wcsncmp(L"\\\\?\\", wpath, 4))
{
if(wcslen(wpath) >= 2 && PathIsUNCW(wpath))
{
/* \\server\path -> \\?\UNC\server\path */
prefix = L"\\\\?\\UNC";
++wpath; /* Skip the first \. */
}
else /* c:\some/path -> \\?\c:\some\path */
prefix = L"\\\\?\\";
}
plen = wcslen(prefix);
len = plen + wcslen(wpath);
wlpath = malloc(len+1*sizeof(wchar_t));
if(wlpath)
{
/* Brute force memory copying, swprintf is too dandy. */
memcpy(wlpath, prefix, sizeof(wchar_t)*plen);
memcpy(wlpath+plen, wpath, sizeof(wchar_t)*(len-plen));
wlpath[len] = 0;
}
return wlpath;
}
/* Convert unix path to wide windows path, optionally marking
it as long path if necessary. */
static wchar_t* u2wlongpath(const char *upath)
{
wchar_t *wpath = NULL;
wchar_t *wlpath = NULL;
wpath = u2wpath(upath);
if(wpath_need_elongation(wpath))
{
wlpath = wlongpath(wpath);
free(wpath);
wpath = wlpath;
}
return wpath;
}
#endif
#else
static wchar_t* u2wlongpath(const char *upath)
{
wchar_t* wpath, *p;
if (!upath || win32_utf8_wide(upath, &wpath, NULL) < 1)
return NULL;
for (p = wpath; *p; ++p)
if (*p == L'/')
*p = L'\\';
return wpath;
}
#endif

528
src/config.h.in Normal file
View File

@@ -0,0 +1,528 @@
/* src/config.h.in. Generated from configure.ac by autoheader. */
/* Define if your architecture wants/needs/can use attribute_align_arg and
alignment checks. It is for 32bit x86... */
#undef ABI_ALIGN_FUN
/* Define to use proper rounding. */
#undef ACCURATE_ROUNDING
/* Define if building universal (internal helper macro) */
#undef AC_APPLE_UNIVERSAL_BUILD
/* Define if .balign is present. */
#undef ASMALIGN_BALIGN
/* Define if .align just takes byte count. */
#undef ASMALIGN_BYTE
/* Define if .align takes 3 for alignment of 2^3=8 bytes instead of 8. */
#undef ASMALIGN_EXP
/* Define if __attribute__((aligned(16))) shall be used */
#undef CCALIGN
/* Define if debugging is enabled. */
#undef DEBUG
/* The default audio output module(s) to use */
#undef DEFAULT_OUTPUT_MODULE
/* Define if building with dynamcally linked libmpg123 */
#undef DYNAMIC_BUILD
/* Use EFBIG as substitude for EOVERFLOW, mingw.org may lack the latter */
#undef EOVERFLOW
/* Define if FIFO support is enabled. */
#undef FIFO
/* Define if frame index should be used. */
#undef FRAME_INDEX
/* Define if gapless is enabled. */
#undef GAPLESS
/* Define to 1 if you have the <alc.h> header file. */
#undef HAVE_ALC_H
/* Define to 1 if you have the <Alib.h> header file. */
#undef HAVE_ALIB_H
/* Define to 1 if you have the <AL/alc.h> header file. */
#undef HAVE_AL_ALC_H
/* Define to 1 if you have the <AL/al.h> header file. */
#undef HAVE_AL_AL_H
/* Define to 1 if you have the <al.h> header file. */
#undef HAVE_AL_H
/* Define to 1 if you have the <arpa/inet.h> header file. */
#undef HAVE_ARPA_INET_H
/* Define to 1 if you have the <asm/audioio.h> header file. */
#undef HAVE_ASM_AUDIOIO_H
/* Define to 1 if you have the `atoll' function. */
#undef HAVE_ATOLL
/* Define to 1 if you have the <audios.h> header file. */
#undef HAVE_AUDIOS_H
/* Define to 1 if you have the <AudioToolbox/AudioToolbox.h> header file. */
#undef HAVE_AUDIOTOOLBOX_AUDIOTOOLBOX_H
/* Define to 1 if you have the <AudioUnit/AudioUnit.h> header file. */
#undef HAVE_AUDIOUNIT_AUDIOUNIT_H
/* Define to 1 if you have the <byteswap.h> header file. */
#undef HAVE_BYTESWAP_H
/* Define to 1 if you have the <CoreServices/CoreServices.h> header file. */
#undef HAVE_CORESERVICES_CORESERVICES_H
/* Define to 1 if you have the <CUlib.h> header file. */
#undef HAVE_CULIB_H
/* Define to 1 if you have the <dirent.h> header file. */
#undef HAVE_DIRENT_H
/* Define to 1 if you have the `dlclose' function. */
#undef HAVE_DLCLOSE
/* Define to 1 if you have the <dlfcn.h> header file. */
#undef HAVE_DLFCN_H
/* Define to 1 if you have the `dlopen' function. */
#undef HAVE_DLOPEN
/* Define to 1 if you have the `dlsym' function. */
#undef HAVE_DLSYM
/* Define to 1 if you have the `getaddrinfo' function. */
#undef HAVE_GETADDRINFO
/* Define to 1 if you have the `getuid' function. */
#undef HAVE_GETUID
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
/* Define to 1 if you have the `iswprint' function. */
#undef HAVE_ISWPRINT
/* Define to 1 if you have the <langinfo.h> header file. */
#undef HAVE_LANGINFO_H
/* Define to 1 if you have the `m' library (-lm). */
#undef HAVE_LIBM
/* Define to 1 if you have the `mx' library (-lmx). */
#undef HAVE_LIBMX
/* Define to 1 if you have the <limits.h> header file. */
#undef HAVE_LIMITS_H
/* Define to 1 if you have the <linux/soundcard.h> header file. */
#undef HAVE_LINUX_SOUNDCARD_H
/* Define to 1 if you have the <locale.h> header file. */
#undef HAVE_LOCALE_H
/* Define to 1 if you have the <machine/soundcard.h> header file. */
#undef HAVE_MACHINE_SOUNDCARD_H
/* Define to 1 if you have the `mbstowcs' function. */
#undef HAVE_MBSTOWCS
/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H
/* Define to 1 if you have the `mkfifo' function. */
#undef HAVE_MKFIFO
/* Define to 1 if you have the `mmap' function. */
#undef HAVE_MMAP
/* Define to 1 if you have the <netdb.h> header file. */
#undef HAVE_NETDB_H
/* Define to 1 if you have the <netinet/in.h> header file. */
#undef HAVE_NETINET_IN_H
/* Define to 1 if you have the <netinet/tcp.h> header file. */
#undef HAVE_NETINET_TCP_H
/* Define to 1 if you have the `nl_langinfo' function. */
#undef HAVE_NL_LANGINFO
/* Define to 1 if you have the <OpenAL/alc.h> header file. */
#undef HAVE_OPENAL_ALC_H
/* Define to 1 if you have the <OpenAL/al.h> header file. */
#undef HAVE_OPENAL_AL_H
/* Define to 1 if you have the <os2me.h> header file. */
#undef HAVE_OS2ME_H
/* Define to 1 if you have the <os2.h> header file. */
#undef HAVE_OS2_H
/* Define to 1 if you have the `random' function. */
#undef HAVE_RANDOM
/* Define to 1 if you have the <sched.h> header file. */
#undef HAVE_SCHED_H
/* Define to 1 if you have the `sched_setscheduler' function. */
#undef HAVE_SCHED_SETSCHEDULER
/* Define to 1 if you have the `setlocale' function. */
#undef HAVE_SETLOCALE
/* Define to 1 if you have the `setpriority' function. */
#undef HAVE_SETPRIORITY
/* Define to 1 if you have the `setuid' function. */
#undef HAVE_SETUID
/* Define to 1 if you have the `shmat' function. */
#undef HAVE_SHMAT
/* Define to 1 if you have the `shmctl' function. */
#undef HAVE_SHMCTL
/* Define to 1 if you have the `shmdt' function. */
#undef HAVE_SHMDT
/* Define to 1 if you have the `shmget' function. */
#undef HAVE_SHMGET
/* Define to 1 if you have the <signal.h> header file. */
#undef HAVE_SIGNAL_H
/* Define to 1 if you have the <sndio.h> header file. */
#undef HAVE_SNDIO_H
/* Define to 1 if you have the <stdint.h> header file. */
#undef HAVE_STDINT_H
/* Define to 1 if you have the <stdio.h> header file. */
#undef HAVE_STDIO_H
/* Define to 1 if you have the <stdlib.h> header file. */
#undef HAVE_STDLIB_H
/* Define to 1 if you have the `strerror' function. */
#undef HAVE_STRERROR
/* Define to 1 if you have the <strings.h> header file. */
#undef HAVE_STRINGS_H
/* Define to 1 if you have the <string.h> header file. */
#undef HAVE_STRING_H
/* Define to 1 if you have the <sun/audioio.h> header file. */
#undef HAVE_SUN_AUDIOIO_H
/* Define to 1 if you have the <sys/audioio.h> header file. */
#undef HAVE_SYS_AUDIOIO_H
/* Define to 1 if you have the <sys/audio.h> header file. */
#undef HAVE_SYS_AUDIO_H
/* Define to 1 if you have the <sys/ioctl.h> header file. */
#undef HAVE_SYS_IOCTL_H
/* Define to 1 if you have the <sys/ipc.h> header file. */
#undef HAVE_SYS_IPC_H
/* Define to 1 if you have the <sys/param.h> header file. */
#undef HAVE_SYS_PARAM_H
/* Define to 1 if you have the <sys/resource.h> header file. */
#undef HAVE_SYS_RESOURCE_H
/* Define to 1 if you have the <sys/select.h> header file. */
#undef HAVE_SYS_SELECT_H
/* Define to 1 if you have the <sys/shm.h> header file. */
#undef HAVE_SYS_SHM_H
/* Define to 1 if you have the <sys/signal.h> header file. */
#undef HAVE_SYS_SIGNAL_H
/* Define to 1 if you have the <sys/socket.h> header file. */
#undef HAVE_SYS_SOCKET_H
/* Define to 1 if you have the <sys/soundcard.h> header file. */
#undef HAVE_SYS_SOUNDCARD_H
/* Define to 1 if you have the <sys/stat.h> header file. */
#undef HAVE_SYS_STAT_H
/* Define to 1 if you have the <sys/time.h> header file. */
#undef HAVE_SYS_TIME_H
/* Define to 1 if you have the <sys/types.h> header file. */
#undef HAVE_SYS_TYPES_H
/* Define to 1 if you have the <sys/wait.h> header file. */
#undef HAVE_SYS_WAIT_H
/* Define this if you have the POSIX termios library */
#undef HAVE_TERMIOS
/* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
/* Define to 1 if you have the <wchar.h> header file. */
#undef HAVE_WCHAR_H
/* Define to 1 if you have the `wcstombs' function. */
#undef HAVE_WCSTOMBS
/* Define to 1 if you have the `wcswidth' function. */
#undef HAVE_WCSWIDTH
/* Define to 1 if you have the <wctype.h> header file. */
#undef HAVE_WCTYPE_H
/* Define to 1 if you have the <windows.h> header file. */
#undef HAVE_WINDOWS_H
/* Define to 1 if you have the <ws2tcpip.h> header file. */
#undef HAVE_WS2TCPIP_H
/* Define to indicate that float storage follows IEEE754. */
#undef IEEE_FLOAT
/* size of the frame index seek table */
#undef INDEX_SIZE
/* Define if IPV6 support is enabled. */
#undef IPV6
/* Define this to the size of native offset type in bits, used for LFS alias
functions. */
#undef LFS_ALIAS_BITS
/* Define to the extension used for runtime loadable modules, say, ".so". */
#undef LT_MODULE_EXT
/* Define to the sub-directory where libtool stores uninstalled libraries. */
#undef LT_OBJDIR
/* Define to the shared library suffix, say, ".dylib". */
#undef LT_SHARED_EXT
/* Define to the shared archive member specification, say "(shr.o)". */
#undef LT_SHARED_LIB_MEMBER
/* Define if network support is enabled. */
#undef NETWORK
/* Define to disable 16 bit integer output. */
#undef NO_16BIT
/* Define to disable 32 bit and 24 bit integer output. */
#undef NO_32BIT
/* Define to disable 8 bit integer output. */
#undef NO_8BIT
/* Define to disable downsampled decoding. */
#undef NO_DOWNSAMPLE
/* Define to disable equalizer. */
#undef NO_EQUALIZER
/* Define to disable error messages in combination with a return value (the
return is left intact). */
#undef NO_ERETURN
/* Define to disable error messages. */
#undef NO_ERRORMSG
/* Define to disable feeder and buffered readers. */
#undef NO_FEEDER
/* Define to disable ICY handling. */
#undef NO_ICY
/* Define to disable ID3v2 parsing. */
#undef NO_ID3V2
/* Define to disable layer I. */
#undef NO_LAYER1
/* Define to disable layer II. */
#undef NO_LAYER2
/* Define to disable layer III. */
#undef NO_LAYER3
/* Define to disable analyzer info. */
#undef NO_MOREINFO
/* Define to disable ntom resampling. */
#undef NO_NTOM
/* Define to disable real output. */
#undef NO_REAL
/* Define to disable string functions. */
#undef NO_STRING
/* Define for post-processed 32 bit formats. */
#undef NO_SYNTH32
/* Define to disable warning messages. */
#undef NO_WARNING
/* Name of package */
#undef PACKAGE
/* Define to the address where bug reports for this package should be sent. */
#undef PACKAGE_BUGREPORT
/* Define to the full name of this package. */
#undef PACKAGE_NAME
/* Define to the full name and version of this package. */
#undef PACKAGE_STRING
/* Define to the one symbol short name of this package. */
#undef PACKAGE_TARNAME
/* Define to the home page for this package. */
#undef PACKAGE_URL
/* Define to the version of this package. */
#undef PACKAGE_VERSION
/* Define if portaudio v18 API is wanted. */
#undef PORTAUDIO18
/* Define for calculating tables at runtime. */
#undef RUNTIME_TABLES
/* The size of `int32_t', as computed by sizeof. */
#undef SIZEOF_INT32_T
/* The size of `long', as computed by sizeof. */
#undef SIZEOF_LONG
/* The size of `off64_t', as computed by sizeof. */
#undef SIZEOF_OFF64_T
/* The size of `off_t', as computed by sizeof. */
#undef SIZEOF_OFF_T
/* The size of `size_t', as computed by sizeof. */
#undef SIZEOF_SIZE_T
/* The size of `ssize_t', as computed by sizeof. */
#undef SIZEOF_SSIZE_T
/* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS
/* Define to not duplicate some code for likely cases in libsyn123. */
#undef SYN123_NO_CASES
/* Define if modules are enabled */
#undef USE_MODULES
/* Define for new Huffman decoding scheme. */
#undef USE_NEW_HUFFTABLE
/* Define to use yasm for assemble AVX sources. */
#undef USE_YASM_FOR_AVX
/* Version number of package */
#undef VERSION
/* Define to use Win32 named pipes */
#undef WANT_WIN32_FIFO
/* Define to use Win32 sockets */
#undef WANT_WIN32_SOCKETS
/* Define to use Unicode for Windows */
#undef WANT_WIN32_UNICODE
/* Windows UWP build */
#undef WINDOWS_UWP
/* Windows Vista and later APIs */
#undef WINVER
/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
significant byte first (like Motorola and SPARC, unlike Intel). */
#if defined AC_APPLE_UNIVERSAL_BUILD
# if defined __BIG_ENDIAN__
# define WORDS_BIGENDIAN 1
# endif
#else
# ifndef WORDS_BIGENDIAN
# undef WORDS_BIGENDIAN
# endif
#endif
/* Define for extreme debugging. */
#undef XDEBUG
/* Enable large inode numbers on Mac OS X 10.5. */
#ifndef _DARWIN_USE_64_BIT_INODE
# define _DARWIN_USE_64_BIT_INODE 1
#endif
/* Number of bits in a file offset, on hosts where this is settable. */
#undef _FILE_OFFSET_BITS
/* Define for large files, on AIX-style hosts. */
#undef _LARGE_FILES
/* Windows Vista and later APIs */
#undef _WIN32_WINNT
/* Define to empty if `const' does not conform to ANSI C. */
#undef const
/* Define to `__inline__' or `__inline' if that's what the C compiler
calls it, or to nothing if 'inline' is not supported under any name. */
#ifndef __cplusplus
#undef inline
#endif
/* Define to `short' if <sys/types.h> does not define. */
#undef int16_t
/* Define to `int' if <sys/types.h> does not define. */
#undef int32_t
/* Define to `long long' if <sys/types.h> does not define. */
#undef int64_t
/* Define to the native offset type (long or actually off_t). */
#undef lfs_alias_t
/* Define to `long int' if <sys/types.h> does not define. */
#undef off_t
/* Define to `unsigned long' if <sys/types.h> does not define. */
#undef size_t
/* Define to `long' if <sys/types.h> does not define. */
#undef ssize_t
/* Define to `unsigned short' if <sys/types.h> does not define. */
#undef uint16_t
/* Define to `unsigned int' if <sys/types.h> does not define. */
#undef uint32_t
/* Define to `unsigned long' if <sys/types.h> does not define. */
#undef uintptr_t

939
src/control_generic.c Normal file
View File

@@ -0,0 +1,939 @@
/*
control_generic.c: control interface for frontends and real console warriors
copyright 1997-99,2004-20 by the mpg123 project - free software under the terms of the LGPL 2.1
see COPYING and AUTHORS files in distribution or http://mpg123.org
initially written by Andreas Neuhaus and Michael Hipp
reworked by Thomas Orgis - it was the entry point for eventually becoming maintainer...
*/
#include "config.h"
/* _BSD_SOURCE needed for setlinebuf, erm, but that's deprecated
so trying _DEFAULT_SOURCE */
#ifndef _DEFAULT_SOURCE
#define _DEFAULT_SOURCE
#endif
/* Defining that after _DEFAULT_SOURCE seems fine and is still
needed for older glibc. I guess I need a configure check
about setlinebuf()/setvbuf() if I really care about old
systems. */
#ifndef _BSD_SOURCE
#define _BSD_SOURCE
#endif
#include "compat.h"
#include "mpg123app.h"
#include "out123.h"
#include <stdarg.h>
#include <ctype.h>
#if !defined (WIN32) || defined (__CYGWIN__)
#include <sys/wait.h>
#include <sys/socket.h>
#endif
#include <errno.h>
#include <string.h>
#include "common.h"
#include "genre.h"
#include "playlist.h"
#include "metaprint.h"
#include "audio.h"
#define MODE_STOPPED 0
#define MODE_PLAYING 1
#define MODE_PAUSED 2
extern out123_handle *ao;
#ifdef FIFO
#include <sys/stat.h>
int control_file = STDIN_FILENO;
#else
#define control_file STDIN_FILENO
#ifdef WANT_WIN32_FIFO
#error Control interface does not work on win32 stdin
#endif /* WANT_WIN32_FIFO */
#endif
FILE *outstream;
int out_is_term = FALSE;
static int mode = MODE_STOPPED;
static int init = 0;
#include "debug.h"
void generic_sendmsg (const char *fmt, ...)
{
va_list ap;
fprintf(outstream, "@");
va_start(ap, fmt);
vfprintf(outstream, fmt, ap);
va_end(ap);
fprintf(outstream, "\n");
}
// Variant that takes the first argument as a string subject to filtering.
static void generic_sendstr(int is_utf8, const char *fmt, char* str, ...)
{
va_list ap;
va_start(ap, str);
char *outbuf = NULL;
outstr(&outbuf, str, is_utf8, out_is_term);
generic_sendmsg(fmt, PSTR(outbuf), ap);
free(outbuf);
va_end(ap);
}
// Another one for two strings. I want to avoid writing a full format string parser.
static void generic_send2str( int is_utf8, const char *fmt
, char* str, char *str2, ... )
{
va_list ap;
va_start(ap, str2);
char *outbuf1 = NULL;
char *outbuf2 = NULL;
outstr(&outbuf1, str, is_utf8, out_is_term);
outstr(&outbuf2, str2, is_utf8, out_is_term);
generic_sendmsg(fmt, PSTR(outbuf1), PSTR(outbuf2), ap);
free(outbuf2);
free(outbuf1);
va_end(ap);
}
// Another one for three strings. Meh ...
static void generic_send3str( int is_utf8, const char *fmt
, char* str, char *str2, char *str3, ... )
{
va_list ap;
va_start(ap, str3);
char *outbuf1 = NULL;
char *outbuf2 = NULL;
char *outbuf3 = NULL;
outstr(&outbuf1, str, is_utf8, out_is_term);
outstr(&outbuf2, str2, is_utf8, out_is_term);
outstr(&outbuf3, str3, is_utf8, out_is_term);
generic_sendmsg( fmt
, PSTR(outbuf1), PSTR(outbuf2), PSTR(outbuf3)
, ap );
free(outbuf3);
free(outbuf2);
free(outbuf1);
va_end(ap);
}
/* Split up a number of lines separated by \n, \r, both or just zero byte
and print out each line with specified prefix. */
static void generic_send_lines(int is_utf8, const char* fmt, mpg123_string *inlines)
{
size_t i;
int hadcr = 0, hadlf = 0;
char *lines = NULL;
char *line = NULL;
size_t len = 0;
char *outbuf = NULL;
if(inlines != NULL && inlines->fill)
{
lines = inlines->p;
len = inlines->fill;
}
else return;
line = lines;
for(i=0; i<len; ++i)
{
if(lines[i] == '\n' || lines[i] == '\r' || lines[i] == 0)
{
char save = lines[i]; /* saving, changing, restoring a byte in the data */
if(save == '\n') ++hadlf;
if(save == '\r') ++hadcr;
if((hadcr || hadlf) && hadlf % 2 == 0 && hadcr % 2 == 0) line = "";
if(line)
{
lines[i] = 0;
outstr(&outbuf, line, is_utf8, out_is_term);
generic_sendmsg(fmt, outbuf ? outbuf : "???");
line = NULL;
lines[i] = save;
}
}
else
{
hadlf = hadcr = 0;
if(line == NULL) line = lines+i;
}
}
free(outbuf);
}
void generic_sendstat (mpg123_handle *fr)
{
off_t current_frame, frames_left;
double current_seconds, seconds_left;
if(!mpg123_position(fr, 0, out123_buffered(ao), &current_frame, &frames_left, &current_seconds, &seconds_left))
generic_sendmsg("F %"OFF_P" %"OFF_P" %3.2f %3.2f", (off_p)current_frame, (off_p)frames_left, current_seconds, seconds_left);
}
// This is only valid as herlper to generic_sendv1, observe info memory usage!
static void v1add(char *buf[], char *info, const char *str, size_t len)
{
memset(info, 0, len);
if(!unknown2utf8(buf, str, len))
{
outstr(buf+1, buf[0], 1, out_is_term);
size_t slen = buf[1] ? strlen(buf[1])+1 : 0;
memcpy(info, PSTR(buf[1]), slen >=len ? len : slen);
}
}
static void generic_sendv1(mpg123_id3v1 *v1, const char *prefix)
{
int i;
char info[125] = "";
char *buf[2];
buf[0] = NULL;
buf[1] = NULL;
v1add(buf, info, v1->title, 30);
v1add(buf, info+30, v1->artist, 30);
v1add(buf, info+60, v1->album, 30);
v1add(buf, info+90, v1->year, 4);
v1add(buf, info+94, v1->comment, 30);
for(i=0;i<124; ++i) if(info[i] == 0) info[i] = ' ';
info[i] = 0;
generic_sendmsg("%s ID3:%s%s", prefix, info, (v1->genre<=genre_count) ? genre_table[v1->genre] : "Unknown");
generic_sendmsg("%s ID3.genre:%i", prefix, v1->genre);
if(v1->comment[28] == 0 && v1->comment[29] != 0)
generic_sendmsg("%s ID3.track:%i", prefix, (unsigned char)v1->comment[29]);
free(buf[1]);
free(buf[0]);
}
static void generic_sendinfoid3(mpg123_handle *mh)
{
mpg123_id3v1 *v1;
mpg123_id3v2 *v2;
if(MPG123_OK != mpg123_id3(mh, &v1, &v2))
{
error1("Cannot get ID3 data: %s", mpg123_strerror(mh));
return;
}
generic_sendmsg("I {");
if(v1 != NULL)
{
generic_sendv1(v1, "I");
}
if(v2 != NULL)
{
generic_send_lines(1, "I ID3v2.title:%s", v2->title);
generic_send_lines(1, "I ID3v2.artist:%s", v2->artist);
generic_send_lines(1, "I ID3v2.album:%s", v2->album);
generic_send_lines(1, "I ID3v2.year:%s", v2->year);
generic_send_lines(1, "I ID3v2.comment:%s", v2->comment);
generic_send_lines(1, "I ID3v2.genre:%s", v2->genre);
}
generic_sendmsg("I }");
}
void generic_sendalltag(mpg123_handle *mh)
{
mpg123_id3v1 *v1;
mpg123_id3v2 *v2;
generic_sendmsg("T {");
if(MPG123_OK != mpg123_id3(mh, &v1, &v2))
{
error1("Cannot get ID3 data: %s", mpg123_strerror(mh));
v2 = NULL;
v1 = NULL;
}
if(v1 != NULL) generic_sendv1(v1, "T");
if(v2 != NULL)
{
size_t i;
for(i=0; i<v2->texts; ++i)
{
char id[5];
memcpy(id, v2->text[i].id, 4);
id[4] = 0;
generic_sendstr(1, "T ID3v2.%s:", id);
generic_send_lines(1, "T =%s", &v2->text[i].text);
}
for(i=0; i<v2->extras; ++i)
{
char id[5];
memcpy(id, v2->extra[i].id, 4);
id[4] = 0;
generic_send2str( 1, "T ID3v2.%s desc(%s)"
, id, MPGSTR(v2->extra[i].description) );
generic_send_lines(1, "T =%s", &v2->extra[i].text);
}
for(i=0; i<v2->comments; ++i)
{
char id[5];
char lang[4];
memcpy(id, v2->comment_list[i].id, 4);
id[4] = 0;
memcpy(lang, v2->comment_list[i].lang, 3);
lang[3] = 0;
generic_send3str( 1, "T ID3v2.%s lang(%s) desc(%s):",
id, lang, MPGSTR(v2->comment_list[i].description) );
generic_send_lines(1, "T =%s", &v2->comment_list[i].text);
}
}
generic_sendmsg("T }");
}
void generic_sendinfo (char *filename)
{
char *s, *t;
s = strrchr(filename, '/');
if (!s)
s = filename;
else
s++;
t = strrchr(s, '.');
if (t)
*t = 0;
generic_sendstr(0, "I %s", s);
}
static void generic_load(mpg123_handle *fr, char *arg, int state)
{
out123_drop(ao);
if(mode != MODE_STOPPED)
{
close_track();
mode = MODE_STOPPED;
}
if(!open_track(arg))
{
generic_sendmsg("E Error opening stream: %s", arg);
generic_sendmsg("P 0");
return;
}
mpg123_seek(fr, 0, SEEK_SET); /* This finds ID3v2 at beginning. */
if(mpg123_meta_check(fr) & MPG123_NEW_ID3)
{
generic_sendinfoid3(fr);
}
else generic_sendinfo(arg);
if(htd.icy_name.fill) generic_sendstr(1, "I ICY-NAME: %s", htd.icy_name.p);
if(htd.icy_url.fill) generic_sendstr(1, "I ICY-URL: %s", htd.icy_url.p);
mode = state;
init = 1;
generic_sendmsg(mode == MODE_PAUSED ? "P 1" : "P 2");
}
static void generic_loadlist(mpg123_handle *fr, char *arg)
{
/* arguments are two: first the index to play, then the URL */
long entry;
long i = 0;
char *file = NULL;
char *thefile = NULL;
char *outbuf = NULL;
/* I feel retarted with string parsing outside Perl. */
while(*arg && isspace(*arg)) ++arg;
entry = atol(arg);
while(*arg && !isspace(*arg)) ++arg;
while(*arg && isspace(*arg)) ++arg;
if(!*arg)
{
generic_sendmsg("E empty list name");
return;
}
generic_sendmsg("I {");
/* Now got the plain playlist path in arg. On to evil manupulation of mpg123's playlist code. */
param.listname = arg;
param.listentry = 0; /* The playlist shall not filter. */
param.loop = 1;
param.shuffle = 0;
int pl_utf8 = 0;
prepare_playlist(0, NULL, 0, &pl_utf8);
while((file = get_next_file()))
{
++i;
/* semantics: 0 brings you to the last track */
if(entry == 0 || entry == i) thefile = file;
outstr(&outbuf, file, pl_utf8, out_is_term);
generic_sendmsg("I LISTENTRY %li: %s", i, outbuf ? outbuf : "???");
}
if(!i) generic_sendmsg("I LIST EMPTY");
generic_sendmsg("I }");
/* If we have something to play, play it. */
if(thefile) generic_load(fr, thefile, MODE_PLAYING);
free_playlist(); /* Free memory after it is not needed anymore. */
free(outbuf);
}
int control_generic (mpg123_handle *fr)
{
struct timeval tv;
fd_set fds;
int n;
/* ThOr */
char alive = 1;
char silent = 0;
/* responses to stderr for frontends needing audio data from stdout */
if (param.remote_err)
{
outstream = stderr;
out_is_term = stderr_is_term;
}
else
{
outstream = stdout;
out_is_term = stdout_is_term;
}
#ifndef WIN32
setlinebuf(outstream);
#else /* perhaps just use setvbuf as it's C89 */
/*
fprintf(outstream, "You are on Win32 and want to use the control interface... tough luck: We need a replacement for select on STDIN first.\n");
return 0;
setvbuf(outstream, (char*)NULL, _IOLBF, 0);
*/
#endif
/* the command behaviour is different, so is the ID */
/* now also with version for command availability */
fprintf(outstream, "@R MPG123 (ThOr) v9\n");
#ifdef FIFO
if(param.fifo)
{
if(param.fifo[0] == 0)
{
error("You wanted an empty FIFO name??");
return 1;
}
#ifndef WANT_WIN32_FIFO
unlink(param.fifo);
if(mkfifo(param.fifo, 0666) == -1)
{
error2("Failed to create FIFO at %s (%s)", param.fifo, strerror(errno));
return 1;
}
debug("going to open named pipe ... blocking until someone gives command");
#endif /* WANT_WIN32_FIFO */
#ifdef WANT_WIN32_FIFO
control_file = win32_fifo_mkfifo(param.fifo);
#else
control_file = open(param.fifo,O_RDONLY);
#endif /* WANT_WIN32_FIFO */
debug("opened");
}
#endif
while (alive)
{
tv.tv_sec = 0;
tv.tv_usec = 0;
FD_ZERO(&fds);
FD_SET(control_file, &fds);
/* play frame if no command needs to be processed */
if (mode == MODE_PLAYING) {
#ifdef WANT_WIN32_FIFO
n = win32_fifo_read_peek(&tv);
#else
n = select(32, &fds, NULL, NULL, &tv);
#endif
if (n == 0) {
if (!play_frame())
{
out123_pause(ao);
/* When the track ended, user may want to keep it open (to seek back),
so there is a decision between stopping and pausing at the end. */
if(param.keep_open)
{
mode = MODE_PAUSED;
/* Hm, buffer should be stopped already, shouldn't it? */
generic_sendmsg("P 1");
}
else
{
mode = MODE_STOPPED;
close_track();
generic_sendmsg("P 0");
}
continue;
}
if (init) {
print_remote_header(fr);
init = 0;
}
if(silent == 0)
{
generic_sendstat(fr);
if(mpg123_meta_check(fr) & MPG123_NEW_ICY)
{
char *meta;
if(mpg123_icy(fr, &meta) == MPG123_OK)
generic_sendstr( 1, "I ICY-META: %s"
, meta != NULL ? meta : "<nil>" );
}
}
}
}
else {
/* wait for command */
while (1) {
#ifdef WANT_WIN32_FIFO
n = win32_fifo_read_peek(NULL);
#else
n = select(32, &fds, NULL, NULL, NULL);
#endif
if (n > 0)
break;
}
}
/* on error */
if(n < 0)
{
merror("waiting for command: %s", strerror(errno));
return 1;
}
/* read & process commands */
if (n > 0)
{
short int len = 1; /* length of buffer */
char *cmd, *arg; /* variables for parsing, */
char *comstr = NULL; /* gcc thinks that this could be used uninitialited... */
char buf[REMOTE_BUFFER_SIZE];
short int counter;
char *next_comstr = buf; /* have it initialized for first command */
/* read as much as possible, maybe multiple commands */
/* When there is nothing to read (EOF) or even an error, it is the end */
#ifdef WANT_WIN32_FIFO
len = win32_fifo_read(buf,REMOTE_BUFFER_SIZE);
#else
len = read(control_file, buf, REMOTE_BUFFER_SIZE);
#endif
if(len < 1)
{
#ifdef FIFO
if(len == 0 && param.fifo)
{
debug("fifo ended... reopening");
#ifdef WANT_WIN32_FIFO
win32_fifo_mkfifo(param.fifo);
#else
close(control_file);
control_file = open(param.fifo,O_RDONLY|O_NONBLOCK);
#endif
if(control_file < 0){ error1("open of fifo failed... %s", strerror(errno)); break; }
continue;
}
#endif
if(len < 0) error1("command read error: %s", strerror(errno));
break;
}
debug1("read %i bytes of commands", len);
/* one command on a line - separation by \n -> C strings in a row */
for(counter = 0; counter < len; ++counter)
{
/* line end is command end */
if( (buf[counter] == '\n') || (buf[counter] == '\r') )
{
debug1("line end at counter=%i", counter);
buf[counter] = 0; /* now it's a properly ending C string */
comstr = next_comstr;
/* skip the additional line ender of \r\n or \n\r */
if( (counter < (len - 1)) && ((buf[counter+1] == '\n') || (buf[counter+1] == '\r')) ) buf[++counter] = 0;
/* next "real" char is first of next command */
next_comstr = buf + counter+1;
/* directly process the command now */
debug1("interpreting command: %s", comstr);
if(strlen(comstr) == 0) continue;
/* PAUSE */
if (!strcasecmp(comstr, "P") || !strcasecmp(comstr, "PAUSE")) {
if(mode != MODE_STOPPED)
{
if (mode == MODE_PLAYING) {
mode = MODE_PAUSED;
out123_pause(ao);
generic_sendmsg("P 1");
} else {
mode = MODE_PLAYING;
out123_continue(ao);
generic_sendmsg("P 2");
}
} else generic_sendmsg("P 0");
continue;
}
/* STOP */
if (!strcasecmp(comstr, "S") || !strcasecmp(comstr, "STOP")) {
if (mode != MODE_STOPPED) {
/* Do we want to drop here? */
out123_drop(ao);
out123_pause(ao);
close_track();
mode = MODE_STOPPED;
generic_sendmsg("P 0");
} else generic_sendmsg("P 0");
continue;
}
/* SILENCE */
if(!strcasecmp(comstr, "SILENCE")) {
silent = 1;
generic_sendmsg("silence");
continue;
}
if(!strcasecmp(comstr, "MUTE")) {
set_mute(ao, muted=TRUE);
generic_sendmsg("mute");
continue;
}
if(!strcasecmp(comstr, "UNMUTE")) {
set_mute(ao, muted=FALSE);
generic_sendmsg("unmute");
continue;
}
if(!strcasecmp(comstr, "T") || !strcasecmp(comstr, "TAG")) {
generic_sendalltag(fr);
continue;
}
if(!strcasecmp(comstr, "SCAN"))
{
if(mode != MODE_STOPPED)
{
if(mpg123_scan(fr) == MPG123_OK)
generic_sendmsg("SCAN done");
else
generic_sendmsg("E %s", mpg123_strerror(fr));
}
else generic_sendmsg("E No track loaded!");
continue;
}
if(!strcasecmp(comstr, "SAMPLE"))
{
off_t pos = mpg123_tell(fr);
off_t len = mpg123_length(fr);
/* I need to have portable printf specifiers that do not truncate the type... more autoconf... */
if(len < 0) generic_sendmsg("E %s", mpg123_strerror(fr));
else generic_sendmsg("SAMPLE %li %li", (long)pos, (long)len);
continue;
}
if(!strcasecmp(comstr, "FORMAT"))
{
long rate;
int ch;
int ret = mpg123_getformat2(fr, &rate, &ch, NULL, 0);
/* I need to have portable printf specifiers that do not truncate the type... more autoconf... */
if(ret < 0) generic_sendmsg("E %s", mpg123_strerror(fr));
else generic_sendmsg("FORMAT %li %i", rate, ch);
continue;
}
if(!strcasecmp(comstr, "SHOWEQ"))
{
int i;
generic_sendmsg("SHOWEQ {");
for(i=0; i<32; ++i)
{
generic_sendmsg("SHOWEQ %i : %i : %f", MPG123_LEFT, i, mpg123_geteq(fr, MPG123_LEFT, i));
generic_sendmsg("SHOWEQ %i : %i : %f", MPG123_RIGHT, i, mpg123_geteq(fr, MPG123_RIGHT, i));
}
generic_sendmsg("SHOWEQ }");
continue;
}
if(!strcasecmp(comstr, "STATE"))
{
long val;
generic_sendmsg("STATE {");
/* Get some state information bits and display them. */
if(mpg123_getstate(fr, MPG123_ACCURATE, &val, NULL) == MPG123_OK)
generic_sendmsg("STATE accurate %li", val);
generic_sendmsg("STATE }");
continue;
}
/* QUIT */
if (!strcasecmp(comstr, "Q") || !strcasecmp(comstr, "QUIT")){
alive = FALSE; continue;
}
/* some HELP */
if (!strcasecmp(comstr, "H") || !strcasecmp(comstr, "HELP")) {
generic_sendmsg("H {");
generic_sendmsg("H HELP/H: command listing (LONG/SHORT forms), command case insensitve");
generic_sendmsg("H LOAD/L <trackname>: load and start playing resource <trackname>");
generic_sendmsg("H LOADPAUSED/LP <trackname>: load but do not start playing resource <trackname>");
generic_sendmsg("H LOADLIST/LL <entry> <url>: load a playlist from given <url>, and display its entries, optionally load and play one of these specificed by the integer <entry> (<0: just list, 0: play last track, >0:play track with that position in list)");
generic_sendmsg("H PAUSE/P: pause playback");
generic_sendmsg("H STOP/S: stop playback (closes file)");
generic_sendmsg("H JUMP/J <frame>|<+offset>|<-offset>|<[+|-]seconds>s: jump to mpeg frame <frame> or change position by offset, same in seconds if number followed by \"s\"");
generic_sendmsg("H VOLUME/V <percent>: set volume in % (0..100...); float value");
generic_sendmsg("H MUTE: turn on software mute in output");
generic_sendmsg("H UNMUTE: turn off software mute in output");
generic_sendmsg("H RVA off|(mix|radio)|(album|audiophile): set rva mode");
generic_sendmsg("H EQ/E <channel> <band> <value>: set equalizer value for frequency band 0 to 31 on channel %i (left) or %i (right) or %i (both)", MPG123_LEFT, MPG123_RIGHT, MPG123_LR);
generic_sendmsg("H EQFILE <filename>: load EQ settings from a file");
generic_sendmsg("H SHOWEQ: show all equalizer settings (as <channel> <band> <value> lines in a SHOWEQ block (like TAG))");
generic_sendmsg("H SEEK/K <sample>|<+offset>|<-offset>: jump to output sample position <samples> or change position by offset");
generic_sendmsg("H SCAN: scan through the file, building seek index");
generic_sendmsg("H SAMPLE: print out the sample position and total number of samples");
generic_sendmsg("H FORMAT: print out sampling rate in Hz and channel count");
generic_sendmsg("H SEQ <bass> <mid> <treble>: simple eq setting...");
generic_sendmsg("H PITCH <[+|-]value>: adjust playback speed (+0.01 is 1 %% faster)");
generic_sendmsg("H SILENCE: be silent during playback (meaning silence in text form)");
generic_sendmsg("H STATE: Print auxiliary state info in several lines (just try it to see what info is there).");
generic_sendmsg("H TAG/T: Print all available (ID3) tag info, for ID3v2 that gives output of all collected text fields, using the ID3v2.3/4 4-character names. NOTE: ID3v2 data will be deleted on non-forward seeks.");
generic_sendmsg("H The output is multiple lines, begin marked by \"@T {\", end by \"@T }\".");
generic_sendmsg("H ID3v1 data is like in the @I info lines (see below), just with \"@T\" in front.");
generic_sendmsg("H An ID3v2 data field is introduced via ([ ... ] means optional):");
generic_sendmsg("H @T ID3v2.<NAME>[ [lang(<LANG>)] desc(<description>)]:");
generic_sendmsg("H The lines of data follow with \"=\" prefixed:");
generic_sendmsg("H @T =<one line of content in UTF-8 encoding>");
generic_sendmsg("H meaning of the @S stream info:");
generic_sendmsg("H %s", remote_header_help);
generic_sendmsg("H The @I lines after loading a track give some ID3 info, the format:");
generic_sendmsg("H @I ID3:artist album year comment genretext");
generic_sendmsg("H where artist,album and comment are exactly 30 characters each, year is 4 characters, genre text unspecified.");
generic_sendmsg("H You will encounter \"@I ID3.genre:<number>\" and \"@I ID3.track:<number>\".");
generic_sendmsg("H Then, there is an excerpt of ID3v2 info in the structure");
generic_sendmsg("H @I ID3v2.title:Blabla bla Bla");
generic_sendmsg("H for every line of the \"title\" data field. Likewise for other fields (author, album, etc).");
generic_sendmsg("H }");
continue;
}
/* commands with arguments */
cmd = NULL;
arg = NULL;
cmd = strtok(comstr," \t"); /* get the main command */
arg = strtok(NULL,""); /* get the args */
if (cmd && strlen(cmd) && arg && strlen(arg))
{
#ifndef NO_EQUALIZER
/* Simple EQ: SEQ <BASS> <MID> <TREBLE> */
if (!strcasecmp(cmd, "SEQ")) {
double b,m,t;
int cn;
if(sscanf(arg, "%lf %lf %lf", &b, &m, &t) == 3)
{
/* Consider adding mpg123_seq()... but also, on could define a nicer courve for that. */
for(cn=0; cn < 1; ++cn) mpg123_eq(fr, MPG123_LEFT|MPG123_RIGHT, cn, b);
for(cn=1; cn < 2; ++cn) mpg123_eq(fr, MPG123_LEFT|MPG123_RIGHT, cn, m);
for(cn=2; cn < 32; ++cn) mpg123_eq(fr, MPG123_LEFT|MPG123_RIGHT, cn, t);
generic_sendmsg("bass: %f mid: %f treble: %f", b, m, t);
}
else generic_sendmsg("E invalid arguments for SEQ: %s", arg);
continue;
}
/* Equalizer control :) (JMG) */
if (!strcasecmp(cmd, "E") || !strcasecmp(cmd, "EQ")) {
double e; /* ThOr: equalizer is of type real... whatever that is */
int c, v;
/*generic_sendmsg("%s",updown);*/
if(sscanf(arg, "%i %i %lf", &c, &v, &e) == 3)
{
if(mpg123_eq(fr, c, v, e) == MPG123_OK)
generic_sendmsg("%i : %i : %f", c, v, e);
else
generic_sendmsg("E failed to set eq: %s", mpg123_strerror(fr));
}
else generic_sendmsg("E invalid arguments for EQ: %s", arg);
continue;
}
if(!strcasecmp(cmd, "EQFILE"))
{
equalfile = arg;
if(load_equalizer(fr) == 0)
generic_sendmsg("EQFILE done");
else
generic_sendmsg("E failed to parse given eq file");
continue;
}
#endif
/* SEEK to a sample offset */
if(!strcasecmp(cmd, "K") || !strcasecmp(cmd, "SEEK"))
{
off_t soff;
off_t oldpos;
off_t newpos;
char *spos = arg;
int whence = SEEK_SET;
if(mode == MODE_STOPPED)
{
generic_sendmsg("E No track loaded!");
continue;
}
oldpos = mpg123_tell(fr);
soff = (off_t) atobigint(spos);
if(spos[0] == '-' || spos[0] == '+') whence = SEEK_CUR;
if(0 > (soff = mpg123_seek(fr, soff, whence)))
{
generic_sendmsg("E Error while seeking: %s", mpg123_strerror(fr));
mpg123_seek(fr, 0, SEEK_SET);
}
out123_drop(ao);
newpos = mpg123_tell(fr);
if(newpos <= oldpos) mpg123_meta_free(fr);
generic_sendmsg("K %"OFF_P, (off_p)newpos);
continue;
}
/* JUMP */
if (!strcasecmp(cmd, "J") || !strcasecmp(cmd, "JUMP")) {
char *spos;
off_t offset;
off_t oldpos;
double secs;
spos = arg;
if(mode == MODE_STOPPED)
{
generic_sendmsg("E No track loaded!");
continue;
}
oldpos = framenum;
if(spos[strlen(spos)-1] == 's' && sscanf(arg, "%lf", &secs) == 1) offset = mpg123_timeframe(fr, secs);
else offset = atol(spos);
/* totally replaced that stuff - it never fully worked
a bit usure about why +pos -> spos+1 earlier... */
if (spos[0] == '-' || spos[0] == '+') offset += framenum;
if(0 > (framenum = mpg123_seek_frame(fr, offset, SEEK_SET)))
{
generic_sendmsg("E Error while seeking");
mpg123_seek_frame(fr, 0, SEEK_SET);
}
out123_drop(ao);
if(framenum <= oldpos) mpg123_meta_free(fr);
generic_sendmsg("J %d", framenum);
continue;
}
/* VOLUME in percent */
if(!strcasecmp(cmd, "V") || !strcasecmp(cmd, "VOLUME"))
{
double v;
mpg123_volume(fr, atof(arg)/100);
mpg123_getvolume(fr, &v, NULL, NULL); /* Necessary? */
generic_sendmsg("V %f%%", v * 100);
continue;
}
/* PITCH (playback speed) in percent */
if(!strcasecmp(cmd, "PITCH"))
{
double p;
if(sscanf(arg, "%lf", &p) == 1)
{
set_pitch(fr, ao, p);
generic_sendmsg("PITCH %f", param.pitch);
}
else generic_sendmsg("E invalid arguments for PITCH: %s", arg);
continue;
}
/* RVA mode */
if(!strcasecmp(cmd, "RVA"))
{
if(!strcasecmp(arg, "off")) param.rva = MPG123_RVA_OFF;
else if(!strcasecmp(arg, "mix") || !strcasecmp(arg, "radio")) param.rva = MPG123_RVA_MIX;
else if(!strcasecmp(arg, "album") || !strcasecmp(arg, "audiophile")) param.rva = MPG123_RVA_ALBUM;
mpg123_volume_change(fr, 0.);
generic_sendmsg("RVA %s", rva_name[param.rva]);
continue;
}
/* LOAD - actually play */
if (!strcasecmp(cmd, "L") || !strcasecmp(cmd, "LOAD")){ generic_load(fr, arg, MODE_PLAYING); continue; }
if (!strcasecmp(cmd, "LL") || !strcasecmp(cmd, "LOADLIST")){ generic_loadlist(fr, arg); continue; }
/* LOADPAUSED */
if (!strcasecmp(cmd, "LP") || !strcasecmp(cmd, "LOADPAUSED")){ generic_load(fr, arg, MODE_PAUSED); continue; }
/* no command matched */
generic_sendstr(0, "E Unknown command: %s", cmd);
} /* end commands with arguments */
else generic_sendstr( 0, "E Unknown command or no arguments: %s"
, comstr );
} /* end of single command processing */
} /* end of scanning the command buffer */
/*
when last command had no \n... should I discard it?
Ideally, I should remember the part and wait for next
read() to get the rest up to a \n. But that can go
to infinity. Too long commands too quickly are just
bad. Cannot/Won't change that. So, discard the unfinished
command and have fingers crossed that the rest of this
unfinished one qualifies as "unknown".
*/
if(buf[len-1] != 0)
{
// All that jazz because I did not reserve space for a zero.
char *last_command;
size_t last_len = len-(size_t)(next_comstr-buf);
last_command = malloc(last_len+1);
if(last_command)
{
memcpy(last_command, next_comstr, last_len);
last_command[last_len] = 0;
generic_sendstr(0, "E Unfinished command: %s", last_command);
free(last_command);
}
else
generic_sendmsg("E Unfinished command: <DOOM>");
}
} /* end command reading & processing */
} /* end main (alive) loop */
debug("going to end");
/* quit gracefully */
debug("closing control");
#ifdef FIFO
#if WANT_WIN32_FIFO
win32_fifo_close();
#else
close(control_file); /* be it FIFO or STDIN */
if(param.fifo) unlink(param.fifo);
#endif /* WANT_WIN32_FIFO */
#endif
debug("control_generic returning");
return 0;
}
/* EOF */

Some files were not shown because too many files have changed in this diff Show More