1356 lines
64 KiB
Rust
1356 lines
64 KiB
Rust
use ::libc;
|
|
use ::c2rust_bitfields;
|
|
extern "C" {
|
|
pub type FLAC__StreamDecoderPrivate;
|
|
pub type FLAC__StreamDecoderProtected;
|
|
#[no_mangle]
|
|
fn malloc(_: libc::c_ulong) -> *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 _checkfade(_: bool);
|
|
#[no_mangle]
|
|
fn decode_newstream(sample_rate: libc::c_uint,
|
|
supported_rates: *mut libc::c_uint) -> libc::c_uint;
|
|
#[no_mangle]
|
|
fn dlopen(__file: *const libc::c_char, __mode: libc::c_int)
|
|
-> *mut libc::c_void;
|
|
#[no_mangle]
|
|
fn dlsym(__handle: *mut libc::c_void, __name: *const libc::c_char)
|
|
-> *mut libc::c_void;
|
|
#[no_mangle]
|
|
fn dlerror() -> *mut libc::c_char;
|
|
#[no_mangle]
|
|
fn pthread_mutex_lock(__mutex: *mut pthread_mutex_t) -> libc::c_int;
|
|
#[no_mangle]
|
|
fn pthread_mutex_unlock(__mutex: *mut pthread_mutex_t) -> libc::c_int;
|
|
#[no_mangle]
|
|
fn logtime() -> *const libc::c_char;
|
|
#[no_mangle]
|
|
fn logprint(fmt: *const libc::c_char, _: ...);
|
|
#[no_mangle]
|
|
fn _buf_used(buf: *mut buffer) -> libc::c_uint;
|
|
#[no_mangle]
|
|
fn _buf_space(buf: *mut buffer) -> libc::c_uint;
|
|
#[no_mangle]
|
|
fn _buf_cont_read(buf: *mut buffer) -> libc::c_uint;
|
|
#[no_mangle]
|
|
fn _buf_cont_write(buf: *mut buffer) -> libc::c_uint;
|
|
#[no_mangle]
|
|
fn _buf_inc_readp(buf: *mut buffer, by: libc::c_uint);
|
|
#[no_mangle]
|
|
fn _buf_inc_writep(buf: *mut buffer, by: libc::c_uint);
|
|
#[no_mangle]
|
|
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<unsafe extern "C" fn(_: u8_t, _: u8_t, _: u8_t, _: u8_t)
|
|
-> ()>,
|
|
pub close: Option<unsafe extern "C" fn() -> ()>,
|
|
pub decode: Option<unsafe extern "C" fn() -> decode_state>,
|
|
}
|
|
pub type output_state = libc::c_int;
|
|
pub const OUTPUT_START_AT: output_state = 5;
|
|
pub const OUTPUT_SKIP_FRAMES: output_state = 4;
|
|
pub const OUTPUT_PAUSE_FRAMES: output_state = 3;
|
|
pub const OUTPUT_RUNNING: output_state = 2;
|
|
pub const OUTPUT_BUFFER: output_state = 1;
|
|
pub const OUTPUT_STOPPED: output_state = 0;
|
|
pub const OUTPUT_OFF: output_state = -1;
|
|
pub type output_format = libc::c_uint;
|
|
pub const S16_LE: output_format = 3;
|
|
pub const S24_3LE: output_format = 2;
|
|
pub const S24_LE: output_format = 1;
|
|
pub const S32_LE: output_format = 0;
|
|
pub type fade_state = libc::c_uint;
|
|
pub const FADE_ACTIVE: fade_state = 2;
|
|
pub const FADE_DUE: fade_state = 1;
|
|
pub const FADE_INACTIVE: fade_state = 0;
|
|
pub type fade_dir = libc::c_uint;
|
|
pub const FADE_CROSS: fade_dir = 3;
|
|
pub const FADE_DOWN: fade_dir = 2;
|
|
pub const FADE_UP: fade_dir = 1;
|
|
pub type fade_mode = libc::c_uint;
|
|
pub const FADE_INOUT: fade_mode = 4;
|
|
pub const FADE_OUT: fade_mode = 3;
|
|
pub const FADE_IN: fade_mode = 2;
|
|
pub const FADE_CROSSFADE: fade_mode = 1;
|
|
pub const FADE_NONE: fade_mode = 0;
|
|
#[derive(Copy, Clone)]
|
|
#[repr(C)]
|
|
pub struct outputstate {
|
|
pub state: output_state,
|
|
pub format: output_format,
|
|
pub device: *const libc::c_char,
|
|
pub buffer: libc::c_uint,
|
|
pub period: libc::c_uint,
|
|
pub track_started: bool,
|
|
pub write_cb: Option<unsafe extern "C" fn(_: frames_t, _: bool, _: s32_t,
|
|
_: s32_t, _: s32_t, _: s32_t,
|
|
_: *mut *mut s32_t)
|
|
-> libc::c_int>,
|
|
pub start_frames: libc::c_uint,
|
|
pub frames_played: libc::c_uint,
|
|
pub frames_played_dmp: libc::c_uint,
|
|
pub current_sample_rate: libc::c_uint,
|
|
pub supported_rates: [libc::c_uint; 18],
|
|
pub default_sample_rate: libc::c_uint,
|
|
pub error_opening: bool,
|
|
pub device_frames: libc::c_uint,
|
|
pub updated: u32_t,
|
|
pub track_start_time: u32_t,
|
|
pub current_replay_gain: u32_t,
|
|
pub c2rust_unnamed: C2RustUnnamed,
|
|
pub next_sample_rate: libc::c_uint,
|
|
pub track_start: *mut u8_t,
|
|
pub gainL: u32_t,
|
|
pub gainR: u32_t,
|
|
pub invert: bool,
|
|
pub next_replay_gain: u32_t,
|
|
pub threshold: libc::c_uint,
|
|
pub fade: fade_state,
|
|
pub fade_start: *mut u8_t,
|
|
pub fade_end: *mut u8_t,
|
|
pub fade_dir: fade_dir,
|
|
pub fade_mode: fade_mode,
|
|
pub fade_secs: libc::c_uint,
|
|
pub rate_delay: libc::c_uint,
|
|
pub delay_active: bool,
|
|
pub stop_time: u32_t,
|
|
pub idle_to: u32_t,
|
|
}
|
|
#[derive(Copy, Clone)]
|
|
#[repr(C)]
|
|
pub union C2RustUnnamed {
|
|
pub pause_frames: u32_t,
|
|
pub skip_frames: u32_t,
|
|
pub start_at: u32_t,
|
|
}
|
|
pub const 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
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*
|
|
*/
|
|
#[derive(Copy, Clone)]
|
|
#[repr(C)]
|
|
pub struct flac {
|
|
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<unsafe extern "C" fn()
|
|
-> *mut FLAC__StreamDecoder>,
|
|
pub FLAC__stream_decoder_reset: Option<unsafe extern "C" fn(_:
|
|
*mut FLAC__StreamDecoder)
|
|
-> FLAC__bool>,
|
|
pub FLAC__stream_decoder_delete: Option<unsafe extern "C" fn(_:
|
|
*mut FLAC__StreamDecoder)
|
|
-> ()>,
|
|
pub FLAC__stream_decoder_init_stream: Option<unsafe extern "C" fn(_:
|
|
*mut FLAC__StreamDecoder,
|
|
_:
|
|
FLAC__StreamDecoderReadCallback,
|
|
_:
|
|
FLAC__StreamDecoderSeekCallback,
|
|
_:
|
|
FLAC__StreamDecoderTellCallback,
|
|
_:
|
|
FLAC__StreamDecoderLengthCallback,
|
|
_:
|
|
FLAC__StreamDecoderEofCallback,
|
|
_:
|
|
FLAC__StreamDecoderWriteCallback,
|
|
_:
|
|
FLAC__StreamDecoderMetadataCallback,
|
|
_:
|
|
FLAC__StreamDecoderErrorCallback,
|
|
_:
|
|
*mut libc::c_void)
|
|
->
|
|
FLAC__StreamDecoderInitStatus>,
|
|
pub FLAC__stream_decoder_init_ogg_stream: Option<unsafe extern "C" fn(_:
|
|
*mut FLAC__StreamDecoder,
|
|
_:
|
|
FLAC__StreamDecoderReadCallback,
|
|
_:
|
|
FLAC__StreamDecoderSeekCallback,
|
|
_:
|
|
FLAC__StreamDecoderTellCallback,
|
|
_:
|
|
FLAC__StreamDecoderLengthCallback,
|
|
_:
|
|
FLAC__StreamDecoderEofCallback,
|
|
_:
|
|
FLAC__StreamDecoderWriteCallback,
|
|
_:
|
|
FLAC__StreamDecoderMetadataCallback,
|
|
_:
|
|
FLAC__StreamDecoderErrorCallback,
|
|
_:
|
|
*mut libc::c_void)
|
|
->
|
|
FLAC__StreamDecoderInitStatus>,
|
|
pub FLAC__stream_decoder_process_single: Option<unsafe extern "C" fn(_:
|
|
*mut FLAC__StreamDecoder)
|
|
-> FLAC__bool>,
|
|
pub FLAC__stream_decoder_get_state: Option<unsafe extern "C" fn(_:
|
|
*const FLAC__StreamDecoder)
|
|
->
|
|
FLAC__StreamDecoderState>,
|
|
}
|
|
pub type FLAC__bool = libc::c_int;
|
|
pub type FLAC__StreamDecoderErrorCallback
|
|
=
|
|
Option<unsafe extern "C" fn(_: *const FLAC__StreamDecoder,
|
|
_: FLAC__StreamDecoderErrorStatus,
|
|
_: *mut libc::c_void) -> ()>;
|
|
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<unsafe extern "C" fn(_: *const FLAC__StreamDecoder,
|
|
_: *const FLAC__StreamMetadata,
|
|
_: *mut libc::c_void) -> ()>;
|
|
#[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<unsafe extern "C" fn(_: *const FLAC__StreamDecoder,
|
|
_: *const FLAC__Frame,
|
|
_: *const *const FLAC__int32,
|
|
_: *mut libc::c_void)
|
|
-> 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<unsafe extern "C" fn(_: *const FLAC__StreamDecoder,
|
|
_: *mut libc::c_void) -> FLAC__bool>;
|
|
pub type FLAC__StreamDecoderLengthCallback
|
|
=
|
|
Option<unsafe extern "C" fn(_: *const FLAC__StreamDecoder,
|
|
_: *mut FLAC__uint64, _: *mut libc::c_void)
|
|
-> 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<unsafe extern "C" fn(_: *const FLAC__StreamDecoder,
|
|
_: *mut FLAC__uint64, _: *mut libc::c_void)
|
|
-> 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<unsafe extern "C" fn(_: *const FLAC__StreamDecoder,
|
|
_: FLAC__uint64, _: *mut libc::c_void)
|
|
-> 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<unsafe extern "C" fn(_: *const FLAC__StreamDecoder,
|
|
_: *mut FLAC__byte, _: *mut size_t,
|
|
_: *mut libc::c_void)
|
|
-> 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 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;
|
|
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 <=
|
|
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 {
|
|
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 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 {
|
|
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 =
|
|
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);
|
|
}
|
|
pthread_mutex_lock(&mut (*outputbuf).mutex);
|
|
while frames > 0 as libc::c_int as libc::c_ulong {
|
|
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 {
|
|
let fresh0 = count;
|
|
count = count.wrapping_sub(1);
|
|
if !(fresh0 != 0) { break ; }
|
|
let fresh1 = lptr;
|
|
lptr = lptr.offset(1);
|
|
let fresh2 = optr;
|
|
optr = optr.offset(1);
|
|
*fresh2 = *fresh1 << 24 as libc::c_int;
|
|
let fresh3 = rptr;
|
|
rptr = rptr.offset(1);
|
|
let fresh4 = optr;
|
|
optr = optr.offset(1);
|
|
*fresh4 = *fresh3 << 24 as libc::c_int
|
|
}
|
|
} else if bits_per_sample == 16 as libc::c_int as libc::c_uint {
|
|
loop {
|
|
let fresh5 = count;
|
|
count = count.wrapping_sub(1);
|
|
if !(fresh5 != 0) { break ; }
|
|
let fresh6 = lptr;
|
|
lptr = lptr.offset(1);
|
|
let fresh7 = optr;
|
|
optr = optr.offset(1);
|
|
*fresh7 = *fresh6 << 16 as libc::c_int;
|
|
let fresh8 = rptr;
|
|
rptr = rptr.offset(1);
|
|
let fresh9 = optr;
|
|
optr = optr.offset(1);
|
|
*fresh9 = *fresh8 << 16 as libc::c_int
|
|
}
|
|
} else if bits_per_sample == 24 as libc::c_int as libc::c_uint {
|
|
loop {
|
|
let fresh10 = count;
|
|
count = count.wrapping_sub(1);
|
|
if !(fresh10 != 0) { break ; }
|
|
let fresh11 = lptr;
|
|
lptr = lptr.offset(1);
|
|
let fresh12 = optr;
|
|
optr = optr.offset(1);
|
|
*fresh12 = *fresh11 << 8 as libc::c_int;
|
|
let fresh13 = rptr;
|
|
rptr = rptr.offset(1);
|
|
let fresh14 = optr;
|
|
optr = optr.offset(1);
|
|
*fresh14 = *fresh13 << 8 as libc::c_int
|
|
}
|
|
} else if bits_per_sample == 32 as libc::c_int as libc::c_uint {
|
|
loop {
|
|
let fresh15 = count;
|
|
count = count.wrapping_sub(1);
|
|
if !(fresh15 != 0) { break ; }
|
|
let fresh16 = lptr;
|
|
lptr = lptr.offset(1);
|
|
let fresh17 = optr;
|
|
optr = optr.offset(1);
|
|
*fresh17 = *fresh16;
|
|
let fresh18 = rptr;
|
|
rptr = rptr.offset(1);
|
|
let fresh19 = optr;
|
|
optr = optr.offset(1);
|
|
*fresh19 = *fresh18
|
|
}
|
|
} else {
|
|
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
|
|
size_t as size_t;
|
|
_buf_inc_writep(outputbuf,
|
|
f_0.wrapping_mul(8 as libc::c_int as libc::c_uint));
|
|
}
|
|
pthread_mutex_unlock(&mut (*outputbuf).mutex);
|
|
return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE;
|
|
}
|
|
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: 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);
|
|
} else {
|
|
(*f).decoder =
|
|
(*f).FLAC__stream_decoder_new.expect("non-null function pointer")()
|
|
}
|
|
if sample_size as libc::c_int == 'o' as i32 {
|
|
if loglevel as libc::c_uint >= 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 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 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 FLAC__StreamDecoder;
|
|
}
|
|
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 ==
|
|
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: *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 >= 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
|
|
}
|
|
(*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<unsafe extern "C" fn()
|
|
->
|
|
*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<unsafe extern "C" fn(_:
|
|
*mut FLAC__StreamDecoder)
|
|
->
|
|
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<unsafe extern "C" fn(_:
|
|
*mut FLAC__StreamDecoder)
|
|
->
|
|
()>>(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 FLAC__StreamDecoder,
|
|
_:
|
|
FLAC__StreamDecoderReadCallback,
|
|
_:
|
|
FLAC__StreamDecoderSeekCallback,
|
|
_:
|
|
FLAC__StreamDecoderTellCallback,
|
|
_:
|
|
FLAC__StreamDecoderLengthCallback,
|
|
_:
|
|
FLAC__StreamDecoderEofCallback,
|
|
_:
|
|
FLAC__StreamDecoderWriteCallback,
|
|
_:
|
|
FLAC__StreamDecoderMetadataCallback,
|
|
_:
|
|
FLAC__StreamDecoderErrorCallback,
|
|
_:
|
|
*mut libc::c_void)
|
|
->
|
|
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<unsafe extern "C" fn(_:
|
|
*mut FLAC__StreamDecoder,
|
|
_:
|
|
FLAC__StreamDecoderReadCallback,
|
|
_:
|
|
FLAC__StreamDecoderSeekCallback,
|
|
_:
|
|
FLAC__StreamDecoderTellCallback,
|
|
_:
|
|
FLAC__StreamDecoderLengthCallback,
|
|
_:
|
|
FLAC__StreamDecoderEofCallback,
|
|
_:
|
|
FLAC__StreamDecoderWriteCallback,
|
|
_:
|
|
FLAC__StreamDecoderMetadataCallback,
|
|
_:
|
|
FLAC__StreamDecoderErrorCallback,
|
|
_:
|
|
*mut libc::c_void)
|
|
->
|
|
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<unsafe extern "C" fn(_:
|
|
*mut FLAC__StreamDecoder)
|
|
->
|
|
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<unsafe extern "C" fn(_:
|
|
*const FLAC__StreamDecoder)
|
|
->
|
|
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 >= 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
|
|
}
|
|
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
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*
|
|
* Additions (c) Paul Hermann, 2015-2017 under the same license terms
|
|
* -Control of Raspberry pi GPIO for amplifier power
|
|
* -Launch script on power status change from LMS
|
|
*/
|
|
// make may define: PORTAUDIO, SELFPIPE, RESAMPLE, RESAMPLE_MP, VISEXPORT, GPIO, IR, DSD, LINKALL to influence build
|
|
// build detection
|
|
// dynamically loaded libraries at run time
|
|
// !LINKALL
|
|
// config options
|
|
// do not reduce as icy-meta max is 4080
|
|
/* SUN */
|
|
/* SUN */
|
|
// printf/scanf formats for u64_t
|
|
// logging
|
|
// utils.c (non logging)
|
|
// buffer.c
|
|
// _* called with mutex locked
|
|
// slimproto.c
|
|
// stream.c
|
|
// decode.c
|
|
// output.c output_alsa.c output_pa.c output_pack.c
|
|
// frames played at the point delay is measured
|
|
// ordered largest first so [0] is max_rate
|
|
// set in decode thread
|
|
// set in decode thread
|
|
// set by slimproto
|
|
// set by slimproto
|
|
// set by slimproto
|
|
// set by slimproto
|
|
// set by slimproto
|
|
// set by slimproto
|
|
// set by slimproto
|
|
// _* called with mutex locked
|
|
// output_alsa.c
|
|
// output_pa.c
|
|
// output_pulse.c
|
|
// output_stdout.c
|
|
// output_pack.c
|
|
// output_vis.c
|
|
// dop.c
|
|
// codecs
|
|
#[no_mangle]
|
|
pub unsafe extern "C" fn register_flac() -> *mut 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::<flac>() 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;
|
|
}
|