Removed W->A from DEFWND_ImmIsUIMessageW.
[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     /* We have finished with the incoming sample, we must release it now */
265     IMediaSample_Release(pSample);
266     
267     return S_OK;
268 }
269
270 static HRESULT DSoundRender_QueryAccept(LPVOID iface, const AM_MEDIA_TYPE * pmt)
271 {
272     WAVEFORMATEX* format = (WAVEFORMATEX*)pmt->pbFormat;
273     TRACE("wFormatTag = %x %x\n", format->wFormatTag, WAVE_FORMAT_PCM);
274     TRACE("nChannels = %d\n", format->nChannels);
275     TRACE("nSamplesPerSec = %ld\n", format->nAvgBytesPerSec);
276     TRACE("nAvgBytesPerSec = %ld\n", format->nAvgBytesPerSec);
277     TRACE("nBlockAlign = %d\n", format->nBlockAlign);
278     TRACE("wBitsPerSample = %d\n", format->wBitsPerSample);
279
280     if (IsEqualIID(&pmt->majortype, &MEDIATYPE_Audio) && IsEqualIID(&pmt->subtype, &MEDIASUBTYPE_PCM))
281         return S_OK;
282     return S_FALSE;
283 }
284
285 HRESULT DSoundRender_create(IUnknown * pUnkOuter, LPVOID * ppv)
286 {
287     HRESULT hr;
288     PIN_INFO piInput;
289     DSoundRenderImpl * pDSoundRender;
290
291     TRACE("(%p, %p)\n", pUnkOuter, ppv);
292
293     *ppv = NULL;
294
295     if (pUnkOuter)
296         return CLASS_E_NOAGGREGATION;
297     
298     pDSoundRender = CoTaskMemAlloc(sizeof(DSoundRenderImpl));
299
300     pDSoundRender->lpVtbl = &DSoundRender_Vtbl;
301     pDSoundRender->IBasicAudio_vtbl = &IBasicAudio_Vtbl;
302     pDSoundRender->refCount = 1;
303     InitializeCriticalSection(&pDSoundRender->csFilter);
304     pDSoundRender->state = State_Stopped;
305     pDSoundRender->pClock = NULL;
306     pDSoundRender->init = 0;
307     ZeroMemory(&pDSoundRender->filterInfo, sizeof(FILTER_INFO));
308
309     pDSoundRender->ppPins = CoTaskMemAlloc(1 * sizeof(IPin *));
310
311     /* construct input pin */
312     piInput.dir = PINDIR_INPUT;
313     piInput.pFilter = (IBaseFilter *)pDSoundRender;
314     strncpyW(piInput.achName, wcsInputPinName, sizeof(piInput.achName) / sizeof(piInput.achName[0]));
315     hr = DSoundRender_InputPin_Construct(&piInput, DSoundRender_Sample, (LPVOID)pDSoundRender, DSoundRender_QueryAccept, &pDSoundRender->csFilter, (IPin **)&pDSoundRender->pInputPin);
316
317     if (SUCCEEDED(hr))
318     {
319         pDSoundRender->ppPins[0] = (IPin *)pDSoundRender->pInputPin;
320         *ppv = (LPVOID)pDSoundRender;
321     }
322     else
323     {
324         CoTaskMemFree(pDSoundRender->ppPins);
325         DeleteCriticalSection(&pDSoundRender->csFilter);
326         CoTaskMemFree(pDSoundRender);
327     }
328
329     return hr;
330 }
331
332 static HRESULT WINAPI DSoundRender_QueryInterface(IBaseFilter * iface, REFIID riid, LPVOID * ppv)
333 {
334     DSoundRenderImpl *This = (DSoundRenderImpl *)iface;
335     TRACE("(%p, %p)->(%s, %p)\n", This, iface, qzdebugstr_guid(riid), ppv);
336
337     *ppv = NULL;
338
339     if (IsEqualIID(riid, &IID_IUnknown))
340         *ppv = (LPVOID)This;
341     else if (IsEqualIID(riid, &IID_IPersist))
342         *ppv = (LPVOID)This;
343     else if (IsEqualIID(riid, &IID_IMediaFilter))
344         *ppv = (LPVOID)This;
345     else if (IsEqualIID(riid, &IID_IBaseFilter))
346         *ppv = (LPVOID)This;
347     else if (IsEqualIID(riid, &IID_IBaseFilter))
348         *ppv = (LPVOID)&(This->IBasicAudio_vtbl);
349
350     if (*ppv)
351     {
352         IUnknown_AddRef((IUnknown *)(*ppv));
353         return S_OK;
354     }
355
356     FIXME("No interface for %s!\n", qzdebugstr_guid(riid));
357
358     return E_NOINTERFACE;
359 }
360
361 static ULONG WINAPI DSoundRender_AddRef(IBaseFilter * iface)
362 {
363     DSoundRenderImpl *This = (DSoundRenderImpl *)iface;
364     TRACE("(%p/%p)->()\n", This, iface);
365     return InterlockedIncrement(&This->refCount);
366 }
367
368 static ULONG WINAPI DSoundRender_Release(IBaseFilter * iface)
369 {
370     DSoundRenderImpl *This = (DSoundRenderImpl *)iface;
371     TRACE("(%p/%p)->()\n", This, iface);
372     if (!InterlockedDecrement(&This->refCount))
373     {
374         DeleteCriticalSection(&This->csFilter);
375         if (This->pClock)
376             IReferenceClock_Release(This->pClock);
377        
378         IPin_Release(This->ppPins[0]);
379         
380         HeapFree(GetProcessHeap(), 0, This->ppPins);
381         This->lpVtbl = NULL;
382         This->IBasicAudio_vtbl = NULL;
383         
384         TRACE("Destroying Audio Renderer\n");
385         CoTaskMemFree(This);
386         
387         return 0;
388     }
389     else
390         return This->refCount;
391 }
392
393 /** IPersist methods **/
394
395 static HRESULT WINAPI DSoundRender_GetClassID(IBaseFilter * iface, CLSID * pClsid)
396 {
397     DSoundRenderImpl *This = (DSoundRenderImpl *)iface;
398     TRACE("(%p/%p)->(%p)\n", This, iface, pClsid);
399
400     *pClsid = CLSID_DSoundRender;
401
402     return S_OK;
403 }
404
405 /** IMediaFilter methods **/
406
407 static HRESULT WINAPI DSoundRender_Stop(IBaseFilter * iface)
408 {
409     HRESULT hr = S_OK;
410     DSoundRenderImpl *This = (DSoundRenderImpl *)iface;
411
412     TRACE("(%p/%p)->()\n", This, iface);
413
414     EnterCriticalSection(&This->csFilter);
415     {
416         This->state = State_Stopped;
417     }
418     LeaveCriticalSection(&This->csFilter);
419     
420     return hr;
421 }
422
423 static HRESULT WINAPI DSoundRender_Pause(IBaseFilter * iface)
424 {
425     HRESULT hr = S_OK;
426     DSoundRenderImpl *This = (DSoundRenderImpl *)iface;
427     
428     TRACE("(%p/%p)->()\n", This, iface);
429
430     EnterCriticalSection(&This->csFilter);
431     {
432         This->state = State_Paused;
433     }
434     LeaveCriticalSection(&This->csFilter);
435
436     return hr;
437 }
438
439 static HRESULT WINAPI DSoundRender_Run(IBaseFilter * iface, REFERENCE_TIME tStart)
440 {
441     HRESULT hr = S_OK;
442     DSoundRenderImpl *This = (DSoundRenderImpl *)iface;
443
444     TRACE("(%p/%p)->(%s)\n", This, iface, wine_dbgstr_longlong(tStart));
445
446     EnterCriticalSection(&This->csFilter);
447     {
448         This->rtStreamStart = tStart;
449         This->state = State_Running;
450     }
451     LeaveCriticalSection(&This->csFilter);
452
453     return hr;
454 }
455
456 static HRESULT WINAPI DSoundRender_GetState(IBaseFilter * iface, DWORD dwMilliSecsTimeout, FILTER_STATE *pState)
457 {
458     DSoundRenderImpl *This = (DSoundRenderImpl *)iface;
459
460     TRACE("(%p/%p)->(%ld, %p)\n", This, iface, dwMilliSecsTimeout, pState);
461
462     EnterCriticalSection(&This->csFilter);
463     {
464         *pState = This->state;
465     }
466     LeaveCriticalSection(&This->csFilter);
467
468     return S_OK;
469 }
470
471 static HRESULT WINAPI DSoundRender_SetSyncSource(IBaseFilter * iface, IReferenceClock *pClock)
472 {
473     DSoundRenderImpl *This = (DSoundRenderImpl *)iface;
474
475     TRACE("(%p/%p)->(%p)\n", This, iface, pClock);
476
477     EnterCriticalSection(&This->csFilter);
478     {
479         if (This->pClock)
480             IReferenceClock_Release(This->pClock);
481         This->pClock = pClock;
482         if (This->pClock)
483             IReferenceClock_AddRef(This->pClock);
484     }
485     LeaveCriticalSection(&This->csFilter);
486
487     return S_OK;
488 }
489
490 static HRESULT WINAPI DSoundRender_GetSyncSource(IBaseFilter * iface, IReferenceClock **ppClock)
491 {
492     DSoundRenderImpl *This = (DSoundRenderImpl *)iface;
493
494     TRACE("(%p/%p)->(%p)\n", This, iface, ppClock);
495
496     EnterCriticalSection(&This->csFilter);
497     {
498         *ppClock = This->pClock;
499         IReferenceClock_AddRef(This->pClock);
500     }
501     LeaveCriticalSection(&This->csFilter);
502     
503     return S_OK;
504 }
505
506 /** IBaseFilter implementation **/
507
508 static HRESULT WINAPI DSoundRender_EnumPins(IBaseFilter * iface, IEnumPins **ppEnum)
509 {
510     ENUMPINDETAILS epd;
511     DSoundRenderImpl *This = (DSoundRenderImpl *)iface;
512
513     TRACE("(%p/%p)->(%p)\n", This, iface, ppEnum);
514
515     epd.cPins = 1; /* input pin */
516     epd.ppPins = This->ppPins;
517     return IEnumPinsImpl_Construct(&epd, ppEnum);
518 }
519
520 static HRESULT WINAPI DSoundRender_FindPin(IBaseFilter * iface, LPCWSTR Id, IPin **ppPin)
521 {
522     DSoundRenderImpl *This = (DSoundRenderImpl *)iface;
523
524     TRACE("(%p/%p)->(%s,%p)\n", This, iface, debugstr_w(Id), ppPin);
525     
526     FIXME("DSoundRender::FindPin(...)\n");
527
528     /* FIXME: critical section */
529
530     return E_NOTIMPL;
531 }
532
533 static HRESULT WINAPI DSoundRender_QueryFilterInfo(IBaseFilter * iface, FILTER_INFO *pInfo)
534 {
535     DSoundRenderImpl *This = (DSoundRenderImpl *)iface;
536
537     TRACE("(%p/%p)->(%p)\n", This, iface, pInfo);
538
539     strcpyW(pInfo->achName, This->filterInfo.achName);
540     pInfo->pGraph = This->filterInfo.pGraph;
541
542     if (pInfo->pGraph)
543         IFilterGraph_AddRef(pInfo->pGraph);
544     
545     return S_OK;
546 }
547
548 static HRESULT WINAPI DSoundRender_JoinFilterGraph(IBaseFilter * iface, IFilterGraph *pGraph, LPCWSTR pName)
549 {
550     HRESULT hr;
551     DSoundRenderImpl *This = (DSoundRenderImpl *)iface;
552
553     TRACE("(%p/%p)->(%p, %s)\n", This, iface, pGraph, debugstr_w(pName));
554
555     EnterCriticalSection(&This->csFilter);
556     {
557         if (pName)
558             strcpyW(This->filterInfo.achName, pName);
559         else
560             *This->filterInfo.achName = '\0';
561         This->filterInfo.pGraph = pGraph; /* NOTE: do NOT increase ref. count */
562
563         hr = IFilterGraph_QueryInterface(pGraph, &IID_IMediaEventSink, (LPVOID*)&This->pEventSink);
564     }
565     LeaveCriticalSection(&This->csFilter);
566
567     return hr;
568 }
569
570 static HRESULT WINAPI DSoundRender_QueryVendorInfo(IBaseFilter * iface, LPWSTR *pVendorInfo)
571 {
572     DSoundRenderImpl *This = (DSoundRenderImpl *)iface;
573     TRACE("(%p/%p)->(%p)\n", This, iface, pVendorInfo);
574     return E_NOTIMPL;
575 }
576
577 static const IBaseFilterVtbl DSoundRender_Vtbl =
578 {
579     DSoundRender_QueryInterface,
580     DSoundRender_AddRef,
581     DSoundRender_Release,
582     DSoundRender_GetClassID,
583     DSoundRender_Stop,
584     DSoundRender_Pause,
585     DSoundRender_Run,
586     DSoundRender_GetState,
587     DSoundRender_SetSyncSource,
588     DSoundRender_GetSyncSource,
589     DSoundRender_EnumPins,
590     DSoundRender_FindPin,
591     DSoundRender_QueryFilterInfo,
592     DSoundRender_JoinFilterGraph,
593     DSoundRender_QueryVendorInfo
594 };
595
596 static HRESULT WINAPI DSoundRender_InputPin_EndOfStream(IPin * iface)
597 {
598     /* FIXME: critical section */
599     InputPin* This = (InputPin*)iface;
600         
601     TRACE("(%p/%p)->()\n", This, iface);
602         
603     return IMediaEventSink_Notify(((DSoundRenderImpl*)This->pin.pinInfo.pFilter)->pEventSink, EC_COMPLETE, S_OK, 0);
604 }
605
606 static const IPinVtbl DSoundRender_InputPin_Vtbl = 
607 {
608     InputPin_QueryInterface,
609     IPinImpl_AddRef,
610     InputPin_Release,
611     InputPin_Connect,
612     InputPin_ReceiveConnection,
613     IPinImpl_Disconnect,
614     IPinImpl_ConnectedTo,
615     IPinImpl_ConnectionMediaType,
616     IPinImpl_QueryPinInfo,
617     IPinImpl_QueryDirection,
618     IPinImpl_QueryId,
619     IPinImpl_QueryAccept,
620     IPinImpl_EnumMediaTypes,
621     IPinImpl_QueryInternalConnections,
622     DSoundRender_InputPin_EndOfStream,
623     InputPin_BeginFlush,
624     InputPin_EndFlush,
625     InputPin_NewSegment
626 };
627
628 static const IMemInputPinVtbl MemInputPin_Vtbl = 
629 {
630     MemInputPin_QueryInterface,
631     MemInputPin_AddRef,
632     MemInputPin_Release,
633     MemInputPin_GetAllocator,
634     MemInputPin_NotifyAllocator,
635     MemInputPin_GetAllocatorRequirements,
636     MemInputPin_Receive,
637     MemInputPin_ReceiveMultiple,
638     MemInputPin_ReceiveCanBlock
639 };
640
641 /*** IUnknown methods ***/
642 static HRESULT WINAPI Basicaudio_QueryInterface(IBasicAudio *iface,
643                                                 REFIID riid,
644                                                 LPVOID*ppvObj) {
645     ICOM_THIS_MULTI(DSoundRenderImpl, IBasicAudio_vtbl, iface);
646
647     TRACE("(%p/%p)->(%s (%p), %p)\n", This, iface, debugstr_guid(riid), riid, ppvObj);
648
649     return DSoundRender_QueryInterface((IBaseFilter*)This, riid, ppvObj);
650 }
651
652 static ULONG WINAPI Basicaudio_AddRef(IBasicAudio *iface) {
653     ICOM_THIS_MULTI(DSoundRenderImpl, IBasicAudio_vtbl, iface);
654
655     TRACE("(%p/%p)->()\n", This, iface);
656
657     return DSoundRender_AddRef((IBaseFilter*)This);
658 }
659
660 static ULONG WINAPI Basicaudio_Release(IBasicAudio *iface) {
661     ICOM_THIS_MULTI(DSoundRenderImpl, IBasicAudio_vtbl, iface);
662
663     TRACE("(%p/%p)->()\n", This, iface);
664
665     return DSoundRender_Release((IBaseFilter*)This);
666 }
667
668 /*** IDispatch methods ***/
669 static HRESULT WINAPI Basicaudio_GetTypeInfoCount(IBasicAudio *iface,
670                                                   UINT*pctinfo) {
671     ICOM_THIS_MULTI(DSoundRenderImpl, IBasicAudio_vtbl, iface);
672
673     TRACE("(%p/%p)->(%p): stub !!!\n", This, iface, pctinfo);
674
675     return S_OK;
676 }
677
678 static HRESULT WINAPI Basicaudio_GetTypeInfo(IBasicAudio *iface,
679                                              UINT iTInfo,
680                                              LCID lcid,
681                                              ITypeInfo**ppTInfo) {
682     ICOM_THIS_MULTI(DSoundRenderImpl, IBasicAudio_vtbl, iface);
683
684     TRACE("(%p/%p)->(%d, %ld, %p): stub !!!\n", This, iface, iTInfo, lcid, ppTInfo);
685
686     return S_OK;
687 }
688
689 static HRESULT WINAPI Basicaudio_GetIDsOfNames(IBasicAudio *iface,
690                                                REFIID riid,
691                                                LPOLESTR*rgszNames,
692                                                UINT cNames,
693                                                LCID lcid,
694                                                DISPID*rgDispId) {
695     ICOM_THIS_MULTI(DSoundRenderImpl, IBasicAudio_vtbl, iface);
696
697     TRACE("(%p/%p)->(%s (%p), %p, %d, %ld, %p): stub !!!\n", This, iface, debugstr_guid(riid), riid, rgszNames, cNames, lcid, rgDispId);
698
699     return S_OK;
700 }
701
702 static HRESULT WINAPI Basicaudio_Invoke(IBasicAudio *iface,
703                                         DISPID dispIdMember,
704                                         REFIID riid,
705                                         LCID lcid,
706                                         WORD wFlags,
707                                         DISPPARAMS*pDispParams,
708                                         VARIANT*pVarResult,
709                                         EXCEPINFO*pExepInfo,
710                                         UINT*puArgErr) {
711     ICOM_THIS_MULTI(DSoundRenderImpl, IBasicAudio_vtbl, iface);
712
713     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);
714
715     return S_OK;
716 }
717
718 /*** IBasicAudio methods ***/
719 static HRESULT WINAPI Basicaudio_put_Volume(IBasicAudio *iface,
720                                             long lVolume) {
721     ICOM_THIS_MULTI(DSoundRenderImpl, IBasicAudio_vtbl, iface);
722
723     TRACE("(%p/%p)->(%ld): stub !!!\n", This, iface, lVolume);
724
725     return S_OK;
726 }
727
728 static HRESULT WINAPI Basicaudio_get_Volume(IBasicAudio *iface,
729                                             long *plVolume) {
730     ICOM_THIS_MULTI(DSoundRenderImpl, IBasicAudio_vtbl, iface);
731
732     TRACE("(%p/%p)->(%p): stub !!!\n", This, iface, plVolume);
733
734     return S_OK;
735 }
736
737 static HRESULT WINAPI Basicaudio_put_Balance(IBasicAudio *iface,
738                                              long lBalance) {
739     ICOM_THIS_MULTI(DSoundRenderImpl, IBasicAudio_vtbl, iface);
740
741     TRACE("(%p/%p)->(%ld): stub !!!\n", This, iface, lBalance);
742
743     return S_OK;
744 }
745
746 static HRESULT WINAPI Basicaudio_get_Balance(IBasicAudio *iface,
747                                              long *plBalance) {
748     ICOM_THIS_MULTI(DSoundRenderImpl, IBasicAudio_vtbl, iface);
749
750     TRACE("(%p/%p)->(%p): stub !!!\n", This, iface, plBalance);
751
752     return S_OK;
753 }
754
755 static const IBasicAudioVtbl IBasicAudio_Vtbl =
756 {
757     Basicaudio_QueryInterface,
758     Basicaudio_AddRef,
759     Basicaudio_Release,
760     Basicaudio_GetTypeInfoCount,
761     Basicaudio_GetTypeInfo,
762     Basicaudio_GetIDsOfNames,
763     Basicaudio_Invoke,
764     Basicaudio_put_Volume,
765     Basicaudio_get_Volume,
766     Basicaudio_put_Balance,
767     Basicaudio_get_Balance
768 };