diff --git a/android/app/src/main/java/com/fabledsword/minstrel/player/output/ActiveUpnpHolder.kt b/android/app/src/main/java/com/fabledsword/minstrel/player/output/ActiveUpnpHolder.kt new file mode 100644 index 00000000..c92201c6 --- /dev/null +++ b/android/app/src/main/java/com/fabledsword/minstrel/player/output/ActiveUpnpHolder.kt @@ -0,0 +1,29 @@ +package com.fabledsword.minstrel.player.output + +import com.fabledsword.minstrel.player.output.upnp.AVTransportClient +import com.fabledsword.minstrel.player.output.upnp.RenderingControlClient +import kotlinx.coroutines.flow.MutableStateFlow +import kotlinx.coroutines.flow.StateFlow +import kotlinx.coroutines.flow.asStateFlow +import javax.inject.Inject +import javax.inject.Singleton + +/** + * Shared singleton handle to the currently-active UPnP route's transport + * + rendering clients. Decouples [com.fabledsword.minstrel.player.MinstrelForwardingPlayer] + * from [OutputPickerController] -- the picker writes; the forwarding + * player reads. Null = no UPnP active (local ExoPlayer path). + */ +data class ActiveUpnp( + val routeId: String, + val routeName: String, + val avTransport: AVTransportClient, + val rendering: RenderingControlClient?, +) + +@Singleton +class ActiveUpnpHolder @Inject constructor() { + private val internal = MutableStateFlow(null) + val active: StateFlow = internal.asStateFlow() + fun set(active: ActiveUpnp?) { internal.value = active } +}