playback: make replaygain always-on

Remove the "Off" ReplayGain setting, as it is mostly meaningless.

Users who don't want ReplayGain can remove the tags from their files.
No efficiency benefits either since the audio processor is always
disabled without replaygain tags. It is better not to confuse users
who do have ReplayGain but wonder why it is not working on their
files because the setting is off.
This commit is contained in:
OxygenCobalt
2022-08-11 11:44:19 -06:00
parent b104dd151d
commit ee68e7ffe9
10 changed files with 14 additions and 22 deletions
@@ -108,8 +108,8 @@ object IntegerTable {
/** Sort.ByDateAdded */
const val SORT_BY_DATE_ADDED = 0xA118
/** ReplayGainMode.Off */
const val REPLAY_GAIN_MODE_OFF = 0xA110
/** ReplayGainMode.Off (No longer used but still reserved) */
// const val REPLAY_GAIN_MODE_OFF = 0xA110
/** ReplayGainMode.Track */
const val REPLAY_GAIN_MODE_TRACK = 0xA111
/** ReplayGainMode.Album */
@@ -67,6 +67,8 @@ class ExoPlayerBackend(private val inner: MediaStoreBackend) : Indexer.Backend {
val songs = mutableListOf<Song>()
val total = cursor.count
// LEFTOFF: Make logic more consistent?
while (cursor.moveToNext()) {
// Note: This call to buildAudio does not populate the genre field. This is
// because indexing genres is quite slow with MediaStore, and so keeping the
@@ -21,8 +21,6 @@ import org.oxycblt.auxio.IntegerTable
/** Represents the current setting for ReplayGain. */
enum class ReplayGainMode {
/** Do not apply ReplayGain. */
OFF,
/** Apply the track gain, falling back to the album gain if the track gain is not found. */
TRACK,
/** Apply the album gain, falling back to the track gain if the album gain is not found. */
@@ -34,7 +32,6 @@ enum class ReplayGainMode {
/** Convert an int [code] into an instance, or null if it isn't valid. */
fun fromIntCode(code: Int): ReplayGainMode? {
return when (code) {
IntegerTable.REPLAY_GAIN_MODE_OFF -> OFF
IntegerTable.REPLAY_GAIN_MODE_TRACK -> TRACK
IntegerTable.REPLAY_GAIN_MODE_ALBUM -> ALBUM
IntegerTable.REPLAY_GAIN_MODE_DYNAMIC -> DYNAMIC
@@ -65,12 +65,6 @@ class ReplayGainAudioProcessor(context: Context) : BaseAudioProcessor() {
* based off Vanilla Music's implementation, but has diverged to a significant extent.
*/
fun applyReplayGain(metadata: Metadata?) {
if (settings.replayGainMode == ReplayGainMode.OFF) {
logD("ReplayGain not enabled")
volume = 1f
return
}
val gain = metadata?.let(::parseReplayGain)
val preAmp = settings.replayGainPreAmp
@@ -79,8 +73,6 @@ class ReplayGainAudioProcessor(context: Context) : BaseAudioProcessor() {
// ReplayGain is configurable, so determine what to do based off of the mode.
val useAlbumGain =
when (settings.replayGainMode) {
ReplayGainMode.OFF -> throw IllegalStateException()
// User wants track gain to be preferred. Default to album gain only if
// there is no track gain.
ReplayGainMode.TRACK -> gain.track == 0f
@@ -109,7 +101,7 @@ class ReplayGainAudioProcessor(context: Context) : BaseAudioProcessor() {
} else {
// No ReplayGain tags existed, or no tags were parsable, or there was no metadata
// in the first place. Return the gain to use when there is no ReplayGain value.
logD("No ReplayGain tags present ")
logD("No ReplayGain tags present")
preAmp.without
}
@@ -265,6 +265,8 @@ class PlaybackService :
return
}
C.ENCODING_PCM_32BIT
logD("Loading ${song.rawName}")
player.setMediaItem(MediaItem.fromUri(song.uri))
player.prepare()
@@ -140,7 +140,7 @@ class Settings(private val context: Context, private val callback: Callback? = n
get() =
ReplayGainMode.fromIntCode(
inner.getInt(context.getString(R.string.set_key_replay_gain), Int.MIN_VALUE))
?: ReplayGainMode.OFF
?: ReplayGainMode.DYNAMIC
/** The current ReplayGain pre-amp configuration */
var replayGainPreAmp: ReplayGainPreAmp