Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Synchronet
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Main
Synchronet
Commits
5fcafb56
Commit
5fcafb56
authored
18 years ago
by
deuce
Browse files
Options
Downloads
Patches
Plain Diff
Attempt to work around waveOutWrite() latency by playing a looping silence
while device is open and no data is playing.
parent
a0f76d8d
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/xpdev/xpbeep.c
+31
-5
31 additions, 5 deletions
src/xpdev/xpbeep.c
with
31 additions
and
5 deletions
src/xpdev/xpbeep.c
+
31
−
5
View file @
5fcafb56
...
...
@@ -63,6 +63,8 @@ static int handle_type=SOUND_DEVICE_CLOSED;
#ifdef _WIN32
static
HWAVEOUT
waveOut
;
static
WAVEHDR
wh
;
static
WAVEHDR
silence
;
static
unsigned
char
silence_data
=
128
;
static
unsigned
char
wave
[
S_RATE
*
15
/
2
+
1
];
#endif
...
...
@@ -232,6 +234,24 @@ BOOL xptone_open(void)
waveOutClose
(
waveOut
);
return
(
FALSE
);
}
memset
(
&
silence
,
0
,
sizeof
(
silence
));
silence
.
lpData
=&
silence_data
;
silence
.
dwBufferLength
=
1
;
silence
.
dwFlags
=
WHDR_BEGINLOOP
|
WHDR_ENDLOOP
;
silence
.
dwLoops
=
0xffffffffUL
;
/* Good for 54 hours of silence @ 22010 */
if
(
waveOutPrepareHeader
(
waveOut
,
&
silence
,
sizeof
(
silence
))
!=
MMSYSERR_NOERROR
)
{
waveOutUnprepareHeader
(
waveOut
,
&
wh
,
sizeof
(
wh
));
sound_device_open_failed
=
TRUE
;
waveOutClose
(
waveOut
);
return
(
FALSE
);
}
if
(
waveOutWrite
(
waveOut
,
&
wh
,
sizeof
(
wh
))
!=
MMSYSERR_NOERROR
)
{
waveOutUnprepareHeader
(
waveOut
,
&
wh
,
sizeof
(
wh
));
waveOutUnprepareHeader
(
waveOut
,
&
silence
,
sizeof
(
wh
));
sound_device_open_failed
=
TRUE
;
waveOutClose
(
waveOut
);
return
(
FALSE
);
}
handle_type
=
SOUND_DEVICE_WIN32
;
if
(
!
sound_device_open_failed
)
return
(
TRUE
);
...
...
@@ -320,9 +340,12 @@ BOOL xptone_close(void)
{
#ifdef _WIN32
if
(
handle_type
==
SOUND_DEVICE_WIN32
)
{
waveOut
Close
(
waveOut
);
waveOut
BreakLoop
(
waveOut
);
while
(
waveOutUnprepareHeader
(
waveOut
,
&
wh
,
sizeof
(
wh
))
==
WAVERR_STILLPLAYING
)
SLEEP
(
1
);
while
(
waveOutUnprepareHeader
(
waveOut
,
&
silence
,
sizeof
(
silence
))
==
WAVERR_STILLPLAYING
)
SLEEP
(
1
);
waveOutClose
(
waveOut
);
}
#endif
...
...
@@ -364,11 +387,14 @@ BOOL xptone(double freq, DWORD duration, enum WAVE_SHAPE shape)
makewave
(
freq
,
wave
,
wh
.
dwBufferLength
,
shape
);
if
(
waveOutWrite
(
waveOut
,
&
wh
,
sizeof
(
wh
))
==
MMSYSERR_NOERROR
)
if
(
waveOutWrite
(
waveOut
,
&
wh
,
sizeof
(
wh
))
==
MMSYSERR_NOERROR
)
{
success
=
TRUE
;
while
(
!
(
wh
.
dwFlags
&
WHDR_DONE
))
SLEEP
(
1
);
waveOutBreakLoop
(
waveOut
);
/* Put the silence back in */
waveOutWrite
(
waveOut
,
&
silence
,
sizeof
(
silence
));
while
(
!
(
wh
.
dwFlags
&
WHDR_DONE
))
SLEEP
(
1
);
}
if
(
must_close
)
xptone_close
();
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment