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 - FLAC playback initially stutters
Summary: FLAC playback initially stutters
Status: RESOLVED FIXED
Alias: None
Product: SDL_mixer
Classification: Unclassified
Component: misc (show other bugs)
Version: 2.0.4
Hardware: x86_64 Linux
: P2 normal
Assignee: Ryan C. Gordon
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-06-21 10:06 UTC by Braden Obrzut
Modified: 2019-12-03 11:59 UTC (History)
2 users (show)

See Also:


Attachments
Patch - music_flac.c - Fix Initial Stutter (575 bytes, patch)
2019-11-18 03:28 UTC, Michael Day
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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.