ReactOS 0.4.16-dev-311-g9382aa2
dsound_private.h File Reference
#include <wine/config.h>
#include <assert.h>
#include <math.h>
#include <stdarg.h>
#include <windef.h>
#include <winbase.h>
#include <winnls.h>
#include <wingdi.h>
#include <winternl.h>
#include <objbase.h>
#include <audioclient.h>
#include <mmddk.h>
#include <dsound.h>
#include <dsconf.h>
#include <dsdriver.h>
#include <vfwmsgs.h>
#include <wine/debug.h>
#include <wine/list.h>
Include dependency graph for dsound_private.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  DirectSoundDevice
 
struct  BufferMemory
 
struct  IDirectSoundBufferImpl
 
struct  DirectSoundCaptureDevice
 
struct  IDirectSoundCaptureBufferImpl
 
struct  IDirectSound3DListenerImpl
 
struct  IKsBufferPropertySetImpl
 
struct  IDirectSound3DBufferImpl
 

Macros

#define WIN32_NO_STATUS
 
#define _INC_WINDOWS
 
#define COM_NO_WINDOWS_H
 
#define COBJMACROS
 
#define NONAMELESSSTRUCT
 
#define NONAMELESSUNION
 
#define DS_TIME_RES   2 /* Resolution of multimedia timer */
 
#define DS_TIME_DEL   10 /* Delay of multimedia timer callback, and duration of HEL fragment */
 
#define DS_HW_ACCEL_FULL   0 /* default on Windows 98 */
 
#define DS_HW_ACCEL_STANDARD   1 /* default on Windows 2000 */
 
#define DS_HW_ACCEL_BASIC   2
 
#define DS_HW_ACCEL_EMULATION   3
 
#define STATE_STOPPED   0
 
#define STATE_STARTING   1
 
#define STATE_PLAYING   2
 
#define STATE_CAPTURING   2
 
#define STATE_STOPPING   3
 
#define DSOUND_FREQSHIFT   (20)
 

Typedefs

typedef struct IDirectSoundImpl IDirectSoundImpl
 
typedef struct IDirectSound_IUnknown IDirectSound_IUnknown
 
typedef struct IDirectSound_IDirectSound IDirectSound_IDirectSound
 
typedef struct IDirectSound8_IUnknown IDirectSound8_IUnknown
 
typedef struct IDirectSound8_IDirectSound IDirectSound8_IDirectSound
 
typedef struct IDirectSound8_IDirectSound8 IDirectSound8_IDirectSound8
 
typedef struct IDirectSoundBufferImpl IDirectSoundBufferImpl
 
typedef struct IDirectSoundCaptureImpl IDirectSoundCaptureImpl
 
typedef struct IDirectSoundCaptureBufferImpl IDirectSoundCaptureBufferImpl
 
typedef struct IDirectSoundNotifyImpl IDirectSoundNotifyImpl
 
typedef struct IDirectSoundCaptureNotifyImpl IDirectSoundCaptureNotifyImpl
 
typedef struct IDirectSound3DListenerImpl IDirectSound3DListenerImpl
 
typedef struct IDirectSound3DBufferImpl IDirectSound3DBufferImpl
 
typedef struct IKsBufferPropertySetImpl IKsBufferPropertySetImpl
 
typedef struct DirectSoundDevice DirectSoundDevice
 
typedef struct DirectSoundCaptureDevice DirectSoundCaptureDevice
 
typedef void(* bitsconvertfunc) (const void *, void *, UINT, UINT, INT, UINT, UINT)
 
typedef void(* mixfunc) (const void *, void *, unsigned)
 
typedef void(* normfunc) (const void *, void *, unsigned)
 
typedef struct BufferMemory BufferMemory
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (dsound)
 
ULONG DirectSoundDevice_Release (DirectSoundDevice *device) DECLSPEC_HIDDEN
 
HRESULT DirectSoundDevice_Initialize (DirectSoundDevice **ppDevice, LPCGUID lpcGUID) DECLSPEC_HIDDEN
 
HRESULT DirectSoundDevice_AddBuffer (DirectSoundDevice *device, IDirectSoundBufferImpl *pDSB) DECLSPEC_HIDDEN
 
HRESULT DirectSoundDevice_RemoveBuffer (DirectSoundDevice *device, IDirectSoundBufferImpl *pDSB) DECLSPEC_HIDDEN
 
HRESULT DirectSoundDevice_GetCaps (DirectSoundDevice *device, LPDSCAPS lpDSCaps) DECLSPEC_HIDDEN
 
HRESULT DirectSoundDevice_CreateSoundBuffer (DirectSoundDevice *device, LPCDSBUFFERDESC dsbd, LPLPDIRECTSOUNDBUFFER ppdsb, LPUNKNOWN lpunk, BOOL from8) DECLSPEC_HIDDEN
 
HRESULT DirectSoundDevice_DuplicateSoundBuffer (DirectSoundDevice *device, LPDIRECTSOUNDBUFFER psb, LPLPDIRECTSOUNDBUFFER ppdsb) DECLSPEC_HIDDEN
 
HRESULT DirectSoundDevice_SetCooperativeLevel (DirectSoundDevice *devcie, HWND hwnd, DWORD level) DECLSPEC_HIDDEN
 
HRESULT DirectSoundDevice_Compact (DirectSoundDevice *device) DECLSPEC_HIDDEN
 
HRESULT DirectSoundDevice_GetSpeakerConfig (DirectSoundDevice *device, LPDWORD lpdwSpeakerConfig) DECLSPEC_HIDDEN
 
HRESULT DirectSoundDevice_SetSpeakerConfig (DirectSoundDevice *device, DWORD config) DECLSPEC_HIDDEN
 
HRESULT DirectSoundDevice_VerifyCertification (DirectSoundDevice *device, LPDWORD pdwCertified) DECLSPEC_HIDDEN
 
HRESULT IDirectSoundBufferImpl_Create (DirectSoundDevice *device, IDirectSoundBufferImpl **ppdsb, LPCDSBUFFERDESC dsbd) DECLSPEC_HIDDEN
 
HRESULT IDirectSoundBufferImpl_Destroy (IDirectSoundBufferImpl *pdsb) DECLSPEC_HIDDEN
 
HRESULT IDirectSoundBufferImpl_Duplicate (DirectSoundDevice *device, IDirectSoundBufferImpl **ppdsb, IDirectSoundBufferImpl *pdsb) DECLSPEC_HIDDEN
 
void secondarybuffer_destroy (IDirectSoundBufferImpl *This) DECLSPEC_HIDDEN
 
HRESULT IDirectSound3DListenerImpl_Create (DirectSoundDevice *device, IDirectSound3DListenerImpl **pdsl) DECLSPEC_HIDDEN
 
HRESULT IKsBufferPropertySetImpl_Create (IDirectSoundBufferImpl *dsb, IKsBufferPropertySetImpl **piks) DECLSPEC_HIDDEN
 
HRESULT IKsBufferPropertySetImpl_Destroy (IKsBufferPropertySetImpl *piks) DECLSPEC_HIDDEN
 
HRESULT IKsPrivatePropertySetImpl_Create (REFIID riid, IKsPropertySet **piks) DECLSPEC_HIDDEN
 
HRESULT IDirectSound3DBufferImpl_Create (IDirectSoundBufferImpl *dsb, IDirectSound3DBufferImpl **pds3db) DECLSPEC_HIDDEN
 
HRESULT IDirectSound3DBufferImpl_Destroy (IDirectSound3DBufferImpl *pds3db) DECLSPEC_HIDDEN
 
HRESULT DSOUND_Create (REFIID riid, LPDIRECTSOUND *ppDS) DECLSPEC_HIDDEN
 
HRESULT DSOUND_Create8 (REFIID riid, LPDIRECTSOUND8 *ppDS) DECLSPEC_HIDDEN
 
DWORD DSOUND_fraglen (DWORD nSamplesPerSec, DWORD nBlockAlign) DECLSPEC_HIDDEN
 
HRESULT DSOUND_PrimaryCreate (DirectSoundDevice *device) DECLSPEC_HIDDEN
 
HRESULT DSOUND_PrimaryDestroy (DirectSoundDevice *device) DECLSPEC_HIDDEN
 
HRESULT DSOUND_PrimaryPlay (DirectSoundDevice *device) DECLSPEC_HIDDEN
 
HRESULT DSOUND_PrimaryStop (DirectSoundDevice *device) DECLSPEC_HIDDEN
 
HRESULT DSOUND_PrimaryGetPosition (DirectSoundDevice *device, LPDWORD playpos, LPDWORD writepos) DECLSPEC_HIDDEN
 
LPWAVEFORMATEX DSOUND_CopyFormat (LPCWAVEFORMATEX wfex) DECLSPEC_HIDDEN
 
HRESULT DSOUND_ReopenDevice (DirectSoundDevice *device, BOOL forcewave) DECLSPEC_HIDDEN
 
HRESULT primarybuffer_create (DirectSoundDevice *device, IDirectSoundBufferImpl **ppdsb, const DSBUFFERDESC *dsbd) DECLSPEC_HIDDEN
 
void primarybuffer_destroy (IDirectSoundBufferImpl *This) DECLSPEC_HIDDEN
 
HRESULT primarybuffer_SetFormat (DirectSoundDevice *device, LPCWAVEFORMATEX wfex) DECLSPEC_HIDDEN
 
HRESULT DSOUND_FullDuplexCreate (REFIID riid, LPDIRECTSOUNDFULLDUPLEX *ppDSFD) DECLSPEC_HIDDEN
 
DWORD DSOUND_bufpos_to_mixpos (const DirectSoundDevice *device, DWORD pos) DECLSPEC_HIDDEN
 
void DSOUND_CheckEvent (const IDirectSoundBufferImpl *dsb, DWORD playpos, int len) DECLSPEC_HIDDEN
 
void DSOUND_RecalcVolPan (PDSVOLUMEPAN volpan) DECLSPEC_HIDDEN
 
void DSOUND_AmpFactorToVolPan (PDSVOLUMEPAN volpan) DECLSPEC_HIDDEN
 
void DSOUND_RecalcFormat (IDirectSoundBufferImpl *dsb) DECLSPEC_HIDDEN
 
void DSOUND_MixToTemporary (const IDirectSoundBufferImpl *dsb, DWORD writepos, DWORD mixlen, BOOL inmixer) DECLSPEC_HIDDEN
 
DWORD DSOUND_secpos_to_bufpos (const IDirectSoundBufferImpl *dsb, DWORD secpos, DWORD secmixpos, DWORD *overshot) DECLSPEC_HIDDEN
 
void CALLBACK DSOUND_timer (UINT timerID, UINT msg, DWORD_PTR dwUser, DWORD_PTR dw1, DWORD_PTR dw2) DECLSPEC_HIDDEN
 
void CALLBACK DSOUND_callback (HWAVEOUT hwo, UINT msg, DWORD_PTR dwUser, DWORD_PTR dw1, DWORD_PTR dw2) DECLSPEC_HIDDEN
 
void DSOUND_Calc3DBuffer (IDirectSoundBufferImpl *dsb) DECLSPEC_HIDDEN
 
HRESULT DSOUND_CaptureCreate (REFIID riid, LPDIRECTSOUNDCAPTURE *ppDSC) DECLSPEC_HIDDEN
 
HRESULT DSOUND_CaptureCreate8 (REFIID riid, LPDIRECTSOUNDCAPTURE8 *ppDSC8) DECLSPEC_HIDDEN
 
HRESULT mmErr (UINT err) DECLSPEC_HIDDEN
 
void setup_dsound_options (void) DECLSPEC_HIDDEN
 
const chardumpCooperativeLevel (DWORD level) DECLSPEC_HIDDEN
 

Variables

int ds_emuldriver DECLSPEC_HIDDEN
 

Macro Definition Documentation

◆ _INC_WINDOWS

#define _INC_WINDOWS

Definition at line 32 of file dsound_private.h.

◆ COBJMACROS

#define COBJMACROS

Definition at line 35 of file dsound_private.h.

◆ COM_NO_WINDOWS_H

#define COM_NO_WINDOWS_H

Definition at line 33 of file dsound_private.h.

◆ DS_HW_ACCEL_BASIC

#define DS_HW_ACCEL_BASIC   2

Definition at line 64 of file dsound_private.h.

◆ DS_HW_ACCEL_EMULATION

#define DS_HW_ACCEL_EMULATION   3

Definition at line 65 of file dsound_private.h.

◆ DS_HW_ACCEL_FULL

#define DS_HW_ACCEL_FULL   0 /* default on Windows 98 */

Definition at line 62 of file dsound_private.h.

◆ DS_HW_ACCEL_STANDARD

#define DS_HW_ACCEL_STANDARD   1 /* default on Windows 2000 */

Definition at line 63 of file dsound_private.h.

◆ DS_TIME_DEL

#define DS_TIME_DEL   10 /* Delay of multimedia timer callback, and duration of HEL fragment */

Definition at line 59 of file dsound_private.h.

◆ DS_TIME_RES

#define DS_TIME_RES   2 /* Resolution of multimedia timer */

Definition at line 58 of file dsound_private.h.

◆ DSOUND_FREQSHIFT

#define DSOUND_FREQSHIFT   (20)

Definition at line 405 of file dsound_private.h.

◆ NONAMELESSSTRUCT

#define NONAMELESSSTRUCT

Definition at line 36 of file dsound_private.h.

◆ NONAMELESSUNION

#define NONAMELESSUNION

Definition at line 37 of file dsound_private.h.

◆ STATE_CAPTURING

#define STATE_CAPTURING   2

Definition at line 402 of file dsound_private.h.

◆ STATE_PLAYING

#define STATE_PLAYING   2

Definition at line 401 of file dsound_private.h.

◆ STATE_STARTING

#define STATE_STARTING   1

Definition at line 400 of file dsound_private.h.

◆ STATE_STOPPED

#define STATE_STOPPED   0

Definition at line 399 of file dsound_private.h.

◆ STATE_STOPPING

#define STATE_STOPPING   3

Definition at line 403 of file dsound_private.h.

◆ WIN32_NO_STATUS

#define WIN32_NO_STATUS

Definition at line 31 of file dsound_private.h.

Typedef Documentation

◆ bitsconvertfunc

typedef void(* bitsconvertfunc) (const void *, void *, UINT, UINT, INT, UINT, UINT)

Definition at line 97 of file dsound_private.h.

◆ BufferMemory

◆ DirectSoundCaptureDevice

◆ DirectSoundDevice

Definition at line 93 of file dsound_private.h.

◆ IDirectSound3DBufferImpl

◆ IDirectSound3DListenerImpl

◆ IDirectSound8_IDirectSound

◆ IDirectSound8_IDirectSound8

◆ IDirectSound8_IUnknown

◆ IDirectSound_IDirectSound

◆ IDirectSound_IUnknown

◆ IDirectSoundBufferImpl

◆ IDirectSoundCaptureBufferImpl

◆ IDirectSoundCaptureImpl

◆ IDirectSoundCaptureNotifyImpl

◆ IDirectSoundImpl

Definition at line 79 of file dsound_private.h.

◆ IDirectSoundNotifyImpl

◆ IKsBufferPropertySetImpl

◆ mixfunc

typedef void(* mixfunc) (const void *, void *, unsigned)

Definition at line 99 of file dsound_private.h.

◆ normfunc

typedef void(* normfunc) (const void *, void *, unsigned)

Definition at line 101 of file dsound_private.h.

Function Documentation

◆ DirectSoundDevice_AddBuffer()

HRESULT DirectSoundDevice_AddBuffer ( DirectSoundDevice device,
IDirectSoundBufferImpl pDSB 
)

Definition at line 1761 of file dsound.c.

1764{
1765 IDirectSoundBufferImpl **newbuffers;
1766 HRESULT hr = DS_OK;
1767
1768 TRACE("(%p, %p)\n", device, pDSB);
1769
1770 RtlAcquireResourceExclusive(&(device->buffer_list_lock), TRUE);
1771
1772 if (device->buffers)
1773 newbuffers = HeapReAlloc(GetProcessHeap(),0,device->buffers,sizeof(IDirectSoundBufferImpl*)*(device->nrofbuffers+1));
1774 else
1775 newbuffers = HeapAlloc(GetProcessHeap(),0,sizeof(IDirectSoundBufferImpl*)*(device->nrofbuffers+1));
1776
1777 if (newbuffers) {
1778 device->buffers = newbuffers;
1779 device->buffers[device->nrofbuffers] = pDSB;
1780 device->nrofbuffers++;
1781 TRACE("buffer count is now %d\n", device->nrofbuffers);
1782 } else {
1783 ERR("out of memory for buffer list! Current buffer count is %d\n", device->nrofbuffers);
1785 }
1786
1787 RtlReleaseResource(&(device->buffer_list_lock));
1788
1789 return hr;
1790}
#define ERR(fmt,...)
Definition: precomp.h:57
#define TRUE
Definition: types.h:120
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HeapReAlloc
Definition: compat.h:734
#define DSERR_OUTOFMEMORY
Definition: dsound.h:125
#define DS_OK
Definition: dsound.h:116
NTSYSAPI BOOLEAN NTAPI RtlAcquireResourceExclusive(_In_ PRTL_RESOURCE Resource, _In_ BOOLEAN Wait)
NTSYSAPI VOID NTAPI RtlReleaseResource(_In_ PRTL_RESOURCE Resource)
HRESULT hr
Definition: shlfolder.c:183
#define TRACE(s)
Definition: solgame.cpp:4
Definition: devices.h:37

Referenced by IDirectSoundBufferImpl_Create(), and IDirectSoundBufferImpl_Duplicate().

◆ DirectSoundDevice_Compact()

HRESULT DirectSoundDevice_Compact ( DirectSoundDevice device)

Definition at line 1683 of file dsound.c.

1685{
1686 TRACE("(%p)\n", device);
1687
1688 if (device == NULL) {
1689 WARN("not initialized\n");
1690 return DSERR_UNINITIALIZED;
1691 }
1692
1693 if (device->priolevel < DSSCL_PRIORITY) {
1694 WARN("incorrect priority level\n");
1695 return DSERR_PRIOLEVELNEEDED;
1696 }
1697
1698 return DS_OK;
1699}
#define WARN(fmt,...)
Definition: precomp.h:61
#define NULL
Definition: types.h:112
#define DSERR_UNINITIALIZED
Definition: dsound.h:133
#define DSSCL_PRIORITY
Definition: dsound.h:248
#define DSERR_PRIOLEVELNEEDED
Definition: dsound.h:124

Referenced by IDirectSound8_IDirectSound8_Compact(), IDirectSound8_IDirectSound_Compact(), and IDirectSound_IDirectSound_Compact().

◆ DirectSoundDevice_CreateSoundBuffer()

HRESULT DirectSoundDevice_CreateSoundBuffer ( DirectSoundDevice device,
LPCDSBUFFERDESC  dsbd,
LPLPDIRECTSOUNDBUFFER  ppdsb,
LPUNKNOWN  lpunk,
BOOL  from8 
)

