summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--servers/audio/effects/audio_effect_record.cpp25
-rw-r--r--servers/audio/effects/audio_effect_record.h6
2 files changed, 18 insertions, 13 deletions
diff --git a/servers/audio/effects/audio_effect_record.cpp b/servers/audio/effects/audio_effect_record.cpp
index ad5fad8464..74a6838d1a 100644
--- a/servers/audio/effects/audio_effect_record.cpp
+++ b/servers/audio/effects/audio_effect_record.cpp
@@ -61,7 +61,7 @@ void AudioEffectRecordInstance::_io_thread_process() {
while (is_recording) {
//Check: The current recording has been requested to stop
- if (is_recording && !base->should_record) {
+ if (is_recording && !base->recording_active) {
is_recording = false;
}
@@ -136,7 +136,7 @@ Ref<AudioEffectInstance> AudioEffectRecord::instance() {
ensure_thread_stopped();
current_instance = ins;
- if (should_record) {
+ if (recording_active) {
ins->init();
}
@@ -144,23 +144,29 @@ Ref<AudioEffectInstance> AudioEffectRecord::instance() {
}
void AudioEffectRecord::ensure_thread_stopped() {
- should_record = false;
+ recording_active = false;
if (current_instance != 0 && current_instance->thread_active) {
Thread::wait_to_finish(current_instance->io_thread);
}
}
-void AudioEffectRecord::set_should_record(bool p_record) {
+void AudioEffectRecord::set_recording_active(bool p_record) {
if (p_record) {
+ if (current_instance == 0) {
+ WARN_PRINTS("Recording should not be set as active before Godot has initialized.");
+ recording_active = false;
+ return;
+ }
+
ensure_thread_stopped();
current_instance->init();
}
- should_record = p_record;
+ recording_active = p_record;
}
-bool AudioEffectRecord::get_should_record() const {
- return should_record;
+bool AudioEffectRecord::is_recording_active() const {
+ return recording_active;
}
void AudioEffectRecord::set_format(AudioStreamSample::Format p_format) {
@@ -244,13 +250,12 @@ Ref<AudioStreamSample> AudioEffectRecord::get_recording() const {
}
void AudioEffectRecord::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_should_record", "record"), &AudioEffectRecord::set_should_record);
- ClassDB::bind_method(D_METHOD("get_should_record"), &AudioEffectRecord::get_should_record);
+ ClassDB::bind_method(D_METHOD("set_recording_active", "record"), &AudioEffectRecord::set_recording_active);
+ ClassDB::bind_method(D_METHOD("is_recording_active"), &AudioEffectRecord::is_recording_active);
ClassDB::bind_method(D_METHOD("set_format", "format"), &AudioEffectRecord::set_format);
ClassDB::bind_method(D_METHOD("get_format"), &AudioEffectRecord::get_format);
ClassDB::bind_method(D_METHOD("get_recording"), &AudioEffectRecord::get_recording);
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "should_record"), "set_should_record", "get_should_record");
ADD_PROPERTY(PropertyInfo(Variant::INT, "format", PROPERTY_HINT_ENUM, "8-Bit,16-Bit,IMA-ADPCM"), "set_format", "get_format");
}
diff --git a/servers/audio/effects/audio_effect_record.h b/servers/audio/effects/audio_effect_record.h
index 05c2d7352f..e4f5ba8a23 100644
--- a/servers/audio/effects/audio_effect_record.h
+++ b/servers/audio/effects/audio_effect_record.h
@@ -78,7 +78,7 @@ class AudioEffectRecord : public AudioEffect {
IO_BUFFER_SIZE_MS = 1500
};
- bool should_record;
+ bool recording_active;
Ref<AudioEffectRecordInstance> current_instance;
AudioStreamSample::Format format;
@@ -91,8 +91,8 @@ protected:
public:
Ref<AudioEffectInstance> instance();
- void set_should_record(bool p_record);
- bool get_should_record() const;
+ void set_recording_active(bool p_record);
+ bool is_recording_active() const;
void set_format(AudioStreamSample::Format p_format);
AudioStreamSample::Format get_format() const;
Ref<AudioStreamSample> get_recording() const;