diff --git a/android/app/build.gradle.kts b/android/app/build.gradle.kts index b9c831c3..387c1079 100644 --- a/android/app/build.gradle.kts +++ b/android/app/build.gradle.kts @@ -9,8 +9,8 @@ android { applicationId = "tv.orbit.classic" minSdk = 26 targetSdk = 36 - versionCode = 125 - versionName = "0.95.6-sound-passthrough" + versionCode = 126 + versionName = "0.95.7-sound-passthrough" } buildFeatures { compose = true } compileOptions { sourceCompatibility = JavaVersion.VERSION_17; targetCompatibility = JavaVersion.VERSION_17 } diff --git a/android/app/src/main/java/tv/orbit/classic/AudioOutput.kt b/android/app/src/main/java/tv/orbit/classic/AudioOutput.kt index 5548a050..6ffbebc1 100644 --- a/android/app/src/main/java/tv/orbit/classic/AudioOutput.kt +++ b/android/app/src/main/java/tv/orbit/classic/AudioOutput.kt @@ -1,46 +1,12 @@ package tv.orbit.classic import android.content.Context -import android.media.AudioFormat import androidx.media3.exoplayer.DefaultRenderersFactory -import androidx.media3.exoplayer.audio.AudioCapabilities -import androidx.media3.exoplayer.audio.AudioSink -import androidx.media3.exoplayer.audio.DefaultAudioSink /** - * How programme sound leaves the box. Paul's set-up (3 November 2026) is the TV's own speakers, no amplifier: the TV - * claims DTS over HDMI, so ExoPlayer sent DTS undecoded, ignoring the box's "surround sound: never" setting, and the TV - * cut it in and out every few seconds. Unless the viewer turns on "Send surround sound to an amplifier", Orbit decodes - * Dolby and DTS on the box (it has its own decoders) and sends plain sound. TrueHD, which this box can't decode, - * still goes out undecoded if the TV accepts it, rather than going silent. + * The renderers every programme player uses, so sound leaves the box the same way everywhere. Dolby and DTS go out + * undecoded for the TV (or an amplifier) to decode: on Paul's Xiaomi box the built-in DTS decoder runs but is silent + * (0.95.5, 3 November 2026), so decoding on the box is not offered. One place to change if another box needs it. */ -internal const val PASSTHROUGH_KEPT = AudioFormat.ENCODING_DOLBY_TRUEHD - -/** What the sound sink may send undecoded. PCM always; TrueHD only where the connection takes it. */ @androidx.annotation.OptIn(androidx.media3.common.util.UnstableApi::class) -@Suppress("DEPRECATION") -internal fun plainSoundCapabilities(device: AudioCapabilities): AudioCapabilities = - AudioCapabilities(plainSoundEncodings(device::supportsEncoding), device.maxChannelCount) - -/** The encodings sent undecoded, given which the connection accepts. */ -internal fun plainSoundEncodings(accepts: (Int) -> Boolean): IntArray = - (listOf(AudioFormat.ENCODING_PCM_16BIT) + listOf(PASSTHROUGH_KEPT).filter(accepts)).toIntArray() - -/** The renderers every programme player uses, so the choice of sound output is the same everywhere. */ -@androidx.annotation.OptIn(androidx.media3.common.util.UnstableApi::class) -internal fun programmeRenderers(context: Context): DefaultRenderersFactory { - val toAmplifier = OrbitSettings(context).surroundToAmplifier - return object : DefaultRenderersFactory(context) { - @Suppress("DEPRECATION") - override fun buildAudioSink(context: Context, enableFloatOutput: Boolean, enableAudioOutputPlaybackParams: Boolean): AudioSink? { - if (toAmplifier) return super.buildAudioSink(context, enableFloatOutput, enableAudioOutputPlaybackParams) - // Built without a context on purpose: with one, the sink keeps re-reading the HDMI connection's own - // capabilities and overrides these (seen on the box: DTS still went out undecoded). - return DefaultAudioSink.Builder() - .setAudioCapabilities(plainSoundCapabilities(AudioCapabilities.getCapabilities(context))) - .setEnableFloatOutput(enableFloatOutput) - .setEnableAudioTrackPlaybackParams(enableAudioOutputPlaybackParams) - .build() - } - } -} +internal fun programmeRenderers(context: Context): DefaultRenderersFactory = DefaultRenderersFactory(context) diff --git a/android/app/src/main/java/tv/orbit/classic/EmbyClient.kt b/android/app/src/main/java/tv/orbit/classic/EmbyClient.kt index acbaf5df..ae90fd0d 100644 --- a/android/app/src/main/java/tv/orbit/classic/EmbyClient.kt +++ b/android/app/src/main/java/tv/orbit/classic/EmbyClient.kt @@ -66,7 +66,7 @@ internal class HttpsEmbyTransport(internal val deviceId: String = UUID.randomUUI connection.connectTimeout = 10_000 connection.readTimeout = request.readTimeoutMs ?: if (request.path == "/Sessions/Logout") 5_000 else 15_000 connection.setRequestProperty("Accept", "application/json") - connection.setRequestProperty("X-Emby-Authorization", "Emby Client=\"Orbit TV\", Device=\"Orbit TV\", DeviceId=\"$deviceId\", Version=\"0.95.6\"") + connection.setRequestProperty("X-Emby-Authorization", "Emby Client=\"Orbit TV\", Device=\"Orbit TV\", DeviceId=\"$deviceId\", Version=\"0.95.7\"") request.token?.let { connection.setRequestProperty("X-Emby-Token", it) } if (request.method == "POST") { val bytes = request.body.orEmpty().toByteArray(Charsets.UTF_8) diff --git a/android/app/src/main/java/tv/orbit/classic/SecureMediaDataSource.kt b/android/app/src/main/java/tv/orbit/classic/SecureMediaDataSource.kt index e17aecd9..e2f6b1d1 100644 --- a/android/app/src/main/java/tv/orbit/classic/SecureMediaDataSource.kt +++ b/android/app/src/main/java/tv/orbit/classic/SecureMediaDataSource.kt @@ -33,7 +33,7 @@ internal class SecureMediaDataSource(private val session: EmbySampleSession) : B next.instanceFollowRedirects = false next.connectTimeout = 10_000 next.readTimeout = 20_000 - next.setRequestProperty("User-Agent", "OrbitTV/0.95.6") + next.setRequestProperty("User-Agent", "OrbitTV/0.95.7") next.setRequestProperty("Accept-Encoding", "identity") session.mediaHeaders(address).forEach { (key, value) -> next.setRequestProperty(key, value) } if (dataSpec.position != 0L || dataSpec.length != C.LENGTH_UNSET.toLong()) { diff --git a/android/app/src/main/java/tv/orbit/classic/Settings.kt b/android/app/src/main/java/tv/orbit/classic/Settings.kt index 7030e351..7873bdc6 100644 --- a/android/app/src/main/java/tv/orbit/classic/Settings.kt +++ b/android/app/src/main/java/tv/orbit/classic/Settings.kt @@ -59,11 +59,6 @@ internal class OrbitSettings(context: Context) { var driveInIntro: Boolean get() = saved.getBoolean("drive_in_intro", true) set(value) { saved.edit().putBoolean("drive_in_intro", value).apply() } - /** On (the default): Dolby and DTS go out undecoded, as before 0.95.4. Off: decoded on the box, which plays nothing for DTS on - * this Xiaomi box (its decoder runs but is silent, checked 3 November 2026), so off is only for a box whose decoders work. */ - var surroundToAmplifier: Boolean - get() = saved.getBoolean("surround_to_amplifier_v2", true) - set(value) { saved.edit().putBoolean("surround_to_amplifier_v2", value).apply() } /** Turns off moving presentation such as the Drive-In's curtains. More screens will follow it as they gain motion. */ var reduceMotion: Boolean get() = saved.getBoolean("reduce_motion", false) @@ -153,7 +148,6 @@ private fun ViewingDetail(totsOn: Boolean, windingDown: Boolean, onWindDown: (Bo var identSound by remember { mutableStateOf(settings.identSound) } var driveInIntro by remember { mutableStateOf(settings.driveInIntro) } var reduceMotion by remember { mutableStateOf(settings.reduceMotion) } - var surroundToAmplifier by remember { mutableStateOf(settings.surroundToAmplifier) } var confirming by remember { mutableStateOf(false) } Column(modifier.verticalScroll(rememberScrollState()), verticalArrangement = Arrangement.spacedBy(8.dp)) { SettingLine("Subtitles", "Turn on English subtitles whenever you tune in, if the programme has them. You can still change them while watching, by pressing right.") { @@ -171,9 +165,6 @@ private fun ViewingDetail(totsOn: Boolean, windingDown: Boolean, onWindDown: (Bo SettingLine("Drive-In curtains", "Play the curtain intro, with its fanfare, as you go into a screening. Back skips it.") { OrbitButton(if (driveInIntro) "On" else "Off", Modifier.width(64.dp), selected = driveInIntro, onClick = { driveInIntro = !driveInIntro; settings.driveInIntro = driveInIntro }) } - SettingLine("Surround sound undecoded", "Send Dolby and DTS sound as it is, for the TV or an amplifier to decode. Off decodes it on the box instead, which on some boxes leaves DTS silent. Takes effect from the next programme.") { - OrbitButton(if (surroundToAmplifier) "On" else "Off", Modifier.width(64.dp), selected = surroundToAmplifier, onClick = { surroundToAmplifier = !surroundToAmplifier; settings.surroundToAmplifier = surroundToAmplifier }) - } SettingLine("Reduce motion", "Leave out moving presentation, such as the Drive-In's curtains.") { OrbitButton(if (reduceMotion) "On" else "Off", Modifier.width(64.dp), selected = reduceMotion, onClick = { reduceMotion = !reduceMotion; settings.reduceMotion = reduceMotion }) } diff --git a/android/app/src/test/java/tv/orbit/classic/AudioOutputTest.kt b/android/app/src/test/java/tv/orbit/classic/AudioOutputTest.kt deleted file mode 100644 index d71177ac..00000000 --- a/android/app/src/test/java/tv/orbit/classic/AudioOutputTest.kt +++ /dev/null @@ -1,18 +0,0 @@ -package tv.orbit.classic - -import android.media.AudioFormat -import org.junit.Assert.assertArrayEquals -import org.junit.Test - -class AudioOutputTest { - private val tv = setOf(AudioFormat.ENCODING_PCM_16BIT, AudioFormat.ENCODING_AC3, AudioFormat.ENCODING_E_AC3, AudioFormat.ENCODING_DTS, AudioFormat.ENCODING_DOLBY_TRUEHD) - - @Test fun dolbyAndDtsAreDecodedOnTheBoxSoOnlyPlainSoundAndTrueHdGoOutUndecoded() { - // The TV accepts DTS and Dolby, but only PCM, and TrueHD (which the box can't decode), are sent as they are. - assertArrayEquals(intArrayOf(AudioFormat.ENCODING_PCM_16BIT, AudioFormat.ENCODING_DOLBY_TRUEHD), plainSoundEncodings(tv::contains)) - } - - @Test fun aConnectionWithoutTrueHdGetsPlainSoundOnly() { - assertArrayEquals(intArrayOf(AudioFormat.ENCODING_PCM_16BIT), plainSoundEncodings(setOf(AudioFormat.ENCODING_PCM_16BIT)::contains)) - } -} diff --git a/docs/VERIFICATION-0.95.7.md b/docs/VERIFICATION-0.95.7.md new file mode 100644 index 00000000..d5ad83e5 --- /dev/null +++ b/docs/VERIFICATION-0.95.7.md @@ -0,0 +1,7 @@ +# Orbit TV 0.95.7: surround sound always undecoded; setting removed + +Follow-up approved by Paul on 3 November 2026 after the 0.95.4 to 0.95.6 detour. On his Xiaomi box the built-in DTS decoder runs but produces silence (0.95.5), so decoding on the box isn't useful. 0.95.7 removes the "Surround sound undecoded" setting: every programme player uses the plain DefaultRenderersFactory through `programmeRenderers` (AudioOutput.kt), so Dolby and DTS go out undecoded for the TV, exactly as before 0.95.4. The leftover preference keys are simply ignored. + +The silent sound on Detour at 22:34 (with passthrough on, and the box's audio HAL receiving the DTS stream) cleared after Paul restarted the box at 22:36, so the box's audio output had got stuck after the evening's switching. The original Terra dropouts at 22:06 to 22:12 remain unexplained; if they come back, check the log while they happen. + +363 unit tests pass (the two plain-sound tests were removed with the feature); lint has no errors.