# Changelog ## v1.2.0 - Raspberry Pi 5 compatibility + deep bug-fix pass Target: Raspberry Pi 5 (BCM2712, Cortex-A76, aarch64 LP64, 8GB) & Ubuntu 24.04. ### Portability (new) - Added `include/portable.h` / `src/portable.c`: endian-safe big-endian wire writers/readers (PS/PES fields built by shift, never by char* casts, so correct under strict alignment and on any endianness); monotonic clock (`CLOCK_MONOTONIC`) instead of wall clock; `nanosleep`-based sleep (usleep is deprecated on newer glibc); `portable_thread_create` with explicit stack size (256KB) so worker threads behave predictably on the 8GB board. - Fixed `PTHREAD_STACK_MIN` signed-vs-unsigned comparison (would break `-Werror` on both x86_64 LP64 and aarch64). - All 64-bit logging uses `PRIu64` from `` (LP64-safe on aarch64). ### Bug fixes found & repaired this pass (build-gated under -Wall -Wextra -Werror) 1. `common.h` missing `/` -> byte/64-bit types undefined. 2. `platform.c` function-pointer type mismatch: `p_ecms_init` declared `void*(*)(void)` but assigned `void*(*)(void*)` (incompatible-pointer-types) and would mis-call the SDK init. 3. `platform.c` `NET_ECMS_GetLastError ? ... : ...` took the address of a function -> always true (dead ternary). Now calls the getter directly. 4. `config.c` unused static `kv()` + leftover `sep/key` dead vars (unused-function/unused-variable). 5. `main.c` getopt string had a stray space `"c: tsh"` and no grouping -> `-t`/`-s` parsing unreliable; corrected to `"c:tsh"`. 6. `main.c` self-test set `g_cfg.simulate=1` BEFORE `config_defaults()` which reset it to 0 -> self-test tried to dlopen the real SDK and failed. Reordered. 7. `stream.c` push(): logged `s->channel` AFTER releasing `s->lock` -> use-after-unlock race. Now snapshots channel/frames under the lock. 8. `stream.c` / `playback.c` session-table removal previously shift-compacted and dropped the tail slot (lost sessions + leaked mutexes). Now clear-in-place. 9. `stream.c` `stream_stats` / `playback.c` `playback_get_session` / `alarm.c` accessors triggered `-Wmisleading-indentation` (multi-`if` on one line). Rebraced for clarity and warning-clean build. 10. Alarm ring buffer overflow path now wraps `g_head` correctly (v1.0 lost events on wrap). ### Structure - 8 source files (portable/config/platform/stream/playback/alarm/main/isup_stub), 7 headers (portable/common/config/platform/stream/playback/alarm/isup_sdk). - `isup_stub.c`: mock ISUP SDK behind `-DISUP_SIM` so it compiles, links and self-tests on Pi5 with NO proprietary .so. Production: drop real aarch64 `libHCNetSDK.so` into `libs/` and `make` (no -DISUP_SIM). - Platform layer uses `dlopen` for the real SDK so the binary never hard-links against a library that may be absent. ### Verification (host x86_64 gcc 14.2, -Wall -Wextra -Werror) - `make simulate`: 0 warnings, 0 errors. - `./...-sim -t` self-test (register -> PS->RTMP 50 frames -> playback start/pause/resume/stop -> 2 alarms + ack -> logout): PASSED, exit 0. - `./...-sim -c config.ini -s` then SIGTERM: graceful shutdown, heartbeat thread joined, exit 0.