Question

I am doing continuous recognition using Google Speech Recognition, this means that to avoid the beeps every few seconds (bug in jelly bean), I have to mute and unmute the system volume.

To do this I use:

mAudioManager.setStreamMute(AudioManager.STREAM_SYSTEM, true);

and the same thing with false.

The issue I have is that sporadically and reproducible on many devices, the system volume will become "locked" at muted until an uninstall or reboot.

I make sure to unmute the system volume when the service is stopped, but it doesn't seem to affect it.

Maybe it is because AudioManager is not meant to unmute and mute so frequently? Any help is welcome.

Was it helpful?

Solution

Android documentation for setStreamMute:

Mute or unmute an audio stream.

...

The mute requests for a given stream are cumulative: the AudioManager can receive several mute requests from one or more clients and the stream will be unmuted only when the same number of unmute requests are received.

...

This ended up being the issue. I was calling more mutes than unmutes if there was an error which caused for this locking.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top