2 * Direct Sound Audio Renderer
4 * Copyright 2004 Christian Costa
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 #include "quartz_private.h"
36 #include "wine/unicode.h"
37 #include "wine/debug.h"
39 WINE_DEFAULT_DEBUG_CHANNEL(quartz
);
41 /* NOTE: buffer can still be filled completely,
42 * but we start waiting until only this amount is buffered
44 static const REFERENCE_TIME DSoundRenderer_Max_Fill
= 150 * 10000;
46 static const IBaseFilterVtbl DSoundRender_Vtbl
;
47 static const IBasicAudioVtbl IBasicAudio_Vtbl
;
48 static const IReferenceClockVtbl IReferenceClock_Vtbl
;
49 static const IAMDirectSoundVtbl IAMDirectSound_Vtbl
;
50 static const IAMFilterMiscFlagsVtbl IAMFilterMiscFlags_Vtbl
;
52 typedef struct DSoundRenderImpl
54 BaseRenderer renderer
;
55 BasicAudio basicAudio
;
57 IReferenceClock IReferenceClock_iface
;
58 IAMDirectSound IAMDirectSound_iface
;
59 IAMFilterMiscFlags IAMFilterMiscFlags_iface
;
61 IDirectSound8
*dsound
;
62 LPDIRECTSOUNDBUFFER dsbuffer
;
65 DWORD last_playpos
, writepos
;
67 REFERENCE_TIME play_time
;
75 HANDLE advisethread
, thread_wait
;
78 static inline DSoundRenderImpl
*impl_from_BaseRenderer(BaseRenderer
*iface
)
80 return CONTAINING_RECORD(iface
, DSoundRenderImpl
, renderer
);
83 static inline DSoundRenderImpl
*impl_from_IBaseFilter(IBaseFilter
*iface
)
85 return CONTAINING_RECORD(iface
, DSoundRenderImpl
, renderer
.filter
.IBaseFilter_iface
);
88 static inline DSoundRenderImpl
*impl_from_IBasicAudio(IBasicAudio
*iface
)
90 return CONTAINING_RECORD(iface
, DSoundRenderImpl
, basicAudio
.IBasicAudio_iface
);
93 static inline DSoundRenderImpl
*impl_from_IReferenceClock(IReferenceClock
*iface
)
95 return CONTAINING_RECORD(iface
, DSoundRenderImpl
, IReferenceClock_iface
);
98 static inline DSoundRenderImpl
*impl_from_IAMDirectSound(IAMDirectSound
*iface
)
100 return CONTAINING_RECORD(iface
, DSoundRenderImpl
, IAMDirectSound_iface
);
103 static inline DSoundRenderImpl
*impl_from_IAMFilterMiscFlags(IAMFilterMiscFlags
*iface
)
105 return CONTAINING_RECORD(iface
, DSoundRenderImpl
, IAMFilterMiscFlags_iface
);
108 static REFERENCE_TIME
time_from_pos(DSoundRenderImpl
*This
, DWORD pos
) {
109 WAVEFORMATEX
*wfx
= (WAVEFORMATEX
*)This
->renderer
.pInputPin
->pin
.mtCurrent
.pbFormat
;
110 REFERENCE_TIME ret
= 10000000;
111 ret
= ret
* pos
/ wfx
->nAvgBytesPerSec
;
115 static DWORD
pos_from_time(DSoundRenderImpl
*This
, REFERENCE_TIME time
) {
116 WAVEFORMATEX
*wfx
= (WAVEFORMATEX
*)This
->renderer
.pInputPin
->pin
.mtCurrent
.pbFormat
;
117 REFERENCE_TIME ret
= time
;
118 ret
*= wfx
->nSamplesPerSec
;
120 ret
*= wfx
->nBlockAlign
;
124 static void DSoundRender_UpdatePositions(DSoundRenderImpl
*This
, DWORD
*seqwritepos
, DWORD
*minwritepos
) {
125 WAVEFORMATEX
*wfx
= (WAVEFORMATEX
*)This
->renderer
.pInputPin
->pin
.mtCurrent
.pbFormat
;
127 DWORD size1
, size2
, playpos
, writepos
, old_writepos
, old_playpos
, adv
;
128 BOOL writepos_set
= This
->writepos
< This
->buf_size
;
130 /* Update position and zero */
131 old_writepos
= This
->writepos
;
132 old_playpos
= This
->last_playpos
;
133 if (old_writepos
<= old_playpos
)
134 old_writepos
+= This
->buf_size
;
136 IDirectSoundBuffer_GetCurrentPosition(This
->dsbuffer
, &playpos
, &writepos
);
137 if (old_playpos
> playpos
) {
138 adv
= This
->buf_size
+ playpos
- old_playpos
;
139 This
->play_time
+= time_from_pos(This
, This
->buf_size
);
141 adv
= playpos
- old_playpos
;
142 This
->last_playpos
= playpos
;
144 TRACE("Moving from %u to %u: clearing %u bytes\n", old_playpos
, playpos
, adv
);
145 IDirectSoundBuffer_Lock(This
->dsbuffer
, old_playpos
, adv
, (void**)&buf1
, &size1
, (void**)&buf2
, &size2
, 0);
146 memset(buf1
, wfx
->wBitsPerSample
== 8 ? 128 : 0, size1
);
147 memset(buf2
, wfx
->wBitsPerSample
== 8 ? 128 : 0, size2
);
148 IDirectSoundBuffer_Unlock(This
->dsbuffer
, buf1
, size1
, buf2
, size2
);
150 *minwritepos
= writepos
;
151 if (!writepos_set
|| old_writepos
< writepos
) {
153 This
->writepos
= This
->buf_size
;
154 FIXME("Underrun of data occurred!\n");
156 *seqwritepos
= writepos
;
158 *seqwritepos
= This
->writepos
;
161 static HRESULT
DSoundRender_GetWritePos(DSoundRenderImpl
*This
, DWORD
*ret_writepos
, REFERENCE_TIME write_at
, DWORD
*pfree
, DWORD
*skip
)
163 WAVEFORMATEX
*wfx
= (WAVEFORMATEX
*)This
->renderer
.pInputPin
->pin
.mtCurrent
.pbFormat
;
164 DWORD writepos
, min_writepos
, playpos
;
165 REFERENCE_TIME max_lag
= 50 * 10000;
166 REFERENCE_TIME min_lag
= 25 * 10000;
167 REFERENCE_TIME cur
, writepos_t
, delta_t
;
169 DSoundRender_UpdatePositions(This
, &writepos
, &min_writepos
);
170 playpos
= This
->last_playpos
;
171 if (This
->renderer
.filter
.pClock
== &This
->IReferenceClock_iface
) {
173 cur
= This
->play_time
+ time_from_pos(This
, playpos
);
174 cur
-= This
->renderer
.filter
.rtStreamStart
;
175 } else if (This
->renderer
.filter
.pClock
) {
176 IReferenceClock_GetTime(This
->renderer
.filter
.pClock
, &cur
);
177 cur
-= This
->renderer
.filter
.rtStreamStart
;
181 if (writepos
== min_writepos
)
186 *ret_writepos
= writepos
;
190 if (writepos
>= playpos
)
191 writepos_t
= cur
+ time_from_pos(This
, writepos
- playpos
);
193 writepos_t
= cur
+ time_from_pos(This
, This
->buf_size
+ writepos
- playpos
);
195 /* write_at: Starting time of sample */
196 /* cur: current time of play position */
197 /* writepos_t: current time of our pointer play position */
198 delta_t
= write_at
- writepos_t
;
199 if (delta_t
>= -max_lag
&& delta_t
<= max_lag
) {
200 TRACE("Continuing from old position\n");
201 *ret_writepos
= writepos
;
202 } else if (delta_t
< 0) {
203 REFERENCE_TIME past
, min_writepos_t
;
204 WARN("Delta too big %i/%i, overwriting old data or even skipping\n", (int)delta_t
/ 10000, (int)max_lag
/ 10000);
205 if (min_writepos
>= playpos
)
206 min_writepos_t
= cur
+ time_from_pos(This
, min_writepos
- playpos
);
208 min_writepos_t
= cur
+ time_from_pos(This
, This
->buf_size
- playpos
+ min_writepos
);
209 past
= min_writepos_t
- write_at
;
211 DWORD skipbytes
= pos_from_time(This
, past
);
212 WARN("Skipping %u bytes\n", skipbytes
);
214 *ret_writepos
= min_writepos
;
216 DWORD aheadbytes
= pos_from_time(This
, -past
);
217 WARN("Advancing %u bytes\n", aheadbytes
);
218 *ret_writepos
= (min_writepos
+ aheadbytes
) % This
->buf_size
;
220 } else /* delta_t > 0 */ {
222 WARN("Delta too big %i/%i, too far ahead\n", (int)delta_t
/ 10000, (int)max_lag
/ 10000);
223 aheadbytes
= pos_from_time(This
, delta_t
);
224 WARN("Advancing %u bytes\n", aheadbytes
);
225 if (delta_t
>= DSoundRenderer_Max_Fill
)
227 *ret_writepos
= (min_writepos
+ aheadbytes
) % This
->buf_size
;
230 if (playpos
> *ret_writepos
)
231 *pfree
= playpos
- *ret_writepos
;
232 else if (playpos
== *ret_writepos
)
233 *pfree
= This
->buf_size
- wfx
->nBlockAlign
;
235 *pfree
= This
->buf_size
+ playpos
- *ret_writepos
;
236 if (time_from_pos(This
, This
->buf_size
- *pfree
) >= DSoundRenderer_Max_Fill
) {
237 TRACE("Blocked: too full %i / %i\n", (int)(time_from_pos(This
, This
->buf_size
- *pfree
)/10000), (int)(DSoundRenderer_Max_Fill
/ 10000));
243 static HRESULT
DSoundRender_HandleEndOfStream(DSoundRenderImpl
*This
)
245 while (This
->renderer
.filter
.state
== State_Running
)
248 DSoundRender_UpdatePositions(This
, &pos1
, &pos2
);
253 LeaveCriticalSection(&This
->renderer
.filter
.csFilter
);
254 LeaveCriticalSection(&This
->renderer
.csRenderLock
);
255 WaitForSingleObject(This
->blocked
, 10);
256 EnterCriticalSection(&This
->renderer
.csRenderLock
);
257 EnterCriticalSection(&This
->renderer
.filter
.csFilter
);
264 static HRESULT
DSoundRender_SendSampleData(DSoundRenderImpl
* This
, REFERENCE_TIME tStart
, REFERENCE_TIME tStop
, const BYTE
*data
, DWORD size
)
268 while (size
&& This
->renderer
.filter
.state
!= State_Stopped
) {
269 DWORD writepos
, skip
= 0, free
, size1
, size2
, ret
;
272 if (This
->renderer
.filter
.state
== State_Running
)
273 hr
= DSoundRender_GetWritePos(This
, &writepos
, tStart
, &free
, &skip
);
279 LeaveCriticalSection(&This
->renderer
.csRenderLock
);
280 ret
= WaitForSingleObject(This
->blocked
, 10);
281 EnterCriticalSection(&This
->renderer
.csRenderLock
);
283 if (This
->renderer
.pInputPin
->flushing
||
284 This
->renderer
.filter
.state
== State_Stopped
) {
285 return This
->renderer
.filter
.state
== State_Paused
? S_OK
: VFW_E_WRONG_STATE
;
287 if (ret
!= WAIT_TIMEOUT
)
294 FIXME("Sample dropped %u of %u bytes\n", skip
, size
);
300 hr
= IDirectSoundBuffer_Lock(This
->dsbuffer
, writepos
, min(free
, size
), (void**)&buf1
, &size1
, (void**)&buf2
, &size2
, 0);
302 ERR("Unable to lock sound buffer! (%x)\n", hr
);
305 memcpy(buf1
, data
, size1
);
307 memcpy(buf2
, data
+size1
, size2
);
308 IDirectSoundBuffer_Unlock(This
->dsbuffer
, buf1
, size1
, buf2
, size2
);
309 This
->writepos
= (writepos
+ size1
+ size2
) % This
->buf_size
;
310 TRACE("Wrote %u bytes at %u, next at %u - (%u/%u)\n", size1
+size2
, writepos
, This
->writepos
, free
, size
);
311 data
+= size1
+ size2
;
312 size
-= size1
+ size2
;
317 static HRESULT WINAPI
DSoundRender_ShouldDrawSampleNow(BaseRenderer
*This
, IMediaSample
*pMediaSample
, REFERENCE_TIME
*pStartTime
, REFERENCE_TIME
*pEndTime
)
319 /* We time ourselves do not use the base renderers timing */
324 static HRESULT WINAPI
DSoundRender_PrepareReceive(BaseRenderer
*iface
, IMediaSample
*pSample
)
326 DSoundRenderImpl
*This
= impl_from_BaseRenderer(iface
);
330 if (IMediaSample_GetMediaType(pSample
, &amt
) == S_OK
)
332 AM_MEDIA_TYPE
*orig
= &This
->renderer
.pInputPin
->pin
.mtCurrent
;
333 WAVEFORMATEX
*origfmt
= (WAVEFORMATEX
*)orig
->pbFormat
;
334 WAVEFORMATEX
*newfmt
= (WAVEFORMATEX
*)amt
->pbFormat
;
336 if (origfmt
->wFormatTag
== newfmt
->wFormatTag
&&
337 origfmt
->nChannels
== newfmt
->nChannels
&&
338 origfmt
->nBlockAlign
== newfmt
->nBlockAlign
&&
339 origfmt
->wBitsPerSample
== newfmt
->wBitsPerSample
&&
340 origfmt
->cbSize
== newfmt
->cbSize
)
342 if (origfmt
->nSamplesPerSec
!= newfmt
->nSamplesPerSec
)
344 hr
= IDirectSoundBuffer_SetFrequency(This
->dsbuffer
,
345 newfmt
->nSamplesPerSec
);
347 return VFW_E_TYPE_NOT_ACCEPTED
;
349 CopyMediaType(orig
, amt
);
350 IMediaSample_SetMediaType(pSample
, NULL
);
354 return VFW_E_TYPE_NOT_ACCEPTED
;
359 static HRESULT WINAPI
DSoundRender_DoRenderSample(BaseRenderer
*iface
, IMediaSample
* pSample
)
361 DSoundRenderImpl
*This
= impl_from_BaseRenderer(iface
);
362 LPBYTE pbSrcStream
= NULL
;
363 LONG cbSrcStream
= 0;
364 REFERENCE_TIME tStart
, tStop
;
367 TRACE("%p %p\n", iface
, pSample
);
369 /* Slightly incorrect, Pause completes when a frame is received so we should signal
370 * pause completion here, but for sound playing a single frame doesn't make sense
373 hr
= IMediaSample_GetPointer(pSample
, &pbSrcStream
);
376 ERR("Cannot get pointer to sample data (%x)\n", hr
);
380 hr
= IMediaSample_GetTime(pSample
, &tStart
, &tStop
);
382 ERR("Cannot get sample time (%x)\n", hr
);
386 IMediaSample_IsDiscontinuity(pSample
);
388 if (IMediaSample_IsPreroll(pSample
) == S_OK
)
394 cbSrcStream
= IMediaSample_GetActualDataLength(pSample
);
395 TRACE("Sample data ptr = %p, size = %d\n", pbSrcStream
, cbSrcStream
);
397 hr
= DSoundRender_SendSampleData(This
, tStart
, tStop
, pbSrcStream
, cbSrcStream
);
398 if (This
->renderer
.filter
.state
== State_Running
&& This
->renderer
.filter
.pClock
&& tStart
>= 0) {
399 REFERENCE_TIME jitter
, now
= 0;
401 IReferenceClock_GetTime(This
->renderer
.filter
.pClock
, &now
);
402 jitter
= now
- This
->renderer
.filter
.rtStreamStart
- tStart
;
403 if (jitter
<= -DSoundRenderer_Max_Fill
)
404 jitter
+= DSoundRenderer_Max_Fill
;
407 q
.Type
= (jitter
> 0 ? Famine
: Flood
);
410 q
.TimeStamp
= tStart
;
411 IQualityControl_Notify((IQualityControl
*)This
->renderer
.qcimpl
, (IBaseFilter
*)This
, q
);
416 static HRESULT WINAPI
DSoundRender_CheckMediaType(BaseRenderer
*iface
, const AM_MEDIA_TYPE
* pmt
)
418 WAVEFORMATEX
* format
;
420 if (!IsEqualIID(&pmt
->majortype
, &MEDIATYPE_Audio
))
423 format
= (WAVEFORMATEX
*)pmt
->pbFormat
;
424 TRACE("Format = %p\n", format
);
425 TRACE("wFormatTag = %x %x\n", format
->wFormatTag
, WAVE_FORMAT_PCM
);
426 TRACE("nChannels = %d\n", format
->nChannels
);
427 TRACE("nSamplesPerSec = %d\n", format
->nAvgBytesPerSec
);
428 TRACE("nAvgBytesPerSec = %d\n", format
->nAvgBytesPerSec
);
429 TRACE("nBlockAlign = %d\n", format
->nBlockAlign
);
430 TRACE("wBitsPerSample = %d\n", format
->wBitsPerSample
);
432 if (!IsEqualIID(&pmt
->subtype
, &MEDIASUBTYPE_PCM
))
438 static VOID WINAPI
DSoundRender_OnStopStreaming(BaseRenderer
* iface
)
440 DSoundRenderImpl
*This
= impl_from_BaseRenderer(iface
);
442 TRACE("(%p/%p)->()\n", This
, iface
);
444 IDirectSoundBuffer_Stop(This
->dsbuffer
);
445 This
->writepos
= This
->buf_size
;
446 SetEvent(This
->blocked
);
449 static VOID WINAPI
DSoundRender_OnStartStreaming(BaseRenderer
* iface
)
451 DSoundRenderImpl
*This
= impl_from_BaseRenderer(iface
);
453 TRACE("(%p)\n", This
);
455 if (This
->renderer
.pInputPin
->pin
.pConnectedTo
)
457 if (This
->renderer
.filter
.state
== State_Paused
)
459 /* Unblock our thread, state changing from paused to running doesn't need a reset for state change */
460 SetEvent(This
->blocked
);
462 IDirectSoundBuffer_Play(This
->dsbuffer
, 0, 0, DSBPLAY_LOOPING
);
463 ResetEvent(This
->blocked
);
467 static HRESULT WINAPI
DSoundRender_CompleteConnect(BaseRenderer
* iface
, IPin
* pReceivePin
)
469 DSoundRenderImpl
*This
= impl_from_BaseRenderer(iface
);
470 const AM_MEDIA_TYPE
* pmt
= &This
->renderer
.pInputPin
->pin
.mtCurrent
;
472 WAVEFORMATEX
*format
;
473 DSBUFFERDESC buf_desc
;
475 TRACE("(%p)->(%p)\n", This
, pReceivePin
);
476 dump_AM_MEDIA_TYPE(pmt
);
478 TRACE("MajorType %s\n", debugstr_guid(&pmt
->majortype
));
479 TRACE("SubType %s\n", debugstr_guid(&pmt
->subtype
));
480 TRACE("Format %s\n", debugstr_guid(&pmt
->formattype
));
481 TRACE("Size %d\n", pmt
->cbFormat
);
483 format
= (WAVEFORMATEX
*)pmt
->pbFormat
;
485 This
->buf_size
= format
->nAvgBytesPerSec
;
487 memset(&buf_desc
,0,sizeof(DSBUFFERDESC
));
488 buf_desc
.dwSize
= sizeof(DSBUFFERDESC
);
489 buf_desc
.dwFlags
= DSBCAPS_CTRLVOLUME
| DSBCAPS_CTRLPAN
|
490 DSBCAPS_CTRLFREQUENCY
| DSBCAPS_GLOBALFOCUS
|
491 DSBCAPS_GETCURRENTPOSITION2
;
492 buf_desc
.dwBufferBytes
= This
->buf_size
;
493 buf_desc
.lpwfxFormat
= format
;
494 hr
= IDirectSound_CreateSoundBuffer(This
->dsound
, &buf_desc
, &This
->dsbuffer
, NULL
);
495 This
->writepos
= This
->buf_size
;
497 ERR("Can't create sound buffer (%x)\n", hr
);
501 hr
= IDirectSoundBuffer_SetVolume(This
->dsbuffer
, This
->volume
);
503 ERR("Can't set volume to %d (%x)\n", This
->volume
, hr
);
505 hr
= IDirectSoundBuffer_SetPan(This
->dsbuffer
, This
->pan
);
507 ERR("Can't set pan to %d (%x)\n", This
->pan
, hr
);
511 if (FAILED(hr
) && hr
!= VFW_E_ALREADY_CONNECTED
)
514 IDirectSoundBuffer_Release(This
->dsbuffer
);
515 This
->dsbuffer
= NULL
;
521 static HRESULT WINAPI
DSoundRender_BreakConnect(BaseRenderer
* iface
)
523 DSoundRenderImpl
*This
= impl_from_BaseRenderer(iface
);
525 TRACE("(%p)->()\n", iface
);
527 if (This
->threadid
) {
528 PostThreadMessageW(This
->threadid
, WM_APP
, 0, 0);
529 LeaveCriticalSection(This
->renderer
.pInputPin
->pin
.pCritSec
);
530 WaitForSingleObject(This
->advisethread
, INFINITE
);
531 EnterCriticalSection(This
->renderer
.pInputPin
->pin
.pCritSec
);
532 CloseHandle(This
->advisethread
);
535 IDirectSoundBuffer_Release(This
->dsbuffer
);
536 This
->dsbuffer
= NULL
;
541 static HRESULT WINAPI
DSoundRender_EndOfStream(BaseRenderer
* iface
)
543 DSoundRenderImpl
*This
= impl_from_BaseRenderer(iface
);
546 TRACE("(%p)->()\n",iface
);
548 hr
= BaseRendererImpl_EndOfStream(iface
);
555 hr
= DSoundRender_HandleEndOfStream(This
);
560 static HRESULT WINAPI
DSoundRender_BeginFlush(BaseRenderer
* iface
)
562 DSoundRenderImpl
*This
= impl_from_BaseRenderer(iface
);
565 BaseRendererImpl_BeginFlush(iface
);
566 SetEvent(This
->blocked
);
571 static HRESULT WINAPI
DSoundRender_EndFlush(BaseRenderer
* iface
)
573 DSoundRenderImpl
*This
= impl_from_BaseRenderer(iface
);
577 BaseRendererImpl_EndFlush(iface
);
578 if (This
->renderer
.filter
.state
!= State_Stopped
)
579 ResetEvent(This
->blocked
);
587 IDirectSoundBuffer_Lock(This
->dsbuffer
, 0, 0, (LPVOID
*)&buffer
, &size
, NULL
, NULL
, DSBLOCK_ENTIREBUFFER
);
588 memset(buffer
, 0, size
);
589 IDirectSoundBuffer_Unlock(This
->dsbuffer
, buffer
, size
, NULL
, 0);
590 This
->writepos
= This
->buf_size
;
596 static const BaseRendererFuncTable BaseFuncTable
= {
597 DSoundRender_CheckMediaType
,
598 DSoundRender_DoRenderSample
,
603 DSoundRender_OnStartStreaming
,
604 DSoundRender_OnStopStreaming
,
608 DSoundRender_ShouldDrawSampleNow
,
609 DSoundRender_PrepareReceive
,
611 DSoundRender_CompleteConnect
,
612 DSoundRender_BreakConnect
,
613 DSoundRender_EndOfStream
,
614 DSoundRender_BeginFlush
,
615 DSoundRender_EndFlush
,
618 HRESULT
DSoundRender_create(IUnknown
* pUnkOuter
, LPVOID
* ppv
)
621 DSoundRenderImpl
* pDSoundRender
;
623 TRACE("(%p, %p)\n", pUnkOuter
, ppv
);
628 return CLASS_E_NOAGGREGATION
;
630 pDSoundRender
= CoTaskMemAlloc(sizeof(DSoundRenderImpl
));
632 return E_OUTOFMEMORY
;
633 ZeroMemory(pDSoundRender
, sizeof(DSoundRenderImpl
));
635 hr
= BaseRenderer_Init(&pDSoundRender
->renderer
, &DSoundRender_Vtbl
, (IUnknown
*)pDSoundRender
, &CLSID_DSoundRender
, (DWORD_PTR
)(__FILE__
": DSoundRenderImpl.csFilter"), &BaseFuncTable
);
637 BasicAudio_Init(&pDSoundRender
->basicAudio
,&IBasicAudio_Vtbl
);
638 pDSoundRender
->IReferenceClock_iface
.lpVtbl
= &IReferenceClock_Vtbl
;
639 pDSoundRender
->IAMDirectSound_iface
.lpVtbl
= &IAMDirectSound_Vtbl
;
640 pDSoundRender
->IAMFilterMiscFlags_iface
.lpVtbl
= &IAMFilterMiscFlags_Vtbl
;
644 hr
= DirectSoundCreate8(NULL
, &pDSoundRender
->dsound
, NULL
);
646 ERR("Cannot create Direct Sound object (%x)\n", hr
);
648 hr
= IDirectSound_SetCooperativeLevel(pDSoundRender
->dsound
, GetDesktopWindow(), DSSCL_PRIORITY
);
650 IDirectSoundBuffer
*buf
;
651 DSBUFFERDESC buf_desc
;
652 memset(&buf_desc
,0,sizeof(DSBUFFERDESC
));
653 buf_desc
.dwSize
= sizeof(DSBUFFERDESC
);
654 buf_desc
.dwFlags
= DSBCAPS_PRIMARYBUFFER
;
655 hr
= IDirectSound_CreateSoundBuffer(pDSoundRender
->dsound
, &buf_desc
, &buf
, NULL
);
657 IDirectSoundBuffer_Play(buf
, 0, 0, DSBPLAY_LOOPING
);
658 IDirectSoundBuffer_Release(buf
);
666 pDSoundRender
->blocked
= CreateEventW(NULL
, TRUE
, TRUE
, NULL
);
668 if (!pDSoundRender
->blocked
|| FAILED(hr
))
670 IUnknown_Release((IUnknown
*)pDSoundRender
);
671 return HRESULT_FROM_WIN32(GetLastError());
674 *ppv
= pDSoundRender
;
678 BaseRendererImpl_Release(&pDSoundRender
->renderer
.filter
.IBaseFilter_iface
);
679 CoTaskMemFree(pDSoundRender
);
685 static HRESULT WINAPI
DSoundRender_QueryInterface(IBaseFilter
* iface
, REFIID riid
, LPVOID
* ppv
)
687 DSoundRenderImpl
*This
= impl_from_IBaseFilter(iface
);
688 TRACE("(%p, %p)->(%s, %p)\n", This
, iface
, qzdebugstr_guid(riid
), ppv
);
692 if (IsEqualIID(riid
, &IID_IBasicAudio
))
693 *ppv
= &This
->basicAudio
.IBasicAudio_iface
;
694 else if (IsEqualIID(riid
, &IID_IReferenceClock
))
695 *ppv
= &This
->IReferenceClock_iface
;
696 else if (IsEqualIID(riid
, &IID_IAMDirectSound
))
697 *ppv
= &This
->IAMDirectSound_iface
;
698 else if (IsEqualIID(riid
, &IID_IAMFilterMiscFlags
))
699 *ppv
= &This
->IAMFilterMiscFlags_iface
;
703 hr
= BaseRendererImpl_QueryInterface(iface
, riid
, ppv
);
710 IUnknown_AddRef((IUnknown
*)(*ppv
));
714 if (!IsEqualIID(riid
, &IID_IPin
) && !IsEqualIID(riid
, &IID_IVideoWindow
))
715 FIXME("No interface for %s!\n", qzdebugstr_guid(riid
));
717 return E_NOINTERFACE
;
720 static ULONG WINAPI
DSoundRender_Release(IBaseFilter
* iface
)
722 DSoundRenderImpl
*This
= impl_from_IBaseFilter(iface
);
723 ULONG refCount
= BaseRendererImpl_Release(iface
);
725 TRACE("(%p)->() Release from %d\n", This
, refCount
+ 1);
729 if (This
->threadid
) {
730 PostThreadMessageW(This
->threadid
, WM_APP
, 0, 0);
731 WaitForSingleObject(This
->advisethread
, INFINITE
);
732 CloseHandle(This
->advisethread
);
736 IDirectSoundBuffer_Release(This
->dsbuffer
);
737 This
->dsbuffer
= NULL
;
739 IDirectSound_Release(This
->dsound
);
742 BasicAudio_Destroy(&This
->basicAudio
);
743 CloseHandle(This
->blocked
);
745 TRACE("Destroying Audio Renderer\n");
754 static HRESULT WINAPI
DSoundRender_Pause(IBaseFilter
* iface
)
757 DSoundRenderImpl
*This
= (DSoundRenderImpl
*)iface
;
759 TRACE("(%p/%p)->()\n", This
, iface
);
761 EnterCriticalSection(&This
->renderer
.csRenderLock
);
762 if (This
->renderer
.filter
.state
!= State_Paused
)
764 if (This
->renderer
.filter
.state
== State_Stopped
)
766 if (This
->renderer
.pInputPin
->pin
.pConnectedTo
)
767 ResetEvent(This
->renderer
.evComplete
);
768 This
->renderer
.pInputPin
->end_of_stream
= 0;
771 hr
= IDirectSoundBuffer_Stop(This
->dsbuffer
);
773 This
->renderer
.filter
.state
= State_Paused
;
775 ResetEvent(This
->blocked
);
776 ResetEvent(This
->renderer
.RenderEvent
);
778 ResetEvent(This
->renderer
.ThreadSignal
);
779 LeaveCriticalSection(&This
->renderer
.csRenderLock
);
784 static const IBaseFilterVtbl DSoundRender_Vtbl
=
786 DSoundRender_QueryInterface
,
787 BaseFilterImpl_AddRef
,
788 DSoundRender_Release
,
789 BaseFilterImpl_GetClassID
,
790 BaseRendererImpl_Stop
,
792 BaseRendererImpl_Run
,
793 BaseRendererImpl_GetState
,
794 BaseRendererImpl_SetSyncSource
,
795 BaseFilterImpl_GetSyncSource
,
796 BaseFilterImpl_EnumPins
,
797 BaseRendererImpl_FindPin
,
798 BaseFilterImpl_QueryFilterInfo
,
799 BaseFilterImpl_JoinFilterGraph
,
800 BaseFilterImpl_QueryVendorInfo
803 /*** IUnknown methods ***/
804 static HRESULT WINAPI
Basicaudio_QueryInterface(IBasicAudio
*iface
,
807 DSoundRenderImpl
*This
= impl_from_IBasicAudio(iface
);
809 TRACE("(%p/%p)->(%s (%p), %p)\n", This
, iface
, debugstr_guid(riid
), riid
, ppvObj
);
811 return DSoundRender_QueryInterface(&This
->renderer
.filter
.IBaseFilter_iface
, riid
, ppvObj
);
814 static ULONG WINAPI
Basicaudio_AddRef(IBasicAudio
*iface
) {
815 DSoundRenderImpl
*This
= impl_from_IBasicAudio(iface
);
817 TRACE("(%p/%p)->()\n", This
, iface
);
819 return BaseFilterImpl_AddRef(&This
->renderer
.filter
.IBaseFilter_iface
);
822 static ULONG WINAPI
Basicaudio_Release(IBasicAudio
*iface
) {
823 DSoundRenderImpl
*This
= impl_from_IBasicAudio(iface
);
825 TRACE("(%p/%p)->()\n", This
, iface
);
827 return DSoundRender_Release(&This
->renderer
.filter
.IBaseFilter_iface
);
830 /*** IBasicAudio methods ***/
831 static HRESULT WINAPI
Basicaudio_put_Volume(IBasicAudio
*iface
,
833 DSoundRenderImpl
*This
= impl_from_IBasicAudio(iface
);
835 TRACE("(%p/%p)->(%d)\n", This
, iface
, lVolume
);
837 if (lVolume
> DSBVOLUME_MAX
|| lVolume
< DSBVOLUME_MIN
)
840 if (This
->dsbuffer
) {
841 if (FAILED(IDirectSoundBuffer_SetVolume(This
->dsbuffer
, lVolume
)))
845 This
->volume
= lVolume
;
849 static HRESULT WINAPI
Basicaudio_get_Volume(IBasicAudio
*iface
,
851 DSoundRenderImpl
*This
= impl_from_IBasicAudio(iface
);
853 TRACE("(%p/%p)->(%p)\n", This
, iface
, plVolume
);
858 *plVolume
= This
->volume
;
862 static HRESULT WINAPI
Basicaudio_put_Balance(IBasicAudio
*iface
,
864 DSoundRenderImpl
*This
= impl_from_IBasicAudio(iface
);
866 TRACE("(%p/%p)->(%d)\n", This
, iface
, lBalance
);
868 if (lBalance
< DSBPAN_LEFT
|| lBalance
> DSBPAN_RIGHT
)
871 if (This
->dsbuffer
) {
872 if (FAILED(IDirectSoundBuffer_SetPan(This
->dsbuffer
, lBalance
)))
876 This
->pan
= lBalance
;
880 static HRESULT WINAPI
Basicaudio_get_Balance(IBasicAudio
*iface
,
882 DSoundRenderImpl
*This
= impl_from_IBasicAudio(iface
);
884 TRACE("(%p/%p)->(%p)\n", This
, iface
, plBalance
);
889 *plBalance
= This
->pan
;
893 static const IBasicAudioVtbl IBasicAudio_Vtbl
=
895 Basicaudio_QueryInterface
,
898 BasicAudioImpl_GetTypeInfoCount
,
899 BasicAudioImpl_GetTypeInfo
,
900 BasicAudioImpl_GetIDsOfNames
,
901 BasicAudioImpl_Invoke
,
902 Basicaudio_put_Volume
,
903 Basicaudio_get_Volume
,
904 Basicaudio_put_Balance
,
905 Basicaudio_get_Balance
908 struct dsoundrender_timer
{
909 struct dsoundrender_timer
*next
;
910 REFERENCE_TIME start
;
911 REFERENCE_TIME periodicity
;
915 static LONG cookie_counter
= 1;
917 static DWORD WINAPI
DSoundAdviseThread(LPVOID lpParam
) {
918 DSoundRenderImpl
*This
= lpParam
;
919 struct dsoundrender_timer head
= {NULL
};
922 TRACE("(%p): Main Loop\n", This
);
924 PeekMessageW(&msg
, NULL
, WM_USER
, WM_USER
, PM_NOREMOVE
);
925 SetEvent(This
->thread_wait
);
930 REFERENCE_TIME curtime
= 0;
932 struct dsoundrender_timer
*prev
= &head
, *cur
;
934 hr
= IReferenceClock_GetTime(&This
->IReferenceClock_iface
, &curtime
);
936 TRACE("Time: %s\n", wine_dbgstr_longlong(curtime
));
939 if (cur
->start
> curtime
) {
940 TRACE("Skipping %p\n", cur
);
942 } else if (cur
->periodicity
) {
943 while (cur
->start
<= curtime
) {
944 cur
->start
+= cur
->periodicity
;
945 ReleaseSemaphore(cur
->handle
, 1, NULL
);
949 struct dsoundrender_timer
*next
= cur
->next
;
950 TRACE("Firing %p %s < %s\n", cur
, wine_dbgstr_longlong(cur
->start
), wine_dbgstr_longlong(curtime
));
951 SetEvent(cur
->handle
);
952 HeapFree(GetProcessHeap(), 0, cur
);
958 ret
= GetMessageW(&msg
, INVALID_HANDLE_VALUE
, WM_APP
, WM_APP
+ 4);
960 ret
= PeekMessageW(&msg
, INVALID_HANDLE_VALUE
, WM_APP
, WM_APP
+ 4, PM_REMOVE
);
962 switch (LOWORD(msg
.message
) - WM_APP
) {
963 case 0: TRACE("Exiting\n"); return 0;
966 struct dsoundrender_timer
*t
= (struct dsoundrender_timer
*)msg
.wParam
;
967 if (LOWORD(msg
.message
) - WM_APP
== 1)
968 TRACE("Adding one-shot timer %p\n", t
);
970 TRACE("Adding periodic timer %p\n", t
);
979 if (cur
->cookie
== msg
.wParam
) {
980 struct dsoundrender_timer
*next
= cur
->next
;
981 HeapFree(GetProcessHeap(), 0, cur
);
989 ret
= PeekMessageW(&msg
, INVALID_HANDLE_VALUE
, WM_APP
, WM_APP
+ 4, PM_REMOVE
);
991 MsgWaitForMultipleObjects(0, NULL
, 5, QS_POSTMESSAGE
, 0);
996 /*** IUnknown methods ***/
997 static HRESULT WINAPI
ReferenceClock_QueryInterface(IReferenceClock
*iface
,
1001 DSoundRenderImpl
*This
= impl_from_IReferenceClock(iface
);
1003 TRACE("(%p/%p)->(%s (%p), %p)\n", This
, iface
, debugstr_guid(riid
), riid
, ppvObj
);
1005 return DSoundRender_QueryInterface(&This
->renderer
.filter
.IBaseFilter_iface
, riid
, ppvObj
);
1008 static ULONG WINAPI
ReferenceClock_AddRef(IReferenceClock
*iface
)
1010 DSoundRenderImpl
*This
= impl_from_IReferenceClock(iface
);
1012 TRACE("(%p/%p)->()\n", This
, iface
);
1014 return BaseFilterImpl_AddRef(&This
->renderer
.filter
.IBaseFilter_iface
);
1017 static ULONG WINAPI
ReferenceClock_Release(IReferenceClock
*iface
)
1019 DSoundRenderImpl
*This
= impl_from_IReferenceClock(iface
);
1021 TRACE("(%p/%p)->()\n", This
, iface
);
1023 return DSoundRender_Release(&This
->renderer
.filter
.IBaseFilter_iface
);
1026 /*** IReferenceClock methods ***/
1027 static HRESULT WINAPI
ReferenceClock_GetTime(IReferenceClock
*iface
,
1028 REFERENCE_TIME
*pTime
)
1030 DSoundRenderImpl
*This
= impl_from_IReferenceClock(iface
);
1031 HRESULT hr
= E_FAIL
;
1033 TRACE("(%p/%p)->(%p)\n", This
, iface
, pTime
);
1037 if (This
->dsbuffer
) {
1038 DWORD writepos1
, writepos2
;
1039 EnterCriticalSection(&This
->renderer
.filter
.csFilter
);
1040 DSoundRender_UpdatePositions(This
, &writepos1
, &writepos2
);
1041 if (This
->renderer
.pInputPin
&& This
->renderer
.pInputPin
->pin
.mtCurrent
.pbFormat
)
1043 *pTime
= This
->play_time
+ time_from_pos(This
, This
->last_playpos
);
1048 ERR("pInputPin Disconncted\n");
1051 LeaveCriticalSection(&This
->renderer
.filter
.csFilter
);
1054 WARN("Could not get reference time (%x)!\n", hr
);
1059 static HRESULT WINAPI
ReferenceClock_AdviseTime(IReferenceClock
*iface
,
1060 REFERENCE_TIME rtBaseTime
,
1061 REFERENCE_TIME rtStreamTime
,
1063 DWORD_PTR
*pdwAdviseCookie
)
1065 DSoundRenderImpl
*This
= impl_from_IReferenceClock(iface
);
1066 REFERENCE_TIME when
= rtBaseTime
+ rtStreamTime
;
1067 REFERENCE_TIME future
;
1068 TRACE("(%p/%p)->(%s, %s, %p, %p)\n", This
, iface
, wine_dbgstr_longlong(rtBaseTime
), wine_dbgstr_longlong(rtStreamTime
), (void*)hEvent
, pdwAdviseCookie
);
1071 return E_INVALIDARG
;
1073 if (!pdwAdviseCookie
)
1076 EnterCriticalSection(&This
->renderer
.filter
.csFilter
);
1077 future
= when
- This
->play_time
;
1078 if (!This
->threadid
&& This
->dsbuffer
) {
1079 This
->thread_wait
= CreateEventW(0, 0, 0, 0);
1080 This
->advisethread
= CreateThread(NULL
, 0, DSoundAdviseThread
, This
, 0, &This
->threadid
);
1081 WaitForSingleObject(This
->thread_wait
, INFINITE
);
1082 CloseHandle(This
->thread_wait
);
1084 LeaveCriticalSection(&This
->renderer
.filter
.csFilter
);
1085 /* If it's in the past or the next millisecond, trigger immediately */
1086 if (future
<= 10000) {
1087 SetEvent((HANDLE
)hEvent
);
1088 *pdwAdviseCookie
= 0;
1090 struct dsoundrender_timer
*t
= HeapAlloc(GetProcessHeap(), 0, sizeof(*t
));
1094 t
->handle
= (HANDLE
)hEvent
;
1095 t
->cookie
= InterlockedIncrement(&cookie_counter
);
1096 PostThreadMessageW(This
->threadid
, WM_APP
+1, (WPARAM
)t
, 0);
1097 *pdwAdviseCookie
= t
->cookie
;
1103 static HRESULT WINAPI
ReferenceClock_AdvisePeriodic(IReferenceClock
*iface
,
1104 REFERENCE_TIME rtStartTime
,
1105 REFERENCE_TIME rtPeriodTime
,
1106 HSEMAPHORE hSemaphore
,
1107 DWORD_PTR
*pdwAdviseCookie
)
1109 DSoundRenderImpl
*This
= impl_from_IReferenceClock(iface
);
1110 struct dsoundrender_timer
*t
;
1112 TRACE("(%p/%p)->(%s, %s, %p, %p)\n", This
, iface
, wine_dbgstr_longlong(rtStartTime
), wine_dbgstr_longlong(rtPeriodTime
), (void*)hSemaphore
, pdwAdviseCookie
);
1114 if (rtStartTime
<= 0 || rtPeriodTime
<= 0)
1115 return E_INVALIDARG
;
1117 if (!pdwAdviseCookie
)
1120 EnterCriticalSection(&This
->renderer
.filter
.csFilter
);
1121 if (!This
->threadid
&& This
->dsbuffer
) {
1122 This
->thread_wait
= CreateEventW(0, 0, 0, 0);
1123 This
->advisethread
= CreateThread(NULL
, 0, DSoundAdviseThread
, This
, 0, &This
->threadid
);
1124 WaitForSingleObject(This
->thread_wait
, INFINITE
);
1125 CloseHandle(This
->thread_wait
);
1127 LeaveCriticalSection(&This
->renderer
.filter
.csFilter
);
1129 t
= HeapAlloc(GetProcessHeap(), 0, sizeof(*t
));
1131 t
->start
= rtStartTime
;
1132 t
->periodicity
= rtPeriodTime
;
1133 t
->handle
= (HANDLE
)hSemaphore
;
1134 t
->cookie
= InterlockedIncrement(&cookie_counter
);
1135 PostThreadMessageW(This
->threadid
, WM_APP
+1, (WPARAM
)t
, 0);
1136 *pdwAdviseCookie
= t
->cookie
;
1141 static HRESULT WINAPI
ReferenceClock_Unadvise(IReferenceClock
*iface
,
1142 DWORD_PTR dwAdviseCookie
)
1144 DSoundRenderImpl
*This
= impl_from_IReferenceClock(iface
);
1146 TRACE("(%p/%p)->(%p)\n", This
, iface
, (void*)dwAdviseCookie
);
1147 if (!This
->advisethread
|| !dwAdviseCookie
)
1149 PostThreadMessageW(This
->threadid
, WM_APP
+3, dwAdviseCookie
, 0);
1153 static const IReferenceClockVtbl IReferenceClock_Vtbl
=
1155 ReferenceClock_QueryInterface
,
1156 ReferenceClock_AddRef
,
1157 ReferenceClock_Release
,
1158 ReferenceClock_GetTime
,
1159 ReferenceClock_AdviseTime
,
1160 ReferenceClock_AdvisePeriodic
,
1161 ReferenceClock_Unadvise
1164 /*** IUnknown methods ***/
1165 static HRESULT WINAPI
AMDirectSound_QueryInterface(IAMDirectSound
*iface
,
1169 DSoundRenderImpl
*This
= impl_from_IAMDirectSound(iface
);
1171 TRACE("(%p/%p)->(%s (%p), %p)\n", This
, iface
, debugstr_guid(riid
), riid
, ppvObj
);
1173 return DSoundRender_QueryInterface(&This
->renderer
.filter
.IBaseFilter_iface
, riid
, ppvObj
);
1176 static ULONG WINAPI
AMDirectSound_AddRef(IAMDirectSound
*iface
)
1178 DSoundRenderImpl
*This
= impl_from_IAMDirectSound(iface
);
1180 TRACE("(%p/%p)->()\n", This
, iface
);
1182 return BaseFilterImpl_AddRef(&This
->renderer
.filter
.IBaseFilter_iface
);
1185 static ULONG WINAPI
AMDirectSound_Release(IAMDirectSound
*iface
)
1187 DSoundRenderImpl
*This
= impl_from_IAMDirectSound(iface
);
1189 TRACE("(%p/%p)->()\n", This
, iface
);
1191 return DSoundRender_Release(&This
->renderer
.filter
.IBaseFilter_iface
);
1194 /*** IAMDirectSound methods ***/
1195 static HRESULT WINAPI
AMDirectSound_GetDirectSoundInterface(IAMDirectSound
*iface
, IDirectSound
**ds
)
1197 DSoundRenderImpl
*This
= impl_from_IAMDirectSound(iface
);
1199 FIXME("(%p/%p)->(%p): stub\n", This
, iface
, ds
);
1204 static HRESULT WINAPI
AMDirectSound_GetPrimaryBufferInterface(IAMDirectSound
*iface
, IDirectSoundBuffer
**buf
)
1206 DSoundRenderImpl
*This
= impl_from_IAMDirectSound(iface
);
1208 FIXME("(%p/%p)->(%p): stub\n", This
, iface
, buf
);
1213 static HRESULT WINAPI
AMDirectSound_GetSecondaryBufferInterface(IAMDirectSound
*iface
, IDirectSoundBuffer
**buf
)
1215 DSoundRenderImpl
*This
= impl_from_IAMDirectSound(iface
);
1217 FIXME("(%p/%p)->(%p): stub\n", This
, iface
, buf
);
1222 static HRESULT WINAPI
AMDirectSound_ReleaseDirectSoundInterface(IAMDirectSound
*iface
, IDirectSound
*ds
)
1224 DSoundRenderImpl
*This
= impl_from_IAMDirectSound(iface
);
1226 FIXME("(%p/%p)->(%p): stub\n", This
, iface
, ds
);
1231 static HRESULT WINAPI
AMDirectSound_ReleasePrimaryBufferInterface(IAMDirectSound
*iface
, IDirectSoundBuffer
*buf
)
1233 DSoundRenderImpl
*This
= impl_from_IAMDirectSound(iface
);
1235 FIXME("(%p/%p)->(%p): stub\n", This
, iface
, buf
);
1240 static HRESULT WINAPI
AMDirectSound_ReleaseSecondaryBufferInterface(IAMDirectSound
*iface
, IDirectSoundBuffer
*buf
)
1242 DSoundRenderImpl
*This
= impl_from_IAMDirectSound(iface
);
1244 FIXME("(%p/%p)->(%p): stub\n", This
, iface
, buf
);
1249 static HRESULT WINAPI
AMDirectSound_SetFocusWindow(IAMDirectSound
*iface
, HWND hwnd
, BOOL bgaudible
)
1251 DSoundRenderImpl
*This
= impl_from_IAMDirectSound(iface
);
1253 FIXME("(%p/%p)->(%p,%d): stub\n", This
, iface
, hwnd
, bgaudible
);
1258 static HRESULT WINAPI
AMDirectSound_GetFocusWindow(IAMDirectSound
*iface
, HWND
*hwnd
, BOOL
*bgaudible
)
1260 DSoundRenderImpl
*This
= impl_from_IAMDirectSound(iface
);
1262 FIXME("(%p/%p)->(%p,%p): stub\n", This
, iface
, hwnd
, bgaudible
);
1267 static const IAMDirectSoundVtbl IAMDirectSound_Vtbl
=
1269 AMDirectSound_QueryInterface
,
1270 AMDirectSound_AddRef
,
1271 AMDirectSound_Release
,
1272 AMDirectSound_GetDirectSoundInterface
,
1273 AMDirectSound_GetPrimaryBufferInterface
,
1274 AMDirectSound_GetSecondaryBufferInterface
,
1275 AMDirectSound_ReleaseDirectSoundInterface
,
1276 AMDirectSound_ReleasePrimaryBufferInterface
,
1277 AMDirectSound_ReleaseSecondaryBufferInterface
,
1278 AMDirectSound_SetFocusWindow
,
1279 AMDirectSound_GetFocusWindow
1282 static HRESULT WINAPI
AMFilterMiscFlags_QueryInterface(IAMFilterMiscFlags
*iface
, REFIID riid
, void **ppv
) {
1283 DSoundRenderImpl
*This
= impl_from_IAMFilterMiscFlags(iface
);
1284 return IUnknown_QueryInterface((IUnknown
*)This
, riid
, ppv
);
1287 static ULONG WINAPI
AMFilterMiscFlags_AddRef(IAMFilterMiscFlags
*iface
) {
1288 DSoundRenderImpl
*This
= impl_from_IAMFilterMiscFlags(iface
);
1289 return IUnknown_AddRef((IUnknown
*)This
);
1292 static ULONG WINAPI
AMFilterMiscFlags_Release(IAMFilterMiscFlags
*iface
) {
1293 DSoundRenderImpl
*This
= impl_from_IAMFilterMiscFlags(iface
);
1294 return IUnknown_Release((IUnknown
*)This
);
1297 static ULONG WINAPI
AMFilterMiscFlags_GetMiscFlags(IAMFilterMiscFlags
*iface
) {
1298 return AM_FILTER_MISC_FLAGS_IS_RENDERER
;
1301 static const IAMFilterMiscFlagsVtbl IAMFilterMiscFlags_Vtbl
= {
1302 AMFilterMiscFlags_QueryInterface
,
1303 AMFilterMiscFlags_AddRef
,
1304 AMFilterMiscFlags_Release
,
1305 AMFilterMiscFlags_GetMiscFlags