Request mic access only when is needed
This commit is contained in:
parent
199c294d4c
commit
7d387dc63f
|
@ -210,6 +210,9 @@
|
||||||
</member>
|
</member>
|
||||||
<member name="audio/driver" type="String" setter="" getter="">
|
<member name="audio/driver" type="String" setter="" getter="">
|
||||||
</member>
|
</member>
|
||||||
|
<member name="audio/enable_audio_input" type="bool" setter="" getter="">
|
||||||
|
This option should be enabled if project works with microphone.
|
||||||
|
</member>
|
||||||
<member name="audio/mix_rate" type="int" setter="" getter="">
|
<member name="audio/mix_rate" type="int" setter="" getter="">
|
||||||
Mix rate used for audio. In general, it's better to not touch this and leave it to the host operating system.
|
Mix rate used for audio. In general, it's better to not touch this and leave it to the host operating system.
|
||||||
</member>
|
</member>
|
||||||
|
|
|
@ -159,7 +159,10 @@ Error AudioDriverCoreAudio::init() {
|
||||||
result = AudioUnitInitialize(audio_unit);
|
result = AudioUnitInitialize(audio_unit);
|
||||||
ERR_FAIL_COND_V(result != noErr, FAILED);
|
ERR_FAIL_COND_V(result != noErr, FAILED);
|
||||||
|
|
||||||
return capture_init();
|
if (GLOBAL_GET("audio/enable_audio_input")) {
|
||||||
|
return capture_init();
|
||||||
|
}
|
||||||
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
OSStatus AudioDriverCoreAudio::output_callback(void *inRefCon,
|
OSStatus AudioDriverCoreAudio::output_callback(void *inRefCon,
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
|
|
||||||
#include "audio_stream.h"
|
#include "audio_stream.h"
|
||||||
#include "core/os/os.h"
|
#include "core/os/os.h"
|
||||||
|
#include "core/project_settings.h"
|
||||||
|
|
||||||
//////////////////////////////
|
//////////////////////////////
|
||||||
|
|
||||||
|
@ -184,6 +185,12 @@ float AudioStreamPlaybackMicrophone::get_stream_sampling_rate() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioStreamPlaybackMicrophone::start(float p_from_pos) {
|
void AudioStreamPlaybackMicrophone::start(float p_from_pos) {
|
||||||
|
|
||||||
|
if (!GLOBAL_GET("audio/enable_audio_input")) {
|
||||||
|
WARN_PRINTS("Need to enable Project settings > Audio > Enable Audio Input option to use capturing.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
input_ofs = 0;
|
input_ofs = 0;
|
||||||
|
|
||||||
AudioDriver::get_singleton()->capture_start();
|
AudioDriver::get_singleton()->capture_start();
|
||||||
|
|
|
@ -172,6 +172,7 @@ int AudioDriverManager::get_driver_count() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioDriverManager::initialize(int p_driver) {
|
void AudioDriverManager::initialize(int p_driver) {
|
||||||
|
GLOBAL_DEF_RST("audio/enable_audio_input", false);
|
||||||
int failed_driver = -1;
|
int failed_driver = -1;
|
||||||
|
|
||||||
// Check if there is a selected driver
|
// Check if there is a selected driver
|
||||||
|
|
Loading…
Reference in New Issue