ReactOS 0.4.16-dev-297-gc569aee
primary.c File Reference
#include "precomp.h"
Include dependency graph for primary.c:

Go to the source code of this file.

Classes

struct  CDirectSoundBuffer
 

Typedefs

typedef struct CDirectSoundBufferLPCDirectSoundBuffer
 

Functions

HRESULT WINAPI PrimaryDirectSoundBuffer8Impl_fnQueryInterface (LPDIRECTSOUNDBUFFER8 iface, IN REFIID riid, LPVOID *ppobj)
 
ULONG WINAPI PrimaryDirectSoundBuffer8Impl_fnAddRef (LPDIRECTSOUNDBUFFER8 iface)
 
ULONG WINAPI PrimaryDirectSoundBuffer8Impl_fnRelease (LPDIRECTSOUNDBUFFER8 iface)
 
HRESULT WINAPI PrimaryDirectSoundBuffer8Impl_fnGetCaps (LPDIRECTSOUNDBUFFER8 iface, LPDSBCAPS pDSBufferCaps)
 
HRESULT WINAPI PrimaryDirectSoundBuffer8Impl_fnGetCurrentPosition (LPDIRECTSOUNDBUFFER8 iface, LPDWORD pdwCurrentPlayCursor, LPDWORD pdwCurrentWriteCursor)
 
HRESULT WINAPI PrimaryDirectSoundBuffer8Impl_fnGetFormat (LPDIRECTSOUNDBUFFER8 iface, LPWAVEFORMATEX pwfxFormat, DWORD dwSizeAllocated, LPDWORD pdwSizeWritten)
 
HRESULT WINAPI PrimaryDirectSoundBuffer8Impl_fnGetVolume (LPDIRECTSOUNDBUFFER8 iface, LPLONG plVolume)
 
HRESULT WINAPI PrimaryDirectSoundBuffer8Impl_fnGetPan (LPDIRECTSOUNDBUFFER8 iface, LPLONG plPan)
 
HRESULT WINAPI PrimaryDirectSoundBuffer8Impl_fnGetFrequency (LPDIRECTSOUNDBUFFER8 iface, LPDWORD pdwFrequency)
 
HRESULT WINAPI PrimaryDirectSoundBuffer8Impl_fnGetStatus (LPDIRECTSOUNDBUFFER8 iface, LPDWORD pdwStatus)
 
HRESULT WINAPI PrimaryDirectSoundBuffer8Impl_fnInitialize (LPDIRECTSOUNDBUFFER8 iface, LPDIRECTSOUND pDirectSound, LPCDSBUFFERDESC pcDSBufferDesc)
 
HRESULT WINAPI PrimaryDirectSoundBuffer8Impl_fnLock (LPDIRECTSOUNDBUFFER8 iface, DWORD dwOffset, DWORD dwBytes, LPVOID *ppvAudioPtr1, LPDWORD pdwAudioBytes1, LPVOID *ppvAudioPtr2, LPDWORD pdwAudioBytes2, DWORD dwFlags)
 
HRESULT WINAPI PrimaryDirectSoundBuffer8Impl_fnPlay (LPDIRECTSOUNDBUFFER8 iface, DWORD dwReserved1, DWORD dwPriority, DWORD dwFlags)
 
HRESULT WINAPI PrimaryDirectSoundBuffer8Impl_fnSetCurrentPosition (LPDIRECTSOUNDBUFFER8 iface, DWORD dwNewPosition)
 
HRESULT WINAPI PrimaryDirectSoundBuffer8Impl_fnSetFormat (LPDIRECTSOUNDBUFFER8 iface, LPCWAVEFORMATEX pcfxFormat)
 
HRESULT WINAPI PrimaryDirectSoundBuffer8Impl_fnSetVolume (LPDIRECTSOUNDBUFFER8 iface, LONG lVolume)
 
HRESULT WINAPI PrimaryDirectSoundBuffer8Impl_fnSetPan (LPDIRECTSOUNDBUFFER8 iface, LONG lPan)
 
HRESULT WINAPI PrimaryDirectSoundBuffer8Impl_fnSetFrequency (LPDIRECTSOUNDBUFFER8 iface, DWORD dwFrequency)
 
HRESULT WINAPI PrimaryDirectSoundBuffer8Impl_fnStop (LPDIRECTSOUNDBUFFER8 iface)
 
HRESULT WINAPI PrimaryDirectSoundBuffer8Impl_fnUnlock (LPDIRECTSOUNDBUFFER8 iface, LPVOID pvAudioPtr1, DWORD dwAudioBytes1, LPVOID pvAudioPtr2, DWORD dwAudioBytes2)
 
HRESULT WINAPI PrimaryDirectSoundBuffer8Impl_fnRestore (LPDIRECTSOUNDBUFFER8 iface)
 
HRESULT WINAPI PrimaryDirectSoundBuffer8Impl_fnSetFX (LPDIRECTSOUNDBUFFER8 iface, DWORD dwEffectsCount, LPDSEFFECTDESC pDSFXDesc, LPDWORD pdwResultCodes)
 
HRESULT WINAPI PrimaryDirectSoundBuffer8Impl_fnAcquireResources (LPDIRECTSOUNDBUFFER8 iface, DWORD dwFlags, DWORD dwEffectsCount, LPDWORD pdwResultCodes)
 
HRESULT WINAPI PrimaryDirectSoundBuffer8Impl_fnGetObjectInPath (LPDIRECTSOUNDBUFFER8 iface, REFGUID rguidObject, DWORD dwIndex, REFGUID rguidInterface, LPVOID *ppObject)
 
