Edit: I was wrong saying there is no other way to allow microphone input. Looked again and found another commit later that introduced allow-host-audio
option. So this is the way to start the emulator with host audio enabled:
emulator -avd YourAvdName -qemu -allow-host-audio
adb emu avd hostmicon
It seems like it's not enabling the switch in the settings, but that's a pure UI issue, the mic works fine.
Previous answer:
I don't believe there is currently a way for this particular setting. Normally emulator setting are saved into AVD.conf
. Here are all the constants for the persistent settings and microphone settings are not among them. Looking further at the Virtual microphone uses host audio input
setting I found the commit which introduced this setting and as you can see when you toggle this setting it sets allow_real_audio
in audio subsystem and that's it. No other code is setting this flag. As you can see here this option is being reset on restart intentionally and hopefully it will be fixed when the described bug is fixed.
Edit: here is a bit more on how exactly the flag is set:
UI switch toggle is handled in this line. It calls this function, which in its turn calls qemu_allow_real_audio, which sets allow_real_audio
flag. This flag is used in the AUD_read
function
if (!allow_real_audio) {
// TODO: Also a potential way to pipe fake audio input
// that is not just all zeroes.
memset(buf, 0x0, size);
}