can't stop coding

ranostaj ranostaj at
Tue Jul 2 15:41:11 EDT 2002

Ryan C. Gordon wrote:

>> It comes to my eye, that playsound has the same functionality in the
>> callback function, so the padSilence function seems to be redundant. I
>> am less than sure of the semantics of buffer, buffer.size, len_mult
>> and len_cvt. If it doesn't work, just remove the padSilence function
>> and the associated parameters (dst_size, zero, mask). Ryan, may I ask
>> you to take a look at this section of the code, too?
> The application only sees the converted buffer; the converter should not
> try to blank out the end of the buffer if the conversion shrinks the
> sound data.

Ok. I didn't blank the whole buffer, just the remaining chunk - and I 
think this may be useful.

If we have chunks of the size of 4kByte, which are tansferred to the 
callback function at
once, this size is denoted in the struct SDL_AudioSpec.samples 
respective SDL_AudioSpec.size.
If, e.g. through rate conversion, a chunk is only one quater full, say, 
length is 17k, we need ceil(17k/4k)
= 5 chunks to hold the buffer. The last chunk is as already said 17k%4k 
= 1k only one quater full,
which needs to be checked in the callback function. It might be a 
slighly better interface
if we blank the remaining three quater so that the callback function 
get's a whole buffer and didn't
has to perform the length check and in the failing case the blanking 
itself, every time it got invoken.

Despite of this I fixed a couple of issues regarding the converter. It 
performs nicely in mono mode.
Stereo remains untested.

-------------- next part --------------
A non-text attachment was scrubbed...
Type: application/x-zip-compressed
Size: 10749 bytes
Desc: not available
URL: <>

More information about the sdlsound mailing list