DWORD PrimaryDirectSoundBuffer_Write (LPDIRECTSOUNDBUFFER8 iface, LPVOID Buffer, DWORD BufferSize)
 
VOID PrimaryDirectSoundBuffer_SetState (LPDIRECTSOUNDBUFFER8 iface, KSSTATE State)
 
HRESULT PrimaryDirectSoundBuffer_GetPosition (LPDIRECTSOUNDBUFFER8 iface, LPDWORD pdwCurrentPlayCursor, LPDWORD pdwCurrentWriteCursor)
 
HRESULT PrimaryDirectSoundBuffer_SetFormat (LPDIRECTSOUNDBUFFER8 iface, LPWAVEFORMATEX pcfxFormat, BOOL bLooped)
 
VOID PrimaryDirectSoundBuffer_AcquireLock (LPDIRECTSOUNDBUFFER8 iface)
 
VOID PrimaryDirectSoundBuffer_ReleaseLock (LPDIRECTSOUNDBUFFER8 iface)
 
HRESULT NewPrimarySoundBuffer (LPDIRECTSOUNDBUFFER8 *OutBuffer, LPFILTERINFO Filter, DWORD dwLevel, DWORD dwFlags)
 

Variables

static IDirectSoundBuffer8Vtbl vt_DirectSoundBuffer8
 

Typedef Documentation

◆ LPCDirectSoundBuffer

Function Documentation

◆ NewPrimarySoundBuffer()

HRESULT NewPrimarySoundBuffer ( LPDIRECTSOUNDBUFFER8 OutBuffer,
LPFILTERINFO  Filter,
DWORD  dwLevel,
DWORD  dwFlags 
)

Definition at line 768 of file primary.c.

773{
775
776 if (!This)
777 {
778 /* not enough memory */
779 return DSERR_OUTOFMEMORY;
780 }
781
782 This->ref = 1;
783 This->lpVtbl = &vt_DirectSoundBuffer8;
784 This->Filter = Filter;
785 This->dwLevel = dwLevel;
786 This->dwFlags = dwFlags;
787 This->dwFrequency = 0;
788 This->Volume = DSBVOLUME_MAX;
789 This->VolumePan = DSBPAN_CENTER;
790 This->hPin = NULL;
791
792 /* FIXME: determine default format for audio device */
793 This->Format.cbSize = sizeof(WAVEFORMATEX);
794 This->Format.nChannels = 2;
795 This->Format.nSamplesPerSec = 44100;
796 This->Format.wBitsPerSample = 16;
797 This->Format.wFormatTag = WAVE_FORMAT_PCM;
798 This->Format.nBlockAlign = (This->Format.nChannels * This->Format.wBitsPerSample) / 8;
799 This->Format.nAvgBytesPerSec = (This->Format.nChannels * This->Format.nSamplesPerSec * This->Format.wBitsPerSample) / 8;
800
802
804 return DS_OK;
805}
#define WAVE_FORMAT_PCM
Definition: constants.h:425
#define NULL
Definition: types.h:112
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
#define DSBPAN_CENTER
Definition: dsound.h:227
#define DSERR_OUTOFMEMORY
Definition: dsound.h:125
#define DSBVOLUME_MAX
Definition: dsound.h:229
#define DS_OK
Definition: dsound.h:116
struct IDirectSoundBuffer8 * LPDIRECTSOUNDBUFFER8
Definition: dsound.h:79
static IDirectSoundBuffer8Vtbl vt_DirectSoundBuffer8
Definition: primary.c:555
_Must_inspect_result_ _In_opt_ PFLT_FILTER Filter
Definition: fltkernel.h:1801
_In_ UCHAR _In_ ULONG _Out_ PUCHAR _Outptr_result_bytebuffer_ OutBufferLength PVOID * OutBuffer
Definition: scsi.h:4071
VOID WINAPI InitializeCriticalSection(OUT LPCRITICAL_SECTION lpCriticalSection)
Definition: synch.c:751
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1176

Referenced by IDirectSound8_fnCreateSoundBuffer().

◆ PrimaryDirectSoundBuffer8Impl_fnAcquireResources()

HRESULT WINAPI PrimaryDirectSoundBuffer8Impl_fnAcquireResources ( LPDIRECTSOUNDBUFFER8  iface,
DWORD  dwFlags,
DWORD  dwEffectsCount,
LPDWORD  pdwResultCodes 
)

Definition at line 532 of file primary.c.

537{
539 return DSERR_INVALIDPARAM;
540}
#define UNIMPLEMENTED
Definition: ntoskrnl.c:15
#define DSERR_INVALIDPARAM
Definition: dsound.h:121

◆ PrimaryDirectSoundBuffer8Impl_fnAddRef()

ULONG WINAPI PrimaryDirectSoundBuffer8Impl_fnAddRef ( LPDIRECTSOUNDBUFFER8  iface)

Definition at line 59 of file primary.c.

61{
62 ULONG ref;
64
66
67 return ref;
68
69}
#define InterlockedIncrement
Definition: armddk.h:53
struct CDirectSoundBuffer * LPCDirectSoundBuffer
Definition: send.c:48
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
uint32_t ULONG
Definition: typedefs.h:59

◆ PrimaryDirectSoundBuffer8Impl_fnGetCaps()

HRESULT WINAPI PrimaryDirectSoundBuffer8Impl_fnGetCaps ( LPDIRECTSOUNDBUFFER8  iface,
LPDSBCAPS  pDSBufferCaps 
)

Definition at line 97 of file primary.c.