Definition at line 1482 of file dsound.c.

1488{
1489 HRESULT hres = DS_OK;
1490 TRACE("(%p,%p,%p,%p)\n",device,dsbd,ppdsb,lpunk);
1491
1492 if (device == NULL) {
1493 WARN("not initialized\n");
1494 return DSERR_UNINITIALIZED;
1495 }
1496
1497 if (dsbd == NULL) {
1498 WARN("invalid parameter: dsbd == NULL\n");
1499 return DSERR_INVALIDPARAM;
1500 }
1501
1502 if (dsbd->dwSize != sizeof(DSBUFFERDESC) &&
1503 dsbd->dwSize != sizeof(DSBUFFERDESC1)) {
1504 WARN("invalid parameter: dsbd\n");
1505 return DSERR_INVALIDPARAM;
1506 }
1507
1508 if (ppdsb == NULL) {
1509 WARN("invalid parameter: ppdsb == NULL\n");
1510 return DSERR_INVALIDPARAM;
1511 }
1512 *ppdsb = NULL;
1513
1514 if (TRACE_ON(dsound)) {
1515 TRACE("(structsize=%d)\n",dsbd->dwSize);
1516 TRACE("(flags=0x%08x:\n",dsbd->dwFlags);
1517 _dump_DSBCAPS(dsbd->dwFlags);
1518 TRACE(")\n");
1519 TRACE("(bufferbytes=%d)\n",dsbd->dwBufferBytes);
1520 TRACE("(lpwfxFormat=%p)\n",dsbd->lpwfxFormat);
1521 }
1522
1523 if (dsbd->dwFlags & DSBCAPS_PRIMARYBUFFER) {
1524 if (dsbd->lpwfxFormat != NULL) {
1525 WARN("invalid parameter: dsbd->lpwfxFormat must be NULL for "
1526 "primary buffer\n");
1527 return DSERR_INVALIDPARAM;
1528 }
1529
1530 if (device->primary) {
1531 WARN("Primary Buffer already created\n");
1533 *ppdsb = (LPDIRECTSOUNDBUFFER)(device->primary);
1534 } else {
1535 hres = primarybuffer_create(device, &device->primary, dsbd);
1536 if (device->primary) {
1537 *ppdsb = (IDirectSoundBuffer*)&device->primary->IDirectSoundBuffer8_iface;
1538 device->primary->dsbd.dwFlags &= ~(DSBCAPS_LOCHARDWARE | DSBCAPS_LOCSOFTWARE);
1539 if (device->hwbuf)
1540 device->primary->dsbd.dwFlags |= DSBCAPS_LOCHARDWARE;
1541 else
1542 device->primary->dsbd.dwFlags |= DSBCAPS_LOCSOFTWARE;
1543 } else
1544 WARN("primarybuffer_create() failed\n");
1545 }
1546 } else {
1548 WAVEFORMATEXTENSIBLE *pwfxe;
1549
1550 if (dsbd->lpwfxFormat == NULL) {
1551 WARN("invalid parameter: dsbd->lpwfxFormat can't be NULL for "
1552 "secondary buffer\n");
1553 return DSERR_INVALIDPARAM;
1554 }
1555 pwfxe = (WAVEFORMATEXTENSIBLE*)dsbd->lpwfxFormat;
1556
1557 if (pwfxe->Format.wBitsPerSample != 16 && pwfxe->Format.wBitsPerSample != 8 && pwfxe->Format.wFormatTag != WAVE_FORMAT_EXTENSIBLE)
1558 {
1559 WARN("wBitsPerSample=%d needs a WAVEFORMATEXTENSIBLE\n", dsbd->lpwfxFormat->wBitsPerSample);
1560 return DSERR_CONTROLUNAVAIL;
1561 }
1563 {
1564 /* check if cbSize is at least 22 bytes */
1565 if (pwfxe->Format.cbSize < (sizeof(WAVEFORMATEXTENSIBLE) - sizeof(WAVEFORMATEX)))
1566 {
1567 WARN("Too small a cbSize %u\n", pwfxe->Format.cbSize);
1568 return DSERR_INVALIDPARAM;
1569 }
1570
1571 /* cbSize should be 22 bytes, with one possible exception */
1572 if (pwfxe->Format.cbSize > (sizeof(WAVEFORMATEXTENSIBLE) - sizeof(WAVEFORMATEX)) &&
1574 pwfxe->Format.cbSize == sizeof(WAVEFORMATEXTENSIBLE)))
1575 {
1576 WARN("Too big a cbSize %u\n", pwfxe->Format.cbSize);
1577 return DSERR_CONTROLUNAVAIL;
1578 }
1579
1581 {
1582 if (!IsEqualGUID(&pwfxe->SubFormat, &GUID_NULL))
1583 FIXME("SubFormat %s not supported right now.\n", debugstr_guid(&pwfxe->SubFormat));
1584 return DSERR_INVALIDPARAM;
1585 }
1587 {
1588 WARN("Samples.wValidBitsPerSample(%d) > Format.wBitsPerSample (%d)\n", pwfxe->Samples.wValidBitsPerSample, pwfxe->Format.wBitsPerSample);
1589 return DSERR_INVALIDPARAM;
1590 }
1592 {
1593 FIXME("Non-packed formats not supported right now: %d/%d\n", pwfxe->Samples.wValidBitsPerSample, dsbd->lpwfxFormat->wBitsPerSample);
1594 return DSERR_CONTROLUNAVAIL;
1595 }
1596 }
1597
1598 TRACE("(formattag=0x%04x,chans=%d,samplerate=%d,"
1599 "bytespersec=%d,blockalign=%d,bitspersamp=%d,cbSize=%d)\n",
1603 dsbd->lpwfxFormat->nBlockAlign,
1605
1606 if (from8 && (dsbd->dwFlags & DSBCAPS_CTRL3D) && (dsbd->lpwfxFormat->nChannels != 1)) {
1607 WARN("invalid parameter: 3D buffer format must be mono\n");
1608 return DSERR_INVALIDPARAM;
1609 }
1610
1612 if (dsb)
1613 *ppdsb = (IDirectSoundBuffer*)&dsb->IDirectSoundBuffer8_iface;
1614 else
1615 WARN("IDirectSoundBufferImpl_Create failed\n");
1616 }
1617
1618 return hres;
1619}
#define FIXME(fmt,...)
Definition: precomp.h:53
HRESULT IDirectSoundBufferImpl_Create(DirectSoundDevice *device, IDirectSoundBufferImpl **pdsb, LPCDSBUFFERDESC dsbd)
Definition: buffer.c:931
static void _dump_DSBCAPS(DWORD xmask)
Definition: dsound.c:131
#define TRACE_ON(x)
Definition: compat.h:75
#define IDirectSoundBuffer_AddRef(p)
Definition: dsound.h:573
struct IDirectSoundBuffer * LPDIRECTSOUNDBUFFER
Definition: dsound.h:76
#define DSERR_CONTROLUNAVAIL
Definition: dsound.h:120
#define DSBCAPS_LOCSOFTWARE
Definition: dsound.h:209
#define DSERR_INVALIDPARAM
Definition: dsound.h:121
#define DSBCAPS_CTRL3D
Definition: dsound.h:210
struct IDirectSoundBuffer8 * LPDIRECTSOUNDBUFFER8
Definition: dsound.h:79
#define DSBCAPS_LOCHARDWARE
Definition: dsound.h:208
#define DSBCAPS_PRIMARYBUFFER
Definition: dsound.h:206
HRESULT primarybuffer_create(DirectSoundDevice *device, IDirectSoundBufferImpl **ppdsb, const DSBUFFERDESC *dsbd) DECLSPEC_HIDDEN
Definition: primary.c:1223
#define debugstr_guid
Definition: kernel32.h:35
#define GUID_NULL
Definition: ks.h:106
#define KSDATAFORMAT_SUBTYPE_PCM
Definition: ksmedia.h:1021
#define WAVE_FORMAT_EXTENSIBLE
Definition: ksmedia.h:651
#define KSDATAFORMAT_SUBTYPE_IEEE_FLOAT
Definition: ksmedia.h:1026
if(dx< 0)
Definition: linetemp.h:194
HRESULT hres
Definition: protocol.c:465
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
IDirectSoundBuffer8 IDirectSoundBuffer8_iface
WAVEFORMATEX Format
Definition: ksmedia.h:638
WORD wValidBitsPerSample
Definition: ksmedia.h:641
union WAVEFORMATEXTENSIBLE::@3023 Samples
WORD wBitsPerSample
Definition: audioclient.idl:45
DWORD dwSize
Definition: dsound.h:288
DWORD dwFlags
Definition: dsound.h:289
DWORD dwBufferBytes
Definition: dsound.h:290
LPWAVEFORMATEX lpwfxFormat
Definition: dsound.h:292
WORD nBlockAlign
Definition: mmreg.h:82
WORD cbSize
Definition: mmreg.h:84
DWORD nAvgBytesPerSec
Definition: mmreg.h:81
DWORD nSamplesPerSec
Definition: mmreg.h:80
WORD nChannels
Definition: mmreg.h:79
WORD wFormatTag
Definition: mmreg.h:78
WORD wBitsPerSample
Definition: mmreg.h:83

Referenced by IDirectSound8_IDirectSound8_CreateSoundBuffer(), IDirectSound8_IDirectSound_CreateSoundBuffer(), and IDirectSound_IDirectSound_CreateSoundBuffer().

◆ DirectSoundDevice_DuplicateSoundBuffer()

HRESULT DirectSoundDevice_DuplicateSoundBuffer ( DirectSoundDevice device,
LPDIRECTSOUNDBUFFER  psb,
LPLPDIRECTSOUNDBUFFER  ppdsb 
)

Definition at line 1621 of file dsound.c.

1625{
1626 HRESULT hres = DS_OK;
1628 TRACE("(%p,%p,%p)\n",device,psb,ppdsb);
1629
1630 if (device == NULL) {
1631 WARN("not initialized\n");
1632 return DSERR_UNINITIALIZED;
1633 }
1634
1635 if (psb == NULL) {
1636 WARN("invalid parameter: psb == NULL\n");
1637 return DSERR_INVALIDPARAM;
1638 }
1639
1640 if (ppdsb == NULL) {
1641 WARN("invalid parameter: ppdsb == NULL\n");
1642 return DSERR_INVALIDPARAM;
1643 }
1644
1645 /* make sure we have a secondary buffer */
1646 if (psb == (IDirectSoundBuffer *)&device->primary->IDirectSoundBuffer8_iface) {
1647 WARN("trying to duplicate primary buffer\n");
1648 *ppdsb = NULL;
1649 return DSERR_INVALIDCALL;
1650 }
1651
1652 /* duplicate the actual buffer implementation */
1654 if (hres == DS_OK)
1655 *ppdsb = (IDirectSoundBuffer*)&dsb->IDirectSoundBuffer8_iface;
1656 else
1657 WARN("IDirectSoundBufferImpl_Duplicate failed\n");
1658
1659 return hres;
1660}
HRESULT IDirectSoundBufferImpl_Duplicate(DirectSoundDevice *device, IDirectSoundBufferImpl **ppdsb, IDirectSoundBufferImpl *pdsb)
Definition: buffer.c:1169
#define DSERR_INVALIDCALL
Definition: dsound.h:122

Referenced by IDirectSound8_IDirectSound8_DuplicateSoundBuffer(), IDirectSound8_IDirectSound_DuplicateSoundBuffer(), and IDirectSound_IDirectSound_DuplicateSoundBuffer().

◆ DirectSoundDevice_GetCaps()

HRESULT DirectSoundDevice_GetCaps ( DirectSoundDevice device,
LPDSCAPS  lpDSCaps 
)

Definition at line 1272 of file dsound.c.

1275{
1276 TRACE("(%p,%p)\n",device,lpDSCaps);
1277
1278 if (device == NULL) {
1279 WARN("not initialized\n");
1280 return DSERR_UNINITIALIZED;
1281 }
1282
1283 if (lpDSCaps == NULL) {
1284 WARN("invalid parameter: lpDSCaps = NULL\n");
1285 return DSERR_INVALIDPARAM;
1286 }
1287
1288 /* check if there is enough room */
1289 if (lpDSCaps->dwSize < sizeof(*lpDSCaps)) {
1290 WARN("invalid parameter: lpDSCaps->dwSize = %d\n", lpDSCaps->dwSize);
1291 return DSERR_INVALIDPARAM;
1292 }
1293
1294 lpDSCaps->dwFlags = device->drvcaps.dwFlags;
1295 if (TRACE_ON(dsound)) {
1296 TRACE("(flags=0x%08x:\n",lpDSCaps->dwFlags);
1297 _dump_DSCAPS(lpDSCaps->dwFlags);
1298 TRACE(")\n");
1299 }
1300 lpDSCaps->dwMinSecondarySampleRate = device->drvcaps.dwMinSecondarySampleRate;
1301 lpDSCaps->dwMaxSecondarySampleRate = device->drvcaps.dwMaxSecondarySampleRate;
1302 lpDSCaps->dwPrimaryBuffers = device->drvcaps.dwPrimaryBuffers;
1303 lpDSCaps->dwMaxHwMixingAllBuffers = device->drvcaps.dwMaxHwMixingAllBuffers;
1304 lpDSCaps->dwMaxHwMixingStaticBuffers = device->drvcaps.dwMaxHwMixingStaticBuffers;
1305 lpDSCaps->dwMaxHwMixingStreamingBuffers = device->drvcaps.dwMaxHwMixingStreamingBuffers;
1306 lpDSCaps->dwFreeHwMixingAllBuffers = device->drvcaps.dwFreeHwMixingAllBuffers;
1307 lpDSCaps->dwFreeHwMixingStaticBuffers = device->drvcaps.dwFreeHwMixingStaticBuffers;
1308 lpDSCaps->dwFreeHwMixingStreamingBuffers = device->drvcaps.dwFreeHwMixingStreamingBuffers;
1309 lpDSCaps->dwMaxHw3DAllBuffers = device->drvcaps.dwMaxHw3DAllBuffers;
1310 lpDSCaps->dwMaxHw3DStaticBuffers = device->drvcaps.dwMaxHw3DStaticBuffers;
1311 lpDSCaps->dwMaxHw3DStreamingBuffers = device->drvcaps.dwMaxHw3DStreamingBuffers;
1312 lpDSCaps->dwFreeHw3DAllBuffers = device->drvcaps.dwFreeHw3DAllBuffers;
1313 lpDSCaps->dwFreeHw3DStaticBuffers = device->drvcaps.dwFreeHw3DStaticBuffers;
1314 lpDSCaps->dwFreeHw3DStreamingBuffers = device->drvcaps.dwFreeHw3DStreamingBuffers;
1315 lpDSCaps->dwTotalHwMemBytes = device->drvcaps.dwTotalHwMemBytes;
1316 lpDSCaps->dwFreeHwMemBytes = device->drvcaps.dwFreeHwMemBytes;
1317 lpDSCaps->dwMaxContigFreeHwMemBytes = device->drvcaps.dwMaxContigFreeHwMemBytes;
1318
1319 /* driver doesn't have these */
1320 lpDSCaps->dwUnlockTransferRateHwBuffers = 4096; /* But we have none... */
1321 lpDSCaps->dwPlayCpuOverheadSwBuffers = 1; /* 1% */
1322
1323 return DS_OK;
1324}
static void _dump_DSCAPS(DWORD xmask)
Definition: dsound.c:105
DWORD dwFlags
Definition: dsound.h:163
DWORD dwMaxContigFreeHwMemBytes
Definition: dsound.h:181
DWORD dwUnlockTransferRateHwBuffers
Definition: dsound.h:182
DWORD dwMaxHwMixingStreamingBuffers
Definition: dsound.h:169
DWORD dwMaxHw3DStreamingBuffers
Definition: dsound.h:175
DWORD dwPrimaryBuffers
Definition: dsound.h:166
DWORD dwMaxSecondarySampleRate
Definition: dsound.h:165
DWORD dwFreeHw3DStreamingBuffers
Definition: dsound.h:178
DWORD dwMaxHw3DStaticBuffers
Definition: dsound.h:174
DWORD dwFreeHw3DStaticBuffers
Definition: dsound.h:177
DWORD dwTotalHwMemBytes
Definition: dsound.h:179
DWORD dwFreeHwMixingStaticBuffers
Definition: dsound.h:171
DWORD dwFreeHwMixingStreamingBuffers
Definition: dsound.h:172
DWORD dwMinSecondarySampleRate
Definition: dsound.h:164
DWORD dwMaxHwMixingAllBuffers
Definition: dsound.h:167
DWORD dwPlayCpuOverheadSwBuffers
Definition: dsound.h:183
DWORD dwMaxHwMixingStaticBuffers
Definition: dsound.h:168
DWORD dwSize
Definition: dsound.h:162
DWORD dwFreeHwMixingAllBuffers
Definition: dsound.h:170
DWORD dwMaxHw3DAllBuffers
Definition: dsound.h:173
DWORD dwFreeHwMemBytes
Definition: dsound.h:180
DWORD dwFreeHw3DAllBuffers
Definition: dsound.h:176

Referenced by IDirectSound8_IDirectSound8_GetCaps(), IDirectSound8_IDirectSound_GetCaps(), and IDirectSound_IDirectSound_GetCaps().

◆ DirectSoundDevice_GetSpeakerConfig()

HRESULT DirectSoundDevice_GetSpeakerConfig ( DirectSoundDevice device,
LPDWORD  lpdwSpeakerConfig 
)

Definition at line 1701 of file dsound.c.

1704{
1705 TRACE("(%p, %p)\n", device, lpdwSpeakerConfig);
1706
1707 if (device == NULL) {
1708 WARN("not initialized\n");
1709 return DSERR_UNINITIALIZED;
1710 }
1711
1712 if (lpdwSpeakerConfig == NULL) {
1713 WARN("invalid parameter: lpdwSpeakerConfig == NULL\n");
1714 return DSERR_INVALIDPARAM;
1715 }
1716
1717 WARN("not fully functional\n");
1718 *lpdwSpeakerConfig = device->speaker_config;
1719 return DS_OK;
1720}

Referenced by IDirectSound8_IDirectSound8_GetSpeakerConfig(), IDirectSound8_IDirectSound_GetSpeakerConfig(), and IDirectSound_IDirectSound_GetSpeakerConfig().

◆ DirectSoundDevice_Initialize()

HRESULT DirectSoundDevice_Initialize ( DirectSoundDevice **  ppDevice,
LPCGUID  lpcGUID 
)

Definition at line 1326 of file dsound.c.

