Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
wine
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Package registry
Container Registry
Model registry
Operate
Terraform modules
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
Zsolt Vadász
wine
Commits
976f56d6
Commit
976f56d6
authored
17 years ago
by
Maarten Lankhorst
Committed by
Alexandre Julliard
17 years ago
Browse files
Options
Downloads
Patches
Plain Diff
dsound: Simplify IDirectSoundBufferImpl_GetCurrentPosition.
parent
a6ab4c51
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
dlls/dsound/buffer.c
+6
-71
6 additions, 71 deletions
dlls/dsound/buffer.c
dlls/dsound/dsound_private.h
+1
-5
1 addition, 5 deletions
dlls/dsound/dsound_private.h
with
7 additions
and
76 deletions
dlls/dsound/buffer.c
+
6
−
71
View file @
976f56d6
...
...
@@ -409,47 +409,9 @@ static ULONG WINAPI IDirectSoundBufferImpl_Release(LPDIRECTSOUNDBUFFER8 iface)
return
ref
;
}
DWORD
DSOUND_CalcPlayPosition
(
IDirectSoundBufferImpl
*
This
,
DWORD
pplay
,
DWORD
pwrite
)
static
DWORD
DSOUND_CalcPlayPosition
(
IDirectSoundBufferImpl
*
This
)
{
DWORD
bplay
=
This
->
buf_mixpos
;
DWORD
pmix
=
This
->
primary_mixpos
;
DirectSoundDevice
*
device
=
This
->
device
;
TRACE
(
"(%p, pplay=%u, pwrite=%u)
\n
"
,
This
,
pplay
,
pwrite
);
/* the actual primary play position (pplay) is always behind last mixed (pmix),
* unless the computer is too slow or something */
/* we need to know how far away we are from there */
if
(
pmix
<
pplay
)
pmix
+=
device
->
buflen
;
/* wraparound */
pmix
-=
pplay
;
/* detect buffer underrun (sanity) */
if
(
pwrite
<
pplay
)
pwrite
+=
device
->
buflen
;
/* wraparound */
pwrite
-=
pplay
;
if
(
pmix
>
(
ds_snd_queue_max
*
device
->
fraglen
+
pwrite
+
device
->
writelead
))
{
ERR
(
"detected an underrun: primary queue was %d
\n
"
,
pmix
);
pmix
=
0
;
}
TRACE
(
"primary back-samples=%d
\n
"
,
pmix
);
/* divide the offset by its sample size */
pmix
/=
device
->
pwfx
->
nBlockAlign
;
/* adjust for our frequency */
pmix
=
(
pmix
*
This
->
freqAdjust
)
>>
DSOUND_FREQSHIFT
;
/* multiply by our own sample size */
pmix
*=
This
->
pwfx
->
nBlockAlign
;
TRACE
(
"this back-offset=%d
\n
"
,
pmix
);
/* sanity */
if
(
pmix
>
This
->
buflen
)
WARN
(
"Mixed length (%d) is longer then buffer length (%d)
\n
"
,
pmix
,
This
->
buflen
);
/* subtract from our last mixed position */
while
(
bplay
<
pmix
)
bplay
+=
This
->
buflen
;
/* wraparound */
bplay
-=
pmix
;
/* check for lead-in */
if
(
This
->
leadin
&&
((
bplay
<
This
->
startpos
)
||
(
bplay
>
This
->
buf_mixpos
)))
{
...
...
@@ -481,38 +443,13 @@ static HRESULT WINAPI IDirectSoundBufferImpl_GetCurrentPosition(
return
hres
;
}
}
else
{
if
(
playpos
&&
(
This
->
state
!=
STATE_PLAYING
))
{
if
(
playpos
&&
(
This
->
state
!=
STATE_PLAYING
))
/* we haven't been merged into the primary buffer (yet) */
*
playpos
=
This
->
buf_mixpos
;
}
else
if
(
playpos
)
{
DWORD
pplay
,
pwrite
;
/* get primary lock, before messing with primary/device data */
EnterCriticalSection
(
&
(
This
->
device
->
mixlock
));
/* let's get this exact; first, recursively call GetPosition on the primary */
if
(
DSOUND_PrimaryGetPosition
(
This
->
device
,
&
pplay
,
&
pwrite
)
!=
DS_OK
)
WARN
(
"DSOUND_PrimaryGetPosition failed
\n
"
);
if
((
This
->
dsbd
.
dwFlags
&
DSBCAPS_GETCURRENTPOSITION2
)
||
This
->
device
->
hwbuf
)
{
/* calculate play position using this */
*
playpos
=
DSOUND_CalcPlayPosition
(
This
,
pplay
,
pwrite
);
}
else
{
/* (unless the app isn't using GETCURRENTPOSITION2) */
/* don't know exactly how this should be handled...
* the docs says that play cursor is reported as directly
* behind write cursor, hmm... */
/* let's just do what might work for Half-Life */
DWORD
wp
;
wp
=
(
This
->
device
->
pwplay
+
This
->
device
->
prebuf
)
*
This
->
device
->
fraglen
;
wp
%=
This
->
device
->
buflen
;
*
playpos
=
DSOUND_CalcPlayPosition
(
This
,
wp
,
pwrite
);
TRACE
(
"Using non-GETCURRENTPOSITION2
\n
"
);
}
LeaveCriticalSection
(
&
(
This
->
device
->
mixlock
));
}
else
if
(
playpos
)
*
playpos
=
DSOUND_CalcPlayPosition
(
This
);
if
(
writepos
)
*
writepos
=
This
->
buf_mixpos
;
*
writepos
=
(
playpos
?
*
playpos
:
This
->
buf_mixpos
)
;
}
if
(
writepos
)
{
if
(
This
->
state
!=
STATE_STOPPED
)
{
...
...
@@ -521,11 +458,9 @@ static HRESULT WINAPI IDirectSoundBufferImpl_GetCurrentPosition(
}
*
writepos
%=
This
->
buflen
;
}
if
(
playpos
)
This
->
last_playpos
=
*
playpos
;
TRACE
(
"playpos = %d, writepos = %d, buflen=%d (%p, time=%d)
\n
"
,
playpos
?*
playpos
:
0
,
writepos
?*
writepos
:
0
,
This
->
buflen
,
This
,
GetTickCount
());
playpos
?*
playpos
:
-
1
,
writepos
?*
writepos
:
-
1
,
This
->
buflen
,
This
,
GetTickCount
());
return
DS_OK
;
}
...
...
This diff is collapsed.
Click to expand it.
dlls/dsound/dsound_private.h
+
1
−
5
View file @
976f56d6
...
...
@@ -170,7 +170,7 @@ struct IDirectSoundBufferImpl
/* used for frequency conversion (PerfectPitch) */
ULONG
freqAdjust
,
freqAcc
;
/* used for intelligent (well, sort of) prebuffering */
DWORD
primary_mixpos
,
buf_mixpos
,
last_playpos
;
DWORD
primary_mixpos
,
buf_mixpos
;
/* IDirectSoundNotifyImpl fields */
IDirectSoundNotifyImpl
*
notify
;
...
...
@@ -427,10 +427,6 @@ HRESULT DSOUND_PrimarySetFormat(DirectSoundDevice *device, LPCWAVEFORMATEX wfex)
HRESULT
DSOUND_FullDuplexCreate
(
REFIID
riid
,
LPDIRECTSOUNDFULLDUPLEX
*
ppDSFD
);
/* buffer.c */
DWORD
DSOUND_CalcPlayPosition
(
IDirectSoundBufferImpl
*
This
,
DWORD
pplay
,
DWORD
pwrite
);
/* mixer.c */
void
DSOUND_CheckEvent
(
IDirectSoundBufferImpl
*
dsb
,
DWORD
playpos
,
int
len
);
...
...
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