100{
102
103 DPRINT("PrimaryDirectSoundBuffer8Impl_fnGetCaps\n");
104
105 if (!pDSBufferCaps)
106 {
107 /* invalid parameter */
108 return DSERR_INVALIDPARAM;
109 }
110
111 if (pDSBufferCaps->dwSize < sizeof(DSBCAPS))
112 {
113 /* invalid buffer size */
114 return DSERR_INVALIDPARAM;
115 }
116
117 /* get buffer details */
118 pDSBufferCaps->dwUnlockTransferRate = 0;
119 pDSBufferCaps->dwPlayCpuOverhead = 0;
120 pDSBufferCaps->dwSize = 0; //FIXME
121 pDSBufferCaps->dwFlags = This->dwFlags;
122
123 return DS_OK;
124}
#define DPRINT
Definition: sndvol32.h:73
DWORD dwUnlockTransferRate
Definition: dsound.h:242
DWORD dwPlayCpuOverhead
Definition: dsound.h:243
DWORD dwFlags
Definition: dsound.h:240
DWORD dwSize
Definition: dsound.h:239

◆ PrimaryDirectSoundBuffer8Impl_fnGetCurrentPosition()

HRESULT WINAPI PrimaryDirectSoundBuffer8Impl_fnGetCurrentPosition ( LPDIRECTSOUNDBUFFER8  iface,
LPDWORD  pdwCurrentPlayCursor,
LPDWORD  pdwCurrentWriteCursor 
)

Definition at line 128 of file primary.c.

132{
134
135 DPRINT("PrimaryDirectSoundBuffer8Impl_fnGetCurrentPosition\n");
136
137 if (This->dwLevel < DSSCL_PRIORITY)
138 {
139 /* needs priority level */
141 }
142
143 if (!pdwCurrentPlayCursor && !pdwCurrentWriteCursor)
144 {
145 /* all parameters are null */
146 return DSERR_INVALIDPARAM;
147 }
148
150 return DSERR_INVALIDPARAM;
151}
#define DSSCL_PRIORITY
Definition: dsound.h:248
#define DSERR_PRIOLEVELNEEDED
Definition: dsound.h:124

◆ PrimaryDirectSoundBuffer8Impl_fnGetFormat()

HRESULT WINAPI PrimaryDirectSoundBuffer8Impl_fnGetFormat ( LPDIRECTSOUNDBUFFER8  iface,
LPWAVEFORMATEX  pwfxFormat,
DWORD  dwSizeAllocated,
LPDWORD  pdwSizeWritten 
)

Definition at line 155 of file primary.c.

160{
161 DWORD FormatSize;
163
164 DPRINT("PrimaryDirectSoundBuffer8Impl_fnGetFormat\n");
165
166 FormatSize = sizeof(WAVEFORMATEX) + This->Format.cbSize;
167
168 if (!pwfxFormat && !pdwSizeWritten)
169 {
170 /* invalid parameter */
171 return DSERR_INVALIDPARAM;
172 }
173
174 if (!pwfxFormat)
175 {
176 /* return required format size */
177 *pdwSizeWritten = FormatSize;
178 return DS_OK;
179 }
180 else
181 {
182 if (dwSizeAllocated >= FormatSize)
183 {
184 /* copy format */
185 CopyMemory(pwfxFormat, &This->Format, FormatSize);
186
187 if (pdwSizeWritten)
188 *pdwSizeWritten = FormatSize;
189
190 return DS_OK;
191 }
192 /* buffer too small */
193 if (pdwSizeWritten)
194 *pdwSizeWritten = 0;
195
196 return DSERR_INVALIDPARAM;
197 }
198}
unsigned long DWORD
Definition: ntddk_ex.h:95
if(dx< 0)
Definition: linetemp.h:194
#define CopyMemory
Definition: winbase.h:1735

◆ PrimaryDirectSoundBuffer8Impl_fnGetFrequency()

HRESULT WINAPI PrimaryDirectSoundBuffer8Impl_fnGetFrequency ( LPDIRECTSOUNDBUFFER8  iface,
LPDWORD  pdwFrequency 
)

Definition at line 246 of file primary.c.

249{
251
252 DPRINT("PrimaryDirectSoundBuffer8Impl_fnGetFrequency\n");
253
254 if (!pdwFrequency)
255 {
256 /* invalid parameter */
257 return DSERR_INVALIDPARAM;
258 }
259
260 /* get frequency */
261 *pdwFrequency = This->dwFrequency;
262
263 return DS_OK;
264}

◆ PrimaryDirectSoundBuffer8Impl_fnGetObjectInPath()

HRESULT WINAPI PrimaryDirectSoundBuffer8Impl_fnGetObjectInPath ( LPDIRECTSOUNDBUFFER8  iface,
REFGUID  rguidObject,
DWORD  dwIndex,
REFGUID  rguidInterface,
LPVOID ppObject 
)

Definition at line 544 of file primary.c.

550{
552 return DSERR_INVALIDPARAM;
553}

◆ PrimaryDirectSoundBuffer8Impl_fnGetPan()

HRESULT WINAPI PrimaryDirectSoundBuffer8Impl_fnGetPan ( LPDIRECTSOUNDBUFFER8  iface,
LPLONG  plPan 
)

Definition at line 224 of file primary.c.

227{
229
230 DPRINT("PrimaryDirectSoundBuffer8Impl_fnGetPan\n");
231
232 if (!plPan)
233 {
234 /* invalid parameter */
235 return DSERR_INVALIDPARAM;
236 }
237
238 /* get frequency */
239 *plPan = This->VolumePan;
240
241 return DS_OK;
242}

◆ PrimaryDirectSoundBuffer8Impl_fnGetStatus()

