3 * Copyright 1998 Marcus Meissner
4 * Copyright 1998 Rob Riggs
5 * Copyright 2000-2002 TransGaming Technologies, Inc.
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
32 #include "wine/debug.h"
34 #include "dsound_private.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(dsound
);
39 /*******************************************************************************
43 static inline struct IDirectSoundBufferImpl
*impl_from_IDirectSoundNotify(IDirectSoundNotify
*iface
)
45 return CONTAINING_RECORD(iface
, struct IDirectSoundBufferImpl
, IDirectSoundNotify_iface
);
48 static HRESULT WINAPI
IDirectSoundNotifyImpl_QueryInterface(IDirectSoundNotify
*iface
, REFIID riid
,
51 IDirectSoundBufferImpl
*This
= impl_from_IDirectSoundNotify(iface
);
53 TRACE("(%p,%s,%p)\n", This
, debugstr_guid(riid
), ppobj
);
55 return IDirectSoundBuffer8_QueryInterface(&This
->IDirectSoundBuffer8_iface
, riid
, ppobj
);
58 static ULONG WINAPI
IDirectSoundNotifyImpl_AddRef(IDirectSoundNotify
*iface
)
60 IDirectSoundBufferImpl
*This
= impl_from_IDirectSoundNotify(iface
);
61 ULONG ref
= InterlockedIncrement(&This
->refn
);
63 TRACE("(%p) ref was %d\n", This
, ref
- 1);
66 InterlockedIncrement(&This
->numIfaces
);
71 static ULONG WINAPI
IDirectSoundNotifyImpl_Release(IDirectSoundNotify
*iface
)
73 IDirectSoundBufferImpl
*This
= impl_from_IDirectSoundNotify(iface
);
74 ULONG ref
= InterlockedDecrement(&This
->refn
);
76 TRACE("(%p) ref was %d\n", This
, ref
+ 1);
78 if (!ref
&& !InterlockedDecrement(&This
->numIfaces
))
79 secondarybuffer_destroy(This
);
84 static int notify_compar(const void *l
, const void *r
)
86 const DSBPOSITIONNOTIFY
*left
= l
;
87 const DSBPOSITIONNOTIFY
*right
= r
;
89 /* place DSBPN_OFFSETSTOP at the start of the sorted array */
90 if(left
->dwOffset
== DSBPN_OFFSETSTOP
){
91 if(right
->dwOffset
!= DSBPN_OFFSETSTOP
)
93 }else if(right
->dwOffset
== DSBPN_OFFSETSTOP
)
96 if(left
->dwOffset
== right
->dwOffset
)
99 if(left
->dwOffset
< right
->dwOffset
)
105 static HRESULT WINAPI
IDirectSoundNotifyImpl_SetNotificationPositions(IDirectSoundNotify
*iface
,
106 DWORD howmuch
, const DSBPOSITIONNOTIFY
*notify
)
108 IDirectSoundBufferImpl
*This
= impl_from_IDirectSoundNotify(iface
);
110 TRACE("(%p,0x%08x,%p)\n",This
,howmuch
,notify
);
112 if (howmuch
> 0 && notify
== NULL
) {
113 WARN("invalid parameter: notify == NULL\n");
114 return DSERR_INVALIDPARAM
;
117 if (TRACE_ON(dsound
)) {
119 for (i
=0;i
<howmuch
;i
++)
120 TRACE("notify at %d to %p\n",
121 notify
[i
].dwOffset
,notify
[i
].hEventNotify
);
125 /* Make an internal copy of the caller-supplied array.
126 * Replace the existing copy if one is already present. */
127 HeapFree(GetProcessHeap(), 0, This
->notifies
);
128 This
->notifies
= HeapAlloc(GetProcessHeap(), 0,
129 howmuch
* sizeof(DSBPOSITIONNOTIFY
));
131 if (This
->notifies
== NULL
) {
132 WARN("out of memory\n");
133 return DSERR_OUTOFMEMORY
;
135 CopyMemory(This
->notifies
, notify
, howmuch
* sizeof(DSBPOSITIONNOTIFY
));
136 This
->nrofnotifies
= howmuch
;
137 qsort(This
->notifies
, howmuch
, sizeof(DSBPOSITIONNOTIFY
), notify_compar
);
139 HeapFree(GetProcessHeap(), 0, This
->notifies
);
140 This
->notifies
= NULL
;
141 This
->nrofnotifies
= 0;
147 static const IDirectSoundNotifyVtbl dsnvt
=
149 IDirectSoundNotifyImpl_QueryInterface
,
150 IDirectSoundNotifyImpl_AddRef
,
151 IDirectSoundNotifyImpl_Release
,
152 IDirectSoundNotifyImpl_SetNotificationPositions
,
155 /*******************************************************************************
159 static inline IDirectSoundBufferImpl
*impl_from_IDirectSoundBuffer8(IDirectSoundBuffer8
*iface
)
161 return CONTAINING_RECORD(iface
, IDirectSoundBufferImpl
, IDirectSoundBuffer8_iface
);
164 static inline BOOL
is_primary_buffer(IDirectSoundBufferImpl
*This
)
166 return (This
->dsbd
.dwFlags
& DSBCAPS_PRIMARYBUFFER
) != 0;
169 static HRESULT WINAPI
IDirectSoundBufferImpl_SetFormat(IDirectSoundBuffer8
*iface
,
170 LPCWAVEFORMATEX wfex
)
172 IDirectSoundBufferImpl
*This
= impl_from_IDirectSoundBuffer8(iface
);
174 TRACE("(%p,%p)\n", iface
, wfex
);
176 if (is_primary_buffer(This
))
177 return primarybuffer_SetFormat(This
->device
, wfex
);
179 WARN("not available for secondary buffers.\n");
180 return DSERR_INVALIDCALL
;
184 static HRESULT WINAPI
IDirectSoundBufferImpl_SetVolume(IDirectSoundBuffer8
*iface
, LONG vol
)
186 IDirectSoundBufferImpl
*This
= impl_from_IDirectSoundBuffer8(iface
);
189 HRESULT hres
= DS_OK
;
191 TRACE("(%p,%d)\n",This
,vol
);
193 if (!(This
->dsbd
.dwFlags
& DSBCAPS_CTRLVOLUME
)) {
194 WARN("control unavailable: This->dsbd.dwFlags = 0x%08x\n", This
->dsbd
.dwFlags
);
195 return DSERR_CONTROLUNAVAIL
;
198 if ((vol
> DSBVOLUME_MAX
) || (vol
< DSBVOLUME_MIN
)) {
199 WARN("invalid parameter: vol = %d\n", vol
);
200 return DSERR_INVALIDPARAM
;
204 RtlAcquireResourceExclusive(&This
->lock
, TRUE
);
206 if (This
->dsbd
.dwFlags
& DSBCAPS_CTRL3D
) {
207 oldVol
= This
->ds3db_lVolume
;
208 This
->ds3db_lVolume
= vol
;
210 /* recalc 3d volume, which in turn recalcs the pans */
211 DSOUND_Calc3DBuffer(This
);
213 oldVol
= This
->volpan
.lVolume
;
214 This
->volpan
.lVolume
= vol
;
216 DSOUND_RecalcVolPan(&(This
->volpan
));
219 RtlReleaseResource(&This
->lock
);
225 static HRESULT WINAPI
IDirectSoundBufferImpl_GetVolume(IDirectSoundBuffer8
*iface
, LONG
*vol
)
227 IDirectSoundBufferImpl
*This
= impl_from_IDirectSoundBuffer8(iface
);
229 TRACE("(%p,%p)\n",This
,vol
);
231 if (!(This
->dsbd
.dwFlags
& DSBCAPS_CTRLVOLUME
)) {
232 WARN("control unavailable\n");
233 return DSERR_CONTROLUNAVAIL
;
237 WARN("invalid parameter: vol == NULL\n");
238 return DSERR_INVALIDPARAM
;
241 *vol
= This
->volpan
.lVolume
;
246 static HRESULT WINAPI
IDirectSoundBufferImpl_SetFrequency(IDirectSoundBuffer8
*iface
, DWORD freq
)
248 IDirectSoundBufferImpl
*This
= impl_from_IDirectSoundBuffer8(iface
);
251 TRACE("(%p,%d)\n",This
,freq
);
253 if (is_primary_buffer(This
)) {
254 WARN("not available for primary buffers.\n");
255 return DSERR_CONTROLUNAVAIL
;
258 if (!(This
->dsbd
.dwFlags
& DSBCAPS_CTRLFREQUENCY
)) {
259 WARN("control unavailable\n");
260 return DSERR_CONTROLUNAVAIL
;
263 if (freq
== DSBFREQUENCY_ORIGINAL
)
264 freq
= This
->pwfx
->nSamplesPerSec
;
266 if ((freq
< DSBFREQUENCY_MIN
) || (freq
> DSBFREQUENCY_MAX
)) {
267 WARN("invalid parameter: freq = %d\n", freq
);
268 return DSERR_INVALIDPARAM
;
272 RtlAcquireResourceExclusive(&This
->lock
, TRUE
);
274 oldFreq
= This
->freq
;
276 if (freq
!= oldFreq
) {
277 This
->freqAdjustNum
= This
->freq
;
278 This
->freqAdjustDen
= This
->device
->pwfx
->nSamplesPerSec
;
279 This
->nAvgBytesPerSec
= freq
* This
->pwfx
->nBlockAlign
;
280 DSOUND_RecalcFormat(This
);
283 RtlReleaseResource(&This
->lock
);
289 static HRESULT WINAPI
IDirectSoundBufferImpl_Play(IDirectSoundBuffer8
*iface
, DWORD reserved1
,
290 DWORD reserved2
, DWORD flags
)
292 IDirectSoundBufferImpl
*This
= impl_from_IDirectSoundBuffer8(iface
);
293 HRESULT hres
= DS_OK
;
296 TRACE("(%p,%08x,%08x,%08x)\n",This
,reserved1
,reserved2
,flags
);
299 RtlAcquireResourceExclusive(&This
->lock
, TRUE
);
301 This
->playflags
= flags
;
302 if (This
->state
== STATE_STOPPED
) {
304 This
->state
= STATE_STARTING
;
305 } else if (This
->state
== STATE_STOPPING
)
306 This
->state
= STATE_PLAYING
;
308 for (i
= 0; i
< This
->num_filters
; i
++) {
309 IMediaObject_Discontinuity(This
->filters
[i
].obj
, 0);
312 RtlReleaseResource(&This
->lock
);
318 static HRESULT WINAPI
IDirectSoundBufferImpl_Stop(IDirectSoundBuffer8
*iface
)
320 IDirectSoundBufferImpl
*This
= impl_from_IDirectSoundBuffer8(iface
);
321 HRESULT hres
= DS_OK
;
323 TRACE("(%p)\n",This
);
326 RtlAcquireResourceExclusive(&This
->lock
, TRUE
);
328 if (This
->state
== STATE_PLAYING
)
329 This
->state
= STATE_STOPPING
;
330 else if (This
->state
== STATE_STARTING
)
332 This
->state
= STATE_STOPPED
;
333 DSOUND_CheckEvent(This
, 0, 0);
336 RtlReleaseResource(&This
->lock
);
342 static ULONG WINAPI
IDirectSoundBufferImpl_AddRef(IDirectSoundBuffer8
*iface
)
344 IDirectSoundBufferImpl
*This
= impl_from_IDirectSoundBuffer8(iface
);
345 ULONG ref
= InterlockedIncrement(&This
->ref
);
347 TRACE("(%p) ref was %d\n", This
, ref
- 1);
350 InterlockedIncrement(&This
->numIfaces
);
355 static ULONG WINAPI
IDirectSoundBufferImpl_Release(IDirectSoundBuffer8
*iface
)
357 IDirectSoundBufferImpl
*This
= impl_from_IDirectSoundBuffer8(iface
);
360 if (is_primary_buffer(This
)){
361 ref
= capped_refcount_dec(&This
->ref
);
363 capped_refcount_dec(&This
->numIfaces
);
364 TRACE("(%p) ref is now: %d\n", This
, ref
);
368 ref
= InterlockedDecrement(&This
->ref
);
369 if (!ref
&& !InterlockedDecrement(&This
->numIfaces
))
370 secondarybuffer_destroy(This
);
372 TRACE("(%p) ref is now %d\n", This
, ref
);
377 static HRESULT WINAPI
IDirectSoundBufferImpl_GetCurrentPosition(IDirectSoundBuffer8
*iface
,
378 DWORD
*playpos
, DWORD
*writepos
)
380 IDirectSoundBufferImpl
*This
= impl_from_IDirectSoundBuffer8(iface
);
383 TRACE("(%p,%p,%p)\n",This
,playpos
,writepos
);
385 RtlAcquireResourceShared(&This
->lock
, TRUE
);
387 pos
= This
->sec_mixpos
;
390 if (pos
>= This
->buflen
){
391 FIXME("Bad play position. playpos: %d, buflen: %d\n", pos
, This
->buflen
);
400 if (writepos
&& This
->state
!= STATE_STOPPED
) {
401 /* apply the documented 10ms lead to writepos */
402 *writepos
+= This
->writelead
;
403 *writepos
%= This
->buflen
;
406 RtlReleaseResource(&This
->lock
);
408 TRACE("playpos = %d, writepos = %d, buflen=%d (%p, time=%d)\n",
409 playpos
?*playpos
:-1, writepos
?*writepos
:-1, This
->buflen
, This
, GetTickCount());
414 static HRESULT WINAPI
IDirectSoundBufferImpl_GetStatus(IDirectSoundBuffer8
*iface
, DWORD
*status
)
416 IDirectSoundBufferImpl
*This
= impl_from_IDirectSoundBuffer8(iface
);
418 TRACE("(%p,%p)\n",This
,status
);
420 if (status
== NULL
) {
421 WARN("invalid parameter: status = NULL\n");
422 return DSERR_INVALIDPARAM
;
426 RtlAcquireResourceShared(&This
->lock
, TRUE
);
427 if ((This
->state
== STATE_STARTING
) || (This
->state
== STATE_PLAYING
)) {
428 *status
|= DSBSTATUS_PLAYING
;
429 if (This
->playflags
& DSBPLAY_LOOPING
)
430 *status
|= DSBSTATUS_LOOPING
;
432 RtlReleaseResource(&This
->lock
);
434 TRACE("status=%x\n", *status
);
439 static HRESULT WINAPI
IDirectSoundBufferImpl_GetFormat(IDirectSoundBuffer8
*iface
,
440 LPWAVEFORMATEX lpwf
, DWORD wfsize
, DWORD
*wfwritten
)
442 IDirectSoundBufferImpl
*This
= impl_from_IDirectSoundBuffer8(iface
);
445 TRACE("(%p,%p,%d,%p)\n",This
,lpwf
,wfsize
,wfwritten
);
447 size
= sizeof(WAVEFORMATEX
) + This
->pwfx
->cbSize
;
449 if (lpwf
) { /* NULL is valid */
450 if (wfsize
>= size
) {
451 CopyMemory(lpwf
,This
->pwfx
,size
);
455 WARN("invalid parameter: wfsize too small\n");
456 CopyMemory(lpwf
,This
->pwfx
,wfsize
);
459 return DSERR_INVALIDPARAM
;
463 *wfwritten
= sizeof(WAVEFORMATEX
) + This
->pwfx
->cbSize
;
465 WARN("invalid parameter: wfwritten == NULL\n");
466 return DSERR_INVALIDPARAM
;
473 static HRESULT WINAPI
IDirectSoundBufferImpl_Lock(IDirectSoundBuffer8
*iface
, DWORD writecursor
,
474 DWORD writebytes
, void **lplpaudioptr1
, DWORD
*audiobytes1
, void **lplpaudioptr2
,
475 DWORD
*audiobytes2
, DWORD flags
)
477 IDirectSoundBufferImpl
*This
= impl_from_IDirectSoundBuffer8(iface
);
478 HRESULT hres
= DS_OK
;
480 TRACE("(%p,%d,%d,%p,%p,%p,%p,0x%08x) at %d\n", This
, writecursor
, writebytes
, lplpaudioptr1
,
481 audiobytes1
, lplpaudioptr2
, audiobytes2
, flags
, GetTickCount());
484 return DSERR_INVALIDPARAM
;
486 /* when this flag is set, writecursor is meaningless and must be calculated */
487 if (flags
& DSBLOCK_FROMWRITECURSOR
) {
488 /* GetCurrentPosition does too much magic to duplicate here */
489 hres
= IDirectSoundBufferImpl_GetCurrentPosition(iface
, NULL
, &writecursor
);
491 WARN("IDirectSoundBufferImpl_GetCurrentPosition failed\n");
496 /* when this flag is set, writebytes is meaningless and must be set */
497 if (flags
& DSBLOCK_ENTIREBUFFER
)
498 writebytes
= This
->buflen
;
500 if (writecursor
>= This
->buflen
) {
501 WARN("Invalid parameter, writecursor: %u >= buflen: %u\n",
502 writecursor
, This
->buflen
);
503 return DSERR_INVALIDPARAM
;
506 if (writebytes
> This
->buflen
) {
507 WARN("Invalid parameter, writebytes: %u > buflen: %u\n",
508 writebytes
, This
->buflen
);
509 return DSERR_INVALIDPARAM
;
513 RtlAcquireResourceShared(&This
->lock
, TRUE
);
515 if (writecursor
+writebytes
<= This
->buflen
) {
516 *(LPBYTE
*)lplpaudioptr1
= This
->buffer
->memory
+writecursor
;
517 if (This
->sec_mixpos
>= writecursor
&& This
->sec_mixpos
< writecursor
+ writebytes
&& This
->state
== STATE_PLAYING
)
518 WARN("Overwriting mixing position, case 1\n");
519 *audiobytes1
= writebytes
;
521 *(LPBYTE
*)lplpaudioptr2
= NULL
;
524 TRACE("Locked %p(%i bytes) and %p(%i bytes) writecursor=%d\n",
525 *(LPBYTE
*)lplpaudioptr1
, *audiobytes1
, lplpaudioptr2
? *(LPBYTE
*)lplpaudioptr2
: NULL
, audiobytes2
? *audiobytes2
: 0, writecursor
);
526 TRACE("->%d.0\n",writebytes
);
527 This
->buffer
->lockedbytes
+= writebytes
;
529 DWORD remainder
= writebytes
+ writecursor
- This
->buflen
;
530 *(LPBYTE
*)lplpaudioptr1
= This
->buffer
->memory
+writecursor
;
531 *audiobytes1
= This
->buflen
-writecursor
;
532 This
->buffer
->lockedbytes
+= *audiobytes1
;
533 if (This
->sec_mixpos
>= writecursor
&& This
->sec_mixpos
< writecursor
+ writebytes
&& This
->state
== STATE_PLAYING
)
534 WARN("Overwriting mixing position, case 2\n");
536 *(LPBYTE
*)lplpaudioptr2
= This
->buffer
->memory
;
538 *audiobytes2
= writebytes
-(This
->buflen
-writecursor
);
539 This
->buffer
->lockedbytes
+= *audiobytes2
;
541 if (audiobytes2
&& This
->sec_mixpos
< remainder
&& This
->state
== STATE_PLAYING
)
542 WARN("Overwriting mixing position, case 3\n");
543 TRACE("Locked %p(%i bytes) and %p(%i bytes) writecursor=%d\n", *(LPBYTE
*)lplpaudioptr1
, *audiobytes1
, lplpaudioptr2
? *(LPBYTE
*)lplpaudioptr2
: NULL
, audiobytes2
? *audiobytes2
: 0, writecursor
);
546 RtlReleaseResource(&This
->lock
);
552 static HRESULT WINAPI
IDirectSoundBufferImpl_SetCurrentPosition(IDirectSoundBuffer8
*iface
,
555 IDirectSoundBufferImpl
*This
= impl_from_IDirectSoundBuffer8(iface
);
556 HRESULT hres
= DS_OK
;
558 TRACE("(%p,%d)\n",This
,newpos
);
561 RtlAcquireResourceExclusive(&This
->lock
, TRUE
);
563 /* start mixing from this new location instead */
564 newpos
%= This
->buflen
;
565 newpos
-= newpos
%This
->pwfx
->nBlockAlign
;
566 This
->sec_mixpos
= newpos
;
568 /* at this point, do not attempt to reset buffers, mess with primary mix position,
569 or anything like that to reduce latency. The data already prebuffered cannot be changed */
571 RtlReleaseResource(&This
->lock
);
577 static HRESULT WINAPI
IDirectSoundBufferImpl_SetPan(IDirectSoundBuffer8
*iface
, LONG pan
)
579 IDirectSoundBufferImpl
*This
= impl_from_IDirectSoundBuffer8(iface
);
580 HRESULT hres
= DS_OK
;
582 TRACE("(%p,%d)\n",This
,pan
);
584 if ((pan
> DSBPAN_RIGHT
) || (pan
< DSBPAN_LEFT
)) {
585 WARN("invalid parameter: pan = %d\n", pan
);
586 return DSERR_INVALIDPARAM
;
589 if (!(This
->dsbd
.dwFlags
& DSBCAPS_CTRLPAN
)) {
590 WARN("control unavailable\n");
591 return DSERR_CONTROLUNAVAIL
;
595 RtlAcquireResourceExclusive(&This
->lock
, TRUE
);
597 if (This
->volpan
.lPan
!= pan
) {
598 This
->volpan
.lPan
= pan
;
599 DSOUND_RecalcVolPan(&(This
->volpan
));
602 RtlReleaseResource(&This
->lock
);
608 static HRESULT WINAPI
IDirectSoundBufferImpl_GetPan(IDirectSoundBuffer8
*iface
, LONG
*pan
)
610 IDirectSoundBufferImpl
*This
= impl_from_IDirectSoundBuffer8(iface
);
612 TRACE("(%p,%p)\n",This
,pan
);
614 if (!(This
->dsbd
.dwFlags
& DSBCAPS_CTRLPAN
)) {
615 WARN("control unavailable\n");
616 return DSERR_CONTROLUNAVAIL
;
620 WARN("invalid parameter: pan = NULL\n");
621 return DSERR_INVALIDPARAM
;
624 *pan
= This
->volpan
.lPan
;
629 static HRESULT WINAPI
IDirectSoundBufferImpl_Unlock(IDirectSoundBuffer8
*iface
, void *p1
, DWORD x1
,
632 IDirectSoundBufferImpl
*This
= impl_from_IDirectSoundBuffer8(iface
), *iter
;
633 HRESULT hres
= DS_OK
;
635 TRACE("(%p,%p,%d,%p,%d)\n", This
,p1
,x1
,p2
,x2
);
640 if((p1
&& ((BYTE
*)p1
< This
->buffer
->memory
|| (BYTE
*)p1
>= This
->buffer
->memory
+ This
->buflen
)) ||
641 (p2
&& ((BYTE
*)p2
< This
->buffer
->memory
|| (BYTE
*)p2
>= This
->buffer
->memory
+ This
->buflen
)))
642 return DSERR_INVALIDPARAM
;
646 RtlAcquireResourceShared(&This
->device
->buffer_list_lock
, TRUE
);
647 LIST_FOR_EACH_ENTRY(iter
, &This
->buffer
->buffers
, IDirectSoundBufferImpl
, entry
)
649 RtlAcquireResourceShared(&iter
->lock
, TRUE
);
652 if(x1
+ (DWORD_PTR
)p1
- (DWORD_PTR
)iter
->buffer
->memory
> iter
->buflen
)
653 hres
= DSERR_INVALIDPARAM
;
655 iter
->buffer
->lockedbytes
-= x1
;
660 if(x2
+ (DWORD_PTR
)p2
- (DWORD_PTR
)iter
->buffer
->memory
> iter
->buflen
)
661 hres
= DSERR_INVALIDPARAM
;
663 iter
->buffer
->lockedbytes
-= x2
;
665 RtlReleaseResource(&iter
->lock
);
667 RtlReleaseResource(&This
->device
->buffer_list_lock
);
673 static HRESULT WINAPI
IDirectSoundBufferImpl_Restore(IDirectSoundBuffer8
*iface
)
675 IDirectSoundBufferImpl
*This
= impl_from_IDirectSoundBuffer8(iface
);
677 FIXME("(%p):stub\n",This
);
681 static HRESULT WINAPI
IDirectSoundBufferImpl_GetFrequency(IDirectSoundBuffer8
*iface
, DWORD
*freq
)
683 IDirectSoundBufferImpl
*This
= impl_from_IDirectSoundBuffer8(iface
);
685 TRACE("(%p,%p)\n",This
,freq
);
688 WARN("invalid parameter: freq = NULL\n");
689 return DSERR_INVALIDPARAM
;
693 TRACE("-> %d\n", *freq
);
698 static HRESULT WINAPI
IDirectSoundBufferImpl_SetFX(IDirectSoundBuffer8
*iface
, DWORD dwEffectsCount
,
699 LPDSEFFECTDESC pDSFXDesc
, DWORD
*pdwResultCodes
)
701 IDirectSoundBufferImpl
*This
= impl_from_IDirectSoundBuffer8(iface
);
708 TRACE("(%p,%u,%p,%p)\n", This
, dwEffectsCount
, pDSFXDesc
, pdwResultCodes
);
711 for (u
=0; u
<dwEffectsCount
; u
++) pdwResultCodes
[u
] = DSFXR_UNKNOWN
;
713 if ((dwEffectsCount
> 0 && !pDSFXDesc
) ||
714 (dwEffectsCount
== 0 && (pDSFXDesc
|| pdwResultCodes
))
718 if (!(This
->dsbd
.dwFlags
& DSBCAPS_CTRLFX
)) {
719 WARN("attempted to call SetFX on buffer without DSBCAPS_CTRLFX\n");
720 return DSERR_CONTROLUNAVAIL
;
723 if (This
->state
!= STATE_STOPPED
)
724 return DSERR_INVALIDCALL
;
726 if (This
->buffer
->lockedbytes
> 0)
727 return DSERR_INVALIDCALL
;
729 if (dwEffectsCount
== 0) {
730 if (This
->num_filters
> 0) {
731 for (u
= 0; u
< This
->num_filters
; u
++) {
732 IMediaObject_Release(This
->filters
[u
].obj
);
734 HeapFree(GetProcessHeap(), 0, This
->filters
);
736 This
->filters
= NULL
;
737 This
->num_filters
= 0;
743 filters
= HeapAlloc(GetProcessHeap(), 0, dwEffectsCount
* sizeof(DSFilter
));
745 WARN("out of memory\n");
746 return DSERR_OUTOFMEMORY
;
751 wfx
.wFormatTag
= WAVE_FORMAT_IEEE_FLOAT
;
752 wfx
.nChannels
= This
->pwfx
->nChannels
;
753 wfx
.nSamplesPerSec
= This
->pwfx
->nSamplesPerSec
;
754 wfx
.wBitsPerSample
= sizeof(float) * 8;
755 wfx
.nBlockAlign
= (wfx
.nChannels
* wfx
.wBitsPerSample
)/8;
756 wfx
.nAvgBytesPerSec
= wfx
.nSamplesPerSec
* wfx
.nBlockAlign
;
757 wfx
.cbSize
= sizeof(wfx
);
759 dmt
.majortype
= KSDATAFORMAT_TYPE_AUDIO
;
760 dmt
.subtype
= KSDATAFORMAT_SUBTYPE_IEEE_FLOAT
;
761 dmt
.bFixedSizeSamples
= TRUE
;
762 dmt
.bTemporalCompression
= FALSE
;
763 dmt
.lSampleSize
= sizeof(float) * This
->pwfx
->nChannels
/ 8;
764 dmt
.formattype
= FORMAT_WaveFormatEx
;
766 dmt
.cbFormat
= sizeof(WAVEFORMATEX
);
767 dmt
.pbFormat
= (BYTE
*)&wfx
;
769 for (u
= 0; u
< dwEffectsCount
; u
++) {
770 hr2
= CoCreateInstance(&pDSFXDesc
[u
].guidDSFXClass
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IMediaObject
, (LPVOID
*)&filters
[u
].obj
);
772 if (SUCCEEDED(hr2
)) {
773 hr2
= IMediaObject_SetInputType(filters
[u
].obj
, 0, &dmt
, 0);
775 WARN("Could not set DMO input type\n");
778 if (SUCCEEDED(hr2
)) {
779 hr2
= IMediaObject_SetOutputType(filters
[u
].obj
, 0, &dmt
, 0);
781 WARN("Could not set DMO output type\n");
789 pdwResultCodes
[u
] = (hr2
== REGDB_E_CLASSNOTREG
) ? DSFXR_UNKNOWN
: DSFXR_FAILED
;
792 pdwResultCodes
[u
] = DSFXR_LOCSOFTWARE
;
797 for (u
= 0; u
< dwEffectsCount
; u
++) {
799 pdwResultCodes
[u
] = (pdwResultCodes
[u
] != DSFXR_UNKNOWN
) ? DSFXR_PRESENT
: DSFXR_UNKNOWN
;
802 IMediaObject_Release(filters
[u
].obj
);
805 HeapFree(GetProcessHeap(), 0, filters
);
807 if (This
->num_filters
> 0) {
808 for (u
= 0; u
< This
->num_filters
; u
++) {
809 IMediaObject_Release(This
->filters
[u
].obj
);
810 if (This
->filters
[u
].inplace
) IMediaObjectInPlace_Release(This
->filters
[u
].inplace
);
812 HeapFree(GetProcessHeap(), 0, This
->filters
);
815 for (u
= 0; u
< dwEffectsCount
; u
++) {
816 memcpy(&filters
[u
].guid
, &pDSFXDesc
[u
].guidDSFXClass
, sizeof(GUID
));
817 if (FAILED(IMediaObject_QueryInterface(filters
[u
].obj
, &IID_IMediaObjectInPlace
, (void*)&filters
[u
].inplace
)))
818 filters
[u
].inplace
= NULL
;
821 This
->filters
= filters
;
822 This
->num_filters
= dwEffectsCount
;
828 static HRESULT WINAPI
IDirectSoundBufferImpl_AcquireResources(IDirectSoundBuffer8
*iface
,
829 DWORD dwFlags
, DWORD dwEffectsCount
, DWORD
*pdwResultCodes
)
831 IDirectSoundBufferImpl
*This
= impl_from_IDirectSoundBuffer8(iface
);
834 FIXME("(%p,%08u,%u,%p): stub, faking success\n",This
,dwFlags
,dwEffectsCount
,pdwResultCodes
);
837 for (u
=0; u
<dwEffectsCount
; u
++) pdwResultCodes
[u
] = DSFXR_UNKNOWN
;
839 WARN("control unavailable\n");
843 static HRESULT WINAPI
IDirectSoundBufferImpl_GetObjectInPath(IDirectSoundBuffer8
*iface
,
844 REFGUID rguidObject
, DWORD dwIndex
, REFGUID rguidInterface
, void **ppObject
)
846 IDirectSoundBufferImpl
*This
= impl_from_IDirectSoundBuffer8(iface
);
848 TRACE("(%p,%s,%u,%s,%p)\n",This
,debugstr_guid(rguidObject
),dwIndex
,debugstr_guid(rguidInterface
),ppObject
);
850 if (dwIndex
>= This
->num_filters
)
851 return DSERR_CONTROLUNAVAIL
;
856 if (IsEqualGUID(rguidObject
, &This
->filters
[dwIndex
].guid
) || IsEqualGUID(rguidObject
, &GUID_All_Objects
)) {
857 if (SUCCEEDED(IMediaObject_QueryInterface(This
->filters
[dwIndex
].obj
, rguidInterface
, ppObject
)))
860 return E_NOINTERFACE
;
862 WARN("control unavailable\n");
863 return DSERR_OBJECTNOTFOUND
;
867 static HRESULT WINAPI
IDirectSoundBufferImpl_Initialize(IDirectSoundBuffer8
*iface
,
868 IDirectSound
*dsound
, LPCDSBUFFERDESC dbsd
)
870 IDirectSoundBufferImpl
*This
= impl_from_IDirectSoundBuffer8(iface
);
872 WARN("(%p) already initialized\n", This
);
873 return DSERR_ALREADYINITIALIZED
;
876 static HRESULT WINAPI
IDirectSoundBufferImpl_GetCaps(IDirectSoundBuffer8
*iface
, LPDSBCAPS caps
)
878 IDirectSoundBufferImpl
*This
= impl_from_IDirectSoundBuffer8(iface
);
880 TRACE("(%p)->(%p)\n",This
,caps
);
883 WARN("invalid parameter: caps == NULL\n");
884 return DSERR_INVALIDPARAM
;
887 if (caps
->dwSize
< sizeof(*caps
)) {
888 WARN("invalid parameter: caps->dwSize = %d\n",caps
->dwSize
);
889 return DSERR_INVALIDPARAM
;
892 caps
->dwFlags
= This
->dsbd
.dwFlags
;
893 caps
->dwFlags
|= DSBCAPS_LOCSOFTWARE
;
895 caps
->dwBufferBytes
= This
->buflen
;
897 /* According to windows, this is zero*/
898 caps
->dwUnlockTransferRate
= 0;
899 caps
->dwPlayCpuOverhead
= 0;
904 static HRESULT WINAPI
IDirectSoundBufferImpl_QueryInterface(IDirectSoundBuffer8
*iface
, REFIID riid
,
907 IDirectSoundBufferImpl
*This
= impl_from_IDirectSoundBuffer8(iface
);
909 TRACE("(%p,%s,%p)\n",This
,debugstr_guid(riid
),ppobj
);
912 WARN("invalid parameter\n");
916 *ppobj
= NULL
; /* assume failure */
918 if ( IsEqualGUID(riid
, &IID_IUnknown
) ||
919 IsEqualGUID(riid
, &IID_IDirectSoundBuffer
) ||
920 IsEqualGUID(riid
, &IID_IDirectSoundBuffer8
) ) {
921 IDirectSoundBuffer8_AddRef(iface
);
926 if ( IsEqualGUID( &IID_IDirectSoundNotify
, riid
) ) {
927 IDirectSoundNotify_AddRef(&This
->IDirectSoundNotify_iface
);
928 *ppobj
= &This
->IDirectSoundNotify_iface
;
932 if ( IsEqualGUID( &IID_IDirectSound3DBuffer
, riid
) ) {
933 if(This
->dsbd
.dwFlags
& DSBCAPS_CTRL3D
){
934 IDirectSound3DBuffer_AddRef(&This
->IDirectSound3DBuffer_iface
);
935 *ppobj
= &This
->IDirectSound3DBuffer_iface
;
938 TRACE("app requested IDirectSound3DBuffer on non-3D secondary buffer\n");
939 return E_NOINTERFACE
;
942 if ( IsEqualGUID( &IID_IDirectSound3DListener
, riid
) ) {
943 ERR("app requested IDirectSound3DListener on secondary buffer\n");
944 return E_NOINTERFACE
;
947 if ( IsEqualGUID( &IID_IKsPropertySet
, riid
) ) {
948 IKsPropertySet_AddRef(&This
->IKsPropertySet_iface
);
949 *ppobj
= &This
->IKsPropertySet_iface
;
953 FIXME( "Unknown IID %s\n", debugstr_guid( riid
) );
955 return E_NOINTERFACE
;
958 static const IDirectSoundBuffer8Vtbl dsbvt
=
960 IDirectSoundBufferImpl_QueryInterface
,
961 IDirectSoundBufferImpl_AddRef
,
962 IDirectSoundBufferImpl_Release
,
963 IDirectSoundBufferImpl_GetCaps
,
964 IDirectSoundBufferImpl_GetCurrentPosition
,
965 IDirectSoundBufferImpl_GetFormat
,
966 IDirectSoundBufferImpl_GetVolume
,
967 IDirectSoundBufferImpl_GetPan
,
968 IDirectSoundBufferImpl_GetFrequency
,
969 IDirectSoundBufferImpl_GetStatus
,
970 IDirectSoundBufferImpl_Initialize
,
971 IDirectSoundBufferImpl_Lock
,
972 IDirectSoundBufferImpl_Play
,
973 IDirectSoundBufferImpl_SetCurrentPosition
,
974 IDirectSoundBufferImpl_SetFormat
,
975 IDirectSoundBufferImpl_SetVolume
,
976 IDirectSoundBufferImpl_SetPan
,
977 IDirectSoundBufferImpl_SetFrequency
,
978 IDirectSoundBufferImpl_Stop
,
979 IDirectSoundBufferImpl_Unlock
,
980 IDirectSoundBufferImpl_Restore
,
981 IDirectSoundBufferImpl_SetFX
,
982 IDirectSoundBufferImpl_AcquireResources
,
983 IDirectSoundBufferImpl_GetObjectInPath
986 HRESULT
secondarybuffer_create(DirectSoundDevice
*device
, const DSBUFFERDESC
*dsbd
,
987 IDirectSoundBuffer
**buffer
)
989 IDirectSoundBufferImpl
*dsb
;
990 LPWAVEFORMATEX wfex
= dsbd
->lpwfxFormat
;
994 TRACE("(%p,%p,%p)\n", device
, dsbd
, buffer
);
996 if (dsbd
->dwBufferBytes
< DSBSIZE_MIN
|| dsbd
->dwBufferBytes
> DSBSIZE_MAX
) {
997 WARN("invalid parameter: dsbd->dwBufferBytes = %d\n", dsbd
->dwBufferBytes
);
998 return DSERR_INVALIDPARAM
; /* FIXME: which error? */
1001 dsb
= HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY
,sizeof(*dsb
));
1004 return DSERR_OUTOFMEMORY
;
1006 TRACE("Created buffer at %p\n", dsb
);
1013 dsb
->device
= device
;
1014 dsb
->IDirectSoundBuffer8_iface
.lpVtbl
= &dsbvt
;
1015 dsb
->IDirectSoundNotify_iface
.lpVtbl
= &dsnvt
;
1016 dsb
->IDirectSound3DBuffer_iface
.lpVtbl
= &ds3dbvt
;
1017 dsb
->IKsPropertySet_iface
.lpVtbl
= &iksbvt
;
1019 /* size depends on version */
1020 CopyMemory(&dsb
->dsbd
, dsbd
, dsbd
->dwSize
);
1022 dsb
->pwfx
= DSOUND_CopyFormat(wfex
);
1024 IDirectSoundBuffer8_Release(&dsb
->IDirectSoundBuffer8_iface
);
1025 return DSERR_OUTOFMEMORY
;
1028 if (dsbd
->dwBufferBytes
% dsbd
->lpwfxFormat
->nBlockAlign
)
1029 dsb
->buflen
= dsbd
->dwBufferBytes
+
1030 (dsbd
->lpwfxFormat
->nBlockAlign
-
1031 (dsbd
->dwBufferBytes
% dsbd
->lpwfxFormat
->nBlockAlign
));
1033 dsb
->buflen
= dsbd
->dwBufferBytes
;
1035 dsb
->freq
= dsbd
->lpwfxFormat
->nSamplesPerSec
;
1036 dsb
->notifies
= NULL
;
1037 dsb
->nrofnotifies
= 0;
1039 /* Check necessary hardware mixing capabilities */
1040 if (wfex
->nChannels
==2) capf
|= DSCAPS_SECONDARYSTEREO
;
1041 else capf
|= DSCAPS_SECONDARYMONO
;
1042 if (wfex
->wBitsPerSample
==16) capf
|= DSCAPS_SECONDARY16BIT
;
1043 else capf
|= DSCAPS_SECONDARY8BIT
;
1045 TRACE("capf = 0x%08x, device->drvcaps.dwFlags = 0x%08x\n", capf
, device
->drvcaps
.dwFlags
);
1047 /* Allocate an empty buffer */
1048 dsb
->buffer
= HeapAlloc(GetProcessHeap(),0,sizeof(*(dsb
->buffer
)));
1050 IDirectSoundBuffer8_Release(&dsb
->IDirectSoundBuffer8_iface
);
1051 return DSERR_OUTOFMEMORY
;
1054 /* Allocate system memory for buffer */
1055 dsb
->buffer
->memory
= HeapAlloc(GetProcessHeap(),0,dsb
->buflen
);
1056 if (!dsb
->buffer
->memory
) {
1057 WARN("out of memory\n");
1058 IDirectSoundBuffer8_Release(&dsb
->IDirectSoundBuffer8_iface
);
1059 return DSERR_OUTOFMEMORY
;
1062 dsb
->buffer
->ref
= 1;
1063 dsb
->buffer
->lockedbytes
= 0;
1064 list_init(&dsb
->buffer
->buffers
);
1065 list_add_head(&dsb
->buffer
->buffers
, &dsb
->entry
);
1066 FillMemory(dsb
->buffer
->memory
, dsb
->buflen
, dsbd
->lpwfxFormat
->wBitsPerSample
== 8 ? 128 : 0);
1068 /* It's not necessary to initialize values to zero since */
1069 /* we allocated this structure with HEAP_ZERO_MEMORY... */
1070 dsb
->sec_mixpos
= 0;
1071 dsb
->state
= STATE_STOPPED
;
1073 dsb
->freqAdjustNum
= dsb
->freq
;
1074 dsb
->freqAdjustDen
= device
->pwfx
->nSamplesPerSec
;
1075 dsb
->nAvgBytesPerSec
= dsb
->freq
*
1076 dsbd
->lpwfxFormat
->nBlockAlign
;
1078 /* calculate fragment size and write lead */
1079 DSOUND_RecalcFormat(dsb
);
1081 if (dsb
->dsbd
.dwFlags
& DSBCAPS_CTRL3D
) {
1082 dsb
->ds3db_ds3db
.dwSize
= sizeof(DS3DBUFFER
);
1083 dsb
->ds3db_ds3db
.vPosition
.x
= 0.0;
1084 dsb
->ds3db_ds3db
.vPosition
.y
= 0.0;
1085 dsb
->ds3db_ds3db
.vPosition
.z
= 0.0;
1086 dsb
->ds3db_ds3db
.vVelocity
.x
= 0.0;
1087 dsb
->ds3db_ds3db
.vVelocity
.y
= 0.0;
1088 dsb
->ds3db_ds3db
.vVelocity
.z
= 0.0;
1089 dsb
->ds3db_ds3db
.dwInsideConeAngle
= DS3D_DEFAULTCONEANGLE
;
1090 dsb
->ds3db_ds3db
.dwOutsideConeAngle
= DS3D_DEFAULTCONEANGLE
;
1091 dsb
->ds3db_ds3db
.vConeOrientation
.x
= 0.0;
1092 dsb
->ds3db_ds3db
.vConeOrientation
.y
= 0.0;
1093 dsb
->ds3db_ds3db
.vConeOrientation
.z
= 0.0;
1094 dsb
->ds3db_ds3db
.lConeOutsideVolume
= DS3D_DEFAULTCONEOUTSIDEVOLUME
;
1095 dsb
->ds3db_ds3db
.flMinDistance
= DS3D_DEFAULTMINDISTANCE
;
1096 dsb
->ds3db_ds3db
.flMaxDistance
= DS3D_DEFAULTMAXDISTANCE
;
1097 dsb
->ds3db_ds3db
.dwMode
= DS3DMODE_NORMAL
;
1099 dsb
->ds3db_need_recalc
= FALSE
;
1100 DSOUND_Calc3DBuffer(dsb
);
1102 DSOUND_RecalcVolPan(&(dsb
->volpan
));
1104 RtlInitializeResource(&dsb
->lock
);
1106 /* register buffer */
1107 err
= DirectSoundDevice_AddBuffer(device
, dsb
);
1109 *buffer
= (IDirectSoundBuffer
*)&dsb
->IDirectSoundBuffer8_iface
;
1111 IDirectSoundBuffer8_Release(&dsb
->IDirectSoundBuffer8_iface
);
1116 void secondarybuffer_destroy(IDirectSoundBufferImpl
*This
)
1118 ULONG ref
= InterlockedIncrement(&This
->numIfaces
);
1121 WARN("Destroying buffer with %u in use interfaces\n", ref
- 1);
1123 if (This
->dsbd
.dwFlags
& DSBCAPS_LOCHARDWARE
)
1124 This
->device
->drvcaps
.dwFreeHwMixingAllBuffers
++;
1126 DirectSoundDevice_RemoveBuffer(This
->device
, This
);
1127 RtlDeleteResource(&This
->lock
);
1129 This
->buffer
->ref
--;
1130 list_remove(&This
->entry
);
1131 if (This
->buffer
->ref
== 0) {
1132 HeapFree(GetProcessHeap(), 0, This
->buffer
->memory
);
1133 HeapFree(GetProcessHeap(), 0, This
->buffer
);
1136 HeapFree(GetProcessHeap(), 0, This
->notifies
);
1137 HeapFree(GetProcessHeap(), 0, This
->pwfx
);
1139 if (This
->filters
) {
1141 for (i
= 0; i
< This
->num_filters
; i
++) {
1142 IMediaObject_Release(This
->filters
[i
].obj
);
1143 if (This
->filters
[i
].inplace
) IMediaObjectInPlace_Release(This
->filters
[i
].inplace
);
1145 HeapFree(GetProcessHeap(), 0, This
->filters
);
1148 HeapFree(GetProcessHeap(), 0, This
);
1150 TRACE("(%p) released\n", This
);
1153 HRESULT
IDirectSoundBufferImpl_Duplicate(
1154 DirectSoundDevice
*device
,
1155 IDirectSoundBufferImpl
**ppdsb
,
1156 IDirectSoundBufferImpl
*pdsb
)
1158 IDirectSoundBufferImpl
*dsb
;
1159 HRESULT hres
= DS_OK
;
1160 TRACE("(%p,%p,%p)\n", device
, ppdsb
, pdsb
);
1162 dsb
= HeapAlloc(GetProcessHeap(),0,sizeof(*dsb
));
1164 WARN("out of memory\n");
1166 return DSERR_OUTOFMEMORY
;
1169 RtlAcquireResourceShared(&pdsb
->lock
, TRUE
);
1171 CopyMemory(dsb
, pdsb
, sizeof(*dsb
));
1173 dsb
->pwfx
= DSOUND_CopyFormat(pdsb
->pwfx
);
1175 RtlReleaseResource(&pdsb
->lock
);
1177 if (dsb
->pwfx
== NULL
) {
1178 HeapFree(GetProcessHeap(),0,dsb
);
1180 return DSERR_OUTOFMEMORY
;
1184 list_add_head(&dsb
->buffer
->buffers
, &dsb
->entry
);
1190 dsb
->state
= STATE_STOPPED
;
1191 dsb
->sec_mixpos
= 0;
1192 dsb
->notifies
= NULL
;
1193 dsb
->nrofnotifies
= 0;
1194 dsb
->device
= device
;
1195 DSOUND_RecalcFormat(dsb
);
1197 RtlInitializeResource(&dsb
->lock
);
1199 /* register buffer */
1200 hres
= DirectSoundDevice_AddBuffer(device
, dsb
);
1201 if (hres
!= DS_OK
) {
1202 RtlDeleteResource(&dsb
->lock
);
1203 list_remove(&dsb
->entry
);
1205 HeapFree(GetProcessHeap(),0,dsb
->pwfx
);
1206 HeapFree(GetProcessHeap(),0,dsb
);
1209 IDirectSoundBuffer8_AddRef(&dsb
->IDirectSoundBuffer8_iface
);
1215 /*******************************************************************************
1219 static inline IDirectSoundBufferImpl
*impl_from_IKsPropertySet(IKsPropertySet
*iface
)
1221 return CONTAINING_RECORD(iface
, IDirectSoundBufferImpl
, IKsPropertySet_iface
);
1224 /* IUnknown methods */
1225 static HRESULT WINAPI
IKsPropertySetImpl_QueryInterface(IKsPropertySet
*iface
, REFIID riid
,
1228 IDirectSoundBufferImpl
*This
= impl_from_IKsPropertySet(iface
);
1230 TRACE("(%p,%s,%p)\n",This
,debugstr_guid(riid
),ppobj
);
1232 return IDirectSoundBuffer8_QueryInterface(&This
->IDirectSoundBuffer8_iface
, riid
, ppobj
);
1235 static ULONG WINAPI
IKsPropertySetImpl_AddRef(IKsPropertySet
*iface
)
1237 IDirectSoundBufferImpl
*This
= impl_from_IKsPropertySet(iface
);
1238 ULONG ref
= InterlockedIncrement(&This
->refiks
);
1240 TRACE("(%p) ref was %d\n", This
, ref
- 1);
1243 InterlockedIncrement(&This
->numIfaces
);
1248 static ULONG WINAPI
IKsPropertySetImpl_Release(IKsPropertySet
*iface
)
1250 IDirectSoundBufferImpl
*This
= impl_from_IKsPropertySet(iface
);
1253 if (is_primary_buffer(This
)){
1254 ref
= capped_refcount_dec(&This
->refiks
);
1256 capped_refcount_dec(&This
->numIfaces
);
1257 TRACE("(%p) ref is now: %d\n", This
, ref
);
1261 ref
= InterlockedDecrement(&This
->refiks
);
1262 if (!ref
&& !InterlockedDecrement(&This
->numIfaces
))
1263 secondarybuffer_destroy(This
);
1265 TRACE("(%p) ref is now %d\n", This
, ref
);
1270 static HRESULT WINAPI
IKsPropertySetImpl_Get(IKsPropertySet
*iface
, REFGUID guidPropSet
,
1271 ULONG dwPropID
, void *pInstanceData
, ULONG cbInstanceData
, void *pPropData
,
1272 ULONG cbPropData
, ULONG
*pcbReturned
)
1274 IDirectSoundBufferImpl
*This
= impl_from_IKsPropertySet(iface
);
1276 TRACE("(iface=%p,guidPropSet=%s,dwPropID=%d,pInstanceData=%p,cbInstanceData=%d,pPropData=%p,cbPropData=%d,pcbReturned=%p)\n",
1277 This
,debugstr_guid(guidPropSet
),dwPropID
,pInstanceData
,cbInstanceData
,pPropData
,cbPropData
,pcbReturned
);
1279 return E_PROP_ID_UNSUPPORTED
;
1282 static HRESULT WINAPI
IKsPropertySetImpl_Set(IKsPropertySet
*iface
, REFGUID guidPropSet
,
1283 ULONG dwPropID
, void *pInstanceData
, ULONG cbInstanceData
, void *pPropData
,
1286 IDirectSoundBufferImpl
*This
= impl_from_IKsPropertySet(iface
);
1288 TRACE("(%p,%s,%d,%p,%d,%p,%d)\n",This
,debugstr_guid(guidPropSet
),dwPropID
,pInstanceData
,cbInstanceData
,pPropData
,cbPropData
);
1290 return E_PROP_ID_UNSUPPORTED
;
1293 static HRESULT WINAPI
IKsPropertySetImpl_QuerySupport(IKsPropertySet
*iface
, REFGUID guidPropSet
,
1294 ULONG dwPropID
, ULONG
*pTypeSupport
)
1296 IDirectSoundBufferImpl
*This
= impl_from_IKsPropertySet(iface
);
1298 TRACE("(%p,%s,%d,%p)\n",This
,debugstr_guid(guidPropSet
),dwPropID
,pTypeSupport
);
1300 return E_PROP_ID_UNSUPPORTED
;
1303 const IKsPropertySetVtbl iksbvt
= {
1304 IKsPropertySetImpl_QueryInterface
,
1305 IKsPropertySetImpl_AddRef
,
1306 IKsPropertySetImpl_Release
,
1307 IKsPropertySetImpl_Get
,
1308 IKsPropertySetImpl_Set
,
1309 IKsPropertySetImpl_QuerySupport