Serialize stream capture preferences with other saved media profiles

This commit is contained in:
evgeny committed 2026-10-28 12:08:07 +01:00
1 parent 7ed8f90068
commit 917a2a2b28
2 files changed
+5 -5

No files matched your search

@@ -279,14 +279,14 @@ class ConfigProvider(private val context: Context) {
LogManager.addLog("INFO", "STREAM", "Broadcast settings saved n=$subblocks r=$redundant; apply on next start")
}
suspend fun getStreamCaptureSettings(): StreamCaptureSettings {
suspend fun getStreamCaptureSettings(): StreamCaptureSettings = configFiles.submit("load stream capture") {
val prefs = context.dataStore.data.first()
return StreamCaptureSettings(prefs[streamCamera] ?: "", prefs[streamWidth] ?: 1280, prefs[streamHeight] ?: 720,
StreamCaptureSettings(prefs[streamCamera] ?: "", prefs[streamWidth] ?: 1280, prefs[streamHeight] ?: 720,
prefs[streamFps] ?: 30, prefs[streamCodec] ?: StreamVideoCodec.H264.id, prefs[streamRotation] ?: StreamOrientation.AUTO.degrees,
prefs[streamBitrate], prefs[streamAudio] ?: true)
}
}.await()
suspend fun saveStreamCaptureSettings(config: StreamCaptureConfig?, audio: Boolean?) {
fun saveStreamCaptureSettings(config: StreamCaptureConfig?, audio: Boolean?): Deferred<Unit> = configFiles.submit("save stream capture") {
context.dataStore.edit { prefs ->
config?.let {
prefs[streamCamera] = it.mode.camera
@@ -45,7 +45,7 @@ object StreamController {
/** Запись переживает закрытие экрана; DataStore сохраняет выбор одним изменением. */
fun rememberSettings(config: StreamCaptureConfig? = null, audio: Boolean? = null) {
settingsScope.launch {
try { ChatApplication.instance.configProvider.saveStreamCaptureSettings(config, audio) }
try { ChatApplication.instance.configProvider.saveStreamCaptureSettings(config, audio).await() }
catch (e: CancellationException) { throw e }
catch (e: Exception) { LogManager.addLog("ERROR", "stream", "capture settings save failed: $e") }
}