Summary
Debug and runtime configuration use inconsistent mechanisms: the encoder takes a growing set of boolean flags via constructor/setters, while the decoder reads debug switches from global environment variables; and the library encode/decode entry points silently read process environment variables for thread limits. This couples library behavior to ambient process state and makes the codec hard to drive from tests or as an embedded library.
Affected areas
src/codec/lac/thread_limit.hpp
src/utils/logger.hpp
src/codec/lac/encoder.hpp / src/codec/block/encoder.hpp
src/codec/block/decoder.cpp
Problem details
- Hidden env coupling inside library calls.
resolve_thread_limit calls std::getenv("LAC_THREADS") (thread_limit.hpp:30-33) from deep inside Encoder::encode / Decoder::decode. A library call thus depends on process environment, is not thread-safe against setenv, and has unclear precedence against the explicit --threads / set_thread_count path.
- Two debug mechanisms for one codec. The encoder threads debug state through booleans
debug_lpc / debug_zr / debug_partitions / debug_stereo_est (lac/encoder.hpp:34-41, block/encoder.hpp:22-28), each with its own setter, while the decoder reads LAC_DEBUG_ZR / LAC_DEBUG_PART via macros (decoder.cpp:66-67, logger.hpp:18-40).
- Boolean-flag soup. The block/encoder configuration is a pile of independent booleans plus
block_index, all set individually — a configuration-object smell that grows with each new debug switch.
- Debug logging writes
std::cerr unsynchronized from multi-threaded encode/decode (logger.hpp:49), so concurrent worker output can interleave.
Acceptance criteria
- Thread-limit resolution does not read environment variables from inside the codec; the CLI resolves
LAC_THREADS / --threads and passes an explicit value to the library.
- A single configuration mechanism (e.g. one options struct) covers encoder and decoder debug/tuning switches, instead of constructor booleans on one side and env-var macros on the other.
- Documented, deterministic precedence for any remaining environment-driven behavior.
- Concurrent debug logging does not interleave (or is documented as debug-only/unsupported under threading).
Summary
Debug and runtime configuration use inconsistent mechanisms: the encoder takes a growing set of boolean flags via constructor/setters, while the decoder reads debug switches from global environment variables; and the library encode/decode entry points silently read process environment variables for thread limits. This couples library behavior to ambient process state and makes the codec hard to drive from tests or as an embedded library.
Affected areas
src/codec/lac/thread_limit.hppsrc/utils/logger.hppsrc/codec/lac/encoder.hpp/src/codec/block/encoder.hppsrc/codec/block/decoder.cppProblem details
resolve_thread_limitcallsstd::getenv("LAC_THREADS")(thread_limit.hpp:30-33) from deep insideEncoder::encode/Decoder::decode. A library call thus depends on process environment, is not thread-safe againstsetenv, and has unclear precedence against the explicit--threads/set_thread_countpath.debug_lpc/debug_zr/debug_partitions/debug_stereo_est(lac/encoder.hpp:34-41,block/encoder.hpp:22-28), each with its own setter, while the decoder readsLAC_DEBUG_ZR/LAC_DEBUG_PARTvia macros (decoder.cpp:66-67,logger.hpp:18-40).block_index, all set individually — a configuration-object smell that grows with each new debug switch.std::cerrunsynchronized from multi-threaded encode/decode (logger.hpp:49), so concurrent worker output can interleave.Acceptance criteria
LAC_THREADS/--threadsand passes an explicit value to the library.