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 416

Summary: Inefficient Audio
Product: SDL Reporter: ajapted
Component: audioAssignee: Ryan C. Gordon <icculus>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2    
Version: 2.0.0   
Hardware: All   
OS: All   

Description ajapted 2007-03-14 20:07:04 UTC
I'm using my own mixer callback function with SDL's
audio system, and I noticed this awful SDL_memset()
on the target buffer before my callback is called.

I realise this is needed for SDL_MixAudio() to work,
but please provide a way to disable it.  My code
doesn't need it, so it's just wasting CPU cycles
(very significant at 44Khz 16-bit stereo).
Comment 1 Ryan C. Gordon 2007-03-14 20:16:21 UTC
This came up a few years ago, and honestly, I'm of the opinion that we don't need the memset at all...most apps fill the buffer completely (or write silence when they can't), and it should be considered a bug if they don't.

Maybe we should remove it and see what external code needs fixing.

--ryan.

Comment 2 Max Horn 2007-04-18 14:35:37 UTC
How about just removing it in 1.3 then?
Comment 3 Sam Lantinga 2007-07-04 01:25:57 UTC
Sounds good to me.  Ryan, you want to take this one?
Comment 4 Sam Lantinga 2007-07-04 14:38:46 UTC
Actually I'm moving this to 1.3, since this isn't something we want to change in 1.2.  The original idea was that it was supposed to simulate mixing into an existing audio stream.  BeOS audio works this way, and many other audio systems do this mixing behind the scenes anyway.

This change is fine to make in 1.3, but I don't want to break things flor 1.2 that assume that the buffer already has data in it (like SDL_mixer)

Ryan, if you have a strong opinion on this, I'm willing to be convinced. :)
Comment 5 Ryan C. Gordon 2007-07-04 14:52:17 UTC
I'm okay with leaving it for 1.3, because there are probably apps that might not bother writing silence when there isn't enough data, but almost everything just overwrites that stream without mixing at the app level, I would think, which would break BeOS, etc.

--ryan.

Comment 6 Sam Lantinga 2007-07-04 15:34:25 UTC
After thinking about it, let's go ahead and make this change in 1.2.12, but definitely document it in the patch notes.
Comment 7 Ryan C. Gordon 2007-07-04 19:30:58 UTC
This is fixed in svn revision #3139 for the 1.2 branch and #3140 for the 1.3 branch.

Now by default we don't initialize the buffer passed to the callback, but in case there's some app that relies on this behaviour and doesn't write data when they think there will be silence pre-written, the user can set an environment variable to force the legacy action.

--ryan.

Comment 8 Ryan C. Gordon 2007-07-08 17:28:53 UTC
svn revision #3181 reverts this change; after some discussion, we agreed that 1.2 shouldn't change behavior like this, since it breaks everything using SDL_mixer, etc.

1.3 has the change, though, and we'll clean up other projects as we come across them during migration from 1.2.

--ryan.