We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 4680

Summary: FLAC playback initially stutters
Product: SDL_mixer Reporter: Braden Obrzut <admin>
Component: miscAssignee: Ryan C. Gordon <icculus>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2 CC: mikeguy42, sezeroz
Version: 2.0.4   
Hardware: x86_64   
OS: Linux   
Attachments: Patch - music_flac.c - Fix Initial Stutter

Description Braden Obrzut 2019-06-21 10:06:47 UTC
When playing a FLAC file the first frame will be repeated.  This is caused by FLAC__stream_decoder_seek_absolute automatically processing a frame, which in turn causes the callback to be run which puts data on the audio stream.  Since FLAC_Play calls FLAC_Seek the frame is decoded there, and then music_internal_play decides to also seek to 0 with music_internal_position causing the frame to be decoded a second time.

Given that all of the Play functions call Seek I'm not sure why music_internal_play needs to do a seek to 0.  But removing that won't be perfect since if a position besides 0 is given the FLAC player will still decode the first frame before starting at the seeked position.  Probably the correct solution is to clear the audio stream in FLAC_Seek.
Comment 1 Michael Day 2019-11-18 03:28:23 UTC
Created attachment 4059 [details]
Patch - music_flac.c - Fix Initial Stutter

I think the fix is as simple as clearing the audio stream before seeking. See the attached patch.
Comment 2 Ozkan Sezer 2019-11-18 04:51:10 UTC
Applied this patch: https://hg.libsdl.org/SDL_mixer/rev/7b663db4eef1

Braden Obrzut: Please make sure that this fixes your issue.
Comment 3 Ozkan Sezer 2019-12-03 11:59:37 UTC
No response from original bug reporter since two weeks.  Closing
as fixed.  Drop a note here if problem persists.