Wait for shared Android stream output release before starting calls
This commit is contained in:
1 parent
c98fdc6297
commit
b3ebc09b9b
2 files changed
+14
-1
No files matched your search
@@ -24,6 +24,16 @@ internal object StreamAudioMixer {
|
||||
LogManager.addLog("INFO", "stream", "mixer input detached id=${input.id} count=${inputs.size}")
|
||||
}
|
||||
|
||||
/** После join всех viewers, вне main thread; запуск новых viewers блокирует CallController. */
|
||||
fun awaitIdle() {
|
||||
val closing = synchronized(lock) {
|
||||
check(inputs.isEmpty()) { "Stream mixer still has ${inputs.size} inputs after viewer release" }
|
||||
worker
|
||||
}
|
||||
closing?.join()
|
||||
LogManager.addLog("INFO", "stream", "shared audio output released for call")
|
||||
}
|
||||
|
||||
private fun run() {
|
||||
val audio = StreamAudioOutput(log = { LogManager.addLog("INFO", "stream", "mixer $it") })
|
||||
val mix = StreamMixBuffer()
|
||||
|
||||
@@ -33,7 +33,10 @@ class StreamPlayerEngine(private val group: Long, private val source: Long, priv
|
||||
player.mutableStatus.value = R.string.stream_ended
|
||||
player.stop()
|
||||
}
|
||||
withContext(Dispatchers.IO) { for (player in stopped) player.worker?.join() }
|
||||
withContext(Dispatchers.IO) {
|
||||
for (player in stopped) player.worker?.join()
|
||||
StreamAudioMixer.awaitIdle()
|
||||
}
|
||||
players.removeAll(stopped.toSet())
|
||||
mutableViewing.value = players.isNotEmpty()
|
||||
LogManager.addLog("INFO", "stream", "viewers released for call count=${stopped.size}")
|
||||
|
||||
Reference in new issue
Block a user