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 543

Summary: Add FLAC audio support
Product: SDL_mixer Reporter: Austen Dicken <cvpcsm>
Component: miscAssignee: Austen Dicken <cvpcsm>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: enhancement    
Priority: P2    
Version: unspecified   
Hardware: x86   
OS: Linux   
Attachments: Patch to add/modify files for FLAC support
Patch to add/modify files for FLAC support

Description Austen Dicken 2008-01-28 19:53:29 UTC
I was thinking it would be great to add support for the Free Lossless Audio Codec (FLAC), so I have been working on a patch to the current SVN checkout of SDL_mixer that would add support for it.

I am just kind of curious as to whether anyone thinks this would be a good idea?  I am about 1/2 way done with the patch and then was going to start testing.

Any thoughts and/or suggestions would be greatly appreciated. ^.^
Comment 1 Sam Lantinga 2008-01-28 21:13:16 UTC
Sure, why not?  Thanks! :)
Comment 2 Austen Dicken 2008-01-30 11:23:35 UTC
Good news!  FLAC files are currently playing using the bundled "playmus" program!  I still need to do a bit more testing as I know the load_flac.c file isn't working right, but I should have a patch for you by tonight or tomorrow!
Comment 3 Sam Lantinga 2008-01-30 13:05:34 UTC
Great, thanks!
Comment 4 Austen Dicken 2008-01-30 19:14:05 UTC
Created attachment 247 [details]
Patch to add/modify files for FLAC support

Ok, here is the patch I made for FLAC support.

I have tested it relatively thoroughly and currently the patch allows:
 1. Pre-loading FLAC files and playing them via LoadWAV
 2. The patch allows for FLAC support in the LoadMUS setting as well as:
     *  Pause / Resume
     *  Volume control
     *  Seeking

I also did a little benchmarking by comparing memory/cpu usage of playmus to that of mplayer, and the results were very good.  playmus typically took about half the RAM as mplayer, though that may be attributed to mplayer being a more "bulky" program.  As such I would say that the two are probably about equal in efficiency.

Also, it is important to note that, similar to the OGG support currently built-in, my FLAC patch only supports 16 bit stereo-encoded sound.  Also, it
is only for Native FLAC (standard) and not the derivative, Ogg-FLAC.

I have tried to find a simple way to detect Ogg-FLAC files, as the only difference between Ogg-FLAC and Native FLAC support is changing the init_ function call, but after digging a little deeper it seems that Ogg-FLAC is basically FLAC wrapped in an Ogg transport layer, so it would be better to have a way to read the Ogg transport layer which then reads the inner audio files according to the proper codec.

But anyway, that's another job for another day!  For now this should provide Native FLAC support!
Comment 5 Austen Dicken 2008-02-03 21:33:44 UTC
Created attachment 248 [details]
Patch to add/modify files for FLAC support

I was continuing my testing of this patch and noticed an error where I was calling .ogg instead of .flac in a particular music union structure.
Comment 6 Austen Dicken 2008-02-03 21:36:04 UTC
I just had a quick question.  I noticed that I have been assigned to this bug and was wondering what connotations that brings along with it.  I am relatively new to the community development model and am not entirely sure of what my role is so far as what I should be doing to resolve this feature and the like.
Comment 7 Sam Lantinga 2008-02-04 11:44:21 UTC
It's just an internal note so we don't assume that we're responsible for implementing the functionality.  By providing a patch and serving as a contact for related bugs, you're fulfilling your role as assignee. We'll apply the patch and run some basic testing and verification of it.

Thanks!
Comment 8 Sam Lantinga 2008-02-26 23:31:58 UTC
This has been added to subversion.  Thanks!
Comment 9 Austen Dicken 2008-02-27 00:24:50 UTC
Glad to be of assistance. :)