Add register_audio_cache/register_cover_cache functions to pmoupnp

Fix "PlaylistManager not initialized" error in play_and_cache example.
The error occurred because pmoplaylist's WriteHandle calls
pmoupnp::get_audio_cache() to validate cache pks, but the global
cache registry wasn't initialized.

Changes:
- Add register_audio_cache() and register_cover_cache() functions
- Export them from pmoupnp lib.rs
- Call them in play_and_cache example after creating caches

This mirrors how UpnpServer initializes the cache registry.
This commit is contained in:
Claude
2025-11-05 19:49:59 +00:00
parent a0b6463273
commit 123bac1fdf
3 changed files with 47 additions and 1 deletions

View File

@@ -100,6 +100,12 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
)?);
tracing::debug!("Cover cache initialized at: {}", cover_cache_dir);
// Enregistrer les caches dans le registre global pmoupnp
// (requis par pmoplaylist pour valider les pks)
pmoupnp::register_audio_cache(audio_cache.clone());
pmoupnp::register_cover_cache(cover_cache.clone());
tracing::debug!("Caches registered in pmoupnp global registry");
// Utiliser le gestionnaire de playlist singleton
tracing::info!("Getting playlist manager...");
let playlist_manager = pmoplaylist::PlaylistManager();