Compare commits

...

No commits in common. "squeezelite-rs" and "master" have entirely different histories.

25 changed files with 628 additions and 17326 deletions

1
.gitignore vendored
View File

@ -78,4 +78,3 @@ fabric.properties
# Android studio 3.1+ serialized cache file # Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser .idea/caches/build_file_checksums.ser

View File

@ -1,44 +0,0 @@
[workspace]
members = [
]
[package]
name = "sqeezers"
authors = ["C2Rust"]
version = "0.0.0"
publish = false
edition = "2018"
autobins = false
[lib]
name = "sqeezers"
path = "lib.rs"
crate-type = ["staticlib", "rlib"]
[dependencies]
c2rust-bitfields = "0.3"
c2rust-asm-casts = "0.1"
libc = "0.2"
[dependencies.c2rust-xcheck-plugin]
path = "../c2rust/cross-checks/rust-checks/rustc-plugin"
version = "*"
[dependencies.c2rust-xcheck-derive]
path = "../c2rust/cross-checks/rust-checks/derive-macros"
version = "*"
[dependencies.c2rust-xcheck-runtime]
path = "../c2rust/cross-checks/rust-checks/runtime"
version = "*"
features = ["libc-hash", "fixed-length-array-hash"]
[dependencies.c2rust-xcheck-backend-zstd-logging]
path = "../c2rust/cross-checks/rust-checks/backends/zstd-logging"
version = "*"
[dependencies.c2rust-ast-printer]
path = "../c2rust/cross-checks/rust-checks/"
version = "*"

626
LICENSE Normal file
View File

@ -0,0 +1,626 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright © 2007 Free Software Foundation, Inc. <http s ://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies of this license
document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for software and
other kinds of works.
The licenses for most software and other practical works are designed to take
away your freedom to share and change the works. By contrast, the GNU General
Public License is intended to guarantee your freedom to share and change all
versions of a program--to make sure it remains free software for all its users.
We, the Free Software Foundation, use the GNU General Public License for most
of our software; it applies also to any other work released this way by its
authors. 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 them 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 prevent others from denying you these rights
or asking you to surrender the rights. Therefore, you have certain responsibilities
if you distribute copies of the software, or if you modify it: responsibilities
to respect the freedom of others.
For example, if you distribute copies of such a program, whether gratis or
for a fee, you must pass on to the recipients the same freedoms that you received.
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.
Developers that use the GNU GPL protect your rights with two steps: (1) assert
copyright on the software, and (2) offer you this License giving you legal
permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains that
there is no warranty for this free software. For both users' and authors'
sake, the GPL requires that modified versions be marked as changed, so that
their problems will not be attributed erroneously to authors of previous versions.
Some devices are designed to deny users access to install or run modified
versions of the software inside them, although the manufacturer can do so.
This is fundamentally incompatible with the aim of protecting users' freedom
to change the software. The systematic pattern of such abuse occurs in the
area of products for individuals to use, which is precisely where it is most
unacceptable. Therefore, we have designed this version of the GPL to prohibit
the practice for those products. If such problems arise substantially in other
domains, we stand ready to extend this provision to those domains in future
versions of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents. States
should not allow patents to restrict development and use of software on general-purpose
computers, but in those that do, we wish to avoid the special danger that
patents applied to a free program could make it effectively proprietary. To
prevent this, the GPL assures that patents cannot be used to render the program
non-free.
The precise terms and conditions for copying, distribution and modification
follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of works,
such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this License.
Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals
or organizations.
To "modify" a work means to copy from or adapt all or part of the work in
a fashion requiring copyright permission, other than the making of an exact
copy. The resulting work is called a "modified version" of the earlier work
or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based on the
Program.
To "propagate" a work means to do anything with it that, without permission,
would make you directly or secondarily liable for infringement under applicable
copyright law, except executing it on a computer or modifying a private copy.
Propagation includes copying, distribution (with or without modification),
making available to the public, and in some countries other activities as
well.
To "convey" a work means any kind of propagation that enables other parties
to make or receive copies. Mere interaction with a user through a computer
network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices" to the
extent that it includes a convenient and prominently visible feature that
(1) displays an appropriate copyright notice, and (2) tells the user that
there is no warranty for the work (except to the extent that warranties are
provided), that licensees may convey the work under this License, and how
to view a copy of this License. If the interface presents a list of user commands
or options, such as a menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work for making
modifications to it. "Object code" means any non-source form of a work.
A "Standard Interface" means an interface that either is an official standard
defined by a recognized standards body, or, in the case of interfaces specified
for a particular programming language, one that is widely used among developers
working in that language.
The "System Libraries" of an executable work include anything, other than
the work as a whole, that (a) is included in the normal form of packaging
a Major Component, but which is not part of that Major Component, and (b)
serves only to enable use of the work with that Major Component, or to implement
a Standard Interface for which an implementation is available to the public
in source code form. A "Major Component", in this context, means a major essential
component (kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to produce
the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all the source
code needed to generate, install, and (for an executable work) run the object
code and to modify the work, including scripts to control those activities.
However, it does not include the work's System Libraries, or general-purpose
tools or generally available free programs which are used unmodified in performing
those activities but which are not part of the work. For example, Corresponding
Source includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically linked
subprograms that the work is specifically designed to require, such as by
intimate data communication or control flow between those subprograms and
other parts of the work.
The Corresponding Source need not include anything that users can regenerate
automatically from other parts of the Corresponding Source.
The Corresponding Source for a work in source code form is that same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of copyright
on the Program, and are irrevocable provided the stated conditions are met.
This License explicitly affirms your unlimited permission to run the unmodified
Program. The output from running a covered work is covered by this License
only if the output, given its content, constitutes a covered work. This License
acknowledges your rights of fair use or other equivalent, as provided by copyright
law.
You may make, run and propagate covered works that you do not convey, without
conditions so long as your license otherwise remains in force. You may convey
covered works to others for the sole purpose of having them make modifications
exclusively for you, or provide you with facilities for running those works,
provided that you comply with the terms of this License in conveying all material
for which you do not control copyright. Those thus making or running the covered
works for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of your copyrighted
material outside their relationship with you.
Conveying under any other circumstances is permitted solely under the conditions
stated below. Sublicensing is not allowed; section 10 makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological measure
under any applicable law fulfilling obligations under article 11 of the WIPO
copyright treaty adopted on 20 December 1996, or similar laws prohibiting
or restricting circumvention of such measures.
When you convey a covered work, you waive any legal power to forbid circumvention
of technological measures to the extent such circumvention is effected by
exercising rights under this License with respect to the covered work, and
you disclaim any intention to limit operation or modification of the work
as a means of enforcing, against the work's users, your or third parties'
legal rights to forbid circumvention of technological measures.
4. Conveying Verbatim Copies.
You may convey 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; keep intact all notices stating
that this License and any non-permissive terms added in accord with section
7 apply to the code; keep intact all notices of the absence of any warranty;
and give all recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey, and you
may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to produce
it from the Program, in the form of source code under the terms of section
4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified it, and
giving a relevant date.
b) The work must carry prominent notices stating that it is released under
this License and any conditions added under section 7. This requirement modifies
the requirement in section 4 to "keep intact all notices".
c) You must license the entire work, as a whole, under this License to anyone
who comes into possession of a copy. This License will therefore apply, along
with any applicable section 7 additional terms, to the whole of the work,
and all its parts, regardless of how they are packaged. This License gives
no permission to license the work in any other way, but it does not invalidate
such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display Appropriate
Legal Notices; however, if the Program has interactive interfaces that do
not display Appropriate Legal Notices, your work need not make them do so.
A compilation of a covered work with other separate and independent works,
which are not by their nature extensions of the covered work, and which are
not combined with it such as to form a larger program, in or on a volume of
a storage or distribution medium, is called an "aggregate" if the compilation
and its resulting copyright are not used to limit the access or legal rights
of the compilation's users beyond what the individual works permit. Inclusion
of a covered work in an aggregate does not cause this License to apply to
the other parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms of sections
4 and 5, provided that you also convey the machine-readable Corresponding
Source under the terms of this License, in one of these ways:
a) Convey the object code in, or embodied in, a physical product (including
a physical distribution medium), accompanied by the Corresponding Source fixed
on a durable physical medium customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product (including
a physical distribution medium), accompanied by a written offer, valid for
at least three years and valid for as long as you offer spare parts or customer
support for that product model, to give anyone who possesses the object code
either (1) a copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical medium customarily
used for software interchange, for a price no more than your reasonable cost
of physically performing this conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the written
offer to provide the Corresponding Source. This alternative is allowed only
occasionally and noncommercially, and only if you received the object code
with such an offer, in accord with subsection 6b.
d) Convey the object code by offering access from a designated place (gratis
or for a charge), and offer equivalent access to the Corresponding Source
in the same way through the same place at no further charge. You need not
require recipients to copy the Corresponding Source along with the object
code. If the place to copy the object code is a network server, the Corresponding
Source may be on a different server (operated by you or a third party) that
supports equivalent copying facilities, provided you maintain clear directions
next to the object code saying where to find the Corresponding Source. Regardless
of what server hosts the Corresponding Source, you remain obligated to ensure
that it is available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided you inform
other peers where the object code and Corresponding Source of the work are
being offered to the general public at no charge under subsection 6d.
A separable portion of the object code, whose source code is excluded from
the Corresponding Source as a System Library, need not be included in conveying
the object code work.
A "User Product" is either (1) a "consumer product", which means any tangible
personal property which is normally used for personal, family, or household
purposes, or (2) anything designed or sold for incorporation into a dwelling.
In determining whether a product is a consumer product, doubtful cases shall
be resolved in favor of coverage. For a particular product received by a particular
user, "normally used" refers to a typical or common use of that class of product,
regardless of the status of the particular user or of the way in which the
particular user actually uses, or expects or is expected to use, the product.
A product is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent the
only significant mode of use of the product.
"Installation Information" for a User Product means any methods, procedures,
authorization keys, or other information required to install and execute modified
versions of a covered work in that User Product from a modified version of
its Corresponding Source. The information must suffice to ensure that the
continued functioning of the modified object code is in no case prevented
or interfered with solely because modification has been made.
If you convey an object code work under this section in, or with, or specifically
for use in, a User Product, and the conveying occurs as part of a transaction
in which the right of possession and use of the User Product is transferred
to the recipient in perpetuity or for a fixed term (regardless of how the
transaction is characterized), the Corresponding Source conveyed under this
section must be accompanied by the Installation Information. But this requirement
does not apply if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has been installed
in ROM).
The requirement to provide Installation Information does not include a requirement
to continue to provide support service, warranty, or updates for a work that
has been modified or installed by the recipient, or for the User Product in
which it has been modified or installed. Access to a network may be denied
when the modification itself materially and adversely affects the operation
of the network or violates the rules and protocols for communication across
the network.
Corresponding Source conveyed, and Installation Information provided, in accord
with this section must be in a format that is publicly documented (and with
an implementation available to the public in source code form), and must require
no special password or key for unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this License
by making exceptions from one or more of its conditions. Additional permissions
that are applicable to the entire Program shall be treated as though they
were included in this License, to the extent that they are valid under applicable
law. If additional permissions apply only to part of the Program, that part
may be used separately under those permissions, but the entire Program remains
governed by this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option remove any
additional permissions from that copy, or from any part of it. (Additional
permissions may be written to require their own removal in certain cases when
you modify the work.) You may place additional permissions on material, added
by you to a covered work, for which you have or can give appropriate copyright
permission.
Notwithstanding any other provision of this License, for material you add
to a covered work, you may (if authorized by the copyright holders of that
material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the terms of
sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or author
attributions in that material or in the Appropriate Legal Notices displayed
by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or requiring
that modified versions of such material be marked in reasonable ways as different
from the original version; or
d) Limiting the use for publicity purposes of names of licensors or authors
of the material; or
e) Declining to grant rights under trademark law for use of some trade names,
trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that material by
anyone who conveys the material (or modified versions of it) with contractual
assumptions of liability to the recipient, for any liability that these contractual
assumptions directly impose on those licensors and authors.
All other non-permissive additional terms are considered "further restrictions"
within the meaning of section 10. If the Program as you received it, or any
part of it, contains a notice stating that it is governed by this License
along with a term that is a further restriction, you may remove that term.
If a license document contains a further restriction but permits relicensing
or conveying under this License, you may add to a covered work material governed
by the terms of that license document, provided that the further restriction
does not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you must place,
in the relevant source files, a statement of the additional terms that apply
to those files, or a notice indicating where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the form
of a separately written license, or stated as exceptions; the above requirements
apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly provided
under this License. Any attempt otherwise to propagate or modify it is void,
and will automatically terminate your rights under this License (including
any patent licenses granted under the third paragraph of section 11).
However, if you cease all violation of this License, then your license from
a particular copyright holder is reinstated (a) provisionally, unless and
until the copyright holder explicitly and finally terminates your license,
and (b) permanently, if the copyright holder fails to notify you of the violation
by some reasonable means prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is reinstated permanently
if the copyright holder notifies you of the violation by some reasonable means,
this is the first time you have received notice of violation of this License
(for any work) from that copyright holder, and you cure the violation prior
to 30 days after your receipt of the notice.
Termination of your rights under this section does not terminate the licenses
of parties who have received copies or rights from you under this License.
If your rights have been terminated and not permanently reinstated, you do
not qualify to receive new licenses for the same material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or run a copy
of the Program. Ancillary propagation of a covered work occurring solely as
a consequence of using peer-to-peer transmission to receive a copy likewise
does not require acceptance. However, nothing other than this License grants
you permission to propagate or modify any covered work. These actions infringe
copyright if you do not accept this License. Therefore, by modifying or propagating
a covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically receives
a license from the original licensors, to run, modify and propagate that work,
subject to this License. You are not responsible for enforcing compliance
by third parties with this License.
An "entity transaction" is a transaction transferring control of an organization,
or substantially all assets of one, or subdividing an organization, or merging
organizations. If propagation of a covered work results from an entity transaction,
each party to that transaction who receives a copy of the work also receives
whatever licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the Corresponding
Source of the work from the predecessor in interest, if the predecessor has
it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the rights
granted or affirmed under this License. For example, you may not impose a
license fee, royalty, or other charge for exercise of rights granted under
this License, and you may not initiate litigation (including a cross-claim
or counterclaim in a lawsuit) alleging that any patent claim is infringed
by making, using, selling, offering for sale, or importing the Program or
any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this License
of the Program or a work on which the Program is based. The work thus licensed
is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims owned or controlled
by the contributor, whether already acquired or hereafter acquired, that would
be infringed by some manner, permitted by this License, of making, using,
or selling its contributor version, but do not include claims that would be
infringed only as a consequence of further modification of the contributor
version. For purposes of this definition, "control" includes the right to
grant patent sublicenses in a manner consistent with the requirements of this
License.
Each contributor grants you a non-exclusive, worldwide, royalty-free patent
license under the contributor's essential patent claims, to make, use, sell,
offer for sale, import and otherwise run, modify and propagate the contents
of its contributor version.
In the following three paragraphs, a "patent license" is any express agreement
or commitment, however denominated, not to enforce a patent (such as an express
permission to practice a patent or covenant not to sue for patent infringement).
To "grant" such a patent license to a party means to make such an agreement
or commitment not to enforce a patent against the party.
If you convey a covered work, knowingly relying on a patent license, and the
Corresponding Source of the work is not available for anyone to copy, free
of charge and under the terms of this License, through a publicly available
network server or other readily accessible means, then you must either (1)
cause the Corresponding Source to be so available, or (2) arrange to deprive
yourself of the benefit of the patent license for this particular work, or
(3) arrange, in a manner consistent with the requirements of this License,
to extend the patent license to downstream recipients. "Knowingly relying"
means you have actual knowledge that, but for the patent license, your conveying
the covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that country
that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or arrangement,
you convey, or propagate by procuring conveyance of, a covered work, and grant
a patent license to some of the parties receiving the covered work authorizing
them to use, propagate, modify or convey a specific copy of the covered work,
then the patent license you grant is automatically extended to all recipients
of the covered work and works based on it.
A patent license is "discriminatory" if it does not include within the scope
of its coverage, prohibits the exercise of, or is conditioned on the non-exercise
of one or more of the rights that are specifically granted under this License.
You may not convey a covered work if you are a party to an arrangement with
a third party that is in the business of distributing software, under which
you make payment to the third party based on the extent of your activity of
conveying the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory patent
license (a) in connection with copies of the covered work conveyed by you
(or copies made from those copies), or (b) primarily for and in connection
with specific products or compilations that contain the covered work, unless
you entered into that arrangement, or that patent license was granted, prior
to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting any implied
license or other defenses to infringement that may otherwise be available
to you under applicable patent law.
12. No Surrender of Others' Freedom.
If 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 convey a covered work so as
to satisfy simultaneously your obligations under this License and any other
pertinent obligations, then as a consequence you may not convey it at all.
For example, if you agree to terms that obligate you to collect a royalty
for further conveying from those to whom you convey the Program, the only
way you could satisfy both those terms and this License would be to refrain
entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have permission to
link or combine any covered work with a work licensed under version 3 of the
GNU Affero General Public License into a single combined work, and to convey
the resulting work. The terms of this License will continue to apply to the
part which is the covered work, but the special requirements of the GNU Affero
General Public License, section 13, concerning interaction through a network
will apply to the combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of the
GNU 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
that a certain numbered version of the GNU General Public License "or any
later version" applies to it, you have the option of following the terms and
conditions either of that numbered version or of any later version published
by the Free Software Foundation. If the Program does not specify a version
number of the GNU General Public License, you may choose any version ever
published by the Free Software Foundation.
If the Program specifies that a proxy can decide which future versions of
the GNU General Public License can be used, that proxy's public statement
of acceptance of a version permanently authorizes you to choose that version
for the Program.
Later license versions may give you additional or different permissions. However,
no additional obligations are imposed on any author or copyright holder as
a result of your choosing to follow a later version.
15. Disclaimer of Warranty.
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.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL
ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 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.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided above cannot
be given local legal effect according to their terms, reviewing courts shall
apply local law that most closely approximates an absolute waiver of all civil
liability in connection with the Program, unless a warranty or assumption
of liability accompanies a copy of the Program in return for a fee. END OF
TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest possible
use to the public, the best way to achieve this is to make it free software
which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest to attach
them to the start of each source file to most effectively state the exclusion
of warranty; and each file should have at least the "copyright" line and a
pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http s ://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short notice like
this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it under certain
conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands might
be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary. For
more information on this, and how to apply and follow the GNU GPL, see <http
s ://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Lesser General Public
License instead of this License. But first, please read <http s ://www.gnu.org/
licenses /why-not-lgpl.html>.

View File

@ -1,33 +1,3 @@
Squeezelite v1.9.x, Copyright 2012-2015 Adrian Smith, 2015-2019 Ralph Irving. # squeezers
See the squeezelite manpage for usage details. Writing a squeezebox / slimserver-client in Rust
https://ralph-irving.github.io/squeezelite.html
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 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Contains dsd2pcm library Copyright 2009, 2011 Sebastian Gesemann which
is subject to its own license.
Contains the Daphile Project full dsd patch Copyright 2013-2017 Daphile,
which is subject to its own license.
Option to allow server side upsampling for PCM streams (-W) from
squeezelite-R2 (c) Marco Curti 2015, marcoc1712@gmail.com.
RaspberryPi minimal GPIO Interface
http://abyz.me.uk/rpi/pigpio/examples.html#Misc_minimal_gpio.
This software uses libraries from the FFmpeg project under
the LGPLv2.1 and its source can be downloaded from
https://sourceforge.net/projects/lmsclients/files/source/

View File

@ -1,13 +0,0 @@
#[cfg(all(unix, not(target_os = "macos")))]
fn main() {
// add unix dependencies below
// println!("cargo:rustc-flags=-l readline");
}
#[cfg(target_os = "macos")]
fn main() {
// add macos dependencies below
// println!("cargo:rustc-flags=-l edit");
}

53
lib.rs
View File

@ -1,53 +0,0 @@
#![allow(dead_code)]
#![allow(mutable_transmutes)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
#![allow(non_upper_case_globals)]
#![allow(unused_assignments)]
#![allow(unused_mut)]
#![cross_check(yes)]
#![feature(asm)]
#![feature(c_variadic)]
#![feature(const_raw_ptr_to_usize_cast)]
#![feature(extern_types)]
#![feature(main)]
#![feature(plugin)]
#![feature(ptr_wrapping_offset_from)]
#![feature(register_tool)]
#![register_tool(c2rust)]
#[macro_use]
extern crate c2rust_bitfields;#[macro_use]
extern crate c2rust_asm_casts;
extern crate libc;
#![plugin(c2rust_xcheck_plugin())]
#[macro_use] extern crate c2rust_xcheck_derive;
#[macro_use] extern crate c2rust_xcheck_runtime;
extern crate c2rust_xcheck_backend_zstd_logging;
#[global_allocator]
static C2RUST_ALLOC: ::std::alloc::System = ::std::alloc::System;
pub mod src {
pub mod buffer;
pub mod decode;
pub mod faad;
pub mod flac;
pub mod mad;
pub mod main;
pub mod mpg;
pub mod output;
pub mod output_alsa;
pub mod output_pa;
pub mod output_pack;
pub mod output_pulse;
pub mod output_stdout;
pub mod pcm;
pub mod slimproto;
pub mod stream;
pub mod utils;
pub mod vorbis;
} // mod src

View File

@ -1 +0,0 @@
nightly-2019-12-05

View File

