mirror of
https://github.com/austinried/subtracks.git
synced 2026-11-11 15:29:15 +01:00
playback: warn once when float output would skip the processor
Float output is the one way the audio processor chain is skipped on this build, and it is a flag the renderers factory is handed. Nothing sets it, so nothing happens today; if it is ever turned on, this says so once at sink construction rather than leaving replay gain silently inapplicable to high-resolution tracks. Offload has no equivalent check: it is not a flag this code sets, and AudioSink.setOffloadMode is only reachable by building the audio renderer by hand. The factory comment names it instead.
This commit is contained in:
@@ -6,6 +6,7 @@ import androidx.media3.common.util.UnstableApi
|
|||||||
import androidx.media3.exoplayer.DefaultRenderersFactory
|
import androidx.media3.exoplayer.DefaultRenderersFactory
|
||||||
import androidx.media3.exoplayer.audio.AudioSink
|
import androidx.media3.exoplayer.audio.AudioSink
|
||||||
import androidx.media3.exoplayer.audio.DefaultAudioSink
|
import androidx.media3.exoplayer.audio.DefaultAudioSink
|
||||||
|
import com.subtracks.log.Log
|
||||||
|
|
||||||
@OptIn(UnstableApi::class)
|
@OptIn(UnstableApi::class)
|
||||||
internal class ReplayGainRenderersFactory(
|
internal class ReplayGainRenderersFactory(
|
||||||
@@ -13,16 +14,25 @@ internal class ReplayGainRenderersFactory(
|
|||||||
private val processor: ReplayGainProcessor,
|
private val processor: ReplayGainProcessor,
|
||||||
) : DefaultRenderersFactory(context) {
|
) : DefaultRenderersFactory(context) {
|
||||||
// Mirrors the stock DefaultRenderersFactory.buildAudioSink. setAudioProcessors keeps the default
|
// Mirrors the stock DefaultRenderersFactory.buildAudioSink. setAudioProcessors keeps the default
|
||||||
// chain and prepends ours; DefaultAudioSink omits the whole chain when float output is enabled.
|
// chain and prepends ours; DefaultAudioSink omits the whole chain when float output is enabled,
|
||||||
|
// and AudioSink.setOffloadMode bypasses it entirely.
|
||||||
public override fun buildAudioSink(
|
public override fun buildAudioSink(
|
||||||
context: Context,
|
context: Context,
|
||||||
enableFloatOutput: Boolean,
|
enableFloatOutput: Boolean,
|
||||||
enableAudioOutputPlaybackParameters: Boolean,
|
enableAudioOutputPlaybackParameters: Boolean,
|
||||||
): AudioSink =
|
): AudioSink {
|
||||||
DefaultAudioSink
|
if (enableFloatOutput) {
|
||||||
|
Log.w(FLOAT_OUTPUT_TAG, "float output is on, so replay gain is not applied to high-resolution tracks")
|
||||||
|
}
|
||||||
|
return DefaultAudioSink
|
||||||
.Builder(context)
|
.Builder(context)
|
||||||
.setEnableFloatOutput(enableFloatOutput)
|
.setEnableFloatOutput(enableFloatOutput)
|
||||||
.setEnableAudioOutputPlaybackParameters(enableAudioOutputPlaybackParameters)
|
.setEnableAudioOutputPlaybackParameters(enableAudioOutputPlaybackParameters)
|
||||||
.setAudioProcessors(arrayOf(processor))
|
.setAudioProcessors(arrayOf(processor))
|
||||||
.build()
|
.build()
|
||||||
|
}
|
||||||
|
|
||||||
|
private companion object {
|
||||||
|
const val FLOAT_OUTPUT_TAG = "replaygain"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user