Expose publisher service boundaries to the existing lifecycle harness

This commit is contained in:
evgeny committed 2026-10-29 13:34:24 +01:00
1 parent e49ccfeb64
commit 1beb19a7f8
3 files changed
+16 -2

No files matched your search

@@ -104,8 +104,6 @@ class RadioAudioEngine {
fun stopForCall(): Future<*> { activeGroup.value = null; return CompletableFuture.completedFuture(Unit) }
fun restoreAfterCall(group: Long) { restored.add(group); activeGroup.value = group }
}
data class HostMediaState(val ongoing: Boolean)
object StreamController { val state = MutableStateFlow<HostMediaState?>(null); fun stopForCall() { state.value = null } }
object StreamPlayerEngine { val viewing = MutableStateFlow(false); fun stopForCall() { viewing.value = false } }
object MediaAudioController { var beforeIdle: () -> Unit = {}; fun awaitIdle() { beforeIdle() } }
enum class MediaAudioProfile { AUTO, PHONE, WIRED, BLUETOOTH }
@@ -33,5 +33,7 @@ object R {
const val call_incoming_stop_stream = 148; const val call_outgoing_stop_stream = 149
const val files_preparing = 201; const val files_transferring = 202; const val files_completed = 203
const val files_cancelled = 204; const val files_failed = 205; const val files_replace_title = 206; const val files_saving = 207
const val stream_resources_busy = 301; const val stream_failed = 302; const val stream_mode_restored = 303
const val stream_title = 304; const val stream_live = 305; const val stream_stop = 306
}
}
@@ -169,6 +169,15 @@ object NativeLib {
var acceptPhoneRequest = true
fun notifyNetworkActive() { networkNotifications.incrementAndGet() }
fun isReady(): Boolean = ready
var streamFailures = emptySet<String>()
val streamStops = mutableListOf<Long>()
val streamEvents = ConcurrentLinkedQueue<ByteArray>()
var streamStats: LongArray? = null
var voiceActive = false
fun voiceIsActive() = voiceActive
fun streamTxStats(id: Long): LongArray? { check("stats" !in streamFailures); return streamStats }
fun streamPull(id: Long): ByteArray? { check("pull" !in streamFailures); return streamEvents.poll() }
fun streamStop(id: Long) { check("stop" !in streamFailures); streamStops.add(id) }
fun setPhoneState(state: Int, policy: Int): Boolean {
phoneRequests.add(state to policy)
return acceptPhoneRequest
@@ -185,6 +194,11 @@ object NativeLib {
/** Управляемая подготовка конфига: тест удерживает реальный worker, считает перекрытия и затем дожидается его завершения. */
class HostConfigProvider {
val radioCompressorSettings = MutableStateFlow(Any())
var failStreamSave = false
fun saveStreamCaptureSettings(config: Any?, audio: Boolean?): Deferred<Unit> = CompletableDeferred<Unit>().also {
if (failStreamSave) it.completeExceptionally(IllegalStateException("stream settings save failed")) else it.complete(Unit)
}
var callRoute = AudioRoute.EARPIECE
fun getCallAudioRoute() = callRoute
suspend fun setCallAudioRoute(route: AudioRoute) { callRoute = route }