--- np2/win9x/soundmng.cpp 2006/12/30 23:26:35 1.12.2.2 +++ np2/win9x/soundmng.cpp 2011/03/07 09:54:11 1.17 @@ -1,19 +1,31 @@ -#include "compiler.h" -#include -#include "parts.h" -#include "wavefile.h" -#include "np2.h" -#include "soundmng.h" -#include "extromio.h" -#include "sound.h" -#include "juliet.h" +/** + * @file soundmng.cpp + * @brief Sound Manager (DirectSound3) + * + * @author $Author: yui $ + * @date $Date: 2011/03/07 09:54:11 $ + */ + +#include "compiler.h" +#include +#include "parts.h" +#include "wavefile.h" +#include "np2.h" +#include "soundmng.h" +#include "extromio.h" +#include "sound.h" +#include "juliet.h" #if defined(VERMOUTH_LIB) -#include "vermouth.h" +#include "vermouth.h" #endif #if defined(MT32SOUND_DLL) -#include "mt32snd.h" +#include "mt32snd.h" #endif +#if !defined(__GNUC__) +#pragma comment(lib, "dsound.lib") +#endif // !defined(__GNUC__) + #if defined(_M_IA64) || defined(_M_AMD64) #define SOUNDBUFFERALIGN (1 << 3) #else @@ -61,14 +73,16 @@ static void (PARTSCALL *fnmix)(SINT16 // ---- directsound -static BRESULT dsoundcreate(void) { - +static BRESULT dsoundcreate(HWND hWnd) +{ // DirectSound¤Î½é´ü²½ if (FAILED(DirectSoundCreate(0, &pDSound, 0))) { goto dscre_err; } - if (FAILED(pDSound->SetCooperativeLevel(hWndMain, DSSCL_PRIORITY))) { - if (FAILED(pDSound->SetCooperativeLevel(hWndMain, DSSCL_NORMAL))) { + if (FAILED(pDSound->SetCooperativeLevel(hWnd, DSSCL_PRIORITY))) + { + if (FAILED(pDSound->SetCooperativeLevel(hWnd, DSSCL_NORMAL))) + { goto dscre_err; } } @@ -92,6 +106,7 @@ UINT soundmng_create(UINT rate, UINT ms) (rate != 11025) && (rate != 22050) && (rate != 44100)) { goto stcre_err1; } + if (ms < 40) { ms = 40; } @@ -135,9 +150,11 @@ 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; return(samples); @@ -466,7 +483,7 @@ void soundmng_pcmstop(UINT num) { BRESULT soundmng_initialize(void) { - if (dsoundcreate() != SUCCESS) { + if (dsoundcreate(g_hWndMain) != SUCCESS) { goto smcre_err; } pcmcreate();