Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
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-winehq
Commits
f0be44c8
Commit
f0be44c8
authored
May 09, 2012
by
Andrew Eikum
Committed by
Alexandre Julliard
May 09, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dsound: Don't destroy primary buffer until device is released.
parent
4d6ff854
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
68 additions
and
33 deletions
+68
-33
buffer.c
dlls/dsound/buffer.c
+28
-16
dsound.c
dlls/dsound/dsound.c
+0
-5
dsound_private.h
dlls/dsound/dsound_private.h
+1
-0
primary.c
dlls/dsound/primary.c
+25
-8
sound3d.c
dlls/dsound/sound3d.c
+5
-4
dsound.c
dlls/dsound/tests/dsound.c
+9
-0
No files found.
dlls/dsound/buffer.c
View file @
f0be44c8
...
...
@@ -327,16 +327,22 @@ static ULONG WINAPI IDirectSoundBufferImpl_AddRef(IDirectSoundBuffer8 *iface)
static
ULONG
WINAPI
IDirectSoundBufferImpl_Release
(
IDirectSoundBuffer8
*
iface
)
{
IDirectSoundBufferImpl
*
This
=
impl_from_IDirectSoundBuffer8
(
iface
);
ULONG
ref
=
InterlockedDecrement
(
&
This
->
ref
);
TRACE
(
"(%p) ref was %d
\n
"
,
This
,
ref
+
1
);
ULONG
ref
;
if
(
is_primary_buffer
(
This
)){
ref
=
capped_refcount_dec
(
&
This
->
ref
);
if
(
!
ref
)
capped_refcount_dec
(
&
This
->
numIfaces
);
TRACE
(
"(%p) ref is now: %d
\n
"
,
This
,
ref
);
return
ref
;
}
if
(
!
ref
&&
!
InterlockedDecrement
(
&
This
->
numIfaces
))
{
if
(
is_primary_buffer
(
This
))
primarybuffer_destroy
(
This
);
else
ref
=
InterlockedDecrement
(
&
This
->
ref
);
if
(
!
ref
&&
!
InterlockedDecrement
(
&
This
->
numIfaces
))
secondarybuffer_destroy
(
This
);
}
TRACE
(
"(%p) ref is now %d
\n
"
,
This
,
ref
);
return
ref
;
}
...
...
@@ -1077,16 +1083,22 @@ static ULONG WINAPI IKsPropertySetImpl_AddRef(IKsPropertySet *iface)
static
ULONG
WINAPI
IKsPropertySetImpl_Release
(
IKsPropertySet
*
iface
)
{
IDirectSoundBufferImpl
*
This
=
impl_from_IKsPropertySet
(
iface
);
ULONG
ref
=
InterlockedDecrement
(
&
This
->
refiks
);
ULONG
ref
;
if
(
is_primary_buffer
(
This
)){
ref
=
capped_refcount_dec
(
&
This
->
refiks
);
if
(
!
ref
)
capped_refcount_dec
(
&
This
->
numIfaces
);
TRACE
(
"(%p) ref is now: %d
\n
"
,
This
,
ref
);
return
ref
;
}
TRACE
(
"(%p) ref was %d
\n
"
,
This
,
ref
+
1
);
ref
=
InterlockedDecrement
(
&
This
->
refiks
);
if
(
!
ref
&&
!
InterlockedDecrement
(
&
This
->
numIfaces
))
secondarybuffer_destroy
(
This
);
TRACE
(
"(%p) ref is now %d
\n
"
,
This
,
ref
);
if
(
!
ref
&&
!
InterlockedDecrement
(
&
This
->
numIfaces
))
{
if
(
is_primary_buffer
(
This
))
primarybuffer_destroy
(
This
);
else
secondarybuffer_destroy
(
This
);
}
return
ref
;
}
...
...
dlls/dsound/dsound.c
View file @
f0be44c8
...
...
@@ -1255,11 +1255,6 @@ ULONG DirectSoundDevice_Release(DirectSoundDevice * device)
secondarybuffer_destroy
(
device
->
buffers
[
i
]);
}
if
(
device
->
primary
)
{
WARN
(
"primary buffer not released
\n
"
);
IDirectSoundBuffer8_Release
((
LPDIRECTSOUNDBUFFER8
)
device
->
primary
);
}
hr
=
DSOUND_PrimaryDestroy
(
device
);
if
(
hr
!=
DS_OK
)
WARN
(
"DSOUND_PrimaryDestroy failed
\n
"
);
...
...
dlls/dsound/dsound_private.h
View file @
f0be44c8
...
...
@@ -288,6 +288,7 @@ HRESULT primarybuffer_create(DirectSoundDevice *device, IDirectSoundBufferImpl *
const
DSBUFFERDESC
*
dsbd
)
DECLSPEC_HIDDEN
;
void
primarybuffer_destroy
(
IDirectSoundBufferImpl
*
This
)
DECLSPEC_HIDDEN
;
HRESULT
primarybuffer_SetFormat
(
DirectSoundDevice
*
device
,
LPCWAVEFORMATEX
wfex
)
DECLSPEC_HIDDEN
;
LONG
capped_refcount_dec
(
LONG
*
ref
)
DECLSPEC_HIDDEN
;
/* duplex.c */
...
...
dlls/dsound/primary.c
View file @
f0be44c8
...
...
@@ -258,6 +258,13 @@ HRESULT DSOUND_PrimaryDestroy(DirectSoundDevice *device)
EnterCriticalSection
(
&
(
device
->
mixlock
));
DSOUND_PrimaryClose
(
device
);
if
(
device
->
primary
&&
(
device
->
primary
->
ref
||
device
->
primary
->
numIfaces
))
WARN
(
"Destroying primary buffer while references held (%u %u)
\n
"
,
device
->
primary
->
ref
,
device
->
primary
->
numIfaces
);
HeapFree
(
GetProcessHeap
(),
0
,
device
->
primary
);
device
->
primary
=
NULL
;
HeapFree
(
GetProcessHeap
(),
0
,
device
->
pwfx
);
device
->
pwfx
=
NULL
;
...
...
@@ -756,21 +763,31 @@ static ULONG WINAPI PrimaryBufferImpl_AddRef(IDirectSoundBuffer *iface)
return
ref
;
}
void
primarybuffer_destroy
(
IDirectSoundBufferImpl
*
This
)
/* Decreases *out by 1 to no less than 0.
* Returns the new value of *out. */
LONG
capped_refcount_dec
(
LONG
*
out
)
{
This
->
device
->
primary
=
NULL
;
HeapFree
(
GetProcessHeap
(),
0
,
This
);
TRACE
(
"(%p) released
\n
"
,
This
);
LONG
ref
,
oldref
;
do
{
ref
=
*
out
;
if
(
!
ref
)
return
0
;
oldref
=
InterlockedCompareExchange
(
out
,
ref
-
1
,
ref
);
}
while
(
oldref
!=
ref
);
return
ref
-
1
;
}
static
ULONG
WINAPI
PrimaryBufferImpl_Release
(
IDirectSoundBuffer
*
iface
)
{
IDirectSoundBufferImpl
*
This
=
impl_from_IDirectSoundBuffer
(
iface
);
DWORD
ref
=
InterlockedDecrement
(
&
(
This
->
ref
));
TRACE
(
"(%p) ref was %d
\n
"
,
This
,
ref
+
1
);
ULONG
ref
;
ref
=
capped_refcount_dec
(
&
This
->
ref
);
if
(
!
ref
)
capped_refcount_dec
(
&
This
->
numIfaces
);
TRACE
(
"(%p) primary ref is now %d
\n
"
,
This
,
ref
);
if
(
!
ref
&&
!
InterlockedDecrement
(
&
This
->
numIfaces
))
primarybuffer_destroy
(
This
);
return
ref
;
}
...
...
dlls/dsound/sound3d.c
View file @
f0be44c8
...
...
@@ -699,12 +699,13 @@ static ULONG WINAPI IDirectSound3DListenerImpl_AddRef(IDirectSound3DListener *if
static
ULONG
WINAPI
IDirectSound3DListenerImpl_Release
(
IDirectSound3DListener
*
iface
)
{
IDirectSoundBufferImpl
*
This
=
impl_from_IDirectSound3DListener
(
iface
);
ULONG
ref
=
InterlockedDecrement
(
&
This
->
ref3D
)
;
ULONG
ref
;
TRACE
(
"(%p) ref was %d
\n
"
,
This
,
ref
+
1
);
ref
=
capped_refcount_dec
(
&
This
->
ref3D
);
if
(
!
ref
)
capped_refcount_dec
(
&
This
->
numIfaces
);
if
(
!
ref
&&
!
InterlockedDecrement
(
&
This
->
numIfaces
))
primarybuffer_destroy
(
This
);
TRACE
(
"(%p) ref is now %d
\n
"
,
This
,
ref
);
return
ref
;
}
...
...
dlls/dsound/tests/dsound.c
View file @
f0be44c8
...
...
@@ -493,6 +493,15 @@ static HRESULT test_primary(LPGUID lpGuid)
!
(
dscaps
.
dwFlags
&
DSCAPS_EMULDRIVER
),
5
.
0
,
0
,
0
,
0
,
0
,
FALSE
,
0
);
ref
=
IDirectSoundBuffer_Release
(
primary
);
ok
(
ref
==
0
,
"IDirectSoundBuffer_Release() primary has %d references
\n
"
,
ref
);
ref
=
IDirectSoundBuffer_AddRef
(
primary
);
ok
(
ref
==
1
,
"IDirectSoundBuffer_AddRef() primary has %d references
\n
"
,
ref
);
ref
=
IDirectSoundBuffer_Release
(
primary
);
ok
(
ref
==
0
,
"IDirectSoundBuffer_Release() primary has %d references
\n
"
,
ref
);
ref
=
IDirectSoundBuffer_Release
(
primary
);
ok
(
ref
==
0
,
"IDirectSoundBuffer_Release() primary has %d references, "
"should have 0
\n
"
,
ref
);
}
...
...
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