HRESULT WINAPI PrimaryDirectSoundBuffer8Impl_fnGetStatus ( LPDIRECTSOUNDBUFFER8  iface,
LPDWORD  pdwStatus 
)

Definition at line 268 of file primary.c.

271{
273
274 DPRINT("PrimaryDirectSoundBuffer8Impl_fnGetStatus\n");
275
276 if (!pdwStatus)
277 {
278 /* invalid parameter */
279 return DSERR_INVALIDPARAM;
280 }
281
282 *pdwStatus = 0;
283 if (This->State == KSSTATE_RUN || This->State == KSSTATE_ACQUIRE)
284 {
285 /* buffer is playing */
286 *pdwStatus |= DSBSTATUS_PLAYING | DSBSTATUS_LOOPING;
287 }
288
289 return DS_OK;
290}
#define DSBSTATUS_LOOPING
Definition: dsound.h:198
#define DSBSTATUS_PLAYING
Definition: dsound.h:196
@ KSSTATE_ACQUIRE
Definition: ks.h:1216
@ KSSTATE_RUN
Definition: ks.h:1218

◆ PrimaryDirectSoundBuffer8Impl_fnGetVolume()

HRESULT WINAPI PrimaryDirectSoundBuffer8Impl_fnGetVolume ( LPDIRECTSOUNDBUFFER8  iface,
LPLONG  plVolume 
)

Definition at line 202 of file primary.c.

205{
207
208 DPRINT("PrimaryDirectSoundBuffer8Impl_fnGetVolume\n");
209
210 if (!plVolume)
211 {
212 /* invalid parameter */
213 return DSERR_INVALIDPARAM;
214 }
215
216 /* get volume */
217 *plVolume = This->Volume;
218
219 return DS_OK;
220}

◆ PrimaryDirectSoundBuffer8Impl_fnInitialize()

HRESULT WINAPI PrimaryDirectSoundBuffer8Impl_fnInitialize ( LPDIRECTSOUNDBUFFER8  iface,
LPDIRECTSOUND  pDirectSound,
LPCDSBUFFERDESC  pcDSBufferDesc 
)

Definition at line 294 of file primary.c.

298{
299 /* RTFM */
301}
#define DSERR_ALREADYINITIALIZED
Definition: dsound.h:129

◆ PrimaryDirectSoundBuffer8Impl_fnLock()

HRESULT WINAPI PrimaryDirectSoundBuffer8Impl_fnLock ( LPDIRECTSOUNDBUFFER8  iface,
DWORD  dwOffset,
DWORD  dwBytes,
LPVOID ppvAudioPtr1,
LPDWORD  pdwAudioBytes1,
LPVOID ppvAudioPtr2,
LPDWORD  pdwAudioBytes2,
DWORD  dwFlags 
)

Definition at line 305 of file primary.c.

314{
316 return DSERR_INVALIDPARAM;
317}

◆ PrimaryDirectSoundBuffer8Impl_fnPlay()

HRESULT WINAPI PrimaryDirectSoundBuffer8Impl_fnPlay ( LPDIRECTSOUNDBUFFER8  iface,
DWORD  dwReserved1,
DWORD  dwPriority,
DWORD  dwFlags 
)

Definition at line 321 of file primary.c.

326{
328
329 DPRINT("PrimaryDirectSoundBuffer8Impl_fnPlay dwFlags %x\n", dwFlags);
330
331 if (dwReserved1 != 0 || !(dwFlags & DSBPLAY_LOOPING))
332 {
333 /* invalid parameter */
334 return DSERR_INVALIDPARAM;
335 }
336
338
339 if (This->State == KSSTATE_STOP)
340 {
342 ASSERT(This->State == KSSTATE_ACQUIRE);
343 }
344
345 if (This->State == KSSTATE_ACQUIRE)
346 {
348 ASSERT(This->State == KSSTATE_PAUSE);
349 }
350
351 if (This->State == KSSTATE_PAUSE)
352 {
354 ASSERT(This->State == KSSTATE_RUN);
355 }
356
358
359 return DS_OK;
360}
#define DSBPLAY_LOOPING
Definition: dsound.h:189
VOID PrimaryDirectSoundBuffer_ReleaseLock(LPDIRECTSOUNDBUFFER8 iface)
Definition: primary.c:757
VOID PrimaryDirectSoundBuffer_AcquireLock(LPDIRECTSOUNDBUFFER8 iface)
Definition: primary.c:746
VOID PrimaryDirectSoundBuffer_SetState(LPDIRECTSOUNDBUFFER8 iface, KSSTATE State)
Definition: primary.c:621
@ KSSTATE_PAUSE
Definition: ks.h:1217
@ KSSTATE_STOP
Definition: ks.h:1215
#define ASSERT(a)
Definition: mode.c:44

◆ PrimaryDirectSoundBuffer8Impl_fnQueryInterface()

HRESULT WINAPI PrimaryDirectSoundBuffer8Impl_fnQueryInterface ( LPDIRECTSOUNDBUFFER8  iface,
IN REFIID  riid,
LPVOID ppobj 
)

Definition at line 32 of file primary.c.

