--- np2/x11/soundmng.c 2003/11/16 16:43:45 1.1 +++ np2/x11/soundmng.c 2011/01/15 18:43:13 1.16 @@ -10,8 +10,6 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES @@ -33,13 +31,7 @@ BYTE snddrv_drv2num(const char* cfgstr) { - if (strcasecmp(cfgstr, "NetBSD") == 0) - return SNDDRV_NETBSD; - else if (strcasecmp(cfgstr, "OSS") == 0) - return SNDDRV_OSS; - else if (strcasecmp(cfgstr, "ESD") == 0) - return SNDDRV_ESD; - else if (strcasecmp(cfgstr, "SDL") == 0) + if (strcasecmp(cfgstr, "SDL") == 0) return SNDDRV_SDL; return SNDDRV_NODRV; } @@ -49,12 +41,6 @@ snddrv_num2drv(BYTE num) { switch (num) { - case SNDDRV_NETBSD: - return "NetBSD"; - case SNDDRV_OSS: - return "OSS"; - case SNDDRV_ESD: - return "ESD"; case SNDDRV_SDL: return "SDL"; } @@ -69,35 +55,46 @@ snddrv_num2drv(BYTE num) #include "dosio.h" #include "parts.h" +#include "sysmng.h" #include "sound.h" + #if defined(VERMOUTH_LIB) #include "vermouth.h" -#endif - -#include "sysmng.h" -#if defined(VERMOUTH_LIB) MIDIMOD vermouth_module = NULL; #endif /* * driver */ -int audio_fd = -1; -snddrv_t snddrv; - +static struct { + BOOL (*drvinit)(UINT rate, UINT samples); + BOOL (*drvterm)(void); + void (*drvlock)(void); + void (*drvunlock)(void); + + void (*sndplay)(void); + void (*sndstop)(void); + + void *(*pcmload)(UINT num, const char *path); + void (*pcmdestroy)(void *chanp, UINT num); + void (*pcmplay)(void *chanp, UINT num, BOOL loop); + void (*pcmstop)(void *chanp, UINT num); + void (*pcmvolume)(void *chanp, UINT num, int volume); +} snddrv; +static int audio_fd = -1; static BOOL opened = FALSE; -static UINT mute = 0; static UINT opna_frame; static BOOL nosound_setup(void); +static BOOL sdlaudio_setup(void); static void PARTSCALL (*fnmix)(SINT16* dst, const SINT32* src, UINT size); -#if defined(__GNUC__) && (defined(i386) || defined(__i386__)) -void PARTSCALL _satuation_s16(SINT16 *dst, const SINT32 *src, UINT size); -void PARTSCALL _satuation_s16x(SINT16 *dst, const SINT32 *src, UINT size); -void PARTSCALL satuation_s16mmx(SINT16 *dst, const SINT32 *src, UINT size); +#if defined(GCC_CPU_ARCH_IA32) +void PARTSCALL _saturation_s16(SINT16 *dst, const SINT32 *src, UINT size); +void PARTSCALL _saturation_s16x(SINT16 *dst, const SINT32 *src, UINT size); +void PARTSCALL saturation_s16mmx(SINT16 *dst, const SINT32 *src, UINT size); #endif /* @@ -111,16 +108,19 @@ static void soundmng_pcmdestroy(void); /* * buffer */ -int sound_nextbuf; -char *sound_event; -char *sound_buffer[NSOUNDBUFFER]; +#ifndef NSOUNDBUFFER +#define NSOUNDBUFFER 2 +#endif +static char *sound_buffer[NSOUNDBUFFER]; +static int sound_nextbuf; +static char *sound_event; static BOOL buffer_init(void); static void buffer_destroy(void); static void buffer_clear(void); -UINT +static UINT calc_blocksize(UINT size) { UINT s = size; @@ -131,83 +131,26 @@ calc_blocksize(UINT size) return s; } -UINT -calc_fragment(UINT size) -{ - UINT f; - - for (f = 0; size > (UINT)(1 << f); f++) - continue; - return f; -} - -void +static void snddrv_setup(void) { if (np2oscfg.snddrv < SNDDRV_DRVMAX) { switch (np2oscfg.snddrv) { -#if defined(USE_NETBSDAUDIO) - case SNDDRV_NETBSD: - netbsdaudio_setup(); - return; -#endif -#if defined(USE_OSSAUDIO) - case SNDDRV_OSS: - ossaudio_setup(); - return; -#endif -#if defined(USE_ESDAUDIO) - case SNDDRV_ESD: - esdaudio_setup(); - return; -#endif #if defined(USE_SDLAUDIO) || defined(USE_SDLMIXER) case SNDDRV_SDL: -#if defined(USE_SDLMIXER) - sdlmixer_setup(); -#else sdlaudio_setup(); -#endif return; #endif } } else { -#if defined(USE_SDLMIXER) - if (sdlmixer_setup() == SUCCESS) { - np2oscfg.snddrv = SNDDRV_SDL; - sysmng_update(SYS_UPDATEOSCFG); - return; - } else -#endif -#if defined(USE_SDLAUDIO) +#if defined(USE_SDLAUDIO) || defined(USE_SDLMIXER) if (sdlaudio_setup() == SUCCESS) { np2oscfg.snddrv = SNDDRV_SDL; sysmng_update(SYS_UPDATEOSCFG); return; } else #endif -#if defined(USE_ESDAUDIO) - if (esdaudio_setup() == SUCCESS) { - np2oscfg.snddrv = SNDDRV_ESD; - sysmng_update(SYS_UPDATEOSCFG); - return; - } else -#endif -#if defined(USE_OSSAUDIO) - if (ossaudio_setup() == SUCCESS) { - np2oscfg.snddrv = SNDDRV_OSS; - sysmng_update(SYS_UPDATEOSCFG); - return; - } else -#endif -#if defined(USE_NETBSDAUDIO) - if (netbsdaudio_setup() == SUCCESS) { - np2oscfg.snddrv = SNDDRV_NETBSD; - sysmng_update(SYS_UPDATEOSCFG); - return; - } else -#endif { /* Nothing to do */ /* fall thourgh "no match" */ @@ -220,25 +163,35 @@ snddrv_setup(void) sysmng_update(SYS_UPDATEOSCFG); } +static void +sounddrv_lock(void) +{ + + (*snddrv.drvlock)(); +} + +static void +sounddrv_unlock(void) +{ + + (*snddrv.drvunlock)(); +} + UINT soundmng_create(UINT rate, UINT bufmsec) { UINT samples; -#if defined(VERMOUTH_LIB) - UINT num; -#endif if (opened || ((rate != 11025) && (rate != 22050) && (rate != 44100))) { return 0; } - snddrv_setup(); - - if (bufmsec < 50) { - bufmsec = 50; - } else if (bufmsec > 1000) { + if (bufmsec < 20) + bufmsec = 20; + else if (bufmsec > 1000) bufmsec = 1000; - } + + snddrv_setup(); samples = (rate * bufmsec) / 1000 / 2; samples = calc_blocksize(samples); @@ -246,6 +199,7 @@ soundmng_create(UINT rate, UINT bufmsec) if ((*snddrv.drvinit)(rate, samples) != SUCCESS) { audio_fd = -1; + nosound_setup(); np2oscfg.snddrv = SNDDRV_NODRV; sysmng_update(SYS_UPDATEOSCFG); return 0; @@ -253,10 +207,7 @@ soundmng_create(UINT rate, UINT bufmsec) #if defined(VERMOUTH_LIB) vermouth_module = midimod_create(rate); - for (num = 0; num < 128; num++) { - midimod_loadprogram(vermouth_module, num); - midimod_loadrhythm(vermouth_module, num); - } + midimod_loadall(vermouth_module); #endif soundmng_setreverse(FALSE); @@ -272,8 +223,10 @@ void soundmng_reset(void) { + sounddrv_lock(); sound_nextbuf = 0; sound_event = NULL; + sounddrv_unlock(); buffer_clear(); } @@ -292,7 +245,6 @@ soundmng_destroy(void) } (*snddrv.sndstop)(); (*snddrv.drvterm)(); - buffer_destroy(); audio_fd = -1; opened = FALSE; } @@ -302,18 +254,14 @@ void soundmng_play(void) { - if (!mute) { - (*snddrv.sndplay)(); - } + (*snddrv.sndplay)(); } void soundmng_stop(void) { - if (!mute) { - (*snddrv.sndstop)(); - } + (*snddrv.sndstop)(); } BOOL @@ -332,6 +280,7 @@ soundmng_deinitialize(void) soundmng_pcmdestroy(); soundmng_destroy(); + buffer_destroy(); } void @@ -341,6 +290,7 @@ soundmng_sync(void) SINT16 *q; if (opened) { + sounddrv_lock(); if (sound_event) { pcm = sound_pcmlock(); q = (SINT16 *)sound_event; @@ -348,6 +298,7 @@ soundmng_sync(void) (*fnmix)(q, pcm, opna_frame); sound_pcmunlock(pcm); } + sounddrv_unlock(); } } @@ -355,15 +306,25 @@ void soundmng_setreverse(BOOL reverse) { -#if defined(__GNUC__) && (defined(i386) || defined(__i386__)) +#if defined(GCC_CPU_ARCH_AMD64) + if (!reverse) { + if (mmxflag & (MMXFLAG_NOTSUPPORT|MMXFLAG_DISABLE)) { + fnmix = satuation_s16; + } else { + fnmix = saturation_s16mmx; + } + } else { + fnmix = satuation_s16x; + } +#elif defined(GCC_CPU_ARCH_IA32) if (!reverse) { if (mmxflag & (MMXFLAG_NOTSUPPORT|MMXFLAG_DISABLE)) { - fnmix = _satuation_s16; + fnmix = _saturation_s16; } else { - fnmix = satuation_s16mmx; + fnmix = saturation_s16mmx; } } else { - fnmix = _satuation_s16x; + fnmix = _saturation_s16x; } #else if (!reverse) { @@ -451,16 +412,19 @@ buffer_init(void) { int i; + sounddrv_lock(); for (i = 0; i < NSOUNDBUFFER; i++) { if (sound_buffer[i]) { _MFREE(sound_buffer[i]); } sound_buffer[i] = (char *)_MALLOC(opna_frame, "sound buffer"); if (sound_buffer[i] == NULL) { - fprintf(stderr, "buffer_init: can't alloc memory\n"); + g_printerr("buffer_init: can't alloc memory\n"); + sounddrv_unlock(); return FAILURE; } } + sounddrv_unlock(); return SUCCESS; } @@ -469,11 +433,13 @@ buffer_clear(void) { int i; + sounddrv_lock(); for (i = 0; i < NSOUNDBUFFER; i++) { if (sound_buffer[i]) { memset(sound_buffer[i], 0, opna_frame); } } + sounddrv_unlock(); } static void @@ -481,12 +447,14 @@ buffer_destroy(void) { int i; + sounddrv_lock(); for (i = 0; i < NSOUNDBUFFER; i++) { if (sound_buffer[i]) { _MFREE(sound_buffer[i]); sound_buffer[i] = NULL; } } + sounddrv_unlock(); } /* @@ -496,9 +464,6 @@ static BOOL nosound_drvinit(UINT rate, UINT bufmsec) { - UNUSED(rate); - UNUSED(bufmsec); - return SUCCESS; } @@ -510,6 +475,20 @@ nosound_drvterm(void) } static void +nosound_drvlock(void) +{ + + /* Nothing to do */ +} + +static void +nosound_drvunlock(void) +{ + + /* Nothing to do */ +} + +static void nosound_sndplay(void) { @@ -523,55 +502,38 @@ nosound_sndstop(void) /* Nothing to do */ } -void * +static void * nosound_pcmload(UINT num, const char *path) { - UNUSED(num); - UNUSED(path); - return NULL; } -void +static void nosound_pcmdestroy(void *chanp, UINT num) { - UNUSED(chanp); - UNUSED(num); - /* Nothing to do */ } -void +static void nosound_pcmplay(void *chanp, UINT num, BOOL loop) { - UNUSED(chanp); - UNUSED(num); - UNUSED(loop); - /* Nothing to do */ } -void +static void nosound_pcmstop(void *chanp, UINT num) { - UNUSED(chanp); - UNUSED(num); - /* Nothing to do */ } -void +static void nosound_pcmvolume(void *chanp, UINT num, int volume) { - UNUSED(chanp); - UNUSED(num); - UNUSED(volume); - /* Nothing to do */ } @@ -581,6 +543,8 @@ nosound_setup(void) snddrv.drvinit = nosound_drvinit; snddrv.drvterm = nosound_drvterm; + snddrv.drvlock = nosound_drvlock; + snddrv.drvunlock = nosound_drvunlock; snddrv.sndplay = nosound_sndplay; snddrv.sndstop = nosound_sndstop; snddrv.pcmload = nosound_pcmload; @@ -592,74 +556,109 @@ nosound_setup(void) return SUCCESS; } -#if defined(USE_NETBSDAUDIO) || defined(USE_OSSAUDIO) || defined(USE_ESDAUDIO) -/* - * common driver - */ -static pthread_t ptid; -static BOOL is_proc; - -static void * -buffer_play(void *arg) +#if defined(GCC_CPU_ARCH_AMD64) +void PARTSCALL +_saturation_s16(SINT16 *dst, const SINT32 *src, UINT size) { - char *buf; - size_t len = opna_frame; - size_t s; - ssize_t r; - - UNUSED(arg); - - buf = (char *)_MALLOC(len, "sound playing buf"); - if (buf == NULL) { - fprintf(stderr, "buffer_play: can't alloc memory\n"); - return NULL; - } - - is_proc = TRUE; - while (is_proc) { - if (sound_event) - memset(sound_event, 0, len); - memcpy(buf, sound_buffer[sound_nextbuf], len); - sound_nextbuf = (sound_nextbuf + 1) % NSOUNDBUFFER; - sound_event = sound_buffer[sound_nextbuf]; - - s = 0; - for (;;) { - r = write(audio_fd, buf + s, len - s); - if (r >= 0) { - s += r; - if (len <= s) - break; - } - } - } - _MFREE(buf); - is_proc = FALSE; - - return NULL; + asm volatile ( + "movq %0, %%rcx;" + "movq %1, %%rdx;" + "movl %2, %%ebx;" + "shrl $1, %%ebx;" + "je .ss16_ed;" + ".ss16_lp:" + "movl (%%rdx), %%eax;" + "cmpl $0x000008000, %%eax;" + "jl .ss16_min;" + "movw $0x7fff, %%ax;" + "jmp .ss16_set;" + ".ss16_min:" + "cmpl $0x0ffff8000, %%eax;" + "jg .ss16_set;" + "movw $0x8001, %%ax;" + ".ss16_set:" + "leal 4(%%rdx), %%edx;" + "movw %%ax, (%%rcx);" + "decl %%ebx;" + "leal 2(%%rcx), %%ecx;" + "jne .ss16_lp;" + ".ss16_ed:" + : /* output */ + : "m" (dst), "m" (src), "m" (size) + : "ebx"); } -void -snddrv_play(void) +void PARTSCALL +_saturation_s16x(SINT16 *dst, const SINT32 *src, UINT size) { - if (pthread_create(&ptid, NULL, buffer_play, NULL) != 0) { - fprintf(stderr, "audio_play: can't create thread.\n"); - } + asm volatile ( + "movq %0, %%rcx;" + "movq %1, %%rdx;" + "movl %2, %%ebx;" + "shrl $2, %%ebx;" + "je .ss16x_ed;" + ".ss16x_lp:" + "movl (%%rdx), %%eax;" + "cmpl $0x000008000, %%eax;" + "jl .ss16xl_min;" + "movw $0x7fff, %%ax;" + "jmp .ss16xl_set;" + ".ss16xl_min:" + "cmpl $0x0ffff8000, %%eax;" + "jg .ss16xl_set;" + "movw $0x8001, %%ax;" + ".ss16xl_set:" + "movw %%ax, 2(%%rcx);" + "movl 4(%%rdx), %%eax;" + "cmpl $0x000008000, %%eax;" + "jl .ss16xr_min;" + "movw $0x7fff, %%ax;" + "jmp .ss16xr_set;" + ".ss16xr_min:" + "cmpl $0x0ffff8000, %%eax;" + "jg .ss16xr_set;" + "mov $0x8001, %%ax;" + ".ss16xr_set:" + "movw %%ax, (%%rcx);" + "leal 8(%%rdx), %%edx;" + "decl %%ebx;" + "leal 4(%%rcx), %%ecx;" + "jne .ss16x_lp;" + ".ss16x_ed:" + : /* output */ + : "m" (dst), "m" (src), "m" (size) + : "ebx"); } -void -snddrv_stop(void) +void PARTSCALL +saturation_s16mmx(SINT16 *dst, const SINT32 *src, UINT size) { - is_proc = FALSE; + asm volatile ( + "movq %0, %%rcx;" + "movq %1, %%rdx;" + "movl %2, %%eax;" + "shrl $3, %%eax;" + "je .ss16m_ed;" + "pxor %%mm0, %%mm0;" + ".ss16m_lp:" + "movq (%%rdx), %%mm1;" + "movq 8(%%rdx), %%mm2;" + "packssdw %%mm2, %%mm1;" + "leaq 16(%%rdx), %%rdx;" + "movq %%mm1, (%%rcx);" + "leaq 8(%%rcx), %%rcx;" + "dec %%eax;" + "jne .ss16m_lp;" + "emms;" + ".ss16m_ed:" + : /* output */ + : "m" (dst), "m" (src), "m" (size)); } - -#endif /* USE_NETBSDAUDIO || USE_OSSAUDIO || USE_ESDAUDIO */ - -#if defined(__GNUC__) && (defined(i386) || defined(__i386__)) +#elif defined(GCC_CPU_ARCH_IA32) void PARTSCALL -_satuation_s16(SINT16 *dst, const SINT32 *src, UINT size) +_saturation_s16(SINT16 *dst, const SINT32 *src, UINT size) { asm volatile ( "movl %0, %%ecx;" @@ -690,7 +689,7 @@ _satuation_s16(SINT16 *dst, const SINT32 } void PARTSCALL -_satuation_s16x(SINT16 *dst, const SINT32 *src, UINT size) +_saturation_s16x(SINT16 *dst, const SINT32 *src, UINT size) { asm volatile ( @@ -733,7 +732,7 @@ _satuation_s16x(SINT16 *dst, const SINT3 } void PARTSCALL -satuation_s16mmx(SINT16 *dst, const SINT32 *src, UINT size) +saturation_s16mmx(SINT16 *dst, const SINT32 *src, UINT size) { asm volatile ( @@ -757,6 +756,234 @@ satuation_s16mmx(SINT16 *dst, const SINT : /* output */ : "m" (dst), "m" (src), "m" (size)); } -#endif /* __GNUC__ && (i386 || __i386__) */ +#endif /* GCC_CPU_ARCH_AMD64 */ + +#if defined(USE_SDLAUDIO) || defined(USE_SDLMIXER) + +#include + +static void sdlaudio_lock(void); +static void sdlaudio_unlock(void); +static void sdlaudio_play(void); +static void sdlaudio_stop(void); +static void sdlaudio_callback(void *, unsigned char *, int); + +#if !defined(USE_SDLMIXER) + +static BOOL +sdlaudio_init(UINT rate, UINT samples) +{ + static SDL_AudioSpec fmt; + int rv; + + fmt.freq = rate; + fmt.format = AUDIO_S16SYS; + fmt.channels = 2; + fmt.samples = samples; + fmt.callback = sdlaudio_callback; + fmt.userdata = (void *)(samples * 2 * sizeof(SINT16)); + + rv = SDL_InitSubSystem(SDL_INIT_AUDIO); + if (rv < 0) { + g_printerr("sdlmixer_init: SDL_InitSubSystem(): %s\n", + SDL_GetError()); + return FAILURE; + } + + audio_fd = SDL_OpenAudio(&fmt, NULL); + if (audio_fd < 0) { + g_printerr("sdlaudio_init: SDL_OpenAudio(): %s\n", + SDL_GetError()); + SDL_QuitSubSystem(SDL_INIT_AUDIO); + return FAILURE; + } + + return SUCCESS; +} + +static BOOL +sdlaudio_term(void) +{ + + SDL_PauseAudio(1); + SDL_CloseAudio(); + + return SUCCESS; +} + +static BOOL +sdlaudio_setup(void) +{ + + snddrv.drvinit = sdlaudio_init; + snddrv.drvterm = sdlaudio_term; + snddrv.drvlock = sdlaudio_lock; + snddrv.drvunlock = sdlaudio_unlock; + snddrv.sndplay = sdlaudio_play; + snddrv.sndstop = sdlaudio_stop; + snddrv.pcmload = nosound_pcmload; + snddrv.pcmdestroy = nosound_pcmdestroy; + snddrv.pcmplay = nosound_pcmplay; + snddrv.pcmstop = nosound_pcmstop; + snddrv.pcmvolume = nosound_pcmvolume; + + return SUCCESS; +} + +#else /* USE_SDLMIXER */ + +#include + +static BOOL +sdlmixer_init(UINT rate, UINT samples) +{ + int rv; + + rv = SDL_InitSubSystem(SDL_INIT_AUDIO); + if (rv < 0) { + g_printerr("sdlmixer_init: SDL_InitSubSystem(): %s\n", + SDL_GetError()); + goto failure; + } + + rv = Mix_OpenAudio(rate, AUDIO_S16SYS, 2, samples); + if (rv < 0) { + g_printerr("sdlmixer_init: Mix_OpenAudio(): %s\n", + Mix_GetError()); + goto failure1; + } + + rv = Mix_AllocateChannels(SOUND_MAXPCM); + if (rv < 0) { + g_printerr("sdlmixer_init: Mix_AllocateChannels(): %s\n", + Mix_GetError()); + goto failure1; + } + + Mix_HookMusic(sdlaudio_callback, (void*)(samples * 2 * sizeof(SINT16))); + + return SUCCESS; + +failure1: + Mix_CloseAudio(); +failure: + return FAILURE; +} + +static BOOL +sdlmixer_term(void) +{ + + SDL_PauseAudio(1); + Mix_CloseAudio(); + + return SUCCESS; +} + +static void * +sdlmixer_pcmload(UINT num, const char *path) +{ + Mix_Chunk *chunk; + + chunk = Mix_LoadWAV(path); + return (void *)chunk; +} + +static void +sdlmixer_pcmdestroy(void *chanp, UINT num) +{ + Mix_Chunk *chunk = (Mix_Chunk *)chanp; + + Mix_HaltChannel(num); + Mix_FreeChunk(chunk); +} + +static void +sdlmixer_pcmplay(void *chanp, UINT num, BOOL loop) +{ + Mix_Chunk *chunk = (Mix_Chunk *)chanp; + + Mix_PlayChannel(num, chunk, loop ? -1 : 1); +} + +static void +sdlmixer_pcmstop(void *chanp, UINT num) +{ + + Mix_HaltChannel(num); +} + +static void +sdlmixer_pcmvolume(void *chanp, UINT num, int volume) +{ + + Mix_Volume(num, (MIX_MAX_VOLUME * volume) / 100); +} + +static BOOL +sdlaudio_setup(void) +{ + + snddrv.drvinit = sdlmixer_init; + snddrv.drvterm = sdlmixer_term; + snddrv.drvlock = sdlaudio_lock; + snddrv.drvunlock = sdlaudio_unlock; + snddrv.sndplay = sdlaudio_play; + snddrv.sndstop = sdlaudio_stop; + snddrv.pcmload = sdlmixer_pcmload; + snddrv.pcmdestroy = sdlmixer_pcmdestroy; + snddrv.pcmplay = sdlmixer_pcmplay; + snddrv.pcmstop = sdlmixer_pcmstop; + snddrv.pcmvolume = sdlmixer_pcmvolume; + + return SUCCESS; +} + +#endif /* !USE_SDLMIXER */ + +static void +sdlaudio_lock(void) +{ + + SDL_LockAudio(); +} + +static void +sdlaudio_unlock(void) +{ + + SDL_UnlockAudio(); +} + +static void +sdlaudio_play(void) +{ + + SDL_PauseAudio(0); +} + +static void +sdlaudio_stop(void) +{ + + SDL_PauseAudio(1); +} + +static void +sdlaudio_callback(void *userdata, unsigned char *stream, int len) +{ + UINT samples = (UINT)userdata; + int nextbuf = sound_nextbuf; + + if (sound_event != NULL) + memset(sound_event, 0, samples); + sound_nextbuf = (sound_nextbuf + 1) % NSOUNDBUFFER; + sound_event = sound_buffer[sound_nextbuf]; + + SDL_MixAudio(stream, (const void *)sound_buffer[nextbuf], len, + SDL_MIX_MAXVOLUME); +} + +#endif /* USE_SDLAUDIO || USE_SDLMIXER */ #endif /* !NOSOUND */