summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvolzhs <volzhs@gmail.com>2018-12-14 00:35:01 +0900
committervolzhs <volzhs@gmail.com>2018-12-14 06:40:13 +0900
commit7d387dc63f75da867a1b9e07cd957b456de99c12 (patch)
tree65ebff10ca2e81cad785990d1e33305229a8243b
parent199c294d4c1f432be4370492902fdf7f9d7fccec (diff)
Request mic access only when is needed
-rw-r--r--doc/classes/ProjectSettings.xml3
-rw-r--r--drivers/coreaudio/audio_driver_coreaudio.cpp5
-rw-r--r--servers/audio/audio_stream.cpp7
-rw-r--r--servers/audio_server.cpp1
4 files changed, 15 insertions, 1 deletions
diff --git a/doc/classes/ProjectSettings.xml b/doc/classes/ProjectSettings.xml
index 7a9918237f..bf9eaa04a7 100644
--- a/doc/classes/ProjectSettings.xml
+++ b/doc/classes/ProjectSettings.xml
@@ -210,6 +210,9 @@
</member>
<member name="audio/driver" type="String" setter="" getter="">
</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="">
Mix rate used for audio. In general, it's better to not touch this and leave it to the host operating system.
</member>
diff --git a/drivers/coreaudio/audio_driver_coreaudio.cpp b/drivers/coreaudio/audio_driver_coreaudio.cpp
index 726cee10a4..3d093b965a 100644
--- a/drivers/coreaudio/audio_driver_coreaudio.cpp
+++ b/drivers/coreaudio/audio_driver_coreaudio.cpp
@@ -159,7 +159,10 @@ Error AudioDriverCoreAudio::init() {
result = AudioUnitInitialize(audio_unit);
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,
diff --git a/servers/audio/audio_stream.cpp b/servers/audio/audio_stream.cpp
index 02a0bed964..21073a1cd1 100644
--- a/servers/audio/audio_stream.cpp
+++ b/servers/audio/audio_stream.cpp
@@ -30,6 +30,7 @@
#include "audio_stream.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) {
+
+ 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;
AudioDriver::get_singleton()->capture_start();
diff --git a/servers/audio_server.cpp b/servers/audio_server.cpp
index 530976f084..759dd77926 100644
--- a/servers/audio_server.cpp
+++ b/servers/audio_server.cpp
@@ -172,6 +172,7 @@ int AudioDriverManager::get_driver_count() {
}
void AudioDriverManager::initialize(int p_driver) {
+ GLOBAL_DEF_RST("audio/enable_audio_input", false);
int failed_driver = -1;
// Check if there is a selected driver