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.

379 lines
13 KiB

  1. /* (C) Copyright Microsoft Corporation 1991. All Rights Reserved */
  2. /* SoundRec.h
  3. */
  4. /* Revision History.
  5. LaurieGr 7/Jan/91 Ported to WIN32 / WIN16 common code
  6. LaurieGr 16/Feb/94 Merged Daytona and Motown versions
  7. */
  8. /* Set NT type debug flags */
  9. #if DBG
  10. # ifndef DEBUG
  11. # define DEBUG
  12. # endif
  13. #endif
  14. /* Enable Win95 UI code for Windows NT with the new shell */
  15. #if WINVER >= 0x0400
  16. #define CHICAGO
  17. #endif
  18. #include <stdlib.h>
  19. #ifndef RC_INVOKED
  20. #ifndef OLE1_REGRESS
  21. #ifdef INCLUDE_OLESTUBS
  22. #include "oleglue.h"
  23. #endif
  24. #else
  25. #pragma message("OLE1 alert")
  26. #include "server.h"
  27. #endif
  28. #endif
  29. #define SIZEOF(x) (sizeof(x)/sizeof(TCHAR))
  30. #if DBG
  31. extern void FAR PASCAL AssertSFL(
  32. LPSTR lpszClause,
  33. LPSTR lpszFileName,
  34. int nLine);
  35. #define Assert(f) ((f)? (void)0 : AssertSFL(#f, __FILE__, __LINE__))
  36. #else // !DBG
  37. #define Assert(x)
  38. #endif // DBG
  39. typedef BYTE * HPBYTE; /* note a BYTE is NOT the same as a CHAR */
  40. typedef BYTE * NPBYTE; /* A CHAR can be TWO BYTES (UNICODE!!) */
  41. #define FMT_DEFAULT 0x0000
  42. #define FMT_STEREO 0x0010
  43. #define FMT_MONO 0x0000
  44. #define FMT_16BIT 0x0008
  45. #define FMT_8BIT 0x0000
  46. #define FMT_RATE 0x0007 /* 1, 2, 4 */
  47. #define FMT_11k 0x0001
  48. #define FMT_22k 0x0002
  49. #define FMT_44k 0x0004
  50. //
  51. // convertsion routines in wave.c
  52. //
  53. LONG PASCAL wfSamplesToBytes(WAVEFORMATEX* pwf, LONG lSamples);
  54. LONG PASCAL wfBytesToSamples(WAVEFORMATEX* pwf, LONG lBytes);
  55. LONG PASCAL wfSamplesToTime (WAVEFORMATEX* pwf, LONG lSamples);
  56. LONG PASCAL wfTimeToSamples (WAVEFORMATEX* pwf, LONG lTime);
  57. #define wfTimeToBytes(pwf, lTime) wfSamplesToBytes(pwf, wfTimeToSamples(pwf, lTime))
  58. #define wfBytesToTime(pwf, lBytes) wfSamplesToTime(pwf, wfBytesToSamples(pwf, lBytes))
  59. #define wfSamplesToSamples(pwf, lSamples) wfBytesToSamples(pwf, wfSamplesToBytes(pwf, lSamples))
  60. #define wfBytesToBytes(pwf, lBytes) wfSamplesToBytes(pwf, wfBytesToSamples(pwf, lBytes))
  61. //
  62. // function to determine if a WAVEFORMATEX is a valid PCM format we support for
  63. // editing and such.
  64. //
  65. BOOL PASCAL IsWaveFormatPCM(WAVEFORMATEX* pwf);
  66. void PASCAL WaveFormatToString(LPWAVEFORMATEX lpwf, LPTSTR sz);
  67. BOOL PASCAL CreateWaveFormat(LPWAVEFORMATEX lpwf, WORD fmt, UINT uiDeviceID);
  68. BOOL PASCAL CreateDefaultWaveFormat(LPWAVEFORMATEX lpwf, UINT uDeviceID);
  69. //
  70. // used to set focus to a dialog control
  71. //
  72. #define SetDlgFocus(hwnd) SendMessage(ghwndApp, WM_NEXTDLGCTL, (WPARAM)(hwnd), 1L)
  73. #define FAKEITEMNAMEFORLINK
  74. #define SZCODE const TCHAR
  75. /* constants */
  76. #define TIMER_MSEC 50 // msec. for display update
  77. #define SCROLL_RANGE 10000 // scrollbar range
  78. #define SCROLL_LINE_MSEC 100 // scrollbar arrow left/right
  79. #define SCROLL_PAGE_MSEC 1000 // scrollbar page left/right
  80. #define WM_USER_DESTROY (WM_USER+10)
  81. #define WM_USER_KILLSERVER (WM_USER+11)
  82. #define WM_USER_WAITPLAYEND (WM_USER+12)
  83. #define WM_BADREG (WM_USER+125)
  84. #define MAX_WAVEHDRS 10
  85. #define MAX_DELTASECONDS 350
  86. #define MAX_MSECSPERBUFFER 10000
  87. #define MIN_WAVEHDRS 2
  88. #define MIN_DELTASECONDS 5
  89. #define MIN_MSECSPERBUFFER 62
  90. #define DEF_BUFFERDELTASECONDS 60
  91. #define DEF_NUMASYNCWAVEHEADERS 10
  92. #define DEF_MSECSPERASYNCBUFFER 250
  93. /* colors */
  94. #define RGB_PANEL GetSysColor(COLOR_BTNFACE) // main window background
  95. #define RGB_STOP GetSysColor(COLOR_BTNTEXT) // color of "Stop" status text
  96. #define RGB_PLAY GetSysColor(COLOR_BTNTEXT) // color of "Play" status text
  97. #define RGB_RECORD GetSysColor(COLOR_BTNTEXT) // color of "Record" status text
  98. #define RGB_FGNFTEXT GetSysColor(COLOR_BTNTEXT) // NoFlickerText foreground
  99. #define RGB_BGNFTEXT GetSysColor(COLOR_BTNFACE) // NoFlickerText background
  100. #define RGB_FGWAVEDISP RGB( 0, 255, 0) // WaveDisplay foreground
  101. #define RGB_BGWAVEDISP RGB( 0, 0, 0) // WaveDisplay background
  102. #define RGB_DARKSHADOW GetSysColor(COLOR_BTNSHADOW) // dark 3-D shadow
  103. #define RGB_LIGHTSHADOW GetSysColor(COLOR_BTNHIGHLIGHT) // light 3-D shadow
  104. /* a window proc */
  105. typedef LONG (FAR PASCAL * LPWNDPROC) (void);
  106. /* globals from "SoundRec.c" */
  107. extern TCHAR chDecimal;
  108. extern TCHAR gachAppName[]; // 8-character name
  109. extern TCHAR gachAppTitle[]; // full name
  110. extern TCHAR gachHelpFile[]; // name of help file
  111. extern TCHAR gachHtmlHelpFile[]; // name of help file
  112. extern TCHAR gachDefFileExt[]; // 3-character file extension
  113. extern HWND ghwndApp; // main application window
  114. extern HMENU ghmenuApp; // main application menu
  115. extern HANDLE ghAccel; // accelerators
  116. extern HINSTANCE ghInst; // program instance handle
  117. extern TCHAR gachFileName[_MAX_PATH]; // cur. file name (or UNTITLED)
  118. extern BOOL gfLZero; // leading zeros?
  119. extern BOOL gfIsRTL; // no compile BIDI support
  120. extern BOOL gfDirty; // file was modified and not saved?
  121. // -1 seems to mean "cannot save"
  122. // Damned funny value for a BOOL!!!!
  123. extern BOOL gfClipboard; // current doc is in clipboard
  124. extern HWND ghwndWaveDisplay; // waveform display window handle
  125. extern HWND ghwndScroll; // scroll bar control window handle
  126. extern HWND ghwndPlay; // Play button window handle
  127. extern HWND ghwndStop; // Stop button window handle
  128. extern HWND ghwndRecord; // Record button window handle
  129. extern HWND ghwndForward; // [>>] button
  130. extern HWND ghwndRewind; // [<<] button
  131. extern UINT guiACMHlpMsg; // ACM Help's message value
  132. /* hack fix for the multiple sound card problem */
  133. #define NEWPAUSE
  134. #ifdef NEWPAUSE
  135. extern BOOL gfPaused;
  136. extern BOOL gfPausing;
  137. extern HWAVE ghPausedWave;
  138. extern BOOL gfWasPlaying;
  139. extern BOOL gfWasRecording;
  140. #endif
  141. #ifdef THRESHOLD
  142. extern HWND ghwndSkipStart; // [>N] button
  143. extern HWND ghwndSkipEnd; // [>-] button
  144. #endif // THRESHOLD
  145. extern int gidDefaultButton;// which button should have focus
  146. extern HICON ghiconApp; // Application's icon
  147. extern TCHAR aszUntitled[]; // Untitled string resource
  148. extern TCHAR aszFilter[]; // File name filter
  149. #ifdef FAKEITEMNAMEFORLINK
  150. extern TCHAR aszFakeItemName[]; // Wave
  151. #endif
  152. extern TCHAR aszPositionFormat[];
  153. extern TCHAR aszNoZeroPositionFormat[];
  154. /* globals from "wave.c" */
  155. extern DWORD gcbWaveFormat; // size of WAVEFORMAT
  156. extern WAVEFORMATEX * gpWaveFormat; // format of WAVE file
  157. extern LPTSTR gpszInfo;
  158. extern HPBYTE gpWaveSamples; // pointer to waveoform samples
  159. extern LONG glWaveSamples; // number of samples total in buffer
  160. extern LONG glWaveSamplesValid; // number of samples that are valid
  161. extern LONG glWavePosition; // current wave position in samples
  162. // from start of buffer
  163. extern LONG glStartPlayRecPos; // pos. when play or record started
  164. extern HWAVEOUT ghWaveOut; // wave-out device (if playing)
  165. extern HWAVEIN ghWaveIn; // wave-out device (if recording)
  166. extern DWORD grgbStatusColor; // color of status text
  167. extern HBRUSH ghbrPanel; // color of main window
  168. extern BOOL gfEmbeddedObject; // TRUE if editing embedded OLE object
  169. extern BOOL gfRunWithEmbeddingFlag; // TRUE if we are run with "-Embedding"
  170. extern int gfErrorBox; // TRUE iff we do not want to display an
  171. // error box (e.g. because one is active)
  172. //OLE2 stuff:
  173. extern BOOL gfStandalone; // CG
  174. extern BOOL gfEmbedded; // CG
  175. extern BOOL gfLinked; // CG
  176. extern BOOL gfCloseAtEndOfPlay; // jyg need I say more?
  177. /* SRECNEW.C */
  178. extern BOOL gfInFileNew; // are we doing a File.New op?
  179. void FAR PASCAL LoadACM(void);
  180. void FreeACM(void);
  181. #include "srecids.h"
  182. typedef enum {
  183. enumCancel,
  184. enumSaved,
  185. enumRevert
  186. } PROMPTRESULT;
  187. /* prototypes from "SoundRec.c" */
  188. INT_PTR CALLBACK SoundRecDlgProc(HWND hDlg, UINT wMsg,
  189. WPARAM wParam, LPARAM lParam);
  190. BOOL ResolveIfLink(PTCHAR szFileName);
  191. /* prototypes from "file.c" */
  192. void FAR PASCAL BeginWaveEdit(void);
  193. void FAR PASCAL EndWaveEdit(BOOL fDirty);
  194. PROMPTRESULT FAR PASCAL PromptToSave(BOOL fMustClose, BOOL fSetForground);
  195. void FAR PASCAL UpdateCaption(void);
  196. BOOL FAR PASCAL FileNew(WORD fmt, BOOL fUpdateDisplay, BOOL fNewDlg);
  197. BOOL FAR PASCAL FileOpen(LPCTSTR szFileName);
  198. BOOL FAR PASCAL FileSave(BOOL fSaveAs);
  199. BOOL FAR PASCAL FileRevert(void);
  200. LPCTSTR FAR PASCAL FileName(LPCTSTR szPath);
  201. MMRESULT ReadWaveFile(HMMIO hmmio, LPWAVEFORMATEX* ppWaveFormat,
  202. DWORD *pcbWaveFormat, LPBYTE * ppWaveSamples, DWORD *plWaveSamples,
  203. LPTSTR szFileName, BOOL fCacheRIFF);
  204. BOOL FAR PASCAL WriteWaveFile(HMMIO hmmio, WAVEFORMATEX* pWaveFormat,
  205. UINT cbWaveFormat, HPBYTE pWaveSamples, LONG lWaveSamples);
  206. /* prototypes from "errorbox.c" */
  207. short FAR cdecl ErrorResBox(HWND hwnd, HANDLE hInst, UINT flags,
  208. UINT idAppName, UINT idErrorStr, ...);
  209. /* prototypes from "edit.c" */
  210. void FAR PASCAL InsertFile(BOOL fPaste);
  211. void FAR PASCAL MixWithFile(BOOL fPaste);
  212. void FAR PASCAL DeleteBefore(void);
  213. void FAR PASCAL DeleteAfter(void);
  214. void FAR PASCAL ChangeVolume(BOOL fIncrease);
  215. void FAR PASCAL MakeFaster(void);
  216. void FAR PASCAL MakeSlower(void);
  217. void FAR PASCAL IncreasePitch(void);
  218. void FAR PASCAL DecreasePitch(void);
  219. void FAR PASCAL AddEcho(void);
  220. #if defined(REVERB)
  221. void FAR PASCAL AddReverb(void);
  222. #endif //REVERB
  223. void FAR PASCAL Reverse(void);
  224. /* prototypes from "wave.c" */
  225. BOOL FAR PASCAL AllocWaveBuffer(long lBytes, BOOL fErrorBox, BOOL fExact);
  226. BOOL FAR PASCAL NewWave(WORD fmt,BOOL fNewDlg);
  227. BOOL FAR PASCAL DestroyWave(void);
  228. BOOL FAR PASCAL PlayWave(void);
  229. BOOL FAR PASCAL RecordWave(void);
  230. void FAR PASCAL WaveOutDone(HWAVEOUT hWaveOut, LPWAVEHDR pWaveHdr);
  231. void FAR PASCAL WaveInData(HWAVEIN hWaveIn, LPWAVEHDR pWaveHdr);
  232. void FAR PASCAL StopWave(void);
  233. void FAR PASCAL SnapBack(void);
  234. void FAR PASCAL UpdateDisplay(BOOL fStatusChanged);
  235. void FAR PASCAL FinishPlay(void);
  236. void FAR PASCAL SkipToStart(void);
  237. void FAR PASCAL SkipToEnd(void);
  238. void FAR PASCAL IncreaseThresh(void);
  239. void FAR PASCAL DecreaseThresh(void);
  240. /* prototypes from "init.c" */
  241. BOOL PASCAL AppInit( HINSTANCE hInst, HINSTANCE hPrev);
  242. BOOL PASCAL SoundDialogInit(HWND hwnd, int iCmdShow);
  243. BOOL PASCAL GetIntlSpecs(void);
  244. /* prototype from "wavedisp.c" */
  245. INT_PTR CALLBACK WaveDisplayWndProc(HWND hwnd, UINT wMsg,
  246. WPARAM wParam, LPARAM lParam);
  247. /* prototype from "nftext.c" */
  248. INT_PTR CALLBACK NFTextWndProc(HWND hwnd, UINT wMsg,
  249. WPARAM wParam, LPARAM lParam);
  250. /* prototype from "sframe.c" */
  251. void FAR PASCAL DrawShadowFrame(HDC hdc, LPRECT prc);
  252. INT_PTR CALLBACK SFrameWndProc(HWND hwnd, UINT wMsg,
  253. WPARAM wParam, LPARAM lParam);
  254. /* prototype from "server.c" */
  255. BOOL FAR PASCAL IsClipboardNative(void);
  256. /* prototypes from "srecnew.c" */
  257. BOOL FAR PASCAL NewSndDialog(HINSTANCE hInst, HWND hwndParent,
  258. PWAVEFORMATEX pwfxPrev, UINT cbPrev,
  259. PWAVEFORMATEX *ppWaveFormat, PUINT pcbWaveFormat);
  260. /* start parameters (set in oleglue.c) */
  261. typedef struct tStartParams {
  262. BOOL fOpen;
  263. BOOL fPlay;
  264. BOOL fNew;
  265. BOOL fClose;
  266. TCHAR achOpenFilename[_MAX_PATH];
  267. } StartParams;
  268. extern StartParams gStartParams;
  269. #ifdef DEBUG
  270. int __iDebugLevel;
  271. extern void FAR cdecl dprintfA(LPSTR, ...);
  272. extern void FAR cdecl dprintfW(LPWSTR, ...);
  273. #ifdef UNICODE
  274. #define dprintf dprintfW
  275. #else
  276. #define dprintf dprintfA
  277. #endif
  278. #if 0
  279. #define DPF if (__iDebugLevel > 0) dprintf
  280. #define DPF1 if (__iDebugLevel >= 1) dprintf
  281. #define DPF2 if (__iDebugLevel >= 2) dprintf
  282. #define DPF3 if (__iDebugLevel >= 3) dprintf
  283. #define DPF4 if (__iDebugLevel >= 4) dprintf
  284. #define CPF
  285. #endif
  286. #ifdef PPC
  287. //
  288. // The below line crashes the PPC compiler for NT 3.51
  289. //
  290. #define DPF(a)
  291. #else
  292. #define DPF if (0) ((int (*)(TCHAR *, ...)) 0)
  293. #endif
  294. #define DPF1 if (0) ((int (*)(TCHAR *, ...)) 0)
  295. #define DPF2 if (0) ((int (*)(TCHAR *, ...)) 0)
  296. #define DPF3 if (0) ((int (*)(TCHAR *, ...)) 0)
  297. #define DPF4 if (0) ((int (*)(TCHAR *, ...)) 0)
  298. #define CPF if (0) ((int (*)(TCHAR *, ...)) 0)
  299. #else
  300. #ifdef PPC
  301. //
  302. // The below line crashes the PPC compiler for NT 3.51
  303. //
  304. #define DPF(a)
  305. #else
  306. #define DPF if (0) ((int (*)(TCHAR *, ...)) 0)
  307. #endif
  308. #define DPF1 if (0) ((int (*)(TCHAR *, ...)) 0)
  309. #define DPF2 if (0) ((int (*)(TCHAR *, ...)) 0)
  310. #define DPF3 if (0) ((int (*)(TCHAR *, ...)) 0)
  311. #define DPF4 if (0) ((int (*)(TCHAR *, ...)) 0)
  312. #define CPF if (0) ((int (*)(TCHAR *, ...)) 0)
  313. #endif //DEBUG