Source code of Windows XP (NT5)
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.

188 lines
4.7 KiB

  1. /*++
  2. Copyright (c) 1997-2000 Microsoft Corporation All Rights Reserved
  3. Module Name:
  4. savedata.h
  5. Abstract:
  6. Declaration of MSVAD data saving class. This class supplies services
  7. to save data to disk.
  8. --*/
  9. #ifndef _MSVAD_SAVEDATA_H
  10. #define _MSVAD_SAVEDATA_H
  11. //-----------------------------------------------------------------------------
  12. // Forward declaration
  13. //-----------------------------------------------------------------------------
  14. class CSaveData;
  15. typedef CSaveData *PCSaveData;
  16. //-----------------------------------------------------------------------------
  17. // Structs
  18. //-----------------------------------------------------------------------------
  19. // Parameter to workitem.
  20. #include <pshpack1.h>
  21. typedef struct _SAVEWORKER_PARAM {
  22. #ifdef USE_OBSOLETE_FUNCS
  23. WORK_QUEUE_ITEM WorkItem;
  24. #else
  25. PIO_WORKITEM WorkItem;
  26. #endif
  27. ULONG ulFrameNo;
  28. ULONG ulDataSize;
  29. PBYTE pData;
  30. PCSaveData pSaveData;
  31. KEVENT EventDone;
  32. } SAVEWORKER_PARAM;
  33. typedef SAVEWORKER_PARAM *PSAVEWORKER_PARAM;
  34. #include <poppack.h>
  35. // wave file header.
  36. #include <pshpack1.h>
  37. typedef struct _OUTPUT_FILE_HEADER
  38. {
  39. DWORD dwRiff;
  40. DWORD dwFileSize;
  41. DWORD dwWave;
  42. DWORD dwFormat;
  43. DWORD dwFormatLength;
  44. } OUTPUT_FILE_HEADER;
  45. typedef OUTPUT_FILE_HEADER *POUTPUT_FILE_HEADER;
  46. typedef struct _OUTPUT_DATA_HEADER
  47. {
  48. DWORD dwData;
  49. DWORD dwDataLength;
  50. } OUTPUT_DATA_HEADER;
  51. typedef OUTPUT_DATA_HEADER *POUTPUT_DATA_HEADER;
  52. #include <poppack.h>
  53. //-----------------------------------------------------------------------------
  54. // Classes
  55. //-----------------------------------------------------------------------------
  56. ///////////////////////////////////////////////////////////////////////////////
  57. // CSaveData
  58. // Saves the wave data to disk.
  59. //
  60. class CSaveData
  61. {
  62. protected:
  63. UNICODE_STRING m_FileName; // DataFile name.
  64. HANDLE m_FileHandle; // DataFile handle.
  65. PBYTE m_pDataBuffer; // Data buffer.
  66. ULONG m_ulBufferSize; // Total buffer size.
  67. ULONG m_ulFramePtr; // Current Frame.
  68. ULONG m_ulFrameCount; // Frame count.
  69. ULONG m_ulFrameSize;
  70. ULONG m_ulBufferPtr; // Pointer in buffer.
  71. PBOOL m_fFrameUsed; // Frame usage table.
  72. KSPIN_LOCK m_FrameInUseSpinLock; // Spinlock for synch.
  73. OBJECT_ATTRIBUTES m_objectAttributes; // Used for opening file.
  74. OUTPUT_FILE_HEADER m_FileHeader;
  75. PWAVEFORMATEX m_waveFormat;
  76. OUTPUT_DATA_HEADER m_DataHeader;
  77. PLARGE_INTEGER m_pFilePtr;
  78. static PDEVICE_OBJECT m_pDeviceObject;
  79. static ULONG m_ulStreamId;
  80. static PSAVEWORKER_PARAM m_pWorkItems;
  81. BOOL m_fWriteDisabled;
  82. public:
  83. CSaveData();
  84. ~CSaveData();
  85. static void DestroyWorkItems
  86. (
  87. void
  88. );
  89. void Disable
  90. (
  91. BOOL fDisable
  92. );
  93. static PSAVEWORKER_PARAM GetNewWorkItem
  94. (
  95. void
  96. );
  97. NTSTATUS Initialize
  98. (
  99. void
  100. );
  101. static NTSTATUS InitializeWorkItems
  102. (
  103. IN PDEVICE_OBJECT DeviceObject
  104. );
  105. void ReadData
  106. (
  107. IN PBYTE pBuffer,
  108. IN ULONG ulByteCount
  109. );
  110. NTSTATUS SetDataFormat
  111. (
  112. IN PKSDATAFORMAT pDataFormat
  113. );
  114. void WaitAllWorkItems
  115. (
  116. void
  117. );
  118. void WriteData
  119. (
  120. IN PBYTE pBuffer,
  121. IN ULONG ulByteCount
  122. );
  123. private:
  124. NTSTATUS FileClose
  125. (
  126. void
  127. );
  128. NTSTATUS FileOpen
  129. (
  130. IN BOOL fOverWrite
  131. );
  132. NTSTATUS FileWrite
  133. (
  134. IN PBYTE pData,
  135. IN ULONG ulDataSize
  136. );
  137. NTSTATUS FileWriteHeader
  138. (
  139. void
  140. );
  141. void SaveFrame
  142. (
  143. IN ULONG ulFrameNo,
  144. IN ULONG ulDataSize
  145. );
  146. friend void SaveFrameWorkerCallback
  147. #ifdef USE_OBSOLETE_FUNCS
  148. (
  149. IN PVOID Context
  150. );
  151. #else
  152. (
  153. PDEVICE_OBJECT pDeviceObject,
  154. IN PVOID Context
  155. );
  156. #endif
  157. };
  158. typedef CSaveData *PCSaveData;
  159. #endif