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>
25 lines
807 B
C++
25 lines
807 B
C++
// Lightweight logger for the injected hook. We can't see stdout from an injected
|
|
// DLL, so each line is (a) streamed to the host over the shared log ring for the
|
|
// in-app Log window, and (b) optionally written to %TEMP%\coop_hook.log (opt-in;
|
|
// see debug_log.cpp). Thread-safe; cheap enough to leave compiled in.
|
|
#pragma once
|
|
|
|
namespace coop
|
|
{
|
|
struct LogRing;
|
|
}
|
|
|
|
namespace coop::hook
|
|
{
|
|
|
|
// Append a printf-style line to the log ring (if attached) and the file (if on).
|
|
// logf = info, logw = warning, loge = error; the host colours the Log window by level.
|
|
void logf(const char* fmt, ...);
|
|
void logw(const char* fmt, ...);
|
|
void loge(const char* fmt, ...);
|
|
|
|
// Attach/detach the host's shared log ring so lines stream to the Log window.
|
|
void set_log_ring(coop::LogRing* ring);
|
|
|
|
} // namespace coop::hook
|