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
d51d55ba
Commit
d51d55ba
authored
Dec 22, 2015
by
Michael Stefaniuc
Committed by
Alexandre Julliard
Dec 22, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dsound: Simplify error handling when creating a sound buffer.
Signed-off-by:
Michael Stefaniuc
<
mstefani@redhat.de
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
7eec8cb4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
30 deletions
+16
-30
buffer.c
dlls/dsound/buffer.c
+16
-30
No files found.
dlls/dsound/buffer.c
View file @
d51d55ba
...
...
@@ -992,29 +992,28 @@ HRESULT IDirectSoundBufferImpl_Create(
LPWAVEFORMATEX
wfex
=
dsbd
->
lpwfxFormat
;
HRESULT
err
=
DS_OK
;
DWORD
capf
=
0
;
TRACE
(
"(%p,%p,%p)
\n
"
,
device
,
pdsb
,
dsbd
);
*
pdsb
=
NULL
;
if
(
dsbd
->
dwBufferBytes
<
DSBSIZE_MIN
||
dsbd
->
dwBufferBytes
>
DSBSIZE_MAX
)
{
WARN
(
"invalid parameter: dsbd->dwBufferBytes = %d
\n
"
,
dsbd
->
dwBufferBytes
);
*
pdsb
=
NULL
;
return
DSERR_INVALIDPARAM
;
/* FIXME: which error? */
}
dsb
=
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
sizeof
(
*
dsb
));
if
(
dsb
==
0
)
{
WARN
(
"out of memory
\n
"
);
*
pdsb
=
NULL
;
if
(
!
dsb
)
return
DSERR_OUTOFMEMORY
;
}
TRACE
(
"Created buffer at %p
\n
"
,
dsb
);
dsb
->
ref
=
0
;
dsb
->
ref
=
1
;
dsb
->
refn
=
0
;
dsb
->
ref3D
=
0
;
dsb
->
refiks
=
0
;
dsb
->
numIfaces
=
0
;
dsb
->
numIfaces
=
1
;
dsb
->
device
=
device
;
dsb
->
IDirectSoundBuffer8_iface
.
lpVtbl
=
&
dsbvt
;
dsb
->
IDirectSoundNotify_iface
.
lpVtbl
=
&
dsnvt
;
...
...
@@ -1025,9 +1024,8 @@ HRESULT IDirectSoundBufferImpl_Create(
CopyMemory
(
&
dsb
->
dsbd
,
dsbd
,
dsbd
->
dwSize
);
dsb
->
pwfx
=
DSOUND_CopyFormat
(
wfex
);
if
(
dsb
->
pwfx
==
NULL
)
{
HeapFree
(
GetProcessHeap
(),
0
,
dsb
);
*
pdsb
=
NULL
;
if
(
!
dsb
->
pwfx
)
{
IDirectSoundBuffer8_Release
(
&
dsb
->
IDirectSoundBuffer8_iface
);
return
DSERR_OUTOFMEMORY
;
}
...
...
@@ -1052,22 +1050,16 @@ HRESULT IDirectSoundBufferImpl_Create(
/* Allocate an empty buffer */
dsb
->
buffer
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeof
(
*
(
dsb
->
buffer
)));
if
(
dsb
->
buffer
==
NULL
)
{
WARN
(
"out of memory
\n
"
);
HeapFree
(
GetProcessHeap
(),
0
,
dsb
->
pwfx
);
HeapFree
(
GetProcessHeap
(),
0
,
dsb
);
*
pdsb
=
NULL
;
if
(
!
dsb
->
buffer
)
{
IDirectSoundBuffer8_Release
(
&
dsb
->
IDirectSoundBuffer8_iface
);
return
DSERR_OUTOFMEMORY
;
}
/* Allocate system memory for buffer */
dsb
->
buffer
->
memory
=
HeapAlloc
(
GetProcessHeap
(),
0
,
dsb
->
buflen
);
if
(
dsb
->
buffer
->
memory
==
NULL
)
{
if
(
!
dsb
->
buffer
->
memory
)
{
WARN
(
"out of memory
\n
"
);
HeapFree
(
GetProcessHeap
(),
0
,
dsb
->
pwfx
);
HeapFree
(
GetProcessHeap
(),
0
,
dsb
->
buffer
);
HeapFree
(
GetProcessHeap
(),
0
,
dsb
);
*
pdsb
=
NULL
;
IDirectSoundBuffer8_Release
(
&
dsb
->
IDirectSoundBuffer8_iface
);
return
DSERR_OUTOFMEMORY
;
}
...
...
@@ -1118,18 +1110,12 @@ HRESULT IDirectSoundBufferImpl_Create(
/* register buffer if not primary */
if
(
!
(
dsbd
->
dwFlags
&
DSBCAPS_PRIMARYBUFFER
))
{
err
=
DirectSoundDevice_AddBuffer
(
device
,
dsb
);
if
(
err
!=
DS_OK
)
{
HeapFree
(
GetProcessHeap
(),
0
,
dsb
->
buffer
->
memory
);
HeapFree
(
GetProcessHeap
(),
0
,
dsb
->
buffer
);
RtlDeleteResource
(
&
dsb
->
lock
);
HeapFree
(
GetProcessHeap
(),
0
,
dsb
->
pwfx
);
HeapFree
(
GetProcessHeap
(),
0
,
dsb
);
dsb
=
NULL
;
}
if
(
err
==
DS_OK
)
*
pdsb
=
dsb
;
else
IDirectSoundBuffer8_Release
(
&
dsb
->
IDirectSoundBuffer8_iface
);
}
IDirectSoundBuffer8_AddRef
(
&
dsb
->
IDirectSoundBuffer8_iface
);
*
pdsb
=
dsb
;
return
err
;
}
...
...
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