0.95.7: surround sound always undecoded; the setting is removed (the box's DTS decoder is silent)
pauljd/davidson-ci: Davidson CI / quality (push) Failing after 2m6s
pauljd/davidson-ci: Davidson CI / ai-review (push) Failing after 1m23s

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-11-03 22:41:25 +00:00
co-authored by Claude Opus 5.5
parent 04be4328bc
commit a71086ad35
7 changed files with 15 additions and 69 deletions
@@ -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)
@@ -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)
@@ -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()) {
@@ -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 })
}