mirror of https://github.com/encounter/SDL.git
os2: misc build fixes
This commit is contained in:
parent
bfc80d83c2
commit
a4040293dd
|
@ -26,7 +26,6 @@
|
||||||
|
|
||||||
#include "../../core/os2/SDL_os2.h"
|
#include "../../core/os2/SDL_os2.h"
|
||||||
|
|
||||||
#include "SDL_timer.h"
|
|
||||||
#include "SDL_audio.h"
|
#include "SDL_audio.h"
|
||||||
#include "../SDL_audio_c.h"
|
#include "../SDL_audio_c.h"
|
||||||
#include "SDL_os2audio.h"
|
#include "SDL_os2audio.h"
|
||||||
|
@ -34,12 +33,12 @@
|
||||||
/*
|
/*
|
||||||
void lockIncr(volatile int *piVal);
|
void lockIncr(volatile int *piVal);
|
||||||
#pragma aux lockIncr = \
|
#pragma aux lockIncr = \
|
||||||
" lock add [eax], 1 "\
|
"lock add [eax], 1 "\
|
||||||
parm [eax];
|
parm [eax];
|
||||||
|
|
||||||
void lockDecr(volatile int *piVal);
|
void lockDecr(volatile int *piVal);
|
||||||
#pragma aux lockDecr = \
|
#pragma aux lockDecr = \
|
||||||
" lock sub [eax], 1 "\
|
"lock sub [eax], 1 "\
|
||||||
parm [eax];
|
parm [eax];
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -169,7 +168,7 @@ static void OS2_DetectDevices(void)
|
||||||
|
|
||||||
static void OS2_WaitDevice(_THIS)
|
static void OS2_WaitDevice(_THIS)
|
||||||
{
|
{
|
||||||
SDL_PrivateAudioData *pAData = (SDL_PrivateAudioData *)this->hidden;
|
SDL_PrivateAudioData *pAData = (SDL_PrivateAudioData *)_this->hidden;
|
||||||
ULONG ulRC;
|
ULONG ulRC;
|
||||||
|
|
||||||
/* Wait for an audio chunk to finish */
|
/* Wait for an audio chunk to finish */
|
||||||
|
@ -181,13 +180,13 @@ static void OS2_WaitDevice(_THIS)
|
||||||
|
|
||||||
static Uint8 *OS2_GetDeviceBuf(_THIS)
|
static Uint8 *OS2_GetDeviceBuf(_THIS)
|
||||||
{
|
{
|
||||||
SDL_PrivateAudioData *pAData = (SDL_PrivateAudioData *)this->hidden;
|
SDL_PrivateAudioData *pAData = (SDL_PrivateAudioData *)_this->hidden;
|
||||||
return pAData->aMixBuffers[pAData->ulNextBuf].pBuffer;
|
return (Uint8 *) pAData->aMixBuffers[pAData->ulNextBuf].pBuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void OS2_PlayDevice(_THIS)
|
static void OS2_PlayDevice(_THIS)
|
||||||
{
|
{
|
||||||
SDL_PrivateAudioData *pAData = (SDL_PrivateAudioData *)this->hidden;
|
SDL_PrivateAudioData *pAData = (SDL_PrivateAudioData *)_this->hidden;
|
||||||
ULONG ulRC;
|
ULONG ulRC;
|
||||||
PMCI_MIX_BUFFER pMixBuffer = &pAData->aMixBuffers[pAData->ulNextBuf];
|
PMCI_MIX_BUFFER pMixBuffer = &pAData->aMixBuffers[pAData->ulNextBuf];
|
||||||
|
|
||||||
|
@ -204,7 +203,7 @@ static void OS2_PlayDevice(_THIS)
|
||||||
|
|
||||||
static void OS2_CloseDevice(_THIS)
|
static void OS2_CloseDevice(_THIS)
|
||||||
{
|
{
|
||||||
SDL_PrivateAudioData *pAData = (SDL_PrivateAudioData *)this->hidden;
|
SDL_PrivateAudioData *pAData = (SDL_PrivateAudioData *)_this->hidden;
|
||||||
MCI_GENERIC_PARMS sMCIGenericParms;
|
MCI_GENERIC_PARMS sMCIGenericParms;
|
||||||
ULONG ulRC;
|
ULONG ulRC;
|
||||||
|
|
||||||
|
@ -230,7 +229,7 @@ static void OS2_CloseDevice(_THIS)
|
||||||
|
|
||||||
stMCIBuffer.ulBufferSize = pAData->aMixBuffers[0].ulBufferLength;
|
stMCIBuffer.ulBufferSize = pAData->aMixBuffers[0].ulBufferLength;
|
||||||
stMCIBuffer.ulNumBuffers = pAData->cMixBuffers;
|
stMCIBuffer.ulNumBuffers = pAData->cMixBuffers;
|
||||||
stMCIBuffer.pBufList = &pAData->aMixBuffers;
|
stMCIBuffer.pBufList = pAData->aMixBuffers;
|
||||||
|
|
||||||
ulRC = mciSendCommand(pAData->usDeviceId, MCI_BUFFER,
|
ulRC = mciSendCommand(pAData->usDeviceId, MCI_BUFFER,
|
||||||
MCI_WAIT | MCI_DEALLOCATE_MEMORY, &stMCIBuffer, 0);
|
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(stMCIAmpOpen);
|
||||||
SDL_zero(stMCIBuffer);
|
SDL_zero(stMCIBuffer);
|
||||||
|
|
||||||
for (SDLAudioFmt = SDL_FirstAudioFormat(this->spec.format);
|
for (SDLAudioFmt = SDL_FirstAudioFormat(_this->spec.format);
|
||||||
SDLAudioFmt != 0; SDLAudioFmt = SDL_NextAudioFormat()) {
|
SDLAudioFmt != 0; SDLAudioFmt = SDL_NextAudioFormat()) {
|
||||||
if (SDLAudioFmt == AUDIO_U8 || SDLAudioFmt == AUDIO_S16)
|
if (SDLAudioFmt == AUDIO_U8 || SDLAudioFmt == AUDIO_S16)
|
||||||
break;
|
break;
|
||||||
|
@ -277,10 +276,10 @@ static int OS2_OpenDevice(_THIS, void *handle, const char *devname,
|
||||||
SDLAudioFmt = AUDIO_S16;
|
SDLAudioFmt = AUDIO_S16;
|
||||||
}
|
}
|
||||||
|
|
||||||
pAData = SDL_calloc(1, sizeof(SDL_PrivateAudioData));
|
pAData = (SDL_PrivateAudioData *) SDL_calloc(1, sizeof(struct SDL_PrivateAudioData));
|
||||||
if (pAData == NULL)
|
if (pAData == NULL)
|
||||||
return SDL_OutOfMemory();
|
return SDL_OutOfMemory();
|
||||||
this->hidden = pAData;
|
_this->hidden = pAData;
|
||||||
|
|
||||||
ulRC = DosCreateEventSem(NULL, &pAData->hevBuf, DCE_AUTORESET, TRUE);
|
ulRC = DosCreateEventSem(NULL, &pAData->hevBuf, DCE_AUTORESET, TRUE);
|
||||||
if (ulRC != NO_ERROR) {
|
if (ulRC != NO_ERROR) {
|
||||||
|
@ -334,21 +333,21 @@ static int OS2_OpenDevice(_THIS, void *handle, const char *devname,
|
||||||
&stMCIAmpSet, 0);
|
&stMCIAmpSet, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
this->spec.format = SDLAudioFmt;
|
_this->spec.format = SDLAudioFmt;
|
||||||
this->spec.channels = this->spec.channels > 1 ? 2 : 1;
|
_this->spec.channels = _this->spec.channels > 1 ? 2 : 1;
|
||||||
if (this->spec.freq < 8000) {
|
if (_this->spec.freq < 8000) {
|
||||||
this->spec.freq = 8000;
|
_this->spec.freq = 8000;
|
||||||
new_freq = TRUE;
|
new_freq = TRUE;
|
||||||
} else if (this->spec.freq > 48000) {
|
} else if (_this->spec.freq > 48000) {
|
||||||
this->spec.freq = 48000;
|
_this->spec.freq = 48000;
|
||||||
new_freq = TRUE;
|
new_freq = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Setup mixer. */
|
/* Setup mixer. */
|
||||||
pAData->stMCIMixSetup.ulFormatTag = MCI_WAVE_FORMAT_PCM;
|
pAData->stMCIMixSetup.ulFormatTag = MCI_WAVE_FORMAT_PCM;
|
||||||
pAData->stMCIMixSetup.ulBitsPerSample = SDL_AUDIO_BITSIZE(SDLAudioFmt);
|
pAData->stMCIMixSetup.ulBitsPerSample = SDL_AUDIO_BITSIZE(SDLAudioFmt);
|
||||||
pAData->stMCIMixSetup.ulSamplesPerSec = this->spec.freq;
|
pAData->stMCIMixSetup.ulSamplesPerSec = _this->spec.freq;
|
||||||
pAData->stMCIMixSetup.ulChannels = this->spec.channels;
|
pAData->stMCIMixSetup.ulChannels = _this->spec.channels;
|
||||||
pAData->stMCIMixSetup.ulDeviceType = MCI_DEVTYPE_WAVEFORM_AUDIO;
|
pAData->stMCIMixSetup.ulDeviceType = MCI_DEVTYPE_WAVEFORM_AUDIO;
|
||||||
if (iscapture == 0) {
|
if (iscapture == 0) {
|
||||||
pAData->stMCIMixSetup.ulFormatMode= MCI_PLAY;
|
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,
|
ulRC = mciSendCommand(pAData->usDeviceId, MCI_MIXSETUP,
|
||||||
MCI_WAIT | MCI_MIXSETUP_INIT, &pAData->stMCIMixSetup, 0);
|
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;
|
new_freq = TRUE;
|
||||||
pAData->stMCIMixSetup.ulSamplesPerSec = 44100;
|
pAData->stMCIMixSetup.ulSamplesPerSec = 44100;
|
||||||
this->spec.freq = 44100;
|
_this->spec.freq = 44100;
|
||||||
ulRC = mciSendCommand(pAData->usDeviceId, MCI_MIXSETUP,
|
ulRC = mciSendCommand(pAData->usDeviceId, MCI_MIXSETUP,
|
||||||
MCI_WAIT | MCI_MIXSETUP_INIT, &pAData->stMCIMixSetup, 0);
|
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);
|
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() */
|
/* also see SDL_audio.c:prepare_audiospec() */
|
||||||
/* Pick a default of ~46 ms at desired frequency */
|
/* 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;
|
Uint32 power2 = 1;
|
||||||
while (power2 < samples) {
|
while (power2 < samples) {
|
||||||
power2 <<= 1;
|
power2 <<= 1;
|
||||||
}
|
}
|
||||||
this->spec.samples = power2;
|
_this->spec.samples = power2;
|
||||||
}
|
}
|
||||||
/* Update the fragment size as size in bytes */
|
/* Update the fragment size as size in bytes */
|
||||||
SDL_CalculateAudioSpec(&this->spec);
|
SDL_CalculateAudioSpec(&_this->spec);
|
||||||
|
|
||||||
/* Allocate memory buffers */
|
/* 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.ulNumBuffers = NUM_BUFFERS;
|
||||||
stMCIBuffer.pBufList = &pAData->aMixBuffers;
|
stMCIBuffer.pBufList = pAData->aMixBuffers;
|
||||||
|
|
||||||
ulRC = mciSendCommand(pAData->usDeviceId, MCI_BUFFER,
|
ulRC = mciSendCommand(pAData->usDeviceId, MCI_BUFFER,
|
||||||
MCI_WAIT | MCI_ALLOCATE_MEMORY, &stMCIBuffer, 0);
|
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);
|
return _MCIError("MCI_BUFFER", ulRC);
|
||||||
}
|
}
|
||||||
pAData->cMixBuffers = stMCIBuffer.ulNumBuffers;
|
pAData->cMixBuffers = stMCIBuffer.ulNumBuffers;
|
||||||
this->spec.size = stMCIBuffer.ulBufferSize;
|
_this->spec.size = stMCIBuffer.ulBufferSize;
|
||||||
|
|
||||||
/* Fill all device buffers with data */
|
/* Fill all device buffers with data */
|
||||||
for (ulIdx = 0; ulIdx < stMCIBuffer.ulNumBuffers; ulIdx++) {
|
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;
|
pAData->aMixBuffers[ulIdx].ulUserParm = (ULONG)pAData;
|
||||||
|
|
||||||
memset(((PMCI_MIX_BUFFER)stMCIBuffer.pBufList)[ulIdx].pBuffer,
|
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 */
|
/* Write buffers to kick off the amp mixer */
|
||||||
/*pAData->ulQueuedBuf = 1;//stMCIBuffer.ulNumBuffers */
|
/*pAData->ulQueuedBuf = 1;//stMCIBuffer.ulNumBuffers */
|
||||||
ulRC = pAData->stMCIMixSetup.pmixWrite(pAData->stMCIMixSetup.ulMixHandle,
|
ulRC = pAData->stMCIMixSetup.pmixWrite(pAData->stMCIMixSetup.ulMixHandle,
|
||||||
&pAData->aMixBuffers,
|
pAData->aMixBuffers,
|
||||||
1 /*stMCIBuffer.ulNumBuffers*/);
|
1 /*stMCIBuffer.ulNumBuffers*/);
|
||||||
if (ulRC != MCIERR_SUCCESS) {
|
if (ulRC != MCIERR_SUCCESS) {
|
||||||
_mixIOError("pmixWrite", ulRC);
|
_mixIOError("pmixWrite", ulRC);
|
||||||
|
|
|
@ -33,9 +33,9 @@
|
||||||
#include <os2me.h>
|
#include <os2me.h>
|
||||||
|
|
||||||
/* Hidden "this" pointer for the audio functions */
|
/* 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
|
typedef struct SDL_PrivateAudioData
|
||||||
{
|
{
|
||||||
|
|
|
@ -41,6 +41,10 @@
|
||||||
#endif
|
#endif
|
||||||
#include "os2cp.h"
|
#include "os2cp.h"
|
||||||
|
|
||||||
|
#if !defined(min)
|
||||||
|
#define min(a, b) (((a) < (b)) ? (a) : (b))
|
||||||
|
#endif
|
||||||
|
|
||||||
#define MAX_CP_NAME_LEN 64
|
#define MAX_CP_NAME_LEN 64
|
||||||
|
|
||||||
typedef struct iuconv_obj {
|
typedef struct iuconv_obj {
|
||||||
|
@ -127,7 +131,7 @@ extern iconv_t _System os2_iconv_open(const char* tocode, const char* fromcode)
|
||||||
uo_fromcode = NULL;
|
uo_fromcode = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
iuobj = malloc(sizeof(iuconv_obj));
|
iuobj = (iuconv_obj *) malloc(sizeof(iuconv_obj));
|
||||||
iuobj->uo_tocode = uo_tocode;
|
iuobj->uo_tocode = uo_tocode;
|
||||||
iuobj->uo_fromcode = uo_fromcode;
|
iuobj->uo_fromcode = uo_fromcode;
|
||||||
iuobj->buf_len = 0;
|
iuobj->buf_len = 0;
|
||||||
|
|
|
@ -83,15 +83,15 @@ int StrUTF8(int fToUTF8, char *pcDst, int cbDst, char *pcSrc, int cbSrc)
|
||||||
char *StrUTF8New(int fToUTF8, char *pcStr, int cbStr)
|
char *StrUTF8New(int fToUTF8, char *pcStr, int cbStr)
|
||||||
{
|
{
|
||||||
int cbNewStr = (((cbStr > 4)? cbStr : 4) + 1) * 2;
|
int cbNewStr = (((cbStr > 4)? cbStr : 4) + 1) * 2;
|
||||||
char *pszNewStr = malloc(cbNewStr);
|
char *pszNewStr = (char *) malloc(cbNewStr);
|
||||||
|
|
||||||
if (pszNewStr == NULL)
|
if (pszNewStr == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
cbNewStr = StrUTF8(fToUTF8, pszNewStr, cbNewStr, pcStr, cbStr);
|
cbNewStr = StrUTF8(fToUTF8, pszNewStr, cbNewStr, pcStr, cbStr);
|
||||||
if (cbNewStr != -1) {
|
if (cbNewStr != -1) {
|
||||||
pcStr = realloc(pszNewStr, cbNewStr + ((fToUTF8)? 1 : sizeof(short)));
|
pcStr = (char *) realloc(pszNewStr, cbNewStr + ((fToUTF8)? 1 : sizeof(short)));
|
||||||
if (pcStr != NULL)
|
if (pcStr)
|
||||||
return pcStr;
|
return pcStr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,10 +51,10 @@ int main(void)
|
||||||
inbuf = StrUTF8New(1, acBuf, strlen(acBuf));
|
inbuf = StrUTF8New(1, acBuf, strlen(acBuf));
|
||||||
|
|
||||||
/* UTF-8 -> system cp. by StrUTF8() */
|
/* 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");
|
puts("StrUTF8() failed");
|
||||||
} else {
|
} else {
|
||||||
printf("system cp. -> UTF-8 -> system cp.: %s\n", &acBuf);
|
printf("system cp. -> UTF-8 -> system cp.: %s\n", acBuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
free(inbuf);
|
free(inbuf);
|
||||||
|
|
Loading…
Reference in New Issue