From d71496262169cd055291b313ae4b3f8dc4b69800 Mon Sep 17 00:00:00 2001 From: dmitrykos Date: Thu, 25 Mar 2010 23:27:27 +0000 Subject: [PATCH] wasapi: - fixed int24 Mono to Stereo mixer (affects Mono streams starting in Exclusive mode) pa_converters: - avoid using 64-bit integer math for Int24_To_Float32 and Int24_To_Int32 under x64 Posix platforms (long is 64-bit there), now using explicit PaInt32 type --- src/common/pa_converters.c | 24 ++++++++++++------------ src/hostapi/wasapi/pa_win_wasapi.c | 9 +++------ 2 files changed, 15 insertions(+), 18 deletions(-) diff --git a/src/common/pa_converters.c b/src/common/pa_converters.c index 70e7a7d..75cb276 100644 --- a/src/common/pa_converters.c +++ b/src/common/pa_converters.c @@ -1073,13 +1073,13 @@ static void Int24_To_Float32( { #if defined(PA_LITTLE_ENDIAN) - temp = (((long)src[0]) << 8); - temp = temp | (((long)src[1]) << 16); - temp = temp | (((long)src[2]) << 24); + temp = (((PaInt32)src[0]) << 8); + temp = temp | (((PaInt32)src[1]) << 16); + temp = temp | (((PaInt32)src[2]) << 24); #elif defined(PA_BIG_ENDIAN) - temp = (((long)src[0]) << 24); - temp = temp | (((long)src[1]) << 16); - temp = temp | (((long)src[2]) << 8); + temp = (((PaInt32)src[0]) << 24); + temp = temp | (((PaInt32)src[1]) << 16); + temp = temp | (((PaInt32)src[2]) << 8); #endif *dest = (float) ((double)temp * const_1_div_2147483648_); @@ -1106,13 +1106,13 @@ static void Int24_To_Int32( { #if defined(PA_LITTLE_ENDIAN) - temp = (((long)src[0]) << 8); - temp = temp | (((long)src[1]) << 16); - temp = temp | (((long)src[2]) << 24); + temp = (((PaInt32)src[0]) << 8); + temp = temp | (((PaInt32)src[1]) << 16); + temp = temp | (((PaInt32)src[2]) << 24); #elif defined(PA_BIG_ENDIAN) - temp = (((long)src[0]) << 24); - temp = temp | (((long)src[1]) << 16); - temp = temp | (((long)src[2]) << 8); + temp = (((PaInt32)src[0]) << 24); + temp = temp | (((PaInt32)src[1]) << 16); + temp = temp | (((PaInt32)src[2]) << 8); #endif *dest = temp; diff --git a/src/hostapi/wasapi/pa_win_wasapi.c b/src/hostapi/wasapi/pa_win_wasapi.c index 71930d5..cb14cf5 100644 --- a/src/hostapi/wasapi/pa_win_wasapi.c +++ b/src/hostapi/wasapi/pa_win_wasapi.c @@ -850,8 +850,8 @@ static BOOL UseWOW64VistaWorkaround() // ------------------------------------------------------------------------------------------ #define _WASAPI_MONO_TO_STEREO_MIXER(TYPE)\ - TYPE * __restrict to = __to;\ - TYPE * __restrict from = __from;\ + TYPE * __restrict to = (TYPE *)__to;\ + TYPE * __restrict from = (TYPE *)__from;\ TYPE * __restrict end = from + count;\ while (from != end)\ {\ @@ -875,10 +875,7 @@ static void _MixMonoToStereo_16(void *__to, void *__from, UINT32 count) // ------------------------------------------------------------------------------------------ static void _MixMonoToStereo_24(void *__to, void *__from, UINT32 count) { -#pragma pack(push, 1) - typedef struct wasapi_int24 { BYTE d[3]; } wasapi_int24; //<< 24 bit value, packed to 1 byte to avoid padding -#pragma pack(pop) - _WASAPI_MONO_TO_STEREO_MIXER(wasapi_int24); + _WASAPI_MONO_TO_STEREO_MIXER(int); // !!! int24 data is contained in 32-bit containers } // ------------------------------------------------------------------------------------------ -- 2.43.0