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 73

Summary: wavestream.c patch
Product: SDL_mixer Reporter: Sam Lantinga <slouken>
Component: miscAssignee: Ryan C. Gordon <icculus>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: blocker    
Priority: P2    
Version: unspecified   
Hardware: All   
OS: All   
Attachments: wavestream.c.diff

Description Sam Lantinga 2006-01-24 01:46:30 UTC
Date: Tue, 15 Apr 2003 23:36:17 +0300
From: King Of The Bongo <ecsa@beiks.com>
Subject: [SDL] SDL_mixer patch

SDL_mixer

Hi, this is modified version of wavestream.c

When you call Mix_VolumeMusic (volume) and play PCM wav stream it does
not apply and the wav file plays with the old values.
Comment 1 Sam Lantinga 2006-01-24 01:46:57 UTC
Created attachment 33 [details]
wavestream.c.diff
Comment 2 Sam Lantinga 2006-01-24 01:47:33 UTC
Obviously we don't want to do a malloc and a free here, but his observation seems valid.  What do you think, Ryan?
Comment 3 Ryan C. Gordon 2006-01-24 04:12:46 UTC
We probably can't avoid the malloc altogether, but we can make it just realloc() if a buffer is too small.

However, we're always mixing against silence here, and just need to adjust volume...I'm wondering if we should avoid calling SDL_MixAudio altogether, which would totally eliminate the need for a second buffer.

--ryan.

Comment 4 Sam Lantinga 2006-01-24 12:46:33 UTC
(In reply to comment #3)
> We probably can't avoid the malloc altogether, but we can make it just
> realloc() if a buffer is too small.
> However, we're always mixing against silence here, and just need to adjust
> volume...I'm wondering if we should avoid calling SDL_MixAudio altogether,
> which would totally eliminate the need for a second buffer.
> --ryan.

Sounds reasonable to me.  Do we need an SDL_AttenuateVolume call? :)
Comment 5 Ryan C. Gordon 2006-01-24 14:42:43 UTC
That might be nice, actually, but for now, we should just put a fix in here that doesn't require an SDL API change. I'll write up a patch.

--ryan.

Comment 6 Ryan C. Gordon 2006-01-27 11:23:22 UTC
Setting Sam as "QA Contact" on all bugs (even resolved ones) so he'll definitely be in the loop to any further discussion here about SDL.

--ryan.

Comment 7 Sam Lantinga 2006-04-30 23:27:41 UTC
Hey Ryan, any progress on this?
Comment 8 Sam Lantinga 2006-05-07 17:19:40 UTC
I'd like to get this fixed for SDL_mixer 1.2.7 release, if possible.
Comment 9 Ryan C. Gordon 2006-05-09 00:34:03 UTC
eh...mixing against silence isn't ideal, but SDL handles all the different data formats under the hood, so it's not worth changing it for the small performance boost.

I'd say use the existing patch, but use an alloca() instead of malloc()/free(). Everything else is going to make things worse for otherwise stable code.

--ryan.
Comment 10 Sam Lantinga 2006-05-09 04:02:57 UTC
This patch is in Subversion, modified to use alloca instead of malloc.