Commit 5e73fc7c authored by Sam Lantinga's avatar Sam Lantinga

Fixed Visual Studio compilation problems

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%403179
parent a4af7a72
...@@ -291,10 +291,8 @@ SDL_StreamLength(SDL_AudioStreamer * stream) ...@@ -291,10 +291,8 @@ SDL_StreamLength(SDL_AudioStreamer * stream)
int int
SDL_StreamInit(SDL_AudioStreamer * stream, int max_len, Uint8 silence) SDL_StreamInit(SDL_AudioStreamer * stream, int max_len, Uint8 silence)
{ {
int i;
/* First try to allocate the buffer */ /* First try to allocate the buffer */
stream->buffer = (Uint8 *) malloc(max_len); stream->buffer = (Uint8 *) SDL_malloc(max_len);
if (stream->buffer == NULL) { if (stream->buffer == NULL) {
return -1; return -1;
} }
...@@ -304,9 +302,9 @@ SDL_StreamInit(SDL_AudioStreamer * stream, int max_len, Uint8 silence) ...@@ -304,9 +302,9 @@ SDL_StreamInit(SDL_AudioStreamer * stream, int max_len, Uint8 silence)
stream->write_pos = 0; stream->write_pos = 0;
/* Zero out the buffer */ /* Zero out the buffer */
for (i = 0; i < max_len; ++i) { SDL_memset(stream->buffer, silence, max_len);
stream->buffer[i] = silence;
} return 0;
} }
/* Deinitialize the stream simply by freeing the buffer */ /* Deinitialize the stream simply by freeing the buffer */
...@@ -314,7 +312,7 @@ void ...@@ -314,7 +312,7 @@ void
SDL_StreamDeinit(SDL_AudioStreamer * stream) SDL_StreamDeinit(SDL_AudioStreamer * stream)
{ {
if (stream->buffer != NULL) { if (stream->buffer != NULL) {
free(stream->buffer); SDL_free(stream->buffer);
} }
} }
......
...@@ -20,6 +20,8 @@ ...@@ -20,6 +20,8 @@
slouken@libsdl.org slouken@libsdl.org
*/ */
#include "SDL_config.h" #include "SDL_config.h"
#define _USE_MATH_DEFINES
#include <math.h> #include <math.h>
/* Functions for audio drivers to perform runtime conversion of audio format */ /* Functions for audio drivers to perform runtime conversion of audio format */
...@@ -27,7 +29,7 @@ ...@@ -27,7 +29,7 @@
#include "SDL_audio.h" #include "SDL_audio.h"
#include "SDL_audio_c.h" #include "SDL_audio_c.h"
#define DEBUG_CONVERT //#define DEBUG_CONVERT
/* These are fractional multiplication routines. That is, their inputs /* These are fractional multiplication routines. That is, their inputs
are two numbers in the range [-1, 1) and the result falls in that are two numbers in the range [-1, 1) and the result falls in that
...@@ -1369,7 +1371,7 @@ SDL_BuildIIRLowpass(SDL_AudioCVT * cvt, SDL_AudioFormat format) ...@@ -1369,7 +1371,7 @@ SDL_BuildIIRLowpass(SDL_AudioCVT * cvt, SDL_AudioFormat format)
w0 = 2.0f * M_PI * fc; w0 = 2.0f * M_PI * fc;
cosw0 = cosf(w0); cosw0 = cosf(w0);
alpha = sin(w0) / (2.0f * Q); alpha = sinf(w0) / (2.0f * Q);
/* Compute coefficients, normalizing by a0 */ /* Compute coefficients, normalizing by a0 */
scale = 1.0f / (1.0f + alpha); scale = 1.0f / (1.0f + alpha);
...@@ -1438,7 +1440,7 @@ SDL_BuildIIRLowpass(SDL_AudioCVT * cvt, SDL_AudioFormat format) ...@@ -1438,7 +1440,7 @@ SDL_BuildIIRLowpass(SDL_AudioCVT * cvt, SDL_AudioFormat format)
#endif #endif
/* Initialize the state buffer to all zeroes, and set initial position */ /* Initialize the state buffer to all zeroes, and set initial position */
memset(cvt->state_buf, 0, 4 * SDL_AUDIO_BITSIZE(format) / 4); SDL_memset(cvt->state_buf, 0, 4 * SDL_AUDIO_BITSIZE(format) / 4);
cvt->state_pos = 0; cvt->state_pos = 0;
#undef convert_fixed #undef convert_fixed
} }
...@@ -1636,7 +1638,7 @@ SDL_BuildWindowedSinc(SDL_AudioCVT * cvt, SDL_AudioFormat format, ...@@ -1636,7 +1638,7 @@ SDL_BuildWindowedSinc(SDL_AudioCVT * cvt, SDL_AudioFormat format,
cvt->len_sinc = m + 1; cvt->len_sinc = m + 1;
/* Allocate the floating point windowed sinc. */ /* Allocate the floating point windowed sinc. */
fSinc = (float *) malloc((m + 1) * sizeof(float)); fSinc = SDL_stack_alloc(float, (m + 1));
if (fSinc == NULL) { if (fSinc == NULL) {
return -1; return -1;
} }
...@@ -1699,16 +1701,17 @@ SDL_BuildWindowedSinc(SDL_AudioCVT * cvt, SDL_AudioFormat format, ...@@ -1699,16 +1701,17 @@ SDL_BuildWindowedSinc(SDL_AudioCVT * cvt, SDL_AudioFormat format,
} }
/* Initialize the state buffer to all zeroes, and set initial position */ /* Initialize the state buffer to all zeroes, and set initial position */
memset(cvt->state_buf, 0, cvt->len_sinc * SDL_AUDIO_BITSIZE(format) / 4); SDL_memset(cvt->state_buf, 0,
cvt->len_sinc * SDL_AUDIO_BITSIZE(format) / 4);
cvt->state_pos = 0; cvt->state_pos = 0;
/* Clean up */ /* Clean up */
#undef convert_fixed #undef convert_fixed
free(fSinc); SDL_stack_free(fSinc);
} }
/* This is used to reduce the resampling ratio */ /* This is used to reduce the resampling ratio */
inline int static __inline__ int
SDL_GCD(int a, int b) SDL_GCD(int a, int b)
{ {
int temp; int temp;
......
...@@ -173,8 +173,8 @@ WIN_InitMouse(_THIS) ...@@ -173,8 +173,8 @@ WIN_InitMouse(_THIS)
if (tablet == index) { if (tablet == index) {
AXIS pressure; AXIS pressure;
int cursors; int cursors;
data->WTInfo(WTI_DEVICES, DVC_NPRESSURE, &pressure); data->WTInfoA(WTI_DEVICES, DVC_NPRESSURE, &pressure);
data->WTInfo(WTI_DEVICES, DVC_NCSRTYPES, &cursors); data->WTInfoA(WTI_DEVICES, DVC_NCSRTYPES, &cursors);
data->mouse = data->mouse =
SDL_AddMouse(&mouse, index, device_name, pressure.axMax, SDL_AddMouse(&mouse, index, device_name, pressure.axMax,
pressure.axMin, cursors); pressure.axMin, cursors);
......
...@@ -110,14 +110,14 @@ WIN_CreateDevice(int devindex) ...@@ -110,14 +110,14 @@ WIN_CreateDevice(int devindex)
data->wintabDLL = LoadLibrary(TEXT("WINTAB32.DLL")); data->wintabDLL = LoadLibrary(TEXT("WINTAB32.DLL"));
if (data->wintabDLL) { if (data->wintabDLL) {
#define PROCNAME(X) #X #define PROCNAME(X) #X
data->WTInfo = data->WTInfoA =
(UINT(*)(UINT, UINT, LPVOID)) GetProcAddress(data->wintabDLL, (UINT(*)(UINT, UINT, LPVOID)) GetProcAddress(data->wintabDLL,
PROCNAME(WTInfo)); PROCNAME(WTInfoA));
data->WTOpen = data->WTOpenA =
(HCTX(*)(HWND, LPLOGCONTEXT, BOOL)) GetProcAddress(data-> (HCTX(*)(HWND, LPLOGCONTEXTA, BOOL)) GetProcAddress(data->
wintabDLL, wintabDLL,
PROCNAME PROCNAME
(WTOpen)); (WTOpenA));
data->WTPacket = data->WTPacket =
(int (*)(HCTX, UINT, LPVOID)) GetProcAddress(data->wintabDLL, (int (*)(HCTX, UINT, LPVOID)) GetProcAddress(data->wintabDLL,
PROCNAME(WTPacket)); PROCNAME(WTPacket));
...@@ -126,7 +126,7 @@ WIN_CreateDevice(int devindex) ...@@ -126,7 +126,7 @@ WIN_CreateDevice(int devindex)
PROCNAME(WTClose)); PROCNAME(WTClose));
#undef PROCNAME #undef PROCNAME
if (!data->WTInfo || !data->WTOpen || !data->WTPacket if (!data->WTInfoA || !data->WTOpenA || !data->WTPacket
|| !data->WTClose) { || !data->WTClose) {
FreeLibrary(data->wintabDLL); FreeLibrary(data->wintabDLL);
data->wintabDLL = NULL; data->wintabDLL = NULL;
......
...@@ -69,8 +69,8 @@ typedef struct SDL_VideoData ...@@ -69,8 +69,8 @@ typedef struct SDL_VideoData
/* *INDENT-OFF* */ /* *INDENT-OFF* */
/* Function pointers for the Wacom API */ /* Function pointers for the Wacom API */
HANDLE wintabDLL; HANDLE wintabDLL;
UINT (*WTInfo) (UINT, UINT, LPVOID); UINT (*WTInfoA) (UINT, UINT, LPVOID);
HCTX (*WTOpen) (HWND, LPLOGCONTEXT, BOOL); HCTX (*WTOpenA) (HWND, LPLOGCONTEXTA, BOOL);
int (*WTPacket) (HCTX, UINT, LPVOID); int (*WTPacket) (HCTX, UINT, LPVOID);
BOOL (*WTClose) (HCTX); BOOL (*WTClose) (HCTX);
/* *INDENT-ON* */ /* *INDENT-ON* */
......
...@@ -151,7 +151,7 @@ WIN_CreateWindow(_THIS, SDL_Window * window) ...@@ -151,7 +151,7 @@ WIN_CreateWindow(_THIS, SDL_Window * window)
SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata; SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata;
RAWINPUTDEVICE Rid; RAWINPUTDEVICE Rid;
AXIS TabX, TabY; AXIS TabX, TabY;
LOGCONTEXT lc; LOGCONTEXTA lc;
HWND hwnd; HWND hwnd;
HWND top; HWND top;
RECT rect; RECT rect;
...@@ -206,15 +206,16 @@ WIN_CreateWindow(_THIS, SDL_Window * window) ...@@ -206,15 +206,16 @@ WIN_CreateWindow(_THIS, SDL_Window * window)
} }
/* we're configuring the tablet data. See Wintab reference for more info */ /* we're configuring the tablet data. See Wintab reference for more info */
if (videodata->wintabDLL && videodata->WTInfo(WTI_DEFSYSCTX, 0, &lc) != 0) { if (videodata->wintabDLL
&& videodata->WTInfoA(WTI_DEFSYSCTX, 0, &lc) != 0) {
lc.lcPktData = PACKETDATA; lc.lcPktData = PACKETDATA;
lc.lcPktMode = PACKETMODE; lc.lcPktMode = PACKETMODE;
lc.lcOptions |= CXO_MESSAGES; lc.lcOptions |= CXO_MESSAGES;
lc.lcOptions |= CXO_SYSTEM; lc.lcOptions |= CXO_SYSTEM;
lc.lcMoveMask = PACKETDATA; lc.lcMoveMask = PACKETDATA;
lc.lcBtnDnMask = lc.lcBtnUpMask = PACKETDATA; lc.lcBtnDnMask = lc.lcBtnUpMask = PACKETDATA;
videodata->WTInfo(WTI_DEVICES, DVC_X, &TabX); videodata->WTInfoA(WTI_DEVICES, DVC_X, &TabX);
videodata->WTInfo(WTI_DEVICES, DVC_Y, &TabY); videodata->WTInfoA(WTI_DEVICES, DVC_Y, &TabY);
lc.lcInOrgX = 0; lc.lcInOrgX = 0;
lc.lcInOrgY = 0; lc.lcInOrgY = 0;
lc.lcInExtX = TabX.axMax; lc.lcInExtX = TabX.axMax;
...@@ -235,7 +236,7 @@ WIN_CreateWindow(_THIS, SDL_Window * window) ...@@ -235,7 +236,7 @@ WIN_CreateWindow(_THIS, SDL_Window * window)
} }
g_hCtx = tmp_hctx; g_hCtx = tmp_hctx;
} }
g_hCtx[window->id] = videodata->WTOpen(hwnd, &lc, TRUE); g_hCtx[window->id] = videodata->WTOpenA(hwnd, &lc, TRUE);
} }
/* we're telling the window, we want it to report raw input events from mice */ /* we're telling the window, we want it to report raw input events from mice */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment