修复退出时崩溃
This commit is contained in:
@@ -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_value;
|
||||||
std::vector<float> sample_peak;
|
std::vector<float> sample_peak;
|
||||||
|
|
||||||
if (get_mixer()->is_ready()) {
|
for (int32_t i = 0; i < in_buffer.size(); ++i) {
|
||||||
for (int32_t i = 0; i < in_buffer.size(); ++i) {
|
auto& buffer = in_buffer.at(i);
|
||||||
auto& buffer = in_buffer.at(i);
|
if (!volume_bar_peak_map.contains(uid)) {
|
||||||
if (!volume_bar_peak_map.contains(uid)) {
|
volume_bar_peak_map[uid].resize(in_buffer.size());
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
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);
|
draw_volume_bar(uid, height, sample_value, sample_peak);
|
||||||
}
|
}
|
||||||
|
|||||||
2
Arona/third_party/imgui
vendored
2
Arona/third_party/imgui
vendored
Submodule Arona/third_party/imgui updated: 79b37f1431...105fdd1bbb
Submodule AronaCore updated: e77638960c...065448c5a3
Reference in New Issue
Block a user