From 222f026899ff01e0c44c54c50417c8e99257f888 Mon Sep 17 00:00:00 2001 From: Ozkan Sezer Date: Wed, 14 Oct 2020 23:01:03 +0300 Subject: [PATCH] os/2: port from SDL2-2.0.4 to SDL2-2.0.5: changes to SDL_os2audio.c, SDL_os2video.c, os2/SDL_systhread.c in order to accomodate SDL2-2.0.5 changes. - audio: WaitDone() is gone, CloseDevice() interface changes. - events / video: DropFile() changes: SDL_DROPBEGIN and SDL_DROPCOMPLETE events, window IDs for drops. - thread: struct SDL_Thread->stacksize --- src/audio/os2/SDL_os2audio.c | 19 ++++--------------- src/thread/os2/SDL_systhread.c | 20 +++++++++++++++----- src/video/os2/SDL_os2video.c | 6 ++++-- 3 files changed, 23 insertions(+), 22 deletions(-) diff --git a/src/audio/os2/SDL_os2audio.c b/src/audio/os2/SDL_os2audio.c index 9da0addc0..bf40fb8ca 100644 --- a/src/audio/os2/SDL_os2audio.c +++ b/src/audio/os2/SDL_os2audio.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2016 Sam Lantinga + Copyright (C) 1997-2017 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -209,13 +209,6 @@ static void OS2_PlayDevice(_THIS) pAData->ulNextBuf = (pAData->ulNextBuf + 1) % pAData->cMixBuffers; } -static void OS2_WaitDone(_THIS) -{ - PSDL_PrivateAudioData pAData = (PSDL_PrivateAudioData)this->hidden; - - DosWaitEventSem( pAData->hevBuf, 3000 ); -} - static void OS2_CloseDevice(_THIS) { PSDL_PrivateAudioData pAData = (PSDL_PrivateAudioData)this->hidden; @@ -264,7 +257,6 @@ static void OS2_CloseDevice(_THIS) DosCloseEventSem( pAData->hevBuf ); SDL_free( pAData ); - this->hidden = NULL; } static int OS2_OpenDevice(_THIS, void *handle, const char *devname, @@ -314,7 +306,6 @@ static int OS2_OpenDevice(_THIS, void *handle, const char *devname, if ( ulRC != MCIERR_SUCCESS ) { stMCIAmpOpen.usDeviceID = (USHORT)~0; - OS2_CloseDevice( this ); return _MCIError( "MCI_OPEN", ulRC ); } pAData->usDeviceId = stMCIAmpOpen.usDeviceID; @@ -338,7 +329,6 @@ static int OS2_OpenDevice(_THIS, void *handle, const char *devname, MCI_WAIT | MCI_SET_OFF | MCI_SET_ITEM, &stMCIAmpSet, 0 ); - // Set record volume. stMCIAmpSet.ulLevel = _getEnvULong( "SDL_AUDIO_RECVOL", 100, 90 ); stMCIAmpSet.ulItem = MCI_AMP_SET_AUDIO; @@ -394,7 +384,6 @@ static int OS2_OpenDevice(_THIS, void *handle, const char *devname, if ( ulRC != MCIERR_SUCCESS ) { pAData->stMCIMixSetup.ulBitsPerSample = 0; - OS2_CloseDevice( this ); return _MCIError( "MCI_MIXSETUP", ulRC ); } @@ -412,7 +401,6 @@ static int OS2_OpenDevice(_THIS, void *handle, const char *devname, MCI_WAIT | MCI_ALLOCATE_MEMORY, &stMCIBuffer, 0 ); if ( ulRC != MCIERR_SUCCESS ) { - OS2_CloseDevice( this ); return _MCIError( "MCI_BUFFER", ulRC ); } pAData->cMixBuffers = stMCIBuffer.ulNumBuffers; @@ -452,11 +440,12 @@ static int OS2_Init(SDL_AudioDriverImpl * impl) impl->OpenDevice = OS2_OpenDevice; impl->PlayDevice = OS2_PlayDevice; impl->WaitDevice = OS2_WaitDevice; - impl->WaitDone = OS2_WaitDone; impl->GetDeviceBuf = OS2_GetDeviceBuf; impl->CloseDevice = OS2_CloseDevice; -// [Digi]: SDL 2.0 does not support recording yet (2016-02-24). +// TODO: IMPLEMENT CAPTURE SUPPORT: +// impl->CaptureFromDevice = ; +// impl->FlushCapture = ; // impl->HasCaptureSupport = SDL_TRUE; return 1; /* this audio target is available. */ diff --git a/src/thread/os2/SDL_systhread.c b/src/thread/os2/SDL_systhread.c index 878aa606f..64d5d6f6d 100644 --- a/src/thread/os2/SDL_systhread.c +++ b/src/thread/os2/SDL_systhread.c @@ -74,14 +74,24 @@ SDL_SYS_CreateThread(SDL_Thread * thread, void *args, if ( pThreadParms == NULL ) return SDL_OutOfMemory(); - // Save the function which we will have to call to clear the RTL of calling app! - pThreadParms->pfnCurrentEndThread = pfnEndThread; + if (thread->stacksize == 0) + thread->stacksize = 65536; + // Also save the real parameters we have to pass to thread function pThreadParms->args = args; - // Start the thread using the runtime library of calling app! - thread->handle = (SYS_ThreadHandle) - ( (size_t) pfnBeginThread( RunThread, NULL, 65535, pThreadParms ) ); + if (pfnBeginThread) { + // Save the function which we will have to call to clear the RTL of calling app! + pThreadParms->pfnCurrentEndThread = pfnEndThread; + // Start the thread using the runtime library of calling app! + thread->handle = (SYS_ThreadHandle) + pfnBeginThread( RunThread, NULL, thread->stacksize, pThreadParms ); + } + else { + pThreadParms->pfnCurrentEndThread = _endthread; + thread->handle = (SYS_ThreadHandle) + _beginthread( RunThread, NULL, thread->stacksize, pThreadParms ); + } if ( thread->handle == -1 ) return SDL_SetError( "Not enough resources to create thread" ); diff --git a/src/video/os2/SDL_os2video.c b/src/video/os2/SDL_os2video.c index cf9d6f28f..ad5d6554d 100644 --- a/src/video/os2/SDL_os2video.c +++ b/src/video/os2/SDL_os2video.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2016 Sam Lantinga + Copyright (C) 1997-2017 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -428,7 +428,7 @@ static MRESULT _wmDrop(PWINDATA pWinData, PDRAGINFO pDragInfo) // Send to SDL full file name converted to UTF-8. pcFName = OS2_SysToUTF8( acFName ); - SDL_SendDropFile( pcFName ); + SDL_SendDropFile( pWinData->window, pcFName ); SDL_free( pcFName ); // Notify a source that a drag operation is complete. @@ -442,6 +442,8 @@ static MRESULT _wmDrop(PWINDATA pWinData, PDRAGINFO pDragInfo) DrgDeleteDraginfoStrHandles( pDragInfo ); DrgFreeDraginfo( pDragInfo ); + SDL_SendDropComplete( pWinData->window ); + return (MRESULT)FALSE; }