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