Browse Source

Fix false queue-full detection in audio diagnostics

master
evgeny 4 days ago
parent
commit
7d75afd4c5
  1. 3
      tools/chatgui/transport/audio_diagnostics.cpp

3
tools/chatgui/transport/audio_diagnostics.cpp

@ -59,6 +59,7 @@ void publish(const void* device, int kind, int stage, int64_t value, int64_t det
for (int attempt = 0; attempt < 4; ++attempt) {
auto& slot = queue[pos % kCapacity];
const auto seq = slot.sequence.load(std::memory_order_acquire);
if (seq < pos) break; // Полное кольцо; сравниваем с позицией именно этого slot.
if (seq == pos && writePosition.compare_exchange_weak(pos, pos + 1, std::memory_order_relaxed)) {
auto& e = slot.event;
e.device = reinterpret_cast<uintptr_t>(device); e.wall = wall; e.cpu = cpu;
@ -74,7 +75,7 @@ void publish(const void* device, int kind, int stage, int64_t value, int64_t det
slot.sequence.store(pos + 1, std::memory_order_release);
return;
}
if (seq < pos) break; // Полное кольцо.
// Неудачный CAS меняет pos: старый seq уже нельзя сравнивать с новой позицией.
pos = writePosition.load(std::memory_order_relaxed);
}
lost.fetch_add(1, std::memory_order_relaxed);

Loading…
Cancel
Save