ReactOS 0.4.15-dev-8339-g4028de8
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 196 of file speaker.c.

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

Referenced by PitChan2Out(), and Port61hWrite().

◆ SpeakerCleanup()

VOID SpeakerCleanup ( VOID  )

Definition at line 295 of file speaker.c.

296{
297 NtClose(hBeep);
298}
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3402
static HANDLE hBeep
Definition: speaker.c:28

Referenced by EmulatorCleanup().

◆ SpeakerInitialize()

VOID SpeakerInitialize ( VOID  )

Definition at line 260 of file speaker.c.

261{
263 UNICODE_STRING BeepDevice;
266
267 /* Retrieve the performance frequency and initialize the timer ticks */
269 if (FreqCount.QuadPart == 0)
270 {
271 wprintf(L"FATAL: Performance counter not available\n");
272 }
273
274 /* Open the BEEP device */
275 RtlInitUnicodeString(&BeepDevice, L"\\Device\\Beep");
281 NULL,
282 0,
285 0,
286 NULL,
287 0);
288 if (!NT_SUCCESS(Status))
289 {
290 DPRINT1("Failed to open the Beep driver, Status 0x%08lx\n", Status);
291 // hBeep = INVALID_HANDLE_VALUE;
292 }
293}
LONG NTSTATUS
Definition: precomp.h:26
#define DPRINT1
Definition: precomp.h:8
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:36
#define NULL
Definition: types.h:112
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define FILE_SHARE_READ
Definition: compat.h:136
#define FILE_OPEN_IF
Definition: from_kernel.h:56
Status
Definition: gdiplustypes.h:25
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define FILE_WRITE_DATA
Definition: nt_native.h:631
#define FILE_READ_DATA
Definition: nt_native.h:628
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
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)
NTSTATUS NTAPI NtQueryPerformanceCounter(OUT PLARGE_INTEGER PerformanceCounter, OUT PLARGE_INTEGER PerformanceFrequency OPTIONAL)
Definition: profile.c:272
#define L(x)
Definition: ntvdm.h:50
static LARGE_INTEGER FreqCount
Definition: speaker.c:30
#define wprintf(...)
Definition: whoami.c:18

Referenced by EmulatorInitialize().