36{
37 LPOLESTR pStr;
39
41 IsEqualIID(riid, &IID_IDirectSoundBuffer) ||
42 IsEqualIID(riid, &IID_IDirectSoundBuffer8))
43 {
44 *ppobj = (LPVOID)&This->lpVtbl;
46 return S_OK;
47 }
48
49 if (SUCCEEDED(StringFromIID(riid, &pStr)))
50 {
51 DPRINT("No Interface for class %s\n", pStr);
52 CoTaskMemFree(pStr);
53 }
54 return E_NOINTERFACE;
55}
const GUID IID_IUnknown
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:442
REFIID riid
Definition: atlbase.h:39
#define S_OK
Definition: intsafe.h:52
#define SUCCEEDED(hr)
Definition: intsafe.h:50
static LPOLESTR
Definition: stg_prop.c:27
#define LPVOID
Definition: nt_native.h:45
_Check_return_ HRESULT WINAPI StringFromIID(_In_ REFIID rclsid, _Outptr_ LPOLESTR *lplpsz)
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95
#define E_NOINTERFACE
Definition: winerror.h:2364

◆ PrimaryDirectSoundBuffer8Impl_fnRelease()

ULONG WINAPI PrimaryDirectSoundBuffer8Impl_fnRelease ( LPDIRECTSOUNDBUFFER8  iface)

Definition at line 73 of file primary.c.

75{
76 ULONG ref;
78
79 ref = InterlockedDecrement(&(This->ref));
80
81 if (!ref)
82 {
83 if (This->hPin)
84 {
85 /* close pin handle */
86 CloseHandle(This->hPin);
87 }
88 /* free primary buffer */
90 }
91
92 return ref;
93}
#define InterlockedDecrement
Definition: armddk.h:52
#define CloseHandle
Definition: compat.h:739
#define HeapFree(x, y, z)
Definition: compat.h:735

◆ PrimaryDirectSoundBuffer8Impl_fnRestore()

HRESULT WINAPI PrimaryDirectSoundBuffer8Impl_fnRestore ( LPDIRECTSOUNDBUFFER8  iface)

Definition at line 510 of file primary.c.

512{
514 return DSERR_INVALIDPARAM;
515}

◆ PrimaryDirectSoundBuffer8Impl_fnSetCurrentPosition()

HRESULT WINAPI PrimaryDirectSoundBuffer8Impl_fnSetCurrentPosition ( LPDIRECTSOUNDBUFFER8  iface,
DWORD  dwNewPosition 
)

Definition at line 364 of file primary.c.

367{
368 /* The position of a primary buffer can't be set */
369 return DSERR_INVALIDCALL;
370}
#define DSERR_INVALIDCALL
Definition: dsound.h:122

◆ PrimaryDirectSoundBuffer8Impl_fnSetFormat()

HRESULT WINAPI PrimaryDirectSoundBuffer8Impl_fnSetFormat ( LPDIRECTSOUNDBUFFER8  iface,
LPCWAVEFORMATEX  pcfxFormat 
)

Definition at line 374 of file primary.c.

377{
379
380 if (This->dwLevel == DSSCL_NORMAL)
381 {
382 /* can't change format with this level */
384 }
385
386 ASSERT(pcfxFormat->cbSize == 0);
387
388
389 DPRINT("This %p Format: Tag %x nChannels %u nSamplesPerSec %u nAvgBytesPerSec %u nBlockAlign %u wBitsPerSample %u cbSize %u\n", This,
390 pcfxFormat->wFormatTag, pcfxFormat->nChannels, pcfxFormat->nSamplesPerSec, pcfxFormat->nAvgBytesPerSec, pcfxFormat->nBlockAlign, pcfxFormat->wBitsPerSample, pcfxFormat->cbSize);
391
392 CopyMemory(&This->Format, pcfxFormat, sizeof(WAVEFORMATEX));
393
394 return DS_OK;
395}
#define DSSCL_NORMAL
Definition: dsound.h:247
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

◆ PrimaryDirectSoundBuffer8Impl_fnSetFrequency()

HRESULT WINAPI PrimaryDirectSoundBuffer8Impl_fnSetFrequency ( LPDIRECTSOUNDBUFFER8  iface,
DWORD  dwFrequency 
)

Definition at line 443 of file primary.c.

446{
448
449 if (This->dwLevel < DSSCL_PRIORITY)
450 {
451 /* needs priority level */
453 }
454
455 /* invalid request */
457}
#define DSERR_CONTROLUNAVAIL
Definition: dsound.h:120

◆ PrimaryDirectSoundBuffer8Impl_fnSetFX()

HRESULT WINAPI PrimaryDirectSoundBuffer8Impl_fnSetFX ( LPDIRECTSOUNDBUFFER8  iface,
DWORD  dwEffectsCount,
LPDSEFFECTDESC  pDSFXDesc,
LPDWORD  pdwResultCodes 
)

Definition at line 520 of file primary.c.

525{
527 return DSERR_INVALIDPARAM;
528}

◆ PrimaryDirectSoundBuffer8Impl_fnSetPan()

HRESULT WINAPI PrimaryDirectSoundBuffer8Impl_fnSetPan ( LPDIRECTSOUNDBUFFER8  iface,
LONG  lPan 
)

Definition at line 421 of file primary.c.

424{
426
427 if (lPan < DSBPAN_LEFT || lPan > DSBPAN_RIGHT)
428 {
429 /* invalid parameter */
430 return DSERR_INVALIDPARAM;
431 }
432
433 /* TODO: call volume node */
434
435 /* Store volume pan */
436 This->VolumePan = lPan;
437
438 return DS_OK;
439}
#define DSBPAN_RIGHT
Definition: dsound.h:228

◆ PrimaryDirectSoundBuffer8Impl_fnSetVolume()

HRESULT WINAPI PrimaryDirectSoundBuffer8Impl_fnSetVolume ( LPDIRECTSOUNDBUFFER8  iface,
LONG  lVolume 
)

Definition at line 399 of file primary.c.

