What is the difference between AudioManager's stream types at low level?

Kirill Boyarshinov picture Kirill Boyarshinov · Jul 9, 2014 · Viewed 11.6k times · Source

There are several stream types in AudioManager. How did they differ at low level? Could it be that usage of e.g. AudioManager.STREAM_MUSIC blocks input microphone stream? Or something else?

Answer

KeithYokoma picture KeithYokoma · Oct 17, 2014

One most significant difference is a volume control.
As the document says, we can set a volume level or adjust a volume for each streams respectively.
And we can control "Audio Focus" that let other apps stop playback or lower the volumes so we can play a sound clearly on a specific stream, or the sound will not block the other high-prioritized sound like phone ring, navigation voice feedback or something like that.

With multiple apps potentially playing audio it's important to think about how they should interact. To avoid every music app playing at the same time, Android uses audio focus to moderate audio playback—only apps that hold the audio focus should play audio.

Other unmentioned thing is which audio device will produce a sound.
Using STREAM_MUSIC the sound will be produced through one audio device(phone speaker, earphone, bluetooth speaker or something else) connected to the phone.
Using STREAM_RING the sound will be produced through all audio device connected to the phone. This behaviour might be differed for each devices.