@ -1,253 +0,0 @@
use ::libc;
extern "C" {
#[no_mangle]
fn malloc(_: libc::c_ulong) -> *mut libc::c_void;
#[no_mangle]
fn free(__ptr: *mut libc::c_void);
#[no_mangle]
fn pthread_mutex_init(__mutex: *mut pthread_mutex_t,
__mutexattr: *const pthread_mutexattr_t)
-> libc::c_int;
#[no_mangle]
fn pthread_mutex_destroy(__mutex: *mut pthread_mutex_t) -> libc::c_int;
#[no_mangle]
fn pthread_mutex_lock(__mutex: *mut pthread_mutex_t) -> libc::c_int;
#[no_mangle]
fn pthread_mutex_unlock(__mutex: *mut pthread_mutex_t) -> libc::c_int;
#[no_mangle]
fn pthread_mutexattr_init(__attr: *mut pthread_mutexattr_t)
-> libc::c_int;
#[no_mangle]
fn pthread_mutexattr_destroy(__attr: *mut pthread_mutexattr_t)
-> libc::c_int;
#[no_mangle]
fn pthread_mutexattr_setprotocol(__attr: *mut pthread_mutexattr_t,
__protocol: libc::c_int) -> libc::c_int;
}
pub type size_t = libc::c_ulong;
pub type __uint8_t = libc::c_uchar;
pub type u_int8_t = __uint8_t;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct __pthread_internal_list {
pub __prev: *mut __pthread_internal_list,
pub __next: *mut __pthread_internal_list,
}
pub type __pthread_list_t = __pthread_internal_list;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct __pthread_mutex_s {
pub __lock: libc::c_int,
pub __count: libc::c_uint,
pub __owner: libc::c_int,
pub __nusers: libc::c_uint,
pub __kind: libc::c_int,
pub __spins: libc::c_short,
pub __elision: libc::c_short,
pub __list: __pthread_list_t,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub union pthread_mutexattr_t {
pub __size: [libc::c_char; 4],
pub __align: libc::c_int,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub union pthread_mutex_t {
pub __data: __pthread_mutex_s,
pub __size: [libc::c_char; 40],
pub __align: libc::c_long,
}
pub type C2RustUnnamed = libc::c_uint;
pub const PTHREAD_PRIO_PROTECT: C2RustUnnamed = 2;
pub const PTHREAD_PRIO_INHERIT: C2RustUnnamed = 1;
pub const PTHREAD_PRIO_NONE: C2RustUnnamed = 0;
pub type u8_t = u_int8_t;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct buffer {
pub buf: *mut u8_t,
pub readp: *mut u8_t,
pub writep: *mut u8_t,
pub wrap: *mut u8_t,
pub size: size_t,
pub base_size: size_t,
pub mutex: pthread_mutex_t,
}
/*
* Squeezelite - lightweight headless squeezebox emulator
*
* (c) Adrian Smith 2012-2015, triode1@btinternet.com
* Ralph Irving 2015-2017, ralph_irving@hotmail.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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
// fifo bufffers
// _* called with muxtex locked
#[inline]
unsafe extern "C" fn _buf_used(mut buf: *mut buffer) -> libc::c_uint {
return if (*buf).writep >= (*buf).readp {
(*buf).writep.wrapping_offset_from((*buf).readp) as
libc::c_long as libc::c_ulong
} else {
(*buf).size.wrapping_sub((*buf).readp.wrapping_offset_from((*buf).writep)
as libc::c_long as libc::c_ulong)
} as libc::c_uint;
}
#[no_mangle]
pub unsafe extern "C" fn _buf_space(mut buf: *mut buffer) -> libc::c_uint {
return (*buf).size.wrapping_sub(_buf_used(buf) as
libc::c_ulong).wrapping_sub(1 as
libc::c_int
as
libc::c_ulong)
as libc::c_uint;
// reduce by one as full same as empty otherwise
}
#[no_mangle]
pub unsafe extern "C" fn _buf_cont_read(mut buf: *mut buffer)
-> libc::c_uint {
return if (*buf).writep >= (*buf).readp {
(*buf).writep.wrapping_offset_from((*buf).readp) as
libc::c_long
} else {
(*buf).wrap.wrapping_offset_from((*buf).readp) as libc::c_long
} as libc::c_uint;
}
#[no_mangle]
pub unsafe extern "C" fn _buf_cont_write(mut buf: *mut buffer)
-> libc::c_uint {
return if (*buf).writep >= (*buf).readp {
(*buf).wrap.wrapping_offset_from((*buf).writep) as libc::c_long
} else {
(*buf).readp.wrapping_offset_from((*buf).writep) as
libc::c_long
} as libc::c_uint;
}
#[no_mangle]
pub unsafe extern "C" fn _buf_inc_readp(mut buf: *mut buffer,
mut by: libc::c_uint) {
(*buf).readp = (*buf).readp.offset(by as isize);
if (*buf).readp >= (*buf).wrap {
(*buf).readp = (*buf).readp.offset(-((*buf).size as isize))
};
}
#[no_mangle]
pub unsafe extern "C" fn _buf_inc_writep(mut buf: *mut buffer,
mut by: libc::c_uint) {
(*buf).writep = (*buf).writep.offset(by as isize);
if (*buf).writep >= (*buf).wrap {
(*buf).writep = (*buf).writep.offset(-((*buf).size as isize))
};
}
#[no_mangle]
pub unsafe extern "C" fn buf_flush(mut buf: *mut buffer) {
pthread_mutex_lock(&mut (*buf).mutex);
(*buf).readp = (*buf).buf;
(*buf).writep = (*buf).buf;
pthread_mutex_unlock(&mut (*buf).mutex);
}
// adjust buffer to multiple of mod bytes so reading in multiple always wraps on frame boundary
#[no_mangle]
pub unsafe extern "C" fn buf_adjust(mut buf: *mut buffer, mut mod_0: size_t) {
let mut size: size_t = 0;
pthread_mutex_lock(&mut (*buf).mutex);
size =
((*buf).base_size.wrapping_div(mod_0) as libc::c_uint as
libc::c_ulong).wrapping_mul(mod_0);
(*buf).readp = (*buf).buf;
(*buf).writep = (*buf).buf;
(*buf).wrap = (*buf).buf.offset(size as isize);
(*buf).size = size;
pthread_mutex_unlock(&mut (*buf).mutex);
}
// called with mutex locked to resize, does not retain contents, reverts to original size if fails
#[no_mangle]
pub unsafe extern "C" fn _buf_resize(mut buf: *mut buffer, mut size: size_t) {
free((*buf).buf as *mut libc::c_void);
(*buf).buf = malloc(size) as *mut u8_t;
if (*buf).buf.is_null() {
size = (*buf).size;
(*buf).buf = malloc(size) as *mut u8_t;
if (*buf).buf.is_null() { size = 0 as libc::c_int as size_t }
}
(*buf).readp = (*buf).buf;
(*buf).writep = (*buf).buf;
(*buf).wrap = (*buf).buf.offset(size as isize);
(*buf).size = size;
(*buf).base_size = size;
}
#[no_mangle]
pub unsafe extern "C" fn buf_init(mut buf: *mut buffer, mut size: size_t) {
(*buf).buf = malloc(size) as *mut u8_t;
(*buf).readp = (*buf).buf;
(*buf).writep = (*buf).buf;
(*buf).wrap = (*buf).buf.offset(size as isize);
(*buf).size = size;
(*buf).base_size = size;
let mut attr: pthread_mutexattr_t = pthread_mutexattr_t{__size: [0; 4],};
pthread_mutexattr_init(&mut attr);
pthread_mutexattr_setprotocol(&mut attr,
PTHREAD_PRIO_INHERIT as libc::c_int);
pthread_mutex_init(&mut (*buf).mutex, &mut attr);
pthread_mutexattr_destroy(&mut attr);
}
/*
* Squeezelite - lightweight headless squeezebox emulator
*
* (c) Adrian Smith 2012-2015, triode1@btinternet.com
* Ralph Irving 2015-2017, ralph_irving@hotmail.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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additions (c) Paul Hermann, 2015-2017 under the same license terms
* -Control of Raspberry pi GPIO for amplifier power
* -Launch script on power status change from LMS
*/
// make may define: PORTAUDIO, SELFPIPE, RESAMPLE, RESAMPLE_MP, VISEXPORT, GPIO, IR, DSD, LINKALL to influence build
// build detection
// dynamically loaded libraries at run time
// !LINKALL
// config options
// do not reduce as icy-meta max is 4080
/* SUN */
/* SUN */
// printf/scanf formats for u64_t
// logging
// utils.c (non logging)
// buffer.c
// _* called with mutex locked
#[no_mangle]
pub unsafe extern "C" fn buf_destroy(mut buf: *mut buffer) {
if !(*buf).buf.is_null() {
free((*buf).buf as *mut libc::c_void);
(*buf).buf = 0 as *mut u8_t;
(*buf).size = 0 as libc::c_int as size_t;
(*buf).base_size = 0 as libc::c_int as size_t;
pthread_mutex_destroy(&mut (*buf).mutex);
};
}

View File

@ -1,729 +0,0 @@
use ::libc;
extern "C" {
#[no_mangle]
fn usleep(__useconds: __useconds_t) -> libc::c_int;
#[no_mangle]
fn pthread_attr_destroy(__attr: *mut pthread_attr_t) -> libc::c_int;
#[no_mangle]
fn strstr(_: *const libc::c_char, _: *const libc::c_char)
-> *mut libc::c_char;
#[no_mangle]
fn pthread_create(__newthread: *mut pthread_t,
__attr: *const pthread_attr_t,
__start_routine:
Option<unsafe extern "C" fn(_: *mut libc::c_void)
-> *mut libc::c_void>,
__arg: *mut libc::c_void) -> libc::c_int;
#[no_mangle]
fn pthread_join(__th: pthread_t, __thread_return: *mut *mut libc::c_void)
-> libc::c_int;
#[no_mangle]
fn pthread_attr_init(__attr: *mut pthread_attr_t) -> libc::c_int;
#[no_mangle]
fn register_faad() -> *mut codec;
#[no_mangle]
fn register_vorbis() -> *mut codec;
#[no_mangle]
fn register_flac() -> *mut codec;
#[no_mangle]
fn register_pcm() -> *mut codec;
#[no_mangle]
fn register_mad() -> *mut codec;
#[no_mangle]
fn register_mpg() -> *mut codec;
#[no_mangle]
fn _checkfade(_: bool);
#[no_mangle]
fn wake_controller();
#[no_mangle]
fn _buf_space(buf: *mut buffer) -> libc::c_uint;
#[no_mangle]
fn _buf_used(buf: *mut buffer) -> libc::c_uint;
#[no_mangle]
fn logprint(fmt: *const libc::c_char, _: ...);
#[no_mangle]
fn logtime() -> *const libc::c_char;
#[no_mangle]
fn pthread_attr_setstacksize(__attr: *mut pthread_attr_t,
__stacksize: size_t) -> libc::c_int;
#[no_mangle]
fn pthread_mutex_unlock(__mutex: *mut pthread_mutex_t) -> libc::c_int;
#[no_mangle]
fn pthread_mutex_lock(__mutex: *mut pthread_mutex_t) -> libc::c_int;
#[no_mangle]
fn pthread_mutex_destroy(__mutex: *mut pthread_mutex_t) -> libc::c_int;
#[no_mangle]
fn pthread_mutex_init(__mutex: *mut pthread_mutex_t,
__mutexattr: *const pthread_mutexattr_t)
-> libc::c_int;
#[no_mangle]
static mut streambuf: *mut buffer;
#[no_mangle]
static mut outputbuf: *mut buffer;
#[no_mangle]
static mut stream: streamstate;
#[no_mangle]
static mut output: outputstate;
}
pub type size_t = libc::c_ulong;
pub type __uint8_t = libc::c_uchar;
pub type __int32_t = libc::c_int;
pub type __uint32_t = libc::c_uint;
pub type __uint64_t = libc::c_ulong;
pub type __useconds_t = libc::c_uint;
pub type int32_t = __int32_t;
pub type u_int8_t = __uint8_t;
pub type u_int32_t = __uint32_t;
pub type u_int64_t = __uint64_t;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct __pthread_internal_list {
pub __prev: *mut __pthread_internal_list,
pub __next: *mut __pthread_internal_list,
}
pub type __pthread_list_t = __pthread_internal_list;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct __pthread_mutex_s {
pub __lock: libc::c_int,
pub __count: libc::c_uint,
pub __owner: libc::c_int,
pub __nusers: libc::c_uint,
pub __kind: libc::c_int,
pub __spins: libc::c_short,
pub __elision: libc::c_short,
pub __list: __pthread_list_t,
}
pub type pthread_t = libc::c_ulong;
#[derive(Copy, Clone)]
#[repr(C)]
pub union pthread_mutexattr_t {
pub __size: [libc::c_char; 4],
pub __align: libc::c_int,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub union pthread_attr_t {
pub __size: [libc::c_char; 56],
pub __align: libc::c_long,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub union pthread_mutex_t {
pub __data: __pthread_mutex_s,
pub __size: [libc::c_char; 40],
pub __align: libc::c_long,
}
pub type u8_t = u_int8_t;
pub type u32_t = u_int32_t;
pub type u64_t = u_int64_t;
pub type s32_t = int32_t;
pub type frames_t = u32_t;
pub type log_level = libc::c_uint;
pub const lSDEBUG: log_level = 4;
pub const lDEBUG: log_level = 3;
pub const lINFO: log_level = 2;
pub const lWARN: log_level = 1;
pub const lERROR: log_level = 0;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct buffer {
pub buf: *mut u8_t,
pub readp: *mut u8_t,
pub writep: *mut u8_t,
pub wrap: *mut u8_t,
pub size: size_t,
pub base_size: size_t,
pub mutex: pthread_mutex_t,
}
pub type stream_state = libc::c_uint;
pub const RECV_HEADERS: stream_state = 7;
pub const SEND_HEADERS: stream_state = 6;
pub const STREAMING_HTTP: stream_state = 5;
pub const STREAMING_FILE: stream_state = 4;
pub const STREAMING_BUFFERING: stream_state = 3;
pub const STREAMING_WAIT: stream_state = 2;
pub const DISCONNECT: stream_state = 1;
pub const STOPPED: stream_state = 0;
pub type disconnect_code = libc::c_uint;
pub const TIMEOUT: disconnect_code = 4;
pub const UNREACHABLE: disconnect_code = 3;
pub const REMOTE_DISCONNECT: disconnect_code = 2;
pub const LOCAL_DISCONNECT: disconnect_code = 1;
pub const DISCONNECT_OK: disconnect_code = 0;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct streamstate {
pub state: stream_state,
pub disconnect: disconnect_code,
pub header: *mut libc::c_char,
pub header_len: size_t,
pub sent_headers: bool,
pub cont_wait: bool,
pub bytes: u64_t,
pub threshold: libc::c_uint,
pub meta_interval: u32_t,
pub meta_next: u32_t,
pub meta_left: u32_t,
pub meta_send: bool,
}
pub type decode_state = libc::c_uint;
pub const DECODE_ERROR: decode_state = 4;
pub const DECODE_COMPLETE: decode_state = 3;
pub const DECODE_RUNNING: decode_state = 2;
pub const DECODE_READY: decode_state = 1;
pub const DECODE_STOPPED: decode_state = 0;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct decodestate {
pub state: decode_state,
pub new_stream: bool,
pub mutex: pthread_mutex_t,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct codec {
pub id: libc::c_char,
pub types: *mut libc::c_char,
pub min_read_bytes: libc::c_uint,
pub min_space: libc::c_uint,
pub open: Option<unsafe extern "C" fn(_: u8_t, _: u8_t, _: u8_t, _: u8_t)
-> ()>,
pub close: Option<unsafe extern "C" fn() -> ()>,
pub decode: Option<unsafe extern "C" fn() -> decode_state>,
}
pub type fade_mode = libc::c_uint;
pub const FADE_INOUT: fade_mode = 4;
pub const FADE_OUT: fade_mode = 3;
pub const FADE_IN: fade_mode = 2;
pub const FADE_CROSSFADE: fade_mode = 1;
pub const FADE_NONE: fade_mode = 0;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct outputstate {
pub state: output_state,
pub format: output_format,
pub device: *const libc::c_char,
pub buffer: libc::c_uint,
pub period: libc::c_uint,
pub track_started: bool,
pub write_cb: Option<unsafe extern "C" fn(_: frames_t, _: bool, _: s32_t,
_: s32_t, _: s32_t, _: s32_t,
_: *mut *mut s32_t)
-> libc::c_int>,
pub start_frames: libc::c_uint,
pub frames_played: libc::c_uint,
pub frames_played_dmp: libc::c_uint,
pub current_sample_rate: libc::c_uint,
pub supported_rates: [libc::c_uint; 18],
pub default_sample_rate: libc::c_uint,
pub error_opening: bool,
pub device_frames: libc::c_uint,
pub updated: u32_t,
pub track_start_time: u32_t,
pub current_replay_gain: u32_t,
pub c2rust_unnamed: C2RustUnnamed,
pub next_sample_rate: libc::c_uint,
pub track_start: *mut u8_t,
pub gainL: u32_t,
pub gainR: u32_t,
pub invert: bool,
pub next_replay_gain: u32_t,
pub threshold: libc::c_uint,
pub fade: fade_state,
pub fade_start: *mut u8_t,
pub fade_end: *mut u8_t,
pub fade_dir: fade_dir,
pub fade_mode: fade_mode,
pub fade_secs: libc::c_uint,
pub rate_delay: libc::c_uint,
pub delay_active: bool,
pub stop_time: u32_t,
pub idle_to: u32_t,
}
pub type fade_dir = libc::c_uint;
pub const FADE_CROSS: fade_dir = 3;
pub const FADE_DOWN: fade_dir = 2;
pub const FADE_UP: fade_dir = 1;
pub type fade_state = libc::c_uint;
pub const FADE_ACTIVE: fade_state = 2;
pub const FADE_DUE: fade_state = 1;
pub const FADE_INACTIVE: fade_state = 0;
#[derive(Copy, Clone)]
#[repr(C)]
pub union C2RustUnnamed {
pub pause_frames: u32_t,
pub skip_frames: u32_t,
pub start_at: u32_t,
}
pub type output_format = libc::c_uint;
pub const S16_LE: output_format = 3;
pub const S24_3LE: output_format = 2;
pub const S24_LE: output_format = 1;
pub const S32_LE: output_format = 0;
pub type output_state = libc::c_int;
pub const OUTPUT_START_AT: output_state = 5;
pub const OUTPUT_SKIP_FRAMES: output_state = 4;
pub const OUTPUT_PAUSE_FRAMES: output_state = 3;
pub const OUTPUT_RUNNING: output_state = 2;
pub const OUTPUT_BUFFER: output_state = 1;
pub const OUTPUT_STOPPED: output_state = 0;
pub const OUTPUT_OFF: output_state = -1;
/*
* Squeezelite - lightweight headless squeezebox emulator
*
* (c) Adrian Smith 2012-2015, triode1@btinternet.com
* Ralph Irving 2015-2017, ralph_irving@hotmail.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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
// decode thread
#[no_mangle]
pub static mut loglevel: log_level = lERROR;
#[no_mangle]
pub static mut decode: decodestate =
decodestate{state: DECODE_STOPPED,
new_stream: false,
mutex:
pthread_mutex_t{__data:
__pthread_mutex_s{__lock: 0,
__count: 0,
__owner: 0,
__nusers: 0,
__kind: 0,
__spins: 0,
__elision: 0,
__list:
__pthread_list_t{__prev:
0
as
*const __pthread_internal_list
as
*mut __pthread_internal_list,
__next:
0
as
*const __pthread_internal_list
as
*mut __pthread_internal_list,},},},};
#[no_mangle]
pub static mut codecs: [*mut codec; 10] =
[0 as *const codec as *mut codec; 10];
#[no_mangle]
pub static mut codec: *mut codec = 0 as *const codec as *mut codec;
static mut flac_container: u8_t = '?' as i32 as u8_t;
static mut running: bool = 1 as libc::c_int != 0;
unsafe extern "C" fn decode_thread() -> *mut libc::c_void {
while running {
let mut bytes: size_t = 0;
let mut space: size_t = 0;
let mut min_space: size_t = 0;
let mut toend: bool = false;
let mut ran: bool = 0 as libc::c_int != 0;
pthread_mutex_lock(&mut (*streambuf).mutex);
bytes = _buf_used(streambuf) as size_t;
toend =
stream.state as libc::c_uint <=
DISCONNECT as libc::c_int as libc::c_uint;
pthread_mutex_unlock(&mut (*streambuf).mutex);
pthread_mutex_lock(&mut (*outputbuf).mutex);
space = _buf_space(outputbuf) as size_t;
pthread_mutex_unlock(&mut (*outputbuf).mutex);
pthread_mutex_lock(&mut decode.mutex);
if decode.state as libc::c_uint ==
DECODE_RUNNING as libc::c_int as libc::c_uint &&
!codec.is_null() {
if loglevel as libc::c_uint >=
lSDEBUG as libc::c_int as libc::c_uint {
logprint(b"%s %s:%d streambuf bytes: %u outputbuf space: %u\n\x00"
as *const u8 as *const libc::c_char, logtime(),
(*::std::mem::transmute::<&[u8; 14],
&[libc::c_char; 14]>(b"decode_thread\x00")).as_ptr(),
76 as libc::c_int, bytes, space);
}
min_space = (*codec).min_space as size_t;
if space > min_space &&
(bytes > (*codec).min_read_bytes as libc::c_ulong ||
toend as libc::c_int != 0) {
decode.state =
(*codec).decode.expect("non-null function pointer")();
if decode.state as libc::c_uint !=
DECODE_RUNNING as libc::c_int as libc::c_uint {
if loglevel as libc::c_uint >=
lINFO as libc::c_int as libc::c_uint {
logprint(b"%s %s:%d decode %s\n\x00" as *const u8 as
*const libc::c_char, logtime(),
(*::std::mem::transmute::<&[u8; 14],
&[libc::c_char; 14]>(b"decode_thread\x00")).as_ptr(),
101 as libc::c_int,
if decode.state as libc::c_uint ==
DECODE_COMPLETE as libc::c_int as
libc::c_uint {
b"complete\x00" as *const u8 as
*const libc::c_char
} else {
b"error\x00" as *const u8 as
*const libc::c_char
});
}
pthread_mutex_lock(&mut (*outputbuf).mutex);
if output.fade_mode as u64 != 0 {
_checkfade(0 as libc::c_int != 0);
}
pthread_mutex_unlock(&mut (*outputbuf).mutex);
wake_controller();
}
ran = 1 as libc::c_int != 0
}
}
pthread_mutex_unlock(&mut decode.mutex);
if !ran { usleep(100000 as libc::c_int as __useconds_t); }
}
return 0 as *mut libc::c_void;
}
unsafe extern "C" fn sort_codecs(mut pry: libc::c_int, mut ptr: *mut codec) {
static mut priority: [libc::c_int; 10] = [0; 10];
let mut i: libc::c_int = 0;
let mut tpry: libc::c_int = 0;
let mut tptr: *mut codec = 0 as *mut codec;
i = 0 as libc::c_int;
while i < 10 as libc::c_int {
if codecs[i as usize].is_null() {
codecs[i as usize] = ptr;
priority[i as usize] = pry;
return
}
if pry < priority[i as usize] {
tptr = codecs[i as usize];
codecs[i as usize] = ptr;
ptr = tptr;
tpry = priority[i as usize];
priority[i as usize] = pry;
pry = tpry
}
i += 1
};
}
static mut thread: pthread_t = 0;
#[no_mangle]
pub unsafe extern "C" fn decode_init(mut level: log_level,
mut include_codecs: *const libc::c_char,
mut exclude_codecs:
*const libc::c_char) {
let mut i: libc::c_int = 0;
let mut order_codecs: *mut libc::c_char = 0 as *mut libc::c_char;
loglevel = level;
if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint {
logprint(b"%s %s:%d init decode\n\x00" as *const u8 as
*const libc::c_char, logtime(),
(*::std::mem::transmute::<&[u8; 12],
&[libc::c_char; 12]>(b"decode_init\x00")).as_ptr(),
154 as libc::c_int);
}
// register codecs
// dsf,dff,alc,wma,wmap,wmal,aac,spt,ogg,ogf,flc,aif,pcm,mp3
i = 0 as libc::c_int;
if strstr(exclude_codecs,
b"aac\x00" as *const u8 as *const libc::c_char).is_null() &&
(include_codecs.is_null() ||
{
order_codecs =
strstr(include_codecs,
b"aac\x00" as *const u8 as
*const libc::c_char);
!order_codecs.is_null()
}) {
sort_codecs(if !include_codecs.is_null() {
order_codecs.wrapping_offset_from(include_codecs) as
libc::c_long
} else { i as libc::c_long } as libc::c_int,
register_faad());
}
if strstr(exclude_codecs,
b"ogg\x00" as *const u8 as *const libc::c_char).is_null() &&
(include_codecs.is_null() ||
{
order_codecs =
strstr(include_codecs,
b"ogg\x00" as *const u8 as
*const libc::c_char);
!order_codecs.is_null()
}) {
sort_codecs(if !include_codecs.is_null() {
order_codecs.wrapping_offset_from(include_codecs) as
libc::c_long
} else { i as libc::c_long } as libc::c_int,
register_vorbis());
}
if strstr(exclude_codecs,
b"flac\x00" as *const u8 as *const libc::c_char).is_null() &&
(include_codecs.is_null() ||
{
order_codecs =
strstr(include_codecs,
b"flac\x00" as *const u8 as
*const libc::c_char);
!order_codecs.is_null()
}) {
sort_codecs(if !include_codecs.is_null() {
order_codecs.wrapping_offset_from(include_codecs) as
libc::c_long
} else { i as libc::c_long } as libc::c_int,
register_flac());
}
if strstr(exclude_codecs,
b"pcm\x00" as *const u8 as *const libc::c_char).is_null() &&
(include_codecs.is_null() ||
{
order_codecs =
strstr(include_codecs,
b"pcm\x00" as *const u8 as
*const libc::c_char);
!order_codecs.is_null()
}) {
sort_codecs(if !include_codecs.is_null() {
order_codecs.wrapping_offset_from(include_codecs) as
libc::c_long
} else { i as libc::c_long } as libc::c_int,
register_pcm());
}
// try mad then mpg for mp3 unless command line option passed
if !(!strstr(exclude_codecs,
b"mp3\x00" as *const u8 as *const libc::c_char).is_null() ||
!strstr(exclude_codecs,
b"mad\x00" as *const u8 as
*const libc::c_char).is_null()) &&
(include_codecs.is_null() ||
{
order_codecs =
strstr(include_codecs,
b"mp3\x00" as *const u8 as
*const libc::c_char);
!order_codecs.is_null()
} ||
{
order_codecs =
strstr(include_codecs,
b"mad\x00" as *const u8 as
*const libc::c_char);
!order_codecs.is_null()
}) {
sort_codecs(if !include_codecs.is_null() {
order_codecs.wrapping_offset_from(include_codecs) as
libc::c_long
} else { i as libc::c_long } as libc::c_int,
register_mad());
} else if !(!strstr(exclude_codecs,
b"mp3\x00" as *const u8 as
*const libc::c_char).is_null() ||
!strstr(exclude_codecs,
b"mpg\x00" as *const u8 as
*const libc::c_char).is_null()) &&
(include_codecs.is_null() ||
{
order_codecs =
strstr(include_codecs,
b"mp3\x00" as *const u8 as
*const libc::c_char);
!order_codecs.is_null()
} ||
{
order_codecs =
strstr(include_codecs,
b"mpg\x00" as *const u8 as
*const libc::c_char);
!order_codecs.is_null()
}) {
sort_codecs(if !include_codecs.is_null() {
order_codecs.wrapping_offset_from(include_codecs) as
libc::c_long
} else { i as libc::c_long } as libc::c_int,
register_mpg());
}
if loglevel as libc::c_uint >= lDEBUG as libc::c_int as libc::c_uint {
logprint(b"%s %s:%d include codecs: %s exclude codecs: %s\n\x00" as
*const u8 as *const libc::c_char, logtime(),
(*::std::mem::transmute::<&[u8; 12],
&[libc::c_char; 12]>(b"decode_init\x00")).as_ptr(),
195 as libc::c_int,
if !include_codecs.is_null() {
include_codecs
} else { b"\x00" as *const u8 as *const libc::c_char },
exclude_codecs);
}
pthread_mutex_init(&mut decode.mutex, 0 as *const pthread_mutexattr_t);
let mut attr: pthread_attr_t = pthread_attr_t{__size: [0; 56],};
pthread_attr_init(&mut attr);
pthread_attr_setstacksize(&mut attr,
(16384 as libc::c_int +
128 as libc::c_int * 1024 as libc::c_int)
as size_t);
pthread_create(&mut thread, &mut attr,
::std::mem::transmute::<Option<unsafe extern "C" fn()
-> *mut libc::c_void>,
Option<unsafe extern "C" fn(_:
*mut libc::c_void)
->
*mut libc::c_void>>(Some(::std::mem::transmute::<unsafe extern "C" fn()
->
*mut libc::c_void,
unsafe extern "C" fn()
->
*mut libc::c_void>(decode_thread))),
0 as *mut libc::c_void);
pthread_attr_destroy(&mut attr);
decode.new_stream = 1 as libc::c_int != 0;
decode.state = DECODE_STOPPED;
}
#[no_mangle]
pub unsafe extern "C" fn decode_close() {
if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint {
logprint(b"%s %s:%d close decode\n\x00" as *const u8 as
*const libc::c_char, logtime(),
(*::std::mem::transmute::<&[u8; 13],
&[libc::c_char; 13]>(b"decode_close\x00")).as_ptr(),
222 as libc::c_int);
}
pthread_mutex_lock(&mut decode.mutex);
if !codec.is_null() {
(*codec).close.expect("non-null function pointer")();
codec = 0 as *mut codec
}
running = 0 as libc::c_int != 0;
pthread_mutex_unlock(&mut decode.mutex);
pthread_join(thread, 0 as *mut *mut libc::c_void);
pthread_mutex_destroy(&mut decode.mutex);
}
#[no_mangle]
pub unsafe extern "C" fn decode_flush() {
if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint {
logprint(b"%s %s:%d decode flush\n\x00" as *const u8 as
*const libc::c_char, logtime(),
(*::std::mem::transmute::<&[u8; 13],
&[libc::c_char; 13]>(b"decode_flush\x00")).as_ptr(),
237 as libc::c_int);
}
pthread_mutex_lock(&mut decode.mutex);
decode.state = DECODE_STOPPED;
pthread_mutex_unlock(&mut decode.mutex);
}
#[no_mangle]
pub unsafe extern "C" fn decode_newstream(mut sample_rate: libc::c_uint,
mut supported_rates:
*mut libc::c_uint)
-> libc::c_uint {
// called with O locked to get sample rate for potentially processed output stream
// release O mutex during process_newstream as it can take some time
return sample_rate;
}
/*
* Squeezelite - lightweight headless squeezebox emulator
*
* (c) Adrian Smith 2012-2015, triode1@btinternet.com
* Ralph Irving 2015-2017, ralph_irving@hotmail.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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additions (c) Paul Hermann, 2015-2017 under the same license terms
* -Control of Raspberry pi GPIO for amplifier power
* -Launch script on power status change from LMS
*/
// make may define: PORTAUDIO, SELFPIPE, RESAMPLE, RESAMPLE_MP, VISEXPORT, GPIO, IR, DSD, LINKALL to influence build
// build detection
// dynamically loaded libraries at run time
// !LINKALL
// config options
// do not reduce as icy-meta max is 4080
/* SUN */
/* SUN */
// printf/scanf formats for u64_t
// logging
// utils.c (non logging)
// buffer.c
// _* called with mutex locked
// slimproto.c
// stream.c
// decode.c
#[no_mangle]
pub unsafe extern "C" fn codec_open(mut format: u8_t, mut sample_size: u8_t,
mut sample_rate: u8_t, mut channels: u8_t,
mut endianness: u8_t) {
let mut i: libc::c_int = 0;
if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint {
logprint(b"%s %s:%d codec open: \'%c\'\n\x00" as *const u8 as
*const libc::c_char, logtime(),
(*::std::mem::transmute::<&[u8; 11],
&[libc::c_char; 11]>(b"codec_open\x00")).as_ptr(),
265 as libc::c_int, format as libc::c_int);
}
pthread_mutex_lock(&mut decode.mutex);
decode.new_stream = 1 as libc::c_int != 0;
decode.state = DECODE_STOPPED;
// potentially changed within codec when processing enabled
// find the required codec
i = 0 as libc::c_int;
while i < 10 as libc::c_int {
if !codecs[i as usize].is_null() &&
(*codecs[i as usize]).id as libc::c_int ==
format as libc::c_int {
// close codec if format or flac container changed
if !codec.is_null() &&
(codec != codecs[i as usize] ||
(*codecs[i as usize]).id as libc::c_int == 'f' as i32
&&
flac_container as libc::c_int !=
sample_size as libc::c_int) {
if loglevel as libc::c_uint >=
lINFO as libc::c_int as libc::c_uint {
logprint(b"%s %s:%d closing codec: \'%c\'\n\x00" as
*const u8 as *const libc::c_char, logtime(),
(*::std::mem::transmute::<&[u8; 11],
&[libc::c_char; 11]>(b"codec_open\x00")).as_ptr(),
283 as libc::c_int, (*codec).id as libc::c_int);
}
(*codec).close.expect("non-null function pointer")();
}
codec = codecs[i as usize];
if (*codec).id as libc::c_int == 'f' as i32 {
flac_container = sample_size
}
(*codec).open.expect("non-null function pointer")(sample_size,
sample_rate,
channels,
endianness);
decode.state = DECODE_READY;
pthread_mutex_unlock(&mut decode.mutex);
return
}
i += 1
}
pthread_mutex_unlock(&mut decode.mutex);
logprint(b"%s %s:%d codec not found\n\x00" as *const u8 as
*const libc::c_char, logtime(),
(*::std::mem::transmute::<&[u8; 11],
&[libc::c_char; 11]>(b"codec_open\x00")).as_ptr(),
303 as libc::c_int);
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

1105
src/mad.rs

File diff suppressed because it is too large Load Diff

View File

@ -1,791 +0,0 @@
use ::libc;
extern "C" {
pub type _IO_wide_data;
pub type _IO_codecvt;
pub type _IO_marker;
#[no_mangle]
fn getpid() -> __pid_t;
/*
* Squeezelite - lightweight headless squeezebox emulator
*
* (c) Adrian Smith 2012-2015, triode1@btinternet.com
* Ralph Irving 2015-2017, ralph_irving@hotmail.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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additions (c) Paul Hermann, 2015-2017 under the same license terms
* -Control of Raspberry pi GPIO for amplifier power
* -Launch script on power status change from LMS
*/
// make may define: PORTAUDIO, SELFPIPE, RESAMPLE, RESAMPLE_MP, VISEXPORT, GPIO, IR, DSD, LINKALL to influence build
// build detection
// dynamically loaded libraries at run time
// !LINKALL
// config options
// do not reduce as icy-meta max is 4080
/* SUN */
/* SUN */
// printf/scanf formats for u64_t
// logging
// utils.c (non logging)
// buffer.c
// _* called with mutex locked
// slimproto.c
// stream.c
// decode.c
// output.c output_alsa.c output_pa.c output_pack.c
// frames played at the point delay is measured
// ordered largest first so [0] is max_rate
// set in decode thread
// set in decode thread
// set by slimproto
// set by slimproto
// set by slimproto
// set by slimproto
// set by slimproto
// set by slimproto
// set by slimproto
// _* called with mutex locked
// output_alsa.c
// output_pa.c
// output_pulse.c
// output_stdout.c
#[no_mangle]
fn output_close_stdout();
#[no_mangle]
static mut stderr: *mut FILE;
#[no_mangle]
fn fclose(__stream: *mut FILE) -> libc::c_int;
#[no_mangle]
fn fopen(_: *const libc::c_char, _: *const libc::c_char) -> *mut FILE;
#[no_mangle]
fn freopen(__filename: *const libc::c_char, __modes: *const libc::c_char,
__stream: *mut FILE) -> *mut FILE;
#[no_mangle]
fn fprintf(_: *mut FILE, _: *const libc::c_char, _: ...) -> libc::c_int;
#[no_mangle]
fn printf(_: *const libc::c_char, _: ...) -> libc::c_int;
#[no_mangle]
fn atoi(__nptr: *const libc::c_char) -> libc::c_int;
#[no_mangle]
fn strtoul(_: *const libc::c_char, _: *mut *mut libc::c_char,
_: libc::c_int) -> libc::c_ulong;
#[no_mangle]
fn free(__ptr: *mut libc::c_void);
#[no_mangle]
fn exit(_: libc::c_int) -> !;
#[no_mangle]
fn realpath(__name: *const libc::c_char, __resolved: *mut libc::c_char)
-> *mut libc::c_char;
#[no_mangle]
fn strcat(_: *mut libc::c_char, _: *const libc::c_char)
-> *mut libc::c_char;
#[no_mangle]
fn strcmp(_: *const libc::c_char, _: *const libc::c_char) -> libc::c_int;
#[no_mangle]
fn strncmp(_: *const libc::c_char, _: *const libc::c_char,
_: libc::c_ulong) -> libc::c_int;
#[no_mangle]
fn strstr(_: *const libc::c_char, _: *const libc::c_char)
-> *mut libc::c_char;
#[no_mangle]
fn strtok(_: *mut libc::c_char, _: *const libc::c_char)
-> *mut libc::c_char;
#[no_mangle]
fn strlen(_: *const libc::c_char) -> libc::c_ulong;
#[no_mangle]
fn strerror(_: libc::c_int) -> *mut libc::c_char;
#[no_mangle]
fn __errno_location() -> *mut libc::c_int;
#[no_mangle]
fn unlink(__name: *const libc::c_char) -> libc::c_int;
#[no_mangle]
fn daemon(__nochdir: libc::c_int, __noclose: libc::c_int) -> libc::c_int;
#[no_mangle]
fn signal(__sig: libc::c_int, __handler: __sighandler_t)
-> __sighandler_t;
#[no_mangle]
fn logtime() -> *const libc::c_char;
#[no_mangle]
fn logprint(fmt: *const libc::c_char, _: ...);
#[no_mangle]
fn next_param(src: *mut libc::c_char, c: libc::c_char)
-> *mut libc::c_char;
#[no_mangle]
fn get_mac(mac: *mut u8_t);
#[no_mangle]
fn slimproto(level: log_level, server: *mut libc::c_char, mac: *mut u8_t,
name: *const libc::c_char, namefile: *const libc::c_char,
modelname: *const libc::c_char, maxSampleRate: libc::c_int);
#[no_mangle]
fn slimproto_stop();
#[no_mangle]
fn stream_init(level: log_level, stream_buf_size: libc::c_uint);
#[no_mangle]
fn stream_close();
#[no_mangle]
fn decode_init(level: log_level, include_codecs: *const libc::c_char,
exclude_codecs: *const libc::c_char);
#[no_mangle]
fn decode_close();
#[no_mangle]
fn list_devices();
#[no_mangle]
fn list_mixers(output_device: *const libc::c_char);
#[no_mangle]
fn output_init_alsa(level: log_level, device: *const libc::c_char,
output_buf_size: libc::c_uint,
params: *mut libc::c_char, rates: *mut libc::c_uint,
rate_delay: libc::c_uint, rt_priority: libc::c_uint,
idle: libc::c_uint, mixer_device: *mut libc::c_char,
volume_mixer: *mut libc::c_char, mixer_unmute: bool,
mixer_linear: bool);
#[no_mangle]
fn output_close_alsa();
#[no_mangle]
fn output_init_stdout(level: log_level, output_buf_size: libc::c_uint,
params: *mut libc::c_char, rates: *mut libc::c_uint,
rate_delay: libc::c_uint);
}
pub type size_t = libc::c_ulong;
pub type __uint8_t = libc::c_uchar;
pub type __off_t = libc::c_long;
pub type __off64_t = libc::c_long;
pub type __pid_t = libc::c_int;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct _IO_FILE {
pub _flags: libc::c_int,
pub _IO_read_ptr: *mut libc::c_char,
pub _IO_read_end: *mut libc::c_char,
pub _IO_read_base: *mut libc::c_char,
pub _IO_write_base: *mut libc::c_char,
pub _IO_write_ptr: *mut libc::c_char,
pub _IO_write_end: *mut libc::c_char,
pub _IO_buf_base: *mut libc::c_char,
pub _IO_buf_end: *mut libc::c_char,
pub _IO_save_base: *mut libc::c_char,
pub _IO_backup_base: *mut libc::c_char,
pub _IO_save_end: *mut libc::c_char,
pub _markers: *mut _IO_marker,
pub _chain: *mut _IO_FILE,
pub _fileno: libc::c_int,
pub _flags2: libc::c_int,
pub _old_offset: __off_t,
pub _cur_column: libc::c_ushort,
pub _vtable_offset: libc::c_schar,
pub _shortbuf: [libc::c_char; 1],
pub _lock: *mut libc::c_void,
pub _offset: __off64_t,
pub _codecvt: *mut _IO_codecvt,
pub _wide_data: *mut _IO_wide_data,
pub _freeres_list: *mut _IO_FILE,
pub _freeres_buf: *mut libc::c_void,
pub __pad5: size_t,
pub _mode: libc::c_int,
pub _unused2: [libc::c_char; 20],
}
pub type _IO_lock_t = ();
pub type FILE = _IO_FILE;
pub type u_int8_t = __uint8_t;
pub type __sighandler_t = Option<unsafe extern "C" fn(_: libc::c_int) -> ()>;
pub type u8_t = u_int8_t;
pub type log_level = libc::c_uint;
pub const lSDEBUG: log_level = 4;
pub const lDEBUG: log_level = 3;
pub const lINFO: log_level = 2;
pub const lWARN: log_level = 1;
pub const lERROR: log_level = 0;
/*
* Squeezelite - lightweight headless squeezebox emulator
*
* (c) Adrian Smith 2012-2015, triode1@btinternet.com
* Ralph Irving 2015-2020, ralph_irving@hotmail.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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additions (c) Paul Hermann, 2015-2017 under the same license terms
* -Control of Raspberry pi GPIO for amplifier power
* -Launch script on power status change from LMS
*/
unsafe extern "C" fn usage(mut argv0: *const libc::c_char) {
printf(b"Squeezelite v1.9.7-1223, Copyright 2012-2015 Adrian Smith, 2015-2020 Ralph Irving. See -t for license terms\nUsage: %s [options]\n -s <server>[:<port>]\tConnect to specified server, otherwise uses autodiscovery to find server\n -o <output device>\tSpecify output device, default \"default\", - = output to stdout\n -l \t\t\tList output devices\n -a <b>:<p>:<f>:<m>\tSpecify ALSA params to open output device, b = buffer time in ms or size in bytes, p = period count or size in bytes, f sample format (16|24|24_3|32), m = use mmap (0|1)\n -a <f>\t\tSpecify sample format (16|24|32) of output file when using -o - to output samples to stdout (interleaved little endian only)\n -b <stream>:<output>\tSpecify internal Stream and Output buffer sizes in Kbytes\n -c <codec1>,<codec2>\tRestrict codecs to those specified, otherwise load all available codecs; known codecs: flac,pcm,mp3,ogg,aac (mad,mpg for specific mp3 codec)\n \t\t\tCodecs reported to LMS in order listed, allowing codec priority refinement.\n -C <timeout>\t\tClose output device when idle after timeout seconds, default is to keep it open while player is \'on\'\n -d <log>=<level>\tSet logging level, logs: all|slimproto|stream|decode|output, level: info|debug|sdebug\n -e <codec1>,<codec2>\tExplicitly exclude native support of one or more codecs; known codecs: flac,pcm,mp3,ogg,aac (mad,mpg for specific mp3 codec)\n -f <logfile>\t\tWrite debug to logfile\n -m <mac addr>\t\tSet mac address, format: ab:cd:ef:12:34:56\n -M <modelname>\tSet the squeezelite player model name sent to the server (default: SqueezeLite)\n -n <name>\t\tSet the player name\n -N <filename>\t\tStore player name in filename to allow server defined name changes to be shared between servers (not supported with -n)\n -W\t\t\tRead wave and aiff format from header, ignore server parameters\n -p <priority>\t\tSet real time priority of output thread (1-99)\n -P <filename>\t\tStore the process id (PID) in filename\n -r <rates>[:<delay>]\tSample rates supported, allows output to be off when squeezelite is started; rates = <maxrate>|<minrate>-<maxrate>|<rate1>,<rate2>,<rate3>; delay = optional delay switching rates in ms\n -O <mixer device>\tSpecify mixer device, defaults to \'output device\'\n -L \t\t\tList volume controls for output device\n -U <control>\t\tUnmute ALSA control and set to full volume (not supported with -V)\n -V <control>\t\tUse ALSA control for volume adjustment, otherwise use software volume adjustment\n -X \t\t\tUse linear volume adjustments instead of in terms of dB (only for hardware volume control)\n -z \t\t\tDaemonize\n -t \t\t\tLicense terms\n -? \t\t\tDisplay this help text\n\nBuild options: LINUX ALSA EVENTFD\n\n\x00"
as *const u8 as *const libc::c_char, argv0);
}
unsafe extern "C" fn license() {
printf(b"Squeezelite v1.9.7-1223, Copyright 2012-2015 Adrian Smith, 2015-2020 Ralph Irving.\n\nThis program is free software: you can redistribute it and/or modify\nit under the terms of the GNU General Public License as published by\nthe Free Software Foundation, either version 3 of the License, or\n(at your option) any later version.\n\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with this program. If not, see <http://www.gnu.org/licenses/>.\n\nOption to allow server side upsampling for PCM streams (-W) from\nsqueezelite-R2 (c) Marco Curti 2015, marcoc1712@gmail.com.\n\n\x00"
as *const u8 as *const libc::c_char);
}
unsafe extern "C" fn sighandler(mut signum: libc::c_int) {
slimproto_stop();
// remove ourselves in case above does not work, second SIGINT will cause non gracefull shutdown
signal(signum, None); // set later
}
#[cross_check(entry(djb2="main"), exit(djb2="main"))]
unsafe fn main_0(mut argc: libc::c_int, mut argv: *mut *mut libc::c_char)
-> libc::c_int {
let mut server: *mut libc::c_char = 0 as *mut libc::c_char;
let mut output_device: *mut libc::c_char =
b"default\x00" as *const u8 as *const libc::c_char as
*mut libc::c_char;
let mut include_codecs: *mut libc::c_char = 0 as *mut libc::c_char;
let mut exclude_codecs: *mut libc::c_char =
b"\x00" as *const u8 as *const libc::c_char as *mut libc::c_char;
let mut name: *mut libc::c_char = 0 as *mut libc::c_char;
let mut namefile: *mut libc::c_char = 0 as *mut libc::c_char;
let mut modelname: *mut libc::c_char = 0 as *mut libc::c_char;
extern "C" {
#[no_mangle]
static mut pcm_check_header: bool;
}
extern "C" {
#[no_mangle]
static mut user_rates: bool;
}
let mut logfile: *mut libc::c_char = 0 as *mut libc::c_char;
let mut mac: [u8_t; 6] = [0; 6];
let mut stream_buf_size: libc::c_uint =
(2 as libc::c_int * 1024 as libc::c_int * 1024 as libc::c_int) as
libc::c_uint;
let mut output_buf_size: libc::c_uint = 0 as libc::c_int as libc::c_uint;
let mut rates: [libc::c_uint; 18] =
[0 as libc::c_int as libc::c_uint, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0];
let mut rate_delay: libc::c_uint = 0 as libc::c_int as libc::c_uint;
let mut resample: *mut libc::c_char = 0 as *mut libc::c_char;
let mut output_params: *mut libc::c_char = 0 as *mut libc::c_char;
let mut idle: libc::c_uint = 0 as libc::c_int as libc::c_uint;
let mut daemonize: bool = 0 as libc::c_int != 0;
let mut pidfile: *mut libc::c_char = 0 as *mut libc::c_char;
let mut pidfp: *mut FILE = 0 as *mut FILE;
let mut rt_priority: libc::c_uint = 45 as libc::c_int as libc::c_uint;
let mut mixer_device: *mut libc::c_char = output_device;
let mut output_mixer: *mut libc::c_char = 0 as *mut libc::c_char;
let mut output_mixer_unmute: bool = 0 as libc::c_int != 0;
let mut linear_volume: bool = 0 as libc::c_int != 0;
let mut log_output: log_level = lWARN;
let mut log_stream: log_level = lWARN;
let mut log_decode: log_level = lWARN;
let mut log_slimproto: log_level = lWARN;
let mut maxSampleRate: libc::c_int = 0 as libc::c_int;
let mut optarg: *mut libc::c_char = 0 as *mut libc::c_char;
let mut optind: libc::c_int = 1 as libc::c_int;
let mut i: libc::c_int = 0;
let mut cmdline: [libc::c_char; 512] =
*::std::mem::transmute::<&[u8; 512],
&mut [libc::c_char; 512]>(b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00");
get_mac(mac.as_mut_ptr());
i = 0 as libc::c_int;
while i < argc &&
strlen(*argv.offset(i as
isize)).wrapping_add(strlen(cmdline.as_mut_ptr())).wrapping_add(2
as
libc::c_int
as
libc::c_ulong)
< 512 as libc::c_int as libc::c_ulong {
strcat(cmdline.as_mut_ptr(), *argv.offset(i as isize));
strcat(cmdline.as_mut_ptr(),
b" \x00" as *const u8 as *const libc::c_char);
i += 1
}
while optind < argc &&
strlen(*argv.offset(optind as isize)) >=
2 as libc::c_int as libc::c_ulong &&
*(*argv.offset(optind as
isize)).offset(0 as libc::c_int as isize) as
libc::c_int == '-' as i32 {
let mut opt: *mut libc::c_char =
(*argv.offset(optind as isize)).offset(1 as libc::c_int as isize);
if !strstr(b"oabcCdefmMnNpPrsUVO\x00" as *const u8 as
*const libc::c_char, opt).is_null() &&
optind < argc - 1 as libc::c_int {
optarg = *argv.offset((optind + 1 as libc::c_int) as isize);
optind += 2 as libc::c_int
} else if !strstr(b"ltz?WLX\x00" as *const u8 as *const libc::c_char,
opt).is_null() {
optarg = 0 as *mut libc::c_char;
optind += 1 as libc::c_int
} else {
fprintf(stderr,
b"\nOption error: -%s\n\n\x00" as *const u8 as
*const libc::c_char, opt);
usage(*argv.offset(0 as libc::c_int as isize));
exit(1 as libc::c_int);
}
let mut current_block_129: u64;
match *opt.offset(0 as libc::c_int as isize) as libc::c_int {
111 => {
output_device = optarg;
mixer_device = optarg;
current_block_129 = 10517665100358322178;
}
97 => {
output_params = optarg;
current_block_129 = 10517665100358322178;
}
98 => {
let mut s: *mut libc::c_char =
next_param(optarg, ':' as i32 as libc::c_char);
let mut o: *mut libc::c_char =
next_param(0 as *mut libc::c_char,
':' as i32 as libc::c_char);
if !s.is_null() {
stream_buf_size =
(atoi(s) * 1024 as libc::c_int) as libc::c_uint
}
if !o.is_null() {
output_buf_size =
(atoi(o) * 1024 as libc::c_int) as libc::c_uint
}
current_block_129 = 10517665100358322178;
}
99 => {
include_codecs = optarg;
current_block_129 = 10517665100358322178;
}
67 => {
if atoi(optarg) > 0 as libc::c_int {
idle =
(atoi(optarg) * 1000 as libc::c_int) as libc::c_uint
}
current_block_129 = 10517665100358322178;
}
101 => {
exclude_codecs = optarg;
current_block_129 = 10517665100358322178;
}
100 => {
let mut l: *mut libc::c_char =
strtok(optarg,
b"=\x00" as *const u8 as *const libc::c_char);
let mut v: *mut libc::c_char =
strtok(0 as *mut libc::c_char,
b"=\x00" as *const u8 as *const libc::c_char);
let mut new: log_level = lWARN;
if !l.is_null() && !v.is_null() {
if strcmp(v,
b"info\x00" as *const u8 as *const libc::c_char)
== 0 {
new = lINFO
}
if strcmp(v,
b"debug\x00" as *const u8 as
*const libc::c_char) == 0 {
new = lDEBUG
}
if strcmp(v,
b"sdebug\x00" as *const u8 as
*const libc::c_char) == 0 {
new = lSDEBUG
}
if strcmp(l,
b"all\x00" as *const u8 as *const libc::c_char)
== 0 ||
strcmp(l,
b"slimproto\x00" as *const u8 as
*const libc::c_char) == 0 {
log_slimproto = new
}
if strcmp(l,
b"all\x00" as *const u8 as *const libc::c_char)
== 0 ||
strcmp(l,
b"stream\x00" as *const u8 as
*const libc::c_char) == 0 {
log_stream = new
}
if strcmp(l,
b"all\x00" as *const u8 as *const libc::c_char)
== 0 ||
strcmp(l,
b"decode\x00" as *const u8 as
*const libc::c_char) == 0 {
log_decode = new
}
if strcmp(l,
b"all\x00" as *const u8 as *const libc::c_char)
== 0 ||
strcmp(l,
b"output\x00" as *const u8 as
*const libc::c_char) == 0 {
log_output = new
}
} else {
fprintf(stderr,
b"\nDebug settings error: -d %s\n\n\x00" as
*const u8 as *const libc::c_char, optarg);
usage(*argv.offset(0 as libc::c_int as isize));
exit(1 as libc::c_int);
}
current_block_129 = 10517665100358322178;
}
102 => {
logfile = optarg;
current_block_129 = 10517665100358322178;
}
109 => {
let mut byte: libc::c_int = 0 as libc::c_int;
let mut tmp: *mut libc::c_char = 0 as *mut libc::c_char;
if strncmp(optarg,
b"00:04:20\x00" as *const u8 as
*const libc::c_char,
8 as libc::c_int as libc::c_ulong) == 0 {
logprint(b"%s %s:%d ignoring mac address from hardware player range 00:04:20:**:**:**\n\x00"
as *const u8 as *const libc::c_char,
logtime(),
(*::std::mem::transmute::<&[u8; 5],
&[libc::c_char; 5]>(b"main\x00")).as_ptr(),
453 as libc::c_int);
} else {
let mut t: *mut libc::c_char =
strtok(optarg,
b":\x00" as *const u8 as *const libc::c_char);
while !t.is_null() && byte < 6 as libc::c_int {
let fresh0 = byte;
byte = byte + 1;
mac[fresh0 as usize] =
strtoul(t, &mut tmp, 16 as libc::c_int) as u8_t;
t =
strtok(0 as *mut libc::c_char,
b":\x00" as *const u8 as
*const libc::c_char)
}
}
current_block_129 = 10517665100358322178;
}
77 => {
modelname = optarg;
current_block_129 = 10517665100358322178;
}
114 => {
let mut rstr: *mut libc::c_char =
next_param(optarg, ':' as i32 as libc::c_char);
let mut dstr: *mut libc::c_char =
next_param(0 as *mut libc::c_char,
':' as i32 as libc::c_char);
if !rstr.is_null() &&
!strstr(rstr,
b",\x00" as *const u8 as
*const libc::c_char).is_null() {
// parse sample rates and sort them
let mut r: *mut libc::c_char =
next_param(rstr, ',' as i32 as libc::c_char);
let mut tmp_0: [libc::c_uint; 18] =
[0 as libc::c_int as libc::c_uint, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
let mut i_0: libc::c_int = 0;
let mut j: libc::c_int = 0;
let mut last: libc::c_int = 999999 as libc::c_int;
i_0 = 0 as libc::c_int;
while !r.is_null() && i_0 < 18 as libc::c_int {
tmp_0[i_0 as usize] = atoi(r) as libc::c_uint;
r =
next_param(0 as *mut libc::c_char,
',' as i32 as libc::c_char);
i_0 += 1
}
i_0 = 0 as libc::c_int;
while i_0 < 18 as libc::c_int {
let mut largest: libc::c_int = 0 as libc::c_int;
j = 0 as libc::c_int;
while j < 18 as libc::c_int {
if tmp_0[j as usize] > largest as libc::c_uint &&
tmp_0[j as usize] < last as libc::c_uint {
largest = tmp_0[j as usize] as libc::c_int
}
j += 1
}
last = largest;
rates[i_0 as usize] = last as libc::c_uint;
i_0 += 1
}
} else if !rstr.is_null() {
// optstr is <min>-<max> or <max>, extract rates from test rates within this range
let mut ref_0: [libc::c_uint; 18] =
[768000 as libc::c_int as libc::c_uint,
705600 as libc::c_int as libc::c_uint,
384000 as libc::c_int as libc::c_uint,
352800 as libc::c_int as libc::c_uint,
192000 as libc::c_int as libc::c_uint,
176400 as libc::c_int as libc::c_uint,
96000 as libc::c_int as libc::c_uint,
88200 as libc::c_int as libc::c_uint,
48000 as libc::c_int as libc::c_uint,
44100 as libc::c_int as libc::c_uint,
32000 as libc::c_int as libc::c_uint,
24000 as libc::c_int as libc::c_uint,
22500 as libc::c_int as libc::c_uint,
16000 as libc::c_int as libc::c_uint,
12000 as libc::c_int as libc::c_uint,
11025 as libc::c_int as libc::c_uint,
8000 as libc::c_int as libc::c_uint,
0 as libc::c_int as libc::c_uint];
let mut str1: *mut libc::c_char =
next_param(rstr, '-' as i32 as libc::c_char);
let mut str2: *mut libc::c_char =
next_param(0 as *mut libc::c_char,
'-' as i32 as libc::c_char);
let mut max: libc::c_uint =
if !str2.is_null() {
atoi(str2) as libc::c_uint
} else if !str1.is_null() {
atoi(str1) as libc::c_uint
} else { ref_0[0 as libc::c_int as usize] };
let mut min: libc::c_uint =
if !str1.is_null() && !str2.is_null() {
atoi(str1)
} else { 0 as libc::c_int } as libc::c_uint;
let mut tmp_1: libc::c_uint = 0;
let mut i_1: libc::c_int = 0;
let mut j_0: libc::c_int = 0;
if max < min { tmp_1 = max; max = min; min = tmp_1 }
rates[0 as libc::c_int as usize] = max;
i_1 = 0 as libc::c_int;
j_0 = 1 as libc::c_int;
while i_1 < 18 as libc::c_int {
if ref_0[i_1 as usize] <
rates[(j_0 - 1 as libc::c_int) as usize] &&
ref_0[i_1 as usize] >= min {
let fresh1 = j_0;
j_0 = j_0 + 1;
rates[fresh1 as usize] = ref_0[i_1 as usize]
}
i_1 += 1
}
}
if !dstr.is_null() { rate_delay = atoi(dstr) as libc::c_uint }
if rates[0 as libc::c_int as usize] != 0 {
user_rates = 1 as libc::c_int != 0
}
current_block_129 = 10517665100358322178;
}
115 => {
server = optarg;
current_block_129 = 10517665100358322178;
}
110 => {
name = optarg;
current_block_129 = 10517665100358322178;
}
78 => {
namefile = optarg;
current_block_129 = 10517665100358322178;
}
87 => {
pcm_check_header = 1 as libc::c_int != 0;
current_block_129 = 10517665100358322178;
}
112 => {
rt_priority = atoi(optarg) as libc::c_uint;
if rt_priority > 99 as libc::c_int as libc::c_uint ||
rt_priority < 1 as libc::c_int as libc::c_uint {
fprintf(stderr,
b"\nError: invalid priority: %s\n\n\x00" as
*const u8 as *const libc::c_char, optarg);
usage(*argv.offset(0 as libc::c_int as isize));
exit(1 as libc::c_int);
}
current_block_129 = 10517665100358322178;
}
80 => {
pidfile = optarg;
current_block_129 = 10517665100358322178;
}
108 => { list_devices(); exit(0 as libc::c_int); }
79 => {
mixer_device = optarg;
current_block_129 = 10517665100358322178;
}
76 => { list_mixers(mixer_device); exit(0 as libc::c_int); }
88 => {
linear_volume = 1 as libc::c_int != 0;
current_block_129 = 10517665100358322178;
}
85 => {
output_mixer_unmute = 1 as libc::c_int != 0;
current_block_129 = 8353035839816271260;
}
86 => { current_block_129 = 8353035839816271260; }
122 => {
daemonize = 1 as libc::c_int != 0;
current_block_129 = 10517665100358322178;
}
116 => { license(); exit(0 as libc::c_int); }
63 => {
usage(*argv.offset(0 as libc::c_int as isize));
exit(0 as libc::c_int);
}
_ => {
fprintf(stderr,
b"Arg error: %s\n\x00" as *const u8 as
*const libc::c_char,
*argv.offset(optind as isize));
current_block_129 = 10517665100358322178;
}
}
match current_block_129 {
8353035839816271260 => {
if !output_mixer.is_null() {
fprintf(stderr,
b"-U and -V option should not be used at same time\n\x00"
as *const u8 as *const libc::c_char);
exit(1 as libc::c_int);
}
output_mixer = optarg
}
_ => { }
}
}
// warn if command line includes something which isn't parsed
if optind < argc {
fprintf(stderr,
b"\nError: command line argument error\n\n\x00" as *const u8
as *const libc::c_char);
usage(*argv.offset(0 as libc::c_int as isize));
exit(1 as libc::c_int);
}
signal(2 as libc::c_int,
Some(sighandler as unsafe extern "C" fn(_: libc::c_int) -> ()));
signal(15 as libc::c_int,
Some(sighandler as unsafe extern "C" fn(_: libc::c_int) -> ()));
signal(3 as libc::c_int,
Some(sighandler as unsafe extern "C" fn(_: libc::c_int) -> ()));
signal(1 as libc::c_int,
Some(sighandler as unsafe extern "C" fn(_: libc::c_int) -> ()));
// set the output buffer size if not specified on the command line, take account of resampling
if output_buf_size == 0 {
output_buf_size =
(44100 as libc::c_int * 8 as libc::c_int * 10 as libc::c_int) as
libc::c_uint;
if !resample.is_null() {
let mut scale: libc::c_uint = 8 as libc::c_int as libc::c_uint;
if rates[0 as libc::c_int as usize] != 0 {
scale =
rates[0 as libc::c_int as
usize].wrapping_div(44100 as libc::c_int as
libc::c_uint);
if scale > 8 as libc::c_int as libc::c_uint {
scale = 8 as libc::c_int as libc::c_uint
}
if scale < 1 as libc::c_int as libc::c_uint {
scale = 1 as libc::c_int as libc::c_uint
}
}
output_buf_size = output_buf_size.wrapping_mul(scale)
}
}
if !logfile.is_null() {
if freopen(logfile, b"a\x00" as *const u8 as *const libc::c_char,
stderr).is_null() {
fprintf(stderr,
b"error opening logfile %s: %s\n\x00" as *const u8 as
*const libc::c_char, logfile,
strerror(*__errno_location()));
} else if log_output as libc::c_uint >=
lINFO as libc::c_int as libc::c_uint ||
log_stream as libc::c_uint >=
lINFO as libc::c_int as libc::c_uint ||
log_decode as libc::c_uint >=
lINFO as libc::c_int as libc::c_uint ||
log_slimproto as libc::c_uint >=
lINFO as libc::c_int as libc::c_uint {
fprintf(stderr, b"\n%s\n\x00" as *const u8 as *const libc::c_char,
cmdline.as_mut_ptr());
}
}
if !pidfile.is_null() {
pidfp = fopen(pidfile, b"w\x00" as *const u8 as *const libc::c_char);
if pidfp.is_null() {
fprintf(stderr,
b"Error opening pidfile %s: %s\n\x00" as *const u8 as
*const libc::c_char, pidfile,
strerror(*__errno_location()));
exit(1 as libc::c_int);
}
pidfile = realpath(pidfile, 0 as *mut libc::c_char)
// daemonize will change cwd
}
if daemonize {
if daemon(0 as libc::c_int,
if !logfile.is_null() {
1 as libc::c_int
} else { 0 as libc::c_int }) != 0 {
fprintf(stderr,
b"error daemonizing: %s\n\x00" as *const u8 as
*const libc::c_char, strerror(*__errno_location()));
}
}
if !pidfp.is_null() {
fprintf(pidfp, b"%d\n\x00" as *const u8 as *const libc::c_char,
getpid());
fclose(pidfp);
}
stream_init(log_stream, stream_buf_size);
if strcmp(output_device, b"-\x00" as *const u8 as *const libc::c_char) ==
0 {
output_init_stdout(log_output, output_buf_size, output_params,
rates.as_mut_ptr(), rate_delay);
} else {
output_init_alsa(log_output, output_device, output_buf_size,
output_params, rates.as_mut_ptr(), rate_delay,
rt_priority, idle, mixer_device, output_mixer,
output_mixer_unmute, linear_volume);
}
decode_init(log_decode, include_codecs, exclude_codecs);
if !name.is_null() && !namefile.is_null() {
fprintf(stderr,
b"-n and -N option should not be used at same time\n\x00" as
*const u8 as *const libc::c_char);
exit(1 as libc::c_int);
}
slimproto(log_slimproto, server, mac.as_mut_ptr(), name, namefile,
modelname, maxSampleRate);
decode_close();
stream_close();
if strcmp(output_device, b"-\x00" as *const u8 as *const libc::c_char) ==
0 {
output_close_stdout();
} else { output_close_alsa(); }
if !pidfile.is_null() {
unlink(pidfile);
free(pidfile as *mut libc::c_void);
}
exit(0 as libc::c_int);
}
#[cross_check(none)]
#[main]
pub fn main() {
let mut args: Vec<*mut libc::c_char> = Vec::new();
for arg in ::std::env::args() {
args.push(::std::ffi::CString::new(arg).expect("Failed to convert argument into CString.").into_raw());
};
args.push(::std::ptr::null_mut());
unsafe {
::std::process::exit(main_0((args.len() - 1) as libc::c_int,
args.as_mut_ptr() as
*mut *mut libc::c_char) as i32)
}
}

View File

@ -1,843 +0,0 @@
use ::libc;
extern "C" {
pub type mpg123_handle_struct;
#[no_mangle]
fn malloc(_: libc::c_ulong) -> *mut libc::c_void;
#[no_mangle]
fn _checkfade(_: bool);
#[no_mangle]
fn dlopen(__file: *const libc::c_char, __mode: libc::c_int)
-> *mut libc::c_void;
#[no_mangle]
fn dlsym(__handle: *mut libc::c_void, __name: *const libc::c_char)
-> *mut libc::c_void;
#[no_mangle]
fn dlerror() -> *mut libc::c_char;
#[no_mangle]
fn pthread_mutex_lock(__mutex: *mut pthread_mutex_t) -> libc::c_int;
#[no_mangle]
fn pthread_mutex_unlock(__mutex: *mut pthread_mutex_t) -> libc::c_int;
#[no_mangle]
fn logtime() -> *const libc::c_char;
#[no_mangle]
fn logprint(fmt: *const libc::c_char, _: ...);
#[no_mangle]
fn _buf_used(buf: *mut buffer) -> libc::c_uint;
#[no_mangle]
fn _buf_space(buf: *mut buffer) -> libc::c_uint;
#[no_mangle]
fn _buf_cont_read(buf: *mut buffer) -> libc::c_uint;
#[no_mangle]
fn _buf_cont_write(buf: *mut buffer) -> libc::c_uint;
#[no_mangle]
fn _buf_inc_readp(buf: *mut buffer, by: libc::c_uint);
#[no_mangle]
fn _buf_inc_writep(buf: *mut buffer, by: libc::c_uint);
#[no_mangle]
fn decode_newstream(sample_rate: libc::c_uint,
supported_rates: *mut libc::c_uint) -> libc::c_uint;
#[no_mangle]
static mut loglevel: log_level;
#[no_mangle]
static mut streambuf: *mut buffer;
#[no_mangle]
static mut outputbuf: *mut buffer;
#[no_mangle]
static mut stream: streamstate;
#[no_mangle]
static mut output: outputstate;
#[no_mangle]
static mut decode: decodestate;
}
pub type size_t = libc::c_ulong;
pub type __uint8_t = libc::c_uchar;
pub type __int16_t = libc::c_short;
pub type __int32_t = libc::c_int;
pub type __uint32_t = libc::c_uint;
pub type __uint64_t = libc::c_ulong;
pub type int16_t = __int16_t;
pub type int32_t = __int32_t;
pub type u_int8_t = __uint8_t;
pub type u_int32_t = __uint32_t;
pub type u_int64_t = __uint64_t;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct __pthread_internal_list {
pub __prev: *mut __pthread_internal_list,
pub __next: *mut __pthread_internal_list,
}
pub type __pthread_list_t = __pthread_internal_list;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct __pthread_mutex_s {
pub __lock: libc::c_int,
pub __count: libc::c_uint,
pub __owner: libc::c_int,
pub __nusers: libc::c_uint,
pub __kind: libc::c_int,
pub __spins: libc::c_short,
pub __elision: libc::c_short,
pub __list: __pthread_list_t,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub union pthread_mutex_t {
pub __data: __pthread_mutex_s,
pub __size: [libc::c_char; 40],
pub __align: libc::c_long,
}
pub type u8_t = u_int8_t;
pub type u32_t = u_int32_t;
pub type u64_t = u_int64_t;
pub type s16_t = int16_t;
pub type s32_t = int32_t;
pub type frames_t = u32_t;
pub type log_level = libc::c_uint;
pub const lSDEBUG: log_level = 4;
pub const lDEBUG: log_level = 3;
pub const lINFO: log_level = 2;
pub const lWARN: log_level = 1;
pub const lERROR: log_level = 0;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct buffer {
pub buf: *mut u8_t,
pub readp: *mut u8_t,
pub writep: *mut u8_t,
pub wrap: *mut u8_t,
pub size: size_t,
pub base_size: size_t,
pub mutex: pthread_mutex_t,
}
pub type stream_state = libc::c_uint;
pub const RECV_HEADERS: stream_state = 7;
pub const SEND_HEADERS: stream_state = 6;
pub const STREAMING_HTTP: stream_state = 5;
pub const STREAMING_FILE: stream_state = 4;
pub const STREAMING_BUFFERING: stream_state = 3;
pub const STREAMING_WAIT: stream_state = 2;
pub const DISCONNECT: stream_state = 1;
pub const STOPPED: stream_state = 0;
pub type disconnect_code = libc::c_uint;
pub const TIMEOUT: disconnect_code = 4;
pub const UNREACHABLE: disconnect_code = 3;
pub const REMOTE_DISCONNECT: disconnect_code = 2;
pub const LOCAL_DISCONNECT: disconnect_code = 1;
pub const DISCONNECT_OK: disconnect_code = 0;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct streamstate {
pub state: stream_state,
pub disconnect: disconnect_code,
pub header: *mut libc::c_char,
pub header_len: size_t,
pub sent_headers: bool,
pub cont_wait: bool,
pub bytes: u64_t,
pub threshold: libc::c_uint,
pub meta_interval: u32_t,
pub meta_next: u32_t,
pub meta_left: u32_t,
pub meta_send: bool,
}
pub type decode_state = libc::c_uint;
pub const DECODE_ERROR: decode_state = 4;
pub const DECODE_COMPLETE: decode_state = 3;
pub const DECODE_RUNNING: decode_state = 2;
pub const DECODE_READY: decode_state = 1;
pub const DECODE_STOPPED: decode_state = 0;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct decodestate {
pub state: decode_state,
pub new_stream: bool,
pub mutex: pthread_mutex_t,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct codec {
pub id: libc::c_char,
pub types: *mut libc::c_char,
pub min_read_bytes: libc::c_uint,
pub min_space: libc::c_uint,
pub open: Option<unsafe extern "C" fn(_: u8_t, _: u8_t, _: u8_t, _: u8_t)
-> ()>,
pub close: Option<unsafe extern "C" fn() -> ()>,
pub decode: Option<unsafe extern "C" fn() -> decode_state>,
}
pub type output_state = libc::c_int;
pub const OUTPUT_START_AT: output_state = 5;
pub const OUTPUT_SKIP_FRAMES: output_state = 4;
pub const OUTPUT_PAUSE_FRAMES: output_state = 3;
pub const OUTPUT_RUNNING: output_state = 2;
pub const OUTPUT_BUFFER: output_state = 1;
pub const OUTPUT_STOPPED: output_state = 0;
pub const OUTPUT_OFF: output_state = -1;
pub type output_format = libc::c_uint;
pub const S16_LE: output_format = 3;
pub const S24_3LE: output_format = 2;
pub const S24_LE: output_format = 1;
pub const S32_LE: output_format = 0;
pub type fade_state = libc::c_uint;
pub const FADE_ACTIVE: fade_state = 2;
pub const FADE_DUE: fade_state = 1;
pub const FADE_INACTIVE: fade_state = 0;
pub type fade_dir = libc::c_uint;
pub const FADE_CROSS: fade_dir = 3;
pub const FADE_DOWN: fade_dir = 2;
pub const FADE_UP: fade_dir = 1;
pub type fade_mode = libc::c_uint;
pub const FADE_INOUT: fade_mode = 4;
pub const FADE_OUT: fade_mode = 3;
pub const FADE_IN: fade_mode = 2;
pub const FADE_CROSSFADE: fade_mode = 1;
pub const FADE_NONE: fade_mode = 0;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct outputstate {
pub state: output_state,
pub format: output_format,
pub device: *const libc::c_char,
pub buffer: libc::c_uint,
pub period: libc::c_uint,
pub track_started: bool,
pub write_cb: Option<unsafe extern "C" fn(_: frames_t, _: bool, _: s32_t,
_: s32_t, _: s32_t, _: s32_t,
_: *mut *mut s32_t)
-> libc::c_int>,
pub start_frames: libc::c_uint,
pub frames_played: libc::c_uint,
pub frames_played_dmp: libc::c_uint,
pub current_sample_rate: libc::c_uint,
pub supported_rates: [libc::c_uint; 18],
pub default_sample_rate: libc::c_uint,
pub error_opening: bool,
pub device_frames: libc::c_uint,
pub updated: u32_t,
pub track_start_time: u32_t,
pub current_replay_gain: u32_t,
pub c2rust_unnamed: C2RustUnnamed,
pub next_sample_rate: libc::c_uint,
pub track_start: *mut u8_t,
pub gainL: u32_t,
pub gainR: u32_t,
pub invert: bool,
pub next_replay_gain: u32_t,
pub threshold: libc::c_uint,
pub fade: fade_state,
pub fade_start: *mut u8_t,
pub fade_end: *mut u8_t,
pub fade_dir: fade_dir,
pub fade_mode: fade_mode,
pub fade_secs: libc::c_uint,
pub rate_delay: libc::c_uint,
pub delay_active: bool,
pub stop_time: u32_t,
pub idle_to: u32_t,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub union C2RustUnnamed {
pub pause_frames: u32_t,
pub skip_frames: u32_t,
pub start_at: u32_t,
}
pub const MPG123_ERR: mpg123_errors = -1;
pub const MPG123_DONE: mpg123_errors = -12;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct mpg {
pub h: *mut mpg123_handle,
pub use16bit: bool,
pub mpg123_init: Option<unsafe extern "C" fn() -> libc::c_int>,
pub mpg123_feature: Option<unsafe extern "C" fn(_: mpg123_feature_set)
-> libc::c_int>,
pub mpg123_rates: Option<unsafe extern "C" fn(_: *mut *const libc::c_long,
_: *mut size_t) -> ()>,
pub mpg123_format_none: Option<unsafe extern "C" fn(_: *mut mpg123_handle)
-> libc::c_int>,
pub mpg123_format: Option<unsafe extern "C" fn(_: *mut mpg123_handle,
_: libc::c_long,
_: libc::c_int,
_: libc::c_int)
-> libc::c_int>,
pub mpg123_new: Option<unsafe extern "C" fn(_: *const libc::c_char,
_: *mut libc::c_int)
-> *mut mpg123_handle>,
pub mpg123_delete: Option<unsafe extern "C" fn(_: *mut mpg123_handle)
-> ()>,
pub mpg123_open_feed: Option<unsafe extern "C" fn(_: *mut mpg123_handle)
-> libc::c_int>,
pub mpg123_decode: Option<unsafe extern "C" fn(_: *mut mpg123_handle,
_: *const libc::c_uchar,
_: size_t,
_: *mut libc::c_uchar,
_: size_t, _: *mut size_t)
-> libc::c_int>,
pub mpg123_getformat: Option<unsafe extern "C" fn(_: *mut mpg123_handle,
_: *mut libc::c_long,
_: *mut libc::c_int,
_: *mut libc::c_int)
-> libc::c_int>,
pub mpg123_plain_strerror: Option<unsafe extern "C" fn(_: libc::c_int)
-> *const libc::c_char>,
}
pub type mpg123_handle = mpg123_handle_struct;
pub type mpg123_feature_set = libc::c_uint;
pub const MPG123_FEATURE_EQUALIZER: mpg123_feature_set = 14;
pub const MPG123_FEATURE_TIMEOUT_READ: mpg123_feature_set = 13;
pub const MPG123_FEATURE_PARSE_ICY: mpg123_feature_set = 12;
pub const MPG123_FEATURE_DECODE_NTOM: mpg123_feature_set = 11;
pub const MPG123_FEATURE_DECODE_DOWNSAMPLE: mpg123_feature_set = 10;
pub const MPG123_FEATURE_DECODE_ACCURATE: mpg123_feature_set = 9;
pub const MPG123_FEATURE_DECODE_LAYER3: mpg123_feature_set = 8;
pub const MPG123_FEATURE_DECODE_LAYER2: mpg123_feature_set = 7;
pub const MPG123_FEATURE_DECODE_LAYER1: mpg123_feature_set = 6;
pub const MPG123_FEATURE_PARSE_ID3V2: mpg123_feature_set = 5;
pub const MPG123_FEATURE_INDEX: mpg123_feature_set = 4;
pub const MPG123_FEATURE_OUTPUT_32BIT: mpg123_feature_set = 3;
pub const MPG123_FEATURE_OUTPUT_16BIT: mpg123_feature_set = 2;
pub const MPG123_FEATURE_OUTPUT_8BIT: mpg123_feature_set = 1;
pub const MPG123_FEATURE_ABI_UTF8OPEN: mpg123_feature_set = 0;
pub const MPG123_NEW_FORMAT: mpg123_errors = -11;
pub const MPG123_ENC_SIGNED_32: mpg123_enc_enum = 4480;
pub const MPG123_ENC_SIGNED_16: mpg123_enc_enum = 208;
pub type mpg123_enc_enum = libc::c_uint;
pub const MPG123_ENC_ANY: mpg123_enc_enum = 30719;
pub const MPG123_ENC_FLOAT_64: mpg123_enc_enum = 1024;
pub const MPG123_ENC_FLOAT_32: mpg123_enc_enum = 512;
pub const MPG123_ENC_UNSIGNED_24: mpg123_enc_enum = 24576;
pub const MPG123_ENC_SIGNED_24: mpg123_enc_enum = 20608;
pub const MPG123_ENC_UNSIGNED_32: mpg123_enc_enum = 8448;
pub const MPG123_ENC_ALAW_8: mpg123_enc_enum = 8;
pub const MPG123_ENC_ULAW_8: mpg123_enc_enum = 4;
pub const MPG123_ENC_SIGNED_8: mpg123_enc_enum = 130;
pub const MPG123_ENC_UNSIGNED_8: mpg123_enc_enum = 1;
pub const MPG123_ENC_UNSIGNED_16: mpg123_enc_enum = 96;
pub const MPG123_ENC_FLOAT: mpg123_enc_enum = 3584;
pub const MPG123_ENC_SIGNED: mpg123_enc_enum = 128;
pub const MPG123_ENC_32: mpg123_enc_enum = 256;
pub const MPG123_ENC_24: mpg123_enc_enum = 16384;
pub const MPG123_ENC_16: mpg123_enc_enum = 64;
pub const MPG123_ENC_8: mpg123_enc_enum = 15;
pub type mpg123_errors = libc::c_int;
pub const MPG123_INT_OVERFLOW: mpg123_errors = 43;
pub const MPG123_LFS_OVERFLOW: mpg123_errors = 42;
pub const MPG123_BAD_CUSTOM_IO: mpg123_errors = 41;
pub const MPG123_LSEEK_FAILED: mpg123_errors = 40;
pub const MPG123_BAD_VALUE: mpg123_errors = 39;
pub const MPG123_MISSING_FEATURE: mpg123_errors = 38;
pub const MPG123_BAD_DECODER_SETUP: mpg123_errors = 37;
pub const MPG123_INDEX_FAIL: mpg123_errors = 36;
pub const MPG123_NO_INDEX: mpg123_errors = 35;
pub const MPG123_BAD_KEY: mpg123_errors = 34;
pub const MPG123_NULL_POINTER: mpg123_errors = 33;
pub const MPG123_NO_RELSEEK: mpg123_errors = 32;
pub const MPG123_NULL_BUFFER: mpg123_errors = 31;
pub const MPG123_BAD_ALIGN: mpg123_errors = 30;
pub const MPG123_NO_8BIT: mpg123_errors = 29;
pub const MPG123_RESYNC_FAIL: mpg123_errors = 28;
pub const MPG123_OUT_OF_SYNC: mpg123_errors = 27;
pub const MPG123_BAD_INDEX_PAR: mpg123_errors = 26;
pub const MPG123_BAD_PARS: mpg123_errors = 25;
pub const MPG123_NO_READER: mpg123_errors = 24;
pub const MPG123_NO_SEEK: mpg123_errors = 23;
pub const MPG123_BAD_FILE: mpg123_errors = 22;
pub const MPG123_NO_TIMEOUT: mpg123_errors = 21;
pub const MPG123_BAD_WHENCE: mpg123_errors = 20;
pub const MPG123_NO_SEEK_FROM_END: mpg123_errors = 19;
pub const MPG123_ERR_READER: mpg123_errors = 18;
pub const MPG123_ERR_NULL: mpg123_errors = 17;
pub const MPG123_BAD_BAND: mpg123_errors = 16;
pub const MPG123_BAD_TYPES: mpg123_errors = 15;
pub const MPG123_NO_SPACE: mpg123_errors = 14;
pub const MPG123_NO_GAPLESS: mpg123_errors = 13;
pub const MPG123_BAD_RVA: mpg123_errors = 12;
pub const MPG123_NO_BUFFERS: mpg123_errors = 11;
pub const MPG123_BAD_HANDLE: mpg123_errors = 10;
pub const MPG123_BAD_DECODER: mpg123_errors = 9;
pub const MPG123_NOT_INITIALIZED: mpg123_errors = 8;
pub const MPG123_OUT_OF_MEM: mpg123_errors = 7;
pub const MPG123_BAD_BUFFER: mpg123_errors = 6;
pub const MPG123_BAD_PARAM: mpg123_errors = 5;
pub const MPG123_ERR_16TO8TABLE: mpg123_errors = 4;
pub const MPG123_BAD_RATE: mpg123_errors = 3;
pub const MPG123_BAD_CHANNEL: mpg123_errors = 2;
pub const MPG123_BAD_OUTFORMAT: mpg123_errors = 1;
pub const MPG123_OK: mpg123_errors = 0;
pub const MPG123_NEED_MORE: mpg123_errors = -10;
static mut m: *mut mpg = 0 as *const mpg as *mut mpg;
unsafe extern "C" fn mpg_decode() -> decode_state {
let mut bytes: size_t = 0;
let mut space: size_t = 0;
let mut size: size_t = 0;
let mut ret: libc::c_int = 0;
let mut write_buf: *mut u8_t = 0 as *mut u8_t;
pthread_mutex_lock(&mut (*streambuf).mutex);
pthread_mutex_lock(&mut (*outputbuf).mutex);
bytes =
if _buf_used(streambuf) < _buf_cont_read(streambuf) {
_buf_used(streambuf)
} else { _buf_cont_read(streambuf) } as size_t;
space =
if _buf_space(outputbuf) < _buf_cont_write(outputbuf) {
_buf_space(outputbuf)
} else { _buf_cont_write(outputbuf) } as size_t;
write_buf = (*outputbuf).writep;
bytes =
if bytes < 512 as libc::c_int as libc::c_ulong {
bytes
} else { 512 as libc::c_int as libc::c_ulong };
space =
if space < (32 as libc::c_int * 1024 as libc::c_int) as libc::c_ulong
{
space
} else { (32 as libc::c_int * 1024 as libc::c_int) as libc::c_ulong };
if (*m).use16bit {
space =
space.wrapping_div(8 as libc::c_int as
libc::c_ulong).wrapping_mul(4 as
libc::c_int
as
libc::c_ulong)
}
// only get the new stream information on first call so we can reset decode.direct appropriately
if decode.new_stream { space = 0 as libc::c_int as size_t }
ret =
(*m).mpg123_decode.expect("non-null function pointer")((*m).h,
(*streambuf).readp,
bytes,
write_buf,
space,
&mut size);
if ret == MPG123_NEW_FORMAT as libc::c_int {
if decode.new_stream {
let mut rate: libc::c_long = 0;
let mut channels: libc::c_int = 0;
let mut enc: libc::c_int = 0;
(*m).mpg123_getformat.expect("non-null function pointer")((*m).h,
&mut rate,
&mut channels,
&mut enc);
if loglevel as libc::c_uint >=
lINFO as libc::c_int as libc::c_uint {
logprint(b"%s %s:%d setting track_start\n\x00" as *const u8 as
*const libc::c_char, logtime(),
(*::std::mem::transmute::<&[u8; 11],
&[libc::c_char; 11]>(b"mpg_decode\x00")).as_ptr(),
125 as libc::c_int);
}
output.next_sample_rate =
decode_newstream(rate as libc::c_uint,
output.supported_rates.as_mut_ptr());
output.track_start = (*outputbuf).writep;
if output.fade_mode as u64 != 0 {
_checkfade(1 as libc::c_int != 0);
}
decode.new_stream = 0 as libc::c_int != 0
} else if loglevel as libc::c_uint >=
lWARN as libc::c_int as libc::c_uint {
logprint(b"%s %s:%d format change mid stream - not supported\n\x00"
as *const u8 as *const libc::c_char, logtime(),
(*::std::mem::transmute::<&[u8; 11],
&[libc::c_char; 11]>(b"mpg_decode\x00")).as_ptr(),
135 as libc::c_int);
}
}
// expand 16bit output to 32bit samples
if (*m).use16bit {
let mut iptr: *mut s16_t = 0 as *mut s16_t;
let mut optr: *mut s32_t = 0 as *mut s32_t;
let mut count: size_t =
size.wrapping_div(2 as libc::c_int as libc::c_ulong);
size = count.wrapping_mul(4 as libc::c_int as libc::c_ulong);
iptr = (write_buf as *mut s16_t).offset(count as isize);
optr = (write_buf as *mut s32_t).offset(count as isize);
loop {
let fresh0 = count;
count = count.wrapping_sub(1);
if !(fresh0 != 0) { break ; }
iptr = iptr.offset(-1);
optr = optr.offset(-1);
*optr = (*iptr as libc::c_int) << 16 as libc::c_int
}
}
_buf_inc_readp(streambuf, bytes as libc::c_uint);
_buf_inc_writep(outputbuf, size as libc::c_uint);
pthread_mutex_unlock(&mut (*outputbuf).mutex);
if loglevel as libc::c_uint >= lSDEBUG as libc::c_int as libc::c_uint {
logprint(b"%s %s:%d write %u frames\n\x00" as *const u8 as
*const libc::c_char, logtime(),
(*::std::mem::transmute::<&[u8; 11],
&[libc::c_char; 11]>(b"mpg_decode\x00")).as_ptr(),
163 as libc::c_int,
size.wrapping_div(8 as libc::c_int as libc::c_ulong));
}
if ret == MPG123_DONE as libc::c_int ||
bytes == 0 as libc::c_int as libc::c_ulong &&
size == 0 as libc::c_int as libc::c_ulong &&
stream.state as libc::c_uint <=
DISCONNECT as libc::c_int as libc::c_uint {
pthread_mutex_unlock(&mut (*streambuf).mutex);
if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint {
logprint(b"%s %s:%d stream complete\n\x00" as *const u8 as
*const libc::c_char, logtime(),
(*::std::mem::transmute::<&[u8; 11],
&[libc::c_char; 11]>(b"mpg_decode\x00")).as_ptr(),
167 as libc::c_int);
}
return DECODE_COMPLETE
}
pthread_mutex_unlock(&mut (*streambuf).mutex);
if ret == MPG123_ERR as libc::c_int {
if loglevel as libc::c_uint >= lWARN as libc::c_int as libc::c_uint {
logprint(b"%s %s:%d Error\n\x00" as *const u8 as
*const libc::c_char, logtime(),
(*::std::mem::transmute::<&[u8; 11],
&[libc::c_char; 11]>(b"mpg_decode\x00")).as_ptr(),
174 as libc::c_int);
}
return DECODE_COMPLETE
}
// OK and NEED_MORE keep running
return DECODE_RUNNING;
}
unsafe extern "C" fn mpg_open(mut size: u8_t, mut rate: u8_t, mut chan: u8_t,
mut endianness: u8_t) {
let mut err: libc::c_int = 0;
let mut list: *const libc::c_long = 0 as *const libc::c_long;
let mut count: size_t = 0;
let mut i: size_t = 0;
if !(*m).h.is_null() {
(*m).mpg123_delete.expect("non-null function pointer")((*m).h);
}
(*m).h =
(*m).mpg123_new.expect("non-null function pointer")(0 as
*const libc::c_char,
&mut err);
if (*m).h.is_null() {
if loglevel as libc::c_uint >= lWARN as libc::c_int as libc::c_uint {
logprint(b"%s %s:%d new error: %s\n\x00" as *const u8 as
*const libc::c_char, logtime(),
(*::std::mem::transmute::<&[u8; 9],
&[libc::c_char; 9]>(b"mpg_open\x00")).as_ptr(),
194 as libc::c_int,
(*m).mpg123_plain_strerror.expect("non-null function pointer")(err));
}
}
// restrict output to 32bit or 16bit signed 2 channel based on library capability
(*m).mpg123_rates.expect("non-null function pointer")(&mut list,
&mut count);
(*m).mpg123_format_none.expect("non-null function pointer")((*m).h);
i = 0 as libc::c_int as size_t;
while i < count {
(*m).mpg123_format.expect("non-null function pointer")((*m).h,
*list.offset(i
as
isize),
2 as
libc::c_int,
if (*m).use16bit
as
libc::c_int
!= 0 {
MPG123_ENC_SIGNED_16
as
libc::c_int
} else {
MPG123_ENC_SIGNED_32
as
libc::c_int
});
i = i.wrapping_add(1)
}
err = (*m).mpg123_open_feed.expect("non-null function pointer")((*m).h);
if err != 0 {
if loglevel as libc::c_uint >= lWARN as libc::c_int as libc::c_uint {
logprint(b"%s %s:%d open feed error: %s\n\x00" as *const u8 as
*const libc::c_char, logtime(),
(*::std::mem::transmute::<&[u8; 9],
&[libc::c_char; 9]>(b"mpg_open\x00")).as_ptr(),
207 as libc::c_int,
(*m).mpg123_plain_strerror.expect("non-null function pointer")(err));
}
};
}
unsafe extern "C" fn mpg_close() {
(*m).mpg123_delete.expect("non-null function pointer")((*m).h);
(*m).h = 0 as *mut mpg123_handle;
}
unsafe extern "C" fn load_mpg() -> bool {
let mut handle: *mut libc::c_void =
dlopen(b"libmpg123.so.0\x00" as *const u8 as *const libc::c_char,
0x2 as libc::c_int);
let mut err: *mut libc::c_char = 0 as *mut libc::c_char;
if handle.is_null() {
if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint {
logprint(b"%s %s:%d dlerror: %s\n\x00" as *const u8 as
*const libc::c_char, logtime(),
(*::std::mem::transmute::<&[u8; 9],
&[libc::c_char; 9]>(b"load_mpg\x00")).as_ptr(),
222 as libc::c_int, dlerror());
}
return 0 as libc::c_int != 0
}
(*m).mpg123_init =
::std::mem::transmute::<*mut libc::c_void,
Option<unsafe extern "C" fn()
->
libc::c_int>>(dlsym(handle,
b"mpg123_init\x00"
as
*const u8
as
*const libc::c_char));
(*m).mpg123_feature =
::std::mem::transmute::<*mut libc::c_void,
Option<unsafe extern "C" fn(_:
mpg123_feature_set)
->
libc::c_int>>(dlsym(handle,
b"mpg123_feature\x00"
as
*const u8
as
*const libc::c_char));
(*m).mpg123_rates =
::std::mem::transmute::<*mut libc::c_void,
Option<unsafe extern "C" fn(_:
*mut *const libc::c_long,
_: *mut size_t)
->
()>>(dlsym(handle,
b"mpg123_rates\x00"
as *const u8 as
*const libc::c_char));
(*m).mpg123_format_none =
::std::mem::transmute::<*mut libc::c_void,
Option<unsafe extern "C" fn(_:
*mut mpg123_handle)
->
libc::c_int>>(dlsym(handle,
b"mpg123_format_none\x00"
as
*const u8
as
*const libc::c_char));
(*m).mpg123_format =
::std::mem::transmute::<*mut libc::c_void,
Option<unsafe extern "C" fn(_:
*mut mpg123_handle,
_: libc::c_long,
_: libc::c_int,
_: libc::c_int)
->
libc::c_int>>(dlsym(handle,
b"mpg123_format\x00"
as
*const u8
as
*const libc::c_char));
(*m).mpg123_new =
::std::mem::transmute::<*mut libc::c_void,
Option<unsafe extern "C" fn(_:
*const libc::c_char,
_:
*mut libc::c_int)
->
*mut mpg123_handle>>(dlsym(handle,
b"mpg123_new\x00"
as
*const u8
as
*const libc::c_char));
(*m).mpg123_delete =
::std::mem::transmute::<*mut libc::c_void,
Option<unsafe extern "C" fn(_:
*mut mpg123_handle)
->
()>>(dlsym(handle,
b"mpg123_delete\x00"
as *const u8 as
*const libc::c_char));
(*m).mpg123_open_feed =
::std::mem::transmute::<*mut libc::c_void,
Option<unsafe extern "C" fn(_:
*mut mpg123_handle)
->
libc::c_int>>(dlsym(handle,
b"mpg123_open_feed\x00"
as
*const u8
as
*const libc::c_char));
(*m).mpg123_decode =
::std::mem::transmute::<*mut libc::c_void,
Option<unsafe extern "C" fn(_:
*mut mpg123_handle,
_:
*const libc::c_uchar,
_: size_t,
_:
*mut libc::c_uchar,
_: size_t,
_: *mut size_t)
->
libc::c_int>>(dlsym(handle,
b"mpg123_decode\x00"
as
*const u8
as
*const libc::c_char));
(*m).mpg123_getformat =
::std::mem::transmute::<*mut libc::c_void,
Option<unsafe extern "C" fn(_:
*mut mpg123_handle,
_:
*mut libc::c_long,
_:
*mut libc::c_int,
_:
*mut libc::c_int)
->
libc::c_int>>(dlsym(handle,
b"mpg123_getformat\x00"
as
*const u8
as
*const libc::c_char));
(*m).mpg123_plain_strerror =
::std::mem::transmute::<*mut libc::c_void,
Option<unsafe extern "C" fn(_: libc::c_int)
->
*const libc::c_char>>(dlsym(handle,
b"mpg123_plain_strerror\x00"
as
*const u8
as
*const libc::c_char));
err = dlerror();
if !err.is_null() {
if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint {
logprint(b"%s %s:%d dlerror: %s\n\x00" as *const u8 as
*const libc::c_char, logtime(),
(*::std::mem::transmute::<&[u8; 9],
&[libc::c_char; 9]>(b"load_mpg\x00")).as_ptr(),
239 as libc::c_int, err);
}
return 0 as libc::c_int != 0
}
if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint {
logprint(b"%s %s:%d loaded libmpg123.so.0\n\x00" as *const u8 as
*const libc::c_char, logtime(),
(*::std::mem::transmute::<&[u8; 9],
&[libc::c_char; 9]>(b"load_mpg\x00")).as_ptr(),
243 as libc::c_int);
}
return 1 as libc::c_int != 0;
}
/*
* Squeezelite - lightweight headless squeezebox emulator
*
* (c) Adrian Smith 2012-2015, triode1@btinternet.com
* Ralph Irving 2015-2017, ralph_irving@hotmail.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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additions (c) Paul Hermann, 2015-2017 under the same license terms
* -Control of Raspberry pi GPIO for amplifier power
* -Launch script on power status change from LMS
*/
// make may define: PORTAUDIO, SELFPIPE, RESAMPLE, RESAMPLE_MP, VISEXPORT, GPIO, IR, DSD, LINKALL to influence build
// build detection
// dynamically loaded libraries at run time
// !LINKALL
// config options
// do not reduce as icy-meta max is 4080
/* SUN */
/* SUN */
// printf/scanf formats for u64_t
// logging
// utils.c (non logging)
// buffer.c
// _* called with mutex locked
// slimproto.c
// stream.c
// decode.c
// output.c output_alsa.c output_pa.c output_pack.c
// frames played at the point delay is measured
// ordered largest first so [0] is max_rate
// set in decode thread
// set in decode thread
// set by slimproto
// set by slimproto
// set by slimproto
// set by slimproto
// set by slimproto
// set by slimproto
// set by slimproto
// _* called with mutex locked
// output_alsa.c
// output_pa.c
// output_pulse.c
// output_stdout.c
// output_pack.c
// output_vis.c
// dop.c
// codecs
#[no_mangle]
pub unsafe extern "C" fn register_mpg() -> *mut codec {
static mut ret: codec =
unsafe {
{
let mut init =
codec{id: 'm' as i32 as libc::c_char,
types:
b"mp3\x00" as *const u8 as *const libc::c_char
as *mut libc::c_char,
min_read_bytes: 512 as libc::c_int as libc::c_uint,
min_space:
(32 as libc::c_int * 1024 as libc::c_int) as
libc::c_uint,
open:
Some(mpg_open as
unsafe extern "C" fn(_: u8_t, _: u8_t,
_: u8_t, _: u8_t)
-> ()),
close:
Some(mpg_close as unsafe extern "C" fn() -> ()),
decode:
Some(mpg_decode as
unsafe extern "C" fn()
-> decode_state),};
init
}
};
m = malloc(::std::mem::size_of::<mpg>() as libc::c_ulong) as *mut mpg;
if m.is_null() { return 0 as *mut codec }
(*m).h = 0 as *mut mpg123_handle;
if !load_mpg() { return 0 as *mut codec }
(*m).mpg123_init.expect("non-null function pointer")();
(*m).use16bit =
(*m).mpg123_feature.expect("non-null function pointer")(MPG123_FEATURE_OUTPUT_32BIT)
!= 0;
if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint {
logprint(b"%s %s:%d using mpg to decode mp3\n\x00" as *const u8 as
*const libc::c_char, logtime(),
(*::std::mem::transmute::<&[u8; 13],
&[libc::c_char; 13]>(b"register_mpg\x00")).as_ptr(),
275 as libc::c_int);
}
return &mut ret;
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,23 +0,0 @@
use ::libc;
// PORTAUDIO
// Portaudio output
/*
* Squeezelite - lightweight headless squeezebox emulator
*
* (c) Adrian Smith 2012-2015, triode1@btinternet.com
* Ralph Irving 2015-2017, ralph_irving@hotmail.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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

View File

@ -1,350 +0,0 @@
use ::libc;
extern "C" {
#[no_mangle]
fn memcpy(_: *mut libc::c_void, _: *const libc::c_void, _: libc::c_ulong)
-> *mut libc::c_void;
}
pub type __uint8_t = libc::c_uchar;
pub type __int32_t = libc::c_int;
pub type __uint32_t = libc::c_uint;
pub type __int64_t = libc::c_long;
pub type int32_t = __int32_t;
pub type int64_t = __int64_t;
pub type u_int8_t = __uint8_t;
pub type u_int32_t = __uint32_t;
pub type u8_t = u_int8_t;
pub type u32_t = u_int32_t;
pub type s32_t = int32_t;
pub type s64_t = int64_t;
pub type frames_t = u32_t;
pub type uintptr_t = libc::c_ulong;
pub type output_format = libc::c_uint;
pub const S16_LE: output_format = 3;
pub const S24_3LE: output_format = 2;
pub const S24_LE: output_format = 1;
pub const S32_LE: output_format = 0;
// inlining these on windows prevents them being linkable...
#[inline]
unsafe extern "C" fn gain(mut gain_0: s32_t, mut sample: s32_t) -> s32_t {
let mut res: s64_t = gain_0 as s64_t * sample as s64_t;
if res as libc::c_longlong > 0x7fffffffffff as libc::c_longlong {
res = 0x7fffffffffff as libc::c_longlong as s64_t
}
if (res as libc::c_longlong) < -(0x7fffffffffff as libc::c_longlong) {
res = -(0x7fffffffffff as libc::c_longlong) as s64_t
}
return (res >> 16 as libc::c_int) as s32_t;
}
#[no_mangle]
pub unsafe extern "C" fn _scale_and_pack_frames(mut outputptr:
*mut libc::c_void,
mut inputptr: *mut s32_t,
mut cnt: frames_t,
mut gainL: s32_t,
mut gainR: s32_t,
mut format: output_format) {
match format as libc::c_uint {
3 => {
let mut optr: *mut u32_t = outputptr as *mut u32_t;
if gainL == 0x10000 as libc::c_int &&
gainR == 0x10000 as libc::c_int {
loop {
let fresh0 = cnt;
cnt = cnt.wrapping_sub(1);
if !(fresh0 != 0) { break ; }
let fresh1 = optr;
optr = optr.offset(1);
*fresh1 =
(*inputptr >> 16 as libc::c_int &
0xffff as libc::c_int) as libc::c_uint |
*inputptr.offset(1 as libc::c_int as isize) as
libc::c_uint & 0xffff0000 as libc::c_uint;
inputptr = inputptr.offset(2 as libc::c_int as isize)
}
} else {
loop {
let fresh2 = cnt;
cnt = cnt.wrapping_sub(1);
if !(fresh2 != 0) { break ; }
let fresh3 = optr;
optr = optr.offset(1);
*fresh3 =
(gain(gainL, *inputptr) >> 16 as libc::c_int &
0xffff as libc::c_int) as libc::c_uint |
gain(gainR,
*inputptr.offset(1 as libc::c_int as isize))
as libc::c_uint & 0xffff0000 as libc::c_uint;
inputptr = inputptr.offset(2 as libc::c_int as isize)
}
}
}
1 => {
let mut optr_0: *mut u32_t = outputptr as *mut u32_t;
if gainL == 0x10000 as libc::c_int &&
gainR == 0x10000 as libc::c_int {
loop {
let fresh4 = cnt;
cnt = cnt.wrapping_sub(1);
if !(fresh4 != 0) { break ; }
let fresh5 = inputptr;
inputptr = inputptr.offset(1);
let fresh6 = optr_0;
optr_0 = optr_0.offset(1);
*fresh6 = (*fresh5 >> 8 as libc::c_int) as u32_t;
let fresh7 = inputptr;
inputptr = inputptr.offset(1);
let fresh8 = optr_0;
optr_0 = optr_0.offset(1);
*fresh8 = (*fresh7 >> 8 as libc::c_int) as u32_t
}
} else {
loop {
let fresh9 = cnt;
cnt = cnt.wrapping_sub(1);
if !(fresh9 != 0) { break ; }
let fresh10 = inputptr;
inputptr = inputptr.offset(1);
let fresh11 = optr_0;
optr_0 = optr_0.offset(1);
*fresh11 =
(gain(gainL, *fresh10) >> 8 as libc::c_int) as u32_t;
let fresh12 = inputptr;
inputptr = inputptr.offset(1);
let fresh13 = optr_0;
optr_0 = optr_0.offset(1);
*fresh13 =
(gain(gainR, *fresh12) >> 8 as libc::c_int) as u32_t
}
}
}
2 => {
let mut optr_1: *mut u8_t = outputptr as *mut u8_t;
if gainL == 0x10000 as libc::c_int &&
gainR == 0x10000 as libc::c_int {
while cnt != 0 {
// attempt to do 32 bit memory accesses - move 2 frames at once: 16 bytes -> 12 bytes
// falls through to exception case when not aligned or if less than 2 frames to move
if optr_1 as uintptr_t &
0x3 as libc::c_int as libc::c_ulong ==
0 as libc::c_int as libc::c_ulong &&
cnt >= 2 as libc::c_int as libc::c_uint {
let mut o_ptr: *mut u32_t =
optr_1 as *mut libc::c_void as *mut u32_t;
while cnt >= 2 as libc::c_int as libc::c_uint {
let fresh14 = inputptr;
inputptr = inputptr.offset(1);
let mut l1: s32_t = *fresh14;
let fresh15 = inputptr;
inputptr = inputptr.offset(1);
let mut r1: s32_t = *fresh15;
let fresh16 = inputptr;
inputptr = inputptr.offset(1);
let mut l2: s32_t = *fresh16;
let fresh17 = inputptr;
inputptr = inputptr.offset(1);
let mut r2: s32_t = *fresh17;
let fresh18 = o_ptr;
o_ptr = o_ptr.offset(1);
*fresh18 =
(l1 as libc::c_uint &
0xffffff00 as libc::c_uint) >>
8 as libc::c_int |
((r1 & 0xff00 as libc::c_int) <<
16 as libc::c_int) as libc::c_uint;
let fresh19 = o_ptr;
o_ptr = o_ptr.offset(1);
*fresh19 =
(r1 as libc::c_uint &
0xffff0000 as libc::c_uint) >>
16 as libc::c_int |
((l2 & 0xffff00 as libc::c_int) <<
8 as libc::c_int) as libc::c_uint;
let fresh20 = o_ptr;
o_ptr = o_ptr.offset(1);
*fresh20 =
(l2 as libc::c_uint &
0xff000000 as libc::c_uint) >>
24 as libc::c_int |
r2 as libc::c_uint &
0xffffff00 as libc::c_uint;
optr_1 =
optr_1.offset(12 as libc::c_int as isize);
cnt =
(cnt as
libc::c_uint).wrapping_sub(2 as
libc::c_int
as
libc::c_uint)
as frames_t as frames_t
}
} else {
let fresh21 = inputptr;
inputptr = inputptr.offset(1);
let mut lsample: s32_t = *fresh21;
let fresh22 = inputptr;
inputptr = inputptr.offset(1);
let mut rsample: s32_t = *fresh22;
let fresh23 = optr_1;
optr_1 = optr_1.offset(1);
*fresh23 =
((lsample & 0xff00 as libc::c_int) >>
8 as libc::c_int) as u8_t;
let fresh24 = optr_1;
optr_1 = optr_1.offset(1);
*fresh24 =
((lsample & 0xff0000 as libc::c_int) >>
16 as libc::c_int) as u8_t;
let fresh25 = optr_1;
optr_1 = optr_1.offset(1);
*fresh25 =
((lsample as libc::c_uint &
0xff000000 as libc::c_uint) >>
24 as libc::c_int) as u8_t;
let fresh26 = optr_1;
optr_1 = optr_1.offset(1);
*fresh26 =
((rsample & 0xff00 as libc::c_int) >>
8 as libc::c_int) as u8_t;
let fresh27 = optr_1;
optr_1 = optr_1.offset(1);
*fresh27 =
((rsample & 0xff0000 as libc::c_int) >>
16 as libc::c_int) as u8_t;
let fresh28 = optr_1;
optr_1 = optr_1.offset(1);
*fresh28 =
((rsample as libc::c_uint &
0xff000000 as libc::c_uint) >>
24 as libc::c_int) as u8_t;
cnt = cnt.wrapping_sub(1)
}
}
} else {
while cnt != 0 {
// attempt to do 32 bit memory accesses - move 2 frames at once: 16 bytes -> 12 bytes
// falls through to exception case when not aligned or if less than 2 frames to move
if optr_1 as uintptr_t &
0x3 as libc::c_int as libc::c_ulong ==
0 as libc::c_int as libc::c_ulong &&
cnt >= 2 as libc::c_int as libc::c_uint {
let mut o_ptr_0: *mut u32_t =
optr_1 as *mut libc::c_void as *mut u32_t;
while cnt >= 2 as libc::c_int as libc::c_uint {
let fresh29 = inputptr;
inputptr = inputptr.offset(1);
let mut l1_0: s32_t = gain(gainL, *fresh29);
let fresh30 = inputptr;
inputptr = inputptr.offset(1);
let mut r1_0: s32_t = gain(gainR, *fresh30);
let fresh31 = inputptr;
inputptr = inputptr.offset(1);
let mut l2_0: s32_t = gain(gainL, *fresh31);
let fresh32 = inputptr;
inputptr = inputptr.offset(1);
let mut r2_0: s32_t = gain(gainR, *fresh32);
let fresh33 = o_ptr_0;
o_ptr_0 = o_ptr_0.offset(1);
*fresh33 =
(l1_0 as libc::c_uint &
0xffffff00 as libc::c_uint) >>
8 as libc::c_int |
((r1_0 & 0xff00 as libc::c_int) <<
16 as libc::c_int) as libc::c_uint;
let fresh34 = o_ptr_0;
o_ptr_0 = o_ptr_0.offset(1);
*fresh34 =
(r1_0 as libc::c_uint &
0xffff0000 as libc::c_uint) >>
16 as libc::c_int |
((l2_0 & 0xffff00 as libc::c_int) <<
8 as libc::c_int) as libc::c_uint;
let fresh35 = o_ptr_0;
o_ptr_0 = o_ptr_0.offset(1);
*fresh35 =
(l2_0 as libc::c_uint &
0xff000000 as libc::c_uint) >>
24 as libc::c_int |
r2_0 as libc::c_uint &
0xffffff00 as libc::c_uint;
optr_1 =
optr_1.offset(12 as libc::c_int as isize);
cnt =
(cnt as
libc::c_uint).wrapping_sub(2 as
libc::c_int
as
libc::c_uint)
as frames_t as frames_t
}
} else {
let fresh36 = inputptr;
inputptr = inputptr.offset(1);
let mut lsample_0: s32_t = gain(gainL, *fresh36);
let fresh37 = inputptr;
inputptr = inputptr.offset(1);
let mut rsample_0: s32_t = gain(gainR, *fresh37);
let fresh38 = optr_1;
optr_1 = optr_1.offset(1);
*fresh38 =
((lsample_0 & 0xff00 as libc::c_int) >>
8 as libc::c_int) as u8_t;
let fresh39 = optr_1;
optr_1 = optr_1.offset(1);
*fresh39 =
((lsample_0 & 0xff0000 as libc::c_int) >>
16 as libc::c_int) as u8_t;
let fresh40 = optr_1;
optr_1 = optr_1.offset(1);
*fresh40 =
((lsample_0 as libc::c_uint &
0xff000000 as libc::c_uint) >>
24 as libc::c_int) as u8_t;
let fresh41 = optr_1;
optr_1 = optr_1.offset(1);
*fresh41 =
((rsample_0 & 0xff00 as libc::c_int) >>
8 as libc::c_int) as u8_t;
let fresh42 = optr_1;
optr_1 = optr_1.offset(1);
*fresh42 =
((rsample_0 & 0xff0000 as libc::c_int) >>
16 as libc::c_int) as u8_t;
let fresh43 = optr_1;
optr_1 = optr_1.offset(1);
*fresh43 =
((rsample_0 as libc::c_uint &
0xff000000 as libc::c_uint) >>
24 as libc::c_int) as u8_t;
cnt = cnt.wrapping_sub(1)
}
}
}
}
0 => {
let mut optr_2: *mut u32_t = outputptr as *mut u32_t;
if gainL == 0x10000 as libc::c_int &&
gainR == 0x10000 as libc::c_int {
memcpy(outputptr, inputptr as *const libc::c_void,
cnt.wrapping_mul(8 as libc::c_int as libc::c_uint) as
libc::c_ulong);
} else {
loop {
let fresh44 = cnt;
cnt = cnt.wrapping_sub(1);
if !(fresh44 != 0) { break ; }
let fresh45 = inputptr;
inputptr = inputptr.offset(1);
let fresh46 = optr_2;
optr_2 = optr_2.offset(1);
*fresh46 = gain(gainL, *fresh45) as u32_t;
let fresh47 = inputptr;
inputptr = inputptr.offset(1);
let fresh48 = optr_2;
optr_2 = optr_2.offset(1);
*fresh48 = gain(gainR, *fresh47) as u32_t
}
}
}
_ => { }
};
}

View File

@ -1,25 +0,0 @@
use ::libc;
// Output using PulseAudio
/*
* Squeezelite - lightweight headless squeezebox emulator
*
* (c) Adrian Smith 2012-2015, triode1@btinternet.com
* Ralph Irving 2015-2020, ralph_irving@hotmail.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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additions (c) Paul Hermann, 2015-2017 under the same license terms
* -Control of Raspberry pi GPIO for amplifier power
* -Launch script on power status change from LMS
*/

View File

@ -1,453 +0,0 @@
use ::libc;
extern "C" {
pub type _IO_wide_data;
pub type _IO_codecvt;
pub type _IO_marker;
#[no_mangle]
static mut stdout: *mut FILE;
#[no_mangle]
fn fwrite(_: *const libc::c_void, _: libc::c_ulong, _: libc::c_ulong,
_: *mut FILE) -> libc::c_ulong;
#[no_mangle]
fn malloc(_: libc::c_ulong) -> *mut libc::c_void;
#[no_mangle]
fn free(__ptr: *mut libc::c_void);
#[no_mangle]
fn memset(_: *mut libc::c_void, _: libc::c_int, _: libc::c_ulong)
-> *mut libc::c_void;
#[no_mangle]
fn strcmp(_: *const libc::c_char, _: *const libc::c_char) -> libc::c_int;
#[no_mangle]
fn _apply_cross(outputbuf_0: *mut buffer, out_frames: frames_t,
cross_gain_in: s32_t, cross_gain_out: s32_t,
cross_ptr: *mut *mut s32_t);
#[no_mangle]
fn _scale_and_pack_frames(outputptr: *mut libc::c_void,
inputptr: *mut s32_t, cnt: frames_t,
gainL: s32_t, gainR: s32_t,
format: output_format);
#[no_mangle]
fn _output_frames(avail: frames_t) -> frames_t;
#[no_mangle]
fn output_close_common();
#[no_mangle]
fn output_init_common(level: log_level, device: *const libc::c_char,
output_buf_size: libc::c_uint,
rates: *mut libc::c_uint, idle: libc::c_uint);
#[no_mangle]
fn pthread_create(__newthread: *mut pthread_t,
__attr: *const pthread_attr_t,
__start_routine:
Option<unsafe extern "C" fn(_: *mut libc::c_void)
-> *mut libc::c_void>,
__arg: *mut libc::c_void) -> libc::c_int;
#[no_mangle]
fn pthread_attr_init(__attr: *mut pthread_attr_t) -> libc::c_int;
#[no_mangle]
fn pthread_attr_destroy(__attr: *mut pthread_attr_t) -> libc::c_int;
#[no_mangle]
fn pthread_attr_setstacksize(__attr: *mut pthread_attr_t,
__stacksize: size_t) -> libc::c_int;
#[no_mangle]
fn pthread_mutex_lock(__mutex: *mut pthread_mutex_t) -> libc::c_int;
#[no_mangle]
fn pthread_mutex_unlock(__mutex: *mut pthread_mutex_t) -> libc::c_int;
#[no_mangle]
fn logtime() -> *const libc::c_char;
#[no_mangle]
fn logprint(fmt: *const libc::c_char, _: ...);
#[no_mangle]
fn gettime_ms() -> u32_t;
#[no_mangle]
static mut output: outputstate;
#[no_mangle]
static mut outputbuf: *mut buffer;
#[no_mangle]
static mut silencebuf: *mut u8_t;
}
pub type size_t = libc::c_ulong;
pub type __uint8_t = libc::c_uchar;
pub type __int32_t = libc::c_int;
pub type __uint32_t = libc::c_uint;
pub type __off_t = libc::c_long;
pub type __off64_t = libc::c_long;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct _IO_FILE {
pub _flags: libc::c_int,
pub _IO_read_ptr: *mut libc::c_char,
pub _IO_read_end: *mut libc::c_char,
pub _IO_read_base: *mut libc::c_char,
pub _IO_write_base: *mut libc::c_char,
pub _IO_write_ptr: *mut libc::c_char,
pub _IO_write_end: *mut libc::c_char,
pub _IO_buf_base: *mut libc::c_char,
pub _IO_buf_end: *mut libc::c_char,
pub _IO_save_base: *mut libc::c_char,
pub _IO_backup_base: *mut libc::c_char,
pub _IO_save_end: *mut libc::c_char,
pub _markers: *mut _IO_marker,
pub _chain: *mut _IO_FILE,
pub _fileno: libc::c_int,
pub _flags2: libc::c_int,
pub _old_offset: __off_t,
pub _cur_column: libc::c_ushort,
pub _vtable_offset: libc::c_schar,
pub _shortbuf: [libc::c_char; 1],
pub _lock: *mut libc::c_void,
pub _offset: __off64_t,
pub _codecvt: *mut _IO_codecvt,
pub _wide_data: *mut _IO_wide_data,
pub _freeres_list: *mut _IO_FILE,
pub _freeres_buf: *mut libc::c_void,
pub __pad5: size_t,
pub _mode: libc::c_int,
pub _unused2: [libc::c_char; 20],
}
pub type _IO_lock_t = ();
pub type FILE = _IO_FILE;
pub type int32_t = __int32_t;
pub type u_int8_t = __uint8_t;
pub type u_int32_t = __uint32_t;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct __pthread_internal_list {
pub __prev: *mut __pthread_internal_list,
pub __next: *mut __pthread_internal_list,
}
pub type __pthread_list_t = __pthread_internal_list;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct __pthread_mutex_s {
pub __lock: libc::c_int,
pub __count: libc::c_uint,
pub __owner: libc::c_int,
pub __nusers: libc::c_uint,
pub __kind: libc::c_int,
pub __spins: libc::c_short,
pub __elision: libc::c_short,
pub __list: __pthread_list_t,
}
pub type pthread_t = libc::c_ulong;
#[derive(Copy, Clone)]
#[repr(C)]
pub union pthread_attr_t {
pub __size: [libc::c_char; 56],
pub __align: libc::c_long,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub union pthread_mutex_t {
pub __data: __pthread_mutex_s,
pub __size: [libc::c_char; 40],
pub __align: libc::c_long,
}
pub type u8_t = u_int8_t;
pub type u32_t = u_int32_t;
pub type s32_t = int32_t;
pub type frames_t = u32_t;
pub type log_level = libc::c_uint;
pub const lSDEBUG: log_level = 4;
pub const lDEBUG: log_level = 3;
pub const lINFO: log_level = 2;
pub const lWARN: log_level = 1;
pub const lERROR: log_level = 0;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct buffer {
pub buf: *mut u8_t,
pub readp: *mut u8_t,
pub writep: *mut u8_t,
pub wrap: *mut u8_t,
pub size: size_t,
pub base_size: size_t,
pub mutex: pthread_mutex_t,
}
pub type output_state = libc::c_int;
pub const OUTPUT_START_AT: output_state = 5;
pub const OUTPUT_SKIP_FRAMES: output_state = 4;
pub const OUTPUT_PAUSE_FRAMES: output_state = 3;
pub const OUTPUT_RUNNING: output_state = 2;
pub const OUTPUT_BUFFER: output_state = 1;
pub const OUTPUT_STOPPED: output_state = 0;
pub const OUTPUT_OFF: output_state = -1;
pub type output_format = libc::c_uint;
pub const S16_LE: output_format = 3;
pub const S24_3LE: output_format = 2;
pub const S24_LE: output_format = 1;
pub const S32_LE: output_format = 0;
pub type fade_state = libc::c_uint;
pub const FADE_ACTIVE: fade_state = 2;
pub const FADE_DUE: fade_state = 1;
pub const FADE_INACTIVE: fade_state = 0;
pub type fade_dir = libc::c_uint;
pub const FADE_CROSS: fade_dir = 3;
pub const FADE_DOWN: fade_dir = 2;
pub const FADE_UP: fade_dir = 1;
pub type fade_mode = libc::c_uint;
pub const FADE_INOUT: fade_mode = 4;
pub const FADE_OUT: fade_mode = 3;
pub const FADE_IN: fade_mode = 2;
pub const FADE_CROSSFADE: fade_mode = 1;
pub const FADE_NONE: fade_mode = 0;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct outputstate {
pub state: output_state,
pub format: output_format,
pub device: *const libc::c_char,
pub buffer: libc::c_uint,
pub period: libc::c_uint,
pub track_started: bool,
pub write_cb: Option<unsafe extern "C" fn(_: frames_t, _: bool, _: s32_t,
_: s32_t, _: s32_t, _: s32_t,
_: *mut *mut s32_t)
-> libc::c_int>,
pub start_frames: libc::c_uint,
pub frames_played: libc::c_uint,
pub frames_played_dmp: libc::c_uint,
pub current_sample_rate: libc::c_uint,
pub supported_rates: [libc::c_uint; 18],
pub default_sample_rate: libc::c_uint,
pub error_opening: bool,
pub device_frames: libc::c_uint,
pub updated: u32_t,
pub track_start_time: u32_t,
pub current_replay_gain: u32_t,
pub c2rust_unnamed: C2RustUnnamed,
pub next_sample_rate: libc::c_uint,
pub track_start: *mut u8_t,
pub gainL: u32_t,
pub gainR: u32_t,
pub invert: bool,
pub next_replay_gain: u32_t,
pub threshold: libc::c_uint,
pub fade: fade_state,
pub fade_start: *mut u8_t,
pub fade_end: *mut u8_t,
pub fade_dir: fade_dir,
pub fade_mode: fade_mode,
pub fade_secs: libc::c_uint,
pub rate_delay: libc::c_uint,
pub delay_active: bool,
pub stop_time: u32_t,
pub idle_to: u32_t,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub union C2RustUnnamed {
pub pause_frames: u32_t,
pub skip_frames: u32_t,
pub start_at: u32_t,
}
static mut loglevel: log_level = lERROR;
static mut running: bool = 1 as libc::c_int != 0;
// buffer to hold output data so we can block on writing outside of output lock, allocated on init
static mut buf: *mut u8_t = 0 as *const u8_t as *mut u8_t;
static mut buffill: libc::c_uint = 0;
static mut bytes_per_frame: libc::c_int = 0;
unsafe extern "C" fn _stdout_write_frames(mut out_frames: frames_t,
mut silence: bool, mut gainL: s32_t,
mut gainR: s32_t,
mut cross_gain_in: s32_t,
mut cross_gain_out: s32_t,
mut cross_ptr: *mut *mut s32_t)
-> libc::c_int {
let mut obuf: *mut u8_t = 0 as *mut u8_t;
if !silence {
if output.fade as libc::c_uint ==
FADE_ACTIVE as libc::c_int as libc::c_uint &&
output.fade_dir as libc::c_uint ==
FADE_CROSS as libc::c_int as libc::c_uint &&
!(*cross_ptr).is_null() {
_apply_cross(outputbuf, out_frames, cross_gain_in, cross_gain_out,
cross_ptr);
}
obuf = (*outputbuf).readp
} else { obuf = silencebuf }
_scale_and_pack_frames(buf.offset(buffill.wrapping_mul(bytes_per_frame as
libc::c_uint)
as isize) as *mut libc::c_void,
obuf as *mut libc::c_void as *mut s32_t,
out_frames, gainL, gainR, output.format);
buffill = buffill.wrapping_add(out_frames);
return out_frames as libc::c_int;
}
unsafe extern "C" fn output_thread() -> *mut libc::c_void {
pthread_mutex_lock(&mut (*outputbuf).mutex);
match output.format as libc::c_uint {
0 => { bytes_per_frame = 4 as libc::c_int * 2 as libc::c_int }
2 => { bytes_per_frame = 3 as libc::c_int * 2 as libc::c_int }
3 => { bytes_per_frame = 2 as libc::c_int * 2 as libc::c_int }
_ => { bytes_per_frame = 4 as libc::c_int * 2 as libc::c_int }
}
pthread_mutex_unlock(&mut (*outputbuf).mutex);
while running {
pthread_mutex_lock(&mut (*outputbuf).mutex);
output.device_frames = 0 as libc::c_int as libc::c_uint;
output.updated = gettime_ms();
output.frames_played_dmp = output.frames_played;
_output_frames(2048 as libc::c_int as frames_t);
pthread_mutex_unlock(&mut (*outputbuf).mutex);
if buffill != 0 {
fwrite(buf as *const libc::c_void,
bytes_per_frame as libc::c_ulong, buffill as libc::c_ulong,
stdout);
buffill = 0 as libc::c_int as libc::c_uint
}
}
return 0 as *mut libc::c_void;
}
static mut thread: pthread_t = 0;
#[no_mangle]
pub unsafe extern "C" fn output_init_stdout(mut level: log_level,
mut output_buf_size: libc::c_uint,
mut params: *mut libc::c_char,
mut rates: *mut libc::c_uint,
mut rate_delay: libc::c_uint) {
loglevel = level;
if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint {
logprint(b"%s %s:%d init output stdout\n\x00" as *const u8 as
*const libc::c_char, logtime(),
(*::std::mem::transmute::<&[u8; 19],
&[libc::c_char; 19]>(b"output_init_stdout\x00")).as_ptr(),
130 as libc::c_int);
}
buf =
malloc((2048 as libc::c_int * 8 as libc::c_int) as libc::c_ulong) as
*mut u8_t;
if buf.is_null() {
logprint(b"%s %s:%d unable to malloc buf\n\x00" as *const u8 as
*const libc::c_char, logtime(),
(*::std::mem::transmute::<&[u8; 19],
&[libc::c_char; 19]>(b"output_init_stdout\x00")).as_ptr(),
134 as libc::c_int);
return
}
buffill = 0 as libc::c_int as libc::c_uint;
memset(&mut output as *mut outputstate as *mut libc::c_void,
0 as libc::c_int,
::std::mem::size_of::<outputstate>() as libc::c_ulong);
output.format = S32_LE;
output.start_frames =
(2048 as libc::c_int * 2 as libc::c_int) as libc::c_uint;
output.write_cb =
Some(_stdout_write_frames as
unsafe extern "C" fn(_: frames_t, _: bool, _: s32_t,
_: s32_t, _: s32_t, _: s32_t,
_: *mut *mut s32_t) -> libc::c_int);
output.rate_delay = rate_delay;
if !params.is_null() {
if strcmp(params, b"32\x00" as *const u8 as *const libc::c_char) == 0
{
output.format = S32_LE
}
if strcmp(params, b"24\x00" as *const u8 as *const libc::c_char) == 0
{
output.format = S24_3LE
}
if strcmp(params, b"16\x00" as *const u8 as *const libc::c_char) == 0
{
output.format = S16_LE
}
}
// ensure output rate is specified to avoid test open
if *rates.offset(0 as libc::c_int as isize) == 0 {
*rates.offset(0 as libc::c_int as isize) =
44100 as libc::c_int as libc::c_uint
}
output_init_common(level, b"-\x00" as *const u8 as *const libc::c_char,
output_buf_size, rates,
0 as libc::c_int as libc::c_uint);
let mut attr: pthread_attr_t = pthread_attr_t{__size: [0; 56],};
pthread_attr_init(&mut attr);
pthread_attr_setstacksize(&mut attr,
(16384 as libc::c_int +
64 as libc::c_int * 1024 as libc::c_int) as
size_t);
pthread_create(&mut thread, &mut attr,
::std::mem::transmute::<Option<unsafe extern "C" fn()
-> *mut libc::c_void>,
Option<unsafe extern "C" fn(_:
*mut libc::c_void)
->
*mut libc::c_void>>(Some(::std::mem::transmute::<unsafe extern "C" fn()
->
*mut libc::c_void,
unsafe extern "C" fn()
->
*mut libc::c_void>(output_thread))),
0 as *mut libc::c_void);
pthread_attr_destroy(&mut attr);
}
/*
* Squeezelite - lightweight headless squeezebox emulator
*
* (c) Adrian Smith 2012-2015, triode1@btinternet.com
* Ralph Irving 2015-2017, ralph_irving@hotmail.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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additions (c) Paul Hermann, 2015-2017 under the same license terms
* -Control of Raspberry pi GPIO for amplifier power
* -Launch script on power status change from LMS
*/
// make may define: PORTAUDIO, SELFPIPE, RESAMPLE, RESAMPLE_MP, VISEXPORT, GPIO, IR, DSD, LINKALL to influence build
// build detection
// dynamically loaded libraries at run time
// !LINKALL
// config options
// do not reduce as icy-meta max is 4080
/* SUN */
/* SUN */
// printf/scanf formats for u64_t
// logging
// utils.c (non logging)
// buffer.c
// _* called with mutex locked
// slimproto.c
// stream.c
// decode.c
// output.c output_alsa.c output_pa.c output_pack.c
// frames played at the point delay is measured
// ordered largest first so [0] is max_rate
// set in decode thread
// set in decode thread
// set by slimproto
// set by slimproto
// set by slimproto
// set by slimproto
// set by slimproto
// set by slimproto
// set by slimproto
// _* called with mutex locked
// output_alsa.c
// output_pa.c
// output_pulse.c
// output_stdout.c
#[no_mangle]
pub unsafe extern "C" fn output_close_stdout() {
if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint {
logprint(b"%s %s:%d close output\n\x00" as *const u8 as
*const libc::c_char, logtime(),
(*::std::mem::transmute::<&[u8; 20],
&[libc::c_char; 20]>(b"output_close_stdout\x00")).as_ptr(),
174 as libc::c_int);
}
pthread_mutex_lock(&mut (*outputbuf).mutex);
running = 0 as libc::c_int != 0;
pthread_mutex_unlock(&mut (*outputbuf).mutex);
free(buf as *mut libc::c_void);
output_close_common();
}

1075
src/pcm.rs

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,919 +0,0 @@
use ::libc;
use ::c2rust_asm_casts;
use c2rust_asm_casts::AsmCastTrait;
extern "C" {
pub type _IO_wide_data;
pub type _IO_codecvt;
pub type _IO_marker;
#[no_mangle]
static mut stderr: *mut FILE;
#[no_mangle]
fn fflush(__stream: *mut FILE) -> libc::c_int;
#[no_mangle]
fn sprintf(_: *mut libc::c_char, _: *const libc::c_char, _: ...)
-> libc::c_int;
#[no_mangle]
fn vfprintf(_: *mut FILE, _: *const libc::c_char, _: ::std::ffi::VaList)
-> libc::c_int;
#[no_mangle]
fn sscanf(_: *const libc::c_char, _: *const libc::c_char, _: ...)
-> libc::c_int;
#[no_mangle]
fn atoi(__nptr: *const libc::c_char) -> libc::c_int;
#[no_mangle]
fn select(__nfds: libc::c_int, __readfds: *mut fd_set,
__writefds: *mut fd_set, __exceptfds: *mut fd_set,
__timeout: *mut timeval) -> libc::c_int;
#[no_mangle]
fn getenv(__name: *const libc::c_char) -> *mut libc::c_char;
#[no_mangle]
fn memcpy(_: *mut libc::c_void, _: *const libc::c_void, _: libc::c_ulong)
-> *mut libc::c_void;
#[no_mangle]
fn memset(_: *mut libc::c_void, _: libc::c_int, _: libc::c_ulong)
-> *mut libc::c_void;
#[no_mangle]
fn strncpy(_: *mut libc::c_char, _: *const libc::c_char, _: libc::c_ulong)
-> *mut libc::c_char;
#[no_mangle]
fn strchr(_: *const libc::c_char, _: libc::c_int) -> *mut libc::c_char;
#[no_mangle]
fn strtok(_: *mut libc::c_char, _: *const libc::c_char)
-> *mut libc::c_char;
#[no_mangle]
fn strlen(_: *const libc::c_char) -> libc::c_ulong;
#[no_mangle]
fn __errno_location() -> *mut libc::c_int;
#[no_mangle]
fn close(__fd: libc::c_int) -> libc::c_int;
#[no_mangle]
fn socket(__domain: libc::c_int, __type: libc::c_int,
__protocol: libc::c_int) -> libc::c_int;
#[no_mangle]
fn connect(__fd: libc::c_int, __addr: *const sockaddr, __len: socklen_t)
-> libc::c_int;
#[no_mangle]
fn getsockopt(__fd: libc::c_int, __level: libc::c_int,
__optname: libc::c_int, __optval: *mut libc::c_void,
__optlen: *mut socklen_t) -> libc::c_int;
#[no_mangle]
fn gettimeofday(__tv: *mut timeval, __tz: __timezone_ptr_t)
-> libc::c_int;
#[no_mangle]
fn poll(__fds: *mut pollfd, __nfds: nfds_t, __timeout: libc::c_int)
-> libc::c_int;
#[no_mangle]
fn strftime(__s: *mut libc::c_char, __maxsize: size_t,
__format: *const libc::c_char, __tp: *const tm) -> size_t;
#[no_mangle]
fn localtime(__timer: *const time_t) -> *mut tm;
#[no_mangle]
fn clock_gettime(__clock_id: clockid_t, __tp: *mut timespec)
-> libc::c_int;
#[no_mangle]
fn eventfd_read(__fd: libc::c_int, __value: *mut eventfd_t)
-> libc::c_int;
#[no_mangle]
fn sysconf(__name: libc::c_int) -> libc::c_long;
#[no_mangle]
fn ioctl(__fd: libc::c_int, __request: libc::c_ulong, _: ...)
-> libc::c_int;
#[no_mangle]
fn getaddrinfo(__name: *const libc::c_char,
__service: *const libc::c_char, __req: *const addrinfo,
__pai: *mut *mut addrinfo) -> libc::c_int;
#[no_mangle]
fn freeaddrinfo(__ai: *mut addrinfo);
#[no_mangle]
fn fcntl(__fd: libc::c_int, __cmd: libc::c_int, _: ...) -> libc::c_int;
}
pub type __builtin_va_list = [__va_list_tag; 1];
#[derive(Copy, Clone)]
#[repr(C)]
pub struct __va_list_tag {
pub gp_offset: libc::c_uint,
pub fp_offset: libc::c_uint,
pub overflow_arg_area: *mut libc::c_void,
pub reg_save_area: *mut libc::c_void,
}
pub type size_t = libc::c_ulong;
pub type va_list = __builtin_va_list;
pub type __uint8_t = libc::c_uchar;
pub type __uint16_t = libc::c_ushort;
pub type __uint32_t = libc::c_uint;
pub type __uint64_t = libc::c_ulong;
pub type __off_t = libc::c_long;
pub type __off64_t = libc::c_long;
pub type __time_t = libc::c_long;
pub type __suseconds_t = libc::c_long;
pub type __clockid_t = libc::c_int;
pub type __syscall_slong_t = libc::c_long;
pub type __caddr_t = *mut libc::c_char;
pub type __socklen_t = libc::c_uint;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct _IO_FILE {
pub _flags: libc::c_int,
pub _IO_read_ptr: *mut libc::c_char,
pub _IO_read_end: *mut libc::c_char,
pub _IO_read_base: *mut libc::c_char,
pub _IO_write_base: *mut libc::c_char,
pub _IO_write_ptr: *mut libc::c_char,
pub _IO_write_end: *mut libc::c_char,
pub _IO_buf_base: *mut libc::c_char,
pub _IO_buf_end: *mut libc::c_char,
pub _IO_save_base: *mut libc::c_char,
pub _IO_backup_base: *mut libc::c_char,
pub _IO_save_end: *mut libc::c_char,
pub _markers: *mut _IO_marker,
pub _chain: *mut _IO_FILE,
pub _fileno: libc::c_int,
pub _flags2: libc::c_int,
pub _old_offset: __off_t,
pub _cur_column: libc::c_ushort,
pub _vtable_offset: libc::c_schar,
pub _shortbuf: [libc::c_char; 1],
pub _lock: *mut libc::c_void,
pub _offset: __off64_t,
pub _codecvt: *mut _IO_codecvt,
pub _wide_data: *mut _IO_wide_data,
pub _freeres_list: *mut _IO_FILE,
pub _freeres_buf: *mut libc::c_void,
pub __pad5: size_t,
pub _mode: libc::c_int,
pub _unused2: [libc::c_char; 20],
}
pub type _IO_lock_t = ();
pub type FILE = _IO_FILE;
pub type clockid_t = __clockid_t;
pub type time_t = __time_t;
pub type u_int8_t = __uint8_t;
pub type u_int16_t = __uint16_t;
pub type u_int32_t = __uint32_t;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct timeval {
pub tv_sec: __time_t,
pub tv_usec: __suseconds_t,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct timespec {
pub tv_sec: __time_t,
pub tv_nsec: __syscall_slong_t,
}
pub type __fd_mask = libc::c_long;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct fd_set {
pub __fds_bits: [__fd_mask; 16],
}
pub type socklen_t = __socklen_t;
pub type C2RustUnnamed = libc::c_uint;
pub const _SC_THREAD_ROBUST_PRIO_PROTECT: C2RustUnnamed = 248;
pub const _SC_THREAD_ROBUST_PRIO_INHERIT: C2RustUnnamed = 247;
pub const _SC_XOPEN_STREAMS: C2RustUnnamed = 246;
pub const _SC_TRACE_USER_EVENT_MAX: C2RustUnnamed = 245;
pub const _SC_TRACE_SYS_MAX: C2RustUnnamed = 244;
pub const _SC_TRACE_NAME_MAX: C2RustUnnamed = 243;
pub const _SC_TRACE_EVENT_NAME_MAX: C2RustUnnamed = 242;
pub const _SC_SS_REPL_MAX: C2RustUnnamed = 241;
pub const _SC_V7_LPBIG_OFFBIG: C2RustUnnamed = 240;
pub const _SC_V7_LP64_OFF64: C2RustUnnamed = 239;
pub const _SC_V7_ILP32_OFFBIG: C2RustUnnamed = 238;
pub const _SC_V7_ILP32_OFF32: C2RustUnnamed = 237;
pub const _SC_RAW_SOCKETS: C2RustUnnamed = 236;
pub const _SC_IPV6: C2RustUnnamed = 235;
pub const _SC_LEVEL4_CACHE_LINESIZE: C2RustUnnamed = 199;
pub const _SC_LEVEL4_CACHE_ASSOC: C2RustUnnamed = 198;
pub const _SC_LEVEL4_CACHE_SIZE: C2RustUnnamed = 197;
pub const _SC_LEVEL3_CACHE_LINESIZE: C2RustUnnamed = 196;
pub const _SC_LEVEL3_CACHE_ASSOC: C2RustUnnamed = 195;
pub const _SC_LEVEL3_CACHE_SIZE: C2RustUnnamed = 194;
pub const _SC_LEVEL2_CACHE_LINESIZE: C2RustUnnamed = 193;
pub const _SC_LEVEL2_CACHE_ASSOC: C2RustUnnamed = 192;
pub const _SC_LEVEL2_CACHE_SIZE: C2RustUnnamed = 191;
pub const _SC_LEVEL1_DCACHE_LINESIZE: C2RustUnnamed = 190;
pub const _SC_LEVEL1_DCACHE_ASSOC: C2RustUnnamed = 189;
pub const _SC_LEVEL1_DCACHE_SIZE: C2RustUnnamed = 188;
pub const _SC_LEVEL1_ICACHE_LINESIZE: C2RustUnnamed = 187;
pub const _SC_LEVEL1_ICACHE_ASSOC: C2RustUnnamed = 186;
pub const _SC_LEVEL1_ICACHE_SIZE: C2RustUnnamed = 185;
pub const _SC_TRACE_LOG: C2RustUnnamed = 184;
pub const _SC_TRACE_INHERIT: C2RustUnnamed = 183;
pub const _SC_TRACE_EVENT_FILTER: C2RustUnnamed = 182;
pub const _SC_TRACE: C2RustUnnamed = 181;
pub const _SC_HOST_NAME_MAX: C2RustUnnamed = 180;
pub const _SC_V6_LPBIG_OFFBIG: C2RustUnnamed = 179;
pub const _SC_V6_LP64_OFF64: C2RustUnnamed = 178;
pub const _SC_V6_ILP32_OFFBIG: C2RustUnnamed = 177;
pub const _SC_V6_ILP32_OFF32: C2RustUnnamed = 176;
pub const _SC_2_PBS_CHECKPOINT: C2RustUnnamed = 175;
pub const _SC_STREAMS: C2RustUnnamed = 174;
pub const _SC_SYMLOOP_MAX: C2RustUnnamed = 173;
pub const _SC_2_PBS_TRACK: C2RustUnnamed = 172;
pub const _SC_2_PBS_MESSAGE: C2RustUnnamed = 171;
pub const _SC_2_PBS_LOCATE: C2RustUnnamed = 170;
pub const _SC_2_PBS_ACCOUNTING: C2RustUnnamed = 169;
pub const _SC_2_PBS: C2RustUnnamed = 168;
pub const _SC_USER_GROUPS_R: C2RustUnnamed = 167;
pub const _SC_USER_GROUPS: C2RustUnnamed = 166;
pub const _SC_TYPED_MEMORY_OBJECTS: C2RustUnnamed = 165;
pub const _SC_TIMEOUTS: C2RustUnnamed = 164;
pub const _SC_SYSTEM_DATABASE_R: C2RustUnnamed = 163;
pub const _SC_SYSTEM_DATABASE: C2RustUnnamed = 162;
pub const _SC_THREAD_SPORADIC_SERVER: C2RustUnnamed = 161;
pub const _SC_SPORADIC_SERVER: C2RustUnnamed = 160;
pub const _SC_SPAWN: C2RustUnnamed = 159;
pub const _SC_SIGNALS: C2RustUnnamed = 158;
pub const _SC_SHELL: C2RustUnnamed = 157;
pub const _SC_REGEX_VERSION: C2RustUnnamed = 156;
pub const _SC_REGEXP: C2RustUnnamed = 155;
pub const _SC_SPIN_LOCKS: C2RustUnnamed = 154;
pub const _SC_READER_WRITER_LOCKS: C2RustUnnamed = 153;
pub const _SC_NETWORKING: C2RustUnnamed = 152;
pub const _SC_SINGLE_PROCESS: C2RustUnnamed = 151;
pub const _SC_MULTI_PROCESS: C2RustUnnamed = 150;
pub const _SC_MONOTONIC_CLOCK: C2RustUnnamed = 149;
pub const _SC_FILE_SYSTEM: C2RustUnnamed = 148;
pub const _SC_FILE_LOCKING: C2RustUnnamed = 147;
pub const _SC_FILE_ATTRIBUTES: C2RustUnnamed = 146;
pub const _SC_PIPE: C2RustUnnamed = 145;
pub const _SC_FIFO: C2RustUnnamed = 144;
pub const _SC_FD_MGMT: C2RustUnnamed = 143;
pub const _SC_DEVICE_SPECIFIC_R: C2RustUnnamed = 142;
pub const _SC_DEVICE_SPECIFIC: C2RustUnnamed = 141;
pub const _SC_DEVICE_IO: C2RustUnnamed = 140;
pub const _SC_THREAD_CPUTIME: C2RustUnnamed = 139;
pub const _SC_CPUTIME: C2RustUnnamed = 138;
pub const _SC_CLOCK_SELECTION: C2RustUnnamed = 137;
pub const _SC_C_LANG_SUPPORT_R: C2RustUnnamed = 136;
pub const _SC_C_LANG_SUPPORT: C2RustUnnamed = 135;
pub const _SC_BASE: C2RustUnnamed = 134;
pub const _SC_BARRIERS: C2RustUnnamed = 133;
pub const _SC_ADVISORY_INFO: C2RustUnnamed = 132;
pub const _SC_XOPEN_REALTIME_THREADS: C2RustUnnamed = 131;
pub const _SC_XOPEN_REALTIME: C2RustUnnamed = 130;
pub const _SC_XOPEN_LEGACY: C2RustUnnamed = 129;
pub const _SC_XBS5_LPBIG_OFFBIG: C2RustUnnamed = 128;
pub const _SC_XBS5_LP64_OFF64: C2RustUnnamed = 127;
pub const _SC_XBS5_ILP32_OFFBIG: C2RustUnnamed = 126;
pub const _SC_XBS5_ILP32_OFF32: C2RustUnnamed = 125;
pub const _SC_NL_TEXTMAX: C2RustUnnamed = 124;
pub const _SC_NL_SETMAX: C2RustUnnamed = 123;
pub const _SC_NL_NMAX: C2RustUnnamed = 122;
pub const _SC_NL_MSGMAX: C2RustUnnamed = 121;
pub const _SC_NL_LANGMAX: C2RustUnnamed = 120;
pub const _SC_NL_ARGMAX: C2RustUnnamed = 119;
pub const _SC_USHRT_MAX: C2RustUnnamed = 118;
pub const _SC_ULONG_MAX: C2RustUnnamed = 117;
pub const _SC_UINT_MAX: C2RustUnnamed = 116;
pub const _SC_UCHAR_MAX: C2RustUnnamed = 115;
pub const _SC_SHRT_MIN: C2RustUnnamed = 114;
pub const _SC_SHRT_MAX: C2RustUnnamed = 113;
pub const _SC_SCHAR_MIN: C2RustUnnamed = 112;
pub const _SC_SCHAR_MAX: C2RustUnnamed = 111;
pub const _SC_SSIZE_MAX: C2RustUnnamed = 110;
pub const _SC_NZERO: C2RustUnnamed = 109;
pub const _SC_MB_LEN_MAX: C2RustUnnamed = 108;
pub const _SC_WORD_BIT: C2RustUnnamed = 107;
pub const _SC_LONG_BIT: C2RustUnnamed = 106;
pub const _SC_INT_MIN: C2RustUnnamed = 105;
pub const _SC_INT_MAX: C2RustUnnamed = 104;
pub const _SC_CHAR_MIN: C2RustUnnamed = 103;
pub const _SC_CHAR_MAX: C2RustUnnamed = 102;
pub const _SC_CHAR_BIT: C2RustUnnamed = 101;
pub const _SC_XOPEN_XPG4: C2RustUnnamed = 100;
pub const _SC_XOPEN_XPG3: C2RustUnnamed = 99;
pub const _SC_XOPEN_XPG2: C2RustUnnamed = 98;
pub const _SC_2_UPE: C2RustUnnamed = 97;
pub const _SC_2_C_VERSION: C2RustUnnamed = 96;
pub const _SC_2_CHAR_TERM: C2RustUnnamed = 95;
pub const _SC_XOPEN_SHM: C2RustUnnamed = 94;
pub const _SC_XOPEN_ENH_I18N: C2RustUnnamed = 93;
pub const _SC_XOPEN_CRYPT: C2RustUnnamed = 92;
pub const _SC_XOPEN_UNIX: C2RustUnnamed = 91;
pub const _SC_XOPEN_XCU_VERSION: C2RustUnnamed = 90;
pub const _SC_XOPEN_VERSION: C2RustUnnamed = 89;
pub const _SC_PASS_MAX: C2RustUnnamed = 88;
pub const _SC_ATEXIT_MAX: C2RustUnnamed = 87;
pub const _SC_AVPHYS_PAGES: C2RustUnnamed = 86;
pub const _SC_PHYS_PAGES: C2RustUnnamed = 85;
pub const _SC_NPROCESSORS_ONLN: C2RustUnnamed = 84;
pub const _SC_NPROCESSORS_CONF: C2RustUnnamed = 83;
pub const _SC_THREAD_PROCESS_SHARED: C2RustUnnamed = 82;
pub const _SC_THREAD_PRIO_PROTECT: C2RustUnnamed = 81;
pub const _SC_THREAD_PRIO_INHERIT: C2RustUnnamed = 80;
pub const _SC_THREAD_PRIORITY_SCHEDULING: C2RustUnnamed = 79;
pub const _SC_THREAD_ATTR_STACKSIZE: C2RustUnnamed = 78;
pub const _SC_THREAD_ATTR_STACKADDR: C2RustUnnamed = 77;
pub const _SC_THREAD_THREADS_MAX: C2RustUnnamed = 76;
pub const _SC_THREAD_STACK_MIN: C2RustUnnamed = 75;
pub const _SC_THREAD_KEYS_MAX: C2RustUnnamed = 74;
pub const _SC_THREAD_DESTRUCTOR_ITERATIONS: C2RustUnnamed = 73;
pub const _SC_TTY_NAME_MAX: C2RustUnnamed = 72;
pub const _SC_LOGIN_NAME_MAX: C2RustUnnamed = 71;
pub const _SC_GETPW_R_SIZE_MAX: C2RustUnnamed = 70;
pub const _SC_GETGR_R_SIZE_MAX: C2RustUnnamed = 69;
pub const _SC_THREAD_SAFE_FUNCTIONS: C2RustUnnamed = 68;
pub const _SC_THREADS: C2RustUnnamed = 67;
pub const _SC_T_IOV_MAX: C2RustUnnamed = 66;
pub const _SC_PII_OSI_M: C2RustUnnamed = 65;
pub const _SC_PII_OSI_CLTS: C2RustUnnamed = 64;
pub const _SC_PII_OSI_COTS: C2RustUnnamed = 63;
pub const _SC_PII_INTERNET_DGRAM: C2RustUnnamed = 62;
pub const _SC_PII_INTERNET_STREAM: C2RustUnnamed = 61;
pub const _SC_IOV_MAX: C2RustUnnamed = 60;
pub const _SC_UIO_MAXIOV: C2RustUnnamed = 60;
pub const _SC_SELECT: C2RustUnnamed = 59;
pub const _SC_POLL: C2RustUnnamed = 58;
pub const _SC_PII_OSI: C2RustUnnamed = 57;
pub const _SC_PII_INTERNET: C2RustUnnamed = 56;
pub const _SC_PII_SOCKET: C2RustUnnamed = 55;
pub const _SC_PII_XTI: C2RustUnnamed = 54;
pub const _SC_PII: C2RustUnnamed = 53;
pub const _SC_2_LOCALEDEF: C2RustUnnamed = 52;
pub const _SC_2_SW_DEV: C2RustUnnamed = 51;
pub const _SC_2_FORT_RUN: C2RustUnnamed = 50;
pub const _SC_2_FORT_DEV: C2RustUnnamed = 49;
pub const _SC_2_C_DEV: C2RustUnnamed = 48;
pub const _SC_2_C_BIND: C2RustUnnamed = 47;
pub const _SC_2_VERSION: C2RustUnnamed = 46;
pub const _SC_CHARCLASS_NAME_MAX: C2RustUnnamed = 45;
pub const _SC_RE_DUP_MAX: C2RustUnnamed = 44;
pub const _SC_LINE_MAX: C2RustUnnamed = 43;
pub const _SC_EXPR_NEST_MAX: C2RustUnnamed = 42;
pub const _SC_EQUIV_CLASS_MAX: C2RustUnnamed = 41;
pub const _SC_COLL_WEIGHTS_MAX: C2RustUnnamed = 40;
pub const _SC_BC_STRING_MAX: C2RustUnnamed = 39;
pub const _SC_BC_SCALE_MAX: C2RustUnnamed = 38;
pub const _SC_BC_DIM_MAX: C2RustUnnamed = 37;
pub const _SC_BC_BASE_MAX: C2RustUnnamed = 36;
pub const _SC_TIMER_MAX: C2RustUnnamed = 35;
pub const _SC_SIGQUEUE_MAX: C2RustUnnamed = 34;
pub const _SC_SEM_VALUE_MAX: C2RustUnnamed = 33;
pub const _SC_SEM_NSEMS_MAX: C2RustUnnamed = 32;
pub const _SC_RTSIG_MAX: C2RustUnnamed = 31;
pub const _SC_PAGESIZE: C2RustUnnamed = 30;
pub const _SC_VERSION: C2RustUnnamed = 29;
pub const _SC_MQ_PRIO_MAX: C2RustUnnamed = 28;
pub const _SC_MQ_OPEN_MAX: C2RustUnnamed = 27;
pub const _SC_DELAYTIMER_MAX: C2RustUnnamed = 26;
pub const _SC_AIO_PRIO_DELTA_MAX: C2RustUnnamed = 25;
pub const _SC_AIO_MAX: C2RustUnnamed = 24;
pub const _SC_AIO_LISTIO_MAX: C2RustUnnamed = 23;
pub const _SC_SHARED_MEMORY_OBJECTS: C2RustUnnamed = 22;
pub const _SC_SEMAPHORES: C2RustUnnamed = 21;
pub const _SC_MESSAGE_PASSING: C2RustUnnamed = 20;
pub const _SC_MEMORY_PROTECTION: C2RustUnnamed = 19;
pub const _SC_MEMLOCK_RANGE: C2RustUnnamed = 18;
pub const _SC_MEMLOCK: C2RustUnnamed = 17;
pub const _SC_MAPPED_FILES: C2RustUnnamed = 16;
pub const _SC_FSYNC: C2RustUnnamed = 15;
pub const _SC_SYNCHRONIZED_IO: C2RustUnnamed = 14;
pub const _SC_PRIORITIZED_IO: C2RustUnnamed = 13;
pub const _SC_ASYNCHRONOUS_IO: C2RustUnnamed = 12;
pub const _SC_TIMERS: C2RustUnnamed = 11;
pub const _SC_PRIORITY_SCHEDULING: C2RustUnnamed = 10;
pub const _SC_REALTIME_SIGNALS: C2RustUnnamed = 9;
pub const _SC_SAVED_IDS: C2RustUnnamed = 8;
pub const _SC_JOB_CONTROL: C2RustUnnamed = 7;
pub const _SC_TZNAME_MAX: C2RustUnnamed = 6;
pub const _SC_STREAM_MAX: C2RustUnnamed = 5;
pub const _SC_OPEN_MAX: C2RustUnnamed = 4;
pub const _SC_NGROUPS_MAX: C2RustUnnamed = 3;
pub const _SC_CLK_TCK: C2RustUnnamed = 2;
pub const _SC_CHILD_MAX: C2RustUnnamed = 1;
pub const _SC_ARG_MAX: C2RustUnnamed = 0;
pub type uint16_t = __uint16_t;
pub type uint32_t = __uint32_t;
pub type uint64_t = __uint64_t;
pub type __socket_type = libc::c_uint;
pub const SOCK_NONBLOCK: __socket_type = 2048;
pub const SOCK_CLOEXEC: __socket_type = 524288;
pub const SOCK_PACKET: __socket_type = 10;
pub const SOCK_DCCP: __socket_type = 6;
pub const SOCK_SEQPACKET: __socket_type = 5;
pub const SOCK_RDM: __socket_type = 4;
pub const SOCK_RAW: __socket_type = 3;
pub const SOCK_DGRAM: __socket_type = 2;
pub const SOCK_STREAM: __socket_type = 1;
pub type sa_family_t = libc::c_ushort;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct sockaddr {
pub sa_family: sa_family_t,
pub sa_data: [libc::c_char; 14],
}
pub type in_addr_t = uint32_t;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct in_addr {
pub s_addr: in_addr_t,
}
pub type in_port_t = uint16_t;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct sockaddr_in {
pub sin_family: sa_family_t,
pub sin_port: in_port_t,
pub sin_addr: in_addr,
pub sin_zero: [libc::c_uchar; 8],
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct timezone {
pub tz_minuteswest: libc::c_int,
pub tz_dsttime: libc::c_int,
}
pub type __timezone_ptr_t = *mut timezone;
pub type nfds_t = libc::c_ulong;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct pollfd {
pub fd: libc::c_int,
pub events: libc::c_short,
pub revents: libc::c_short,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct tm {
pub tm_sec: libc::c_int,
pub tm_min: libc::c_int,
pub tm_hour: libc::c_int,
pub tm_mday: libc::c_int,
pub tm_mon: libc::c_int,
pub tm_year: libc::c_int,
pub tm_wday: libc::c_int,
pub tm_yday: libc::c_int,
pub tm_isdst: libc::c_int,
pub tm_gmtoff: libc::c_long,
pub tm_zone: *const libc::c_char,
}
pub type u8_t = u_int8_t;
pub type u16_t = u_int16_t;
pub type u32_t = u_int32_t;
pub type sockfd = libc::c_int;
pub type eventfd_t = uint64_t;
pub type event_type = libc::c_uint;
pub const EVENT_WAKE: event_type = 2;
pub const EVENT_READ: event_type = 1;
pub const EVENT_TIMEOUT: event_type = 0;
#[derive(Copy, Clone)]
#[repr(C)]
pub union C2RustUnnamed_0 {
pub ifru_addr: sockaddr,
pub ifru_dstaddr: sockaddr,
pub ifru_broadaddr: sockaddr,
pub ifru_netmask: sockaddr,
pub ifru_hwaddr: sockaddr,
pub ifru_flags: libc::c_short,
pub ifru_ivalue: libc::c_int,
pub ifru_mtu: libc::c_int,
pub ifru_map: ifmap,
pub ifru_slave: [libc::c_char; 16],
pub ifru_newname: [libc::c_char; 16],
pub ifru_data: __caddr_t,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct ifmap {
pub mem_start: libc::c_ulong,
pub mem_end: libc::c_ulong,
pub base_addr: libc::c_ushort,
pub irq: libc::c_uchar,
pub dma: libc::c_uchar,
pub port: libc::c_uchar,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct ifreq {
pub ifr_ifrn: C2RustUnnamed_1,
pub ifr_ifru: C2RustUnnamed_0,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub union C2RustUnnamed_1 {
pub ifrn_name: [libc::c_char; 16],
}
#[derive(Copy, Clone)]
#[repr(C)]
pub union C2RustUnnamed_2 {
pub ifcu_buf: __caddr_t,
pub ifcu_req: *mut ifreq,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct ifconf {
pub ifc_len: libc::c_int,
pub ifc_ifcu: C2RustUnnamed_2,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct addrinfo {
pub ai_flags: libc::c_int,
pub ai_family: libc::c_int,
pub ai_socktype: libc::c_int,
pub ai_protocol: libc::c_int,
pub ai_addrlen: socklen_t,
pub ai_addr: *mut sockaddr,
pub ai_canonname: *mut libc::c_char,
pub ai_next: *mut addrinfo,
}
/*
* Squeezelite - lightweight headless squeezebox emulator
*
* (c) Adrian Smith 2012-2015, triode1@btinternet.com
* Ralph Irving 2015-2017, ralph_irving@hotmail.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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
// logging functions
#[no_mangle]
pub unsafe extern "C" fn logtime() -> *const libc::c_char {
static mut buf: [libc::c_char; 100] = [0; 100];
let mut tv: timeval = timeval{tv_sec: 0, tv_usec: 0,};
gettimeofday(&mut tv, 0 as *mut timezone);
strftime(buf.as_mut_ptr(),
::std::mem::size_of::<[libc::c_char; 100]>() as libc::c_ulong,
b"[%T.\x00" as *const u8 as *const libc::c_char,
localtime(&mut tv.tv_sec));
sprintf(buf.as_mut_ptr().offset(strlen(buf.as_mut_ptr()) as isize),
b"%06ld]\x00" as *const u8 as *const libc::c_char, tv.tv_usec);
return buf.as_mut_ptr();
}
#[no_mangle]
pub unsafe extern "C" fn logprint(mut fmt: *const libc::c_char,
mut args: ...) {
let mut args_0: ::std::ffi::VaListImpl;
args_0 = args.clone();
vfprintf(stderr, fmt, args_0.as_va_list());
fflush(stderr);
}
// cmdline parsing
#[no_mangle]
pub unsafe extern "C" fn next_param(mut src: *mut libc::c_char,
mut c: libc::c_char)
-> *mut libc::c_char {
static mut str: *mut libc::c_char =
0 as *const libc::c_char as *mut libc::c_char;
let mut ptr: *mut libc::c_char = 0 as *mut libc::c_char;
let mut ret: *mut libc::c_char = 0 as *mut libc::c_char;
if !src.is_null() { str = src }
if !str.is_null() &&
{ ptr = strchr(str, c as libc::c_int); !ptr.is_null() } {
ret = str;
*ptr = '\u{0}' as i32 as libc::c_char;
str = ptr.offset(1 as libc::c_int as isize)
} else { ret = str; str = 0 as *mut libc::c_char }
return if !ret.is_null() &&
*ret.offset(0 as libc::c_int as isize) as libc::c_int != 0 {
ret
} else { 0 as *mut libc::c_char };
}
// clock
#[no_mangle]
pub unsafe extern "C" fn gettime_ms() -> u32_t {
let mut ts: timespec = timespec{tv_sec: 0, tv_nsec: 0,};
if clock_gettime(1 as libc::c_int, &mut ts) == 0 {
return (ts.tv_sec * 1000 as libc::c_int as libc::c_long +
ts.tv_nsec / 1000000 as libc::c_int as libc::c_long) as
u32_t
}
let mut tv: timeval = timeval{tv_sec: 0, tv_usec: 0,};
gettimeofday(&mut tv, 0 as *mut timezone);
return (tv.tv_sec * 1000 as libc::c_int as libc::c_long +
tv.tv_usec / 1000 as libc::c_int as libc::c_long) as u32_t;
}
// mac address
// search first 4 interfaces returned by IFCONF
#[no_mangle]
pub unsafe extern "C" fn get_mac(mut mac: *mut u8_t) {
let mut utmac: *mut libc::c_char = 0 as *mut libc::c_char;
let mut ifc: ifconf =
ifconf{ifc_len: 0,
ifc_ifcu: C2RustUnnamed_2{ifcu_buf: 0 as *mut libc::c_char,},};
let mut ifr: *mut ifreq = 0 as *mut ifreq;
let mut ifend: *mut ifreq = 0 as *mut ifreq;
let mut ifreq: ifreq =
ifreq{ifr_ifrn: C2RustUnnamed_1{ifrn_name: [0; 16],},
ifr_ifru:
C2RustUnnamed_0{ifru_addr:
sockaddr{sa_family: 0,
sa_data: [0; 14],},},};
let mut ifs: [ifreq; 4] =
[ifreq{ifr_ifrn: C2RustUnnamed_1{ifrn_name: [0; 16],},
ifr_ifru:
C2RustUnnamed_0{ifru_addr:
sockaddr{sa_family: 0,
sa_data: [0; 14],},},}; 4];
utmac = getenv(b"UTMAC\x00" as *const u8 as *const libc::c_char);
if !utmac.is_null() {
if strlen(utmac) == 17 as libc::c_int as libc::c_ulong {
if sscanf(utmac,
b"%2hhx:%2hhx:%2hhx:%2hhx:%2hhx:%2hhx\x00" as *const u8
as *const libc::c_char,
&mut *mac.offset(0 as libc::c_int as isize) as
*mut u8_t,
&mut *mac.offset(1 as libc::c_int as isize) as
*mut u8_t,
&mut *mac.offset(2 as libc::c_int as isize) as
*mut u8_t,
&mut *mac.offset(3 as libc::c_int as isize) as
*mut u8_t,
&mut *mac.offset(4 as libc::c_int as isize) as
*mut u8_t,
&mut *mac.offset(5 as libc::c_int as isize) as
*mut u8_t) == 6 as libc::c_int {
return
}
}
}
let ref mut fresh0 = *mac.offset(5 as libc::c_int as isize);
*fresh0 = 0 as libc::c_int as u8_t;
let ref mut fresh1 = *mac.offset(4 as libc::c_int as isize);
*fresh1 = *fresh0;
let ref mut fresh2 = *mac.offset(3 as libc::c_int as isize);
*fresh2 = *fresh1;
let ref mut fresh3 = *mac.offset(2 as libc::c_int as isize);
*fresh3 = *fresh2;
let ref mut fresh4 = *mac.offset(1 as libc::c_int as isize);
*fresh4 = *fresh3;
*mac.offset(0 as libc::c_int as isize) = *fresh4;
let mut s: libc::c_int =
socket(2 as libc::c_int, SOCK_DGRAM as libc::c_int, 0 as libc::c_int);
ifc.ifc_len =
::std::mem::size_of::<[ifreq; 4]>() as libc::c_ulong as libc::c_int;
ifc.ifc_ifcu.ifcu_req = ifs.as_mut_ptr();
if ioctl(s, 0x8912 as libc::c_int as libc::c_ulong,
&mut ifc as *mut ifconf) == 0 as libc::c_int {
ifend =
ifs.as_mut_ptr().offset((ifc.ifc_len as
libc::c_ulong).wrapping_div(::std::mem::size_of::<ifreq>()
as
libc::c_ulong)
as isize);
ifr = ifc.ifc_ifcu.ifcu_req;
while ifr < ifend {
if (*ifr).ifr_ifru.ifru_addr.sa_family as libc::c_int ==
2 as libc::c_int {
strncpy(ifreq.ifr_ifrn.ifrn_name.as_mut_ptr(),
(*ifr).ifr_ifrn.ifrn_name.as_mut_ptr(),
(::std::mem::size_of::<[libc::c_char; 16]>() as
libc::c_ulong).wrapping_sub(1 as libc::c_int as
libc::c_ulong));
if ioctl(s, 0x8927 as libc::c_int as libc::c_ulong,
&mut ifreq as *mut ifreq) == 0 as libc::c_int {
memcpy(mac as *mut libc::c_void,
ifreq.ifr_ifru.ifru_hwaddr.sa_data.as_mut_ptr() as
*const libc::c_void,
6 as libc::c_int as libc::c_ulong);
if *mac.offset(0 as libc::c_int as isize) as libc::c_int +
*mac.offset(1 as libc::c_int as isize) as
libc::c_int +
*mac.offset(2 as libc::c_int as isize) as
libc::c_int != 0 as libc::c_int {
break ;
}
}
}
ifr = ifr.offset(1)
}
}
close(s);
}
#[no_mangle]
pub unsafe extern "C" fn set_nonblock(mut s: sockfd) {
let mut flags: libc::c_int = fcntl(s, 3 as libc::c_int, 0 as libc::c_int);
fcntl(s, 4 as libc::c_int, flags | 0o4000 as libc::c_int);
}
// connect for socket already set to non blocking with timeout in seconds
#[no_mangle]
pub unsafe extern "C" fn connect_timeout(mut sock: sockfd,
mut addr: *const sockaddr,
mut addrlen: socklen_t,
mut timeout: libc::c_int)
-> libc::c_int {
let mut w: fd_set = fd_set{__fds_bits: [0; 16],};
let mut e: fd_set = fd_set{__fds_bits: [0; 16],};
let mut tval: timeval = timeval{tv_sec: 0, tv_usec: 0,};
if connect(sock, addr, addrlen) < 0 as libc::c_int {
if *__errno_location() != 115 as libc::c_int {
return -(1 as libc::c_int)
}
}
let mut __d0: libc::c_int = 0;
let mut __d1: libc::c_int = 0;
let fresh5 = &mut __d0;
let fresh6;
let fresh7 = &mut __d1;
let fresh8;
let fresh9 =
(::std::mem::size_of::<fd_set>() as
libc::c_ulong).wrapping_div(::std::mem::size_of::<__fd_mask>() as
libc::c_ulong);
let fresh10 =
&mut *w.__fds_bits.as_mut_ptr().offset(0 as libc::c_int as isize) as
*mut __fd_mask;
asm!("cld; rep; stosq" : "={cx}" (fresh6), "={di}" (fresh8) : "{ax}"
(0 as libc::c_int), "0"
(c2rust_asm_casts::AsmCast::cast_in(fresh5, fresh9)), "1"
(c2rust_asm_casts::AsmCast::cast_in(fresh7, fresh10)) : "memory" :
"volatile");
c2rust_asm_casts::AsmCast::cast_out(fresh5, fresh9, fresh6);
c2rust_asm_casts::AsmCast::cast_out(fresh7, fresh10, fresh8);
w.__fds_bits[(sock /
(8 as libc::c_int *
::std::mem::size_of::<__fd_mask>() as libc::c_ulong
as libc::c_int)) as usize] |=
((1 as libc::c_ulong) <<
sock %
(8 as libc::c_int *
::std::mem::size_of::<__fd_mask>() as libc::c_ulong as
libc::c_int)) as __fd_mask;
e = w;
tval.tv_sec = timeout as __time_t;
tval.tv_usec = 0 as libc::c_int as __suseconds_t;
// only return 0 if w set and sock error is zero, otherwise return error code
if select(sock + 1 as libc::c_int, 0 as *mut fd_set, &mut w, &mut e,
(if timeout != 0 { &mut tval } else { 0 as *mut timeval })) ==
1 as libc::c_int &&
w.__fds_bits[(sock /
(8 as libc::c_int *
::std::mem::size_of::<__fd_mask>() as
libc::c_ulong as libc::c_int)) as usize]
&
((1 as libc::c_ulong) <<
sock %
(8 as libc::c_int *
::std::mem::size_of::<__fd_mask>() as
libc::c_ulong as libc::c_int)) as __fd_mask
!= 0 as libc::c_int as libc::c_long {
let mut error: libc::c_int = 0 as libc::c_int;
let mut len: socklen_t =
::std::mem::size_of::<libc::c_int>() as libc::c_ulong as
socklen_t;
getsockopt(sock, 1 as libc::c_int, 4 as libc::c_int,
&mut error as *mut libc::c_int as *mut libc::c_void,
&mut len);
return error
}
return -(1 as libc::c_int);
}
#[no_mangle]
pub unsafe extern "C" fn server_addr(mut server: *mut libc::c_char,
mut ip_ptr: *mut in_addr_t,
mut port_ptr: *mut libc::c_uint) {
let mut res: *mut addrinfo = 0 as *mut addrinfo;
let mut hints: addrinfo =
addrinfo{ai_flags: 0,
ai_family: 0,
ai_socktype: 0,
ai_protocol: 0,
ai_addrlen: 0,
ai_addr: 0 as *mut sockaddr,
ai_canonname: 0 as *mut libc::c_char,
ai_next: 0 as *mut addrinfo,};
let mut port: *const libc::c_char = 0 as *const libc::c_char;
if !strtok(server, b":\x00" as *const u8 as *const libc::c_char).is_null()
{
port =
strtok(0 as *mut libc::c_char,
b":\x00" as *const u8 as *const libc::c_char);
if !port.is_null() { *port_ptr = atoi(port) as libc::c_uint }
}
memset(&mut hints as *mut addrinfo as *mut libc::c_void, 0 as libc::c_int,
::std::mem::size_of::<addrinfo>() as libc::c_ulong);
hints.ai_family = 2 as libc::c_int;
getaddrinfo(server, 0 as *const libc::c_char, &mut hints, &mut res);
if !res.is_null() && !(*res).ai_addr.is_null() {
*ip_ptr = (*((*res).ai_addr as *mut sockaddr_in)).sin_addr.s_addr
}
if !res.is_null() { freeaddrinfo(res); };
}
#[no_mangle]
pub unsafe extern "C" fn set_readwake_handles(mut handles: *mut pollfd,
mut s: sockfd,
mut e: libc::c_int) {
(*handles.offset(0 as libc::c_int as isize)).fd = s;
(*handles.offset(1 as libc::c_int as isize)).fd = e;
(*handles.offset(0 as libc::c_int as isize)).events =
0x1 as libc::c_int as libc::c_short;
(*handles.offset(1 as libc::c_int as isize)).events =
0x1 as libc::c_int as libc::c_short;
}
#[no_mangle]
pub unsafe extern "C" fn wait_readwake(mut handles: *mut pollfd,
mut timeout: libc::c_int)
-> event_type {
if poll(handles, 2 as libc::c_int as nfds_t, timeout) > 0 as libc::c_int {
if (*handles.offset(0 as libc::c_int as isize)).revents != 0 {
return EVENT_READ
}
if (*handles.offset(1 as libc::c_int as isize)).revents != 0 {
let mut val: eventfd_t = 0;
eventfd_read((*handles.offset(1 as libc::c_int as isize)).fd,
&mut val);
return EVENT_WAKE
}
}
return EVENT_TIMEOUT;
}
// pack/unpack to network byte order
#[no_mangle]
pub unsafe extern "C" fn packN(mut dest: *mut u32_t, mut val: u32_t) {
let mut ptr: *mut u8_t = dest as *mut u8_t;
*ptr =
(val >> 24 as libc::c_int & 0xff as libc::c_int as libc::c_uint) as
u8_t;
*ptr.offset(1 as libc::c_int as isize) =
(val >> 16 as libc::c_int & 0xff as libc::c_int as libc::c_uint) as
u8_t;
*ptr.offset(2 as libc::c_int as isize) =
(val >> 8 as libc::c_int & 0xff as libc::c_int as libc::c_uint) as
u8_t;
*ptr.offset(3 as libc::c_int as isize) =
(val & 0xff as libc::c_int as libc::c_uint) as u8_t;
}
#[no_mangle]
pub unsafe extern "C" fn packn(mut dest: *mut u16_t, mut val: u16_t) {
let mut ptr: *mut u8_t = dest as *mut u8_t;
*ptr =
(val as libc::c_int >> 8 as libc::c_int & 0xff as libc::c_int) as
u8_t;
*ptr.offset(1 as libc::c_int as isize) =
(val as libc::c_int & 0xff as libc::c_int) as u8_t;
}
#[no_mangle]
pub unsafe extern "C" fn unpackN(mut src: *mut u32_t) -> u32_t {
let mut ptr: *mut u8_t = src as *mut u8_t;
return ((*ptr as libc::c_int) << 24 as libc::c_int |
(*ptr.offset(1 as libc::c_int as isize) as libc::c_int) <<
16 as libc::c_int |
(*ptr.offset(2 as libc::c_int as isize) as libc::c_int) <<
8 as libc::c_int |
*ptr.offset(3 as libc::c_int as isize) as libc::c_int) as
u32_t;
}
#[no_mangle]
pub unsafe extern "C" fn unpackn(mut src: *mut u16_t) -> u16_t {
let mut ptr: *mut u8_t = src as *mut u8_t;
return ((*ptr as libc::c_int) << 8 as libc::c_int |
*ptr.offset(1 as libc::c_int as isize) as libc::c_int) as
u16_t;
}
/*
* Squeezelite - lightweight headless squeezebox emulator
*
* (c) Adrian Smith 2012-2015, triode1@btinternet.com
* Ralph Irving 2015-2017, ralph_irving@hotmail.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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additions (c) Paul Hermann, 2015-2017 under the same license terms
* -Control of Raspberry pi GPIO for amplifier power
* -Launch script on power status change from LMS
*/
// make may define: PORTAUDIO, SELFPIPE, RESAMPLE, RESAMPLE_MP, VISEXPORT, GPIO, IR, DSD, LINKALL to influence build
// build detection
// dynamically loaded libraries at run time
// !LINKALL
// config options
// do not reduce as icy-meta max is 4080
/* SUN */
/* SUN */
// printf/scanf formats for u64_t
// logging
// utils.c (non logging)
#[no_mangle]
pub unsafe extern "C" fn touch_memory(mut buf: *mut u8_t, mut size: size_t) {
let mut ptr: *mut u8_t = 0 as *mut u8_t;
ptr = buf;
while ptr < buf.offset(size as isize) {
*ptr = 0 as libc::c_int as u8_t;
ptr = ptr.offset(sysconf(_SC_PAGESIZE as libc::c_int) as isize)
};
}

View File

@ -1,985 +0,0 @@
use ::libc;
extern "C" {
#[no_mangle]
fn malloc(_: libc::c_ulong) -> *mut libc::c_void;
#[no_mangle]
fn free(__ptr: *mut libc::c_void);
#[no_mangle]
fn memcpy(_: *mut libc::c_void, _: *const libc::c_void, _: libc::c_ulong)
-> *mut libc::c_void;
#[no_mangle]
fn memset(_: *mut libc::c_void, _: libc::c_int, _: libc::c_ulong)
-> *mut libc::c_void;
#[no_mangle]
fn dlopen(__file: *const libc::c_char, __mode: libc::c_int)
-> *mut libc::c_void;
#[no_mangle]
fn dlsym(__handle: *mut libc::c_void, __name: *const libc::c_char)
-> *mut libc::c_void;
#[no_mangle]
fn dlerror() -> *mut libc::c_char;
#[no_mangle]
fn pthread_mutex_lock(__mutex: *mut pthread_mutex_t) -> libc::c_int;
#[no_mangle]
fn pthread_mutex_unlock(__mutex: *mut pthread_mutex_t) -> libc::c_int;
#[no_mangle]
fn logtime() -> *const libc::c_char;
#[no_mangle]
fn logprint(fmt: *const libc::c_char, _: ...);
#[no_mangle]
fn _buf_used(buf: *mut buffer) -> libc::c_uint;
#[no_mangle]
fn _buf_space(buf: *mut buffer) -> libc::c_uint;
#[no_mangle]
fn _buf_cont_read(buf: *mut buffer) -> libc::c_uint;
#[no_mangle]
fn _buf_cont_write(buf: *mut buffer) -> libc::c_uint;
#[no_mangle]
fn _buf_inc_readp(buf: *mut buffer, by: libc::c_uint);
#[no_mangle]
fn _buf_inc_writep(buf: *mut buffer, by: libc::c_uint);
#[no_mangle]
fn decode_newstream(sample_rate: libc::c_uint,
supported_rates: *mut libc::c_uint) -> libc::c_uint;
#[no_mangle]
fn _checkfade(_: bool);
#[no_mangle]
static mut loglevel: log_level;
#[no_mangle]
static mut streambuf: *mut buffer;
#[no_mangle]
static mut outputbuf: *mut buffer;
#[no_mangle]
static mut stream: streamstate;
#[no_mangle]
static mut output: outputstate;
#[no_mangle]
static mut decode: decodestate;
}
pub type size_t = libc::c_ulong;
pub type __uint8_t = libc::c_uchar;
pub type __int16_t = libc::c_short;
pub type __int32_t = libc::c_int;
pub type __uint32_t = libc::c_uint;
pub type __int64_t = libc::c_long;
pub type __uint64_t = libc::c_ulong;
pub type int16_t = __int16_t;
pub type int32_t = __int32_t;
pub type int64_t = __int64_t;
pub type u_int8_t = __uint8_t;
pub type u_int32_t = __uint32_t;
pub type u_int64_t = __uint64_t;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct __pthread_internal_list {
pub __prev: *mut __pthread_internal_list,
pub __next: *mut __pthread_internal_list,
}
pub type __pthread_list_t = __pthread_internal_list;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct __pthread_mutex_s {
pub __lock: libc::c_int,
pub __count: libc::c_uint,
pub __owner: libc::c_int,
pub __nusers: libc::c_uint,
pub __kind: libc::c_int,
pub __spins: libc::c_short,
pub __elision: libc::c_short,
pub __list: __pthread_list_t,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub union pthread_mutex_t {
pub __data: __pthread_mutex_s,
pub __size: [libc::c_char; 40],
pub __align: libc::c_long,
}
pub type u8_t = u_int8_t;
pub type u32_t = u_int32_t;
pub type u64_t = u_int64_t;
pub type s16_t = int16_t;
pub type s32_t = int32_t;
pub type frames_t = u32_t;
pub type log_level = libc::c_uint;
pub const lSDEBUG: log_level = 4;
pub const lDEBUG: log_level = 3;
pub const lINFO: log_level = 2;
pub const lWARN: log_level = 1;
pub const lERROR: log_level = 0;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct buffer {
pub buf: *mut u8_t,
pub readp: *mut u8_t,
pub writep: *mut u8_t,
pub wrap: *mut u8_t,
pub size: size_t,
pub base_size: size_t,
pub mutex: pthread_mutex_t,
}
pub type stream_state = libc::c_uint;
pub const RECV_HEADERS: stream_state = 7;
pub const SEND_HEADERS: stream_state = 6;
pub const STREAMING_HTTP: stream_state = 5;
pub const STREAMING_FILE: stream_state = 4;
pub const STREAMING_BUFFERING: stream_state = 3;
pub const STREAMING_WAIT: stream_state = 2;
pub const DISCONNECT: stream_state = 1;
pub const STOPPED: stream_state = 0;
pub type disconnect_code = libc::c_uint;
pub const TIMEOUT: disconnect_code = 4;
pub const UNREACHABLE: disconnect_code = 3;
pub const REMOTE_DISCONNECT: disconnect_code = 2;
pub const LOCAL_DISCONNECT: disconnect_code = 1;
pub const DISCONNECT_OK: disconnect_code = 0;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct streamstate {
pub state: stream_state,
pub disconnect: disconnect_code,
pub header: *mut libc::c_char,
pub header_len: size_t,
pub sent_headers: bool,
pub cont_wait: bool,
pub bytes: u64_t,
pub threshold: libc::c_uint,
pub meta_interval: u32_t,
pub meta_next: u32_t,
pub meta_left: u32_t,
pub meta_send: bool,
}
pub type decode_state = libc::c_uint;
pub const DECODE_ERROR: decode_state = 4;
pub const DECODE_COMPLETE: decode_state = 3;
pub const DECODE_RUNNING: decode_state = 2;
pub const DECODE_READY: decode_state = 1;
pub const DECODE_STOPPED: decode_state = 0;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct decodestate {
pub state: decode_state,
pub new_stream: bool,
pub mutex: pthread_mutex_t,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct codec {
pub id: libc::c_char,
pub types: *mut libc::c_char,
pub min_read_bytes: libc::c_uint,
pub min_space: libc::c_uint,
pub open: Option<unsafe extern "C" fn(_: u8_t, _: u8_t, _: u8_t, _: u8_t)
-> ()>,
pub close: Option<unsafe extern "C" fn() -> ()>,
pub decode: Option<unsafe extern "C" fn() -> decode_state>,
}
pub type output_state = libc::c_int;
pub const OUTPUT_START_AT: output_state = 5;
pub const OUTPUT_SKIP_FRAMES: output_state = 4;
pub const OUTPUT_PAUSE_FRAMES: output_state = 3;
pub const OUTPUT_RUNNING: output_state = 2;
pub const OUTPUT_BUFFER: output_state = 1;
pub const OUTPUT_STOPPED: output_state = 0;
pub const OUTPUT_OFF: output_state = -1;
pub type output_format = libc::c_uint;
pub const S16_LE: output_format = 3;
pub const S24_3LE: output_format = 2;
pub const S24_LE: output_format = 1;
pub const S32_LE: output_format = 0;
pub type fade_state = libc::c_uint;
pub const FADE_ACTIVE: fade_state = 2;
pub const FADE_DUE: fade_state = 1;
pub const FADE_INACTIVE: fade_state = 0;
pub type fade_dir = libc::c_uint;
pub const FADE_CROSS: fade_dir = 3;
pub const FADE_DOWN: fade_dir = 2;
pub const FADE_UP: fade_dir = 1;
pub type fade_mode = libc::c_uint;
pub const FADE_INOUT: fade_mode = 4;
pub const FADE_OUT: fade_mode = 3;
pub const FADE_IN: fade_mode = 2;
pub const FADE_CROSSFADE: fade_mode = 1;
pub const FADE_NONE: fade_mode = 0;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct outputstate {
pub state: output_state,
pub format: output_format,
pub device: *const libc::c_char,
pub buffer: libc::c_uint,
pub period: libc::c_uint,
pub track_started: bool,
pub write_cb: Option<unsafe extern "C" fn(_: frames_t, _: bool, _: s32_t,
_: s32_t, _: s32_t, _: s32_t,
_: *mut *mut s32_t)
-> libc::c_int>,
pub start_frames: libc::c_uint,
pub frames_played: libc::c_uint,
pub frames_played_dmp: libc::c_uint,
pub current_sample_rate: libc::c_uint,
pub supported_rates: [libc::c_uint; 18],
pub default_sample_rate: libc::c_uint,
pub error_opening: bool,
pub device_frames: libc::c_uint,
pub updated: u32_t,
pub track_start_time: u32_t,
pub current_replay_gain: u32_t,
pub c2rust_unnamed: C2RustUnnamed,
pub next_sample_rate: libc::c_uint,
pub track_start: *mut u8_t,
pub gainL: u32_t,
pub gainR: u32_t,
pub invert: bool,
pub next_replay_gain: u32_t,
pub threshold: libc::c_uint,
pub fade: fade_state,
pub fade_start: *mut u8_t,
pub fade_end: *mut u8_t,
pub fade_dir: fade_dir,
pub fade_mode: fade_mode,
pub fade_secs: libc::c_uint,
pub rate_delay: libc::c_uint,
pub delay_active: bool,
pub stop_time: u32_t,
pub idle_to: u32_t,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub union C2RustUnnamed {
pub pause_frames: u32_t,
pub skip_frames: u32_t,
pub start_at: u32_t,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct OggVorbis_File {
pub datasource: *mut libc::c_void,
pub seekable: libc::c_int,
pub offset: ogg_int64_t,
pub end: ogg_int64_t,
pub oy: ogg_sync_state,
pub links: libc::c_int,
pub offsets: *mut ogg_int64_t,
pub dataoffsets: *mut ogg_int64_t,
pub serialnos: *mut libc::c_long,
pub pcmlengths: *mut ogg_int64_t,
pub vi: *mut vorbis_info,
pub vc: *mut vorbis_comment,
pub pcm_offset: ogg_int64_t,
pub ready_state: libc::c_int,
pub current_serialno: libc::c_long,
pub current_link: libc::c_int,
pub bittrack: libc::c_double,
pub samptrack: libc::c_double,
pub os: ogg_stream_state,
pub vd: vorbis_dsp_state,
pub vb: vorbis_block,
pub callbacks: ov_callbacks,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct ov_callbacks {
pub read_func: Option<unsafe extern "C" fn(_: *mut libc::c_void,
_: size_t, _: size_t,
_: *mut libc::c_void)
-> size_t>,
pub seek_func: Option<unsafe extern "C" fn(_: *mut libc::c_void,
_: ogg_int64_t, _: libc::c_int)
-> libc::c_int>,
pub close_func: Option<unsafe extern "C" fn(_: *mut libc::c_void)
-> libc::c_int>,
pub tell_func: Option<unsafe extern "C" fn(_: *mut libc::c_void)
-> libc::c_long>,
}
pub type ogg_int64_t = int64_t;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct vorbis_block {
pub pcm: *mut *mut libc::c_float,
pub opb: oggpack_buffer,
pub lW: libc::c_long,
pub W: libc::c_long,
pub nW: libc::c_long,
pub pcmend: libc::c_int,
pub mode: libc::c_int,
pub eofflag: libc::c_int,
pub granulepos: ogg_int64_t,
pub sequence: ogg_int64_t,
pub vd: *mut vorbis_dsp_state,
pub localstore: *mut libc::c_void,
pub localtop: libc::c_long,
pub localalloc: libc::c_long,
pub totaluse: libc::c_long,
pub reap: *mut alloc_chain,
pub glue_bits: libc::c_long,
pub time_bits: libc::c_long,
pub floor_bits: libc::c_long,
pub res_bits: libc::c_long,
pub internal: *mut libc::c_void,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct alloc_chain {
pub ptr: *mut libc::c_void,
pub next: *mut alloc_chain,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct vorbis_dsp_state {
pub analysisp: libc::c_int,
pub vi: *mut vorbis_info,
pub pcm: *mut *mut libc::c_float,
pub pcmret: *mut *mut libc::c_float,
pub pcm_storage: libc::c_int,
pub pcm_current: libc::c_int,
pub pcm_returned: libc::c_int,
pub preextrapolate: libc::c_int,
pub eofflag: libc::c_int,
pub lW: libc::c_long,
pub W: libc::c_long,
pub nW: libc::c_long,
pub centerW: libc::c_long,
pub granulepos: ogg_int64_t,
pub sequence: ogg_int64_t,
pub glue_bits: ogg_int64_t,
pub time_bits: ogg_int64_t,
pub floor_bits: ogg_int64_t,
pub res_bits: ogg_int64_t,
pub backend_state: *mut libc::c_void,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct vorbis_info {
pub version: libc::c_int,
pub channels: libc::c_int,
pub rate: libc::c_long,
pub bitrate_upper: libc::c_long,
pub bitrate_nominal: libc::c_long,
pub bitrate_lower: libc::c_long,
pub bitrate_window: libc::c_long,
pub codec_setup: *mut libc::c_void,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct oggpack_buffer {
pub endbyte: libc::c_long,
pub endbit: libc::c_int,
pub buffer: *mut libc::c_uchar,
pub ptr: *mut libc::c_uchar,
pub storage: libc::c_long,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct ogg_stream_state {
pub body_data: *mut libc::c_uchar,
pub body_storage: libc::c_long,
pub body_fill: libc::c_long,
pub body_returned: libc::c_long,
pub lacing_vals: *mut libc::c_int,
pub granule_vals: *mut ogg_int64_t,
pub lacing_storage: libc::c_long,
pub lacing_fill: libc::c_long,
pub lacing_packet: libc::c_long,
pub lacing_returned: libc::c_long,
pub header: [libc::c_uchar; 282],
pub header_fill: libc::c_int,
pub e_o_s: libc::c_int,
pub b_o_s: libc::c_int,
pub serialno: libc::c_long,
pub pageno: libc::c_long,
pub packetno: ogg_int64_t,
pub granulepos: ogg_int64_t,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct vorbis_comment {
pub user_comments: *mut *mut libc::c_char,
pub comment_lengths: *mut libc::c_int,
pub comments: libc::c_int,
pub vendor: *mut libc::c_char,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct ogg_sync_state {
pub data: *mut libc::c_uchar,
pub storage: libc::c_int,
pub fill: libc::c_int,
pub returned: libc::c_int,
pub unsynced: libc::c_int,
pub headerbytes: libc::c_int,
pub bodybytes: libc::c_int,
}
// automatically select between floating point (preferred) and fixed point libraries:
// NOTE: works with Tremor version here: http://svn.xiph.org/trunk/Tremor, not vorbisidec.1.0.2 currently in ubuntu
// we take common definations from <vorbis/vorbisfile.h> even though we can use tremor at run time
// tremor's OggVorbis_File struct is normally smaller so this is ok, but padding added to malloc in case it is bigger
#[derive(Copy, Clone)]
#[repr(C)]
pub struct vorbis {
pub vf: *mut OggVorbis_File,
pub opened: bool,
pub write_buf: *mut u8_t,
pub ov_info: Option<unsafe extern "C" fn(_: *mut OggVorbis_File,
_: libc::c_int)
-> *mut vorbis_info>,
pub ov_clear: Option<unsafe extern "C" fn(_: *mut OggVorbis_File)
-> libc::c_int>,
pub ov_read: Option<unsafe extern "C" fn(_: *mut OggVorbis_File,
_: *mut libc::c_char,
_: libc::c_int, _: libc::c_int,
_: libc::c_int, _: libc::c_int,
_: *mut libc::c_int)
-> libc::c_long>,
pub ov_read_tremor: Option<unsafe extern "C" fn(_: *mut OggVorbis_File,
_: *mut libc::c_char,
_: libc::c_int,
_: *mut libc::c_int)
-> libc::c_long>,
pub ov_open_callbacks: Option<unsafe extern "C" fn(_: *mut libc::c_void,
_: *mut OggVorbis_File,
_: *const libc::c_char,
_: libc::c_long,
_: ov_callbacks)
-> libc::c_int>,
}
static mut v: *mut vorbis = 0 as *const vorbis as *mut vorbis;
// called with mutex locked within vorbis_decode to avoid locking O before S
unsafe extern "C" fn _read_cb(mut ptr: *mut libc::c_void, mut size: size_t,
mut nmemb: size_t,
mut datasource: *mut libc::c_void) -> size_t {
let mut bytes: size_t = 0;
pthread_mutex_lock(&mut (*streambuf).mutex);
bytes =
if _buf_used(streambuf) < _buf_cont_read(streambuf) {
_buf_used(streambuf)
} else { _buf_cont_read(streambuf) } as size_t;
bytes =
if bytes < size.wrapping_mul(nmemb) {
bytes
} else { size.wrapping_mul(nmemb) };
memcpy(ptr, (*streambuf).readp as *const libc::c_void, bytes);
_buf_inc_readp(streambuf, bytes as libc::c_uint);
pthread_mutex_unlock(&mut (*streambuf).mutex);
return bytes.wrapping_div(size);
}
// these are needed for older versions of tremor, later versions and libvorbis allow NULL to be used
unsafe extern "C" fn _seek_cb(mut datasource: *mut libc::c_void,
mut offset: ogg_int64_t,
mut whence: libc::c_int) -> libc::c_int {
return -(1 as libc::c_int); // samples returned are 16 bits
}
unsafe extern "C" fn _close_cb(mut datasource: *mut libc::c_void)
-> libc::c_int {
return 0 as libc::c_int;
}
unsafe extern "C" fn _tell_cb(mut datasource: *mut libc::c_void)
-> libc::c_long {
return 0 as libc::c_int as libc::c_long;
}
unsafe extern "C" fn vorbis_decode() -> decode_state {
static mut channels: libc::c_int = 0;
let mut frames: frames_t = 0;
let mut bytes: libc::c_int = 0;
let mut s: libc::c_int = 0;
let mut n: libc::c_int = 0;
let mut write_buf: *mut u8_t = 0 as *mut u8_t;
pthread_mutex_lock(&mut (*streambuf).mutex);
if stream.state as libc::c_uint <=
DISCONNECT as libc::c_int as libc::c_uint &&
_buf_used(streambuf) == 0 {
pthread_mutex_unlock(&mut (*streambuf).mutex);
return DECODE_COMPLETE
}
pthread_mutex_unlock(&mut (*streambuf).mutex);
if decode.new_stream {
let mut cbs: ov_callbacks =
ov_callbacks{read_func: None,
seek_func: None,
close_func: None,
tell_func: None,};
let mut err: libc::c_int = 0;
let mut info: *mut vorbis_info = 0 as *mut vorbis_info;
cbs.read_func =
Some(_read_cb as
unsafe extern "C" fn(_: *mut libc::c_void, _: size_t,
_: size_t, _: *mut libc::c_void)
-> size_t);
if (*v).ov_read_tremor.is_some() {
cbs.seek_func =
Some(_seek_cb as
unsafe extern "C" fn(_: *mut libc::c_void,
_: ogg_int64_t, _: libc::c_int)
-> libc::c_int);
cbs.close_func =
Some(_close_cb as
unsafe extern "C" fn(_: *mut libc::c_void)
-> libc::c_int);
cbs.tell_func =
Some(_tell_cb as
unsafe extern "C" fn(_: *mut libc::c_void)
-> libc::c_long)
} else {
cbs.seek_func = None;
cbs.close_func = None;
cbs.tell_func = None
}
err =
(*v).ov_open_callbacks.expect("non-null function pointer")(streambuf
as
*mut libc::c_void,
(*v).vf,
0 as
*const libc::c_char,
0 as
libc::c_int
as
libc::c_long,
cbs);
if err < 0 as libc::c_int {
if loglevel as libc::c_uint >=
lWARN as libc::c_int as libc::c_uint {
logprint(b"%s %s:%d open_callbacks error: %d\n\x00" as
*const u8 as *const libc::c_char, logtime(),
(*::std::mem::transmute::<&[u8; 14],
&[libc::c_char; 14]>(b"vorbis_decode\x00")).as_ptr(),
162 as libc::c_int, err);
}
return DECODE_COMPLETE
}
(*v).opened = 1 as libc::c_int != 0;
info =
(*v).ov_info.expect("non-null function pointer")((*v).vf,
-(1 as
libc::c_int));
if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint {
logprint(b"%s %s:%d setting track_start\n\x00" as *const u8 as
*const libc::c_char, logtime(),
(*::std::mem::transmute::<&[u8; 14],
&[libc::c_char; 14]>(b"vorbis_decode\x00")).as_ptr(),
169 as libc::c_int);
}
pthread_mutex_lock(&mut (*outputbuf).mutex);
output.next_sample_rate =
decode_newstream((*info).rate as libc::c_uint,
output.supported_rates.as_mut_ptr());
output.track_start = (*outputbuf).writep;
if output.fade_mode as u64 != 0 { _checkfade(1 as libc::c_int != 0); }
decode.new_stream = 0 as libc::c_int != 0;
pthread_mutex_unlock(&mut (*outputbuf).mutex);
channels = (*info).channels;
if channels > 2 as libc::c_int {
if loglevel as libc::c_uint >=
lWARN as libc::c_int as libc::c_uint {
logprint(b"%s %s:%d too many channels: %d\n\x00" as *const u8
as *const libc::c_char, logtime(),
(*::std::mem::transmute::<&[u8; 14],
&[libc::c_char; 14]>(b"vorbis_decode\x00")).as_ptr(),
181 as libc::c_int, channels);
}
return DECODE_ERROR
}
}
frames =
(if _buf_space(outputbuf) < _buf_cont_write(outputbuf) {
_buf_space(outputbuf)
} else {
_buf_cont_write(outputbuf)
}).wrapping_div(8 as libc::c_int as libc::c_uint);
write_buf = (*v).write_buf;
frames =
if frames < 2048 as libc::c_int as libc::c_uint {
frames
} else { 2048 as libc::c_int as libc::c_uint };
bytes =
frames.wrapping_mul(2 as libc::c_int as
libc::c_uint).wrapping_mul(channels as
libc::c_uint)
as libc::c_int;
// write the decoded frames into outputbuf even though they are 16 bits per sample, then unpack them
if (*v).ov_read_tremor.is_none() {
n =
(*v).ov_read.expect("non-null function pointer")((*v).vf,
write_buf as
*mut libc::c_char,
bytes,
0 as libc::c_int,
2 as libc::c_int,
1 as libc::c_int,
&mut s) as
libc::c_int
} else {
n =
(*v).ov_read_tremor.expect("non-null function pointer")((*v).vf,
write_buf
as
*mut libc::c_char,
bytes,
&mut s) as
libc::c_int
}
pthread_mutex_lock(&mut (*outputbuf).mutex);
if n > 0 as libc::c_int {
let mut count: frames_t = 0;
let mut iptr: *mut s16_t = 0 as *mut s16_t;
let mut optr: *mut s32_t = 0 as *mut s32_t;
frames = (n / 2 as libc::c_int / channels) as frames_t;
count = frames.wrapping_mul(channels as libc::c_uint);
iptr = (write_buf as *mut s16_t).offset(count as isize);
optr =
((*outputbuf).writep as
*mut s32_t).offset(frames.wrapping_mul(2 as libc::c_int as
libc::c_uint) as
isize);
if channels == 2 as libc::c_int {
loop {
let fresh0 = count;
count = count.wrapping_sub(1);
if !(fresh0 != 0) { break ; }
iptr = iptr.offset(-1);
optr = optr.offset(-1);
*optr = (*iptr as libc::c_int) << 16 as libc::c_int
}
} else if channels == 1 as libc::c_int {
loop {
let fresh1 = count;
count = count.wrapping_sub(1);
if !(fresh1 != 0) { break ; }
iptr = iptr.offset(-1);
optr = optr.offset(-1);
*optr = (*iptr as libc::c_int) << 16 as libc::c_int;
optr = optr.offset(-1);
*optr = (*iptr as libc::c_int) << 16 as libc::c_int
}
}
_buf_inc_writep(outputbuf,
frames.wrapping_mul(8 as libc::c_int as
libc::c_uint));
if loglevel as libc::c_uint >= lSDEBUG as libc::c_int as libc::c_uint
{
logprint(b"%s %s:%d wrote %u frames\n\x00" as *const u8 as
*const libc::c_char, logtime(),
(*::std::mem::transmute::<&[u8; 14],
&[libc::c_char; 14]>(b"vorbis_decode\x00")).as_ptr(),
265 as libc::c_int, frames);
}
} else if n == 0 as libc::c_int {
if stream.state as libc::c_uint <=
DISCONNECT as libc::c_int as libc::c_uint {
if loglevel as libc::c_uint >=
lINFO as libc::c_int as libc::c_uint {
logprint(b"%s %s:%d partial decode\n\x00" as *const u8 as
*const libc::c_char, logtime(),
(*::std::mem::transmute::<&[u8; 14],
&[libc::c_char; 14]>(b"vorbis_decode\x00")).as_ptr(),
270 as libc::c_int);
}
pthread_mutex_unlock(&mut (*outputbuf).mutex);
return DECODE_COMPLETE
} else {
if loglevel as libc::c_uint >=
lINFO as libc::c_int as libc::c_uint {
logprint(b"%s %s:%d no frame decoded\n\x00" as *const u8 as
*const libc::c_char, logtime(),
(*::std::mem::transmute::<&[u8; 14],
&[libc::c_char; 14]>(b"vorbis_decode\x00")).as_ptr(),
274 as libc::c_int);
}
}
} else if n == -(3 as libc::c_int) {
// recoverable hole in stream, seen when skipping
if loglevel as libc::c_uint >= lDEBUG as libc::c_int as libc::c_uint {
logprint(b"%s %s:%d hole in stream\n\x00" as *const u8 as
*const libc::c_char, logtime(),
(*::std::mem::transmute::<&[u8; 14],
&[libc::c_char; 14]>(b"vorbis_decode\x00")).as_ptr(),
280 as
libc::c_int); // add some padding as struct size may be larger
}
} else {
if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint {
logprint(b"%s %s:%d ov_read error: %d\n\x00" as *const u8 as
*const libc::c_char, logtime(),
(*::std::mem::transmute::<&[u8; 14],
&[libc::c_char; 14]>(b"vorbis_decode\x00")).as_ptr(),
284 as libc::c_int, n);
}
pthread_mutex_unlock(&mut (*outputbuf).mutex);
return DECODE_COMPLETE
}
pthread_mutex_unlock(&mut (*outputbuf).mutex);
return DECODE_RUNNING;
}
unsafe extern "C" fn vorbis_open(mut size: u8_t, mut rate: u8_t,
mut chan: u8_t, mut endianness: u8_t) {
if (*v).vf.is_null() {
(*v).vf =
malloc((::std::mem::size_of::<OggVorbis_File>() as
libc::c_ulong).wrapping_add(128 as libc::c_int as
libc::c_ulong)) as
*mut OggVorbis_File;
memset((*v).vf as *mut libc::c_void, 0 as libc::c_int,
(::std::mem::size_of::<OggVorbis_File>() as
libc::c_ulong).wrapping_add(128 as libc::c_int as
libc::c_ulong));
(*v).write_buf =
malloc((2048 as libc::c_int * 8 as libc::c_int) as libc::c_ulong)
as *mut u8_t
} else if (*v).opened {
(*v).ov_clear.expect("non-null function pointer")((*v).vf);
(*v).opened = 0 as libc::c_int != 0
};
}
unsafe extern "C" fn vorbis_close() {
if (*v).opened {
(*v).ov_clear.expect("non-null function pointer")((*v).vf);
(*v).opened = 0 as libc::c_int != 0
}
free((*v).vf as *mut libc::c_void);
free((*v).write_buf as *mut libc::c_void);
(*v).write_buf = 0 as *mut u8_t;
(*v).vf = 0 as *mut OggVorbis_File;
}
unsafe extern "C" fn load_vorbis() -> bool {
let mut handle: *mut libc::c_void =
dlopen(b"libvorbisfile.so.3\x00" as *const u8 as *const libc::c_char,
0x2 as libc::c_int);
let mut err: *mut libc::c_char = 0 as *mut libc::c_char;
let mut tremor: bool = 0 as libc::c_int != 0;
if handle.is_null() {
handle =
dlopen(b"libvorbisidec.so.1\x00" as *const u8 as
*const libc::c_char, 0x2 as libc::c_int);
if !handle.is_null() {
tremor = 1 as libc::c_int != 0
} else {
if loglevel as libc::c_uint >=
lINFO as libc::c_int as libc::c_uint {
logprint(b"%s %s:%d dlerror: %s\n\x00" as *const u8 as
*const libc::c_char, logtime(),
(*::std::mem::transmute::<&[u8; 12],
&[libc::c_char; 12]>(b"load_vorbis\x00")).as_ptr(),
332 as libc::c_int, dlerror());
}
return 0 as libc::c_int != 0
}
}
(*v).ov_read =
::std::mem::transmute::<*mut libc::c_void,
Option<unsafe extern "C" fn(_:
*mut OggVorbis_File,
_:
*mut libc::c_char,
_: libc::c_int,
_: libc::c_int,
_: libc::c_int,
_: libc::c_int,
_:
*mut libc::c_int)
->
libc::c_long>>(if tremor as
libc::c_int
!= 0 {
0 as
*mut libc::c_void
} else {
dlsym(handle,
b"ov_read\x00"
as
*const u8
as
*const libc::c_char)
});
(*v).ov_read_tremor =
::std::mem::transmute::<*mut libc::c_void,
Option<unsafe extern "C" fn(_:
*mut OggVorbis_File,
_:
*mut libc::c_char,
_: libc::c_int,
_:
*mut libc::c_int)
->
libc::c_long>>(if tremor as
libc::c_int
!= 0 {
dlsym(handle,
b"ov_read\x00"
as
*const u8
as
*const libc::c_char)
} else {
0 as
*mut libc::c_void
});
(*v).ov_info =
::std::mem::transmute::<*mut libc::c_void,
Option<unsafe extern "C" fn(_:
*mut OggVorbis_File,
_: libc::c_int)
->
*mut vorbis_info>>(dlsym(handle,
b"ov_info\x00"
as
*const u8
as
*const libc::c_char));
(*v).ov_clear =
::std::mem::transmute::<*mut libc::c_void,
Option<unsafe extern "C" fn(_:
*mut OggVorbis_File)
->
libc::c_int>>(dlsym(handle,
b"ov_clear\x00"
as
*const u8
as
*const libc::c_char));
(*v).ov_open_callbacks =
::std::mem::transmute::<*mut libc::c_void,
Option<unsafe extern "C" fn(_:
*mut libc::c_void,
_:
*mut OggVorbis_File,
_:
*const libc::c_char,
_: libc::c_long,
_: ov_callbacks)
->
libc::c_int>>(dlsym(handle,
b"ov_open_callbacks\x00"
as
*const u8
as
*const libc::c_char));
err = dlerror();
if !err.is_null() {
if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint {
logprint(b"%s %s:%d dlerror: %s\n\x00" as *const u8 as
*const libc::c_char, logtime(),
(*::std::mem::transmute::<&[u8; 12],
&[libc::c_char; 12]>(b"load_vorbis\x00")).as_ptr(),
344 as libc::c_int, err);
}
return 0 as libc::c_int != 0
}
if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint {
logprint(b"%s %s:%d loaded %s\n\x00" as *const u8 as
*const libc::c_char, logtime(),
(*::std::mem::transmute::<&[u8; 12],
&[libc::c_char; 12]>(b"load_vorbis\x00")).as_ptr(),
348 as libc::c_int,
if tremor as libc::c_int != 0 {
b"libvorbisidec.so.1\x00" as *const u8 as
*const libc::c_char
} else {
b"libvorbisfile.so.3\x00" as *const u8 as
*const libc::c_char
});
}
return 1 as libc::c_int != 0;
}
/*
* Squeezelite - lightweight headless squeezebox emulator
*
* (c) Adrian Smith 2012-2015, triode1@btinternet.com
* Ralph Irving 2015-2017, ralph_irving@hotmail.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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additions (c) Paul Hermann, 2015-2017 under the same license terms
* -Control of Raspberry pi GPIO for amplifier power
* -Launch script on power status change from LMS
*/
// make may define: PORTAUDIO, SELFPIPE, RESAMPLE, RESAMPLE_MP, VISEXPORT, GPIO, IR, DSD, LINKALL to influence build
// build detection
// dynamically loaded libraries at run time
// !LINKALL
// config options
// do not reduce as icy-meta max is 4080
/* SUN */
/* SUN */
// printf/scanf formats for u64_t
// logging
// utils.c (non logging)
// buffer.c
// _* called with mutex locked
// slimproto.c
// stream.c
// decode.c
// output.c output_alsa.c output_pa.c output_pack.c
// frames played at the point delay is measured
// ordered largest first so [0] is max_rate
// set in decode thread
// set in decode thread
// set by slimproto
// set by slimproto
// set by slimproto
// set by slimproto
// set by slimproto
// set by slimproto
// set by slimproto
// _* called with mutex locked
// output_alsa.c
// output_pa.c
// output_pulse.c
// output_stdout.c
// output_pack.c
// output_vis.c
// dop.c
// codecs
#[no_mangle]
pub unsafe extern "C" fn register_vorbis() -> *mut codec {
static mut ret: codec =
unsafe {
{
let mut init =
codec{id: 'o' as i32 as libc::c_char,
types:
b"ogg\x00" as *const u8 as *const libc::c_char
as *mut libc::c_char,
min_read_bytes: 4096 as libc::c_int as libc::c_uint,
min_space: 20480 as libc::c_int as libc::c_uint,
open:
Some(vorbis_open as
unsafe extern "C" fn(_: u8_t, _: u8_t,
_: u8_t, _: u8_t)
-> ()),
close:
Some(vorbis_close as
unsafe extern "C" fn() -> ()),
decode:
Some(vorbis_decode as
unsafe extern "C" fn()
-> decode_state),};
init
}
};
v =
malloc(::std::mem::size_of::<vorbis>() as libc::c_ulong) as
*mut vorbis;
if v.is_null() { return 0 as *mut codec }
(*v).vf = 0 as *mut OggVorbis_File;
(*v).opened = 0 as libc::c_int != 0;
if !load_vorbis() { return 0 as *mut codec }
if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint {
logprint(b"%s %s:%d using vorbis to decode ogg\n\x00" as *const u8 as
*const libc::c_char, logtime(),
(*::std::mem::transmute::<&[u8; 16],
&[libc::c_char; 16]>(b"register_vorbis\x00")).as_ptr(),
377 as libc::c_int);
}
return &mut ret;
}