402{
404
405 if (lVolume < DSBVOLUME_MIN || lVolume > DSBVOLUME_MAX)
406 {
407 /* invalid parameter */
408 return DSERR_INVALIDPARAM;
409 }
410
411 /* TODO: call volume node */
412
413 /* Store volume */
414 This->Volume = lVolume;
415
416 return DS_OK;
417}

◆ PrimaryDirectSoundBuffer8Impl_fnStop()

HRESULT WINAPI PrimaryDirectSoundBuffer8Impl_fnStop ( LPDIRECTSOUNDBUFFER8  iface)

Definition at line 461 of file primary.c.

463{
465
466 DPRINT("PrimaryDirectSoundBuffer8Impl_fnStop\n");
467
469
470 if (This->State == KSSTATE_RUN)
471 {
473 ASSERT(This->State == KSSTATE_PAUSE);
474 }
475
476 if (This->State == KSSTATE_PAUSE)
477 {
479 ASSERT(This->State == KSSTATE_ACQUIRE);
480 }
481
482 if (This->State == KSSTATE_ACQUIRE)
483 {
485 ASSERT(This->State == KSSTATE_STOP);
486 }
487
489
490 return DS_OK;
491}

◆ PrimaryDirectSoundBuffer8Impl_fnUnlock()

HRESULT WINAPI PrimaryDirectSoundBuffer8Impl_fnUnlock ( LPDIRECTSOUNDBUFFER8  iface,
LPVOID  pvAudioPtr1,
DWORD  dwAudioBytes1,
LPVOID  pvAudioPtr2,
DWORD  dwAudioBytes2 
)

Definition at line 496 of file primary.c.

502{
504 return DSERR_INVALIDPARAM;
505}

◆ PrimaryDirectSoundBuffer_AcquireLock()

VOID PrimaryDirectSoundBuffer_AcquireLock ( LPDIRECTSOUNDBUFFER8  iface)

Definition at line 746 of file primary.c.

748{
750
752
753
754}
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)

Referenced by PrimaryDirectSoundBuffer8Impl_fnPlay(), PrimaryDirectSoundBuffer8Impl_fnStop(), and SecondaryDirectSoundBuffer8Impl_fnPlay().

◆ PrimaryDirectSoundBuffer_GetPosition()

HRESULT PrimaryDirectSoundBuffer_GetPosition ( LPDIRECTSOUNDBUFFER8  iface,
LPDWORD  pdwCurrentPlayCursor,
LPDWORD  pdwCurrentWriteCursor 
)

Definition at line 644 of file primary.c.

648{
653
654 //DPRINT("PrimaryDirectSoundBuffer_GetPosition\n");
655
656 if (!This->hPin)
657 {
658 if (pdwCurrentPlayCursor)
659 *pdwCurrentPlayCursor = 0;
660
661 if (pdwCurrentWriteCursor)
662 *pdwCurrentWriteCursor = 0;
663
664 DPRINT("No Audio Pin\n");
665 return DS_OK;
666 }
667
668 /* setup audio position property request */
672
673
675
676 if (Result != ERROR_SUCCESS)
677 {
678 DPRINT("GetPosition failed with %x\n", Result);
679 return DSERR_UNSUPPORTED;
680 }
681
682 //DPRINT("Play %I64u Write %I64u \n", Position.PlayOffset, Position.WriteOffset);
683
684 if (pdwCurrentPlayCursor)
685 *pdwCurrentPlayCursor = (DWORD)Position.PlayOffset;
686
687 if (pdwCurrentWriteCursor)
688 *pdwCurrentWriteCursor = (DWORD)Position.WriteOffset;
689
690 return DS_OK;
691}
#define ERROR_SUCCESS
Definition: deptool.c:10
DWORD SyncOverlappedDeviceIoControl(IN HANDLE Handle, IN DWORD IoControlCode, IN LPVOID InBuffer, IN DWORD InBufferSize, OUT LPVOID OutBuffer, IN DWORD OutBufferSize, OUT LPDWORD BytesTransferred OPTIONAL)
Definition: misc.c:298
#define DSERR_UNSUPPORTED
Definition: dsound.h:127
#define KSPROPERTY_TYPE_GET
Definition: dmksctrl.h:42
#define IOCTL_KS_PROPERTY
Definition: ks.h:127
@ KSPROPERTY_AUDIO_POSITION
Definition: ksmedia.h:1058
#define KSPROPSETID_Audio
Definition: ksmedia.h:1051
#define DWORD
Definition: nt_native.h:44
static COORD Position
Definition: mouse.c:34
_In_ WDFREQUEST Request
Definition: wdfdevice.h:547
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:409

Referenced by SecondaryDirectSoundBuffer8Impl_fnGetCurrentPosition().

◆ PrimaryDirectSoundBuffer_ReleaseLock()

VOID PrimaryDirectSoundBuffer_ReleaseLock ( LPDIRECTSOUNDBUFFER8  iface)

Definition at line 757 of file primary.c.

759{
761
763
764}
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)

Referenced by PrimaryDirectSoundBuffer8Impl_fnPlay(), PrimaryDirectSoundBuffer8Impl_fnStop(), and SecondaryDirectSoundBuffer8Impl_fnPlay().

◆ PrimaryDirectSoundBuffer_SetFormat()

HRESULT PrimaryDirectSoundBuffer_SetFormat ( LPDIRECTSOUNDBUFFER8  iface,
LPWAVEFORMATEX  pcfxFormat,
BOOL  bLooped 
)

Definition at line 694 of file primary.c.

