mirror of
https://github.com/storytold/effectcraft.git
synced 2026-10-24 10:09:32 -06:00
The freeze and quit during a FLAC preview did not reproduce on current main (Windows 11): a 4-minute stereo and a 10-minute 24-bit 6-channel 96 kHz FLAC played through a RAM preview with a real-time audio pull, after trimming and zooming, with no stall, no growing queue and memory bounded by the RAM preview budget; 150 cpal output start/stop cycles ran clean. Three defects in that path were found and fixed: - FilmCraft decodes FLAC, MP3, Ogg and AIFF files whole when they are opened (8 s and 1.4 GB for the 10-minute 6-channel file). MediaPool opened a file outside its lock, so every caller asking before the first open finished decoded the whole file too: a preview's frame workers, audio feeder, conform and waveform threads at once (8 reads at once: 8 decodes). Each path now opens once; the others wait for it. - AudioPlayback::start mixed its first 50 ms on the calling (UI) thread, so the first read of such a file froze the UI for the whole decode (audio-only previews start the sound right away). All mixing is on the feeder thread now; the device plays silence until the first block arrives, and the clock (frames actually played) waits for it. - Conforming (Settings > Disk > Conformed Audio Folder, on by default) held the whole conformed track in memory before writing it, sized by the footage duration from the file's header: a header claiming a month of audio aborted the app on a failed 995 GB allocation. The conformed file is now written a chunk at a time, and footage longer than 24 hours is read from its decoder instead of conformed. Tests: media concurrent_first_reads_open_a_file_once (8 threads: 8 opens before, 1 now; PoolStats::opened), pool a_header_claiming_a_month_of_audio_is_not_conformed (aborted before), ui-egui audio starting_audio_does_not_wait_for_slow_footage (start took the footage's 2 s before), conformed_flac_audio_reads_back_like_the_ decoder, and the robustness test flac_audio_of_any_shape_reads_in_ device_blocks (2 minutes of 24-bit 6-channel 96 kHz, mono 8 kHz, 11.025 kHz, 192 kHz and 8-channel FLAC read in 1024-frame blocks at 48 kHz through and past the end: level, silence after the end, opened once). FLAC fixtures come from ffmpeg (skipped without it). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>