--- np2/win9x/soundmng.cpp 2005/02/09 20:11:35 1.9 +++ np2/win9x/soundmng.cpp 2006/12/24 00:52:29 1.12 @@ -10,7 +10,11 @@ #if defined(VERMOUTH_LIB) #include "vermouth.h" #endif +#if defined(MT32SOUND_DLL) +#include "mt32snd.h" +#endif +#if !defined(_WIN64) #ifdef __cplusplus extern "C" { #endif @@ -18,6 +22,7 @@ void __fastcall satuation_s16mmx(SINT16 #ifdef __cplusplus } #endif +#endif #if 1 @@ -50,7 +55,7 @@ static void (PARTSCALL *fnmix)(SINT16 // ---- directsound -static BOOL dsoundcreate(void) { +static BRESULT dsoundcreate(void) { // DirectSound¤Î½é´ü²½ if (FAILED(DirectSoundCreate(0, &pDSound, 0))) { @@ -75,6 +80,7 @@ UINT soundmng_create(UINT rate, UINT ms) UINT samples; DSBUFFERDESC dsbdesc; PCMWAVEFORMAT pcmwf; + int i; if ((pDSound == NULL) || (rate != 11025) && (rate != 22050) && (rate != 44100)) { @@ -103,14 +109,19 @@ UINT soundmng_create(UINT rate, UINT ms) pcmwf.wf.nBlockAlign = 2 * sizeof(SINT16); pcmwf.wf.nAvgBytesPerSec = rate * 2 * sizeof(SINT16); - ZeroMemory(&dsbdesc, sizeof(DSBUFFERDESC)); - dsbdesc.dwSize = DSBUFFERDESC_SIZE; - dsbdesc.dwFlags = DSBCAPS_CTRLPAN | DSBCAPS_CTRLVOLUME | + for (i=0; i<2; i++) { + ZeroMemory(&dsbdesc, sizeof(DSBUFFERDESC)); + dsbdesc.dwSize = i ? sizeof(dsbdesc) : DSBUFFERDESC_SIZE; + dsbdesc.dwFlags = DSBCAPS_CTRLPAN | DSBCAPS_CTRLVOLUME | DSBCAPS_CTRLFREQUENCY | DSBCAPS_STICKYFOCUS | DSBCAPS_GETCURRENTPOSITION2; - dsbdesc.lpwfxFormat = (LPWAVEFORMATEX)&pcmwf; - dsbdesc.dwBufferBytes = dsstreambytes * 2; - if (FAILED(pDSound->CreateSoundBuffer(&dsbdesc, &pDSData3, NULL))) { + dsbdesc.lpwfxFormat = (LPWAVEFORMATEX)&pcmwf; + dsbdesc.dwBufferBytes = dsstreambytes * 2; + if (SUCCEEDED(pDSound->CreateSoundBuffer(&dsbdesc, &pDSData3, NULL))) { + break; + } + } + if (i >= 2) { goto stcre_err2; } @@ -118,8 +129,10 @@ UINT soundmng_create(UINT rate, UINT ms) vermouth_module = midimod_create(rate); midimod_loadall(vermouth_module); #endif +#if defined(MT32SOUND_DLL) + mt32sound_setrate(rate); +#endif dsstreamevent = (UINT8)-1; - soundmng_reset(); return(samples); stcre_err2: @@ -157,6 +170,9 @@ void soundmng_destroy(void) { midimod_destroy(vermouth_module); vermouth_module = NULL; #endif +#if defined(MT32SOUND_DLL) + mt32sound_setrate(0); +#endif pDSData3->Stop(); pDSData3->Release(); pDSData3 = NULL; @@ -247,12 +263,16 @@ void soundmng_sync(void) { void soundmng_setreverse(BOOL reverse) { if (!reverse) { +#if !defined(_WIN64) if (mmxflag) { fnmix = satuation_s16; } else { fnmix = satuation_s16mmx; } +#else + fnmix = satuation_s16; +#endif } else { fnmix = satuation_s16x; @@ -408,7 +428,7 @@ void soundmng_pcmvolume(UINT num, int vo } } -BOOL soundmng_pcmplay(UINT num, BOOL loop) { +BRESULT soundmng_pcmplay(UINT num, BOOL loop) { LPDIRECTSOUNDBUFFER dsbuf; @@ -438,12 +458,15 @@ void soundmng_pcmstop(UINT num) { // ---- -BOOL soundmng_initialize(void) { +BRESULT soundmng_initialize(void) { if (dsoundcreate() != SUCCESS) { goto smcre_err; } pcmcreate(); +#if defined(MT32SOUND_DLL) + mt32sound_initialize(); +#endif return(SUCCESS); smcre_err: @@ -453,6 +476,9 @@ smcre_err: void soundmng_deinitialize(void) { +#if defined(MT32SOUND_DLL) + mt32sound_deinitialize(); +#endif pcmdestroy(); soundmng_destroy(); RELEASE(pDSound);