1327{
1328 HRESULT hr = DS_OK;
1329 unsigned wod, wodn;
1330 BOOLEAN found = FALSE;
1331 GUID devGUID;
1332 DirectSoundDevice * device = *ppDevice;
1333 TRACE("(%p,%s)\n",ppDevice,debugstr_guid(lpcGUID));
1334
1335 if (*ppDevice != NULL) {
1336 WARN("already initialized\n");
1338 }
1339
1340 /* Default device? */
1341 if (!lpcGUID || IsEqualGUID(lpcGUID, &GUID_NULL))
1342 lpcGUID = &DSDEVID_DefaultPlayback;
1343
1344 if (GetDeviceID(lpcGUID, &devGUID) != DS_OK) {
1345 WARN("invalid parameter: lpcGUID\n");
1346 return DSERR_INVALIDPARAM;
1347 }
1348
1349 /* Enumerate WINMM audio devices and find the one we want */
1350 wodn = waveOutGetNumDevs();
1351 if (!wodn) {
1352 WARN("no driver\n");
1353 return DSERR_NODRIVER;
1354 }
1355
1356 for (wod=0; wod<wodn; wod++) {
1357 if (IsEqualGUID( &devGUID, &DSOUND_renderer_guids[wod])) {
1358 found = TRUE;
1359 break;
1360 }
1361 }
1362
1363 if (found == FALSE) {
1364 WARN("No device found matching given ID!\n");
1365 return DSERR_NODRIVER;
1366 }
1367
1368 if (DSOUND_renderer[wod]) {
1369 if (IsEqualGUID(&devGUID, &DSOUND_renderer[wod]->guid)) {
1370 device = DSOUND_renderer[wod];
1372 *ppDevice = device;
1373 return DS_OK;
1374 } else {
1375 ERR("device GUID doesn't match\n");
1376 hr = DSERR_GENERIC;
1377 return hr;
1378 }
1379 } else {
1381 if (hr != DS_OK) {
1382 WARN("DirectSoundDevice_Create failed\n");
1383 return hr;
1384 }
1385 }
1386
1387 *ppDevice = device;
1388 device->guid = devGUID;
1389 device->driver = NULL;
1390
1391 device->drvdesc.dnDevNode = wod;
1393 if (FAILED(hr))
1394 {
1395 WARN("DSOUND_ReopenDevice failed: %08x\n", hr);
1396 return hr;
1397 }
1398
1399 if (device->driver) {
1400 /* the driver is now open, so it's now allowed to call GetCaps */
1401 hr = IDsDriver_GetCaps(device->driver,&(device->drvcaps));
1402 if (hr != DS_OK) {
1403 WARN("IDsDriver_GetCaps failed\n");
1404 return hr;
1405 }
1406 } else {
1407 WAVEOUTCAPSA woc;
1408 hr = mmErr(waveOutGetDevCapsA(device->drvdesc.dnDevNode, &woc, sizeof(woc)));
1409 if (hr != DS_OK) {
1410 WARN("waveOutGetDevCaps failed\n");
1411 return hr;
1412 }
1413 ZeroMemory(&device->drvcaps, sizeof(device->drvcaps));
1414 if ((woc.dwFormats & WAVE_FORMAT_1M08) ||
1415 (woc.dwFormats & WAVE_FORMAT_2M08) ||
1416 (woc.dwFormats & WAVE_FORMAT_4M08) ||
1417 (woc.dwFormats & WAVE_FORMAT_48M08) ||
1418 (woc.dwFormats & WAVE_FORMAT_96M08)) {
1419 device->drvcaps.dwFlags |= DSCAPS_PRIMARY8BIT;
1420 device->drvcaps.dwFlags |= DSCAPS_PRIMARYMONO;
1421 }
1422 if ((woc.dwFormats & WAVE_FORMAT_1M16) ||
1423 (woc.dwFormats & WAVE_FORMAT_2M16) ||
1424 (woc.dwFormats & WAVE_FORMAT_4M16) ||
1425 (woc.dwFormats & WAVE_FORMAT_48M16) ||
1426 (woc.dwFormats & WAVE_FORMAT_96M16)) {
1427 device->drvcaps.dwFlags |= DSCAPS_PRIMARY16BIT;
1428 device->drvcaps.dwFlags |= DSCAPS_PRIMARYMONO;
1429 }
1430 if ((woc.dwFormats & WAVE_FORMAT_1S08) ||
1431 (woc.dwFormats & WAVE_FORMAT_2S08) ||
1432 (woc.dwFormats & WAVE_FORMAT_4S08) ||
1433 (woc.dwFormats & WAVE_FORMAT_48S08) ||
1434 (woc.dwFormats & WAVE_FORMAT_96S08)) {
1435 device->drvcaps.dwFlags |= DSCAPS_PRIMARY8BIT;
1436 device->drvcaps.dwFlags |= DSCAPS_PRIMARYSTEREO;
1437 }
1438 if ((woc.dwFormats & WAVE_FORMAT_1S16) ||
1439 (woc.dwFormats & WAVE_FORMAT_2S16) ||
1440 (woc.dwFormats & WAVE_FORMAT_4S16) ||
1441 (woc.dwFormats & WAVE_FORMAT_48S16) ||
1442 (woc.dwFormats & WAVE_FORMAT_96S16)) {
1443 device->drvcaps.dwFlags |= DSCAPS_PRIMARY16BIT;
1444 device->drvcaps.dwFlags |= DSCAPS_PRIMARYSTEREO;
1445 }
1446 if (ds_emuldriver)
1447 device->drvcaps.dwFlags |= DSCAPS_EMULDRIVER;
1448 device->drvcaps.dwMinSecondarySampleRate = DSBFREQUENCY_MIN;
1449 device->drvcaps.dwMaxSecondarySampleRate = DSBFREQUENCY_MAX;
1450 ZeroMemory(&device->volpan, sizeof(device->volpan));
1451 }
1452
1454 if (hr == DS_OK) {
1455 UINT triggertime = DS_TIME_DEL, res = DS_TIME_RES, id;
1456 TIMECAPS time;
1457
1458 DSOUND_renderer[device->drvdesc.dnDevNode] = device;
1459 timeGetDevCaps(&time, sizeof(TIMECAPS));
1460 TRACE("Minimum timer resolution: %u, max timer: %u\n", time.wPeriodMin, time.wPeriodMax);
1461 if (triggertime < time.wPeriodMin)
1462 triggertime = time.wPeriodMin;
1463 if (res < time.wPeriodMin)
1464 res = time.wPeriodMin;
1466 WARN("Could not set minimum resolution, don't expect sound\n");
1467 id = timeSetEvent(triggertime, res, DSOUND_timer, (DWORD_PTR)device, TIME_PERIODIC | TIME_KILL_SYNCHRONOUS);
1468 if (!id)
1469 {
1470 WARN("Timer not created! Retrying without TIME_KILL_SYNCHRONOUS\n");
1472 if (!id) ERR("Could not create timer, sound playback will not occur\n");
1473 }
1474 DSOUND_renderer[device->drvdesc.dnDevNode]->timerID = id;
1475 } else {
1476 WARN("DSOUND_PrimaryCreate failed\n");
1477 }
1478
1479 return hr;
1480}
unsigned char BOOLEAN
#define FALSE
Definition: types.h:117
HRESULT WINAPI GetDeviceID(LPCGUID pGuidSrc, LPGUID pGuidDest)
Definition: dsound.c:53
static HRESULT DirectSoundDevice_Create(DirectSoundDevice **ppDevice)
Definition: dsound.c:1141
static ULONG DirectSoundDevice_AddRef(DirectSoundDevice *device)
Definition: dsound.c:1209
MMRESULT WINAPI timeBeginPeriod(UINT wPeriod)
Definition: time.c:423
MMRESULT WINAPI timeGetDevCaps(LPTIMECAPS lpCaps, UINT wSize)
Definition: time.c:401
MMRESULT WINAPI timeSetEvent(UINT wDelay, UINT wResol, LPTIMECALLBACK lpFunc, DWORD_PTR dwUser, UINT wFlags)
Definition: time.c:360
#define IDsDriver_GetCaps(p, a)
Definition: dsdriver.h:162
#define DSERR_ALREADYINITIALIZED
Definition: dsound.h:129
#define DSBFREQUENCY_MAX
Definition: dsound.h:232
#define DSCAPS_PRIMARY8BIT
Definition: dsound.h:145
#define DSCAPS_PRIMARYMONO
Definition: dsound.h:143
#define DSCAPS_EMULDRIVER
Definition: dsound.h:148
#define DSCAPS_PRIMARY16BIT
Definition: dsound.h:146
#define DSCAPS_PRIMARYSTEREO
Definition: dsound.h:144
#define DSERR_GENERIC
Definition: dsound.h:123
#define DSERR_NODRIVER
Definition: dsound.h:128
#define DSBFREQUENCY_MIN
Definition: dsound.h:231
GUID DSOUND_renderer_guids[MAXWAVEDRIVERS]
Definition: dsound_main.c:41
HRESULT mmErr(UINT err)
Definition: dsound_main.c:44
DirectSoundDevice * DSOUND_renderer[MAXWAVEDRIVERS]
Definition: dsound_main.c:40
int ds_emuldriver
Definition: dsound_main.c:73
HRESULT DSOUND_ReopenDevice(DirectSoundDevice *device, BOOL forcewave) DECLSPEC_HIDDEN
Definition: primary.c:73
#define DS_TIME_RES
void CALLBACK DSOUND_timer(UINT timerID, UINT msg, DWORD_PTR dwUser, DWORD_PTR dw1, DWORD_PTR dw2) DECLSPEC_HIDDEN
Definition: mixer.c:984
#define DS_TIME_DEL
HRESULT DSOUND_PrimaryCreate(DirectSoundDevice *device) DECLSPEC_HIDDEN
Definition: primary.c:304
GLuint res
Definition: glext.h:9613
GLuint id
Definition: glext.h:5910
#define FAILED(hr)
Definition: intsafe.h:51
const GUID * guid
__u16 time
Definition: mkdosfs.c:8
#define WAVE_FORMAT_2S08
Definition: mmsystem.h:211
#define WAVE_FORMAT_1M08
Definition: mmsystem.h:206
#define WAVE_FORMAT_2M08
Definition: mmsystem.h:210
#define TIME_PERIODIC
Definition: mmsystem.h:422
#define WAVE_FORMAT_2M16
Definition: mmsystem.h:212
#define WAVE_FORMAT_4S08
Definition: mmsystem.h:215
#define WAVE_FORMAT_1S08
Definition: mmsystem.h:207
#define WAVE_FORMAT_4M16
Definition: mmsystem.h:216
#define WAVE_FORMAT_1S16
Definition: mmsystem.h:209
#define WAVE_FORMAT_4M08
Definition: mmsystem.h:214
#define WAVE_FORMAT_4S16
Definition: mmsystem.h:217
#define WAVE_FORMAT_1M16
Definition: mmsystem.h:208
#define WAVE_FORMAT_2S16
Definition: mmsystem.h:213
#define TIMERR_NOCANDO
Definition: mmsystem.h:419
unsigned int UINT
Definition: ndis.h:50
uint32_t DWORD_PTR
Definition: typedefs.h:65
#define ZeroMemory
Definition: winbase.h:1737
UINT WINAPI waveOutGetDevCapsA(UINT_PTR uDeviceID, LPWAVEOUTCAPSA lpCaps, UINT uSize)
Definition: winmm.c:2145
UINT WINAPI waveOutGetNumDevs(void)
Definition: winmm.c:2137
#define WAVE_FORMAT_48S16
Definition: winmm_test.h:23
#define WAVE_FORMAT_48M16
Definition: winmm_test.h:22
#define WAVE_FORMAT_96S08
Definition: winmm_test.h:25
#define WAVE_FORMAT_96M16
Definition: winmm_test.h:26
#define WAVE_FORMAT_96S16
Definition: winmm_test.h:27
#define WAVE_FORMAT_48M08
Definition: winmm_test.h:20
#define WAVE_FORMAT_48S08
Definition: winmm_test.h:21
#define WAVE_FORMAT_96M08
Definition: winmm_test.h:24

Referenced by IDirectSound8_IDirectSound8_Initialize(), IDirectSound8_IDirectSound_Initialize(), and IDirectSound_IDirectSound_Initialize().

◆ DirectSoundDevice_Release()

ULONG DirectSoundDevice_Release ( DirectSoundDevice device)

Definition at line 1216 of file dsound.c.

1217{
1218 HRESULT hr;
1220 TRACE("(%p) ref was %u\n", device, ref + 1);
1221 if (!ref) {
1222 int i;
1223 timeKillEvent(device->timerID);
1225
1226 /* The kill event should have allowed the timer process to expire
1227 * but try to grab the lock just in case. Can't hold lock because
1228 * IDirectSoundBufferImpl_Destroy also grabs the lock */
1229 RtlAcquireResourceShared(&(device->buffer_list_lock), TRUE);
1230 RtlReleaseResource(&(device->buffer_list_lock));
1231
1232 /* It is allowed to release this object even when buffers are playing */
1233 if (device->buffers) {
1234 WARN("%d secondary buffers not released\n", device->nrofbuffers);
1235 for( i=0;i<device->nrofbuffers;i++)
1237 }
1238
1239 if (device->primary) {
1240 WARN("primary buffer not released\n");
1242 }
1243
1245 if (hr != DS_OK)
1246 WARN("DSOUND_PrimaryDestroy failed\n");
1247
1248 if (device->driver)
1249 IDsDriver_Close(device->driver);
1250
1251 if (device->drvdesc.dwFlags & DSDDESC_DOMMSYSTEMOPEN)
1252 waveOutClose(device->hwo);
1253
1254 if (device->driver)
1255 IDsDriver_Release(device->driver);
1256
1257 DSOUND_renderer[device->drvdesc.dnDevNode] = NULL;
1258
1259 HeapFree(GetProcessHeap(), 0, device->tmp_buffer);
1260 HeapFree(GetProcessHeap(), 0, device->mix_buffer);
1261 if (device->drvdesc.dwFlags & DSDDESC_USESYSTEMMEMORY)
1262 HeapFree(GetProcessHeap(), 0, device->buffer);
1263 RtlDeleteResource(&device->buffer_list_lock);
1264 device->mixlock.DebugInfo->Spare[0] = 0;
1265 DeleteCriticalSection(&device->mixlock);
1267 TRACE("(%p) released\n", device);
1268 }
1269 return ref;
1270}
#define InterlockedDecrement
Definition: armddk.h:52
HRESULT IDirectSoundBufferImpl_Destroy(IDirectSoundBufferImpl *pdsb)
Definition: buffer.c:1137
#define HeapFree(x, y, z)
Definition: compat.h:735
MMRESULT WINAPI timeKillEvent(UINT wID)
Definition: time.c:370
MMRESULT WINAPI timeEndPeriod(UINT wPeriod)
Definition: time.c:446
#define IDsDriver_Close(p)
Definition: dsdriver.h:161
#define DSDDESC_DOMMSYSTEMOPEN
Definition: dsdriver.h:50
#define DSDDESC_USESYSTEMMEMORY
Definition: dsdriver.h:52
#define IDsDriver_Release(p)
Definition: dsdriver.h:157
#define IDirectSoundBuffer8_Release(p)
Definition: dsound.h:660
HRESULT DSOUND_PrimaryDestroy(DirectSoundDevice *device) DECLSPEC_HIDDEN
Definition: primary.c:321
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
NTSYSAPI BOOLEAN NTAPI RtlAcquireResourceShared(_In_ PRTL_RESOURCE Resource, _In_ BOOLEAN Wait)
NTSYSAPI VOID NTAPI RtlDeleteResource(_In_ PRTL_RESOURCE Resource)
Definition: send.c:48
uint32_t ULONG
Definition: typedefs.h:59
void WINAPI DeleteCriticalSection(PCRITICAL_SECTION)
UINT WINAPI waveOutClose(HWAVEOUT hWaveOut)
Definition: winmm.c:2257

Referenced by IDirectSoundImpl_Release().

◆ DirectSoundDevice_RemoveBuffer()

HRESULT DirectSoundDevice_RemoveBuffer ( DirectSoundDevice device,
IDirectSoundBufferImpl pDSB 
)

Definition at line 1796 of file dsound.c.

1799{
1800 int i;
1801 HRESULT hr = DS_OK;
1802
1803 TRACE("(%p, %p)\n", device, pDSB);
1804
1805 RtlAcquireResourceExclusive(&(device->buffer_list_lock), TRUE);
1806
1807 for (i = 0; i < device->nrofbuffers; i++)
1808 if (device->buffers[i] == pDSB)
1809 break;
1810
1811 if (i < device->nrofbuffers) {
1812 /* Put the last buffer of the list in the (now empty) position */
1813 device->buffers[i] = device->buffers[device->nrofbuffers - 1];
1814 device->nrofbuffers--;
1815 device->buffers = HeapReAlloc(GetProcessHeap(),0,device->buffers,sizeof(LPDIRECTSOUNDBUFFER8)*device->nrofbuffers);
1816 TRACE("buffer count is now %d\n", device->nrofbuffers);
1817 }
1818
1819 if (device->nrofbuffers == 0) {
1820 HeapFree(GetProcessHeap(),0,device->buffers);
1821 device->buffers = NULL;
1822 }
1823
1824 RtlReleaseResource(&(device->buffer_list_lock));
1825
1826 return hr;
1827}

Referenced by secondarybuffer_destroy().

◆ DirectSoundDevice_SetCooperativeLevel()

HRESULT DirectSoundDevice_SetCooperativeLevel ( DirectSoundDevice devcie,
HWND  hwnd,
DWORD  level 
)

Definition at line 1662 of file dsound.c.

1666{
1667 TRACE("(%p,%p,%s)\n",device,hwnd,dumpCooperativeLevel(level));
1668
1669 if (device == NULL) {
1670 WARN("not initialized\n");
1671 return DSERR_UNINITIALIZED;
1672 }
1673
1675 WARN("level=%s not fully supported\n",
1676 level==DSSCL_PRIORITY ? "DSSCL_PRIORITY" : "DSSCL_EXCLUSIVE");
1677 }
1678
1679 device->priolevel = level;
1680 return DS_OK;
1681}
const char * dumpCooperativeLevel(DWORD level)
Definition: dsound.c:92
#define DSSCL_EXCLUSIVE
Definition: dsound.h:249
GLint level
Definition: gl.h:1546
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023

Referenced by IDirectSound8_IDirectSound8_SetCooperativeLevel(), IDirectSound8_IDirectSound_SetCooperativeLevel(), and IDirectSound_IDirectSound_SetCooperativeLevel().

◆ DirectSoundDevice_SetSpeakerConfig()

HRESULT DirectSoundDevice_SetSpeakerConfig ( DirectSoundDevice device,
DWORD  config 
)

Definition at line 1722 of file dsound.c.

1725{
1726 TRACE("(%p,0x%08x)\n",device,config);
1727
1728 if (device == NULL) {
1729 WARN("not initialized\n");
1730 return DSERR_UNINITIALIZED;
1731 }
1732
1733 device->speaker_config = config;
1734 WARN("not fully functional\n");
1735 return DS_OK;
1736}
struct config_s config

