summaryrefslogtreecommitdiff
path: root/servers/audio_server.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'servers/audio_server.cpp')
-rw-r--r--servers/audio_server.cpp137
1 files changed, 13 insertions, 124 deletions
diff --git a/servers/audio_server.cpp b/servers/audio_server.cpp
index 10fa69a12e..eb034fa615 100644
--- a/servers/audio_server.cpp
+++ b/servers/audio_server.cpp
@@ -73,42 +73,6 @@ void AudioDriver::update_mix_time(int p_frames) {
_last_mix_time = OS::get_singleton()->get_ticks_usec();
}
-void AudioDriver::update_microphone_default(StringName p_device_name) {
- if (default_microphone_device_output != NULL) {
- MicrophoneDeviceOutput *output = default_microphone_device_output->owner;
- output->remove_reciever(default_microphone_device_output);
-
- while (output != NULL) {
- MicrophoneDeviceOutput *owner = output->owner;
- if (output->recievers.size() == 0) {
- if (owner == NULL) {
- if (output->active == true) {
- capture_device_stop(output->name);
- output->active == false;
- }
- } else {
- owner->remove_reciever(output);
- memdelete(output);
- }
- output = owner;
- }
- }
-
- if (microphone_device_output_map.has(p_device_name)) {
-
- Map<StringName, MicrophoneDeviceOutput *>::Element *e = microphone_device_output_map.find(p_device_name);
- MicrophoneDeviceOutput *new_output = e->get();
- new_output->add_reciever(default_microphone_device_output);
- if (new_output->active == false) {
- capture_device_start(p_device_name);
- new_output->active = true;
- }
- }
-
- output = default_microphone_device_output->owner;
- }
-}
-
double AudioDriver::get_mix_time() const {
double total = (OS::get_singleton()->get_ticks_usec() - _last_mix_time) / 1000000.0;
@@ -138,75 +102,19 @@ int AudioDriver::get_total_channels_by_speaker_mode(AudioDriver::SpeakerMode p_m
ERR_FAIL_V(2);
}
-AudioDriver::MicrophoneReciever *AudioDriver::create_microphone_reciever(const StringName &p_device_name) {
-
- MicrophoneReciever *microphone_reciever = NULL;
- MicrophoneDeviceOutput *reciever_output = NULL;
- MicrophoneDeviceOutput *device_output = NULL;
-
- StringName device_name = capture_device_get_default_name();
-
- if (microphone_device_output_map.has(device_name)) {
-
- Map<StringName, MicrophoneDeviceOutput *>::Element *e = microphone_device_output_map.find(device_name);
- device_output = e->get();
- }
-
- if (device_output) {
- if (p_device_name == "") {
- if (default_microphone_device_output != NULL) {
- reciever_output = default_microphone_device_output;
- } else {
- // Default reciever does not exist, create it and connect it
- default_microphone_device_output = memnew(MicrophoneDeviceOutputIndirect);
- reciever_output = default_microphone_device_output;
- device_output->add_reciever(reciever_output);
- }
- } else {
- if (microphone_device_output_map.has(p_device_name)) {
- reciever_output = device_output;
- }
- }
+Array AudioDriver::get_device_list() {
+ Array list;
- if (reciever_output) {
- microphone_reciever = memnew(MicrophoneReciever);
- reciever_output->add_reciever(microphone_reciever);
- if (device_output->active == false) {
- capture_device_start(device_name);
- device_output->active = true;
- }
- }
- }
+ list.push_back("Default");
- return microphone_reciever;
+ return list;
}
-void AudioDriver::destroy_microphone_reciever(AudioDriver::MicrophoneReciever *p_microphone_reciever) {
-
- if (p_microphone_reciever != NULL) {
- MicrophoneDeviceOutput *output = p_microphone_reciever->owner;
- output->remove_reciever(p_microphone_reciever);
-
- while (output != NULL) {
- MicrophoneDeviceOutput *owner = output->owner;
- if (output->recievers.size() == 0) {
- if (owner == NULL) {
- if (output->active == true) {
- capture_device_stop(output->name);
- output->active == false;
- }
- } else {
- owner->remove_reciever(output);
- memdelete(output);
- }
- output = owner;
- }
- }
- memdelete(p_microphone_reciever);
- }
+String AudioDriver::get_device() {
+ return "Default";
}
-Array AudioDriver::get_device_list() {
+Array AudioDriver::capture_get_device_list() {
Array list;
list.push_back("Default");
@@ -214,17 +122,11 @@ Array AudioDriver::get_device_list() {
return list;
}
-String AudioDriver::get_device() {
- return "Default";
-}
-
AudioDriver::AudioDriver() {
_last_mix_time = 0;
_mix_amount = 0;
- default_microphone_device_output = NULL;
-
#ifdef DEBUG_ENABLED
prof_time = 0;
#endif
@@ -1308,32 +1210,19 @@ void AudioServer::set_device(String device) {
AudioDriver::get_singleton()->set_device(device);
}
-PoolStringArray AudioServer::audio_in_get_device_names() {
-
- lock();
- PoolStringArray device_names = AudioDriver::get_singleton()->capture_device_get_names();
- unlock();
+Array AudioServer::capture_get_device_list() {
- return device_names;
+ return AudioDriver::get_singleton()->capture_get_device_list();
}
-AudioDriver::MicrophoneReciever *AudioServer::create_microphone_reciever(const StringName &p_device_name) {
- AudioDriver::MicrophoneReciever *microphone_reciever = NULL;
-
- lock();
- microphone_reciever = AudioDriver::get_singleton()->create_microphone_reciever(p_device_name);
- unlock();
+StringName AudioServer::capture_get_device() {
- return microphone_reciever;
+ return AudioDriver::get_singleton()->capture_get_device();
}
-void AudioServer::destroy_microphone_reciever(AudioDriver::MicrophoneReciever *p_microphone_reciever) {
- lock();
- AudioDriver::get_singleton()->destroy_microphone_reciever(p_microphone_reciever);
- unlock();
-}
+void AudioServer::capture_set_device(StringName device) {
-void AudioServer::_change_default_device(StringName p_recording_device_default_name) {
+ AudioDriver::get_singleton()->capture_set_device(device);
}
void AudioServer::_bind_methods() {