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 IMediaSeekingVtbl IMediaSeeking_Vtbl
;
50 static const IAMDirectSoundVtbl IAMDirectSound_Vtbl
;
51 static const IAMFilterMiscFlagsVtbl IAMFilterMiscFlags_Vtbl
;
53 typedef struct DSoundRenderImpl
55 BaseRenderer renderer
;
57 const IBasicAudioVtbl
*IBasicAudio_vtbl
;
58 const IReferenceClockVtbl
*IReferenceClock_vtbl
;
59 const IAMDirectSoundVtbl
*IAMDirectSound_vtbl
;
60 const IAMFilterMiscFlagsVtbl
*IAMFilterMiscFlags_vtbl
;
62 IDirectSound8
*dsound
;
63 LPDIRECTSOUNDBUFFER dsbuffer
;
66 DWORD last_playpos
, writepos
;
68 REFERENCE_TIME play_time
;
76 HANDLE advisethread
, thread_wait
;
79 static inline DSoundRenderImpl
*impl_from_BaseRenderer(BaseRenderer
*iface
)
81 return CONTAINING_RECORD(iface
, DSoundRenderImpl
, renderer
);
84 static inline DSoundRenderImpl
*impl_from_IBaseFilter(IBaseFilter
*iface
)
86 return CONTAINING_RECORD(iface
, DSoundRenderImpl
, renderer
.filter
.IBaseFilter_iface
);
89 static REFERENCE_TIME
time_from_pos(DSoundRenderImpl
*This
, DWORD pos
) {
90 WAVEFORMATEX
*wfx
= (WAVEFORMATEX
*)This
->renderer
.pInputPin
->pin
.mtCurrent
.pbFormat
;
91 REFERENCE_TIME ret
= 10000000;
92 ret
= ret
* pos
/ wfx
->nAvgBytesPerSec
;
96 static DWORD
pos_from_time(DSoundRenderImpl
*This
, REFERENCE_TIME time
) {
97 WAVEFORMATEX
*wfx
= (WAVEFORMATEX
*)This
->renderer
.pInputPin
->pin
.mtCurrent
.pbFormat
;
98 REFERENCE_TIME ret
= time
;
99 ret
*= wfx
->nSamplesPerSec
;
101 ret
*= wfx
->nBlockAlign
;
105 static void DSoundRender_UpdatePositions(DSoundRenderImpl
*This
, DWORD
*seqwritepos
, DWORD
*minwritepos
) {
106 WAVEFORMATEX
*wfx
= (WAVEFORMATEX
*)This
->renderer
.pInputPin
->pin
.mtCurrent
.pbFormat
;
108 DWORD size1
, size2
, playpos
, writepos
, old_writepos
, old_playpos
, adv
;
109 BOOL writepos_set
= This
->writepos
< This
->buf_size
;
111 /* Update position and zero */
112 old_writepos
= This
->writepos
;
113 old_playpos
= This
->last_playpos
;
114 if (old_writepos
<= old_playpos
)
115 old_writepos
+= This
->buf_size
;
117 IDirectSoundBuffer_GetCurrentPosition(This
->dsbuffer
, &playpos
, &writepos
);
118 if (old_playpos
> playpos
) {
119 adv
= This
->buf_size
+ playpos
- old_playpos
;
120 This
->play_time
+= time_from_pos(This
, This
->buf_size
);
122 adv
= playpos
- old_playpos
;
123 This
->last_playpos
= playpos
;
125 TRACE("Moving from %u to %u: clearing %u bytes\n", old_playpos
, playpos
, adv
);
126 IDirectSoundBuffer_Lock(This
->dsbuffer
, old_playpos
, adv
, (void**)&buf1
, &size1
, (void**)&buf2
, &size2
, 0);
127 memset(buf1
, wfx
->wBitsPerSample
== 8 ? 128 : 0, size1
);
128 memset(buf2
, wfx
->wBitsPerSample
== 8 ? 128 : 0, size2
);
129 IDirectSoundBuffer_Unlock(This
->dsbuffer
, buf1
, size1
, buf2
, size2
);
131 *minwritepos
= writepos
;
132 if (!writepos_set
|| old_writepos
< writepos
) {
134 This
->writepos
= This
->buf_size
;
135 FIXME("Underrun of data occurred!\n");
137 *seqwritepos
= writepos
;
139 *seqwritepos
= This
->writepos
;
142 static HRESULT
DSoundRender_GetWritePos(DSoundRenderImpl
*This
, DWORD
*ret_writepos
, REFERENCE_TIME write_at
, DWORD
*pfree
, DWORD
*skip
)
144 WAVEFORMATEX
*wfx
= (WAVEFORMATEX
*)This
->renderer
.pInputPin
->pin
.mtCurrent
.pbFormat
;
145 DWORD writepos
, min_writepos
, playpos
;
146 REFERENCE_TIME max_lag
= 50 * 10000;
147 REFERENCE_TIME min_lag
= 25 * 10000;
148 REFERENCE_TIME cur
, writepos_t
, delta_t
;
150 DSoundRender_UpdatePositions(This
, &writepos
, &min_writepos
);
151 playpos
= This
->last_playpos
;
152 if (This
->renderer
.filter
.pClock
== (IReferenceClock
*)&This
->IReferenceClock_vtbl
) {
154 cur
= This
->play_time
+ time_from_pos(This
, playpos
);
155 cur
-= This
->renderer
.filter
.rtStreamStart
;
156 } else if (This
->renderer
.filter
.pClock
) {
157 IReferenceClock_GetTime(This
->renderer
.filter
.pClock
, &cur
);
158 cur
-= This
->renderer
.filter
.rtStreamStart
;
162 if (writepos
== min_writepos
)
167 *ret_writepos
= writepos
;
171 if (writepos
>= playpos
)
172 writepos_t
= cur
+ time_from_pos(This
, writepos
- playpos
);
174 writepos_t
= cur
+ time_from_pos(This
, This
->buf_size
+ writepos
- playpos
);
176 /* write_at: Starting time of sample */
177 /* cur: current time of play position */
178 /* writepos_t: current time of our pointer play position */
179 delta_t
= write_at
- writepos_t
;
180 if (delta_t
>= -max_lag
&& delta_t
<= max_lag
) {
181 TRACE("Continuing from old position\n");
182 *ret_writepos
= writepos
;
183 } else if (delta_t
< 0) {
184 REFERENCE_TIME past
, min_writepos_t
;
185 WARN("Delta too big %i/%i, overwriting old data or even skipping\n", (int)delta_t
/ 10000, (int)max_lag
/ 10000);
186 if (min_writepos
>= playpos
)
187 min_writepos_t
= cur
+ time_from_pos(This
, min_writepos
- playpos
);
189 min_writepos_t
= cur
+ time_from_pos(This
, This
->buf_size
- playpos
+ min_writepos
);
190 past
= min_writepos_t
- write_at
;
192 DWORD skipbytes
= pos_from_time(This
, past
);
193 WARN("Skipping %u bytes\n", skipbytes
);
195 *ret_writepos
= min_writepos
;
197 DWORD aheadbytes
= pos_from_time(This
, -past
);
198 WARN("Advancing %u bytes\n", aheadbytes
);
199 *ret_writepos
= (min_writepos
+ aheadbytes
) % This
->buf_size
;
201 } else /* delta_t > 0 */ {
203 WARN("Delta too big %i/%i, too far ahead\n", (int)delta_t
/ 10000, (int)max_lag
/ 10000);
204 aheadbytes
= pos_from_time(This
, delta_t
);
205 WARN("Advancing %u bytes\n", aheadbytes
);
206 if (delta_t
>= DSoundRenderer_Max_Fill
)
208 *ret_writepos
= (min_writepos
+ aheadbytes
) % This
->buf_size
;
211 if (playpos
> *ret_writepos
)
212 *pfree
= playpos
- *ret_writepos
;
213 else if (playpos
== *ret_writepos
)
214 *pfree
= This
->buf_size
- wfx
->nBlockAlign
;
216 *pfree
= This
->buf_size
+ playpos
- *ret_writepos
;
217 if (time_from_pos(This
, This
->buf_size
- *pfree
) >= DSoundRenderer_Max_Fill
) {
218 TRACE("Blocked: too full %i / %i\n", (int)(time_from_pos(This
, This
->buf_size
- *pfree
)/10000), (int)(DSoundRenderer_Max_Fill
/ 10000));
224 static HRESULT
DSoundRender_HandleEndOfStream(DSoundRenderImpl
*This
)
227 IMediaEventSink
*pEventSink
;
232 DSoundRender_UpdatePositions(This
, &pos1
, &pos2
);
237 LeaveCriticalSection(&This
->renderer
.filter
.csFilter
);
238 LeaveCriticalSection(&This
->renderer
.csRenderLock
);
239 WaitForSingleObject(This
->blocked
, 10);
240 EnterCriticalSection(&This
->renderer
.filter
.csFilter
);
241 EnterCriticalSection(&This
->renderer
.csRenderLock
);
243 if (This
->renderer
.pInputPin
->flushing
||
244 This
->renderer
.filter
.state
!= State_Running
) {
245 SetEvent(This
->renderer
.evComplete
);
250 if (!This
->renderer
.filter
.filterInfo
.pGraph
)
253 hr
= IFilterGraph_QueryInterface(This
->renderer
.filter
.filterInfo
.pGraph
, &IID_IMediaEventSink
, (LPVOID
*)&pEventSink
);
256 hr
= IMediaEventSink_Notify(pEventSink
, EC_COMPLETE
, S_OK
, (LONG_PTR
)This
);
257 IMediaEventSink_Release(pEventSink
);
262 static HRESULT
DSoundRender_SendSampleData(DSoundRenderImpl
* This
, REFERENCE_TIME tStart
, REFERENCE_TIME tStop
, const BYTE
*data
, DWORD size
)
266 while (size
&& This
->renderer
.filter
.state
!= State_Stopped
) {
267 DWORD writepos
, skip
= 0, free
, size1
, size2
, ret
;
270 if (This
->renderer
.filter
.state
== State_Running
)
271 hr
= DSoundRender_GetWritePos(This
, &writepos
, tStart
, &free
, &skip
);
277 LeaveCriticalSection(&This
->renderer
.csRenderLock
);
278 ret
= WaitForSingleObject(This
->blocked
, 10);
279 EnterCriticalSection(&This
->renderer
.csRenderLock
);
281 if (This
->renderer
.pInputPin
->flushing
||
282 This
->renderer
.filter
.state
== State_Stopped
) {
283 SetEvent(This
->renderer
.evComplete
);
284 return This
->renderer
.filter
.state
== State_Paused
? S_OK
: VFW_E_WRONG_STATE
;
286 if (ret
!= WAIT_TIMEOUT
)
293 FIXME("Sample dropped %u of %u bytes\n", skip
, size
);
299 hr
= IDirectSoundBuffer_Lock(This
->dsbuffer
, writepos
, min(free
, size
), (void**)&buf1
, &size1
, (void**)&buf2
, &size2
, 0);
301 ERR("Unable to lock sound buffer! (%x)\n", hr
);
304 memcpy(buf1
, data
, size1
);
306 memcpy(buf2
, data
+size1
, size2
);
307 IDirectSoundBuffer_Unlock(This
->dsbuffer
, buf1
, size1
, buf2
, size2
);
308 This
->writepos
= (writepos
+ size1
+ size2
) % This
->buf_size
;
309 TRACE("Wrote %u bytes at %u, next at %u - (%u/%u)\n", size1
+size2
, writepos
, This
->writepos
, free
, size
);
310 data
+= size1
+ size2
;
311 size
-= size1
+ size2
;
316 static HRESULT WINAPI
DSoundRender_ShouldDrawSampleNow(BaseRenderer
*This
, IMediaSample
*pMediaSample
, REFERENCE_TIME
*pStartTime
, REFERENCE_TIME
*pEndTime
)
318 /* We time ourselves do not use the base renderers timing */
323 HRESULT WINAPI
DSoundRender_PrepareReceive(BaseRenderer
*iface
, IMediaSample
*pSample
)
325 DSoundRenderImpl
*This
= impl_from_BaseRenderer(iface
);
329 if (IMediaSample_GetMediaType(pSample
, &amt
) == S_OK
)
331 AM_MEDIA_TYPE
*orig
= &This
->renderer
.pInputPin
->pin
.mtCurrent
;
332 WAVEFORMATEX
*origfmt
= (WAVEFORMATEX
*)orig
->pbFormat
;
333 WAVEFORMATEX
*newfmt
= (WAVEFORMATEX
*)amt
->pbFormat
;
335 if (origfmt
->wFormatTag
== newfmt
->wFormatTag
&&
336 origfmt
->nChannels
== newfmt
->nChannels
&&
337 origfmt
->nBlockAlign
== newfmt
->nBlockAlign
&&
338 origfmt
->wBitsPerSample
== newfmt
->wBitsPerSample
&&
339 origfmt
->cbSize
== newfmt
->cbSize
)
341 if (origfmt
->nSamplesPerSec
!= newfmt
->nSamplesPerSec
)
343 hr
= IDirectSoundBuffer_SetFrequency(This
->dsbuffer
,
344 newfmt
->nSamplesPerSec
);
346 return VFW_E_TYPE_NOT_ACCEPTED
;
348 CopyMediaType(orig
, amt
);
349 IMediaSample_SetMediaType(pSample
, NULL
);
353 return VFW_E_TYPE_NOT_ACCEPTED
;
358 static HRESULT WINAPI
DSoundRender_DoRenderSample(BaseRenderer
*iface
, IMediaSample
* pSample
)
360 DSoundRenderImpl
*This
= impl_from_BaseRenderer(iface
);
361 LPBYTE pbSrcStream
= NULL
;
362 LONG cbSrcStream
= 0;
363 REFERENCE_TIME tStart
, tStop
;
366 TRACE("%p %p\n", iface
, pSample
);
368 /* Slightly incorrect, Pause completes when a frame is received so we should signal
369 * pause completion here, but for sound playing a single frame doesn't make sense
372 hr
= IMediaSample_GetPointer(pSample
, &pbSrcStream
);
375 ERR("Cannot get pointer to sample data (%x)\n", hr
);
379 hr
= IMediaSample_GetTime(pSample
, &tStart
, &tStop
);
381 ERR("Cannot get sample time (%x)\n", hr
);
385 IMediaSample_IsDiscontinuity(pSample
);
387 if (IMediaSample_IsPreroll(pSample
) == S_OK
)
393 cbSrcStream
= IMediaSample_GetActualDataLength(pSample
);
394 TRACE("Sample data ptr = %p, size = %d\n", pbSrcStream
, cbSrcStream
);
396 hr
= DSoundRender_SendSampleData(This
, tStart
, tStop
, pbSrcStream
, cbSrcStream
);
397 if (This
->renderer
.filter
.state
== State_Running
&& This
->renderer
.filter
.pClock
&& tStart
>= 0) {
398 REFERENCE_TIME jitter
, now
= 0;
400 IReferenceClock_GetTime(This
->renderer
.filter
.pClock
, &now
);
401 jitter
= now
- This
->renderer
.filter
.rtStreamStart
- tStart
;
402 if (jitter
<= -DSoundRenderer_Max_Fill
)
403 jitter
+= DSoundRenderer_Max_Fill
;
406 q
.Type
= (jitter
> 0 ? Famine
: Flood
);
409 q
.TimeStamp
= tStart
;
410 IQualityControl_Notify((IQualityControl
*)This
->renderer
.qcimpl
, (IBaseFilter
*)This
, q
);
415 static HRESULT WINAPI
DSoundRender_CheckMediaType(BaseRenderer
*iface
, const AM_MEDIA_TYPE
* pmt
)
417 WAVEFORMATEX
* format
;
419 if (!IsEqualIID(&pmt
->majortype
, &MEDIATYPE_Audio
))
422 format
= (WAVEFORMATEX
*)pmt
->pbFormat
;
423 TRACE("Format = %p\n", format
);
424 TRACE("wFormatTag = %x %x\n", format
->wFormatTag
, WAVE_FORMAT_PCM
);
425 TRACE("nChannels = %d\n", format
->nChannels
);
426 TRACE("nSamplesPerSec = %d\n", format
->nAvgBytesPerSec
);
427 TRACE("nAvgBytesPerSec = %d\n", format
->nAvgBytesPerSec
);
428 TRACE("nBlockAlign = %d\n", format
->nBlockAlign
);
429 TRACE("wBitsPerSample = %d\n", format
->wBitsPerSample
);
431 if (!IsEqualIID(&pmt
->subtype
, &MEDIASUBTYPE_PCM
))
437 static VOID WINAPI
DSoundRender_OnStopStreaming(BaseRenderer
* iface
)
439 DSoundRenderImpl
*This
= impl_from_BaseRenderer(iface
);
441 TRACE("(%p/%p)->()\n", This
, iface
);
443 IDirectSoundBuffer_Stop(This
->dsbuffer
);
444 This
->writepos
= This
->buf_size
;
445 SetEvent(This
->blocked
);
448 static VOID WINAPI
DSoundRender_OnStartStreaming(BaseRenderer
* iface
)
450 DSoundRenderImpl
*This
= impl_from_BaseRenderer(iface
);
452 TRACE("(%p)\n", This
);
454 if (This
->renderer
.pInputPin
->pin
.pConnectedTo
)
456 if (This
->renderer
.filter
.state
== State_Paused
)
458 /* Unblock our thread, state changing from paused to running doesn't need a reset for state change */
459 SetEvent(This
->blocked
);
461 else if (This
->renderer
.filter
.state
== State_Stopped
)
463 ResetEvent(This
->renderer
.evComplete
);
464 This
->renderer
.pInputPin
->end_of_stream
= 0;
466 IDirectSoundBuffer_Play(This
->dsbuffer
, 0, 0, DSBPLAY_LOOPING
);
467 ResetEvent(This
->blocked
);
471 static HRESULT WINAPI
DSoundRender_CompleteConnect(BaseRenderer
* iface
, IPin
* pReceivePin
)
473 DSoundRenderImpl
*This
= impl_from_BaseRenderer(iface
);
474 const AM_MEDIA_TYPE
* pmt
= &This
->renderer
.pInputPin
->pin
.mtCurrent
;
476 WAVEFORMATEX
*format
;
477 DSBUFFERDESC buf_desc
;
479 TRACE("(%p)->(%p)\n", This
, pReceivePin
);
480 dump_AM_MEDIA_TYPE(pmt
);
482 TRACE("MajorType %s\n", debugstr_guid(&pmt
->majortype
));
483 TRACE("SubType %s\n", debugstr_guid(&pmt
->subtype
));
484 TRACE("Format %s\n", debugstr_guid(&pmt
->formattype
));
485 TRACE("Size %d\n", pmt
->cbFormat
);
487 format
= (WAVEFORMATEX
*)pmt
->pbFormat
;
489 This
->buf_size
= format
->nAvgBytesPerSec
;
491 memset(&buf_desc
,0,sizeof(DSBUFFERDESC
));
492 buf_desc
.dwSize
= sizeof(DSBUFFERDESC
);
493 buf_desc
.dwFlags
= DSBCAPS_CTRLVOLUME
| DSBCAPS_CTRLPAN
|
494 DSBCAPS_CTRLFREQUENCY
| DSBCAPS_GLOBALFOCUS
|
495 DSBCAPS_GETCURRENTPOSITION2
;
496 buf_desc
.dwBufferBytes
= This
->buf_size
;
497 buf_desc
.lpwfxFormat
= format
;
498 hr
= IDirectSound_CreateSoundBuffer(This
->dsound
, &buf_desc
, &This
->dsbuffer
, NULL
);
499 This
->writepos
= This
->buf_size
;
501 ERR("Can't create sound buffer (%x)\n", hr
);
505 hr
= IDirectSoundBuffer_SetVolume(This
->dsbuffer
, This
->volume
);
507 ERR("Can't set volume to %d (%x)\n", This
->volume
, hr
);
509 hr
= IDirectSoundBuffer_SetPan(This
->dsbuffer
, This
->pan
);
511 ERR("Can't set pan to %d (%x)\n", This
->pan
, hr
);
515 if (FAILED(hr
) && hr
!= VFW_E_ALREADY_CONNECTED
)
518 IDirectSoundBuffer_Release(This
->dsbuffer
);
519 This
->dsbuffer
= NULL
;
525 static HRESULT WINAPI
DSoundRender_BreakConnect(BaseRenderer
* iface
)
527 DSoundRenderImpl
*This
= impl_from_BaseRenderer(iface
);
529 TRACE("(%p)->()\n", iface
);
531 if (This
->threadid
) {
532 PostThreadMessageW(This
->threadid
, WM_APP
, 0, 0);
533 WaitForSingleObject(This
->advisethread
, INFINITE
);
534 CloseHandle(This
->advisethread
);
537 IDirectSoundBuffer_Release(This
->dsbuffer
);
538 This
->dsbuffer
= NULL
;
543 static HRESULT WINAPI
DSoundRender_EndOfStream(BaseRenderer
* iface
)
545 DSoundRenderImpl
*This
= impl_from_BaseRenderer(iface
);
548 TRACE("(%p)->()\n",iface
);
550 hr
= BaseRendererImpl_EndOfStream(iface
);
557 hr
= DSoundRender_HandleEndOfStream(This
);
562 static HRESULT WINAPI
DSoundRender_BeginFlush(BaseRenderer
* iface
)
564 DSoundRenderImpl
*This
= impl_from_BaseRenderer(iface
);
567 BaseRendererImpl_BeginFlush(iface
);
568 SetEvent(This
->blocked
);
573 static HRESULT WINAPI
DSoundRender_EndFlush(BaseRenderer
* iface
)
575 DSoundRenderImpl
*This
= impl_from_BaseRenderer(iface
);
579 BaseRendererImpl_EndFlush(iface
);
581 ResetEvent(This
->renderer
.evComplete
);
582 LeaveCriticalSection(This
->renderer
.pInputPin
->pin
.pCritSec
);
583 LeaveCriticalSection(&This
->renderer
.filter
.csFilter
);
584 LeaveCriticalSection(&This
->renderer
.csRenderLock
);
585 WaitForSingleObject(This
->renderer
.evComplete
, -1);
586 EnterCriticalSection(This
->renderer
.pInputPin
->pin
.pCritSec
);
587 EnterCriticalSection(&This
->renderer
.filter
.csFilter
);
588 EnterCriticalSection(&This
->renderer
.csRenderLock
);
590 if (This
->renderer
.filter
.state
!= State_Stopped
)
591 ResetEvent(This
->blocked
);
599 IDirectSoundBuffer_Lock(This
->dsbuffer
, 0, 0, (LPVOID
*)&buffer
, &size
, NULL
, NULL
, DSBLOCK_ENTIREBUFFER
);
600 memset(buffer
, 0, size
);
601 IDirectSoundBuffer_Unlock(This
->dsbuffer
, buffer
, size
, NULL
, 0);
602 This
->writepos
= This
->buf_size
;
608 static const BaseRendererFuncTable BaseFuncTable
= {
609 DSoundRender_CheckMediaType
,
610 DSoundRender_DoRenderSample
,
615 DSoundRender_OnStartStreaming
,
616 DSoundRender_OnStopStreaming
,
620 DSoundRender_ShouldDrawSampleNow
,
621 DSoundRender_PrepareReceive
,
623 DSoundRender_CompleteConnect
,
624 DSoundRender_BreakConnect
,
625 DSoundRender_EndOfStream
,
626 DSoundRender_BeginFlush
,
627 DSoundRender_EndFlush
,
630 HRESULT
DSoundRender_create(IUnknown
* pUnkOuter
, LPVOID
* ppv
)
633 DSoundRenderImpl
* pDSoundRender
;
635 TRACE("(%p, %p)\n", pUnkOuter
, ppv
);
640 return CLASS_E_NOAGGREGATION
;
642 pDSoundRender
= CoTaskMemAlloc(sizeof(DSoundRenderImpl
));
644 return E_OUTOFMEMORY
;
645 ZeroMemory(pDSoundRender
, sizeof(DSoundRenderImpl
));
647 hr
= BaseRenderer_Init(&pDSoundRender
->renderer
, &DSoundRender_Vtbl
, (IUnknown
*)pDSoundRender
, &CLSID_DSoundRender
, (DWORD_PTR
)(__FILE__
": DSoundRenderImpl.csFilter"), &BaseFuncTable
);
649 pDSoundRender
->IBasicAudio_vtbl
= &IBasicAudio_Vtbl
;
650 pDSoundRender
->IReferenceClock_vtbl
= &IReferenceClock_Vtbl
;
651 pDSoundRender
->IAMDirectSound_vtbl
= &IAMDirectSound_Vtbl
;
652 pDSoundRender
->IAMFilterMiscFlags_vtbl
= &IAMFilterMiscFlags_Vtbl
;
656 hr
= DirectSoundCreate8(NULL
, &pDSoundRender
->dsound
, NULL
);
658 ERR("Cannot create Direct Sound object (%x)\n", hr
);
660 hr
= IDirectSound_SetCooperativeLevel(pDSoundRender
->dsound
, GetDesktopWindow(), DSSCL_PRIORITY
);
662 IDirectSoundBuffer
*buf
;
663 DSBUFFERDESC buf_desc
;
664 memset(&buf_desc
,0,sizeof(DSBUFFERDESC
));
665 buf_desc
.dwSize
= sizeof(DSBUFFERDESC
);
666 buf_desc
.dwFlags
= DSBCAPS_PRIMARYBUFFER
;
667 hr
= IDirectSound_CreateSoundBuffer(pDSoundRender
->dsound
, &buf_desc
, &buf
, NULL
);
669 IDirectSoundBuffer_Play(buf
, 0, 0, DSBPLAY_LOOPING
);
670 IUnknown_Release(buf
);
678 pDSoundRender
->blocked
= CreateEventW(NULL
, TRUE
, TRUE
, NULL
);
680 if (!pDSoundRender
->blocked
|| FAILED(hr
))
682 IUnknown_Release((IUnknown
*)pDSoundRender
);
683 return HRESULT_FROM_WIN32(GetLastError());
686 *ppv
= pDSoundRender
;
690 BaseRendererImpl_Release(&pDSoundRender
->renderer
.filter
.IBaseFilter_iface
);
691 CoTaskMemFree(pDSoundRender
);
697 static HRESULT WINAPI
DSoundRender_QueryInterface(IBaseFilter
* iface
, REFIID riid
, LPVOID
* ppv
)
699 DSoundRenderImpl
*This
= impl_from_IBaseFilter(iface
);
700 TRACE("(%p, %p)->(%s, %p)\n", This
, iface
, qzdebugstr_guid(riid
), ppv
);
704 if (IsEqualIID(riid
, &IID_IBasicAudio
))
705 *ppv
= &This
->IBasicAudio_vtbl
;
706 else if (IsEqualIID(riid
, &IID_IReferenceClock
))
707 *ppv
= &This
->IReferenceClock_vtbl
;
708 else if (IsEqualIID(riid
, &IID_IAMDirectSound
))
709 *ppv
= &This
->IAMDirectSound_vtbl
;
710 else if (IsEqualIID(riid
, &IID_IAMFilterMiscFlags
))
711 *ppv
= &This
->IAMFilterMiscFlags_vtbl
;
715 hr
= BaseRendererImpl_QueryInterface(iface
, riid
, ppv
);
722 IUnknown_AddRef((IUnknown
*)(*ppv
));
726 if (!IsEqualIID(riid
, &IID_IPin
) && !IsEqualIID(riid
, &IID_IVideoWindow
))
727 FIXME("No interface for %s!\n", qzdebugstr_guid(riid
));
729 return E_NOINTERFACE
;
732 static ULONG WINAPI
DSoundRender_Release(IBaseFilter
* iface
)
734 DSoundRenderImpl
*This
= impl_from_IBaseFilter(iface
);
735 ULONG refCount
= BaseRendererImpl_Release(iface
);
737 TRACE("(%p)->() Release from %d\n", This
, refCount
+ 1);
741 if (This
->threadid
) {
742 PostThreadMessageW(This
->threadid
, WM_APP
, 0, 0);
743 WaitForSingleObject(This
->advisethread
, INFINITE
);
744 CloseHandle(This
->advisethread
);
748 IDirectSoundBuffer_Release(This
->dsbuffer
);
749 This
->dsbuffer
= NULL
;
751 IDirectSound_Release(This
->dsound
);
754 This
->IBasicAudio_vtbl
= NULL
;
756 CloseHandle(This
->blocked
);
758 TRACE("Destroying Audio Renderer\n");
767 static const IBaseFilterVtbl DSoundRender_Vtbl
=
769 DSoundRender_QueryInterface
,
770 BaseFilterImpl_AddRef
,
771 DSoundRender_Release
,
772 BaseFilterImpl_GetClassID
,
773 BaseRendererImpl_Stop
,
774 BaseRendererImpl_Pause
,
775 BaseRendererImpl_Run
,
776 BaseRendererImpl_GetState
,
777 BaseRendererImpl_SetSyncSource
,
778 BaseFilterImpl_GetSyncSource
,
779 BaseFilterImpl_EnumPins
,
780 BaseRendererImpl_FindPin
,
781 BaseFilterImpl_QueryFilterInfo
,
782 BaseFilterImpl_JoinFilterGraph
,
783 BaseFilterImpl_QueryVendorInfo
786 /*** IUnknown methods ***/
787 static HRESULT WINAPI
Basicaudio_QueryInterface(IBasicAudio
*iface
,
790 ICOM_THIS_MULTI(DSoundRenderImpl
, IBasicAudio_vtbl
, iface
);
792 TRACE("(%p/%p)->(%s (%p), %p)\n", This
, iface
, debugstr_guid(riid
), riid
, ppvObj
);
794 return DSoundRender_QueryInterface(&This
->renderer
.filter
.IBaseFilter_iface
, riid
, ppvObj
);
797 static ULONG WINAPI
Basicaudio_AddRef(IBasicAudio
*iface
) {
798 ICOM_THIS_MULTI(DSoundRenderImpl
, IBasicAudio_vtbl
, iface
);
800 TRACE("(%p/%p)->()\n", This
, iface
);
802 return BaseFilterImpl_AddRef(&This
->renderer
.filter
.IBaseFilter_iface
);
805 static ULONG WINAPI
Basicaudio_Release(IBasicAudio
*iface
) {
806 ICOM_THIS_MULTI(DSoundRenderImpl
, IBasicAudio_vtbl
, iface
);
808 TRACE("(%p/%p)->()\n", This
, iface
);
810 return DSoundRender_Release(&This
->renderer
.filter
.IBaseFilter_iface
);
813 /*** IDispatch methods ***/
814 static HRESULT WINAPI
Basicaudio_GetTypeInfoCount(IBasicAudio
*iface
,
816 ICOM_THIS_MULTI(DSoundRenderImpl
, IBasicAudio_vtbl
, iface
);
818 TRACE("(%p/%p)->(%p): stub !!!\n", This
, iface
, pctinfo
);
823 static HRESULT WINAPI
Basicaudio_GetTypeInfo(IBasicAudio
*iface
,
826 ITypeInfo
**ppTInfo
) {
827 ICOM_THIS_MULTI(DSoundRenderImpl
, IBasicAudio_vtbl
, iface
);
829 TRACE("(%p/%p)->(%d, %d, %p): stub !!!\n", This
, iface
, iTInfo
, lcid
, ppTInfo
);
834 static HRESULT WINAPI
Basicaudio_GetIDsOfNames(IBasicAudio
*iface
,
840 ICOM_THIS_MULTI(DSoundRenderImpl
, IBasicAudio_vtbl
, iface
);
842 TRACE("(%p/%p)->(%s (%p), %p, %d, %d, %p): stub !!!\n", This
, iface
, debugstr_guid(riid
), riid
, rgszNames
, cNames
, lcid
, rgDispId
);
847 static HRESULT WINAPI
Basicaudio_Invoke(IBasicAudio
*iface
,
852 DISPPARAMS
*pDispParams
,
856 ICOM_THIS_MULTI(DSoundRenderImpl
, IBasicAudio_vtbl
, iface
);
858 TRACE("(%p/%p)->(%d, %s (%p), %d, %04x, %p, %p, %p, %p): stub !!!\n", This
, iface
, dispIdMember
, debugstr_guid(riid
), riid
, lcid
, wFlags
, pDispParams
, pVarResult
, pExepInfo
, puArgErr
);
863 /*** IBasicAudio methods ***/
864 static HRESULT WINAPI
Basicaudio_put_Volume(IBasicAudio
*iface
,
866 ICOM_THIS_MULTI(DSoundRenderImpl
, IBasicAudio_vtbl
, iface
);
868 TRACE("(%p/%p)->(%d)\n", This
, iface
, lVolume
);
870 if (lVolume
> DSBVOLUME_MAX
|| lVolume
< DSBVOLUME_MIN
)
873 if (This
->dsbuffer
) {
874 if (FAILED(IDirectSoundBuffer_SetVolume(This
->dsbuffer
, lVolume
)))
878 This
->volume
= lVolume
;
882 static HRESULT WINAPI
Basicaudio_get_Volume(IBasicAudio
*iface
,
884 ICOM_THIS_MULTI(DSoundRenderImpl
, IBasicAudio_vtbl
, iface
);
886 TRACE("(%p/%p)->(%p)\n", This
, iface
, plVolume
);
891 *plVolume
= This
->volume
;
895 static HRESULT WINAPI
Basicaudio_put_Balance(IBasicAudio
*iface
,
897 ICOM_THIS_MULTI(DSoundRenderImpl
, IBasicAudio_vtbl
, iface
);
899 TRACE("(%p/%p)->(%d)\n", This
, iface
, lBalance
);
901 if (lBalance
< DSBPAN_LEFT
|| lBalance
> DSBPAN_RIGHT
)
904 if (This
->dsbuffer
) {
905 if (FAILED(IDirectSoundBuffer_SetPan(This
->dsbuffer
, lBalance
)))
909 This
->pan
= lBalance
;
913 static HRESULT WINAPI
Basicaudio_get_Balance(IBasicAudio
*iface
,
915 ICOM_THIS_MULTI(DSoundRenderImpl
, IBasicAudio_vtbl
, iface
);
917 TRACE("(%p/%p)->(%p)\n", This
, iface
, plBalance
);
922 *plBalance
= This
->pan
;
926 static const IBasicAudioVtbl IBasicAudio_Vtbl
=
928 Basicaudio_QueryInterface
,
931 Basicaudio_GetTypeInfoCount
,
932 Basicaudio_GetTypeInfo
,
933 Basicaudio_GetIDsOfNames
,
935 Basicaudio_put_Volume
,
936 Basicaudio_get_Volume
,
937 Basicaudio_put_Balance
,
938 Basicaudio_get_Balance
941 struct dsoundrender_timer
{
942 struct dsoundrender_timer
*next
;
943 REFERENCE_TIME start
;
944 REFERENCE_TIME periodicity
;
948 static LONG cookie_counter
= 1;
950 static DWORD WINAPI
DSoundAdviseThread(LPVOID lpParam
) {
951 DSoundRenderImpl
*This
= lpParam
;
952 struct dsoundrender_timer head
= { };
955 TRACE("(%p): Main Loop\n", This
);
957 PeekMessageW(&msg
, NULL
, WM_USER
, WM_USER
, PM_NOREMOVE
);
958 SetEvent(This
->thread_wait
);
963 REFERENCE_TIME curtime
= 0;
965 struct dsoundrender_timer
*prev
= &head
, *cur
;
967 hr
= IReferenceClock_GetTime((IReferenceClock
*) &This
->IReferenceClock_vtbl
, &curtime
);
969 FIXME("Could not get time: %08x\n", hr
);
972 TRACE("Time: %s\n", wine_dbgstr_longlong(curtime
));
975 if (cur
->start
> curtime
) {
976 TRACE("Skipping %p\n", cur
);
978 } else if (cur
->periodicity
) {
979 while (cur
->start
<= curtime
) {
980 cur
->start
+= cur
->periodicity
;
981 ReleaseSemaphore(cur
->handle
, 1, NULL
);
985 struct dsoundrender_timer
*next
= cur
->next
;
986 TRACE("Firing %p %s < %s\n", cur
, wine_dbgstr_longlong(cur
->start
), wine_dbgstr_longlong(curtime
));
987 SetEvent(cur
->handle
);
988 HeapFree(GetProcessHeap(), 0, cur
);
993 ret
= GetMessageW(&msg
, INVALID_HANDLE_VALUE
, WM_APP
, WM_APP
+ 4);
995 ret
= PeekMessageW(&msg
, INVALID_HANDLE_VALUE
, WM_APP
, WM_APP
+ 4, PM_REMOVE
);
997 switch (LOWORD(msg
.message
) - WM_APP
) {
998 case 0: TRACE("Exiting\n"); return 0;
1001 struct dsoundrender_timer
*t
= (struct dsoundrender_timer
*)msg
.wParam
;
1002 if (LOWORD(msg
.message
) - WM_APP
== 1)
1003 TRACE("Adding one-shot timer %p\n", t
);
1005 TRACE("Adding periodic timer %p\n", t
);
1006 t
->next
= head
.next
;
1012 while (prev
->next
) {
1014 if (cur
->cookie
== msg
.wParam
) {
1015 struct dsoundrender_timer
*next
= cur
->next
;
1016 HeapFree(GetProcessHeap(), 0, cur
);
1024 ret
= PeekMessageW(&msg
, INVALID_HANDLE_VALUE
, WM_APP
, WM_APP
+ 4, PM_REMOVE
);
1026 MsgWaitForMultipleObjects(0, NULL
, 5, QS_POSTMESSAGE
, 0);
1031 /*** IUnknown methods ***/
1032 static HRESULT WINAPI
ReferenceClock_QueryInterface(IReferenceClock
*iface
,
1036 ICOM_THIS_MULTI(DSoundRenderImpl
, IReferenceClock_vtbl
, iface
);
1038 TRACE("(%p/%p)->(%s (%p), %p)\n", This
, iface
, debugstr_guid(riid
), riid
, ppvObj
);
1040 return DSoundRender_QueryInterface(&This
->renderer
.filter
.IBaseFilter_iface
, riid
, ppvObj
);
1043 static ULONG WINAPI
ReferenceClock_AddRef(IReferenceClock
*iface
)
1045 ICOM_THIS_MULTI(DSoundRenderImpl
, IReferenceClock_vtbl
, iface
);
1047 TRACE("(%p/%p)->()\n", This
, iface
);
1049 return BaseFilterImpl_AddRef(&This
->renderer
.filter
.IBaseFilter_iface
);
1052 static ULONG WINAPI
ReferenceClock_Release(IReferenceClock
*iface
)
1054 ICOM_THIS_MULTI(DSoundRenderImpl
, IReferenceClock_vtbl
, iface
);
1056 TRACE("(%p/%p)->()\n", This
, iface
);
1058 return DSoundRender_Release(&This
->renderer
.filter
.IBaseFilter_iface
);
1061 /*** IReferenceClock methods ***/
1062 static HRESULT WINAPI
ReferenceClock_GetTime(IReferenceClock
*iface
,
1063 REFERENCE_TIME
*pTime
)
1065 ICOM_THIS_MULTI(DSoundRenderImpl
, IReferenceClock_vtbl
, iface
);
1066 HRESULT hr
= E_FAIL
;
1068 TRACE("(%p/%p)->(%p)\n", This
, iface
, pTime
);
1072 if (This
->dsbuffer
) {
1073 DWORD writepos1
, writepos2
;
1074 EnterCriticalSection(&This
->renderer
.filter
.csFilter
);
1075 DSoundRender_UpdatePositions(This
, &writepos1
, &writepos2
);
1076 *pTime
= This
->play_time
+ time_from_pos(This
, This
->last_playpos
);
1077 LeaveCriticalSection(&This
->renderer
.filter
.csFilter
);
1081 WARN("Could not get reference time (%x)!\n", hr
);
1086 static HRESULT WINAPI
ReferenceClock_AdviseTime(IReferenceClock
*iface
,
1087 REFERENCE_TIME rtBaseTime
,
1088 REFERENCE_TIME rtStreamTime
,
1090 DWORD_PTR
*pdwAdviseCookie
)
1092 ICOM_THIS_MULTI(DSoundRenderImpl
, IReferenceClock_vtbl
, iface
);
1093 REFERENCE_TIME when
= rtBaseTime
+ rtStreamTime
;
1094 REFERENCE_TIME future
;
1095 TRACE("(%p/%p)->(%s, %s, %p, %p)\n", This
, iface
, wine_dbgstr_longlong(rtBaseTime
), wine_dbgstr_longlong(rtStreamTime
), (void*)hEvent
, pdwAdviseCookie
);
1098 return E_INVALIDARG
;
1100 if (!pdwAdviseCookie
)
1103 EnterCriticalSection(&This
->renderer
.filter
.csFilter
);
1104 future
= when
- This
->play_time
;
1105 if (!This
->threadid
&& This
->dsbuffer
) {
1106 This
->thread_wait
= CreateEventW(0, 0, 0, 0);
1107 This
->advisethread
= CreateThread(NULL
, 0, DSoundAdviseThread
, This
, 0, &This
->threadid
);
1108 WaitForSingleObject(This
->thread_wait
, INFINITE
);
1109 CloseHandle(This
->thread_wait
);
1111 LeaveCriticalSection(&This
->renderer
.filter
.csFilter
);
1112 /* If it's in the past or the next millisecond, trigger immediately */
1113 if (future
<= 10000) {
1114 SetEvent((HANDLE
)hEvent
);
1115 *pdwAdviseCookie
= 0;
1117 struct dsoundrender_timer
*t
= HeapAlloc(GetProcessHeap(), 0, sizeof(*t
));
1121 t
->handle
= (HANDLE
)hEvent
;
1122 t
->cookie
= InterlockedIncrement(&cookie_counter
);
1123 PostThreadMessageW(This
->threadid
, WM_APP
+1, (WPARAM
)t
, 0);
1124 *pdwAdviseCookie
= t
->cookie
;
1130 static HRESULT WINAPI
ReferenceClock_AdvisePeriodic(IReferenceClock
*iface
,
1131 REFERENCE_TIME rtStartTime
,
1132 REFERENCE_TIME rtPeriodTime
,
1133 HSEMAPHORE hSemaphore
,
1134 DWORD_PTR
*pdwAdviseCookie
)
1136 ICOM_THIS_MULTI(DSoundRenderImpl
, IReferenceClock_vtbl
, iface
);
1137 struct dsoundrender_timer
*t
;
1139 TRACE("(%p/%p)->(%s, %s, %p, %p)\n", This
, iface
, wine_dbgstr_longlong(rtStartTime
), wine_dbgstr_longlong(rtPeriodTime
), (void*)hSemaphore
, pdwAdviseCookie
);
1141 if (rtStartTime
<= 0 || rtPeriodTime
<= 0)
1142 return E_INVALIDARG
;
1144 if (!pdwAdviseCookie
)
1147 EnterCriticalSection(&This
->renderer
.filter
.csFilter
);
1148 if (!This
->threadid
&& This
->dsbuffer
) {
1149 This
->thread_wait
= CreateEventW(0, 0, 0, 0);
1150 This
->advisethread
= CreateThread(NULL
, 0, DSoundAdviseThread
, This
, 0, &This
->threadid
);
1151 WaitForSingleObject(This
->thread_wait
, INFINITE
);
1152 CloseHandle(This
->thread_wait
);
1154 LeaveCriticalSection(&This
->renderer
.filter
.csFilter
);
1156 t
= HeapAlloc(GetProcessHeap(), 0, sizeof(*t
));
1158 t
->start
= rtStartTime
;
1159 t
->periodicity
= rtPeriodTime
;
1160 t
->handle
= (HANDLE
)hSemaphore
;
1161 t
->cookie
= InterlockedIncrement(&cookie_counter
);
1162 PostThreadMessageW(This
->threadid
, WM_APP
+1, (WPARAM
)t
, 0);
1163 *pdwAdviseCookie
= t
->cookie
;
1168 static HRESULT WINAPI
ReferenceClock_Unadvise(IReferenceClock
*iface
,
1169 DWORD_PTR dwAdviseCookie
)
1171 ICOM_THIS_MULTI(DSoundRenderImpl
, IReferenceClock_vtbl
, iface
);
1173 TRACE("(%p/%p)->(%p)\n", This
, iface
, (void*)dwAdviseCookie
);
1174 if (!This
->advisethread
|| !dwAdviseCookie
)
1176 PostThreadMessageW(This
->threadid
, WM_APP
+3, dwAdviseCookie
, 0);
1180 static const IReferenceClockVtbl IReferenceClock_Vtbl
=
1182 ReferenceClock_QueryInterface
,
1183 ReferenceClock_AddRef
,
1184 ReferenceClock_Release
,
1185 ReferenceClock_GetTime
,
1186 ReferenceClock_AdviseTime
,
1187 ReferenceClock_AdvisePeriodic
,
1188 ReferenceClock_Unadvise
1191 /*** IUnknown methods ***/
1192 static HRESULT WINAPI
AMDirectSound_QueryInterface(IAMDirectSound
*iface
,
1196 ICOM_THIS_MULTI(DSoundRenderImpl
, IAMDirectSound_vtbl
, iface
);
1198 TRACE("(%p/%p)->(%s (%p), %p)\n", This
, iface
, debugstr_guid(riid
), riid
, ppvObj
);
1200 return DSoundRender_QueryInterface(&This
->renderer
.filter
.IBaseFilter_iface
, riid
, ppvObj
);
1203 static ULONG WINAPI
AMDirectSound_AddRef(IAMDirectSound
*iface
)
1205 ICOM_THIS_MULTI(DSoundRenderImpl
, IAMDirectSound_vtbl
, iface
);
1207 TRACE("(%p/%p)->()\n", This
, iface
);
1209 return BaseFilterImpl_AddRef(&This
->renderer
.filter
.IBaseFilter_iface
);
1212 static ULONG WINAPI
AMDirectSound_Release(IAMDirectSound
*iface
)
1214 ICOM_THIS_MULTI(DSoundRenderImpl
, IAMDirectSound_vtbl
, iface
);
1216 TRACE("(%p/%p)->()\n", This
, iface
);
1218 return DSoundRender_Release(&This
->renderer
.filter
.IBaseFilter_iface
);
1221 /*** IAMDirectSound methods ***/
1222 static HRESULT WINAPI
AMDirectSound_GetDirectSoundInterface(IAMDirectSound
*iface
, IDirectSound
**ds
)
1224 ICOM_THIS_MULTI(DSoundRenderImpl
, IAMDirectSound_vtbl
, iface
);
1226 FIXME("(%p/%p)->(%p): stub\n", This
, iface
, ds
);
1231 static HRESULT WINAPI
AMDirectSound_GetPrimaryBufferInterface(IAMDirectSound
*iface
, IDirectSoundBuffer
**buf
)
1233 ICOM_THIS_MULTI(DSoundRenderImpl
, IAMDirectSound_vtbl
, iface
);
1235 FIXME("(%p/%p)->(%p): stub\n", This
, iface
, buf
);
1240 static HRESULT WINAPI
AMDirectSound_GetSecondaryBufferInterface(IAMDirectSound
*iface
, IDirectSoundBuffer
**buf
)
1242 ICOM_THIS_MULTI(DSoundRenderImpl
, IAMDirectSound_vtbl
, iface
);
1244 FIXME("(%p/%p)->(%p): stub\n", This
, iface
, buf
);
1249 static HRESULT WINAPI
AMDirectSound_ReleaseDirectSoundInterface(IAMDirectSound
*iface
, IDirectSound
*ds
)
1251 ICOM_THIS_MULTI(DSoundRenderImpl
, IAMDirectSound_vtbl
, iface
);
1253 FIXME("(%p/%p)->(%p): stub\n", This
, iface
, ds
);
1258 static HRESULT WINAPI
AMDirectSound_ReleasePrimaryBufferInterface(IAMDirectSound
*iface
, IDirectSoundBuffer
*buf
)
1260 ICOM_THIS_MULTI(DSoundRenderImpl
, IAMDirectSound_vtbl
, iface
);
1262 FIXME("(%p/%p)->(%p): stub\n", This
, iface
, buf
);
1267 static HRESULT WINAPI
AMDirectSound_ReleaseSecondaryBufferInterface(IAMDirectSound
*iface
, IDirectSoundBuffer
*buf
)
1269 ICOM_THIS_MULTI(DSoundRenderImpl
, IAMDirectSound_vtbl
, iface
);
1271 FIXME("(%p/%p)->(%p): stub\n", This
, iface
, buf
);
1276 static HRESULT WINAPI
AMDirectSound_SetFocusWindow(IAMDirectSound
*iface
, HWND hwnd
, BOOL bgsilent
)
1278 ICOM_THIS_MULTI(DSoundRenderImpl
, IAMDirectSound_vtbl
, iface
);
1280 FIXME("(%p/%p)->(%p,%d): stub\n", This
, iface
, hwnd
, bgsilent
);
1285 static HRESULT WINAPI
AMDirectSound_GetFocusWindow(IAMDirectSound
*iface
, HWND hwnd
)
1287 ICOM_THIS_MULTI(DSoundRenderImpl
, IAMDirectSound_vtbl
, iface
);
1289 FIXME("(%p/%p)->(%p): stub\n", This
, iface
, hwnd
);
1294 static const IAMDirectSoundVtbl IAMDirectSound_Vtbl
=
1296 AMDirectSound_QueryInterface
,
1297 AMDirectSound_AddRef
,
1298 AMDirectSound_Release
,
1299 AMDirectSound_GetDirectSoundInterface
,
1300 AMDirectSound_GetPrimaryBufferInterface
,
1301 AMDirectSound_GetSecondaryBufferInterface
,
1302 AMDirectSound_ReleaseDirectSoundInterface
,
1303 AMDirectSound_ReleasePrimaryBufferInterface
,
1304 AMDirectSound_ReleaseSecondaryBufferInterface
,
1305 AMDirectSound_SetFocusWindow
,
1306 AMDirectSound_GetFocusWindow
1309 static DSoundRenderImpl
*from_IAMFilterMiscFlags(IAMFilterMiscFlags
*iface
) {
1310 return (DSoundRenderImpl
*)((char*)iface
- offsetof(DSoundRenderImpl
, IAMFilterMiscFlags_vtbl
));
1313 static HRESULT WINAPI
AMFilterMiscFlags_QueryInterface(IAMFilterMiscFlags
*iface
, REFIID riid
, void **ppv
) {
1314 DSoundRenderImpl
*This
= from_IAMFilterMiscFlags(iface
);
1315 return IUnknown_QueryInterface((IUnknown
*)This
, riid
, ppv
);
1318 static ULONG WINAPI
AMFilterMiscFlags_AddRef(IAMFilterMiscFlags
*iface
) {
1319 DSoundRenderImpl
*This
= from_IAMFilterMiscFlags(iface
);
1320 return IUnknown_AddRef((IUnknown
*)This
);
1323 static ULONG WINAPI
AMFilterMiscFlags_Release(IAMFilterMiscFlags
*iface
) {
1324 DSoundRenderImpl
*This
= from_IAMFilterMiscFlags(iface
);
1325 return IUnknown_Release((IUnknown
*)This
);
1328 static ULONG WINAPI
AMFilterMiscFlags_GetMiscFlags(IAMFilterMiscFlags
*iface
) {
1329 return AM_FILTER_MISC_FLAGS_IS_RENDERER
;
1332 static const IAMFilterMiscFlagsVtbl IAMFilterMiscFlags_Vtbl
= {
1333 AMFilterMiscFlags_QueryInterface
,
1334 AMFilterMiscFlags_AddRef
,
1335 AMFilterMiscFlags_Release
,
1336 AMFilterMiscFlags_GetMiscFlags