Referenced by IDirectSound8_IDirectSound8_SetSpeakerConfig(), IDirectSound8_IDirectSound_SetSpeakerConfig(), and IDirectSound_IDirectSound_SetSpeakerConfig().

◆ DirectSoundDevice_VerifyCertification()

HRESULT DirectSoundDevice_VerifyCertification ( DirectSoundDevice device,
LPDWORD  pdwCertified 
)

Definition at line 1738 of file dsound.c.

1741{
1742 TRACE("(%p, %p)\n",device,pdwCertified);
1743
1744 if (device == NULL) {
1745 WARN("not initialized\n");
1746 return DSERR_UNINITIALIZED;
1747 }
1748
1749 if (device->drvcaps.dwFlags & DSCAPS_CERTIFIED)
1750 *pdwCertified = DS_CERTIFIED;
1751 else
1752 *pdwCertified = DS_UNCERTIFIED;
1753
1754 return DS_OK;
1755}
#define DSCAPS_CERTIFIED
Definition: dsound.h:149
#define DS_UNCERTIFIED
Definition: dsound.h:327
#define DS_CERTIFIED
Definition: dsound.h:326

Referenced by IDirectSound8_IDirectSound8_VerifyCertification().

◆ DSOUND_AmpFactorToVolPan()

void DSOUND_AmpFactorToVolPan ( PDSVOLUMEPAN  volpan)

Definition at line 46 of file mixer.c.

47{
48 double left,right;
49 TRACE("(%p)\n",volpan);
50
51 TRACE("left=%x, right=%x\n",volpan->dwTotalLeftAmpFactor,volpan->dwTotalRightAmpFactor);
52 if (volpan->dwTotalLeftAmpFactor==0)
53 left=-10000;
54 else
55 left=600 * log(((double)volpan->dwTotalLeftAmpFactor) / 0xffff) / log(2);
56 if (volpan->dwTotalRightAmpFactor==0)
57 right=-10000;
58 else
59 right=600 * log(((double)volpan->dwTotalRightAmpFactor) / 0xffff) / log(2);
60 if (left<right)
61 {
62 volpan->lVolume=right;
64 }
65 else
66 {
67 volpan->lVolume=left;
69 }
70 if (volpan->lVolume < -10000)
71 volpan->lVolume=-10000;
72 volpan->lPan=right-left;
73 if (volpan->lPan < -10000)
74 volpan->lPan=-10000;
75
76 TRACE("Vol=%d Pan=%d\n", volpan->lVolume, volpan->lPan);
77}
GLdouble GLdouble right
Definition: glext.h:10859
GLint left
Definition: glext.h:7726
#define log(outFile, fmt,...)
Definition: util.h:15
DWORD dwTotalRightAmpFactor
Definition: dsdriver.h:106
DWORD dwVolAmpFactor
Definition: dsdriver.h:108
LONG lVolume
Definition: dsdriver.h:107
DWORD dwTotalLeftAmpFactor
Definition: dsdriver.h:105

Referenced by PrimaryBufferImpl_GetPan(), PrimaryBufferImpl_GetVolume(), PrimaryBufferImpl_SetPan(), and PrimaryBufferImpl_SetVolume().

◆ DSOUND_bufpos_to_mixpos()

DWORD DSOUND_bufpos_to_mixpos ( const DirectSoundDevice device,
DWORD  pos 
)

Convert a primary buffer position to a pointer position for device->mix_buffer device: DirectSoundDevice for which to calculate pos: Primary buffer position to converts Returns: Offset for mix_buffer

Definition at line 84 of file mixer.c.

85{
86 DWORD ret = pos * 32 / device->pwfx->wBitsPerSample;
87 if (device->pwfx->wBitsPerSample == 32)
88 ret *= 2;
89 return ret;
90}
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret

Referenced by DSOUND_MixInBuffer(), DSOUND_PerformMix(), DSOUND_PrimaryOpen(), and primarybuffer_SetFormat().

◆ DSOUND_Calc3DBuffer()

void DSOUND_Calc3DBuffer ( IDirectSoundBufferImpl dsb)

Definition at line 141 of file sound3d.c.

142{
143 /* volume, at which the sound will be played after all calcs. */
144 D3DVALUE lVolume = 0;
145 /* stuff for distance related stuff calc. */
146 D3DVECTOR vDistance;
147 D3DVALUE flDistance = 0;
148 /* panning related stuff */
149 D3DVALUE flAngle;
150 D3DVECTOR vLeft;
151 /* doppler shift related stuff */
152#if 0
153 D3DVALUE flFreq, flBufferVel, flListenerVel;
154#endif
155
156 TRACE("(%p)\n",dsb);
157
158 /* initial buffer volume */
159 lVolume = dsb->ds3db_lVolume;
160
161 switch (dsb->ds3db_ds3db.dwMode)
162 {
163 case DS3DMODE_DISABLE:
164 TRACE("3D processing disabled\n");
165 /* this one is here only to eliminate annoying warning message */
167 break;
168 case DS3DMODE_NORMAL:
169 TRACE("Normal 3D processing mode\n");
170 /* we need to calculate distance between buffer and listener*/
172 flDistance = VectorMagnitude (&vDistance);
173 break;
175 TRACE("Head-relative 3D processing mode\n");
176 /* distance between buffer and listener is same as buffer's position */
177 flDistance = VectorMagnitude (&dsb->ds3db_ds3db.vPosition);
178 break;
179 }
180
181 if (flDistance > dsb->ds3db_ds3db.flMaxDistance)
182 {
183 /* some apps don't want you to hear too distant sounds... */
185 {
188 /* i guess mixing here would be a waste of power */
189 return;
190 }
191 else
192 flDistance = dsb->ds3db_ds3db.flMaxDistance;
193 }
194
195 if (flDistance < dsb->ds3db_ds3db.flMinDistance)
196 flDistance = dsb->ds3db_ds3db.flMinDistance;
197
198 /* attenuation proportional to the distance squared, converted to millibels as in lVolume*/
199 lVolume -= log10(flDistance/dsb->ds3db_ds3db.flMinDistance * flDistance/dsb->ds3db_ds3db.flMinDistance)*1000;
200 TRACE("dist. att: Distance = %f, MinDistance = %f => adjusting volume %d to %f\n", flDistance, dsb->ds3db_ds3db.flMinDistance, dsb->ds3db_lVolume, lVolume);
201
202 /* conning */
203 /* sometimes it happens that vConeOrientation vector = (0,0,0); in this case angle is "nan" and it's useless*/
205 {
206 TRACE("conning: cones not set\n");
207 }
208 else
209 {
210 /* calculate angle */
211 flAngle = AngleBetweenVectorsDeg(&dsb->ds3db_ds3db.vConeOrientation, &vDistance);
212 /* if by any chance it happens that OutsideConeAngle = InsideConeAngle (that means that conning has no effect) */
214 {
215 /* my test show that for my way of calc., we need only half of angles */
216 DWORD dwInsideConeAngle = dsb->ds3db_ds3db.dwInsideConeAngle/2;
217 DWORD dwOutsideConeAngle = dsb->ds3db_ds3db.dwOutsideConeAngle/2;
218 if (dwOutsideConeAngle == dwInsideConeAngle)
219 ++dwOutsideConeAngle;
220
221 /* full volume */
222 if (flAngle < dwInsideConeAngle)
223 flAngle = dwInsideConeAngle;
224 /* min (app defined) volume */
225 if (flAngle > dwOutsideConeAngle)
226 flAngle = dwOutsideConeAngle;
227 /* this probably isn't the right thing, but it's ok for the time being */
228 lVolume += ((dsb->ds3db_ds3db.lConeOutsideVolume)/((dwOutsideConeAngle) - (dwInsideConeAngle))) * flAngle;
229 }
230 TRACE("conning: Angle = %f deg; InsideConeAngle(/2) = %d deg; OutsideConeAngle(/2) = %d deg; ConeOutsideVolume = %d => adjusting volume to %f\n",
232 }
233 dsb->volpan.lVolume = lVolume;
234
235 /* panning */
236 if (dsb->device->ds3dl.vPosition.x == dsb->ds3db_ds3db.vPosition.x &&
237 dsb->device->ds3dl.vPosition.y == dsb->ds3db_ds3db.vPosition.y &&
238 dsb->device->ds3dl.vPosition.z == dsb->ds3db_ds3db.vPosition.z) {
239 dsb->volpan.lPan = 0;
240 flAngle = 0.0;
241 }
242 else
243 {
246 flAngle = AngleBetweenVectorsRad(&vLeft, &vDistance);
247 /* for now, we'll use "linear formula" (which is probably incorrect); if someone has it in book, correct it */
248 dsb->volpan.lPan = 10000*2*flAngle/M_PI - 10000;
249 }
250 TRACE("panning: Angle = %f rad, lPan = %d\n", flAngle, dsb->volpan.lPan);
251
252 /* FIXME: Doppler Effect disabled since i have no idea which frequency to change and how to do it */
253#if 0
254 /* doppler shift*/
255 if ((VectorMagnitude(&ds3db_ds3db.vVelocity) == 0) && (VectorMagnitude(&dsb->device->ds3dl.vVelocity) == 0))
256 {
257 TRACE("doppler: Buffer and Listener don't have velocities\n");
258 }
259 else if (ds3db_ds3db.vVelocity != dsb->device->ds3dl.vVelocity)
260 {
261 /* calculate length of ds3db_ds3db.vVelocity component which causes Doppler Effect
262 NOTE: if buffer moves TOWARDS the listener, it's velocity component is NEGATIVE
263 if buffer moves AWAY from listener, it's velocity component is POSITIVE */
264 flBufferVel = ProjectVector(&dsb->ds3db_ds3db.vVelocity, &vDistance);
265 /* calculate length of ds3dl.vVelocity component which causes Doppler Effect
266 NOTE: if listener moves TOWARDS the buffer, it's velocity component is POSITIVE
267 if listener moves AWAY from buffer, it's velocity component is NEGATIVE */
268 flListenerVel = ProjectVector(&dsb->device->ds3dl.vVelocity, &vDistance);
269 /* formula taken from Gianicoli D.: Physics, 4th edition: */
270 /* FIXME: replace dsb->freq with appropriate frequency ! */
271 flFreq = dsb->freq * ((DEFAULT_VELOCITY + flListenerVel)/(DEFAULT_VELOCITY + flBufferVel));
272 TRACE("doppler: Buffer velocity (component) = %lf, Listener velocity (component) = %lf => Doppler shift: %ld Hz -> %lf Hz\n", flBufferVel, flListenerVel,
273 dsb->freq, flFreq);
274 /* FIXME: replace following line with correct frequency setting ! */
275 dsb->freq = flFreq;
277 DSOUND_MixToTemporary(dsb, 0, dsb->buflen);
278 }
279#endif
280
281 /* time for remix */
283}
float D3DVALUE
Definition: d3dtypes.h:89
#define DSBCAPS_MUTE3DATMAXDISTANCE
Definition: dsound.h:221
#define DS3DMODE_HEADRELATIVE
Definition: dsound.h:911
#define DS3DMODE_DISABLE
Definition: dsound.h:912
#define DSBVOLUME_MIN
Definition: dsound.h:230
#define DS3DMODE_NORMAL
Definition: dsound.h:910
void DSOUND_MixToTemporary(const IDirectSoundBufferImpl *dsb, DWORD writepos, DWORD mixlen, BOOL inmixer) DECLSPEC_HIDDEN
Definition: mixer.c:332
void DSOUND_RecalcVolPan(PDSVOLUMEPAN volpan) DECLSPEC_HIDDEN
Definition: mixer.c:27
void DSOUND_RecalcFormat(IDirectSoundBufferImpl *dsb) DECLSPEC_HIDDEN
Definition: mixer.c:162
double log10(double x)
Definition: freeldr.c:122
#define M_PI
Definition: macros.h:263
static D3DVALUE AngleBetweenVectorsDeg(const D3DVECTOR *a, const D3DVECTOR *b)
Definition: sound3d.c:107
static D3DVALUE AngleBetweenVectorsRad(const D3DVECTOR *a, const D3DVECTOR *b)
Definition: sound3d.c:90
static D3DVECTOR VectorBetweenTwoPoints(const D3DVECTOR *a, const D3DVECTOR *b)
Definition: sound3d.c:113
static D3DVECTOR VectorProduct(const D3DVECTOR *a, const D3DVECTOR *b)
Definition: sound3d.c:60
#define DEFAULT_VELOCITY
Definition: sound3d.c:43
static D3DVALUE VectorMagnitude(const D3DVECTOR *a)
Definition: sound3d.c:72
static D3DVALUE ProjectVector(const D3DVECTOR *a, const D3DVECTOR *p)
Definition: sound3d.c:126
DS3DLISTENER ds3dl
DirectSoundDevice * device
DWORD dwInsideConeAngle
Definition: dsound.h:1029
D3DVECTOR vConeOrientation
Definition: dsound.h:1031
DWORD dwOutsideConeAngle
Definition: dsound.h:1030
DWORD dwMode
Definition: dsound.h:1035
D3DVECTOR vPosition
Definition: dsound.h:1027
D3DVECTOR vVelocity
Definition: dsound.h:1028
LONG lConeOutsideVolume
Definition: dsound.h:1032
D3DVALUE flMinDistance
Definition: dsound.h:1033
D3DVALUE flMaxDistance
Definition: dsound.h:1034
D3DVECTOR vOrientTop
Definition: dsound.h:943
D3DVECTOR vVelocity
Definition: dsound.h:941
D3DVECTOR vPosition
Definition: dsound.h:940
D3DVECTOR vOrientFront
Definition: dsound.h:942

Referenced by DSOUND_Mix3DBuffer(), IDirectSoundBufferImpl_Create(), and IDirectSoundBufferImpl_SetVolume().

◆ DSOUND_callback()

void CALLBACK DSOUND_callback ( HWAVEOUT  hwo,
UINT  msg,
DWORD_PTR  dwUser,
DWORD_PTR  dw1,
DWORD_PTR  dw2 
)

Definition at line 1011 of file mixer.c.

1012{
1014 TRACE("(%p,%x,%lx,%lx,%lx)\n",hwo,msg,dwUser,dw1,dw2);
1015 TRACE("entering at %d, msg=%08x(%s)\n", GetTickCount(), msg,
1016 msg==MM_WOM_DONE ? "MM_WOM_DONE" : msg==MM_WOM_CLOSE ? "MM_WOM_CLOSE" :
1017 msg==MM_WOM_OPEN ? "MM_WOM_OPEN" : "UNKNOWN");
1018
1019 /* check if packet completed from wave driver */
1020 if (msg == MM_WOM_DONE) {
1021
1022 /* **** */
1023 EnterCriticalSection(&(device->mixlock));
1024
1025 TRACE("done playing primary pos=%d\n", device->pwplay * device->fraglen);
1026
1027 /* update playpos */
1028 device->pwplay++;
1029 device->pwplay %= device->helfrags;
1030
1031 /* sanity */
1032 if(device->pwqueue == 0){
1033 ERR("Wave queue corrupted!\n");
1034 }
1035
1036 /* update queue */
1037 device->pwqueue--;
1038
1039 LeaveCriticalSection(&(device->mixlock));
1040 /* **** */
1041 }
1042 TRACE("completed\n");
1043}
#define msg(x)
Definition: auth_time.c:54
DWORD WINAPI GetTickCount(VOID)
Definition: time.c:455
#define MM_WOM_CLOSE
Definition: mmsystem.h:57
#define MM_WOM_OPEN
Definition: mmsystem.h:56
#define MM_WOM_DONE
Definition: mmsystem.h:58
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)

Referenced by DSOUND_ReopenDevice().

◆ DSOUND_CaptureCreate()

HRESULT DSOUND_CaptureCreate ( REFIID  riid,
LPDIRECTSOUNDCAPTURE ppDSC 
)

Definition at line 1336 of file capture.c.

1339{
1341 HRESULT hr;
1342 TRACE("(%s, %p)\n", debugstr_guid(riid), ppDSC);
1343
1344 if (!IsEqualIID(riid, &IID_IUnknown) &&
1345 !IsEqualIID(riid, &IID_IDirectSoundCapture)) {
1346 *ppDSC = 0;
1347 return E_NOINTERFACE;
1348 }
1349
1350 /* Get dsound configuration */
1352
1354 if (hr == DS_OK) {
1356 *ppDSC = pDSC;
1357 } else {
1358 WARN("IDirectSoundCaptureImpl_Create failed\n");
1359 *ppDSC = 0;
1360 }
1361
1362 return hr;
1363}
const GUID IID_IUnknown
static HRESULT IDirectSoundCaptureImpl_Create(LPDIRECTSOUNDCAPTURE8 *ppDSC)
Definition: capture.c:1313
struct IDirectSoundCapture * LPDIRECTSOUNDCAPTURE
Definition: dsound.h:92
#define IDirectSoundCapture_AddRef(p)
Definition: dsound.h:735
void setup_dsound_options(void)
Definition: dsound_main.c:102
REFIID riid
Definition: atlbase.h:39
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95
#define E_NOINTERFACE
Definition: winerror.h:2364

Referenced by DirectSoundCaptureCreate().

◆ DSOUND_CaptureCreate8()

HRESULT DSOUND_CaptureCreate8 ( REFIID  riid,
LPDIRECTSOUNDCAPTURE8 ppDSC8 
)

Definition at line 1365 of file capture.c.

1368{
1370 HRESULT hr;
1371 TRACE("(%s, %p)\n", debugstr_guid(riid), ppDSC8);
1372
1373 if (!IsEqualIID(riid, &IID_IUnknown) &&
1375 *ppDSC8 = 0;
1376 return E_NOINTERFACE;
1377 }
1378
1379 /* Get dsound configuration */
1381
1383 if (hr == DS_OK) {
1385 *ppDSC8 = pDSC8;
1386 } else {
1387 WARN("IDirectSoundCaptureImpl_Create failed\n");
1388 *ppDSC8 = 0;
1389 }
1390
1391 return hr;
1392}
#define IID_IDirectSoundCapture8
Definition: dsound.h:93
struct IDirectSoundCapture * LPDIRECTSOUNDCAPTURE8
Definition: dsound.h:94

Referenced by DirectSoundCaptureCreate8(), and IDirectSoundFullDuplexImpl_Initialize().

◆ DSOUND_CheckEvent()

void DSOUND_CheckEvent ( const IDirectSoundBufferImpl dsb,
DWORD  playpos,
int  len 
)

Check for application callback requests for when the play position reaches certain points.

The offsets that will be triggered will be those between the recorded "last played" position for the buffer (i.e. dsb->playpos) and "len" bytes beyond that position.

Definition at line 221 of file mixer.c.

