diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2020-01-20 13:11:47 +0100 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2020-01-20 13:18:01 +0100 |
commit | 837adb30fd92406c266b9a7ac2a652db2e38cfcc (patch) | |
tree | 61b8fafb842bdaeadcc403b728e7e9bf2555eda3 /servers/audio | |
parent | c3fd1012de2d0913a375ddfe6ee93035fe5260eb (diff) |
Revert "Exposes capture methods to AudioServer + documentation" #30468
Reverts the following commits:
- c81ec6f26d40b70283958a4ef3e216fb32cbaf14:
"Exposes capture methods to AudioServer, variable renames for
consistency, added documentation."
- 47c558b98abf842910c780294314326662410cdf:
"Expose audio callbacks as signals."
- dabaa11b3c451e9b8f2cca7e563bd9ec51edb169:
"Fix to make sure the capture buffers are deallocated at shutdown.
Silences warnings."
Some documentation improvements were kept for pre-existing methods.
See rationale for reverting these changes in #30468.
Diffstat (limited to 'servers/audio')
-rw-r--r-- | servers/audio/audio_stream.cpp | 42 | ||||
-rw-r--r-- | servers/audio/audio_stream.h | 2 |
2 files changed, 22 insertions, 22 deletions
diff --git a/servers/audio/audio_stream.cpp b/servers/audio/audio_stream.cpp index 6b286e09e9..58742c82d4 100644 --- a/servers/audio/audio_stream.cpp +++ b/servers/audio/audio_stream.cpp @@ -134,31 +134,31 @@ AudioStreamMicrophone::AudioStreamMicrophone() { void AudioStreamPlaybackMicrophone::_mix_internal(AudioFrame *p_buffer, int p_frames) { - AudioServer::get_singleton()->lock(); + AudioDriver::get_singleton()->lock(); - PoolVector<int32_t> capture_buffer = AudioServer::get_singleton()->get_capture_buffer(); - unsigned int capture_size = AudioServer::get_singleton()->get_capture_size(); - int mix_rate = AudioServer::get_singleton()->get_mix_rate(); - unsigned int playback_delay = MIN(((50 * mix_rate) / 1000) * 2, capture_buffer.size() >> 1); + Vector<int32_t> buf = AudioDriver::get_singleton()->get_input_buffer(); + unsigned int input_size = AudioDriver::get_singleton()->get_input_size(); + int mix_rate = AudioDriver::get_singleton()->get_mix_rate(); + unsigned int playback_delay = MIN(((50 * mix_rate) / 1000) * 2, buf.size() >> 1); #ifdef DEBUG_ENABLED - unsigned int capture_position = AudioServer::get_singleton()->get_capture_position(); + unsigned int input_position = AudioDriver::get_singleton()->get_input_position(); #endif - if (playback_delay > capture_size) { + if (playback_delay > input_size) { for (int i = 0; i < p_frames; i++) { p_buffer[i] = AudioFrame(0.0f, 0.0f); } - capture_ofs = 0; + input_ofs = 0; } else { for (int i = 0; i < p_frames; i++) { - if (capture_size > capture_ofs && (int)capture_ofs < capture_buffer.size()) { - float l = (capture_buffer[capture_ofs++] >> 16) / 32768.f; - if ((int)capture_ofs >= capture_buffer.size()) { - capture_ofs = 0; + if (input_size > input_ofs && (int)input_ofs < buf.size()) { + float l = (buf[input_ofs++] >> 16) / 32768.f; + if ((int)input_ofs >= buf.size()) { + input_ofs = 0; } - float r = (capture_buffer[capture_ofs++] >> 16) / 32768.f; - if ((int)capture_ofs >= capture_buffer.size()) { - capture_ofs = 0; + float r = (buf[input_ofs++] >> 16) / 32768.f; + if ((int)input_ofs >= buf.size()) { + input_ofs = 0; } p_buffer[i] = AudioFrame(l, r); @@ -169,12 +169,12 @@ void AudioStreamPlaybackMicrophone::_mix_internal(AudioFrame *p_buffer, int p_fr } #ifdef DEBUG_ENABLED - if (capture_ofs > capture_position && (int)(capture_ofs - capture_position) < (p_frames * 2)) { - print_verbose(String(get_class_name()) + " buffer underrun: capture_position=" + itos(capture_position) + " capture_ofs=" + itos(capture_ofs) + " capture_size=" + itos(capture_size)); + if (input_ofs > input_position && (int)(input_ofs - input_position) < (p_frames * 2)) { + print_verbose(String(get_class_name()) + " buffer underrun: input_position=" + itos(input_position) + " input_ofs=" + itos(input_ofs) + " input_size=" + itos(input_size)); } #endif - AudioServer::get_singleton()->unlock(); + AudioDriver::get_singleton()->unlock(); } void AudioStreamPlaybackMicrophone::mix(AudioFrame *p_buffer, float p_rate_scale, int p_frames) { @@ -196,9 +196,9 @@ void AudioStreamPlaybackMicrophone::start(float p_from_pos) { return; } - capture_ofs = 0; + input_ofs = 0; - if (AudioServer::get_singleton()->capture_start() == OK) { + if (AudioDriver::get_singleton()->capture_start() == OK) { active = true; _begin_resample(); } @@ -206,7 +206,7 @@ void AudioStreamPlaybackMicrophone::start(float p_from_pos) { void AudioStreamPlaybackMicrophone::stop() { if (active) { - AudioServer::get_singleton()->capture_stop(); + AudioDriver::get_singleton()->capture_stop(); active = false; } } diff --git a/servers/audio/audio_stream.h b/servers/audio/audio_stream.h index 58775c3d94..6d62eabec1 100644 --- a/servers/audio/audio_stream.h +++ b/servers/audio/audio_stream.h @@ -123,7 +123,7 @@ class AudioStreamPlaybackMicrophone : public AudioStreamPlaybackResampled { friend class AudioStreamMicrophone; bool active; - unsigned int capture_ofs; + unsigned int input_ofs; Ref<AudioStreamMicrophone> microphone; |