KLMusic.h
上传用户:dzyhzl
上传日期:2019-04-29
资源大小:56270k
文件大小:2k
源码类别:

模拟服务器

开发平台:

C/C++

  1. //---------------------------------------------------------------------------
  2. // Sword3 Engine (c) 1999-2000 by Kingsoft
  3. //
  4. // File: KLMusic.h
  5. // Date: 2000.08.08
  6. // Code: Daniel Wang
  7. // Desc: Header File
  8. //---------------------------------------------------------------------------
  9. #ifndef KLMusic_H
  10. #define KLMusic_H
  11. //---------------------------------------------------------------------------
  12. #define NUMEVENTS 3
  13. //---------------------------------------------------------------------------
  14. #include "KLThread.h"
  15. //---------------------------------------------------------------------------
  16. class KLMusic
  17. {
  18. protected:
  19. LPDIRECTSOUND8 m_pDS;
  20. WAVEFORMATEX m_WaveFormat;
  21. LPDIRECTSOUNDBUFFER  m_pSoundBuffer;
  22. LPDIRECTSOUNDNOTIFY  m_pSoundNotify;
  23. DSBPOSITIONNOTIFY m_PosNotify[NUMEVENTS];
  24. HANDLE m_hEvent[NUMEVENTS];
  25. DWORD m_dwBufferSize;
  26. BOOL m_bLoop;
  27. KLThread m_Thread;
  28. HWND m_hWnd;
  29. public:
  30. KLMusic();
  31. ~KLMusic();
  32. virtual BOOL Open(LPSTR FileName);
  33. virtual void Close();
  34. virtual void Play(BOOL bLoop = FALSE);
  35. virtual void Stop();
  36. virtual void Rewind();
  37. virtual void SetVolume(LONG lVolume);
  38. virtual BOOL HandleNotify();
  39. void SetWinHandle(HWND h){m_hWnd = h;}
  40. protected:
  41. virtual BOOL Init();
  42. bool InitDSound();
  43. virtual void InitSoundFormat();
  44. virtual BOOL InitSoundBuffer();
  45. virtual void FreeSoundBuffer();
  46. virtual BOOL InitSoundNotify();
  47. virtual void FreeSoundNotify();
  48. virtual BOOL InitEventHandle();
  49. virtual void FreeEventHandle();
  50. virtual BOOL FillBufferWithSound(DWORD dwPos);
  51. virtual BOOL FillBufferWithSilence();
  52. virtual DWORD ReadWaveData(LPBYTE lpBuf, DWORD dwLen);
  53. static void ThreadFunction(void* lpParam);
  54. };
  55. //---------------------------------------------------------------------------
  56. #endif