ReactOS  0.4.14-dev-608-gd495a4f
speaker.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

VOID SpeakerChange (UCHAR Port61hValue)
 
VOID SpeakerInitialize (VOID)
 
VOID SpeakerCleanup (VOID)
 

Function Documentation

◆ SpeakerChange()

VOID SpeakerChange ( UCHAR  Port61hValue)

Definition at line 195 of file speaker.c.

196 {
197  static BOOLEAN OldSpeakerOff = TRUE;
198 
199  BOOLEAN Timer2Gate = !!(Port61hValue & 0x01);
200  BOOLEAN SpeakerOn = !!(Port61hValue & 0x02);
201 
202  DPRINT("SpeakerChange -- Timer2Gate == %s ; SpeakerOn == %s\n",
203  Timer2Gate ? "true" : "false", SpeakerOn ? "true" : "false");
204 
205  if (Timer2Gate)
206  {
207  if (SpeakerOn)
208  {
209  /* Start beeping */
212  Frequency = 0;
213 
215  }
216  else
217  {
218  /* Stop beeping */
219  MakeBeep(0, 0);
220  }
221  }
222  else
223  {
224  if (SpeakerOn)
225  {
226  if (OldSpeakerOff)
227  {
228  OldSpeakerOff = FALSE;
229  PulseSample();
230  }
231 
234  else if (CountStart.QuadPart != 0)
235  MakeBeep(CLICK_FREQ, 1); /* Click */
236  else
237  MakeBeep(0, 0); /* Stop beeping */
238  }
239  else
240  {
241  OldSpeakerOff = TRUE;
242 
243  /*
244  * Check how far away was the previous pulse and if
245  * it was >= (200 + eps) ms away then stop beeping.
246  */
248  {
249  CountStart.QuadPart = 0;
250  FreqPulses = 0;
251 
252  /* Stop beeping */
253  MakeBeep(0, 0);
254  }
255  }
256  }
257 }
#define TRUE
Definition: types.h:120
static VOID PulseSample(VOID)
Definition: speaker.c:92
DWORD WINAPI GetTickCount(VOID)
Definition: time.c:455
#define MIN_AUDIBLE_FREQ
Definition: speaker.c:34
unsigned char BOOLEAN
void DPRINT(...)
Definition: polytest.cpp:61
#define SPEAKER_RESPONSE
Definition: speaker.c:32
WORD PitGetReloadValue(BYTE Channel)
Definition: pit.c:493
static ULONG FreqPulses
Definition: speaker.c:30
#define PIT_BASE_FREQUENCY
Definition: pit.h:17
#define CLICK_FREQ
Definition: speaker.c:36
static LARGE_INTEGER CountStart
Definition: speaker.c:29
static VOID MakeBeep(ULONG Frequency, ULONG Duration)
Definition: speaker.c:43
static ULONG PulseTickCount
Definition: speaker.c:30
#define MAX_AUDIBLE_FREQ
Definition: speaker.c:35
static LARGE_INTEGER Frequency
Definition: clock.c:41
unsigned int ULONG
Definition: retypes.h:1
#define INFINITE
Definition: serial.h:102
LONGLONG QuadPart
Definition: typedefs.h:112

Referenced by PitChan2Out(), and Port61hWrite().

◆ SpeakerCleanup()

VOID SpeakerCleanup ( VOID  )

Definition at line 294 of file speaker.c.

295 {
296  NtClose(hBeep);
297 }
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3399
static HANDLE hBeep
Definition: speaker.c:27

Referenced by EmulatorCleanup().

◆ SpeakerInitialize()

VOID SpeakerInitialize ( VOID  )

Definition at line 259 of file speaker.c.

260 {
262  UNICODE_STRING BeepDevice;
265 
266  /* Retrieve the performance frequency and initialize the timer ticks */
268  if (FreqCount.QuadPart == 0)
269  {
270  wprintf(L"FATAL: Performance counter not available\n");
271  }
272 
273  /* Open the BEEP device */
274  RtlInitUnicodeString(&BeepDevice, L"\\Device\\Beep");
279  &IoStatusBlock,
280  NULL,
281  0,
283  FILE_OPEN_IF,
284  0,
285  NULL,
286  0);
287  if (!NT_SUCCESS(Status))
288  {
289  DPRINT1("Failed to open the Beep driver, Status 0x%08lx\n", Status);
290  // hBeep = INVALID_HANDLE_VALUE;
291  }
292 }
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
static LARGE_INTEGER FreqCount
Definition: speaker.c:29
#define FILE_OPEN_IF
Definition: from_kernel.h:56
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS NTAPI NtQueryPerformanceCounter(OUT PLARGE_INTEGER PerformanceCounter, OUT PLARGE_INTEGER PerformanceFrequency OPTIONAL)
Definition: profile.c:278
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define wprintf(...)
Definition: whoami.c:18
#define FILE_SHARE_READ
Definition: compat.h:125
#define FILE_READ_DATA
Definition: nt_native.h:628
smooth NULL
Definition: ftsmooth.c:416
#define FILE_WRITE_DATA
Definition: nt_native.h:631
NTSTATUS NTAPI NtCreateFile(OUT PHANDLE FileHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, OUT PIO_STATUS_BLOCK IoStatusBlock, IN PLARGE_INTEGER AllocationSize OPTIONAL, IN ULONG FileAttributes, IN ULONG ShareAccess, IN ULONG CreateDisposition, IN ULONG CreateOptions, IN PVOID EaBuffer OPTIONAL, IN ULONG EaLength)
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
static const WCHAR L[]
Definition: oid.c:1250
static LARGE_INTEGER CountStart
Definition: speaker.c:29
Status
Definition: gdiplustypes.h:24
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
#define DPRINT1
Definition: precomp.h:8
static HANDLE hBeep
Definition: speaker.c:27
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
LONGLONG QuadPart
Definition: typedefs.h:112

Referenced by EmulatorInitialize().