9

When I'm starting my Android Emulator, I click on the three dots at right. Then, in "Extended controls" window, I set the Microphone options all active.

I must do it every time I start it, and it's very annoying. It is possible to make these settings active by default? And how?

Lore
  • 1,286
  • 1
  • 22
  • 57

1 Answers1

9

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);
    }
vmontazeri
  • 393
  • 2
  • 20
esentsov
  • 6,372
  • 21
  • 28
  • *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.* Can you indicate me where exactly is this line of code? – Lore Sep 22 '19 at 08:42
  • Thanks. Where I can find all of these files in my filesystem? :) – Lore Sep 22 '19 at 09:35
  • These files are from aosp project and you can download it if you wish. [Here](https://source.android.com/setup/build/downloading) is the instruction how to download aosp. Just specify `emu-master-dev` branch to get the emulator source code. – esentsov Sep 22 '19 at 11:34
  • @Lore I was wrong saying there is no way to enable the setting. Please check the updated answer. – esentsov Sep 22 '19 at 11:35
  • This works, and it's ok for me on this project... but with "default" i mean something that I can set on emulator config, then forget about it. Not to activate every time by command line. – Lore Sep 23 '19 at 07:50
  • There is seem to be no way to set it as a default. But you can use [this solution](https://stackoverflow.com/a/51858653/2548988) to achieve set-and-forget experience – esentsov Sep 23 '19 at 09:32
  • The solution is for mac... I am on Windows – Lore Sep 23 '19 at 11:16
  • You should be able to do the same on windows with a bat file – esentsov Sep 23 '19 at 11:27
  • 1
    Sorry, I'm not a windows expert. At least you can create a bat file with the exact command from the answer and run it to launch the emulator. Not perfect, but at least no typing every time. – esentsov Sep 23 '19 at 16:21