From a4040293ddc7ed6fd7e6679dd9446b6c5e6b0913 Mon Sep 17 00:00:00 2001 From: Ozkan Sezer Date: Sun, 25 Oct 2020 10:10:02 +0300 Subject: [PATCH] os2: misc build fixes --- src/audio/os2/SDL_os2audio.c | 61 ++++++++++++++++---------------- src/audio/os2/SDL_os2audio.h | 4 +-- src/core/os2/geniconv/os2iconv.c | 6 +++- src/core/os2/geniconv/sys2utf8.c | 6 ++-- src/core/os2/geniconv/test.c | 4 +-- 5 files changed, 42 insertions(+), 39 deletions(-) diff --git a/src/audio/os2/SDL_os2audio.c b/src/audio/os2/SDL_os2audio.c index 9e5e99b29..4a8017d6c 100644 --- a/src/audio/os2/SDL_os2audio.c +++ b/src/audio/os2/SDL_os2audio.c @@ -26,7 +26,6 @@ #include "../../core/os2/SDL_os2.h" -#include "SDL_timer.h" #include "SDL_audio.h" #include "../SDL_audio_c.h" #include "SDL_os2audio.h" @@ -34,12 +33,12 @@ /* void lockIncr(volatile int *piVal); #pragma aux lockIncr = \ - " lock add [eax], 1 "\ + "lock add [eax], 1 "\ parm [eax]; void lockDecr(volatile int *piVal); #pragma aux lockDecr = \ - " lock sub [eax], 1 "\ + "lock sub [eax], 1 "\ parm [eax]; */ @@ -169,7 +168,7 @@ static void OS2_DetectDevices(void) static void OS2_WaitDevice(_THIS) { - SDL_PrivateAudioData *pAData = (SDL_PrivateAudioData *)this->hidden; + SDL_PrivateAudioData *pAData = (SDL_PrivateAudioData *)_this->hidden; ULONG ulRC; /* Wait for an audio chunk to finish */ @@ -181,13 +180,13 @@ static void OS2_WaitDevice(_THIS) static Uint8 *OS2_GetDeviceBuf(_THIS) { - SDL_PrivateAudioData *pAData = (SDL_PrivateAudioData *)this->hidden; - return pAData->aMixBuffers[pAData->ulNextBuf].pBuffer; + SDL_PrivateAudioData *pAData = (SDL_PrivateAudioData *)_this->hidden; + return (Uint8 *) pAData->aMixBuffers[pAData->ulNextBuf].pBuffer; } static void OS2_PlayDevice(_THIS) { - SDL_PrivateAudioData *pAData = (SDL_PrivateAudioData *)this->hidden; + SDL_PrivateAudioData *pAData = (SDL_PrivateAudioData *)_this->hidden; ULONG ulRC; PMCI_MIX_BUFFER pMixBuffer = &pAData->aMixBuffers[pAData->ulNextBuf]; @@ -204,7 +203,7 @@ static void OS2_PlayDevice(_THIS) static void OS2_CloseDevice(_THIS) { - SDL_PrivateAudioData *pAData = (SDL_PrivateAudioData *)this->hidden; + SDL_PrivateAudioData *pAData = (SDL_PrivateAudioData *)_this->hidden; MCI_GENERIC_PARMS sMCIGenericParms; ULONG ulRC; @@ -230,7 +229,7 @@ static void OS2_CloseDevice(_THIS) stMCIBuffer.ulBufferSize = pAData->aMixBuffers[0].ulBufferLength; stMCIBuffer.ulNumBuffers = pAData->cMixBuffers; - stMCIBuffer.pBufList = &pAData->aMixBuffers; + stMCIBuffer.pBufList = pAData->aMixBuffers; ulRC = mciSendCommand(pAData->usDeviceId, MCI_BUFFER, MCI_WAIT | MCI_DEALLOCATE_MEMORY, &stMCIBuffer, 0); @@ -267,7 +266,7 @@ static int OS2_OpenDevice(_THIS, void *handle, const char *devname, SDL_zero(stMCIAmpOpen); SDL_zero(stMCIBuffer); - for (SDLAudioFmt = SDL_FirstAudioFormat(this->spec.format); + for (SDLAudioFmt = SDL_FirstAudioFormat(_this->spec.format); SDLAudioFmt != 0; SDLAudioFmt = SDL_NextAudioFormat()) { if (SDLAudioFmt == AUDIO_U8 || SDLAudioFmt == AUDIO_S16) break; @@ -277,10 +276,10 @@ static int OS2_OpenDevice(_THIS, void *handle, const char *devname, SDLAudioFmt = AUDIO_S16; } - pAData = SDL_calloc(1, sizeof(SDL_PrivateAudioData)); + pAData = (SDL_PrivateAudioData *) SDL_calloc(1, sizeof(struct SDL_PrivateAudioData)); if (pAData == NULL) return SDL_OutOfMemory(); - this->hidden = pAData; + _this->hidden = pAData; ulRC = DosCreateEventSem(NULL, &pAData->hevBuf, DCE_AUTORESET, TRUE); if (ulRC != NO_ERROR) { @@ -334,21 +333,21 @@ static int OS2_OpenDevice(_THIS, void *handle, const char *devname, &stMCIAmpSet, 0); } - this->spec.format = SDLAudioFmt; - this->spec.channels = this->spec.channels > 1 ? 2 : 1; - if (this->spec.freq < 8000) { - this->spec.freq = 8000; + _this->spec.format = SDLAudioFmt; + _this->spec.channels = _this->spec.channels > 1 ? 2 : 1; + if (_this->spec.freq < 8000) { + _this->spec.freq = 8000; new_freq = TRUE; - } else if (this->spec.freq > 48000) { - this->spec.freq = 48000; + } else if (_this->spec.freq > 48000) { + _this->spec.freq = 48000; new_freq = TRUE; } /* Setup mixer. */ pAData->stMCIMixSetup.ulFormatTag = MCI_WAVE_FORMAT_PCM; pAData->stMCIMixSetup.ulBitsPerSample = SDL_AUDIO_BITSIZE(SDLAudioFmt); - pAData->stMCIMixSetup.ulSamplesPerSec = this->spec.freq; - pAData->stMCIMixSetup.ulChannels = this->spec.channels; + pAData->stMCIMixSetup.ulSamplesPerSec = _this->spec.freq; + pAData->stMCIMixSetup.ulChannels = _this->spec.channels; pAData->stMCIMixSetup.ulDeviceType = MCI_DEVTYPE_WAVEFORM_AUDIO; if (iscapture == 0) { pAData->stMCIMixSetup.ulFormatMode= MCI_PLAY; @@ -360,10 +359,10 @@ static int OS2_OpenDevice(_THIS, void *handle, const char *devname, ulRC = mciSendCommand(pAData->usDeviceId, MCI_MIXSETUP, MCI_WAIT | MCI_MIXSETUP_INIT, &pAData->stMCIMixSetup, 0); - if (ulRC != MCIERR_SUCCESS && this->spec.freq > 44100) { + if (ulRC != MCIERR_SUCCESS && _this->spec.freq > 44100) { new_freq = TRUE; pAData->stMCIMixSetup.ulSamplesPerSec = 44100; - this->spec.freq = 44100; + _this->spec.freq = 44100; ulRC = mciSendCommand(pAData->usDeviceId, MCI_MIXSETUP, MCI_WAIT | MCI_MIXSETUP_INIT, &pAData->stMCIMixSetup, 0); } @@ -379,23 +378,23 @@ static int OS2_OpenDevice(_THIS, void *handle, const char *devname, return _MCIError("MCI_MIXSETUP", ulRC); } - if (this->spec.samples == 0 || new_freq == TRUE) { + if (_this->spec.samples == 0 || new_freq == TRUE) { /* also see SDL_audio.c:prepare_audiospec() */ /* Pick a default of ~46 ms at desired frequency */ - Uint32 samples = (this->spec.freq / 1000) * 46; + Uint32 samples = (_this->spec.freq / 1000) * 46; Uint32 power2 = 1; while (power2 < samples) { power2 <<= 1; } - this->spec.samples = power2; + _this->spec.samples = power2; } /* Update the fragment size as size in bytes */ - SDL_CalculateAudioSpec(&this->spec); + SDL_CalculateAudioSpec(&_this->spec); /* Allocate memory buffers */ - stMCIBuffer.ulBufferSize = this->spec.size;/* (this->spec.freq / 1000) * 100 */ + stMCIBuffer.ulBufferSize = _this->spec.size;/* (_this->spec.freq / 1000) * 100 */ stMCIBuffer.ulNumBuffers = NUM_BUFFERS; - stMCIBuffer.pBufList = &pAData->aMixBuffers; + stMCIBuffer.pBufList = pAData->aMixBuffers; ulRC = mciSendCommand(pAData->usDeviceId, MCI_BUFFER, MCI_WAIT | MCI_ALLOCATE_MEMORY, &stMCIBuffer, 0); @@ -403,7 +402,7 @@ static int OS2_OpenDevice(_THIS, void *handle, const char *devname, return _MCIError("MCI_BUFFER", ulRC); } pAData->cMixBuffers = stMCIBuffer.ulNumBuffers; - this->spec.size = stMCIBuffer.ulBufferSize; + _this->spec.size = stMCIBuffer.ulBufferSize; /* Fill all device buffers with data */ for (ulIdx = 0; ulIdx < stMCIBuffer.ulNumBuffers; ulIdx++) { @@ -412,13 +411,13 @@ static int OS2_OpenDevice(_THIS, void *handle, const char *devname, pAData->aMixBuffers[ulIdx].ulUserParm = (ULONG)pAData; memset(((PMCI_MIX_BUFFER)stMCIBuffer.pBufList)[ulIdx].pBuffer, - this->spec.silence, stMCIBuffer.ulBufferSize); + _this->spec.silence, stMCIBuffer.ulBufferSize); } /* Write buffers to kick off the amp mixer */ /*pAData->ulQueuedBuf = 1;//stMCIBuffer.ulNumBuffers */ ulRC = pAData->stMCIMixSetup.pmixWrite(pAData->stMCIMixSetup.ulMixHandle, - &pAData->aMixBuffers, + pAData->aMixBuffers, 1 /*stMCIBuffer.ulNumBuffers*/); if (ulRC != MCIERR_SUCCESS) { _mixIOError("pmixWrite", ulRC); diff --git a/src/audio/os2/SDL_os2audio.h b/src/audio/os2/SDL_os2audio.h index 781d41305..46a338463 100644 --- a/src/audio/os2/SDL_os2audio.h +++ b/src/audio/os2/SDL_os2audio.h @@ -33,9 +33,9 @@ #include /* Hidden "this" pointer for the audio functions */ -#define _THIS SDL_AudioDevice *this +#define _THIS SDL_AudioDevice *_this -#define NUM_BUFFERS 3 +#define NUM_BUFFERS 3 typedef struct SDL_PrivateAudioData { diff --git a/src/core/os2/geniconv/os2iconv.c b/src/core/os2/geniconv/os2iconv.c index d7dfe0698..e03a6a410 100644 --- a/src/core/os2/geniconv/os2iconv.c +++ b/src/core/os2/geniconv/os2iconv.c @@ -41,6 +41,10 @@ #endif #include "os2cp.h" +#if !defined(min) +#define min(a, b) (((a) < (b)) ? (a) : (b)) +#endif + #define MAX_CP_NAME_LEN 64 typedef struct iuconv_obj { @@ -127,7 +131,7 @@ extern iconv_t _System os2_iconv_open(const char* tocode, const char* fromcode) uo_fromcode = NULL; } - iuobj = malloc(sizeof(iuconv_obj)); + iuobj = (iuconv_obj *) malloc(sizeof(iuconv_obj)); iuobj->uo_tocode = uo_tocode; iuobj->uo_fromcode = uo_fromcode; iuobj->buf_len = 0; diff --git a/src/core/os2/geniconv/sys2utf8.c b/src/core/os2/geniconv/sys2utf8.c index 392cd4b77..4815476cc 100644 --- a/src/core/os2/geniconv/sys2utf8.c +++ b/src/core/os2/geniconv/sys2utf8.c @@ -83,15 +83,15 @@ int StrUTF8(int fToUTF8, char *pcDst, int cbDst, char *pcSrc, int cbSrc) char *StrUTF8New(int fToUTF8, char *pcStr, int cbStr) { int cbNewStr = (((cbStr > 4)? cbStr : 4) + 1) * 2; - char *pszNewStr = malloc(cbNewStr); + char *pszNewStr = (char *) malloc(cbNewStr); if (pszNewStr == NULL) return NULL; cbNewStr = StrUTF8(fToUTF8, pszNewStr, cbNewStr, pcStr, cbStr); if (cbNewStr != -1) { - pcStr = realloc(pszNewStr, cbNewStr + ((fToUTF8)? 1 : sizeof(short))); - if (pcStr != NULL) + pcStr = (char *) realloc(pszNewStr, cbNewStr + ((fToUTF8)? 1 : sizeof(short))); + if (pcStr) return pcStr; } diff --git a/src/core/os2/geniconv/test.c b/src/core/os2/geniconv/test.c index 405ceac7f..cbe8db084 100644 --- a/src/core/os2/geniconv/test.c +++ b/src/core/os2/geniconv/test.c @@ -51,10 +51,10 @@ int main(void) inbuf = StrUTF8New(1, acBuf, strlen(acBuf)); /* UTF-8 -> system cp. by StrUTF8() */ - if (StrUTF8(0, &acBuf, sizeof(acBuf), inbuf, strlen(inbuf)) == -1) { + if (StrUTF8(0, acBuf, sizeof(acBuf), inbuf, strlen(inbuf)) == -1) { puts("StrUTF8() failed"); } else { - printf("system cp. -> UTF-8 -> system cp.: %s\n", &acBuf); + printf("system cp. -> UTF-8 -> system cp.: %s\n", acBuf); } free(inbuf);