diff options
Diffstat (limited to 'servers/audio_server.cpp')
-rw-r--r-- | servers/audio_server.cpp | 77 |
1 files changed, 19 insertions, 58 deletions
diff --git a/servers/audio_server.cpp b/servers/audio_server.cpp index 1da0146084..2a5a5040b6 100644 --- a/servers/audio_server.cpp +++ b/servers/audio_server.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */ +/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -29,6 +29,7 @@ /*************************************************************************/ #include "audio_server.h" + #include "core/io/resource_loader.h" #include "core/os/file_access.h" #include "core/os/os.h" @@ -36,14 +37,11 @@ #include "scene/resources/audio_stream_sample.h" #include "servers/audio/audio_driver_dummy.h" #include "servers/audio/effects/audio_effect_compressor.h" -#ifdef TOOLS_ENABLED +#ifdef TOOLS_ENABLED #define MARK_EDITED set_edited(true); - #else - #define MARK_EDITED - #endif AudioDriver *AudioDriver::singleton = NULL; @@ -85,26 +83,26 @@ double AudioDriver::get_time_to_next_mix() const { return mix_buffer - total; } -void AudioDriver::capture_buffer_init(int driver_buffer_frames) { +void AudioDriver::input_buffer_init(int driver_buffer_frames) { - const int capture_buffer_channels = 2; - capture_buffer.resize(driver_buffer_frames * capture_buffer_channels * 4); - capture_position = 0; - capture_size = 0; + const int input_buffer_channels = 2; + input_buffer.resize(driver_buffer_frames * input_buffer_channels * 4); + input_position = 0; + input_size = 0; } -void AudioDriver::capture_buffer_write(int32_t sample) { +void AudioDriver::input_buffer_write(int32_t sample) { - if ((int)capture_position < capture_buffer.size()) { - capture_buffer.write()[capture_position++] = sample; - if ((int)capture_position >= capture_buffer.size()) { - capture_position = 0; + if ((int)input_position < input_buffer.size()) { + input_buffer.write[input_position++] = sample; + if ((int)input_position >= input_buffer.size()) { + input_position = 0; } - if ((int)capture_size < capture_buffer.size()) { - capture_size++; + if ((int)input_size < input_buffer.size()) { + input_size++; } } else { - WARN_PRINTS("capture_buffer_write: Invalid capture_position=" + itos(capture_position) + " capture_buffer.size()=" + itos(capture_buffer.size())); + WARN_PRINT("input_buffer_write: Invalid input_position=" + itos(input_position) + " input_buffer.size()=" + itos(input_buffer.size())); } } @@ -154,8 +152,8 @@ AudioDriver::AudioDriver() { _last_mix_time = 0; _last_mix_frames = 0; - capture_position = 0; - capture_size = 0; + input_position = 0; + input_size = 0; #ifdef DEBUG_ENABLED prof_time = 0; @@ -338,8 +336,6 @@ void AudioServer::_mix_step() { E->get().callback(E->get().userdata); } - emit_signal("audio_mix_callback"); - for (int i = buses.size() - 1; i >= 0; i--) { //go bus by bus Bus *bus = buses[i]; @@ -1059,8 +1055,6 @@ void AudioServer::update() { E->get().callback(E->get().userdata); } - - emit_signal("audio_update_callback"); } void AudioServer::load_default_bus_layout() { @@ -1079,7 +1073,6 @@ void AudioServer::finish() { for (int i = 0; i < AudioDriverManager::get_driver_count(); i++) { AudioDriverManager::get_driver(i)->finish(); - AudioDriverManager::get_driver(i)->clear_capture_buffer(); } for (int i = 0; i < buses.size(); i++) { @@ -1307,14 +1300,6 @@ void AudioServer::set_device(String device) { AudioDriver::get_singleton()->set_device(device); } -Error AudioServer::capture_start() { - return AudioDriver::get_singleton()->capture_start(); -} - -Error AudioServer::capture_stop() { - return AudioDriver::get_singleton()->capture_stop(); -} - Array AudioServer::capture_get_device_list() { return AudioDriver::get_singleton()->capture_get_device_list(); @@ -1330,18 +1315,6 @@ void AudioServer::capture_set_device(const String &p_name) { AudioDriver::get_singleton()->capture_set_device(p_name); } -PoolVector<int32_t> AudioServer::get_capture_buffer() { - return AudioDriver::get_singleton()->get_capture_buffer(); -} - -unsigned int AudioServer::get_capture_position() { - return AudioDriver::get_singleton()->get_capture_position(); -} - -unsigned int AudioServer::get_capture_size() { - return AudioDriver::get_singleton()->get_capture_size(); -} - void AudioServer::_bind_methods() { ClassDB::bind_method(D_METHOD("set_bus_count", "amount"), &AudioServer::set_bus_count); @@ -1402,28 +1375,18 @@ void AudioServer::_bind_methods() { ClassDB::bind_method(D_METHOD("get_time_since_last_mix"), &AudioServer::get_time_since_last_mix); ClassDB::bind_method(D_METHOD("get_output_latency"), &AudioServer::get_output_latency); - ClassDB::bind_method(D_METHOD("capture_start"), &AudioServer::capture_start); - ClassDB::bind_method(D_METHOD("capture_stop"), &AudioServer::capture_stop); - ClassDB::bind_method(D_METHOD("capture_get_device_list"), &AudioServer::capture_get_device_list); ClassDB::bind_method(D_METHOD("capture_get_device"), &AudioServer::capture_get_device); ClassDB::bind_method(D_METHOD("capture_set_device", "name"), &AudioServer::capture_set_device); - ClassDB::bind_method(D_METHOD("get_capture_buffer"), &AudioServer::get_capture_buffer); - ClassDB::bind_method(D_METHOD("get_capture_position"), &AudioServer::get_capture_position); - ClassDB::bind_method(D_METHOD("get_capture_size"), &AudioServer::get_capture_size); - ClassDB::bind_method(D_METHOD("set_bus_layout", "bus_layout"), &AudioServer::set_bus_layout); ClassDB::bind_method(D_METHOD("generate_bus_layout"), &AudioServer::generate_bus_layout); ADD_PROPERTY(PropertyInfo(Variant::INT, "bus_count"), "set_bus_count", "get_bus_count"); ADD_PROPERTY(PropertyInfo(Variant::STRING, "device"), "set_device", "get_device"); - ADD_PROPERTY(PropertyInfo(Variant::STRING, "capture_device"), "capture_set_device", "capture_get_device"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "global_rate_scale"), "set_global_rate_scale", "get_global_rate_scale"); ADD_SIGNAL(MethodInfo("bus_layout_changed")); - ADD_SIGNAL(MethodInfo("audio_mix_callback")); - ADD_SIGNAL(MethodInfo("audio_update_callback")); BIND_ENUM_CONSTANT(SPEAKER_MODE_STEREO); BIND_ENUM_CONSTANT(SPEAKER_SURROUND_31); @@ -1440,8 +1403,6 @@ AudioServer::AudioServer() { mix_frames = 0; channel_count = 0; to_mix = 0; - output_latency = 0; - output_latency_ticks = 0; #ifdef DEBUG_ENABLED prof_time = 0; #endif |