222{
223 int i;
226 TRACE("(%p,%d)\n",dsb,len);
227
228 if (dsb->nrofnotifies == 0)
229 return;
230
231 TRACE("(%p) buflen = %d, playpos = %d, len = %d\n",
232 dsb, dsb->buflen, playpos, len);
233 for (i = 0; i < dsb->nrofnotifies ; i++) {
234 event = dsb->notifies + i;
235 offset = event->dwOffset;
236 TRACE("checking %d, position %d, event = %p\n",
237 i, offset, event->hEventNotify);
238 /* DSBPN_OFFSETSTOP has to be the last element. So this is */
239 /* OK. [Inside DirectX, p274] */
240 /* Windows does not seem to enforce this, and some apps rely */
241 /* on that, so we can't stop there. */
242 /* */
243 /* This also means we can't sort the entries by offset, */
244 /* because DSBPN_OFFSETSTOP == -1 */
245 if (offset == DSBPN_OFFSETSTOP) {
246 if (dsb->state == STATE_STOPPED) {
247 SetEvent(event->hEventNotify);
248 TRACE("signalled event %p (%d)\n", event->hEventNotify, i);
249 }
250 continue;
251 }
252 if ((playpos + len) >= dsb->buflen) {
253 if ((offset < ((playpos + len) % dsb->buflen)) ||
254 (offset >= playpos)) {
255 TRACE("signalled event %p (%d)\n", event->hEventNotify, i);
256 SetEvent(event->hEventNotify);
257 }
258 } else {
259 if ((offset >= playpos) && (offset < (playpos + len))) {
260 TRACE("signalled event %p (%d)\n", event->hEventNotify, i);
261 SetEvent(event->hEventNotify);
262 }
263 }
264 }
265}
#define DSBPN_OFFSETSTOP
Definition: dsound.h:876
#define STATE_STOPPED
struct _cl_event * event
Definition: glext.h:7739
GLenum GLsizei len
Definition: glext.h:6722
GLintptr offset
Definition: glext.h:5920
LPDSBPOSITIONNOTIFY notifies
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:733

Referenced by DSOUND_MixInBuffer(), DSOUND_MixToPrimary(), and IDirectSoundBufferImpl_Stop().

◆ DSOUND_CopyFormat()

LPWAVEFORMATEX DSOUND_CopyFormat ( LPCWAVEFORMATEX  wfex)

Definition at line 437 of file primary.c.

438{
441 if (pwfx == NULL) {
442 WARN("out of memory\n");
443 } else if (wfex->wFormatTag != WAVE_FORMAT_PCM) {
444 CopyMemory(pwfx, wfex, size);
445 } else {
446 CopyMemory(pwfx, wfex, sizeof(PCMWAVEFORMAT));
447 pwfx->cbSize=0;
448 if (pwfx->nBlockAlign != pwfx->nChannels * pwfx->wBitsPerSample/8) {
449 WARN("Fixing bad nBlockAlign (%u)\n", pwfx->nBlockAlign);
450 pwfx->nBlockAlign = pwfx->nChannels * pwfx->wBitsPerSample/8;
451 }
452 if (pwfx->nAvgBytesPerSec != pwfx->nSamplesPerSec * pwfx->nBlockAlign) {
453 WARN("Fixing bad nAvgBytesPerSec (%u)\n", pwfx->nAvgBytesPerSec);
454 pwfx->nAvgBytesPerSec = pwfx->nSamplesPerSec * pwfx->nBlockAlign;
455 }
456 }
457 return pwfx;
458}
#define WAVE_FORMAT_PCM
Definition: constants.h:425
GLsizeiptr size
Definition: glext.h:5919
#define CopyMemory
Definition: winbase.h:1735
static DWORD DSOUND_GetFormatSize(LPCWAVEFORMATEX wfex)
Definition: primary.c:429

Referenced by IDirectSoundBufferImpl_Create(), IDirectSoundBufferImpl_Duplicate(), IDirectSoundCaptureBufferImpl_Create(), and primarybuffer_SetFormat().

◆ DSOUND_Create()

HRESULT DSOUND_Create ( REFIID  riid,
LPDIRECTSOUND ppDS 
)

Definition at line 963 of file dsound.c.

966{
967 LPDIRECTSOUND8 pDS;
968 HRESULT hr;
969 TRACE("(%s, %p)\n", debugstr_guid(riid), ppDS);
970
971 if (!IsEqualIID(riid, &IID_IUnknown) &&
972 !IsEqualIID(riid, &IID_IDirectSound)) {
973 *ppDS = 0;
974 return E_NOINTERFACE;
975 }
976
977 /* Get dsound configuration */
979
981 if (hr == DS_OK) {
983 if (*ppDS)
985 else {
986 WARN("IDirectSound_IDirectSound_Create failed\n");
988 }
989 } else {
990 WARN("IDirectSoundImpl_Create failed\n");
991 *ppDS = 0;
992 }
993
994 return hr;
995}
static ULONG WINAPI IDirectSound_IDirectSound_AddRef(LPDIRECTSOUND iface)
Definition: dsound.c:401
static HRESULT IDirectSoundImpl_Create(LPDIRECTSOUND8 *ppds)
Definition: dsound.c:287
static HRESULT IDirectSound_IDirectSound_Create(LPDIRECTSOUND8 pds, LPDIRECTSOUND *ppds)
Definition: dsound.c:515
struct IDirectSound8 * LPDIRECTSOUND8
Definition: dsound.h:73
#define IDirectSound8_Release(p)
Definition: dsound.h:507

Referenced by DirectSoundCreate().

◆ DSOUND_Create8()

HRESULT DSOUND_Create8 ( REFIID  riid,
LPDIRECTSOUND8 ppDS 
)

Definition at line 1050 of file dsound.c.

1053{
1054 LPDIRECTSOUND8 pDS;
1055 HRESULT hr;
1056 TRACE("(%s, %p)\n", debugstr_guid(riid), ppDS);
1057
1058 if (!IsEqualIID(riid, &IID_IUnknown) &&
1059 !IsEqualIID(riid, &IID_IDirectSound) &&
1060 !IsEqualIID(riid, &IID_IDirectSound8)) {
1061 *ppDS = 0;
1062 return E_NOINTERFACE;
1063 }
1064
1065 /* Get dsound configuration */
1067
1069 if (hr == DS_OK) {
1071 if (*ppDS)
1073 else {
1074 WARN("IDirectSound8_IDirectSound8_Create failed\n");
1076 }
1077 } else {
1078 WARN("IDirectSoundImpl_Create failed\n");
1079 *ppDS = 0;
1080 }
1081
1082 return hr;
1083}
static HRESULT IDirectSound8_IDirectSound8_Create(LPDIRECTSOUND8 pds, LPDIRECTSOUND8 *ppds)
Definition: dsound.c:928
static ULONG WINAPI IDirectSound8_IDirectSound8_AddRef(LPDIRECTSOUND8 iface)
Definition: dsound.c:804

Referenced by DirectSoundCreate8(), and IDirectSoundFullDuplexImpl_Initialize().

◆ DSOUND_fraglen()

DWORD DSOUND_fraglen ( DWORD  nSamplesPerSec,
DWORD  nBlockAlign 
)

Calculate how long a fragment length of about 10 ms should be in frames

nSamplesPerSec: Frequency rate in samples per second nBlockAlign: Size of a single blockalign

Returns: Size in bytes of a single fragment

Definition at line 36 of file primary.c.

37{
38 /* Given a timer delay of 10ms, the fragment size is approximately:
39 * fraglen = (nSamplesPerSec * 10 / 1000) * nBlockAlign
40 * ==> fraglen = (nSamplesPerSec / 100) * nBlockSize
41 *
42 * ALSA uses buffers that are powers of 2. Because of this, fraglen
43 * is rounded up to the nearest power of 2:
44 */
45
46 if (nSamplesPerSec <= 12800)
47 return 128 * nBlockAlign;
48
49 if (nSamplesPerSec <= 25600)
50 return 256 * nBlockAlign;
51
52 if (nSamplesPerSec <= 51200)
53 return 512 * nBlockAlign;
54
55 return 1024 * nBlockAlign;
56}

Referenced by DSOUND_RecalcPrimary(), and IDirectSoundCaptureBufferImpl_Start().

◆ DSOUND_FullDuplexCreate()

HRESULT DSOUND_FullDuplexCreate ( REFIID  riid,
LPDIRECTSOUNDFULLDUPLEX ppDSFD 
)

Definition at line 604 of file duplex.c.

607{
609 TRACE("(%s, %p)\n", debugstr_guid(riid), ppDSFD);
610
611 if (ppDSFD == NULL) {
612 WARN("invalid parameter: ppDSFD == NULL\n");
613 return DSERR_INVALIDPARAM;
614 }
615
616 if (!IsEqualIID(riid, &IID_IUnknown) &&
617 !IsEqualIID(riid, &IID_IDirectSoundFullDuplex)) {
618 *ppDSFD = 0;
619 return E_NOINTERFACE;
620 }
621
622 /* Get dsound configuration */
624
627
628 if (This == NULL) {
629 WARN("out of memory\n");
630 *ppDSFD = NULL;
631 return DSERR_OUTOFMEMORY;
632 }
633
634 This->lpVtbl = &dsfdvt;
635 This->ref = 1;
636 This->capture_device = NULL;
637 This->renderer_device = NULL;
638
639 *ppDSFD = (LPDIRECTSOUNDFULLDUPLEX)This;
640
641 return DS_OK;
642}
static const IDirectSoundFullDuplexVtbl dsfdvt
Definition: duplex.c:593
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
struct IDirectSoundFullDuplex * LPDIRECTSOUNDFULLDUPLEX
Definition: dsound.h:103

Referenced by DirectSoundFullDuplexCreate().

◆ DSOUND_MixToTemporary()

void DSOUND_MixToTemporary ( const IDirectSoundBufferImpl dsb,
DWORD  writepos,
DWORD  len,
BOOL  inmixer 
)

Mix at most the given amount of data into the allocated temporary buffer of the given secondary buffer, starting from the dsb's first currently unsampled frame (writepos), translating frequency (pitch), stereo/mono and bits-per-sample so that it is ideal for the primary buffer. Doesn't perform any mixing - this is a straight copy/convert operation.

dsb = the secondary buffer writepos = Starting position of changed buffer len = number of bytes to resample from writepos

NOTE: writepos + len <= buflen. When called by mixer, MixOne makes sure of this.

Definition at line 332 of file mixer.c.

333{
334 INT size;
335 BYTE *ibp, *obp, *obp_begin;
336 INT iAdvance = dsb->pwfx->nBlockAlign;
337 INT oAdvance = dsb->device->pwfx->nBlockAlign;
338 DWORD freqAcc, target_writepos = 0, overshot, maxlen;
339
340 /* We resample only when needed */
341 if ((dsb->tmp_buffer && inmixer) || (!dsb->tmp_buffer && !inmixer) || dsb->resampleinmixer != inmixer)
342 return;
343
344 assert(writepos + len <= dsb->buflen);
345 if (inmixer && writepos + len < dsb->buflen)
346 len += dsb->pwfx->nBlockAlign;
347
348 maxlen = DSOUND_secpos_to_bufpos(dsb, len, 0, NULL);
349
350 ibp = dsb->buffer->memory + writepos;
351 if (!inmixer)
352 obp_begin = dsb->tmp_buffer;
353 else if (dsb->device->tmp_buffer_len < maxlen || !dsb->device->tmp_buffer)
354 {
355 dsb->device->tmp_buffer_len = maxlen;
356 if (dsb->device->tmp_buffer)
357 dsb->device->tmp_buffer = HeapReAlloc(GetProcessHeap(), 0, dsb->device->tmp_buffer, maxlen);
358 else
359 dsb->device->tmp_buffer = HeapAlloc(GetProcessHeap(), 0, maxlen);
360 obp_begin = dsb->device->tmp_buffer;
361 }
362 else
363 obp_begin = dsb->device->tmp_buffer;
364
365 TRACE("(%p, %p)\n", dsb, ibp);
366 size = len / iAdvance;
367
368 /* Check for same sample rate */
369 if (dsb->freq == dsb->device->pwfx->nSamplesPerSec) {
370 TRACE("(%p) Same sample rate %d = primary %d\n", dsb,
371 dsb->freq, dsb->device->pwfx->nSamplesPerSec);
372 obp = obp_begin;
373 if (!inmixer)
374 obp += writepos/iAdvance*oAdvance;
375
376 cp_fields(dsb, ibp, obp, iAdvance, oAdvance, size, 0, 1 << DSOUND_FREQSHIFT);
377 return;
378 }
379
380 /* Mix in different sample rates */
381 TRACE("(%p) Adjusting frequency: %d -> %d\n", dsb, dsb->freq, dsb->device->pwfx->nSamplesPerSec);
382
383 target_writepos = DSOUND_secpos_to_bufpos(dsb, writepos, dsb->sec_mixpos, &freqAcc);
384 overshot = freqAcc >> DSOUND_FREQSHIFT;
385 if (overshot)
386 {
387 if (overshot >= size)
388 return;
389 size -= overshot;
390 writepos += overshot * iAdvance;
391 if (writepos >= dsb->buflen)
392 return;
393 ibp = dsb->buffer->memory + writepos;
394 freqAcc &= (1 << DSOUND_FREQSHIFT) - 1;
395 TRACE("Overshot: %d, freqAcc: %04x\n", overshot, freqAcc);
396 }
397
398 if (!inmixer)
399 obp = obp_begin + target_writepos;
400 else obp = obp_begin;
401
402 /* FIXME: Small problem here when we're overwriting buf_mixpos, it then STILL uses old freqAcc, not sure if it matters or not */
403 cp_fields(dsb, ibp, obp, iAdvance, oAdvance, size, freqAcc, dsb->freqAdjust);
404}
DWORD DSOUND_secpos_to_bufpos(const IDirectSoundBufferImpl *dsb, DWORD secpos, DWORD secmixpos, DWORD *overshot)
Definition: mixer.c:99
static void cp_fields(const IDirectSoundBufferImpl *dsb, const BYTE *ibuf, BYTE *obuf, UINT istride, UINT ostride, UINT count, UINT freqAcc, UINT adj)
Definition: mixer.c:271
#define assert(x)
Definition: debug.h:53
#define DSOUND_FREQSHIFT
PWAVEFORMATEX pwfx
int32_t INT
Definition: typedefs.h:58
unsigned char BYTE
Definition: xxhash.c:193

Referenced by DSOUND_Calc3DBuffer(), DSOUND_MixInBuffer(), IDirectSoundBufferImpl_Duplicate(), IDirectSoundBufferImpl_SetFrequency(), IDirectSoundBufferImpl_Unlock(), and primarybuffer_SetFormat().

◆ DSOUND_PrimaryCreate()

HRESULT DSOUND_PrimaryCreate ( DirectSoundDevice device)

Definition at line 304 of file primary.c.

305{
306 HRESULT err = DS_OK;
307 TRACE("(%p)\n", device);
308
309 device->buflen = ds_hel_buflen;
311
312 if (err != DS_OK) {
313 WARN("DSOUND_PrimaryOpen failed\n");
314 return err;
315 }
316
317 device->state = STATE_STOPPED;
318 return DS_OK;
319}
int ds_hel_buflen
Definition: dsound_main.c:74
#define err(...)
static HRESULT DSOUND_PrimaryOpen(DirectSoundDevice *device)
Definition: primary.c:136

Referenced by DirectSoundDevice_Initialize().

◆ DSOUND_PrimaryDestroy()

HRESULT DSOUND_PrimaryDestroy ( DirectSoundDevice device)

Definition at line 321 of file primary.c.

322{
323 TRACE("(%p)\n", device);
324
325 /* **** */
326 EnterCriticalSection(&(device->mixlock));
327
329 if (device->driver) {
330 if (device->hwbuf) {
331 if (IDsDriverBuffer_Release(device->hwbuf) == 0)
332 device->hwbuf = 0;
333 }
334 } else
335 HeapFree(GetProcessHeap(),0,device->pwave);
336 HeapFree(GetProcessHeap(),0,device->pwfx);
337 device->pwfx=NULL;
338
339 LeaveCriticalSection(&(device->mixlock));
340 /* **** */
341
342 return DS_OK;
343}
#define IDsDriverBuffer_Release(p)
Definition: dsdriver.h:194
static void DSOUND_PrimaryClose(DirectSoundDevice *device)
Definition: primary.c:275

Referenced by DirectSoundDevice_Release().

◆ DSOUND_PrimaryGetPosition()

HRESULT DSOUND_PrimaryGetPosition ( DirectSoundDevice device,
LPDWORD  playpos,
LPDWORD  writepos 
)

Definition at line 402 of file primary.c.

403{
404 TRACE("(%p,%p,%p)\n", device, playpos, writepos);
405
406 if (device->hwbuf) {
407 HRESULT err=IDsDriverBuffer_GetPosition(device->hwbuf,playpos,writepos);
408 if (err != S_OK) {
409 WARN("IDsDriverBuffer_GetPosition failed\n");
410 return err;
411 }
412 } else {
413 TRACE("pwplay=%i, pwqueue=%i\n", device->pwplay, device->pwqueue);
414
415 /* check if playpos was requested */
416 if (playpos)
417 /* use the cached play position */
418 *playpos = device->pwplay * device->fraglen;
419
420 /* check if writepos was requested */
421 if (writepos)
422 /* the writepos is the first non-queued position */
423 *writepos = ((device->pwplay + device->pwqueue) % device->helfrags) * device->fraglen;
424 }
425 TRACE("playpos = %d, writepos = %d (%p, time=%d)\n", playpos?*playpos:-1, writepos?*writepos:-1, device, GetTickCount());
426 return DS_OK;
427}
#define IDsDriverBuffer_GetPosition(p, a, b)
Definition: dsdriver.h:202
#define S_OK
Definition: intsafe.h:52

Referenced by DSOUND_PerformMix(), and PrimaryBufferImpl_GetCurrentPosition().

◆ DSOUND_PrimaryPlay()

HRESULT DSOUND_PrimaryPlay ( DirectSoundDevice device)

Definition at line 345 of file primary.c.

346{
347 HRESULT err = DS_OK;
348 TRACE("(%p)\n", device);
349
350 if (device->hwbuf) {
352 if (err != DS_OK)
353 WARN("IDsDriverBuffer_Play failed\n");
354 } else {
356 if (err != DS_OK)
357 WARN("waveOutRestart failed\n");
358 }
359
360 return err;
361}
#define IDsDriverBuffer_Play(p, a, b, c)
Definition: dsdriver.h:203
#define DSBPLAY_LOOPING
Definition: dsound.h:189
UINT WINAPI waveOutRestart(HWAVEOUT hWaveOut)
Definition: winmm.c:2399

Referenced by DSOUND_PerformMix().

◆ DSOUND_PrimaryStop()

HRESULT DSOUND_PrimaryStop ( DirectSoundDevice device)

Definition at line 363 of file primary.c.

