Harden the guessed-stream sample-rate measurement that produced wrong rates (e.g. 44100 read as ~46205). New rate_estimator.hpp measures over longer ~0.5 s windows, rejects any window that doesn't snap to a standard rate (standard rates are >8% apart, so a quantization/burst error big enough to miss one lands in no-man's-land, never on a wrong neighbour), and requires consensus across windows before committing. If consensus isn't reached it commits a low-confidence estimate (new AudioFormat_LowConfidence, shown red) rather than spinning or publishing garbage. Pure logic, unit-tested with adversarial cadences (rate_estimator_test) incl. the real 46205 bug value. Add log severity levels: hook logw/loge set LogRecord.level; the host Log window colors warnings amber and errors red. The low-confidence rate logs a warning. Protocol -> v15 (new format states); also reserves AudioFormat_Override. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
42 lines
915 B
C++
42 lines
915 B
C++
// Log window: shows the log lines the injected hook streams over the shared log
|
|
// ring (see coop/log_ring.hpp). Pull new lines each frame from the IPC server,
|
|
// keep a bounded rolling history, and render them with autoscroll + a filter.
|
|
#pragma once
|
|
|
|
#include <cstdint>
|
|
#include <deque>
|
|
#include <string>
|
|
|
|
#include "coop/log_ring.hpp"
|
|
|
|
namespace coop
|
|
{
|
|
|
|
class InjectionPanel;
|
|
|
|
class LogPanel
|
|
{
|
|
public:
|
|
// Pull any new lines the hook emitted (call once per frame before draw()).
|
|
void pull(InjectionPanel& injection);
|
|
|
|
void draw();
|
|
|
|
private:
|
|
void add_line(const LogRecord& rec);
|
|
|
|
struct Line
|
|
{
|
|
std::string text;
|
|
std::uint32_t level; // LogLevel, for colouring
|
|
};
|
|
std::deque<Line> lines_;
|
|
char filter_[96] = {};
|
|
bool autoscroll_ = true;
|
|
std::uint64_t first_millis_ = 0; // hook clock at the first line, for relative timestamps
|
|
|
|
static constexpr std::size_t kMaxLines = 2000;
|
|
};
|
|
|
|
} // namespace coop
|