From 3d14705a0708686f48a7d2a9cee641724ca383cd Mon Sep 17 00:00:00 2001 From: Nanako <469449812@qq.com> Date: Fri, 22 Mar 2024 15:37:48 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=AF=E7=94=A8RtAudio?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/audio/device/audio_device_manager.cpp | 38 +++++++++++----------- core/audio/device/audio_device_manager.h | 2 +- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/core/audio/device/audio_device_manager.cpp b/core/audio/device/audio_device_manager.cpp index 787b267..83f9516 100644 --- a/core/audio/device/audio_device_manager.cpp +++ b/core/audio/device/audio_device_manager.cpp @@ -31,7 +31,7 @@ void audio_device_manager::start() { if (input_params_.deviceId != 0) { input_params = &input_params_; } - // audio_.openStream(&output_params_, input_params, RTAUDIO_FLOAT32, get_sample_rate(), &options_.numberOfBuffers, &rt_audio_callback, this, &options_); + audio_.openStream(&output_params_, input_params, RTAUDIO_FLOAT32, get_sample_rate(), &options_.numberOfBuffers, &rt_audio_callback, this, &options_); } uint32_t audio_device_manager::get_sample_rate() const { @@ -86,23 +86,23 @@ void audio_device_manager::render_thread() { const uint32_t frames = get_buffer_size(); const uint32_t rate = get_sample_rate(); - // while (audio_.isStreamRunning()) { - // const uint32_t milliseconds = 1.f / (rate / (frames / 4)) * 1000; - // - // g_audio_thread_hub.process_messages(); - // if (render_buffer_.Num() >= render_buffer_size_) { - // std::this_thread::sleep_for(std::chrono::milliseconds(milliseconds)); - // continue; - // } - // g_midi_sequencer.process(rate, frames); - // g_mixer.reset(); - // g_plugin_host_manager.process(frames); - // g_mixer.process(frames); - // - // const auto& master_headers = master->buffer.get_headers_vector(); - // for (const auto element: master_headers) { - // render_buffer_.Push(element, frames); - // } - // } + while (audio_.isStreamRunning()) { + const uint32_t milliseconds = 1.f / (rate / (frames / 4)) * 1000; + + g_audio_thread_hub.process_messages(); + if (render_buffer_.Num() >= render_buffer_size_) { + std::this_thread::sleep_for(std::chrono::milliseconds(milliseconds)); + continue; + } + g_midi_sequencer.process(rate, frames); + g_mixer.reset(); + g_plugin_host_manager.process(frames); + g_mixer.process(frames); + + const auto& master_headers = master->buffer.get_headers_vector(); + for (const auto element: master_headers) { + render_buffer_.Push(element, frames); + } + } spdlog::info("port_audio render thread stopped"); } diff --git a/core/audio/device/audio_device_manager.h b/core/audio/device/audio_device_manager.h index d623e83..bce5688 100644 --- a/core/audio/device/audio_device_manager.h +++ b/core/audio/device/audio_device_manager.h @@ -36,7 +36,7 @@ private: RtAudio::StreamParameters output_params_ = {}; RtAudio::StreamOptions options_ = {}; uint32_t sample_rate_ = 44100; - // RtAudio audio_; + RtAudio audio_; }; DEFINE_SINGLETON_INSTANCE(audio_device_manager)