修复退出时崩溃
This commit is contained in:
parent
57151f25d2
commit
36855e65a7
@ -95,38 +95,36 @@ void draw_volume_bar(uint64_t uid, float height, circular_buffer_vector_type& in
|
||||
std::vector<float> sample_value;
|
||||
std::vector<float> sample_peak;
|
||||
|
||||
if (get_mixer()->is_ready()) {
|
||||
for (int32_t i = 0; i < in_buffer.size(); ++i) {
|
||||
auto& buffer = in_buffer.at(i);
|
||||
if (!volume_bar_peak_map.contains(uid)) {
|
||||
volume_bar_peak_map[uid].resize(in_buffer.size());
|
||||
}
|
||||
volume_bar_peak_info& peak_info = volume_bar_peak_map[uid].at(i);
|
||||
|
||||
// calculate peak
|
||||
uint32_t count = std::min(delta_sample_count, buffer.num());
|
||||
temp_buffer.resize(count);
|
||||
buffer.pop(temp_buffer.data(), count);
|
||||
auto peak_it = std::max_element(temp_buffer.begin(), temp_buffer.end(), [](sample_t a, sample_t b) {
|
||||
return std::abs(a) < std::abs(b);
|
||||
});
|
||||
sample_t peak = std::abs(*peak_it);
|
||||
|
||||
// update peak
|
||||
if (peak > peak_info.peak) {
|
||||
peak_info.peak = peak;
|
||||
peak_info.left_time = volume_bar_peak_duration;
|
||||
} else {
|
||||
peak_info.left_time -= delta_time;
|
||||
if (peak_info.left_time < 0.0f) {
|
||||
peak_info.peak -= delta_time * volume_bar_peak_decay;
|
||||
peak_info.left_time = 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
sample_value.push_back(peak);
|
||||
sample_peak.push_back(peak_info.peak);
|
||||
for (int32_t i = 0; i < in_buffer.size(); ++i) {
|
||||
auto& buffer = in_buffer.at(i);
|
||||
if (!volume_bar_peak_map.contains(uid)) {
|
||||
volume_bar_peak_map[uid].resize(in_buffer.size());
|
||||
}
|
||||
volume_bar_peak_info& peak_info = volume_bar_peak_map[uid].at(i);
|
||||
|
||||
// calculate peak
|
||||
uint32_t count = std::min(delta_sample_count, buffer.num());
|
||||
temp_buffer.resize(count);
|
||||
buffer.pop(temp_buffer.data(), count);
|
||||
auto peak_it = std::max_element(temp_buffer.begin(), temp_buffer.end(), [](sample_t a, sample_t b) {
|
||||
return std::abs(a) < std::abs(b);
|
||||
});
|
||||
sample_t peak = std::abs(*peak_it);
|
||||
|
||||
// update peak
|
||||
if (peak > peak_info.peak) {
|
||||
peak_info.peak = peak;
|
||||
peak_info.left_time = volume_bar_peak_duration;
|
||||
} else {
|
||||
peak_info.left_time -= delta_time;
|
||||
if (peak_info.left_time < 0.0f) {
|
||||
peak_info.peak -= delta_time * volume_bar_peak_decay;
|
||||
peak_info.left_time = 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
sample_value.push_back(peak);
|
||||
sample_peak.push_back(peak_info.peak);
|
||||
}
|
||||
draw_volume_bar(uid, height, sample_value, sample_peak);
|
||||
}
|
||||
|
2
Arona/third_party/imgui
vendored
2
Arona/third_party/imgui
vendored
@ -1 +1 @@
|
||||
Subproject commit 79b37f14318110c08d72c26003f622bf6bbdcb54
|
||||
Subproject commit 105fdd1bbb3233d3eee36bc4cc13d0f10eb2890d
|
@ -1 +1 @@
|
||||
Subproject commit e77638960cb7714544854e954d3b6f4e99432801
|
||||
Subproject commit 065448c5a303d55baca3cbb7e98b75b5e78c3072
|
Loading…
x
Reference in New Issue
Block a user