1. 移除ui_buffer的延迟
2. 修复删除混音轨道的插件时导致的崩溃
This commit is contained in:
parent
e74ecd2250
commit
3c10185a8a
@ -188,7 +188,6 @@ void mixer_processor::update_latency() {
|
||||
const int32_t track_latency = link->from()->get_latency();
|
||||
const int32_t to_master_latency = latency_diff - track_latency;
|
||||
link->compensator().set_latency(to_master_latency);
|
||||
link->from()->set_ui_buffer_latency(to_master_latency);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include "channel_interface.h"
|
||||
#include "audio/device/audio_device_manager.h"
|
||||
#include "audio/plugin_host/plugin_host.h"
|
||||
#include "audio/plugin_host/plugin_host_manager.h"
|
||||
#include "thread_message/thread_message_hubs.h"
|
||||
|
||||
mixer_track::~mixer_track() {
|
||||
@ -10,7 +11,7 @@ mixer_track::~mixer_track() {
|
||||
channel_interface_ = nullptr;
|
||||
for (auto e : effects_) {
|
||||
// e->on_latency_changed.remove_all(this);
|
||||
delete_effect(this, e);
|
||||
get_plugin_host_manager()->remove_effect_plugin_host(e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -37,13 +38,12 @@ void mixer_track::add_effect(plugin_host* in_effect) {
|
||||
}
|
||||
|
||||
void mixer_track::remove_effect(plugin_host* in_effect) {
|
||||
in_effect->try_close_editor();
|
||||
g_audio_thread_hub.push_message([in_effect, this] {
|
||||
auto remove_effect_track = std::remove(in_effect->owner_tracks.begin(), in_effect->owner_tracks.end(), this);
|
||||
in_effect->owner_tracks.erase(remove_effect_track, in_effect->owner_tracks.end());
|
||||
|
||||
auto remove_effect = std::remove(effects_.begin(), effects_.end(), in_effect);
|
||||
effects_.erase(remove_effect, effects_.end());
|
||||
const auto f = std::ranges::find(effects_, in_effect);
|
||||
effects_.erase(f);
|
||||
});
|
||||
get_plugin_host_manager()->remove_effect_plugin_host(in_effect);
|
||||
}
|
||||
|
||||
void mixer_track::process(uint32_t in_frames) {
|
||||
@ -59,16 +59,6 @@ auto mixer_track::get_latency() const -> int32_t {
|
||||
return latency;
|
||||
}
|
||||
|
||||
void mixer_track::set_ui_buffer_latency(int32_t in_latency) {
|
||||
const uint32_t block_size = g_audio_device_manager.get_buffer_size();
|
||||
const int32_t block_num = std::ceil((float)in_latency / block_size) + 4;
|
||||
|
||||
for (auto& buffer : ui_buffers_) {
|
||||
buffer.set_capacity(block_num * block_size);
|
||||
buffer.push_zeros(in_latency);
|
||||
}
|
||||
}
|
||||
|
||||
void mixer_track::push_ui_buffer(const audio_buffer& in_buffer) {
|
||||
auto headers = in_buffer.get_headers_vector();
|
||||
for (const auto& header : std::ranges::views::zip(headers, ui_buffers_)) {
|
||||
@ -91,11 +81,3 @@ auto instrument_track::get_name() const -> std::string {
|
||||
auto instrument_track::get_latency() const -> int32_t {
|
||||
return mixer_track::get_latency() + instrument_->get_latency() + instrument_->get_user_latency();
|
||||
}
|
||||
|
||||
void delete_effect(mixer_track* track, plugin_host* host) {
|
||||
track->remove_effect(host);
|
||||
host->try_close_editor();
|
||||
g_audio_thread_hub.push_message([host, track]() {
|
||||
delete host;
|
||||
});
|
||||
}
|
||||
|
@ -59,7 +59,6 @@ public:
|
||||
return get_name() + "##" + std::to_string(id_);
|
||||
}
|
||||
|
||||
void set_ui_buffer_latency(int32_t in_latency);
|
||||
void push_ui_buffer(const audio_buffer& in_buffer);
|
||||
|
||||
[[nodiscard]] auto get_ui_buffer() -> circular_buffer_vector_type& { return ui_buffers_;}
|
||||
@ -104,5 +103,3 @@ public:
|
||||
private:
|
||||
std::string name_;
|
||||
};
|
||||
|
||||
CORE_API void delete_effect(mixer_track* track, plugin_host* host);
|
||||
|
@ -1,12 +1,19 @@
|
||||
#include "plugin_host.h"
|
||||
|
||||
#include "audio/mixer/channel_interface.h"
|
||||
#include "audio/mixer/latency_compensator.h"
|
||||
#include "window/window_manager.h"
|
||||
|
||||
plugin_host::~plugin_host() {
|
||||
delete channel;
|
||||
}
|
||||
|
||||
void plugin_host::begin_release() {
|
||||
int32_t latency = get_latency();
|
||||
if (latency > 0)
|
||||
on_latency_offset_changed.broadcast();
|
||||
}
|
||||
|
||||
void plugin_host::on_update_buffer_size(int buffer_size)
|
||||
{
|
||||
ui_buffers = std::make_shared<circular_buffer_vector_type>();
|
||||
|
@ -35,6 +35,7 @@ public:
|
||||
, type_(in_type) {}
|
||||
|
||||
virtual ~plugin_host();
|
||||
virtual void begin_release();
|
||||
|
||||
[[nodiscard]] uint64_t get_uid() const { return id; }
|
||||
[[nodiscard]] plugin_host_type get_type() const { return type_; }
|
||||
|
@ -36,6 +36,19 @@ plugin_host* plugin_host_manager::create_effect_plugin_host(const char* path) {
|
||||
return host;
|
||||
}
|
||||
|
||||
void plugin_host_manager::remove_effect_plugin_host(plugin_host* in_host) {
|
||||
g_audio_thread_hub.push_message([in_host, this]() {
|
||||
auto find = std::ranges::find(plugin_hosts_, in_host);
|
||||
if (find != plugin_hosts_.end()) {
|
||||
plugin_hosts_.erase(find);
|
||||
g_main_thread_hub.push_message([in_host, this]() {
|
||||
in_host->begin_release();
|
||||
delete in_host;
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
plugin_host* plugin_host_manager::create_instrument_plugin_host(const char* path) {
|
||||
auto host = load_plugin(path);
|
||||
if (host) {
|
||||
@ -53,6 +66,7 @@ void plugin_host_manager::remove_instrument_plugin_host(plugin_host* host) {
|
||||
instrument_plugins_.erase(find);
|
||||
g_main_thread_hub.push_message([host, this]() {
|
||||
on_instrument_removed.broadcast(host);
|
||||
host->begin_release();
|
||||
delete host;
|
||||
});
|
||||
update_taskflow(g_audio_device_manager.get_buffer_size());
|
||||
|
@ -16,7 +16,8 @@ public:
|
||||
|
||||
void release(singleton_release_guard& release_guard) override;
|
||||
|
||||
plugin_host* create_effect_plugin_host(const char* path);
|
||||
auto create_effect_plugin_host(const char* path) -> plugin_host*;
|
||||
void remove_effect_plugin_host(plugin_host* in_host);
|
||||
|
||||
plugin_host* create_instrument_plugin_host(const char* path);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user