Refactor OGG-FLAC streaming to support multi-client broadcast
Migrate from single-client direct OGG-FLAC sink to multi-client broadcast streaming sink. - Replace DirectOggFlacHandle with OggFlacStreamHandle for multi-client support - Update sink implementation to use StreamingOggFlacSink with proper backpressure - Change connection model from 'connect()' to 'subscribe()' - Adjust stream handling to support independent client streams - Update stream endpoint to always respond with 200 chunked instead of range requests - Add tracing for stream lifecycle events - Reduce OGG channel capacity to strict backpressure (1) - Add Drop implementation for stream cleanup - Improve logging and error handling for concurrent access This change enables multiple simultaneous clients to connect to the same audio stream without interfering with each other, while maintaining proper TCP backpressure and stream lifecycle management.
This commit is contained in:
@@ -29,8 +29,8 @@ pub struct WebRendererInstance {
|
||||
pub udn: String,
|
||||
pub device_instance: Arc<DeviceInstance>,
|
||||
pub state: SharedState,
|
||||
/// Handle vers le sink OGG-FLAC — clonable, connect() crée un nouveau flux avec backpressure.
|
||||
pub flac_handle: pmoaudio_ext::sinks::DirectOggFlacHandle,
|
||||
/// Handle vers le sink OGG-FLAC — clonable, subscribe() crée un flux indépendant par client.
|
||||
pub flac_handle: pmoaudio_ext::sinks::OggFlacStreamHandle,
|
||||
pub pipeline: PipelineHandle,
|
||||
pub created_at: SystemTime,
|
||||
}
|
||||
@@ -116,16 +116,16 @@ impl RendererRegistry {
|
||||
Ok((stream_url, udn))
|
||||
}
|
||||
|
||||
/// Retourne un DirectOggFlacStream pour l'endpoint /stream.
|
||||
/// Chaque appel retourne un wrapper sur le même reader persistant.
|
||||
/// Retourne un OggFlacClientStream indépendant pour l'endpoint /stream.
|
||||
/// Chaque appel crée un nouveau subscriber broadcast — safe pour connexions simultanées.
|
||||
pub fn get_stream(
|
||||
&self,
|
||||
instance_id: &str,
|
||||
) -> Option<pmoaudio_ext::sinks::DirectOggFlacStream> {
|
||||
) -> Option<pmoaudio_ext::sinks::OggFlacClientStream> {
|
||||
self.instances
|
||||
.read()
|
||||
.get(instance_id)
|
||||
.map(|i| i.flac_handle.get_stream())
|
||||
.map(|i| i.flac_handle.subscribe())
|
||||
}
|
||||
|
||||
/// Retourne le PipelineHandle par UDN (pour les handlers UPnP)
|
||||
|
||||
Reference in New Issue
Block a user