mirror of
https://github.com/Boof2015/astra-mobile.git
synced 2026-08-16 16:21:21 +02:00
fix android auto quirks
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user