364{
365 HRESULT err = DS_OK;
366 TRACE("(%p)\n", device);
367
368 if (device->hwbuf) {
370 if (err == DSERR_BUFFERLOST) {
373 if (FAILED(err))
374 ERR("DSOUND_ReopenDevice failed\n");
375 else
376 {
378 if (FAILED(err))
379 WARN("DSOUND_PrimaryOpen failed\n");
380 }
381 } else if (err != DS_OK) {
382 WARN("IDsDriverBuffer_Stop failed\n");
383 }
384 } else {
385
386 /* don't call the wave system with the lock set */
387 LeaveCriticalSection(&(device->mixlock));
388 /* **** */
389
390 err = mmErr(waveOutPause(device->hwo));
391
392 /* **** */
393 EnterCriticalSection(&(device->mixlock));
394
395 if (err != DS_OK)
396 WARN("waveOutPause failed\n");
397 }
398
399 return err;
400}
#define IDsDriverBuffer_Stop(p)
Definition: dsdriver.h:204
#define DSERR_BUFFERLOST
Definition: dsound.h:131
HRESULT DSOUND_ReopenDevice(DirectSoundDevice *device, BOOL forcewave)
Definition: primary.c:73
UINT WINAPI waveOutPause(HWAVEOUT hWaveOut)
Definition: winmm.c:2371

Referenced by DSOUND_PerformMix().

◆ DSOUND_RecalcFormat()

void DSOUND_RecalcFormat ( IDirectSoundBufferImpl dsb)

Recalculate the size for temporary buffer, and new writelead Should be called when one of the following things occur:

  • Primary buffer format is changed
  • This buffer format (frequency) is changed

After this, DSOUND_MixToTemporary(dsb, 0, dsb->buflen) should be called to refill the temporary buffer with data.

Definition at line 162 of file mixer.c.

163{
164 BOOL needremix = TRUE, needresample = (dsb->freq != dsb->device->pwfx->nSamplesPerSec);
165 DWORD bAlign = dsb->pwfx->nBlockAlign, pAlign = dsb->device->pwfx->nBlockAlign;
167 BOOL ieee = FALSE;
168
169 TRACE("(%p)\n",dsb);
170
171 pwfxe = (WAVEFORMATEXTENSIBLE *) dsb->pwfx;
172
175 ieee = TRUE;
176
177 /* calculate the 10ms write lead */
178 dsb->writelead = (dsb->freq / 100) * dsb->pwfx->nBlockAlign;
179
180 if ((dsb->pwfx->wBitsPerSample == dsb->device->pwfx->wBitsPerSample) &&
181 (dsb->pwfx->nChannels == dsb->device->pwfx->nChannels) && !needresample && !ieee)
182 needremix = FALSE;
184 dsb->tmp_buffer = NULL;
185 dsb->max_buffer_len = dsb->freqAcc = dsb->freqAccNext = 0;
186 dsb->freqneeded = needresample;
187
188 if (ieee)
189 dsb->convert = convertbpp[4][dsb->device->pwfx->wBitsPerSample/8 - 1];
190 else
191 dsb->convert = convertbpp[dsb->pwfx->wBitsPerSample/8 - 1][dsb->device->pwfx->wBitsPerSample/8 - 1];
192
193 dsb->resampleinmixer = FALSE;
194
195 if (needremix)
196 {
197 if (needresample)
199 else
200 dsb->tmp_buffer_len = dsb->buflen / bAlign * pAlign;
201 dsb->max_buffer_len = dsb->tmp_buffer_len;
202 if ((dsb->max_buffer_len <= dsb->device->buflen || dsb->max_buffer_len < ds_snd_shadow_maxsize * 1024 * 1024) && ds_snd_shadow_maxsize >= 0)
204 if (dsb->tmp_buffer)
205 FillMemory(dsb->tmp_buffer, dsb->tmp_buffer_len, dsb->device->pwfx->wBitsPerSample == 8 ? 128 : 0);
206 else
207 dsb->resampleinmixer = TRUE;
208 }
209 else dsb->max_buffer_len = dsb->tmp_buffer_len = dsb->buflen;
211}
static void DSOUND_RecalcFreqAcc(IDirectSoundBufferImpl *dsb)
Definition: mixer.c:145
const bitsconvertfunc convertbpp[5][4]
int ds_snd_shadow_maxsize
Definition: dsound_main.c:77
#define FillMemory(BUF, SIZ, MASK)
Definition: strucsup.c:31
unsigned int BOOL
Definition: ntddk_ex.h:94
#define WAVE_FORMAT_IEEE_FLOAT
Definition: mmreg.h:97
bitsconvertfunc convert

Referenced by DSOUND_Calc3DBuffer(), IDirectSoundBufferImpl_Create(), IDirectSoundBufferImpl_Duplicate(), IDirectSoundBufferImpl_SetFrequency(), and primarybuffer_SetFormat().

◆ DSOUND_RecalcVolPan()

void DSOUND_RecalcVolPan ( PDSVOLUMEPAN  volpan)

Definition at line 27 of file mixer.c.

28{
29 double temp;
30 TRACE("(%p)\n",volpan);
31
32 TRACE("Vol=%d Pan=%d\n", volpan->lVolume, volpan->lPan);
33 /* the AmpFactors are expressed in 16.16 fixed point */
34 volpan->dwVolAmpFactor = (ULONG) (pow(2.0, volpan->lVolume / 600.0) * 0xffff);
35 /* FIXME: dwPan{Left|Right}AmpFactor */
36
37 /* FIXME: use calculated vol and pan ampfactors */
38 temp = (double) (volpan->lVolume - (volpan->lPan > 0 ? volpan->lPan : 0));
39 volpan->dwTotalLeftAmpFactor = (ULONG) (pow(2.0, temp / 600.0) * 0xffff);
40 temp = (double) (volpan->lVolume + (volpan->lPan < 0 ? volpan->lPan : 0));
41 volpan->dwTotalRightAmpFactor = (ULONG) (pow(2.0, temp / 600.0) * 0xffff);
42
43 TRACE("left = %x, right = %x\n", volpan->dwTotalLeftAmpFactor, volpan->dwTotalRightAmpFactor);
44}
double pow(double x, double y)
Definition: freeldr.c:110
static const char mbstate_t *static wchar_t const char mbstate_t *static const wchar_t int *static double
Definition: string.c:80
static calc_node_t temp
Definition: rpn_ieee.c:38

Referenced by DSOUND_Calc3DBuffer(), IDirectSoundBufferImpl_Create(), IDirectSoundBufferImpl_SetPan(), IDirectSoundBufferImpl_SetVolume(), PrimaryBufferImpl_SetPan(), and PrimaryBufferImpl_SetVolume().

◆ DSOUND_ReopenDevice()

HRESULT DSOUND_ReopenDevice ( DirectSoundDevice device,
BOOL  forcewave 
)

Definition at line 73 of file primary.c.

74{
76 TRACE("(%p, %d)\n", device, forcewave);
77
78 if (device->driver)
79 {
80 IDsDriver_Close(device->driver);
81 if (device->drvdesc.dwFlags & DSDDESC_DOMMSYSTEMOPEN)
82 waveOutClose(device->hwo);
84 device->driver = NULL;
85 device->buffer = NULL;
86 device->hwo = 0;
87 }
88 else if (device->drvdesc.dwFlags & DSDDESC_DOMMSYSTEMOPEN)
89 waveOutClose(device->hwo);
90
91 /* DRV_QUERYDSOUNDIFACE is a "Wine extension" to get the DSound interface */
92 if (ds_hw_accel != DS_HW_ACCEL_EMULATION && !forcewave)
93 waveOutMessage((HWAVEOUT)(DWORD_PTR)device->drvdesc.dnDevNode, DRV_QUERYDSOUNDIFACE, (DWORD_PTR)&device->driver, 0);
94
95 /* Get driver description */
96 if (device->driver) {
97 DWORD wod = device->drvdesc.dnDevNode;
98 hres = IDsDriver_GetDriverDesc(device->driver,&(device->drvdesc));
99 device->drvdesc.dnDevNode = wod;
100 if (FAILED(hres)) {
101 WARN("IDsDriver_GetDriverDesc failed: %08x\n", hres);
102 IDsDriver_Release(device->driver);
103 device->driver = NULL;
104 }
105 }
106
107 /* if no DirectSound interface available, use WINMM API instead */
108 if (!device->driver)
110
111 if (device->drvdesc.dwFlags & DSDDESC_DOMMSYSTEMOPEN)
112 {
114
115 if (device->driver)
117
118 hres = mmErr(waveOutOpen(&(device->hwo), device->drvdesc.dnDevNode, device->pwfx, (DWORD_PTR)DSOUND_callback, (DWORD_PTR)device, flags));
119 if (FAILED(hres)) {
120 WARN("waveOutOpen failed\n");
121 if (device->driver)
122 {
123 IDsDriver_Release(device->driver);
124 device->driver = NULL;
125 }
126 return hres;
127 }
128 }
129
130 if (device->driver)
131 hres = IDsDriver_Open(device->driver);
132
133 return hres;
134}
#define IDsDriver_GetDriverDesc(p, a)
Definition: dsdriver.h:159
#define IDsDriver_Open(p)
Definition: dsdriver.h:160
#define DSDDESC_DOMMSYSTEMSETFORMAT
Definition: dsdriver.h:51
int ds_hw_accel
Definition: dsound_main.c:78
void CALLBACK DSOUND_callback(HWAVEOUT hwo, UINT msg, DWORD_PTR dwUser, DWORD_PTR dw1, DWORD_PTR dw2) DECLSPEC_HIDDEN
Definition: mixer.c:1011
#define DS_HW_ACCEL_EMULATION
GLbitfield flags
Definition: glext.h:7161
#define WAVE_MAPPED
Definition: mmsystem.h:190
#define CALLBACK_FUNCTION
Definition: mmsystem.h:150
#define WAVE_DIRECTSOUND
Definition: mmddk.h:482
MMRESULT WINAPI waveOutOpen(LPHWAVEOUT lphWaveOut, UINT uDeviceID, LPCWAVEFORMATEX lpFormat, DWORD_PTR dwCallback, DWORD_PTR dwInstance, DWORD dwFlags)
Definition: winmm.c:2246
UINT WINAPI waveOutMessage(HWAVEOUT hWaveOut, UINT uMessage, DWORD_PTR dwParam1, DWORD_PTR dwParam2)
Definition: winmm.c:2538

Referenced by DirectSoundDevice_Initialize(), DSOUND_PrimaryOpen(), DSOUND_PrimaryStop(), and primarybuffer_SetFormat().

◆ DSOUND_secpos_to_bufpos()

DWORD DSOUND_secpos_to_bufpos ( const IDirectSoundBufferImpl dsb,
DWORD  secpos,
DWORD  secmixpos,
DWORD overshot 
)

This function converts a 'native' sample pointer to a resampled pointer that fits for primary secmixpos is used to decide which freqAcc is needed overshot tells what the 'actual' secpos is now (optional)

Definition at line 99 of file mixer.c.

100{
101 DWORD64 framelen = secpos / dsb->pwfx->nBlockAlign;
102 DWORD64 freqAdjust = dsb->freqAdjust;
103 DWORD64 acc, freqAcc;
104
105 if (secpos < secmixpos)
106 freqAcc = dsb->freqAccNext;
107 else freqAcc = dsb->freqAcc;
108 acc = (framelen << DSOUND_FREQSHIFT) + (freqAdjust - 1 - freqAcc);
109 acc /= freqAdjust;
110 if (overshot)
111 {
112 DWORD64 oshot = acc * freqAdjust + freqAcc;
113 assert(oshot >= framelen << DSOUND_FREQSHIFT);
114 oshot -= framelen << DSOUND_FREQSHIFT;
115 *overshot = (DWORD)oshot;
116 assert(*overshot < dsb->freqAdjust);
117 }
118 return (DWORD)acc * dsb->device->pwfx->nBlockAlign;
119}
#define DWORD
Definition: nt_native.h:44
uint64_t DWORD64
Definition: typedefs.h:67

Referenced by DSOUND_MixToTemporary(), DSOUND_RecalcFormat(), DSOUND_RecalcFreqAcc(), and IDirectSoundBufferImpl_SetCurrentPosition().

◆ DSOUND_timer()

void CALLBACK DSOUND_timer ( UINT  timerID,
UINT  msg,
DWORD_PTR  dwUser,
DWORD_PTR  dw1,
DWORD_PTR  dw2 
)

Definition at line 984 of file mixer.c.

986{
988 DWORD start_time = GetTickCount();
989 DWORD end_time;
990 TRACE("(%d,%d,0x%lx,0x%lx,0x%lx)\n",timerID,msg,dwUser,dw1,dw2);
991 TRACE("entering at %d\n", start_time);
992
993 if (DSOUND_renderer[device->drvdesc.dnDevNode] != device) {
994 ERR("dsound died without killing us?\n");
995 timeKillEvent(timerID);
997 return;
998 }
999
1000 RtlAcquireResourceShared(&(device->buffer_list_lock), TRUE);
1001
1002 if (device->ref)
1004
1005 RtlReleaseResource(&(device->buffer_list_lock));
1006
1007 end_time = GetTickCount();
1008 TRACE("completed processing at %d, duration = %d\n", end_time, end_time - start_time);
1009}
static void DSOUND_PerformMix(DirectSoundDevice *device)
Definition: mixer.c:787

Referenced by DirectSoundDevice_Initialize().

◆ dumpCooperativeLevel()

const char * dumpCooperativeLevel ( DWORD  level)

Definition at line 92 of file dsound.c.

93{
94#define LE(x) case x: return #x
95 switch (level) {
100 }
101#undef LE
102 return wine_dbg_sprintf("Unknown(%08x)", level);
103}
#define LE(x)
const char * wine_dbg_sprintf(const char *format,...)
Definition: compat.c:296
#define DSSCL_NORMAL
Definition: dsound.h:247
#define DSSCL_WRITEPRIMARY
Definition: dsound.h:250

Referenced by DirectSoundDevice_SetCooperativeLevel(), IDirectSound8_IDirectSound8_SetCooperativeLevel(), IDirectSound8_IDirectSound_SetCooperativeLevel(), IDirectSound_IDirectSound_SetCooperativeLevel(), and IDirectSoundFullDuplex_IDirectSound8_SetCooperativeLevel().

◆ IDirectSound3DBufferImpl_Create()

HRESULT IDirectSound3DBufferImpl_Create ( IDirectSoundBufferImpl dsb,
IDirectSound3DBufferImpl **  pds3db 
)

Definition at line 667 of file sound3d.c.

670{
672 TRACE("(%p,%p)\n",dsb,pds3db);
673
674 ds3db = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(*ds3db));
675
676 if (ds3db == NULL) {
677 WARN("out of memory\n");
678 *pds3db = 0;
679 return DSERR_OUTOFMEMORY;
680 }
681
682 ds3db->ref = 0;
683 ds3db->dsb = dsb;
684 ds3db->lpVtbl = &ds3dbvt;
685
686 ds3db->dsb->ds3db_ds3db.dwSize = sizeof(DS3DBUFFER);
687 ds3db->dsb->ds3db_ds3db.vPosition.x = 0.0;
688 ds3db->dsb->ds3db_ds3db.vPosition.y = 0.0;
689 ds3db->dsb->ds3db_ds3db.vPosition.z = 0.0;
690 ds3db->dsb->ds3db_ds3db.vVelocity.x = 0.0;
691 ds3db->dsb->ds3db_ds3db.vVelocity.y = 0.0;
692 ds3db->dsb->ds3db_ds3db.vVelocity.z = 0.0;
695 ds3db->dsb->ds3db_ds3db.vConeOrientation.x = 0.0;
696 ds3db->dsb->ds3db_ds3db.vConeOrientation.y = 0.0;
697 ds3db->dsb->ds3db_ds3db.vConeOrientation.z = 0.0;
702
703 ds3db->dsb->ds3db_need_recalc = TRUE;
704
705 *pds3db = ds3db;
706 return S_OK;
707}
#define DS3D_DEFAULTCONEANGLE
Definition: dsound.h:934
#define DS3D_DEFAULTMINDISTANCE
Definition: dsound.h:929
#define DS3D_DEFAULTCONEOUTSIDEVOLUME
Definition: dsound.h:936
struct _DS3DBUFFER DS3DBUFFER
#define DS3D_DEFAULTMAXDISTANCE
Definition: dsound.h:930
static const IDirectSound3DBufferVtbl ds3dbvt
Definition: sound3d.c:640
IDirectSoundBufferImpl * dsb
const IDirectSound3DBufferVtbl * lpVtbl
DWORD dwSize
Definition: dsound.h:1026

Referenced by IDirectSoundBufferImpl_QueryInterface().

◆ IDirectSound3DBufferImpl_Destroy()

HRESULT IDirectSound3DBufferImpl_Destroy ( IDirectSound3DBufferImpl pds3db)

Definition at line 709 of file sound3d.c.

711{
712 TRACE("(%p)\n",pds3db);
713
715
716 return S_OK;
717}
struct IDirectSound3DBuffer * LPDIRECTSOUND3DBUFFER
Definition: dsound.h:89
static ULONG WINAPI IDirectSound3DBufferImpl_Release(LPDIRECTSOUND3DBUFFER iface)
Definition: sound3d.c:333

Referenced by IDirectSoundBufferImpl_Destroy().

◆ IDirectSound3DListenerImpl_Create()

HRESULT IDirectSound3DListenerImpl_Create ( DirectSoundDevice device,
IDirectSound3DListenerImpl **  pdsl 
)

Definition at line 1034 of file sound3d.c.

1037{
1039 TRACE("(%p,%p)\n",device,ppdsl);
1040
1041 pdsl = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(*pdsl));
1042
1043 if (pdsl == NULL) {
1044 WARN("out of memory\n");
1045 *ppdsl = 0;
1046 return DSERR_OUTOFMEMORY;
1047 }
1048
1049 pdsl->ref = 0;
1050 pdsl->lpVtbl = &ds3dlvt;
1051
1052 pdsl->device = device;
1053
1054 pdsl->device->ds3dl.dwSize = sizeof(DS3DLISTENER);
1055 pdsl->device->ds3dl.vPosition.x = 0.0;
1056 pdsl->device->ds3dl.vPosition.y = 0.0;
1057 pdsl->device->ds3dl.vPosition.z = 0.0;
1058 pdsl->device->ds3dl.vVelocity.x = 0.0;
1059 pdsl->device->ds3dl.vVelocity.y = 0.0;
1060 pdsl->device->ds3dl.vVelocity.z = 0.0;
1061 pdsl->device->ds3dl.vOrientFront.x = 0.0;
1062 pdsl->device->ds3dl.vOrientFront.y = 0.0;
1063 pdsl->device->ds3dl.vOrientFront.z = 1.0;
1064 pdsl->device->ds3dl.vOrientTop.x = 0.0;
1065 pdsl->device->ds3dl.vOrientTop.y = 1.0;
1066 pdsl->device->ds3dl.vOrientTop.z = 0.0;
1070
1071 pdsl->device->ds3dl_need_recalc = TRUE;
1072
1073 *ppdsl = pdsl;
1074 return S_OK;
1075}
#define DS3D_DEFAULTROLLOFFFACTOR
Definition: dsound.h:923
#define DS3D_DEFAULTDOPPLERFACTOR
Definition: dsound.h:927
struct _DS3DLISTENER DS3DLISTENER
#define DS3D_DEFAULTDISTANCEFACTOR
Definition: dsound.h:919
static const IDirectSound3DListenerVtbl ds3dlvt
Definition: sound3d.c:1010
DirectSoundDevice * device
const IDirectSound3DListenerVtbl * lpVtbl
DWORD dwSize
Definition: dsound.h:939
D3DVALUE flDopplerFactor
Definition: dsound.h:946
D3DVALUE flRolloffFactor
Definition: dsound.h:945
D3DVALUE flDistanceFactor
Definition: dsound.h:944

