Verify orphan routing listener cleanup and independent route release
This commit is contained in:
1 parent
9b6f6e5295
commit
c77d6fb059
2 files changed
+25
-4
No files matched your search
@@ -180,9 +180,11 @@ internal open class MediaAudioSession(private val io: ScheduledExecutorService =
|
||||
checkBlockingCaller()
|
||||
io.submit {
|
||||
if (outputs[track] !== registration && pendingOutputs[track] !== registration) return@submit
|
||||
detachOutput(track, registration)
|
||||
var failure: Exception? = null
|
||||
try { detachOutput(track, registration) } catch (e: Exception) { failure = e }
|
||||
try { reconcile() }
|
||||
catch (e: Exception) { recover(e) }
|
||||
failure?.let { throw it }
|
||||
LogManager.addLog("INFO", "media_audio", "output detached session=${registration.session} count=${outputs.size}")
|
||||
}.get()
|
||||
}
|
||||
|
||||
+22
-3
@@ -196,8 +196,10 @@ class MediaAudioSessionTest {
|
||||
val error = assertThrows(IllegalStateException::class.java) { background { owner.attachOutput(output) } }
|
||||
assertTrue(error.message!!.contains("add listener after"))
|
||||
diagnostic("output listener cleanup failed"); diagnostic("output registration failed")
|
||||
assertEquals(1, output.listeners.size)
|
||||
assertThrows(IllegalStateException::class.java) { background { owner.awaitIdle() } }
|
||||
output.failures = emptySet()
|
||||
output.history.forEach { output.removeOnRoutingChangedListener(it) }
|
||||
clock.fire(); drain(); assertTrue(output.listeners.isEmpty())
|
||||
background { owner.awaitIdle() }
|
||||
}
|
||||
|
||||
@@ -205,12 +207,29 @@ class MediaAudioSessionTest {
|
||||
start(); val one = track(); val two = track()
|
||||
val first = attach(one); attach(two)
|
||||
one.failures = setOf("remove listener")
|
||||
background { first.close() }
|
||||
assertThrows(IllegalStateException::class.java) { background { first.close() } }
|
||||
assertEquals(1, two.listeners.size)
|
||||
one.failures = emptySet(); one.history.forEach { one.removeOnRoutingChangedListener(it) }
|
||||
assertEquals(1, one.listeners.size)
|
||||
one.failures = emptySet(); background { first.close() }; assertTrue(one.listeners.isEmpty())
|
||||
diagnostic("output listener removal failed")
|
||||
}
|
||||
|
||||
@Test fun failedRegistrationListenerCleanupRemainsSafeAfterTheCallerReleasesItsTrack() {
|
||||
start(); val output = track().apply { failures = setOf("add listener after", "remove listener") }
|
||||
assertThrows(IllegalStateException::class.java) { background { owner.attachOutput(output) } }
|
||||
output.released = true; output.deliver(0); drain(); assertEquals(0, output.accessAfterRelease)
|
||||
output.failures = emptySet(); clock.fire(); drain(); assertTrue(output.listeners.isEmpty())
|
||||
background { owner.awaitIdle() }
|
||||
}
|
||||
|
||||
@Test fun removalFailureAfterEffectStillNeedsAnAcknowledgedRetry() {
|
||||
start(); val output = track(); val lease = attach(output); output.failures = setOf("remove listener after")
|
||||
assertThrows(IllegalStateException::class.java) { background { lease.close() } }
|
||||
assertTrue(output.listeners.isEmpty())
|
||||
assertThrows(IllegalStateException::class.java) { background { owner.close() } }
|
||||
output.failures = emptySet(); background { lease.close() }; background { owner.close() }
|
||||
}
|
||||
|
||||
@Test fun preferenceWriteFailureDoesNotCommitUnsavedSelection() {
|
||||
start()
|
||||
select(MediaAudioProfile.PHONE)
|
||||
|
||||
Reference in new issue
Block a user