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
This commit is contained in:
Gustav Lund 2018-07-27 09:41:40 +02:00
parent b5b8f52d4f
commit 0672fc377e
2 changed files with 18 additions and 13 deletions

View File

@ -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");
}

View File

@ -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;