annotate win64-msvc/include/pa_win_waveformat.h @ 74:2f2b27544483

Rebuild win32 Opus using mingw 5 rather than 7 to avoid runtime incompatibility
author Chris Cannam
date Wed, 30 Jan 2019 10:30:56 +0000
parents 95867ba8caa8
children
rev   line source
Chris@60 1 #ifndef PA_WIN_WAVEFORMAT_H
Chris@60 2 #define PA_WIN_WAVEFORMAT_H
Chris@60 3
Chris@60 4 /*
Chris@60 5 * PortAudio Portable Real-Time Audio Library
Chris@60 6 * Windows WAVEFORMAT* data structure utilities
Chris@60 7 * portaudio.h should be included before this file.
Chris@60 8 *
Chris@60 9 * Copyright (c) 2007 Ross Bencina
Chris@60 10 *
Chris@60 11 * Permission is hereby granted, free of charge, to any person obtaining
Chris@60 12 * a copy of this software and associated documentation files
Chris@60 13 * (the "Software"), to deal in the Software without restriction,
Chris@60 14 * including without limitation the rights to use, copy, modify, merge,
Chris@60 15 * publish, distribute, sublicense, and/or sell copies of the Software,
Chris@60 16 * and to permit persons to whom the Software is furnished to do so,
Chris@60 17 * subject to the following conditions:
Chris@60 18 *
Chris@60 19 * The above copyright notice and this permission notice shall be
Chris@60 20 * included in all copies or substantial portions of the Software.
Chris@60 21 *
Chris@60 22 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
Chris@60 23 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
Chris@60 24 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
Chris@60 25 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
Chris@60 26 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
Chris@60 27 * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
Chris@60 28 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Chris@60 29 */
Chris@60 30
Chris@60 31 /*
Chris@60 32 * The text above constitutes the entire PortAudio license; however,
Chris@60 33 * the PortAudio community also makes the following non-binding requests:
Chris@60 34 *
Chris@60 35 * Any person wishing to distribute modifications to the Software is
Chris@60 36 * requested to send the modifications to the original developer so that
Chris@60 37 * they can be incorporated into the canonical version. It is also
Chris@60 38 * requested that these non-binding requests be included along with the
Chris@60 39 * license above.
Chris@60 40 */
Chris@60 41
Chris@60 42 /** @file
Chris@60 43 @ingroup public_header
Chris@60 44 @brief Windows specific PortAudio API extension and utilities header file.
Chris@60 45 */
Chris@60 46
Chris@60 47 #ifdef __cplusplus
Chris@60 48 extern "C" {
Chris@60 49 #endif
Chris@60 50
Chris@60 51 /*
Chris@60 52 The following #defines for speaker channel masks are the same
Chris@60 53 as those in ksmedia.h, except with PAWIN_ prepended, KSAUDIO_ removed
Chris@60 54 in some cases, and casts to PaWinWaveFormatChannelMask added.
Chris@60 55 */
Chris@60 56
Chris@60 57 typedef unsigned long PaWinWaveFormatChannelMask;
Chris@60 58
Chris@60 59 /* Speaker Positions: */
Chris@60 60 #define PAWIN_SPEAKER_FRONT_LEFT ((PaWinWaveFormatChannelMask)0x1)
Chris@60 61 #define PAWIN_SPEAKER_FRONT_RIGHT ((PaWinWaveFormatChannelMask)0x2)
Chris@60 62 #define PAWIN_SPEAKER_FRONT_CENTER ((PaWinWaveFormatChannelMask)0x4)
Chris@60 63 #define PAWIN_SPEAKER_LOW_FREQUENCY ((PaWinWaveFormatChannelMask)0x8)
Chris@60 64 #define PAWIN_SPEAKER_BACK_LEFT ((PaWinWaveFormatChannelMask)0x10)
Chris@60 65 #define PAWIN_SPEAKER_BACK_RIGHT ((PaWinWaveFormatChannelMask)0x20)
Chris@60 66 #define PAWIN_SPEAKER_FRONT_LEFT_OF_CENTER ((PaWinWaveFormatChannelMask)0x40)
Chris@60 67 #define PAWIN_SPEAKER_FRONT_RIGHT_OF_CENTER ((PaWinWaveFormatChannelMask)0x80)
Chris@60 68 #define PAWIN_SPEAKER_BACK_CENTER ((PaWinWaveFormatChannelMask)0x100)
Chris@60 69 #define PAWIN_SPEAKER_SIDE_LEFT ((PaWinWaveFormatChannelMask)0x200)
Chris@60 70 #define PAWIN_SPEAKER_SIDE_RIGHT ((PaWinWaveFormatChannelMask)0x400)
Chris@60 71 #define PAWIN_SPEAKER_TOP_CENTER ((PaWinWaveFormatChannelMask)0x800)
Chris@60 72 #define PAWIN_SPEAKER_TOP_FRONT_LEFT ((PaWinWaveFormatChannelMask)0x1000)
Chris@60 73 #define PAWIN_SPEAKER_TOP_FRONT_CENTER ((PaWinWaveFormatChannelMask)0x2000)
Chris@60 74 #define PAWIN_SPEAKER_TOP_FRONT_RIGHT ((PaWinWaveFormatChannelMask)0x4000)
Chris@60 75 #define PAWIN_SPEAKER_TOP_BACK_LEFT ((PaWinWaveFormatChannelMask)0x8000)
Chris@60 76 #define PAWIN_SPEAKER_TOP_BACK_CENTER ((PaWinWaveFormatChannelMask)0x10000)
Chris@60 77 #define PAWIN_SPEAKER_TOP_BACK_RIGHT ((PaWinWaveFormatChannelMask)0x20000)
Chris@60 78
Chris@60 79 /* Bit mask locations reserved for future use */
Chris@60 80 #define PAWIN_SPEAKER_RESERVED ((PaWinWaveFormatChannelMask)0x7FFC0000)
Chris@60 81
Chris@60 82 /* Used to specify that any possible permutation of speaker configurations */
Chris@60 83 #define PAWIN_SPEAKER_ALL ((PaWinWaveFormatChannelMask)0x80000000)
Chris@60 84
Chris@60 85 /* DirectSound Speaker Config */
Chris@60 86 #define PAWIN_SPEAKER_DIRECTOUT 0
Chris@60 87 #define PAWIN_SPEAKER_MONO (PAWIN_SPEAKER_FRONT_CENTER)
Chris@60 88 #define PAWIN_SPEAKER_STEREO (PAWIN_SPEAKER_FRONT_LEFT | PAWIN_SPEAKER_FRONT_RIGHT)
Chris@60 89 #define PAWIN_SPEAKER_QUAD (PAWIN_SPEAKER_FRONT_LEFT | PAWIN_SPEAKER_FRONT_RIGHT | \
Chris@60 90 PAWIN_SPEAKER_BACK_LEFT | PAWIN_SPEAKER_BACK_RIGHT)
Chris@60 91 #define PAWIN_SPEAKER_SURROUND (PAWIN_SPEAKER_FRONT_LEFT | PAWIN_SPEAKER_FRONT_RIGHT | \
Chris@60 92 PAWIN_SPEAKER_FRONT_CENTER | PAWIN_SPEAKER_BACK_CENTER)
Chris@60 93 #define PAWIN_SPEAKER_5POINT1 (PAWIN_SPEAKER_FRONT_LEFT | PAWIN_SPEAKER_FRONT_RIGHT | \
Chris@60 94 PAWIN_SPEAKER_FRONT_CENTER | PAWIN_SPEAKER_LOW_FREQUENCY | \
Chris@60 95 PAWIN_SPEAKER_BACK_LEFT | PAWIN_SPEAKER_BACK_RIGHT)
Chris@60 96 #define PAWIN_SPEAKER_7POINT1 (PAWIN_SPEAKER_FRONT_LEFT | PAWIN_SPEAKER_FRONT_RIGHT | \
Chris@60 97 PAWIN_SPEAKER_FRONT_CENTER | PAWIN_SPEAKER_LOW_FREQUENCY | \
Chris@60 98 PAWIN_SPEAKER_BACK_LEFT | PAWIN_SPEAKER_BACK_RIGHT | \
Chris@60 99 PAWIN_SPEAKER_FRONT_LEFT_OF_CENTER | PAWIN_SPEAKER_FRONT_RIGHT_OF_CENTER)
Chris@60 100 #define PAWIN_SPEAKER_5POINT1_SURROUND (PAWIN_SPEAKER_FRONT_LEFT | PAWIN_SPEAKER_FRONT_RIGHT | \
Chris@60 101 PAWIN_SPEAKER_FRONT_CENTER | PAWIN_SPEAKER_LOW_FREQUENCY | \
Chris@60 102 PAWIN_SPEAKER_SIDE_LEFT | PAWIN_SPEAKER_SIDE_RIGHT)
Chris@60 103 #define PAWIN_SPEAKER_7POINT1_SURROUND (PAWIN_SPEAKER_FRONT_LEFT | PAWIN_SPEAKER_FRONT_RIGHT | \
Chris@60 104 PAWIN_SPEAKER_FRONT_CENTER | PAWIN_SPEAKER_LOW_FREQUENCY | \
Chris@60 105 PAWIN_SPEAKER_BACK_LEFT | PAWIN_SPEAKER_BACK_RIGHT | \
Chris@60 106 PAWIN_SPEAKER_SIDE_LEFT | PAWIN_SPEAKER_SIDE_RIGHT)
Chris@60 107 /*
Chris@60 108 According to the Microsoft documentation:
Chris@60 109 The following are obsolete 5.1 and 7.1 settings (they lack side speakers). Note this means
Chris@60 110 that the default 5.1 and 7.1 settings (KSAUDIO_SPEAKER_5POINT1 and KSAUDIO_SPEAKER_7POINT1 are
Chris@60 111 similarly obsolete but are unchanged for compatibility reasons).
Chris@60 112 */
Chris@60 113 #define PAWIN_SPEAKER_5POINT1_BACK PAWIN_SPEAKER_5POINT1
Chris@60 114 #define PAWIN_SPEAKER_7POINT1_WIDE PAWIN_SPEAKER_7POINT1
Chris@60 115
Chris@60 116 /* DVD Speaker Positions */
Chris@60 117 #define PAWIN_SPEAKER_GROUND_FRONT_LEFT PAWIN_SPEAKER_FRONT_LEFT
Chris@60 118 #define PAWIN_SPEAKER_GROUND_FRONT_CENTER PAWIN_SPEAKER_FRONT_CENTER
Chris@60 119 #define PAWIN_SPEAKER_GROUND_FRONT_RIGHT PAWIN_SPEAKER_FRONT_RIGHT
Chris@60 120 #define PAWIN_SPEAKER_GROUND_REAR_LEFT PAWIN_SPEAKER_BACK_LEFT
Chris@60 121 #define PAWIN_SPEAKER_GROUND_REAR_RIGHT PAWIN_SPEAKER_BACK_RIGHT
Chris@60 122 #define PAWIN_SPEAKER_TOP_MIDDLE PAWIN_SPEAKER_TOP_CENTER
Chris@60 123 #define PAWIN_SPEAKER_SUPER_WOOFER PAWIN_SPEAKER_LOW_FREQUENCY
Chris@60 124
Chris@60 125
Chris@60 126 /*
Chris@60 127 PaWinWaveFormat is defined here to provide compatibility with
Chris@60 128 compilation environments which don't have headers defining
Chris@60 129 WAVEFORMATEXTENSIBLE (e.g. older versions of MSVC, Borland C++ etc.
Chris@60 130
Chris@60 131 The fields for WAVEFORMATEX and WAVEFORMATEXTENSIBLE are declared as an
Chris@60 132 unsigned char array here to avoid clients who include this file having
Chris@60 133 a dependency on windows.h and mmsystem.h, and also to to avoid having
Chris@60 134 to write separate packing pragmas for each compiler.
Chris@60 135 */
Chris@60 136 #define PAWIN_SIZEOF_WAVEFORMATEX 18
Chris@60 137 #define PAWIN_SIZEOF_WAVEFORMATEXTENSIBLE (PAWIN_SIZEOF_WAVEFORMATEX + 22)
Chris@60 138
Chris@60 139 typedef struct{
Chris@60 140 unsigned char fields[ PAWIN_SIZEOF_WAVEFORMATEXTENSIBLE ];
Chris@60 141 unsigned long extraLongForAlignment; /* ensure that compiler aligns struct to DWORD */
Chris@60 142 } PaWinWaveFormat;
Chris@60 143
Chris@60 144 /*
Chris@60 145 WAVEFORMATEXTENSIBLE fields:
Chris@60 146
Chris@60 147 union {
Chris@60 148 WORD wValidBitsPerSample;
Chris@60 149 WORD wSamplesPerBlock;
Chris@60 150 WORD wReserved;
Chris@60 151 } Samples;
Chris@60 152 DWORD dwChannelMask;
Chris@60 153 GUID SubFormat;
Chris@60 154 */
Chris@60 155
Chris@60 156 #define PAWIN_INDEXOF_WVALIDBITSPERSAMPLE (PAWIN_SIZEOF_WAVEFORMATEX+0)
Chris@60 157 #define PAWIN_INDEXOF_DWCHANNELMASK (PAWIN_SIZEOF_WAVEFORMATEX+2)
Chris@60 158 #define PAWIN_INDEXOF_SUBFORMAT (PAWIN_SIZEOF_WAVEFORMATEX+6)
Chris@60 159
Chris@60 160
Chris@60 161 /*
Chris@60 162 Valid values to pass for the waveFormatTag PaWin_InitializeWaveFormatEx and
Chris@60 163 PaWin_InitializeWaveFormatExtensible functions below. These must match
Chris@60 164 the standard Windows WAVE_FORMAT_* values.
Chris@60 165 */
Chris@60 166 #define PAWIN_WAVE_FORMAT_PCM (1)
Chris@60 167 #define PAWIN_WAVE_FORMAT_IEEE_FLOAT (3)
Chris@60 168 #define PAWIN_WAVE_FORMAT_DOLBY_AC3_SPDIF (0x0092)
Chris@60 169 #define PAWIN_WAVE_FORMAT_WMA_SPDIF (0x0164)
Chris@60 170
Chris@60 171
Chris@60 172 /*
Chris@60 173 returns PAWIN_WAVE_FORMAT_PCM or PAWIN_WAVE_FORMAT_IEEE_FLOAT
Chris@60 174 depending on the sampleFormat parameter.
Chris@60 175 */
Chris@60 176 int PaWin_SampleFormatToLinearWaveFormatTag( PaSampleFormat sampleFormat );
Chris@60 177
Chris@60 178 /*
Chris@60 179 Use the following two functions to initialize the waveformat structure.
Chris@60 180 */
Chris@60 181
Chris@60 182 void PaWin_InitializeWaveFormatEx( PaWinWaveFormat *waveFormat,
Chris@60 183 int numChannels, PaSampleFormat sampleFormat, int waveFormatTag, double sampleRate );
Chris@60 184
Chris@60 185
Chris@60 186 void PaWin_InitializeWaveFormatExtensible( PaWinWaveFormat *waveFormat,
Chris@60 187 int numChannels, PaSampleFormat sampleFormat, int waveFormatTag, double sampleRate,
Chris@60 188 PaWinWaveFormatChannelMask channelMask );
Chris@60 189
Chris@60 190
Chris@60 191 /* Map a channel count to a speaker channel mask */
Chris@60 192 PaWinWaveFormatChannelMask PaWin_DefaultChannelMask( int numChannels );
Chris@60 193
Chris@60 194
Chris@60 195 #ifdef __cplusplus
Chris@60 196 }
Chris@60 197 #endif /* __cplusplus */
Chris@60 198
Chris@45 199 #endif /* PA_WIN_WAVEFORMAT_H */