Fixed breaking strict-aliasing rules (if compiled with GCC with -fstrict-aliasing) in PaWin_InitializeWaveFormatExtensible(). (#342)

This commit is contained in:
Dmitry Kostjuchenko 2020-12-08 08:26:54 +02:00 committed by GitHub
commit 5f35d35ad0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -98,14 +98,15 @@ void PaWin_InitializeWaveFormatExtensible( PaWinWaveFormat *waveFormat,
waveFormatEx->wBitsPerSample = bytesPerSample * 8;
waveFormatEx->cbSize = 22;
*((WORD*)&waveFormat->fields[PAWIN_INDEXOF_WVALIDBITSPERSAMPLE]) =
waveFormatEx->wBitsPerSample;
memcpy(&waveFormat->fields[PAWIN_INDEXOF_WVALIDBITSPERSAMPLE],
&waveFormatEx->wBitsPerSample, sizeof(WORD));
*((DWORD*)&waveFormat->fields[PAWIN_INDEXOF_DWCHANNELMASK]) = channelMask;
memcpy(&waveFormat->fields[PAWIN_INDEXOF_DWCHANNELMASK],
&channelMask, sizeof(DWORD));
guid = pawin_ksDataFormatSubtypeGuidBase;
guid.Data1 = (USHORT)waveFormatTag;
*((GUID*)&waveFormat->fields[PAWIN_INDEXOF_SUBFORMAT]) = guid;
memcpy(&waveFormat->fields[PAWIN_INDEXOF_SUBFORMAT], &guid, sizeof(GUID));
}
PaWinWaveFormatChannelMask PaWin_DefaultChannelMask( int numChannels )