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:
@@ -157,6 +157,44 @@ pub fn get_audio_cache() -> Option<Arc<AudioCache>> {
|
||||
CACHE_REGISTRY.read().unwrap().audio_cache()
|
||||
}
|
||||
|
||||
/// Enregistre le cache audio global
|
||||
///
|
||||
/// Cette fonction doit être appelée au démarrage de l'application
|
||||
/// pour rendre le cache audio disponible globalement.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```rust,ignore
|
||||
/// use pmoupnp::cache_registry::register_audio_cache;
|
||||
/// use pmoaudiocache::Cache as AudioCache;
|
||||
/// use std::sync::Arc;
|
||||
///
|
||||
/// let audio_cache = Arc::new(AudioCache::new("./cache", 1000)?);
|
||||
/// register_audio_cache(audio_cache);
|
||||
/// ```
|
||||
pub fn register_audio_cache(cache: Arc<AudioCache>) {
|
||||
CACHE_REGISTRY.write().unwrap().set_audio_cache(cache);
|
||||
}
|
||||
|
||||
/// Enregistre le cache de couvertures global
|
||||
///
|
||||
/// Cette fonction doit être appelée au démarrage de l'application
|
||||
/// pour rendre le cache de couvertures disponible globalement.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```rust,ignore
|
||||
/// use pmoupnp::cache_registry::register_cover_cache;
|
||||
/// use pmocovers::Cache as CoverCache;
|
||||
/// use std::sync::Arc;
|
||||
///
|
||||
/// let cover_cache = Arc::new(CoverCache::new("./covers", 100)?);
|
||||
/// register_cover_cache(cover_cache);
|
||||
/// ```
|
||||
pub fn register_cover_cache(cache: Arc<CoverCache>) {
|
||||
CACHE_REGISTRY.write().unwrap().set_cover_cache(cache);
|
||||
}
|
||||
|
||||
/// Construit l'URL complète pour une couverture
|
||||
///
|
||||
/// Fonction globale qui utilise le registre de caches pour construire l'URL.
|
||||
|
||||
@@ -16,7 +16,9 @@ pub mod variable_types;
|
||||
use std::sync::RwLock;
|
||||
use std::{collections::HashMap, sync::Arc};
|
||||
|
||||
pub use crate::cache_registry::{get_audio_cache, get_cover_cache};
|
||||
pub use crate::cache_registry::{
|
||||
get_audio_cache, get_cover_cache, register_audio_cache, register_cover_cache,
|
||||
};
|
||||
pub use crate::object_trait::*;
|
||||
pub use crate::upnp_server::UpnpServerExt;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user