Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

211 lines
7.4 KiB

  1. // Copyright (c) 1996-1999 Microsoft Corporation
  2. // UMSynth.h : Declaration of CUserModeSynth
  3. #ifndef __UMSYNTH_H_
  4. #define __UMSYNTH_H_
  5. #include <ks.h>
  6. #include <ksproxy.h>
  7. #include <mmsystem.h>
  8. #include "dsound.h"
  9. #include "dmusicc.h"
  10. #include "dmusics.h"
  11. #include "CSynth.h"
  12. #include "synth.h"
  13. #include "dsoundp.h" // For IDirectSoundSource
  14. class CUserModeSynth;
  15. // @@BEGIN_DDKSPLIT -- This section will be removed in the DDK sample. See ddkreadme.txt for more info.
  16. #if 0 // The following section will only take affect in the DDK sample.
  17. // @@END_DDKSPLIT
  18. // {F5038F82-C052-11D2-872F-00600893B1BD}
  19. DEFINE_GUID(CLSID_DDKSynth,
  20. 0xf5038f82, 0xc052, 0x11d2, 0x87, 0x2f, 0x0, 0x60, 0x8, 0x93, 0xb1, 0xbd);
  21. // @@BEGIN_DDKSPLIT -- This section will be removed in the DDK sample.
  22. #endif
  23. // @@END_DDKSPLIT
  24. typedef HRESULT (CUserModeSynth::*GENPROPHANDLER)(ULONG ulId, BOOL fSet, LPVOID pbBuffer, PULONG cbBuffer);
  25. #define GENPROP_F_STATIC 0x00000000
  26. #define GENPROP_F_FNHANDLER 0x00000001
  27. #include <pshpack4.h>
  28. struct GENERICPROPERTY
  29. {
  30. const GUID *pguidPropertySet; // What property set?
  31. ULONG ulId; // What item?
  32. ULONG ulSupported; // Get/Set flags for QuerySupported
  33. ULONG ulFlags; // GENPROP_F_xxx
  34. LPVOID pPropertyData; // Data to be returned
  35. ULONG cbPropertyData; // and its size
  36. GENPROPHANDLER pfnHandler; // Handler fn iff GENPROP_F_FNHANDLER
  37. };
  38. #include <poppack.h>
  39. /////////////////////////////////////////////////////////////////////////////
  40. // CDMSynth
  41. class CUserModeSynth : public IDirectMusicSynth8, public IDirectSoundSource, public IKsControl
  42. {
  43. // @@BEGIN_DDKSPLIT -- This section will be removed in the DDK sample. See ddkreadme.txt for more info.
  44. friend class CDSLink;
  45. friend class CClock;
  46. // @@END_DDKSPLIT
  47. public:
  48. // IUnknown
  49. //
  50. virtual STDMETHODIMP QueryInterface(const IID &iid, void **ppv);
  51. virtual STDMETHODIMP_(ULONG) AddRef();
  52. virtual STDMETHODIMP_(ULONG) Release();
  53. // IDirectMusicSynth
  54. public:
  55. virtual STDMETHODIMP Open(LPDMUS_PORTPARAMS pPortParams);
  56. virtual STDMETHODIMP Close();
  57. virtual STDMETHODIMP SetNumChannelGroups(DWORD dwGroups);
  58. virtual STDMETHODIMP Download(LPHANDLE phDownload, LPVOID pvData, LPBOOL pbFree);
  59. virtual STDMETHODIMP Unload(HANDLE hDownload,
  60. HRESULT ( CALLBACK *lpFreeHandle)(HANDLE,HANDLE),
  61. HANDLE hUserData);
  62. virtual STDMETHODIMP PlayBuffer(REFERENCE_TIME rt, LPBYTE pbBuffer, DWORD cbBuffer);
  63. virtual STDMETHODIMP GetRunningStats(LPDMUS_SYNTHSTATS pStats);
  64. virtual STDMETHODIMP GetPortCaps(LPDMUS_PORTCAPS pCaps);
  65. virtual STDMETHODIMP SetMasterClock(IReferenceClock *pClock);
  66. virtual STDMETHODIMP GetLatencyClock(IReferenceClock **ppClock);
  67. virtual STDMETHODIMP Activate(BOOL fEnable);
  68. virtual STDMETHODIMP SetSynthSink(IDirectMusicSynthSink *pSynthSink);
  69. virtual STDMETHODIMP Render(short *pBuffer, DWORD dwLength, LONGLONG llPosition);
  70. virtual STDMETHODIMP SetChannelPriority(DWORD dwChannelGroup, DWORD dwChannel, DWORD dwPriority);
  71. virtual STDMETHODIMP GetChannelPriority(DWORD dwChannelGroup, DWORD dwChannel, LPDWORD pdwPriority);
  72. virtual STDMETHODIMP GetFormat(LPWAVEFORMATEX pWaveFormatEx, LPDWORD pdwWaveFormatExSize);
  73. virtual STDMETHODIMP GetAppend(DWORD* pdwAppend);
  74. // IDirectMusicSynth8
  75. public:
  76. virtual STDMETHODIMP PlayVoice(REFERENCE_TIME rt, DWORD dwVoiceId, DWORD dwChannelGroup, DWORD dwChannel, DWORD dwDLId, PREL prPitch, VREL vrVolume, SAMPLE_TIME stVoiceStart, SAMPLE_TIME stLoopStart, SAMPLE_TIME stLoopEnd );
  77. virtual STDMETHODIMP StopVoice(REFERENCE_TIME rt, DWORD dwVoiceId );
  78. virtual STDMETHODIMP GetVoiceState(DWORD dwVoice[], DWORD cbVoice, DMUS_VOICE_STATE VoiceState[] );
  79. virtual STDMETHODIMP Refresh(DWORD dwDownloadID, DWORD dwFlags );
  80. virtual STDMETHODIMP AssignChannelToBuses(DWORD dwChannelGroup, DWORD dwChannel, LPDWORD pdwBuses, DWORD cBuses );
  81. // IDirectSoundSource
  82. public:
  83. virtual STDMETHODIMP GetFormat(LPWAVEFORMATEX pWaveFormatEx, DWORD dwSizeAllocated, LPDWORD pdwSizeWritten);
  84. virtual STDMETHODIMP SetSink(IDirectSoundConnect* pSinkConnect);
  85. virtual STDMETHODIMP Seek(ULONGLONG sp);
  86. virtual STDMETHODIMP Read(LPVOID *ppvBuffer, LPDWORD pdwIDs, LPDWORD pdwFuncIDs, LPLONG plPitchBends, DWORD cpvBuffer, PULONGLONG pcb);
  87. virtual STDMETHODIMP GetSize(PULONGLONG pcb);
  88. // IDirectSoundSource : members
  89. private:
  90. ULONGLONG m_ullPosition;
  91. // IKsControl
  92. public:
  93. virtual STDMETHODIMP KsProperty(
  94. PKSPROPERTY pPropertyIn,
  95. ULONG ulPropertyLength,
  96. LPVOID pvPropertyData,
  97. ULONG ulDataLength,
  98. PULONG pulBytesReturned);
  99. virtual STDMETHODIMP KsMethod(
  100. IN PKSMETHOD Method,
  101. IN ULONG MethodLength,
  102. IN OUT LPVOID MethodData,
  103. IN ULONG DataLength,
  104. OUT PULONG BytesReturned
  105. );
  106. virtual STDMETHODIMP KsEvent(
  107. IN PKSEVENT Event,
  108. IN ULONG EventLength,
  109. IN OUT LPVOID EventData,
  110. IN ULONG DataLength,
  111. OUT PULONG BytesReturned
  112. );
  113. CUserModeSynth();
  114. ~CUserModeSynth();
  115. HRESULT Init();
  116. private:
  117. // @@BEGIN_DDKSPLIT -- This section will be removed in the DDK sample. See ddkreadme.txt for more info.
  118. HRESULT UseDefaultSynthSink();
  119. // @@END_DDKSPLIT
  120. long m_cRef;
  121. IDirectMusicSynthSink *m_pSynthSink;
  122. IDirectSoundSynthSink *m_pSynthSink8;
  123. CSynth * m_pSynth; // Just one synth engine.
  124. BOOL m_fActive; // Currently active.
  125. DWORD m_dwSampleRate; // Synths sample rate
  126. DWORD m_dwChannels; // number of ouput channels
  127. DWORD m_dwBufferFlags;// flags the type of output buffer dssink or interleaved or plain mono
  128. LONG m_lVolume; // in 1/100 dB
  129. LONG m_lBoost; // in 1/100 dB
  130. LONG m_lGainAdjust; // in 1/100 dB
  131. CRITICAL_SECTION m_CriticalSection; // Critical section to manage access.
  132. BOOL m_fCSInitialized;
  133. HRESULT HandleSetVolume(
  134. ULONG ulId,
  135. BOOL fSet,
  136. LPVOID pbBuffer,
  137. PULONG pcbBuffer);
  138. HRESULT HandleSetBoost(
  139. ULONG ulId,
  140. BOOL fSet,
  141. LPVOID pbBuffer,
  142. PULONG pcbBuffer);
  143. HRESULT HandleReverb(ULONG ulId, BOOL fSet, LPVOID pbBuffer, PULONG pcbBuffer);
  144. HRESULT HandleEffects(ULONG ulId, BOOL fSet, LPVOID pbBuffer, PULONG pcbBuffer);
  145. HRESULT HandleGetSampleRate(ULONG ulId, BOOL fSet, LPVOID pbBuffer, PULONG pcbBuffer);
  146. static GENERICPROPERTY m_aProperty[];
  147. static const int m_nProperty;
  148. //static GENERICPROPERTY *FindPropertyItem(REFGUID rguid, ULONG ulId);
  149. GENERICPROPERTY *FindPropertyItem(REFGUID rguid, ULONG ulId);
  150. };
  151. // Class factory
  152. //
  153. // Common to emulation/WDM.
  154. //
  155. class CDirectMusicSynthFactory : public IClassFactory
  156. {
  157. public:
  158. // IUnknown
  159. //
  160. virtual STDMETHODIMP QueryInterface(const IID &iid, void **ppv);
  161. virtual STDMETHODIMP_(ULONG) AddRef();
  162. virtual STDMETHODIMP_(ULONG) Release();
  163. // Interface IClassFactory
  164. //
  165. virtual STDMETHODIMP CreateInstance(IUnknown* pUnknownOuter, const IID& iid, void** ppv);
  166. virtual STDMETHODIMP LockServer(BOOL bLock);
  167. // Constructor
  168. //
  169. CDirectMusicSynthFactory();
  170. // Destructor
  171. ~CDirectMusicSynthFactory();
  172. private:
  173. long m_cRef;
  174. };
  175. #endif //__UMSYNTH_H_