The previous algorithm was incorrectly finding frame boundaries.
Now properly collects all sync code positions and returns the last one,
ensuring everything before it contains only complete frames.
Changes:
- Collect all sync code positions (0xFF 0xF8-0xFE) in buffer
- Return position of last sync code (start of incomplete frame)
- Everything before this is complete frames ready to send
- Require at least 2 sync codes to identify complete frames
- Lower threshold from 4KB to 1KB for better responsiveness
- Add detailed trace logging for debugging
This should fix "sample/frame number mismatch in adjacent frames" errors.