mshtml.idl: Added HTMLDocumentEvents and HTMLDocumentEvents2 dispifaces.
[wine] / dlls / quartz / dsoundrender.c
1 /*
2  * Direct Sound Audio Renderer
3  *
4  * Copyright 2004 Christian Costa
5  *
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.
10  *
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.
15  *
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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  */
20
21 #include "config.h"
22
23 #include "quartz_private.h"
24 #include "control_private.h"
25 #include "pin.h"
26
27 #include "uuids.h"
28 #include "mmreg.h"
29 #include "vfwmsgs.h"
30 #include "fourcc.h"
31 #include "windef.h"
32 #include "winbase.h"
33 #include "dshow.h"
34 #include "evcode.h"
35 #include "strmif.h"
36 #include "dsound.h"
37
38 #include "wine/unicode.h"
39 #include "wine/debug.h"
40
41 WINE_DEFAULT_DEBUG_CHANNEL(quartz);
42
43 static const WCHAR wcsInputPinName[] = {'i','n','p','u','t',' ','p','i','n',0};
44
45 static const IBaseFilterVtbl DSoundRender_Vtbl;
46 static const IPinVtbl DSoundRender_InputPin_Vtbl;
47 static const IMemInputPinVtbl MemInputPin_Vtbl; 
48 static const IBasicAudioVtbl IBasicAudio_Vtbl;
49
50 typedef struct DSoundRenderImpl
51 {
52     const IBaseFilterVtbl * lpVtbl;
53     const IBasicAudioVtbl *IBasicAudio_vtbl;
54
55     LONG refCount;
56     CRITICAL_SECTION csFilter;
57     FILTER_STATE state;
58     REFERENCE_TIME rtStreamStart;
59     IReferenceClock * pClock;
60     FILTER_INFO filterInfo;
61
62     InputPin * pInputPin;
63     IPin ** ppPins;
64
65     LPDIRECTSOUND dsound;
66     LPDIRECTSOUNDBUFFER dsbuffer;
67     DWORD write_pos;
68     BOOL init;
69     BOOL started;
70 } DSoundRenderImpl;
71
72 static HRESULT DSoundRender_InputPin_Construct(const PIN_INFO * pPinInfo, SAMPLEPROC pSampleProc, LPVOID pUserData, QUERYACCEPTPROC pQueryAccept, LPCRITICAL_SECTION pCritSec, IPin ** ppPin)
73 {
74     InputPin * pPinImpl;
75
76     *ppPin = NULL;
77
78     if (pPinInfo->dir != PINDIR_INPUT)
79     {
80         ERR("Pin direction(%x) != PINDIR_INPUT\n", pPinInfo->dir);
81         return E_INVALIDARG;
82     }
83
84     pPinImpl = CoTaskMemAlloc(sizeof(*pPinImpl));
85
86     if (!pPinImpl)
87         return E_OUTOFMEMORY;
88
89     if (SUCCEEDED(InputPin_Init(pPinInfo, pSampleProc, pUserData, pQueryAccept, pCritSec, pPinImpl)))
90     {
91         pPinImpl->pin.lpVtbl = &DSoundRender_InputPin_Vtbl;
92         pPinImpl->lpVtblMemInput = &MemInputPin_Vtbl;
93         
94         *ppPin = (IPin *)(&pPinImpl->pin.lpVtbl);
95         return S_OK;
96     }
97     return E_FAIL;
98 }
99
100
101 #define DSBUFFERSIZE 8192
102
103 static HRESULT DSoundRender_CreateSoundBuffer(IBaseFilter * iface)
104 {
105     HRESULT hr;
106     WAVEFORMATEX wav_fmt;
107     AM_MEDIA_TYPE amt;
108     WAVEFORMATEX* format;
109     DSBUFFERDESC buf_desc;
110     DSoundRenderImpl *This = (DSoundRenderImpl *)iface;
111
112     hr = IPin_ConnectionMediaType(This->ppPins[0], &amt);
113     if (FAILED(hr)) {
114         ERR("Unable to retrieve media type\n");
115         return hr;
116     }
117
118     TRACE("MajorType %s\n", debugstr_guid(&amt.majortype));
119     TRACE("SubType %s\n", debugstr_guid(&amt.subtype));
120     TRACE("Format %s\n", debugstr_guid(&amt.formattype));
121     TRACE("Size %ld\n", amt.cbFormat);
122
123     dump_AM_MEDIA_TYPE(&amt);
124     
125     format = (WAVEFORMATEX*)amt.pbFormat;
126     TRACE("wFormatTag = %x %x\n", format->wFormatTag, WAVE_FORMAT_PCM);
127     TRACE("nChannels = %d\n", format->nChannels);
128     TRACE("nSamplesPerSec = %lu\n", format->nSamplesPerSec);
129     TRACE("nAvgBytesPerSec = %lu\n", format->nAvgBytesPerSec);
130     TRACE("nBlockAlign = %d\n", format->nBlockAlign);
131     TRACE("wBitsPerSample = %d\n", format->wBitsPerSample);
132     TRACE("cbSize = %d\n", format->cbSize);
133     
134     hr = DirectSoundCreate(NULL, &This->dsound, NULL);
135     if (FAILED(hr)) {
136         ERR("Cannot create Direct Sound object\n");
137         return hr;
138     }
139
140     wav_fmt = *format;
141     wav_fmt.cbSize = 0;
142
143     memset(&buf_desc,0,sizeof(DSBUFFERDESC));
144     buf_desc.dwSize = sizeof(DSBUFFERDESC);
145     buf_desc.dwBufferBytes = DSBUFFERSIZE;
146     buf_desc.lpwfxFormat = &wav_fmt;
147     hr = IDirectSound_CreateSoundBuffer(This->dsound, &buf_desc, &This->dsbuffer, NULL);
148     if (FAILED(hr)) {
149         ERR("Can't create sound buffer !\n");
150         IDirectSound_Release(This->dsound);
151         return hr;
152     }
153
154     This->write_pos = 0;
155     
156     return hr;
157 }
158
159 static HRESULT DSoundRender_SendSampleData(DSoundRenderImpl* This, LPBYTE data, DWORD size)
160 {
161     HRESULT hr;
162     LPBYTE lpbuf1 = NULL;
163     LPBYTE lpbuf2 = NULL;
164     DWORD dwsize1 = 0;
165     DWORD dwsize2 = 0;
166     DWORD size2;
167     DWORD play_pos,buf_free;
168
169     while (1)
170     {
171         hr = IDirectSoundBuffer_GetCurrentPosition(This->dsbuffer, &play_pos, NULL);
172         if (hr != DS_OK)
173         {
174             ERR("Error GetCurrentPosition: %lx\n", hr);
175             break;
176         }
177         if (This->write_pos < play_pos)
178              buf_free = play_pos-This->write_pos;
179         else
180              buf_free = DSBUFFERSIZE - This->write_pos + play_pos;
181
182         size2 = min(buf_free, size);
183         hr = IDirectSoundBuffer_Lock(This->dsbuffer, This->write_pos, size2, &lpbuf1, &dwsize1, &lpbuf2, &dwsize2, 0);
184         if (hr != DS_OK) {
185             ERR("Unable to lock sound buffer! (%lx)\n", hr);
186             break;
187         }
188         /* TRACE("write_pos=%ld, size=%ld, sz1=%ld, sz2=%ld\n", This->write_pos, size2, dwsize1, dwsize2); */
189
190         memcpy(lpbuf1, data, dwsize1);
191         if (dwsize2)
192             memcpy(lpbuf2, data + dwsize1, dwsize2);
193
194         hr = IDirectSoundBuffer_Unlock(This->dsbuffer, lpbuf1, dwsize1, lpbuf2, dwsize2);
195         if (hr != DS_OK)
196             ERR("Unable to unlock sound buffer! (%lx)\n", hr);
197         if (!This->started)
198         {
199             hr = IDirectSoundBuffer_Play(This->dsbuffer, 0, 0, DSBPLAY_LOOPING);
200             if (hr == DS_OK)
201                 This->started = TRUE;
202             else
203                 ERR("Can't start playing! (%lx)\n", hr);
204         }
205         size -= dwsize1 + dwsize2;
206         data += dwsize1 + dwsize2;
207         This->write_pos = (This->write_pos + dwsize1 + dwsize2) % DSBUFFERSIZE;
208
209         if (!size)
210             break;
211         Sleep(10);
212     }
213
214     return hr;
215 }
216
217 static HRESULT DSoundRender_Sample(LPVOID iface, IMediaSample * pSample)
218 {
219     DSoundRenderImpl *This = (DSoundRenderImpl *)iface;
220     LPBYTE pbSrcStream = NULL;
221     long cbSrcStream = 0;
222     REFERENCE_TIME tStart, tStop;
223     HRESULT hr;
224
225     TRACE("%p %p\n", iface, pSample);
226     
227     hr = IMediaSample_GetPointer(pSample, &pbSrcStream);
228     if (FAILED(hr))
229     {
230         ERR("Cannot get pointer to sample data (%lx)\n", hr);
231         return hr;
232     }
233
234     hr = IMediaSample_GetTime(pSample, &tStart, &tStop);
235     if (FAILED(hr))
236         ERR("Cannot get sample time (%lx)\n", hr);
237
238     cbSrcStream = IMediaSample_GetActualDataLength(pSample);
239
240     TRACE("Sample data ptr = %p, size = %ld\n", pbSrcStream, cbSrcStream);
241
242 #if 0 /* For debugging purpose */
243     {
244         int i;
245         for(i = 0; i < cbSrcStream; i++)
246         {
247             if ((i!=0) && !(i%16))
248                 TRACE("\n");
249             TRACE("%02x ", pbSrcStream[i]);
250         }
251         TRACE("\n");
252     }
253 #endif
254   
255     if (!This->init)
256     {
257         hr = DSoundRender_CreateSoundBuffer(iface);
258         if (SUCCEEDED(hr))
259             This->init = TRUE;
260         else
261         {
262             ERR("Unable to create DSound buffer\n");
263             return hr;
264         }
265     }
266     
267     hr = DSoundRender_SendSampleData(This, pbSrcStream, cbSrcStream);
268
269     return hr;
270 }
271
272 static HRESULT DSoundRender_QueryAccept(LPVOID iface, const AM_MEDIA_TYPE * pmt)
273 {
274     WAVEFORMATEX* format = (WAVEFORMATEX*)pmt->pbFormat;
275     TRACE("wFormatTag = %x %x\n", format->wFormatTag, WAVE_FORMAT_PCM);
276     TRACE("nChannels = %d\n", format->nChannels);
277     TRACE("nSamplesPerSec = %ld\n", format->nAvgBytesPerSec);
278     TRACE("nAvgBytesPerSec = %ld\n", format->nAvgBytesPerSec);
279     TRACE("nBlockAlign = %d\n", format->nBlockAlign);
280     TRACE("wBitsPerSample = %d\n", format->wBitsPerSample);
281
282     if (IsEqualIID(&pmt->majortype, &MEDIATYPE_Audio) && IsEqualIID(&pmt->subtype, &MEDIASUBTYPE_PCM))
283         return S_OK;
284     return S_FALSE;
285 }
286
287 HRESULT DSoundRender_create(IUnknown * pUnkOuter, LPVOID * ppv)
288 {
289     HRESULT hr;
290     PIN_INFO piInput;
291     DSoundRenderImpl * pDSoundRender;
292
293     TRACE("(%p, %p)\n", pUnkOuter, ppv);
294
295     *ppv = NULL;
296
297     if (pUnkOuter)
298         return CLASS_E_NOAGGREGATION;
299     
300     pDSoundRender = CoTaskMemAlloc(sizeof(DSoundRenderImpl));
301
302     pDSoundRender->lpVtbl = &DSoundRender_Vtbl;
303     pDSoundRender->IBasicAudio_vtbl = &IBasicAudio_Vtbl;
304     pDSoundRender->refCount = 1;
305     InitializeCriticalSection(&pDSoundRender->csFilter);
306     pDSoundRender->state = State_Stopped;
307     pDSoundRender->pClock = NULL;
308     pDSoundRender->init = FALSE;
309     pDSoundRender->started = FALSE;
310     ZeroMemory(&pDSoundRender->filterInfo, sizeof(FILTER_INFO));
311
312     pDSoundRender->ppPins = CoTaskMemAlloc(1 * sizeof(IPin *));
313
314     /* construct input pin */
315     piInput.dir = PINDIR_INPUT;
316     piInput.pFilter = (IBaseFilter *)pDSoundRender;
317     lstrcpynW(piInput.achName, wcsInputPinName, sizeof(piInput.achName) / sizeof(piInput.achName[0]));
318     hr = DSoundRender_InputPin_Construct(&piInput, DSoundRender_Sample, (LPVOID)pDSoundRender, DSoundRender_QueryAccept, &pDSoundRender->csFilter, (IPin **)&pDSoundRender->pInputPin);
319
320     if (SUCCEEDED(hr))
321     {
322         pDSoundRender->ppPins[0] = (IPin *)pDSoundRender->pInputPin;
323         *ppv = (LPVOID)pDSoundRender;
324     }
325     else
326     {
327         CoTaskMemFree(pDSoundRender->ppPins);
328         DeleteCriticalSection(&pDSoundRender->csFilter);
329         CoTaskMemFree(pDSoundRender);
330     }
331
332     return hr;
333 }
334
335 static HRESULT WINAPI DSoundRender_QueryInterface(IBaseFilter * iface, REFIID riid, LPVOID * ppv)
336 {
337     DSoundRenderImpl *This = (DSoundRenderImpl *)iface;
338     TRACE("(%p, %p)->(%s, %p)\n", This, iface, qzdebugstr_guid(riid), ppv);
339
340     *ppv = NULL;
341
342     if (IsEqualIID(riid, &IID_IUnknown))
343         *ppv = (LPVOID)This;
344     else if (IsEqualIID(riid, &IID_IPersist))
345         *ppv = (LPVOID)This;
346     else if (IsEqualIID(riid, &IID_IMediaFilter))
347         *ppv = (LPVOID)This;
348     else if (IsEqualIID(riid, &IID_IBaseFilter))
349         *ppv = (LPVOID)This;
350     else if (IsEqualIID(riid, &IID_IBaseFilter))
351         *ppv = (LPVOID)&(This->IBasicAudio_vtbl);
352
353     if (*ppv)
354     {
355         IUnknown_AddRef((IUnknown *)(*ppv));
356         return S_OK;
357     }
358
359     FIXME("No interface for %s!\n", qzdebugstr_guid(riid));
360
361     return E_NOINTERFACE;
362 }
363
364 static ULONG WINAPI DSoundRender_AddRef(IBaseFilter * iface)
365 {
366     DSoundRenderImpl *This = (DSoundRenderImpl *)iface;
367     ULONG refCount = InterlockedIncrement(&This->refCount);
368
369     TRACE("(%p/%p)->() AddRef from %ld\n", This, iface, refCount - 1);
370
371     return refCount;
372 }
373
374 static ULONG WINAPI DSoundRender_Release(IBaseFilter * iface)
375 {
376     DSoundRenderImpl *This = (DSoundRenderImpl *)iface;
377     ULONG refCount = InterlockedDecrement(&This->refCount);
378
379     TRACE("(%p/%p)->() Release from %ld\n", This, iface, refCount + 1);
380
381     if (!refCount)
382     {
383         DeleteCriticalSection(&This->csFilter);
384         if (This->pClock)
385             IReferenceClock_Release(This->pClock);
386        
387         IPin_Release(This->ppPins[0]);
388         
389         HeapFree(GetProcessHeap(), 0, This->ppPins);
390         This->lpVtbl = NULL;
391         This->IBasicAudio_vtbl = NULL;
392         
393         TRACE("Destroying Audio Renderer\n");
394         CoTaskMemFree(This);
395         
396         return 0;
397     }
398     else
399         return refCount;
400 }
401
402 /** IPersist methods **/
403
404 static HRESULT WINAPI DSoundRender_GetClassID(IBaseFilter * iface, CLSID * pClsid)
405 {
406     DSoundRenderImpl *This = (DSoundRenderImpl *)iface;
407     TRACE("(%p/%p)->(%p)\n", This, iface, pClsid);
408
409     *pClsid = CLSID_DSoundRender;
410
411     return S_OK;
412 }
413
414 /** IMediaFilter methods **/
415
416 static HRESULT WINAPI DSoundRender_Stop(IBaseFilter * iface)
417 {
418     HRESULT hr = S_OK;
419     DSoundRenderImpl *This = (DSoundRenderImpl *)iface;
420
421     TRACE("(%p/%p)->()\n", This, iface);
422
423     EnterCriticalSection(&This->csFilter);
424     {
425         This->state = State_Stopped;
426     }
427     LeaveCriticalSection(&This->csFilter);
428     
429     return hr;
430 }
431
432 static HRESULT WINAPI DSoundRender_Pause(IBaseFilter * iface)
433 {
434     HRESULT hr = S_OK;
435     DSoundRenderImpl *This = (DSoundRenderImpl *)iface;
436     
437     TRACE("(%p/%p)->()\n", This, iface);
438
439     EnterCriticalSection(&This->csFilter);
440     {
441         This->state = State_Paused;
442     }
443     LeaveCriticalSection(&This->csFilter);
444
445     return hr;
446 }
447
448 static HRESULT WINAPI DSoundRender_Run(IBaseFilter * iface, REFERENCE_TIME tStart)
449 {
450     HRESULT hr = S_OK;
451     DSoundRenderImpl *This = (DSoundRenderImpl *)iface;
452
453     TRACE("(%p/%p)->(%s)\n", This, iface, wine_dbgstr_longlong(tStart));
454
455     EnterCriticalSection(&This->csFilter);
456     {
457         This->rtStreamStart = tStart;
458         This->state = State_Running;
459     }
460     LeaveCriticalSection(&This->csFilter);
461
462     return hr;
463 }
464
465 static HRESULT WINAPI DSoundRender_GetState(IBaseFilter * iface, DWORD dwMilliSecsTimeout, FILTER_STATE *pState)
466 {
467     DSoundRenderImpl *This = (DSoundRenderImpl *)iface;
468
469     TRACE("(%p/%p)->(%ld, %p)\n", This, iface, dwMilliSecsTimeout, pState);
470
471     EnterCriticalSection(&This->csFilter);
472     {
473         *pState = This->state;
474     }
475     LeaveCriticalSection(&This->csFilter);
476
477     return S_OK;
478 }
479
480 static HRESULT WINAPI DSoundRender_SetSyncSource(IBaseFilter * iface, IReferenceClock *pClock)
481 {
482     DSoundRenderImpl *This = (DSoundRenderImpl *)iface;
483
484     TRACE("(%p/%p)->(%p)\n", This, iface, pClock);
485
486     EnterCriticalSection(&This->csFilter);
487     {
488         if (This->pClock)
489             IReferenceClock_Release(This->pClock);
490         This->pClock = pClock;
491         if (This->pClock)
492             IReferenceClock_AddRef(This->pClock);
493     }
494     LeaveCriticalSection(&This->csFilter);
495
496     return S_OK;
497 }
498
499 static HRESULT WINAPI DSoundRender_GetSyncSource(IBaseFilter * iface, IReferenceClock **ppClock)
500 {
501     DSoundRenderImpl *This = (DSoundRenderImpl *)iface;
502
503     TRACE("(%p/%p)->(%p)\n", This, iface, ppClock);
504
505     EnterCriticalSection(&This->csFilter);
506     {
507         *ppClock = This->pClock;
508         IReferenceClock_AddRef(This->pClock);
509     }
510     LeaveCriticalSection(&This->csFilter);
511     
512     return S_OK;
513 }
514
515 /** IBaseFilter implementation **/
516
517 static HRESULT WINAPI DSoundRender_EnumPins(IBaseFilter * iface, IEnumPins **ppEnum)
518 {
519     ENUMPINDETAILS epd;
520     DSoundRenderImpl *This = (DSoundRenderImpl *)iface;
521
522     TRACE("(%p/%p)->(%p)\n", This, iface, ppEnum);
523
524     epd.cPins = 1; /* input pin */
525     epd.ppPins = This->ppPins;
526     return IEnumPinsImpl_Construct(&epd, ppEnum);
527 }
528
529 static HRESULT WINAPI DSoundRender_FindPin(IBaseFilter * iface, LPCWSTR Id, IPin **ppPin)
530 {
531     DSoundRenderImpl *This = (DSoundRenderImpl *)iface;
532
533     TRACE("(%p/%p)->(%s,%p)\n", This, iface, debugstr_w(Id), ppPin);
534     
535     FIXME("DSoundRender::FindPin(...)\n");
536
537     /* FIXME: critical section */
538
539     return E_NOTIMPL;
540 }
541
542 static HRESULT WINAPI DSoundRender_QueryFilterInfo(IBaseFilter * iface, FILTER_INFO *pInfo)
543 {
544     DSoundRenderImpl *This = (DSoundRenderImpl *)iface;
545
546     TRACE("(%p/%p)->(%p)\n", This, iface, pInfo);
547
548     strcpyW(pInfo->achName, This->filterInfo.achName);
549     pInfo->pGraph = This->filterInfo.pGraph;
550
551     if (pInfo->pGraph)
552         IFilterGraph_AddRef(pInfo->pGraph);
553     
554     return S_OK;
555 }
556
557 static HRESULT WINAPI DSoundRender_JoinFilterGraph(IBaseFilter * iface, IFilterGraph *pGraph, LPCWSTR pName)
558 {
559     DSoundRenderImpl *This = (DSoundRenderImpl *)iface;
560
561     TRACE("(%p/%p)->(%p, %s)\n", This, iface, pGraph, debugstr_w(pName));
562
563     EnterCriticalSection(&This->csFilter);
564     {
565         if (pName)
566             strcpyW(This->filterInfo.achName, pName);
567         else
568             *This->filterInfo.achName = '\0';
569         This->filterInfo.pGraph = pGraph; /* NOTE: do NOT increase ref. count */
570     }
571     LeaveCriticalSection(&This->csFilter);
572
573     return S_OK;
574 }
575
576 static HRESULT WINAPI DSoundRender_QueryVendorInfo(IBaseFilter * iface, LPWSTR *pVendorInfo)
577 {
578     DSoundRenderImpl *This = (DSoundRenderImpl *)iface;
579     TRACE("(%p/%p)->(%p)\n", This, iface, pVendorInfo);
580     return E_NOTIMPL;
581 }
582
583 static const IBaseFilterVtbl DSoundRender_Vtbl =
584 {
585     DSoundRender_QueryInterface,
586     DSoundRender_AddRef,
587     DSoundRender_Release,
588     DSoundRender_GetClassID,
589     DSoundRender_Stop,
590     DSoundRender_Pause,
591     DSoundRender_Run,
592     DSoundRender_GetState,
593     DSoundRender_SetSyncSource,
594     DSoundRender_GetSyncSource,
595     DSoundRender_EnumPins,
596     DSoundRender_FindPin,
597     DSoundRender_QueryFilterInfo,
598     DSoundRender_JoinFilterGraph,
599     DSoundRender_QueryVendorInfo
600 };
601
602 static HRESULT WINAPI DSoundRender_InputPin_EndOfStream(IPin * iface)
603 {
604     InputPin* This = (InputPin*)iface;
605     IMediaEventSink* pEventSink;
606     HRESULT hr;
607
608     TRACE("(%p/%p)->()\n", This, iface);
609
610     hr = IFilterGraph_QueryInterface(((DSoundRenderImpl*)This->pin.pinInfo.pFilter)->filterInfo.pGraph, &IID_IMediaEventSink, (LPVOID*)&pEventSink);
611     if (SUCCEEDED(hr))
612     {
613         /* FIXME: We should wait that all audio data has been played */
614         hr = IMediaEventSink_Notify(pEventSink, EC_COMPLETE, S_OK, 0);
615         IMediaEventSink_Release(pEventSink);
616     }
617
618     return hr;
619 }
620
621 static const IPinVtbl DSoundRender_InputPin_Vtbl = 
622 {
623     InputPin_QueryInterface,
624     IPinImpl_AddRef,
625     InputPin_Release,
626     InputPin_Connect,
627     InputPin_ReceiveConnection,
628     IPinImpl_Disconnect,
629     IPinImpl_ConnectedTo,
630     IPinImpl_ConnectionMediaType,
631     IPinImpl_QueryPinInfo,
632     IPinImpl_QueryDirection,
633     IPinImpl_QueryId,
634     IPinImpl_QueryAccept,
635     IPinImpl_EnumMediaTypes,
636     IPinImpl_QueryInternalConnections,
637     DSoundRender_InputPin_EndOfStream,
638     InputPin_BeginFlush,
639     InputPin_EndFlush,
640     InputPin_NewSegment
641 };
642
643 static const IMemInputPinVtbl MemInputPin_Vtbl = 
644 {
645     MemInputPin_QueryInterface,
646     MemInputPin_AddRef,
647     MemInputPin_Release,
648     MemInputPin_GetAllocator,
649     MemInputPin_NotifyAllocator,
650     MemInputPin_GetAllocatorRequirements,
651     MemInputPin_Receive,
652     MemInputPin_ReceiveMultiple,
653     MemInputPin_ReceiveCanBlock
654 };
655
656 /*** IUnknown methods ***/
657 static HRESULT WINAPI Basicaudio_QueryInterface(IBasicAudio *iface,
658                                                 REFIID riid,
659                                                 LPVOID*ppvObj) {
660     ICOM_THIS_MULTI(DSoundRenderImpl, IBasicAudio_vtbl, iface);
661
662     TRACE("(%p/%p)->(%s (%p), %p)\n", This, iface, debugstr_guid(riid), riid, ppvObj);
663
664     return DSoundRender_QueryInterface((IBaseFilter*)This, riid, ppvObj);
665 }
666
667 static ULONG WINAPI Basicaudio_AddRef(IBasicAudio *iface) {
668     ICOM_THIS_MULTI(DSoundRenderImpl, IBasicAudio_vtbl, iface);
669
670     TRACE("(%p/%p)->()\n", This, iface);
671
672     return DSoundRender_AddRef((IBaseFilter*)This);
673 }
674
675 static ULONG WINAPI Basicaudio_Release(IBasicAudio *iface) {
676     ICOM_THIS_MULTI(DSoundRenderImpl, IBasicAudio_vtbl, iface);
677
678     TRACE("(%p/%p)->()\n", This, iface);
679
680     return DSoundRender_Release((IBaseFilter*)This);
681 }
682
683 /*** IDispatch methods ***/
684 static HRESULT WINAPI Basicaudio_GetTypeInfoCount(IBasicAudio *iface,
685                                                   UINT*pctinfo) {
686     ICOM_THIS_MULTI(DSoundRenderImpl, IBasicAudio_vtbl, iface);
687
688     TRACE("(%p/%p)->(%p): stub !!!\n", This, iface, pctinfo);
689
690     return S_OK;
691 }
692
693 static HRESULT WINAPI Basicaudio_GetTypeInfo(IBasicAudio *iface,
694                                              UINT iTInfo,
695                                              LCID lcid,
696                                              ITypeInfo**ppTInfo) {
697     ICOM_THIS_MULTI(DSoundRenderImpl, IBasicAudio_vtbl, iface);
698
699     TRACE("(%p/%p)->(%d, %ld, %p): stub !!!\n", This, iface, iTInfo, lcid, ppTInfo);
700
701     return S_OK;
702 }
703
704 static HRESULT WINAPI Basicaudio_GetIDsOfNames(IBasicAudio *iface,
705                                                REFIID riid,
706                                                LPOLESTR*rgszNames,
707                                                UINT cNames,
708                                                LCID lcid,
709                                                DISPID*rgDispId) {
710     ICOM_THIS_MULTI(DSoundRenderImpl, IBasicAudio_vtbl, iface);
711
712     TRACE("(%p/%p)->(%s (%p), %p, %d, %ld, %p): stub !!!\n", This, iface, debugstr_guid(riid), riid, rgszNames, cNames, lcid, rgDispId);
713
714     return S_OK;
715 }
716
717 static HRESULT WINAPI Basicaudio_Invoke(IBasicAudio *iface,
718                                         DISPID dispIdMember,
719                                         REFIID riid,
720                                         LCID lcid,
721                                         WORD wFlags,
722                                         DISPPARAMS*pDispParams,
723                                         VARIANT*pVarResult,
724                                         EXCEPINFO*pExepInfo,
725                                         UINT*puArgErr) {
726     ICOM_THIS_MULTI(DSoundRenderImpl, IBasicAudio_vtbl, iface);
727
728     TRACE("(%p/%p)->(%ld, %s (%p), %ld, %04x, %p, %p, %p, %p): stub !!!\n", This, iface, dispIdMember, debugstr_guid(riid), riid, lcid, wFlags, pDispParams, pVarResult, pExepInfo, puArgErr);
729
730     return S_OK;
731 }
732
733 /*** IBasicAudio methods ***/
734 static HRESULT WINAPI Basicaudio_put_Volume(IBasicAudio *iface,
735                                             long lVolume) {
736     ICOM_THIS_MULTI(DSoundRenderImpl, IBasicAudio_vtbl, iface);
737
738     TRACE("(%p/%p)->(%ld): stub !!!\n", This, iface, lVolume);
739
740     return S_OK;
741 }
742
743 static HRESULT WINAPI Basicaudio_get_Volume(IBasicAudio *iface,
744                                             long *plVolume) {
745     ICOM_THIS_MULTI(DSoundRenderImpl, IBasicAudio_vtbl, iface);
746
747     TRACE("(%p/%p)->(%p): stub !!!\n", This, iface, plVolume);
748
749     return S_OK;
750 }
751
752 static HRESULT WINAPI Basicaudio_put_Balance(IBasicAudio *iface,
753                                              long lBalance) {
754     ICOM_THIS_MULTI(DSoundRenderImpl, IBasicAudio_vtbl, iface);
755
756     TRACE("(%p/%p)->(%ld): stub !!!\n", This, iface, lBalance);
757
758     return S_OK;
759 }
760
761 static HRESULT WINAPI Basicaudio_get_Balance(IBasicAudio *iface,
762                                              long *plBalance) {
763     ICOM_THIS_MULTI(DSoundRenderImpl, IBasicAudio_vtbl, iface);
764
765     TRACE("(%p/%p)->(%p): stub !!!\n", This, iface, plBalance);
766
767     return S_OK;
768 }
769
770 static const IBasicAudioVtbl IBasicAudio_Vtbl =
771 {
772     Basicaudio_QueryInterface,
773     Basicaudio_AddRef,
774     Basicaudio_Release,
775     Basicaudio_GetTypeInfoCount,
776     Basicaudio_GetTypeInfo,
777     Basicaudio_GetIDsOfNames,
778     Basicaudio_Invoke,
779     Basicaudio_put_Volume,
780     Basicaudio_get_Volume,
781     Basicaudio_put_Balance,
782     Basicaudio_get_Balance
783 };