Referenced by PrimaryBufferImpl_QueryInterface().

◆ IDirectSoundBufferImpl_Create()

HRESULT IDirectSoundBufferImpl_Create ( DirectSoundDevice device,
IDirectSoundBufferImpl **  ppdsb,
LPCDSBUFFERDESC  dsbd 
)

Definition at line 931 of file buffer.c.

935{
937 LPWAVEFORMATEX wfex = dsbd->lpwfxFormat;
938 HRESULT err = DS_OK;
939 DWORD capf = 0;
940 int use_hw;
941 TRACE("(%p,%p,%p)\n",device,pdsb,dsbd);
942
943 if (dsbd->dwBufferBytes < DSBSIZE_MIN || dsbd->dwBufferBytes > DSBSIZE_MAX) {
944 WARN("invalid parameter: dsbd->dwBufferBytes = %d\n", dsbd->dwBufferBytes);
945 *pdsb = NULL;
946 return DSERR_INVALIDPARAM; /* FIXME: which error? */
947 }
948
949 dsb = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(*dsb));
950
951 if (dsb == 0) {
952 WARN("out of memory\n");
953 *pdsb = NULL;
954 return DSERR_OUTOFMEMORY;
955 }
956
957 TRACE("Created buffer at %p\n", dsb);
958
959 dsb->ref = 1;
960 dsb->numIfaces = 1;
961 dsb->device = device;
962 dsb->IDirectSoundBuffer8_iface.lpVtbl = &dsbvt;
963 dsb->iks = NULL;
964
965 /* size depends on version */
966 CopyMemory(&dsb->dsbd, dsbd, dsbd->dwSize);
967
968 dsb->pwfx = DSOUND_CopyFormat(wfex);
969 if (dsb->pwfx == NULL) {
970 HeapFree(GetProcessHeap(),0,dsb);
971 *pdsb = NULL;
972 return DSERR_OUTOFMEMORY;
973 }
974
975 if (dsbd->dwBufferBytes % dsbd->lpwfxFormat->nBlockAlign)
976 dsb->buflen = dsbd->dwBufferBytes +
977 (dsbd->lpwfxFormat->nBlockAlign -
978 (dsbd->dwBufferBytes % dsbd->lpwfxFormat->nBlockAlign));
979 else
980 dsb->buflen = dsbd->dwBufferBytes;
981
982 dsb->freq = dsbd->lpwfxFormat->nSamplesPerSec;
983 dsb->notify = NULL;
984 dsb->notifies = NULL;
985 dsb->nrofnotifies = 0;
986 dsb->hwnotify = 0;
987
988 /* Check necessary hardware mixing capabilities */
989 if (wfex->nChannels==2) capf |= DSCAPS_SECONDARYSTEREO;
990 else capf |= DSCAPS_SECONDARYMONO;
991 if (wfex->wBitsPerSample==16) capf |= DSCAPS_SECONDARY16BIT;
992 else capf |= DSCAPS_SECONDARY8BIT;
993
994 use_hw = !!(dsbd->dwFlags & DSBCAPS_LOCHARDWARE);
995 TRACE("use_hw = %d, capf = 0x%08x, device->drvcaps.dwFlags = 0x%08x\n", use_hw, capf, device->drvcaps.dwFlags);
996 if (use_hw && ((device->drvcaps.dwFlags & capf) != capf || !device->driver))
997 {
998 if (device->driver)
999 WARN("Format not supported for hardware buffer\n");
1000 HeapFree(GetProcessHeap(),0,dsb->pwfx);
1001 HeapFree(GetProcessHeap(),0,dsb);
1002 *pdsb = NULL;
1003 if ((device->drvcaps.dwFlags & capf) != capf)
1004 return DSERR_BADFORMAT;
1005 return DSERR_GENERIC;
1006 }
1007
1008 /* FIXME: check hardware sample rate mixing capabilities */
1009 /* FIXME: check app hints for software/hardware buffer (STATIC, LOCHARDWARE, etc) */
1010 /* FIXME: check whether any hardware buffers are left */
1011 /* FIXME: handle DSDHEAP_CREATEHEAP for hardware buffers */
1012
1013 /* Allocate an empty buffer */
1014 dsb->buffer = HeapAlloc(GetProcessHeap(),0,sizeof(*(dsb->buffer)));
1015 if (dsb->buffer == NULL) {
1016 WARN("out of memory\n");
1017 HeapFree(GetProcessHeap(),0,dsb->pwfx);
1018 HeapFree(GetProcessHeap(),0,dsb);
1019 *pdsb = NULL;
1020 return DSERR_OUTOFMEMORY;
1021 }
1022
1023 /* Allocate system memory for buffer if applicable */
1024 if ((device->drvdesc.dwFlags & DSDDESC_USESYSTEMMEMORY) || !use_hw) {
1025 dsb->buffer->memory = HeapAlloc(GetProcessHeap(),0,dsb->buflen);
1026 if (dsb->buffer->memory == NULL) {
1027 WARN("out of memory\n");
1028 HeapFree(GetProcessHeap(),0,dsb->pwfx);
1029 HeapFree(GetProcessHeap(),0,dsb->buffer);
1030 HeapFree(GetProcessHeap(),0,dsb);
1031 *pdsb = NULL;
1032 return DSERR_OUTOFMEMORY;
1033 }
1034 }
1035
1036 /* Allocate the hardware buffer */
1037 if (use_hw) {
1038 err = IDsDriver_CreateSoundBuffer(device->driver,wfex,dsbd->dwFlags,0,
1039 &(dsb->buflen),&(dsb->buffer->memory),
1040 (LPVOID*)&(dsb->hwbuf));
1041 if (FAILED(err))
1042 {
1043 WARN("Failed to create hardware secondary buffer: %08x\n", err);
1044 if (device->drvdesc.dwFlags & DSDDESC_USESYSTEMMEMORY)
1046 HeapFree(GetProcessHeap(),0,dsb->buffer);
1047 HeapFree(GetProcessHeap(),0,dsb->pwfx);
1048 HeapFree(GetProcessHeap(),0,dsb);
1049 *pdsb = NULL;
1050 return DSERR_GENERIC;
1051 }
1052 }
1053
1054 dsb->buffer->ref = 1;
1055 list_init(&dsb->buffer->buffers);
1056 list_add_head(&dsb->buffer->buffers, &dsb->entry);
1057 FillMemory(dsb->buffer->memory, dsb->buflen, dsbd->lpwfxFormat->wBitsPerSample == 8 ? 128 : 0);
1058
1059 /* It's not necessary to initialize values to zero since */
1060 /* we allocated this structure with HEAP_ZERO_MEMORY... */
1061 dsb->buf_mixpos = dsb->sec_mixpos = 0;
1062 dsb->state = STATE_STOPPED;
1063
1064 dsb->freqAdjust = ((DWORD64)dsb->freq << DSOUND_FREQSHIFT) / device->pwfx->nSamplesPerSec;
1065 dsb->nAvgBytesPerSec = dsb->freq *
1066 dsbd->lpwfxFormat->nBlockAlign;
1067
1068 /* calculate fragment size and write lead */
1070
1071 if (dsb->dsbd.dwFlags & DSBCAPS_CTRL3D) {
1072 dsb->ds3db_ds3db.dwSize = sizeof(DS3DBUFFER);
1073 dsb->ds3db_ds3db.vPosition.x = 0.0;
1074 dsb->ds3db_ds3db.vPosition.y = 0.0;
1075 dsb->ds3db_ds3db.vPosition.z = 0.0;
1076 dsb->ds3db_ds3db.vVelocity.x = 0.0;
1077 dsb->ds3db_ds3db.vVelocity.y = 0.0;
1078 dsb->ds3db_ds3db.vVelocity.z = 0.0;
1081 dsb->ds3db_ds3db.vConeOrientation.x = 0.0;
1082 dsb->ds3db_ds3db.vConeOrientation.y = 0.0;
1083 dsb->ds3db_ds3db.vConeOrientation.z = 0.0;
1088
1089 dsb->ds3db_need_recalc = FALSE;
1091 } else
1092 DSOUND_RecalcVolPan(&(dsb->volpan));
1093
1095
1096 /* register buffer if not primary */
1097 if (!(dsbd->dwFlags & DSBCAPS_PRIMARYBUFFER)) {
1099 if (err != DS_OK) {
1101 HeapFree(GetProcessHeap(),0,dsb->buffer);
1102 RtlDeleteResource(&dsb->lock);
1103 HeapFree(GetProcessHeap(),0,dsb->pwfx);
1104 HeapFree(GetProcessHeap(),0,dsb);
1105 dsb = NULL;
1106 }
1107 }
1108
1109 *pdsb = dsb;
1110 return err;
1111}
static void list_add_head(struct list_entry *head, struct list_entry *entry)
Definition: list.h:76
static void list_init(struct list_entry *head)
Definition: list.h:51
static const IDirectSoundBuffer8Vtbl dsbvt
Definition: buffer.c:903
HRESULT DirectSoundDevice_AddBuffer(DirectSoundDevice *device, IDirectSoundBufferImpl *pDSB)
Definition: dsound.c:1761
#define IDsDriver_CreateSoundBuffer(p, a, b, c, d, e, f)
Definition: dsdriver.h:163
#define DSERR_BADFORMAT
Definition: dsound.h:126
#define DSCAPS_SECONDARYSTEREO
Definition: dsound.h:151
#define DSCAPS_SECONDARYMONO
Definition: dsound.h:150
#define DSCAPS_SECONDARY8BIT
Definition: dsound.h:152
#define DSBSIZE_MAX
Definition: dsound.h:225
#define DSCAPS_SECONDARY16BIT
Definition: dsound.h:153
#define DSBSIZE_MIN
Definition: dsound.h:224
void DSOUND_Calc3DBuffer(IDirectSoundBufferImpl *dsb) DECLSPEC_HIDDEN
Definition: sound3d.c:141
LPWAVEFORMATEX DSOUND_CopyFormat(LPCWAVEFORMATEX wfex) DECLSPEC_HIDDEN
Definition: primary.c:437
NTSYSAPI VOID NTAPI RtlInitializeResource(_In_ PRTL_RESOURCE Resource)
struct list buffers
IDirectSoundNotifyImpl * notify
IKsBufferPropertySetImpl * iks
PIDSDRIVERBUFFER hwbuf
PIDSDRIVERNOTIFY hwnotify

Referenced by DirectSoundDevice_CreateSoundBuffer().

◆ IDirectSoundBufferImpl_Destroy()

HRESULT IDirectSoundBufferImpl_Destroy ( IDirectSoundBufferImpl pdsb)

Definition at line 1137 of file buffer.c.

1139{
1140 TRACE("(%p)\n",pdsb);
1141
1142 /* This keeps the *_Destroy functions from possibly deleting
1143 * this object until it is ready to be deleted */
1145
1146 if (pdsb->iks) {
1147 WARN("iks not NULL\n");
1149 pdsb->iks = NULL;
1150 }
1151
1152 if (pdsb->ds3db) {
1153 WARN("ds3db not NULL\n");
1155 pdsb->ds3db = NULL;
1156 }
1157
1158 if (pdsb->notify) {
1159 WARN("notify not NULL\n");
1161 pdsb->notify = NULL;
1162 }
1163
1165
1166 return S_OK;
1167}
#define InterlockedIncrement
Definition: armddk.h:53
HRESULT IKsBufferPropertySetImpl_Destroy(IKsBufferPropertySetImpl *piks)
Definition: buffer.c:1416
static HRESULT IDirectSoundNotifyImpl_Destroy(IDirectSoundNotifyImpl *pdsn)
Definition: buffer.c:155
void secondarybuffer_destroy(IDirectSoundBufferImpl *This)
Definition: buffer.c:1113
HRESULT IDirectSound3DBufferImpl_Destroy(IDirectSound3DBufferImpl *pds3db) DECLSPEC_HIDDEN
Definition: sound3d.c:709
IDirectSound3DBufferImpl * ds3db

Referenced by DirectSoundDevice_Release().

◆ IDirectSoundBufferImpl_Duplicate()

HRESULT IDirectSoundBufferImpl_Duplicate ( DirectSoundDevice device,
IDirectSoundBufferImpl **  ppdsb,
IDirectSoundBufferImpl pdsb 
)

Definition at line 1169 of file buffer.c.

1173{
1175 HRESULT hres = DS_OK;
1176 TRACE("(%p,%p,%p)\n", device, ppdsb, pdsb);
1177
1178 dsb = HeapAlloc(GetProcessHeap(),0,sizeof(*dsb));
1179 if (dsb == NULL) {
1180 WARN("out of memory\n");
1181 *ppdsb = NULL;
1182 return DSERR_OUTOFMEMORY;
1183 }
1184 CopyMemory(dsb, pdsb, sizeof(*dsb));
1185
1186 dsb->pwfx = DSOUND_CopyFormat(pdsb->pwfx);
1187 if (dsb->pwfx == NULL) {
1188 HeapFree(GetProcessHeap(),0,dsb);
1189 *ppdsb = NULL;
1190 return DSERR_OUTOFMEMORY;
1191 }
1192
1193 if (pdsb->hwbuf) {
1194 TRACE("duplicating hardware buffer\n");
1195
1197 (LPVOID *)&dsb->hwbuf);
1198 if (FAILED(hres)) {
1199 WARN("IDsDriver_DuplicateSoundBuffer failed (%08x)\n", hres);
1200 HeapFree(GetProcessHeap(),0,dsb->pwfx);
1201 HeapFree(GetProcessHeap(),0,dsb);
1202 *ppdsb = NULL;
1203 return hres;
1204 }
1205 }
1206
1207 dsb->buffer->ref++;
1208 list_add_head(&dsb->buffer->buffers, &dsb->entry);
1209 dsb->ref = 1;
1210 dsb->numIfaces = 1;
1211 dsb->state = STATE_STOPPED;
1212 dsb->buf_mixpos = dsb->sec_mixpos = 0;
1213 dsb->notify = NULL;
1214 dsb->notifies = NULL;
1215 dsb->nrofnotifies = 0;
1216 dsb->device = device;
1217 dsb->ds3db = NULL;
1218 dsb->iks = NULL; /* FIXME? */
1219 dsb->tmp_buffer = NULL;
1221 DSOUND_MixToTemporary(dsb, 0, dsb->buflen, FALSE);
1222
1224
1225 /* register buffer */
1227 if (hres != DS_OK) {
1228 RtlDeleteResource(&dsb->lock);
1230 list_remove(&dsb->entry);
1231 dsb->buffer->ref--;
1232 HeapFree(GetProcessHeap(),0,dsb->pwfx);
1233 HeapFree(GetProcessHeap(),0,dsb);
1234 dsb = NULL;
1235 }
1236
1237 *ppdsb = dsb;
1238 return hres;
1239}
static void list_remove(struct list_entry *entry)
Definition: list.h:90
#define IDsDriver_DuplicateSoundBuffer(p, a, b)
Definition: dsdriver.h:164

Referenced by DirectSoundDevice_DuplicateSoundBuffer().

◆ IKsBufferPropertySetImpl_Create()

HRESULT IKsBufferPropertySetImpl_Create ( IDirectSoundBufferImpl dsb,
IKsBufferPropertySetImpl **  piks 
)

Definition at line 1390 of file buffer.c.

1393{
1395 TRACE("(%p,%p)\n",dsb,piks);
1396 *piks = NULL;
1397
1398 iks = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(*iks));
1399 if (iks == 0) {
1400 WARN("out of memory\n");
1401 *piks = NULL;
1402 return DSERR_OUTOFMEMORY;
1403 }
1404
1405 iks->ref = 0;
1406 iks->dsb = dsb;
1407 dsb->iks = iks;
1408 iks->lpVtbl = &iksbvt;
1409
1411
1412 *piks = iks;
1413 return S_OK;
1414}
static const IKsPropertySetVtbl iksbvt
Definition: buffer.c:1381
IDirectSoundBufferImpl * dsb
const IKsPropertySetVtbl * lpVtbl

Referenced by IDirectSoundBufferImpl_QueryInterface().

◆ IKsBufferPropertySetImpl_Destroy()

HRESULT IKsBufferPropertySetImpl_Destroy ( IKsBufferPropertySetImpl piks)

Definition at line 1416 of file buffer.c.

1418{
1419 TRACE("(%p)\n",piks);
1420
1422
1423 return S_OK;
1424}
static ULONG WINAPI IKsBufferPropertySetImpl_Release(LPKSPROPERTYSET iface)
Definition: buffer.c:1265

Referenced by IDirectSoundBufferImpl_Destroy().

◆ IKsPrivatePropertySetImpl_Create()

HRESULT IKsPrivatePropertySetImpl_Create ( REFIID  riid,
IKsPropertySet **  piks 
)

Definition at line 615 of file propset.c.

618{
620 TRACE("(%s, %p)\n", debugstr_guid(riid), piks);
621
622 if (!IsEqualIID(riid, &IID_IUnknown) &&
624 *piks = 0;
625 return E_NOINTERFACE;
626 }
627
628 iks = HeapAlloc(GetProcessHeap(),0,sizeof(*iks));
629 iks->ref = 1;
630 iks->IKsPropertySet_iface.lpVtbl = &ikspvt;
631
632 *piks = &iks->IKsPropertySet_iface;
633 return S_OK;
634}
const GUID IID_IKsPropertySet
Definition: controlnode.cpp:13
static const IKsPropertySetVtbl ikspvt
Definition: propset.c:606
IKsPropertySet IKsPropertySet_iface
Definition: propset.c:26

◆ mmErr()

HRESULT mmErr ( UINT  err)

Definition at line 44 of file dsound_main.c.

