Adding a transpiled version of [Ralph Irving's squeezelite](https://github.com/ralph-irving/squeezelite).
Transpiled by c2rust: `c2rust transpile --binary main compile_commands.json -r --reduce-type-annotations -o ../squeezers -- -I/usr/lib/clang/9.0.1/include`
This commit is contained in:
commit
33155c6ce2
81
.gitignore
vendored
Normal file
81
.gitignore
vendored
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
# ---> Rust
|
||||||
|
# Generated by Cargo
|
||||||
|
# will have compiled files and executables
|
||||||
|
/target/
|
||||||
|
|
||||||
|
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
|
||||||
|
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
|
||||||
|
Cargo.lock
|
||||||
|
|
||||||
|
# These are backup files generated by rustfmt
|
||||||
|
**/*.rs.bk
|
||||||
|
|
||||||
|
# ---> JetBrains
|
||||||
|
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
|
||||||
|
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
|
||||||
|
|
||||||
|
# User-specific stuff
|
||||||
|
.idea/**/workspace.xml
|
||||||
|
.idea/**/tasks.xml
|
||||||
|
.idea/**/usage.statistics.xml
|
||||||
|
.idea/**/dictionaries
|
||||||
|
.idea/**/shelf
|
||||||
|
|
||||||
|
# Generated files
|
||||||
|
.idea/**/contentModel.xml
|
||||||
|
|
||||||
|
# Sensitive or high-churn files
|
||||||
|
.idea/**/dataSources/
|
||||||
|
.idea/**/dataSources.ids
|
||||||
|
.idea/**/dataSources.local.xml
|
||||||
|
.idea/**/sqlDataSources.xml
|
||||||
|
.idea/**/dynamic.xml
|
||||||
|
.idea/**/uiDesigner.xml
|
||||||
|
.idea/**/dbnavigator.xml
|
||||||
|
|
||||||
|
# Gradle
|
||||||
|
.idea/**/gradle.xml
|
||||||
|
.idea/**/libraries
|
||||||
|
|
||||||
|
# Gradle and Maven with auto-import
|
||||||
|
# When using Gradle or Maven with auto-import, you should exclude module files,
|
||||||
|
# since they will be recreated, and may cause churn. Uncomment if using
|
||||||
|
# auto-import.
|
||||||
|
# .idea/modules.xml
|
||||||
|
# .idea/*.iml
|
||||||
|
# .idea/modules
|
||||||
|
|
||||||
|
# CMake
|
||||||
|
cmake-build-*/
|
||||||
|
|
||||||
|
# Mongo Explorer plugin
|
||||||
|
.idea/**/mongoSettings.xml
|
||||||
|
|
||||||
|
# File-based project format
|
||||||
|
*.iws
|
||||||
|
|
||||||
|
# IntelliJ
|
||||||
|
out/
|
||||||
|
|
||||||
|
# mpeltonen/sbt-idea plugin
|
||||||
|
.idea_modules/
|
||||||
|
|
||||||
|
# JIRA plugin
|
||||||
|
atlassian-ide-plugin.xml
|
||||||
|
|
||||||
|
# Cursive Clojure plugin
|
||||||
|
.idea/replstate.xml
|
||||||
|
|
||||||
|
# Crashlytics plugin (for Android Studio and IntelliJ)
|
||||||
|
com_crashlytics_export_strings.xml
|
||||||
|
crashlytics.properties
|
||||||
|
crashlytics-build.properties
|
||||||
|
fabric.properties
|
||||||
|
|
||||||
|
# Editor-based Rest Client
|
||||||
|
.idea/httpRequests
|
||||||
|
|
||||||
|
# Android studio 3.1+ serialized cache file
|
||||||
|
.idea/caches/build_file_checksums.ser
|
||||||
|
|
||||||
|
|
29
Cargo.toml
Normal file
29
Cargo.toml
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
[workspace]
|
||||||
|
members = [
|
||||||
|
]
|
||||||
|
|
||||||
|
[package]
|
||||||
|
name = "squeezers"
|
||||||
|
authors = ["C2Rust"]
|
||||||
|
version = "0.0.0"
|
||||||
|
publish = false
|
||||||
|
edition = "2018"
|
||||||
|
autobins = false
|
||||||
|
|
||||||
|
[lib]
|
||||||
|
name = "squeezers"
|
||||||
|
path = "lib.rs"
|
||||||
|
crate-type = ["staticlib", "rlib"]
|
||||||
|
|
||||||
|
|
||||||
|
[[bin]]
|
||||||
|
path = "src/main.rs"
|
||||||
|
name = "main"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
c2rust-bitfields = "0.3"
|
||||||
|
c2rust-asm-casts = "0.1"
|
||||||
|
libc = "0.2"
|
||||||
|
|
||||||
|
|
||||||
|
|
33
README.md
Normal file
33
README.md
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
Squeezelite v1.9.x, Copyright 2012-2015 Adrian Smith, 2015-2019 Ralph Irving.
|
||||||
|
|
||||||
|
See the squeezelite manpage for usage details.
|
||||||
|
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/
|
13
build.rs
Normal file
13
build.rs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
#[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");
|
||||||
|
}
|
51
lib.rs
Normal file
51
lib.rs
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
#![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)]
|
||||||
|
#![feature(asm)]
|
||||||
|
#![feature(c_variadic)]
|
||||||
|
#![feature(const_raw_ptr_to_usize_cast)]
|
||||||
|
#![feature(extern_types)]
|
||||||
|
#![feature(main)]
|
||||||
|
#![feature(ptr_wrapping_offset_from)]
|
||||||
|
#![feature(register_tool)]
|
||||||
|
#![register_tool(c2rust)]
|
||||||
|
|
||||||
|
#[path = "src/internal.rs"]
|
||||||
|
pub mod internal;
|
||||||
|
#[path = "src/squeezelite_h.rs"]
|
||||||
|
pub mod squeezelite_h;
|
||||||
|
#[path = "src/stdarg_h.rs"]
|
||||||
|
pub mod stdarg_h;
|
||||||
|
#[path = "src/stddef_h.rs"]
|
||||||
|
pub mod stddef_h;
|
||||||
|
#[path = "src/stdlib.rs"]
|
||||||
|
pub mod stdlib;
|
||||||
|
#[macro_use]
|
||||||
|
extern crate c2rust_bitfields;
|
||||||
|
#[macro_use]
|
||||||
|
extern crate c2rust_asm_casts;
|
||||||
|
extern crate libc;
|
||||||
|
|
||||||
|
pub mod src {
|
||||||
|
pub mod buffer;
|
||||||
|
pub mod decode;
|
||||||
|
pub mod faad;
|
||||||
|
pub mod flac;
|
||||||
|
pub mod mad;
|
||||||
|
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
|
1
rust-toolchain
Normal file
1
rust-toolchain
Normal file
@ -0,0 +1 @@
|
|||||||
|
nightly-2019-12-05
|
227
src/buffer.rs
Normal file
227
src/buffer.rs
Normal file
@ -0,0 +1,227 @@
|
|||||||
|
use ::libc;
|
||||||
|
|
||||||
|
pub use crate::stddef_h::size_t;
|
||||||
|
pub use crate::stdlib::__uint8_t;
|
||||||
|
pub use crate::stdlib::u_int8_t;
|
||||||
|
|
||||||
|
pub use crate::squeezelite_h::buffer;
|
||||||
|
pub use crate::squeezelite_h::u8_t;
|
||||||
|
pub use crate::stdlib::__pthread_internal_list;
|
||||||
|
pub use crate::stdlib::__pthread_list_t;
|
||||||
|
pub use crate::stdlib::__pthread_mutex_s;
|
||||||
|
use crate::stdlib::free;
|
||||||
|
use crate::stdlib::malloc;
|
||||||
|
pub use crate::stdlib::pthread_mutex_destroy;
|
||||||
|
pub use crate::stdlib::pthread_mutex_init;
|
||||||
|
pub use crate::stdlib::pthread_mutex_lock;
|
||||||
|
pub use crate::stdlib::pthread_mutex_t;
|
||||||
|
pub use crate::stdlib::pthread_mutex_unlock;
|
||||||
|
pub use crate::stdlib::pthread_mutexattr_destroy;
|
||||||
|
pub use crate::stdlib::pthread_mutexattr_init;
|
||||||
|
pub use crate::stdlib::pthread_mutexattr_setprotocol;
|
||||||
|
pub use crate::stdlib::pthread_mutexattr_t;
|
||||||
|
pub use crate::stdlib::C2RustUnnamed_0;
|
||||||
|
pub use crate::stdlib::PTHREAD_PRIO_INHERIT;
|
||||||
|
pub use crate::stdlib::PTHREAD_PRIO_NONE;
|
||||||
|
pub use crate::stdlib::PTHREAD_PRIO_PROTECT;
|
||||||
|
/*
|
||||||
|
* 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 crate::squeezelite_h::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 crate::squeezelite_h::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 crate::squeezelite_h::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 crate::squeezelite_h::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 crate::squeezelite_h::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 crate::squeezelite_h::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 crate::squeezelite_h::buffer) {
|
||||||
|
crate::stdlib::pthread_mutex_lock(&mut (*buf).mutex);
|
||||||
|
(*buf).readp = (*buf).buf;
|
||||||
|
(*buf).writep = (*buf).buf;
|
||||||
|
crate::stdlib::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 crate::squeezelite_h::buffer,
|
||||||
|
mut mod_0: crate::stddef_h::size_t,
|
||||||
|
) {
|
||||||
|
let mut size: crate::stddef_h::size_t = 0;
|
||||||
|
crate::stdlib::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;
|
||||||
|
crate::stdlib::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 crate::squeezelite_h::buffer,
|
||||||
|
mut size: crate::stddef_h::size_t,
|
||||||
|
) {
|
||||||
|
crate::stdlib::free((*buf).buf as *mut libc::c_void);
|
||||||
|
(*buf).buf = crate::stdlib::malloc(size) as *mut crate::squeezelite_h::u8_t;
|
||||||
|
if (*buf).buf.is_null() {
|
||||||
|
size = (*buf).size;
|
||||||
|
(*buf).buf = crate::stdlib::malloc(size) as *mut crate::squeezelite_h::u8_t;
|
||||||
|
if (*buf).buf.is_null() {
|
||||||
|
size = 0 as libc::c_int as crate::stddef_h::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 crate::squeezelite_h::buffer,
|
||||||
|
mut size: crate::stddef_h::size_t,
|
||||||
|
) {
|
||||||
|
(*buf).buf = crate::stdlib::malloc(size) as *mut crate::squeezelite_h::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 = crate::stdlib::pthread_mutexattr_t { __size: [0; 4] };
|
||||||
|
crate::stdlib::pthread_mutexattr_init(&mut attr);
|
||||||
|
crate::stdlib::pthread_mutexattr_setprotocol(
|
||||||
|
&mut attr,
|
||||||
|
crate::stdlib::PTHREAD_PRIO_INHERIT as libc::c_int,
|
||||||
|
);
|
||||||
|
crate::stdlib::pthread_mutex_init(&mut (*buf).mutex, &mut attr);
|
||||||
|
crate::stdlib::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 crate::squeezelite_h::buffer) {
|
||||||
|
if !(*buf).buf.is_null() {
|
||||||
|
crate::stdlib::free((*buf).buf as *mut libc::c_void);
|
||||||
|
(*buf).buf = 0 as *mut crate::squeezelite_h::u8_t;
|
||||||
|
(*buf).size = 0 as libc::c_int as crate::stddef_h::size_t;
|
||||||
|
(*buf).base_size = 0 as libc::c_int as crate::stddef_h::size_t;
|
||||||
|
crate::stdlib::pthread_mutex_destroy(&mut (*buf).mutex);
|
||||||
|
};
|
||||||
|
}
|
669
src/decode.rs
Normal file
669
src/decode.rs
Normal file
@ -0,0 +1,669 @@
|
|||||||
|
use ::libc;
|
||||||
|
|
||||||
|
pub use crate::stddef_h::size_t;
|
||||||
|
pub use crate::stdlib::__int32_t;
|
||||||
|
pub use crate::stdlib::__uint32_t;
|
||||||
|
pub use crate::stdlib::__uint64_t;
|
||||||
|
pub use crate::stdlib::__uint8_t;
|
||||||
|
pub use crate::stdlib::__useconds_t;
|
||||||
|
pub use crate::stdlib::int32_t;
|
||||||
|
|
||||||
|
pub use crate::squeezelite_h::_buf_used;
|
||||||
|
pub use crate::squeezelite_h::buffer;
|
||||||
|
pub use crate::squeezelite_h::codec;
|
||||||
|
pub use crate::squeezelite_h::decode_state;
|
||||||
|
pub use crate::squeezelite_h::decodestate;
|
||||||
|
pub use crate::squeezelite_h::disconnect_code;
|
||||||
|
pub use crate::squeezelite_h::fade_dir;
|
||||||
|
pub use crate::squeezelite_h::fade_mode;
|
||||||
|
pub use crate::squeezelite_h::fade_state;
|
||||||
|
pub use crate::squeezelite_h::frames_t;
|
||||||
|
pub use crate::squeezelite_h::lDEBUG;
|
||||||
|
pub use crate::squeezelite_h::lERROR;
|
||||||
|
pub use crate::squeezelite_h::lINFO;
|
||||||
|
pub use crate::squeezelite_h::lSDEBUG;
|
||||||
|
pub use crate::squeezelite_h::lWARN;
|
||||||
|
pub use crate::squeezelite_h::log_level;
|
||||||
|
pub use crate::squeezelite_h::output_format;
|
||||||
|
pub use crate::squeezelite_h::output_state;
|
||||||
|
pub use crate::squeezelite_h::outputstate;
|
||||||
|
pub use crate::squeezelite_h::s32_t;
|
||||||
|
pub use crate::squeezelite_h::stream_state;
|
||||||
|
pub use crate::squeezelite_h::streamstate;
|
||||||
|
pub use crate::squeezelite_h::u32_t;
|
||||||
|
pub use crate::squeezelite_h::u64_t;
|
||||||
|
pub use crate::squeezelite_h::u8_t;
|
||||||
|
pub use crate::squeezelite_h::C2RustUnnamed_1;
|
||||||
|
pub use crate::squeezelite_h::DECODE_COMPLETE;
|
||||||
|
pub use crate::squeezelite_h::DECODE_ERROR;
|
||||||
|
pub use crate::squeezelite_h::DECODE_READY;
|
||||||
|
pub use crate::squeezelite_h::DECODE_RUNNING;
|
||||||
|
pub use crate::squeezelite_h::DECODE_STOPPED;
|
||||||
|
pub use crate::squeezelite_h::DISCONNECT;
|
||||||
|
pub use crate::squeezelite_h::DISCONNECT_OK;
|
||||||
|
pub use crate::squeezelite_h::FADE_ACTIVE;
|
||||||
|
pub use crate::squeezelite_h::FADE_CROSS;
|
||||||
|
pub use crate::squeezelite_h::FADE_CROSSFADE;
|
||||||
|
pub use crate::squeezelite_h::FADE_DOWN;
|
||||||
|
pub use crate::squeezelite_h::FADE_DUE;
|
||||||
|
pub use crate::squeezelite_h::FADE_IN;
|
||||||
|
pub use crate::squeezelite_h::FADE_INACTIVE;
|
||||||
|
pub use crate::squeezelite_h::FADE_INOUT;
|
||||||
|
pub use crate::squeezelite_h::FADE_NONE;
|
||||||
|
pub use crate::squeezelite_h::FADE_OUT;
|
||||||
|
pub use crate::squeezelite_h::FADE_UP;
|
||||||
|
pub use crate::squeezelite_h::LOCAL_DISCONNECT;
|
||||||
|
pub use crate::squeezelite_h::OUTPUT_BUFFER;
|
||||||
|
pub use crate::squeezelite_h::OUTPUT_OFF;
|
||||||
|
pub use crate::squeezelite_h::OUTPUT_PAUSE_FRAMES;
|
||||||
|
pub use crate::squeezelite_h::OUTPUT_RUNNING;
|
||||||
|
pub use crate::squeezelite_h::OUTPUT_SKIP_FRAMES;
|
||||||
|
pub use crate::squeezelite_h::OUTPUT_START_AT;
|
||||||
|
pub use crate::squeezelite_h::OUTPUT_STOPPED;
|
||||||
|
pub use crate::squeezelite_h::RECV_HEADERS;
|
||||||
|
pub use crate::squeezelite_h::REMOTE_DISCONNECT;
|
||||||
|
pub use crate::squeezelite_h::S16_LE;
|
||||||
|
pub use crate::squeezelite_h::S24_3LE;
|
||||||
|
pub use crate::squeezelite_h::S24_LE;
|
||||||
|
pub use crate::squeezelite_h::S32_LE;
|
||||||
|
pub use crate::squeezelite_h::SEND_HEADERS;
|
||||||
|
pub use crate::squeezelite_h::STOPPED;
|
||||||
|
pub use crate::squeezelite_h::STREAMING_BUFFERING;
|
||||||
|
pub use crate::squeezelite_h::STREAMING_FILE;
|
||||||
|
pub use crate::squeezelite_h::STREAMING_HTTP;
|
||||||
|
pub use crate::squeezelite_h::STREAMING_WAIT;
|
||||||
|
pub use crate::squeezelite_h::TIMEOUT;
|
||||||
|
pub use crate::squeezelite_h::UNREACHABLE;
|
||||||
|
pub use crate::src::buffer::_buf_space;
|
||||||
|
pub use crate::src::faad::register_faad;
|
||||||
|
pub use crate::src::flac::register_flac;
|
||||||
|
pub use crate::src::mad::register_mad;
|
||||||
|
pub use crate::src::mpg::register_mpg;
|
||||||
|
pub use crate::src::output::_checkfade;
|
||||||
|
pub use crate::src::pcm::register_pcm;
|
||||||
|
pub use crate::src::slimproto::wake_controller;
|
||||||
|
pub use crate::src::utils::logprint;
|
||||||
|
pub use crate::src::utils::logtime;
|
||||||
|
pub use crate::src::vorbis::register_vorbis;
|
||||||
|
pub use crate::stdlib::__pthread_internal_list;
|
||||||
|
pub use crate::stdlib::__pthread_list_t;
|
||||||
|
pub use crate::stdlib::__pthread_mutex_s;
|
||||||
|
use crate::stdlib::pthread_attr_destroy;
|
||||||
|
use crate::stdlib::pthread_attr_init;
|
||||||
|
use crate::stdlib::pthread_attr_setstacksize;
|
||||||
|
pub use crate::stdlib::pthread_attr_t;
|
||||||
|
use crate::stdlib::pthread_create;
|
||||||
|
use crate::stdlib::pthread_join;
|
||||||
|
use crate::stdlib::pthread_mutex_destroy;
|
||||||
|
use crate::stdlib::pthread_mutex_init;
|
||||||
|
use crate::stdlib::pthread_mutex_lock;
|
||||||
|
pub use crate::stdlib::pthread_mutex_t;
|
||||||
|
use crate::stdlib::pthread_mutex_unlock;
|
||||||
|
pub use crate::stdlib::pthread_mutexattr_t;
|
||||||
|
pub use crate::stdlib::pthread_t;
|
||||||
|
use crate::stdlib::strstr;
|
||||||
|
pub use crate::stdlib::u_int32_t;
|
||||||
|
pub use crate::stdlib::u_int64_t;
|
||||||
|
pub use crate::stdlib::u_int8_t;
|
||||||
|
use crate::stdlib::usleep;
|
||||||
|
extern "C" {
|
||||||
|
#[no_mangle]
|
||||||
|
pub static mut streambuf: *mut crate::squeezelite_h::buffer;
|
||||||
|
#[no_mangle]
|
||||||
|
pub static mut outputbuf: *mut crate::squeezelite_h::buffer;
|
||||||
|
#[no_mangle]
|
||||||
|
pub static mut stream: crate::squeezelite_h::streamstate;
|
||||||
|
#[no_mangle]
|
||||||
|
pub static mut output: crate::squeezelite_h::outputstate;
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
* 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: crate::squeezelite_h::log_level = crate::squeezelite_h::lERROR;
|
||||||
|
#[no_mangle]
|
||||||
|
|
||||||
|
pub static mut decode: crate::squeezelite_h::decodestate = crate::squeezelite_h::decodestate {
|
||||||
|
state: crate::squeezelite_h::DECODE_STOPPED,
|
||||||
|
new_stream: false,
|
||||||
|
mutex: crate::stdlib::pthread_mutex_t {
|
||||||
|
__data: crate::stdlib::__pthread_mutex_s {
|
||||||
|
__lock: 0,
|
||||||
|
__count: 0,
|
||||||
|
__owner: 0,
|
||||||
|
__nusers: 0,
|
||||||
|
__kind: 0,
|
||||||
|
__spins: 0,
|
||||||
|
__elision: 0,
|
||||||
|
__list: crate::stdlib::__pthread_list_t {
|
||||||
|
__prev: 0 as *const crate::stdlib::__pthread_internal_list
|
||||||
|
as *mut crate::stdlib::__pthread_internal_list,
|
||||||
|
__next: 0 as *const crate::stdlib::__pthread_internal_list
|
||||||
|
as *mut crate::stdlib::__pthread_internal_list,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
#[no_mangle]
|
||||||
|
|
||||||
|
pub static mut codecs: [*mut crate::squeezelite_h::codec; 10] =
|
||||||
|
[0 as *const crate::squeezelite_h::codec as *mut crate::squeezelite_h::codec; 10];
|
||||||
|
#[no_mangle]
|
||||||
|
|
||||||
|
pub static mut codec: *mut crate::squeezelite_h::codec =
|
||||||
|
0 as *const crate::squeezelite_h::codec as *mut crate::squeezelite_h::codec;
|
||||||
|
|
||||||
|
static mut flac_container: crate::squeezelite_h::u8_t = '?' as i32 as crate::squeezelite_h::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: crate::stddef_h::size_t = 0;
|
||||||
|
let mut space: crate::stddef_h::size_t = 0;
|
||||||
|
let mut min_space: crate::stddef_h::size_t = 0;
|
||||||
|
let mut toend: bool = false;
|
||||||
|
let mut ran = 0 as libc::c_int != 0;
|
||||||
|
crate::stdlib::pthread_mutex_lock(&mut (*streambuf).mutex);
|
||||||
|
bytes = crate::squeezelite_h::_buf_used(streambuf) as crate::stddef_h::size_t;
|
||||||
|
toend = stream.state as libc::c_uint
|
||||||
|
<= crate::squeezelite_h::DISCONNECT as libc::c_int as libc::c_uint;
|
||||||
|
crate::stdlib::pthread_mutex_unlock(&mut (*streambuf).mutex);
|
||||||
|
crate::stdlib::pthread_mutex_lock(&mut (*outputbuf).mutex);
|
||||||
|
space = crate::src::buffer::_buf_space(outputbuf) as crate::stddef_h::size_t;
|
||||||
|
crate::stdlib::pthread_mutex_unlock(&mut (*outputbuf).mutex);
|
||||||
|
crate::stdlib::pthread_mutex_lock(&mut decode.mutex);
|
||||||
|
if decode.state as libc::c_uint
|
||||||
|
== crate::squeezelite_h::DECODE_RUNNING as libc::c_int as libc::c_uint
|
||||||
|
&& !codec.is_null()
|
||||||
|
{
|
||||||
|
if loglevel as libc::c_uint
|
||||||
|
>= crate::squeezelite_h::lSDEBUG as libc::c_int as libc::c_uint
|
||||||
|
{
|
||||||
|
crate::src::utils::logprint(
|
||||||
|
b"%s %s:%d streambuf bytes: %u outputbuf space: %u\n\x00" as *const u8
|
||||||
|
as *const libc::c_char,
|
||||||
|
crate::src::utils::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 crate::stddef_h::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
|
||||||
|
!= crate::squeezelite_h::DECODE_RUNNING as libc::c_int as libc::c_uint
|
||||||
|
{
|
||||||
|
if loglevel as libc::c_uint
|
||||||
|
>= crate::squeezelite_h::lINFO as libc::c_int as libc::c_uint
|
||||||
|
{
|
||||||
|
crate::src::utils::logprint(
|
||||||
|
b"%s %s:%d decode %s\n\x00" as *const u8 as *const libc::c_char,
|
||||||
|
crate::src::utils::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
|
||||||
|
== crate::squeezelite_h::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
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
crate::stdlib::pthread_mutex_lock(&mut (*outputbuf).mutex);
|
||||||
|
if output.fade_mode as u64 != 0 {
|
||||||
|
crate::src::output::_checkfade(0 as libc::c_int != 0);
|
||||||
|
}
|
||||||
|
crate::stdlib::pthread_mutex_unlock(&mut (*outputbuf).mutex);
|
||||||
|
crate::src::slimproto::wake_controller();
|
||||||
|
}
|
||||||
|
ran = 1 as libc::c_int != 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
crate::stdlib::pthread_mutex_unlock(&mut decode.mutex);
|
||||||
|
if !ran {
|
||||||
|
crate::stdlib::usleep(100000 as libc::c_int as crate::stdlib::__useconds_t);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0 as *mut libc::c_void;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe extern "C" fn sort_codecs(mut pry: libc::c_int, mut ptr: *mut crate::squeezelite_h::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 = 0 as *mut crate::squeezelite_h::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: crate::stdlib::pthread_t = 0;
|
||||||
|
#[no_mangle]
|
||||||
|
|
||||||
|
pub unsafe extern "C" fn decode_init(
|
||||||
|
mut level: crate::squeezelite_h::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 = 0 as *mut libc::c_char;
|
||||||
|
loglevel = level;
|
||||||
|
if loglevel as libc::c_uint >= crate::squeezelite_h::lINFO as libc::c_int as libc::c_uint {
|
||||||
|
crate::src::utils::logprint(
|
||||||
|
b"%s %s:%d init decode\n\x00" as *const u8 as *const libc::c_char,
|
||||||
|
crate::src::utils::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 crate::stdlib::strstr(
|
||||||
|
exclude_codecs,
|
||||||
|
b"aac\x00" as *const u8 as *const libc::c_char,
|
||||||
|
)
|
||||||
|
.is_null()
|
||||||
|
&& (include_codecs.is_null() || {
|
||||||
|
order_codecs = crate::stdlib::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,
|
||||||
|
crate::src::faad::register_faad(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if crate::stdlib::strstr(
|
||||||
|
exclude_codecs,
|
||||||
|
b"ogg\x00" as *const u8 as *const libc::c_char,
|
||||||
|
)
|
||||||
|
.is_null()
|
||||||
|
&& (include_codecs.is_null() || {
|
||||||
|
order_codecs = crate::stdlib::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,
|
||||||
|
crate::src::vorbis::register_vorbis(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if crate::stdlib::strstr(
|
||||||
|
exclude_codecs,
|
||||||
|
b"flac\x00" as *const u8 as *const libc::c_char,
|
||||||
|
)
|
||||||
|
.is_null()
|
||||||
|
&& (include_codecs.is_null() || {
|
||||||
|
order_codecs = crate::stdlib::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,
|
||||||
|
crate::src::flac::register_flac(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if crate::stdlib::strstr(
|
||||||
|
exclude_codecs,
|
||||||
|
b"pcm\x00" as *const u8 as *const libc::c_char,
|
||||||
|
)
|
||||||
|
.is_null()
|
||||||
|
&& (include_codecs.is_null() || {
|
||||||
|
order_codecs = crate::stdlib::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,
|
||||||
|
crate::src::pcm::register_pcm(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
// try mad then mpg for mp3 unless command line option passed
|
||||||
|
if !(!crate::stdlib::strstr(
|
||||||
|
exclude_codecs,
|
||||||
|
b"mp3\x00" as *const u8 as *const libc::c_char,
|
||||||
|
)
|
||||||
|
.is_null()
|
||||||
|
|| !crate::stdlib::strstr(
|
||||||
|
exclude_codecs,
|
||||||
|
b"mad\x00" as *const u8 as *const libc::c_char,
|
||||||
|
)
|
||||||
|
.is_null())
|
||||||
|
&& (include_codecs.is_null()
|
||||||
|
|| {
|
||||||
|
order_codecs = crate::stdlib::strstr(
|
||||||
|
include_codecs,
|
||||||
|
b"mp3\x00" as *const u8 as *const libc::c_char,
|
||||||
|
);
|
||||||
|
!order_codecs.is_null()
|
||||||
|
}
|
||||||
|
|| {
|
||||||
|
order_codecs = crate::stdlib::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,
|
||||||
|
crate::src::mad::register_mad(),
|
||||||
|
);
|
||||||
|
} else if !(!crate::stdlib::strstr(
|
||||||
|
exclude_codecs,
|
||||||
|
b"mp3\x00" as *const u8 as *const libc::c_char,
|
||||||
|
)
|
||||||
|
.is_null()
|
||||||
|
|| !crate::stdlib::strstr(
|
||||||
|
exclude_codecs,
|
||||||
|
b"mpg\x00" as *const u8 as *const libc::c_char,
|
||||||
|
)
|
||||||
|
.is_null())
|
||||||
|
&& (include_codecs.is_null()
|
||||||
|
|| {
|
||||||
|
order_codecs = crate::stdlib::strstr(
|
||||||
|
include_codecs,
|
||||||
|
b"mp3\x00" as *const u8 as *const libc::c_char,
|
||||||
|
);
|
||||||
|
!order_codecs.is_null()
|
||||||
|
}
|
||||||
|
|| {
|
||||||
|
order_codecs = crate::stdlib::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,
|
||||||
|
crate::src::mpg::register_mpg(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if loglevel as libc::c_uint >= crate::squeezelite_h::lDEBUG as libc::c_int as libc::c_uint {
|
||||||
|
crate::src::utils::logprint(
|
||||||
|
b"%s %s:%d include codecs: %s exclude codecs: %s\n\x00" as *const u8
|
||||||
|
as *const libc::c_char,
|
||||||
|
crate::src::utils::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,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
crate::stdlib::pthread_mutex_init(
|
||||||
|
&mut decode.mutex,
|
||||||
|
0 as *const crate::stdlib::pthread_mutexattr_t,
|
||||||
|
);
|
||||||
|
let mut attr = crate::stdlib::pthread_attr_t { __size: [0; 56] };
|
||||||
|
crate::stdlib::pthread_attr_init(&mut attr);
|
||||||
|
crate::stdlib::pthread_attr_setstacksize(
|
||||||
|
&mut attr,
|
||||||
|
(16384 as libc::c_int + 128 as libc::c_int * 1024 as libc::c_int)
|
||||||
|
as crate::stddef_h::size_t,
|
||||||
|
);
|
||||||
|
crate::stdlib::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,
|
||||||
|
);
|
||||||
|
crate::stdlib::pthread_attr_destroy(&mut attr);
|
||||||
|
decode.new_stream = 1 as libc::c_int != 0;
|
||||||
|
decode.state = crate::squeezelite_h::DECODE_STOPPED;
|
||||||
|
}
|
||||||
|
#[no_mangle]
|
||||||
|
|
||||||
|
pub unsafe extern "C" fn decode_close() {
|
||||||
|
if loglevel as libc::c_uint >= crate::squeezelite_h::lINFO as libc::c_int as libc::c_uint {
|
||||||
|
crate::src::utils::logprint(
|
||||||
|
b"%s %s:%d close decode\n\x00" as *const u8 as *const libc::c_char,
|
||||||
|
crate::src::utils::logtime(),
|
||||||
|
(*::std::mem::transmute::<&[u8; 13], &[libc::c_char; 13]>(b"decode_close\x00"))
|
||||||
|
.as_ptr(),
|
||||||
|
222 as libc::c_int,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
crate::stdlib::pthread_mutex_lock(&mut decode.mutex);
|
||||||
|
if !codec.is_null() {
|
||||||
|
(*codec).close.expect("non-null function pointer")();
|
||||||
|
codec = 0 as *mut crate::squeezelite_h::codec
|
||||||
|
}
|
||||||
|
running = 0 as libc::c_int != 0;
|
||||||
|
crate::stdlib::pthread_mutex_unlock(&mut decode.mutex);
|
||||||
|
crate::stdlib::pthread_join(thread, 0 as *mut *mut libc::c_void);
|
||||||
|
crate::stdlib::pthread_mutex_destroy(&mut decode.mutex);
|
||||||
|
}
|
||||||
|
#[no_mangle]
|
||||||
|
|
||||||
|
pub unsafe extern "C" fn decode_flush() {
|
||||||
|
if loglevel as libc::c_uint >= crate::squeezelite_h::lINFO as libc::c_int as libc::c_uint {
|
||||||
|
crate::src::utils::logprint(
|
||||||
|
b"%s %s:%d decode flush\n\x00" as *const u8 as *const libc::c_char,
|
||||||
|
crate::src::utils::logtime(),
|
||||||
|
(*::std::mem::transmute::<&[u8; 13], &[libc::c_char; 13]>(b"decode_flush\x00"))
|
||||||
|
.as_ptr(),
|
||||||
|
237 as libc::c_int,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
crate::stdlib::pthread_mutex_lock(&mut decode.mutex);
|
||||||
|
decode.state = crate::squeezelite_h::DECODE_STOPPED;
|
||||||
|
crate::stdlib::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: crate::squeezelite_h::u8_t,
|
||||||
|
mut sample_size: crate::squeezelite_h::u8_t,
|
||||||
|
mut sample_rate: crate::squeezelite_h::u8_t,
|
||||||
|
mut channels: crate::squeezelite_h::u8_t,
|
||||||
|
mut endianness: crate::squeezelite_h::u8_t,
|
||||||
|
) {
|
||||||
|
let mut i: libc::c_int = 0;
|
||||||
|
if loglevel as libc::c_uint >= crate::squeezelite_h::lINFO as libc::c_int as libc::c_uint {
|
||||||
|
crate::src::utils::logprint(
|
||||||
|
b"%s %s:%d codec open: \'%c\'\n\x00" as *const u8 as *const libc::c_char,
|
||||||
|
crate::src::utils::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,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
crate::stdlib::pthread_mutex_lock(&mut decode.mutex);
|
||||||
|
decode.new_stream = 1 as libc::c_int != 0;
|
||||||
|
decode.state = crate::squeezelite_h::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
|
||||||
|
>= crate::squeezelite_h::lINFO as libc::c_int as libc::c_uint
|
||||||
|
{
|
||||||
|
crate::src::utils::logprint(
|
||||||
|
b"%s %s:%d closing codec: \'%c\'\n\x00" as *const u8 as *const libc::c_char,
|
||||||
|
crate::src::utils::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 = crate::squeezelite_h::DECODE_READY;
|
||||||
|
crate::stdlib::pthread_mutex_unlock(&mut decode.mutex);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
i += 1
|
||||||
|
}
|
||||||
|
crate::stdlib::pthread_mutex_unlock(&mut decode.mutex);
|
||||||
|
crate::src::utils::logprint(
|
||||||
|
b"%s %s:%d codec not found\n\x00" as *const u8 as *const libc::c_char,
|
||||||
|
crate::src::utils::logtime(),
|
||||||
|
(*::std::mem::transmute::<&[u8; 11], &[libc::c_char; 11]>(b"codec_open\x00")).as_ptr(),
|
||||||
|
303 as libc::c_int,
|
||||||
|
);
|
||||||
|
}
|
1553
src/faad.rs
Normal file
1553
src/faad.rs
Normal file
File diff suppressed because it is too large
Load Diff
927
src/flac.rs
Normal file
927
src/flac.rs
Normal file
@ -0,0 +1,927 @@
|
|||||||
|
use ::c2rust_bitfields;
|
||||||
|
use ::libc;
|
||||||
|
|
||||||
|
pub use crate::stddef_h::size_t;
|
||||||
|
pub use crate::stdlib::__int32_t;
|
||||||
|
pub use crate::stdlib::__uint16_t;
|
||||||
|
pub use crate::stdlib::__uint32_t;
|
||||||
|
pub use crate::stdlib::__uint64_t;
|
||||||
|
pub use crate::stdlib::__uint8_t;
|
||||||
|
pub use crate::stdlib::int32_t;
|
||||||
|
|
||||||
|
pub use crate::stdlib::__pthread_internal_list;
|
||||||
|
pub use crate::stdlib::__pthread_list_t;
|
||||||
|
pub use crate::stdlib::__pthread_mutex_s;
|
||||||
|
pub use crate::stdlib::pthread_mutex_t;
|
||||||
|
pub use crate::stdlib::u_int32_t;
|
||||||
|
pub use crate::stdlib::u_int64_t;
|
||||||
|
pub use crate::stdlib::u_int8_t;
|
||||||
|
|
||||||
|
pub use crate::squeezelite_h::buffer;
|
||||||
|
pub use crate::squeezelite_h::codec;
|
||||||
|
pub use crate::squeezelite_h::decode_state;
|
||||||
|
pub use crate::squeezelite_h::decodestate;
|
||||||
|
pub use crate::squeezelite_h::disconnect_code;
|
||||||
|
pub use crate::squeezelite_h::fade_dir;
|
||||||
|
pub use crate::squeezelite_h::fade_mode;
|
||||||
|
pub use crate::squeezelite_h::fade_state;
|
||||||
|
pub use crate::squeezelite_h::frames_t;
|
||||||
|
pub use crate::squeezelite_h::lDEBUG;
|
||||||
|
pub use crate::squeezelite_h::lERROR;
|
||||||
|
pub use crate::squeezelite_h::lINFO;
|
||||||
|
pub use crate::squeezelite_h::lSDEBUG;
|
||||||
|
pub use crate::squeezelite_h::lWARN;
|
||||||
|
pub use crate::squeezelite_h::log_level;
|
||||||
|
pub use crate::squeezelite_h::output_format;
|
||||||
|
pub use crate::squeezelite_h::output_state;
|
||||||
|
pub use crate::squeezelite_h::outputstate;
|
||||||
|
pub use crate::squeezelite_h::s32_t;
|
||||||
|
pub use crate::squeezelite_h::stream_state;
|
||||||
|
pub use crate::squeezelite_h::streamstate;
|
||||||
|
pub use crate::squeezelite_h::u32_t;
|
||||||
|
pub use crate::squeezelite_h::u64_t;
|
||||||
|
pub use crate::squeezelite_h::u8_t;
|
||||||
|
pub use crate::squeezelite_h::C2RustUnnamed_1;
|
||||||
|
pub use crate::squeezelite_h::_buf_used;
|
||||||
|
pub use crate::squeezelite_h::DECODE_COMPLETE;
|
||||||
|
pub use crate::squeezelite_h::DECODE_ERROR;
|
||||||
|
pub use crate::squeezelite_h::DECODE_READY;
|
||||||
|
pub use crate::squeezelite_h::DECODE_RUNNING;
|
||||||
|
pub use crate::squeezelite_h::DECODE_STOPPED;
|
||||||
|
pub use crate::squeezelite_h::DISCONNECT;
|
||||||
|
pub use crate::squeezelite_h::DISCONNECT_OK;
|
||||||
|
pub use crate::squeezelite_h::FADE_ACTIVE;
|
||||||
|
pub use crate::squeezelite_h::FADE_CROSS;
|
||||||
|
pub use crate::squeezelite_h::FADE_CROSSFADE;
|
||||||
|
pub use crate::squeezelite_h::FADE_DOWN;
|
||||||
|
pub use crate::squeezelite_h::FADE_DUE;
|
||||||
|
pub use crate::squeezelite_h::FADE_IN;
|
||||||
|
pub use crate::squeezelite_h::FADE_INACTIVE;
|
||||||
|
pub use crate::squeezelite_h::FADE_INOUT;
|
||||||
|
pub use crate::squeezelite_h::FADE_NONE;
|
||||||
|
pub use crate::squeezelite_h::FADE_OUT;
|
||||||
|
pub use crate::squeezelite_h::FADE_UP;
|
||||||
|
pub use crate::squeezelite_h::LOCAL_DISCONNECT;
|
||||||
|
pub use crate::squeezelite_h::OUTPUT_BUFFER;
|
||||||
|
pub use crate::squeezelite_h::OUTPUT_OFF;
|
||||||
|
pub use crate::squeezelite_h::OUTPUT_PAUSE_FRAMES;
|
||||||
|
pub use crate::squeezelite_h::OUTPUT_RUNNING;
|
||||||
|
pub use crate::squeezelite_h::OUTPUT_SKIP_FRAMES;
|
||||||
|
pub use crate::squeezelite_h::OUTPUT_START_AT;
|
||||||
|
pub use crate::squeezelite_h::OUTPUT_STOPPED;
|
||||||
|
pub use crate::squeezelite_h::RECV_HEADERS;
|
||||||
|
pub use crate::squeezelite_h::REMOTE_DISCONNECT;
|
||||||
|
pub use crate::squeezelite_h::S16_LE;
|
||||||
|
pub use crate::squeezelite_h::S24_3LE;
|
||||||
|
pub use crate::squeezelite_h::S24_LE;
|
||||||
|
pub use crate::squeezelite_h::S32_LE;
|
||||||
|
pub use crate::squeezelite_h::SEND_HEADERS;
|
||||||
|
pub use crate::squeezelite_h::STOPPED;
|
||||||
|
pub use crate::squeezelite_h::STREAMING_BUFFERING;
|
||||||
|
pub use crate::squeezelite_h::STREAMING_FILE;
|
||||||
|
pub use crate::squeezelite_h::STREAMING_HTTP;
|
||||||
|
pub use crate::squeezelite_h::STREAMING_WAIT;
|
||||||
|
pub use crate::squeezelite_h::TIMEOUT;
|
||||||
|
pub use crate::squeezelite_h::UNREACHABLE;
|
||||||
|
pub use crate::src::buffer::_buf_cont_read;
|
||||||
|
pub use crate::src::buffer::_buf_cont_write;
|
||||||
|
pub use crate::src::buffer::_buf_inc_readp;
|
||||||
|
pub use crate::src::buffer::_buf_inc_writep;
|
||||||
|
pub use crate::src::buffer::_buf_space;
|
||||||
|
pub use crate::src::decode::decode_newstream;
|
||||||
|
pub use crate::src::output::_checkfade;
|
||||||
|
pub use crate::src::utils::logprint;
|
||||||
|
pub use crate::src::utils::logtime;
|
||||||
|
use crate::stdlib::malloc;
|
||||||
|
use crate::stdlib::memcpy;
|
||||||
|
pub use crate::stdlib::uint16_t;
|
||||||
|
pub use crate::stdlib::uint32_t;
|
||||||
|
pub use crate::stdlib::uint64_t;
|
||||||
|
pub use crate::stdlib::uint8_t;
|
||||||
|
pub use crate::stdlib::C2RustUnnamed_4;
|
||||||
|
pub use crate::stdlib::C2RustUnnamed_5;
|
||||||
|
pub use crate::stdlib::C2RustUnnamed_6;
|
||||||
|
pub use crate::stdlib::C2RustUnnamed_7;
|
||||||
|
pub use crate::stdlib::FLAC__ChannelAssignment;
|
||||||
|
pub use crate::stdlib::FLAC__EntropyCodingMethod;
|
||||||
|
pub use crate::stdlib::FLAC__EntropyCodingMethodType;
|
||||||
|
pub use crate::stdlib::FLAC__EntropyCodingMethod_PartitionedRice;
|
||||||
|
pub use crate::stdlib::FLAC__EntropyCodingMethod_PartitionedRiceContents;
|
||||||
|
pub use crate::stdlib::FLAC__Frame;
|
||||||
|
pub use crate::stdlib::FLAC__FrameFooter;
|
||||||
|
pub use crate::stdlib::FLAC__FrameHeader;
|
||||||
|
pub use crate::stdlib::FLAC__FrameNumberType;
|
||||||
|
pub use crate::stdlib::FLAC__MetadataType;
|
||||||
|
pub use crate::stdlib::FLAC__StreamDecoder;
|
||||||
|
pub use crate::stdlib::FLAC__StreamDecoderEofCallback;
|
||||||
|
pub use crate::stdlib::FLAC__StreamDecoderErrorCallback;
|
||||||
|
pub use crate::stdlib::FLAC__StreamDecoderErrorStatus;
|
||||||
|
pub use crate::stdlib::FLAC__StreamDecoderInitStatus;
|
||||||
|
pub use crate::stdlib::FLAC__StreamDecoderLengthCallback;
|
||||||
|
pub use crate::stdlib::FLAC__StreamDecoderLengthStatus;
|
||||||
|
pub use crate::stdlib::FLAC__StreamDecoderMetadataCallback;
|
||||||
|
pub use crate::stdlib::FLAC__StreamDecoderPrivate;
|
||||||
|
pub use crate::stdlib::FLAC__StreamDecoderProtected;
|
||||||
|
pub use crate::stdlib::FLAC__StreamDecoderReadCallback;
|
||||||
|
pub use crate::stdlib::FLAC__StreamDecoderReadStatus;
|
||||||
|
pub use crate::stdlib::FLAC__StreamDecoderSeekCallback;
|
||||||
|
pub use crate::stdlib::FLAC__StreamDecoderSeekStatus;
|
||||||
|
pub use crate::stdlib::FLAC__StreamDecoderState;
|
||||||
|
pub use crate::stdlib::FLAC__StreamDecoderTellCallback;
|
||||||
|
pub use crate::stdlib::FLAC__StreamDecoderTellStatus;
|
||||||
|
pub use crate::stdlib::FLAC__StreamDecoderWriteCallback;
|
||||||
|
pub use crate::stdlib::FLAC__StreamDecoderWriteStatus;
|
||||||
|
pub use crate::stdlib::FLAC__StreamMetadata;
|
||||||
|
pub use crate::stdlib::FLAC__StreamMetadata_Application;
|
||||||
|
pub use crate::stdlib::FLAC__StreamMetadata_CueSheet;
|
||||||
|
pub use crate::stdlib::FLAC__StreamMetadata_CueSheet_Index;
|
||||||
|
pub use crate::stdlib::FLAC__StreamMetadata_CueSheet_Track;
|
||||||
|
pub use crate::stdlib::FLAC__StreamMetadata_Padding;
|
||||||
|
pub use crate::stdlib::FLAC__StreamMetadata_Picture;
|
||||||
|
pub use crate::stdlib::FLAC__StreamMetadata_Picture_Type;
|
||||||
|
pub use crate::stdlib::FLAC__StreamMetadata_SeekPoint;
|
||||||
|
pub use crate::stdlib::FLAC__StreamMetadata_SeekTable;
|
||||||
|
pub use crate::stdlib::FLAC__StreamMetadata_StreamInfo;
|
||||||
|
pub use crate::stdlib::FLAC__StreamMetadata_Unknown;
|
||||||
|
pub use crate::stdlib::FLAC__StreamMetadata_VorbisComment;
|
||||||
|
pub use crate::stdlib::FLAC__StreamMetadata_VorbisComment_Entry;
|
||||||
|
pub use crate::stdlib::FLAC__Subframe;
|
||||||
|
pub use crate::stdlib::FLAC__SubframeType;
|
||||||
|
pub use crate::stdlib::FLAC__Subframe_Constant;
|
||||||
|
pub use crate::stdlib::FLAC__Subframe_Fixed;
|
||||||
|
pub use crate::stdlib::FLAC__Subframe_LPC;
|
||||||
|
pub use crate::stdlib::FLAC__Subframe_Verbatim;
|
||||||
|
pub use crate::stdlib::FLAC__bool;
|
||||||
|
pub use crate::stdlib::FLAC__byte;
|
||||||
|
pub use crate::stdlib::FLAC__int32;
|
||||||
|
pub use crate::stdlib::FLAC__uint16;
|
||||||
|
pub use crate::stdlib::FLAC__uint32;
|
||||||
|
pub use crate::stdlib::FLAC__uint64;
|
||||||
|
pub use crate::stdlib::FLAC__uint8;
|
||||||
|
pub use crate::stdlib::FLAC__CHANNEL_ASSIGNMENT_INDEPENDENT;
|
||||||
|
pub use crate::stdlib::FLAC__CHANNEL_ASSIGNMENT_LEFT_SIDE;
|
||||||
|
pub use crate::stdlib::FLAC__CHANNEL_ASSIGNMENT_MID_SIDE;
|
||||||
|
pub use crate::stdlib::FLAC__CHANNEL_ASSIGNMENT_RIGHT_SIDE;
|
||||||
|
pub use crate::stdlib::FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE;
|
||||||
|
pub use crate::stdlib::FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2;
|
||||||
|
pub use crate::stdlib::FLAC__FRAME_NUMBER_TYPE_FRAME_NUMBER;
|
||||||
|
pub use crate::stdlib::FLAC__FRAME_NUMBER_TYPE_SAMPLE_NUMBER;
|
||||||
|
pub use crate::stdlib::FLAC__MAX_METADATA_TYPE;
|
||||||
|
pub use crate::stdlib::FLAC__METADATA_TYPE_APPLICATION;
|
||||||
|
pub use crate::stdlib::FLAC__METADATA_TYPE_CUESHEET;
|
||||||
|
pub use crate::stdlib::FLAC__METADATA_TYPE_PADDING;
|
||||||
|
pub use crate::stdlib::FLAC__METADATA_TYPE_PICTURE;
|
||||||
|
pub use crate::stdlib::FLAC__METADATA_TYPE_SEEKTABLE;
|
||||||
|
pub use crate::stdlib::FLAC__METADATA_TYPE_STREAMINFO;
|
||||||
|
pub use crate::stdlib::FLAC__METADATA_TYPE_UNDEFINED;
|
||||||
|
pub use crate::stdlib::FLAC__METADATA_TYPE_VORBIS_COMMENT;
|
||||||
|
pub use crate::stdlib::FLAC__STREAM_DECODER_ABORTED;
|
||||||
|
pub use crate::stdlib::FLAC__STREAM_DECODER_END_OF_STREAM;
|
||||||
|
pub use crate::stdlib::FLAC__STREAM_DECODER_ERROR_STATUS_BAD_HEADER;
|
||||||
|
pub use crate::stdlib::FLAC__STREAM_DECODER_ERROR_STATUS_FRAME_CRC_MISMATCH;
|
||||||
|
pub use crate::stdlib::FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC;
|
||||||
|
pub use crate::stdlib::FLAC__STREAM_DECODER_ERROR_STATUS_UNPARSEABLE_STREAM;
|
||||||
|
pub use crate::stdlib::FLAC__STREAM_DECODER_INIT_STATUS_ALREADY_INITIALIZED;
|
||||||
|
pub use crate::stdlib::FLAC__STREAM_DECODER_INIT_STATUS_ERROR_OPENING_FILE;
|
||||||
|
pub use crate::stdlib::FLAC__STREAM_DECODER_INIT_STATUS_INVALID_CALLBACKS;
|
||||||
|
pub use crate::stdlib::FLAC__STREAM_DECODER_INIT_STATUS_MEMORY_ALLOCATION_ERROR;
|
||||||
|
pub use crate::stdlib::FLAC__STREAM_DECODER_INIT_STATUS_OK;
|
||||||
|
pub use crate::stdlib::FLAC__STREAM_DECODER_INIT_STATUS_UNSUPPORTED_CONTAINER;
|
||||||
|
pub use crate::stdlib::FLAC__STREAM_DECODER_LENGTH_STATUS_ERROR;
|
||||||
|
pub use crate::stdlib::FLAC__STREAM_DECODER_LENGTH_STATUS_OK;
|
||||||
|
pub use crate::stdlib::FLAC__STREAM_DECODER_LENGTH_STATUS_UNSUPPORTED;
|
||||||
|
pub use crate::stdlib::FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR;
|
||||||
|
pub use crate::stdlib::FLAC__STREAM_DECODER_OGG_ERROR;
|
||||||
|
pub use crate::stdlib::FLAC__STREAM_DECODER_READ_FRAME;
|
||||||
|
pub use crate::stdlib::FLAC__STREAM_DECODER_READ_METADATA;
|
||||||
|
pub use crate::stdlib::FLAC__STREAM_DECODER_READ_STATUS_ABORT;
|
||||||
|
pub use crate::stdlib::FLAC__STREAM_DECODER_READ_STATUS_CONTINUE;
|
||||||
|
pub use crate::stdlib::FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM;
|
||||||
|
pub use crate::stdlib::FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC;
|
||||||
|
pub use crate::stdlib::FLAC__STREAM_DECODER_SEARCH_FOR_METADATA;
|
||||||
|
pub use crate::stdlib::FLAC__STREAM_DECODER_SEEK_ERROR;
|
||||||
|
pub use crate::stdlib::FLAC__STREAM_DECODER_SEEK_STATUS_ERROR;
|
||||||
|
pub use crate::stdlib::FLAC__STREAM_DECODER_SEEK_STATUS_OK;
|
||||||
|
pub use crate::stdlib::FLAC__STREAM_DECODER_SEEK_STATUS_UNSUPPORTED;
|
||||||
|
pub use crate::stdlib::FLAC__STREAM_DECODER_TELL_STATUS_ERROR;
|
||||||
|
pub use crate::stdlib::FLAC__STREAM_DECODER_TELL_STATUS_OK;
|
||||||
|
pub use crate::stdlib::FLAC__STREAM_DECODER_TELL_STATUS_UNSUPPORTED;
|
||||||
|
pub use crate::stdlib::FLAC__STREAM_DECODER_UNINITIALIZED;
|
||||||
|
pub use crate::stdlib::FLAC__STREAM_DECODER_WRITE_STATUS_ABORT;
|
||||||
|
pub use crate::stdlib::FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE;
|
||||||
|
pub use crate::stdlib::FLAC__STREAM_METADATA_PICTURE_TYPE_ARTIST;
|
||||||
|
pub use crate::stdlib::FLAC__STREAM_METADATA_PICTURE_TYPE_BACK_COVER;
|
||||||
|
pub use crate::stdlib::FLAC__STREAM_METADATA_PICTURE_TYPE_BAND;
|
||||||
|
pub use crate::stdlib::FLAC__STREAM_METADATA_PICTURE_TYPE_BAND_LOGOTYPE;
|
||||||
|
pub use crate::stdlib::FLAC__STREAM_METADATA_PICTURE_TYPE_COMPOSER;
|
||||||
|
pub use crate::stdlib::FLAC__STREAM_METADATA_PICTURE_TYPE_CONDUCTOR;
|
||||||
|
pub use crate::stdlib::FLAC__STREAM_METADATA_PICTURE_TYPE_DURING_PERFORMANCE;
|
||||||
|
pub use crate::stdlib::FLAC__STREAM_METADATA_PICTURE_TYPE_DURING_RECORDING;
|
||||||
|
pub use crate::stdlib::FLAC__STREAM_METADATA_PICTURE_TYPE_FILE_ICON;
|
||||||
|
pub use crate::stdlib::FLAC__STREAM_METADATA_PICTURE_TYPE_FILE_ICON_STANDARD;
|
||||||
|
pub use crate::stdlib::FLAC__STREAM_METADATA_PICTURE_TYPE_FISH;
|
||||||
|
pub use crate::stdlib::FLAC__STREAM_METADATA_PICTURE_TYPE_FRONT_COVER;
|
||||||
|
pub use crate::stdlib::FLAC__STREAM_METADATA_PICTURE_TYPE_ILLUSTRATION;
|
||||||
|
pub use crate::stdlib::FLAC__STREAM_METADATA_PICTURE_TYPE_LEAD_ARTIST;
|
||||||
|
pub use crate::stdlib::FLAC__STREAM_METADATA_PICTURE_TYPE_LEAFLET_PAGE;
|
||||||
|
pub use crate::stdlib::FLAC__STREAM_METADATA_PICTURE_TYPE_LYRICIST;
|
||||||
|
pub use crate::stdlib::FLAC__STREAM_METADATA_PICTURE_TYPE_MEDIA;
|
||||||
|
pub use crate::stdlib::FLAC__STREAM_METADATA_PICTURE_TYPE_OTHER;
|
||||||
|
pub use crate::stdlib::FLAC__STREAM_METADATA_PICTURE_TYPE_PUBLISHER_LOGOTYPE;
|
||||||
|
pub use crate::stdlib::FLAC__STREAM_METADATA_PICTURE_TYPE_RECORDING_LOCATION;
|
||||||
|
pub use crate::stdlib::FLAC__STREAM_METADATA_PICTURE_TYPE_UNDEFINED;
|
||||||
|
pub use crate::stdlib::FLAC__STREAM_METADATA_PICTURE_TYPE_VIDEO_SCREEN_CAPTURE;
|
||||||
|
pub use crate::stdlib::FLAC__SUBFRAME_TYPE_CONSTANT;
|
||||||
|
pub use crate::stdlib::FLAC__SUBFRAME_TYPE_FIXED;
|
||||||
|
pub use crate::stdlib::FLAC__SUBFRAME_TYPE_LPC;
|
||||||
|
pub use crate::stdlib::FLAC__SUBFRAME_TYPE_VERBATIM;
|
||||||
|
|
||||||
|
use crate::stdlib::dlerror;
|
||||||
|
use crate::stdlib::dlopen;
|
||||||
|
use crate::stdlib::dlsym;
|
||||||
|
use crate::stdlib::pthread_mutex_lock;
|
||||||
|
use crate::stdlib::pthread_mutex_unlock;
|
||||||
|
extern "C" {
|
||||||
|
#[no_mangle]
|
||||||
|
pub static mut loglevel: crate::squeezelite_h::log_level;
|
||||||
|
#[no_mangle]
|
||||||
|
pub static mut streambuf: *mut crate::squeezelite_h::buffer;
|
||||||
|
#[no_mangle]
|
||||||
|
pub static mut outputbuf: *mut crate::squeezelite_h::buffer;
|
||||||
|
#[no_mangle]
|
||||||
|
pub static mut stream: crate::squeezelite_h::streamstate;
|
||||||
|
#[no_mangle]
|
||||||
|
pub static mut output: crate::squeezelite_h::outputstate;
|
||||||
|
#[no_mangle]
|
||||||
|
pub static mut decode: crate::squeezelite_h::decodestate;
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
* Squeezelite - lightweight headless squeezeplay emulator for linux
|
||||||
|
*
|
||||||
|
* (c) Adrian Smith 2012, triode1@btinternet.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/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#[repr(C)]
|
||||||
|
#[derive(Copy, Clone)]
|
||||||
|
pub struct flac {
|
||||||
|
pub decoder: *mut crate::stdlib::FLAC__StreamDecoder,
|
||||||
|
pub FLAC__StreamDecoderErrorStatusString: *mut *const libc::c_char,
|
||||||
|
pub FLAC__StreamDecoderStateString: *mut *const libc::c_char,
|
||||||
|
pub FLAC__stream_decoder_new:
|
||||||
|
Option<unsafe extern "C" fn() -> *mut crate::stdlib::FLAC__StreamDecoder>,
|
||||||
|
pub FLAC__stream_decoder_reset: Option<
|
||||||
|
unsafe extern "C" fn(
|
||||||
|
_: *mut crate::stdlib::FLAC__StreamDecoder,
|
||||||
|
) -> crate::stdlib::FLAC__bool,
|
||||||
|
>,
|
||||||
|
pub FLAC__stream_decoder_delete:
|
||||||
|
Option<unsafe extern "C" fn(_: *mut crate::stdlib::FLAC__StreamDecoder) -> ()>,
|
||||||
|
pub FLAC__stream_decoder_init_stream: Option<
|
||||||
|
unsafe extern "C" fn(
|
||||||
|
_: *mut crate::stdlib::FLAC__StreamDecoder,
|
||||||
|
_: crate::stdlib::FLAC__StreamDecoderReadCallback,
|
||||||
|
_: crate::stdlib::FLAC__StreamDecoderSeekCallback,
|
||||||
|
_: crate::stdlib::FLAC__StreamDecoderTellCallback,
|
||||||
|
_: crate::stdlib::FLAC__StreamDecoderLengthCallback,
|
||||||
|
_: crate::stdlib::FLAC__StreamDecoderEofCallback,
|
||||||
|
_: crate::stdlib::FLAC__StreamDecoderWriteCallback,
|
||||||
|
_: crate::stdlib::FLAC__StreamDecoderMetadataCallback,
|
||||||
|
_: crate::stdlib::FLAC__StreamDecoderErrorCallback,
|
||||||
|
_: *mut libc::c_void,
|
||||||
|
) -> crate::stdlib::FLAC__StreamDecoderInitStatus,
|
||||||
|
>,
|
||||||
|
pub FLAC__stream_decoder_init_ogg_stream: Option<
|
||||||
|
unsafe extern "C" fn(
|
||||||
|
_: *mut crate::stdlib::FLAC__StreamDecoder,
|
||||||
|
_: crate::stdlib::FLAC__StreamDecoderReadCallback,
|
||||||
|
_: crate::stdlib::FLAC__StreamDecoderSeekCallback,
|
||||||
|
_: crate::stdlib::FLAC__StreamDecoderTellCallback,
|
||||||
|
_: crate::stdlib::FLAC__StreamDecoderLengthCallback,
|
||||||
|
_: crate::stdlib::FLAC__StreamDecoderEofCallback,
|
||||||
|
_: crate::stdlib::FLAC__StreamDecoderWriteCallback,
|
||||||
|
_: crate::stdlib::FLAC__StreamDecoderMetadataCallback,
|
||||||
|
_: crate::stdlib::FLAC__StreamDecoderErrorCallback,
|
||||||
|
_: *mut libc::c_void,
|
||||||
|
) -> crate::stdlib::FLAC__StreamDecoderInitStatus,
|
||||||
|
>,
|
||||||
|
pub FLAC__stream_decoder_process_single: Option<
|
||||||
|
unsafe extern "C" fn(
|
||||||
|
_: *mut crate::stdlib::FLAC__StreamDecoder,
|
||||||
|
) -> crate::stdlib::FLAC__bool,
|
||||||
|
>,
|
||||||
|
pub FLAC__stream_decoder_get_state: Option<
|
||||||
|
unsafe extern "C" fn(
|
||||||
|
_: *const crate::stdlib::FLAC__StreamDecoder,
|
||||||
|
) -> crate::stdlib::FLAC__StreamDecoderState,
|
||||||
|
>,
|
||||||
|
}
|
||||||
|
|
||||||
|
static mut f: *mut flac = 0 as *const flac as *mut flac;
|
||||||
|
|
||||||
|
unsafe extern "C" fn read_cb(
|
||||||
|
mut decoder: *const crate::stdlib::FLAC__StreamDecoder,
|
||||||
|
mut buffer: *mut crate::stdlib::FLAC__byte,
|
||||||
|
mut want: *mut crate::stddef_h::size_t,
|
||||||
|
mut client_data: *mut libc::c_void,
|
||||||
|
) -> crate::stdlib::FLAC__StreamDecoderReadStatus {
|
||||||
|
let mut bytes: crate::stddef_h::size_t = 0;
|
||||||
|
let mut end: bool = false;
|
||||||
|
crate::stdlib::pthread_mutex_lock(&mut (*streambuf).mutex);
|
||||||
|
bytes = if crate::squeezelite_h::_buf_used(streambuf)
|
||||||
|
< crate::src::buffer::_buf_cont_read(streambuf)
|
||||||
|
{
|
||||||
|
crate::squeezelite_h::_buf_used(streambuf)
|
||||||
|
} else {
|
||||||
|
crate::src::buffer::_buf_cont_read(streambuf)
|
||||||
|
} as crate::stddef_h::size_t;
|
||||||
|
bytes = if bytes < *want { bytes } else { *want };
|
||||||
|
end = stream.state as libc::c_uint
|
||||||
|
<= crate::squeezelite_h::DISCONNECT as libc::c_int as libc::c_uint
|
||||||
|
&& bytes == 0 as libc::c_int as libc::c_ulong;
|
||||||
|
crate::stdlib::memcpy(
|
||||||
|
buffer as *mut libc::c_void,
|
||||||
|
(*streambuf).readp as *const libc::c_void,
|
||||||
|
bytes,
|
||||||
|
);
|
||||||
|
crate::src::buffer::_buf_inc_readp(streambuf, bytes as libc::c_uint);
|
||||||
|
crate::stdlib::pthread_mutex_unlock(&mut (*streambuf).mutex);
|
||||||
|
*want = bytes;
|
||||||
|
return if end as libc::c_int != 0 {
|
||||||
|
crate::stdlib::FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM as libc::c_int
|
||||||
|
} else {
|
||||||
|
crate::stdlib::FLAC__STREAM_DECODER_READ_STATUS_CONTINUE as libc::c_int
|
||||||
|
} as crate::stdlib::FLAC__StreamDecoderReadStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe extern "C" fn write_cb(
|
||||||
|
mut decoder: *const crate::stdlib::FLAC__StreamDecoder,
|
||||||
|
mut frame: *const crate::stdlib::FLAC__Frame,
|
||||||
|
mut buffer: *const *const crate::stdlib::FLAC__int32,
|
||||||
|
mut client_data: *mut libc::c_void,
|
||||||
|
) -> crate::stdlib::FLAC__StreamDecoderWriteStatus {
|
||||||
|
let mut frames = (*frame).header.blocksize as crate::stddef_h::size_t;
|
||||||
|
let mut bits_per_sample = (*frame).header.bits_per_sample;
|
||||||
|
let mut channels = (*frame).header.channels;
|
||||||
|
let mut lptr = *buffer.offset(0 as libc::c_int as isize) as *mut crate::stdlib::FLAC__int32;
|
||||||
|
let mut rptr = *buffer.offset(if channels > 1 as libc::c_int as libc::c_uint {
|
||||||
|
1 as libc::c_int
|
||||||
|
} else {
|
||||||
|
0 as libc::c_int
|
||||||
|
} as isize) as *mut crate::stdlib::FLAC__int32;
|
||||||
|
if decode.new_stream {
|
||||||
|
crate::stdlib::pthread_mutex_lock(&mut (*outputbuf).mutex);
|
||||||
|
if loglevel as libc::c_uint >= crate::squeezelite_h::lINFO as libc::c_int as libc::c_uint {
|
||||||
|
crate::src::utils::logprint(
|
||||||
|
b"%s %s:%d setting track_start\n\x00" as *const u8 as *const libc::c_char,
|
||||||
|
crate::src::utils::logtime(),
|
||||||
|
(*::std::mem::transmute::<&[u8; 9], &[libc::c_char; 9]>(b"write_cb\x00")).as_ptr(),
|
||||||
|
128 as libc::c_int,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
output.track_start = (*outputbuf).writep;
|
||||||
|
decode.new_stream = 0 as libc::c_int != 0;
|
||||||
|
output.next_sample_rate = crate::src::decode::decode_newstream(
|
||||||
|
(*frame).header.sample_rate,
|
||||||
|
output.supported_rates.as_mut_ptr(),
|
||||||
|
);
|
||||||
|
if output.fade_mode as u64 != 0 {
|
||||||
|
crate::src::output::_checkfade(1 as libc::c_int != 0);
|
||||||
|
}
|
||||||
|
crate::stdlib::pthread_mutex_unlock(&mut (*outputbuf).mutex);
|
||||||
|
}
|
||||||
|
crate::stdlib::pthread_mutex_lock(&mut (*outputbuf).mutex);
|
||||||
|
while frames > 0 as libc::c_int as libc::c_ulong {
|
||||||
|
let mut f_0: crate::squeezelite_h::frames_t = 0;
|
||||||
|
let mut count: crate::squeezelite_h::frames_t = 0;
|
||||||
|
let mut optr = 0 as *mut crate::squeezelite_h::s32_t;
|
||||||
|
optr = (*outputbuf).writep as *mut crate::squeezelite_h::s32_t;
|
||||||
|
f_0 = (if crate::src::buffer::_buf_space(outputbuf)
|
||||||
|
< crate::src::buffer::_buf_cont_write(outputbuf)
|
||||||
|
{
|
||||||
|
crate::src::buffer::_buf_space(outputbuf)
|
||||||
|
} else {
|
||||||
|
crate::src::buffer::_buf_cont_write(outputbuf)
|
||||||
|
})
|
||||||
|
.wrapping_div(8 as libc::c_int as libc::c_uint);
|
||||||
|
f_0 = if (f_0 as libc::c_ulong) < frames {
|
||||||
|
f_0 as libc::c_ulong
|
||||||
|
} else {
|
||||||
|
frames
|
||||||
|
} as crate::squeezelite_h::frames_t;
|
||||||
|
count = f_0;
|
||||||
|
if bits_per_sample == 8 as libc::c_int as libc::c_uint {
|
||||||
|
loop {
|
||||||
|
let fresh0 = count;
|
||||||
|
count = count.wrapping_sub(1);
|
||||||
|
if !(fresh0 != 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
let fresh1 = lptr;
|
||||||
|
lptr = lptr.offset(1);
|
||||||
|
let fresh2 = optr;
|
||||||
|
optr = optr.offset(1);
|
||||||
|
*fresh2 = *fresh1 << 24 as libc::c_int;
|
||||||
|
let fresh3 = rptr;
|
||||||
|
rptr = rptr.offset(1);
|
||||||
|
let fresh4 = optr;
|
||||||
|
optr = optr.offset(1);
|
||||||
|
*fresh4 = *fresh3 << 24 as libc::c_int
|
||||||
|
}
|
||||||
|
} else if bits_per_sample == 16 as libc::c_int as libc::c_uint {
|
||||||
|
loop {
|
||||||
|
let fresh5 = count;
|
||||||
|
count = count.wrapping_sub(1);
|
||||||
|
if !(fresh5 != 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
let fresh6 = lptr;
|
||||||
|
lptr = lptr.offset(1);
|
||||||
|
let fresh7 = optr;
|
||||||
|
optr = optr.offset(1);
|
||||||
|
*fresh7 = *fresh6 << 16 as libc::c_int;
|
||||||
|
let fresh8 = rptr;
|
||||||
|
rptr = rptr.offset(1);
|
||||||
|
let fresh9 = optr;
|
||||||
|
optr = optr.offset(1);
|
||||||
|
*fresh9 = *fresh8 << 16 as libc::c_int
|
||||||
|
}
|
||||||
|
} else if bits_per_sample == 24 as libc::c_int as libc::c_uint {
|
||||||
|
loop {
|
||||||
|
let fresh10 = count;
|
||||||
|
count = count.wrapping_sub(1);
|
||||||
|
if !(fresh10 != 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
let fresh11 = lptr;
|
||||||
|
lptr = lptr.offset(1);
|
||||||
|
let fresh12 = optr;
|
||||||
|
optr = optr.offset(1);
|
||||||
|
*fresh12 = *fresh11 << 8 as libc::c_int;
|
||||||
|
let fresh13 = rptr;
|
||||||
|
rptr = rptr.offset(1);
|
||||||
|
let fresh14 = optr;
|
||||||
|
optr = optr.offset(1);
|
||||||
|
*fresh14 = *fresh13 << 8 as libc::c_int
|
||||||
|
}
|
||||||
|
} else if bits_per_sample == 32 as libc::c_int as libc::c_uint {
|
||||||
|
loop {
|
||||||
|
let fresh15 = count;
|
||||||
|
count = count.wrapping_sub(1);
|
||||||
|
if !(fresh15 != 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
let fresh16 = lptr;
|
||||||
|
lptr = lptr.offset(1);
|
||||||
|
let fresh17 = optr;
|
||||||
|
optr = optr.offset(1);
|
||||||
|
*fresh17 = *fresh16;
|
||||||
|
let fresh18 = rptr;
|
||||||
|
rptr = rptr.offset(1);
|
||||||
|
let fresh19 = optr;
|
||||||
|
optr = optr.offset(1);
|
||||||
|
*fresh19 = *fresh18
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
crate::src::utils::logprint(
|
||||||
|
b"%s %s:%d unsupported bits per sample: %u\n\x00" as *const u8
|
||||||
|
as *const libc::c_char,
|
||||||
|
crate::src::utils::logtime(),
|
||||||
|
(*::std::mem::transmute::<&[u8; 9], &[libc::c_char; 9]>(b"write_cb\x00")).as_ptr(),
|
||||||
|
200 as libc::c_int,
|
||||||
|
bits_per_sample,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
frames = (frames as libc::c_ulong).wrapping_sub(f_0 as libc::c_ulong)
|
||||||
|
as crate::stddef_h::size_t as crate::stddef_h::size_t;
|
||||||
|
crate::src::buffer::_buf_inc_writep(
|
||||||
|
outputbuf,
|
||||||
|
f_0.wrapping_mul(8 as libc::c_int as libc::c_uint),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
crate::stdlib::pthread_mutex_unlock(&mut (*outputbuf).mutex);
|
||||||
|
return crate::stdlib::FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe extern "C" fn error_cb(
|
||||||
|
mut decoder: *const crate::stdlib::FLAC__StreamDecoder,
|
||||||
|
mut status: crate::stdlib::FLAC__StreamDecoderErrorStatus,
|
||||||
|
mut client_data: *mut libc::c_void,
|
||||||
|
) {
|
||||||
|
if loglevel as libc::c_uint >= crate::squeezelite_h::lINFO as libc::c_int as libc::c_uint {
|
||||||
|
crate::src::utils::logprint(
|
||||||
|
b"%s %s:%d flac error: %s\n\x00" as *const u8 as *const libc::c_char,
|
||||||
|
crate::src::utils::logtime(),
|
||||||
|
(*::std::mem::transmute::<&[u8; 9], &[libc::c_char; 9]>(b"error_cb\x00")).as_ptr(),
|
||||||
|
220 as libc::c_int,
|
||||||
|
*(*f)
|
||||||
|
.FLAC__StreamDecoderErrorStatusString
|
||||||
|
.offset(status as isize),
|
||||||
|
);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe extern "C" fn flac_open(
|
||||||
|
mut sample_size: crate::squeezelite_h::u8_t,
|
||||||
|
mut sample_rate: crate::squeezelite_h::u8_t,
|
||||||
|
mut channels: crate::squeezelite_h::u8_t,
|
||||||
|
mut endianness: crate::squeezelite_h::u8_t,
|
||||||
|
) {
|
||||||
|
if !(*f).decoder.is_null() {
|
||||||
|
(*f).FLAC__stream_decoder_reset
|
||||||
|
.expect("non-null function pointer")((*f).decoder);
|
||||||
|
} else {
|
||||||
|
(*f).decoder = (*f)
|
||||||
|
.FLAC__stream_decoder_new
|
||||||
|
.expect("non-null function pointer")()
|
||||||
|
}
|
||||||
|
if sample_size as libc::c_int == 'o' as i32 {
|
||||||
|
if loglevel as libc::c_uint >= crate::squeezelite_h::lDEBUG as libc::c_int as libc::c_uint {
|
||||||
|
crate::src::utils::logprint(
|
||||||
|
b"%s %s:%d ogg/flac container - using init_ogg_stream\n\x00" as *const u8
|
||||||
|
as *const libc::c_char,
|
||||||
|
crate::src::utils::logtime(),
|
||||||
|
(*::std::mem::transmute::<&[u8; 10], &[libc::c_char; 10]>(b"flac_open\x00"))
|
||||||
|
.as_ptr(),
|
||||||
|
231 as libc::c_int,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
(*f).FLAC__stream_decoder_init_ogg_stream
|
||||||
|
.expect("non-null function pointer")(
|
||||||
|
(*f).decoder,
|
||||||
|
Some(
|
||||||
|
read_cb
|
||||||
|
as unsafe extern "C" fn(
|
||||||
|
_: *const crate::stdlib::FLAC__StreamDecoder,
|
||||||
|
_: *mut crate::stdlib::FLAC__byte,
|
||||||
|
_: *mut crate::stddef_h::size_t,
|
||||||
|
_: *mut libc::c_void,
|
||||||
|
)
|
||||||
|
-> crate::stdlib::FLAC__StreamDecoderReadStatus,
|
||||||
|
),
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
Some(
|
||||||
|
write_cb
|
||||||
|
as unsafe extern "C" fn(
|
||||||
|
_: *const crate::stdlib::FLAC__StreamDecoder,
|
||||||
|
_: *const crate::stdlib::FLAC__Frame,
|
||||||
|
_: *const *const crate::stdlib::FLAC__int32,
|
||||||
|
_: *mut libc::c_void,
|
||||||
|
)
|
||||||
|
-> crate::stdlib::FLAC__StreamDecoderWriteStatus,
|
||||||
|
),
|
||||||
|
None,
|
||||||
|
Some(
|
||||||
|
error_cb
|
||||||
|
as unsafe extern "C" fn(
|
||||||
|
_: *const crate::stdlib::FLAC__StreamDecoder,
|
||||||
|
_: crate::stdlib::FLAC__StreamDecoderErrorStatus,
|
||||||
|
_: *mut libc::c_void,
|
||||||
|
) -> (),
|
||||||
|
),
|
||||||
|
0 as *mut libc::c_void,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
(*f).FLAC__stream_decoder_init_stream
|
||||||
|
.expect("non-null function pointer")(
|
||||||
|
(*f).decoder,
|
||||||
|
Some(
|
||||||
|
read_cb
|
||||||
|
as unsafe extern "C" fn(
|
||||||
|
_: *const crate::stdlib::FLAC__StreamDecoder,
|
||||||
|
_: *mut crate::stdlib::FLAC__byte,
|
||||||
|
_: *mut crate::stddef_h::size_t,
|
||||||
|
_: *mut libc::c_void,
|
||||||
|
)
|
||||||
|
-> crate::stdlib::FLAC__StreamDecoderReadStatus,
|
||||||
|
),
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
Some(
|
||||||
|
write_cb
|
||||||
|
as unsafe extern "C" fn(
|
||||||
|
_: *const crate::stdlib::FLAC__StreamDecoder,
|
||||||
|
_: *const crate::stdlib::FLAC__Frame,
|
||||||
|
_: *const *const crate::stdlib::FLAC__int32,
|
||||||
|
_: *mut libc::c_void,
|
||||||
|
)
|
||||||
|
-> crate::stdlib::FLAC__StreamDecoderWriteStatus,
|
||||||
|
),
|
||||||
|
None,
|
||||||
|
Some(
|
||||||
|
error_cb
|
||||||
|
as unsafe extern "C" fn(
|
||||||
|
_: *const crate::stdlib::FLAC__StreamDecoder,
|
||||||
|
_: crate::stdlib::FLAC__StreamDecoderErrorStatus,
|
||||||
|
_: *mut libc::c_void,
|
||||||
|
) -> (),
|
||||||
|
),
|
||||||
|
0 as *mut libc::c_void,
|
||||||
|
);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe extern "C" fn flac_close() {
|
||||||
|
(*f).FLAC__stream_decoder_delete
|
||||||
|
.expect("non-null function pointer")((*f).decoder);
|
||||||
|
(*f).decoder = 0 as *mut crate::stdlib::FLAC__StreamDecoder;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe extern "C" fn flac_decode() -> crate::squeezelite_h::decode_state {
|
||||||
|
let mut ok = (*f)
|
||||||
|
.FLAC__stream_decoder_process_single
|
||||||
|
.expect("non-null function pointer")((*f).decoder)
|
||||||
|
!= 0;
|
||||||
|
let mut state = (*f)
|
||||||
|
.FLAC__stream_decoder_get_state
|
||||||
|
.expect("non-null function pointer")((*f).decoder);
|
||||||
|
if !ok
|
||||||
|
&& state as libc::c_uint
|
||||||
|
!= crate::stdlib::FLAC__STREAM_DECODER_END_OF_STREAM as libc::c_int as libc::c_uint
|
||||||
|
{
|
||||||
|
if loglevel as libc::c_uint >= crate::squeezelite_h::lINFO as libc::c_int as libc::c_uint {
|
||||||
|
crate::src::utils::logprint(
|
||||||
|
b"%s %s:%d flac error: %s\n\x00" as *const u8 as *const libc::c_char,
|
||||||
|
crate::src::utils::logtime(),
|
||||||
|
(*::std::mem::transmute::<&[u8; 12], &[libc::c_char; 12]>(b"flac_decode\x00"))
|
||||||
|
.as_ptr(),
|
||||||
|
249 as libc::c_int,
|
||||||
|
*(*f).FLAC__StreamDecoderStateString.offset(state as isize),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if state as libc::c_uint
|
||||||
|
== crate::stdlib::FLAC__STREAM_DECODER_END_OF_STREAM as libc::c_int as libc::c_uint
|
||||||
|
{
|
||||||
|
return crate::squeezelite_h::DECODE_COMPLETE;
|
||||||
|
} else if state as libc::c_uint
|
||||||
|
> crate::stdlib::FLAC__STREAM_DECODER_END_OF_STREAM as libc::c_int as libc::c_uint
|
||||||
|
{
|
||||||
|
return crate::squeezelite_h::DECODE_ERROR;
|
||||||
|
} else {
|
||||||
|
return crate::squeezelite_h::DECODE_RUNNING;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe extern "C" fn load_flac() -> bool {
|
||||||
|
let mut handle = crate::stdlib::dlopen(
|
||||||
|
b"libFLAC.so.8\x00" as *const u8 as *const libc::c_char,
|
||||||
|
0x2 as libc::c_int,
|
||||||
|
);
|
||||||
|
let mut err = 0 as *mut libc::c_char;
|
||||||
|
if handle.is_null() {
|
||||||
|
if loglevel as libc::c_uint >= crate::squeezelite_h::lINFO as libc::c_int as libc::c_uint {
|
||||||
|
crate::src::utils::logprint(
|
||||||
|
b"%s %s:%d dlerror: %s\n\x00" as *const u8 as *const libc::c_char,
|
||||||
|
crate::src::utils::logtime(),
|
||||||
|
(*::std::mem::transmute::<&[u8; 10], &[libc::c_char; 10]>(b"load_flac\x00"))
|
||||||
|
.as_ptr(),
|
||||||
|
267 as libc::c_int,
|
||||||
|
crate::stdlib::dlerror(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return 0 as libc::c_int != 0;
|
||||||
|
}
|
||||||
|
(*f).FLAC__StreamDecoderErrorStatusString = crate::stdlib::dlsym(
|
||||||
|
handle,
|
||||||
|
b"FLAC__StreamDecoderErrorStatusString\x00" as *const u8 as *const libc::c_char,
|
||||||
|
) as *mut *const libc::c_char;
|
||||||
|
(*f).FLAC__StreamDecoderStateString = crate::stdlib::dlsym(
|
||||||
|
handle,
|
||||||
|
b"FLAC__StreamDecoderStateString\x00" as *const u8 as *const libc::c_char,
|
||||||
|
) as *mut *const libc::c_char;
|
||||||
|
(*f).FLAC__stream_decoder_new = ::std::mem::transmute::<
|
||||||
|
*mut libc::c_void,
|
||||||
|
Option<unsafe extern "C" fn() -> *mut crate::stdlib::FLAC__StreamDecoder>,
|
||||||
|
>(crate::stdlib::dlsym(
|
||||||
|
handle,
|
||||||
|
b"FLAC__stream_decoder_new\x00" as *const u8 as *const libc::c_char,
|
||||||
|
));
|
||||||
|
(*f).FLAC__stream_decoder_reset = ::std::mem::transmute::<
|
||||||
|
*mut libc::c_void,
|
||||||
|
Option<
|
||||||
|
unsafe extern "C" fn(
|
||||||
|
_: *mut crate::stdlib::FLAC__StreamDecoder,
|
||||||
|
) -> crate::stdlib::FLAC__bool,
|
||||||
|
>,
|
||||||
|
>(crate::stdlib::dlsym(
|
||||||
|
handle,
|
||||||
|
b"FLAC__stream_decoder_reset\x00" as *const u8 as *const libc::c_char,
|
||||||
|
));
|
||||||
|
(*f).FLAC__stream_decoder_delete = ::std::mem::transmute::<
|
||||||
|
*mut libc::c_void,
|
||||||
|
Option<unsafe extern "C" fn(_: *mut crate::stdlib::FLAC__StreamDecoder) -> ()>,
|
||||||
|
>(crate::stdlib::dlsym(
|
||||||
|
handle,
|
||||||
|
b"FLAC__stream_decoder_delete\x00" as *const u8 as *const libc::c_char,
|
||||||
|
));
|
||||||
|
(*f).FLAC__stream_decoder_init_stream = ::std::mem::transmute::<
|
||||||
|
*mut libc::c_void,
|
||||||
|
Option<
|
||||||
|
unsafe extern "C" fn(
|
||||||
|
_: *mut crate::stdlib::FLAC__StreamDecoder,
|
||||||
|
_: crate::stdlib::FLAC__StreamDecoderReadCallback,
|
||||||
|
_: crate::stdlib::FLAC__StreamDecoderSeekCallback,
|
||||||
|
_: crate::stdlib::FLAC__StreamDecoderTellCallback,
|
||||||
|
_: crate::stdlib::FLAC__StreamDecoderLengthCallback,
|
||||||
|
_: crate::stdlib::FLAC__StreamDecoderEofCallback,
|
||||||
|
_: crate::stdlib::FLAC__StreamDecoderWriteCallback,
|
||||||
|
_: crate::stdlib::FLAC__StreamDecoderMetadataCallback,
|
||||||
|
_: crate::stdlib::FLAC__StreamDecoderErrorCallback,
|
||||||
|
_: *mut libc::c_void,
|
||||||
|
) -> crate::stdlib::FLAC__StreamDecoderInitStatus,
|
||||||
|
>,
|
||||||
|
>(crate::stdlib::dlsym(
|
||||||
|
handle,
|
||||||
|
b"FLAC__stream_decoder_init_stream\x00" as *const u8 as *const libc::c_char,
|
||||||
|
));
|
||||||
|
(*f).FLAC__stream_decoder_init_ogg_stream = ::std::mem::transmute::<
|
||||||
|
*mut libc::c_void,
|
||||||
|
Option<
|
||||||
|
unsafe extern "C" fn(
|
||||||
|
_: *mut crate::stdlib::FLAC__StreamDecoder,
|
||||||
|
_: crate::stdlib::FLAC__StreamDecoderReadCallback,
|
||||||
|
_: crate::stdlib::FLAC__StreamDecoderSeekCallback,
|
||||||
|
_: crate::stdlib::FLAC__StreamDecoderTellCallback,
|
||||||
|
_: crate::stdlib::FLAC__StreamDecoderLengthCallback,
|
||||||
|
_: crate::stdlib::FLAC__StreamDecoderEofCallback,
|
||||||
|
_: crate::stdlib::FLAC__StreamDecoderWriteCallback,
|
||||||
|
_: crate::stdlib::FLAC__StreamDecoderMetadataCallback,
|
||||||
|
_: crate::stdlib::FLAC__StreamDecoderErrorCallback,
|
||||||
|
_: *mut libc::c_void,
|
||||||
|
) -> crate::stdlib::FLAC__StreamDecoderInitStatus,
|
||||||
|
>,
|
||||||
|
>(crate::stdlib::dlsym(
|
||||||
|
handle,
|
||||||
|
b"FLAC__stream_decoder_init_ogg_stream\x00" as *const u8 as *const libc::c_char,
|
||||||
|
));
|
||||||
|
(*f).FLAC__stream_decoder_process_single = ::std::mem::transmute::<
|
||||||
|
*mut libc::c_void,
|
||||||
|
Option<
|
||||||
|
unsafe extern "C" fn(
|
||||||
|
_: *mut crate::stdlib::FLAC__StreamDecoder,
|
||||||
|
) -> crate::stdlib::FLAC__bool,
|
||||||
|
>,
|
||||||
|
>(crate::stdlib::dlsym(
|
||||||
|
handle,
|
||||||
|
b"FLAC__stream_decoder_process_single\x00" as *const u8 as *const libc::c_char,
|
||||||
|
));
|
||||||
|
(*f).FLAC__stream_decoder_get_state = ::std::mem::transmute::<
|
||||||
|
*mut libc::c_void,
|
||||||
|
Option<
|
||||||
|
unsafe extern "C" fn(
|
||||||
|
_: *const crate::stdlib::FLAC__StreamDecoder,
|
||||||
|
) -> crate::stdlib::FLAC__StreamDecoderState,
|
||||||
|
>,
|
||||||
|
>(crate::stdlib::dlsym(
|
||||||
|
handle,
|
||||||
|
b"FLAC__stream_decoder_get_state\x00" as *const u8 as *const libc::c_char,
|
||||||
|
));
|
||||||
|
err = crate::stdlib::dlerror();
|
||||||
|
if !err.is_null() {
|
||||||
|
if loglevel as libc::c_uint >= crate::squeezelite_h::lINFO as libc::c_int as libc::c_uint {
|
||||||
|
crate::src::utils::logprint(
|
||||||
|
b"%s %s:%d dlerror: %s\n\x00" as *const u8 as *const libc::c_char,
|
||||||
|
crate::src::utils::logtime(),
|
||||||
|
(*::std::mem::transmute::<&[u8; 10], &[libc::c_char; 10]>(b"load_flac\x00"))
|
||||||
|
.as_ptr(),
|
||||||
|
282 as libc::c_int,
|
||||||
|
err,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return 0 as libc::c_int != 0;
|
||||||
|
}
|
||||||
|
if loglevel as libc::c_uint >= crate::squeezelite_h::lINFO as libc::c_int as libc::c_uint {
|
||||||
|
crate::src::utils::logprint(
|
||||||
|
b"%s %s:%d loaded libFLAC.so.8\n\x00" as *const u8 as *const libc::c_char,
|
||||||
|
crate::src::utils::logtime(),
|
||||||
|
(*::std::mem::transmute::<&[u8; 10], &[libc::c_char; 10]>(b"load_flac\x00")).as_ptr(),
|
||||||
|
286 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_flac() -> *mut crate::squeezelite_h::codec {
|
||||||
|
static mut ret: crate::squeezelite_h::codec = unsafe {
|
||||||
|
{
|
||||||
|
let mut init = crate::squeezelite_h::codec {
|
||||||
|
id: 'f' as i32 as libc::c_char,
|
||||||
|
types: b"ogf,flc\x00" as *const u8 as *const libc::c_char as *mut libc::c_char,
|
||||||
|
min_read_bytes: 16384 as libc::c_int as libc::c_uint,
|
||||||
|
min_space: 204800 as libc::c_int as libc::c_uint,
|
||||||
|
open: Some(
|
||||||
|
flac_open
|
||||||
|
as unsafe extern "C" fn(
|
||||||
|
_: crate::squeezelite_h::u8_t,
|
||||||
|
_: crate::squeezelite_h::u8_t,
|
||||||
|
_: crate::squeezelite_h::u8_t,
|
||||||
|
_: crate::squeezelite_h::u8_t,
|
||||||
|
) -> (),
|
||||||
|
),
|
||||||
|
close: Some(flac_close as unsafe extern "C" fn() -> ()),
|
||||||
|
decode: Some(
|
||||||
|
flac_decode as unsafe extern "C" fn() -> crate::squeezelite_h::decode_state,
|
||||||
|
),
|
||||||
|
};
|
||||||
|
init
|
||||||
|
}
|
||||||
|
};
|
||||||
|
f = crate::stdlib::malloc(::std::mem::size_of::<flac>() as libc::c_ulong) as *mut flac;
|
||||||
|
if f.is_null() {
|
||||||
|
return 0 as *mut crate::squeezelite_h::codec;
|
||||||
|
}
|
||||||
|
(*f).decoder = 0 as *mut crate::stdlib::FLAC__StreamDecoder;
|
||||||
|
if !load_flac() {
|
||||||
|
return 0 as *mut crate::squeezelite_h::codec;
|
||||||
|
}
|
||||||
|
if loglevel as libc::c_uint >= crate::squeezelite_h::lINFO as libc::c_int as libc::c_uint {
|
||||||
|
crate::src::utils::logprint(
|
||||||
|
b"%s %s:%d using flac to decode ogf,flc\n\x00" as *const u8 as *const libc::c_char,
|
||||||
|
crate::src::utils::logtime(),
|
||||||
|
(*::std::mem::transmute::<&[u8; 14], &[libc::c_char; 14]>(b"register_flac\x00"))
|
||||||
|
.as_ptr(),
|
||||||
|
314 as libc::c_int,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return &mut ret;
|
||||||
|
}
|
9
src/internal.rs
Normal file
9
src/internal.rs
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
pub type __builtin_va_list = [crate::internal::__va_list_tag; 1];
|
||||||
|
#[repr(C)]
|
||||||
|
#[derive(Copy, Clone)]
|
||||||
|
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,
|
||||||
|
}
|
989
src/mad.rs
Normal file
989
src/mad.rs
Normal file
@ -0,0 +1,989 @@
|
|||||||
|
use ::libc;
|
||||||
|
|
||||||
|
pub use crate::stddef_h::size_t;
|
||||||
|
pub use crate::stdlib::__int32_t;
|
||||||
|
pub use crate::stdlib::__uint32_t;
|
||||||
|
pub use crate::stdlib::__uint64_t;
|
||||||
|
pub use crate::stdlib::__uint8_t;
|
||||||
|
pub use crate::stdlib::int32_t;
|
||||||
|
|
||||||
|
pub use crate::stdlib::__pthread_internal_list;
|
||||||
|
pub use crate::stdlib::__pthread_list_t;
|
||||||
|
pub use crate::stdlib::__pthread_mutex_s;
|
||||||
|
pub use crate::stdlib::pthread_mutex_t;
|
||||||
|
pub use crate::stdlib::u_int32_t;
|
||||||
|
pub use crate::stdlib::u_int64_t;
|
||||||
|
pub use crate::stdlib::u_int8_t;
|
||||||
|
|
||||||
|
pub use crate::squeezelite_h::buffer;
|
||||||
|
pub use crate::squeezelite_h::codec;
|
||||||
|
pub use crate::squeezelite_h::decode_state;
|
||||||
|
pub use crate::squeezelite_h::decodestate;
|
||||||
|
pub use crate::squeezelite_h::disconnect_code;
|
||||||
|
pub use crate::squeezelite_h::fade_dir;
|
||||||
|
pub use crate::squeezelite_h::fade_mode;
|
||||||
|
pub use crate::squeezelite_h::fade_state;
|
||||||
|
pub use crate::squeezelite_h::frames_t;
|
||||||
|
pub use crate::squeezelite_h::lDEBUG;
|
||||||
|
pub use crate::squeezelite_h::lERROR;
|
||||||
|
pub use crate::squeezelite_h::lINFO;
|
||||||
|
pub use crate::squeezelite_h::lSDEBUG;
|
||||||
|
pub use crate::squeezelite_h::lWARN;
|
||||||
|
pub use crate::squeezelite_h::log_level;
|
||||||
|
pub use crate::squeezelite_h::output_format;
|
||||||
|
pub use crate::squeezelite_h::output_state;
|
||||||
|
pub use crate::squeezelite_h::outputstate;
|
||||||
|
pub use crate::squeezelite_h::s32_t;
|
||||||
|
pub use crate::squeezelite_h::stream_state;
|
||||||
|
pub use crate::squeezelite_h::streamstate;
|
||||||
|
pub use crate::squeezelite_h::u32_t;
|
||||||
|
pub use crate::squeezelite_h::u64_t;
|
||||||
|
pub use crate::squeezelite_h::u8_t;
|
||||||
|
pub use crate::squeezelite_h::C2RustUnnamed_1;
|
||||||
|
pub use crate::squeezelite_h::_buf_used;
|
||||||
|
pub use crate::squeezelite_h::DECODE_COMPLETE;
|
||||||
|
pub use crate::squeezelite_h::DECODE_ERROR;
|
||||||
|
pub use crate::squeezelite_h::DECODE_READY;
|
||||||
|
pub use crate::squeezelite_h::DECODE_RUNNING;
|
||||||
|
pub use crate::squeezelite_h::DECODE_STOPPED;
|
||||||
|
pub use crate::squeezelite_h::DISCONNECT;
|
||||||
|
pub use crate::squeezelite_h::DISCONNECT_OK;
|
||||||
|
pub use crate::squeezelite_h::FADE_ACTIVE;
|
||||||
|
pub use crate::squeezelite_h::FADE_CROSS;
|
||||||
|
pub use crate::squeezelite_h::FADE_CROSSFADE;
|
||||||
|
pub use crate::squeezelite_h::FADE_DOWN;
|
||||||
|
pub use crate::squeezelite_h::FADE_DUE;
|
||||||
|
pub use crate::squeezelite_h::FADE_IN;
|
||||||
|
pub use crate::squeezelite_h::FADE_INACTIVE;
|
||||||
|
pub use crate::squeezelite_h::FADE_INOUT;
|
||||||
|
pub use crate::squeezelite_h::FADE_NONE;
|
||||||
|
pub use crate::squeezelite_h::FADE_OUT;
|
||||||
|
pub use crate::squeezelite_h::FADE_UP;
|
||||||
|
pub use crate::squeezelite_h::LOCAL_DISCONNECT;
|
||||||
|
pub use crate::squeezelite_h::OUTPUT_BUFFER;
|
||||||
|
pub use crate::squeezelite_h::OUTPUT_OFF;
|
||||||
|
pub use crate::squeezelite_h::OUTPUT_PAUSE_FRAMES;
|
||||||
|
pub use crate::squeezelite_h::OUTPUT_RUNNING;
|
||||||
|
pub use crate::squeezelite_h::OUTPUT_SKIP_FRAMES;
|
||||||
|
pub use crate::squeezelite_h::OUTPUT_START_AT;
|
||||||
|
pub use crate::squeezelite_h::OUTPUT_STOPPED;
|
||||||
|
pub use crate::squeezelite_h::RECV_HEADERS;
|
||||||
|
pub use crate::squeezelite_h::REMOTE_DISCONNECT;
|
||||||
|
pub use crate::squeezelite_h::S16_LE;
|
||||||
|
pub use crate::squeezelite_h::S24_3LE;
|
||||||
|
pub use crate::squeezelite_h::S24_LE;
|
||||||
|
pub use crate::squeezelite_h::S32_LE;
|
||||||
|
pub use crate::squeezelite_h::SEND_HEADERS;
|
||||||
|
pub use crate::squeezelite_h::STOPPED;
|
||||||
|
pub use crate::squeezelite_h::STREAMING_BUFFERING;
|
||||||
|
pub use crate::squeezelite_h::STREAMING_FILE;
|
||||||
|
pub use crate::squeezelite_h::STREAMING_HTTP;
|
||||||
|
pub use crate::squeezelite_h::STREAMING_WAIT;
|
||||||
|
pub use crate::squeezelite_h::TIMEOUT;
|
||||||
|
pub use crate::squeezelite_h::UNREACHABLE;
|
||||||
|
pub use crate::src::buffer::_buf_cont_read;
|
||||||
|
pub use crate::src::buffer::_buf_cont_write;
|
||||||
|
pub use crate::src::buffer::_buf_inc_readp;
|
||||||
|
pub use crate::src::buffer::_buf_inc_writep;
|
||||||
|
pub use crate::src::buffer::_buf_space;
|
||||||
|
pub use crate::src::decode::decode_newstream;
|
||||||
|
pub use crate::src::output::_checkfade;
|
||||||
|
pub use crate::src::utils::logprint;
|
||||||
|
pub use crate::src::utils::logtime;
|
||||||
|
pub use crate::src::utils::unpackN;
|
||||||
|
use crate::stdlib::dlerror;
|
||||||
|
use crate::stdlib::dlopen;
|
||||||
|
use crate::stdlib::dlsym;
|
||||||
|
use crate::stdlib::free;
|
||||||
|
pub use crate::stdlib::mad_bitptr;
|
||||||
|
pub use crate::stdlib::mad_emphasis;
|
||||||
|
pub use crate::stdlib::mad_error;
|
||||||
|
pub use crate::stdlib::mad_fixed_t;
|
||||||
|
pub use crate::stdlib::mad_frame;
|
||||||
|
pub use crate::stdlib::mad_header;
|
||||||
|
pub use crate::stdlib::mad_layer;
|
||||||
|
pub use crate::stdlib::mad_mode;
|
||||||
|
pub use crate::stdlib::mad_pcm;
|
||||||
|
pub use crate::stdlib::mad_stream;
|
||||||
|
pub use crate::stdlib::mad_synth;
|
||||||
|
pub use crate::stdlib::mad_timer_t;
|
||||||
|
use crate::stdlib::malloc;
|
||||||
|
use crate::stdlib::memcmp;
|
||||||
|
use crate::stdlib::memcpy;
|
||||||
|
use crate::stdlib::memmove;
|
||||||
|
use crate::stdlib::memset;
|
||||||
|
use crate::stdlib::pthread_mutex_lock;
|
||||||
|
use crate::stdlib::pthread_mutex_unlock;
|
||||||
|
pub use crate::stdlib::MAD_EMPHASIS_50_15_US;
|
||||||
|
pub use crate::stdlib::MAD_EMPHASIS_CCITT_J_17;
|
||||||
|
pub use crate::stdlib::MAD_EMPHASIS_NONE;
|
||||||
|
pub use crate::stdlib::MAD_EMPHASIS_RESERVED;
|
||||||
|
pub use crate::stdlib::MAD_ERROR_BADBIGVALUES;
|
||||||
|
pub use crate::stdlib::MAD_ERROR_BADBITALLOC;
|
||||||
|
pub use crate::stdlib::MAD_ERROR_BADBITRATE;
|
||||||
|
pub use crate::stdlib::MAD_ERROR_BADBLOCKTYPE;
|
||||||
|
pub use crate::stdlib::MAD_ERROR_BADCRC;
|
||||||
|
pub use crate::stdlib::MAD_ERROR_BADDATAPTR;
|
||||||
|
pub use crate::stdlib::MAD_ERROR_BADEMPHASIS;
|
||||||
|
pub use crate::stdlib::MAD_ERROR_BADFRAMELEN;
|
||||||
|
pub use crate::stdlib::MAD_ERROR_BADHUFFDATA;
|
||||||
|
pub use crate::stdlib::MAD_ERROR_BADHUFFTABLE;
|
||||||
|
pub use crate::stdlib::MAD_ERROR_BADLAYER;
|
||||||
|
pub use crate::stdlib::MAD_ERROR_BADMODE;
|
||||||
|
pub use crate::stdlib::MAD_ERROR_BADPART3LEN;
|
||||||
|
pub use crate::stdlib::MAD_ERROR_BADSAMPLERATE;
|
||||||
|
pub use crate::stdlib::MAD_ERROR_BADSCALEFACTOR;
|
||||||
|
pub use crate::stdlib::MAD_ERROR_BADSCFSI;
|
||||||
|
pub use crate::stdlib::MAD_ERROR_BADSTEREO;
|
||||||
|
pub use crate::stdlib::MAD_ERROR_BUFLEN;
|
||||||
|
pub use crate::stdlib::MAD_ERROR_BUFPTR;
|
||||||
|
pub use crate::stdlib::MAD_ERROR_LOSTSYNC;
|
||||||
|
pub use crate::stdlib::MAD_ERROR_NOMEM;
|
||||||
|
pub use crate::stdlib::MAD_ERROR_NONE;
|
||||||
|
pub use crate::stdlib::MAD_LAYER_I;
|
||||||
|
pub use crate::stdlib::MAD_LAYER_II;
|
||||||
|
pub use crate::stdlib::MAD_LAYER_III;
|
||||||
|
pub use crate::stdlib::MAD_MODE_DUAL_CHANNEL;
|
||||||
|
pub use crate::stdlib::MAD_MODE_JOINT_STEREO;
|
||||||
|
pub use crate::stdlib::MAD_MODE_SINGLE_CHANNEL;
|
||||||
|
pub use crate::stdlib::MAD_MODE_STEREO;
|
||||||
|
extern "C" {
|
||||||
|
#[no_mangle]
|
||||||
|
pub static mut loglevel: crate::squeezelite_h::log_level;
|
||||||
|
#[no_mangle]
|
||||||
|
pub static mut streambuf: *mut crate::squeezelite_h::buffer;
|
||||||
|
#[no_mangle]
|
||||||
|
pub static mut outputbuf: *mut crate::squeezelite_h::buffer;
|
||||||
|
#[no_mangle]
|
||||||
|
pub static mut stream: crate::squeezelite_h::streamstate;
|
||||||
|
#[no_mangle]
|
||||||
|
pub static mut output: crate::squeezelite_h::outputstate;
|
||||||
|
#[no_mangle]
|
||||||
|
pub static mut decode: crate::squeezelite_h::decodestate;
|
||||||
|
}
|
||||||
|
// local buffer used by decoder: FIXME merge with any other decoders needing one?
|
||||||
|
|
||||||
|
#[repr(C)]
|
||||||
|
#[derive(Copy, Clone)]
|
||||||
|
pub struct mad {
|
||||||
|
pub readbuf: *mut crate::squeezelite_h::u8_t,
|
||||||
|
pub readbuf_len: libc::c_uint,
|
||||||
|
pub stream: crate::stdlib::mad_stream,
|
||||||
|
pub frame: crate::stdlib::mad_frame,
|
||||||
|
pub synth: crate::stdlib::mad_synth,
|
||||||
|
pub last_error: crate::stdlib::mad_error,
|
||||||
|
pub checktags: libc::c_int,
|
||||||
|
pub consume: crate::squeezelite_h::u32_t,
|
||||||
|
pub skip: crate::squeezelite_h::u32_t,
|
||||||
|
pub samples: crate::squeezelite_h::u64_t,
|
||||||
|
pub padding: crate::squeezelite_h::u32_t,
|
||||||
|
pub mad_stream_init: Option<unsafe extern "C" fn(_: *mut crate::stdlib::mad_stream) -> ()>,
|
||||||
|
pub mad_frame_init: Option<unsafe extern "C" fn(_: *mut crate::stdlib::mad_frame) -> ()>,
|
||||||
|
pub mad_synth_init: Option<unsafe extern "C" fn(_: *mut crate::stdlib::mad_synth) -> ()>,
|
||||||
|
pub mad_frame_finish: Option<unsafe extern "C" fn(_: *mut crate::stdlib::mad_frame) -> ()>,
|
||||||
|
pub mad_stream_finish: Option<unsafe extern "C" fn(_: *mut crate::stdlib::mad_stream) -> ()>,
|
||||||
|
pub mad_stream_buffer: Option<
|
||||||
|
unsafe extern "C" fn(
|
||||||
|
_: *mut crate::stdlib::mad_stream,
|
||||||
|
_: *const libc::c_uchar,
|
||||||
|
_: libc::c_ulong,
|
||||||
|
) -> (),
|
||||||
|
>,
|
||||||
|
pub mad_frame_decode: Option<
|
||||||
|
unsafe extern "C" fn(
|
||||||
|
_: *mut crate::stdlib::mad_frame,
|
||||||
|
_: *mut crate::stdlib::mad_stream,
|
||||||
|
) -> libc::c_int,
|
||||||
|
>,
|
||||||
|
pub mad_synth_frame: Option<
|
||||||
|
unsafe extern "C" fn(
|
||||||
|
_: *mut crate::stdlib::mad_synth,
|
||||||
|
_: *const crate::stdlib::mad_frame,
|
||||||
|
) -> (),
|
||||||
|
>,
|
||||||
|
pub mad_stream_errorstr:
|
||||||
|
Option<unsafe extern "C" fn(_: *const crate::stdlib::mad_stream) -> *const libc::c_char>,
|
||||||
|
}
|
||||||
|
|
||||||
|
static mut m: *mut mad = 0 as *const mad as *mut mad;
|
||||||
|
// based on libmad minimad.c scale
|
||||||
|
#[inline]
|
||||||
|
|
||||||
|
unsafe extern "C" fn scale(mut sample: crate::stdlib::mad_fixed_t) -> crate::squeezelite_h::u32_t {
|
||||||
|
sample = (sample as libc::c_long
|
||||||
|
+ ((1 as libc::c_long) << 28 as libc::c_int - 24 as libc::c_int))
|
||||||
|
as crate::stdlib::mad_fixed_t;
|
||||||
|
if sample >= 0x10000000 as libc::c_long as crate::stdlib::mad_fixed_t {
|
||||||
|
sample = 0x10000000 as libc::c_long as crate::stdlib::mad_fixed_t - 1 as libc::c_int
|
||||||
|
} else if sample < -(0x10000000 as libc::c_long as crate::stdlib::mad_fixed_t) {
|
||||||
|
sample = -(0x10000000 as libc::c_long as crate::stdlib::mad_fixed_t)
|
||||||
|
}
|
||||||
|
return ((sample >> 28 as libc::c_int + 1 as libc::c_int - 24 as libc::c_int)
|
||||||
|
<< 8 as libc::c_int) as crate::squeezelite_h::u32_t;
|
||||||
|
}
|
||||||
|
// check for id3.2 tag at start of file - http://id3.org/id3v2.4.0-structure, return length
|
||||||
|
|
||||||
|
unsafe extern "C" fn _check_id3_tag(mut bytes: crate::stddef_h::size_t) -> libc::c_uint {
|
||||||
|
let mut ptr = (*streambuf).readp;
|
||||||
|
let mut size = 0 as libc::c_int as crate::squeezelite_h::u32_t;
|
||||||
|
if bytes > 10 as libc::c_int as libc::c_ulong
|
||||||
|
&& *ptr as libc::c_int == 'I' as i32
|
||||||
|
&& *ptr.offset(1 as libc::c_int as isize) as libc::c_int == 'D' as i32
|
||||||
|
&& *ptr.offset(2 as libc::c_int as isize) as libc::c_int == '3' as i32
|
||||||
|
{
|
||||||
|
// size is encoded as syncsafe integer, add 10 if footer present
|
||||||
|
if (*ptr.offset(6 as libc::c_int as isize) as libc::c_int) < 0x80 as libc::c_int
|
||||||
|
&& (*ptr.offset(7 as libc::c_int as isize) as libc::c_int) < 0x80 as libc::c_int
|
||||||
|
&& (*ptr.offset(8 as libc::c_int as isize) as libc::c_int) < 0x80 as libc::c_int
|
||||||
|
&& (*ptr.offset(9 as libc::c_int as isize) as libc::c_int) < 0x80 as libc::c_int
|
||||||
|
{
|
||||||
|
size = (10 as libc::c_int
|
||||||
|
+ ((*ptr.offset(6 as libc::c_int as isize) as libc::c_int) << 21 as libc::c_int)
|
||||||
|
+ ((*ptr.offset(7 as libc::c_int as isize) as libc::c_int) << 14 as libc::c_int)
|
||||||
|
+ ((*ptr.offset(8 as libc::c_int as isize) as libc::c_int) << 7 as libc::c_int)
|
||||||
|
+ *ptr.offset(9 as libc::c_int as isize) as libc::c_int
|
||||||
|
+ (if *ptr.offset(5 as libc::c_int as isize) as libc::c_int & 0x10 as libc::c_int
|
||||||
|
!= 0
|
||||||
|
{
|
||||||
|
10 as libc::c_int
|
||||||
|
} else {
|
||||||
|
0 as libc::c_int
|
||||||
|
})) as crate::squeezelite_h::u32_t;
|
||||||
|
if loglevel as libc::c_uint
|
||||||
|
>= crate::squeezelite_h::lDEBUG as libc::c_int as libc::c_uint
|
||||||
|
{
|
||||||
|
crate::src::utils::logprint(
|
||||||
|
b"%s %s:%d id3.2 tag len: %u\n\x00" as *const u8 as *const libc::c_char,
|
||||||
|
crate::src::utils::logtime(),
|
||||||
|
(*::std::mem::transmute::<&[u8; 15], &[libc::c_char; 15]>(
|
||||||
|
b"_check_id3_tag\x00",
|
||||||
|
))
|
||||||
|
.as_ptr(),
|
||||||
|
111 as libc::c_int,
|
||||||
|
size,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
// check for lame gapless params, don't advance streambuf
|
||||||
|
|
||||||
|
unsafe extern "C" fn _check_lame_header(mut bytes: crate::stddef_h::size_t) {
|
||||||
|
let mut ptr = (*streambuf).readp;
|
||||||
|
if *ptr as libc::c_int == 0xff as libc::c_int
|
||||||
|
&& *ptr.offset(1 as libc::c_int as isize) as libc::c_int & 0xf0 as libc::c_int
|
||||||
|
== 0xf0 as libc::c_int
|
||||||
|
&& bytes > 180 as libc::c_int as libc::c_ulong
|
||||||
|
{
|
||||||
|
let mut frame_count = 0 as libc::c_int as crate::squeezelite_h::u32_t;
|
||||||
|
let mut enc_delay = 0 as libc::c_int as crate::squeezelite_h::u32_t;
|
||||||
|
let mut enc_padding = 0 as libc::c_int as crate::squeezelite_h::u32_t;
|
||||||
|
let mut flags: crate::squeezelite_h::u8_t = 0;
|
||||||
|
// 2 channels
|
||||||
|
if crate::stdlib::memcmp(
|
||||||
|
ptr.offset(36 as libc::c_int as isize) as *const libc::c_void,
|
||||||
|
b"Xing\x00" as *const u8 as *const libc::c_char as *const libc::c_void,
|
||||||
|
4 as libc::c_int as libc::c_ulong,
|
||||||
|
) == 0
|
||||||
|
|| crate::stdlib::memcmp(
|
||||||
|
ptr.offset(36 as libc::c_int as isize) as *const libc::c_void,
|
||||||
|
b"Info\x00" as *const u8 as *const libc::c_char as *const libc::c_void,
|
||||||
|
4 as libc::c_int as libc::c_ulong,
|
||||||
|
) == 0
|
||||||
|
{
|
||||||
|
ptr = ptr.offset((36 as libc::c_int + 7 as libc::c_int) as isize)
|
||||||
|
// mono
|
||||||
|
} else if crate::stdlib::memcmp(
|
||||||
|
ptr.offset(21 as libc::c_int as isize) as *const libc::c_void,
|
||||||
|
b"Xing\x00" as *const u8 as *const libc::c_char as *const libc::c_void,
|
||||||
|
4 as libc::c_int as libc::c_ulong,
|
||||||
|
) == 0
|
||||||
|
|| crate::stdlib::memcmp(
|
||||||
|
ptr.offset(21 as libc::c_int as isize) as *const libc::c_void,
|
||||||
|
b"Info\x00" as *const u8 as *const libc::c_char as *const libc::c_void,
|
||||||
|
4 as libc::c_int as libc::c_ulong,
|
||||||
|
) == 0
|
||||||
|
{
|
||||||
|
ptr = ptr.offset((21 as libc::c_int + 7 as libc::c_int) as isize)
|
||||||
|
}
|
||||||
|
flags = *ptr;
|
||||||
|
if flags as libc::c_int & 0x1 as libc::c_int != 0 {
|
||||||
|
frame_count = crate::src::utils::unpackN(
|
||||||
|
ptr.offset(1 as libc::c_int as isize) as *mut crate::squeezelite_h::u32_t
|
||||||
|
);
|
||||||
|
ptr = ptr.offset(4 as libc::c_int as isize)
|
||||||
|
}
|
||||||
|
if flags as libc::c_int & 0x2 as libc::c_int != 0 {
|
||||||
|
ptr = ptr.offset(4 as libc::c_int as isize)
|
||||||
|
}
|
||||||
|
if flags as libc::c_int & 0x4 as libc::c_int != 0 {
|
||||||
|
ptr = ptr.offset(100 as libc::c_int as isize)
|
||||||
|
}
|
||||||
|
if flags as libc::c_int & 0x8 as libc::c_int != 0 {
|
||||||
|
ptr = ptr.offset(4 as libc::c_int as isize)
|
||||||
|
}
|
||||||
|
if crate::stdlib::memcmp(
|
||||||
|
ptr.offset(1 as libc::c_int as isize) as *const libc::c_void,
|
||||||
|
b"LAME\x00" as *const u8 as *const libc::c_char as *const libc::c_void,
|
||||||
|
4 as libc::c_int as libc::c_ulong,
|
||||||
|
) != 0
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ptr = ptr.offset(22 as libc::c_int as isize);
|
||||||
|
enc_delay = (((*ptr as libc::c_int) << 4 as libc::c_int
|
||||||
|
| *ptr.offset(1 as libc::c_int as isize) as libc::c_int >> 4 as libc::c_int)
|
||||||
|
+ 529 as libc::c_int) as crate::squeezelite_h::u32_t;
|
||||||
|
enc_padding = ((*ptr.offset(1 as libc::c_int as isize) as libc::c_int & 0xf as libc::c_int)
|
||||||
|
<< 8 as libc::c_int
|
||||||
|
| *ptr.offset(2 as libc::c_int as isize) as libc::c_int)
|
||||||
|
as crate::squeezelite_h::u32_t;
|
||||||
|
enc_padding = if enc_padding > 529 as libc::c_int as libc::c_uint {
|
||||||
|
enc_padding.wrapping_sub(529 as libc::c_int as libc::c_uint)
|
||||||
|
} else {
|
||||||
|
0 as libc::c_int as libc::c_uint
|
||||||
|
};
|
||||||
|
// add one frame to initial skip for this (empty) frame
|
||||||
|
(*m).skip = enc_delay.wrapping_add(1152 as libc::c_int as libc::c_uint);
|
||||||
|
(*m).samples = frame_count
|
||||||
|
.wrapping_mul(1152 as libc::c_int as libc::c_uint)
|
||||||
|
.wrapping_sub(enc_delay)
|
||||||
|
.wrapping_sub(enc_padding) as crate::squeezelite_h::u64_t;
|
||||||
|
(*m).padding = enc_padding;
|
||||||
|
if loglevel as libc::c_uint >= crate::squeezelite_h::lINFO as libc::c_int as libc::c_uint {
|
||||||
|
crate::src::utils::logprint(
|
||||||
|
b"%s %s:%d gapless: skip: %u samples: %lu delay: %u padding: %u\n\x00" as *const u8
|
||||||
|
as *const libc::c_char,
|
||||||
|
crate::src::utils::logtime(),
|
||||||
|
(*::std::mem::transmute::<&[u8; 19], &[libc::c_char; 19]>(
|
||||||
|
b"_check_lame_header\x00",
|
||||||
|
))
|
||||||
|
.as_ptr(),
|
||||||
|
160 as libc::c_int,
|
||||||
|
(*m).skip,
|
||||||
|
(*m).samples,
|
||||||
|
enc_delay,
|
||||||
|
enc_padding,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe extern "C" fn mad_decode() -> crate::squeezelite_h::decode_state {
|
||||||
|
let mut bytes: crate::stddef_h::size_t = 0;
|
||||||
|
let mut eos = 0 as libc::c_int != 0;
|
||||||
|
crate::stdlib::pthread_mutex_lock(&mut (*streambuf).mutex);
|
||||||
|
bytes = if crate::squeezelite_h::_buf_used(streambuf)
|
||||||
|
< crate::src::buffer::_buf_cont_read(streambuf)
|
||||||
|
{
|
||||||
|
crate::squeezelite_h::_buf_used(streambuf)
|
||||||
|
} else {
|
||||||
|
crate::src::buffer::_buf_cont_read(streambuf)
|
||||||
|
} as crate::stddef_h::size_t;
|
||||||
|
if (*m).checktags != 0 {
|
||||||
|
if (*m).checktags == 1 as libc::c_int {
|
||||||
|
(*m).consume = _check_id3_tag(bytes);
|
||||||
|
(*m).checktags = 2 as libc::c_int
|
||||||
|
}
|
||||||
|
if (*m).consume != 0 {
|
||||||
|
let mut consume = if ((*m).consume as libc::c_ulong) < bytes {
|
||||||
|
(*m).consume as libc::c_ulong
|
||||||
|
} else {
|
||||||
|
bytes
|
||||||
|
} as crate::squeezelite_h::u32_t;
|
||||||
|
if loglevel as libc::c_uint
|
||||||
|
>= crate::squeezelite_h::lDEBUG as libc::c_int as libc::c_uint
|
||||||
|
{
|
||||||
|
crate::src::utils::logprint(
|
||||||
|
b"%s %s:%d consume: %u of %u\n\x00" as *const u8 as *const libc::c_char,
|
||||||
|
crate::src::utils::logtime(),
|
||||||
|
(*::std::mem::transmute::<&[u8; 11], &[libc::c_char; 11]>(b"mad_decode\x00"))
|
||||||
|
.as_ptr(),
|
||||||
|
178 as libc::c_int,
|
||||||
|
consume,
|
||||||
|
(*m).consume,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
crate::src::buffer::_buf_inc_readp(streambuf, consume);
|
||||||
|
(*m).consume = ((*m).consume as libc::c_uint).wrapping_sub(consume)
|
||||||
|
as crate::squeezelite_h::u32_t
|
||||||
|
as crate::squeezelite_h::u32_t;
|
||||||
|
crate::stdlib::pthread_mutex_unlock(&mut (*streambuf).mutex);
|
||||||
|
return crate::squeezelite_h::DECODE_RUNNING;
|
||||||
|
}
|
||||||
|
if (*m).checktags == 2 as libc::c_int {
|
||||||
|
if stream.meta_interval == 0 {
|
||||||
|
_check_lame_header(bytes);
|
||||||
|
}
|
||||||
|
(*m).checktags = 0 as libc::c_int
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !(*m).stream.next_frame.is_null() && (*m).readbuf_len != 0 {
|
||||||
|
(*m).readbuf_len = ((*m).readbuf_len as libc::c_long
|
||||||
|
- (*m).stream.next_frame.wrapping_offset_from((*m).readbuf) as libc::c_long)
|
||||||
|
as libc::c_uint;
|
||||||
|
crate::stdlib::memmove(
|
||||||
|
(*m).readbuf as *mut libc::c_void,
|
||||||
|
(*m).stream.next_frame as *const libc::c_void,
|
||||||
|
(*m).readbuf_len as libc::c_ulong,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
bytes = if bytes
|
||||||
|
< (2048 as libc::c_int as libc::c_uint).wrapping_sub((*m).readbuf_len) as libc::c_ulong
|
||||||
|
{
|
||||||
|
bytes
|
||||||
|
} else {
|
||||||
|
(2048 as libc::c_int as libc::c_uint).wrapping_sub((*m).readbuf_len) as libc::c_ulong
|
||||||
|
};
|
||||||
|
crate::stdlib::memcpy(
|
||||||
|
(*m).readbuf.offset((*m).readbuf_len as isize) as *mut libc::c_void,
|
||||||
|
(*streambuf).readp as *const libc::c_void,
|
||||||
|
bytes,
|
||||||
|
);
|
||||||
|
(*m).readbuf_len =
|
||||||
|
((*m).readbuf_len as libc::c_ulong).wrapping_add(bytes) as libc::c_uint as libc::c_uint;
|
||||||
|
crate::src::buffer::_buf_inc_readp(streambuf, bytes as libc::c_uint);
|
||||||
|
if stream.state as libc::c_uint
|
||||||
|
<= crate::squeezelite_h::DISCONNECT as libc::c_int as libc::c_uint
|
||||||
|
&& crate::squeezelite_h::_buf_used(streambuf) == 0 as libc::c_int as libc::c_uint
|
||||||
|
{
|
||||||
|
eos = 1 as libc::c_int != 0;
|
||||||
|
if loglevel as libc::c_uint >= crate::squeezelite_h::lDEBUG as libc::c_int as libc::c_uint {
|
||||||
|
crate::src::utils::logprint(
|
||||||
|
b"%s %s:%d end of stream\n\x00" as *const u8 as *const libc::c_char,
|
||||||
|
crate::src::utils::logtime(),
|
||||||
|
(*::std::mem::transmute::<&[u8; 11], &[libc::c_char; 11]>(b"mad_decode\x00"))
|
||||||
|
.as_ptr(),
|
||||||
|
204 as libc::c_int,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
crate::stdlib::memset(
|
||||||
|
(*m).readbuf.offset((*m).readbuf_len as isize) as *mut libc::c_void,
|
||||||
|
0 as libc::c_int,
|
||||||
|
8 as libc::c_int as libc::c_ulong,
|
||||||
|
);
|
||||||
|
(*m).readbuf_len = (*m)
|
||||||
|
.readbuf_len
|
||||||
|
.wrapping_add(8 as libc::c_int as libc::c_uint)
|
||||||
|
}
|
||||||
|
crate::stdlib::pthread_mutex_unlock(&mut (*streambuf).mutex);
|
||||||
|
(*m).mad_stream_buffer.expect("non-null function pointer")(
|
||||||
|
&mut (*m).stream,
|
||||||
|
(*m).readbuf,
|
||||||
|
(*m).readbuf_len as libc::c_ulong,
|
||||||
|
);
|
||||||
|
loop {
|
||||||
|
let mut frames: crate::stddef_h::size_t = 0;
|
||||||
|
let mut iptrl = 0 as *mut crate::squeezelite_h::s32_t;
|
||||||
|
let mut iptrr = 0 as *mut crate::squeezelite_h::s32_t;
|
||||||
|
let mut max_frames: libc::c_uint = 0;
|
||||||
|
if (*m).mad_frame_decode.expect("non-null function pointer")(
|
||||||
|
&mut (*m).frame,
|
||||||
|
&mut (*m).stream,
|
||||||
|
) == -(1 as libc::c_int)
|
||||||
|
{
|
||||||
|
let mut ret = crate::squeezelite_h::DECODE_STOPPED;
|
||||||
|
if !eos
|
||||||
|
&& (*m).stream.error as libc::c_uint
|
||||||
|
== crate::stdlib::MAD_ERROR_BUFLEN as libc::c_int as libc::c_uint
|
||||||
|
{
|
||||||
|
ret = crate::squeezelite_h::DECODE_RUNNING
|
||||||
|
} else if eos as libc::c_int != 0
|
||||||
|
&& ((*m).stream.error as libc::c_uint
|
||||||
|
== crate::stdlib::MAD_ERROR_BUFLEN as libc::c_int as libc::c_uint
|
||||||
|
|| (*m).stream.error as libc::c_uint
|
||||||
|
== crate::stdlib::MAD_ERROR_LOSTSYNC as libc::c_int as libc::c_uint
|
||||||
|
|| (*m).stream.error as libc::c_uint
|
||||||
|
== crate::stdlib::MAD_ERROR_BADBITRATE as libc::c_int as libc::c_uint)
|
||||||
|
{
|
||||||
|
ret = crate::squeezelite_h::DECODE_COMPLETE
|
||||||
|
} else if (*m).stream.error as libc::c_uint & 0xff00 as libc::c_int as libc::c_uint == 0
|
||||||
|
{
|
||||||
|
if loglevel as libc::c_uint
|
||||||
|
>= crate::squeezelite_h::lINFO as libc::c_int as libc::c_uint
|
||||||
|
{
|
||||||
|
crate::src::utils::logprint(
|
||||||
|
b"%s %s:%d mad_frame_decode error: %s - stopping decoder\n\x00" as *const u8
|
||||||
|
as *const libc::c_char,
|
||||||
|
crate::src::utils::logtime(),
|
||||||
|
(*::std::mem::transmute::<&[u8; 11], &[libc::c_char; 11]>(
|
||||||
|
b"mad_decode\x00",
|
||||||
|
))
|
||||||
|
.as_ptr(),
|
||||||
|
227 as libc::c_int,
|
||||||
|
(*m).mad_stream_errorstr.expect("non-null function pointer")(
|
||||||
|
&mut (*m).stream,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
ret = crate::squeezelite_h::DECODE_COMPLETE
|
||||||
|
} else {
|
||||||
|
if (*m).stream.error as libc::c_uint != (*m).last_error as libc::c_uint {
|
||||||
|
// suppress repeat error messages
|
||||||
|
if loglevel as libc::c_uint
|
||||||
|
>= crate::squeezelite_h::lDEBUG as libc::c_int as libc::c_uint
|
||||||
|
{
|
||||||
|
crate::src::utils::logprint(
|
||||||
|
b"%s %s:%d mad_frame_decode error: %s\n\x00" as *const u8
|
||||||
|
as *const libc::c_char,
|
||||||
|
crate::src::utils::logtime(),
|
||||||
|
(*::std::mem::transmute::<&[u8; 11], &[libc::c_char; 11]>(
|
||||||
|
b"mad_decode\x00",
|
||||||
|
))
|
||||||
|
.as_ptr(),
|
||||||
|
232 as libc::c_int,
|
||||||
|
(*m).mad_stream_errorstr.expect("non-null function pointer")(
|
||||||
|
&mut (*m).stream,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ret = crate::squeezelite_h::DECODE_RUNNING
|
||||||
|
}
|
||||||
|
(*m).last_error = (*m).stream.error;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
(*m).mad_synth_frame.expect("non-null function pointer")(&mut (*m).synth, &mut (*m).frame);
|
||||||
|
if decode.new_stream {
|
||||||
|
crate::stdlib::pthread_mutex_lock(&mut (*outputbuf).mutex);
|
||||||
|
if loglevel as libc::c_uint
|
||||||
|
>= crate::squeezelite_h::lINFO as libc::c_int as libc::c_uint
|
||||||
|
{
|
||||||
|
crate::src::utils::logprint(
|
||||||
|
b"%s %s:%d setting track_start\n\x00" as *const u8 as *const libc::c_char,
|
||||||
|
crate::src::utils::logtime(),
|
||||||
|
(*::std::mem::transmute::<&[u8; 11], &[libc::c_char; 11]>(b"mad_decode\x00"))
|
||||||
|
.as_ptr(),
|
||||||
|
244 as libc::c_int,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
output.next_sample_rate = crate::src::decode::decode_newstream(
|
||||||
|
(*m).synth.pcm.samplerate,
|
||||||
|
output.supported_rates.as_mut_ptr(),
|
||||||
|
);
|
||||||
|
output.track_start = (*outputbuf).writep;
|
||||||
|
if output.fade_mode as u64 != 0 {
|
||||||
|
crate::src::output::_checkfade(1 as libc::c_int != 0);
|
||||||
|
}
|
||||||
|
decode.new_stream = 0 as libc::c_int != 0;
|
||||||
|
crate::stdlib::pthread_mutex_unlock(&mut (*outputbuf).mutex);
|
||||||
|
}
|
||||||
|
crate::stdlib::pthread_mutex_lock(&mut (*outputbuf).mutex);
|
||||||
|
max_frames = crate::src::buffer::_buf_space(outputbuf)
|
||||||
|
.wrapping_div(8 as libc::c_int as libc::c_uint);
|
||||||
|
if (*m).synth.pcm.length as libc::c_uint > max_frames {
|
||||||
|
if loglevel as libc::c_uint
|
||||||
|
>= crate::squeezelite_h::lWARN as libc::c_int as libc::c_uint
|
||||||
|
{
|
||||||
|
crate::src::utils::logprint(
|
||||||
|
b"%s %s:%d too many samples - dropping samples\n\x00" as *const u8
|
||||||
|
as *const libc::c_char,
|
||||||
|
crate::src::utils::logtime(),
|
||||||
|
(*::std::mem::transmute::<&[u8; 11], &[libc::c_char; 11]>(b"mad_decode\x00"))
|
||||||
|
.as_ptr(),
|
||||||
|
263 as libc::c_int,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
(*m).synth.pcm.length = max_frames as libc::c_ushort
|
||||||
|
}
|
||||||
|
frames = (*m).synth.pcm.length as crate::stddef_h::size_t;
|
||||||
|
iptrl = (*m).synth.pcm.samples[0 as libc::c_int as usize].as_mut_ptr();
|
||||||
|
iptrr = (*m).synth.pcm.samples
|
||||||
|
[((*m).synth.pcm.channels as libc::c_int - 1 as libc::c_int) as usize]
|
||||||
|
.as_mut_ptr();
|
||||||
|
if (*m).skip != 0 {
|
||||||
|
let mut skip = if ((*m).skip as libc::c_ulong) < frames {
|
||||||
|
(*m).skip as libc::c_ulong
|
||||||
|
} else {
|
||||||
|
frames
|
||||||
|
} as crate::squeezelite_h::u32_t;
|
||||||
|
if loglevel as libc::c_uint
|
||||||
|
>= crate::squeezelite_h::lDEBUG as libc::c_int as libc::c_uint
|
||||||
|
{
|
||||||
|
crate::src::utils::logprint(
|
||||||
|
b"%s %s:%d gapless: skipping %u frames at start\n\x00" as *const u8
|
||||||
|
as *const libc::c_char,
|
||||||
|
crate::src::utils::logtime(),
|
||||||
|
(*::std::mem::transmute::<&[u8; 11], &[libc::c_char; 11]>(b"mad_decode\x00"))
|
||||||
|
.as_ptr(),
|
||||||
|
273 as libc::c_int,
|
||||||
|
skip,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
frames = (frames as libc::c_ulong).wrapping_sub(skip as libc::c_ulong)
|
||||||
|
as crate::stddef_h::size_t as crate::stddef_h::size_t;
|
||||||
|
(*m).skip = ((*m).skip as libc::c_uint).wrapping_sub(skip)
|
||||||
|
as crate::squeezelite_h::u32_t
|
||||||
|
as crate::squeezelite_h::u32_t;
|
||||||
|
iptrl = iptrl.offset(skip as isize);
|
||||||
|
iptrr = iptrr.offset(skip as isize)
|
||||||
|
}
|
||||||
|
if (*m).samples != 0 {
|
||||||
|
if (*m).samples < frames {
|
||||||
|
if loglevel as libc::c_uint
|
||||||
|
>= crate::squeezelite_h::lDEBUG as libc::c_int as libc::c_uint
|
||||||
|
{
|
||||||
|
crate::src::utils::logprint(
|
||||||
|
b"%s %s:%d gapless: trimming %u frames from end\n\x00" as *const u8
|
||||||
|
as *const libc::c_char,
|
||||||
|
crate::src::utils::logtime(),
|
||||||
|
(*::std::mem::transmute::<&[u8; 11], &[libc::c_char; 11]>(
|
||||||
|
b"mad_decode\x00",
|
||||||
|
))
|
||||||
|
.as_ptr(),
|
||||||
|
282 as libc::c_int,
|
||||||
|
frames.wrapping_sub((*m).samples),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
frames = (*m).samples
|
||||||
|
}
|
||||||
|
(*m).samples = ((*m).samples as libc::c_ulong).wrapping_sub(frames)
|
||||||
|
as crate::squeezelite_h::u64_t
|
||||||
|
as crate::squeezelite_h::u64_t;
|
||||||
|
if (*m).samples > 0 as libc::c_int as libc::c_ulong
|
||||||
|
&& eos as libc::c_int != 0
|
||||||
|
&& !(*(*m).stream.next_frame.offset(0 as libc::c_int as isize) as libc::c_int
|
||||||
|
== 0xff as libc::c_int
|
||||||
|
&& *(*m).stream.next_frame.offset(1 as libc::c_int as isize) as libc::c_int
|
||||||
|
& 0xf0 as libc::c_int
|
||||||
|
== 0xf0 as libc::c_int)
|
||||||
|
{
|
||||||
|
// this is the last frame to be decoded, but more samples expected so we must have skipped, remove padding
|
||||||
|
// note this only works if the padding is less than one frame of 1152 bytes otherswise some gap will remain
|
||||||
|
if loglevel as libc::c_uint
|
||||||
|
>= crate::squeezelite_h::lDEBUG as libc::c_int as libc::c_uint
|
||||||
|
{
|
||||||
|
crate::src::utils::logprint(
|
||||||
|
b"%s %s:%d gapless: early end - trimming padding from end\n\x00"
|
||||||
|
as *const u8 as *const libc::c_char,
|
||||||
|
crate::src::utils::logtime(),
|
||||||
|
(*::std::mem::transmute::<&[u8; 11], &[libc::c_char; 11]>(
|
||||||
|
b"mad_decode\x00",
|
||||||
|
))
|
||||||
|
.as_ptr(),
|
||||||
|
289 as libc::c_int,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if frames >= (*m).padding as libc::c_ulong {
|
||||||
|
frames = (frames as libc::c_ulong).wrapping_sub((*m).padding as libc::c_ulong)
|
||||||
|
as crate::stddef_h::size_t
|
||||||
|
as crate::stddef_h::size_t
|
||||||
|
} else {
|
||||||
|
frames = 0 as libc::c_int as crate::stddef_h::size_t
|
||||||
|
}
|
||||||
|
(*m).samples = 0 as libc::c_int as crate::squeezelite_h::u64_t
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if loglevel as libc::c_uint >= crate::squeezelite_h::lSDEBUG as libc::c_int as libc::c_uint
|
||||||
|
{
|
||||||
|
crate::src::utils::logprint(
|
||||||
|
b"%s %s:%d write %u frames\n\x00" as *const u8 as *const libc::c_char,
|
||||||
|
crate::src::utils::logtime(),
|
||||||
|
(*::std::mem::transmute::<&[u8; 11], &[libc::c_char; 11]>(b"mad_decode\x00"))
|
||||||
|
.as_ptr(),
|
||||||
|
299 as libc::c_int,
|
||||||
|
frames,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
while frames > 0 as libc::c_int as libc::c_ulong {
|
||||||
|
let mut f: crate::stddef_h::size_t = 0;
|
||||||
|
let mut count: crate::stddef_h::size_t = 0;
|
||||||
|
let mut optr = 0 as *mut crate::squeezelite_h::s32_t;
|
||||||
|
f = if frames
|
||||||
|
< crate::src::buffer::_buf_cont_write(outputbuf)
|
||||||
|
.wrapping_div(8 as libc::c_int as libc::c_uint)
|
||||||
|
as libc::c_ulong
|
||||||
|
{
|
||||||
|
frames
|
||||||
|
} else {
|
||||||
|
crate::src::buffer::_buf_cont_write(outputbuf)
|
||||||
|
.wrapping_div(8 as libc::c_int as libc::c_uint) as libc::c_ulong
|
||||||
|
};
|
||||||
|
optr = (*outputbuf).writep as *mut crate::squeezelite_h::s32_t;
|
||||||
|
count = f;
|
||||||
|
loop {
|
||||||
|
let fresh0 = count;
|
||||||
|
count = count.wrapping_sub(1);
|
||||||
|
if !(fresh0 != 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
let fresh1 = iptrl;
|
||||||
|
iptrl = iptrl.offset(1);
|
||||||
|
let fresh2 = optr;
|
||||||
|
optr = optr.offset(1);
|
||||||
|
*fresh2 = scale(*fresh1) as crate::squeezelite_h::s32_t;
|
||||||
|
let fresh3 = iptrr;
|
||||||
|
iptrr = iptrr.offset(1);
|
||||||
|
let fresh4 = optr;
|
||||||
|
optr = optr.offset(1);
|
||||||
|
*fresh4 = scale(*fresh3) as crate::squeezelite_h::s32_t
|
||||||
|
}
|
||||||
|
frames = (frames as libc::c_ulong).wrapping_sub(f) as crate::stddef_h::size_t
|
||||||
|
as crate::stddef_h::size_t;
|
||||||
|
crate::src::buffer::_buf_inc_writep(
|
||||||
|
outputbuf,
|
||||||
|
f.wrapping_mul(8 as libc::c_int as libc::c_ulong) as libc::c_uint,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
crate::stdlib::pthread_mutex_unlock(&mut (*outputbuf).mutex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe extern "C" fn mad_open(
|
||||||
|
mut size: crate::squeezelite_h::u8_t,
|
||||||
|
mut rate: crate::squeezelite_h::u8_t,
|
||||||
|
mut chan: crate::squeezelite_h::u8_t,
|
||||||
|
mut endianness: crate::squeezelite_h::u8_t,
|
||||||
|
) {
|
||||||
|
if (*m).readbuf.is_null() {
|
||||||
|
(*m).readbuf =
|
||||||
|
crate::stdlib::malloc((2048 as libc::c_int + 8 as libc::c_int) as libc::c_ulong)
|
||||||
|
as *mut crate::squeezelite_h::u8_t
|
||||||
|
}
|
||||||
|
(*m).checktags = 1 as libc::c_int;
|
||||||
|
(*m).consume = 0 as libc::c_int as crate::squeezelite_h::u32_t;
|
||||||
|
(*m).skip = 529 as libc::c_int as crate::squeezelite_h::u32_t;
|
||||||
|
(*m).samples = 0 as libc::c_int as crate::squeezelite_h::u64_t;
|
||||||
|
(*m).readbuf_len = 0 as libc::c_int as libc::c_uint;
|
||||||
|
(*m).last_error = crate::stdlib::MAD_ERROR_NONE;
|
||||||
|
(*m).mad_stream_init.expect("non-null function pointer")(&mut (*m).stream);
|
||||||
|
(*m).mad_frame_init.expect("non-null function pointer")(&mut (*m).frame);
|
||||||
|
(*m).mad_synth_init.expect("non-null function pointer")(&mut (*m).synth);
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe extern "C" fn mad_close() {
|
||||||
|
// macro only in current version
|
||||||
|
(*m).mad_frame_finish.expect("non-null function pointer")(&mut (*m).frame);
|
||||||
|
(*m).mad_stream_finish.expect("non-null function pointer")(&mut (*m).stream);
|
||||||
|
crate::stdlib::free((*m).readbuf as *mut libc::c_void);
|
||||||
|
(*m).readbuf = 0 as *mut crate::squeezelite_h::u8_t;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe extern "C" fn load_mad() -> bool {
|
||||||
|
let mut handle = crate::stdlib::dlopen(
|
||||||
|
b"libmad.so.0\x00" as *const u8 as *const libc::c_char,
|
||||||
|
0x2 as libc::c_int,
|
||||||
|
);
|
||||||
|
let mut err = 0 as *mut libc::c_char;
|
||||||
|
if handle.is_null() {
|
||||||
|
if loglevel as libc::c_uint >= crate::squeezelite_h::lINFO as libc::c_int as libc::c_uint {
|
||||||
|
crate::src::utils::logprint(
|
||||||
|
b"%s %s:%d dlerror: %s\n\x00" as *const u8 as *const libc::c_char,
|
||||||
|
crate::src::utils::logtime(),
|
||||||
|
(*::std::mem::transmute::<&[u8; 9], &[libc::c_char; 9]>(b"load_mad\x00")).as_ptr(),
|
||||||
|
366 as libc::c_int,
|
||||||
|
crate::stdlib::dlerror(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return 0 as libc::c_int != 0;
|
||||||
|
}
|
||||||
|
(*m).mad_stream_init = ::std::mem::transmute::<
|
||||||
|
*mut libc::c_void,
|
||||||
|
Option<unsafe extern "C" fn(_: *mut crate::stdlib::mad_stream) -> ()>,
|
||||||
|
>(crate::stdlib::dlsym(
|
||||||
|
handle,
|
||||||
|
b"mad_stream_init\x00" as *const u8 as *const libc::c_char,
|
||||||
|
));
|
||||||
|
(*m).mad_frame_init = ::std::mem::transmute::<
|
||||||
|
*mut libc::c_void,
|
||||||
|
Option<unsafe extern "C" fn(_: *mut crate::stdlib::mad_frame) -> ()>,
|
||||||
|
>(crate::stdlib::dlsym(
|
||||||
|
handle,
|
||||||
|
b"mad_frame_init\x00" as *const u8 as *const libc::c_char,
|
||||||
|
));
|
||||||
|
(*m).mad_synth_init = ::std::mem::transmute::<
|
||||||
|
*mut libc::c_void,
|
||||||
|
Option<unsafe extern "C" fn(_: *mut crate::stdlib::mad_synth) -> ()>,
|
||||||
|
>(crate::stdlib::dlsym(
|
||||||
|
handle,
|
||||||
|
b"mad_synth_init\x00" as *const u8 as *const libc::c_char,
|
||||||
|
));
|
||||||
|
(*m).mad_frame_finish = ::std::mem::transmute::<
|
||||||
|
*mut libc::c_void,
|
||||||
|
Option<unsafe extern "C" fn(_: *mut crate::stdlib::mad_frame) -> ()>,
|
||||||
|
>(crate::stdlib::dlsym(
|
||||||
|
handle,
|
||||||
|
b"mad_frame_finish\x00" as *const u8 as *const libc::c_char,
|
||||||
|
));
|
||||||
|
(*m).mad_stream_finish = ::std::mem::transmute::<
|
||||||
|
*mut libc::c_void,
|
||||||
|
Option<unsafe extern "C" fn(_: *mut crate::stdlib::mad_stream) -> ()>,
|
||||||
|
>(crate::stdlib::dlsym(
|
||||||
|
handle,
|
||||||
|
b"mad_stream_finish\x00" as *const u8 as *const libc::c_char,
|
||||||
|
));
|
||||||
|
(*m).mad_stream_buffer = ::std::mem::transmute::<
|
||||||
|
*mut libc::c_void,
|
||||||
|
Option<
|
||||||
|
unsafe extern "C" fn(
|
||||||
|
_: *mut crate::stdlib::mad_stream,
|
||||||
|
_: *const libc::c_uchar,
|
||||||
|
_: libc::c_ulong,
|
||||||
|
) -> (),
|
||||||
|
>,
|
||||||
|
>(crate::stdlib::dlsym(
|
||||||
|
handle,
|
||||||
|
b"mad_stream_buffer\x00" as *const u8 as *const libc::c_char,
|
||||||
|
));
|
||||||
|
(*m).mad_frame_decode = ::std::mem::transmute::<
|
||||||
|
*mut libc::c_void,
|
||||||
|
Option<
|
||||||
|
unsafe extern "C" fn(
|
||||||
|
_: *mut crate::stdlib::mad_frame,
|
||||||
|
_: *mut crate::stdlib::mad_stream,
|
||||||
|
) -> libc::c_int,
|
||||||
|
>,
|
||||||
|
>(crate::stdlib::dlsym(
|
||||||
|
handle,
|
||||||
|
b"mad_frame_decode\x00" as *const u8 as *const libc::c_char,
|
||||||
|
));
|
||||||
|
(*m).mad_synth_frame = ::std::mem::transmute::<
|
||||||
|
*mut libc::c_void,
|
||||||
|
Option<
|
||||||
|
unsafe extern "C" fn(
|
||||||
|
_: *mut crate::stdlib::mad_synth,
|
||||||
|
_: *const crate::stdlib::mad_frame,
|
||||||
|
) -> (),
|
||||||
|
>,
|
||||||
|
>(crate::stdlib::dlsym(
|
||||||
|
handle,
|
||||||
|
b"mad_synth_frame\x00" as *const u8 as *const libc::c_char,
|
||||||
|
));
|
||||||
|
(*m).mad_stream_errorstr = ::std::mem::transmute::<
|
||||||
|
*mut libc::c_void,
|
||||||
|
Option<unsafe extern "C" fn(_: *const crate::stdlib::mad_stream) -> *const libc::c_char>,
|
||||||
|
>(crate::stdlib::dlsym(
|
||||||
|
handle,
|
||||||
|
b"mad_stream_errorstr\x00" as *const u8 as *const libc::c_char,
|
||||||
|
));
|
||||||
|
err = crate::stdlib::dlerror();
|
||||||
|
if !err.is_null() {
|
||||||
|
if loglevel as libc::c_uint >= crate::squeezelite_h::lINFO as libc::c_int as libc::c_uint {
|
||||||
|
crate::src::utils::logprint(
|
||||||
|
b"%s %s:%d dlerror: %s\n\x00" as *const u8 as *const libc::c_char,
|
||||||
|
crate::src::utils::logtime(),
|
||||||
|
(*::std::mem::transmute::<&[u8; 9], &[libc::c_char; 9]>(b"load_mad\x00")).as_ptr(),
|
||||||
|
381 as libc::c_int,
|
||||||
|
err,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return 0 as libc::c_int != 0;
|
||||||
|
}
|
||||||
|
if loglevel as libc::c_uint >= crate::squeezelite_h::lINFO as libc::c_int as libc::c_uint {
|
||||||
|
crate::src::utils::logprint(
|
||||||
|
b"%s %s:%d loaded libmad.so.0\n\x00" as *const u8 as *const libc::c_char,
|
||||||
|
crate::src::utils::logtime(),
|
||||||
|
(*::std::mem::transmute::<&[u8; 9], &[libc::c_char; 9]>(b"load_mad\x00")).as_ptr(),
|
||||||
|
385 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_mad() -> *mut crate::squeezelite_h::codec {
|
||||||
|
static mut ret: crate::squeezelite_h::codec = unsafe {
|
||||||
|
{
|
||||||
|
let mut init = crate::squeezelite_h::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: 2048 as libc::c_int as libc::c_uint,
|
||||||
|
min_space: 206800 as libc::c_int as libc::c_uint,
|
||||||
|
open: Some(
|
||||||
|
mad_open
|
||||||
|
as unsafe extern "C" fn(
|
||||||
|
_: crate::squeezelite_h::u8_t,
|
||||||
|
_: crate::squeezelite_h::u8_t,
|
||||||
|
_: crate::squeezelite_h::u8_t,
|
||||||
|
_: crate::squeezelite_h::u8_t,
|
||||||
|
) -> (),
|
||||||
|
),
|
||||||
|
close: Some(mad_close as unsafe extern "C" fn() -> ()),
|
||||||
|
decode: Some(
|
||||||
|
mad_decode as unsafe extern "C" fn() -> crate::squeezelite_h::decode_state,
|
||||||
|
),
|
||||||
|
};
|
||||||
|
init
|
||||||
|
}
|
||||||
|
};
|
||||||
|
m = crate::stdlib::malloc(::std::mem::size_of::<mad>() as libc::c_ulong) as *mut mad;
|
||||||
|
if m.is_null() {
|
||||||
|
return 0 as *mut crate::squeezelite_h::codec;
|
||||||
|
}
|
||||||
|
(*m).readbuf = 0 as *mut crate::squeezelite_h::u8_t;
|
||||||
|
(*m).readbuf_len = 0 as libc::c_int as libc::c_uint;
|
||||||
|
if !load_mad() {
|
||||||
|
return 0 as *mut crate::squeezelite_h::codec;
|
||||||
|
}
|
||||||
|
if loglevel as libc::c_uint >= crate::squeezelite_h::lINFO as libc::c_int as libc::c_uint {
|
||||||
|
crate::src::utils::logprint(
|
||||||
|
b"%s %s:%d using mad to decode mp3\n\x00" as *const u8 as *const libc::c_char,
|
||||||
|
crate::src::utils::logtime(),
|
||||||
|
(*::std::mem::transmute::<&[u8; 13], &[libc::c_char; 13]>(b"register_mad\x00"))
|
||||||
|
.as_ptr(),
|
||||||
|
414 as libc::c_int,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return &mut ret;
|
||||||
|
}
|
1014
src/main.rs
Normal file
1014
src/main.rs
Normal file
File diff suppressed because it is too large
Load Diff
742
src/mpg.rs
Normal file
742
src/mpg.rs
Normal file
@ -0,0 +1,742 @@
|
|||||||
|
use ::libc;
|
||||||
|
|
||||||
|
pub use crate::stddef_h::size_t;
|
||||||
|
|
||||||
|
pub use crate::stdlib::__int16_t;
|
||||||
|
pub use crate::stdlib::__int32_t;
|
||||||
|
pub use crate::stdlib::__pthread_internal_list;
|
||||||
|
pub use crate::stdlib::__pthread_list_t;
|
||||||
|
pub use crate::stdlib::__pthread_mutex_s;
|
||||||
|
pub use crate::stdlib::__uint32_t;
|
||||||
|
pub use crate::stdlib::__uint64_t;
|
||||||
|
pub use crate::stdlib::__uint8_t;
|
||||||
|
pub use crate::stdlib::int16_t;
|
||||||
|
pub use crate::stdlib::int32_t;
|
||||||
|
pub use crate::stdlib::pthread_mutex_t;
|
||||||
|
pub use crate::stdlib::u_int32_t;
|
||||||
|
pub use crate::stdlib::u_int64_t;
|
||||||
|
pub use crate::stdlib::u_int8_t;
|
||||||
|
|
||||||
|
pub use crate::squeezelite_h::buffer;
|
||||||
|
pub use crate::squeezelite_h::codec;
|
||||||
|
pub use crate::squeezelite_h::decode_state;
|
||||||
|
pub use crate::squeezelite_h::decodestate;
|
||||||
|
pub use crate::squeezelite_h::disconnect_code;
|
||||||
|
pub use crate::squeezelite_h::fade_dir;
|
||||||
|
pub use crate::squeezelite_h::fade_mode;
|
||||||
|
pub use crate::squeezelite_h::fade_state;
|
||||||
|
pub use crate::squeezelite_h::frames_t;
|
||||||
|
pub use crate::squeezelite_h::lDEBUG;
|
||||||
|
pub use crate::squeezelite_h::lERROR;
|
||||||
|
pub use crate::squeezelite_h::lINFO;
|
||||||
|
pub use crate::squeezelite_h::lSDEBUG;
|
||||||
|
pub use crate::squeezelite_h::lWARN;
|
||||||
|
pub use crate::squeezelite_h::log_level;
|
||||||
|
pub use crate::squeezelite_h::output_format;
|
||||||
|
pub use crate::squeezelite_h::output_state;
|
||||||
|
pub use crate::squeezelite_h::outputstate;
|
||||||
|
pub use crate::squeezelite_h::s16_t;
|
||||||
|
pub use crate::squeezelite_h::s32_t;
|
||||||
|
pub use crate::squeezelite_h::stream_state;
|
||||||
|
pub use crate::squeezelite_h::streamstate;
|
||||||
|
pub use crate::squeezelite_h::u32_t;
|
||||||
|
pub use crate::squeezelite_h::u64_t;
|
||||||
|
pub use crate::squeezelite_h::u8_t;
|
||||||
|
pub use crate::squeezelite_h::C2RustUnnamed_1;
|
||||||
|
pub use crate::squeezelite_h::_buf_used;
|
||||||
|
pub use crate::squeezelite_h::DECODE_COMPLETE;
|
||||||
|
pub use crate::squeezelite_h::DECODE_ERROR;
|
||||||
|
pub use crate::squeezelite_h::DECODE_READY;
|
||||||
|
pub use crate::squeezelite_h::DECODE_RUNNING;
|
||||||
|
pub use crate::squeezelite_h::DECODE_STOPPED;
|
||||||
|
pub use crate::squeezelite_h::DISCONNECT;
|
||||||
|
pub use crate::squeezelite_h::DISCONNECT_OK;
|
||||||
|
pub use crate::squeezelite_h::FADE_ACTIVE;
|
||||||
|
pub use crate::squeezelite_h::FADE_CROSS;
|
||||||
|
pub use crate::squeezelite_h::FADE_CROSSFADE;
|
||||||
|
pub use crate::squeezelite_h::FADE_DOWN;
|
||||||
|
pub use crate::squeezelite_h::FADE_DUE;
|
||||||
|
pub use crate::squeezelite_h::FADE_IN;
|
||||||
|
pub use crate::squeezelite_h::FADE_INACTIVE;
|
||||||
|
pub use crate::squeezelite_h::FADE_INOUT;
|
||||||
|
pub use crate::squeezelite_h::FADE_NONE;
|
||||||
|
pub use crate::squeezelite_h::FADE_OUT;
|
||||||
|
pub use crate::squeezelite_h::FADE_UP;
|
||||||
|
pub use crate::squeezelite_h::LOCAL_DISCONNECT;
|
||||||
|
pub use crate::squeezelite_h::OUTPUT_BUFFER;
|
||||||
|
pub use crate::squeezelite_h::OUTPUT_OFF;
|
||||||
|
pub use crate::squeezelite_h::OUTPUT_PAUSE_FRAMES;
|
||||||
|
pub use crate::squeezelite_h::OUTPUT_RUNNING;
|
||||||
|
pub use crate::squeezelite_h::OUTPUT_SKIP_FRAMES;
|
||||||
|
pub use crate::squeezelite_h::OUTPUT_START_AT;
|
||||||
|
pub use crate::squeezelite_h::OUTPUT_STOPPED;
|
||||||
|
pub use crate::squeezelite_h::RECV_HEADERS;
|
||||||
|
pub use crate::squeezelite_h::REMOTE_DISCONNECT;
|
||||||
|
pub use crate::squeezelite_h::S16_LE;
|
||||||
|
pub use crate::squeezelite_h::S24_3LE;
|
||||||
|
pub use crate::squeezelite_h::S24_LE;
|
||||||
|
pub use crate::squeezelite_h::S32_LE;
|
||||||
|
pub use crate::squeezelite_h::SEND_HEADERS;
|
||||||
|
pub use crate::squeezelite_h::STOPPED;
|
||||||
|
pub use crate::squeezelite_h::STREAMING_BUFFERING;
|
||||||
|
pub use crate::squeezelite_h::STREAMING_FILE;
|
||||||
|
pub use crate::squeezelite_h::STREAMING_HTTP;
|
||||||
|
pub use crate::squeezelite_h::STREAMING_WAIT;
|
||||||
|
pub use crate::squeezelite_h::TIMEOUT;
|
||||||
|
pub use crate::squeezelite_h::UNREACHABLE;
|
||||||
|
pub use crate::src::buffer::_buf_cont_read;
|
||||||
|
pub use crate::src::buffer::_buf_cont_write;
|
||||||
|
pub use crate::src::buffer::_buf_inc_readp;
|
||||||
|
pub use crate::src::buffer::_buf_inc_writep;
|
||||||
|
pub use crate::src::buffer::_buf_space;
|
||||||
|
pub use crate::src::decode::decode_newstream;
|
||||||
|
pub use crate::src::output::_checkfade;
|
||||||
|
pub use crate::src::utils::logprint;
|
||||||
|
pub use crate::src::utils::logtime;
|
||||||
|
use crate::stdlib::malloc;
|
||||||
|
pub use crate::stdlib::mpg123_enc_enum;
|
||||||
|
pub use crate::stdlib::mpg123_errors;
|
||||||
|
pub use crate::stdlib::mpg123_feature_set;
|
||||||
|
pub use crate::stdlib::mpg123_handle;
|
||||||
|
pub use crate::stdlib::mpg123_handle_struct;
|
||||||
|
pub use crate::stdlib::MPG123_BAD_ALIGN;
|
||||||
|
pub use crate::stdlib::MPG123_BAD_BAND;
|
||||||
|
pub use crate::stdlib::MPG123_BAD_BUFFER;
|
||||||
|
pub use crate::stdlib::MPG123_BAD_CHANNEL;
|
||||||
|
pub use crate::stdlib::MPG123_BAD_CUSTOM_IO;
|
||||||
|
pub use crate::stdlib::MPG123_BAD_DECODER;
|
||||||
|
pub use crate::stdlib::MPG123_BAD_DECODER_SETUP;
|
||||||
|
pub use crate::stdlib::MPG123_BAD_FILE;
|
||||||
|
pub use crate::stdlib::MPG123_BAD_HANDLE;
|
||||||
|
pub use crate::stdlib::MPG123_BAD_INDEX_PAR;
|
||||||
|
pub use crate::stdlib::MPG123_BAD_KEY;
|
||||||
|
pub use crate::stdlib::MPG123_BAD_OUTFORMAT;
|
||||||
|
pub use crate::stdlib::MPG123_BAD_PARAM;
|
||||||
|
pub use crate::stdlib::MPG123_BAD_PARS;
|
||||||
|
pub use crate::stdlib::MPG123_BAD_RATE;
|
||||||
|
pub use crate::stdlib::MPG123_BAD_RVA;
|
||||||
|
pub use crate::stdlib::MPG123_BAD_TYPES;
|
||||||
|
pub use crate::stdlib::MPG123_BAD_VALUE;
|
||||||
|
pub use crate::stdlib::MPG123_BAD_WHENCE;
|
||||||
|
pub use crate::stdlib::MPG123_DONE;
|
||||||
|
pub use crate::stdlib::MPG123_ENC_16;
|
||||||
|
pub use crate::stdlib::MPG123_ENC_24;
|
||||||
|
pub use crate::stdlib::MPG123_ENC_32;
|
||||||
|
pub use crate::stdlib::MPG123_ENC_8;
|
||||||
|
pub use crate::stdlib::MPG123_ENC_ALAW_8;
|
||||||
|
pub use crate::stdlib::MPG123_ENC_ANY;
|
||||||
|
pub use crate::stdlib::MPG123_ENC_FLOAT;
|
||||||
|
pub use crate::stdlib::MPG123_ENC_FLOAT_32;
|
||||||
|
pub use crate::stdlib::MPG123_ENC_FLOAT_64;
|
||||||
|
pub use crate::stdlib::MPG123_ENC_SIGNED;
|
||||||
|
pub use crate::stdlib::MPG123_ENC_SIGNED_16;
|
||||||
|
pub use crate::stdlib::MPG123_ENC_SIGNED_24;
|
||||||
|
pub use crate::stdlib::MPG123_ENC_SIGNED_32;
|
||||||
|
pub use crate::stdlib::MPG123_ENC_SIGNED_8;
|
||||||
|
pub use crate::stdlib::MPG123_ENC_ULAW_8;
|
||||||
|
pub use crate::stdlib::MPG123_ENC_UNSIGNED_16;
|
||||||
|
pub use crate::stdlib::MPG123_ENC_UNSIGNED_24;
|
||||||
|
pub use crate::stdlib::MPG123_ENC_UNSIGNED_32;
|
||||||
|
pub use crate::stdlib::MPG123_ENC_UNSIGNED_8;
|
||||||
|
pub use crate::stdlib::MPG123_ERR;
|
||||||
|
pub use crate::stdlib::MPG123_ERR_16TO8TABLE;
|
||||||
|
pub use crate::stdlib::MPG123_ERR_NULL;
|
||||||
|
pub use crate::stdlib::MPG123_ERR_READER;
|
||||||
|
pub use crate::stdlib::MPG123_FEATURE_ABI_UTF8OPEN;
|
||||||
|
pub use crate::stdlib::MPG123_FEATURE_DECODE_ACCURATE;
|
||||||
|
pub use crate::stdlib::MPG123_FEATURE_DECODE_DOWNSAMPLE;
|
||||||
|
pub use crate::stdlib::MPG123_FEATURE_DECODE_LAYER1;
|
||||||
|
pub use crate::stdlib::MPG123_FEATURE_DECODE_LAYER2;
|
||||||
|
pub use crate::stdlib::MPG123_FEATURE_DECODE_LAYER3;
|
||||||
|
pub use crate::stdlib::MPG123_FEATURE_DECODE_NTOM;
|
||||||
|
pub use crate::stdlib::MPG123_FEATURE_EQUALIZER;
|
||||||
|
pub use crate::stdlib::MPG123_FEATURE_INDEX;
|
||||||
|
pub use crate::stdlib::MPG123_FEATURE_OUTPUT_16BIT;
|
||||||
|
pub use crate::stdlib::MPG123_FEATURE_OUTPUT_32BIT;
|
||||||
|
pub use crate::stdlib::MPG123_FEATURE_OUTPUT_8BIT;
|
||||||
|
pub use crate::stdlib::MPG123_FEATURE_PARSE_ICY;
|
||||||
|
pub use crate::stdlib::MPG123_FEATURE_PARSE_ID3V2;
|
||||||
|
pub use crate::stdlib::MPG123_FEATURE_TIMEOUT_READ;
|
||||||
|
pub use crate::stdlib::MPG123_INDEX_FAIL;
|
||||||
|
pub use crate::stdlib::MPG123_INT_OVERFLOW;
|
||||||
|
pub use crate::stdlib::MPG123_LFS_OVERFLOW;
|
||||||
|
pub use crate::stdlib::MPG123_LSEEK_FAILED;
|
||||||
|
pub use crate::stdlib::MPG123_MISSING_FEATURE;
|
||||||
|
pub use crate::stdlib::MPG123_NEED_MORE;
|
||||||
|
pub use crate::stdlib::MPG123_NEW_FORMAT;
|
||||||
|
pub use crate::stdlib::MPG123_NOT_INITIALIZED;
|
||||||
|
pub use crate::stdlib::MPG123_NO_8BIT;
|
||||||
|
pub use crate::stdlib::MPG123_NO_BUFFERS;
|
||||||
|
pub use crate::stdlib::MPG123_NO_GAPLESS;
|
||||||
|
pub use crate::stdlib::MPG123_NO_INDEX;
|
||||||
|
pub use crate::stdlib::MPG123_NO_READER;
|
||||||
|
pub use crate::stdlib::MPG123_NO_RELSEEK;
|
||||||
|
pub use crate::stdlib::MPG123_NO_SEEK;
|
||||||
|
pub use crate::stdlib::MPG123_NO_SEEK_FROM_END;
|
||||||
|
pub use crate::stdlib::MPG123_NO_SPACE;
|
||||||
|
pub use crate::stdlib::MPG123_NO_TIMEOUT;
|
||||||
|
pub use crate::stdlib::MPG123_NULL_BUFFER;
|
||||||
|
pub use crate::stdlib::MPG123_NULL_POINTER;
|
||||||
|
pub use crate::stdlib::MPG123_OK;
|
||||||
|
pub use crate::stdlib::MPG123_OUT_OF_MEM;
|
||||||
|
pub use crate::stdlib::MPG123_OUT_OF_SYNC;
|
||||||
|
pub use crate::stdlib::MPG123_RESYNC_FAIL;
|
||||||
|
|
||||||
|
use crate::stdlib::dlerror;
|
||||||
|
use crate::stdlib::dlopen;
|
||||||
|
use crate::stdlib::dlsym;
|
||||||
|
use crate::stdlib::pthread_mutex_lock;
|
||||||
|
use crate::stdlib::pthread_mutex_unlock;
|
||||||
|
extern "C" {
|
||||||
|
#[no_mangle]
|
||||||
|
pub static mut loglevel: crate::squeezelite_h::log_level;
|
||||||
|
#[no_mangle]
|
||||||
|
pub static mut streambuf: *mut crate::squeezelite_h::buffer;
|
||||||
|
#[no_mangle]
|
||||||
|
pub static mut outputbuf: *mut crate::squeezelite_h::buffer;
|
||||||
|
#[no_mangle]
|
||||||
|
pub static mut stream: crate::squeezelite_h::streamstate;
|
||||||
|
#[no_mangle]
|
||||||
|
pub static mut output: crate::squeezelite_h::outputstate;
|
||||||
|
#[no_mangle]
|
||||||
|
pub static mut decode: crate::squeezelite_h::decodestate;
|
||||||
|
}
|
||||||
|
|
||||||
|
#[repr(C)]
|
||||||
|
#[derive(Copy, Clone)]
|
||||||
|
pub struct mpg {
|
||||||
|
pub h: *mut crate::stdlib::mpg123_handle,
|
||||||
|
pub use16bit: bool,
|
||||||
|
pub mpg123_init: Option<unsafe extern "C" fn() -> libc::c_int>,
|
||||||
|
pub mpg123_feature:
|
||||||
|
Option<unsafe extern "C" fn(_: crate::stdlib::mpg123_feature_set) -> libc::c_int>,
|
||||||
|
pub mpg123_rates: Option<
|
||||||
|
unsafe extern "C" fn(_: *mut *const libc::c_long, _: *mut crate::stddef_h::size_t) -> (),
|
||||||
|
>,
|
||||||
|
pub mpg123_format_none:
|
||||||
|
Option<unsafe extern "C" fn(_: *mut crate::stdlib::mpg123_handle) -> libc::c_int>,
|
||||||
|
pub mpg123_format: Option<
|
||||||
|
unsafe extern "C" fn(
|
||||||
|
_: *mut crate::stdlib::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 crate::stdlib::mpg123_handle,
|
||||||
|
>,
|
||||||
|
pub mpg123_delete: Option<unsafe extern "C" fn(_: *mut crate::stdlib::mpg123_handle) -> ()>,
|
||||||
|
pub mpg123_open_feed:
|
||||||
|
Option<unsafe extern "C" fn(_: *mut crate::stdlib::mpg123_handle) -> libc::c_int>,
|
||||||
|
pub mpg123_decode: Option<
|
||||||
|
unsafe extern "C" fn(
|
||||||
|
_: *mut crate::stdlib::mpg123_handle,
|
||||||
|
_: *const libc::c_uchar,
|
||||||
|
_: crate::stddef_h::size_t,
|
||||||
|
_: *mut libc::c_uchar,
|
||||||
|
_: crate::stddef_h::size_t,
|
||||||
|
_: *mut crate::stddef_h::size_t,
|
||||||
|
) -> libc::c_int,
|
||||||
|
>,
|
||||||
|
pub mpg123_getformat: Option<
|
||||||
|
unsafe extern "C" fn(
|
||||||
|
_: *mut crate::stdlib::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>,
|
||||||
|
}
|
||||||
|
|
||||||
|
static mut m: *mut mpg = 0 as *const mpg as *mut mpg;
|
||||||
|
|
||||||
|
unsafe extern "C" fn mpg_decode() -> crate::squeezelite_h::decode_state {
|
||||||
|
let mut bytes: crate::stddef_h::size_t = 0;
|
||||||
|
let mut space: crate::stddef_h::size_t = 0;
|
||||||
|
let mut size: crate::stddef_h::size_t = 0;
|
||||||
|
let mut ret: libc::c_int = 0;
|
||||||
|
let mut write_buf = 0 as *mut crate::squeezelite_h::u8_t;
|
||||||
|
crate::stdlib::pthread_mutex_lock(&mut (*streambuf).mutex);
|
||||||
|
crate::stdlib::pthread_mutex_lock(&mut (*outputbuf).mutex);
|
||||||
|
bytes = if crate::squeezelite_h::_buf_used(streambuf)
|
||||||
|
< crate::src::buffer::_buf_cont_read(streambuf)
|
||||||
|
{
|
||||||
|
crate::squeezelite_h::_buf_used(streambuf)
|
||||||
|
} else {
|
||||||
|
crate::src::buffer::_buf_cont_read(streambuf)
|
||||||
|
} as crate::stddef_h::size_t;
|
||||||
|
space = if crate::src::buffer::_buf_space(outputbuf)
|
||||||
|
< crate::src::buffer::_buf_cont_write(outputbuf)
|
||||||
|
{
|
||||||
|
crate::src::buffer::_buf_space(outputbuf)
|
||||||
|
} else {
|
||||||
|
crate::src::buffer::_buf_cont_write(outputbuf)
|
||||||
|
} as crate::stddef_h::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 crate::stddef_h::size_t
|
||||||
|
}
|
||||||
|
ret = (*m).mpg123_decode.expect("non-null function pointer")(
|
||||||
|
(*m).h,
|
||||||
|
(*streambuf).readp,
|
||||||
|
bytes,
|
||||||
|
write_buf,
|
||||||
|
space,
|
||||||
|
&mut size,
|
||||||
|
);
|
||||||
|
if ret == crate::stdlib::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
|
||||||
|
>= crate::squeezelite_h::lINFO as libc::c_int as libc::c_uint
|
||||||
|
{
|
||||||
|
crate::src::utils::logprint(
|
||||||
|
b"%s %s:%d setting track_start\n\x00" as *const u8 as *const libc::c_char,
|
||||||
|
crate::src::utils::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 = crate::src::decode::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 {
|
||||||
|
crate::src::output::_checkfade(1 as libc::c_int != 0);
|
||||||
|
}
|
||||||
|
decode.new_stream = 0 as libc::c_int != 0
|
||||||
|
} else if loglevel as libc::c_uint
|
||||||
|
>= crate::squeezelite_h::lWARN as libc::c_int as libc::c_uint
|
||||||
|
{
|
||||||
|
crate::src::utils::logprint(
|
||||||
|
b"%s %s:%d format change mid stream - not supported\n\x00" as *const u8
|
||||||
|
as *const libc::c_char,
|
||||||
|
crate::src::utils::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 = 0 as *mut crate::squeezelite_h::s16_t;
|
||||||
|
let mut optr = 0 as *mut crate::squeezelite_h::s32_t;
|
||||||
|
let mut count = 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 crate::squeezelite_h::s16_t).offset(count as isize);
|
||||||
|
optr = (write_buf as *mut crate::squeezelite_h::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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
crate::src::buffer::_buf_inc_readp(streambuf, bytes as libc::c_uint);
|
||||||
|
crate::src::buffer::_buf_inc_writep(outputbuf, size as libc::c_uint);
|
||||||
|
crate::stdlib::pthread_mutex_unlock(&mut (*outputbuf).mutex);
|
||||||
|
if loglevel as libc::c_uint >= crate::squeezelite_h::lSDEBUG as libc::c_int as libc::c_uint {
|
||||||
|
crate::src::utils::logprint(
|
||||||
|
b"%s %s:%d write %u frames\n\x00" as *const u8 as *const libc::c_char,
|
||||||
|
crate::src::utils::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 == crate::stdlib::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
|
||||||
|
<= crate::squeezelite_h::DISCONNECT as libc::c_int as libc::c_uint
|
||||||
|
{
|
||||||
|
crate::stdlib::pthread_mutex_unlock(&mut (*streambuf).mutex);
|
||||||
|
if loglevel as libc::c_uint >= crate::squeezelite_h::lINFO as libc::c_int as libc::c_uint {
|
||||||
|
crate::src::utils::logprint(
|
||||||
|
b"%s %s:%d stream complete\n\x00" as *const u8 as *const libc::c_char,
|
||||||
|
crate::src::utils::logtime(),
|
||||||
|
(*::std::mem::transmute::<&[u8; 11], &[libc::c_char; 11]>(b"mpg_decode\x00"))
|
||||||
|
.as_ptr(),
|
||||||
|
167 as libc::c_int,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return crate::squeezelite_h::DECODE_COMPLETE;
|
||||||
|
}
|
||||||
|
crate::stdlib::pthread_mutex_unlock(&mut (*streambuf).mutex);
|
||||||
|
if ret == crate::stdlib::MPG123_ERR as libc::c_int {
|
||||||
|
if loglevel as libc::c_uint >= crate::squeezelite_h::lWARN as libc::c_int as libc::c_uint {
|
||||||
|
crate::src::utils::logprint(
|
||||||
|
b"%s %s:%d Error\n\x00" as *const u8 as *const libc::c_char,
|
||||||
|
crate::src::utils::logtime(),
|
||||||
|
(*::std::mem::transmute::<&[u8; 11], &[libc::c_char; 11]>(b"mpg_decode\x00"))
|
||||||
|
.as_ptr(),
|
||||||
|
174 as libc::c_int,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return crate::squeezelite_h::DECODE_COMPLETE;
|
||||||
|
}
|
||||||
|
// OK and NEED_MORE keep running
|
||||||
|
return crate::squeezelite_h::DECODE_RUNNING;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe extern "C" fn mpg_open(
|
||||||
|
mut size: crate::squeezelite_h::u8_t,
|
||||||
|
mut rate: crate::squeezelite_h::u8_t,
|
||||||
|
mut chan: crate::squeezelite_h::u8_t,
|
||||||
|
mut endianness: crate::squeezelite_h::u8_t,
|
||||||
|
) {
|
||||||
|
let mut err: libc::c_int = 0;
|
||||||
|
let mut list = 0 as *const libc::c_long;
|
||||||
|
let mut count: crate::stddef_h::size_t = 0;
|
||||||
|
let mut i: crate::stddef_h::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 >= crate::squeezelite_h::lWARN as libc::c_int as libc::c_uint {
|
||||||
|
crate::src::utils::logprint(
|
||||||
|
b"%s %s:%d new error: %s\n\x00" as *const u8 as *const libc::c_char,
|
||||||
|
crate::src::utils::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 crate::stddef_h::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 {
|
||||||
|
crate::stdlib::MPG123_ENC_SIGNED_16 as libc::c_int
|
||||||
|
} else {
|
||||||
|
crate::stdlib::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 >= crate::squeezelite_h::lWARN as libc::c_int as libc::c_uint {
|
||||||
|
crate::src::utils::logprint(
|
||||||
|
b"%s %s:%d open feed error: %s\n\x00" as *const u8 as *const libc::c_char,
|
||||||
|
crate::src::utils::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 crate::stdlib::mpg123_handle;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe extern "C" fn load_mpg() -> bool {
|
||||||
|
let mut handle = crate::stdlib::dlopen(
|
||||||
|
b"libmpg123.so.0\x00" as *const u8 as *const libc::c_char,
|
||||||
|
0x2 as libc::c_int,
|
||||||
|
);
|
||||||
|
let mut err = 0 as *mut libc::c_char;
|
||||||
|
if handle.is_null() {
|
||||||
|
if loglevel as libc::c_uint >= crate::squeezelite_h::lINFO as libc::c_int as libc::c_uint {
|
||||||
|
crate::src::utils::logprint(
|
||||||
|
b"%s %s:%d dlerror: %s\n\x00" as *const u8 as *const libc::c_char,
|
||||||
|
crate::src::utils::logtime(),
|
||||||
|
(*::std::mem::transmute::<&[u8; 9], &[libc::c_char; 9]>(b"load_mpg\x00")).as_ptr(),
|
||||||
|
222 as libc::c_int,
|
||||||
|
crate::stdlib::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>,
|
||||||
|
>(crate::stdlib::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(_: crate::stdlib::mpg123_feature_set) -> libc::c_int>,
|
||||||
|
>(crate::stdlib::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 crate::stddef_h::size_t,
|
||||||
|
) -> (),
|
||||||
|
>,
|
||||||
|
>(crate::stdlib::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 crate::stdlib::mpg123_handle) -> libc::c_int>,
|
||||||
|
>(crate::stdlib::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 crate::stdlib::mpg123_handle,
|
||||||
|
_: libc::c_long,
|
||||||
|
_: libc::c_int,
|
||||||
|
_: libc::c_int,
|
||||||
|
) -> libc::c_int,
|
||||||
|
>,
|
||||||
|
>(crate::stdlib::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 crate::stdlib::mpg123_handle,
|
||||||
|
>,
|
||||||
|
>(crate::stdlib::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 crate::stdlib::mpg123_handle) -> ()>,
|
||||||
|
>(crate::stdlib::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 crate::stdlib::mpg123_handle) -> libc::c_int>,
|
||||||
|
>(crate::stdlib::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 crate::stdlib::mpg123_handle,
|
||||||
|
_: *const libc::c_uchar,
|
||||||
|
_: crate::stddef_h::size_t,
|
||||||
|
_: *mut libc::c_uchar,
|
||||||
|
_: crate::stddef_h::size_t,
|
||||||
|
_: *mut crate::stddef_h::size_t,
|
||||||
|
) -> libc::c_int,
|
||||||
|
>,
|
||||||
|
>(crate::stdlib::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 crate::stdlib::mpg123_handle,
|
||||||
|
_: *mut libc::c_long,
|
||||||
|
_: *mut libc::c_int,
|
||||||
|
_: *mut libc::c_int,
|
||||||
|
) -> libc::c_int,
|
||||||
|
>,
|
||||||
|
>(crate::stdlib::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>,
|
||||||
|
>(crate::stdlib::dlsym(
|
||||||
|
handle,
|
||||||
|
b"mpg123_plain_strerror\x00" as *const u8 as *const libc::c_char,
|
||||||
|
));
|
||||||
|
err = crate::stdlib::dlerror();
|
||||||
|
if !err.is_null() {
|
||||||
|
if loglevel as libc::c_uint >= crate::squeezelite_h::lINFO as libc::c_int as libc::c_uint {
|
||||||
|
crate::src::utils::logprint(
|
||||||
|
b"%s %s:%d dlerror: %s\n\x00" as *const u8 as *const libc::c_char,
|
||||||
|
crate::src::utils::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 >= crate::squeezelite_h::lINFO as libc::c_int as libc::c_uint {
|
||||||
|
crate::src::utils::logprint(
|
||||||
|
b"%s %s:%d loaded libmpg123.so.0\n\x00" as *const u8 as *const libc::c_char,
|
||||||
|
crate::src::utils::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 crate::squeezelite_h::codec {
|
||||||
|
static mut ret: crate::squeezelite_h::codec = unsafe {
|
||||||
|
{
|
||||||
|
let mut init = crate::squeezelite_h::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(
|
||||||
|
_: crate::squeezelite_h::u8_t,
|
||||||
|
_: crate::squeezelite_h::u8_t,
|
||||||
|
_: crate::squeezelite_h::u8_t,
|
||||||
|
_: crate::squeezelite_h::u8_t,
|
||||||
|
) -> (),
|
||||||
|
),
|
||||||
|
close: Some(mpg_close as unsafe extern "C" fn() -> ()),
|
||||||
|
decode: Some(
|
||||||
|
mpg_decode as unsafe extern "C" fn() -> crate::squeezelite_h::decode_state,
|
||||||
|
),
|
||||||
|
};
|
||||||
|
init
|
||||||
|
}
|
||||||
|
};
|
||||||
|
m = crate::stdlib::malloc(::std::mem::size_of::<mpg>() as libc::c_ulong) as *mut mpg;
|
||||||
|
if m.is_null() {
|
||||||
|
return 0 as *mut crate::squeezelite_h::codec;
|
||||||
|
}
|
||||||
|
(*m).h = 0 as *mut crate::stdlib::mpg123_handle;
|
||||||
|
if !load_mpg() {
|
||||||
|
return 0 as *mut crate::squeezelite_h::codec;
|
||||||
|
}
|
||||||
|
(*m).mpg123_init.expect("non-null function pointer")();
|
||||||
|
(*m).use16bit = (*m).mpg123_feature.expect("non-null function pointer")(
|
||||||
|
crate::stdlib::MPG123_FEATURE_OUTPUT_32BIT,
|
||||||
|
) != 0;
|
||||||
|
if loglevel as libc::c_uint >= crate::squeezelite_h::lINFO as libc::c_int as libc::c_uint {
|
||||||
|
crate::src::utils::logprint(
|
||||||
|
b"%s %s:%d using mpg to decode mp3\n\x00" as *const u8 as *const libc::c_char,
|
||||||
|
crate::src::utils::logtime(),
|
||||||
|
(*::std::mem::transmute::<&[u8; 13], &[libc::c_char; 13]>(b"register_mpg\x00"))
|
||||||
|
.as_ptr(),
|
||||||
|
275 as libc::c_int,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return &mut ret;
|
||||||
|
}
|
1152
src/output.rs
Normal file
1152
src/output.rs
Normal file
File diff suppressed because it is too large
Load Diff
2390
src/output_alsa.rs
Normal file
2390
src/output_alsa.rs
Normal file
File diff suppressed because it is too large
Load Diff
23
src/output_pa.rs
Normal file
23
src/output_pa.rs
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
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/>.
|
||||||
|
*
|
||||||
|
*/
|
324
src/output_pack.rs
Normal file
324
src/output_pack.rs
Normal file
@ -0,0 +1,324 @@
|
|||||||
|
use ::libc;
|
||||||
|
|
||||||
|
pub use crate::squeezelite_h::frames_t;
|
||||||
|
pub use crate::squeezelite_h::output_format;
|
||||||
|
pub use crate::squeezelite_h::s32_t;
|
||||||
|
pub use crate::squeezelite_h::s64_t;
|
||||||
|
pub use crate::squeezelite_h::u32_t;
|
||||||
|
pub use crate::squeezelite_h::u8_t;
|
||||||
|
pub use crate::squeezelite_h::S16_LE;
|
||||||
|
pub use crate::squeezelite_h::S24_3LE;
|
||||||
|
pub use crate::squeezelite_h::S24_LE;
|
||||||
|
pub use crate::squeezelite_h::S32_LE;
|
||||||
|
pub use crate::stdlib::__int32_t;
|
||||||
|
pub use crate::stdlib::__int64_t;
|
||||||
|
pub use crate::stdlib::__uint32_t;
|
||||||
|
pub use crate::stdlib::__uint8_t;
|
||||||
|
pub use crate::stdlib::int32_t;
|
||||||
|
pub use crate::stdlib::int64_t;
|
||||||
|
use crate::stdlib::memcpy;
|
||||||
|
pub use crate::stdlib::u_int32_t;
|
||||||
|
pub use crate::stdlib::u_int8_t;
|
||||||
|
pub use crate::stdlib::uintptr_t;
|
||||||
|
// inlining these on windows prevents them being linkable...
|
||||||
|
#[inline]
|
||||||
|
|
||||||
|
unsafe extern "C" fn gain(
|
||||||
|
mut gain_0: crate::squeezelite_h::s32_t,
|
||||||
|
mut sample: crate::squeezelite_h::s32_t,
|
||||||
|
) -> crate::squeezelite_h::s32_t {
|
||||||
|
let mut res = gain_0 as crate::squeezelite_h::s64_t * sample as crate::squeezelite_h::s64_t;
|
||||||
|
if res as libc::c_longlong > 0x7fffffffffff as libc::c_longlong {
|
||||||
|
res = 0x7fffffffffff as libc::c_longlong as crate::squeezelite_h::s64_t
|
||||||
|
}
|
||||||
|
if (res as libc::c_longlong) < -(0x7fffffffffff as libc::c_longlong) {
|
||||||
|
res = -(0x7fffffffffff as libc::c_longlong) as crate::squeezelite_h::s64_t
|
||||||
|
}
|
||||||
|
return (res >> 16 as libc::c_int) as crate::squeezelite_h::s32_t;
|
||||||
|
}
|
||||||
|
#[no_mangle]
|
||||||
|
|
||||||
|
pub unsafe extern "C" fn _scale_and_pack_frames(
|
||||||
|
mut outputptr: *mut libc::c_void,
|
||||||
|
mut inputptr: *mut crate::squeezelite_h::s32_t,
|
||||||
|
mut cnt: crate::squeezelite_h::frames_t,
|
||||||
|
mut gainL: crate::squeezelite_h::s32_t,
|
||||||
|
mut gainR: crate::squeezelite_h::s32_t,
|
||||||
|
mut format: crate::squeezelite_h::output_format,
|
||||||
|
) {
|
||||||
|
match format as libc::c_uint {
|
||||||
|
3 => {
|
||||||
|
let mut optr = outputptr as *mut crate::squeezelite_h::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 = outputptr as *mut crate::squeezelite_h::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 crate::squeezelite_h::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 crate::squeezelite_h::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 crate::squeezelite_h::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 crate::squeezelite_h::u32_t
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
2 => {
|
||||||
|
let mut optr_1 = outputptr as *mut crate::squeezelite_h::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 crate::stdlib::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 =
|
||||||
|
optr_1 as *mut libc::c_void as *mut crate::squeezelite_h::u32_t;
|
||||||
|
while cnt >= 2 as libc::c_int as libc::c_uint {
|
||||||
|
let fresh14 = inputptr;
|
||||||
|
inputptr = inputptr.offset(1);
|
||||||
|
let mut l1 = *fresh14;
|
||||||
|
let fresh15 = inputptr;
|
||||||
|
inputptr = inputptr.offset(1);
|
||||||
|
let mut r1 = *fresh15;
|
||||||
|
let fresh16 = inputptr;
|
||||||
|
inputptr = inputptr.offset(1);
|
||||||
|
let mut l2 = *fresh16;
|
||||||
|
let fresh17 = inputptr;
|
||||||
|
inputptr = inputptr.offset(1);
|
||||||
|
let mut r2 = *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 crate::squeezelite_h::frames_t
|
||||||
|
as crate::squeezelite_h::frames_t
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
let fresh21 = inputptr;
|
||||||
|
inputptr = inputptr.offset(1);
|
||||||
|
let mut lsample = *fresh21;
|
||||||
|
let fresh22 = inputptr;
|
||||||
|
inputptr = inputptr.offset(1);
|
||||||
|
let mut rsample = *fresh22;
|
||||||
|
let fresh23 = optr_1;
|
||||||
|
optr_1 = optr_1.offset(1);
|
||||||
|
*fresh23 = ((lsample & 0xff00 as libc::c_int) >> 8 as libc::c_int)
|
||||||
|
as crate::squeezelite_h::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 crate::squeezelite_h::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 crate::squeezelite_h::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 crate::squeezelite_h::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 crate::squeezelite_h::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 crate::squeezelite_h::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 crate::stdlib::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 =
|
||||||
|
optr_1 as *mut libc::c_void as *mut crate::squeezelite_h::u32_t;
|
||||||
|
while cnt >= 2 as libc::c_int as libc::c_uint {
|
||||||
|
let fresh29 = inputptr;
|
||||||
|
inputptr = inputptr.offset(1);
|
||||||
|
let mut l1_0 = gain(gainL, *fresh29);
|
||||||
|
let fresh30 = inputptr;
|
||||||
|
inputptr = inputptr.offset(1);
|
||||||
|
let mut r1_0 = gain(gainR, *fresh30);
|
||||||
|
let fresh31 = inputptr;
|
||||||
|
inputptr = inputptr.offset(1);
|
||||||
|
let mut l2_0 = gain(gainL, *fresh31);
|
||||||
|
let fresh32 = inputptr;
|
||||||
|
inputptr = inputptr.offset(1);
|
||||||
|
let mut r2_0 = 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 crate::squeezelite_h::frames_t
|
||||||
|
as crate::squeezelite_h::frames_t
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
let fresh36 = inputptr;
|
||||||
|
inputptr = inputptr.offset(1);
|
||||||
|
let mut lsample_0 = gain(gainL, *fresh36);
|
||||||
|
let fresh37 = inputptr;
|
||||||
|
inputptr = inputptr.offset(1);
|
||||||
|
let mut rsample_0 = 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 crate::squeezelite_h::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 crate::squeezelite_h::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 crate::squeezelite_h::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 crate::squeezelite_h::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 crate::squeezelite_h::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 crate::squeezelite_h::u8_t;
|
||||||
|
cnt = cnt.wrapping_sub(1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
0 => {
|
||||||
|
let mut optr_2 = outputptr as *mut crate::squeezelite_h::u32_t;
|
||||||
|
if gainL == 0x10000 as libc::c_int && gainR == 0x10000 as libc::c_int {
|
||||||
|
crate::stdlib::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 crate::squeezelite_h::u32_t;
|
||||||
|
let fresh47 = inputptr;
|
||||||
|
inputptr = inputptr.offset(1);
|
||||||
|
let fresh48 = optr_2;
|
||||||
|
optr_2 = optr_2.offset(1);
|
||||||
|
*fresh48 = gain(gainR, *fresh47) as crate::squeezelite_h::u32_t
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_ => {}
|
||||||
|
};
|
||||||
|
}
|
25
src/output_pulse.rs
Normal file
25
src/output_pulse.rs
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
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
|
||||||
|
*/
|
346
src/output_stdout.rs
Normal file
346
src/output_stdout.rs
Normal file
@ -0,0 +1,346 @@
|
|||||||
|
use ::libc;
|
||||||
|
|
||||||
|
pub use crate::stddef_h::size_t;
|
||||||
|
|
||||||
|
pub use crate::stdlib::_IO_codecvt;
|
||||||
|
pub use crate::stdlib::_IO_lock_t;
|
||||||
|
pub use crate::stdlib::_IO_marker;
|
||||||
|
pub use crate::stdlib::_IO_wide_data;
|
||||||
|
pub use crate::stdlib::__int32_t;
|
||||||
|
pub use crate::stdlib::__off64_t;
|
||||||
|
pub use crate::stdlib::__off_t;
|
||||||
|
pub use crate::stdlib::__uint32_t;
|
||||||
|
pub use crate::stdlib::__uint8_t;
|
||||||
|
pub use crate::stdlib::int32_t;
|
||||||
|
pub use crate::stdlib::FILE;
|
||||||
|
pub use crate::stdlib::_IO_FILE;
|
||||||
|
|
||||||
|
pub use crate::squeezelite_h::_apply_cross;
|
||||||
|
pub use crate::squeezelite_h::buffer;
|
||||||
|
pub use crate::squeezelite_h::fade_dir;
|
||||||
|
pub use crate::squeezelite_h::fade_mode;
|
||||||
|
pub use crate::squeezelite_h::fade_state;
|
||||||
|
pub use crate::squeezelite_h::frames_t;
|
||||||
|
pub use crate::squeezelite_h::lDEBUG;
|
||||||
|
pub use crate::squeezelite_h::lERROR;
|
||||||
|
pub use crate::squeezelite_h::lINFO;
|
||||||
|
pub use crate::squeezelite_h::lSDEBUG;
|
||||||
|
pub use crate::squeezelite_h::lWARN;
|
||||||
|
pub use crate::squeezelite_h::log_level;
|
||||||
|
pub use crate::squeezelite_h::output_format;
|
||||||
|
pub use crate::squeezelite_h::output_state;
|
||||||
|
pub use crate::squeezelite_h::outputstate;
|
||||||
|
pub use crate::squeezelite_h::s32_t;
|
||||||
|
pub use crate::squeezelite_h::u32_t;
|
||||||
|
pub use crate::squeezelite_h::u8_t;
|
||||||
|
pub use crate::squeezelite_h::C2RustUnnamed_1;
|
||||||
|
pub use crate::squeezelite_h::FADE_ACTIVE;
|
||||||
|
pub use crate::squeezelite_h::FADE_CROSS;
|
||||||
|
pub use crate::squeezelite_h::FADE_CROSSFADE;
|
||||||
|
pub use crate::squeezelite_h::FADE_DOWN;
|
||||||
|
pub use crate::squeezelite_h::FADE_DUE;
|
||||||
|
pub use crate::squeezelite_h::FADE_IN;
|
||||||
|
pub use crate::squeezelite_h::FADE_INACTIVE;
|
||||||
|
pub use crate::squeezelite_h::FADE_INOUT;
|
||||||
|
pub use crate::squeezelite_h::FADE_NONE;
|
||||||
|
pub use crate::squeezelite_h::FADE_OUT;
|
||||||
|
pub use crate::squeezelite_h::FADE_UP;
|
||||||
|
pub use crate::squeezelite_h::OUTPUT_BUFFER;
|
||||||
|
pub use crate::squeezelite_h::OUTPUT_OFF;
|
||||||
|
pub use crate::squeezelite_h::OUTPUT_PAUSE_FRAMES;
|
||||||
|
pub use crate::squeezelite_h::OUTPUT_RUNNING;
|
||||||
|
pub use crate::squeezelite_h::OUTPUT_SKIP_FRAMES;
|
||||||
|
pub use crate::squeezelite_h::OUTPUT_START_AT;
|
||||||
|
pub use crate::squeezelite_h::OUTPUT_STOPPED;
|
||||||
|
pub use crate::squeezelite_h::S16_LE;
|
||||||
|
pub use crate::squeezelite_h::S24_3LE;
|
||||||
|
pub use crate::squeezelite_h::S24_LE;
|
||||||
|
pub use crate::squeezelite_h::S32_LE;
|
||||||
|
pub use crate::src::output::_output_frames;
|
||||||
|
pub use crate::src::output::output_close_common;
|
||||||
|
pub use crate::src::output::output_init_common;
|
||||||
|
pub use crate::src::output_pack::_scale_and_pack_frames;
|
||||||
|
pub use crate::src::utils::gettime_ms;
|
||||||
|
pub use crate::src::utils::logprint;
|
||||||
|
pub use crate::src::utils::logtime;
|
||||||
|
pub use crate::stdlib::__pthread_internal_list;
|
||||||
|
pub use crate::stdlib::__pthread_list_t;
|
||||||
|
pub use crate::stdlib::__pthread_mutex_s;
|
||||||
|
use crate::stdlib::free;
|
||||||
|
use crate::stdlib::fwrite;
|
||||||
|
use crate::stdlib::malloc;
|
||||||
|
use crate::stdlib::memset;
|
||||||
|
use crate::stdlib::pthread_attr_destroy;
|
||||||
|
use crate::stdlib::pthread_attr_init;
|
||||||
|
use crate::stdlib::pthread_attr_setstacksize;
|
||||||
|
pub use crate::stdlib::pthread_attr_t;
|
||||||
|
use crate::stdlib::pthread_create;
|
||||||
|
use crate::stdlib::pthread_mutex_lock;
|
||||||
|
pub use crate::stdlib::pthread_mutex_t;
|
||||||
|
use crate::stdlib::pthread_mutex_unlock;
|
||||||
|
pub use crate::stdlib::pthread_t;
|
||||||
|
use crate::stdlib::stdout;
|
||||||
|
use crate::stdlib::strcmp;
|
||||||
|
pub use crate::stdlib::u_int32_t;
|
||||||
|
pub use crate::stdlib::u_int8_t;
|
||||||
|
extern "C" {
|
||||||
|
#[no_mangle]
|
||||||
|
pub static mut output: crate::squeezelite_h::outputstate;
|
||||||
|
#[no_mangle]
|
||||||
|
pub static mut outputbuf: *mut crate::squeezelite_h::buffer;
|
||||||
|
#[no_mangle]
|
||||||
|
pub static mut silencebuf: *mut crate::squeezelite_h::u8_t;
|
||||||
|
}
|
||||||
|
|
||||||
|
static mut loglevel: crate::squeezelite_h::log_level = crate::squeezelite_h::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 crate::squeezelite_h::u8_t =
|
||||||
|
0 as *const crate::squeezelite_h::u8_t as *mut crate::squeezelite_h::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: crate::squeezelite_h::frames_t,
|
||||||
|
mut silence: bool,
|
||||||
|
mut gainL: crate::squeezelite_h::s32_t,
|
||||||
|
mut gainR: crate::squeezelite_h::s32_t,
|
||||||
|
mut cross_gain_in: crate::squeezelite_h::s32_t,
|
||||||
|
mut cross_gain_out: crate::squeezelite_h::s32_t,
|
||||||
|
mut cross_ptr: *mut *mut crate::squeezelite_h::s32_t,
|
||||||
|
) -> libc::c_int {
|
||||||
|
let mut obuf = 0 as *mut crate::squeezelite_h::u8_t;
|
||||||
|
if !silence {
|
||||||
|
if output.fade as libc::c_uint
|
||||||
|
== crate::squeezelite_h::FADE_ACTIVE as libc::c_int as libc::c_uint
|
||||||
|
&& output.fade_dir as libc::c_uint
|
||||||
|
== crate::squeezelite_h::FADE_CROSS as libc::c_int as libc::c_uint
|
||||||
|
&& !(*cross_ptr).is_null()
|
||||||
|
{
|
||||||
|
crate::squeezelite_h::_apply_cross(
|
||||||
|
outputbuf,
|
||||||
|
out_frames,
|
||||||
|
cross_gain_in,
|
||||||
|
cross_gain_out,
|
||||||
|
cross_ptr,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
obuf = (*outputbuf).readp
|
||||||
|
} else {
|
||||||
|
obuf = silencebuf
|
||||||
|
}
|
||||||
|
crate::src::output_pack::_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 crate::squeezelite_h::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 {
|
||||||
|
crate::stdlib::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,
|
||||||
|
}
|
||||||
|
crate::stdlib::pthread_mutex_unlock(&mut (*outputbuf).mutex);
|
||||||
|
while running {
|
||||||
|
crate::stdlib::pthread_mutex_lock(&mut (*outputbuf).mutex);
|
||||||
|
output.device_frames = 0 as libc::c_int as libc::c_uint;
|
||||||
|
output.updated = crate::src::utils::gettime_ms();
|
||||||
|
output.frames_played_dmp = output.frames_played;
|
||||||
|
crate::src::output::_output_frames(2048 as libc::c_int as crate::squeezelite_h::frames_t);
|
||||||
|
crate::stdlib::pthread_mutex_unlock(&mut (*outputbuf).mutex);
|
||||||
|
if buffill != 0 {
|
||||||
|
crate::stdlib::fwrite(
|
||||||
|
buf as *const libc::c_void,
|
||||||
|
bytes_per_frame as libc::c_ulong,
|
||||||
|
buffill as libc::c_ulong,
|
||||||
|
crate::stdlib::stdout,
|
||||||
|
);
|
||||||
|
buffill = 0 as libc::c_int as libc::c_uint
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0 as *mut libc::c_void;
|
||||||
|
}
|
||||||
|
|
||||||
|
static mut thread: crate::stdlib::pthread_t = 0;
|
||||||
|
#[no_mangle]
|
||||||
|
|
||||||
|
pub unsafe extern "C" fn output_init_stdout(
|
||||||
|
mut level: crate::squeezelite_h::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 >= crate::squeezelite_h::lINFO as libc::c_int as libc::c_uint {
|
||||||
|
crate::src::utils::logprint(
|
||||||
|
b"%s %s:%d init output stdout\n\x00" as *const u8 as *const libc::c_char,
|
||||||
|
crate::src::utils::logtime(),
|
||||||
|
(*::std::mem::transmute::<&[u8; 19], &[libc::c_char; 19]>(b"output_init_stdout\x00"))
|
||||||
|
.as_ptr(),
|
||||||
|
130 as libc::c_int,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
buf = crate::stdlib::malloc((2048 as libc::c_int * 8 as libc::c_int) as libc::c_ulong)
|
||||||
|
as *mut crate::squeezelite_h::u8_t;
|
||||||
|
if buf.is_null() {
|
||||||
|
crate::src::utils::logprint(
|
||||||
|
b"%s %s:%d unable to malloc buf\n\x00" as *const u8 as *const libc::c_char,
|
||||||
|
crate::src::utils::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;
|
||||||
|
crate::stdlib::memset(
|
||||||
|
&mut output as *mut crate::squeezelite_h::outputstate as *mut libc::c_void,
|
||||||
|
0 as libc::c_int,
|
||||||
|
::std::mem::size_of::<crate::squeezelite_h::outputstate>() as libc::c_ulong,
|
||||||
|
);
|
||||||
|
output.format = crate::squeezelite_h::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(
|
||||||
|
_: crate::squeezelite_h::frames_t,
|
||||||
|
_: bool,
|
||||||
|
_: crate::squeezelite_h::s32_t,
|
||||||
|
_: crate::squeezelite_h::s32_t,
|
||||||
|
_: crate::squeezelite_h::s32_t,
|
||||||
|
_: crate::squeezelite_h::s32_t,
|
||||||
|
_: *mut *mut crate::squeezelite_h::s32_t,
|
||||||
|
) -> libc::c_int,
|
||||||
|
);
|
||||||
|
output.rate_delay = rate_delay;
|
||||||
|
if !params.is_null() {
|
||||||
|
if crate::stdlib::strcmp(params, b"32\x00" as *const u8 as *const libc::c_char) == 0 {
|
||||||
|
output.format = crate::squeezelite_h::S32_LE
|
||||||
|
}
|
||||||
|
if crate::stdlib::strcmp(params, b"24\x00" as *const u8 as *const libc::c_char) == 0 {
|
||||||
|
output.format = crate::squeezelite_h::S24_3LE
|
||||||
|
}
|
||||||
|
if crate::stdlib::strcmp(params, b"16\x00" as *const u8 as *const libc::c_char) == 0 {
|
||||||
|
output.format = crate::squeezelite_h::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
|
||||||
|
}
|
||||||
|
crate::src::output::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 = crate::stdlib::pthread_attr_t { __size: [0; 56] };
|
||||||
|
crate::stdlib::pthread_attr_init(&mut attr);
|
||||||
|
crate::stdlib::pthread_attr_setstacksize(
|
||||||
|
&mut attr,
|
||||||
|
(16384 as libc::c_int + 64 as libc::c_int * 1024 as libc::c_int) as crate::stddef_h::size_t,
|
||||||
|
);
|
||||||
|
crate::stdlib::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,
|
||||||
|
);
|
||||||
|
crate::stdlib::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 >= crate::squeezelite_h::lINFO as libc::c_int as libc::c_uint {
|
||||||
|
crate::src::utils::logprint(
|
||||||
|
b"%s %s:%d close output\n\x00" as *const u8 as *const libc::c_char,
|
||||||
|
crate::src::utils::logtime(),
|
||||||
|
(*::std::mem::transmute::<&[u8; 20], &[libc::c_char; 20]>(b"output_close_stdout\x00"))
|
||||||
|
.as_ptr(),
|
||||||
|
174 as libc::c_int,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
crate::stdlib::pthread_mutex_lock(&mut (*outputbuf).mutex);
|
||||||
|
running = 0 as libc::c_int != 0;
|
||||||
|
crate::stdlib::pthread_mutex_unlock(&mut (*outputbuf).mutex);
|
||||||
|
crate::stdlib::free(buf as *mut libc::c_void);
|
||||||
|
crate::src::output::output_close_common();
|
||||||
|
}
|
1015
src/pcm.rs
Normal file
1015
src/pcm.rs
Normal file
File diff suppressed because it is too large
Load Diff
2542
src/slimproto.rs
Normal file
2542
src/slimproto.rs
Normal file
File diff suppressed because it is too large
Load Diff
207
src/squeezelite_h.rs
Normal file
207
src/squeezelite_h.rs
Normal file
@ -0,0 +1,207 @@
|
|||||||
|
extern "C" {
|
||||||
|
#[no_mangle]
|
||||||
|
pub fn _buf_used(buf: *mut crate::squeezelite_h::buffer) -> libc::c_uint;
|
||||||
|
|
||||||
|
#[no_mangle]
|
||||||
|
pub fn to_gain(f: libc::c_float) -> crate::squeezelite_h::s32_t;
|
||||||
|
|
||||||
|
#[no_mangle]
|
||||||
|
pub fn gain(
|
||||||
|
gain_0: crate::squeezelite_h::s32_t,
|
||||||
|
sample: crate::squeezelite_h::s32_t,
|
||||||
|
) -> crate::squeezelite_h::s32_t;
|
||||||
|
|
||||||
|
#[no_mangle]
|
||||||
|
pub fn _apply_cross(
|
||||||
|
outputbuf_0: *mut crate::squeezelite_h::buffer,
|
||||||
|
out_frames: crate::squeezelite_h::frames_t,
|
||||||
|
cross_gain_in: crate::squeezelite_h::s32_t,
|
||||||
|
cross_gain_out: crate::squeezelite_h::s32_t,
|
||||||
|
cross_ptr: *mut *mut crate::squeezelite_h::s32_t,
|
||||||
|
);
|
||||||
|
|
||||||
|
#[no_mangle]
|
||||||
|
pub fn _apply_gain(
|
||||||
|
outputbuf_0: *mut crate::squeezelite_h::buffer,
|
||||||
|
count: crate::squeezelite_h::frames_t,
|
||||||
|
gainL: crate::squeezelite_h::s32_t,
|
||||||
|
gainR: crate::squeezelite_h::s32_t,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
// =============== BEGIN squeezelite_h ================
|
||||||
|
pub type s16_t = crate::stdlib::int16_t;
|
||||||
|
#[repr(C)]
|
||||||
|
#[derive(Copy, Clone)]
|
||||||
|
pub union C2RustUnnamed_1 {
|
||||||
|
pub pause_frames: crate::squeezelite_h::u32_t,
|
||||||
|
pub skip_frames: crate::squeezelite_h::u32_t,
|
||||||
|
pub start_at: crate::squeezelite_h::u32_t,
|
||||||
|
}
|
||||||
|
pub type u32_t = crate::stdlib::u_int32_t;
|
||||||
|
pub type u64_t = crate::stdlib::u_int64_t;
|
||||||
|
pub type s32_t = crate::stdlib::int32_t;
|
||||||
|
pub type frames_t = crate::squeezelite_h::u32_t;
|
||||||
|
pub type log_level = libc::c_uint;
|
||||||
|
pub type stream_state = libc::c_uint;
|
||||||
|
pub type disconnect_code = libc::c_uint;
|
||||||
|
#[repr(C)]
|
||||||
|
#[derive(Copy, Clone)]
|
||||||
|
pub struct streamstate {
|
||||||
|
pub state: crate::squeezelite_h::stream_state,
|
||||||
|
pub disconnect: crate::squeezelite_h::disconnect_code,
|
||||||
|
pub header: *mut libc::c_char,
|
||||||
|
pub header_len: crate::stddef_h::size_t,
|
||||||
|
pub sent_headers: bool,
|
||||||
|
pub cont_wait: bool,
|
||||||
|
pub bytes: crate::squeezelite_h::u64_t,
|
||||||
|
pub threshold: libc::c_uint,
|
||||||
|
pub meta_interval: crate::squeezelite_h::u32_t,
|
||||||
|
pub meta_next: crate::squeezelite_h::u32_t,
|
||||||
|
pub meta_left: crate::squeezelite_h::u32_t,
|
||||||
|
pub meta_send: bool,
|
||||||
|
}
|
||||||
|
pub type decode_state = libc::c_uint;
|
||||||
|
#[repr(C)]
|
||||||
|
#[derive(Copy, Clone)]
|
||||||
|
pub struct decodestate {
|
||||||
|
pub state: crate::squeezelite_h::decode_state,
|
||||||
|
pub new_stream: bool,
|
||||||
|
pub mutex: crate::stdlib::pthread_mutex_t,
|
||||||
|
}
|
||||||
|
#[repr(C)]
|
||||||
|
#[derive(Copy, Clone)]
|
||||||
|
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(
|
||||||
|
_: crate::squeezelite_h::u8_t,
|
||||||
|
_: crate::squeezelite_h::u8_t,
|
||||||
|
_: crate::squeezelite_h::u8_t,
|
||||||
|
_: crate::squeezelite_h::u8_t,
|
||||||
|
) -> (),
|
||||||
|
>,
|
||||||
|
pub close: Option<unsafe extern "C" fn() -> ()>,
|
||||||
|
pub decode: Option<unsafe extern "C" fn() -> crate::squeezelite_h::decode_state>,
|
||||||
|
}
|
||||||
|
pub type fade_mode = libc::c_uint;
|
||||||
|
#[repr(C)]
|
||||||
|
#[derive(Copy, Clone)]
|
||||||
|
pub struct outputstate {
|
||||||
|
pub state: crate::squeezelite_h::output_state,
|
||||||
|
pub format: crate::squeezelite_h::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(
|
||||||
|
_: crate::squeezelite_h::frames_t,
|
||||||
|
_: bool,
|
||||||
|
_: crate::squeezelite_h::s32_t,
|
||||||
|
_: crate::squeezelite_h::s32_t,
|
||||||
|
_: crate::squeezelite_h::s32_t,
|
||||||
|
_: crate::squeezelite_h::s32_t,
|
||||||
|
_: *mut *mut crate::squeezelite_h::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: crate::squeezelite_h::u32_t,
|
||||||
|
pub track_start_time: crate::squeezelite_h::u32_t,
|
||||||
|
pub current_replay_gain: crate::squeezelite_h::u32_t,
|
||||||
|
pub c2rust_unnamed: crate::squeezelite_h::C2RustUnnamed_1,
|
||||||
|
pub next_sample_rate: libc::c_uint,
|
||||||
|
pub track_start: *mut crate::squeezelite_h::u8_t,
|
||||||
|
pub gainL: crate::squeezelite_h::u32_t,
|
||||||
|
pub gainR: crate::squeezelite_h::u32_t,
|
||||||
|
pub invert: bool,
|
||||||
|
pub next_replay_gain: crate::squeezelite_h::u32_t,
|
||||||
|
pub threshold: libc::c_uint,
|
||||||
|
pub fade: crate::squeezelite_h::fade_state,
|
||||||
|
pub fade_start: *mut crate::squeezelite_h::u8_t,
|
||||||
|
pub fade_end: *mut crate::squeezelite_h::u8_t,
|
||||||
|
pub fade_dir: crate::squeezelite_h::fade_dir,
|
||||||
|
pub fade_mode: crate::squeezelite_h::fade_mode,
|
||||||
|
pub fade_secs: libc::c_uint,
|
||||||
|
pub rate_delay: libc::c_uint,
|
||||||
|
pub delay_active: bool,
|
||||||
|
pub stop_time: crate::squeezelite_h::u32_t,
|
||||||
|
pub idle_to: crate::squeezelite_h::u32_t,
|
||||||
|
}
|
||||||
|
pub type fade_dir = libc::c_uint;
|
||||||
|
pub type fade_state = libc::c_uint;
|
||||||
|
pub type output_format = libc::c_uint;
|
||||||
|
pub type output_state = libc::c_int;
|
||||||
|
pub type s64_t = crate::stdlib::int64_t;
|
||||||
|
pub const lSDEBUG: crate::squeezelite_h::log_level = 4;
|
||||||
|
pub const lDEBUG: crate::squeezelite_h::log_level = 3;
|
||||||
|
pub const lINFO: crate::squeezelite_h::log_level = 2;
|
||||||
|
pub const lWARN: crate::squeezelite_h::log_level = 1;
|
||||||
|
pub const lERROR: crate::squeezelite_h::log_level = 0;
|
||||||
|
pub const RECV_HEADERS: crate::squeezelite_h::stream_state = 7;
|
||||||
|
pub const SEND_HEADERS: crate::squeezelite_h::stream_state = 6;
|
||||||
|
pub const STREAMING_HTTP: crate::squeezelite_h::stream_state = 5;
|
||||||
|
pub const STREAMING_FILE: crate::squeezelite_h::stream_state = 4;
|
||||||
|
pub const STREAMING_BUFFERING: crate::squeezelite_h::stream_state = 3;
|
||||||
|
pub const STREAMING_WAIT: crate::squeezelite_h::stream_state = 2;
|
||||||
|
pub const DISCONNECT: crate::squeezelite_h::stream_state = 1;
|
||||||
|
pub const STOPPED: crate::squeezelite_h::stream_state = 0;
|
||||||
|
pub const TIMEOUT: crate::squeezelite_h::disconnect_code = 4;
|
||||||
|
pub const UNREACHABLE: crate::squeezelite_h::disconnect_code = 3;
|
||||||
|
pub const REMOTE_DISCONNECT: crate::squeezelite_h::disconnect_code = 2;
|
||||||
|
pub const LOCAL_DISCONNECT: crate::squeezelite_h::disconnect_code = 1;
|
||||||
|
pub const DISCONNECT_OK: crate::squeezelite_h::disconnect_code = 0;
|
||||||
|
pub const DECODE_ERROR: crate::squeezelite_h::decode_state = 4;
|
||||||
|
pub const DECODE_COMPLETE: crate::squeezelite_h::decode_state = 3;
|
||||||
|
pub const DECODE_RUNNING: crate::squeezelite_h::decode_state = 2;
|
||||||
|
pub const DECODE_READY: crate::squeezelite_h::decode_state = 1;
|
||||||
|
pub const DECODE_STOPPED: crate::squeezelite_h::decode_state = 0;
|
||||||
|
pub const FADE_INOUT: crate::squeezelite_h::fade_mode = 4;
|
||||||
|
pub const FADE_OUT: crate::squeezelite_h::fade_mode = 3;
|
||||||
|
pub const FADE_IN: crate::squeezelite_h::fade_mode = 2;
|
||||||
|
pub const FADE_CROSSFADE: crate::squeezelite_h::fade_mode = 1;
|
||||||
|
pub const FADE_NONE: crate::squeezelite_h::fade_mode = 0;
|
||||||
|
pub const FADE_CROSS: crate::squeezelite_h::fade_dir = 3;
|
||||||
|
pub const FADE_DOWN: crate::squeezelite_h::fade_dir = 2;
|
||||||
|
pub const FADE_UP: crate::squeezelite_h::fade_dir = 1;
|
||||||
|
pub const FADE_ACTIVE: crate::squeezelite_h::fade_state = 2;
|
||||||
|
pub const FADE_DUE: crate::squeezelite_h::fade_state = 1;
|
||||||
|
pub const FADE_INACTIVE: crate::squeezelite_h::fade_state = 0;
|
||||||
|
pub const S16_LE: crate::squeezelite_h::output_format = 3;
|
||||||
|
pub const S24_3LE: crate::squeezelite_h::output_format = 2;
|
||||||
|
pub const S24_LE: crate::squeezelite_h::output_format = 1;
|
||||||
|
pub const S32_LE: crate::squeezelite_h::output_format = 0;
|
||||||
|
pub const OUTPUT_START_AT: crate::squeezelite_h::output_state = 5;
|
||||||
|
pub const OUTPUT_SKIP_FRAMES: crate::squeezelite_h::output_state = 4;
|
||||||
|
pub const OUTPUT_PAUSE_FRAMES: crate::squeezelite_h::output_state = 3;
|
||||||
|
pub const OUTPUT_RUNNING: crate::squeezelite_h::output_state = 2;
|
||||||
|
pub const OUTPUT_BUFFER: crate::squeezelite_h::output_state = 1;
|
||||||
|
pub const OUTPUT_STOPPED: crate::squeezelite_h::output_state = 0;
|
||||||
|
pub const OUTPUT_OFF: crate::squeezelite_h::output_state = -1;
|
||||||
|
pub type u16_t = crate::stdlib::u_int16_t;
|
||||||
|
pub type sockfd = libc::c_int;
|
||||||
|
pub type event_type = libc::c_uint;
|
||||||
|
pub const EVENT_WAKE: crate::squeezelite_h::event_type = 2;
|
||||||
|
pub const EVENT_READ: crate::squeezelite_h::event_type = 1;
|
||||||
|
pub const EVENT_TIMEOUT: crate::squeezelite_h::event_type = 0;
|
||||||
|
pub type u8_t = crate::stdlib::u_int8_t;
|
||||||
|
#[repr(C)]
|
||||||
|
#[derive(Copy, Clone)]
|
||||||
|
pub struct buffer {
|
||||||
|
pub buf: *mut crate::squeezelite_h::u8_t,
|
||||||
|
pub readp: *mut crate::squeezelite_h::u8_t,
|
||||||
|
pub writep: *mut crate::squeezelite_h::u8_t,
|
||||||
|
pub wrap: *mut crate::squeezelite_h::u8_t,
|
||||||
|
pub size: crate::stddef_h::size_t,
|
||||||
|
pub base_size: crate::stddef_h::size_t,
|
||||||
|
pub mutex: crate::stdlib::pthread_mutex_t,
|
||||||
|
}
|
1
src/stdarg_h.rs
Normal file
1
src/stdarg_h.rs
Normal file
@ -0,0 +1 @@
|
|||||||
|
pub type va_list = crate::internal::__builtin_va_list;
|
1
src/stddef_h.rs
Normal file
1
src/stddef_h.rs
Normal file
@ -0,0 +1 @@
|
|||||||
|
pub type size_t = libc::c_ulong;
|
2259
src/stdlib.rs
Normal file
2259
src/stdlib.rs
Normal file
File diff suppressed because it is too large
Load Diff
1128
src/stream.rs
Normal file
1128
src/stream.rs
Normal file
File diff suppressed because it is too large
Load Diff
817
src/utils.rs
Normal file
817
src/utils.rs
Normal file
@ -0,0 +1,817 @@
|
|||||||
|
use ::c2rust_asm_casts;
|
||||||
|
use ::libc;
|
||||||
|
|
||||||
|
pub use crate::internal::__builtin_va_list;
|
||||||
|
pub use crate::internal::__va_list_tag;
|
||||||
|
pub use crate::stdarg_h::va_list;
|
||||||
|
pub use crate::stddef_h::size_t;
|
||||||
|
use c2rust_asm_casts::AsmCastTrait;
|
||||||
|
|
||||||
|
pub use crate::stdlib::_IO_codecvt;
|
||||||
|
pub use crate::stdlib::_IO_lock_t;
|
||||||
|
pub use crate::stdlib::_IO_marker;
|
||||||
|
pub use crate::stdlib::_IO_wide_data;
|
||||||
|
pub use crate::stdlib::__caddr_t;
|
||||||
|
pub use crate::stdlib::__clockid_t;
|
||||||
|
pub use crate::stdlib::__off64_t;
|
||||||
|
pub use crate::stdlib::__off_t;
|
||||||
|
pub use crate::stdlib::__socklen_t;
|
||||||
|
pub use crate::stdlib::__suseconds_t;
|
||||||
|
pub use crate::stdlib::__syscall_slong_t;
|
||||||
|
pub use crate::stdlib::__time_t;
|
||||||
|
pub use crate::stdlib::__uint16_t;
|
||||||
|
pub use crate::stdlib::__uint32_t;
|
||||||
|
pub use crate::stdlib::__uint64_t;
|
||||||
|
pub use crate::stdlib::__uint8_t;
|
||||||
|
pub use crate::stdlib::clockid_t;
|
||||||
|
pub use crate::stdlib::time_t;
|
||||||
|
pub use crate::stdlib::timespec;
|
||||||
|
pub use crate::stdlib::timeval;
|
||||||
|
pub use crate::stdlib::u_int16_t;
|
||||||
|
pub use crate::stdlib::u_int32_t;
|
||||||
|
pub use crate::stdlib::u_int8_t;
|
||||||
|
pub use crate::stdlib::FILE;
|
||||||
|
pub use crate::stdlib::_IO_FILE;
|
||||||
|
|
||||||
|
pub use crate::stdlib::__fd_mask;
|
||||||
|
pub use crate::stdlib::__socket_type;
|
||||||
|
pub use crate::stdlib::close;
|
||||||
|
pub use crate::stdlib::fd_set;
|
||||||
|
pub use crate::stdlib::sa_family_t;
|
||||||
|
pub use crate::stdlib::select;
|
||||||
|
pub use crate::stdlib::sockaddr;
|
||||||
|
pub use crate::stdlib::socklen_t;
|
||||||
|
pub use crate::stdlib::sysconf;
|
||||||
|
pub use crate::stdlib::uint16_t;
|
||||||
|
pub use crate::stdlib::uint32_t;
|
||||||
|
pub use crate::stdlib::uint64_t;
|
||||||
|
pub use crate::stdlib::C2RustUnnamed_0;
|
||||||
|
pub use crate::stdlib::SOCK_CLOEXEC;
|
||||||
|
pub use crate::stdlib::SOCK_DCCP;
|
||||||
|
pub use crate::stdlib::SOCK_DGRAM;
|
||||||
|
pub use crate::stdlib::SOCK_NONBLOCK;
|
||||||
|
pub use crate::stdlib::SOCK_PACKET;
|
||||||
|
pub use crate::stdlib::SOCK_RAW;
|
||||||
|
pub use crate::stdlib::SOCK_RDM;
|
||||||
|
pub use crate::stdlib::SOCK_SEQPACKET;
|
||||||
|
pub use crate::stdlib::SOCK_STREAM;
|
||||||
|
pub use crate::stdlib::_SC_2_CHAR_TERM;
|
||||||
|
pub use crate::stdlib::_SC_2_C_BIND;
|
||||||
|
pub use crate::stdlib::_SC_2_C_DEV;
|
||||||
|
pub use crate::stdlib::_SC_2_C_VERSION;
|
||||||
|
pub use crate::stdlib::_SC_2_FORT_DEV;
|
||||||
|
pub use crate::stdlib::_SC_2_FORT_RUN;
|
||||||
|
pub use crate::stdlib::_SC_2_LOCALEDEF;
|
||||||
|
pub use crate::stdlib::_SC_2_PBS;
|
||||||
|
pub use crate::stdlib::_SC_2_PBS_ACCOUNTING;
|
||||||
|
pub use crate::stdlib::_SC_2_PBS_CHECKPOINT;
|
||||||
|
pub use crate::stdlib::_SC_2_PBS_LOCATE;
|
||||||
|
pub use crate::stdlib::_SC_2_PBS_MESSAGE;
|
||||||
|
pub use crate::stdlib::_SC_2_PBS_TRACK;
|
||||||
|
pub use crate::stdlib::_SC_2_SW_DEV;
|
||||||
|
pub use crate::stdlib::_SC_2_UPE;
|
||||||
|
pub use crate::stdlib::_SC_2_VERSION;
|
||||||
|
pub use crate::stdlib::_SC_ADVISORY_INFO;
|
||||||
|
pub use crate::stdlib::_SC_AIO_LISTIO_MAX;
|
||||||
|
pub use crate::stdlib::_SC_AIO_MAX;
|
||||||
|
pub use crate::stdlib::_SC_AIO_PRIO_DELTA_MAX;
|
||||||
|
pub use crate::stdlib::_SC_ARG_MAX;
|
||||||
|
pub use crate::stdlib::_SC_ASYNCHRONOUS_IO;
|
||||||
|
pub use crate::stdlib::_SC_ATEXIT_MAX;
|
||||||
|
pub use crate::stdlib::_SC_AVPHYS_PAGES;
|
||||||
|
pub use crate::stdlib::_SC_BARRIERS;
|
||||||
|
pub use crate::stdlib::_SC_BASE;
|
||||||
|
pub use crate::stdlib::_SC_BC_BASE_MAX;
|
||||||
|
pub use crate::stdlib::_SC_BC_DIM_MAX;
|
||||||
|
pub use crate::stdlib::_SC_BC_SCALE_MAX;
|
||||||
|
pub use crate::stdlib::_SC_BC_STRING_MAX;
|
||||||
|
pub use crate::stdlib::_SC_CHARCLASS_NAME_MAX;
|
||||||
|
pub use crate::stdlib::_SC_CHAR_BIT;
|
||||||
|
pub use crate::stdlib::_SC_CHAR_MAX;
|
||||||
|
pub use crate::stdlib::_SC_CHAR_MIN;
|
||||||
|
pub use crate::stdlib::_SC_CHILD_MAX;
|
||||||
|
pub use crate::stdlib::_SC_CLK_TCK;
|
||||||
|
pub use crate::stdlib::_SC_CLOCK_SELECTION;
|
||||||
|
pub use crate::stdlib::_SC_COLL_WEIGHTS_MAX;
|
||||||
|
pub use crate::stdlib::_SC_CPUTIME;
|
||||||
|
pub use crate::stdlib::_SC_C_LANG_SUPPORT;
|
||||||
|
pub use crate::stdlib::_SC_C_LANG_SUPPORT_R;
|
||||||
|
pub use crate::stdlib::_SC_DELAYTIMER_MAX;
|
||||||
|
pub use crate::stdlib::_SC_DEVICE_IO;
|
||||||
|
pub use crate::stdlib::_SC_DEVICE_SPECIFIC;
|
||||||
|
pub use crate::stdlib::_SC_DEVICE_SPECIFIC_R;
|
||||||
|
pub use crate::stdlib::_SC_EQUIV_CLASS_MAX;
|
||||||
|
pub use crate::stdlib::_SC_EXPR_NEST_MAX;
|
||||||
|
pub use crate::stdlib::_SC_FD_MGMT;
|
||||||
|
pub use crate::stdlib::_SC_FIFO;
|
||||||
|
pub use crate::stdlib::_SC_FILE_ATTRIBUTES;
|
||||||
|
pub use crate::stdlib::_SC_FILE_LOCKING;
|
||||||
|
pub use crate::stdlib::_SC_FILE_SYSTEM;
|
||||||
|
pub use crate::stdlib::_SC_FSYNC;
|
||||||
|
pub use crate::stdlib::_SC_GETGR_R_SIZE_MAX;
|
||||||
|
pub use crate::stdlib::_SC_GETPW_R_SIZE_MAX;
|
||||||
|
pub use crate::stdlib::_SC_HOST_NAME_MAX;
|
||||||
|
pub use crate::stdlib::_SC_INT_MAX;
|
||||||
|
pub use crate::stdlib::_SC_INT_MIN;
|
||||||
|
pub use crate::stdlib::_SC_IOV_MAX;
|
||||||
|
pub use crate::stdlib::_SC_IPV6;
|
||||||
|
pub use crate::stdlib::_SC_JOB_CONTROL;
|
||||||
|
pub use crate::stdlib::_SC_LEVEL1_DCACHE_ASSOC;
|
||||||
|
pub use crate::stdlib::_SC_LEVEL1_DCACHE_LINESIZE;
|
||||||
|
pub use crate::stdlib::_SC_LEVEL1_DCACHE_SIZE;
|
||||||
|
pub use crate::stdlib::_SC_LEVEL1_ICACHE_ASSOC;
|
||||||
|
pub use crate::stdlib::_SC_LEVEL1_ICACHE_LINESIZE;
|
||||||
|
pub use crate::stdlib::_SC_LEVEL1_ICACHE_SIZE;
|
||||||
|
pub use crate::stdlib::_SC_LEVEL2_CACHE_ASSOC;
|
||||||
|
pub use crate::stdlib::_SC_LEVEL2_CACHE_LINESIZE;
|
||||||
|
pub use crate::stdlib::_SC_LEVEL2_CACHE_SIZE;
|
||||||
|
pub use crate::stdlib::_SC_LEVEL3_CACHE_ASSOC;
|
||||||
|
pub use crate::stdlib::_SC_LEVEL3_CACHE_LINESIZE;
|
||||||
|
pub use crate::stdlib::_SC_LEVEL3_CACHE_SIZE;
|
||||||
|
pub use crate::stdlib::_SC_LEVEL4_CACHE_ASSOC;
|
||||||
|
pub use crate::stdlib::_SC_LEVEL4_CACHE_LINESIZE;
|
||||||
|
pub use crate::stdlib::_SC_LEVEL4_CACHE_SIZE;
|
||||||
|
pub use crate::stdlib::_SC_LINE_MAX;
|
||||||
|
pub use crate::stdlib::_SC_LOGIN_NAME_MAX;
|
||||||
|
pub use crate::stdlib::_SC_LONG_BIT;
|
||||||
|
pub use crate::stdlib::_SC_MAPPED_FILES;
|
||||||
|
pub use crate::stdlib::_SC_MB_LEN_MAX;
|
||||||
|
pub use crate::stdlib::_SC_MEMLOCK;
|
||||||
|
pub use crate::stdlib::_SC_MEMLOCK_RANGE;
|
||||||
|
pub use crate::stdlib::_SC_MEMORY_PROTECTION;
|
||||||
|
pub use crate::stdlib::_SC_MESSAGE_PASSING;
|
||||||
|
pub use crate::stdlib::_SC_MONOTONIC_CLOCK;
|
||||||
|
pub use crate::stdlib::_SC_MQ_OPEN_MAX;
|
||||||
|
pub use crate::stdlib::_SC_MQ_PRIO_MAX;
|
||||||
|
pub use crate::stdlib::_SC_MULTI_PROCESS;
|
||||||
|
pub use crate::stdlib::_SC_NETWORKING;
|
||||||
|
pub use crate::stdlib::_SC_NGROUPS_MAX;
|
||||||
|
pub use crate::stdlib::_SC_NL_ARGMAX;
|
||||||
|
pub use crate::stdlib::_SC_NL_LANGMAX;
|
||||||
|
pub use crate::stdlib::_SC_NL_MSGMAX;
|
||||||
|
pub use crate::stdlib::_SC_NL_NMAX;
|
||||||
|
pub use crate::stdlib::_SC_NL_SETMAX;
|
||||||
|
pub use crate::stdlib::_SC_NL_TEXTMAX;
|
||||||
|
pub use crate::stdlib::_SC_NPROCESSORS_CONF;
|
||||||
|
pub use crate::stdlib::_SC_NPROCESSORS_ONLN;
|
||||||
|
pub use crate::stdlib::_SC_NZERO;
|
||||||
|
pub use crate::stdlib::_SC_OPEN_MAX;
|
||||||
|
pub use crate::stdlib::_SC_PAGESIZE;
|
||||||
|
pub use crate::stdlib::_SC_PASS_MAX;
|
||||||
|
pub use crate::stdlib::_SC_PHYS_PAGES;
|
||||||
|
pub use crate::stdlib::_SC_PII;
|
||||||
|
pub use crate::stdlib::_SC_PII_INTERNET;
|
||||||
|
pub use crate::stdlib::_SC_PII_INTERNET_DGRAM;
|
||||||
|
pub use crate::stdlib::_SC_PII_INTERNET_STREAM;
|
||||||
|
pub use crate::stdlib::_SC_PII_OSI;
|
||||||
|
pub use crate::stdlib::_SC_PII_OSI_CLTS;
|
||||||
|
pub use crate::stdlib::_SC_PII_OSI_COTS;
|
||||||
|
pub use crate::stdlib::_SC_PII_OSI_M;
|
||||||
|
pub use crate::stdlib::_SC_PII_SOCKET;
|
||||||
|
pub use crate::stdlib::_SC_PII_XTI;
|
||||||
|
pub use crate::stdlib::_SC_PIPE;
|
||||||
|
pub use crate::stdlib::_SC_POLL;
|
||||||
|
pub use crate::stdlib::_SC_PRIORITIZED_IO;
|
||||||
|
pub use crate::stdlib::_SC_PRIORITY_SCHEDULING;
|
||||||
|
pub use crate::stdlib::_SC_RAW_SOCKETS;
|
||||||
|
pub use crate::stdlib::_SC_READER_WRITER_LOCKS;
|
||||||
|
pub use crate::stdlib::_SC_REALTIME_SIGNALS;
|
||||||
|
pub use crate::stdlib::_SC_REGEXP;
|
||||||
|
pub use crate::stdlib::_SC_REGEX_VERSION;
|
||||||
|
pub use crate::stdlib::_SC_RE_DUP_MAX;
|
||||||
|
pub use crate::stdlib::_SC_RTSIG_MAX;
|
||||||
|
pub use crate::stdlib::_SC_SAVED_IDS;
|
||||||
|
pub use crate::stdlib::_SC_SCHAR_MAX;
|
||||||
|
pub use crate::stdlib::_SC_SCHAR_MIN;
|
||||||
|
pub use crate::stdlib::_SC_SELECT;
|
||||||
|
pub use crate::stdlib::_SC_SEMAPHORES;
|
||||||
|
pub use crate::stdlib::_SC_SEM_NSEMS_MAX;
|
||||||
|
pub use crate::stdlib::_SC_SEM_VALUE_MAX;
|
||||||
|
pub use crate::stdlib::_SC_SHARED_MEMORY_OBJECTS;
|
||||||
|
pub use crate::stdlib::_SC_SHELL;
|
||||||
|
pub use crate::stdlib::_SC_SHRT_MAX;
|
||||||
|
pub use crate::stdlib::_SC_SHRT_MIN;
|
||||||
|
pub use crate::stdlib::_SC_SIGNALS;
|
||||||
|
pub use crate::stdlib::_SC_SIGQUEUE_MAX;
|
||||||
|
pub use crate::stdlib::_SC_SINGLE_PROCESS;
|
||||||
|
pub use crate::stdlib::_SC_SPAWN;
|
||||||
|
pub use crate::stdlib::_SC_SPIN_LOCKS;
|
||||||
|
pub use crate::stdlib::_SC_SPORADIC_SERVER;
|
||||||
|
pub use crate::stdlib::_SC_SSIZE_MAX;
|
||||||
|
pub use crate::stdlib::_SC_SS_REPL_MAX;
|
||||||
|
pub use crate::stdlib::_SC_STREAMS;
|
||||||
|
pub use crate::stdlib::_SC_STREAM_MAX;
|
||||||
|
pub use crate::stdlib::_SC_SYMLOOP_MAX;
|
||||||
|
pub use crate::stdlib::_SC_SYNCHRONIZED_IO;
|
||||||
|
pub use crate::stdlib::_SC_SYSTEM_DATABASE;
|
||||||
|
pub use crate::stdlib::_SC_SYSTEM_DATABASE_R;
|
||||||
|
pub use crate::stdlib::_SC_THREADS;
|
||||||
|
pub use crate::stdlib::_SC_THREAD_ATTR_STACKADDR;
|
||||||
|
pub use crate::stdlib::_SC_THREAD_ATTR_STACKSIZE;
|
||||||
|
pub use crate::stdlib::_SC_THREAD_CPUTIME;
|
||||||
|
pub use crate::stdlib::_SC_THREAD_DESTRUCTOR_ITERATIONS;
|
||||||
|
pub use crate::stdlib::_SC_THREAD_KEYS_MAX;
|
||||||
|
pub use crate::stdlib::_SC_THREAD_PRIORITY_SCHEDULING;
|
||||||
|
pub use crate::stdlib::_SC_THREAD_PRIO_INHERIT;
|
||||||
|
pub use crate::stdlib::_SC_THREAD_PRIO_PROTECT;
|
||||||
|
pub use crate::stdlib::_SC_THREAD_PROCESS_SHARED;
|
||||||
|
pub use crate::stdlib::_SC_THREAD_ROBUST_PRIO_INHERIT;
|
||||||
|
pub use crate::stdlib::_SC_THREAD_ROBUST_PRIO_PROTECT;
|
||||||
|
pub use crate::stdlib::_SC_THREAD_SAFE_FUNCTIONS;
|
||||||
|
pub use crate::stdlib::_SC_THREAD_SPORADIC_SERVER;
|
||||||
|
pub use crate::stdlib::_SC_THREAD_STACK_MIN;
|
||||||
|
pub use crate::stdlib::_SC_THREAD_THREADS_MAX;
|
||||||
|
pub use crate::stdlib::_SC_TIMEOUTS;
|
||||||
|
pub use crate::stdlib::_SC_TIMERS;
|
||||||
|
pub use crate::stdlib::_SC_TIMER_MAX;
|
||||||
|
pub use crate::stdlib::_SC_TRACE;
|
||||||
|
pub use crate::stdlib::_SC_TRACE_EVENT_FILTER;
|
||||||
|
pub use crate::stdlib::_SC_TRACE_EVENT_NAME_MAX;
|
||||||
|
pub use crate::stdlib::_SC_TRACE_INHERIT;
|
||||||
|
pub use crate::stdlib::_SC_TRACE_LOG;
|
||||||
|
pub use crate::stdlib::_SC_TRACE_NAME_MAX;
|
||||||
|
pub use crate::stdlib::_SC_TRACE_SYS_MAX;
|
||||||
|
pub use crate::stdlib::_SC_TRACE_USER_EVENT_MAX;
|
||||||
|
pub use crate::stdlib::_SC_TTY_NAME_MAX;
|
||||||
|
pub use crate::stdlib::_SC_TYPED_MEMORY_OBJECTS;
|
||||||
|
pub use crate::stdlib::_SC_TZNAME_MAX;
|
||||||
|
pub use crate::stdlib::_SC_T_IOV_MAX;
|
||||||
|
pub use crate::stdlib::_SC_UCHAR_MAX;
|
||||||
|
pub use crate::stdlib::_SC_UINT_MAX;
|
||||||
|
pub use crate::stdlib::_SC_UIO_MAXIOV;
|
||||||
|
pub use crate::stdlib::_SC_ULONG_MAX;
|
||||||
|
pub use crate::stdlib::_SC_USER_GROUPS;
|
||||||
|
pub use crate::stdlib::_SC_USER_GROUPS_R;
|
||||||
|
pub use crate::stdlib::_SC_USHRT_MAX;
|
||||||
|
pub use crate::stdlib::_SC_V6_ILP32_OFF32;
|
||||||
|
pub use crate::stdlib::_SC_V6_ILP32_OFFBIG;
|
||||||
|
pub use crate::stdlib::_SC_V6_LP64_OFF64;
|
||||||
|
pub use crate::stdlib::_SC_V6_LPBIG_OFFBIG;
|
||||||
|
pub use crate::stdlib::_SC_V7_ILP32_OFF32;
|
||||||
|
pub use crate::stdlib::_SC_V7_ILP32_OFFBIG;
|
||||||
|
pub use crate::stdlib::_SC_V7_LP64_OFF64;
|
||||||
|
pub use crate::stdlib::_SC_V7_LPBIG_OFFBIG;
|
||||||
|
pub use crate::stdlib::_SC_VERSION;
|
||||||
|
pub use crate::stdlib::_SC_WORD_BIT;
|
||||||
|
pub use crate::stdlib::_SC_XBS5_ILP32_OFF32;
|
||||||
|
pub use crate::stdlib::_SC_XBS5_ILP32_OFFBIG;
|
||||||
|
pub use crate::stdlib::_SC_XBS5_LP64_OFF64;
|
||||||
|
pub use crate::stdlib::_SC_XBS5_LPBIG_OFFBIG;
|
||||||
|
pub use crate::stdlib::_SC_XOPEN_CRYPT;
|
||||||
|
pub use crate::stdlib::_SC_XOPEN_ENH_I18N;
|
||||||
|
pub use crate::stdlib::_SC_XOPEN_LEGACY;
|
||||||
|
pub use crate::stdlib::_SC_XOPEN_REALTIME;
|
||||||
|
pub use crate::stdlib::_SC_XOPEN_REALTIME_THREADS;
|
||||||
|
pub use crate::stdlib::_SC_XOPEN_SHM;
|
||||||
|
pub use crate::stdlib::_SC_XOPEN_STREAMS;
|
||||||
|
pub use crate::stdlib::_SC_XOPEN_UNIX;
|
||||||
|
pub use crate::stdlib::_SC_XOPEN_VERSION;
|
||||||
|
pub use crate::stdlib::_SC_XOPEN_XCU_VERSION;
|
||||||
|
pub use crate::stdlib::_SC_XOPEN_XPG2;
|
||||||
|
pub use crate::stdlib::_SC_XOPEN_XPG3;
|
||||||
|
pub use crate::stdlib::_SC_XOPEN_XPG4;
|
||||||
|
|
||||||
|
pub use crate::stdlib::__timezone_ptr_t;
|
||||||
|
pub use crate::stdlib::gettimeofday;
|
||||||
|
pub use crate::stdlib::in_addr;
|
||||||
|
pub use crate::stdlib::in_addr_t;
|
||||||
|
pub use crate::stdlib::in_port_t;
|
||||||
|
pub use crate::stdlib::nfds_t;
|
||||||
|
pub use crate::stdlib::poll;
|
||||||
|
pub use crate::stdlib::pollfd;
|
||||||
|
pub use crate::stdlib::sockaddr_in;
|
||||||
|
pub use crate::stdlib::timezone;
|
||||||
|
pub use crate::stdlib::tm;
|
||||||
|
|
||||||
|
pub use crate::squeezelite_h::event_type;
|
||||||
|
pub use crate::squeezelite_h::sockfd;
|
||||||
|
pub use crate::squeezelite_h::u16_t;
|
||||||
|
pub use crate::squeezelite_h::u32_t;
|
||||||
|
pub use crate::squeezelite_h::u8_t;
|
||||||
|
pub use crate::squeezelite_h::EVENT_READ;
|
||||||
|
pub use crate::squeezelite_h::EVENT_TIMEOUT;
|
||||||
|
pub use crate::squeezelite_h::EVENT_WAKE;
|
||||||
|
use crate::stdlib::__errno_location;
|
||||||
|
pub use crate::stdlib::addrinfo;
|
||||||
|
use crate::stdlib::atoi;
|
||||||
|
pub use crate::stdlib::eventfd_read;
|
||||||
|
pub use crate::stdlib::eventfd_t;
|
||||||
|
use crate::stdlib::fflush;
|
||||||
|
pub use crate::stdlib::freeaddrinfo;
|
||||||
|
pub use crate::stdlib::getaddrinfo;
|
||||||
|
use crate::stdlib::getenv;
|
||||||
|
pub use crate::stdlib::ifconf;
|
||||||
|
pub use crate::stdlib::ifmap;
|
||||||
|
pub use crate::stdlib::ifreq;
|
||||||
|
use crate::stdlib::memcpy;
|
||||||
|
use crate::stdlib::memset;
|
||||||
|
use crate::stdlib::sprintf;
|
||||||
|
use crate::stdlib::sscanf;
|
||||||
|
use crate::stdlib::stderr;
|
||||||
|
use crate::stdlib::strchr;
|
||||||
|
use crate::stdlib::strlen;
|
||||||
|
use crate::stdlib::strncpy;
|
||||||
|
use crate::stdlib::strtok;
|
||||||
|
use crate::stdlib::vfprintf;
|
||||||
|
pub use crate::stdlib::C2RustUnnamed_20;
|
||||||
|
pub use crate::stdlib::C2RustUnnamed_21;
|
||||||
|
pub use crate::stdlib::C2RustUnnamed_22;
|
||||||
|
|
||||||
|
use crate::stdlib::clock_gettime;
|
||||||
|
use crate::stdlib::connect;
|
||||||
|
use crate::stdlib::fcntl;
|
||||||
|
use crate::stdlib::getsockopt;
|
||||||
|
use crate::stdlib::ioctl;
|
||||||
|
use crate::stdlib::localtime;
|
||||||
|
use crate::stdlib::socket;
|
||||||
|
use crate::stdlib::strftime;
|
||||||
|
/*
|
||||||
|
* 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 = crate::stdlib::timeval {
|
||||||
|
tv_sec: 0,
|
||||||
|
tv_usec: 0,
|
||||||
|
};
|
||||||
|
crate::stdlib::gettimeofday(&mut tv, 0 as *mut crate::stdlib::timezone);
|
||||||
|
crate::stdlib::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,
|
||||||
|
crate::stdlib::localtime(&mut tv.tv_sec),
|
||||||
|
);
|
||||||
|
crate::stdlib::sprintf(
|
||||||
|
buf.as_mut_ptr()
|
||||||
|
.offset(crate::stdlib::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();
|
||||||
|
crate::stdlib::vfprintf(crate::stdlib::stderr, fmt, args_0.as_va_list());
|
||||||
|
crate::stdlib::fflush(crate::stdlib::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 = 0 as *mut libc::c_char;
|
||||||
|
let mut ret = 0 as *mut libc::c_char;
|
||||||
|
if !src.is_null() {
|
||||||
|
str = src
|
||||||
|
}
|
||||||
|
if !str.is_null() && {
|
||||||
|
ptr = crate::stdlib::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() -> crate::squeezelite_h::u32_t {
|
||||||
|
let mut ts = crate::stdlib::timespec {
|
||||||
|
tv_sec: 0,
|
||||||
|
tv_nsec: 0,
|
||||||
|
};
|
||||||
|
if crate::stdlib::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 crate::squeezelite_h::u32_t;
|
||||||
|
}
|
||||||
|
let mut tv = crate::stdlib::timeval {
|
||||||
|
tv_sec: 0,
|
||||||
|
tv_usec: 0,
|
||||||
|
};
|
||||||
|
crate::stdlib::gettimeofday(&mut tv, 0 as *mut crate::stdlib::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 crate::squeezelite_h::u32_t;
|
||||||
|
}
|
||||||
|
// mac address
|
||||||
|
// search first 4 interfaces returned by IFCONF
|
||||||
|
#[no_mangle]
|
||||||
|
|
||||||
|
pub unsafe extern "C" fn get_mac(mut mac: *mut crate::squeezelite_h::u8_t) {
|
||||||
|
let mut utmac = 0 as *mut libc::c_char;
|
||||||
|
let mut ifc = crate::stdlib::ifconf {
|
||||||
|
ifc_len: 0,
|
||||||
|
ifc_ifcu: crate::stdlib::C2RustUnnamed_22 {
|
||||||
|
ifcu_buf: 0 as *mut libc::c_char,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
let mut ifr = 0 as *mut crate::stdlib::ifreq;
|
||||||
|
let mut ifend = 0 as *mut crate::stdlib::ifreq;
|
||||||
|
let mut ifreq = crate::stdlib::ifreq {
|
||||||
|
ifr_ifrn: crate::stdlib::C2RustUnnamed_21 { ifrn_name: [0; 16] },
|
||||||
|
ifr_ifru: crate::stdlib::C2RustUnnamed_20 {
|
||||||
|
ifru_addr: crate::stdlib::sockaddr {
|
||||||
|
sa_family: 0,
|
||||||
|
sa_data: [0; 14],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
let mut ifs: [crate::stdlib::ifreq; 4] = [crate::stdlib::ifreq {
|
||||||
|
ifr_ifrn: crate::stdlib::C2RustUnnamed_21 { ifrn_name: [0; 16] },
|
||||||
|
ifr_ifru: crate::stdlib::C2RustUnnamed_20 {
|
||||||
|
ifru_addr: crate::stdlib::sockaddr {
|
||||||
|
sa_family: 0,
|
||||||
|
sa_data: [0; 14],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}; 4];
|
||||||
|
utmac = crate::stdlib::getenv(b"UTMAC\x00" as *const u8 as *const libc::c_char);
|
||||||
|
if !utmac.is_null() {
|
||||||
|
if crate::stdlib::strlen(utmac) == 17 as libc::c_int as libc::c_ulong {
|
||||||
|
if crate::stdlib::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 crate::squeezelite_h::u8_t,
|
||||||
|
&mut *mac.offset(1 as libc::c_int as isize) as *mut crate::squeezelite_h::u8_t,
|
||||||
|
&mut *mac.offset(2 as libc::c_int as isize) as *mut crate::squeezelite_h::u8_t,
|
||||||
|
&mut *mac.offset(3 as libc::c_int as isize) as *mut crate::squeezelite_h::u8_t,
|
||||||
|
&mut *mac.offset(4 as libc::c_int as isize) as *mut crate::squeezelite_h::u8_t,
|
||||||
|
&mut *mac.offset(5 as libc::c_int as isize) as *mut crate::squeezelite_h::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 crate::squeezelite_h::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 = crate::stdlib::socket(
|
||||||
|
2 as libc::c_int,
|
||||||
|
crate::stdlib::SOCK_DGRAM as libc::c_int,
|
||||||
|
0 as libc::c_int,
|
||||||
|
);
|
||||||
|
ifc.ifc_len =
|
||||||
|
::std::mem::size_of::<[crate::stdlib::ifreq; 4]>() as libc::c_ulong as libc::c_int;
|
||||||
|
ifc.ifc_ifcu.ifcu_req = ifs.as_mut_ptr();
|
||||||
|
if crate::stdlib::ioctl(
|
||||||
|
s,
|
||||||
|
0x8912 as libc::c_int as libc::c_ulong,
|
||||||
|
&mut ifc as *mut crate::stdlib::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::<crate::stdlib::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 {
|
||||||
|
crate::stdlib::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 crate::stdlib::ioctl(
|
||||||
|
s,
|
||||||
|
0x8927 as libc::c_int as libc::c_ulong,
|
||||||
|
&mut ifreq as *mut crate::stdlib::ifreq,
|
||||||
|
) == 0 as libc::c_int
|
||||||
|
{
|
||||||
|
crate::stdlib::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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
crate::stdlib::close(s);
|
||||||
|
}
|
||||||
|
#[no_mangle]
|
||||||
|
|
||||||
|
pub unsafe extern "C" fn set_nonblock(mut s: crate::squeezelite_h::sockfd) {
|
||||||
|
let mut flags = crate::stdlib::fcntl(s, 3 as libc::c_int, 0 as libc::c_int);
|
||||||
|
crate::stdlib::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: crate::squeezelite_h::sockfd,
|
||||||
|
mut addr: *const crate::stdlib::sockaddr,
|
||||||
|
mut addrlen: crate::stdlib::socklen_t,
|
||||||
|
mut timeout: libc::c_int,
|
||||||
|
) -> libc::c_int {
|
||||||
|
let mut w = crate::stdlib::fd_set {
|
||||||
|
__fds_bits: [0; 16],
|
||||||
|
};
|
||||||
|
let mut e = crate::stdlib::fd_set {
|
||||||
|
__fds_bits: [0; 16],
|
||||||
|
};
|
||||||
|
let mut tval = crate::stdlib::timeval {
|
||||||
|
tv_sec: 0,
|
||||||
|
tv_usec: 0,
|
||||||
|
};
|
||||||
|
if crate::stdlib::connect(sock, addr, addrlen) < 0 as libc::c_int {
|
||||||
|
if *crate::stdlib::__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::<crate::stdlib::fd_set>() as libc::c_ulong)
|
||||||
|
.wrapping_div(::std::mem::size_of::<crate::stdlib::__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 crate::stdlib::__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::<crate::stdlib::__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::<crate::stdlib::__fd_mask>() as libc::c_ulong
|
||||||
|
as libc::c_int)) as crate::stdlib::__fd_mask;
|
||||||
|
e = w;
|
||||||
|
tval.tv_sec = timeout as crate::stdlib::__time_t;
|
||||||
|
tval.tv_usec = 0 as libc::c_int as crate::stdlib::__suseconds_t;
|
||||||
|
// only return 0 if w set and sock error is zero, otherwise return error code
|
||||||
|
if crate::stdlib::select(
|
||||||
|
sock + 1 as libc::c_int,
|
||||||
|
0 as *mut crate::stdlib::fd_set,
|
||||||
|
&mut w,
|
||||||
|
&mut e,
|
||||||
|
(if timeout != 0 {
|
||||||
|
&mut tval
|
||||||
|
} else {
|
||||||
|
0 as *mut crate::stdlib::timeval
|
||||||
|
}),
|
||||||
|
) == 1 as libc::c_int
|
||||||
|
&& w.__fds_bits[(sock
|
||||||
|
/ (8 as libc::c_int
|
||||||
|
* ::std::mem::size_of::<crate::stdlib::__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::<crate::stdlib::__fd_mask>() as libc::c_ulong
|
||||||
|
as libc::c_int)) as crate::stdlib::__fd_mask
|
||||||
|
!= 0 as libc::c_int as libc::c_long
|
||||||
|
{
|
||||||
|
let mut error = 0 as libc::c_int;
|
||||||
|
let mut len =
|
||||||
|
::std::mem::size_of::<libc::c_int>() as libc::c_ulong as crate::stdlib::socklen_t;
|
||||||
|
crate::stdlib::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 crate::stdlib::in_addr_t,
|
||||||
|
mut port_ptr: *mut libc::c_uint,
|
||||||
|
) {
|
||||||
|
let mut res = 0 as *mut crate::stdlib::addrinfo;
|
||||||
|
let mut hints = crate::stdlib::addrinfo {
|
||||||
|
ai_flags: 0,
|
||||||
|
ai_family: 0,
|
||||||
|
ai_socktype: 0,
|
||||||
|
ai_protocol: 0,
|
||||||
|
ai_addrlen: 0,
|
||||||
|
ai_addr: 0 as *mut crate::stdlib::sockaddr,
|
||||||
|
ai_canonname: 0 as *mut libc::c_char,
|
||||||
|
ai_next: 0 as *mut crate::stdlib::addrinfo,
|
||||||
|
};
|
||||||
|
let mut port = 0 as *const libc::c_char;
|
||||||
|
if !crate::stdlib::strtok(server, b":\x00" as *const u8 as *const libc::c_char).is_null() {
|
||||||
|
port = crate::stdlib::strtok(
|
||||||
|
0 as *mut libc::c_char,
|
||||||
|
b":\x00" as *const u8 as *const libc::c_char,
|
||||||
|
);
|
||||||
|
if !port.is_null() {
|
||||||
|
*port_ptr = crate::stdlib::atoi(port) as libc::c_uint
|
||||||
|
}
|
||||||
|
}
|
||||||
|
crate::stdlib::memset(
|
||||||
|
&mut hints as *mut crate::stdlib::addrinfo as *mut libc::c_void,
|
||||||
|
0 as libc::c_int,
|
||||||
|
::std::mem::size_of::<crate::stdlib::addrinfo>() as libc::c_ulong,
|
||||||
|
);
|
||||||
|
hints.ai_family = 2 as libc::c_int;
|
||||||
|
crate::stdlib::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 crate::stdlib::sockaddr_in))
|
||||||
|
.sin_addr
|
||||||
|
.s_addr
|
||||||
|
}
|
||||||
|
if !res.is_null() {
|
||||||
|
crate::stdlib::freeaddrinfo(res);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
#[no_mangle]
|
||||||
|
|
||||||
|
pub unsafe extern "C" fn set_readwake_handles(
|
||||||
|
mut handles: *mut crate::stdlib::pollfd,
|
||||||
|
mut s: crate::squeezelite_h::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 crate::stdlib::pollfd,
|
||||||
|
mut timeout: libc::c_int,
|
||||||
|
) -> crate::squeezelite_h::event_type {
|
||||||
|
if crate::stdlib::poll(handles, 2 as libc::c_int as crate::stdlib::nfds_t, timeout)
|
||||||
|
> 0 as libc::c_int
|
||||||
|
{
|
||||||
|
if (*handles.offset(0 as libc::c_int as isize)).revents != 0 {
|
||||||
|
return crate::squeezelite_h::EVENT_READ;
|
||||||
|
}
|
||||||
|
if (*handles.offset(1 as libc::c_int as isize)).revents != 0 {
|
||||||
|
let mut val: crate::stdlib::eventfd_t = 0;
|
||||||
|
crate::stdlib::eventfd_read((*handles.offset(1 as libc::c_int as isize)).fd, &mut val);
|
||||||
|
return crate::squeezelite_h::EVENT_WAKE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return crate::squeezelite_h::EVENT_TIMEOUT;
|
||||||
|
}
|
||||||
|
// pack/unpack to network byte order
|
||||||
|
#[no_mangle]
|
||||||
|
|
||||||
|
pub unsafe extern "C" fn packN(
|
||||||
|
mut dest: *mut crate::squeezelite_h::u32_t,
|
||||||
|
mut val: crate::squeezelite_h::u32_t,
|
||||||
|
) {
|
||||||
|
let mut ptr = dest as *mut crate::squeezelite_h::u8_t;
|
||||||
|
*ptr = (val >> 24 as libc::c_int & 0xff as libc::c_int as libc::c_uint)
|
||||||
|
as crate::squeezelite_h::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 crate::squeezelite_h::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 crate::squeezelite_h::u8_t;
|
||||||
|
*ptr.offset(3 as libc::c_int as isize) =
|
||||||
|
(val & 0xff as libc::c_int as libc::c_uint) as crate::squeezelite_h::u8_t;
|
||||||
|
}
|
||||||
|
#[no_mangle]
|
||||||
|
|
||||||
|
pub unsafe extern "C" fn packn(
|
||||||
|
mut dest: *mut crate::squeezelite_h::u16_t,
|
||||||
|
mut val: crate::squeezelite_h::u16_t,
|
||||||
|
) {
|
||||||
|
let mut ptr = dest as *mut crate::squeezelite_h::u8_t;
|
||||||
|
*ptr = (val as libc::c_int >> 8 as libc::c_int & 0xff as libc::c_int)
|
||||||
|
as crate::squeezelite_h::u8_t;
|
||||||
|
*ptr.offset(1 as libc::c_int as isize) =
|
||||||
|
(val as libc::c_int & 0xff as libc::c_int) as crate::squeezelite_h::u8_t;
|
||||||
|
}
|
||||||
|
#[no_mangle]
|
||||||
|
|
||||||
|
pub unsafe extern "C" fn unpackN(
|
||||||
|
mut src: *mut crate::squeezelite_h::u32_t,
|
||||||
|
) -> crate::squeezelite_h::u32_t {
|
||||||
|
let mut ptr = src as *mut crate::squeezelite_h::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 crate::squeezelite_h::u32_t;
|
||||||
|
}
|
||||||
|
#[no_mangle]
|
||||||
|
|
||||||
|
pub unsafe extern "C" fn unpackn(
|
||||||
|
mut src: *mut crate::squeezelite_h::u16_t,
|
||||||
|
) -> crate::squeezelite_h::u16_t {
|
||||||
|
let mut ptr = src as *mut crate::squeezelite_h::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 crate::squeezelite_h::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 crate::squeezelite_h::u8_t,
|
||||||
|
mut size: crate::stddef_h::size_t,
|
||||||
|
) {
|
||||||
|
let mut ptr = 0 as *mut crate::squeezelite_h::u8_t;
|
||||||
|
ptr = buf;
|
||||||
|
while ptr < buf.offset(size as isize) {
|
||||||
|
*ptr = 0 as libc::c_int as crate::squeezelite_h::u8_t;
|
||||||
|
ptr =
|
||||||
|
ptr.offset(crate::stdlib::sysconf(crate::stdlib::_SC_PAGESIZE as libc::c_int) as isize)
|
||||||
|
}
|
||||||
|
}
|
763
src/vorbis.rs
Normal file
763
src/vorbis.rs
Normal file
@ -0,0 +1,763 @@
|
|||||||
|
use ::libc;
|
||||||
|
|
||||||
|
pub use crate::stddef_h::size_t;
|
||||||
|
|
||||||
|
pub use crate::stdlib::__int16_t;
|
||||||
|
pub use crate::stdlib::__int32_t;
|
||||||
|
pub use crate::stdlib::__int64_t;
|
||||||
|
pub use crate::stdlib::__pthread_internal_list;
|
||||||
|
pub use crate::stdlib::__pthread_list_t;
|
||||||
|
pub use crate::stdlib::__pthread_mutex_s;
|
||||||
|
pub use crate::stdlib::__uint32_t;
|
||||||
|
pub use crate::stdlib::__uint64_t;
|
||||||
|
pub use crate::stdlib::__uint8_t;
|
||||||
|
pub use crate::stdlib::int16_t;
|
||||||
|
pub use crate::stdlib::int32_t;
|
||||||
|
pub use crate::stdlib::int64_t;
|
||||||
|
pub use crate::stdlib::pthread_mutex_t;
|
||||||
|
pub use crate::stdlib::u_int32_t;
|
||||||
|
pub use crate::stdlib::u_int64_t;
|
||||||
|
pub use crate::stdlib::u_int8_t;
|
||||||
|
|
||||||
|
pub use crate::squeezelite_h::buffer;
|
||||||
|
pub use crate::squeezelite_h::codec;
|
||||||
|
pub use crate::squeezelite_h::decode_state;
|
||||||
|
pub use crate::squeezelite_h::decodestate;
|
||||||
|
pub use crate::squeezelite_h::disconnect_code;
|
||||||
|
pub use crate::squeezelite_h::fade_dir;
|
||||||
|
pub use crate::squeezelite_h::fade_mode;
|
||||||
|
pub use crate::squeezelite_h::fade_state;
|
||||||
|
pub use crate::squeezelite_h::frames_t;
|
||||||
|
pub use crate::squeezelite_h::lDEBUG;
|
||||||
|
pub use crate::squeezelite_h::lERROR;
|
||||||
|
pub use crate::squeezelite_h::lINFO;
|
||||||
|
pub use crate::squeezelite_h::lSDEBUG;
|
||||||
|
pub use crate::squeezelite_h::lWARN;
|
||||||
|
pub use crate::squeezelite_h::log_level;
|
||||||
|
pub use crate::squeezelite_h::output_format;
|
||||||
|
pub use crate::squeezelite_h::output_state;
|
||||||
|
pub use crate::squeezelite_h::outputstate;
|
||||||
|
pub use crate::squeezelite_h::s16_t;
|
||||||
|
pub use crate::squeezelite_h::s32_t;
|
||||||
|
pub use crate::squeezelite_h::stream_state;
|
||||||
|
pub use crate::squeezelite_h::streamstate;
|
||||||
|
pub use crate::squeezelite_h::u32_t;
|
||||||
|
pub use crate::squeezelite_h::u64_t;
|
||||||
|
pub use crate::squeezelite_h::u8_t;
|
||||||
|
pub use crate::squeezelite_h::C2RustUnnamed_1;
|
||||||
|
pub use crate::squeezelite_h::_buf_used;
|
||||||
|
pub use crate::squeezelite_h::DECODE_COMPLETE;
|
||||||
|
pub use crate::squeezelite_h::DECODE_ERROR;
|
||||||
|
pub use crate::squeezelite_h::DECODE_READY;
|
||||||
|
pub use crate::squeezelite_h::DECODE_RUNNING;
|
||||||
|
pub use crate::squeezelite_h::DECODE_STOPPED;
|
||||||
|
pub use crate::squeezelite_h::DISCONNECT;
|
||||||
|
pub use crate::squeezelite_h::DISCONNECT_OK;
|
||||||
|
pub use crate::squeezelite_h::FADE_ACTIVE;
|
||||||
|
pub use crate::squeezelite_h::FADE_CROSS;
|
||||||
|
pub use crate::squeezelite_h::FADE_CROSSFADE;
|
||||||
|
pub use crate::squeezelite_h::FADE_DOWN;
|
||||||
|
pub use crate::squeezelite_h::FADE_DUE;
|
||||||
|
pub use crate::squeezelite_h::FADE_IN;
|
||||||
|
pub use crate::squeezelite_h::FADE_INACTIVE;
|
||||||
|
pub use crate::squeezelite_h::FADE_INOUT;
|
||||||
|
pub use crate::squeezelite_h::FADE_NONE;
|
||||||
|
pub use crate::squeezelite_h::FADE_OUT;
|
||||||
|
pub use crate::squeezelite_h::FADE_UP;
|
||||||
|
pub use crate::squeezelite_h::LOCAL_DISCONNECT;
|
||||||
|
pub use crate::squeezelite_h::OUTPUT_BUFFER;
|
||||||
|
pub use crate::squeezelite_h::OUTPUT_OFF;
|
||||||
|
pub use crate::squeezelite_h::OUTPUT_PAUSE_FRAMES;
|
||||||
|
pub use crate::squeezelite_h::OUTPUT_RUNNING;
|
||||||
|
pub use crate::squeezelite_h::OUTPUT_SKIP_FRAMES;
|
||||||
|
pub use crate::squeezelite_h::OUTPUT_START_AT;
|
||||||
|
pub use crate::squeezelite_h::OUTPUT_STOPPED;
|
||||||
|
pub use crate::squeezelite_h::RECV_HEADERS;
|
||||||
|
pub use crate::squeezelite_h::REMOTE_DISCONNECT;
|
||||||
|
pub use crate::squeezelite_h::S16_LE;
|
||||||
|
pub use crate::squeezelite_h::S24_3LE;
|
||||||
|
pub use crate::squeezelite_h::S24_LE;
|
||||||
|
pub use crate::squeezelite_h::S32_LE;
|
||||||
|
pub use crate::squeezelite_h::SEND_HEADERS;
|
||||||
|
pub use crate::squeezelite_h::STOPPED;
|
||||||
|
pub use crate::squeezelite_h::STREAMING_BUFFERING;
|
||||||
|
pub use crate::squeezelite_h::STREAMING_FILE;
|
||||||
|
pub use crate::squeezelite_h::STREAMING_HTTP;
|
||||||
|
pub use crate::squeezelite_h::STREAMING_WAIT;
|
||||||
|
pub use crate::squeezelite_h::TIMEOUT;
|
||||||
|
pub use crate::squeezelite_h::UNREACHABLE;
|
||||||
|
pub use crate::src::buffer::_buf_cont_read;
|
||||||
|
pub use crate::src::buffer::_buf_cont_write;
|
||||||
|
pub use crate::src::buffer::_buf_inc_readp;
|
||||||
|
pub use crate::src::buffer::_buf_inc_writep;
|
||||||
|
pub use crate::src::buffer::_buf_space;
|
||||||
|
pub use crate::src::decode::decode_newstream;
|
||||||
|
pub use crate::src::output::_checkfade;
|
||||||
|
pub use crate::src::utils::logprint;
|
||||||
|
pub use crate::src::utils::logtime;
|
||||||
|
pub use crate::stdlib::ogg_int64_t;
|
||||||
|
pub use crate::stdlib::ov_callbacks;
|
||||||
|
pub use crate::stdlib::OggVorbis_File;
|
||||||
|
|
||||||
|
pub use crate::stdlib::alloc_chain;
|
||||||
|
use crate::stdlib::dlerror;
|
||||||
|
use crate::stdlib::dlopen;
|
||||||
|
use crate::stdlib::dlsym;
|
||||||
|
use crate::stdlib::free;
|
||||||
|
use crate::stdlib::malloc;
|
||||||
|
use crate::stdlib::memcpy;
|
||||||
|
use crate::stdlib::memset;
|
||||||
|
pub use crate::stdlib::ogg_stream_state;
|
||||||
|
pub use crate::stdlib::ogg_sync_state;
|
||||||
|
pub use crate::stdlib::oggpack_buffer;
|
||||||
|
use crate::stdlib::pthread_mutex_lock;
|
||||||
|
use crate::stdlib::pthread_mutex_unlock;
|
||||||
|
pub use crate::stdlib::vorbis_block;
|
||||||
|
pub use crate::stdlib::vorbis_comment;
|
||||||
|
pub use crate::stdlib::vorbis_dsp_state;
|
||||||
|
pub use crate::stdlib::vorbis_info;
|
||||||
|
extern "C" {
|
||||||
|
#[no_mangle]
|
||||||
|
pub static mut loglevel: crate::squeezelite_h::log_level;
|
||||||
|
#[no_mangle]
|
||||||
|
pub static mut streambuf: *mut crate::squeezelite_h::buffer;
|
||||||
|
#[no_mangle]
|
||||||
|
pub static mut outputbuf: *mut crate::squeezelite_h::buffer;
|
||||||
|
#[no_mangle]
|
||||||
|
pub static mut stream: crate::squeezelite_h::streamstate;
|
||||||
|
#[no_mangle]
|
||||||
|
pub static mut output: crate::squeezelite_h::outputstate;
|
||||||
|
#[no_mangle]
|
||||||
|
pub static mut decode: crate::squeezelite_h::decodestate;
|
||||||
|
}
|
||||||
|
// 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
|
||||||
|
|
||||||
|
#[repr(C)]
|
||||||
|
#[derive(Copy, Clone)]
|
||||||
|
pub struct vorbis {
|
||||||
|
pub vf: *mut crate::stdlib::OggVorbis_File,
|
||||||
|
pub opened: bool,
|
||||||
|
pub write_buf: *mut crate::squeezelite_h::u8_t,
|
||||||
|
pub ov_info: Option<
|
||||||
|
unsafe extern "C" fn(
|
||||||
|
_: *mut crate::stdlib::OggVorbis_File,
|
||||||
|
_: libc::c_int,
|
||||||
|
) -> *mut crate::stdlib::vorbis_info,
|
||||||
|
>,
|
||||||
|
pub ov_clear:
|
||||||
|
Option<unsafe extern "C" fn(_: *mut crate::stdlib::OggVorbis_File) -> libc::c_int>,
|
||||||
|
pub ov_read: Option<
|
||||||
|
unsafe extern "C" fn(
|
||||||
|
_: *mut crate::stdlib::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 crate::stdlib::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 crate::stdlib::OggVorbis_File,
|
||||||
|
_: *const libc::c_char,
|
||||||
|
_: libc::c_long,
|
||||||
|
_: crate::stdlib::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: crate::stddef_h::size_t,
|
||||||
|
mut nmemb: crate::stddef_h::size_t,
|
||||||
|
mut datasource: *mut libc::c_void,
|
||||||
|
) -> crate::stddef_h::size_t {
|
||||||
|
let mut bytes: crate::stddef_h::size_t = 0;
|
||||||
|
crate::stdlib::pthread_mutex_lock(&mut (*streambuf).mutex);
|
||||||
|
bytes = if crate::squeezelite_h::_buf_used(streambuf)
|
||||||
|
< crate::src::buffer::_buf_cont_read(streambuf)
|
||||||
|
{
|
||||||
|
crate::squeezelite_h::_buf_used(streambuf)
|
||||||
|
} else {
|
||||||
|
crate::src::buffer::_buf_cont_read(streambuf)
|
||||||
|
} as crate::stddef_h::size_t;
|
||||||
|
bytes = if bytes < size.wrapping_mul(nmemb) {
|
||||||
|
bytes
|
||||||
|
} else {
|
||||||
|
size.wrapping_mul(nmemb)
|
||||||
|
};
|
||||||
|
crate::stdlib::memcpy(ptr, (*streambuf).readp as *const libc::c_void, bytes);
|
||||||
|
crate::src::buffer::_buf_inc_readp(streambuf, bytes as libc::c_uint);
|
||||||
|
crate::stdlib::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: crate::stdlib::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() -> crate::squeezelite_h::decode_state {
|
||||||
|
static mut channels: libc::c_int = 0;
|
||||||
|
let mut frames: crate::squeezelite_h::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 = 0 as *mut crate::squeezelite_h::u8_t;
|
||||||
|
crate::stdlib::pthread_mutex_lock(&mut (*streambuf).mutex);
|
||||||
|
if stream.state as libc::c_uint
|
||||||
|
<= crate::squeezelite_h::DISCONNECT as libc::c_int as libc::c_uint
|
||||||
|
&& crate::squeezelite_h::_buf_used(streambuf) == 0
|
||||||
|
{
|
||||||
|
crate::stdlib::pthread_mutex_unlock(&mut (*streambuf).mutex);
|
||||||
|
return crate::squeezelite_h::DECODE_COMPLETE;
|
||||||
|
}
|
||||||
|
crate::stdlib::pthread_mutex_unlock(&mut (*streambuf).mutex);
|
||||||
|
if decode.new_stream {
|
||||||
|
let mut cbs = crate::stdlib::ov_callbacks {
|
||||||
|
read_func: None,
|
||||||
|
seek_func: None,
|
||||||
|
close_func: None,
|
||||||
|
tell_func: None,
|
||||||
|
};
|
||||||
|
let mut err: libc::c_int = 0;
|
||||||
|
let mut info = 0 as *mut crate::stdlib::vorbis_info;
|
||||||
|
cbs.read_func = Some(
|
||||||
|
_read_cb
|
||||||
|
as unsafe extern "C" fn(
|
||||||
|
_: *mut libc::c_void,
|
||||||
|
_: crate::stddef_h::size_t,
|
||||||
|
_: crate::stddef_h::size_t,
|
||||||
|
_: *mut libc::c_void,
|
||||||
|
) -> crate::stddef_h::size_t,
|
||||||
|
);
|
||||||
|
if (*v).ov_read_tremor.is_some() {
|
||||||
|
cbs.seek_func = Some(
|
||||||
|
_seek_cb
|
||||||
|
as unsafe extern "C" fn(
|
||||||
|
_: *mut libc::c_void,
|
||||||
|
_: crate::stdlib::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
|
||||||
|
>= crate::squeezelite_h::lWARN as libc::c_int as libc::c_uint
|
||||||
|
{
|
||||||
|
crate::src::utils::logprint(
|
||||||
|
b"%s %s:%d open_callbacks error: %d\n\x00" as *const u8 as *const libc::c_char,
|
||||||
|
crate::src::utils::logtime(),
|
||||||
|
(*::std::mem::transmute::<&[u8; 14], &[libc::c_char; 14]>(
|
||||||
|
b"vorbis_decode\x00",
|
||||||
|
))
|
||||||
|
.as_ptr(),
|
||||||
|
162 as libc::c_int,
|
||||||
|
err,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return crate::squeezelite_h::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 >= crate::squeezelite_h::lINFO as libc::c_int as libc::c_uint {
|
||||||
|
crate::src::utils::logprint(
|
||||||
|
b"%s %s:%d setting track_start\n\x00" as *const u8 as *const libc::c_char,
|
||||||
|
crate::src::utils::logtime(),
|
||||||
|
(*::std::mem::transmute::<&[u8; 14], &[libc::c_char; 14]>(b"vorbis_decode\x00"))
|
||||||
|
.as_ptr(),
|
||||||
|
169 as libc::c_int,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
crate::stdlib::pthread_mutex_lock(&mut (*outputbuf).mutex);
|
||||||
|
output.next_sample_rate = crate::src::decode::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 {
|
||||||
|
crate::src::output::_checkfade(1 as libc::c_int != 0);
|
||||||
|
}
|
||||||
|
decode.new_stream = 0 as libc::c_int != 0;
|
||||||
|
crate::stdlib::pthread_mutex_unlock(&mut (*outputbuf).mutex);
|
||||||
|
channels = (*info).channels;
|
||||||
|
if channels > 2 as libc::c_int {
|
||||||
|
if loglevel as libc::c_uint
|
||||||
|
>= crate::squeezelite_h::lWARN as libc::c_int as libc::c_uint
|
||||||
|
{
|
||||||
|
crate::src::utils::logprint(
|
||||||
|
b"%s %s:%d too many channels: %d\n\x00" as *const u8 as *const libc::c_char,
|
||||||
|
crate::src::utils::logtime(),
|
||||||
|
(*::std::mem::transmute::<&[u8; 14], &[libc::c_char; 14]>(
|
||||||
|
b"vorbis_decode\x00",
|
||||||
|
))
|
||||||
|
.as_ptr(),
|
||||||
|
181 as libc::c_int,
|
||||||
|
channels,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return crate::squeezelite_h::DECODE_ERROR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
frames = (if crate::src::buffer::_buf_space(outputbuf)
|
||||||
|
< crate::src::buffer::_buf_cont_write(outputbuf)
|
||||||
|
{
|
||||||
|
crate::src::buffer::_buf_space(outputbuf)
|
||||||
|
} else {
|
||||||
|
crate::src::buffer::_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
|
||||||
|
}
|
||||||
|
crate::stdlib::pthread_mutex_lock(&mut (*outputbuf).mutex);
|
||||||
|
if n > 0 as libc::c_int {
|
||||||
|
let mut count: crate::squeezelite_h::frames_t = 0;
|
||||||
|
let mut iptr = 0 as *mut crate::squeezelite_h::s16_t;
|
||||||
|
let mut optr = 0 as *mut crate::squeezelite_h::s32_t;
|
||||||
|
frames = (n / 2 as libc::c_int / channels) as crate::squeezelite_h::frames_t;
|
||||||
|
count = frames.wrapping_mul(channels as libc::c_uint);
|
||||||
|
iptr = (write_buf as *mut crate::squeezelite_h::s16_t).offset(count as isize);
|
||||||
|
optr = ((*outputbuf).writep as *mut crate::squeezelite_h::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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
crate::src::buffer::_buf_inc_writep(
|
||||||
|
outputbuf,
|
||||||
|
frames.wrapping_mul(8 as libc::c_int as libc::c_uint),
|
||||||
|
);
|
||||||
|
if loglevel as libc::c_uint >= crate::squeezelite_h::lSDEBUG as libc::c_int as libc::c_uint
|
||||||
|
{
|
||||||
|
crate::src::utils::logprint(
|
||||||
|
b"%s %s:%d wrote %u frames\n\x00" as *const u8 as *const libc::c_char,
|
||||||
|
crate::src::utils::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
|
||||||
|
<= crate::squeezelite_h::DISCONNECT as libc::c_int as libc::c_uint
|
||||||
|
{
|
||||||
|
if loglevel as libc::c_uint
|
||||||
|
>= crate::squeezelite_h::lINFO as libc::c_int as libc::c_uint
|
||||||
|
{
|
||||||
|
crate::src::utils::logprint(
|
||||||
|
b"%s %s:%d partial decode\n\x00" as *const u8 as *const libc::c_char,
|
||||||
|
crate::src::utils::logtime(),
|
||||||
|
(*::std::mem::transmute::<&[u8; 14], &[libc::c_char; 14]>(
|
||||||
|
b"vorbis_decode\x00",
|
||||||
|
))
|
||||||
|
.as_ptr(),
|
||||||
|
270 as libc::c_int,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
crate::stdlib::pthread_mutex_unlock(&mut (*outputbuf).mutex);
|
||||||
|
return crate::squeezelite_h::DECODE_COMPLETE;
|
||||||
|
} else {
|
||||||
|
if loglevel as libc::c_uint
|
||||||
|
>= crate::squeezelite_h::lINFO as libc::c_int as libc::c_uint
|
||||||
|
{
|
||||||
|
crate::src::utils::logprint(
|
||||||
|
b"%s %s:%d no frame decoded\n\x00" as *const u8 as *const libc::c_char,
|
||||||
|
crate::src::utils::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 >= crate::squeezelite_h::lDEBUG as libc::c_int as libc::c_uint {
|
||||||
|
crate::src::utils::logprint(
|
||||||
|
b"%s %s:%d hole in stream\n\x00" as *const u8 as *const libc::c_char,
|
||||||
|
crate::src::utils::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 >= crate::squeezelite_h::lINFO as libc::c_int as libc::c_uint {
|
||||||
|
crate::src::utils::logprint(
|
||||||
|
b"%s %s:%d ov_read error: %d\n\x00" as *const u8 as *const libc::c_char,
|
||||||
|
crate::src::utils::logtime(),
|
||||||
|
(*::std::mem::transmute::<&[u8; 14], &[libc::c_char; 14]>(b"vorbis_decode\x00"))
|
||||||
|
.as_ptr(),
|
||||||
|
284 as libc::c_int,
|
||||||
|
n,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
crate::stdlib::pthread_mutex_unlock(&mut (*outputbuf).mutex);
|
||||||
|
return crate::squeezelite_h::DECODE_COMPLETE;
|
||||||
|
}
|
||||||
|
crate::stdlib::pthread_mutex_unlock(&mut (*outputbuf).mutex);
|
||||||
|
return crate::squeezelite_h::DECODE_RUNNING;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe extern "C" fn vorbis_open(
|
||||||
|
mut size: crate::squeezelite_h::u8_t,
|
||||||
|
mut rate: crate::squeezelite_h::u8_t,
|
||||||
|
mut chan: crate::squeezelite_h::u8_t,
|
||||||
|
mut endianness: crate::squeezelite_h::u8_t,
|
||||||
|
) {
|
||||||
|
if (*v).vf.is_null() {
|
||||||
|
(*v).vf = crate::stdlib::malloc(
|
||||||
|
(::std::mem::size_of::<crate::stdlib::OggVorbis_File>() as libc::c_ulong)
|
||||||
|
.wrapping_add(128 as libc::c_int as libc::c_ulong),
|
||||||
|
) as *mut crate::stdlib::OggVorbis_File;
|
||||||
|
crate::stdlib::memset(
|
||||||
|
(*v).vf as *mut libc::c_void,
|
||||||
|
0 as libc::c_int,
|
||||||
|
(::std::mem::size_of::<crate::stdlib::OggVorbis_File>() as libc::c_ulong)
|
||||||
|
.wrapping_add(128 as libc::c_int as libc::c_ulong),
|
||||||
|
);
|
||||||
|
(*v).write_buf =
|
||||||
|
crate::stdlib::malloc((2048 as libc::c_int * 8 as libc::c_int) as libc::c_ulong)
|
||||||
|
as *mut crate::squeezelite_h::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
|
||||||
|
}
|
||||||
|
crate::stdlib::free((*v).vf as *mut libc::c_void);
|
||||||
|
crate::stdlib::free((*v).write_buf as *mut libc::c_void);
|
||||||
|
(*v).write_buf = 0 as *mut crate::squeezelite_h::u8_t;
|
||||||
|
(*v).vf = 0 as *mut crate::stdlib::OggVorbis_File;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe extern "C" fn load_vorbis() -> bool {
|
||||||
|
let mut handle = crate::stdlib::dlopen(
|
||||||
|
b"libvorbisfile.so.3\x00" as *const u8 as *const libc::c_char,
|
||||||
|
0x2 as libc::c_int,
|
||||||
|
);
|
||||||
|
let mut err = 0 as *mut libc::c_char;
|
||||||
|
let mut tremor = 0 as libc::c_int != 0;
|
||||||
|
if handle.is_null() {
|
||||||
|
handle = crate::stdlib::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
|
||||||
|
>= crate::squeezelite_h::lINFO as libc::c_int as libc::c_uint
|
||||||
|
{
|
||||||
|
crate::src::utils::logprint(
|
||||||
|
b"%s %s:%d dlerror: %s\n\x00" as *const u8 as *const libc::c_char,
|
||||||
|
crate::src::utils::logtime(),
|
||||||
|
(*::std::mem::transmute::<&[u8; 12], &[libc::c_char; 12]>(b"load_vorbis\x00"))
|
||||||
|
.as_ptr(),
|
||||||
|
332 as libc::c_int,
|
||||||
|
crate::stdlib::dlerror(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return 0 as libc::c_int != 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
(*v).ov_read = ::std::mem::transmute::<
|
||||||
|
*mut libc::c_void,
|
||||||
|
Option<
|
||||||
|
unsafe extern "C" fn(
|
||||||
|
_: *mut crate::stdlib::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 {
|
||||||
|
crate::stdlib::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 crate::stdlib::OggVorbis_File,
|
||||||
|
_: *mut libc::c_char,
|
||||||
|
_: libc::c_int,
|
||||||
|
_: *mut libc::c_int,
|
||||||
|
) -> libc::c_long,
|
||||||
|
>,
|
||||||
|
>(if tremor as libc::c_int != 0 {
|
||||||
|
crate::stdlib::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 crate::stdlib::OggVorbis_File,
|
||||||
|
_: libc::c_int,
|
||||||
|
) -> *mut crate::stdlib::vorbis_info,
|
||||||
|
>,
|
||||||
|
>(crate::stdlib::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 crate::stdlib::OggVorbis_File) -> libc::c_int>,
|
||||||
|
>(crate::stdlib::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 crate::stdlib::OggVorbis_File,
|
||||||
|
_: *const libc::c_char,
|
||||||
|
_: libc::c_long,
|
||||||
|
_: crate::stdlib::ov_callbacks,
|
||||||
|
) -> libc::c_int,
|
||||||
|
>,
|
||||||
|
>(crate::stdlib::dlsym(
|
||||||
|
handle,
|
||||||
|
b"ov_open_callbacks\x00" as *const u8 as *const libc::c_char,
|
||||||
|
));
|
||||||
|
err = crate::stdlib::dlerror();
|
||||||
|
if !err.is_null() {
|
||||||
|
if loglevel as libc::c_uint >= crate::squeezelite_h::lINFO as libc::c_int as libc::c_uint {
|
||||||
|
crate::src::utils::logprint(
|
||||||
|
b"%s %s:%d dlerror: %s\n\x00" as *const u8 as *const libc::c_char,
|
||||||
|
crate::src::utils::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 >= crate::squeezelite_h::lINFO as libc::c_int as libc::c_uint {
|
||||||
|
crate::src::utils::logprint(
|
||||||
|
b"%s %s:%d loaded %s\n\x00" as *const u8 as *const libc::c_char,
|
||||||
|
crate::src::utils::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 crate::squeezelite_h::codec {
|
||||||
|
static mut ret: crate::squeezelite_h::codec = unsafe {
|
||||||
|
{
|
||||||
|
let mut init = crate::squeezelite_h::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(
|
||||||
|
_: crate::squeezelite_h::u8_t,
|
||||||
|
_: crate::squeezelite_h::u8_t,
|
||||||
|
_: crate::squeezelite_h::u8_t,
|
||||||
|
_: crate::squeezelite_h::u8_t,
|
||||||
|
) -> (),
|
||||||
|
),
|
||||||
|
close: Some(vorbis_close as unsafe extern "C" fn() -> ()),
|
||||||
|
decode: Some(
|
||||||
|
vorbis_decode as unsafe extern "C" fn() -> crate::squeezelite_h::decode_state,
|
||||||
|
),
|
||||||
|
};
|
||||||
|
init
|
||||||
|
}
|
||||||
|
};
|
||||||
|
v = crate::stdlib::malloc(::std::mem::size_of::<vorbis>() as libc::c_ulong) as *mut vorbis;
|
||||||
|
if v.is_null() {
|
||||||
|
return 0 as *mut crate::squeezelite_h::codec;
|
||||||
|
}
|
||||||
|
(*v).vf = 0 as *mut crate::stdlib::OggVorbis_File;
|
||||||
|
(*v).opened = 0 as libc::c_int != 0;
|
||||||
|
if !load_vorbis() {
|
||||||
|
return 0 as *mut crate::squeezelite_h::codec;
|
||||||
|
}
|
||||||
|
if loglevel as libc::c_uint >= crate::squeezelite_h::lINFO as libc::c_int as libc::c_uint {
|
||||||
|
crate::src::utils::logprint(
|
||||||
|
b"%s %s:%d using vorbis to decode ogg\n\x00" as *const u8 as *const libc::c_char,
|
||||||
|
crate::src::utils::logtime(),
|
||||||
|
(*::std::mem::transmute::<&[u8; 16], &[libc::c_char; 16]>(b"register_vorbis\x00"))
|
||||||
|
.as_ptr(),
|
||||||
|
377 as libc::c_int,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return &mut ret;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user