feat: inline timestamp markers for offline audio segments#4851
feat: inline timestamp markers for offline audio segments#4851
Conversation
Add recording_start_time tracking to the SD card storage layer. The info.txt file is extended from 4 bytes (offset only) to 8 bytes (offset + recording start time) with backward-compatible reading.
Extend the storage read characteristic from 2 to 3 uint32 values to include the recording start time alongside file size and offset.
Add write_timestamp_to_storage() to write a 5-byte marker (0xFF + 4-byte LE epoch) before the first audio frame of each offline recording segment. Add storage_flush_buffer() to flush pending data on shutdown. Reset the marker flag on each BLE connect so subsequent offline sessions get fresh timestamps.
Call storage_flush_buffer() in turnoff_all() to ensure any pending audio data in the write buffer is persisted before powering off the SD card.
Parse inline timestamp markers in both BLE and WiFi sync paths to split audio into properly-timed WAL segments. Also fix chunk size calculation to use actual codec FPS instead of hardcoded values, and derive WAL duration from actual frame count rather than a fixed 60-second assumption.
There was a problem hiding this comment.
Code Review
This pull request successfully implements a valuable feature by embedding inline timestamp markers in offline audio recordings, allowing for accurate segmentation. The firmware and app changes are well-executed, with robust logic for handling the new data format and maintaining backward compatibility. However, the review identified two high-severity issues that should be addressed: unrelated logging configuration changes in omi.conf that appear to be development artifacts, and the removal of a necessary header file in sd_card.c which could compromise build stability. Once these points are resolved, the pull request will be in excellent shape.
Instead of flushing immediately when a 0xFF timestamp marker is encountered during BLE streaming, record markers and their frame indices. Split segments at marker boundaries only during the normal chunking phase, preventing tiny 5-second WAL fragments.
Split from #4851 - app changes only. Parses 0xFF timestamp markers from the offline audio stream and fixes WAL segment timing during SD card sync. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Split from #4851 - firmware changes only. Adds inline 0xFF timestamp markers in the offline audio stream, exposes recording start time via BLE, and flushes storage buffer on shutdown. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Hey @mdmohsin7 👋 Thank you so much for taking the time to contribute to Omi! We truly appreciate you putting in the effort to submit this pull request. After careful review, we've decided not to merge this particular PR. Please don't take this personally — we genuinely try to merge as many contributions as possible, but sometimes we have to make tough calls based on:
Your contribution is still valuable to us, and we'd love to see you contribute again in the future! If you'd like feedback on how to improve this PR or want to discuss alternative approaches, please don't hesitate to reach out. Thank you for being part of the Omi community! 💜 |
#5572) ## Summary - Parses inline `0xFF` timestamp markers from the offline audio data stream so each recording segment has an exact UTC start time - Fixes WAL timing bugs: chunk size now uses actual codec FPS, and WAL duration derives from real frame count instead of a hardcoded 60-second assumption - Splits audio into correctly-timed WAL segments based on timestamp markers Split from #4851 — app changes only. See #5571 for the firmware counterpart. ### App changes - **sdcard_wal_sync.dart**: Gates all timestamp marker logic on firmware version `>= 3.0.16` using `_supportsTimestampMarkers()`. Old firmware uses the original legacy parsing path unchanged. New firmware uses marker-aware parsing in both BLE and WiFi sync paths, splitting audio into correctly-timed WAL segments. Also fixes chunk size from `sdcardChunkSizeSecs * 100` to `sdcardChunkSizeSecs * codec.getFramesPerSecond()` (new firmware path only). ### Firmware version gating - **Old firmware (< 3.0.16)**: Takes the `_readStorageBytesToFileLegacy()` path — identical to current `main` branch behavior. No marker detection, no new chunking logic. - **New firmware (>= 3.0.16)**: Takes the `_readStorageBytesToFileWithMarkers()` path — parses `0xFF` markers, splits segments by timestamp boundaries, uses device-provided recording start time. ## Test plan - [ ] Connect with old firmware (< 3.0.16) → verify BLE sync works identically to current behavior - [ ] Connect with new firmware (>= 3.0.16) → disconnect BLE → record ~1 min offline → reconnect → sync - [ ] Verify app shows WAL segments with correct timestamps from device-provided epochs - [ ] Test WiFi sync path with both old and new firmware 🤖 Generated with [Claude Code](https://claude.com/claude-code)

Summary
0xFFtimestamp markers in the offline audio data stream so each recording segment (between BLE disconnects or power cycles) has an exact UTC start timeinfo.txton SD card from 4 to 8 bytes to persist a recording start time alongside the read offsetFirmware changes
write_timestamp_to_storage()injects a 5-byte marker (0xFF+ 4-byte LE epoch) before the first offline audio frame of each segment.storage_flush_buffer()flushes pending data on shutdown.needs_timestamp_markerflag resets on each BLE connect.recording_start_timepersisted ininfo.txt(backward-compatible 8-byte format)[file_size, offset, recording_start_time]storage_flush_buffer()beforeapp_sd_off()inturnoff_all()App changes
0xFFmarkers in both BLE and WiFi sync paths, splits audio into correctly-timed WAL segments. Fixes chunk size fromsdcardChunkSizeSecs * 100tosdcardChunkSizeSecs * codec.getFramesPerSecond().Backward compatibility
Test plan