Reverse the order for deleting the items in resetcontent to correctly
[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     ULONG refCount;
56     CRITICAL_SECTION csFilter;
57     FILTER_STATE state;
58     REFERENCE_TIME rtStreamStart;
59     IReferenceClock * pClock;
60     FILTER_INFO filterInfo;
61     IMediaEventSink * pEventSink;
62
63     InputPin * pInputPin;
64     IPin ** ppPins;
65
66     LPDIRECTSOUND dsound;
67     LPDIRECTSOUNDBUFFER dsbuffer;
68     DWORD write_pos;
69     int init;
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         return hr;
151     }
152
153     This->write_pos = 0;
154     
155     return hr;
156 }
157
158 static DWORD DSoundRender_SendSampleData(DSoundRenderImpl* This, LPBYTE data, DWORD size)
159 {
160     HRESULT result;
161     LPBYTE lpbuf1 = NULL;
162     LPBYTE lpbuf2 = NULL;
163     DWORD dwsize1 = 0;
164     DWORD dwsize2 = 0;
165     static int init_;
166     DWORD size2;
167     DWORD play_pos,buf_free;
168
169     while (1)
170     {
171         result=IDirectSoundBuffer_GetCurrentPosition(This->dsbuffer, &play_pos, NULL);
172         if (result != DS_OK) {
173           ERR("Error GetCurrentPosition: %lx\n", result);
174           break;
175         }
176         if (This->write_pos < play_pos)
177            buf_free = play_pos-This->write_pos;
178         else
179            buf_free = DSBUFFERSIZE - This->write_pos + play_pos;
180
181         size2 = min(buf_free, size);
182         result = IDirectSoundBuffer_Lock(This->dsbuffer, This->write_pos, size2, &lpbuf1, &dwsize1, &lpbuf2, &dwsize2, 0);
183         if (result != DS_OK) {
184           ERR("Unable to lock sound buffer !\n");
185           break;
186         }
187         /* TRACE("write_pos=%ld, size=%ld, sz1=%ld, sz2=%ld\n", This->write_pos, size2, dwsize1, dwsize2); */
188
189         memcpy(lpbuf1, data, dwsize1);
190         if (dwsize2) {
191             memcpy(lpbuf2, data + dwsize1, dwsize2);
192         }
193
194         result = IDirectSoundBuffer_Unlock(This->dsbuffer, lpbuf1, dwsize1, lpbuf2, dwsize2);
195         if (result != DS_OK)
196             ERR("Unable to unlock sound buffer !\n");
197         if (!init_)
198         {
199             result = IDirectSoundBuffer_Play(This->dsbuffer, 0, 0, DSBPLAY_LOOPING);
200             if (result != DS_OK) {
201                 ERR("Can't start playing !\n");
202             }
203         }
204         size -= dwsize1 + dwsize2;
205         data += dwsize1 + dwsize2;
206         This->write_pos = (This->write_pos + dwsize1 + dwsize2) % DSBUFFERSIZE;
207
208         if (!size)
209           break;
210         Sleep(10);
211     }
212     return 0;
213 }
214
215 static HRESULT DSoundRender_Sample(LPVOID iface, IMediaSample * pSample)
216 {
217     DSoundRenderImpl *This = (DSoundRenderImpl *)iface;
218     LPBYTE pbSrcStream = NULL;
219     long cbSrcStream = 0;
220     REFERENCE_TIME tStart, tStop;
221     HRESULT hr;
222
223     TRACE("%p %p\n", iface, pSample);
224     
225     hr = IMediaSample_GetPointer(pSample, &pbSrcStream);
226     if (FAILED(hr))
227     {
228         ERR("Cannot get pointer to sample data (%lx)\n", hr);
229         return hr;
230     }
231
232     hr = IMediaSample_GetTime(pSample, &tStart, &tStop);
233     if (FAILED(hr))
234         ERR("Cannot get sample time (%lx)\n", hr);
235
236     cbSrcStream = IMediaSample_GetActualDataLength(pSample);
237
238     TRACE("Sample data ptr = %p, size = %ld\n", pbSrcStream, cbSrcStream);
239
240 #if 0 /* For debugging purpose */
241     {
242         int i;
243         for(i = 0; i < cbSrcStream; i++)
244         {
245             if ((i!=0) && !(i%16))
246                 DPRINTF("\n");
247             DPRINTF("%02x ", pbSrcStream[i]);
248         }
249         DPRINTF("\n");
250     }
251 #endif
252   
253     if (!This->init)
254     {
255         This->init = 1;
256         hr = DSoundRender_CreateSoundBuffer(iface);
257         if (FAILED(hr))
258         {
259             ERR("Unable to create DSound buffer\n");
260         }
261     }
262     DSoundRender_SendSampleData(This, pbSrcStream, cbSrcStream);
263     
264     return S_OK;
265 }
266
267 static HRESULT DSoundRender_QueryAccept(LPVOID iface, const AM_MEDIA_TYPE * pmt)
268 {
269     WAVEFORMATEX* format = (WAVEFORMATEX*)pmt->pbFormat;
270     TRACE("wFormatTag = %x %x\n", format->wFormatTag, WAVE_FORMAT_PCM);
271     TRACE("nChannels = %d\n", format->nChannels);
272     TRACE("nSamplesPerSec = %ld\n", format->nAvgBytesPerSec);
273     TRACE("nAvgBytesPerSec = %ld\n", format->nAvgBytesPerSec);
274     TRACE("nBlockAlign = %d\n", format->nBlockAlign);
275     TRACE("wBitsPerSample = %d\n", format->wBitsPerSample);
276
277     if (IsEqualIID(&pmt->majortype, &MEDIATYPE_Audio) && IsEqualIID(&pmt->subtype, &MEDIASUBTYPE_PCM))
278         return S_OK;
279     return S_FALSE;
280 }
281
282 HRESULT DSoundRender_create(IUnknown * pUnkOuter, LPVOID * ppv)
283 {
284     HRESULT hr;
285     PIN_INFO piInput;
286     DSoundRenderImpl * pDSoundRender;
287
288     TRACE("(%p, %p)\n", pUnkOuter, ppv);
289
290     *ppv = NULL;
291
292     if (pUnkOuter)
293         return CLASS_E_NOAGGREGATION;
294     
295     pDSoundRender = CoTaskMemAlloc(sizeof(DSoundRenderImpl));
296
297     pDSoundRender->lpVtbl = &DSoundRender_Vtbl;
298     pDSoundRender->IBasicAudio_vtbl = &IBasicAudio_Vtbl;
299     pDSoundRender->refCount = 1;
300     InitializeCriticalSection(&pDSoundRender->csFilter);
301     pDSoundRender->state = State_Stopped;
302     pDSoundRender->pClock = NULL;
303     pDSoundRender->init = 0;
304     ZeroMemory(&pDSoundRender->filterInfo, sizeof(FILTER_INFO));
305
306     pDSoundRender->ppPins = CoTaskMemAlloc(1 * sizeof(IPin *));
307
308     /* construct input pin */
309     piInput.dir = PINDIR_INPUT;
310     piInput.pFilter = (IBaseFilter *)pDSoundRender;
311     strncpyW(piInput.achName, wcsInputPinName, sizeof(piInput.achName) / sizeof(piInput.achName[0]));
312     hr = DSoundRender_InputPin_Construct(&piInput, DSoundRender_Sample, (LPVOID)pDSoundRender, DSoundRender_QueryAccept, &pDSoundRender->csFilter, (IPin **)&pDSoundRender->pInputPin);
313
314     if (SUCCEEDED(hr))
315     {
316         pDSoundRender->ppPins[0] = (IPin *)pDSoundRender->pInputPin;
317         *ppv = (LPVOID)pDSoundRender;
318     }
319     else
320     {
321         CoTaskMemFree(pDSoundRender->ppPins);
322         DeleteCriticalSection(&pDSoundRender->csFilter);
323         CoTaskMemFree(pDSoundRender);
324     }
325
326     return hr;
327 }
328
329 static HRESULT WINAPI DSoundRender_QueryInterface(IBaseFilter * iface, REFIID riid, LPVOID * ppv)
330 {
331     DSoundRenderImpl *This = (DSoundRenderImpl *)iface;
332     TRACE("(%p, %p)->(%s, %p)\n", This, iface, qzdebugstr_guid(riid), ppv);
333
334     *ppv = NULL;
335
336     if (IsEqualIID(riid, &IID_IUnknown))
337         *ppv = (LPVOID)This;
338     else if (IsEqualIID(riid, &IID_IPersist))
339         *ppv = (LPVOID)This;
340     else if (IsEqualIID(riid, &IID_IMediaFilter))
341         *ppv = (LPVOID)This;
342     else if (IsEqualIID(riid, &IID_IBaseFilter))
343         *ppv = (LPVOID)This;
344     else if (IsEqualIID(riid, &IID_IBaseFilter))
345         *ppv = (LPVOID)&(This->IBasicAudio_vtbl);
346
347     if (*ppv)
348     {
349         IUnknown_AddRef((IUnknown *)(*ppv));
350         return S_OK;
351     }
352
353     FIXME("No interface for %s!\n", qzdebugstr_guid(riid));
354
355     return E_NOINTERFACE;
356 }
357
358 static ULONG WINAPI DSoundRender_AddRef(IBaseFilter * iface)
359 {
360     DSoundRenderImpl *This = (DSoundRenderImpl *)iface;
361     ULONG refCount = InterlockedIncrement(&This->refCount);
362
363     TRACE("(%p/%p)->() AddRef from %ld\n", This, iface, refCount - 1);
364
365     return refCount;
366 }
367
368 static ULONG WINAPI DSoundRender_Release(IBaseFilter * iface)
369 {
370     DSoundRenderImpl *This = (DSoundRenderImpl *)iface;
371     ULONG refCount = InterlockedDecrement(&This->refCount);
372
373     TRACE("(%p/%p)->() Release from %ld\n", This, iface, refCount + 1);
374
375     if (!refCount)
376     {
377         DeleteCriticalSection(&This->csFilter);
378         if (This->pClock)
379             IReferenceClock_Release(This->pClock);
380        
381         IPin_Release(This->ppPins[0]);
382         
383         HeapFree(GetProcessHeap(), 0, This->ppPins);
384         This->lpVtbl = NULL;
385         This->IBasicAudio_vtbl = NULL;
386         
387         TRACE("Destroying Audio Renderer\n");
388         CoTaskMemFree(This);
389         
390         return 0;
391     }
392     else
393         return refCount;
394 }
395
396 /** IPersist methods **/
397
398 static HRESULT WINAPI DSoundRender_GetClassID(IBaseFilter * iface, CLSID * pClsid)
399 {
400     DSoundRenderImpl *This = (DSoundRenderImpl *)iface;
401     TRACE("(%p/%p)->(%p)\n", This, iface, pClsid);
402
403     *pClsid = CLSID_DSoundRender;
404
405     return S_OK;
406 }
407
408 /** IMediaFilter methods **/
409
410 static HRESULT WINAPI DSoundRender_Stop(IBaseFilter * iface)
411 {
412     HRESULT hr = S_OK;
413     DSoundRenderImpl *This = (DSoundRenderImpl *)iface;
414
415     TRACE("(%p/%p)->()\n", This, iface);
416
417     EnterCriticalSection(&This->csFilter);
418     {
419         This->state = State_Stopped;
420     }
421     LeaveCriticalSection(&This->csFilter);
422     
423     return hr;
424 }
425
426 static HRESULT WINAPI DSoundRender_Pause(IBaseFilter * iface)
427 {
428     HRESULT hr = S_OK;
429     DSoundRenderImpl *This = (DSoundRenderImpl *)iface;
430     
431     TRACE("(%p/%p)->()\n", This, iface);
432
433     EnterCriticalSection(&This->csFilter);
434     {
435         This->state = State_Paused;
436     }
437     LeaveCriticalSection(&This->csFilter);
438
439     return hr;
440 }
441
442 static HRESULT WINAPI DSoundRender_Run(IBaseFilter * iface, REFERENCE_TIME tStart)
443 {
444     HRESULT hr = S_OK;
445     DSoundRenderImpl *This = (DSoundRenderImpl *)iface;
446
447     TRACE("(%p/%p)->(%s)\n", This, iface, wine_dbgstr_longlong(tStart));
448
449     EnterCriticalSection(&This->csFilter);
450     {
451         This->rtStreamStart = tStart;
452         This->state = State_Running;
453     }
454     LeaveCriticalSection(&This->csFilter);
455
456     return hr;
457 }
458
459 static HRESULT WINAPI DSoundRender_GetState(IBaseFilter * iface, DWORD dwMilliSecsTimeout, FILTER_STATE *pState)
460 {
461     DSoundRenderImpl *This = (DSoundRenderImpl *)iface;
462
463     TRACE("(%p/%p)->(%ld, %p)\n", This, iface, dwMilliSecsTimeout, pState);
464
465     EnterCriticalSection(&This->csFilter);
466     {
467         *pState = This->state;
468     }
469     LeaveCriticalSection(&This->csFilter);
470
471     return S_OK;
472 }
473
474 static HRESULT WINAPI DSoundRender_SetSyncSource(IBaseFilter * iface, IReferenceClock *pClock)
475 {
476     DSoundRenderImpl *This = (DSoundRenderImpl *)iface;
477
478     TRACE("(%p/%p)->(%p)\n", This, iface, pClock);
479
480     EnterCriticalSection(&This->csFilter);
481     {
482         if (This->pClock)
483             IReferenceClock_Release(This->pClock);
484         This->pClock = pClock;
485         if (This->pClock)
486             IReferenceClock_AddRef(This->pClock);
487     }
488     LeaveCriticalSection(&This->csFilter);
489
490     return S_OK;
491 }
492
493 static HRESULT WINAPI DSoundRender_GetSyncSource(IBaseFilter * iface, IReferenceClock **ppClock)
494 {
495     DSoundRenderImpl *This = (DSoundRenderImpl *)iface;
496
497     TRACE("(%p/%p)->(%p)\n", This, iface, ppClock);
498
499     EnterCriticalSection(&This->csFilter);
500     {
501         *ppClock = This->pClock;
502         IReferenceClock_AddRef(This->pClock);
503     }
504     LeaveCriticalSection(&This->csFilter);
505     
506     return S_OK;
507 }
508
509 /** IBaseFilter implementation **/
510
511 static HRESULT WINAPI DSoundRender_EnumPins(IBaseFilter * iface, IEnumPins **ppEnum)
512 {
513     ENUMPINDETAILS epd;
514     DSoundRenderImpl *This = (DSoundRenderImpl *)iface;
515
516     TRACE("(%p/%p)->(%p)\n", This, iface, ppEnum);
517
518     epd.cPins = 1; /* input pin */
519     epd.ppPins = This->ppPins;
520     return IEnumPinsImpl_Construct(&epd, ppEnum);
521 }
522
523 static HRESULT WINAPI DSoundRender_FindPin(IBaseFilter * iface, LPCWSTR Id, IPin **ppPin)
524 {
525     DSoundRenderImpl *This = (DSoundRenderImpl *)iface;
526
527     TRACE("(%p/%p)->(%s,%p)\n", This, iface, debugstr_w(Id), ppPin);
528     
529     FIXME("DSoundRender::FindPin(...)\n");
530
531     /* FIXME: critical section */
532
533     return E_NOTIMPL;
534 }
535
536 static HRESULT WINAPI DSoundRender_QueryFilterInfo(IBaseFilter * iface, FILTER_INFO *pInfo)
537 {
538     DSoundRenderImpl *This = (DSoundRenderImpl *)iface;
539
540     TRACE("(%p/%p)->(%p)\n", This, iface, pInfo);
541
542     strcpyW(pInfo->achName, This->filterInfo.achName);
543     pInfo->pGraph = This->filterInfo.pGraph;
544
545     if (pInfo->pGraph)
546         IFilterGraph_AddRef(pInfo->pGraph);
547     
548     return S_OK;
549 }
550
551 static HRESULT WINAPI DSoundRender_JoinFilterGraph(IBaseFilter * iface, IFilterGraph *pGraph, LPCWSTR pName)
552 {
553     HRESULT hr;
554     DSoundRenderImpl *This = (DSoundRenderImpl *)iface;
555
556     TRACE("(%p/%p)->(%p, %s)\n", This, iface, pGraph, debugstr_w(pName));
557
558     EnterCriticalSection(&This->csFilter);
559     {
560         if (pName)
561             strcpyW(This->filterInfo.achName, pName);
562         else
563             *This->filterInfo.achName = '\0';
564         This->filterInfo.pGraph = pGraph; /* NOTE: do NOT increase ref. count */
565
566         hr = IFilterGraph_QueryInterface(pGraph, &IID_IMediaEventSink, (LPVOID*)&This->pEventSink);
567     }
568     LeaveCriticalSection(&This->csFilter);
569
570     return hr;
571 }
572
573 static HRESULT WINAPI DSoundRender_QueryVendorInfo(IBaseFilter * iface, LPWSTR *pVendorInfo)
574 {
575     DSoundRenderImpl *This = (DSoundRenderImpl *)iface;
576     TRACE("(%p/%p)->(%p)\n", This, iface, pVendorInfo);
577     return E_NOTIMPL;
578 }
579
580 static const IBaseFilterVtbl DSoundRender_Vtbl =
581 {
582     DSoundRender_QueryInterface,
583     DSoundRender_AddRef,
584     DSoundRender_Release,
585     DSoundRender_GetClassID,
586     DSoundRender_Stop,
587     DSoundRender_Pause,
588     DSoundRender_Run,
589     DSoundRender_GetState,
590     DSoundRender_SetSyncSource,
591     DSoundRender_GetSyncSource,
592     DSoundRender_EnumPins,
593     DSoundRender_FindPin,
594     DSoundRender_QueryFilterInfo,
595     DSoundRender_JoinFilterGraph,
596     DSoundRender_QueryVendorInfo
597 };
598
599 static HRESULT WINAPI DSoundRender_InputPin_EndOfStream(IPin * iface)
600 {
601     /* FIXME: critical section */
602     InputPin* This = (InputPin*)iface;
603         
604     TRACE("(%p/%p)->()\n", This, iface);
605         
606     return IMediaEventSink_Notify(((DSoundRenderImpl*)This->pin.pinInfo.pFilter)->pEventSink, EC_COMPLETE, S_OK, 0);
607 }
608
609 static const IPinVtbl DSoundRender_InputPin_Vtbl = 
610 {
611     InputPin_QueryInterface,
612     IPinImpl_AddRef,
613     InputPin_Release,
614     InputPin_Connect,
615     InputPin_ReceiveConnection,
616     IPinImpl_Disconnect,
617     IPinImpl_ConnectedTo,
618     IPinImpl_ConnectionMediaType,
619     IPinImpl_QueryPinInfo,
620     IPinImpl_QueryDirection,
621     IPinImpl_QueryId,
622     IPinImpl_QueryAccept,
623     IPinImpl_EnumMediaTypes,
624     IPinImpl_QueryInternalConnections,
625     DSoundRender_InputPin_EndOfStream,
626     InputPin_BeginFlush,
627     InputPin_EndFlush,
628     InputPin_NewSegment
629 };
630
631 static const IMemInputPinVtbl MemInputPin_Vtbl = 
632 {
633     MemInputPin_QueryInterface,
634     MemInputPin_AddRef,
635     MemInputPin_Release,
636     MemInputPin_GetAllocator,
637     MemInputPin_NotifyAllocator,
638     MemInputPin_GetAllocatorRequirements,
639     MemInputPin_Receive,
640     MemInputPin_ReceiveMultiple,
641     MemInputPin_ReceiveCanBlock
642 };
643
644 /*** IUnknown methods ***/
645 static HRESULT WINAPI Basicaudio_QueryInterface(IBasicAudio *iface,
646                                                 REFIID riid,
647                                                 LPVOID*ppvObj) {
648     ICOM_THIS_MULTI(DSoundRenderImpl, IBasicAudio_vtbl, iface);
649
650     TRACE("(%p/%p)->(%s (%p), %p)\n", This, iface, debugstr_guid(riid), riid, ppvObj);
651
652     return DSoundRender_QueryInterface((IBaseFilter*)This, riid, ppvObj);
653 }
654
655 static ULONG WINAPI Basicaudio_AddRef(IBasicAudio *iface) {
656     ICOM_THIS_MULTI(DSoundRenderImpl, IBasicAudio_vtbl, iface);
657
658     TRACE("(%p/%p)->()\n", This, iface);
659
660     return DSoundRender_AddRef((IBaseFilter*)This);
661 }
662
663 static ULONG WINAPI Basicaudio_Release(IBasicAudio *iface) {
664     ICOM_THIS_MULTI(DSoundRenderImpl, IBasicAudio_vtbl, iface);
665
666     TRACE("(%p/%p)->()\n", This, iface);
667
668     return DSoundRender_Release((IBaseFilter*)This);
669 }
670
671 /*** IDispatch methods ***/
672 static HRESULT WINAPI Basicaudio_GetTypeInfoCount(IBasicAudio *iface,
673                                                   UINT*pctinfo) {
674     ICOM_THIS_MULTI(DSoundRenderImpl, IBasicAudio_vtbl, iface);
675
676     TRACE("(%p/%p)->(%p): stub !!!\n", This, iface, pctinfo);
677
678     return S_OK;
679 }
680
681 static HRESULT WINAPI Basicaudio_GetTypeInfo(IBasicAudio *iface,
682                                              UINT iTInfo,
683                                              LCID lcid,
684                                              ITypeInfo**ppTInfo) {
685     ICOM_THIS_MULTI(DSoundRenderImpl, IBasicAudio_vtbl, iface);
686
687     TRACE("(%p/%p)->(%d, %ld, %p): stub !!!\n", This, iface, iTInfo, lcid, ppTInfo);
688
689     return S_OK;
690 }
691
692 static HRESULT WINAPI Basicaudio_GetIDsOfNames(IBasicAudio *iface,
693                                                REFIID riid,
694                                                LPOLESTR*rgszNames,
695                                                UINT cNames,
696                                                LCID lcid,
697                                                DISPID*rgDispId) {
698     ICOM_THIS_MULTI(DSoundRenderImpl, IBasicAudio_vtbl, iface);
699
700     TRACE("(%p/%p)->(%s (%p), %p, %d, %ld, %p): stub !!!\n", This, iface, debugstr_guid(riid), riid, rgszNames, cNames, lcid, rgDispId);
701
702     return S_OK;
703 }
704
705 static HRESULT WINAPI Basicaudio_Invoke(IBasicAudio *iface,
706                                         DISPID dispIdMember,
707                                         REFIID riid,
708                                         LCID lcid,
709                                         WORD wFlags,
710                                         DISPPARAMS*pDispParams,
711                                         VARIANT*pVarResult,
712                                         EXCEPINFO*pExepInfo,
713                                         UINT*puArgErr) {
714     ICOM_THIS_MULTI(DSoundRenderImpl, IBasicAudio_vtbl, iface);
715
716     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);
717
718     return S_OK;
719 }
720
721 /*** IBasicAudio methods ***/
722 static HRESULT WINAPI Basicaudio_put_Volume(IBasicAudio *iface,
723                                             long lVolume) {
724     ICOM_THIS_MULTI(DSoundRenderImpl, IBasicAudio_vtbl, iface);
725
726     TRACE("(%p/%p)->(%ld): stub !!!\n", This, iface, lVolume);
727
728     return S_OK;
729 }
730
731 static HRESULT WINAPI Basicaudio_get_Volume(IBasicAudio *iface,
732                                             long *plVolume) {
733     ICOM_THIS_MULTI(DSoundRenderImpl, IBasicAudio_vtbl, iface);
734
735     TRACE("(%p/%p)->(%p): stub !!!\n", This, iface, plVolume);
736
737     return S_OK;
738 }
739
740 static HRESULT WINAPI Basicaudio_put_Balance(IBasicAudio *iface,
741                                              long lBalance) {
742     ICOM_THIS_MULTI(DSoundRenderImpl, IBasicAudio_vtbl, iface);
743
744     TRACE("(%p/%p)->(%ld): stub !!!\n", This, iface, lBalance);
745
746     return S_OK;
747 }
748
749 static HRESULT WINAPI Basicaudio_get_Balance(IBasicAudio *iface,
750                                              long *plBalance) {
751     ICOM_THIS_MULTI(DSoundRenderImpl, IBasicAudio_vtbl, iface);
752
753     TRACE("(%p/%p)->(%p): stub !!!\n", This, iface, plBalance);
754
755     return S_OK;
756 }
757
758 static const IBasicAudioVtbl IBasicAudio_Vtbl =
759 {
760     Basicaudio_QueryInterface,
761     Basicaudio_AddRef,
762     Basicaudio_Release,
763     Basicaudio_GetTypeInfoCount,
764     Basicaudio_GetTypeInfo,
765     Basicaudio_GetIDsOfNames,
766     Basicaudio_Invoke,
767     Basicaudio_put_Volume,
768     Basicaudio_get_Volume,
769     Basicaudio_put_Balance,
770     Basicaudio_get_Balance
771 };