diff --git a/Cargo.toml b/Cargo.toml index 2f033ab..b726a05 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,7 @@ members = [ ] [package] -name = "squeezers" +name = "sqeezers" authors = ["C2Rust"] version = "0.0.0" publish = false @@ -11,19 +11,34 @@ edition = "2018" autobins = false [lib] -name = "squeezers" +name = "sqeezers" 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" +[dependencies.c2rust-xcheck-plugin] +path = "../c2rust/cross-checks/rust-checks/rustc-plugin" +version = "*" +[dependencies.c2rust-xcheck-derive] +path = "../c2rust/cross-checks/rust-checks/derive-macros" +version = "*" + +[dependencies.c2rust-xcheck-runtime] +path = "../c2rust/cross-checks/rust-checks/runtime" +version = "*" +features = ["libc-hash", "fixed-length-array-hash"] + +[dependencies.c2rust-xcheck-backend-zstd-logging] +path = "../c2rust/cross-checks/rust-checks/backends/zstd-logging" +version = "*" + +[dependencies.c2rust-ast-printer] +path = "../c2rust/cross-checks/rust-checks/" +version = "*" diff --git a/lib.rs b/lib.rs index 5e14886..d8971aa 100644 --- a/lib.rs +++ b/lib.rs @@ -5,47 +5,49 @@ #![allow(non_upper_case_globals)] #![allow(unused_assignments)] #![allow(unused_mut)] +#![cross_check(yes)] #![feature(asm)] #![feature(c_variadic)] #![feature(const_raw_ptr_to_usize_cast)] #![feature(extern_types)] #![feature(main)] +#![feature(plugin)] #![feature(ptr_wrapping_offset_from)] #![feature(register_tool)] #![register_tool(c2rust)] -#[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_bitfields;#[macro_use] extern crate c2rust_asm_casts; extern crate libc; +#![plugin(c2rust_xcheck_plugin())] +#[macro_use] extern crate c2rust_xcheck_derive; +#[macro_use] extern crate c2rust_xcheck_runtime; +extern crate c2rust_xcheck_backend_zstd_logging; + +#[global_allocator] +static C2RUST_ALLOC: ::std::alloc::System = ::std::alloc::System; + pub mod src { - pub mod buffer; - pub mod decode; - pub mod faad; - pub mod flac; - pub mod mad; - pub mod 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; +pub mod buffer; +pub mod decode; +pub mod faad; +pub mod flac; +pub mod mad; +pub mod main; +pub mod mpg; +pub mod output; +pub mod output_alsa; +pub mod output_pa; +pub mod output_pack; +pub mod output_pulse; +pub mod output_stdout; +pub mod pcm; +pub mod slimproto; +pub mod stream; +pub mod utils; +pub mod vorbis; } // mod src + diff --git a/src/buffer.rs b/src/buffer.rs index c102c32..60fa1db 100644 --- a/src/buffer.rs +++ b/src/buffer.rs @@ -1,30 +1,81 @@ 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; -/* +extern "C" { + #[no_mangle] + fn malloc(_: libc::c_ulong) -> *mut libc::c_void; + #[no_mangle] + fn free(__ptr: *mut libc::c_void); + #[no_mangle] + fn pthread_mutex_init(__mutex: *mut pthread_mutex_t, + __mutexattr: *const pthread_mutexattr_t) + -> libc::c_int; + #[no_mangle] + fn pthread_mutex_destroy(__mutex: *mut pthread_mutex_t) -> libc::c_int; + #[no_mangle] + fn pthread_mutex_lock(__mutex: *mut pthread_mutex_t) -> libc::c_int; + #[no_mangle] + fn pthread_mutex_unlock(__mutex: *mut pthread_mutex_t) -> libc::c_int; + #[no_mangle] + fn pthread_mutexattr_init(__attr: *mut pthread_mutexattr_t) + -> libc::c_int; + #[no_mangle] + fn pthread_mutexattr_destroy(__attr: *mut pthread_mutexattr_t) + -> libc::c_int; + #[no_mangle] + fn pthread_mutexattr_setprotocol(__attr: *mut pthread_mutexattr_t, + __protocol: libc::c_int) -> libc::c_int; +} +pub type size_t = libc::c_ulong; +pub type __uint8_t = libc::c_uchar; +pub type u_int8_t = __uint8_t; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct __pthread_internal_list { + pub __prev: *mut __pthread_internal_list, + pub __next: *mut __pthread_internal_list, +} +pub type __pthread_list_t = __pthread_internal_list; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct __pthread_mutex_s { + pub __lock: libc::c_int, + pub __count: libc::c_uint, + pub __owner: libc::c_int, + pub __nusers: libc::c_uint, + pub __kind: libc::c_int, + pub __spins: libc::c_short, + pub __elision: libc::c_short, + pub __list: __pthread_list_t, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub union pthread_mutexattr_t { + pub __size: [libc::c_char; 4], + pub __align: libc::c_int, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub union pthread_mutex_t { + pub __data: __pthread_mutex_s, + pub __size: [libc::c_char; 40], + pub __align: libc::c_long, +} +pub type C2RustUnnamed = libc::c_uint; +pub const PTHREAD_PRIO_PROTECT: C2RustUnnamed = 2; +pub const PTHREAD_PRIO_INHERIT: C2RustUnnamed = 1; +pub const PTHREAD_PRIO_NONE: C2RustUnnamed = 0; +pub type u8_t = u_int8_t; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct buffer { + pub buf: *mut u8_t, + pub readp: *mut u8_t, + pub writep: *mut u8_t, + pub wrap: *mut u8_t, + pub size: size_t, + pub base_size: size_t, + pub mutex: pthread_mutex_t, +} +/* * Squeezelite - lightweight headless squeezebox emulator * * (c) Adrian Smith 2012-2015, triode1@btinternet.com @@ -34,7 +85,7 @@ pub use crate::stdlib::PTHREAD_PRIO_PROTECT; * 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 @@ -44,112 +95,94 @@ pub use crate::stdlib::PTHREAD_PRIO_PROTECT; * along with this program. If not, see . * */ -// fifo bufffers +// fifo bufffers // _* called with muxtex locked #[inline] - -unsafe extern "C" fn _buf_used(mut buf: *mut crate::squeezelite_h::buffer) -> libc::c_uint { +unsafe extern "C" fn _buf_used(mut buf: *mut buffer) -> libc::c_uint { return if (*buf).writep >= (*buf).readp { - (*buf).writep.wrapping_offset_from((*buf).readp) as libc::c_long as libc::c_ulong - } else { - (*buf).size.wrapping_sub( - (*buf).readp.wrapping_offset_from((*buf).writep) as libc::c_long as libc::c_ulong, - ) - } as libc::c_uint; + (*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; +pub unsafe extern "C" fn _buf_space(mut buf: *mut buffer) -> libc::c_uint { + return (*buf).size.wrapping_sub(_buf_used(buf) as + libc::c_ulong).wrapping_sub(1 as + libc::c_int + as + libc::c_ulong) + as libc::c_uint; // reduce by one as full same as empty otherwise } #[no_mangle] - -pub unsafe extern "C" fn _buf_cont_read( - mut buf: *mut crate::squeezelite_h::buffer, -) -> libc::c_uint { +pub unsafe extern "C" fn _buf_cont_read(mut buf: *mut buffer) + -> libc::c_uint { return if (*buf).writep >= (*buf).readp { - (*buf).writep.wrapping_offset_from((*buf).readp) as libc::c_long - } else { - (*buf).wrap.wrapping_offset_from((*buf).readp) as libc::c_long - } as libc::c_uint; + (*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 { +pub unsafe extern "C" fn _buf_cont_write(mut buf: *mut buffer) + -> libc::c_uint { return if (*buf).writep >= (*buf).readp { - (*buf).wrap.wrapping_offset_from((*buf).writep) as libc::c_long - } else { - (*buf).readp.wrapping_offset_from((*buf).writep) as libc::c_long - } as libc::c_uint; + (*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, -) { +pub unsafe extern "C" fn _buf_inc_readp(mut buf: *mut buffer, + mut by: libc::c_uint) { (*buf).readp = (*buf).readp.offset(by as isize); if (*buf).readp >= (*buf).wrap { (*buf).readp = (*buf).readp.offset(-((*buf).size as isize)) }; } #[no_mangle] - -pub unsafe extern "C" fn _buf_inc_writep( - mut buf: *mut crate::squeezelite_h::buffer, - mut by: libc::c_uint, -) { +pub unsafe extern "C" fn _buf_inc_writep(mut buf: *mut buffer, + mut by: libc::c_uint) { (*buf).writep = (*buf).writep.offset(by as isize); if (*buf).writep >= (*buf).wrap { (*buf).writep = (*buf).writep.offset(-((*buf).size as isize)) }; } #[no_mangle] - -pub unsafe extern "C" fn buf_flush(mut buf: *mut crate::squeezelite_h::buffer) { - crate::stdlib::pthread_mutex_lock(&mut (*buf).mutex); +pub unsafe extern "C" fn buf_flush(mut buf: *mut buffer) { + pthread_mutex_lock(&mut (*buf).mutex); (*buf).readp = (*buf).buf; (*buf).writep = (*buf).buf; - crate::stdlib::pthread_mutex_unlock(&mut (*buf).mutex); + 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); +pub unsafe extern "C" fn buf_adjust(mut buf: *mut buffer, mut mod_0: size_t) { + let mut size: size_t = 0; + pthread_mutex_lock(&mut (*buf).mutex); size = - ((*buf).base_size.wrapping_div(mod_0) as libc::c_uint as libc::c_ulong).wrapping_mul(mod_0); + ((*buf).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); + 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; +pub unsafe extern "C" fn _buf_resize(mut buf: *mut buffer, mut size: size_t) { + free((*buf).buf as *mut libc::c_void); + (*buf).buf = malloc(size) as *mut u8_t; if (*buf).buf.is_null() { size = (*buf).size; - (*buf).buf = 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).buf = malloc(size) as *mut u8_t; + if (*buf).buf.is_null() { size = 0 as libc::c_int as size_t } } (*buf).readp = (*buf).buf; (*buf).writep = (*buf).buf; @@ -158,37 +191,31 @@ pub unsafe extern "C" fn _buf_resize( (*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; +pub unsafe extern "C" fn buf_init(mut buf: *mut buffer, mut size: size_t) { + (*buf).buf = malloc(size) as *mut u8_t; (*buf).readp = (*buf).buf; (*buf).writep = (*buf).buf; (*buf).wrap = (*buf).buf.offset(size as isize); (*buf).size = size; (*buf).base_size = size; - let mut attr = 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); + let mut attr: pthread_mutexattr_t = pthread_mutexattr_t{__size: [0; 4],}; + pthread_mutexattr_init(&mut attr); + pthread_mutexattr_setprotocol(&mut attr, + PTHREAD_PRIO_INHERIT as libc::c_int); + pthread_mutex_init(&mut (*buf).mutex, &mut attr); + pthread_mutexattr_destroy(&mut attr); } -/* +/* * Squeezelite - lightweight headless squeezebox emulator * * (c) Adrian Smith 2012-2015, triode1@btinternet.com * Ralph Irving 2015-2017, ralph_irving@hotmail.com - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the @@ -215,13 +242,12 @@ pub unsafe extern "C" fn buf_init( // buffer.c // _* called with mutex locked #[no_mangle] - -pub unsafe extern "C" fn buf_destroy(mut buf: *mut crate::squeezelite_h::buffer) { +pub unsafe extern "C" fn buf_destroy(mut buf: *mut 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); + free((*buf).buf as *mut libc::c_void); + (*buf).buf = 0 as *mut u8_t; + (*buf).size = 0 as libc::c_int as size_t; + (*buf).base_size = 0 as libc::c_int as size_t; + pthread_mutex_destroy(&mut (*buf).mutex); }; } diff --git a/src/decode.rs b/src/decode.rs index 34082e3..afcb68b 100644 --- a/src/decode.rs +++ b/src/decode.rs @@ -1,122 +1,275 @@ 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; + fn usleep(__useconds: __useconds_t) -> libc::c_int; #[no_mangle] - pub static mut outputbuf: *mut crate::squeezelite_h::buffer; + fn pthread_attr_destroy(__attr: *mut pthread_attr_t) -> libc::c_int; #[no_mangle] - pub static mut stream: crate::squeezelite_h::streamstate; + fn strstr(_: *const libc::c_char, _: *const libc::c_char) + -> *mut libc::c_char; #[no_mangle] - pub static mut output: crate::squeezelite_h::outputstate; + fn pthread_create(__newthread: *mut pthread_t, + __attr: *const pthread_attr_t, + __start_routine: + Option *mut libc::c_void>, + __arg: *mut libc::c_void) -> libc::c_int; + #[no_mangle] + fn pthread_join(__th: pthread_t, __thread_return: *mut *mut libc::c_void) + -> libc::c_int; + #[no_mangle] + fn pthread_attr_init(__attr: *mut pthread_attr_t) -> libc::c_int; + #[no_mangle] + fn register_faad() -> *mut codec; + #[no_mangle] + fn register_vorbis() -> *mut codec; + #[no_mangle] + fn register_flac() -> *mut codec; + #[no_mangle] + fn register_pcm() -> *mut codec; + #[no_mangle] + fn register_mad() -> *mut codec; + #[no_mangle] + fn register_mpg() -> *mut codec; + #[no_mangle] + fn _checkfade(_: bool); + #[no_mangle] + fn wake_controller(); + #[no_mangle] + fn _buf_space(buf: *mut buffer) -> libc::c_uint; + #[no_mangle] + fn _buf_used(buf: *mut buffer) -> libc::c_uint; + #[no_mangle] + fn logprint(fmt: *const libc::c_char, _: ...); + #[no_mangle] + fn logtime() -> *const libc::c_char; + #[no_mangle] + fn pthread_attr_setstacksize(__attr: *mut pthread_attr_t, + __stacksize: size_t) -> libc::c_int; + #[no_mangle] + fn pthread_mutex_unlock(__mutex: *mut pthread_mutex_t) -> libc::c_int; + #[no_mangle] + fn pthread_mutex_lock(__mutex: *mut pthread_mutex_t) -> libc::c_int; + #[no_mangle] + fn pthread_mutex_destroy(__mutex: *mut pthread_mutex_t) -> libc::c_int; + #[no_mangle] + fn pthread_mutex_init(__mutex: *mut pthread_mutex_t, + __mutexattr: *const pthread_mutexattr_t) + -> libc::c_int; + #[no_mangle] + static mut streambuf: *mut buffer; + #[no_mangle] + static mut outputbuf: *mut buffer; + #[no_mangle] + static mut stream: streamstate; + #[no_mangle] + static mut output: outputstate; } -/* +pub type size_t = libc::c_ulong; +pub type __uint8_t = libc::c_uchar; +pub type __int32_t = libc::c_int; +pub type __uint32_t = libc::c_uint; +pub type __uint64_t = libc::c_ulong; +pub type __useconds_t = libc::c_uint; +pub type int32_t = __int32_t; +pub type u_int8_t = __uint8_t; +pub type u_int32_t = __uint32_t; +pub type u_int64_t = __uint64_t; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct __pthread_internal_list { + pub __prev: *mut __pthread_internal_list, + pub __next: *mut __pthread_internal_list, +} +pub type __pthread_list_t = __pthread_internal_list; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct __pthread_mutex_s { + pub __lock: libc::c_int, + pub __count: libc::c_uint, + pub __owner: libc::c_int, + pub __nusers: libc::c_uint, + pub __kind: libc::c_int, + pub __spins: libc::c_short, + pub __elision: libc::c_short, + pub __list: __pthread_list_t, +} +pub type pthread_t = libc::c_ulong; +#[derive(Copy, Clone)] +#[repr(C)] +pub union pthread_mutexattr_t { + pub __size: [libc::c_char; 4], + pub __align: libc::c_int, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub union pthread_attr_t { + pub __size: [libc::c_char; 56], + pub __align: libc::c_long, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub union pthread_mutex_t { + pub __data: __pthread_mutex_s, + pub __size: [libc::c_char; 40], + pub __align: libc::c_long, +} +pub type u8_t = u_int8_t; +pub type u32_t = u_int32_t; +pub type u64_t = u_int64_t; +pub type s32_t = int32_t; +pub type frames_t = u32_t; +pub type log_level = libc::c_uint; +pub const lSDEBUG: log_level = 4; +pub const lDEBUG: log_level = 3; +pub const lINFO: log_level = 2; +pub const lWARN: log_level = 1; +pub const lERROR: log_level = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct buffer { + pub buf: *mut u8_t, + pub readp: *mut u8_t, + pub writep: *mut u8_t, + pub wrap: *mut u8_t, + pub size: size_t, + pub base_size: size_t, + pub mutex: pthread_mutex_t, +} +pub type stream_state = libc::c_uint; +pub const RECV_HEADERS: stream_state = 7; +pub const SEND_HEADERS: stream_state = 6; +pub const STREAMING_HTTP: stream_state = 5; +pub const STREAMING_FILE: stream_state = 4; +pub const STREAMING_BUFFERING: stream_state = 3; +pub const STREAMING_WAIT: stream_state = 2; +pub const DISCONNECT: stream_state = 1; +pub const STOPPED: stream_state = 0; +pub type disconnect_code = libc::c_uint; +pub const TIMEOUT: disconnect_code = 4; +pub const UNREACHABLE: disconnect_code = 3; +pub const REMOTE_DISCONNECT: disconnect_code = 2; +pub const LOCAL_DISCONNECT: disconnect_code = 1; +pub const DISCONNECT_OK: disconnect_code = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct streamstate { + pub state: stream_state, + pub disconnect: disconnect_code, + pub header: *mut libc::c_char, + pub header_len: size_t, + pub sent_headers: bool, + pub cont_wait: bool, + pub bytes: u64_t, + pub threshold: libc::c_uint, + pub meta_interval: u32_t, + pub meta_next: u32_t, + pub meta_left: u32_t, + pub meta_send: bool, +} +pub type decode_state = libc::c_uint; +pub const DECODE_ERROR: decode_state = 4; +pub const DECODE_COMPLETE: decode_state = 3; +pub const DECODE_RUNNING: decode_state = 2; +pub const DECODE_READY: decode_state = 1; +pub const DECODE_STOPPED: decode_state = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct decodestate { + pub state: decode_state, + pub new_stream: bool, + pub mutex: pthread_mutex_t, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct codec { + pub id: libc::c_char, + pub types: *mut libc::c_char, + pub min_read_bytes: libc::c_uint, + pub min_space: libc::c_uint, + pub open: Option ()>, + pub close: Option ()>, + pub decode: Option decode_state>, +} +pub type fade_mode = libc::c_uint; +pub const FADE_INOUT: fade_mode = 4; +pub const FADE_OUT: fade_mode = 3; +pub const FADE_IN: fade_mode = 2; +pub const FADE_CROSSFADE: fade_mode = 1; +pub const FADE_NONE: fade_mode = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct outputstate { + pub state: output_state, + pub format: output_format, + pub device: *const libc::c_char, + pub buffer: libc::c_uint, + pub period: libc::c_uint, + pub track_started: bool, + pub write_cb: Option libc::c_int>, + pub start_frames: libc::c_uint, + pub frames_played: libc::c_uint, + pub frames_played_dmp: libc::c_uint, + pub current_sample_rate: libc::c_uint, + pub supported_rates: [libc::c_uint; 18], + pub default_sample_rate: libc::c_uint, + pub error_opening: bool, + pub device_frames: libc::c_uint, + pub updated: u32_t, + pub track_start_time: u32_t, + pub current_replay_gain: u32_t, + pub c2rust_unnamed: C2RustUnnamed, + pub next_sample_rate: libc::c_uint, + pub track_start: *mut u8_t, + pub gainL: u32_t, + pub gainR: u32_t, + pub invert: bool, + pub next_replay_gain: u32_t, + pub threshold: libc::c_uint, + pub fade: fade_state, + pub fade_start: *mut u8_t, + pub fade_end: *mut u8_t, + pub fade_dir: fade_dir, + pub fade_mode: fade_mode, + pub fade_secs: libc::c_uint, + pub rate_delay: libc::c_uint, + pub delay_active: bool, + pub stop_time: u32_t, + pub idle_to: u32_t, +} +pub type fade_dir = libc::c_uint; +pub const FADE_CROSS: fade_dir = 3; +pub const FADE_DOWN: fade_dir = 2; +pub const FADE_UP: fade_dir = 1; +pub type fade_state = libc::c_uint; +pub const FADE_ACTIVE: fade_state = 2; +pub const FADE_DUE: fade_state = 1; +pub const FADE_INACTIVE: fade_state = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub union C2RustUnnamed { + pub pause_frames: u32_t, + pub skip_frames: u32_t, + pub start_at: u32_t, +} +pub type output_format = libc::c_uint; +pub const S16_LE: output_format = 3; +pub const S24_3LE: output_format = 2; +pub const S24_LE: output_format = 1; +pub const S32_LE: output_format = 0; +pub type output_state = libc::c_int; +pub const OUTPUT_START_AT: output_state = 5; +pub const OUTPUT_SKIP_FRAMES: output_state = 4; +pub const OUTPUT_PAUSE_FRAMES: output_state = 3; +pub const OUTPUT_RUNNING: output_state = 2; +pub const OUTPUT_BUFFER: output_state = 1; +pub const OUTPUT_STOPPED: output_state = 0; +pub const OUTPUT_OFF: output_state = -1; +/* * Squeezelite - lightweight headless squeezebox emulator * * (c) Adrian Smith 2012-2015, triode1@btinternet.com @@ -126,7 +279,7 @@ extern "C" { * 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 @@ -138,138 +291,119 @@ extern "C" { */ // decode thread #[no_mangle] - -pub static mut loglevel: crate::squeezelite_h::log_level = crate::squeezelite_h::lERROR; +pub static mut loglevel: log_level = 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, - }, - }, - }, -}; +pub static mut decode: decodestate = + decodestate{state: DECODE_STOPPED, + new_stream: false, + mutex: + pthread_mutex_t{__data: + __pthread_mutex_s{__lock: 0, + __count: 0, + __owner: 0, + __nusers: 0, + __kind: 0, + __spins: 0, + __elision: 0, + __list: + __pthread_list_t{__prev: + 0 + as + *const __pthread_internal_list + as + *mut __pthread_internal_list, + __next: + 0 + as + *const __pthread_internal_list + as + *mut __pthread_internal_list,},},},}; #[no_mangle] - -pub static mut codecs: [*mut crate::squeezelite_h::codec; 10] = - [0 as *const crate::squeezelite_h::codec as *mut crate::squeezelite_h::codec; 10]; +pub static mut codecs: [*mut codec; 10] = + [0 as *const codec as *mut 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; - +pub static mut codec: *mut codec = 0 as *const codec as *mut codec; +static mut flac_container: u8_t = '?' as i32 as u8_t; static mut running: bool = 1 as libc::c_int != 0; - unsafe extern "C" fn decode_thread() -> *mut libc::c_void { while running { - let mut bytes: 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 bytes: size_t = 0; + let mut space: size_t = 0; + let mut min_space: size_t = 0; let mut toend: bool = false; - let mut ran = 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, - ); + let mut ran: bool = 0 as libc::c_int != 0; + pthread_mutex_lock(&mut (*streambuf).mutex); + bytes = _buf_used(streambuf) as size_t; + toend = + stream.state as libc::c_uint <= + DISCONNECT as libc::c_int as libc::c_uint; + pthread_mutex_unlock(&mut (*streambuf).mutex); + pthread_mutex_lock(&mut (*outputbuf).mutex); + space = _buf_space(outputbuf) as size_t; + pthread_mutex_unlock(&mut (*outputbuf).mutex); + pthread_mutex_lock(&mut decode.mutex); + if decode.state as libc::c_uint == + DECODE_RUNNING as libc::c_int as libc::c_uint && + !codec.is_null() { + if loglevel as libc::c_uint >= + lSDEBUG as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d streambuf bytes: %u outputbuf space: %u\n\x00" + as *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 14], + &[libc::c_char; 14]>(b"decode_thread\x00")).as_ptr(), + 76 as libc::c_int, bytes, space); } - min_space = (*codec).min_space as 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 - }, - ); + min_space = (*codec).min_space as size_t; + if space > min_space && + (bytes > (*codec).min_read_bytes as libc::c_ulong || + toend as libc::c_int != 0) { + decode.state = + (*codec).decode.expect("non-null function pointer")(); + if decode.state as libc::c_uint != + DECODE_RUNNING as libc::c_int as libc::c_uint { + if loglevel as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d decode %s\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 14], + &[libc::c_char; 14]>(b"decode_thread\x00")).as_ptr(), + 101 as libc::c_int, + if decode.state as libc::c_uint == + DECODE_COMPLETE as libc::c_int as + libc::c_uint { + b"complete\x00" as *const u8 as + *const libc::c_char + } else { + b"error\x00" as *const u8 as + *const libc::c_char + }); } - crate::stdlib::pthread_mutex_lock(&mut (*outputbuf).mutex); + pthread_mutex_lock(&mut (*outputbuf).mutex); if output.fade_mode as u64 != 0 { - crate::src::output::_checkfade(0 as libc::c_int != 0); + _checkfade(0 as libc::c_int != 0); } - crate::stdlib::pthread_mutex_unlock(&mut (*outputbuf).mutex); - crate::src::slimproto::wake_controller(); + pthread_mutex_unlock(&mut (*outputbuf).mutex); + 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); - } + pthread_mutex_unlock(&mut decode.mutex); + if !ran { usleep(100000 as libc::c_int as __useconds_t); } } return 0 as *mut libc::c_void; } - -unsafe extern "C" fn sort_codecs(mut pry: libc::c_int, mut ptr: *mut crate::squeezelite_h::codec) { +unsafe extern "C" fn sort_codecs(mut pry: libc::c_int, mut ptr: *mut codec) { static mut priority: [libc::c_int; 10] = [0; 10]; let mut i: libc::c_int = 0; let mut tpry: libc::c_int = 0; - let mut tptr = 0 as *mut crate::squeezelite_h::codec; + let mut tptr: *mut codec = 0 as *mut codec; i = 0 as libc::c_int; while i < 10 as libc::c_int { if codecs[i as usize].is_null() { codecs[i as usize] = ptr; priority[i as usize] = pry; - return; + return } if pry < priority[i as usize] { tptr = codecs[i as usize]; @@ -280,290 +414,231 @@ unsafe extern "C" fn sort_codecs(mut pry: libc::c_int, mut ptr: *mut crate::sque pry = tpry } i += 1 - } + }; } - -static mut thread: crate::stdlib::pthread_t = 0; +static mut thread: 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, -) { +pub unsafe extern "C" fn decode_init(mut level: log_level, + mut include_codecs: *const libc::c_char, + mut exclude_codecs: + *const libc::c_char) { let mut i: libc::c_int = 0; - let mut order_codecs = 0 as *mut libc::c_char; + let mut order_codecs: *mut libc::c_char = 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, - ); + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d init decode\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 12], + &[libc::c_char; 12]>(b"decode_init\x00")).as_ptr(), + 154 as libc::c_int); } // register codecs - // dsf,dff,alc,wma,wmap,wmal,aac,spt,ogg,ogf,flc,aif,pcm,mp3 + // 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 strstr(exclude_codecs, + b"aac\x00" as *const u8 as *const libc::c_char).is_null() && + (include_codecs.is_null() || + { + order_codecs = + strstr(include_codecs, + b"aac\x00" as *const u8 as + *const libc::c_char); + !order_codecs.is_null() + }) { + sort_codecs(if !include_codecs.is_null() { + order_codecs.wrapping_offset_from(include_codecs) as + libc::c_long + } else { i as libc::c_long } as libc::c_int, + register_faad()); } - if 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 strstr(exclude_codecs, + b"ogg\x00" as *const u8 as *const libc::c_char).is_null() && + (include_codecs.is_null() || + { + order_codecs = + strstr(include_codecs, + b"ogg\x00" as *const u8 as + *const libc::c_char); + !order_codecs.is_null() + }) { + sort_codecs(if !include_codecs.is_null() { + order_codecs.wrapping_offset_from(include_codecs) as + libc::c_long + } else { i as libc::c_long } as libc::c_int, + register_vorbis()); } - if 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 strstr(exclude_codecs, + b"flac\x00" as *const u8 as *const libc::c_char).is_null() && + (include_codecs.is_null() || + { + order_codecs = + strstr(include_codecs, + b"flac\x00" as *const u8 as + *const libc::c_char); + !order_codecs.is_null() + }) { + sort_codecs(if !include_codecs.is_null() { + order_codecs.wrapping_offset_from(include_codecs) as + libc::c_long + } else { i as libc::c_long } as libc::c_int, + register_flac()); } - if 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(), - ); + if strstr(exclude_codecs, + b"pcm\x00" as *const u8 as *const libc::c_char).is_null() && + (include_codecs.is_null() || + { + order_codecs = + strstr(include_codecs, + b"pcm\x00" as *const u8 as + *const libc::c_char); + !order_codecs.is_null() + }) { + sort_codecs(if !include_codecs.is_null() { + order_codecs.wrapping_offset_from(include_codecs) as + libc::c_long + } else { i as libc::c_long } as libc::c_int, + register_pcm()); } // try mad then mpg for mp3 unless command line option passed - if !(!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 !(!strstr(exclude_codecs, + b"mp3\x00" as *const u8 as *const libc::c_char).is_null() || + !strstr(exclude_codecs, + b"mad\x00" as *const u8 as + *const libc::c_char).is_null()) && + (include_codecs.is_null() || + { + order_codecs = + strstr(include_codecs, + b"mp3\x00" as *const u8 as + *const libc::c_char); + !order_codecs.is_null() + } || + { + order_codecs = + strstr(include_codecs, + b"mad\x00" as *const u8 as + *const libc::c_char); + !order_codecs.is_null() + }) { + sort_codecs(if !include_codecs.is_null() { + order_codecs.wrapping_offset_from(include_codecs) as + libc::c_long + } else { i as libc::c_long } as libc::c_int, + register_mad()); + } else if !(!strstr(exclude_codecs, + b"mp3\x00" as *const u8 as + *const libc::c_char).is_null() || + !strstr(exclude_codecs, + b"mpg\x00" as *const u8 as + *const libc::c_char).is_null()) && + (include_codecs.is_null() || + { + order_codecs = + strstr(include_codecs, + b"mp3\x00" as *const u8 as + *const libc::c_char); + !order_codecs.is_null() + } || + { + order_codecs = + strstr(include_codecs, + b"mpg\x00" as *const u8 as + *const libc::c_char); + !order_codecs.is_null() + }) { + sort_codecs(if !include_codecs.is_null() { + order_codecs.wrapping_offset_from(include_codecs) as + libc::c_long + } else { i as libc::c_long } as libc::c_int, + register_mpg()); } - if loglevel as libc::c_uint >= 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, - ); + if loglevel as libc::c_uint >= lDEBUG as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d include codecs: %s exclude codecs: %s\n\x00" as + *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 12], + &[libc::c_char; 12]>(b"decode_init\x00")).as_ptr(), + 195 as libc::c_int, + if !include_codecs.is_null() { + include_codecs + } else { b"\x00" as *const u8 as *const libc::c_char }, + exclude_codecs); } - 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 *mut libc::c_void>, - Option *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); + pthread_mutex_init(&mut decode.mutex, 0 as *const pthread_mutexattr_t); + let mut attr: pthread_attr_t = pthread_attr_t{__size: [0; 56],}; + pthread_attr_init(&mut attr); + pthread_attr_setstacksize(&mut attr, + (16384 as libc::c_int + + 128 as libc::c_int * 1024 as libc::c_int) + as size_t); + pthread_create(&mut thread, &mut attr, + ::std::mem::transmute:: *mut libc::c_void>, + Option + *mut libc::c_void>>(Some(::std::mem::transmute:: + *mut libc::c_void, + unsafe extern "C" fn() + -> + *mut libc::c_void>(decode_thread))), + 0 as *mut libc::c_void); + pthread_attr_destroy(&mut attr); decode.new_stream = 1 as libc::c_int != 0; - decode.state = crate::squeezelite_h::DECODE_STOPPED; + decode.state = 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, - ); + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d close decode\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 13], + &[libc::c_char; 13]>(b"decode_close\x00")).as_ptr(), + 222 as libc::c_int); } - crate::stdlib::pthread_mutex_lock(&mut decode.mutex); + 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 + codec = 0 as *mut 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); + pthread_mutex_unlock(&mut decode.mutex); + pthread_join(thread, 0 as *mut *mut libc::c_void); + pthread_mutex_destroy(&mut decode.mutex); } #[no_mangle] - pub unsafe extern "C" fn decode_flush() { - if loglevel as libc::c_uint >= 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, - ); + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d decode flush\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 13], + &[libc::c_char; 13]>(b"decode_flush\x00")).as_ptr(), + 237 as libc::c_int); } - crate::stdlib::pthread_mutex_lock(&mut decode.mutex); - decode.state = crate::squeezelite_h::DECODE_STOPPED; - crate::stdlib::pthread_mutex_unlock(&mut decode.mutex); + pthread_mutex_lock(&mut decode.mutex); + decode.state = DECODE_STOPPED; + pthread_mutex_unlock(&mut decode.mutex); } #[no_mangle] - -pub unsafe extern "C" fn decode_newstream( - mut sample_rate: libc::c_uint, - mut supported_rates: *mut libc::c_uint, -) -> libc::c_uint { +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 + // 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 @@ -593,53 +668,41 @@ pub unsafe extern "C" fn decode_newstream( // 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, -) { +pub unsafe extern "C" fn codec_open(mut format: u8_t, mut sample_size: u8_t, + mut sample_rate: u8_t, mut channels: u8_t, + mut endianness: u8_t) { let mut i: libc::c_int = 0; - if loglevel as libc::c_uint >= 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, - ); + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d codec open: \'%c\'\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 11], + &[libc::c_char; 11]>(b"codec_open\x00")).as_ptr(), + 265 as libc::c_int, format as libc::c_int); } - crate::stdlib::pthread_mutex_lock(&mut decode.mutex); + pthread_mutex_lock(&mut decode.mutex); decode.new_stream = 1 as libc::c_int != 0; - decode.state = crate::squeezelite_h::DECODE_STOPPED; + decode.state = DECODE_STOPPED; // potentially changed within codec when processing enabled // find the required codec i = 0 as libc::c_int; while i < 10 as libc::c_int { - if !codecs[i as usize].is_null() - && (*codecs[i as usize]).id as libc::c_int == format as libc::c_int - { + 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, - ); + if !codec.is_null() && + (codec != codecs[i as usize] || + (*codecs[i as usize]).id as libc::c_int == 'f' as i32 + && + flac_container as libc::c_int != + sample_size as libc::c_int) { + if loglevel as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d closing codec: \'%c\'\n\x00" as + *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 11], + &[libc::c_char; 11]>(b"codec_open\x00")).as_ptr(), + 283 as libc::c_int, (*codec).id as libc::c_int); } (*codec).close.expect("non-null function pointer")(); } @@ -647,23 +710,20 @@ pub unsafe extern "C" fn codec_open( 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; + (*codec).open.expect("non-null function pointer")(sample_size, + sample_rate, + channels, + endianness); + decode.state = DECODE_READY; + pthread_mutex_unlock(&mut decode.mutex); + return } i += 1 } - 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, - ); + pthread_mutex_unlock(&mut decode.mutex); + logprint(b"%s %s:%d codec not found\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 11], + &[libc::c_char; 11]>(b"codec_open\x00")).as_ptr(), + 303 as libc::c_int); } diff --git a/src/faad.rs b/src/faad.rs index 4016806..f631431 100644 --- a/src/faad.rs +++ b/src/faad.rs @@ -1,482 +1,580 @@ 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::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::sscanf; -pub use crate::stdlib::NeAACDecConfiguration; -pub use crate::stdlib::NeAACDecConfigurationPtr; -pub use crate::stdlib::NeAACDecFrameInfo; -pub use crate::stdlib::NeAACDecHandle; - -use crate::stdlib::dlerror; -use crate::stdlib::dlopen; -use crate::stdlib::dlsym; -use crate::stdlib::free; -use crate::stdlib::malloc; -use crate::stdlib::memcmp; -use crate::stdlib::memcpy; -use crate::stdlib::pthread_mutex_lock; -use crate::stdlib::pthread_mutex_unlock; -use crate::stdlib::strcmp; extern "C" { #[no_mangle] - pub static mut loglevel: crate::squeezelite_h::log_level; + fn sscanf(_: *const libc::c_char, _: *const libc::c_char, _: ...) + -> libc::c_int; #[no_mangle] - pub static mut streambuf: *mut crate::squeezelite_h::buffer; + fn malloc(_: libc::c_ulong) -> *mut libc::c_void; #[no_mangle] - pub static mut outputbuf: *mut crate::squeezelite_h::buffer; + fn free(__ptr: *mut libc::c_void); #[no_mangle] - pub static mut stream: crate::squeezelite_h::streamstate; + fn memcpy(_: *mut libc::c_void, _: *const libc::c_void, _: libc::c_ulong) + -> *mut libc::c_void; #[no_mangle] - pub static mut output: crate::squeezelite_h::outputstate; + fn memcmp(_: *const libc::c_void, _: *const libc::c_void, + _: libc::c_ulong) -> libc::c_int; #[no_mangle] - pub static mut decode: crate::squeezelite_h::decodestate; + fn strcmp(_: *const libc::c_char, _: *const libc::c_char) -> libc::c_int; + #[no_mangle] + fn dlopen(__file: *const libc::c_char, __mode: libc::c_int) + -> *mut libc::c_void; + #[no_mangle] + fn dlsym(__handle: *mut libc::c_void, __name: *const libc::c_char) + -> *mut libc::c_void; + #[no_mangle] + fn dlerror() -> *mut libc::c_char; + #[no_mangle] + fn pthread_mutex_lock(__mutex: *mut pthread_mutex_t) -> libc::c_int; + #[no_mangle] + fn pthread_mutex_unlock(__mutex: *mut pthread_mutex_t) -> libc::c_int; + #[no_mangle] + fn logtime() -> *const libc::c_char; + #[no_mangle] + fn logprint(fmt: *const libc::c_char, _: ...); + #[no_mangle] + fn unpackN(src: *mut u32_t) -> u32_t; + #[no_mangle] + fn _buf_used(buf: *mut buffer) -> libc::c_uint; + #[no_mangle] + fn _buf_cont_read(buf: *mut buffer) -> libc::c_uint; + #[no_mangle] + fn _buf_cont_write(buf: *mut buffer) -> libc::c_uint; + #[no_mangle] + fn _buf_inc_readp(buf: *mut buffer, by: libc::c_uint); + #[no_mangle] + fn _buf_inc_writep(buf: *mut buffer, by: libc::c_uint); + #[no_mangle] + fn decode_newstream(sample_rate: libc::c_uint, + supported_rates: *mut libc::c_uint) -> libc::c_uint; + #[no_mangle] + fn _checkfade(_: bool); + #[no_mangle] + static mut loglevel: log_level; + #[no_mangle] + static mut streambuf: *mut buffer; + #[no_mangle] + static mut outputbuf: *mut buffer; + #[no_mangle] + static mut stream: streamstate; + #[no_mangle] + static mut output: outputstate; + #[no_mangle] + static mut decode: decodestate; } - -#[repr(C)] +pub type size_t = libc::c_ulong; +pub type __uint8_t = libc::c_uchar; +pub type __int32_t = libc::c_int; +pub type __uint32_t = libc::c_uint; +pub type __uint64_t = libc::c_ulong; +pub type int32_t = __int32_t; +pub type u_int8_t = __uint8_t; +pub type u_int32_t = __uint32_t; +pub type u_int64_t = __uint64_t; #[derive(Copy, Clone)] +#[repr(C)] +pub struct __pthread_internal_list { + pub __prev: *mut __pthread_internal_list, + pub __next: *mut __pthread_internal_list, +} +pub type __pthread_list_t = __pthread_internal_list; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct __pthread_mutex_s { + pub __lock: libc::c_int, + pub __count: libc::c_uint, + pub __owner: libc::c_int, + pub __nusers: libc::c_uint, + pub __kind: libc::c_int, + pub __spins: libc::c_short, + pub __elision: libc::c_short, + pub __list: __pthread_list_t, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub union pthread_mutex_t { + pub __data: __pthread_mutex_s, + pub __size: [libc::c_char; 40], + pub __align: libc::c_long, +} +pub type u8_t = u_int8_t; +pub type u32_t = u_int32_t; +pub type u64_t = u_int64_t; +pub type s32_t = int32_t; +pub type frames_t = u32_t; +pub type log_level = libc::c_uint; +pub const lSDEBUG: log_level = 4; +pub const lDEBUG: log_level = 3; +pub const lINFO: log_level = 2; +pub const lWARN: log_level = 1; +pub const lERROR: log_level = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct buffer { + pub buf: *mut u8_t, + pub readp: *mut u8_t, + pub writep: *mut u8_t, + pub wrap: *mut u8_t, + pub size: size_t, + pub base_size: size_t, + pub mutex: pthread_mutex_t, +} +pub type stream_state = libc::c_uint; +pub const RECV_HEADERS: stream_state = 7; +pub const SEND_HEADERS: stream_state = 6; +pub const STREAMING_HTTP: stream_state = 5; +pub const STREAMING_FILE: stream_state = 4; +pub const STREAMING_BUFFERING: stream_state = 3; +pub const STREAMING_WAIT: stream_state = 2; +pub const DISCONNECT: stream_state = 1; +pub const STOPPED: stream_state = 0; +pub type disconnect_code = libc::c_uint; +pub const TIMEOUT: disconnect_code = 4; +pub const UNREACHABLE: disconnect_code = 3; +pub const REMOTE_DISCONNECT: disconnect_code = 2; +pub const LOCAL_DISCONNECT: disconnect_code = 1; +pub const DISCONNECT_OK: disconnect_code = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct streamstate { + pub state: stream_state, + pub disconnect: disconnect_code, + pub header: *mut libc::c_char, + pub header_len: size_t, + pub sent_headers: bool, + pub cont_wait: bool, + pub bytes: u64_t, + pub threshold: libc::c_uint, + pub meta_interval: u32_t, + pub meta_next: u32_t, + pub meta_left: u32_t, + pub meta_send: bool, +} +pub type decode_state = libc::c_uint; +pub const DECODE_ERROR: decode_state = 4; +pub const DECODE_COMPLETE: decode_state = 3; +pub const DECODE_RUNNING: decode_state = 2; +pub const DECODE_READY: decode_state = 1; +pub const DECODE_STOPPED: decode_state = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct decodestate { + pub state: decode_state, + pub new_stream: bool, + pub mutex: pthread_mutex_t, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct codec { + pub id: libc::c_char, + pub types: *mut libc::c_char, + pub min_read_bytes: libc::c_uint, + pub min_space: libc::c_uint, + pub open: Option ()>, + pub close: Option ()>, + pub decode: Option decode_state>, +} +pub type output_state = libc::c_int; +pub const OUTPUT_START_AT: output_state = 5; +pub const OUTPUT_SKIP_FRAMES: output_state = 4; +pub const OUTPUT_PAUSE_FRAMES: output_state = 3; +pub const OUTPUT_RUNNING: output_state = 2; +pub const OUTPUT_BUFFER: output_state = 1; +pub const OUTPUT_STOPPED: output_state = 0; +pub const OUTPUT_OFF: output_state = -1; +pub type output_format = libc::c_uint; +pub const S16_LE: output_format = 3; +pub const S24_3LE: output_format = 2; +pub const S24_LE: output_format = 1; +pub const S32_LE: output_format = 0; +pub type fade_state = libc::c_uint; +pub const FADE_ACTIVE: fade_state = 2; +pub const FADE_DUE: fade_state = 1; +pub const FADE_INACTIVE: fade_state = 0; +pub type fade_dir = libc::c_uint; +pub const FADE_CROSS: fade_dir = 3; +pub const FADE_DOWN: fade_dir = 2; +pub const FADE_UP: fade_dir = 1; +pub type fade_mode = libc::c_uint; +pub const FADE_INOUT: fade_mode = 4; +pub const FADE_OUT: fade_mode = 3; +pub const FADE_IN: fade_mode = 2; +pub const FADE_CROSSFADE: fade_mode = 1; +pub const FADE_NONE: fade_mode = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct outputstate { + pub state: output_state, + pub format: output_format, + pub device: *const libc::c_char, + pub buffer: libc::c_uint, + pub period: libc::c_uint, + pub track_started: bool, + pub write_cb: Option libc::c_int>, + pub start_frames: libc::c_uint, + pub frames_played: libc::c_uint, + pub frames_played_dmp: libc::c_uint, + pub current_sample_rate: libc::c_uint, + pub supported_rates: [libc::c_uint; 18], + pub default_sample_rate: libc::c_uint, + pub error_opening: bool, + pub device_frames: libc::c_uint, + pub updated: u32_t, + pub track_start_time: u32_t, + pub current_replay_gain: u32_t, + pub c2rust_unnamed: C2RustUnnamed, + pub next_sample_rate: libc::c_uint, + pub track_start: *mut u8_t, + pub gainL: u32_t, + pub gainR: u32_t, + pub invert: bool, + pub next_replay_gain: u32_t, + pub threshold: libc::c_uint, + pub fade: fade_state, + pub fade_start: *mut u8_t, + pub fade_end: *mut u8_t, + pub fade_dir: fade_dir, + pub fade_mode: fade_mode, + pub fade_secs: libc::c_uint, + pub rate_delay: libc::c_uint, + pub delay_active: bool, + pub stop_time: u32_t, + pub idle_to: u32_t, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub union C2RustUnnamed { + pub pause_frames: u32_t, + pub skip_frames: u32_t, + pub start_at: u32_t, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct NeAACDecFrameInfo { + pub bytesconsumed: libc::c_ulong, + pub samples: libc::c_ulong, + pub channels: libc::c_uchar, + pub error: libc::c_uchar, + pub samplerate: libc::c_ulong, + pub sbr: libc::c_uchar, + pub object_type: libc::c_uchar, + pub header_type: libc::c_uchar, + pub num_front_channels: libc::c_uchar, + pub num_side_channels: libc::c_uchar, + pub num_back_channels: libc::c_uchar, + pub num_lfe_channels: libc::c_uchar, + pub channel_position: [libc::c_uchar; 64], + pub ps: libc::c_uchar, +} +#[derive(Copy, Clone)] +#[repr(C)] pub struct faad { - pub hAac: crate::stdlib::NeAACDecHandle, - pub type_0: crate::squeezelite_h::u8_t, - pub consume: crate::squeezelite_h::u32_t, - pub pos: crate::squeezelite_h::u32_t, - pub sample: crate::squeezelite_h::u32_t, - pub nextchunk: crate::squeezelite_h::u32_t, + pub hAac: NeAACDecHandle, + pub type_0: u8_t, + pub consume: u32_t, + pub pos: u32_t, + pub sample: u32_t, + pub nextchunk: u32_t, pub stsc: *mut libc::c_void, - pub skip: crate::squeezelite_h::u32_t, - pub samples: crate::squeezelite_h::u64_t, - pub sttssamples: crate::squeezelite_h::u64_t, + pub skip: u32_t, + pub samples: u64_t, + pub sttssamples: u64_t, pub empty: bool, pub chunkinfo: *mut chunk_table, - pub NeAACDecGetCurrentConfiguration: Option< - unsafe extern "C" fn( - _: crate::stdlib::NeAACDecHandle, - ) -> crate::stdlib::NeAACDecConfigurationPtr, - >, - pub NeAACDecSetConfiguration: Option< - unsafe extern "C" fn( - _: crate::stdlib::NeAACDecHandle, - _: crate::stdlib::NeAACDecConfigurationPtr, - ) -> libc::c_uchar, - >, - pub NeAACDecOpen: Option crate::stdlib::NeAACDecHandle>, - pub NeAACDecClose: Option ()>, - pub NeAACDecInit: Option< - unsafe extern "C" fn( - _: crate::stdlib::NeAACDecHandle, - _: *mut libc::c_uchar, - _: libc::c_ulong, - _: *mut libc::c_ulong, - _: *mut libc::c_uchar, - ) -> libc::c_long, - >, - pub NeAACDecInit2: Option< - unsafe extern "C" fn( - _: crate::stdlib::NeAACDecHandle, - _: *mut libc::c_uchar, - _: libc::c_ulong, - _: *mut libc::c_ulong, - _: *mut libc::c_uchar, - ) -> libc::c_char, - >, - pub NeAACDecDecode: Option< - unsafe extern "C" fn( - _: crate::stdlib::NeAACDecHandle, - _: *mut crate::stdlib::NeAACDecFrameInfo, - _: *mut libc::c_uchar, - _: libc::c_ulong, - ) -> *mut libc::c_void, - >, - pub NeAACDecGetErrorMessage: - Option *mut libc::c_char>, + pub NeAACDecGetCurrentConfiguration: Option + NeAACDecConfigurationPtr>, + pub NeAACDecSetConfiguration: Option libc::c_uchar>, + pub NeAACDecOpen: Option NeAACDecHandle>, + pub NeAACDecClose: Option ()>, + pub NeAACDecInit: Option libc::c_long>, + pub NeAACDecInit2: Option libc::c_char>, + pub NeAACDecDecode: Option *mut libc::c_void>, + pub NeAACDecGetErrorMessage: Option *mut libc::c_char>, } - -#[repr(C)] +pub type NeAACDecHandle = *mut libc::c_void; +pub type NeAACDecConfigurationPtr = *mut NeAACDecConfiguration; #[derive(Copy, Clone)] -pub struct chunk_table { - pub sample: crate::squeezelite_h::u32_t, - pub offset: crate::squeezelite_h::u32_t, +#[repr(C)] +pub struct NeAACDecConfiguration { + pub defObjectType: libc::c_uchar, + pub defSampleRate: libc::c_ulong, + pub outputFormat: libc::c_uchar, + pub downMatrix: libc::c_uchar, + pub useOldADTSFormat: libc::c_uchar, + pub dontUpSampleImplicitSBR: libc::c_uchar, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct chunk_table { + pub sample: u32_t, + pub offset: u32_t, } - static mut a: *mut faad = 0 as *const faad as *mut faad; // minimal code for mp4 file parsing to extract audio config and find media data // adapted from faad2/common/mp4ff #[no_mangle] - -pub unsafe extern "C" fn mp4_desc_length( - mut buf: *mut *mut crate::squeezelite_h::u8_t, -) -> crate::squeezelite_h::u32_t { - let mut b: crate::squeezelite_h::u8_t = 0; - let mut num_bytes = 0 as libc::c_int as crate::squeezelite_h::u8_t; - let mut length = 0 as libc::c_int as crate::squeezelite_h::u32_t; - loop { +pub unsafe extern "C" fn mp4_desc_length(mut buf: *mut *mut u8_t) -> u32_t { + let mut b: u8_t = 0; + let mut num_bytes: u8_t = 0 as libc::c_int as u8_t; + let mut length: u32_t = 0 as libc::c_int as u32_t; + loop { b = **buf; *buf = (*buf).offset(1 as libc::c_int as isize); num_bytes = num_bytes.wrapping_add(1); length = - length << 7 as libc::c_int | (b as libc::c_int & 0x7f as libc::c_int) as libc::c_uint; - if !(b as libc::c_int & 0x80 as libc::c_int != 0 - && (num_bytes as libc::c_int) < 4 as libc::c_int) - { - break; + length << 7 as libc::c_int | + (b as libc::c_int & 0x7f as libc::c_int) as libc::c_uint; + if !(b as libc::c_int & 0x80 as libc::c_int != 0 && + (num_bytes as libc::c_int) < 4 as libc::c_int) { + break ; } } return length; } // read mp4 header to extract config data - -unsafe extern "C" fn read_mp4_header( - mut samplerate_p: *mut libc::c_ulong, - mut channels_p: *mut libc::c_uchar, -) -> libc::c_int { - let mut 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; +unsafe extern "C" fn read_mp4_header(mut samplerate_p: *mut libc::c_ulong, + mut channels_p: *mut libc::c_uchar) + -> libc::c_int { + let mut bytes: size_t = + if _buf_used(streambuf) < _buf_cont_read(streambuf) { + _buf_used(streambuf) + } else { _buf_cont_read(streambuf) } as size_t; let mut type_0: [libc::c_char; 5] = [0; 5]; - let mut len: crate::squeezelite_h::u32_t = 0; + let mut len: u32_t = 0; while bytes >= 8 as libc::c_int as libc::c_ulong { // count trak to find the first playable one static mut trak: libc::c_uint = 0; static mut play: libc::c_uint = 0; - let mut consume: crate::squeezelite_h::u32_t = 0; - len = crate::src::utils::unpackN((*streambuf).readp as *mut crate::squeezelite_h::u32_t); - crate::stdlib::memcpy( - type_0.as_mut_ptr() as *mut libc::c_void, - (*streambuf).readp.offset(4 as libc::c_int as isize) as *const libc::c_void, - 4 as libc::c_int as libc::c_ulong, - ); + let mut consume: u32_t = 0; + len = unpackN((*streambuf).readp as *mut u32_t); + memcpy(type_0.as_mut_ptr() as *mut libc::c_void, + (*streambuf).readp.offset(4 as libc::c_int as isize) as + *const libc::c_void, 4 as libc::c_int as libc::c_ulong); type_0[4 as libc::c_int as usize] = '\u{0}' as i32 as libc::c_char; - if crate::stdlib::strcmp( - type_0.as_mut_ptr(), - b"moov\x00" as *const u8 as *const libc::c_char, - ) == 0 - { + if strcmp(type_0.as_mut_ptr(), + b"moov\x00" as *const u8 as *const libc::c_char) == 0 { trak = 0 as libc::c_int as libc::c_uint; play = 0 as libc::c_int as libc::c_uint } - if crate::stdlib::strcmp( - type_0.as_mut_ptr(), - b"trak\x00" as *const u8 as *const libc::c_char, - ) == 0 - { + if strcmp(type_0.as_mut_ptr(), + b"trak\x00" as *const u8 as *const libc::c_char) == 0 { trak = trak.wrapping_add(1) } // extract audio config from within esds and pass to DecInit2 - if crate::stdlib::strcmp( - type_0.as_mut_ptr(), - b"esds\x00" as *const u8 as *const libc::c_char, - ) == 0 - && bytes > len as libc::c_ulong - { + if strcmp(type_0.as_mut_ptr(), + b"esds\x00" as *const u8 as *const libc::c_char) == 0 && + bytes > len as libc::c_ulong { let mut config_len: libc::c_uint = 0; - let mut ptr = (*streambuf).readp.offset(12 as libc::c_int as isize); + let mut ptr: *mut u8_t = + (*streambuf).readp.offset(12 as libc::c_int as isize); let fresh0 = ptr; ptr = ptr.offset(1); if *fresh0 as libc::c_int == 0x3 as libc::c_int { mp4_desc_length(&mut ptr); ptr = ptr.offset(4 as libc::c_int as isize) - } else { - ptr = ptr.offset(3 as libc::c_int as isize) - } + } else { ptr = ptr.offset(3 as libc::c_int as isize) } mp4_desc_length(&mut ptr); ptr = ptr.offset(13 as libc::c_int as isize); let fresh1 = ptr; ptr = ptr.offset(1); if *fresh1 as libc::c_int != 0x5 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 parsing esds\n\x00" as *const u8 as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 16], &[libc::c_char; 16]>( - b"read_mp4_header\x00", - )) - .as_ptr(), - 146 as libc::c_int, - ); + if loglevel as libc::c_uint >= + lWARN as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d error parsing esds\n\x00" as *const u8 + as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 16], + &[libc::c_char; 16]>(b"read_mp4_header\x00")).as_ptr(), + 146 as libc::c_int); } - return -(1 as libc::c_int); + return -(1 as libc::c_int) } config_len = mp4_desc_length(&mut ptr); - if (*a).NeAACDecInit2.expect("non-null function pointer")( - (*a).hAac, - ptr, - config_len as libc::c_ulong, - samplerate_p, - channels_p, - ) as libc::c_int - == 0 as libc::c_int - { - 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 playable aac track: %u\n\x00" as *const u8 - as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 16], &[libc::c_char; 16]>( - b"read_mp4_header\x00", - )) - .as_ptr(), - 151 as libc::c_int, - trak, - ); + if (*a).NeAACDecInit2.expect("non-null function pointer")((*a).hAac, + ptr, + config_len + as + libc::c_ulong, + samplerate_p, + channels_p) + as libc::c_int == 0 as libc::c_int { + if loglevel as libc::c_uint >= + lDEBUG as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d playable aac track: %u\n\x00" as + *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 16], + &[libc::c_char; 16]>(b"read_mp4_header\x00")).as_ptr(), + 151 as libc::c_int, trak); } play = trak } } // extract the total number of samples from stts - if crate::stdlib::strcmp( - type_0.as_mut_ptr(), - b"stts\x00" as *const u8 as *const libc::c_char, - ) == 0 - && bytes > len as libc::c_ulong - { - let mut i: crate::squeezelite_h::u32_t = 0; - let mut ptr_0 = (*streambuf).readp.offset(12 as libc::c_int as isize); - let mut entries = crate::src::utils::unpackN(ptr_0 as *mut crate::squeezelite_h::u32_t); + if strcmp(type_0.as_mut_ptr(), + b"stts\x00" as *const u8 as *const libc::c_char) == 0 && + bytes > len as libc::c_ulong { + let mut i: u32_t = 0; + let mut ptr_0: *mut u8_t = + (*streambuf).readp.offset(12 as libc::c_int as isize); + let mut entries: u32_t = unpackN(ptr_0 as *mut u32_t); ptr_0 = ptr_0.offset(4 as libc::c_int as isize); - i = 0 as libc::c_int as crate::squeezelite_h::u32_t; + i = 0 as libc::c_int as u32_t; while i < entries { - let mut count = - crate::src::utils::unpackN(ptr_0 as *mut crate::squeezelite_h::u32_t); - let mut size = crate::src::utils::unpackN( - ptr_0.offset(4 as libc::c_int as isize) as *mut crate::squeezelite_h::u32_t - ); - (*a).sttssamples = ((*a).sttssamples as libc::c_ulong) - .wrapping_add(count.wrapping_mul(size) as libc::c_ulong) - as crate::squeezelite_h::u64_t - as crate::squeezelite_h::u64_t; + let mut count: u32_t = unpackN(ptr_0 as *mut u32_t); + let mut size: u32_t = + unpackN(ptr_0.offset(4 as libc::c_int as isize) as + *mut u32_t); + (*a).sttssamples = + ((*a).sttssamples as + libc::c_ulong).wrapping_add(count.wrapping_mul(size) + as libc::c_ulong) as + u64_t as u64_t; ptr_0 = ptr_0.offset(8 as libc::c_int as isize); i = i.wrapping_add(1) } - 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 total number of samples contained in stts: %lu\n\x00" as *const u8 - as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 16], &[libc::c_char; 16]>( - b"read_mp4_header\x00", - )) - .as_ptr(), - 168 as libc::c_int, - (*a).sttssamples, - ); + if loglevel as libc::c_uint >= + lDEBUG as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d total number of samples contained in stts: %lu\n\x00" + as *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 16], + &[libc::c_char; 16]>(b"read_mp4_header\x00")).as_ptr(), + 168 as libc::c_int, (*a).sttssamples); } } // stash sample to chunk info, assume it comes before stco - if crate::stdlib::strcmp( - type_0.as_mut_ptr(), - b"stsc\x00" as *const u8 as *const libc::c_char, - ) == 0 - && bytes > len as libc::c_ulong - && (*a).chunkinfo.is_null() - { - (*a).stsc = crate::stdlib::malloc( - len.wrapping_sub(12 as libc::c_int as libc::c_uint) as libc::c_ulong - ); + if strcmp(type_0.as_mut_ptr(), + b"stsc\x00" as *const u8 as *const libc::c_char) == 0 && + bytes > len as libc::c_ulong && (*a).chunkinfo.is_null() { + (*a).stsc = + malloc(len.wrapping_sub(12 as libc::c_int as libc::c_uint) as + libc::c_ulong); if (*a).stsc.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 malloc fail\n\x00" as *const u8 as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 16], &[libc::c_char; 16]>( - b"read_mp4_header\x00", - )) - .as_ptr(), - 175 as libc::c_int, - ); + if loglevel as libc::c_uint >= + lWARN as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d malloc fail\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 16], + &[libc::c_char; 16]>(b"read_mp4_header\x00")).as_ptr(), + 175 as libc::c_int); } - return -(1 as libc::c_int); + return -(1 as libc::c_int) } - crate::stdlib::memcpy( - (*a).stsc, - (*streambuf).readp.offset(12 as libc::c_int as isize) as *const libc::c_void, - len.wrapping_sub(12 as libc::c_int as libc::c_uint) as libc::c_ulong, - ); + memcpy((*a).stsc, + (*streambuf).readp.offset(12 as libc::c_int as isize) as + *const libc::c_void, + len.wrapping_sub(12 as libc::c_int as libc::c_uint) as + libc::c_ulong); } // build offsets table from stco and stored stsc - if crate::stdlib::strcmp( - type_0.as_mut_ptr(), - b"stco\x00" as *const u8 as *const libc::c_char, - ) == 0 - && bytes > len as libc::c_ulong - && play == trak - { - let mut i_0: crate::squeezelite_h::u32_t = 0; + if strcmp(type_0.as_mut_ptr(), + b"stco\x00" as *const u8 as *const libc::c_char) == 0 && + bytes > len as libc::c_ulong && play == trak { + let mut i_0: u32_t = 0; // extract chunk offsets - let mut ptr_1 = (*streambuf).readp.offset(12 as libc::c_int as isize); - let mut entries_0 = - crate::src::utils::unpackN(ptr_1 as *mut crate::squeezelite_h::u32_t); + let mut ptr_1: *mut u8_t = + (*streambuf).readp.offset(12 as libc::c_int as isize); + let mut entries_0: u32_t = unpackN(ptr_1 as *mut u32_t); ptr_1 = ptr_1.offset(4 as libc::c_int as isize); - (*a).chunkinfo = crate::stdlib::malloc( - (::std::mem::size_of::() as libc::c_ulong).wrapping_mul( - entries_0.wrapping_add(1 as libc::c_int as libc::c_uint) as libc::c_ulong, - ), - ) as *mut chunk_table; + (*a).chunkinfo = + malloc((::std::mem::size_of::() as + libc::c_ulong).wrapping_mul(entries_0.wrapping_add(1 + as + libc::c_int + as + libc::c_uint) + as libc::c_ulong)) + as *mut chunk_table; if (*a).chunkinfo.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 malloc fail\n\x00" as *const u8 as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 16], &[libc::c_char; 16]>( - b"read_mp4_header\x00", - )) - .as_ptr(), - 190 as libc::c_int, - ); + if loglevel as libc::c_uint >= + lWARN as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d malloc fail\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 16], + &[libc::c_char; 16]>(b"read_mp4_header\x00")).as_ptr(), + 190 as libc::c_int); } - return -(1 as libc::c_int); + return -(1 as libc::c_int) } - i_0 = 0 as libc::c_int as crate::squeezelite_h::u32_t; + i_0 = 0 as libc::c_int as u32_t; while i_0 < entries_0 { (*(*a).chunkinfo.offset(i_0 as isize)).offset = - crate::src::utils::unpackN(ptr_1 as *mut crate::squeezelite_h::u32_t); + unpackN(ptr_1 as *mut u32_t); (*(*a).chunkinfo.offset(i_0 as isize)).sample = - 0 as libc::c_int as crate::squeezelite_h::u32_t; + 0 as libc::c_int as u32_t; ptr_1 = ptr_1.offset(4 as libc::c_int as isize); i_0 = i_0.wrapping_add(1) } (*(*a).chunkinfo.offset(i_0 as isize)).sample = - 0 as libc::c_int as crate::squeezelite_h::u32_t; + 0 as libc::c_int as u32_t; (*(*a).chunkinfo.offset(i_0 as isize)).offset = - 0 as libc::c_int as crate::squeezelite_h::u32_t; + 0 as libc::c_int as u32_t; // fill in first sample id for each chunk from stored stsc if !(*a).stsc.is_null() { - let mut stsc_entries = - crate::src::utils::unpackN((*a).stsc as *mut crate::squeezelite_h::u32_t); - let mut sample = 0 as libc::c_int as crate::squeezelite_h::u32_t; - let mut last = 0 as libc::c_int as crate::squeezelite_h::u32_t; - let mut last_samples = 0 as libc::c_int as crate::squeezelite_h::u32_t; - let mut ptr_2 = ((*a).stsc as *mut crate::squeezelite_h::u8_t) - .offset(4 as libc::c_int as isize); - loop { + let mut stsc_entries: u32_t = + unpackN((*a).stsc as *mut u32_t); + let mut sample: u32_t = 0 as libc::c_int as u32_t; + let mut last: u32_t = 0 as libc::c_int as u32_t; + let mut last_samples: u32_t = 0 as libc::c_int as u32_t; + let mut ptr_2: *mut u8_t = + ((*a).stsc as + *mut u8_t).offset(4 as libc::c_int as isize); + loop { let fresh2 = stsc_entries; stsc_entries = stsc_entries.wrapping_sub(1); - if !(fresh2 != 0) { - break; - } - let mut first = - crate::src::utils::unpackN(ptr_2 as *mut crate::squeezelite_h::u32_t); - let mut samples = - crate::src::utils::unpackN(ptr_2.offset(4 as libc::c_int as isize) - as *mut crate::squeezelite_h::u32_t); + if !(fresh2 != 0) { break ; } + let mut first: u32_t = unpackN(ptr_2 as *mut u32_t); + let mut samples: u32_t = + unpackN(ptr_2.offset(4 as libc::c_int as isize) as + *mut u32_t); if last != 0 { - i_0 = last.wrapping_sub(1 as libc::c_int as libc::c_uint); - while i_0 < first.wrapping_sub(1 as libc::c_int as libc::c_uint) { - (*(*a).chunkinfo.offset(i_0 as isize)).sample = sample; - sample = (sample as libc::c_uint).wrapping_add(last_samples) - as crate::squeezelite_h::u32_t - as crate::squeezelite_h::u32_t; + i_0 = + last.wrapping_sub(1 as libc::c_int as + libc::c_uint); + while i_0 < + first.wrapping_sub(1 as libc::c_int as + libc::c_uint) { + (*(*a).chunkinfo.offset(i_0 as isize)).sample = + sample; + sample = + (sample as + libc::c_uint).wrapping_add(last_samples) + as u32_t as u32_t; i_0 = i_0.wrapping_add(1) } } if stsc_entries == 0 as libc::c_int as libc::c_uint { - i_0 = first.wrapping_sub(1 as libc::c_int as libc::c_uint); + i_0 = + first.wrapping_sub(1 as libc::c_int as + libc::c_uint); while i_0 < entries_0 { - (*(*a).chunkinfo.offset(i_0 as isize)).sample = sample; - sample = (sample as libc::c_uint).wrapping_add(samples) - as crate::squeezelite_h::u32_t - as crate::squeezelite_h::u32_t; + (*(*a).chunkinfo.offset(i_0 as isize)).sample = + sample; + sample = + (sample as libc::c_uint).wrapping_add(samples) + as u32_t as u32_t; i_0 = i_0.wrapping_add(1) } } @@ -484,193 +582,155 @@ unsafe extern "C" fn read_mp4_header( last_samples = samples; ptr_2 = ptr_2.offset(12 as libc::c_int as isize) } - crate::stdlib::free((*a).stsc); + free((*a).stsc); (*a).stsc = 0 as *mut libc::c_void } } // found media data, advance to start of first chunk and return - if crate::stdlib::strcmp( - type_0.as_mut_ptr(), - b"mdat\x00" as *const u8 as *const libc::c_char, - ) == 0 - { - crate::src::buffer::_buf_inc_readp(streambuf, 8 as libc::c_int as libc::c_uint); - (*a).pos = ((*a).pos as libc::c_uint).wrapping_add(8 as libc::c_int as libc::c_uint) - as crate::squeezelite_h::u32_t - as crate::squeezelite_h::u32_t; - bytes = (bytes as libc::c_ulong).wrapping_sub(8 as libc::c_int as libc::c_ulong) - as crate::stddef_h::size_t as crate::stddef_h::size_t; + if strcmp(type_0.as_mut_ptr(), + b"mdat\x00" as *const u8 as *const libc::c_char) == 0 { + _buf_inc_readp(streambuf, 8 as libc::c_int as libc::c_uint); + (*a).pos = + ((*a).pos as + libc::c_uint).wrapping_add(8 as libc::c_int as + libc::c_uint) as u32_t as + u32_t; + bytes = + (bytes as + libc::c_ulong).wrapping_sub(8 as libc::c_int as + libc::c_ulong) as size_t + as size_t; if play != 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 type: mdat len: %u pos: %u\n\x00" as *const u8 - as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 16], &[libc::c_char; 16]>( - b"read_mp4_header\x00", - )) - .as_ptr(), - 236 as libc::c_int, - len, - (*a).pos, - ); + if loglevel as libc::c_uint >= + lDEBUG as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d type: mdat len: %u pos: %u\n\x00" as + *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 16], + &[libc::c_char; 16]>(b"read_mp4_header\x00")).as_ptr(), + 236 as libc::c_int, len, (*a).pos); } - if !(*a).chunkinfo.is_null() - && (*(*a).chunkinfo.offset(0 as libc::c_int as isize)).offset > (*a).pos - { - let mut skip = (*(*a).chunkinfo.offset(0 as libc::c_int as isize)) - .offset - .wrapping_sub((*a).pos); - 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 skipping: %u\n\x00" as *const u8 as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 16], &[libc::c_char; 16]>( - b"read_mp4_header\x00", - )) - .as_ptr(), - 239 as libc::c_int, - skip, - ); + if !(*a).chunkinfo.is_null() && + (*(*a).chunkinfo.offset(0 as libc::c_int as + isize)).offset > (*a).pos { + let mut skip: u32_t = + (*(*a).chunkinfo.offset(0 as libc::c_int as + isize)).offset.wrapping_sub((*a).pos); + if loglevel as libc::c_uint >= + lDEBUG as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d skipping: %u\n\x00" as *const u8 + as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 16], + &[libc::c_char; 16]>(b"read_mp4_header\x00")).as_ptr(), + 239 as libc::c_int, skip); } if skip as libc::c_ulong <= bytes { - crate::src::buffer::_buf_inc_readp(streambuf, skip); - (*a).pos = ((*a).pos as libc::c_uint).wrapping_add(skip) - as crate::squeezelite_h::u32_t - as crate::squeezelite_h::u32_t - } else { - (*a).consume = skip - } + _buf_inc_readp(streambuf, skip); + (*a).pos = + ((*a).pos as libc::c_uint).wrapping_add(skip) as + u32_t as u32_t + } else { (*a).consume = skip } } - (*a).nextchunk = 1 as libc::c_int as crate::squeezelite_h::u32_t; + (*a).nextchunk = 1 as libc::c_int as u32_t; (*a).sample = (*a).nextchunk; - return 1 as libc::c_int; + return 1 as libc::c_int } else { - 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 type: mdat len: %u, no playable track found\n\x00" as *const u8 - as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 16], &[libc::c_char; 16]>( - b"read_mp4_header\x00", - )) - .as_ptr(), - 250 as libc::c_int, - len, - ); + if loglevel as libc::c_uint >= + lDEBUG as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d type: mdat len: %u, no playable track found\n\x00" + as *const u8 as *const libc::c_char, + logtime(), + (*::std::mem::transmute::<&[u8; 16], + &[libc::c_char; 16]>(b"read_mp4_header\x00")).as_ptr(), + 250 as libc::c_int, len); } - return -(1 as libc::c_int); + return -(1 as libc::c_int) } } // parse key-value atoms within ilst ---- entries to get encoder padding within iTunSMPB entry for gapless - if crate::stdlib::strcmp( - type_0.as_mut_ptr(), - b"----\x00" as *const u8 as *const libc::c_char, - ) == 0 - && bytes > len as libc::c_ulong - { - let mut ptr_3 = (*streambuf).readp.offset(8 as libc::c_int as isize); - let mut remain = len.wrapping_sub(8 as libc::c_int as libc::c_uint); - let mut size_0: crate::squeezelite_h::u32_t = 0; - if crate::stdlib::memcmp( - ptr_3.offset(4 as libc::c_int as isize) as *const libc::c_void, - b"mean\x00" as *const u8 as *const libc::c_char as *const libc::c_void, - 4 as libc::c_int as libc::c_ulong, - ) == 0 - && { - size_0 = crate::src::utils::unpackN(ptr_3 as *mut crate::squeezelite_h::u32_t); - (size_0) < remain - } - { + if strcmp(type_0.as_mut_ptr(), + b"----\x00" as *const u8 as *const libc::c_char) == 0 && + bytes > len as libc::c_ulong { + let mut ptr_3: *mut u8_t = + (*streambuf).readp.offset(8 as libc::c_int as isize); + let mut remain: u32_t = + len.wrapping_sub(8 as libc::c_int as libc::c_uint); + let mut size_0: u32_t = 0; + if memcmp(ptr_3.offset(4 as libc::c_int as isize) as + *const libc::c_void, + b"mean\x00" as *const u8 as *const libc::c_char as + *const libc::c_void, + 4 as libc::c_int as libc::c_ulong) == 0 && + { + size_0 = unpackN(ptr_3 as *mut u32_t); + (size_0) < remain + } { ptr_3 = ptr_3.offset(size_0 as isize); - remain = (remain as libc::c_uint).wrapping_sub(size_0) - as crate::squeezelite_h::u32_t - as crate::squeezelite_h::u32_t + remain = + (remain as libc::c_uint).wrapping_sub(size_0) as u32_t as + u32_t } - if crate::stdlib::memcmp( - ptr_3.offset(4 as libc::c_int as isize) as *const libc::c_void, - b"name\x00" as *const u8 as *const libc::c_char as *const libc::c_void, - 4 as libc::c_int as libc::c_ulong, - ) == 0 - && { - size_0 = crate::src::utils::unpackN(ptr_3 as *mut crate::squeezelite_h::u32_t); - (size_0) < remain - } - && crate::stdlib::memcmp( - ptr_3.offset(12 as libc::c_int as isize) as *const libc::c_void, - b"iTunSMPB\x00" as *const u8 as *const libc::c_char as *const libc::c_void, - 8 as libc::c_int as libc::c_ulong, - ) == 0 - { + if memcmp(ptr_3.offset(4 as libc::c_int as isize) as + *const libc::c_void, + b"name\x00" as *const u8 as *const libc::c_char as + *const libc::c_void, + 4 as libc::c_int as libc::c_ulong) == 0 && + { + size_0 = unpackN(ptr_3 as *mut u32_t); + (size_0) < remain + } && + memcmp(ptr_3.offset(12 as libc::c_int as isize) as + *const libc::c_void, + b"iTunSMPB\x00" as *const u8 as *const libc::c_char + as *const libc::c_void, + 8 as libc::c_int as libc::c_ulong) == 0 { ptr_3 = ptr_3.offset(size_0 as isize); - remain = (remain as libc::c_uint).wrapping_sub(size_0) - as crate::squeezelite_h::u32_t - as crate::squeezelite_h::u32_t + remain = + (remain as libc::c_uint).wrapping_sub(size_0) as u32_t as + u32_t } - if crate::stdlib::memcmp( - ptr_3.offset(4 as libc::c_int as isize) as *const libc::c_void, - b"data\x00" as *const u8 as *const libc::c_char as *const libc::c_void, - 4 as libc::c_int as libc::c_ulong, - ) == 0 - && remain > (16 as libc::c_int + 48 as libc::c_int) as libc::c_uint - { + if memcmp(ptr_3.offset(4 as libc::c_int as isize) as + *const libc::c_void, + b"data\x00" as *const u8 as *const libc::c_char as + *const libc::c_void, + 4 as libc::c_int as libc::c_ulong) == 0 && + remain > + (16 as libc::c_int + 48 as libc::c_int) as libc::c_uint + { // data is stored as hex strings: 0 start end samples - let mut b: crate::squeezelite_h::u32_t = 0; - let mut c: crate::squeezelite_h::u32_t = 0; - let mut d: crate::squeezelite_h::u64_t = 0; - if crate::stdlib::sscanf( - ptr_3.offset(16 as libc::c_int as isize) as *const libc::c_char, - b"%x %x %x %lx\x00" as *const u8 as *const libc::c_char, - &mut b as *mut crate::squeezelite_h::u32_t, - &mut b as *mut crate::squeezelite_h::u32_t, - &mut c as *mut crate::squeezelite_h::u32_t, - &mut d as *mut crate::squeezelite_h::u64_t, - ) == 4 as libc::c_int - { - 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 iTunSMPB start: %u end: %u samples: %lu\n\x00" as *const u8 - as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 16], &[libc::c_char; 16]>( - b"read_mp4_header\x00", - )) - .as_ptr(), - 269 as libc::c_int, - b, - c, - d, - ); + let mut b: u32_t = 0; + let mut c: u32_t = 0; + let mut d: u64_t = 0; + if sscanf(ptr_3.offset(16 as libc::c_int as isize) as + *const libc::c_char, + b"%x %x %x %lx\x00" as *const u8 as + *const libc::c_char, &mut b as *mut u32_t, + &mut b as *mut u32_t, &mut c as *mut u32_t, + &mut d as *mut u64_t) == 4 as libc::c_int { + if loglevel as libc::c_uint >= + lDEBUG as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d iTunSMPB start: %u end: %u samples: %lu\n\x00" + as *const u8 as *const libc::c_char, + logtime(), + (*::std::mem::transmute::<&[u8; 16], + &[libc::c_char; 16]>(b"read_mp4_header\x00")).as_ptr(), + 269 as libc::c_int, b, c, d); } - if (*a).sttssamples != 0 - && (*a).sttssamples < (b.wrapping_add(c) as libc::c_ulong).wrapping_add(d) - { - 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 reducing samples as stts count is less\n\x00" - as *const u8 - as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 16], &[libc::c_char; 16]>( - b"read_mp4_header\x00", - )) - .as_ptr(), - 271 as libc::c_int, - ); + if (*a).sttssamples != 0 && + (*a).sttssamples < + (b.wrapping_add(c) as + libc::c_ulong).wrapping_add(d) { + if loglevel as libc::c_uint >= + lDEBUG as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d reducing samples as stts count is less\n\x00" + as *const u8 as *const libc::c_char, + logtime(), + (*::std::mem::transmute::<&[u8; 16], + &[libc::c_char; 16]>(b"read_mp4_header\x00")).as_ptr(), + 271 as libc::c_int); } - d = (*a) - .sttssamples - .wrapping_sub(b.wrapping_add(c) as libc::c_ulong) + d = + (*a).sttssamples.wrapping_sub(b.wrapping_add(c) as + libc::c_ulong) } (*a).skip = b; (*a).samples = d @@ -680,227 +740,173 @@ unsafe extern "C" fn read_mp4_header( // default to consuming entire box consume = len; // read into these boxes so reduce consume - if crate::stdlib::strcmp( - type_0.as_mut_ptr(), - b"moov\x00" as *const u8 as *const libc::c_char, - ) == 0 - || crate::stdlib::strcmp( - type_0.as_mut_ptr(), - b"trak\x00" as *const u8 as *const libc::c_char, - ) == 0 - || crate::stdlib::strcmp( - type_0.as_mut_ptr(), - b"mdia\x00" as *const u8 as *const libc::c_char, - ) == 0 - || crate::stdlib::strcmp( - type_0.as_mut_ptr(), - b"minf\x00" as *const u8 as *const libc::c_char, - ) == 0 - || crate::stdlib::strcmp( - type_0.as_mut_ptr(), - b"stbl\x00" as *const u8 as *const libc::c_char, - ) == 0 - || crate::stdlib::strcmp( - type_0.as_mut_ptr(), - b"udta\x00" as *const u8 as *const libc::c_char, - ) == 0 - || crate::stdlib::strcmp( - type_0.as_mut_ptr(), - b"ilst\x00" as *const u8 as *const libc::c_char, - ) == 0 - { - consume = 8 as libc::c_int as crate::squeezelite_h::u32_t + if strcmp(type_0.as_mut_ptr(), + b"moov\x00" as *const u8 as *const libc::c_char) == 0 || + strcmp(type_0.as_mut_ptr(), + b"trak\x00" as *const u8 as *const libc::c_char) == 0 || + strcmp(type_0.as_mut_ptr(), + b"mdia\x00" as *const u8 as *const libc::c_char) == 0 || + strcmp(type_0.as_mut_ptr(), + b"minf\x00" as *const u8 as *const libc::c_char) == 0 || + strcmp(type_0.as_mut_ptr(), + b"stbl\x00" as *const u8 as *const libc::c_char) == 0 || + strcmp(type_0.as_mut_ptr(), + b"udta\x00" as *const u8 as *const libc::c_char) == 0 || + strcmp(type_0.as_mut_ptr(), + b"ilst\x00" as *const u8 as *const libc::c_char) == 0 { + consume = 8 as libc::c_int as u32_t } // special cases which mix mix data in the enclosing box which we want to read into - if crate::stdlib::strcmp( - type_0.as_mut_ptr(), - b"stsd\x00" as *const u8 as *const libc::c_char, - ) == 0 - { - consume = 16 as libc::c_int as crate::squeezelite_h::u32_t + if strcmp(type_0.as_mut_ptr(), + b"stsd\x00" as *const u8 as *const libc::c_char) == 0 { + consume = 16 as libc::c_int as u32_t } - if crate::stdlib::strcmp( - type_0.as_mut_ptr(), - b"mp4a\x00" as *const u8 as *const libc::c_char, - ) == 0 - { - consume = 36 as libc::c_int as crate::squeezelite_h::u32_t + if strcmp(type_0.as_mut_ptr(), + b"mp4a\x00" as *const u8 as *const libc::c_char) == 0 { + consume = 36 as libc::c_int as u32_t } - if crate::stdlib::strcmp( - type_0.as_mut_ptr(), - b"meta\x00" as *const u8 as *const libc::c_char, - ) == 0 - { - consume = 12 as libc::c_int as crate::squeezelite_h::u32_t + if strcmp(type_0.as_mut_ptr(), + b"meta\x00" as *const u8 as *const libc::c_char) == 0 { + consume = 12 as libc::c_int as u32_t } // consume rest of box if it has been parsed (all in the buffer) or is not one we want to parse if bytes >= consume as libc::c_ulong { - 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 type: %s len: %u consume: %u\n\x00" as *const u8 - as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 16], &[libc::c_char; 16]>( - b"read_mp4_header\x00", - )) - .as_ptr(), - 295 as libc::c_int, - type_0.as_mut_ptr(), - len, - consume, - ); + if loglevel as libc::c_uint >= + lDEBUG as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d type: %s len: %u consume: %u\n\x00" as + *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 16], + &[libc::c_char; 16]>(b"read_mp4_header\x00")).as_ptr(), + 295 as libc::c_int, type_0.as_mut_ptr(), len, + consume); } - crate::src::buffer::_buf_inc_readp(streambuf, consume); - (*a).pos = ((*a).pos as libc::c_uint).wrapping_add(consume) - as crate::squeezelite_h::u32_t - as crate::squeezelite_h::u32_t; - bytes = (bytes as libc::c_ulong).wrapping_sub(consume as libc::c_ulong) - as crate::stddef_h::size_t as crate::stddef_h::size_t + _buf_inc_readp(streambuf, consume); + (*a).pos = + ((*a).pos as libc::c_uint).wrapping_add(consume) as u32_t as + u32_t; + bytes = + (bytes as + libc::c_ulong).wrapping_sub(consume as libc::c_ulong) as + size_t as size_t } else { - if crate::stdlib::strcmp( - type_0.as_mut_ptr(), - b"esds\x00" as *const u8 as *const libc::c_char, - ) == 0 - || crate::stdlib::strcmp( - type_0.as_mut_ptr(), - b"stts\x00" as *const u8 as *const libc::c_char, - ) == 0 - || crate::stdlib::strcmp( - type_0.as_mut_ptr(), - b"stsc\x00" as *const u8 as *const libc::c_char, - ) == 0 - || crate::stdlib::strcmp( - type_0.as_mut_ptr(), - b"stco\x00" as *const u8 as *const libc::c_char, - ) == 0 - || crate::stdlib::strcmp( - type_0.as_mut_ptr(), - b"----\x00" as *const u8 as *const libc::c_char, - ) == 0 - { - break; + if strcmp(type_0.as_mut_ptr(), + b"esds\x00" as *const u8 as *const libc::c_char) == 0 || + strcmp(type_0.as_mut_ptr(), + b"stts\x00" as *const u8 as *const libc::c_char) == + 0 || + strcmp(type_0.as_mut_ptr(), + b"stsc\x00" as *const u8 as *const libc::c_char) == + 0 || + strcmp(type_0.as_mut_ptr(), + b"stco\x00" as *const u8 as *const libc::c_char) == + 0 || + strcmp(type_0.as_mut_ptr(), + b"----\x00" as *const u8 as *const libc::c_char) == + 0 { + break ; } - 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 type: %s len: %u consume: %u - partial consume: %u\n\x00" - as *const u8 as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 16], &[libc::c_char; 16]>( - b"read_mp4_header\x00", - )) - .as_ptr(), - 301 as libc::c_int, - type_0.as_mut_ptr(), - len, - consume, - bytes, - ); + if loglevel as libc::c_uint >= + lDEBUG as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d type: %s len: %u consume: %u - partial consume: %u\n\x00" + as *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 16], + &[libc::c_char; 16]>(b"read_mp4_header\x00")).as_ptr(), + 301 as libc::c_int, type_0.as_mut_ptr(), len, + consume, bytes); } - crate::src::buffer::_buf_inc_readp(streambuf, bytes as libc::c_uint); - (*a).pos = ((*a).pos as libc::c_ulong).wrapping_add(bytes) - as crate::squeezelite_h::u32_t - as crate::squeezelite_h::u32_t; + _buf_inc_readp(streambuf, bytes as libc::c_uint); + (*a).pos = + ((*a).pos as libc::c_ulong).wrapping_add(bytes) as u32_t as + u32_t; (*a).consume = - (consume as libc::c_ulong).wrapping_sub(bytes) as crate::squeezelite_h::u32_t; - break; + (consume as libc::c_ulong).wrapping_sub(bytes) as u32_t; + break ; } } return 0 as libc::c_int; } - -unsafe extern "C" fn faad_decode() -> crate::squeezelite_h::decode_state { - let mut bytes_total: crate::stddef_h::size_t = 0; - let mut bytes_wrap: crate::stddef_h::size_t = 0; - let mut info = crate::stdlib::NeAACDecFrameInfo { - bytesconsumed: 0, - samples: 0, - channels: 0, - error: 0, - samplerate: 0, - sbr: 0, - object_type: 0, - header_type: 0, - num_front_channels: 0, - num_side_channels: 0, - num_back_channels: 0, - num_lfe_channels: 0, - channel_position: [0; 64], - ps: 0, - }; - let mut iptr = 0 as *mut crate::squeezelite_h::s32_t; +unsafe extern "C" fn faad_decode() -> decode_state { + let mut bytes_total: size_t = 0; + let mut bytes_wrap: size_t = 0; + let mut info: NeAACDecFrameInfo = + NeAACDecFrameInfo{bytesconsumed: 0, + samples: 0, + channels: 0, + error: 0, + samplerate: 0, + sbr: 0, + object_type: 0, + header_type: 0, + num_front_channels: 0, + num_side_channels: 0, + num_back_channels: 0, + num_lfe_channels: 0, + channel_position: [0; 64], + ps: 0,}; + let mut iptr: *mut s32_t = 0 as *mut s32_t; let mut endstream: bool = false; - let mut frames: crate::squeezelite_h::frames_t = 0; - crate::stdlib::pthread_mutex_lock(&mut (*streambuf).mutex); - bytes_total = crate::squeezelite_h::_buf_used(streambuf) as crate::stddef_h::size_t; - bytes_wrap = if bytes_total < crate::src::buffer::_buf_cont_read(streambuf) as libc::c_ulong { - bytes_total - } else { - crate::src::buffer::_buf_cont_read(streambuf) as libc::c_ulong - }; - if stream.state as libc::c_uint - <= crate::squeezelite_h::DISCONNECT as libc::c_int as libc::c_uint - && bytes_total == 0 - { - crate::stdlib::pthread_mutex_unlock(&mut (*streambuf).mutex); - return crate::squeezelite_h::DECODE_COMPLETE; + let mut frames: frames_t = 0; + pthread_mutex_lock(&mut (*streambuf).mutex); + bytes_total = _buf_used(streambuf) as size_t; + bytes_wrap = + if bytes_total < _buf_cont_read(streambuf) as libc::c_ulong { + bytes_total + } else { _buf_cont_read(streambuf) as libc::c_ulong }; + if stream.state as libc::c_uint <= + DISCONNECT as libc::c_int as libc::c_uint && bytes_total == 0 { + pthread_mutex_unlock(&mut (*streambuf).mutex); + return DECODE_COMPLETE } if (*a).consume != 0 { - let mut consume = if ((*a).consume as libc::c_ulong) < bytes_wrap { - (*a).consume as libc::c_ulong - } else { - bytes_wrap - } 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; 12], &[libc::c_char; 12]>(b"faad_decode\x00")) - .as_ptr(), - 333 as libc::c_int, - consume, - (*a).consume, - ); + let mut consume: u32_t = + if ((*a).consume as libc::c_ulong) < bytes_wrap { + (*a).consume as libc::c_ulong + } else { bytes_wrap } as u32_t; + if loglevel as libc::c_uint >= lDEBUG as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d consume: %u of %u\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 12], + &[libc::c_char; 12]>(b"faad_decode\x00")).as_ptr(), + 333 as libc::c_int, consume, (*a).consume); } - crate::src::buffer::_buf_inc_readp(streambuf, consume); - (*a).pos = ((*a).pos as libc::c_uint).wrapping_add(consume) as crate::squeezelite_h::u32_t - as crate::squeezelite_h::u32_t; - (*a).consume = ((*a).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; + _buf_inc_readp(streambuf, consume); + (*a).pos = + ((*a).pos as libc::c_uint).wrapping_add(consume) as u32_t as + u32_t; + (*a).consume = + ((*a).consume as libc::c_uint).wrapping_sub(consume) as u32_t as + u32_t; + pthread_mutex_unlock(&mut (*streambuf).mutex); + return DECODE_RUNNING } if decode.new_stream { - let mut found = 0 as libc::c_int; + let mut found: libc::c_int = 0 as libc::c_int; static mut channels: libc::c_uchar = 0; static mut samplerate: libc::c_ulong = 0; if (*a).type_0 as libc::c_int == '2' as i32 { // adts stream - seek for header - while bytes_wrap >= 2 as libc::c_int as libc::c_ulong - && (*(*streambuf).readp as libc::c_int != 0xff as libc::c_int - || *(*streambuf).readp.offset(1 as libc::c_int as isize) as libc::c_int - & 0xf6 as libc::c_int - != 0xf0 as libc::c_int) - { - crate::src::buffer::_buf_inc_readp(streambuf, 1 as libc::c_int as libc::c_uint); + while bytes_wrap >= 2 as libc::c_int as libc::c_ulong && + (*(*streambuf).readp as libc::c_int != + 0xff as libc::c_int || + *(*streambuf).readp.offset(1 as libc::c_int as + isize) as + libc::c_int & 0xf6 as libc::c_int != + 0xf0 as libc::c_int) { + _buf_inc_readp(streambuf, 1 as libc::c_int as libc::c_uint); bytes_total = bytes_total.wrapping_sub(1); bytes_wrap = bytes_wrap.wrapping_sub(1) } if bytes_wrap >= 2 as libc::c_int as libc::c_ulong { - let mut n = (*a).NeAACDecInit.expect("non-null function pointer")( - (*a).hAac, - (*streambuf).readp, - bytes_wrap, - &mut samplerate, - &mut channels, - ); + let mut n: libc::c_long = + (*a).NeAACDecInit.expect("non-null function pointer")((*a).hAac, + (*streambuf).readp, + bytes_wrap, + &mut samplerate, + &mut channels); if n < 0 as libc::c_int as libc::c_long { found = -(1 as libc::c_int) } else { - crate::src::buffer::_buf_inc_readp(streambuf, n as libc::c_uint); + _buf_inc_readp(streambuf, n as libc::c_uint); found = 1 as libc::c_int } } @@ -909,283 +915,235 @@ unsafe extern "C" fn faad_decode() -> crate::squeezelite_h::decode_state { found = read_mp4_header(&mut samplerate, &mut channels) } if found == 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 samplerate: %u channels: %u\n\x00" as *const u8 - as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 12], &[libc::c_char; 12]>(b"faad_decode\x00")) - .as_ptr(), - 373 as libc::c_int, - samplerate, - channels as libc::c_int, - ); + if loglevel as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d samplerate: %u channels: %u\n\x00" as + *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 12], + &[libc::c_char; 12]>(b"faad_decode\x00")).as_ptr(), + 373 as libc::c_int, samplerate, + channels as libc::c_int); } - bytes_total = crate::squeezelite_h::_buf_used(streambuf) as crate::stddef_h::size_t; + bytes_total = _buf_used(streambuf) as size_t; bytes_wrap = - if bytes_total < crate::src::buffer::_buf_cont_read(streambuf) as libc::c_ulong { + if bytes_total < _buf_cont_read(streambuf) as libc::c_ulong { bytes_total - } else { - crate::src::buffer::_buf_cont_read(streambuf) as libc::c_ulong - }; - 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; 12], &[libc::c_char; 12]>(b"faad_decode\x00")) - .as_ptr(), - 378 as libc::c_int, - ); + } else { _buf_cont_read(streambuf) as libc::c_ulong }; + pthread_mutex_lock(&mut (*outputbuf).mutex); + if loglevel as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d setting track_start\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 12], + &[libc::c_char; 12]>(b"faad_decode\x00")).as_ptr(), + 378 as libc::c_int); } - output.next_sample_rate = crate::src::decode::decode_newstream( - samplerate as libc::c_uint, - output.supported_rates.as_mut_ptr(), - ); + output.next_sample_rate = + decode_newstream(samplerate 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); + _checkfade(1 as libc::c_int != 0); } decode.new_stream = 0 as libc::c_int != 0; - crate::stdlib::pthread_mutex_unlock(&mut (*outputbuf).mutex); + pthread_mutex_unlock(&mut (*outputbuf).mutex); } else if found == -(1 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 reading stream header\n\x00" as *const u8 - as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 12], &[libc::c_char; 12]>(b"faad_decode\x00")) - .as_ptr(), - 388 as libc::c_int, - ); + if loglevel as libc::c_uint >= + lWARN as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d error reading stream header\n\x00" as + *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 12], + &[libc::c_char; 12]>(b"faad_decode\x00")).as_ptr(), + 388 as libc::c_int); } - crate::stdlib::pthread_mutex_unlock(&mut (*streambuf).mutex); - return crate::squeezelite_h::DECODE_ERROR; + pthread_mutex_unlock(&mut (*streambuf).mutex); + return DECODE_ERROR } else { // not finished header parsing come back next time - crate::stdlib::pthread_mutex_unlock(&mut (*streambuf).mutex); - return crate::squeezelite_h::DECODE_RUNNING; + pthread_mutex_unlock(&mut (*streambuf).mutex); + return DECODE_RUNNING } } - if bytes_wrap < 2048 as libc::c_int as libc::c_ulong - && bytes_total > 2048 as libc::c_int as libc::c_ulong - { + if bytes_wrap < 2048 as libc::c_int as libc::c_ulong && + bytes_total > 2048 as libc::c_int as libc::c_ulong { // make a local copy of frames which may have wrapped round the end of streambuf - let mut buf: [crate::squeezelite_h::u8_t; 2048] = [0; 2048]; - crate::stdlib::memcpy( - buf.as_mut_ptr() as *mut libc::c_void, - (*streambuf).readp as *const libc::c_void, - bytes_wrap, - ); - crate::stdlib::memcpy( - buf.as_mut_ptr().offset(bytes_wrap as isize) as *mut libc::c_void, - (*streambuf).buf as *const libc::c_void, - (2048 as libc::c_int as libc::c_ulong).wrapping_sub(bytes_wrap), - ); - iptr = (*a).NeAACDecDecode.expect("non-null function pointer")( - (*a).hAac, - &mut info, - buf.as_mut_ptr(), - 2048 as libc::c_int as libc::c_ulong, - ) as *mut crate::squeezelite_h::s32_t + let mut buf: [u8_t; 2048] = [0; 2048]; + memcpy(buf.as_mut_ptr() as *mut libc::c_void, + (*streambuf).readp as *const libc::c_void, bytes_wrap); + memcpy(buf.as_mut_ptr().offset(bytes_wrap as isize) as + *mut libc::c_void, (*streambuf).buf as *const libc::c_void, + (2048 as libc::c_int as + libc::c_ulong).wrapping_sub(bytes_wrap)); + iptr = + (*a).NeAACDecDecode.expect("non-null function pointer")((*a).hAac, + &mut info, + buf.as_mut_ptr(), + 2048 as + libc::c_int + as + libc::c_ulong) + as *mut s32_t } else { - iptr = (*a).NeAACDecDecode.expect("non-null function pointer")( - (*a).hAac, - &mut info, - (*streambuf).readp, - bytes_wrap, - ) as *mut crate::squeezelite_h::s32_t + iptr = + (*a).NeAACDecDecode.expect("non-null function pointer")((*a).hAac, + &mut info, + (*streambuf).readp, + bytes_wrap) + as *mut s32_t } if info.error != 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 error: %u %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"faad_decode\x00")) - .as_ptr(), - 415 as libc::c_int, - info.error as libc::c_int, - (*a).NeAACDecGetErrorMessage - .expect("non-null function pointer")(info.error), - ); + if loglevel as libc::c_uint >= lWARN as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d error: %u %s\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 12], + &[libc::c_char; 12]>(b"faad_decode\x00")).as_ptr(), + 415 as libc::c_int, info.error as libc::c_int, + (*a).NeAACDecGetErrorMessage.expect("non-null function pointer")(info.error)); } } endstream = 0 as libc::c_int != 0; // mp4 end of chunk - skip to next offset - if !(*a).chunkinfo.is_null() - && (*(*a).chunkinfo.offset((*a).nextchunk as isize)).offset != 0 - && { - let fresh3 = (*a).sample; - (*a).sample = (*a).sample.wrapping_add(1); - (fresh3) == (*(*a).chunkinfo.offset((*a).nextchunk as isize)).sample - } - { - if (*(*a).chunkinfo.offset((*a).nextchunk as isize)).offset > (*a).pos { - let mut skip = (*(*a).chunkinfo.offset((*a).nextchunk as isize)) - .offset - .wrapping_sub((*a).pos); + if !(*a).chunkinfo.is_null() && + (*(*a).chunkinfo.offset((*a).nextchunk as isize)).offset != 0 && + { + let fresh3 = (*a).sample; + (*a).sample = (*a).sample.wrapping_add(1); + (fresh3) == + (*(*a).chunkinfo.offset((*a).nextchunk as isize)).sample + } { + if (*(*a).chunkinfo.offset((*a).nextchunk as isize)).offset > (*a).pos + { + let mut skip: u32_t = + (*(*a).chunkinfo.offset((*a).nextchunk as + isize)).offset.wrapping_sub((*a).pos); if skip as libc::c_ulong != info.bytesconsumed { - 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 skipping to next chunk pos: %u consumed: %u != skip: %u\n\x00" - as *const u8 as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 12], &[libc::c_char; 12]>( - b"faad_decode\x00", - )) - .as_ptr(), - 426 as libc::c_int, - (*a).pos, - info.bytesconsumed, - skip, - ); + if loglevel as libc::c_uint >= + lDEBUG as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d skipping to next chunk pos: %u consumed: %u != skip: %u\n\x00" + as *const u8 as *const libc::c_char, + logtime(), + (*::std::mem::transmute::<&[u8; 12], + &[libc::c_char; 12]>(b"faad_decode\x00")).as_ptr(), + 426 as libc::c_int, (*a).pos, info.bytesconsumed, + skip); } } if bytes_total >= skip as libc::c_ulong { - crate::src::buffer::_buf_inc_readp(streambuf, skip); - (*a).pos = ((*a).pos as libc::c_uint).wrapping_add(skip) - as crate::squeezelite_h::u32_t - as crate::squeezelite_h::u32_t - } else { - (*a).consume = skip - } + _buf_inc_readp(streambuf, skip); + (*a).pos = + ((*a).pos as libc::c_uint).wrapping_add(skip) as u32_t as + u32_t + } else { (*a).consume = skip } (*a).nextchunk = (*a).nextchunk.wrapping_add(1) } else { - crate::src::utils::logprint( - b"%s %s:%d error: need to skip backwards!\n\x00" as *const u8 - as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 12], &[libc::c_char; 12]>(b"faad_decode\x00")) - .as_ptr(), - 436 as libc::c_int, - ); + logprint(b"%s %s:%d error: need to skip backwards!\n\x00" as + *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 12], + &[libc::c_char; 12]>(b"faad_decode\x00")).as_ptr(), + 436 as libc::c_int); endstream = 1 as libc::c_int != 0 } - // adts and mp4 when not at end of chunk + // adts and mp4 when not at end of chunk } else if info.bytesconsumed != 0 as libc::c_int as libc::c_ulong { - crate::src::buffer::_buf_inc_readp(streambuf, info.bytesconsumed as libc::c_uint); - (*a).pos = ((*a).pos as libc::c_ulong).wrapping_add(info.bytesconsumed) - as crate::squeezelite_h::u32_t as crate::squeezelite_h::u32_t - // error which doesn't advance streambuf - end - } else { - endstream = 1 as libc::c_int != 0 - } - crate::stdlib::pthread_mutex_unlock(&mut (*streambuf).mutex); + _buf_inc_readp(streambuf, info.bytesconsumed as libc::c_uint); + (*a).pos = + ((*a).pos as libc::c_ulong).wrapping_add(info.bytesconsumed) as + u32_t as u32_t + // error which doesn't advance streambuf - end + } else { endstream = 1 as libc::c_int != 0 } + pthread_mutex_unlock(&mut (*streambuf).mutex); if endstream { - 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 unable to decode further\n\x00" as *const u8 as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 12], &[libc::c_char; 12]>(b"faad_decode\x00")) - .as_ptr(), - 454 as libc::c_int, - ); + if loglevel as libc::c_uint >= lWARN as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d unable to decode further\n\x00" as *const u8 + as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 12], + &[libc::c_char; 12]>(b"faad_decode\x00")).as_ptr(), + 454 as libc::c_int); } - return crate::squeezelite_h::DECODE_ERROR; + return DECODE_ERROR } if info.samples == 0 { (*a).empty = 1 as libc::c_int != 0; - return crate::squeezelite_h::DECODE_RUNNING; + return DECODE_RUNNING } frames = - info.samples.wrapping_div(info.channels as libc::c_ulong) as crate::squeezelite_h::frames_t; + info.samples.wrapping_div(info.channels as libc::c_ulong) as frames_t; if (*a).skip != 0 { - let mut skip_0: crate::squeezelite_h::u32_t = 0; + let mut skip_0: u32_t = 0; if (*a).empty { (*a).empty = 0 as libc::c_int != 0; - (*a).skip = ((*a).skip as libc::c_uint).wrapping_sub(frames) - as crate::squeezelite_h::u32_t - 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: first frame empty, skipped %u frames at start\n\x00" - as *const u8 as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 12], &[libc::c_char; 12]>(b"faad_decode\x00")) - .as_ptr(), - 470 as libc::c_int, - frames, - ); + (*a).skip = + ((*a).skip as libc::c_uint).wrapping_sub(frames) as u32_t as + u32_t; + if loglevel as libc::c_uint >= + lDEBUG as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d gapless: first frame empty, skipped %u frames at start\n\x00" + as *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 12], + &[libc::c_char; 12]>(b"faad_decode\x00")).as_ptr(), + 470 as libc::c_int, frames); } } - skip_0 = if frames < (*a).skip { - frames - } else { - (*a).skip - }; - 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; 12], &[libc::c_char; 12]>(b"faad_decode\x00")) - .as_ptr(), - 473 as libc::c_int, - skip_0, - ); + skip_0 = if frames < (*a).skip { frames } else { (*a).skip }; + if loglevel as libc::c_uint >= lDEBUG as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d gapless: skipping %u frames at start\n\x00" as + *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 12], + &[libc::c_char; 12]>(b"faad_decode\x00")).as_ptr(), + 473 as libc::c_int, skip_0); } - frames = (frames as libc::c_uint).wrapping_sub(skip_0) as crate::squeezelite_h::frames_t - as crate::squeezelite_h::frames_t; - (*a).skip = ((*a).skip as libc::c_uint).wrapping_sub(skip_0) as crate::squeezelite_h::u32_t - as crate::squeezelite_h::u32_t; - iptr = iptr.offset(skip_0.wrapping_mul(info.channels as libc::c_uint) as isize) + frames = + (frames as libc::c_uint).wrapping_sub(skip_0) as frames_t as + frames_t; + (*a).skip = + ((*a).skip as libc::c_uint).wrapping_sub(skip_0) as u32_t as + u32_t; + iptr = + iptr.offset(skip_0.wrapping_mul(info.channels as libc::c_uint) as + isize) } if (*a).samples != 0 { if (*a).samples < frames as libc::c_ulong { - 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; 12], &[libc::c_char; 12]>(b"faad_decode\x00")) - .as_ptr(), - 481 as libc::c_int, - (frames as libc::c_ulong).wrapping_sub((*a).samples), - ); + if loglevel as libc::c_uint >= + lDEBUG as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d gapless: trimming %u frames from end\n\x00" + as *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 12], + &[libc::c_char; 12]>(b"faad_decode\x00")).as_ptr(), + 481 as libc::c_int, + (frames as + libc::c_ulong).wrapping_sub((*a).samples)); } - frames = (*a).samples as crate::squeezelite_h::frames_t + frames = (*a).samples as frames_t } - (*a).samples = ((*a).samples as libc::c_ulong).wrapping_sub(frames as libc::c_ulong) - as crate::squeezelite_h::u64_t as crate::squeezelite_h::u64_t + (*a).samples = + ((*a).samples as + libc::c_ulong).wrapping_sub(frames as libc::c_ulong) as u64_t + as 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; 12], &[libc::c_char; 12]>(b"faad_decode\x00")).as_ptr(), - 487 as libc::c_int, - frames, - ); + if loglevel as libc::c_uint >= lSDEBUG as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d write %u frames\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 12], + &[libc::c_char; 12]>(b"faad_decode\x00")).as_ptr(), + 487 as libc::c_int, frames); } - crate::stdlib::pthread_mutex_lock(&mut (*outputbuf).mutex); + pthread_mutex_lock(&mut (*outputbuf).mutex); while frames > 0 as libc::c_int as libc::c_uint { - let mut f: 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; - f = crate::src::buffer::_buf_cont_write(outputbuf) - .wrapping_div(8 as libc::c_int as libc::c_uint); - optr = (*outputbuf).writep as *mut crate::squeezelite_h::s32_t; + let mut f: frames_t = 0; + let mut count: frames_t = 0; + let mut optr: *mut s32_t = 0 as *mut s32_t; + f = + _buf_cont_write(outputbuf).wrapping_div(8 as libc::c_int as + libc::c_uint); + optr = (*outputbuf).writep as *mut s32_t; f = if f < frames { f } else { frames }; count = f; if info.channels as libc::c_int == 2 as libc::c_int { - loop { + loop { let fresh4 = count; count = count.wrapping_sub(1); - if !(fresh4 != 0) { - break; - } + if !(fresh4 != 0) { break ; } let fresh5 = iptr; iptr = iptr.offset(1); let fresh6 = optr; @@ -1198,12 +1156,10 @@ unsafe extern "C" fn faad_decode() -> crate::squeezelite_h::decode_state { *fresh8 = *fresh7 << 8 as libc::c_int } } else if info.channels as libc::c_int == 1 as libc::c_int { - loop { + loop { let fresh9 = count; count = count.wrapping_sub(1); - if !(fresh9 != 0) { - break; - } + if !(fresh9 != 0) { break ; } let fresh10 = optr; optr = optr.offset(1); *fresh10 = *iptr << 8 as libc::c_int; @@ -1213,247 +1169,227 @@ unsafe extern "C" fn faad_decode() -> crate::squeezelite_h::decode_state { optr = optr.offset(1); *fresh12 = *fresh11 << 8 as libc::c_int } - } 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 unsupported number of channels\n\x00" as *const u8 - as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 12], &[libc::c_char; 12]>(b"faad_decode\x00")) - .as_ptr(), - 519 as libc::c_int, - ); + } else if loglevel as libc::c_uint >= + lWARN as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d unsupported number of channels\n\x00" as + *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 12], + &[libc::c_char; 12]>(b"faad_decode\x00")).as_ptr(), + 519 as libc::c_int); } - frames = (frames as libc::c_uint).wrapping_sub(f) as crate::squeezelite_h::frames_t - as crate::squeezelite_h::frames_t; - crate::src::buffer::_buf_inc_writep( - outputbuf, - f.wrapping_mul(8 as libc::c_int as libc::c_uint), - ); + frames = + (frames as libc::c_uint).wrapping_sub(f) as frames_t as frames_t; + _buf_inc_writep(outputbuf, + f.wrapping_mul(8 as libc::c_int as libc::c_uint)); } - crate::stdlib::pthread_mutex_unlock(&mut (*outputbuf).mutex); - return crate::squeezelite_h::DECODE_RUNNING; + pthread_mutex_unlock(&mut (*outputbuf).mutex); + return DECODE_RUNNING; } - -unsafe extern "C" fn faad_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 conf = 0 as *mut crate::stdlib::NeAACDecConfiguration; - 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 opening %s 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"faad_open\x00")).as_ptr(), - 541 as libc::c_int, - if size as libc::c_int == '2' as i32 { - b"adts\x00" as *const u8 as *const libc::c_char - } else { - b"mp4\x00" as *const u8 as *const libc::c_char - }, - ); +unsafe extern "C" fn faad_open(mut size: u8_t, mut rate: u8_t, mut chan: u8_t, + mut endianness: u8_t) { + let mut conf: NeAACDecConfigurationPtr = 0 as *mut NeAACDecConfiguration; + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d opening %s stream\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 10], + &[libc::c_char; 10]>(b"faad_open\x00")).as_ptr(), + 541 as libc::c_int, + if size as libc::c_int == '2' as i32 { + b"adts\x00" as *const u8 as *const libc::c_char + } else { b"mp4\x00" as *const u8 as *const libc::c_char }); } (*a).type_0 = size; - (*a).nextchunk = 0 as libc::c_int as crate::squeezelite_h::u32_t; + (*a).nextchunk = 0 as libc::c_int as u32_t; (*a).sample = (*a).nextchunk; (*a).consume = (*a).sample; (*a).pos = (*a).consume; if !(*a).chunkinfo.is_null() { - crate::stdlib::free((*a).chunkinfo as *mut libc::c_void); - } - if !(*a).stsc.is_null() { - crate::stdlib::free((*a).stsc); + free((*a).chunkinfo as *mut libc::c_void); } + if !(*a).stsc.is_null() { free((*a).stsc); } (*a).chunkinfo = 0 as *mut chunk_table; (*a).stsc = 0 as *mut libc::c_void; - (*a).skip = 0 as libc::c_int as crate::squeezelite_h::u32_t; - (*a).samples = 0 as libc::c_int as crate::squeezelite_h::u64_t; - (*a).sttssamples = 0 as libc::c_int as crate::squeezelite_h::u64_t; + (*a).skip = 0 as libc::c_int as u32_t; + (*a).samples = 0 as libc::c_int as u64_t; + (*a).sttssamples = 0 as libc::c_int as u64_t; (*a).empty = 0 as libc::c_int != 0; if !(*a).hAac.is_null() { (*a).NeAACDecClose.expect("non-null function pointer")((*a).hAac); } (*a).hAac = (*a).NeAACDecOpen.expect("non-null function pointer")(); - conf = (*a) - .NeAACDecGetCurrentConfiguration - .expect("non-null function pointer")((*a).hAac); + conf = + (*a).NeAACDecGetCurrentConfiguration.expect("non-null function pointer")((*a).hAac); (*conf).outputFormat = 2 as libc::c_int as libc::c_uchar; (*conf).downMatrix = 1 as libc::c_int as libc::c_uchar; - if (*a) - .NeAACDecSetConfiguration - .expect("non-null function pointer")((*a).hAac, conf) - == 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 error setting config\n\x00" as *const u8 as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 10], &[libc::c_char; 10]>(b"faad_open\x00")) - .as_ptr(), - 570 as libc::c_int, - ); + if (*a).NeAACDecSetConfiguration.expect("non-null function pointer")((*a).hAac, + conf) + == 0 { + if loglevel as libc::c_uint >= lWARN as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d error setting config\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 10], + &[libc::c_char; 10]>(b"faad_open\x00")).as_ptr(), + 570 as libc::c_int); } }; } - unsafe extern "C" fn faad_close() { (*a).NeAACDecClose.expect("non-null function pointer")((*a).hAac); (*a).hAac = 0 as *mut libc::c_void; if !(*a).chunkinfo.is_null() { - crate::stdlib::free((*a).chunkinfo as *mut libc::c_void); + free((*a).chunkinfo as *mut libc::c_void); (*a).chunkinfo = 0 as *mut chunk_table } if !(*a).stsc.is_null() { - crate::stdlib::free((*a).stsc); + free((*a).stsc); (*a).stsc = 0 as *mut libc::c_void }; } - unsafe extern "C" fn load_faad() -> bool { - let mut handle = crate::stdlib::dlopen( - b"libfaad.so.2\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 handle: *mut libc::c_void = + dlopen(b"libfaad.so.2\x00" as *const u8 as *const libc::c_char, + 0x2 as libc::c_int); + let mut err: *mut libc::c_char = 0 as *mut libc::c_char; if handle.is_null() { - if loglevel as libc::c_uint >= 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_faad\x00")) - .as_ptr(), - 593 as libc::c_int, - crate::stdlib::dlerror(), - ); + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d dlerror: %s\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 10], + &[libc::c_char; 10]>(b"load_faad\x00")).as_ptr(), + 593 as libc::c_int, dlerror()); } - return 0 as libc::c_int != 0; + return 0 as libc::c_int != 0 } - (*a).NeAACDecGetCurrentConfiguration = ::std::mem::transmute::< - *mut libc::c_void, - Option< - unsafe extern "C" fn( - _: crate::stdlib::NeAACDecHandle, - ) -> crate::stdlib::NeAACDecConfigurationPtr, - >, - >(crate::stdlib::dlsym( - handle, - b"NeAACDecGetCurrentConfiguration\x00" as *const u8 as *const libc::c_char, - )); - (*a).NeAACDecSetConfiguration = ::std::mem::transmute::< - *mut libc::c_void, - Option< - unsafe extern "C" fn( - _: crate::stdlib::NeAACDecHandle, - _: crate::stdlib::NeAACDecConfigurationPtr, - ) -> libc::c_uchar, - >, - >(crate::stdlib::dlsym( - handle, - b"NeAACDecSetConfiguration\x00" as *const u8 as *const libc::c_char, - )); - (*a).NeAACDecOpen = ::std::mem::transmute::< - *mut libc::c_void, - Option crate::stdlib::NeAACDecHandle>, - >(crate::stdlib::dlsym( - handle, - b"NeAACDecOpen\x00" as *const u8 as *const libc::c_char, - )); - (*a).NeAACDecClose = ::std::mem::transmute::< - *mut libc::c_void, - Option ()>, - >(crate::stdlib::dlsym( - handle, - b"NeAACDecClose\x00" as *const u8 as *const libc::c_char, - )); - (*a).NeAACDecInit = ::std::mem::transmute::< - *mut libc::c_void, - Option< - unsafe extern "C" fn( - _: crate::stdlib::NeAACDecHandle, - _: *mut libc::c_uchar, - _: libc::c_ulong, - _: *mut libc::c_ulong, - _: *mut libc::c_uchar, - ) -> libc::c_long, - >, - >(crate::stdlib::dlsym( - handle, - b"NeAACDecInit\x00" as *const u8 as *const libc::c_char, - )); - (*a).NeAACDecInit2 = ::std::mem::transmute::< - *mut libc::c_void, - Option< - unsafe extern "C" fn( - _: crate::stdlib::NeAACDecHandle, - _: *mut libc::c_uchar, - _: libc::c_ulong, - _: *mut libc::c_ulong, - _: *mut libc::c_uchar, - ) -> libc::c_char, - >, - >(crate::stdlib::dlsym( - handle, - b"NeAACDecInit2\x00" as *const u8 as *const libc::c_char, - )); - (*a).NeAACDecDecode = ::std::mem::transmute::< - *mut libc::c_void, - Option< - unsafe extern "C" fn( - _: crate::stdlib::NeAACDecHandle, - _: *mut crate::stdlib::NeAACDecFrameInfo, - _: *mut libc::c_uchar, - _: libc::c_ulong, - ) -> *mut libc::c_void, - >, - >(crate::stdlib::dlsym( - handle, - b"NeAACDecDecode\x00" as *const u8 as *const libc::c_char, - )); - (*a).NeAACDecGetErrorMessage = ::std::mem::transmute::< - *mut libc::c_void, - Option *mut libc::c_char>, - >(crate::stdlib::dlsym( - handle, - b"NeAACDecGetErrorMessage\x00" as *const u8 as *const libc::c_char, - )); - err = crate::stdlib::dlerror(); + (*a).NeAACDecGetCurrentConfiguration = + ::std::mem::transmute::<*mut libc::c_void, + Option + NeAACDecConfigurationPtr>>(dlsym(handle, + b"NeAACDecGetCurrentConfiguration\x00" + as + *const u8 + as + *const libc::c_char)); + (*a).NeAACDecSetConfiguration = + ::std::mem::transmute::<*mut libc::c_void, + Option + libc::c_uchar>>(dlsym(handle, + b"NeAACDecSetConfiguration\x00" + as + *const u8 + as + *const libc::c_char)); + (*a).NeAACDecOpen = + ::std::mem::transmute::<*mut libc::c_void, + Option + NeAACDecHandle>>(dlsym(handle, + b"NeAACDecOpen\x00" + as + *const u8 + as + *const libc::c_char)); + (*a).NeAACDecClose = + ::std::mem::transmute::<*mut libc::c_void, + Option + ()>>(dlsym(handle, + b"NeAACDecClose\x00" + as *const u8 as + *const libc::c_char)); + (*a).NeAACDecInit = + ::std::mem::transmute::<*mut libc::c_void, + Option + libc::c_long>>(dlsym(handle, + b"NeAACDecInit\x00" + as + *const u8 + as + *const libc::c_char)); + (*a).NeAACDecInit2 = + ::std::mem::transmute::<*mut libc::c_void, + Option + libc::c_char>>(dlsym(handle, + b"NeAACDecInit2\x00" + as + *const u8 + as + *const libc::c_char)); + (*a).NeAACDecDecode = + ::std::mem::transmute::<*mut libc::c_void, + Option + *mut libc::c_void>>(dlsym(handle, + b"NeAACDecDecode\x00" + as + *const u8 + as + *const libc::c_char)); + (*a).NeAACDecGetErrorMessage = + ::std::mem::transmute::<*mut libc::c_void, + Option + *mut libc::c_char>>(dlsym(handle, + b"NeAACDecGetErrorMessage\x00" + as + *const u8 + as + *const libc::c_char)); + err = 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_faad\x00")) - .as_ptr(), - 607 as libc::c_int, - err, - ); + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d dlerror: %s\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 10], + &[libc::c_char; 10]>(b"load_faad\x00")).as_ptr(), + 607 as libc::c_int, err); } - return 0 as libc::c_int != 0; + 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 libfaad.so.2\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_faad\x00")).as_ptr(), - 611 as libc::c_int, - ); + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d loaded libfaad.so.2\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 10], + &[libc::c_char; 10]>(b"load_faad\x00")).as_ptr(), + 611 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 @@ -1504,50 +1440,44 @@ unsafe extern "C" fn load_faad() -> bool { // dop.c // codecs #[no_mangle] - -pub unsafe extern "C" fn register_faad() -> *mut crate::squeezelite_h::codec { - static mut ret: crate::squeezelite_h::codec = unsafe { - { - let mut init = crate::squeezelite_h::codec { - id: 'a' as i32 as libc::c_char, - types: b"aac\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: 20480 as libc::c_int as libc::c_uint, - open: Some( - faad_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(faad_close as unsafe extern "C" fn() -> ()), - decode: Some( - faad_decode as unsafe extern "C" fn() -> crate::squeezelite_h::decode_state, - ), - }; - init - } - }; - a = crate::stdlib::malloc(::std::mem::size_of::() as libc::c_ulong) as *mut faad; - if a.is_null() { - return 0 as *mut crate::squeezelite_h::codec; - } +pub unsafe extern "C" fn register_faad() -> *mut codec { + static mut ret: codec = + unsafe { + { + let mut init = + codec{id: 'a' as i32 as libc::c_char, + types: + b"aac\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: 20480 as libc::c_int as libc::c_uint, + open: + Some(faad_open as + unsafe extern "C" fn(_: u8_t, _: u8_t, + _: u8_t, _: u8_t) + -> ()), + close: + Some(faad_close as + unsafe extern "C" fn() -> ()), + decode: + Some(faad_decode as + unsafe extern "C" fn() + -> decode_state),}; + init + } + }; + a = malloc(::std::mem::size_of::() as libc::c_ulong) as *mut faad; + if a.is_null() { return 0 as *mut codec } (*a).hAac = 0 as *mut libc::c_void; (*a).chunkinfo = 0 as *mut chunk_table; (*a).stsc = 0 as *mut libc::c_void; - if !load_faad() { - 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 faad to decode aac\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_faad\x00")) - .as_ptr(), - 641 as libc::c_int, - ); + if !load_faad() { return 0 as *mut codec } + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d using faad to decode aac\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 14], + &[libc::c_char; 14]>(b"register_faad\x00")).as_ptr(), + 641 as libc::c_int); } return &mut ret; } diff --git a/src/flac.rs b/src/flac.rs index 28e883a..4693ab8 100644 --- a/src/flac.rs +++ b/src/flac.rs @@ -1,261 +1,277 @@ -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; +use ::c2rust_bitfields; extern "C" { + pub type FLAC__StreamDecoderPrivate; + pub type FLAC__StreamDecoderProtected; #[no_mangle] - pub static mut loglevel: crate::squeezelite_h::log_level; + fn malloc(_: libc::c_ulong) -> *mut libc::c_void; #[no_mangle] - pub static mut streambuf: *mut crate::squeezelite_h::buffer; + fn memcpy(_: *mut libc::c_void, _: *const libc::c_void, _: libc::c_ulong) + -> *mut libc::c_void; #[no_mangle] - pub static mut outputbuf: *mut crate::squeezelite_h::buffer; + fn _checkfade(_: bool); #[no_mangle] - pub static mut stream: crate::squeezelite_h::streamstate; + fn decode_newstream(sample_rate: libc::c_uint, + supported_rates: *mut libc::c_uint) -> libc::c_uint; #[no_mangle] - pub static mut output: crate::squeezelite_h::outputstate; + fn dlopen(__file: *const libc::c_char, __mode: libc::c_int) + -> *mut libc::c_void; #[no_mangle] - pub static mut decode: crate::squeezelite_h::decodestate; + fn dlsym(__handle: *mut libc::c_void, __name: *const libc::c_char) + -> *mut libc::c_void; + #[no_mangle] + fn dlerror() -> *mut libc::c_char; + #[no_mangle] + fn pthread_mutex_lock(__mutex: *mut pthread_mutex_t) -> libc::c_int; + #[no_mangle] + fn pthread_mutex_unlock(__mutex: *mut pthread_mutex_t) -> libc::c_int; + #[no_mangle] + fn logtime() -> *const libc::c_char; + #[no_mangle] + fn logprint(fmt: *const libc::c_char, _: ...); + #[no_mangle] + fn _buf_used(buf: *mut buffer) -> libc::c_uint; + #[no_mangle] + fn _buf_space(buf: *mut buffer) -> libc::c_uint; + #[no_mangle] + fn _buf_cont_read(buf: *mut buffer) -> libc::c_uint; + #[no_mangle] + fn _buf_cont_write(buf: *mut buffer) -> libc::c_uint; + #[no_mangle] + fn _buf_inc_readp(buf: *mut buffer, by: libc::c_uint); + #[no_mangle] + fn _buf_inc_writep(buf: *mut buffer, by: libc::c_uint); + #[no_mangle] + static mut loglevel: log_level; + #[no_mangle] + static mut streambuf: *mut buffer; + #[no_mangle] + static mut outputbuf: *mut buffer; + #[no_mangle] + static mut stream: streamstate; + #[no_mangle] + static mut output: outputstate; + #[no_mangle] + static mut decode: decodestate; } -/* +pub type size_t = libc::c_ulong; +pub type __uint8_t = libc::c_uchar; +pub type __uint16_t = libc::c_ushort; +pub type __int32_t = libc::c_int; +pub type __uint32_t = libc::c_uint; +pub type __uint64_t = libc::c_ulong; +pub type int32_t = __int32_t; +pub type u_int8_t = __uint8_t; +pub type u_int32_t = __uint32_t; +pub type u_int64_t = __uint64_t; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct __pthread_internal_list { + pub __prev: *mut __pthread_internal_list, + pub __next: *mut __pthread_internal_list, +} +pub type __pthread_list_t = __pthread_internal_list; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct __pthread_mutex_s { + pub __lock: libc::c_int, + pub __count: libc::c_uint, + pub __owner: libc::c_int, + pub __nusers: libc::c_uint, + pub __kind: libc::c_int, + pub __spins: libc::c_short, + pub __elision: libc::c_short, + pub __list: __pthread_list_t, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub union pthread_mutex_t { + pub __data: __pthread_mutex_s, + pub __size: [libc::c_char; 40], + pub __align: libc::c_long, +} +pub type uint8_t = __uint8_t; +pub type uint16_t = __uint16_t; +pub type uint32_t = __uint32_t; +pub type uint64_t = __uint64_t; +pub type u8_t = u_int8_t; +pub type u32_t = u_int32_t; +pub type u64_t = u_int64_t; +pub type s32_t = int32_t; +pub type frames_t = u32_t; +pub type log_level = libc::c_uint; +pub const lSDEBUG: log_level = 4; +pub const lDEBUG: log_level = 3; +pub const lINFO: log_level = 2; +pub const lWARN: log_level = 1; +pub const lERROR: log_level = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct buffer { + pub buf: *mut u8_t, + pub readp: *mut u8_t, + pub writep: *mut u8_t, + pub wrap: *mut u8_t, + pub size: size_t, + pub base_size: size_t, + pub mutex: pthread_mutex_t, +} +pub type stream_state = libc::c_uint; +pub const RECV_HEADERS: stream_state = 7; +pub const SEND_HEADERS: stream_state = 6; +pub const STREAMING_HTTP: stream_state = 5; +pub const STREAMING_FILE: stream_state = 4; +pub const STREAMING_BUFFERING: stream_state = 3; +pub const STREAMING_WAIT: stream_state = 2; +pub const DISCONNECT: stream_state = 1; +pub const STOPPED: stream_state = 0; +pub type disconnect_code = libc::c_uint; +pub const TIMEOUT: disconnect_code = 4; +pub const UNREACHABLE: disconnect_code = 3; +pub const REMOTE_DISCONNECT: disconnect_code = 2; +pub const LOCAL_DISCONNECT: disconnect_code = 1; +pub const DISCONNECT_OK: disconnect_code = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct streamstate { + pub state: stream_state, + pub disconnect: disconnect_code, + pub header: *mut libc::c_char, + pub header_len: size_t, + pub sent_headers: bool, + pub cont_wait: bool, + pub bytes: u64_t, + pub threshold: libc::c_uint, + pub meta_interval: u32_t, + pub meta_next: u32_t, + pub meta_left: u32_t, + pub meta_send: bool, +} +pub type decode_state = libc::c_uint; +pub const DECODE_ERROR: decode_state = 4; +pub const DECODE_COMPLETE: decode_state = 3; +pub const DECODE_RUNNING: decode_state = 2; +pub const DECODE_READY: decode_state = 1; +pub const DECODE_STOPPED: decode_state = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct decodestate { + pub state: decode_state, + pub new_stream: bool, + pub mutex: pthread_mutex_t, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct codec { + pub id: libc::c_char, + pub types: *mut libc::c_char, + pub min_read_bytes: libc::c_uint, + pub min_space: libc::c_uint, + pub open: Option ()>, + pub close: Option ()>, + pub decode: Option decode_state>, +} +pub type output_state = libc::c_int; +pub const OUTPUT_START_AT: output_state = 5; +pub const OUTPUT_SKIP_FRAMES: output_state = 4; +pub const OUTPUT_PAUSE_FRAMES: output_state = 3; +pub const OUTPUT_RUNNING: output_state = 2; +pub const OUTPUT_BUFFER: output_state = 1; +pub const OUTPUT_STOPPED: output_state = 0; +pub const OUTPUT_OFF: output_state = -1; +pub type output_format = libc::c_uint; +pub const S16_LE: output_format = 3; +pub const S24_3LE: output_format = 2; +pub const S24_LE: output_format = 1; +pub const S32_LE: output_format = 0; +pub type fade_state = libc::c_uint; +pub const FADE_ACTIVE: fade_state = 2; +pub const FADE_DUE: fade_state = 1; +pub const FADE_INACTIVE: fade_state = 0; +pub type fade_dir = libc::c_uint; +pub const FADE_CROSS: fade_dir = 3; +pub const FADE_DOWN: fade_dir = 2; +pub const FADE_UP: fade_dir = 1; +pub type fade_mode = libc::c_uint; +pub const FADE_INOUT: fade_mode = 4; +pub const FADE_OUT: fade_mode = 3; +pub const FADE_IN: fade_mode = 2; +pub const FADE_CROSSFADE: fade_mode = 1; +pub const FADE_NONE: fade_mode = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct outputstate { + pub state: output_state, + pub format: output_format, + pub device: *const libc::c_char, + pub buffer: libc::c_uint, + pub period: libc::c_uint, + pub track_started: bool, + pub write_cb: Option libc::c_int>, + pub start_frames: libc::c_uint, + pub frames_played: libc::c_uint, + pub frames_played_dmp: libc::c_uint, + pub current_sample_rate: libc::c_uint, + pub supported_rates: [libc::c_uint; 18], + pub default_sample_rate: libc::c_uint, + pub error_opening: bool, + pub device_frames: libc::c_uint, + pub updated: u32_t, + pub track_start_time: u32_t, + pub current_replay_gain: u32_t, + pub c2rust_unnamed: C2RustUnnamed, + pub next_sample_rate: libc::c_uint, + pub track_start: *mut u8_t, + pub gainL: u32_t, + pub gainR: u32_t, + pub invert: bool, + pub next_replay_gain: u32_t, + pub threshold: libc::c_uint, + pub fade: fade_state, + pub fade_start: *mut u8_t, + pub fade_end: *mut u8_t, + pub fade_dir: fade_dir, + pub fade_mode: fade_mode, + pub fade_secs: libc::c_uint, + pub rate_delay: libc::c_uint, + pub delay_active: bool, + pub stop_time: u32_t, + pub idle_to: u32_t, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub union C2RustUnnamed { + pub pause_frames: u32_t, + pub skip_frames: u32_t, + pub start_at: u32_t, +} +pub const FLAC__STREAM_DECODER_END_OF_STREAM: FLAC__StreamDecoderState = 4; +pub type FLAC__StreamDecoderState = libc::c_uint; +pub const FLAC__STREAM_DECODER_UNINITIALIZED: FLAC__StreamDecoderState = 9; +pub const FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR: + FLAC__StreamDecoderState = + 8; +pub const FLAC__STREAM_DECODER_ABORTED: FLAC__StreamDecoderState = 7; +pub const FLAC__STREAM_DECODER_SEEK_ERROR: FLAC__StreamDecoderState = 6; +pub const FLAC__STREAM_DECODER_OGG_ERROR: FLAC__StreamDecoderState = 5; +pub const FLAC__STREAM_DECODER_READ_FRAME: FLAC__StreamDecoderState = 3; +pub const FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC: FLAC__StreamDecoderState + = + 2; +pub const FLAC__STREAM_DECODER_READ_METADATA: FLAC__StreamDecoderState = 1; +pub const FLAC__STREAM_DECODER_SEARCH_FOR_METADATA: FLAC__StreamDecoderState = + 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct FLAC__StreamDecoder { + pub protected_: *mut FLAC__StreamDecoderProtected, + pub private_: *mut FLAC__StreamDecoderPrivate, +} +/* * Squeezelite - lightweight headless squeezeplay emulator for linux * * (c) Adrian Smith 2012, triode1@btinternet.com @@ -264,7 +280,7 @@ extern "C" { * 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 @@ -274,162 +290,589 @@ extern "C" { * along with this program. If not, see . * */ - -#[repr(C)] #[derive(Copy, Clone)] +#[repr(C)] pub struct flac { - pub decoder: *mut crate::stdlib::FLAC__StreamDecoder, + pub decoder: *mut FLAC__StreamDecoder, pub FLAC__StreamDecoderErrorStatusString: *mut *const libc::c_char, pub FLAC__StreamDecoderStateString: *mut *const libc::c_char, - pub FLAC__stream_decoder_new: - Option *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 ()>, - 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, - >, + pub FLAC__stream_decoder_new: Option *mut FLAC__StreamDecoder>, + pub FLAC__stream_decoder_reset: Option FLAC__bool>, + pub FLAC__stream_decoder_delete: Option ()>, + pub FLAC__stream_decoder_init_stream: Option + FLAC__StreamDecoderInitStatus>, + pub FLAC__stream_decoder_init_ogg_stream: Option + FLAC__StreamDecoderInitStatus>, + pub FLAC__stream_decoder_process_single: Option FLAC__bool>, + pub FLAC__stream_decoder_get_state: Option + FLAC__StreamDecoderState>, } - +pub type FLAC__bool = libc::c_int; +pub type FLAC__StreamDecoderErrorCallback + = + Option ()>; +pub type FLAC__StreamDecoderErrorStatus = libc::c_uint; +pub const FLAC__STREAM_DECODER_ERROR_STATUS_UNPARSEABLE_STREAM: + FLAC__StreamDecoderErrorStatus = + 3; +pub const FLAC__STREAM_DECODER_ERROR_STATUS_FRAME_CRC_MISMATCH: + FLAC__StreamDecoderErrorStatus = + 2; +pub const FLAC__STREAM_DECODER_ERROR_STATUS_BAD_HEADER: + FLAC__StreamDecoderErrorStatus = + 1; +pub const FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC: + FLAC__StreamDecoderErrorStatus = + 0; +pub type FLAC__StreamDecoderMetadataCallback + = + Option ()>; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct FLAC__StreamMetadata { + pub type_0: FLAC__MetadataType, + pub is_last: FLAC__bool, + pub length: uint32_t, + pub data: C2RustUnnamed_0, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub union C2RustUnnamed_0 { + pub stream_info: FLAC__StreamMetadata_StreamInfo, + pub padding: FLAC__StreamMetadata_Padding, + pub application: FLAC__StreamMetadata_Application, + pub seek_table: FLAC__StreamMetadata_SeekTable, + pub vorbis_comment: FLAC__StreamMetadata_VorbisComment, + pub cue_sheet: FLAC__StreamMetadata_CueSheet, + pub picture: FLAC__StreamMetadata_Picture, + pub unknown: FLAC__StreamMetadata_Unknown, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct FLAC__StreamMetadata_Unknown { + pub data: *mut FLAC__byte, +} +pub type FLAC__byte = FLAC__uint8; +pub type FLAC__uint8 = uint8_t; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct FLAC__StreamMetadata_Picture { + pub type_0: FLAC__StreamMetadata_Picture_Type, + pub mime_type: *mut libc::c_char, + pub description: *mut FLAC__byte, + pub width: FLAC__uint32, + pub height: FLAC__uint32, + pub depth: FLAC__uint32, + pub colors: FLAC__uint32, + pub data_length: FLAC__uint32, + pub data: *mut FLAC__byte, +} +pub type FLAC__uint32 = uint32_t; +pub type FLAC__StreamMetadata_Picture_Type = libc::c_uint; +pub const FLAC__STREAM_METADATA_PICTURE_TYPE_UNDEFINED: + FLAC__StreamMetadata_Picture_Type = + 21; +pub const FLAC__STREAM_METADATA_PICTURE_TYPE_PUBLISHER_LOGOTYPE: + FLAC__StreamMetadata_Picture_Type = + 20; +pub const FLAC__STREAM_METADATA_PICTURE_TYPE_BAND_LOGOTYPE: + FLAC__StreamMetadata_Picture_Type = + 19; +pub const FLAC__STREAM_METADATA_PICTURE_TYPE_ILLUSTRATION: + FLAC__StreamMetadata_Picture_Type = + 18; +pub const FLAC__STREAM_METADATA_PICTURE_TYPE_FISH: + FLAC__StreamMetadata_Picture_Type = + 17; +pub const FLAC__STREAM_METADATA_PICTURE_TYPE_VIDEO_SCREEN_CAPTURE: + FLAC__StreamMetadata_Picture_Type = + 16; +pub const FLAC__STREAM_METADATA_PICTURE_TYPE_DURING_PERFORMANCE: + FLAC__StreamMetadata_Picture_Type = + 15; +pub const FLAC__STREAM_METADATA_PICTURE_TYPE_DURING_RECORDING: + FLAC__StreamMetadata_Picture_Type = + 14; +pub const FLAC__STREAM_METADATA_PICTURE_TYPE_RECORDING_LOCATION: + FLAC__StreamMetadata_Picture_Type = + 13; +pub const FLAC__STREAM_METADATA_PICTURE_TYPE_LYRICIST: + FLAC__StreamMetadata_Picture_Type = + 12; +pub const FLAC__STREAM_METADATA_PICTURE_TYPE_COMPOSER: + FLAC__StreamMetadata_Picture_Type = + 11; +pub const FLAC__STREAM_METADATA_PICTURE_TYPE_BAND: + FLAC__StreamMetadata_Picture_Type = + 10; +pub const FLAC__STREAM_METADATA_PICTURE_TYPE_CONDUCTOR: + FLAC__StreamMetadata_Picture_Type = + 9; +pub const FLAC__STREAM_METADATA_PICTURE_TYPE_ARTIST: + FLAC__StreamMetadata_Picture_Type = + 8; +pub const FLAC__STREAM_METADATA_PICTURE_TYPE_LEAD_ARTIST: + FLAC__StreamMetadata_Picture_Type = + 7; +pub const FLAC__STREAM_METADATA_PICTURE_TYPE_MEDIA: + FLAC__StreamMetadata_Picture_Type = + 6; +pub const FLAC__STREAM_METADATA_PICTURE_TYPE_LEAFLET_PAGE: + FLAC__StreamMetadata_Picture_Type = + 5; +pub const FLAC__STREAM_METADATA_PICTURE_TYPE_BACK_COVER: + FLAC__StreamMetadata_Picture_Type = + 4; +pub const FLAC__STREAM_METADATA_PICTURE_TYPE_FRONT_COVER: + FLAC__StreamMetadata_Picture_Type = + 3; +pub const FLAC__STREAM_METADATA_PICTURE_TYPE_FILE_ICON: + FLAC__StreamMetadata_Picture_Type = + 2; +pub const FLAC__STREAM_METADATA_PICTURE_TYPE_FILE_ICON_STANDARD: + FLAC__StreamMetadata_Picture_Type = + 1; +pub const FLAC__STREAM_METADATA_PICTURE_TYPE_OTHER: + FLAC__StreamMetadata_Picture_Type = + 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct FLAC__StreamMetadata_CueSheet { + pub media_catalog_number: [libc::c_char; 129], + pub lead_in: FLAC__uint64, + pub is_cd: FLAC__bool, + pub num_tracks: uint32_t, + pub tracks: *mut FLAC__StreamMetadata_CueSheet_Track, +} +#[derive(Copy, Clone, BitfieldStruct)] +#[repr(C)] +pub struct FLAC__StreamMetadata_CueSheet_Track { + pub offset: FLAC__uint64, + pub number: FLAC__byte, + pub isrc: [libc::c_char; 13], + #[bitfield(name = "type_0", ty = "uint32_t", bits = "0..=0")] + #[bitfield(name = "pre_emphasis", ty = "uint32_t", bits = "1..=1")] + pub type_0_pre_emphasis: [u8; 1], + pub num_indices: FLAC__byte, + pub indices: *mut FLAC__StreamMetadata_CueSheet_Index, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct FLAC__StreamMetadata_CueSheet_Index { + pub offset: FLAC__uint64, + pub number: FLAC__byte, +} +pub type FLAC__uint64 = uint64_t; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct FLAC__StreamMetadata_VorbisComment { + pub vendor_string: FLAC__StreamMetadata_VorbisComment_Entry, + pub num_comments: FLAC__uint32, + pub comments: *mut FLAC__StreamMetadata_VorbisComment_Entry, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct FLAC__StreamMetadata_VorbisComment_Entry { + pub length: FLAC__uint32, + pub entry: *mut FLAC__byte, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct FLAC__StreamMetadata_SeekTable { + pub num_points: uint32_t, + pub points: *mut FLAC__StreamMetadata_SeekPoint, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct FLAC__StreamMetadata_SeekPoint { + pub sample_number: FLAC__uint64, + pub stream_offset: FLAC__uint64, + pub frame_samples: uint32_t, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct FLAC__StreamMetadata_Application { + pub id: [FLAC__byte; 4], + pub data: *mut FLAC__byte, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct FLAC__StreamMetadata_Padding { + pub dummy: libc::c_int, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct FLAC__StreamMetadata_StreamInfo { + pub min_blocksize: uint32_t, + pub max_blocksize: uint32_t, + pub min_framesize: uint32_t, + pub max_framesize: uint32_t, + pub sample_rate: uint32_t, + pub channels: uint32_t, + pub bits_per_sample: uint32_t, + pub total_samples: FLAC__uint64, + pub md5sum: [FLAC__byte; 16], +} +pub type FLAC__MetadataType = libc::c_uint; +pub const FLAC__MAX_METADATA_TYPE: FLAC__MetadataType = 126; +pub const FLAC__METADATA_TYPE_UNDEFINED: FLAC__MetadataType = 7; +pub const FLAC__METADATA_TYPE_PICTURE: FLAC__MetadataType = 6; +pub const FLAC__METADATA_TYPE_CUESHEET: FLAC__MetadataType = 5; +pub const FLAC__METADATA_TYPE_VORBIS_COMMENT: FLAC__MetadataType = 4; +pub const FLAC__METADATA_TYPE_SEEKTABLE: FLAC__MetadataType = 3; +pub const FLAC__METADATA_TYPE_APPLICATION: FLAC__MetadataType = 2; +pub const FLAC__METADATA_TYPE_PADDING: FLAC__MetadataType = 1; +pub const FLAC__METADATA_TYPE_STREAMINFO: FLAC__MetadataType = 0; +pub type FLAC__StreamDecoderWriteCallback + = + Option FLAC__StreamDecoderWriteStatus>; +pub type FLAC__int32 = int32_t; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct FLAC__Frame { + pub header: FLAC__FrameHeader, + pub subframes: [FLAC__Subframe; 8], + pub footer: FLAC__FrameFooter, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct FLAC__FrameFooter { + pub crc: FLAC__uint16, +} +pub type FLAC__uint16 = uint16_t; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct FLAC__Subframe { + pub type_0: FLAC__SubframeType, + pub data: C2RustUnnamed_1, + pub wasted_bits: uint32_t, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub union C2RustUnnamed_1 { + pub constant: FLAC__Subframe_Constant, + pub fixed: FLAC__Subframe_Fixed, + pub lpc: FLAC__Subframe_LPC, + pub verbatim: FLAC__Subframe_Verbatim, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct FLAC__Subframe_Verbatim { + pub data: *const FLAC__int32, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct FLAC__Subframe_LPC { + pub entropy_coding_method: FLAC__EntropyCodingMethod, + pub order: uint32_t, + pub qlp_coeff_precision: uint32_t, + pub quantization_level: libc::c_int, + pub qlp_coeff: [FLAC__int32; 32], + pub warmup: [FLAC__int32; 32], + pub residual: *const FLAC__int32, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct FLAC__EntropyCodingMethod { + pub type_0: FLAC__EntropyCodingMethodType, + pub data: C2RustUnnamed_2, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub union C2RustUnnamed_2 { + pub partitioned_rice: FLAC__EntropyCodingMethod_PartitionedRice, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct FLAC__EntropyCodingMethod_PartitionedRice { + pub order: uint32_t, + pub contents: *const FLAC__EntropyCodingMethod_PartitionedRiceContents, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct FLAC__EntropyCodingMethod_PartitionedRiceContents { + pub parameters: *mut uint32_t, + pub raw_bits: *mut uint32_t, + pub capacity_by_order: uint32_t, +} +pub type FLAC__EntropyCodingMethodType = libc::c_uint; +pub const FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2: + FLAC__EntropyCodingMethodType = + 1; +pub const FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE: + FLAC__EntropyCodingMethodType = + 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct FLAC__Subframe_Fixed { + pub entropy_coding_method: FLAC__EntropyCodingMethod, + pub order: uint32_t, + pub warmup: [FLAC__int32; 4], + pub residual: *const FLAC__int32, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct FLAC__Subframe_Constant { + pub value: FLAC__int32, +} +pub type FLAC__SubframeType = libc::c_uint; +pub const FLAC__SUBFRAME_TYPE_LPC: FLAC__SubframeType = 3; +pub const FLAC__SUBFRAME_TYPE_FIXED: FLAC__SubframeType = 2; +pub const FLAC__SUBFRAME_TYPE_VERBATIM: FLAC__SubframeType = 1; +pub const FLAC__SUBFRAME_TYPE_CONSTANT: FLAC__SubframeType = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct FLAC__FrameHeader { + pub blocksize: uint32_t, + pub sample_rate: uint32_t, + pub channels: uint32_t, + pub channel_assignment: FLAC__ChannelAssignment, + pub bits_per_sample: uint32_t, + pub number_type: FLAC__FrameNumberType, + pub number: C2RustUnnamed_3, + pub crc: FLAC__uint8, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub union C2RustUnnamed_3 { + pub frame_number: FLAC__uint32, + pub sample_number: FLAC__uint64, +} +pub type FLAC__FrameNumberType = libc::c_uint; +pub const FLAC__FRAME_NUMBER_TYPE_SAMPLE_NUMBER: FLAC__FrameNumberType = 1; +pub const FLAC__FRAME_NUMBER_TYPE_FRAME_NUMBER: FLAC__FrameNumberType = 0; +pub type FLAC__ChannelAssignment = libc::c_uint; +pub const FLAC__CHANNEL_ASSIGNMENT_MID_SIDE: FLAC__ChannelAssignment = 3; +pub const FLAC__CHANNEL_ASSIGNMENT_RIGHT_SIDE: FLAC__ChannelAssignment = 2; +pub const FLAC__CHANNEL_ASSIGNMENT_LEFT_SIDE: FLAC__ChannelAssignment = 1; +pub const FLAC__CHANNEL_ASSIGNMENT_INDEPENDENT: FLAC__ChannelAssignment = 0; +pub type FLAC__StreamDecoderWriteStatus = libc::c_uint; +pub const FLAC__STREAM_DECODER_WRITE_STATUS_ABORT: + FLAC__StreamDecoderWriteStatus = + 1; +pub const FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE: + FLAC__StreamDecoderWriteStatus = + 0; +pub type FLAC__StreamDecoderEofCallback + = + Option FLAC__bool>; +pub type FLAC__StreamDecoderLengthCallback + = + Option FLAC__StreamDecoderLengthStatus>; +pub type FLAC__StreamDecoderLengthStatus = libc::c_uint; +pub const FLAC__STREAM_DECODER_LENGTH_STATUS_UNSUPPORTED: + FLAC__StreamDecoderLengthStatus = + 2; +pub const FLAC__STREAM_DECODER_LENGTH_STATUS_ERROR: + FLAC__StreamDecoderLengthStatus = + 1; +pub const FLAC__STREAM_DECODER_LENGTH_STATUS_OK: + FLAC__StreamDecoderLengthStatus = + 0; +pub type FLAC__StreamDecoderTellCallback + = + Option FLAC__StreamDecoderTellStatus>; +pub type FLAC__StreamDecoderTellStatus = libc::c_uint; +pub const FLAC__STREAM_DECODER_TELL_STATUS_UNSUPPORTED: + FLAC__StreamDecoderTellStatus = + 2; +pub const FLAC__STREAM_DECODER_TELL_STATUS_ERROR: + FLAC__StreamDecoderTellStatus = + 1; +pub const FLAC__STREAM_DECODER_TELL_STATUS_OK: FLAC__StreamDecoderTellStatus = + 0; +pub type FLAC__StreamDecoderSeekCallback + = + Option FLAC__StreamDecoderSeekStatus>; +pub type FLAC__StreamDecoderSeekStatus = libc::c_uint; +pub const FLAC__STREAM_DECODER_SEEK_STATUS_UNSUPPORTED: + FLAC__StreamDecoderSeekStatus = + 2; +pub const FLAC__STREAM_DECODER_SEEK_STATUS_ERROR: + FLAC__StreamDecoderSeekStatus = + 1; +pub const FLAC__STREAM_DECODER_SEEK_STATUS_OK: FLAC__StreamDecoderSeekStatus = + 0; +pub type FLAC__StreamDecoderReadCallback + = + Option FLAC__StreamDecoderReadStatus>; +pub type FLAC__StreamDecoderReadStatus = libc::c_uint; +pub const FLAC__STREAM_DECODER_READ_STATUS_ABORT: + FLAC__StreamDecoderReadStatus = + 2; +pub const FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM: + FLAC__StreamDecoderReadStatus = + 1; +pub const FLAC__STREAM_DECODER_READ_STATUS_CONTINUE: + FLAC__StreamDecoderReadStatus = + 0; +pub type FLAC__StreamDecoderInitStatus = libc::c_uint; +pub const FLAC__STREAM_DECODER_INIT_STATUS_ALREADY_INITIALIZED: + FLAC__StreamDecoderInitStatus = + 5; +pub const FLAC__STREAM_DECODER_INIT_STATUS_ERROR_OPENING_FILE: + FLAC__StreamDecoderInitStatus = + 4; +pub const FLAC__STREAM_DECODER_INIT_STATUS_MEMORY_ALLOCATION_ERROR: + FLAC__StreamDecoderInitStatus = + 3; +pub const FLAC__STREAM_DECODER_INIT_STATUS_INVALID_CALLBACKS: + FLAC__StreamDecoderInitStatus = + 2; +pub const FLAC__STREAM_DECODER_INIT_STATUS_UNSUPPORTED_CONTAINER: + FLAC__StreamDecoderInitStatus = + 1; +pub const FLAC__STREAM_DECODER_INIT_STATUS_OK: FLAC__StreamDecoderInitStatus = + 0; 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; +unsafe extern "C" fn read_cb(mut decoder: *const FLAC__StreamDecoder, + mut buffer: *mut FLAC__byte, + mut want: *mut size_t, + mut client_data: *mut libc::c_void) + -> FLAC__StreamDecoderReadStatus { + let mut bytes: 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; + pthread_mutex_lock(&mut (*streambuf).mutex); + bytes = + if _buf_used(streambuf) < _buf_cont_read(streambuf) { + _buf_used(streambuf) + } else { _buf_cont_read(streambuf) } as size_t; bytes = if bytes < *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); + end = + stream.state as libc::c_uint <= + DISCONNECT as libc::c_int as libc::c_uint && + bytes == 0 as libc::c_int as libc::c_ulong; + memcpy(buffer as *mut libc::c_void, + (*streambuf).readp as *const libc::c_void, bytes); + _buf_inc_readp(streambuf, bytes as libc::c_uint); + 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; + FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM as libc::c_int + } else { FLAC__STREAM_DECODER_READ_STATUS_CONTINUE as libc::c_int } + as 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; +unsafe extern "C" fn write_cb(mut decoder: *const FLAC__StreamDecoder, + mut frame: *const FLAC__Frame, + mut buffer: *const *const FLAC__int32, + mut client_data: *mut libc::c_void) + -> FLAC__StreamDecoderWriteStatus { + let mut frames: size_t = (*frame).header.blocksize as size_t; + let mut bits_per_sample: libc::c_uint = (*frame).header.bits_per_sample; + let mut channels: libc::c_uint = (*frame).header.channels; + let mut lptr: *mut FLAC__int32 = + *buffer.offset(0 as libc::c_int as isize) as *mut FLAC__int32; + let mut rptr: *mut FLAC__int32 = + *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 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, - ); + pthread_mutex_lock(&mut (*outputbuf).mutex); + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d setting track_start\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 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); + output.next_sample_rate = + decode_newstream((*frame).header.sample_rate, + output.supported_rates.as_mut_ptr()); + if output.fade_mode as u64 != 0 { _checkfade(1 as libc::c_int != 0); } + pthread_mutex_unlock(&mut (*outputbuf).mutex); } - crate::stdlib::pthread_mutex_lock(&mut (*outputbuf).mutex); + 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; + let mut f_0: frames_t = 0; + let mut count: frames_t = 0; + let mut optr: *mut s32_t = 0 as *mut s32_t; + optr = (*outputbuf).writep as *mut s32_t; + f_0 = + (if _buf_space(outputbuf) < _buf_cont_write(outputbuf) { + _buf_space(outputbuf) + } else { + _buf_cont_write(outputbuf) + }).wrapping_div(8 as libc::c_int as libc::c_uint); + f_0 = + if (f_0 as libc::c_ulong) < frames { + f_0 as libc::c_ulong + } else { frames } as frames_t; count = f_0; if bits_per_sample == 8 as libc::c_int as libc::c_uint { - loop { + loop { let fresh0 = count; count = count.wrapping_sub(1); - if !(fresh0 != 0) { - break; - } + if !(fresh0 != 0) { break ; } let fresh1 = lptr; lptr = lptr.offset(1); let fresh2 = optr; @@ -442,12 +885,10 @@ unsafe extern "C" fn write_cb( *fresh4 = *fresh3 << 24 as libc::c_int } } else if bits_per_sample == 16 as libc::c_int as libc::c_uint { - loop { + loop { let fresh5 = count; count = count.wrapping_sub(1); - if !(fresh5 != 0) { - break; - } + if !(fresh5 != 0) { break ; } let fresh6 = lptr; lptr = lptr.offset(1); let fresh7 = optr; @@ -460,12 +901,10 @@ unsafe extern "C" fn write_cb( *fresh9 = *fresh8 << 16 as libc::c_int } } else if bits_per_sample == 24 as libc::c_int as libc::c_uint { - loop { + loop { let fresh10 = count; count = count.wrapping_sub(1); - if !(fresh10 != 0) { - break; - } + if !(fresh10 != 0) { break ; } let fresh11 = lptr; lptr = lptr.offset(1); let fresh12 = optr; @@ -478,12 +917,10 @@ unsafe extern "C" fn write_cb( *fresh14 = *fresh13 << 8 as libc::c_int } } else if bits_per_sample == 32 as libc::c_int as libc::c_uint { - loop { + loop { let fresh15 = count; count = count.wrapping_sub(1); - if !(fresh15 != 0) { - break; - } + if !(fresh15 != 0) { break ; } let fresh16 = lptr; lptr = lptr.offset(1); let fresh17 = optr; @@ -496,340 +933,336 @@ unsafe extern "C" fn write_cb( *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, - ); + logprint(b"%s %s:%d unsupported bits per sample: %u\n\x00" as + *const u8 as *const libc::c_char, 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), - ); + frames = + (frames as libc::c_ulong).wrapping_sub(f_0 as libc::c_ulong) as + size_t as size_t; + _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; + pthread_mutex_unlock(&mut (*outputbuf).mutex); + return 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 error_cb(mut decoder: *const FLAC__StreamDecoder, + mut status: FLAC__StreamDecoderErrorStatus, + mut client_data: *mut libc::c_void) { + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d flac error: %s\n\x00" as *const u8 as + *const libc::c_char, 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, -) { +unsafe extern "C" fn flac_open(mut sample_size: u8_t, mut sample_rate: u8_t, + mut channels: u8_t, mut endianness: u8_t) { if !(*f).decoder.is_null() { - (*f).FLAC__stream_decoder_reset - .expect("non-null function pointer")((*f).decoder); + (*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")() + (*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, - ); + if loglevel as libc::c_uint >= lDEBUG as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d ogg/flac container - using init_ogg_stream\n\x00" + as *const u8 as *const libc::c_char, 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, - ); + (*f).FLAC__stream_decoder_init_ogg_stream.expect("non-null function pointer")((*f).decoder, + Some(read_cb + as + unsafe extern "C" fn(_: + *const FLAC__StreamDecoder, + _: + *mut FLAC__byte, + _: + *mut size_t, + _: + *mut libc::c_void) + -> + FLAC__StreamDecoderReadStatus), + None, + None, + None, + None, + Some(write_cb + as + unsafe extern "C" fn(_: + *const FLAC__StreamDecoder, + _: + *const FLAC__Frame, + _: + *const *const FLAC__int32, + _: + *mut libc::c_void) + -> + FLAC__StreamDecoderWriteStatus), + None, + Some(error_cb + as + unsafe extern "C" fn(_: + *const FLAC__StreamDecoder, + _: + 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, - ); + (*f).FLAC__stream_decoder_init_stream.expect("non-null function pointer")((*f).decoder, + Some(read_cb + as + unsafe extern "C" fn(_: + *const FLAC__StreamDecoder, + _: + *mut FLAC__byte, + _: + *mut size_t, + _: + *mut libc::c_void) + -> + FLAC__StreamDecoderReadStatus), + None, + None, + None, + None, + Some(write_cb + as + unsafe extern "C" fn(_: + *const FLAC__StreamDecoder, + _: + *const FLAC__Frame, + _: + *const *const FLAC__int32, + _: + *mut libc::c_void) + -> + FLAC__StreamDecoderWriteStatus), + None, + Some(error_cb + as + unsafe extern "C" fn(_: + *const FLAC__StreamDecoder, + _: + 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; + (*f).FLAC__stream_decoder_delete.expect("non-null function pointer")((*f).decoder); + (*f).decoder = 0 as *mut 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), - ); +unsafe extern "C" fn flac_decode() -> decode_state { + let mut ok: bool = + (*f).FLAC__stream_decoder_process_single.expect("non-null function pointer")((*f).decoder) + != 0; + let mut state: FLAC__StreamDecoderState = + (*f).FLAC__stream_decoder_get_state.expect("non-null function pointer")((*f).decoder); + if !ok && + state as libc::c_uint != + FLAC__STREAM_DECODER_END_OF_STREAM as libc::c_int as + libc::c_uint { + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d flac error: %s\n\x00" as *const u8 as + *const libc::c_char, 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; - }; + if state as libc::c_uint == + FLAC__STREAM_DECODER_END_OF_STREAM as libc::c_int as libc::c_uint { + return DECODE_COMPLETE + } else if state as libc::c_uint > + FLAC__STREAM_DECODER_END_OF_STREAM as libc::c_int as + libc::c_uint { + return DECODE_ERROR + } else { return 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; + let mut handle: *mut libc::c_void = + dlopen(b"libFLAC.so.8\x00" as *const u8 as *const libc::c_char, + 0x2 as libc::c_int); + let mut err: *mut libc::c_char = 0 as *mut libc::c_char; if handle.is_null() { - if loglevel as libc::c_uint >= 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(), - ); + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d dlerror: %s\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 10], + &[libc::c_char; 10]>(b"load_flac\x00")).as_ptr(), + 267 as libc::c_int, dlerror()); } - return 0 as libc::c_int != 0; + 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 *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 ()>, - >(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(); + (*f).FLAC__StreamDecoderErrorStatusString = + dlsym(handle, + b"FLAC__StreamDecoderErrorStatusString\x00" as *const u8 as + *const libc::c_char) as *mut *const libc::c_char; + (*f).FLAC__StreamDecoderStateString = + 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 + *mut FLAC__StreamDecoder>>(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 + FLAC__bool>>(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 + ()>>(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 + FLAC__StreamDecoderInitStatus>>(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 + FLAC__StreamDecoderInitStatus>>(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 + FLAC__bool>>(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 + FLAC__StreamDecoderState>>(dlsym(handle, + b"FLAC__stream_decoder_get_state\x00" + as + *const u8 + as + *const libc::c_char)); + err = 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, - ); + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d dlerror: %s\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 10], + &[libc::c_char; 10]>(b"load_flac\x00")).as_ptr(), + 282 as libc::c_int, err); } - return 0 as libc::c_int != 0; + 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, - ); + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d loaded libFLAC.so.8\n\x00" as *const u8 as + *const libc::c_char, 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 @@ -880,48 +1313,43 @@ unsafe extern "C" fn load_flac() -> bool { // 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::() 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, - ); +pub unsafe extern "C" fn register_flac() -> *mut codec { + static mut ret: codec = + unsafe { + { + let mut init = + 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(_: u8_t, _: u8_t, + _: u8_t, _: u8_t) + -> ()), + close: + Some(flac_close as + unsafe extern "C" fn() -> ()), + decode: + Some(flac_decode as + unsafe extern "C" fn() + -> decode_state),}; + init + } + }; + f = malloc(::std::mem::size_of::() as libc::c_ulong) as *mut flac; + if f.is_null() { return 0 as *mut codec } + (*f).decoder = 0 as *mut FLAC__StreamDecoder; + if !load_flac() { return 0 as *mut codec } + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d using flac to decode ogf,flc\n\x00" as *const u8 + as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 14], + &[libc::c_char; 14]>(b"register_flac\x00")).as_ptr(), + 314 as libc::c_int); } return &mut ret; } diff --git a/src/internal.rs b/src/internal.rs deleted file mode 100644 index bfe0b43..0000000 --- a/src/internal.rs +++ /dev/null @@ -1,9 +0,0 @@ -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, -} diff --git a/src/mad.rs b/src/mad.rs index 1ec1a51..18b6903 100644 --- a/src/mad.rs +++ b/src/mad.rs @@ -1,317 +1,504 @@ 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; + fn _checkfade(_: bool); #[no_mangle] - pub static mut streambuf: *mut crate::squeezelite_h::buffer; + fn decode_newstream(sample_rate: libc::c_uint, + supported_rates: *mut libc::c_uint) -> libc::c_uint; #[no_mangle] - pub static mut outputbuf: *mut crate::squeezelite_h::buffer; + fn _buf_inc_writep(buf: *mut buffer, by: libc::c_uint); #[no_mangle] - pub static mut stream: crate::squeezelite_h::streamstate; + fn _buf_inc_readp(buf: *mut buffer, by: libc::c_uint); #[no_mangle] - pub static mut output: crate::squeezelite_h::outputstate; + fn _buf_cont_write(buf: *mut buffer) -> libc::c_uint; #[no_mangle] - pub static mut decode: crate::squeezelite_h::decodestate; + fn _buf_cont_read(buf: *mut buffer) -> libc::c_uint; + #[no_mangle] + fn _buf_space(buf: *mut buffer) -> libc::c_uint; + #[no_mangle] + fn _buf_used(buf: *mut buffer) -> libc::c_uint; + #[no_mangle] + fn unpackN(src: *mut u32_t) -> u32_t; + #[no_mangle] + fn malloc(_: libc::c_ulong) -> *mut libc::c_void; + #[no_mangle] + fn free(__ptr: *mut libc::c_void); + #[no_mangle] + fn memcpy(_: *mut libc::c_void, _: *const libc::c_void, _: libc::c_ulong) + -> *mut libc::c_void; + #[no_mangle] + fn memmove(_: *mut libc::c_void, _: *const libc::c_void, _: libc::c_ulong) + -> *mut libc::c_void; + #[no_mangle] + fn memset(_: *mut libc::c_void, _: libc::c_int, _: libc::c_ulong) + -> *mut libc::c_void; + #[no_mangle] + fn memcmp(_: *const libc::c_void, _: *const libc::c_void, + _: libc::c_ulong) -> libc::c_int; + #[no_mangle] + fn dlopen(__file: *const libc::c_char, __mode: libc::c_int) + -> *mut libc::c_void; + #[no_mangle] + fn dlsym(__handle: *mut libc::c_void, __name: *const libc::c_char) + -> *mut libc::c_void; + #[no_mangle] + fn dlerror() -> *mut libc::c_char; + #[no_mangle] + fn pthread_mutex_lock(__mutex: *mut pthread_mutex_t) -> libc::c_int; + #[no_mangle] + fn pthread_mutex_unlock(__mutex: *mut pthread_mutex_t) -> libc::c_int; + #[no_mangle] + fn logtime() -> *const libc::c_char; + #[no_mangle] + fn logprint(fmt: *const libc::c_char, _: ...); + #[no_mangle] + static mut loglevel: log_level; + #[no_mangle] + static mut streambuf: *mut buffer; + #[no_mangle] + static mut outputbuf: *mut buffer; + #[no_mangle] + static mut stream: streamstate; + #[no_mangle] + static mut output: outputstate; + #[no_mangle] + static mut decode: decodestate; } -// local buffer used by decoder: FIXME merge with any other decoders needing one? - -#[repr(C)] +pub type size_t = libc::c_ulong; +pub type __uint8_t = libc::c_uchar; +pub type __int32_t = libc::c_int; +pub type __uint32_t = libc::c_uint; +pub type __uint64_t = libc::c_ulong; +pub type int32_t = __int32_t; +pub type u_int8_t = __uint8_t; +pub type u_int32_t = __uint32_t; +pub type u_int64_t = __uint64_t; #[derive(Copy, Clone)] -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 ()>, - pub mad_frame_init: Option ()>, - pub mad_synth_init: Option ()>, - pub mad_frame_finish: Option ()>, - pub mad_stream_finish: Option ()>, - 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 *const libc::c_char>, +#[repr(C)] +pub struct __pthread_internal_list { + pub __prev: *mut __pthread_internal_list, + pub __next: *mut __pthread_internal_list, +} +pub type __pthread_list_t = __pthread_internal_list; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct __pthread_mutex_s { + pub __lock: libc::c_int, + pub __count: libc::c_uint, + pub __owner: libc::c_int, + pub __nusers: libc::c_uint, + pub __kind: libc::c_int, + pub __spins: libc::c_short, + pub __elision: libc::c_short, + pub __list: __pthread_list_t, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub union pthread_mutex_t { + pub __data: __pthread_mutex_s, + pub __size: [libc::c_char; 40], + pub __align: libc::c_long, +} +pub type u8_t = u_int8_t; +pub type u32_t = u_int32_t; +pub type u64_t = u_int64_t; +pub type s32_t = int32_t; +pub type frames_t = u32_t; +pub type log_level = libc::c_uint; +pub const lSDEBUG: log_level = 4; +pub const lDEBUG: log_level = 3; +pub const lINFO: log_level = 2; +pub const lWARN: log_level = 1; +pub const lERROR: log_level = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct buffer { + pub buf: *mut u8_t, + pub readp: *mut u8_t, + pub writep: *mut u8_t, + pub wrap: *mut u8_t, + pub size: size_t, + pub base_size: size_t, + pub mutex: pthread_mutex_t, +} +pub type stream_state = libc::c_uint; +pub const RECV_HEADERS: stream_state = 7; +pub const SEND_HEADERS: stream_state = 6; +pub const STREAMING_HTTP: stream_state = 5; +pub const STREAMING_FILE: stream_state = 4; +pub const STREAMING_BUFFERING: stream_state = 3; +pub const STREAMING_WAIT: stream_state = 2; +pub const DISCONNECT: stream_state = 1; +pub const STOPPED: stream_state = 0; +pub type disconnect_code = libc::c_uint; +pub const TIMEOUT: disconnect_code = 4; +pub const UNREACHABLE: disconnect_code = 3; +pub const REMOTE_DISCONNECT: disconnect_code = 2; +pub const LOCAL_DISCONNECT: disconnect_code = 1; +pub const DISCONNECT_OK: disconnect_code = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct streamstate { + pub state: stream_state, + pub disconnect: disconnect_code, + pub header: *mut libc::c_char, + pub header_len: size_t, + pub sent_headers: bool, + pub cont_wait: bool, + pub bytes: u64_t, + pub threshold: libc::c_uint, + pub meta_interval: u32_t, + pub meta_next: u32_t, + pub meta_left: u32_t, + pub meta_send: bool, +} +pub type decode_state = libc::c_uint; +pub const DECODE_ERROR: decode_state = 4; +pub const DECODE_COMPLETE: decode_state = 3; +pub const DECODE_RUNNING: decode_state = 2; +pub const DECODE_READY: decode_state = 1; +pub const DECODE_STOPPED: decode_state = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct decodestate { + pub state: decode_state, + pub new_stream: bool, + pub mutex: pthread_mutex_t, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct codec { + pub id: libc::c_char, + pub types: *mut libc::c_char, + pub min_read_bytes: libc::c_uint, + pub min_space: libc::c_uint, + pub open: Option ()>, + pub close: Option ()>, + pub decode: Option decode_state>, +} +pub type output_state = libc::c_int; +pub const OUTPUT_START_AT: output_state = 5; +pub const OUTPUT_SKIP_FRAMES: output_state = 4; +pub const OUTPUT_PAUSE_FRAMES: output_state = 3; +pub const OUTPUT_RUNNING: output_state = 2; +pub const OUTPUT_BUFFER: output_state = 1; +pub const OUTPUT_STOPPED: output_state = 0; +pub const OUTPUT_OFF: output_state = -1; +pub type output_format = libc::c_uint; +pub const S16_LE: output_format = 3; +pub const S24_3LE: output_format = 2; +pub const S24_LE: output_format = 1; +pub const S32_LE: output_format = 0; +pub type fade_state = libc::c_uint; +pub const FADE_ACTIVE: fade_state = 2; +pub const FADE_DUE: fade_state = 1; +pub const FADE_INACTIVE: fade_state = 0; +pub type fade_dir = libc::c_uint; +pub const FADE_CROSS: fade_dir = 3; +pub const FADE_DOWN: fade_dir = 2; +pub const FADE_UP: fade_dir = 1; +pub type fade_mode = libc::c_uint; +pub const FADE_INOUT: fade_mode = 4; +pub const FADE_OUT: fade_mode = 3; +pub const FADE_IN: fade_mode = 2; +pub const FADE_CROSSFADE: fade_mode = 1; +pub const FADE_NONE: fade_mode = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct outputstate { + pub state: output_state, + pub format: output_format, + pub device: *const libc::c_char, + pub buffer: libc::c_uint, + pub period: libc::c_uint, + pub track_started: bool, + pub write_cb: Option libc::c_int>, + pub start_frames: libc::c_uint, + pub frames_played: libc::c_uint, + pub frames_played_dmp: libc::c_uint, + pub current_sample_rate: libc::c_uint, + pub supported_rates: [libc::c_uint; 18], + pub default_sample_rate: libc::c_uint, + pub error_opening: bool, + pub device_frames: libc::c_uint, + pub updated: u32_t, + pub track_start_time: u32_t, + pub current_replay_gain: u32_t, + pub c2rust_unnamed: C2RustUnnamed, + pub next_sample_rate: libc::c_uint, + pub track_start: *mut u8_t, + pub gainL: u32_t, + pub gainR: u32_t, + pub invert: bool, + pub next_replay_gain: u32_t, + pub threshold: libc::c_uint, + pub fade: fade_state, + pub fade_start: *mut u8_t, + pub fade_end: *mut u8_t, + pub fade_dir: fade_dir, + pub fade_mode: fade_mode, + pub fade_secs: libc::c_uint, + pub rate_delay: libc::c_uint, + pub delay_active: bool, + pub stop_time: u32_t, + pub idle_to: u32_t, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub union C2RustUnnamed { + pub pause_frames: u32_t, + pub skip_frames: u32_t, + pub start_at: u32_t, +} +pub type mad_fixed_t = libc::c_int; +// local buffer used by decoder: FIXME merge with any other decoders needing one? +#[derive(Copy, Clone)] +#[repr(C)] +pub struct mad { + pub readbuf: *mut u8_t, + pub readbuf_len: libc::c_uint, + pub stream: mad_stream, + pub frame: mad_frame, + pub synth: mad_synth, + pub last_error: mad_error, + pub checktags: libc::c_int, + pub consume: u32_t, + pub skip: u32_t, + pub samples: u64_t, + pub padding: u32_t, + pub mad_stream_init: Option ()>, + pub mad_frame_init: Option ()>, + pub mad_synth_init: Option ()>, + pub mad_frame_finish: Option ()>, + pub mad_stream_finish: Option ()>, + pub mad_stream_buffer: Option ()>, + pub mad_frame_decode: Option libc::c_int>, + pub mad_synth_frame: Option ()>, + pub mad_stream_errorstr: Option *const libc::c_char>, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct mad_stream { + pub buffer: *const libc::c_uchar, + pub bufend: *const libc::c_uchar, + pub skiplen: libc::c_ulong, + pub sync: libc::c_int, + pub freerate: libc::c_ulong, + pub this_frame: *const libc::c_uchar, + pub next_frame: *const libc::c_uchar, + pub ptr: mad_bitptr, + pub anc_ptr: mad_bitptr, + pub anc_bitlen: libc::c_uint, + pub main_data: *mut [libc::c_uchar; 2567], + pub md_len: libc::c_uint, + pub options: libc::c_int, + pub error: mad_error, +} +pub type mad_error = libc::c_uint; +pub const MAD_ERROR_BADSTEREO: mad_error = 569; +pub const MAD_ERROR_BADHUFFDATA: mad_error = 568; +pub const MAD_ERROR_BADHUFFTABLE: mad_error = 567; +pub const MAD_ERROR_BADPART3LEN: mad_error = 566; +pub const MAD_ERROR_BADDATAPTR: mad_error = 565; +pub const MAD_ERROR_BADSCFSI: mad_error = 564; +pub const MAD_ERROR_BADBLOCKTYPE: mad_error = 563; +pub const MAD_ERROR_BADBIGVALUES: mad_error = 562; +pub const MAD_ERROR_BADFRAMELEN: mad_error = 561; +pub const MAD_ERROR_BADMODE: mad_error = 546; +pub const MAD_ERROR_BADSCALEFACTOR: mad_error = 545; +pub const MAD_ERROR_BADBITALLOC: mad_error = 529; +pub const MAD_ERROR_BADCRC: mad_error = 513; +pub const MAD_ERROR_BADEMPHASIS: mad_error = 261; +pub const MAD_ERROR_BADSAMPLERATE: mad_error = 260; +pub const MAD_ERROR_BADBITRATE: mad_error = 259; +pub const MAD_ERROR_BADLAYER: mad_error = 258; +pub const MAD_ERROR_LOSTSYNC: mad_error = 257; +pub const MAD_ERROR_NOMEM: mad_error = 49; +pub const MAD_ERROR_BUFPTR: mad_error = 2; +pub const MAD_ERROR_BUFLEN: mad_error = 1; +pub const MAD_ERROR_NONE: mad_error = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct mad_bitptr { + pub byte: *const libc::c_uchar, + pub cache: libc::c_ushort, + pub left: libc::c_ushort, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct mad_frame { + pub header: mad_header, + pub options: libc::c_int, + pub sbsample: [[[mad_fixed_t; 32]; 36]; 2], + pub overlap: *mut [[[mad_fixed_t; 18]; 32]; 2], +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct mad_header { + pub layer: mad_layer, + pub mode: mad_mode, + pub mode_extension: libc::c_int, + pub emphasis: mad_emphasis, + pub bitrate: libc::c_ulong, + pub samplerate: libc::c_uint, + pub crc_check: libc::c_ushort, + pub crc_target: libc::c_ushort, + pub flags: libc::c_int, + pub private_bits: libc::c_int, + pub duration: mad_timer_t, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct mad_timer_t { + pub seconds: libc::c_long, + pub fraction: libc::c_ulong, +} +pub type mad_emphasis = libc::c_uint; +pub const MAD_EMPHASIS_RESERVED: mad_emphasis = 2; +pub const MAD_EMPHASIS_CCITT_J_17: mad_emphasis = 3; +pub const MAD_EMPHASIS_50_15_US: mad_emphasis = 1; +pub const MAD_EMPHASIS_NONE: mad_emphasis = 0; +pub type mad_mode = libc::c_uint; +pub const MAD_MODE_STEREO: mad_mode = 3; +pub const MAD_MODE_JOINT_STEREO: mad_mode = 2; +pub const MAD_MODE_DUAL_CHANNEL: mad_mode = 1; +pub const MAD_MODE_SINGLE_CHANNEL: mad_mode = 0; +pub type mad_layer = libc::c_uint; +pub const MAD_LAYER_III: mad_layer = 3; +pub const MAD_LAYER_II: mad_layer = 2; +pub const MAD_LAYER_I: mad_layer = 1; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct mad_synth { + pub filter: [[[[[mad_fixed_t; 8]; 16]; 2]; 2]; 2], + pub phase: libc::c_uint, + pub pcm: mad_pcm, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct mad_pcm { + pub samplerate: libc::c_uint, + pub channels: libc::c_ushort, + pub length: libc::c_ushort, + pub samples: [[mad_fixed_t; 1152]; 2], } - 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) +unsafe extern "C" fn scale(mut sample: mad_fixed_t) -> u32_t { + sample = + (sample as libc::c_long + + ((1 as libc::c_long) << 28 as libc::c_int - 24 as libc::c_int)) + as mad_fixed_t; + if sample >= 0x10000000 as libc::c_long as mad_fixed_t { + sample = 0x10000000 as libc::c_long as mad_fixed_t - 1 as libc::c_int + } else if sample < -(0x10000000 as libc::c_long as mad_fixed_t) { + sample = -(0x10000000 as libc::c_long as 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; + return ((sample >> + 28 as libc::c_int + 1 as libc::c_int - 24 as libc::c_int) << + 8 as libc::c_int) as 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 - { +unsafe extern "C" fn _check_id3_tag(mut bytes: size_t) -> libc::c_uint { + let mut ptr: *mut u8_t = (*streambuf).readp; + let mut size: u32_t = 0 as libc::c_int as 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, - ); + 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 u32_t; + if loglevel as libc::c_uint >= + lDEBUG as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d id3.2 tag len: %u\n\x00" as *const u8 as + *const libc::c_char, 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; +unsafe extern "C" fn _check_lame_header(mut bytes: size_t) { + let mut ptr: *mut u8_t = (*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: u32_t = 0 as libc::c_int as u32_t; + let mut enc_delay: u32_t = 0 as libc::c_int as u32_t; + let mut enc_padding: u32_t = 0 as libc::c_int as u32_t; + let mut flags: 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 - { + if 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 || + 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 - { + // mono + } else if 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 || + 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 - ); + frame_count = + unpackN(ptr.offset(1 as libc::c_int as isize) as *mut u32_t); ptr = ptr.offset(4 as libc::c_int as isize) } if flags as libc::c_int & 0x2 as libc::c_int != 0 { @@ -323,574 +510,510 @@ unsafe extern "C" fn _check_lame_header(mut bytes: crate::stddef_h::size_t) { 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; + if 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 - }; + 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 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 + 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).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 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, - ); + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d gapless: skip: %u samples: %lu delay: %u padding: %u\n\x00" + as *const u8 as *const libc::c_char, 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; +unsafe extern "C" fn mad_decode() -> decode_state { + let mut bytes: size_t = 0; + let mut eos: bool = 0 as libc::c_int != 0; + pthread_mutex_lock(&mut (*streambuf).mutex); + bytes = + if _buf_used(streambuf) < _buf_cont_read(streambuf) { + _buf_used(streambuf) + } else { _buf_cont_read(streambuf) } as size_t; 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, - ); + let mut consume: u32_t = + if ((*m).consume as libc::c_ulong) < bytes { + (*m).consume as libc::c_ulong + } else { bytes } as u32_t; + if loglevel as libc::c_uint >= + lDEBUG as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d consume: %u of %u\n\x00" as *const u8 as + *const libc::c_char, 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; + _buf_inc_readp(streambuf, consume); + (*m).consume = + ((*m).consume as libc::c_uint).wrapping_sub(consume) as u32_t + as u32_t; + pthread_mutex_unlock(&mut (*streambuf).mutex); + return DECODE_RUNNING } if (*m).checktags == 2 as libc::c_int { - if stream.meta_interval == 0 { - _check_lame_header(bytes); - } + 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, - ); + (*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; + 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, - ); + 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 + }; + 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 - { + ((*m).readbuf_len as libc::c_ulong).wrapping_add(bytes) as + libc::c_uint as libc::c_uint; + _buf_inc_readp(streambuf, bytes as libc::c_uint); + if stream.state as libc::c_uint <= + DISCONNECT as libc::c_int as libc::c_uint && + _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, - ); + if loglevel as libc::c_uint >= lDEBUG as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d end of stream\n\x00" as *const u8 as + *const libc::c_char, 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) + 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; + 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: size_t = 0; + let mut iptrl: *mut s32_t = 0 as *mut s32_t; + let mut iptrr: *mut s32_t = 0 as *mut 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, - ), - ); + if (*m).mad_frame_decode.expect("non-null function pointer")(&mut (*m).frame, + &mut (*m).stream) + == -(1 as libc::c_int) { + let mut ret: decode_state = DECODE_STOPPED; + if !eos && + (*m).stream.error as libc::c_uint == + MAD_ERROR_BUFLEN as libc::c_int as libc::c_uint { + ret = DECODE_RUNNING + } else if eos as libc::c_int != 0 && + ((*m).stream.error as libc::c_uint == + MAD_ERROR_BUFLEN as libc::c_int as libc::c_uint + || + (*m).stream.error as libc::c_uint == + MAD_ERROR_LOSTSYNC as libc::c_int as + libc::c_uint || + (*m).stream.error as libc::c_uint == + MAD_ERROR_BADBITRATE as libc::c_int as + libc::c_uint) { + ret = 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 >= + lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d mad_frame_decode error: %s - stopping decoder\n\x00" + as *const u8 as *const libc::c_char, + 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 + ret = DECODE_COMPLETE } else { - if (*m).stream.error as libc::c_uint != (*m).last_error as libc::c_uint { + 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, - ), - ); + if loglevel as libc::c_uint >= + lDEBUG as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d mad_frame_decode error: %s\n\x00" + as *const u8 as *const libc::c_char, + 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 + ret = DECODE_RUNNING } (*m).last_error = (*m).stream.error; - return ret; + return ret } - (*m).mad_synth_frame.expect("non-null function pointer")(&mut (*m).synth, &mut (*m).frame); + (*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, - ); + pthread_mutex_lock(&mut (*outputbuf).mutex); + if loglevel as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d setting track_start\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 11], + &[libc::c_char; 11]>(b"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.next_sample_rate = + 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); + _checkfade(1 as libc::c_int != 0); } decode.new_stream = 0 as libc::c_int != 0; - crate::stdlib::pthread_mutex_unlock(&mut (*outputbuf).mutex); + 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); + pthread_mutex_lock(&mut (*outputbuf).mutex); + max_frames = + _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, - ); + if loglevel as libc::c_uint >= + lWARN as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d too many samples - dropping samples\n\x00" + as *const u8 as *const libc::c_char, 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(); + frames = (*m).synth.pcm.length as 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, - ); + let mut skip: u32_t = + if ((*m).skip as libc::c_ulong) < frames { + (*m).skip as libc::c_ulong + } else { frames } as u32_t; + if loglevel as libc::c_uint >= + lDEBUG as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d gapless: skipping %u frames at start\n\x00" + as *const u8 as *const libc::c_char, 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; + frames = + (frames as libc::c_ulong).wrapping_sub(skip as libc::c_ulong) + as size_t as size_t; + (*m).skip = + ((*m).skip as libc::c_uint).wrapping_sub(skip) as u32_t as + 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), - ); + if loglevel as libc::c_uint >= + lDEBUG as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d gapless: trimming %u frames from end\n\x00" + as *const u8 as *const libc::c_char, + 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) - { + (*m).samples = + ((*m).samples as libc::c_ulong).wrapping_sub(frames) as u64_t + as 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, - ); + // 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 >= + lDEBUG as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d gapless: early end - trimming padding from end\n\x00" + as *const u8 as *const libc::c_char, + 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 + frames = + (frames as + libc::c_ulong).wrapping_sub((*m).padding as + libc::c_ulong) as + size_t as size_t + } else { frames = 0 as libc::c_int as size_t } + (*m).samples = 0 as libc::c_int as 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, - ); + if loglevel as libc::c_uint >= lSDEBUG as libc::c_int as libc::c_uint + { + logprint(b"%s %s:%d write %u frames\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 11], + &[libc::c_char; 11]>(b"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; + let mut f: size_t = 0; + let mut count: size_t = 0; + let mut optr: *mut s32_t = 0 as *mut s32_t; + f = + if frames < + _buf_cont_write(outputbuf).wrapping_div(8 as + libc::c_int + as + libc::c_uint) + as libc::c_ulong { + frames + } else { + _buf_cont_write(outputbuf).wrapping_div(8 as libc::c_int + as + libc::c_uint) + as libc::c_ulong + }; + optr = (*outputbuf).writep as *mut s32_t; count = f; - loop { + loop { let fresh0 = count; count = count.wrapping_sub(1); - if !(fresh0 != 0) { - break; - } + 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; + *fresh2 = scale(*fresh1) as 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 + *fresh4 = scale(*fresh3) as 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, - ); + frames = + (frames as libc::c_ulong).wrapping_sub(f) as size_t as size_t; + _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); - } + 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, -) { +unsafe extern "C" fn mad_open(mut size: u8_t, mut rate: u8_t, mut chan: u8_t, + mut endianness: 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 + malloc((2048 as libc::c_int + 8 as libc::c_int) as libc::c_ulong) + as *mut 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).consume = 0 as libc::c_int as u32_t; + (*m).skip = 529 as libc::c_int as u32_t; + (*m).samples = 0 as libc::c_int as u64_t; (*m).readbuf_len = 0 as libc::c_int as libc::c_uint; - (*m).last_error = crate::stdlib::MAD_ERROR_NONE; + (*m).last_error = 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; + free((*m).readbuf as *mut libc::c_void); + (*m).readbuf = 0 as *mut 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; + let mut handle: *mut libc::c_void = + dlopen(b"libmad.so.0\x00" as *const u8 as *const libc::c_char, + 0x2 as libc::c_int); + let mut err: *mut libc::c_char = 0 as *mut libc::c_char; if handle.is_null() { - if loglevel as libc::c_uint >= 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(), - ); + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d dlerror: %s\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 9], + &[libc::c_char; 9]>(b"load_mad\x00")).as_ptr(), + 366 as libc::c_int, dlerror()); } - return 0 as libc::c_int != 0; + return 0 as libc::c_int != 0 } - (*m).mad_stream_init = ::std::mem::transmute::< - *mut libc::c_void, - Option ()>, - >(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 ()>, - >(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 ()>, - >(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 ()>, - >(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 ()>, - >(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 *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(); + (*m).mad_stream_init = + ::std::mem::transmute::<*mut libc::c_void, + Option + ()>>(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 + ()>>(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 + ()>>(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 + ()>>(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 + ()>>(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 + ()>>(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 + libc::c_int>>(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 + ()>>(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 + *const libc::c_char>>(dlsym(handle, + b"mad_stream_errorstr\x00" + as + *const u8 + as + *const libc::c_char)); + err = 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, - ); + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d dlerror: %s\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 9], + &[libc::c_char; 9]>(b"load_mad\x00")).as_ptr(), + 381 as libc::c_int, err); } - return 0 as libc::c_int != 0; + 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, - ); + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d loaded libmad.so.0\n\x00" as *const u8 as + *const libc::c_char, 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 @@ -941,49 +1064,42 @@ unsafe extern "C" fn load_mad() -> bool { // 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::() 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; +pub unsafe extern "C" fn register_mad() -> *mut codec { + static mut ret: codec = + unsafe { + { + let mut init = + codec{id: 'm' as i32 as libc::c_char, + types: + b"mp3\x00" as *const u8 as *const libc::c_char + as *mut libc::c_char, + min_read_bytes: 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(_: u8_t, _: u8_t, + _: u8_t, _: u8_t) + -> ()), + close: + Some(mad_close as unsafe extern "C" fn() -> ()), + decode: + Some(mad_decode as + unsafe extern "C" fn() + -> decode_state),}; + init + } + }; + m = malloc(::std::mem::size_of::() as libc::c_ulong) as *mut mad; + if m.is_null() { return 0 as *mut codec } + (*m).readbuf = 0 as *mut 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, - ); + if !load_mad() { return 0 as *mut codec } + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d using mad to decode mp3\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 13], + &[libc::c_char; 13]>(b"register_mad\x00")).as_ptr(), + 414 as libc::c_int); } return &mut ret; } diff --git a/src/main.rs b/src/main.rs index 4ebfbf7..dba2b3c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,321 +1,223 @@ -#![allow( - dead_code, - mutable_transmutes, - non_camel_case_types, - non_snake_case, - non_upper_case_globals, - unused_assignments, - unused_mut -)] -#![register_tool(c2rust)] -#![feature(const_raw_ptr_to_usize_cast, extern_types, main, register_tool)] -pub mod stddef_h { - pub type size_t = libc::c_ulong; -} -pub mod squeezelite_h { - extern "C" { - #[no_mangle] - pub fn output_close_stdout(); - - #[no_mangle] - pub fn output_init_stdout( - level: crate::squeezelite_h::log_level, - output_buf_size: libc::c_uint, - params: *mut libc::c_char, - rates: *mut libc::c_uint, - rate_delay: libc::c_uint, - ); - - #[no_mangle] - pub fn output_close_alsa(); - - #[no_mangle] - pub fn output_init_alsa( - level: crate::squeezelite_h::log_level, - device: *const libc::c_char, - output_buf_size: libc::c_uint, - params: *mut libc::c_char, - rates: *mut libc::c_uint, - rate_delay: libc::c_uint, - rt_priority: libc::c_uint, - idle: libc::c_uint, - mixer_device: *mut libc::c_char, - volume_mixer: *mut libc::c_char, - mixer_unmute: bool, - mixer_linear: bool, - ); - - #[no_mangle] - pub fn list_mixers(output_device: *const libc::c_char); - - #[no_mangle] - pub fn list_devices(); - - #[no_mangle] - pub fn decode_close(); - - #[no_mangle] - pub fn decode_init( - level: crate::squeezelite_h::log_level, - include_codecs: *const libc::c_char, - exclude_codecs: *const libc::c_char, - ); - - #[no_mangle] - pub fn stream_close(); - - #[no_mangle] - pub fn stream_init(level: crate::squeezelite_h::log_level, stream_buf_size: libc::c_uint); - - #[no_mangle] - pub fn slimproto_stop(); - - #[no_mangle] - pub fn slimproto( - level: crate::squeezelite_h::log_level, - server: *mut libc::c_char, - mac: *mut crate::squeezelite_h::u8_t, - name: *const libc::c_char, - namefile: *const libc::c_char, - modelname: *const libc::c_char, - maxSampleRate: libc::c_int, - ); - - #[no_mangle] - pub fn get_mac(mac: *mut crate::squeezelite_h::u8_t); - - #[no_mangle] - pub fn next_param(src: *mut libc::c_char, c: libc::c_char) -> *mut libc::c_char; - - #[no_mangle] - pub fn logprint(fmt: *const libc::c_char, _: ...); - - #[no_mangle] - pub fn logtime() -> *const libc::c_char; - } - pub type u8_t = crate::stdlib::u_int8_t; - - pub type log_level = libc::c_uint; - - 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 mod stdlib { - extern "C" { - #[no_mangle] - pub fn __errno_location() -> *mut libc::c_int; - #[no_mangle] - pub fn signal( - __sig: libc::c_int, - __handler: crate::stdlib::__sighandler_t, - ) -> crate::stdlib::__sighandler_t; - #[no_mangle] - pub static mut stderr: *mut crate::stdlib::FILE; - - #[no_mangle] - pub fn fclose(__stream: *mut crate::stdlib::FILE) -> libc::c_int; - - #[no_mangle] - pub fn fopen(_: *const libc::c_char, _: *const libc::c_char) -> *mut crate::stdlib::FILE; - - #[no_mangle] - pub fn freopen( - __filename: *const libc::c_char, - __modes: *const libc::c_char, - __stream: *mut crate::stdlib::FILE, - ) -> *mut crate::stdlib::FILE; - - #[no_mangle] - pub fn fprintf(_: *mut crate::stdlib::FILE, _: *const libc::c_char, _: ...) -> libc::c_int; - - #[no_mangle] - pub fn printf(_: *const libc::c_char, _: ...) -> libc::c_int; - #[no_mangle] - pub fn atoi(__nptr: *const libc::c_char) -> libc::c_int; - - #[no_mangle] - pub fn strtoul( - _: *const libc::c_char, - _: *mut *mut libc::c_char, - _: libc::c_int, - ) -> libc::c_ulong; - - #[no_mangle] - pub fn free(__ptr: *mut libc::c_void); - - #[no_mangle] - pub fn exit(_: libc::c_int) -> !; - - #[no_mangle] - pub fn realpath( - __name: *const libc::c_char, - __resolved: *mut libc::c_char, - ) -> *mut libc::c_char; - #[no_mangle] - pub fn strcat(_: *mut libc::c_char, _: *const libc::c_char) -> *mut libc::c_char; - - #[no_mangle] - pub fn strcmp(_: *const libc::c_char, _: *const libc::c_char) -> libc::c_int; - - #[no_mangle] - pub fn strncmp( - _: *const libc::c_char, - _: *const libc::c_char, - _: libc::c_ulong, - ) -> libc::c_int; - - #[no_mangle] - pub fn strstr(_: *const libc::c_char, _: *const libc::c_char) -> *mut libc::c_char; - - #[no_mangle] - pub fn strtok(_: *mut libc::c_char, _: *const libc::c_char) -> *mut libc::c_char; - - #[no_mangle] - pub fn strlen(_: *const libc::c_char) -> libc::c_ulong; - - #[no_mangle] - pub fn strerror(_: libc::c_int) -> *mut libc::c_char; - pub type _IO_wide_data; - - pub type _IO_codecvt; - - pub type _IO_marker; - #[no_mangle] - pub fn getpid() -> crate::stdlib::__pid_t; - - #[no_mangle] - pub fn unlink(__name: *const libc::c_char) -> libc::c_int; - - #[no_mangle] - pub fn daemon(__nochdir: libc::c_int, __noclose: libc::c_int) -> libc::c_int; - } - pub type FILE = crate::stdlib::_IO_FILE; - pub type __sighandler_t = Option ()>; - #[repr(C)] - #[derive(Copy, Clone)] - pub struct _IO_FILE { - pub _flags: libc::c_int, - pub _IO_read_ptr: *mut libc::c_char, - pub _IO_read_end: *mut libc::c_char, - pub _IO_read_base: *mut libc::c_char, - pub _IO_write_base: *mut libc::c_char, - pub _IO_write_ptr: *mut libc::c_char, - pub _IO_write_end: *mut libc::c_char, - pub _IO_buf_base: *mut libc::c_char, - pub _IO_buf_end: *mut libc::c_char, - pub _IO_save_base: *mut libc::c_char, - pub _IO_backup_base: *mut libc::c_char, - pub _IO_save_end: *mut libc::c_char, - pub _markers: *mut crate::stdlib::_IO_marker, - pub _chain: *mut crate::stdlib::_IO_FILE, - pub _fileno: libc::c_int, - pub _flags2: libc::c_int, - pub _old_offset: crate::stdlib::__off_t, - pub _cur_column: libc::c_ushort, - pub _vtable_offset: libc::c_schar, - pub _shortbuf: [libc::c_char; 1], - pub _lock: *mut libc::c_void, - pub _offset: crate::stdlib::__off64_t, - pub _codecvt: *mut crate::stdlib::_IO_codecvt, - pub _wide_data: *mut crate::stdlib::_IO_wide_data, - pub _freeres_list: *mut crate::stdlib::_IO_FILE, - pub _freeres_buf: *mut libc::c_void, - pub __pad5: crate::stddef_h::size_t, - pub _mode: libc::c_int, - pub _unused2: [libc::c_char; 20], - } - - pub type _IO_lock_t = (); - pub type u_int8_t = crate::stdlib::__uint8_t; - pub type __uint8_t = libc::c_uchar; - - pub type __off_t = libc::c_long; - - pub type __off64_t = libc::c_long; - - pub type __pid_t = libc::c_int; -} -use ::squeezers::*; - -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::__off64_t; -pub use crate::stdlib::__off_t; -pub use crate::stdlib::__pid_t; -pub use crate::stdlib::__uint8_t; -pub use crate::stdlib::u_int8_t; -pub use crate::stdlib::FILE; -pub use crate::stdlib::_IO_FILE; - -pub use crate::squeezelite_h::decode_close; -pub use crate::squeezelite_h::decode_init; -pub use crate::squeezelite_h::get_mac; -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::list_devices; -pub use crate::squeezelite_h::list_mixers; -pub use crate::squeezelite_h::log_level; -pub use crate::squeezelite_h::logprint; -pub use crate::squeezelite_h::logtime; -pub use crate::squeezelite_h::next_param; -pub use crate::squeezelite_h::output_close_alsa; -pub use crate::squeezelite_h::output_close_stdout; -pub use crate::squeezelite_h::output_init_alsa; -pub use crate::squeezelite_h::output_init_stdout; -pub use crate::squeezelite_h::slimproto; -pub use crate::squeezelite_h::slimproto_stop; -pub use crate::squeezelite_h::stream_close; -pub use crate::squeezelite_h::stream_init; -pub use crate::squeezelite_h::u8_t; -use crate::stdlib::__errno_location; -pub use crate::stdlib::__sighandler_t; -use crate::stdlib::atoi; -use crate::stdlib::daemon; -use crate::stdlib::exit; -use crate::stdlib::fclose; -use crate::stdlib::fopen; -use crate::stdlib::fprintf; -use crate::stdlib::free; -use crate::stdlib::freopen; -use crate::stdlib::getpid; -use crate::stdlib::printf; -use crate::stdlib::realpath; -pub use crate::stdlib::signal; -use crate::stdlib::stderr; -use crate::stdlib::strcat; -use crate::stdlib::strcmp; -use crate::stdlib::strerror; -use crate::stdlib::strlen; -use crate::stdlib::strncmp; -use crate::stdlib::strstr; -use crate::stdlib::strtok; -use crate::stdlib::strtoul; -use crate::stdlib::unlink; -/* +use ::libc; +extern "C" { + pub type _IO_wide_data; + pub type _IO_codecvt; + pub type _IO_marker; + #[no_mangle] + fn getpid() -> __pid_t; + /* * Squeezelite - lightweight headless squeezebox emulator * * (c) Adrian Smith 2012-2015, triode1@btinternet.com - * Ralph Irving 2015-2020, ralph_irving@hotmail.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 . + * + * Additions (c) Paul Hermann, 2015-2017 under the same license terms + * -Control of Raspberry pi GPIO for amplifier power + * -Launch script on power status change from LMS + */ + // make may define: PORTAUDIO, SELFPIPE, RESAMPLE, RESAMPLE_MP, VISEXPORT, GPIO, IR, DSD, LINKALL to influence build + // build detection + // dynamically loaded libraries at run time + // !LINKALL + // config options + // do not reduce as icy-meta max is 4080 + /* SUN */ + /* SUN */ + // printf/scanf formats for u64_t + // logging + // utils.c (non logging) + // buffer.c + // _* called with mutex locked + // slimproto.c + // stream.c + // decode.c + // output.c output_alsa.c output_pa.c output_pack.c + // frames played at the point delay is measured + // ordered largest first so [0] is max_rate + // set in decode thread + // set in decode thread + // set by slimproto + // set by slimproto + // set by slimproto + // set by slimproto + // set by slimproto + // set by slimproto + // set by slimproto + // _* called with mutex locked + // output_alsa.c + // output_pa.c + // output_pulse.c + // output_stdout.c + #[no_mangle] + fn output_close_stdout(); + #[no_mangle] + static mut stderr: *mut FILE; + #[no_mangle] + fn fclose(__stream: *mut FILE) -> libc::c_int; + #[no_mangle] + fn fopen(_: *const libc::c_char, _: *const libc::c_char) -> *mut FILE; + #[no_mangle] + fn freopen(__filename: *const libc::c_char, __modes: *const libc::c_char, + __stream: *mut FILE) -> *mut FILE; + #[no_mangle] + fn fprintf(_: *mut FILE, _: *const libc::c_char, _: ...) -> libc::c_int; + #[no_mangle] + fn printf(_: *const libc::c_char, _: ...) -> libc::c_int; + #[no_mangle] + fn atoi(__nptr: *const libc::c_char) -> libc::c_int; + #[no_mangle] + fn strtoul(_: *const libc::c_char, _: *mut *mut libc::c_char, + _: libc::c_int) -> libc::c_ulong; + #[no_mangle] + fn free(__ptr: *mut libc::c_void); + #[no_mangle] + fn exit(_: libc::c_int) -> !; + #[no_mangle] + fn realpath(__name: *const libc::c_char, __resolved: *mut libc::c_char) + -> *mut libc::c_char; + #[no_mangle] + fn strcat(_: *mut libc::c_char, _: *const libc::c_char) + -> *mut libc::c_char; + #[no_mangle] + fn strcmp(_: *const libc::c_char, _: *const libc::c_char) -> libc::c_int; + #[no_mangle] + fn strncmp(_: *const libc::c_char, _: *const libc::c_char, + _: libc::c_ulong) -> libc::c_int; + #[no_mangle] + fn strstr(_: *const libc::c_char, _: *const libc::c_char) + -> *mut libc::c_char; + #[no_mangle] + fn strtok(_: *mut libc::c_char, _: *const libc::c_char) + -> *mut libc::c_char; + #[no_mangle] + fn strlen(_: *const libc::c_char) -> libc::c_ulong; + #[no_mangle] + fn strerror(_: libc::c_int) -> *mut libc::c_char; + #[no_mangle] + fn __errno_location() -> *mut libc::c_int; + #[no_mangle] + fn unlink(__name: *const libc::c_char) -> libc::c_int; + #[no_mangle] + fn daemon(__nochdir: libc::c_int, __noclose: libc::c_int) -> libc::c_int; + #[no_mangle] + fn signal(__sig: libc::c_int, __handler: __sighandler_t) + -> __sighandler_t; + #[no_mangle] + fn logtime() -> *const libc::c_char; + #[no_mangle] + fn logprint(fmt: *const libc::c_char, _: ...); + #[no_mangle] + fn next_param(src: *mut libc::c_char, c: libc::c_char) + -> *mut libc::c_char; + #[no_mangle] + fn get_mac(mac: *mut u8_t); + #[no_mangle] + fn slimproto(level: log_level, server: *mut libc::c_char, mac: *mut u8_t, + name: *const libc::c_char, namefile: *const libc::c_char, + modelname: *const libc::c_char, maxSampleRate: libc::c_int); + #[no_mangle] + fn slimproto_stop(); + #[no_mangle] + fn stream_init(level: log_level, stream_buf_size: libc::c_uint); + #[no_mangle] + fn stream_close(); + #[no_mangle] + fn decode_init(level: log_level, include_codecs: *const libc::c_char, + exclude_codecs: *const libc::c_char); + #[no_mangle] + fn decode_close(); + #[no_mangle] + fn list_devices(); + #[no_mangle] + fn list_mixers(output_device: *const libc::c_char); + #[no_mangle] + fn output_init_alsa(level: log_level, device: *const libc::c_char, + output_buf_size: libc::c_uint, + params: *mut libc::c_char, rates: *mut libc::c_uint, + rate_delay: libc::c_uint, rt_priority: libc::c_uint, + idle: libc::c_uint, mixer_device: *mut libc::c_char, + volume_mixer: *mut libc::c_char, mixer_unmute: bool, + mixer_linear: bool); + #[no_mangle] + fn output_close_alsa(); + #[no_mangle] + fn output_init_stdout(level: log_level, output_buf_size: libc::c_uint, + params: *mut libc::c_char, rates: *mut libc::c_uint, + rate_delay: libc::c_uint); +} +pub type size_t = libc::c_ulong; +pub type __uint8_t = libc::c_uchar; +pub type __off_t = libc::c_long; +pub type __off64_t = libc::c_long; +pub type __pid_t = libc::c_int; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct _IO_FILE { + pub _flags: libc::c_int, + pub _IO_read_ptr: *mut libc::c_char, + pub _IO_read_end: *mut libc::c_char, + pub _IO_read_base: *mut libc::c_char, + pub _IO_write_base: *mut libc::c_char, + pub _IO_write_ptr: *mut libc::c_char, + pub _IO_write_end: *mut libc::c_char, + pub _IO_buf_base: *mut libc::c_char, + pub _IO_buf_end: *mut libc::c_char, + pub _IO_save_base: *mut libc::c_char, + pub _IO_backup_base: *mut libc::c_char, + pub _IO_save_end: *mut libc::c_char, + pub _markers: *mut _IO_marker, + pub _chain: *mut _IO_FILE, + pub _fileno: libc::c_int, + pub _flags2: libc::c_int, + pub _old_offset: __off_t, + pub _cur_column: libc::c_ushort, + pub _vtable_offset: libc::c_schar, + pub _shortbuf: [libc::c_char; 1], + pub _lock: *mut libc::c_void, + pub _offset: __off64_t, + pub _codecvt: *mut _IO_codecvt, + pub _wide_data: *mut _IO_wide_data, + pub _freeres_list: *mut _IO_FILE, + pub _freeres_buf: *mut libc::c_void, + pub __pad5: size_t, + pub _mode: libc::c_int, + pub _unused2: [libc::c_char; 20], +} +pub type _IO_lock_t = (); +pub type FILE = _IO_FILE; +pub type u_int8_t = __uint8_t; +pub type __sighandler_t = Option ()>; +pub type u8_t = u_int8_t; +pub type log_level = libc::c_uint; +pub const lSDEBUG: log_level = 4; +pub const lDEBUG: log_level = 3; +pub const lINFO: log_level = 2; +pub const lWARN: log_level = 1; +pub const lERROR: log_level = 0; +/* + * Squeezelite - lightweight headless squeezebox emulator + * + * (c) Adrian Smith 2012-2015, triode1@btinternet.com + * Ralph Irving 2015-2020, ralph_irving@hotmail.com + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the @@ -328,130 +230,110 @@ use crate::stdlib::unlink; * -Control of Raspberry pi GPIO for amplifier power * -Launch script on power status change from LMS */ - unsafe extern "C" fn usage(mut argv0: *const libc::c_char) { - crate::stdlib::printf(b"Squeezelite v1.9.7-1218, Copyright 2012-2015 Adrian Smith, 2015-2020 Ralph Irving. See -t for license terms\nUsage: %s [options]\n -s [:]\tConnect to specified server, otherwise uses autodiscovery to find server\n -o \tSpecify output device, default \"default\", - = output to stdout\n -l \t\t\tList output devices\n -a :::\tSpecify ALSA params to open output device, b = buffer time in ms or size in bytes, p = period count or size in bytes, f sample format (16|24|24_3|32), m = use mmap (0|1)\n -a \t\tSpecify sample format (16|24|32) of output file when using -o - to output samples to stdout (interleaved little endian only)\n -b :\tSpecify internal Stream and Output buffer sizes in Kbytes\n -c ,\tRestrict codecs to those specified, otherwise load all available codecs; known codecs: flac,pcm,mp3,ogg,aac (mad,mpg for specific mp3 codec)\n \t\t\tCodecs reported to LMS in order listed, allowing codec priority refinement.\n -C \t\tClose output device when idle after timeout seconds, default is to keep it open while player is \'on\'\n -d =\tSet logging level, logs: all|slimproto|stream|decode|output, level: info|debug|sdebug\n -e ,\tExplicitly exclude native support of one or more codecs; known codecs: flac,pcm,mp3,ogg,aac (mad,mpg for specific mp3 codec)\n -f \t\tWrite debug to logfile\n -m \t\tSet mac address, format: ab:cd:ef:12:34:56\n -M \tSet the squeezelite player model name sent to the server (default: SqueezeLite)\n -n \t\tSet the player name\n -N \t\tStore player name in filename to allow server defined name changes to be shared between servers (not supported with -n)\n -W\t\t\tRead wave and aiff format from header, ignore server parameters\n -p \t\tSet real time priority of output thread (1-99)\n -P \t\tStore the process id (PID) in filename\n -r [:]\tSample rates supported, allows output to be off when squeezelite is started; rates = |-|,,; delay = optional delay switching rates in ms\n -O \tSpecify mixer device, defaults to \'output device\'\n -L \t\t\tList volume controls for output device\n -U \t\tUnmute ALSA control and set to full volume (not supported with -V)\n -V \t\tUse ALSA control for volume adjustment, otherwise use software volume adjustment\n -X \t\t\tUse linear volume adjustments instead of in terms of dB (only for hardware volume control)\n -z \t\t\tDaemonize\n -t \t\t\tLicense terms\n -? \t\t\tDisplay this help text\n\nBuild options: LINUX ALSA EVENTFD\n\n\x00" + printf(b"Squeezelite v1.9.7-1223, Copyright 2012-2015 Adrian Smith, 2015-2020 Ralph Irving. See -t for license terms\nUsage: %s [options]\n -s [:]\tConnect to specified server, otherwise uses autodiscovery to find server\n -o \tSpecify output device, default \"default\", - = output to stdout\n -l \t\t\tList output devices\n -a :::\tSpecify ALSA params to open output device, b = buffer time in ms or size in bytes, p = period count or size in bytes, f sample format (16|24|24_3|32), m = use mmap (0|1)\n -a \t\tSpecify sample format (16|24|32) of output file when using -o - to output samples to stdout (interleaved little endian only)\n -b :\tSpecify internal Stream and Output buffer sizes in Kbytes\n -c ,\tRestrict codecs to those specified, otherwise load all available codecs; known codecs: flac,pcm,mp3,ogg,aac (mad,mpg for specific mp3 codec)\n \t\t\tCodecs reported to LMS in order listed, allowing codec priority refinement.\n -C \t\tClose output device when idle after timeout seconds, default is to keep it open while player is \'on\'\n -d =\tSet logging level, logs: all|slimproto|stream|decode|output, level: info|debug|sdebug\n -e ,\tExplicitly exclude native support of one or more codecs; known codecs: flac,pcm,mp3,ogg,aac (mad,mpg for specific mp3 codec)\n -f \t\tWrite debug to logfile\n -m \t\tSet mac address, format: ab:cd:ef:12:34:56\n -M \tSet the squeezelite player model name sent to the server (default: SqueezeLite)\n -n \t\tSet the player name\n -N \t\tStore player name in filename to allow server defined name changes to be shared between servers (not supported with -n)\n -W\t\t\tRead wave and aiff format from header, ignore server parameters\n -p \t\tSet real time priority of output thread (1-99)\n -P \t\tStore the process id (PID) in filename\n -r [:]\tSample rates supported, allows output to be off when squeezelite is started; rates = |-|,,; delay = optional delay switching rates in ms\n -O \tSpecify mixer device, defaults to \'output device\'\n -L \t\t\tList volume controls for output device\n -U \t\tUnmute ALSA control and set to full volume (not supported with -V)\n -V \t\tUse ALSA control for volume adjustment, otherwise use software volume adjustment\n -X \t\t\tUse linear volume adjustments instead of in terms of dB (only for hardware volume control)\n -z \t\t\tDaemonize\n -t \t\t\tLicense terms\n -? \t\t\tDisplay this help text\n\nBuild options: LINUX ALSA EVENTFD\n\n\x00" as *const u8 as *const libc::c_char, argv0); } - unsafe extern "C" fn license() { - crate::stdlib::printf(b"Squeezelite v1.9.7-1218, Copyright 2012-2015 Adrian Smith, 2015-2020 Ralph Irving.\n\nThis program is free software: you can redistribute it and/or modify\nit under the terms of the GNU General Public License as published by\nthe Free Software Foundation, either version 3 of the License, or\n(at your option) any later version.\n\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with this program. If not, see .\n\nOption to allow server side upsampling for PCM streams (-W) from\nsqueezelite-R2 (c) Marco Curti 2015, marcoc1712@gmail.com.\n\n\x00" + printf(b"Squeezelite v1.9.7-1223, Copyright 2012-2015 Adrian Smith, 2015-2020 Ralph Irving.\n\nThis program is free software: you can redistribute it and/or modify\nit under the terms of the GNU General Public License as published by\nthe Free Software Foundation, either version 3 of the License, or\n(at your option) any later version.\n\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with this program. If not, see .\n\nOption to allow server side upsampling for PCM streams (-W) from\nsqueezelite-R2 (c) Marco Curti 2015, marcoc1712@gmail.com.\n\n\x00" as *const u8 as *const libc::c_char); } - unsafe extern "C" fn sighandler(mut signum: libc::c_int) { - crate::squeezelite_h::slimproto_stop(); + slimproto_stop(); // remove ourselves in case above does not work, second SIGINT will cause non gracefull shutdown - crate::stdlib::signal(signum, None); // set later + signal(signum, None); // set later } - -unsafe fn main_0(mut argc: libc::c_int, mut argv: *mut *mut libc::c_char) -> libc::c_int { - let mut server = 0 as *mut libc::c_char; - let mut output_device = b"default\x00" as *const u8 as *const libc::c_char as *mut libc::c_char; - let mut include_codecs = 0 as *mut libc::c_char; - let mut exclude_codecs = b"\x00" as *const u8 as *const libc::c_char as *mut libc::c_char; - let mut name = 0 as *mut libc::c_char; - let mut namefile = 0 as *mut libc::c_char; - let mut modelname = 0 as *mut libc::c_char; +#[cross_check(entry(djb2="main"), exit(djb2="main"))] +unsafe fn main_0(mut argc: libc::c_int, mut argv: *mut *mut libc::c_char) + -> libc::c_int { + let mut server: *mut libc::c_char = 0 as *mut libc::c_char; + let mut output_device: *mut libc::c_char = + b"default\x00" as *const u8 as *const libc::c_char as + *mut libc::c_char; + let mut include_codecs: *mut libc::c_char = 0 as *mut libc::c_char; + let mut exclude_codecs: *mut libc::c_char = + b"\x00" as *const u8 as *const libc::c_char as *mut libc::c_char; + let mut name: *mut libc::c_char = 0 as *mut libc::c_char; + let mut namefile: *mut libc::c_char = 0 as *mut libc::c_char; + let mut modelname: *mut libc::c_char = 0 as *mut libc::c_char; extern "C" { #[no_mangle] - pub static mut pcm_check_header: bool; + static mut pcm_check_header: bool; } extern "C" { #[no_mangle] - pub static mut user_rates: bool; + static mut user_rates: bool; } - let mut logfile = 0 as *mut libc::c_char; - let mut mac: [crate::squeezelite_h::u8_t; 6] = [0; 6]; - let mut stream_buf_size = - (2 as libc::c_int * 1024 as libc::c_int * 1024 as libc::c_int) as libc::c_uint; - let mut output_buf_size = 0 as libc::c_int as libc::c_uint; - let mut rates: [libc::c_uint; 18] = [ - 0 as libc::c_int as libc::c_uint, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - ]; - let mut rate_delay = 0 as libc::c_int as libc::c_uint; - let mut resample = 0 as *mut libc::c_char; - let mut output_params = 0 as *mut libc::c_char; - let mut idle = 0 as libc::c_int as libc::c_uint; - let mut daemonize = 0 as libc::c_int != 0; - let mut pidfile = 0 as *mut libc::c_char; - let mut pidfp = 0 as *mut crate::stdlib::FILE; - let mut rt_priority = 45 as libc::c_int as libc::c_uint; - let mut mixer_device = output_device; - let mut output_mixer = 0 as *mut libc::c_char; - let mut output_mixer_unmute = 0 as libc::c_int != 0; - let mut linear_volume = 0 as libc::c_int != 0; - let mut log_output = crate::squeezelite_h::lWARN; - let mut log_stream = crate::squeezelite_h::lWARN; - let mut log_decode = crate::squeezelite_h::lWARN; - let mut log_slimproto = crate::squeezelite_h::lWARN; - let mut maxSampleRate = 0 as libc::c_int; - let mut optarg = 0 as *mut libc::c_char; - let mut optind = 1 as libc::c_int; + let mut logfile: *mut libc::c_char = 0 as *mut libc::c_char; + let mut mac: [u8_t; 6] = [0; 6]; + let mut stream_buf_size: libc::c_uint = + (2 as libc::c_int * 1024 as libc::c_int * 1024 as libc::c_int) as + libc::c_uint; + let mut output_buf_size: libc::c_uint = 0 as libc::c_int as libc::c_uint; + let mut rates: [libc::c_uint; 18] = + [0 as libc::c_int as libc::c_uint, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0]; + let mut rate_delay: libc::c_uint = 0 as libc::c_int as libc::c_uint; + let mut resample: *mut libc::c_char = 0 as *mut libc::c_char; + let mut output_params: *mut libc::c_char = 0 as *mut libc::c_char; + let mut idle: libc::c_uint = 0 as libc::c_int as libc::c_uint; + let mut daemonize: bool = 0 as libc::c_int != 0; + let mut pidfile: *mut libc::c_char = 0 as *mut libc::c_char; + let mut pidfp: *mut FILE = 0 as *mut FILE; + let mut rt_priority: libc::c_uint = 45 as libc::c_int as libc::c_uint; + let mut mixer_device: *mut libc::c_char = output_device; + let mut output_mixer: *mut libc::c_char = 0 as *mut libc::c_char; + let mut output_mixer_unmute: bool = 0 as libc::c_int != 0; + let mut linear_volume: bool = 0 as libc::c_int != 0; + let mut log_output: log_level = lWARN; + let mut log_stream: log_level = lWARN; + let mut log_decode: log_level = lWARN; + let mut log_slimproto: log_level = lWARN; + let mut maxSampleRate: libc::c_int = 0 as libc::c_int; + let mut optarg: *mut libc::c_char = 0 as *mut libc::c_char; + let mut optind: libc::c_int = 1 as libc::c_int; let mut i: libc::c_int = 0; let mut cmdline: [libc::c_char; 512] = *::std::mem::transmute::<&[u8; 512], &mut [libc::c_char; 512]>(b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"); - crate::squeezelite_h::get_mac(mac.as_mut_ptr()); + get_mac(mac.as_mut_ptr()); i = 0 as libc::c_int; - while i < argc - && crate::stdlib::strlen(*argv.offset(i as isize)) - .wrapping_add(crate::stdlib::strlen(cmdline.as_mut_ptr())) - .wrapping_add(2 as libc::c_int as libc::c_ulong) - < 512 as libc::c_int as libc::c_ulong - { - crate::stdlib::strcat(cmdline.as_mut_ptr(), *argv.offset(i as isize)); - crate::stdlib::strcat( - cmdline.as_mut_ptr(), - b" \x00" as *const u8 as *const libc::c_char, - ); + while i < argc && + strlen(*argv.offset(i as + isize)).wrapping_add(strlen(cmdline.as_mut_ptr())).wrapping_add(2 + as + libc::c_int + as + libc::c_ulong) + < 512 as libc::c_int as libc::c_ulong { + strcat(cmdline.as_mut_ptr(), *argv.offset(i as isize)); + strcat(cmdline.as_mut_ptr(), + b" \x00" as *const u8 as *const libc::c_char); i += 1 } - while optind < argc - && crate::stdlib::strlen(*argv.offset(optind as isize)) >= 2 as libc::c_int as libc::c_ulong - && *(*argv.offset(optind as isize)).offset(0 as libc::c_int as isize) as libc::c_int - == '-' as i32 - { - let mut opt = (*argv.offset(optind as isize)).offset(1 as libc::c_int as isize); - if !crate::stdlib::strstr( - b"oabcCdefmMnNpPrsUVO\x00" as *const u8 as *const libc::c_char, - opt, - ) - .is_null() - && optind < argc - 1 as libc::c_int - { + while optind < argc && + strlen(*argv.offset(optind as isize)) >= + 2 as libc::c_int as libc::c_ulong && + *(*argv.offset(optind as + isize)).offset(0 as libc::c_int as isize) as + libc::c_int == '-' as i32 { + let mut opt: *mut libc::c_char = + (*argv.offset(optind as isize)).offset(1 as libc::c_int as isize); + if !strstr(b"oabcCdefmMnNpPrsUVO\x00" as *const u8 as + *const libc::c_char, opt).is_null() && + optind < argc - 1 as libc::c_int { optarg = *argv.offset((optind + 1 as libc::c_int) as isize); optind += 2 as libc::c_int - } else if !crate::stdlib::strstr(b"ltz?WLX\x00" as *const u8 as *const libc::c_char, opt) - .is_null() - { + } else if !strstr(b"ltz?WLX\x00" as *const u8 as *const libc::c_char, + opt).is_null() { optarg = 0 as *mut libc::c_char; optind += 1 as libc::c_int } else { - crate::stdlib::fprintf( - crate::stdlib::stderr, - b"\nOption error: -%s\n\n\x00" as *const u8 as *const libc::c_char, - opt, - ); + fprintf(stderr, + b"\nOption error: -%s\n\n\x00" as *const u8 as + *const libc::c_char, opt); usage(*argv.offset(0 as libc::c_int as isize)); - crate::stdlib::exit(1 as libc::c_int); + exit(1 as libc::c_int); } let mut current_block_129: u64; match *opt.offset(0 as libc::c_int as isize) as libc::c_int { @@ -465,16 +347,18 @@ unsafe fn main_0(mut argc: libc::c_int, mut argv: *mut *mut libc::c_char) -> lib current_block_129 = 10517665100358322178; } 98 => { - let mut s = crate::squeezelite_h::next_param(optarg, ':' as i32 as libc::c_char); - let mut o = crate::squeezelite_h::next_param( - 0 as *mut libc::c_char, - ':' as i32 as libc::c_char, - ); + let mut s: *mut libc::c_char = + next_param(optarg, ':' as i32 as libc::c_char); + let mut o: *mut libc::c_char = + next_param(0 as *mut libc::c_char, + ':' as i32 as libc::c_char); if !s.is_null() { - stream_buf_size = (crate::stdlib::atoi(s) * 1024 as libc::c_int) as libc::c_uint + stream_buf_size = + (atoi(s) * 1024 as libc::c_int) as libc::c_uint } if !o.is_null() { - output_buf_size = (crate::stdlib::atoi(o) * 1024 as libc::c_int) as libc::c_uint + output_buf_size = + (atoi(o) * 1024 as libc::c_int) as libc::c_uint } current_block_129 = 10517665100358322178; } @@ -483,8 +367,9 @@ unsafe fn main_0(mut argc: libc::c_int, mut argv: *mut *mut libc::c_char) -> lib current_block_129 = 10517665100358322178; } 67 => { - if crate::stdlib::atoi(optarg) > 0 as libc::c_int { - idle = (crate::stdlib::atoi(optarg) * 1000 as libc::c_int) as libc::c_uint + if atoi(optarg) > 0 as libc::c_int { + idle = + (atoi(optarg) * 1000 as libc::c_int) as libc::c_uint } current_block_129 = 10517665100358322178; } @@ -493,70 +378,67 @@ unsafe fn main_0(mut argc: libc::c_int, mut argv: *mut *mut libc::c_char) -> lib current_block_129 = 10517665100358322178; } 100 => { - let mut l = - crate::stdlib::strtok(optarg, b"=\x00" as *const u8 as *const libc::c_char); - let mut v = crate::stdlib::strtok( - 0 as *mut libc::c_char, - b"=\x00" as *const u8 as *const libc::c_char, - ); - let mut new = crate::squeezelite_h::lWARN; + let mut l: *mut libc::c_char = + strtok(optarg, + b"=\x00" as *const u8 as *const libc::c_char); + let mut v: *mut libc::c_char = + strtok(0 as *mut libc::c_char, + b"=\x00" as *const u8 as *const libc::c_char); + let mut new: log_level = lWARN; if !l.is_null() && !v.is_null() { - if crate::stdlib::strcmp(v, b"info\x00" as *const u8 as *const libc::c_char) - == 0 - { - new = crate::squeezelite_h::lINFO + if strcmp(v, + b"info\x00" as *const u8 as *const libc::c_char) + == 0 { + new = lINFO } - if crate::stdlib::strcmp(v, b"debug\x00" as *const u8 as *const libc::c_char) - == 0 - { - new = crate::squeezelite_h::lDEBUG + if strcmp(v, + b"debug\x00" as *const u8 as + *const libc::c_char) == 0 { + new = lDEBUG } - if crate::stdlib::strcmp(v, b"sdebug\x00" as *const u8 as *const libc::c_char) - == 0 - { - new = crate::squeezelite_h::lSDEBUG + if strcmp(v, + b"sdebug\x00" as *const u8 as + *const libc::c_char) == 0 { + new = lSDEBUG } - if crate::stdlib::strcmp(l, b"all\x00" as *const u8 as *const libc::c_char) == 0 - || crate::stdlib::strcmp( - l, - b"slimproto\x00" as *const u8 as *const libc::c_char, - ) == 0 - { + if strcmp(l, + b"all\x00" as *const u8 as *const libc::c_char) + == 0 || + strcmp(l, + b"slimproto\x00" as *const u8 as + *const libc::c_char) == 0 { log_slimproto = new } - if crate::stdlib::strcmp(l, b"all\x00" as *const u8 as *const libc::c_char) == 0 - || crate::stdlib::strcmp( - l, - b"stream\x00" as *const u8 as *const libc::c_char, - ) == 0 - { + if strcmp(l, + b"all\x00" as *const u8 as *const libc::c_char) + == 0 || + strcmp(l, + b"stream\x00" as *const u8 as + *const libc::c_char) == 0 { log_stream = new } - if crate::stdlib::strcmp(l, b"all\x00" as *const u8 as *const libc::c_char) == 0 - || crate::stdlib::strcmp( - l, - b"decode\x00" as *const u8 as *const libc::c_char, - ) == 0 - { + if strcmp(l, + b"all\x00" as *const u8 as *const libc::c_char) + == 0 || + strcmp(l, + b"decode\x00" as *const u8 as + *const libc::c_char) == 0 { log_decode = new } - if crate::stdlib::strcmp(l, b"all\x00" as *const u8 as *const libc::c_char) == 0 - || crate::stdlib::strcmp( - l, - b"output\x00" as *const u8 as *const libc::c_char, - ) == 0 - { + if strcmp(l, + b"all\x00" as *const u8 as *const libc::c_char) + == 0 || + strcmp(l, + b"output\x00" as *const u8 as + *const libc::c_char) == 0 { log_output = new } } else { - crate::stdlib::fprintf( - crate::stdlib::stderr, - b"\nDebug settings error: -d %s\n\n\x00" as *const u8 - as *const libc::c_char, - optarg, - ); + fprintf(stderr, + b"\nDebug settings error: -d %s\n\n\x00" as + *const u8 as *const libc::c_char, optarg); usage(*argv.offset(0 as libc::c_int as isize)); - crate::stdlib::exit(1 as libc::c_int); + exit(1 as libc::c_int); } current_block_129 = 10517665100358322178; } @@ -565,33 +447,31 @@ unsafe fn main_0(mut argc: libc::c_int, mut argv: *mut *mut libc::c_char) -> lib current_block_129 = 10517665100358322178; } 109 => { - let mut byte = 0 as libc::c_int; - let mut tmp = 0 as *mut libc::c_char; - if crate::stdlib::strncmp( - optarg, - b"00:04:20\x00" as *const u8 as *const libc::c_char, - 8 as libc::c_int as libc::c_ulong, - ) == 0 - { - crate::squeezelite_h::logprint(b"%s %s:%d ignoring mac address from hardware player range 00:04:20:**:**:**\n\x00" + let mut byte: libc::c_int = 0 as libc::c_int; + let mut tmp: *mut libc::c_char = 0 as *mut libc::c_char; + if strncmp(optarg, + b"00:04:20\x00" as *const u8 as + *const libc::c_char, + 8 as libc::c_int as libc::c_ulong) == 0 { + logprint(b"%s %s:%d ignoring mac address from hardware player range 00:04:20:**:**:**\n\x00" as *const u8 as *const libc::c_char, - crate::squeezelite_h::logtime(), + logtime(), (*::std::mem::transmute::<&[u8; 5], &[libc::c_char; 5]>(b"main\x00")).as_ptr(), 453 as libc::c_int); } else { - let mut t = - crate::stdlib::strtok(optarg, b":\x00" as *const u8 as *const libc::c_char); + let mut t: *mut libc::c_char = + strtok(optarg, + b":\x00" as *const u8 as *const libc::c_char); while !t.is_null() && byte < 6 as libc::c_int { let fresh0 = byte; byte = byte + 1; mac[fresh0 as usize] = - crate::stdlib::strtoul(t, &mut tmp, 16 as libc::c_int) - as crate::squeezelite_h::u8_t; - t = crate::stdlib::strtok( - 0 as *mut libc::c_char, - b":\x00" as *const u8 as *const libc::c_char, - ) + strtoul(t, &mut tmp, 16 as libc::c_int) as u8_t; + t = + strtok(0 as *mut libc::c_char, + b":\x00" as *const u8 as + *const libc::c_char) } } current_block_129 = 10517665100358322178; @@ -601,57 +481,39 @@ unsafe fn main_0(mut argc: libc::c_int, mut argv: *mut *mut libc::c_char) -> lib current_block_129 = 10517665100358322178; } 114 => { - let mut rstr = crate::squeezelite_h::next_param(optarg, ':' as i32 as libc::c_char); - let mut dstr = crate::squeezelite_h::next_param( - 0 as *mut libc::c_char, - ':' as i32 as libc::c_char, - ); - if !rstr.is_null() - && !crate::stdlib::strstr(rstr, b",\x00" as *const u8 as *const libc::c_char) - .is_null() - { + let mut rstr: *mut libc::c_char = + next_param(optarg, ':' as i32 as libc::c_char); + let mut dstr: *mut libc::c_char = + next_param(0 as *mut libc::c_char, + ':' as i32 as libc::c_char); + if !rstr.is_null() && + !strstr(rstr, + b",\x00" as *const u8 as + *const libc::c_char).is_null() { // parse sample rates and sort them - let mut r = crate::squeezelite_h::next_param(rstr, ',' as i32 as libc::c_char); - let mut tmp_0: [libc::c_uint; 18] = [ - 0 as libc::c_int as libc::c_uint, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - ]; + let mut r: *mut libc::c_char = + next_param(rstr, ',' as i32 as libc::c_char); + let mut tmp_0: [libc::c_uint; 18] = + [0 as libc::c_int as libc::c_uint, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; let mut i_0: libc::c_int = 0; let mut j: libc::c_int = 0; - let mut last = 999999 as libc::c_int; + let mut last: libc::c_int = 999999 as libc::c_int; i_0 = 0 as libc::c_int; while !r.is_null() && i_0 < 18 as libc::c_int { - tmp_0[i_0 as usize] = crate::stdlib::atoi(r) as libc::c_uint; - r = crate::squeezelite_h::next_param( - 0 as *mut libc::c_char, - ',' as i32 as libc::c_char, - ); + tmp_0[i_0 as usize] = atoi(r) as libc::c_uint; + r = + next_param(0 as *mut libc::c_char, + ',' as i32 as libc::c_char); i_0 += 1 } i_0 = 0 as libc::c_int; while i_0 < 18 as libc::c_int { - let mut largest = 0 as libc::c_int; + let mut largest: libc::c_int = 0 as libc::c_int; j = 0 as libc::c_int; while j < 18 as libc::c_int { - if tmp_0[j as usize] > largest as libc::c_uint - && tmp_0[j as usize] < last as libc::c_uint - { + if tmp_0[j as usize] > largest as libc::c_uint && + tmp_0[j as usize] < last as libc::c_uint { largest = tmp_0[j as usize] as libc::c_int } j += 1 @@ -662,59 +524,51 @@ unsafe fn main_0(mut argc: libc::c_int, mut argv: *mut *mut libc::c_char) -> lib } } else if !rstr.is_null() { // optstr is - or , extract rates from test rates within this range - let mut ref_0: [libc::c_uint; 18] = [ - 768000 as libc::c_int as libc::c_uint, - 705600 as libc::c_int as libc::c_uint, - 384000 as libc::c_int as libc::c_uint, - 352800 as libc::c_int as libc::c_uint, - 192000 as libc::c_int as libc::c_uint, - 176400 as libc::c_int as libc::c_uint, - 96000 as libc::c_int as libc::c_uint, - 88200 as libc::c_int as libc::c_uint, - 48000 as libc::c_int as libc::c_uint, - 44100 as libc::c_int as libc::c_uint, - 32000 as libc::c_int as libc::c_uint, - 24000 as libc::c_int as libc::c_uint, - 22500 as libc::c_int as libc::c_uint, - 16000 as libc::c_int as libc::c_uint, - 12000 as libc::c_int as libc::c_uint, - 11025 as libc::c_int as libc::c_uint, - 8000 as libc::c_int as libc::c_uint, - 0 as libc::c_int as libc::c_uint, - ]; - let mut str1 = - crate::squeezelite_h::next_param(rstr, '-' as i32 as libc::c_char); - let mut str2 = crate::squeezelite_h::next_param( - 0 as *mut libc::c_char, - '-' as i32 as libc::c_char, - ); - let mut max = if !str2.is_null() { - crate::stdlib::atoi(str2) as libc::c_uint - } else if !str1.is_null() { - crate::stdlib::atoi(str1) as libc::c_uint - } else { - ref_0[0 as libc::c_int as usize] - }; - let mut min = if !str1.is_null() && !str2.is_null() { - crate::stdlib::atoi(str1) - } else { - 0 as libc::c_int - } as libc::c_uint; + let mut ref_0: [libc::c_uint; 18] = + [768000 as libc::c_int as libc::c_uint, + 705600 as libc::c_int as libc::c_uint, + 384000 as libc::c_int as libc::c_uint, + 352800 as libc::c_int as libc::c_uint, + 192000 as libc::c_int as libc::c_uint, + 176400 as libc::c_int as libc::c_uint, + 96000 as libc::c_int as libc::c_uint, + 88200 as libc::c_int as libc::c_uint, + 48000 as libc::c_int as libc::c_uint, + 44100 as libc::c_int as libc::c_uint, + 32000 as libc::c_int as libc::c_uint, + 24000 as libc::c_int as libc::c_uint, + 22500 as libc::c_int as libc::c_uint, + 16000 as libc::c_int as libc::c_uint, + 12000 as libc::c_int as libc::c_uint, + 11025 as libc::c_int as libc::c_uint, + 8000 as libc::c_int as libc::c_uint, + 0 as libc::c_int as libc::c_uint]; + let mut str1: *mut libc::c_char = + next_param(rstr, '-' as i32 as libc::c_char); + let mut str2: *mut libc::c_char = + next_param(0 as *mut libc::c_char, + '-' as i32 as libc::c_char); + let mut max: libc::c_uint = + if !str2.is_null() { + atoi(str2) as libc::c_uint + } else if !str1.is_null() { + atoi(str1) as libc::c_uint + } else { ref_0[0 as libc::c_int as usize] }; + let mut min: libc::c_uint = + if !str1.is_null() && !str2.is_null() { + atoi(str1) + } else { 0 as libc::c_int } as libc::c_uint; let mut tmp_1: libc::c_uint = 0; let mut i_1: libc::c_int = 0; let mut j_0: libc::c_int = 0; - if max < min { - tmp_1 = max; - max = min; - min = tmp_1 - } + if max < min { tmp_1 = max; max = min; min = tmp_1 } rates[0 as libc::c_int as usize] = max; i_1 = 0 as libc::c_int; j_0 = 1 as libc::c_int; while i_1 < 18 as libc::c_int { - if ref_0[i_1 as usize] < rates[(j_0 - 1 as libc::c_int) as usize] - && ref_0[i_1 as usize] >= min - { + if ref_0[i_1 as usize] < + rates[(j_0 - 1 as libc::c_int) as usize] && + ref_0[i_1 as usize] >= min { let fresh1 = j_0; j_0 = j_0 + 1; rates[fresh1 as usize] = ref_0[i_1 as usize] @@ -722,9 +576,7 @@ unsafe fn main_0(mut argc: libc::c_int, mut argv: *mut *mut libc::c_char) -> lib i_1 += 1 } } - if !dstr.is_null() { - rate_delay = crate::stdlib::atoi(dstr) as libc::c_uint - } + if !dstr.is_null() { rate_delay = atoi(dstr) as libc::c_uint } if rates[0 as libc::c_int as usize] != 0 { user_rates = 1 as libc::c_int != 0 } @@ -747,18 +599,14 @@ unsafe fn main_0(mut argc: libc::c_int, mut argv: *mut *mut libc::c_char) -> lib current_block_129 = 10517665100358322178; } 112 => { - rt_priority = crate::stdlib::atoi(optarg) as libc::c_uint; - if rt_priority > 99 as libc::c_int as libc::c_uint - || rt_priority < 1 as libc::c_int as libc::c_uint - { - crate::stdlib::fprintf( - crate::stdlib::stderr, - b"\nError: invalid priority: %s\n\n\x00" as *const u8 - as *const libc::c_char, - optarg, - ); + rt_priority = atoi(optarg) as libc::c_uint; + if rt_priority > 99 as libc::c_int as libc::c_uint || + rt_priority < 1 as libc::c_int as libc::c_uint { + fprintf(stderr, + b"\nError: invalid priority: %s\n\n\x00" as + *const u8 as *const libc::c_char, optarg); usage(*argv.offset(0 as libc::c_int as isize)); - crate::stdlib::exit(1 as libc::c_int); + exit(1 as libc::c_int); } current_block_129 = 10517665100358322178; } @@ -766,99 +614,79 @@ unsafe fn main_0(mut argc: libc::c_int, mut argv: *mut *mut libc::c_char) -> lib pidfile = optarg; current_block_129 = 10517665100358322178; } - 108 => { - crate::squeezelite_h::list_devices(); - crate::stdlib::exit(0 as libc::c_int); - } + 108 => { list_devices(); exit(0 as libc::c_int); } 79 => { mixer_device = optarg; current_block_129 = 10517665100358322178; } - 76 => { - crate::squeezelite_h::list_mixers(mixer_device); - crate::stdlib::exit(0 as libc::c_int); - } + 76 => { list_mixers(mixer_device); exit(0 as libc::c_int); } 88 => { linear_volume = 1 as libc::c_int != 0; current_block_129 = 10517665100358322178; } 85 => { output_mixer_unmute = 1 as libc::c_int != 0; - current_block_129 = 17662379048890589436; - } - 86 => { - current_block_129 = 17662379048890589436; + current_block_129 = 8353035839816271260; } + 86 => { current_block_129 = 8353035839816271260; } 122 => { daemonize = 1 as libc::c_int != 0; current_block_129 = 10517665100358322178; } - 116 => { - license(); - crate::stdlib::exit(0 as libc::c_int); - } + 116 => { license(); exit(0 as libc::c_int); } 63 => { usage(*argv.offset(0 as libc::c_int as isize)); - crate::stdlib::exit(0 as libc::c_int); + exit(0 as libc::c_int); } _ => { - crate::stdlib::fprintf( - crate::stdlib::stderr, - b"Arg error: %s\n\x00" as *const u8 as *const libc::c_char, - *argv.offset(optind as isize), - ); + fprintf(stderr, + b"Arg error: %s\n\x00" as *const u8 as + *const libc::c_char, + *argv.offset(optind as isize)); current_block_129 = 10517665100358322178; } } match current_block_129 { - 17662379048890589436 => { + 8353035839816271260 => { if !output_mixer.is_null() { - crate::stdlib::fprintf( - crate::stdlib::stderr, - b"-U and -V option should not be used at same time\n\x00" as *const u8 - as *const libc::c_char, - ); - crate::stdlib::exit(1 as libc::c_int); + fprintf(stderr, + b"-U and -V option should not be used at same time\n\x00" + as *const u8 as *const libc::c_char); + exit(1 as libc::c_int); } output_mixer = optarg } - _ => {} + _ => { } } } // warn if command line includes something which isn't parsed if optind < argc { - crate::stdlib::fprintf( - crate::stdlib::stderr, - b"\nError: command line argument error\n\n\x00" as *const u8 as *const libc::c_char, - ); + fprintf(stderr, + b"\nError: command line argument error\n\n\x00" as *const u8 + as *const libc::c_char); usage(*argv.offset(0 as libc::c_int as isize)); - crate::stdlib::exit(1 as libc::c_int); + exit(1 as libc::c_int); } - crate::stdlib::signal( - 2 as libc::c_int, - Some(sighandler as unsafe extern "C" fn(_: libc::c_int) -> ()), - ); - crate::stdlib::signal( - 15 as libc::c_int, - Some(sighandler as unsafe extern "C" fn(_: libc::c_int) -> ()), - ); - crate::stdlib::signal( - 3 as libc::c_int, - Some(sighandler as unsafe extern "C" fn(_: libc::c_int) -> ()), - ); - crate::stdlib::signal( - 1 as libc::c_int, - Some(sighandler as unsafe extern "C" fn(_: libc::c_int) -> ()), - ); + signal(2 as libc::c_int, + Some(sighandler as unsafe extern "C" fn(_: libc::c_int) -> ())); + signal(15 as libc::c_int, + Some(sighandler as unsafe extern "C" fn(_: libc::c_int) -> ())); + signal(3 as libc::c_int, + Some(sighandler as unsafe extern "C" fn(_: libc::c_int) -> ())); + signal(1 as libc::c_int, + Some(sighandler as unsafe extern "C" fn(_: libc::c_int) -> ())); // set the output buffer size if not specified on the command line, take account of resampling if output_buf_size == 0 { output_buf_size = - (44100 as libc::c_int * 8 as libc::c_int * 10 as libc::c_int) as libc::c_uint; + (44100 as libc::c_int * 8 as libc::c_int * 10 as libc::c_int) as + libc::c_uint; if !resample.is_null() { - let mut scale = 8 as libc::c_int as libc::c_uint; + let mut scale: libc::c_uint = 8 as libc::c_int as libc::c_uint; if rates[0 as libc::c_int as usize] != 0 { - scale = rates[0 as libc::c_int as usize] - .wrapping_div(44100 as libc::c_int as libc::c_uint); + scale = + rates[0 as libc::c_int as + usize].wrapping_div(44100 as libc::c_int as + libc::c_uint); if scale > 8 as libc::c_int as libc::c_uint { scale = 8 as libc::c_int as libc::c_uint } @@ -870,145 +698,94 @@ unsafe fn main_0(mut argc: libc::c_int, mut argv: *mut *mut libc::c_char) -> lib } } if !logfile.is_null() { - if crate::stdlib::freopen( - logfile, - b"a\x00" as *const u8 as *const libc::c_char, - crate::stdlib::stderr, - ) - .is_null() - { - crate::stdlib::fprintf( - crate::stdlib::stderr, - b"error opening logfile %s: %s\n\x00" as *const u8 as *const libc::c_char, - logfile, - crate::stdlib::strerror(*crate::stdlib::__errno_location()), - ); - } else if log_output as libc::c_uint - >= crate::squeezelite_h::lINFO as libc::c_int as libc::c_uint - || log_stream as libc::c_uint - >= crate::squeezelite_h::lINFO as libc::c_int as libc::c_uint - || log_decode as libc::c_uint - >= crate::squeezelite_h::lINFO as libc::c_int as libc::c_uint - || log_slimproto as libc::c_uint - >= crate::squeezelite_h::lINFO as libc::c_int as libc::c_uint - { - crate::stdlib::fprintf( - crate::stdlib::stderr, - b"\n%s\n\x00" as *const u8 as *const libc::c_char, - cmdline.as_mut_ptr(), - ); + if freopen(logfile, b"a\x00" as *const u8 as *const libc::c_char, + stderr).is_null() { + fprintf(stderr, + b"error opening logfile %s: %s\n\x00" as *const u8 as + *const libc::c_char, logfile, + strerror(*__errno_location())); + } else if log_output as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint || + log_stream as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint || + log_decode as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint || + log_slimproto as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint { + fprintf(stderr, b"\n%s\n\x00" as *const u8 as *const libc::c_char, + cmdline.as_mut_ptr()); } } if !pidfile.is_null() { - pidfp = crate::stdlib::fopen(pidfile, b"w\x00" as *const u8 as *const libc::c_char); + pidfp = fopen(pidfile, b"w\x00" as *const u8 as *const libc::c_char); if pidfp.is_null() { - crate::stdlib::fprintf( - crate::stdlib::stderr, - b"Error opening pidfile %s: %s\n\x00" as *const u8 as *const libc::c_char, - pidfile, - crate::stdlib::strerror(*crate::stdlib::__errno_location()), - ); - crate::stdlib::exit(1 as libc::c_int); + fprintf(stderr, + b"Error opening pidfile %s: %s\n\x00" as *const u8 as + *const libc::c_char, pidfile, + strerror(*__errno_location())); + exit(1 as libc::c_int); } - pidfile = crate::stdlib::realpath(pidfile, 0 as *mut libc::c_char) + pidfile = realpath(pidfile, 0 as *mut libc::c_char) // daemonize will change cwd } if daemonize { - if crate::stdlib::daemon( - 0 as libc::c_int, - if !logfile.is_null() { - 1 as libc::c_int - } else { - 0 as libc::c_int - }, - ) != 0 - { - crate::stdlib::fprintf( - crate::stdlib::stderr, - b"error daemonizing: %s\n\x00" as *const u8 as *const libc::c_char, - crate::stdlib::strerror(*crate::stdlib::__errno_location()), - ); + if daemon(0 as libc::c_int, + if !logfile.is_null() { + 1 as libc::c_int + } else { 0 as libc::c_int }) != 0 { + fprintf(stderr, + b"error daemonizing: %s\n\x00" as *const u8 as + *const libc::c_char, strerror(*__errno_location())); } } if !pidfp.is_null() { - crate::stdlib::fprintf( - pidfp, - b"%d\n\x00" as *const u8 as *const libc::c_char, - crate::stdlib::getpid(), - ); - crate::stdlib::fclose(pidfp); + fprintf(pidfp, b"%d\n\x00" as *const u8 as *const libc::c_char, + getpid()); + fclose(pidfp); } - crate::squeezelite_h::stream_init(log_stream, stream_buf_size); - if crate::stdlib::strcmp(output_device, b"-\x00" as *const u8 as *const libc::c_char) == 0 { - crate::squeezelite_h::output_init_stdout( - log_output, - output_buf_size, - output_params, - rates.as_mut_ptr(), - rate_delay, - ); + stream_init(log_stream, stream_buf_size); + if strcmp(output_device, b"-\x00" as *const u8 as *const libc::c_char) == + 0 { + output_init_stdout(log_output, output_buf_size, output_params, + rates.as_mut_ptr(), rate_delay); } else { - crate::squeezelite_h::output_init_alsa( - log_output, - output_device, - output_buf_size, - output_params, - rates.as_mut_ptr(), - rate_delay, - rt_priority, - idle, - mixer_device, - output_mixer, - output_mixer_unmute, - linear_volume, - ); + output_init_alsa(log_output, output_device, output_buf_size, + output_params, rates.as_mut_ptr(), rate_delay, + rt_priority, idle, mixer_device, output_mixer, + output_mixer_unmute, linear_volume); } - crate::squeezelite_h::decode_init(log_decode, include_codecs, exclude_codecs); + decode_init(log_decode, include_codecs, exclude_codecs); if !name.is_null() && !namefile.is_null() { - crate::stdlib::fprintf( - crate::stdlib::stderr, - b"-n and -N option should not be used at same time\n\x00" as *const u8 - as *const libc::c_char, - ); - crate::stdlib::exit(1 as libc::c_int); - } - crate::squeezelite_h::slimproto( - log_slimproto, - server, - mac.as_mut_ptr(), - name, - namefile, - modelname, - maxSampleRate, - ); - crate::squeezelite_h::decode_close(); - crate::squeezelite_h::stream_close(); - if crate::stdlib::strcmp(output_device, b"-\x00" as *const u8 as *const libc::c_char) == 0 { - crate::squeezelite_h::output_close_stdout(); - } else { - crate::squeezelite_h::output_close_alsa(); + fprintf(stderr, + b"-n and -N option should not be used at same time\n\x00" as + *const u8 as *const libc::c_char); + exit(1 as libc::c_int); } + slimproto(log_slimproto, server, mac.as_mut_ptr(), name, namefile, + modelname, maxSampleRate); + decode_close(); + stream_close(); + if strcmp(output_device, b"-\x00" as *const u8 as *const libc::c_char) == + 0 { + output_close_stdout(); + } else { output_close_alsa(); } if !pidfile.is_null() { - crate::stdlib::unlink(pidfile); - crate::stdlib::free(pidfile as *mut libc::c_void); + unlink(pidfile); + free(pidfile as *mut libc::c_void); } - crate::stdlib::exit(0 as libc::c_int); + exit(0 as libc::c_int); } +#[cross_check(none)] #[main] pub fn main() { let mut args: Vec<*mut libc::c_char> = Vec::new(); for arg in ::std::env::args() { - args.push( - ::std::ffi::CString::new(arg) - .expect("Failed to convert argument into CString.") - .into_raw(), - ); - } + args.push(::std::ffi::CString::new(arg).expect("Failed to convert argument into CString.").into_raw()); + }; args.push(::std::ptr::null_mut()); unsafe { - ::std::process::exit(main_0( - (args.len() - 1) as libc::c_int, - args.as_mut_ptr() as *mut *mut libc::c_char, - ) as i32) + ::std::process::exit(main_0((args.len() - 1) as libc::c_int, + args.as_mut_ptr() as + *mut *mut libc::c_char) as i32) } } diff --git a/src/mpg.rs b/src/mpg.rs index 5fe1a00..e96b23e 100644 --- a/src/mpg.rs +++ b/src/mpg.rs @@ -1,646 +1,752 @@ 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" { + pub type mpg123_handle_struct; #[no_mangle] - pub static mut loglevel: crate::squeezelite_h::log_level; + fn malloc(_: libc::c_ulong) -> *mut libc::c_void; #[no_mangle] - pub static mut streambuf: *mut crate::squeezelite_h::buffer; + fn _checkfade(_: bool); #[no_mangle] - pub static mut outputbuf: *mut crate::squeezelite_h::buffer; + fn dlopen(__file: *const libc::c_char, __mode: libc::c_int) + -> *mut libc::c_void; #[no_mangle] - pub static mut stream: crate::squeezelite_h::streamstate; + fn dlsym(__handle: *mut libc::c_void, __name: *const libc::c_char) + -> *mut libc::c_void; #[no_mangle] - pub static mut output: crate::squeezelite_h::outputstate; + fn dlerror() -> *mut libc::c_char; #[no_mangle] - pub static mut decode: crate::squeezelite_h::decodestate; + fn pthread_mutex_lock(__mutex: *mut pthread_mutex_t) -> libc::c_int; + #[no_mangle] + fn pthread_mutex_unlock(__mutex: *mut pthread_mutex_t) -> libc::c_int; + #[no_mangle] + fn logtime() -> *const libc::c_char; + #[no_mangle] + fn logprint(fmt: *const libc::c_char, _: ...); + #[no_mangle] + fn _buf_used(buf: *mut buffer) -> libc::c_uint; + #[no_mangle] + fn _buf_space(buf: *mut buffer) -> libc::c_uint; + #[no_mangle] + fn _buf_cont_read(buf: *mut buffer) -> libc::c_uint; + #[no_mangle] + fn _buf_cont_write(buf: *mut buffer) -> libc::c_uint; + #[no_mangle] + fn _buf_inc_readp(buf: *mut buffer, by: libc::c_uint); + #[no_mangle] + fn _buf_inc_writep(buf: *mut buffer, by: libc::c_uint); + #[no_mangle] + fn decode_newstream(sample_rate: libc::c_uint, + supported_rates: *mut libc::c_uint) -> libc::c_uint; + #[no_mangle] + static mut loglevel: log_level; + #[no_mangle] + static mut streambuf: *mut buffer; + #[no_mangle] + static mut outputbuf: *mut buffer; + #[no_mangle] + static mut stream: streamstate; + #[no_mangle] + static mut output: outputstate; + #[no_mangle] + static mut decode: decodestate; } - -#[repr(C)] +pub type size_t = libc::c_ulong; +pub type __uint8_t = libc::c_uchar; +pub type __int16_t = libc::c_short; +pub type __int32_t = libc::c_int; +pub type __uint32_t = libc::c_uint; +pub type __uint64_t = libc::c_ulong; +pub type int16_t = __int16_t; +pub type int32_t = __int32_t; +pub type u_int8_t = __uint8_t; +pub type u_int32_t = __uint32_t; +pub type u_int64_t = __uint64_t; #[derive(Copy, Clone)] +#[repr(C)] +pub struct __pthread_internal_list { + pub __prev: *mut __pthread_internal_list, + pub __next: *mut __pthread_internal_list, +} +pub type __pthread_list_t = __pthread_internal_list; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct __pthread_mutex_s { + pub __lock: libc::c_int, + pub __count: libc::c_uint, + pub __owner: libc::c_int, + pub __nusers: libc::c_uint, + pub __kind: libc::c_int, + pub __spins: libc::c_short, + pub __elision: libc::c_short, + pub __list: __pthread_list_t, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub union pthread_mutex_t { + pub __data: __pthread_mutex_s, + pub __size: [libc::c_char; 40], + pub __align: libc::c_long, +} +pub type u8_t = u_int8_t; +pub type u32_t = u_int32_t; +pub type u64_t = u_int64_t; +pub type s16_t = int16_t; +pub type s32_t = int32_t; +pub type frames_t = u32_t; +pub type log_level = libc::c_uint; +pub const lSDEBUG: log_level = 4; +pub const lDEBUG: log_level = 3; +pub const lINFO: log_level = 2; +pub const lWARN: log_level = 1; +pub const lERROR: log_level = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct buffer { + pub buf: *mut u8_t, + pub readp: *mut u8_t, + pub writep: *mut u8_t, + pub wrap: *mut u8_t, + pub size: size_t, + pub base_size: size_t, + pub mutex: pthread_mutex_t, +} +pub type stream_state = libc::c_uint; +pub const RECV_HEADERS: stream_state = 7; +pub const SEND_HEADERS: stream_state = 6; +pub const STREAMING_HTTP: stream_state = 5; +pub const STREAMING_FILE: stream_state = 4; +pub const STREAMING_BUFFERING: stream_state = 3; +pub const STREAMING_WAIT: stream_state = 2; +pub const DISCONNECT: stream_state = 1; +pub const STOPPED: stream_state = 0; +pub type disconnect_code = libc::c_uint; +pub const TIMEOUT: disconnect_code = 4; +pub const UNREACHABLE: disconnect_code = 3; +pub const REMOTE_DISCONNECT: disconnect_code = 2; +pub const LOCAL_DISCONNECT: disconnect_code = 1; +pub const DISCONNECT_OK: disconnect_code = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct streamstate { + pub state: stream_state, + pub disconnect: disconnect_code, + pub header: *mut libc::c_char, + pub header_len: size_t, + pub sent_headers: bool, + pub cont_wait: bool, + pub bytes: u64_t, + pub threshold: libc::c_uint, + pub meta_interval: u32_t, + pub meta_next: u32_t, + pub meta_left: u32_t, + pub meta_send: bool, +} +pub type decode_state = libc::c_uint; +pub const DECODE_ERROR: decode_state = 4; +pub const DECODE_COMPLETE: decode_state = 3; +pub const DECODE_RUNNING: decode_state = 2; +pub const DECODE_READY: decode_state = 1; +pub const DECODE_STOPPED: decode_state = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct decodestate { + pub state: decode_state, + pub new_stream: bool, + pub mutex: pthread_mutex_t, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct codec { + pub id: libc::c_char, + pub types: *mut libc::c_char, + pub min_read_bytes: libc::c_uint, + pub min_space: libc::c_uint, + pub open: Option ()>, + pub close: Option ()>, + pub decode: Option decode_state>, +} +pub type output_state = libc::c_int; +pub const OUTPUT_START_AT: output_state = 5; +pub const OUTPUT_SKIP_FRAMES: output_state = 4; +pub const OUTPUT_PAUSE_FRAMES: output_state = 3; +pub const OUTPUT_RUNNING: output_state = 2; +pub const OUTPUT_BUFFER: output_state = 1; +pub const OUTPUT_STOPPED: output_state = 0; +pub const OUTPUT_OFF: output_state = -1; +pub type output_format = libc::c_uint; +pub const S16_LE: output_format = 3; +pub const S24_3LE: output_format = 2; +pub const S24_LE: output_format = 1; +pub const S32_LE: output_format = 0; +pub type fade_state = libc::c_uint; +pub const FADE_ACTIVE: fade_state = 2; +pub const FADE_DUE: fade_state = 1; +pub const FADE_INACTIVE: fade_state = 0; +pub type fade_dir = libc::c_uint; +pub const FADE_CROSS: fade_dir = 3; +pub const FADE_DOWN: fade_dir = 2; +pub const FADE_UP: fade_dir = 1; +pub type fade_mode = libc::c_uint; +pub const FADE_INOUT: fade_mode = 4; +pub const FADE_OUT: fade_mode = 3; +pub const FADE_IN: fade_mode = 2; +pub const FADE_CROSSFADE: fade_mode = 1; +pub const FADE_NONE: fade_mode = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct outputstate { + pub state: output_state, + pub format: output_format, + pub device: *const libc::c_char, + pub buffer: libc::c_uint, + pub period: libc::c_uint, + pub track_started: bool, + pub write_cb: Option libc::c_int>, + pub start_frames: libc::c_uint, + pub frames_played: libc::c_uint, + pub frames_played_dmp: libc::c_uint, + pub current_sample_rate: libc::c_uint, + pub supported_rates: [libc::c_uint; 18], + pub default_sample_rate: libc::c_uint, + pub error_opening: bool, + pub device_frames: libc::c_uint, + pub updated: u32_t, + pub track_start_time: u32_t, + pub current_replay_gain: u32_t, + pub c2rust_unnamed: C2RustUnnamed, + pub next_sample_rate: libc::c_uint, + pub track_start: *mut u8_t, + pub gainL: u32_t, + pub gainR: u32_t, + pub invert: bool, + pub next_replay_gain: u32_t, + pub threshold: libc::c_uint, + pub fade: fade_state, + pub fade_start: *mut u8_t, + pub fade_end: *mut u8_t, + pub fade_dir: fade_dir, + pub fade_mode: fade_mode, + pub fade_secs: libc::c_uint, + pub rate_delay: libc::c_uint, + pub delay_active: bool, + pub stop_time: u32_t, + pub idle_to: u32_t, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub union C2RustUnnamed { + pub pause_frames: u32_t, + pub skip_frames: u32_t, + pub start_at: u32_t, +} +pub const MPG123_ERR: mpg123_errors = -1; +pub const MPG123_DONE: mpg123_errors = -12; +#[derive(Copy, Clone)] +#[repr(C)] pub struct mpg { - pub h: *mut crate::stdlib::mpg123_handle, + pub h: *mut mpg123_handle, pub use16bit: bool, pub mpg123_init: Option libc::c_int>, - pub mpg123_feature: - Option 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 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 ()>, - pub mpg123_open_feed: - Option 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 *const libc::c_char>, + pub mpg123_feature: Option libc::c_int>, + pub mpg123_rates: Option ()>, + pub mpg123_format_none: Option libc::c_int>, + pub mpg123_format: Option libc::c_int>, + pub mpg123_new: Option *mut mpg123_handle>, + pub mpg123_delete: Option ()>, + pub mpg123_open_feed: Option libc::c_int>, + pub mpg123_decode: Option libc::c_int>, + pub mpg123_getformat: Option libc::c_int>, + pub mpg123_plain_strerror: Option *const libc::c_char>, } - +pub type mpg123_handle = mpg123_handle_struct; +pub type mpg123_feature_set = libc::c_uint; +pub const MPG123_FEATURE_EQUALIZER: mpg123_feature_set = 14; +pub const MPG123_FEATURE_TIMEOUT_READ: mpg123_feature_set = 13; +pub const MPG123_FEATURE_PARSE_ICY: mpg123_feature_set = 12; +pub const MPG123_FEATURE_DECODE_NTOM: mpg123_feature_set = 11; +pub const MPG123_FEATURE_DECODE_DOWNSAMPLE: mpg123_feature_set = 10; +pub const MPG123_FEATURE_DECODE_ACCURATE: mpg123_feature_set = 9; +pub const MPG123_FEATURE_DECODE_LAYER3: mpg123_feature_set = 8; +pub const MPG123_FEATURE_DECODE_LAYER2: mpg123_feature_set = 7; +pub const MPG123_FEATURE_DECODE_LAYER1: mpg123_feature_set = 6; +pub const MPG123_FEATURE_PARSE_ID3V2: mpg123_feature_set = 5; +pub const MPG123_FEATURE_INDEX: mpg123_feature_set = 4; +pub const MPG123_FEATURE_OUTPUT_32BIT: mpg123_feature_set = 3; +pub const MPG123_FEATURE_OUTPUT_16BIT: mpg123_feature_set = 2; +pub const MPG123_FEATURE_OUTPUT_8BIT: mpg123_feature_set = 1; +pub const MPG123_FEATURE_ABI_UTF8OPEN: mpg123_feature_set = 0; +pub const MPG123_NEW_FORMAT: mpg123_errors = -11; +pub const MPG123_ENC_SIGNED_32: mpg123_enc_enum = 4480; +pub const MPG123_ENC_SIGNED_16: mpg123_enc_enum = 208; +pub type mpg123_enc_enum = libc::c_uint; +pub const MPG123_ENC_ANY: mpg123_enc_enum = 30719; +pub const MPG123_ENC_FLOAT_64: mpg123_enc_enum = 1024; +pub const MPG123_ENC_FLOAT_32: mpg123_enc_enum = 512; +pub const MPG123_ENC_UNSIGNED_24: mpg123_enc_enum = 24576; +pub const MPG123_ENC_SIGNED_24: mpg123_enc_enum = 20608; +pub const MPG123_ENC_UNSIGNED_32: mpg123_enc_enum = 8448; +pub const MPG123_ENC_ALAW_8: mpg123_enc_enum = 8; +pub const MPG123_ENC_ULAW_8: mpg123_enc_enum = 4; +pub const MPG123_ENC_SIGNED_8: mpg123_enc_enum = 130; +pub const MPG123_ENC_UNSIGNED_8: mpg123_enc_enum = 1; +pub const MPG123_ENC_UNSIGNED_16: mpg123_enc_enum = 96; +pub const MPG123_ENC_FLOAT: mpg123_enc_enum = 3584; +pub const MPG123_ENC_SIGNED: mpg123_enc_enum = 128; +pub const MPG123_ENC_32: mpg123_enc_enum = 256; +pub const MPG123_ENC_24: mpg123_enc_enum = 16384; +pub const MPG123_ENC_16: mpg123_enc_enum = 64; +pub const MPG123_ENC_8: mpg123_enc_enum = 15; +pub type mpg123_errors = libc::c_int; +pub const MPG123_INT_OVERFLOW: mpg123_errors = 43; +pub const MPG123_LFS_OVERFLOW: mpg123_errors = 42; +pub const MPG123_BAD_CUSTOM_IO: mpg123_errors = 41; +pub const MPG123_LSEEK_FAILED: mpg123_errors = 40; +pub const MPG123_BAD_VALUE: mpg123_errors = 39; +pub const MPG123_MISSING_FEATURE: mpg123_errors = 38; +pub const MPG123_BAD_DECODER_SETUP: mpg123_errors = 37; +pub const MPG123_INDEX_FAIL: mpg123_errors = 36; +pub const MPG123_NO_INDEX: mpg123_errors = 35; +pub const MPG123_BAD_KEY: mpg123_errors = 34; +pub const MPG123_NULL_POINTER: mpg123_errors = 33; +pub const MPG123_NO_RELSEEK: mpg123_errors = 32; +pub const MPG123_NULL_BUFFER: mpg123_errors = 31; +pub const MPG123_BAD_ALIGN: mpg123_errors = 30; +pub const MPG123_NO_8BIT: mpg123_errors = 29; +pub const MPG123_RESYNC_FAIL: mpg123_errors = 28; +pub const MPG123_OUT_OF_SYNC: mpg123_errors = 27; +pub const MPG123_BAD_INDEX_PAR: mpg123_errors = 26; +pub const MPG123_BAD_PARS: mpg123_errors = 25; +pub const MPG123_NO_READER: mpg123_errors = 24; +pub const MPG123_NO_SEEK: mpg123_errors = 23; +pub const MPG123_BAD_FILE: mpg123_errors = 22; +pub const MPG123_NO_TIMEOUT: mpg123_errors = 21; +pub const MPG123_BAD_WHENCE: mpg123_errors = 20; +pub const MPG123_NO_SEEK_FROM_END: mpg123_errors = 19; +pub const MPG123_ERR_READER: mpg123_errors = 18; +pub const MPG123_ERR_NULL: mpg123_errors = 17; +pub const MPG123_BAD_BAND: mpg123_errors = 16; +pub const MPG123_BAD_TYPES: mpg123_errors = 15; +pub const MPG123_NO_SPACE: mpg123_errors = 14; +pub const MPG123_NO_GAPLESS: mpg123_errors = 13; +pub const MPG123_BAD_RVA: mpg123_errors = 12; +pub const MPG123_NO_BUFFERS: mpg123_errors = 11; +pub const MPG123_BAD_HANDLE: mpg123_errors = 10; +pub const MPG123_BAD_DECODER: mpg123_errors = 9; +pub const MPG123_NOT_INITIALIZED: mpg123_errors = 8; +pub const MPG123_OUT_OF_MEM: mpg123_errors = 7; +pub const MPG123_BAD_BUFFER: mpg123_errors = 6; +pub const MPG123_BAD_PARAM: mpg123_errors = 5; +pub const MPG123_ERR_16TO8TABLE: mpg123_errors = 4; +pub const MPG123_BAD_RATE: mpg123_errors = 3; +pub const MPG123_BAD_CHANNEL: mpg123_errors = 2; +pub const MPG123_BAD_OUTFORMAT: mpg123_errors = 1; +pub const MPG123_OK: mpg123_errors = 0; +pub const MPG123_NEED_MORE: mpg123_errors = -10; static mut m: *mut mpg = 0 as *const mpg as *mut mpg; - -unsafe extern "C" fn mpg_decode() -> 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; +unsafe extern "C" fn mpg_decode() -> decode_state { + let mut bytes: size_t = 0; + let mut space: size_t = 0; + let mut size: size_t = 0; let mut ret: libc::c_int = 0; - let mut write_buf = 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; + let mut write_buf: *mut u8_t = 0 as *mut u8_t; + pthread_mutex_lock(&mut (*streambuf).mutex); + pthread_mutex_lock(&mut (*outputbuf).mutex); + bytes = + if _buf_used(streambuf) < _buf_cont_read(streambuf) { + _buf_used(streambuf) + } else { _buf_cont_read(streambuf) } as size_t; + space = + if _buf_space(outputbuf) < _buf_cont_write(outputbuf) { + _buf_space(outputbuf) + } else { _buf_cont_write(outputbuf) } as size_t; write_buf = (*outputbuf).writep; - bytes = if bytes < 512 as libc::c_int as libc::c_ulong { - bytes - } else { - 512 as libc::c_int as libc::c_ulong - }; - space = if space < (32 as libc::c_int * 1024 as libc::c_int) as libc::c_ulong { - space - } else { - (32 as libc::c_int * 1024 as libc::c_int) as libc::c_ulong - }; + 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) + 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 { space = 0 as libc::c_int as size_t } + ret = + (*m).mpg123_decode.expect("non-null function pointer")((*m).h, + (*streambuf).readp, + bytes, + write_buf, + space, + &mut size); + if ret == MPG123_NEW_FORMAT as libc::c_int { if decode.new_stream { let mut rate: libc::c_long = 0; let mut channels: libc::c_int = 0; let mut enc: libc::c_int = 0; - (*m).mpg123_getformat.expect("non-null function pointer")( - (*m).h, - &mut rate, - &mut channels, - &mut enc, - ); - if loglevel as libc::c_uint - >= 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, - ); + (*m).mpg123_getformat.expect("non-null function pointer")((*m).h, + &mut rate, + &mut channels, + &mut enc); + if loglevel as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d setting track_start\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 11], + &[libc::c_char; 11]>(b"mpg_decode\x00")).as_ptr(), + 125 as libc::c_int); } - output.next_sample_rate = crate::src::decode::decode_newstream( - rate as libc::c_uint, - output.supported_rates.as_mut_ptr(), - ); + output.next_sample_rate = + decode_newstream(rate as libc::c_uint, + output.supported_rates.as_mut_ptr()); output.track_start = (*outputbuf).writep; if output.fade_mode as u64 != 0 { - crate::src::output::_checkfade(1 as libc::c_int != 0); + _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, - ); + } else if loglevel as libc::c_uint >= + lWARN as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d format change mid stream - not supported\n\x00" + as *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 11], + &[libc::c_char; 11]>(b"mpg_decode\x00")).as_ptr(), + 135 as libc::c_int); } } // expand 16bit output to 32bit samples if (*m).use16bit { - let mut iptr = 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); + let mut iptr: *mut s16_t = 0 as *mut s16_t; + let mut optr: *mut s32_t = 0 as *mut s32_t; + let mut count: size_t = + size.wrapping_div(2 as libc::c_int as libc::c_ulong); size = count.wrapping_mul(4 as libc::c_int as libc::c_ulong); - iptr = (write_buf as *mut crate::squeezelite_h::s16_t).offset(count as isize); - optr = (write_buf as *mut crate::squeezelite_h::s32_t).offset(count as isize); - loop { + iptr = (write_buf as *mut s16_t).offset(count as isize); + optr = (write_buf as *mut s32_t).offset(count as isize); + loop { let fresh0 = count; count = count.wrapping_sub(1); - if !(fresh0 != 0) { - break; - } + 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), - ); + _buf_inc_readp(streambuf, bytes as libc::c_uint); + _buf_inc_writep(outputbuf, size as libc::c_uint); + pthread_mutex_unlock(&mut (*outputbuf).mutex); + if loglevel as libc::c_uint >= lSDEBUG as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d write %u frames\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 11], + &[libc::c_char; 11]>(b"mpg_decode\x00")).as_ptr(), + 163 as libc::c_int, + size.wrapping_div(8 as libc::c_int as libc::c_ulong)); } - if ret == 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, - ); + if ret == MPG123_DONE as libc::c_int || + bytes == 0 as libc::c_int as libc::c_ulong && + size == 0 as libc::c_int as libc::c_ulong && + stream.state as libc::c_uint <= + DISCONNECT as libc::c_int as libc::c_uint { + pthread_mutex_unlock(&mut (*streambuf).mutex); + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d stream complete\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 11], + &[libc::c_char; 11]>(b"mpg_decode\x00")).as_ptr(), + 167 as libc::c_int); } - return crate::squeezelite_h::DECODE_COMPLETE; + return 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, - ); + pthread_mutex_unlock(&mut (*streambuf).mutex); + if ret == MPG123_ERR as libc::c_int { + if loglevel as libc::c_uint >= lWARN as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d Error\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 11], + &[libc::c_char; 11]>(b"mpg_decode\x00")).as_ptr(), + 174 as libc::c_int); } - return crate::squeezelite_h::DECODE_COMPLETE; + return DECODE_COMPLETE } // OK and NEED_MORE keep running - return crate::squeezelite_h::DECODE_RUNNING; + return 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, -) { +unsafe extern "C" fn mpg_open(mut size: u8_t, mut rate: u8_t, mut chan: u8_t, + mut endianness: u8_t) { let mut err: libc::c_int = 0; - let mut list = 0 as *const libc::c_long; - let mut count: crate::stddef_h::size_t = 0; - let mut i: crate::stddef_h::size_t = 0; + let mut list: *const libc::c_long = 0 as *const libc::c_long; + let mut count: size_t = 0; + let mut i: size_t = 0; if !(*m).h.is_null() { (*m).mpg123_delete.expect("non-null function pointer")((*m).h); } (*m).h = - (*m).mpg123_new.expect("non-null function pointer")(0 as *const libc::c_char, &mut err); + (*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), - ); + if loglevel as libc::c_uint >= lWARN as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d new error: %s\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 9], + &[libc::c_char; 9]>(b"mpg_open\x00")).as_ptr(), + 194 as libc::c_int, + (*m).mpg123_plain_strerror.expect("non-null function pointer")(err)); } } // restrict output to 32bit or 16bit signed 2 channel based on library capability - (*m).mpg123_rates.expect("non-null function pointer")(&mut list, &mut count); + (*m).mpg123_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; + i = 0 as libc::c_int as size_t; while i < count { - (*m).mpg123_format.expect("non-null function pointer")( - (*m).h, - *list.offset(i as isize), - 2 as libc::c_int, - if (*m).use16bit as libc::c_int != 0 { - crate::stdlib::MPG123_ENC_SIGNED_16 as libc::c_int - } else { - crate::stdlib::MPG123_ENC_SIGNED_32 as libc::c_int - }, - ); + (*m).mpg123_format.expect("non-null function pointer")((*m).h, + *list.offset(i + as + isize), + 2 as + libc::c_int, + if (*m).use16bit + as + libc::c_int + != 0 { + MPG123_ENC_SIGNED_16 + as + libc::c_int + } else { + MPG123_ENC_SIGNED_32 + as + libc::c_int + }); i = i.wrapping_add(1) } err = (*m).mpg123_open_feed.expect("non-null function pointer")((*m).h); if err != 0 { - if loglevel as libc::c_uint >= 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), - ); + if loglevel as libc::c_uint >= lWARN as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d open feed error: %s\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 9], + &[libc::c_char; 9]>(b"mpg_open\x00")).as_ptr(), + 207 as libc::c_int, + (*m).mpg123_plain_strerror.expect("non-null function pointer")(err)); } }; } - unsafe extern "C" fn mpg_close() { (*m).mpg123_delete.expect("non-null function pointer")((*m).h); - (*m).h = 0 as *mut crate::stdlib::mpg123_handle; + (*m).h = 0 as *mut 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; + let mut handle: *mut libc::c_void = + dlopen(b"libmpg123.so.0\x00" as *const u8 as *const libc::c_char, + 0x2 as libc::c_int); + let mut err: *mut libc::c_char = 0 as *mut libc::c_char; if handle.is_null() { - if loglevel as libc::c_uint >= 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(), - ); + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d dlerror: %s\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 9], + &[libc::c_char; 9]>(b"load_mpg\x00")).as_ptr(), + 222 as libc::c_int, dlerror()); } - return 0 as libc::c_int != 0; + return 0 as libc::c_int != 0 } - (*m).mpg123_init = ::std::mem::transmute::< - *mut libc::c_void, - Option 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 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 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 ()>, - >(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 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 *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(); + (*m).mpg123_init = + ::std::mem::transmute::<*mut libc::c_void, + Option + libc::c_int>>(dlsym(handle, + b"mpg123_init\x00" + as + *const u8 + as + *const libc::c_char)); + (*m).mpg123_feature = + ::std::mem::transmute::<*mut libc::c_void, + Option + libc::c_int>>(dlsym(handle, + b"mpg123_feature\x00" + as + *const u8 + as + *const libc::c_char)); + (*m).mpg123_rates = + ::std::mem::transmute::<*mut libc::c_void, + Option + ()>>(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 + libc::c_int>>(dlsym(handle, + b"mpg123_format_none\x00" + as + *const u8 + as + *const libc::c_char)); + (*m).mpg123_format = + ::std::mem::transmute::<*mut libc::c_void, + Option + libc::c_int>>(dlsym(handle, + b"mpg123_format\x00" + as + *const u8 + as + *const libc::c_char)); + (*m).mpg123_new = + ::std::mem::transmute::<*mut libc::c_void, + Option + *mut mpg123_handle>>(dlsym(handle, + b"mpg123_new\x00" + as + *const u8 + as + *const libc::c_char)); + (*m).mpg123_delete = + ::std::mem::transmute::<*mut libc::c_void, + Option + ()>>(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 + libc::c_int>>(dlsym(handle, + b"mpg123_open_feed\x00" + as + *const u8 + as + *const libc::c_char)); + (*m).mpg123_decode = + ::std::mem::transmute::<*mut libc::c_void, + Option + libc::c_int>>(dlsym(handle, + b"mpg123_decode\x00" + as + *const u8 + as + *const libc::c_char)); + (*m).mpg123_getformat = + ::std::mem::transmute::<*mut libc::c_void, + Option + libc::c_int>>(dlsym(handle, + b"mpg123_getformat\x00" + as + *const u8 + as + *const libc::c_char)); + (*m).mpg123_plain_strerror = + ::std::mem::transmute::<*mut libc::c_void, + Option + *const libc::c_char>>(dlsym(handle, + b"mpg123_plain_strerror\x00" + as + *const u8 + as + *const libc::c_char)); + err = dlerror(); if !err.is_null() { - if loglevel as libc::c_uint >= 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, - ); + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d dlerror: %s\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 9], + &[libc::c_char; 9]>(b"load_mpg\x00")).as_ptr(), + 239 as libc::c_int, err); } - return 0 as libc::c_int != 0; + 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, - ); + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d loaded libmpg123.so.0\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 9], + &[libc::c_char; 9]>(b"load_mpg\x00")).as_ptr(), + 243 as libc::c_int); } return 1 as libc::c_int != 0; } -/* +/* * Squeezelite - lightweight headless squeezebox emulator * * (c) Adrian Smith 2012-2015, triode1@btinternet.com * Ralph Irving 2015-2017, ralph_irving@hotmail.com - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the @@ -691,52 +797,47 @@ unsafe extern "C" fn load_mpg() -> bool { // 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::() 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; - } +pub unsafe extern "C" fn register_mpg() -> *mut codec { + static mut ret: codec = + unsafe { + { + let mut init = + codec{id: 'm' as i32 as libc::c_char, + types: + b"mp3\x00" as *const u8 as *const libc::c_char + as *mut libc::c_char, + min_read_bytes: 512 as libc::c_int as libc::c_uint, + min_space: + (32 as libc::c_int * 1024 as libc::c_int) as + libc::c_uint, + open: + Some(mpg_open as + unsafe extern "C" fn(_: u8_t, _: u8_t, + _: u8_t, _: u8_t) + -> ()), + close: + Some(mpg_close as unsafe extern "C" fn() -> ()), + decode: + Some(mpg_decode as + unsafe extern "C" fn() + -> decode_state),}; + init + } + }; + m = malloc(::std::mem::size_of::() as libc::c_ulong) as *mut mpg; + if m.is_null() { return 0 as *mut codec } + (*m).h = 0 as *mut mpg123_handle; + if !load_mpg() { return 0 as *mut codec } (*m).mpg123_init.expect("non-null function pointer")(); - (*m).use16bit = (*m).mpg123_feature.expect("non-null function pointer")( - 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, - ); + (*m).use16bit = + (*m).mpg123_feature.expect("non-null function pointer")(MPG123_FEATURE_OUTPUT_32BIT) + != 0; + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d using mpg to decode mp3\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 13], + &[libc::c_char; 13]>(b"register_mpg\x00")).as_ptr(), + 275 as libc::c_int); } return &mut ret; } diff --git a/src/output.rs b/src/output.rs index 099636e..f275a8f 100644 --- a/src/output.rs +++ b/src/output.rs @@ -1,82 +1,188 @@ 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::__uint8_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::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::gain; -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::to_gain; -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::buffer::_buf_cont_read; -pub use crate::src::buffer::_buf_inc_readp; -pub use crate::src::buffer::_buf_resize; -pub use crate::src::buffer::buf_destroy; -pub use crate::src::buffer::buf_flush; -pub use crate::src::buffer::buf_init; -pub use crate::src::output_alsa::test_open; -pub use crate::src::slimproto::wake_controller; -pub use crate::src::utils::gettime_ms; -pub use crate::src::utils::logprint; -pub use crate::src::utils::logtime; -pub use crate::src::utils::touch_memory; -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; -use crate::stdlib::sprintf; -pub use crate::stdlib::u_int32_t; -pub use crate::stdlib::u_int8_t; - -use crate::stdlib::exit; -use crate::stdlib::free; -use crate::stdlib::malloc; -use crate::stdlib::memset; -use crate::stdlib::pthread_mutex_lock; -use crate::stdlib::pthread_mutex_unlock; -use crate::stdlib::strcat; -/* +extern "C" { + #[no_mangle] + fn sprintf(_: *mut libc::c_char, _: *const libc::c_char, _: ...) + -> libc::c_int; + #[no_mangle] + fn malloc(_: libc::c_ulong) -> *mut libc::c_void; + #[no_mangle] + fn free(__ptr: *mut libc::c_void); + #[no_mangle] + fn exit(_: libc::c_int) -> !; + #[no_mangle] + fn memset(_: *mut libc::c_void, _: libc::c_int, _: libc::c_ulong) + -> *mut libc::c_void; + #[no_mangle] + fn strcat(_: *mut libc::c_char, _: *const libc::c_char) + -> *mut libc::c_char; + #[no_mangle] + fn pthread_mutex_lock(__mutex: *mut pthread_mutex_t) -> libc::c_int; + #[no_mangle] + fn pthread_mutex_unlock(__mutex: *mut pthread_mutex_t) -> libc::c_int; + #[no_mangle] + fn logtime() -> *const libc::c_char; + #[no_mangle] + fn logprint(fmt: *const libc::c_char, _: ...); + #[no_mangle] + fn gettime_ms() -> u32_t; + #[no_mangle] + fn touch_memory(buf_0: *mut u8_t, size: size_t); + #[no_mangle] + fn _buf_used(buf_0: *mut buffer) -> libc::c_uint; + #[no_mangle] + fn _buf_cont_read(buf_0: *mut buffer) -> libc::c_uint; + #[no_mangle] + fn _buf_inc_readp(buf_0: *mut buffer, by: libc::c_uint); + #[no_mangle] + fn buf_flush(buf_0: *mut buffer); + #[no_mangle] + fn _buf_resize(buf_0: *mut buffer, size: size_t); + #[no_mangle] + fn buf_init(buf_0: *mut buffer, size: size_t); + #[no_mangle] + fn buf_destroy(buf_0: *mut buffer); + #[no_mangle] + fn wake_controller(); + #[no_mangle] + fn test_open(device: *const libc::c_char, rates: *mut libc::c_uint, + userdef_rates: bool) -> bool; + #[no_mangle] + fn gain(gain_0: s32_t, sample: s32_t) -> s32_t; + #[no_mangle] + fn to_gain(f: libc::c_float) -> s32_t; +} +pub type size_t = libc::c_ulong; +pub type __uint8_t = libc::c_uchar; +pub type __int32_t = libc::c_int; +pub type __uint32_t = libc::c_uint; +pub type int32_t = __int32_t; +pub type u_int8_t = __uint8_t; +pub type u_int32_t = __uint32_t; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct __pthread_internal_list { + pub __prev: *mut __pthread_internal_list, + pub __next: *mut __pthread_internal_list, +} +pub type __pthread_list_t = __pthread_internal_list; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct __pthread_mutex_s { + pub __lock: libc::c_int, + pub __count: libc::c_uint, + pub __owner: libc::c_int, + pub __nusers: libc::c_uint, + pub __kind: libc::c_int, + pub __spins: libc::c_short, + pub __elision: libc::c_short, + pub __list: __pthread_list_t, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub union pthread_mutex_t { + pub __data: __pthread_mutex_s, + pub __size: [libc::c_char; 40], + pub __align: libc::c_long, +} +pub type u8_t = u_int8_t; +pub type u32_t = u_int32_t; +pub type s32_t = int32_t; +pub type frames_t = u32_t; +pub type log_level = libc::c_uint; +pub const lSDEBUG: log_level = 4; +pub const lDEBUG: log_level = 3; +pub const lINFO: log_level = 2; +pub const lWARN: log_level = 1; +pub const lERROR: log_level = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct buffer { + pub buf: *mut u8_t, + pub readp: *mut u8_t, + pub writep: *mut u8_t, + pub wrap: *mut u8_t, + pub size: size_t, + pub base_size: size_t, + pub mutex: pthread_mutex_t, +} +pub type output_state = libc::c_int; +pub const OUTPUT_START_AT: output_state = 5; +pub const OUTPUT_SKIP_FRAMES: output_state = 4; +pub const OUTPUT_PAUSE_FRAMES: output_state = 3; +pub const OUTPUT_RUNNING: output_state = 2; +pub const OUTPUT_BUFFER: output_state = 1; +pub const OUTPUT_STOPPED: output_state = 0; +pub const OUTPUT_OFF: output_state = -1; +pub type output_format = libc::c_uint; +pub const S16_LE: output_format = 3; +pub const S24_3LE: output_format = 2; +pub const S24_LE: output_format = 1; +pub const S32_LE: output_format = 0; +pub type fade_state = libc::c_uint; +pub const FADE_ACTIVE: fade_state = 2; +pub const FADE_DUE: fade_state = 1; +pub const FADE_INACTIVE: fade_state = 0; +pub type fade_dir = libc::c_uint; +pub const FADE_CROSS: fade_dir = 3; +pub const FADE_DOWN: fade_dir = 2; +pub const FADE_UP: fade_dir = 1; +pub type fade_mode = libc::c_uint; +pub const FADE_INOUT: fade_mode = 4; +pub const FADE_OUT: fade_mode = 3; +pub const FADE_IN: fade_mode = 2; +pub const FADE_CROSSFADE: fade_mode = 1; +pub const FADE_NONE: fade_mode = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct outputstate { + pub state: output_state, + pub format: output_format, + pub device: *const libc::c_char, + pub buffer: libc::c_uint, + pub period: libc::c_uint, + pub track_started: bool, + pub write_cb: Option libc::c_int>, + pub start_frames: libc::c_uint, + pub frames_played: libc::c_uint, + pub frames_played_dmp: libc::c_uint, + pub current_sample_rate: libc::c_uint, + pub supported_rates: [libc::c_uint; 18], + pub default_sample_rate: libc::c_uint, + pub error_opening: bool, + pub device_frames: libc::c_uint, + pub updated: u32_t, + pub track_start_time: u32_t, + pub current_replay_gain: u32_t, + pub c2rust_unnamed: C2RustUnnamed, + pub next_sample_rate: libc::c_uint, + pub track_start: *mut u8_t, + pub gainL: u32_t, + pub gainR: u32_t, + pub invert: bool, + pub next_replay_gain: u32_t, + pub threshold: libc::c_uint, + pub fade: fade_state, + pub fade_start: *mut u8_t, + pub fade_end: *mut u8_t, + pub fade_dir: fade_dir, + pub fade_mode: fade_mode, + pub fade_secs: libc::c_uint, + pub rate_delay: libc::c_uint, + pub delay_active: bool, + pub stop_time: u32_t, + pub idle_to: u32_t, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub union C2RustUnnamed { + pub pause_frames: u32_t, + pub skip_frames: u32_t, + pub start_at: u32_t, +} +/* * Squeezelite - lightweight headless squeezebox emulator * * (c) Adrian Smith 2012-2015, triode1@btinternet.com @@ -86,7 +192,7 @@ use crate::stdlib::strcat; * 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 @@ -97,926 +203,809 @@ use crate::stdlib::strcat; * */ // Common output function - -static mut loglevel: crate::squeezelite_h::log_level = crate::squeezelite_h::lERROR; +static mut loglevel: log_level = lERROR; #[no_mangle] - -pub static mut output: crate::squeezelite_h::outputstate = crate::squeezelite_h::outputstate { - state: crate::squeezelite_h::OUTPUT_STOPPED, - format: crate::squeezelite_h::S32_LE, - device: 0 as *const libc::c_char, - buffer: 0, - period: 0, - track_started: false, - write_cb: None, - start_frames: 0, - frames_played: 0, - frames_played_dmp: 0, - current_sample_rate: 0, - supported_rates: [0; 18], - default_sample_rate: 0, - error_opening: false, - device_frames: 0, - updated: 0, - track_start_time: 0, - current_replay_gain: 0, - c2rust_unnamed: crate::squeezelite_h::C2RustUnnamed_1 { pause_frames: 0 }, - next_sample_rate: 0, - track_start: 0 as *const crate::squeezelite_h::u8_t as *mut crate::squeezelite_h::u8_t, - gainL: 0, - gainR: 0, - invert: false, - next_replay_gain: 0, - threshold: 0, - fade: crate::squeezelite_h::FADE_INACTIVE, - fade_start: 0 as *const crate::squeezelite_h::u8_t as *mut crate::squeezelite_h::u8_t, - fade_end: 0 as *const crate::squeezelite_h::u8_t as *mut crate::squeezelite_h::u8_t, - fade_dir: 0 as crate::squeezelite_h::fade_dir, - fade_mode: crate::squeezelite_h::FADE_NONE, - fade_secs: 0, - rate_delay: 0, - delay_active: false, - stop_time: 0, - idle_to: 0, -}; - -static mut buf: crate::squeezelite_h::buffer = crate::squeezelite_h::buffer { - buf: 0 as *const crate::squeezelite_h::u8_t as *mut crate::squeezelite_h::u8_t, - readp: 0 as *const crate::squeezelite_h::u8_t as *mut crate::squeezelite_h::u8_t, - writep: 0 as *const crate::squeezelite_h::u8_t as *mut crate::squeezelite_h::u8_t, - wrap: 0 as *const crate::squeezelite_h::u8_t as *mut crate::squeezelite_h::u8_t, - size: 0, - base_size: 0, - 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, - }, - }, - }, -}; +pub static mut output: outputstate = + outputstate{state: OUTPUT_STOPPED, + format: S32_LE, + device: 0 as *const libc::c_char, + buffer: 0, + period: 0, + track_started: false, + write_cb: None, + start_frames: 0, + frames_played: 0, + frames_played_dmp: 0, + current_sample_rate: 0, + supported_rates: [0; 18], + default_sample_rate: 0, + error_opening: false, + device_frames: 0, + updated: 0, + track_start_time: 0, + current_replay_gain: 0, + c2rust_unnamed: C2RustUnnamed{pause_frames: 0,}, + next_sample_rate: 0, + track_start: 0 as *const u8_t as *mut u8_t, + gainL: 0, + gainR: 0, + invert: false, + next_replay_gain: 0, + threshold: 0, + fade: FADE_INACTIVE, + fade_start: 0 as *const u8_t as *mut u8_t, + fade_end: 0 as *const u8_t as *mut u8_t, + fade_dir: 0 as fade_dir, + fade_mode: FADE_NONE, + fade_secs: 0, + rate_delay: 0, + delay_active: false, + stop_time: 0, + idle_to: 0,}; +static mut buf: buffer = + buffer{buf: 0 as *const u8_t as *mut u8_t, + readp: 0 as *const u8_t as *mut u8_t, + writep: 0 as *const u8_t as *mut u8_t, + wrap: 0 as *const u8_t as *mut u8_t, + size: 0, + base_size: 0, + mutex: + pthread_mutex_t{__data: + __pthread_mutex_s{__lock: 0, + __count: 0, + __owner: 0, + __nusers: 0, + __kind: 0, + __spins: 0, + __elision: 0, + __list: + __pthread_list_t{__prev: + 0 + as + *const __pthread_internal_list + as + *mut __pthread_internal_list, + __next: + 0 + as + *const __pthread_internal_list + as + *mut __pthread_internal_list,},},},}; #[no_mangle] - -pub static mut outputbuf: *mut crate::squeezelite_h::buffer = - unsafe { &buf as *const crate::squeezelite_h::buffer as *mut crate::squeezelite_h::buffer }; +pub static mut outputbuf: *mut buffer = + unsafe { &buf as *const buffer as *mut buffer }; #[no_mangle] - -pub static mut silencebuf: *mut crate::squeezelite_h::u8_t = - 0 as *const crate::squeezelite_h::u8_t as *mut crate::squeezelite_h::u8_t; +pub static mut silencebuf: *mut u8_t = 0 as *const u8_t as *mut u8_t; #[no_mangle] - pub static mut user_rates: bool = 0 as libc::c_int != 0; // functions starting _* are called with mutex locked #[no_mangle] - -pub unsafe extern "C" fn _output_frames( - mut avail: crate::squeezelite_h::frames_t, -) -> crate::squeezelite_h::frames_t { - let mut frames: crate::squeezelite_h::frames_t = 0; - let mut size: crate::squeezelite_h::frames_t = 0; +pub unsafe extern "C" fn _output_frames(mut avail: frames_t) -> frames_t { + let mut frames: frames_t = 0; + let mut size: frames_t = 0; let mut silence: bool = false; - let mut cross_gain_in = 0 as libc::c_int; - let mut cross_gain_out = 0 as libc::c_int; - let mut cross_ptr = 0 as *mut crate::squeezelite_h::s32_t; - let mut gainL = if output.current_replay_gain != 0 { - crate::squeezelite_h::gain( - output.gainL as crate::squeezelite_h::s32_t, - output.current_replay_gain as crate::squeezelite_h::s32_t, - ) as libc::c_uint - } else { - output.gainL - } as crate::squeezelite_h::s32_t; - let mut gainR = if output.current_replay_gain != 0 { - crate::squeezelite_h::gain( - output.gainR as crate::squeezelite_h::s32_t, - output.current_replay_gain as crate::squeezelite_h::s32_t, - ) as libc::c_uint - } else { - output.gainR - } as crate::squeezelite_h::s32_t; - if output.invert { - gainL = -gainL; - gainR = -gainR - } + let mut cross_gain_in: s32_t = 0 as libc::c_int; + let mut cross_gain_out: s32_t = 0 as libc::c_int; + let mut cross_ptr: *mut s32_t = 0 as *mut s32_t; + let mut gainL: s32_t = + if output.current_replay_gain != 0 { + gain(output.gainL as s32_t, output.current_replay_gain as s32_t) + as libc::c_uint + } else { output.gainL } as s32_t; + let mut gainR: s32_t = + if output.current_replay_gain != 0 { + gain(output.gainR as s32_t, output.current_replay_gain as s32_t) + as libc::c_uint + } else { output.gainR } as s32_t; + if output.invert { gainL = -gainL; gainR = -gainR } frames = - crate::squeezelite_h::_buf_used(outputbuf).wrapping_div(8 as libc::c_int as libc::c_uint); + _buf_used(outputbuf).wrapping_div(8 as libc::c_int as libc::c_uint); silence = 0 as libc::c_int != 0; // start when threshold met - if output.state as libc::c_int == crate::squeezelite_h::OUTPUT_BUFFER as libc::c_int - && frames - > output - .threshold - .wrapping_mul(output.next_sample_rate) - .wrapping_div(10 as libc::c_int as libc::c_uint) - && frames > output.start_frames - { - output.state = crate::squeezelite_h::OUTPUT_RUNNING; - 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 start buffer frames: %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"_output_frames\x00")) - .as_ptr(), - 64 as libc::c_int, - frames, - ); + if output.state as libc::c_int == OUTPUT_BUFFER as libc::c_int && + frames > + output.threshold.wrapping_mul(output.next_sample_rate).wrapping_div(10 + as + libc::c_int + as + libc::c_uint) + && frames > output.start_frames { + output.state = OUTPUT_RUNNING; + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d start buffer frames: %u\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 15], + &[libc::c_char; 15]>(b"_output_frames\x00")).as_ptr(), + 64 as libc::c_int, frames); } - crate::src::slimproto::wake_controller(); + wake_controller(); } // skip ahead - consume outputbuf but play nothing - if output.state as libc::c_int == crate::squeezelite_h::OUTPUT_SKIP_FRAMES as libc::c_int { + if output.state as libc::c_int == OUTPUT_SKIP_FRAMES as libc::c_int { if frames > 0 as libc::c_int as libc::c_uint { - let mut skip = if frames < output.c2rust_unnamed.skip_frames { - frames - } else { - output.c2rust_unnamed.skip_frames - }; - 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 skip %u of %u frames\n\x00" as *const u8 as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 15], &[libc::c_char; 15]>( - b"_output_frames\x00", - )) - .as_ptr(), - 72 as libc::c_int, - skip, - output.c2rust_unnamed.skip_frames, - ); + let mut skip: frames_t = + if frames < output.c2rust_unnamed.skip_frames { + frames + } else { output.c2rust_unnamed.skip_frames }; + if loglevel as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d skip %u of %u frames\n\x00" as *const u8 + as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 15], + &[libc::c_char; 15]>(b"_output_frames\x00")).as_ptr(), + 72 as libc::c_int, skip, + output.c2rust_unnamed.skip_frames); } - frames = (frames as libc::c_uint).wrapping_sub(skip) as crate::squeezelite_h::frames_t - as crate::squeezelite_h::frames_t; + frames = + (frames as libc::c_uint).wrapping_sub(skip) as frames_t as + frames_t; output.frames_played = output.frames_played.wrapping_add(skip); while skip > 0 as libc::c_int as libc::c_uint { - let mut cont_frames = if skip - < crate::src::buffer::_buf_cont_read(outputbuf) - .wrapping_div(8 as libc::c_int as libc::c_uint) - { - skip - } else { - crate::src::buffer::_buf_cont_read(outputbuf) - .wrapping_div(8 as libc::c_int as libc::c_uint) - }; - skip = (skip as libc::c_uint).wrapping_sub(cont_frames) - as crate::squeezelite_h::frames_t - as crate::squeezelite_h::frames_t; - crate::src::buffer::_buf_inc_readp( - outputbuf, - cont_frames.wrapping_mul(8 as libc::c_int as libc::c_uint), - ); + let mut cont_frames: frames_t = + if skip < + _buf_cont_read(outputbuf).wrapping_div(8 as + libc::c_int + as + libc::c_uint) + { + skip + } else { + _buf_cont_read(outputbuf).wrapping_div(8 as + libc::c_int + as + libc::c_uint) + }; + skip = + (skip as libc::c_uint).wrapping_sub(cont_frames) as + frames_t as frames_t; + _buf_inc_readp(outputbuf, + cont_frames.wrapping_mul(8 as libc::c_int as + libc::c_uint)); } } - output.state = crate::squeezelite_h::OUTPUT_RUNNING + output.state = OUTPUT_RUNNING } // pause frames - play silence for required frames - if output.state as libc::c_int == crate::squeezelite_h::OUTPUT_PAUSE_FRAMES 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 pause %u frames\n\x00" as *const u8 as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 15], &[libc::c_char; 15]>(b"_output_frames\x00")) - .as_ptr(), - 86 as libc::c_int, - output.c2rust_unnamed.pause_frames, - ); + if output.state as libc::c_int == OUTPUT_PAUSE_FRAMES as libc::c_int { + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d pause %u frames\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 15], + &[libc::c_char; 15]>(b"_output_frames\x00")).as_ptr(), + 86 as libc::c_int, output.c2rust_unnamed.pause_frames); } - if output.c2rust_unnamed.pause_frames == 0 as libc::c_int as libc::c_uint { - output.state = crate::squeezelite_h::OUTPUT_RUNNING + if output.c2rust_unnamed.pause_frames == + 0 as libc::c_int as libc::c_uint { + output.state = OUTPUT_RUNNING } else { silence = 1 as libc::c_int != 0; - frames = if avail < output.c2rust_unnamed.pause_frames { - avail - } else { - output.c2rust_unnamed.pause_frames - }; - frames = if frames < 2048 as libc::c_int as libc::c_uint { - frames - } else { - 2048 as libc::c_int as libc::c_uint - }; + frames = + if avail < output.c2rust_unnamed.pause_frames { + avail + } else { output.c2rust_unnamed.pause_frames }; + frames = + if frames < 2048 as libc::c_int as libc::c_uint { + frames + } else { 2048 as libc::c_int as libc::c_uint }; output.c2rust_unnamed.pause_frames = - (output.c2rust_unnamed.pause_frames as libc::c_uint).wrapping_sub(frames) - as crate::squeezelite_h::u32_t as crate::squeezelite_h::u32_t + (output.c2rust_unnamed.pause_frames as + libc::c_uint).wrapping_sub(frames) as u32_t as u32_t } } // start at - play silence until jiffies reached - if output.state as libc::c_int == crate::squeezelite_h::OUTPUT_START_AT as libc::c_int { - let mut now = crate::src::utils::gettime_ms(); - if now >= output.c2rust_unnamed.start_at - || output.c2rust_unnamed.start_at - > now.wrapping_add(10000 as libc::c_int as libc::c_uint) - { - output.state = crate::squeezelite_h::OUTPUT_RUNNING + if output.state as libc::c_int == OUTPUT_START_AT as libc::c_int { + let mut now: u32_t = gettime_ms(); + if now >= output.c2rust_unnamed.start_at || + output.c2rust_unnamed.start_at > + now.wrapping_add(10000 as libc::c_int as libc::c_uint) { + output.state = OUTPUT_RUNNING } else { - let mut delta_frames = output - .c2rust_unnamed - .start_at - .wrapping_sub(now) - .wrapping_mul(output.current_sample_rate) - .wrapping_div(1000 as libc::c_int as libc::c_uint); + let mut delta_frames: u32_t = + output.c2rust_unnamed.start_at.wrapping_sub(now).wrapping_mul(output.current_sample_rate).wrapping_div(1000 + as + libc::c_int + as + libc::c_uint); silence = 1 as libc::c_int != 0; - frames = if avail < delta_frames { - avail - } else { - delta_frames - }; - frames = if frames < 2048 as libc::c_int as libc::c_uint { - frames - } else { - 2048 as libc::c_int as libc::c_uint - } + frames = if avail < delta_frames { avail } else { delta_frames }; + frames = + if frames < 2048 as libc::c_int as libc::c_uint { + frames + } else { 2048 as libc::c_int as libc::c_uint } } } // play silence if buffering or no frames - if output.state as libc::c_int <= crate::squeezelite_h::OUTPUT_BUFFER as libc::c_int - || frames == 0 as libc::c_int as libc::c_uint - { + if output.state as libc::c_int <= OUTPUT_BUFFER as libc::c_int || + frames == 0 as libc::c_int as libc::c_uint { silence = 1 as libc::c_int != 0; - frames = if avail < 2048 as libc::c_int as libc::c_uint { - avail - } else { - 2048 as libc::c_int as libc::c_uint - } + frames = + if avail < 2048 as libc::c_int as libc::c_uint { + avail + } else { 2048 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 avail: %d frames: %d silence: %d\n\x00" as *const u8 as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 15], &[libc::c_char; 15]>(b"_output_frames\x00")) - .as_ptr(), - 116 as libc::c_int, - avail, - frames, - silence as libc::c_int, - ); + if loglevel as libc::c_uint >= lSDEBUG as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d avail: %d frames: %d silence: %d\n\x00" as + *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 15], + &[libc::c_char; 15]>(b"_output_frames\x00")).as_ptr(), + 116 as libc::c_int, avail, frames, silence as libc::c_int); } frames = if frames < avail { frames } else { avail }; size = frames; while size > 0 as libc::c_int as libc::c_uint { - let mut out_frames: crate::squeezelite_h::frames_t = 0; - let mut cont_frames_0 = crate::src::buffer::_buf_cont_read(outputbuf) - .wrapping_div(8 as libc::c_int as libc::c_uint); + let mut out_frames: frames_t = 0; + let mut cont_frames_0: frames_t = + _buf_cont_read(outputbuf).wrapping_div(8 as libc::c_int as + libc::c_uint); let mut wrote: libc::c_int = 0; if !output.track_start.is_null() && !silence { if output.track_start == (*outputbuf).readp { - let mut delay = 0 as libc::c_int as libc::c_uint; + let mut delay: libc::c_uint = + 0 as libc::c_int as libc::c_uint; if output.current_sample_rate != output.next_sample_rate { delay = output.rate_delay } - frames = (frames as libc::c_uint).wrapping_sub(size) - as crate::squeezelite_h::frames_t - as crate::squeezelite_h::frames_t; + frames = + (frames as libc::c_uint).wrapping_sub(size) as frames_t as + frames_t; // add silence delay in two halves, before and after track start on rate or pcm-dop change if delay != 0 { - output.state = crate::squeezelite_h::OUTPUT_PAUSE_FRAMES; // first delay - don't process track start + output.state = + OUTPUT_PAUSE_FRAMES; // first delay - don't process track start if !output.delay_active { - output.c2rust_unnamed.pause_frames = output - .current_sample_rate - .wrapping_mul(delay) - .wrapping_div(2000 as libc::c_int as libc::c_uint); + output.c2rust_unnamed.pause_frames = + output.current_sample_rate.wrapping_mul(delay).wrapping_div(2000 + as + libc::c_int + as + libc::c_uint); output.delay_active = 1 as libc::c_int != 0; - break; + break ; } else { - output.c2rust_unnamed.pause_frames = output - .next_sample_rate - .wrapping_mul(delay) - .wrapping_div(2000 as libc::c_int as libc::c_uint); + output.c2rust_unnamed.pause_frames = + output.next_sample_rate.wrapping_mul(delay).wrapping_div(2000 + as + libc::c_int + as + libc::c_uint); output.delay_active = 0 as libc::c_int != 0 // second delay - process track start } } - 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 track start sample rate: %u replay_gain: %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"_output_frames\x00", - )) - .as_ptr(), - 149 as libc::c_int, - output.next_sample_rate, - output.next_replay_gain, - ); + if loglevel as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d track start sample rate: %u replay_gain: %u\n\x00" + as *const u8 as *const libc::c_char, + logtime(), + (*::std::mem::transmute::<&[u8; 15], + &[libc::c_char; 15]>(b"_output_frames\x00")).as_ptr(), + 149 as libc::c_int, output.next_sample_rate, + output.next_replay_gain); } output.frames_played = 0 as libc::c_int as libc::c_uint; output.track_started = 1 as libc::c_int != 0; - output.track_start_time = crate::src::utils::gettime_ms(); + output.track_start_time = gettime_ms(); output.current_sample_rate = output.next_sample_rate; - if output.fade as libc::c_uint - == crate::squeezelite_h::FADE_INACTIVE as libc::c_int as libc::c_uint - || output.fade_mode as libc::c_uint - != crate::squeezelite_h::FADE_CROSSFADE as libc::c_int as libc::c_uint - { + if output.fade as libc::c_uint == + FADE_INACTIVE as libc::c_int as libc::c_uint || + output.fade_mode as libc::c_uint != + FADE_CROSSFADE as libc::c_int as libc::c_uint { output.current_replay_gain = output.next_replay_gain } - output.track_start = 0 as *mut crate::squeezelite_h::u8_t; - break; + output.track_start = 0 as *mut u8_t; + break ; } else if output.track_start > (*outputbuf).readp { // reduce cont_frames so we find the next track start at beginning of next chunk - cont_frames_0 = if (cont_frames_0 as libc::c_long) - < output.track_start.wrapping_offset_from((*outputbuf).readp) as libc::c_long - / 8 as libc::c_int as libc::c_long - { - cont_frames_0 as libc::c_long - } else { - (output.track_start.wrapping_offset_from((*outputbuf).readp) as libc::c_long) - / 8 as libc::c_int as libc::c_long - } as crate::squeezelite_h::frames_t + cont_frames_0 = + if (cont_frames_0 as libc::c_long) < + output.track_start.wrapping_offset_from((*outputbuf).readp) + as libc::c_long / + 8 as libc::c_int as libc::c_long { + cont_frames_0 as libc::c_long + } else { + (output.track_start.wrapping_offset_from((*outputbuf).readp) + as libc::c_long) / + 8 as libc::c_int as libc::c_long + } as frames_t } } if output.fade as libc::c_uint != 0 && !silence { - if output.fade as libc::c_uint - == crate::squeezelite_h::FADE_DUE as libc::c_int as libc::c_uint - { + if output.fade as libc::c_uint == + FADE_DUE as libc::c_int as libc::c_uint { if output.fade_start == (*outputbuf).readp { - 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 fade start reached\n\x00" as *const u8 - as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 15], &[libc::c_char; 15]>( - b"_output_frames\x00", - )) - .as_ptr(), - 177 as libc::c_int, - ); + if loglevel as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d fade start reached\n\x00" as + *const u8 as *const libc::c_char, + logtime(), + (*::std::mem::transmute::<&[u8; 15], + &[libc::c_char; 15]>(b"_output_frames\x00")).as_ptr(), + 177 as libc::c_int); } - output.fade = crate::squeezelite_h::FADE_ACTIVE + output.fade = FADE_ACTIVE } else if output.fade_start > (*outputbuf).readp { - cont_frames_0 = if (cont_frames_0 as libc::c_long) - < output.fade_start.wrapping_offset_from((*outputbuf).readp) as libc::c_long - / 8 as libc::c_int as libc::c_long - { - cont_frames_0 as libc::c_long - } else { - (output.fade_start.wrapping_offset_from((*outputbuf).readp) as libc::c_long) - / 8 as libc::c_int as libc::c_long - } as crate::squeezelite_h::frames_t + cont_frames_0 = + if (cont_frames_0 as libc::c_long) < + output.fade_start.wrapping_offset_from((*outputbuf).readp) + as libc::c_long / + 8 as libc::c_int as libc::c_long { + cont_frames_0 as libc::c_long + } else { + (output.fade_start.wrapping_offset_from((*outputbuf).readp) + as libc::c_long) / + 8 as libc::c_int as libc::c_long + } as frames_t } } - if output.fade as libc::c_uint - == crate::squeezelite_h::FADE_ACTIVE as libc::c_int as libc::c_uint - { + if output.fade as libc::c_uint == + FADE_ACTIVE as libc::c_int as libc::c_uint { // find position within fade - let mut cur_f = if (*outputbuf).readp >= output.fade_start { - ((*outputbuf).readp.wrapping_offset_from(output.fade_start) as libc::c_long) - / 8 as libc::c_int as libc::c_long - } else { - ((*outputbuf) - .readp - .offset((*outputbuf).size as isize) - .wrapping_offset_from(output.fade_start) - as libc::c_long) - / 8 as libc::c_int as libc::c_long - } as crate::squeezelite_h::frames_t; - let mut dur_f = if output.fade_end >= output.fade_start { - (output.fade_end.wrapping_offset_from(output.fade_start) as libc::c_long) - / 8 as libc::c_int as libc::c_long - } else { - (output - .fade_end - .offset((*outputbuf).size as isize) - .wrapping_offset_from(output.fade_start) - as libc::c_long) - / 8 as libc::c_int as libc::c_long - } as crate::squeezelite_h::frames_t; + let mut cur_f: frames_t = + if (*outputbuf).readp >= output.fade_start { + ((*outputbuf).readp.wrapping_offset_from(output.fade_start) + as libc::c_long) / + 8 as libc::c_int as libc::c_long + } else { + ((*outputbuf).readp.offset((*outputbuf).size as + isize).wrapping_offset_from(output.fade_start) + as libc::c_long) / + 8 as libc::c_int as libc::c_long + } as frames_t; + let mut dur_f: frames_t = + if output.fade_end >= output.fade_start { + (output.fade_end.wrapping_offset_from(output.fade_start) + as libc::c_long) / + 8 as libc::c_int as libc::c_long + } else { + (output.fade_end.offset((*outputbuf).size as + isize).wrapping_offset_from(output.fade_start) + as libc::c_long) / + 8 as libc::c_int as libc::c_long + } as frames_t; if cur_f >= dur_f { - if output.fade_mode as libc::c_uint - == crate::squeezelite_h::FADE_INOUT as libc::c_int as libc::c_uint - && output.fade_dir as libc::c_uint - == crate::squeezelite_h::FADE_DOWN 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 fade down complete, starting fade up\n\x00" as *const u8 - as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 15], &[libc::c_char; 15]>( - b"_output_frames\x00", - )) - .as_ptr(), - 191 as libc::c_int, - ); + if output.fade_mode as libc::c_uint == + FADE_INOUT as libc::c_int as libc::c_uint && + output.fade_dir as libc::c_uint == + FADE_DOWN as libc::c_int as libc::c_uint { + if loglevel as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d fade down complete, starting fade up\n\x00" + as *const u8 as *const libc::c_char, + logtime(), + (*::std::mem::transmute::<&[u8; 15], + &[libc::c_char; 15]>(b"_output_frames\x00")).as_ptr(), + 191 as libc::c_int); } - output.fade_dir = crate::squeezelite_h::FADE_UP; + output.fade_dir = FADE_UP; output.fade_start = (*outputbuf).readp; - output.fade_end = (*outputbuf) - .readp - .offset(dur_f.wrapping_mul(8 as libc::c_int as libc::c_uint) as isize); + output.fade_end = + (*outputbuf).readp.offset(dur_f.wrapping_mul(8 as + libc::c_int + as + libc::c_uint) + as isize); if output.fade_end >= (*outputbuf).wrap { - output.fade_end = output.fade_end.offset(-((*outputbuf).size as isize)) + output.fade_end = + output.fade_end.offset(-((*outputbuf).size as + isize)) } - cur_f = 0 as libc::c_int as crate::squeezelite_h::frames_t - } else if output.fade_mode as libc::c_uint - == crate::squeezelite_h::FADE_CROSSFADE 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 crossfade complete\n\x00" as *const u8 - as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 15], &[libc::c_char; 15]>( - b"_output_frames\x00", - )) - .as_ptr(), - 200 as libc::c_int, - ); + cur_f = 0 as libc::c_int as frames_t + } else if output.fade_mode as libc::c_uint == + FADE_CROSSFADE as libc::c_int as + libc::c_uint { + if loglevel as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d crossfade complete\n\x00" as + *const u8 as *const libc::c_char, + logtime(), + (*::std::mem::transmute::<&[u8; 15], + &[libc::c_char; 15]>(b"_output_frames\x00")).as_ptr(), + 200 as libc::c_int); } - if crate::squeezelite_h::_buf_used(outputbuf) - >= dur_f.wrapping_mul(8 as libc::c_int as libc::c_uint) - { - crate::src::buffer::_buf_inc_readp( - outputbuf, - dur_f.wrapping_mul(8 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 skipped crossfaded start\n\x00" as *const u8 - as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 15], &[libc::c_char; 15]>( - b"_output_frames\x00", - )) - .as_ptr(), - 203 as libc::c_int, - ); + if _buf_used(outputbuf) >= + dur_f.wrapping_mul(8 as libc::c_int as + libc::c_uint) { + _buf_inc_readp(outputbuf, + dur_f.wrapping_mul(8 as libc::c_int + as + libc::c_uint)); + if loglevel as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d skipped crossfaded start\n\x00" + as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 15], + &[libc::c_char; 15]>(b"_output_frames\x00")).as_ptr(), + 203 as libc::c_int); } - } 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 unable to skip crossfaded start\n\x00" as *const u8 - as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 15], &[libc::c_char; 15]>( - b"_output_frames\x00", - )) - .as_ptr(), - 205 as libc::c_int, - ); + } else if loglevel as libc::c_uint >= + lWARN as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d unable to skip crossfaded start\n\x00" + as *const u8 as *const libc::c_char, + logtime(), + (*::std::mem::transmute::<&[u8; 15], + &[libc::c_char; 15]>(b"_output_frames\x00")).as_ptr(), + 205 as libc::c_int); } - output.fade = crate::squeezelite_h::FADE_INACTIVE; + output.fade = FADE_INACTIVE; output.current_replay_gain = output.next_replay_gain } 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 fade complete\n\x00" as *const u8 as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 15], &[libc::c_char; 15]>( - b"_output_frames\x00", - )) - .as_ptr(), - 210 as libc::c_int, - ); + if loglevel as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d fade complete\n\x00" as + *const u8 as *const libc::c_char, + logtime(), + (*::std::mem::transmute::<&[u8; 15], + &[libc::c_char; 15]>(b"_output_frames\x00")).as_ptr(), + 210 as libc::c_int); } - output.fade = crate::squeezelite_h::FADE_INACTIVE + output.fade = FADE_INACTIVE } } // if fade in progress set fade gain, ensure cont_frames reduced so we get to end of fade at start of chunk if output.fade as u64 != 0 { if output.fade_end > (*outputbuf).readp { - cont_frames_0 = if (cont_frames_0 as libc::c_long) - < output.fade_end.wrapping_offset_from((*outputbuf).readp) - as libc::c_long - / 8 as libc::c_int as libc::c_long - { - cont_frames_0 as libc::c_long - } else { - (output.fade_end.wrapping_offset_from((*outputbuf).readp) - as libc::c_long) - / 8 as libc::c_int as libc::c_long - } as crate::squeezelite_h::frames_t + cont_frames_0 = + if (cont_frames_0 as libc::c_long) < + output.fade_end.wrapping_offset_from((*outputbuf).readp) + as libc::c_long / + 8 as libc::c_int as libc::c_long { + cont_frames_0 as libc::c_long + } else { + (output.fade_end.wrapping_offset_from((*outputbuf).readp) + as libc::c_long) / + 8 as libc::c_int as libc::c_long + } as frames_t } - if output.fade_dir as libc::c_uint - == crate::squeezelite_h::FADE_UP as libc::c_int as libc::c_uint - || output.fade_dir as libc::c_uint - == crate::squeezelite_h::FADE_DOWN as libc::c_int as libc::c_uint - { + if output.fade_dir as libc::c_uint == + FADE_UP as libc::c_int as libc::c_uint || + output.fade_dir as libc::c_uint == + FADE_DOWN as libc::c_int as libc::c_uint { // fade in, in-out, out handled via altering standard gain - let mut fade_gain: crate::squeezelite_h::s32_t = 0; - if output.fade_dir as libc::c_uint - == crate::squeezelite_h::FADE_DOWN as libc::c_int as libc::c_uint - { + let mut fade_gain: s32_t = 0; + if output.fade_dir as libc::c_uint == + FADE_DOWN as libc::c_int as libc::c_uint { cur_f = dur_f.wrapping_sub(cur_f) } - fade_gain = crate::squeezelite_h::to_gain( - cur_f as libc::c_float / dur_f as libc::c_float, - ); - gainL = crate::squeezelite_h::gain(gainL, fade_gain); - gainR = crate::squeezelite_h::gain(gainR, fade_gain); - if output.invert { - gainL = -gainL; - gainR = -gainR - } + fade_gain = + to_gain(cur_f as libc::c_float / + dur_f as libc::c_float); + gainL = gain(gainL, fade_gain); + gainR = gain(gainR, fade_gain); + if output.invert { gainL = -gainL; gainR = -gainR } } - if output.fade_dir as libc::c_uint - == crate::squeezelite_h::FADE_CROSS as libc::c_int as libc::c_uint - { + if output.fade_dir as libc::c_uint == + FADE_CROSS as libc::c_int as libc::c_uint { // cross fade requires special treatment - performed later based on these values - // support different replay gain for old and new track by retaining old value until crossfade completes - if crate::squeezelite_h::_buf_used(outputbuf) - .wrapping_div(8 as libc::c_int as libc::c_uint) - > dur_f.wrapping_add(size) - { - cross_gain_in = crate::squeezelite_h::to_gain( - cur_f as libc::c_float / dur_f as libc::c_float, - ); - cross_gain_out = 0x10000 as libc::c_int - cross_gain_in; + // support different replay gain for old and new track by retaining old value until crossfade completes + if _buf_used(outputbuf).wrapping_div(8 as libc::c_int + as + libc::c_uint) + > dur_f.wrapping_add(size) { + cross_gain_in = + to_gain(cur_f as libc::c_float / + dur_f as libc::c_float); + cross_gain_out = + 0x10000 as libc::c_int - cross_gain_in; if output.current_replay_gain != 0 { - cross_gain_out = crate::squeezelite_h::gain( - cross_gain_out, - output.current_replay_gain as crate::squeezelite_h::s32_t, - ) + cross_gain_out = + gain(cross_gain_out, + output.current_replay_gain as s32_t) } if output.next_replay_gain != 0 { - cross_gain_in = crate::squeezelite_h::gain( - cross_gain_in, - output.next_replay_gain as crate::squeezelite_h::s32_t, - ) + cross_gain_in = + gain(cross_gain_in, + output.next_replay_gain as s32_t) } - gainL = output.gainL as crate::squeezelite_h::s32_t; - gainR = output.gainR as crate::squeezelite_h::s32_t; + gainL = output.gainL as s32_t; + gainR = output.gainR as s32_t; if output.invert { gainL = -gainL; gainR = -gainR } cross_ptr = - output - .fade_end - .offset(cur_f.wrapping_mul(8 as libc::c_int as libc::c_uint) - as isize) - as *mut crate::squeezelite_h::s32_t + output.fade_end.offset(cur_f.wrapping_mul(8 as + libc::c_int + as + libc::c_uint) + as isize) as + *mut s32_t } 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 unable to continue crossfade - too few samples\n\x00" - as *const u8 - as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 15], &[libc::c_char; 15]>( - b"_output_frames\x00", - )) - .as_ptr(), - 247 as libc::c_int, - ); + if loglevel as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d unable to continue crossfade - too few samples\n\x00" + as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 15], + &[libc::c_char; 15]>(b"_output_frames\x00")).as_ptr(), + 247 as libc::c_int); } - output.fade = crate::squeezelite_h::FADE_INACTIVE + output.fade = FADE_INACTIVE } } } } } - out_frames = if !silence { - if size < cont_frames_0 { - size - } else { - cont_frames_0 - } - } else { - size - }; - wrote = output.write_cb.expect("non-null function pointer")( - out_frames, - silence, - gainL, - gainR, - cross_gain_in, - cross_gain_out, - &mut cross_ptr, - ); - if wrote <= 0 as libc::c_int { - frames = (frames as libc::c_uint).wrapping_sub(size) as crate::squeezelite_h::frames_t - as crate::squeezelite_h::frames_t; - break; - } else { - out_frames = wrote as crate::squeezelite_h::frames_t; - size = (size as libc::c_uint).wrapping_sub(out_frames) as crate::squeezelite_h::frames_t - as crate::squeezelite_h::frames_t; + out_frames = if !silence { - crate::src::buffer::_buf_inc_readp( - outputbuf, - out_frames.wrapping_mul(8 as libc::c_int as libc::c_uint), - ); - output.frames_played = output.frames_played.wrapping_add(out_frames) + if size < cont_frames_0 { size } else { cont_frames_0 } + } else { size }; + wrote = + output.write_cb.expect("non-null function pointer")(out_frames, + silence, + gainL, gainR, + cross_gain_in, + cross_gain_out, + &mut cross_ptr); + if wrote <= 0 as libc::c_int { + frames = + (frames as libc::c_uint).wrapping_sub(size) as frames_t as + frames_t; + break ; + } else { + out_frames = wrote as frames_t; + size = + (size as libc::c_uint).wrapping_sub(out_frames) as frames_t as + frames_t; + if !silence { + _buf_inc_readp(outputbuf, + out_frames.wrapping_mul(8 as libc::c_int as + libc::c_uint)); + output.frames_played = + output.frames_played.wrapping_add(out_frames) } } } - 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; 15], &[libc::c_char; 15]>(b"_output_frames\x00")) - .as_ptr(), - 276 as libc::c_int, - frames, - ); + if loglevel as libc::c_uint >= lSDEBUG as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d wrote %u frames\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 15], + &[libc::c_char; 15]>(b"_output_frames\x00")).as_ptr(), + 276 as libc::c_int, frames); } return frames; } // _* called with mutex locked #[no_mangle] - pub unsafe extern "C" fn _checkfade(mut start: bool) { - let mut bytes: crate::squeezelite_h::frames_t = 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 fade mode: %u duration: %u %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"_checkfade\x00")).as_ptr(), - 284 as libc::c_int, - output.fade_mode as libc::c_uint, - output.fade_secs, - if start as libc::c_int != 0 { - b"track-start\x00" as *const u8 as *const libc::c_char - } else { - b"track-end\x00" as *const u8 as *const libc::c_char - }, - ); + let mut bytes: frames_t = 0; + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d fade mode: %u duration: %u %s\n\x00" as *const u8 + as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 11], + &[libc::c_char; 11]>(b"_checkfade\x00")).as_ptr(), + 284 as libc::c_int, output.fade_mode as libc::c_uint, + output.fade_secs, + if start as libc::c_int != 0 { + b"track-start\x00" as *const u8 as *const libc::c_char + } else { + b"track-end\x00" as *const u8 as *const libc::c_char + }); } - bytes = output - .next_sample_rate - .wrapping_mul(8 as libc::c_int as libc::c_uint) - .wrapping_mul(output.fade_secs); - if output.fade_mode as libc::c_uint - == crate::squeezelite_h::FADE_INOUT as libc::c_int as libc::c_uint - { + bytes = + output.next_sample_rate.wrapping_mul(8 as libc::c_int as + libc::c_uint).wrapping_mul(output.fade_secs); + if output.fade_mode as libc::c_uint == + FADE_INOUT as libc::c_int as libc::c_uint { /* align on a frame boundary */ - bytes = bytes - .wrapping_div(2 as libc::c_int as libc::c_uint) - .wrapping_div(8 as libc::c_int as libc::c_uint) - .wrapping_mul(8 as libc::c_int as libc::c_uint) + bytes = + bytes.wrapping_div(2 as libc::c_int as + libc::c_uint).wrapping_div(8 as libc::c_int + as + libc::c_uint).wrapping_mul(8 + as + libc::c_int + as + libc::c_uint) } // shorter than full buffer otherwise start and end align - if start as libc::c_int != 0 - && (output.fade_mode as libc::c_uint - == crate::squeezelite_h::FADE_IN as libc::c_int as libc::c_uint - || output.fade_mode as libc::c_uint - == crate::squeezelite_h::FADE_INOUT as libc::c_int as libc::c_uint - && crate::squeezelite_h::_buf_used(outputbuf) == 0 as libc::c_int as libc::c_uint) - { - bytes = if (bytes as libc::c_ulong) - < (*outputbuf) - .size - .wrapping_sub(8 as libc::c_int as libc::c_ulong) - { - bytes as libc::c_ulong - } else { - (*outputbuf) - .size - .wrapping_sub(8 as libc::c_int as libc::c_ulong) - } as crate::squeezelite_h::frames_t; // max of current remaining samples from previous track - 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 fade IN: %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"_checkfade\x00")) - .as_ptr(), - 294 as libc::c_int, - bytes.wrapping_div(8 as libc::c_int as libc::c_uint), - ); // max of 90% of outputbuf as we consume additional buffer during crossfade + if start as libc::c_int != 0 && + (output.fade_mode as libc::c_uint == + FADE_IN as libc::c_int as libc::c_uint || + output.fade_mode as libc::c_uint == + FADE_INOUT as libc::c_int as libc::c_uint && + _buf_used(outputbuf) == 0 as libc::c_int as libc::c_uint) + { + bytes = + if (bytes as libc::c_ulong) < + (*outputbuf).size.wrapping_sub(8 as libc::c_int as + libc::c_ulong) { + bytes as libc::c_ulong + } else { + (*outputbuf).size.wrapping_sub(8 as libc::c_int as + libc::c_ulong) + } as + frames_t; // max of current remaining samples from previous track + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d fade IN: %u frames\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 11], + &[libc::c_char; 11]>(b"_checkfade\x00")).as_ptr(), + 294 as libc::c_int, + bytes.wrapping_div(8 as libc::c_int as + libc::c_uint)); // max of 90% of outputbuf as we consume additional buffer during crossfade } - output.fade = crate::squeezelite_h::FADE_DUE; - output.fade_dir = crate::squeezelite_h::FADE_UP; + output.fade = FADE_DUE; + output.fade_dir = FADE_UP; output.fade_start = (*outputbuf).writep; output.fade_end = output.fade_start.offset(bytes as isize); if output.fade_end >= (*outputbuf).wrap { - output.fade_end = output.fade_end.offset(-((*outputbuf).size as isize)) + output.fade_end = + output.fade_end.offset(-((*outputbuf).size as isize)) } } - if !start - && (output.fade_mode as libc::c_uint - == crate::squeezelite_h::FADE_OUT as libc::c_int as libc::c_uint - || output.fade_mode as libc::c_uint - == crate::squeezelite_h::FADE_INOUT as libc::c_int as libc::c_uint) - { - bytes = if crate::squeezelite_h::_buf_used(outputbuf) < bytes { - crate::squeezelite_h::_buf_used(outputbuf) - } else { - bytes - }; - 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 fade %s: %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"_checkfade\x00")) - .as_ptr(), - 306 as libc::c_int, - if output.fade_mode as libc::c_uint - == crate::squeezelite_h::FADE_INOUT as libc::c_int as libc::c_uint - { - b"IN-OUT\x00" as *const u8 as *const libc::c_char - } else { - b"OUT\x00" as *const u8 as *const libc::c_char - }, - bytes.wrapping_div(8 as libc::c_int as libc::c_uint), - ); + if !start && + (output.fade_mode as libc::c_uint == + FADE_OUT as libc::c_int as libc::c_uint || + output.fade_mode as libc::c_uint == + FADE_INOUT as libc::c_int as libc::c_uint) { + bytes = + if _buf_used(outputbuf) < bytes { + _buf_used(outputbuf) + } else { bytes }; + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d fade %s: %u frames\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 11], + &[libc::c_char; 11]>(b"_checkfade\x00")).as_ptr(), + 306 as libc::c_int, + if output.fade_mode as libc::c_uint == + FADE_INOUT as libc::c_int as libc::c_uint { + b"IN-OUT\x00" as *const u8 as *const libc::c_char + } else { + b"OUT\x00" as *const u8 as *const libc::c_char + }, bytes.wrapping_div(8 as libc::c_int as libc::c_uint)); } - output.fade = crate::squeezelite_h::FADE_DUE; - output.fade_dir = crate::squeezelite_h::FADE_DOWN; + output.fade = FADE_DUE; + output.fade_dir = FADE_DOWN; output.fade_start = (*outputbuf).writep.offset(-(bytes as isize)); if output.fade_start < (*outputbuf).buf { - output.fade_start = output.fade_start.offset((*outputbuf).size as isize) + output.fade_start = + output.fade_start.offset((*outputbuf).size as isize) } output.fade_end = (*outputbuf).writep } - if start as libc::c_int != 0 - && output.fade_mode as libc::c_uint - == crate::squeezelite_h::FADE_CROSSFADE as libc::c_int as libc::c_uint - { - if crate::squeezelite_h::_buf_used(outputbuf) != 0 as libc::c_int as libc::c_uint { + if start as libc::c_int != 0 && + output.fade_mode as libc::c_uint == + FADE_CROSSFADE as libc::c_int as libc::c_uint { + if _buf_used(outputbuf) != 0 as libc::c_int as libc::c_uint { if output.next_sample_rate != output.current_sample_rate { - 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 crossfade disabled as sample rates differ\n\x00" as *const u8 - as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 11], &[libc::c_char; 11]>( - b"_checkfade\x00", - )) - .as_ptr(), - 319 as libc::c_int, - ); + if loglevel as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d crossfade disabled as sample rates differ\n\x00" + as *const u8 as *const libc::c_char, + logtime(), + (*::std::mem::transmute::<&[u8; 11], + &[libc::c_char; 11]>(b"_checkfade\x00")).as_ptr(), + 319 as libc::c_int); } - return; + return } - bytes = if bytes < crate::squeezelite_h::_buf_used(outputbuf) { - bytes - } else { - crate::squeezelite_h::_buf_used(outputbuf) - }; - bytes = if bytes - < ((*outputbuf).size as libc::c_double * 0.9f64) as crate::squeezelite_h::frames_t - { - bytes - } else { - ((*outputbuf).size as libc::c_double * 0.9f64) as crate::squeezelite_h::frames_t - }; - 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 CROSSFADE: %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"_checkfade\x00")) - .as_ptr(), - 324 as libc::c_int, - bytes.wrapping_div(8 as libc::c_int as libc::c_uint), - ); + bytes = + if bytes < _buf_used(outputbuf) { + bytes + } else { _buf_used(outputbuf) }; + bytes = + if bytes < + ((*outputbuf).size as libc::c_double * 0.9f64) as + frames_t { + bytes + } else { + ((*outputbuf).size as libc::c_double * 0.9f64) as frames_t + }; + if loglevel as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d CROSSFADE: %u frames\n\x00" as *const u8 + as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 11], + &[libc::c_char; 11]>(b"_checkfade\x00")).as_ptr(), + 324 as libc::c_int, + bytes.wrapping_div(8 as libc::c_int as + libc::c_uint)); } - output.fade = crate::squeezelite_h::FADE_DUE; - output.fade_dir = crate::squeezelite_h::FADE_CROSS; + output.fade = FADE_DUE; + output.fade_dir = FADE_CROSS; output.fade_start = (*outputbuf).writep.offset(-(bytes as isize)); if output.fade_start < (*outputbuf).buf { - output.fade_start = output.fade_start.offset((*outputbuf).size as isize) + output.fade_start = + output.fade_start.offset((*outputbuf).size as isize) } output.fade_end = (*outputbuf).writep; output.track_start = output.fade_start - } else if (*outputbuf).size - == (44100 as libc::c_int * 8 as libc::c_int * 10 as libc::c_int) as libc::c_ulong - && (*outputbuf).readp == (*outputbuf).buf - { + } else if (*outputbuf).size == + (44100 as libc::c_int * 8 as libc::c_int * + 10 as libc::c_int) as libc::c_ulong && + (*outputbuf).readp == (*outputbuf).buf { // if default setting used and nothing in buffer attempt to resize to provide full crossfade support - 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 resize outputbuf for crossfade\n\x00" as *const u8 - as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 11], &[libc::c_char; 11]>(b"_checkfade\x00")) - .as_ptr(), - 335 as libc::c_int, - ); + if loglevel as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d resize outputbuf for crossfade\n\x00" as + *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 11], + &[libc::c_char; 11]>(b"_checkfade\x00")).as_ptr(), + 335 as libc::c_int); } - crate::src::buffer::_buf_resize( - outputbuf, - (44100 as libc::c_int * 8 as libc::c_int * 10 as libc::c_int * 12 as libc::c_int - / 10 as libc::c_int) as crate::stddef_h::size_t, - ); - crate::src::utils::touch_memory((*outputbuf).buf, (*outputbuf).size); + _buf_resize(outputbuf, + (44100 as libc::c_int * 8 as libc::c_int * + 10 as libc::c_int * 12 as libc::c_int / + 10 as libc::c_int) as size_t); + touch_memory((*outputbuf).buf, (*outputbuf).size); } }; } #[no_mangle] - -pub unsafe extern "C" fn output_init_common( - mut level: crate::squeezelite_h::log_level, - mut device: *const libc::c_char, - mut output_buf_size: libc::c_uint, - mut rates: *mut libc::c_uint, - mut idle: libc::c_uint, -) { +pub unsafe extern "C" fn output_init_common(mut level: log_level, + mut device: *const libc::c_char, + mut output_buf_size: libc::c_uint, + mut rates: *mut libc::c_uint, + mut idle: libc::c_uint) { let mut i: libc::c_uint = 0; loglevel = level; - output_buf_size = output_buf_size - .wrapping_sub(output_buf_size.wrapping_rem(8 as libc::c_int as libc::c_uint)); - 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 outputbuf size: %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"output_init_common\x00")) - .as_ptr(), - 350 as libc::c_int, - output_buf_size, - ); + output_buf_size = + output_buf_size.wrapping_sub(output_buf_size.wrapping_rem(8 as + libc::c_int + as + libc::c_uint)); + if loglevel as libc::c_uint >= lDEBUG as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d outputbuf size: %u\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 19], + &[libc::c_char; 19]>(b"output_init_common\x00")).as_ptr(), + 350 as libc::c_int, output_buf_size); } - crate::src::buffer::buf_init(outputbuf, output_buf_size as crate::stddef_h::size_t); + buf_init(outputbuf, output_buf_size as size_t); if (*outputbuf).buf.is_null() { - crate::src::utils::logprint( - b"%s %s:%d unable to malloc output buffer\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_common\x00")) - .as_ptr(), - 354 as libc::c_int, - ); - crate::stdlib::exit(0 as libc::c_int); + logprint(b"%s %s:%d unable to malloc output buffer\n\x00" as *const u8 + as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 19], + &[libc::c_char; 19]>(b"output_init_common\x00")).as_ptr(), + 354 as libc::c_int); + exit(0 as libc::c_int); } - silencebuf = crate::stdlib::malloc((2048 as libc::c_int * 8 as libc::c_int) as libc::c_ulong) - as *mut crate::squeezelite_h::u8_t; + silencebuf = + malloc((2048 as libc::c_int * 8 as libc::c_int) as libc::c_ulong) as + *mut u8_t; if silencebuf.is_null() { - crate::src::utils::logprint( - b"%s %s:%d unable to malloc silence buffer\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_common\x00")) - .as_ptr(), - 360 as libc::c_int, - ); - crate::stdlib::exit(0 as libc::c_int); + logprint(b"%s %s:%d unable to malloc silence buffer\n\x00" as + *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 19], + &[libc::c_char; 19]>(b"output_init_common\x00")).as_ptr(), + 360 as libc::c_int); + exit(0 as libc::c_int); } - crate::stdlib::memset( - silencebuf as *mut libc::c_void, - 0 as libc::c_int, - (2048 as libc::c_int * 8 as libc::c_int) as libc::c_ulong, - ); - 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 idle timeout: %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"output_init_common\x00")) - .as_ptr(), - 374 as libc::c_int, - idle, - ); + memset(silencebuf as *mut libc::c_void, 0 as libc::c_int, + (2048 as libc::c_int * 8 as libc::c_int) as libc::c_ulong); + if loglevel as libc::c_uint >= lDEBUG as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d idle timeout: %u\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 19], + &[libc::c_char; 19]>(b"output_init_common\x00")).as_ptr(), + 374 as libc::c_int, idle); } - output.state = if idle != 0 { - crate::squeezelite_h::OUTPUT_OFF as libc::c_int - } else { - crate::squeezelite_h::OUTPUT_STOPPED as libc::c_int - } as crate::squeezelite_h::output_state; + output.state = + if idle != 0 { + OUTPUT_OFF as libc::c_int + } else { OUTPUT_STOPPED as libc::c_int } as output_state; output.device = device; - output.fade = crate::squeezelite_h::FADE_INACTIVE; + output.fade = FADE_INACTIVE; output.invert = 0 as libc::c_int != 0; output.error_opening = 0 as libc::c_int != 0; output.idle_to = idle; /* Skip test_open for stdout, set default sample rates */ - if *output.device.offset(0 as libc::c_int as isize) as libc::c_int == '-' as i32 { + if *output.device.offset(0 as libc::c_int as isize) as libc::c_int == + '-' as i32 { i = 0 as libc::c_int as libc::c_uint; while i < 18 as libc::c_int as libc::c_uint { output.supported_rates[i as usize] = *rates.offset(i as isize); i = i.wrapping_add(1) } - } else if !crate::src::output_alsa::test_open( - output.device, - output.supported_rates.as_mut_ptr(), - user_rates, - ) { - crate::src::utils::logprint( - b"%s %s:%d unable to open output device: %s\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_common\x00")) - .as_ptr(), - 391 as libc::c_int, - output.device, - ); - crate::stdlib::exit(0 as libc::c_int); + } else if !test_open(output.device, output.supported_rates.as_mut_ptr(), + user_rates) { + logprint(b"%s %s:%d unable to open output device: %s\n\x00" as + *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 19], + &[libc::c_char; 19]>(b"output_init_common\x00")).as_ptr(), + 391 as libc::c_int, output.device); + exit(0 as libc::c_int); } if user_rates { i = 0 as libc::c_int as libc::c_uint; @@ -1028,63 +1017,55 @@ pub unsafe extern "C" fn output_init_common( // set initial sample rate, preferring 44100 i = 0 as libc::c_int as libc::c_uint; while i < 18 as libc::c_int as libc::c_uint { - if output.supported_rates[i as usize] == 44100 as libc::c_int as libc::c_uint { + if output.supported_rates[i as usize] == + 44100 as libc::c_int as libc::c_uint { output.default_sample_rate = 44100 as libc::c_int as libc::c_uint; - break; - } else { - i = i.wrapping_add(1) - } + break ; + } else { i = i.wrapping_add(1) } } if output.default_sample_rate == 0 { - output.default_sample_rate = output.supported_rates[0 as libc::c_int as usize] + output.default_sample_rate = + output.supported_rates[0 as libc::c_int as usize] } output.current_sample_rate = output.default_sample_rate; - if loglevel as libc::c_uint >= crate::squeezelite_h::lINFO as libc::c_int as libc::c_uint { + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { let mut rates_buf: [libc::c_char; 180] = *::std::mem::transmute::<&[u8; 180], &mut [libc::c_char; 180]>(b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"); i = 0 as libc::c_int as libc::c_uint; while output.supported_rates[i as usize] != 0 { let mut s: [libc::c_char; 10] = [0; 10]; - crate::stdlib::sprintf( - s.as_mut_ptr(), - b"%d \x00" as *const u8 as *const libc::c_char, - output.supported_rates[i as usize], - ); - crate::stdlib::strcat(rates_buf.as_mut_ptr(), s.as_mut_ptr()); + sprintf(s.as_mut_ptr(), + b"%d \x00" as *const u8 as *const libc::c_char, + output.supported_rates[i as usize]); + strcat(rates_buf.as_mut_ptr(), s.as_mut_ptr()); i = i.wrapping_add(1) } - 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 supported rates: %s\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_common\x00", - )) - .as_ptr(), - 422 as libc::c_int, - rates_buf.as_mut_ptr(), - ); + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d supported rates: %s\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 19], + &[libc::c_char; 19]>(b"output_init_common\x00")).as_ptr(), + 422 as libc::c_int, rates_buf.as_mut_ptr()); } }; } #[no_mangle] - pub unsafe extern "C" fn output_close_common() { - crate::src::buffer::buf_destroy(outputbuf); - crate::stdlib::free(silencebuf as *mut libc::c_void); + buf_destroy(outputbuf); + free(silencebuf as *mut libc::c_void); } -/* +/* * 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 @@ -1126,27 +1107,24 @@ pub unsafe extern "C" fn output_close_common() { // set by slimproto // set by slimproto #[no_mangle] - pub unsafe extern "C" fn output_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 flush output buffer\n\x00" as *const u8 as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 13], &[libc::c_char; 13]>(b"output_flush\x00")) - .as_ptr(), - 435 as libc::c_int, - ); + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d flush output buffer\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 13], + &[libc::c_char; 13]>(b"output_flush\x00")).as_ptr(), + 435 as libc::c_int); } - crate::src::buffer::buf_flush(outputbuf); - crate::stdlib::pthread_mutex_lock(&mut (*outputbuf).mutex); - output.fade = crate::squeezelite_h::FADE_INACTIVE; - if output.state as libc::c_int != crate::squeezelite_h::OUTPUT_OFF as libc::c_int { - output.state = crate::squeezelite_h::OUTPUT_STOPPED; + buf_flush(outputbuf); + pthread_mutex_lock(&mut (*outputbuf).mutex); + output.fade = FADE_INACTIVE; + if output.state as libc::c_int != OUTPUT_OFF as libc::c_int { + output.state = OUTPUT_STOPPED; if output.error_opening { output.current_sample_rate = output.default_sample_rate } output.delay_active = 0 as libc::c_int != 0 } output.frames_played = 0 as libc::c_int as libc::c_uint; - crate::stdlib::pthread_mutex_unlock(&mut (*outputbuf).mutex); + pthread_mutex_unlock(&mut (*outputbuf).mutex); } diff --git a/src/output_alsa.rs b/src/output_alsa.rs index 408d7f3..340bf0c 100644 --- a/src/output_alsa.rs +++ b/src/output_alsa.rs @@ -1,554 +1,860 @@ 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; - -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::__useconds_t; -pub use crate::stdlib::int32_t; -pub use crate::stdlib::FILE; -pub use crate::stdlib::_IO_FILE; - -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_attr_t; -pub use crate::stdlib::pthread_mutex_t; -pub use crate::stdlib::pthread_t; -pub use crate::stdlib::sched_param; -pub use crate::stdlib::u_int32_t; -pub use crate::stdlib::u_int8_t; - -pub use crate::squeezelite_h::_apply_cross; -pub use crate::squeezelite_h::_apply_gain; -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::src::utils::next_param; -pub use crate::src::utils::touch_memory; -use crate::stdlib::__errno_location; -pub use crate::stdlib::_snd_mixer; -pub use crate::stdlib::_snd_mixer_class; -pub use crate::stdlib::_snd_mixer_elem; -pub use crate::stdlib::_snd_mixer_selem_channel_id; -pub use crate::stdlib::_snd_mixer_selem_id; -pub use crate::stdlib::_snd_output; -pub use crate::stdlib::_snd_pcm; -pub use crate::stdlib::_snd_pcm_access; -pub use crate::stdlib::_snd_pcm_channel_area; -pub use crate::stdlib::_snd_pcm_format; -pub use crate::stdlib::_snd_pcm_hw_params; -pub use crate::stdlib::_snd_pcm_state; -pub use crate::stdlib::_snd_pcm_stream; -use crate::stdlib::atoi; -use crate::stdlib::fflush; -use crate::stdlib::fprintf; -use crate::stdlib::free; -use crate::stdlib::malloc; -use crate::stdlib::memcpy; -use crate::stdlib::memset; -use crate::stdlib::printf; -pub use crate::stdlib::snd_lib_error_handler_t; -pub use crate::stdlib::snd_lib_error_set_handler; -pub use crate::stdlib::snd_mixer_attach; -pub use crate::stdlib::snd_mixer_class_t; -pub use crate::stdlib::snd_mixer_close; -pub use crate::stdlib::snd_mixer_elem_next; -pub use crate::stdlib::snd_mixer_elem_t; -pub use crate::stdlib::snd_mixer_find_selem; -pub use crate::stdlib::snd_mixer_first_elem; -pub use crate::stdlib::snd_mixer_load; -pub use crate::stdlib::snd_mixer_open; -pub use crate::stdlib::snd_mixer_selem_channel_id_t; -pub use crate::stdlib::snd_mixer_selem_get_id; -pub use crate::stdlib::snd_mixer_selem_get_playback_dB_range; -pub use crate::stdlib::snd_mixer_selem_get_playback_volume; -pub use crate::stdlib::snd_mixer_selem_get_playback_volume_range; -pub use crate::stdlib::snd_mixer_selem_has_playback_switch; -pub use crate::stdlib::snd_mixer_selem_has_playback_volume; -pub use crate::stdlib::snd_mixer_selem_id_get_index; -pub use crate::stdlib::snd_mixer_selem_id_get_name; -pub use crate::stdlib::snd_mixer_selem_id_set_index; -pub use crate::stdlib::snd_mixer_selem_id_set_name; -pub use crate::stdlib::snd_mixer_selem_id_sizeof; -pub use crate::stdlib::snd_mixer_selem_id_t; -pub use crate::stdlib::snd_mixer_selem_register; -pub use crate::stdlib::snd_mixer_selem_regopt; -pub use crate::stdlib::snd_mixer_selem_regopt_abstract; -pub use crate::stdlib::snd_mixer_selem_set_playback_dB; -pub use crate::stdlib::snd_mixer_selem_set_playback_switch_all; -pub use crate::stdlib::snd_mixer_selem_set_playback_volume; -pub use crate::stdlib::snd_mixer_t; -pub use crate::stdlib::snd_output_stdio_attach; -pub use crate::stdlib::snd_output_t; -pub use crate::stdlib::snd_pcm_access_t; -pub use crate::stdlib::snd_pcm_avail_update; -pub use crate::stdlib::snd_pcm_channel_area_t; -pub use crate::stdlib::snd_pcm_close; -pub use crate::stdlib::snd_pcm_delay; -pub use crate::stdlib::snd_pcm_dump; -pub use crate::stdlib::snd_pcm_format_name; -pub use crate::stdlib::snd_pcm_format_t; -pub use crate::stdlib::snd_pcm_hw_params; -pub use crate::stdlib::snd_pcm_hw_params_any; -pub use crate::stdlib::snd_pcm_hw_params_get_buffer_size; -pub use crate::stdlib::snd_pcm_hw_params_get_period_size; -pub use crate::stdlib::snd_pcm_hw_params_set_access; -pub use crate::stdlib::snd_pcm_hw_params_set_buffer_size_near; -pub use crate::stdlib::snd_pcm_hw_params_set_buffer_time_near; -pub use crate::stdlib::snd_pcm_hw_params_set_channels; -pub use crate::stdlib::snd_pcm_hw_params_set_format; -pub use crate::stdlib::snd_pcm_hw_params_set_period_size_near; -pub use crate::stdlib::snd_pcm_hw_params_set_periods_near; -pub use crate::stdlib::snd_pcm_hw_params_set_rate; -pub use crate::stdlib::snd_pcm_hw_params_set_rate_resample; -pub use crate::stdlib::snd_pcm_hw_params_sizeof; -pub use crate::stdlib::snd_pcm_hw_params_t; -pub use crate::stdlib::snd_pcm_hw_params_test_rate; -pub use crate::stdlib::snd_pcm_mmap_begin; -pub use crate::stdlib::snd_pcm_mmap_commit; -pub use crate::stdlib::snd_pcm_open; -pub use crate::stdlib::snd_pcm_recover; -pub use crate::stdlib::snd_pcm_sframes_t; -pub use crate::stdlib::snd_pcm_start; -pub use crate::stdlib::snd_pcm_state; -pub use crate::stdlib::snd_pcm_state_t; -pub use crate::stdlib::snd_pcm_stream_t; -pub use crate::stdlib::snd_pcm_t; -pub use crate::stdlib::snd_pcm_uframes_t; -pub use crate::stdlib::snd_pcm_wait; -pub use crate::stdlib::snd_pcm_writei; -pub use crate::stdlib::snd_strerror; -use crate::stdlib::stderr; -use crate::stdlib::strcmp; -use crate::stdlib::strcpy; -use crate::stdlib::strdup; -use crate::stdlib::strerror; -use crate::stdlib::strlen; -use crate::stdlib::strncmp; -use crate::stdlib::strrchr; -use crate::stdlib::strtok; -use crate::stdlib::vfprintf; -pub use crate::stdlib::SND_MIXER_SABSTRACT_BASIC; -pub use crate::stdlib::SND_MIXER_SABSTRACT_NONE; -pub use crate::stdlib::SND_MIXER_SCHN_FRONT_CENTER; -pub use crate::stdlib::SND_MIXER_SCHN_FRONT_LEFT; -pub use crate::stdlib::SND_MIXER_SCHN_FRONT_RIGHT; -pub use crate::stdlib::SND_MIXER_SCHN_LAST; -pub use crate::stdlib::SND_MIXER_SCHN_MONO; -pub use crate::stdlib::SND_MIXER_SCHN_REAR_CENTER; -pub use crate::stdlib::SND_MIXER_SCHN_REAR_LEFT; -pub use crate::stdlib::SND_MIXER_SCHN_REAR_RIGHT; -pub use crate::stdlib::SND_MIXER_SCHN_SIDE_LEFT; -pub use crate::stdlib::SND_MIXER_SCHN_SIDE_RIGHT; -pub use crate::stdlib::SND_MIXER_SCHN_UNKNOWN; -pub use crate::stdlib::SND_MIXER_SCHN_WOOFER; -pub use crate::stdlib::SND_PCM_ACCESS_LAST; -pub use crate::stdlib::SND_PCM_ACCESS_MMAP_COMPLEX; -pub use crate::stdlib::SND_PCM_ACCESS_MMAP_INTERLEAVED; -pub use crate::stdlib::SND_PCM_ACCESS_MMAP_NONINTERLEAVED; -pub use crate::stdlib::SND_PCM_ACCESS_RW_INTERLEAVED; -pub use crate::stdlib::SND_PCM_ACCESS_RW_NONINTERLEAVED; -pub use crate::stdlib::SND_PCM_FORMAT_A_LAW; -pub use crate::stdlib::SND_PCM_FORMAT_DSD_U16_BE; -pub use crate::stdlib::SND_PCM_FORMAT_DSD_U16_LE; -pub use crate::stdlib::SND_PCM_FORMAT_DSD_U32_BE; -pub use crate::stdlib::SND_PCM_FORMAT_DSD_U32_LE; -pub use crate::stdlib::SND_PCM_FORMAT_DSD_U8; -pub use crate::stdlib::SND_PCM_FORMAT_FLOAT; -pub use crate::stdlib::SND_PCM_FORMAT_FLOAT64; -pub use crate::stdlib::SND_PCM_FORMAT_FLOAT64_BE; -pub use crate::stdlib::SND_PCM_FORMAT_FLOAT64_LE; -pub use crate::stdlib::SND_PCM_FORMAT_FLOAT_BE; -pub use crate::stdlib::SND_PCM_FORMAT_FLOAT_LE; -pub use crate::stdlib::SND_PCM_FORMAT_G723_24; -pub use crate::stdlib::SND_PCM_FORMAT_G723_24_1B; -pub use crate::stdlib::SND_PCM_FORMAT_G723_40; -pub use crate::stdlib::SND_PCM_FORMAT_G723_40_1B; -pub use crate::stdlib::SND_PCM_FORMAT_GSM; -pub use crate::stdlib::SND_PCM_FORMAT_IEC958_SUBFRAME; -pub use crate::stdlib::SND_PCM_FORMAT_IEC958_SUBFRAME_BE; -pub use crate::stdlib::SND_PCM_FORMAT_IEC958_SUBFRAME_LE; -pub use crate::stdlib::SND_PCM_FORMAT_IMA_ADPCM; -pub use crate::stdlib::SND_PCM_FORMAT_LAST; -pub use crate::stdlib::SND_PCM_FORMAT_MPEG; -pub use crate::stdlib::SND_PCM_FORMAT_MU_LAW; -pub use crate::stdlib::SND_PCM_FORMAT_S16; -pub use crate::stdlib::SND_PCM_FORMAT_S16_BE; -pub use crate::stdlib::SND_PCM_FORMAT_S16_LE; -pub use crate::stdlib::SND_PCM_FORMAT_S18_3BE; -pub use crate::stdlib::SND_PCM_FORMAT_S18_3LE; -pub use crate::stdlib::SND_PCM_FORMAT_S20; -pub use crate::stdlib::SND_PCM_FORMAT_S20_3BE; -pub use crate::stdlib::SND_PCM_FORMAT_S20_3LE; -pub use crate::stdlib::SND_PCM_FORMAT_S20_BE; -pub use crate::stdlib::SND_PCM_FORMAT_S20_LE; -pub use crate::stdlib::SND_PCM_FORMAT_S24; -pub use crate::stdlib::SND_PCM_FORMAT_S24_3BE; -pub use crate::stdlib::SND_PCM_FORMAT_S24_3LE; -pub use crate::stdlib::SND_PCM_FORMAT_S24_BE; -pub use crate::stdlib::SND_PCM_FORMAT_S24_LE; -pub use crate::stdlib::SND_PCM_FORMAT_S32; -pub use crate::stdlib::SND_PCM_FORMAT_S32_BE; -pub use crate::stdlib::SND_PCM_FORMAT_S32_LE; -pub use crate::stdlib::SND_PCM_FORMAT_S8; -pub use crate::stdlib::SND_PCM_FORMAT_SPECIAL; -pub use crate::stdlib::SND_PCM_FORMAT_U16; -pub use crate::stdlib::SND_PCM_FORMAT_U16_BE; -pub use crate::stdlib::SND_PCM_FORMAT_U16_LE; -pub use crate::stdlib::SND_PCM_FORMAT_U18_3BE; -pub use crate::stdlib::SND_PCM_FORMAT_U18_3LE; -pub use crate::stdlib::SND_PCM_FORMAT_U20; -pub use crate::stdlib::SND_PCM_FORMAT_U20_3BE; -pub use crate::stdlib::SND_PCM_FORMAT_U20_3LE; -pub use crate::stdlib::SND_PCM_FORMAT_U20_BE; -pub use crate::stdlib::SND_PCM_FORMAT_U20_LE; -pub use crate::stdlib::SND_PCM_FORMAT_U24; -pub use crate::stdlib::SND_PCM_FORMAT_U24_3BE; -pub use crate::stdlib::SND_PCM_FORMAT_U24_3LE; -pub use crate::stdlib::SND_PCM_FORMAT_U24_BE; -pub use crate::stdlib::SND_PCM_FORMAT_U24_LE; -pub use crate::stdlib::SND_PCM_FORMAT_U32; -pub use crate::stdlib::SND_PCM_FORMAT_U32_BE; -pub use crate::stdlib::SND_PCM_FORMAT_U32_LE; -pub use crate::stdlib::SND_PCM_FORMAT_U8; -pub use crate::stdlib::SND_PCM_FORMAT_UNKNOWN; -pub use crate::stdlib::SND_PCM_STATE_DISCONNECTED; -pub use crate::stdlib::SND_PCM_STATE_DRAINING; -pub use crate::stdlib::SND_PCM_STATE_LAST; -pub use crate::stdlib::SND_PCM_STATE_OPEN; -pub use crate::stdlib::SND_PCM_STATE_PAUSED; -pub use crate::stdlib::SND_PCM_STATE_PREPARED; -pub use crate::stdlib::SND_PCM_STATE_PRIVATE1; -pub use crate::stdlib::SND_PCM_STATE_RUNNING; -pub use crate::stdlib::SND_PCM_STATE_SETUP; -pub use crate::stdlib::SND_PCM_STATE_SUSPENDED; -pub use crate::stdlib::SND_PCM_STATE_XRUN; -pub use crate::stdlib::SND_PCM_STREAM_CAPTURE; -pub use crate::stdlib::SND_PCM_STREAM_LAST; -pub use crate::stdlib::SND_PCM_STREAM_PLAYBACK; - -use crate::stdlib::floor; -use crate::stdlib::log10; -use crate::stdlib::mallopt; -use crate::stdlib::mlockall; -use crate::stdlib::pthread_attr_destroy; -use crate::stdlib::pthread_attr_init; -use crate::stdlib::pthread_attr_setstacksize; -use crate::stdlib::pthread_create; -use crate::stdlib::pthread_join; -use crate::stdlib::pthread_mutex_lock; -use crate::stdlib::pthread_mutex_unlock; -use crate::stdlib::pthread_setschedparam; -use crate::stdlib::sleep; -use crate::stdlib::snd_device_name_free_hint; -use crate::stdlib::snd_device_name_get_hint; -use crate::stdlib::snd_device_name_hint; -use crate::stdlib::usleep; extern "C" { + pub type _IO_wide_data; + pub type _IO_codecvt; + pub type _IO_marker; + pub type _snd_mixer; + pub type _snd_mixer_selem_id; + pub type _snd_mixer_elem; + pub type _snd_mixer_class; + pub type _snd_pcm; + pub type _snd_pcm_hw_params; + pub type _snd_output; #[no_mangle] - pub static mut silencebuf: *mut crate::squeezelite_h::u8_t; + static mut stderr: *mut FILE; #[no_mangle] - pub static mut output: crate::squeezelite_h::outputstate; + fn fflush(__stream: *mut FILE) -> libc::c_int; #[no_mangle] - pub static mut outputbuf: *mut crate::squeezelite_h::buffer; + fn fprintf(_: *mut FILE, _: *const libc::c_char, _: ...) -> libc::c_int; + #[no_mangle] + fn printf(_: *const libc::c_char, _: ...) -> libc::c_int; + #[no_mangle] + fn vfprintf(_: *mut FILE, _: *const libc::c_char, _: ::std::ffi::VaList) + -> libc::c_int; + #[no_mangle] + fn atoi(__nptr: *const libc::c_char) -> libc::c_int; + #[no_mangle] + fn malloc(_: libc::c_ulong) -> *mut libc::c_void; + #[no_mangle] + fn free(__ptr: *mut libc::c_void); + #[no_mangle] + fn memcpy(_: *mut libc::c_void, _: *const libc::c_void, _: libc::c_ulong) + -> *mut libc::c_void; + #[no_mangle] + fn memset(_: *mut libc::c_void, _: libc::c_int, _: libc::c_ulong) + -> *mut libc::c_void; + #[no_mangle] + fn strcpy(_: *mut libc::c_char, _: *const libc::c_char) + -> *mut libc::c_char; + #[no_mangle] + fn strcmp(_: *const libc::c_char, _: *const libc::c_char) -> libc::c_int; + #[no_mangle] + fn strncmp(_: *const libc::c_char, _: *const libc::c_char, + _: libc::c_ulong) -> libc::c_int; + #[no_mangle] + fn strdup(_: *const libc::c_char) -> *mut libc::c_char; + #[no_mangle] + fn strrchr(_: *const libc::c_char, _: libc::c_int) -> *mut libc::c_char; + #[no_mangle] + fn strtok(_: *mut libc::c_char, _: *const libc::c_char) + -> *mut libc::c_char; + #[no_mangle] + fn strlen(_: *const libc::c_char) -> libc::c_ulong; + #[no_mangle] + fn strerror(_: libc::c_int) -> *mut libc::c_char; + #[no_mangle] + fn __errno_location() -> *mut libc::c_int; + #[no_mangle] + fn sleep(__seconds: libc::c_uint) -> libc::c_uint; + #[no_mangle] + fn usleep(__useconds: __useconds_t) -> libc::c_int; + #[no_mangle] + fn pthread_create(__newthread: *mut pthread_t, + __attr: *const pthread_attr_t, + __start_routine: + Option *mut libc::c_void>, + __arg: *mut libc::c_void) -> libc::c_int; + #[no_mangle] + fn pthread_join(__th: pthread_t, __thread_return: *mut *mut libc::c_void) + -> libc::c_int; + #[no_mangle] + fn pthread_attr_init(__attr: *mut pthread_attr_t) -> libc::c_int; + #[no_mangle] + fn pthread_attr_destroy(__attr: *mut pthread_attr_t) -> libc::c_int; + #[no_mangle] + fn pthread_attr_setstacksize(__attr: *mut pthread_attr_t, + __stacksize: size_t) -> libc::c_int; + #[no_mangle] + fn pthread_setschedparam(__target_thread: pthread_t, + __policy: libc::c_int, + __param: *const sched_param) -> libc::c_int; + #[no_mangle] + fn pthread_mutex_lock(__mutex: *mut pthread_mutex_t) -> libc::c_int; + #[no_mangle] + fn pthread_mutex_unlock(__mutex: *mut pthread_mutex_t) -> libc::c_int; + #[no_mangle] + fn logtime() -> *const libc::c_char; + #[no_mangle] + fn logprint(fmt: *const libc::c_char, _: ...); + #[no_mangle] + fn next_param(src: *mut libc::c_char, c: libc::c_char) + -> *mut libc::c_char; + #[no_mangle] + fn gettime_ms() -> u32_t; + #[no_mangle] + fn touch_memory(buf: *mut u8_t, size: size_t); + #[no_mangle] + fn output_init_common(level: log_level, device: *const libc::c_char, + output_buf_size: libc::c_uint, + rates: *mut libc::c_uint, idle: libc::c_uint); + #[no_mangle] + fn output_close_common(); + #[no_mangle] + fn _output_frames(avail: frames_t) -> frames_t; + #[no_mangle] + fn _apply_cross(outputbuf_0: *mut buffer, out_frames: frames_t, + cross_gain_in: s32_t, cross_gain_out: s32_t, + cross_ptr: *mut *mut s32_t); + #[no_mangle] + fn _scale_and_pack_frames(outputptr: *mut libc::c_void, + inputptr: *mut s32_t, cnt: frames_t, + gainL: s32_t, gainR: s32_t, + format: output_format); + #[no_mangle] + fn _apply_gain(outputbuf_0: *mut buffer, count: frames_t, gainL: s32_t, + gainR: s32_t); + #[no_mangle] + fn snd_pcm_open(pcm: *mut *mut snd_pcm_t, name: *const libc::c_char, + stream: snd_pcm_stream_t, mode: libc::c_int) + -> libc::c_int; + #[no_mangle] + fn snd_pcm_close(pcm: *mut snd_pcm_t) -> libc::c_int; + #[no_mangle] + fn snd_pcm_hw_params(pcm: *mut snd_pcm_t, + params: *mut snd_pcm_hw_params_t) -> libc::c_int; + #[no_mangle] + fn snd_pcm_start(pcm: *mut snd_pcm_t) -> libc::c_int; + #[no_mangle] + fn snd_pcm_state(pcm: *mut snd_pcm_t) -> snd_pcm_state_t; + #[no_mangle] + fn snd_pcm_delay(pcm: *mut snd_pcm_t, delayp: *mut snd_pcm_sframes_t) + -> libc::c_int; + #[no_mangle] + fn snd_pcm_avail_update(pcm: *mut snd_pcm_t) -> snd_pcm_sframes_t; + #[no_mangle] + fn snd_pcm_writei(pcm: *mut snd_pcm_t, buffer: *const libc::c_void, + size: snd_pcm_uframes_t) -> snd_pcm_sframes_t; + #[no_mangle] + fn snd_pcm_wait(pcm: *mut snd_pcm_t, timeout: libc::c_int) -> libc::c_int; + #[no_mangle] + fn snd_pcm_recover(pcm: *mut snd_pcm_t, err: libc::c_int, + silent: libc::c_int) -> libc::c_int; + #[no_mangle] + fn snd_pcm_hw_params_any(pcm: *mut snd_pcm_t, + params: *mut snd_pcm_hw_params_t) -> libc::c_int; + #[no_mangle] + fn snd_pcm_hw_params_sizeof() -> size_t; + #[no_mangle] + fn snd_pcm_hw_params_set_access(pcm: *mut snd_pcm_t, + params: *mut snd_pcm_hw_params_t, + _access: snd_pcm_access_t) -> libc::c_int; + #[no_mangle] + fn snd_pcm_hw_params_set_format(pcm: *mut snd_pcm_t, + params: *mut snd_pcm_hw_params_t, + val: snd_pcm_format_t) -> libc::c_int; + #[no_mangle] + fn snd_pcm_hw_params_set_channels(pcm: *mut snd_pcm_t, + params: *mut snd_pcm_hw_params_t, + val: libc::c_uint) -> libc::c_int; + #[no_mangle] + fn snd_pcm_hw_params_test_rate(pcm: *mut snd_pcm_t, + params: *mut snd_pcm_hw_params_t, + val: libc::c_uint, dir: libc::c_int) + -> libc::c_int; + #[no_mangle] + fn snd_pcm_hw_params_set_rate(pcm: *mut snd_pcm_t, + params: *mut snd_pcm_hw_params_t, + val: libc::c_uint, dir: libc::c_int) + -> libc::c_int; + #[no_mangle] + fn snd_pcm_hw_params_set_rate_resample(pcm: *mut snd_pcm_t, + params: *mut snd_pcm_hw_params_t, + val: libc::c_uint) -> libc::c_int; + #[no_mangle] + fn snd_pcm_hw_params_get_period_size(params: *const snd_pcm_hw_params_t, + frames: *mut snd_pcm_uframes_t, + dir: *mut libc::c_int) + -> libc::c_int; + #[no_mangle] + fn snd_pcm_hw_params_set_period_size_near(pcm: *mut snd_pcm_t, + params: + *mut snd_pcm_hw_params_t, + val: *mut snd_pcm_uframes_t, + dir: *mut libc::c_int) + -> libc::c_int; + #[no_mangle] + fn snd_pcm_hw_params_set_periods_near(pcm: *mut snd_pcm_t, + params: *mut snd_pcm_hw_params_t, + val: *mut libc::c_uint, + dir: *mut libc::c_int) + -> libc::c_int; + #[no_mangle] + fn snd_pcm_hw_params_set_buffer_time_near(pcm: *mut snd_pcm_t, + params: + *mut snd_pcm_hw_params_t, + val: *mut libc::c_uint, + dir: *mut libc::c_int) + -> libc::c_int; + #[no_mangle] + fn snd_pcm_hw_params_get_buffer_size(params: *const snd_pcm_hw_params_t, + val: *mut snd_pcm_uframes_t) + -> libc::c_int; + #[no_mangle] + fn snd_pcm_hw_params_set_buffer_size_near(pcm: *mut snd_pcm_t, + params: + *mut snd_pcm_hw_params_t, + val: *mut snd_pcm_uframes_t) + -> libc::c_int; + #[no_mangle] + fn snd_pcm_format_name(format: snd_pcm_format_t) -> *const libc::c_char; + #[no_mangle] + fn snd_mixer_find_selem(mixer: *mut snd_mixer_t, + id: *const snd_mixer_selem_id_t) + -> *mut snd_mixer_elem_t; + #[no_mangle] + fn snd_device_name_free_hint(hints: *mut *mut libc::c_void) + -> libc::c_int; + #[no_mangle] + fn snd_pcm_mmap_begin(pcm: *mut snd_pcm_t, + areas: *mut *const snd_pcm_channel_area_t, + offset: *mut snd_pcm_uframes_t, + frames: *mut snd_pcm_uframes_t) -> libc::c_int; + #[no_mangle] + fn snd_pcm_mmap_commit(pcm: *mut snd_pcm_t, offset: snd_pcm_uframes_t, + frames: snd_pcm_uframes_t) -> snd_pcm_sframes_t; + #[no_mangle] + fn snd_device_name_get_hint(hint: *const libc::c_void, + id: *const libc::c_char) -> *mut libc::c_char; + #[no_mangle] + fn snd_lib_error_set_handler(handler: snd_lib_error_handler_t) + -> libc::c_int; + #[no_mangle] + fn snd_device_name_hint(card: libc::c_int, iface: *const libc::c_char, + hints: *mut *mut *mut libc::c_void) + -> libc::c_int; + #[no_mangle] + fn snd_mixer_selem_id_set_index(obj: *mut snd_mixer_selem_id_t, + val: libc::c_uint); + #[no_mangle] + fn snd_mixer_selem_id_set_name(obj: *mut snd_mixer_selem_id_t, + val: *const libc::c_char); + #[no_mangle] + fn snd_mixer_close(mixer: *mut snd_mixer_t) -> libc::c_int; + #[no_mangle] + fn snd_mixer_selem_has_playback_switch(elem: *mut snd_mixer_elem_t) + -> libc::c_int; + #[no_mangle] + fn snd_mixer_selem_set_playback_switch_all(elem: *mut snd_mixer_elem_t, + value: libc::c_int) + -> libc::c_int; + #[no_mangle] + fn snd_mixer_selem_get_playback_dB_range(elem: *mut snd_mixer_elem_t, + min: *mut libc::c_long, + max: *mut libc::c_long) + -> libc::c_int; + #[no_mangle] + fn snd_mixer_selem_get_playback_volume_range(elem: *mut snd_mixer_elem_t, + min: *mut libc::c_long, + max: *mut libc::c_long) + -> libc::c_int; + #[no_mangle] + fn snd_output_stdio_attach(outputp: *mut *mut snd_output_t, fp: *mut FILE, + _close: libc::c_int) -> libc::c_int; + #[no_mangle] + fn snd_pcm_dump(pcm: *mut snd_pcm_t, out: *mut snd_output_t) + -> libc::c_int; + #[no_mangle] + fn snd_mixer_selem_set_playback_volume(elem: *mut snd_mixer_elem_t, + channel: + snd_mixer_selem_channel_id_t, + value: libc::c_long) + -> libc::c_int; + #[no_mangle] + fn snd_mixer_selem_set_playback_dB(elem: *mut snd_mixer_elem_t, + channel: snd_mixer_selem_channel_id_t, + value: libc::c_long, dir: libc::c_int) + -> libc::c_int; + #[no_mangle] + fn snd_mixer_selem_get_playback_volume(elem: *mut snd_mixer_elem_t, + channel: + snd_mixer_selem_channel_id_t, + value: *mut libc::c_long) + -> libc::c_int; + #[no_mangle] + fn snd_mixer_selem_id_sizeof() -> size_t; + #[no_mangle] + fn snd_mixer_open(mixer: *mut *mut snd_mixer_t, mode: libc::c_int) + -> libc::c_int; + #[no_mangle] + fn snd_mixer_attach(mixer: *mut snd_mixer_t, name: *const libc::c_char) + -> libc::c_int; + #[no_mangle] + fn snd_mixer_selem_register(mixer: *mut snd_mixer_t, + options: *mut snd_mixer_selem_regopt, + classp: *mut *mut snd_mixer_class_t) + -> libc::c_int; + #[no_mangle] + fn snd_mixer_load(mixer: *mut snd_mixer_t) -> libc::c_int; + #[no_mangle] + fn snd_strerror(errnum: libc::c_int) -> *const libc::c_char; + #[no_mangle] + fn snd_mixer_first_elem(mixer: *mut snd_mixer_t) -> *mut snd_mixer_elem_t; + #[no_mangle] + fn snd_mixer_elem_next(elem: *mut snd_mixer_elem_t) + -> *mut snd_mixer_elem_t; + #[no_mangle] + fn snd_mixer_selem_has_playback_volume(elem: *mut snd_mixer_elem_t) + -> libc::c_int; + #[no_mangle] + fn snd_mixer_selem_get_id(element: *mut snd_mixer_elem_t, + id: *mut snd_mixer_selem_id_t); + #[no_mangle] + fn snd_mixer_selem_id_get_name(obj: *const snd_mixer_selem_id_t) + -> *const libc::c_char; + #[no_mangle] + fn snd_mixer_selem_id_get_index(obj: *const snd_mixer_selem_id_t) + -> libc::c_uint; + #[no_mangle] + fn mlockall(__flags: libc::c_int) -> libc::c_int; + #[no_mangle] + fn mallopt(__param: libc::c_int, __val: libc::c_int) -> libc::c_int; + #[no_mangle] + fn log10(_: libc::c_double) -> libc::c_double; + #[no_mangle] + fn floor(_: libc::c_double) -> libc::c_double; + #[no_mangle] + static mut silencebuf: *mut u8_t; + #[no_mangle] + static mut output: outputstate; + #[no_mangle] + static mut outputbuf: *mut buffer; } -// ouput device - -#[repr(C)] +pub type __builtin_va_list = [__va_list_tag; 1]; #[derive(Copy, Clone)] -pub struct C2RustUnnamed_12 { +#[repr(C)] +pub struct __va_list_tag { + pub gp_offset: libc::c_uint, + pub fp_offset: libc::c_uint, + pub overflow_arg_area: *mut libc::c_void, + pub reg_save_area: *mut libc::c_void, +} +pub type size_t = libc::c_ulong; +pub type va_list = __builtin_va_list; +pub type __uint8_t = libc::c_uchar; +pub type __int32_t = libc::c_int; +pub type __uint32_t = libc::c_uint; +pub type __off_t = libc::c_long; +pub type __off64_t = libc::c_long; +pub type __useconds_t = libc::c_uint; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct _IO_FILE { + pub _flags: libc::c_int, + pub _IO_read_ptr: *mut libc::c_char, + pub _IO_read_end: *mut libc::c_char, + pub _IO_read_base: *mut libc::c_char, + pub _IO_write_base: *mut libc::c_char, + pub _IO_write_ptr: *mut libc::c_char, + pub _IO_write_end: *mut libc::c_char, + pub _IO_buf_base: *mut libc::c_char, + pub _IO_buf_end: *mut libc::c_char, + pub _IO_save_base: *mut libc::c_char, + pub _IO_backup_base: *mut libc::c_char, + pub _IO_save_end: *mut libc::c_char, + pub _markers: *mut _IO_marker, + pub _chain: *mut _IO_FILE, + pub _fileno: libc::c_int, + pub _flags2: libc::c_int, + pub _old_offset: __off_t, + pub _cur_column: libc::c_ushort, + pub _vtable_offset: libc::c_schar, + pub _shortbuf: [libc::c_char; 1], + pub _lock: *mut libc::c_void, + pub _offset: __off64_t, + pub _codecvt: *mut _IO_codecvt, + pub _wide_data: *mut _IO_wide_data, + pub _freeres_list: *mut _IO_FILE, + pub _freeres_buf: *mut libc::c_void, + pub __pad5: size_t, + pub _mode: libc::c_int, + pub _unused2: [libc::c_char; 20], +} +pub type _IO_lock_t = (); +pub type FILE = _IO_FILE; +pub type int32_t = __int32_t; +pub type u_int8_t = __uint8_t; +pub type u_int32_t = __uint32_t; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct __pthread_internal_list { + pub __prev: *mut __pthread_internal_list, + pub __next: *mut __pthread_internal_list, +} +pub type __pthread_list_t = __pthread_internal_list; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct __pthread_mutex_s { + pub __lock: libc::c_int, + pub __count: libc::c_uint, + pub __owner: libc::c_int, + pub __nusers: libc::c_uint, + pub __kind: libc::c_int, + pub __spins: libc::c_short, + pub __elision: libc::c_short, + pub __list: __pthread_list_t, +} +pub type pthread_t = libc::c_ulong; +#[derive(Copy, Clone)] +#[repr(C)] +pub union pthread_attr_t { + pub __size: [libc::c_char; 56], + pub __align: libc::c_long, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub union pthread_mutex_t { + pub __data: __pthread_mutex_s, + pub __size: [libc::c_char; 40], + pub __align: libc::c_long, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct sched_param { + pub sched_priority: libc::c_int, +} +pub type u8_t = u_int8_t; +pub type u32_t = u_int32_t; +pub type s32_t = int32_t; +pub type frames_t = u32_t; +pub type log_level = libc::c_uint; +pub const lSDEBUG: log_level = 4; +pub const lDEBUG: log_level = 3; +pub const lINFO: log_level = 2; +pub const lWARN: log_level = 1; +pub const lERROR: log_level = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct buffer { + pub buf: *mut u8_t, + pub readp: *mut u8_t, + pub writep: *mut u8_t, + pub wrap: *mut u8_t, + pub size: size_t, + pub base_size: size_t, + pub mutex: pthread_mutex_t, +} +pub type output_state = libc::c_int; +pub const OUTPUT_START_AT: output_state = 5; +pub const OUTPUT_SKIP_FRAMES: output_state = 4; +pub const OUTPUT_PAUSE_FRAMES: output_state = 3; +pub const OUTPUT_RUNNING: output_state = 2; +pub const OUTPUT_BUFFER: output_state = 1; +pub const OUTPUT_STOPPED: output_state = 0; +pub const OUTPUT_OFF: output_state = -1; +pub type output_format = libc::c_uint; +pub const S16_LE: output_format = 3; +pub const S24_3LE: output_format = 2; +pub const S24_LE: output_format = 1; +pub const S32_LE: output_format = 0; +pub type fade_state = libc::c_uint; +pub const FADE_ACTIVE: fade_state = 2; +pub const FADE_DUE: fade_state = 1; +pub const FADE_INACTIVE: fade_state = 0; +pub type fade_dir = libc::c_uint; +pub const FADE_CROSS: fade_dir = 3; +pub const FADE_DOWN: fade_dir = 2; +pub const FADE_UP: fade_dir = 1; +pub type fade_mode = libc::c_uint; +pub const FADE_INOUT: fade_mode = 4; +pub const FADE_OUT: fade_mode = 3; +pub const FADE_IN: fade_mode = 2; +pub const FADE_CROSSFADE: fade_mode = 1; +pub const FADE_NONE: fade_mode = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct outputstate { + pub state: output_state, + pub format: output_format, + pub device: *const libc::c_char, + pub buffer: libc::c_uint, + pub period: libc::c_uint, + pub track_started: bool, + pub write_cb: Option libc::c_int>, + pub start_frames: libc::c_uint, + pub frames_played: libc::c_uint, + pub frames_played_dmp: libc::c_uint, + pub current_sample_rate: libc::c_uint, + pub supported_rates: [libc::c_uint; 18], + pub default_sample_rate: libc::c_uint, + pub error_opening: bool, + pub device_frames: libc::c_uint, + pub updated: u32_t, + pub track_start_time: u32_t, + pub current_replay_gain: u32_t, + pub c2rust_unnamed: C2RustUnnamed, + pub next_sample_rate: libc::c_uint, + pub track_start: *mut u8_t, + pub gainL: u32_t, + pub gainR: u32_t, + pub invert: bool, + pub next_replay_gain: u32_t, + pub threshold: libc::c_uint, + pub fade: fade_state, + pub fade_start: *mut u8_t, + pub fade_end: *mut u8_t, + pub fade_dir: fade_dir, + pub fade_mode: fade_mode, + pub fade_secs: libc::c_uint, + pub rate_delay: libc::c_uint, + pub delay_active: bool, + pub stop_time: u32_t, + pub idle_to: u32_t, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub union C2RustUnnamed { + pub pause_frames: u32_t, + pub skip_frames: u32_t, + pub start_at: u32_t, +} +pub type snd_mixer_t = _snd_mixer; +pub type snd_mixer_selem_id_t = _snd_mixer_selem_id; +pub type snd_mixer_elem_t = _snd_mixer_elem; +pub type snd_mixer_class_t = _snd_mixer_class; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct snd_mixer_selem_regopt { + pub ver: libc::c_int, + pub abstract_0: snd_mixer_selem_regopt_abstract, + pub device: *const libc::c_char, + pub playback_pcm: *mut snd_pcm_t, + pub capture_pcm: *mut snd_pcm_t, +} +pub type snd_pcm_t = _snd_pcm; +pub type snd_mixer_selem_regopt_abstract = libc::c_uint; +pub const SND_MIXER_SABSTRACT_BASIC: snd_mixer_selem_regopt_abstract = 1; +pub const SND_MIXER_SABSTRACT_NONE: snd_mixer_selem_regopt_abstract = 0; +// ouput device +#[derive(Copy, Clone)] +#[repr(C)] +pub struct C2RustUnnamed_0 { pub device: [libc::c_char; 129], pub ctl: *mut libc::c_char, pub mixer_ctl: *mut libc::c_char, - pub format: crate::stdlib::snd_pcm_format_t, - pub buffer_size: crate::stdlib::snd_pcm_uframes_t, - pub period_size: crate::stdlib::snd_pcm_uframes_t, + pub format: snd_pcm_format_t, + pub buffer_size: snd_pcm_uframes_t, + pub period_size: snd_pcm_uframes_t, pub rate: libc::c_uint, pub mmap: bool, pub reopen: bool, - pub write_buf: *mut crate::squeezelite_h::u8_t, + pub write_buf: *mut u8_t, pub volume_mixer_name: *const libc::c_char, pub mixer_linear: bool, - pub mixer_elem: *mut crate::stdlib::snd_mixer_elem_t, - pub mixer_handle: *mut crate::stdlib::snd_mixer_t, + pub mixer_elem: *mut snd_mixer_elem_t, + pub mixer_handle: *mut snd_mixer_t, pub mixer_min: libc::c_long, pub mixer_max: libc::c_long, } - -static mut fmts: [crate::stdlib::snd_pcm_format_t; 5] = [ - crate::stdlib::SND_PCM_FORMAT_S32_LE, - crate::stdlib::SND_PCM_FORMAT_S24_LE, - crate::stdlib::SND_PCM_FORMAT_S24_3LE, - crate::stdlib::SND_PCM_FORMAT_S16_LE, - crate::stdlib::SND_PCM_FORMAT_UNKNOWN, -]; - -static mut alsa: C2RustUnnamed_12 = C2RustUnnamed_12 { - device: [0; 129], - ctl: 0 as *const libc::c_char as *mut libc::c_char, - mixer_ctl: 0 as *const libc::c_char as *mut libc::c_char, - format: crate::stdlib::SND_PCM_FORMAT_S8, - buffer_size: 0, - period_size: 0, - rate: 0, - mmap: false, - reopen: false, - write_buf: 0 as *const crate::squeezelite_h::u8_t as *mut crate::squeezelite_h::u8_t, - volume_mixer_name: 0 as *const libc::c_char, - mixer_linear: false, - mixer_elem: 0 as *const crate::stdlib::snd_mixer_elem_t as *mut crate::stdlib::snd_mixer_elem_t, - mixer_handle: 0 as *const crate::stdlib::snd_mixer_t as *mut crate::stdlib::snd_mixer_t, - mixer_min: 0, - mixer_max: 0, -}; - -static mut pcmp: *mut crate::stdlib::snd_pcm_t = - 0 as *const crate::stdlib::snd_pcm_t as *mut crate::stdlib::snd_pcm_t; - -static mut loglevel: crate::squeezelite_h::log_level = crate::squeezelite_h::lERROR; - +pub type snd_pcm_uframes_t = libc::c_ulong; +pub type snd_pcm_format_t = _snd_pcm_format; +pub type _snd_pcm_format = libc::c_int; +pub const SND_PCM_FORMAT_U20: _snd_pcm_format = 27; +pub const SND_PCM_FORMAT_S20: _snd_pcm_format = 25; +pub const SND_PCM_FORMAT_IEC958_SUBFRAME: _snd_pcm_format = 18; +pub const SND_PCM_FORMAT_FLOAT64: _snd_pcm_format = 16; +pub const SND_PCM_FORMAT_FLOAT: _snd_pcm_format = 14; +pub const SND_PCM_FORMAT_U32: _snd_pcm_format = 12; +pub const SND_PCM_FORMAT_S32: _snd_pcm_format = 10; +pub const SND_PCM_FORMAT_U24: _snd_pcm_format = 8; +pub const SND_PCM_FORMAT_S24: _snd_pcm_format = 6; +pub const SND_PCM_FORMAT_U16: _snd_pcm_format = 4; +pub const SND_PCM_FORMAT_S16: _snd_pcm_format = 2; +pub const SND_PCM_FORMAT_LAST: _snd_pcm_format = 52; +pub const SND_PCM_FORMAT_DSD_U32_BE: _snd_pcm_format = 52; +pub const SND_PCM_FORMAT_DSD_U16_BE: _snd_pcm_format = 51; +pub const SND_PCM_FORMAT_DSD_U32_LE: _snd_pcm_format = 50; +pub const SND_PCM_FORMAT_DSD_U16_LE: _snd_pcm_format = 49; +pub const SND_PCM_FORMAT_DSD_U8: _snd_pcm_format = 48; +pub const SND_PCM_FORMAT_G723_40_1B: _snd_pcm_format = 47; +pub const SND_PCM_FORMAT_G723_40: _snd_pcm_format = 46; +pub const SND_PCM_FORMAT_G723_24_1B: _snd_pcm_format = 45; +pub const SND_PCM_FORMAT_G723_24: _snd_pcm_format = 44; +pub const SND_PCM_FORMAT_U18_3BE: _snd_pcm_format = 43; +pub const SND_PCM_FORMAT_U18_3LE: _snd_pcm_format = 42; +pub const SND_PCM_FORMAT_S18_3BE: _snd_pcm_format = 41; +pub const SND_PCM_FORMAT_S18_3LE: _snd_pcm_format = 40; +pub const SND_PCM_FORMAT_U20_3BE: _snd_pcm_format = 39; +pub const SND_PCM_FORMAT_U20_3LE: _snd_pcm_format = 38; +pub const SND_PCM_FORMAT_S20_3BE: _snd_pcm_format = 37; +pub const SND_PCM_FORMAT_S20_3LE: _snd_pcm_format = 36; +pub const SND_PCM_FORMAT_U24_3BE: _snd_pcm_format = 35; +pub const SND_PCM_FORMAT_U24_3LE: _snd_pcm_format = 34; +pub const SND_PCM_FORMAT_S24_3BE: _snd_pcm_format = 33; +pub const SND_PCM_FORMAT_S24_3LE: _snd_pcm_format = 32; +pub const SND_PCM_FORMAT_SPECIAL: _snd_pcm_format = 31; +pub const SND_PCM_FORMAT_U20_BE: _snd_pcm_format = 28; +pub const SND_PCM_FORMAT_U20_LE: _snd_pcm_format = 27; +pub const SND_PCM_FORMAT_S20_BE: _snd_pcm_format = 26; +pub const SND_PCM_FORMAT_S20_LE: _snd_pcm_format = 25; +pub const SND_PCM_FORMAT_GSM: _snd_pcm_format = 24; +pub const SND_PCM_FORMAT_MPEG: _snd_pcm_format = 23; +pub const SND_PCM_FORMAT_IMA_ADPCM: _snd_pcm_format = 22; +pub const SND_PCM_FORMAT_A_LAW: _snd_pcm_format = 21; +pub const SND_PCM_FORMAT_MU_LAW: _snd_pcm_format = 20; +pub const SND_PCM_FORMAT_IEC958_SUBFRAME_BE: _snd_pcm_format = 19; +pub const SND_PCM_FORMAT_IEC958_SUBFRAME_LE: _snd_pcm_format = 18; +pub const SND_PCM_FORMAT_FLOAT64_BE: _snd_pcm_format = 17; +pub const SND_PCM_FORMAT_FLOAT64_LE: _snd_pcm_format = 16; +pub const SND_PCM_FORMAT_FLOAT_BE: _snd_pcm_format = 15; +pub const SND_PCM_FORMAT_FLOAT_LE: _snd_pcm_format = 14; +pub const SND_PCM_FORMAT_U32_BE: _snd_pcm_format = 13; +pub const SND_PCM_FORMAT_U32_LE: _snd_pcm_format = 12; +pub const SND_PCM_FORMAT_S32_BE: _snd_pcm_format = 11; +pub const SND_PCM_FORMAT_S32_LE: _snd_pcm_format = 10; +pub const SND_PCM_FORMAT_U24_BE: _snd_pcm_format = 9; +pub const SND_PCM_FORMAT_U24_LE: _snd_pcm_format = 8; +pub const SND_PCM_FORMAT_S24_BE: _snd_pcm_format = 7; +pub const SND_PCM_FORMAT_S24_LE: _snd_pcm_format = 6; +pub const SND_PCM_FORMAT_U16_BE: _snd_pcm_format = 5; +pub const SND_PCM_FORMAT_U16_LE: _snd_pcm_format = 4; +pub const SND_PCM_FORMAT_S16_BE: _snd_pcm_format = 3; +pub const SND_PCM_FORMAT_S16_LE: _snd_pcm_format = 2; +pub const SND_PCM_FORMAT_U8: _snd_pcm_format = 1; +pub const SND_PCM_FORMAT_S8: _snd_pcm_format = 0; +pub const SND_PCM_FORMAT_UNKNOWN: _snd_pcm_format = -1; +pub type snd_mixer_selem_channel_id_t = _snd_mixer_selem_channel_id; +pub type _snd_mixer_selem_channel_id = libc::c_int; +pub const SND_MIXER_SCHN_MONO: _snd_mixer_selem_channel_id = 0; +pub const SND_MIXER_SCHN_LAST: _snd_mixer_selem_channel_id = 31; +pub const SND_MIXER_SCHN_REAR_CENTER: _snd_mixer_selem_channel_id = 8; +pub const SND_MIXER_SCHN_SIDE_RIGHT: _snd_mixer_selem_channel_id = 7; +pub const SND_MIXER_SCHN_SIDE_LEFT: _snd_mixer_selem_channel_id = 6; +pub const SND_MIXER_SCHN_WOOFER: _snd_mixer_selem_channel_id = 5; +pub const SND_MIXER_SCHN_FRONT_CENTER: _snd_mixer_selem_channel_id = 4; +pub const SND_MIXER_SCHN_REAR_RIGHT: _snd_mixer_selem_channel_id = 3; +pub const SND_MIXER_SCHN_REAR_LEFT: _snd_mixer_selem_channel_id = 2; +pub const SND_MIXER_SCHN_FRONT_RIGHT: _snd_mixer_selem_channel_id = 1; +pub const SND_MIXER_SCHN_FRONT_LEFT: _snd_mixer_selem_channel_id = 0; +pub const SND_MIXER_SCHN_UNKNOWN: _snd_mixer_selem_channel_id = -1; +pub type snd_pcm_hw_params_t = _snd_pcm_hw_params; +pub type snd_pcm_stream_t = _snd_pcm_stream; +pub type _snd_pcm_stream = libc::c_uint; +pub const SND_PCM_STREAM_LAST: _snd_pcm_stream = 1; +pub const SND_PCM_STREAM_CAPTURE: _snd_pcm_stream = 1; +pub const SND_PCM_STREAM_PLAYBACK: _snd_pcm_stream = 0; +pub type snd_pcm_sframes_t = libc::c_long; +pub const SND_PCM_STATE_DISCONNECTED: _snd_pcm_state = 8; +pub type snd_pcm_state_t = _snd_pcm_state; +pub type _snd_pcm_state = libc::c_uint; +pub const SND_PCM_STATE_PRIVATE1: _snd_pcm_state = 1024; +pub const SND_PCM_STATE_LAST: _snd_pcm_state = 8; +pub const SND_PCM_STATE_SUSPENDED: _snd_pcm_state = 7; +pub const SND_PCM_STATE_PAUSED: _snd_pcm_state = 6; +pub const SND_PCM_STATE_DRAINING: _snd_pcm_state = 5; +pub const SND_PCM_STATE_XRUN: _snd_pcm_state = 4; +pub const SND_PCM_STATE_RUNNING: _snd_pcm_state = 3; +pub const SND_PCM_STATE_PREPARED: _snd_pcm_state = 2; +pub const SND_PCM_STATE_SETUP: _snd_pcm_state = 1; +pub const SND_PCM_STATE_OPEN: _snd_pcm_state = 0; +pub type snd_output_t = _snd_output; +pub type snd_pcm_access_t = _snd_pcm_access; +pub type _snd_pcm_access = libc::c_uint; +pub const SND_PCM_ACCESS_LAST: _snd_pcm_access = 4; +pub const SND_PCM_ACCESS_RW_NONINTERLEAVED: _snd_pcm_access = 4; +pub const SND_PCM_ACCESS_RW_INTERLEAVED: _snd_pcm_access = 3; +pub const SND_PCM_ACCESS_MMAP_COMPLEX: _snd_pcm_access = 2; +pub const SND_PCM_ACCESS_MMAP_NONINTERLEAVED: _snd_pcm_access = 1; +pub const SND_PCM_ACCESS_MMAP_INTERLEAVED: _snd_pcm_access = 0; +pub type snd_lib_error_handler_t + = + Option ()>; +pub type snd_pcm_channel_area_t = _snd_pcm_channel_area; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct _snd_pcm_channel_area { + pub addr: *mut libc::c_void, + pub first: libc::c_uint, + pub step: libc::c_uint, +} +static mut fmts: [snd_pcm_format_t; 5] = + [SND_PCM_FORMAT_S32_LE, SND_PCM_FORMAT_S24_LE, SND_PCM_FORMAT_S24_3LE, + SND_PCM_FORMAT_S16_LE, SND_PCM_FORMAT_UNKNOWN]; +static mut alsa: C2RustUnnamed_0 = + C2RustUnnamed_0{device: [0; 129], + ctl: 0 as *const libc::c_char as *mut libc::c_char, + mixer_ctl: 0 as *const libc::c_char as *mut libc::c_char, + format: SND_PCM_FORMAT_S8, + buffer_size: 0, + period_size: 0, + rate: 0, + mmap: false, + reopen: false, + write_buf: 0 as *const u8_t as *mut u8_t, + volume_mixer_name: 0 as *const libc::c_char, + mixer_linear: false, + mixer_elem: + 0 as *const snd_mixer_elem_t as *mut snd_mixer_elem_t, + mixer_handle: 0 as *const snd_mixer_t as *mut snd_mixer_t, + mixer_min: 0, + mixer_max: 0,}; +static mut pcmp: *mut snd_pcm_t = 0 as *const snd_pcm_t as *mut snd_pcm_t; +static mut loglevel: log_level = lERROR; static mut running: bool = 1 as libc::c_int != 0; - -unsafe extern "C" fn ctl4device(mut device: *const libc::c_char) -> *mut libc::c_char { - let mut ctl = 0 as *mut libc::c_char; - if crate::stdlib::strncmp( - device, - b"hw:\x00" as *const u8 as *const libc::c_char, - 3 as libc::c_int as libc::c_ulong, - ) == 0 - { - ctl = crate::stdlib::strdup(device) - } else if crate::stdlib::strncmp( - device, - b"plughw:\x00" as *const u8 as *const libc::c_char, - 7 as libc::c_int as libc::c_ulong, - ) == 0 - { - ctl = crate::stdlib::strdup(device.offset(4 as libc::c_int as isize)) +unsafe extern "C" fn ctl4device(mut device: *const libc::c_char) + -> *mut libc::c_char { + let mut ctl: *mut libc::c_char = 0 as *mut libc::c_char; + if strncmp(device, b"hw:\x00" as *const u8 as *const libc::c_char, + 3 as libc::c_int as libc::c_ulong) == 0 { + ctl = strdup(device) + } else if strncmp(device, + b"plughw:\x00" as *const u8 as *const libc::c_char, + 7 as libc::c_int as libc::c_ulong) == 0 { + ctl = strdup(device.offset(4 as libc::c_int as isize)) } if !ctl.is_null() { - let mut comma = 0 as *mut libc::c_char; - comma = crate::stdlib::strrchr(ctl, ',' as i32); - if !comma.is_null() { - *comma = '\u{0}' as i32 as libc::c_char - } - } else { - ctl = crate::stdlib::strdup(device) - } + let mut comma: *mut libc::c_char = 0 as *mut libc::c_char; + comma = strrchr(ctl, ',' as i32); + if !comma.is_null() { *comma = '\u{0}' as i32 as libc::c_char } + } else { ctl = strdup(device) } return ctl; } #[no_mangle] - pub unsafe extern "C" fn list_devices() { - let mut hints = 0 as *mut *mut libc::c_void; - let mut n = 0 as *mut *mut libc::c_void; - if crate::stdlib::snd_device_name_hint( - -(1 as libc::c_int), - b"pcm\x00" as *const u8 as *const libc::c_char, - &mut hints, - ) >= 0 as libc::c_int - { + let mut hints: *mut *mut libc::c_void = 0 as *mut *mut libc::c_void; + let mut n: *mut *mut libc::c_void = 0 as *mut *mut libc::c_void; + if snd_device_name_hint(-(1 as libc::c_int), + b"pcm\x00" as *const u8 as *const libc::c_char, + &mut hints) >= 0 as libc::c_int { n = hints; - crate::stdlib::printf(b"Output devices:\n\x00" as *const u8 as *const libc::c_char); + printf(b"Output devices:\n\x00" as *const u8 as *const libc::c_char); while !(*n).is_null() { - let mut name = crate::stdlib::snd_device_name_get_hint( - *n, - b"NAME\x00" as *const u8 as *const libc::c_char, - ); - let mut desc = crate::stdlib::snd_device_name_get_hint( - *n, - b"DESC\x00" as *const u8 as *const libc::c_char, - ); + let mut name: *mut libc::c_char = + snd_device_name_get_hint(*n, + b"NAME\x00" as *const u8 as + *const libc::c_char); + let mut desc: *mut libc::c_char = + snd_device_name_get_hint(*n, + b"DESC\x00" as *const u8 as + *const libc::c_char); if !name.is_null() { - crate::stdlib::printf(b" %-30s\x00" as *const u8 as *const libc::c_char, name); + printf(b" %-30s\x00" as *const u8 as *const libc::c_char, + name); } if !desc.is_null() { - let mut s1 = - crate::stdlib::strtok(desc, b"\n\x00" as *const u8 as *const libc::c_char); - let mut s2 = crate::stdlib::strtok( - 0 as *mut libc::c_char, - b"\n\x00" as *const u8 as *const libc::c_char, - ); + let mut s1: *mut libc::c_char = + strtok(desc, + b"\n\x00" as *const u8 as *const libc::c_char); + let mut s2: *mut libc::c_char = + strtok(0 as *mut libc::c_char, + b"\n\x00" as *const u8 as *const libc::c_char); if !s1.is_null() { - crate::stdlib::printf(b" - %s\x00" as *const u8 as *const libc::c_char, s1); + printf(b" - %s\x00" as *const u8 as *const libc::c_char, + s1); } if !s2.is_null() { - crate::stdlib::printf(b" - %s\x00" as *const u8 as *const libc::c_char, s2); + printf(b" - %s\x00" as *const u8 as *const libc::c_char, + s2); } } - crate::stdlib::printf(b"\n\x00" as *const u8 as *const libc::c_char); - if !name.is_null() { - crate::stdlib::free(name as *mut libc::c_void); - } - if !desc.is_null() { - crate::stdlib::free(desc as *mut libc::c_void); - } + printf(b"\n\x00" as *const u8 as *const libc::c_char); + if !name.is_null() { free(name as *mut libc::c_void); } + if !desc.is_null() { free(desc as *mut libc::c_void); } n = n.offset(1) } - crate::stdlib::snd_device_name_free_hint(hints); + snd_device_name_free_hint(hints); } - crate::stdlib::printf(b"\n\x00" as *const u8 as *const libc::c_char); + printf(b"\n\x00" as *const u8 as *const libc::c_char); } #[no_mangle] - pub unsafe extern "C" fn list_mixers(mut output_device: *const libc::c_char) { let mut err: libc::c_int = 0; - let mut handle = 0 as *mut crate::stdlib::snd_mixer_t; - let mut sid = 0 as *mut crate::stdlib::snd_mixer_selem_id_t; - let mut elem = 0 as *mut crate::stdlib::snd_mixer_elem_t; - let mut ctl = ctl4device(output_device); - let mut fresh0 = ::std::vec::from_elem(0, crate::stdlib::snd_mixer_selem_id_sizeof() as usize); - sid = fresh0.as_mut_ptr() as *mut crate::stdlib::snd_mixer_selem_id_t; - crate::stdlib::memset( - sid as *mut libc::c_void, - 0 as libc::c_int, - crate::stdlib::snd_mixer_selem_id_sizeof(), - ); - 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 listing mixers for: %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"list_mixers\x00")).as_ptr(), - 139 as libc::c_int, - output_device, - ); + let mut handle: *mut snd_mixer_t = 0 as *mut snd_mixer_t; + let mut sid: *mut snd_mixer_selem_id_t = 0 as *mut snd_mixer_selem_id_t; + let mut elem: *mut snd_mixer_elem_t = 0 as *mut snd_mixer_elem_t; + let mut ctl: *mut libc::c_char = ctl4device(output_device); + let mut fresh0 = + ::std::vec::from_elem(0, snd_mixer_selem_id_sizeof() as usize); + sid = fresh0.as_mut_ptr() as *mut snd_mixer_selem_id_t; + memset(sid as *mut libc::c_void, 0 as libc::c_int, + snd_mixer_selem_id_sizeof()); + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d listing mixers for: %s\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 12], + &[libc::c_char; 12]>(b"list_mixers\x00")).as_ptr(), + 139 as libc::c_int, output_device); } - err = crate::stdlib::snd_mixer_open(&mut handle, 0 as libc::c_int); + err = snd_mixer_open(&mut handle, 0 as libc::c_int); if err < 0 as libc::c_int { - crate::src::utils::logprint( - b"%s %s:%d open 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"list_mixers\x00")).as_ptr(), - 142 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); - return; + logprint(b"%s %s:%d open error: %s\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 12], + &[libc::c_char; 12]>(b"list_mixers\x00")).as_ptr(), + 142 as libc::c_int, snd_strerror(err)); + return } - err = crate::stdlib::snd_mixer_attach(handle, ctl); + err = snd_mixer_attach(handle, ctl); if err < 0 as libc::c_int { - crate::src::utils::logprint( - b"%s %s:%d attach 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"list_mixers\x00")).as_ptr(), - 146 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); - crate::stdlib::snd_mixer_close(handle); - crate::stdlib::free(ctl as *mut libc::c_void); - return; + logprint(b"%s %s:%d attach error: %s\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 12], + &[libc::c_char; 12]>(b"list_mixers\x00")).as_ptr(), + 146 as libc::c_int, snd_strerror(err)); + snd_mixer_close(handle); + free(ctl as *mut libc::c_void); + return } - crate::stdlib::free(ctl as *mut libc::c_void); - err = crate::stdlib::snd_mixer_selem_register( - handle, - 0 as *mut crate::stdlib::snd_mixer_selem_regopt, - 0 as *mut *mut crate::stdlib::snd_mixer_class_t, - ); + free(ctl as *mut libc::c_void); + err = + snd_mixer_selem_register(handle, 0 as *mut snd_mixer_selem_regopt, + 0 as *mut *mut snd_mixer_class_t); if err < 0 as libc::c_int { - crate::src::utils::logprint( - b"%s %s:%d register 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"list_mixers\x00")).as_ptr(), - 153 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); - crate::stdlib::snd_mixer_close(handle); - return; + logprint(b"%s %s:%d register error: %s\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 12], + &[libc::c_char; 12]>(b"list_mixers\x00")).as_ptr(), + 153 as libc::c_int, snd_strerror(err)); + snd_mixer_close(handle); + return } - err = crate::stdlib::snd_mixer_load(handle); + err = snd_mixer_load(handle); if err < 0 as libc::c_int { - crate::src::utils::logprint( - b"%s %s:%d load 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"list_mixers\x00")).as_ptr(), - 158 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); - crate::stdlib::snd_mixer_close(handle); - return; + logprint(b"%s %s:%d load error: %s\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 12], + &[libc::c_char; 12]>(b"list_mixers\x00")).as_ptr(), + 158 as libc::c_int, snd_strerror(err)); + snd_mixer_close(handle); + return } - crate::stdlib::printf( - b"Volume controls for %s\n\x00" as *const u8 as *const libc::c_char, - output_device, - ); - elem = crate::stdlib::snd_mixer_first_elem(handle); + printf(b"Volume controls for %s\n\x00" as *const u8 as + *const libc::c_char, output_device); + elem = snd_mixer_first_elem(handle); while !elem.is_null() { - if crate::stdlib::snd_mixer_selem_has_playback_volume(elem) != 0 { - crate::stdlib::snd_mixer_selem_get_id(elem, sid); - crate::stdlib::printf( - b" %s\x00" as *const u8 as *const libc::c_char, - crate::stdlib::snd_mixer_selem_id_get_name(sid), - ); - if crate::stdlib::snd_mixer_selem_id_get_index(sid) != 0 { - crate::stdlib::printf( - b",%d\x00" as *const u8 as *const libc::c_char, - crate::stdlib::snd_mixer_selem_id_get_index(sid), - ); + if snd_mixer_selem_has_playback_volume(elem) != 0 { + snd_mixer_selem_get_id(elem, sid); + printf(b" %s\x00" as *const u8 as *const libc::c_char, + snd_mixer_selem_id_get_name(sid)); + if snd_mixer_selem_id_get_index(sid) != 0 { + printf(b",%d\x00" as *const u8 as *const libc::c_char, + snd_mixer_selem_id_get_index(sid)); } - crate::stdlib::printf(b"\n\x00" as *const u8 as *const libc::c_char); + printf(b"\n\x00" as *const u8 as *const libc::c_char); } - elem = crate::stdlib::snd_mixer_elem_next(elem) + elem = snd_mixer_elem_next(elem) } - crate::stdlib::printf(b"\n\x00" as *const u8 as *const libc::c_char); - crate::stdlib::snd_mixer_close(handle); + printf(b"\n\x00" as *const u8 as *const libc::c_char); + snd_mixer_close(handle); } // LMS volume map for SqueezePlay sends values in range ~ -72..0 dB - -unsafe extern "C" fn set_mixer(mut setmax: bool, mut ldB: libc::c_float, mut rdB: libc::c_float) { +unsafe extern "C" fn set_mixer(mut setmax: bool, mut ldB: libc::c_float, + mut rdB: libc::c_float) { let mut err: libc::c_int = 0; let mut nleft: libc::c_long = 0; let mut nright: libc::c_long = 0; @@ -559,331 +865,261 @@ unsafe extern "C" fn set_mixer(mut setmax: bool, mut ldB: libc::c_float, mut rdB rraw = alsa.mixer_max; lraw = rraw } else { - lraw = ((if ldB > -(72 as libc::c_int) as libc::c_float { - (72 as libc::c_int as libc::c_double) + crate::stdlib::floor(ldB as libc::c_double) - } else { - 0 as libc::c_int as libc::c_double - }) / 72 as libc::c_int as libc::c_double - * (alsa.mixer_max - alsa.mixer_min) as libc::c_double - + alsa.mixer_min as libc::c_double) as libc::c_long; - rraw = ((if rdB > -(72 as libc::c_int) as libc::c_float { - (72 as libc::c_int as libc::c_double) + crate::stdlib::floor(rdB as libc::c_double) - } else { - 0 as libc::c_int as libc::c_double - }) / 72 as libc::c_int as libc::c_double - * (alsa.mixer_max - alsa.mixer_min) as libc::c_double - + alsa.mixer_min as libc::c_double) as libc::c_long + lraw = + ((if ldB > -(72 as libc::c_int) as libc::c_float { + (72 as libc::c_int as libc::c_double) + + floor(ldB as libc::c_double) + } else { 0 as libc::c_int as libc::c_double }) / + 72 as libc::c_int as libc::c_double * + (alsa.mixer_max - alsa.mixer_min) as libc::c_double + + alsa.mixer_min as libc::c_double) as libc::c_long; + rraw = + ((if rdB > -(72 as libc::c_int) as libc::c_float { + (72 as libc::c_int as libc::c_double) + + floor(rdB as libc::c_double) + } else { 0 as libc::c_int as libc::c_double }) / + 72 as libc::c_int as libc::c_double * + (alsa.mixer_max - alsa.mixer_min) as libc::c_double + + alsa.mixer_min as libc::c_double) as libc::c_long } - 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 setting vol raw [%ld..%ld]\n\x00" as *const u8 as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 10], &[libc::c_char; 10]>(b"set_mixer\x00")) - .as_ptr(), - 193 as libc::c_int, - alsa.mixer_min, - alsa.mixer_max, - ); + if loglevel as libc::c_uint >= lDEBUG as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d setting vol raw [%ld..%ld]\n\x00" as *const u8 + as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 10], + &[libc::c_char; 10]>(b"set_mixer\x00")).as_ptr(), + 193 as libc::c_int, alsa.mixer_min, alsa.mixer_max); } - err = crate::stdlib::snd_mixer_selem_set_playback_volume( - alsa.mixer_elem, - crate::stdlib::SND_MIXER_SCHN_FRONT_LEFT, - lraw, - ); + err = + snd_mixer_selem_set_playback_volume(alsa.mixer_elem, + SND_MIXER_SCHN_FRONT_LEFT, + lraw); if err < 0 as libc::c_int { - crate::src::utils::logprint( - b"%s %s:%d error setting left volume: %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"set_mixer\x00")) - .as_ptr(), - 195 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); + logprint(b"%s %s:%d error setting left volume: %s\n\x00" as + *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 10], + &[libc::c_char; 10]>(b"set_mixer\x00")).as_ptr(), + 195 as libc::c_int, snd_strerror(err)); } - err = crate::stdlib::snd_mixer_selem_set_playback_volume( - alsa.mixer_elem, - crate::stdlib::SND_MIXER_SCHN_FRONT_RIGHT, - rraw, - ); + err = + snd_mixer_selem_set_playback_volume(alsa.mixer_elem, + SND_MIXER_SCHN_FRONT_RIGHT, + rraw); if err < 0 as libc::c_int { - crate::src::utils::logprint( - b"%s %s:%d error setting right volume: %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"set_mixer\x00")) - .as_ptr(), - 198 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); + logprint(b"%s %s:%d error setting right volume: %s\n\x00" as + *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 10], + &[libc::c_char; 10]>(b"set_mixer\x00")).as_ptr(), + 198 as libc::c_int, snd_strerror(err)); } } else { // set db directly - 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 setting vol dB [%ld..%ld]\n\x00" as *const u8 as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 10], &[libc::c_char; 10]>(b"set_mixer\x00")) - .as_ptr(), - 202 as libc::c_int, - alsa.mixer_min, - alsa.mixer_max, - ); + if loglevel as libc::c_uint >= lDEBUG as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d setting vol dB [%ld..%ld]\n\x00" as *const u8 + as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 10], + &[libc::c_char; 10]>(b"set_mixer\x00")).as_ptr(), + 202 as libc::c_int, alsa.mixer_min, alsa.mixer_max); } if setmax { // set to 0dB if available as this should be max volume for music recored at max pcm values - if alsa.mixer_max >= 0 as libc::c_int as libc::c_long - && alsa.mixer_min <= 0 as libc::c_int as libc::c_long - { + if alsa.mixer_max >= 0 as libc::c_int as libc::c_long && + alsa.mixer_min <= 0 as libc::c_int as libc::c_long { rdB = 0 as libc::c_int as libc::c_float; ldB = rdB - } else { - rdB = alsa.mixer_max as libc::c_float; - ldB = rdB - } + } else { rdB = alsa.mixer_max as libc::c_float; ldB = rdB } } - err = crate::stdlib::snd_mixer_selem_set_playback_dB( - alsa.mixer_elem, - crate::stdlib::SND_MIXER_SCHN_FRONT_LEFT, - (100 as libc::c_int as libc::c_float * ldB) as libc::c_long, - 1 as libc::c_int, - ); + err = + snd_mixer_selem_set_playback_dB(alsa.mixer_elem, + SND_MIXER_SCHN_FRONT_LEFT, + (100 as libc::c_int as + libc::c_float * ldB) as + libc::c_long, + 1 as libc::c_int); if err < 0 as libc::c_int { - crate::src::utils::logprint( - b"%s %s:%d error setting left volume: %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"set_mixer\x00")) - .as_ptr(), - 212 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); + logprint(b"%s %s:%d error setting left volume: %s\n\x00" as + *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 10], + &[libc::c_char; 10]>(b"set_mixer\x00")).as_ptr(), + 212 as libc::c_int, snd_strerror(err)); } - err = crate::stdlib::snd_mixer_selem_set_playback_dB( - alsa.mixer_elem, - crate::stdlib::SND_MIXER_SCHN_FRONT_RIGHT, - (100 as libc::c_int as libc::c_float * rdB) as libc::c_long, - 1 as libc::c_int, - ); + err = + snd_mixer_selem_set_playback_dB(alsa.mixer_elem, + SND_MIXER_SCHN_FRONT_RIGHT, + (100 as libc::c_int as + libc::c_float * rdB) as + libc::c_long, + 1 as libc::c_int); if err < 0 as libc::c_int { - crate::src::utils::logprint( - b"%s %s:%d error setting right volume: %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"set_mixer\x00")) - .as_ptr(), - 215 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); + logprint(b"%s %s:%d error setting right volume: %s\n\x00" as + *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 10], + &[libc::c_char; 10]>(b"set_mixer\x00")).as_ptr(), + 215 as libc::c_int, snd_strerror(err)); } } - err = crate::stdlib::snd_mixer_selem_get_playback_volume( - alsa.mixer_elem, - crate::stdlib::SND_MIXER_SCHN_FRONT_LEFT, - &mut nleft, - ); + err = + snd_mixer_selem_get_playback_volume(alsa.mixer_elem, + SND_MIXER_SCHN_FRONT_LEFT, + &mut nleft); if err < 0 as libc::c_int { - crate::src::utils::logprint( - b"%s %s:%d error getting left vol: %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"set_mixer\x00")).as_ptr(), - 220 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); + logprint(b"%s %s:%d error getting left vol: %s\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 10], + &[libc::c_char; 10]>(b"set_mixer\x00")).as_ptr(), + 220 as libc::c_int, snd_strerror(err)); } - err = crate::stdlib::snd_mixer_selem_get_playback_volume( - alsa.mixer_elem, - crate::stdlib::SND_MIXER_SCHN_FRONT_RIGHT, - &mut nright, - ); + err = + snd_mixer_selem_get_playback_volume(alsa.mixer_elem, + SND_MIXER_SCHN_FRONT_RIGHT, + &mut nright); if err < 0 as libc::c_int { - crate::src::utils::logprint( - b"%s %s:%d error getting right vol: %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"set_mixer\x00")).as_ptr(), - 223 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); + logprint(b"%s %s:%d error getting right vol: %s\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 10], + &[libc::c_char; 10]>(b"set_mixer\x00")).as_ptr(), + 223 as libc::c_int, snd_strerror(err)); } - 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 %s left: %3.1fdB -> %ld right: %3.1fdB -> %ld\n\x00" as *const u8 - as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 10], &[libc::c_char; 10]>(b"set_mixer\x00")).as_ptr(), - 226 as libc::c_int, - alsa.volume_mixer_name, - ldB as libc::c_double, - nleft, - rdB as libc::c_double, - nright, - ); + if loglevel as libc::c_uint >= lDEBUG as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d %s left: %3.1fdB -> %ld right: %3.1fdB -> %ld\n\x00" + as *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 10], + &[libc::c_char; 10]>(b"set_mixer\x00")).as_ptr(), + 226 as libc::c_int, alsa.volume_mixer_name, + ldB as libc::c_double, nleft, rdB as libc::c_double, nright); }; } #[no_mangle] - -pub unsafe extern "C" fn set_volume(mut left: libc::c_uint, mut right: libc::c_uint) { +pub unsafe extern "C" fn set_volume(mut left: libc::c_uint, + mut right: libc::c_uint) { let mut ldB: libc::c_float = 0.; let mut rdB: libc::c_float = 0.; if alsa.volume_mixer_name.is_null() { - 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 setting internal gain left: %u right: %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"set_volume\x00")) - .as_ptr(), - 233 as libc::c_int, - left, - right, - ); + if loglevel as libc::c_uint >= lDEBUG as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d setting internal gain left: %u right: %u\n\x00" + as *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 11], + &[libc::c_char; 11]>(b"set_volume\x00")).as_ptr(), + 233 as libc::c_int, left, right); } - crate::stdlib::pthread_mutex_lock(&mut (*outputbuf).mutex); + pthread_mutex_lock(&mut (*outputbuf).mutex); output.gainL = left; output.gainR = right; - crate::stdlib::pthread_mutex_unlock(&mut (*outputbuf).mutex); - return; + pthread_mutex_unlock(&mut (*outputbuf).mutex); + return } else { - crate::stdlib::pthread_mutex_lock(&mut (*outputbuf).mutex); - output.gainL = 0x10000 as libc::c_int as crate::squeezelite_h::u32_t; - output.gainR = 0x10000 as libc::c_int as crate::squeezelite_h::u32_t; - crate::stdlib::pthread_mutex_unlock(&mut (*outputbuf).mutex); + pthread_mutex_lock(&mut (*outputbuf).mutex); + output.gainL = 0x10000 as libc::c_int as u32_t; + output.gainR = 0x10000 as libc::c_int as u32_t; + pthread_mutex_unlock(&mut (*outputbuf).mutex); } // convert 16.16 fixed point to dB - ldB = (20 as libc::c_int as libc::c_double - * crate::stdlib::log10((left as libc::c_float / 65536.0f32) as libc::c_double)) - as libc::c_float; - rdB = (20 as libc::c_int as libc::c_double - * crate::stdlib::log10((right as libc::c_float / 65536.0f32) as libc::c_double)) - as libc::c_float; + ldB = + (20 as libc::c_int as libc::c_double * + log10((left as libc::c_float / 65536.0f32) as libc::c_double)) as + libc::c_float; + rdB = + (20 as libc::c_int as libc::c_double * + log10((right as libc::c_float / 65536.0f32) as libc::c_double)) + as libc::c_float; set_mixer(0 as libc::c_int != 0, ldB, rdB); } - -unsafe extern "C" fn alsa_error_handler( - mut file: *const libc::c_char, - mut line: libc::c_int, - mut function: *const libc::c_char, - mut err: libc::c_int, - mut fmt: *const libc::c_char, - mut args: ... -) -> *mut libc::c_void { +unsafe extern "C" fn alsa_error_handler(mut file: *const libc::c_char, + mut line: libc::c_int, + mut function: *const libc::c_char, + mut err: libc::c_int, + mut fmt: *const libc::c_char, + mut args: ...) -> *mut libc::c_void { let mut args_0: ::std::ffi::VaListImpl; - if loglevel as libc::c_uint >= crate::squeezelite_h::lINFO as libc::c_int as libc::c_uint - && err == 0 as libc::c_int - || loglevel as libc::c_uint >= crate::squeezelite_h::lDEBUG as libc::c_int as libc::c_uint - { - crate::stdlib::fprintf( - crate::stdlib::stderr, - b"%s ALSA %s:%d \x00" as *const u8 as *const libc::c_char, - crate::src::utils::logtime(), - function, - line, - ); + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint && + err == 0 as libc::c_int || + loglevel as libc::c_uint >= lDEBUG as libc::c_int as libc::c_uint { + fprintf(stderr, + b"%s ALSA %s:%d \x00" as *const u8 as *const libc::c_char, + logtime(), function, line); args_0 = args.clone(); - crate::stdlib::vfprintf(crate::stdlib::stderr, fmt, args_0.as_va_list()); - crate::stdlib::fprintf( - crate::stdlib::stderr, - b"\n\x00" as *const u8 as *const libc::c_char, - ); - crate::stdlib::fflush(crate::stdlib::stderr); + vfprintf(stderr, fmt, args_0.as_va_list()); + fprintf(stderr, b"\n\x00" as *const u8 as *const libc::c_char); + fflush(stderr); } return 0 as *mut libc::c_void; } - unsafe extern "C" fn alsa_close() { let mut err: libc::c_int = 0; - err = crate::stdlib::snd_pcm_close(pcmp); + err = snd_pcm_close(pcmp); if err < 0 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 snd_pcm_close 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"alsa_close\x00")) - .as_ptr(), - 268 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d snd_pcm_close error: %s\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 11], + &[libc::c_char; 11]>(b"alsa_close\x00")).as_ptr(), + 268 as libc::c_int, snd_strerror(err)); } }; } #[no_mangle] - -pub unsafe extern "C" fn test_open( - mut device: *const libc::c_char, - mut rates: *mut libc::c_uint, - mut userdef_rates: bool, -) -> bool { +pub unsafe extern "C" fn test_open(mut device: *const libc::c_char, + mut rates: *mut libc::c_uint, + mut userdef_rates: bool) -> bool { let mut err: libc::c_int = 0; - let mut pcm = 0 as *mut crate::stdlib::snd_pcm_t; - let mut hw_params = 0 as *mut crate::stdlib::snd_pcm_hw_params_t; - let mut fresh1 = ::std::vec::from_elem(0, crate::stdlib::snd_pcm_hw_params_sizeof() as usize); - hw_params = fresh1.as_mut_ptr() as *mut crate::stdlib::snd_pcm_hw_params_t; - crate::stdlib::memset( - hw_params as *mut libc::c_void, - 0 as libc::c_int, - crate::stdlib::snd_pcm_hw_params_sizeof(), - ); + let mut pcm: *mut snd_pcm_t = 0 as *mut snd_pcm_t; + let mut hw_params: *mut snd_pcm_hw_params_t = + 0 as *mut snd_pcm_hw_params_t; + let mut fresh1 = + ::std::vec::from_elem(0, snd_pcm_hw_params_sizeof() as usize); + hw_params = fresh1.as_mut_ptr() as *mut snd_pcm_hw_params_t; + memset(hw_params as *mut libc::c_void, 0 as libc::c_int, + snd_pcm_hw_params_sizeof()); // open device - err = crate::stdlib::snd_pcm_open( - &mut pcm, - device, - crate::stdlib::SND_PCM_STREAM_PLAYBACK, - 0 as libc::c_int, - ); + err = + snd_pcm_open(&mut pcm, device, SND_PCM_STREAM_PLAYBACK, + 0 as libc::c_int); if err < 0 as libc::c_int { - crate::src::utils::logprint( - b"%s %s:%d playback open error: %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"test_open\x00")).as_ptr(), - 281 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); - return 0 as libc::c_int != 0; + logprint(b"%s %s:%d playback open error: %s\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 10], + &[libc::c_char; 10]>(b"test_open\x00")).as_ptr(), + 281 as libc::c_int, snd_strerror(err)); + return 0 as libc::c_int != 0 } // get max params - err = crate::stdlib::snd_pcm_hw_params_any(pcm, hw_params); + err = snd_pcm_hw_params_any(pcm, hw_params); if err < 0 as libc::c_int { - crate::src::utils::logprint( - b"%s %s:%d hwparam init error: %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"test_open\x00")).as_ptr(), - 287 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); - return 0 as libc::c_int != 0; + logprint(b"%s %s:%d hwparam init error: %s\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 10], + &[libc::c_char; 10]>(b"test_open\x00")).as_ptr(), + 287 as libc::c_int, snd_strerror(err)); + return 0 as libc::c_int != 0 } // find supported sample rates to enable client side resampling of non supported rates if !userdef_rates { let mut i: libc::c_uint = 0; let mut ind: libc::c_uint = 0; - let mut ref_0: [libc::c_uint; 18] = [ - 768000 as libc::c_int as libc::c_uint, - 705600 as libc::c_int as libc::c_uint, - 384000 as libc::c_int as libc::c_uint, - 352800 as libc::c_int as libc::c_uint, - 192000 as libc::c_int as libc::c_uint, - 176400 as libc::c_int as libc::c_uint, - 96000 as libc::c_int as libc::c_uint, - 88200 as libc::c_int as libc::c_uint, - 48000 as libc::c_int as libc::c_uint, - 44100 as libc::c_int as libc::c_uint, - 32000 as libc::c_int as libc::c_uint, - 24000 as libc::c_int as libc::c_uint, - 22500 as libc::c_int as libc::c_uint, - 16000 as libc::c_int as libc::c_uint, - 12000 as libc::c_int as libc::c_uint, - 11025 as libc::c_int as libc::c_uint, - 8000 as libc::c_int as libc::c_uint, - 0 as libc::c_int as libc::c_uint, - ]; + let mut ref_0: [libc::c_uint; 18] = + [768000 as libc::c_int as libc::c_uint, + 705600 as libc::c_int as libc::c_uint, + 384000 as libc::c_int as libc::c_uint, + 352800 as libc::c_int as libc::c_uint, + 192000 as libc::c_int as libc::c_uint, + 176400 as libc::c_int as libc::c_uint, + 96000 as libc::c_int as libc::c_uint, + 88200 as libc::c_int as libc::c_uint, + 48000 as libc::c_int as libc::c_uint, + 44100 as libc::c_int as libc::c_uint, + 32000 as libc::c_int as libc::c_uint, + 24000 as libc::c_int as libc::c_uint, + 22500 as libc::c_int as libc::c_uint, + 16000 as libc::c_int as libc::c_uint, + 12000 as libc::c_int as libc::c_uint, + 11025 as libc::c_int as libc::c_uint, + 8000 as libc::c_int as libc::c_uint, + 0 as libc::c_int as libc::c_uint]; i = 0 as libc::c_int as libc::c_uint; ind = 0 as libc::c_int as libc::c_uint; while ref_0[i as usize] != 0 { - if crate::stdlib::snd_pcm_hw_params_test_rate( - pcm, - hw_params, - ref_0[i as usize], - 0 as libc::c_int, - ) == 0 as libc::c_int - { + if snd_pcm_hw_params_test_rate(pcm, hw_params, ref_0[i as usize], + 0 as libc::c_int) == + 0 as libc::c_int { let fresh2 = ind; ind = ind.wrapping_add(1); *rates.offset(fresh2 as isize) = ref_0[i as usize] @@ -891,925 +1127,707 @@ pub unsafe extern "C" fn test_open( i = i.wrapping_add(1) } } - err = crate::stdlib::snd_pcm_close(pcm); + err = snd_pcm_close(pcm); if err < 0 as libc::c_int { - crate::src::utils::logprint( - b"%s %s:%d snd_pcm_close error: %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"test_open\x00")).as_ptr(), - 304 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); - return 0 as libc::c_int != 0; + logprint(b"%s %s:%d snd_pcm_close error: %s\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 10], + &[libc::c_char; 10]>(b"test_open\x00")).as_ptr(), + 304 as libc::c_int, snd_strerror(err)); + return 0 as libc::c_int != 0 } return 1 as libc::c_int != 0; } - unsafe extern "C" fn pcm_probe(mut device: *const libc::c_char) -> bool { let mut err: libc::c_int = 0; - let mut pcm = 0 as *mut crate::stdlib::snd_pcm_t; - err = crate::stdlib::snd_pcm_open( - &mut pcm, - device, - crate::stdlib::SND_PCM_STREAM_PLAYBACK, - 0 as libc::c_int, - ); + let mut pcm: *mut snd_pcm_t = 0 as *mut snd_pcm_t; + err = + snd_pcm_open(&mut pcm, device, SND_PCM_STREAM_PLAYBACK, + 0 as libc::c_int); + if err < 0 as libc::c_int { return 0 as libc::c_int != 0 } + err = snd_pcm_close(pcm); if err < 0 as libc::c_int { - return 0 as libc::c_int != 0; - } - err = crate::stdlib::snd_pcm_close(pcm); - if err < 0 as libc::c_int { - crate::src::utils::logprint( - b"%s %s:%d snd_pcm_close error: %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"pcm_probe\x00")).as_ptr(), - 320 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); + logprint(b"%s %s:%d snd_pcm_close error: %s\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 10], + &[libc::c_char; 10]>(b"pcm_probe\x00")).as_ptr(), + 320 as libc::c_int, snd_strerror(err)); } return 1 as libc::c_int != 0; } - -unsafe extern "C" fn alsa_open( - mut device: *const libc::c_char, - mut sample_rate: libc::c_uint, - mut alsa_buffer: libc::c_uint, - mut alsa_period: libc::c_uint, -) -> libc::c_int { +unsafe extern "C" fn alsa_open(mut device: *const libc::c_char, + mut sample_rate: libc::c_uint, + mut alsa_buffer: libc::c_uint, + mut alsa_period: libc::c_uint) -> libc::c_int { let mut err: libc::c_int = 0; - let mut hw_params = 0 as *mut crate::stdlib::snd_pcm_hw_params_t; - let mut fresh3 = ::std::vec::from_elem(0, crate::stdlib::snd_pcm_hw_params_sizeof() as usize); - hw_params = fresh3.as_mut_ptr() as *mut crate::stdlib::snd_pcm_hw_params_t; - crate::stdlib::memset( - hw_params as *mut libc::c_void, - 0 as libc::c_int, - crate::stdlib::snd_pcm_hw_params_sizeof(), - ); + let mut hw_params: *mut snd_pcm_hw_params_t = + 0 as *mut snd_pcm_hw_params_t; + let mut fresh3 = + ::std::vec::from_elem(0, snd_pcm_hw_params_sizeof() as usize); + hw_params = fresh3.as_mut_ptr() as *mut snd_pcm_hw_params_t; + memset(hw_params as *mut libc::c_void, 0 as libc::c_int, + snd_pcm_hw_params_sizeof()); // close if already open - if !pcmp.is_null() { - alsa_close(); - } + if !pcmp.is_null() { alsa_close(); } // reset params alsa.rate = 0 as libc::c_int as libc::c_uint; - alsa.period_size = 0 as libc::c_int as crate::stdlib::snd_pcm_uframes_t; - crate::stdlib::strcpy(alsa.device.as_mut_ptr(), device); - if crate::stdlib::strlen(device) - > (128 as libc::c_int - 4 as libc::c_int - 1 as libc::c_int) as libc::c_ulong - { - crate::src::utils::logprint( - b"%s %s:%d device name too long: %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"alsa_open\x00")).as_ptr(), - 347 as libc::c_int, - device, - ); - return -(1 as libc::c_int); + alsa.period_size = 0 as libc::c_int as snd_pcm_uframes_t; + strcpy(alsa.device.as_mut_ptr(), device); + if strlen(device) > + (128 as libc::c_int - 4 as libc::c_int - 1 as libc::c_int) as + libc::c_ulong { + logprint(b"%s %s:%d device name too long: %s\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 10], + &[libc::c_char; 10]>(b"alsa_open\x00")).as_ptr(), + 347 as libc::c_int, device); + return -(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 opening device at: %u\n\x00" as *const u8 as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 10], &[libc::c_char; 10]>(b"alsa_open\x00")).as_ptr(), - 351 as libc::c_int, - sample_rate, - ); + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d opening device at: %u\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 10], + &[libc::c_char; 10]>(b"alsa_open\x00")).as_ptr(), + 351 as libc::c_int, sample_rate); } let mut retry: bool = false; - loop { + loop { // open device - err = crate::stdlib::snd_pcm_open( - &mut pcmp, - alsa.device.as_mut_ptr(), - crate::stdlib::SND_PCM_STREAM_PLAYBACK, - 0 as libc::c_int, - ); + err = + snd_pcm_open(&mut pcmp, alsa.device.as_mut_ptr(), + SND_PCM_STREAM_PLAYBACK, 0 as libc::c_int); if err < 0 as libc::c_int { - crate::src::utils::logprint( - b"%s %s:%d playback open error: %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"alsa_open\x00")) - .as_ptr(), - 357 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); - return err; + logprint(b"%s %s:%d playback open error: %s\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 10], + &[libc::c_char; 10]>(b"alsa_open\x00")).as_ptr(), + 357 as libc::c_int, snd_strerror(err)); + return err } // init params - crate::stdlib::memset( - hw_params as *mut libc::c_void, - 0 as libc::c_int, - crate::stdlib::snd_pcm_hw_params_sizeof(), - ); - err = crate::stdlib::snd_pcm_hw_params_any(pcmp, hw_params); + memset(hw_params as *mut libc::c_void, 0 as libc::c_int, + snd_pcm_hw_params_sizeof()); + err = snd_pcm_hw_params_any(pcmp, hw_params); if err < 0 as libc::c_int { - crate::src::utils::logprint( - b"%s %s:%d hwparam init error: %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"alsa_open\x00")) - .as_ptr(), - 364 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); - return err; + logprint(b"%s %s:%d hwparam init error: %s\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 10], + &[libc::c_char; 10]>(b"alsa_open\x00")).as_ptr(), + 364 as libc::c_int, snd_strerror(err)); + return err } // open hw: devices without resampling, if sample rate fails try plughw: with resampling - let mut hw = crate::stdlib::strncmp( - alsa.device.as_mut_ptr(), - b"hw:\x00" as *const u8 as *const libc::c_char, - 3 as libc::c_int as libc::c_ulong, - ) == 0; + let mut hw: bool = + strncmp(alsa.device.as_mut_ptr(), + b"hw:\x00" as *const u8 as *const libc::c_char, + 3 as libc::c_int as libc::c_ulong) == 0; retry = 0 as libc::c_int != 0; - err = crate::stdlib::snd_pcm_hw_params_set_rate_resample( - pcmp, - hw_params, - !hw as libc::c_int as libc::c_uint, - ); + err = + snd_pcm_hw_params_set_rate_resample(pcmp, hw_params, + !hw as libc::c_int as + libc::c_uint); if err < 0 as libc::c_int { - crate::src::utils::logprint( - b"%s %s:%d resampling setup failed: %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"alsa_open\x00")) - .as_ptr(), - 373 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); - return err; + logprint(b"%s %s:%d resampling setup failed: %s\n\x00" as + *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 10], + &[libc::c_char; 10]>(b"alsa_open\x00")).as_ptr(), + 373 as libc::c_int, snd_strerror(err)); + return err } - err = crate::stdlib::snd_pcm_hw_params_set_rate( - pcmp, - hw_params, - sample_rate, - 0 as libc::c_int, - ); + err = + snd_pcm_hw_params_set_rate(pcmp, hw_params, sample_rate, + 0 as libc::c_int); if err < 0 as libc::c_int { if hw { - crate::stdlib::strcpy( - alsa.device.as_mut_ptr().offset(4 as libc::c_int as isize), - device, - ); - crate::stdlib::memcpy( - alsa.device.as_mut_ptr() as *mut libc::c_void, - b"plug\x00" as *const u8 as *const libc::c_char as *const libc::c_void, - 4 as libc::c_int as libc::c_ulong, - ); - 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 reopening device %s in plug mode as %s for resampling\n\x00" - as *const u8 as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 10], &[libc::c_char; 10]>( - b"alsa_open\x00", - )) - .as_ptr(), - 381 as libc::c_int, - device, - alsa.device.as_mut_ptr(), - ); + strcpy(alsa.device.as_mut_ptr().offset(4 as libc::c_int as + isize), device); + memcpy(alsa.device.as_mut_ptr() as *mut libc::c_void, + b"plug\x00" as *const u8 as *const libc::c_char as + *const libc::c_void, + 4 as libc::c_int as libc::c_ulong); + if loglevel as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d reopening device %s in plug mode as %s for resampling\n\x00" + as *const u8 as *const libc::c_char, + logtime(), + (*::std::mem::transmute::<&[u8; 10], + &[libc::c_char; 10]>(b"alsa_open\x00")).as_ptr(), + 381 as libc::c_int, device, + alsa.device.as_mut_ptr()); } - crate::stdlib::snd_pcm_close(pcmp); + snd_pcm_close(pcmp); retry = 1 as libc::c_int != 0 } } - if !retry { - break; - } + if !retry { break ; } } - // set access - if !alsa.mmap - || crate::stdlib::snd_pcm_hw_params_set_access( - pcmp, - hw_params, - crate::stdlib::SND_PCM_ACCESS_MMAP_INTERLEAVED, - ) < 0 as libc::c_int - { - err = crate::stdlib::snd_pcm_hw_params_set_access( - pcmp, - hw_params, - crate::stdlib::SND_PCM_ACCESS_RW_INTERLEAVED, - ); + // set access + if !alsa.mmap || + snd_pcm_hw_params_set_access(pcmp, hw_params, + SND_PCM_ACCESS_MMAP_INTERLEAVED) < + 0 as libc::c_int { + err = + snd_pcm_hw_params_set_access(pcmp, hw_params, + SND_PCM_ACCESS_RW_INTERLEAVED); if err < 0 as libc::c_int { - crate::src::utils::logprint( - b"%s %s:%d access type not available: %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"alsa_open\x00")) - .as_ptr(), - 392 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); - return err; + logprint(b"%s %s:%d access type not available: %s\n\x00" as + *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 10], + &[libc::c_char; 10]>(b"alsa_open\x00")).as_ptr(), + 392 as libc::c_int, snd_strerror(err)); + return err } alsa.mmap = 0 as libc::c_int != 0 } // set the sample format - let mut fmt = if alsa.format as libc::c_int != 0 { - &mut alsa.format - } else { - fmts.as_mut_ptr() - }; - loop { - if crate::stdlib::snd_pcm_hw_params_set_format(pcmp, hw_params, *fmt) >= 0 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 opened device %s using format: %s sample rate: %u mmap: %u\n\x00" - as *const u8 as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 10], &[libc::c_char; 10]>(b"alsa_open\x00")) - .as_ptr(), - 422 as libc::c_int, - alsa.device.as_mut_ptr(), - crate::stdlib::snd_pcm_format_name(*fmt), - sample_rate, - alsa.mmap as libc::c_int, - ); + let mut fmt: *mut snd_pcm_format_t = + if alsa.format as libc::c_int != 0 { + &mut alsa.format + } else { fmts.as_mut_ptr() }; + loop { + if snd_pcm_hw_params_set_format(pcmp, hw_params, *fmt) >= + 0 as libc::c_int { + if loglevel as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d opened device %s using format: %s sample rate: %u mmap: %u\n\x00" + as *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 10], + &[libc::c_char; 10]>(b"alsa_open\x00")).as_ptr(), + 422 as libc::c_int, alsa.device.as_mut_ptr(), + snd_pcm_format_name(*fmt), sample_rate, + alsa.mmap as libc::c_int); } alsa.format = *fmt; - break; + break ; } else { if alsa.format as u64 != 0 { - crate::src::utils::logprint( - b"%s %s:%d unable to open audio device requested format: %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"alsa_open\x00")) - .as_ptr(), - 427 as libc::c_int, - crate::stdlib::snd_pcm_format_name(alsa.format), - ); - return -(1 as libc::c_int); + logprint(b"%s %s:%d unable to open audio device requested format: %s\n\x00" + as *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 10], + &[libc::c_char; 10]>(b"alsa_open\x00")).as_ptr(), + 427 as libc::c_int, + snd_pcm_format_name(alsa.format)); + return -(1 as libc::c_int) } fmt = fmt.offset(1); - if *fmt as libc::c_int == crate::stdlib::SND_PCM_FORMAT_UNKNOWN as libc::c_int { - crate::src::utils::logprint( - b"%s %s:%d unable to open audio device with any supported format\n\x00" - as *const u8 as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 10], &[libc::c_char; 10]>(b"alsa_open\x00")) - .as_ptr(), - 432 as libc::c_int, - ); - return -(1 as libc::c_int); + if *fmt as libc::c_int == SND_PCM_FORMAT_UNKNOWN as libc::c_int { + logprint(b"%s %s:%d unable to open audio device with any supported format\n\x00" + as *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 10], + &[libc::c_char; 10]>(b"alsa_open\x00")).as_ptr(), + 432 as libc::c_int); + return -(1 as libc::c_int) } - if !(*fmt as libc::c_int != crate::stdlib::SND_PCM_FORMAT_UNKNOWN as libc::c_int) { - break; + if !(*fmt as libc::c_int != SND_PCM_FORMAT_UNKNOWN as libc::c_int) + { + break ; } } } // set the output format to be used by _scale_and_pack match alsa.format as libc::c_int { - 10 => output.format = crate::squeezelite_h::S32_LE, - 6 => output.format = crate::squeezelite_h::S24_LE, - 32 => output.format = crate::squeezelite_h::S24_3LE, - 2 => output.format = crate::squeezelite_h::S16_LE, - _ => {} + 10 => { output.format = S32_LE } + 6 => { output.format = S24_LE } + 32 => { output.format = S24_3LE } + 2 => { output.format = S16_LE } + _ => { } } // set channels - err = crate::stdlib::snd_pcm_hw_params_set_channels( - pcmp, - hw_params, - 2 as libc::c_int as libc::c_uint, - ); + err = + snd_pcm_hw_params_set_channels(pcmp, hw_params, + 2 as libc::c_int as libc::c_uint); if err < 0 as libc::c_int { - crate::src::utils::logprint( - b"%s %s:%d channel count not available: %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"alsa_open\x00")).as_ptr(), - 465 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); - return err; + logprint(b"%s %s:%d channel count not available: %s\n\x00" as + *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 10], + &[libc::c_char; 10]>(b"alsa_open\x00")).as_ptr(), + 465 as libc::c_int, snd_strerror(err)); + return err } // set period size - value of < 50 treated as period count, otherwise size in bytes if alsa_period < 50 as libc::c_int as libc::c_uint { - let mut count = alsa_period; - err = crate::stdlib::snd_pcm_hw_params_set_periods_near( - pcmp, - hw_params, - &mut count, - 0 as *mut libc::c_int, - ); + let mut count: libc::c_uint = alsa_period; + err = + snd_pcm_hw_params_set_periods_near(pcmp, hw_params, &mut count, + 0 as *mut libc::c_int); if err < 0 as libc::c_int { - crate::src::utils::logprint( - b"%s %s:%d unable to set period count %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"alsa_open\x00")) - .as_ptr(), - 473 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); - return err; + logprint(b"%s %s:%d unable to set period count %s\n\x00" as + *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 10], + &[libc::c_char; 10]>(b"alsa_open\x00")).as_ptr(), + 473 as libc::c_int, snd_strerror(err)); + return err } } else { - let mut size = alsa_period as crate::stdlib::snd_pcm_uframes_t; - let mut dir = 0 as libc::c_int; - err = crate::stdlib::snd_pcm_hw_params_set_period_size_near( - pcmp, hw_params, &mut size, &mut dir, - ); + let mut size: snd_pcm_uframes_t = alsa_period as snd_pcm_uframes_t; + let mut dir: libc::c_int = 0 as libc::c_int; + err = + snd_pcm_hw_params_set_period_size_near(pcmp, hw_params, &mut size, + &mut dir); if err < 0 as libc::c_int { - crate::src::utils::logprint( - b"%s %s:%d unable to set period size %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"alsa_open\x00")) - .as_ptr(), - 480 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); - return err; + logprint(b"%s %s:%d unable to set period size %s\n\x00" as + *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 10], + &[libc::c_char; 10]>(b"alsa_open\x00")).as_ptr(), + 480 as libc::c_int, snd_strerror(err)); + return err } } // set buffer size - value of < 500 treated as buffer time in ms, otherwise size in bytes if alsa_buffer < 500 as libc::c_int as libc::c_uint { - let mut time = alsa_buffer.wrapping_mul(1000 as libc::c_int as libc::c_uint); - let mut dir_0 = 0 as libc::c_int; - err = crate::stdlib::snd_pcm_hw_params_set_buffer_time_near( - pcmp, hw_params, &mut time, &mut dir_0, - ); + let mut time: libc::c_uint = + alsa_buffer.wrapping_mul(1000 as libc::c_int as libc::c_uint); + let mut dir_0: libc::c_int = 0 as libc::c_int; + err = + snd_pcm_hw_params_set_buffer_time_near(pcmp, hw_params, &mut time, + &mut dir_0); if err < 0 as libc::c_int { - crate::src::utils::logprint( - b"%s %s:%d unable to set buffer time %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"alsa_open\x00")) - .as_ptr(), - 490 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); - return err; + logprint(b"%s %s:%d unable to set buffer time %s\n\x00" as + *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 10], + &[libc::c_char; 10]>(b"alsa_open\x00")).as_ptr(), + 490 as libc::c_int, snd_strerror(err)); + return err } } else { - let mut size_0 = alsa_buffer as crate::stdlib::snd_pcm_uframes_t; - err = crate::stdlib::snd_pcm_hw_params_set_buffer_size_near(pcmp, hw_params, &mut size_0); + let mut size_0: snd_pcm_uframes_t = alsa_buffer as snd_pcm_uframes_t; + err = + snd_pcm_hw_params_set_buffer_size_near(pcmp, hw_params, + &mut size_0); if err < 0 as libc::c_int { - crate::src::utils::logprint( - b"%s %s:%d unable to set buffer size %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"alsa_open\x00")) - .as_ptr(), - 496 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); - return err; + logprint(b"%s %s:%d unable to set buffer size %s\n\x00" as + *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 10], + &[libc::c_char; 10]>(b"alsa_open\x00")).as_ptr(), + 496 as libc::c_int, snd_strerror(err)); + return err } } // get period_size - err = crate::stdlib::snd_pcm_hw_params_get_period_size( - hw_params, - &mut alsa.period_size, - 0 as *mut libc::c_int, - ); + err = + snd_pcm_hw_params_get_period_size(hw_params, &mut alsa.period_size, + 0 as *mut libc::c_int); if err < 0 as libc::c_int { - crate::src::utils::logprint( - b"%s %s:%d unable to get period size: %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"alsa_open\x00")).as_ptr(), - 503 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); - return err; + logprint(b"%s %s:%d unable to get period size: %s\n\x00" as *const u8 + as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 10], + &[libc::c_char; 10]>(b"alsa_open\x00")).as_ptr(), + 503 as libc::c_int, snd_strerror(err)); + return err } // get buffer_size - err = crate::stdlib::snd_pcm_hw_params_get_buffer_size(hw_params, &mut alsa.buffer_size); + err = snd_pcm_hw_params_get_buffer_size(hw_params, &mut alsa.buffer_size); if err < 0 as libc::c_int { - crate::src::utils::logprint( - b"%s %s:%d unable to get buffer size: %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"alsa_open\x00")).as_ptr(), - 509 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); - return err; + logprint(b"%s %s:%d unable to get buffer size: %s\n\x00" as *const u8 + as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 10], + &[libc::c_char; 10]>(b"alsa_open\x00")).as_ptr(), + 509 as libc::c_int, snd_strerror(err)); + return err } - 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 buffer: %u period: %u -> buffer size: %u period size: %u\n\x00" as *const u8 - as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 10], &[libc::c_char; 10]>(b"alsa_open\x00")).as_ptr(), - 513 as libc::c_int, - alsa_buffer, - alsa_period, - alsa.buffer_size, - alsa.period_size, - ); + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d buffer: %u period: %u -> buffer size: %u period size: %u\n\x00" + as *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 10], + &[libc::c_char; 10]>(b"alsa_open\x00")).as_ptr(), + 513 as libc::c_int, alsa_buffer, alsa_period, + alsa.buffer_size, alsa.period_size); } // ensure we have two buffer sizes of samples before starting output - output.start_frames = alsa - .buffer_size - .wrapping_mul(2 as libc::c_int as libc::c_ulong) as libc::c_uint; + output.start_frames = + alsa.buffer_size.wrapping_mul(2 as libc::c_int as libc::c_ulong) as + libc::c_uint; // create an intermediate buffer for non mmap case for all but NATIVE_FORMAT - // this is used to pack samples into the output format before calling writei - if !alsa.mmap - && alsa.write_buf.is_null() - && alsa.format as libc::c_int != crate::stdlib::SND_PCM_FORMAT_S32_LE as libc::c_int - { - alsa.write_buf = crate::stdlib::malloc( - alsa.buffer_size - .wrapping_mul(8 as libc::c_int as libc::c_ulong), - ) as *mut crate::squeezelite_h::u8_t; + // this is used to pack samples into the output format before calling writei + if !alsa.mmap && alsa.write_buf.is_null() && + alsa.format as libc::c_int != SND_PCM_FORMAT_S32_LE as libc::c_int + { + alsa.write_buf = + malloc(alsa.buffer_size.wrapping_mul(8 as libc::c_int as + libc::c_ulong)) as + *mut u8_t; if alsa.write_buf.is_null() { - crate::src::utils::logprint( - b"%s %s:%d unable to malloc write_buf\n\x00" as *const u8 as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 10], &[libc::c_char; 10]>(b"alsa_open\x00")) - .as_ptr(), - 523 as libc::c_int, - ); - return -(1 as libc::c_int); + logprint(b"%s %s:%d unable to malloc write_buf\n\x00" as *const u8 + as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 10], + &[libc::c_char; 10]>(b"alsa_open\x00")).as_ptr(), + 523 as libc::c_int); + return -(1 as libc::c_int) } } // set params - err = crate::stdlib::snd_pcm_hw_params(pcmp, hw_params); + err = snd_pcm_hw_params(pcmp, hw_params); if err < 0 as libc::c_int { - crate::src::utils::logprint( - b"%s %s:%d unable to set hw params: %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"alsa_open\x00")).as_ptr(), - 530 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); - return err; + logprint(b"%s %s:%d unable to set hw params: %s\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 10], + &[libc::c_char; 10]>(b"alsa_open\x00")).as_ptr(), + 530 as libc::c_int, snd_strerror(err)); + return err } // dump info - if loglevel as libc::c_uint == crate::squeezelite_h::lSDEBUG as libc::c_int as libc::c_uint { - static mut debug_output: *mut crate::stdlib::snd_output_t = - 0 as *const crate::stdlib::snd_output_t as *mut crate::stdlib::snd_output_t; - crate::stdlib::snd_output_stdio_attach( - &mut debug_output, - crate::stdlib::stderr, - 0 as libc::c_int, - ); - crate::stdlib::snd_pcm_dump(pcmp, debug_output); + if loglevel as libc::c_uint == lSDEBUG as libc::c_int as libc::c_uint { + static mut debug_output: *mut snd_output_t = + 0 as *const snd_output_t as *mut snd_output_t; + snd_output_stdio_attach(&mut debug_output, stderr, 0 as libc::c_int); + snd_pcm_dump(pcmp, debug_output); } // this indicates we have opened the device ok alsa.rate = sample_rate; return 0 as libc::c_int; } - -unsafe extern "C" fn _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 areas = 0 as *const crate::stdlib::snd_pcm_channel_area_t; - let mut offset: crate::stdlib::snd_pcm_uframes_t = 0; - let mut outputptr = 0 as *mut libc::c_void; - let mut inputptr = 0 as *mut crate::squeezelite_h::s32_t; +unsafe extern "C" fn _write_frames(mut out_frames: frames_t, + mut silence: bool, mut gainL: s32_t, + mut gainR: s32_t, mut cross_gain_in: s32_t, + mut cross_gain_out: s32_t, + mut cross_ptr: *mut *mut s32_t) + -> libc::c_int { + let mut areas: *const snd_pcm_channel_area_t = + 0 as *const snd_pcm_channel_area_t; + let mut offset: snd_pcm_uframes_t = 0; + let mut outputptr: *mut libc::c_void = 0 as *mut libc::c_void; + let mut inputptr: *mut s32_t = 0 as *mut s32_t; let mut err: libc::c_int = 0; if alsa.mmap { - let mut alsa_frames = out_frames as crate::stdlib::snd_pcm_uframes_t; - crate::stdlib::snd_pcm_avail_update(pcmp); - err = crate::stdlib::snd_pcm_mmap_begin(pcmp, &mut areas, &mut offset, &mut alsa_frames); + let mut alsa_frames: snd_pcm_uframes_t = + out_frames as snd_pcm_uframes_t; + snd_pcm_avail_update(pcmp); + err = + snd_pcm_mmap_begin(pcmp, &mut areas, &mut offset, + &mut alsa_frames); 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 error from mmap_begin: %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"_write_frames\x00", - )) - .as_ptr(), - 565 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); + if loglevel as libc::c_uint >= + lWARN as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d error from mmap_begin: %s\n\x00" as + *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 14], + &[libc::c_char; 14]>(b"_write_frames\x00")).as_ptr(), + 565 as libc::c_int, snd_strerror(err)); } - return -(1 as libc::c_int); + return -(1 as libc::c_int) } - out_frames = alsa_frames as crate::squeezelite_h::frames_t + out_frames = alsa_frames as frames_t } if !silence { // applying cross fade is delayed until this point as mmap_begin can change out_frames - 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, - ); + if output.fade as libc::c_uint == + FADE_ACTIVE as libc::c_int as libc::c_uint && + output.fade_dir as libc::c_uint == + FADE_CROSS as libc::c_int as libc::c_uint && + !(*cross_ptr).is_null() { + _apply_cross(outputbuf, out_frames, cross_gain_in, cross_gain_out, + cross_ptr); } } - inputptr = if silence as libc::c_int != 0 { - silencebuf - } else { - (*outputbuf).readp - } as *mut crate::squeezelite_h::s32_t; - if alsa.mmap as libc::c_int != 0 - || alsa.format as libc::c_int != crate::stdlib::SND_PCM_FORMAT_S32_LE as libc::c_int - { - outputptr = if alsa.mmap as libc::c_int != 0 { - (*areas.offset(0 as libc::c_int as isize)).addr.offset( - ((*areas.offset(0 as libc::c_int as isize)).first as libc::c_ulong) - .wrapping_add(offset.wrapping_mul( - (*areas.offset(0 as libc::c_int as isize)).step as libc::c_ulong, - )) - .wrapping_div(8 as libc::c_int as libc::c_ulong) as isize, - ) - } else { - alsa.write_buf as *mut libc::c_void - }; - crate::src::output_pack::_scale_and_pack_frames( - outputptr, - inputptr, - out_frames, - gainL, - gainR, - output.format, - ); + inputptr = + if silence as libc::c_int != 0 { + silencebuf + } else { (*outputbuf).readp } as *mut s32_t; + if alsa.mmap as libc::c_int != 0 || + alsa.format as libc::c_int != SND_PCM_FORMAT_S32_LE as libc::c_int + { + outputptr = + if alsa.mmap as libc::c_int != 0 { + (*areas.offset(0 as libc::c_int as + isize)).addr.offset(((*areas.offset(0 as + libc::c_int + as + isize)).first + as + libc::c_ulong).wrapping_add(offset.wrapping_mul((*areas.offset(0 + as + libc::c_int + as + isize)).step + as + libc::c_ulong)).wrapping_div(8 + as + libc::c_int + as + libc::c_ulong) + as isize) + } else { alsa.write_buf as *mut libc::c_void }; + _scale_and_pack_frames(outputptr, inputptr, out_frames, gainL, gainR, + output.format); } else { outputptr = inputptr as *mut libc::c_void; if !silence { - if gainL != 0x10000 as libc::c_int || gainR != 0x10000 as libc::c_int { - crate::squeezelite_h::_apply_gain(outputbuf, out_frames, gainL, gainR); + if gainL != 0x10000 as libc::c_int || + gainR != 0x10000 as libc::c_int { + _apply_gain(outputbuf, out_frames, gainL, gainR); } } } if alsa.mmap { - let mut w = crate::stdlib::snd_pcm_mmap_commit( - pcmp, - offset, - out_frames as crate::stdlib::snd_pcm_uframes_t, - ); - if w < 0 as libc::c_int as libc::c_long || w != out_frames as libc::c_long { - 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 mmap_commit error\n\x00" as *const u8 as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 14], &[libc::c_char; 14]>( - b"_write_frames\x00", - )) - .as_ptr(), - 615 as libc::c_int, - ); + let mut w: snd_pcm_sframes_t = + snd_pcm_mmap_commit(pcmp, offset, + out_frames as snd_pcm_uframes_t); + if w < 0 as libc::c_int as libc::c_long || + w != out_frames as libc::c_long { + if loglevel as libc::c_uint >= + lWARN as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d mmap_commit error\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 14], + &[libc::c_char; 14]>(b"_write_frames\x00")).as_ptr(), + 615 as libc::c_int); } - return -(1 as libc::c_int); + return -(1 as libc::c_int) } } else { - let mut w_0 = crate::stdlib::snd_pcm_writei( - pcmp, - outputptr, - out_frames as crate::stdlib::snd_pcm_uframes_t, - ); + let mut w_0: snd_pcm_sframes_t = + snd_pcm_writei(pcmp, outputptr, out_frames as snd_pcm_uframes_t); if w_0 < 0 as libc::c_int as libc::c_long { //if (w != -EAGAIN && ((err = snd_pcm_recover(pcmp, w, 1)) < 0)) { - err = crate::stdlib::snd_pcm_recover(pcmp, w_0 as libc::c_int, 1 as libc::c_int); + err = snd_pcm_recover(pcmp, w_0 as libc::c_int, 1 as libc::c_int); if err < 0 as libc::c_int { - static mut recover_count: libc::c_uint = 0 as libc::c_int as libc::c_uint; - if loglevel as libc::c_uint - >= crate::squeezelite_h::lWARN as libc::c_int as libc::c_uint - { + static mut recover_count: libc::c_uint = + 0 as libc::c_int as libc::c_uint; + if loglevel as libc::c_uint >= + lWARN as libc::c_int as libc::c_uint { recover_count = recover_count.wrapping_add(1); - crate::src::utils::logprint( - b"%s %s:%d recover failed: %s [%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"_write_frames\x00", - )) - .as_ptr(), - 626 as libc::c_int, - crate::stdlib::snd_strerror(err), - recover_count, - ); + logprint(b"%s %s:%d recover failed: %s [%u]\n\x00" as + *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 14], + &[libc::c_char; 14]>(b"_write_frames\x00")).as_ptr(), + 626 as libc::c_int, snd_strerror(err), + recover_count); } if recover_count >= 10 as libc::c_int as libc::c_uint { recover_count = 0 as libc::c_int as libc::c_uint; alsa_close(); - pcmp = 0 as *mut crate::stdlib::snd_pcm_t + pcmp = 0 as *mut snd_pcm_t } } - return -(1 as libc::c_int); + return -(1 as libc::c_int) } else { if w_0 != out_frames as libc::c_long { - 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 writei only wrote %u of %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"_write_frames\x00", - )) - .as_ptr(), - 636 as libc::c_int, - w_0, - out_frames, - ); + if loglevel as libc::c_uint >= + lWARN as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d writei only wrote %u of %u\n\x00" as + *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 14], + &[libc::c_char; 14]>(b"_write_frames\x00")).as_ptr(), + 636 as libc::c_int, w_0, out_frames); } } - out_frames = w_0 as crate::squeezelite_h::frames_t + out_frames = w_0 as frames_t } } return out_frames as libc::c_int; } - -unsafe extern "C" fn output_thread(mut arg: *mut libc::c_void) -> *mut libc::c_void { - let mut start = 1 as libc::c_int != 0; - let mut output_off = - output.state as libc::c_int == crate::squeezelite_h::OUTPUT_OFF as libc::c_int; - let mut probe_device = !arg.is_null(); +unsafe extern "C" fn output_thread(mut arg: *mut libc::c_void) + -> *mut libc::c_void { + let mut start: bool = 1 as libc::c_int != 0; + let mut output_off: bool = + output.state as libc::c_int == OUTPUT_OFF as libc::c_int; + let mut probe_device: bool = !arg.is_null(); let mut err: libc::c_int = 0; while running { // disabled output - player is off while output_off { - crate::stdlib::usleep(100000 as libc::c_int as crate::stdlib::__useconds_t); - crate::stdlib::pthread_mutex_lock(&mut (*outputbuf).mutex); + usleep(100000 as libc::c_int as __useconds_t); + pthread_mutex_lock(&mut (*outputbuf).mutex); output_off = - output.state as libc::c_int == crate::squeezelite_h::OUTPUT_OFF as libc::c_int; - crate::stdlib::pthread_mutex_unlock(&mut (*outputbuf).mutex); - if !running { - return 0 as *mut libc::c_void; - } + output.state as libc::c_int == OUTPUT_OFF as libc::c_int; + pthread_mutex_unlock(&mut (*outputbuf).mutex); + if !running { return 0 as *mut libc::c_void } } // wait until device returns - to allow usb audio devices to be turned off if probe_device { while !pcm_probe(output.device) { - 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 waiting for device %s to return\n\x00" as *const u8 - as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 14], &[libc::c_char; 14]>( - b"output_thread\x00", - )) - .as_ptr(), - 665 as libc::c_int, - output.device, - ); + if loglevel as libc::c_uint >= + lDEBUG as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d waiting for device %s to return\n\x00" + as *const u8 as *const libc::c_char, + logtime(), + (*::std::mem::transmute::<&[u8; 14], + &[libc::c_char; 14]>(b"output_thread\x00")).as_ptr(), + 665 as libc::c_int, output.device); } - crate::stdlib::sleep(5 as libc::c_int as libc::c_uint); + sleep(5 as libc::c_int as libc::c_uint); } probe_device = 0 as libc::c_int != 0 } if pcmp.is_null() || alsa.rate != output.current_sample_rate { - 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 open output device: %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"output_thread\x00", - )) - .as_ptr(), - 687 as libc::c_int, - output.device, - ); + if loglevel as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d open output device: %s\n\x00" as *const u8 + as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 14], + &[libc::c_char; 14]>(b"output_thread\x00")).as_ptr(), + 687 as libc::c_int, output.device); } - crate::stdlib::pthread_mutex_lock(&mut (*outputbuf).mutex); + pthread_mutex_lock(&mut (*outputbuf).mutex); // FIXME - some alsa hardware requires opening twice for a new sample rate to work - // this is a workaround which should be removed + // this is a workaround which should be removed if alsa.reopen { - alsa_open( - output.device, - output.current_sample_rate, - output.buffer, - output.period, - ); + alsa_open(output.device, output.current_sample_rate, + output.buffer, output.period); } - if alsa_open( - output.device, - output.current_sample_rate, - output.buffer, - output.period, - ) != 0 - { + if alsa_open(output.device, output.current_sample_rate, + output.buffer, output.period) != 0 { output.error_opening = 1 as libc::c_int != 0; - crate::stdlib::pthread_mutex_unlock(&mut (*outputbuf).mutex); - crate::stdlib::sleep(5 as libc::c_int as libc::c_uint); - continue; + pthread_mutex_unlock(&mut (*outputbuf).mutex); + sleep(5 as libc::c_int as libc::c_uint); + continue ; } else { output.error_opening = 0 as libc::c_int != 0; start = 1 as libc::c_int != 0; - crate::stdlib::pthread_mutex_unlock(&mut (*outputbuf).mutex); + pthread_mutex_unlock(&mut (*outputbuf).mutex); } } - let mut state = crate::stdlib::snd_pcm_state(pcmp); - if state as libc::c_uint == crate::stdlib::SND_PCM_STATE_XRUN 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 XRUN\n\x00" as *const u8 as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 14], &[libc::c_char; 14]>( - b"output_thread\x00", - )) - .as_ptr(), - 717 as libc::c_int, - ); + let mut state: snd_pcm_state_t = snd_pcm_state(pcmp); + if state as libc::c_uint == + SND_PCM_STATE_XRUN as libc::c_int as libc::c_uint { + if loglevel as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d XRUN\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 14], + &[libc::c_char; 14]>(b"output_thread\x00")).as_ptr(), + 717 as libc::c_int); } - err = crate::stdlib::snd_pcm_recover(pcmp, -(32 as libc::c_int), 1 as libc::c_int); + err = + snd_pcm_recover(pcmp, -(32 as libc::c_int), 1 as libc::c_int); if err < 0 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 XRUN recover failed: %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"output_thread\x00", - )) - .as_ptr(), - 719 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); + if loglevel as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d XRUN recover failed: %s\n\x00" as + *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 14], + &[libc::c_char; 14]>(b"output_thread\x00")).as_ptr(), + 719 as libc::c_int, snd_strerror(err)); } } start = 1 as libc::c_int != 0 } else { - if state as libc::c_uint - == crate::stdlib::SND_PCM_STATE_SUSPENDED as libc::c_int as libc::c_uint - { - err = crate::stdlib::snd_pcm_recover(pcmp, -(86 as libc::c_int), 1 as libc::c_int); + if state as libc::c_uint == + SND_PCM_STATE_SUSPENDED as libc::c_int as libc::c_uint { + err = + snd_pcm_recover(pcmp, -(86 as libc::c_int), + 1 as libc::c_int); if err < 0 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 SUSPEND recover failed: %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"output_thread\x00", - )) - .as_ptr(), - 725 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); + if loglevel as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d SUSPEND recover failed: %s\n\x00" + as *const u8 as *const libc::c_char, + logtime(), + (*::std::mem::transmute::<&[u8; 14], + &[libc::c_char; 14]>(b"output_thread\x00")).as_ptr(), + 725 as libc::c_int, snd_strerror(err)); } } - } else if state as libc::c_uint - == crate::stdlib::SND_PCM_STATE_DISCONNECTED 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 Device %s no longer available\n\x00" as *const u8 - as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 14], &[libc::c_char; 14]>( - b"output_thread\x00", - )) - .as_ptr(), - 728 as libc::c_int, - output.device, - ); + } else if state as libc::c_uint == + SND_PCM_STATE_DISCONNECTED as libc::c_int as + libc::c_uint { + if loglevel as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d Device %s no longer available\n\x00" + as *const u8 as *const libc::c_char, + logtime(), + (*::std::mem::transmute::<&[u8; 14], + &[libc::c_char; 14]>(b"output_thread\x00")).as_ptr(), + 728 as libc::c_int, output.device); } alsa_close(); - pcmp = 0 as *mut crate::stdlib::snd_pcm_t; + pcmp = 0 as *mut snd_pcm_t; probe_device = 1 as libc::c_int != 0; - continue; + continue ; } - let mut avail = crate::stdlib::snd_pcm_avail_update(pcmp); + let mut avail: snd_pcm_sframes_t = snd_pcm_avail_update(pcmp); if avail < 0 as libc::c_int as libc::c_long { - err = crate::stdlib::snd_pcm_recover(pcmp, avail as libc::c_int, 1 as libc::c_int); + err = + snd_pcm_recover(pcmp, avail as libc::c_int, + 1 as libc::c_int); if err < 0 as libc::c_int { if err == -(19 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 Device %s no longer available\n\x00" as *const u8 - as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 14], &[libc::c_char; 14]>( - b"output_thread\x00", - )) - .as_ptr(), - 740 as libc::c_int, - output.device, - ); + if loglevel as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d Device %s no longer available\n\x00" + as *const u8 as *const libc::c_char, + logtime(), + (*::std::mem::transmute::<&[u8; 14], + &[libc::c_char; 14]>(b"output_thread\x00")).as_ptr(), + 740 as libc::c_int, output.device); } alsa_close(); - pcmp = 0 as *mut crate::stdlib::snd_pcm_t; + pcmp = 0 as *mut snd_pcm_t; probe_device = 1 as libc::c_int != 0; - continue; - } 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 recover failed: %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"output_thread\x00", - )) - .as_ptr(), - 746 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); + continue ; + } else if loglevel as libc::c_uint >= + lWARN as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d recover failed: %s\n\x00" as + *const u8 as *const libc::c_char, + logtime(), + (*::std::mem::transmute::<&[u8; 14], + &[libc::c_char; 14]>(b"output_thread\x00")).as_ptr(), + 746 as libc::c_int, snd_strerror(err)); } } start = 1 as libc::c_int != 0 } else if (avail as libc::c_ulong) < alsa.period_size { if start { - if alsa.mmap as libc::c_int != 0 && { - err = crate::stdlib::snd_pcm_start(pcmp); - (err) < 0 as libc::c_int - } { - err = crate::stdlib::snd_pcm_recover(pcmp, err, 1 as libc::c_int); - if !(err < 0 as libc::c_int) { - continue; - } + if alsa.mmap as libc::c_int != 0 && + { + err = snd_pcm_start(pcmp); + (err) < 0 as libc::c_int + } { + err = snd_pcm_recover(pcmp, err, 1 as libc::c_int); + if !(err < 0 as libc::c_int) { continue ; } if err == -(19 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 Device %s no longer available\n\x00" as *const u8 - as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 14], &[libc::c_char; 14]>( - b"output_thread\x00", - )) - .as_ptr(), - 757 as libc::c_int, - output.device, - ); + if loglevel as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d Device %s no longer available\n\x00" + as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 14], + &[libc::c_char; 14]>(b"output_thread\x00")).as_ptr(), + 757 as libc::c_int, output.device); } alsa_close(); - pcmp = 0 as *mut crate::stdlib::snd_pcm_t; + pcmp = 0 as *mut snd_pcm_t; probe_device = 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 start error: %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"output_thread\x00", - )) - .as_ptr(), - 763 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); + if loglevel as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d start error: %s\n\x00" as + *const u8 as *const libc::c_char, + logtime(), + (*::std::mem::transmute::<&[u8; 14], + &[libc::c_char; 14]>(b"output_thread\x00")).as_ptr(), + 763 as libc::c_int, + snd_strerror(err)); } - crate::stdlib::usleep( - 10000 as libc::c_int as crate::stdlib::__useconds_t, - ); + usleep(10000 as libc::c_int as __useconds_t); } - } else { - start = 0 as libc::c_int != 0 - } + } else { start = 0 as libc::c_int != 0 } } else { - crate::stdlib::usleep(10000 as libc::c_int as crate::stdlib::__useconds_t); - err = crate::stdlib::snd_pcm_wait(pcmp, 1000 as libc::c_int); + usleep(10000 as libc::c_int as __useconds_t); + err = snd_pcm_wait(pcmp, 1000 as libc::c_int); if err <= 0 as libc::c_int { if err == 0 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 pcm wait timeout\n\x00" as *const u8 - as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 14], &[libc::c_char; 14]>( - b"output_thread\x00", - )) - .as_ptr(), - 773 as libc::c_int, - ); + if loglevel as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d pcm wait timeout\n\x00" as + *const u8 as *const libc::c_char, + logtime(), + (*::std::mem::transmute::<&[u8; 14], + &[libc::c_char; 14]>(b"output_thread\x00")).as_ptr(), + 773 as libc::c_int); } } - err = crate::stdlib::snd_pcm_recover(pcmp, err, 1 as libc::c_int); + err = snd_pcm_recover(pcmp, err, 1 as libc::c_int); if err < 0 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 pcm wait error: %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"output_thread\x00", - )) - .as_ptr(), - 776 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); + if loglevel as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d pcm wait error: %s\n\x00" + as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 14], + &[libc::c_char; 14]>(b"output_thread\x00")).as_ptr(), + 776 as libc::c_int, + snd_strerror(err)); } } start = 1 as libc::c_int != 0 @@ -1817,136 +1835,104 @@ unsafe extern "C" fn output_thread(mut arg: *mut libc::c_void) -> *mut libc::c_v } } else { // restrict avail to within sensible limits as alsa drivers can return erroneous large values - // in writei mode restrict to period_size due to size of write_buf + // in writei mode restrict to period_size due to size of write_buf if alsa.mmap { - avail = if (avail as libc::c_ulong) < alsa.buffer_size { - avail as libc::c_ulong - } else { - alsa.buffer_size - } as crate::stdlib::snd_pcm_sframes_t + avail = + if (avail as libc::c_ulong) < alsa.buffer_size { + avail as libc::c_ulong + } else { alsa.buffer_size } as snd_pcm_sframes_t } else { - avail = if (avail as libc::c_ulong) < alsa.period_size { - avail as libc::c_ulong - } else { - alsa.period_size - } as crate::stdlib::snd_pcm_sframes_t + avail = + if (avail as libc::c_ulong) < alsa.period_size { + avail as libc::c_ulong + } else { alsa.period_size } as snd_pcm_sframes_t } // avoid spinning in cases where wait returns but no bytes available (seen with pulse audio) if avail == 0 as libc::c_int as libc::c_long { - 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 avail 0 - sleeping\n\x00" as *const u8 - as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 14], &[libc::c_char; 14]>( - b"output_thread\x00", - )) - .as_ptr(), - 794 as libc::c_int, - ); + if loglevel as libc::c_uint >= + lSDEBUG as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d avail 0 - sleeping\n\x00" as + *const u8 as *const libc::c_char, + logtime(), + (*::std::mem::transmute::<&[u8; 14], + &[libc::c_char; 14]>(b"output_thread\x00")).as_ptr(), + 794 as libc::c_int); } - crate::stdlib::usleep(10000 as libc::c_int as crate::stdlib::__useconds_t); + usleep(10000 as libc::c_int as __useconds_t); } else { - crate::stdlib::pthread_mutex_lock(&mut (*outputbuf).mutex); + pthread_mutex_lock(&mut (*outputbuf).mutex); // turn off if requested - if output.state as libc::c_int - == crate::squeezelite_h::OUTPUT_OFF as libc::c_int - { - crate::stdlib::pthread_mutex_unlock(&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 disabling output\n\x00" as *const u8 - as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 14], &[libc::c_char; 14]>( - b"output_thread\x00", - )) - .as_ptr(), - 804 as libc::c_int, - ); + if output.state as libc::c_int == + OUTPUT_OFF as libc::c_int { + pthread_mutex_unlock(&mut (*outputbuf).mutex); + if loglevel as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d disabling output\n\x00" as + *const u8 as *const libc::c_char, + logtime(), + (*::std::mem::transmute::<&[u8; 14], + &[libc::c_char; 14]>(b"output_thread\x00")).as_ptr(), + 804 as libc::c_int); } alsa_close(); - pcmp = 0 as *mut crate::stdlib::snd_pcm_t; + pcmp = 0 as *mut snd_pcm_t; output_off = 1 as libc::c_int != 0 } else { // measure output delay - let mut delay: crate::stdlib::snd_pcm_sframes_t = 0; - err = crate::stdlib::snd_pcm_delay(pcmp, &mut delay); + let mut delay: snd_pcm_sframes_t = 0; + err = snd_pcm_delay(pcmp, &mut delay); if err < 0 as libc::c_int { if err == -(32 as libc::c_int) { // EPIPE indicates underrun - attempt to recover - crate::stdlib::pthread_mutex_unlock(&mut (*outputbuf).mutex); - continue; + pthread_mutex_unlock(&mut (*outputbuf).mutex); + continue ; } else if err == -(5 as libc::c_int) { // EIO can occur with non existant pulse server - 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 snd_pcm_delay returns: EIO - sleeping\n\x00" - as *const u8 - as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 14], &[libc::c_char; 14]>( - b"output_thread\x00", - )) - .as_ptr(), - 833 as libc::c_int, - ); + pthread_mutex_unlock(&mut (*outputbuf).mutex); + if loglevel as libc::c_uint >= + lSDEBUG as libc::c_int as libc::c_uint + { + logprint(b"%s %s:%d snd_pcm_delay returns: EIO - sleeping\n\x00" + as *const u8 as + *const libc::c_char, + logtime(), + (*::std::mem::transmute::<&[u8; 14], + &[libc::c_char; 14]>(b"output_thread\x00")).as_ptr(), + 833 as libc::c_int); } - crate::stdlib::usleep( - 100000 as libc::c_int as crate::stdlib::__useconds_t, - ); - continue; - } else 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 snd_pcm_delay returns: %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"output_thread\x00", - )) - .as_ptr(), - 837 as libc::c_int, - err, - ); + usleep(100000 as libc::c_int as __useconds_t); + continue ; + } else if loglevel as libc::c_uint >= + lDEBUG as libc::c_int as + libc::c_uint { + logprint(b"%s %s:%d snd_pcm_delay returns: %d\n\x00" + as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 14], + &[libc::c_char; 14]>(b"output_thread\x00")).as_ptr(), + 837 as libc::c_int, err); } } else { output.device_frames = delay as libc::c_uint; - output.updated = crate::src::utils::gettime_ms(); + output.updated = gettime_ms(); output.frames_played_dmp = output.frames_played } // process frames - let mut wrote = crate::src::output::_output_frames( - avail as crate::squeezelite_h::frames_t, - ); - crate::stdlib::pthread_mutex_unlock(&mut (*outputbuf).mutex); + let mut wrote: frames_t = + _output_frames(avail as frames_t); + pthread_mutex_unlock(&mut (*outputbuf).mutex); // some output devices such as alsa null refuse any data, avoid spinning if wrote == 0 { - 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 0 - sleeping\n\x00" as *const u8 - as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 14], &[libc::c_char; 14]>( - b"output_thread\x00", - )) - .as_ptr(), - 852 as libc::c_int, - ); + if loglevel as libc::c_uint >= + lSDEBUG as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d wrote 0 - sleeping\n\x00" + as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 14], + &[libc::c_char; 14]>(b"output_thread\x00")).as_ptr(), + 852 as libc::c_int); } - crate::stdlib::usleep( - 10000 as libc::c_int as crate::stdlib::__useconds_t, - ); + usleep(10000 as libc::c_int as __useconds_t); } } } @@ -1956,435 +1942,338 @@ unsafe extern "C" fn output_thread(mut arg: *mut libc::c_void) -> *mut libc::c_v return 0 as *mut libc::c_void; } #[no_mangle] - -pub unsafe extern "C" fn mixer_init_alsa( - mut device: *const libc::c_char, - mut mixer: *const libc::c_char, - mut mixer_index: libc::c_int, -) -> libc::c_int { +pub unsafe extern "C" fn mixer_init_alsa(mut device: *const libc::c_char, + mut mixer: *const libc::c_char, + mut mixer_index: libc::c_int) + -> libc::c_int { let mut err: libc::c_int = 0; - let mut sid = 0 as *mut crate::stdlib::snd_mixer_selem_id_t; - err = crate::stdlib::snd_mixer_open(&mut alsa.mixer_handle, 0 as libc::c_int); + let mut sid: *mut snd_mixer_selem_id_t = 0 as *mut snd_mixer_selem_id_t; + err = snd_mixer_open(&mut alsa.mixer_handle, 0 as libc::c_int); if err < 0 as libc::c_int { - crate::src::utils::logprint( - b"%s %s:%d open error: %s\n\x00" as *const u8 as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 16], &[libc::c_char; 16]>(b"mixer_init_alsa\x00")) - .as_ptr(), - 865 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); - return -(1 as libc::c_int); + logprint(b"%s %s:%d open error: %s\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 16], + &[libc::c_char; 16]>(b"mixer_init_alsa\x00")).as_ptr(), + 865 as libc::c_int, snd_strerror(err)); + return -(1 as libc::c_int) } - err = crate::stdlib::snd_mixer_attach(alsa.mixer_handle, device); + err = snd_mixer_attach(alsa.mixer_handle, device); if err < 0 as libc::c_int { - crate::src::utils::logprint( - b"%s %s:%d attach error: %s\n\x00" as *const u8 as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 16], &[libc::c_char; 16]>(b"mixer_init_alsa\x00")) - .as_ptr(), - 869 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); - crate::stdlib::snd_mixer_close(alsa.mixer_handle); - return -(1 as libc::c_int); + logprint(b"%s %s:%d attach error: %s\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 16], + &[libc::c_char; 16]>(b"mixer_init_alsa\x00")).as_ptr(), + 869 as libc::c_int, snd_strerror(err)); + snd_mixer_close(alsa.mixer_handle); + return -(1 as libc::c_int) } - err = crate::stdlib::snd_mixer_selem_register( - alsa.mixer_handle, - 0 as *mut crate::stdlib::snd_mixer_selem_regopt, - 0 as *mut *mut crate::stdlib::snd_mixer_class_t, - ); + err = + snd_mixer_selem_register(alsa.mixer_handle, + 0 as *mut snd_mixer_selem_regopt, + 0 as *mut *mut snd_mixer_class_t); if err < 0 as libc::c_int { - crate::src::utils::logprint( - b"%s %s:%d register error: %s\n\x00" as *const u8 as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 16], &[libc::c_char; 16]>(b"mixer_init_alsa\x00")) - .as_ptr(), - 874 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); - crate::stdlib::snd_mixer_close(alsa.mixer_handle); - return -(1 as libc::c_int); + logprint(b"%s %s:%d register error: %s\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 16], + &[libc::c_char; 16]>(b"mixer_init_alsa\x00")).as_ptr(), + 874 as libc::c_int, snd_strerror(err)); + snd_mixer_close(alsa.mixer_handle); + return -(1 as libc::c_int) } - err = crate::stdlib::snd_mixer_load(alsa.mixer_handle); + err = snd_mixer_load(alsa.mixer_handle); if err < 0 as libc::c_int { - crate::src::utils::logprint( - b"%s %s:%d load error: %s\n\x00" as *const u8 as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 16], &[libc::c_char; 16]>(b"mixer_init_alsa\x00")) - .as_ptr(), - 879 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); - crate::stdlib::snd_mixer_close(alsa.mixer_handle); - return -(1 as libc::c_int); + logprint(b"%s %s:%d load error: %s\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 16], + &[libc::c_char; 16]>(b"mixer_init_alsa\x00")).as_ptr(), + 879 as libc::c_int, snd_strerror(err)); + snd_mixer_close(alsa.mixer_handle); + return -(1 as libc::c_int) } - let mut fresh4 = ::std::vec::from_elem(0, crate::stdlib::snd_mixer_selem_id_sizeof() as usize); - sid = fresh4.as_mut_ptr() as *mut crate::stdlib::snd_mixer_selem_id_t; - crate::stdlib::memset( - sid as *mut libc::c_void, - 0 as libc::c_int, - crate::stdlib::snd_mixer_selem_id_sizeof(), - ); - crate::stdlib::snd_mixer_selem_id_set_index(sid, mixer_index as libc::c_uint); - crate::stdlib::snd_mixer_selem_id_set_name(sid, mixer); - alsa.mixer_elem = crate::stdlib::snd_mixer_find_selem(alsa.mixer_handle, sid); + let mut fresh4 = + ::std::vec::from_elem(0, snd_mixer_selem_id_sizeof() as usize); + sid = fresh4.as_mut_ptr() as *mut snd_mixer_selem_id_t; + memset(sid as *mut libc::c_void, 0 as libc::c_int, + snd_mixer_selem_id_sizeof()); + snd_mixer_selem_id_set_index(sid, mixer_index as libc::c_uint); + snd_mixer_selem_id_set_name(sid, mixer); + alsa.mixer_elem = snd_mixer_find_selem(alsa.mixer_handle, sid); if alsa.mixer_elem.is_null() { - crate::src::utils::logprint( - b"%s %s:%d error find selem %s\n\x00" as *const u8 as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 16], &[libc::c_char; 16]>(b"mixer_init_alsa\x00")) - .as_ptr(), - 889 as libc::c_int, - alsa.mixer_handle, - ); - crate::stdlib::snd_mixer_close(alsa.mixer_handle); - return -(1 as libc::c_int); + logprint(b"%s %s:%d error find selem %s\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 16], + &[libc::c_char; 16]>(b"mixer_init_alsa\x00")).as_ptr(), + 889 as libc::c_int, alsa.mixer_handle); + snd_mixer_close(alsa.mixer_handle); + return -(1 as libc::c_int) } - if crate::stdlib::snd_mixer_selem_has_playback_switch(alsa.mixer_elem) != 0 { - crate::stdlib::snd_mixer_selem_set_playback_switch_all(alsa.mixer_elem, 1 as libc::c_int); + if snd_mixer_selem_has_playback_switch(alsa.mixer_elem) != 0 { + snd_mixer_selem_set_playback_switch_all(alsa.mixer_elem, + 1 as libc::c_int); // unmute } - err = crate::stdlib::snd_mixer_selem_get_playback_dB_range( - alsa.mixer_elem, - &mut alsa.mixer_min, - &mut alsa.mixer_max, - ); - if err < 0 as libc::c_int - || alsa.mixer_max - alsa.mixer_min < 1000 as libc::c_int as libc::c_long - || alsa.mixer_linear as libc::c_int != 0 - { + err = + snd_mixer_selem_get_playback_dB_range(alsa.mixer_elem, + &mut alsa.mixer_min, + &mut alsa.mixer_max); + if err < 0 as libc::c_int || + alsa.mixer_max - alsa.mixer_min < + 1000 as libc::c_int as libc::c_long || + alsa.mixer_linear as libc::c_int != 0 { alsa.mixer_linear = 1 as libc::c_int != 0; // unable to get db range or range is less than 10dB - ignore and set using raw values - err = crate::stdlib::snd_mixer_selem_get_playback_volume_range( - alsa.mixer_elem, - &mut alsa.mixer_min, - &mut alsa.mixer_max, - ); + err = + snd_mixer_selem_get_playback_volume_range(alsa.mixer_elem, + &mut alsa.mixer_min, + &mut alsa.mixer_max); if err < 0 as libc::c_int { - crate::src::utils::logprint( - b"%s %s:%d Unable to get volume raw range\n\x00" as *const u8 - as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 16], &[libc::c_char; 16]>(b"mixer_init_alsa\x00")) - .as_ptr(), - 905 as libc::c_int, - ); - return -(1 as libc::c_int); + logprint(b"%s %s:%d Unable to get volume raw range\n\x00" as + *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 16], + &[libc::c_char; 16]>(b"mixer_init_alsa\x00")).as_ptr(), + 905 as libc::c_int); + return -(1 as libc::c_int) } } return 0 as libc::c_int; } - -static mut thread: crate::stdlib::pthread_t = 0; +static mut thread: pthread_t = 0; #[no_mangle] - -pub unsafe extern "C" fn output_init_alsa( - mut level: crate::squeezelite_h::log_level, - mut device: *const libc::c_char, - 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, - mut rt_priority: libc::c_uint, - mut idle: libc::c_uint, - mut mixer_device: *mut libc::c_char, - mut volume_mixer: *mut libc::c_char, - mut mixer_unmute: bool, - mut mixer_linear: bool, -) { - let mut alsa_buffer = 40 as libc::c_int as libc::c_uint; - let mut alsa_period = 4 as libc::c_int as libc::c_uint; - let mut alsa_sample_fmt = 0 as *mut libc::c_char; - let mut alsa_mmap = 1 as libc::c_int != 0; - let mut alsa_reopen = 0 as libc::c_int != 0; - let mut volume_mixer_name = - crate::src::utils::next_param(volume_mixer, ',' as i32 as libc::c_char); - let mut volume_mixer_index = - crate::src::utils::next_param(0 as *mut libc::c_char, ',' as i32 as libc::c_char); - let mut t = crate::src::utils::next_param(params, ':' as i32 as libc::c_char); - let mut c = crate::src::utils::next_param(0 as *mut libc::c_char, ':' as i32 as libc::c_char); - let mut s = crate::src::utils::next_param(0 as *mut libc::c_char, ':' as i32 as libc::c_char); - let mut m = crate::src::utils::next_param(0 as *mut libc::c_char, ':' as i32 as libc::c_char); - let mut r = crate::src::utils::next_param(0 as *mut libc::c_char, ':' as i32 as libc::c_char); - if !t.is_null() { - alsa_buffer = crate::stdlib::atoi(t) as libc::c_uint - } - if !c.is_null() { - alsa_period = crate::stdlib::atoi(c) as libc::c_uint - } - if !s.is_null() { - alsa_sample_fmt = s - } - if !m.is_null() { - alsa_mmap = crate::stdlib::atoi(m) != 0 - } - if !r.is_null() { - alsa_reopen = crate::stdlib::atoi(r) != 0 - } +pub unsafe extern "C" fn output_init_alsa(mut level: log_level, + mut device: *const libc::c_char, + 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, + mut rt_priority: libc::c_uint, + mut idle: libc::c_uint, + mut mixer_device: *mut libc::c_char, + mut volume_mixer: *mut libc::c_char, + mut mixer_unmute: bool, + mut mixer_linear: bool) { + let mut alsa_buffer: libc::c_uint = 40 as libc::c_int as libc::c_uint; + let mut alsa_period: libc::c_uint = 4 as libc::c_int as libc::c_uint; + let mut alsa_sample_fmt: *mut libc::c_char = 0 as *mut libc::c_char; + let mut alsa_mmap: bool = 1 as libc::c_int != 0; + let mut alsa_reopen: bool = 0 as libc::c_int != 0; + let mut volume_mixer_name: *mut libc::c_char = + next_param(volume_mixer, ',' as i32 as libc::c_char); + let mut volume_mixer_index: *mut libc::c_char = + next_param(0 as *mut libc::c_char, ',' as i32 as libc::c_char); + let mut t: *mut libc::c_char = + next_param(params, ':' as i32 as libc::c_char); + let mut c: *mut libc::c_char = + next_param(0 as *mut libc::c_char, ':' as i32 as libc::c_char); + let mut s: *mut libc::c_char = + next_param(0 as *mut libc::c_char, ':' as i32 as libc::c_char); + let mut m: *mut libc::c_char = + next_param(0 as *mut libc::c_char, ':' as i32 as libc::c_char); + let mut r: *mut libc::c_char = + next_param(0 as *mut libc::c_char, ':' as i32 as libc::c_char); + if !t.is_null() { alsa_buffer = atoi(t) as libc::c_uint } + if !c.is_null() { alsa_period = atoi(c) as libc::c_uint } + if !s.is_null() { alsa_sample_fmt = s } + if !m.is_null() { alsa_mmap = atoi(m) != 0 } + if !r.is_null() { alsa_reopen = atoi(r) != 0 } 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\n\x00" as *const u8 as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"output_init_alsa\x00")) - .as_ptr(), - 939 as libc::c_int, - ); + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d init output\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 17], + &[libc::c_char; 17]>(b"output_init_alsa\x00")).as_ptr(), + 939 as libc::c_int); } - 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::() as libc::c_ulong, - ); + memset(&mut output as *mut outputstate as *mut libc::c_void, + 0 as libc::c_int, + ::std::mem::size_of::() as libc::c_ulong); alsa.mmap = alsa_mmap; - alsa.write_buf = 0 as *mut crate::squeezelite_h::u8_t; - alsa.format = crate::stdlib::SND_PCM_FORMAT_S8; + alsa.write_buf = 0 as *mut u8_t; + alsa.format = SND_PCM_FORMAT_S8; alsa.reopen = alsa_reopen; - alsa.mixer_handle = 0 as *mut crate::stdlib::snd_mixer_t; + alsa.mixer_handle = 0 as *mut snd_mixer_t; alsa.ctl = ctl4device(device); - alsa.mixer_ctl = if !mixer_device.is_null() { - ctl4device(mixer_device) - } else { - alsa.ctl - }; + alsa.mixer_ctl = + if !mixer_device.is_null() { + ctl4device(mixer_device) + } else { alsa.ctl }; alsa.volume_mixer_name = volume_mixer_name; alsa.mixer_linear = mixer_linear; - output.format = crate::squeezelite_h::S32_LE; + output.format = S32_LE; output.buffer = alsa_buffer; output.period = alsa_period; output.start_frames = 0 as libc::c_int as libc::c_uint; - output.write_cb = Some( - _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.write_cb = + Some(_write_frames as + unsafe extern "C" fn(_: frames_t, _: bool, _: s32_t, + _: s32_t, _: s32_t, _: s32_t, + _: *mut *mut s32_t) -> libc::c_int); output.rate_delay = rate_delay; if !alsa_sample_fmt.is_null() { - if crate::stdlib::strcmp( - alsa_sample_fmt, - b"32\x00" as *const u8 as *const libc::c_char, - ) == 0 - { - alsa.format = crate::stdlib::SND_PCM_FORMAT_S32_LE + if strcmp(alsa_sample_fmt, + b"32\x00" as *const u8 as *const libc::c_char) == 0 { + alsa.format = SND_PCM_FORMAT_S32_LE } - if crate::stdlib::strcmp( - alsa_sample_fmt, - b"24\x00" as *const u8 as *const libc::c_char, - ) == 0 - { - alsa.format = crate::stdlib::SND_PCM_FORMAT_S24_LE + if strcmp(alsa_sample_fmt, + b"24\x00" as *const u8 as *const libc::c_char) == 0 { + alsa.format = SND_PCM_FORMAT_S24_LE } - if crate::stdlib::strcmp( - alsa_sample_fmt, - b"24_3\x00" as *const u8 as *const libc::c_char, - ) == 0 - { - alsa.format = crate::stdlib::SND_PCM_FORMAT_S24_3LE + if strcmp(alsa_sample_fmt, + b"24_3\x00" as *const u8 as *const libc::c_char) == 0 { + alsa.format = SND_PCM_FORMAT_S24_3LE } - if crate::stdlib::strcmp( - alsa_sample_fmt, - b"16\x00" as *const u8 as *const libc::c_char, - ) == 0 - { - alsa.format = crate::stdlib::SND_PCM_FORMAT_S16_LE + if strcmp(alsa_sample_fmt, + b"16\x00" as *const u8 as *const libc::c_char) == 0 { + alsa.format = SND_PCM_FORMAT_S16_LE } } - 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 requested alsa_buffer: %u alsa_period: %u format: %s mmap: %u\n\x00" - as *const u8 as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"output_init_alsa\x00")) - .as_ptr(), - 979 as libc::c_int, - output.buffer, - output.period, - if !alsa_sample_fmt.is_null() { - alsa_sample_fmt as *const libc::c_char - } else { - b"any\x00" as *const u8 as *const libc::c_char - }, - alsa.mmap as libc::c_int, - ); + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d requested alsa_buffer: %u alsa_period: %u format: %s mmap: %u\n\x00" + as *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 17], + &[libc::c_char; 17]>(b"output_init_alsa\x00")).as_ptr(), + 979 as libc::c_int, output.buffer, output.period, + if !alsa_sample_fmt.is_null() { + alsa_sample_fmt as *const libc::c_char + } else { b"any\x00" as *const u8 as *const libc::c_char }, + alsa.mmap as libc::c_int); } - crate::stdlib::snd_lib_error_set_handler(::std::mem::transmute::< - Option< - unsafe extern "C" fn( - _: *const libc::c_char, - _: libc::c_int, - _: *const libc::c_char, - _: libc::c_int, - _: *const libc::c_char, - _: ... - ) -> *mut libc::c_void, - >, - crate::stdlib::snd_lib_error_handler_t, - >(Some( - alsa_error_handler - as unsafe extern "C" fn( - _: *const libc::c_char, - _: libc::c_int, - _: *const libc::c_char, - _: libc::c_int, - _: *const libc::c_char, - _: ... - ) -> *mut libc::c_void, - ))); - crate::src::output::output_init_common(level, device, output_buf_size, rates, idle); + snd_lib_error_set_handler(::std::mem::transmute:: + *mut libc::c_void>, + snd_lib_error_handler_t>(Some(alsa_error_handler + as + unsafe extern "C" fn(_: + *const libc::c_char, + _: + libc::c_int, + _: + *const libc::c_char, + _: + libc::c_int, + _: + *const libc::c_char, + _: + ...) + -> + *mut libc::c_void))); + output_init_common(level, device, output_buf_size, rates, idle); if !volume_mixer_name.is_null() { - if mixer_init_alsa( - alsa.mixer_ctl, - alsa.volume_mixer_name, - (if !volume_mixer_index.is_null() { - crate::stdlib::atoi(volume_mixer_index) - } else { - 0 as libc::c_int - }), - ) < 0 as libc::c_int - { - crate::src::utils::logprint( - b"%s %s:%d Initialization of mixer failed, reverting to software volume\n\x00" - as *const u8 as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"output_init_alsa\x00")) - .as_ptr(), - 989 as libc::c_int, - ); - alsa.mixer_handle = 0 as *mut crate::stdlib::snd_mixer_t; + if mixer_init_alsa(alsa.mixer_ctl, alsa.volume_mixer_name, + (if !volume_mixer_index.is_null() { + atoi(volume_mixer_index) + } else { 0 as libc::c_int })) < 0 as libc::c_int { + logprint(b"%s %s:%d Initialization of mixer failed, reverting to software volume\n\x00" + as *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 17], + &[libc::c_char; 17]>(b"output_init_alsa\x00")).as_ptr(), + 989 as libc::c_int); + alsa.mixer_handle = 0 as *mut snd_mixer_t; alsa.volume_mixer_name = 0 as *const libc::c_char } } if mixer_unmute as libc::c_int != 0 && !alsa.volume_mixer_name.is_null() { - set_mixer( - 1 as libc::c_int != 0, - 0 as libc::c_int as libc::c_float, - 0 as libc::c_int as libc::c_float, - ); + set_mixer(1 as libc::c_int != 0, 0 as libc::c_int as libc::c_float, + 0 as libc::c_int as libc::c_float); alsa.volume_mixer_name = 0 as *const libc::c_char } - // RT linux - aim to avoid pagefaults by locking memory: - // https://rt.wiki.kernel.org/index.php/Threaded_RT-application_with_memory_locking_and_stack_handling_example - if crate::stdlib::mlockall(1 as libc::c_int | 2 as libc::c_int) == -(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 unable to lock memory: %s\n\x00" as *const u8 as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"output_init_alsa\x00")) - .as_ptr(), - 1003 as libc::c_int, - crate::stdlib::strerror(*crate::stdlib::__errno_location()), - ); + // RT linux - aim to avoid pagefaults by locking memory: + // https://rt.wiki.kernel.org/index.php/Threaded_RT-application_with_memory_locking_and_stack_handling_example + if mlockall(1 as libc::c_int | 2 as libc::c_int) == -(1 as libc::c_int) { + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d unable to lock memory: %s\n\x00" as *const u8 + as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 17], + &[libc::c_char; 17]>(b"output_init_alsa\x00")).as_ptr(), + 1003 as libc::c_int, strerror(*__errno_location())); } - } 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 memory locked\n\x00" as *const u8 as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"output_init_alsa\x00")) - .as_ptr(), - 1005 as libc::c_int, - ); + } else if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint + { + logprint(b"%s %s:%d memory locked\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 17], + &[libc::c_char; 17]>(b"output_init_alsa\x00")).as_ptr(), + 1005 as libc::c_int); } - crate::stdlib::mallopt(-(1 as libc::c_int), -(1 as libc::c_int)); - crate::stdlib::mallopt(-(4 as libc::c_int), 0 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 glibc detected using mallopt\n\x00" as *const u8 as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"output_init_alsa\x00")) - .as_ptr(), - 1011 as libc::c_int, - ); + mallopt(-(1 as libc::c_int), -(1 as libc::c_int)); + mallopt(-(4 as libc::c_int), 0 as libc::c_int); + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d glibc detected using mallopt\n\x00" as *const u8 + as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 17], + &[libc::c_char; 17]>(b"output_init_alsa\x00")).as_ptr(), + 1011 as libc::c_int); } - crate::src::utils::touch_memory( - silencebuf, - (2048 as libc::c_int * 8 as libc::c_int) as crate::stddef_h::size_t, - ); - crate::src::utils::touch_memory((*outputbuf).buf, (*outputbuf).size); + touch_memory(silencebuf, + (2048 as libc::c_int * 8 as libc::c_int) as size_t); + touch_memory((*outputbuf).buf, (*outputbuf).size); // start output thread - 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, - Some(output_thread as unsafe extern "C" fn(_: *mut libc::c_void) -> *mut libc::c_void), - if *rates.offset(0 as libc::c_int as isize) != 0 { - b"probe\x00" as *const u8 as *const libc::c_char - } else { - 0 as *const libc::c_char - } as *mut libc::c_void, - ); - crate::stdlib::pthread_attr_destroy(&mut attr); + let mut attr: pthread_attr_t = pthread_attr_t{__size: [0; 56],}; + pthread_attr_init(&mut attr); + pthread_attr_setstacksize(&mut attr, + (16384 as libc::c_int + + 64 as libc::c_int * 1024 as libc::c_int) as + size_t); + pthread_create(&mut thread, &mut attr, + Some(output_thread as + unsafe extern "C" fn(_: *mut libc::c_void) + -> *mut libc::c_void), + if *rates.offset(0 as libc::c_int as isize) != 0 { + b"probe\x00" as *const u8 as *const libc::c_char + } else { 0 as *const libc::c_char } as *mut libc::c_void); + pthread_attr_destroy(&mut attr); // try to set this thread to real-time scheduler class, only works as root or if user has permission - let mut param = crate::stdlib::sched_param { sched_priority: 0 }; + let mut param: sched_param = sched_param{sched_priority: 0,}; param.sched_priority = rt_priority as libc::c_int; - if crate::stdlib::pthread_setschedparam(thread, 1 as libc::c_int, &mut param) - != 0 as libc::c_int - { - 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 unable to set output sched fifo: %s\n\x00" as *const u8 - as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"output_init_alsa\x00")) - .as_ptr(), - 1029 as libc::c_int, - crate::stdlib::strerror(*crate::stdlib::__errno_location()), - ); + if pthread_setschedparam(thread, 1 as libc::c_int, &mut param) != + 0 as libc::c_int { + if loglevel as libc::c_uint >= lDEBUG as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d unable to set output sched fifo: %s\n\x00" as + *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 17], + &[libc::c_char; 17]>(b"output_init_alsa\x00")).as_ptr(), + 1029 as libc::c_int, strerror(*__errno_location())); } - } else 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 set output sched fifo rt: %u\n\x00" as *const u8 as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"output_init_alsa\x00")) - .as_ptr(), - 1031 as libc::c_int, - param.sched_priority, - ); + } else if loglevel as libc::c_uint >= + lDEBUG as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d set output sched fifo rt: %u\n\x00" as *const u8 + as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 17], + &[libc::c_char; 17]>(b"output_init_alsa\x00")).as_ptr(), + 1031 as libc::c_int, param.sched_priority); }; } #[no_mangle] - pub unsafe extern "C" fn output_close_alsa() { - 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; 18], &[libc::c_char; 18]>(b"output_close_alsa\x00")) - .as_ptr(), - 1036 as libc::c_int, - ); + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d close output\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 18], + &[libc::c_char; 18]>(b"output_close_alsa\x00")).as_ptr(), + 1036 as libc::c_int); } - crate::stdlib::pthread_mutex_lock(&mut (*outputbuf).mutex); + pthread_mutex_lock(&mut (*outputbuf).mutex); running = 0 as libc::c_int != 0; - crate::stdlib::pthread_mutex_unlock(&mut (*outputbuf).mutex); - crate::stdlib::pthread_join(thread, 0 as *mut *mut libc::c_void); + pthread_mutex_unlock(&mut (*outputbuf).mutex); + pthread_join(thread, 0 as *mut *mut libc::c_void); if !alsa.write_buf.is_null() { - crate::stdlib::free(alsa.write_buf as *mut libc::c_void); - } - if !alsa.ctl.is_null() { - crate::stdlib::free(alsa.ctl as *mut libc::c_void); + free(alsa.write_buf as *mut libc::c_void); } + if !alsa.ctl.is_null() { free(alsa.ctl as *mut libc::c_void); } if !alsa.mixer_ctl.is_null() { - crate::stdlib::free(alsa.mixer_ctl as *mut libc::c_void); + free(alsa.mixer_ctl as *mut libc::c_void); } - if !alsa.mixer_handle.is_null() { - crate::stdlib::snd_mixer_close(alsa.mixer_handle); - } - crate::src::output::output_close_common(); + if !alsa.mixer_handle.is_null() { snd_mixer_close(alsa.mixer_handle); } + output_close_common(); } // ALSA diff --git a/src/output_pa.rs b/src/output_pa.rs index f86a2d8..c1d881c 100644 --- a/src/output_pa.rs +++ b/src/output_pa.rs @@ -1,7 +1,7 @@ use ::libc; // PORTAUDIO // Portaudio output -/* +/* * Squeezelite - lightweight headless squeezebox emulator * * (c) Adrian Smith 2012-2015, triode1@btinternet.com @@ -11,7 +11,7 @@ use ::libc; * 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 diff --git a/src/output_pack.rs b/src/output_pack.rs index bcb5b16..873ed0b 100644 --- a/src/output_pack.rs +++ b/src/output_pack.rs @@ -1,324 +1,350 @@ 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; +extern "C" { + #[no_mangle] + fn memcpy(_: *mut libc::c_void, _: *const libc::c_void, _: libc::c_ulong) + -> *mut libc::c_void; +} +pub type __uint8_t = libc::c_uchar; +pub type __int32_t = libc::c_int; +pub type __uint32_t = libc::c_uint; +pub type __int64_t = libc::c_long; +pub type int32_t = __int32_t; +pub type int64_t = __int64_t; +pub type u_int8_t = __uint8_t; +pub type u_int32_t = __uint32_t; +pub type u8_t = u_int8_t; +pub type u32_t = u_int32_t; +pub type s32_t = int32_t; +pub type s64_t = int64_t; +pub type frames_t = u32_t; +pub type uintptr_t = libc::c_ulong; +pub type output_format = libc::c_uint; +pub const S16_LE: output_format = 3; +pub const S24_3LE: output_format = 2; +pub const S24_LE: output_format = 1; +pub const S32_LE: output_format = 0; // inlining these on windows prevents them being linkable... #[inline] - -unsafe extern "C" fn gain( - mut gain_0: 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; +unsafe extern "C" fn gain(mut gain_0: s32_t, mut sample: s32_t) -> s32_t { + let mut res: s64_t = gain_0 as s64_t * sample as s64_t; if res as libc::c_longlong > 0x7fffffffffff as libc::c_longlong { - res = 0x7fffffffffff as libc::c_longlong as crate::squeezelite_h::s64_t + res = 0x7fffffffffff as libc::c_longlong as s64_t } if (res as libc::c_longlong) < -(0x7fffffffffff as libc::c_longlong) { - res = -(0x7fffffffffff as libc::c_longlong) as crate::squeezelite_h::s64_t + res = -(0x7fffffffffff as libc::c_longlong) as s64_t } - return (res >> 16 as libc::c_int) as crate::squeezelite_h::s32_t; + return (res >> 16 as libc::c_int) as s32_t; } #[no_mangle] - -pub unsafe extern "C" fn _scale_and_pack_frames( - mut outputptr: *mut libc::c_void, - mut inputptr: *mut 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, -) { +pub unsafe extern "C" fn _scale_and_pack_frames(mut outputptr: + *mut libc::c_void, + mut inputptr: *mut s32_t, + mut cnt: frames_t, + mut gainL: s32_t, + mut gainR: s32_t, + mut format: output_format) { match format as libc::c_uint { 3 => { - let mut optr = outputptr as *mut crate::squeezelite_h::u32_t; - if gainL == 0x10000 as libc::c_int && gainR == 0x10000 as libc::c_int { - loop { + let mut optr: *mut u32_t = outputptr as *mut u32_t; + if gainL == 0x10000 as libc::c_int && + gainR == 0x10000 as libc::c_int { + loop { let fresh0 = cnt; cnt = cnt.wrapping_sub(1); - if !(fresh0 != 0) { - break; - } + 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; + *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 { + loop { let fresh2 = cnt; cnt = cnt.wrapping_sub(1); - if !(fresh2 != 0) { - break; - } + 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; + *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 mut optr_0: *mut u32_t = outputptr as *mut u32_t; + if gainL == 0x10000 as libc::c_int && + gainR == 0x10000 as libc::c_int { + loop { let fresh4 = cnt; cnt = cnt.wrapping_sub(1); - if !(fresh4 != 0) { - break; - } + 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; + *fresh6 = (*fresh5 >> 8 as libc::c_int) as u32_t; let fresh7 = inputptr; inputptr = inputptr.offset(1); let fresh8 = optr_0; optr_0 = optr_0.offset(1); - *fresh8 = (*fresh7 >> 8 as libc::c_int) as crate::squeezelite_h::u32_t + *fresh8 = (*fresh7 >> 8 as libc::c_int) as u32_t } } else { - loop { + loop { let fresh9 = cnt; cnt = cnt.wrapping_sub(1); - if !(fresh9 != 0) { - break; - } + 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; + (gain(gainL, *fresh10) >> 8 as libc::c_int) as u32_t; let fresh12 = inputptr; inputptr = inputptr.offset(1); let fresh13 = optr_0; optr_0 = optr_0.offset(1); *fresh13 = - (gain(gainR, *fresh12) >> 8 as libc::c_int) as crate::squeezelite_h::u32_t + (gain(gainR, *fresh12) >> 8 as libc::c_int) as 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 { + let mut optr_1: *mut u8_t = outputptr as *mut u8_t; + if gainL == 0x10000 as libc::c_int && + gainR == 0x10000 as libc::c_int { while cnt != 0 { // attempt to do 32 bit memory accesses - move 2 frames at once: 16 bytes -> 12 bytes - // falls through to exception case when not aligned or if less than 2 frames to move - if optr_1 as 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; + // falls through to exception case when not aligned or if less than 2 frames to move + if optr_1 as uintptr_t & + 0x3 as libc::c_int as libc::c_ulong == + 0 as libc::c_int as libc::c_ulong && + cnt >= 2 as libc::c_int as libc::c_uint { + let mut o_ptr: *mut u32_t = + optr_1 as *mut libc::c_void as *mut u32_t; while cnt >= 2 as libc::c_int as libc::c_uint { let fresh14 = inputptr; inputptr = inputptr.offset(1); - let mut l1 = *fresh14; + let mut l1: s32_t = *fresh14; let fresh15 = inputptr; inputptr = inputptr.offset(1); - let mut r1 = *fresh15; + let mut r1: s32_t = *fresh15; let fresh16 = inputptr; inputptr = inputptr.offset(1); - let mut l2 = *fresh16; + let mut l2: s32_t = *fresh16; let fresh17 = inputptr; inputptr = inputptr.offset(1); - let mut r2 = *fresh17; + let mut r2: s32_t = *fresh17; let fresh18 = o_ptr; o_ptr = o_ptr.offset(1); - *fresh18 = (l1 as libc::c_uint & 0xffffff00 as libc::c_uint) - >> 8 as libc::c_int - | ((r1 & 0xff00 as libc::c_int) << 16 as libc::c_int) - as libc::c_uint; + *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; + *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 + *fresh20 = + (l2 as libc::c_uint & + 0xff000000 as libc::c_uint) >> + 24 as libc::c_int | + r2 as libc::c_uint & + 0xffffff00 as libc::c_uint; + optr_1 = + optr_1.offset(12 as libc::c_int as isize); + cnt = + (cnt as + libc::c_uint).wrapping_sub(2 as + libc::c_int + as + libc::c_uint) + as frames_t as frames_t } } else { let fresh21 = inputptr; inputptr = inputptr.offset(1); - let mut lsample = *fresh21; + let mut lsample: s32_t = *fresh21; let fresh22 = inputptr; inputptr = inputptr.offset(1); - let mut rsample = *fresh22; + let mut rsample: s32_t = *fresh22; let fresh23 = optr_1; optr_1 = optr_1.offset(1); - *fresh23 = ((lsample & 0xff00 as libc::c_int) >> 8 as libc::c_int) - as crate::squeezelite_h::u8_t; + *fresh23 = + ((lsample & 0xff00 as libc::c_int) >> + 8 as libc::c_int) as u8_t; let fresh24 = optr_1; optr_1 = optr_1.offset(1); - *fresh24 = ((lsample & 0xff0000 as libc::c_int) >> 16 as libc::c_int) - as crate::squeezelite_h::u8_t; + *fresh24 = + ((lsample & 0xff0000 as libc::c_int) >> + 16 as libc::c_int) as u8_t; let fresh25 = optr_1; optr_1 = optr_1.offset(1); - *fresh25 = ((lsample as libc::c_uint & 0xff000000 as libc::c_uint) - >> 24 as libc::c_int) - as crate::squeezelite_h::u8_t; + *fresh25 = + ((lsample as libc::c_uint & + 0xff000000 as libc::c_uint) >> + 24 as libc::c_int) as u8_t; let fresh26 = optr_1; optr_1 = optr_1.offset(1); - *fresh26 = ((rsample & 0xff00 as libc::c_int) >> 8 as libc::c_int) - as crate::squeezelite_h::u8_t; + *fresh26 = + ((rsample & 0xff00 as libc::c_int) >> + 8 as libc::c_int) as u8_t; let fresh27 = optr_1; optr_1 = optr_1.offset(1); - *fresh27 = ((rsample & 0xff0000 as libc::c_int) >> 16 as libc::c_int) - as crate::squeezelite_h::u8_t; + *fresh27 = + ((rsample & 0xff0000 as libc::c_int) >> + 16 as libc::c_int) as u8_t; let fresh28 = optr_1; optr_1 = optr_1.offset(1); - *fresh28 = ((rsample as libc::c_uint & 0xff000000 as libc::c_uint) - >> 24 as libc::c_int) - as crate::squeezelite_h::u8_t; + *fresh28 = + ((rsample as libc::c_uint & + 0xff000000 as libc::c_uint) >> + 24 as libc::c_int) as u8_t; cnt = cnt.wrapping_sub(1) } } } else { while cnt != 0 { // attempt to do 32 bit memory accesses - move 2 frames at once: 16 bytes -> 12 bytes - // falls through to exception case when not aligned or if less than 2 frames to move - if optr_1 as 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; + // falls through to exception case when not aligned or if less than 2 frames to move + if optr_1 as uintptr_t & + 0x3 as libc::c_int as libc::c_ulong == + 0 as libc::c_int as libc::c_ulong && + cnt >= 2 as libc::c_int as libc::c_uint { + let mut o_ptr_0: *mut u32_t = + optr_1 as *mut libc::c_void as *mut u32_t; while cnt >= 2 as libc::c_int as libc::c_uint { let fresh29 = inputptr; inputptr = inputptr.offset(1); - let mut l1_0 = gain(gainL, *fresh29); + let mut l1_0: s32_t = gain(gainL, *fresh29); let fresh30 = inputptr; inputptr = inputptr.offset(1); - let mut r1_0 = gain(gainR, *fresh30); + let mut r1_0: s32_t = gain(gainR, *fresh30); let fresh31 = inputptr; inputptr = inputptr.offset(1); - let mut l2_0 = gain(gainL, *fresh31); + let mut l2_0: s32_t = gain(gainL, *fresh31); let fresh32 = inputptr; inputptr = inputptr.offset(1); - let mut r2_0 = gain(gainR, *fresh32); + let mut r2_0: s32_t = gain(gainR, *fresh32); let fresh33 = o_ptr_0; o_ptr_0 = o_ptr_0.offset(1); - *fresh33 = (l1_0 as libc::c_uint & 0xffffff00 as libc::c_uint) - >> 8 as libc::c_int - | ((r1_0 & 0xff00 as libc::c_int) << 16 as libc::c_int) - as libc::c_uint; + *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; + *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 + *fresh35 = + (l2_0 as libc::c_uint & + 0xff000000 as libc::c_uint) >> + 24 as libc::c_int | + r2_0 as libc::c_uint & + 0xffffff00 as libc::c_uint; + optr_1 = + optr_1.offset(12 as libc::c_int as isize); + cnt = + (cnt as + libc::c_uint).wrapping_sub(2 as + libc::c_int + as + libc::c_uint) + as frames_t as frames_t } } else { let fresh36 = inputptr; inputptr = inputptr.offset(1); - let mut lsample_0 = gain(gainL, *fresh36); + let mut lsample_0: s32_t = gain(gainL, *fresh36); let fresh37 = inputptr; inputptr = inputptr.offset(1); - let mut rsample_0 = gain(gainR, *fresh37); + let mut rsample_0: s32_t = gain(gainR, *fresh37); let fresh38 = optr_1; optr_1 = optr_1.offset(1); - *fresh38 = ((lsample_0 & 0xff00 as libc::c_int) >> 8 as libc::c_int) - as crate::squeezelite_h::u8_t; + *fresh38 = + ((lsample_0 & 0xff00 as libc::c_int) >> + 8 as libc::c_int) as u8_t; let fresh39 = optr_1; optr_1 = optr_1.offset(1); - *fresh39 = ((lsample_0 & 0xff0000 as libc::c_int) >> 16 as libc::c_int) - as crate::squeezelite_h::u8_t; + *fresh39 = + ((lsample_0 & 0xff0000 as libc::c_int) >> + 16 as libc::c_int) as u8_t; let fresh40 = optr_1; optr_1 = optr_1.offset(1); - *fresh40 = ((lsample_0 as libc::c_uint & 0xff000000 as libc::c_uint) - >> 24 as libc::c_int) - as crate::squeezelite_h::u8_t; + *fresh40 = + ((lsample_0 as libc::c_uint & + 0xff000000 as libc::c_uint) >> + 24 as libc::c_int) as u8_t; let fresh41 = optr_1; optr_1 = optr_1.offset(1); - *fresh41 = ((rsample_0 & 0xff00 as libc::c_int) >> 8 as libc::c_int) - as crate::squeezelite_h::u8_t; + *fresh41 = + ((rsample_0 & 0xff00 as libc::c_int) >> + 8 as libc::c_int) as u8_t; let fresh42 = optr_1; optr_1 = optr_1.offset(1); - *fresh42 = ((rsample_0 & 0xff0000 as libc::c_int) >> 16 as libc::c_int) - as crate::squeezelite_h::u8_t; + *fresh42 = + ((rsample_0 & 0xff0000 as libc::c_int) >> + 16 as libc::c_int) as u8_t; let fresh43 = optr_1; optr_1 = optr_1.offset(1); - *fresh43 = ((rsample_0 as libc::c_uint & 0xff000000 as libc::c_uint) - >> 24 as libc::c_int) - as crate::squeezelite_h::u8_t; + *fresh43 = + ((rsample_0 as libc::c_uint & + 0xff000000 as libc::c_uint) >> + 24 as libc::c_int) as u8_t; cnt = cnt.wrapping_sub(1) } } } } 0 => { - let mut optr_2 = 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, - ); + let mut optr_2: *mut u32_t = outputptr as *mut u32_t; + if gainL == 0x10000 as libc::c_int && + gainR == 0x10000 as libc::c_int { + memcpy(outputptr, inputptr as *const libc::c_void, + cnt.wrapping_mul(8 as libc::c_int as libc::c_uint) as + libc::c_ulong); } else { - loop { + loop { let fresh44 = cnt; cnt = cnt.wrapping_sub(1); - if !(fresh44 != 0) { - break; - } + 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; + *fresh46 = gain(gainL, *fresh45) as u32_t; let fresh47 = inputptr; inputptr = inputptr.offset(1); let fresh48 = optr_2; optr_2 = optr_2.offset(1); - *fresh48 = gain(gainR, *fresh47) as crate::squeezelite_h::u32_t + *fresh48 = gain(gainR, *fresh47) as u32_t } } } - _ => {} + _ => { } }; } diff --git a/src/output_pulse.rs b/src/output_pulse.rs index 77f5f52..fe6d259 100644 --- a/src/output_pulse.rs +++ b/src/output_pulse.rs @@ -1,6 +1,6 @@ use ::libc; // Output using PulseAudio -/* +/* * Squeezelite - lightweight headless squeezebox emulator * * (c) Adrian Smith 2012-2015, triode1@btinternet.com @@ -10,7 +10,7 @@ use ::libc; * 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 diff --git a/src/output_stdout.rs b/src/output_stdout.rs index a3a0d25..988fbff 100644 --- a/src/output_stdout.rs +++ b/src/output_stdout.rs @@ -1,286 +1,396 @@ 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" { + pub type _IO_wide_data; + pub type _IO_codecvt; + pub type _IO_marker; #[no_mangle] - pub static mut output: crate::squeezelite_h::outputstate; + static mut stdout: *mut FILE; #[no_mangle] - pub static mut outputbuf: *mut crate::squeezelite_h::buffer; + fn fwrite(_: *const libc::c_void, _: libc::c_ulong, _: libc::c_ulong, + _: *mut FILE) -> libc::c_ulong; #[no_mangle] - pub static mut silencebuf: *mut crate::squeezelite_h::u8_t; + fn malloc(_: libc::c_ulong) -> *mut libc::c_void; + #[no_mangle] + fn free(__ptr: *mut libc::c_void); + #[no_mangle] + fn memset(_: *mut libc::c_void, _: libc::c_int, _: libc::c_ulong) + -> *mut libc::c_void; + #[no_mangle] + fn strcmp(_: *const libc::c_char, _: *const libc::c_char) -> libc::c_int; + #[no_mangle] + fn _apply_cross(outputbuf_0: *mut buffer, out_frames: frames_t, + cross_gain_in: s32_t, cross_gain_out: s32_t, + cross_ptr: *mut *mut s32_t); + #[no_mangle] + fn _scale_and_pack_frames(outputptr: *mut libc::c_void, + inputptr: *mut s32_t, cnt: frames_t, + gainL: s32_t, gainR: s32_t, + format: output_format); + #[no_mangle] + fn _output_frames(avail: frames_t) -> frames_t; + #[no_mangle] + fn output_close_common(); + #[no_mangle] + fn output_init_common(level: log_level, device: *const libc::c_char, + output_buf_size: libc::c_uint, + rates: *mut libc::c_uint, idle: libc::c_uint); + #[no_mangle] + fn pthread_create(__newthread: *mut pthread_t, + __attr: *const pthread_attr_t, + __start_routine: + Option *mut libc::c_void>, + __arg: *mut libc::c_void) -> libc::c_int; + #[no_mangle] + fn pthread_attr_init(__attr: *mut pthread_attr_t) -> libc::c_int; + #[no_mangle] + fn pthread_attr_destroy(__attr: *mut pthread_attr_t) -> libc::c_int; + #[no_mangle] + fn pthread_attr_setstacksize(__attr: *mut pthread_attr_t, + __stacksize: size_t) -> libc::c_int; + #[no_mangle] + fn pthread_mutex_lock(__mutex: *mut pthread_mutex_t) -> libc::c_int; + #[no_mangle] + fn pthread_mutex_unlock(__mutex: *mut pthread_mutex_t) -> libc::c_int; + #[no_mangle] + fn logtime() -> *const libc::c_char; + #[no_mangle] + fn logprint(fmt: *const libc::c_char, _: ...); + #[no_mangle] + fn gettime_ms() -> u32_t; + #[no_mangle] + static mut output: outputstate; + #[no_mangle] + static mut outputbuf: *mut buffer; + #[no_mangle] + static mut silencebuf: *mut u8_t; } - -static mut loglevel: crate::squeezelite_h::log_level = crate::squeezelite_h::lERROR; - +pub type size_t = libc::c_ulong; +pub type __uint8_t = libc::c_uchar; +pub type __int32_t = libc::c_int; +pub type __uint32_t = libc::c_uint; +pub type __off_t = libc::c_long; +pub type __off64_t = libc::c_long; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct _IO_FILE { + pub _flags: libc::c_int, + pub _IO_read_ptr: *mut libc::c_char, + pub _IO_read_end: *mut libc::c_char, + pub _IO_read_base: *mut libc::c_char, + pub _IO_write_base: *mut libc::c_char, + pub _IO_write_ptr: *mut libc::c_char, + pub _IO_write_end: *mut libc::c_char, + pub _IO_buf_base: *mut libc::c_char, + pub _IO_buf_end: *mut libc::c_char, + pub _IO_save_base: *mut libc::c_char, + pub _IO_backup_base: *mut libc::c_char, + pub _IO_save_end: *mut libc::c_char, + pub _markers: *mut _IO_marker, + pub _chain: *mut _IO_FILE, + pub _fileno: libc::c_int, + pub _flags2: libc::c_int, + pub _old_offset: __off_t, + pub _cur_column: libc::c_ushort, + pub _vtable_offset: libc::c_schar, + pub _shortbuf: [libc::c_char; 1], + pub _lock: *mut libc::c_void, + pub _offset: __off64_t, + pub _codecvt: *mut _IO_codecvt, + pub _wide_data: *mut _IO_wide_data, + pub _freeres_list: *mut _IO_FILE, + pub _freeres_buf: *mut libc::c_void, + pub __pad5: size_t, + pub _mode: libc::c_int, + pub _unused2: [libc::c_char; 20], +} +pub type _IO_lock_t = (); +pub type FILE = _IO_FILE; +pub type int32_t = __int32_t; +pub type u_int8_t = __uint8_t; +pub type u_int32_t = __uint32_t; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct __pthread_internal_list { + pub __prev: *mut __pthread_internal_list, + pub __next: *mut __pthread_internal_list, +} +pub type __pthread_list_t = __pthread_internal_list; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct __pthread_mutex_s { + pub __lock: libc::c_int, + pub __count: libc::c_uint, + pub __owner: libc::c_int, + pub __nusers: libc::c_uint, + pub __kind: libc::c_int, + pub __spins: libc::c_short, + pub __elision: libc::c_short, + pub __list: __pthread_list_t, +} +pub type pthread_t = libc::c_ulong; +#[derive(Copy, Clone)] +#[repr(C)] +pub union pthread_attr_t { + pub __size: [libc::c_char; 56], + pub __align: libc::c_long, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub union pthread_mutex_t { + pub __data: __pthread_mutex_s, + pub __size: [libc::c_char; 40], + pub __align: libc::c_long, +} +pub type u8_t = u_int8_t; +pub type u32_t = u_int32_t; +pub type s32_t = int32_t; +pub type frames_t = u32_t; +pub type log_level = libc::c_uint; +pub const lSDEBUG: log_level = 4; +pub const lDEBUG: log_level = 3; +pub const lINFO: log_level = 2; +pub const lWARN: log_level = 1; +pub const lERROR: log_level = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct buffer { + pub buf: *mut u8_t, + pub readp: *mut u8_t, + pub writep: *mut u8_t, + pub wrap: *mut u8_t, + pub size: size_t, + pub base_size: size_t, + pub mutex: pthread_mutex_t, +} +pub type output_state = libc::c_int; +pub const OUTPUT_START_AT: output_state = 5; +pub const OUTPUT_SKIP_FRAMES: output_state = 4; +pub const OUTPUT_PAUSE_FRAMES: output_state = 3; +pub const OUTPUT_RUNNING: output_state = 2; +pub const OUTPUT_BUFFER: output_state = 1; +pub const OUTPUT_STOPPED: output_state = 0; +pub const OUTPUT_OFF: output_state = -1; +pub type output_format = libc::c_uint; +pub const S16_LE: output_format = 3; +pub const S24_3LE: output_format = 2; +pub const S24_LE: output_format = 1; +pub const S32_LE: output_format = 0; +pub type fade_state = libc::c_uint; +pub const FADE_ACTIVE: fade_state = 2; +pub const FADE_DUE: fade_state = 1; +pub const FADE_INACTIVE: fade_state = 0; +pub type fade_dir = libc::c_uint; +pub const FADE_CROSS: fade_dir = 3; +pub const FADE_DOWN: fade_dir = 2; +pub const FADE_UP: fade_dir = 1; +pub type fade_mode = libc::c_uint; +pub const FADE_INOUT: fade_mode = 4; +pub const FADE_OUT: fade_mode = 3; +pub const FADE_IN: fade_mode = 2; +pub const FADE_CROSSFADE: fade_mode = 1; +pub const FADE_NONE: fade_mode = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct outputstate { + pub state: output_state, + pub format: output_format, + pub device: *const libc::c_char, + pub buffer: libc::c_uint, + pub period: libc::c_uint, + pub track_started: bool, + pub write_cb: Option libc::c_int>, + pub start_frames: libc::c_uint, + pub frames_played: libc::c_uint, + pub frames_played_dmp: libc::c_uint, + pub current_sample_rate: libc::c_uint, + pub supported_rates: [libc::c_uint; 18], + pub default_sample_rate: libc::c_uint, + pub error_opening: bool, + pub device_frames: libc::c_uint, + pub updated: u32_t, + pub track_start_time: u32_t, + pub current_replay_gain: u32_t, + pub c2rust_unnamed: C2RustUnnamed, + pub next_sample_rate: libc::c_uint, + pub track_start: *mut u8_t, + pub gainL: u32_t, + pub gainR: u32_t, + pub invert: bool, + pub next_replay_gain: u32_t, + pub threshold: libc::c_uint, + pub fade: fade_state, + pub fade_start: *mut u8_t, + pub fade_end: *mut u8_t, + pub fade_dir: fade_dir, + pub fade_mode: fade_mode, + pub fade_secs: libc::c_uint, + pub rate_delay: libc::c_uint, + pub delay_active: bool, + pub stop_time: u32_t, + pub idle_to: u32_t, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub union C2RustUnnamed { + pub pause_frames: u32_t, + pub skip_frames: u32_t, + pub start_at: u32_t, +} +static mut loglevel: log_level = lERROR; static mut running: bool = 1 as libc::c_int != 0; // buffer to hold output data so we can block on writing outside of output lock, allocated on init - -static mut buf: *mut crate::squeezelite_h::u8_t = - 0 as *const crate::squeezelite_h::u8_t as *mut crate::squeezelite_h::u8_t; - +static mut buf: *mut u8_t = 0 as *const u8_t as *mut u8_t; static mut buffill: libc::c_uint = 0; - static mut bytes_per_frame: libc::c_int = 0; - -unsafe extern "C" fn _stdout_write_frames( - mut out_frames: 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; +unsafe extern "C" fn _stdout_write_frames(mut out_frames: frames_t, + mut silence: bool, mut gainL: s32_t, + mut gainR: s32_t, + mut cross_gain_in: s32_t, + mut cross_gain_out: s32_t, + mut cross_ptr: *mut *mut s32_t) + -> libc::c_int { + let mut obuf: *mut u8_t = 0 as *mut u8_t; if !silence { - if output.fade as libc::c_uint - == 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, - ); + if output.fade as libc::c_uint == + FADE_ACTIVE as libc::c_int as libc::c_uint && + output.fade_dir as libc::c_uint == + FADE_CROSS as libc::c_int as libc::c_uint && + !(*cross_ptr).is_null() { + _apply_cross(outputbuf, out_frames, cross_gain_in, cross_gain_out, + cross_ptr); } obuf = (*outputbuf).readp - } else { - obuf = silencebuf - } - 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, - ); + } else { obuf = silencebuf } + _scale_and_pack_frames(buf.offset(buffill.wrapping_mul(bytes_per_frame as + libc::c_uint) + as isize) as *mut libc::c_void, + obuf as *mut libc::c_void as *mut s32_t, + out_frames, gainL, gainR, output.format); buffill = buffill.wrapping_add(out_frames); return out_frames as libc::c_int; } - unsafe extern "C" fn output_thread() -> *mut libc::c_void { - crate::stdlib::pthread_mutex_lock(&mut (*outputbuf).mutex); + 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, + 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); + pthread_mutex_unlock(&mut (*outputbuf).mutex); while running { - crate::stdlib::pthread_mutex_lock(&mut (*outputbuf).mutex); + 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.updated = 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); + _output_frames(2048 as libc::c_int as frames_t); + 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, - ); + fwrite(buf as *const libc::c_void, + bytes_per_frame as libc::c_ulong, buffill as libc::c_ulong, + stdout); buffill = 0 as libc::c_int as libc::c_uint } } return 0 as *mut libc::c_void; } - -static mut thread: crate::stdlib::pthread_t = 0; +static mut thread: 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, -) { +pub unsafe extern "C" fn output_init_stdout(mut level: log_level, + mut output_buf_size: libc::c_uint, + mut params: *mut libc::c_char, + mut rates: *mut libc::c_uint, + mut rate_delay: libc::c_uint) { loglevel = level; - if loglevel as libc::c_uint >= 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, - ); + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d init output stdout\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 19], + &[libc::c_char; 19]>(b"output_init_stdout\x00")).as_ptr(), + 130 as libc::c_int); } - buf = crate::stdlib::malloc((2048 as libc::c_int * 8 as libc::c_int) as libc::c_ulong) - as *mut crate::squeezelite_h::u8_t; + buf = + malloc((2048 as libc::c_int * 8 as libc::c_int) as libc::c_ulong) as + *mut 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; + logprint(b"%s %s:%d unable to malloc buf\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 19], + &[libc::c_char; 19]>(b"output_init_stdout\x00")).as_ptr(), + 134 as libc::c_int); + return } buffill = 0 as libc::c_int as libc::c_uint; - 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::() 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, - ); + memset(&mut output as *mut outputstate as *mut libc::c_void, + 0 as libc::c_int, + ::std::mem::size_of::() as libc::c_ulong); + output.format = S32_LE; + output.start_frames = + (2048 as libc::c_int * 2 as libc::c_int) as libc::c_uint; + output.write_cb = + Some(_stdout_write_frames as + unsafe extern "C" fn(_: frames_t, _: bool, _: s32_t, + _: s32_t, _: s32_t, _: s32_t, + _: *mut *mut s32_t) -> libc::c_int); output.rate_delay = rate_delay; if !params.is_null() { - if crate::stdlib::strcmp(params, b"32\x00" as *const u8 as *const libc::c_char) == 0 { - output.format = crate::squeezelite_h::S32_LE + if strcmp(params, b"32\x00" as *const u8 as *const libc::c_char) == 0 + { + output.format = 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 strcmp(params, b"24\x00" as *const u8 as *const libc::c_char) == 0 + { + output.format = 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 + if strcmp(params, b"16\x00" as *const u8 as *const libc::c_char) == 0 + { + output.format = S16_LE } } // ensure output rate is specified to avoid test open if *rates.offset(0 as libc::c_int as isize) == 0 { - *rates.offset(0 as libc::c_int as isize) = 44100 as libc::c_int as libc::c_uint + *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 *mut libc::c_void>, - Option *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); + output_init_common(level, b"-\x00" as *const u8 as *const libc::c_char, + output_buf_size, rates, + 0 as libc::c_int as libc::c_uint); + let mut attr: pthread_attr_t = pthread_attr_t{__size: [0; 56],}; + pthread_attr_init(&mut attr); + pthread_attr_setstacksize(&mut attr, + (16384 as libc::c_int + + 64 as libc::c_int * 1024 as libc::c_int) as + size_t); + pthread_create(&mut thread, &mut attr, + ::std::mem::transmute:: *mut libc::c_void>, + Option + *mut libc::c_void>>(Some(::std::mem::transmute:: + *mut libc::c_void, + unsafe extern "C" fn() + -> + *mut libc::c_void>(output_thread))), + 0 as *mut libc::c_void); + pthread_attr_destroy(&mut attr); } -/* +/* * Squeezelite - lightweight headless squeezebox emulator * * (c) Adrian Smith 2012-2015, triode1@btinternet.com * Ralph Irving 2015-2017, ralph_irving@hotmail.com - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the @@ -327,20 +437,17 @@ pub unsafe extern "C" fn output_init_stdout( // 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, - ); + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d close output\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 20], + &[libc::c_char; 20]>(b"output_close_stdout\x00")).as_ptr(), + 174 as libc::c_int); } - crate::stdlib::pthread_mutex_lock(&mut (*outputbuf).mutex); + 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(); + pthread_mutex_unlock(&mut (*outputbuf).mutex); + free(buf as *mut libc::c_void); + output_close_common(); } diff --git a/src/pcm.rs b/src/pcm.rs index 054befd..5c261cd 100644 --- a/src/pcm.rs +++ b/src/pcm.rs @@ -1,245 +1,333 @@ 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::buffer::buf_adjust; -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::memcmp; -use crate::stdlib::memcpy; -use crate::stdlib::pthread_mutex_lock; -use crate::stdlib::pthread_mutex_unlock; extern "C" { - /* - * 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 . - * - */ #[no_mangle] - pub static mut loglevel: crate::squeezelite_h::log_level; + fn memcpy(_: *mut libc::c_void, _: *const libc::c_void, _: libc::c_ulong) + -> *mut libc::c_void; #[no_mangle] - pub static mut streambuf: *mut crate::squeezelite_h::buffer; + fn memcmp(_: *const libc::c_void, _: *const libc::c_void, + _: libc::c_ulong) -> libc::c_int; #[no_mangle] - pub static mut outputbuf: *mut crate::squeezelite_h::buffer; + fn _checkfade(_: bool); #[no_mangle] - pub static mut stream: crate::squeezelite_h::streamstate; + fn decode_newstream(sample_rate_0: libc::c_uint, + supported_rates: *mut libc::c_uint) -> libc::c_uint; #[no_mangle] - pub static mut output: crate::squeezelite_h::outputstate; + fn buf_adjust(buf: *mut buffer, mod_0: size_t); #[no_mangle] - pub static mut decode: crate::squeezelite_h::decodestate; + fn _buf_inc_writep(buf: *mut buffer, by: libc::c_uint); + #[no_mangle] + fn _buf_inc_readp(buf: *mut buffer, by: libc::c_uint); + #[no_mangle] + fn _buf_cont_write(buf: *mut buffer) -> libc::c_uint; + #[no_mangle] + fn _buf_cont_read(buf: *mut buffer) -> libc::c_uint; + #[no_mangle] + fn _buf_space(buf: *mut buffer) -> libc::c_uint; + #[no_mangle] + fn _buf_used(buf: *mut buffer) -> libc::c_uint; + #[no_mangle] + fn logprint(fmt: *const libc::c_char, _: ...); + #[no_mangle] + fn logtime() -> *const libc::c_char; + #[no_mangle] + fn pthread_mutex_unlock(__mutex: *mut pthread_mutex_t) -> libc::c_int; + #[no_mangle] + fn pthread_mutex_lock(__mutex: *mut pthread_mutex_t) -> libc::c_int; + /* + * 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 . + * + */ + #[no_mangle] + static mut loglevel: log_level; + #[no_mangle] + static mut streambuf: *mut buffer; + #[no_mangle] + static mut outputbuf: *mut buffer; + #[no_mangle] + static mut stream: streamstate; + #[no_mangle] + static mut output: outputstate; + #[no_mangle] + static mut decode: decodestate; +} +pub type size_t = libc::c_ulong; +pub type __uint8_t = libc::c_uchar; +pub type __int32_t = libc::c_int; +pub type __uint32_t = libc::c_uint; +pub type __uint64_t = libc::c_ulong; +pub type int32_t = __int32_t; +pub type u_int8_t = __uint8_t; +pub type u_int32_t = __uint32_t; +pub type u_int64_t = __uint64_t; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct __pthread_internal_list { + pub __prev: *mut __pthread_internal_list, + pub __next: *mut __pthread_internal_list, +} +pub type __pthread_list_t = __pthread_internal_list; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct __pthread_mutex_s { + pub __lock: libc::c_int, + pub __count: libc::c_uint, + pub __owner: libc::c_int, + pub __nusers: libc::c_uint, + pub __kind: libc::c_int, + pub __spins: libc::c_short, + pub __elision: libc::c_short, + pub __list: __pthread_list_t, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub union pthread_mutex_t { + pub __data: __pthread_mutex_s, + pub __size: [libc::c_char; 40], + pub __align: libc::c_long, +} +pub type u8_t = u_int8_t; +pub type u32_t = u_int32_t; +pub type u64_t = u_int64_t; +pub type s32_t = int32_t; +pub type frames_t = u32_t; +pub type log_level = libc::c_uint; +pub const lSDEBUG: log_level = 4; +pub const lDEBUG: log_level = 3; +pub const lINFO: log_level = 2; +pub const lWARN: log_level = 1; +pub const lERROR: log_level = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct buffer { + pub buf: *mut u8_t, + pub readp: *mut u8_t, + pub writep: *mut u8_t, + pub wrap: *mut u8_t, + pub size: size_t, + pub base_size: size_t, + pub mutex: pthread_mutex_t, +} +pub type stream_state = libc::c_uint; +pub const RECV_HEADERS: stream_state = 7; +pub const SEND_HEADERS: stream_state = 6; +pub const STREAMING_HTTP: stream_state = 5; +pub const STREAMING_FILE: stream_state = 4; +pub const STREAMING_BUFFERING: stream_state = 3; +pub const STREAMING_WAIT: stream_state = 2; +pub const DISCONNECT: stream_state = 1; +pub const STOPPED: stream_state = 0; +pub type disconnect_code = libc::c_uint; +pub const TIMEOUT: disconnect_code = 4; +pub const UNREACHABLE: disconnect_code = 3; +pub const REMOTE_DISCONNECT: disconnect_code = 2; +pub const LOCAL_DISCONNECT: disconnect_code = 1; +pub const DISCONNECT_OK: disconnect_code = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct streamstate { + pub state: stream_state, + pub disconnect: disconnect_code, + pub header: *mut libc::c_char, + pub header_len: size_t, + pub sent_headers: bool, + pub cont_wait: bool, + pub bytes: u64_t, + pub threshold: libc::c_uint, + pub meta_interval: u32_t, + pub meta_next: u32_t, + pub meta_left: u32_t, + pub meta_send: bool, +} +pub type decode_state = libc::c_uint; +pub const DECODE_ERROR: decode_state = 4; +pub const DECODE_COMPLETE: decode_state = 3; +pub const DECODE_RUNNING: decode_state = 2; +pub const DECODE_READY: decode_state = 1; +pub const DECODE_STOPPED: decode_state = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct decodestate { + pub state: decode_state, + pub new_stream: bool, + pub mutex: pthread_mutex_t, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct codec { + pub id: libc::c_char, + pub types: *mut libc::c_char, + pub min_read_bytes: libc::c_uint, + pub min_space: libc::c_uint, + pub open: Option ()>, + pub close: Option ()>, + pub decode: Option decode_state>, +} +pub type output_state = libc::c_int; +pub const OUTPUT_START_AT: output_state = 5; +pub const OUTPUT_SKIP_FRAMES: output_state = 4; +pub const OUTPUT_PAUSE_FRAMES: output_state = 3; +pub const OUTPUT_RUNNING: output_state = 2; +pub const OUTPUT_BUFFER: output_state = 1; +pub const OUTPUT_STOPPED: output_state = 0; +pub const OUTPUT_OFF: output_state = -1; +pub type output_format = libc::c_uint; +pub const S16_LE: output_format = 3; +pub const S24_3LE: output_format = 2; +pub const S24_LE: output_format = 1; +pub const S32_LE: output_format = 0; +pub type fade_state = libc::c_uint; +pub const FADE_ACTIVE: fade_state = 2; +pub const FADE_DUE: fade_state = 1; +pub const FADE_INACTIVE: fade_state = 0; +pub type fade_dir = libc::c_uint; +pub const FADE_CROSS: fade_dir = 3; +pub const FADE_DOWN: fade_dir = 2; +pub const FADE_UP: fade_dir = 1; +pub type fade_mode = libc::c_uint; +pub const FADE_INOUT: fade_mode = 4; +pub const FADE_OUT: fade_mode = 3; +pub const FADE_IN: fade_mode = 2; +pub const FADE_CROSSFADE: fade_mode = 1; +pub const FADE_NONE: fade_mode = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct outputstate { + pub state: output_state, + pub format: output_format, + pub device: *const libc::c_char, + pub buffer: libc::c_uint, + pub period: libc::c_uint, + pub track_started: bool, + pub write_cb: Option libc::c_int>, + pub start_frames: libc::c_uint, + pub frames_played: libc::c_uint, + pub frames_played_dmp: libc::c_uint, + pub current_sample_rate: libc::c_uint, + pub supported_rates: [libc::c_uint; 18], + pub default_sample_rate: libc::c_uint, + pub error_opening: bool, + pub device_frames: libc::c_uint, + pub updated: u32_t, + pub track_start_time: u32_t, + pub current_replay_gain: u32_t, + pub c2rust_unnamed: C2RustUnnamed, + pub next_sample_rate: libc::c_uint, + pub track_start: *mut u8_t, + pub gainL: u32_t, + pub gainR: u32_t, + pub invert: bool, + pub next_replay_gain: u32_t, + pub threshold: libc::c_uint, + pub fade: fade_state, + pub fade_start: *mut u8_t, + pub fade_end: *mut u8_t, + pub fade_dir: fade_dir, + pub fade_mode: fade_mode, + pub fade_secs: libc::c_uint, + pub rate_delay: libc::c_uint, + pub delay_active: bool, + pub stop_time: u32_t, + pub idle_to: u32_t, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub union C2RustUnnamed { + pub pause_frames: u32_t, + pub skip_frames: u32_t, + pub start_at: u32_t, } - pub const AIFF: header_format = 2; - pub type header_format = libc::c_uint; - pub const WAVE: header_format = 1; - pub const UNKNOWN: header_format = 0; #[no_mangle] - pub static mut pcm_check_header: bool = 0 as libc::c_int != 0; - -static mut sample_rates: [crate::squeezelite_h::u32_t; 17] = [ - 11025 as libc::c_int as crate::squeezelite_h::u32_t, - 22050 as libc::c_int as crate::squeezelite_h::u32_t, - 32000 as libc::c_int as crate::squeezelite_h::u32_t, - 44100 as libc::c_int as crate::squeezelite_h::u32_t, - 48000 as libc::c_int as crate::squeezelite_h::u32_t, - 8000 as libc::c_int as crate::squeezelite_h::u32_t, - 12000 as libc::c_int as crate::squeezelite_h::u32_t, - 16000 as libc::c_int as crate::squeezelite_h::u32_t, - 24000 as libc::c_int as crate::squeezelite_h::u32_t, - 96000 as libc::c_int as crate::squeezelite_h::u32_t, - 88200 as libc::c_int as crate::squeezelite_h::u32_t, - 176400 as libc::c_int as crate::squeezelite_h::u32_t, - 192000 as libc::c_int as crate::squeezelite_h::u32_t, - 352800 as libc::c_int as crate::squeezelite_h::u32_t, - 384000 as libc::c_int as crate::squeezelite_h::u32_t, - 705600 as libc::c_int as crate::squeezelite_h::u32_t, - 768000 as libc::c_int as crate::squeezelite_h::u32_t, -]; - -static mut sample_rate: crate::squeezelite_h::u32_t = 0; - -static mut sample_size: crate::squeezelite_h::u32_t = 0; - -static mut channels: crate::squeezelite_h::u32_t = 0; - +static mut sample_rates: [u32_t; 17] = + [11025 as libc::c_int as u32_t, 22050 as libc::c_int as u32_t, + 32000 as libc::c_int as u32_t, 44100 as libc::c_int as u32_t, + 48000 as libc::c_int as u32_t, 8000 as libc::c_int as u32_t, + 12000 as libc::c_int as u32_t, 16000 as libc::c_int as u32_t, + 24000 as libc::c_int as u32_t, 96000 as libc::c_int as u32_t, + 88200 as libc::c_int as u32_t, 176400 as libc::c_int as u32_t, + 192000 as libc::c_int as u32_t, 352800 as libc::c_int as u32_t, + 384000 as libc::c_int as u32_t, 705600 as libc::c_int as u32_t, + 768000 as libc::c_int as u32_t]; +static mut sample_rate: u32_t = 0; +static mut sample_size: u32_t = 0; +static mut channels: u32_t = 0; static mut bigendian: bool = false; - static mut limit: bool = false; - -static mut audio_left: crate::squeezelite_h::u32_t = 0; - -static mut bytes_per_frame: crate::squeezelite_h::u32_t = 0; - +static mut audio_left: u32_t = 0; +static mut bytes_per_frame: u32_t = 0; unsafe extern "C" fn _check_header() { - let mut ptr = (*streambuf).readp; - let mut 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) - }; - let mut format = UNKNOWN; + let mut ptr: *mut u8_t = (*streambuf).readp; + let mut bytes: libc::c_uint = + if _buf_used(streambuf) < _buf_cont_read(streambuf) { + _buf_used(streambuf) + } else { _buf_cont_read(streambuf) }; + let mut format: header_format = UNKNOWN; // simple parsing of wav and aiff headers and get to samples if bytes > 12 as libc::c_int as libc::c_uint { - if crate::stdlib::memcmp( - ptr as *const libc::c_void, - b"RIFF\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(8 as libc::c_int as isize) as *const libc::c_void, - b"WAVE\x00" as *const u8 as *const libc::c_char as *const libc::c_void, - 4 as libc::c_int as libc::c_ulong, - ) == 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 WAVE\n\x00" as *const u8 as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 14], &[libc::c_char; 14]>( - b"_check_header\x00", - )) - .as_ptr(), - 80 as libc::c_int, - ); + if memcmp(ptr as *const libc::c_void, + b"RIFF\x00" as *const u8 as *const libc::c_char as + *const libc::c_void, 4 as libc::c_int as libc::c_ulong) + == 0 && + memcmp(ptr.offset(8 as libc::c_int as isize) as + *const libc::c_void, + b"WAVE\x00" as *const u8 as *const libc::c_char as + *const libc::c_void, + 4 as libc::c_int as libc::c_ulong) == 0 { + if loglevel as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d WAVE\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 14], + &[libc::c_char; 14]>(b"_check_header\x00")).as_ptr(), + 80 as libc::c_int); } format = WAVE - } else if crate::stdlib::memcmp( - ptr as *const libc::c_void, - b"FORM\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(8 as libc::c_int as isize) as *const libc::c_void, - b"AIFF\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(8 as libc::c_int as isize) as *const libc::c_void, - b"AIFC\x00" as *const u8 as *const libc::c_char as *const libc::c_void, - 4 as libc::c_int as libc::c_ulong, - ) == 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 AIFF\n\x00" as *const u8 as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 14], &[libc::c_char; 14]>( - b"_check_header\x00", - )) - .as_ptr(), - 83 as libc::c_int, - ); + } else if memcmp(ptr as *const libc::c_void, + b"FORM\x00" as *const u8 as *const libc::c_char as + *const libc::c_void, + 4 as libc::c_int as libc::c_ulong) == 0 && + (memcmp(ptr.offset(8 as libc::c_int as isize) as + *const libc::c_void, + b"AIFF\x00" as *const u8 as *const libc::c_char + as *const libc::c_void, + 4 as libc::c_int as libc::c_ulong) == 0 || + memcmp(ptr.offset(8 as libc::c_int as isize) as + *const libc::c_void, + b"AIFC\x00" as *const u8 as + *const libc::c_char as + *const libc::c_void, + 4 as libc::c_int as libc::c_ulong) == 0) { + if loglevel as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d AIFF\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 14], + &[libc::c_char; 14]>(b"_check_header\x00")).as_ptr(), + 83 as libc::c_int); } format = AIFF } @@ -250,215 +338,195 @@ unsafe extern "C" fn _check_header() { while bytes >= 8 as libc::c_int as libc::c_uint { let mut id: [libc::c_char; 5] = [0; 5]; let mut len: libc::c_uint = 0; - crate::stdlib::memcpy( - id.as_mut_ptr() as *mut libc::c_void, - ptr as *const libc::c_void, - 4 as libc::c_int as libc::c_ulong, - ); + memcpy(id.as_mut_ptr() as *mut libc::c_void, + ptr as *const libc::c_void, + 4 as libc::c_int as libc::c_ulong); id[4 as libc::c_int as usize] = '\u{0}' as i32 as libc::c_char; if format as libc::c_uint == WAVE as libc::c_int as libc::c_uint { - len = (*ptr.offset(4 as libc::c_int as isize) as libc::c_int - | (*ptr.offset(5 as libc::c_int as isize) as libc::c_int) << 8 as libc::c_int - | (*ptr.offset(6 as libc::c_int as isize) as libc::c_int) << 16 as libc::c_int - | (*ptr.offset(7 as libc::c_int as isize) as libc::c_int) << 24 as libc::c_int) - as libc::c_uint + len = + (*ptr.offset(4 as libc::c_int as isize) as libc::c_int | + (*ptr.offset(5 as libc::c_int as isize) as + libc::c_int) << 8 as libc::c_int | + (*ptr.offset(6 as libc::c_int as isize) as + libc::c_int) << 16 as libc::c_int | + (*ptr.offset(7 as libc::c_int as isize) as + libc::c_int) << 24 as libc::c_int) as + libc::c_uint } else { - len = ((*ptr.offset(4 as libc::c_int as isize) as libc::c_int) << 24 as libc::c_int - | (*ptr.offset(5 as libc::c_int as isize) as libc::c_int) << 16 as libc::c_int - | (*ptr.offset(6 as libc::c_int as isize) as libc::c_int) << 8 as libc::c_int - | *ptr.offset(7 as libc::c_int as isize) as libc::c_int) - as libc::c_uint + len = + ((*ptr.offset(4 as libc::c_int as isize) as libc::c_int) + << 24 as libc::c_int | + (*ptr.offset(5 as libc::c_int as isize) as + libc::c_int) << 16 as libc::c_int | + (*ptr.offset(6 as libc::c_int as isize) as + libc::c_int) << 8 as libc::c_int | + *ptr.offset(7 as libc::c_int as isize) 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 header: %s len: %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"_check_header\x00", - )) - .as_ptr(), - 104 as libc::c_int, - id.as_mut_ptr(), - len, - ); + if loglevel as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d header: %s len: %d\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 14], + &[libc::c_char; 14]>(b"_check_header\x00")).as_ptr(), + 104 as libc::c_int, id.as_mut_ptr(), len); } if format as libc::c_uint == WAVE as libc::c_int as libc::c_uint - && crate::stdlib::memcmp( - ptr as *const libc::c_void, - b"data\x00" as *const u8 as *const libc::c_char as *const libc::c_void, - 4 as libc::c_int as libc::c_ulong, - ) == 0 - { + && + memcmp(ptr as *const libc::c_void, + b"data\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(8 as libc::c_int as isize); - crate::src::buffer::_buf_inc_readp( - streambuf, - ptr.wrapping_offset_from((*streambuf).readp) as libc::c_long as libc::c_uint, - ); + _buf_inc_readp(streambuf, + ptr.wrapping_offset_from((*streambuf).readp) as + libc::c_long as libc::c_uint); audio_left = len; - if audio_left == 0xffffffff as libc::c_uint - || audio_left == 0x7fffeffc 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 wav audio size unknown: %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"_check_header\x00", - )) - .as_ptr(), - 112 as libc::c_int, - audio_left, - ); + if audio_left == 0xffffffff as libc::c_uint || + audio_left == 0x7fffeffc as libc::c_int as libc::c_uint + { + if loglevel as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d wav audio size unknown: %u\n\x00" + as *const u8 as *const libc::c_char, + logtime(), + (*::std::mem::transmute::<&[u8; 14], + &[libc::c_char; 14]>(b"_check_header\x00")).as_ptr(), + 112 as libc::c_int, audio_left); } limit = 0 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 wav audio size: %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"_check_header\x00", - )) - .as_ptr(), - 115 as libc::c_int, - audio_left, - ); + if loglevel as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d wav audio size: %u\n\x00" as + *const u8 as *const libc::c_char, + logtime(), + (*::std::mem::transmute::<&[u8; 14], + &[libc::c_char; 14]>(b"_check_header\x00")).as_ptr(), + 115 as libc::c_int, audio_left); } limit = 1 as libc::c_int != 0 } - return; + return } if format as libc::c_uint == AIFF as libc::c_int as libc::c_uint - && crate::stdlib::memcmp( - ptr as *const libc::c_void, - b"SSND\x00" as *const u8 as *const libc::c_char as *const libc::c_void, - 4 as libc::c_int as libc::c_ulong, - ) == 0 - && bytes >= 16 as libc::c_int as libc::c_uint - { - let mut offset = ((*ptr.offset(8 as libc::c_int as isize) as libc::c_int) - << 24 as libc::c_int - | (*ptr.offset(9 as libc::c_int as isize) as libc::c_int) << 16 as libc::c_int - | (*ptr.offset(10 as libc::c_int as isize) as libc::c_int) << 8 as libc::c_int - | *ptr.offset(11 as libc::c_int as isize) as libc::c_int) - as libc::c_uint; + && + memcmp(ptr as *const libc::c_void, + b"SSND\x00" as *const u8 as *const libc::c_char as + *const libc::c_void, + 4 as libc::c_int as libc::c_ulong) == 0 && + bytes >= 16 as libc::c_int as libc::c_uint { + let mut offset: libc::c_uint = + ((*ptr.offset(8 as libc::c_int as isize) as libc::c_int) + << 24 as libc::c_int | + (*ptr.offset(9 as libc::c_int as isize) as + libc::c_int) << 16 as libc::c_int | + (*ptr.offset(10 as libc::c_int as isize) as + libc::c_int) << 8 as libc::c_int | + *ptr.offset(11 as libc::c_int as isize) as + libc::c_int) as libc::c_uint; // following 4 bytes is blocksize - ignored - ptr = ptr.offset((8 as libc::c_int + 8 as libc::c_int) as isize); - crate::src::buffer::_buf_inc_readp( - streambuf, - ptr.offset(offset as isize) - .wrapping_offset_from((*streambuf).readp) - as libc::c_long as libc::c_uint, - ); + ptr = + ptr.offset((8 as libc::c_int + 8 as libc::c_int) as + isize); + _buf_inc_readp(streambuf, + ptr.offset(offset as + isize).wrapping_offset_from((*streambuf).readp) + as libc::c_long as libc::c_uint); // Reading from an upsampled stream, length could be wrong. - // Only use length in header for files. - if stream.state as libc::c_uint - == crate::squeezelite_h::STREAMING_FILE as libc::c_int as libc::c_uint - { - audio_left = len - .wrapping_sub(8 as libc::c_int as libc::c_uint) - .wrapping_sub(offset); - 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 aif audio size: %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"_check_header\x00", - )) - .as_ptr(), - 131 as libc::c_int, - audio_left, - ); + // Only use length in header for files. + if stream.state as libc::c_uint == + STREAMING_FILE as libc::c_int as libc::c_uint { + audio_left = + len.wrapping_sub(8 as libc::c_int as + libc::c_uint).wrapping_sub(offset); + if loglevel as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d aif audio size: %u\n\x00" as + *const u8 as *const libc::c_char, + logtime(), + (*::std::mem::transmute::<&[u8; 14], + &[libc::c_char; 14]>(b"_check_header\x00")).as_ptr(), + 131 as libc::c_int, audio_left); } limit = 1 as libc::c_int != 0 } - return; + return } if format as libc::c_uint == WAVE as libc::c_int as libc::c_uint - && crate::stdlib::memcmp( - ptr as *const libc::c_void, - b"fmt \x00" as *const u8 as *const libc::c_char as *const libc::c_void, - 4 as libc::c_int as libc::c_ulong, - ) == 0 - && bytes >= 24 as libc::c_int as libc::c_uint - { + && + memcmp(ptr as *const libc::c_void, + b"fmt \x00" as *const u8 as *const libc::c_char as + *const libc::c_void, + 4 as libc::c_int as libc::c_ulong) == 0 && + bytes >= 24 as libc::c_int as libc::c_uint { // override the server parsed values with our own - channels = (*ptr.offset(10 as libc::c_int as isize) as libc::c_int - | (*ptr.offset(11 as libc::c_int as isize) as libc::c_int) << 8 as libc::c_int) - as crate::squeezelite_h::u32_t; - sample_rate = (*ptr.offset(12 as libc::c_int as isize) as libc::c_int - | (*ptr.offset(13 as libc::c_int as isize) as libc::c_int) << 8 as libc::c_int - | (*ptr.offset(14 as libc::c_int as isize) as libc::c_int) << 16 as libc::c_int - | (*ptr.offset(15 as libc::c_int as isize) as libc::c_int) << 24 as libc::c_int) - as crate::squeezelite_h::u32_t; - sample_size = ((*ptr.offset(22 as libc::c_int as isize) as libc::c_int - | (*ptr.offset(23 as libc::c_int as isize) as libc::c_int) << 8 as libc::c_int) - / 8 as libc::c_int) - as crate::squeezelite_h::u32_t; + channels = + (*ptr.offset(10 as libc::c_int as isize) as libc::c_int | + (*ptr.offset(11 as libc::c_int as isize) as + libc::c_int) << 8 as libc::c_int) as u32_t; + sample_rate = + (*ptr.offset(12 as libc::c_int as isize) as libc::c_int | + (*ptr.offset(13 as libc::c_int as isize) as + libc::c_int) << 8 as libc::c_int | + (*ptr.offset(14 as libc::c_int as isize) as + libc::c_int) << 16 as libc::c_int | + (*ptr.offset(15 as libc::c_int as isize) as + libc::c_int) << 24 as libc::c_int) as u32_t; + sample_size = + ((*ptr.offset(22 as libc::c_int as isize) as libc::c_int | + (*ptr.offset(23 as libc::c_int as isize) as + libc::c_int) << 8 as libc::c_int) / + 8 as libc::c_int) as u32_t; bigendian = 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 pcm size: %u rate: %u chan: %u bigendian: %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"_check_header\x00", - )) - .as_ptr(), - 143 as libc::c_int, - sample_size, - sample_rate, - channels, - bigendian as libc::c_int, - ); + if loglevel as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d pcm size: %u rate: %u chan: %u bigendian: %u\n\x00" + as *const u8 as *const libc::c_char, + logtime(), + (*::std::mem::transmute::<&[u8; 14], + &[libc::c_char; 14]>(b"_check_header\x00")).as_ptr(), + 143 as libc::c_int, sample_size, sample_rate, + channels, bigendian as libc::c_int); } } if format as libc::c_uint == AIFF as libc::c_int as libc::c_uint - && crate::stdlib::memcmp( - ptr as *const libc::c_void, - b"COMM\x00" as *const u8 as *const libc::c_char as *const libc::c_void, - 4 as libc::c_int as libc::c_ulong, - ) == 0 - && bytes >= 26 as libc::c_int as libc::c_uint - { + && + memcmp(ptr as *const libc::c_void, + b"COMM\x00" as *const u8 as *const libc::c_char as + *const libc::c_void, + 4 as libc::c_int as libc::c_ulong) == 0 && + bytes >= 26 as libc::c_int as libc::c_uint { let mut exponent: libc::c_int = 0; // override the server parsed values with our own - channels = ((*ptr.offset(8 as libc::c_int as isize) as libc::c_int) - << 8 as libc::c_int - | *ptr.offset(9 as libc::c_int as isize) as libc::c_int) - as crate::squeezelite_h::u32_t; + channels = + ((*ptr.offset(8 as libc::c_int as isize) as libc::c_int) + << 8 as libc::c_int | + *ptr.offset(9 as libc::c_int as isize) as + libc::c_int) as u32_t; sample_size = - (((*ptr.offset(14 as libc::c_int as isize) as libc::c_int) << 8 as libc::c_int - | *ptr.offset(15 as libc::c_int as isize) as libc::c_int) - / 8 as libc::c_int) as crate::squeezelite_h::u32_t; + (((*ptr.offset(14 as libc::c_int as isize) as libc::c_int) + << 8 as libc::c_int | + *ptr.offset(15 as libc::c_int as isize) as + libc::c_int) / 8 as libc::c_int) as u32_t; bigendian = 1 as libc::c_int != 0; // sample rate is encoded as IEEE 80 bit extended format - // make some assumptions to simplify processing - only use first 32 bits of mantissa - exponent = ((*ptr.offset(16 as libc::c_int as isize) as libc::c_int - & 0x7f as libc::c_int) - << 8 as libc::c_int - | *ptr.offset(17 as libc::c_int as isize) as libc::c_int) - - 16383 as libc::c_int - - 31 as libc::c_int; - sample_rate = ((*ptr.offset(18 as libc::c_int as isize) as libc::c_int) - << 24 as libc::c_int - | (*ptr.offset(19 as libc::c_int as isize) as libc::c_int) << 16 as libc::c_int - | (*ptr.offset(20 as libc::c_int as isize) as libc::c_int) << 8 as libc::c_int - | *ptr.offset(21 as libc::c_int as isize) as libc::c_int) - as crate::squeezelite_h::u32_t; + // make some assumptions to simplify processing - only use first 32 bits of mantissa + exponent = + ((*ptr.offset(16 as libc::c_int as isize) as libc::c_int & + 0x7f as libc::c_int) << 8 as libc::c_int | + *ptr.offset(17 as libc::c_int as isize) as + libc::c_int) - 16383 as libc::c_int - + 31 as libc::c_int; + sample_rate = + ((*ptr.offset(18 as libc::c_int as isize) as libc::c_int) + << 24 as libc::c_int | + (*ptr.offset(19 as libc::c_int as isize) as + libc::c_int) << 16 as libc::c_int | + (*ptr.offset(20 as libc::c_int as isize) as + libc::c_int) << 8 as libc::c_int | + *ptr.offset(21 as libc::c_int as isize) as + libc::c_int) as u32_t; while exponent < 0 as libc::c_int { sample_rate >>= 1 as libc::c_int; exponent += 1 @@ -467,325 +535,276 @@ unsafe extern "C" fn _check_header() { sample_rate <<= 1 as libc::c_int; exponent -= 1 } - 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 pcm size: %u rate: %u chan: %u bigendian: %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"_check_header\x00", - )) - .as_ptr(), - 158 as libc::c_int, - sample_size, - sample_rate, - channels, - bigendian as libc::c_int, - ); + if loglevel as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d pcm size: %u rate: %u chan: %u bigendian: %u\n\x00" + as *const u8 as *const libc::c_char, + logtime(), + (*::std::mem::transmute::<&[u8; 14], + &[libc::c_char; 14]>(b"_check_header\x00")).as_ptr(), + 158 as libc::c_int, sample_size, sample_rate, + channels, bigendian as libc::c_int); } } if bytes >= len.wrapping_add(8 as libc::c_int as libc::c_uint) { - ptr = ptr.offset(len.wrapping_add(8 as libc::c_int as libc::c_uint) as isize); - bytes = bytes.wrapping_sub(len.wrapping_add(8 as libc::c_int as libc::c_uint)) + ptr = + ptr.offset(len.wrapping_add(8 as libc::c_int as + libc::c_uint) as isize); + bytes = + bytes.wrapping_sub(len.wrapping_add(8 as libc::c_int as + libc::c_uint)) } 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 run out of data\n\x00" as *const u8 as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 14], &[libc::c_char; 14]>( - b"_check_header\x00", - )) - .as_ptr(), - 165 as libc::c_int, - ); + if loglevel as libc::c_uint >= + lWARN as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d run out of data\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 14], + &[libc::c_char; 14]>(b"_check_header\x00")).as_ptr(), + 165 as libc::c_int); } - return; + return } } - } 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 unknown format - can\'t parse header\n\x00" as *const u8 - as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 14], &[libc::c_char; 14]>(b"_check_header\x00")) - .as_ptr(), - 171 as libc::c_int, - ); + } else if loglevel as libc::c_uint >= lWARN as libc::c_int as libc::c_uint + { + logprint(b"%s %s:%d unknown format - can\'t parse header\n\x00" as + *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 14], + &[libc::c_char; 14]>(b"_check_header\x00")).as_ptr(), + 171 as libc::c_int); }; } - -unsafe extern "C" fn pcm_decode() -> crate::squeezelite_h::decode_state { +unsafe extern "C" fn pcm_decode() -> decode_state { let mut bytes: libc::c_uint = 0; let mut in_0: libc::c_uint = 0; let mut out: libc::c_uint = 0; - let mut frames: crate::squeezelite_h::frames_t = 0; - let mut count: crate::squeezelite_h::frames_t = 0; - let mut optr = 0 as *mut crate::squeezelite_h::u32_t; - let mut iptr = 0 as *mut crate::squeezelite_h::u8_t; - let mut tmp: [crate::squeezelite_h::u8_t; 16] = [0; 16]; - crate::stdlib::pthread_mutex_lock(&mut (*streambuf).mutex); - if decode.new_stream as libc::c_int != 0 - && (stream.state as libc::c_uint - == crate::squeezelite_h::STREAMING_FILE as libc::c_int as libc::c_uint - || pcm_check_header as libc::c_int != 0) - { + let mut frames: frames_t = 0; + let mut count: frames_t = 0; + let mut optr: *mut u32_t = 0 as *mut u32_t; + let mut iptr: *mut u8_t = 0 as *mut u8_t; + let mut tmp: [u8_t; 16] = [0; 16]; + pthread_mutex_lock(&mut (*streambuf).mutex); + if decode.new_stream as libc::c_int != 0 && + (stream.state as libc::c_uint == + STREAMING_FILE as libc::c_int as libc::c_uint || + pcm_check_header as libc::c_int != 0) { _check_header(); } - 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) - }; - out = (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); - if 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_uint - || limit as libc::c_int != 0 && audio_left == 0 as libc::c_int as libc::c_uint - { - crate::stdlib::pthread_mutex_unlock(&mut (*outputbuf).mutex); - crate::stdlib::pthread_mutex_unlock(&mut (*streambuf).mutex); - return crate::squeezelite_h::DECODE_COMPLETE; + pthread_mutex_lock(&mut (*outputbuf).mutex); + bytes = + if _buf_used(streambuf) < _buf_cont_read(streambuf) { + _buf_used(streambuf) + } else { _buf_cont_read(streambuf) }; + out = + (if _buf_space(outputbuf) < _buf_cont_write(outputbuf) { + _buf_space(outputbuf) + } else { + _buf_cont_write(outputbuf) + }).wrapping_div(8 as libc::c_int as libc::c_uint); + if stream.state as libc::c_uint <= + DISCONNECT as libc::c_int as libc::c_uint && + bytes == 0 as libc::c_int as libc::c_uint || + limit as libc::c_int != 0 && + audio_left == 0 as libc::c_int as libc::c_uint { + pthread_mutex_unlock(&mut (*outputbuf).mutex); + pthread_mutex_unlock(&mut (*streambuf).mutex); + return DECODE_COMPLETE } if decode.new_stream { - 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"pcm_decode\x00")) - .as_ptr(), - 206 as libc::c_int, - ); + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d setting track_start\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 11], + &[libc::c_char; 11]>(b"pcm_decode\x00")).as_ptr(), + 206 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(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); - } + decode_newstream(sample_rate, + output.supported_rates.as_mut_ptr()); + if output.fade_mode as u64 != 0 { _checkfade(1 as libc::c_int != 0); } bytes_per_frame = channels.wrapping_mul(sample_size) } - optr = (*outputbuf).writep as *mut crate::squeezelite_h::u32_t; + optr = (*outputbuf).writep as *mut u32_t; iptr = (*streambuf).readp; in_0 = bytes.wrapping_div(bytes_per_frame); // handle frame wrapping round end of streambuf - // - only need if resizing of streambuf does not avoid this, could occur in localfile case - if in_0 == 0 as libc::c_int as libc::c_uint - && bytes > 0 as libc::c_int as libc::c_uint - && crate::squeezelite_h::_buf_used(streambuf) >= bytes_per_frame - { - crate::stdlib::memcpy( - tmp.as_mut_ptr() as *mut libc::c_void, - iptr as *const libc::c_void, - bytes as libc::c_ulong, - ); - crate::stdlib::memcpy( - tmp.as_mut_ptr().offset(bytes as isize) as *mut libc::c_void, - (*streambuf).buf as *const libc::c_void, - bytes_per_frame.wrapping_sub(bytes) as libc::c_ulong, - ); + // - only need if resizing of streambuf does not avoid this, could occur in localfile case + if in_0 == 0 as libc::c_int as libc::c_uint && + bytes > 0 as libc::c_int as libc::c_uint && + _buf_used(streambuf) >= bytes_per_frame { + memcpy(tmp.as_mut_ptr() as *mut libc::c_void, + iptr as *const libc::c_void, bytes as libc::c_ulong); + memcpy(tmp.as_mut_ptr().offset(bytes as isize) as *mut libc::c_void, + (*streambuf).buf as *const libc::c_void, + bytes_per_frame.wrapping_sub(bytes) as libc::c_ulong); iptr = tmp.as_mut_ptr(); in_0 = 1 as libc::c_int as libc::c_uint } frames = if in_0 < out { in_0 } else { out }; - frames = if frames < 4096 as libc::c_int as libc::c_uint { - frames - } else { - 4096 as libc::c_int as libc::c_uint - }; - if limit as libc::c_int != 0 && frames.wrapping_mul(bytes_per_frame) > audio_left { - 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 reached end of audio\n\x00" as *const u8 as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 11], &[libc::c_char; 11]>(b"pcm_decode\x00")) - .as_ptr(), - 261 as libc::c_int, - ); + frames = + if frames < 4096 as libc::c_int as libc::c_uint { + frames + } else { 4096 as libc::c_int as libc::c_uint }; + if limit as libc::c_int != 0 && + frames.wrapping_mul(bytes_per_frame) > audio_left { + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d reached end of audio\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 11], + &[libc::c_char; 11]>(b"pcm_decode\x00")).as_ptr(), + 261 as libc::c_int); } frames = audio_left.wrapping_div(bytes_per_frame) } count = frames.wrapping_mul(channels); if channels == 2 as libc::c_int as libc::c_uint { if sample_size == 1 as libc::c_int as libc::c_uint { - loop { + loop { let fresh0 = count; count = count.wrapping_sub(1); - if !(fresh0 != 0) { - break; - } + if !(fresh0 != 0) { break ; } let fresh1 = iptr; iptr = iptr.offset(1); let fresh2 = optr; optr = optr.offset(1); *fresh2 = - ((*fresh1 as libc::c_int) << 24 as libc::c_int) as crate::squeezelite_h::u32_t + ((*fresh1 as libc::c_int) << 24 as libc::c_int) as u32_t } } else if sample_size == 2 as libc::c_int as libc::c_uint { if bigendian { - loop { + loop { let fresh3 = count; count = count.wrapping_sub(1); - if !(fresh3 != 0) { - break; - } + if !(fresh3 != 0) { break ; } let fresh4 = optr; optr = optr.offset(1); - *fresh4 = ((*iptr as libc::c_int) << 24 as libc::c_int - | (*iptr.offset(1 as libc::c_int as isize) as libc::c_int) - << 16 as libc::c_int) - as crate::squeezelite_h::u32_t; + *fresh4 = + ((*iptr as libc::c_int) << 24 as libc::c_int | + (*iptr.offset(1 as libc::c_int as isize) as + libc::c_int) << 16 as libc::c_int) as u32_t; iptr = iptr.offset(2 as libc::c_int as isize) } } else { - loop { + loop { let fresh5 = count; count = count.wrapping_sub(1); - if !(fresh5 != 0) { - break; - } + if !(fresh5 != 0) { break ; } let fresh6 = optr; optr = optr.offset(1); - *fresh6 = ((*iptr as libc::c_int) << 16 as libc::c_int - | (*iptr.offset(1 as libc::c_int as isize) as libc::c_int) - << 24 as libc::c_int) - as crate::squeezelite_h::u32_t; + *fresh6 = + ((*iptr as libc::c_int) << 16 as libc::c_int | + (*iptr.offset(1 as libc::c_int as isize) as + libc::c_int) << 24 as libc::c_int) as u32_t; iptr = iptr.offset(2 as libc::c_int as isize) } } } else if sample_size == 3 as libc::c_int as libc::c_uint { if bigendian { - loop { + loop { let fresh7 = count; count = count.wrapping_sub(1); - if !(fresh7 != 0) { - break; - } + if !(fresh7 != 0) { break ; } let fresh8 = optr; optr = optr.offset(1); - *fresh8 = ((*iptr as libc::c_int) << 24 as libc::c_int - | (*iptr.offset(1 as libc::c_int as isize) as libc::c_int) - << 16 as libc::c_int - | (*iptr.offset(2 as libc::c_int as isize) as libc::c_int) - << 8 as libc::c_int) - as crate::squeezelite_h::u32_t; + *fresh8 = + ((*iptr as libc::c_int) << 24 as libc::c_int | + (*iptr.offset(1 as libc::c_int as isize) as + libc::c_int) << 16 as libc::c_int | + (*iptr.offset(2 as libc::c_int as isize) as + libc::c_int) << 8 as libc::c_int) as u32_t; iptr = iptr.offset(3 as libc::c_int as isize) } } else { - loop { + loop { let fresh9 = count; count = count.wrapping_sub(1); - if !(fresh9 != 0) { - break; - } + if !(fresh9 != 0) { break ; } let fresh10 = optr; optr = optr.offset(1); - *fresh10 = ((*iptr as libc::c_int) << 8 as libc::c_int - | (*iptr.offset(1 as libc::c_int as isize) as libc::c_int) - << 16 as libc::c_int - | (*iptr.offset(2 as libc::c_int as isize) as libc::c_int) - << 24 as libc::c_int) - as crate::squeezelite_h::u32_t; + *fresh10 = + ((*iptr as libc::c_int) << 8 as libc::c_int | + (*iptr.offset(1 as libc::c_int as isize) as + libc::c_int) << 16 as libc::c_int | + (*iptr.offset(2 as libc::c_int as isize) as + libc::c_int) << 24 as libc::c_int) as u32_t; iptr = iptr.offset(3 as libc::c_int as isize) } } } else if sample_size == 4 as libc::c_int as libc::c_uint { if bigendian { - loop { + loop { let fresh11 = count; count = count.wrapping_sub(1); - if !(fresh11 != 0) { - break; - } + if !(fresh11 != 0) { break ; } let fresh12 = optr; optr = optr.offset(1); - *fresh12 = ((*iptr as libc::c_int) << 24 as libc::c_int - | (*iptr.offset(1 as libc::c_int as isize) as libc::c_int) - << 16 as libc::c_int - | (*iptr.offset(2 as libc::c_int as isize) as libc::c_int) - << 8 as libc::c_int - | *iptr.offset(3 as libc::c_int as isize) as libc::c_int) - as crate::squeezelite_h::u32_t; + *fresh12 = + ((*iptr as libc::c_int) << 24 as libc::c_int | + (*iptr.offset(1 as libc::c_int as isize) as + libc::c_int) << 16 as libc::c_int | + (*iptr.offset(2 as libc::c_int as isize) as + libc::c_int) << 8 as libc::c_int | + *iptr.offset(3 as libc::c_int as isize) as + libc::c_int) as u32_t; iptr = iptr.offset(4 as libc::c_int as isize) } } else { - loop { + loop { let fresh13 = count; count = count.wrapping_sub(1); - if !(fresh13 != 0) { - break; - } + if !(fresh13 != 0) { break ; } let fresh14 = optr; optr = optr.offset(1); - *fresh14 = (*iptr as libc::c_int - | (*iptr.offset(1 as libc::c_int as isize) as libc::c_int) - << 8 as libc::c_int - | (*iptr.offset(2 as libc::c_int as isize) as libc::c_int) - << 16 as libc::c_int - | (*iptr.offset(3 as libc::c_int as isize) as libc::c_int) - << 24 as libc::c_int) - as crate::squeezelite_h::u32_t; + *fresh14 = + (*iptr as libc::c_int | + (*iptr.offset(1 as libc::c_int as isize) as + libc::c_int) << 8 as libc::c_int | + (*iptr.offset(2 as libc::c_int as isize) as + libc::c_int) << 16 as libc::c_int | + (*iptr.offset(3 as libc::c_int as isize) as + libc::c_int) << 24 as libc::c_int) as u32_t; iptr = iptr.offset(4 as libc::c_int as isize) } } } } else if channels == 1 as libc::c_int as libc::c_uint { if sample_size == 1 as libc::c_int as libc::c_uint { - loop { + loop { let fresh15 = count; count = count.wrapping_sub(1); - if !(fresh15 != 0) { - break; - } + if !(fresh15 != 0) { break ; } let fresh16 = iptr; iptr = iptr.offset(1); *optr = - ((*fresh16 as libc::c_int) << 24 as libc::c_int) as crate::squeezelite_h::u32_t; + ((*fresh16 as libc::c_int) << 24 as libc::c_int) as u32_t; *optr.offset(1 as libc::c_int as isize) = *optr; optr = optr.offset(2 as libc::c_int as isize) } } else if sample_size == 2 as libc::c_int as libc::c_uint { if bigendian { - loop { + loop { let fresh17 = count; count = count.wrapping_sub(1); - if !(fresh17 != 0) { - break; - } - *optr = ((*iptr as libc::c_int) << 24 as libc::c_int - | (*iptr.offset(1 as libc::c_int as isize) as libc::c_int) - << 16 as libc::c_int) - as crate::squeezelite_h::u32_t; + if !(fresh17 != 0) { break ; } + *optr = + ((*iptr as libc::c_int) << 24 as libc::c_int | + (*iptr.offset(1 as libc::c_int as isize) as + libc::c_int) << 16 as libc::c_int) as u32_t; *optr.offset(1 as libc::c_int as isize) = *optr; iptr = iptr.offset(2 as libc::c_int as isize); optr = optr.offset(2 as libc::c_int as isize) } } else { - loop { + loop { let fresh18 = count; count = count.wrapping_sub(1); - if !(fresh18 != 0) { - break; - } - *optr = ((*iptr as libc::c_int) << 16 as libc::c_int - | (*iptr.offset(1 as libc::c_int as isize) as libc::c_int) - << 24 as libc::c_int) - as crate::squeezelite_h::u32_t; + if !(fresh18 != 0) { break ; } + *optr = + ((*iptr as libc::c_int) << 16 as libc::c_int | + (*iptr.offset(1 as libc::c_int as isize) as + libc::c_int) << 24 as libc::c_int) as u32_t; *optr.offset(1 as libc::c_int as isize) = *optr; iptr = iptr.offset(2 as libc::c_int as isize); optr = optr.offset(2 as libc::c_int as isize) @@ -793,35 +812,31 @@ unsafe extern "C" fn pcm_decode() -> crate::squeezelite_h::decode_state { } } else if sample_size == 3 as libc::c_int as libc::c_uint { if bigendian { - loop { + loop { let fresh19 = count; count = count.wrapping_sub(1); - if !(fresh19 != 0) { - break; - } - *optr = ((*iptr as libc::c_int) << 24 as libc::c_int - | (*iptr.offset(1 as libc::c_int as isize) as libc::c_int) - << 16 as libc::c_int - | (*iptr.offset(2 as libc::c_int as isize) as libc::c_int) - << 8 as libc::c_int) - as crate::squeezelite_h::u32_t; + if !(fresh19 != 0) { break ; } + *optr = + ((*iptr as libc::c_int) << 24 as libc::c_int | + (*iptr.offset(1 as libc::c_int as isize) as + libc::c_int) << 16 as libc::c_int | + (*iptr.offset(2 as libc::c_int as isize) as + libc::c_int) << 8 as libc::c_int) as u32_t; *optr.offset(1 as libc::c_int as isize) = *optr; iptr = iptr.offset(3 as libc::c_int as isize); optr = optr.offset(2 as libc::c_int as isize) } } else { - loop { + loop { let fresh20 = count; count = count.wrapping_sub(1); - if !(fresh20 != 0) { - break; - } - *optr = ((*iptr as libc::c_int) << 8 as libc::c_int - | (*iptr.offset(1 as libc::c_int as isize) as libc::c_int) - << 16 as libc::c_int - | (*iptr.offset(2 as libc::c_int as isize) as libc::c_int) - << 24 as libc::c_int) - as crate::squeezelite_h::u32_t; + if !(fresh20 != 0) { break ; } + *optr = + ((*iptr as libc::c_int) << 8 as libc::c_int | + (*iptr.offset(1 as libc::c_int as isize) as + libc::c_int) << 16 as libc::c_int | + (*iptr.offset(2 as libc::c_int as isize) as + libc::c_int) << 24 as libc::c_int) as u32_t; *optr.offset(1 as libc::c_int as isize) = *optr; iptr = iptr.offset(3 as libc::c_int as isize); optr = optr.offset(2 as libc::c_int as isize) @@ -829,42 +844,39 @@ unsafe extern "C" fn pcm_decode() -> crate::squeezelite_h::decode_state { } } else if sample_size == 4 as libc::c_int as libc::c_uint { if bigendian { - loop { + loop { let fresh21 = count; count = count.wrapping_sub(1); - if !(fresh21 != 0) { - break; - } + if !(fresh21 != 0) { break ; } let fresh22 = optr; optr = optr.offset(1); - *fresh22 = ((*iptr as libc::c_int) << 24 as libc::c_int - | (*iptr.offset(1 as libc::c_int as isize) as libc::c_int) - << 16 as libc::c_int - | (*iptr.offset(2 as libc::c_int as isize) as libc::c_int) - << 8 as libc::c_int - | *iptr.offset(3 as libc::c_int as isize) as libc::c_int) - as crate::squeezelite_h::u32_t; + *fresh22 = + ((*iptr as libc::c_int) << 24 as libc::c_int | + (*iptr.offset(1 as libc::c_int as isize) as + libc::c_int) << 16 as libc::c_int | + (*iptr.offset(2 as libc::c_int as isize) as + libc::c_int) << 8 as libc::c_int | + *iptr.offset(3 as libc::c_int as isize) as + libc::c_int) as u32_t; *optr.offset(1 as libc::c_int as isize) = *optr; iptr = iptr.offset(4 as libc::c_int as isize); optr = optr.offset(2 as libc::c_int as isize) } } else { - loop { + loop { let fresh23 = count; count = count.wrapping_sub(1); - if !(fresh23 != 0) { - break; - } + if !(fresh23 != 0) { break ; } let fresh24 = optr; optr = optr.offset(1); - *fresh24 = (*iptr as libc::c_int - | (*iptr.offset(1 as libc::c_int as isize) as libc::c_int) - << 8 as libc::c_int - | (*iptr.offset(2 as libc::c_int as isize) as libc::c_int) - << 16 as libc::c_int - | (*iptr.offset(3 as libc::c_int as isize) as libc::c_int) - << 24 as libc::c_int) - as crate::squeezelite_h::u32_t; + *fresh24 = + (*iptr as libc::c_int | + (*iptr.offset(1 as libc::c_int as isize) as + libc::c_int) << 8 as libc::c_int | + (*iptr.offset(2 as libc::c_int as isize) as + libc::c_int) << 16 as libc::c_int | + (*iptr.offset(3 as libc::c_int as isize) as + libc::c_int) << 24 as libc::c_int) as u32_t; *optr.offset(1 as libc::c_int as isize) = *optr; iptr = iptr.offset(4 as libc::c_int as isize); optr = optr.offset(2 as libc::c_int as isize) @@ -872,144 +884,192 @@ unsafe extern "C" fn pcm_decode() -> crate::squeezelite_h::decode_state { } } } else { - crate::src::utils::logprint( - b"%s %s:%d unsupported channels\n\x00" as *const u8 as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 11], &[libc::c_char; 11]>(b"pcm_decode\x00")).as_ptr(), - 366 as libc::c_int, - ); + logprint(b"%s %s:%d unsupported channels\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 11], + &[libc::c_char; 11]>(b"pcm_decode\x00")).as_ptr(), + 366 as libc::c_int); } - 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 decoded %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"pcm_decode\x00")).as_ptr(), - 369 as libc::c_int, - frames, - ); + if loglevel as libc::c_uint >= lSDEBUG as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d decoded %u frames\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 11], + &[libc::c_char; 11]>(b"pcm_decode\x00")).as_ptr(), + 369 as libc::c_int, frames); } - crate::src::buffer::_buf_inc_readp(streambuf, frames.wrapping_mul(bytes_per_frame)); + _buf_inc_readp(streambuf, frames.wrapping_mul(bytes_per_frame)); if limit { - audio_left = (audio_left as libc::c_uint).wrapping_sub(frames.wrapping_mul(bytes_per_frame)) - as crate::squeezelite_h::u32_t as crate::squeezelite_h::u32_t + audio_left = + (audio_left as + libc::c_uint).wrapping_sub(frames.wrapping_mul(bytes_per_frame)) + as u32_t as u32_t } - crate::src::buffer::_buf_inc_writep( - outputbuf, - frames.wrapping_mul(8 as libc::c_int as libc::c_uint), - ); - crate::stdlib::pthread_mutex_unlock(&mut (*outputbuf).mutex); - crate::stdlib::pthread_mutex_unlock(&mut (*streambuf).mutex); - return crate::squeezelite_h::DECODE_RUNNING; + _buf_inc_writep(outputbuf, + frames.wrapping_mul(8 as libc::c_int as libc::c_uint)); + pthread_mutex_unlock(&mut (*outputbuf).mutex); + pthread_mutex_unlock(&mut (*streambuf).mutex); + return DECODE_RUNNING; } - -unsafe extern "C" fn pcm_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, -) { +unsafe extern "C" fn pcm_open(mut size: u8_t, mut rate: u8_t, mut chan: u8_t, + mut endianness: u8_t) { sample_size = - (size as libc::c_int - '0' as i32 + 1 as libc::c_int) as crate::squeezelite_h::u32_t; + (size as libc::c_int - '0' as i32 + 1 as libc::c_int) as u32_t; sample_rate = sample_rates[(rate as libc::c_int - '0' as i32) as usize]; - channels = (chan as libc::c_int - '0' as i32) as crate::squeezelite_h::u32_t; + channels = (chan as libc::c_int - '0' as i32) as u32_t; bigendian = endianness as libc::c_int == '0' as i32; limit = 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 pcm size: %u rate: %u chan: %u bigendian: %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"pcm_open\x00")).as_ptr(), - 397 as libc::c_int, - sample_size, - sample_rate, - channels, - bigendian as libc::c_int, - ); + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d pcm size: %u rate: %u chan: %u bigendian: %u\n\x00" + as *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 9], + &[libc::c_char; 9]>(b"pcm_open\x00")).as_ptr(), + 397 as libc::c_int, sample_size, sample_rate, channels, + bigendian as libc::c_int); } - crate::src::buffer::buf_adjust( - streambuf, - sample_size.wrapping_mul(channels) as crate::stddef_h::size_t, - ); + buf_adjust(streambuf, sample_size.wrapping_mul(channels) as size_t); } - unsafe extern "C" fn pcm_close() { - crate::src::buffer::buf_adjust(streambuf, 1 as libc::c_int as crate::stddef_h::size_t); + buf_adjust(streambuf, 1 as libc::c_int as size_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 . + * + * 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_pcm() -> *mut crate::squeezelite_h::codec { +pub unsafe extern "C" fn register_pcm() -> *mut codec { if pcm_check_header { - static mut ret: crate::squeezelite_h::codec = unsafe { - { - let mut init = crate::squeezelite_h::codec { - id: 'p' as i32 as libc::c_char, - types: b"wav,aif,pcm\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: 102400 as libc::c_int as libc::c_uint, - open: Some( - pcm_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(pcm_close as unsafe extern "C" fn() -> ()), - decode: Some( - pcm_decode as unsafe extern "C" fn() -> crate::squeezelite_h::decode_state, - ), - }; - init - } - }; - 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 pcm to decode wav,aif,pcm\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_pcm\x00")) - .as_ptr(), - 418 as libc::c_int, - ); + static mut ret: codec = + unsafe { + { + let mut init = + codec{id: 'p' as i32 as libc::c_char, + types: + b"wav,aif,pcm\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: + 102400 as libc::c_int as libc::c_uint, + open: + Some(pcm_open as + unsafe extern "C" fn(_: u8_t, + _: u8_t, + _: u8_t, + _: u8_t) + -> ()), + close: + Some(pcm_close as + unsafe extern "C" fn() -> ()), + decode: + Some(pcm_decode as + unsafe extern "C" fn() + -> decode_state),}; + init + } + }; + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d using pcm to decode wav,aif,pcm\n\x00" as + *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 13], + &[libc::c_char; 13]>(b"register_pcm\x00")).as_ptr(), + 418 as libc::c_int); } - return &mut ret; + return &mut ret } else { - static mut ret_0: crate::squeezelite_h::codec = unsafe { - { - let mut init = crate::squeezelite_h::codec { - id: 'p' as i32 as libc::c_char, - types: b"aif,pcm\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: 102400 as libc::c_int as libc::c_uint, - open: Some( - pcm_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(pcm_close as unsafe extern "C" fn() -> ()), - decode: Some( - pcm_decode as unsafe extern "C" fn() -> crate::squeezelite_h::decode_state, - ), - }; - init - } - }; - 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 pcm to decode aif,pcm\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_pcm\x00")) - .as_ptr(), - 433 as libc::c_int, - ); + static mut ret_0: codec = + unsafe { + { + let mut init = + codec{id: 'p' as i32 as libc::c_char, + types: + b"aif,pcm\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: + 102400 as libc::c_int as libc::c_uint, + open: + Some(pcm_open as + unsafe extern "C" fn(_: u8_t, + _: u8_t, + _: u8_t, + _: u8_t) + -> ()), + close: + Some(pcm_close as + unsafe extern "C" fn() -> ()), + decode: + Some(pcm_decode as + unsafe extern "C" fn() + -> decode_state),}; + init + } + }; + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d using pcm to decode aif,pcm\n\x00" as + *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 13], + &[libc::c_char; 13]>(b"register_pcm\x00")).as_ptr(), + 433 as libc::c_int); } - return &mut ret_0; + return &mut ret_0 }; } diff --git a/src/slimproto.rs b/src/slimproto.rs index 5f145a8..7683db5 100644 --- a/src/slimproto.rs +++ b/src/slimproto.rs @@ -1,167 +1,625 @@ -// =============== BEGIN slimproto_h ================ - -// char header[] - added in sendRESP - -// S:N:Slimproto _http_metadata_handler -#[repr(C, packed)] +use ::libc; +extern "C" { + pub type _IO_wide_data; + pub type _IO_codecvt; + pub type _IO_marker; + #[no_mangle] + fn close(__fd: libc::c_int) -> libc::c_int; + #[no_mangle] + fn sleep(__seconds: libc::c_uint) -> libc::c_uint; + #[no_mangle] + fn usleep(__useconds: __useconds_t) -> libc::c_int; + #[no_mangle] + fn fopen(_: *const libc::c_char, _: *const libc::c_char) -> *mut FILE; + #[no_mangle] + fn snprintf(_: *mut libc::c_char, _: libc::c_ulong, + _: *const libc::c_char, _: ...) -> libc::c_int; + #[no_mangle] + fn fgets(__s: *mut libc::c_char, __n: libc::c_int, __stream: *mut FILE) + -> *mut libc::c_char; + #[no_mangle] + fn fputs(__s: *const libc::c_char, __stream: *mut FILE) -> libc::c_int; + #[no_mangle] + fn malloc(_: libc::c_ulong) -> *mut libc::c_void; + #[no_mangle] + fn free(__ptr: *mut libc::c_void); + #[no_mangle] + fn memcpy(_: *mut libc::c_void, _: *const libc::c_void, _: libc::c_ulong) + -> *mut libc::c_void; + #[no_mangle] + fn memset(_: *mut libc::c_void, _: libc::c_int, _: libc::c_ulong) + -> *mut libc::c_void; + #[no_mangle] + fn strncpy(_: *mut libc::c_char, _: *const libc::c_char, _: libc::c_ulong) + -> *mut libc::c_char; + #[no_mangle] + fn strcat(_: *mut libc::c_char, _: *const libc::c_char) + -> *mut libc::c_char; + #[no_mangle] + fn strncat(_: *mut libc::c_char, _: *const libc::c_char, _: libc::c_ulong) + -> *mut libc::c_char; + #[no_mangle] + fn strncmp(_: *const libc::c_char, _: *const libc::c_char, + _: libc::c_ulong) -> libc::c_int; + #[no_mangle] + fn __errno_location() -> *mut libc::c_int; + #[no_mangle] + fn fclose(__stream: *mut FILE) -> libc::c_int; + #[no_mangle] + fn socket(__domain: libc::c_int, __type: libc::c_int, + __protocol: libc::c_int) -> libc::c_int; + #[no_mangle] + fn getsockname(__fd: libc::c_int, __addr: *mut sockaddr, + __len: *mut socklen_t) -> libc::c_int; + #[no_mangle] + fn send(__fd: libc::c_int, __buf: *const libc::c_void, __n: size_t, + __flags: libc::c_int) -> ssize_t; + #[no_mangle] + fn recv(__fd: libc::c_int, __buf: *mut libc::c_void, __n: size_t, + __flags: libc::c_int) -> ssize_t; + #[no_mangle] + fn sendto(__fd: libc::c_int, __buf: *const libc::c_void, __n: size_t, + __flags: libc::c_int, __addr: *const sockaddr, + __addr_len: socklen_t) -> ssize_t; + #[no_mangle] + fn recvfrom(__fd: libc::c_int, __buf: *mut libc::c_void, __n: size_t, + __flags: libc::c_int, __addr: *mut sockaddr, + __addr_len: *mut socklen_t) -> ssize_t; + #[no_mangle] + fn setsockopt(__fd: libc::c_int, __level: libc::c_int, + __optname: libc::c_int, __optval: *const libc::c_void, + __optlen: socklen_t) -> libc::c_int; + #[no_mangle] + fn ntohs(__netshort: uint16_t) -> uint16_t; + #[no_mangle] + fn htonl(__hostlong: uint32_t) -> uint32_t; + #[no_mangle] + fn htons(__hostshort: uint16_t) -> uint16_t; + #[no_mangle] + fn inet_ntoa(__in: in_addr) -> *mut libc::c_char; + #[no_mangle] + fn poll(__fds: *mut pollfd, __nfds: nfds_t, __timeout: libc::c_int) + -> libc::c_int; + #[no_mangle] + fn pthread_mutex_lock(__mutex: *mut pthread_mutex_t) -> libc::c_int; + #[no_mangle] + fn pthread_mutex_unlock(__mutex: *mut pthread_mutex_t) -> libc::c_int; + #[no_mangle] + fn eventfd(__count: libc::c_uint, __flags: libc::c_int) -> libc::c_int; + #[no_mangle] + fn eventfd_write(__fd: libc::c_int, __value: eventfd_t) -> libc::c_int; + #[no_mangle] + fn logtime() -> *const libc::c_char; + #[no_mangle] + fn logprint(fmt: *const libc::c_char, _: ...); + #[no_mangle] + fn gettime_ms() -> u32_t; + #[no_mangle] + fn set_nonblock(s: sockfd); + #[no_mangle] + fn connect_timeout(sock_0: sockfd, addr: *const sockaddr, + addrlen: socklen_t, timeout: libc::c_int) + -> libc::c_int; + #[no_mangle] + fn server_addr(server: *mut libc::c_char, ip_ptr: *mut in_addr_t, + port_ptr: *mut libc::c_uint); + #[no_mangle] + fn set_readwake_handles(handles: *mut pollfd, s: sockfd, e: libc::c_int); + #[no_mangle] + fn wait_readwake(handles: *mut pollfd, timeout: libc::c_int) + -> event_type; + #[no_mangle] + fn packN(dest: *mut u32_t, val: u32_t); + #[no_mangle] + fn packn(dest: *mut u16_t, val: u16_t); + #[no_mangle] + fn unpackN(src: *mut u32_t) -> u32_t; + #[no_mangle] + fn _buf_used(buf: *mut buffer) -> libc::c_uint; + #[no_mangle] + fn buf_flush(buf: *mut buffer); + #[no_mangle] + fn decode_flush(); + #[no_mangle] + fn output_flush(); + #[no_mangle] + fn stream_file(header: *const libc::c_char, header_len: size_t, + threshold: libc::c_uint); + #[no_mangle] + fn stream_sock(ip: u32_t, port: u16_t, header: *const libc::c_char, + header_len: size_t, threshold: libc::c_uint, + cont_wait: bool); + #[no_mangle] + fn codec_open(format: u8_t, sample_size: u8_t, sample_rate: u8_t, + channels: u8_t, endianness: u8_t); + #[no_mangle] + fn set_volume(left: libc::c_uint, right: libc::c_uint); + #[no_mangle] + fn stream_disconnect() -> bool; + #[no_mangle] + fn strlen(_: *const libc::c_char) -> libc::c_ulong; + #[no_mangle] + fn strerror(_: libc::c_int) -> *mut libc::c_char; + #[no_mangle] + static mut streambuf: *mut buffer; + #[no_mangle] + static mut outputbuf: *mut buffer; + #[no_mangle] + static mut stream: streamstate; + #[no_mangle] + static mut output: outputstate; + #[no_mangle] + static mut decode: decodestate; + #[no_mangle] + static mut codecs: [*mut codec; 0]; +} +pub type size_t = libc::c_ulong; +pub type __uint8_t = libc::c_uchar; +pub type __uint16_t = libc::c_ushort; +pub type __int32_t = libc::c_int; +pub type __uint32_t = libc::c_uint; +pub type __uint64_t = libc::c_ulong; +pub type __off_t = libc::c_long; +pub type __off64_t = libc::c_long; +pub type __useconds_t = libc::c_uint; +pub type __ssize_t = libc::c_long; +pub type __socklen_t = libc::c_uint; #[derive(Copy, Clone)] +#[repr(C)] +pub struct _IO_FILE { + pub _flags: libc::c_int, + pub _IO_read_ptr: *mut libc::c_char, + pub _IO_read_end: *mut libc::c_char, + pub _IO_read_base: *mut libc::c_char, + pub _IO_write_base: *mut libc::c_char, + pub _IO_write_ptr: *mut libc::c_char, + pub _IO_write_end: *mut libc::c_char, + pub _IO_buf_base: *mut libc::c_char, + pub _IO_buf_end: *mut libc::c_char, + pub _IO_save_base: *mut libc::c_char, + pub _IO_backup_base: *mut libc::c_char, + pub _IO_save_end: *mut libc::c_char, + pub _markers: *mut _IO_marker, + pub _chain: *mut _IO_FILE, + pub _fileno: libc::c_int, + pub _flags2: libc::c_int, + pub _old_offset: __off_t, + pub _cur_column: libc::c_ushort, + pub _vtable_offset: libc::c_schar, + pub _shortbuf: [libc::c_char; 1], + pub _lock: *mut libc::c_void, + pub _offset: __off64_t, + pub _codecvt: *mut _IO_codecvt, + pub _wide_data: *mut _IO_wide_data, + pub _freeres_list: *mut _IO_FILE, + pub _freeres_buf: *mut libc::c_void, + pub __pad5: size_t, + pub _mode: libc::c_int, + pub _unused2: [libc::c_char; 20], +} +pub type _IO_lock_t = (); +pub type FILE = _IO_FILE; +pub type ssize_t = __ssize_t; +pub type int32_t = __int32_t; +pub type u_int8_t = __uint8_t; +pub type u_int16_t = __uint16_t; +pub type u_int32_t = __uint32_t; +pub type u_int64_t = __uint64_t; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct __pthread_internal_list { + pub __prev: *mut __pthread_internal_list, + pub __next: *mut __pthread_internal_list, +} +pub type __pthread_list_t = __pthread_internal_list; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct __pthread_mutex_s { + pub __lock: libc::c_int, + pub __count: libc::c_uint, + pub __owner: libc::c_int, + pub __nusers: libc::c_uint, + pub __kind: libc::c_int, + pub __spins: libc::c_short, + pub __elision: libc::c_short, + pub __list: __pthread_list_t, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub union pthread_mutex_t { + pub __data: __pthread_mutex_s, + pub __size: [libc::c_char; 40], + pub __align: libc::c_long, +} +pub type socklen_t = __socklen_t; +pub type uint16_t = __uint16_t; +pub type uint32_t = __uint32_t; +pub type uint64_t = __uint64_t; +pub type __socket_type = libc::c_uint; +pub const SOCK_NONBLOCK: __socket_type = 2048; +pub const SOCK_CLOEXEC: __socket_type = 524288; +pub const SOCK_PACKET: __socket_type = 10; +pub const SOCK_DCCP: __socket_type = 6; +pub const SOCK_SEQPACKET: __socket_type = 5; +pub const SOCK_RDM: __socket_type = 4; +pub const SOCK_RAW: __socket_type = 3; +pub const SOCK_DGRAM: __socket_type = 2; +pub const SOCK_STREAM: __socket_type = 1; +pub type sa_family_t = libc::c_ushort; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct sockaddr { + pub sa_family: sa_family_t, + pub sa_data: [libc::c_char; 14], +} +pub type C2RustUnnamed = libc::c_uint; +pub const MSG_CMSG_CLOEXEC: C2RustUnnamed = 1073741824; +pub const MSG_FASTOPEN: C2RustUnnamed = 536870912; +pub const MSG_ZEROCOPY: C2RustUnnamed = 67108864; +pub const MSG_BATCH: C2RustUnnamed = 262144; +pub const MSG_WAITFORONE: C2RustUnnamed = 65536; +pub const MSG_MORE: C2RustUnnamed = 32768; +pub const MSG_NOSIGNAL: C2RustUnnamed = 16384; +pub const MSG_ERRQUEUE: C2RustUnnamed = 8192; +pub const MSG_RST: C2RustUnnamed = 4096; +pub const MSG_CONFIRM: C2RustUnnamed = 2048; +pub const MSG_SYN: C2RustUnnamed = 1024; +pub const MSG_FIN: C2RustUnnamed = 512; +pub const MSG_WAITALL: C2RustUnnamed = 256; +pub const MSG_EOR: C2RustUnnamed = 128; +pub const MSG_DONTWAIT: C2RustUnnamed = 64; +pub const MSG_TRUNC: C2RustUnnamed = 32; +pub const MSG_PROXY: C2RustUnnamed = 16; +pub const MSG_CTRUNC: C2RustUnnamed = 8; +pub const MSG_DONTROUTE: C2RustUnnamed = 4; +pub const MSG_PEEK: C2RustUnnamed = 2; +pub const MSG_OOB: C2RustUnnamed = 1; +pub type in_addr_t = uint32_t; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct in_addr { + pub s_addr: in_addr_t, +} +pub type in_port_t = uint16_t; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct sockaddr_in { + pub sin_family: sa_family_t, + pub sin_port: in_port_t, + pub sin_addr: in_addr, + pub sin_zero: [libc::c_uchar; 8], +} +pub type nfds_t = libc::c_ulong; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct pollfd { + pub fd: libc::c_int, + pub events: libc::c_short, + pub revents: libc::c_short, +} +pub type u8_t = u_int8_t; +pub type u16_t = u_int16_t; +pub type u32_t = u_int32_t; +pub type u64_t = u_int64_t; +pub type s32_t = int32_t; +pub type frames_t = u32_t; +pub type sockfd = libc::c_int; +pub type eventfd_t = uint64_t; +pub type log_level = libc::c_uint; +pub const lSDEBUG: log_level = 4; +pub const lDEBUG: log_level = 3; +pub const lINFO: log_level = 2; +pub const lWARN: log_level = 1; +pub const lERROR: log_level = 0; +pub type event_type = libc::c_uint; +pub const EVENT_WAKE: event_type = 2; +pub const EVENT_READ: event_type = 1; +pub const EVENT_TIMEOUT: event_type = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct buffer { + pub buf: *mut u8_t, + pub readp: *mut u8_t, + pub writep: *mut u8_t, + pub wrap: *mut u8_t, + pub size: size_t, + pub base_size: size_t, + pub mutex: pthread_mutex_t, +} +// char header[] - added in sendRESP +// S:N:Slimproto _http_metadata_handler +#[derive(Copy, Clone)] +#[repr(C, packed)] pub struct META_header { pub opcode: [libc::c_char; 4], - pub length: crate::squeezelite_h::u32_t, + pub length: u32_t, } // S:N:Slimproto _http_response_handler - -#[repr(C, packed)] #[derive(Copy, Clone)] +#[repr(C, packed)] pub struct RESP_header { pub opcode: [libc::c_char; 4], - pub length: crate::squeezelite_h::u32_t, + pub length: u32_t, } // u8_t capabilities[]; // S:N:Slimproto _stat_handler - -#[repr(C, packed)] #[derive(Copy, Clone)] +#[repr(C, packed)] pub struct STAT_packet { pub opcode: [libc::c_char; 4], - pub length: crate::squeezelite_h::u32_t, - pub event: crate::squeezelite_h::u32_t, - pub num_crlf: crate::squeezelite_h::u8_t, - pub mas_initialized: crate::squeezelite_h::u8_t, - pub mas_mode: crate::squeezelite_h::u8_t, - pub stream_buffer_size: crate::squeezelite_h::u32_t, - pub stream_buffer_fullness: crate::squeezelite_h::u32_t, - pub bytes_received_H: crate::squeezelite_h::u32_t, - pub bytes_received_L: crate::squeezelite_h::u32_t, - pub signal_strength: crate::squeezelite_h::u16_t, - pub jiffies: crate::squeezelite_h::u32_t, - pub output_buffer_size: crate::squeezelite_h::u32_t, - pub output_buffer_fullness: crate::squeezelite_h::u32_t, - pub elapsed_seconds: crate::squeezelite_h::u32_t, - pub voltage: crate::squeezelite_h::u16_t, - pub elapsed_milliseconds: crate::squeezelite_h::u32_t, - pub server_timestamp: crate::squeezelite_h::u32_t, - pub error_code: crate::squeezelite_h::u16_t, + pub length: u32_t, + pub event: u32_t, + pub num_crlf: u8_t, + pub mas_initialized: u8_t, + pub mas_mode: u8_t, + pub stream_buffer_size: u32_t, + pub stream_buffer_fullness: u32_t, + pub bytes_received_H: u32_t, + pub bytes_received_L: u32_t, + pub signal_strength: u16_t, + pub jiffies: u32_t, + pub output_buffer_size: u32_t, + pub output_buffer_fullness: u32_t, + pub elapsed_seconds: u32_t, + pub voltage: u16_t, + pub elapsed_milliseconds: u32_t, + pub server_timestamp: u32_t, + pub error_code: u16_t, } -// S:N:Slimproto _disco_handler - -#[repr(C, packed)] #[derive(Copy, Clone)] +#[repr(C)] +pub struct C2RustUnnamed_0 { + pub updated: u32_t, + pub stream_start: u32_t, + pub stream_full: u32_t, + pub stream_size: u32_t, + pub stream_bytes: u64_t, + pub output_full: u32_t, + pub output_size: u32_t, + pub frames_played: u32_t, + pub device_frames: u32_t, + pub current_sample_rate: u32_t, + pub last: u32_t, + pub stream_state: stream_state, +} +pub type stream_state = libc::c_uint; +pub const RECV_HEADERS: stream_state = 7; +pub const SEND_HEADERS: stream_state = 6; +pub const STREAMING_HTTP: stream_state = 5; +pub const STREAMING_FILE: stream_state = 4; +pub const STREAMING_BUFFERING: stream_state = 3; +pub const STREAMING_WAIT: stream_state = 2; +pub const DISCONNECT: stream_state = 1; +pub const STOPPED: stream_state = 0; +pub type disconnect_code = libc::c_uint; +pub const TIMEOUT: disconnect_code = 4; +pub const UNREACHABLE: disconnect_code = 3; +pub const REMOTE_DISCONNECT: disconnect_code = 2; +pub const LOCAL_DISCONNECT: disconnect_code = 1; +pub const DISCONNECT_OK: disconnect_code = 0; +// S:N:Slimproto _disco_handler +#[derive(Copy, Clone)] +#[repr(C, packed)] pub struct DSCO_packet { pub opcode: [libc::c_char; 4], - pub length: crate::squeezelite_h::u32_t, - pub reason: crate::squeezelite_h::u8_t, + pub length: u32_t, + pub reason: u8_t, +} +pub const OUTPUT_RUNNING: output_state = 2; +pub type output_state = libc::c_int; +pub const OUTPUT_START_AT: output_state = 5; +pub const OUTPUT_SKIP_FRAMES: output_state = 4; +pub const OUTPUT_PAUSE_FRAMES: output_state = 3; +pub const OUTPUT_BUFFER: output_state = 1; +pub const OUTPUT_STOPPED: output_state = 0; +pub const OUTPUT_OFF: output_state = -1; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct outputstate { + pub state: output_state, + pub format: output_format, + pub device: *const libc::c_char, + pub buffer: libc::c_uint, + pub period: libc::c_uint, + pub track_started: bool, + pub write_cb: Option libc::c_int>, + pub start_frames: libc::c_uint, + pub frames_played: libc::c_uint, + pub frames_played_dmp: libc::c_uint, + pub current_sample_rate: libc::c_uint, + pub supported_rates: [libc::c_uint; 18], + pub default_sample_rate: libc::c_uint, + pub error_opening: bool, + pub device_frames: libc::c_uint, + pub updated: u32_t, + pub track_start_time: u32_t, + pub current_replay_gain: u32_t, + pub c2rust_unnamed: C2RustUnnamed_1, + pub next_sample_rate: libc::c_uint, + pub track_start: *mut u8_t, + pub gainL: u32_t, + pub gainR: u32_t, + pub invert: bool, + pub next_replay_gain: u32_t, + pub threshold: libc::c_uint, + pub fade: fade_state, + pub fade_start: *mut u8_t, + pub fade_end: *mut u8_t, + pub fade_dir: fade_dir, + pub fade_mode: fade_mode, + pub fade_secs: libc::c_uint, + pub rate_delay: libc::c_uint, + pub delay_active: bool, + pub stop_time: u32_t, + pub idle_to: u32_t, +} +pub type fade_mode = libc::c_uint; +pub const FADE_INOUT: fade_mode = 4; +pub const FADE_OUT: fade_mode = 3; +pub const FADE_IN: fade_mode = 2; +pub const FADE_CROSSFADE: fade_mode = 1; +pub const FADE_NONE: fade_mode = 0; +pub type fade_dir = libc::c_uint; +pub const FADE_CROSS: fade_dir = 3; +pub const FADE_DOWN: fade_dir = 2; +pub const FADE_UP: fade_dir = 1; +pub type fade_state = libc::c_uint; +pub const FADE_ACTIVE: fade_state = 2; +pub const FADE_DUE: fade_state = 1; +pub const FADE_INACTIVE: fade_state = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub union C2RustUnnamed_1 { + pub pause_frames: u32_t, + pub skip_frames: u32_t, + pub start_at: u32_t, +} +pub type output_format = libc::c_uint; +pub const S16_LE: output_format = 3; +pub const S24_3LE: output_format = 2; +pub const S24_LE: output_format = 1; +pub const S32_LE: output_format = 0; +pub const DECODE_STOPPED: decode_state = 0; +pub type decode_state = libc::c_uint; +pub const DECODE_ERROR: decode_state = 4; +pub const DECODE_COMPLETE: decode_state = 3; +pub const DECODE_RUNNING: decode_state = 2; +pub const DECODE_READY: decode_state = 1; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct decodestate { + pub state: decode_state, + pub new_stream: bool, + pub mutex: pthread_mutex_t, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct streamstate { + pub state: stream_state, + pub disconnect: disconnect_code, + pub header: *mut libc::c_char, + pub header_len: size_t, + pub sent_headers: bool, + pub cont_wait: bool, + pub bytes: u64_t, + pub threshold: libc::c_uint, + pub meta_interval: u32_t, + pub meta_next: u32_t, + pub meta_left: u32_t, + pub meta_send: bool, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct handler { + pub opcode: [libc::c_char; 5], + pub handler: Option ()>, } // guids we don't use // S:C:Commands - -#[repr(C, packed)] #[derive(Copy, Clone)] +#[repr(C, packed)] pub struct serv_packet { pub opcode: [libc::c_char; 4], - pub server_ip: crate::squeezelite_h::u32_t, + pub server_ip: u32_t, } // possible sync group // S:P:Squeezebox2 - -#[repr(C, packed)] #[derive(Copy, Clone)] +#[repr(C, packed)] pub struct setd_packet { pub opcode: [libc::c_char; 4], - pub id: crate::squeezelite_h::u8_t, + pub id: u8_t, pub data: [libc::c_char; 0], } // char metadata[] // S:N:Slimproto _http_setting_handler - -#[repr(C, packed)] #[derive(Copy, Clone)] +#[repr(C, packed)] pub struct SETD_header { pub opcode: [libc::c_char; 4], - pub length: crate::squeezelite_h::u32_t, - pub id: crate::squeezelite_h::u8_t, + pub length: u32_t, + pub id: u8_t, } // S:P:Squeezebox2 - -#[repr(C, packed)] #[derive(Copy, Clone)] +#[repr(C, packed)] pub struct audg_packet { pub opcode: [libc::c_char; 4], - pub old_gainL: crate::squeezelite_h::u32_t, - pub old_gainR: crate::squeezelite_h::u32_t, - pub adjust: crate::squeezelite_h::u8_t, - pub preamp: crate::squeezelite_h::u8_t, - pub gainL: crate::squeezelite_h::u32_t, - pub gainR: crate::squeezelite_h::u32_t, + pub old_gainL: u32_t, + pub old_gainR: u32_t, + pub adjust: u8_t, + pub preamp: u8_t, + pub gainL: u32_t, + pub gainR: u32_t, } //char request_string[]; // S:P:Squeezebox2 - -#[repr(C, packed)] #[derive(Copy, Clone)] +#[repr(C, packed)] pub struct aude_packet { pub opcode: [libc::c_char; 4], - pub enable_spdif: crate::squeezelite_h::u8_t, - pub enable_dac: crate::squeezelite_h::u8_t, + pub enable_spdif: u8_t, + pub enable_dac: u8_t, } // codec open - this is an extension to slimproto to allow the server to read the header and then return decode params - -#[repr(C, packed)] #[derive(Copy, Clone)] +#[repr(C, packed)] pub struct codc_packet { pub opcode: [libc::c_char; 4], - pub format: crate::squeezelite_h::u8_t, - pub pcm_sample_size: crate::squeezelite_h::u8_t, - pub pcm_sample_rate: crate::squeezelite_h::u8_t, - pub pcm_channels: crate::squeezelite_h::u8_t, - pub pcm_endianness: crate::squeezelite_h::u8_t, + pub format: u8_t, + pub pcm_sample_size: u8_t, + pub pcm_sample_rate: u8_t, + pub pcm_channels: u8_t, + pub pcm_endianness: u8_t, } // squence ids - unused // S:P:Squeezebox2 - -#[repr(C, packed)] #[derive(Copy, Clone)] +#[repr(C, packed)] pub struct cont_packet { pub opcode: [libc::c_char; 4], - pub metaint: crate::squeezelite_h::u32_t, - pub loop_0: crate::squeezelite_h::u8_t, + pub metaint: u32_t, + pub loop_0: u8_t, } // data // from S:P:Squeezebox stream_s - -#[repr(C, packed)] #[derive(Copy, Clone)] +#[repr(C, packed)] pub struct strm_packet { pub opcode: [libc::c_char; 4], pub command: libc::c_char, - pub autostart: crate::squeezelite_h::u8_t, - pub format: crate::squeezelite_h::u8_t, - pub pcm_sample_size: crate::squeezelite_h::u8_t, - pub pcm_sample_rate: crate::squeezelite_h::u8_t, - pub pcm_channels: crate::squeezelite_h::u8_t, - pub pcm_endianness: crate::squeezelite_h::u8_t, - pub threshold: crate::squeezelite_h::u8_t, - pub spdif_enable: crate::squeezelite_h::u8_t, - pub transition_period: crate::squeezelite_h::u8_t, - pub transition_type: crate::squeezelite_h::u8_t, - pub flags: crate::squeezelite_h::u8_t, - pub output_threshold: crate::squeezelite_h::u8_t, - pub slaves: crate::squeezelite_h::u8_t, - pub replay_gain: crate::squeezelite_h::u32_t, - pub server_port: crate::squeezelite_h::u16_t, - pub server_ip: crate::squeezelite_h::u32_t, + pub autostart: u8_t, + pub format: u8_t, + pub pcm_sample_size: u8_t, + pub pcm_sample_rate: u8_t, + pub pcm_channels: u8_t, + pub pcm_endianness: u8_t, + pub threshold: u8_t, + pub spdif_enable: u8_t, + pub transition_period: u8_t, + pub transition_type: u8_t, + pub flags: u8_t, + pub output_threshold: u8_t, + pub slaves: u8_t, + pub replay_gain: u32_t, + pub server_port: u16_t, + pub server_ip: u32_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 @@ -173,275 +631,43 @@ pub struct strm_packet { */ // packet formats for slimproto // from S:N:Slimproto _hello_handler - -#[repr(C, packed)] #[derive(Copy, Clone)] +#[repr(C, packed)] pub struct HELO_packet { pub opcode: [libc::c_char; 4], - pub length: crate::squeezelite_h::u32_t, - pub deviceid: crate::squeezelite_h::u8_t, - pub revision: crate::squeezelite_h::u8_t, - pub mac: [crate::squeezelite_h::u8_t; 6], - pub uuid: [crate::squeezelite_h::u8_t; 16], - pub wlan_channellist: crate::squeezelite_h::u16_t, - pub bytes_received_H: crate::squeezelite_h::u32_t, - pub bytes_received_L: crate::squeezelite_h::u32_t, + pub length: u32_t, + pub deviceid: u8_t, + pub revision: u8_t, + pub mac: [u8_t; 6], + pub uuid: [u8_t; 16], + pub wlan_channellist: u16_t, + pub bytes_received_H: u32_t, + pub bytes_received_L: u32_t, pub lang: [libc::c_char; 2], } -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::__socklen_t; -pub use crate::stdlib::__ssize_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::__useconds_t; -pub use crate::stdlib::fclose; -pub use crate::stdlib::fgets; -pub use crate::stdlib::fopen; -pub use crate::stdlib::fputs; -pub use crate::stdlib::int32_t; -pub use crate::stdlib::snprintf; -pub use crate::stdlib::ssize_t; -pub use crate::stdlib::FILE; -pub use crate::stdlib::_IO_FILE; - -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_int16_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::stdlib::__socket_type; -pub use crate::stdlib::close; -pub use crate::stdlib::sa_family_t; -pub use crate::stdlib::sleep; -pub use crate::stdlib::socklen_t; -pub use crate::stdlib::uint16_t; -pub use crate::stdlib::uint32_t; -pub use crate::stdlib::uint64_t; -pub use crate::stdlib::usleep; -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::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::event_type; -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::sockfd; -pub use crate::squeezelite_h::stream_state; -pub use crate::squeezelite_h::streamstate; -pub use crate::squeezelite_h::u16_t; -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::EVENT_READ; -pub use crate::squeezelite_h::EVENT_TIMEOUT; -pub use crate::squeezelite_h::EVENT_WAKE; -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_flush; -pub use crate::src::decode::codec_open; -pub use crate::src::decode::decode_flush; -pub use crate::src::output::output_flush; -pub use crate::src::output_alsa::set_volume; -pub use crate::src::stream::stream_disconnect; -pub use crate::src::stream::stream_file; -pub use crate::src::stream::stream_sock; -pub use crate::src::utils::connect_timeout; -pub use crate::src::utils::gettime_ms; -pub use crate::src::utils::logprint; -pub use crate::src::utils::logtime; -pub use crate::src::utils::packN; -pub use crate::src::utils::packn; -pub use crate::src::utils::server_addr; -pub use crate::src::utils::set_nonblock; -pub use crate::src::utils::set_readwake_handles; -pub use crate::src::utils::unpackN; -pub use crate::src::utils::wait_readwake; -use crate::stdlib::__errno_location; -pub use crate::stdlib::eventfd; -pub use crate::stdlib::eventfd_t; -pub use crate::stdlib::eventfd_write; -use crate::stdlib::free; -use crate::stdlib::getsockname; -pub use crate::stdlib::htonl; -pub use crate::stdlib::htons; -pub use crate::stdlib::in_addr; -pub use crate::stdlib::in_addr_t; -pub use crate::stdlib::in_port_t; -use crate::stdlib::inet_ntoa; -use crate::stdlib::malloc; -use crate::stdlib::memcpy; -use crate::stdlib::memset; -pub use crate::stdlib::nfds_t; -pub use crate::stdlib::ntohs; -pub use crate::stdlib::poll; -pub use crate::stdlib::pollfd; -use crate::stdlib::pthread_mutex_lock; -use crate::stdlib::pthread_mutex_unlock; -use crate::stdlib::recv; -use crate::stdlib::recvfrom; -use crate::stdlib::send; -use crate::stdlib::sendto; -use crate::stdlib::setsockopt; -pub use crate::stdlib::sockaddr; -pub use crate::stdlib::sockaddr_in; -use crate::stdlib::socket; -use crate::stdlib::strcat; -use crate::stdlib::strerror; -use crate::stdlib::strlen; -use crate::stdlib::strncat; -use crate::stdlib::strncmp; -use crate::stdlib::strncpy; -pub use crate::stdlib::C2RustUnnamed_0; -pub use crate::stdlib::MSG_BATCH; -pub use crate::stdlib::MSG_CMSG_CLOEXEC; -pub use crate::stdlib::MSG_CONFIRM; -pub use crate::stdlib::MSG_CTRUNC; -pub use crate::stdlib::MSG_DONTROUTE; -pub use crate::stdlib::MSG_DONTWAIT; -pub use crate::stdlib::MSG_EOR; -pub use crate::stdlib::MSG_ERRQUEUE; -pub use crate::stdlib::MSG_FASTOPEN; -pub use crate::stdlib::MSG_FIN; -pub use crate::stdlib::MSG_MORE; -pub use crate::stdlib::MSG_NOSIGNAL; -pub use crate::stdlib::MSG_OOB; -pub use crate::stdlib::MSG_PEEK; -pub use crate::stdlib::MSG_PROXY; -pub use crate::stdlib::MSG_RST; -pub use crate::stdlib::MSG_SYN; -pub use crate::stdlib::MSG_TRUNC; -pub use crate::stdlib::MSG_WAITALL; -pub use crate::stdlib::MSG_WAITFORONE; -pub use crate::stdlib::MSG_ZEROCOPY; -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; - #[no_mangle] - pub static mut decode: crate::squeezelite_h::decodestate; - #[no_mangle] - pub static mut codecs: [*mut crate::squeezelite_h::codec; 0]; -} - -#[repr(C)] #[derive(Copy, Clone)] -pub struct C2RustUnnamed_17 { - pub updated: crate::squeezelite_h::u32_t, - pub stream_start: crate::squeezelite_h::u32_t, - pub stream_full: crate::squeezelite_h::u32_t, - pub stream_size: crate::squeezelite_h::u32_t, - pub stream_bytes: crate::squeezelite_h::u64_t, - pub output_full: crate::squeezelite_h::u32_t, - pub output_size: crate::squeezelite_h::u32_t, - pub frames_played: crate::squeezelite_h::u32_t, - pub device_frames: crate::squeezelite_h::u32_t, - pub current_sample_rate: crate::squeezelite_h::u32_t, - pub last: crate::squeezelite_h::u32_t, - pub stream_state: crate::squeezelite_h::stream_state, -} - #[repr(C)] -#[derive(Copy, Clone)] -pub struct handler { - pub opcode: [libc::c_char; 5], - pub handler: - Option ()>, +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 ()>, + pub close: Option ()>, + pub decode: Option decode_state>, } -/* +/* * 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 @@ -454,368 +680,276 @@ pub struct handler { * -Control of Raspberry pi GPIO for amplifier power * -Launch script on power status change from LMS */ - -static mut loglevel: crate::squeezelite_h::log_level = crate::squeezelite_h::lERROR; +static mut loglevel: log_level = lERROR; // 3483 - -static mut sock: crate::squeezelite_h::sockfd = -(1 as libc::c_int); - -static mut slimproto_ip: crate::stdlib::in_addr_t = 0 as libc::c_int as crate::stdlib::in_addr_t; +static mut sock: sockfd = -(1 as libc::c_int); +static mut slimproto_ip: in_addr_t = 0 as libc::c_int as in_addr_t; #[no_mangle] - pub static mut wake_e: libc::c_int = 0; - -static mut status: C2RustUnnamed_17 = C2RustUnnamed_17 { - updated: 0, - stream_start: 0, - stream_full: 0, - stream_size: 0, - stream_bytes: 0, - output_full: 0, - output_size: 0, - frames_played: 0, - device_frames: 0, - current_sample_rate: 0, - last: 0, - stream_state: crate::squeezelite_h::STOPPED, -}; +static mut status: C2RustUnnamed_0 = + C2RustUnnamed_0{updated: 0, + stream_start: 0, + stream_full: 0, + stream_size: 0, + stream_bytes: 0, + output_full: 0, + output_size: 0, + frames_played: 0, + device_frames: 0, + current_sample_rate: 0, + last: 0, + stream_state: STOPPED,}; #[no_mangle] - pub static mut autostart: libc::c_int = 0; #[no_mangle] - pub static mut sentSTMu: bool = false; #[no_mangle] - pub static mut sentSTMo: bool = false; #[no_mangle] - pub static mut sentSTMl: bool = false; #[no_mangle] - -pub static mut new_server: crate::squeezelite_h::u32_t = 0; +pub static mut new_server: u32_t = 0; #[no_mangle] - -pub static mut new_server_cap: *mut libc::c_char = 0 as *const libc::c_char as *mut libc::c_char; +pub static mut new_server_cap: *mut libc::c_char = + 0 as *const libc::c_char as *mut libc::c_char; #[no_mangle] - -pub static mut player_name: [libc::c_char; 65] = [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, -]; +pub static mut player_name: [libc::c_char; 65] = + [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; #[no_mangle] - pub static mut name_file: *const libc::c_char = 0 as *const libc::c_char; #[no_mangle] - -pub unsafe extern "C" fn send_packet( - mut packet: *mut crate::squeezelite_h::u8_t, - mut len: crate::stddef_h::size_t, -) { - let mut ptr = packet; // squeezeplay - let mut try_0 = 0 as libc::c_int as libc::c_uint; - let mut n: crate::stdlib::ssize_t = 0; +pub unsafe extern "C" fn send_packet(mut packet: *mut u8_t, mut len: size_t) { + let mut ptr: *mut u8_t = packet; // squeezeplay + let mut try_0: libc::c_uint = 0 as libc::c_int as libc::c_uint; + let mut n: ssize_t = 0; while len != 0 { - n = crate::stdlib::send( - sock, - ptr as *const libc::c_void, - len, - crate::stdlib::MSG_NOSIGNAL as libc::c_int, - ); + n = + send(sock, ptr as *const libc::c_void, len, + MSG_NOSIGNAL as libc::c_int); if n <= 0 as libc::c_int as libc::c_long { - if n < 0 as libc::c_int as libc::c_long - && *crate::stdlib::__errno_location() == 11 as libc::c_int - && try_0 < 10 as libc::c_int as libc::c_uint - { - if loglevel as libc::c_uint - >= crate::squeezelite_h::lDEBUG as libc::c_int as libc::c_uint - { + if n < 0 as libc::c_int as libc::c_long && + *__errno_location() == 11 as libc::c_int && + try_0 < 10 as libc::c_int as libc::c_uint { + if loglevel as libc::c_uint >= + lDEBUG as libc::c_int as libc::c_uint { try_0 = try_0.wrapping_add(1); - crate::src::utils::logprint( - b"%s %s:%d retrying (%d) writing to socket\n\x00" as *const u8 - as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 12], &[libc::c_char; 12]>( - b"send_packet\x00", - )) - .as_ptr(), - 104 as libc::c_int, - try_0, - ); + logprint(b"%s %s:%d retrying (%d) writing to socket\n\x00" + as *const u8 as *const libc::c_char, + logtime(), + (*::std::mem::transmute::<&[u8; 12], + &[libc::c_char; 12]>(b"send_packet\x00")).as_ptr(), + 104 as libc::c_int, try_0); } - crate::stdlib::usleep(1000 as libc::c_int as crate::stdlib::__useconds_t); + usleep(1000 as libc::c_int as __useconds_t); } 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 failed writing to socket: %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"send_packet\x00", - )) - .as_ptr(), - 108 as libc::c_int, - crate::stdlib::strerror(*crate::stdlib::__errno_location()), - ); + if loglevel as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d failed writing to socket: %s\n\x00" as + *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 12], + &[libc::c_char; 12]>(b"send_packet\x00")).as_ptr(), + 108 as libc::c_int, + strerror(*__errno_location())); } - return; + return } } else { ptr = ptr.offset(n as isize); - len = (len as libc::c_ulong).wrapping_sub(n as libc::c_ulong) as crate::stddef_h::size_t - as crate::stddef_h::size_t + len = + (len as libc::c_ulong).wrapping_sub(n as libc::c_ulong) as + size_t as size_t } - } -} - -unsafe extern "C" fn sendHELO( - mut reconnect: bool, - mut fixed_cap: *const libc::c_char, - mut var_cap: *const libc::c_char, - mut mac: *mut crate::squeezelite_h::u8_t, -) { - let mut base_cap = 0 as *const libc::c_char; - let mut pkt = crate::src::slimproto::HELO_packet { - opcode: [0; 4], - length: 0, - deviceid: 0, - revision: 0, - mac: [0; 6], - uuid: [0; 16], - wlan_channellist: 0, - bytes_received_H: 0, - bytes_received_L: 0, - lang: [0; 2], }; +} +unsafe extern "C" fn sendHELO(mut reconnect: bool, + mut fixed_cap: *const libc::c_char, + mut var_cap: *const libc::c_char, + mut mac: *mut u8_t) { + let mut base_cap: *const libc::c_char = 0 as *const libc::c_char; + let mut pkt: HELO_packet = + HELO_packet{opcode: [0; 4], + length: 0, + deviceid: 0, + revision: 0, + mac: [0; 6], + uuid: [0; 16], + wlan_channellist: 0, + bytes_received_H: 0, + bytes_received_L: 0, + lang: [0; 2],}; base_cap = - b"Model=squeezelite,AccuratePlayPoints=1,HasDigitalOut=1,HasPolarityInversion=1,Firmware=v1.9.7-1218\x00" + b"Model=squeezelite,AccuratePlayPoints=1,HasDigitalOut=1,HasPolarityInversion=1,Firmware=v1.9.7-1223\x00" as *const u8 as *const libc::c_char; - crate::stdlib::memset( - &mut pkt as *mut crate::src::slimproto::HELO_packet as *mut libc::c_void, - 0 as libc::c_int, - ::std::mem::size_of::() as libc::c_ulong, - ); - crate::stdlib::memcpy( - &mut pkt.opcode as *mut [libc::c_char; 4] as *mut libc::c_void, - b"HELO\x00" as *const u8 as *const libc::c_char as *const libc::c_void, - 4 as libc::c_int as libc::c_ulong, - ); - pkt.length = crate::stdlib::htonl( - (::std::mem::size_of::() as libc::c_ulong) - .wrapping_sub(8 as libc::c_int as libc::c_ulong) - .wrapping_add(crate::stdlib::strlen(base_cap)) - .wrapping_add(crate::stdlib::strlen(fixed_cap)) - .wrapping_add(crate::stdlib::strlen(var_cap)) as crate::stdlib::uint32_t, - ); - pkt.deviceid = 12 as libc::c_int as crate::squeezelite_h::u8_t; - pkt.revision = 0 as libc::c_int as crate::squeezelite_h::u8_t; - crate::src::utils::packn( - &mut pkt.wlan_channellist, - if reconnect as libc::c_int != 0 { - 0x4000 as libc::c_int - } else { - 0 as libc::c_int - } as crate::squeezelite_h::u16_t, - ); - crate::src::utils::packN( - &mut pkt.bytes_received_H, - (status.stream_bytes >> 32 as libc::c_int) as crate::squeezelite_h::u32_t, - ); - crate::src::utils::packN( - &mut pkt.bytes_received_L, - (status.stream_bytes & 0xffffffff as libc::c_uint as libc::c_ulong) - as crate::squeezelite_h::u32_t, - ); - crate::stdlib::memcpy( - pkt.mac.as_mut_ptr() as *mut libc::c_void, - mac as *const libc::c_void, - 6 as libc::c_int as libc::c_ulong, - ); - 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 mac: %02x:%02x:%02x:%02x:%02x:%02x\n\x00" as *const u8 - as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 9], &[libc::c_char; 9]>(b"sendHELO\x00")).as_ptr(), - 142 as libc::c_int, - pkt.mac[0 as libc::c_int as usize] as libc::c_int, - pkt.mac[1 as libc::c_int as usize] as libc::c_int, - pkt.mac[2 as libc::c_int as usize] as libc::c_int, - pkt.mac[3 as libc::c_int as usize] as libc::c_int, - pkt.mac[4 as libc::c_int as usize] as libc::c_int, - pkt.mac[5 as libc::c_int as usize] as libc::c_int, - ); + memset(&mut pkt as *mut HELO_packet as *mut libc::c_void, + 0 as libc::c_int, + ::std::mem::size_of::() as libc::c_ulong); + memcpy(&mut pkt.opcode as *mut [libc::c_char; 4] as *mut libc::c_void, + b"HELO\x00" as *const u8 as *const libc::c_char as + *const libc::c_void, 4 as libc::c_int as libc::c_ulong); + pkt.length = + htonl((::std::mem::size_of::() as + libc::c_ulong).wrapping_sub(8 as libc::c_int as + libc::c_ulong).wrapping_add(strlen(base_cap)).wrapping_add(strlen(fixed_cap)).wrapping_add(strlen(var_cap)) + as uint32_t); + pkt.deviceid = 12 as libc::c_int as u8_t; + pkt.revision = 0 as libc::c_int as u8_t; + packn(&mut pkt.wlan_channellist, + if reconnect as libc::c_int != 0 { + 0x4000 as libc::c_int + } else { 0 as libc::c_int } as u16_t); + packN(&mut pkt.bytes_received_H, + (status.stream_bytes >> 32 as libc::c_int) as u32_t); + packN(&mut pkt.bytes_received_L, + (status.stream_bytes & 0xffffffff as libc::c_uint as libc::c_ulong) + as u32_t); + memcpy(pkt.mac.as_mut_ptr() as *mut libc::c_void, + mac as *const libc::c_void, 6 as libc::c_int as libc::c_ulong); + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d mac: %02x:%02x:%02x:%02x:%02x:%02x\n\x00" as + *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 9], + &[libc::c_char; 9]>(b"sendHELO\x00")).as_ptr(), + 142 as libc::c_int, + pkt.mac[0 as libc::c_int as usize] as libc::c_int, + pkt.mac[1 as libc::c_int as usize] as libc::c_int, + pkt.mac[2 as libc::c_int as usize] as libc::c_int, + pkt.mac[3 as libc::c_int as usize] as libc::c_int, + pkt.mac[4 as libc::c_int as usize] as libc::c_int, + pkt.mac[5 as libc::c_int as usize] 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 cap: %s%s%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"sendHELO\x00")).as_ptr(), - 144 as libc::c_int, - base_cap, - fixed_cap, - var_cap, - ); + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d cap: %s%s%s\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 9], + &[libc::c_char; 9]>(b"sendHELO\x00")).as_ptr(), + 144 as libc::c_int, base_cap, fixed_cap, var_cap); } - send_packet( - &mut pkt as *mut crate::src::slimproto::HELO_packet as *mut crate::squeezelite_h::u8_t, - ::std::mem::size_of::() as libc::c_ulong, - ); - send_packet( - base_cap as *mut crate::squeezelite_h::u8_t, - crate::stdlib::strlen(base_cap), - ); - send_packet( - fixed_cap as *mut crate::squeezelite_h::u8_t, - crate::stdlib::strlen(fixed_cap), - ); - send_packet( - var_cap as *mut crate::squeezelite_h::u8_t, - crate::stdlib::strlen(var_cap), - ); + send_packet(&mut pkt as *mut HELO_packet as *mut u8_t, + ::std::mem::size_of::() as libc::c_ulong); + send_packet(base_cap as *mut u8_t, strlen(base_cap)); + send_packet(fixed_cap as *mut u8_t, strlen(fixed_cap)); + send_packet(var_cap as *mut u8_t, strlen(var_cap)); } - -unsafe extern "C" fn sendSTAT( - mut event: *const libc::c_char, - mut server_timestamp: crate::squeezelite_h::u32_t, -) { - let mut pkt = crate::src::slimproto::STAT_packet { - opcode: [0; 4], - length: 0, - event: 0, - num_crlf: 0, - mas_initialized: 0, - mas_mode: 0, - stream_buffer_size: 0, - stream_buffer_fullness: 0, - bytes_received_H: 0, - bytes_received_L: 0, - signal_strength: 0, - jiffies: 0, - output_buffer_size: 0, - output_buffer_fullness: 0, - elapsed_seconds: 0, - voltage: 0, - elapsed_milliseconds: 0, - server_timestamp: 0, - error_code: 0, - }; - let mut now = crate::src::utils::gettime_ms(); - let mut ms_played: crate::squeezelite_h::u32_t = 0; - if status.current_sample_rate != 0 - && status.frames_played != 0 - && status.frames_played > status.device_frames - { - ms_played = (status.frames_played.wrapping_sub(status.device_frames) - as crate::squeezelite_h::u64_t) - .wrapping_mul(1000 as libc::c_int as crate::squeezelite_h::u64_t) - .wrapping_div(status.current_sample_rate as crate::squeezelite_h::u64_t) - as crate::squeezelite_h::u32_t; +unsafe extern "C" fn sendSTAT(mut event: *const libc::c_char, + mut server_timestamp: u32_t) { + let mut pkt: STAT_packet = + STAT_packet{opcode: [0; 4], + length: 0, + event: 0, + num_crlf: 0, + mas_initialized: 0, + mas_mode: 0, + stream_buffer_size: 0, + stream_buffer_fullness: 0, + bytes_received_H: 0, + bytes_received_L: 0, + signal_strength: 0, + jiffies: 0, + output_buffer_size: 0, + output_buffer_fullness: 0, + elapsed_seconds: 0, + voltage: 0, + elapsed_milliseconds: 0, + server_timestamp: 0, + error_code: 0,}; + let mut now: u32_t = gettime_ms(); + let mut ms_played: u32_t = 0; + if status.current_sample_rate != 0 && status.frames_played != 0 && + status.frames_played > status.device_frames { + ms_played = + (status.frames_played.wrapping_sub(status.device_frames) as + u64_t).wrapping_mul(1000 as libc::c_int as + u64_t).wrapping_div(status.current_sample_rate + as u64_t) as + u32_t; if now > status.updated { - ms_played = (ms_played as libc::c_uint).wrapping_add(now.wrapping_sub(status.updated)) - as crate::squeezelite_h::u32_t - as crate::squeezelite_h::u32_t + ms_played = + (ms_played as + libc::c_uint).wrapping_add(now.wrapping_sub(status.updated)) + as u32_t as u32_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 ms_played: %u (frames_played: %u device_frames: %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"sendSTAT\x00")).as_ptr(), - 160 as libc::c_int, - ms_played, - status.frames_played, - status.device_frames, - ); + if loglevel as libc::c_uint >= lSDEBUG as libc::c_int as libc::c_uint + { + logprint(b"%s %s:%d ms_played: %u (frames_played: %u device_frames: %u)\n\x00" + as *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 9], + &[libc::c_char; 9]>(b"sendSTAT\x00")).as_ptr(), + 160 as libc::c_int, ms_played, status.frames_played, + status.device_frames); } } else if status.frames_played != 0 && now > status.stream_start { ms_played = now.wrapping_sub(status.stream_start); - 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 ms_played: %u using elapsed time (frames_played: %u device_frames: %u)\n\x00" - as *const u8 as *const libc::c_char, crate::src::utils::logtime(), + if loglevel as libc::c_uint >= lSDEBUG as libc::c_int as libc::c_uint + { + logprint(b"%s %s:%d ms_played: %u using elapsed time (frames_played: %u device_frames: %u)\n\x00" + as *const u8 as *const libc::c_char, logtime(), (*::std::mem::transmute::<&[u8; 9], &[libc::c_char; 9]>(b"sendSTAT\x00")).as_ptr(), 163 as libc::c_int, ms_played, status.frames_played, status.device_frames); } } else { - 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 ms_played: 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"sendSTAT\x00")).as_ptr(), - 165 as libc::c_int, - ); - } - ms_played = 0 as libc::c_int as crate::squeezelite_h::u32_t - } - crate::stdlib::memset( - &mut pkt as *mut crate::src::slimproto::STAT_packet as *mut libc::c_void, - 0 as libc::c_int, - ::std::mem::size_of::() as libc::c_ulong, - ); - crate::stdlib::memcpy( - &mut pkt.opcode as *mut [libc::c_char; 4] as *mut libc::c_void, - b"STAT\x00" as *const u8 as *const libc::c_char as *const libc::c_void, - 4 as libc::c_int as libc::c_ulong, - ); - pkt.length = crate::stdlib::htonl( - (::std::mem::size_of::() as libc::c_ulong) - .wrapping_sub(8 as libc::c_int as libc::c_ulong) as crate::stdlib::uint32_t, - ); - crate::stdlib::memcpy( - &mut pkt.event as *mut crate::squeezelite_h::u32_t as *mut libc::c_void, - event as *const libc::c_void, - 4 as libc::c_int as libc::c_ulong, - ); - // num_crlf - // mas_initialized; mas_mode; - crate::src::utils::packN(&mut pkt.stream_buffer_fullness, status.stream_full); - crate::src::utils::packN(&mut pkt.stream_buffer_size, status.stream_size); - crate::src::utils::packN( - &mut pkt.bytes_received_H, - (status.stream_bytes >> 32 as libc::c_int) as crate::squeezelite_h::u32_t, - ); - crate::src::utils::packN( - &mut pkt.bytes_received_L, - (status.stream_bytes & 0xffffffff as libc::c_uint as libc::c_ulong) - as crate::squeezelite_h::u32_t, - ); - pkt.signal_strength = 0xffff as libc::c_int as crate::squeezelite_h::u16_t; - crate::src::utils::packN(&mut pkt.jiffies, now); - crate::src::utils::packN(&mut pkt.output_buffer_size, status.output_size); - crate::src::utils::packN(&mut pkt.output_buffer_fullness, status.output_full); - crate::src::utils::packN( - &mut pkt.elapsed_seconds, - ms_played.wrapping_div(1000 as libc::c_int as libc::c_uint), - ); - // voltage; - crate::src::utils::packN(&mut pkt.elapsed_milliseconds, ms_played); // keep this is server format - don't unpack/pack - pkt.server_timestamp = server_timestamp; - // error_code; - 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 STAT: %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"sendSTAT\x00")).as_ptr(), - 189 as libc::c_int, - event, - ); // id 0 is playername S:P:Squeezebox2 - } // STMt replay_gain is no longer used to track latency, but support it - if loglevel as libc::c_uint == crate::squeezelite_h::lSDEBUG 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 received bytesL: %u streambuf: %u outputbuf: %u calc elapsed: %u real elapsed: %u (diff: %d) device: %u delay: %d\n\x00" - as *const u8 as *const libc::c_char, crate::src::utils::logtime(), + if loglevel as libc::c_uint >= lSDEBUG as libc::c_int as libc::c_uint + { + logprint(b"%s %s:%d ms_played: 0\n\x00" as *const u8 as + *const libc::c_char, logtime(), (*::std::mem::transmute::<&[u8; 9], &[libc::c_char; 9]>(b"sendSTAT\x00")).as_ptr(), - 194 as libc::c_int, status.stream_bytes as crate::squeezelite_h::u32_t, + 165 as libc::c_int); + } + ms_played = 0 as libc::c_int as u32_t + } + memset(&mut pkt as *mut STAT_packet as *mut libc::c_void, + 0 as libc::c_int, + ::std::mem::size_of::
::\tSpecify ALSA params to open output device, b = buffer time in ms or size in bytes, p = period count or size in bytes, f sample format (16|24|24_3|32), m = use mmap (0|1)\n -a \t\tSpecify sample format (16|24|32) of output file when using -o - to output samples to stdout (interleaved little endian only)\n -b :\tSpecify internal Stream and Output buffer sizes in Kbytes\n -c ,\tRestrict codecs to those specified, otherwise load all available codecs; known codecs: flac,pcm,mp3,ogg,aac (mad,mpg for specific mp3 codec)\n \t\t\tCodecs reported to LMS in order listed, allowing codec priority refinement.\n -C \t\tClose output device when idle after timeout seconds, default is to keep it open while player is \'on\'\n -d =\tSet logging level, logs: all|slimproto|stream|decode|output, level: info|debug|sdebug\n -e ,\tExplicitly exclude native support of one or more codecs; known codecs: flac,pcm,mp3,ogg,aac (mad,mpg for specific mp3 codec)\n -f \t\tWrite debug to logfile\n -m \t\tSet mac address, format: ab:cd:ef:12:34:56\n -M \tSet the squeezelite player model name sent to the server (default: SqueezeLite)\n -n \t\tSet the player name\n -N \t\tStore player name in filename to allow server defined name changes to be shared between servers (not supported with -n)\n -W\t\t\tRead wave and aiff format from header, ignore server parameters\n -p \t\tSet real time priority of output thread (1-99)\n -P \t\tStore the process id (PID) in filename\n -r [:]\tSample rates supported, allows output to be off when squeezelite is started; rates = |-|,,; delay = optional delay switching rates in ms\n -O \tSpecify mixer device, defaults to \'output device\'\n -L \t\t\tList volume controls for output device\n -U \t\tUnmute ALSA control and set to full volume (not supported with -V)\n -V \t\tUse ALSA control for volume adjustment, otherwise use software volume adjustment\n -X \t\t\tUse linear volume adjustments instead of in terms of dB (only for hardware volume control)\n -z \t\t\tDaemonize\n -t \t\t\tLicense terms\n -? \t\t\tDisplay this help text\n\nBuild options: LINUX ALSA EVENTFD\n\n\x00" + printf(b"Squeezelite v1.9.7-1223, Copyright 2012-2015 Adrian Smith, 2015-2020 Ralph Irving. See -t for license terms\nUsage: %s [options]\n -s [:]\tConnect to specified server, otherwise uses autodiscovery to find server\n -o \tSpecify output device, default \"default\", - = output to stdout\n -l \t\t\tList output devices\n -a :::\tSpecify ALSA params to open output device, b = buffer time in ms or size in bytes, p = period count or size in bytes, f sample format (16|24|24_3|32), m = use mmap (0|1)\n -a \t\tSpecify sample format (16|24|32) of output file when using -o - to output samples to stdout (interleaved little endian only)\n -b :\tSpecify internal Stream and Output buffer sizes in Kbytes\n -c ,\tRestrict codecs to those specified, otherwise load all available codecs; known codecs: flac,pcm,mp3,ogg,aac (mad,mpg for specific mp3 codec)\n \t\t\tCodecs reported to LMS in order listed, allowing codec priority refinement.\n -C \t\tClose output device when idle after timeout seconds, default is to keep it open while player is \'on\'\n -d =\tSet logging level, logs: all|slimproto|stream|decode|output, level: info|debug|sdebug\n -e ,\tExplicitly exclude native support of one or more codecs; known codecs: flac,pcm,mp3,ogg,aac (mad,mpg for specific mp3 codec)\n -f \t\tWrite debug to logfile\n -m \t\tSet mac address, format: ab:cd:ef:12:34:56\n -M \tSet the squeezelite player model name sent to the server (default: SqueezeLite)\n -n \t\tSet the player name\n -N \t\tStore player name in filename to allow server defined name changes to be shared between servers (not supported with -n)\n -W\t\t\tRead wave and aiff format from header, ignore server parameters\n -p \t\tSet real time priority of output thread (1-99)\n -P \t\tStore the process id (PID) in filename\n -r [:]\tSample rates supported, allows output to be off when squeezelite is started; rates = |-|,,; delay = optional delay switching rates in ms\n -O \tSpecify mixer device, defaults to \'output device\'\n -L \t\t\tList volume controls for output device\n -U \t\tUnmute ALSA control and set to full volume (not supported with -V)\n -V \t\tUse ALSA control for volume adjustment, otherwise use software volume adjustment\n -X \t\t\tUse linear volume adjustments instead of in terms of dB (only for hardware volume control)\n -z \t\t\tDaemonize\n -t \t\t\tLicense terms\n -? \t\t\tDisplay this help text\n\nBuild options: LINUX ALSA EVENTFD\n\n\x00" as *const u8 as *const libc::c_char, argv0); } - unsafe extern "C" fn license() { - crate::stdlib::printf(b"Squeezelite v1.9.7-1218, Copyright 2012-2015 Adrian Smith, 2015-2020 Ralph Irving.\n\nThis program is free software: you can redistribute it and/or modify\nit under the terms of the GNU General Public License as published by\nthe Free Software Foundation, either version 3 of the License, or\n(at your option) any later version.\n\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with this program. If not, see .\n\nOption to allow server side upsampling for PCM streams (-W) from\nsqueezelite-R2 (c) Marco Curti 2015, marcoc1712@gmail.com.\n\n\x00" + printf(b"Squeezelite v1.9.7-1223, Copyright 2012-2015 Adrian Smith, 2015-2020 Ralph Irving.\n\nThis program is free software: you can redistribute it and/or modify\nit under the terms of the GNU General Public License as published by\nthe Free Software Foundation, either version 3 of the License, or\n(at your option) any later version.\n\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with this program. If not, see .\n\nOption to allow server side upsampling for PCM streams (-W) from\nsqueezelite-R2 (c) Marco Curti 2015, marcoc1712@gmail.com.\n\n\x00" as *const u8 as *const libc::c_char); } - unsafe extern "C" fn sighandler(mut signum: libc::c_int) { - crate::squeezelite_h::slimproto_stop(); + slimproto_stop(); // remove ourselves in case above does not work, second SIGINT will cause non gracefull shutdown - crate::stdlib::signal(signum, None); // set later + signal(signum, None); // set later } - -unsafe fn main_0(mut argc: libc::c_int, mut argv: *mut *mut libc::c_char) -> libc::c_int { - let mut server = 0 as *mut libc::c_char; - let mut output_device = b"default\x00" as *const u8 as *const libc::c_char as *mut libc::c_char; - let mut include_codecs = 0 as *mut libc::c_char; - let mut exclude_codecs = b"\x00" as *const u8 as *const libc::c_char as *mut libc::c_char; - let mut name = 0 as *mut libc::c_char; - let mut namefile = 0 as *mut libc::c_char; - let mut modelname = 0 as *mut libc::c_char; +#[cross_check(entry(djb2="main"), exit(djb2="main"))] +unsafe fn main_0(mut argc: libc::c_int, mut argv: *mut *mut libc::c_char) + -> libc::c_int { + let mut server: *mut libc::c_char = 0 as *mut libc::c_char; + let mut output_device: *mut libc::c_char = + b"default\x00" as *const u8 as *const libc::c_char as + *mut libc::c_char; + let mut include_codecs: *mut libc::c_char = 0 as *mut libc::c_char; + let mut exclude_codecs: *mut libc::c_char = + b"\x00" as *const u8 as *const libc::c_char as *mut libc::c_char; + let mut name: *mut libc::c_char = 0 as *mut libc::c_char; + let mut namefile: *mut libc::c_char = 0 as *mut libc::c_char; + let mut modelname: *mut libc::c_char = 0 as *mut libc::c_char; extern "C" { #[no_mangle] - pub static mut pcm_check_header: bool; + static mut pcm_check_header: bool; } extern "C" { #[no_mangle] - pub static mut user_rates: bool; + static mut user_rates: bool; } - let mut logfile = 0 as *mut libc::c_char; - let mut mac: [crate::squeezelite_h::u8_t; 6] = [0; 6]; - let mut stream_buf_size = - (2 as libc::c_int * 1024 as libc::c_int * 1024 as libc::c_int) as libc::c_uint; - let mut output_buf_size = 0 as libc::c_int as libc::c_uint; - let mut rates: [libc::c_uint; 18] = [ - 0 as libc::c_int as libc::c_uint, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - ]; - let mut rate_delay = 0 as libc::c_int as libc::c_uint; - let mut resample = 0 as *mut libc::c_char; - let mut output_params = 0 as *mut libc::c_char; - let mut idle = 0 as libc::c_int as libc::c_uint; - let mut daemonize = 0 as libc::c_int != 0; - let mut pidfile = 0 as *mut libc::c_char; - let mut pidfp = 0 as *mut crate::stdlib::FILE; - let mut rt_priority = 45 as libc::c_int as libc::c_uint; - let mut mixer_device = output_device; - let mut output_mixer = 0 as *mut libc::c_char; - let mut output_mixer_unmute = 0 as libc::c_int != 0; - let mut linear_volume = 0 as libc::c_int != 0; - let mut log_output = crate::squeezelite_h::lWARN; - let mut log_stream = crate::squeezelite_h::lWARN; - let mut log_decode = crate::squeezelite_h::lWARN; - let mut log_slimproto = crate::squeezelite_h::lWARN; - let mut maxSampleRate = 0 as libc::c_int; - let mut optarg = 0 as *mut libc::c_char; - let mut optind = 1 as libc::c_int; + let mut logfile: *mut libc::c_char = 0 as *mut libc::c_char; + let mut mac: [u8_t; 6] = [0; 6]; + let mut stream_buf_size: libc::c_uint = + (2 as libc::c_int * 1024 as libc::c_int * 1024 as libc::c_int) as + libc::c_uint; + let mut output_buf_size: libc::c_uint = 0 as libc::c_int as libc::c_uint; + let mut rates: [libc::c_uint; 18] = + [0 as libc::c_int as libc::c_uint, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0]; + let mut rate_delay: libc::c_uint = 0 as libc::c_int as libc::c_uint; + let mut resample: *mut libc::c_char = 0 as *mut libc::c_char; + let mut output_params: *mut libc::c_char = 0 as *mut libc::c_char; + let mut idle: libc::c_uint = 0 as libc::c_int as libc::c_uint; + let mut daemonize: bool = 0 as libc::c_int != 0; + let mut pidfile: *mut libc::c_char = 0 as *mut libc::c_char; + let mut pidfp: *mut FILE = 0 as *mut FILE; + let mut rt_priority: libc::c_uint = 45 as libc::c_int as libc::c_uint; + let mut mixer_device: *mut libc::c_char = output_device; + let mut output_mixer: *mut libc::c_char = 0 as *mut libc::c_char; + let mut output_mixer_unmute: bool = 0 as libc::c_int != 0; + let mut linear_volume: bool = 0 as libc::c_int != 0; + let mut log_output: log_level = lWARN; + let mut log_stream: log_level = lWARN; + let mut log_decode: log_level = lWARN; + let mut log_slimproto: log_level = lWARN; + let mut maxSampleRate: libc::c_int = 0 as libc::c_int; + let mut optarg: *mut libc::c_char = 0 as *mut libc::c_char; + let mut optind: libc::c_int = 1 as libc::c_int; let mut i: libc::c_int = 0; let mut cmdline: [libc::c_char; 512] = *::std::mem::transmute::<&[u8; 512], &mut [libc::c_char; 512]>(b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"); - crate::squeezelite_h::get_mac(mac.as_mut_ptr()); + get_mac(mac.as_mut_ptr()); i = 0 as libc::c_int; - while i < argc - && crate::stdlib::strlen(*argv.offset(i as isize)) - .wrapping_add(crate::stdlib::strlen(cmdline.as_mut_ptr())) - .wrapping_add(2 as libc::c_int as libc::c_ulong) - < 512 as libc::c_int as libc::c_ulong - { - crate::stdlib::strcat(cmdline.as_mut_ptr(), *argv.offset(i as isize)); - crate::stdlib::strcat( - cmdline.as_mut_ptr(), - b" \x00" as *const u8 as *const libc::c_char, - ); + while i < argc && + strlen(*argv.offset(i as + isize)).wrapping_add(strlen(cmdline.as_mut_ptr())).wrapping_add(2 + as + libc::c_int + as + libc::c_ulong) + < 512 as libc::c_int as libc::c_ulong { + strcat(cmdline.as_mut_ptr(), *argv.offset(i as isize)); + strcat(cmdline.as_mut_ptr(), + b" \x00" as *const u8 as *const libc::c_char); i += 1 } - while optind < argc - && crate::stdlib::strlen(*argv.offset(optind as isize)) >= 2 as libc::c_int as libc::c_ulong - && *(*argv.offset(optind as isize)).offset(0 as libc::c_int as isize) as libc::c_int - == '-' as i32 - { - let mut opt = (*argv.offset(optind as isize)).offset(1 as libc::c_int as isize); - if !crate::stdlib::strstr( - b"oabcCdefmMnNpPrsUVO\x00" as *const u8 as *const libc::c_char, - opt, - ) - .is_null() - && optind < argc - 1 as libc::c_int - { + while optind < argc && + strlen(*argv.offset(optind as isize)) >= + 2 as libc::c_int as libc::c_ulong && + *(*argv.offset(optind as + isize)).offset(0 as libc::c_int as isize) as + libc::c_int == '-' as i32 { + let mut opt: *mut libc::c_char = + (*argv.offset(optind as isize)).offset(1 as libc::c_int as isize); + if !strstr(b"oabcCdefmMnNpPrsUVO\x00" as *const u8 as + *const libc::c_char, opt).is_null() && + optind < argc - 1 as libc::c_int { optarg = *argv.offset((optind + 1 as libc::c_int) as isize); optind += 2 as libc::c_int - } else if !crate::stdlib::strstr(b"ltz?WLX\x00" as *const u8 as *const libc::c_char, opt) - .is_null() - { + } else if !strstr(b"ltz?WLX\x00" as *const u8 as *const libc::c_char, + opt).is_null() { optarg = 0 as *mut libc::c_char; optind += 1 as libc::c_int } else { - crate::stdlib::fprintf( - crate::stdlib::stderr, - b"\nOption error: -%s\n\n\x00" as *const u8 as *const libc::c_char, - opt, - ); + fprintf(stderr, + b"\nOption error: -%s\n\n\x00" as *const u8 as + *const libc::c_char, opt); usage(*argv.offset(0 as libc::c_int as isize)); - crate::stdlib::exit(1 as libc::c_int); + exit(1 as libc::c_int); } let mut current_block_129: u64; match *opt.offset(0 as libc::c_int as isize) as libc::c_int { @@ -465,16 +347,18 @@ unsafe fn main_0(mut argc: libc::c_int, mut argv: *mut *mut libc::c_char) -> lib current_block_129 = 10517665100358322178; } 98 => { - let mut s = crate::squeezelite_h::next_param(optarg, ':' as i32 as libc::c_char); - let mut o = crate::squeezelite_h::next_param( - 0 as *mut libc::c_char, - ':' as i32 as libc::c_char, - ); + let mut s: *mut libc::c_char = + next_param(optarg, ':' as i32 as libc::c_char); + let mut o: *mut libc::c_char = + next_param(0 as *mut libc::c_char, + ':' as i32 as libc::c_char); if !s.is_null() { - stream_buf_size = (crate::stdlib::atoi(s) * 1024 as libc::c_int) as libc::c_uint + stream_buf_size = + (atoi(s) * 1024 as libc::c_int) as libc::c_uint } if !o.is_null() { - output_buf_size = (crate::stdlib::atoi(o) * 1024 as libc::c_int) as libc::c_uint + output_buf_size = + (atoi(o) * 1024 as libc::c_int) as libc::c_uint } current_block_129 = 10517665100358322178; } @@ -483,8 +367,9 @@ unsafe fn main_0(mut argc: libc::c_int, mut argv: *mut *mut libc::c_char) -> lib current_block_129 = 10517665100358322178; } 67 => { - if crate::stdlib::atoi(optarg) > 0 as libc::c_int { - idle = (crate::stdlib::atoi(optarg) * 1000 as libc::c_int) as libc::c_uint + if atoi(optarg) > 0 as libc::c_int { + idle = + (atoi(optarg) * 1000 as libc::c_int) as libc::c_uint } current_block_129 = 10517665100358322178; } @@ -493,70 +378,67 @@ unsafe fn main_0(mut argc: libc::c_int, mut argv: *mut *mut libc::c_char) -> lib current_block_129 = 10517665100358322178; } 100 => { - let mut l = - crate::stdlib::strtok(optarg, b"=\x00" as *const u8 as *const libc::c_char); - let mut v = crate::stdlib::strtok( - 0 as *mut libc::c_char, - b"=\x00" as *const u8 as *const libc::c_char, - ); - let mut new = crate::squeezelite_h::lWARN; + let mut l: *mut libc::c_char = + strtok(optarg, + b"=\x00" as *const u8 as *const libc::c_char); + let mut v: *mut libc::c_char = + strtok(0 as *mut libc::c_char, + b"=\x00" as *const u8 as *const libc::c_char); + let mut new: log_level = lWARN; if !l.is_null() && !v.is_null() { - if crate::stdlib::strcmp(v, b"info\x00" as *const u8 as *const libc::c_char) - == 0 - { - new = crate::squeezelite_h::lINFO + if strcmp(v, + b"info\x00" as *const u8 as *const libc::c_char) + == 0 { + new = lINFO } - if crate::stdlib::strcmp(v, b"debug\x00" as *const u8 as *const libc::c_char) - == 0 - { - new = crate::squeezelite_h::lDEBUG + if strcmp(v, + b"debug\x00" as *const u8 as + *const libc::c_char) == 0 { + new = lDEBUG } - if crate::stdlib::strcmp(v, b"sdebug\x00" as *const u8 as *const libc::c_char) - == 0 - { - new = crate::squeezelite_h::lSDEBUG + if strcmp(v, + b"sdebug\x00" as *const u8 as + *const libc::c_char) == 0 { + new = lSDEBUG } - if crate::stdlib::strcmp(l, b"all\x00" as *const u8 as *const libc::c_char) == 0 - || crate::stdlib::strcmp( - l, - b"slimproto\x00" as *const u8 as *const libc::c_char, - ) == 0 - { + if strcmp(l, + b"all\x00" as *const u8 as *const libc::c_char) + == 0 || + strcmp(l, + b"slimproto\x00" as *const u8 as + *const libc::c_char) == 0 { log_slimproto = new } - if crate::stdlib::strcmp(l, b"all\x00" as *const u8 as *const libc::c_char) == 0 - || crate::stdlib::strcmp( - l, - b"stream\x00" as *const u8 as *const libc::c_char, - ) == 0 - { + if strcmp(l, + b"all\x00" as *const u8 as *const libc::c_char) + == 0 || + strcmp(l, + b"stream\x00" as *const u8 as + *const libc::c_char) == 0 { log_stream = new } - if crate::stdlib::strcmp(l, b"all\x00" as *const u8 as *const libc::c_char) == 0 - || crate::stdlib::strcmp( - l, - b"decode\x00" as *const u8 as *const libc::c_char, - ) == 0 - { + if strcmp(l, + b"all\x00" as *const u8 as *const libc::c_char) + == 0 || + strcmp(l, + b"decode\x00" as *const u8 as + *const libc::c_char) == 0 { log_decode = new } - if crate::stdlib::strcmp(l, b"all\x00" as *const u8 as *const libc::c_char) == 0 - || crate::stdlib::strcmp( - l, - b"output\x00" as *const u8 as *const libc::c_char, - ) == 0 - { + if strcmp(l, + b"all\x00" as *const u8 as *const libc::c_char) + == 0 || + strcmp(l, + b"output\x00" as *const u8 as + *const libc::c_char) == 0 { log_output = new } } else { - crate::stdlib::fprintf( - crate::stdlib::stderr, - b"\nDebug settings error: -d %s\n\n\x00" as *const u8 - as *const libc::c_char, - optarg, - ); + fprintf(stderr, + b"\nDebug settings error: -d %s\n\n\x00" as + *const u8 as *const libc::c_char, optarg); usage(*argv.offset(0 as libc::c_int as isize)); - crate::stdlib::exit(1 as libc::c_int); + exit(1 as libc::c_int); } current_block_129 = 10517665100358322178; } @@ -565,33 +447,31 @@ unsafe fn main_0(mut argc: libc::c_int, mut argv: *mut *mut libc::c_char) -> lib current_block_129 = 10517665100358322178; } 109 => { - let mut byte = 0 as libc::c_int; - let mut tmp = 0 as *mut libc::c_char; - if crate::stdlib::strncmp( - optarg, - b"00:04:20\x00" as *const u8 as *const libc::c_char, - 8 as libc::c_int as libc::c_ulong, - ) == 0 - { - crate::squeezelite_h::logprint(b"%s %s:%d ignoring mac address from hardware player range 00:04:20:**:**:**\n\x00" + let mut byte: libc::c_int = 0 as libc::c_int; + let mut tmp: *mut libc::c_char = 0 as *mut libc::c_char; + if strncmp(optarg, + b"00:04:20\x00" as *const u8 as + *const libc::c_char, + 8 as libc::c_int as libc::c_ulong) == 0 { + logprint(b"%s %s:%d ignoring mac address from hardware player range 00:04:20:**:**:**\n\x00" as *const u8 as *const libc::c_char, - crate::squeezelite_h::logtime(), + logtime(), (*::std::mem::transmute::<&[u8; 5], &[libc::c_char; 5]>(b"main\x00")).as_ptr(), 453 as libc::c_int); } else { - let mut t = - crate::stdlib::strtok(optarg, b":\x00" as *const u8 as *const libc::c_char); + let mut t: *mut libc::c_char = + strtok(optarg, + b":\x00" as *const u8 as *const libc::c_char); while !t.is_null() && byte < 6 as libc::c_int { let fresh0 = byte; byte = byte + 1; mac[fresh0 as usize] = - crate::stdlib::strtoul(t, &mut tmp, 16 as libc::c_int) - as crate::squeezelite_h::u8_t; - t = crate::stdlib::strtok( - 0 as *mut libc::c_char, - b":\x00" as *const u8 as *const libc::c_char, - ) + strtoul(t, &mut tmp, 16 as libc::c_int) as u8_t; + t = + strtok(0 as *mut libc::c_char, + b":\x00" as *const u8 as + *const libc::c_char) } } current_block_129 = 10517665100358322178; @@ -601,57 +481,39 @@ unsafe fn main_0(mut argc: libc::c_int, mut argv: *mut *mut libc::c_char) -> lib current_block_129 = 10517665100358322178; } 114 => { - let mut rstr = crate::squeezelite_h::next_param(optarg, ':' as i32 as libc::c_char); - let mut dstr = crate::squeezelite_h::next_param( - 0 as *mut libc::c_char, - ':' as i32 as libc::c_char, - ); - if !rstr.is_null() - && !crate::stdlib::strstr(rstr, b",\x00" as *const u8 as *const libc::c_char) - .is_null() - { + let mut rstr: *mut libc::c_char = + next_param(optarg, ':' as i32 as libc::c_char); + let mut dstr: *mut libc::c_char = + next_param(0 as *mut libc::c_char, + ':' as i32 as libc::c_char); + if !rstr.is_null() && + !strstr(rstr, + b",\x00" as *const u8 as + *const libc::c_char).is_null() { // parse sample rates and sort them - let mut r = crate::squeezelite_h::next_param(rstr, ',' as i32 as libc::c_char); - let mut tmp_0: [libc::c_uint; 18] = [ - 0 as libc::c_int as libc::c_uint, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - ]; + let mut r: *mut libc::c_char = + next_param(rstr, ',' as i32 as libc::c_char); + let mut tmp_0: [libc::c_uint; 18] = + [0 as libc::c_int as libc::c_uint, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; let mut i_0: libc::c_int = 0; let mut j: libc::c_int = 0; - let mut last = 999999 as libc::c_int; + let mut last: libc::c_int = 999999 as libc::c_int; i_0 = 0 as libc::c_int; while !r.is_null() && i_0 < 18 as libc::c_int { - tmp_0[i_0 as usize] = crate::stdlib::atoi(r) as libc::c_uint; - r = crate::squeezelite_h::next_param( - 0 as *mut libc::c_char, - ',' as i32 as libc::c_char, - ); + tmp_0[i_0 as usize] = atoi(r) as libc::c_uint; + r = + next_param(0 as *mut libc::c_char, + ',' as i32 as libc::c_char); i_0 += 1 } i_0 = 0 as libc::c_int; while i_0 < 18 as libc::c_int { - let mut largest = 0 as libc::c_int; + let mut largest: libc::c_int = 0 as libc::c_int; j = 0 as libc::c_int; while j < 18 as libc::c_int { - if tmp_0[j as usize] > largest as libc::c_uint - && tmp_0[j as usize] < last as libc::c_uint - { + if tmp_0[j as usize] > largest as libc::c_uint && + tmp_0[j as usize] < last as libc::c_uint { largest = tmp_0[j as usize] as libc::c_int } j += 1 @@ -662,59 +524,51 @@ unsafe fn main_0(mut argc: libc::c_int, mut argv: *mut *mut libc::c_char) -> lib } } else if !rstr.is_null() { // optstr is - or , extract rates from test rates within this range - let mut ref_0: [libc::c_uint; 18] = [ - 768000 as libc::c_int as libc::c_uint, - 705600 as libc::c_int as libc::c_uint, - 384000 as libc::c_int as libc::c_uint, - 352800 as libc::c_int as libc::c_uint, - 192000 as libc::c_int as libc::c_uint, - 176400 as libc::c_int as libc::c_uint, - 96000 as libc::c_int as libc::c_uint, - 88200 as libc::c_int as libc::c_uint, - 48000 as libc::c_int as libc::c_uint, - 44100 as libc::c_int as libc::c_uint, - 32000 as libc::c_int as libc::c_uint, - 24000 as libc::c_int as libc::c_uint, - 22500 as libc::c_int as libc::c_uint, - 16000 as libc::c_int as libc::c_uint, - 12000 as libc::c_int as libc::c_uint, - 11025 as libc::c_int as libc::c_uint, - 8000 as libc::c_int as libc::c_uint, - 0 as libc::c_int as libc::c_uint, - ]; - let mut str1 = - crate::squeezelite_h::next_param(rstr, '-' as i32 as libc::c_char); - let mut str2 = crate::squeezelite_h::next_param( - 0 as *mut libc::c_char, - '-' as i32 as libc::c_char, - ); - let mut max = if !str2.is_null() { - crate::stdlib::atoi(str2) as libc::c_uint - } else if !str1.is_null() { - crate::stdlib::atoi(str1) as libc::c_uint - } else { - ref_0[0 as libc::c_int as usize] - }; - let mut min = if !str1.is_null() && !str2.is_null() { - crate::stdlib::atoi(str1) - } else { - 0 as libc::c_int - } as libc::c_uint; + let mut ref_0: [libc::c_uint; 18] = + [768000 as libc::c_int as libc::c_uint, + 705600 as libc::c_int as libc::c_uint, + 384000 as libc::c_int as libc::c_uint, + 352800 as libc::c_int as libc::c_uint, + 192000 as libc::c_int as libc::c_uint, + 176400 as libc::c_int as libc::c_uint, + 96000 as libc::c_int as libc::c_uint, + 88200 as libc::c_int as libc::c_uint, + 48000 as libc::c_int as libc::c_uint, + 44100 as libc::c_int as libc::c_uint, + 32000 as libc::c_int as libc::c_uint, + 24000 as libc::c_int as libc::c_uint, + 22500 as libc::c_int as libc::c_uint, + 16000 as libc::c_int as libc::c_uint, + 12000 as libc::c_int as libc::c_uint, + 11025 as libc::c_int as libc::c_uint, + 8000 as libc::c_int as libc::c_uint, + 0 as libc::c_int as libc::c_uint]; + let mut str1: *mut libc::c_char = + next_param(rstr, '-' as i32 as libc::c_char); + let mut str2: *mut libc::c_char = + next_param(0 as *mut libc::c_char, + '-' as i32 as libc::c_char); + let mut max: libc::c_uint = + if !str2.is_null() { + atoi(str2) as libc::c_uint + } else if !str1.is_null() { + atoi(str1) as libc::c_uint + } else { ref_0[0 as libc::c_int as usize] }; + let mut min: libc::c_uint = + if !str1.is_null() && !str2.is_null() { + atoi(str1) + } else { 0 as libc::c_int } as libc::c_uint; let mut tmp_1: libc::c_uint = 0; let mut i_1: libc::c_int = 0; let mut j_0: libc::c_int = 0; - if max < min { - tmp_1 = max; - max = min; - min = tmp_1 - } + if max < min { tmp_1 = max; max = min; min = tmp_1 } rates[0 as libc::c_int as usize] = max; i_1 = 0 as libc::c_int; j_0 = 1 as libc::c_int; while i_1 < 18 as libc::c_int { - if ref_0[i_1 as usize] < rates[(j_0 - 1 as libc::c_int) as usize] - && ref_0[i_1 as usize] >= min - { + if ref_0[i_1 as usize] < + rates[(j_0 - 1 as libc::c_int) as usize] && + ref_0[i_1 as usize] >= min { let fresh1 = j_0; j_0 = j_0 + 1; rates[fresh1 as usize] = ref_0[i_1 as usize] @@ -722,9 +576,7 @@ unsafe fn main_0(mut argc: libc::c_int, mut argv: *mut *mut libc::c_char) -> lib i_1 += 1 } } - if !dstr.is_null() { - rate_delay = crate::stdlib::atoi(dstr) as libc::c_uint - } + if !dstr.is_null() { rate_delay = atoi(dstr) as libc::c_uint } if rates[0 as libc::c_int as usize] != 0 { user_rates = 1 as libc::c_int != 0 } @@ -747,18 +599,14 @@ unsafe fn main_0(mut argc: libc::c_int, mut argv: *mut *mut libc::c_char) -> lib current_block_129 = 10517665100358322178; } 112 => { - rt_priority = crate::stdlib::atoi(optarg) as libc::c_uint; - if rt_priority > 99 as libc::c_int as libc::c_uint - || rt_priority < 1 as libc::c_int as libc::c_uint - { - crate::stdlib::fprintf( - crate::stdlib::stderr, - b"\nError: invalid priority: %s\n\n\x00" as *const u8 - as *const libc::c_char, - optarg, - ); + rt_priority = atoi(optarg) as libc::c_uint; + if rt_priority > 99 as libc::c_int as libc::c_uint || + rt_priority < 1 as libc::c_int as libc::c_uint { + fprintf(stderr, + b"\nError: invalid priority: %s\n\n\x00" as + *const u8 as *const libc::c_char, optarg); usage(*argv.offset(0 as libc::c_int as isize)); - crate::stdlib::exit(1 as libc::c_int); + exit(1 as libc::c_int); } current_block_129 = 10517665100358322178; } @@ -766,99 +614,79 @@ unsafe fn main_0(mut argc: libc::c_int, mut argv: *mut *mut libc::c_char) -> lib pidfile = optarg; current_block_129 = 10517665100358322178; } - 108 => { - crate::squeezelite_h::list_devices(); - crate::stdlib::exit(0 as libc::c_int); - } + 108 => { list_devices(); exit(0 as libc::c_int); } 79 => { mixer_device = optarg; current_block_129 = 10517665100358322178; } - 76 => { - crate::squeezelite_h::list_mixers(mixer_device); - crate::stdlib::exit(0 as libc::c_int); - } + 76 => { list_mixers(mixer_device); exit(0 as libc::c_int); } 88 => { linear_volume = 1 as libc::c_int != 0; current_block_129 = 10517665100358322178; } 85 => { output_mixer_unmute = 1 as libc::c_int != 0; - current_block_129 = 17662379048890589436; - } - 86 => { - current_block_129 = 17662379048890589436; + current_block_129 = 8353035839816271260; } + 86 => { current_block_129 = 8353035839816271260; } 122 => { daemonize = 1 as libc::c_int != 0; current_block_129 = 10517665100358322178; } - 116 => { - license(); - crate::stdlib::exit(0 as libc::c_int); - } + 116 => { license(); exit(0 as libc::c_int); } 63 => { usage(*argv.offset(0 as libc::c_int as isize)); - crate::stdlib::exit(0 as libc::c_int); + exit(0 as libc::c_int); } _ => { - crate::stdlib::fprintf( - crate::stdlib::stderr, - b"Arg error: %s\n\x00" as *const u8 as *const libc::c_char, - *argv.offset(optind as isize), - ); + fprintf(stderr, + b"Arg error: %s\n\x00" as *const u8 as + *const libc::c_char, + *argv.offset(optind as isize)); current_block_129 = 10517665100358322178; } } match current_block_129 { - 17662379048890589436 => { + 8353035839816271260 => { if !output_mixer.is_null() { - crate::stdlib::fprintf( - crate::stdlib::stderr, - b"-U and -V option should not be used at same time\n\x00" as *const u8 - as *const libc::c_char, - ); - crate::stdlib::exit(1 as libc::c_int); + fprintf(stderr, + b"-U and -V option should not be used at same time\n\x00" + as *const u8 as *const libc::c_char); + exit(1 as libc::c_int); } output_mixer = optarg } - _ => {} + _ => { } } } // warn if command line includes something which isn't parsed if optind < argc { - crate::stdlib::fprintf( - crate::stdlib::stderr, - b"\nError: command line argument error\n\n\x00" as *const u8 as *const libc::c_char, - ); + fprintf(stderr, + b"\nError: command line argument error\n\n\x00" as *const u8 + as *const libc::c_char); usage(*argv.offset(0 as libc::c_int as isize)); - crate::stdlib::exit(1 as libc::c_int); + exit(1 as libc::c_int); } - crate::stdlib::signal( - 2 as libc::c_int, - Some(sighandler as unsafe extern "C" fn(_: libc::c_int) -> ()), - ); - crate::stdlib::signal( - 15 as libc::c_int, - Some(sighandler as unsafe extern "C" fn(_: libc::c_int) -> ()), - ); - crate::stdlib::signal( - 3 as libc::c_int, - Some(sighandler as unsafe extern "C" fn(_: libc::c_int) -> ()), - ); - crate::stdlib::signal( - 1 as libc::c_int, - Some(sighandler as unsafe extern "C" fn(_: libc::c_int) -> ()), - ); + signal(2 as libc::c_int, + Some(sighandler as unsafe extern "C" fn(_: libc::c_int) -> ())); + signal(15 as libc::c_int, + Some(sighandler as unsafe extern "C" fn(_: libc::c_int) -> ())); + signal(3 as libc::c_int, + Some(sighandler as unsafe extern "C" fn(_: libc::c_int) -> ())); + signal(1 as libc::c_int, + Some(sighandler as unsafe extern "C" fn(_: libc::c_int) -> ())); // set the output buffer size if not specified on the command line, take account of resampling if output_buf_size == 0 { output_buf_size = - (44100 as libc::c_int * 8 as libc::c_int * 10 as libc::c_int) as libc::c_uint; + (44100 as libc::c_int * 8 as libc::c_int * 10 as libc::c_int) as + libc::c_uint; if !resample.is_null() { - let mut scale = 8 as libc::c_int as libc::c_uint; + let mut scale: libc::c_uint = 8 as libc::c_int as libc::c_uint; if rates[0 as libc::c_int as usize] != 0 { - scale = rates[0 as libc::c_int as usize] - .wrapping_div(44100 as libc::c_int as libc::c_uint); + scale = + rates[0 as libc::c_int as + usize].wrapping_div(44100 as libc::c_int as + libc::c_uint); if scale > 8 as libc::c_int as libc::c_uint { scale = 8 as libc::c_int as libc::c_uint } @@ -870,145 +698,94 @@ unsafe fn main_0(mut argc: libc::c_int, mut argv: *mut *mut libc::c_char) -> lib } } if !logfile.is_null() { - if crate::stdlib::freopen( - logfile, - b"a\x00" as *const u8 as *const libc::c_char, - crate::stdlib::stderr, - ) - .is_null() - { - crate::stdlib::fprintf( - crate::stdlib::stderr, - b"error opening logfile %s: %s\n\x00" as *const u8 as *const libc::c_char, - logfile, - crate::stdlib::strerror(*crate::stdlib::__errno_location()), - ); - } else if log_output as libc::c_uint - >= crate::squeezelite_h::lINFO as libc::c_int as libc::c_uint - || log_stream as libc::c_uint - >= crate::squeezelite_h::lINFO as libc::c_int as libc::c_uint - || log_decode as libc::c_uint - >= crate::squeezelite_h::lINFO as libc::c_int as libc::c_uint - || log_slimproto as libc::c_uint - >= crate::squeezelite_h::lINFO as libc::c_int as libc::c_uint - { - crate::stdlib::fprintf( - crate::stdlib::stderr, - b"\n%s\n\x00" as *const u8 as *const libc::c_char, - cmdline.as_mut_ptr(), - ); + if freopen(logfile, b"a\x00" as *const u8 as *const libc::c_char, + stderr).is_null() { + fprintf(stderr, + b"error opening logfile %s: %s\n\x00" as *const u8 as + *const libc::c_char, logfile, + strerror(*__errno_location())); + } else if log_output as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint || + log_stream as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint || + log_decode as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint || + log_slimproto as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint { + fprintf(stderr, b"\n%s\n\x00" as *const u8 as *const libc::c_char, + cmdline.as_mut_ptr()); } } if !pidfile.is_null() { - pidfp = crate::stdlib::fopen(pidfile, b"w\x00" as *const u8 as *const libc::c_char); + pidfp = fopen(pidfile, b"w\x00" as *const u8 as *const libc::c_char); if pidfp.is_null() { - crate::stdlib::fprintf( - crate::stdlib::stderr, - b"Error opening pidfile %s: %s\n\x00" as *const u8 as *const libc::c_char, - pidfile, - crate::stdlib::strerror(*crate::stdlib::__errno_location()), - ); - crate::stdlib::exit(1 as libc::c_int); + fprintf(stderr, + b"Error opening pidfile %s: %s\n\x00" as *const u8 as + *const libc::c_char, pidfile, + strerror(*__errno_location())); + exit(1 as libc::c_int); } - pidfile = crate::stdlib::realpath(pidfile, 0 as *mut libc::c_char) + pidfile = realpath(pidfile, 0 as *mut libc::c_char) // daemonize will change cwd } if daemonize { - if crate::stdlib::daemon( - 0 as libc::c_int, - if !logfile.is_null() { - 1 as libc::c_int - } else { - 0 as libc::c_int - }, - ) != 0 - { - crate::stdlib::fprintf( - crate::stdlib::stderr, - b"error daemonizing: %s\n\x00" as *const u8 as *const libc::c_char, - crate::stdlib::strerror(*crate::stdlib::__errno_location()), - ); + if daemon(0 as libc::c_int, + if !logfile.is_null() { + 1 as libc::c_int + } else { 0 as libc::c_int }) != 0 { + fprintf(stderr, + b"error daemonizing: %s\n\x00" as *const u8 as + *const libc::c_char, strerror(*__errno_location())); } } if !pidfp.is_null() { - crate::stdlib::fprintf( - pidfp, - b"%d\n\x00" as *const u8 as *const libc::c_char, - crate::stdlib::getpid(), - ); - crate::stdlib::fclose(pidfp); + fprintf(pidfp, b"%d\n\x00" as *const u8 as *const libc::c_char, + getpid()); + fclose(pidfp); } - crate::squeezelite_h::stream_init(log_stream, stream_buf_size); - if crate::stdlib::strcmp(output_device, b"-\x00" as *const u8 as *const libc::c_char) == 0 { - crate::squeezelite_h::output_init_stdout( - log_output, - output_buf_size, - output_params, - rates.as_mut_ptr(), - rate_delay, - ); + stream_init(log_stream, stream_buf_size); + if strcmp(output_device, b"-\x00" as *const u8 as *const libc::c_char) == + 0 { + output_init_stdout(log_output, output_buf_size, output_params, + rates.as_mut_ptr(), rate_delay); } else { - crate::squeezelite_h::output_init_alsa( - log_output, - output_device, - output_buf_size, - output_params, - rates.as_mut_ptr(), - rate_delay, - rt_priority, - idle, - mixer_device, - output_mixer, - output_mixer_unmute, - linear_volume, - ); + output_init_alsa(log_output, output_device, output_buf_size, + output_params, rates.as_mut_ptr(), rate_delay, + rt_priority, idle, mixer_device, output_mixer, + output_mixer_unmute, linear_volume); } - crate::squeezelite_h::decode_init(log_decode, include_codecs, exclude_codecs); + decode_init(log_decode, include_codecs, exclude_codecs); if !name.is_null() && !namefile.is_null() { - crate::stdlib::fprintf( - crate::stdlib::stderr, - b"-n and -N option should not be used at same time\n\x00" as *const u8 - as *const libc::c_char, - ); - crate::stdlib::exit(1 as libc::c_int); - } - crate::squeezelite_h::slimproto( - log_slimproto, - server, - mac.as_mut_ptr(), - name, - namefile, - modelname, - maxSampleRate, - ); - crate::squeezelite_h::decode_close(); - crate::squeezelite_h::stream_close(); - if crate::stdlib::strcmp(output_device, b"-\x00" as *const u8 as *const libc::c_char) == 0 { - crate::squeezelite_h::output_close_stdout(); - } else { - crate::squeezelite_h::output_close_alsa(); + fprintf(stderr, + b"-n and -N option should not be used at same time\n\x00" as + *const u8 as *const libc::c_char); + exit(1 as libc::c_int); } + slimproto(log_slimproto, server, mac.as_mut_ptr(), name, namefile, + modelname, maxSampleRate); + decode_close(); + stream_close(); + if strcmp(output_device, b"-\x00" as *const u8 as *const libc::c_char) == + 0 { + output_close_stdout(); + } else { output_close_alsa(); } if !pidfile.is_null() { - crate::stdlib::unlink(pidfile); - crate::stdlib::free(pidfile as *mut libc::c_void); + unlink(pidfile); + free(pidfile as *mut libc::c_void); } - crate::stdlib::exit(0 as libc::c_int); + exit(0 as libc::c_int); } +#[cross_check(none)] #[main] pub fn main() { let mut args: Vec<*mut libc::c_char> = Vec::new(); for arg in ::std::env::args() { - args.push( - ::std::ffi::CString::new(arg) - .expect("Failed to convert argument into CString.") - .into_raw(), - ); - } + args.push(::std::ffi::CString::new(arg).expect("Failed to convert argument into CString.").into_raw()); + }; args.push(::std::ptr::null_mut()); unsafe { - ::std::process::exit(main_0( - (args.len() - 1) as libc::c_int, - args.as_mut_ptr() as *mut *mut libc::c_char, - ) as i32) + ::std::process::exit(main_0((args.len() - 1) as libc::c_int, + args.as_mut_ptr() as + *mut *mut libc::c_char) as i32) } } diff --git a/src/mpg.rs b/src/mpg.rs index 5fe1a00..e96b23e 100644 --- a/src/mpg.rs +++ b/src/mpg.rs @@ -1,646 +1,752 @@ 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" { + pub type mpg123_handle_struct; #[no_mangle] - pub static mut loglevel: crate::squeezelite_h::log_level; + fn malloc(_: libc::c_ulong) -> *mut libc::c_void; #[no_mangle] - pub static mut streambuf: *mut crate::squeezelite_h::buffer; + fn _checkfade(_: bool); #[no_mangle] - pub static mut outputbuf: *mut crate::squeezelite_h::buffer; + fn dlopen(__file: *const libc::c_char, __mode: libc::c_int) + -> *mut libc::c_void; #[no_mangle] - pub static mut stream: crate::squeezelite_h::streamstate; + fn dlsym(__handle: *mut libc::c_void, __name: *const libc::c_char) + -> *mut libc::c_void; #[no_mangle] - pub static mut output: crate::squeezelite_h::outputstate; + fn dlerror() -> *mut libc::c_char; #[no_mangle] - pub static mut decode: crate::squeezelite_h::decodestate; + fn pthread_mutex_lock(__mutex: *mut pthread_mutex_t) -> libc::c_int; + #[no_mangle] + fn pthread_mutex_unlock(__mutex: *mut pthread_mutex_t) -> libc::c_int; + #[no_mangle] + fn logtime() -> *const libc::c_char; + #[no_mangle] + fn logprint(fmt: *const libc::c_char, _: ...); + #[no_mangle] + fn _buf_used(buf: *mut buffer) -> libc::c_uint; + #[no_mangle] + fn _buf_space(buf: *mut buffer) -> libc::c_uint; + #[no_mangle] + fn _buf_cont_read(buf: *mut buffer) -> libc::c_uint; + #[no_mangle] + fn _buf_cont_write(buf: *mut buffer) -> libc::c_uint; + #[no_mangle] + fn _buf_inc_readp(buf: *mut buffer, by: libc::c_uint); + #[no_mangle] + fn _buf_inc_writep(buf: *mut buffer, by: libc::c_uint); + #[no_mangle] + fn decode_newstream(sample_rate: libc::c_uint, + supported_rates: *mut libc::c_uint) -> libc::c_uint; + #[no_mangle] + static mut loglevel: log_level; + #[no_mangle] + static mut streambuf: *mut buffer; + #[no_mangle] + static mut outputbuf: *mut buffer; + #[no_mangle] + static mut stream: streamstate; + #[no_mangle] + static mut output: outputstate; + #[no_mangle] + static mut decode: decodestate; } - -#[repr(C)] +pub type size_t = libc::c_ulong; +pub type __uint8_t = libc::c_uchar; +pub type __int16_t = libc::c_short; +pub type __int32_t = libc::c_int; +pub type __uint32_t = libc::c_uint; +pub type __uint64_t = libc::c_ulong; +pub type int16_t = __int16_t; +pub type int32_t = __int32_t; +pub type u_int8_t = __uint8_t; +pub type u_int32_t = __uint32_t; +pub type u_int64_t = __uint64_t; #[derive(Copy, Clone)] +#[repr(C)] +pub struct __pthread_internal_list { + pub __prev: *mut __pthread_internal_list, + pub __next: *mut __pthread_internal_list, +} +pub type __pthread_list_t = __pthread_internal_list; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct __pthread_mutex_s { + pub __lock: libc::c_int, + pub __count: libc::c_uint, + pub __owner: libc::c_int, + pub __nusers: libc::c_uint, + pub __kind: libc::c_int, + pub __spins: libc::c_short, + pub __elision: libc::c_short, + pub __list: __pthread_list_t, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub union pthread_mutex_t { + pub __data: __pthread_mutex_s, + pub __size: [libc::c_char; 40], + pub __align: libc::c_long, +} +pub type u8_t = u_int8_t; +pub type u32_t = u_int32_t; +pub type u64_t = u_int64_t; +pub type s16_t = int16_t; +pub type s32_t = int32_t; +pub type frames_t = u32_t; +pub type log_level = libc::c_uint; +pub const lSDEBUG: log_level = 4; +pub const lDEBUG: log_level = 3; +pub const lINFO: log_level = 2; +pub const lWARN: log_level = 1; +pub const lERROR: log_level = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct buffer { + pub buf: *mut u8_t, + pub readp: *mut u8_t, + pub writep: *mut u8_t, + pub wrap: *mut u8_t, + pub size: size_t, + pub base_size: size_t, + pub mutex: pthread_mutex_t, +} +pub type stream_state = libc::c_uint; +pub const RECV_HEADERS: stream_state = 7; +pub const SEND_HEADERS: stream_state = 6; +pub const STREAMING_HTTP: stream_state = 5; +pub const STREAMING_FILE: stream_state = 4; +pub const STREAMING_BUFFERING: stream_state = 3; +pub const STREAMING_WAIT: stream_state = 2; +pub const DISCONNECT: stream_state = 1; +pub const STOPPED: stream_state = 0; +pub type disconnect_code = libc::c_uint; +pub const TIMEOUT: disconnect_code = 4; +pub const UNREACHABLE: disconnect_code = 3; +pub const REMOTE_DISCONNECT: disconnect_code = 2; +pub const LOCAL_DISCONNECT: disconnect_code = 1; +pub const DISCONNECT_OK: disconnect_code = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct streamstate { + pub state: stream_state, + pub disconnect: disconnect_code, + pub header: *mut libc::c_char, + pub header_len: size_t, + pub sent_headers: bool, + pub cont_wait: bool, + pub bytes: u64_t, + pub threshold: libc::c_uint, + pub meta_interval: u32_t, + pub meta_next: u32_t, + pub meta_left: u32_t, + pub meta_send: bool, +} +pub type decode_state = libc::c_uint; +pub const DECODE_ERROR: decode_state = 4; +pub const DECODE_COMPLETE: decode_state = 3; +pub const DECODE_RUNNING: decode_state = 2; +pub const DECODE_READY: decode_state = 1; +pub const DECODE_STOPPED: decode_state = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct decodestate { + pub state: decode_state, + pub new_stream: bool, + pub mutex: pthread_mutex_t, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct codec { + pub id: libc::c_char, + pub types: *mut libc::c_char, + pub min_read_bytes: libc::c_uint, + pub min_space: libc::c_uint, + pub open: Option ()>, + pub close: Option ()>, + pub decode: Option decode_state>, +} +pub type output_state = libc::c_int; +pub const OUTPUT_START_AT: output_state = 5; +pub const OUTPUT_SKIP_FRAMES: output_state = 4; +pub const OUTPUT_PAUSE_FRAMES: output_state = 3; +pub const OUTPUT_RUNNING: output_state = 2; +pub const OUTPUT_BUFFER: output_state = 1; +pub const OUTPUT_STOPPED: output_state = 0; +pub const OUTPUT_OFF: output_state = -1; +pub type output_format = libc::c_uint; +pub const S16_LE: output_format = 3; +pub const S24_3LE: output_format = 2; +pub const S24_LE: output_format = 1; +pub const S32_LE: output_format = 0; +pub type fade_state = libc::c_uint; +pub const FADE_ACTIVE: fade_state = 2; +pub const FADE_DUE: fade_state = 1; +pub const FADE_INACTIVE: fade_state = 0; +pub type fade_dir = libc::c_uint; +pub const FADE_CROSS: fade_dir = 3; +pub const FADE_DOWN: fade_dir = 2; +pub const FADE_UP: fade_dir = 1; +pub type fade_mode = libc::c_uint; +pub const FADE_INOUT: fade_mode = 4; +pub const FADE_OUT: fade_mode = 3; +pub const FADE_IN: fade_mode = 2; +pub const FADE_CROSSFADE: fade_mode = 1; +pub const FADE_NONE: fade_mode = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct outputstate { + pub state: output_state, + pub format: output_format, + pub device: *const libc::c_char, + pub buffer: libc::c_uint, + pub period: libc::c_uint, + pub track_started: bool, + pub write_cb: Option libc::c_int>, + pub start_frames: libc::c_uint, + pub frames_played: libc::c_uint, + pub frames_played_dmp: libc::c_uint, + pub current_sample_rate: libc::c_uint, + pub supported_rates: [libc::c_uint; 18], + pub default_sample_rate: libc::c_uint, + pub error_opening: bool, + pub device_frames: libc::c_uint, + pub updated: u32_t, + pub track_start_time: u32_t, + pub current_replay_gain: u32_t, + pub c2rust_unnamed: C2RustUnnamed, + pub next_sample_rate: libc::c_uint, + pub track_start: *mut u8_t, + pub gainL: u32_t, + pub gainR: u32_t, + pub invert: bool, + pub next_replay_gain: u32_t, + pub threshold: libc::c_uint, + pub fade: fade_state, + pub fade_start: *mut u8_t, + pub fade_end: *mut u8_t, + pub fade_dir: fade_dir, + pub fade_mode: fade_mode, + pub fade_secs: libc::c_uint, + pub rate_delay: libc::c_uint, + pub delay_active: bool, + pub stop_time: u32_t, + pub idle_to: u32_t, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub union C2RustUnnamed { + pub pause_frames: u32_t, + pub skip_frames: u32_t, + pub start_at: u32_t, +} +pub const MPG123_ERR: mpg123_errors = -1; +pub const MPG123_DONE: mpg123_errors = -12; +#[derive(Copy, Clone)] +#[repr(C)] pub struct mpg { - pub h: *mut crate::stdlib::mpg123_handle, + pub h: *mut mpg123_handle, pub use16bit: bool, pub mpg123_init: Option libc::c_int>, - pub mpg123_feature: - Option 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 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 ()>, - pub mpg123_open_feed: - Option 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 *const libc::c_char>, + pub mpg123_feature: Option libc::c_int>, + pub mpg123_rates: Option ()>, + pub mpg123_format_none: Option libc::c_int>, + pub mpg123_format: Option libc::c_int>, + pub mpg123_new: Option *mut mpg123_handle>, + pub mpg123_delete: Option ()>, + pub mpg123_open_feed: Option libc::c_int>, + pub mpg123_decode: Option libc::c_int>, + pub mpg123_getformat: Option libc::c_int>, + pub mpg123_plain_strerror: Option *const libc::c_char>, } - +pub type mpg123_handle = mpg123_handle_struct; +pub type mpg123_feature_set = libc::c_uint; +pub const MPG123_FEATURE_EQUALIZER: mpg123_feature_set = 14; +pub const MPG123_FEATURE_TIMEOUT_READ: mpg123_feature_set = 13; +pub const MPG123_FEATURE_PARSE_ICY: mpg123_feature_set = 12; +pub const MPG123_FEATURE_DECODE_NTOM: mpg123_feature_set = 11; +pub const MPG123_FEATURE_DECODE_DOWNSAMPLE: mpg123_feature_set = 10; +pub const MPG123_FEATURE_DECODE_ACCURATE: mpg123_feature_set = 9; +pub const MPG123_FEATURE_DECODE_LAYER3: mpg123_feature_set = 8; +pub const MPG123_FEATURE_DECODE_LAYER2: mpg123_feature_set = 7; +pub const MPG123_FEATURE_DECODE_LAYER1: mpg123_feature_set = 6; +pub const MPG123_FEATURE_PARSE_ID3V2: mpg123_feature_set = 5; +pub const MPG123_FEATURE_INDEX: mpg123_feature_set = 4; +pub const MPG123_FEATURE_OUTPUT_32BIT: mpg123_feature_set = 3; +pub const MPG123_FEATURE_OUTPUT_16BIT: mpg123_feature_set = 2; +pub const MPG123_FEATURE_OUTPUT_8BIT: mpg123_feature_set = 1; +pub const MPG123_FEATURE_ABI_UTF8OPEN: mpg123_feature_set = 0; +pub const MPG123_NEW_FORMAT: mpg123_errors = -11; +pub const MPG123_ENC_SIGNED_32: mpg123_enc_enum = 4480; +pub const MPG123_ENC_SIGNED_16: mpg123_enc_enum = 208; +pub type mpg123_enc_enum = libc::c_uint; +pub const MPG123_ENC_ANY: mpg123_enc_enum = 30719; +pub const MPG123_ENC_FLOAT_64: mpg123_enc_enum = 1024; +pub const MPG123_ENC_FLOAT_32: mpg123_enc_enum = 512; +pub const MPG123_ENC_UNSIGNED_24: mpg123_enc_enum = 24576; +pub const MPG123_ENC_SIGNED_24: mpg123_enc_enum = 20608; +pub const MPG123_ENC_UNSIGNED_32: mpg123_enc_enum = 8448; +pub const MPG123_ENC_ALAW_8: mpg123_enc_enum = 8; +pub const MPG123_ENC_ULAW_8: mpg123_enc_enum = 4; +pub const MPG123_ENC_SIGNED_8: mpg123_enc_enum = 130; +pub const MPG123_ENC_UNSIGNED_8: mpg123_enc_enum = 1; +pub const MPG123_ENC_UNSIGNED_16: mpg123_enc_enum = 96; +pub const MPG123_ENC_FLOAT: mpg123_enc_enum = 3584; +pub const MPG123_ENC_SIGNED: mpg123_enc_enum = 128; +pub const MPG123_ENC_32: mpg123_enc_enum = 256; +pub const MPG123_ENC_24: mpg123_enc_enum = 16384; +pub const MPG123_ENC_16: mpg123_enc_enum = 64; +pub const MPG123_ENC_8: mpg123_enc_enum = 15; +pub type mpg123_errors = libc::c_int; +pub const MPG123_INT_OVERFLOW: mpg123_errors = 43; +pub const MPG123_LFS_OVERFLOW: mpg123_errors = 42; +pub const MPG123_BAD_CUSTOM_IO: mpg123_errors = 41; +pub const MPG123_LSEEK_FAILED: mpg123_errors = 40; +pub const MPG123_BAD_VALUE: mpg123_errors = 39; +pub const MPG123_MISSING_FEATURE: mpg123_errors = 38; +pub const MPG123_BAD_DECODER_SETUP: mpg123_errors = 37; +pub const MPG123_INDEX_FAIL: mpg123_errors = 36; +pub const MPG123_NO_INDEX: mpg123_errors = 35; +pub const MPG123_BAD_KEY: mpg123_errors = 34; +pub const MPG123_NULL_POINTER: mpg123_errors = 33; +pub const MPG123_NO_RELSEEK: mpg123_errors = 32; +pub const MPG123_NULL_BUFFER: mpg123_errors = 31; +pub const MPG123_BAD_ALIGN: mpg123_errors = 30; +pub const MPG123_NO_8BIT: mpg123_errors = 29; +pub const MPG123_RESYNC_FAIL: mpg123_errors = 28; +pub const MPG123_OUT_OF_SYNC: mpg123_errors = 27; +pub const MPG123_BAD_INDEX_PAR: mpg123_errors = 26; +pub const MPG123_BAD_PARS: mpg123_errors = 25; +pub const MPG123_NO_READER: mpg123_errors = 24; +pub const MPG123_NO_SEEK: mpg123_errors = 23; +pub const MPG123_BAD_FILE: mpg123_errors = 22; +pub const MPG123_NO_TIMEOUT: mpg123_errors = 21; +pub const MPG123_BAD_WHENCE: mpg123_errors = 20; +pub const MPG123_NO_SEEK_FROM_END: mpg123_errors = 19; +pub const MPG123_ERR_READER: mpg123_errors = 18; +pub const MPG123_ERR_NULL: mpg123_errors = 17; +pub const MPG123_BAD_BAND: mpg123_errors = 16; +pub const MPG123_BAD_TYPES: mpg123_errors = 15; +pub const MPG123_NO_SPACE: mpg123_errors = 14; +pub const MPG123_NO_GAPLESS: mpg123_errors = 13; +pub const MPG123_BAD_RVA: mpg123_errors = 12; +pub const MPG123_NO_BUFFERS: mpg123_errors = 11; +pub const MPG123_BAD_HANDLE: mpg123_errors = 10; +pub const MPG123_BAD_DECODER: mpg123_errors = 9; +pub const MPG123_NOT_INITIALIZED: mpg123_errors = 8; +pub const MPG123_OUT_OF_MEM: mpg123_errors = 7; +pub const MPG123_BAD_BUFFER: mpg123_errors = 6; +pub const MPG123_BAD_PARAM: mpg123_errors = 5; +pub const MPG123_ERR_16TO8TABLE: mpg123_errors = 4; +pub const MPG123_BAD_RATE: mpg123_errors = 3; +pub const MPG123_BAD_CHANNEL: mpg123_errors = 2; +pub const MPG123_BAD_OUTFORMAT: mpg123_errors = 1; +pub const MPG123_OK: mpg123_errors = 0; +pub const MPG123_NEED_MORE: mpg123_errors = -10; static mut m: *mut mpg = 0 as *const mpg as *mut mpg; - -unsafe extern "C" fn mpg_decode() -> 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; +unsafe extern "C" fn mpg_decode() -> decode_state { + let mut bytes: size_t = 0; + let mut space: size_t = 0; + let mut size: size_t = 0; let mut ret: libc::c_int = 0; - let mut write_buf = 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; + let mut write_buf: *mut u8_t = 0 as *mut u8_t; + pthread_mutex_lock(&mut (*streambuf).mutex); + pthread_mutex_lock(&mut (*outputbuf).mutex); + bytes = + if _buf_used(streambuf) < _buf_cont_read(streambuf) { + _buf_used(streambuf) + } else { _buf_cont_read(streambuf) } as size_t; + space = + if _buf_space(outputbuf) < _buf_cont_write(outputbuf) { + _buf_space(outputbuf) + } else { _buf_cont_write(outputbuf) } as size_t; write_buf = (*outputbuf).writep; - bytes = if bytes < 512 as libc::c_int as libc::c_ulong { - bytes - } else { - 512 as libc::c_int as libc::c_ulong - }; - space = if space < (32 as libc::c_int * 1024 as libc::c_int) as libc::c_ulong { - space - } else { - (32 as libc::c_int * 1024 as libc::c_int) as libc::c_ulong - }; + 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) + 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 { space = 0 as libc::c_int as size_t } + ret = + (*m).mpg123_decode.expect("non-null function pointer")((*m).h, + (*streambuf).readp, + bytes, + write_buf, + space, + &mut size); + if ret == MPG123_NEW_FORMAT as libc::c_int { if decode.new_stream { let mut rate: libc::c_long = 0; let mut channels: libc::c_int = 0; let mut enc: libc::c_int = 0; - (*m).mpg123_getformat.expect("non-null function pointer")( - (*m).h, - &mut rate, - &mut channels, - &mut enc, - ); - if loglevel as libc::c_uint - >= 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, - ); + (*m).mpg123_getformat.expect("non-null function pointer")((*m).h, + &mut rate, + &mut channels, + &mut enc); + if loglevel as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d setting track_start\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 11], + &[libc::c_char; 11]>(b"mpg_decode\x00")).as_ptr(), + 125 as libc::c_int); } - output.next_sample_rate = crate::src::decode::decode_newstream( - rate as libc::c_uint, - output.supported_rates.as_mut_ptr(), - ); + output.next_sample_rate = + decode_newstream(rate as libc::c_uint, + output.supported_rates.as_mut_ptr()); output.track_start = (*outputbuf).writep; if output.fade_mode as u64 != 0 { - crate::src::output::_checkfade(1 as libc::c_int != 0); + _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, - ); + } else if loglevel as libc::c_uint >= + lWARN as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d format change mid stream - not supported\n\x00" + as *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 11], + &[libc::c_char; 11]>(b"mpg_decode\x00")).as_ptr(), + 135 as libc::c_int); } } // expand 16bit output to 32bit samples if (*m).use16bit { - let mut iptr = 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); + let mut iptr: *mut s16_t = 0 as *mut s16_t; + let mut optr: *mut s32_t = 0 as *mut s32_t; + let mut count: size_t = + size.wrapping_div(2 as libc::c_int as libc::c_ulong); size = count.wrapping_mul(4 as libc::c_int as libc::c_ulong); - iptr = (write_buf as *mut crate::squeezelite_h::s16_t).offset(count as isize); - optr = (write_buf as *mut crate::squeezelite_h::s32_t).offset(count as isize); - loop { + iptr = (write_buf as *mut s16_t).offset(count as isize); + optr = (write_buf as *mut s32_t).offset(count as isize); + loop { let fresh0 = count; count = count.wrapping_sub(1); - if !(fresh0 != 0) { - break; - } + 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), - ); + _buf_inc_readp(streambuf, bytes as libc::c_uint); + _buf_inc_writep(outputbuf, size as libc::c_uint); + pthread_mutex_unlock(&mut (*outputbuf).mutex); + if loglevel as libc::c_uint >= lSDEBUG as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d write %u frames\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 11], + &[libc::c_char; 11]>(b"mpg_decode\x00")).as_ptr(), + 163 as libc::c_int, + size.wrapping_div(8 as libc::c_int as libc::c_ulong)); } - if ret == 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, - ); + if ret == MPG123_DONE as libc::c_int || + bytes == 0 as libc::c_int as libc::c_ulong && + size == 0 as libc::c_int as libc::c_ulong && + stream.state as libc::c_uint <= + DISCONNECT as libc::c_int as libc::c_uint { + pthread_mutex_unlock(&mut (*streambuf).mutex); + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d stream complete\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 11], + &[libc::c_char; 11]>(b"mpg_decode\x00")).as_ptr(), + 167 as libc::c_int); } - return crate::squeezelite_h::DECODE_COMPLETE; + return 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, - ); + pthread_mutex_unlock(&mut (*streambuf).mutex); + if ret == MPG123_ERR as libc::c_int { + if loglevel as libc::c_uint >= lWARN as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d Error\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 11], + &[libc::c_char; 11]>(b"mpg_decode\x00")).as_ptr(), + 174 as libc::c_int); } - return crate::squeezelite_h::DECODE_COMPLETE; + return DECODE_COMPLETE } // OK and NEED_MORE keep running - return crate::squeezelite_h::DECODE_RUNNING; + return 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, -) { +unsafe extern "C" fn mpg_open(mut size: u8_t, mut rate: u8_t, mut chan: u8_t, + mut endianness: u8_t) { let mut err: libc::c_int = 0; - let mut list = 0 as *const libc::c_long; - let mut count: crate::stddef_h::size_t = 0; - let mut i: crate::stddef_h::size_t = 0; + let mut list: *const libc::c_long = 0 as *const libc::c_long; + let mut count: size_t = 0; + let mut i: size_t = 0; if !(*m).h.is_null() { (*m).mpg123_delete.expect("non-null function pointer")((*m).h); } (*m).h = - (*m).mpg123_new.expect("non-null function pointer")(0 as *const libc::c_char, &mut err); + (*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), - ); + if loglevel as libc::c_uint >= lWARN as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d new error: %s\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 9], + &[libc::c_char; 9]>(b"mpg_open\x00")).as_ptr(), + 194 as libc::c_int, + (*m).mpg123_plain_strerror.expect("non-null function pointer")(err)); } } // restrict output to 32bit or 16bit signed 2 channel based on library capability - (*m).mpg123_rates.expect("non-null function pointer")(&mut list, &mut count); + (*m).mpg123_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; + i = 0 as libc::c_int as size_t; while i < count { - (*m).mpg123_format.expect("non-null function pointer")( - (*m).h, - *list.offset(i as isize), - 2 as libc::c_int, - if (*m).use16bit as libc::c_int != 0 { - crate::stdlib::MPG123_ENC_SIGNED_16 as libc::c_int - } else { - crate::stdlib::MPG123_ENC_SIGNED_32 as libc::c_int - }, - ); + (*m).mpg123_format.expect("non-null function pointer")((*m).h, + *list.offset(i + as + isize), + 2 as + libc::c_int, + if (*m).use16bit + as + libc::c_int + != 0 { + MPG123_ENC_SIGNED_16 + as + libc::c_int + } else { + MPG123_ENC_SIGNED_32 + as + libc::c_int + }); i = i.wrapping_add(1) } err = (*m).mpg123_open_feed.expect("non-null function pointer")((*m).h); if err != 0 { - if loglevel as libc::c_uint >= 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), - ); + if loglevel as libc::c_uint >= lWARN as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d open feed error: %s\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 9], + &[libc::c_char; 9]>(b"mpg_open\x00")).as_ptr(), + 207 as libc::c_int, + (*m).mpg123_plain_strerror.expect("non-null function pointer")(err)); } }; } - unsafe extern "C" fn mpg_close() { (*m).mpg123_delete.expect("non-null function pointer")((*m).h); - (*m).h = 0 as *mut crate::stdlib::mpg123_handle; + (*m).h = 0 as *mut 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; + let mut handle: *mut libc::c_void = + dlopen(b"libmpg123.so.0\x00" as *const u8 as *const libc::c_char, + 0x2 as libc::c_int); + let mut err: *mut libc::c_char = 0 as *mut libc::c_char; if handle.is_null() { - if loglevel as libc::c_uint >= 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(), - ); + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d dlerror: %s\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 9], + &[libc::c_char; 9]>(b"load_mpg\x00")).as_ptr(), + 222 as libc::c_int, dlerror()); } - return 0 as libc::c_int != 0; + return 0 as libc::c_int != 0 } - (*m).mpg123_init = ::std::mem::transmute::< - *mut libc::c_void, - Option 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 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 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 ()>, - >(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 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 *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(); + (*m).mpg123_init = + ::std::mem::transmute::<*mut libc::c_void, + Option + libc::c_int>>(dlsym(handle, + b"mpg123_init\x00" + as + *const u8 + as + *const libc::c_char)); + (*m).mpg123_feature = + ::std::mem::transmute::<*mut libc::c_void, + Option + libc::c_int>>(dlsym(handle, + b"mpg123_feature\x00" + as + *const u8 + as + *const libc::c_char)); + (*m).mpg123_rates = + ::std::mem::transmute::<*mut libc::c_void, + Option + ()>>(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 + libc::c_int>>(dlsym(handle, + b"mpg123_format_none\x00" + as + *const u8 + as + *const libc::c_char)); + (*m).mpg123_format = + ::std::mem::transmute::<*mut libc::c_void, + Option + libc::c_int>>(dlsym(handle, + b"mpg123_format\x00" + as + *const u8 + as + *const libc::c_char)); + (*m).mpg123_new = + ::std::mem::transmute::<*mut libc::c_void, + Option + *mut mpg123_handle>>(dlsym(handle, + b"mpg123_new\x00" + as + *const u8 + as + *const libc::c_char)); + (*m).mpg123_delete = + ::std::mem::transmute::<*mut libc::c_void, + Option + ()>>(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 + libc::c_int>>(dlsym(handle, + b"mpg123_open_feed\x00" + as + *const u8 + as + *const libc::c_char)); + (*m).mpg123_decode = + ::std::mem::transmute::<*mut libc::c_void, + Option + libc::c_int>>(dlsym(handle, + b"mpg123_decode\x00" + as + *const u8 + as + *const libc::c_char)); + (*m).mpg123_getformat = + ::std::mem::transmute::<*mut libc::c_void, + Option + libc::c_int>>(dlsym(handle, + b"mpg123_getformat\x00" + as + *const u8 + as + *const libc::c_char)); + (*m).mpg123_plain_strerror = + ::std::mem::transmute::<*mut libc::c_void, + Option + *const libc::c_char>>(dlsym(handle, + b"mpg123_plain_strerror\x00" + as + *const u8 + as + *const libc::c_char)); + err = dlerror(); if !err.is_null() { - if loglevel as libc::c_uint >= 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, - ); + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d dlerror: %s\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 9], + &[libc::c_char; 9]>(b"load_mpg\x00")).as_ptr(), + 239 as libc::c_int, err); } - return 0 as libc::c_int != 0; + 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, - ); + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d loaded libmpg123.so.0\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 9], + &[libc::c_char; 9]>(b"load_mpg\x00")).as_ptr(), + 243 as libc::c_int); } return 1 as libc::c_int != 0; } -/* +/* * Squeezelite - lightweight headless squeezebox emulator * * (c) Adrian Smith 2012-2015, triode1@btinternet.com * Ralph Irving 2015-2017, ralph_irving@hotmail.com - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the @@ -691,52 +797,47 @@ unsafe extern "C" fn load_mpg() -> bool { // 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::() 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; - } +pub unsafe extern "C" fn register_mpg() -> *mut codec { + static mut ret: codec = + unsafe { + { + let mut init = + codec{id: 'm' as i32 as libc::c_char, + types: + b"mp3\x00" as *const u8 as *const libc::c_char + as *mut libc::c_char, + min_read_bytes: 512 as libc::c_int as libc::c_uint, + min_space: + (32 as libc::c_int * 1024 as libc::c_int) as + libc::c_uint, + open: + Some(mpg_open as + unsafe extern "C" fn(_: u8_t, _: u8_t, + _: u8_t, _: u8_t) + -> ()), + close: + Some(mpg_close as unsafe extern "C" fn() -> ()), + decode: + Some(mpg_decode as + unsafe extern "C" fn() + -> decode_state),}; + init + } + }; + m = malloc(::std::mem::size_of::() as libc::c_ulong) as *mut mpg; + if m.is_null() { return 0 as *mut codec } + (*m).h = 0 as *mut mpg123_handle; + if !load_mpg() { return 0 as *mut codec } (*m).mpg123_init.expect("non-null function pointer")(); - (*m).use16bit = (*m).mpg123_feature.expect("non-null function pointer")( - 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, - ); + (*m).use16bit = + (*m).mpg123_feature.expect("non-null function pointer")(MPG123_FEATURE_OUTPUT_32BIT) + != 0; + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d using mpg to decode mp3\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 13], + &[libc::c_char; 13]>(b"register_mpg\x00")).as_ptr(), + 275 as libc::c_int); } return &mut ret; } diff --git a/src/output.rs b/src/output.rs index 099636e..f275a8f 100644 --- a/src/output.rs +++ b/src/output.rs @@ -1,82 +1,188 @@ 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::__uint8_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::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::gain; -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::to_gain; -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::buffer::_buf_cont_read; -pub use crate::src::buffer::_buf_inc_readp; -pub use crate::src::buffer::_buf_resize; -pub use crate::src::buffer::buf_destroy; -pub use crate::src::buffer::buf_flush; -pub use crate::src::buffer::buf_init; -pub use crate::src::output_alsa::test_open; -pub use crate::src::slimproto::wake_controller; -pub use crate::src::utils::gettime_ms; -pub use crate::src::utils::logprint; -pub use crate::src::utils::logtime; -pub use crate::src::utils::touch_memory; -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; -use crate::stdlib::sprintf; -pub use crate::stdlib::u_int32_t; -pub use crate::stdlib::u_int8_t; - -use crate::stdlib::exit; -use crate::stdlib::free; -use crate::stdlib::malloc; -use crate::stdlib::memset; -use crate::stdlib::pthread_mutex_lock; -use crate::stdlib::pthread_mutex_unlock; -use crate::stdlib::strcat; -/* +extern "C" { + #[no_mangle] + fn sprintf(_: *mut libc::c_char, _: *const libc::c_char, _: ...) + -> libc::c_int; + #[no_mangle] + fn malloc(_: libc::c_ulong) -> *mut libc::c_void; + #[no_mangle] + fn free(__ptr: *mut libc::c_void); + #[no_mangle] + fn exit(_: libc::c_int) -> !; + #[no_mangle] + fn memset(_: *mut libc::c_void, _: libc::c_int, _: libc::c_ulong) + -> *mut libc::c_void; + #[no_mangle] + fn strcat(_: *mut libc::c_char, _: *const libc::c_char) + -> *mut libc::c_char; + #[no_mangle] + fn pthread_mutex_lock(__mutex: *mut pthread_mutex_t) -> libc::c_int; + #[no_mangle] + fn pthread_mutex_unlock(__mutex: *mut pthread_mutex_t) -> libc::c_int; + #[no_mangle] + fn logtime() -> *const libc::c_char; + #[no_mangle] + fn logprint(fmt: *const libc::c_char, _: ...); + #[no_mangle] + fn gettime_ms() -> u32_t; + #[no_mangle] + fn touch_memory(buf_0: *mut u8_t, size: size_t); + #[no_mangle] + fn _buf_used(buf_0: *mut buffer) -> libc::c_uint; + #[no_mangle] + fn _buf_cont_read(buf_0: *mut buffer) -> libc::c_uint; + #[no_mangle] + fn _buf_inc_readp(buf_0: *mut buffer, by: libc::c_uint); + #[no_mangle] + fn buf_flush(buf_0: *mut buffer); + #[no_mangle] + fn _buf_resize(buf_0: *mut buffer, size: size_t); + #[no_mangle] + fn buf_init(buf_0: *mut buffer, size: size_t); + #[no_mangle] + fn buf_destroy(buf_0: *mut buffer); + #[no_mangle] + fn wake_controller(); + #[no_mangle] + fn test_open(device: *const libc::c_char, rates: *mut libc::c_uint, + userdef_rates: bool) -> bool; + #[no_mangle] + fn gain(gain_0: s32_t, sample: s32_t) -> s32_t; + #[no_mangle] + fn to_gain(f: libc::c_float) -> s32_t; +} +pub type size_t = libc::c_ulong; +pub type __uint8_t = libc::c_uchar; +pub type __int32_t = libc::c_int; +pub type __uint32_t = libc::c_uint; +pub type int32_t = __int32_t; +pub type u_int8_t = __uint8_t; +pub type u_int32_t = __uint32_t; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct __pthread_internal_list { + pub __prev: *mut __pthread_internal_list, + pub __next: *mut __pthread_internal_list, +} +pub type __pthread_list_t = __pthread_internal_list; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct __pthread_mutex_s { + pub __lock: libc::c_int, + pub __count: libc::c_uint, + pub __owner: libc::c_int, + pub __nusers: libc::c_uint, + pub __kind: libc::c_int, + pub __spins: libc::c_short, + pub __elision: libc::c_short, + pub __list: __pthread_list_t, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub union pthread_mutex_t { + pub __data: __pthread_mutex_s, + pub __size: [libc::c_char; 40], + pub __align: libc::c_long, +} +pub type u8_t = u_int8_t; +pub type u32_t = u_int32_t; +pub type s32_t = int32_t; +pub type frames_t = u32_t; +pub type log_level = libc::c_uint; +pub const lSDEBUG: log_level = 4; +pub const lDEBUG: log_level = 3; +pub const lINFO: log_level = 2; +pub const lWARN: log_level = 1; +pub const lERROR: log_level = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct buffer { + pub buf: *mut u8_t, + pub readp: *mut u8_t, + pub writep: *mut u8_t, + pub wrap: *mut u8_t, + pub size: size_t, + pub base_size: size_t, + pub mutex: pthread_mutex_t, +} +pub type output_state = libc::c_int; +pub const OUTPUT_START_AT: output_state = 5; +pub const OUTPUT_SKIP_FRAMES: output_state = 4; +pub const OUTPUT_PAUSE_FRAMES: output_state = 3; +pub const OUTPUT_RUNNING: output_state = 2; +pub const OUTPUT_BUFFER: output_state = 1; +pub const OUTPUT_STOPPED: output_state = 0; +pub const OUTPUT_OFF: output_state = -1; +pub type output_format = libc::c_uint; +pub const S16_LE: output_format = 3; +pub const S24_3LE: output_format = 2; +pub const S24_LE: output_format = 1; +pub const S32_LE: output_format = 0; +pub type fade_state = libc::c_uint; +pub const FADE_ACTIVE: fade_state = 2; +pub const FADE_DUE: fade_state = 1; +pub const FADE_INACTIVE: fade_state = 0; +pub type fade_dir = libc::c_uint; +pub const FADE_CROSS: fade_dir = 3; +pub const FADE_DOWN: fade_dir = 2; +pub const FADE_UP: fade_dir = 1; +pub type fade_mode = libc::c_uint; +pub const FADE_INOUT: fade_mode = 4; +pub const FADE_OUT: fade_mode = 3; +pub const FADE_IN: fade_mode = 2; +pub const FADE_CROSSFADE: fade_mode = 1; +pub const FADE_NONE: fade_mode = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct outputstate { + pub state: output_state, + pub format: output_format, + pub device: *const libc::c_char, + pub buffer: libc::c_uint, + pub period: libc::c_uint, + pub track_started: bool, + pub write_cb: Option libc::c_int>, + pub start_frames: libc::c_uint, + pub frames_played: libc::c_uint, + pub frames_played_dmp: libc::c_uint, + pub current_sample_rate: libc::c_uint, + pub supported_rates: [libc::c_uint; 18], + pub default_sample_rate: libc::c_uint, + pub error_opening: bool, + pub device_frames: libc::c_uint, + pub updated: u32_t, + pub track_start_time: u32_t, + pub current_replay_gain: u32_t, + pub c2rust_unnamed: C2RustUnnamed, + pub next_sample_rate: libc::c_uint, + pub track_start: *mut u8_t, + pub gainL: u32_t, + pub gainR: u32_t, + pub invert: bool, + pub next_replay_gain: u32_t, + pub threshold: libc::c_uint, + pub fade: fade_state, + pub fade_start: *mut u8_t, + pub fade_end: *mut u8_t, + pub fade_dir: fade_dir, + pub fade_mode: fade_mode, + pub fade_secs: libc::c_uint, + pub rate_delay: libc::c_uint, + pub delay_active: bool, + pub stop_time: u32_t, + pub idle_to: u32_t, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub union C2RustUnnamed { + pub pause_frames: u32_t, + pub skip_frames: u32_t, + pub start_at: u32_t, +} +/* * Squeezelite - lightweight headless squeezebox emulator * * (c) Adrian Smith 2012-2015, triode1@btinternet.com @@ -86,7 +192,7 @@ use crate::stdlib::strcat; * 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 @@ -97,926 +203,809 @@ use crate::stdlib::strcat; * */ // Common output function - -static mut loglevel: crate::squeezelite_h::log_level = crate::squeezelite_h::lERROR; +static mut loglevel: log_level = lERROR; #[no_mangle] - -pub static mut output: crate::squeezelite_h::outputstate = crate::squeezelite_h::outputstate { - state: crate::squeezelite_h::OUTPUT_STOPPED, - format: crate::squeezelite_h::S32_LE, - device: 0 as *const libc::c_char, - buffer: 0, - period: 0, - track_started: false, - write_cb: None, - start_frames: 0, - frames_played: 0, - frames_played_dmp: 0, - current_sample_rate: 0, - supported_rates: [0; 18], - default_sample_rate: 0, - error_opening: false, - device_frames: 0, - updated: 0, - track_start_time: 0, - current_replay_gain: 0, - c2rust_unnamed: crate::squeezelite_h::C2RustUnnamed_1 { pause_frames: 0 }, - next_sample_rate: 0, - track_start: 0 as *const crate::squeezelite_h::u8_t as *mut crate::squeezelite_h::u8_t, - gainL: 0, - gainR: 0, - invert: false, - next_replay_gain: 0, - threshold: 0, - fade: crate::squeezelite_h::FADE_INACTIVE, - fade_start: 0 as *const crate::squeezelite_h::u8_t as *mut crate::squeezelite_h::u8_t, - fade_end: 0 as *const crate::squeezelite_h::u8_t as *mut crate::squeezelite_h::u8_t, - fade_dir: 0 as crate::squeezelite_h::fade_dir, - fade_mode: crate::squeezelite_h::FADE_NONE, - fade_secs: 0, - rate_delay: 0, - delay_active: false, - stop_time: 0, - idle_to: 0, -}; - -static mut buf: crate::squeezelite_h::buffer = crate::squeezelite_h::buffer { - buf: 0 as *const crate::squeezelite_h::u8_t as *mut crate::squeezelite_h::u8_t, - readp: 0 as *const crate::squeezelite_h::u8_t as *mut crate::squeezelite_h::u8_t, - writep: 0 as *const crate::squeezelite_h::u8_t as *mut crate::squeezelite_h::u8_t, - wrap: 0 as *const crate::squeezelite_h::u8_t as *mut crate::squeezelite_h::u8_t, - size: 0, - base_size: 0, - 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, - }, - }, - }, -}; +pub static mut output: outputstate = + outputstate{state: OUTPUT_STOPPED, + format: S32_LE, + device: 0 as *const libc::c_char, + buffer: 0, + period: 0, + track_started: false, + write_cb: None, + start_frames: 0, + frames_played: 0, + frames_played_dmp: 0, + current_sample_rate: 0, + supported_rates: [0; 18], + default_sample_rate: 0, + error_opening: false, + device_frames: 0, + updated: 0, + track_start_time: 0, + current_replay_gain: 0, + c2rust_unnamed: C2RustUnnamed{pause_frames: 0,}, + next_sample_rate: 0, + track_start: 0 as *const u8_t as *mut u8_t, + gainL: 0, + gainR: 0, + invert: false, + next_replay_gain: 0, + threshold: 0, + fade: FADE_INACTIVE, + fade_start: 0 as *const u8_t as *mut u8_t, + fade_end: 0 as *const u8_t as *mut u8_t, + fade_dir: 0 as fade_dir, + fade_mode: FADE_NONE, + fade_secs: 0, + rate_delay: 0, + delay_active: false, + stop_time: 0, + idle_to: 0,}; +static mut buf: buffer = + buffer{buf: 0 as *const u8_t as *mut u8_t, + readp: 0 as *const u8_t as *mut u8_t, + writep: 0 as *const u8_t as *mut u8_t, + wrap: 0 as *const u8_t as *mut u8_t, + size: 0, + base_size: 0, + mutex: + pthread_mutex_t{__data: + __pthread_mutex_s{__lock: 0, + __count: 0, + __owner: 0, + __nusers: 0, + __kind: 0, + __spins: 0, + __elision: 0, + __list: + __pthread_list_t{__prev: + 0 + as + *const __pthread_internal_list + as + *mut __pthread_internal_list, + __next: + 0 + as + *const __pthread_internal_list + as + *mut __pthread_internal_list,},},},}; #[no_mangle] - -pub static mut outputbuf: *mut crate::squeezelite_h::buffer = - unsafe { &buf as *const crate::squeezelite_h::buffer as *mut crate::squeezelite_h::buffer }; +pub static mut outputbuf: *mut buffer = + unsafe { &buf as *const buffer as *mut buffer }; #[no_mangle] - -pub static mut silencebuf: *mut crate::squeezelite_h::u8_t = - 0 as *const crate::squeezelite_h::u8_t as *mut crate::squeezelite_h::u8_t; +pub static mut silencebuf: *mut u8_t = 0 as *const u8_t as *mut u8_t; #[no_mangle] - pub static mut user_rates: bool = 0 as libc::c_int != 0; // functions starting _* are called with mutex locked #[no_mangle] - -pub unsafe extern "C" fn _output_frames( - mut avail: crate::squeezelite_h::frames_t, -) -> crate::squeezelite_h::frames_t { - let mut frames: crate::squeezelite_h::frames_t = 0; - let mut size: crate::squeezelite_h::frames_t = 0; +pub unsafe extern "C" fn _output_frames(mut avail: frames_t) -> frames_t { + let mut frames: frames_t = 0; + let mut size: frames_t = 0; let mut silence: bool = false; - let mut cross_gain_in = 0 as libc::c_int; - let mut cross_gain_out = 0 as libc::c_int; - let mut cross_ptr = 0 as *mut crate::squeezelite_h::s32_t; - let mut gainL = if output.current_replay_gain != 0 { - crate::squeezelite_h::gain( - output.gainL as crate::squeezelite_h::s32_t, - output.current_replay_gain as crate::squeezelite_h::s32_t, - ) as libc::c_uint - } else { - output.gainL - } as crate::squeezelite_h::s32_t; - let mut gainR = if output.current_replay_gain != 0 { - crate::squeezelite_h::gain( - output.gainR as crate::squeezelite_h::s32_t, - output.current_replay_gain as crate::squeezelite_h::s32_t, - ) as libc::c_uint - } else { - output.gainR - } as crate::squeezelite_h::s32_t; - if output.invert { - gainL = -gainL; - gainR = -gainR - } + let mut cross_gain_in: s32_t = 0 as libc::c_int; + let mut cross_gain_out: s32_t = 0 as libc::c_int; + let mut cross_ptr: *mut s32_t = 0 as *mut s32_t; + let mut gainL: s32_t = + if output.current_replay_gain != 0 { + gain(output.gainL as s32_t, output.current_replay_gain as s32_t) + as libc::c_uint + } else { output.gainL } as s32_t; + let mut gainR: s32_t = + if output.current_replay_gain != 0 { + gain(output.gainR as s32_t, output.current_replay_gain as s32_t) + as libc::c_uint + } else { output.gainR } as s32_t; + if output.invert { gainL = -gainL; gainR = -gainR } frames = - crate::squeezelite_h::_buf_used(outputbuf).wrapping_div(8 as libc::c_int as libc::c_uint); + _buf_used(outputbuf).wrapping_div(8 as libc::c_int as libc::c_uint); silence = 0 as libc::c_int != 0; // start when threshold met - if output.state as libc::c_int == crate::squeezelite_h::OUTPUT_BUFFER as libc::c_int - && frames - > output - .threshold - .wrapping_mul(output.next_sample_rate) - .wrapping_div(10 as libc::c_int as libc::c_uint) - && frames > output.start_frames - { - output.state = crate::squeezelite_h::OUTPUT_RUNNING; - 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 start buffer frames: %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"_output_frames\x00")) - .as_ptr(), - 64 as libc::c_int, - frames, - ); + if output.state as libc::c_int == OUTPUT_BUFFER as libc::c_int && + frames > + output.threshold.wrapping_mul(output.next_sample_rate).wrapping_div(10 + as + libc::c_int + as + libc::c_uint) + && frames > output.start_frames { + output.state = OUTPUT_RUNNING; + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d start buffer frames: %u\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 15], + &[libc::c_char; 15]>(b"_output_frames\x00")).as_ptr(), + 64 as libc::c_int, frames); } - crate::src::slimproto::wake_controller(); + wake_controller(); } // skip ahead - consume outputbuf but play nothing - if output.state as libc::c_int == crate::squeezelite_h::OUTPUT_SKIP_FRAMES as libc::c_int { + if output.state as libc::c_int == OUTPUT_SKIP_FRAMES as libc::c_int { if frames > 0 as libc::c_int as libc::c_uint { - let mut skip = if frames < output.c2rust_unnamed.skip_frames { - frames - } else { - output.c2rust_unnamed.skip_frames - }; - 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 skip %u of %u frames\n\x00" as *const u8 as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 15], &[libc::c_char; 15]>( - b"_output_frames\x00", - )) - .as_ptr(), - 72 as libc::c_int, - skip, - output.c2rust_unnamed.skip_frames, - ); + let mut skip: frames_t = + if frames < output.c2rust_unnamed.skip_frames { + frames + } else { output.c2rust_unnamed.skip_frames }; + if loglevel as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d skip %u of %u frames\n\x00" as *const u8 + as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 15], + &[libc::c_char; 15]>(b"_output_frames\x00")).as_ptr(), + 72 as libc::c_int, skip, + output.c2rust_unnamed.skip_frames); } - frames = (frames as libc::c_uint).wrapping_sub(skip) as crate::squeezelite_h::frames_t - as crate::squeezelite_h::frames_t; + frames = + (frames as libc::c_uint).wrapping_sub(skip) as frames_t as + frames_t; output.frames_played = output.frames_played.wrapping_add(skip); while skip > 0 as libc::c_int as libc::c_uint { - let mut cont_frames = if skip - < crate::src::buffer::_buf_cont_read(outputbuf) - .wrapping_div(8 as libc::c_int as libc::c_uint) - { - skip - } else { - crate::src::buffer::_buf_cont_read(outputbuf) - .wrapping_div(8 as libc::c_int as libc::c_uint) - }; - skip = (skip as libc::c_uint).wrapping_sub(cont_frames) - as crate::squeezelite_h::frames_t - as crate::squeezelite_h::frames_t; - crate::src::buffer::_buf_inc_readp( - outputbuf, - cont_frames.wrapping_mul(8 as libc::c_int as libc::c_uint), - ); + let mut cont_frames: frames_t = + if skip < + _buf_cont_read(outputbuf).wrapping_div(8 as + libc::c_int + as + libc::c_uint) + { + skip + } else { + _buf_cont_read(outputbuf).wrapping_div(8 as + libc::c_int + as + libc::c_uint) + }; + skip = + (skip as libc::c_uint).wrapping_sub(cont_frames) as + frames_t as frames_t; + _buf_inc_readp(outputbuf, + cont_frames.wrapping_mul(8 as libc::c_int as + libc::c_uint)); } } - output.state = crate::squeezelite_h::OUTPUT_RUNNING + output.state = OUTPUT_RUNNING } // pause frames - play silence for required frames - if output.state as libc::c_int == crate::squeezelite_h::OUTPUT_PAUSE_FRAMES 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 pause %u frames\n\x00" as *const u8 as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 15], &[libc::c_char; 15]>(b"_output_frames\x00")) - .as_ptr(), - 86 as libc::c_int, - output.c2rust_unnamed.pause_frames, - ); + if output.state as libc::c_int == OUTPUT_PAUSE_FRAMES as libc::c_int { + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d pause %u frames\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 15], + &[libc::c_char; 15]>(b"_output_frames\x00")).as_ptr(), + 86 as libc::c_int, output.c2rust_unnamed.pause_frames); } - if output.c2rust_unnamed.pause_frames == 0 as libc::c_int as libc::c_uint { - output.state = crate::squeezelite_h::OUTPUT_RUNNING + if output.c2rust_unnamed.pause_frames == + 0 as libc::c_int as libc::c_uint { + output.state = OUTPUT_RUNNING } else { silence = 1 as libc::c_int != 0; - frames = if avail < output.c2rust_unnamed.pause_frames { - avail - } else { - output.c2rust_unnamed.pause_frames - }; - frames = if frames < 2048 as libc::c_int as libc::c_uint { - frames - } else { - 2048 as libc::c_int as libc::c_uint - }; + frames = + if avail < output.c2rust_unnamed.pause_frames { + avail + } else { output.c2rust_unnamed.pause_frames }; + frames = + if frames < 2048 as libc::c_int as libc::c_uint { + frames + } else { 2048 as libc::c_int as libc::c_uint }; output.c2rust_unnamed.pause_frames = - (output.c2rust_unnamed.pause_frames as libc::c_uint).wrapping_sub(frames) - as crate::squeezelite_h::u32_t as crate::squeezelite_h::u32_t + (output.c2rust_unnamed.pause_frames as + libc::c_uint).wrapping_sub(frames) as u32_t as u32_t } } // start at - play silence until jiffies reached - if output.state as libc::c_int == crate::squeezelite_h::OUTPUT_START_AT as libc::c_int { - let mut now = crate::src::utils::gettime_ms(); - if now >= output.c2rust_unnamed.start_at - || output.c2rust_unnamed.start_at - > now.wrapping_add(10000 as libc::c_int as libc::c_uint) - { - output.state = crate::squeezelite_h::OUTPUT_RUNNING + if output.state as libc::c_int == OUTPUT_START_AT as libc::c_int { + let mut now: u32_t = gettime_ms(); + if now >= output.c2rust_unnamed.start_at || + output.c2rust_unnamed.start_at > + now.wrapping_add(10000 as libc::c_int as libc::c_uint) { + output.state = OUTPUT_RUNNING } else { - let mut delta_frames = output - .c2rust_unnamed - .start_at - .wrapping_sub(now) - .wrapping_mul(output.current_sample_rate) - .wrapping_div(1000 as libc::c_int as libc::c_uint); + let mut delta_frames: u32_t = + output.c2rust_unnamed.start_at.wrapping_sub(now).wrapping_mul(output.current_sample_rate).wrapping_div(1000 + as + libc::c_int + as + libc::c_uint); silence = 1 as libc::c_int != 0; - frames = if avail < delta_frames { - avail - } else { - delta_frames - }; - frames = if frames < 2048 as libc::c_int as libc::c_uint { - frames - } else { - 2048 as libc::c_int as libc::c_uint - } + frames = if avail < delta_frames { avail } else { delta_frames }; + frames = + if frames < 2048 as libc::c_int as libc::c_uint { + frames + } else { 2048 as libc::c_int as libc::c_uint } } } // play silence if buffering or no frames - if output.state as libc::c_int <= crate::squeezelite_h::OUTPUT_BUFFER as libc::c_int - || frames == 0 as libc::c_int as libc::c_uint - { + if output.state as libc::c_int <= OUTPUT_BUFFER as libc::c_int || + frames == 0 as libc::c_int as libc::c_uint { silence = 1 as libc::c_int != 0; - frames = if avail < 2048 as libc::c_int as libc::c_uint { - avail - } else { - 2048 as libc::c_int as libc::c_uint - } + frames = + if avail < 2048 as libc::c_int as libc::c_uint { + avail + } else { 2048 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 avail: %d frames: %d silence: %d\n\x00" as *const u8 as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 15], &[libc::c_char; 15]>(b"_output_frames\x00")) - .as_ptr(), - 116 as libc::c_int, - avail, - frames, - silence as libc::c_int, - ); + if loglevel as libc::c_uint >= lSDEBUG as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d avail: %d frames: %d silence: %d\n\x00" as + *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 15], + &[libc::c_char; 15]>(b"_output_frames\x00")).as_ptr(), + 116 as libc::c_int, avail, frames, silence as libc::c_int); } frames = if frames < avail { frames } else { avail }; size = frames; while size > 0 as libc::c_int as libc::c_uint { - let mut out_frames: crate::squeezelite_h::frames_t = 0; - let mut cont_frames_0 = crate::src::buffer::_buf_cont_read(outputbuf) - .wrapping_div(8 as libc::c_int as libc::c_uint); + let mut out_frames: frames_t = 0; + let mut cont_frames_0: frames_t = + _buf_cont_read(outputbuf).wrapping_div(8 as libc::c_int as + libc::c_uint); let mut wrote: libc::c_int = 0; if !output.track_start.is_null() && !silence { if output.track_start == (*outputbuf).readp { - let mut delay = 0 as libc::c_int as libc::c_uint; + let mut delay: libc::c_uint = + 0 as libc::c_int as libc::c_uint; if output.current_sample_rate != output.next_sample_rate { delay = output.rate_delay } - frames = (frames as libc::c_uint).wrapping_sub(size) - as crate::squeezelite_h::frames_t - as crate::squeezelite_h::frames_t; + frames = + (frames as libc::c_uint).wrapping_sub(size) as frames_t as + frames_t; // add silence delay in two halves, before and after track start on rate or pcm-dop change if delay != 0 { - output.state = crate::squeezelite_h::OUTPUT_PAUSE_FRAMES; // first delay - don't process track start + output.state = + OUTPUT_PAUSE_FRAMES; // first delay - don't process track start if !output.delay_active { - output.c2rust_unnamed.pause_frames = output - .current_sample_rate - .wrapping_mul(delay) - .wrapping_div(2000 as libc::c_int as libc::c_uint); + output.c2rust_unnamed.pause_frames = + output.current_sample_rate.wrapping_mul(delay).wrapping_div(2000 + as + libc::c_int + as + libc::c_uint); output.delay_active = 1 as libc::c_int != 0; - break; + break ; } else { - output.c2rust_unnamed.pause_frames = output - .next_sample_rate - .wrapping_mul(delay) - .wrapping_div(2000 as libc::c_int as libc::c_uint); + output.c2rust_unnamed.pause_frames = + output.next_sample_rate.wrapping_mul(delay).wrapping_div(2000 + as + libc::c_int + as + libc::c_uint); output.delay_active = 0 as libc::c_int != 0 // second delay - process track start } } - 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 track start sample rate: %u replay_gain: %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"_output_frames\x00", - )) - .as_ptr(), - 149 as libc::c_int, - output.next_sample_rate, - output.next_replay_gain, - ); + if loglevel as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d track start sample rate: %u replay_gain: %u\n\x00" + as *const u8 as *const libc::c_char, + logtime(), + (*::std::mem::transmute::<&[u8; 15], + &[libc::c_char; 15]>(b"_output_frames\x00")).as_ptr(), + 149 as libc::c_int, output.next_sample_rate, + output.next_replay_gain); } output.frames_played = 0 as libc::c_int as libc::c_uint; output.track_started = 1 as libc::c_int != 0; - output.track_start_time = crate::src::utils::gettime_ms(); + output.track_start_time = gettime_ms(); output.current_sample_rate = output.next_sample_rate; - if output.fade as libc::c_uint - == crate::squeezelite_h::FADE_INACTIVE as libc::c_int as libc::c_uint - || output.fade_mode as libc::c_uint - != crate::squeezelite_h::FADE_CROSSFADE as libc::c_int as libc::c_uint - { + if output.fade as libc::c_uint == + FADE_INACTIVE as libc::c_int as libc::c_uint || + output.fade_mode as libc::c_uint != + FADE_CROSSFADE as libc::c_int as libc::c_uint { output.current_replay_gain = output.next_replay_gain } - output.track_start = 0 as *mut crate::squeezelite_h::u8_t; - break; + output.track_start = 0 as *mut u8_t; + break ; } else if output.track_start > (*outputbuf).readp { // reduce cont_frames so we find the next track start at beginning of next chunk - cont_frames_0 = if (cont_frames_0 as libc::c_long) - < output.track_start.wrapping_offset_from((*outputbuf).readp) as libc::c_long - / 8 as libc::c_int as libc::c_long - { - cont_frames_0 as libc::c_long - } else { - (output.track_start.wrapping_offset_from((*outputbuf).readp) as libc::c_long) - / 8 as libc::c_int as libc::c_long - } as crate::squeezelite_h::frames_t + cont_frames_0 = + if (cont_frames_0 as libc::c_long) < + output.track_start.wrapping_offset_from((*outputbuf).readp) + as libc::c_long / + 8 as libc::c_int as libc::c_long { + cont_frames_0 as libc::c_long + } else { + (output.track_start.wrapping_offset_from((*outputbuf).readp) + as libc::c_long) / + 8 as libc::c_int as libc::c_long + } as frames_t } } if output.fade as libc::c_uint != 0 && !silence { - if output.fade as libc::c_uint - == crate::squeezelite_h::FADE_DUE as libc::c_int as libc::c_uint - { + if output.fade as libc::c_uint == + FADE_DUE as libc::c_int as libc::c_uint { if output.fade_start == (*outputbuf).readp { - 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 fade start reached\n\x00" as *const u8 - as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 15], &[libc::c_char; 15]>( - b"_output_frames\x00", - )) - .as_ptr(), - 177 as libc::c_int, - ); + if loglevel as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d fade start reached\n\x00" as + *const u8 as *const libc::c_char, + logtime(), + (*::std::mem::transmute::<&[u8; 15], + &[libc::c_char; 15]>(b"_output_frames\x00")).as_ptr(), + 177 as libc::c_int); } - output.fade = crate::squeezelite_h::FADE_ACTIVE + output.fade = FADE_ACTIVE } else if output.fade_start > (*outputbuf).readp { - cont_frames_0 = if (cont_frames_0 as libc::c_long) - < output.fade_start.wrapping_offset_from((*outputbuf).readp) as libc::c_long - / 8 as libc::c_int as libc::c_long - { - cont_frames_0 as libc::c_long - } else { - (output.fade_start.wrapping_offset_from((*outputbuf).readp) as libc::c_long) - / 8 as libc::c_int as libc::c_long - } as crate::squeezelite_h::frames_t + cont_frames_0 = + if (cont_frames_0 as libc::c_long) < + output.fade_start.wrapping_offset_from((*outputbuf).readp) + as libc::c_long / + 8 as libc::c_int as libc::c_long { + cont_frames_0 as libc::c_long + } else { + (output.fade_start.wrapping_offset_from((*outputbuf).readp) + as libc::c_long) / + 8 as libc::c_int as libc::c_long + } as frames_t } } - if output.fade as libc::c_uint - == crate::squeezelite_h::FADE_ACTIVE as libc::c_int as libc::c_uint - { + if output.fade as libc::c_uint == + FADE_ACTIVE as libc::c_int as libc::c_uint { // find position within fade - let mut cur_f = if (*outputbuf).readp >= output.fade_start { - ((*outputbuf).readp.wrapping_offset_from(output.fade_start) as libc::c_long) - / 8 as libc::c_int as libc::c_long - } else { - ((*outputbuf) - .readp - .offset((*outputbuf).size as isize) - .wrapping_offset_from(output.fade_start) - as libc::c_long) - / 8 as libc::c_int as libc::c_long - } as crate::squeezelite_h::frames_t; - let mut dur_f = if output.fade_end >= output.fade_start { - (output.fade_end.wrapping_offset_from(output.fade_start) as libc::c_long) - / 8 as libc::c_int as libc::c_long - } else { - (output - .fade_end - .offset((*outputbuf).size as isize) - .wrapping_offset_from(output.fade_start) - as libc::c_long) - / 8 as libc::c_int as libc::c_long - } as crate::squeezelite_h::frames_t; + let mut cur_f: frames_t = + if (*outputbuf).readp >= output.fade_start { + ((*outputbuf).readp.wrapping_offset_from(output.fade_start) + as libc::c_long) / + 8 as libc::c_int as libc::c_long + } else { + ((*outputbuf).readp.offset((*outputbuf).size as + isize).wrapping_offset_from(output.fade_start) + as libc::c_long) / + 8 as libc::c_int as libc::c_long + } as frames_t; + let mut dur_f: frames_t = + if output.fade_end >= output.fade_start { + (output.fade_end.wrapping_offset_from(output.fade_start) + as libc::c_long) / + 8 as libc::c_int as libc::c_long + } else { + (output.fade_end.offset((*outputbuf).size as + isize).wrapping_offset_from(output.fade_start) + as libc::c_long) / + 8 as libc::c_int as libc::c_long + } as frames_t; if cur_f >= dur_f { - if output.fade_mode as libc::c_uint - == crate::squeezelite_h::FADE_INOUT as libc::c_int as libc::c_uint - && output.fade_dir as libc::c_uint - == crate::squeezelite_h::FADE_DOWN 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 fade down complete, starting fade up\n\x00" as *const u8 - as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 15], &[libc::c_char; 15]>( - b"_output_frames\x00", - )) - .as_ptr(), - 191 as libc::c_int, - ); + if output.fade_mode as libc::c_uint == + FADE_INOUT as libc::c_int as libc::c_uint && + output.fade_dir as libc::c_uint == + FADE_DOWN as libc::c_int as libc::c_uint { + if loglevel as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d fade down complete, starting fade up\n\x00" + as *const u8 as *const libc::c_char, + logtime(), + (*::std::mem::transmute::<&[u8; 15], + &[libc::c_char; 15]>(b"_output_frames\x00")).as_ptr(), + 191 as libc::c_int); } - output.fade_dir = crate::squeezelite_h::FADE_UP; + output.fade_dir = FADE_UP; output.fade_start = (*outputbuf).readp; - output.fade_end = (*outputbuf) - .readp - .offset(dur_f.wrapping_mul(8 as libc::c_int as libc::c_uint) as isize); + output.fade_end = + (*outputbuf).readp.offset(dur_f.wrapping_mul(8 as + libc::c_int + as + libc::c_uint) + as isize); if output.fade_end >= (*outputbuf).wrap { - output.fade_end = output.fade_end.offset(-((*outputbuf).size as isize)) + output.fade_end = + output.fade_end.offset(-((*outputbuf).size as + isize)) } - cur_f = 0 as libc::c_int as crate::squeezelite_h::frames_t - } else if output.fade_mode as libc::c_uint - == crate::squeezelite_h::FADE_CROSSFADE 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 crossfade complete\n\x00" as *const u8 - as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 15], &[libc::c_char; 15]>( - b"_output_frames\x00", - )) - .as_ptr(), - 200 as libc::c_int, - ); + cur_f = 0 as libc::c_int as frames_t + } else if output.fade_mode as libc::c_uint == + FADE_CROSSFADE as libc::c_int as + libc::c_uint { + if loglevel as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d crossfade complete\n\x00" as + *const u8 as *const libc::c_char, + logtime(), + (*::std::mem::transmute::<&[u8; 15], + &[libc::c_char; 15]>(b"_output_frames\x00")).as_ptr(), + 200 as libc::c_int); } - if crate::squeezelite_h::_buf_used(outputbuf) - >= dur_f.wrapping_mul(8 as libc::c_int as libc::c_uint) - { - crate::src::buffer::_buf_inc_readp( - outputbuf, - dur_f.wrapping_mul(8 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 skipped crossfaded start\n\x00" as *const u8 - as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 15], &[libc::c_char; 15]>( - b"_output_frames\x00", - )) - .as_ptr(), - 203 as libc::c_int, - ); + if _buf_used(outputbuf) >= + dur_f.wrapping_mul(8 as libc::c_int as + libc::c_uint) { + _buf_inc_readp(outputbuf, + dur_f.wrapping_mul(8 as libc::c_int + as + libc::c_uint)); + if loglevel as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d skipped crossfaded start\n\x00" + as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 15], + &[libc::c_char; 15]>(b"_output_frames\x00")).as_ptr(), + 203 as libc::c_int); } - } 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 unable to skip crossfaded start\n\x00" as *const u8 - as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 15], &[libc::c_char; 15]>( - b"_output_frames\x00", - )) - .as_ptr(), - 205 as libc::c_int, - ); + } else if loglevel as libc::c_uint >= + lWARN as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d unable to skip crossfaded start\n\x00" + as *const u8 as *const libc::c_char, + logtime(), + (*::std::mem::transmute::<&[u8; 15], + &[libc::c_char; 15]>(b"_output_frames\x00")).as_ptr(), + 205 as libc::c_int); } - output.fade = crate::squeezelite_h::FADE_INACTIVE; + output.fade = FADE_INACTIVE; output.current_replay_gain = output.next_replay_gain } 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 fade complete\n\x00" as *const u8 as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 15], &[libc::c_char; 15]>( - b"_output_frames\x00", - )) - .as_ptr(), - 210 as libc::c_int, - ); + if loglevel as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d fade complete\n\x00" as + *const u8 as *const libc::c_char, + logtime(), + (*::std::mem::transmute::<&[u8; 15], + &[libc::c_char; 15]>(b"_output_frames\x00")).as_ptr(), + 210 as libc::c_int); } - output.fade = crate::squeezelite_h::FADE_INACTIVE + output.fade = FADE_INACTIVE } } // if fade in progress set fade gain, ensure cont_frames reduced so we get to end of fade at start of chunk if output.fade as u64 != 0 { if output.fade_end > (*outputbuf).readp { - cont_frames_0 = if (cont_frames_0 as libc::c_long) - < output.fade_end.wrapping_offset_from((*outputbuf).readp) - as libc::c_long - / 8 as libc::c_int as libc::c_long - { - cont_frames_0 as libc::c_long - } else { - (output.fade_end.wrapping_offset_from((*outputbuf).readp) - as libc::c_long) - / 8 as libc::c_int as libc::c_long - } as crate::squeezelite_h::frames_t + cont_frames_0 = + if (cont_frames_0 as libc::c_long) < + output.fade_end.wrapping_offset_from((*outputbuf).readp) + as libc::c_long / + 8 as libc::c_int as libc::c_long { + cont_frames_0 as libc::c_long + } else { + (output.fade_end.wrapping_offset_from((*outputbuf).readp) + as libc::c_long) / + 8 as libc::c_int as libc::c_long + } as frames_t } - if output.fade_dir as libc::c_uint - == crate::squeezelite_h::FADE_UP as libc::c_int as libc::c_uint - || output.fade_dir as libc::c_uint - == crate::squeezelite_h::FADE_DOWN as libc::c_int as libc::c_uint - { + if output.fade_dir as libc::c_uint == + FADE_UP as libc::c_int as libc::c_uint || + output.fade_dir as libc::c_uint == + FADE_DOWN as libc::c_int as libc::c_uint { // fade in, in-out, out handled via altering standard gain - let mut fade_gain: crate::squeezelite_h::s32_t = 0; - if output.fade_dir as libc::c_uint - == crate::squeezelite_h::FADE_DOWN as libc::c_int as libc::c_uint - { + let mut fade_gain: s32_t = 0; + if output.fade_dir as libc::c_uint == + FADE_DOWN as libc::c_int as libc::c_uint { cur_f = dur_f.wrapping_sub(cur_f) } - fade_gain = crate::squeezelite_h::to_gain( - cur_f as libc::c_float / dur_f as libc::c_float, - ); - gainL = crate::squeezelite_h::gain(gainL, fade_gain); - gainR = crate::squeezelite_h::gain(gainR, fade_gain); - if output.invert { - gainL = -gainL; - gainR = -gainR - } + fade_gain = + to_gain(cur_f as libc::c_float / + dur_f as libc::c_float); + gainL = gain(gainL, fade_gain); + gainR = gain(gainR, fade_gain); + if output.invert { gainL = -gainL; gainR = -gainR } } - if output.fade_dir as libc::c_uint - == crate::squeezelite_h::FADE_CROSS as libc::c_int as libc::c_uint - { + if output.fade_dir as libc::c_uint == + FADE_CROSS as libc::c_int as libc::c_uint { // cross fade requires special treatment - performed later based on these values - // support different replay gain for old and new track by retaining old value until crossfade completes - if crate::squeezelite_h::_buf_used(outputbuf) - .wrapping_div(8 as libc::c_int as libc::c_uint) - > dur_f.wrapping_add(size) - { - cross_gain_in = crate::squeezelite_h::to_gain( - cur_f as libc::c_float / dur_f as libc::c_float, - ); - cross_gain_out = 0x10000 as libc::c_int - cross_gain_in; + // support different replay gain for old and new track by retaining old value until crossfade completes + if _buf_used(outputbuf).wrapping_div(8 as libc::c_int + as + libc::c_uint) + > dur_f.wrapping_add(size) { + cross_gain_in = + to_gain(cur_f as libc::c_float / + dur_f as libc::c_float); + cross_gain_out = + 0x10000 as libc::c_int - cross_gain_in; if output.current_replay_gain != 0 { - cross_gain_out = crate::squeezelite_h::gain( - cross_gain_out, - output.current_replay_gain as crate::squeezelite_h::s32_t, - ) + cross_gain_out = + gain(cross_gain_out, + output.current_replay_gain as s32_t) } if output.next_replay_gain != 0 { - cross_gain_in = crate::squeezelite_h::gain( - cross_gain_in, - output.next_replay_gain as crate::squeezelite_h::s32_t, - ) + cross_gain_in = + gain(cross_gain_in, + output.next_replay_gain as s32_t) } - gainL = output.gainL as crate::squeezelite_h::s32_t; - gainR = output.gainR as crate::squeezelite_h::s32_t; + gainL = output.gainL as s32_t; + gainR = output.gainR as s32_t; if output.invert { gainL = -gainL; gainR = -gainR } cross_ptr = - output - .fade_end - .offset(cur_f.wrapping_mul(8 as libc::c_int as libc::c_uint) - as isize) - as *mut crate::squeezelite_h::s32_t + output.fade_end.offset(cur_f.wrapping_mul(8 as + libc::c_int + as + libc::c_uint) + as isize) as + *mut s32_t } 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 unable to continue crossfade - too few samples\n\x00" - as *const u8 - as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 15], &[libc::c_char; 15]>( - b"_output_frames\x00", - )) - .as_ptr(), - 247 as libc::c_int, - ); + if loglevel as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d unable to continue crossfade - too few samples\n\x00" + as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 15], + &[libc::c_char; 15]>(b"_output_frames\x00")).as_ptr(), + 247 as libc::c_int); } - output.fade = crate::squeezelite_h::FADE_INACTIVE + output.fade = FADE_INACTIVE } } } } } - out_frames = if !silence { - if size < cont_frames_0 { - size - } else { - cont_frames_0 - } - } else { - size - }; - wrote = output.write_cb.expect("non-null function pointer")( - out_frames, - silence, - gainL, - gainR, - cross_gain_in, - cross_gain_out, - &mut cross_ptr, - ); - if wrote <= 0 as libc::c_int { - frames = (frames as libc::c_uint).wrapping_sub(size) as crate::squeezelite_h::frames_t - as crate::squeezelite_h::frames_t; - break; - } else { - out_frames = wrote as crate::squeezelite_h::frames_t; - size = (size as libc::c_uint).wrapping_sub(out_frames) as crate::squeezelite_h::frames_t - as crate::squeezelite_h::frames_t; + out_frames = if !silence { - crate::src::buffer::_buf_inc_readp( - outputbuf, - out_frames.wrapping_mul(8 as libc::c_int as libc::c_uint), - ); - output.frames_played = output.frames_played.wrapping_add(out_frames) + if size < cont_frames_0 { size } else { cont_frames_0 } + } else { size }; + wrote = + output.write_cb.expect("non-null function pointer")(out_frames, + silence, + gainL, gainR, + cross_gain_in, + cross_gain_out, + &mut cross_ptr); + if wrote <= 0 as libc::c_int { + frames = + (frames as libc::c_uint).wrapping_sub(size) as frames_t as + frames_t; + break ; + } else { + out_frames = wrote as frames_t; + size = + (size as libc::c_uint).wrapping_sub(out_frames) as frames_t as + frames_t; + if !silence { + _buf_inc_readp(outputbuf, + out_frames.wrapping_mul(8 as libc::c_int as + libc::c_uint)); + output.frames_played = + output.frames_played.wrapping_add(out_frames) } } } - 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; 15], &[libc::c_char; 15]>(b"_output_frames\x00")) - .as_ptr(), - 276 as libc::c_int, - frames, - ); + if loglevel as libc::c_uint >= lSDEBUG as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d wrote %u frames\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 15], + &[libc::c_char; 15]>(b"_output_frames\x00")).as_ptr(), + 276 as libc::c_int, frames); } return frames; } // _* called with mutex locked #[no_mangle] - pub unsafe extern "C" fn _checkfade(mut start: bool) { - let mut bytes: crate::squeezelite_h::frames_t = 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 fade mode: %u duration: %u %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"_checkfade\x00")).as_ptr(), - 284 as libc::c_int, - output.fade_mode as libc::c_uint, - output.fade_secs, - if start as libc::c_int != 0 { - b"track-start\x00" as *const u8 as *const libc::c_char - } else { - b"track-end\x00" as *const u8 as *const libc::c_char - }, - ); + let mut bytes: frames_t = 0; + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d fade mode: %u duration: %u %s\n\x00" as *const u8 + as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 11], + &[libc::c_char; 11]>(b"_checkfade\x00")).as_ptr(), + 284 as libc::c_int, output.fade_mode as libc::c_uint, + output.fade_secs, + if start as libc::c_int != 0 { + b"track-start\x00" as *const u8 as *const libc::c_char + } else { + b"track-end\x00" as *const u8 as *const libc::c_char + }); } - bytes = output - .next_sample_rate - .wrapping_mul(8 as libc::c_int as libc::c_uint) - .wrapping_mul(output.fade_secs); - if output.fade_mode as libc::c_uint - == crate::squeezelite_h::FADE_INOUT as libc::c_int as libc::c_uint - { + bytes = + output.next_sample_rate.wrapping_mul(8 as libc::c_int as + libc::c_uint).wrapping_mul(output.fade_secs); + if output.fade_mode as libc::c_uint == + FADE_INOUT as libc::c_int as libc::c_uint { /* align on a frame boundary */ - bytes = bytes - .wrapping_div(2 as libc::c_int as libc::c_uint) - .wrapping_div(8 as libc::c_int as libc::c_uint) - .wrapping_mul(8 as libc::c_int as libc::c_uint) + bytes = + bytes.wrapping_div(2 as libc::c_int as + libc::c_uint).wrapping_div(8 as libc::c_int + as + libc::c_uint).wrapping_mul(8 + as + libc::c_int + as + libc::c_uint) } // shorter than full buffer otherwise start and end align - if start as libc::c_int != 0 - && (output.fade_mode as libc::c_uint - == crate::squeezelite_h::FADE_IN as libc::c_int as libc::c_uint - || output.fade_mode as libc::c_uint - == crate::squeezelite_h::FADE_INOUT as libc::c_int as libc::c_uint - && crate::squeezelite_h::_buf_used(outputbuf) == 0 as libc::c_int as libc::c_uint) - { - bytes = if (bytes as libc::c_ulong) - < (*outputbuf) - .size - .wrapping_sub(8 as libc::c_int as libc::c_ulong) - { - bytes as libc::c_ulong - } else { - (*outputbuf) - .size - .wrapping_sub(8 as libc::c_int as libc::c_ulong) - } as crate::squeezelite_h::frames_t; // max of current remaining samples from previous track - 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 fade IN: %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"_checkfade\x00")) - .as_ptr(), - 294 as libc::c_int, - bytes.wrapping_div(8 as libc::c_int as libc::c_uint), - ); // max of 90% of outputbuf as we consume additional buffer during crossfade + if start as libc::c_int != 0 && + (output.fade_mode as libc::c_uint == + FADE_IN as libc::c_int as libc::c_uint || + output.fade_mode as libc::c_uint == + FADE_INOUT as libc::c_int as libc::c_uint && + _buf_used(outputbuf) == 0 as libc::c_int as libc::c_uint) + { + bytes = + if (bytes as libc::c_ulong) < + (*outputbuf).size.wrapping_sub(8 as libc::c_int as + libc::c_ulong) { + bytes as libc::c_ulong + } else { + (*outputbuf).size.wrapping_sub(8 as libc::c_int as + libc::c_ulong) + } as + frames_t; // max of current remaining samples from previous track + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d fade IN: %u frames\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 11], + &[libc::c_char; 11]>(b"_checkfade\x00")).as_ptr(), + 294 as libc::c_int, + bytes.wrapping_div(8 as libc::c_int as + libc::c_uint)); // max of 90% of outputbuf as we consume additional buffer during crossfade } - output.fade = crate::squeezelite_h::FADE_DUE; - output.fade_dir = crate::squeezelite_h::FADE_UP; + output.fade = FADE_DUE; + output.fade_dir = FADE_UP; output.fade_start = (*outputbuf).writep; output.fade_end = output.fade_start.offset(bytes as isize); if output.fade_end >= (*outputbuf).wrap { - output.fade_end = output.fade_end.offset(-((*outputbuf).size as isize)) + output.fade_end = + output.fade_end.offset(-((*outputbuf).size as isize)) } } - if !start - && (output.fade_mode as libc::c_uint - == crate::squeezelite_h::FADE_OUT as libc::c_int as libc::c_uint - || output.fade_mode as libc::c_uint - == crate::squeezelite_h::FADE_INOUT as libc::c_int as libc::c_uint) - { - bytes = if crate::squeezelite_h::_buf_used(outputbuf) < bytes { - crate::squeezelite_h::_buf_used(outputbuf) - } else { - bytes - }; - 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 fade %s: %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"_checkfade\x00")) - .as_ptr(), - 306 as libc::c_int, - if output.fade_mode as libc::c_uint - == crate::squeezelite_h::FADE_INOUT as libc::c_int as libc::c_uint - { - b"IN-OUT\x00" as *const u8 as *const libc::c_char - } else { - b"OUT\x00" as *const u8 as *const libc::c_char - }, - bytes.wrapping_div(8 as libc::c_int as libc::c_uint), - ); + if !start && + (output.fade_mode as libc::c_uint == + FADE_OUT as libc::c_int as libc::c_uint || + output.fade_mode as libc::c_uint == + FADE_INOUT as libc::c_int as libc::c_uint) { + bytes = + if _buf_used(outputbuf) < bytes { + _buf_used(outputbuf) + } else { bytes }; + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d fade %s: %u frames\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 11], + &[libc::c_char; 11]>(b"_checkfade\x00")).as_ptr(), + 306 as libc::c_int, + if output.fade_mode as libc::c_uint == + FADE_INOUT as libc::c_int as libc::c_uint { + b"IN-OUT\x00" as *const u8 as *const libc::c_char + } else { + b"OUT\x00" as *const u8 as *const libc::c_char + }, bytes.wrapping_div(8 as libc::c_int as libc::c_uint)); } - output.fade = crate::squeezelite_h::FADE_DUE; - output.fade_dir = crate::squeezelite_h::FADE_DOWN; + output.fade = FADE_DUE; + output.fade_dir = FADE_DOWN; output.fade_start = (*outputbuf).writep.offset(-(bytes as isize)); if output.fade_start < (*outputbuf).buf { - output.fade_start = output.fade_start.offset((*outputbuf).size as isize) + output.fade_start = + output.fade_start.offset((*outputbuf).size as isize) } output.fade_end = (*outputbuf).writep } - if start as libc::c_int != 0 - && output.fade_mode as libc::c_uint - == crate::squeezelite_h::FADE_CROSSFADE as libc::c_int as libc::c_uint - { - if crate::squeezelite_h::_buf_used(outputbuf) != 0 as libc::c_int as libc::c_uint { + if start as libc::c_int != 0 && + output.fade_mode as libc::c_uint == + FADE_CROSSFADE as libc::c_int as libc::c_uint { + if _buf_used(outputbuf) != 0 as libc::c_int as libc::c_uint { if output.next_sample_rate != output.current_sample_rate { - 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 crossfade disabled as sample rates differ\n\x00" as *const u8 - as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 11], &[libc::c_char; 11]>( - b"_checkfade\x00", - )) - .as_ptr(), - 319 as libc::c_int, - ); + if loglevel as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d crossfade disabled as sample rates differ\n\x00" + as *const u8 as *const libc::c_char, + logtime(), + (*::std::mem::transmute::<&[u8; 11], + &[libc::c_char; 11]>(b"_checkfade\x00")).as_ptr(), + 319 as libc::c_int); } - return; + return } - bytes = if bytes < crate::squeezelite_h::_buf_used(outputbuf) { - bytes - } else { - crate::squeezelite_h::_buf_used(outputbuf) - }; - bytes = if bytes - < ((*outputbuf).size as libc::c_double * 0.9f64) as crate::squeezelite_h::frames_t - { - bytes - } else { - ((*outputbuf).size as libc::c_double * 0.9f64) as crate::squeezelite_h::frames_t - }; - 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 CROSSFADE: %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"_checkfade\x00")) - .as_ptr(), - 324 as libc::c_int, - bytes.wrapping_div(8 as libc::c_int as libc::c_uint), - ); + bytes = + if bytes < _buf_used(outputbuf) { + bytes + } else { _buf_used(outputbuf) }; + bytes = + if bytes < + ((*outputbuf).size as libc::c_double * 0.9f64) as + frames_t { + bytes + } else { + ((*outputbuf).size as libc::c_double * 0.9f64) as frames_t + }; + if loglevel as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d CROSSFADE: %u frames\n\x00" as *const u8 + as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 11], + &[libc::c_char; 11]>(b"_checkfade\x00")).as_ptr(), + 324 as libc::c_int, + bytes.wrapping_div(8 as libc::c_int as + libc::c_uint)); } - output.fade = crate::squeezelite_h::FADE_DUE; - output.fade_dir = crate::squeezelite_h::FADE_CROSS; + output.fade = FADE_DUE; + output.fade_dir = FADE_CROSS; output.fade_start = (*outputbuf).writep.offset(-(bytes as isize)); if output.fade_start < (*outputbuf).buf { - output.fade_start = output.fade_start.offset((*outputbuf).size as isize) + output.fade_start = + output.fade_start.offset((*outputbuf).size as isize) } output.fade_end = (*outputbuf).writep; output.track_start = output.fade_start - } else if (*outputbuf).size - == (44100 as libc::c_int * 8 as libc::c_int * 10 as libc::c_int) as libc::c_ulong - && (*outputbuf).readp == (*outputbuf).buf - { + } else if (*outputbuf).size == + (44100 as libc::c_int * 8 as libc::c_int * + 10 as libc::c_int) as libc::c_ulong && + (*outputbuf).readp == (*outputbuf).buf { // if default setting used and nothing in buffer attempt to resize to provide full crossfade support - 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 resize outputbuf for crossfade\n\x00" as *const u8 - as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 11], &[libc::c_char; 11]>(b"_checkfade\x00")) - .as_ptr(), - 335 as libc::c_int, - ); + if loglevel as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d resize outputbuf for crossfade\n\x00" as + *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 11], + &[libc::c_char; 11]>(b"_checkfade\x00")).as_ptr(), + 335 as libc::c_int); } - crate::src::buffer::_buf_resize( - outputbuf, - (44100 as libc::c_int * 8 as libc::c_int * 10 as libc::c_int * 12 as libc::c_int - / 10 as libc::c_int) as crate::stddef_h::size_t, - ); - crate::src::utils::touch_memory((*outputbuf).buf, (*outputbuf).size); + _buf_resize(outputbuf, + (44100 as libc::c_int * 8 as libc::c_int * + 10 as libc::c_int * 12 as libc::c_int / + 10 as libc::c_int) as size_t); + touch_memory((*outputbuf).buf, (*outputbuf).size); } }; } #[no_mangle] - -pub unsafe extern "C" fn output_init_common( - mut level: crate::squeezelite_h::log_level, - mut device: *const libc::c_char, - mut output_buf_size: libc::c_uint, - mut rates: *mut libc::c_uint, - mut idle: libc::c_uint, -) { +pub unsafe extern "C" fn output_init_common(mut level: log_level, + mut device: *const libc::c_char, + mut output_buf_size: libc::c_uint, + mut rates: *mut libc::c_uint, + mut idle: libc::c_uint) { let mut i: libc::c_uint = 0; loglevel = level; - output_buf_size = output_buf_size - .wrapping_sub(output_buf_size.wrapping_rem(8 as libc::c_int as libc::c_uint)); - 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 outputbuf size: %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"output_init_common\x00")) - .as_ptr(), - 350 as libc::c_int, - output_buf_size, - ); + output_buf_size = + output_buf_size.wrapping_sub(output_buf_size.wrapping_rem(8 as + libc::c_int + as + libc::c_uint)); + if loglevel as libc::c_uint >= lDEBUG as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d outputbuf size: %u\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 19], + &[libc::c_char; 19]>(b"output_init_common\x00")).as_ptr(), + 350 as libc::c_int, output_buf_size); } - crate::src::buffer::buf_init(outputbuf, output_buf_size as crate::stddef_h::size_t); + buf_init(outputbuf, output_buf_size as size_t); if (*outputbuf).buf.is_null() { - crate::src::utils::logprint( - b"%s %s:%d unable to malloc output buffer\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_common\x00")) - .as_ptr(), - 354 as libc::c_int, - ); - crate::stdlib::exit(0 as libc::c_int); + logprint(b"%s %s:%d unable to malloc output buffer\n\x00" as *const u8 + as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 19], + &[libc::c_char; 19]>(b"output_init_common\x00")).as_ptr(), + 354 as libc::c_int); + exit(0 as libc::c_int); } - silencebuf = crate::stdlib::malloc((2048 as libc::c_int * 8 as libc::c_int) as libc::c_ulong) - as *mut crate::squeezelite_h::u8_t; + silencebuf = + malloc((2048 as libc::c_int * 8 as libc::c_int) as libc::c_ulong) as + *mut u8_t; if silencebuf.is_null() { - crate::src::utils::logprint( - b"%s %s:%d unable to malloc silence buffer\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_common\x00")) - .as_ptr(), - 360 as libc::c_int, - ); - crate::stdlib::exit(0 as libc::c_int); + logprint(b"%s %s:%d unable to malloc silence buffer\n\x00" as + *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 19], + &[libc::c_char; 19]>(b"output_init_common\x00")).as_ptr(), + 360 as libc::c_int); + exit(0 as libc::c_int); } - crate::stdlib::memset( - silencebuf as *mut libc::c_void, - 0 as libc::c_int, - (2048 as libc::c_int * 8 as libc::c_int) as libc::c_ulong, - ); - 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 idle timeout: %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"output_init_common\x00")) - .as_ptr(), - 374 as libc::c_int, - idle, - ); + memset(silencebuf as *mut libc::c_void, 0 as libc::c_int, + (2048 as libc::c_int * 8 as libc::c_int) as libc::c_ulong); + if loglevel as libc::c_uint >= lDEBUG as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d idle timeout: %u\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 19], + &[libc::c_char; 19]>(b"output_init_common\x00")).as_ptr(), + 374 as libc::c_int, idle); } - output.state = if idle != 0 { - crate::squeezelite_h::OUTPUT_OFF as libc::c_int - } else { - crate::squeezelite_h::OUTPUT_STOPPED as libc::c_int - } as crate::squeezelite_h::output_state; + output.state = + if idle != 0 { + OUTPUT_OFF as libc::c_int + } else { OUTPUT_STOPPED as libc::c_int } as output_state; output.device = device; - output.fade = crate::squeezelite_h::FADE_INACTIVE; + output.fade = FADE_INACTIVE; output.invert = 0 as libc::c_int != 0; output.error_opening = 0 as libc::c_int != 0; output.idle_to = idle; /* Skip test_open for stdout, set default sample rates */ - if *output.device.offset(0 as libc::c_int as isize) as libc::c_int == '-' as i32 { + if *output.device.offset(0 as libc::c_int as isize) as libc::c_int == + '-' as i32 { i = 0 as libc::c_int as libc::c_uint; while i < 18 as libc::c_int as libc::c_uint { output.supported_rates[i as usize] = *rates.offset(i as isize); i = i.wrapping_add(1) } - } else if !crate::src::output_alsa::test_open( - output.device, - output.supported_rates.as_mut_ptr(), - user_rates, - ) { - crate::src::utils::logprint( - b"%s %s:%d unable to open output device: %s\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_common\x00")) - .as_ptr(), - 391 as libc::c_int, - output.device, - ); - crate::stdlib::exit(0 as libc::c_int); + } else if !test_open(output.device, output.supported_rates.as_mut_ptr(), + user_rates) { + logprint(b"%s %s:%d unable to open output device: %s\n\x00" as + *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 19], + &[libc::c_char; 19]>(b"output_init_common\x00")).as_ptr(), + 391 as libc::c_int, output.device); + exit(0 as libc::c_int); } if user_rates { i = 0 as libc::c_int as libc::c_uint; @@ -1028,63 +1017,55 @@ pub unsafe extern "C" fn output_init_common( // set initial sample rate, preferring 44100 i = 0 as libc::c_int as libc::c_uint; while i < 18 as libc::c_int as libc::c_uint { - if output.supported_rates[i as usize] == 44100 as libc::c_int as libc::c_uint { + if output.supported_rates[i as usize] == + 44100 as libc::c_int as libc::c_uint { output.default_sample_rate = 44100 as libc::c_int as libc::c_uint; - break; - } else { - i = i.wrapping_add(1) - } + break ; + } else { i = i.wrapping_add(1) } } if output.default_sample_rate == 0 { - output.default_sample_rate = output.supported_rates[0 as libc::c_int as usize] + output.default_sample_rate = + output.supported_rates[0 as libc::c_int as usize] } output.current_sample_rate = output.default_sample_rate; - if loglevel as libc::c_uint >= crate::squeezelite_h::lINFO as libc::c_int as libc::c_uint { + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { let mut rates_buf: [libc::c_char; 180] = *::std::mem::transmute::<&[u8; 180], &mut [libc::c_char; 180]>(b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"); i = 0 as libc::c_int as libc::c_uint; while output.supported_rates[i as usize] != 0 { let mut s: [libc::c_char; 10] = [0; 10]; - crate::stdlib::sprintf( - s.as_mut_ptr(), - b"%d \x00" as *const u8 as *const libc::c_char, - output.supported_rates[i as usize], - ); - crate::stdlib::strcat(rates_buf.as_mut_ptr(), s.as_mut_ptr()); + sprintf(s.as_mut_ptr(), + b"%d \x00" as *const u8 as *const libc::c_char, + output.supported_rates[i as usize]); + strcat(rates_buf.as_mut_ptr(), s.as_mut_ptr()); i = i.wrapping_add(1) } - 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 supported rates: %s\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_common\x00", - )) - .as_ptr(), - 422 as libc::c_int, - rates_buf.as_mut_ptr(), - ); + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d supported rates: %s\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 19], + &[libc::c_char; 19]>(b"output_init_common\x00")).as_ptr(), + 422 as libc::c_int, rates_buf.as_mut_ptr()); } }; } #[no_mangle] - pub unsafe extern "C" fn output_close_common() { - crate::src::buffer::buf_destroy(outputbuf); - crate::stdlib::free(silencebuf as *mut libc::c_void); + buf_destroy(outputbuf); + free(silencebuf as *mut libc::c_void); } -/* +/* * 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 @@ -1126,27 +1107,24 @@ pub unsafe extern "C" fn output_close_common() { // set by slimproto // set by slimproto #[no_mangle] - pub unsafe extern "C" fn output_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 flush output buffer\n\x00" as *const u8 as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 13], &[libc::c_char; 13]>(b"output_flush\x00")) - .as_ptr(), - 435 as libc::c_int, - ); + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d flush output buffer\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 13], + &[libc::c_char; 13]>(b"output_flush\x00")).as_ptr(), + 435 as libc::c_int); } - crate::src::buffer::buf_flush(outputbuf); - crate::stdlib::pthread_mutex_lock(&mut (*outputbuf).mutex); - output.fade = crate::squeezelite_h::FADE_INACTIVE; - if output.state as libc::c_int != crate::squeezelite_h::OUTPUT_OFF as libc::c_int { - output.state = crate::squeezelite_h::OUTPUT_STOPPED; + buf_flush(outputbuf); + pthread_mutex_lock(&mut (*outputbuf).mutex); + output.fade = FADE_INACTIVE; + if output.state as libc::c_int != OUTPUT_OFF as libc::c_int { + output.state = OUTPUT_STOPPED; if output.error_opening { output.current_sample_rate = output.default_sample_rate } output.delay_active = 0 as libc::c_int != 0 } output.frames_played = 0 as libc::c_int as libc::c_uint; - crate::stdlib::pthread_mutex_unlock(&mut (*outputbuf).mutex); + pthread_mutex_unlock(&mut (*outputbuf).mutex); } diff --git a/src/output_alsa.rs b/src/output_alsa.rs index 408d7f3..340bf0c 100644 --- a/src/output_alsa.rs +++ b/src/output_alsa.rs @@ -1,554 +1,860 @@ 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; - -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::__useconds_t; -pub use crate::stdlib::int32_t; -pub use crate::stdlib::FILE; -pub use crate::stdlib::_IO_FILE; - -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_attr_t; -pub use crate::stdlib::pthread_mutex_t; -pub use crate::stdlib::pthread_t; -pub use crate::stdlib::sched_param; -pub use crate::stdlib::u_int32_t; -pub use crate::stdlib::u_int8_t; - -pub use crate::squeezelite_h::_apply_cross; -pub use crate::squeezelite_h::_apply_gain; -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::src::utils::next_param; -pub use crate::src::utils::touch_memory; -use crate::stdlib::__errno_location; -pub use crate::stdlib::_snd_mixer; -pub use crate::stdlib::_snd_mixer_class; -pub use crate::stdlib::_snd_mixer_elem; -pub use crate::stdlib::_snd_mixer_selem_channel_id; -pub use crate::stdlib::_snd_mixer_selem_id; -pub use crate::stdlib::_snd_output; -pub use crate::stdlib::_snd_pcm; -pub use crate::stdlib::_snd_pcm_access; -pub use crate::stdlib::_snd_pcm_channel_area; -pub use crate::stdlib::_snd_pcm_format; -pub use crate::stdlib::_snd_pcm_hw_params; -pub use crate::stdlib::_snd_pcm_state; -pub use crate::stdlib::_snd_pcm_stream; -use crate::stdlib::atoi; -use crate::stdlib::fflush; -use crate::stdlib::fprintf; -use crate::stdlib::free; -use crate::stdlib::malloc; -use crate::stdlib::memcpy; -use crate::stdlib::memset; -use crate::stdlib::printf; -pub use crate::stdlib::snd_lib_error_handler_t; -pub use crate::stdlib::snd_lib_error_set_handler; -pub use crate::stdlib::snd_mixer_attach; -pub use crate::stdlib::snd_mixer_class_t; -pub use crate::stdlib::snd_mixer_close; -pub use crate::stdlib::snd_mixer_elem_next; -pub use crate::stdlib::snd_mixer_elem_t; -pub use crate::stdlib::snd_mixer_find_selem; -pub use crate::stdlib::snd_mixer_first_elem; -pub use crate::stdlib::snd_mixer_load; -pub use crate::stdlib::snd_mixer_open; -pub use crate::stdlib::snd_mixer_selem_channel_id_t; -pub use crate::stdlib::snd_mixer_selem_get_id; -pub use crate::stdlib::snd_mixer_selem_get_playback_dB_range; -pub use crate::stdlib::snd_mixer_selem_get_playback_volume; -pub use crate::stdlib::snd_mixer_selem_get_playback_volume_range; -pub use crate::stdlib::snd_mixer_selem_has_playback_switch; -pub use crate::stdlib::snd_mixer_selem_has_playback_volume; -pub use crate::stdlib::snd_mixer_selem_id_get_index; -pub use crate::stdlib::snd_mixer_selem_id_get_name; -pub use crate::stdlib::snd_mixer_selem_id_set_index; -pub use crate::stdlib::snd_mixer_selem_id_set_name; -pub use crate::stdlib::snd_mixer_selem_id_sizeof; -pub use crate::stdlib::snd_mixer_selem_id_t; -pub use crate::stdlib::snd_mixer_selem_register; -pub use crate::stdlib::snd_mixer_selem_regopt; -pub use crate::stdlib::snd_mixer_selem_regopt_abstract; -pub use crate::stdlib::snd_mixer_selem_set_playback_dB; -pub use crate::stdlib::snd_mixer_selem_set_playback_switch_all; -pub use crate::stdlib::snd_mixer_selem_set_playback_volume; -pub use crate::stdlib::snd_mixer_t; -pub use crate::stdlib::snd_output_stdio_attach; -pub use crate::stdlib::snd_output_t; -pub use crate::stdlib::snd_pcm_access_t; -pub use crate::stdlib::snd_pcm_avail_update; -pub use crate::stdlib::snd_pcm_channel_area_t; -pub use crate::stdlib::snd_pcm_close; -pub use crate::stdlib::snd_pcm_delay; -pub use crate::stdlib::snd_pcm_dump; -pub use crate::stdlib::snd_pcm_format_name; -pub use crate::stdlib::snd_pcm_format_t; -pub use crate::stdlib::snd_pcm_hw_params; -pub use crate::stdlib::snd_pcm_hw_params_any; -pub use crate::stdlib::snd_pcm_hw_params_get_buffer_size; -pub use crate::stdlib::snd_pcm_hw_params_get_period_size; -pub use crate::stdlib::snd_pcm_hw_params_set_access; -pub use crate::stdlib::snd_pcm_hw_params_set_buffer_size_near; -pub use crate::stdlib::snd_pcm_hw_params_set_buffer_time_near; -pub use crate::stdlib::snd_pcm_hw_params_set_channels; -pub use crate::stdlib::snd_pcm_hw_params_set_format; -pub use crate::stdlib::snd_pcm_hw_params_set_period_size_near; -pub use crate::stdlib::snd_pcm_hw_params_set_periods_near; -pub use crate::stdlib::snd_pcm_hw_params_set_rate; -pub use crate::stdlib::snd_pcm_hw_params_set_rate_resample; -pub use crate::stdlib::snd_pcm_hw_params_sizeof; -pub use crate::stdlib::snd_pcm_hw_params_t; -pub use crate::stdlib::snd_pcm_hw_params_test_rate; -pub use crate::stdlib::snd_pcm_mmap_begin; -pub use crate::stdlib::snd_pcm_mmap_commit; -pub use crate::stdlib::snd_pcm_open; -pub use crate::stdlib::snd_pcm_recover; -pub use crate::stdlib::snd_pcm_sframes_t; -pub use crate::stdlib::snd_pcm_start; -pub use crate::stdlib::snd_pcm_state; -pub use crate::stdlib::snd_pcm_state_t; -pub use crate::stdlib::snd_pcm_stream_t; -pub use crate::stdlib::snd_pcm_t; -pub use crate::stdlib::snd_pcm_uframes_t; -pub use crate::stdlib::snd_pcm_wait; -pub use crate::stdlib::snd_pcm_writei; -pub use crate::stdlib::snd_strerror; -use crate::stdlib::stderr; -use crate::stdlib::strcmp; -use crate::stdlib::strcpy; -use crate::stdlib::strdup; -use crate::stdlib::strerror; -use crate::stdlib::strlen; -use crate::stdlib::strncmp; -use crate::stdlib::strrchr; -use crate::stdlib::strtok; -use crate::stdlib::vfprintf; -pub use crate::stdlib::SND_MIXER_SABSTRACT_BASIC; -pub use crate::stdlib::SND_MIXER_SABSTRACT_NONE; -pub use crate::stdlib::SND_MIXER_SCHN_FRONT_CENTER; -pub use crate::stdlib::SND_MIXER_SCHN_FRONT_LEFT; -pub use crate::stdlib::SND_MIXER_SCHN_FRONT_RIGHT; -pub use crate::stdlib::SND_MIXER_SCHN_LAST; -pub use crate::stdlib::SND_MIXER_SCHN_MONO; -pub use crate::stdlib::SND_MIXER_SCHN_REAR_CENTER; -pub use crate::stdlib::SND_MIXER_SCHN_REAR_LEFT; -pub use crate::stdlib::SND_MIXER_SCHN_REAR_RIGHT; -pub use crate::stdlib::SND_MIXER_SCHN_SIDE_LEFT; -pub use crate::stdlib::SND_MIXER_SCHN_SIDE_RIGHT; -pub use crate::stdlib::SND_MIXER_SCHN_UNKNOWN; -pub use crate::stdlib::SND_MIXER_SCHN_WOOFER; -pub use crate::stdlib::SND_PCM_ACCESS_LAST; -pub use crate::stdlib::SND_PCM_ACCESS_MMAP_COMPLEX; -pub use crate::stdlib::SND_PCM_ACCESS_MMAP_INTERLEAVED; -pub use crate::stdlib::SND_PCM_ACCESS_MMAP_NONINTERLEAVED; -pub use crate::stdlib::SND_PCM_ACCESS_RW_INTERLEAVED; -pub use crate::stdlib::SND_PCM_ACCESS_RW_NONINTERLEAVED; -pub use crate::stdlib::SND_PCM_FORMAT_A_LAW; -pub use crate::stdlib::SND_PCM_FORMAT_DSD_U16_BE; -pub use crate::stdlib::SND_PCM_FORMAT_DSD_U16_LE; -pub use crate::stdlib::SND_PCM_FORMAT_DSD_U32_BE; -pub use crate::stdlib::SND_PCM_FORMAT_DSD_U32_LE; -pub use crate::stdlib::SND_PCM_FORMAT_DSD_U8; -pub use crate::stdlib::SND_PCM_FORMAT_FLOAT; -pub use crate::stdlib::SND_PCM_FORMAT_FLOAT64; -pub use crate::stdlib::SND_PCM_FORMAT_FLOAT64_BE; -pub use crate::stdlib::SND_PCM_FORMAT_FLOAT64_LE; -pub use crate::stdlib::SND_PCM_FORMAT_FLOAT_BE; -pub use crate::stdlib::SND_PCM_FORMAT_FLOAT_LE; -pub use crate::stdlib::SND_PCM_FORMAT_G723_24; -pub use crate::stdlib::SND_PCM_FORMAT_G723_24_1B; -pub use crate::stdlib::SND_PCM_FORMAT_G723_40; -pub use crate::stdlib::SND_PCM_FORMAT_G723_40_1B; -pub use crate::stdlib::SND_PCM_FORMAT_GSM; -pub use crate::stdlib::SND_PCM_FORMAT_IEC958_SUBFRAME; -pub use crate::stdlib::SND_PCM_FORMAT_IEC958_SUBFRAME_BE; -pub use crate::stdlib::SND_PCM_FORMAT_IEC958_SUBFRAME_LE; -pub use crate::stdlib::SND_PCM_FORMAT_IMA_ADPCM; -pub use crate::stdlib::SND_PCM_FORMAT_LAST; -pub use crate::stdlib::SND_PCM_FORMAT_MPEG; -pub use crate::stdlib::SND_PCM_FORMAT_MU_LAW; -pub use crate::stdlib::SND_PCM_FORMAT_S16; -pub use crate::stdlib::SND_PCM_FORMAT_S16_BE; -pub use crate::stdlib::SND_PCM_FORMAT_S16_LE; -pub use crate::stdlib::SND_PCM_FORMAT_S18_3BE; -pub use crate::stdlib::SND_PCM_FORMAT_S18_3LE; -pub use crate::stdlib::SND_PCM_FORMAT_S20; -pub use crate::stdlib::SND_PCM_FORMAT_S20_3BE; -pub use crate::stdlib::SND_PCM_FORMAT_S20_3LE; -pub use crate::stdlib::SND_PCM_FORMAT_S20_BE; -pub use crate::stdlib::SND_PCM_FORMAT_S20_LE; -pub use crate::stdlib::SND_PCM_FORMAT_S24; -pub use crate::stdlib::SND_PCM_FORMAT_S24_3BE; -pub use crate::stdlib::SND_PCM_FORMAT_S24_3LE; -pub use crate::stdlib::SND_PCM_FORMAT_S24_BE; -pub use crate::stdlib::SND_PCM_FORMAT_S24_LE; -pub use crate::stdlib::SND_PCM_FORMAT_S32; -pub use crate::stdlib::SND_PCM_FORMAT_S32_BE; -pub use crate::stdlib::SND_PCM_FORMAT_S32_LE; -pub use crate::stdlib::SND_PCM_FORMAT_S8; -pub use crate::stdlib::SND_PCM_FORMAT_SPECIAL; -pub use crate::stdlib::SND_PCM_FORMAT_U16; -pub use crate::stdlib::SND_PCM_FORMAT_U16_BE; -pub use crate::stdlib::SND_PCM_FORMAT_U16_LE; -pub use crate::stdlib::SND_PCM_FORMAT_U18_3BE; -pub use crate::stdlib::SND_PCM_FORMAT_U18_3LE; -pub use crate::stdlib::SND_PCM_FORMAT_U20; -pub use crate::stdlib::SND_PCM_FORMAT_U20_3BE; -pub use crate::stdlib::SND_PCM_FORMAT_U20_3LE; -pub use crate::stdlib::SND_PCM_FORMAT_U20_BE; -pub use crate::stdlib::SND_PCM_FORMAT_U20_LE; -pub use crate::stdlib::SND_PCM_FORMAT_U24; -pub use crate::stdlib::SND_PCM_FORMAT_U24_3BE; -pub use crate::stdlib::SND_PCM_FORMAT_U24_3LE; -pub use crate::stdlib::SND_PCM_FORMAT_U24_BE; -pub use crate::stdlib::SND_PCM_FORMAT_U24_LE; -pub use crate::stdlib::SND_PCM_FORMAT_U32; -pub use crate::stdlib::SND_PCM_FORMAT_U32_BE; -pub use crate::stdlib::SND_PCM_FORMAT_U32_LE; -pub use crate::stdlib::SND_PCM_FORMAT_U8; -pub use crate::stdlib::SND_PCM_FORMAT_UNKNOWN; -pub use crate::stdlib::SND_PCM_STATE_DISCONNECTED; -pub use crate::stdlib::SND_PCM_STATE_DRAINING; -pub use crate::stdlib::SND_PCM_STATE_LAST; -pub use crate::stdlib::SND_PCM_STATE_OPEN; -pub use crate::stdlib::SND_PCM_STATE_PAUSED; -pub use crate::stdlib::SND_PCM_STATE_PREPARED; -pub use crate::stdlib::SND_PCM_STATE_PRIVATE1; -pub use crate::stdlib::SND_PCM_STATE_RUNNING; -pub use crate::stdlib::SND_PCM_STATE_SETUP; -pub use crate::stdlib::SND_PCM_STATE_SUSPENDED; -pub use crate::stdlib::SND_PCM_STATE_XRUN; -pub use crate::stdlib::SND_PCM_STREAM_CAPTURE; -pub use crate::stdlib::SND_PCM_STREAM_LAST; -pub use crate::stdlib::SND_PCM_STREAM_PLAYBACK; - -use crate::stdlib::floor; -use crate::stdlib::log10; -use crate::stdlib::mallopt; -use crate::stdlib::mlockall; -use crate::stdlib::pthread_attr_destroy; -use crate::stdlib::pthread_attr_init; -use crate::stdlib::pthread_attr_setstacksize; -use crate::stdlib::pthread_create; -use crate::stdlib::pthread_join; -use crate::stdlib::pthread_mutex_lock; -use crate::stdlib::pthread_mutex_unlock; -use crate::stdlib::pthread_setschedparam; -use crate::stdlib::sleep; -use crate::stdlib::snd_device_name_free_hint; -use crate::stdlib::snd_device_name_get_hint; -use crate::stdlib::snd_device_name_hint; -use crate::stdlib::usleep; extern "C" { + pub type _IO_wide_data; + pub type _IO_codecvt; + pub type _IO_marker; + pub type _snd_mixer; + pub type _snd_mixer_selem_id; + pub type _snd_mixer_elem; + pub type _snd_mixer_class; + pub type _snd_pcm; + pub type _snd_pcm_hw_params; + pub type _snd_output; #[no_mangle] - pub static mut silencebuf: *mut crate::squeezelite_h::u8_t; + static mut stderr: *mut FILE; #[no_mangle] - pub static mut output: crate::squeezelite_h::outputstate; + fn fflush(__stream: *mut FILE) -> libc::c_int; #[no_mangle] - pub static mut outputbuf: *mut crate::squeezelite_h::buffer; + fn fprintf(_: *mut FILE, _: *const libc::c_char, _: ...) -> libc::c_int; + #[no_mangle] + fn printf(_: *const libc::c_char, _: ...) -> libc::c_int; + #[no_mangle] + fn vfprintf(_: *mut FILE, _: *const libc::c_char, _: ::std::ffi::VaList) + -> libc::c_int; + #[no_mangle] + fn atoi(__nptr: *const libc::c_char) -> libc::c_int; + #[no_mangle] + fn malloc(_: libc::c_ulong) -> *mut libc::c_void; + #[no_mangle] + fn free(__ptr: *mut libc::c_void); + #[no_mangle] + fn memcpy(_: *mut libc::c_void, _: *const libc::c_void, _: libc::c_ulong) + -> *mut libc::c_void; + #[no_mangle] + fn memset(_: *mut libc::c_void, _: libc::c_int, _: libc::c_ulong) + -> *mut libc::c_void; + #[no_mangle] + fn strcpy(_: *mut libc::c_char, _: *const libc::c_char) + -> *mut libc::c_char; + #[no_mangle] + fn strcmp(_: *const libc::c_char, _: *const libc::c_char) -> libc::c_int; + #[no_mangle] + fn strncmp(_: *const libc::c_char, _: *const libc::c_char, + _: libc::c_ulong) -> libc::c_int; + #[no_mangle] + fn strdup(_: *const libc::c_char) -> *mut libc::c_char; + #[no_mangle] + fn strrchr(_: *const libc::c_char, _: libc::c_int) -> *mut libc::c_char; + #[no_mangle] + fn strtok(_: *mut libc::c_char, _: *const libc::c_char) + -> *mut libc::c_char; + #[no_mangle] + fn strlen(_: *const libc::c_char) -> libc::c_ulong; + #[no_mangle] + fn strerror(_: libc::c_int) -> *mut libc::c_char; + #[no_mangle] + fn __errno_location() -> *mut libc::c_int; + #[no_mangle] + fn sleep(__seconds: libc::c_uint) -> libc::c_uint; + #[no_mangle] + fn usleep(__useconds: __useconds_t) -> libc::c_int; + #[no_mangle] + fn pthread_create(__newthread: *mut pthread_t, + __attr: *const pthread_attr_t, + __start_routine: + Option *mut libc::c_void>, + __arg: *mut libc::c_void) -> libc::c_int; + #[no_mangle] + fn pthread_join(__th: pthread_t, __thread_return: *mut *mut libc::c_void) + -> libc::c_int; + #[no_mangle] + fn pthread_attr_init(__attr: *mut pthread_attr_t) -> libc::c_int; + #[no_mangle] + fn pthread_attr_destroy(__attr: *mut pthread_attr_t) -> libc::c_int; + #[no_mangle] + fn pthread_attr_setstacksize(__attr: *mut pthread_attr_t, + __stacksize: size_t) -> libc::c_int; + #[no_mangle] + fn pthread_setschedparam(__target_thread: pthread_t, + __policy: libc::c_int, + __param: *const sched_param) -> libc::c_int; + #[no_mangle] + fn pthread_mutex_lock(__mutex: *mut pthread_mutex_t) -> libc::c_int; + #[no_mangle] + fn pthread_mutex_unlock(__mutex: *mut pthread_mutex_t) -> libc::c_int; + #[no_mangle] + fn logtime() -> *const libc::c_char; + #[no_mangle] + fn logprint(fmt: *const libc::c_char, _: ...); + #[no_mangle] + fn next_param(src: *mut libc::c_char, c: libc::c_char) + -> *mut libc::c_char; + #[no_mangle] + fn gettime_ms() -> u32_t; + #[no_mangle] + fn touch_memory(buf: *mut u8_t, size: size_t); + #[no_mangle] + fn output_init_common(level: log_level, device: *const libc::c_char, + output_buf_size: libc::c_uint, + rates: *mut libc::c_uint, idle: libc::c_uint); + #[no_mangle] + fn output_close_common(); + #[no_mangle] + fn _output_frames(avail: frames_t) -> frames_t; + #[no_mangle] + fn _apply_cross(outputbuf_0: *mut buffer, out_frames: frames_t, + cross_gain_in: s32_t, cross_gain_out: s32_t, + cross_ptr: *mut *mut s32_t); + #[no_mangle] + fn _scale_and_pack_frames(outputptr: *mut libc::c_void, + inputptr: *mut s32_t, cnt: frames_t, + gainL: s32_t, gainR: s32_t, + format: output_format); + #[no_mangle] + fn _apply_gain(outputbuf_0: *mut buffer, count: frames_t, gainL: s32_t, + gainR: s32_t); + #[no_mangle] + fn snd_pcm_open(pcm: *mut *mut snd_pcm_t, name: *const libc::c_char, + stream: snd_pcm_stream_t, mode: libc::c_int) + -> libc::c_int; + #[no_mangle] + fn snd_pcm_close(pcm: *mut snd_pcm_t) -> libc::c_int; + #[no_mangle] + fn snd_pcm_hw_params(pcm: *mut snd_pcm_t, + params: *mut snd_pcm_hw_params_t) -> libc::c_int; + #[no_mangle] + fn snd_pcm_start(pcm: *mut snd_pcm_t) -> libc::c_int; + #[no_mangle] + fn snd_pcm_state(pcm: *mut snd_pcm_t) -> snd_pcm_state_t; + #[no_mangle] + fn snd_pcm_delay(pcm: *mut snd_pcm_t, delayp: *mut snd_pcm_sframes_t) + -> libc::c_int; + #[no_mangle] + fn snd_pcm_avail_update(pcm: *mut snd_pcm_t) -> snd_pcm_sframes_t; + #[no_mangle] + fn snd_pcm_writei(pcm: *mut snd_pcm_t, buffer: *const libc::c_void, + size: snd_pcm_uframes_t) -> snd_pcm_sframes_t; + #[no_mangle] + fn snd_pcm_wait(pcm: *mut snd_pcm_t, timeout: libc::c_int) -> libc::c_int; + #[no_mangle] + fn snd_pcm_recover(pcm: *mut snd_pcm_t, err: libc::c_int, + silent: libc::c_int) -> libc::c_int; + #[no_mangle] + fn snd_pcm_hw_params_any(pcm: *mut snd_pcm_t, + params: *mut snd_pcm_hw_params_t) -> libc::c_int; + #[no_mangle] + fn snd_pcm_hw_params_sizeof() -> size_t; + #[no_mangle] + fn snd_pcm_hw_params_set_access(pcm: *mut snd_pcm_t, + params: *mut snd_pcm_hw_params_t, + _access: snd_pcm_access_t) -> libc::c_int; + #[no_mangle] + fn snd_pcm_hw_params_set_format(pcm: *mut snd_pcm_t, + params: *mut snd_pcm_hw_params_t, + val: snd_pcm_format_t) -> libc::c_int; + #[no_mangle] + fn snd_pcm_hw_params_set_channels(pcm: *mut snd_pcm_t, + params: *mut snd_pcm_hw_params_t, + val: libc::c_uint) -> libc::c_int; + #[no_mangle] + fn snd_pcm_hw_params_test_rate(pcm: *mut snd_pcm_t, + params: *mut snd_pcm_hw_params_t, + val: libc::c_uint, dir: libc::c_int) + -> libc::c_int; + #[no_mangle] + fn snd_pcm_hw_params_set_rate(pcm: *mut snd_pcm_t, + params: *mut snd_pcm_hw_params_t, + val: libc::c_uint, dir: libc::c_int) + -> libc::c_int; + #[no_mangle] + fn snd_pcm_hw_params_set_rate_resample(pcm: *mut snd_pcm_t, + params: *mut snd_pcm_hw_params_t, + val: libc::c_uint) -> libc::c_int; + #[no_mangle] + fn snd_pcm_hw_params_get_period_size(params: *const snd_pcm_hw_params_t, + frames: *mut snd_pcm_uframes_t, + dir: *mut libc::c_int) + -> libc::c_int; + #[no_mangle] + fn snd_pcm_hw_params_set_period_size_near(pcm: *mut snd_pcm_t, + params: + *mut snd_pcm_hw_params_t, + val: *mut snd_pcm_uframes_t, + dir: *mut libc::c_int) + -> libc::c_int; + #[no_mangle] + fn snd_pcm_hw_params_set_periods_near(pcm: *mut snd_pcm_t, + params: *mut snd_pcm_hw_params_t, + val: *mut libc::c_uint, + dir: *mut libc::c_int) + -> libc::c_int; + #[no_mangle] + fn snd_pcm_hw_params_set_buffer_time_near(pcm: *mut snd_pcm_t, + params: + *mut snd_pcm_hw_params_t, + val: *mut libc::c_uint, + dir: *mut libc::c_int) + -> libc::c_int; + #[no_mangle] + fn snd_pcm_hw_params_get_buffer_size(params: *const snd_pcm_hw_params_t, + val: *mut snd_pcm_uframes_t) + -> libc::c_int; + #[no_mangle] + fn snd_pcm_hw_params_set_buffer_size_near(pcm: *mut snd_pcm_t, + params: + *mut snd_pcm_hw_params_t, + val: *mut snd_pcm_uframes_t) + -> libc::c_int; + #[no_mangle] + fn snd_pcm_format_name(format: snd_pcm_format_t) -> *const libc::c_char; + #[no_mangle] + fn snd_mixer_find_selem(mixer: *mut snd_mixer_t, + id: *const snd_mixer_selem_id_t) + -> *mut snd_mixer_elem_t; + #[no_mangle] + fn snd_device_name_free_hint(hints: *mut *mut libc::c_void) + -> libc::c_int; + #[no_mangle] + fn snd_pcm_mmap_begin(pcm: *mut snd_pcm_t, + areas: *mut *const snd_pcm_channel_area_t, + offset: *mut snd_pcm_uframes_t, + frames: *mut snd_pcm_uframes_t) -> libc::c_int; + #[no_mangle] + fn snd_pcm_mmap_commit(pcm: *mut snd_pcm_t, offset: snd_pcm_uframes_t, + frames: snd_pcm_uframes_t) -> snd_pcm_sframes_t; + #[no_mangle] + fn snd_device_name_get_hint(hint: *const libc::c_void, + id: *const libc::c_char) -> *mut libc::c_char; + #[no_mangle] + fn snd_lib_error_set_handler(handler: snd_lib_error_handler_t) + -> libc::c_int; + #[no_mangle] + fn snd_device_name_hint(card: libc::c_int, iface: *const libc::c_char, + hints: *mut *mut *mut libc::c_void) + -> libc::c_int; + #[no_mangle] + fn snd_mixer_selem_id_set_index(obj: *mut snd_mixer_selem_id_t, + val: libc::c_uint); + #[no_mangle] + fn snd_mixer_selem_id_set_name(obj: *mut snd_mixer_selem_id_t, + val: *const libc::c_char); + #[no_mangle] + fn snd_mixer_close(mixer: *mut snd_mixer_t) -> libc::c_int; + #[no_mangle] + fn snd_mixer_selem_has_playback_switch(elem: *mut snd_mixer_elem_t) + -> libc::c_int; + #[no_mangle] + fn snd_mixer_selem_set_playback_switch_all(elem: *mut snd_mixer_elem_t, + value: libc::c_int) + -> libc::c_int; + #[no_mangle] + fn snd_mixer_selem_get_playback_dB_range(elem: *mut snd_mixer_elem_t, + min: *mut libc::c_long, + max: *mut libc::c_long) + -> libc::c_int; + #[no_mangle] + fn snd_mixer_selem_get_playback_volume_range(elem: *mut snd_mixer_elem_t, + min: *mut libc::c_long, + max: *mut libc::c_long) + -> libc::c_int; + #[no_mangle] + fn snd_output_stdio_attach(outputp: *mut *mut snd_output_t, fp: *mut FILE, + _close: libc::c_int) -> libc::c_int; + #[no_mangle] + fn snd_pcm_dump(pcm: *mut snd_pcm_t, out: *mut snd_output_t) + -> libc::c_int; + #[no_mangle] + fn snd_mixer_selem_set_playback_volume(elem: *mut snd_mixer_elem_t, + channel: + snd_mixer_selem_channel_id_t, + value: libc::c_long) + -> libc::c_int; + #[no_mangle] + fn snd_mixer_selem_set_playback_dB(elem: *mut snd_mixer_elem_t, + channel: snd_mixer_selem_channel_id_t, + value: libc::c_long, dir: libc::c_int) + -> libc::c_int; + #[no_mangle] + fn snd_mixer_selem_get_playback_volume(elem: *mut snd_mixer_elem_t, + channel: + snd_mixer_selem_channel_id_t, + value: *mut libc::c_long) + -> libc::c_int; + #[no_mangle] + fn snd_mixer_selem_id_sizeof() -> size_t; + #[no_mangle] + fn snd_mixer_open(mixer: *mut *mut snd_mixer_t, mode: libc::c_int) + -> libc::c_int; + #[no_mangle] + fn snd_mixer_attach(mixer: *mut snd_mixer_t, name: *const libc::c_char) + -> libc::c_int; + #[no_mangle] + fn snd_mixer_selem_register(mixer: *mut snd_mixer_t, + options: *mut snd_mixer_selem_regopt, + classp: *mut *mut snd_mixer_class_t) + -> libc::c_int; + #[no_mangle] + fn snd_mixer_load(mixer: *mut snd_mixer_t) -> libc::c_int; + #[no_mangle] + fn snd_strerror(errnum: libc::c_int) -> *const libc::c_char; + #[no_mangle] + fn snd_mixer_first_elem(mixer: *mut snd_mixer_t) -> *mut snd_mixer_elem_t; + #[no_mangle] + fn snd_mixer_elem_next(elem: *mut snd_mixer_elem_t) + -> *mut snd_mixer_elem_t; + #[no_mangle] + fn snd_mixer_selem_has_playback_volume(elem: *mut snd_mixer_elem_t) + -> libc::c_int; + #[no_mangle] + fn snd_mixer_selem_get_id(element: *mut snd_mixer_elem_t, + id: *mut snd_mixer_selem_id_t); + #[no_mangle] + fn snd_mixer_selem_id_get_name(obj: *const snd_mixer_selem_id_t) + -> *const libc::c_char; + #[no_mangle] + fn snd_mixer_selem_id_get_index(obj: *const snd_mixer_selem_id_t) + -> libc::c_uint; + #[no_mangle] + fn mlockall(__flags: libc::c_int) -> libc::c_int; + #[no_mangle] + fn mallopt(__param: libc::c_int, __val: libc::c_int) -> libc::c_int; + #[no_mangle] + fn log10(_: libc::c_double) -> libc::c_double; + #[no_mangle] + fn floor(_: libc::c_double) -> libc::c_double; + #[no_mangle] + static mut silencebuf: *mut u8_t; + #[no_mangle] + static mut output: outputstate; + #[no_mangle] + static mut outputbuf: *mut buffer; } -// ouput device - -#[repr(C)] +pub type __builtin_va_list = [__va_list_tag; 1]; #[derive(Copy, Clone)] -pub struct C2RustUnnamed_12 { +#[repr(C)] +pub struct __va_list_tag { + pub gp_offset: libc::c_uint, + pub fp_offset: libc::c_uint, + pub overflow_arg_area: *mut libc::c_void, + pub reg_save_area: *mut libc::c_void, +} +pub type size_t = libc::c_ulong; +pub type va_list = __builtin_va_list; +pub type __uint8_t = libc::c_uchar; +pub type __int32_t = libc::c_int; +pub type __uint32_t = libc::c_uint; +pub type __off_t = libc::c_long; +pub type __off64_t = libc::c_long; +pub type __useconds_t = libc::c_uint; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct _IO_FILE { + pub _flags: libc::c_int, + pub _IO_read_ptr: *mut libc::c_char, + pub _IO_read_end: *mut libc::c_char, + pub _IO_read_base: *mut libc::c_char, + pub _IO_write_base: *mut libc::c_char, + pub _IO_write_ptr: *mut libc::c_char, + pub _IO_write_end: *mut libc::c_char, + pub _IO_buf_base: *mut libc::c_char, + pub _IO_buf_end: *mut libc::c_char, + pub _IO_save_base: *mut libc::c_char, + pub _IO_backup_base: *mut libc::c_char, + pub _IO_save_end: *mut libc::c_char, + pub _markers: *mut _IO_marker, + pub _chain: *mut _IO_FILE, + pub _fileno: libc::c_int, + pub _flags2: libc::c_int, + pub _old_offset: __off_t, + pub _cur_column: libc::c_ushort, + pub _vtable_offset: libc::c_schar, + pub _shortbuf: [libc::c_char; 1], + pub _lock: *mut libc::c_void, + pub _offset: __off64_t, + pub _codecvt: *mut _IO_codecvt, + pub _wide_data: *mut _IO_wide_data, + pub _freeres_list: *mut _IO_FILE, + pub _freeres_buf: *mut libc::c_void, + pub __pad5: size_t, + pub _mode: libc::c_int, + pub _unused2: [libc::c_char; 20], +} +pub type _IO_lock_t = (); +pub type FILE = _IO_FILE; +pub type int32_t = __int32_t; +pub type u_int8_t = __uint8_t; +pub type u_int32_t = __uint32_t; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct __pthread_internal_list { + pub __prev: *mut __pthread_internal_list, + pub __next: *mut __pthread_internal_list, +} +pub type __pthread_list_t = __pthread_internal_list; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct __pthread_mutex_s { + pub __lock: libc::c_int, + pub __count: libc::c_uint, + pub __owner: libc::c_int, + pub __nusers: libc::c_uint, + pub __kind: libc::c_int, + pub __spins: libc::c_short, + pub __elision: libc::c_short, + pub __list: __pthread_list_t, +} +pub type pthread_t = libc::c_ulong; +#[derive(Copy, Clone)] +#[repr(C)] +pub union pthread_attr_t { + pub __size: [libc::c_char; 56], + pub __align: libc::c_long, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub union pthread_mutex_t { + pub __data: __pthread_mutex_s, + pub __size: [libc::c_char; 40], + pub __align: libc::c_long, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct sched_param { + pub sched_priority: libc::c_int, +} +pub type u8_t = u_int8_t; +pub type u32_t = u_int32_t; +pub type s32_t = int32_t; +pub type frames_t = u32_t; +pub type log_level = libc::c_uint; +pub const lSDEBUG: log_level = 4; +pub const lDEBUG: log_level = 3; +pub const lINFO: log_level = 2; +pub const lWARN: log_level = 1; +pub const lERROR: log_level = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct buffer { + pub buf: *mut u8_t, + pub readp: *mut u8_t, + pub writep: *mut u8_t, + pub wrap: *mut u8_t, + pub size: size_t, + pub base_size: size_t, + pub mutex: pthread_mutex_t, +} +pub type output_state = libc::c_int; +pub const OUTPUT_START_AT: output_state = 5; +pub const OUTPUT_SKIP_FRAMES: output_state = 4; +pub const OUTPUT_PAUSE_FRAMES: output_state = 3; +pub const OUTPUT_RUNNING: output_state = 2; +pub const OUTPUT_BUFFER: output_state = 1; +pub const OUTPUT_STOPPED: output_state = 0; +pub const OUTPUT_OFF: output_state = -1; +pub type output_format = libc::c_uint; +pub const S16_LE: output_format = 3; +pub const S24_3LE: output_format = 2; +pub const S24_LE: output_format = 1; +pub const S32_LE: output_format = 0; +pub type fade_state = libc::c_uint; +pub const FADE_ACTIVE: fade_state = 2; +pub const FADE_DUE: fade_state = 1; +pub const FADE_INACTIVE: fade_state = 0; +pub type fade_dir = libc::c_uint; +pub const FADE_CROSS: fade_dir = 3; +pub const FADE_DOWN: fade_dir = 2; +pub const FADE_UP: fade_dir = 1; +pub type fade_mode = libc::c_uint; +pub const FADE_INOUT: fade_mode = 4; +pub const FADE_OUT: fade_mode = 3; +pub const FADE_IN: fade_mode = 2; +pub const FADE_CROSSFADE: fade_mode = 1; +pub const FADE_NONE: fade_mode = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct outputstate { + pub state: output_state, + pub format: output_format, + pub device: *const libc::c_char, + pub buffer: libc::c_uint, + pub period: libc::c_uint, + pub track_started: bool, + pub write_cb: Option libc::c_int>, + pub start_frames: libc::c_uint, + pub frames_played: libc::c_uint, + pub frames_played_dmp: libc::c_uint, + pub current_sample_rate: libc::c_uint, + pub supported_rates: [libc::c_uint; 18], + pub default_sample_rate: libc::c_uint, + pub error_opening: bool, + pub device_frames: libc::c_uint, + pub updated: u32_t, + pub track_start_time: u32_t, + pub current_replay_gain: u32_t, + pub c2rust_unnamed: C2RustUnnamed, + pub next_sample_rate: libc::c_uint, + pub track_start: *mut u8_t, + pub gainL: u32_t, + pub gainR: u32_t, + pub invert: bool, + pub next_replay_gain: u32_t, + pub threshold: libc::c_uint, + pub fade: fade_state, + pub fade_start: *mut u8_t, + pub fade_end: *mut u8_t, + pub fade_dir: fade_dir, + pub fade_mode: fade_mode, + pub fade_secs: libc::c_uint, + pub rate_delay: libc::c_uint, + pub delay_active: bool, + pub stop_time: u32_t, + pub idle_to: u32_t, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub union C2RustUnnamed { + pub pause_frames: u32_t, + pub skip_frames: u32_t, + pub start_at: u32_t, +} +pub type snd_mixer_t = _snd_mixer; +pub type snd_mixer_selem_id_t = _snd_mixer_selem_id; +pub type snd_mixer_elem_t = _snd_mixer_elem; +pub type snd_mixer_class_t = _snd_mixer_class; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct snd_mixer_selem_regopt { + pub ver: libc::c_int, + pub abstract_0: snd_mixer_selem_regopt_abstract, + pub device: *const libc::c_char, + pub playback_pcm: *mut snd_pcm_t, + pub capture_pcm: *mut snd_pcm_t, +} +pub type snd_pcm_t = _snd_pcm; +pub type snd_mixer_selem_regopt_abstract = libc::c_uint; +pub const SND_MIXER_SABSTRACT_BASIC: snd_mixer_selem_regopt_abstract = 1; +pub const SND_MIXER_SABSTRACT_NONE: snd_mixer_selem_regopt_abstract = 0; +// ouput device +#[derive(Copy, Clone)] +#[repr(C)] +pub struct C2RustUnnamed_0 { pub device: [libc::c_char; 129], pub ctl: *mut libc::c_char, pub mixer_ctl: *mut libc::c_char, - pub format: crate::stdlib::snd_pcm_format_t, - pub buffer_size: crate::stdlib::snd_pcm_uframes_t, - pub period_size: crate::stdlib::snd_pcm_uframes_t, + pub format: snd_pcm_format_t, + pub buffer_size: snd_pcm_uframes_t, + pub period_size: snd_pcm_uframes_t, pub rate: libc::c_uint, pub mmap: bool, pub reopen: bool, - pub write_buf: *mut crate::squeezelite_h::u8_t, + pub write_buf: *mut u8_t, pub volume_mixer_name: *const libc::c_char, pub mixer_linear: bool, - pub mixer_elem: *mut crate::stdlib::snd_mixer_elem_t, - pub mixer_handle: *mut crate::stdlib::snd_mixer_t, + pub mixer_elem: *mut snd_mixer_elem_t, + pub mixer_handle: *mut snd_mixer_t, pub mixer_min: libc::c_long, pub mixer_max: libc::c_long, } - -static mut fmts: [crate::stdlib::snd_pcm_format_t; 5] = [ - crate::stdlib::SND_PCM_FORMAT_S32_LE, - crate::stdlib::SND_PCM_FORMAT_S24_LE, - crate::stdlib::SND_PCM_FORMAT_S24_3LE, - crate::stdlib::SND_PCM_FORMAT_S16_LE, - crate::stdlib::SND_PCM_FORMAT_UNKNOWN, -]; - -static mut alsa: C2RustUnnamed_12 = C2RustUnnamed_12 { - device: [0; 129], - ctl: 0 as *const libc::c_char as *mut libc::c_char, - mixer_ctl: 0 as *const libc::c_char as *mut libc::c_char, - format: crate::stdlib::SND_PCM_FORMAT_S8, - buffer_size: 0, - period_size: 0, - rate: 0, - mmap: false, - reopen: false, - write_buf: 0 as *const crate::squeezelite_h::u8_t as *mut crate::squeezelite_h::u8_t, - volume_mixer_name: 0 as *const libc::c_char, - mixer_linear: false, - mixer_elem: 0 as *const crate::stdlib::snd_mixer_elem_t as *mut crate::stdlib::snd_mixer_elem_t, - mixer_handle: 0 as *const crate::stdlib::snd_mixer_t as *mut crate::stdlib::snd_mixer_t, - mixer_min: 0, - mixer_max: 0, -}; - -static mut pcmp: *mut crate::stdlib::snd_pcm_t = - 0 as *const crate::stdlib::snd_pcm_t as *mut crate::stdlib::snd_pcm_t; - -static mut loglevel: crate::squeezelite_h::log_level = crate::squeezelite_h::lERROR; - +pub type snd_pcm_uframes_t = libc::c_ulong; +pub type snd_pcm_format_t = _snd_pcm_format; +pub type _snd_pcm_format = libc::c_int; +pub const SND_PCM_FORMAT_U20: _snd_pcm_format = 27; +pub const SND_PCM_FORMAT_S20: _snd_pcm_format = 25; +pub const SND_PCM_FORMAT_IEC958_SUBFRAME: _snd_pcm_format = 18; +pub const SND_PCM_FORMAT_FLOAT64: _snd_pcm_format = 16; +pub const SND_PCM_FORMAT_FLOAT: _snd_pcm_format = 14; +pub const SND_PCM_FORMAT_U32: _snd_pcm_format = 12; +pub const SND_PCM_FORMAT_S32: _snd_pcm_format = 10; +pub const SND_PCM_FORMAT_U24: _snd_pcm_format = 8; +pub const SND_PCM_FORMAT_S24: _snd_pcm_format = 6; +pub const SND_PCM_FORMAT_U16: _snd_pcm_format = 4; +pub const SND_PCM_FORMAT_S16: _snd_pcm_format = 2; +pub const SND_PCM_FORMAT_LAST: _snd_pcm_format = 52; +pub const SND_PCM_FORMAT_DSD_U32_BE: _snd_pcm_format = 52; +pub const SND_PCM_FORMAT_DSD_U16_BE: _snd_pcm_format = 51; +pub const SND_PCM_FORMAT_DSD_U32_LE: _snd_pcm_format = 50; +pub const SND_PCM_FORMAT_DSD_U16_LE: _snd_pcm_format = 49; +pub const SND_PCM_FORMAT_DSD_U8: _snd_pcm_format = 48; +pub const SND_PCM_FORMAT_G723_40_1B: _snd_pcm_format = 47; +pub const SND_PCM_FORMAT_G723_40: _snd_pcm_format = 46; +pub const SND_PCM_FORMAT_G723_24_1B: _snd_pcm_format = 45; +pub const SND_PCM_FORMAT_G723_24: _snd_pcm_format = 44; +pub const SND_PCM_FORMAT_U18_3BE: _snd_pcm_format = 43; +pub const SND_PCM_FORMAT_U18_3LE: _snd_pcm_format = 42; +pub const SND_PCM_FORMAT_S18_3BE: _snd_pcm_format = 41; +pub const SND_PCM_FORMAT_S18_3LE: _snd_pcm_format = 40; +pub const SND_PCM_FORMAT_U20_3BE: _snd_pcm_format = 39; +pub const SND_PCM_FORMAT_U20_3LE: _snd_pcm_format = 38; +pub const SND_PCM_FORMAT_S20_3BE: _snd_pcm_format = 37; +pub const SND_PCM_FORMAT_S20_3LE: _snd_pcm_format = 36; +pub const SND_PCM_FORMAT_U24_3BE: _snd_pcm_format = 35; +pub const SND_PCM_FORMAT_U24_3LE: _snd_pcm_format = 34; +pub const SND_PCM_FORMAT_S24_3BE: _snd_pcm_format = 33; +pub const SND_PCM_FORMAT_S24_3LE: _snd_pcm_format = 32; +pub const SND_PCM_FORMAT_SPECIAL: _snd_pcm_format = 31; +pub const SND_PCM_FORMAT_U20_BE: _snd_pcm_format = 28; +pub const SND_PCM_FORMAT_U20_LE: _snd_pcm_format = 27; +pub const SND_PCM_FORMAT_S20_BE: _snd_pcm_format = 26; +pub const SND_PCM_FORMAT_S20_LE: _snd_pcm_format = 25; +pub const SND_PCM_FORMAT_GSM: _snd_pcm_format = 24; +pub const SND_PCM_FORMAT_MPEG: _snd_pcm_format = 23; +pub const SND_PCM_FORMAT_IMA_ADPCM: _snd_pcm_format = 22; +pub const SND_PCM_FORMAT_A_LAW: _snd_pcm_format = 21; +pub const SND_PCM_FORMAT_MU_LAW: _snd_pcm_format = 20; +pub const SND_PCM_FORMAT_IEC958_SUBFRAME_BE: _snd_pcm_format = 19; +pub const SND_PCM_FORMAT_IEC958_SUBFRAME_LE: _snd_pcm_format = 18; +pub const SND_PCM_FORMAT_FLOAT64_BE: _snd_pcm_format = 17; +pub const SND_PCM_FORMAT_FLOAT64_LE: _snd_pcm_format = 16; +pub const SND_PCM_FORMAT_FLOAT_BE: _snd_pcm_format = 15; +pub const SND_PCM_FORMAT_FLOAT_LE: _snd_pcm_format = 14; +pub const SND_PCM_FORMAT_U32_BE: _snd_pcm_format = 13; +pub const SND_PCM_FORMAT_U32_LE: _snd_pcm_format = 12; +pub const SND_PCM_FORMAT_S32_BE: _snd_pcm_format = 11; +pub const SND_PCM_FORMAT_S32_LE: _snd_pcm_format = 10; +pub const SND_PCM_FORMAT_U24_BE: _snd_pcm_format = 9; +pub const SND_PCM_FORMAT_U24_LE: _snd_pcm_format = 8; +pub const SND_PCM_FORMAT_S24_BE: _snd_pcm_format = 7; +pub const SND_PCM_FORMAT_S24_LE: _snd_pcm_format = 6; +pub const SND_PCM_FORMAT_U16_BE: _snd_pcm_format = 5; +pub const SND_PCM_FORMAT_U16_LE: _snd_pcm_format = 4; +pub const SND_PCM_FORMAT_S16_BE: _snd_pcm_format = 3; +pub const SND_PCM_FORMAT_S16_LE: _snd_pcm_format = 2; +pub const SND_PCM_FORMAT_U8: _snd_pcm_format = 1; +pub const SND_PCM_FORMAT_S8: _snd_pcm_format = 0; +pub const SND_PCM_FORMAT_UNKNOWN: _snd_pcm_format = -1; +pub type snd_mixer_selem_channel_id_t = _snd_mixer_selem_channel_id; +pub type _snd_mixer_selem_channel_id = libc::c_int; +pub const SND_MIXER_SCHN_MONO: _snd_mixer_selem_channel_id = 0; +pub const SND_MIXER_SCHN_LAST: _snd_mixer_selem_channel_id = 31; +pub const SND_MIXER_SCHN_REAR_CENTER: _snd_mixer_selem_channel_id = 8; +pub const SND_MIXER_SCHN_SIDE_RIGHT: _snd_mixer_selem_channel_id = 7; +pub const SND_MIXER_SCHN_SIDE_LEFT: _snd_mixer_selem_channel_id = 6; +pub const SND_MIXER_SCHN_WOOFER: _snd_mixer_selem_channel_id = 5; +pub const SND_MIXER_SCHN_FRONT_CENTER: _snd_mixer_selem_channel_id = 4; +pub const SND_MIXER_SCHN_REAR_RIGHT: _snd_mixer_selem_channel_id = 3; +pub const SND_MIXER_SCHN_REAR_LEFT: _snd_mixer_selem_channel_id = 2; +pub const SND_MIXER_SCHN_FRONT_RIGHT: _snd_mixer_selem_channel_id = 1; +pub const SND_MIXER_SCHN_FRONT_LEFT: _snd_mixer_selem_channel_id = 0; +pub const SND_MIXER_SCHN_UNKNOWN: _snd_mixer_selem_channel_id = -1; +pub type snd_pcm_hw_params_t = _snd_pcm_hw_params; +pub type snd_pcm_stream_t = _snd_pcm_stream; +pub type _snd_pcm_stream = libc::c_uint; +pub const SND_PCM_STREAM_LAST: _snd_pcm_stream = 1; +pub const SND_PCM_STREAM_CAPTURE: _snd_pcm_stream = 1; +pub const SND_PCM_STREAM_PLAYBACK: _snd_pcm_stream = 0; +pub type snd_pcm_sframes_t = libc::c_long; +pub const SND_PCM_STATE_DISCONNECTED: _snd_pcm_state = 8; +pub type snd_pcm_state_t = _snd_pcm_state; +pub type _snd_pcm_state = libc::c_uint; +pub const SND_PCM_STATE_PRIVATE1: _snd_pcm_state = 1024; +pub const SND_PCM_STATE_LAST: _snd_pcm_state = 8; +pub const SND_PCM_STATE_SUSPENDED: _snd_pcm_state = 7; +pub const SND_PCM_STATE_PAUSED: _snd_pcm_state = 6; +pub const SND_PCM_STATE_DRAINING: _snd_pcm_state = 5; +pub const SND_PCM_STATE_XRUN: _snd_pcm_state = 4; +pub const SND_PCM_STATE_RUNNING: _snd_pcm_state = 3; +pub const SND_PCM_STATE_PREPARED: _snd_pcm_state = 2; +pub const SND_PCM_STATE_SETUP: _snd_pcm_state = 1; +pub const SND_PCM_STATE_OPEN: _snd_pcm_state = 0; +pub type snd_output_t = _snd_output; +pub type snd_pcm_access_t = _snd_pcm_access; +pub type _snd_pcm_access = libc::c_uint; +pub const SND_PCM_ACCESS_LAST: _snd_pcm_access = 4; +pub const SND_PCM_ACCESS_RW_NONINTERLEAVED: _snd_pcm_access = 4; +pub const SND_PCM_ACCESS_RW_INTERLEAVED: _snd_pcm_access = 3; +pub const SND_PCM_ACCESS_MMAP_COMPLEX: _snd_pcm_access = 2; +pub const SND_PCM_ACCESS_MMAP_NONINTERLEAVED: _snd_pcm_access = 1; +pub const SND_PCM_ACCESS_MMAP_INTERLEAVED: _snd_pcm_access = 0; +pub type snd_lib_error_handler_t + = + Option ()>; +pub type snd_pcm_channel_area_t = _snd_pcm_channel_area; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct _snd_pcm_channel_area { + pub addr: *mut libc::c_void, + pub first: libc::c_uint, + pub step: libc::c_uint, +} +static mut fmts: [snd_pcm_format_t; 5] = + [SND_PCM_FORMAT_S32_LE, SND_PCM_FORMAT_S24_LE, SND_PCM_FORMAT_S24_3LE, + SND_PCM_FORMAT_S16_LE, SND_PCM_FORMAT_UNKNOWN]; +static mut alsa: C2RustUnnamed_0 = + C2RustUnnamed_0{device: [0; 129], + ctl: 0 as *const libc::c_char as *mut libc::c_char, + mixer_ctl: 0 as *const libc::c_char as *mut libc::c_char, + format: SND_PCM_FORMAT_S8, + buffer_size: 0, + period_size: 0, + rate: 0, + mmap: false, + reopen: false, + write_buf: 0 as *const u8_t as *mut u8_t, + volume_mixer_name: 0 as *const libc::c_char, + mixer_linear: false, + mixer_elem: + 0 as *const snd_mixer_elem_t as *mut snd_mixer_elem_t, + mixer_handle: 0 as *const snd_mixer_t as *mut snd_mixer_t, + mixer_min: 0, + mixer_max: 0,}; +static mut pcmp: *mut snd_pcm_t = 0 as *const snd_pcm_t as *mut snd_pcm_t; +static mut loglevel: log_level = lERROR; static mut running: bool = 1 as libc::c_int != 0; - -unsafe extern "C" fn ctl4device(mut device: *const libc::c_char) -> *mut libc::c_char { - let mut ctl = 0 as *mut libc::c_char; - if crate::stdlib::strncmp( - device, - b"hw:\x00" as *const u8 as *const libc::c_char, - 3 as libc::c_int as libc::c_ulong, - ) == 0 - { - ctl = crate::stdlib::strdup(device) - } else if crate::stdlib::strncmp( - device, - b"plughw:\x00" as *const u8 as *const libc::c_char, - 7 as libc::c_int as libc::c_ulong, - ) == 0 - { - ctl = crate::stdlib::strdup(device.offset(4 as libc::c_int as isize)) +unsafe extern "C" fn ctl4device(mut device: *const libc::c_char) + -> *mut libc::c_char { + let mut ctl: *mut libc::c_char = 0 as *mut libc::c_char; + if strncmp(device, b"hw:\x00" as *const u8 as *const libc::c_char, + 3 as libc::c_int as libc::c_ulong) == 0 { + ctl = strdup(device) + } else if strncmp(device, + b"plughw:\x00" as *const u8 as *const libc::c_char, + 7 as libc::c_int as libc::c_ulong) == 0 { + ctl = strdup(device.offset(4 as libc::c_int as isize)) } if !ctl.is_null() { - let mut comma = 0 as *mut libc::c_char; - comma = crate::stdlib::strrchr(ctl, ',' as i32); - if !comma.is_null() { - *comma = '\u{0}' as i32 as libc::c_char - } - } else { - ctl = crate::stdlib::strdup(device) - } + let mut comma: *mut libc::c_char = 0 as *mut libc::c_char; + comma = strrchr(ctl, ',' as i32); + if !comma.is_null() { *comma = '\u{0}' as i32 as libc::c_char } + } else { ctl = strdup(device) } return ctl; } #[no_mangle] - pub unsafe extern "C" fn list_devices() { - let mut hints = 0 as *mut *mut libc::c_void; - let mut n = 0 as *mut *mut libc::c_void; - if crate::stdlib::snd_device_name_hint( - -(1 as libc::c_int), - b"pcm\x00" as *const u8 as *const libc::c_char, - &mut hints, - ) >= 0 as libc::c_int - { + let mut hints: *mut *mut libc::c_void = 0 as *mut *mut libc::c_void; + let mut n: *mut *mut libc::c_void = 0 as *mut *mut libc::c_void; + if snd_device_name_hint(-(1 as libc::c_int), + b"pcm\x00" as *const u8 as *const libc::c_char, + &mut hints) >= 0 as libc::c_int { n = hints; - crate::stdlib::printf(b"Output devices:\n\x00" as *const u8 as *const libc::c_char); + printf(b"Output devices:\n\x00" as *const u8 as *const libc::c_char); while !(*n).is_null() { - let mut name = crate::stdlib::snd_device_name_get_hint( - *n, - b"NAME\x00" as *const u8 as *const libc::c_char, - ); - let mut desc = crate::stdlib::snd_device_name_get_hint( - *n, - b"DESC\x00" as *const u8 as *const libc::c_char, - ); + let mut name: *mut libc::c_char = + snd_device_name_get_hint(*n, + b"NAME\x00" as *const u8 as + *const libc::c_char); + let mut desc: *mut libc::c_char = + snd_device_name_get_hint(*n, + b"DESC\x00" as *const u8 as + *const libc::c_char); if !name.is_null() { - crate::stdlib::printf(b" %-30s\x00" as *const u8 as *const libc::c_char, name); + printf(b" %-30s\x00" as *const u8 as *const libc::c_char, + name); } if !desc.is_null() { - let mut s1 = - crate::stdlib::strtok(desc, b"\n\x00" as *const u8 as *const libc::c_char); - let mut s2 = crate::stdlib::strtok( - 0 as *mut libc::c_char, - b"\n\x00" as *const u8 as *const libc::c_char, - ); + let mut s1: *mut libc::c_char = + strtok(desc, + b"\n\x00" as *const u8 as *const libc::c_char); + let mut s2: *mut libc::c_char = + strtok(0 as *mut libc::c_char, + b"\n\x00" as *const u8 as *const libc::c_char); if !s1.is_null() { - crate::stdlib::printf(b" - %s\x00" as *const u8 as *const libc::c_char, s1); + printf(b" - %s\x00" as *const u8 as *const libc::c_char, + s1); } if !s2.is_null() { - crate::stdlib::printf(b" - %s\x00" as *const u8 as *const libc::c_char, s2); + printf(b" - %s\x00" as *const u8 as *const libc::c_char, + s2); } } - crate::stdlib::printf(b"\n\x00" as *const u8 as *const libc::c_char); - if !name.is_null() { - crate::stdlib::free(name as *mut libc::c_void); - } - if !desc.is_null() { - crate::stdlib::free(desc as *mut libc::c_void); - } + printf(b"\n\x00" as *const u8 as *const libc::c_char); + if !name.is_null() { free(name as *mut libc::c_void); } + if !desc.is_null() { free(desc as *mut libc::c_void); } n = n.offset(1) } - crate::stdlib::snd_device_name_free_hint(hints); + snd_device_name_free_hint(hints); } - crate::stdlib::printf(b"\n\x00" as *const u8 as *const libc::c_char); + printf(b"\n\x00" as *const u8 as *const libc::c_char); } #[no_mangle] - pub unsafe extern "C" fn list_mixers(mut output_device: *const libc::c_char) { let mut err: libc::c_int = 0; - let mut handle = 0 as *mut crate::stdlib::snd_mixer_t; - let mut sid = 0 as *mut crate::stdlib::snd_mixer_selem_id_t; - let mut elem = 0 as *mut crate::stdlib::snd_mixer_elem_t; - let mut ctl = ctl4device(output_device); - let mut fresh0 = ::std::vec::from_elem(0, crate::stdlib::snd_mixer_selem_id_sizeof() as usize); - sid = fresh0.as_mut_ptr() as *mut crate::stdlib::snd_mixer_selem_id_t; - crate::stdlib::memset( - sid as *mut libc::c_void, - 0 as libc::c_int, - crate::stdlib::snd_mixer_selem_id_sizeof(), - ); - 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 listing mixers for: %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"list_mixers\x00")).as_ptr(), - 139 as libc::c_int, - output_device, - ); + let mut handle: *mut snd_mixer_t = 0 as *mut snd_mixer_t; + let mut sid: *mut snd_mixer_selem_id_t = 0 as *mut snd_mixer_selem_id_t; + let mut elem: *mut snd_mixer_elem_t = 0 as *mut snd_mixer_elem_t; + let mut ctl: *mut libc::c_char = ctl4device(output_device); + let mut fresh0 = + ::std::vec::from_elem(0, snd_mixer_selem_id_sizeof() as usize); + sid = fresh0.as_mut_ptr() as *mut snd_mixer_selem_id_t; + memset(sid as *mut libc::c_void, 0 as libc::c_int, + snd_mixer_selem_id_sizeof()); + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d listing mixers for: %s\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 12], + &[libc::c_char; 12]>(b"list_mixers\x00")).as_ptr(), + 139 as libc::c_int, output_device); } - err = crate::stdlib::snd_mixer_open(&mut handle, 0 as libc::c_int); + err = snd_mixer_open(&mut handle, 0 as libc::c_int); if err < 0 as libc::c_int { - crate::src::utils::logprint( - b"%s %s:%d open 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"list_mixers\x00")).as_ptr(), - 142 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); - return; + logprint(b"%s %s:%d open error: %s\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 12], + &[libc::c_char; 12]>(b"list_mixers\x00")).as_ptr(), + 142 as libc::c_int, snd_strerror(err)); + return } - err = crate::stdlib::snd_mixer_attach(handle, ctl); + err = snd_mixer_attach(handle, ctl); if err < 0 as libc::c_int { - crate::src::utils::logprint( - b"%s %s:%d attach 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"list_mixers\x00")).as_ptr(), - 146 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); - crate::stdlib::snd_mixer_close(handle); - crate::stdlib::free(ctl as *mut libc::c_void); - return; + logprint(b"%s %s:%d attach error: %s\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 12], + &[libc::c_char; 12]>(b"list_mixers\x00")).as_ptr(), + 146 as libc::c_int, snd_strerror(err)); + snd_mixer_close(handle); + free(ctl as *mut libc::c_void); + return } - crate::stdlib::free(ctl as *mut libc::c_void); - err = crate::stdlib::snd_mixer_selem_register( - handle, - 0 as *mut crate::stdlib::snd_mixer_selem_regopt, - 0 as *mut *mut crate::stdlib::snd_mixer_class_t, - ); + free(ctl as *mut libc::c_void); + err = + snd_mixer_selem_register(handle, 0 as *mut snd_mixer_selem_regopt, + 0 as *mut *mut snd_mixer_class_t); if err < 0 as libc::c_int { - crate::src::utils::logprint( - b"%s %s:%d register 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"list_mixers\x00")).as_ptr(), - 153 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); - crate::stdlib::snd_mixer_close(handle); - return; + logprint(b"%s %s:%d register error: %s\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 12], + &[libc::c_char; 12]>(b"list_mixers\x00")).as_ptr(), + 153 as libc::c_int, snd_strerror(err)); + snd_mixer_close(handle); + return } - err = crate::stdlib::snd_mixer_load(handle); + err = snd_mixer_load(handle); if err < 0 as libc::c_int { - crate::src::utils::logprint( - b"%s %s:%d load 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"list_mixers\x00")).as_ptr(), - 158 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); - crate::stdlib::snd_mixer_close(handle); - return; + logprint(b"%s %s:%d load error: %s\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 12], + &[libc::c_char; 12]>(b"list_mixers\x00")).as_ptr(), + 158 as libc::c_int, snd_strerror(err)); + snd_mixer_close(handle); + return } - crate::stdlib::printf( - b"Volume controls for %s\n\x00" as *const u8 as *const libc::c_char, - output_device, - ); - elem = crate::stdlib::snd_mixer_first_elem(handle); + printf(b"Volume controls for %s\n\x00" as *const u8 as + *const libc::c_char, output_device); + elem = snd_mixer_first_elem(handle); while !elem.is_null() { - if crate::stdlib::snd_mixer_selem_has_playback_volume(elem) != 0 { - crate::stdlib::snd_mixer_selem_get_id(elem, sid); - crate::stdlib::printf( - b" %s\x00" as *const u8 as *const libc::c_char, - crate::stdlib::snd_mixer_selem_id_get_name(sid), - ); - if crate::stdlib::snd_mixer_selem_id_get_index(sid) != 0 { - crate::stdlib::printf( - b",%d\x00" as *const u8 as *const libc::c_char, - crate::stdlib::snd_mixer_selem_id_get_index(sid), - ); + if snd_mixer_selem_has_playback_volume(elem) != 0 { + snd_mixer_selem_get_id(elem, sid); + printf(b" %s\x00" as *const u8 as *const libc::c_char, + snd_mixer_selem_id_get_name(sid)); + if snd_mixer_selem_id_get_index(sid) != 0 { + printf(b",%d\x00" as *const u8 as *const libc::c_char, + snd_mixer_selem_id_get_index(sid)); } - crate::stdlib::printf(b"\n\x00" as *const u8 as *const libc::c_char); + printf(b"\n\x00" as *const u8 as *const libc::c_char); } - elem = crate::stdlib::snd_mixer_elem_next(elem) + elem = snd_mixer_elem_next(elem) } - crate::stdlib::printf(b"\n\x00" as *const u8 as *const libc::c_char); - crate::stdlib::snd_mixer_close(handle); + printf(b"\n\x00" as *const u8 as *const libc::c_char); + snd_mixer_close(handle); } // LMS volume map for SqueezePlay sends values in range ~ -72..0 dB - -unsafe extern "C" fn set_mixer(mut setmax: bool, mut ldB: libc::c_float, mut rdB: libc::c_float) { +unsafe extern "C" fn set_mixer(mut setmax: bool, mut ldB: libc::c_float, + mut rdB: libc::c_float) { let mut err: libc::c_int = 0; let mut nleft: libc::c_long = 0; let mut nright: libc::c_long = 0; @@ -559,331 +865,261 @@ unsafe extern "C" fn set_mixer(mut setmax: bool, mut ldB: libc::c_float, mut rdB rraw = alsa.mixer_max; lraw = rraw } else { - lraw = ((if ldB > -(72 as libc::c_int) as libc::c_float { - (72 as libc::c_int as libc::c_double) + crate::stdlib::floor(ldB as libc::c_double) - } else { - 0 as libc::c_int as libc::c_double - }) / 72 as libc::c_int as libc::c_double - * (alsa.mixer_max - alsa.mixer_min) as libc::c_double - + alsa.mixer_min as libc::c_double) as libc::c_long; - rraw = ((if rdB > -(72 as libc::c_int) as libc::c_float { - (72 as libc::c_int as libc::c_double) + crate::stdlib::floor(rdB as libc::c_double) - } else { - 0 as libc::c_int as libc::c_double - }) / 72 as libc::c_int as libc::c_double - * (alsa.mixer_max - alsa.mixer_min) as libc::c_double - + alsa.mixer_min as libc::c_double) as libc::c_long + lraw = + ((if ldB > -(72 as libc::c_int) as libc::c_float { + (72 as libc::c_int as libc::c_double) + + floor(ldB as libc::c_double) + } else { 0 as libc::c_int as libc::c_double }) / + 72 as libc::c_int as libc::c_double * + (alsa.mixer_max - alsa.mixer_min) as libc::c_double + + alsa.mixer_min as libc::c_double) as libc::c_long; + rraw = + ((if rdB > -(72 as libc::c_int) as libc::c_float { + (72 as libc::c_int as libc::c_double) + + floor(rdB as libc::c_double) + } else { 0 as libc::c_int as libc::c_double }) / + 72 as libc::c_int as libc::c_double * + (alsa.mixer_max - alsa.mixer_min) as libc::c_double + + alsa.mixer_min as libc::c_double) as libc::c_long } - 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 setting vol raw [%ld..%ld]\n\x00" as *const u8 as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 10], &[libc::c_char; 10]>(b"set_mixer\x00")) - .as_ptr(), - 193 as libc::c_int, - alsa.mixer_min, - alsa.mixer_max, - ); + if loglevel as libc::c_uint >= lDEBUG as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d setting vol raw [%ld..%ld]\n\x00" as *const u8 + as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 10], + &[libc::c_char; 10]>(b"set_mixer\x00")).as_ptr(), + 193 as libc::c_int, alsa.mixer_min, alsa.mixer_max); } - err = crate::stdlib::snd_mixer_selem_set_playback_volume( - alsa.mixer_elem, - crate::stdlib::SND_MIXER_SCHN_FRONT_LEFT, - lraw, - ); + err = + snd_mixer_selem_set_playback_volume(alsa.mixer_elem, + SND_MIXER_SCHN_FRONT_LEFT, + lraw); if err < 0 as libc::c_int { - crate::src::utils::logprint( - b"%s %s:%d error setting left volume: %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"set_mixer\x00")) - .as_ptr(), - 195 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); + logprint(b"%s %s:%d error setting left volume: %s\n\x00" as + *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 10], + &[libc::c_char; 10]>(b"set_mixer\x00")).as_ptr(), + 195 as libc::c_int, snd_strerror(err)); } - err = crate::stdlib::snd_mixer_selem_set_playback_volume( - alsa.mixer_elem, - crate::stdlib::SND_MIXER_SCHN_FRONT_RIGHT, - rraw, - ); + err = + snd_mixer_selem_set_playback_volume(alsa.mixer_elem, + SND_MIXER_SCHN_FRONT_RIGHT, + rraw); if err < 0 as libc::c_int { - crate::src::utils::logprint( - b"%s %s:%d error setting right volume: %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"set_mixer\x00")) - .as_ptr(), - 198 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); + logprint(b"%s %s:%d error setting right volume: %s\n\x00" as + *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 10], + &[libc::c_char; 10]>(b"set_mixer\x00")).as_ptr(), + 198 as libc::c_int, snd_strerror(err)); } } else { // set db directly - 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 setting vol dB [%ld..%ld]\n\x00" as *const u8 as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 10], &[libc::c_char; 10]>(b"set_mixer\x00")) - .as_ptr(), - 202 as libc::c_int, - alsa.mixer_min, - alsa.mixer_max, - ); + if loglevel as libc::c_uint >= lDEBUG as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d setting vol dB [%ld..%ld]\n\x00" as *const u8 + as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 10], + &[libc::c_char; 10]>(b"set_mixer\x00")).as_ptr(), + 202 as libc::c_int, alsa.mixer_min, alsa.mixer_max); } if setmax { // set to 0dB if available as this should be max volume for music recored at max pcm values - if alsa.mixer_max >= 0 as libc::c_int as libc::c_long - && alsa.mixer_min <= 0 as libc::c_int as libc::c_long - { + if alsa.mixer_max >= 0 as libc::c_int as libc::c_long && + alsa.mixer_min <= 0 as libc::c_int as libc::c_long { rdB = 0 as libc::c_int as libc::c_float; ldB = rdB - } else { - rdB = alsa.mixer_max as libc::c_float; - ldB = rdB - } + } else { rdB = alsa.mixer_max as libc::c_float; ldB = rdB } } - err = crate::stdlib::snd_mixer_selem_set_playback_dB( - alsa.mixer_elem, - crate::stdlib::SND_MIXER_SCHN_FRONT_LEFT, - (100 as libc::c_int as libc::c_float * ldB) as libc::c_long, - 1 as libc::c_int, - ); + err = + snd_mixer_selem_set_playback_dB(alsa.mixer_elem, + SND_MIXER_SCHN_FRONT_LEFT, + (100 as libc::c_int as + libc::c_float * ldB) as + libc::c_long, + 1 as libc::c_int); if err < 0 as libc::c_int { - crate::src::utils::logprint( - b"%s %s:%d error setting left volume: %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"set_mixer\x00")) - .as_ptr(), - 212 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); + logprint(b"%s %s:%d error setting left volume: %s\n\x00" as + *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 10], + &[libc::c_char; 10]>(b"set_mixer\x00")).as_ptr(), + 212 as libc::c_int, snd_strerror(err)); } - err = crate::stdlib::snd_mixer_selem_set_playback_dB( - alsa.mixer_elem, - crate::stdlib::SND_MIXER_SCHN_FRONT_RIGHT, - (100 as libc::c_int as libc::c_float * rdB) as libc::c_long, - 1 as libc::c_int, - ); + err = + snd_mixer_selem_set_playback_dB(alsa.mixer_elem, + SND_MIXER_SCHN_FRONT_RIGHT, + (100 as libc::c_int as + libc::c_float * rdB) as + libc::c_long, + 1 as libc::c_int); if err < 0 as libc::c_int { - crate::src::utils::logprint( - b"%s %s:%d error setting right volume: %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"set_mixer\x00")) - .as_ptr(), - 215 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); + logprint(b"%s %s:%d error setting right volume: %s\n\x00" as + *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 10], + &[libc::c_char; 10]>(b"set_mixer\x00")).as_ptr(), + 215 as libc::c_int, snd_strerror(err)); } } - err = crate::stdlib::snd_mixer_selem_get_playback_volume( - alsa.mixer_elem, - crate::stdlib::SND_MIXER_SCHN_FRONT_LEFT, - &mut nleft, - ); + err = + snd_mixer_selem_get_playback_volume(alsa.mixer_elem, + SND_MIXER_SCHN_FRONT_LEFT, + &mut nleft); if err < 0 as libc::c_int { - crate::src::utils::logprint( - b"%s %s:%d error getting left vol: %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"set_mixer\x00")).as_ptr(), - 220 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); + logprint(b"%s %s:%d error getting left vol: %s\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 10], + &[libc::c_char; 10]>(b"set_mixer\x00")).as_ptr(), + 220 as libc::c_int, snd_strerror(err)); } - err = crate::stdlib::snd_mixer_selem_get_playback_volume( - alsa.mixer_elem, - crate::stdlib::SND_MIXER_SCHN_FRONT_RIGHT, - &mut nright, - ); + err = + snd_mixer_selem_get_playback_volume(alsa.mixer_elem, + SND_MIXER_SCHN_FRONT_RIGHT, + &mut nright); if err < 0 as libc::c_int { - crate::src::utils::logprint( - b"%s %s:%d error getting right vol: %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"set_mixer\x00")).as_ptr(), - 223 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); + logprint(b"%s %s:%d error getting right vol: %s\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 10], + &[libc::c_char; 10]>(b"set_mixer\x00")).as_ptr(), + 223 as libc::c_int, snd_strerror(err)); } - 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 %s left: %3.1fdB -> %ld right: %3.1fdB -> %ld\n\x00" as *const u8 - as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 10], &[libc::c_char; 10]>(b"set_mixer\x00")).as_ptr(), - 226 as libc::c_int, - alsa.volume_mixer_name, - ldB as libc::c_double, - nleft, - rdB as libc::c_double, - nright, - ); + if loglevel as libc::c_uint >= lDEBUG as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d %s left: %3.1fdB -> %ld right: %3.1fdB -> %ld\n\x00" + as *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 10], + &[libc::c_char; 10]>(b"set_mixer\x00")).as_ptr(), + 226 as libc::c_int, alsa.volume_mixer_name, + ldB as libc::c_double, nleft, rdB as libc::c_double, nright); }; } #[no_mangle] - -pub unsafe extern "C" fn set_volume(mut left: libc::c_uint, mut right: libc::c_uint) { +pub unsafe extern "C" fn set_volume(mut left: libc::c_uint, + mut right: libc::c_uint) { let mut ldB: libc::c_float = 0.; let mut rdB: libc::c_float = 0.; if alsa.volume_mixer_name.is_null() { - 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 setting internal gain left: %u right: %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"set_volume\x00")) - .as_ptr(), - 233 as libc::c_int, - left, - right, - ); + if loglevel as libc::c_uint >= lDEBUG as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d setting internal gain left: %u right: %u\n\x00" + as *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 11], + &[libc::c_char; 11]>(b"set_volume\x00")).as_ptr(), + 233 as libc::c_int, left, right); } - crate::stdlib::pthread_mutex_lock(&mut (*outputbuf).mutex); + pthread_mutex_lock(&mut (*outputbuf).mutex); output.gainL = left; output.gainR = right; - crate::stdlib::pthread_mutex_unlock(&mut (*outputbuf).mutex); - return; + pthread_mutex_unlock(&mut (*outputbuf).mutex); + return } else { - crate::stdlib::pthread_mutex_lock(&mut (*outputbuf).mutex); - output.gainL = 0x10000 as libc::c_int as crate::squeezelite_h::u32_t; - output.gainR = 0x10000 as libc::c_int as crate::squeezelite_h::u32_t; - crate::stdlib::pthread_mutex_unlock(&mut (*outputbuf).mutex); + pthread_mutex_lock(&mut (*outputbuf).mutex); + output.gainL = 0x10000 as libc::c_int as u32_t; + output.gainR = 0x10000 as libc::c_int as u32_t; + pthread_mutex_unlock(&mut (*outputbuf).mutex); } // convert 16.16 fixed point to dB - ldB = (20 as libc::c_int as libc::c_double - * crate::stdlib::log10((left as libc::c_float / 65536.0f32) as libc::c_double)) - as libc::c_float; - rdB = (20 as libc::c_int as libc::c_double - * crate::stdlib::log10((right as libc::c_float / 65536.0f32) as libc::c_double)) - as libc::c_float; + ldB = + (20 as libc::c_int as libc::c_double * + log10((left as libc::c_float / 65536.0f32) as libc::c_double)) as + libc::c_float; + rdB = + (20 as libc::c_int as libc::c_double * + log10((right as libc::c_float / 65536.0f32) as libc::c_double)) + as libc::c_float; set_mixer(0 as libc::c_int != 0, ldB, rdB); } - -unsafe extern "C" fn alsa_error_handler( - mut file: *const libc::c_char, - mut line: libc::c_int, - mut function: *const libc::c_char, - mut err: libc::c_int, - mut fmt: *const libc::c_char, - mut args: ... -) -> *mut libc::c_void { +unsafe extern "C" fn alsa_error_handler(mut file: *const libc::c_char, + mut line: libc::c_int, + mut function: *const libc::c_char, + mut err: libc::c_int, + mut fmt: *const libc::c_char, + mut args: ...) -> *mut libc::c_void { let mut args_0: ::std::ffi::VaListImpl; - if loglevel as libc::c_uint >= crate::squeezelite_h::lINFO as libc::c_int as libc::c_uint - && err == 0 as libc::c_int - || loglevel as libc::c_uint >= crate::squeezelite_h::lDEBUG as libc::c_int as libc::c_uint - { - crate::stdlib::fprintf( - crate::stdlib::stderr, - b"%s ALSA %s:%d \x00" as *const u8 as *const libc::c_char, - crate::src::utils::logtime(), - function, - line, - ); + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint && + err == 0 as libc::c_int || + loglevel as libc::c_uint >= lDEBUG as libc::c_int as libc::c_uint { + fprintf(stderr, + b"%s ALSA %s:%d \x00" as *const u8 as *const libc::c_char, + logtime(), function, line); args_0 = args.clone(); - crate::stdlib::vfprintf(crate::stdlib::stderr, fmt, args_0.as_va_list()); - crate::stdlib::fprintf( - crate::stdlib::stderr, - b"\n\x00" as *const u8 as *const libc::c_char, - ); - crate::stdlib::fflush(crate::stdlib::stderr); + vfprintf(stderr, fmt, args_0.as_va_list()); + fprintf(stderr, b"\n\x00" as *const u8 as *const libc::c_char); + fflush(stderr); } return 0 as *mut libc::c_void; } - unsafe extern "C" fn alsa_close() { let mut err: libc::c_int = 0; - err = crate::stdlib::snd_pcm_close(pcmp); + err = snd_pcm_close(pcmp); if err < 0 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 snd_pcm_close 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"alsa_close\x00")) - .as_ptr(), - 268 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d snd_pcm_close error: %s\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 11], + &[libc::c_char; 11]>(b"alsa_close\x00")).as_ptr(), + 268 as libc::c_int, snd_strerror(err)); } }; } #[no_mangle] - -pub unsafe extern "C" fn test_open( - mut device: *const libc::c_char, - mut rates: *mut libc::c_uint, - mut userdef_rates: bool, -) -> bool { +pub unsafe extern "C" fn test_open(mut device: *const libc::c_char, + mut rates: *mut libc::c_uint, + mut userdef_rates: bool) -> bool { let mut err: libc::c_int = 0; - let mut pcm = 0 as *mut crate::stdlib::snd_pcm_t; - let mut hw_params = 0 as *mut crate::stdlib::snd_pcm_hw_params_t; - let mut fresh1 = ::std::vec::from_elem(0, crate::stdlib::snd_pcm_hw_params_sizeof() as usize); - hw_params = fresh1.as_mut_ptr() as *mut crate::stdlib::snd_pcm_hw_params_t; - crate::stdlib::memset( - hw_params as *mut libc::c_void, - 0 as libc::c_int, - crate::stdlib::snd_pcm_hw_params_sizeof(), - ); + let mut pcm: *mut snd_pcm_t = 0 as *mut snd_pcm_t; + let mut hw_params: *mut snd_pcm_hw_params_t = + 0 as *mut snd_pcm_hw_params_t; + let mut fresh1 = + ::std::vec::from_elem(0, snd_pcm_hw_params_sizeof() as usize); + hw_params = fresh1.as_mut_ptr() as *mut snd_pcm_hw_params_t; + memset(hw_params as *mut libc::c_void, 0 as libc::c_int, + snd_pcm_hw_params_sizeof()); // open device - err = crate::stdlib::snd_pcm_open( - &mut pcm, - device, - crate::stdlib::SND_PCM_STREAM_PLAYBACK, - 0 as libc::c_int, - ); + err = + snd_pcm_open(&mut pcm, device, SND_PCM_STREAM_PLAYBACK, + 0 as libc::c_int); if err < 0 as libc::c_int { - crate::src::utils::logprint( - b"%s %s:%d playback open error: %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"test_open\x00")).as_ptr(), - 281 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); - return 0 as libc::c_int != 0; + logprint(b"%s %s:%d playback open error: %s\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 10], + &[libc::c_char; 10]>(b"test_open\x00")).as_ptr(), + 281 as libc::c_int, snd_strerror(err)); + return 0 as libc::c_int != 0 } // get max params - err = crate::stdlib::snd_pcm_hw_params_any(pcm, hw_params); + err = snd_pcm_hw_params_any(pcm, hw_params); if err < 0 as libc::c_int { - crate::src::utils::logprint( - b"%s %s:%d hwparam init error: %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"test_open\x00")).as_ptr(), - 287 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); - return 0 as libc::c_int != 0; + logprint(b"%s %s:%d hwparam init error: %s\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 10], + &[libc::c_char; 10]>(b"test_open\x00")).as_ptr(), + 287 as libc::c_int, snd_strerror(err)); + return 0 as libc::c_int != 0 } // find supported sample rates to enable client side resampling of non supported rates if !userdef_rates { let mut i: libc::c_uint = 0; let mut ind: libc::c_uint = 0; - let mut ref_0: [libc::c_uint; 18] = [ - 768000 as libc::c_int as libc::c_uint, - 705600 as libc::c_int as libc::c_uint, - 384000 as libc::c_int as libc::c_uint, - 352800 as libc::c_int as libc::c_uint, - 192000 as libc::c_int as libc::c_uint, - 176400 as libc::c_int as libc::c_uint, - 96000 as libc::c_int as libc::c_uint, - 88200 as libc::c_int as libc::c_uint, - 48000 as libc::c_int as libc::c_uint, - 44100 as libc::c_int as libc::c_uint, - 32000 as libc::c_int as libc::c_uint, - 24000 as libc::c_int as libc::c_uint, - 22500 as libc::c_int as libc::c_uint, - 16000 as libc::c_int as libc::c_uint, - 12000 as libc::c_int as libc::c_uint, - 11025 as libc::c_int as libc::c_uint, - 8000 as libc::c_int as libc::c_uint, - 0 as libc::c_int as libc::c_uint, - ]; + let mut ref_0: [libc::c_uint; 18] = + [768000 as libc::c_int as libc::c_uint, + 705600 as libc::c_int as libc::c_uint, + 384000 as libc::c_int as libc::c_uint, + 352800 as libc::c_int as libc::c_uint, + 192000 as libc::c_int as libc::c_uint, + 176400 as libc::c_int as libc::c_uint, + 96000 as libc::c_int as libc::c_uint, + 88200 as libc::c_int as libc::c_uint, + 48000 as libc::c_int as libc::c_uint, + 44100 as libc::c_int as libc::c_uint, + 32000 as libc::c_int as libc::c_uint, + 24000 as libc::c_int as libc::c_uint, + 22500 as libc::c_int as libc::c_uint, + 16000 as libc::c_int as libc::c_uint, + 12000 as libc::c_int as libc::c_uint, + 11025 as libc::c_int as libc::c_uint, + 8000 as libc::c_int as libc::c_uint, + 0 as libc::c_int as libc::c_uint]; i = 0 as libc::c_int as libc::c_uint; ind = 0 as libc::c_int as libc::c_uint; while ref_0[i as usize] != 0 { - if crate::stdlib::snd_pcm_hw_params_test_rate( - pcm, - hw_params, - ref_0[i as usize], - 0 as libc::c_int, - ) == 0 as libc::c_int - { + if snd_pcm_hw_params_test_rate(pcm, hw_params, ref_0[i as usize], + 0 as libc::c_int) == + 0 as libc::c_int { let fresh2 = ind; ind = ind.wrapping_add(1); *rates.offset(fresh2 as isize) = ref_0[i as usize] @@ -891,925 +1127,707 @@ pub unsafe extern "C" fn test_open( i = i.wrapping_add(1) } } - err = crate::stdlib::snd_pcm_close(pcm); + err = snd_pcm_close(pcm); if err < 0 as libc::c_int { - crate::src::utils::logprint( - b"%s %s:%d snd_pcm_close error: %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"test_open\x00")).as_ptr(), - 304 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); - return 0 as libc::c_int != 0; + logprint(b"%s %s:%d snd_pcm_close error: %s\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 10], + &[libc::c_char; 10]>(b"test_open\x00")).as_ptr(), + 304 as libc::c_int, snd_strerror(err)); + return 0 as libc::c_int != 0 } return 1 as libc::c_int != 0; } - unsafe extern "C" fn pcm_probe(mut device: *const libc::c_char) -> bool { let mut err: libc::c_int = 0; - let mut pcm = 0 as *mut crate::stdlib::snd_pcm_t; - err = crate::stdlib::snd_pcm_open( - &mut pcm, - device, - crate::stdlib::SND_PCM_STREAM_PLAYBACK, - 0 as libc::c_int, - ); + let mut pcm: *mut snd_pcm_t = 0 as *mut snd_pcm_t; + err = + snd_pcm_open(&mut pcm, device, SND_PCM_STREAM_PLAYBACK, + 0 as libc::c_int); + if err < 0 as libc::c_int { return 0 as libc::c_int != 0 } + err = snd_pcm_close(pcm); if err < 0 as libc::c_int { - return 0 as libc::c_int != 0; - } - err = crate::stdlib::snd_pcm_close(pcm); - if err < 0 as libc::c_int { - crate::src::utils::logprint( - b"%s %s:%d snd_pcm_close error: %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"pcm_probe\x00")).as_ptr(), - 320 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); + logprint(b"%s %s:%d snd_pcm_close error: %s\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 10], + &[libc::c_char; 10]>(b"pcm_probe\x00")).as_ptr(), + 320 as libc::c_int, snd_strerror(err)); } return 1 as libc::c_int != 0; } - -unsafe extern "C" fn alsa_open( - mut device: *const libc::c_char, - mut sample_rate: libc::c_uint, - mut alsa_buffer: libc::c_uint, - mut alsa_period: libc::c_uint, -) -> libc::c_int { +unsafe extern "C" fn alsa_open(mut device: *const libc::c_char, + mut sample_rate: libc::c_uint, + mut alsa_buffer: libc::c_uint, + mut alsa_period: libc::c_uint) -> libc::c_int { let mut err: libc::c_int = 0; - let mut hw_params = 0 as *mut crate::stdlib::snd_pcm_hw_params_t; - let mut fresh3 = ::std::vec::from_elem(0, crate::stdlib::snd_pcm_hw_params_sizeof() as usize); - hw_params = fresh3.as_mut_ptr() as *mut crate::stdlib::snd_pcm_hw_params_t; - crate::stdlib::memset( - hw_params as *mut libc::c_void, - 0 as libc::c_int, - crate::stdlib::snd_pcm_hw_params_sizeof(), - ); + let mut hw_params: *mut snd_pcm_hw_params_t = + 0 as *mut snd_pcm_hw_params_t; + let mut fresh3 = + ::std::vec::from_elem(0, snd_pcm_hw_params_sizeof() as usize); + hw_params = fresh3.as_mut_ptr() as *mut snd_pcm_hw_params_t; + memset(hw_params as *mut libc::c_void, 0 as libc::c_int, + snd_pcm_hw_params_sizeof()); // close if already open - if !pcmp.is_null() { - alsa_close(); - } + if !pcmp.is_null() { alsa_close(); } // reset params alsa.rate = 0 as libc::c_int as libc::c_uint; - alsa.period_size = 0 as libc::c_int as crate::stdlib::snd_pcm_uframes_t; - crate::stdlib::strcpy(alsa.device.as_mut_ptr(), device); - if crate::stdlib::strlen(device) - > (128 as libc::c_int - 4 as libc::c_int - 1 as libc::c_int) as libc::c_ulong - { - crate::src::utils::logprint( - b"%s %s:%d device name too long: %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"alsa_open\x00")).as_ptr(), - 347 as libc::c_int, - device, - ); - return -(1 as libc::c_int); + alsa.period_size = 0 as libc::c_int as snd_pcm_uframes_t; + strcpy(alsa.device.as_mut_ptr(), device); + if strlen(device) > + (128 as libc::c_int - 4 as libc::c_int - 1 as libc::c_int) as + libc::c_ulong { + logprint(b"%s %s:%d device name too long: %s\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 10], + &[libc::c_char; 10]>(b"alsa_open\x00")).as_ptr(), + 347 as libc::c_int, device); + return -(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 opening device at: %u\n\x00" as *const u8 as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 10], &[libc::c_char; 10]>(b"alsa_open\x00")).as_ptr(), - 351 as libc::c_int, - sample_rate, - ); + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d opening device at: %u\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 10], + &[libc::c_char; 10]>(b"alsa_open\x00")).as_ptr(), + 351 as libc::c_int, sample_rate); } let mut retry: bool = false; - loop { + loop { // open device - err = crate::stdlib::snd_pcm_open( - &mut pcmp, - alsa.device.as_mut_ptr(), - crate::stdlib::SND_PCM_STREAM_PLAYBACK, - 0 as libc::c_int, - ); + err = + snd_pcm_open(&mut pcmp, alsa.device.as_mut_ptr(), + SND_PCM_STREAM_PLAYBACK, 0 as libc::c_int); if err < 0 as libc::c_int { - crate::src::utils::logprint( - b"%s %s:%d playback open error: %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"alsa_open\x00")) - .as_ptr(), - 357 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); - return err; + logprint(b"%s %s:%d playback open error: %s\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 10], + &[libc::c_char; 10]>(b"alsa_open\x00")).as_ptr(), + 357 as libc::c_int, snd_strerror(err)); + return err } // init params - crate::stdlib::memset( - hw_params as *mut libc::c_void, - 0 as libc::c_int, - crate::stdlib::snd_pcm_hw_params_sizeof(), - ); - err = crate::stdlib::snd_pcm_hw_params_any(pcmp, hw_params); + memset(hw_params as *mut libc::c_void, 0 as libc::c_int, + snd_pcm_hw_params_sizeof()); + err = snd_pcm_hw_params_any(pcmp, hw_params); if err < 0 as libc::c_int { - crate::src::utils::logprint( - b"%s %s:%d hwparam init error: %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"alsa_open\x00")) - .as_ptr(), - 364 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); - return err; + logprint(b"%s %s:%d hwparam init error: %s\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 10], + &[libc::c_char; 10]>(b"alsa_open\x00")).as_ptr(), + 364 as libc::c_int, snd_strerror(err)); + return err } // open hw: devices without resampling, if sample rate fails try plughw: with resampling - let mut hw = crate::stdlib::strncmp( - alsa.device.as_mut_ptr(), - b"hw:\x00" as *const u8 as *const libc::c_char, - 3 as libc::c_int as libc::c_ulong, - ) == 0; + let mut hw: bool = + strncmp(alsa.device.as_mut_ptr(), + b"hw:\x00" as *const u8 as *const libc::c_char, + 3 as libc::c_int as libc::c_ulong) == 0; retry = 0 as libc::c_int != 0; - err = crate::stdlib::snd_pcm_hw_params_set_rate_resample( - pcmp, - hw_params, - !hw as libc::c_int as libc::c_uint, - ); + err = + snd_pcm_hw_params_set_rate_resample(pcmp, hw_params, + !hw as libc::c_int as + libc::c_uint); if err < 0 as libc::c_int { - crate::src::utils::logprint( - b"%s %s:%d resampling setup failed: %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"alsa_open\x00")) - .as_ptr(), - 373 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); - return err; + logprint(b"%s %s:%d resampling setup failed: %s\n\x00" as + *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 10], + &[libc::c_char; 10]>(b"alsa_open\x00")).as_ptr(), + 373 as libc::c_int, snd_strerror(err)); + return err } - err = crate::stdlib::snd_pcm_hw_params_set_rate( - pcmp, - hw_params, - sample_rate, - 0 as libc::c_int, - ); + err = + snd_pcm_hw_params_set_rate(pcmp, hw_params, sample_rate, + 0 as libc::c_int); if err < 0 as libc::c_int { if hw { - crate::stdlib::strcpy( - alsa.device.as_mut_ptr().offset(4 as libc::c_int as isize), - device, - ); - crate::stdlib::memcpy( - alsa.device.as_mut_ptr() as *mut libc::c_void, - b"plug\x00" as *const u8 as *const libc::c_char as *const libc::c_void, - 4 as libc::c_int as libc::c_ulong, - ); - 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 reopening device %s in plug mode as %s for resampling\n\x00" - as *const u8 as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 10], &[libc::c_char; 10]>( - b"alsa_open\x00", - )) - .as_ptr(), - 381 as libc::c_int, - device, - alsa.device.as_mut_ptr(), - ); + strcpy(alsa.device.as_mut_ptr().offset(4 as libc::c_int as + isize), device); + memcpy(alsa.device.as_mut_ptr() as *mut libc::c_void, + b"plug\x00" as *const u8 as *const libc::c_char as + *const libc::c_void, + 4 as libc::c_int as libc::c_ulong); + if loglevel as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d reopening device %s in plug mode as %s for resampling\n\x00" + as *const u8 as *const libc::c_char, + logtime(), + (*::std::mem::transmute::<&[u8; 10], + &[libc::c_char; 10]>(b"alsa_open\x00")).as_ptr(), + 381 as libc::c_int, device, + alsa.device.as_mut_ptr()); } - crate::stdlib::snd_pcm_close(pcmp); + snd_pcm_close(pcmp); retry = 1 as libc::c_int != 0 } } - if !retry { - break; - } + if !retry { break ; } } - // set access - if !alsa.mmap - || crate::stdlib::snd_pcm_hw_params_set_access( - pcmp, - hw_params, - crate::stdlib::SND_PCM_ACCESS_MMAP_INTERLEAVED, - ) < 0 as libc::c_int - { - err = crate::stdlib::snd_pcm_hw_params_set_access( - pcmp, - hw_params, - crate::stdlib::SND_PCM_ACCESS_RW_INTERLEAVED, - ); + // set access + if !alsa.mmap || + snd_pcm_hw_params_set_access(pcmp, hw_params, + SND_PCM_ACCESS_MMAP_INTERLEAVED) < + 0 as libc::c_int { + err = + snd_pcm_hw_params_set_access(pcmp, hw_params, + SND_PCM_ACCESS_RW_INTERLEAVED); if err < 0 as libc::c_int { - crate::src::utils::logprint( - b"%s %s:%d access type not available: %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"alsa_open\x00")) - .as_ptr(), - 392 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); - return err; + logprint(b"%s %s:%d access type not available: %s\n\x00" as + *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 10], + &[libc::c_char; 10]>(b"alsa_open\x00")).as_ptr(), + 392 as libc::c_int, snd_strerror(err)); + return err } alsa.mmap = 0 as libc::c_int != 0 } // set the sample format - let mut fmt = if alsa.format as libc::c_int != 0 { - &mut alsa.format - } else { - fmts.as_mut_ptr() - }; - loop { - if crate::stdlib::snd_pcm_hw_params_set_format(pcmp, hw_params, *fmt) >= 0 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 opened device %s using format: %s sample rate: %u mmap: %u\n\x00" - as *const u8 as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 10], &[libc::c_char; 10]>(b"alsa_open\x00")) - .as_ptr(), - 422 as libc::c_int, - alsa.device.as_mut_ptr(), - crate::stdlib::snd_pcm_format_name(*fmt), - sample_rate, - alsa.mmap as libc::c_int, - ); + let mut fmt: *mut snd_pcm_format_t = + if alsa.format as libc::c_int != 0 { + &mut alsa.format + } else { fmts.as_mut_ptr() }; + loop { + if snd_pcm_hw_params_set_format(pcmp, hw_params, *fmt) >= + 0 as libc::c_int { + if loglevel as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d opened device %s using format: %s sample rate: %u mmap: %u\n\x00" + as *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 10], + &[libc::c_char; 10]>(b"alsa_open\x00")).as_ptr(), + 422 as libc::c_int, alsa.device.as_mut_ptr(), + snd_pcm_format_name(*fmt), sample_rate, + alsa.mmap as libc::c_int); } alsa.format = *fmt; - break; + break ; } else { if alsa.format as u64 != 0 { - crate::src::utils::logprint( - b"%s %s:%d unable to open audio device requested format: %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"alsa_open\x00")) - .as_ptr(), - 427 as libc::c_int, - crate::stdlib::snd_pcm_format_name(alsa.format), - ); - return -(1 as libc::c_int); + logprint(b"%s %s:%d unable to open audio device requested format: %s\n\x00" + as *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 10], + &[libc::c_char; 10]>(b"alsa_open\x00")).as_ptr(), + 427 as libc::c_int, + snd_pcm_format_name(alsa.format)); + return -(1 as libc::c_int) } fmt = fmt.offset(1); - if *fmt as libc::c_int == crate::stdlib::SND_PCM_FORMAT_UNKNOWN as libc::c_int { - crate::src::utils::logprint( - b"%s %s:%d unable to open audio device with any supported format\n\x00" - as *const u8 as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 10], &[libc::c_char; 10]>(b"alsa_open\x00")) - .as_ptr(), - 432 as libc::c_int, - ); - return -(1 as libc::c_int); + if *fmt as libc::c_int == SND_PCM_FORMAT_UNKNOWN as libc::c_int { + logprint(b"%s %s:%d unable to open audio device with any supported format\n\x00" + as *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 10], + &[libc::c_char; 10]>(b"alsa_open\x00")).as_ptr(), + 432 as libc::c_int); + return -(1 as libc::c_int) } - if !(*fmt as libc::c_int != crate::stdlib::SND_PCM_FORMAT_UNKNOWN as libc::c_int) { - break; + if !(*fmt as libc::c_int != SND_PCM_FORMAT_UNKNOWN as libc::c_int) + { + break ; } } } // set the output format to be used by _scale_and_pack match alsa.format as libc::c_int { - 10 => output.format = crate::squeezelite_h::S32_LE, - 6 => output.format = crate::squeezelite_h::S24_LE, - 32 => output.format = crate::squeezelite_h::S24_3LE, - 2 => output.format = crate::squeezelite_h::S16_LE, - _ => {} + 10 => { output.format = S32_LE } + 6 => { output.format = S24_LE } + 32 => { output.format = S24_3LE } + 2 => { output.format = S16_LE } + _ => { } } // set channels - err = crate::stdlib::snd_pcm_hw_params_set_channels( - pcmp, - hw_params, - 2 as libc::c_int as libc::c_uint, - ); + err = + snd_pcm_hw_params_set_channels(pcmp, hw_params, + 2 as libc::c_int as libc::c_uint); if err < 0 as libc::c_int { - crate::src::utils::logprint( - b"%s %s:%d channel count not available: %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"alsa_open\x00")).as_ptr(), - 465 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); - return err; + logprint(b"%s %s:%d channel count not available: %s\n\x00" as + *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 10], + &[libc::c_char; 10]>(b"alsa_open\x00")).as_ptr(), + 465 as libc::c_int, snd_strerror(err)); + return err } // set period size - value of < 50 treated as period count, otherwise size in bytes if alsa_period < 50 as libc::c_int as libc::c_uint { - let mut count = alsa_period; - err = crate::stdlib::snd_pcm_hw_params_set_periods_near( - pcmp, - hw_params, - &mut count, - 0 as *mut libc::c_int, - ); + let mut count: libc::c_uint = alsa_period; + err = + snd_pcm_hw_params_set_periods_near(pcmp, hw_params, &mut count, + 0 as *mut libc::c_int); if err < 0 as libc::c_int { - crate::src::utils::logprint( - b"%s %s:%d unable to set period count %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"alsa_open\x00")) - .as_ptr(), - 473 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); - return err; + logprint(b"%s %s:%d unable to set period count %s\n\x00" as + *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 10], + &[libc::c_char; 10]>(b"alsa_open\x00")).as_ptr(), + 473 as libc::c_int, snd_strerror(err)); + return err } } else { - let mut size = alsa_period as crate::stdlib::snd_pcm_uframes_t; - let mut dir = 0 as libc::c_int; - err = crate::stdlib::snd_pcm_hw_params_set_period_size_near( - pcmp, hw_params, &mut size, &mut dir, - ); + let mut size: snd_pcm_uframes_t = alsa_period as snd_pcm_uframes_t; + let mut dir: libc::c_int = 0 as libc::c_int; + err = + snd_pcm_hw_params_set_period_size_near(pcmp, hw_params, &mut size, + &mut dir); if err < 0 as libc::c_int { - crate::src::utils::logprint( - b"%s %s:%d unable to set period size %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"alsa_open\x00")) - .as_ptr(), - 480 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); - return err; + logprint(b"%s %s:%d unable to set period size %s\n\x00" as + *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 10], + &[libc::c_char; 10]>(b"alsa_open\x00")).as_ptr(), + 480 as libc::c_int, snd_strerror(err)); + return err } } // set buffer size - value of < 500 treated as buffer time in ms, otherwise size in bytes if alsa_buffer < 500 as libc::c_int as libc::c_uint { - let mut time = alsa_buffer.wrapping_mul(1000 as libc::c_int as libc::c_uint); - let mut dir_0 = 0 as libc::c_int; - err = crate::stdlib::snd_pcm_hw_params_set_buffer_time_near( - pcmp, hw_params, &mut time, &mut dir_0, - ); + let mut time: libc::c_uint = + alsa_buffer.wrapping_mul(1000 as libc::c_int as libc::c_uint); + let mut dir_0: libc::c_int = 0 as libc::c_int; + err = + snd_pcm_hw_params_set_buffer_time_near(pcmp, hw_params, &mut time, + &mut dir_0); if err < 0 as libc::c_int { - crate::src::utils::logprint( - b"%s %s:%d unable to set buffer time %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"alsa_open\x00")) - .as_ptr(), - 490 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); - return err; + logprint(b"%s %s:%d unable to set buffer time %s\n\x00" as + *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 10], + &[libc::c_char; 10]>(b"alsa_open\x00")).as_ptr(), + 490 as libc::c_int, snd_strerror(err)); + return err } } else { - let mut size_0 = alsa_buffer as crate::stdlib::snd_pcm_uframes_t; - err = crate::stdlib::snd_pcm_hw_params_set_buffer_size_near(pcmp, hw_params, &mut size_0); + let mut size_0: snd_pcm_uframes_t = alsa_buffer as snd_pcm_uframes_t; + err = + snd_pcm_hw_params_set_buffer_size_near(pcmp, hw_params, + &mut size_0); if err < 0 as libc::c_int { - crate::src::utils::logprint( - b"%s %s:%d unable to set buffer size %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"alsa_open\x00")) - .as_ptr(), - 496 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); - return err; + logprint(b"%s %s:%d unable to set buffer size %s\n\x00" as + *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 10], + &[libc::c_char; 10]>(b"alsa_open\x00")).as_ptr(), + 496 as libc::c_int, snd_strerror(err)); + return err } } // get period_size - err = crate::stdlib::snd_pcm_hw_params_get_period_size( - hw_params, - &mut alsa.period_size, - 0 as *mut libc::c_int, - ); + err = + snd_pcm_hw_params_get_period_size(hw_params, &mut alsa.period_size, + 0 as *mut libc::c_int); if err < 0 as libc::c_int { - crate::src::utils::logprint( - b"%s %s:%d unable to get period size: %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"alsa_open\x00")).as_ptr(), - 503 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); - return err; + logprint(b"%s %s:%d unable to get period size: %s\n\x00" as *const u8 + as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 10], + &[libc::c_char; 10]>(b"alsa_open\x00")).as_ptr(), + 503 as libc::c_int, snd_strerror(err)); + return err } // get buffer_size - err = crate::stdlib::snd_pcm_hw_params_get_buffer_size(hw_params, &mut alsa.buffer_size); + err = snd_pcm_hw_params_get_buffer_size(hw_params, &mut alsa.buffer_size); if err < 0 as libc::c_int { - crate::src::utils::logprint( - b"%s %s:%d unable to get buffer size: %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"alsa_open\x00")).as_ptr(), - 509 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); - return err; + logprint(b"%s %s:%d unable to get buffer size: %s\n\x00" as *const u8 + as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 10], + &[libc::c_char; 10]>(b"alsa_open\x00")).as_ptr(), + 509 as libc::c_int, snd_strerror(err)); + return err } - 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 buffer: %u period: %u -> buffer size: %u period size: %u\n\x00" as *const u8 - as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 10], &[libc::c_char; 10]>(b"alsa_open\x00")).as_ptr(), - 513 as libc::c_int, - alsa_buffer, - alsa_period, - alsa.buffer_size, - alsa.period_size, - ); + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d buffer: %u period: %u -> buffer size: %u period size: %u\n\x00" + as *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 10], + &[libc::c_char; 10]>(b"alsa_open\x00")).as_ptr(), + 513 as libc::c_int, alsa_buffer, alsa_period, + alsa.buffer_size, alsa.period_size); } // ensure we have two buffer sizes of samples before starting output - output.start_frames = alsa - .buffer_size - .wrapping_mul(2 as libc::c_int as libc::c_ulong) as libc::c_uint; + output.start_frames = + alsa.buffer_size.wrapping_mul(2 as libc::c_int as libc::c_ulong) as + libc::c_uint; // create an intermediate buffer for non mmap case for all but NATIVE_FORMAT - // this is used to pack samples into the output format before calling writei - if !alsa.mmap - && alsa.write_buf.is_null() - && alsa.format as libc::c_int != crate::stdlib::SND_PCM_FORMAT_S32_LE as libc::c_int - { - alsa.write_buf = crate::stdlib::malloc( - alsa.buffer_size - .wrapping_mul(8 as libc::c_int as libc::c_ulong), - ) as *mut crate::squeezelite_h::u8_t; + // this is used to pack samples into the output format before calling writei + if !alsa.mmap && alsa.write_buf.is_null() && + alsa.format as libc::c_int != SND_PCM_FORMAT_S32_LE as libc::c_int + { + alsa.write_buf = + malloc(alsa.buffer_size.wrapping_mul(8 as libc::c_int as + libc::c_ulong)) as + *mut u8_t; if alsa.write_buf.is_null() { - crate::src::utils::logprint( - b"%s %s:%d unable to malloc write_buf\n\x00" as *const u8 as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 10], &[libc::c_char; 10]>(b"alsa_open\x00")) - .as_ptr(), - 523 as libc::c_int, - ); - return -(1 as libc::c_int); + logprint(b"%s %s:%d unable to malloc write_buf\n\x00" as *const u8 + as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 10], + &[libc::c_char; 10]>(b"alsa_open\x00")).as_ptr(), + 523 as libc::c_int); + return -(1 as libc::c_int) } } // set params - err = crate::stdlib::snd_pcm_hw_params(pcmp, hw_params); + err = snd_pcm_hw_params(pcmp, hw_params); if err < 0 as libc::c_int { - crate::src::utils::logprint( - b"%s %s:%d unable to set hw params: %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"alsa_open\x00")).as_ptr(), - 530 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); - return err; + logprint(b"%s %s:%d unable to set hw params: %s\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 10], + &[libc::c_char; 10]>(b"alsa_open\x00")).as_ptr(), + 530 as libc::c_int, snd_strerror(err)); + return err } // dump info - if loglevel as libc::c_uint == crate::squeezelite_h::lSDEBUG as libc::c_int as libc::c_uint { - static mut debug_output: *mut crate::stdlib::snd_output_t = - 0 as *const crate::stdlib::snd_output_t as *mut crate::stdlib::snd_output_t; - crate::stdlib::snd_output_stdio_attach( - &mut debug_output, - crate::stdlib::stderr, - 0 as libc::c_int, - ); - crate::stdlib::snd_pcm_dump(pcmp, debug_output); + if loglevel as libc::c_uint == lSDEBUG as libc::c_int as libc::c_uint { + static mut debug_output: *mut snd_output_t = + 0 as *const snd_output_t as *mut snd_output_t; + snd_output_stdio_attach(&mut debug_output, stderr, 0 as libc::c_int); + snd_pcm_dump(pcmp, debug_output); } // this indicates we have opened the device ok alsa.rate = sample_rate; return 0 as libc::c_int; } - -unsafe extern "C" fn _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 areas = 0 as *const crate::stdlib::snd_pcm_channel_area_t; - let mut offset: crate::stdlib::snd_pcm_uframes_t = 0; - let mut outputptr = 0 as *mut libc::c_void; - let mut inputptr = 0 as *mut crate::squeezelite_h::s32_t; +unsafe extern "C" fn _write_frames(mut out_frames: frames_t, + mut silence: bool, mut gainL: s32_t, + mut gainR: s32_t, mut cross_gain_in: s32_t, + mut cross_gain_out: s32_t, + mut cross_ptr: *mut *mut s32_t) + -> libc::c_int { + let mut areas: *const snd_pcm_channel_area_t = + 0 as *const snd_pcm_channel_area_t; + let mut offset: snd_pcm_uframes_t = 0; + let mut outputptr: *mut libc::c_void = 0 as *mut libc::c_void; + let mut inputptr: *mut s32_t = 0 as *mut s32_t; let mut err: libc::c_int = 0; if alsa.mmap { - let mut alsa_frames = out_frames as crate::stdlib::snd_pcm_uframes_t; - crate::stdlib::snd_pcm_avail_update(pcmp); - err = crate::stdlib::snd_pcm_mmap_begin(pcmp, &mut areas, &mut offset, &mut alsa_frames); + let mut alsa_frames: snd_pcm_uframes_t = + out_frames as snd_pcm_uframes_t; + snd_pcm_avail_update(pcmp); + err = + snd_pcm_mmap_begin(pcmp, &mut areas, &mut offset, + &mut alsa_frames); 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 error from mmap_begin: %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"_write_frames\x00", - )) - .as_ptr(), - 565 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); + if loglevel as libc::c_uint >= + lWARN as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d error from mmap_begin: %s\n\x00" as + *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 14], + &[libc::c_char; 14]>(b"_write_frames\x00")).as_ptr(), + 565 as libc::c_int, snd_strerror(err)); } - return -(1 as libc::c_int); + return -(1 as libc::c_int) } - out_frames = alsa_frames as crate::squeezelite_h::frames_t + out_frames = alsa_frames as frames_t } if !silence { // applying cross fade is delayed until this point as mmap_begin can change out_frames - 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, - ); + if output.fade as libc::c_uint == + FADE_ACTIVE as libc::c_int as libc::c_uint && + output.fade_dir as libc::c_uint == + FADE_CROSS as libc::c_int as libc::c_uint && + !(*cross_ptr).is_null() { + _apply_cross(outputbuf, out_frames, cross_gain_in, cross_gain_out, + cross_ptr); } } - inputptr = if silence as libc::c_int != 0 { - silencebuf - } else { - (*outputbuf).readp - } as *mut crate::squeezelite_h::s32_t; - if alsa.mmap as libc::c_int != 0 - || alsa.format as libc::c_int != crate::stdlib::SND_PCM_FORMAT_S32_LE as libc::c_int - { - outputptr = if alsa.mmap as libc::c_int != 0 { - (*areas.offset(0 as libc::c_int as isize)).addr.offset( - ((*areas.offset(0 as libc::c_int as isize)).first as libc::c_ulong) - .wrapping_add(offset.wrapping_mul( - (*areas.offset(0 as libc::c_int as isize)).step as libc::c_ulong, - )) - .wrapping_div(8 as libc::c_int as libc::c_ulong) as isize, - ) - } else { - alsa.write_buf as *mut libc::c_void - }; - crate::src::output_pack::_scale_and_pack_frames( - outputptr, - inputptr, - out_frames, - gainL, - gainR, - output.format, - ); + inputptr = + if silence as libc::c_int != 0 { + silencebuf + } else { (*outputbuf).readp } as *mut s32_t; + if alsa.mmap as libc::c_int != 0 || + alsa.format as libc::c_int != SND_PCM_FORMAT_S32_LE as libc::c_int + { + outputptr = + if alsa.mmap as libc::c_int != 0 { + (*areas.offset(0 as libc::c_int as + isize)).addr.offset(((*areas.offset(0 as + libc::c_int + as + isize)).first + as + libc::c_ulong).wrapping_add(offset.wrapping_mul((*areas.offset(0 + as + libc::c_int + as + isize)).step + as + libc::c_ulong)).wrapping_div(8 + as + libc::c_int + as + libc::c_ulong) + as isize) + } else { alsa.write_buf as *mut libc::c_void }; + _scale_and_pack_frames(outputptr, inputptr, out_frames, gainL, gainR, + output.format); } else { outputptr = inputptr as *mut libc::c_void; if !silence { - if gainL != 0x10000 as libc::c_int || gainR != 0x10000 as libc::c_int { - crate::squeezelite_h::_apply_gain(outputbuf, out_frames, gainL, gainR); + if gainL != 0x10000 as libc::c_int || + gainR != 0x10000 as libc::c_int { + _apply_gain(outputbuf, out_frames, gainL, gainR); } } } if alsa.mmap { - let mut w = crate::stdlib::snd_pcm_mmap_commit( - pcmp, - offset, - out_frames as crate::stdlib::snd_pcm_uframes_t, - ); - if w < 0 as libc::c_int as libc::c_long || w != out_frames as libc::c_long { - 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 mmap_commit error\n\x00" as *const u8 as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 14], &[libc::c_char; 14]>( - b"_write_frames\x00", - )) - .as_ptr(), - 615 as libc::c_int, - ); + let mut w: snd_pcm_sframes_t = + snd_pcm_mmap_commit(pcmp, offset, + out_frames as snd_pcm_uframes_t); + if w < 0 as libc::c_int as libc::c_long || + w != out_frames as libc::c_long { + if loglevel as libc::c_uint >= + lWARN as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d mmap_commit error\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 14], + &[libc::c_char; 14]>(b"_write_frames\x00")).as_ptr(), + 615 as libc::c_int); } - return -(1 as libc::c_int); + return -(1 as libc::c_int) } } else { - let mut w_0 = crate::stdlib::snd_pcm_writei( - pcmp, - outputptr, - out_frames as crate::stdlib::snd_pcm_uframes_t, - ); + let mut w_0: snd_pcm_sframes_t = + snd_pcm_writei(pcmp, outputptr, out_frames as snd_pcm_uframes_t); if w_0 < 0 as libc::c_int as libc::c_long { //if (w != -EAGAIN && ((err = snd_pcm_recover(pcmp, w, 1)) < 0)) { - err = crate::stdlib::snd_pcm_recover(pcmp, w_0 as libc::c_int, 1 as libc::c_int); + err = snd_pcm_recover(pcmp, w_0 as libc::c_int, 1 as libc::c_int); if err < 0 as libc::c_int { - static mut recover_count: libc::c_uint = 0 as libc::c_int as libc::c_uint; - if loglevel as libc::c_uint - >= crate::squeezelite_h::lWARN as libc::c_int as libc::c_uint - { + static mut recover_count: libc::c_uint = + 0 as libc::c_int as libc::c_uint; + if loglevel as libc::c_uint >= + lWARN as libc::c_int as libc::c_uint { recover_count = recover_count.wrapping_add(1); - crate::src::utils::logprint( - b"%s %s:%d recover failed: %s [%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"_write_frames\x00", - )) - .as_ptr(), - 626 as libc::c_int, - crate::stdlib::snd_strerror(err), - recover_count, - ); + logprint(b"%s %s:%d recover failed: %s [%u]\n\x00" as + *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 14], + &[libc::c_char; 14]>(b"_write_frames\x00")).as_ptr(), + 626 as libc::c_int, snd_strerror(err), + recover_count); } if recover_count >= 10 as libc::c_int as libc::c_uint { recover_count = 0 as libc::c_int as libc::c_uint; alsa_close(); - pcmp = 0 as *mut crate::stdlib::snd_pcm_t + pcmp = 0 as *mut snd_pcm_t } } - return -(1 as libc::c_int); + return -(1 as libc::c_int) } else { if w_0 != out_frames as libc::c_long { - 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 writei only wrote %u of %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"_write_frames\x00", - )) - .as_ptr(), - 636 as libc::c_int, - w_0, - out_frames, - ); + if loglevel as libc::c_uint >= + lWARN as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d writei only wrote %u of %u\n\x00" as + *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 14], + &[libc::c_char; 14]>(b"_write_frames\x00")).as_ptr(), + 636 as libc::c_int, w_0, out_frames); } } - out_frames = w_0 as crate::squeezelite_h::frames_t + out_frames = w_0 as frames_t } } return out_frames as libc::c_int; } - -unsafe extern "C" fn output_thread(mut arg: *mut libc::c_void) -> *mut libc::c_void { - let mut start = 1 as libc::c_int != 0; - let mut output_off = - output.state as libc::c_int == crate::squeezelite_h::OUTPUT_OFF as libc::c_int; - let mut probe_device = !arg.is_null(); +unsafe extern "C" fn output_thread(mut arg: *mut libc::c_void) + -> *mut libc::c_void { + let mut start: bool = 1 as libc::c_int != 0; + let mut output_off: bool = + output.state as libc::c_int == OUTPUT_OFF as libc::c_int; + let mut probe_device: bool = !arg.is_null(); let mut err: libc::c_int = 0; while running { // disabled output - player is off while output_off { - crate::stdlib::usleep(100000 as libc::c_int as crate::stdlib::__useconds_t); - crate::stdlib::pthread_mutex_lock(&mut (*outputbuf).mutex); + usleep(100000 as libc::c_int as __useconds_t); + pthread_mutex_lock(&mut (*outputbuf).mutex); output_off = - output.state as libc::c_int == crate::squeezelite_h::OUTPUT_OFF as libc::c_int; - crate::stdlib::pthread_mutex_unlock(&mut (*outputbuf).mutex); - if !running { - return 0 as *mut libc::c_void; - } + output.state as libc::c_int == OUTPUT_OFF as libc::c_int; + pthread_mutex_unlock(&mut (*outputbuf).mutex); + if !running { return 0 as *mut libc::c_void } } // wait until device returns - to allow usb audio devices to be turned off if probe_device { while !pcm_probe(output.device) { - 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 waiting for device %s to return\n\x00" as *const u8 - as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 14], &[libc::c_char; 14]>( - b"output_thread\x00", - )) - .as_ptr(), - 665 as libc::c_int, - output.device, - ); + if loglevel as libc::c_uint >= + lDEBUG as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d waiting for device %s to return\n\x00" + as *const u8 as *const libc::c_char, + logtime(), + (*::std::mem::transmute::<&[u8; 14], + &[libc::c_char; 14]>(b"output_thread\x00")).as_ptr(), + 665 as libc::c_int, output.device); } - crate::stdlib::sleep(5 as libc::c_int as libc::c_uint); + sleep(5 as libc::c_int as libc::c_uint); } probe_device = 0 as libc::c_int != 0 } if pcmp.is_null() || alsa.rate != output.current_sample_rate { - 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 open output device: %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"output_thread\x00", - )) - .as_ptr(), - 687 as libc::c_int, - output.device, - ); + if loglevel as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d open output device: %s\n\x00" as *const u8 + as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 14], + &[libc::c_char; 14]>(b"output_thread\x00")).as_ptr(), + 687 as libc::c_int, output.device); } - crate::stdlib::pthread_mutex_lock(&mut (*outputbuf).mutex); + pthread_mutex_lock(&mut (*outputbuf).mutex); // FIXME - some alsa hardware requires opening twice for a new sample rate to work - // this is a workaround which should be removed + // this is a workaround which should be removed if alsa.reopen { - alsa_open( - output.device, - output.current_sample_rate, - output.buffer, - output.period, - ); + alsa_open(output.device, output.current_sample_rate, + output.buffer, output.period); } - if alsa_open( - output.device, - output.current_sample_rate, - output.buffer, - output.period, - ) != 0 - { + if alsa_open(output.device, output.current_sample_rate, + output.buffer, output.period) != 0 { output.error_opening = 1 as libc::c_int != 0; - crate::stdlib::pthread_mutex_unlock(&mut (*outputbuf).mutex); - crate::stdlib::sleep(5 as libc::c_int as libc::c_uint); - continue; + pthread_mutex_unlock(&mut (*outputbuf).mutex); + sleep(5 as libc::c_int as libc::c_uint); + continue ; } else { output.error_opening = 0 as libc::c_int != 0; start = 1 as libc::c_int != 0; - crate::stdlib::pthread_mutex_unlock(&mut (*outputbuf).mutex); + pthread_mutex_unlock(&mut (*outputbuf).mutex); } } - let mut state = crate::stdlib::snd_pcm_state(pcmp); - if state as libc::c_uint == crate::stdlib::SND_PCM_STATE_XRUN 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 XRUN\n\x00" as *const u8 as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 14], &[libc::c_char; 14]>( - b"output_thread\x00", - )) - .as_ptr(), - 717 as libc::c_int, - ); + let mut state: snd_pcm_state_t = snd_pcm_state(pcmp); + if state as libc::c_uint == + SND_PCM_STATE_XRUN as libc::c_int as libc::c_uint { + if loglevel as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d XRUN\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 14], + &[libc::c_char; 14]>(b"output_thread\x00")).as_ptr(), + 717 as libc::c_int); } - err = crate::stdlib::snd_pcm_recover(pcmp, -(32 as libc::c_int), 1 as libc::c_int); + err = + snd_pcm_recover(pcmp, -(32 as libc::c_int), 1 as libc::c_int); if err < 0 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 XRUN recover failed: %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"output_thread\x00", - )) - .as_ptr(), - 719 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); + if loglevel as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d XRUN recover failed: %s\n\x00" as + *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 14], + &[libc::c_char; 14]>(b"output_thread\x00")).as_ptr(), + 719 as libc::c_int, snd_strerror(err)); } } start = 1 as libc::c_int != 0 } else { - if state as libc::c_uint - == crate::stdlib::SND_PCM_STATE_SUSPENDED as libc::c_int as libc::c_uint - { - err = crate::stdlib::snd_pcm_recover(pcmp, -(86 as libc::c_int), 1 as libc::c_int); + if state as libc::c_uint == + SND_PCM_STATE_SUSPENDED as libc::c_int as libc::c_uint { + err = + snd_pcm_recover(pcmp, -(86 as libc::c_int), + 1 as libc::c_int); if err < 0 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 SUSPEND recover failed: %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"output_thread\x00", - )) - .as_ptr(), - 725 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); + if loglevel as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d SUSPEND recover failed: %s\n\x00" + as *const u8 as *const libc::c_char, + logtime(), + (*::std::mem::transmute::<&[u8; 14], + &[libc::c_char; 14]>(b"output_thread\x00")).as_ptr(), + 725 as libc::c_int, snd_strerror(err)); } } - } else if state as libc::c_uint - == crate::stdlib::SND_PCM_STATE_DISCONNECTED 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 Device %s no longer available\n\x00" as *const u8 - as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 14], &[libc::c_char; 14]>( - b"output_thread\x00", - )) - .as_ptr(), - 728 as libc::c_int, - output.device, - ); + } else if state as libc::c_uint == + SND_PCM_STATE_DISCONNECTED as libc::c_int as + libc::c_uint { + if loglevel as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d Device %s no longer available\n\x00" + as *const u8 as *const libc::c_char, + logtime(), + (*::std::mem::transmute::<&[u8; 14], + &[libc::c_char; 14]>(b"output_thread\x00")).as_ptr(), + 728 as libc::c_int, output.device); } alsa_close(); - pcmp = 0 as *mut crate::stdlib::snd_pcm_t; + pcmp = 0 as *mut snd_pcm_t; probe_device = 1 as libc::c_int != 0; - continue; + continue ; } - let mut avail = crate::stdlib::snd_pcm_avail_update(pcmp); + let mut avail: snd_pcm_sframes_t = snd_pcm_avail_update(pcmp); if avail < 0 as libc::c_int as libc::c_long { - err = crate::stdlib::snd_pcm_recover(pcmp, avail as libc::c_int, 1 as libc::c_int); + err = + snd_pcm_recover(pcmp, avail as libc::c_int, + 1 as libc::c_int); if err < 0 as libc::c_int { if err == -(19 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 Device %s no longer available\n\x00" as *const u8 - as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 14], &[libc::c_char; 14]>( - b"output_thread\x00", - )) - .as_ptr(), - 740 as libc::c_int, - output.device, - ); + if loglevel as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d Device %s no longer available\n\x00" + as *const u8 as *const libc::c_char, + logtime(), + (*::std::mem::transmute::<&[u8; 14], + &[libc::c_char; 14]>(b"output_thread\x00")).as_ptr(), + 740 as libc::c_int, output.device); } alsa_close(); - pcmp = 0 as *mut crate::stdlib::snd_pcm_t; + pcmp = 0 as *mut snd_pcm_t; probe_device = 1 as libc::c_int != 0; - continue; - } 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 recover failed: %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"output_thread\x00", - )) - .as_ptr(), - 746 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); + continue ; + } else if loglevel as libc::c_uint >= + lWARN as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d recover failed: %s\n\x00" as + *const u8 as *const libc::c_char, + logtime(), + (*::std::mem::transmute::<&[u8; 14], + &[libc::c_char; 14]>(b"output_thread\x00")).as_ptr(), + 746 as libc::c_int, snd_strerror(err)); } } start = 1 as libc::c_int != 0 } else if (avail as libc::c_ulong) < alsa.period_size { if start { - if alsa.mmap as libc::c_int != 0 && { - err = crate::stdlib::snd_pcm_start(pcmp); - (err) < 0 as libc::c_int - } { - err = crate::stdlib::snd_pcm_recover(pcmp, err, 1 as libc::c_int); - if !(err < 0 as libc::c_int) { - continue; - } + if alsa.mmap as libc::c_int != 0 && + { + err = snd_pcm_start(pcmp); + (err) < 0 as libc::c_int + } { + err = snd_pcm_recover(pcmp, err, 1 as libc::c_int); + if !(err < 0 as libc::c_int) { continue ; } if err == -(19 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 Device %s no longer available\n\x00" as *const u8 - as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 14], &[libc::c_char; 14]>( - b"output_thread\x00", - )) - .as_ptr(), - 757 as libc::c_int, - output.device, - ); + if loglevel as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d Device %s no longer available\n\x00" + as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 14], + &[libc::c_char; 14]>(b"output_thread\x00")).as_ptr(), + 757 as libc::c_int, output.device); } alsa_close(); - pcmp = 0 as *mut crate::stdlib::snd_pcm_t; + pcmp = 0 as *mut snd_pcm_t; probe_device = 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 start error: %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"output_thread\x00", - )) - .as_ptr(), - 763 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); + if loglevel as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d start error: %s\n\x00" as + *const u8 as *const libc::c_char, + logtime(), + (*::std::mem::transmute::<&[u8; 14], + &[libc::c_char; 14]>(b"output_thread\x00")).as_ptr(), + 763 as libc::c_int, + snd_strerror(err)); } - crate::stdlib::usleep( - 10000 as libc::c_int as crate::stdlib::__useconds_t, - ); + usleep(10000 as libc::c_int as __useconds_t); } - } else { - start = 0 as libc::c_int != 0 - } + } else { start = 0 as libc::c_int != 0 } } else { - crate::stdlib::usleep(10000 as libc::c_int as crate::stdlib::__useconds_t); - err = crate::stdlib::snd_pcm_wait(pcmp, 1000 as libc::c_int); + usleep(10000 as libc::c_int as __useconds_t); + err = snd_pcm_wait(pcmp, 1000 as libc::c_int); if err <= 0 as libc::c_int { if err == 0 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 pcm wait timeout\n\x00" as *const u8 - as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 14], &[libc::c_char; 14]>( - b"output_thread\x00", - )) - .as_ptr(), - 773 as libc::c_int, - ); + if loglevel as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d pcm wait timeout\n\x00" as + *const u8 as *const libc::c_char, + logtime(), + (*::std::mem::transmute::<&[u8; 14], + &[libc::c_char; 14]>(b"output_thread\x00")).as_ptr(), + 773 as libc::c_int); } } - err = crate::stdlib::snd_pcm_recover(pcmp, err, 1 as libc::c_int); + err = snd_pcm_recover(pcmp, err, 1 as libc::c_int); if err < 0 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 pcm wait error: %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"output_thread\x00", - )) - .as_ptr(), - 776 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); + if loglevel as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d pcm wait error: %s\n\x00" + as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 14], + &[libc::c_char; 14]>(b"output_thread\x00")).as_ptr(), + 776 as libc::c_int, + snd_strerror(err)); } } start = 1 as libc::c_int != 0 @@ -1817,136 +1835,104 @@ unsafe extern "C" fn output_thread(mut arg: *mut libc::c_void) -> *mut libc::c_v } } else { // restrict avail to within sensible limits as alsa drivers can return erroneous large values - // in writei mode restrict to period_size due to size of write_buf + // in writei mode restrict to period_size due to size of write_buf if alsa.mmap { - avail = if (avail as libc::c_ulong) < alsa.buffer_size { - avail as libc::c_ulong - } else { - alsa.buffer_size - } as crate::stdlib::snd_pcm_sframes_t + avail = + if (avail as libc::c_ulong) < alsa.buffer_size { + avail as libc::c_ulong + } else { alsa.buffer_size } as snd_pcm_sframes_t } else { - avail = if (avail as libc::c_ulong) < alsa.period_size { - avail as libc::c_ulong - } else { - alsa.period_size - } as crate::stdlib::snd_pcm_sframes_t + avail = + if (avail as libc::c_ulong) < alsa.period_size { + avail as libc::c_ulong + } else { alsa.period_size } as snd_pcm_sframes_t } // avoid spinning in cases where wait returns but no bytes available (seen with pulse audio) if avail == 0 as libc::c_int as libc::c_long { - 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 avail 0 - sleeping\n\x00" as *const u8 - as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 14], &[libc::c_char; 14]>( - b"output_thread\x00", - )) - .as_ptr(), - 794 as libc::c_int, - ); + if loglevel as libc::c_uint >= + lSDEBUG as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d avail 0 - sleeping\n\x00" as + *const u8 as *const libc::c_char, + logtime(), + (*::std::mem::transmute::<&[u8; 14], + &[libc::c_char; 14]>(b"output_thread\x00")).as_ptr(), + 794 as libc::c_int); } - crate::stdlib::usleep(10000 as libc::c_int as crate::stdlib::__useconds_t); + usleep(10000 as libc::c_int as __useconds_t); } else { - crate::stdlib::pthread_mutex_lock(&mut (*outputbuf).mutex); + pthread_mutex_lock(&mut (*outputbuf).mutex); // turn off if requested - if output.state as libc::c_int - == crate::squeezelite_h::OUTPUT_OFF as libc::c_int - { - crate::stdlib::pthread_mutex_unlock(&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 disabling output\n\x00" as *const u8 - as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 14], &[libc::c_char; 14]>( - b"output_thread\x00", - )) - .as_ptr(), - 804 as libc::c_int, - ); + if output.state as libc::c_int == + OUTPUT_OFF as libc::c_int { + pthread_mutex_unlock(&mut (*outputbuf).mutex); + if loglevel as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d disabling output\n\x00" as + *const u8 as *const libc::c_char, + logtime(), + (*::std::mem::transmute::<&[u8; 14], + &[libc::c_char; 14]>(b"output_thread\x00")).as_ptr(), + 804 as libc::c_int); } alsa_close(); - pcmp = 0 as *mut crate::stdlib::snd_pcm_t; + pcmp = 0 as *mut snd_pcm_t; output_off = 1 as libc::c_int != 0 } else { // measure output delay - let mut delay: crate::stdlib::snd_pcm_sframes_t = 0; - err = crate::stdlib::snd_pcm_delay(pcmp, &mut delay); + let mut delay: snd_pcm_sframes_t = 0; + err = snd_pcm_delay(pcmp, &mut delay); if err < 0 as libc::c_int { if err == -(32 as libc::c_int) { // EPIPE indicates underrun - attempt to recover - crate::stdlib::pthread_mutex_unlock(&mut (*outputbuf).mutex); - continue; + pthread_mutex_unlock(&mut (*outputbuf).mutex); + continue ; } else if err == -(5 as libc::c_int) { // EIO can occur with non existant pulse server - 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 snd_pcm_delay returns: EIO - sleeping\n\x00" - as *const u8 - as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 14], &[libc::c_char; 14]>( - b"output_thread\x00", - )) - .as_ptr(), - 833 as libc::c_int, - ); + pthread_mutex_unlock(&mut (*outputbuf).mutex); + if loglevel as libc::c_uint >= + lSDEBUG as libc::c_int as libc::c_uint + { + logprint(b"%s %s:%d snd_pcm_delay returns: EIO - sleeping\n\x00" + as *const u8 as + *const libc::c_char, + logtime(), + (*::std::mem::transmute::<&[u8; 14], + &[libc::c_char; 14]>(b"output_thread\x00")).as_ptr(), + 833 as libc::c_int); } - crate::stdlib::usleep( - 100000 as libc::c_int as crate::stdlib::__useconds_t, - ); - continue; - } else 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 snd_pcm_delay returns: %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"output_thread\x00", - )) - .as_ptr(), - 837 as libc::c_int, - err, - ); + usleep(100000 as libc::c_int as __useconds_t); + continue ; + } else if loglevel as libc::c_uint >= + lDEBUG as libc::c_int as + libc::c_uint { + logprint(b"%s %s:%d snd_pcm_delay returns: %d\n\x00" + as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 14], + &[libc::c_char; 14]>(b"output_thread\x00")).as_ptr(), + 837 as libc::c_int, err); } } else { output.device_frames = delay as libc::c_uint; - output.updated = crate::src::utils::gettime_ms(); + output.updated = gettime_ms(); output.frames_played_dmp = output.frames_played } // process frames - let mut wrote = crate::src::output::_output_frames( - avail as crate::squeezelite_h::frames_t, - ); - crate::stdlib::pthread_mutex_unlock(&mut (*outputbuf).mutex); + let mut wrote: frames_t = + _output_frames(avail as frames_t); + pthread_mutex_unlock(&mut (*outputbuf).mutex); // some output devices such as alsa null refuse any data, avoid spinning if wrote == 0 { - 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 0 - sleeping\n\x00" as *const u8 - as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 14], &[libc::c_char; 14]>( - b"output_thread\x00", - )) - .as_ptr(), - 852 as libc::c_int, - ); + if loglevel as libc::c_uint >= + lSDEBUG as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d wrote 0 - sleeping\n\x00" + as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 14], + &[libc::c_char; 14]>(b"output_thread\x00")).as_ptr(), + 852 as libc::c_int); } - crate::stdlib::usleep( - 10000 as libc::c_int as crate::stdlib::__useconds_t, - ); + usleep(10000 as libc::c_int as __useconds_t); } } } @@ -1956,435 +1942,338 @@ unsafe extern "C" fn output_thread(mut arg: *mut libc::c_void) -> *mut libc::c_v return 0 as *mut libc::c_void; } #[no_mangle] - -pub unsafe extern "C" fn mixer_init_alsa( - mut device: *const libc::c_char, - mut mixer: *const libc::c_char, - mut mixer_index: libc::c_int, -) -> libc::c_int { +pub unsafe extern "C" fn mixer_init_alsa(mut device: *const libc::c_char, + mut mixer: *const libc::c_char, + mut mixer_index: libc::c_int) + -> libc::c_int { let mut err: libc::c_int = 0; - let mut sid = 0 as *mut crate::stdlib::snd_mixer_selem_id_t; - err = crate::stdlib::snd_mixer_open(&mut alsa.mixer_handle, 0 as libc::c_int); + let mut sid: *mut snd_mixer_selem_id_t = 0 as *mut snd_mixer_selem_id_t; + err = snd_mixer_open(&mut alsa.mixer_handle, 0 as libc::c_int); if err < 0 as libc::c_int { - crate::src::utils::logprint( - b"%s %s:%d open error: %s\n\x00" as *const u8 as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 16], &[libc::c_char; 16]>(b"mixer_init_alsa\x00")) - .as_ptr(), - 865 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); - return -(1 as libc::c_int); + logprint(b"%s %s:%d open error: %s\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 16], + &[libc::c_char; 16]>(b"mixer_init_alsa\x00")).as_ptr(), + 865 as libc::c_int, snd_strerror(err)); + return -(1 as libc::c_int) } - err = crate::stdlib::snd_mixer_attach(alsa.mixer_handle, device); + err = snd_mixer_attach(alsa.mixer_handle, device); if err < 0 as libc::c_int { - crate::src::utils::logprint( - b"%s %s:%d attach error: %s\n\x00" as *const u8 as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 16], &[libc::c_char; 16]>(b"mixer_init_alsa\x00")) - .as_ptr(), - 869 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); - crate::stdlib::snd_mixer_close(alsa.mixer_handle); - return -(1 as libc::c_int); + logprint(b"%s %s:%d attach error: %s\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 16], + &[libc::c_char; 16]>(b"mixer_init_alsa\x00")).as_ptr(), + 869 as libc::c_int, snd_strerror(err)); + snd_mixer_close(alsa.mixer_handle); + return -(1 as libc::c_int) } - err = crate::stdlib::snd_mixer_selem_register( - alsa.mixer_handle, - 0 as *mut crate::stdlib::snd_mixer_selem_regopt, - 0 as *mut *mut crate::stdlib::snd_mixer_class_t, - ); + err = + snd_mixer_selem_register(alsa.mixer_handle, + 0 as *mut snd_mixer_selem_regopt, + 0 as *mut *mut snd_mixer_class_t); if err < 0 as libc::c_int { - crate::src::utils::logprint( - b"%s %s:%d register error: %s\n\x00" as *const u8 as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 16], &[libc::c_char; 16]>(b"mixer_init_alsa\x00")) - .as_ptr(), - 874 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); - crate::stdlib::snd_mixer_close(alsa.mixer_handle); - return -(1 as libc::c_int); + logprint(b"%s %s:%d register error: %s\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 16], + &[libc::c_char; 16]>(b"mixer_init_alsa\x00")).as_ptr(), + 874 as libc::c_int, snd_strerror(err)); + snd_mixer_close(alsa.mixer_handle); + return -(1 as libc::c_int) } - err = crate::stdlib::snd_mixer_load(alsa.mixer_handle); + err = snd_mixer_load(alsa.mixer_handle); if err < 0 as libc::c_int { - crate::src::utils::logprint( - b"%s %s:%d load error: %s\n\x00" as *const u8 as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 16], &[libc::c_char; 16]>(b"mixer_init_alsa\x00")) - .as_ptr(), - 879 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); - crate::stdlib::snd_mixer_close(alsa.mixer_handle); - return -(1 as libc::c_int); + logprint(b"%s %s:%d load error: %s\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 16], + &[libc::c_char; 16]>(b"mixer_init_alsa\x00")).as_ptr(), + 879 as libc::c_int, snd_strerror(err)); + snd_mixer_close(alsa.mixer_handle); + return -(1 as libc::c_int) } - let mut fresh4 = ::std::vec::from_elem(0, crate::stdlib::snd_mixer_selem_id_sizeof() as usize); - sid = fresh4.as_mut_ptr() as *mut crate::stdlib::snd_mixer_selem_id_t; - crate::stdlib::memset( - sid as *mut libc::c_void, - 0 as libc::c_int, - crate::stdlib::snd_mixer_selem_id_sizeof(), - ); - crate::stdlib::snd_mixer_selem_id_set_index(sid, mixer_index as libc::c_uint); - crate::stdlib::snd_mixer_selem_id_set_name(sid, mixer); - alsa.mixer_elem = crate::stdlib::snd_mixer_find_selem(alsa.mixer_handle, sid); + let mut fresh4 = + ::std::vec::from_elem(0, snd_mixer_selem_id_sizeof() as usize); + sid = fresh4.as_mut_ptr() as *mut snd_mixer_selem_id_t; + memset(sid as *mut libc::c_void, 0 as libc::c_int, + snd_mixer_selem_id_sizeof()); + snd_mixer_selem_id_set_index(sid, mixer_index as libc::c_uint); + snd_mixer_selem_id_set_name(sid, mixer); + alsa.mixer_elem = snd_mixer_find_selem(alsa.mixer_handle, sid); if alsa.mixer_elem.is_null() { - crate::src::utils::logprint( - b"%s %s:%d error find selem %s\n\x00" as *const u8 as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 16], &[libc::c_char; 16]>(b"mixer_init_alsa\x00")) - .as_ptr(), - 889 as libc::c_int, - alsa.mixer_handle, - ); - crate::stdlib::snd_mixer_close(alsa.mixer_handle); - return -(1 as libc::c_int); + logprint(b"%s %s:%d error find selem %s\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 16], + &[libc::c_char; 16]>(b"mixer_init_alsa\x00")).as_ptr(), + 889 as libc::c_int, alsa.mixer_handle); + snd_mixer_close(alsa.mixer_handle); + return -(1 as libc::c_int) } - if crate::stdlib::snd_mixer_selem_has_playback_switch(alsa.mixer_elem) != 0 { - crate::stdlib::snd_mixer_selem_set_playback_switch_all(alsa.mixer_elem, 1 as libc::c_int); + if snd_mixer_selem_has_playback_switch(alsa.mixer_elem) != 0 { + snd_mixer_selem_set_playback_switch_all(alsa.mixer_elem, + 1 as libc::c_int); // unmute } - err = crate::stdlib::snd_mixer_selem_get_playback_dB_range( - alsa.mixer_elem, - &mut alsa.mixer_min, - &mut alsa.mixer_max, - ); - if err < 0 as libc::c_int - || alsa.mixer_max - alsa.mixer_min < 1000 as libc::c_int as libc::c_long - || alsa.mixer_linear as libc::c_int != 0 - { + err = + snd_mixer_selem_get_playback_dB_range(alsa.mixer_elem, + &mut alsa.mixer_min, + &mut alsa.mixer_max); + if err < 0 as libc::c_int || + alsa.mixer_max - alsa.mixer_min < + 1000 as libc::c_int as libc::c_long || + alsa.mixer_linear as libc::c_int != 0 { alsa.mixer_linear = 1 as libc::c_int != 0; // unable to get db range or range is less than 10dB - ignore and set using raw values - err = crate::stdlib::snd_mixer_selem_get_playback_volume_range( - alsa.mixer_elem, - &mut alsa.mixer_min, - &mut alsa.mixer_max, - ); + err = + snd_mixer_selem_get_playback_volume_range(alsa.mixer_elem, + &mut alsa.mixer_min, + &mut alsa.mixer_max); if err < 0 as libc::c_int { - crate::src::utils::logprint( - b"%s %s:%d Unable to get volume raw range\n\x00" as *const u8 - as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 16], &[libc::c_char; 16]>(b"mixer_init_alsa\x00")) - .as_ptr(), - 905 as libc::c_int, - ); - return -(1 as libc::c_int); + logprint(b"%s %s:%d Unable to get volume raw range\n\x00" as + *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 16], + &[libc::c_char; 16]>(b"mixer_init_alsa\x00")).as_ptr(), + 905 as libc::c_int); + return -(1 as libc::c_int) } } return 0 as libc::c_int; } - -static mut thread: crate::stdlib::pthread_t = 0; +static mut thread: pthread_t = 0; #[no_mangle] - -pub unsafe extern "C" fn output_init_alsa( - mut level: crate::squeezelite_h::log_level, - mut device: *const libc::c_char, - 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, - mut rt_priority: libc::c_uint, - mut idle: libc::c_uint, - mut mixer_device: *mut libc::c_char, - mut volume_mixer: *mut libc::c_char, - mut mixer_unmute: bool, - mut mixer_linear: bool, -) { - let mut alsa_buffer = 40 as libc::c_int as libc::c_uint; - let mut alsa_period = 4 as libc::c_int as libc::c_uint; - let mut alsa_sample_fmt = 0 as *mut libc::c_char; - let mut alsa_mmap = 1 as libc::c_int != 0; - let mut alsa_reopen = 0 as libc::c_int != 0; - let mut volume_mixer_name = - crate::src::utils::next_param(volume_mixer, ',' as i32 as libc::c_char); - let mut volume_mixer_index = - crate::src::utils::next_param(0 as *mut libc::c_char, ',' as i32 as libc::c_char); - let mut t = crate::src::utils::next_param(params, ':' as i32 as libc::c_char); - let mut c = crate::src::utils::next_param(0 as *mut libc::c_char, ':' as i32 as libc::c_char); - let mut s = crate::src::utils::next_param(0 as *mut libc::c_char, ':' as i32 as libc::c_char); - let mut m = crate::src::utils::next_param(0 as *mut libc::c_char, ':' as i32 as libc::c_char); - let mut r = crate::src::utils::next_param(0 as *mut libc::c_char, ':' as i32 as libc::c_char); - if !t.is_null() { - alsa_buffer = crate::stdlib::atoi(t) as libc::c_uint - } - if !c.is_null() { - alsa_period = crate::stdlib::atoi(c) as libc::c_uint - } - if !s.is_null() { - alsa_sample_fmt = s - } - if !m.is_null() { - alsa_mmap = crate::stdlib::atoi(m) != 0 - } - if !r.is_null() { - alsa_reopen = crate::stdlib::atoi(r) != 0 - } +pub unsafe extern "C" fn output_init_alsa(mut level: log_level, + mut device: *const libc::c_char, + 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, + mut rt_priority: libc::c_uint, + mut idle: libc::c_uint, + mut mixer_device: *mut libc::c_char, + mut volume_mixer: *mut libc::c_char, + mut mixer_unmute: bool, + mut mixer_linear: bool) { + let mut alsa_buffer: libc::c_uint = 40 as libc::c_int as libc::c_uint; + let mut alsa_period: libc::c_uint = 4 as libc::c_int as libc::c_uint; + let mut alsa_sample_fmt: *mut libc::c_char = 0 as *mut libc::c_char; + let mut alsa_mmap: bool = 1 as libc::c_int != 0; + let mut alsa_reopen: bool = 0 as libc::c_int != 0; + let mut volume_mixer_name: *mut libc::c_char = + next_param(volume_mixer, ',' as i32 as libc::c_char); + let mut volume_mixer_index: *mut libc::c_char = + next_param(0 as *mut libc::c_char, ',' as i32 as libc::c_char); + let mut t: *mut libc::c_char = + next_param(params, ':' as i32 as libc::c_char); + let mut c: *mut libc::c_char = + next_param(0 as *mut libc::c_char, ':' as i32 as libc::c_char); + let mut s: *mut libc::c_char = + next_param(0 as *mut libc::c_char, ':' as i32 as libc::c_char); + let mut m: *mut libc::c_char = + next_param(0 as *mut libc::c_char, ':' as i32 as libc::c_char); + let mut r: *mut libc::c_char = + next_param(0 as *mut libc::c_char, ':' as i32 as libc::c_char); + if !t.is_null() { alsa_buffer = atoi(t) as libc::c_uint } + if !c.is_null() { alsa_period = atoi(c) as libc::c_uint } + if !s.is_null() { alsa_sample_fmt = s } + if !m.is_null() { alsa_mmap = atoi(m) != 0 } + if !r.is_null() { alsa_reopen = atoi(r) != 0 } 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\n\x00" as *const u8 as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"output_init_alsa\x00")) - .as_ptr(), - 939 as libc::c_int, - ); + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d init output\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 17], + &[libc::c_char; 17]>(b"output_init_alsa\x00")).as_ptr(), + 939 as libc::c_int); } - 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::() as libc::c_ulong, - ); + memset(&mut output as *mut outputstate as *mut libc::c_void, + 0 as libc::c_int, + ::std::mem::size_of::() as libc::c_ulong); alsa.mmap = alsa_mmap; - alsa.write_buf = 0 as *mut crate::squeezelite_h::u8_t; - alsa.format = crate::stdlib::SND_PCM_FORMAT_S8; + alsa.write_buf = 0 as *mut u8_t; + alsa.format = SND_PCM_FORMAT_S8; alsa.reopen = alsa_reopen; - alsa.mixer_handle = 0 as *mut crate::stdlib::snd_mixer_t; + alsa.mixer_handle = 0 as *mut snd_mixer_t; alsa.ctl = ctl4device(device); - alsa.mixer_ctl = if !mixer_device.is_null() { - ctl4device(mixer_device) - } else { - alsa.ctl - }; + alsa.mixer_ctl = + if !mixer_device.is_null() { + ctl4device(mixer_device) + } else { alsa.ctl }; alsa.volume_mixer_name = volume_mixer_name; alsa.mixer_linear = mixer_linear; - output.format = crate::squeezelite_h::S32_LE; + output.format = S32_LE; output.buffer = alsa_buffer; output.period = alsa_period; output.start_frames = 0 as libc::c_int as libc::c_uint; - output.write_cb = Some( - _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.write_cb = + Some(_write_frames as + unsafe extern "C" fn(_: frames_t, _: bool, _: s32_t, + _: s32_t, _: s32_t, _: s32_t, + _: *mut *mut s32_t) -> libc::c_int); output.rate_delay = rate_delay; if !alsa_sample_fmt.is_null() { - if crate::stdlib::strcmp( - alsa_sample_fmt, - b"32\x00" as *const u8 as *const libc::c_char, - ) == 0 - { - alsa.format = crate::stdlib::SND_PCM_FORMAT_S32_LE + if strcmp(alsa_sample_fmt, + b"32\x00" as *const u8 as *const libc::c_char) == 0 { + alsa.format = SND_PCM_FORMAT_S32_LE } - if crate::stdlib::strcmp( - alsa_sample_fmt, - b"24\x00" as *const u8 as *const libc::c_char, - ) == 0 - { - alsa.format = crate::stdlib::SND_PCM_FORMAT_S24_LE + if strcmp(alsa_sample_fmt, + b"24\x00" as *const u8 as *const libc::c_char) == 0 { + alsa.format = SND_PCM_FORMAT_S24_LE } - if crate::stdlib::strcmp( - alsa_sample_fmt, - b"24_3\x00" as *const u8 as *const libc::c_char, - ) == 0 - { - alsa.format = crate::stdlib::SND_PCM_FORMAT_S24_3LE + if strcmp(alsa_sample_fmt, + b"24_3\x00" as *const u8 as *const libc::c_char) == 0 { + alsa.format = SND_PCM_FORMAT_S24_3LE } - if crate::stdlib::strcmp( - alsa_sample_fmt, - b"16\x00" as *const u8 as *const libc::c_char, - ) == 0 - { - alsa.format = crate::stdlib::SND_PCM_FORMAT_S16_LE + if strcmp(alsa_sample_fmt, + b"16\x00" as *const u8 as *const libc::c_char) == 0 { + alsa.format = SND_PCM_FORMAT_S16_LE } } - 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 requested alsa_buffer: %u alsa_period: %u format: %s mmap: %u\n\x00" - as *const u8 as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"output_init_alsa\x00")) - .as_ptr(), - 979 as libc::c_int, - output.buffer, - output.period, - if !alsa_sample_fmt.is_null() { - alsa_sample_fmt as *const libc::c_char - } else { - b"any\x00" as *const u8 as *const libc::c_char - }, - alsa.mmap as libc::c_int, - ); + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d requested alsa_buffer: %u alsa_period: %u format: %s mmap: %u\n\x00" + as *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 17], + &[libc::c_char; 17]>(b"output_init_alsa\x00")).as_ptr(), + 979 as libc::c_int, output.buffer, output.period, + if !alsa_sample_fmt.is_null() { + alsa_sample_fmt as *const libc::c_char + } else { b"any\x00" as *const u8 as *const libc::c_char }, + alsa.mmap as libc::c_int); } - crate::stdlib::snd_lib_error_set_handler(::std::mem::transmute::< - Option< - unsafe extern "C" fn( - _: *const libc::c_char, - _: libc::c_int, - _: *const libc::c_char, - _: libc::c_int, - _: *const libc::c_char, - _: ... - ) -> *mut libc::c_void, - >, - crate::stdlib::snd_lib_error_handler_t, - >(Some( - alsa_error_handler - as unsafe extern "C" fn( - _: *const libc::c_char, - _: libc::c_int, - _: *const libc::c_char, - _: libc::c_int, - _: *const libc::c_char, - _: ... - ) -> *mut libc::c_void, - ))); - crate::src::output::output_init_common(level, device, output_buf_size, rates, idle); + snd_lib_error_set_handler(::std::mem::transmute:: + *mut libc::c_void>, + snd_lib_error_handler_t>(Some(alsa_error_handler + as + unsafe extern "C" fn(_: + *const libc::c_char, + _: + libc::c_int, + _: + *const libc::c_char, + _: + libc::c_int, + _: + *const libc::c_char, + _: + ...) + -> + *mut libc::c_void))); + output_init_common(level, device, output_buf_size, rates, idle); if !volume_mixer_name.is_null() { - if mixer_init_alsa( - alsa.mixer_ctl, - alsa.volume_mixer_name, - (if !volume_mixer_index.is_null() { - crate::stdlib::atoi(volume_mixer_index) - } else { - 0 as libc::c_int - }), - ) < 0 as libc::c_int - { - crate::src::utils::logprint( - b"%s %s:%d Initialization of mixer failed, reverting to software volume\n\x00" - as *const u8 as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"output_init_alsa\x00")) - .as_ptr(), - 989 as libc::c_int, - ); - alsa.mixer_handle = 0 as *mut crate::stdlib::snd_mixer_t; + if mixer_init_alsa(alsa.mixer_ctl, alsa.volume_mixer_name, + (if !volume_mixer_index.is_null() { + atoi(volume_mixer_index) + } else { 0 as libc::c_int })) < 0 as libc::c_int { + logprint(b"%s %s:%d Initialization of mixer failed, reverting to software volume\n\x00" + as *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 17], + &[libc::c_char; 17]>(b"output_init_alsa\x00")).as_ptr(), + 989 as libc::c_int); + alsa.mixer_handle = 0 as *mut snd_mixer_t; alsa.volume_mixer_name = 0 as *const libc::c_char } } if mixer_unmute as libc::c_int != 0 && !alsa.volume_mixer_name.is_null() { - set_mixer( - 1 as libc::c_int != 0, - 0 as libc::c_int as libc::c_float, - 0 as libc::c_int as libc::c_float, - ); + set_mixer(1 as libc::c_int != 0, 0 as libc::c_int as libc::c_float, + 0 as libc::c_int as libc::c_float); alsa.volume_mixer_name = 0 as *const libc::c_char } - // RT linux - aim to avoid pagefaults by locking memory: - // https://rt.wiki.kernel.org/index.php/Threaded_RT-application_with_memory_locking_and_stack_handling_example - if crate::stdlib::mlockall(1 as libc::c_int | 2 as libc::c_int) == -(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 unable to lock memory: %s\n\x00" as *const u8 as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"output_init_alsa\x00")) - .as_ptr(), - 1003 as libc::c_int, - crate::stdlib::strerror(*crate::stdlib::__errno_location()), - ); + // RT linux - aim to avoid pagefaults by locking memory: + // https://rt.wiki.kernel.org/index.php/Threaded_RT-application_with_memory_locking_and_stack_handling_example + if mlockall(1 as libc::c_int | 2 as libc::c_int) == -(1 as libc::c_int) { + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d unable to lock memory: %s\n\x00" as *const u8 + as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 17], + &[libc::c_char; 17]>(b"output_init_alsa\x00")).as_ptr(), + 1003 as libc::c_int, strerror(*__errno_location())); } - } 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 memory locked\n\x00" as *const u8 as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"output_init_alsa\x00")) - .as_ptr(), - 1005 as libc::c_int, - ); + } else if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint + { + logprint(b"%s %s:%d memory locked\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 17], + &[libc::c_char; 17]>(b"output_init_alsa\x00")).as_ptr(), + 1005 as libc::c_int); } - crate::stdlib::mallopt(-(1 as libc::c_int), -(1 as libc::c_int)); - crate::stdlib::mallopt(-(4 as libc::c_int), 0 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 glibc detected using mallopt\n\x00" as *const u8 as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"output_init_alsa\x00")) - .as_ptr(), - 1011 as libc::c_int, - ); + mallopt(-(1 as libc::c_int), -(1 as libc::c_int)); + mallopt(-(4 as libc::c_int), 0 as libc::c_int); + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d glibc detected using mallopt\n\x00" as *const u8 + as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 17], + &[libc::c_char; 17]>(b"output_init_alsa\x00")).as_ptr(), + 1011 as libc::c_int); } - crate::src::utils::touch_memory( - silencebuf, - (2048 as libc::c_int * 8 as libc::c_int) as crate::stddef_h::size_t, - ); - crate::src::utils::touch_memory((*outputbuf).buf, (*outputbuf).size); + touch_memory(silencebuf, + (2048 as libc::c_int * 8 as libc::c_int) as size_t); + touch_memory((*outputbuf).buf, (*outputbuf).size); // start output thread - 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, - Some(output_thread as unsafe extern "C" fn(_: *mut libc::c_void) -> *mut libc::c_void), - if *rates.offset(0 as libc::c_int as isize) != 0 { - b"probe\x00" as *const u8 as *const libc::c_char - } else { - 0 as *const libc::c_char - } as *mut libc::c_void, - ); - crate::stdlib::pthread_attr_destroy(&mut attr); + let mut attr: pthread_attr_t = pthread_attr_t{__size: [0; 56],}; + pthread_attr_init(&mut attr); + pthread_attr_setstacksize(&mut attr, + (16384 as libc::c_int + + 64 as libc::c_int * 1024 as libc::c_int) as + size_t); + pthread_create(&mut thread, &mut attr, + Some(output_thread as + unsafe extern "C" fn(_: *mut libc::c_void) + -> *mut libc::c_void), + if *rates.offset(0 as libc::c_int as isize) != 0 { + b"probe\x00" as *const u8 as *const libc::c_char + } else { 0 as *const libc::c_char } as *mut libc::c_void); + pthread_attr_destroy(&mut attr); // try to set this thread to real-time scheduler class, only works as root or if user has permission - let mut param = crate::stdlib::sched_param { sched_priority: 0 }; + let mut param: sched_param = sched_param{sched_priority: 0,}; param.sched_priority = rt_priority as libc::c_int; - if crate::stdlib::pthread_setschedparam(thread, 1 as libc::c_int, &mut param) - != 0 as libc::c_int - { - 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 unable to set output sched fifo: %s\n\x00" as *const u8 - as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"output_init_alsa\x00")) - .as_ptr(), - 1029 as libc::c_int, - crate::stdlib::strerror(*crate::stdlib::__errno_location()), - ); + if pthread_setschedparam(thread, 1 as libc::c_int, &mut param) != + 0 as libc::c_int { + if loglevel as libc::c_uint >= lDEBUG as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d unable to set output sched fifo: %s\n\x00" as + *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 17], + &[libc::c_char; 17]>(b"output_init_alsa\x00")).as_ptr(), + 1029 as libc::c_int, strerror(*__errno_location())); } - } else 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 set output sched fifo rt: %u\n\x00" as *const u8 as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"output_init_alsa\x00")) - .as_ptr(), - 1031 as libc::c_int, - param.sched_priority, - ); + } else if loglevel as libc::c_uint >= + lDEBUG as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d set output sched fifo rt: %u\n\x00" as *const u8 + as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 17], + &[libc::c_char; 17]>(b"output_init_alsa\x00")).as_ptr(), + 1031 as libc::c_int, param.sched_priority); }; } #[no_mangle] - pub unsafe extern "C" fn output_close_alsa() { - 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; 18], &[libc::c_char; 18]>(b"output_close_alsa\x00")) - .as_ptr(), - 1036 as libc::c_int, - ); + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d close output\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 18], + &[libc::c_char; 18]>(b"output_close_alsa\x00")).as_ptr(), + 1036 as libc::c_int); } - crate::stdlib::pthread_mutex_lock(&mut (*outputbuf).mutex); + pthread_mutex_lock(&mut (*outputbuf).mutex); running = 0 as libc::c_int != 0; - crate::stdlib::pthread_mutex_unlock(&mut (*outputbuf).mutex); - crate::stdlib::pthread_join(thread, 0 as *mut *mut libc::c_void); + pthread_mutex_unlock(&mut (*outputbuf).mutex); + pthread_join(thread, 0 as *mut *mut libc::c_void); if !alsa.write_buf.is_null() { - crate::stdlib::free(alsa.write_buf as *mut libc::c_void); - } - if !alsa.ctl.is_null() { - crate::stdlib::free(alsa.ctl as *mut libc::c_void); + free(alsa.write_buf as *mut libc::c_void); } + if !alsa.ctl.is_null() { free(alsa.ctl as *mut libc::c_void); } if !alsa.mixer_ctl.is_null() { - crate::stdlib::free(alsa.mixer_ctl as *mut libc::c_void); + free(alsa.mixer_ctl as *mut libc::c_void); } - if !alsa.mixer_handle.is_null() { - crate::stdlib::snd_mixer_close(alsa.mixer_handle); - } - crate::src::output::output_close_common(); + if !alsa.mixer_handle.is_null() { snd_mixer_close(alsa.mixer_handle); } + output_close_common(); } // ALSA diff --git a/src/output_pa.rs b/src/output_pa.rs index f86a2d8..c1d881c 100644 --- a/src/output_pa.rs +++ b/src/output_pa.rs @@ -1,7 +1,7 @@ use ::libc; // PORTAUDIO // Portaudio output -/* +/* * Squeezelite - lightweight headless squeezebox emulator * * (c) Adrian Smith 2012-2015, triode1@btinternet.com @@ -11,7 +11,7 @@ use ::libc; * 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 diff --git a/src/output_pack.rs b/src/output_pack.rs index bcb5b16..873ed0b 100644 --- a/src/output_pack.rs +++ b/src/output_pack.rs @@ -1,324 +1,350 @@ 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; +extern "C" { + #[no_mangle] + fn memcpy(_: *mut libc::c_void, _: *const libc::c_void, _: libc::c_ulong) + -> *mut libc::c_void; +} +pub type __uint8_t = libc::c_uchar; +pub type __int32_t = libc::c_int; +pub type __uint32_t = libc::c_uint; +pub type __int64_t = libc::c_long; +pub type int32_t = __int32_t; +pub type int64_t = __int64_t; +pub type u_int8_t = __uint8_t; +pub type u_int32_t = __uint32_t; +pub type u8_t = u_int8_t; +pub type u32_t = u_int32_t; +pub type s32_t = int32_t; +pub type s64_t = int64_t; +pub type frames_t = u32_t; +pub type uintptr_t = libc::c_ulong; +pub type output_format = libc::c_uint; +pub const S16_LE: output_format = 3; +pub const S24_3LE: output_format = 2; +pub const S24_LE: output_format = 1; +pub const S32_LE: output_format = 0; // inlining these on windows prevents them being linkable... #[inline] - -unsafe extern "C" fn gain( - mut gain_0: 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; +unsafe extern "C" fn gain(mut gain_0: s32_t, mut sample: s32_t) -> s32_t { + let mut res: s64_t = gain_0 as s64_t * sample as s64_t; if res as libc::c_longlong > 0x7fffffffffff as libc::c_longlong { - res = 0x7fffffffffff as libc::c_longlong as crate::squeezelite_h::s64_t + res = 0x7fffffffffff as libc::c_longlong as s64_t } if (res as libc::c_longlong) < -(0x7fffffffffff as libc::c_longlong) { - res = -(0x7fffffffffff as libc::c_longlong) as crate::squeezelite_h::s64_t + res = -(0x7fffffffffff as libc::c_longlong) as s64_t } - return (res >> 16 as libc::c_int) as crate::squeezelite_h::s32_t; + return (res >> 16 as libc::c_int) as s32_t; } #[no_mangle] - -pub unsafe extern "C" fn _scale_and_pack_frames( - mut outputptr: *mut libc::c_void, - mut inputptr: *mut 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, -) { +pub unsafe extern "C" fn _scale_and_pack_frames(mut outputptr: + *mut libc::c_void, + mut inputptr: *mut s32_t, + mut cnt: frames_t, + mut gainL: s32_t, + mut gainR: s32_t, + mut format: output_format) { match format as libc::c_uint { 3 => { - let mut optr = outputptr as *mut crate::squeezelite_h::u32_t; - if gainL == 0x10000 as libc::c_int && gainR == 0x10000 as libc::c_int { - loop { + let mut optr: *mut u32_t = outputptr as *mut u32_t; + if gainL == 0x10000 as libc::c_int && + gainR == 0x10000 as libc::c_int { + loop { let fresh0 = cnt; cnt = cnt.wrapping_sub(1); - if !(fresh0 != 0) { - break; - } + 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; + *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 { + loop { let fresh2 = cnt; cnt = cnt.wrapping_sub(1); - if !(fresh2 != 0) { - break; - } + 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; + *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 mut optr_0: *mut u32_t = outputptr as *mut u32_t; + if gainL == 0x10000 as libc::c_int && + gainR == 0x10000 as libc::c_int { + loop { let fresh4 = cnt; cnt = cnt.wrapping_sub(1); - if !(fresh4 != 0) { - break; - } + 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; + *fresh6 = (*fresh5 >> 8 as libc::c_int) as u32_t; let fresh7 = inputptr; inputptr = inputptr.offset(1); let fresh8 = optr_0; optr_0 = optr_0.offset(1); - *fresh8 = (*fresh7 >> 8 as libc::c_int) as crate::squeezelite_h::u32_t + *fresh8 = (*fresh7 >> 8 as libc::c_int) as u32_t } } else { - loop { + loop { let fresh9 = cnt; cnt = cnt.wrapping_sub(1); - if !(fresh9 != 0) { - break; - } + 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; + (gain(gainL, *fresh10) >> 8 as libc::c_int) as u32_t; let fresh12 = inputptr; inputptr = inputptr.offset(1); let fresh13 = optr_0; optr_0 = optr_0.offset(1); *fresh13 = - (gain(gainR, *fresh12) >> 8 as libc::c_int) as crate::squeezelite_h::u32_t + (gain(gainR, *fresh12) >> 8 as libc::c_int) as 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 { + let mut optr_1: *mut u8_t = outputptr as *mut u8_t; + if gainL == 0x10000 as libc::c_int && + gainR == 0x10000 as libc::c_int { while cnt != 0 { // attempt to do 32 bit memory accesses - move 2 frames at once: 16 bytes -> 12 bytes - // falls through to exception case when not aligned or if less than 2 frames to move - if optr_1 as 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; + // falls through to exception case when not aligned or if less than 2 frames to move + if optr_1 as uintptr_t & + 0x3 as libc::c_int as libc::c_ulong == + 0 as libc::c_int as libc::c_ulong && + cnt >= 2 as libc::c_int as libc::c_uint { + let mut o_ptr: *mut u32_t = + optr_1 as *mut libc::c_void as *mut u32_t; while cnt >= 2 as libc::c_int as libc::c_uint { let fresh14 = inputptr; inputptr = inputptr.offset(1); - let mut l1 = *fresh14; + let mut l1: s32_t = *fresh14; let fresh15 = inputptr; inputptr = inputptr.offset(1); - let mut r1 = *fresh15; + let mut r1: s32_t = *fresh15; let fresh16 = inputptr; inputptr = inputptr.offset(1); - let mut l2 = *fresh16; + let mut l2: s32_t = *fresh16; let fresh17 = inputptr; inputptr = inputptr.offset(1); - let mut r2 = *fresh17; + let mut r2: s32_t = *fresh17; let fresh18 = o_ptr; o_ptr = o_ptr.offset(1); - *fresh18 = (l1 as libc::c_uint & 0xffffff00 as libc::c_uint) - >> 8 as libc::c_int - | ((r1 & 0xff00 as libc::c_int) << 16 as libc::c_int) - as libc::c_uint; + *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; + *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 + *fresh20 = + (l2 as libc::c_uint & + 0xff000000 as libc::c_uint) >> + 24 as libc::c_int | + r2 as libc::c_uint & + 0xffffff00 as libc::c_uint; + optr_1 = + optr_1.offset(12 as libc::c_int as isize); + cnt = + (cnt as + libc::c_uint).wrapping_sub(2 as + libc::c_int + as + libc::c_uint) + as frames_t as frames_t } } else { let fresh21 = inputptr; inputptr = inputptr.offset(1); - let mut lsample = *fresh21; + let mut lsample: s32_t = *fresh21; let fresh22 = inputptr; inputptr = inputptr.offset(1); - let mut rsample = *fresh22; + let mut rsample: s32_t = *fresh22; let fresh23 = optr_1; optr_1 = optr_1.offset(1); - *fresh23 = ((lsample & 0xff00 as libc::c_int) >> 8 as libc::c_int) - as crate::squeezelite_h::u8_t; + *fresh23 = + ((lsample & 0xff00 as libc::c_int) >> + 8 as libc::c_int) as u8_t; let fresh24 = optr_1; optr_1 = optr_1.offset(1); - *fresh24 = ((lsample & 0xff0000 as libc::c_int) >> 16 as libc::c_int) - as crate::squeezelite_h::u8_t; + *fresh24 = + ((lsample & 0xff0000 as libc::c_int) >> + 16 as libc::c_int) as u8_t; let fresh25 = optr_1; optr_1 = optr_1.offset(1); - *fresh25 = ((lsample as libc::c_uint & 0xff000000 as libc::c_uint) - >> 24 as libc::c_int) - as crate::squeezelite_h::u8_t; + *fresh25 = + ((lsample as libc::c_uint & + 0xff000000 as libc::c_uint) >> + 24 as libc::c_int) as u8_t; let fresh26 = optr_1; optr_1 = optr_1.offset(1); - *fresh26 = ((rsample & 0xff00 as libc::c_int) >> 8 as libc::c_int) - as crate::squeezelite_h::u8_t; + *fresh26 = + ((rsample & 0xff00 as libc::c_int) >> + 8 as libc::c_int) as u8_t; let fresh27 = optr_1; optr_1 = optr_1.offset(1); - *fresh27 = ((rsample & 0xff0000 as libc::c_int) >> 16 as libc::c_int) - as crate::squeezelite_h::u8_t; + *fresh27 = + ((rsample & 0xff0000 as libc::c_int) >> + 16 as libc::c_int) as u8_t; let fresh28 = optr_1; optr_1 = optr_1.offset(1); - *fresh28 = ((rsample as libc::c_uint & 0xff000000 as libc::c_uint) - >> 24 as libc::c_int) - as crate::squeezelite_h::u8_t; + *fresh28 = + ((rsample as libc::c_uint & + 0xff000000 as libc::c_uint) >> + 24 as libc::c_int) as u8_t; cnt = cnt.wrapping_sub(1) } } } else { while cnt != 0 { // attempt to do 32 bit memory accesses - move 2 frames at once: 16 bytes -> 12 bytes - // falls through to exception case when not aligned or if less than 2 frames to move - if optr_1 as 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; + // falls through to exception case when not aligned or if less than 2 frames to move + if optr_1 as uintptr_t & + 0x3 as libc::c_int as libc::c_ulong == + 0 as libc::c_int as libc::c_ulong && + cnt >= 2 as libc::c_int as libc::c_uint { + let mut o_ptr_0: *mut u32_t = + optr_1 as *mut libc::c_void as *mut u32_t; while cnt >= 2 as libc::c_int as libc::c_uint { let fresh29 = inputptr; inputptr = inputptr.offset(1); - let mut l1_0 = gain(gainL, *fresh29); + let mut l1_0: s32_t = gain(gainL, *fresh29); let fresh30 = inputptr; inputptr = inputptr.offset(1); - let mut r1_0 = gain(gainR, *fresh30); + let mut r1_0: s32_t = gain(gainR, *fresh30); let fresh31 = inputptr; inputptr = inputptr.offset(1); - let mut l2_0 = gain(gainL, *fresh31); + let mut l2_0: s32_t = gain(gainL, *fresh31); let fresh32 = inputptr; inputptr = inputptr.offset(1); - let mut r2_0 = gain(gainR, *fresh32); + let mut r2_0: s32_t = gain(gainR, *fresh32); let fresh33 = o_ptr_0; o_ptr_0 = o_ptr_0.offset(1); - *fresh33 = (l1_0 as libc::c_uint & 0xffffff00 as libc::c_uint) - >> 8 as libc::c_int - | ((r1_0 & 0xff00 as libc::c_int) << 16 as libc::c_int) - as libc::c_uint; + *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; + *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 + *fresh35 = + (l2_0 as libc::c_uint & + 0xff000000 as libc::c_uint) >> + 24 as libc::c_int | + r2_0 as libc::c_uint & + 0xffffff00 as libc::c_uint; + optr_1 = + optr_1.offset(12 as libc::c_int as isize); + cnt = + (cnt as + libc::c_uint).wrapping_sub(2 as + libc::c_int + as + libc::c_uint) + as frames_t as frames_t } } else { let fresh36 = inputptr; inputptr = inputptr.offset(1); - let mut lsample_0 = gain(gainL, *fresh36); + let mut lsample_0: s32_t = gain(gainL, *fresh36); let fresh37 = inputptr; inputptr = inputptr.offset(1); - let mut rsample_0 = gain(gainR, *fresh37); + let mut rsample_0: s32_t = gain(gainR, *fresh37); let fresh38 = optr_1; optr_1 = optr_1.offset(1); - *fresh38 = ((lsample_0 & 0xff00 as libc::c_int) >> 8 as libc::c_int) - as crate::squeezelite_h::u8_t; + *fresh38 = + ((lsample_0 & 0xff00 as libc::c_int) >> + 8 as libc::c_int) as u8_t; let fresh39 = optr_1; optr_1 = optr_1.offset(1); - *fresh39 = ((lsample_0 & 0xff0000 as libc::c_int) >> 16 as libc::c_int) - as crate::squeezelite_h::u8_t; + *fresh39 = + ((lsample_0 & 0xff0000 as libc::c_int) >> + 16 as libc::c_int) as u8_t; let fresh40 = optr_1; optr_1 = optr_1.offset(1); - *fresh40 = ((lsample_0 as libc::c_uint & 0xff000000 as libc::c_uint) - >> 24 as libc::c_int) - as crate::squeezelite_h::u8_t; + *fresh40 = + ((lsample_0 as libc::c_uint & + 0xff000000 as libc::c_uint) >> + 24 as libc::c_int) as u8_t; let fresh41 = optr_1; optr_1 = optr_1.offset(1); - *fresh41 = ((rsample_0 & 0xff00 as libc::c_int) >> 8 as libc::c_int) - as crate::squeezelite_h::u8_t; + *fresh41 = + ((rsample_0 & 0xff00 as libc::c_int) >> + 8 as libc::c_int) as u8_t; let fresh42 = optr_1; optr_1 = optr_1.offset(1); - *fresh42 = ((rsample_0 & 0xff0000 as libc::c_int) >> 16 as libc::c_int) - as crate::squeezelite_h::u8_t; + *fresh42 = + ((rsample_0 & 0xff0000 as libc::c_int) >> + 16 as libc::c_int) as u8_t; let fresh43 = optr_1; optr_1 = optr_1.offset(1); - *fresh43 = ((rsample_0 as libc::c_uint & 0xff000000 as libc::c_uint) - >> 24 as libc::c_int) - as crate::squeezelite_h::u8_t; + *fresh43 = + ((rsample_0 as libc::c_uint & + 0xff000000 as libc::c_uint) >> + 24 as libc::c_int) as u8_t; cnt = cnt.wrapping_sub(1) } } } } 0 => { - let mut optr_2 = 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, - ); + let mut optr_2: *mut u32_t = outputptr as *mut u32_t; + if gainL == 0x10000 as libc::c_int && + gainR == 0x10000 as libc::c_int { + memcpy(outputptr, inputptr as *const libc::c_void, + cnt.wrapping_mul(8 as libc::c_int as libc::c_uint) as + libc::c_ulong); } else { - loop { + loop { let fresh44 = cnt; cnt = cnt.wrapping_sub(1); - if !(fresh44 != 0) { - break; - } + 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; + *fresh46 = gain(gainL, *fresh45) as u32_t; let fresh47 = inputptr; inputptr = inputptr.offset(1); let fresh48 = optr_2; optr_2 = optr_2.offset(1); - *fresh48 = gain(gainR, *fresh47) as crate::squeezelite_h::u32_t + *fresh48 = gain(gainR, *fresh47) as u32_t } } } - _ => {} + _ => { } }; } diff --git a/src/output_pulse.rs b/src/output_pulse.rs index 77f5f52..fe6d259 100644 --- a/src/output_pulse.rs +++ b/src/output_pulse.rs @@ -1,6 +1,6 @@ use ::libc; // Output using PulseAudio -/* +/* * Squeezelite - lightweight headless squeezebox emulator * * (c) Adrian Smith 2012-2015, triode1@btinternet.com @@ -10,7 +10,7 @@ use ::libc; * 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 diff --git a/src/output_stdout.rs b/src/output_stdout.rs index a3a0d25..988fbff 100644 --- a/src/output_stdout.rs +++ b/src/output_stdout.rs @@ -1,286 +1,396 @@ 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" { + pub type _IO_wide_data; + pub type _IO_codecvt; + pub type _IO_marker; #[no_mangle] - pub static mut output: crate::squeezelite_h::outputstate; + static mut stdout: *mut FILE; #[no_mangle] - pub static mut outputbuf: *mut crate::squeezelite_h::buffer; + fn fwrite(_: *const libc::c_void, _: libc::c_ulong, _: libc::c_ulong, + _: *mut FILE) -> libc::c_ulong; #[no_mangle] - pub static mut silencebuf: *mut crate::squeezelite_h::u8_t; + fn malloc(_: libc::c_ulong) -> *mut libc::c_void; + #[no_mangle] + fn free(__ptr: *mut libc::c_void); + #[no_mangle] + fn memset(_: *mut libc::c_void, _: libc::c_int, _: libc::c_ulong) + -> *mut libc::c_void; + #[no_mangle] + fn strcmp(_: *const libc::c_char, _: *const libc::c_char) -> libc::c_int; + #[no_mangle] + fn _apply_cross(outputbuf_0: *mut buffer, out_frames: frames_t, + cross_gain_in: s32_t, cross_gain_out: s32_t, + cross_ptr: *mut *mut s32_t); + #[no_mangle] + fn _scale_and_pack_frames(outputptr: *mut libc::c_void, + inputptr: *mut s32_t, cnt: frames_t, + gainL: s32_t, gainR: s32_t, + format: output_format); + #[no_mangle] + fn _output_frames(avail: frames_t) -> frames_t; + #[no_mangle] + fn output_close_common(); + #[no_mangle] + fn output_init_common(level: log_level, device: *const libc::c_char, + output_buf_size: libc::c_uint, + rates: *mut libc::c_uint, idle: libc::c_uint); + #[no_mangle] + fn pthread_create(__newthread: *mut pthread_t, + __attr: *const pthread_attr_t, + __start_routine: + Option *mut libc::c_void>, + __arg: *mut libc::c_void) -> libc::c_int; + #[no_mangle] + fn pthread_attr_init(__attr: *mut pthread_attr_t) -> libc::c_int; + #[no_mangle] + fn pthread_attr_destroy(__attr: *mut pthread_attr_t) -> libc::c_int; + #[no_mangle] + fn pthread_attr_setstacksize(__attr: *mut pthread_attr_t, + __stacksize: size_t) -> libc::c_int; + #[no_mangle] + fn pthread_mutex_lock(__mutex: *mut pthread_mutex_t) -> libc::c_int; + #[no_mangle] + fn pthread_mutex_unlock(__mutex: *mut pthread_mutex_t) -> libc::c_int; + #[no_mangle] + fn logtime() -> *const libc::c_char; + #[no_mangle] + fn logprint(fmt: *const libc::c_char, _: ...); + #[no_mangle] + fn gettime_ms() -> u32_t; + #[no_mangle] + static mut output: outputstate; + #[no_mangle] + static mut outputbuf: *mut buffer; + #[no_mangle] + static mut silencebuf: *mut u8_t; } - -static mut loglevel: crate::squeezelite_h::log_level = crate::squeezelite_h::lERROR; - +pub type size_t = libc::c_ulong; +pub type __uint8_t = libc::c_uchar; +pub type __int32_t = libc::c_int; +pub type __uint32_t = libc::c_uint; +pub type __off_t = libc::c_long; +pub type __off64_t = libc::c_long; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct _IO_FILE { + pub _flags: libc::c_int, + pub _IO_read_ptr: *mut libc::c_char, + pub _IO_read_end: *mut libc::c_char, + pub _IO_read_base: *mut libc::c_char, + pub _IO_write_base: *mut libc::c_char, + pub _IO_write_ptr: *mut libc::c_char, + pub _IO_write_end: *mut libc::c_char, + pub _IO_buf_base: *mut libc::c_char, + pub _IO_buf_end: *mut libc::c_char, + pub _IO_save_base: *mut libc::c_char, + pub _IO_backup_base: *mut libc::c_char, + pub _IO_save_end: *mut libc::c_char, + pub _markers: *mut _IO_marker, + pub _chain: *mut _IO_FILE, + pub _fileno: libc::c_int, + pub _flags2: libc::c_int, + pub _old_offset: __off_t, + pub _cur_column: libc::c_ushort, + pub _vtable_offset: libc::c_schar, + pub _shortbuf: [libc::c_char; 1], + pub _lock: *mut libc::c_void, + pub _offset: __off64_t, + pub _codecvt: *mut _IO_codecvt, + pub _wide_data: *mut _IO_wide_data, + pub _freeres_list: *mut _IO_FILE, + pub _freeres_buf: *mut libc::c_void, + pub __pad5: size_t, + pub _mode: libc::c_int, + pub _unused2: [libc::c_char; 20], +} +pub type _IO_lock_t = (); +pub type FILE = _IO_FILE; +pub type int32_t = __int32_t; +pub type u_int8_t = __uint8_t; +pub type u_int32_t = __uint32_t; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct __pthread_internal_list { + pub __prev: *mut __pthread_internal_list, + pub __next: *mut __pthread_internal_list, +} +pub type __pthread_list_t = __pthread_internal_list; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct __pthread_mutex_s { + pub __lock: libc::c_int, + pub __count: libc::c_uint, + pub __owner: libc::c_int, + pub __nusers: libc::c_uint, + pub __kind: libc::c_int, + pub __spins: libc::c_short, + pub __elision: libc::c_short, + pub __list: __pthread_list_t, +} +pub type pthread_t = libc::c_ulong; +#[derive(Copy, Clone)] +#[repr(C)] +pub union pthread_attr_t { + pub __size: [libc::c_char; 56], + pub __align: libc::c_long, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub union pthread_mutex_t { + pub __data: __pthread_mutex_s, + pub __size: [libc::c_char; 40], + pub __align: libc::c_long, +} +pub type u8_t = u_int8_t; +pub type u32_t = u_int32_t; +pub type s32_t = int32_t; +pub type frames_t = u32_t; +pub type log_level = libc::c_uint; +pub const lSDEBUG: log_level = 4; +pub const lDEBUG: log_level = 3; +pub const lINFO: log_level = 2; +pub const lWARN: log_level = 1; +pub const lERROR: log_level = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct buffer { + pub buf: *mut u8_t, + pub readp: *mut u8_t, + pub writep: *mut u8_t, + pub wrap: *mut u8_t, + pub size: size_t, + pub base_size: size_t, + pub mutex: pthread_mutex_t, +} +pub type output_state = libc::c_int; +pub const OUTPUT_START_AT: output_state = 5; +pub const OUTPUT_SKIP_FRAMES: output_state = 4; +pub const OUTPUT_PAUSE_FRAMES: output_state = 3; +pub const OUTPUT_RUNNING: output_state = 2; +pub const OUTPUT_BUFFER: output_state = 1; +pub const OUTPUT_STOPPED: output_state = 0; +pub const OUTPUT_OFF: output_state = -1; +pub type output_format = libc::c_uint; +pub const S16_LE: output_format = 3; +pub const S24_3LE: output_format = 2; +pub const S24_LE: output_format = 1; +pub const S32_LE: output_format = 0; +pub type fade_state = libc::c_uint; +pub const FADE_ACTIVE: fade_state = 2; +pub const FADE_DUE: fade_state = 1; +pub const FADE_INACTIVE: fade_state = 0; +pub type fade_dir = libc::c_uint; +pub const FADE_CROSS: fade_dir = 3; +pub const FADE_DOWN: fade_dir = 2; +pub const FADE_UP: fade_dir = 1; +pub type fade_mode = libc::c_uint; +pub const FADE_INOUT: fade_mode = 4; +pub const FADE_OUT: fade_mode = 3; +pub const FADE_IN: fade_mode = 2; +pub const FADE_CROSSFADE: fade_mode = 1; +pub const FADE_NONE: fade_mode = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct outputstate { + pub state: output_state, + pub format: output_format, + pub device: *const libc::c_char, + pub buffer: libc::c_uint, + pub period: libc::c_uint, + pub track_started: bool, + pub write_cb: Option libc::c_int>, + pub start_frames: libc::c_uint, + pub frames_played: libc::c_uint, + pub frames_played_dmp: libc::c_uint, + pub current_sample_rate: libc::c_uint, + pub supported_rates: [libc::c_uint; 18], + pub default_sample_rate: libc::c_uint, + pub error_opening: bool, + pub device_frames: libc::c_uint, + pub updated: u32_t, + pub track_start_time: u32_t, + pub current_replay_gain: u32_t, + pub c2rust_unnamed: C2RustUnnamed, + pub next_sample_rate: libc::c_uint, + pub track_start: *mut u8_t, + pub gainL: u32_t, + pub gainR: u32_t, + pub invert: bool, + pub next_replay_gain: u32_t, + pub threshold: libc::c_uint, + pub fade: fade_state, + pub fade_start: *mut u8_t, + pub fade_end: *mut u8_t, + pub fade_dir: fade_dir, + pub fade_mode: fade_mode, + pub fade_secs: libc::c_uint, + pub rate_delay: libc::c_uint, + pub delay_active: bool, + pub stop_time: u32_t, + pub idle_to: u32_t, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub union C2RustUnnamed { + pub pause_frames: u32_t, + pub skip_frames: u32_t, + pub start_at: u32_t, +} +static mut loglevel: log_level = lERROR; static mut running: bool = 1 as libc::c_int != 0; // buffer to hold output data so we can block on writing outside of output lock, allocated on init - -static mut buf: *mut crate::squeezelite_h::u8_t = - 0 as *const crate::squeezelite_h::u8_t as *mut crate::squeezelite_h::u8_t; - +static mut buf: *mut u8_t = 0 as *const u8_t as *mut u8_t; static mut buffill: libc::c_uint = 0; - static mut bytes_per_frame: libc::c_int = 0; - -unsafe extern "C" fn _stdout_write_frames( - mut out_frames: 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; +unsafe extern "C" fn _stdout_write_frames(mut out_frames: frames_t, + mut silence: bool, mut gainL: s32_t, + mut gainR: s32_t, + mut cross_gain_in: s32_t, + mut cross_gain_out: s32_t, + mut cross_ptr: *mut *mut s32_t) + -> libc::c_int { + let mut obuf: *mut u8_t = 0 as *mut u8_t; if !silence { - if output.fade as libc::c_uint - == 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, - ); + if output.fade as libc::c_uint == + FADE_ACTIVE as libc::c_int as libc::c_uint && + output.fade_dir as libc::c_uint == + FADE_CROSS as libc::c_int as libc::c_uint && + !(*cross_ptr).is_null() { + _apply_cross(outputbuf, out_frames, cross_gain_in, cross_gain_out, + cross_ptr); } obuf = (*outputbuf).readp - } else { - obuf = silencebuf - } - 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, - ); + } else { obuf = silencebuf } + _scale_and_pack_frames(buf.offset(buffill.wrapping_mul(bytes_per_frame as + libc::c_uint) + as isize) as *mut libc::c_void, + obuf as *mut libc::c_void as *mut s32_t, + out_frames, gainL, gainR, output.format); buffill = buffill.wrapping_add(out_frames); return out_frames as libc::c_int; } - unsafe extern "C" fn output_thread() -> *mut libc::c_void { - crate::stdlib::pthread_mutex_lock(&mut (*outputbuf).mutex); + 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, + 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); + pthread_mutex_unlock(&mut (*outputbuf).mutex); while running { - crate::stdlib::pthread_mutex_lock(&mut (*outputbuf).mutex); + 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.updated = 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); + _output_frames(2048 as libc::c_int as frames_t); + 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, - ); + fwrite(buf as *const libc::c_void, + bytes_per_frame as libc::c_ulong, buffill as libc::c_ulong, + stdout); buffill = 0 as libc::c_int as libc::c_uint } } return 0 as *mut libc::c_void; } - -static mut thread: crate::stdlib::pthread_t = 0; +static mut thread: 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, -) { +pub unsafe extern "C" fn output_init_stdout(mut level: log_level, + mut output_buf_size: libc::c_uint, + mut params: *mut libc::c_char, + mut rates: *mut libc::c_uint, + mut rate_delay: libc::c_uint) { loglevel = level; - if loglevel as libc::c_uint >= 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, - ); + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d init output stdout\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 19], + &[libc::c_char; 19]>(b"output_init_stdout\x00")).as_ptr(), + 130 as libc::c_int); } - buf = crate::stdlib::malloc((2048 as libc::c_int * 8 as libc::c_int) as libc::c_ulong) - as *mut crate::squeezelite_h::u8_t; + buf = + malloc((2048 as libc::c_int * 8 as libc::c_int) as libc::c_ulong) as + *mut 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; + logprint(b"%s %s:%d unable to malloc buf\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 19], + &[libc::c_char; 19]>(b"output_init_stdout\x00")).as_ptr(), + 134 as libc::c_int); + return } buffill = 0 as libc::c_int as libc::c_uint; - 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::() 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, - ); + memset(&mut output as *mut outputstate as *mut libc::c_void, + 0 as libc::c_int, + ::std::mem::size_of::() as libc::c_ulong); + output.format = S32_LE; + output.start_frames = + (2048 as libc::c_int * 2 as libc::c_int) as libc::c_uint; + output.write_cb = + Some(_stdout_write_frames as + unsafe extern "C" fn(_: frames_t, _: bool, _: s32_t, + _: s32_t, _: s32_t, _: s32_t, + _: *mut *mut s32_t) -> libc::c_int); output.rate_delay = rate_delay; if !params.is_null() { - if crate::stdlib::strcmp(params, b"32\x00" as *const u8 as *const libc::c_char) == 0 { - output.format = crate::squeezelite_h::S32_LE + if strcmp(params, b"32\x00" as *const u8 as *const libc::c_char) == 0 + { + output.format = 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 strcmp(params, b"24\x00" as *const u8 as *const libc::c_char) == 0 + { + output.format = 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 + if strcmp(params, b"16\x00" as *const u8 as *const libc::c_char) == 0 + { + output.format = S16_LE } } // ensure output rate is specified to avoid test open if *rates.offset(0 as libc::c_int as isize) == 0 { - *rates.offset(0 as libc::c_int as isize) = 44100 as libc::c_int as libc::c_uint + *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 *mut libc::c_void>, - Option *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); + output_init_common(level, b"-\x00" as *const u8 as *const libc::c_char, + output_buf_size, rates, + 0 as libc::c_int as libc::c_uint); + let mut attr: pthread_attr_t = pthread_attr_t{__size: [0; 56],}; + pthread_attr_init(&mut attr); + pthread_attr_setstacksize(&mut attr, + (16384 as libc::c_int + + 64 as libc::c_int * 1024 as libc::c_int) as + size_t); + pthread_create(&mut thread, &mut attr, + ::std::mem::transmute:: *mut libc::c_void>, + Option + *mut libc::c_void>>(Some(::std::mem::transmute:: + *mut libc::c_void, + unsafe extern "C" fn() + -> + *mut libc::c_void>(output_thread))), + 0 as *mut libc::c_void); + pthread_attr_destroy(&mut attr); } -/* +/* * Squeezelite - lightweight headless squeezebox emulator * * (c) Adrian Smith 2012-2015, triode1@btinternet.com * Ralph Irving 2015-2017, ralph_irving@hotmail.com - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the @@ -327,20 +437,17 @@ pub unsafe extern "C" fn output_init_stdout( // 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, - ); + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d close output\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 20], + &[libc::c_char; 20]>(b"output_close_stdout\x00")).as_ptr(), + 174 as libc::c_int); } - crate::stdlib::pthread_mutex_lock(&mut (*outputbuf).mutex); + 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(); + pthread_mutex_unlock(&mut (*outputbuf).mutex); + free(buf as *mut libc::c_void); + output_close_common(); } diff --git a/src/pcm.rs b/src/pcm.rs index 054befd..5c261cd 100644 --- a/src/pcm.rs +++ b/src/pcm.rs @@ -1,245 +1,333 @@ 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::buffer::buf_adjust; -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::memcmp; -use crate::stdlib::memcpy; -use crate::stdlib::pthread_mutex_lock; -use crate::stdlib::pthread_mutex_unlock; extern "C" { - /* - * 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 . - * - */ #[no_mangle] - pub static mut loglevel: crate::squeezelite_h::log_level; + fn memcpy(_: *mut libc::c_void, _: *const libc::c_void, _: libc::c_ulong) + -> *mut libc::c_void; #[no_mangle] - pub static mut streambuf: *mut crate::squeezelite_h::buffer; + fn memcmp(_: *const libc::c_void, _: *const libc::c_void, + _: libc::c_ulong) -> libc::c_int; #[no_mangle] - pub static mut outputbuf: *mut crate::squeezelite_h::buffer; + fn _checkfade(_: bool); #[no_mangle] - pub static mut stream: crate::squeezelite_h::streamstate; + fn decode_newstream(sample_rate_0: libc::c_uint, + supported_rates: *mut libc::c_uint) -> libc::c_uint; #[no_mangle] - pub static mut output: crate::squeezelite_h::outputstate; + fn buf_adjust(buf: *mut buffer, mod_0: size_t); #[no_mangle] - pub static mut decode: crate::squeezelite_h::decodestate; + fn _buf_inc_writep(buf: *mut buffer, by: libc::c_uint); + #[no_mangle] + fn _buf_inc_readp(buf: *mut buffer, by: libc::c_uint); + #[no_mangle] + fn _buf_cont_write(buf: *mut buffer) -> libc::c_uint; + #[no_mangle] + fn _buf_cont_read(buf: *mut buffer) -> libc::c_uint; + #[no_mangle] + fn _buf_space(buf: *mut buffer) -> libc::c_uint; + #[no_mangle] + fn _buf_used(buf: *mut buffer) -> libc::c_uint; + #[no_mangle] + fn logprint(fmt: *const libc::c_char, _: ...); + #[no_mangle] + fn logtime() -> *const libc::c_char; + #[no_mangle] + fn pthread_mutex_unlock(__mutex: *mut pthread_mutex_t) -> libc::c_int; + #[no_mangle] + fn pthread_mutex_lock(__mutex: *mut pthread_mutex_t) -> libc::c_int; + /* + * 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 . + * + */ + #[no_mangle] + static mut loglevel: log_level; + #[no_mangle] + static mut streambuf: *mut buffer; + #[no_mangle] + static mut outputbuf: *mut buffer; + #[no_mangle] + static mut stream: streamstate; + #[no_mangle] + static mut output: outputstate; + #[no_mangle] + static mut decode: decodestate; +} +pub type size_t = libc::c_ulong; +pub type __uint8_t = libc::c_uchar; +pub type __int32_t = libc::c_int; +pub type __uint32_t = libc::c_uint; +pub type __uint64_t = libc::c_ulong; +pub type int32_t = __int32_t; +pub type u_int8_t = __uint8_t; +pub type u_int32_t = __uint32_t; +pub type u_int64_t = __uint64_t; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct __pthread_internal_list { + pub __prev: *mut __pthread_internal_list, + pub __next: *mut __pthread_internal_list, +} +pub type __pthread_list_t = __pthread_internal_list; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct __pthread_mutex_s { + pub __lock: libc::c_int, + pub __count: libc::c_uint, + pub __owner: libc::c_int, + pub __nusers: libc::c_uint, + pub __kind: libc::c_int, + pub __spins: libc::c_short, + pub __elision: libc::c_short, + pub __list: __pthread_list_t, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub union pthread_mutex_t { + pub __data: __pthread_mutex_s, + pub __size: [libc::c_char; 40], + pub __align: libc::c_long, +} +pub type u8_t = u_int8_t; +pub type u32_t = u_int32_t; +pub type u64_t = u_int64_t; +pub type s32_t = int32_t; +pub type frames_t = u32_t; +pub type log_level = libc::c_uint; +pub const lSDEBUG: log_level = 4; +pub const lDEBUG: log_level = 3; +pub const lINFO: log_level = 2; +pub const lWARN: log_level = 1; +pub const lERROR: log_level = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct buffer { + pub buf: *mut u8_t, + pub readp: *mut u8_t, + pub writep: *mut u8_t, + pub wrap: *mut u8_t, + pub size: size_t, + pub base_size: size_t, + pub mutex: pthread_mutex_t, +} +pub type stream_state = libc::c_uint; +pub const RECV_HEADERS: stream_state = 7; +pub const SEND_HEADERS: stream_state = 6; +pub const STREAMING_HTTP: stream_state = 5; +pub const STREAMING_FILE: stream_state = 4; +pub const STREAMING_BUFFERING: stream_state = 3; +pub const STREAMING_WAIT: stream_state = 2; +pub const DISCONNECT: stream_state = 1; +pub const STOPPED: stream_state = 0; +pub type disconnect_code = libc::c_uint; +pub const TIMEOUT: disconnect_code = 4; +pub const UNREACHABLE: disconnect_code = 3; +pub const REMOTE_DISCONNECT: disconnect_code = 2; +pub const LOCAL_DISCONNECT: disconnect_code = 1; +pub const DISCONNECT_OK: disconnect_code = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct streamstate { + pub state: stream_state, + pub disconnect: disconnect_code, + pub header: *mut libc::c_char, + pub header_len: size_t, + pub sent_headers: bool, + pub cont_wait: bool, + pub bytes: u64_t, + pub threshold: libc::c_uint, + pub meta_interval: u32_t, + pub meta_next: u32_t, + pub meta_left: u32_t, + pub meta_send: bool, +} +pub type decode_state = libc::c_uint; +pub const DECODE_ERROR: decode_state = 4; +pub const DECODE_COMPLETE: decode_state = 3; +pub const DECODE_RUNNING: decode_state = 2; +pub const DECODE_READY: decode_state = 1; +pub const DECODE_STOPPED: decode_state = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct decodestate { + pub state: decode_state, + pub new_stream: bool, + pub mutex: pthread_mutex_t, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct codec { + pub id: libc::c_char, + pub types: *mut libc::c_char, + pub min_read_bytes: libc::c_uint, + pub min_space: libc::c_uint, + pub open: Option ()>, + pub close: Option ()>, + pub decode: Option decode_state>, +} +pub type output_state = libc::c_int; +pub const OUTPUT_START_AT: output_state = 5; +pub const OUTPUT_SKIP_FRAMES: output_state = 4; +pub const OUTPUT_PAUSE_FRAMES: output_state = 3; +pub const OUTPUT_RUNNING: output_state = 2; +pub const OUTPUT_BUFFER: output_state = 1; +pub const OUTPUT_STOPPED: output_state = 0; +pub const OUTPUT_OFF: output_state = -1; +pub type output_format = libc::c_uint; +pub const S16_LE: output_format = 3; +pub const S24_3LE: output_format = 2; +pub const S24_LE: output_format = 1; +pub const S32_LE: output_format = 0; +pub type fade_state = libc::c_uint; +pub const FADE_ACTIVE: fade_state = 2; +pub const FADE_DUE: fade_state = 1; +pub const FADE_INACTIVE: fade_state = 0; +pub type fade_dir = libc::c_uint; +pub const FADE_CROSS: fade_dir = 3; +pub const FADE_DOWN: fade_dir = 2; +pub const FADE_UP: fade_dir = 1; +pub type fade_mode = libc::c_uint; +pub const FADE_INOUT: fade_mode = 4; +pub const FADE_OUT: fade_mode = 3; +pub const FADE_IN: fade_mode = 2; +pub const FADE_CROSSFADE: fade_mode = 1; +pub const FADE_NONE: fade_mode = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct outputstate { + pub state: output_state, + pub format: output_format, + pub device: *const libc::c_char, + pub buffer: libc::c_uint, + pub period: libc::c_uint, + pub track_started: bool, + pub write_cb: Option libc::c_int>, + pub start_frames: libc::c_uint, + pub frames_played: libc::c_uint, + pub frames_played_dmp: libc::c_uint, + pub current_sample_rate: libc::c_uint, + pub supported_rates: [libc::c_uint; 18], + pub default_sample_rate: libc::c_uint, + pub error_opening: bool, + pub device_frames: libc::c_uint, + pub updated: u32_t, + pub track_start_time: u32_t, + pub current_replay_gain: u32_t, + pub c2rust_unnamed: C2RustUnnamed, + pub next_sample_rate: libc::c_uint, + pub track_start: *mut u8_t, + pub gainL: u32_t, + pub gainR: u32_t, + pub invert: bool, + pub next_replay_gain: u32_t, + pub threshold: libc::c_uint, + pub fade: fade_state, + pub fade_start: *mut u8_t, + pub fade_end: *mut u8_t, + pub fade_dir: fade_dir, + pub fade_mode: fade_mode, + pub fade_secs: libc::c_uint, + pub rate_delay: libc::c_uint, + pub delay_active: bool, + pub stop_time: u32_t, + pub idle_to: u32_t, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub union C2RustUnnamed { + pub pause_frames: u32_t, + pub skip_frames: u32_t, + pub start_at: u32_t, } - pub const AIFF: header_format = 2; - pub type header_format = libc::c_uint; - pub const WAVE: header_format = 1; - pub const UNKNOWN: header_format = 0; #[no_mangle] - pub static mut pcm_check_header: bool = 0 as libc::c_int != 0; - -static mut sample_rates: [crate::squeezelite_h::u32_t; 17] = [ - 11025 as libc::c_int as crate::squeezelite_h::u32_t, - 22050 as libc::c_int as crate::squeezelite_h::u32_t, - 32000 as libc::c_int as crate::squeezelite_h::u32_t, - 44100 as libc::c_int as crate::squeezelite_h::u32_t, - 48000 as libc::c_int as crate::squeezelite_h::u32_t, - 8000 as libc::c_int as crate::squeezelite_h::u32_t, - 12000 as libc::c_int as crate::squeezelite_h::u32_t, - 16000 as libc::c_int as crate::squeezelite_h::u32_t, - 24000 as libc::c_int as crate::squeezelite_h::u32_t, - 96000 as libc::c_int as crate::squeezelite_h::u32_t, - 88200 as libc::c_int as crate::squeezelite_h::u32_t, - 176400 as libc::c_int as crate::squeezelite_h::u32_t, - 192000 as libc::c_int as crate::squeezelite_h::u32_t, - 352800 as libc::c_int as crate::squeezelite_h::u32_t, - 384000 as libc::c_int as crate::squeezelite_h::u32_t, - 705600 as libc::c_int as crate::squeezelite_h::u32_t, - 768000 as libc::c_int as crate::squeezelite_h::u32_t, -]; - -static mut sample_rate: crate::squeezelite_h::u32_t = 0; - -static mut sample_size: crate::squeezelite_h::u32_t = 0; - -static mut channels: crate::squeezelite_h::u32_t = 0; - +static mut sample_rates: [u32_t; 17] = + [11025 as libc::c_int as u32_t, 22050 as libc::c_int as u32_t, + 32000 as libc::c_int as u32_t, 44100 as libc::c_int as u32_t, + 48000 as libc::c_int as u32_t, 8000 as libc::c_int as u32_t, + 12000 as libc::c_int as u32_t, 16000 as libc::c_int as u32_t, + 24000 as libc::c_int as u32_t, 96000 as libc::c_int as u32_t, + 88200 as libc::c_int as u32_t, 176400 as libc::c_int as u32_t, + 192000 as libc::c_int as u32_t, 352800 as libc::c_int as u32_t, + 384000 as libc::c_int as u32_t, 705600 as libc::c_int as u32_t, + 768000 as libc::c_int as u32_t]; +static mut sample_rate: u32_t = 0; +static mut sample_size: u32_t = 0; +static mut channels: u32_t = 0; static mut bigendian: bool = false; - static mut limit: bool = false; - -static mut audio_left: crate::squeezelite_h::u32_t = 0; - -static mut bytes_per_frame: crate::squeezelite_h::u32_t = 0; - +static mut audio_left: u32_t = 0; +static mut bytes_per_frame: u32_t = 0; unsafe extern "C" fn _check_header() { - let mut ptr = (*streambuf).readp; - let mut 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) - }; - let mut format = UNKNOWN; + let mut ptr: *mut u8_t = (*streambuf).readp; + let mut bytes: libc::c_uint = + if _buf_used(streambuf) < _buf_cont_read(streambuf) { + _buf_used(streambuf) + } else { _buf_cont_read(streambuf) }; + let mut format: header_format = UNKNOWN; // simple parsing of wav and aiff headers and get to samples if bytes > 12 as libc::c_int as libc::c_uint { - if crate::stdlib::memcmp( - ptr as *const libc::c_void, - b"RIFF\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(8 as libc::c_int as isize) as *const libc::c_void, - b"WAVE\x00" as *const u8 as *const libc::c_char as *const libc::c_void, - 4 as libc::c_int as libc::c_ulong, - ) == 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 WAVE\n\x00" as *const u8 as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 14], &[libc::c_char; 14]>( - b"_check_header\x00", - )) - .as_ptr(), - 80 as libc::c_int, - ); + if memcmp(ptr as *const libc::c_void, + b"RIFF\x00" as *const u8 as *const libc::c_char as + *const libc::c_void, 4 as libc::c_int as libc::c_ulong) + == 0 && + memcmp(ptr.offset(8 as libc::c_int as isize) as + *const libc::c_void, + b"WAVE\x00" as *const u8 as *const libc::c_char as + *const libc::c_void, + 4 as libc::c_int as libc::c_ulong) == 0 { + if loglevel as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d WAVE\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 14], + &[libc::c_char; 14]>(b"_check_header\x00")).as_ptr(), + 80 as libc::c_int); } format = WAVE - } else if crate::stdlib::memcmp( - ptr as *const libc::c_void, - b"FORM\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(8 as libc::c_int as isize) as *const libc::c_void, - b"AIFF\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(8 as libc::c_int as isize) as *const libc::c_void, - b"AIFC\x00" as *const u8 as *const libc::c_char as *const libc::c_void, - 4 as libc::c_int as libc::c_ulong, - ) == 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 AIFF\n\x00" as *const u8 as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 14], &[libc::c_char; 14]>( - b"_check_header\x00", - )) - .as_ptr(), - 83 as libc::c_int, - ); + } else if memcmp(ptr as *const libc::c_void, + b"FORM\x00" as *const u8 as *const libc::c_char as + *const libc::c_void, + 4 as libc::c_int as libc::c_ulong) == 0 && + (memcmp(ptr.offset(8 as libc::c_int as isize) as + *const libc::c_void, + b"AIFF\x00" as *const u8 as *const libc::c_char + as *const libc::c_void, + 4 as libc::c_int as libc::c_ulong) == 0 || + memcmp(ptr.offset(8 as libc::c_int as isize) as + *const libc::c_void, + b"AIFC\x00" as *const u8 as + *const libc::c_char as + *const libc::c_void, + 4 as libc::c_int as libc::c_ulong) == 0) { + if loglevel as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d AIFF\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 14], + &[libc::c_char; 14]>(b"_check_header\x00")).as_ptr(), + 83 as libc::c_int); } format = AIFF } @@ -250,215 +338,195 @@ unsafe extern "C" fn _check_header() { while bytes >= 8 as libc::c_int as libc::c_uint { let mut id: [libc::c_char; 5] = [0; 5]; let mut len: libc::c_uint = 0; - crate::stdlib::memcpy( - id.as_mut_ptr() as *mut libc::c_void, - ptr as *const libc::c_void, - 4 as libc::c_int as libc::c_ulong, - ); + memcpy(id.as_mut_ptr() as *mut libc::c_void, + ptr as *const libc::c_void, + 4 as libc::c_int as libc::c_ulong); id[4 as libc::c_int as usize] = '\u{0}' as i32 as libc::c_char; if format as libc::c_uint == WAVE as libc::c_int as libc::c_uint { - len = (*ptr.offset(4 as libc::c_int as isize) as libc::c_int - | (*ptr.offset(5 as libc::c_int as isize) as libc::c_int) << 8 as libc::c_int - | (*ptr.offset(6 as libc::c_int as isize) as libc::c_int) << 16 as libc::c_int - | (*ptr.offset(7 as libc::c_int as isize) as libc::c_int) << 24 as libc::c_int) - as libc::c_uint + len = + (*ptr.offset(4 as libc::c_int as isize) as libc::c_int | + (*ptr.offset(5 as libc::c_int as isize) as + libc::c_int) << 8 as libc::c_int | + (*ptr.offset(6 as libc::c_int as isize) as + libc::c_int) << 16 as libc::c_int | + (*ptr.offset(7 as libc::c_int as isize) as + libc::c_int) << 24 as libc::c_int) as + libc::c_uint } else { - len = ((*ptr.offset(4 as libc::c_int as isize) as libc::c_int) << 24 as libc::c_int - | (*ptr.offset(5 as libc::c_int as isize) as libc::c_int) << 16 as libc::c_int - | (*ptr.offset(6 as libc::c_int as isize) as libc::c_int) << 8 as libc::c_int - | *ptr.offset(7 as libc::c_int as isize) as libc::c_int) - as libc::c_uint + len = + ((*ptr.offset(4 as libc::c_int as isize) as libc::c_int) + << 24 as libc::c_int | + (*ptr.offset(5 as libc::c_int as isize) as + libc::c_int) << 16 as libc::c_int | + (*ptr.offset(6 as libc::c_int as isize) as + libc::c_int) << 8 as libc::c_int | + *ptr.offset(7 as libc::c_int as isize) 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 header: %s len: %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"_check_header\x00", - )) - .as_ptr(), - 104 as libc::c_int, - id.as_mut_ptr(), - len, - ); + if loglevel as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d header: %s len: %d\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 14], + &[libc::c_char; 14]>(b"_check_header\x00")).as_ptr(), + 104 as libc::c_int, id.as_mut_ptr(), len); } if format as libc::c_uint == WAVE as libc::c_int as libc::c_uint - && crate::stdlib::memcmp( - ptr as *const libc::c_void, - b"data\x00" as *const u8 as *const libc::c_char as *const libc::c_void, - 4 as libc::c_int as libc::c_ulong, - ) == 0 - { + && + memcmp(ptr as *const libc::c_void, + b"data\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(8 as libc::c_int as isize); - crate::src::buffer::_buf_inc_readp( - streambuf, - ptr.wrapping_offset_from((*streambuf).readp) as libc::c_long as libc::c_uint, - ); + _buf_inc_readp(streambuf, + ptr.wrapping_offset_from((*streambuf).readp) as + libc::c_long as libc::c_uint); audio_left = len; - if audio_left == 0xffffffff as libc::c_uint - || audio_left == 0x7fffeffc 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 wav audio size unknown: %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"_check_header\x00", - )) - .as_ptr(), - 112 as libc::c_int, - audio_left, - ); + if audio_left == 0xffffffff as libc::c_uint || + audio_left == 0x7fffeffc as libc::c_int as libc::c_uint + { + if loglevel as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d wav audio size unknown: %u\n\x00" + as *const u8 as *const libc::c_char, + logtime(), + (*::std::mem::transmute::<&[u8; 14], + &[libc::c_char; 14]>(b"_check_header\x00")).as_ptr(), + 112 as libc::c_int, audio_left); } limit = 0 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 wav audio size: %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"_check_header\x00", - )) - .as_ptr(), - 115 as libc::c_int, - audio_left, - ); + if loglevel as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d wav audio size: %u\n\x00" as + *const u8 as *const libc::c_char, + logtime(), + (*::std::mem::transmute::<&[u8; 14], + &[libc::c_char; 14]>(b"_check_header\x00")).as_ptr(), + 115 as libc::c_int, audio_left); } limit = 1 as libc::c_int != 0 } - return; + return } if format as libc::c_uint == AIFF as libc::c_int as libc::c_uint - && crate::stdlib::memcmp( - ptr as *const libc::c_void, - b"SSND\x00" as *const u8 as *const libc::c_char as *const libc::c_void, - 4 as libc::c_int as libc::c_ulong, - ) == 0 - && bytes >= 16 as libc::c_int as libc::c_uint - { - let mut offset = ((*ptr.offset(8 as libc::c_int as isize) as libc::c_int) - << 24 as libc::c_int - | (*ptr.offset(9 as libc::c_int as isize) as libc::c_int) << 16 as libc::c_int - | (*ptr.offset(10 as libc::c_int as isize) as libc::c_int) << 8 as libc::c_int - | *ptr.offset(11 as libc::c_int as isize) as libc::c_int) - as libc::c_uint; + && + memcmp(ptr as *const libc::c_void, + b"SSND\x00" as *const u8 as *const libc::c_char as + *const libc::c_void, + 4 as libc::c_int as libc::c_ulong) == 0 && + bytes >= 16 as libc::c_int as libc::c_uint { + let mut offset: libc::c_uint = + ((*ptr.offset(8 as libc::c_int as isize) as libc::c_int) + << 24 as libc::c_int | + (*ptr.offset(9 as libc::c_int as isize) as + libc::c_int) << 16 as libc::c_int | + (*ptr.offset(10 as libc::c_int as isize) as + libc::c_int) << 8 as libc::c_int | + *ptr.offset(11 as libc::c_int as isize) as + libc::c_int) as libc::c_uint; // following 4 bytes is blocksize - ignored - ptr = ptr.offset((8 as libc::c_int + 8 as libc::c_int) as isize); - crate::src::buffer::_buf_inc_readp( - streambuf, - ptr.offset(offset as isize) - .wrapping_offset_from((*streambuf).readp) - as libc::c_long as libc::c_uint, - ); + ptr = + ptr.offset((8 as libc::c_int + 8 as libc::c_int) as + isize); + _buf_inc_readp(streambuf, + ptr.offset(offset as + isize).wrapping_offset_from((*streambuf).readp) + as libc::c_long as libc::c_uint); // Reading from an upsampled stream, length could be wrong. - // Only use length in header for files. - if stream.state as libc::c_uint - == crate::squeezelite_h::STREAMING_FILE as libc::c_int as libc::c_uint - { - audio_left = len - .wrapping_sub(8 as libc::c_int as libc::c_uint) - .wrapping_sub(offset); - 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 aif audio size: %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"_check_header\x00", - )) - .as_ptr(), - 131 as libc::c_int, - audio_left, - ); + // Only use length in header for files. + if stream.state as libc::c_uint == + STREAMING_FILE as libc::c_int as libc::c_uint { + audio_left = + len.wrapping_sub(8 as libc::c_int as + libc::c_uint).wrapping_sub(offset); + if loglevel as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d aif audio size: %u\n\x00" as + *const u8 as *const libc::c_char, + logtime(), + (*::std::mem::transmute::<&[u8; 14], + &[libc::c_char; 14]>(b"_check_header\x00")).as_ptr(), + 131 as libc::c_int, audio_left); } limit = 1 as libc::c_int != 0 } - return; + return } if format as libc::c_uint == WAVE as libc::c_int as libc::c_uint - && crate::stdlib::memcmp( - ptr as *const libc::c_void, - b"fmt \x00" as *const u8 as *const libc::c_char as *const libc::c_void, - 4 as libc::c_int as libc::c_ulong, - ) == 0 - && bytes >= 24 as libc::c_int as libc::c_uint - { + && + memcmp(ptr as *const libc::c_void, + b"fmt \x00" as *const u8 as *const libc::c_char as + *const libc::c_void, + 4 as libc::c_int as libc::c_ulong) == 0 && + bytes >= 24 as libc::c_int as libc::c_uint { // override the server parsed values with our own - channels = (*ptr.offset(10 as libc::c_int as isize) as libc::c_int - | (*ptr.offset(11 as libc::c_int as isize) as libc::c_int) << 8 as libc::c_int) - as crate::squeezelite_h::u32_t; - sample_rate = (*ptr.offset(12 as libc::c_int as isize) as libc::c_int - | (*ptr.offset(13 as libc::c_int as isize) as libc::c_int) << 8 as libc::c_int - | (*ptr.offset(14 as libc::c_int as isize) as libc::c_int) << 16 as libc::c_int - | (*ptr.offset(15 as libc::c_int as isize) as libc::c_int) << 24 as libc::c_int) - as crate::squeezelite_h::u32_t; - sample_size = ((*ptr.offset(22 as libc::c_int as isize) as libc::c_int - | (*ptr.offset(23 as libc::c_int as isize) as libc::c_int) << 8 as libc::c_int) - / 8 as libc::c_int) - as crate::squeezelite_h::u32_t; + channels = + (*ptr.offset(10 as libc::c_int as isize) as libc::c_int | + (*ptr.offset(11 as libc::c_int as isize) as + libc::c_int) << 8 as libc::c_int) as u32_t; + sample_rate = + (*ptr.offset(12 as libc::c_int as isize) as libc::c_int | + (*ptr.offset(13 as libc::c_int as isize) as + libc::c_int) << 8 as libc::c_int | + (*ptr.offset(14 as libc::c_int as isize) as + libc::c_int) << 16 as libc::c_int | + (*ptr.offset(15 as libc::c_int as isize) as + libc::c_int) << 24 as libc::c_int) as u32_t; + sample_size = + ((*ptr.offset(22 as libc::c_int as isize) as libc::c_int | + (*ptr.offset(23 as libc::c_int as isize) as + libc::c_int) << 8 as libc::c_int) / + 8 as libc::c_int) as u32_t; bigendian = 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 pcm size: %u rate: %u chan: %u bigendian: %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"_check_header\x00", - )) - .as_ptr(), - 143 as libc::c_int, - sample_size, - sample_rate, - channels, - bigendian as libc::c_int, - ); + if loglevel as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d pcm size: %u rate: %u chan: %u bigendian: %u\n\x00" + as *const u8 as *const libc::c_char, + logtime(), + (*::std::mem::transmute::<&[u8; 14], + &[libc::c_char; 14]>(b"_check_header\x00")).as_ptr(), + 143 as libc::c_int, sample_size, sample_rate, + channels, bigendian as libc::c_int); } } if format as libc::c_uint == AIFF as libc::c_int as libc::c_uint - && crate::stdlib::memcmp( - ptr as *const libc::c_void, - b"COMM\x00" as *const u8 as *const libc::c_char as *const libc::c_void, - 4 as libc::c_int as libc::c_ulong, - ) == 0 - && bytes >= 26 as libc::c_int as libc::c_uint - { + && + memcmp(ptr as *const libc::c_void, + b"COMM\x00" as *const u8 as *const libc::c_char as + *const libc::c_void, + 4 as libc::c_int as libc::c_ulong) == 0 && + bytes >= 26 as libc::c_int as libc::c_uint { let mut exponent: libc::c_int = 0; // override the server parsed values with our own - channels = ((*ptr.offset(8 as libc::c_int as isize) as libc::c_int) - << 8 as libc::c_int - | *ptr.offset(9 as libc::c_int as isize) as libc::c_int) - as crate::squeezelite_h::u32_t; + channels = + ((*ptr.offset(8 as libc::c_int as isize) as libc::c_int) + << 8 as libc::c_int | + *ptr.offset(9 as libc::c_int as isize) as + libc::c_int) as u32_t; sample_size = - (((*ptr.offset(14 as libc::c_int as isize) as libc::c_int) << 8 as libc::c_int - | *ptr.offset(15 as libc::c_int as isize) as libc::c_int) - / 8 as libc::c_int) as crate::squeezelite_h::u32_t; + (((*ptr.offset(14 as libc::c_int as isize) as libc::c_int) + << 8 as libc::c_int | + *ptr.offset(15 as libc::c_int as isize) as + libc::c_int) / 8 as libc::c_int) as u32_t; bigendian = 1 as libc::c_int != 0; // sample rate is encoded as IEEE 80 bit extended format - // make some assumptions to simplify processing - only use first 32 bits of mantissa - exponent = ((*ptr.offset(16 as libc::c_int as isize) as libc::c_int - & 0x7f as libc::c_int) - << 8 as libc::c_int - | *ptr.offset(17 as libc::c_int as isize) as libc::c_int) - - 16383 as libc::c_int - - 31 as libc::c_int; - sample_rate = ((*ptr.offset(18 as libc::c_int as isize) as libc::c_int) - << 24 as libc::c_int - | (*ptr.offset(19 as libc::c_int as isize) as libc::c_int) << 16 as libc::c_int - | (*ptr.offset(20 as libc::c_int as isize) as libc::c_int) << 8 as libc::c_int - | *ptr.offset(21 as libc::c_int as isize) as libc::c_int) - as crate::squeezelite_h::u32_t; + // make some assumptions to simplify processing - only use first 32 bits of mantissa + exponent = + ((*ptr.offset(16 as libc::c_int as isize) as libc::c_int & + 0x7f as libc::c_int) << 8 as libc::c_int | + *ptr.offset(17 as libc::c_int as isize) as + libc::c_int) - 16383 as libc::c_int - + 31 as libc::c_int; + sample_rate = + ((*ptr.offset(18 as libc::c_int as isize) as libc::c_int) + << 24 as libc::c_int | + (*ptr.offset(19 as libc::c_int as isize) as + libc::c_int) << 16 as libc::c_int | + (*ptr.offset(20 as libc::c_int as isize) as + libc::c_int) << 8 as libc::c_int | + *ptr.offset(21 as libc::c_int as isize) as + libc::c_int) as u32_t; while exponent < 0 as libc::c_int { sample_rate >>= 1 as libc::c_int; exponent += 1 @@ -467,325 +535,276 @@ unsafe extern "C" fn _check_header() { sample_rate <<= 1 as libc::c_int; exponent -= 1 } - 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 pcm size: %u rate: %u chan: %u bigendian: %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"_check_header\x00", - )) - .as_ptr(), - 158 as libc::c_int, - sample_size, - sample_rate, - channels, - bigendian as libc::c_int, - ); + if loglevel as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d pcm size: %u rate: %u chan: %u bigendian: %u\n\x00" + as *const u8 as *const libc::c_char, + logtime(), + (*::std::mem::transmute::<&[u8; 14], + &[libc::c_char; 14]>(b"_check_header\x00")).as_ptr(), + 158 as libc::c_int, sample_size, sample_rate, + channels, bigendian as libc::c_int); } } if bytes >= len.wrapping_add(8 as libc::c_int as libc::c_uint) { - ptr = ptr.offset(len.wrapping_add(8 as libc::c_int as libc::c_uint) as isize); - bytes = bytes.wrapping_sub(len.wrapping_add(8 as libc::c_int as libc::c_uint)) + ptr = + ptr.offset(len.wrapping_add(8 as libc::c_int as + libc::c_uint) as isize); + bytes = + bytes.wrapping_sub(len.wrapping_add(8 as libc::c_int as + libc::c_uint)) } 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 run out of data\n\x00" as *const u8 as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 14], &[libc::c_char; 14]>( - b"_check_header\x00", - )) - .as_ptr(), - 165 as libc::c_int, - ); + if loglevel as libc::c_uint >= + lWARN as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d run out of data\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 14], + &[libc::c_char; 14]>(b"_check_header\x00")).as_ptr(), + 165 as libc::c_int); } - return; + return } } - } 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 unknown format - can\'t parse header\n\x00" as *const u8 - as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 14], &[libc::c_char; 14]>(b"_check_header\x00")) - .as_ptr(), - 171 as libc::c_int, - ); + } else if loglevel as libc::c_uint >= lWARN as libc::c_int as libc::c_uint + { + logprint(b"%s %s:%d unknown format - can\'t parse header\n\x00" as + *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 14], + &[libc::c_char; 14]>(b"_check_header\x00")).as_ptr(), + 171 as libc::c_int); }; } - -unsafe extern "C" fn pcm_decode() -> crate::squeezelite_h::decode_state { +unsafe extern "C" fn pcm_decode() -> decode_state { let mut bytes: libc::c_uint = 0; let mut in_0: libc::c_uint = 0; let mut out: libc::c_uint = 0; - let mut frames: crate::squeezelite_h::frames_t = 0; - let mut count: crate::squeezelite_h::frames_t = 0; - let mut optr = 0 as *mut crate::squeezelite_h::u32_t; - let mut iptr = 0 as *mut crate::squeezelite_h::u8_t; - let mut tmp: [crate::squeezelite_h::u8_t; 16] = [0; 16]; - crate::stdlib::pthread_mutex_lock(&mut (*streambuf).mutex); - if decode.new_stream as libc::c_int != 0 - && (stream.state as libc::c_uint - == crate::squeezelite_h::STREAMING_FILE as libc::c_int as libc::c_uint - || pcm_check_header as libc::c_int != 0) - { + let mut frames: frames_t = 0; + let mut count: frames_t = 0; + let mut optr: *mut u32_t = 0 as *mut u32_t; + let mut iptr: *mut u8_t = 0 as *mut u8_t; + let mut tmp: [u8_t; 16] = [0; 16]; + pthread_mutex_lock(&mut (*streambuf).mutex); + if decode.new_stream as libc::c_int != 0 && + (stream.state as libc::c_uint == + STREAMING_FILE as libc::c_int as libc::c_uint || + pcm_check_header as libc::c_int != 0) { _check_header(); } - 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) - }; - out = (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); - if 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_uint - || limit as libc::c_int != 0 && audio_left == 0 as libc::c_int as libc::c_uint - { - crate::stdlib::pthread_mutex_unlock(&mut (*outputbuf).mutex); - crate::stdlib::pthread_mutex_unlock(&mut (*streambuf).mutex); - return crate::squeezelite_h::DECODE_COMPLETE; + pthread_mutex_lock(&mut (*outputbuf).mutex); + bytes = + if _buf_used(streambuf) < _buf_cont_read(streambuf) { + _buf_used(streambuf) + } else { _buf_cont_read(streambuf) }; + out = + (if _buf_space(outputbuf) < _buf_cont_write(outputbuf) { + _buf_space(outputbuf) + } else { + _buf_cont_write(outputbuf) + }).wrapping_div(8 as libc::c_int as libc::c_uint); + if stream.state as libc::c_uint <= + DISCONNECT as libc::c_int as libc::c_uint && + bytes == 0 as libc::c_int as libc::c_uint || + limit as libc::c_int != 0 && + audio_left == 0 as libc::c_int as libc::c_uint { + pthread_mutex_unlock(&mut (*outputbuf).mutex); + pthread_mutex_unlock(&mut (*streambuf).mutex); + return DECODE_COMPLETE } if decode.new_stream { - 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"pcm_decode\x00")) - .as_ptr(), - 206 as libc::c_int, - ); + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d setting track_start\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 11], + &[libc::c_char; 11]>(b"pcm_decode\x00")).as_ptr(), + 206 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(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); - } + decode_newstream(sample_rate, + output.supported_rates.as_mut_ptr()); + if output.fade_mode as u64 != 0 { _checkfade(1 as libc::c_int != 0); } bytes_per_frame = channels.wrapping_mul(sample_size) } - optr = (*outputbuf).writep as *mut crate::squeezelite_h::u32_t; + optr = (*outputbuf).writep as *mut u32_t; iptr = (*streambuf).readp; in_0 = bytes.wrapping_div(bytes_per_frame); // handle frame wrapping round end of streambuf - // - only need if resizing of streambuf does not avoid this, could occur in localfile case - if in_0 == 0 as libc::c_int as libc::c_uint - && bytes > 0 as libc::c_int as libc::c_uint - && crate::squeezelite_h::_buf_used(streambuf) >= bytes_per_frame - { - crate::stdlib::memcpy( - tmp.as_mut_ptr() as *mut libc::c_void, - iptr as *const libc::c_void, - bytes as libc::c_ulong, - ); - crate::stdlib::memcpy( - tmp.as_mut_ptr().offset(bytes as isize) as *mut libc::c_void, - (*streambuf).buf as *const libc::c_void, - bytes_per_frame.wrapping_sub(bytes) as libc::c_ulong, - ); + // - only need if resizing of streambuf does not avoid this, could occur in localfile case + if in_0 == 0 as libc::c_int as libc::c_uint && + bytes > 0 as libc::c_int as libc::c_uint && + _buf_used(streambuf) >= bytes_per_frame { + memcpy(tmp.as_mut_ptr() as *mut libc::c_void, + iptr as *const libc::c_void, bytes as libc::c_ulong); + memcpy(tmp.as_mut_ptr().offset(bytes as isize) as *mut libc::c_void, + (*streambuf).buf as *const libc::c_void, + bytes_per_frame.wrapping_sub(bytes) as libc::c_ulong); iptr = tmp.as_mut_ptr(); in_0 = 1 as libc::c_int as libc::c_uint } frames = if in_0 < out { in_0 } else { out }; - frames = if frames < 4096 as libc::c_int as libc::c_uint { - frames - } else { - 4096 as libc::c_int as libc::c_uint - }; - if limit as libc::c_int != 0 && frames.wrapping_mul(bytes_per_frame) > audio_left { - 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 reached end of audio\n\x00" as *const u8 as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 11], &[libc::c_char; 11]>(b"pcm_decode\x00")) - .as_ptr(), - 261 as libc::c_int, - ); + frames = + if frames < 4096 as libc::c_int as libc::c_uint { + frames + } else { 4096 as libc::c_int as libc::c_uint }; + if limit as libc::c_int != 0 && + frames.wrapping_mul(bytes_per_frame) > audio_left { + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d reached end of audio\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 11], + &[libc::c_char; 11]>(b"pcm_decode\x00")).as_ptr(), + 261 as libc::c_int); } frames = audio_left.wrapping_div(bytes_per_frame) } count = frames.wrapping_mul(channels); if channels == 2 as libc::c_int as libc::c_uint { if sample_size == 1 as libc::c_int as libc::c_uint { - loop { + loop { let fresh0 = count; count = count.wrapping_sub(1); - if !(fresh0 != 0) { - break; - } + if !(fresh0 != 0) { break ; } let fresh1 = iptr; iptr = iptr.offset(1); let fresh2 = optr; optr = optr.offset(1); *fresh2 = - ((*fresh1 as libc::c_int) << 24 as libc::c_int) as crate::squeezelite_h::u32_t + ((*fresh1 as libc::c_int) << 24 as libc::c_int) as u32_t } } else if sample_size == 2 as libc::c_int as libc::c_uint { if bigendian { - loop { + loop { let fresh3 = count; count = count.wrapping_sub(1); - if !(fresh3 != 0) { - break; - } + if !(fresh3 != 0) { break ; } let fresh4 = optr; optr = optr.offset(1); - *fresh4 = ((*iptr as libc::c_int) << 24 as libc::c_int - | (*iptr.offset(1 as libc::c_int as isize) as libc::c_int) - << 16 as libc::c_int) - as crate::squeezelite_h::u32_t; + *fresh4 = + ((*iptr as libc::c_int) << 24 as libc::c_int | + (*iptr.offset(1 as libc::c_int as isize) as + libc::c_int) << 16 as libc::c_int) as u32_t; iptr = iptr.offset(2 as libc::c_int as isize) } } else { - loop { + loop { let fresh5 = count; count = count.wrapping_sub(1); - if !(fresh5 != 0) { - break; - } + if !(fresh5 != 0) { break ; } let fresh6 = optr; optr = optr.offset(1); - *fresh6 = ((*iptr as libc::c_int) << 16 as libc::c_int - | (*iptr.offset(1 as libc::c_int as isize) as libc::c_int) - << 24 as libc::c_int) - as crate::squeezelite_h::u32_t; + *fresh6 = + ((*iptr as libc::c_int) << 16 as libc::c_int | + (*iptr.offset(1 as libc::c_int as isize) as + libc::c_int) << 24 as libc::c_int) as u32_t; iptr = iptr.offset(2 as libc::c_int as isize) } } } else if sample_size == 3 as libc::c_int as libc::c_uint { if bigendian { - loop { + loop { let fresh7 = count; count = count.wrapping_sub(1); - if !(fresh7 != 0) { - break; - } + if !(fresh7 != 0) { break ; } let fresh8 = optr; optr = optr.offset(1); - *fresh8 = ((*iptr as libc::c_int) << 24 as libc::c_int - | (*iptr.offset(1 as libc::c_int as isize) as libc::c_int) - << 16 as libc::c_int - | (*iptr.offset(2 as libc::c_int as isize) as libc::c_int) - << 8 as libc::c_int) - as crate::squeezelite_h::u32_t; + *fresh8 = + ((*iptr as libc::c_int) << 24 as libc::c_int | + (*iptr.offset(1 as libc::c_int as isize) as + libc::c_int) << 16 as libc::c_int | + (*iptr.offset(2 as libc::c_int as isize) as + libc::c_int) << 8 as libc::c_int) as u32_t; iptr = iptr.offset(3 as libc::c_int as isize) } } else { - loop { + loop { let fresh9 = count; count = count.wrapping_sub(1); - if !(fresh9 != 0) { - break; - } + if !(fresh9 != 0) { break ; } let fresh10 = optr; optr = optr.offset(1); - *fresh10 = ((*iptr as libc::c_int) << 8 as libc::c_int - | (*iptr.offset(1 as libc::c_int as isize) as libc::c_int) - << 16 as libc::c_int - | (*iptr.offset(2 as libc::c_int as isize) as libc::c_int) - << 24 as libc::c_int) - as crate::squeezelite_h::u32_t; + *fresh10 = + ((*iptr as libc::c_int) << 8 as libc::c_int | + (*iptr.offset(1 as libc::c_int as isize) as + libc::c_int) << 16 as libc::c_int | + (*iptr.offset(2 as libc::c_int as isize) as + libc::c_int) << 24 as libc::c_int) as u32_t; iptr = iptr.offset(3 as libc::c_int as isize) } } } else if sample_size == 4 as libc::c_int as libc::c_uint { if bigendian { - loop { + loop { let fresh11 = count; count = count.wrapping_sub(1); - if !(fresh11 != 0) { - break; - } + if !(fresh11 != 0) { break ; } let fresh12 = optr; optr = optr.offset(1); - *fresh12 = ((*iptr as libc::c_int) << 24 as libc::c_int - | (*iptr.offset(1 as libc::c_int as isize) as libc::c_int) - << 16 as libc::c_int - | (*iptr.offset(2 as libc::c_int as isize) as libc::c_int) - << 8 as libc::c_int - | *iptr.offset(3 as libc::c_int as isize) as libc::c_int) - as crate::squeezelite_h::u32_t; + *fresh12 = + ((*iptr as libc::c_int) << 24 as libc::c_int | + (*iptr.offset(1 as libc::c_int as isize) as + libc::c_int) << 16 as libc::c_int | + (*iptr.offset(2 as libc::c_int as isize) as + libc::c_int) << 8 as libc::c_int | + *iptr.offset(3 as libc::c_int as isize) as + libc::c_int) as u32_t; iptr = iptr.offset(4 as libc::c_int as isize) } } else { - loop { + loop { let fresh13 = count; count = count.wrapping_sub(1); - if !(fresh13 != 0) { - break; - } + if !(fresh13 != 0) { break ; } let fresh14 = optr; optr = optr.offset(1); - *fresh14 = (*iptr as libc::c_int - | (*iptr.offset(1 as libc::c_int as isize) as libc::c_int) - << 8 as libc::c_int - | (*iptr.offset(2 as libc::c_int as isize) as libc::c_int) - << 16 as libc::c_int - | (*iptr.offset(3 as libc::c_int as isize) as libc::c_int) - << 24 as libc::c_int) - as crate::squeezelite_h::u32_t; + *fresh14 = + (*iptr as libc::c_int | + (*iptr.offset(1 as libc::c_int as isize) as + libc::c_int) << 8 as libc::c_int | + (*iptr.offset(2 as libc::c_int as isize) as + libc::c_int) << 16 as libc::c_int | + (*iptr.offset(3 as libc::c_int as isize) as + libc::c_int) << 24 as libc::c_int) as u32_t; iptr = iptr.offset(4 as libc::c_int as isize) } } } } else if channels == 1 as libc::c_int as libc::c_uint { if sample_size == 1 as libc::c_int as libc::c_uint { - loop { + loop { let fresh15 = count; count = count.wrapping_sub(1); - if !(fresh15 != 0) { - break; - } + if !(fresh15 != 0) { break ; } let fresh16 = iptr; iptr = iptr.offset(1); *optr = - ((*fresh16 as libc::c_int) << 24 as libc::c_int) as crate::squeezelite_h::u32_t; + ((*fresh16 as libc::c_int) << 24 as libc::c_int) as u32_t; *optr.offset(1 as libc::c_int as isize) = *optr; optr = optr.offset(2 as libc::c_int as isize) } } else if sample_size == 2 as libc::c_int as libc::c_uint { if bigendian { - loop { + loop { let fresh17 = count; count = count.wrapping_sub(1); - if !(fresh17 != 0) { - break; - } - *optr = ((*iptr as libc::c_int) << 24 as libc::c_int - | (*iptr.offset(1 as libc::c_int as isize) as libc::c_int) - << 16 as libc::c_int) - as crate::squeezelite_h::u32_t; + if !(fresh17 != 0) { break ; } + *optr = + ((*iptr as libc::c_int) << 24 as libc::c_int | + (*iptr.offset(1 as libc::c_int as isize) as + libc::c_int) << 16 as libc::c_int) as u32_t; *optr.offset(1 as libc::c_int as isize) = *optr; iptr = iptr.offset(2 as libc::c_int as isize); optr = optr.offset(2 as libc::c_int as isize) } } else { - loop { + loop { let fresh18 = count; count = count.wrapping_sub(1); - if !(fresh18 != 0) { - break; - } - *optr = ((*iptr as libc::c_int) << 16 as libc::c_int - | (*iptr.offset(1 as libc::c_int as isize) as libc::c_int) - << 24 as libc::c_int) - as crate::squeezelite_h::u32_t; + if !(fresh18 != 0) { break ; } + *optr = + ((*iptr as libc::c_int) << 16 as libc::c_int | + (*iptr.offset(1 as libc::c_int as isize) as + libc::c_int) << 24 as libc::c_int) as u32_t; *optr.offset(1 as libc::c_int as isize) = *optr; iptr = iptr.offset(2 as libc::c_int as isize); optr = optr.offset(2 as libc::c_int as isize) @@ -793,35 +812,31 @@ unsafe extern "C" fn pcm_decode() -> crate::squeezelite_h::decode_state { } } else if sample_size == 3 as libc::c_int as libc::c_uint { if bigendian { - loop { + loop { let fresh19 = count; count = count.wrapping_sub(1); - if !(fresh19 != 0) { - break; - } - *optr = ((*iptr as libc::c_int) << 24 as libc::c_int - | (*iptr.offset(1 as libc::c_int as isize) as libc::c_int) - << 16 as libc::c_int - | (*iptr.offset(2 as libc::c_int as isize) as libc::c_int) - << 8 as libc::c_int) - as crate::squeezelite_h::u32_t; + if !(fresh19 != 0) { break ; } + *optr = + ((*iptr as libc::c_int) << 24 as libc::c_int | + (*iptr.offset(1 as libc::c_int as isize) as + libc::c_int) << 16 as libc::c_int | + (*iptr.offset(2 as libc::c_int as isize) as + libc::c_int) << 8 as libc::c_int) as u32_t; *optr.offset(1 as libc::c_int as isize) = *optr; iptr = iptr.offset(3 as libc::c_int as isize); optr = optr.offset(2 as libc::c_int as isize) } } else { - loop { + loop { let fresh20 = count; count = count.wrapping_sub(1); - if !(fresh20 != 0) { - break; - } - *optr = ((*iptr as libc::c_int) << 8 as libc::c_int - | (*iptr.offset(1 as libc::c_int as isize) as libc::c_int) - << 16 as libc::c_int - | (*iptr.offset(2 as libc::c_int as isize) as libc::c_int) - << 24 as libc::c_int) - as crate::squeezelite_h::u32_t; + if !(fresh20 != 0) { break ; } + *optr = + ((*iptr as libc::c_int) << 8 as libc::c_int | + (*iptr.offset(1 as libc::c_int as isize) as + libc::c_int) << 16 as libc::c_int | + (*iptr.offset(2 as libc::c_int as isize) as + libc::c_int) << 24 as libc::c_int) as u32_t; *optr.offset(1 as libc::c_int as isize) = *optr; iptr = iptr.offset(3 as libc::c_int as isize); optr = optr.offset(2 as libc::c_int as isize) @@ -829,42 +844,39 @@ unsafe extern "C" fn pcm_decode() -> crate::squeezelite_h::decode_state { } } else if sample_size == 4 as libc::c_int as libc::c_uint { if bigendian { - loop { + loop { let fresh21 = count; count = count.wrapping_sub(1); - if !(fresh21 != 0) { - break; - } + if !(fresh21 != 0) { break ; } let fresh22 = optr; optr = optr.offset(1); - *fresh22 = ((*iptr as libc::c_int) << 24 as libc::c_int - | (*iptr.offset(1 as libc::c_int as isize) as libc::c_int) - << 16 as libc::c_int - | (*iptr.offset(2 as libc::c_int as isize) as libc::c_int) - << 8 as libc::c_int - | *iptr.offset(3 as libc::c_int as isize) as libc::c_int) - as crate::squeezelite_h::u32_t; + *fresh22 = + ((*iptr as libc::c_int) << 24 as libc::c_int | + (*iptr.offset(1 as libc::c_int as isize) as + libc::c_int) << 16 as libc::c_int | + (*iptr.offset(2 as libc::c_int as isize) as + libc::c_int) << 8 as libc::c_int | + *iptr.offset(3 as libc::c_int as isize) as + libc::c_int) as u32_t; *optr.offset(1 as libc::c_int as isize) = *optr; iptr = iptr.offset(4 as libc::c_int as isize); optr = optr.offset(2 as libc::c_int as isize) } } else { - loop { + loop { let fresh23 = count; count = count.wrapping_sub(1); - if !(fresh23 != 0) { - break; - } + if !(fresh23 != 0) { break ; } let fresh24 = optr; optr = optr.offset(1); - *fresh24 = (*iptr as libc::c_int - | (*iptr.offset(1 as libc::c_int as isize) as libc::c_int) - << 8 as libc::c_int - | (*iptr.offset(2 as libc::c_int as isize) as libc::c_int) - << 16 as libc::c_int - | (*iptr.offset(3 as libc::c_int as isize) as libc::c_int) - << 24 as libc::c_int) - as crate::squeezelite_h::u32_t; + *fresh24 = + (*iptr as libc::c_int | + (*iptr.offset(1 as libc::c_int as isize) as + libc::c_int) << 8 as libc::c_int | + (*iptr.offset(2 as libc::c_int as isize) as + libc::c_int) << 16 as libc::c_int | + (*iptr.offset(3 as libc::c_int as isize) as + libc::c_int) << 24 as libc::c_int) as u32_t; *optr.offset(1 as libc::c_int as isize) = *optr; iptr = iptr.offset(4 as libc::c_int as isize); optr = optr.offset(2 as libc::c_int as isize) @@ -872,144 +884,192 @@ unsafe extern "C" fn pcm_decode() -> crate::squeezelite_h::decode_state { } } } else { - crate::src::utils::logprint( - b"%s %s:%d unsupported channels\n\x00" as *const u8 as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 11], &[libc::c_char; 11]>(b"pcm_decode\x00")).as_ptr(), - 366 as libc::c_int, - ); + logprint(b"%s %s:%d unsupported channels\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 11], + &[libc::c_char; 11]>(b"pcm_decode\x00")).as_ptr(), + 366 as libc::c_int); } - 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 decoded %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"pcm_decode\x00")).as_ptr(), - 369 as libc::c_int, - frames, - ); + if loglevel as libc::c_uint >= lSDEBUG as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d decoded %u frames\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 11], + &[libc::c_char; 11]>(b"pcm_decode\x00")).as_ptr(), + 369 as libc::c_int, frames); } - crate::src::buffer::_buf_inc_readp(streambuf, frames.wrapping_mul(bytes_per_frame)); + _buf_inc_readp(streambuf, frames.wrapping_mul(bytes_per_frame)); if limit { - audio_left = (audio_left as libc::c_uint).wrapping_sub(frames.wrapping_mul(bytes_per_frame)) - as crate::squeezelite_h::u32_t as crate::squeezelite_h::u32_t + audio_left = + (audio_left as + libc::c_uint).wrapping_sub(frames.wrapping_mul(bytes_per_frame)) + as u32_t as u32_t } - crate::src::buffer::_buf_inc_writep( - outputbuf, - frames.wrapping_mul(8 as libc::c_int as libc::c_uint), - ); - crate::stdlib::pthread_mutex_unlock(&mut (*outputbuf).mutex); - crate::stdlib::pthread_mutex_unlock(&mut (*streambuf).mutex); - return crate::squeezelite_h::DECODE_RUNNING; + _buf_inc_writep(outputbuf, + frames.wrapping_mul(8 as libc::c_int as libc::c_uint)); + pthread_mutex_unlock(&mut (*outputbuf).mutex); + pthread_mutex_unlock(&mut (*streambuf).mutex); + return DECODE_RUNNING; } - -unsafe extern "C" fn pcm_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, -) { +unsafe extern "C" fn pcm_open(mut size: u8_t, mut rate: u8_t, mut chan: u8_t, + mut endianness: u8_t) { sample_size = - (size as libc::c_int - '0' as i32 + 1 as libc::c_int) as crate::squeezelite_h::u32_t; + (size as libc::c_int - '0' as i32 + 1 as libc::c_int) as u32_t; sample_rate = sample_rates[(rate as libc::c_int - '0' as i32) as usize]; - channels = (chan as libc::c_int - '0' as i32) as crate::squeezelite_h::u32_t; + channels = (chan as libc::c_int - '0' as i32) as u32_t; bigendian = endianness as libc::c_int == '0' as i32; limit = 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 pcm size: %u rate: %u chan: %u bigendian: %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"pcm_open\x00")).as_ptr(), - 397 as libc::c_int, - sample_size, - sample_rate, - channels, - bigendian as libc::c_int, - ); + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d pcm size: %u rate: %u chan: %u bigendian: %u\n\x00" + as *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 9], + &[libc::c_char; 9]>(b"pcm_open\x00")).as_ptr(), + 397 as libc::c_int, sample_size, sample_rate, channels, + bigendian as libc::c_int); } - crate::src::buffer::buf_adjust( - streambuf, - sample_size.wrapping_mul(channels) as crate::stddef_h::size_t, - ); + buf_adjust(streambuf, sample_size.wrapping_mul(channels) as size_t); } - unsafe extern "C" fn pcm_close() { - crate::src::buffer::buf_adjust(streambuf, 1 as libc::c_int as crate::stddef_h::size_t); + buf_adjust(streambuf, 1 as libc::c_int as size_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 . + * + * 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_pcm() -> *mut crate::squeezelite_h::codec { +pub unsafe extern "C" fn register_pcm() -> *mut codec { if pcm_check_header { - static mut ret: crate::squeezelite_h::codec = unsafe { - { - let mut init = crate::squeezelite_h::codec { - id: 'p' as i32 as libc::c_char, - types: b"wav,aif,pcm\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: 102400 as libc::c_int as libc::c_uint, - open: Some( - pcm_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(pcm_close as unsafe extern "C" fn() -> ()), - decode: Some( - pcm_decode as unsafe extern "C" fn() -> crate::squeezelite_h::decode_state, - ), - }; - init - } - }; - 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 pcm to decode wav,aif,pcm\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_pcm\x00")) - .as_ptr(), - 418 as libc::c_int, - ); + static mut ret: codec = + unsafe { + { + let mut init = + codec{id: 'p' as i32 as libc::c_char, + types: + b"wav,aif,pcm\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: + 102400 as libc::c_int as libc::c_uint, + open: + Some(pcm_open as + unsafe extern "C" fn(_: u8_t, + _: u8_t, + _: u8_t, + _: u8_t) + -> ()), + close: + Some(pcm_close as + unsafe extern "C" fn() -> ()), + decode: + Some(pcm_decode as + unsafe extern "C" fn() + -> decode_state),}; + init + } + }; + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d using pcm to decode wav,aif,pcm\n\x00" as + *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 13], + &[libc::c_char; 13]>(b"register_pcm\x00")).as_ptr(), + 418 as libc::c_int); } - return &mut ret; + return &mut ret } else { - static mut ret_0: crate::squeezelite_h::codec = unsafe { - { - let mut init = crate::squeezelite_h::codec { - id: 'p' as i32 as libc::c_char, - types: b"aif,pcm\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: 102400 as libc::c_int as libc::c_uint, - open: Some( - pcm_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(pcm_close as unsafe extern "C" fn() -> ()), - decode: Some( - pcm_decode as unsafe extern "C" fn() -> crate::squeezelite_h::decode_state, - ), - }; - init - } - }; - 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 pcm to decode aif,pcm\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_pcm\x00")) - .as_ptr(), - 433 as libc::c_int, - ); + static mut ret_0: codec = + unsafe { + { + let mut init = + codec{id: 'p' as i32 as libc::c_char, + types: + b"aif,pcm\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: + 102400 as libc::c_int as libc::c_uint, + open: + Some(pcm_open as + unsafe extern "C" fn(_: u8_t, + _: u8_t, + _: u8_t, + _: u8_t) + -> ()), + close: + Some(pcm_close as + unsafe extern "C" fn() -> ()), + decode: + Some(pcm_decode as + unsafe extern "C" fn() + -> decode_state),}; + init + } + }; + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d using pcm to decode aif,pcm\n\x00" as + *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 13], + &[libc::c_char; 13]>(b"register_pcm\x00")).as_ptr(), + 433 as libc::c_int); } - return &mut ret_0; + return &mut ret_0 }; } diff --git a/src/slimproto.rs b/src/slimproto.rs index 5f145a8..7683db5 100644 --- a/src/slimproto.rs +++ b/src/slimproto.rs @@ -1,167 +1,625 @@ -// =============== BEGIN slimproto_h ================ - -// char header[] - added in sendRESP - -// S:N:Slimproto _http_metadata_handler -#[repr(C, packed)] +use ::libc; +extern "C" { + pub type _IO_wide_data; + pub type _IO_codecvt; + pub type _IO_marker; + #[no_mangle] + fn close(__fd: libc::c_int) -> libc::c_int; + #[no_mangle] + fn sleep(__seconds: libc::c_uint) -> libc::c_uint; + #[no_mangle] + fn usleep(__useconds: __useconds_t) -> libc::c_int; + #[no_mangle] + fn fopen(_: *const libc::c_char, _: *const libc::c_char) -> *mut FILE; + #[no_mangle] + fn snprintf(_: *mut libc::c_char, _: libc::c_ulong, + _: *const libc::c_char, _: ...) -> libc::c_int; + #[no_mangle] + fn fgets(__s: *mut libc::c_char, __n: libc::c_int, __stream: *mut FILE) + -> *mut libc::c_char; + #[no_mangle] + fn fputs(__s: *const libc::c_char, __stream: *mut FILE) -> libc::c_int; + #[no_mangle] + fn malloc(_: libc::c_ulong) -> *mut libc::c_void; + #[no_mangle] + fn free(__ptr: *mut libc::c_void); + #[no_mangle] + fn memcpy(_: *mut libc::c_void, _: *const libc::c_void, _: libc::c_ulong) + -> *mut libc::c_void; + #[no_mangle] + fn memset(_: *mut libc::c_void, _: libc::c_int, _: libc::c_ulong) + -> *mut libc::c_void; + #[no_mangle] + fn strncpy(_: *mut libc::c_char, _: *const libc::c_char, _: libc::c_ulong) + -> *mut libc::c_char; + #[no_mangle] + fn strcat(_: *mut libc::c_char, _: *const libc::c_char) + -> *mut libc::c_char; + #[no_mangle] + fn strncat(_: *mut libc::c_char, _: *const libc::c_char, _: libc::c_ulong) + -> *mut libc::c_char; + #[no_mangle] + fn strncmp(_: *const libc::c_char, _: *const libc::c_char, + _: libc::c_ulong) -> libc::c_int; + #[no_mangle] + fn __errno_location() -> *mut libc::c_int; + #[no_mangle] + fn fclose(__stream: *mut FILE) -> libc::c_int; + #[no_mangle] + fn socket(__domain: libc::c_int, __type: libc::c_int, + __protocol: libc::c_int) -> libc::c_int; + #[no_mangle] + fn getsockname(__fd: libc::c_int, __addr: *mut sockaddr, + __len: *mut socklen_t) -> libc::c_int; + #[no_mangle] + fn send(__fd: libc::c_int, __buf: *const libc::c_void, __n: size_t, + __flags: libc::c_int) -> ssize_t; + #[no_mangle] + fn recv(__fd: libc::c_int, __buf: *mut libc::c_void, __n: size_t, + __flags: libc::c_int) -> ssize_t; + #[no_mangle] + fn sendto(__fd: libc::c_int, __buf: *const libc::c_void, __n: size_t, + __flags: libc::c_int, __addr: *const sockaddr, + __addr_len: socklen_t) -> ssize_t; + #[no_mangle] + fn recvfrom(__fd: libc::c_int, __buf: *mut libc::c_void, __n: size_t, + __flags: libc::c_int, __addr: *mut sockaddr, + __addr_len: *mut socklen_t) -> ssize_t; + #[no_mangle] + fn setsockopt(__fd: libc::c_int, __level: libc::c_int, + __optname: libc::c_int, __optval: *const libc::c_void, + __optlen: socklen_t) -> libc::c_int; + #[no_mangle] + fn ntohs(__netshort: uint16_t) -> uint16_t; + #[no_mangle] + fn htonl(__hostlong: uint32_t) -> uint32_t; + #[no_mangle] + fn htons(__hostshort: uint16_t) -> uint16_t; + #[no_mangle] + fn inet_ntoa(__in: in_addr) -> *mut libc::c_char; + #[no_mangle] + fn poll(__fds: *mut pollfd, __nfds: nfds_t, __timeout: libc::c_int) + -> libc::c_int; + #[no_mangle] + fn pthread_mutex_lock(__mutex: *mut pthread_mutex_t) -> libc::c_int; + #[no_mangle] + fn pthread_mutex_unlock(__mutex: *mut pthread_mutex_t) -> libc::c_int; + #[no_mangle] + fn eventfd(__count: libc::c_uint, __flags: libc::c_int) -> libc::c_int; + #[no_mangle] + fn eventfd_write(__fd: libc::c_int, __value: eventfd_t) -> libc::c_int; + #[no_mangle] + fn logtime() -> *const libc::c_char; + #[no_mangle] + fn logprint(fmt: *const libc::c_char, _: ...); + #[no_mangle] + fn gettime_ms() -> u32_t; + #[no_mangle] + fn set_nonblock(s: sockfd); + #[no_mangle] + fn connect_timeout(sock_0: sockfd, addr: *const sockaddr, + addrlen: socklen_t, timeout: libc::c_int) + -> libc::c_int; + #[no_mangle] + fn server_addr(server: *mut libc::c_char, ip_ptr: *mut in_addr_t, + port_ptr: *mut libc::c_uint); + #[no_mangle] + fn set_readwake_handles(handles: *mut pollfd, s: sockfd, e: libc::c_int); + #[no_mangle] + fn wait_readwake(handles: *mut pollfd, timeout: libc::c_int) + -> event_type; + #[no_mangle] + fn packN(dest: *mut u32_t, val: u32_t); + #[no_mangle] + fn packn(dest: *mut u16_t, val: u16_t); + #[no_mangle] + fn unpackN(src: *mut u32_t) -> u32_t; + #[no_mangle] + fn _buf_used(buf: *mut buffer) -> libc::c_uint; + #[no_mangle] + fn buf_flush(buf: *mut buffer); + #[no_mangle] + fn decode_flush(); + #[no_mangle] + fn output_flush(); + #[no_mangle] + fn stream_file(header: *const libc::c_char, header_len: size_t, + threshold: libc::c_uint); + #[no_mangle] + fn stream_sock(ip: u32_t, port: u16_t, header: *const libc::c_char, + header_len: size_t, threshold: libc::c_uint, + cont_wait: bool); + #[no_mangle] + fn codec_open(format: u8_t, sample_size: u8_t, sample_rate: u8_t, + channels: u8_t, endianness: u8_t); + #[no_mangle] + fn set_volume(left: libc::c_uint, right: libc::c_uint); + #[no_mangle] + fn stream_disconnect() -> bool; + #[no_mangle] + fn strlen(_: *const libc::c_char) -> libc::c_ulong; + #[no_mangle] + fn strerror(_: libc::c_int) -> *mut libc::c_char; + #[no_mangle] + static mut streambuf: *mut buffer; + #[no_mangle] + static mut outputbuf: *mut buffer; + #[no_mangle] + static mut stream: streamstate; + #[no_mangle] + static mut output: outputstate; + #[no_mangle] + static mut decode: decodestate; + #[no_mangle] + static mut codecs: [*mut codec; 0]; +} +pub type size_t = libc::c_ulong; +pub type __uint8_t = libc::c_uchar; +pub type __uint16_t = libc::c_ushort; +pub type __int32_t = libc::c_int; +pub type __uint32_t = libc::c_uint; +pub type __uint64_t = libc::c_ulong; +pub type __off_t = libc::c_long; +pub type __off64_t = libc::c_long; +pub type __useconds_t = libc::c_uint; +pub type __ssize_t = libc::c_long; +pub type __socklen_t = libc::c_uint; #[derive(Copy, Clone)] +#[repr(C)] +pub struct _IO_FILE { + pub _flags: libc::c_int, + pub _IO_read_ptr: *mut libc::c_char, + pub _IO_read_end: *mut libc::c_char, + pub _IO_read_base: *mut libc::c_char, + pub _IO_write_base: *mut libc::c_char, + pub _IO_write_ptr: *mut libc::c_char, + pub _IO_write_end: *mut libc::c_char, + pub _IO_buf_base: *mut libc::c_char, + pub _IO_buf_end: *mut libc::c_char, + pub _IO_save_base: *mut libc::c_char, + pub _IO_backup_base: *mut libc::c_char, + pub _IO_save_end: *mut libc::c_char, + pub _markers: *mut _IO_marker, + pub _chain: *mut _IO_FILE, + pub _fileno: libc::c_int, + pub _flags2: libc::c_int, + pub _old_offset: __off_t, + pub _cur_column: libc::c_ushort, + pub _vtable_offset: libc::c_schar, + pub _shortbuf: [libc::c_char; 1], + pub _lock: *mut libc::c_void, + pub _offset: __off64_t, + pub _codecvt: *mut _IO_codecvt, + pub _wide_data: *mut _IO_wide_data, + pub _freeres_list: *mut _IO_FILE, + pub _freeres_buf: *mut libc::c_void, + pub __pad5: size_t, + pub _mode: libc::c_int, + pub _unused2: [libc::c_char; 20], +} +pub type _IO_lock_t = (); +pub type FILE = _IO_FILE; +pub type ssize_t = __ssize_t; +pub type int32_t = __int32_t; +pub type u_int8_t = __uint8_t; +pub type u_int16_t = __uint16_t; +pub type u_int32_t = __uint32_t; +pub type u_int64_t = __uint64_t; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct __pthread_internal_list { + pub __prev: *mut __pthread_internal_list, + pub __next: *mut __pthread_internal_list, +} +pub type __pthread_list_t = __pthread_internal_list; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct __pthread_mutex_s { + pub __lock: libc::c_int, + pub __count: libc::c_uint, + pub __owner: libc::c_int, + pub __nusers: libc::c_uint, + pub __kind: libc::c_int, + pub __spins: libc::c_short, + pub __elision: libc::c_short, + pub __list: __pthread_list_t, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub union pthread_mutex_t { + pub __data: __pthread_mutex_s, + pub __size: [libc::c_char; 40], + pub __align: libc::c_long, +} +pub type socklen_t = __socklen_t; +pub type uint16_t = __uint16_t; +pub type uint32_t = __uint32_t; +pub type uint64_t = __uint64_t; +pub type __socket_type = libc::c_uint; +pub const SOCK_NONBLOCK: __socket_type = 2048; +pub const SOCK_CLOEXEC: __socket_type = 524288; +pub const SOCK_PACKET: __socket_type = 10; +pub const SOCK_DCCP: __socket_type = 6; +pub const SOCK_SEQPACKET: __socket_type = 5; +pub const SOCK_RDM: __socket_type = 4; +pub const SOCK_RAW: __socket_type = 3; +pub const SOCK_DGRAM: __socket_type = 2; +pub const SOCK_STREAM: __socket_type = 1; +pub type sa_family_t = libc::c_ushort; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct sockaddr { + pub sa_family: sa_family_t, + pub sa_data: [libc::c_char; 14], +} +pub type C2RustUnnamed = libc::c_uint; +pub const MSG_CMSG_CLOEXEC: C2RustUnnamed = 1073741824; +pub const MSG_FASTOPEN: C2RustUnnamed = 536870912; +pub const MSG_ZEROCOPY: C2RustUnnamed = 67108864; +pub const MSG_BATCH: C2RustUnnamed = 262144; +pub const MSG_WAITFORONE: C2RustUnnamed = 65536; +pub const MSG_MORE: C2RustUnnamed = 32768; +pub const MSG_NOSIGNAL: C2RustUnnamed = 16384; +pub const MSG_ERRQUEUE: C2RustUnnamed = 8192; +pub const MSG_RST: C2RustUnnamed = 4096; +pub const MSG_CONFIRM: C2RustUnnamed = 2048; +pub const MSG_SYN: C2RustUnnamed = 1024; +pub const MSG_FIN: C2RustUnnamed = 512; +pub const MSG_WAITALL: C2RustUnnamed = 256; +pub const MSG_EOR: C2RustUnnamed = 128; +pub const MSG_DONTWAIT: C2RustUnnamed = 64; +pub const MSG_TRUNC: C2RustUnnamed = 32; +pub const MSG_PROXY: C2RustUnnamed = 16; +pub const MSG_CTRUNC: C2RustUnnamed = 8; +pub const MSG_DONTROUTE: C2RustUnnamed = 4; +pub const MSG_PEEK: C2RustUnnamed = 2; +pub const MSG_OOB: C2RustUnnamed = 1; +pub type in_addr_t = uint32_t; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct in_addr { + pub s_addr: in_addr_t, +} +pub type in_port_t = uint16_t; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct sockaddr_in { + pub sin_family: sa_family_t, + pub sin_port: in_port_t, + pub sin_addr: in_addr, + pub sin_zero: [libc::c_uchar; 8], +} +pub type nfds_t = libc::c_ulong; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct pollfd { + pub fd: libc::c_int, + pub events: libc::c_short, + pub revents: libc::c_short, +} +pub type u8_t = u_int8_t; +pub type u16_t = u_int16_t; +pub type u32_t = u_int32_t; +pub type u64_t = u_int64_t; +pub type s32_t = int32_t; +pub type frames_t = u32_t; +pub type sockfd = libc::c_int; +pub type eventfd_t = uint64_t; +pub type log_level = libc::c_uint; +pub const lSDEBUG: log_level = 4; +pub const lDEBUG: log_level = 3; +pub const lINFO: log_level = 2; +pub const lWARN: log_level = 1; +pub const lERROR: log_level = 0; +pub type event_type = libc::c_uint; +pub const EVENT_WAKE: event_type = 2; +pub const EVENT_READ: event_type = 1; +pub const EVENT_TIMEOUT: event_type = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct buffer { + pub buf: *mut u8_t, + pub readp: *mut u8_t, + pub writep: *mut u8_t, + pub wrap: *mut u8_t, + pub size: size_t, + pub base_size: size_t, + pub mutex: pthread_mutex_t, +} +// char header[] - added in sendRESP +// S:N:Slimproto _http_metadata_handler +#[derive(Copy, Clone)] +#[repr(C, packed)] pub struct META_header { pub opcode: [libc::c_char; 4], - pub length: crate::squeezelite_h::u32_t, + pub length: u32_t, } // S:N:Slimproto _http_response_handler - -#[repr(C, packed)] #[derive(Copy, Clone)] +#[repr(C, packed)] pub struct RESP_header { pub opcode: [libc::c_char; 4], - pub length: crate::squeezelite_h::u32_t, + pub length: u32_t, } // u8_t capabilities[]; // S:N:Slimproto _stat_handler - -#[repr(C, packed)] #[derive(Copy, Clone)] +#[repr(C, packed)] pub struct STAT_packet { pub opcode: [libc::c_char; 4], - pub length: crate::squeezelite_h::u32_t, - pub event: crate::squeezelite_h::u32_t, - pub num_crlf: crate::squeezelite_h::u8_t, - pub mas_initialized: crate::squeezelite_h::u8_t, - pub mas_mode: crate::squeezelite_h::u8_t, - pub stream_buffer_size: crate::squeezelite_h::u32_t, - pub stream_buffer_fullness: crate::squeezelite_h::u32_t, - pub bytes_received_H: crate::squeezelite_h::u32_t, - pub bytes_received_L: crate::squeezelite_h::u32_t, - pub signal_strength: crate::squeezelite_h::u16_t, - pub jiffies: crate::squeezelite_h::u32_t, - pub output_buffer_size: crate::squeezelite_h::u32_t, - pub output_buffer_fullness: crate::squeezelite_h::u32_t, - pub elapsed_seconds: crate::squeezelite_h::u32_t, - pub voltage: crate::squeezelite_h::u16_t, - pub elapsed_milliseconds: crate::squeezelite_h::u32_t, - pub server_timestamp: crate::squeezelite_h::u32_t, - pub error_code: crate::squeezelite_h::u16_t, + pub length: u32_t, + pub event: u32_t, + pub num_crlf: u8_t, + pub mas_initialized: u8_t, + pub mas_mode: u8_t, + pub stream_buffer_size: u32_t, + pub stream_buffer_fullness: u32_t, + pub bytes_received_H: u32_t, + pub bytes_received_L: u32_t, + pub signal_strength: u16_t, + pub jiffies: u32_t, + pub output_buffer_size: u32_t, + pub output_buffer_fullness: u32_t, + pub elapsed_seconds: u32_t, + pub voltage: u16_t, + pub elapsed_milliseconds: u32_t, + pub server_timestamp: u32_t, + pub error_code: u16_t, } -// S:N:Slimproto _disco_handler - -#[repr(C, packed)] #[derive(Copy, Clone)] +#[repr(C)] +pub struct C2RustUnnamed_0 { + pub updated: u32_t, + pub stream_start: u32_t, + pub stream_full: u32_t, + pub stream_size: u32_t, + pub stream_bytes: u64_t, + pub output_full: u32_t, + pub output_size: u32_t, + pub frames_played: u32_t, + pub device_frames: u32_t, + pub current_sample_rate: u32_t, + pub last: u32_t, + pub stream_state: stream_state, +} +pub type stream_state = libc::c_uint; +pub const RECV_HEADERS: stream_state = 7; +pub const SEND_HEADERS: stream_state = 6; +pub const STREAMING_HTTP: stream_state = 5; +pub const STREAMING_FILE: stream_state = 4; +pub const STREAMING_BUFFERING: stream_state = 3; +pub const STREAMING_WAIT: stream_state = 2; +pub const DISCONNECT: stream_state = 1; +pub const STOPPED: stream_state = 0; +pub type disconnect_code = libc::c_uint; +pub const TIMEOUT: disconnect_code = 4; +pub const UNREACHABLE: disconnect_code = 3; +pub const REMOTE_DISCONNECT: disconnect_code = 2; +pub const LOCAL_DISCONNECT: disconnect_code = 1; +pub const DISCONNECT_OK: disconnect_code = 0; +// S:N:Slimproto _disco_handler +#[derive(Copy, Clone)] +#[repr(C, packed)] pub struct DSCO_packet { pub opcode: [libc::c_char; 4], - pub length: crate::squeezelite_h::u32_t, - pub reason: crate::squeezelite_h::u8_t, + pub length: u32_t, + pub reason: u8_t, +} +pub const OUTPUT_RUNNING: output_state = 2; +pub type output_state = libc::c_int; +pub const OUTPUT_START_AT: output_state = 5; +pub const OUTPUT_SKIP_FRAMES: output_state = 4; +pub const OUTPUT_PAUSE_FRAMES: output_state = 3; +pub const OUTPUT_BUFFER: output_state = 1; +pub const OUTPUT_STOPPED: output_state = 0; +pub const OUTPUT_OFF: output_state = -1; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct outputstate { + pub state: output_state, + pub format: output_format, + pub device: *const libc::c_char, + pub buffer: libc::c_uint, + pub period: libc::c_uint, + pub track_started: bool, + pub write_cb: Option libc::c_int>, + pub start_frames: libc::c_uint, + pub frames_played: libc::c_uint, + pub frames_played_dmp: libc::c_uint, + pub current_sample_rate: libc::c_uint, + pub supported_rates: [libc::c_uint; 18], + pub default_sample_rate: libc::c_uint, + pub error_opening: bool, + pub device_frames: libc::c_uint, + pub updated: u32_t, + pub track_start_time: u32_t, + pub current_replay_gain: u32_t, + pub c2rust_unnamed: C2RustUnnamed_1, + pub next_sample_rate: libc::c_uint, + pub track_start: *mut u8_t, + pub gainL: u32_t, + pub gainR: u32_t, + pub invert: bool, + pub next_replay_gain: u32_t, + pub threshold: libc::c_uint, + pub fade: fade_state, + pub fade_start: *mut u8_t, + pub fade_end: *mut u8_t, + pub fade_dir: fade_dir, + pub fade_mode: fade_mode, + pub fade_secs: libc::c_uint, + pub rate_delay: libc::c_uint, + pub delay_active: bool, + pub stop_time: u32_t, + pub idle_to: u32_t, +} +pub type fade_mode = libc::c_uint; +pub const FADE_INOUT: fade_mode = 4; +pub const FADE_OUT: fade_mode = 3; +pub const FADE_IN: fade_mode = 2; +pub const FADE_CROSSFADE: fade_mode = 1; +pub const FADE_NONE: fade_mode = 0; +pub type fade_dir = libc::c_uint; +pub const FADE_CROSS: fade_dir = 3; +pub const FADE_DOWN: fade_dir = 2; +pub const FADE_UP: fade_dir = 1; +pub type fade_state = libc::c_uint; +pub const FADE_ACTIVE: fade_state = 2; +pub const FADE_DUE: fade_state = 1; +pub const FADE_INACTIVE: fade_state = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub union C2RustUnnamed_1 { + pub pause_frames: u32_t, + pub skip_frames: u32_t, + pub start_at: u32_t, +} +pub type output_format = libc::c_uint; +pub const S16_LE: output_format = 3; +pub const S24_3LE: output_format = 2; +pub const S24_LE: output_format = 1; +pub const S32_LE: output_format = 0; +pub const DECODE_STOPPED: decode_state = 0; +pub type decode_state = libc::c_uint; +pub const DECODE_ERROR: decode_state = 4; +pub const DECODE_COMPLETE: decode_state = 3; +pub const DECODE_RUNNING: decode_state = 2; +pub const DECODE_READY: decode_state = 1; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct decodestate { + pub state: decode_state, + pub new_stream: bool, + pub mutex: pthread_mutex_t, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct streamstate { + pub state: stream_state, + pub disconnect: disconnect_code, + pub header: *mut libc::c_char, + pub header_len: size_t, + pub sent_headers: bool, + pub cont_wait: bool, + pub bytes: u64_t, + pub threshold: libc::c_uint, + pub meta_interval: u32_t, + pub meta_next: u32_t, + pub meta_left: u32_t, + pub meta_send: bool, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct handler { + pub opcode: [libc::c_char; 5], + pub handler: Option ()>, } // guids we don't use // S:C:Commands - -#[repr(C, packed)] #[derive(Copy, Clone)] +#[repr(C, packed)] pub struct serv_packet { pub opcode: [libc::c_char; 4], - pub server_ip: crate::squeezelite_h::u32_t, + pub server_ip: u32_t, } // possible sync group // S:P:Squeezebox2 - -#[repr(C, packed)] #[derive(Copy, Clone)] +#[repr(C, packed)] pub struct setd_packet { pub opcode: [libc::c_char; 4], - pub id: crate::squeezelite_h::u8_t, + pub id: u8_t, pub data: [libc::c_char; 0], } // char metadata[] // S:N:Slimproto _http_setting_handler - -#[repr(C, packed)] #[derive(Copy, Clone)] +#[repr(C, packed)] pub struct SETD_header { pub opcode: [libc::c_char; 4], - pub length: crate::squeezelite_h::u32_t, - pub id: crate::squeezelite_h::u8_t, + pub length: u32_t, + pub id: u8_t, } // S:P:Squeezebox2 - -#[repr(C, packed)] #[derive(Copy, Clone)] +#[repr(C, packed)] pub struct audg_packet { pub opcode: [libc::c_char; 4], - pub old_gainL: crate::squeezelite_h::u32_t, - pub old_gainR: crate::squeezelite_h::u32_t, - pub adjust: crate::squeezelite_h::u8_t, - pub preamp: crate::squeezelite_h::u8_t, - pub gainL: crate::squeezelite_h::u32_t, - pub gainR: crate::squeezelite_h::u32_t, + pub old_gainL: u32_t, + pub old_gainR: u32_t, + pub adjust: u8_t, + pub preamp: u8_t, + pub gainL: u32_t, + pub gainR: u32_t, } //char request_string[]; // S:P:Squeezebox2 - -#[repr(C, packed)] #[derive(Copy, Clone)] +#[repr(C, packed)] pub struct aude_packet { pub opcode: [libc::c_char; 4], - pub enable_spdif: crate::squeezelite_h::u8_t, - pub enable_dac: crate::squeezelite_h::u8_t, + pub enable_spdif: u8_t, + pub enable_dac: u8_t, } // codec open - this is an extension to slimproto to allow the server to read the header and then return decode params - -#[repr(C, packed)] #[derive(Copy, Clone)] +#[repr(C, packed)] pub struct codc_packet { pub opcode: [libc::c_char; 4], - pub format: crate::squeezelite_h::u8_t, - pub pcm_sample_size: crate::squeezelite_h::u8_t, - pub pcm_sample_rate: crate::squeezelite_h::u8_t, - pub pcm_channels: crate::squeezelite_h::u8_t, - pub pcm_endianness: crate::squeezelite_h::u8_t, + pub format: u8_t, + pub pcm_sample_size: u8_t, + pub pcm_sample_rate: u8_t, + pub pcm_channels: u8_t, + pub pcm_endianness: u8_t, } // squence ids - unused // S:P:Squeezebox2 - -#[repr(C, packed)] #[derive(Copy, Clone)] +#[repr(C, packed)] pub struct cont_packet { pub opcode: [libc::c_char; 4], - pub metaint: crate::squeezelite_h::u32_t, - pub loop_0: crate::squeezelite_h::u8_t, + pub metaint: u32_t, + pub loop_0: u8_t, } // data // from S:P:Squeezebox stream_s - -#[repr(C, packed)] #[derive(Copy, Clone)] +#[repr(C, packed)] pub struct strm_packet { pub opcode: [libc::c_char; 4], pub command: libc::c_char, - pub autostart: crate::squeezelite_h::u8_t, - pub format: crate::squeezelite_h::u8_t, - pub pcm_sample_size: crate::squeezelite_h::u8_t, - pub pcm_sample_rate: crate::squeezelite_h::u8_t, - pub pcm_channels: crate::squeezelite_h::u8_t, - pub pcm_endianness: crate::squeezelite_h::u8_t, - pub threshold: crate::squeezelite_h::u8_t, - pub spdif_enable: crate::squeezelite_h::u8_t, - pub transition_period: crate::squeezelite_h::u8_t, - pub transition_type: crate::squeezelite_h::u8_t, - pub flags: crate::squeezelite_h::u8_t, - pub output_threshold: crate::squeezelite_h::u8_t, - pub slaves: crate::squeezelite_h::u8_t, - pub replay_gain: crate::squeezelite_h::u32_t, - pub server_port: crate::squeezelite_h::u16_t, - pub server_ip: crate::squeezelite_h::u32_t, + pub autostart: u8_t, + pub format: u8_t, + pub pcm_sample_size: u8_t, + pub pcm_sample_rate: u8_t, + pub pcm_channels: u8_t, + pub pcm_endianness: u8_t, + pub threshold: u8_t, + pub spdif_enable: u8_t, + pub transition_period: u8_t, + pub transition_type: u8_t, + pub flags: u8_t, + pub output_threshold: u8_t, + pub slaves: u8_t, + pub replay_gain: u32_t, + pub server_port: u16_t, + pub server_ip: u32_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 @@ -173,275 +631,43 @@ pub struct strm_packet { */ // packet formats for slimproto // from S:N:Slimproto _hello_handler - -#[repr(C, packed)] #[derive(Copy, Clone)] +#[repr(C, packed)] pub struct HELO_packet { pub opcode: [libc::c_char; 4], - pub length: crate::squeezelite_h::u32_t, - pub deviceid: crate::squeezelite_h::u8_t, - pub revision: crate::squeezelite_h::u8_t, - pub mac: [crate::squeezelite_h::u8_t; 6], - pub uuid: [crate::squeezelite_h::u8_t; 16], - pub wlan_channellist: crate::squeezelite_h::u16_t, - pub bytes_received_H: crate::squeezelite_h::u32_t, - pub bytes_received_L: crate::squeezelite_h::u32_t, + pub length: u32_t, + pub deviceid: u8_t, + pub revision: u8_t, + pub mac: [u8_t; 6], + pub uuid: [u8_t; 16], + pub wlan_channellist: u16_t, + pub bytes_received_H: u32_t, + pub bytes_received_L: u32_t, pub lang: [libc::c_char; 2], } -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::__socklen_t; -pub use crate::stdlib::__ssize_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::__useconds_t; -pub use crate::stdlib::fclose; -pub use crate::stdlib::fgets; -pub use crate::stdlib::fopen; -pub use crate::stdlib::fputs; -pub use crate::stdlib::int32_t; -pub use crate::stdlib::snprintf; -pub use crate::stdlib::ssize_t; -pub use crate::stdlib::FILE; -pub use crate::stdlib::_IO_FILE; - -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_int16_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::stdlib::__socket_type; -pub use crate::stdlib::close; -pub use crate::stdlib::sa_family_t; -pub use crate::stdlib::sleep; -pub use crate::stdlib::socklen_t; -pub use crate::stdlib::uint16_t; -pub use crate::stdlib::uint32_t; -pub use crate::stdlib::uint64_t; -pub use crate::stdlib::usleep; -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::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::event_type; -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::sockfd; -pub use crate::squeezelite_h::stream_state; -pub use crate::squeezelite_h::streamstate; -pub use crate::squeezelite_h::u16_t; -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::EVENT_READ; -pub use crate::squeezelite_h::EVENT_TIMEOUT; -pub use crate::squeezelite_h::EVENT_WAKE; -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_flush; -pub use crate::src::decode::codec_open; -pub use crate::src::decode::decode_flush; -pub use crate::src::output::output_flush; -pub use crate::src::output_alsa::set_volume; -pub use crate::src::stream::stream_disconnect; -pub use crate::src::stream::stream_file; -pub use crate::src::stream::stream_sock; -pub use crate::src::utils::connect_timeout; -pub use crate::src::utils::gettime_ms; -pub use crate::src::utils::logprint; -pub use crate::src::utils::logtime; -pub use crate::src::utils::packN; -pub use crate::src::utils::packn; -pub use crate::src::utils::server_addr; -pub use crate::src::utils::set_nonblock; -pub use crate::src::utils::set_readwake_handles; -pub use crate::src::utils::unpackN; -pub use crate::src::utils::wait_readwake; -use crate::stdlib::__errno_location; -pub use crate::stdlib::eventfd; -pub use crate::stdlib::eventfd_t; -pub use crate::stdlib::eventfd_write; -use crate::stdlib::free; -use crate::stdlib::getsockname; -pub use crate::stdlib::htonl; -pub use crate::stdlib::htons; -pub use crate::stdlib::in_addr; -pub use crate::stdlib::in_addr_t; -pub use crate::stdlib::in_port_t; -use crate::stdlib::inet_ntoa; -use crate::stdlib::malloc; -use crate::stdlib::memcpy; -use crate::stdlib::memset; -pub use crate::stdlib::nfds_t; -pub use crate::stdlib::ntohs; -pub use crate::stdlib::poll; -pub use crate::stdlib::pollfd; -use crate::stdlib::pthread_mutex_lock; -use crate::stdlib::pthread_mutex_unlock; -use crate::stdlib::recv; -use crate::stdlib::recvfrom; -use crate::stdlib::send; -use crate::stdlib::sendto; -use crate::stdlib::setsockopt; -pub use crate::stdlib::sockaddr; -pub use crate::stdlib::sockaddr_in; -use crate::stdlib::socket; -use crate::stdlib::strcat; -use crate::stdlib::strerror; -use crate::stdlib::strlen; -use crate::stdlib::strncat; -use crate::stdlib::strncmp; -use crate::stdlib::strncpy; -pub use crate::stdlib::C2RustUnnamed_0; -pub use crate::stdlib::MSG_BATCH; -pub use crate::stdlib::MSG_CMSG_CLOEXEC; -pub use crate::stdlib::MSG_CONFIRM; -pub use crate::stdlib::MSG_CTRUNC; -pub use crate::stdlib::MSG_DONTROUTE; -pub use crate::stdlib::MSG_DONTWAIT; -pub use crate::stdlib::MSG_EOR; -pub use crate::stdlib::MSG_ERRQUEUE; -pub use crate::stdlib::MSG_FASTOPEN; -pub use crate::stdlib::MSG_FIN; -pub use crate::stdlib::MSG_MORE; -pub use crate::stdlib::MSG_NOSIGNAL; -pub use crate::stdlib::MSG_OOB; -pub use crate::stdlib::MSG_PEEK; -pub use crate::stdlib::MSG_PROXY; -pub use crate::stdlib::MSG_RST; -pub use crate::stdlib::MSG_SYN; -pub use crate::stdlib::MSG_TRUNC; -pub use crate::stdlib::MSG_WAITALL; -pub use crate::stdlib::MSG_WAITFORONE; -pub use crate::stdlib::MSG_ZEROCOPY; -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; - #[no_mangle] - pub static mut decode: crate::squeezelite_h::decodestate; - #[no_mangle] - pub static mut codecs: [*mut crate::squeezelite_h::codec; 0]; -} - -#[repr(C)] #[derive(Copy, Clone)] -pub struct C2RustUnnamed_17 { - pub updated: crate::squeezelite_h::u32_t, - pub stream_start: crate::squeezelite_h::u32_t, - pub stream_full: crate::squeezelite_h::u32_t, - pub stream_size: crate::squeezelite_h::u32_t, - pub stream_bytes: crate::squeezelite_h::u64_t, - pub output_full: crate::squeezelite_h::u32_t, - pub output_size: crate::squeezelite_h::u32_t, - pub frames_played: crate::squeezelite_h::u32_t, - pub device_frames: crate::squeezelite_h::u32_t, - pub current_sample_rate: crate::squeezelite_h::u32_t, - pub last: crate::squeezelite_h::u32_t, - pub stream_state: crate::squeezelite_h::stream_state, -} - #[repr(C)] -#[derive(Copy, Clone)] -pub struct handler { - pub opcode: [libc::c_char; 5], - pub handler: - Option ()>, +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 ()>, + pub close: Option ()>, + pub decode: Option decode_state>, } -/* +/* * 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 @@ -454,368 +680,276 @@ pub struct handler { * -Control of Raspberry pi GPIO for amplifier power * -Launch script on power status change from LMS */ - -static mut loglevel: crate::squeezelite_h::log_level = crate::squeezelite_h::lERROR; +static mut loglevel: log_level = lERROR; // 3483 - -static mut sock: crate::squeezelite_h::sockfd = -(1 as libc::c_int); - -static mut slimproto_ip: crate::stdlib::in_addr_t = 0 as libc::c_int as crate::stdlib::in_addr_t; +static mut sock: sockfd = -(1 as libc::c_int); +static mut slimproto_ip: in_addr_t = 0 as libc::c_int as in_addr_t; #[no_mangle] - pub static mut wake_e: libc::c_int = 0; - -static mut status: C2RustUnnamed_17 = C2RustUnnamed_17 { - updated: 0, - stream_start: 0, - stream_full: 0, - stream_size: 0, - stream_bytes: 0, - output_full: 0, - output_size: 0, - frames_played: 0, - device_frames: 0, - current_sample_rate: 0, - last: 0, - stream_state: crate::squeezelite_h::STOPPED, -}; +static mut status: C2RustUnnamed_0 = + C2RustUnnamed_0{updated: 0, + stream_start: 0, + stream_full: 0, + stream_size: 0, + stream_bytes: 0, + output_full: 0, + output_size: 0, + frames_played: 0, + device_frames: 0, + current_sample_rate: 0, + last: 0, + stream_state: STOPPED,}; #[no_mangle] - pub static mut autostart: libc::c_int = 0; #[no_mangle] - pub static mut sentSTMu: bool = false; #[no_mangle] - pub static mut sentSTMo: bool = false; #[no_mangle] - pub static mut sentSTMl: bool = false; #[no_mangle] - -pub static mut new_server: crate::squeezelite_h::u32_t = 0; +pub static mut new_server: u32_t = 0; #[no_mangle] - -pub static mut new_server_cap: *mut libc::c_char = 0 as *const libc::c_char as *mut libc::c_char; +pub static mut new_server_cap: *mut libc::c_char = + 0 as *const libc::c_char as *mut libc::c_char; #[no_mangle] - -pub static mut player_name: [libc::c_char; 65] = [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, -]; +pub static mut player_name: [libc::c_char; 65] = + [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; #[no_mangle] - pub static mut name_file: *const libc::c_char = 0 as *const libc::c_char; #[no_mangle] - -pub unsafe extern "C" fn send_packet( - mut packet: *mut crate::squeezelite_h::u8_t, - mut len: crate::stddef_h::size_t, -) { - let mut ptr = packet; // squeezeplay - let mut try_0 = 0 as libc::c_int as libc::c_uint; - let mut n: crate::stdlib::ssize_t = 0; +pub unsafe extern "C" fn send_packet(mut packet: *mut u8_t, mut len: size_t) { + let mut ptr: *mut u8_t = packet; // squeezeplay + let mut try_0: libc::c_uint = 0 as libc::c_int as libc::c_uint; + let mut n: ssize_t = 0; while len != 0 { - n = crate::stdlib::send( - sock, - ptr as *const libc::c_void, - len, - crate::stdlib::MSG_NOSIGNAL as libc::c_int, - ); + n = + send(sock, ptr as *const libc::c_void, len, + MSG_NOSIGNAL as libc::c_int); if n <= 0 as libc::c_int as libc::c_long { - if n < 0 as libc::c_int as libc::c_long - && *crate::stdlib::__errno_location() == 11 as libc::c_int - && try_0 < 10 as libc::c_int as libc::c_uint - { - if loglevel as libc::c_uint - >= crate::squeezelite_h::lDEBUG as libc::c_int as libc::c_uint - { + if n < 0 as libc::c_int as libc::c_long && + *__errno_location() == 11 as libc::c_int && + try_0 < 10 as libc::c_int as libc::c_uint { + if loglevel as libc::c_uint >= + lDEBUG as libc::c_int as libc::c_uint { try_0 = try_0.wrapping_add(1); - crate::src::utils::logprint( - b"%s %s:%d retrying (%d) writing to socket\n\x00" as *const u8 - as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 12], &[libc::c_char; 12]>( - b"send_packet\x00", - )) - .as_ptr(), - 104 as libc::c_int, - try_0, - ); + logprint(b"%s %s:%d retrying (%d) writing to socket\n\x00" + as *const u8 as *const libc::c_char, + logtime(), + (*::std::mem::transmute::<&[u8; 12], + &[libc::c_char; 12]>(b"send_packet\x00")).as_ptr(), + 104 as libc::c_int, try_0); } - crate::stdlib::usleep(1000 as libc::c_int as crate::stdlib::__useconds_t); + usleep(1000 as libc::c_int as __useconds_t); } 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 failed writing to socket: %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"send_packet\x00", - )) - .as_ptr(), - 108 as libc::c_int, - crate::stdlib::strerror(*crate::stdlib::__errno_location()), - ); + if loglevel as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d failed writing to socket: %s\n\x00" as + *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 12], + &[libc::c_char; 12]>(b"send_packet\x00")).as_ptr(), + 108 as libc::c_int, + strerror(*__errno_location())); } - return; + return } } else { ptr = ptr.offset(n as isize); - len = (len as libc::c_ulong).wrapping_sub(n as libc::c_ulong) as crate::stddef_h::size_t - as crate::stddef_h::size_t + len = + (len as libc::c_ulong).wrapping_sub(n as libc::c_ulong) as + size_t as size_t } - } -} - -unsafe extern "C" fn sendHELO( - mut reconnect: bool, - mut fixed_cap: *const libc::c_char, - mut var_cap: *const libc::c_char, - mut mac: *mut crate::squeezelite_h::u8_t, -) { - let mut base_cap = 0 as *const libc::c_char; - let mut pkt = crate::src::slimproto::HELO_packet { - opcode: [0; 4], - length: 0, - deviceid: 0, - revision: 0, - mac: [0; 6], - uuid: [0; 16], - wlan_channellist: 0, - bytes_received_H: 0, - bytes_received_L: 0, - lang: [0; 2], }; +} +unsafe extern "C" fn sendHELO(mut reconnect: bool, + mut fixed_cap: *const libc::c_char, + mut var_cap: *const libc::c_char, + mut mac: *mut u8_t) { + let mut base_cap: *const libc::c_char = 0 as *const libc::c_char; + let mut pkt: HELO_packet = + HELO_packet{opcode: [0; 4], + length: 0, + deviceid: 0, + revision: 0, + mac: [0; 6], + uuid: [0; 16], + wlan_channellist: 0, + bytes_received_H: 0, + bytes_received_L: 0, + lang: [0; 2],}; base_cap = - b"Model=squeezelite,AccuratePlayPoints=1,HasDigitalOut=1,HasPolarityInversion=1,Firmware=v1.9.7-1218\x00" + b"Model=squeezelite,AccuratePlayPoints=1,HasDigitalOut=1,HasPolarityInversion=1,Firmware=v1.9.7-1223\x00" as *const u8 as *const libc::c_char; - crate::stdlib::memset( - &mut pkt as *mut crate::src::slimproto::HELO_packet as *mut libc::c_void, - 0 as libc::c_int, - ::std::mem::size_of::() as libc::c_ulong, - ); - crate::stdlib::memcpy( - &mut pkt.opcode as *mut [libc::c_char; 4] as *mut libc::c_void, - b"HELO\x00" as *const u8 as *const libc::c_char as *const libc::c_void, - 4 as libc::c_int as libc::c_ulong, - ); - pkt.length = crate::stdlib::htonl( - (::std::mem::size_of::() as libc::c_ulong) - .wrapping_sub(8 as libc::c_int as libc::c_ulong) - .wrapping_add(crate::stdlib::strlen(base_cap)) - .wrapping_add(crate::stdlib::strlen(fixed_cap)) - .wrapping_add(crate::stdlib::strlen(var_cap)) as crate::stdlib::uint32_t, - ); - pkt.deviceid = 12 as libc::c_int as crate::squeezelite_h::u8_t; - pkt.revision = 0 as libc::c_int as crate::squeezelite_h::u8_t; - crate::src::utils::packn( - &mut pkt.wlan_channellist, - if reconnect as libc::c_int != 0 { - 0x4000 as libc::c_int - } else { - 0 as libc::c_int - } as crate::squeezelite_h::u16_t, - ); - crate::src::utils::packN( - &mut pkt.bytes_received_H, - (status.stream_bytes >> 32 as libc::c_int) as crate::squeezelite_h::u32_t, - ); - crate::src::utils::packN( - &mut pkt.bytes_received_L, - (status.stream_bytes & 0xffffffff as libc::c_uint as libc::c_ulong) - as crate::squeezelite_h::u32_t, - ); - crate::stdlib::memcpy( - pkt.mac.as_mut_ptr() as *mut libc::c_void, - mac as *const libc::c_void, - 6 as libc::c_int as libc::c_ulong, - ); - 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 mac: %02x:%02x:%02x:%02x:%02x:%02x\n\x00" as *const u8 - as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 9], &[libc::c_char; 9]>(b"sendHELO\x00")).as_ptr(), - 142 as libc::c_int, - pkt.mac[0 as libc::c_int as usize] as libc::c_int, - pkt.mac[1 as libc::c_int as usize] as libc::c_int, - pkt.mac[2 as libc::c_int as usize] as libc::c_int, - pkt.mac[3 as libc::c_int as usize] as libc::c_int, - pkt.mac[4 as libc::c_int as usize] as libc::c_int, - pkt.mac[5 as libc::c_int as usize] as libc::c_int, - ); + memset(&mut pkt as *mut HELO_packet as *mut libc::c_void, + 0 as libc::c_int, + ::std::mem::size_of::() as libc::c_ulong); + memcpy(&mut pkt.opcode as *mut [libc::c_char; 4] as *mut libc::c_void, + b"HELO\x00" as *const u8 as *const libc::c_char as + *const libc::c_void, 4 as libc::c_int as libc::c_ulong); + pkt.length = + htonl((::std::mem::size_of::() as + libc::c_ulong).wrapping_sub(8 as libc::c_int as + libc::c_ulong).wrapping_add(strlen(base_cap)).wrapping_add(strlen(fixed_cap)).wrapping_add(strlen(var_cap)) + as uint32_t); + pkt.deviceid = 12 as libc::c_int as u8_t; + pkt.revision = 0 as libc::c_int as u8_t; + packn(&mut pkt.wlan_channellist, + if reconnect as libc::c_int != 0 { + 0x4000 as libc::c_int + } else { 0 as libc::c_int } as u16_t); + packN(&mut pkt.bytes_received_H, + (status.stream_bytes >> 32 as libc::c_int) as u32_t); + packN(&mut pkt.bytes_received_L, + (status.stream_bytes & 0xffffffff as libc::c_uint as libc::c_ulong) + as u32_t); + memcpy(pkt.mac.as_mut_ptr() as *mut libc::c_void, + mac as *const libc::c_void, 6 as libc::c_int as libc::c_ulong); + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d mac: %02x:%02x:%02x:%02x:%02x:%02x\n\x00" as + *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 9], + &[libc::c_char; 9]>(b"sendHELO\x00")).as_ptr(), + 142 as libc::c_int, + pkt.mac[0 as libc::c_int as usize] as libc::c_int, + pkt.mac[1 as libc::c_int as usize] as libc::c_int, + pkt.mac[2 as libc::c_int as usize] as libc::c_int, + pkt.mac[3 as libc::c_int as usize] as libc::c_int, + pkt.mac[4 as libc::c_int as usize] as libc::c_int, + pkt.mac[5 as libc::c_int as usize] 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 cap: %s%s%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"sendHELO\x00")).as_ptr(), - 144 as libc::c_int, - base_cap, - fixed_cap, - var_cap, - ); + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d cap: %s%s%s\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 9], + &[libc::c_char; 9]>(b"sendHELO\x00")).as_ptr(), + 144 as libc::c_int, base_cap, fixed_cap, var_cap); } - send_packet( - &mut pkt as *mut crate::src::slimproto::HELO_packet as *mut crate::squeezelite_h::u8_t, - ::std::mem::size_of::() as libc::c_ulong, - ); - send_packet( - base_cap as *mut crate::squeezelite_h::u8_t, - crate::stdlib::strlen(base_cap), - ); - send_packet( - fixed_cap as *mut crate::squeezelite_h::u8_t, - crate::stdlib::strlen(fixed_cap), - ); - send_packet( - var_cap as *mut crate::squeezelite_h::u8_t, - crate::stdlib::strlen(var_cap), - ); + send_packet(&mut pkt as *mut HELO_packet as *mut u8_t, + ::std::mem::size_of::() as libc::c_ulong); + send_packet(base_cap as *mut u8_t, strlen(base_cap)); + send_packet(fixed_cap as *mut u8_t, strlen(fixed_cap)); + send_packet(var_cap as *mut u8_t, strlen(var_cap)); } - -unsafe extern "C" fn sendSTAT( - mut event: *const libc::c_char, - mut server_timestamp: crate::squeezelite_h::u32_t, -) { - let mut pkt = crate::src::slimproto::STAT_packet { - opcode: [0; 4], - length: 0, - event: 0, - num_crlf: 0, - mas_initialized: 0, - mas_mode: 0, - stream_buffer_size: 0, - stream_buffer_fullness: 0, - bytes_received_H: 0, - bytes_received_L: 0, - signal_strength: 0, - jiffies: 0, - output_buffer_size: 0, - output_buffer_fullness: 0, - elapsed_seconds: 0, - voltage: 0, - elapsed_milliseconds: 0, - server_timestamp: 0, - error_code: 0, - }; - let mut now = crate::src::utils::gettime_ms(); - let mut ms_played: crate::squeezelite_h::u32_t = 0; - if status.current_sample_rate != 0 - && status.frames_played != 0 - && status.frames_played > status.device_frames - { - ms_played = (status.frames_played.wrapping_sub(status.device_frames) - as crate::squeezelite_h::u64_t) - .wrapping_mul(1000 as libc::c_int as crate::squeezelite_h::u64_t) - .wrapping_div(status.current_sample_rate as crate::squeezelite_h::u64_t) - as crate::squeezelite_h::u32_t; +unsafe extern "C" fn sendSTAT(mut event: *const libc::c_char, + mut server_timestamp: u32_t) { + let mut pkt: STAT_packet = + STAT_packet{opcode: [0; 4], + length: 0, + event: 0, + num_crlf: 0, + mas_initialized: 0, + mas_mode: 0, + stream_buffer_size: 0, + stream_buffer_fullness: 0, + bytes_received_H: 0, + bytes_received_L: 0, + signal_strength: 0, + jiffies: 0, + output_buffer_size: 0, + output_buffer_fullness: 0, + elapsed_seconds: 0, + voltage: 0, + elapsed_milliseconds: 0, + server_timestamp: 0, + error_code: 0,}; + let mut now: u32_t = gettime_ms(); + let mut ms_played: u32_t = 0; + if status.current_sample_rate != 0 && status.frames_played != 0 && + status.frames_played > status.device_frames { + ms_played = + (status.frames_played.wrapping_sub(status.device_frames) as + u64_t).wrapping_mul(1000 as libc::c_int as + u64_t).wrapping_div(status.current_sample_rate + as u64_t) as + u32_t; if now > status.updated { - ms_played = (ms_played as libc::c_uint).wrapping_add(now.wrapping_sub(status.updated)) - as crate::squeezelite_h::u32_t - as crate::squeezelite_h::u32_t + ms_played = + (ms_played as + libc::c_uint).wrapping_add(now.wrapping_sub(status.updated)) + as u32_t as u32_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 ms_played: %u (frames_played: %u device_frames: %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"sendSTAT\x00")).as_ptr(), - 160 as libc::c_int, - ms_played, - status.frames_played, - status.device_frames, - ); + if loglevel as libc::c_uint >= lSDEBUG as libc::c_int as libc::c_uint + { + logprint(b"%s %s:%d ms_played: %u (frames_played: %u device_frames: %u)\n\x00" + as *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 9], + &[libc::c_char; 9]>(b"sendSTAT\x00")).as_ptr(), + 160 as libc::c_int, ms_played, status.frames_played, + status.device_frames); } } else if status.frames_played != 0 && now > status.stream_start { ms_played = now.wrapping_sub(status.stream_start); - 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 ms_played: %u using elapsed time (frames_played: %u device_frames: %u)\n\x00" - as *const u8 as *const libc::c_char, crate::src::utils::logtime(), + if loglevel as libc::c_uint >= lSDEBUG as libc::c_int as libc::c_uint + { + logprint(b"%s %s:%d ms_played: %u using elapsed time (frames_played: %u device_frames: %u)\n\x00" + as *const u8 as *const libc::c_char, logtime(), (*::std::mem::transmute::<&[u8; 9], &[libc::c_char; 9]>(b"sendSTAT\x00")).as_ptr(), 163 as libc::c_int, ms_played, status.frames_played, status.device_frames); } } else { - 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 ms_played: 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"sendSTAT\x00")).as_ptr(), - 165 as libc::c_int, - ); - } - ms_played = 0 as libc::c_int as crate::squeezelite_h::u32_t - } - crate::stdlib::memset( - &mut pkt as *mut crate::src::slimproto::STAT_packet as *mut libc::c_void, - 0 as libc::c_int, - ::std::mem::size_of::() as libc::c_ulong, - ); - crate::stdlib::memcpy( - &mut pkt.opcode as *mut [libc::c_char; 4] as *mut libc::c_void, - b"STAT\x00" as *const u8 as *const libc::c_char as *const libc::c_void, - 4 as libc::c_int as libc::c_ulong, - ); - pkt.length = crate::stdlib::htonl( - (::std::mem::size_of::() as libc::c_ulong) - .wrapping_sub(8 as libc::c_int as libc::c_ulong) as crate::stdlib::uint32_t, - ); - crate::stdlib::memcpy( - &mut pkt.event as *mut crate::squeezelite_h::u32_t as *mut libc::c_void, - event as *const libc::c_void, - 4 as libc::c_int as libc::c_ulong, - ); - // num_crlf - // mas_initialized; mas_mode; - crate::src::utils::packN(&mut pkt.stream_buffer_fullness, status.stream_full); - crate::src::utils::packN(&mut pkt.stream_buffer_size, status.stream_size); - crate::src::utils::packN( - &mut pkt.bytes_received_H, - (status.stream_bytes >> 32 as libc::c_int) as crate::squeezelite_h::u32_t, - ); - crate::src::utils::packN( - &mut pkt.bytes_received_L, - (status.stream_bytes & 0xffffffff as libc::c_uint as libc::c_ulong) - as crate::squeezelite_h::u32_t, - ); - pkt.signal_strength = 0xffff as libc::c_int as crate::squeezelite_h::u16_t; - crate::src::utils::packN(&mut pkt.jiffies, now); - crate::src::utils::packN(&mut pkt.output_buffer_size, status.output_size); - crate::src::utils::packN(&mut pkt.output_buffer_fullness, status.output_full); - crate::src::utils::packN( - &mut pkt.elapsed_seconds, - ms_played.wrapping_div(1000 as libc::c_int as libc::c_uint), - ); - // voltage; - crate::src::utils::packN(&mut pkt.elapsed_milliseconds, ms_played); // keep this is server format - don't unpack/pack - pkt.server_timestamp = server_timestamp; - // error_code; - 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 STAT: %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"sendSTAT\x00")).as_ptr(), - 189 as libc::c_int, - event, - ); // id 0 is playername S:P:Squeezebox2 - } // STMt replay_gain is no longer used to track latency, but support it - if loglevel as libc::c_uint == crate::squeezelite_h::lSDEBUG 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 received bytesL: %u streambuf: %u outputbuf: %u calc elapsed: %u real elapsed: %u (diff: %d) device: %u delay: %d\n\x00" - as *const u8 as *const libc::c_char, crate::src::utils::logtime(), + if loglevel as libc::c_uint >= lSDEBUG as libc::c_int as libc::c_uint + { + logprint(b"%s %s:%d ms_played: 0\n\x00" as *const u8 as + *const libc::c_char, logtime(), (*::std::mem::transmute::<&[u8; 9], &[libc::c_char; 9]>(b"sendSTAT\x00")).as_ptr(), - 194 as libc::c_int, status.stream_bytes as crate::squeezelite_h::u32_t, + 165 as libc::c_int); + } + ms_played = 0 as libc::c_int as u32_t + } + memset(&mut pkt as *mut STAT_packet as *mut libc::c_void, + 0 as libc::c_int, + ::std::mem::size_of::
::\tSpecify ALSA params to open output device, b = buffer time in ms or size in bytes, p = period count or size in bytes, f sample format (16|24|24_3|32), m = use mmap (0|1)\n -a \t\tSpecify sample format (16|24|32) of output file when using -o - to output samples to stdout (interleaved little endian only)\n -b :\tSpecify internal Stream and Output buffer sizes in Kbytes\n -c ,\tRestrict codecs to those specified, otherwise load all available codecs; known codecs: flac,pcm,mp3,ogg,aac (mad,mpg for specific mp3 codec)\n \t\t\tCodecs reported to LMS in order listed, allowing codec priority refinement.\n -C \t\tClose output device when idle after timeout seconds, default is to keep it open while player is \'on\'\n -d =\tSet logging level, logs: all|slimproto|stream|decode|output, level: info|debug|sdebug\n -e ,\tExplicitly exclude native support of one or more codecs; known codecs: flac,pcm,mp3,ogg,aac (mad,mpg for specific mp3 codec)\n -f \t\tWrite debug to logfile\n -m \t\tSet mac address, format: ab:cd:ef:12:34:56\n -M \tSet the squeezelite player model name sent to the server (default: SqueezeLite)\n -n \t\tSet the player name\n -N \t\tStore player name in filename to allow server defined name changes to be shared between servers (not supported with -n)\n -W\t\t\tRead wave and aiff format from header, ignore server parameters\n -p \t\tSet real time priority of output thread (1-99)\n -P \t\tStore the process id (PID) in filename\n -r [:]\tSample rates supported, allows output to be off when squeezelite is started; rates = |-|,,; delay = optional delay switching rates in ms\n -O \tSpecify mixer device, defaults to \'output device\'\n -L \t\t\tList volume controls for output device\n -U \t\tUnmute ALSA control and set to full volume (not supported with -V)\n -V \t\tUse ALSA control for volume adjustment, otherwise use software volume adjustment\n -X \t\t\tUse linear volume adjustments instead of in terms of dB (only for hardware volume control)\n -z \t\t\tDaemonize\n -t \t\t\tLicense terms\n -? \t\t\tDisplay this help text\n\nBuild options: LINUX ALSA EVENTFD\n\n\x00" as *const u8 as *const libc::c_char, argv0); } - unsafe extern "C" fn license() { - crate::stdlib::printf(b"Squeezelite v1.9.7-1218, Copyright 2012-2015 Adrian Smith, 2015-2020 Ralph Irving.\n\nThis program is free software: you can redistribute it and/or modify\nit under the terms of the GNU General Public License as published by\nthe Free Software Foundation, either version 3 of the License, or\n(at your option) any later version.\n\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with this program. If not, see .\n\nOption to allow server side upsampling for PCM streams (-W) from\nsqueezelite-R2 (c) Marco Curti 2015, marcoc1712@gmail.com.\n\n\x00" + printf(b"Squeezelite v1.9.7-1223, Copyright 2012-2015 Adrian Smith, 2015-2020 Ralph Irving.\n\nThis program is free software: you can redistribute it and/or modify\nit under the terms of the GNU General Public License as published by\nthe Free Software Foundation, either version 3 of the License, or\n(at your option) any later version.\n\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with this program. If not, see .\n\nOption to allow server side upsampling for PCM streams (-W) from\nsqueezelite-R2 (c) Marco Curti 2015, marcoc1712@gmail.com.\n\n\x00" as *const u8 as *const libc::c_char); } - unsafe extern "C" fn sighandler(mut signum: libc::c_int) { - crate::squeezelite_h::slimproto_stop(); + slimproto_stop(); // remove ourselves in case above does not work, second SIGINT will cause non gracefull shutdown - crate::stdlib::signal(signum, None); // set later + signal(signum, None); // set later } - -unsafe fn main_0(mut argc: libc::c_int, mut argv: *mut *mut libc::c_char) -> libc::c_int { - let mut server = 0 as *mut libc::c_char; - let mut output_device = b"default\x00" as *const u8 as *const libc::c_char as *mut libc::c_char; - let mut include_codecs = 0 as *mut libc::c_char; - let mut exclude_codecs = b"\x00" as *const u8 as *const libc::c_char as *mut libc::c_char; - let mut name = 0 as *mut libc::c_char; - let mut namefile = 0 as *mut libc::c_char; - let mut modelname = 0 as *mut libc::c_char; +#[cross_check(entry(djb2="main"), exit(djb2="main"))] +unsafe fn main_0(mut argc: libc::c_int, mut argv: *mut *mut libc::c_char) + -> libc::c_int { + let mut server: *mut libc::c_char = 0 as *mut libc::c_char; + let mut output_device: *mut libc::c_char = + b"default\x00" as *const u8 as *const libc::c_char as + *mut libc::c_char; + let mut include_codecs: *mut libc::c_char = 0 as *mut libc::c_char; + let mut exclude_codecs: *mut libc::c_char = + b"\x00" as *const u8 as *const libc::c_char as *mut libc::c_char; + let mut name: *mut libc::c_char = 0 as *mut libc::c_char; + let mut namefile: *mut libc::c_char = 0 as *mut libc::c_char; + let mut modelname: *mut libc::c_char = 0 as *mut libc::c_char; extern "C" { #[no_mangle] - pub static mut pcm_check_header: bool; + static mut pcm_check_header: bool; } extern "C" { #[no_mangle] - pub static mut user_rates: bool; + static mut user_rates: bool; } - let mut logfile = 0 as *mut libc::c_char; - let mut mac: [crate::squeezelite_h::u8_t; 6] = [0; 6]; - let mut stream_buf_size = - (2 as libc::c_int * 1024 as libc::c_int * 1024 as libc::c_int) as libc::c_uint; - let mut output_buf_size = 0 as libc::c_int as libc::c_uint; - let mut rates: [libc::c_uint; 18] = [ - 0 as libc::c_int as libc::c_uint, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - ]; - let mut rate_delay = 0 as libc::c_int as libc::c_uint; - let mut resample = 0 as *mut libc::c_char; - let mut output_params = 0 as *mut libc::c_char; - let mut idle = 0 as libc::c_int as libc::c_uint; - let mut daemonize = 0 as libc::c_int != 0; - let mut pidfile = 0 as *mut libc::c_char; - let mut pidfp = 0 as *mut crate::stdlib::FILE; - let mut rt_priority = 45 as libc::c_int as libc::c_uint; - let mut mixer_device = output_device; - let mut output_mixer = 0 as *mut libc::c_char; - let mut output_mixer_unmute = 0 as libc::c_int != 0; - let mut linear_volume = 0 as libc::c_int != 0; - let mut log_output = crate::squeezelite_h::lWARN; - let mut log_stream = crate::squeezelite_h::lWARN; - let mut log_decode = crate::squeezelite_h::lWARN; - let mut log_slimproto = crate::squeezelite_h::lWARN; - let mut maxSampleRate = 0 as libc::c_int; - let mut optarg = 0 as *mut libc::c_char; - let mut optind = 1 as libc::c_int; + let mut logfile: *mut libc::c_char = 0 as *mut libc::c_char; + let mut mac: [u8_t; 6] = [0; 6]; + let mut stream_buf_size: libc::c_uint = + (2 as libc::c_int * 1024 as libc::c_int * 1024 as libc::c_int) as + libc::c_uint; + let mut output_buf_size: libc::c_uint = 0 as libc::c_int as libc::c_uint; + let mut rates: [libc::c_uint; 18] = + [0 as libc::c_int as libc::c_uint, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0]; + let mut rate_delay: libc::c_uint = 0 as libc::c_int as libc::c_uint; + let mut resample: *mut libc::c_char = 0 as *mut libc::c_char; + let mut output_params: *mut libc::c_char = 0 as *mut libc::c_char; + let mut idle: libc::c_uint = 0 as libc::c_int as libc::c_uint; + let mut daemonize: bool = 0 as libc::c_int != 0; + let mut pidfile: *mut libc::c_char = 0 as *mut libc::c_char; + let mut pidfp: *mut FILE = 0 as *mut FILE; + let mut rt_priority: libc::c_uint = 45 as libc::c_int as libc::c_uint; + let mut mixer_device: *mut libc::c_char = output_device; + let mut output_mixer: *mut libc::c_char = 0 as *mut libc::c_char; + let mut output_mixer_unmute: bool = 0 as libc::c_int != 0; + let mut linear_volume: bool = 0 as libc::c_int != 0; + let mut log_output: log_level = lWARN; + let mut log_stream: log_level = lWARN; + let mut log_decode: log_level = lWARN; + let mut log_slimproto: log_level = lWARN; + let mut maxSampleRate: libc::c_int = 0 as libc::c_int; + let mut optarg: *mut libc::c_char = 0 as *mut libc::c_char; + let mut optind: libc::c_int = 1 as libc::c_int; let mut i: libc::c_int = 0; let mut cmdline: [libc::c_char; 512] = *::std::mem::transmute::<&[u8; 512], &mut [libc::c_char; 512]>(b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"); - crate::squeezelite_h::get_mac(mac.as_mut_ptr()); + get_mac(mac.as_mut_ptr()); i = 0 as libc::c_int; - while i < argc - && crate::stdlib::strlen(*argv.offset(i as isize)) - .wrapping_add(crate::stdlib::strlen(cmdline.as_mut_ptr())) - .wrapping_add(2 as libc::c_int as libc::c_ulong) - < 512 as libc::c_int as libc::c_ulong - { - crate::stdlib::strcat(cmdline.as_mut_ptr(), *argv.offset(i as isize)); - crate::stdlib::strcat( - cmdline.as_mut_ptr(), - b" \x00" as *const u8 as *const libc::c_char, - ); + while i < argc && + strlen(*argv.offset(i as + isize)).wrapping_add(strlen(cmdline.as_mut_ptr())).wrapping_add(2 + as + libc::c_int + as + libc::c_ulong) + < 512 as libc::c_int as libc::c_ulong { + strcat(cmdline.as_mut_ptr(), *argv.offset(i as isize)); + strcat(cmdline.as_mut_ptr(), + b" \x00" as *const u8 as *const libc::c_char); i += 1 } - while optind < argc - && crate::stdlib::strlen(*argv.offset(optind as isize)) >= 2 as libc::c_int as libc::c_ulong - && *(*argv.offset(optind as isize)).offset(0 as libc::c_int as isize) as libc::c_int - == '-' as i32 - { - let mut opt = (*argv.offset(optind as isize)).offset(1 as libc::c_int as isize); - if !crate::stdlib::strstr( - b"oabcCdefmMnNpPrsUVO\x00" as *const u8 as *const libc::c_char, - opt, - ) - .is_null() - && optind < argc - 1 as libc::c_int - { + while optind < argc && + strlen(*argv.offset(optind as isize)) >= + 2 as libc::c_int as libc::c_ulong && + *(*argv.offset(optind as + isize)).offset(0 as libc::c_int as isize) as + libc::c_int == '-' as i32 { + let mut opt: *mut libc::c_char = + (*argv.offset(optind as isize)).offset(1 as libc::c_int as isize); + if !strstr(b"oabcCdefmMnNpPrsUVO\x00" as *const u8 as + *const libc::c_char, opt).is_null() && + optind < argc - 1 as libc::c_int { optarg = *argv.offset((optind + 1 as libc::c_int) as isize); optind += 2 as libc::c_int - } else if !crate::stdlib::strstr(b"ltz?WLX\x00" as *const u8 as *const libc::c_char, opt) - .is_null() - { + } else if !strstr(b"ltz?WLX\x00" as *const u8 as *const libc::c_char, + opt).is_null() { optarg = 0 as *mut libc::c_char; optind += 1 as libc::c_int } else { - crate::stdlib::fprintf( - crate::stdlib::stderr, - b"\nOption error: -%s\n\n\x00" as *const u8 as *const libc::c_char, - opt, - ); + fprintf(stderr, + b"\nOption error: -%s\n\n\x00" as *const u8 as + *const libc::c_char, opt); usage(*argv.offset(0 as libc::c_int as isize)); - crate::stdlib::exit(1 as libc::c_int); + exit(1 as libc::c_int); } let mut current_block_129: u64; match *opt.offset(0 as libc::c_int as isize) as libc::c_int { @@ -465,16 +347,18 @@ unsafe fn main_0(mut argc: libc::c_int, mut argv: *mut *mut libc::c_char) -> lib current_block_129 = 10517665100358322178; } 98 => { - let mut s = crate::squeezelite_h::next_param(optarg, ':' as i32 as libc::c_char); - let mut o = crate::squeezelite_h::next_param( - 0 as *mut libc::c_char, - ':' as i32 as libc::c_char, - ); + let mut s: *mut libc::c_char = + next_param(optarg, ':' as i32 as libc::c_char); + let mut o: *mut libc::c_char = + next_param(0 as *mut libc::c_char, + ':' as i32 as libc::c_char); if !s.is_null() { - stream_buf_size = (crate::stdlib::atoi(s) * 1024 as libc::c_int) as libc::c_uint + stream_buf_size = + (atoi(s) * 1024 as libc::c_int) as libc::c_uint } if !o.is_null() { - output_buf_size = (crate::stdlib::atoi(o) * 1024 as libc::c_int) as libc::c_uint + output_buf_size = + (atoi(o) * 1024 as libc::c_int) as libc::c_uint } current_block_129 = 10517665100358322178; } @@ -483,8 +367,9 @@ unsafe fn main_0(mut argc: libc::c_int, mut argv: *mut *mut libc::c_char) -> lib current_block_129 = 10517665100358322178; } 67 => { - if crate::stdlib::atoi(optarg) > 0 as libc::c_int { - idle = (crate::stdlib::atoi(optarg) * 1000 as libc::c_int) as libc::c_uint + if atoi(optarg) > 0 as libc::c_int { + idle = + (atoi(optarg) * 1000 as libc::c_int) as libc::c_uint } current_block_129 = 10517665100358322178; } @@ -493,70 +378,67 @@ unsafe fn main_0(mut argc: libc::c_int, mut argv: *mut *mut libc::c_char) -> lib current_block_129 = 10517665100358322178; } 100 => { - let mut l = - crate::stdlib::strtok(optarg, b"=\x00" as *const u8 as *const libc::c_char); - let mut v = crate::stdlib::strtok( - 0 as *mut libc::c_char, - b"=\x00" as *const u8 as *const libc::c_char, - ); - let mut new = crate::squeezelite_h::lWARN; + let mut l: *mut libc::c_char = + strtok(optarg, + b"=\x00" as *const u8 as *const libc::c_char); + let mut v: *mut libc::c_char = + strtok(0 as *mut libc::c_char, + b"=\x00" as *const u8 as *const libc::c_char); + let mut new: log_level = lWARN; if !l.is_null() && !v.is_null() { - if crate::stdlib::strcmp(v, b"info\x00" as *const u8 as *const libc::c_char) - == 0 - { - new = crate::squeezelite_h::lINFO + if strcmp(v, + b"info\x00" as *const u8 as *const libc::c_char) + == 0 { + new = lINFO } - if crate::stdlib::strcmp(v, b"debug\x00" as *const u8 as *const libc::c_char) - == 0 - { - new = crate::squeezelite_h::lDEBUG + if strcmp(v, + b"debug\x00" as *const u8 as + *const libc::c_char) == 0 { + new = lDEBUG } - if crate::stdlib::strcmp(v, b"sdebug\x00" as *const u8 as *const libc::c_char) - == 0 - { - new = crate::squeezelite_h::lSDEBUG + if strcmp(v, + b"sdebug\x00" as *const u8 as + *const libc::c_char) == 0 { + new = lSDEBUG } - if crate::stdlib::strcmp(l, b"all\x00" as *const u8 as *const libc::c_char) == 0 - || crate::stdlib::strcmp( - l, - b"slimproto\x00" as *const u8 as *const libc::c_char, - ) == 0 - { + if strcmp(l, + b"all\x00" as *const u8 as *const libc::c_char) + == 0 || + strcmp(l, + b"slimproto\x00" as *const u8 as + *const libc::c_char) == 0 { log_slimproto = new } - if crate::stdlib::strcmp(l, b"all\x00" as *const u8 as *const libc::c_char) == 0 - || crate::stdlib::strcmp( - l, - b"stream\x00" as *const u8 as *const libc::c_char, - ) == 0 - { + if strcmp(l, + b"all\x00" as *const u8 as *const libc::c_char) + == 0 || + strcmp(l, + b"stream\x00" as *const u8 as + *const libc::c_char) == 0 { log_stream = new } - if crate::stdlib::strcmp(l, b"all\x00" as *const u8 as *const libc::c_char) == 0 - || crate::stdlib::strcmp( - l, - b"decode\x00" as *const u8 as *const libc::c_char, - ) == 0 - { + if strcmp(l, + b"all\x00" as *const u8 as *const libc::c_char) + == 0 || + strcmp(l, + b"decode\x00" as *const u8 as + *const libc::c_char) == 0 { log_decode = new } - if crate::stdlib::strcmp(l, b"all\x00" as *const u8 as *const libc::c_char) == 0 - || crate::stdlib::strcmp( - l, - b"output\x00" as *const u8 as *const libc::c_char, - ) == 0 - { + if strcmp(l, + b"all\x00" as *const u8 as *const libc::c_char) + == 0 || + strcmp(l, + b"output\x00" as *const u8 as + *const libc::c_char) == 0 { log_output = new } } else { - crate::stdlib::fprintf( - crate::stdlib::stderr, - b"\nDebug settings error: -d %s\n\n\x00" as *const u8 - as *const libc::c_char, - optarg, - ); + fprintf(stderr, + b"\nDebug settings error: -d %s\n\n\x00" as + *const u8 as *const libc::c_char, optarg); usage(*argv.offset(0 as libc::c_int as isize)); - crate::stdlib::exit(1 as libc::c_int); + exit(1 as libc::c_int); } current_block_129 = 10517665100358322178; } @@ -565,33 +447,31 @@ unsafe fn main_0(mut argc: libc::c_int, mut argv: *mut *mut libc::c_char) -> lib current_block_129 = 10517665100358322178; } 109 => { - let mut byte = 0 as libc::c_int; - let mut tmp = 0 as *mut libc::c_char; - if crate::stdlib::strncmp( - optarg, - b"00:04:20\x00" as *const u8 as *const libc::c_char, - 8 as libc::c_int as libc::c_ulong, - ) == 0 - { - crate::squeezelite_h::logprint(b"%s %s:%d ignoring mac address from hardware player range 00:04:20:**:**:**\n\x00" + let mut byte: libc::c_int = 0 as libc::c_int; + let mut tmp: *mut libc::c_char = 0 as *mut libc::c_char; + if strncmp(optarg, + b"00:04:20\x00" as *const u8 as + *const libc::c_char, + 8 as libc::c_int as libc::c_ulong) == 0 { + logprint(b"%s %s:%d ignoring mac address from hardware player range 00:04:20:**:**:**\n\x00" as *const u8 as *const libc::c_char, - crate::squeezelite_h::logtime(), + logtime(), (*::std::mem::transmute::<&[u8; 5], &[libc::c_char; 5]>(b"main\x00")).as_ptr(), 453 as libc::c_int); } else { - let mut t = - crate::stdlib::strtok(optarg, b":\x00" as *const u8 as *const libc::c_char); + let mut t: *mut libc::c_char = + strtok(optarg, + b":\x00" as *const u8 as *const libc::c_char); while !t.is_null() && byte < 6 as libc::c_int { let fresh0 = byte; byte = byte + 1; mac[fresh0 as usize] = - crate::stdlib::strtoul(t, &mut tmp, 16 as libc::c_int) - as crate::squeezelite_h::u8_t; - t = crate::stdlib::strtok( - 0 as *mut libc::c_char, - b":\x00" as *const u8 as *const libc::c_char, - ) + strtoul(t, &mut tmp, 16 as libc::c_int) as u8_t; + t = + strtok(0 as *mut libc::c_char, + b":\x00" as *const u8 as + *const libc::c_char) } } current_block_129 = 10517665100358322178; @@ -601,57 +481,39 @@ unsafe fn main_0(mut argc: libc::c_int, mut argv: *mut *mut libc::c_char) -> lib current_block_129 = 10517665100358322178; } 114 => { - let mut rstr = crate::squeezelite_h::next_param(optarg, ':' as i32 as libc::c_char); - let mut dstr = crate::squeezelite_h::next_param( - 0 as *mut libc::c_char, - ':' as i32 as libc::c_char, - ); - if !rstr.is_null() - && !crate::stdlib::strstr(rstr, b",\x00" as *const u8 as *const libc::c_char) - .is_null() - { + let mut rstr: *mut libc::c_char = + next_param(optarg, ':' as i32 as libc::c_char); + let mut dstr: *mut libc::c_char = + next_param(0 as *mut libc::c_char, + ':' as i32 as libc::c_char); + if !rstr.is_null() && + !strstr(rstr, + b",\x00" as *const u8 as + *const libc::c_char).is_null() { // parse sample rates and sort them - let mut r = crate::squeezelite_h::next_param(rstr, ',' as i32 as libc::c_char); - let mut tmp_0: [libc::c_uint; 18] = [ - 0 as libc::c_int as libc::c_uint, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - ]; + let mut r: *mut libc::c_char = + next_param(rstr, ',' as i32 as libc::c_char); + let mut tmp_0: [libc::c_uint; 18] = + [0 as libc::c_int as libc::c_uint, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; let mut i_0: libc::c_int = 0; let mut j: libc::c_int = 0; - let mut last = 999999 as libc::c_int; + let mut last: libc::c_int = 999999 as libc::c_int; i_0 = 0 as libc::c_int; while !r.is_null() && i_0 < 18 as libc::c_int { - tmp_0[i_0 as usize] = crate::stdlib::atoi(r) as libc::c_uint; - r = crate::squeezelite_h::next_param( - 0 as *mut libc::c_char, - ',' as i32 as libc::c_char, - ); + tmp_0[i_0 as usize] = atoi(r) as libc::c_uint; + r = + next_param(0 as *mut libc::c_char, + ',' as i32 as libc::c_char); i_0 += 1 } i_0 = 0 as libc::c_int; while i_0 < 18 as libc::c_int { - let mut largest = 0 as libc::c_int; + let mut largest: libc::c_int = 0 as libc::c_int; j = 0 as libc::c_int; while j < 18 as libc::c_int { - if tmp_0[j as usize] > largest as libc::c_uint - && tmp_0[j as usize] < last as libc::c_uint - { + if tmp_0[j as usize] > largest as libc::c_uint && + tmp_0[j as usize] < last as libc::c_uint { largest = tmp_0[j as usize] as libc::c_int } j += 1 @@ -662,59 +524,51 @@ unsafe fn main_0(mut argc: libc::c_int, mut argv: *mut *mut libc::c_char) -> lib } } else if !rstr.is_null() { // optstr is - or , extract rates from test rates within this range - let mut ref_0: [libc::c_uint; 18] = [ - 768000 as libc::c_int as libc::c_uint, - 705600 as libc::c_int as libc::c_uint, - 384000 as libc::c_int as libc::c_uint, - 352800 as libc::c_int as libc::c_uint, - 192000 as libc::c_int as libc::c_uint, - 176400 as libc::c_int as libc::c_uint, - 96000 as libc::c_int as libc::c_uint, - 88200 as libc::c_int as libc::c_uint, - 48000 as libc::c_int as libc::c_uint, - 44100 as libc::c_int as libc::c_uint, - 32000 as libc::c_int as libc::c_uint, - 24000 as libc::c_int as libc::c_uint, - 22500 as libc::c_int as libc::c_uint, - 16000 as libc::c_int as libc::c_uint, - 12000 as libc::c_int as libc::c_uint, - 11025 as libc::c_int as libc::c_uint, - 8000 as libc::c_int as libc::c_uint, - 0 as libc::c_int as libc::c_uint, - ]; - let mut str1 = - crate::squeezelite_h::next_param(rstr, '-' as i32 as libc::c_char); - let mut str2 = crate::squeezelite_h::next_param( - 0 as *mut libc::c_char, - '-' as i32 as libc::c_char, - ); - let mut max = if !str2.is_null() { - crate::stdlib::atoi(str2) as libc::c_uint - } else if !str1.is_null() { - crate::stdlib::atoi(str1) as libc::c_uint - } else { - ref_0[0 as libc::c_int as usize] - }; - let mut min = if !str1.is_null() && !str2.is_null() { - crate::stdlib::atoi(str1) - } else { - 0 as libc::c_int - } as libc::c_uint; + let mut ref_0: [libc::c_uint; 18] = + [768000 as libc::c_int as libc::c_uint, + 705600 as libc::c_int as libc::c_uint, + 384000 as libc::c_int as libc::c_uint, + 352800 as libc::c_int as libc::c_uint, + 192000 as libc::c_int as libc::c_uint, + 176400 as libc::c_int as libc::c_uint, + 96000 as libc::c_int as libc::c_uint, + 88200 as libc::c_int as libc::c_uint, + 48000 as libc::c_int as libc::c_uint, + 44100 as libc::c_int as libc::c_uint, + 32000 as libc::c_int as libc::c_uint, + 24000 as libc::c_int as libc::c_uint, + 22500 as libc::c_int as libc::c_uint, + 16000 as libc::c_int as libc::c_uint, + 12000 as libc::c_int as libc::c_uint, + 11025 as libc::c_int as libc::c_uint, + 8000 as libc::c_int as libc::c_uint, + 0 as libc::c_int as libc::c_uint]; + let mut str1: *mut libc::c_char = + next_param(rstr, '-' as i32 as libc::c_char); + let mut str2: *mut libc::c_char = + next_param(0 as *mut libc::c_char, + '-' as i32 as libc::c_char); + let mut max: libc::c_uint = + if !str2.is_null() { + atoi(str2) as libc::c_uint + } else if !str1.is_null() { + atoi(str1) as libc::c_uint + } else { ref_0[0 as libc::c_int as usize] }; + let mut min: libc::c_uint = + if !str1.is_null() && !str2.is_null() { + atoi(str1) + } else { 0 as libc::c_int } as libc::c_uint; let mut tmp_1: libc::c_uint = 0; let mut i_1: libc::c_int = 0; let mut j_0: libc::c_int = 0; - if max < min { - tmp_1 = max; - max = min; - min = tmp_1 - } + if max < min { tmp_1 = max; max = min; min = tmp_1 } rates[0 as libc::c_int as usize] = max; i_1 = 0 as libc::c_int; j_0 = 1 as libc::c_int; while i_1 < 18 as libc::c_int { - if ref_0[i_1 as usize] < rates[(j_0 - 1 as libc::c_int) as usize] - && ref_0[i_1 as usize] >= min - { + if ref_0[i_1 as usize] < + rates[(j_0 - 1 as libc::c_int) as usize] && + ref_0[i_1 as usize] >= min { let fresh1 = j_0; j_0 = j_0 + 1; rates[fresh1 as usize] = ref_0[i_1 as usize] @@ -722,9 +576,7 @@ unsafe fn main_0(mut argc: libc::c_int, mut argv: *mut *mut libc::c_char) -> lib i_1 += 1 } } - if !dstr.is_null() { - rate_delay = crate::stdlib::atoi(dstr) as libc::c_uint - } + if !dstr.is_null() { rate_delay = atoi(dstr) as libc::c_uint } if rates[0 as libc::c_int as usize] != 0 { user_rates = 1 as libc::c_int != 0 } @@ -747,18 +599,14 @@ unsafe fn main_0(mut argc: libc::c_int, mut argv: *mut *mut libc::c_char) -> lib current_block_129 = 10517665100358322178; } 112 => { - rt_priority = crate::stdlib::atoi(optarg) as libc::c_uint; - if rt_priority > 99 as libc::c_int as libc::c_uint - || rt_priority < 1 as libc::c_int as libc::c_uint - { - crate::stdlib::fprintf( - crate::stdlib::stderr, - b"\nError: invalid priority: %s\n\n\x00" as *const u8 - as *const libc::c_char, - optarg, - ); + rt_priority = atoi(optarg) as libc::c_uint; + if rt_priority > 99 as libc::c_int as libc::c_uint || + rt_priority < 1 as libc::c_int as libc::c_uint { + fprintf(stderr, + b"\nError: invalid priority: %s\n\n\x00" as + *const u8 as *const libc::c_char, optarg); usage(*argv.offset(0 as libc::c_int as isize)); - crate::stdlib::exit(1 as libc::c_int); + exit(1 as libc::c_int); } current_block_129 = 10517665100358322178; } @@ -766,99 +614,79 @@ unsafe fn main_0(mut argc: libc::c_int, mut argv: *mut *mut libc::c_char) -> lib pidfile = optarg; current_block_129 = 10517665100358322178; } - 108 => { - crate::squeezelite_h::list_devices(); - crate::stdlib::exit(0 as libc::c_int); - } + 108 => { list_devices(); exit(0 as libc::c_int); } 79 => { mixer_device = optarg; current_block_129 = 10517665100358322178; } - 76 => { - crate::squeezelite_h::list_mixers(mixer_device); - crate::stdlib::exit(0 as libc::c_int); - } + 76 => { list_mixers(mixer_device); exit(0 as libc::c_int); } 88 => { linear_volume = 1 as libc::c_int != 0; current_block_129 = 10517665100358322178; } 85 => { output_mixer_unmute = 1 as libc::c_int != 0; - current_block_129 = 17662379048890589436; - } - 86 => { - current_block_129 = 17662379048890589436; + current_block_129 = 8353035839816271260; } + 86 => { current_block_129 = 8353035839816271260; } 122 => { daemonize = 1 as libc::c_int != 0; current_block_129 = 10517665100358322178; } - 116 => { - license(); - crate::stdlib::exit(0 as libc::c_int); - } + 116 => { license(); exit(0 as libc::c_int); } 63 => { usage(*argv.offset(0 as libc::c_int as isize)); - crate::stdlib::exit(0 as libc::c_int); + exit(0 as libc::c_int); } _ => { - crate::stdlib::fprintf( - crate::stdlib::stderr, - b"Arg error: %s\n\x00" as *const u8 as *const libc::c_char, - *argv.offset(optind as isize), - ); + fprintf(stderr, + b"Arg error: %s\n\x00" as *const u8 as + *const libc::c_char, + *argv.offset(optind as isize)); current_block_129 = 10517665100358322178; } } match current_block_129 { - 17662379048890589436 => { + 8353035839816271260 => { if !output_mixer.is_null() { - crate::stdlib::fprintf( - crate::stdlib::stderr, - b"-U and -V option should not be used at same time\n\x00" as *const u8 - as *const libc::c_char, - ); - crate::stdlib::exit(1 as libc::c_int); + fprintf(stderr, + b"-U and -V option should not be used at same time\n\x00" + as *const u8 as *const libc::c_char); + exit(1 as libc::c_int); } output_mixer = optarg } - _ => {} + _ => { } } } // warn if command line includes something which isn't parsed if optind < argc { - crate::stdlib::fprintf( - crate::stdlib::stderr, - b"\nError: command line argument error\n\n\x00" as *const u8 as *const libc::c_char, - ); + fprintf(stderr, + b"\nError: command line argument error\n\n\x00" as *const u8 + as *const libc::c_char); usage(*argv.offset(0 as libc::c_int as isize)); - crate::stdlib::exit(1 as libc::c_int); + exit(1 as libc::c_int); } - crate::stdlib::signal( - 2 as libc::c_int, - Some(sighandler as unsafe extern "C" fn(_: libc::c_int) -> ()), - ); - crate::stdlib::signal( - 15 as libc::c_int, - Some(sighandler as unsafe extern "C" fn(_: libc::c_int) -> ()), - ); - crate::stdlib::signal( - 3 as libc::c_int, - Some(sighandler as unsafe extern "C" fn(_: libc::c_int) -> ()), - ); - crate::stdlib::signal( - 1 as libc::c_int, - Some(sighandler as unsafe extern "C" fn(_: libc::c_int) -> ()), - ); + signal(2 as libc::c_int, + Some(sighandler as unsafe extern "C" fn(_: libc::c_int) -> ())); + signal(15 as libc::c_int, + Some(sighandler as unsafe extern "C" fn(_: libc::c_int) -> ())); + signal(3 as libc::c_int, + Some(sighandler as unsafe extern "C" fn(_: libc::c_int) -> ())); + signal(1 as libc::c_int, + Some(sighandler as unsafe extern "C" fn(_: libc::c_int) -> ())); // set the output buffer size if not specified on the command line, take account of resampling if output_buf_size == 0 { output_buf_size = - (44100 as libc::c_int * 8 as libc::c_int * 10 as libc::c_int) as libc::c_uint; + (44100 as libc::c_int * 8 as libc::c_int * 10 as libc::c_int) as + libc::c_uint; if !resample.is_null() { - let mut scale = 8 as libc::c_int as libc::c_uint; + let mut scale: libc::c_uint = 8 as libc::c_int as libc::c_uint; if rates[0 as libc::c_int as usize] != 0 { - scale = rates[0 as libc::c_int as usize] - .wrapping_div(44100 as libc::c_int as libc::c_uint); + scale = + rates[0 as libc::c_int as + usize].wrapping_div(44100 as libc::c_int as + libc::c_uint); if scale > 8 as libc::c_int as libc::c_uint { scale = 8 as libc::c_int as libc::c_uint } @@ -870,145 +698,94 @@ unsafe fn main_0(mut argc: libc::c_int, mut argv: *mut *mut libc::c_char) -> lib } } if !logfile.is_null() { - if crate::stdlib::freopen( - logfile, - b"a\x00" as *const u8 as *const libc::c_char, - crate::stdlib::stderr, - ) - .is_null() - { - crate::stdlib::fprintf( - crate::stdlib::stderr, - b"error opening logfile %s: %s\n\x00" as *const u8 as *const libc::c_char, - logfile, - crate::stdlib::strerror(*crate::stdlib::__errno_location()), - ); - } else if log_output as libc::c_uint - >= crate::squeezelite_h::lINFO as libc::c_int as libc::c_uint - || log_stream as libc::c_uint - >= crate::squeezelite_h::lINFO as libc::c_int as libc::c_uint - || log_decode as libc::c_uint - >= crate::squeezelite_h::lINFO as libc::c_int as libc::c_uint - || log_slimproto as libc::c_uint - >= crate::squeezelite_h::lINFO as libc::c_int as libc::c_uint - { - crate::stdlib::fprintf( - crate::stdlib::stderr, - b"\n%s\n\x00" as *const u8 as *const libc::c_char, - cmdline.as_mut_ptr(), - ); + if freopen(logfile, b"a\x00" as *const u8 as *const libc::c_char, + stderr).is_null() { + fprintf(stderr, + b"error opening logfile %s: %s\n\x00" as *const u8 as + *const libc::c_char, logfile, + strerror(*__errno_location())); + } else if log_output as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint || + log_stream as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint || + log_decode as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint || + log_slimproto as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint { + fprintf(stderr, b"\n%s\n\x00" as *const u8 as *const libc::c_char, + cmdline.as_mut_ptr()); } } if !pidfile.is_null() { - pidfp = crate::stdlib::fopen(pidfile, b"w\x00" as *const u8 as *const libc::c_char); + pidfp = fopen(pidfile, b"w\x00" as *const u8 as *const libc::c_char); if pidfp.is_null() { - crate::stdlib::fprintf( - crate::stdlib::stderr, - b"Error opening pidfile %s: %s\n\x00" as *const u8 as *const libc::c_char, - pidfile, - crate::stdlib::strerror(*crate::stdlib::__errno_location()), - ); - crate::stdlib::exit(1 as libc::c_int); + fprintf(stderr, + b"Error opening pidfile %s: %s\n\x00" as *const u8 as + *const libc::c_char, pidfile, + strerror(*__errno_location())); + exit(1 as libc::c_int); } - pidfile = crate::stdlib::realpath(pidfile, 0 as *mut libc::c_char) + pidfile = realpath(pidfile, 0 as *mut libc::c_char) // daemonize will change cwd } if daemonize { - if crate::stdlib::daemon( - 0 as libc::c_int, - if !logfile.is_null() { - 1 as libc::c_int - } else { - 0 as libc::c_int - }, - ) != 0 - { - crate::stdlib::fprintf( - crate::stdlib::stderr, - b"error daemonizing: %s\n\x00" as *const u8 as *const libc::c_char, - crate::stdlib::strerror(*crate::stdlib::__errno_location()), - ); + if daemon(0 as libc::c_int, + if !logfile.is_null() { + 1 as libc::c_int + } else { 0 as libc::c_int }) != 0 { + fprintf(stderr, + b"error daemonizing: %s\n\x00" as *const u8 as + *const libc::c_char, strerror(*__errno_location())); } } if !pidfp.is_null() { - crate::stdlib::fprintf( - pidfp, - b"%d\n\x00" as *const u8 as *const libc::c_char, - crate::stdlib::getpid(), - ); - crate::stdlib::fclose(pidfp); + fprintf(pidfp, b"%d\n\x00" as *const u8 as *const libc::c_char, + getpid()); + fclose(pidfp); } - crate::squeezelite_h::stream_init(log_stream, stream_buf_size); - if crate::stdlib::strcmp(output_device, b"-\x00" as *const u8 as *const libc::c_char) == 0 { - crate::squeezelite_h::output_init_stdout( - log_output, - output_buf_size, - output_params, - rates.as_mut_ptr(), - rate_delay, - ); + stream_init(log_stream, stream_buf_size); + if strcmp(output_device, b"-\x00" as *const u8 as *const libc::c_char) == + 0 { + output_init_stdout(log_output, output_buf_size, output_params, + rates.as_mut_ptr(), rate_delay); } else { - crate::squeezelite_h::output_init_alsa( - log_output, - output_device, - output_buf_size, - output_params, - rates.as_mut_ptr(), - rate_delay, - rt_priority, - idle, - mixer_device, - output_mixer, - output_mixer_unmute, - linear_volume, - ); + output_init_alsa(log_output, output_device, output_buf_size, + output_params, rates.as_mut_ptr(), rate_delay, + rt_priority, idle, mixer_device, output_mixer, + output_mixer_unmute, linear_volume); } - crate::squeezelite_h::decode_init(log_decode, include_codecs, exclude_codecs); + decode_init(log_decode, include_codecs, exclude_codecs); if !name.is_null() && !namefile.is_null() { - crate::stdlib::fprintf( - crate::stdlib::stderr, - b"-n and -N option should not be used at same time\n\x00" as *const u8 - as *const libc::c_char, - ); - crate::stdlib::exit(1 as libc::c_int); - } - crate::squeezelite_h::slimproto( - log_slimproto, - server, - mac.as_mut_ptr(), - name, - namefile, - modelname, - maxSampleRate, - ); - crate::squeezelite_h::decode_close(); - crate::squeezelite_h::stream_close(); - if crate::stdlib::strcmp(output_device, b"-\x00" as *const u8 as *const libc::c_char) == 0 { - crate::squeezelite_h::output_close_stdout(); - } else { - crate::squeezelite_h::output_close_alsa(); + fprintf(stderr, + b"-n and -N option should not be used at same time\n\x00" as + *const u8 as *const libc::c_char); + exit(1 as libc::c_int); } + slimproto(log_slimproto, server, mac.as_mut_ptr(), name, namefile, + modelname, maxSampleRate); + decode_close(); + stream_close(); + if strcmp(output_device, b"-\x00" as *const u8 as *const libc::c_char) == + 0 { + output_close_stdout(); + } else { output_close_alsa(); } if !pidfile.is_null() { - crate::stdlib::unlink(pidfile); - crate::stdlib::free(pidfile as *mut libc::c_void); + unlink(pidfile); + free(pidfile as *mut libc::c_void); } - crate::stdlib::exit(0 as libc::c_int); + exit(0 as libc::c_int); } +#[cross_check(none)] #[main] pub fn main() { let mut args: Vec<*mut libc::c_char> = Vec::new(); for arg in ::std::env::args() { - args.push( - ::std::ffi::CString::new(arg) - .expect("Failed to convert argument into CString.") - .into_raw(), - ); - } + args.push(::std::ffi::CString::new(arg).expect("Failed to convert argument into CString.").into_raw()); + }; args.push(::std::ptr::null_mut()); unsafe { - ::std::process::exit(main_0( - (args.len() - 1) as libc::c_int, - args.as_mut_ptr() as *mut *mut libc::c_char, - ) as i32) + ::std::process::exit(main_0((args.len() - 1) as libc::c_int, + args.as_mut_ptr() as + *mut *mut libc::c_char) as i32) } } diff --git a/src/mpg.rs b/src/mpg.rs index 5fe1a00..e96b23e 100644 --- a/src/mpg.rs +++ b/src/mpg.rs @@ -1,646 +1,752 @@ 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" { + pub type mpg123_handle_struct; #[no_mangle] - pub static mut loglevel: crate::squeezelite_h::log_level; + fn malloc(_: libc::c_ulong) -> *mut libc::c_void; #[no_mangle] - pub static mut streambuf: *mut crate::squeezelite_h::buffer; + fn _checkfade(_: bool); #[no_mangle] - pub static mut outputbuf: *mut crate::squeezelite_h::buffer; + fn dlopen(__file: *const libc::c_char, __mode: libc::c_int) + -> *mut libc::c_void; #[no_mangle] - pub static mut stream: crate::squeezelite_h::streamstate; + fn dlsym(__handle: *mut libc::c_void, __name: *const libc::c_char) + -> *mut libc::c_void; #[no_mangle] - pub static mut output: crate::squeezelite_h::outputstate; + fn dlerror() -> *mut libc::c_char; #[no_mangle] - pub static mut decode: crate::squeezelite_h::decodestate; + fn pthread_mutex_lock(__mutex: *mut pthread_mutex_t) -> libc::c_int; + #[no_mangle] + fn pthread_mutex_unlock(__mutex: *mut pthread_mutex_t) -> libc::c_int; + #[no_mangle] + fn logtime() -> *const libc::c_char; + #[no_mangle] + fn logprint(fmt: *const libc::c_char, _: ...); + #[no_mangle] + fn _buf_used(buf: *mut buffer) -> libc::c_uint; + #[no_mangle] + fn _buf_space(buf: *mut buffer) -> libc::c_uint; + #[no_mangle] + fn _buf_cont_read(buf: *mut buffer) -> libc::c_uint; + #[no_mangle] + fn _buf_cont_write(buf: *mut buffer) -> libc::c_uint; + #[no_mangle] + fn _buf_inc_readp(buf: *mut buffer, by: libc::c_uint); + #[no_mangle] + fn _buf_inc_writep(buf: *mut buffer, by: libc::c_uint); + #[no_mangle] + fn decode_newstream(sample_rate: libc::c_uint, + supported_rates: *mut libc::c_uint) -> libc::c_uint; + #[no_mangle] + static mut loglevel: log_level; + #[no_mangle] + static mut streambuf: *mut buffer; + #[no_mangle] + static mut outputbuf: *mut buffer; + #[no_mangle] + static mut stream: streamstate; + #[no_mangle] + static mut output: outputstate; + #[no_mangle] + static mut decode: decodestate; } - -#[repr(C)] +pub type size_t = libc::c_ulong; +pub type __uint8_t = libc::c_uchar; +pub type __int16_t = libc::c_short; +pub type __int32_t = libc::c_int; +pub type __uint32_t = libc::c_uint; +pub type __uint64_t = libc::c_ulong; +pub type int16_t = __int16_t; +pub type int32_t = __int32_t; +pub type u_int8_t = __uint8_t; +pub type u_int32_t = __uint32_t; +pub type u_int64_t = __uint64_t; #[derive(Copy, Clone)] +#[repr(C)] +pub struct __pthread_internal_list { + pub __prev: *mut __pthread_internal_list, + pub __next: *mut __pthread_internal_list, +} +pub type __pthread_list_t = __pthread_internal_list; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct __pthread_mutex_s { + pub __lock: libc::c_int, + pub __count: libc::c_uint, + pub __owner: libc::c_int, + pub __nusers: libc::c_uint, + pub __kind: libc::c_int, + pub __spins: libc::c_short, + pub __elision: libc::c_short, + pub __list: __pthread_list_t, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub union pthread_mutex_t { + pub __data: __pthread_mutex_s, + pub __size: [libc::c_char; 40], + pub __align: libc::c_long, +} +pub type u8_t = u_int8_t; +pub type u32_t = u_int32_t; +pub type u64_t = u_int64_t; +pub type s16_t = int16_t; +pub type s32_t = int32_t; +pub type frames_t = u32_t; +pub type log_level = libc::c_uint; +pub const lSDEBUG: log_level = 4; +pub const lDEBUG: log_level = 3; +pub const lINFO: log_level = 2; +pub const lWARN: log_level = 1; +pub const lERROR: log_level = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct buffer { + pub buf: *mut u8_t, + pub readp: *mut u8_t, + pub writep: *mut u8_t, + pub wrap: *mut u8_t, + pub size: size_t, + pub base_size: size_t, + pub mutex: pthread_mutex_t, +} +pub type stream_state = libc::c_uint; +pub const RECV_HEADERS: stream_state = 7; +pub const SEND_HEADERS: stream_state = 6; +pub const STREAMING_HTTP: stream_state = 5; +pub const STREAMING_FILE: stream_state = 4; +pub const STREAMING_BUFFERING: stream_state = 3; +pub const STREAMING_WAIT: stream_state = 2; +pub const DISCONNECT: stream_state = 1; +pub const STOPPED: stream_state = 0; +pub type disconnect_code = libc::c_uint; +pub const TIMEOUT: disconnect_code = 4; +pub const UNREACHABLE: disconnect_code = 3; +pub const REMOTE_DISCONNECT: disconnect_code = 2; +pub const LOCAL_DISCONNECT: disconnect_code = 1; +pub const DISCONNECT_OK: disconnect_code = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct streamstate { + pub state: stream_state, + pub disconnect: disconnect_code, + pub header: *mut libc::c_char, + pub header_len: size_t, + pub sent_headers: bool, + pub cont_wait: bool, + pub bytes: u64_t, + pub threshold: libc::c_uint, + pub meta_interval: u32_t, + pub meta_next: u32_t, + pub meta_left: u32_t, + pub meta_send: bool, +} +pub type decode_state = libc::c_uint; +pub const DECODE_ERROR: decode_state = 4; +pub const DECODE_COMPLETE: decode_state = 3; +pub const DECODE_RUNNING: decode_state = 2; +pub const DECODE_READY: decode_state = 1; +pub const DECODE_STOPPED: decode_state = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct decodestate { + pub state: decode_state, + pub new_stream: bool, + pub mutex: pthread_mutex_t, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct codec { + pub id: libc::c_char, + pub types: *mut libc::c_char, + pub min_read_bytes: libc::c_uint, + pub min_space: libc::c_uint, + pub open: Option ()>, + pub close: Option ()>, + pub decode: Option decode_state>, +} +pub type output_state = libc::c_int; +pub const OUTPUT_START_AT: output_state = 5; +pub const OUTPUT_SKIP_FRAMES: output_state = 4; +pub const OUTPUT_PAUSE_FRAMES: output_state = 3; +pub const OUTPUT_RUNNING: output_state = 2; +pub const OUTPUT_BUFFER: output_state = 1; +pub const OUTPUT_STOPPED: output_state = 0; +pub const OUTPUT_OFF: output_state = -1; +pub type output_format = libc::c_uint; +pub const S16_LE: output_format = 3; +pub const S24_3LE: output_format = 2; +pub const S24_LE: output_format = 1; +pub const S32_LE: output_format = 0; +pub type fade_state = libc::c_uint; +pub const FADE_ACTIVE: fade_state = 2; +pub const FADE_DUE: fade_state = 1; +pub const FADE_INACTIVE: fade_state = 0; +pub type fade_dir = libc::c_uint; +pub const FADE_CROSS: fade_dir = 3; +pub const FADE_DOWN: fade_dir = 2; +pub const FADE_UP: fade_dir = 1; +pub type fade_mode = libc::c_uint; +pub const FADE_INOUT: fade_mode = 4; +pub const FADE_OUT: fade_mode = 3; +pub const FADE_IN: fade_mode = 2; +pub const FADE_CROSSFADE: fade_mode = 1; +pub const FADE_NONE: fade_mode = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct outputstate { + pub state: output_state, + pub format: output_format, + pub device: *const libc::c_char, + pub buffer: libc::c_uint, + pub period: libc::c_uint, + pub track_started: bool, + pub write_cb: Option libc::c_int>, + pub start_frames: libc::c_uint, + pub frames_played: libc::c_uint, + pub frames_played_dmp: libc::c_uint, + pub current_sample_rate: libc::c_uint, + pub supported_rates: [libc::c_uint; 18], + pub default_sample_rate: libc::c_uint, + pub error_opening: bool, + pub device_frames: libc::c_uint, + pub updated: u32_t, + pub track_start_time: u32_t, + pub current_replay_gain: u32_t, + pub c2rust_unnamed: C2RustUnnamed, + pub next_sample_rate: libc::c_uint, + pub track_start: *mut u8_t, + pub gainL: u32_t, + pub gainR: u32_t, + pub invert: bool, + pub next_replay_gain: u32_t, + pub threshold: libc::c_uint, + pub fade: fade_state, + pub fade_start: *mut u8_t, + pub fade_end: *mut u8_t, + pub fade_dir: fade_dir, + pub fade_mode: fade_mode, + pub fade_secs: libc::c_uint, + pub rate_delay: libc::c_uint, + pub delay_active: bool, + pub stop_time: u32_t, + pub idle_to: u32_t, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub union C2RustUnnamed { + pub pause_frames: u32_t, + pub skip_frames: u32_t, + pub start_at: u32_t, +} +pub const MPG123_ERR: mpg123_errors = -1; +pub const MPG123_DONE: mpg123_errors = -12; +#[derive(Copy, Clone)] +#[repr(C)] pub struct mpg { - pub h: *mut crate::stdlib::mpg123_handle, + pub h: *mut mpg123_handle, pub use16bit: bool, pub mpg123_init: Option libc::c_int>, - pub mpg123_feature: - Option 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 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 ()>, - pub mpg123_open_feed: - Option 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 *const libc::c_char>, + pub mpg123_feature: Option libc::c_int>, + pub mpg123_rates: Option ()>, + pub mpg123_format_none: Option libc::c_int>, + pub mpg123_format: Option libc::c_int>, + pub mpg123_new: Option *mut mpg123_handle>, + pub mpg123_delete: Option ()>, + pub mpg123_open_feed: Option libc::c_int>, + pub mpg123_decode: Option libc::c_int>, + pub mpg123_getformat: Option libc::c_int>, + pub mpg123_plain_strerror: Option *const libc::c_char>, } - +pub type mpg123_handle = mpg123_handle_struct; +pub type mpg123_feature_set = libc::c_uint; +pub const MPG123_FEATURE_EQUALIZER: mpg123_feature_set = 14; +pub const MPG123_FEATURE_TIMEOUT_READ: mpg123_feature_set = 13; +pub const MPG123_FEATURE_PARSE_ICY: mpg123_feature_set = 12; +pub const MPG123_FEATURE_DECODE_NTOM: mpg123_feature_set = 11; +pub const MPG123_FEATURE_DECODE_DOWNSAMPLE: mpg123_feature_set = 10; +pub const MPG123_FEATURE_DECODE_ACCURATE: mpg123_feature_set = 9; +pub const MPG123_FEATURE_DECODE_LAYER3: mpg123_feature_set = 8; +pub const MPG123_FEATURE_DECODE_LAYER2: mpg123_feature_set = 7; +pub const MPG123_FEATURE_DECODE_LAYER1: mpg123_feature_set = 6; +pub const MPG123_FEATURE_PARSE_ID3V2: mpg123_feature_set = 5; +pub const MPG123_FEATURE_INDEX: mpg123_feature_set = 4; +pub const MPG123_FEATURE_OUTPUT_32BIT: mpg123_feature_set = 3; +pub const MPG123_FEATURE_OUTPUT_16BIT: mpg123_feature_set = 2; +pub const MPG123_FEATURE_OUTPUT_8BIT: mpg123_feature_set = 1; +pub const MPG123_FEATURE_ABI_UTF8OPEN: mpg123_feature_set = 0; +pub const MPG123_NEW_FORMAT: mpg123_errors = -11; +pub const MPG123_ENC_SIGNED_32: mpg123_enc_enum = 4480; +pub const MPG123_ENC_SIGNED_16: mpg123_enc_enum = 208; +pub type mpg123_enc_enum = libc::c_uint; +pub const MPG123_ENC_ANY: mpg123_enc_enum = 30719; +pub const MPG123_ENC_FLOAT_64: mpg123_enc_enum = 1024; +pub const MPG123_ENC_FLOAT_32: mpg123_enc_enum = 512; +pub const MPG123_ENC_UNSIGNED_24: mpg123_enc_enum = 24576; +pub const MPG123_ENC_SIGNED_24: mpg123_enc_enum = 20608; +pub const MPG123_ENC_UNSIGNED_32: mpg123_enc_enum = 8448; +pub const MPG123_ENC_ALAW_8: mpg123_enc_enum = 8; +pub const MPG123_ENC_ULAW_8: mpg123_enc_enum = 4; +pub const MPG123_ENC_SIGNED_8: mpg123_enc_enum = 130; +pub const MPG123_ENC_UNSIGNED_8: mpg123_enc_enum = 1; +pub const MPG123_ENC_UNSIGNED_16: mpg123_enc_enum = 96; +pub const MPG123_ENC_FLOAT: mpg123_enc_enum = 3584; +pub const MPG123_ENC_SIGNED: mpg123_enc_enum = 128; +pub const MPG123_ENC_32: mpg123_enc_enum = 256; +pub const MPG123_ENC_24: mpg123_enc_enum = 16384; +pub const MPG123_ENC_16: mpg123_enc_enum = 64; +pub const MPG123_ENC_8: mpg123_enc_enum = 15; +pub type mpg123_errors = libc::c_int; +pub const MPG123_INT_OVERFLOW: mpg123_errors = 43; +pub const MPG123_LFS_OVERFLOW: mpg123_errors = 42; +pub const MPG123_BAD_CUSTOM_IO: mpg123_errors = 41; +pub const MPG123_LSEEK_FAILED: mpg123_errors = 40; +pub const MPG123_BAD_VALUE: mpg123_errors = 39; +pub const MPG123_MISSING_FEATURE: mpg123_errors = 38; +pub const MPG123_BAD_DECODER_SETUP: mpg123_errors = 37; +pub const MPG123_INDEX_FAIL: mpg123_errors = 36; +pub const MPG123_NO_INDEX: mpg123_errors = 35; +pub const MPG123_BAD_KEY: mpg123_errors = 34; +pub const MPG123_NULL_POINTER: mpg123_errors = 33; +pub const MPG123_NO_RELSEEK: mpg123_errors = 32; +pub const MPG123_NULL_BUFFER: mpg123_errors = 31; +pub const MPG123_BAD_ALIGN: mpg123_errors = 30; +pub const MPG123_NO_8BIT: mpg123_errors = 29; +pub const MPG123_RESYNC_FAIL: mpg123_errors = 28; +pub const MPG123_OUT_OF_SYNC: mpg123_errors = 27; +pub const MPG123_BAD_INDEX_PAR: mpg123_errors = 26; +pub const MPG123_BAD_PARS: mpg123_errors = 25; +pub const MPG123_NO_READER: mpg123_errors = 24; +pub const MPG123_NO_SEEK: mpg123_errors = 23; +pub const MPG123_BAD_FILE: mpg123_errors = 22; +pub const MPG123_NO_TIMEOUT: mpg123_errors = 21; +pub const MPG123_BAD_WHENCE: mpg123_errors = 20; +pub const MPG123_NO_SEEK_FROM_END: mpg123_errors = 19; +pub const MPG123_ERR_READER: mpg123_errors = 18; +pub const MPG123_ERR_NULL: mpg123_errors = 17; +pub const MPG123_BAD_BAND: mpg123_errors = 16; +pub const MPG123_BAD_TYPES: mpg123_errors = 15; +pub const MPG123_NO_SPACE: mpg123_errors = 14; +pub const MPG123_NO_GAPLESS: mpg123_errors = 13; +pub const MPG123_BAD_RVA: mpg123_errors = 12; +pub const MPG123_NO_BUFFERS: mpg123_errors = 11; +pub const MPG123_BAD_HANDLE: mpg123_errors = 10; +pub const MPG123_BAD_DECODER: mpg123_errors = 9; +pub const MPG123_NOT_INITIALIZED: mpg123_errors = 8; +pub const MPG123_OUT_OF_MEM: mpg123_errors = 7; +pub const MPG123_BAD_BUFFER: mpg123_errors = 6; +pub const MPG123_BAD_PARAM: mpg123_errors = 5; +pub const MPG123_ERR_16TO8TABLE: mpg123_errors = 4; +pub const MPG123_BAD_RATE: mpg123_errors = 3; +pub const MPG123_BAD_CHANNEL: mpg123_errors = 2; +pub const MPG123_BAD_OUTFORMAT: mpg123_errors = 1; +pub const MPG123_OK: mpg123_errors = 0; +pub const MPG123_NEED_MORE: mpg123_errors = -10; static mut m: *mut mpg = 0 as *const mpg as *mut mpg; - -unsafe extern "C" fn mpg_decode() -> 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; +unsafe extern "C" fn mpg_decode() -> decode_state { + let mut bytes: size_t = 0; + let mut space: size_t = 0; + let mut size: size_t = 0; let mut ret: libc::c_int = 0; - let mut write_buf = 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; + let mut write_buf: *mut u8_t = 0 as *mut u8_t; + pthread_mutex_lock(&mut (*streambuf).mutex); + pthread_mutex_lock(&mut (*outputbuf).mutex); + bytes = + if _buf_used(streambuf) < _buf_cont_read(streambuf) { + _buf_used(streambuf) + } else { _buf_cont_read(streambuf) } as size_t; + space = + if _buf_space(outputbuf) < _buf_cont_write(outputbuf) { + _buf_space(outputbuf) + } else { _buf_cont_write(outputbuf) } as size_t; write_buf = (*outputbuf).writep; - bytes = if bytes < 512 as libc::c_int as libc::c_ulong { - bytes - } else { - 512 as libc::c_int as libc::c_ulong - }; - space = if space < (32 as libc::c_int * 1024 as libc::c_int) as libc::c_ulong { - space - } else { - (32 as libc::c_int * 1024 as libc::c_int) as libc::c_ulong - }; + 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) + 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 { space = 0 as libc::c_int as size_t } + ret = + (*m).mpg123_decode.expect("non-null function pointer")((*m).h, + (*streambuf).readp, + bytes, + write_buf, + space, + &mut size); + if ret == MPG123_NEW_FORMAT as libc::c_int { if decode.new_stream { let mut rate: libc::c_long = 0; let mut channels: libc::c_int = 0; let mut enc: libc::c_int = 0; - (*m).mpg123_getformat.expect("non-null function pointer")( - (*m).h, - &mut rate, - &mut channels, - &mut enc, - ); - if loglevel as libc::c_uint - >= 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, - ); + (*m).mpg123_getformat.expect("non-null function pointer")((*m).h, + &mut rate, + &mut channels, + &mut enc); + if loglevel as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d setting track_start\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 11], + &[libc::c_char; 11]>(b"mpg_decode\x00")).as_ptr(), + 125 as libc::c_int); } - output.next_sample_rate = crate::src::decode::decode_newstream( - rate as libc::c_uint, - output.supported_rates.as_mut_ptr(), - ); + output.next_sample_rate = + decode_newstream(rate as libc::c_uint, + output.supported_rates.as_mut_ptr()); output.track_start = (*outputbuf).writep; if output.fade_mode as u64 != 0 { - crate::src::output::_checkfade(1 as libc::c_int != 0); + _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, - ); + } else if loglevel as libc::c_uint >= + lWARN as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d format change mid stream - not supported\n\x00" + as *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 11], + &[libc::c_char; 11]>(b"mpg_decode\x00")).as_ptr(), + 135 as libc::c_int); } } // expand 16bit output to 32bit samples if (*m).use16bit { - let mut iptr = 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); + let mut iptr: *mut s16_t = 0 as *mut s16_t; + let mut optr: *mut s32_t = 0 as *mut s32_t; + let mut count: size_t = + size.wrapping_div(2 as libc::c_int as libc::c_ulong); size = count.wrapping_mul(4 as libc::c_int as libc::c_ulong); - iptr = (write_buf as *mut crate::squeezelite_h::s16_t).offset(count as isize); - optr = (write_buf as *mut crate::squeezelite_h::s32_t).offset(count as isize); - loop { + iptr = (write_buf as *mut s16_t).offset(count as isize); + optr = (write_buf as *mut s32_t).offset(count as isize); + loop { let fresh0 = count; count = count.wrapping_sub(1); - if !(fresh0 != 0) { - break; - } + 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), - ); + _buf_inc_readp(streambuf, bytes as libc::c_uint); + _buf_inc_writep(outputbuf, size as libc::c_uint); + pthread_mutex_unlock(&mut (*outputbuf).mutex); + if loglevel as libc::c_uint >= lSDEBUG as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d write %u frames\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 11], + &[libc::c_char; 11]>(b"mpg_decode\x00")).as_ptr(), + 163 as libc::c_int, + size.wrapping_div(8 as libc::c_int as libc::c_ulong)); } - if ret == 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, - ); + if ret == MPG123_DONE as libc::c_int || + bytes == 0 as libc::c_int as libc::c_ulong && + size == 0 as libc::c_int as libc::c_ulong && + stream.state as libc::c_uint <= + DISCONNECT as libc::c_int as libc::c_uint { + pthread_mutex_unlock(&mut (*streambuf).mutex); + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d stream complete\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 11], + &[libc::c_char; 11]>(b"mpg_decode\x00")).as_ptr(), + 167 as libc::c_int); } - return crate::squeezelite_h::DECODE_COMPLETE; + return 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, - ); + pthread_mutex_unlock(&mut (*streambuf).mutex); + if ret == MPG123_ERR as libc::c_int { + if loglevel as libc::c_uint >= lWARN as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d Error\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 11], + &[libc::c_char; 11]>(b"mpg_decode\x00")).as_ptr(), + 174 as libc::c_int); } - return crate::squeezelite_h::DECODE_COMPLETE; + return DECODE_COMPLETE } // OK and NEED_MORE keep running - return crate::squeezelite_h::DECODE_RUNNING; + return 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, -) { +unsafe extern "C" fn mpg_open(mut size: u8_t, mut rate: u8_t, mut chan: u8_t, + mut endianness: u8_t) { let mut err: libc::c_int = 0; - let mut list = 0 as *const libc::c_long; - let mut count: crate::stddef_h::size_t = 0; - let mut i: crate::stddef_h::size_t = 0; + let mut list: *const libc::c_long = 0 as *const libc::c_long; + let mut count: size_t = 0; + let mut i: size_t = 0; if !(*m).h.is_null() { (*m).mpg123_delete.expect("non-null function pointer")((*m).h); } (*m).h = - (*m).mpg123_new.expect("non-null function pointer")(0 as *const libc::c_char, &mut err); + (*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), - ); + if loglevel as libc::c_uint >= lWARN as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d new error: %s\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 9], + &[libc::c_char; 9]>(b"mpg_open\x00")).as_ptr(), + 194 as libc::c_int, + (*m).mpg123_plain_strerror.expect("non-null function pointer")(err)); } } // restrict output to 32bit or 16bit signed 2 channel based on library capability - (*m).mpg123_rates.expect("non-null function pointer")(&mut list, &mut count); + (*m).mpg123_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; + i = 0 as libc::c_int as size_t; while i < count { - (*m).mpg123_format.expect("non-null function pointer")( - (*m).h, - *list.offset(i as isize), - 2 as libc::c_int, - if (*m).use16bit as libc::c_int != 0 { - crate::stdlib::MPG123_ENC_SIGNED_16 as libc::c_int - } else { - crate::stdlib::MPG123_ENC_SIGNED_32 as libc::c_int - }, - ); + (*m).mpg123_format.expect("non-null function pointer")((*m).h, + *list.offset(i + as + isize), + 2 as + libc::c_int, + if (*m).use16bit + as + libc::c_int + != 0 { + MPG123_ENC_SIGNED_16 + as + libc::c_int + } else { + MPG123_ENC_SIGNED_32 + as + libc::c_int + }); i = i.wrapping_add(1) } err = (*m).mpg123_open_feed.expect("non-null function pointer")((*m).h); if err != 0 { - if loglevel as libc::c_uint >= 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), - ); + if loglevel as libc::c_uint >= lWARN as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d open feed error: %s\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 9], + &[libc::c_char; 9]>(b"mpg_open\x00")).as_ptr(), + 207 as libc::c_int, + (*m).mpg123_plain_strerror.expect("non-null function pointer")(err)); } }; } - unsafe extern "C" fn mpg_close() { (*m).mpg123_delete.expect("non-null function pointer")((*m).h); - (*m).h = 0 as *mut crate::stdlib::mpg123_handle; + (*m).h = 0 as *mut 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; + let mut handle: *mut libc::c_void = + dlopen(b"libmpg123.so.0\x00" as *const u8 as *const libc::c_char, + 0x2 as libc::c_int); + let mut err: *mut libc::c_char = 0 as *mut libc::c_char; if handle.is_null() { - if loglevel as libc::c_uint >= 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(), - ); + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d dlerror: %s\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 9], + &[libc::c_char; 9]>(b"load_mpg\x00")).as_ptr(), + 222 as libc::c_int, dlerror()); } - return 0 as libc::c_int != 0; + return 0 as libc::c_int != 0 } - (*m).mpg123_init = ::std::mem::transmute::< - *mut libc::c_void, - Option 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 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 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 ()>, - >(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 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 *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(); + (*m).mpg123_init = + ::std::mem::transmute::<*mut libc::c_void, + Option + libc::c_int>>(dlsym(handle, + b"mpg123_init\x00" + as + *const u8 + as + *const libc::c_char)); + (*m).mpg123_feature = + ::std::mem::transmute::<*mut libc::c_void, + Option + libc::c_int>>(dlsym(handle, + b"mpg123_feature\x00" + as + *const u8 + as + *const libc::c_char)); + (*m).mpg123_rates = + ::std::mem::transmute::<*mut libc::c_void, + Option + ()>>(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 + libc::c_int>>(dlsym(handle, + b"mpg123_format_none\x00" + as + *const u8 + as + *const libc::c_char)); + (*m).mpg123_format = + ::std::mem::transmute::<*mut libc::c_void, + Option + libc::c_int>>(dlsym(handle, + b"mpg123_format\x00" + as + *const u8 + as + *const libc::c_char)); + (*m).mpg123_new = + ::std::mem::transmute::<*mut libc::c_void, + Option + *mut mpg123_handle>>(dlsym(handle, + b"mpg123_new\x00" + as + *const u8 + as + *const libc::c_char)); + (*m).mpg123_delete = + ::std::mem::transmute::<*mut libc::c_void, + Option + ()>>(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 + libc::c_int>>(dlsym(handle, + b"mpg123_open_feed\x00" + as + *const u8 + as + *const libc::c_char)); + (*m).mpg123_decode = + ::std::mem::transmute::<*mut libc::c_void, + Option + libc::c_int>>(dlsym(handle, + b"mpg123_decode\x00" + as + *const u8 + as + *const libc::c_char)); + (*m).mpg123_getformat = + ::std::mem::transmute::<*mut libc::c_void, + Option + libc::c_int>>(dlsym(handle, + b"mpg123_getformat\x00" + as + *const u8 + as + *const libc::c_char)); + (*m).mpg123_plain_strerror = + ::std::mem::transmute::<*mut libc::c_void, + Option + *const libc::c_char>>(dlsym(handle, + b"mpg123_plain_strerror\x00" + as + *const u8 + as + *const libc::c_char)); + err = dlerror(); if !err.is_null() { - if loglevel as libc::c_uint >= 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, - ); + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d dlerror: %s\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 9], + &[libc::c_char; 9]>(b"load_mpg\x00")).as_ptr(), + 239 as libc::c_int, err); } - return 0 as libc::c_int != 0; + 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, - ); + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d loaded libmpg123.so.0\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 9], + &[libc::c_char; 9]>(b"load_mpg\x00")).as_ptr(), + 243 as libc::c_int); } return 1 as libc::c_int != 0; } -/* +/* * Squeezelite - lightweight headless squeezebox emulator * * (c) Adrian Smith 2012-2015, triode1@btinternet.com * Ralph Irving 2015-2017, ralph_irving@hotmail.com - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the @@ -691,52 +797,47 @@ unsafe extern "C" fn load_mpg() -> bool { // 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::() 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; - } +pub unsafe extern "C" fn register_mpg() -> *mut codec { + static mut ret: codec = + unsafe { + { + let mut init = + codec{id: 'm' as i32 as libc::c_char, + types: + b"mp3\x00" as *const u8 as *const libc::c_char + as *mut libc::c_char, + min_read_bytes: 512 as libc::c_int as libc::c_uint, + min_space: + (32 as libc::c_int * 1024 as libc::c_int) as + libc::c_uint, + open: + Some(mpg_open as + unsafe extern "C" fn(_: u8_t, _: u8_t, + _: u8_t, _: u8_t) + -> ()), + close: + Some(mpg_close as unsafe extern "C" fn() -> ()), + decode: + Some(mpg_decode as + unsafe extern "C" fn() + -> decode_state),}; + init + } + }; + m = malloc(::std::mem::size_of::() as libc::c_ulong) as *mut mpg; + if m.is_null() { return 0 as *mut codec } + (*m).h = 0 as *mut mpg123_handle; + if !load_mpg() { return 0 as *mut codec } (*m).mpg123_init.expect("non-null function pointer")(); - (*m).use16bit = (*m).mpg123_feature.expect("non-null function pointer")( - 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, - ); + (*m).use16bit = + (*m).mpg123_feature.expect("non-null function pointer")(MPG123_FEATURE_OUTPUT_32BIT) + != 0; + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d using mpg to decode mp3\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 13], + &[libc::c_char; 13]>(b"register_mpg\x00")).as_ptr(), + 275 as libc::c_int); } return &mut ret; } diff --git a/src/output.rs b/src/output.rs index 099636e..f275a8f 100644 --- a/src/output.rs +++ b/src/output.rs @@ -1,82 +1,188 @@ 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::__uint8_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::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::gain; -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::to_gain; -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::buffer::_buf_cont_read; -pub use crate::src::buffer::_buf_inc_readp; -pub use crate::src::buffer::_buf_resize; -pub use crate::src::buffer::buf_destroy; -pub use crate::src::buffer::buf_flush; -pub use crate::src::buffer::buf_init; -pub use crate::src::output_alsa::test_open; -pub use crate::src::slimproto::wake_controller; -pub use crate::src::utils::gettime_ms; -pub use crate::src::utils::logprint; -pub use crate::src::utils::logtime; -pub use crate::src::utils::touch_memory; -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; -use crate::stdlib::sprintf; -pub use crate::stdlib::u_int32_t; -pub use crate::stdlib::u_int8_t; - -use crate::stdlib::exit; -use crate::stdlib::free; -use crate::stdlib::malloc; -use crate::stdlib::memset; -use crate::stdlib::pthread_mutex_lock; -use crate::stdlib::pthread_mutex_unlock; -use crate::stdlib::strcat; -/* +extern "C" { + #[no_mangle] + fn sprintf(_: *mut libc::c_char, _: *const libc::c_char, _: ...) + -> libc::c_int; + #[no_mangle] + fn malloc(_: libc::c_ulong) -> *mut libc::c_void; + #[no_mangle] + fn free(__ptr: *mut libc::c_void); + #[no_mangle] + fn exit(_: libc::c_int) -> !; + #[no_mangle] + fn memset(_: *mut libc::c_void, _: libc::c_int, _: libc::c_ulong) + -> *mut libc::c_void; + #[no_mangle] + fn strcat(_: *mut libc::c_char, _: *const libc::c_char) + -> *mut libc::c_char; + #[no_mangle] + fn pthread_mutex_lock(__mutex: *mut pthread_mutex_t) -> libc::c_int; + #[no_mangle] + fn pthread_mutex_unlock(__mutex: *mut pthread_mutex_t) -> libc::c_int; + #[no_mangle] + fn logtime() -> *const libc::c_char; + #[no_mangle] + fn logprint(fmt: *const libc::c_char, _: ...); + #[no_mangle] + fn gettime_ms() -> u32_t; + #[no_mangle] + fn touch_memory(buf_0: *mut u8_t, size: size_t); + #[no_mangle] + fn _buf_used(buf_0: *mut buffer) -> libc::c_uint; + #[no_mangle] + fn _buf_cont_read(buf_0: *mut buffer) -> libc::c_uint; + #[no_mangle] + fn _buf_inc_readp(buf_0: *mut buffer, by: libc::c_uint); + #[no_mangle] + fn buf_flush(buf_0: *mut buffer); + #[no_mangle] + fn _buf_resize(buf_0: *mut buffer, size: size_t); + #[no_mangle] + fn buf_init(buf_0: *mut buffer, size: size_t); + #[no_mangle] + fn buf_destroy(buf_0: *mut buffer); + #[no_mangle] + fn wake_controller(); + #[no_mangle] + fn test_open(device: *const libc::c_char, rates: *mut libc::c_uint, + userdef_rates: bool) -> bool; + #[no_mangle] + fn gain(gain_0: s32_t, sample: s32_t) -> s32_t; + #[no_mangle] + fn to_gain(f: libc::c_float) -> s32_t; +} +pub type size_t = libc::c_ulong; +pub type __uint8_t = libc::c_uchar; +pub type __int32_t = libc::c_int; +pub type __uint32_t = libc::c_uint; +pub type int32_t = __int32_t; +pub type u_int8_t = __uint8_t; +pub type u_int32_t = __uint32_t; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct __pthread_internal_list { + pub __prev: *mut __pthread_internal_list, + pub __next: *mut __pthread_internal_list, +} +pub type __pthread_list_t = __pthread_internal_list; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct __pthread_mutex_s { + pub __lock: libc::c_int, + pub __count: libc::c_uint, + pub __owner: libc::c_int, + pub __nusers: libc::c_uint, + pub __kind: libc::c_int, + pub __spins: libc::c_short, + pub __elision: libc::c_short, + pub __list: __pthread_list_t, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub union pthread_mutex_t { + pub __data: __pthread_mutex_s, + pub __size: [libc::c_char; 40], + pub __align: libc::c_long, +} +pub type u8_t = u_int8_t; +pub type u32_t = u_int32_t; +pub type s32_t = int32_t; +pub type frames_t = u32_t; +pub type log_level = libc::c_uint; +pub const lSDEBUG: log_level = 4; +pub const lDEBUG: log_level = 3; +pub const lINFO: log_level = 2; +pub const lWARN: log_level = 1; +pub const lERROR: log_level = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct buffer { + pub buf: *mut u8_t, + pub readp: *mut u8_t, + pub writep: *mut u8_t, + pub wrap: *mut u8_t, + pub size: size_t, + pub base_size: size_t, + pub mutex: pthread_mutex_t, +} +pub type output_state = libc::c_int; +pub const OUTPUT_START_AT: output_state = 5; +pub const OUTPUT_SKIP_FRAMES: output_state = 4; +pub const OUTPUT_PAUSE_FRAMES: output_state = 3; +pub const OUTPUT_RUNNING: output_state = 2; +pub const OUTPUT_BUFFER: output_state = 1; +pub const OUTPUT_STOPPED: output_state = 0; +pub const OUTPUT_OFF: output_state = -1; +pub type output_format = libc::c_uint; +pub const S16_LE: output_format = 3; +pub const S24_3LE: output_format = 2; +pub const S24_LE: output_format = 1; +pub const S32_LE: output_format = 0; +pub type fade_state = libc::c_uint; +pub const FADE_ACTIVE: fade_state = 2; +pub const FADE_DUE: fade_state = 1; +pub const FADE_INACTIVE: fade_state = 0; +pub type fade_dir = libc::c_uint; +pub const FADE_CROSS: fade_dir = 3; +pub const FADE_DOWN: fade_dir = 2; +pub const FADE_UP: fade_dir = 1; +pub type fade_mode = libc::c_uint; +pub const FADE_INOUT: fade_mode = 4; +pub const FADE_OUT: fade_mode = 3; +pub const FADE_IN: fade_mode = 2; +pub const FADE_CROSSFADE: fade_mode = 1; +pub const FADE_NONE: fade_mode = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct outputstate { + pub state: output_state, + pub format: output_format, + pub device: *const libc::c_char, + pub buffer: libc::c_uint, + pub period: libc::c_uint, + pub track_started: bool, + pub write_cb: Option libc::c_int>, + pub start_frames: libc::c_uint, + pub frames_played: libc::c_uint, + pub frames_played_dmp: libc::c_uint, + pub current_sample_rate: libc::c_uint, + pub supported_rates: [libc::c_uint; 18], + pub default_sample_rate: libc::c_uint, + pub error_opening: bool, + pub device_frames: libc::c_uint, + pub updated: u32_t, + pub track_start_time: u32_t, + pub current_replay_gain: u32_t, + pub c2rust_unnamed: C2RustUnnamed, + pub next_sample_rate: libc::c_uint, + pub track_start: *mut u8_t, + pub gainL: u32_t, + pub gainR: u32_t, + pub invert: bool, + pub next_replay_gain: u32_t, + pub threshold: libc::c_uint, + pub fade: fade_state, + pub fade_start: *mut u8_t, + pub fade_end: *mut u8_t, + pub fade_dir: fade_dir, + pub fade_mode: fade_mode, + pub fade_secs: libc::c_uint, + pub rate_delay: libc::c_uint, + pub delay_active: bool, + pub stop_time: u32_t, + pub idle_to: u32_t, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub union C2RustUnnamed { + pub pause_frames: u32_t, + pub skip_frames: u32_t, + pub start_at: u32_t, +} +/* * Squeezelite - lightweight headless squeezebox emulator * * (c) Adrian Smith 2012-2015, triode1@btinternet.com @@ -86,7 +192,7 @@ use crate::stdlib::strcat; * 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 @@ -97,926 +203,809 @@ use crate::stdlib::strcat; * */ // Common output function - -static mut loglevel: crate::squeezelite_h::log_level = crate::squeezelite_h::lERROR; +static mut loglevel: log_level = lERROR; #[no_mangle] - -pub static mut output: crate::squeezelite_h::outputstate = crate::squeezelite_h::outputstate { - state: crate::squeezelite_h::OUTPUT_STOPPED, - format: crate::squeezelite_h::S32_LE, - device: 0 as *const libc::c_char, - buffer: 0, - period: 0, - track_started: false, - write_cb: None, - start_frames: 0, - frames_played: 0, - frames_played_dmp: 0, - current_sample_rate: 0, - supported_rates: [0; 18], - default_sample_rate: 0, - error_opening: false, - device_frames: 0, - updated: 0, - track_start_time: 0, - current_replay_gain: 0, - c2rust_unnamed: crate::squeezelite_h::C2RustUnnamed_1 { pause_frames: 0 }, - next_sample_rate: 0, - track_start: 0 as *const crate::squeezelite_h::u8_t as *mut crate::squeezelite_h::u8_t, - gainL: 0, - gainR: 0, - invert: false, - next_replay_gain: 0, - threshold: 0, - fade: crate::squeezelite_h::FADE_INACTIVE, - fade_start: 0 as *const crate::squeezelite_h::u8_t as *mut crate::squeezelite_h::u8_t, - fade_end: 0 as *const crate::squeezelite_h::u8_t as *mut crate::squeezelite_h::u8_t, - fade_dir: 0 as crate::squeezelite_h::fade_dir, - fade_mode: crate::squeezelite_h::FADE_NONE, - fade_secs: 0, - rate_delay: 0, - delay_active: false, - stop_time: 0, - idle_to: 0, -}; - -static mut buf: crate::squeezelite_h::buffer = crate::squeezelite_h::buffer { - buf: 0 as *const crate::squeezelite_h::u8_t as *mut crate::squeezelite_h::u8_t, - readp: 0 as *const crate::squeezelite_h::u8_t as *mut crate::squeezelite_h::u8_t, - writep: 0 as *const crate::squeezelite_h::u8_t as *mut crate::squeezelite_h::u8_t, - wrap: 0 as *const crate::squeezelite_h::u8_t as *mut crate::squeezelite_h::u8_t, - size: 0, - base_size: 0, - 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, - }, - }, - }, -}; +pub static mut output: outputstate = + outputstate{state: OUTPUT_STOPPED, + format: S32_LE, + device: 0 as *const libc::c_char, + buffer: 0, + period: 0, + track_started: false, + write_cb: None, + start_frames: 0, + frames_played: 0, + frames_played_dmp: 0, + current_sample_rate: 0, + supported_rates: [0; 18], + default_sample_rate: 0, + error_opening: false, + device_frames: 0, + updated: 0, + track_start_time: 0, + current_replay_gain: 0, + c2rust_unnamed: C2RustUnnamed{pause_frames: 0,}, + next_sample_rate: 0, + track_start: 0 as *const u8_t as *mut u8_t, + gainL: 0, + gainR: 0, + invert: false, + next_replay_gain: 0, + threshold: 0, + fade: FADE_INACTIVE, + fade_start: 0 as *const u8_t as *mut u8_t, + fade_end: 0 as *const u8_t as *mut u8_t, + fade_dir: 0 as fade_dir, + fade_mode: FADE_NONE, + fade_secs: 0, + rate_delay: 0, + delay_active: false, + stop_time: 0, + idle_to: 0,}; +static mut buf: buffer = + buffer{buf: 0 as *const u8_t as *mut u8_t, + readp: 0 as *const u8_t as *mut u8_t, + writep: 0 as *const u8_t as *mut u8_t, + wrap: 0 as *const u8_t as *mut u8_t, + size: 0, + base_size: 0, + mutex: + pthread_mutex_t{__data: + __pthread_mutex_s{__lock: 0, + __count: 0, + __owner: 0, + __nusers: 0, + __kind: 0, + __spins: 0, + __elision: 0, + __list: + __pthread_list_t{__prev: + 0 + as + *const __pthread_internal_list + as + *mut __pthread_internal_list, + __next: + 0 + as + *const __pthread_internal_list + as + *mut __pthread_internal_list,},},},}; #[no_mangle] - -pub static mut outputbuf: *mut crate::squeezelite_h::buffer = - unsafe { &buf as *const crate::squeezelite_h::buffer as *mut crate::squeezelite_h::buffer }; +pub static mut outputbuf: *mut buffer = + unsafe { &buf as *const buffer as *mut buffer }; #[no_mangle] - -pub static mut silencebuf: *mut crate::squeezelite_h::u8_t = - 0 as *const crate::squeezelite_h::u8_t as *mut crate::squeezelite_h::u8_t; +pub static mut silencebuf: *mut u8_t = 0 as *const u8_t as *mut u8_t; #[no_mangle] - pub static mut user_rates: bool = 0 as libc::c_int != 0; // functions starting _* are called with mutex locked #[no_mangle] - -pub unsafe extern "C" fn _output_frames( - mut avail: crate::squeezelite_h::frames_t, -) -> crate::squeezelite_h::frames_t { - let mut frames: crate::squeezelite_h::frames_t = 0; - let mut size: crate::squeezelite_h::frames_t = 0; +pub unsafe extern "C" fn _output_frames(mut avail: frames_t) -> frames_t { + let mut frames: frames_t = 0; + let mut size: frames_t = 0; let mut silence: bool = false; - let mut cross_gain_in = 0 as libc::c_int; - let mut cross_gain_out = 0 as libc::c_int; - let mut cross_ptr = 0 as *mut crate::squeezelite_h::s32_t; - let mut gainL = if output.current_replay_gain != 0 { - crate::squeezelite_h::gain( - output.gainL as crate::squeezelite_h::s32_t, - output.current_replay_gain as crate::squeezelite_h::s32_t, - ) as libc::c_uint - } else { - output.gainL - } as crate::squeezelite_h::s32_t; - let mut gainR = if output.current_replay_gain != 0 { - crate::squeezelite_h::gain( - output.gainR as crate::squeezelite_h::s32_t, - output.current_replay_gain as crate::squeezelite_h::s32_t, - ) as libc::c_uint - } else { - output.gainR - } as crate::squeezelite_h::s32_t; - if output.invert { - gainL = -gainL; - gainR = -gainR - } + let mut cross_gain_in: s32_t = 0 as libc::c_int; + let mut cross_gain_out: s32_t = 0 as libc::c_int; + let mut cross_ptr: *mut s32_t = 0 as *mut s32_t; + let mut gainL: s32_t = + if output.current_replay_gain != 0 { + gain(output.gainL as s32_t, output.current_replay_gain as s32_t) + as libc::c_uint + } else { output.gainL } as s32_t; + let mut gainR: s32_t = + if output.current_replay_gain != 0 { + gain(output.gainR as s32_t, output.current_replay_gain as s32_t) + as libc::c_uint + } else { output.gainR } as s32_t; + if output.invert { gainL = -gainL; gainR = -gainR } frames = - crate::squeezelite_h::_buf_used(outputbuf).wrapping_div(8 as libc::c_int as libc::c_uint); + _buf_used(outputbuf).wrapping_div(8 as libc::c_int as libc::c_uint); silence = 0 as libc::c_int != 0; // start when threshold met - if output.state as libc::c_int == crate::squeezelite_h::OUTPUT_BUFFER as libc::c_int - && frames - > output - .threshold - .wrapping_mul(output.next_sample_rate) - .wrapping_div(10 as libc::c_int as libc::c_uint) - && frames > output.start_frames - { - output.state = crate::squeezelite_h::OUTPUT_RUNNING; - 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 start buffer frames: %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"_output_frames\x00")) - .as_ptr(), - 64 as libc::c_int, - frames, - ); + if output.state as libc::c_int == OUTPUT_BUFFER as libc::c_int && + frames > + output.threshold.wrapping_mul(output.next_sample_rate).wrapping_div(10 + as + libc::c_int + as + libc::c_uint) + && frames > output.start_frames { + output.state = OUTPUT_RUNNING; + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d start buffer frames: %u\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 15], + &[libc::c_char; 15]>(b"_output_frames\x00")).as_ptr(), + 64 as libc::c_int, frames); } - crate::src::slimproto::wake_controller(); + wake_controller(); } // skip ahead - consume outputbuf but play nothing - if output.state as libc::c_int == crate::squeezelite_h::OUTPUT_SKIP_FRAMES as libc::c_int { + if output.state as libc::c_int == OUTPUT_SKIP_FRAMES as libc::c_int { if frames > 0 as libc::c_int as libc::c_uint { - let mut skip = if frames < output.c2rust_unnamed.skip_frames { - frames - } else { - output.c2rust_unnamed.skip_frames - }; - 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 skip %u of %u frames\n\x00" as *const u8 as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 15], &[libc::c_char; 15]>( - b"_output_frames\x00", - )) - .as_ptr(), - 72 as libc::c_int, - skip, - output.c2rust_unnamed.skip_frames, - ); + let mut skip: frames_t = + if frames < output.c2rust_unnamed.skip_frames { + frames + } else { output.c2rust_unnamed.skip_frames }; + if loglevel as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d skip %u of %u frames\n\x00" as *const u8 + as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 15], + &[libc::c_char; 15]>(b"_output_frames\x00")).as_ptr(), + 72 as libc::c_int, skip, + output.c2rust_unnamed.skip_frames); } - frames = (frames as libc::c_uint).wrapping_sub(skip) as crate::squeezelite_h::frames_t - as crate::squeezelite_h::frames_t; + frames = + (frames as libc::c_uint).wrapping_sub(skip) as frames_t as + frames_t; output.frames_played = output.frames_played.wrapping_add(skip); while skip > 0 as libc::c_int as libc::c_uint { - let mut cont_frames = if skip - < crate::src::buffer::_buf_cont_read(outputbuf) - .wrapping_div(8 as libc::c_int as libc::c_uint) - { - skip - } else { - crate::src::buffer::_buf_cont_read(outputbuf) - .wrapping_div(8 as libc::c_int as libc::c_uint) - }; - skip = (skip as libc::c_uint).wrapping_sub(cont_frames) - as crate::squeezelite_h::frames_t - as crate::squeezelite_h::frames_t; - crate::src::buffer::_buf_inc_readp( - outputbuf, - cont_frames.wrapping_mul(8 as libc::c_int as libc::c_uint), - ); + let mut cont_frames: frames_t = + if skip < + _buf_cont_read(outputbuf).wrapping_div(8 as + libc::c_int + as + libc::c_uint) + { + skip + } else { + _buf_cont_read(outputbuf).wrapping_div(8 as + libc::c_int + as + libc::c_uint) + }; + skip = + (skip as libc::c_uint).wrapping_sub(cont_frames) as + frames_t as frames_t; + _buf_inc_readp(outputbuf, + cont_frames.wrapping_mul(8 as libc::c_int as + libc::c_uint)); } } - output.state = crate::squeezelite_h::OUTPUT_RUNNING + output.state = OUTPUT_RUNNING } // pause frames - play silence for required frames - if output.state as libc::c_int == crate::squeezelite_h::OUTPUT_PAUSE_FRAMES 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 pause %u frames\n\x00" as *const u8 as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 15], &[libc::c_char; 15]>(b"_output_frames\x00")) - .as_ptr(), - 86 as libc::c_int, - output.c2rust_unnamed.pause_frames, - ); + if output.state as libc::c_int == OUTPUT_PAUSE_FRAMES as libc::c_int { + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d pause %u frames\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 15], + &[libc::c_char; 15]>(b"_output_frames\x00")).as_ptr(), + 86 as libc::c_int, output.c2rust_unnamed.pause_frames); } - if output.c2rust_unnamed.pause_frames == 0 as libc::c_int as libc::c_uint { - output.state = crate::squeezelite_h::OUTPUT_RUNNING + if output.c2rust_unnamed.pause_frames == + 0 as libc::c_int as libc::c_uint { + output.state = OUTPUT_RUNNING } else { silence = 1 as libc::c_int != 0; - frames = if avail < output.c2rust_unnamed.pause_frames { - avail - } else { - output.c2rust_unnamed.pause_frames - }; - frames = if frames < 2048 as libc::c_int as libc::c_uint { - frames - } else { - 2048 as libc::c_int as libc::c_uint - }; + frames = + if avail < output.c2rust_unnamed.pause_frames { + avail + } else { output.c2rust_unnamed.pause_frames }; + frames = + if frames < 2048 as libc::c_int as libc::c_uint { + frames + } else { 2048 as libc::c_int as libc::c_uint }; output.c2rust_unnamed.pause_frames = - (output.c2rust_unnamed.pause_frames as libc::c_uint).wrapping_sub(frames) - as crate::squeezelite_h::u32_t as crate::squeezelite_h::u32_t + (output.c2rust_unnamed.pause_frames as + libc::c_uint).wrapping_sub(frames) as u32_t as u32_t } } // start at - play silence until jiffies reached - if output.state as libc::c_int == crate::squeezelite_h::OUTPUT_START_AT as libc::c_int { - let mut now = crate::src::utils::gettime_ms(); - if now >= output.c2rust_unnamed.start_at - || output.c2rust_unnamed.start_at - > now.wrapping_add(10000 as libc::c_int as libc::c_uint) - { - output.state = crate::squeezelite_h::OUTPUT_RUNNING + if output.state as libc::c_int == OUTPUT_START_AT as libc::c_int { + let mut now: u32_t = gettime_ms(); + if now >= output.c2rust_unnamed.start_at || + output.c2rust_unnamed.start_at > + now.wrapping_add(10000 as libc::c_int as libc::c_uint) { + output.state = OUTPUT_RUNNING } else { - let mut delta_frames = output - .c2rust_unnamed - .start_at - .wrapping_sub(now) - .wrapping_mul(output.current_sample_rate) - .wrapping_div(1000 as libc::c_int as libc::c_uint); + let mut delta_frames: u32_t = + output.c2rust_unnamed.start_at.wrapping_sub(now).wrapping_mul(output.current_sample_rate).wrapping_div(1000 + as + libc::c_int + as + libc::c_uint); silence = 1 as libc::c_int != 0; - frames = if avail < delta_frames { - avail - } else { - delta_frames - }; - frames = if frames < 2048 as libc::c_int as libc::c_uint { - frames - } else { - 2048 as libc::c_int as libc::c_uint - } + frames = if avail < delta_frames { avail } else { delta_frames }; + frames = + if frames < 2048 as libc::c_int as libc::c_uint { + frames + } else { 2048 as libc::c_int as libc::c_uint } } } // play silence if buffering or no frames - if output.state as libc::c_int <= crate::squeezelite_h::OUTPUT_BUFFER as libc::c_int - || frames == 0 as libc::c_int as libc::c_uint - { + if output.state as libc::c_int <= OUTPUT_BUFFER as libc::c_int || + frames == 0 as libc::c_int as libc::c_uint { silence = 1 as libc::c_int != 0; - frames = if avail < 2048 as libc::c_int as libc::c_uint { - avail - } else { - 2048 as libc::c_int as libc::c_uint - } + frames = + if avail < 2048 as libc::c_int as libc::c_uint { + avail + } else { 2048 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 avail: %d frames: %d silence: %d\n\x00" as *const u8 as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 15], &[libc::c_char; 15]>(b"_output_frames\x00")) - .as_ptr(), - 116 as libc::c_int, - avail, - frames, - silence as libc::c_int, - ); + if loglevel as libc::c_uint >= lSDEBUG as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d avail: %d frames: %d silence: %d\n\x00" as + *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 15], + &[libc::c_char; 15]>(b"_output_frames\x00")).as_ptr(), + 116 as libc::c_int, avail, frames, silence as libc::c_int); } frames = if frames < avail { frames } else { avail }; size = frames; while size > 0 as libc::c_int as libc::c_uint { - let mut out_frames: crate::squeezelite_h::frames_t = 0; - let mut cont_frames_0 = crate::src::buffer::_buf_cont_read(outputbuf) - .wrapping_div(8 as libc::c_int as libc::c_uint); + let mut out_frames: frames_t = 0; + let mut cont_frames_0: frames_t = + _buf_cont_read(outputbuf).wrapping_div(8 as libc::c_int as + libc::c_uint); let mut wrote: libc::c_int = 0; if !output.track_start.is_null() && !silence { if output.track_start == (*outputbuf).readp { - let mut delay = 0 as libc::c_int as libc::c_uint; + let mut delay: libc::c_uint = + 0 as libc::c_int as libc::c_uint; if output.current_sample_rate != output.next_sample_rate { delay = output.rate_delay } - frames = (frames as libc::c_uint).wrapping_sub(size) - as crate::squeezelite_h::frames_t - as crate::squeezelite_h::frames_t; + frames = + (frames as libc::c_uint).wrapping_sub(size) as frames_t as + frames_t; // add silence delay in two halves, before and after track start on rate or pcm-dop change if delay != 0 { - output.state = crate::squeezelite_h::OUTPUT_PAUSE_FRAMES; // first delay - don't process track start + output.state = + OUTPUT_PAUSE_FRAMES; // first delay - don't process track start if !output.delay_active { - output.c2rust_unnamed.pause_frames = output - .current_sample_rate - .wrapping_mul(delay) - .wrapping_div(2000 as libc::c_int as libc::c_uint); + output.c2rust_unnamed.pause_frames = + output.current_sample_rate.wrapping_mul(delay).wrapping_div(2000 + as + libc::c_int + as + libc::c_uint); output.delay_active = 1 as libc::c_int != 0; - break; + break ; } else { - output.c2rust_unnamed.pause_frames = output - .next_sample_rate - .wrapping_mul(delay) - .wrapping_div(2000 as libc::c_int as libc::c_uint); + output.c2rust_unnamed.pause_frames = + output.next_sample_rate.wrapping_mul(delay).wrapping_div(2000 + as + libc::c_int + as + libc::c_uint); output.delay_active = 0 as libc::c_int != 0 // second delay - process track start } } - 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 track start sample rate: %u replay_gain: %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"_output_frames\x00", - )) - .as_ptr(), - 149 as libc::c_int, - output.next_sample_rate, - output.next_replay_gain, - ); + if loglevel as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d track start sample rate: %u replay_gain: %u\n\x00" + as *const u8 as *const libc::c_char, + logtime(), + (*::std::mem::transmute::<&[u8; 15], + &[libc::c_char; 15]>(b"_output_frames\x00")).as_ptr(), + 149 as libc::c_int, output.next_sample_rate, + output.next_replay_gain); } output.frames_played = 0 as libc::c_int as libc::c_uint; output.track_started = 1 as libc::c_int != 0; - output.track_start_time = crate::src::utils::gettime_ms(); + output.track_start_time = gettime_ms(); output.current_sample_rate = output.next_sample_rate; - if output.fade as libc::c_uint - == crate::squeezelite_h::FADE_INACTIVE as libc::c_int as libc::c_uint - || output.fade_mode as libc::c_uint - != crate::squeezelite_h::FADE_CROSSFADE as libc::c_int as libc::c_uint - { + if output.fade as libc::c_uint == + FADE_INACTIVE as libc::c_int as libc::c_uint || + output.fade_mode as libc::c_uint != + FADE_CROSSFADE as libc::c_int as libc::c_uint { output.current_replay_gain = output.next_replay_gain } - output.track_start = 0 as *mut crate::squeezelite_h::u8_t; - break; + output.track_start = 0 as *mut u8_t; + break ; } else if output.track_start > (*outputbuf).readp { // reduce cont_frames so we find the next track start at beginning of next chunk - cont_frames_0 = if (cont_frames_0 as libc::c_long) - < output.track_start.wrapping_offset_from((*outputbuf).readp) as libc::c_long - / 8 as libc::c_int as libc::c_long - { - cont_frames_0 as libc::c_long - } else { - (output.track_start.wrapping_offset_from((*outputbuf).readp) as libc::c_long) - / 8 as libc::c_int as libc::c_long - } as crate::squeezelite_h::frames_t + cont_frames_0 = + if (cont_frames_0 as libc::c_long) < + output.track_start.wrapping_offset_from((*outputbuf).readp) + as libc::c_long / + 8 as libc::c_int as libc::c_long { + cont_frames_0 as libc::c_long + } else { + (output.track_start.wrapping_offset_from((*outputbuf).readp) + as libc::c_long) / + 8 as libc::c_int as libc::c_long + } as frames_t } } if output.fade as libc::c_uint != 0 && !silence { - if output.fade as libc::c_uint - == crate::squeezelite_h::FADE_DUE as libc::c_int as libc::c_uint - { + if output.fade as libc::c_uint == + FADE_DUE as libc::c_int as libc::c_uint { if output.fade_start == (*outputbuf).readp { - 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 fade start reached\n\x00" as *const u8 - as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 15], &[libc::c_char; 15]>( - b"_output_frames\x00", - )) - .as_ptr(), - 177 as libc::c_int, - ); + if loglevel as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d fade start reached\n\x00" as + *const u8 as *const libc::c_char, + logtime(), + (*::std::mem::transmute::<&[u8; 15], + &[libc::c_char; 15]>(b"_output_frames\x00")).as_ptr(), + 177 as libc::c_int); } - output.fade = crate::squeezelite_h::FADE_ACTIVE + output.fade = FADE_ACTIVE } else if output.fade_start > (*outputbuf).readp { - cont_frames_0 = if (cont_frames_0 as libc::c_long) - < output.fade_start.wrapping_offset_from((*outputbuf).readp) as libc::c_long - / 8 as libc::c_int as libc::c_long - { - cont_frames_0 as libc::c_long - } else { - (output.fade_start.wrapping_offset_from((*outputbuf).readp) as libc::c_long) - / 8 as libc::c_int as libc::c_long - } as crate::squeezelite_h::frames_t + cont_frames_0 = + if (cont_frames_0 as libc::c_long) < + output.fade_start.wrapping_offset_from((*outputbuf).readp) + as libc::c_long / + 8 as libc::c_int as libc::c_long { + cont_frames_0 as libc::c_long + } else { + (output.fade_start.wrapping_offset_from((*outputbuf).readp) + as libc::c_long) / + 8 as libc::c_int as libc::c_long + } as frames_t } } - if output.fade as libc::c_uint - == crate::squeezelite_h::FADE_ACTIVE as libc::c_int as libc::c_uint - { + if output.fade as libc::c_uint == + FADE_ACTIVE as libc::c_int as libc::c_uint { // find position within fade - let mut cur_f = if (*outputbuf).readp >= output.fade_start { - ((*outputbuf).readp.wrapping_offset_from(output.fade_start) as libc::c_long) - / 8 as libc::c_int as libc::c_long - } else { - ((*outputbuf) - .readp - .offset((*outputbuf).size as isize) - .wrapping_offset_from(output.fade_start) - as libc::c_long) - / 8 as libc::c_int as libc::c_long - } as crate::squeezelite_h::frames_t; - let mut dur_f = if output.fade_end >= output.fade_start { - (output.fade_end.wrapping_offset_from(output.fade_start) as libc::c_long) - / 8 as libc::c_int as libc::c_long - } else { - (output - .fade_end - .offset((*outputbuf).size as isize) - .wrapping_offset_from(output.fade_start) - as libc::c_long) - / 8 as libc::c_int as libc::c_long - } as crate::squeezelite_h::frames_t; + let mut cur_f: frames_t = + if (*outputbuf).readp >= output.fade_start { + ((*outputbuf).readp.wrapping_offset_from(output.fade_start) + as libc::c_long) / + 8 as libc::c_int as libc::c_long + } else { + ((*outputbuf).readp.offset((*outputbuf).size as + isize).wrapping_offset_from(output.fade_start) + as libc::c_long) / + 8 as libc::c_int as libc::c_long + } as frames_t; + let mut dur_f: frames_t = + if output.fade_end >= output.fade_start { + (output.fade_end.wrapping_offset_from(output.fade_start) + as libc::c_long) / + 8 as libc::c_int as libc::c_long + } else { + (output.fade_end.offset((*outputbuf).size as + isize).wrapping_offset_from(output.fade_start) + as libc::c_long) / + 8 as libc::c_int as libc::c_long + } as frames_t; if cur_f >= dur_f { - if output.fade_mode as libc::c_uint - == crate::squeezelite_h::FADE_INOUT as libc::c_int as libc::c_uint - && output.fade_dir as libc::c_uint - == crate::squeezelite_h::FADE_DOWN 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 fade down complete, starting fade up\n\x00" as *const u8 - as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 15], &[libc::c_char; 15]>( - b"_output_frames\x00", - )) - .as_ptr(), - 191 as libc::c_int, - ); + if output.fade_mode as libc::c_uint == + FADE_INOUT as libc::c_int as libc::c_uint && + output.fade_dir as libc::c_uint == + FADE_DOWN as libc::c_int as libc::c_uint { + if loglevel as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d fade down complete, starting fade up\n\x00" + as *const u8 as *const libc::c_char, + logtime(), + (*::std::mem::transmute::<&[u8; 15], + &[libc::c_char; 15]>(b"_output_frames\x00")).as_ptr(), + 191 as libc::c_int); } - output.fade_dir = crate::squeezelite_h::FADE_UP; + output.fade_dir = FADE_UP; output.fade_start = (*outputbuf).readp; - output.fade_end = (*outputbuf) - .readp - .offset(dur_f.wrapping_mul(8 as libc::c_int as libc::c_uint) as isize); + output.fade_end = + (*outputbuf).readp.offset(dur_f.wrapping_mul(8 as + libc::c_int + as + libc::c_uint) + as isize); if output.fade_end >= (*outputbuf).wrap { - output.fade_end = output.fade_end.offset(-((*outputbuf).size as isize)) + output.fade_end = + output.fade_end.offset(-((*outputbuf).size as + isize)) } - cur_f = 0 as libc::c_int as crate::squeezelite_h::frames_t - } else if output.fade_mode as libc::c_uint - == crate::squeezelite_h::FADE_CROSSFADE 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 crossfade complete\n\x00" as *const u8 - as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 15], &[libc::c_char; 15]>( - b"_output_frames\x00", - )) - .as_ptr(), - 200 as libc::c_int, - ); + cur_f = 0 as libc::c_int as frames_t + } else if output.fade_mode as libc::c_uint == + FADE_CROSSFADE as libc::c_int as + libc::c_uint { + if loglevel as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d crossfade complete\n\x00" as + *const u8 as *const libc::c_char, + logtime(), + (*::std::mem::transmute::<&[u8; 15], + &[libc::c_char; 15]>(b"_output_frames\x00")).as_ptr(), + 200 as libc::c_int); } - if crate::squeezelite_h::_buf_used(outputbuf) - >= dur_f.wrapping_mul(8 as libc::c_int as libc::c_uint) - { - crate::src::buffer::_buf_inc_readp( - outputbuf, - dur_f.wrapping_mul(8 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 skipped crossfaded start\n\x00" as *const u8 - as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 15], &[libc::c_char; 15]>( - b"_output_frames\x00", - )) - .as_ptr(), - 203 as libc::c_int, - ); + if _buf_used(outputbuf) >= + dur_f.wrapping_mul(8 as libc::c_int as + libc::c_uint) { + _buf_inc_readp(outputbuf, + dur_f.wrapping_mul(8 as libc::c_int + as + libc::c_uint)); + if loglevel as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d skipped crossfaded start\n\x00" + as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 15], + &[libc::c_char; 15]>(b"_output_frames\x00")).as_ptr(), + 203 as libc::c_int); } - } 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 unable to skip crossfaded start\n\x00" as *const u8 - as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 15], &[libc::c_char; 15]>( - b"_output_frames\x00", - )) - .as_ptr(), - 205 as libc::c_int, - ); + } else if loglevel as libc::c_uint >= + lWARN as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d unable to skip crossfaded start\n\x00" + as *const u8 as *const libc::c_char, + logtime(), + (*::std::mem::transmute::<&[u8; 15], + &[libc::c_char; 15]>(b"_output_frames\x00")).as_ptr(), + 205 as libc::c_int); } - output.fade = crate::squeezelite_h::FADE_INACTIVE; + output.fade = FADE_INACTIVE; output.current_replay_gain = output.next_replay_gain } 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 fade complete\n\x00" as *const u8 as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 15], &[libc::c_char; 15]>( - b"_output_frames\x00", - )) - .as_ptr(), - 210 as libc::c_int, - ); + if loglevel as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d fade complete\n\x00" as + *const u8 as *const libc::c_char, + logtime(), + (*::std::mem::transmute::<&[u8; 15], + &[libc::c_char; 15]>(b"_output_frames\x00")).as_ptr(), + 210 as libc::c_int); } - output.fade = crate::squeezelite_h::FADE_INACTIVE + output.fade = FADE_INACTIVE } } // if fade in progress set fade gain, ensure cont_frames reduced so we get to end of fade at start of chunk if output.fade as u64 != 0 { if output.fade_end > (*outputbuf).readp { - cont_frames_0 = if (cont_frames_0 as libc::c_long) - < output.fade_end.wrapping_offset_from((*outputbuf).readp) - as libc::c_long - / 8 as libc::c_int as libc::c_long - { - cont_frames_0 as libc::c_long - } else { - (output.fade_end.wrapping_offset_from((*outputbuf).readp) - as libc::c_long) - / 8 as libc::c_int as libc::c_long - } as crate::squeezelite_h::frames_t + cont_frames_0 = + if (cont_frames_0 as libc::c_long) < + output.fade_end.wrapping_offset_from((*outputbuf).readp) + as libc::c_long / + 8 as libc::c_int as libc::c_long { + cont_frames_0 as libc::c_long + } else { + (output.fade_end.wrapping_offset_from((*outputbuf).readp) + as libc::c_long) / + 8 as libc::c_int as libc::c_long + } as frames_t } - if output.fade_dir as libc::c_uint - == crate::squeezelite_h::FADE_UP as libc::c_int as libc::c_uint - || output.fade_dir as libc::c_uint - == crate::squeezelite_h::FADE_DOWN as libc::c_int as libc::c_uint - { + if output.fade_dir as libc::c_uint == + FADE_UP as libc::c_int as libc::c_uint || + output.fade_dir as libc::c_uint == + FADE_DOWN as libc::c_int as libc::c_uint { // fade in, in-out, out handled via altering standard gain - let mut fade_gain: crate::squeezelite_h::s32_t = 0; - if output.fade_dir as libc::c_uint - == crate::squeezelite_h::FADE_DOWN as libc::c_int as libc::c_uint - { + let mut fade_gain: s32_t = 0; + if output.fade_dir as libc::c_uint == + FADE_DOWN as libc::c_int as libc::c_uint { cur_f = dur_f.wrapping_sub(cur_f) } - fade_gain = crate::squeezelite_h::to_gain( - cur_f as libc::c_float / dur_f as libc::c_float, - ); - gainL = crate::squeezelite_h::gain(gainL, fade_gain); - gainR = crate::squeezelite_h::gain(gainR, fade_gain); - if output.invert { - gainL = -gainL; - gainR = -gainR - } + fade_gain = + to_gain(cur_f as libc::c_float / + dur_f as libc::c_float); + gainL = gain(gainL, fade_gain); + gainR = gain(gainR, fade_gain); + if output.invert { gainL = -gainL; gainR = -gainR } } - if output.fade_dir as libc::c_uint - == crate::squeezelite_h::FADE_CROSS as libc::c_int as libc::c_uint - { + if output.fade_dir as libc::c_uint == + FADE_CROSS as libc::c_int as libc::c_uint { // cross fade requires special treatment - performed later based on these values - // support different replay gain for old and new track by retaining old value until crossfade completes - if crate::squeezelite_h::_buf_used(outputbuf) - .wrapping_div(8 as libc::c_int as libc::c_uint) - > dur_f.wrapping_add(size) - { - cross_gain_in = crate::squeezelite_h::to_gain( - cur_f as libc::c_float / dur_f as libc::c_float, - ); - cross_gain_out = 0x10000 as libc::c_int - cross_gain_in; + // support different replay gain for old and new track by retaining old value until crossfade completes + if _buf_used(outputbuf).wrapping_div(8 as libc::c_int + as + libc::c_uint) + > dur_f.wrapping_add(size) { + cross_gain_in = + to_gain(cur_f as libc::c_float / + dur_f as libc::c_float); + cross_gain_out = + 0x10000 as libc::c_int - cross_gain_in; if output.current_replay_gain != 0 { - cross_gain_out = crate::squeezelite_h::gain( - cross_gain_out, - output.current_replay_gain as crate::squeezelite_h::s32_t, - ) + cross_gain_out = + gain(cross_gain_out, + output.current_replay_gain as s32_t) } if output.next_replay_gain != 0 { - cross_gain_in = crate::squeezelite_h::gain( - cross_gain_in, - output.next_replay_gain as crate::squeezelite_h::s32_t, - ) + cross_gain_in = + gain(cross_gain_in, + output.next_replay_gain as s32_t) } - gainL = output.gainL as crate::squeezelite_h::s32_t; - gainR = output.gainR as crate::squeezelite_h::s32_t; + gainL = output.gainL as s32_t; + gainR = output.gainR as s32_t; if output.invert { gainL = -gainL; gainR = -gainR } cross_ptr = - output - .fade_end - .offset(cur_f.wrapping_mul(8 as libc::c_int as libc::c_uint) - as isize) - as *mut crate::squeezelite_h::s32_t + output.fade_end.offset(cur_f.wrapping_mul(8 as + libc::c_int + as + libc::c_uint) + as isize) as + *mut s32_t } 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 unable to continue crossfade - too few samples\n\x00" - as *const u8 - as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 15], &[libc::c_char; 15]>( - b"_output_frames\x00", - )) - .as_ptr(), - 247 as libc::c_int, - ); + if loglevel as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d unable to continue crossfade - too few samples\n\x00" + as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 15], + &[libc::c_char; 15]>(b"_output_frames\x00")).as_ptr(), + 247 as libc::c_int); } - output.fade = crate::squeezelite_h::FADE_INACTIVE + output.fade = FADE_INACTIVE } } } } } - out_frames = if !silence { - if size < cont_frames_0 { - size - } else { - cont_frames_0 - } - } else { - size - }; - wrote = output.write_cb.expect("non-null function pointer")( - out_frames, - silence, - gainL, - gainR, - cross_gain_in, - cross_gain_out, - &mut cross_ptr, - ); - if wrote <= 0 as libc::c_int { - frames = (frames as libc::c_uint).wrapping_sub(size) as crate::squeezelite_h::frames_t - as crate::squeezelite_h::frames_t; - break; - } else { - out_frames = wrote as crate::squeezelite_h::frames_t; - size = (size as libc::c_uint).wrapping_sub(out_frames) as crate::squeezelite_h::frames_t - as crate::squeezelite_h::frames_t; + out_frames = if !silence { - crate::src::buffer::_buf_inc_readp( - outputbuf, - out_frames.wrapping_mul(8 as libc::c_int as libc::c_uint), - ); - output.frames_played = output.frames_played.wrapping_add(out_frames) + if size < cont_frames_0 { size } else { cont_frames_0 } + } else { size }; + wrote = + output.write_cb.expect("non-null function pointer")(out_frames, + silence, + gainL, gainR, + cross_gain_in, + cross_gain_out, + &mut cross_ptr); + if wrote <= 0 as libc::c_int { + frames = + (frames as libc::c_uint).wrapping_sub(size) as frames_t as + frames_t; + break ; + } else { + out_frames = wrote as frames_t; + size = + (size as libc::c_uint).wrapping_sub(out_frames) as frames_t as + frames_t; + if !silence { + _buf_inc_readp(outputbuf, + out_frames.wrapping_mul(8 as libc::c_int as + libc::c_uint)); + output.frames_played = + output.frames_played.wrapping_add(out_frames) } } } - 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; 15], &[libc::c_char; 15]>(b"_output_frames\x00")) - .as_ptr(), - 276 as libc::c_int, - frames, - ); + if loglevel as libc::c_uint >= lSDEBUG as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d wrote %u frames\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 15], + &[libc::c_char; 15]>(b"_output_frames\x00")).as_ptr(), + 276 as libc::c_int, frames); } return frames; } // _* called with mutex locked #[no_mangle] - pub unsafe extern "C" fn _checkfade(mut start: bool) { - let mut bytes: crate::squeezelite_h::frames_t = 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 fade mode: %u duration: %u %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"_checkfade\x00")).as_ptr(), - 284 as libc::c_int, - output.fade_mode as libc::c_uint, - output.fade_secs, - if start as libc::c_int != 0 { - b"track-start\x00" as *const u8 as *const libc::c_char - } else { - b"track-end\x00" as *const u8 as *const libc::c_char - }, - ); + let mut bytes: frames_t = 0; + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d fade mode: %u duration: %u %s\n\x00" as *const u8 + as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 11], + &[libc::c_char; 11]>(b"_checkfade\x00")).as_ptr(), + 284 as libc::c_int, output.fade_mode as libc::c_uint, + output.fade_secs, + if start as libc::c_int != 0 { + b"track-start\x00" as *const u8 as *const libc::c_char + } else { + b"track-end\x00" as *const u8 as *const libc::c_char + }); } - bytes = output - .next_sample_rate - .wrapping_mul(8 as libc::c_int as libc::c_uint) - .wrapping_mul(output.fade_secs); - if output.fade_mode as libc::c_uint - == crate::squeezelite_h::FADE_INOUT as libc::c_int as libc::c_uint - { + bytes = + output.next_sample_rate.wrapping_mul(8 as libc::c_int as + libc::c_uint).wrapping_mul(output.fade_secs); + if output.fade_mode as libc::c_uint == + FADE_INOUT as libc::c_int as libc::c_uint { /* align on a frame boundary */ - bytes = bytes - .wrapping_div(2 as libc::c_int as libc::c_uint) - .wrapping_div(8 as libc::c_int as libc::c_uint) - .wrapping_mul(8 as libc::c_int as libc::c_uint) + bytes = + bytes.wrapping_div(2 as libc::c_int as + libc::c_uint).wrapping_div(8 as libc::c_int + as + libc::c_uint).wrapping_mul(8 + as + libc::c_int + as + libc::c_uint) } // shorter than full buffer otherwise start and end align - if start as libc::c_int != 0 - && (output.fade_mode as libc::c_uint - == crate::squeezelite_h::FADE_IN as libc::c_int as libc::c_uint - || output.fade_mode as libc::c_uint - == crate::squeezelite_h::FADE_INOUT as libc::c_int as libc::c_uint - && crate::squeezelite_h::_buf_used(outputbuf) == 0 as libc::c_int as libc::c_uint) - { - bytes = if (bytes as libc::c_ulong) - < (*outputbuf) - .size - .wrapping_sub(8 as libc::c_int as libc::c_ulong) - { - bytes as libc::c_ulong - } else { - (*outputbuf) - .size - .wrapping_sub(8 as libc::c_int as libc::c_ulong) - } as crate::squeezelite_h::frames_t; // max of current remaining samples from previous track - 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 fade IN: %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"_checkfade\x00")) - .as_ptr(), - 294 as libc::c_int, - bytes.wrapping_div(8 as libc::c_int as libc::c_uint), - ); // max of 90% of outputbuf as we consume additional buffer during crossfade + if start as libc::c_int != 0 && + (output.fade_mode as libc::c_uint == + FADE_IN as libc::c_int as libc::c_uint || + output.fade_mode as libc::c_uint == + FADE_INOUT as libc::c_int as libc::c_uint && + _buf_used(outputbuf) == 0 as libc::c_int as libc::c_uint) + { + bytes = + if (bytes as libc::c_ulong) < + (*outputbuf).size.wrapping_sub(8 as libc::c_int as + libc::c_ulong) { + bytes as libc::c_ulong + } else { + (*outputbuf).size.wrapping_sub(8 as libc::c_int as + libc::c_ulong) + } as + frames_t; // max of current remaining samples from previous track + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d fade IN: %u frames\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 11], + &[libc::c_char; 11]>(b"_checkfade\x00")).as_ptr(), + 294 as libc::c_int, + bytes.wrapping_div(8 as libc::c_int as + libc::c_uint)); // max of 90% of outputbuf as we consume additional buffer during crossfade } - output.fade = crate::squeezelite_h::FADE_DUE; - output.fade_dir = crate::squeezelite_h::FADE_UP; + output.fade = FADE_DUE; + output.fade_dir = FADE_UP; output.fade_start = (*outputbuf).writep; output.fade_end = output.fade_start.offset(bytes as isize); if output.fade_end >= (*outputbuf).wrap { - output.fade_end = output.fade_end.offset(-((*outputbuf).size as isize)) + output.fade_end = + output.fade_end.offset(-((*outputbuf).size as isize)) } } - if !start - && (output.fade_mode as libc::c_uint - == crate::squeezelite_h::FADE_OUT as libc::c_int as libc::c_uint - || output.fade_mode as libc::c_uint - == crate::squeezelite_h::FADE_INOUT as libc::c_int as libc::c_uint) - { - bytes = if crate::squeezelite_h::_buf_used(outputbuf) < bytes { - crate::squeezelite_h::_buf_used(outputbuf) - } else { - bytes - }; - 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 fade %s: %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"_checkfade\x00")) - .as_ptr(), - 306 as libc::c_int, - if output.fade_mode as libc::c_uint - == crate::squeezelite_h::FADE_INOUT as libc::c_int as libc::c_uint - { - b"IN-OUT\x00" as *const u8 as *const libc::c_char - } else { - b"OUT\x00" as *const u8 as *const libc::c_char - }, - bytes.wrapping_div(8 as libc::c_int as libc::c_uint), - ); + if !start && + (output.fade_mode as libc::c_uint == + FADE_OUT as libc::c_int as libc::c_uint || + output.fade_mode as libc::c_uint == + FADE_INOUT as libc::c_int as libc::c_uint) { + bytes = + if _buf_used(outputbuf) < bytes { + _buf_used(outputbuf) + } else { bytes }; + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d fade %s: %u frames\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 11], + &[libc::c_char; 11]>(b"_checkfade\x00")).as_ptr(), + 306 as libc::c_int, + if output.fade_mode as libc::c_uint == + FADE_INOUT as libc::c_int as libc::c_uint { + b"IN-OUT\x00" as *const u8 as *const libc::c_char + } else { + b"OUT\x00" as *const u8 as *const libc::c_char + }, bytes.wrapping_div(8 as libc::c_int as libc::c_uint)); } - output.fade = crate::squeezelite_h::FADE_DUE; - output.fade_dir = crate::squeezelite_h::FADE_DOWN; + output.fade = FADE_DUE; + output.fade_dir = FADE_DOWN; output.fade_start = (*outputbuf).writep.offset(-(bytes as isize)); if output.fade_start < (*outputbuf).buf { - output.fade_start = output.fade_start.offset((*outputbuf).size as isize) + output.fade_start = + output.fade_start.offset((*outputbuf).size as isize) } output.fade_end = (*outputbuf).writep } - if start as libc::c_int != 0 - && output.fade_mode as libc::c_uint - == crate::squeezelite_h::FADE_CROSSFADE as libc::c_int as libc::c_uint - { - if crate::squeezelite_h::_buf_used(outputbuf) != 0 as libc::c_int as libc::c_uint { + if start as libc::c_int != 0 && + output.fade_mode as libc::c_uint == + FADE_CROSSFADE as libc::c_int as libc::c_uint { + if _buf_used(outputbuf) != 0 as libc::c_int as libc::c_uint { if output.next_sample_rate != output.current_sample_rate { - 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 crossfade disabled as sample rates differ\n\x00" as *const u8 - as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 11], &[libc::c_char; 11]>( - b"_checkfade\x00", - )) - .as_ptr(), - 319 as libc::c_int, - ); + if loglevel as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d crossfade disabled as sample rates differ\n\x00" + as *const u8 as *const libc::c_char, + logtime(), + (*::std::mem::transmute::<&[u8; 11], + &[libc::c_char; 11]>(b"_checkfade\x00")).as_ptr(), + 319 as libc::c_int); } - return; + return } - bytes = if bytes < crate::squeezelite_h::_buf_used(outputbuf) { - bytes - } else { - crate::squeezelite_h::_buf_used(outputbuf) - }; - bytes = if bytes - < ((*outputbuf).size as libc::c_double * 0.9f64) as crate::squeezelite_h::frames_t - { - bytes - } else { - ((*outputbuf).size as libc::c_double * 0.9f64) as crate::squeezelite_h::frames_t - }; - 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 CROSSFADE: %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"_checkfade\x00")) - .as_ptr(), - 324 as libc::c_int, - bytes.wrapping_div(8 as libc::c_int as libc::c_uint), - ); + bytes = + if bytes < _buf_used(outputbuf) { + bytes + } else { _buf_used(outputbuf) }; + bytes = + if bytes < + ((*outputbuf).size as libc::c_double * 0.9f64) as + frames_t { + bytes + } else { + ((*outputbuf).size as libc::c_double * 0.9f64) as frames_t + }; + if loglevel as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d CROSSFADE: %u frames\n\x00" as *const u8 + as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 11], + &[libc::c_char; 11]>(b"_checkfade\x00")).as_ptr(), + 324 as libc::c_int, + bytes.wrapping_div(8 as libc::c_int as + libc::c_uint)); } - output.fade = crate::squeezelite_h::FADE_DUE; - output.fade_dir = crate::squeezelite_h::FADE_CROSS; + output.fade = FADE_DUE; + output.fade_dir = FADE_CROSS; output.fade_start = (*outputbuf).writep.offset(-(bytes as isize)); if output.fade_start < (*outputbuf).buf { - output.fade_start = output.fade_start.offset((*outputbuf).size as isize) + output.fade_start = + output.fade_start.offset((*outputbuf).size as isize) } output.fade_end = (*outputbuf).writep; output.track_start = output.fade_start - } else if (*outputbuf).size - == (44100 as libc::c_int * 8 as libc::c_int * 10 as libc::c_int) as libc::c_ulong - && (*outputbuf).readp == (*outputbuf).buf - { + } else if (*outputbuf).size == + (44100 as libc::c_int * 8 as libc::c_int * + 10 as libc::c_int) as libc::c_ulong && + (*outputbuf).readp == (*outputbuf).buf { // if default setting used and nothing in buffer attempt to resize to provide full crossfade support - 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 resize outputbuf for crossfade\n\x00" as *const u8 - as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 11], &[libc::c_char; 11]>(b"_checkfade\x00")) - .as_ptr(), - 335 as libc::c_int, - ); + if loglevel as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d resize outputbuf for crossfade\n\x00" as + *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 11], + &[libc::c_char; 11]>(b"_checkfade\x00")).as_ptr(), + 335 as libc::c_int); } - crate::src::buffer::_buf_resize( - outputbuf, - (44100 as libc::c_int * 8 as libc::c_int * 10 as libc::c_int * 12 as libc::c_int - / 10 as libc::c_int) as crate::stddef_h::size_t, - ); - crate::src::utils::touch_memory((*outputbuf).buf, (*outputbuf).size); + _buf_resize(outputbuf, + (44100 as libc::c_int * 8 as libc::c_int * + 10 as libc::c_int * 12 as libc::c_int / + 10 as libc::c_int) as size_t); + touch_memory((*outputbuf).buf, (*outputbuf).size); } }; } #[no_mangle] - -pub unsafe extern "C" fn output_init_common( - mut level: crate::squeezelite_h::log_level, - mut device: *const libc::c_char, - mut output_buf_size: libc::c_uint, - mut rates: *mut libc::c_uint, - mut idle: libc::c_uint, -) { +pub unsafe extern "C" fn output_init_common(mut level: log_level, + mut device: *const libc::c_char, + mut output_buf_size: libc::c_uint, + mut rates: *mut libc::c_uint, + mut idle: libc::c_uint) { let mut i: libc::c_uint = 0; loglevel = level; - output_buf_size = output_buf_size - .wrapping_sub(output_buf_size.wrapping_rem(8 as libc::c_int as libc::c_uint)); - 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 outputbuf size: %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"output_init_common\x00")) - .as_ptr(), - 350 as libc::c_int, - output_buf_size, - ); + output_buf_size = + output_buf_size.wrapping_sub(output_buf_size.wrapping_rem(8 as + libc::c_int + as + libc::c_uint)); + if loglevel as libc::c_uint >= lDEBUG as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d outputbuf size: %u\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 19], + &[libc::c_char; 19]>(b"output_init_common\x00")).as_ptr(), + 350 as libc::c_int, output_buf_size); } - crate::src::buffer::buf_init(outputbuf, output_buf_size as crate::stddef_h::size_t); + buf_init(outputbuf, output_buf_size as size_t); if (*outputbuf).buf.is_null() { - crate::src::utils::logprint( - b"%s %s:%d unable to malloc output buffer\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_common\x00")) - .as_ptr(), - 354 as libc::c_int, - ); - crate::stdlib::exit(0 as libc::c_int); + logprint(b"%s %s:%d unable to malloc output buffer\n\x00" as *const u8 + as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 19], + &[libc::c_char; 19]>(b"output_init_common\x00")).as_ptr(), + 354 as libc::c_int); + exit(0 as libc::c_int); } - silencebuf = crate::stdlib::malloc((2048 as libc::c_int * 8 as libc::c_int) as libc::c_ulong) - as *mut crate::squeezelite_h::u8_t; + silencebuf = + malloc((2048 as libc::c_int * 8 as libc::c_int) as libc::c_ulong) as + *mut u8_t; if silencebuf.is_null() { - crate::src::utils::logprint( - b"%s %s:%d unable to malloc silence buffer\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_common\x00")) - .as_ptr(), - 360 as libc::c_int, - ); - crate::stdlib::exit(0 as libc::c_int); + logprint(b"%s %s:%d unable to malloc silence buffer\n\x00" as + *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 19], + &[libc::c_char; 19]>(b"output_init_common\x00")).as_ptr(), + 360 as libc::c_int); + exit(0 as libc::c_int); } - crate::stdlib::memset( - silencebuf as *mut libc::c_void, - 0 as libc::c_int, - (2048 as libc::c_int * 8 as libc::c_int) as libc::c_ulong, - ); - 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 idle timeout: %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"output_init_common\x00")) - .as_ptr(), - 374 as libc::c_int, - idle, - ); + memset(silencebuf as *mut libc::c_void, 0 as libc::c_int, + (2048 as libc::c_int * 8 as libc::c_int) as libc::c_ulong); + if loglevel as libc::c_uint >= lDEBUG as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d idle timeout: %u\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 19], + &[libc::c_char; 19]>(b"output_init_common\x00")).as_ptr(), + 374 as libc::c_int, idle); } - output.state = if idle != 0 { - crate::squeezelite_h::OUTPUT_OFF as libc::c_int - } else { - crate::squeezelite_h::OUTPUT_STOPPED as libc::c_int - } as crate::squeezelite_h::output_state; + output.state = + if idle != 0 { + OUTPUT_OFF as libc::c_int + } else { OUTPUT_STOPPED as libc::c_int } as output_state; output.device = device; - output.fade = crate::squeezelite_h::FADE_INACTIVE; + output.fade = FADE_INACTIVE; output.invert = 0 as libc::c_int != 0; output.error_opening = 0 as libc::c_int != 0; output.idle_to = idle; /* Skip test_open for stdout, set default sample rates */ - if *output.device.offset(0 as libc::c_int as isize) as libc::c_int == '-' as i32 { + if *output.device.offset(0 as libc::c_int as isize) as libc::c_int == + '-' as i32 { i = 0 as libc::c_int as libc::c_uint; while i < 18 as libc::c_int as libc::c_uint { output.supported_rates[i as usize] = *rates.offset(i as isize); i = i.wrapping_add(1) } - } else if !crate::src::output_alsa::test_open( - output.device, - output.supported_rates.as_mut_ptr(), - user_rates, - ) { - crate::src::utils::logprint( - b"%s %s:%d unable to open output device: %s\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_common\x00")) - .as_ptr(), - 391 as libc::c_int, - output.device, - ); - crate::stdlib::exit(0 as libc::c_int); + } else if !test_open(output.device, output.supported_rates.as_mut_ptr(), + user_rates) { + logprint(b"%s %s:%d unable to open output device: %s\n\x00" as + *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 19], + &[libc::c_char; 19]>(b"output_init_common\x00")).as_ptr(), + 391 as libc::c_int, output.device); + exit(0 as libc::c_int); } if user_rates { i = 0 as libc::c_int as libc::c_uint; @@ -1028,63 +1017,55 @@ pub unsafe extern "C" fn output_init_common( // set initial sample rate, preferring 44100 i = 0 as libc::c_int as libc::c_uint; while i < 18 as libc::c_int as libc::c_uint { - if output.supported_rates[i as usize] == 44100 as libc::c_int as libc::c_uint { + if output.supported_rates[i as usize] == + 44100 as libc::c_int as libc::c_uint { output.default_sample_rate = 44100 as libc::c_int as libc::c_uint; - break; - } else { - i = i.wrapping_add(1) - } + break ; + } else { i = i.wrapping_add(1) } } if output.default_sample_rate == 0 { - output.default_sample_rate = output.supported_rates[0 as libc::c_int as usize] + output.default_sample_rate = + output.supported_rates[0 as libc::c_int as usize] } output.current_sample_rate = output.default_sample_rate; - if loglevel as libc::c_uint >= crate::squeezelite_h::lINFO as libc::c_int as libc::c_uint { + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { let mut rates_buf: [libc::c_char; 180] = *::std::mem::transmute::<&[u8; 180], &mut [libc::c_char; 180]>(b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"); i = 0 as libc::c_int as libc::c_uint; while output.supported_rates[i as usize] != 0 { let mut s: [libc::c_char; 10] = [0; 10]; - crate::stdlib::sprintf( - s.as_mut_ptr(), - b"%d \x00" as *const u8 as *const libc::c_char, - output.supported_rates[i as usize], - ); - crate::stdlib::strcat(rates_buf.as_mut_ptr(), s.as_mut_ptr()); + sprintf(s.as_mut_ptr(), + b"%d \x00" as *const u8 as *const libc::c_char, + output.supported_rates[i as usize]); + strcat(rates_buf.as_mut_ptr(), s.as_mut_ptr()); i = i.wrapping_add(1) } - 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 supported rates: %s\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_common\x00", - )) - .as_ptr(), - 422 as libc::c_int, - rates_buf.as_mut_ptr(), - ); + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d supported rates: %s\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 19], + &[libc::c_char; 19]>(b"output_init_common\x00")).as_ptr(), + 422 as libc::c_int, rates_buf.as_mut_ptr()); } }; } #[no_mangle] - pub unsafe extern "C" fn output_close_common() { - crate::src::buffer::buf_destroy(outputbuf); - crate::stdlib::free(silencebuf as *mut libc::c_void); + buf_destroy(outputbuf); + free(silencebuf as *mut libc::c_void); } -/* +/* * 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 @@ -1126,27 +1107,24 @@ pub unsafe extern "C" fn output_close_common() { // set by slimproto // set by slimproto #[no_mangle] - pub unsafe extern "C" fn output_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 flush output buffer\n\x00" as *const u8 as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 13], &[libc::c_char; 13]>(b"output_flush\x00")) - .as_ptr(), - 435 as libc::c_int, - ); + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d flush output buffer\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 13], + &[libc::c_char; 13]>(b"output_flush\x00")).as_ptr(), + 435 as libc::c_int); } - crate::src::buffer::buf_flush(outputbuf); - crate::stdlib::pthread_mutex_lock(&mut (*outputbuf).mutex); - output.fade = crate::squeezelite_h::FADE_INACTIVE; - if output.state as libc::c_int != crate::squeezelite_h::OUTPUT_OFF as libc::c_int { - output.state = crate::squeezelite_h::OUTPUT_STOPPED; + buf_flush(outputbuf); + pthread_mutex_lock(&mut (*outputbuf).mutex); + output.fade = FADE_INACTIVE; + if output.state as libc::c_int != OUTPUT_OFF as libc::c_int { + output.state = OUTPUT_STOPPED; if output.error_opening { output.current_sample_rate = output.default_sample_rate } output.delay_active = 0 as libc::c_int != 0 } output.frames_played = 0 as libc::c_int as libc::c_uint; - crate::stdlib::pthread_mutex_unlock(&mut (*outputbuf).mutex); + pthread_mutex_unlock(&mut (*outputbuf).mutex); } diff --git a/src/output_alsa.rs b/src/output_alsa.rs index 408d7f3..340bf0c 100644 --- a/src/output_alsa.rs +++ b/src/output_alsa.rs @@ -1,554 +1,860 @@ 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; - -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::__useconds_t; -pub use crate::stdlib::int32_t; -pub use crate::stdlib::FILE; -pub use crate::stdlib::_IO_FILE; - -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_attr_t; -pub use crate::stdlib::pthread_mutex_t; -pub use crate::stdlib::pthread_t; -pub use crate::stdlib::sched_param; -pub use crate::stdlib::u_int32_t; -pub use crate::stdlib::u_int8_t; - -pub use crate::squeezelite_h::_apply_cross; -pub use crate::squeezelite_h::_apply_gain; -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::src::utils::next_param; -pub use crate::src::utils::touch_memory; -use crate::stdlib::__errno_location; -pub use crate::stdlib::_snd_mixer; -pub use crate::stdlib::_snd_mixer_class; -pub use crate::stdlib::_snd_mixer_elem; -pub use crate::stdlib::_snd_mixer_selem_channel_id; -pub use crate::stdlib::_snd_mixer_selem_id; -pub use crate::stdlib::_snd_output; -pub use crate::stdlib::_snd_pcm; -pub use crate::stdlib::_snd_pcm_access; -pub use crate::stdlib::_snd_pcm_channel_area; -pub use crate::stdlib::_snd_pcm_format; -pub use crate::stdlib::_snd_pcm_hw_params; -pub use crate::stdlib::_snd_pcm_state; -pub use crate::stdlib::_snd_pcm_stream; -use crate::stdlib::atoi; -use crate::stdlib::fflush; -use crate::stdlib::fprintf; -use crate::stdlib::free; -use crate::stdlib::malloc; -use crate::stdlib::memcpy; -use crate::stdlib::memset; -use crate::stdlib::printf; -pub use crate::stdlib::snd_lib_error_handler_t; -pub use crate::stdlib::snd_lib_error_set_handler; -pub use crate::stdlib::snd_mixer_attach; -pub use crate::stdlib::snd_mixer_class_t; -pub use crate::stdlib::snd_mixer_close; -pub use crate::stdlib::snd_mixer_elem_next; -pub use crate::stdlib::snd_mixer_elem_t; -pub use crate::stdlib::snd_mixer_find_selem; -pub use crate::stdlib::snd_mixer_first_elem; -pub use crate::stdlib::snd_mixer_load; -pub use crate::stdlib::snd_mixer_open; -pub use crate::stdlib::snd_mixer_selem_channel_id_t; -pub use crate::stdlib::snd_mixer_selem_get_id; -pub use crate::stdlib::snd_mixer_selem_get_playback_dB_range; -pub use crate::stdlib::snd_mixer_selem_get_playback_volume; -pub use crate::stdlib::snd_mixer_selem_get_playback_volume_range; -pub use crate::stdlib::snd_mixer_selem_has_playback_switch; -pub use crate::stdlib::snd_mixer_selem_has_playback_volume; -pub use crate::stdlib::snd_mixer_selem_id_get_index; -pub use crate::stdlib::snd_mixer_selem_id_get_name; -pub use crate::stdlib::snd_mixer_selem_id_set_index; -pub use crate::stdlib::snd_mixer_selem_id_set_name; -pub use crate::stdlib::snd_mixer_selem_id_sizeof; -pub use crate::stdlib::snd_mixer_selem_id_t; -pub use crate::stdlib::snd_mixer_selem_register; -pub use crate::stdlib::snd_mixer_selem_regopt; -pub use crate::stdlib::snd_mixer_selem_regopt_abstract; -pub use crate::stdlib::snd_mixer_selem_set_playback_dB; -pub use crate::stdlib::snd_mixer_selem_set_playback_switch_all; -pub use crate::stdlib::snd_mixer_selem_set_playback_volume; -pub use crate::stdlib::snd_mixer_t; -pub use crate::stdlib::snd_output_stdio_attach; -pub use crate::stdlib::snd_output_t; -pub use crate::stdlib::snd_pcm_access_t; -pub use crate::stdlib::snd_pcm_avail_update; -pub use crate::stdlib::snd_pcm_channel_area_t; -pub use crate::stdlib::snd_pcm_close; -pub use crate::stdlib::snd_pcm_delay; -pub use crate::stdlib::snd_pcm_dump; -pub use crate::stdlib::snd_pcm_format_name; -pub use crate::stdlib::snd_pcm_format_t; -pub use crate::stdlib::snd_pcm_hw_params; -pub use crate::stdlib::snd_pcm_hw_params_any; -pub use crate::stdlib::snd_pcm_hw_params_get_buffer_size; -pub use crate::stdlib::snd_pcm_hw_params_get_period_size; -pub use crate::stdlib::snd_pcm_hw_params_set_access; -pub use crate::stdlib::snd_pcm_hw_params_set_buffer_size_near; -pub use crate::stdlib::snd_pcm_hw_params_set_buffer_time_near; -pub use crate::stdlib::snd_pcm_hw_params_set_channels; -pub use crate::stdlib::snd_pcm_hw_params_set_format; -pub use crate::stdlib::snd_pcm_hw_params_set_period_size_near; -pub use crate::stdlib::snd_pcm_hw_params_set_periods_near; -pub use crate::stdlib::snd_pcm_hw_params_set_rate; -pub use crate::stdlib::snd_pcm_hw_params_set_rate_resample; -pub use crate::stdlib::snd_pcm_hw_params_sizeof; -pub use crate::stdlib::snd_pcm_hw_params_t; -pub use crate::stdlib::snd_pcm_hw_params_test_rate; -pub use crate::stdlib::snd_pcm_mmap_begin; -pub use crate::stdlib::snd_pcm_mmap_commit; -pub use crate::stdlib::snd_pcm_open; -pub use crate::stdlib::snd_pcm_recover; -pub use crate::stdlib::snd_pcm_sframes_t; -pub use crate::stdlib::snd_pcm_start; -pub use crate::stdlib::snd_pcm_state; -pub use crate::stdlib::snd_pcm_state_t; -pub use crate::stdlib::snd_pcm_stream_t; -pub use crate::stdlib::snd_pcm_t; -pub use crate::stdlib::snd_pcm_uframes_t; -pub use crate::stdlib::snd_pcm_wait; -pub use crate::stdlib::snd_pcm_writei; -pub use crate::stdlib::snd_strerror; -use crate::stdlib::stderr; -use crate::stdlib::strcmp; -use crate::stdlib::strcpy; -use crate::stdlib::strdup; -use crate::stdlib::strerror; -use crate::stdlib::strlen; -use crate::stdlib::strncmp; -use crate::stdlib::strrchr; -use crate::stdlib::strtok; -use crate::stdlib::vfprintf; -pub use crate::stdlib::SND_MIXER_SABSTRACT_BASIC; -pub use crate::stdlib::SND_MIXER_SABSTRACT_NONE; -pub use crate::stdlib::SND_MIXER_SCHN_FRONT_CENTER; -pub use crate::stdlib::SND_MIXER_SCHN_FRONT_LEFT; -pub use crate::stdlib::SND_MIXER_SCHN_FRONT_RIGHT; -pub use crate::stdlib::SND_MIXER_SCHN_LAST; -pub use crate::stdlib::SND_MIXER_SCHN_MONO; -pub use crate::stdlib::SND_MIXER_SCHN_REAR_CENTER; -pub use crate::stdlib::SND_MIXER_SCHN_REAR_LEFT; -pub use crate::stdlib::SND_MIXER_SCHN_REAR_RIGHT; -pub use crate::stdlib::SND_MIXER_SCHN_SIDE_LEFT; -pub use crate::stdlib::SND_MIXER_SCHN_SIDE_RIGHT; -pub use crate::stdlib::SND_MIXER_SCHN_UNKNOWN; -pub use crate::stdlib::SND_MIXER_SCHN_WOOFER; -pub use crate::stdlib::SND_PCM_ACCESS_LAST; -pub use crate::stdlib::SND_PCM_ACCESS_MMAP_COMPLEX; -pub use crate::stdlib::SND_PCM_ACCESS_MMAP_INTERLEAVED; -pub use crate::stdlib::SND_PCM_ACCESS_MMAP_NONINTERLEAVED; -pub use crate::stdlib::SND_PCM_ACCESS_RW_INTERLEAVED; -pub use crate::stdlib::SND_PCM_ACCESS_RW_NONINTERLEAVED; -pub use crate::stdlib::SND_PCM_FORMAT_A_LAW; -pub use crate::stdlib::SND_PCM_FORMAT_DSD_U16_BE; -pub use crate::stdlib::SND_PCM_FORMAT_DSD_U16_LE; -pub use crate::stdlib::SND_PCM_FORMAT_DSD_U32_BE; -pub use crate::stdlib::SND_PCM_FORMAT_DSD_U32_LE; -pub use crate::stdlib::SND_PCM_FORMAT_DSD_U8; -pub use crate::stdlib::SND_PCM_FORMAT_FLOAT; -pub use crate::stdlib::SND_PCM_FORMAT_FLOAT64; -pub use crate::stdlib::SND_PCM_FORMAT_FLOAT64_BE; -pub use crate::stdlib::SND_PCM_FORMAT_FLOAT64_LE; -pub use crate::stdlib::SND_PCM_FORMAT_FLOAT_BE; -pub use crate::stdlib::SND_PCM_FORMAT_FLOAT_LE; -pub use crate::stdlib::SND_PCM_FORMAT_G723_24; -pub use crate::stdlib::SND_PCM_FORMAT_G723_24_1B; -pub use crate::stdlib::SND_PCM_FORMAT_G723_40; -pub use crate::stdlib::SND_PCM_FORMAT_G723_40_1B; -pub use crate::stdlib::SND_PCM_FORMAT_GSM; -pub use crate::stdlib::SND_PCM_FORMAT_IEC958_SUBFRAME; -pub use crate::stdlib::SND_PCM_FORMAT_IEC958_SUBFRAME_BE; -pub use crate::stdlib::SND_PCM_FORMAT_IEC958_SUBFRAME_LE; -pub use crate::stdlib::SND_PCM_FORMAT_IMA_ADPCM; -pub use crate::stdlib::SND_PCM_FORMAT_LAST; -pub use crate::stdlib::SND_PCM_FORMAT_MPEG; -pub use crate::stdlib::SND_PCM_FORMAT_MU_LAW; -pub use crate::stdlib::SND_PCM_FORMAT_S16; -pub use crate::stdlib::SND_PCM_FORMAT_S16_BE; -pub use crate::stdlib::SND_PCM_FORMAT_S16_LE; -pub use crate::stdlib::SND_PCM_FORMAT_S18_3BE; -pub use crate::stdlib::SND_PCM_FORMAT_S18_3LE; -pub use crate::stdlib::SND_PCM_FORMAT_S20; -pub use crate::stdlib::SND_PCM_FORMAT_S20_3BE; -pub use crate::stdlib::SND_PCM_FORMAT_S20_3LE; -pub use crate::stdlib::SND_PCM_FORMAT_S20_BE; -pub use crate::stdlib::SND_PCM_FORMAT_S20_LE; -pub use crate::stdlib::SND_PCM_FORMAT_S24; -pub use crate::stdlib::SND_PCM_FORMAT_S24_3BE; -pub use crate::stdlib::SND_PCM_FORMAT_S24_3LE; -pub use crate::stdlib::SND_PCM_FORMAT_S24_BE; -pub use crate::stdlib::SND_PCM_FORMAT_S24_LE; -pub use crate::stdlib::SND_PCM_FORMAT_S32; -pub use crate::stdlib::SND_PCM_FORMAT_S32_BE; -pub use crate::stdlib::SND_PCM_FORMAT_S32_LE; -pub use crate::stdlib::SND_PCM_FORMAT_S8; -pub use crate::stdlib::SND_PCM_FORMAT_SPECIAL; -pub use crate::stdlib::SND_PCM_FORMAT_U16; -pub use crate::stdlib::SND_PCM_FORMAT_U16_BE; -pub use crate::stdlib::SND_PCM_FORMAT_U16_LE; -pub use crate::stdlib::SND_PCM_FORMAT_U18_3BE; -pub use crate::stdlib::SND_PCM_FORMAT_U18_3LE; -pub use crate::stdlib::SND_PCM_FORMAT_U20; -pub use crate::stdlib::SND_PCM_FORMAT_U20_3BE; -pub use crate::stdlib::SND_PCM_FORMAT_U20_3LE; -pub use crate::stdlib::SND_PCM_FORMAT_U20_BE; -pub use crate::stdlib::SND_PCM_FORMAT_U20_LE; -pub use crate::stdlib::SND_PCM_FORMAT_U24; -pub use crate::stdlib::SND_PCM_FORMAT_U24_3BE; -pub use crate::stdlib::SND_PCM_FORMAT_U24_3LE; -pub use crate::stdlib::SND_PCM_FORMAT_U24_BE; -pub use crate::stdlib::SND_PCM_FORMAT_U24_LE; -pub use crate::stdlib::SND_PCM_FORMAT_U32; -pub use crate::stdlib::SND_PCM_FORMAT_U32_BE; -pub use crate::stdlib::SND_PCM_FORMAT_U32_LE; -pub use crate::stdlib::SND_PCM_FORMAT_U8; -pub use crate::stdlib::SND_PCM_FORMAT_UNKNOWN; -pub use crate::stdlib::SND_PCM_STATE_DISCONNECTED; -pub use crate::stdlib::SND_PCM_STATE_DRAINING; -pub use crate::stdlib::SND_PCM_STATE_LAST; -pub use crate::stdlib::SND_PCM_STATE_OPEN; -pub use crate::stdlib::SND_PCM_STATE_PAUSED; -pub use crate::stdlib::SND_PCM_STATE_PREPARED; -pub use crate::stdlib::SND_PCM_STATE_PRIVATE1; -pub use crate::stdlib::SND_PCM_STATE_RUNNING; -pub use crate::stdlib::SND_PCM_STATE_SETUP; -pub use crate::stdlib::SND_PCM_STATE_SUSPENDED; -pub use crate::stdlib::SND_PCM_STATE_XRUN; -pub use crate::stdlib::SND_PCM_STREAM_CAPTURE; -pub use crate::stdlib::SND_PCM_STREAM_LAST; -pub use crate::stdlib::SND_PCM_STREAM_PLAYBACK; - -use crate::stdlib::floor; -use crate::stdlib::log10; -use crate::stdlib::mallopt; -use crate::stdlib::mlockall; -use crate::stdlib::pthread_attr_destroy; -use crate::stdlib::pthread_attr_init; -use crate::stdlib::pthread_attr_setstacksize; -use crate::stdlib::pthread_create; -use crate::stdlib::pthread_join; -use crate::stdlib::pthread_mutex_lock; -use crate::stdlib::pthread_mutex_unlock; -use crate::stdlib::pthread_setschedparam; -use crate::stdlib::sleep; -use crate::stdlib::snd_device_name_free_hint; -use crate::stdlib::snd_device_name_get_hint; -use crate::stdlib::snd_device_name_hint; -use crate::stdlib::usleep; extern "C" { + pub type _IO_wide_data; + pub type _IO_codecvt; + pub type _IO_marker; + pub type _snd_mixer; + pub type _snd_mixer_selem_id; + pub type _snd_mixer_elem; + pub type _snd_mixer_class; + pub type _snd_pcm; + pub type _snd_pcm_hw_params; + pub type _snd_output; #[no_mangle] - pub static mut silencebuf: *mut crate::squeezelite_h::u8_t; + static mut stderr: *mut FILE; #[no_mangle] - pub static mut output: crate::squeezelite_h::outputstate; + fn fflush(__stream: *mut FILE) -> libc::c_int; #[no_mangle] - pub static mut outputbuf: *mut crate::squeezelite_h::buffer; + fn fprintf(_: *mut FILE, _: *const libc::c_char, _: ...) -> libc::c_int; + #[no_mangle] + fn printf(_: *const libc::c_char, _: ...) -> libc::c_int; + #[no_mangle] + fn vfprintf(_: *mut FILE, _: *const libc::c_char, _: ::std::ffi::VaList) + -> libc::c_int; + #[no_mangle] + fn atoi(__nptr: *const libc::c_char) -> libc::c_int; + #[no_mangle] + fn malloc(_: libc::c_ulong) -> *mut libc::c_void; + #[no_mangle] + fn free(__ptr: *mut libc::c_void); + #[no_mangle] + fn memcpy(_: *mut libc::c_void, _: *const libc::c_void, _: libc::c_ulong) + -> *mut libc::c_void; + #[no_mangle] + fn memset(_: *mut libc::c_void, _: libc::c_int, _: libc::c_ulong) + -> *mut libc::c_void; + #[no_mangle] + fn strcpy(_: *mut libc::c_char, _: *const libc::c_char) + -> *mut libc::c_char; + #[no_mangle] + fn strcmp(_: *const libc::c_char, _: *const libc::c_char) -> libc::c_int; + #[no_mangle] + fn strncmp(_: *const libc::c_char, _: *const libc::c_char, + _: libc::c_ulong) -> libc::c_int; + #[no_mangle] + fn strdup(_: *const libc::c_char) -> *mut libc::c_char; + #[no_mangle] + fn strrchr(_: *const libc::c_char, _: libc::c_int) -> *mut libc::c_char; + #[no_mangle] + fn strtok(_: *mut libc::c_char, _: *const libc::c_char) + -> *mut libc::c_char; + #[no_mangle] + fn strlen(_: *const libc::c_char) -> libc::c_ulong; + #[no_mangle] + fn strerror(_: libc::c_int) -> *mut libc::c_char; + #[no_mangle] + fn __errno_location() -> *mut libc::c_int; + #[no_mangle] + fn sleep(__seconds: libc::c_uint) -> libc::c_uint; + #[no_mangle] + fn usleep(__useconds: __useconds_t) -> libc::c_int; + #[no_mangle] + fn pthread_create(__newthread: *mut pthread_t, + __attr: *const pthread_attr_t, + __start_routine: + Option *mut libc::c_void>, + __arg: *mut libc::c_void) -> libc::c_int; + #[no_mangle] + fn pthread_join(__th: pthread_t, __thread_return: *mut *mut libc::c_void) + -> libc::c_int; + #[no_mangle] + fn pthread_attr_init(__attr: *mut pthread_attr_t) -> libc::c_int; + #[no_mangle] + fn pthread_attr_destroy(__attr: *mut pthread_attr_t) -> libc::c_int; + #[no_mangle] + fn pthread_attr_setstacksize(__attr: *mut pthread_attr_t, + __stacksize: size_t) -> libc::c_int; + #[no_mangle] + fn pthread_setschedparam(__target_thread: pthread_t, + __policy: libc::c_int, + __param: *const sched_param) -> libc::c_int; + #[no_mangle] + fn pthread_mutex_lock(__mutex: *mut pthread_mutex_t) -> libc::c_int; + #[no_mangle] + fn pthread_mutex_unlock(__mutex: *mut pthread_mutex_t) -> libc::c_int; + #[no_mangle] + fn logtime() -> *const libc::c_char; + #[no_mangle] + fn logprint(fmt: *const libc::c_char, _: ...); + #[no_mangle] + fn next_param(src: *mut libc::c_char, c: libc::c_char) + -> *mut libc::c_char; + #[no_mangle] + fn gettime_ms() -> u32_t; + #[no_mangle] + fn touch_memory(buf: *mut u8_t, size: size_t); + #[no_mangle] + fn output_init_common(level: log_level, device: *const libc::c_char, + output_buf_size: libc::c_uint, + rates: *mut libc::c_uint, idle: libc::c_uint); + #[no_mangle] + fn output_close_common(); + #[no_mangle] + fn _output_frames(avail: frames_t) -> frames_t; + #[no_mangle] + fn _apply_cross(outputbuf_0: *mut buffer, out_frames: frames_t, + cross_gain_in: s32_t, cross_gain_out: s32_t, + cross_ptr: *mut *mut s32_t); + #[no_mangle] + fn _scale_and_pack_frames(outputptr: *mut libc::c_void, + inputptr: *mut s32_t, cnt: frames_t, + gainL: s32_t, gainR: s32_t, + format: output_format); + #[no_mangle] + fn _apply_gain(outputbuf_0: *mut buffer, count: frames_t, gainL: s32_t, + gainR: s32_t); + #[no_mangle] + fn snd_pcm_open(pcm: *mut *mut snd_pcm_t, name: *const libc::c_char, + stream: snd_pcm_stream_t, mode: libc::c_int) + -> libc::c_int; + #[no_mangle] + fn snd_pcm_close(pcm: *mut snd_pcm_t) -> libc::c_int; + #[no_mangle] + fn snd_pcm_hw_params(pcm: *mut snd_pcm_t, + params: *mut snd_pcm_hw_params_t) -> libc::c_int; + #[no_mangle] + fn snd_pcm_start(pcm: *mut snd_pcm_t) -> libc::c_int; + #[no_mangle] + fn snd_pcm_state(pcm: *mut snd_pcm_t) -> snd_pcm_state_t; + #[no_mangle] + fn snd_pcm_delay(pcm: *mut snd_pcm_t, delayp: *mut snd_pcm_sframes_t) + -> libc::c_int; + #[no_mangle] + fn snd_pcm_avail_update(pcm: *mut snd_pcm_t) -> snd_pcm_sframes_t; + #[no_mangle] + fn snd_pcm_writei(pcm: *mut snd_pcm_t, buffer: *const libc::c_void, + size: snd_pcm_uframes_t) -> snd_pcm_sframes_t; + #[no_mangle] + fn snd_pcm_wait(pcm: *mut snd_pcm_t, timeout: libc::c_int) -> libc::c_int; + #[no_mangle] + fn snd_pcm_recover(pcm: *mut snd_pcm_t, err: libc::c_int, + silent: libc::c_int) -> libc::c_int; + #[no_mangle] + fn snd_pcm_hw_params_any(pcm: *mut snd_pcm_t, + params: *mut snd_pcm_hw_params_t) -> libc::c_int; + #[no_mangle] + fn snd_pcm_hw_params_sizeof() -> size_t; + #[no_mangle] + fn snd_pcm_hw_params_set_access(pcm: *mut snd_pcm_t, + params: *mut snd_pcm_hw_params_t, + _access: snd_pcm_access_t) -> libc::c_int; + #[no_mangle] + fn snd_pcm_hw_params_set_format(pcm: *mut snd_pcm_t, + params: *mut snd_pcm_hw_params_t, + val: snd_pcm_format_t) -> libc::c_int; + #[no_mangle] + fn snd_pcm_hw_params_set_channels(pcm: *mut snd_pcm_t, + params: *mut snd_pcm_hw_params_t, + val: libc::c_uint) -> libc::c_int; + #[no_mangle] + fn snd_pcm_hw_params_test_rate(pcm: *mut snd_pcm_t, + params: *mut snd_pcm_hw_params_t, + val: libc::c_uint, dir: libc::c_int) + -> libc::c_int; + #[no_mangle] + fn snd_pcm_hw_params_set_rate(pcm: *mut snd_pcm_t, + params: *mut snd_pcm_hw_params_t, + val: libc::c_uint, dir: libc::c_int) + -> libc::c_int; + #[no_mangle] + fn snd_pcm_hw_params_set_rate_resample(pcm: *mut snd_pcm_t, + params: *mut snd_pcm_hw_params_t, + val: libc::c_uint) -> libc::c_int; + #[no_mangle] + fn snd_pcm_hw_params_get_period_size(params: *const snd_pcm_hw_params_t, + frames: *mut snd_pcm_uframes_t, + dir: *mut libc::c_int) + -> libc::c_int; + #[no_mangle] + fn snd_pcm_hw_params_set_period_size_near(pcm: *mut snd_pcm_t, + params: + *mut snd_pcm_hw_params_t, + val: *mut snd_pcm_uframes_t, + dir: *mut libc::c_int) + -> libc::c_int; + #[no_mangle] + fn snd_pcm_hw_params_set_periods_near(pcm: *mut snd_pcm_t, + params: *mut snd_pcm_hw_params_t, + val: *mut libc::c_uint, + dir: *mut libc::c_int) + -> libc::c_int; + #[no_mangle] + fn snd_pcm_hw_params_set_buffer_time_near(pcm: *mut snd_pcm_t, + params: + *mut snd_pcm_hw_params_t, + val: *mut libc::c_uint, + dir: *mut libc::c_int) + -> libc::c_int; + #[no_mangle] + fn snd_pcm_hw_params_get_buffer_size(params: *const snd_pcm_hw_params_t, + val: *mut snd_pcm_uframes_t) + -> libc::c_int; + #[no_mangle] + fn snd_pcm_hw_params_set_buffer_size_near(pcm: *mut snd_pcm_t, + params: + *mut snd_pcm_hw_params_t, + val: *mut snd_pcm_uframes_t) + -> libc::c_int; + #[no_mangle] + fn snd_pcm_format_name(format: snd_pcm_format_t) -> *const libc::c_char; + #[no_mangle] + fn snd_mixer_find_selem(mixer: *mut snd_mixer_t, + id: *const snd_mixer_selem_id_t) + -> *mut snd_mixer_elem_t; + #[no_mangle] + fn snd_device_name_free_hint(hints: *mut *mut libc::c_void) + -> libc::c_int; + #[no_mangle] + fn snd_pcm_mmap_begin(pcm: *mut snd_pcm_t, + areas: *mut *const snd_pcm_channel_area_t, + offset: *mut snd_pcm_uframes_t, + frames: *mut snd_pcm_uframes_t) -> libc::c_int; + #[no_mangle] + fn snd_pcm_mmap_commit(pcm: *mut snd_pcm_t, offset: snd_pcm_uframes_t, + frames: snd_pcm_uframes_t) -> snd_pcm_sframes_t; + #[no_mangle] + fn snd_device_name_get_hint(hint: *const libc::c_void, + id: *const libc::c_char) -> *mut libc::c_char; + #[no_mangle] + fn snd_lib_error_set_handler(handler: snd_lib_error_handler_t) + -> libc::c_int; + #[no_mangle] + fn snd_device_name_hint(card: libc::c_int, iface: *const libc::c_char, + hints: *mut *mut *mut libc::c_void) + -> libc::c_int; + #[no_mangle] + fn snd_mixer_selem_id_set_index(obj: *mut snd_mixer_selem_id_t, + val: libc::c_uint); + #[no_mangle] + fn snd_mixer_selem_id_set_name(obj: *mut snd_mixer_selem_id_t, + val: *const libc::c_char); + #[no_mangle] + fn snd_mixer_close(mixer: *mut snd_mixer_t) -> libc::c_int; + #[no_mangle] + fn snd_mixer_selem_has_playback_switch(elem: *mut snd_mixer_elem_t) + -> libc::c_int; + #[no_mangle] + fn snd_mixer_selem_set_playback_switch_all(elem: *mut snd_mixer_elem_t, + value: libc::c_int) + -> libc::c_int; + #[no_mangle] + fn snd_mixer_selem_get_playback_dB_range(elem: *mut snd_mixer_elem_t, + min: *mut libc::c_long, + max: *mut libc::c_long) + -> libc::c_int; + #[no_mangle] + fn snd_mixer_selem_get_playback_volume_range(elem: *mut snd_mixer_elem_t, + min: *mut libc::c_long, + max: *mut libc::c_long) + -> libc::c_int; + #[no_mangle] + fn snd_output_stdio_attach(outputp: *mut *mut snd_output_t, fp: *mut FILE, + _close: libc::c_int) -> libc::c_int; + #[no_mangle] + fn snd_pcm_dump(pcm: *mut snd_pcm_t, out: *mut snd_output_t) + -> libc::c_int; + #[no_mangle] + fn snd_mixer_selem_set_playback_volume(elem: *mut snd_mixer_elem_t, + channel: + snd_mixer_selem_channel_id_t, + value: libc::c_long) + -> libc::c_int; + #[no_mangle] + fn snd_mixer_selem_set_playback_dB(elem: *mut snd_mixer_elem_t, + channel: snd_mixer_selem_channel_id_t, + value: libc::c_long, dir: libc::c_int) + -> libc::c_int; + #[no_mangle] + fn snd_mixer_selem_get_playback_volume(elem: *mut snd_mixer_elem_t, + channel: + snd_mixer_selem_channel_id_t, + value: *mut libc::c_long) + -> libc::c_int; + #[no_mangle] + fn snd_mixer_selem_id_sizeof() -> size_t; + #[no_mangle] + fn snd_mixer_open(mixer: *mut *mut snd_mixer_t, mode: libc::c_int) + -> libc::c_int; + #[no_mangle] + fn snd_mixer_attach(mixer: *mut snd_mixer_t, name: *const libc::c_char) + -> libc::c_int; + #[no_mangle] + fn snd_mixer_selem_register(mixer: *mut snd_mixer_t, + options: *mut snd_mixer_selem_regopt, + classp: *mut *mut snd_mixer_class_t) + -> libc::c_int; + #[no_mangle] + fn snd_mixer_load(mixer: *mut snd_mixer_t) -> libc::c_int; + #[no_mangle] + fn snd_strerror(errnum: libc::c_int) -> *const libc::c_char; + #[no_mangle] + fn snd_mixer_first_elem(mixer: *mut snd_mixer_t) -> *mut snd_mixer_elem_t; + #[no_mangle] + fn snd_mixer_elem_next(elem: *mut snd_mixer_elem_t) + -> *mut snd_mixer_elem_t; + #[no_mangle] + fn snd_mixer_selem_has_playback_volume(elem: *mut snd_mixer_elem_t) + -> libc::c_int; + #[no_mangle] + fn snd_mixer_selem_get_id(element: *mut snd_mixer_elem_t, + id: *mut snd_mixer_selem_id_t); + #[no_mangle] + fn snd_mixer_selem_id_get_name(obj: *const snd_mixer_selem_id_t) + -> *const libc::c_char; + #[no_mangle] + fn snd_mixer_selem_id_get_index(obj: *const snd_mixer_selem_id_t) + -> libc::c_uint; + #[no_mangle] + fn mlockall(__flags: libc::c_int) -> libc::c_int; + #[no_mangle] + fn mallopt(__param: libc::c_int, __val: libc::c_int) -> libc::c_int; + #[no_mangle] + fn log10(_: libc::c_double) -> libc::c_double; + #[no_mangle] + fn floor(_: libc::c_double) -> libc::c_double; + #[no_mangle] + static mut silencebuf: *mut u8_t; + #[no_mangle] + static mut output: outputstate; + #[no_mangle] + static mut outputbuf: *mut buffer; } -// ouput device - -#[repr(C)] +pub type __builtin_va_list = [__va_list_tag; 1]; #[derive(Copy, Clone)] -pub struct C2RustUnnamed_12 { +#[repr(C)] +pub struct __va_list_tag { + pub gp_offset: libc::c_uint, + pub fp_offset: libc::c_uint, + pub overflow_arg_area: *mut libc::c_void, + pub reg_save_area: *mut libc::c_void, +} +pub type size_t = libc::c_ulong; +pub type va_list = __builtin_va_list; +pub type __uint8_t = libc::c_uchar; +pub type __int32_t = libc::c_int; +pub type __uint32_t = libc::c_uint; +pub type __off_t = libc::c_long; +pub type __off64_t = libc::c_long; +pub type __useconds_t = libc::c_uint; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct _IO_FILE { + pub _flags: libc::c_int, + pub _IO_read_ptr: *mut libc::c_char, + pub _IO_read_end: *mut libc::c_char, + pub _IO_read_base: *mut libc::c_char, + pub _IO_write_base: *mut libc::c_char, + pub _IO_write_ptr: *mut libc::c_char, + pub _IO_write_end: *mut libc::c_char, + pub _IO_buf_base: *mut libc::c_char, + pub _IO_buf_end: *mut libc::c_char, + pub _IO_save_base: *mut libc::c_char, + pub _IO_backup_base: *mut libc::c_char, + pub _IO_save_end: *mut libc::c_char, + pub _markers: *mut _IO_marker, + pub _chain: *mut _IO_FILE, + pub _fileno: libc::c_int, + pub _flags2: libc::c_int, + pub _old_offset: __off_t, + pub _cur_column: libc::c_ushort, + pub _vtable_offset: libc::c_schar, + pub _shortbuf: [libc::c_char; 1], + pub _lock: *mut libc::c_void, + pub _offset: __off64_t, + pub _codecvt: *mut _IO_codecvt, + pub _wide_data: *mut _IO_wide_data, + pub _freeres_list: *mut _IO_FILE, + pub _freeres_buf: *mut libc::c_void, + pub __pad5: size_t, + pub _mode: libc::c_int, + pub _unused2: [libc::c_char; 20], +} +pub type _IO_lock_t = (); +pub type FILE = _IO_FILE; +pub type int32_t = __int32_t; +pub type u_int8_t = __uint8_t; +pub type u_int32_t = __uint32_t; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct __pthread_internal_list { + pub __prev: *mut __pthread_internal_list, + pub __next: *mut __pthread_internal_list, +} +pub type __pthread_list_t = __pthread_internal_list; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct __pthread_mutex_s { + pub __lock: libc::c_int, + pub __count: libc::c_uint, + pub __owner: libc::c_int, + pub __nusers: libc::c_uint, + pub __kind: libc::c_int, + pub __spins: libc::c_short, + pub __elision: libc::c_short, + pub __list: __pthread_list_t, +} +pub type pthread_t = libc::c_ulong; +#[derive(Copy, Clone)] +#[repr(C)] +pub union pthread_attr_t { + pub __size: [libc::c_char; 56], + pub __align: libc::c_long, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub union pthread_mutex_t { + pub __data: __pthread_mutex_s, + pub __size: [libc::c_char; 40], + pub __align: libc::c_long, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct sched_param { + pub sched_priority: libc::c_int, +} +pub type u8_t = u_int8_t; +pub type u32_t = u_int32_t; +pub type s32_t = int32_t; +pub type frames_t = u32_t; +pub type log_level = libc::c_uint; +pub const lSDEBUG: log_level = 4; +pub const lDEBUG: log_level = 3; +pub const lINFO: log_level = 2; +pub const lWARN: log_level = 1; +pub const lERROR: log_level = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct buffer { + pub buf: *mut u8_t, + pub readp: *mut u8_t, + pub writep: *mut u8_t, + pub wrap: *mut u8_t, + pub size: size_t, + pub base_size: size_t, + pub mutex: pthread_mutex_t, +} +pub type output_state = libc::c_int; +pub const OUTPUT_START_AT: output_state = 5; +pub const OUTPUT_SKIP_FRAMES: output_state = 4; +pub const OUTPUT_PAUSE_FRAMES: output_state = 3; +pub const OUTPUT_RUNNING: output_state = 2; +pub const OUTPUT_BUFFER: output_state = 1; +pub const OUTPUT_STOPPED: output_state = 0; +pub const OUTPUT_OFF: output_state = -1; +pub type output_format = libc::c_uint; +pub const S16_LE: output_format = 3; +pub const S24_3LE: output_format = 2; +pub const S24_LE: output_format = 1; +pub const S32_LE: output_format = 0; +pub type fade_state = libc::c_uint; +pub const FADE_ACTIVE: fade_state = 2; +pub const FADE_DUE: fade_state = 1; +pub const FADE_INACTIVE: fade_state = 0; +pub type fade_dir = libc::c_uint; +pub const FADE_CROSS: fade_dir = 3; +pub const FADE_DOWN: fade_dir = 2; +pub const FADE_UP: fade_dir = 1; +pub type fade_mode = libc::c_uint; +pub const FADE_INOUT: fade_mode = 4; +pub const FADE_OUT: fade_mode = 3; +pub const FADE_IN: fade_mode = 2; +pub const FADE_CROSSFADE: fade_mode = 1; +pub const FADE_NONE: fade_mode = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct outputstate { + pub state: output_state, + pub format: output_format, + pub device: *const libc::c_char, + pub buffer: libc::c_uint, + pub period: libc::c_uint, + pub track_started: bool, + pub write_cb: Option libc::c_int>, + pub start_frames: libc::c_uint, + pub frames_played: libc::c_uint, + pub frames_played_dmp: libc::c_uint, + pub current_sample_rate: libc::c_uint, + pub supported_rates: [libc::c_uint; 18], + pub default_sample_rate: libc::c_uint, + pub error_opening: bool, + pub device_frames: libc::c_uint, + pub updated: u32_t, + pub track_start_time: u32_t, + pub current_replay_gain: u32_t, + pub c2rust_unnamed: C2RustUnnamed, + pub next_sample_rate: libc::c_uint, + pub track_start: *mut u8_t, + pub gainL: u32_t, + pub gainR: u32_t, + pub invert: bool, + pub next_replay_gain: u32_t, + pub threshold: libc::c_uint, + pub fade: fade_state, + pub fade_start: *mut u8_t, + pub fade_end: *mut u8_t, + pub fade_dir: fade_dir, + pub fade_mode: fade_mode, + pub fade_secs: libc::c_uint, + pub rate_delay: libc::c_uint, + pub delay_active: bool, + pub stop_time: u32_t, + pub idle_to: u32_t, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub union C2RustUnnamed { + pub pause_frames: u32_t, + pub skip_frames: u32_t, + pub start_at: u32_t, +} +pub type snd_mixer_t = _snd_mixer; +pub type snd_mixer_selem_id_t = _snd_mixer_selem_id; +pub type snd_mixer_elem_t = _snd_mixer_elem; +pub type snd_mixer_class_t = _snd_mixer_class; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct snd_mixer_selem_regopt { + pub ver: libc::c_int, + pub abstract_0: snd_mixer_selem_regopt_abstract, + pub device: *const libc::c_char, + pub playback_pcm: *mut snd_pcm_t, + pub capture_pcm: *mut snd_pcm_t, +} +pub type snd_pcm_t = _snd_pcm; +pub type snd_mixer_selem_regopt_abstract = libc::c_uint; +pub const SND_MIXER_SABSTRACT_BASIC: snd_mixer_selem_regopt_abstract = 1; +pub const SND_MIXER_SABSTRACT_NONE: snd_mixer_selem_regopt_abstract = 0; +// ouput device +#[derive(Copy, Clone)] +#[repr(C)] +pub struct C2RustUnnamed_0 { pub device: [libc::c_char; 129], pub ctl: *mut libc::c_char, pub mixer_ctl: *mut libc::c_char, - pub format: crate::stdlib::snd_pcm_format_t, - pub buffer_size: crate::stdlib::snd_pcm_uframes_t, - pub period_size: crate::stdlib::snd_pcm_uframes_t, + pub format: snd_pcm_format_t, + pub buffer_size: snd_pcm_uframes_t, + pub period_size: snd_pcm_uframes_t, pub rate: libc::c_uint, pub mmap: bool, pub reopen: bool, - pub write_buf: *mut crate::squeezelite_h::u8_t, + pub write_buf: *mut u8_t, pub volume_mixer_name: *const libc::c_char, pub mixer_linear: bool, - pub mixer_elem: *mut crate::stdlib::snd_mixer_elem_t, - pub mixer_handle: *mut crate::stdlib::snd_mixer_t, + pub mixer_elem: *mut snd_mixer_elem_t, + pub mixer_handle: *mut snd_mixer_t, pub mixer_min: libc::c_long, pub mixer_max: libc::c_long, } - -static mut fmts: [crate::stdlib::snd_pcm_format_t; 5] = [ - crate::stdlib::SND_PCM_FORMAT_S32_LE, - crate::stdlib::SND_PCM_FORMAT_S24_LE, - crate::stdlib::SND_PCM_FORMAT_S24_3LE, - crate::stdlib::SND_PCM_FORMAT_S16_LE, - crate::stdlib::SND_PCM_FORMAT_UNKNOWN, -]; - -static mut alsa: C2RustUnnamed_12 = C2RustUnnamed_12 { - device: [0; 129], - ctl: 0 as *const libc::c_char as *mut libc::c_char, - mixer_ctl: 0 as *const libc::c_char as *mut libc::c_char, - format: crate::stdlib::SND_PCM_FORMAT_S8, - buffer_size: 0, - period_size: 0, - rate: 0, - mmap: false, - reopen: false, - write_buf: 0 as *const crate::squeezelite_h::u8_t as *mut crate::squeezelite_h::u8_t, - volume_mixer_name: 0 as *const libc::c_char, - mixer_linear: false, - mixer_elem: 0 as *const crate::stdlib::snd_mixer_elem_t as *mut crate::stdlib::snd_mixer_elem_t, - mixer_handle: 0 as *const crate::stdlib::snd_mixer_t as *mut crate::stdlib::snd_mixer_t, - mixer_min: 0, - mixer_max: 0, -}; - -static mut pcmp: *mut crate::stdlib::snd_pcm_t = - 0 as *const crate::stdlib::snd_pcm_t as *mut crate::stdlib::snd_pcm_t; - -static mut loglevel: crate::squeezelite_h::log_level = crate::squeezelite_h::lERROR; - +pub type snd_pcm_uframes_t = libc::c_ulong; +pub type snd_pcm_format_t = _snd_pcm_format; +pub type _snd_pcm_format = libc::c_int; +pub const SND_PCM_FORMAT_U20: _snd_pcm_format = 27; +pub const SND_PCM_FORMAT_S20: _snd_pcm_format = 25; +pub const SND_PCM_FORMAT_IEC958_SUBFRAME: _snd_pcm_format = 18; +pub const SND_PCM_FORMAT_FLOAT64: _snd_pcm_format = 16; +pub const SND_PCM_FORMAT_FLOAT: _snd_pcm_format = 14; +pub const SND_PCM_FORMAT_U32: _snd_pcm_format = 12; +pub const SND_PCM_FORMAT_S32: _snd_pcm_format = 10; +pub const SND_PCM_FORMAT_U24: _snd_pcm_format = 8; +pub const SND_PCM_FORMAT_S24: _snd_pcm_format = 6; +pub const SND_PCM_FORMAT_U16: _snd_pcm_format = 4; +pub const SND_PCM_FORMAT_S16: _snd_pcm_format = 2; +pub const SND_PCM_FORMAT_LAST: _snd_pcm_format = 52; +pub const SND_PCM_FORMAT_DSD_U32_BE: _snd_pcm_format = 52; +pub const SND_PCM_FORMAT_DSD_U16_BE: _snd_pcm_format = 51; +pub const SND_PCM_FORMAT_DSD_U32_LE: _snd_pcm_format = 50; +pub const SND_PCM_FORMAT_DSD_U16_LE: _snd_pcm_format = 49; +pub const SND_PCM_FORMAT_DSD_U8: _snd_pcm_format = 48; +pub const SND_PCM_FORMAT_G723_40_1B: _snd_pcm_format = 47; +pub const SND_PCM_FORMAT_G723_40: _snd_pcm_format = 46; +pub const SND_PCM_FORMAT_G723_24_1B: _snd_pcm_format = 45; +pub const SND_PCM_FORMAT_G723_24: _snd_pcm_format = 44; +pub const SND_PCM_FORMAT_U18_3BE: _snd_pcm_format = 43; +pub const SND_PCM_FORMAT_U18_3LE: _snd_pcm_format = 42; +pub const SND_PCM_FORMAT_S18_3BE: _snd_pcm_format = 41; +pub const SND_PCM_FORMAT_S18_3LE: _snd_pcm_format = 40; +pub const SND_PCM_FORMAT_U20_3BE: _snd_pcm_format = 39; +pub const SND_PCM_FORMAT_U20_3LE: _snd_pcm_format = 38; +pub const SND_PCM_FORMAT_S20_3BE: _snd_pcm_format = 37; +pub const SND_PCM_FORMAT_S20_3LE: _snd_pcm_format = 36; +pub const SND_PCM_FORMAT_U24_3BE: _snd_pcm_format = 35; +pub const SND_PCM_FORMAT_U24_3LE: _snd_pcm_format = 34; +pub const SND_PCM_FORMAT_S24_3BE: _snd_pcm_format = 33; +pub const SND_PCM_FORMAT_S24_3LE: _snd_pcm_format = 32; +pub const SND_PCM_FORMAT_SPECIAL: _snd_pcm_format = 31; +pub const SND_PCM_FORMAT_U20_BE: _snd_pcm_format = 28; +pub const SND_PCM_FORMAT_U20_LE: _snd_pcm_format = 27; +pub const SND_PCM_FORMAT_S20_BE: _snd_pcm_format = 26; +pub const SND_PCM_FORMAT_S20_LE: _snd_pcm_format = 25; +pub const SND_PCM_FORMAT_GSM: _snd_pcm_format = 24; +pub const SND_PCM_FORMAT_MPEG: _snd_pcm_format = 23; +pub const SND_PCM_FORMAT_IMA_ADPCM: _snd_pcm_format = 22; +pub const SND_PCM_FORMAT_A_LAW: _snd_pcm_format = 21; +pub const SND_PCM_FORMAT_MU_LAW: _snd_pcm_format = 20; +pub const SND_PCM_FORMAT_IEC958_SUBFRAME_BE: _snd_pcm_format = 19; +pub const SND_PCM_FORMAT_IEC958_SUBFRAME_LE: _snd_pcm_format = 18; +pub const SND_PCM_FORMAT_FLOAT64_BE: _snd_pcm_format = 17; +pub const SND_PCM_FORMAT_FLOAT64_LE: _snd_pcm_format = 16; +pub const SND_PCM_FORMAT_FLOAT_BE: _snd_pcm_format = 15; +pub const SND_PCM_FORMAT_FLOAT_LE: _snd_pcm_format = 14; +pub const SND_PCM_FORMAT_U32_BE: _snd_pcm_format = 13; +pub const SND_PCM_FORMAT_U32_LE: _snd_pcm_format = 12; +pub const SND_PCM_FORMAT_S32_BE: _snd_pcm_format = 11; +pub const SND_PCM_FORMAT_S32_LE: _snd_pcm_format = 10; +pub const SND_PCM_FORMAT_U24_BE: _snd_pcm_format = 9; +pub const SND_PCM_FORMAT_U24_LE: _snd_pcm_format = 8; +pub const SND_PCM_FORMAT_S24_BE: _snd_pcm_format = 7; +pub const SND_PCM_FORMAT_S24_LE: _snd_pcm_format = 6; +pub const SND_PCM_FORMAT_U16_BE: _snd_pcm_format = 5; +pub const SND_PCM_FORMAT_U16_LE: _snd_pcm_format = 4; +pub const SND_PCM_FORMAT_S16_BE: _snd_pcm_format = 3; +pub const SND_PCM_FORMAT_S16_LE: _snd_pcm_format = 2; +pub const SND_PCM_FORMAT_U8: _snd_pcm_format = 1; +pub const SND_PCM_FORMAT_S8: _snd_pcm_format = 0; +pub const SND_PCM_FORMAT_UNKNOWN: _snd_pcm_format = -1; +pub type snd_mixer_selem_channel_id_t = _snd_mixer_selem_channel_id; +pub type _snd_mixer_selem_channel_id = libc::c_int; +pub const SND_MIXER_SCHN_MONO: _snd_mixer_selem_channel_id = 0; +pub const SND_MIXER_SCHN_LAST: _snd_mixer_selem_channel_id = 31; +pub const SND_MIXER_SCHN_REAR_CENTER: _snd_mixer_selem_channel_id = 8; +pub const SND_MIXER_SCHN_SIDE_RIGHT: _snd_mixer_selem_channel_id = 7; +pub const SND_MIXER_SCHN_SIDE_LEFT: _snd_mixer_selem_channel_id = 6; +pub const SND_MIXER_SCHN_WOOFER: _snd_mixer_selem_channel_id = 5; +pub const SND_MIXER_SCHN_FRONT_CENTER: _snd_mixer_selem_channel_id = 4; +pub const SND_MIXER_SCHN_REAR_RIGHT: _snd_mixer_selem_channel_id = 3; +pub const SND_MIXER_SCHN_REAR_LEFT: _snd_mixer_selem_channel_id = 2; +pub const SND_MIXER_SCHN_FRONT_RIGHT: _snd_mixer_selem_channel_id = 1; +pub const SND_MIXER_SCHN_FRONT_LEFT: _snd_mixer_selem_channel_id = 0; +pub const SND_MIXER_SCHN_UNKNOWN: _snd_mixer_selem_channel_id = -1; +pub type snd_pcm_hw_params_t = _snd_pcm_hw_params; +pub type snd_pcm_stream_t = _snd_pcm_stream; +pub type _snd_pcm_stream = libc::c_uint; +pub const SND_PCM_STREAM_LAST: _snd_pcm_stream = 1; +pub const SND_PCM_STREAM_CAPTURE: _snd_pcm_stream = 1; +pub const SND_PCM_STREAM_PLAYBACK: _snd_pcm_stream = 0; +pub type snd_pcm_sframes_t = libc::c_long; +pub const SND_PCM_STATE_DISCONNECTED: _snd_pcm_state = 8; +pub type snd_pcm_state_t = _snd_pcm_state; +pub type _snd_pcm_state = libc::c_uint; +pub const SND_PCM_STATE_PRIVATE1: _snd_pcm_state = 1024; +pub const SND_PCM_STATE_LAST: _snd_pcm_state = 8; +pub const SND_PCM_STATE_SUSPENDED: _snd_pcm_state = 7; +pub const SND_PCM_STATE_PAUSED: _snd_pcm_state = 6; +pub const SND_PCM_STATE_DRAINING: _snd_pcm_state = 5; +pub const SND_PCM_STATE_XRUN: _snd_pcm_state = 4; +pub const SND_PCM_STATE_RUNNING: _snd_pcm_state = 3; +pub const SND_PCM_STATE_PREPARED: _snd_pcm_state = 2; +pub const SND_PCM_STATE_SETUP: _snd_pcm_state = 1; +pub const SND_PCM_STATE_OPEN: _snd_pcm_state = 0; +pub type snd_output_t = _snd_output; +pub type snd_pcm_access_t = _snd_pcm_access; +pub type _snd_pcm_access = libc::c_uint; +pub const SND_PCM_ACCESS_LAST: _snd_pcm_access = 4; +pub const SND_PCM_ACCESS_RW_NONINTERLEAVED: _snd_pcm_access = 4; +pub const SND_PCM_ACCESS_RW_INTERLEAVED: _snd_pcm_access = 3; +pub const SND_PCM_ACCESS_MMAP_COMPLEX: _snd_pcm_access = 2; +pub const SND_PCM_ACCESS_MMAP_NONINTERLEAVED: _snd_pcm_access = 1; +pub const SND_PCM_ACCESS_MMAP_INTERLEAVED: _snd_pcm_access = 0; +pub type snd_lib_error_handler_t + = + Option ()>; +pub type snd_pcm_channel_area_t = _snd_pcm_channel_area; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct _snd_pcm_channel_area { + pub addr: *mut libc::c_void, + pub first: libc::c_uint, + pub step: libc::c_uint, +} +static mut fmts: [snd_pcm_format_t; 5] = + [SND_PCM_FORMAT_S32_LE, SND_PCM_FORMAT_S24_LE, SND_PCM_FORMAT_S24_3LE, + SND_PCM_FORMAT_S16_LE, SND_PCM_FORMAT_UNKNOWN]; +static mut alsa: C2RustUnnamed_0 = + C2RustUnnamed_0{device: [0; 129], + ctl: 0 as *const libc::c_char as *mut libc::c_char, + mixer_ctl: 0 as *const libc::c_char as *mut libc::c_char, + format: SND_PCM_FORMAT_S8, + buffer_size: 0, + period_size: 0, + rate: 0, + mmap: false, + reopen: false, + write_buf: 0 as *const u8_t as *mut u8_t, + volume_mixer_name: 0 as *const libc::c_char, + mixer_linear: false, + mixer_elem: + 0 as *const snd_mixer_elem_t as *mut snd_mixer_elem_t, + mixer_handle: 0 as *const snd_mixer_t as *mut snd_mixer_t, + mixer_min: 0, + mixer_max: 0,}; +static mut pcmp: *mut snd_pcm_t = 0 as *const snd_pcm_t as *mut snd_pcm_t; +static mut loglevel: log_level = lERROR; static mut running: bool = 1 as libc::c_int != 0; - -unsafe extern "C" fn ctl4device(mut device: *const libc::c_char) -> *mut libc::c_char { - let mut ctl = 0 as *mut libc::c_char; - if crate::stdlib::strncmp( - device, - b"hw:\x00" as *const u8 as *const libc::c_char, - 3 as libc::c_int as libc::c_ulong, - ) == 0 - { - ctl = crate::stdlib::strdup(device) - } else if crate::stdlib::strncmp( - device, - b"plughw:\x00" as *const u8 as *const libc::c_char, - 7 as libc::c_int as libc::c_ulong, - ) == 0 - { - ctl = crate::stdlib::strdup(device.offset(4 as libc::c_int as isize)) +unsafe extern "C" fn ctl4device(mut device: *const libc::c_char) + -> *mut libc::c_char { + let mut ctl: *mut libc::c_char = 0 as *mut libc::c_char; + if strncmp(device, b"hw:\x00" as *const u8 as *const libc::c_char, + 3 as libc::c_int as libc::c_ulong) == 0 { + ctl = strdup(device) + } else if strncmp(device, + b"plughw:\x00" as *const u8 as *const libc::c_char, + 7 as libc::c_int as libc::c_ulong) == 0 { + ctl = strdup(device.offset(4 as libc::c_int as isize)) } if !ctl.is_null() { - let mut comma = 0 as *mut libc::c_char; - comma = crate::stdlib::strrchr(ctl, ',' as i32); - if !comma.is_null() { - *comma = '\u{0}' as i32 as libc::c_char - } - } else { - ctl = crate::stdlib::strdup(device) - } + let mut comma: *mut libc::c_char = 0 as *mut libc::c_char; + comma = strrchr(ctl, ',' as i32); + if !comma.is_null() { *comma = '\u{0}' as i32 as libc::c_char } + } else { ctl = strdup(device) } return ctl; } #[no_mangle] - pub unsafe extern "C" fn list_devices() { - let mut hints = 0 as *mut *mut libc::c_void; - let mut n = 0 as *mut *mut libc::c_void; - if crate::stdlib::snd_device_name_hint( - -(1 as libc::c_int), - b"pcm\x00" as *const u8 as *const libc::c_char, - &mut hints, - ) >= 0 as libc::c_int - { + let mut hints: *mut *mut libc::c_void = 0 as *mut *mut libc::c_void; + let mut n: *mut *mut libc::c_void = 0 as *mut *mut libc::c_void; + if snd_device_name_hint(-(1 as libc::c_int), + b"pcm\x00" as *const u8 as *const libc::c_char, + &mut hints) >= 0 as libc::c_int { n = hints; - crate::stdlib::printf(b"Output devices:\n\x00" as *const u8 as *const libc::c_char); + printf(b"Output devices:\n\x00" as *const u8 as *const libc::c_char); while !(*n).is_null() { - let mut name = crate::stdlib::snd_device_name_get_hint( - *n, - b"NAME\x00" as *const u8 as *const libc::c_char, - ); - let mut desc = crate::stdlib::snd_device_name_get_hint( - *n, - b"DESC\x00" as *const u8 as *const libc::c_char, - ); + let mut name: *mut libc::c_char = + snd_device_name_get_hint(*n, + b"NAME\x00" as *const u8 as + *const libc::c_char); + let mut desc: *mut libc::c_char = + snd_device_name_get_hint(*n, + b"DESC\x00" as *const u8 as + *const libc::c_char); if !name.is_null() { - crate::stdlib::printf(b" %-30s\x00" as *const u8 as *const libc::c_char, name); + printf(b" %-30s\x00" as *const u8 as *const libc::c_char, + name); } if !desc.is_null() { - let mut s1 = - crate::stdlib::strtok(desc, b"\n\x00" as *const u8 as *const libc::c_char); - let mut s2 = crate::stdlib::strtok( - 0 as *mut libc::c_char, - b"\n\x00" as *const u8 as *const libc::c_char, - ); + let mut s1: *mut libc::c_char = + strtok(desc, + b"\n\x00" as *const u8 as *const libc::c_char); + let mut s2: *mut libc::c_char = + strtok(0 as *mut libc::c_char, + b"\n\x00" as *const u8 as *const libc::c_char); if !s1.is_null() { - crate::stdlib::printf(b" - %s\x00" as *const u8 as *const libc::c_char, s1); + printf(b" - %s\x00" as *const u8 as *const libc::c_char, + s1); } if !s2.is_null() { - crate::stdlib::printf(b" - %s\x00" as *const u8 as *const libc::c_char, s2); + printf(b" - %s\x00" as *const u8 as *const libc::c_char, + s2); } } - crate::stdlib::printf(b"\n\x00" as *const u8 as *const libc::c_char); - if !name.is_null() { - crate::stdlib::free(name as *mut libc::c_void); - } - if !desc.is_null() { - crate::stdlib::free(desc as *mut libc::c_void); - } + printf(b"\n\x00" as *const u8 as *const libc::c_char); + if !name.is_null() { free(name as *mut libc::c_void); } + if !desc.is_null() { free(desc as *mut libc::c_void); } n = n.offset(1) } - crate::stdlib::snd_device_name_free_hint(hints); + snd_device_name_free_hint(hints); } - crate::stdlib::printf(b"\n\x00" as *const u8 as *const libc::c_char); + printf(b"\n\x00" as *const u8 as *const libc::c_char); } #[no_mangle] - pub unsafe extern "C" fn list_mixers(mut output_device: *const libc::c_char) { let mut err: libc::c_int = 0; - let mut handle = 0 as *mut crate::stdlib::snd_mixer_t; - let mut sid = 0 as *mut crate::stdlib::snd_mixer_selem_id_t; - let mut elem = 0 as *mut crate::stdlib::snd_mixer_elem_t; - let mut ctl = ctl4device(output_device); - let mut fresh0 = ::std::vec::from_elem(0, crate::stdlib::snd_mixer_selem_id_sizeof() as usize); - sid = fresh0.as_mut_ptr() as *mut crate::stdlib::snd_mixer_selem_id_t; - crate::stdlib::memset( - sid as *mut libc::c_void, - 0 as libc::c_int, - crate::stdlib::snd_mixer_selem_id_sizeof(), - ); - 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 listing mixers for: %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"list_mixers\x00")).as_ptr(), - 139 as libc::c_int, - output_device, - ); + let mut handle: *mut snd_mixer_t = 0 as *mut snd_mixer_t; + let mut sid: *mut snd_mixer_selem_id_t = 0 as *mut snd_mixer_selem_id_t; + let mut elem: *mut snd_mixer_elem_t = 0 as *mut snd_mixer_elem_t; + let mut ctl: *mut libc::c_char = ctl4device(output_device); + let mut fresh0 = + ::std::vec::from_elem(0, snd_mixer_selem_id_sizeof() as usize); + sid = fresh0.as_mut_ptr() as *mut snd_mixer_selem_id_t; + memset(sid as *mut libc::c_void, 0 as libc::c_int, + snd_mixer_selem_id_sizeof()); + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d listing mixers for: %s\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 12], + &[libc::c_char; 12]>(b"list_mixers\x00")).as_ptr(), + 139 as libc::c_int, output_device); } - err = crate::stdlib::snd_mixer_open(&mut handle, 0 as libc::c_int); + err = snd_mixer_open(&mut handle, 0 as libc::c_int); if err < 0 as libc::c_int { - crate::src::utils::logprint( - b"%s %s:%d open 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"list_mixers\x00")).as_ptr(), - 142 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); - return; + logprint(b"%s %s:%d open error: %s\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 12], + &[libc::c_char; 12]>(b"list_mixers\x00")).as_ptr(), + 142 as libc::c_int, snd_strerror(err)); + return } - err = crate::stdlib::snd_mixer_attach(handle, ctl); + err = snd_mixer_attach(handle, ctl); if err < 0 as libc::c_int { - crate::src::utils::logprint( - b"%s %s:%d attach 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"list_mixers\x00")).as_ptr(), - 146 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); - crate::stdlib::snd_mixer_close(handle); - crate::stdlib::free(ctl as *mut libc::c_void); - return; + logprint(b"%s %s:%d attach error: %s\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 12], + &[libc::c_char; 12]>(b"list_mixers\x00")).as_ptr(), + 146 as libc::c_int, snd_strerror(err)); + snd_mixer_close(handle); + free(ctl as *mut libc::c_void); + return } - crate::stdlib::free(ctl as *mut libc::c_void); - err = crate::stdlib::snd_mixer_selem_register( - handle, - 0 as *mut crate::stdlib::snd_mixer_selem_regopt, - 0 as *mut *mut crate::stdlib::snd_mixer_class_t, - ); + free(ctl as *mut libc::c_void); + err = + snd_mixer_selem_register(handle, 0 as *mut snd_mixer_selem_regopt, + 0 as *mut *mut snd_mixer_class_t); if err < 0 as libc::c_int { - crate::src::utils::logprint( - b"%s %s:%d register 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"list_mixers\x00")).as_ptr(), - 153 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); - crate::stdlib::snd_mixer_close(handle); - return; + logprint(b"%s %s:%d register error: %s\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 12], + &[libc::c_char; 12]>(b"list_mixers\x00")).as_ptr(), + 153 as libc::c_int, snd_strerror(err)); + snd_mixer_close(handle); + return } - err = crate::stdlib::snd_mixer_load(handle); + err = snd_mixer_load(handle); if err < 0 as libc::c_int { - crate::src::utils::logprint( - b"%s %s:%d load 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"list_mixers\x00")).as_ptr(), - 158 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); - crate::stdlib::snd_mixer_close(handle); - return; + logprint(b"%s %s:%d load error: %s\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 12], + &[libc::c_char; 12]>(b"list_mixers\x00")).as_ptr(), + 158 as libc::c_int, snd_strerror(err)); + snd_mixer_close(handle); + return } - crate::stdlib::printf( - b"Volume controls for %s\n\x00" as *const u8 as *const libc::c_char, - output_device, - ); - elem = crate::stdlib::snd_mixer_first_elem(handle); + printf(b"Volume controls for %s\n\x00" as *const u8 as + *const libc::c_char, output_device); + elem = snd_mixer_first_elem(handle); while !elem.is_null() { - if crate::stdlib::snd_mixer_selem_has_playback_volume(elem) != 0 { - crate::stdlib::snd_mixer_selem_get_id(elem, sid); - crate::stdlib::printf( - b" %s\x00" as *const u8 as *const libc::c_char, - crate::stdlib::snd_mixer_selem_id_get_name(sid), - ); - if crate::stdlib::snd_mixer_selem_id_get_index(sid) != 0 { - crate::stdlib::printf( - b",%d\x00" as *const u8 as *const libc::c_char, - crate::stdlib::snd_mixer_selem_id_get_index(sid), - ); + if snd_mixer_selem_has_playback_volume(elem) != 0 { + snd_mixer_selem_get_id(elem, sid); + printf(b" %s\x00" as *const u8 as *const libc::c_char, + snd_mixer_selem_id_get_name(sid)); + if snd_mixer_selem_id_get_index(sid) != 0 { + printf(b",%d\x00" as *const u8 as *const libc::c_char, + snd_mixer_selem_id_get_index(sid)); } - crate::stdlib::printf(b"\n\x00" as *const u8 as *const libc::c_char); + printf(b"\n\x00" as *const u8 as *const libc::c_char); } - elem = crate::stdlib::snd_mixer_elem_next(elem) + elem = snd_mixer_elem_next(elem) } - crate::stdlib::printf(b"\n\x00" as *const u8 as *const libc::c_char); - crate::stdlib::snd_mixer_close(handle); + printf(b"\n\x00" as *const u8 as *const libc::c_char); + snd_mixer_close(handle); } // LMS volume map for SqueezePlay sends values in range ~ -72..0 dB - -unsafe extern "C" fn set_mixer(mut setmax: bool, mut ldB: libc::c_float, mut rdB: libc::c_float) { +unsafe extern "C" fn set_mixer(mut setmax: bool, mut ldB: libc::c_float, + mut rdB: libc::c_float) { let mut err: libc::c_int = 0; let mut nleft: libc::c_long = 0; let mut nright: libc::c_long = 0; @@ -559,331 +865,261 @@ unsafe extern "C" fn set_mixer(mut setmax: bool, mut ldB: libc::c_float, mut rdB rraw = alsa.mixer_max; lraw = rraw } else { - lraw = ((if ldB > -(72 as libc::c_int) as libc::c_float { - (72 as libc::c_int as libc::c_double) + crate::stdlib::floor(ldB as libc::c_double) - } else { - 0 as libc::c_int as libc::c_double - }) / 72 as libc::c_int as libc::c_double - * (alsa.mixer_max - alsa.mixer_min) as libc::c_double - + alsa.mixer_min as libc::c_double) as libc::c_long; - rraw = ((if rdB > -(72 as libc::c_int) as libc::c_float { - (72 as libc::c_int as libc::c_double) + crate::stdlib::floor(rdB as libc::c_double) - } else { - 0 as libc::c_int as libc::c_double - }) / 72 as libc::c_int as libc::c_double - * (alsa.mixer_max - alsa.mixer_min) as libc::c_double - + alsa.mixer_min as libc::c_double) as libc::c_long + lraw = + ((if ldB > -(72 as libc::c_int) as libc::c_float { + (72 as libc::c_int as libc::c_double) + + floor(ldB as libc::c_double) + } else { 0 as libc::c_int as libc::c_double }) / + 72 as libc::c_int as libc::c_double * + (alsa.mixer_max - alsa.mixer_min) as libc::c_double + + alsa.mixer_min as libc::c_double) as libc::c_long; + rraw = + ((if rdB > -(72 as libc::c_int) as libc::c_float { + (72 as libc::c_int as libc::c_double) + + floor(rdB as libc::c_double) + } else { 0 as libc::c_int as libc::c_double }) / + 72 as libc::c_int as libc::c_double * + (alsa.mixer_max - alsa.mixer_min) as libc::c_double + + alsa.mixer_min as libc::c_double) as libc::c_long } - 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 setting vol raw [%ld..%ld]\n\x00" as *const u8 as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 10], &[libc::c_char; 10]>(b"set_mixer\x00")) - .as_ptr(), - 193 as libc::c_int, - alsa.mixer_min, - alsa.mixer_max, - ); + if loglevel as libc::c_uint >= lDEBUG as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d setting vol raw [%ld..%ld]\n\x00" as *const u8 + as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 10], + &[libc::c_char; 10]>(b"set_mixer\x00")).as_ptr(), + 193 as libc::c_int, alsa.mixer_min, alsa.mixer_max); } - err = crate::stdlib::snd_mixer_selem_set_playback_volume( - alsa.mixer_elem, - crate::stdlib::SND_MIXER_SCHN_FRONT_LEFT, - lraw, - ); + err = + snd_mixer_selem_set_playback_volume(alsa.mixer_elem, + SND_MIXER_SCHN_FRONT_LEFT, + lraw); if err < 0 as libc::c_int { - crate::src::utils::logprint( - b"%s %s:%d error setting left volume: %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"set_mixer\x00")) - .as_ptr(), - 195 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); + logprint(b"%s %s:%d error setting left volume: %s\n\x00" as + *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 10], + &[libc::c_char; 10]>(b"set_mixer\x00")).as_ptr(), + 195 as libc::c_int, snd_strerror(err)); } - err = crate::stdlib::snd_mixer_selem_set_playback_volume( - alsa.mixer_elem, - crate::stdlib::SND_MIXER_SCHN_FRONT_RIGHT, - rraw, - ); + err = + snd_mixer_selem_set_playback_volume(alsa.mixer_elem, + SND_MIXER_SCHN_FRONT_RIGHT, + rraw); if err < 0 as libc::c_int { - crate::src::utils::logprint( - b"%s %s:%d error setting right volume: %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"set_mixer\x00")) - .as_ptr(), - 198 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); + logprint(b"%s %s:%d error setting right volume: %s\n\x00" as + *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 10], + &[libc::c_char; 10]>(b"set_mixer\x00")).as_ptr(), + 198 as libc::c_int, snd_strerror(err)); } } else { // set db directly - 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 setting vol dB [%ld..%ld]\n\x00" as *const u8 as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 10], &[libc::c_char; 10]>(b"set_mixer\x00")) - .as_ptr(), - 202 as libc::c_int, - alsa.mixer_min, - alsa.mixer_max, - ); + if loglevel as libc::c_uint >= lDEBUG as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d setting vol dB [%ld..%ld]\n\x00" as *const u8 + as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 10], + &[libc::c_char; 10]>(b"set_mixer\x00")).as_ptr(), + 202 as libc::c_int, alsa.mixer_min, alsa.mixer_max); } if setmax { // set to 0dB if available as this should be max volume for music recored at max pcm values - if alsa.mixer_max >= 0 as libc::c_int as libc::c_long - && alsa.mixer_min <= 0 as libc::c_int as libc::c_long - { + if alsa.mixer_max >= 0 as libc::c_int as libc::c_long && + alsa.mixer_min <= 0 as libc::c_int as libc::c_long { rdB = 0 as libc::c_int as libc::c_float; ldB = rdB - } else { - rdB = alsa.mixer_max as libc::c_float; - ldB = rdB - } + } else { rdB = alsa.mixer_max as libc::c_float; ldB = rdB } } - err = crate::stdlib::snd_mixer_selem_set_playback_dB( - alsa.mixer_elem, - crate::stdlib::SND_MIXER_SCHN_FRONT_LEFT, - (100 as libc::c_int as libc::c_float * ldB) as libc::c_long, - 1 as libc::c_int, - ); + err = + snd_mixer_selem_set_playback_dB(alsa.mixer_elem, + SND_MIXER_SCHN_FRONT_LEFT, + (100 as libc::c_int as + libc::c_float * ldB) as + libc::c_long, + 1 as libc::c_int); if err < 0 as libc::c_int { - crate::src::utils::logprint( - b"%s %s:%d error setting left volume: %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"set_mixer\x00")) - .as_ptr(), - 212 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); + logprint(b"%s %s:%d error setting left volume: %s\n\x00" as + *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 10], + &[libc::c_char; 10]>(b"set_mixer\x00")).as_ptr(), + 212 as libc::c_int, snd_strerror(err)); } - err = crate::stdlib::snd_mixer_selem_set_playback_dB( - alsa.mixer_elem, - crate::stdlib::SND_MIXER_SCHN_FRONT_RIGHT, - (100 as libc::c_int as libc::c_float * rdB) as libc::c_long, - 1 as libc::c_int, - ); + err = + snd_mixer_selem_set_playback_dB(alsa.mixer_elem, + SND_MIXER_SCHN_FRONT_RIGHT, + (100 as libc::c_int as + libc::c_float * rdB) as + libc::c_long, + 1 as libc::c_int); if err < 0 as libc::c_int { - crate::src::utils::logprint( - b"%s %s:%d error setting right volume: %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"set_mixer\x00")) - .as_ptr(), - 215 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); + logprint(b"%s %s:%d error setting right volume: %s\n\x00" as + *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 10], + &[libc::c_char; 10]>(b"set_mixer\x00")).as_ptr(), + 215 as libc::c_int, snd_strerror(err)); } } - err = crate::stdlib::snd_mixer_selem_get_playback_volume( - alsa.mixer_elem, - crate::stdlib::SND_MIXER_SCHN_FRONT_LEFT, - &mut nleft, - ); + err = + snd_mixer_selem_get_playback_volume(alsa.mixer_elem, + SND_MIXER_SCHN_FRONT_LEFT, + &mut nleft); if err < 0 as libc::c_int { - crate::src::utils::logprint( - b"%s %s:%d error getting left vol: %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"set_mixer\x00")).as_ptr(), - 220 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); + logprint(b"%s %s:%d error getting left vol: %s\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 10], + &[libc::c_char; 10]>(b"set_mixer\x00")).as_ptr(), + 220 as libc::c_int, snd_strerror(err)); } - err = crate::stdlib::snd_mixer_selem_get_playback_volume( - alsa.mixer_elem, - crate::stdlib::SND_MIXER_SCHN_FRONT_RIGHT, - &mut nright, - ); + err = + snd_mixer_selem_get_playback_volume(alsa.mixer_elem, + SND_MIXER_SCHN_FRONT_RIGHT, + &mut nright); if err < 0 as libc::c_int { - crate::src::utils::logprint( - b"%s %s:%d error getting right vol: %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"set_mixer\x00")).as_ptr(), - 223 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); + logprint(b"%s %s:%d error getting right vol: %s\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 10], + &[libc::c_char; 10]>(b"set_mixer\x00")).as_ptr(), + 223 as libc::c_int, snd_strerror(err)); } - 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 %s left: %3.1fdB -> %ld right: %3.1fdB -> %ld\n\x00" as *const u8 - as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 10], &[libc::c_char; 10]>(b"set_mixer\x00")).as_ptr(), - 226 as libc::c_int, - alsa.volume_mixer_name, - ldB as libc::c_double, - nleft, - rdB as libc::c_double, - nright, - ); + if loglevel as libc::c_uint >= lDEBUG as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d %s left: %3.1fdB -> %ld right: %3.1fdB -> %ld\n\x00" + as *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 10], + &[libc::c_char; 10]>(b"set_mixer\x00")).as_ptr(), + 226 as libc::c_int, alsa.volume_mixer_name, + ldB as libc::c_double, nleft, rdB as libc::c_double, nright); }; } #[no_mangle] - -pub unsafe extern "C" fn set_volume(mut left: libc::c_uint, mut right: libc::c_uint) { +pub unsafe extern "C" fn set_volume(mut left: libc::c_uint, + mut right: libc::c_uint) { let mut ldB: libc::c_float = 0.; let mut rdB: libc::c_float = 0.; if alsa.volume_mixer_name.is_null() { - 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 setting internal gain left: %u right: %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"set_volume\x00")) - .as_ptr(), - 233 as libc::c_int, - left, - right, - ); + if loglevel as libc::c_uint >= lDEBUG as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d setting internal gain left: %u right: %u\n\x00" + as *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 11], + &[libc::c_char; 11]>(b"set_volume\x00")).as_ptr(), + 233 as libc::c_int, left, right); } - crate::stdlib::pthread_mutex_lock(&mut (*outputbuf).mutex); + pthread_mutex_lock(&mut (*outputbuf).mutex); output.gainL = left; output.gainR = right; - crate::stdlib::pthread_mutex_unlock(&mut (*outputbuf).mutex); - return; + pthread_mutex_unlock(&mut (*outputbuf).mutex); + return } else { - crate::stdlib::pthread_mutex_lock(&mut (*outputbuf).mutex); - output.gainL = 0x10000 as libc::c_int as crate::squeezelite_h::u32_t; - output.gainR = 0x10000 as libc::c_int as crate::squeezelite_h::u32_t; - crate::stdlib::pthread_mutex_unlock(&mut (*outputbuf).mutex); + pthread_mutex_lock(&mut (*outputbuf).mutex); + output.gainL = 0x10000 as libc::c_int as u32_t; + output.gainR = 0x10000 as libc::c_int as u32_t; + pthread_mutex_unlock(&mut (*outputbuf).mutex); } // convert 16.16 fixed point to dB - ldB = (20 as libc::c_int as libc::c_double - * crate::stdlib::log10((left as libc::c_float / 65536.0f32) as libc::c_double)) - as libc::c_float; - rdB = (20 as libc::c_int as libc::c_double - * crate::stdlib::log10((right as libc::c_float / 65536.0f32) as libc::c_double)) - as libc::c_float; + ldB = + (20 as libc::c_int as libc::c_double * + log10((left as libc::c_float / 65536.0f32) as libc::c_double)) as + libc::c_float; + rdB = + (20 as libc::c_int as libc::c_double * + log10((right as libc::c_float / 65536.0f32) as libc::c_double)) + as libc::c_float; set_mixer(0 as libc::c_int != 0, ldB, rdB); } - -unsafe extern "C" fn alsa_error_handler( - mut file: *const libc::c_char, - mut line: libc::c_int, - mut function: *const libc::c_char, - mut err: libc::c_int, - mut fmt: *const libc::c_char, - mut args: ... -) -> *mut libc::c_void { +unsafe extern "C" fn alsa_error_handler(mut file: *const libc::c_char, + mut line: libc::c_int, + mut function: *const libc::c_char, + mut err: libc::c_int, + mut fmt: *const libc::c_char, + mut args: ...) -> *mut libc::c_void { let mut args_0: ::std::ffi::VaListImpl; - if loglevel as libc::c_uint >= crate::squeezelite_h::lINFO as libc::c_int as libc::c_uint - && err == 0 as libc::c_int - || loglevel as libc::c_uint >= crate::squeezelite_h::lDEBUG as libc::c_int as libc::c_uint - { - crate::stdlib::fprintf( - crate::stdlib::stderr, - b"%s ALSA %s:%d \x00" as *const u8 as *const libc::c_char, - crate::src::utils::logtime(), - function, - line, - ); + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint && + err == 0 as libc::c_int || + loglevel as libc::c_uint >= lDEBUG as libc::c_int as libc::c_uint { + fprintf(stderr, + b"%s ALSA %s:%d \x00" as *const u8 as *const libc::c_char, + logtime(), function, line); args_0 = args.clone(); - crate::stdlib::vfprintf(crate::stdlib::stderr, fmt, args_0.as_va_list()); - crate::stdlib::fprintf( - crate::stdlib::stderr, - b"\n\x00" as *const u8 as *const libc::c_char, - ); - crate::stdlib::fflush(crate::stdlib::stderr); + vfprintf(stderr, fmt, args_0.as_va_list()); + fprintf(stderr, b"\n\x00" as *const u8 as *const libc::c_char); + fflush(stderr); } return 0 as *mut libc::c_void; } - unsafe extern "C" fn alsa_close() { let mut err: libc::c_int = 0; - err = crate::stdlib::snd_pcm_close(pcmp); + err = snd_pcm_close(pcmp); if err < 0 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 snd_pcm_close 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"alsa_close\x00")) - .as_ptr(), - 268 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d snd_pcm_close error: %s\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 11], + &[libc::c_char; 11]>(b"alsa_close\x00")).as_ptr(), + 268 as libc::c_int, snd_strerror(err)); } }; } #[no_mangle] - -pub unsafe extern "C" fn test_open( - mut device: *const libc::c_char, - mut rates: *mut libc::c_uint, - mut userdef_rates: bool, -) -> bool { +pub unsafe extern "C" fn test_open(mut device: *const libc::c_char, + mut rates: *mut libc::c_uint, + mut userdef_rates: bool) -> bool { let mut err: libc::c_int = 0; - let mut pcm = 0 as *mut crate::stdlib::snd_pcm_t; - let mut hw_params = 0 as *mut crate::stdlib::snd_pcm_hw_params_t; - let mut fresh1 = ::std::vec::from_elem(0, crate::stdlib::snd_pcm_hw_params_sizeof() as usize); - hw_params = fresh1.as_mut_ptr() as *mut crate::stdlib::snd_pcm_hw_params_t; - crate::stdlib::memset( - hw_params as *mut libc::c_void, - 0 as libc::c_int, - crate::stdlib::snd_pcm_hw_params_sizeof(), - ); + let mut pcm: *mut snd_pcm_t = 0 as *mut snd_pcm_t; + let mut hw_params: *mut snd_pcm_hw_params_t = + 0 as *mut snd_pcm_hw_params_t; + let mut fresh1 = + ::std::vec::from_elem(0, snd_pcm_hw_params_sizeof() as usize); + hw_params = fresh1.as_mut_ptr() as *mut snd_pcm_hw_params_t; + memset(hw_params as *mut libc::c_void, 0 as libc::c_int, + snd_pcm_hw_params_sizeof()); // open device - err = crate::stdlib::snd_pcm_open( - &mut pcm, - device, - crate::stdlib::SND_PCM_STREAM_PLAYBACK, - 0 as libc::c_int, - ); + err = + snd_pcm_open(&mut pcm, device, SND_PCM_STREAM_PLAYBACK, + 0 as libc::c_int); if err < 0 as libc::c_int { - crate::src::utils::logprint( - b"%s %s:%d playback open error: %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"test_open\x00")).as_ptr(), - 281 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); - return 0 as libc::c_int != 0; + logprint(b"%s %s:%d playback open error: %s\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 10], + &[libc::c_char; 10]>(b"test_open\x00")).as_ptr(), + 281 as libc::c_int, snd_strerror(err)); + return 0 as libc::c_int != 0 } // get max params - err = crate::stdlib::snd_pcm_hw_params_any(pcm, hw_params); + err = snd_pcm_hw_params_any(pcm, hw_params); if err < 0 as libc::c_int { - crate::src::utils::logprint( - b"%s %s:%d hwparam init error: %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"test_open\x00")).as_ptr(), - 287 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); - return 0 as libc::c_int != 0; + logprint(b"%s %s:%d hwparam init error: %s\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 10], + &[libc::c_char; 10]>(b"test_open\x00")).as_ptr(), + 287 as libc::c_int, snd_strerror(err)); + return 0 as libc::c_int != 0 } // find supported sample rates to enable client side resampling of non supported rates if !userdef_rates { let mut i: libc::c_uint = 0; let mut ind: libc::c_uint = 0; - let mut ref_0: [libc::c_uint; 18] = [ - 768000 as libc::c_int as libc::c_uint, - 705600 as libc::c_int as libc::c_uint, - 384000 as libc::c_int as libc::c_uint, - 352800 as libc::c_int as libc::c_uint, - 192000 as libc::c_int as libc::c_uint, - 176400 as libc::c_int as libc::c_uint, - 96000 as libc::c_int as libc::c_uint, - 88200 as libc::c_int as libc::c_uint, - 48000 as libc::c_int as libc::c_uint, - 44100 as libc::c_int as libc::c_uint, - 32000 as libc::c_int as libc::c_uint, - 24000 as libc::c_int as libc::c_uint, - 22500 as libc::c_int as libc::c_uint, - 16000 as libc::c_int as libc::c_uint, - 12000 as libc::c_int as libc::c_uint, - 11025 as libc::c_int as libc::c_uint, - 8000 as libc::c_int as libc::c_uint, - 0 as libc::c_int as libc::c_uint, - ]; + let mut ref_0: [libc::c_uint; 18] = + [768000 as libc::c_int as libc::c_uint, + 705600 as libc::c_int as libc::c_uint, + 384000 as libc::c_int as libc::c_uint, + 352800 as libc::c_int as libc::c_uint, + 192000 as libc::c_int as libc::c_uint, + 176400 as libc::c_int as libc::c_uint, + 96000 as libc::c_int as libc::c_uint, + 88200 as libc::c_int as libc::c_uint, + 48000 as libc::c_int as libc::c_uint, + 44100 as libc::c_int as libc::c_uint, + 32000 as libc::c_int as libc::c_uint, + 24000 as libc::c_int as libc::c_uint, + 22500 as libc::c_int as libc::c_uint, + 16000 as libc::c_int as libc::c_uint, + 12000 as libc::c_int as libc::c_uint, + 11025 as libc::c_int as libc::c_uint, + 8000 as libc::c_int as libc::c_uint, + 0 as libc::c_int as libc::c_uint]; i = 0 as libc::c_int as libc::c_uint; ind = 0 as libc::c_int as libc::c_uint; while ref_0[i as usize] != 0 { - if crate::stdlib::snd_pcm_hw_params_test_rate( - pcm, - hw_params, - ref_0[i as usize], - 0 as libc::c_int, - ) == 0 as libc::c_int - { + if snd_pcm_hw_params_test_rate(pcm, hw_params, ref_0[i as usize], + 0 as libc::c_int) == + 0 as libc::c_int { let fresh2 = ind; ind = ind.wrapping_add(1); *rates.offset(fresh2 as isize) = ref_0[i as usize] @@ -891,925 +1127,707 @@ pub unsafe extern "C" fn test_open( i = i.wrapping_add(1) } } - err = crate::stdlib::snd_pcm_close(pcm); + err = snd_pcm_close(pcm); if err < 0 as libc::c_int { - crate::src::utils::logprint( - b"%s %s:%d snd_pcm_close error: %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"test_open\x00")).as_ptr(), - 304 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); - return 0 as libc::c_int != 0; + logprint(b"%s %s:%d snd_pcm_close error: %s\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 10], + &[libc::c_char; 10]>(b"test_open\x00")).as_ptr(), + 304 as libc::c_int, snd_strerror(err)); + return 0 as libc::c_int != 0 } return 1 as libc::c_int != 0; } - unsafe extern "C" fn pcm_probe(mut device: *const libc::c_char) -> bool { let mut err: libc::c_int = 0; - let mut pcm = 0 as *mut crate::stdlib::snd_pcm_t; - err = crate::stdlib::snd_pcm_open( - &mut pcm, - device, - crate::stdlib::SND_PCM_STREAM_PLAYBACK, - 0 as libc::c_int, - ); + let mut pcm: *mut snd_pcm_t = 0 as *mut snd_pcm_t; + err = + snd_pcm_open(&mut pcm, device, SND_PCM_STREAM_PLAYBACK, + 0 as libc::c_int); + if err < 0 as libc::c_int { return 0 as libc::c_int != 0 } + err = snd_pcm_close(pcm); if err < 0 as libc::c_int { - return 0 as libc::c_int != 0; - } - err = crate::stdlib::snd_pcm_close(pcm); - if err < 0 as libc::c_int { - crate::src::utils::logprint( - b"%s %s:%d snd_pcm_close error: %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"pcm_probe\x00")).as_ptr(), - 320 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); + logprint(b"%s %s:%d snd_pcm_close error: %s\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 10], + &[libc::c_char; 10]>(b"pcm_probe\x00")).as_ptr(), + 320 as libc::c_int, snd_strerror(err)); } return 1 as libc::c_int != 0; } - -unsafe extern "C" fn alsa_open( - mut device: *const libc::c_char, - mut sample_rate: libc::c_uint, - mut alsa_buffer: libc::c_uint, - mut alsa_period: libc::c_uint, -) -> libc::c_int { +unsafe extern "C" fn alsa_open(mut device: *const libc::c_char, + mut sample_rate: libc::c_uint, + mut alsa_buffer: libc::c_uint, + mut alsa_period: libc::c_uint) -> libc::c_int { let mut err: libc::c_int = 0; - let mut hw_params = 0 as *mut crate::stdlib::snd_pcm_hw_params_t; - let mut fresh3 = ::std::vec::from_elem(0, crate::stdlib::snd_pcm_hw_params_sizeof() as usize); - hw_params = fresh3.as_mut_ptr() as *mut crate::stdlib::snd_pcm_hw_params_t; - crate::stdlib::memset( - hw_params as *mut libc::c_void, - 0 as libc::c_int, - crate::stdlib::snd_pcm_hw_params_sizeof(), - ); + let mut hw_params: *mut snd_pcm_hw_params_t = + 0 as *mut snd_pcm_hw_params_t; + let mut fresh3 = + ::std::vec::from_elem(0, snd_pcm_hw_params_sizeof() as usize); + hw_params = fresh3.as_mut_ptr() as *mut snd_pcm_hw_params_t; + memset(hw_params as *mut libc::c_void, 0 as libc::c_int, + snd_pcm_hw_params_sizeof()); // close if already open - if !pcmp.is_null() { - alsa_close(); - } + if !pcmp.is_null() { alsa_close(); } // reset params alsa.rate = 0 as libc::c_int as libc::c_uint; - alsa.period_size = 0 as libc::c_int as crate::stdlib::snd_pcm_uframes_t; - crate::stdlib::strcpy(alsa.device.as_mut_ptr(), device); - if crate::stdlib::strlen(device) - > (128 as libc::c_int - 4 as libc::c_int - 1 as libc::c_int) as libc::c_ulong - { - crate::src::utils::logprint( - b"%s %s:%d device name too long: %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"alsa_open\x00")).as_ptr(), - 347 as libc::c_int, - device, - ); - return -(1 as libc::c_int); + alsa.period_size = 0 as libc::c_int as snd_pcm_uframes_t; + strcpy(alsa.device.as_mut_ptr(), device); + if strlen(device) > + (128 as libc::c_int - 4 as libc::c_int - 1 as libc::c_int) as + libc::c_ulong { + logprint(b"%s %s:%d device name too long: %s\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 10], + &[libc::c_char; 10]>(b"alsa_open\x00")).as_ptr(), + 347 as libc::c_int, device); + return -(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 opening device at: %u\n\x00" as *const u8 as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 10], &[libc::c_char; 10]>(b"alsa_open\x00")).as_ptr(), - 351 as libc::c_int, - sample_rate, - ); + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d opening device at: %u\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 10], + &[libc::c_char; 10]>(b"alsa_open\x00")).as_ptr(), + 351 as libc::c_int, sample_rate); } let mut retry: bool = false; - loop { + loop { // open device - err = crate::stdlib::snd_pcm_open( - &mut pcmp, - alsa.device.as_mut_ptr(), - crate::stdlib::SND_PCM_STREAM_PLAYBACK, - 0 as libc::c_int, - ); + err = + snd_pcm_open(&mut pcmp, alsa.device.as_mut_ptr(), + SND_PCM_STREAM_PLAYBACK, 0 as libc::c_int); if err < 0 as libc::c_int { - crate::src::utils::logprint( - b"%s %s:%d playback open error: %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"alsa_open\x00")) - .as_ptr(), - 357 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); - return err; + logprint(b"%s %s:%d playback open error: %s\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 10], + &[libc::c_char; 10]>(b"alsa_open\x00")).as_ptr(), + 357 as libc::c_int, snd_strerror(err)); + return err } // init params - crate::stdlib::memset( - hw_params as *mut libc::c_void, - 0 as libc::c_int, - crate::stdlib::snd_pcm_hw_params_sizeof(), - ); - err = crate::stdlib::snd_pcm_hw_params_any(pcmp, hw_params); + memset(hw_params as *mut libc::c_void, 0 as libc::c_int, + snd_pcm_hw_params_sizeof()); + err = snd_pcm_hw_params_any(pcmp, hw_params); if err < 0 as libc::c_int { - crate::src::utils::logprint( - b"%s %s:%d hwparam init error: %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"alsa_open\x00")) - .as_ptr(), - 364 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); - return err; + logprint(b"%s %s:%d hwparam init error: %s\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 10], + &[libc::c_char; 10]>(b"alsa_open\x00")).as_ptr(), + 364 as libc::c_int, snd_strerror(err)); + return err } // open hw: devices without resampling, if sample rate fails try plughw: with resampling - let mut hw = crate::stdlib::strncmp( - alsa.device.as_mut_ptr(), - b"hw:\x00" as *const u8 as *const libc::c_char, - 3 as libc::c_int as libc::c_ulong, - ) == 0; + let mut hw: bool = + strncmp(alsa.device.as_mut_ptr(), + b"hw:\x00" as *const u8 as *const libc::c_char, + 3 as libc::c_int as libc::c_ulong) == 0; retry = 0 as libc::c_int != 0; - err = crate::stdlib::snd_pcm_hw_params_set_rate_resample( - pcmp, - hw_params, - !hw as libc::c_int as libc::c_uint, - ); + err = + snd_pcm_hw_params_set_rate_resample(pcmp, hw_params, + !hw as libc::c_int as + libc::c_uint); if err < 0 as libc::c_int { - crate::src::utils::logprint( - b"%s %s:%d resampling setup failed: %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"alsa_open\x00")) - .as_ptr(), - 373 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); - return err; + logprint(b"%s %s:%d resampling setup failed: %s\n\x00" as + *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 10], + &[libc::c_char; 10]>(b"alsa_open\x00")).as_ptr(), + 373 as libc::c_int, snd_strerror(err)); + return err } - err = crate::stdlib::snd_pcm_hw_params_set_rate( - pcmp, - hw_params, - sample_rate, - 0 as libc::c_int, - ); + err = + snd_pcm_hw_params_set_rate(pcmp, hw_params, sample_rate, + 0 as libc::c_int); if err < 0 as libc::c_int { if hw { - crate::stdlib::strcpy( - alsa.device.as_mut_ptr().offset(4 as libc::c_int as isize), - device, - ); - crate::stdlib::memcpy( - alsa.device.as_mut_ptr() as *mut libc::c_void, - b"plug\x00" as *const u8 as *const libc::c_char as *const libc::c_void, - 4 as libc::c_int as libc::c_ulong, - ); - 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 reopening device %s in plug mode as %s for resampling\n\x00" - as *const u8 as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 10], &[libc::c_char; 10]>( - b"alsa_open\x00", - )) - .as_ptr(), - 381 as libc::c_int, - device, - alsa.device.as_mut_ptr(), - ); + strcpy(alsa.device.as_mut_ptr().offset(4 as libc::c_int as + isize), device); + memcpy(alsa.device.as_mut_ptr() as *mut libc::c_void, + b"plug\x00" as *const u8 as *const libc::c_char as + *const libc::c_void, + 4 as libc::c_int as libc::c_ulong); + if loglevel as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d reopening device %s in plug mode as %s for resampling\n\x00" + as *const u8 as *const libc::c_char, + logtime(), + (*::std::mem::transmute::<&[u8; 10], + &[libc::c_char; 10]>(b"alsa_open\x00")).as_ptr(), + 381 as libc::c_int, device, + alsa.device.as_mut_ptr()); } - crate::stdlib::snd_pcm_close(pcmp); + snd_pcm_close(pcmp); retry = 1 as libc::c_int != 0 } } - if !retry { - break; - } + if !retry { break ; } } - // set access - if !alsa.mmap - || crate::stdlib::snd_pcm_hw_params_set_access( - pcmp, - hw_params, - crate::stdlib::SND_PCM_ACCESS_MMAP_INTERLEAVED, - ) < 0 as libc::c_int - { - err = crate::stdlib::snd_pcm_hw_params_set_access( - pcmp, - hw_params, - crate::stdlib::SND_PCM_ACCESS_RW_INTERLEAVED, - ); + // set access + if !alsa.mmap || + snd_pcm_hw_params_set_access(pcmp, hw_params, + SND_PCM_ACCESS_MMAP_INTERLEAVED) < + 0 as libc::c_int { + err = + snd_pcm_hw_params_set_access(pcmp, hw_params, + SND_PCM_ACCESS_RW_INTERLEAVED); if err < 0 as libc::c_int { - crate::src::utils::logprint( - b"%s %s:%d access type not available: %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"alsa_open\x00")) - .as_ptr(), - 392 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); - return err; + logprint(b"%s %s:%d access type not available: %s\n\x00" as + *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 10], + &[libc::c_char; 10]>(b"alsa_open\x00")).as_ptr(), + 392 as libc::c_int, snd_strerror(err)); + return err } alsa.mmap = 0 as libc::c_int != 0 } // set the sample format - let mut fmt = if alsa.format as libc::c_int != 0 { - &mut alsa.format - } else { - fmts.as_mut_ptr() - }; - loop { - if crate::stdlib::snd_pcm_hw_params_set_format(pcmp, hw_params, *fmt) >= 0 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 opened device %s using format: %s sample rate: %u mmap: %u\n\x00" - as *const u8 as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 10], &[libc::c_char; 10]>(b"alsa_open\x00")) - .as_ptr(), - 422 as libc::c_int, - alsa.device.as_mut_ptr(), - crate::stdlib::snd_pcm_format_name(*fmt), - sample_rate, - alsa.mmap as libc::c_int, - ); + let mut fmt: *mut snd_pcm_format_t = + if alsa.format as libc::c_int != 0 { + &mut alsa.format + } else { fmts.as_mut_ptr() }; + loop { + if snd_pcm_hw_params_set_format(pcmp, hw_params, *fmt) >= + 0 as libc::c_int { + if loglevel as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d opened device %s using format: %s sample rate: %u mmap: %u\n\x00" + as *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 10], + &[libc::c_char; 10]>(b"alsa_open\x00")).as_ptr(), + 422 as libc::c_int, alsa.device.as_mut_ptr(), + snd_pcm_format_name(*fmt), sample_rate, + alsa.mmap as libc::c_int); } alsa.format = *fmt; - break; + break ; } else { if alsa.format as u64 != 0 { - crate::src::utils::logprint( - b"%s %s:%d unable to open audio device requested format: %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"alsa_open\x00")) - .as_ptr(), - 427 as libc::c_int, - crate::stdlib::snd_pcm_format_name(alsa.format), - ); - return -(1 as libc::c_int); + logprint(b"%s %s:%d unable to open audio device requested format: %s\n\x00" + as *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 10], + &[libc::c_char; 10]>(b"alsa_open\x00")).as_ptr(), + 427 as libc::c_int, + snd_pcm_format_name(alsa.format)); + return -(1 as libc::c_int) } fmt = fmt.offset(1); - if *fmt as libc::c_int == crate::stdlib::SND_PCM_FORMAT_UNKNOWN as libc::c_int { - crate::src::utils::logprint( - b"%s %s:%d unable to open audio device with any supported format\n\x00" - as *const u8 as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 10], &[libc::c_char; 10]>(b"alsa_open\x00")) - .as_ptr(), - 432 as libc::c_int, - ); - return -(1 as libc::c_int); + if *fmt as libc::c_int == SND_PCM_FORMAT_UNKNOWN as libc::c_int { + logprint(b"%s %s:%d unable to open audio device with any supported format\n\x00" + as *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 10], + &[libc::c_char; 10]>(b"alsa_open\x00")).as_ptr(), + 432 as libc::c_int); + return -(1 as libc::c_int) } - if !(*fmt as libc::c_int != crate::stdlib::SND_PCM_FORMAT_UNKNOWN as libc::c_int) { - break; + if !(*fmt as libc::c_int != SND_PCM_FORMAT_UNKNOWN as libc::c_int) + { + break ; } } } // set the output format to be used by _scale_and_pack match alsa.format as libc::c_int { - 10 => output.format = crate::squeezelite_h::S32_LE, - 6 => output.format = crate::squeezelite_h::S24_LE, - 32 => output.format = crate::squeezelite_h::S24_3LE, - 2 => output.format = crate::squeezelite_h::S16_LE, - _ => {} + 10 => { output.format = S32_LE } + 6 => { output.format = S24_LE } + 32 => { output.format = S24_3LE } + 2 => { output.format = S16_LE } + _ => { } } // set channels - err = crate::stdlib::snd_pcm_hw_params_set_channels( - pcmp, - hw_params, - 2 as libc::c_int as libc::c_uint, - ); + err = + snd_pcm_hw_params_set_channels(pcmp, hw_params, + 2 as libc::c_int as libc::c_uint); if err < 0 as libc::c_int { - crate::src::utils::logprint( - b"%s %s:%d channel count not available: %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"alsa_open\x00")).as_ptr(), - 465 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); - return err; + logprint(b"%s %s:%d channel count not available: %s\n\x00" as + *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 10], + &[libc::c_char; 10]>(b"alsa_open\x00")).as_ptr(), + 465 as libc::c_int, snd_strerror(err)); + return err } // set period size - value of < 50 treated as period count, otherwise size in bytes if alsa_period < 50 as libc::c_int as libc::c_uint { - let mut count = alsa_period; - err = crate::stdlib::snd_pcm_hw_params_set_periods_near( - pcmp, - hw_params, - &mut count, - 0 as *mut libc::c_int, - ); + let mut count: libc::c_uint = alsa_period; + err = + snd_pcm_hw_params_set_periods_near(pcmp, hw_params, &mut count, + 0 as *mut libc::c_int); if err < 0 as libc::c_int { - crate::src::utils::logprint( - b"%s %s:%d unable to set period count %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"alsa_open\x00")) - .as_ptr(), - 473 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); - return err; + logprint(b"%s %s:%d unable to set period count %s\n\x00" as + *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 10], + &[libc::c_char; 10]>(b"alsa_open\x00")).as_ptr(), + 473 as libc::c_int, snd_strerror(err)); + return err } } else { - let mut size = alsa_period as crate::stdlib::snd_pcm_uframes_t; - let mut dir = 0 as libc::c_int; - err = crate::stdlib::snd_pcm_hw_params_set_period_size_near( - pcmp, hw_params, &mut size, &mut dir, - ); + let mut size: snd_pcm_uframes_t = alsa_period as snd_pcm_uframes_t; + let mut dir: libc::c_int = 0 as libc::c_int; + err = + snd_pcm_hw_params_set_period_size_near(pcmp, hw_params, &mut size, + &mut dir); if err < 0 as libc::c_int { - crate::src::utils::logprint( - b"%s %s:%d unable to set period size %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"alsa_open\x00")) - .as_ptr(), - 480 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); - return err; + logprint(b"%s %s:%d unable to set period size %s\n\x00" as + *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 10], + &[libc::c_char; 10]>(b"alsa_open\x00")).as_ptr(), + 480 as libc::c_int, snd_strerror(err)); + return err } } // set buffer size - value of < 500 treated as buffer time in ms, otherwise size in bytes if alsa_buffer < 500 as libc::c_int as libc::c_uint { - let mut time = alsa_buffer.wrapping_mul(1000 as libc::c_int as libc::c_uint); - let mut dir_0 = 0 as libc::c_int; - err = crate::stdlib::snd_pcm_hw_params_set_buffer_time_near( - pcmp, hw_params, &mut time, &mut dir_0, - ); + let mut time: libc::c_uint = + alsa_buffer.wrapping_mul(1000 as libc::c_int as libc::c_uint); + let mut dir_0: libc::c_int = 0 as libc::c_int; + err = + snd_pcm_hw_params_set_buffer_time_near(pcmp, hw_params, &mut time, + &mut dir_0); if err < 0 as libc::c_int { - crate::src::utils::logprint( - b"%s %s:%d unable to set buffer time %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"alsa_open\x00")) - .as_ptr(), - 490 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); - return err; + logprint(b"%s %s:%d unable to set buffer time %s\n\x00" as + *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 10], + &[libc::c_char; 10]>(b"alsa_open\x00")).as_ptr(), + 490 as libc::c_int, snd_strerror(err)); + return err } } else { - let mut size_0 = alsa_buffer as crate::stdlib::snd_pcm_uframes_t; - err = crate::stdlib::snd_pcm_hw_params_set_buffer_size_near(pcmp, hw_params, &mut size_0); + let mut size_0: snd_pcm_uframes_t = alsa_buffer as snd_pcm_uframes_t; + err = + snd_pcm_hw_params_set_buffer_size_near(pcmp, hw_params, + &mut size_0); if err < 0 as libc::c_int { - crate::src::utils::logprint( - b"%s %s:%d unable to set buffer size %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"alsa_open\x00")) - .as_ptr(), - 496 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); - return err; + logprint(b"%s %s:%d unable to set buffer size %s\n\x00" as + *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 10], + &[libc::c_char; 10]>(b"alsa_open\x00")).as_ptr(), + 496 as libc::c_int, snd_strerror(err)); + return err } } // get period_size - err = crate::stdlib::snd_pcm_hw_params_get_period_size( - hw_params, - &mut alsa.period_size, - 0 as *mut libc::c_int, - ); + err = + snd_pcm_hw_params_get_period_size(hw_params, &mut alsa.period_size, + 0 as *mut libc::c_int); if err < 0 as libc::c_int { - crate::src::utils::logprint( - b"%s %s:%d unable to get period size: %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"alsa_open\x00")).as_ptr(), - 503 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); - return err; + logprint(b"%s %s:%d unable to get period size: %s\n\x00" as *const u8 + as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 10], + &[libc::c_char; 10]>(b"alsa_open\x00")).as_ptr(), + 503 as libc::c_int, snd_strerror(err)); + return err } // get buffer_size - err = crate::stdlib::snd_pcm_hw_params_get_buffer_size(hw_params, &mut alsa.buffer_size); + err = snd_pcm_hw_params_get_buffer_size(hw_params, &mut alsa.buffer_size); if err < 0 as libc::c_int { - crate::src::utils::logprint( - b"%s %s:%d unable to get buffer size: %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"alsa_open\x00")).as_ptr(), - 509 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); - return err; + logprint(b"%s %s:%d unable to get buffer size: %s\n\x00" as *const u8 + as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 10], + &[libc::c_char; 10]>(b"alsa_open\x00")).as_ptr(), + 509 as libc::c_int, snd_strerror(err)); + return err } - 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 buffer: %u period: %u -> buffer size: %u period size: %u\n\x00" as *const u8 - as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 10], &[libc::c_char; 10]>(b"alsa_open\x00")).as_ptr(), - 513 as libc::c_int, - alsa_buffer, - alsa_period, - alsa.buffer_size, - alsa.period_size, - ); + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d buffer: %u period: %u -> buffer size: %u period size: %u\n\x00" + as *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 10], + &[libc::c_char; 10]>(b"alsa_open\x00")).as_ptr(), + 513 as libc::c_int, alsa_buffer, alsa_period, + alsa.buffer_size, alsa.period_size); } // ensure we have two buffer sizes of samples before starting output - output.start_frames = alsa - .buffer_size - .wrapping_mul(2 as libc::c_int as libc::c_ulong) as libc::c_uint; + output.start_frames = + alsa.buffer_size.wrapping_mul(2 as libc::c_int as libc::c_ulong) as + libc::c_uint; // create an intermediate buffer for non mmap case for all but NATIVE_FORMAT - // this is used to pack samples into the output format before calling writei - if !alsa.mmap - && alsa.write_buf.is_null() - && alsa.format as libc::c_int != crate::stdlib::SND_PCM_FORMAT_S32_LE as libc::c_int - { - alsa.write_buf = crate::stdlib::malloc( - alsa.buffer_size - .wrapping_mul(8 as libc::c_int as libc::c_ulong), - ) as *mut crate::squeezelite_h::u8_t; + // this is used to pack samples into the output format before calling writei + if !alsa.mmap && alsa.write_buf.is_null() && + alsa.format as libc::c_int != SND_PCM_FORMAT_S32_LE as libc::c_int + { + alsa.write_buf = + malloc(alsa.buffer_size.wrapping_mul(8 as libc::c_int as + libc::c_ulong)) as + *mut u8_t; if alsa.write_buf.is_null() { - crate::src::utils::logprint( - b"%s %s:%d unable to malloc write_buf\n\x00" as *const u8 as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 10], &[libc::c_char; 10]>(b"alsa_open\x00")) - .as_ptr(), - 523 as libc::c_int, - ); - return -(1 as libc::c_int); + logprint(b"%s %s:%d unable to malloc write_buf\n\x00" as *const u8 + as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 10], + &[libc::c_char; 10]>(b"alsa_open\x00")).as_ptr(), + 523 as libc::c_int); + return -(1 as libc::c_int) } } // set params - err = crate::stdlib::snd_pcm_hw_params(pcmp, hw_params); + err = snd_pcm_hw_params(pcmp, hw_params); if err < 0 as libc::c_int { - crate::src::utils::logprint( - b"%s %s:%d unable to set hw params: %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"alsa_open\x00")).as_ptr(), - 530 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); - return err; + logprint(b"%s %s:%d unable to set hw params: %s\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 10], + &[libc::c_char; 10]>(b"alsa_open\x00")).as_ptr(), + 530 as libc::c_int, snd_strerror(err)); + return err } // dump info - if loglevel as libc::c_uint == crate::squeezelite_h::lSDEBUG as libc::c_int as libc::c_uint { - static mut debug_output: *mut crate::stdlib::snd_output_t = - 0 as *const crate::stdlib::snd_output_t as *mut crate::stdlib::snd_output_t; - crate::stdlib::snd_output_stdio_attach( - &mut debug_output, - crate::stdlib::stderr, - 0 as libc::c_int, - ); - crate::stdlib::snd_pcm_dump(pcmp, debug_output); + if loglevel as libc::c_uint == lSDEBUG as libc::c_int as libc::c_uint { + static mut debug_output: *mut snd_output_t = + 0 as *const snd_output_t as *mut snd_output_t; + snd_output_stdio_attach(&mut debug_output, stderr, 0 as libc::c_int); + snd_pcm_dump(pcmp, debug_output); } // this indicates we have opened the device ok alsa.rate = sample_rate; return 0 as libc::c_int; } - -unsafe extern "C" fn _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 areas = 0 as *const crate::stdlib::snd_pcm_channel_area_t; - let mut offset: crate::stdlib::snd_pcm_uframes_t = 0; - let mut outputptr = 0 as *mut libc::c_void; - let mut inputptr = 0 as *mut crate::squeezelite_h::s32_t; +unsafe extern "C" fn _write_frames(mut out_frames: frames_t, + mut silence: bool, mut gainL: s32_t, + mut gainR: s32_t, mut cross_gain_in: s32_t, + mut cross_gain_out: s32_t, + mut cross_ptr: *mut *mut s32_t) + -> libc::c_int { + let mut areas: *const snd_pcm_channel_area_t = + 0 as *const snd_pcm_channel_area_t; + let mut offset: snd_pcm_uframes_t = 0; + let mut outputptr: *mut libc::c_void = 0 as *mut libc::c_void; + let mut inputptr: *mut s32_t = 0 as *mut s32_t; let mut err: libc::c_int = 0; if alsa.mmap { - let mut alsa_frames = out_frames as crate::stdlib::snd_pcm_uframes_t; - crate::stdlib::snd_pcm_avail_update(pcmp); - err = crate::stdlib::snd_pcm_mmap_begin(pcmp, &mut areas, &mut offset, &mut alsa_frames); + let mut alsa_frames: snd_pcm_uframes_t = + out_frames as snd_pcm_uframes_t; + snd_pcm_avail_update(pcmp); + err = + snd_pcm_mmap_begin(pcmp, &mut areas, &mut offset, + &mut alsa_frames); 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 error from mmap_begin: %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"_write_frames\x00", - )) - .as_ptr(), - 565 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); + if loglevel as libc::c_uint >= + lWARN as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d error from mmap_begin: %s\n\x00" as + *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 14], + &[libc::c_char; 14]>(b"_write_frames\x00")).as_ptr(), + 565 as libc::c_int, snd_strerror(err)); } - return -(1 as libc::c_int); + return -(1 as libc::c_int) } - out_frames = alsa_frames as crate::squeezelite_h::frames_t + out_frames = alsa_frames as frames_t } if !silence { // applying cross fade is delayed until this point as mmap_begin can change out_frames - 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, - ); + if output.fade as libc::c_uint == + FADE_ACTIVE as libc::c_int as libc::c_uint && + output.fade_dir as libc::c_uint == + FADE_CROSS as libc::c_int as libc::c_uint && + !(*cross_ptr).is_null() { + _apply_cross(outputbuf, out_frames, cross_gain_in, cross_gain_out, + cross_ptr); } } - inputptr = if silence as libc::c_int != 0 { - silencebuf - } else { - (*outputbuf).readp - } as *mut crate::squeezelite_h::s32_t; - if alsa.mmap as libc::c_int != 0 - || alsa.format as libc::c_int != crate::stdlib::SND_PCM_FORMAT_S32_LE as libc::c_int - { - outputptr = if alsa.mmap as libc::c_int != 0 { - (*areas.offset(0 as libc::c_int as isize)).addr.offset( - ((*areas.offset(0 as libc::c_int as isize)).first as libc::c_ulong) - .wrapping_add(offset.wrapping_mul( - (*areas.offset(0 as libc::c_int as isize)).step as libc::c_ulong, - )) - .wrapping_div(8 as libc::c_int as libc::c_ulong) as isize, - ) - } else { - alsa.write_buf as *mut libc::c_void - }; - crate::src::output_pack::_scale_and_pack_frames( - outputptr, - inputptr, - out_frames, - gainL, - gainR, - output.format, - ); + inputptr = + if silence as libc::c_int != 0 { + silencebuf + } else { (*outputbuf).readp } as *mut s32_t; + if alsa.mmap as libc::c_int != 0 || + alsa.format as libc::c_int != SND_PCM_FORMAT_S32_LE as libc::c_int + { + outputptr = + if alsa.mmap as libc::c_int != 0 { + (*areas.offset(0 as libc::c_int as + isize)).addr.offset(((*areas.offset(0 as + libc::c_int + as + isize)).first + as + libc::c_ulong).wrapping_add(offset.wrapping_mul((*areas.offset(0 + as + libc::c_int + as + isize)).step + as + libc::c_ulong)).wrapping_div(8 + as + libc::c_int + as + libc::c_ulong) + as isize) + } else { alsa.write_buf as *mut libc::c_void }; + _scale_and_pack_frames(outputptr, inputptr, out_frames, gainL, gainR, + output.format); } else { outputptr = inputptr as *mut libc::c_void; if !silence { - if gainL != 0x10000 as libc::c_int || gainR != 0x10000 as libc::c_int { - crate::squeezelite_h::_apply_gain(outputbuf, out_frames, gainL, gainR); + if gainL != 0x10000 as libc::c_int || + gainR != 0x10000 as libc::c_int { + _apply_gain(outputbuf, out_frames, gainL, gainR); } } } if alsa.mmap { - let mut w = crate::stdlib::snd_pcm_mmap_commit( - pcmp, - offset, - out_frames as crate::stdlib::snd_pcm_uframes_t, - ); - if w < 0 as libc::c_int as libc::c_long || w != out_frames as libc::c_long { - 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 mmap_commit error\n\x00" as *const u8 as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 14], &[libc::c_char; 14]>( - b"_write_frames\x00", - )) - .as_ptr(), - 615 as libc::c_int, - ); + let mut w: snd_pcm_sframes_t = + snd_pcm_mmap_commit(pcmp, offset, + out_frames as snd_pcm_uframes_t); + if w < 0 as libc::c_int as libc::c_long || + w != out_frames as libc::c_long { + if loglevel as libc::c_uint >= + lWARN as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d mmap_commit error\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 14], + &[libc::c_char; 14]>(b"_write_frames\x00")).as_ptr(), + 615 as libc::c_int); } - return -(1 as libc::c_int); + return -(1 as libc::c_int) } } else { - let mut w_0 = crate::stdlib::snd_pcm_writei( - pcmp, - outputptr, - out_frames as crate::stdlib::snd_pcm_uframes_t, - ); + let mut w_0: snd_pcm_sframes_t = + snd_pcm_writei(pcmp, outputptr, out_frames as snd_pcm_uframes_t); if w_0 < 0 as libc::c_int as libc::c_long { //if (w != -EAGAIN && ((err = snd_pcm_recover(pcmp, w, 1)) < 0)) { - err = crate::stdlib::snd_pcm_recover(pcmp, w_0 as libc::c_int, 1 as libc::c_int); + err = snd_pcm_recover(pcmp, w_0 as libc::c_int, 1 as libc::c_int); if err < 0 as libc::c_int { - static mut recover_count: libc::c_uint = 0 as libc::c_int as libc::c_uint; - if loglevel as libc::c_uint - >= crate::squeezelite_h::lWARN as libc::c_int as libc::c_uint - { + static mut recover_count: libc::c_uint = + 0 as libc::c_int as libc::c_uint; + if loglevel as libc::c_uint >= + lWARN as libc::c_int as libc::c_uint { recover_count = recover_count.wrapping_add(1); - crate::src::utils::logprint( - b"%s %s:%d recover failed: %s [%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"_write_frames\x00", - )) - .as_ptr(), - 626 as libc::c_int, - crate::stdlib::snd_strerror(err), - recover_count, - ); + logprint(b"%s %s:%d recover failed: %s [%u]\n\x00" as + *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 14], + &[libc::c_char; 14]>(b"_write_frames\x00")).as_ptr(), + 626 as libc::c_int, snd_strerror(err), + recover_count); } if recover_count >= 10 as libc::c_int as libc::c_uint { recover_count = 0 as libc::c_int as libc::c_uint; alsa_close(); - pcmp = 0 as *mut crate::stdlib::snd_pcm_t + pcmp = 0 as *mut snd_pcm_t } } - return -(1 as libc::c_int); + return -(1 as libc::c_int) } else { if w_0 != out_frames as libc::c_long { - 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 writei only wrote %u of %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"_write_frames\x00", - )) - .as_ptr(), - 636 as libc::c_int, - w_0, - out_frames, - ); + if loglevel as libc::c_uint >= + lWARN as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d writei only wrote %u of %u\n\x00" as + *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 14], + &[libc::c_char; 14]>(b"_write_frames\x00")).as_ptr(), + 636 as libc::c_int, w_0, out_frames); } } - out_frames = w_0 as crate::squeezelite_h::frames_t + out_frames = w_0 as frames_t } } return out_frames as libc::c_int; } - -unsafe extern "C" fn output_thread(mut arg: *mut libc::c_void) -> *mut libc::c_void { - let mut start = 1 as libc::c_int != 0; - let mut output_off = - output.state as libc::c_int == crate::squeezelite_h::OUTPUT_OFF as libc::c_int; - let mut probe_device = !arg.is_null(); +unsafe extern "C" fn output_thread(mut arg: *mut libc::c_void) + -> *mut libc::c_void { + let mut start: bool = 1 as libc::c_int != 0; + let mut output_off: bool = + output.state as libc::c_int == OUTPUT_OFF as libc::c_int; + let mut probe_device: bool = !arg.is_null(); let mut err: libc::c_int = 0; while running { // disabled output - player is off while output_off { - crate::stdlib::usleep(100000 as libc::c_int as crate::stdlib::__useconds_t); - crate::stdlib::pthread_mutex_lock(&mut (*outputbuf).mutex); + usleep(100000 as libc::c_int as __useconds_t); + pthread_mutex_lock(&mut (*outputbuf).mutex); output_off = - output.state as libc::c_int == crate::squeezelite_h::OUTPUT_OFF as libc::c_int; - crate::stdlib::pthread_mutex_unlock(&mut (*outputbuf).mutex); - if !running { - return 0 as *mut libc::c_void; - } + output.state as libc::c_int == OUTPUT_OFF as libc::c_int; + pthread_mutex_unlock(&mut (*outputbuf).mutex); + if !running { return 0 as *mut libc::c_void } } // wait until device returns - to allow usb audio devices to be turned off if probe_device { while !pcm_probe(output.device) { - 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 waiting for device %s to return\n\x00" as *const u8 - as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 14], &[libc::c_char; 14]>( - b"output_thread\x00", - )) - .as_ptr(), - 665 as libc::c_int, - output.device, - ); + if loglevel as libc::c_uint >= + lDEBUG as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d waiting for device %s to return\n\x00" + as *const u8 as *const libc::c_char, + logtime(), + (*::std::mem::transmute::<&[u8; 14], + &[libc::c_char; 14]>(b"output_thread\x00")).as_ptr(), + 665 as libc::c_int, output.device); } - crate::stdlib::sleep(5 as libc::c_int as libc::c_uint); + sleep(5 as libc::c_int as libc::c_uint); } probe_device = 0 as libc::c_int != 0 } if pcmp.is_null() || alsa.rate != output.current_sample_rate { - 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 open output device: %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"output_thread\x00", - )) - .as_ptr(), - 687 as libc::c_int, - output.device, - ); + if loglevel as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d open output device: %s\n\x00" as *const u8 + as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 14], + &[libc::c_char; 14]>(b"output_thread\x00")).as_ptr(), + 687 as libc::c_int, output.device); } - crate::stdlib::pthread_mutex_lock(&mut (*outputbuf).mutex); + pthread_mutex_lock(&mut (*outputbuf).mutex); // FIXME - some alsa hardware requires opening twice for a new sample rate to work - // this is a workaround which should be removed + // this is a workaround which should be removed if alsa.reopen { - alsa_open( - output.device, - output.current_sample_rate, - output.buffer, - output.period, - ); + alsa_open(output.device, output.current_sample_rate, + output.buffer, output.period); } - if alsa_open( - output.device, - output.current_sample_rate, - output.buffer, - output.period, - ) != 0 - { + if alsa_open(output.device, output.current_sample_rate, + output.buffer, output.period) != 0 { output.error_opening = 1 as libc::c_int != 0; - crate::stdlib::pthread_mutex_unlock(&mut (*outputbuf).mutex); - crate::stdlib::sleep(5 as libc::c_int as libc::c_uint); - continue; + pthread_mutex_unlock(&mut (*outputbuf).mutex); + sleep(5 as libc::c_int as libc::c_uint); + continue ; } else { output.error_opening = 0 as libc::c_int != 0; start = 1 as libc::c_int != 0; - crate::stdlib::pthread_mutex_unlock(&mut (*outputbuf).mutex); + pthread_mutex_unlock(&mut (*outputbuf).mutex); } } - let mut state = crate::stdlib::snd_pcm_state(pcmp); - if state as libc::c_uint == crate::stdlib::SND_PCM_STATE_XRUN 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 XRUN\n\x00" as *const u8 as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 14], &[libc::c_char; 14]>( - b"output_thread\x00", - )) - .as_ptr(), - 717 as libc::c_int, - ); + let mut state: snd_pcm_state_t = snd_pcm_state(pcmp); + if state as libc::c_uint == + SND_PCM_STATE_XRUN as libc::c_int as libc::c_uint { + if loglevel as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d XRUN\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 14], + &[libc::c_char; 14]>(b"output_thread\x00")).as_ptr(), + 717 as libc::c_int); } - err = crate::stdlib::snd_pcm_recover(pcmp, -(32 as libc::c_int), 1 as libc::c_int); + err = + snd_pcm_recover(pcmp, -(32 as libc::c_int), 1 as libc::c_int); if err < 0 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 XRUN recover failed: %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"output_thread\x00", - )) - .as_ptr(), - 719 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); + if loglevel as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d XRUN recover failed: %s\n\x00" as + *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 14], + &[libc::c_char; 14]>(b"output_thread\x00")).as_ptr(), + 719 as libc::c_int, snd_strerror(err)); } } start = 1 as libc::c_int != 0 } else { - if state as libc::c_uint - == crate::stdlib::SND_PCM_STATE_SUSPENDED as libc::c_int as libc::c_uint - { - err = crate::stdlib::snd_pcm_recover(pcmp, -(86 as libc::c_int), 1 as libc::c_int); + if state as libc::c_uint == + SND_PCM_STATE_SUSPENDED as libc::c_int as libc::c_uint { + err = + snd_pcm_recover(pcmp, -(86 as libc::c_int), + 1 as libc::c_int); if err < 0 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 SUSPEND recover failed: %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"output_thread\x00", - )) - .as_ptr(), - 725 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); + if loglevel as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d SUSPEND recover failed: %s\n\x00" + as *const u8 as *const libc::c_char, + logtime(), + (*::std::mem::transmute::<&[u8; 14], + &[libc::c_char; 14]>(b"output_thread\x00")).as_ptr(), + 725 as libc::c_int, snd_strerror(err)); } } - } else if state as libc::c_uint - == crate::stdlib::SND_PCM_STATE_DISCONNECTED 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 Device %s no longer available\n\x00" as *const u8 - as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 14], &[libc::c_char; 14]>( - b"output_thread\x00", - )) - .as_ptr(), - 728 as libc::c_int, - output.device, - ); + } else if state as libc::c_uint == + SND_PCM_STATE_DISCONNECTED as libc::c_int as + libc::c_uint { + if loglevel as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d Device %s no longer available\n\x00" + as *const u8 as *const libc::c_char, + logtime(), + (*::std::mem::transmute::<&[u8; 14], + &[libc::c_char; 14]>(b"output_thread\x00")).as_ptr(), + 728 as libc::c_int, output.device); } alsa_close(); - pcmp = 0 as *mut crate::stdlib::snd_pcm_t; + pcmp = 0 as *mut snd_pcm_t; probe_device = 1 as libc::c_int != 0; - continue; + continue ; } - let mut avail = crate::stdlib::snd_pcm_avail_update(pcmp); + let mut avail: snd_pcm_sframes_t = snd_pcm_avail_update(pcmp); if avail < 0 as libc::c_int as libc::c_long { - err = crate::stdlib::snd_pcm_recover(pcmp, avail as libc::c_int, 1 as libc::c_int); + err = + snd_pcm_recover(pcmp, avail as libc::c_int, + 1 as libc::c_int); if err < 0 as libc::c_int { if err == -(19 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 Device %s no longer available\n\x00" as *const u8 - as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 14], &[libc::c_char; 14]>( - b"output_thread\x00", - )) - .as_ptr(), - 740 as libc::c_int, - output.device, - ); + if loglevel as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d Device %s no longer available\n\x00" + as *const u8 as *const libc::c_char, + logtime(), + (*::std::mem::transmute::<&[u8; 14], + &[libc::c_char; 14]>(b"output_thread\x00")).as_ptr(), + 740 as libc::c_int, output.device); } alsa_close(); - pcmp = 0 as *mut crate::stdlib::snd_pcm_t; + pcmp = 0 as *mut snd_pcm_t; probe_device = 1 as libc::c_int != 0; - continue; - } 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 recover failed: %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"output_thread\x00", - )) - .as_ptr(), - 746 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); + continue ; + } else if loglevel as libc::c_uint >= + lWARN as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d recover failed: %s\n\x00" as + *const u8 as *const libc::c_char, + logtime(), + (*::std::mem::transmute::<&[u8; 14], + &[libc::c_char; 14]>(b"output_thread\x00")).as_ptr(), + 746 as libc::c_int, snd_strerror(err)); } } start = 1 as libc::c_int != 0 } else if (avail as libc::c_ulong) < alsa.period_size { if start { - if alsa.mmap as libc::c_int != 0 && { - err = crate::stdlib::snd_pcm_start(pcmp); - (err) < 0 as libc::c_int - } { - err = crate::stdlib::snd_pcm_recover(pcmp, err, 1 as libc::c_int); - if !(err < 0 as libc::c_int) { - continue; - } + if alsa.mmap as libc::c_int != 0 && + { + err = snd_pcm_start(pcmp); + (err) < 0 as libc::c_int + } { + err = snd_pcm_recover(pcmp, err, 1 as libc::c_int); + if !(err < 0 as libc::c_int) { continue ; } if err == -(19 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 Device %s no longer available\n\x00" as *const u8 - as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 14], &[libc::c_char; 14]>( - b"output_thread\x00", - )) - .as_ptr(), - 757 as libc::c_int, - output.device, - ); + if loglevel as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d Device %s no longer available\n\x00" + as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 14], + &[libc::c_char; 14]>(b"output_thread\x00")).as_ptr(), + 757 as libc::c_int, output.device); } alsa_close(); - pcmp = 0 as *mut crate::stdlib::snd_pcm_t; + pcmp = 0 as *mut snd_pcm_t; probe_device = 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 start error: %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"output_thread\x00", - )) - .as_ptr(), - 763 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); + if loglevel as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d start error: %s\n\x00" as + *const u8 as *const libc::c_char, + logtime(), + (*::std::mem::transmute::<&[u8; 14], + &[libc::c_char; 14]>(b"output_thread\x00")).as_ptr(), + 763 as libc::c_int, + snd_strerror(err)); } - crate::stdlib::usleep( - 10000 as libc::c_int as crate::stdlib::__useconds_t, - ); + usleep(10000 as libc::c_int as __useconds_t); } - } else { - start = 0 as libc::c_int != 0 - } + } else { start = 0 as libc::c_int != 0 } } else { - crate::stdlib::usleep(10000 as libc::c_int as crate::stdlib::__useconds_t); - err = crate::stdlib::snd_pcm_wait(pcmp, 1000 as libc::c_int); + usleep(10000 as libc::c_int as __useconds_t); + err = snd_pcm_wait(pcmp, 1000 as libc::c_int); if err <= 0 as libc::c_int { if err == 0 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 pcm wait timeout\n\x00" as *const u8 - as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 14], &[libc::c_char; 14]>( - b"output_thread\x00", - )) - .as_ptr(), - 773 as libc::c_int, - ); + if loglevel as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d pcm wait timeout\n\x00" as + *const u8 as *const libc::c_char, + logtime(), + (*::std::mem::transmute::<&[u8; 14], + &[libc::c_char; 14]>(b"output_thread\x00")).as_ptr(), + 773 as libc::c_int); } } - err = crate::stdlib::snd_pcm_recover(pcmp, err, 1 as libc::c_int); + err = snd_pcm_recover(pcmp, err, 1 as libc::c_int); if err < 0 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 pcm wait error: %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"output_thread\x00", - )) - .as_ptr(), - 776 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); + if loglevel as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d pcm wait error: %s\n\x00" + as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 14], + &[libc::c_char; 14]>(b"output_thread\x00")).as_ptr(), + 776 as libc::c_int, + snd_strerror(err)); } } start = 1 as libc::c_int != 0 @@ -1817,136 +1835,104 @@ unsafe extern "C" fn output_thread(mut arg: *mut libc::c_void) -> *mut libc::c_v } } else { // restrict avail to within sensible limits as alsa drivers can return erroneous large values - // in writei mode restrict to period_size due to size of write_buf + // in writei mode restrict to period_size due to size of write_buf if alsa.mmap { - avail = if (avail as libc::c_ulong) < alsa.buffer_size { - avail as libc::c_ulong - } else { - alsa.buffer_size - } as crate::stdlib::snd_pcm_sframes_t + avail = + if (avail as libc::c_ulong) < alsa.buffer_size { + avail as libc::c_ulong + } else { alsa.buffer_size } as snd_pcm_sframes_t } else { - avail = if (avail as libc::c_ulong) < alsa.period_size { - avail as libc::c_ulong - } else { - alsa.period_size - } as crate::stdlib::snd_pcm_sframes_t + avail = + if (avail as libc::c_ulong) < alsa.period_size { + avail as libc::c_ulong + } else { alsa.period_size } as snd_pcm_sframes_t } // avoid spinning in cases where wait returns but no bytes available (seen with pulse audio) if avail == 0 as libc::c_int as libc::c_long { - 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 avail 0 - sleeping\n\x00" as *const u8 - as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 14], &[libc::c_char; 14]>( - b"output_thread\x00", - )) - .as_ptr(), - 794 as libc::c_int, - ); + if loglevel as libc::c_uint >= + lSDEBUG as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d avail 0 - sleeping\n\x00" as + *const u8 as *const libc::c_char, + logtime(), + (*::std::mem::transmute::<&[u8; 14], + &[libc::c_char; 14]>(b"output_thread\x00")).as_ptr(), + 794 as libc::c_int); } - crate::stdlib::usleep(10000 as libc::c_int as crate::stdlib::__useconds_t); + usleep(10000 as libc::c_int as __useconds_t); } else { - crate::stdlib::pthread_mutex_lock(&mut (*outputbuf).mutex); + pthread_mutex_lock(&mut (*outputbuf).mutex); // turn off if requested - if output.state as libc::c_int - == crate::squeezelite_h::OUTPUT_OFF as libc::c_int - { - crate::stdlib::pthread_mutex_unlock(&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 disabling output\n\x00" as *const u8 - as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 14], &[libc::c_char; 14]>( - b"output_thread\x00", - )) - .as_ptr(), - 804 as libc::c_int, - ); + if output.state as libc::c_int == + OUTPUT_OFF as libc::c_int { + pthread_mutex_unlock(&mut (*outputbuf).mutex); + if loglevel as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d disabling output\n\x00" as + *const u8 as *const libc::c_char, + logtime(), + (*::std::mem::transmute::<&[u8; 14], + &[libc::c_char; 14]>(b"output_thread\x00")).as_ptr(), + 804 as libc::c_int); } alsa_close(); - pcmp = 0 as *mut crate::stdlib::snd_pcm_t; + pcmp = 0 as *mut snd_pcm_t; output_off = 1 as libc::c_int != 0 } else { // measure output delay - let mut delay: crate::stdlib::snd_pcm_sframes_t = 0; - err = crate::stdlib::snd_pcm_delay(pcmp, &mut delay); + let mut delay: snd_pcm_sframes_t = 0; + err = snd_pcm_delay(pcmp, &mut delay); if err < 0 as libc::c_int { if err == -(32 as libc::c_int) { // EPIPE indicates underrun - attempt to recover - crate::stdlib::pthread_mutex_unlock(&mut (*outputbuf).mutex); - continue; + pthread_mutex_unlock(&mut (*outputbuf).mutex); + continue ; } else if err == -(5 as libc::c_int) { // EIO can occur with non existant pulse server - 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 snd_pcm_delay returns: EIO - sleeping\n\x00" - as *const u8 - as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 14], &[libc::c_char; 14]>( - b"output_thread\x00", - )) - .as_ptr(), - 833 as libc::c_int, - ); + pthread_mutex_unlock(&mut (*outputbuf).mutex); + if loglevel as libc::c_uint >= + lSDEBUG as libc::c_int as libc::c_uint + { + logprint(b"%s %s:%d snd_pcm_delay returns: EIO - sleeping\n\x00" + as *const u8 as + *const libc::c_char, + logtime(), + (*::std::mem::transmute::<&[u8; 14], + &[libc::c_char; 14]>(b"output_thread\x00")).as_ptr(), + 833 as libc::c_int); } - crate::stdlib::usleep( - 100000 as libc::c_int as crate::stdlib::__useconds_t, - ); - continue; - } else 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 snd_pcm_delay returns: %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"output_thread\x00", - )) - .as_ptr(), - 837 as libc::c_int, - err, - ); + usleep(100000 as libc::c_int as __useconds_t); + continue ; + } else if loglevel as libc::c_uint >= + lDEBUG as libc::c_int as + libc::c_uint { + logprint(b"%s %s:%d snd_pcm_delay returns: %d\n\x00" + as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 14], + &[libc::c_char; 14]>(b"output_thread\x00")).as_ptr(), + 837 as libc::c_int, err); } } else { output.device_frames = delay as libc::c_uint; - output.updated = crate::src::utils::gettime_ms(); + output.updated = gettime_ms(); output.frames_played_dmp = output.frames_played } // process frames - let mut wrote = crate::src::output::_output_frames( - avail as crate::squeezelite_h::frames_t, - ); - crate::stdlib::pthread_mutex_unlock(&mut (*outputbuf).mutex); + let mut wrote: frames_t = + _output_frames(avail as frames_t); + pthread_mutex_unlock(&mut (*outputbuf).mutex); // some output devices such as alsa null refuse any data, avoid spinning if wrote == 0 { - 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 0 - sleeping\n\x00" as *const u8 - as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 14], &[libc::c_char; 14]>( - b"output_thread\x00", - )) - .as_ptr(), - 852 as libc::c_int, - ); + if loglevel as libc::c_uint >= + lSDEBUG as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d wrote 0 - sleeping\n\x00" + as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 14], + &[libc::c_char; 14]>(b"output_thread\x00")).as_ptr(), + 852 as libc::c_int); } - crate::stdlib::usleep( - 10000 as libc::c_int as crate::stdlib::__useconds_t, - ); + usleep(10000 as libc::c_int as __useconds_t); } } } @@ -1956,435 +1942,338 @@ unsafe extern "C" fn output_thread(mut arg: *mut libc::c_void) -> *mut libc::c_v return 0 as *mut libc::c_void; } #[no_mangle] - -pub unsafe extern "C" fn mixer_init_alsa( - mut device: *const libc::c_char, - mut mixer: *const libc::c_char, - mut mixer_index: libc::c_int, -) -> libc::c_int { +pub unsafe extern "C" fn mixer_init_alsa(mut device: *const libc::c_char, + mut mixer: *const libc::c_char, + mut mixer_index: libc::c_int) + -> libc::c_int { let mut err: libc::c_int = 0; - let mut sid = 0 as *mut crate::stdlib::snd_mixer_selem_id_t; - err = crate::stdlib::snd_mixer_open(&mut alsa.mixer_handle, 0 as libc::c_int); + let mut sid: *mut snd_mixer_selem_id_t = 0 as *mut snd_mixer_selem_id_t; + err = snd_mixer_open(&mut alsa.mixer_handle, 0 as libc::c_int); if err < 0 as libc::c_int { - crate::src::utils::logprint( - b"%s %s:%d open error: %s\n\x00" as *const u8 as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 16], &[libc::c_char; 16]>(b"mixer_init_alsa\x00")) - .as_ptr(), - 865 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); - return -(1 as libc::c_int); + logprint(b"%s %s:%d open error: %s\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 16], + &[libc::c_char; 16]>(b"mixer_init_alsa\x00")).as_ptr(), + 865 as libc::c_int, snd_strerror(err)); + return -(1 as libc::c_int) } - err = crate::stdlib::snd_mixer_attach(alsa.mixer_handle, device); + err = snd_mixer_attach(alsa.mixer_handle, device); if err < 0 as libc::c_int { - crate::src::utils::logprint( - b"%s %s:%d attach error: %s\n\x00" as *const u8 as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 16], &[libc::c_char; 16]>(b"mixer_init_alsa\x00")) - .as_ptr(), - 869 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); - crate::stdlib::snd_mixer_close(alsa.mixer_handle); - return -(1 as libc::c_int); + logprint(b"%s %s:%d attach error: %s\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 16], + &[libc::c_char; 16]>(b"mixer_init_alsa\x00")).as_ptr(), + 869 as libc::c_int, snd_strerror(err)); + snd_mixer_close(alsa.mixer_handle); + return -(1 as libc::c_int) } - err = crate::stdlib::snd_mixer_selem_register( - alsa.mixer_handle, - 0 as *mut crate::stdlib::snd_mixer_selem_regopt, - 0 as *mut *mut crate::stdlib::snd_mixer_class_t, - ); + err = + snd_mixer_selem_register(alsa.mixer_handle, + 0 as *mut snd_mixer_selem_regopt, + 0 as *mut *mut snd_mixer_class_t); if err < 0 as libc::c_int { - crate::src::utils::logprint( - b"%s %s:%d register error: %s\n\x00" as *const u8 as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 16], &[libc::c_char; 16]>(b"mixer_init_alsa\x00")) - .as_ptr(), - 874 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); - crate::stdlib::snd_mixer_close(alsa.mixer_handle); - return -(1 as libc::c_int); + logprint(b"%s %s:%d register error: %s\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 16], + &[libc::c_char; 16]>(b"mixer_init_alsa\x00")).as_ptr(), + 874 as libc::c_int, snd_strerror(err)); + snd_mixer_close(alsa.mixer_handle); + return -(1 as libc::c_int) } - err = crate::stdlib::snd_mixer_load(alsa.mixer_handle); + err = snd_mixer_load(alsa.mixer_handle); if err < 0 as libc::c_int { - crate::src::utils::logprint( - b"%s %s:%d load error: %s\n\x00" as *const u8 as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 16], &[libc::c_char; 16]>(b"mixer_init_alsa\x00")) - .as_ptr(), - 879 as libc::c_int, - crate::stdlib::snd_strerror(err), - ); - crate::stdlib::snd_mixer_close(alsa.mixer_handle); - return -(1 as libc::c_int); + logprint(b"%s %s:%d load error: %s\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 16], + &[libc::c_char; 16]>(b"mixer_init_alsa\x00")).as_ptr(), + 879 as libc::c_int, snd_strerror(err)); + snd_mixer_close(alsa.mixer_handle); + return -(1 as libc::c_int) } - let mut fresh4 = ::std::vec::from_elem(0, crate::stdlib::snd_mixer_selem_id_sizeof() as usize); - sid = fresh4.as_mut_ptr() as *mut crate::stdlib::snd_mixer_selem_id_t; - crate::stdlib::memset( - sid as *mut libc::c_void, - 0 as libc::c_int, - crate::stdlib::snd_mixer_selem_id_sizeof(), - ); - crate::stdlib::snd_mixer_selem_id_set_index(sid, mixer_index as libc::c_uint); - crate::stdlib::snd_mixer_selem_id_set_name(sid, mixer); - alsa.mixer_elem = crate::stdlib::snd_mixer_find_selem(alsa.mixer_handle, sid); + let mut fresh4 = + ::std::vec::from_elem(0, snd_mixer_selem_id_sizeof() as usize); + sid = fresh4.as_mut_ptr() as *mut snd_mixer_selem_id_t; + memset(sid as *mut libc::c_void, 0 as libc::c_int, + snd_mixer_selem_id_sizeof()); + snd_mixer_selem_id_set_index(sid, mixer_index as libc::c_uint); + snd_mixer_selem_id_set_name(sid, mixer); + alsa.mixer_elem = snd_mixer_find_selem(alsa.mixer_handle, sid); if alsa.mixer_elem.is_null() { - crate::src::utils::logprint( - b"%s %s:%d error find selem %s\n\x00" as *const u8 as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 16], &[libc::c_char; 16]>(b"mixer_init_alsa\x00")) - .as_ptr(), - 889 as libc::c_int, - alsa.mixer_handle, - ); - crate::stdlib::snd_mixer_close(alsa.mixer_handle); - return -(1 as libc::c_int); + logprint(b"%s %s:%d error find selem %s\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 16], + &[libc::c_char; 16]>(b"mixer_init_alsa\x00")).as_ptr(), + 889 as libc::c_int, alsa.mixer_handle); + snd_mixer_close(alsa.mixer_handle); + return -(1 as libc::c_int) } - if crate::stdlib::snd_mixer_selem_has_playback_switch(alsa.mixer_elem) != 0 { - crate::stdlib::snd_mixer_selem_set_playback_switch_all(alsa.mixer_elem, 1 as libc::c_int); + if snd_mixer_selem_has_playback_switch(alsa.mixer_elem) != 0 { + snd_mixer_selem_set_playback_switch_all(alsa.mixer_elem, + 1 as libc::c_int); // unmute } - err = crate::stdlib::snd_mixer_selem_get_playback_dB_range( - alsa.mixer_elem, - &mut alsa.mixer_min, - &mut alsa.mixer_max, - ); - if err < 0 as libc::c_int - || alsa.mixer_max - alsa.mixer_min < 1000 as libc::c_int as libc::c_long - || alsa.mixer_linear as libc::c_int != 0 - { + err = + snd_mixer_selem_get_playback_dB_range(alsa.mixer_elem, + &mut alsa.mixer_min, + &mut alsa.mixer_max); + if err < 0 as libc::c_int || + alsa.mixer_max - alsa.mixer_min < + 1000 as libc::c_int as libc::c_long || + alsa.mixer_linear as libc::c_int != 0 { alsa.mixer_linear = 1 as libc::c_int != 0; // unable to get db range or range is less than 10dB - ignore and set using raw values - err = crate::stdlib::snd_mixer_selem_get_playback_volume_range( - alsa.mixer_elem, - &mut alsa.mixer_min, - &mut alsa.mixer_max, - ); + err = + snd_mixer_selem_get_playback_volume_range(alsa.mixer_elem, + &mut alsa.mixer_min, + &mut alsa.mixer_max); if err < 0 as libc::c_int { - crate::src::utils::logprint( - b"%s %s:%d Unable to get volume raw range\n\x00" as *const u8 - as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 16], &[libc::c_char; 16]>(b"mixer_init_alsa\x00")) - .as_ptr(), - 905 as libc::c_int, - ); - return -(1 as libc::c_int); + logprint(b"%s %s:%d Unable to get volume raw range\n\x00" as + *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 16], + &[libc::c_char; 16]>(b"mixer_init_alsa\x00")).as_ptr(), + 905 as libc::c_int); + return -(1 as libc::c_int) } } return 0 as libc::c_int; } - -static mut thread: crate::stdlib::pthread_t = 0; +static mut thread: pthread_t = 0; #[no_mangle] - -pub unsafe extern "C" fn output_init_alsa( - mut level: crate::squeezelite_h::log_level, - mut device: *const libc::c_char, - 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, - mut rt_priority: libc::c_uint, - mut idle: libc::c_uint, - mut mixer_device: *mut libc::c_char, - mut volume_mixer: *mut libc::c_char, - mut mixer_unmute: bool, - mut mixer_linear: bool, -) { - let mut alsa_buffer = 40 as libc::c_int as libc::c_uint; - let mut alsa_period = 4 as libc::c_int as libc::c_uint; - let mut alsa_sample_fmt = 0 as *mut libc::c_char; - let mut alsa_mmap = 1 as libc::c_int != 0; - let mut alsa_reopen = 0 as libc::c_int != 0; - let mut volume_mixer_name = - crate::src::utils::next_param(volume_mixer, ',' as i32 as libc::c_char); - let mut volume_mixer_index = - crate::src::utils::next_param(0 as *mut libc::c_char, ',' as i32 as libc::c_char); - let mut t = crate::src::utils::next_param(params, ':' as i32 as libc::c_char); - let mut c = crate::src::utils::next_param(0 as *mut libc::c_char, ':' as i32 as libc::c_char); - let mut s = crate::src::utils::next_param(0 as *mut libc::c_char, ':' as i32 as libc::c_char); - let mut m = crate::src::utils::next_param(0 as *mut libc::c_char, ':' as i32 as libc::c_char); - let mut r = crate::src::utils::next_param(0 as *mut libc::c_char, ':' as i32 as libc::c_char); - if !t.is_null() { - alsa_buffer = crate::stdlib::atoi(t) as libc::c_uint - } - if !c.is_null() { - alsa_period = crate::stdlib::atoi(c) as libc::c_uint - } - if !s.is_null() { - alsa_sample_fmt = s - } - if !m.is_null() { - alsa_mmap = crate::stdlib::atoi(m) != 0 - } - if !r.is_null() { - alsa_reopen = crate::stdlib::atoi(r) != 0 - } +pub unsafe extern "C" fn output_init_alsa(mut level: log_level, + mut device: *const libc::c_char, + 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, + mut rt_priority: libc::c_uint, + mut idle: libc::c_uint, + mut mixer_device: *mut libc::c_char, + mut volume_mixer: *mut libc::c_char, + mut mixer_unmute: bool, + mut mixer_linear: bool) { + let mut alsa_buffer: libc::c_uint = 40 as libc::c_int as libc::c_uint; + let mut alsa_period: libc::c_uint = 4 as libc::c_int as libc::c_uint; + let mut alsa_sample_fmt: *mut libc::c_char = 0 as *mut libc::c_char; + let mut alsa_mmap: bool = 1 as libc::c_int != 0; + let mut alsa_reopen: bool = 0 as libc::c_int != 0; + let mut volume_mixer_name: *mut libc::c_char = + next_param(volume_mixer, ',' as i32 as libc::c_char); + let mut volume_mixer_index: *mut libc::c_char = + next_param(0 as *mut libc::c_char, ',' as i32 as libc::c_char); + let mut t: *mut libc::c_char = + next_param(params, ':' as i32 as libc::c_char); + let mut c: *mut libc::c_char = + next_param(0 as *mut libc::c_char, ':' as i32 as libc::c_char); + let mut s: *mut libc::c_char = + next_param(0 as *mut libc::c_char, ':' as i32 as libc::c_char); + let mut m: *mut libc::c_char = + next_param(0 as *mut libc::c_char, ':' as i32 as libc::c_char); + let mut r: *mut libc::c_char = + next_param(0 as *mut libc::c_char, ':' as i32 as libc::c_char); + if !t.is_null() { alsa_buffer = atoi(t) as libc::c_uint } + if !c.is_null() { alsa_period = atoi(c) as libc::c_uint } + if !s.is_null() { alsa_sample_fmt = s } + if !m.is_null() { alsa_mmap = atoi(m) != 0 } + if !r.is_null() { alsa_reopen = atoi(r) != 0 } 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\n\x00" as *const u8 as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"output_init_alsa\x00")) - .as_ptr(), - 939 as libc::c_int, - ); + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d init output\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 17], + &[libc::c_char; 17]>(b"output_init_alsa\x00")).as_ptr(), + 939 as libc::c_int); } - 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::() as libc::c_ulong, - ); + memset(&mut output as *mut outputstate as *mut libc::c_void, + 0 as libc::c_int, + ::std::mem::size_of::() as libc::c_ulong); alsa.mmap = alsa_mmap; - alsa.write_buf = 0 as *mut crate::squeezelite_h::u8_t; - alsa.format = crate::stdlib::SND_PCM_FORMAT_S8; + alsa.write_buf = 0 as *mut u8_t; + alsa.format = SND_PCM_FORMAT_S8; alsa.reopen = alsa_reopen; - alsa.mixer_handle = 0 as *mut crate::stdlib::snd_mixer_t; + alsa.mixer_handle = 0 as *mut snd_mixer_t; alsa.ctl = ctl4device(device); - alsa.mixer_ctl = if !mixer_device.is_null() { - ctl4device(mixer_device) - } else { - alsa.ctl - }; + alsa.mixer_ctl = + if !mixer_device.is_null() { + ctl4device(mixer_device) + } else { alsa.ctl }; alsa.volume_mixer_name = volume_mixer_name; alsa.mixer_linear = mixer_linear; - output.format = crate::squeezelite_h::S32_LE; + output.format = S32_LE; output.buffer = alsa_buffer; output.period = alsa_period; output.start_frames = 0 as libc::c_int as libc::c_uint; - output.write_cb = Some( - _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.write_cb = + Some(_write_frames as + unsafe extern "C" fn(_: frames_t, _: bool, _: s32_t, + _: s32_t, _: s32_t, _: s32_t, + _: *mut *mut s32_t) -> libc::c_int); output.rate_delay = rate_delay; if !alsa_sample_fmt.is_null() { - if crate::stdlib::strcmp( - alsa_sample_fmt, - b"32\x00" as *const u8 as *const libc::c_char, - ) == 0 - { - alsa.format = crate::stdlib::SND_PCM_FORMAT_S32_LE + if strcmp(alsa_sample_fmt, + b"32\x00" as *const u8 as *const libc::c_char) == 0 { + alsa.format = SND_PCM_FORMAT_S32_LE } - if crate::stdlib::strcmp( - alsa_sample_fmt, - b"24\x00" as *const u8 as *const libc::c_char, - ) == 0 - { - alsa.format = crate::stdlib::SND_PCM_FORMAT_S24_LE + if strcmp(alsa_sample_fmt, + b"24\x00" as *const u8 as *const libc::c_char) == 0 { + alsa.format = SND_PCM_FORMAT_S24_LE } - if crate::stdlib::strcmp( - alsa_sample_fmt, - b"24_3\x00" as *const u8 as *const libc::c_char, - ) == 0 - { - alsa.format = crate::stdlib::SND_PCM_FORMAT_S24_3LE + if strcmp(alsa_sample_fmt, + b"24_3\x00" as *const u8 as *const libc::c_char) == 0 { + alsa.format = SND_PCM_FORMAT_S24_3LE } - if crate::stdlib::strcmp( - alsa_sample_fmt, - b"16\x00" as *const u8 as *const libc::c_char, - ) == 0 - { - alsa.format = crate::stdlib::SND_PCM_FORMAT_S16_LE + if strcmp(alsa_sample_fmt, + b"16\x00" as *const u8 as *const libc::c_char) == 0 { + alsa.format = SND_PCM_FORMAT_S16_LE } } - 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 requested alsa_buffer: %u alsa_period: %u format: %s mmap: %u\n\x00" - as *const u8 as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"output_init_alsa\x00")) - .as_ptr(), - 979 as libc::c_int, - output.buffer, - output.period, - if !alsa_sample_fmt.is_null() { - alsa_sample_fmt as *const libc::c_char - } else { - b"any\x00" as *const u8 as *const libc::c_char - }, - alsa.mmap as libc::c_int, - ); + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d requested alsa_buffer: %u alsa_period: %u format: %s mmap: %u\n\x00" + as *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 17], + &[libc::c_char; 17]>(b"output_init_alsa\x00")).as_ptr(), + 979 as libc::c_int, output.buffer, output.period, + if !alsa_sample_fmt.is_null() { + alsa_sample_fmt as *const libc::c_char + } else { b"any\x00" as *const u8 as *const libc::c_char }, + alsa.mmap as libc::c_int); } - crate::stdlib::snd_lib_error_set_handler(::std::mem::transmute::< - Option< - unsafe extern "C" fn( - _: *const libc::c_char, - _: libc::c_int, - _: *const libc::c_char, - _: libc::c_int, - _: *const libc::c_char, - _: ... - ) -> *mut libc::c_void, - >, - crate::stdlib::snd_lib_error_handler_t, - >(Some( - alsa_error_handler - as unsafe extern "C" fn( - _: *const libc::c_char, - _: libc::c_int, - _: *const libc::c_char, - _: libc::c_int, - _: *const libc::c_char, - _: ... - ) -> *mut libc::c_void, - ))); - crate::src::output::output_init_common(level, device, output_buf_size, rates, idle); + snd_lib_error_set_handler(::std::mem::transmute:: + *mut libc::c_void>, + snd_lib_error_handler_t>(Some(alsa_error_handler + as + unsafe extern "C" fn(_: + *const libc::c_char, + _: + libc::c_int, + _: + *const libc::c_char, + _: + libc::c_int, + _: + *const libc::c_char, + _: + ...) + -> + *mut libc::c_void))); + output_init_common(level, device, output_buf_size, rates, idle); if !volume_mixer_name.is_null() { - if mixer_init_alsa( - alsa.mixer_ctl, - alsa.volume_mixer_name, - (if !volume_mixer_index.is_null() { - crate::stdlib::atoi(volume_mixer_index) - } else { - 0 as libc::c_int - }), - ) < 0 as libc::c_int - { - crate::src::utils::logprint( - b"%s %s:%d Initialization of mixer failed, reverting to software volume\n\x00" - as *const u8 as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"output_init_alsa\x00")) - .as_ptr(), - 989 as libc::c_int, - ); - alsa.mixer_handle = 0 as *mut crate::stdlib::snd_mixer_t; + if mixer_init_alsa(alsa.mixer_ctl, alsa.volume_mixer_name, + (if !volume_mixer_index.is_null() { + atoi(volume_mixer_index) + } else { 0 as libc::c_int })) < 0 as libc::c_int { + logprint(b"%s %s:%d Initialization of mixer failed, reverting to software volume\n\x00" + as *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 17], + &[libc::c_char; 17]>(b"output_init_alsa\x00")).as_ptr(), + 989 as libc::c_int); + alsa.mixer_handle = 0 as *mut snd_mixer_t; alsa.volume_mixer_name = 0 as *const libc::c_char } } if mixer_unmute as libc::c_int != 0 && !alsa.volume_mixer_name.is_null() { - set_mixer( - 1 as libc::c_int != 0, - 0 as libc::c_int as libc::c_float, - 0 as libc::c_int as libc::c_float, - ); + set_mixer(1 as libc::c_int != 0, 0 as libc::c_int as libc::c_float, + 0 as libc::c_int as libc::c_float); alsa.volume_mixer_name = 0 as *const libc::c_char } - // RT linux - aim to avoid pagefaults by locking memory: - // https://rt.wiki.kernel.org/index.php/Threaded_RT-application_with_memory_locking_and_stack_handling_example - if crate::stdlib::mlockall(1 as libc::c_int | 2 as libc::c_int) == -(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 unable to lock memory: %s\n\x00" as *const u8 as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"output_init_alsa\x00")) - .as_ptr(), - 1003 as libc::c_int, - crate::stdlib::strerror(*crate::stdlib::__errno_location()), - ); + // RT linux - aim to avoid pagefaults by locking memory: + // https://rt.wiki.kernel.org/index.php/Threaded_RT-application_with_memory_locking_and_stack_handling_example + if mlockall(1 as libc::c_int | 2 as libc::c_int) == -(1 as libc::c_int) { + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d unable to lock memory: %s\n\x00" as *const u8 + as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 17], + &[libc::c_char; 17]>(b"output_init_alsa\x00")).as_ptr(), + 1003 as libc::c_int, strerror(*__errno_location())); } - } 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 memory locked\n\x00" as *const u8 as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"output_init_alsa\x00")) - .as_ptr(), - 1005 as libc::c_int, - ); + } else if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint + { + logprint(b"%s %s:%d memory locked\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 17], + &[libc::c_char; 17]>(b"output_init_alsa\x00")).as_ptr(), + 1005 as libc::c_int); } - crate::stdlib::mallopt(-(1 as libc::c_int), -(1 as libc::c_int)); - crate::stdlib::mallopt(-(4 as libc::c_int), 0 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 glibc detected using mallopt\n\x00" as *const u8 as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"output_init_alsa\x00")) - .as_ptr(), - 1011 as libc::c_int, - ); + mallopt(-(1 as libc::c_int), -(1 as libc::c_int)); + mallopt(-(4 as libc::c_int), 0 as libc::c_int); + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d glibc detected using mallopt\n\x00" as *const u8 + as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 17], + &[libc::c_char; 17]>(b"output_init_alsa\x00")).as_ptr(), + 1011 as libc::c_int); } - crate::src::utils::touch_memory( - silencebuf, - (2048 as libc::c_int * 8 as libc::c_int) as crate::stddef_h::size_t, - ); - crate::src::utils::touch_memory((*outputbuf).buf, (*outputbuf).size); + touch_memory(silencebuf, + (2048 as libc::c_int * 8 as libc::c_int) as size_t); + touch_memory((*outputbuf).buf, (*outputbuf).size); // start output thread - 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, - Some(output_thread as unsafe extern "C" fn(_: *mut libc::c_void) -> *mut libc::c_void), - if *rates.offset(0 as libc::c_int as isize) != 0 { - b"probe\x00" as *const u8 as *const libc::c_char - } else { - 0 as *const libc::c_char - } as *mut libc::c_void, - ); - crate::stdlib::pthread_attr_destroy(&mut attr); + let mut attr: pthread_attr_t = pthread_attr_t{__size: [0; 56],}; + pthread_attr_init(&mut attr); + pthread_attr_setstacksize(&mut attr, + (16384 as libc::c_int + + 64 as libc::c_int * 1024 as libc::c_int) as + size_t); + pthread_create(&mut thread, &mut attr, + Some(output_thread as + unsafe extern "C" fn(_: *mut libc::c_void) + -> *mut libc::c_void), + if *rates.offset(0 as libc::c_int as isize) != 0 { + b"probe\x00" as *const u8 as *const libc::c_char + } else { 0 as *const libc::c_char } as *mut libc::c_void); + pthread_attr_destroy(&mut attr); // try to set this thread to real-time scheduler class, only works as root or if user has permission - let mut param = crate::stdlib::sched_param { sched_priority: 0 }; + let mut param: sched_param = sched_param{sched_priority: 0,}; param.sched_priority = rt_priority as libc::c_int; - if crate::stdlib::pthread_setschedparam(thread, 1 as libc::c_int, &mut param) - != 0 as libc::c_int - { - 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 unable to set output sched fifo: %s\n\x00" as *const u8 - as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"output_init_alsa\x00")) - .as_ptr(), - 1029 as libc::c_int, - crate::stdlib::strerror(*crate::stdlib::__errno_location()), - ); + if pthread_setschedparam(thread, 1 as libc::c_int, &mut param) != + 0 as libc::c_int { + if loglevel as libc::c_uint >= lDEBUG as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d unable to set output sched fifo: %s\n\x00" as + *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 17], + &[libc::c_char; 17]>(b"output_init_alsa\x00")).as_ptr(), + 1029 as libc::c_int, strerror(*__errno_location())); } - } else 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 set output sched fifo rt: %u\n\x00" as *const u8 as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"output_init_alsa\x00")) - .as_ptr(), - 1031 as libc::c_int, - param.sched_priority, - ); + } else if loglevel as libc::c_uint >= + lDEBUG as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d set output sched fifo rt: %u\n\x00" as *const u8 + as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 17], + &[libc::c_char; 17]>(b"output_init_alsa\x00")).as_ptr(), + 1031 as libc::c_int, param.sched_priority); }; } #[no_mangle] - pub unsafe extern "C" fn output_close_alsa() { - 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; 18], &[libc::c_char; 18]>(b"output_close_alsa\x00")) - .as_ptr(), - 1036 as libc::c_int, - ); + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d close output\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 18], + &[libc::c_char; 18]>(b"output_close_alsa\x00")).as_ptr(), + 1036 as libc::c_int); } - crate::stdlib::pthread_mutex_lock(&mut (*outputbuf).mutex); + pthread_mutex_lock(&mut (*outputbuf).mutex); running = 0 as libc::c_int != 0; - crate::stdlib::pthread_mutex_unlock(&mut (*outputbuf).mutex); - crate::stdlib::pthread_join(thread, 0 as *mut *mut libc::c_void); + pthread_mutex_unlock(&mut (*outputbuf).mutex); + pthread_join(thread, 0 as *mut *mut libc::c_void); if !alsa.write_buf.is_null() { - crate::stdlib::free(alsa.write_buf as *mut libc::c_void); - } - if !alsa.ctl.is_null() { - crate::stdlib::free(alsa.ctl as *mut libc::c_void); + free(alsa.write_buf as *mut libc::c_void); } + if !alsa.ctl.is_null() { free(alsa.ctl as *mut libc::c_void); } if !alsa.mixer_ctl.is_null() { - crate::stdlib::free(alsa.mixer_ctl as *mut libc::c_void); + free(alsa.mixer_ctl as *mut libc::c_void); } - if !alsa.mixer_handle.is_null() { - crate::stdlib::snd_mixer_close(alsa.mixer_handle); - } - crate::src::output::output_close_common(); + if !alsa.mixer_handle.is_null() { snd_mixer_close(alsa.mixer_handle); } + output_close_common(); } // ALSA diff --git a/src/output_pa.rs b/src/output_pa.rs index f86a2d8..c1d881c 100644 --- a/src/output_pa.rs +++ b/src/output_pa.rs @@ -1,7 +1,7 @@ use ::libc; // PORTAUDIO // Portaudio output -/* +/* * Squeezelite - lightweight headless squeezebox emulator * * (c) Adrian Smith 2012-2015, triode1@btinternet.com @@ -11,7 +11,7 @@ use ::libc; * 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 diff --git a/src/output_pack.rs b/src/output_pack.rs index bcb5b16..873ed0b 100644 --- a/src/output_pack.rs +++ b/src/output_pack.rs @@ -1,324 +1,350 @@ 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; +extern "C" { + #[no_mangle] + fn memcpy(_: *mut libc::c_void, _: *const libc::c_void, _: libc::c_ulong) + -> *mut libc::c_void; +} +pub type __uint8_t = libc::c_uchar; +pub type __int32_t = libc::c_int; +pub type __uint32_t = libc::c_uint; +pub type __int64_t = libc::c_long; +pub type int32_t = __int32_t; +pub type int64_t = __int64_t; +pub type u_int8_t = __uint8_t; +pub type u_int32_t = __uint32_t; +pub type u8_t = u_int8_t; +pub type u32_t = u_int32_t; +pub type s32_t = int32_t; +pub type s64_t = int64_t; +pub type frames_t = u32_t; +pub type uintptr_t = libc::c_ulong; +pub type output_format = libc::c_uint; +pub const S16_LE: output_format = 3; +pub const S24_3LE: output_format = 2; +pub const S24_LE: output_format = 1; +pub const S32_LE: output_format = 0; // inlining these on windows prevents them being linkable... #[inline] - -unsafe extern "C" fn gain( - mut gain_0: 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; +unsafe extern "C" fn gain(mut gain_0: s32_t, mut sample: s32_t) -> s32_t { + let mut res: s64_t = gain_0 as s64_t * sample as s64_t; if res as libc::c_longlong > 0x7fffffffffff as libc::c_longlong { - res = 0x7fffffffffff as libc::c_longlong as crate::squeezelite_h::s64_t + res = 0x7fffffffffff as libc::c_longlong as s64_t } if (res as libc::c_longlong) < -(0x7fffffffffff as libc::c_longlong) { - res = -(0x7fffffffffff as libc::c_longlong) as crate::squeezelite_h::s64_t + res = -(0x7fffffffffff as libc::c_longlong) as s64_t } - return (res >> 16 as libc::c_int) as crate::squeezelite_h::s32_t; + return (res >> 16 as libc::c_int) as s32_t; } #[no_mangle] - -pub unsafe extern "C" fn _scale_and_pack_frames( - mut outputptr: *mut libc::c_void, - mut inputptr: *mut 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, -) { +pub unsafe extern "C" fn _scale_and_pack_frames(mut outputptr: + *mut libc::c_void, + mut inputptr: *mut s32_t, + mut cnt: frames_t, + mut gainL: s32_t, + mut gainR: s32_t, + mut format: output_format) { match format as libc::c_uint { 3 => { - let mut optr = outputptr as *mut crate::squeezelite_h::u32_t; - if gainL == 0x10000 as libc::c_int && gainR == 0x10000 as libc::c_int { - loop { + let mut optr: *mut u32_t = outputptr as *mut u32_t; + if gainL == 0x10000 as libc::c_int && + gainR == 0x10000 as libc::c_int { + loop { let fresh0 = cnt; cnt = cnt.wrapping_sub(1); - if !(fresh0 != 0) { - break; - } + 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; + *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 { + loop { let fresh2 = cnt; cnt = cnt.wrapping_sub(1); - if !(fresh2 != 0) { - break; - } + 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; + *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 mut optr_0: *mut u32_t = outputptr as *mut u32_t; + if gainL == 0x10000 as libc::c_int && + gainR == 0x10000 as libc::c_int { + loop { let fresh4 = cnt; cnt = cnt.wrapping_sub(1); - if !(fresh4 != 0) { - break; - } + 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; + *fresh6 = (*fresh5 >> 8 as libc::c_int) as u32_t; let fresh7 = inputptr; inputptr = inputptr.offset(1); let fresh8 = optr_0; optr_0 = optr_0.offset(1); - *fresh8 = (*fresh7 >> 8 as libc::c_int) as crate::squeezelite_h::u32_t + *fresh8 = (*fresh7 >> 8 as libc::c_int) as u32_t } } else { - loop { + loop { let fresh9 = cnt; cnt = cnt.wrapping_sub(1); - if !(fresh9 != 0) { - break; - } + 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; + (gain(gainL, *fresh10) >> 8 as libc::c_int) as u32_t; let fresh12 = inputptr; inputptr = inputptr.offset(1); let fresh13 = optr_0; optr_0 = optr_0.offset(1); *fresh13 = - (gain(gainR, *fresh12) >> 8 as libc::c_int) as crate::squeezelite_h::u32_t + (gain(gainR, *fresh12) >> 8 as libc::c_int) as 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 { + let mut optr_1: *mut u8_t = outputptr as *mut u8_t; + if gainL == 0x10000 as libc::c_int && + gainR == 0x10000 as libc::c_int { while cnt != 0 { // attempt to do 32 bit memory accesses - move 2 frames at once: 16 bytes -> 12 bytes - // falls through to exception case when not aligned or if less than 2 frames to move - if optr_1 as 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; + // falls through to exception case when not aligned or if less than 2 frames to move + if optr_1 as uintptr_t & + 0x3 as libc::c_int as libc::c_ulong == + 0 as libc::c_int as libc::c_ulong && + cnt >= 2 as libc::c_int as libc::c_uint { + let mut o_ptr: *mut u32_t = + optr_1 as *mut libc::c_void as *mut u32_t; while cnt >= 2 as libc::c_int as libc::c_uint { let fresh14 = inputptr; inputptr = inputptr.offset(1); - let mut l1 = *fresh14; + let mut l1: s32_t = *fresh14; let fresh15 = inputptr; inputptr = inputptr.offset(1); - let mut r1 = *fresh15; + let mut r1: s32_t = *fresh15; let fresh16 = inputptr; inputptr = inputptr.offset(1); - let mut l2 = *fresh16; + let mut l2: s32_t = *fresh16; let fresh17 = inputptr; inputptr = inputptr.offset(1); - let mut r2 = *fresh17; + let mut r2: s32_t = *fresh17; let fresh18 = o_ptr; o_ptr = o_ptr.offset(1); - *fresh18 = (l1 as libc::c_uint & 0xffffff00 as libc::c_uint) - >> 8 as libc::c_int - | ((r1 & 0xff00 as libc::c_int) << 16 as libc::c_int) - as libc::c_uint; + *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; + *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 + *fresh20 = + (l2 as libc::c_uint & + 0xff000000 as libc::c_uint) >> + 24 as libc::c_int | + r2 as libc::c_uint & + 0xffffff00 as libc::c_uint; + optr_1 = + optr_1.offset(12 as libc::c_int as isize); + cnt = + (cnt as + libc::c_uint).wrapping_sub(2 as + libc::c_int + as + libc::c_uint) + as frames_t as frames_t } } else { let fresh21 = inputptr; inputptr = inputptr.offset(1); - let mut lsample = *fresh21; + let mut lsample: s32_t = *fresh21; let fresh22 = inputptr; inputptr = inputptr.offset(1); - let mut rsample = *fresh22; + let mut rsample: s32_t = *fresh22; let fresh23 = optr_1; optr_1 = optr_1.offset(1); - *fresh23 = ((lsample & 0xff00 as libc::c_int) >> 8 as libc::c_int) - as crate::squeezelite_h::u8_t; + *fresh23 = + ((lsample & 0xff00 as libc::c_int) >> + 8 as libc::c_int) as u8_t; let fresh24 = optr_1; optr_1 = optr_1.offset(1); - *fresh24 = ((lsample & 0xff0000 as libc::c_int) >> 16 as libc::c_int) - as crate::squeezelite_h::u8_t; + *fresh24 = + ((lsample & 0xff0000 as libc::c_int) >> + 16 as libc::c_int) as u8_t; let fresh25 = optr_1; optr_1 = optr_1.offset(1); - *fresh25 = ((lsample as libc::c_uint & 0xff000000 as libc::c_uint) - >> 24 as libc::c_int) - as crate::squeezelite_h::u8_t; + *fresh25 = + ((lsample as libc::c_uint & + 0xff000000 as libc::c_uint) >> + 24 as libc::c_int) as u8_t; let fresh26 = optr_1; optr_1 = optr_1.offset(1); - *fresh26 = ((rsample & 0xff00 as libc::c_int) >> 8 as libc::c_int) - as crate::squeezelite_h::u8_t; + *fresh26 = + ((rsample & 0xff00 as libc::c_int) >> + 8 as libc::c_int) as u8_t; let fresh27 = optr_1; optr_1 = optr_1.offset(1); - *fresh27 = ((rsample & 0xff0000 as libc::c_int) >> 16 as libc::c_int) - as crate::squeezelite_h::u8_t; + *fresh27 = + ((rsample & 0xff0000 as libc::c_int) >> + 16 as libc::c_int) as u8_t; let fresh28 = optr_1; optr_1 = optr_1.offset(1); - *fresh28 = ((rsample as libc::c_uint & 0xff000000 as libc::c_uint) - >> 24 as libc::c_int) - as crate::squeezelite_h::u8_t; + *fresh28 = + ((rsample as libc::c_uint & + 0xff000000 as libc::c_uint) >> + 24 as libc::c_int) as u8_t; cnt = cnt.wrapping_sub(1) } } } else { while cnt != 0 { // attempt to do 32 bit memory accesses - move 2 frames at once: 16 bytes -> 12 bytes - // falls through to exception case when not aligned or if less than 2 frames to move - if optr_1 as 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; + // falls through to exception case when not aligned or if less than 2 frames to move + if optr_1 as uintptr_t & + 0x3 as libc::c_int as libc::c_ulong == + 0 as libc::c_int as libc::c_ulong && + cnt >= 2 as libc::c_int as libc::c_uint { + let mut o_ptr_0: *mut u32_t = + optr_1 as *mut libc::c_void as *mut u32_t; while cnt >= 2 as libc::c_int as libc::c_uint { let fresh29 = inputptr; inputptr = inputptr.offset(1); - let mut l1_0 = gain(gainL, *fresh29); + let mut l1_0: s32_t = gain(gainL, *fresh29); let fresh30 = inputptr; inputptr = inputptr.offset(1); - let mut r1_0 = gain(gainR, *fresh30); + let mut r1_0: s32_t = gain(gainR, *fresh30); let fresh31 = inputptr; inputptr = inputptr.offset(1); - let mut l2_0 = gain(gainL, *fresh31); + let mut l2_0: s32_t = gain(gainL, *fresh31); let fresh32 = inputptr; inputptr = inputptr.offset(1); - let mut r2_0 = gain(gainR, *fresh32); + let mut r2_0: s32_t = gain(gainR, *fresh32); let fresh33 = o_ptr_0; o_ptr_0 = o_ptr_0.offset(1); - *fresh33 = (l1_0 as libc::c_uint & 0xffffff00 as libc::c_uint) - >> 8 as libc::c_int - | ((r1_0 & 0xff00 as libc::c_int) << 16 as libc::c_int) - as libc::c_uint; + *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; + *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 + *fresh35 = + (l2_0 as libc::c_uint & + 0xff000000 as libc::c_uint) >> + 24 as libc::c_int | + r2_0 as libc::c_uint & + 0xffffff00 as libc::c_uint; + optr_1 = + optr_1.offset(12 as libc::c_int as isize); + cnt = + (cnt as + libc::c_uint).wrapping_sub(2 as + libc::c_int + as + libc::c_uint) + as frames_t as frames_t } } else { let fresh36 = inputptr; inputptr = inputptr.offset(1); - let mut lsample_0 = gain(gainL, *fresh36); + let mut lsample_0: s32_t = gain(gainL, *fresh36); let fresh37 = inputptr; inputptr = inputptr.offset(1); - let mut rsample_0 = gain(gainR, *fresh37); + let mut rsample_0: s32_t = gain(gainR, *fresh37); let fresh38 = optr_1; optr_1 = optr_1.offset(1); - *fresh38 = ((lsample_0 & 0xff00 as libc::c_int) >> 8 as libc::c_int) - as crate::squeezelite_h::u8_t; + *fresh38 = + ((lsample_0 & 0xff00 as libc::c_int) >> + 8 as libc::c_int) as u8_t; let fresh39 = optr_1; optr_1 = optr_1.offset(1); - *fresh39 = ((lsample_0 & 0xff0000 as libc::c_int) >> 16 as libc::c_int) - as crate::squeezelite_h::u8_t; + *fresh39 = + ((lsample_0 & 0xff0000 as libc::c_int) >> + 16 as libc::c_int) as u8_t; let fresh40 = optr_1; optr_1 = optr_1.offset(1); - *fresh40 = ((lsample_0 as libc::c_uint & 0xff000000 as libc::c_uint) - >> 24 as libc::c_int) - as crate::squeezelite_h::u8_t; + *fresh40 = + ((lsample_0 as libc::c_uint & + 0xff000000 as libc::c_uint) >> + 24 as libc::c_int) as u8_t; let fresh41 = optr_1; optr_1 = optr_1.offset(1); - *fresh41 = ((rsample_0 & 0xff00 as libc::c_int) >> 8 as libc::c_int) - as crate::squeezelite_h::u8_t; + *fresh41 = + ((rsample_0 & 0xff00 as libc::c_int) >> + 8 as libc::c_int) as u8_t; let fresh42 = optr_1; optr_1 = optr_1.offset(1); - *fresh42 = ((rsample_0 & 0xff0000 as libc::c_int) >> 16 as libc::c_int) - as crate::squeezelite_h::u8_t; + *fresh42 = + ((rsample_0 & 0xff0000 as libc::c_int) >> + 16 as libc::c_int) as u8_t; let fresh43 = optr_1; optr_1 = optr_1.offset(1); - *fresh43 = ((rsample_0 as libc::c_uint & 0xff000000 as libc::c_uint) - >> 24 as libc::c_int) - as crate::squeezelite_h::u8_t; + *fresh43 = + ((rsample_0 as libc::c_uint & + 0xff000000 as libc::c_uint) >> + 24 as libc::c_int) as u8_t; cnt = cnt.wrapping_sub(1) } } } } 0 => { - let mut optr_2 = 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, - ); + let mut optr_2: *mut u32_t = outputptr as *mut u32_t; + if gainL == 0x10000 as libc::c_int && + gainR == 0x10000 as libc::c_int { + memcpy(outputptr, inputptr as *const libc::c_void, + cnt.wrapping_mul(8 as libc::c_int as libc::c_uint) as + libc::c_ulong); } else { - loop { + loop { let fresh44 = cnt; cnt = cnt.wrapping_sub(1); - if !(fresh44 != 0) { - break; - } + 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; + *fresh46 = gain(gainL, *fresh45) as u32_t; let fresh47 = inputptr; inputptr = inputptr.offset(1); let fresh48 = optr_2; optr_2 = optr_2.offset(1); - *fresh48 = gain(gainR, *fresh47) as crate::squeezelite_h::u32_t + *fresh48 = gain(gainR, *fresh47) as u32_t } } } - _ => {} + _ => { } }; } diff --git a/src/output_pulse.rs b/src/output_pulse.rs index 77f5f52..fe6d259 100644 --- a/src/output_pulse.rs +++ b/src/output_pulse.rs @@ -1,6 +1,6 @@ use ::libc; // Output using PulseAudio -/* +/* * Squeezelite - lightweight headless squeezebox emulator * * (c) Adrian Smith 2012-2015, triode1@btinternet.com @@ -10,7 +10,7 @@ use ::libc; * 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 diff --git a/src/output_stdout.rs b/src/output_stdout.rs index a3a0d25..988fbff 100644 --- a/src/output_stdout.rs +++ b/src/output_stdout.rs @@ -1,286 +1,396 @@ 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" { + pub type _IO_wide_data; + pub type _IO_codecvt; + pub type _IO_marker; #[no_mangle] - pub static mut output: crate::squeezelite_h::outputstate; + static mut stdout: *mut FILE; #[no_mangle] - pub static mut outputbuf: *mut crate::squeezelite_h::buffer; + fn fwrite(_: *const libc::c_void, _: libc::c_ulong, _: libc::c_ulong, + _: *mut FILE) -> libc::c_ulong; #[no_mangle] - pub static mut silencebuf: *mut crate::squeezelite_h::u8_t; + fn malloc(_: libc::c_ulong) -> *mut libc::c_void; + #[no_mangle] + fn free(__ptr: *mut libc::c_void); + #[no_mangle] + fn memset(_: *mut libc::c_void, _: libc::c_int, _: libc::c_ulong) + -> *mut libc::c_void; + #[no_mangle] + fn strcmp(_: *const libc::c_char, _: *const libc::c_char) -> libc::c_int; + #[no_mangle] + fn _apply_cross(outputbuf_0: *mut buffer, out_frames: frames_t, + cross_gain_in: s32_t, cross_gain_out: s32_t, + cross_ptr: *mut *mut s32_t); + #[no_mangle] + fn _scale_and_pack_frames(outputptr: *mut libc::c_void, + inputptr: *mut s32_t, cnt: frames_t, + gainL: s32_t, gainR: s32_t, + format: output_format); + #[no_mangle] + fn _output_frames(avail: frames_t) -> frames_t; + #[no_mangle] + fn output_close_common(); + #[no_mangle] + fn output_init_common(level: log_level, device: *const libc::c_char, + output_buf_size: libc::c_uint, + rates: *mut libc::c_uint, idle: libc::c_uint); + #[no_mangle] + fn pthread_create(__newthread: *mut pthread_t, + __attr: *const pthread_attr_t, + __start_routine: + Option *mut libc::c_void>, + __arg: *mut libc::c_void) -> libc::c_int; + #[no_mangle] + fn pthread_attr_init(__attr: *mut pthread_attr_t) -> libc::c_int; + #[no_mangle] + fn pthread_attr_destroy(__attr: *mut pthread_attr_t) -> libc::c_int; + #[no_mangle] + fn pthread_attr_setstacksize(__attr: *mut pthread_attr_t, + __stacksize: size_t) -> libc::c_int; + #[no_mangle] + fn pthread_mutex_lock(__mutex: *mut pthread_mutex_t) -> libc::c_int; + #[no_mangle] + fn pthread_mutex_unlock(__mutex: *mut pthread_mutex_t) -> libc::c_int; + #[no_mangle] + fn logtime() -> *const libc::c_char; + #[no_mangle] + fn logprint(fmt: *const libc::c_char, _: ...); + #[no_mangle] + fn gettime_ms() -> u32_t; + #[no_mangle] + static mut output: outputstate; + #[no_mangle] + static mut outputbuf: *mut buffer; + #[no_mangle] + static mut silencebuf: *mut u8_t; } - -static mut loglevel: crate::squeezelite_h::log_level = crate::squeezelite_h::lERROR; - +pub type size_t = libc::c_ulong; +pub type __uint8_t = libc::c_uchar; +pub type __int32_t = libc::c_int; +pub type __uint32_t = libc::c_uint; +pub type __off_t = libc::c_long; +pub type __off64_t = libc::c_long; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct _IO_FILE { + pub _flags: libc::c_int, + pub _IO_read_ptr: *mut libc::c_char, + pub _IO_read_end: *mut libc::c_char, + pub _IO_read_base: *mut libc::c_char, + pub _IO_write_base: *mut libc::c_char, + pub _IO_write_ptr: *mut libc::c_char, + pub _IO_write_end: *mut libc::c_char, + pub _IO_buf_base: *mut libc::c_char, + pub _IO_buf_end: *mut libc::c_char, + pub _IO_save_base: *mut libc::c_char, + pub _IO_backup_base: *mut libc::c_char, + pub _IO_save_end: *mut libc::c_char, + pub _markers: *mut _IO_marker, + pub _chain: *mut _IO_FILE, + pub _fileno: libc::c_int, + pub _flags2: libc::c_int, + pub _old_offset: __off_t, + pub _cur_column: libc::c_ushort, + pub _vtable_offset: libc::c_schar, + pub _shortbuf: [libc::c_char; 1], + pub _lock: *mut libc::c_void, + pub _offset: __off64_t, + pub _codecvt: *mut _IO_codecvt, + pub _wide_data: *mut _IO_wide_data, + pub _freeres_list: *mut _IO_FILE, + pub _freeres_buf: *mut libc::c_void, + pub __pad5: size_t, + pub _mode: libc::c_int, + pub _unused2: [libc::c_char; 20], +} +pub type _IO_lock_t = (); +pub type FILE = _IO_FILE; +pub type int32_t = __int32_t; +pub type u_int8_t = __uint8_t; +pub type u_int32_t = __uint32_t; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct __pthread_internal_list { + pub __prev: *mut __pthread_internal_list, + pub __next: *mut __pthread_internal_list, +} +pub type __pthread_list_t = __pthread_internal_list; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct __pthread_mutex_s { + pub __lock: libc::c_int, + pub __count: libc::c_uint, + pub __owner: libc::c_int, + pub __nusers: libc::c_uint, + pub __kind: libc::c_int, + pub __spins: libc::c_short, + pub __elision: libc::c_short, + pub __list: __pthread_list_t, +} +pub type pthread_t = libc::c_ulong; +#[derive(Copy, Clone)] +#[repr(C)] +pub union pthread_attr_t { + pub __size: [libc::c_char; 56], + pub __align: libc::c_long, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub union pthread_mutex_t { + pub __data: __pthread_mutex_s, + pub __size: [libc::c_char; 40], + pub __align: libc::c_long, +} +pub type u8_t = u_int8_t; +pub type u32_t = u_int32_t; +pub type s32_t = int32_t; +pub type frames_t = u32_t; +pub type log_level = libc::c_uint; +pub const lSDEBUG: log_level = 4; +pub const lDEBUG: log_level = 3; +pub const lINFO: log_level = 2; +pub const lWARN: log_level = 1; +pub const lERROR: log_level = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct buffer { + pub buf: *mut u8_t, + pub readp: *mut u8_t, + pub writep: *mut u8_t, + pub wrap: *mut u8_t, + pub size: size_t, + pub base_size: size_t, + pub mutex: pthread_mutex_t, +} +pub type output_state = libc::c_int; +pub const OUTPUT_START_AT: output_state = 5; +pub const OUTPUT_SKIP_FRAMES: output_state = 4; +pub const OUTPUT_PAUSE_FRAMES: output_state = 3; +pub const OUTPUT_RUNNING: output_state = 2; +pub const OUTPUT_BUFFER: output_state = 1; +pub const OUTPUT_STOPPED: output_state = 0; +pub const OUTPUT_OFF: output_state = -1; +pub type output_format = libc::c_uint; +pub const S16_LE: output_format = 3; +pub const S24_3LE: output_format = 2; +pub const S24_LE: output_format = 1; +pub const S32_LE: output_format = 0; +pub type fade_state = libc::c_uint; +pub const FADE_ACTIVE: fade_state = 2; +pub const FADE_DUE: fade_state = 1; +pub const FADE_INACTIVE: fade_state = 0; +pub type fade_dir = libc::c_uint; +pub const FADE_CROSS: fade_dir = 3; +pub const FADE_DOWN: fade_dir = 2; +pub const FADE_UP: fade_dir = 1; +pub type fade_mode = libc::c_uint; +pub const FADE_INOUT: fade_mode = 4; +pub const FADE_OUT: fade_mode = 3; +pub const FADE_IN: fade_mode = 2; +pub const FADE_CROSSFADE: fade_mode = 1; +pub const FADE_NONE: fade_mode = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct outputstate { + pub state: output_state, + pub format: output_format, + pub device: *const libc::c_char, + pub buffer: libc::c_uint, + pub period: libc::c_uint, + pub track_started: bool, + pub write_cb: Option libc::c_int>, + pub start_frames: libc::c_uint, + pub frames_played: libc::c_uint, + pub frames_played_dmp: libc::c_uint, + pub current_sample_rate: libc::c_uint, + pub supported_rates: [libc::c_uint; 18], + pub default_sample_rate: libc::c_uint, + pub error_opening: bool, + pub device_frames: libc::c_uint, + pub updated: u32_t, + pub track_start_time: u32_t, + pub current_replay_gain: u32_t, + pub c2rust_unnamed: C2RustUnnamed, + pub next_sample_rate: libc::c_uint, + pub track_start: *mut u8_t, + pub gainL: u32_t, + pub gainR: u32_t, + pub invert: bool, + pub next_replay_gain: u32_t, + pub threshold: libc::c_uint, + pub fade: fade_state, + pub fade_start: *mut u8_t, + pub fade_end: *mut u8_t, + pub fade_dir: fade_dir, + pub fade_mode: fade_mode, + pub fade_secs: libc::c_uint, + pub rate_delay: libc::c_uint, + pub delay_active: bool, + pub stop_time: u32_t, + pub idle_to: u32_t, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub union C2RustUnnamed { + pub pause_frames: u32_t, + pub skip_frames: u32_t, + pub start_at: u32_t, +} +static mut loglevel: log_level = lERROR; static mut running: bool = 1 as libc::c_int != 0; // buffer to hold output data so we can block on writing outside of output lock, allocated on init - -static mut buf: *mut crate::squeezelite_h::u8_t = - 0 as *const crate::squeezelite_h::u8_t as *mut crate::squeezelite_h::u8_t; - +static mut buf: *mut u8_t = 0 as *const u8_t as *mut u8_t; static mut buffill: libc::c_uint = 0; - static mut bytes_per_frame: libc::c_int = 0; - -unsafe extern "C" fn _stdout_write_frames( - mut out_frames: 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; +unsafe extern "C" fn _stdout_write_frames(mut out_frames: frames_t, + mut silence: bool, mut gainL: s32_t, + mut gainR: s32_t, + mut cross_gain_in: s32_t, + mut cross_gain_out: s32_t, + mut cross_ptr: *mut *mut s32_t) + -> libc::c_int { + let mut obuf: *mut u8_t = 0 as *mut u8_t; if !silence { - if output.fade as libc::c_uint - == 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, - ); + if output.fade as libc::c_uint == + FADE_ACTIVE as libc::c_int as libc::c_uint && + output.fade_dir as libc::c_uint == + FADE_CROSS as libc::c_int as libc::c_uint && + !(*cross_ptr).is_null() { + _apply_cross(outputbuf, out_frames, cross_gain_in, cross_gain_out, + cross_ptr); } obuf = (*outputbuf).readp - } else { - obuf = silencebuf - } - 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, - ); + } else { obuf = silencebuf } + _scale_and_pack_frames(buf.offset(buffill.wrapping_mul(bytes_per_frame as + libc::c_uint) + as isize) as *mut libc::c_void, + obuf as *mut libc::c_void as *mut s32_t, + out_frames, gainL, gainR, output.format); buffill = buffill.wrapping_add(out_frames); return out_frames as libc::c_int; } - unsafe extern "C" fn output_thread() -> *mut libc::c_void { - crate::stdlib::pthread_mutex_lock(&mut (*outputbuf).mutex); + 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, + 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); + pthread_mutex_unlock(&mut (*outputbuf).mutex); while running { - crate::stdlib::pthread_mutex_lock(&mut (*outputbuf).mutex); + 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.updated = 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); + _output_frames(2048 as libc::c_int as frames_t); + 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, - ); + fwrite(buf as *const libc::c_void, + bytes_per_frame as libc::c_ulong, buffill as libc::c_ulong, + stdout); buffill = 0 as libc::c_int as libc::c_uint } } return 0 as *mut libc::c_void; } - -static mut thread: crate::stdlib::pthread_t = 0; +static mut thread: 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, -) { +pub unsafe extern "C" fn output_init_stdout(mut level: log_level, + mut output_buf_size: libc::c_uint, + mut params: *mut libc::c_char, + mut rates: *mut libc::c_uint, + mut rate_delay: libc::c_uint) { loglevel = level; - if loglevel as libc::c_uint >= 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, - ); + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d init output stdout\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 19], + &[libc::c_char; 19]>(b"output_init_stdout\x00")).as_ptr(), + 130 as libc::c_int); } - buf = crate::stdlib::malloc((2048 as libc::c_int * 8 as libc::c_int) as libc::c_ulong) - as *mut crate::squeezelite_h::u8_t; + buf = + malloc((2048 as libc::c_int * 8 as libc::c_int) as libc::c_ulong) as + *mut 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; + logprint(b"%s %s:%d unable to malloc buf\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 19], + &[libc::c_char; 19]>(b"output_init_stdout\x00")).as_ptr(), + 134 as libc::c_int); + return } buffill = 0 as libc::c_int as libc::c_uint; - 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::() 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, - ); + memset(&mut output as *mut outputstate as *mut libc::c_void, + 0 as libc::c_int, + ::std::mem::size_of::() as libc::c_ulong); + output.format = S32_LE; + output.start_frames = + (2048 as libc::c_int * 2 as libc::c_int) as libc::c_uint; + output.write_cb = + Some(_stdout_write_frames as + unsafe extern "C" fn(_: frames_t, _: bool, _: s32_t, + _: s32_t, _: s32_t, _: s32_t, + _: *mut *mut s32_t) -> libc::c_int); output.rate_delay = rate_delay; if !params.is_null() { - if crate::stdlib::strcmp(params, b"32\x00" as *const u8 as *const libc::c_char) == 0 { - output.format = crate::squeezelite_h::S32_LE + if strcmp(params, b"32\x00" as *const u8 as *const libc::c_char) == 0 + { + output.format = 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 strcmp(params, b"24\x00" as *const u8 as *const libc::c_char) == 0 + { + output.format = 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 + if strcmp(params, b"16\x00" as *const u8 as *const libc::c_char) == 0 + { + output.format = S16_LE } } // ensure output rate is specified to avoid test open if *rates.offset(0 as libc::c_int as isize) == 0 { - *rates.offset(0 as libc::c_int as isize) = 44100 as libc::c_int as libc::c_uint + *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 *mut libc::c_void>, - Option *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); + output_init_common(level, b"-\x00" as *const u8 as *const libc::c_char, + output_buf_size, rates, + 0 as libc::c_int as libc::c_uint); + let mut attr: pthread_attr_t = pthread_attr_t{__size: [0; 56],}; + pthread_attr_init(&mut attr); + pthread_attr_setstacksize(&mut attr, + (16384 as libc::c_int + + 64 as libc::c_int * 1024 as libc::c_int) as + size_t); + pthread_create(&mut thread, &mut attr, + ::std::mem::transmute:: *mut libc::c_void>, + Option + *mut libc::c_void>>(Some(::std::mem::transmute:: + *mut libc::c_void, + unsafe extern "C" fn() + -> + *mut libc::c_void>(output_thread))), + 0 as *mut libc::c_void); + pthread_attr_destroy(&mut attr); } -/* +/* * Squeezelite - lightweight headless squeezebox emulator * * (c) Adrian Smith 2012-2015, triode1@btinternet.com * Ralph Irving 2015-2017, ralph_irving@hotmail.com - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the @@ -327,20 +437,17 @@ pub unsafe extern "C" fn output_init_stdout( // 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, - ); + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d close output\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 20], + &[libc::c_char; 20]>(b"output_close_stdout\x00")).as_ptr(), + 174 as libc::c_int); } - crate::stdlib::pthread_mutex_lock(&mut (*outputbuf).mutex); + 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(); + pthread_mutex_unlock(&mut (*outputbuf).mutex); + free(buf as *mut libc::c_void); + output_close_common(); } diff --git a/src/pcm.rs b/src/pcm.rs index 054befd..5c261cd 100644 --- a/src/pcm.rs +++ b/src/pcm.rs @@ -1,245 +1,333 @@ 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::buffer::buf_adjust; -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::memcmp; -use crate::stdlib::memcpy; -use crate::stdlib::pthread_mutex_lock; -use crate::stdlib::pthread_mutex_unlock; extern "C" { - /* - * 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 . - * - */ #[no_mangle] - pub static mut loglevel: crate::squeezelite_h::log_level; + fn memcpy(_: *mut libc::c_void, _: *const libc::c_void, _: libc::c_ulong) + -> *mut libc::c_void; #[no_mangle] - pub static mut streambuf: *mut crate::squeezelite_h::buffer; + fn memcmp(_: *const libc::c_void, _: *const libc::c_void, + _: libc::c_ulong) -> libc::c_int; #[no_mangle] - pub static mut outputbuf: *mut crate::squeezelite_h::buffer; + fn _checkfade(_: bool); #[no_mangle] - pub static mut stream: crate::squeezelite_h::streamstate; + fn decode_newstream(sample_rate_0: libc::c_uint, + supported_rates: *mut libc::c_uint) -> libc::c_uint; #[no_mangle] - pub static mut output: crate::squeezelite_h::outputstate; + fn buf_adjust(buf: *mut buffer, mod_0: size_t); #[no_mangle] - pub static mut decode: crate::squeezelite_h::decodestate; + fn _buf_inc_writep(buf: *mut buffer, by: libc::c_uint); + #[no_mangle] + fn _buf_inc_readp(buf: *mut buffer, by: libc::c_uint); + #[no_mangle] + fn _buf_cont_write(buf: *mut buffer) -> libc::c_uint; + #[no_mangle] + fn _buf_cont_read(buf: *mut buffer) -> libc::c_uint; + #[no_mangle] + fn _buf_space(buf: *mut buffer) -> libc::c_uint; + #[no_mangle] + fn _buf_used(buf: *mut buffer) -> libc::c_uint; + #[no_mangle] + fn logprint(fmt: *const libc::c_char, _: ...); + #[no_mangle] + fn logtime() -> *const libc::c_char; + #[no_mangle] + fn pthread_mutex_unlock(__mutex: *mut pthread_mutex_t) -> libc::c_int; + #[no_mangle] + fn pthread_mutex_lock(__mutex: *mut pthread_mutex_t) -> libc::c_int; + /* + * 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 . + * + */ + #[no_mangle] + static mut loglevel: log_level; + #[no_mangle] + static mut streambuf: *mut buffer; + #[no_mangle] + static mut outputbuf: *mut buffer; + #[no_mangle] + static mut stream: streamstate; + #[no_mangle] + static mut output: outputstate; + #[no_mangle] + static mut decode: decodestate; +} +pub type size_t = libc::c_ulong; +pub type __uint8_t = libc::c_uchar; +pub type __int32_t = libc::c_int; +pub type __uint32_t = libc::c_uint; +pub type __uint64_t = libc::c_ulong; +pub type int32_t = __int32_t; +pub type u_int8_t = __uint8_t; +pub type u_int32_t = __uint32_t; +pub type u_int64_t = __uint64_t; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct __pthread_internal_list { + pub __prev: *mut __pthread_internal_list, + pub __next: *mut __pthread_internal_list, +} +pub type __pthread_list_t = __pthread_internal_list; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct __pthread_mutex_s { + pub __lock: libc::c_int, + pub __count: libc::c_uint, + pub __owner: libc::c_int, + pub __nusers: libc::c_uint, + pub __kind: libc::c_int, + pub __spins: libc::c_short, + pub __elision: libc::c_short, + pub __list: __pthread_list_t, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub union pthread_mutex_t { + pub __data: __pthread_mutex_s, + pub __size: [libc::c_char; 40], + pub __align: libc::c_long, +} +pub type u8_t = u_int8_t; +pub type u32_t = u_int32_t; +pub type u64_t = u_int64_t; +pub type s32_t = int32_t; +pub type frames_t = u32_t; +pub type log_level = libc::c_uint; +pub const lSDEBUG: log_level = 4; +pub const lDEBUG: log_level = 3; +pub const lINFO: log_level = 2; +pub const lWARN: log_level = 1; +pub const lERROR: log_level = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct buffer { + pub buf: *mut u8_t, + pub readp: *mut u8_t, + pub writep: *mut u8_t, + pub wrap: *mut u8_t, + pub size: size_t, + pub base_size: size_t, + pub mutex: pthread_mutex_t, +} +pub type stream_state = libc::c_uint; +pub const RECV_HEADERS: stream_state = 7; +pub const SEND_HEADERS: stream_state = 6; +pub const STREAMING_HTTP: stream_state = 5; +pub const STREAMING_FILE: stream_state = 4; +pub const STREAMING_BUFFERING: stream_state = 3; +pub const STREAMING_WAIT: stream_state = 2; +pub const DISCONNECT: stream_state = 1; +pub const STOPPED: stream_state = 0; +pub type disconnect_code = libc::c_uint; +pub const TIMEOUT: disconnect_code = 4; +pub const UNREACHABLE: disconnect_code = 3; +pub const REMOTE_DISCONNECT: disconnect_code = 2; +pub const LOCAL_DISCONNECT: disconnect_code = 1; +pub const DISCONNECT_OK: disconnect_code = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct streamstate { + pub state: stream_state, + pub disconnect: disconnect_code, + pub header: *mut libc::c_char, + pub header_len: size_t, + pub sent_headers: bool, + pub cont_wait: bool, + pub bytes: u64_t, + pub threshold: libc::c_uint, + pub meta_interval: u32_t, + pub meta_next: u32_t, + pub meta_left: u32_t, + pub meta_send: bool, +} +pub type decode_state = libc::c_uint; +pub const DECODE_ERROR: decode_state = 4; +pub const DECODE_COMPLETE: decode_state = 3; +pub const DECODE_RUNNING: decode_state = 2; +pub const DECODE_READY: decode_state = 1; +pub const DECODE_STOPPED: decode_state = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct decodestate { + pub state: decode_state, + pub new_stream: bool, + pub mutex: pthread_mutex_t, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct codec { + pub id: libc::c_char, + pub types: *mut libc::c_char, + pub min_read_bytes: libc::c_uint, + pub min_space: libc::c_uint, + pub open: Option ()>, + pub close: Option ()>, + pub decode: Option decode_state>, +} +pub type output_state = libc::c_int; +pub const OUTPUT_START_AT: output_state = 5; +pub const OUTPUT_SKIP_FRAMES: output_state = 4; +pub const OUTPUT_PAUSE_FRAMES: output_state = 3; +pub const OUTPUT_RUNNING: output_state = 2; +pub const OUTPUT_BUFFER: output_state = 1; +pub const OUTPUT_STOPPED: output_state = 0; +pub const OUTPUT_OFF: output_state = -1; +pub type output_format = libc::c_uint; +pub const S16_LE: output_format = 3; +pub const S24_3LE: output_format = 2; +pub const S24_LE: output_format = 1; +pub const S32_LE: output_format = 0; +pub type fade_state = libc::c_uint; +pub const FADE_ACTIVE: fade_state = 2; +pub const FADE_DUE: fade_state = 1; +pub const FADE_INACTIVE: fade_state = 0; +pub type fade_dir = libc::c_uint; +pub const FADE_CROSS: fade_dir = 3; +pub const FADE_DOWN: fade_dir = 2; +pub const FADE_UP: fade_dir = 1; +pub type fade_mode = libc::c_uint; +pub const FADE_INOUT: fade_mode = 4; +pub const FADE_OUT: fade_mode = 3; +pub const FADE_IN: fade_mode = 2; +pub const FADE_CROSSFADE: fade_mode = 1; +pub const FADE_NONE: fade_mode = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct outputstate { + pub state: output_state, + pub format: output_format, + pub device: *const libc::c_char, + pub buffer: libc::c_uint, + pub period: libc::c_uint, + pub track_started: bool, + pub write_cb: Option libc::c_int>, + pub start_frames: libc::c_uint, + pub frames_played: libc::c_uint, + pub frames_played_dmp: libc::c_uint, + pub current_sample_rate: libc::c_uint, + pub supported_rates: [libc::c_uint; 18], + pub default_sample_rate: libc::c_uint, + pub error_opening: bool, + pub device_frames: libc::c_uint, + pub updated: u32_t, + pub track_start_time: u32_t, + pub current_replay_gain: u32_t, + pub c2rust_unnamed: C2RustUnnamed, + pub next_sample_rate: libc::c_uint, + pub track_start: *mut u8_t, + pub gainL: u32_t, + pub gainR: u32_t, + pub invert: bool, + pub next_replay_gain: u32_t, + pub threshold: libc::c_uint, + pub fade: fade_state, + pub fade_start: *mut u8_t, + pub fade_end: *mut u8_t, + pub fade_dir: fade_dir, + pub fade_mode: fade_mode, + pub fade_secs: libc::c_uint, + pub rate_delay: libc::c_uint, + pub delay_active: bool, + pub stop_time: u32_t, + pub idle_to: u32_t, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub union C2RustUnnamed { + pub pause_frames: u32_t, + pub skip_frames: u32_t, + pub start_at: u32_t, } - pub const AIFF: header_format = 2; - pub type header_format = libc::c_uint; - pub const WAVE: header_format = 1; - pub const UNKNOWN: header_format = 0; #[no_mangle] - pub static mut pcm_check_header: bool = 0 as libc::c_int != 0; - -static mut sample_rates: [crate::squeezelite_h::u32_t; 17] = [ - 11025 as libc::c_int as crate::squeezelite_h::u32_t, - 22050 as libc::c_int as crate::squeezelite_h::u32_t, - 32000 as libc::c_int as crate::squeezelite_h::u32_t, - 44100 as libc::c_int as crate::squeezelite_h::u32_t, - 48000 as libc::c_int as crate::squeezelite_h::u32_t, - 8000 as libc::c_int as crate::squeezelite_h::u32_t, - 12000 as libc::c_int as crate::squeezelite_h::u32_t, - 16000 as libc::c_int as crate::squeezelite_h::u32_t, - 24000 as libc::c_int as crate::squeezelite_h::u32_t, - 96000 as libc::c_int as crate::squeezelite_h::u32_t, - 88200 as libc::c_int as crate::squeezelite_h::u32_t, - 176400 as libc::c_int as crate::squeezelite_h::u32_t, - 192000 as libc::c_int as crate::squeezelite_h::u32_t, - 352800 as libc::c_int as crate::squeezelite_h::u32_t, - 384000 as libc::c_int as crate::squeezelite_h::u32_t, - 705600 as libc::c_int as crate::squeezelite_h::u32_t, - 768000 as libc::c_int as crate::squeezelite_h::u32_t, -]; - -static mut sample_rate: crate::squeezelite_h::u32_t = 0; - -static mut sample_size: crate::squeezelite_h::u32_t = 0; - -static mut channels: crate::squeezelite_h::u32_t = 0; - +static mut sample_rates: [u32_t; 17] = + [11025 as libc::c_int as u32_t, 22050 as libc::c_int as u32_t, + 32000 as libc::c_int as u32_t, 44100 as libc::c_int as u32_t, + 48000 as libc::c_int as u32_t, 8000 as libc::c_int as u32_t, + 12000 as libc::c_int as u32_t, 16000 as libc::c_int as u32_t, + 24000 as libc::c_int as u32_t, 96000 as libc::c_int as u32_t, + 88200 as libc::c_int as u32_t, 176400 as libc::c_int as u32_t, + 192000 as libc::c_int as u32_t, 352800 as libc::c_int as u32_t, + 384000 as libc::c_int as u32_t, 705600 as libc::c_int as u32_t, + 768000 as libc::c_int as u32_t]; +static mut sample_rate: u32_t = 0; +static mut sample_size: u32_t = 0; +static mut channels: u32_t = 0; static mut bigendian: bool = false; - static mut limit: bool = false; - -static mut audio_left: crate::squeezelite_h::u32_t = 0; - -static mut bytes_per_frame: crate::squeezelite_h::u32_t = 0; - +static mut audio_left: u32_t = 0; +static mut bytes_per_frame: u32_t = 0; unsafe extern "C" fn _check_header() { - let mut ptr = (*streambuf).readp; - let mut 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) - }; - let mut format = UNKNOWN; + let mut ptr: *mut u8_t = (*streambuf).readp; + let mut bytes: libc::c_uint = + if _buf_used(streambuf) < _buf_cont_read(streambuf) { + _buf_used(streambuf) + } else { _buf_cont_read(streambuf) }; + let mut format: header_format = UNKNOWN; // simple parsing of wav and aiff headers and get to samples if bytes > 12 as libc::c_int as libc::c_uint { - if crate::stdlib::memcmp( - ptr as *const libc::c_void, - b"RIFF\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(8 as libc::c_int as isize) as *const libc::c_void, - b"WAVE\x00" as *const u8 as *const libc::c_char as *const libc::c_void, - 4 as libc::c_int as libc::c_ulong, - ) == 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 WAVE\n\x00" as *const u8 as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 14], &[libc::c_char; 14]>( - b"_check_header\x00", - )) - .as_ptr(), - 80 as libc::c_int, - ); + if memcmp(ptr as *const libc::c_void, + b"RIFF\x00" as *const u8 as *const libc::c_char as + *const libc::c_void, 4 as libc::c_int as libc::c_ulong) + == 0 && + memcmp(ptr.offset(8 as libc::c_int as isize) as + *const libc::c_void, + b"WAVE\x00" as *const u8 as *const libc::c_char as + *const libc::c_void, + 4 as libc::c_int as libc::c_ulong) == 0 { + if loglevel as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d WAVE\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 14], + &[libc::c_char; 14]>(b"_check_header\x00")).as_ptr(), + 80 as libc::c_int); } format = WAVE - } else if crate::stdlib::memcmp( - ptr as *const libc::c_void, - b"FORM\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(8 as libc::c_int as isize) as *const libc::c_void, - b"AIFF\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(8 as libc::c_int as isize) as *const libc::c_void, - b"AIFC\x00" as *const u8 as *const libc::c_char as *const libc::c_void, - 4 as libc::c_int as libc::c_ulong, - ) == 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 AIFF\n\x00" as *const u8 as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 14], &[libc::c_char; 14]>( - b"_check_header\x00", - )) - .as_ptr(), - 83 as libc::c_int, - ); + } else if memcmp(ptr as *const libc::c_void, + b"FORM\x00" as *const u8 as *const libc::c_char as + *const libc::c_void, + 4 as libc::c_int as libc::c_ulong) == 0 && + (memcmp(ptr.offset(8 as libc::c_int as isize) as + *const libc::c_void, + b"AIFF\x00" as *const u8 as *const libc::c_char + as *const libc::c_void, + 4 as libc::c_int as libc::c_ulong) == 0 || + memcmp(ptr.offset(8 as libc::c_int as isize) as + *const libc::c_void, + b"AIFC\x00" as *const u8 as + *const libc::c_char as + *const libc::c_void, + 4 as libc::c_int as libc::c_ulong) == 0) { + if loglevel as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d AIFF\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 14], + &[libc::c_char; 14]>(b"_check_header\x00")).as_ptr(), + 83 as libc::c_int); } format = AIFF } @@ -250,215 +338,195 @@ unsafe extern "C" fn _check_header() { while bytes >= 8 as libc::c_int as libc::c_uint { let mut id: [libc::c_char; 5] = [0; 5]; let mut len: libc::c_uint = 0; - crate::stdlib::memcpy( - id.as_mut_ptr() as *mut libc::c_void, - ptr as *const libc::c_void, - 4 as libc::c_int as libc::c_ulong, - ); + memcpy(id.as_mut_ptr() as *mut libc::c_void, + ptr as *const libc::c_void, + 4 as libc::c_int as libc::c_ulong); id[4 as libc::c_int as usize] = '\u{0}' as i32 as libc::c_char; if format as libc::c_uint == WAVE as libc::c_int as libc::c_uint { - len = (*ptr.offset(4 as libc::c_int as isize) as libc::c_int - | (*ptr.offset(5 as libc::c_int as isize) as libc::c_int) << 8 as libc::c_int - | (*ptr.offset(6 as libc::c_int as isize) as libc::c_int) << 16 as libc::c_int - | (*ptr.offset(7 as libc::c_int as isize) as libc::c_int) << 24 as libc::c_int) - as libc::c_uint + len = + (*ptr.offset(4 as libc::c_int as isize) as libc::c_int | + (*ptr.offset(5 as libc::c_int as isize) as + libc::c_int) << 8 as libc::c_int | + (*ptr.offset(6 as libc::c_int as isize) as + libc::c_int) << 16 as libc::c_int | + (*ptr.offset(7 as libc::c_int as isize) as + libc::c_int) << 24 as libc::c_int) as + libc::c_uint } else { - len = ((*ptr.offset(4 as libc::c_int as isize) as libc::c_int) << 24 as libc::c_int - | (*ptr.offset(5 as libc::c_int as isize) as libc::c_int) << 16 as libc::c_int - | (*ptr.offset(6 as libc::c_int as isize) as libc::c_int) << 8 as libc::c_int - | *ptr.offset(7 as libc::c_int as isize) as libc::c_int) - as libc::c_uint + len = + ((*ptr.offset(4 as libc::c_int as isize) as libc::c_int) + << 24 as libc::c_int | + (*ptr.offset(5 as libc::c_int as isize) as + libc::c_int) << 16 as libc::c_int | + (*ptr.offset(6 as libc::c_int as isize) as + libc::c_int) << 8 as libc::c_int | + *ptr.offset(7 as libc::c_int as isize) 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 header: %s len: %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"_check_header\x00", - )) - .as_ptr(), - 104 as libc::c_int, - id.as_mut_ptr(), - len, - ); + if loglevel as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d header: %s len: %d\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 14], + &[libc::c_char; 14]>(b"_check_header\x00")).as_ptr(), + 104 as libc::c_int, id.as_mut_ptr(), len); } if format as libc::c_uint == WAVE as libc::c_int as libc::c_uint - && crate::stdlib::memcmp( - ptr as *const libc::c_void, - b"data\x00" as *const u8 as *const libc::c_char as *const libc::c_void, - 4 as libc::c_int as libc::c_ulong, - ) == 0 - { + && + memcmp(ptr as *const libc::c_void, + b"data\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(8 as libc::c_int as isize); - crate::src::buffer::_buf_inc_readp( - streambuf, - ptr.wrapping_offset_from((*streambuf).readp) as libc::c_long as libc::c_uint, - ); + _buf_inc_readp(streambuf, + ptr.wrapping_offset_from((*streambuf).readp) as + libc::c_long as libc::c_uint); audio_left = len; - if audio_left == 0xffffffff as libc::c_uint - || audio_left == 0x7fffeffc 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 wav audio size unknown: %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"_check_header\x00", - )) - .as_ptr(), - 112 as libc::c_int, - audio_left, - ); + if audio_left == 0xffffffff as libc::c_uint || + audio_left == 0x7fffeffc as libc::c_int as libc::c_uint + { + if loglevel as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d wav audio size unknown: %u\n\x00" + as *const u8 as *const libc::c_char, + logtime(), + (*::std::mem::transmute::<&[u8; 14], + &[libc::c_char; 14]>(b"_check_header\x00")).as_ptr(), + 112 as libc::c_int, audio_left); } limit = 0 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 wav audio size: %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"_check_header\x00", - )) - .as_ptr(), - 115 as libc::c_int, - audio_left, - ); + if loglevel as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d wav audio size: %u\n\x00" as + *const u8 as *const libc::c_char, + logtime(), + (*::std::mem::transmute::<&[u8; 14], + &[libc::c_char; 14]>(b"_check_header\x00")).as_ptr(), + 115 as libc::c_int, audio_left); } limit = 1 as libc::c_int != 0 } - return; + return } if format as libc::c_uint == AIFF as libc::c_int as libc::c_uint - && crate::stdlib::memcmp( - ptr as *const libc::c_void, - b"SSND\x00" as *const u8 as *const libc::c_char as *const libc::c_void, - 4 as libc::c_int as libc::c_ulong, - ) == 0 - && bytes >= 16 as libc::c_int as libc::c_uint - { - let mut offset = ((*ptr.offset(8 as libc::c_int as isize) as libc::c_int) - << 24 as libc::c_int - | (*ptr.offset(9 as libc::c_int as isize) as libc::c_int) << 16 as libc::c_int - | (*ptr.offset(10 as libc::c_int as isize) as libc::c_int) << 8 as libc::c_int - | *ptr.offset(11 as libc::c_int as isize) as libc::c_int) - as libc::c_uint; + && + memcmp(ptr as *const libc::c_void, + b"SSND\x00" as *const u8 as *const libc::c_char as + *const libc::c_void, + 4 as libc::c_int as libc::c_ulong) == 0 && + bytes >= 16 as libc::c_int as libc::c_uint { + let mut offset: libc::c_uint = + ((*ptr.offset(8 as libc::c_int as isize) as libc::c_int) + << 24 as libc::c_int | + (*ptr.offset(9 as libc::c_int as isize) as + libc::c_int) << 16 as libc::c_int | + (*ptr.offset(10 as libc::c_int as isize) as + libc::c_int) << 8 as libc::c_int | + *ptr.offset(11 as libc::c_int as isize) as + libc::c_int) as libc::c_uint; // following 4 bytes is blocksize - ignored - ptr = ptr.offset((8 as libc::c_int + 8 as libc::c_int) as isize); - crate::src::buffer::_buf_inc_readp( - streambuf, - ptr.offset(offset as isize) - .wrapping_offset_from((*streambuf).readp) - as libc::c_long as libc::c_uint, - ); + ptr = + ptr.offset((8 as libc::c_int + 8 as libc::c_int) as + isize); + _buf_inc_readp(streambuf, + ptr.offset(offset as + isize).wrapping_offset_from((*streambuf).readp) + as libc::c_long as libc::c_uint); // Reading from an upsampled stream, length could be wrong. - // Only use length in header for files. - if stream.state as libc::c_uint - == crate::squeezelite_h::STREAMING_FILE as libc::c_int as libc::c_uint - { - audio_left = len - .wrapping_sub(8 as libc::c_int as libc::c_uint) - .wrapping_sub(offset); - 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 aif audio size: %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"_check_header\x00", - )) - .as_ptr(), - 131 as libc::c_int, - audio_left, - ); + // Only use length in header for files. + if stream.state as libc::c_uint == + STREAMING_FILE as libc::c_int as libc::c_uint { + audio_left = + len.wrapping_sub(8 as libc::c_int as + libc::c_uint).wrapping_sub(offset); + if loglevel as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d aif audio size: %u\n\x00" as + *const u8 as *const libc::c_char, + logtime(), + (*::std::mem::transmute::<&[u8; 14], + &[libc::c_char; 14]>(b"_check_header\x00")).as_ptr(), + 131 as libc::c_int, audio_left); } limit = 1 as libc::c_int != 0 } - return; + return } if format as libc::c_uint == WAVE as libc::c_int as libc::c_uint - && crate::stdlib::memcmp( - ptr as *const libc::c_void, - b"fmt \x00" as *const u8 as *const libc::c_char as *const libc::c_void, - 4 as libc::c_int as libc::c_ulong, - ) == 0 - && bytes >= 24 as libc::c_int as libc::c_uint - { + && + memcmp(ptr as *const libc::c_void, + b"fmt \x00" as *const u8 as *const libc::c_char as + *const libc::c_void, + 4 as libc::c_int as libc::c_ulong) == 0 && + bytes >= 24 as libc::c_int as libc::c_uint { // override the server parsed values with our own - channels = (*ptr.offset(10 as libc::c_int as isize) as libc::c_int - | (*ptr.offset(11 as libc::c_int as isize) as libc::c_int) << 8 as libc::c_int) - as crate::squeezelite_h::u32_t; - sample_rate = (*ptr.offset(12 as libc::c_int as isize) as libc::c_int - | (*ptr.offset(13 as libc::c_int as isize) as libc::c_int) << 8 as libc::c_int - | (*ptr.offset(14 as libc::c_int as isize) as libc::c_int) << 16 as libc::c_int - | (*ptr.offset(15 as libc::c_int as isize) as libc::c_int) << 24 as libc::c_int) - as crate::squeezelite_h::u32_t; - sample_size = ((*ptr.offset(22 as libc::c_int as isize) as libc::c_int - | (*ptr.offset(23 as libc::c_int as isize) as libc::c_int) << 8 as libc::c_int) - / 8 as libc::c_int) - as crate::squeezelite_h::u32_t; + channels = + (*ptr.offset(10 as libc::c_int as isize) as libc::c_int | + (*ptr.offset(11 as libc::c_int as isize) as + libc::c_int) << 8 as libc::c_int) as u32_t; + sample_rate = + (*ptr.offset(12 as libc::c_int as isize) as libc::c_int | + (*ptr.offset(13 as libc::c_int as isize) as + libc::c_int) << 8 as libc::c_int | + (*ptr.offset(14 as libc::c_int as isize) as + libc::c_int) << 16 as libc::c_int | + (*ptr.offset(15 as libc::c_int as isize) as + libc::c_int) << 24 as libc::c_int) as u32_t; + sample_size = + ((*ptr.offset(22 as libc::c_int as isize) as libc::c_int | + (*ptr.offset(23 as libc::c_int as isize) as + libc::c_int) << 8 as libc::c_int) / + 8 as libc::c_int) as u32_t; bigendian = 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 pcm size: %u rate: %u chan: %u bigendian: %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"_check_header\x00", - )) - .as_ptr(), - 143 as libc::c_int, - sample_size, - sample_rate, - channels, - bigendian as libc::c_int, - ); + if loglevel as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d pcm size: %u rate: %u chan: %u bigendian: %u\n\x00" + as *const u8 as *const libc::c_char, + logtime(), + (*::std::mem::transmute::<&[u8; 14], + &[libc::c_char; 14]>(b"_check_header\x00")).as_ptr(), + 143 as libc::c_int, sample_size, sample_rate, + channels, bigendian as libc::c_int); } } if format as libc::c_uint == AIFF as libc::c_int as libc::c_uint - && crate::stdlib::memcmp( - ptr as *const libc::c_void, - b"COMM\x00" as *const u8 as *const libc::c_char as *const libc::c_void, - 4 as libc::c_int as libc::c_ulong, - ) == 0 - && bytes >= 26 as libc::c_int as libc::c_uint - { + && + memcmp(ptr as *const libc::c_void, + b"COMM\x00" as *const u8 as *const libc::c_char as + *const libc::c_void, + 4 as libc::c_int as libc::c_ulong) == 0 && + bytes >= 26 as libc::c_int as libc::c_uint { let mut exponent: libc::c_int = 0; // override the server parsed values with our own - channels = ((*ptr.offset(8 as libc::c_int as isize) as libc::c_int) - << 8 as libc::c_int - | *ptr.offset(9 as libc::c_int as isize) as libc::c_int) - as crate::squeezelite_h::u32_t; + channels = + ((*ptr.offset(8 as libc::c_int as isize) as libc::c_int) + << 8 as libc::c_int | + *ptr.offset(9 as libc::c_int as isize) as + libc::c_int) as u32_t; sample_size = - (((*ptr.offset(14 as libc::c_int as isize) as libc::c_int) << 8 as libc::c_int - | *ptr.offset(15 as libc::c_int as isize) as libc::c_int) - / 8 as libc::c_int) as crate::squeezelite_h::u32_t; + (((*ptr.offset(14 as libc::c_int as isize) as libc::c_int) + << 8 as libc::c_int | + *ptr.offset(15 as libc::c_int as isize) as + libc::c_int) / 8 as libc::c_int) as u32_t; bigendian = 1 as libc::c_int != 0; // sample rate is encoded as IEEE 80 bit extended format - // make some assumptions to simplify processing - only use first 32 bits of mantissa - exponent = ((*ptr.offset(16 as libc::c_int as isize) as libc::c_int - & 0x7f as libc::c_int) - << 8 as libc::c_int - | *ptr.offset(17 as libc::c_int as isize) as libc::c_int) - - 16383 as libc::c_int - - 31 as libc::c_int; - sample_rate = ((*ptr.offset(18 as libc::c_int as isize) as libc::c_int) - << 24 as libc::c_int - | (*ptr.offset(19 as libc::c_int as isize) as libc::c_int) << 16 as libc::c_int - | (*ptr.offset(20 as libc::c_int as isize) as libc::c_int) << 8 as libc::c_int - | *ptr.offset(21 as libc::c_int as isize) as libc::c_int) - as crate::squeezelite_h::u32_t; + // make some assumptions to simplify processing - only use first 32 bits of mantissa + exponent = + ((*ptr.offset(16 as libc::c_int as isize) as libc::c_int & + 0x7f as libc::c_int) << 8 as libc::c_int | + *ptr.offset(17 as libc::c_int as isize) as + libc::c_int) - 16383 as libc::c_int - + 31 as libc::c_int; + sample_rate = + ((*ptr.offset(18 as libc::c_int as isize) as libc::c_int) + << 24 as libc::c_int | + (*ptr.offset(19 as libc::c_int as isize) as + libc::c_int) << 16 as libc::c_int | + (*ptr.offset(20 as libc::c_int as isize) as + libc::c_int) << 8 as libc::c_int | + *ptr.offset(21 as libc::c_int as isize) as + libc::c_int) as u32_t; while exponent < 0 as libc::c_int { sample_rate >>= 1 as libc::c_int; exponent += 1 @@ -467,325 +535,276 @@ unsafe extern "C" fn _check_header() { sample_rate <<= 1 as libc::c_int; exponent -= 1 } - 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 pcm size: %u rate: %u chan: %u bigendian: %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"_check_header\x00", - )) - .as_ptr(), - 158 as libc::c_int, - sample_size, - sample_rate, - channels, - bigendian as libc::c_int, - ); + if loglevel as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d pcm size: %u rate: %u chan: %u bigendian: %u\n\x00" + as *const u8 as *const libc::c_char, + logtime(), + (*::std::mem::transmute::<&[u8; 14], + &[libc::c_char; 14]>(b"_check_header\x00")).as_ptr(), + 158 as libc::c_int, sample_size, sample_rate, + channels, bigendian as libc::c_int); } } if bytes >= len.wrapping_add(8 as libc::c_int as libc::c_uint) { - ptr = ptr.offset(len.wrapping_add(8 as libc::c_int as libc::c_uint) as isize); - bytes = bytes.wrapping_sub(len.wrapping_add(8 as libc::c_int as libc::c_uint)) + ptr = + ptr.offset(len.wrapping_add(8 as libc::c_int as + libc::c_uint) as isize); + bytes = + bytes.wrapping_sub(len.wrapping_add(8 as libc::c_int as + libc::c_uint)) } 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 run out of data\n\x00" as *const u8 as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 14], &[libc::c_char; 14]>( - b"_check_header\x00", - )) - .as_ptr(), - 165 as libc::c_int, - ); + if loglevel as libc::c_uint >= + lWARN as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d run out of data\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 14], + &[libc::c_char; 14]>(b"_check_header\x00")).as_ptr(), + 165 as libc::c_int); } - return; + return } } - } 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 unknown format - can\'t parse header\n\x00" as *const u8 - as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 14], &[libc::c_char; 14]>(b"_check_header\x00")) - .as_ptr(), - 171 as libc::c_int, - ); + } else if loglevel as libc::c_uint >= lWARN as libc::c_int as libc::c_uint + { + logprint(b"%s %s:%d unknown format - can\'t parse header\n\x00" as + *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 14], + &[libc::c_char; 14]>(b"_check_header\x00")).as_ptr(), + 171 as libc::c_int); }; } - -unsafe extern "C" fn pcm_decode() -> crate::squeezelite_h::decode_state { +unsafe extern "C" fn pcm_decode() -> decode_state { let mut bytes: libc::c_uint = 0; let mut in_0: libc::c_uint = 0; let mut out: libc::c_uint = 0; - let mut frames: crate::squeezelite_h::frames_t = 0; - let mut count: crate::squeezelite_h::frames_t = 0; - let mut optr = 0 as *mut crate::squeezelite_h::u32_t; - let mut iptr = 0 as *mut crate::squeezelite_h::u8_t; - let mut tmp: [crate::squeezelite_h::u8_t; 16] = [0; 16]; - crate::stdlib::pthread_mutex_lock(&mut (*streambuf).mutex); - if decode.new_stream as libc::c_int != 0 - && (stream.state as libc::c_uint - == crate::squeezelite_h::STREAMING_FILE as libc::c_int as libc::c_uint - || pcm_check_header as libc::c_int != 0) - { + let mut frames: frames_t = 0; + let mut count: frames_t = 0; + let mut optr: *mut u32_t = 0 as *mut u32_t; + let mut iptr: *mut u8_t = 0 as *mut u8_t; + let mut tmp: [u8_t; 16] = [0; 16]; + pthread_mutex_lock(&mut (*streambuf).mutex); + if decode.new_stream as libc::c_int != 0 && + (stream.state as libc::c_uint == + STREAMING_FILE as libc::c_int as libc::c_uint || + pcm_check_header as libc::c_int != 0) { _check_header(); } - 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) - }; - out = (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); - if 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_uint - || limit as libc::c_int != 0 && audio_left == 0 as libc::c_int as libc::c_uint - { - crate::stdlib::pthread_mutex_unlock(&mut (*outputbuf).mutex); - crate::stdlib::pthread_mutex_unlock(&mut (*streambuf).mutex); - return crate::squeezelite_h::DECODE_COMPLETE; + pthread_mutex_lock(&mut (*outputbuf).mutex); + bytes = + if _buf_used(streambuf) < _buf_cont_read(streambuf) { + _buf_used(streambuf) + } else { _buf_cont_read(streambuf) }; + out = + (if _buf_space(outputbuf) < _buf_cont_write(outputbuf) { + _buf_space(outputbuf) + } else { + _buf_cont_write(outputbuf) + }).wrapping_div(8 as libc::c_int as libc::c_uint); + if stream.state as libc::c_uint <= + DISCONNECT as libc::c_int as libc::c_uint && + bytes == 0 as libc::c_int as libc::c_uint || + limit as libc::c_int != 0 && + audio_left == 0 as libc::c_int as libc::c_uint { + pthread_mutex_unlock(&mut (*outputbuf).mutex); + pthread_mutex_unlock(&mut (*streambuf).mutex); + return DECODE_COMPLETE } if decode.new_stream { - 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"pcm_decode\x00")) - .as_ptr(), - 206 as libc::c_int, - ); + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d setting track_start\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 11], + &[libc::c_char; 11]>(b"pcm_decode\x00")).as_ptr(), + 206 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(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); - } + decode_newstream(sample_rate, + output.supported_rates.as_mut_ptr()); + if output.fade_mode as u64 != 0 { _checkfade(1 as libc::c_int != 0); } bytes_per_frame = channels.wrapping_mul(sample_size) } - optr = (*outputbuf).writep as *mut crate::squeezelite_h::u32_t; + optr = (*outputbuf).writep as *mut u32_t; iptr = (*streambuf).readp; in_0 = bytes.wrapping_div(bytes_per_frame); // handle frame wrapping round end of streambuf - // - only need if resizing of streambuf does not avoid this, could occur in localfile case - if in_0 == 0 as libc::c_int as libc::c_uint - && bytes > 0 as libc::c_int as libc::c_uint - && crate::squeezelite_h::_buf_used(streambuf) >= bytes_per_frame - { - crate::stdlib::memcpy( - tmp.as_mut_ptr() as *mut libc::c_void, - iptr as *const libc::c_void, - bytes as libc::c_ulong, - ); - crate::stdlib::memcpy( - tmp.as_mut_ptr().offset(bytes as isize) as *mut libc::c_void, - (*streambuf).buf as *const libc::c_void, - bytes_per_frame.wrapping_sub(bytes) as libc::c_ulong, - ); + // - only need if resizing of streambuf does not avoid this, could occur in localfile case + if in_0 == 0 as libc::c_int as libc::c_uint && + bytes > 0 as libc::c_int as libc::c_uint && + _buf_used(streambuf) >= bytes_per_frame { + memcpy(tmp.as_mut_ptr() as *mut libc::c_void, + iptr as *const libc::c_void, bytes as libc::c_ulong); + memcpy(tmp.as_mut_ptr().offset(bytes as isize) as *mut libc::c_void, + (*streambuf).buf as *const libc::c_void, + bytes_per_frame.wrapping_sub(bytes) as libc::c_ulong); iptr = tmp.as_mut_ptr(); in_0 = 1 as libc::c_int as libc::c_uint } frames = if in_0 < out { in_0 } else { out }; - frames = if frames < 4096 as libc::c_int as libc::c_uint { - frames - } else { - 4096 as libc::c_int as libc::c_uint - }; - if limit as libc::c_int != 0 && frames.wrapping_mul(bytes_per_frame) > audio_left { - 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 reached end of audio\n\x00" as *const u8 as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 11], &[libc::c_char; 11]>(b"pcm_decode\x00")) - .as_ptr(), - 261 as libc::c_int, - ); + frames = + if frames < 4096 as libc::c_int as libc::c_uint { + frames + } else { 4096 as libc::c_int as libc::c_uint }; + if limit as libc::c_int != 0 && + frames.wrapping_mul(bytes_per_frame) > audio_left { + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d reached end of audio\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 11], + &[libc::c_char; 11]>(b"pcm_decode\x00")).as_ptr(), + 261 as libc::c_int); } frames = audio_left.wrapping_div(bytes_per_frame) } count = frames.wrapping_mul(channels); if channels == 2 as libc::c_int as libc::c_uint { if sample_size == 1 as libc::c_int as libc::c_uint { - loop { + loop { let fresh0 = count; count = count.wrapping_sub(1); - if !(fresh0 != 0) { - break; - } + if !(fresh0 != 0) { break ; } let fresh1 = iptr; iptr = iptr.offset(1); let fresh2 = optr; optr = optr.offset(1); *fresh2 = - ((*fresh1 as libc::c_int) << 24 as libc::c_int) as crate::squeezelite_h::u32_t + ((*fresh1 as libc::c_int) << 24 as libc::c_int) as u32_t } } else if sample_size == 2 as libc::c_int as libc::c_uint { if bigendian { - loop { + loop { let fresh3 = count; count = count.wrapping_sub(1); - if !(fresh3 != 0) { - break; - } + if !(fresh3 != 0) { break ; } let fresh4 = optr; optr = optr.offset(1); - *fresh4 = ((*iptr as libc::c_int) << 24 as libc::c_int - | (*iptr.offset(1 as libc::c_int as isize) as libc::c_int) - << 16 as libc::c_int) - as crate::squeezelite_h::u32_t; + *fresh4 = + ((*iptr as libc::c_int) << 24 as libc::c_int | + (*iptr.offset(1 as libc::c_int as isize) as + libc::c_int) << 16 as libc::c_int) as u32_t; iptr = iptr.offset(2 as libc::c_int as isize) } } else { - loop { + loop { let fresh5 = count; count = count.wrapping_sub(1); - if !(fresh5 != 0) { - break; - } + if !(fresh5 != 0) { break ; } let fresh6 = optr; optr = optr.offset(1); - *fresh6 = ((*iptr as libc::c_int) << 16 as libc::c_int - | (*iptr.offset(1 as libc::c_int as isize) as libc::c_int) - << 24 as libc::c_int) - as crate::squeezelite_h::u32_t; + *fresh6 = + ((*iptr as libc::c_int) << 16 as libc::c_int | + (*iptr.offset(1 as libc::c_int as isize) as + libc::c_int) << 24 as libc::c_int) as u32_t; iptr = iptr.offset(2 as libc::c_int as isize) } } } else if sample_size == 3 as libc::c_int as libc::c_uint { if bigendian { - loop { + loop { let fresh7 = count; count = count.wrapping_sub(1); - if !(fresh7 != 0) { - break; - } + if !(fresh7 != 0) { break ; } let fresh8 = optr; optr = optr.offset(1); - *fresh8 = ((*iptr as libc::c_int) << 24 as libc::c_int - | (*iptr.offset(1 as libc::c_int as isize) as libc::c_int) - << 16 as libc::c_int - | (*iptr.offset(2 as libc::c_int as isize) as libc::c_int) - << 8 as libc::c_int) - as crate::squeezelite_h::u32_t; + *fresh8 = + ((*iptr as libc::c_int) << 24 as libc::c_int | + (*iptr.offset(1 as libc::c_int as isize) as + libc::c_int) << 16 as libc::c_int | + (*iptr.offset(2 as libc::c_int as isize) as + libc::c_int) << 8 as libc::c_int) as u32_t; iptr = iptr.offset(3 as libc::c_int as isize) } } else { - loop { + loop { let fresh9 = count; count = count.wrapping_sub(1); - if !(fresh9 != 0) { - break; - } + if !(fresh9 != 0) { break ; } let fresh10 = optr; optr = optr.offset(1); - *fresh10 = ((*iptr as libc::c_int) << 8 as libc::c_int - | (*iptr.offset(1 as libc::c_int as isize) as libc::c_int) - << 16 as libc::c_int - | (*iptr.offset(2 as libc::c_int as isize) as libc::c_int) - << 24 as libc::c_int) - as crate::squeezelite_h::u32_t; + *fresh10 = + ((*iptr as libc::c_int) << 8 as libc::c_int | + (*iptr.offset(1 as libc::c_int as isize) as + libc::c_int) << 16 as libc::c_int | + (*iptr.offset(2 as libc::c_int as isize) as + libc::c_int) << 24 as libc::c_int) as u32_t; iptr = iptr.offset(3 as libc::c_int as isize) } } } else if sample_size == 4 as libc::c_int as libc::c_uint { if bigendian { - loop { + loop { let fresh11 = count; count = count.wrapping_sub(1); - if !(fresh11 != 0) { - break; - } + if !(fresh11 != 0) { break ; } let fresh12 = optr; optr = optr.offset(1); - *fresh12 = ((*iptr as libc::c_int) << 24 as libc::c_int - | (*iptr.offset(1 as libc::c_int as isize) as libc::c_int) - << 16 as libc::c_int - | (*iptr.offset(2 as libc::c_int as isize) as libc::c_int) - << 8 as libc::c_int - | *iptr.offset(3 as libc::c_int as isize) as libc::c_int) - as crate::squeezelite_h::u32_t; + *fresh12 = + ((*iptr as libc::c_int) << 24 as libc::c_int | + (*iptr.offset(1 as libc::c_int as isize) as + libc::c_int) << 16 as libc::c_int | + (*iptr.offset(2 as libc::c_int as isize) as + libc::c_int) << 8 as libc::c_int | + *iptr.offset(3 as libc::c_int as isize) as + libc::c_int) as u32_t; iptr = iptr.offset(4 as libc::c_int as isize) } } else { - loop { + loop { let fresh13 = count; count = count.wrapping_sub(1); - if !(fresh13 != 0) { - break; - } + if !(fresh13 != 0) { break ; } let fresh14 = optr; optr = optr.offset(1); - *fresh14 = (*iptr as libc::c_int - | (*iptr.offset(1 as libc::c_int as isize) as libc::c_int) - << 8 as libc::c_int - | (*iptr.offset(2 as libc::c_int as isize) as libc::c_int) - << 16 as libc::c_int - | (*iptr.offset(3 as libc::c_int as isize) as libc::c_int) - << 24 as libc::c_int) - as crate::squeezelite_h::u32_t; + *fresh14 = + (*iptr as libc::c_int | + (*iptr.offset(1 as libc::c_int as isize) as + libc::c_int) << 8 as libc::c_int | + (*iptr.offset(2 as libc::c_int as isize) as + libc::c_int) << 16 as libc::c_int | + (*iptr.offset(3 as libc::c_int as isize) as + libc::c_int) << 24 as libc::c_int) as u32_t; iptr = iptr.offset(4 as libc::c_int as isize) } } } } else if channels == 1 as libc::c_int as libc::c_uint { if sample_size == 1 as libc::c_int as libc::c_uint { - loop { + loop { let fresh15 = count; count = count.wrapping_sub(1); - if !(fresh15 != 0) { - break; - } + if !(fresh15 != 0) { break ; } let fresh16 = iptr; iptr = iptr.offset(1); *optr = - ((*fresh16 as libc::c_int) << 24 as libc::c_int) as crate::squeezelite_h::u32_t; + ((*fresh16 as libc::c_int) << 24 as libc::c_int) as u32_t; *optr.offset(1 as libc::c_int as isize) = *optr; optr = optr.offset(2 as libc::c_int as isize) } } else if sample_size == 2 as libc::c_int as libc::c_uint { if bigendian { - loop { + loop { let fresh17 = count; count = count.wrapping_sub(1); - if !(fresh17 != 0) { - break; - } - *optr = ((*iptr as libc::c_int) << 24 as libc::c_int - | (*iptr.offset(1 as libc::c_int as isize) as libc::c_int) - << 16 as libc::c_int) - as crate::squeezelite_h::u32_t; + if !(fresh17 != 0) { break ; } + *optr = + ((*iptr as libc::c_int) << 24 as libc::c_int | + (*iptr.offset(1 as libc::c_int as isize) as + libc::c_int) << 16 as libc::c_int) as u32_t; *optr.offset(1 as libc::c_int as isize) = *optr; iptr = iptr.offset(2 as libc::c_int as isize); optr = optr.offset(2 as libc::c_int as isize) } } else { - loop { + loop { let fresh18 = count; count = count.wrapping_sub(1); - if !(fresh18 != 0) { - break; - } - *optr = ((*iptr as libc::c_int) << 16 as libc::c_int - | (*iptr.offset(1 as libc::c_int as isize) as libc::c_int) - << 24 as libc::c_int) - as crate::squeezelite_h::u32_t; + if !(fresh18 != 0) { break ; } + *optr = + ((*iptr as libc::c_int) << 16 as libc::c_int | + (*iptr.offset(1 as libc::c_int as isize) as + libc::c_int) << 24 as libc::c_int) as u32_t; *optr.offset(1 as libc::c_int as isize) = *optr; iptr = iptr.offset(2 as libc::c_int as isize); optr = optr.offset(2 as libc::c_int as isize) @@ -793,35 +812,31 @@ unsafe extern "C" fn pcm_decode() -> crate::squeezelite_h::decode_state { } } else if sample_size == 3 as libc::c_int as libc::c_uint { if bigendian { - loop { + loop { let fresh19 = count; count = count.wrapping_sub(1); - if !(fresh19 != 0) { - break; - } - *optr = ((*iptr as libc::c_int) << 24 as libc::c_int - | (*iptr.offset(1 as libc::c_int as isize) as libc::c_int) - << 16 as libc::c_int - | (*iptr.offset(2 as libc::c_int as isize) as libc::c_int) - << 8 as libc::c_int) - as crate::squeezelite_h::u32_t; + if !(fresh19 != 0) { break ; } + *optr = + ((*iptr as libc::c_int) << 24 as libc::c_int | + (*iptr.offset(1 as libc::c_int as isize) as + libc::c_int) << 16 as libc::c_int | + (*iptr.offset(2 as libc::c_int as isize) as + libc::c_int) << 8 as libc::c_int) as u32_t; *optr.offset(1 as libc::c_int as isize) = *optr; iptr = iptr.offset(3 as libc::c_int as isize); optr = optr.offset(2 as libc::c_int as isize) } } else { - loop { + loop { let fresh20 = count; count = count.wrapping_sub(1); - if !(fresh20 != 0) { - break; - } - *optr = ((*iptr as libc::c_int) << 8 as libc::c_int - | (*iptr.offset(1 as libc::c_int as isize) as libc::c_int) - << 16 as libc::c_int - | (*iptr.offset(2 as libc::c_int as isize) as libc::c_int) - << 24 as libc::c_int) - as crate::squeezelite_h::u32_t; + if !(fresh20 != 0) { break ; } + *optr = + ((*iptr as libc::c_int) << 8 as libc::c_int | + (*iptr.offset(1 as libc::c_int as isize) as + libc::c_int) << 16 as libc::c_int | + (*iptr.offset(2 as libc::c_int as isize) as + libc::c_int) << 24 as libc::c_int) as u32_t; *optr.offset(1 as libc::c_int as isize) = *optr; iptr = iptr.offset(3 as libc::c_int as isize); optr = optr.offset(2 as libc::c_int as isize) @@ -829,42 +844,39 @@ unsafe extern "C" fn pcm_decode() -> crate::squeezelite_h::decode_state { } } else if sample_size == 4 as libc::c_int as libc::c_uint { if bigendian { - loop { + loop { let fresh21 = count; count = count.wrapping_sub(1); - if !(fresh21 != 0) { - break; - } + if !(fresh21 != 0) { break ; } let fresh22 = optr; optr = optr.offset(1); - *fresh22 = ((*iptr as libc::c_int) << 24 as libc::c_int - | (*iptr.offset(1 as libc::c_int as isize) as libc::c_int) - << 16 as libc::c_int - | (*iptr.offset(2 as libc::c_int as isize) as libc::c_int) - << 8 as libc::c_int - | *iptr.offset(3 as libc::c_int as isize) as libc::c_int) - as crate::squeezelite_h::u32_t; + *fresh22 = + ((*iptr as libc::c_int) << 24 as libc::c_int | + (*iptr.offset(1 as libc::c_int as isize) as + libc::c_int) << 16 as libc::c_int | + (*iptr.offset(2 as libc::c_int as isize) as + libc::c_int) << 8 as libc::c_int | + *iptr.offset(3 as libc::c_int as isize) as + libc::c_int) as u32_t; *optr.offset(1 as libc::c_int as isize) = *optr; iptr = iptr.offset(4 as libc::c_int as isize); optr = optr.offset(2 as libc::c_int as isize) } } else { - loop { + loop { let fresh23 = count; count = count.wrapping_sub(1); - if !(fresh23 != 0) { - break; - } + if !(fresh23 != 0) { break ; } let fresh24 = optr; optr = optr.offset(1); - *fresh24 = (*iptr as libc::c_int - | (*iptr.offset(1 as libc::c_int as isize) as libc::c_int) - << 8 as libc::c_int - | (*iptr.offset(2 as libc::c_int as isize) as libc::c_int) - << 16 as libc::c_int - | (*iptr.offset(3 as libc::c_int as isize) as libc::c_int) - << 24 as libc::c_int) - as crate::squeezelite_h::u32_t; + *fresh24 = + (*iptr as libc::c_int | + (*iptr.offset(1 as libc::c_int as isize) as + libc::c_int) << 8 as libc::c_int | + (*iptr.offset(2 as libc::c_int as isize) as + libc::c_int) << 16 as libc::c_int | + (*iptr.offset(3 as libc::c_int as isize) as + libc::c_int) << 24 as libc::c_int) as u32_t; *optr.offset(1 as libc::c_int as isize) = *optr; iptr = iptr.offset(4 as libc::c_int as isize); optr = optr.offset(2 as libc::c_int as isize) @@ -872,144 +884,192 @@ unsafe extern "C" fn pcm_decode() -> crate::squeezelite_h::decode_state { } } } else { - crate::src::utils::logprint( - b"%s %s:%d unsupported channels\n\x00" as *const u8 as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 11], &[libc::c_char; 11]>(b"pcm_decode\x00")).as_ptr(), - 366 as libc::c_int, - ); + logprint(b"%s %s:%d unsupported channels\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 11], + &[libc::c_char; 11]>(b"pcm_decode\x00")).as_ptr(), + 366 as libc::c_int); } - 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 decoded %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"pcm_decode\x00")).as_ptr(), - 369 as libc::c_int, - frames, - ); + if loglevel as libc::c_uint >= lSDEBUG as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d decoded %u frames\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 11], + &[libc::c_char; 11]>(b"pcm_decode\x00")).as_ptr(), + 369 as libc::c_int, frames); } - crate::src::buffer::_buf_inc_readp(streambuf, frames.wrapping_mul(bytes_per_frame)); + _buf_inc_readp(streambuf, frames.wrapping_mul(bytes_per_frame)); if limit { - audio_left = (audio_left as libc::c_uint).wrapping_sub(frames.wrapping_mul(bytes_per_frame)) - as crate::squeezelite_h::u32_t as crate::squeezelite_h::u32_t + audio_left = + (audio_left as + libc::c_uint).wrapping_sub(frames.wrapping_mul(bytes_per_frame)) + as u32_t as u32_t } - crate::src::buffer::_buf_inc_writep( - outputbuf, - frames.wrapping_mul(8 as libc::c_int as libc::c_uint), - ); - crate::stdlib::pthread_mutex_unlock(&mut (*outputbuf).mutex); - crate::stdlib::pthread_mutex_unlock(&mut (*streambuf).mutex); - return crate::squeezelite_h::DECODE_RUNNING; + _buf_inc_writep(outputbuf, + frames.wrapping_mul(8 as libc::c_int as libc::c_uint)); + pthread_mutex_unlock(&mut (*outputbuf).mutex); + pthread_mutex_unlock(&mut (*streambuf).mutex); + return DECODE_RUNNING; } - -unsafe extern "C" fn pcm_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, -) { +unsafe extern "C" fn pcm_open(mut size: u8_t, mut rate: u8_t, mut chan: u8_t, + mut endianness: u8_t) { sample_size = - (size as libc::c_int - '0' as i32 + 1 as libc::c_int) as crate::squeezelite_h::u32_t; + (size as libc::c_int - '0' as i32 + 1 as libc::c_int) as u32_t; sample_rate = sample_rates[(rate as libc::c_int - '0' as i32) as usize]; - channels = (chan as libc::c_int - '0' as i32) as crate::squeezelite_h::u32_t; + channels = (chan as libc::c_int - '0' as i32) as u32_t; bigendian = endianness as libc::c_int == '0' as i32; limit = 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 pcm size: %u rate: %u chan: %u bigendian: %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"pcm_open\x00")).as_ptr(), - 397 as libc::c_int, - sample_size, - sample_rate, - channels, - bigendian as libc::c_int, - ); + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d pcm size: %u rate: %u chan: %u bigendian: %u\n\x00" + as *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 9], + &[libc::c_char; 9]>(b"pcm_open\x00")).as_ptr(), + 397 as libc::c_int, sample_size, sample_rate, channels, + bigendian as libc::c_int); } - crate::src::buffer::buf_adjust( - streambuf, - sample_size.wrapping_mul(channels) as crate::stddef_h::size_t, - ); + buf_adjust(streambuf, sample_size.wrapping_mul(channels) as size_t); } - unsafe extern "C" fn pcm_close() { - crate::src::buffer::buf_adjust(streambuf, 1 as libc::c_int as crate::stddef_h::size_t); + buf_adjust(streambuf, 1 as libc::c_int as size_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 . + * + * 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_pcm() -> *mut crate::squeezelite_h::codec { +pub unsafe extern "C" fn register_pcm() -> *mut codec { if pcm_check_header { - static mut ret: crate::squeezelite_h::codec = unsafe { - { - let mut init = crate::squeezelite_h::codec { - id: 'p' as i32 as libc::c_char, - types: b"wav,aif,pcm\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: 102400 as libc::c_int as libc::c_uint, - open: Some( - pcm_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(pcm_close as unsafe extern "C" fn() -> ()), - decode: Some( - pcm_decode as unsafe extern "C" fn() -> crate::squeezelite_h::decode_state, - ), - }; - init - } - }; - 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 pcm to decode wav,aif,pcm\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_pcm\x00")) - .as_ptr(), - 418 as libc::c_int, - ); + static mut ret: codec = + unsafe { + { + let mut init = + codec{id: 'p' as i32 as libc::c_char, + types: + b"wav,aif,pcm\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: + 102400 as libc::c_int as libc::c_uint, + open: + Some(pcm_open as + unsafe extern "C" fn(_: u8_t, + _: u8_t, + _: u8_t, + _: u8_t) + -> ()), + close: + Some(pcm_close as + unsafe extern "C" fn() -> ()), + decode: + Some(pcm_decode as + unsafe extern "C" fn() + -> decode_state),}; + init + } + }; + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d using pcm to decode wav,aif,pcm\n\x00" as + *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 13], + &[libc::c_char; 13]>(b"register_pcm\x00")).as_ptr(), + 418 as libc::c_int); } - return &mut ret; + return &mut ret } else { - static mut ret_0: crate::squeezelite_h::codec = unsafe { - { - let mut init = crate::squeezelite_h::codec { - id: 'p' as i32 as libc::c_char, - types: b"aif,pcm\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: 102400 as libc::c_int as libc::c_uint, - open: Some( - pcm_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(pcm_close as unsafe extern "C" fn() -> ()), - decode: Some( - pcm_decode as unsafe extern "C" fn() -> crate::squeezelite_h::decode_state, - ), - }; - init - } - }; - 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 pcm to decode aif,pcm\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_pcm\x00")) - .as_ptr(), - 433 as libc::c_int, - ); + static mut ret_0: codec = + unsafe { + { + let mut init = + codec{id: 'p' as i32 as libc::c_char, + types: + b"aif,pcm\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: + 102400 as libc::c_int as libc::c_uint, + open: + Some(pcm_open as + unsafe extern "C" fn(_: u8_t, + _: u8_t, + _: u8_t, + _: u8_t) + -> ()), + close: + Some(pcm_close as + unsafe extern "C" fn() -> ()), + decode: + Some(pcm_decode as + unsafe extern "C" fn() + -> decode_state),}; + init + } + }; + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d using pcm to decode aif,pcm\n\x00" as + *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 13], + &[libc::c_char; 13]>(b"register_pcm\x00")).as_ptr(), + 433 as libc::c_int); } - return &mut ret_0; + return &mut ret_0 }; } diff --git a/src/slimproto.rs b/src/slimproto.rs index 5f145a8..7683db5 100644 --- a/src/slimproto.rs +++ b/src/slimproto.rs @@ -1,167 +1,625 @@ -// =============== BEGIN slimproto_h ================ - -// char header[] - added in sendRESP - -// S:N:Slimproto _http_metadata_handler -#[repr(C, packed)] +use ::libc; +extern "C" { + pub type _IO_wide_data; + pub type _IO_codecvt; + pub type _IO_marker; + #[no_mangle] + fn close(__fd: libc::c_int) -> libc::c_int; + #[no_mangle] + fn sleep(__seconds: libc::c_uint) -> libc::c_uint; + #[no_mangle] + fn usleep(__useconds: __useconds_t) -> libc::c_int; + #[no_mangle] + fn fopen(_: *const libc::c_char, _: *const libc::c_char) -> *mut FILE; + #[no_mangle] + fn snprintf(_: *mut libc::c_char, _: libc::c_ulong, + _: *const libc::c_char, _: ...) -> libc::c_int; + #[no_mangle] + fn fgets(__s: *mut libc::c_char, __n: libc::c_int, __stream: *mut FILE) + -> *mut libc::c_char; + #[no_mangle] + fn fputs(__s: *const libc::c_char, __stream: *mut FILE) -> libc::c_int; + #[no_mangle] + fn malloc(_: libc::c_ulong) -> *mut libc::c_void; + #[no_mangle] + fn free(__ptr: *mut libc::c_void); + #[no_mangle] + fn memcpy(_: *mut libc::c_void, _: *const libc::c_void, _: libc::c_ulong) + -> *mut libc::c_void; + #[no_mangle] + fn memset(_: *mut libc::c_void, _: libc::c_int, _: libc::c_ulong) + -> *mut libc::c_void; + #[no_mangle] + fn strncpy(_: *mut libc::c_char, _: *const libc::c_char, _: libc::c_ulong) + -> *mut libc::c_char; + #[no_mangle] + fn strcat(_: *mut libc::c_char, _: *const libc::c_char) + -> *mut libc::c_char; + #[no_mangle] + fn strncat(_: *mut libc::c_char, _: *const libc::c_char, _: libc::c_ulong) + -> *mut libc::c_char; + #[no_mangle] + fn strncmp(_: *const libc::c_char, _: *const libc::c_char, + _: libc::c_ulong) -> libc::c_int; + #[no_mangle] + fn __errno_location() -> *mut libc::c_int; + #[no_mangle] + fn fclose(__stream: *mut FILE) -> libc::c_int; + #[no_mangle] + fn socket(__domain: libc::c_int, __type: libc::c_int, + __protocol: libc::c_int) -> libc::c_int; + #[no_mangle] + fn getsockname(__fd: libc::c_int, __addr: *mut sockaddr, + __len: *mut socklen_t) -> libc::c_int; + #[no_mangle] + fn send(__fd: libc::c_int, __buf: *const libc::c_void, __n: size_t, + __flags: libc::c_int) -> ssize_t; + #[no_mangle] + fn recv(__fd: libc::c_int, __buf: *mut libc::c_void, __n: size_t, + __flags: libc::c_int) -> ssize_t; + #[no_mangle] + fn sendto(__fd: libc::c_int, __buf: *const libc::c_void, __n: size_t, + __flags: libc::c_int, __addr: *const sockaddr, + __addr_len: socklen_t) -> ssize_t; + #[no_mangle] + fn recvfrom(__fd: libc::c_int, __buf: *mut libc::c_void, __n: size_t, + __flags: libc::c_int, __addr: *mut sockaddr, + __addr_len: *mut socklen_t) -> ssize_t; + #[no_mangle] + fn setsockopt(__fd: libc::c_int, __level: libc::c_int, + __optname: libc::c_int, __optval: *const libc::c_void, + __optlen: socklen_t) -> libc::c_int; + #[no_mangle] + fn ntohs(__netshort: uint16_t) -> uint16_t; + #[no_mangle] + fn htonl(__hostlong: uint32_t) -> uint32_t; + #[no_mangle] + fn htons(__hostshort: uint16_t) -> uint16_t; + #[no_mangle] + fn inet_ntoa(__in: in_addr) -> *mut libc::c_char; + #[no_mangle] + fn poll(__fds: *mut pollfd, __nfds: nfds_t, __timeout: libc::c_int) + -> libc::c_int; + #[no_mangle] + fn pthread_mutex_lock(__mutex: *mut pthread_mutex_t) -> libc::c_int; + #[no_mangle] + fn pthread_mutex_unlock(__mutex: *mut pthread_mutex_t) -> libc::c_int; + #[no_mangle] + fn eventfd(__count: libc::c_uint, __flags: libc::c_int) -> libc::c_int; + #[no_mangle] + fn eventfd_write(__fd: libc::c_int, __value: eventfd_t) -> libc::c_int; + #[no_mangle] + fn logtime() -> *const libc::c_char; + #[no_mangle] + fn logprint(fmt: *const libc::c_char, _: ...); + #[no_mangle] + fn gettime_ms() -> u32_t; + #[no_mangle] + fn set_nonblock(s: sockfd); + #[no_mangle] + fn connect_timeout(sock_0: sockfd, addr: *const sockaddr, + addrlen: socklen_t, timeout: libc::c_int) + -> libc::c_int; + #[no_mangle] + fn server_addr(server: *mut libc::c_char, ip_ptr: *mut in_addr_t, + port_ptr: *mut libc::c_uint); + #[no_mangle] + fn set_readwake_handles(handles: *mut pollfd, s: sockfd, e: libc::c_int); + #[no_mangle] + fn wait_readwake(handles: *mut pollfd, timeout: libc::c_int) + -> event_type; + #[no_mangle] + fn packN(dest: *mut u32_t, val: u32_t); + #[no_mangle] + fn packn(dest: *mut u16_t, val: u16_t); + #[no_mangle] + fn unpackN(src: *mut u32_t) -> u32_t; + #[no_mangle] + fn _buf_used(buf: *mut buffer) -> libc::c_uint; + #[no_mangle] + fn buf_flush(buf: *mut buffer); + #[no_mangle] + fn decode_flush(); + #[no_mangle] + fn output_flush(); + #[no_mangle] + fn stream_file(header: *const libc::c_char, header_len: size_t, + threshold: libc::c_uint); + #[no_mangle] + fn stream_sock(ip: u32_t, port: u16_t, header: *const libc::c_char, + header_len: size_t, threshold: libc::c_uint, + cont_wait: bool); + #[no_mangle] + fn codec_open(format: u8_t, sample_size: u8_t, sample_rate: u8_t, + channels: u8_t, endianness: u8_t); + #[no_mangle] + fn set_volume(left: libc::c_uint, right: libc::c_uint); + #[no_mangle] + fn stream_disconnect() -> bool; + #[no_mangle] + fn strlen(_: *const libc::c_char) -> libc::c_ulong; + #[no_mangle] + fn strerror(_: libc::c_int) -> *mut libc::c_char; + #[no_mangle] + static mut streambuf: *mut buffer; + #[no_mangle] + static mut outputbuf: *mut buffer; + #[no_mangle] + static mut stream: streamstate; + #[no_mangle] + static mut output: outputstate; + #[no_mangle] + static mut decode: decodestate; + #[no_mangle] + static mut codecs: [*mut codec; 0]; +} +pub type size_t = libc::c_ulong; +pub type __uint8_t = libc::c_uchar; +pub type __uint16_t = libc::c_ushort; +pub type __int32_t = libc::c_int; +pub type __uint32_t = libc::c_uint; +pub type __uint64_t = libc::c_ulong; +pub type __off_t = libc::c_long; +pub type __off64_t = libc::c_long; +pub type __useconds_t = libc::c_uint; +pub type __ssize_t = libc::c_long; +pub type __socklen_t = libc::c_uint; #[derive(Copy, Clone)] +#[repr(C)] +pub struct _IO_FILE { + pub _flags: libc::c_int, + pub _IO_read_ptr: *mut libc::c_char, + pub _IO_read_end: *mut libc::c_char, + pub _IO_read_base: *mut libc::c_char, + pub _IO_write_base: *mut libc::c_char, + pub _IO_write_ptr: *mut libc::c_char, + pub _IO_write_end: *mut libc::c_char, + pub _IO_buf_base: *mut libc::c_char, + pub _IO_buf_end: *mut libc::c_char, + pub _IO_save_base: *mut libc::c_char, + pub _IO_backup_base: *mut libc::c_char, + pub _IO_save_end: *mut libc::c_char, + pub _markers: *mut _IO_marker, + pub _chain: *mut _IO_FILE, + pub _fileno: libc::c_int, + pub _flags2: libc::c_int, + pub _old_offset: __off_t, + pub _cur_column: libc::c_ushort, + pub _vtable_offset: libc::c_schar, + pub _shortbuf: [libc::c_char; 1], + pub _lock: *mut libc::c_void, + pub _offset: __off64_t, + pub _codecvt: *mut _IO_codecvt, + pub _wide_data: *mut _IO_wide_data, + pub _freeres_list: *mut _IO_FILE, + pub _freeres_buf: *mut libc::c_void, + pub __pad5: size_t, + pub _mode: libc::c_int, + pub _unused2: [libc::c_char; 20], +} +pub type _IO_lock_t = (); +pub type FILE = _IO_FILE; +pub type ssize_t = __ssize_t; +pub type int32_t = __int32_t; +pub type u_int8_t = __uint8_t; +pub type u_int16_t = __uint16_t; +pub type u_int32_t = __uint32_t; +pub type u_int64_t = __uint64_t; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct __pthread_internal_list { + pub __prev: *mut __pthread_internal_list, + pub __next: *mut __pthread_internal_list, +} +pub type __pthread_list_t = __pthread_internal_list; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct __pthread_mutex_s { + pub __lock: libc::c_int, + pub __count: libc::c_uint, + pub __owner: libc::c_int, + pub __nusers: libc::c_uint, + pub __kind: libc::c_int, + pub __spins: libc::c_short, + pub __elision: libc::c_short, + pub __list: __pthread_list_t, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub union pthread_mutex_t { + pub __data: __pthread_mutex_s, + pub __size: [libc::c_char; 40], + pub __align: libc::c_long, +} +pub type socklen_t = __socklen_t; +pub type uint16_t = __uint16_t; +pub type uint32_t = __uint32_t; +pub type uint64_t = __uint64_t; +pub type __socket_type = libc::c_uint; +pub const SOCK_NONBLOCK: __socket_type = 2048; +pub const SOCK_CLOEXEC: __socket_type = 524288; +pub const SOCK_PACKET: __socket_type = 10; +pub const SOCK_DCCP: __socket_type = 6; +pub const SOCK_SEQPACKET: __socket_type = 5; +pub const SOCK_RDM: __socket_type = 4; +pub const SOCK_RAW: __socket_type = 3; +pub const SOCK_DGRAM: __socket_type = 2; +pub const SOCK_STREAM: __socket_type = 1; +pub type sa_family_t = libc::c_ushort; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct sockaddr { + pub sa_family: sa_family_t, + pub sa_data: [libc::c_char; 14], +} +pub type C2RustUnnamed = libc::c_uint; +pub const MSG_CMSG_CLOEXEC: C2RustUnnamed = 1073741824; +pub const MSG_FASTOPEN: C2RustUnnamed = 536870912; +pub const MSG_ZEROCOPY: C2RustUnnamed = 67108864; +pub const MSG_BATCH: C2RustUnnamed = 262144; +pub const MSG_WAITFORONE: C2RustUnnamed = 65536; +pub const MSG_MORE: C2RustUnnamed = 32768; +pub const MSG_NOSIGNAL: C2RustUnnamed = 16384; +pub const MSG_ERRQUEUE: C2RustUnnamed = 8192; +pub const MSG_RST: C2RustUnnamed = 4096; +pub const MSG_CONFIRM: C2RustUnnamed = 2048; +pub const MSG_SYN: C2RustUnnamed = 1024; +pub const MSG_FIN: C2RustUnnamed = 512; +pub const MSG_WAITALL: C2RustUnnamed = 256; +pub const MSG_EOR: C2RustUnnamed = 128; +pub const MSG_DONTWAIT: C2RustUnnamed = 64; +pub const MSG_TRUNC: C2RustUnnamed = 32; +pub const MSG_PROXY: C2RustUnnamed = 16; +pub const MSG_CTRUNC: C2RustUnnamed = 8; +pub const MSG_DONTROUTE: C2RustUnnamed = 4; +pub const MSG_PEEK: C2RustUnnamed = 2; +pub const MSG_OOB: C2RustUnnamed = 1; +pub type in_addr_t = uint32_t; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct in_addr { + pub s_addr: in_addr_t, +} +pub type in_port_t = uint16_t; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct sockaddr_in { + pub sin_family: sa_family_t, + pub sin_port: in_port_t, + pub sin_addr: in_addr, + pub sin_zero: [libc::c_uchar; 8], +} +pub type nfds_t = libc::c_ulong; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct pollfd { + pub fd: libc::c_int, + pub events: libc::c_short, + pub revents: libc::c_short, +} +pub type u8_t = u_int8_t; +pub type u16_t = u_int16_t; +pub type u32_t = u_int32_t; +pub type u64_t = u_int64_t; +pub type s32_t = int32_t; +pub type frames_t = u32_t; +pub type sockfd = libc::c_int; +pub type eventfd_t = uint64_t; +pub type log_level = libc::c_uint; +pub const lSDEBUG: log_level = 4; +pub const lDEBUG: log_level = 3; +pub const lINFO: log_level = 2; +pub const lWARN: log_level = 1; +pub const lERROR: log_level = 0; +pub type event_type = libc::c_uint; +pub const EVENT_WAKE: event_type = 2; +pub const EVENT_READ: event_type = 1; +pub const EVENT_TIMEOUT: event_type = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct buffer { + pub buf: *mut u8_t, + pub readp: *mut u8_t, + pub writep: *mut u8_t, + pub wrap: *mut u8_t, + pub size: size_t, + pub base_size: size_t, + pub mutex: pthread_mutex_t, +} +// char header[] - added in sendRESP +// S:N:Slimproto _http_metadata_handler +#[derive(Copy, Clone)] +#[repr(C, packed)] pub struct META_header { pub opcode: [libc::c_char; 4], - pub length: crate::squeezelite_h::u32_t, + pub length: u32_t, } // S:N:Slimproto _http_response_handler - -#[repr(C, packed)] #[derive(Copy, Clone)] +#[repr(C, packed)] pub struct RESP_header { pub opcode: [libc::c_char; 4], - pub length: crate::squeezelite_h::u32_t, + pub length: u32_t, } // u8_t capabilities[]; // S:N:Slimproto _stat_handler - -#[repr(C, packed)] #[derive(Copy, Clone)] +#[repr(C, packed)] pub struct STAT_packet { pub opcode: [libc::c_char; 4], - pub length: crate::squeezelite_h::u32_t, - pub event: crate::squeezelite_h::u32_t, - pub num_crlf: crate::squeezelite_h::u8_t, - pub mas_initialized: crate::squeezelite_h::u8_t, - pub mas_mode: crate::squeezelite_h::u8_t, - pub stream_buffer_size: crate::squeezelite_h::u32_t, - pub stream_buffer_fullness: crate::squeezelite_h::u32_t, - pub bytes_received_H: crate::squeezelite_h::u32_t, - pub bytes_received_L: crate::squeezelite_h::u32_t, - pub signal_strength: crate::squeezelite_h::u16_t, - pub jiffies: crate::squeezelite_h::u32_t, - pub output_buffer_size: crate::squeezelite_h::u32_t, - pub output_buffer_fullness: crate::squeezelite_h::u32_t, - pub elapsed_seconds: crate::squeezelite_h::u32_t, - pub voltage: crate::squeezelite_h::u16_t, - pub elapsed_milliseconds: crate::squeezelite_h::u32_t, - pub server_timestamp: crate::squeezelite_h::u32_t, - pub error_code: crate::squeezelite_h::u16_t, + pub length: u32_t, + pub event: u32_t, + pub num_crlf: u8_t, + pub mas_initialized: u8_t, + pub mas_mode: u8_t, + pub stream_buffer_size: u32_t, + pub stream_buffer_fullness: u32_t, + pub bytes_received_H: u32_t, + pub bytes_received_L: u32_t, + pub signal_strength: u16_t, + pub jiffies: u32_t, + pub output_buffer_size: u32_t, + pub output_buffer_fullness: u32_t, + pub elapsed_seconds: u32_t, + pub voltage: u16_t, + pub elapsed_milliseconds: u32_t, + pub server_timestamp: u32_t, + pub error_code: u16_t, } -// S:N:Slimproto _disco_handler - -#[repr(C, packed)] #[derive(Copy, Clone)] +#[repr(C)] +pub struct C2RustUnnamed_0 { + pub updated: u32_t, + pub stream_start: u32_t, + pub stream_full: u32_t, + pub stream_size: u32_t, + pub stream_bytes: u64_t, + pub output_full: u32_t, + pub output_size: u32_t, + pub frames_played: u32_t, + pub device_frames: u32_t, + pub current_sample_rate: u32_t, + pub last: u32_t, + pub stream_state: stream_state, +} +pub type stream_state = libc::c_uint; +pub const RECV_HEADERS: stream_state = 7; +pub const SEND_HEADERS: stream_state = 6; +pub const STREAMING_HTTP: stream_state = 5; +pub const STREAMING_FILE: stream_state = 4; +pub const STREAMING_BUFFERING: stream_state = 3; +pub const STREAMING_WAIT: stream_state = 2; +pub const DISCONNECT: stream_state = 1; +pub const STOPPED: stream_state = 0; +pub type disconnect_code = libc::c_uint; +pub const TIMEOUT: disconnect_code = 4; +pub const UNREACHABLE: disconnect_code = 3; +pub const REMOTE_DISCONNECT: disconnect_code = 2; +pub const LOCAL_DISCONNECT: disconnect_code = 1; +pub const DISCONNECT_OK: disconnect_code = 0; +// S:N:Slimproto _disco_handler +#[derive(Copy, Clone)] +#[repr(C, packed)] pub struct DSCO_packet { pub opcode: [libc::c_char; 4], - pub length: crate::squeezelite_h::u32_t, - pub reason: crate::squeezelite_h::u8_t, + pub length: u32_t, + pub reason: u8_t, +} +pub const OUTPUT_RUNNING: output_state = 2; +pub type output_state = libc::c_int; +pub const OUTPUT_START_AT: output_state = 5; +pub const OUTPUT_SKIP_FRAMES: output_state = 4; +pub const OUTPUT_PAUSE_FRAMES: output_state = 3; +pub const OUTPUT_BUFFER: output_state = 1; +pub const OUTPUT_STOPPED: output_state = 0; +pub const OUTPUT_OFF: output_state = -1; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct outputstate { + pub state: output_state, + pub format: output_format, + pub device: *const libc::c_char, + pub buffer: libc::c_uint, + pub period: libc::c_uint, + pub track_started: bool, + pub write_cb: Option libc::c_int>, + pub start_frames: libc::c_uint, + pub frames_played: libc::c_uint, + pub frames_played_dmp: libc::c_uint, + pub current_sample_rate: libc::c_uint, + pub supported_rates: [libc::c_uint; 18], + pub default_sample_rate: libc::c_uint, + pub error_opening: bool, + pub device_frames: libc::c_uint, + pub updated: u32_t, + pub track_start_time: u32_t, + pub current_replay_gain: u32_t, + pub c2rust_unnamed: C2RustUnnamed_1, + pub next_sample_rate: libc::c_uint, + pub track_start: *mut u8_t, + pub gainL: u32_t, + pub gainR: u32_t, + pub invert: bool, + pub next_replay_gain: u32_t, + pub threshold: libc::c_uint, + pub fade: fade_state, + pub fade_start: *mut u8_t, + pub fade_end: *mut u8_t, + pub fade_dir: fade_dir, + pub fade_mode: fade_mode, + pub fade_secs: libc::c_uint, + pub rate_delay: libc::c_uint, + pub delay_active: bool, + pub stop_time: u32_t, + pub idle_to: u32_t, +} +pub type fade_mode = libc::c_uint; +pub const FADE_INOUT: fade_mode = 4; +pub const FADE_OUT: fade_mode = 3; +pub const FADE_IN: fade_mode = 2; +pub const FADE_CROSSFADE: fade_mode = 1; +pub const FADE_NONE: fade_mode = 0; +pub type fade_dir = libc::c_uint; +pub const FADE_CROSS: fade_dir = 3; +pub const FADE_DOWN: fade_dir = 2; +pub const FADE_UP: fade_dir = 1; +pub type fade_state = libc::c_uint; +pub const FADE_ACTIVE: fade_state = 2; +pub const FADE_DUE: fade_state = 1; +pub const FADE_INACTIVE: fade_state = 0; +#[derive(Copy, Clone)] +#[repr(C)] +pub union C2RustUnnamed_1 { + pub pause_frames: u32_t, + pub skip_frames: u32_t, + pub start_at: u32_t, +} +pub type output_format = libc::c_uint; +pub const S16_LE: output_format = 3; +pub const S24_3LE: output_format = 2; +pub const S24_LE: output_format = 1; +pub const S32_LE: output_format = 0; +pub const DECODE_STOPPED: decode_state = 0; +pub type decode_state = libc::c_uint; +pub const DECODE_ERROR: decode_state = 4; +pub const DECODE_COMPLETE: decode_state = 3; +pub const DECODE_RUNNING: decode_state = 2; +pub const DECODE_READY: decode_state = 1; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct decodestate { + pub state: decode_state, + pub new_stream: bool, + pub mutex: pthread_mutex_t, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct streamstate { + pub state: stream_state, + pub disconnect: disconnect_code, + pub header: *mut libc::c_char, + pub header_len: size_t, + pub sent_headers: bool, + pub cont_wait: bool, + pub bytes: u64_t, + pub threshold: libc::c_uint, + pub meta_interval: u32_t, + pub meta_next: u32_t, + pub meta_left: u32_t, + pub meta_send: bool, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct handler { + pub opcode: [libc::c_char; 5], + pub handler: Option ()>, } // guids we don't use // S:C:Commands - -#[repr(C, packed)] #[derive(Copy, Clone)] +#[repr(C, packed)] pub struct serv_packet { pub opcode: [libc::c_char; 4], - pub server_ip: crate::squeezelite_h::u32_t, + pub server_ip: u32_t, } // possible sync group // S:P:Squeezebox2 - -#[repr(C, packed)] #[derive(Copy, Clone)] +#[repr(C, packed)] pub struct setd_packet { pub opcode: [libc::c_char; 4], - pub id: crate::squeezelite_h::u8_t, + pub id: u8_t, pub data: [libc::c_char; 0], } // char metadata[] // S:N:Slimproto _http_setting_handler - -#[repr(C, packed)] #[derive(Copy, Clone)] +#[repr(C, packed)] pub struct SETD_header { pub opcode: [libc::c_char; 4], - pub length: crate::squeezelite_h::u32_t, - pub id: crate::squeezelite_h::u8_t, + pub length: u32_t, + pub id: u8_t, } // S:P:Squeezebox2 - -#[repr(C, packed)] #[derive(Copy, Clone)] +#[repr(C, packed)] pub struct audg_packet { pub opcode: [libc::c_char; 4], - pub old_gainL: crate::squeezelite_h::u32_t, - pub old_gainR: crate::squeezelite_h::u32_t, - pub adjust: crate::squeezelite_h::u8_t, - pub preamp: crate::squeezelite_h::u8_t, - pub gainL: crate::squeezelite_h::u32_t, - pub gainR: crate::squeezelite_h::u32_t, + pub old_gainL: u32_t, + pub old_gainR: u32_t, + pub adjust: u8_t, + pub preamp: u8_t, + pub gainL: u32_t, + pub gainR: u32_t, } //char request_string[]; // S:P:Squeezebox2 - -#[repr(C, packed)] #[derive(Copy, Clone)] +#[repr(C, packed)] pub struct aude_packet { pub opcode: [libc::c_char; 4], - pub enable_spdif: crate::squeezelite_h::u8_t, - pub enable_dac: crate::squeezelite_h::u8_t, + pub enable_spdif: u8_t, + pub enable_dac: u8_t, } // codec open - this is an extension to slimproto to allow the server to read the header and then return decode params - -#[repr(C, packed)] #[derive(Copy, Clone)] +#[repr(C, packed)] pub struct codc_packet { pub opcode: [libc::c_char; 4], - pub format: crate::squeezelite_h::u8_t, - pub pcm_sample_size: crate::squeezelite_h::u8_t, - pub pcm_sample_rate: crate::squeezelite_h::u8_t, - pub pcm_channels: crate::squeezelite_h::u8_t, - pub pcm_endianness: crate::squeezelite_h::u8_t, + pub format: u8_t, + pub pcm_sample_size: u8_t, + pub pcm_sample_rate: u8_t, + pub pcm_channels: u8_t, + pub pcm_endianness: u8_t, } // squence ids - unused // S:P:Squeezebox2 - -#[repr(C, packed)] #[derive(Copy, Clone)] +#[repr(C, packed)] pub struct cont_packet { pub opcode: [libc::c_char; 4], - pub metaint: crate::squeezelite_h::u32_t, - pub loop_0: crate::squeezelite_h::u8_t, + pub metaint: u32_t, + pub loop_0: u8_t, } // data // from S:P:Squeezebox stream_s - -#[repr(C, packed)] #[derive(Copy, Clone)] +#[repr(C, packed)] pub struct strm_packet { pub opcode: [libc::c_char; 4], pub command: libc::c_char, - pub autostart: crate::squeezelite_h::u8_t, - pub format: crate::squeezelite_h::u8_t, - pub pcm_sample_size: crate::squeezelite_h::u8_t, - pub pcm_sample_rate: crate::squeezelite_h::u8_t, - pub pcm_channels: crate::squeezelite_h::u8_t, - pub pcm_endianness: crate::squeezelite_h::u8_t, - pub threshold: crate::squeezelite_h::u8_t, - pub spdif_enable: crate::squeezelite_h::u8_t, - pub transition_period: crate::squeezelite_h::u8_t, - pub transition_type: crate::squeezelite_h::u8_t, - pub flags: crate::squeezelite_h::u8_t, - pub output_threshold: crate::squeezelite_h::u8_t, - pub slaves: crate::squeezelite_h::u8_t, - pub replay_gain: crate::squeezelite_h::u32_t, - pub server_port: crate::squeezelite_h::u16_t, - pub server_ip: crate::squeezelite_h::u32_t, + pub autostart: u8_t, + pub format: u8_t, + pub pcm_sample_size: u8_t, + pub pcm_sample_rate: u8_t, + pub pcm_channels: u8_t, + pub pcm_endianness: u8_t, + pub threshold: u8_t, + pub spdif_enable: u8_t, + pub transition_period: u8_t, + pub transition_type: u8_t, + pub flags: u8_t, + pub output_threshold: u8_t, + pub slaves: u8_t, + pub replay_gain: u32_t, + pub server_port: u16_t, + pub server_ip: u32_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 @@ -173,275 +631,43 @@ pub struct strm_packet { */ // packet formats for slimproto // from S:N:Slimproto _hello_handler - -#[repr(C, packed)] #[derive(Copy, Clone)] +#[repr(C, packed)] pub struct HELO_packet { pub opcode: [libc::c_char; 4], - pub length: crate::squeezelite_h::u32_t, - pub deviceid: crate::squeezelite_h::u8_t, - pub revision: crate::squeezelite_h::u8_t, - pub mac: [crate::squeezelite_h::u8_t; 6], - pub uuid: [crate::squeezelite_h::u8_t; 16], - pub wlan_channellist: crate::squeezelite_h::u16_t, - pub bytes_received_H: crate::squeezelite_h::u32_t, - pub bytes_received_L: crate::squeezelite_h::u32_t, + pub length: u32_t, + pub deviceid: u8_t, + pub revision: u8_t, + pub mac: [u8_t; 6], + pub uuid: [u8_t; 16], + pub wlan_channellist: u16_t, + pub bytes_received_H: u32_t, + pub bytes_received_L: u32_t, pub lang: [libc::c_char; 2], } -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::__socklen_t; -pub use crate::stdlib::__ssize_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::__useconds_t; -pub use crate::stdlib::fclose; -pub use crate::stdlib::fgets; -pub use crate::stdlib::fopen; -pub use crate::stdlib::fputs; -pub use crate::stdlib::int32_t; -pub use crate::stdlib::snprintf; -pub use crate::stdlib::ssize_t; -pub use crate::stdlib::FILE; -pub use crate::stdlib::_IO_FILE; - -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_int16_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::stdlib::__socket_type; -pub use crate::stdlib::close; -pub use crate::stdlib::sa_family_t; -pub use crate::stdlib::sleep; -pub use crate::stdlib::socklen_t; -pub use crate::stdlib::uint16_t; -pub use crate::stdlib::uint32_t; -pub use crate::stdlib::uint64_t; -pub use crate::stdlib::usleep; -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::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::event_type; -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::sockfd; -pub use crate::squeezelite_h::stream_state; -pub use crate::squeezelite_h::streamstate; -pub use crate::squeezelite_h::u16_t; -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::EVENT_READ; -pub use crate::squeezelite_h::EVENT_TIMEOUT; -pub use crate::squeezelite_h::EVENT_WAKE; -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_flush; -pub use crate::src::decode::codec_open; -pub use crate::src::decode::decode_flush; -pub use crate::src::output::output_flush; -pub use crate::src::output_alsa::set_volume; -pub use crate::src::stream::stream_disconnect; -pub use crate::src::stream::stream_file; -pub use crate::src::stream::stream_sock; -pub use crate::src::utils::connect_timeout; -pub use crate::src::utils::gettime_ms; -pub use crate::src::utils::logprint; -pub use crate::src::utils::logtime; -pub use crate::src::utils::packN; -pub use crate::src::utils::packn; -pub use crate::src::utils::server_addr; -pub use crate::src::utils::set_nonblock; -pub use crate::src::utils::set_readwake_handles; -pub use crate::src::utils::unpackN; -pub use crate::src::utils::wait_readwake; -use crate::stdlib::__errno_location; -pub use crate::stdlib::eventfd; -pub use crate::stdlib::eventfd_t; -pub use crate::stdlib::eventfd_write; -use crate::stdlib::free; -use crate::stdlib::getsockname; -pub use crate::stdlib::htonl; -pub use crate::stdlib::htons; -pub use crate::stdlib::in_addr; -pub use crate::stdlib::in_addr_t; -pub use crate::stdlib::in_port_t; -use crate::stdlib::inet_ntoa; -use crate::stdlib::malloc; -use crate::stdlib::memcpy; -use crate::stdlib::memset; -pub use crate::stdlib::nfds_t; -pub use crate::stdlib::ntohs; -pub use crate::stdlib::poll; -pub use crate::stdlib::pollfd; -use crate::stdlib::pthread_mutex_lock; -use crate::stdlib::pthread_mutex_unlock; -use crate::stdlib::recv; -use crate::stdlib::recvfrom; -use crate::stdlib::send; -use crate::stdlib::sendto; -use crate::stdlib::setsockopt; -pub use crate::stdlib::sockaddr; -pub use crate::stdlib::sockaddr_in; -use crate::stdlib::socket; -use crate::stdlib::strcat; -use crate::stdlib::strerror; -use crate::stdlib::strlen; -use crate::stdlib::strncat; -use crate::stdlib::strncmp; -use crate::stdlib::strncpy; -pub use crate::stdlib::C2RustUnnamed_0; -pub use crate::stdlib::MSG_BATCH; -pub use crate::stdlib::MSG_CMSG_CLOEXEC; -pub use crate::stdlib::MSG_CONFIRM; -pub use crate::stdlib::MSG_CTRUNC; -pub use crate::stdlib::MSG_DONTROUTE; -pub use crate::stdlib::MSG_DONTWAIT; -pub use crate::stdlib::MSG_EOR; -pub use crate::stdlib::MSG_ERRQUEUE; -pub use crate::stdlib::MSG_FASTOPEN; -pub use crate::stdlib::MSG_FIN; -pub use crate::stdlib::MSG_MORE; -pub use crate::stdlib::MSG_NOSIGNAL; -pub use crate::stdlib::MSG_OOB; -pub use crate::stdlib::MSG_PEEK; -pub use crate::stdlib::MSG_PROXY; -pub use crate::stdlib::MSG_RST; -pub use crate::stdlib::MSG_SYN; -pub use crate::stdlib::MSG_TRUNC; -pub use crate::stdlib::MSG_WAITALL; -pub use crate::stdlib::MSG_WAITFORONE; -pub use crate::stdlib::MSG_ZEROCOPY; -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; - #[no_mangle] - pub static mut decode: crate::squeezelite_h::decodestate; - #[no_mangle] - pub static mut codecs: [*mut crate::squeezelite_h::codec; 0]; -} - -#[repr(C)] #[derive(Copy, Clone)] -pub struct C2RustUnnamed_17 { - pub updated: crate::squeezelite_h::u32_t, - pub stream_start: crate::squeezelite_h::u32_t, - pub stream_full: crate::squeezelite_h::u32_t, - pub stream_size: crate::squeezelite_h::u32_t, - pub stream_bytes: crate::squeezelite_h::u64_t, - pub output_full: crate::squeezelite_h::u32_t, - pub output_size: crate::squeezelite_h::u32_t, - pub frames_played: crate::squeezelite_h::u32_t, - pub device_frames: crate::squeezelite_h::u32_t, - pub current_sample_rate: crate::squeezelite_h::u32_t, - pub last: crate::squeezelite_h::u32_t, - pub stream_state: crate::squeezelite_h::stream_state, -} - #[repr(C)] -#[derive(Copy, Clone)] -pub struct handler { - pub opcode: [libc::c_char; 5], - pub handler: - Option ()>, +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 ()>, + pub close: Option ()>, + pub decode: Option decode_state>, } -/* +/* * 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 @@ -454,368 +680,276 @@ pub struct handler { * -Control of Raspberry pi GPIO for amplifier power * -Launch script on power status change from LMS */ - -static mut loglevel: crate::squeezelite_h::log_level = crate::squeezelite_h::lERROR; +static mut loglevel: log_level = lERROR; // 3483 - -static mut sock: crate::squeezelite_h::sockfd = -(1 as libc::c_int); - -static mut slimproto_ip: crate::stdlib::in_addr_t = 0 as libc::c_int as crate::stdlib::in_addr_t; +static mut sock: sockfd = -(1 as libc::c_int); +static mut slimproto_ip: in_addr_t = 0 as libc::c_int as in_addr_t; #[no_mangle] - pub static mut wake_e: libc::c_int = 0; - -static mut status: C2RustUnnamed_17 = C2RustUnnamed_17 { - updated: 0, - stream_start: 0, - stream_full: 0, - stream_size: 0, - stream_bytes: 0, - output_full: 0, - output_size: 0, - frames_played: 0, - device_frames: 0, - current_sample_rate: 0, - last: 0, - stream_state: crate::squeezelite_h::STOPPED, -}; +static mut status: C2RustUnnamed_0 = + C2RustUnnamed_0{updated: 0, + stream_start: 0, + stream_full: 0, + stream_size: 0, + stream_bytes: 0, + output_full: 0, + output_size: 0, + frames_played: 0, + device_frames: 0, + current_sample_rate: 0, + last: 0, + stream_state: STOPPED,}; #[no_mangle] - pub static mut autostart: libc::c_int = 0; #[no_mangle] - pub static mut sentSTMu: bool = false; #[no_mangle] - pub static mut sentSTMo: bool = false; #[no_mangle] - pub static mut sentSTMl: bool = false; #[no_mangle] - -pub static mut new_server: crate::squeezelite_h::u32_t = 0; +pub static mut new_server: u32_t = 0; #[no_mangle] - -pub static mut new_server_cap: *mut libc::c_char = 0 as *const libc::c_char as *mut libc::c_char; +pub static mut new_server_cap: *mut libc::c_char = + 0 as *const libc::c_char as *mut libc::c_char; #[no_mangle] - -pub static mut player_name: [libc::c_char; 65] = [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, -]; +pub static mut player_name: [libc::c_char; 65] = + [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; #[no_mangle] - pub static mut name_file: *const libc::c_char = 0 as *const libc::c_char; #[no_mangle] - -pub unsafe extern "C" fn send_packet( - mut packet: *mut crate::squeezelite_h::u8_t, - mut len: crate::stddef_h::size_t, -) { - let mut ptr = packet; // squeezeplay - let mut try_0 = 0 as libc::c_int as libc::c_uint; - let mut n: crate::stdlib::ssize_t = 0; +pub unsafe extern "C" fn send_packet(mut packet: *mut u8_t, mut len: size_t) { + let mut ptr: *mut u8_t = packet; // squeezeplay + let mut try_0: libc::c_uint = 0 as libc::c_int as libc::c_uint; + let mut n: ssize_t = 0; while len != 0 { - n = crate::stdlib::send( - sock, - ptr as *const libc::c_void, - len, - crate::stdlib::MSG_NOSIGNAL as libc::c_int, - ); + n = + send(sock, ptr as *const libc::c_void, len, + MSG_NOSIGNAL as libc::c_int); if n <= 0 as libc::c_int as libc::c_long { - if n < 0 as libc::c_int as libc::c_long - && *crate::stdlib::__errno_location() == 11 as libc::c_int - && try_0 < 10 as libc::c_int as libc::c_uint - { - if loglevel as libc::c_uint - >= crate::squeezelite_h::lDEBUG as libc::c_int as libc::c_uint - { + if n < 0 as libc::c_int as libc::c_long && + *__errno_location() == 11 as libc::c_int && + try_0 < 10 as libc::c_int as libc::c_uint { + if loglevel as libc::c_uint >= + lDEBUG as libc::c_int as libc::c_uint { try_0 = try_0.wrapping_add(1); - crate::src::utils::logprint( - b"%s %s:%d retrying (%d) writing to socket\n\x00" as *const u8 - as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 12], &[libc::c_char; 12]>( - b"send_packet\x00", - )) - .as_ptr(), - 104 as libc::c_int, - try_0, - ); + logprint(b"%s %s:%d retrying (%d) writing to socket\n\x00" + as *const u8 as *const libc::c_char, + logtime(), + (*::std::mem::transmute::<&[u8; 12], + &[libc::c_char; 12]>(b"send_packet\x00")).as_ptr(), + 104 as libc::c_int, try_0); } - crate::stdlib::usleep(1000 as libc::c_int as crate::stdlib::__useconds_t); + usleep(1000 as libc::c_int as __useconds_t); } 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 failed writing to socket: %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"send_packet\x00", - )) - .as_ptr(), - 108 as libc::c_int, - crate::stdlib::strerror(*crate::stdlib::__errno_location()), - ); + if loglevel as libc::c_uint >= + lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d failed writing to socket: %s\n\x00" as + *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 12], + &[libc::c_char; 12]>(b"send_packet\x00")).as_ptr(), + 108 as libc::c_int, + strerror(*__errno_location())); } - return; + return } } else { ptr = ptr.offset(n as isize); - len = (len as libc::c_ulong).wrapping_sub(n as libc::c_ulong) as crate::stddef_h::size_t - as crate::stddef_h::size_t + len = + (len as libc::c_ulong).wrapping_sub(n as libc::c_ulong) as + size_t as size_t } - } -} - -unsafe extern "C" fn sendHELO( - mut reconnect: bool, - mut fixed_cap: *const libc::c_char, - mut var_cap: *const libc::c_char, - mut mac: *mut crate::squeezelite_h::u8_t, -) { - let mut base_cap = 0 as *const libc::c_char; - let mut pkt = crate::src::slimproto::HELO_packet { - opcode: [0; 4], - length: 0, - deviceid: 0, - revision: 0, - mac: [0; 6], - uuid: [0; 16], - wlan_channellist: 0, - bytes_received_H: 0, - bytes_received_L: 0, - lang: [0; 2], }; +} +unsafe extern "C" fn sendHELO(mut reconnect: bool, + mut fixed_cap: *const libc::c_char, + mut var_cap: *const libc::c_char, + mut mac: *mut u8_t) { + let mut base_cap: *const libc::c_char = 0 as *const libc::c_char; + let mut pkt: HELO_packet = + HELO_packet{opcode: [0; 4], + length: 0, + deviceid: 0, + revision: 0, + mac: [0; 6], + uuid: [0; 16], + wlan_channellist: 0, + bytes_received_H: 0, + bytes_received_L: 0, + lang: [0; 2],}; base_cap = - b"Model=squeezelite,AccuratePlayPoints=1,HasDigitalOut=1,HasPolarityInversion=1,Firmware=v1.9.7-1218\x00" + b"Model=squeezelite,AccuratePlayPoints=1,HasDigitalOut=1,HasPolarityInversion=1,Firmware=v1.9.7-1223\x00" as *const u8 as *const libc::c_char; - crate::stdlib::memset( - &mut pkt as *mut crate::src::slimproto::HELO_packet as *mut libc::c_void, - 0 as libc::c_int, - ::std::mem::size_of::() as libc::c_ulong, - ); - crate::stdlib::memcpy( - &mut pkt.opcode as *mut [libc::c_char; 4] as *mut libc::c_void, - b"HELO\x00" as *const u8 as *const libc::c_char as *const libc::c_void, - 4 as libc::c_int as libc::c_ulong, - ); - pkt.length = crate::stdlib::htonl( - (::std::mem::size_of::() as libc::c_ulong) - .wrapping_sub(8 as libc::c_int as libc::c_ulong) - .wrapping_add(crate::stdlib::strlen(base_cap)) - .wrapping_add(crate::stdlib::strlen(fixed_cap)) - .wrapping_add(crate::stdlib::strlen(var_cap)) as crate::stdlib::uint32_t, - ); - pkt.deviceid = 12 as libc::c_int as crate::squeezelite_h::u8_t; - pkt.revision = 0 as libc::c_int as crate::squeezelite_h::u8_t; - crate::src::utils::packn( - &mut pkt.wlan_channellist, - if reconnect as libc::c_int != 0 { - 0x4000 as libc::c_int - } else { - 0 as libc::c_int - } as crate::squeezelite_h::u16_t, - ); - crate::src::utils::packN( - &mut pkt.bytes_received_H, - (status.stream_bytes >> 32 as libc::c_int) as crate::squeezelite_h::u32_t, - ); - crate::src::utils::packN( - &mut pkt.bytes_received_L, - (status.stream_bytes & 0xffffffff as libc::c_uint as libc::c_ulong) - as crate::squeezelite_h::u32_t, - ); - crate::stdlib::memcpy( - pkt.mac.as_mut_ptr() as *mut libc::c_void, - mac as *const libc::c_void, - 6 as libc::c_int as libc::c_ulong, - ); - 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 mac: %02x:%02x:%02x:%02x:%02x:%02x\n\x00" as *const u8 - as *const libc::c_char, - crate::src::utils::logtime(), - (*::std::mem::transmute::<&[u8; 9], &[libc::c_char; 9]>(b"sendHELO\x00")).as_ptr(), - 142 as libc::c_int, - pkt.mac[0 as libc::c_int as usize] as libc::c_int, - pkt.mac[1 as libc::c_int as usize] as libc::c_int, - pkt.mac[2 as libc::c_int as usize] as libc::c_int, - pkt.mac[3 as libc::c_int as usize] as libc::c_int, - pkt.mac[4 as libc::c_int as usize] as libc::c_int, - pkt.mac[5 as libc::c_int as usize] as libc::c_int, - ); + memset(&mut pkt as *mut HELO_packet as *mut libc::c_void, + 0 as libc::c_int, + ::std::mem::size_of::() as libc::c_ulong); + memcpy(&mut pkt.opcode as *mut [libc::c_char; 4] as *mut libc::c_void, + b"HELO\x00" as *const u8 as *const libc::c_char as + *const libc::c_void, 4 as libc::c_int as libc::c_ulong); + pkt.length = + htonl((::std::mem::size_of::() as + libc::c_ulong).wrapping_sub(8 as libc::c_int as + libc::c_ulong).wrapping_add(strlen(base_cap)).wrapping_add(strlen(fixed_cap)).wrapping_add(strlen(var_cap)) + as uint32_t); + pkt.deviceid = 12 as libc::c_int as u8_t; + pkt.revision = 0 as libc::c_int as u8_t; + packn(&mut pkt.wlan_channellist, + if reconnect as libc::c_int != 0 { + 0x4000 as libc::c_int + } else { 0 as libc::c_int } as u16_t); + packN(&mut pkt.bytes_received_H, + (status.stream_bytes >> 32 as libc::c_int) as u32_t); + packN(&mut pkt.bytes_received_L, + (status.stream_bytes & 0xffffffff as libc::c_uint as libc::c_ulong) + as u32_t); + memcpy(pkt.mac.as_mut_ptr() as *mut libc::c_void, + mac as *const libc::c_void, 6 as libc::c_int as libc::c_ulong); + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d mac: %02x:%02x:%02x:%02x:%02x:%02x\n\x00" as + *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 9], + &[libc::c_char; 9]>(b"sendHELO\x00")).as_ptr(), + 142 as libc::c_int, + pkt.mac[0 as libc::c_int as usize] as libc::c_int, + pkt.mac[1 as libc::c_int as usize] as libc::c_int, + pkt.mac[2 as libc::c_int as usize] as libc::c_int, + pkt.mac[3 as libc::c_int as usize] as libc::c_int, + pkt.mac[4 as libc::c_int as usize] as libc::c_int, + pkt.mac[5 as libc::c_int as usize] 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 cap: %s%s%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"sendHELO\x00")).as_ptr(), - 144 as libc::c_int, - base_cap, - fixed_cap, - var_cap, - ); + if loglevel as libc::c_uint >= lINFO as libc::c_int as libc::c_uint { + logprint(b"%s %s:%d cap: %s%s%s\n\x00" as *const u8 as + *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 9], + &[libc::c_char; 9]>(b"sendHELO\x00")).as_ptr(), + 144 as libc::c_int, base_cap, fixed_cap, var_cap); } - send_packet( - &mut pkt as *mut crate::src::slimproto::HELO_packet as *mut crate::squeezelite_h::u8_t, - ::std::mem::size_of::() as libc::c_ulong, - ); - send_packet( - base_cap as *mut crate::squeezelite_h::u8_t, - crate::stdlib::strlen(base_cap), - ); - send_packet( - fixed_cap as *mut crate::squeezelite_h::u8_t, - crate::stdlib::strlen(fixed_cap), - ); - send_packet( - var_cap as *mut crate::squeezelite_h::u8_t, - crate::stdlib::strlen(var_cap), - ); + send_packet(&mut pkt as *mut HELO_packet as *mut u8_t, + ::std::mem::size_of::() as libc::c_ulong); + send_packet(base_cap as *mut u8_t, strlen(base_cap)); + send_packet(fixed_cap as *mut u8_t, strlen(fixed_cap)); + send_packet(var_cap as *mut u8_t, strlen(var_cap)); } - -unsafe extern "C" fn sendSTAT( - mut event: *const libc::c_char, - mut server_timestamp: crate::squeezelite_h::u32_t, -) { - let mut pkt = crate::src::slimproto::STAT_packet { - opcode: [0; 4], - length: 0, - event: 0, - num_crlf: 0, - mas_initialized: 0, - mas_mode: 0, - stream_buffer_size: 0, - stream_buffer_fullness: 0, - bytes_received_H: 0, - bytes_received_L: 0, - signal_strength: 0, - jiffies: 0, - output_buffer_size: 0, - output_buffer_fullness: 0, - elapsed_seconds: 0, - voltage: 0, - elapsed_milliseconds: 0, - server_timestamp: 0, - error_code: 0, - }; - let mut now = crate::src::utils::gettime_ms(); - let mut ms_played: crate::squeezelite_h::u32_t = 0; - if status.current_sample_rate != 0 - && status.frames_played != 0 - && status.frames_played > status.device_frames - { - ms_played = (status.frames_played.wrapping_sub(status.device_frames) - as crate::squeezelite_h::u64_t) - .wrapping_mul(1000 as libc::c_int as crate::squeezelite_h::u64_t) - .wrapping_div(status.current_sample_rate as crate::squeezelite_h::u64_t) - as crate::squeezelite_h::u32_t; +unsafe extern "C" fn sendSTAT(mut event: *const libc::c_char, + mut server_timestamp: u32_t) { + let mut pkt: STAT_packet = + STAT_packet{opcode: [0; 4], + length: 0, + event: 0, + num_crlf: 0, + mas_initialized: 0, + mas_mode: 0, + stream_buffer_size: 0, + stream_buffer_fullness: 0, + bytes_received_H: 0, + bytes_received_L: 0, + signal_strength: 0, + jiffies: 0, + output_buffer_size: 0, + output_buffer_fullness: 0, + elapsed_seconds: 0, + voltage: 0, + elapsed_milliseconds: 0, + server_timestamp: 0, + error_code: 0,}; + let mut now: u32_t = gettime_ms(); + let mut ms_played: u32_t = 0; + if status.current_sample_rate != 0 && status.frames_played != 0 && + status.frames_played > status.device_frames { + ms_played = + (status.frames_played.wrapping_sub(status.device_frames) as + u64_t).wrapping_mul(1000 as libc::c_int as + u64_t).wrapping_div(status.current_sample_rate + as u64_t) as + u32_t; if now > status.updated { - ms_played = (ms_played as libc::c_uint).wrapping_add(now.wrapping_sub(status.updated)) - as crate::squeezelite_h::u32_t - as crate::squeezelite_h::u32_t + ms_played = + (ms_played as + libc::c_uint).wrapping_add(now.wrapping_sub(status.updated)) + as u32_t as u32_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 ms_played: %u (frames_played: %u device_frames: %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"sendSTAT\x00")).as_ptr(), - 160 as libc::c_int, - ms_played, - status.frames_played, - status.device_frames, - ); + if loglevel as libc::c_uint >= lSDEBUG as libc::c_int as libc::c_uint + { + logprint(b"%s %s:%d ms_played: %u (frames_played: %u device_frames: %u)\n\x00" + as *const u8 as *const libc::c_char, logtime(), + (*::std::mem::transmute::<&[u8; 9], + &[libc::c_char; 9]>(b"sendSTAT\x00")).as_ptr(), + 160 as libc::c_int, ms_played, status.frames_played, + status.device_frames); } } else if status.frames_played != 0 && now > status.stream_start { ms_played = now.wrapping_sub(status.stream_start); - 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 ms_played: %u using elapsed time (frames_played: %u device_frames: %u)\n\x00" - as *const u8 as *const libc::c_char, crate::src::utils::logtime(), + if loglevel as libc::c_uint >= lSDEBUG as libc::c_int as libc::c_uint + { + logprint(b"%s %s:%d ms_played: %u using elapsed time (frames_played: %u device_frames: %u)\n\x00" + as *const u8 as *const libc::c_char, logtime(), (*::std::mem::transmute::<&[u8; 9], &[libc::c_char; 9]>(b"sendSTAT\x00")).as_ptr(), 163 as libc::c_int, ms_played, status.frames_played, status.device_frames); } } else { - 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 ms_played: 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"sendSTAT\x00")).as_ptr(), - 165 as libc::c_int, - ); - } - ms_played = 0 as libc::c_int as crate::squeezelite_h::u32_t - } - crate::stdlib::memset( - &mut pkt as *mut crate::src::slimproto::STAT_packet as *mut libc::c_void, - 0 as libc::c_int, - ::std::mem::size_of::() as libc::c_ulong, - ); - crate::stdlib::memcpy( - &mut pkt.opcode as *mut [libc::c_char; 4] as *mut libc::c_void, - b"STAT\x00" as *const u8 as *const libc::c_char as *const libc::c_void, - 4 as libc::c_int as libc::c_ulong, - ); - pkt.length = crate::stdlib::htonl( - (::std::mem::size_of::() as libc::c_ulong) - .wrapping_sub(8 as libc::c_int as libc::c_ulong) as crate::stdlib::uint32_t, - ); - crate::stdlib::memcpy( - &mut pkt.event as *mut crate::squeezelite_h::u32_t as *mut libc::c_void, - event as *const libc::c_void, - 4 as libc::c_int as libc::c_ulong, - ); - // num_crlf - // mas_initialized; mas_mode; - crate::src::utils::packN(&mut pkt.stream_buffer_fullness, status.stream_full); - crate::src::utils::packN(&mut pkt.stream_buffer_size, status.stream_size); - crate::src::utils::packN( - &mut pkt.bytes_received_H, - (status.stream_bytes >> 32 as libc::c_int) as crate::squeezelite_h::u32_t, - ); - crate::src::utils::packN( - &mut pkt.bytes_received_L, - (status.stream_bytes & 0xffffffff as libc::c_uint as libc::c_ulong) - as crate::squeezelite_h::u32_t, - ); - pkt.signal_strength = 0xffff as libc::c_int as crate::squeezelite_h::u16_t; - crate::src::utils::packN(&mut pkt.jiffies, now); - crate::src::utils::packN(&mut pkt.output_buffer_size, status.output_size); - crate::src::utils::packN(&mut pkt.output_buffer_fullness, status.output_full); - crate::src::utils::packN( - &mut pkt.elapsed_seconds, - ms_played.wrapping_div(1000 as libc::c_int as libc::c_uint), - ); - // voltage; - crate::src::utils::packN(&mut pkt.elapsed_milliseconds, ms_played); // keep this is server format - don't unpack/pack - pkt.server_timestamp = server_timestamp; - // error_code; - 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 STAT: %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"sendSTAT\x00")).as_ptr(), - 189 as libc::c_int, - event, - ); // id 0 is playername S:P:Squeezebox2 - } // STMt replay_gain is no longer used to track latency, but support it - if loglevel as libc::c_uint == crate::squeezelite_h::lSDEBUG 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 received bytesL: %u streambuf: %u outputbuf: %u calc elapsed: %u real elapsed: %u (diff: %d) device: %u delay: %d\n\x00" - as *const u8 as *const libc::c_char, crate::src::utils::logtime(), + if loglevel as libc::c_uint >= lSDEBUG as libc::c_int as libc::c_uint + { + logprint(b"%s %s:%d ms_played: 0\n\x00" as *const u8 as + *const libc::c_char, logtime(), (*::std::mem::transmute::<&[u8; 9], &[libc::c_char; 9]>(b"sendSTAT\x00")).as_ptr(), - 194 as libc::c_int, status.stream_bytes as crate::squeezelite_h::u32_t, + 165 as libc::c_int); + } + ms_played = 0 as libc::c_int as u32_t + } + memset(&mut pkt as *mut STAT_packet as *mut libc::c_void, + 0 as libc::c_int, + ::std::mem::size_of::