fix android auto quirks

This commit is contained in:
Boof2015
2026-07-13 23:04:28 -04:00
parent 3ac75432a4
commit a8c1f4fd22
22 changed files with 897 additions and 27 deletions
+4
View File
@@ -33,3 +33,7 @@ android {
abortOnError false
}
}
dependencies {
testImplementation 'junit:junit:4.13.2'
}
@@ -79,6 +79,12 @@ class AstraScopeModule : Module() {
GainBridge.activateSmoothFor(url)
}
// Hard-prime while paused; unlike activateTrackGain this must not spend the
// first audible second gliding down from the process default (unity).
Function("primeTrackGain") { url: String ->
GainBridge.primeFor(url)
}
// Conservative temp gain applied when a transition hits an unregistered URL
// (unanalyzed track). JS keeps this at 1 while normalization is disabled.
Function("setFallbackGain") { linear: Double ->
@@ -89,6 +89,15 @@ object GainBridge {
setTarget(gains[url] ?: fallbackGain, CORRECTION_RAMP_MS)
}
/**
* Prime a paused player before play is released. There is no live signal to
* declick here, so publishing a zero-duration target guarantees the first
* processed frame is already at the requested gain.
*/
fun primeFor(url: String) {
setTarget(gains[url] ?: fallbackGain, 0)
}
/** Glide to an explicit gain (unity paths: no track / remote track / disabled). */
fun setGainSmooth(linear: Float) {
setTarget(linear, CORRECTION_RAMP_MS)
@@ -0,0 +1,26 @@
package expo.modules.astrascope
import org.junit.Assert.assertEquals
import org.junit.Test
class GainBridgeTest {
@Test
fun pausedPrimePublishesTargetWithoutCorrectionRamp() {
GainBridge.putGain("test-track", 0.25f)
GainBridge.primeFor("test-track")
assertEquals(0.25f, GainBridge.targetGain, 0.0001f)
assertEquals(0, GainBridge.rampMs)
}
@Test
fun pausedPrimeUsesFallbackForUnanalyzedTrack() {
GainBridge.fallbackGain = 0.5f
GainBridge.primeFor("missing-track")
assertEquals(0.5f, GainBridge.targetGain, 0.0001f)
assertEquals(0, GainBridge.rampMs)
}
}