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
52e384f9
Commit
52e384f9
authored
Jan 14, 2006
by
Robert Reif
Committed by
Alexandre Julliard
Jan 14, 2006
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dsound: Rename some functions, make some functions global, and move
some code around.
parent
2d82fc42
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
131 additions
and
109 deletions
+131
-109
buffer.c
dlls/dsound/buffer.c
+100
-2
dsound.c
dlls/dsound/dsound.c
+10
-95
dsound_private.h
dlls/dsound/dsound_private.h
+21
-12
No files found.
dlls/dsound/buffer.c
View file @
52e384f9
...
...
@@ -364,7 +364,7 @@ static ULONG WINAPI IDirectSoundBufferImpl_Release(LPDIRECTSOUNDBUFFER8 iface)
TRACE
(
"(%p) ref was %ld
\n
"
,
This
,
ref
+
1
);
if
(
!
ref
)
{
D
SOUND
_RemoveBuffer
(
This
->
device
,
This
);
D
irectSoundDevice
_RemoveBuffer
(
This
->
device
,
This
);
This
->
lock
.
DebugInfo
->
Spare
[
0
]
=
0
;
DeleteCriticalSection
(
&
(
This
->
lock
));
...
...
@@ -1158,7 +1158,7 @@ HRESULT IDirectSoundBufferImpl_Create(
/* register buffer if not primary */
if
(
!
(
dsbd
->
dwFlags
&
DSBCAPS_PRIMARYBUFFER
))
{
err
=
D
SOUND
_AddBuffer
(
device
,
dsb
);
err
=
D
irectSoundDevice
_AddBuffer
(
device
,
dsb
);
if
(
err
!=
DS_OK
)
{
HeapFree
(
GetProcessHeap
(),
0
,
dsb
->
buffer
->
memory
);
HeapFree
(
GetProcessHeap
(),
0
,
dsb
->
buffer
);
...
...
@@ -1212,6 +1212,104 @@ HRESULT IDirectSoundBufferImpl_Destroy(
return
S_OK
;
}
HRESULT
IDirectSoundBufferImpl_Duplicate
(
DirectSoundDevice
*
device
,
IDirectSoundBufferImpl
**
ppdsb
,
IDirectSoundBufferImpl
*
pdsb
)
{
IDirectSoundBufferImpl
*
dsb
;
HRESULT
hres
=
DS_OK
;
int
size
;
TRACE
(
"(%p,%p,%p)
\n
"
,
device
,
pdsb
,
pdsb
);
dsb
=
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
sizeof
(
*
dsb
));
if
(
dsb
==
NULL
)
{
WARN
(
"out of memory
\n
"
);
*
ppdsb
=
NULL
;
return
DSERR_OUTOFMEMORY
;
}
CopyMemory
(
dsb
,
pdsb
,
sizeof
(
IDirectSoundBufferImpl
));
if
(
pdsb
->
hwbuf
)
{
TRACE
(
"duplicating hardware buffer
\n
"
);
hres
=
IDsDriver_DuplicateSoundBuffer
(
device
->
driver
,
pdsb
->
hwbuf
,
(
LPVOID
*
)
&
dsb
->
hwbuf
);
if
(
hres
!=
DS_OK
)
{
TRACE
(
"IDsDriver_DuplicateSoundBuffer failed, falling back to "
"software buffer
\n
"
);
dsb
->
hwbuf
=
NULL
;
/* allocate buffer */
if
(
device
->
drvdesc
.
dwFlags
&
DSDDESC_USESYSTEMMEMORY
)
{
dsb
->
buffer
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeof
(
*
(
dsb
->
buffer
)));
if
(
dsb
->
buffer
==
NULL
)
{
WARN
(
"out of memory
\n
"
);
HeapFree
(
GetProcessHeap
(),
0
,
dsb
);
*
ppdsb
=
NULL
;
return
DSERR_OUTOFMEMORY
;
}
dsb
->
buffer
->
memory
=
HeapAlloc
(
GetProcessHeap
(),
0
,
dsb
->
buflen
);
if
(
dsb
->
buffer
->
memory
==
NULL
)
{
WARN
(
"out of memory
\n
"
);
HeapFree
(
GetProcessHeap
(),
0
,
dsb
->
buffer
);
HeapFree
(
GetProcessHeap
(),
0
,
dsb
);
*
ppdsb
=
NULL
;
return
DSERR_OUTOFMEMORY
;
}
dsb
->
buffer
->
ref
=
1
;
/* FIXME: copy buffer ? */
}
}
}
else
{
dsb
->
hwbuf
=
NULL
;
dsb
->
buffer
->
ref
++
;
}
dsb
->
ref
=
0
;
dsb
->
state
=
STATE_STOPPED
;
dsb
->
playpos
=
0
;
dsb
->
buf_mixpos
=
0
;
dsb
->
device
=
device
;
dsb
->
ds3db
=
NULL
;
dsb
->
iks
=
NULL
;
/* FIXME? */
dsb
->
secondary
=
NULL
;
/* variable sized struct so calculate size based on format */
size
=
sizeof
(
WAVEFORMATEX
)
+
pdsb
->
pwfx
->
cbSize
;
dsb
->
pwfx
=
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
size
);
if
(
dsb
->
pwfx
==
NULL
)
{
WARN
(
"out of memory
\n
"
);
HeapFree
(
GetProcessHeap
(),
0
,
dsb
->
buffer
);
HeapFree
(
GetProcessHeap
(),
0
,
dsb
);
*
ppdsb
=
NULL
;
return
DSERR_OUTOFMEMORY
;
}
CopyMemory
(
dsb
->
pwfx
,
pdsb
->
pwfx
,
size
);
InitializeCriticalSection
(
&
(
dsb
->
lock
));
dsb
->
lock
.
DebugInfo
->
Spare
[
0
]
=
(
DWORD_PTR
)
"DSOUNDBUFFER_lock"
;
/* register buffer */
hres
=
DirectSoundDevice_AddBuffer
(
device
,
dsb
);
if
(
hres
!=
DS_OK
)
{
dsb
->
lock
.
DebugInfo
->
Spare
[
0
]
=
0
;
DeleteCriticalSection
(
&
(
dsb
->
lock
));
HeapFree
(
GetProcessHeap
(),
0
,
dsb
->
buffer
);
HeapFree
(
GetProcessHeap
(),
0
,
dsb
->
pwfx
);
HeapFree
(
GetProcessHeap
(),
0
,
dsb
);
*
ppdsb
=
0
;
}
*
ppdsb
=
dsb
;
return
hres
;
}
/*******************************************************************************
* SecondaryBuffer
*/
...
...
dlls/dsound/dsound.c
View file @
52e384f9
...
...
@@ -45,10 +45,6 @@ static ULONG WINAPI IDirectSound8_IUnknown_AddRef(LPUNKNOWN iface);
static
ULONG
WINAPI
IDirectSound8_IDirectSound_AddRef
(
LPDIRECTSOUND
iface
);
static
ULONG
WINAPI
IDirectSound8_IDirectSound8_AddRef
(
LPDIRECTSOUND8
iface
);
static
HRESULT
DirectSoundDevice_Create
(
DirectSoundDevice
**
ppDevice
);
static
ULONG
DirectSoundDevice_AddRef
(
DirectSoundDevice
*
device
);
static
ULONG
DirectSoundDevice_Release
(
DirectSoundDevice
*
device
);
static
const
char
*
dumpCooperativeLevel
(
DWORD
level
)
{
static
char
unknown
[
32
];
...
...
@@ -440,10 +436,8 @@ static HRESULT WINAPI IDirectSoundImpl_DuplicateSoundBuffer(
LPDIRECTSOUNDBUFFER
psb
,
LPLPDIRECTSOUNDBUFFER
ppdsb
)
{
IDirectSoundBufferImpl
*
pdsb
;
IDirectSoundBufferImpl
*
dsb
;
HRESULT
hres
=
DS_OK
;
int
size
;
IDirectSoundImpl
*
This
=
(
IDirectSoundImpl
*
)
iface
;
TRACE
(
"(%p,%p,%p)
\n
"
,
This
,
psb
,
ppdsb
);
...
...
@@ -475,90 +469,11 @@ static HRESULT WINAPI IDirectSoundImpl_DuplicateSoundBuffer(
return
DSERR_INVALIDCALL
;
}
pdsb
=
((
SecondaryBufferImpl
*
)
psb
)
->
dsb
;
dsb
=
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
sizeof
(
*
dsb
)
);
/* duplicate the actual buffer implementation */
hres
=
IDirectSoundBufferImpl_Duplicate
(
This
->
device
,
&
dsb
,
((
SecondaryBufferImpl
*
)
psb
)
->
dsb
);
if
(
dsb
==
NULL
)
{
WARN
(
"out of memory
\n
"
);
*
ppdsb
=
NULL
;
return
DSERR_OUTOFMEMORY
;
}
CopyMemory
(
dsb
,
pdsb
,
sizeof
(
IDirectSoundBufferImpl
));
if
(
pdsb
->
hwbuf
)
{
TRACE
(
"duplicating hardware buffer
\n
"
);
hres
=
IDsDriver_DuplicateSoundBuffer
(
This
->
device
->
driver
,
pdsb
->
hwbuf
,
(
LPVOID
*
)
&
dsb
->
hwbuf
);
if
(
hres
!=
DS_OK
)
{
TRACE
(
"IDsDriver_DuplicateSoundBuffer failed, falling back to software buffer
\n
"
);
dsb
->
hwbuf
=
NULL
;
/* allocate buffer */
if
(
This
->
device
->
drvdesc
.
dwFlags
&
DSDDESC_USESYSTEMMEMORY
)
{
dsb
->
buffer
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeof
(
*
(
dsb
->
buffer
)));
if
(
dsb
->
buffer
==
NULL
)
{
WARN
(
"out of memory
\n
"
);
HeapFree
(
GetProcessHeap
(),
0
,
dsb
);
*
ppdsb
=
NULL
;
return
DSERR_OUTOFMEMORY
;
}
dsb
->
buffer
->
memory
=
HeapAlloc
(
GetProcessHeap
(),
0
,
dsb
->
buflen
);
if
(
dsb
->
buffer
->
memory
==
NULL
)
{
WARN
(
"out of memory
\n
"
);
HeapFree
(
GetProcessHeap
(),
0
,
dsb
->
buffer
);
HeapFree
(
GetProcessHeap
(),
0
,
dsb
);
*
ppdsb
=
NULL
;
return
DSERR_OUTOFMEMORY
;
}
dsb
->
buffer
->
ref
=
1
;
/* FIXME: copy buffer ? */
}
}
}
else
{
dsb
->
hwbuf
=
NULL
;
dsb
->
buffer
->
ref
++
;
}
dsb
->
ref
=
0
;
dsb
->
state
=
STATE_STOPPED
;
dsb
->
playpos
=
0
;
dsb
->
buf_mixpos
=
0
;
dsb
->
device
=
This
->
device
;
dsb
->
ds3db
=
NULL
;
dsb
->
iks
=
NULL
;
/* FIXME? */
dsb
->
secondary
=
NULL
;
/* variable sized struct so calculate size based on format */
size
=
sizeof
(
WAVEFORMATEX
)
+
pdsb
->
pwfx
->
cbSize
;
dsb
->
pwfx
=
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
size
);
if
(
dsb
->
pwfx
==
NULL
)
{
WARN
(
"out of memory
\n
"
);
HeapFree
(
GetProcessHeap
(),
0
,
dsb
->
buffer
);
HeapFree
(
GetProcessHeap
(),
0
,
dsb
);
*
ppdsb
=
NULL
;
return
DSERR_OUTOFMEMORY
;
}
CopyMemory
(
dsb
->
pwfx
,
pdsb
->
pwfx
,
size
);
InitializeCriticalSection
(
&
(
dsb
->
lock
));
dsb
->
lock
.
DebugInfo
->
Spare
[
0
]
=
(
DWORD_PTR
)
"DSOUNDBUFFER_lock"
;
/* register buffer */
hres
=
DSOUND_AddBuffer
(
This
->
device
,
dsb
);
if
(
hres
!=
DS_OK
)
{
IDirectSoundBuffer8_Release
(
psb
);
dsb
->
lock
.
DebugInfo
->
Spare
[
0
]
=
0
;
DeleteCriticalSection
(
&
(
dsb
->
lock
));
HeapFree
(
GetProcessHeap
(),
0
,
dsb
->
buffer
);
HeapFree
(
GetProcessHeap
(),
0
,
dsb
->
pwfx
);
HeapFree
(
GetProcessHeap
(),
0
,
dsb
);
*
ppdsb
=
0
;
}
else
{
if
(
hres
==
DS_OK
)
{
hres
=
SecondaryBufferImpl_Create
(
dsb
,
(
SecondaryBufferImpl
**
)
ppdsb
);
if
(
*
ppdsb
)
{
dsb
->
secondary
=
(
SecondaryBufferImpl
*
)
*
ppdsb
;
...
...
@@ -867,7 +782,7 @@ static const IDirectSound8Vtbl IDirectSoundImpl_Vtbl =
IDirectSoundImpl_VerifyCertification
};
static
HRESULT
DirectSoundDevice_Create
(
DirectSoundDevice
**
ppDevice
)
HRESULT
DirectSoundDevice_Create
(
DirectSoundDevice
**
ppDevice
)
{
DirectSoundDevice
*
device
;
TRACE
(
"(%p)
\n
"
,
ppDevice
);
...
...
@@ -947,14 +862,14 @@ static HRESULT DirectSoundDevice_Create(DirectSoundDevice ** ppDevice)
return
DS_OK
;
}
static
ULONG
DirectSoundDevice_AddRef
(
DirectSoundDevice
*
device
)
ULONG
DirectSoundDevice_AddRef
(
DirectSoundDevice
*
device
)
{
ULONG
ref
=
InterlockedIncrement
(
&
(
device
->
ref
));
TRACE
(
"(%p) ref was %ld
\n
"
,
device
,
ref
-
1
);
return
ref
;
}
static
ULONG
DirectSoundDevice_Release
(
DirectSoundDevice
*
device
)
ULONG
DirectSoundDevice_Release
(
DirectSoundDevice
*
device
)
{
HRESULT
hr
;
ULONG
ref
=
InterlockedDecrement
(
&
(
device
->
ref
));
...
...
@@ -1005,7 +920,7 @@ static ULONG DirectSoundDevice_Release(DirectSoundDevice * device)
device
->
mixlock
.
DebugInfo
->
Spare
[
0
]
=
0
;
DeleteCriticalSection
(
&
device
->
mixlock
);
HeapFree
(
GetProcessHeap
(),
0
,
device
);
TRACE
(
"(%p) released
\n
"
,
device
);
TRACE
(
"(%p) released
\n
"
,
device
);
}
return
ref
;
}
...
...
@@ -1848,7 +1763,7 @@ HRESULT WINAPI DirectSoundCreate8(
* Add secondary buffer to buffer list.
* Gets exclusive access to buffer for writing.
*/
HRESULT
D
SOUND
_AddBuffer
(
HRESULT
D
irectSoundDevice
_AddBuffer
(
DirectSoundDevice
*
device
,
IDirectSoundBufferImpl
*
pDSB
)
{
...
...
@@ -1883,7 +1798,7 @@ HRESULT DSOUND_AddBuffer(
* Remove secondary buffer from buffer list.
* Gets exclusive access to buffer for writing.
*/
HRESULT
D
SOUND
_RemoveBuffer
(
HRESULT
D
irectSoundDevice
_RemoveBuffer
(
DirectSoundDevice
*
device
,
IDirectSoundBufferImpl
*
pDSB
)
{
...
...
dlls/dsound/dsound_private.h
View file @
52e384f9
...
...
@@ -81,6 +81,12 @@ struct IDirectSoundImpl
LPDIRECTSOUND8
pDS8
;
};
HRESULT
IDirectSoundImpl_Create
(
LPDIRECTSOUND8
*
ppds
);
/*****************************************************************************
* IDirectSoundDevice implementation structure
*/
struct
DirectSoundDevice
{
LONG
ref
;
...
...
@@ -122,16 +128,15 @@ typedef struct BufferMemory
LPBYTE
memory
;
}
BufferMemory
;
HRESULT
IDirectSoundImpl_Create
(
LPDIRECTSOUND8
*
ppds
);
HRESULT
DSOUND_Create
(
LPDIRECTSOUND
*
ppDS
,
IUnknown
*
pUnkOuter
);
HRESULT
DSOUND_Create8
(
LPDIRECTSOUND8
*
ppDS
,
IUnknown
*
pUnkOuter
);
HRESULT
DirectSoundDevice_Create
(
DirectSoundDevice
**
ppDevice
);
ULONG
DirectSoundDevice_AddRef
(
DirectSoundDevice
*
device
);
ULONG
DirectSoundDevice_Release
(
DirectSoundDevice
*
device
);
HRESULT
DirectSoundDevice_AddBuffer
(
DirectSoundDevice
*
device
,
IDirectSoundBufferImpl
*
pDSB
);
HRESULT
DirectSoundDevice_RemoveBuffer
(
DirectSoundDevice
*
device
,
IDirectSoundBufferImpl
*
pDSB
);
/*****************************************************************************
* IDirectSound COM components
...
...
@@ -240,6 +245,10 @@ HRESULT IDirectSoundBufferImpl_Create(
LPCDSBUFFERDESC
dsbd
);
HRESULT
IDirectSoundBufferImpl_Destroy
(
IDirectSoundBufferImpl
*
pdsb
);
HRESULT
IDirectSoundBufferImpl_Duplicate
(
DirectSoundDevice
*
device
,
IDirectSoundBufferImpl
**
ppdsb
,
IDirectSoundBufferImpl
*
pdsb
);
/*****************************************************************************
* SecondaryBuffer implementation structure
...
...
@@ -488,8 +497,8 @@ void DSOUND_RecalcFormat(IDirectSoundBufferImpl *dsb);
/* dsound.c */
HRESULT
DSOUND_
AddBuffer
(
DirectSoundDevice
*
device
,
IDirectSoundBufferImpl
*
pDSB
);
HRESULT
DSOUND_
RemoveBuffer
(
DirectSoundDevice
*
device
,
IDirectSoundBufferImpl
*
pDSB
);
HRESULT
DSOUND_
Create
(
LPDIRECTSOUND
*
ppDS
,
IUnknown
*
pUnkOuter
);
HRESULT
DSOUND_
Create8
(
LPDIRECTSOUND8
*
ppDS
,
IUnknown
*
pUnkOuter
);
/* primary.c */
...
...
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