Rockbox open source high quality audio player as a Music Player Daemon
mpris rockbox mpd libadwaita audio rust zig deno
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

Implement save_remote_track_metadata for cdylib (port from crates/cli)

Real impl spawns a tokio runtime, opens the library DB pool, and calls rockbox_library::audio_scan::save_audio_metadata to index the remote URL's metadata. Identical to crates/cli's version (which we can't depend on because of host-only assumptions: SIGTERM dance, getenv(HOME) panic, prctl).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

+39
+39
crates/expo/src/daemon.rs
··· 78 78 static _KEEPALIVE_UPNP: extern "C" fn(u16) = 79 79 rockbox_upnp::pcm_upnp_set_http_port; 80 80 81 + /// `save_remote_track_metadata` — port of crates/cli's identical function 82 + /// (we don't depend on rockbox-cli because of its host-only assumptions: 83 + /// SIGTERM dance, getenv("HOME") panic, prctl). crates/server calls this 84 + /// for HTTP-streamed tracks to index their metadata into the library DB. 85 + #[no_mangle] 86 + pub extern "C" fn save_remote_track_metadata(url: *const c_char) -> i32 { 87 + if url.is_null() { 88 + tracing::warn!("save_remote_track_metadata: null url"); 89 + return -1; 90 + } 91 + let url = unsafe { std::ffi::CStr::from_ptr(url) }; 92 + let url = match url.to_str() { 93 + Ok(s) => s, 94 + Err(e) => { 95 + tracing::warn!("save_remote_track_metadata: invalid utf-8: {}", e); 96 + return -1; 97 + } 98 + }; 99 + 100 + let rt = match tokio::runtime::Runtime::new() { 101 + Ok(rt) => rt, 102 + Err(e) => { 103 + tracing::error!("save_remote_track_metadata: failed to create runtime: {}", e); 104 + return -1; 105 + } 106 + }; 107 + 108 + match rt.block_on(async { 109 + let pool = rockbox_library::create_connection_pool().await?; 110 + rockbox_library::audio_scan::save_audio_metadata(pool, url, None).await 111 + }) { 112 + Ok(()) => 0, 113 + Err(e) => { 114 + tracing::error!("save_remote_track_metadata: {}", e); 115 + -1 116 + } 117 + } 118 + } 119 + 81 120 /// Same keepalive trick for the netstream Rust crate's C-ABI exports — 82 121 /// the C firmware's streamfd.c calls rb_net_open / rb_net_read / etc., but 83 122 /// rustc dead-code-strips them from the cdylib link unless we reference