698{
699 ULONG PinId, DeviceId = 0, Result;
701
702 if (This->hPin)
703 {
704 // FIXME
705 // check if multiple buffers are active
706 // in that case need mixing
707
708 if (SetPinFormat(This->hPin, pcfxFormat))
709 return DS_OK;
710 else
711 return DSERR_GENERIC;
712 }
713
714 do
715 {
716 /* try all available recording pins on that filter */
717 PinId = GetPinIdFromFilter(This->Filter, FALSE, DeviceId);
718 DPRINT("PinId %u DeviceId %u\n", PinId, DeviceId);
719
720 if (PinId == ULONG_MAX)
721 break;
722
723 Result = OpenPin(This->Filter->hFilter, PinId, (LPWAVEFORMATEX)pcfxFormat, &This->hPin, bLooped);
724 DPRINT("PinId %u Result %u\n", PinId, Result);
725 if (Result == ERROR_SUCCESS)
726 {
727 This->dwFrequency = pcfxFormat->nSamplesPerSec;
728 break;
729 }
730
731 This->hPin = NULL;
732 DeviceId++;
733 }while(TRUE);
734
735 if (!This->hPin)
736 {
737 DPRINT("PrimaryDirectSoundBuffer8Impl_fnSetFormat failed\n");
738 return DSERR_INVALIDPARAM;
739 }
740
741 DPRINT("PrimaryDirectSoundBuffer8Impl_fnSetFormat success\n");
742 return DS_OK;
743}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
ULONG GetPinIdFromFilter(LPFILTERINFO Filter, BOOL bCapture, ULONG Offset)
Definition: devicelist.c:13
DWORD OpenPin(HANDLE hFilter, ULONG PinId, LPWAVEFORMATEX WaveFormatEx, PHANDLE hPin, BOOL bLoop)
Definition: misc.c:212
BOOL SetPinFormat(IN HANDLE hPin, IN LPWAVEFORMATEX WaveFormatEx)
Definition: misc.c:77
#define DSERR_GENERIC
Definition: dsound.h:123
#define ULONG_MAX
Definition: intsafe.h:155

Referenced by SecondaryDirectSoundBuffer8Impl_fnPlay().

◆ PrimaryDirectSoundBuffer_SetState()

VOID PrimaryDirectSoundBuffer_SetState ( LPDIRECTSOUNDBUFFER8  iface,
KSSTATE  State 
)

Definition at line 621 of file primary.c.

624{
628
629 if (This->State == State)
630 return;
631
635
637 if (Result == ERROR_SUCCESS)
638 {
639 This->State = State;
640 }
641}
#define KSPROPERTY_TYPE_SET
Definition: dmksctrl.h:43
@ KSPROPERTY_CONNECTION_STATE
Definition: ks.h:349
KSSTATE
Definition: ks.h:1214
#define KSPROPSETID_Connection
Definition: ks.h:346
_Must_inspect_result_ _In_ WDFUSBDEVICE _In_opt_ WDFREQUEST _In_opt_ PWDF_REQUEST_SEND_OPTIONS _In_ PWDF_USB_CONTROL_SETUP_PACKET _In_opt_ PWDF_MEMORY_DESCRIPTOR _Out_opt_ PULONG BytesTransferred
Definition: wdfusb.h:1342

Referenced by PrimaryDirectSoundBuffer8Impl_fnPlay(), PrimaryDirectSoundBuffer8Impl_fnStop(), SecondaryDirectSoundBuffer8Impl_fnPlay(), and SecondaryDirectSoundBuffer8Impl_fnStop().

◆ PrimaryDirectSoundBuffer_Write()

DWORD PrimaryDirectSoundBuffer_Write ( LPDIRECTSOUNDBUFFER8  iface,
LPVOID  Buffer,
DWORD  BufferSize 
)

Definition at line 587 of file primary.c.