45{
46 switch(err) {
48 return DS_OK;
50 return DSERR_ALLOCATED;
51 case MMSYSERR_ERROR:
54 return DSERR_GENERIC; /* FIXME */
57 return DSERR_NODRIVER;
58 case MMSYSERR_NOMEM:
59 return DSERR_OUTOFMEMORY;
63 return DSERR_INVALIDPARAM;
65 return DSERR_UNSUPPORTED;
66 default:
67 FIXME("Unknown MMSYS error %d\n",err);
68 return DSERR_GENERIC;
69 }
70}
#define DSERR_ALLOCATED
Definition: dsound.h:119
#define DSERR_UNSUPPORTED
Definition: dsound.h:127
#define WAVERR_STILLPLAYING
Definition: mmsystem.h:177
#define MMSYSERR_NOMEM
Definition: mmsystem.h:103
#define MMSYSERR_NOTSUPPORTED
Definition: mmsystem.h:104
#define MMSYSERR_NODRIVER
Definition: mmsystem.h:102
#define MMSYSERR_INVALHANDLE
Definition: mmsystem.h:101
#define MMSYSERR_INVALPARAM
Definition: mmsystem.h:107
#define MMSYSERR_NOERROR
Definition: mmsystem.h:96
#define WAVERR_BADFORMAT
Definition: mmsystem.h:176
#define MMSYSERR_ALLOCATED
Definition: mmsystem.h:100
#define MMSYSERR_ERROR
Definition: mmsystem.h:97
#define MMSYSERR_BADDEVICEID
Definition: mmsystem.h:98
#define WAVERR_UNPREPARED
Definition: mmsystem.h:178

Referenced by DirectSoundCaptureDevice_Initialize(), DirectSoundCaptureEnumerateW(), DirectSoundDevice_Initialize(), DirectSoundEnumerateW(), DSOUND_PrimaryOpen(), DSOUND_PrimaryPlay(), DSOUND_PrimaryStop(), DSOUND_ReopenDevice(), IDirectSoundCaptureBufferImpl_Create(), IDirectSoundCaptureBufferImpl_Start(), and IDirectSoundCaptureBufferImpl_Stop().

◆ primarybuffer_create()

HRESULT primarybuffer_create ( DirectSoundDevice device,
IDirectSoundBufferImpl **  ppdsb,
const DSBUFFERDESC dsbd 
)

Definition at line 1223 of file primary.c.

1225{
1227 TRACE("%p,%p,%p)\n",device,ppdsb,dsbd);
1228
1229 if (dsbd->lpwfxFormat) {
1230 WARN("invalid parameter: dsbd->lpwfxFormat != NULL\n");
1231 *ppdsb = NULL;
1232 return DSERR_INVALIDPARAM;
1233 }
1234
1235 dsb = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(*dsb));
1236
1237 if (dsb == NULL) {
1238 WARN("out of memory\n");
1239 *ppdsb = NULL;
1240 return DSERR_OUTOFMEMORY;
1241 }
1242
1243 dsb->ref = 1;
1244 dsb->numIfaces = 1;
1245 dsb->device = device;
1246 dsb->IDirectSoundBuffer8_iface.lpVtbl = (IDirectSoundBuffer8Vtbl *)&dspbvt;
1247 dsb->dsbd = *dsbd;
1248
1249 TRACE("Created primary buffer at %p\n", dsb);
1250 TRACE("(formattag=0x%04x,chans=%d,samplerate=%d,"
1251 "bytespersec=%d,blockalign=%d,bitspersamp=%d,cbSize=%d)\n",
1252 device->pwfx->wFormatTag, device->pwfx->nChannels,
1253 device->pwfx->nSamplesPerSec, device->pwfx->nAvgBytesPerSec,
1254 device->pwfx->nBlockAlign, device->pwfx->wBitsPerSample,
1255 device->pwfx->cbSize);
1256
1257 *ppdsb = dsb;
1258 return S_OK;
1259}
static const IDirectSoundBufferVtbl dspbvt
Definition: primary.c:1198

Referenced by DirectSoundDevice_CreateSoundBuffer().

◆ primarybuffer_destroy()

void primarybuffer_destroy ( IDirectSoundBufferImpl This)

Definition at line 763 of file primary.c.

764{
765 This->device->primary = NULL;
767 TRACE("(%p) released\n", This);
768}

Referenced by IDirectSound3DListenerImpl_Release(), IDirectSoundBufferImpl_Release(), and PrimaryBufferImpl_Release().

◆ primarybuffer_SetFormat()

HRESULT primarybuffer_SetFormat ( DirectSoundDevice device,
LPCWAVEFORMATEX  wfex 
)

Definition at line 460 of file primary.c.

461{
463 int i;
464 DWORD nSamplesPerSec, bpp, chans;
465 LPWAVEFORMATEX oldpwfx;
466 BOOL forced = device->priolevel == DSSCL_WRITEPRIMARY;
467
468 TRACE("(%p,%p)\n", device, wfex);
469
470 if (device->priolevel == DSSCL_NORMAL) {
471 WARN("failed priority check!\n");
473 }
474
475 /* Let's be pedantic! */
476 if (wfex == NULL) {
477 WARN("invalid parameter: wfex==NULL!\n");
478 return DSERR_INVALIDPARAM;
479 }
480 TRACE("(formattag=0x%04x,chans=%d,samplerate=%d,"
481 "bytespersec=%d,blockalign=%d,bitspersamp=%d,cbSize=%d)\n",
482 wfex->wFormatTag, wfex->nChannels, wfex->nSamplesPerSec,
483 wfex->nAvgBytesPerSec, wfex->nBlockAlign,
484 wfex->wBitsPerSample, wfex->cbSize);
485
486 /* **** */
487 RtlAcquireResourceExclusive(&(device->buffer_list_lock), TRUE);
488 EnterCriticalSection(&(device->mixlock));
489
490 nSamplesPerSec = device->pwfx->nSamplesPerSec;
491 bpp = device->pwfx->wBitsPerSample;
492 chans = device->pwfx->nChannels;
493
494 oldpwfx = device->pwfx;
495 device->pwfx = DSOUND_CopyFormat(wfex);
496 if (device->pwfx == NULL) {
497 device->pwfx = oldpwfx;
498 oldpwfx = NULL;
500 goto done;
501 }
502
503 if (!(device->drvdesc.dwFlags & DSDDESC_DOMMSYSTEMSETFORMAT) && device->hwbuf) {
505
506 /* On bad format, try to re-create, big chance it will work then, only do this if we <HAVE> to */
507 if (forced && (device->pwfx->nSamplesPerSec/100 != wfex->nSamplesPerSec/100 || err == DSERR_BADFORMAT))
508 {
509 DWORD cp_size = wfex->wFormatTag == WAVE_FORMAT_PCM ?
510 sizeof(PCMWAVEFORMAT) : sizeof(WAVEFORMATEX) + wfex->cbSize;
512 CopyMemory(device->pwfx, wfex, cp_size);
513 }
514
515 if (err != DSERR_BUFFERLOST && FAILED(err)) {
517 WARN("IDsDriverBuffer_SetFormat failed\n");
518 if (!forced) {
519 CopyMemory(device->pwfx, oldpwfx, size);
520 err = DS_OK;
521 }
522 goto done;
523 }
524
525 if (err == S_FALSE)
526 {
527 /* ALSA specific: S_FALSE tells that recreation was successful,
528 * but size and location may be changed, and buffer has to be restarted
529 * I put it here, so if frequency doesn't match the error will be changed to DSERR_BUFFERLOST
530 * and the entire re-initialization will occur anyway
531 */
532 IDsDriverBuffer_Lock(device->hwbuf, (LPVOID *)&device->buffer, &device->buflen, NULL, NULL, 0, 0, DSBLOCK_ENTIREBUFFER);
533 IDsDriverBuffer_Unlock(device->hwbuf, device->buffer, 0, NULL, 0);
534
535 if (device->state == STATE_PLAYING) device->state = STATE_STARTING;
536 else if (device->state == STATE_STOPPING) device->state = STATE_STOPPED;
537 device->pwplay = device->pwqueue = device->playpos = device->mixpos = 0;
538 err = DS_OK;
539 }
541 }
542
543 if (err == DSERR_BUFFERLOST)
544 {
546
548 if (FAILED(err))
549 {
550 WARN("DSOUND_ReopenDevice failed: %08x\n", err);
551 goto done;
552 }
554 if (err != DS_OK) {
555 WARN("DSOUND_PrimaryOpen failed\n");
556 goto done;
557 }
558
559 if (wfex->nSamplesPerSec/100 != device->pwfx->nSamplesPerSec/100 && forced && device->buffer)
560 {
562 device->pwfx->nSamplesPerSec = wfex->nSamplesPerSec;
564 if (FAILED(err))
565 WARN("DSOUND_ReopenDevice(2) failed: %08x\n", err);
566 else if (FAILED((err = DSOUND_PrimaryOpen(device))))
567 WARN("DSOUND_PrimaryOpen(2) failed: %08x\n", err);
568 }
569 }
570
571 device->mix_buffer_len = DSOUND_bufpos_to_mixpos(device, device->buflen);
572 device->mix_buffer = HeapReAlloc(GetProcessHeap(), 0, device->mix_buffer, device->mix_buffer_len);
573 FillMemory(device->mix_buffer, device->mix_buffer_len, 0);
574 device->mixfunction = mixfunctions[device->pwfx->wBitsPerSample/8 - 1];
575 device->normfunction = normfunctions[device->pwfx->wBitsPerSample/8 - 1];
576
577 if (nSamplesPerSec != device->pwfx->nSamplesPerSec || bpp != device->pwfx->wBitsPerSample || chans != device->pwfx->nChannels) {
578 IDirectSoundBufferImpl** dsb = device->buffers;
579 for (i = 0; i < device->nrofbuffers; i++, dsb++) {
580 /* **** */
581 RtlAcquireResourceExclusive(&(*dsb)->lock, TRUE);
582
583 (*dsb)->freqAdjust = ((DWORD64)(*dsb)->freq << DSOUND_FREQSHIFT) / device->pwfx->nSamplesPerSec;
584 DSOUND_RecalcFormat((*dsb));
585 DSOUND_MixToTemporary((*dsb), 0, (*dsb)->buflen, FALSE);
586 (*dsb)->primary_mixpos = 0;
587
588 RtlReleaseResource(&(*dsb)->lock);
589 /* **** */
590 }
591 }
592
593done:
594 LeaveCriticalSection(&(device->mixlock));
595 RtlReleaseResource(&(device->buffer_list_lock));
596 /* **** */
597
598 HeapFree(GetProcessHeap(), 0, oldpwfx);
599 return err;
600}
DWORD bpp
Definition: surface.c:185
#define IDsDriverBuffer_SetFormat(p, a)
Definition: dsdriver.h:198
#define IDsDriverBuffer_Unlock(p, a, b, c, d)
Definition: dsdriver.h:197
#define IDsDriverBuffer_Lock(p, a, b, c, d, e, f, g)
Definition: dsdriver.h:196
#define DSBLOCK_ENTIREBUFFER
Definition: dsound.h:204
const mixfunc mixfunctions[4]
const normfunc normfunctions[4]
#define STATE_STOPPING
#define STATE_PLAYING
#define STATE_STARTING
DWORD DSOUND_bufpos_to_mixpos(const DirectSoundDevice *device, DWORD pos) DECLSPEC_HIDDEN
Definition: mixer.c:84
struct pcmwaveformat_tag PCMWAVEFORMAT
LPWAVEFORMATEX DSOUND_CopyFormat(LPCWAVEFORMATEX wfex)
Definition: primary.c:437
static void DSOUND_RecalcPrimary(DirectSoundDevice *device)
Definition: primary.c:58
#define S_FALSE
Definition: winerror.h:2357

Referenced by IDirectSoundBufferImpl_SetFormat(), and PrimaryBufferImpl_SetFormat().

◆ secondarybuffer_destroy()

void secondarybuffer_destroy ( IDirectSoundBufferImpl This)

Definition at line 1113 of file buffer.c.

1114{
1116 RtlDeleteResource(&This->lock);
1117
1118 if (This->hwbuf)
1120 if (!This->hwbuf || (This->device->drvdesc.dwFlags & DSDDESC_USESYSTEMMEMORY)) {
1121 This->buffer->ref--;
1122 list_remove(&This->entry);
1123 if (This->buffer->ref == 0) {
1124 HeapFree(GetProcessHeap(), 0, This->buffer->memory);
1125 HeapFree(GetProcessHeap(), 0, This->buffer);
1126 }
1127 }
1128
1129 HeapFree(GetProcessHeap(), 0, This->tmp_buffer);
1130 HeapFree(GetProcessHeap(), 0, This->notifies);
1131 HeapFree(GetProcessHeap(), 0, This->pwfx);
1133
1134 TRACE("(%p) released\n", This);
1135}
HRESULT DirectSoundDevice_RemoveBuffer(DirectSoundDevice *device, IDirectSoundBufferImpl *pDSB)
Definition: dsound.c:1796

Referenced by IDirectSound3DBufferImpl_Release(), IDirectSoundBufferImpl_Destroy(), and IDirectSoundBufferImpl_Release().

◆ setup_dsound_options()

void setup_dsound_options ( void  )

Definition at line 102 of file dsound_main.c.

103{
104 char buffer[MAX_PATH+16];
105 HKEY hkey, appkey = 0;
106 DWORD len;
107
108 buffer[MAX_PATH]='\0';
109
110 /* @@ Wine registry key: HKCU\Software\Wine\DirectSound */
111 if (RegOpenKeyA( HKEY_CURRENT_USER, "Software\\Wine\\DirectSound", &hkey )) hkey = 0;
112
114 if (len && len < MAX_PATH)
115 {
116 HKEY tmpkey;
117 /* @@ Wine registry key: HKCU\Software\Wine\AppDefaults\app.exe\DirectSound */
118 if (!RegOpenKeyA( HKEY_CURRENT_USER, "Software\\Wine\\AppDefaults", &tmpkey ))
119 {
120 char *p, *appname = buffer;
121 if ((p = strrchr( appname, '/' ))) appname = p + 1;
122 if ((p = strrchr( appname, '\\' ))) appname = p + 1;
123 strcat( appname, "\\DirectSound" );
124 TRACE("appname = [%s]\n", appname);
125 if (RegOpenKeyA( tmpkey, appname, &appkey )) appkey = 0;
126 RegCloseKey( tmpkey );
127 }
128 }
129
130 /* get options */
131
132 if (!get_config_key( hkey, appkey, "EmulDriver", buffer, MAX_PATH ))
134
135 if (!get_config_key( hkey, appkey, "HelBuflen", buffer, MAX_PATH ))
137
138 if (!get_config_key( hkey, appkey, "SndQueueMax", buffer, MAX_PATH ))
140
141 if (!get_config_key( hkey, appkey, "SndQueueMin", buffer, MAX_PATH ))
143
144 if (!get_config_key( hkey, appkey, "HardwareAcceleration", buffer, MAX_PATH )) {
145 if (strcmp(buffer, "Full") == 0)
147 else if (strcmp(buffer, "Standard") == 0)
149 else if (strcmp(buffer, "Basic") == 0)
151 else if (strcmp(buffer, "Emulation") == 0)
153 }
154
155 if (!get_config_key( hkey, appkey, "DefaultPlayback", buffer, MAX_PATH ))
157
158 if (!get_config_key( hkey, appkey, "MaxShadowSize", buffer, MAX_PATH ))
160
161 if (!get_config_key( hkey, appkey, "DefaultCapture", buffer, MAX_PATH ))
163
164 if (!get_config_key( hkey, appkey, "DefaultSampleRate", buffer, MAX_PATH ))
166
167 if (!get_config_key( hkey, appkey, "DefaultBitsPerSample", buffer, MAX_PATH ))
169
170 if (appkey) RegCloseKey( appkey );
171 if (hkey) RegCloseKey( hkey );
172
173 TRACE("ds_emuldriver = %d\n", ds_emuldriver);
174 TRACE("ds_hel_buflen = %d\n", ds_hel_buflen);
175 TRACE("ds_snd_queue_max = %d\n", ds_snd_queue_max);
176 TRACE("ds_snd_queue_min = %d\n", ds_snd_queue_min);
177 TRACE("ds_hw_accel = %s\n",
178 ds_hw_accel==DS_HW_ACCEL_FULL ? "Full" :
179 ds_hw_accel==DS_HW_ACCEL_STANDARD ? "Standard" :
180 ds_hw_accel==DS_HW_ACCEL_BASIC ? "Basic" :
181 ds_hw_accel==DS_HW_ACCEL_EMULATION ? "Emulation" :
182 "Unknown");
183 TRACE("ds_default_playback = %d\n", ds_default_playback);
184 TRACE("ds_default_capture = %d\n", ds_default_playback);
185 TRACE("ds_default_sample_rate = %d\n", ds_default_sample_rate);
186 TRACE("ds_default_bits_per_sample = %d\n", ds_default_bits_per_sample);
187 TRACE("ds_snd_shadow_maxsize = %d\n", ds_snd_shadow_maxsize);
188}
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
#define RegCloseKey(hKey)
Definition: registry.h:49
LONG WINAPI RegOpenKeyA(HKEY hKey, LPCSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:3234
#define MAX_PATH
Definition: compat.h:34
DWORD WINAPI GetModuleFileNameA(HINSTANCE hModule, LPSTR lpFilename, DWORD nSize)
Definition: loader.c:539
static int ds_default_capture
Definition: dsound_main.c:82
int ds_snd_queue_min
Definition: dsound_main.c:76
int ds_snd_queue_max
Definition: dsound_main.c:75
int ds_default_sample_rate
Definition: dsound_main.c:79
int ds_default_bits_per_sample
Definition: dsound_main.c:80
static DWORD get_config_key(HKEY defkey, HKEY appkey, const char *name, char *buffer, DWORD size)
Definition: dsound_main.c:89
static int ds_default_playback
Definition: dsound_main.c:81
#define DS_HW_ACCEL_FULL
#define DS_HW_ACCEL_STANDARD
#define DS_HW_ACCEL_BASIC
GLuint buffer
Definition: glext.h:5915
GLfloat GLfloat p
Definition: glext.h:8902
_Check_return_ int __cdecl atoi(_In_z_ const char *_Str)
_CRT_RESTORE_GCC_WARNINGS _CRT_DISABLE_GCC_WARNINGS _Check_return_ _CRTIMP _CONST_RETURN char *__cdecl strrchr(_In_z_ const char *_Str, _In_ int _Ch)
#define HKEY_CURRENT_USER
Definition: winreg.h:11

Referenced by DirectSoundCaptureEnumerateW(), DirectSoundEnumerateW(), DSOUND_CaptureCreate(), DSOUND_CaptureCreate8(), DSOUND_Create(), DSOUND_Create8(), DSOUND_FullDuplexCreate(), and DSPROPERTY_DescriptionW().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( dsound  )

Variable Documentation

◆ DECLSPEC_HIDDEN

GUID DSOUND_capture_guids [MAXWAVEDRIVERS] DECLSPEC_HIDDEN
extern

Definition at line 68 of file dsound_private.h.