[PATCH v2] msacm32: Rewrite PCM conversion functions.

Andrew Eikum aeikum at codeweavers.com
Wed Jun 14 08:42:22 CDT 2017


On Tue, Jun 13, 2017 at 04:35:52PM -0500, Zebediah Figura wrote:
> +#define PCM_CVT_CHANGE_FUNC(name)	static void name(DWORD srcRate, const unsigned char *src, DWORD *nsrc, \
> +							 DWORD dstRate, unsigned char *dst, DWORD *ndst) \
> +    { \
> +    DWORD error = srcRate / 2; \
> +    DWORD srcUsed = 0, dstUsed = 0; \
> +    for (srcUsed = 0; srcUsed < *nsrc; srcUsed++) { \
> +        error += dstRate; \
> +        while (error > srcRate) { \
> +            if (dstUsed == *ndst) { \
> +                *nsrc = srcUsed; \
> +                *ndst = dstUsed; \
> +                return; \
> +            }
> +
> +            /* conversion is done here */
> +
> +#define PCM_CVT_CHANGE_FUNC_END(offset)	\
> +            dstUsed++; \
> +            error -= srcRate; \
> +        } \
> +        src += offset; \
> +    } \
> +    *nsrc = srcUsed; \
> +    *ndst = dstUsed; \
> +}
> +
> +PCM_CVT_CHANGE_FUNC(cvtSS88C)
> +    *dst++ = src[0];
> +    *dst++ = src[1];
> +PCM_CVT_CHANGE_FUNC_END(2)
> +

I really dislike complicated preprocessor tricks. Can't this be done
in a similar way with real functions? If not, I'd rather have the
copy-pasted code than these difficult macros.

Andrew



More information about the wine-devel mailing list