Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-cw
Commits
1053bfb4
Commit
1053bfb4
authored
May 14, 2012
by
Andrew Eikum
Committed by
Alexandre Julliard
May 14, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dsound: Express buffer positions in terms of bytes, not fragments.
parent
2c608745
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
46 deletions
+34
-46
dsound_private.h
dlls/dsound/dsound_private.h
+1
-1
mixer.c
dlls/dsound/mixer.c
+29
-36
primary.c
dlls/dsound/primary.c
+4
-9
No files found.
dlls/dsound/dsound_private.h
View file @
1053bfb4
...
...
@@ -83,7 +83,7 @@ struct DirectSoundDevice
DSCAPS
drvcaps
;
DWORD
priolevel
;
PWAVEFORMATEX
pwfx
;
UINT
timerID
,
p
wplay
,
pwqueue
,
prebuf
,
helfrags
;
UINT
timerID
,
p
laying_offs_bytes
,
in_mmdev_bytes
,
prebuf
,
helfrags
;
UINT64
last_pos_bytes
;
DWORD
fraglen
;
LPBYTE
buffer
;
...
...
dlls/dsound/mixer.c
View file @
1053bfb4
...
...
@@ -663,53 +663,47 @@ static void DSOUND_MixToPrimary(const DirectSoundDevice *device, DWORD writepos,
static
void
DSOUND_WaveQueue
(
DirectSoundDevice
*
device
,
BOOL
force
)
{
DWORD
prebuf_frames
,
buf_offs_bytes
,
wave_fragpos
;
int
prebuf_frags
;
DWORD
prebuf_frames
,
prebuf_bytes
,
read_offs_bytes
;
BYTE
*
buffer
;
HRESULT
hr
;
TRACE
(
"(%p)
\n
"
,
device
);
/* calculate the current wave frag position */
wave_fragpos
=
(
device
->
pwplay
+
device
->
pwqueue
)
%
device
->
helfrags
;
read_offs_bytes
=
(
device
->
playing_offs_bytes
+
device
->
in_mmdev_bytes
)
%
device
->
buflen
;
/* calculate the current wave write position */
buf_offs_bytes
=
wave_fragpos
*
device
->
fraglen
;
TRACE
(
"wave_fragpos = %i, buf_offs_bytes = %i, pwqueue = %i, prebuf = %i
\n
"
,
wave_fragpos
,
buf_offs_bytes
,
device
->
pwqueue
,
device
->
prebuf
);
TRACE
(
"read_offs_bytes = %u, playing_offs_bytes = %u, in_mmdev_bytes: %u, prebuf = %u
\n
"
,
read_offs_bytes
,
device
->
playing_offs_bytes
,
device
->
in_mmdev_bytes
,
device
->
prebuf
);
if
(
!
force
)
{
/* check remaining prebuffered frags */
prebuf_frags
=
device
->
mixpos
/
device
->
fraglen
;
if
(
prebuf_frags
==
device
->
helfrags
)
--
prebuf_frags
;
TRACE
(
"wave_fragpos = %d, mixpos_frags = %d
\n
"
,
wave_fragpos
,
prebuf_frags
);
if
(
prebuf_frags
<
wave_fragpos
)
prebuf_frags
+=
device
->
helfrags
;
prebuf_frags
-=
wave_fragpos
;
TRACE
(
"wanted prebuf_frags = %d
\n
"
,
prebuf_frags
);
if
(
device
->
mixpos
<
device
->
playing_offs_bytes
)
prebuf_bytes
=
device
->
mixpos
+
device
->
buflen
-
device
->
playing_offs_bytes
;
else
prebuf_bytes
=
device
->
mixpos
-
device
->
playing_offs_bytes
;
}
else
/* buffer the maximum amount of frags */
prebuf_
frags
=
device
->
prebuf
;
prebuf_
bytes
=
device
->
prebuf
*
device
->
fraglen
;
/* limit to the queue we have left */
if
((
prebuf_frags
+
device
->
pwqueue
)
>
device
->
prebuf
)
prebuf_
frags
=
device
->
prebuf
-
device
->
pwqueue
;
if
(
device
->
in_mmdev_bytes
+
prebuf_bytes
>
device
->
prebuf
*
device
->
fraglen
)
prebuf_
bytes
=
device
->
prebuf
*
device
->
fraglen
-
device
->
in_mmdev_bytes
;
TRACE
(
"prebuf_
frags = %i
\n
"
,
prebuf_frag
s
);
TRACE
(
"prebuf_
bytes = %u
\n
"
,
prebuf_byte
s
);
if
(
!
prebuf_
frag
s
)
if
(
!
prebuf_
byte
s
)
return
;
/* adjust queue */
device
->
pwqueue
+=
prebuf_frags
;
device
->
in_mmdev_bytes
+=
prebuf_bytes
;
prebuf_frames
=
((
prebuf_frags
+
wave_fragpos
>
device
->
helfrags
)
?
(
device
->
helfrags
-
wave_fragpos
)
:
(
prebuf_frags
))
*
device
->
fraglen
/
device
->
pwfx
->
nBlockAlign
;
if
(
prebuf_bytes
+
read_offs_bytes
>
device
->
buflen
){
DWORD
chunk_bytes
=
device
->
buflen
-
read_offs_bytes
;
prebuf_frames
=
chunk_bytes
/
device
->
pwfx
->
nBlockAlign
;
prebuf_bytes
-=
chunk_bytes
;
}
else
{
prebuf_frames
=
prebuf_bytes
/
device
->
pwfx
->
nBlockAlign
;
prebuf_bytes
=
0
;
}
hr
=
IAudioRenderClient_GetBuffer
(
device
->
render
,
prebuf_frames
,
&
buffer
);
if
(
FAILED
(
hr
)){
...
...
@@ -717,7 +711,7 @@ static void DSOUND_WaveQueue(DirectSoundDevice *device, BOOL force)
return
;
}
memcpy
(
buffer
,
device
->
buffer
+
buf
_offs_bytes
,
memcpy
(
buffer
,
device
->
buffer
+
read
_offs_bytes
,
prebuf_frames
*
device
->
pwfx
->
nBlockAlign
);
hr
=
IAudioRenderClient_ReleaseBuffer
(
device
->
render
,
prebuf_frames
,
0
);
...
...
@@ -727,9 +721,8 @@ static void DSOUND_WaveQueue(DirectSoundDevice *device, BOOL force)
}
/* check if anything wrapped */
prebuf_frags
=
prebuf_frags
+
wave_fragpos
-
device
->
helfrags
;
if
(
prebuf_frags
>
0
){
prebuf_frames
=
prebuf_frags
*
device
->
fraglen
/
device
->
pwfx
->
nBlockAlign
;
if
(
prebuf_bytes
>
0
){
prebuf_frames
=
prebuf_bytes
/
device
->
pwfx
->
nBlockAlign
;
hr
=
IAudioRenderClient_GetBuffer
(
device
->
render
,
prebuf_frames
,
&
buffer
);
if
(
FAILED
(
hr
)){
...
...
@@ -746,7 +739,7 @@ static void DSOUND_WaveQueue(DirectSoundDevice *device, BOOL force)
}
}
TRACE
(
"
queue now = %i
\n
"
,
device
->
pwqueue
);
TRACE
(
"
in_mmdev_bytes now = %i
\n
"
,
device
->
in_mmdev_bytes
);
}
/**
...
...
@@ -783,9 +776,9 @@ static void DSOUND_PerformMix(DirectSoundDevice *device)
delta_frags
=
(
pos_bytes
-
device
->
last_pos_bytes
)
/
device
->
fraglen
;
if
(
delta_frags
>
0
){
device
->
p
wplay
+=
delta_frags
;
device
->
p
wplay
%=
device
->
helfrags
;
device
->
pwqueue
-=
delta_frags
;
device
->
p
laying_offs_bytes
+=
delta_frags
*
device
->
fraglen
;
device
->
p
laying_offs_bytes
%=
device
->
buflen
;
device
->
in_mmdev_bytes
-=
delta_frags
*
device
->
fraglen
;
device
->
last_pos_bytes
=
pos_bytes
-
(
pos_bytes
%
device
->
fraglen
);
}
...
...
dlls/dsound/primary.c
View file @
1053bfb4
...
...
@@ -210,7 +210,7 @@ static HRESULT DSOUND_PrimaryOpen(DirectSoundDevice *device)
device
->
normfunction
=
normfunctions
[
device
->
pwfx
->
wBitsPerSample
/
8
-
1
];
FillMemory
(
device
->
buffer
,
device
->
buflen
,
(
device
->
pwfx
->
wBitsPerSample
==
8
)
?
128
:
0
);
FillMemory
(
device
->
mix_buffer
,
device
->
mix_buffer_len
,
0
);
device
->
last_pos_bytes
=
device
->
p
wplay
=
device
->
pwqueue
=
device
->
playpos
=
device
->
mixpos
=
0
;
device
->
last_pos_bytes
=
device
->
p
laying_offs_bytes
=
device
->
in_mmdev_bytes
=
device
->
playpos
=
device
->
mixpos
=
0
;
return
DS_OK
;
}
...
...
@@ -221,8 +221,6 @@ static void DSOUND_PrimaryClose(DirectSoundDevice *device)
TRACE
(
"(%p)
\n
"
,
device
);
device
->
pwqueue
=
(
DWORD
)
-
1
;
/* resetting queues */
if
(
device
->
client
){
hr
=
IAudioClient_Stop
(
device
->
client
);
if
(
FAILED
(
hr
))
...
...
@@ -230,7 +228,7 @@ static void DSOUND_PrimaryClose(DirectSoundDevice *device)
}
/* clear the queue */
device
->
pwqueue
=
0
;
device
->
in_mmdev_bytes
=
0
;
}
HRESULT
DSOUND_PrimaryCreate
(
DirectSoundDevice
*
device
)
...
...
@@ -308,17 +306,14 @@ HRESULT DSOUND_PrimaryGetPosition(DirectSoundDevice *device, LPDWORD playpos, LP
{
TRACE
(
"(%p,%p,%p)
\n
"
,
device
,
playpos
,
writepos
);
TRACE
(
"pwplay=%i, pwqueue=%i
\n
"
,
device
->
pwplay
,
device
->
pwqueue
);
/* check if playpos was requested */
if
(
playpos
)
/* use the cached play position */
*
playpos
=
device
->
pwplay
*
device
->
fraglen
;
*
playpos
=
device
->
playing_offs_bytes
;
/* check if writepos was requested */
if
(
writepos
)
/* the writepos is the first non-queued position */
*
writepos
=
(
(
device
->
pwplay
+
device
->
pwqueue
)
%
device
->
helfrags
)
*
device
->
frag
len
;
*
writepos
=
(
device
->
playing_offs_bytes
+
device
->
in_mmdev_bytes
)
%
device
->
buf
len
;
TRACE
(
"playpos = %d, writepos = %d (%p, time=%d)
\n
"
,
playpos
?*
playpos
:-
1
,
writepos
?*
writepos
:-
1
,
device
,
GetTickCount
());
return
DS_OK
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment