diff --git a/sfxr/main.cpp b/sfxr/main.cpp index 69a30c6..16946b3 100644 --- a/sfxr/main.cpp +++ b/sfxr/main.cpp @@ -28,11 +28,7 @@ */ -#ifdef WIN32 -#include "ddrawkit.h" -#else #include "sdlkit.h" -#endif #include #include @@ -40,13 +36,7 @@ #include #include -#ifdef WIN32 -#include "DPInput.h" // WIN32 -#include "pa/portaudio.h" -#include "fileselector.h" // WIN32 -#else #include "SDL.h" -#endif #define rnd(n) (rand()%(n+1)) @@ -557,37 +547,15 @@ void SynthSample(int length, float* buffer, FILE* file) } DPInput *input; -#ifdef WIN32 -PortAudioStream *stream; -#endif bool mute_stream; -#ifdef WIN32 -//ancient portaudio stuff -static int AudioCallback(void *inputBuffer, void *outputBuffer, - unsigned long framesPerBuffer, - PaTimestamp outTime, void *userData) -{ - float *out=(float*)outputBuffer; - float *in=(float*)inputBuffer; - (void)outTime; - - if(playing_sample && !mute_stream) - SynthSample(framesPerBuffer, out, NULL); - else - for(int i=0;i 1.0) f = 1.0; ((Sint16*)stream)[l] = (Sint16)(f * 32767); } + delete[] fbuf; } else memset(stream, 0, len); } -#endif bool ExportWAV(char* filename) { @@ -608,7 +576,6 @@ bool ExportWAV(char* filename) if(!foutput) return false; // write wav header - char string[32]; unsigned int dword=0; unsigned short word=0; fwrite("RIFF", 4, 1, foutput); // "RIFF" @@ -1398,22 +1365,6 @@ void ddkInit() ResetParams(); -#ifdef WIN32 - // Init PortAudio - SetEnvironmentVariable("PA_MIN_LATENCY_MSEC", "75"); // WIN32 - Pa_Initialize(); - Pa_OpenDefaultStream( - &stream, - 0, - 1, - paFloat32, // output type - 44100, - 512, // samples per buffer - 0, // # of buffers - AudioCallback, - NULL); - Pa_StartStream(stream); -#else SDL_AudioSpec des; des.freq = 44100; des.format = AUDIO_S16SYS; @@ -1423,7 +1374,6 @@ void ddkInit() des.userdata = NULL; VERIFY(!SDL_OpenAudio(&des, NULL)); SDL_PauseAudio(0); -#endif } void ddkFree() @@ -1431,12 +1381,5 @@ void ddkFree() delete input; free(ld48.data); free(font.data); - -#ifdef WIN32 - // Close PortAudio - Pa_StopStream(stream); - Pa_CloseStream(stream); - Pa_Terminate(); -#endif } diff --git a/sfxr/sdlkit.h b/sfxr/sdlkit.h index 2e6cc05..1d8fd1e 100644 --- a/sfxr/sdlkit.h +++ b/sfxr/sdlkit.h @@ -96,15 +96,23 @@ static void sdlupdate () static bool ddkLock () { - SDL_LockSurface(sdlscreen); + if(SDL_MUSTLOCK(sdlscreen)) + { + if(SDL_LockSurface(sdlscreen) < 0) + return false; + } ddkpitch = sdlscreen->pitch / (sdlscreen->format->BitsPerPixel == 32 ? 4 : 2); ddkscreen16 = (Uint16*)(sdlscreen->pixels); ddkscreen32 = (Uint32*)(sdlscreen->pixels); + return true; } static void ddkUnlock () { - SDL_UnlockSurface(sdlscreen); + if(SDL_MUSTLOCK(sdlscreen)) + { + SDL_UnlockSurface(sdlscreen); + } } static void ddkSetMode (int width, int height, int bpp, int refreshrate, int fullscreen, const char *title) diff --git a/sfxr/sfxr b/sfxr/sfxr deleted file mode 100755 index 40a37a1..0000000 Binary files a/sfxr/sfxr and /dev/null differ