X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?p=pcsx_rearmed.git;a=blobdiff_plain;f=plugins%2Fdfsound%2Fsdl.c;h=ce92b6e66b571e7a6f1679cb4a5cc341485363d4;hp=45ccba2dde7c8ffac6489e5a98d1bd88541b53fc;hb=8a55ebcc07d4f860633db8c77bb9e16bcfa03313;hpb=ef79bbde537d6b9c745a7d86cb9df1d04c35590d diff --git a/plugins/dfsound/sdl.c b/plugins/dfsound/sdl.c index 45ccba2d..ce92b6e6 100644 --- a/plugins/dfsound/sdl.c +++ b/plugins/dfsound/sdl.c @@ -16,10 +16,9 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307 USA */ -#include "stdafx.h" - -#include "externals.h" +#include #include +#include "out.h" #define BUFFER_SIZE 22050 @@ -61,40 +60,40 @@ static void DestroySDL() { } } -void SetupSound(void) { +static int sdl_init(void) { SDL_AudioSpec spec; - if (pSndBuffer != NULL) return; + if (pSndBuffer != NULL) return -1; InitSDL(); spec.freq = 44100; spec.format = AUDIO_S16SYS; - spec.channels = iDisStereo ? 1 : 2; + spec.channels = 2; spec.samples = 512; spec.callback = SOUND_FillAudio; if (SDL_OpenAudio(&spec, NULL) < 0) { DestroySDL(); - return; + return -1; } iBufSize = BUFFER_SIZE; - if (iDisStereo) iBufSize /= 2; pSndBuffer = (short *)malloc(iBufSize * sizeof(short)); if (pSndBuffer == NULL) { SDL_CloseAudio(); - return; + return -1; } iReadPos = 0; iWritePos = 0; SDL_PauseAudio(0); + return 0; } -void RemoveSound(void) { +static void sdl_finish(void) { if (pSndBuffer == NULL) return; SDL_CloseAudio(); @@ -104,20 +103,20 @@ void RemoveSound(void) { pSndBuffer = NULL; } -unsigned long SoundGetBytesBuffered(void) { +static int sdl_busy(void) { int size; - if (pSndBuffer == NULL) return SOUNDSIZE; + if (pSndBuffer == NULL) return 1; size = iReadPos - iWritePos; if (size <= 0) size += iBufSize; - if (size < iBufSize / 2) return SOUNDSIZE; + if (size < iBufSize / 2) return 1; return 0; } -void SoundFeedStreamData(unsigned char *pSound, long lBytes) { +static void sdl_feed(void *pSound, int lBytes) { short *p = (short *)pSound; if (pSndBuffer == NULL) return; @@ -133,3 +132,12 @@ void SoundFeedStreamData(unsigned char *pSound, long lBytes) { lBytes -= sizeof(short); } } + +void out_register_sdl(struct out_driver *drv) +{ + drv->name = "sdl"; + drv->init = sdl_init; + drv->finish = sdl_finish; + drv->busy = sdl_busy; + drv->feed = sdl_feed; +}