591{
594 OVERLAPPED Overlapped;
595
597
598 ZeroMemory(&Overlapped, sizeof(OVERLAPPED));
599 Overlapped.hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
600
601
602 ASSERT(This->hPin);
604
605 Header.FrameExtent = BufferSize;
606 Header.DataUsed = BufferSize;
607 Header.Data = Buffer;
608 Header.Size = sizeof(KSSTREAM_HEADER);
609 Header.PresentationTime.Numerator = 1;
610 Header.PresentationTime.Denominator = 1;
611
613
614 if (Result != ERROR_SUCCESS)
615 return 0;
616
617 return BytesTransferred;
618}
Definition: bufpool.h:45
Definition: Header.h:9
#define BufferSize
Definition: mmc.h:75
BOOL WINAPI DeviceIoControl(IN HANDLE hDevice, IN DWORD dwIoControlCode, IN LPVOID lpInBuffer OPTIONAL, IN DWORD nInBufferSize OPTIONAL, OUT LPVOID lpOutBuffer OPTIONAL, IN DWORD nOutBufferSize OPTIONAL, OUT LPDWORD lpBytesReturned OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: deviceio.c:136
#define IOCTL_KS_WRITE_STREAM
Definition: ks.h:139
HANDLE hEvent
Definition: winbase.h:845
#define ZeroMemory
Definition: winbase.h:1737
#define CreateEvent
Definition: winbase.h:3773

Referenced by SecondaryDirectSoundBuffer8Impl_fnPlay().

Variable Documentation

◆ vt_DirectSoundBuffer8

IDirectSoundBuffer8Vtbl vt_DirectSoundBuffer8
static
Initial value:
=
{
}
HRESULT WINAPI PrimaryDirectSoundBuffer8Impl_fnRestore(LPDIRECTSOUNDBUFFER8 iface)
Definition: primary.c:510
HRESULT WINAPI PrimaryDirectSoundBuffer8Impl_fnGetCurrentPosition(LPDIRECTSOUNDBUFFER8 iface, LPDWORD pdwCurrentPlayCursor, LPDWORD pdwCurrentWriteCursor)
Definition: primary.c:128
HRESULT WINAPI PrimaryDirectSoundBuffer8Impl_fnPlay(LPDIRECTSOUNDBUFFER8 iface, DWORD dwReserved1, DWORD dwPriority, DWORD dwFlags)
Definition: primary.c:321
HRESULT WINAPI PrimaryDirectSoundBuffer8Impl_fnGetPan(LPDIRECTSOUNDBUFFER8 iface, LPLONG plPan)
Definition: primary.c:224
HRESULT WINAPI PrimaryDirectSoundBuffer8Impl_fnGetCaps(LPDIRECTSOUNDBUFFER8 iface, LPDSBCAPS pDSBufferCaps)
Definition: primary.c:97
HRESULT WINAPI PrimaryDirectSoundBuffer8Impl_fnGetVolume(LPDIRECTSOUNDBUFFER8 iface, LPLONG plVolume)
Definition: primary.c:202
ULONG WINAPI PrimaryDirectSoundBuffer8Impl_fnAddRef(LPDIRECTSOUNDBUFFER8 iface)
Definition: primary.c:59
HRESULT WINAPI PrimaryDirectSoundBuffer8Impl_fnSetCurrentPosition(LPDIRECTSOUNDBUFFER8 iface, DWORD dwNewPosition)
Definition: primary.c:364
HRESULT WINAPI PrimaryDirectSoundBuffer8Impl_fnQueryInterface(LPDIRECTSOUNDBUFFER8 iface, IN REFIID riid, LPVOID *ppobj)
Definition: primary.c:32
HRESULT WINAPI PrimaryDirectSoundBuffer8Impl_fnLock(LPDIRECTSOUNDBUFFER8 iface, DWORD dwOffset, DWORD dwBytes, LPVOID *ppvAudioPtr1, LPDWORD pdwAudioBytes1, LPVOID *ppvAudioPtr2, LPDWORD pdwAudioBytes2, DWORD dwFlags)
Definition: primary.c:305
HRESULT WINAPI PrimaryDirectSoundBuffer8Impl_fnSetFX(LPDIRECTSOUNDBUFFER8 iface, DWORD dwEffectsCount, LPDSEFFECTDESC pDSFXDesc, LPDWORD pdwResultCodes)
Definition: primary.c:520
HRESULT WINAPI PrimaryDirectSoundBuffer8Impl_fnGetFormat(LPDIRECTSOUNDBUFFER8 iface, LPWAVEFORMATEX pwfxFormat, DWORD dwSizeAllocated, LPDWORD pdwSizeWritten)
Definition: primary.c:155
HRESULT WINAPI PrimaryDirectSoundBuffer8Impl_fnSetFrequency(LPDIRECTSOUNDBUFFER8 iface, DWORD dwFrequency)
Definition: primary.c:443
HRESULT WINAPI PrimaryDirectSoundBuffer8Impl_fnStop(LPDIRECTSOUNDBUFFER8 iface)
Definition: primary.c:461
HRESULT WINAPI PrimaryDirectSoundBuffer8Impl_fnUnlock(LPDIRECTSOUNDBUFFER8 iface, LPVOID pvAudioPtr1, DWORD dwAudioBytes1, LPVOID pvAudioPtr2, DWORD dwAudioBytes2)
Definition: primary.c:496
ULONG WINAPI PrimaryDirectSoundBuffer8Impl_fnRelease(LPDIRECTSOUNDBUFFER8 iface)
Definition: primary.c:73
HRESULT WINAPI PrimaryDirectSoundBuffer8Impl_fnSetFormat(LPDIRECTSOUNDBUFFER8 iface, LPCWAVEFORMATEX pcfxFormat)
Definition: primary.c:374
HRESULT WINAPI PrimaryDirectSoundBuffer8Impl_fnSetPan(LPDIRECTSOUNDBUFFER8 iface, LONG lPan)
Definition: primary.c:421
HRESULT WINAPI PrimaryDirectSoundBuffer8Impl_fnSetVolume(LPDIRECTSOUNDBUFFER8 iface, LONG lVolume)
Definition: primary.c:399
HRESULT WINAPI PrimaryDirectSoundBuffer8Impl_fnGetObjectInPath(LPDIRECTSOUNDBUFFER8 iface, REFGUID rguidObject, DWORD dwIndex, REFGUID rguidInterface, LPVOID *ppObject)
Definition: primary.c:544
HRESULT WINAPI PrimaryDirectSoundBuffer8Impl_fnAcquireResources(LPDIRECTSOUNDBUFFER8 iface, DWORD dwFlags, DWORD dwEffectsCount, LPDWORD pdwResultCodes)
Definition: primary.c:532
HRESULT WINAPI PrimaryDirectSoundBuffer8Impl_fnGetFrequency(LPDIRECTSOUNDBUFFER8 iface, LPDWORD pdwFrequency)
Definition: primary.c:246
HRESULT WINAPI PrimaryDirectSoundBuffer8Impl_fnGetStatus(LPDIRECTSOUNDBUFFER8 iface, LPDWORD pdwStatus)
Definition: primary.c:268
HRESULT WINAPI PrimaryDirectSoundBuffer8Impl_fnInitialize(LPDIRECTSOUNDBUFFER8 iface, LPDIRECTSOUND pDirectSound, LPCDSBUFFERDESC pcDSBufferDesc)
Definition: primary.c:294

Definition at line 555 of file primary.c.

Referenced by NewPrimarySoundBuffer().