A modern Music Player Daemon based on Rockbox open source high quality audio player
libadwaita
audio
rust
zig
deno
mpris
rockbox
mpd
1use std::ffi::{c_char, c_int, c_long, c_uchar, c_uint, c_ulong, c_void};
2
3pub mod browse;
4pub mod dir;
5pub mod events;
6pub mod file;
7pub mod menu;
8pub mod metadata;
9pub mod misc;
10pub mod playback;
11pub mod playlist;
12pub mod plugin;
13pub mod settings;
14pub mod sound;
15pub mod system;
16pub mod tagcache;
17pub mod types;
18
19pub const MAX_PATH: usize = 260;
20const ID3V2_BUF_SIZE: usize = 1800;
21const MAX_PATHNAME: usize = 80;
22const NB_SCREENS: usize = 2;
23pub const HZ: i32 = 100;
24
25pub const PLAYLIST_PREPEND: i32 = -1;
26pub const PLAYLIST_INSERT: i32 = -2;
27pub const PLAYLIST_INSERT_LAST: i32 = -3;
28pub const PLAYLIST_INSERT_FIRST: i32 = -4;
29pub const PLAYLIST_INSERT_SHUFFLED: i32 = -5;
30pub const PLAYLIST_REPLACE: i32 = -6;
31pub const PLAYLIST_INSERT_LAST_SHUFFLED: i32 = -7;
32pub const PLAYLIST_INSERT_LAST_ROTATED: i32 = -8;
33
34#[macro_export]
35macro_rules! cast_ptr {
36 ($ptr:expr) => {{
37 $ptr as *const std::ffi::c_char
38 }};
39}
40
41#[macro_export]
42macro_rules! get_string_from_ptr {
43 ($ptr:expr) => {
44 unsafe {
45 match $ptr.is_null() {
46 true => String::new(),
47 false => std::ffi::CStr::from_ptr($ptr)
48 .to_string_lossy()
49 .into_owned(),
50 }
51 }
52 };
53}
54
55#[macro_export]
56macro_rules! convert_ptr_to_vec {
57 ($ptr:expr, $len:expr) => {{
58 if $ptr.is_null() {
59 Vec::new()
60 } else {
61 // Safety: Ensure that the pointer is valid for $len elements,
62 // and that the memory was allocated in a way that is compatible with Rust's Vec.
63 unsafe { Vec::from_raw_parts($ptr as *mut i8, $len, $len) }
64 }
65 }};
66}
67
68#[macro_export]
69macro_rules! ptr_to_option {
70 ($ptr:expr) => {
71 if $ptr.is_null() {
72 None
73 } else {
74 unsafe { Some(*$ptr) }
75 }
76 };
77}
78
79#[macro_export]
80macro_rules! set_value_setting {
81 ($setting:expr, $global_setting:expr) => {
82 if let Some(value) = $setting {
83 $global_setting = value;
84 }
85 };
86}
87
88#[macro_export]
89macro_rules! set_str_setting {
90 ($setting:expr, $global_setting:expr, $len:expr) => {
91 if let Some(player_name) = $setting {
92 let mut array = [0u8; $len]; // Initialize a fixed-size array with zeros
93 let bytes = player_name.as_bytes(); // Convert the String to bytes
94
95 let copy_len = bytes.len().min($len);
96 array[..copy_len].copy_from_slice(&bytes[..copy_len]);
97 $global_setting = array;
98 }
99 };
100}
101
102#[repr(C)]
103#[derive(Debug, Copy, Clone)]
104pub struct Mp3Entry {
105 pub path: [c_uchar; MAX_PATH], // char path[MAX_PATH]
106 pub title: *mut c_char, // char* title
107 pub artist: *mut c_char, // char* artist
108 pub album: *mut c_char, // char* album
109 pub genre_string: *mut c_char, // char* genre_string
110 pub disc_string: *mut c_char, // char* disc_string
111 pub track_string: *mut c_char, // char* track_string
112 pub year_string: *mut c_char, // char* year_string
113 pub composer: *mut c_char, // char* composer
114 pub comment: *mut c_char, // char* comment
115 pub albumartist: *mut c_char, // char* albumartist
116 pub grouping: *mut c_char, // char* grouping
117 pub discnum: c_int, // int discnum
118 pub tracknum: c_int, // int tracknum
119 pub layer: c_int, // int layer
120 pub year: c_int, // int year
121 pub id3version: c_uchar, // unsigned char id3version
122 pub codectype: c_uint, // unsigned int codectype
123 pub bitrate: c_uint, // unsigned int bitrate
124 pub frequency: c_ulong, // unsigned long frequency
125 pub id3v2len: c_ulong, // unsigned long id3v2len
126 pub id3v1len: c_ulong, // unsigned long id3v1len
127 pub first_frame_offset: c_ulong, // unsigned long first_frame_offset
128 pub filesize: c_ulong, // unsigned long filesize
129 pub length: c_ulong, // unsigned long length
130 pub elapsed: c_ulong, // unsigned long elapsed
131 pub lead_trim: c_int, // int lead_trim
132 pub tail_trim: c_int, // int tail_trim
133 pub samples: u64, // uint64_t samples
134 pub frame_count: c_ulong, // unsigned long frame_count
135 pub bytesperframe: c_ulong, // unsigned long bytesperframe
136 pub vbr: bool, // bool vbr
137 pub has_toc: bool, // bool has_toc
138 pub toc: [c_uchar; 100], // unsigned char toc[100]
139 pub needs_upsampling_correction: bool, // bool needs_upsampling_correction
140 pub id3v2buf: [c_uchar; ID3V2_BUF_SIZE], // char id3v2buf[ID3V2_BUF_SIZE]
141 pub id3v1buf: [[c_uchar; 92]; 4], // char id3v1buf[4][92]
142 pub offset: c_ulong, // unsigned long offset
143 pub index: c_int, // int index
144 pub skip_resume_adjustments: bool, // bool skip_resume_adjustments
145 pub autoresumable: c_uchar, // unsigned char autoresumable
146 pub tagcache_idx: c_long, // long tagcache_idx
147 pub rating: c_int, // int rating
148 pub score: c_int, // int score
149 pub playcount: c_long, // long playcount
150 pub lastplayed: c_long, // long lastplayed
151 pub playtime: c_long, // long playtime
152 pub track_level: c_long, // long track_level
153 pub album_level: c_long, // long album_level
154 pub track_gain: c_long, // long track_gain
155 pub album_gain: c_long, // long album_gain
156 pub track_peak: c_long, // long track_peak
157 pub album_peak: c_long, // long album_peak
158 pub has_embedded_albumart: bool, // bool has_embedded_albumart
159 pub albumart: *mut c_void, // struct mp3_albumart albumart
160 pub has_embedded_cuesheet: bool, // bool has_embedded_cuesheet
161 // pub embedded_cuesheet: *mut c_void, // struct embedded_cuesheet embedded_cuesheet
162 // pub cuesheet: *mut c_void, // struct cuesheet* cuesheet
163 pub mb_track_id: *mut c_char, // char* mb_track_id
164 pub is_asf_stream: bool, // bool is_asf_stream
165}
166
167const PLAYLIST_CONTROL_FILE: &str = "./config/rockbox.org/.playlist_control";
168const MAX_DIR_LEVELS: usize = 10;
169
170#[repr(C)]
171#[derive(Debug)]
172pub struct PlaylistInfo {
173 pub utf8: bool, // bool utf8
174 pub control_created: bool, // bool control_created
175 pub flags: u32, // unsigned int flags
176 pub fd: i32, // int fd
177 pub control_fd: i32, // int control_fd
178 pub max_playlist_size: i32, // int max_playlist_size
179 pub indices: [c_ulong; 200], // unsigned long* indices
180 pub index: i32, // int index
181 pub first_index: i32, // int first_index
182 pub amount: i32, // int amount
183 pub last_insert_pos: i32, // int last_insert_pos
184 pub started: bool, // bool started
185 pub last_shuffled_start: i32, // int last_shuffled_start
186 pub seed: i32, // int seed
187 pub mutex: *mut c_void, // struct mutex (convert to a void pointer for FFI)
188 pub dirlen: i32, // int dirlen
189 pub filename: [c_uchar; MAX_PATH], // char filename[MAX_PATH]
190 pub control_filename:
191 [c_uchar; std::mem::size_of::<[u8; PLAYLIST_CONTROL_FILE.len() + 100 + 8]>()], // char control_filename[sizeof(PLAYLIST_CONTROL_FILE) + 8]
192 pub dcfrefs_handle: i32, // int dcfrefs_handle
193}
194
195#[repr(C)]
196#[derive(Debug)]
197pub struct PlaylistTrackInfo {
198 pub filename: [c_uchar; MAX_PATH], // char filename[MAX_PATH]
199 pub attr: c_int,
200 pub index: c_int,
201 pub display_index: c_int,
202}
203
204#[repr(C)]
205#[derive(Debug, Copy, Clone, PartialEq, Eq)]
206pub enum ThemableIcons {
207 NoIcon = -1,
208 IconNoIcon, // Icon_NOICON = NOICON
209 IconAudio, // Icon_Audio
210 IconFolder, // Icon_Folder
211 IconPlaylist, // Icon_Playlist
212 IconCursor, // Icon_Cursor
213 IconWps, // Icon_Wps
214 IconFirmware, // Icon_Firmware
215 IconFont, // Icon_Font
216 IconLanguage, // Icon_Language
217 IconConfig, // Icon_Config
218 IconPlugin, // Icon_Plugin
219 IconBookmark, // Icon_Bookmark
220 IconPreset, // Icon_Preset
221 IconQueued, // Icon_Queued
222 IconMoving, // Icon_Moving
223 IconKeyboard, // Icon_Keyboard
224 IconReverseCursor, // Icon_Reverse_Cursor
225 IconQuestionmark, // Icon_Questionmark
226 IconMenuSetting, // Icon_Menu_setting
227 IconMenuFunctioncall, // Icon_Menu_functioncall
228 IconSubmenu, // Icon_Submenu
229 IconSubmenuEntered, // Icon_Submenu_Entered
230 IconRecording, // Icon_Recording
231 IconVoice, // Icon_Voice
232 IconGeneralSettingsMenu, // Icon_General_settings_menu
233 IconSystemMenu, // Icon_System_menu
234 IconPlaybackMenu, // Icon_Playback_menu
235 IconDisplayMenu, // Icon_Display_menu
236 IconRemoteDisplayMenu, // Icon_Remote_Display_menu
237 IconRadioScreen, // Icon_Radio_screen
238 IconFileViewMenu, // Icon_file_view_menu
239 IconEQ, // Icon_EQ
240 IconRockbox, // Icon_Rockbox
241 IconLastThemeable, // Icon_Last_Themeable
242}
243
244#[repr(C)]
245#[derive(Debug)]
246pub struct TreeCache {
247 pub entries_handle: c_int, // int entries_handle
248 pub name_buffer_handle: c_int, // int name_buffer_handle
249 pub max_entries: c_int, // int max_entries
250 pub name_buffer_size: c_int, // int name_buffer_size (in bytes)
251}
252
253#[repr(C)]
254#[derive(Debug)]
255pub struct TreeContext {
256 pub currdir: [c_uchar; MAX_PATH], // char currdir[MAX_PATH]
257 pub dirlevel: c_int, // int dirlevel
258 pub selected_item: c_int, // int selected_item
259 pub selected_item_history: [c_int; MAX_DIR_LEVELS], // int selected_item_history[MAX_DIR_LEVELS]
260 pub dirfilter: *mut c_int, // int* dirfilter
261 pub filesindir: c_int, // int filesindir
262 pub dirsindir: c_int, // int dirsindir
263 pub dirlength: c_int, // int dirlength
264 pub currtable: c_int, // int currtable (db use)
265 pub currextra: c_int, // int currextra (db use)
266 pub sort_dir: c_int, // int sort_dir
267 pub out_of_tree: c_int, // int out_of_tree
268 pub cache: TreeCache, // struct tree_cache cache
269 pub dirfull: bool, // bool dirfull
270 pub is_browsing: bool, // bool is_browsing
271 pub browse: *mut BrowseContext, // struct browse_context* browse
272}
273
274#[repr(C)]
275#[derive(Debug, Copy, Clone)]
276pub struct BrowseContext {
277 pub dirfilter: c_int, // int dirfilter
278 pub flags: c_uint, // unsigned flags
279 pub callback_show_item:
280 Option<extern "C" fn(name: *mut c_char, attr: c_int, tc: *mut TreeContext) -> bool>, // bool (*callback_show_item)(...)
281 pub title: *mut c_char, // char* title
282 pub icon: ThemableIcons, // enum themable_icons icon
283 pub root: *const c_char, // const char* root
284 pub selected: *const c_char, // const char* selected
285 pub buf: *mut c_char, // char* buf
286 pub bufsize: usize, // size_t bufsize
287}
288
289#[repr(C)]
290#[derive(Debug)]
291pub struct Entry {
292 pub name: *mut c_char, // char* name
293 pub attr: c_int, // int attr (FAT attributes + file type flags)
294 pub time_write: c_uint, // unsigned time_write (Last write time)
295 pub customaction: c_int, // int customaction (db use)
296}
297
298pub type PlaylistInsertCb = Option<extern "C" fn()>;
299pub type AddToPlCallback = Option<extern "C" fn()>;
300pub type ProgressFunc = Option<extern "C" fn(x: c_int)>;
301pub type ActionCb = Option<extern "C" fn(file_name: *const c_char) -> c_uchar>;
302
303#[repr(C)]
304#[derive(Debug)]
305pub struct Tm {
306 pub tm_sec: c_int, // Seconds. [0-60] (1 leap second)
307 pub tm_min: c_int, // Minutes. [0-59]
308 pub tm_hour: c_int, // Hours. [0-23]
309 pub tm_mday: c_int, // Day. [1-31]
310 pub tm_mon: c_int, // Month. [0-11]
311 pub tm_year: c_int, // Year - 1900
312 pub tm_wday: c_int, // Day of week. [0-6]
313 pub tm_yday: c_int, // Days in year. [0-365]
314 pub tm_isdst: c_int, // DST. [-1/0/1]
315 pub tm_gmtoff: c_long, // Seconds east of UTC
316 pub tm_zone: *const c_char, // Timezone abbreviation
317}
318
319#[repr(C)]
320#[derive(Debug)]
321pub struct Dir {}
322
323#[repr(C)]
324#[derive(Debug)]
325pub struct dirent {}
326
327#[repr(C)]
328#[derive(Debug)]
329pub struct Dirent {
330 pub attribute: c_uint,
331 pub d_name: [c_uchar; MAX_PATH],
332}
333
334const TAG_COUNT: usize = 32;
335const SEEK_LIST_SIZE: usize = 32;
336const TAGCACHE_MAX_FILTERS: usize = 4;
337const TAGCACHE_MAX_CLAUSES: usize = 32;
338const EQ_NUM_BANDS: usize = 10;
339const QUICKSCREEN_ITEM_COUNT: usize = 4;
340const MAX_FILENAME: usize = 32;
341
342#[repr(C)]
343#[derive(Debug)]
344pub struct TagcacheSearch {
345 /* For internal use only. */
346 fd: c_int,
347 masterfd: c_int,
348 idxfd: [c_int; TAG_COUNT],
349 seeklist: [TagcacheSeeklistEntry; SEEK_LIST_SIZE],
350 seek_list_count: c_int,
351 filter_tag: [i32; TAGCACHE_MAX_FILTERS],
352 filter_seek: [i32; TAGCACHE_MAX_FILTERS],
353 filter_count: c_int,
354 clause: [*mut TagcacheSearchClause; TAGCACHE_MAX_CLAUSES],
355 clause_count: c_int,
356 list_position: c_int,
357 seek_pos: c_int,
358 position: c_long,
359 entry_count: c_int,
360 valid: bool,
361 initialized: bool,
362 unique_list: *mut u32,
363 unique_list_capacity: c_int,
364 unique_list_count: c_int,
365
366 /* Exported variables. */
367 ramsearch: bool, /* Is ram copy of the tagcache being used. */
368 ramresult: bool, /* False if result is not static, and must be copied. */
369 r#type: c_int, /* The tag type to be searched. */
370 result: *mut c_char, /* The result data for all tags. */
371 result_len: c_int, /* Length of the result including \0 */
372 result_seek: i32, /* Current position in the tag data. */
373 idx_id: i32, /* Entry number in the master index. */
374}
375
376#[repr(C)]
377#[derive(Debug)]
378pub struct TagcacheSeeklistEntry {
379 seek: i32,
380 flag: i32,
381 idx_id: i32,
382}
383
384#[repr(C)]
385#[derive(Debug)]
386pub struct TagcacheSearchClause {
387 tag: c_int,
388 r#type: c_int,
389 numeric: bool,
390 source: c_int,
391 numeric_data: c_long,
392 str: *mut c_char,
393}
394
395#[repr(C)]
396#[derive(Debug)]
397pub struct TagcacheStat {
398 db_path: [c_uchar; MAX_PATHNAME + 1], // Path to DB root directory
399
400 initialized: bool, // Is tagcache currently busy?
401 readyvalid: bool, // Has tagcache ready status been ascertained?
402 ready: bool, // Is tagcache ready to be used?
403 ramcache: bool, // Is tagcache loaded in RAM?
404 commit_delayed: bool, // Has commit been delayed until next reboot?
405 econ: bool, // Is endianess correction enabled?
406 syncscreen: bool, // Synchronous operation with debug screen?
407 curentry: *const c_char, // Path of the current entry being scanned
408
409 commit_step: c_int, // Commit progress
410 ramcache_allocated: c_int, // Has RAM been allocated for ramcache?
411 ramcache_used: c_int, // How much RAM has been really used?
412 progress: c_int, // Current progress of disk scan
413 processed_entries: c_int, // Scanned disk entries so far
414 total_entries: c_int, // Total entries in tagcache
415 queue_length: c_int, // Command queue length
416}
417
418#[repr(C)]
419pub union StorageType {
420 int_val: c_int, // assuming it's an integer type, adjust according to the actual definition
421 // other possible types if storage_type is a union of different types
422}
423
424#[repr(C)]
425#[derive(Debug)]
426pub struct SoundSetting {
427 pub setting: c_int, // from the enum in firmware/sound.h
428}
429
430#[repr(C)]
431#[derive(Debug)]
432pub struct BoolSetting {
433 pub option_callback: Option<extern "C" fn(bool)>,
434 pub lang_yes: c_int,
435 pub lang_no: c_int,
436}
437
438#[repr(C)]
439#[derive(Debug)]
440pub struct FilenameSetting {
441 pub prefix: *const c_char,
442 pub suffix: *const c_char,
443 pub max_len: c_int,
444}
445
446#[repr(C)]
447pub struct IntSetting {
448 pub option_callback: Option<extern "C" fn(c_int)>,
449 pub unit: c_int,
450 pub step: c_int,
451 pub min: c_int,
452 pub max: c_int,
453 pub formatter: Option<extern "C" fn(*mut c_char, usize, c_int, *const c_char) -> *const c_char>,
454 pub get_talk_id: Option<extern "C" fn(c_int, c_int) -> c_int>,
455}
456
457#[repr(C)]
458pub struct ChoiceSetting {
459 pub option_callback: Option<extern "C" fn(c_int)>,
460 pub count: c_int,
461 pub data: ChoiceSettingData,
462}
463
464#[repr(C)]
465pub union ChoiceSettingData {
466 pub desc: *const *const c_uchar,
467 pub talks: *const c_int,
468}
469
470#[repr(C)]
471#[derive(Debug)]
472pub struct TableSetting {
473 pub option_callback: Option<extern "C" fn(c_int)>,
474 pub formatter: Option<extern "C" fn(*mut c_char, usize, c_int, *const c_char) -> *const c_char>,
475 pub get_talk_id: Option<extern "C" fn(c_int, c_int) -> c_int>,
476 pub unit: c_int,
477 pub count: c_int,
478 pub values: *const c_int,
479}
480
481#[repr(C)]
482#[derive(Debug)]
483pub struct CustomSetting {
484 pub option_callback: Option<extern "C" fn(c_int)>,
485 pub formatter: Option<extern "C" fn(*mut c_char, usize, c_int, *const c_char) -> *const c_char>,
486 pub get_talk_id: Option<extern "C" fn(c_int, c_int) -> c_int>,
487 pub unit: c_int,
488 pub count: c_int,
489 pub values: *const c_int,
490}
491
492#[repr(C)]
493pub struct SettingsList {
494 pub flags: c_uint, // uint32_t -> c_uint
495 pub setting: *mut c_void, // pointer to void
496 pub lang_id: c_int, // int
497 pub default_val: StorageType, // union storage_type
498 pub cfg_name: *const c_char, // const char*
499 pub cfg_vals: *const c_char, // const char*
500
501 // union with different possible struct types
502 pub setting_type: SettingsTypeUnion,
503}
504
505#[repr(C)]
506pub union SettingsTypeUnion {
507 pub RESERVED: *const c_void, // void pointer for the reserved field
508 pub sound_setting: *const SoundSetting, // pointer to SoundSetting struct
509 pub bool_setting: *const BoolSetting, // pointer to BoolSetting struct
510 pub filename_setting: *const FilenameSetting, // pointer to FilenameSetting struct
511 pub int_setting: *const IntSetting, // pointer to IntSetting struct
512 pub choice_setting: *const ChoiceSetting, // pointer to ChoiceSetting struct
513 pub table_setting: *const TableSetting, // pointer to TableSetting struct
514 pub custom_setting: *const CustomSetting, // pointer to CustomSetting struct
515}
516
517#[repr(C)]
518pub union FrameBufferData {
519 pub data: *mut c_void, // void* in C
520 pub ch_ptr: *mut c_char, // char* in C
521 pub fb_ptr: *mut c_char,
522}
523
524#[repr(C)]
525pub struct FrameBuffer {
526 pub buffer_data: FrameBufferData, // union data
527 pub get_address_fn: Option<extern "C" fn(x: c_int, y: c_int) -> *mut c_void>, // Function pointer
528 pub stride: isize, // ptrdiff_t in C
529 pub elems: usize, // size_t in C
530}
531
532#[repr(C)]
533pub struct Viewport {
534 pub x: c_int, // int in C
535 pub y: c_int, // int in C
536 pub width: c_int, // int in C
537 pub height: c_int, // int in C
538 pub flags: c_int, // int in C
539 pub font: c_int, // int in C
540 pub drawmode: c_int, // int in C
541 pub buffer: *mut FrameBuffer, // pointer to FrameBuffer struct
542 pub fg_pattern: c_uint, // unsigned int in C
543 pub bg_pattern: c_uint, // unsigned int in C
544}
545
546#[repr(C)]
547pub enum OptionType {
548 RbInt = 0,
549 RbBool = 1,
550}
551
552#[repr(C)]
553pub struct OptItems {
554 pub string: *const c_uchar, // const unsigned char*
555 pub voice_id: c_int, // int32_t
556}
557
558pub type PcmPlayCallbackType =
559 Option<extern "C" fn(start: *const *const c_void, size: *mut c_ulong)>;
560
561#[repr(C)]
562pub enum PcmDmaStatus {
563 PcmDmaStatusErrDma = -1, // PCM_DMAST_ERR_DMA in C
564 PcmDmaStatusOk = 0, // PCM_DMAST_OK in C
565 PcmDmaStatusStarted = 1, // PCM_DMAST_STARTED in C
566}
567
568pub type PcmStatusCallbackType = Option<extern "C" fn(status: PcmDmaStatus) -> PcmDmaStatus>;
569
570#[repr(C)]
571pub struct SampleFormat {
572 pub version: u8,
573 pub num_channels: u8,
574 pub frac_bits: u8,
575 pub output_scale: u8,
576 pub frequency: i32,
577 pub codec_frequency: i32,
578}
579
580#[repr(C)]
581pub struct DspBuffer {
582 pub remcount: i32, // Samples in buffer (In, Int, Out)
583
584 // Union for channel pointers
585 pub pin: [*const c_void; 2], // Channel pointers (In)
586 pub p32: [*mut i32; 2], // Channel pointers (Int)
587 pub p16out: *mut i16, // DSP output buffer (Out)
588
589 // Union for buffer count and proc_mask
590 pub proc_mask: u32, // In-place effects already applied
591 pub bufcount: i32, // Buffer length/dest buffer remaining
592
593 pub format: SampleFormat, // Buffer format data
594}
595
596impl DspBuffer {
597 pub fn new() -> Self {
598 Self {
599 remcount: 0,
600 pin: [std::ptr::null(); 2],
601 p32: [std::ptr::null_mut(); 2],
602 p16out: std::ptr::null_mut(),
603 proc_mask: 0,
604 bufcount: 0,
605 format: SampleFormat {
606 version: 0,
607 num_channels: 0,
608 frac_bits: 0,
609 output_scale: 0,
610 frequency: 0,
611 codec_frequency: 0,
612 },
613 }
614 }
615}
616
617pub type SampleInputFnType = unsafe extern "C" fn(samples: *const u8, size: usize);
618
619pub type SampleOutputFnType = unsafe extern "C" fn(samples: *const u8, size: usize);
620
621#[repr(C)]
622pub struct DspProcEntry {
623 pub data: isize, // intptr_t in C
624 pub process: Option<extern "C" fn(*mut DspProcEntry, *mut *mut DspBuffer)>,
625}
626
627impl DspProcEntry {
628 pub fn new() -> Self {
629 Self {
630 data: 0,
631 process: None,
632 }
633 }
634}
635
636#[repr(C)]
637pub struct DspProcSlot {
638 pub proc_entry: DspProcEntry, // Adjust the type if necessary
639 pub next: *mut DspProcSlot,
640 pub mask: u32,
641 pub version: u8,
642 pub db_index: u8,
643}
644
645#[repr(C)]
646pub struct SampleIoData {
647 pub outcount: i32,
648 pub format: SampleFormat, // Replace with actual type
649 pub sample_depth: i32,
650 pub stereo_mode: i32,
651 pub input_samples: SampleInputFnType,
652 pub sample_buf: DspBuffer, // Replace with actual type
653 pub sample_buf_p: [*mut i32; 2],
654 pub output_samples: SampleOutputFnType,
655 pub output_sampr: u32,
656 pub format_dirty: u8,
657 pub output_version: u8,
658}
659
660#[repr(C)]
661pub struct DspConfig {
662 pub io_data: SampleIoData, // Adjust the type if necessary
663 pub slot_free_mask: u32,
664 pub proc_mask_enabled: u32,
665 pub proc_mask_active: u32,
666 pub proc_slots: *mut DspProcSlot,
667}
668
669#[repr(C)]
670pub enum PcmMixerChannel {
671 Playback = 0,
672 Voice,
673 NumChannels,
674}
675
676impl PcmMixerChannel {
677 // Optionally, add methods for convenience
678 pub fn as_u32(self) -> u32 {
679 self as u32
680 }
681
682 pub fn from_u32(value: u32) -> Option<Self> {
683 match value {
684 0 => Some(PcmMixerChannel::Playback),
685 1 => Some(PcmMixerChannel::Voice),
686 // Include this if HAVE_HARDWARE_BEEP is not defined
687 // 2 => Some(PcmMixerChannel::Beep),
688 _ => None,
689 }
690 }
691}
692
693#[repr(C)]
694pub enum ChannelStatus {
695 Stopped = 0,
696 Playing,
697 Paused,
698}
699
700impl ChannelStatus {
701 // Optionally, add methods for convenience
702 pub fn as_u32(self) -> u32 {
703 self as u32
704 }
705
706 pub fn from_u32(value: u32) -> Option<Self> {
707 match value {
708 0 => Some(ChannelStatus::Stopped),
709 1 => Some(ChannelStatus::Playing),
710 2 => Some(ChannelStatus::Paused),
711 _ => None,
712 }
713 }
714}
715
716#[repr(C)]
717pub struct PcmPeaks {
718 pub left: u32, // Left peak value
719 pub right: u32, // Right peak value
720 pub period: i64, // For tracking calling period
721 pub tick: i64, // Last tick called
722}
723
724pub type ChanBufferHookFnType = extern "C" fn(start: *const c_void, size: usize);
725
726#[repr(C)]
727pub enum SystemSound {
728 KeyClick = 0,
729 TrackSkip,
730 TrackNoMore,
731 ListEdgeBeepWrap,
732 ListEdgeBeepNoWrap,
733}
734
735#[repr(C)]
736#[derive(Debug, Copy, Clone)]
737pub struct UserSettings {
738 // Audio settings
739 pub balance: c_int,
740 pub bass: c_int,
741 pub treble: c_int,
742 pub channel_config: c_int,
743 pub stereo_width: c_int,
744
745 pub bass_cutoff: c_int,
746 pub treble_cutoff: c_int,
747
748 pub crossfade: c_int,
749 pub crossfade_fade_in_delay: c_int,
750 pub crossfade_fade_out_delay: c_int,
751 pub crossfade_fade_in_duration: c_int,
752 pub crossfade_fade_out_duration: c_int,
753 pub crossfade_fade_out_mixmode: c_int,
754
755 // Replaygain
756 pub replaygain_settings: ReplaygainSettings,
757
758 // Crossfeed
759 pub crossfeed: c_int,
760 pub crossfeed_direct_gain: c_uint,
761 pub crossfeed_cross_gain: c_uint,
762 pub crossfeed_hf_attenuation: c_uint,
763 pub crossfeed_hf_cutoff: c_uint,
764
765 // EQ
766 pub eq_enabled: bool,
767 pub eq_precut: c_uint,
768 pub eq_band_settings: [EqBandSetting; EQ_NUM_BANDS],
769
770 // Misc. swcodec
771 pub beep: c_int,
772 pub keyclick: c_int,
773 pub keyclick_repeats: c_int,
774 pub dithering_enabled: bool,
775 pub timestretch_enabled: bool,
776
777 // Misc options
778 pub list_accel_start_delay: c_int,
779 pub list_accel_wait: c_int,
780
781 pub touchpad_sensitivity: c_int,
782 pub touchpad_deadzone: c_int,
783
784 pub pause_rewind: c_int,
785 pub unplug_mode: c_int,
786 pub unplug_autoresume: bool,
787
788 pub qs_items: [*const SettingsList; QUICKSCREEN_ITEM_COUNT],
789
790 pub timeformat: c_int,
791 pub disk_spindown: c_int,
792 pub buffer_margin: c_int,
793
794 pub dirfilter: c_int,
795 pub show_filename_ext: c_int,
796 pub default_codepage: c_int,
797 pub hold_lr_for_scroll_in_list: bool,
798 pub play_selected: bool,
799 pub single_mode: c_int,
800 pub party_mode: bool,
801 pub cuesheet: bool,
802 pub car_adapter_mode: bool,
803 pub car_adapter_mode_delay: c_int,
804 pub start_in_screen: c_int,
805 pub ff_rewind_min_step: c_int,
806 pub ff_rewind_accel: c_int,
807
808 pub peak_meter_release: c_int,
809 pub peak_meter_hold: c_int,
810 pub peak_meter_clip_hold: c_int,
811 pub peak_meter_dbfs: bool,
812 pub peak_meter_min: c_int,
813 pub peak_meter_max: c_int,
814
815 pub wps_file: [c_uchar; MAX_FILENAME + 1],
816 pub sbs_file: [c_uchar; MAX_FILENAME + 1],
817 pub lang_file: [c_uchar; MAX_FILENAME + 1],
818 pub playlist_catalog_dir: [c_uchar; MAX_PATHNAME + 1],
819 pub skip_length: c_int,
820 pub max_files_in_dir: c_int,
821 pub max_files_in_playlist: c_int,
822 pub volume_type: c_int,
823 pub battery_display: c_int,
824 pub show_icons: bool,
825 pub statusbar: c_int,
826
827 pub scrollbar: c_int,
828 pub scrollbar_width: c_int,
829
830 pub list_line_padding: c_int,
831 pub list_separator_height: c_int,
832 pub list_separator_color: c_int,
833
834 pub browse_current: bool,
835 pub scroll_paginated: bool,
836 pub list_wraparound: bool,
837 pub list_order: c_int,
838 pub scroll_speed: c_int,
839 pub bidir_limit: c_int,
840 pub scroll_delay: c_int,
841 pub scroll_step: c_int,
842
843 pub autoloadbookmark: c_int,
844 pub autocreatebookmark: c_int,
845 pub autoupdatebookmark: bool,
846 pub usemrb: c_int,
847
848 pub dircache: bool,
849 pub tagcache_ram: c_int,
850 pub tagcache_autoupdate: bool,
851 pub autoresume_enable: bool,
852 pub autoresume_automatic: c_int,
853 pub autoresume_paths: [c_uchar; MAX_PATHNAME + 1],
854 pub runtimedb: bool,
855 pub tagcache_scan_paths: [c_uchar; MAX_PATHNAME + 1],
856 pub tagcache_db_path: [c_uchar; MAX_PATHNAME + 1],
857 pub backdrop_file: [c_uchar; MAX_PATHNAME + 1],
858
859 pub bg_color: c_int,
860 pub fg_color: c_int,
861 pub lss_color: c_int,
862 pub lse_color: c_int,
863 pub lst_color: c_int,
864 pub colors_file: [c_uchar; MAX_FILENAME + 1],
865
866 pub browser_default: c_int,
867
868 pub repeat_mode: c_int,
869 pub next_folder: c_int,
870 pub constrain_next_folder: bool,
871 pub recursive_dir_insert: c_int,
872 pub fade_on_stop: bool,
873 pub playlist_shuffle: bool,
874 pub warnon_erase_dynplaylist: bool,
875 pub keep_current_track_on_replace_playlist: bool,
876 pub show_shuffled_adding_options: bool,
877 pub show_queue_options: c_int,
878 pub album_art: c_int,
879 pub rewind_across_tracks: bool,
880
881 pub playlist_viewer_icons: bool,
882 pub playlist_viewer_indices: bool,
883 pub playlist_viewer_track_display: c_int,
884
885 pub talk_menu: bool,
886 pub talk_dir: c_int,
887 pub talk_dir_clip: bool,
888 pub talk_file: c_int,
889 pub talk_file_clip: bool,
890 pub talk_filetype: bool,
891 pub talk_battery_level: bool,
892 pub talk_mixer_amp: c_int,
893
894 pub sort_case: bool,
895 pub sort_dir: c_int,
896 pub sort_file: c_int,
897 pub interpret_numbers: c_int,
898
899 pub poweroff: c_int,
900 pub battery_capacity: c_int,
901 pub battery_type: c_int,
902 pub spdif_enable: bool,
903 pub usb_charging: c_int,
904
905 pub contrast: c_int,
906 pub invert: bool,
907 pub flip_display: bool,
908 pub cursor_style: c_int,
909 pub screen_scroll_step: c_int,
910 pub show_path_in_browser: c_int,
911 pub offset_out_of_view: bool,
912 pub disable_mainmenu_scrolling: bool,
913 pub icon_file: [c_uchar; MAX_FILENAME + 1],
914 pub viewers_icon_file: [c_uchar; MAX_FILENAME + 1],
915 pub font_file: [c_uchar; MAX_FILENAME + 1],
916 pub glyphs_to_cache: c_int,
917 pub kbd_file: [c_uchar; MAX_FILENAME + 1],
918 pub backlight_timeout: c_int,
919 pub caption_backlight: bool,
920 pub bl_filter_first_keypress: bool,
921 pub backlight_timeout_plugged: c_int,
922 pub bt_selective_softlock_actions: bool,
923 pub bt_selective_softlock_actions_mask: c_int,
924 pub bl_selective_actions: bool,
925 pub bl_selective_actions_mask: c_int,
926 pub backlight_on_button_hold: c_int,
927 pub lcd_sleep_after_backlight_off: c_int,
928 pub brightness: c_int,
929
930 pub speaker_mode: c_int,
931 pub prevent_skip: bool,
932
933 pub touch_mode: c_int,
934 pub ts_calibration_data: TouchscreenParameter,
935
936 pub pitch_mode_semitone: bool,
937 pub pitch_mode_timestretch: bool,
938
939 pub usb_hid: bool,
940 pub usb_keypad_mode: c_int,
941
942 pub usb_skip_first_drive: bool,
943
944 pub ui_vp_config: [c_uchar; 64],
945 pub player_name: [c_uchar; 64],
946
947 pub compressor_settings: CompressorSettings,
948
949 pub sleeptimer_duration: c_int,
950 pub sleeptimer_on_startup: bool,
951 pub keypress_restarts_sleeptimer: bool,
952
953 pub show_shutdown_message: bool,
954
955 pub hotkey_wps: c_int,
956 pub hotkey_tree: c_int,
957
958 pub resume_rewind: c_int,
959
960 pub depth_3d: c_int,
961
962 pub roll_off: c_int,
963
964 pub power_mode: c_int,
965
966 pub keyclick_hardware: bool,
967
968 pub start_directory: [c_uchar; MAX_PATHNAME + 1],
969 pub root_menu_customized: bool,
970 pub shortcuts_replaces_qs: bool,
971
972 pub play_frequency: c_int,
973 pub volume_limit: c_int,
974
975 pub volume_adjust_mode: c_int,
976 pub volume_adjust_norm_steps: c_int,
977
978 pub surround_enabled: c_int,
979 pub surround_balance: c_int,
980 pub surround_fx1: c_int,
981 pub surround_fx2: c_int,
982 pub surround_method2: bool,
983 pub surround_mix: c_int,
984
985 pub pbe: c_int,
986 pub pbe_precut: c_int,
987
988 pub afr_enabled: c_int,
989
990 pub governor: c_int,
991 pub stereosw_mode: c_int,
992}
993
994// Define other structs used in UserSettings
995#[repr(C)]
996#[derive(Debug, Copy, Clone)]
997pub struct ReplaygainSettings {
998 pub noclip: bool, // scale to prevent clips
999 pub r#type: c_int, // 0=track gain, 1=album gain, 2=track gain if shuffle is on, album gain otherwise, 4=off
1000 pub preamp: c_int, // scale replaygained tracks by this
1001}
1002
1003#[repr(C)]
1004#[derive(Debug, Copy, Clone)]
1005pub struct EqBandSetting {
1006 pub cutoff: c_int,
1007 pub q: c_int,
1008 pub gain: c_int,
1009}
1010
1011#[repr(C)]
1012#[derive(Debug, Clone, Copy)]
1013pub struct TouchscreenParameter {
1014 pub A: c_int,
1015 pub B: c_int,
1016 pub C: c_int,
1017 pub D: c_int,
1018 pub E: c_int,
1019 pub F: c_int,
1020 pub divider: c_int,
1021}
1022
1023#[repr(C)]
1024#[derive(Debug, Copy, Clone)]
1025pub struct CompressorSettings {
1026 pub threshold: c_int,
1027 pub makeup_gain: c_int,
1028 pub ratio: c_int,
1029 pub knee: c_int,
1030 pub release_time: c_int,
1031 pub attack_time: c_int,
1032}
1033
1034#[repr(C)]
1035#[derive(Debug)]
1036pub struct HwEqBand {
1037 pub gain: c_int,
1038 pub frequency: c_int,
1039 pub width: c_int,
1040}
1041
1042#[repr(C)]
1043#[derive(Debug)]
1044pub struct CbmpBitmapInfoEntry {
1045 pub pbmp: *const c_uchar,
1046 pub width: c_uchar,
1047 pub height: c_uchar, // !ASSUMES MULTIPLES OF 8!
1048 pub count: c_uchar,
1049}
1050
1051#[repr(C)]
1052#[derive(Debug, Clone, Copy)]
1053pub struct SystemStatus {
1054 pub volume: i32,
1055 pub resume_index: i32,
1056 pub resume_crc32: u32,
1057 pub resume_elapsed: u32,
1058 pub resume_offset: u32,
1059 pub runtime: i32,
1060 pub topruntime: i32,
1061 pub dircache_size: i32,
1062 pub last_screen: i8,
1063 pub viewer_icon_count: i32,
1064 pub last_volume_change: i32,
1065 pub font_id: [i32; NB_SCREENS],
1066}
1067
1068extern "C" {
1069 pub static mut global_settings: UserSettings;
1070 pub static global_status: SystemStatus;
1071 pub static language_strings: *mut *mut c_char;
1072 pub static core_bitmaps: CbmpBitmapInfoEntry;
1073
1074 fn get_version() -> *const c_char;
1075
1076 // Playback control
1077 fn audio_pause() -> c_void;
1078 fn audio_play(elapsed: c_long, offset: c_long) -> c_void;
1079 fn audio_resume() -> c_void;
1080 fn audio_next() -> c_void;
1081 fn audio_prev() -> c_void;
1082 fn audio_ff_rewind(newtime: c_int) -> c_void;
1083 fn audio_next_track() -> *mut Mp3Entry;
1084 fn audio_status() -> c_int;
1085 fn audio_current_track() -> *mut Mp3Entry;
1086 fn audio_flush_and_reload_tracks() -> c_void;
1087 fn audio_get_file_pos() -> c_int;
1088 fn audio_hard_stop() -> c_void;
1089
1090 // Playlist control
1091 fn playlist_get_current() -> PlaylistInfo;
1092 fn playlist_get_resume_info(resume_index: *mut c_int) -> c_int;
1093 fn rb_get_track_info_from_current_playlist(index: i32) -> PlaylistTrackInfo;
1094 fn rb_build_playlist(files: *const *const u8, start_index: i32, size: i32) -> i32;
1095 fn rb_playlist_insert_tracks(files: *const *const u8, position: i32, size: i32) -> i32;
1096 fn rb_playlist_insert_track(filename: *const u8, position: i32, queue: bool, sync: bool)
1097 -> i32;
1098 fn rb_playlist_delete_track(index: i32) -> i32;
1099 fn rb_playlist_insert_directory(
1100 dir: *const c_char,
1101 position: i32,
1102 queue: bool,
1103 recurse: bool,
1104 ) -> i32;
1105 fn rb_playlist_remove_all_tracks() -> c_int;
1106 fn playlist_get_first_index(playlist: *mut PlaylistInfo) -> c_int;
1107 fn playlist_get_display_index() -> c_int;
1108 fn playlist_amount() -> c_int;
1109 fn playlist_resume() -> c_int;
1110 fn playlist_resume_track(start_index: c_int, crc: c_uint, elapsed: c_ulong, offset: c_ulong);
1111 fn playlist_set_modified(playlist: *mut PlaylistInfo, modified: c_uchar);
1112 fn playlist_start(start_index: c_int, elapsed: c_ulong, offset: c_ulong);
1113 fn playlist_sync(playlist: *mut PlaylistInfo);
1114 fn playlist_create(dir: *const c_char, file: *const c_char) -> c_int;
1115 fn playlist_shuffle(random_seed: c_int, start_index: c_int) -> c_int;
1116 fn playlist_randomise_current(seed: c_uint, start_current: c_uchar) -> c_int;
1117 fn playlist_sort_current(start_current: c_uchar) -> c_int;
1118 fn rb_playlist_index() -> i32;
1119 fn rb_playlist_first_index() -> i32;
1120 fn rb_playlist_last_insert_pos() -> i32;
1121 fn rb_playlist_seed() -> i32;
1122 fn rb_playlist_last_shuffled_start() -> i32;
1123 fn rb_max_playlist_size() -> i32;
1124 fn warn_on_pl_erase() -> c_uchar;
1125
1126 // Sound
1127 fn adjust_volume(steps: c_int);
1128 fn sound_set(setting: c_int, value: c_int);
1129 fn sound_current(setting: c_int) -> c_int;
1130 fn sound_default(setting: c_int) -> c_int;
1131 fn sound_min(setting: c_int) -> c_int;
1132 fn sound_max(setting: c_int) -> c_int;
1133 fn sound_unit(setting: c_int) -> *const c_char;
1134 fn sound_val2phys(setting: c_int, value: c_int) -> c_int;
1135 fn sound_get_pitch() -> c_int;
1136 fn sound_set_pitch(pitch: c_int);
1137 fn pcm_apply_settings();
1138 fn pcm_play_data(
1139 get_more: PcmPlayCallbackType,
1140 status_cb: PcmStatusCallbackType,
1141 start: *const *const c_void,
1142 size: usize,
1143 );
1144 fn pcm_play_stop();
1145 fn pcm_set_frequency(frequency: c_uint);
1146 fn pcm_is_playing() -> c_uchar;
1147 fn pcm_play_lock();
1148 fn pcm_play_unlock();
1149 fn beep_play(frequency: c_uint, duration: c_uint, amplitude: c_uint);
1150 fn dsp_set_crossfeed_type(r#type: c_int);
1151 fn dsp_eq_enable(enable: c_uchar);
1152 fn dsp_dither_enable(enable: c_uchar);
1153 fn dsp_get_timestretch() -> c_int;
1154 fn dsp_set_timestretch(percent: c_int);
1155 fn dsp_timestretch_enable(enabled: c_uchar);
1156 fn dsp_timestretch_available() -> c_uchar;
1157 fn dsp_configure(dsp: *mut DspConfig, setting: c_uint, value: c_long) -> c_long;
1158 fn dsp_get_config(dsp_id: c_int) -> DspConfig;
1159 fn dsp_process(dsp: *mut DspConfig, src: *mut DspBuffer, dst: *mut *mut DspBuffer);
1160 fn mixer_channel_status(channel: PcmMixerChannel) -> ChannelStatus;
1161 fn mixer_channel_get_buffer(channel: PcmMixerChannel, count: *mut c_int) -> *mut c_void;
1162 fn mixer_channel_calculate_peaks(channel: PcmMixerChannel, peaks: *mut PcmPeaks);
1163 fn mixer_channel_play_data(
1164 channel: PcmMixerChannel,
1165 get_more: PcmPlayCallbackType,
1166 start: *const *const c_void,
1167 size: usize,
1168 );
1169 fn mixer_channel_play_pause(channel: PcmMixerChannel, play: c_uchar);
1170 fn mixer_channel_stop(channel: PcmMixerChannel);
1171 fn mixer_channel_set_amplitude(channel: PcmMixerChannel, amplitude: c_uint);
1172 fn mixer_channel_get_bytes_waiting(channel: PcmMixerChannel) -> usize;
1173 fn mixer_channel_set_buffer_hook(channel: PcmMixerChannel, r#fn: ChanBufferHookFnType);
1174 fn mixer_set_frequency(samplerate: c_uint);
1175 fn mixer_get_frequency() -> c_uint;
1176 fn pcmbuf_fade(fade: c_int, r#in: c_uchar);
1177 fn pcmbuf_set_low_latency(state: c_uchar);
1178 fn system_sound_play(sound: SystemSound);
1179 fn keyclick_click(rawbutton: c_uchar, action: c_int);
1180 fn audio_set_crossfade(crossfade: c_int);
1181
1182 // Browsing
1183 fn rockbox_browse_at(path: *const c_char) -> c_int;
1184 fn rb_rockbox_browse() -> c_int;
1185 fn rb_tree_get_context() -> TreeContext;
1186 fn rb_tree_get_entries() -> Entry;
1187 fn rb_tree_get_entry_at(index: c_int) -> Entry;
1188 fn set_current_file(path: *const c_char);
1189 fn set_dirfilter(l_dirfilter: c_int);
1190 fn onplay_show_playlist_menu(
1191 path: *const c_char, // const char* path
1192 attr: c_int, // int attr
1193 playlist_insert_cb: PlaylistInsertCb, // void (*playlist_insert_cb)()
1194 );
1195 fn onplay_show_playlist_cat_menu(
1196 track_name: *const c_char,
1197 attr: c_int,
1198 add_to_pl_cb: AddToPlCallback,
1199 );
1200 fn browse_id3(
1201 id3: *mut Mp3Entry,
1202 playlist_display_index: c_int,
1203 playlist_amount: c_int,
1204 modified: *mut Tm,
1205 track_ct: c_int,
1206 ) -> c_uchar;
1207
1208 // Directory
1209 fn opendir(dirname: *const c_char) -> Dir;
1210 fn closedir(dirp: *mut Dir) -> c_int;
1211 fn readdir(dirp: *mut Dir) -> dirent;
1212 fn mkdir(path: *const c_char) -> c_int;
1213 fn rmdir(path: *const c_char) -> c_int;
1214 fn dir_get_info(dirp: *mut Dir, entry: *mut dirent) -> Dirent;
1215
1216 // File
1217 fn open_utf8();
1218 fn open();
1219 fn creat();
1220 fn close();
1221 fn read();
1222 fn lseek();
1223 fn write();
1224 fn remove();
1225 fn rename();
1226 fn ftruncate();
1227 fn fdprintf();
1228 fn read_line();
1229 fn settings_parseline();
1230 fn reload_directory();
1231 fn create_numbered_filename();
1232 fn strip_extension();
1233 fn crc_32();
1234 fn crc_32r();
1235 fn filetype_get_attr();
1236 fn filetype_get_plugin();
1237
1238 // Metadata
1239 fn rb_get_metadata(fd: i32, trackname: *const c_char) -> Mp3Entry;
1240 fn get_codec_string(codectype: c_int) -> *const c_char;
1241 fn count_mp3_frames(
1242 fd: c_int,
1243 startpos: c_int,
1244 filesize: c_int,
1245 progressfunc: ProgressFunc,
1246 buf: *mut c_uchar,
1247 buflen: usize,
1248 ) -> c_int;
1249 fn create_xing_header(
1250 fd: c_int,
1251 startpos: c_long,
1252 filesize: c_long,
1253 buf: *mut c_uchar,
1254 num_frames: c_ulong,
1255 rec_time: c_ulong,
1256 header_template: c_ulong,
1257 progressfunc: ProgressFunc,
1258 generate_toc: c_uchar,
1259 tempbuf: *mut c_uchar,
1260 tembuf_len: usize,
1261 ) -> c_int;
1262 fn tagcache_search(tcs: *mut TagcacheSearch, tag: c_int) -> c_uchar;
1263 fn tagcache_search_set_uniqbuf(tcs: *mut TagcacheSearch, buffer: *mut c_void, length: c_long);
1264 fn tagcache_search_add_filter(tcs: *mut TagcacheSearch, tag: c_int, seek: c_int) -> c_uchar;
1265 fn tagcache_get_next(tcs: *mut TagcacheSearch, buf: *mut c_char, size: c_long) -> c_uchar;
1266 // fn tagcahe_retrieve(tcs: *mut TagcacheSearch, idxid: c_int, tag: c_int) -> c_uchar;
1267 // fn tagcache_search_finish(tcs: *mut TagcacheSearch);
1268 fn tagcache_get_numeric(tcs: *mut TagcacheSearch, tag: c_int) -> c_long;
1269 fn tagcache_get_stat() -> TagcacheStat;
1270 fn tagcache_commit_finalize();
1271 fn tagtree_subentries_do_action(cb: ActionCb) -> c_uchar;
1272 fn search_albumart_files(
1273 id3: *mut Mp3Entry,
1274 size_string: *const c_char,
1275 buf: *mut c_char,
1276 buflen: c_int,
1277 ) -> c_uchar;
1278
1279 // Kernel / System
1280 fn sleep(ticks: c_int);
1281 fn r#yield();
1282 pub static mut current_tick: std::ffi::c_long;
1283 fn default_event_handler(event: c_long);
1284 fn create_thread();
1285 fn thread_self();
1286 fn thread_exit();
1287 fn thread_wait();
1288 fn thread_thaw();
1289 fn thread_set_priority(thread_id: c_uint, priority: c_int);
1290 fn mutex_init();
1291 fn mutex_lock();
1292 fn mutex_unlock();
1293 fn semaphore_init();
1294 fn semaphore_wait();
1295 fn semaphore_release();
1296 fn reset_poweroff_timer();
1297 fn set_sleeptimer_duration(minutes: c_int);
1298 fn get_sleep_timer();
1299
1300 // Menu
1301 fn root_menu_get_options();
1302 fn do_menu();
1303 fn root_menu_set_default();
1304 fn root_menu_write_to_cfg();
1305 fn root_menu_load_from_cfg();
1306
1307 // Settings
1308 fn get_settings_list(count: *mut c_int) -> SettingsList;
1309 fn find_setting(variable: *const c_void) -> SettingsList;
1310 fn settings_save() -> c_int;
1311 fn settings_apply(read_disk: c_uchar);
1312 fn audio_settings_apply();
1313 fn option_screen(
1314 setting: *mut SettingsList,
1315 parent: [Viewport; NB_SCREENS],
1316 use_temp_var: c_uchar,
1317 option_title: *mut c_uchar,
1318 ) -> c_uchar;
1319 fn set_option(
1320 string: *const c_char,
1321 options: *const OptItems,
1322 numoptions: c_int,
1323 function: Option<extern "C" fn(x: c_int) -> c_uchar>,
1324 ) -> c_uchar;
1325 fn set_bool_options(
1326 string: *const c_char,
1327 variable: *const c_uchar,
1328 yes_str: *const c_char,
1329 yes_voice: c_int,
1330 no_str: *const c_char,
1331 no_voice: c_int,
1332 function: Option<extern "C" fn(x: c_int) -> c_uchar>,
1333 );
1334 fn set_int(
1335 unit: *const c_char,
1336 voice_unit: c_int,
1337 variable: *const c_int,
1338 function: Option<extern "C" fn(c_int)>,
1339 step: c_int,
1340 min: c_int,
1341 max: c_int,
1342 formatter: Option<extern "C" fn(*mut c_char, usize, c_int, *const c_char) -> *const c_char>,
1343 );
1344 fn set_int_ex(
1345 unit: *const c_char,
1346 voice_unit: c_int,
1347 variable: *const c_int,
1348 function: Option<extern "C" fn(c_int)>,
1349 step: c_int,
1350 min: c_int,
1351 max: c_int,
1352 formatter: Option<extern "C" fn(*mut c_char, usize, c_int, *const c_char) -> *const c_char>,
1353 get_talk_id: Option<extern "C" fn(c_int, c_int) -> c_int>,
1354 );
1355 fn set_bool(string: *const c_char, variable: *const c_uchar) -> c_uchar;
1356 fn rb_get_crossfade_mode() -> i32;
1357 fn set_repeat_mode(mode: c_int);
1358
1359 // Misc
1360 fn codec_load_file();
1361 fn codec_run_proc();
1362 fn codec_close();
1363 fn read_bmp_file();
1364 fn read_bmp_fd();
1365 fn read_jpeg_file();
1366 fn read_jpeg_fd();
1367
1368 // Plugin
1369 fn plugin_open();
1370 fn plugin_get_buffer();
1371 fn plugin_get_current_filename();
1372 fn plugin_reserve_buffer();
1373}