androidx / androidx/media

Sound disappears when custom equalizer is enabled

Open
#1,410 4 comments 0 reactions 1 assignee View on GitHub

Nobody has claimed this yet.

bug bug: in platform low priority
Dominant language
Java
Stars
3k
Forks
955
Avg merge
12d 14h
Merged PRs (30d)
2

Description

Version

Media3 main branch

More version details

Good afternoon!

On a number of devices with HyperOS,

  1. when a custom equalizer is installed, the sound disappears when listening to tracks/switching tracks. If you adjust the volume on the device, the sound is restored.

  2. If I add exoplayer::release and create a new ExoPlayer object for each new track, then, judging by messages from users, the sound does not disappear (there is no bug).

  3. If the custom equalizer is turned off, the sound does not disappear (there is no bug)

The logs for all three cases contain the same errors.

Sample errors

"W libc : Access denied finding property "ro.vendor.df.effect.conflict"
sample_logs.txt
"

I give errors for the device in attachment

OS: Android 14

Xiaomi HyperOS 1.0.1.0
Poco x5 5g 22111317
Resolution: 2176x1080
DensityDpi:440

i give dependencies

implementation("androidx.media3:media3-exoplayer:1.3.1")
implementation("androidx.media3:media3-ui:1.3.1")

I give code:

private fun createExoplayer() {
    player = ExoPlayer.Builder(applicationContext).build()
    val audioSessionId = player.audioSessionId
    initEqualizer(audioSessionId)
}


@Synchronized
private fun initEqualizer(audioSessionId: Int?) {
    if (audioSessionId == null) {
        stopEqualizer()
        return
    }

    equalizer = Equalizer(150, audioSessionId)

    val shorts = listOf<Short>(0, 0, 0, 0, 0)

    applyBandLevels4AudioSession(shorts)
}


private fun applyBandLevels4AudioSession(bandLevels: List<Short>) {
    val eq = equalizer ?: return
    val minLevel = eq.bandLevelRange[0]
    val maxLevel = eq.bandLevelRange[1]
    val numberOfBands = eq.numberOfBands.toInt()

    if (numberOfBands == 0 || numberOfBands != bandLevels.size) return
    try {
        bandLevels.forEachIndexed { band, level ->
            if (level in (minLevel)..maxLevel) {
                eq.setBandLevel(band.toShort(), level)
            }
        }
        eq.enabled = true
    } catch (e: RuntimeException) {
    }
}

@Synchronized
private fun stopEqualizer() {
    equalizer?.enabled = false
    equalizer?.release()
    equalizer = null
}


//method for playing Track
private fun play(uri: Uri) {


    /*  If you uncomment this the error will go away. But the same errors are written to the logs*/

    // exoplayerRelease()
    // createExoplayer()

    player.setMediaItem(MediaItem.fromUri(uri))
    player.prepare()
    player.playWhenReady = true
}

private fun exoplayerRelease() {
    player.release()
    initEqualizer(null)

}
Devices that reproduce the issue

Poco x5 5g 22111317 Android 14 Xiaomi HyperOS 1.0.1.0

Devices that do not reproduce the issue

No response

Reproducible in the demo app?

Not tested

Reproduction steps
  1. Install a custom equalizer

  2. Launch tracks

  3. Switch tracks

Expected result

Sound is heard

Actual result

No sound is heard

Media

In All mp3 files

Bug Report
  • You will email the zip file produced by adb bugreport to android-media-github@google.com after filing this issue.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.