diff options
author | Gustav Lund <glu@gamblify.com> | 2018-07-27 09:41:40 +0200 |
---|---|---|
committer | Gustav Lund <glu@gamblify.com> | 2018-07-27 09:52:54 +0200 |
commit | 0672fc377e1a95927c9efda05e54fd1101c91de6 (patch) | |
tree | 42fa3474bdca4b1d2d9fe2653df4d2149ce8fb1f /servers | |
parent | b5b8f52d4f96e019ed85174e117b766dcb703083 (diff) |
Fix of AudioRecordingEffect property
For debug purposes the boolean whether the recording is active or not were an editor property.
It has been removed to avoid users leaving it on true on close, causing it to be saved in the default_bus_layout
It was also renamed to better describe its functionality
related to issue: 20487
Diffstat (limited to 'servers')
-rw-r--r-- | servers/audio/effects/audio_effect_record.cpp | 25 | ||||
-rw-r--r-- | servers/audio/effects/audio_effect_record.h | 6 |
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; |