[PATCH 4/4] dsound: Resample to float, not device format

Alexander E. Patrakov patrakov at gmail.com
Thu Jul 26 09:01:50 CDT 2012


Andrew Eikum wrote:
> Before this patch, the chain is
> secondary format
>  =(Resample)=> float
>  =(Reformat)=> device format
>  =(Mix)=> float
>  =(Reformat)=> device format
> 
> Now it's
> secondary format
>  =(Resample)=> float
>  =(Mix)=> float
>  =(Reformat)=> device format

Overall, this looks like a good cleanup. However, the chart above uses
the word "(Mix)" for a combination of two operations: 1) apply volume to
each sample, 2) calculate sum of samples corresponding to all playing
buffers. I'd like you to resend this patch with these two steps shown
separately (this also applies to the copy in the comments in mixer.c).

Some notes about the code:

The planned optimization that groups secondary buffers by sample rate
before resampling the mix of them depends on having the volume applied
before resampling, not after. So these operations have to be reordered
in a later patch.

>  void put_mono2stereo(const IDirectSoundBufferImpl *dsb, DWORD pos, DWORD channel, float value)
>  {
>      dsb->put_aux(dsb, pos, 0, value);
>      dsb->put_aux(dsb, pos, 1, value);
>  }
...
> -	dsb->put_aux = putbpp[dsb->device->pwfx->wBitsPerSample/8 - 1];
> +	dsb->put_aux = putieee32;
>  
>  	dsb->get = dsb->get_aux;
>  	dsb->put = dsb->put_aux;
... and then dsb-> put and dsb->get are possibly overwritten

Here it looks like we can also remove put_aux by always using put_ieee32
in put_mono2stereo().


> +	vLeft = dsb->volpan.dwTotalLeftAmpFactor / ((float)0xFFFF);
> +	vRight = dsb->volpan.dwTotalRightAmpFactor / ((float)0xFFFF);

If dwTotal{Left,Right}AmpFactor is not something public, then we can as
well store it as a float.

All of the above can, of course, be addressed later.

-- 
Alexander E. Patrakov




More information about the wine-devel mailing list