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