strmbase: Implement BaseFilter in strmbase.
[wine/multimedia.git] / dlls / quartz / dsoundrender.c
blob383679e68b5283909182b59075331a308070c79e
1 /*
2 * Direct Sound Audio Renderer
4 * Copyright 2004 Christian Costa
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.
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.
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
21 #include "config.h"
23 #include "quartz_private.h"
24 #include "control_private.h"
25 #include "pin.h"
27 #include "uuids.h"
28 #include "vfwmsgs.h"
29 #include "windef.h"
30 #include "winbase.h"
31 #include "dshow.h"
32 #include "evcode.h"
33 #include "strmif.h"
34 #include "dsound.h"
35 #include "amaudio.h"
37 #include "wine/unicode.h"
38 #include "wine/debug.h"
40 WINE_DEFAULT_DEBUG_CHANNEL(quartz);
42 static const WCHAR wcsInputPinName[] = {'i','n','p','u','t',' ','p','i','n',0};
44 static const IBaseFilterVtbl DSoundRender_Vtbl;
45 static const IPinVtbl DSoundRender_InputPin_Vtbl;
46 static const IBasicAudioVtbl IBasicAudio_Vtbl;
47 static const IReferenceClockVtbl IReferenceClock_Vtbl;
48 static const IMediaSeekingVtbl IMediaSeeking_Vtbl;
49 static const IAMDirectSoundVtbl IAMDirectSound_Vtbl;
51 typedef struct DSoundRenderImpl
53 BaseFilter filter;
55 const IBasicAudioVtbl *IBasicAudio_vtbl;
56 const IReferenceClockVtbl *IReferenceClock_vtbl;
57 const IAMDirectSoundVtbl *IAMDirectSound_vtbl;
58 IUnknown *seekthru_unk;
60 REFERENCE_TIME rtLastStop;
62 BaseInputPin * pInputPin;
64 IDirectSound8 *dsound;
65 LPDIRECTSOUNDBUFFER dsbuffer;
66 DWORD buf_size;
67 DWORD write_pos;
68 DWORD write_loops;
70 DWORD last_play_pos;
71 DWORD play_loops;
72 DWORD in_loop;
74 REFERENCE_TIME play_time;
76 HANDLE state_change, blocked;
78 LONG volume;
79 LONG pan;
80 } DSoundRenderImpl;
82 static inline HRESULT DSoundRender_GetPos(DSoundRenderImpl *This, DWORD *pPlayPos, REFERENCE_TIME *pRefTime)
84 HRESULT hr;
86 EnterCriticalSection(&This->filter.csFilter);
88 DWORD state;
89 DWORD write_pos;
91 hr = IDirectSoundBuffer_GetStatus(This->dsbuffer, &state);
92 if (SUCCEEDED(hr) && !(state & DSBSTATUS_PLAYING) && This->filter.state == State_Running)
94 TRACE("Not playing, kickstarting the engine\n");
96 hr = IDirectSoundBuffer_Play(This->dsbuffer, 0, 0, DSBPLAY_LOOPING);
97 if (FAILED(hr))
98 ERR("Can't play sound buffer (%x)\n", hr);
101 if (SUCCEEDED(hr))
102 hr = IDirectSoundBuffer_GetCurrentPosition(This->dsbuffer, pPlayPos, &write_pos);
103 if (hr == S_OK)
105 DWORD play_pos = *pPlayPos;
107 if (play_pos < This->last_play_pos)
108 This->play_loops++;
109 This->last_play_pos = play_pos;
111 /* If we really fell behind, start at the next possible position
112 * Also happens when just starting playback for the first time,
113 * or when flushing
115 if ((This->play_loops*This->buf_size)+play_pos >=
116 (This->write_loops*This->buf_size)+This->write_pos)
117 This->write_pos = write_pos;
119 if (pRefTime)
121 REFERENCE_TIME play_time;
122 play_time = ((REFERENCE_TIME)This->play_loops*10000000) +
123 ((REFERENCE_TIME)play_pos*10000000/This->buf_size);
125 /* Don't let time run backwards */
126 if(play_time-This->play_time > 0)
127 This->play_time = play_time;
128 else
129 hr = S_FALSE;
131 *pRefTime = This->play_time;
135 LeaveCriticalSection(&This->filter.csFilter);
137 return hr;
140 static HRESULT DSoundRender_SendSampleData(DSoundRenderImpl* This, const BYTE *data, DWORD size)
142 HRESULT hr = S_OK;
143 LPBYTE lpbuf1 = NULL;
144 LPBYTE lpbuf2 = NULL;
145 DWORD dwsize1 = 0;
146 DWORD dwsize2 = 0;
147 DWORD size2;
148 DWORD play_pos,buf_free;
150 do {
152 hr = DSoundRender_GetPos(This, &play_pos, NULL);
153 if (hr != DS_OK)
155 ERR("GetPos returned error: %x\n", hr);
156 break;
158 if (This->write_pos <= play_pos)
159 buf_free = play_pos-This->write_pos;
160 else
161 buf_free = This->buf_size - This->write_pos + play_pos;
163 /* Wait for enough of the buffer to empty before filling it */
164 if(buf_free < This->buf_size/20)
166 DWORD ret;
167 This->in_loop = 1;
168 LeaveCriticalSection(&This->filter.csFilter);
169 ret = WaitForSingleObject(This->blocked, 50);
170 if (ret != WAIT_TIMEOUT)
171 ERR("%x\n", ret);
172 EnterCriticalSection(&This->filter.csFilter);
173 This->in_loop = 0;
174 if (This->pInputPin->flushing)
175 return VFW_E_WRONG_STATE;
176 if (This->filter.state == State_Stopped)
177 return VFW_E_WRONG_STATE;
178 continue;
181 size2 = min(buf_free, size);
182 hr = IDirectSoundBuffer_Lock(This->dsbuffer, This->write_pos, size2, (LPVOID *)&lpbuf1, &dwsize1, (LPVOID *)&lpbuf2, &dwsize2, 0);
183 if (hr != DS_OK) {
184 ERR("Unable to lock sound buffer! (%x)\n", hr);
185 break;
187 /* TRACE("write_pos=%d, size=%d, sz1=%d, sz2=%d\n", This->write_pos, size2, dwsize1, dwsize2); */
189 memcpy(lpbuf1, data, dwsize1);
190 if (dwsize2)
191 memcpy(lpbuf2, data + dwsize1, dwsize2);
193 hr = IDirectSoundBuffer_Unlock(This->dsbuffer, lpbuf1, dwsize1, lpbuf2, dwsize2);
194 if (hr != DS_OK)
195 ERR("Unable to unlock sound buffer! (%x)\n", hr);
197 size -= dwsize1 + dwsize2;
198 data += dwsize1 + dwsize2;
199 This->write_pos += dwsize1 + dwsize2;
200 if (This->write_pos >= This->buf_size)
202 This->write_pos -= This->buf_size;
203 This->write_loops++;
205 } while (size && This->filter.state == State_Running);
207 return hr;
210 static HRESULT WINAPI DSoundRender_Receive(IPin *iface, IMediaSample * pSample)
212 BaseInputPin *pin = (BaseInputPin*)iface;
213 DSoundRenderImpl *This = (DSoundRenderImpl*)pin->pin.pinInfo.pFilter;
214 LPBYTE pbSrcStream = NULL;
215 LONG cbSrcStream = 0;
216 REFERENCE_TIME tStart, tStop;
217 HRESULT hr;
218 AM_MEDIA_TYPE *amt;
220 TRACE("%p %p\n", iface, pSample);
222 /* Slightly incorrect, Pause completes when a frame is received so we should signal
223 * pause completion here, but for sound playing a single frame doesn't make sense
226 EnterCriticalSection(&This->filter.csFilter);
228 if (This->pInputPin->end_of_stream || This->pInputPin->flushing)
230 LeaveCriticalSection(&This->filter.csFilter);
231 return S_FALSE;
234 if (This->filter.state == State_Stopped)
236 LeaveCriticalSection(&This->filter.csFilter);
237 return VFW_E_WRONG_STATE;
240 if (IMediaSample_GetMediaType(pSample, &amt) == S_OK)
242 AM_MEDIA_TYPE *orig = &This->pInputPin->pin.mtCurrent;
243 WAVEFORMATEX *origfmt = (WAVEFORMATEX *)orig->pbFormat;
244 WAVEFORMATEX *newfmt = (WAVEFORMATEX *)amt->pbFormat;
246 if (origfmt->wFormatTag == newfmt->wFormatTag &&
247 origfmt->nChannels == newfmt->nChannels &&
248 origfmt->nBlockAlign == newfmt->nBlockAlign &&
249 origfmt->wBitsPerSample == newfmt->wBitsPerSample &&
250 origfmt->cbSize == newfmt->cbSize)
252 if (origfmt->nSamplesPerSec != newfmt->nSamplesPerSec)
254 hr = IDirectSoundBuffer_SetFrequency(This->dsbuffer,
255 newfmt->nSamplesPerSec);
256 if (FAILED(hr))
258 LeaveCriticalSection(&This->filter.csFilter);
259 return VFW_E_TYPE_NOT_ACCEPTED;
261 FreeMediaType(orig);
262 CopyMediaType(orig, amt);
263 IMediaSample_SetMediaType(pSample, NULL);
266 else
268 LeaveCriticalSection(&This->filter.csFilter);
269 return VFW_E_TYPE_NOT_ACCEPTED;
273 hr = IMediaSample_GetPointer(pSample, &pbSrcStream);
274 if (FAILED(hr))
276 ERR("Cannot get pointer to sample data (%x)\n", hr);
277 LeaveCriticalSection(&This->filter.csFilter);
278 return hr;
281 hr = IMediaSample_GetTime(pSample, &tStart, &tStop);
282 if (FAILED(hr))
283 ERR("Cannot get sample time (%x)\n", hr);
284 else
285 MediaSeekingPassThru_RegisterMediaTime(This->seekthru_unk, tStart);
287 if (This->rtLastStop != tStart && (IMediaSample_IsDiscontinuity(pSample) == S_FALSE))
288 WARN("Unexpected discontinuity: Last: %u.%03u, tStart: %u.%03u\n",
289 (DWORD)(This->rtLastStop / 10000000), (DWORD)((This->rtLastStop / 10000)%1000),
290 (DWORD)(tStart / 10000000), (DWORD)((tStart / 10000)%1000));
291 This->rtLastStop = tStop;
293 if (IMediaSample_IsPreroll(pSample) == S_OK)
295 TRACE("Preroll!\n");
296 LeaveCriticalSection(&This->filter.csFilter);
297 return S_OK;
300 if (This->filter.state == State_Paused)
302 SetEvent(This->state_change);
303 LeaveCriticalSection(&This->filter.csFilter);
304 WaitForSingleObject(This->blocked, INFINITE);
305 EnterCriticalSection(&This->filter.csFilter);
306 if (This->filter.state == State_Stopped)
308 LeaveCriticalSection(&This->filter.csFilter);
309 return VFW_E_WRONG_STATE;
312 if (This->filter.state == State_Paused)
314 /* Assuming we return because of flushing */
315 TRACE("Flushing\n");
316 LeaveCriticalSection(&This->filter.csFilter);
317 return S_OK;
319 SetEvent(This->state_change);
322 cbSrcStream = IMediaSample_GetActualDataLength(pSample);
323 TRACE("Sample data ptr = %p, size = %d\n", pbSrcStream, cbSrcStream);
325 #if 0 /* For debugging purpose */
327 int i;
328 for(i = 0; i < cbSrcStream; i++)
330 if ((i!=0) && !(i%16))
331 TRACE("\n");
332 TRACE("%02x ", pbSrcStream[i]);
334 TRACE("\n");
336 #endif
338 hr = DSoundRender_SendSampleData(This, pbSrcStream, cbSrcStream);
339 SetEvent(This->state_change);
340 LeaveCriticalSection(&This->filter.csFilter);
341 return hr;
344 static HRESULT WINAPI DSoundRender_CheckMediaType(IPin *iface, const AM_MEDIA_TYPE * pmt)
346 WAVEFORMATEX* format;
348 if (!IsEqualIID(&pmt->majortype, &MEDIATYPE_Audio))
349 return S_FALSE;
351 format = (WAVEFORMATEX*)pmt->pbFormat;
352 TRACE("Format = %p\n", format);
353 TRACE("wFormatTag = %x %x\n", format->wFormatTag, WAVE_FORMAT_PCM);
354 TRACE("nChannels = %d\n", format->nChannels);
355 TRACE("nSamplesPerSec = %d\n", format->nAvgBytesPerSec);
356 TRACE("nAvgBytesPerSec = %d\n", format->nAvgBytesPerSec);
357 TRACE("nBlockAlign = %d\n", format->nBlockAlign);
358 TRACE("wBitsPerSample = %d\n", format->wBitsPerSample);
360 if (!IsEqualIID(&pmt->subtype, &MEDIASUBTYPE_PCM))
361 return S_FALSE;
363 return S_OK;
366 HRESULT DSoundRender_create(IUnknown * pUnkOuter, LPVOID * ppv)
368 HRESULT hr;
369 PIN_INFO piInput;
370 DSoundRenderImpl * pDSoundRender;
372 TRACE("(%p, %p)\n", pUnkOuter, ppv);
374 *ppv = NULL;
376 if (pUnkOuter)
377 return CLASS_E_NOAGGREGATION;
379 pDSoundRender = CoTaskMemAlloc(sizeof(DSoundRenderImpl));
380 if (!pDSoundRender)
381 return E_OUTOFMEMORY;
382 ZeroMemory(pDSoundRender, sizeof(DSoundRenderImpl));
384 BaseFilter_Init(&pDSoundRender->filter, &DSoundRender_Vtbl, &CLSID_DSoundRender, (DWORD_PTR)(__FILE__ ": DSoundRenderImpl.csFilter"));
386 pDSoundRender->IBasicAudio_vtbl = &IBasicAudio_Vtbl;
387 pDSoundRender->IReferenceClock_vtbl = &IReferenceClock_Vtbl;
388 pDSoundRender->IAMDirectSound_vtbl = &IAMDirectSound_Vtbl;
390 /* construct input pin */
391 piInput.dir = PINDIR_INPUT;
392 piInput.pFilter = (IBaseFilter *)pDSoundRender;
393 lstrcpynW(piInput.achName, wcsInputPinName, sizeof(piInput.achName) / sizeof(piInput.achName[0]));
394 hr = BaseInputPin_Construct(&DSoundRender_InputPin_Vtbl, &piInput, DSoundRender_CheckMediaType, DSoundRender_Receive, &pDSoundRender->filter.csFilter, NULL, (IPin **)&pDSoundRender->pInputPin);
396 if (SUCCEEDED(hr))
398 hr = DirectSoundCreate8(NULL, &pDSoundRender->dsound, NULL);
399 if (FAILED(hr))
400 ERR("Cannot create Direct Sound object (%x)\n", hr);
401 else
402 IDirectSound_SetCooperativeLevel(pDSoundRender->dsound, GetDesktopWindow(), DSSCL_PRIORITY);
405 if (SUCCEEDED(hr))
407 ISeekingPassThru *passthru;
408 pDSoundRender->state_change = CreateEventW(NULL, TRUE, TRUE, NULL);
409 pDSoundRender->blocked = CreateEventW(NULL, TRUE, TRUE, NULL);
410 hr = CoCreateInstance(&CLSID_SeekingPassThru, (IUnknown*)pDSoundRender, CLSCTX_INPROC_SERVER, &IID_IUnknown, (void**)&pDSoundRender->seekthru_unk);
411 if (!pDSoundRender->state_change || !pDSoundRender->blocked || FAILED(hr))
413 IUnknown_Release((IUnknown *)pDSoundRender);
414 return HRESULT_FROM_WIN32(GetLastError());
417 IUnknown_QueryInterface(pDSoundRender->seekthru_unk, &IID_ISeekingPassThru, (void**)&passthru);
418 ISeekingPassThru_Init(passthru, TRUE, (IPin*)pDSoundRender->pInputPin);
419 ISeekingPassThru_Release(passthru);
420 *ppv = pDSoundRender;
422 else
424 if (pDSoundRender->pInputPin)
425 IPin_Release((IPin*)pDSoundRender->pInputPin);
426 BaseFilterImpl_Release((IBaseFilter*)pDSoundRender);
427 CoTaskMemFree(pDSoundRender);
430 return hr;
433 static HRESULT WINAPI DSoundRender_QueryInterface(IBaseFilter * iface, REFIID riid, LPVOID * ppv)
435 DSoundRenderImpl *This = (DSoundRenderImpl *)iface;
436 TRACE("(%p, %p)->(%s, %p)\n", This, iface, qzdebugstr_guid(riid), ppv);
438 *ppv = NULL;
440 if (IsEqualIID(riid, &IID_IUnknown))
441 *ppv = This;
442 else if (IsEqualIID(riid, &IID_IPersist))
443 *ppv = This;
444 else if (IsEqualIID(riid, &IID_IMediaFilter))
445 *ppv = This;
446 else if (IsEqualIID(riid, &IID_IBaseFilter))
447 *ppv = This;
448 else if (IsEqualIID(riid, &IID_IBasicAudio))
449 *ppv = &This->IBasicAudio_vtbl;
450 else if (IsEqualIID(riid, &IID_IReferenceClock))
451 *ppv = &This->IReferenceClock_vtbl;
452 else if (IsEqualIID(riid, &IID_IMediaSeeking))
453 return IUnknown_QueryInterface(This->seekthru_unk, riid, ppv);
454 else if (IsEqualIID(riid, &IID_IAMDirectSound))
455 *ppv = &This->IAMDirectSound_vtbl;
457 if (*ppv)
459 IUnknown_AddRef((IUnknown *)(*ppv));
460 return S_OK;
463 if (!IsEqualIID(riid, &IID_IPin) && !IsEqualIID(riid, &IID_IVideoWindow))
464 FIXME("No interface for %s!\n", qzdebugstr_guid(riid));
466 return E_NOINTERFACE;
469 static ULONG WINAPI DSoundRender_Release(IBaseFilter * iface)
471 DSoundRenderImpl *This = (DSoundRenderImpl *)iface;
472 ULONG refCount = BaseFilterImpl_Release(iface);
474 TRACE("(%p)->() Release from %d\n", This, refCount + 1);
476 if (!refCount)
478 IPin *pConnectedTo;
480 if (This->dsbuffer)
481 IDirectSoundBuffer_Release(This->dsbuffer);
482 This->dsbuffer = NULL;
483 if (This->dsound)
484 IDirectSound_Release(This->dsound);
485 This->dsound = NULL;
487 if (SUCCEEDED(IPin_ConnectedTo((IPin *)This->pInputPin, &pConnectedTo)))
489 IPin_Disconnect(pConnectedTo);
490 IPin_Release(pConnectedTo);
492 IPin_Disconnect((IPin *)This->pInputPin);
494 IPin_Release((IPin *)This->pInputPin);
496 This->IBasicAudio_vtbl = NULL;
497 if (This->seekthru_unk)
498 IUnknown_Release(This->seekthru_unk);
500 CloseHandle(This->state_change);
501 CloseHandle(This->blocked);
503 TRACE("Destroying Audio Renderer\n");
504 CoTaskMemFree(This);
506 return 0;
508 else
509 return refCount;
512 /** IMediaFilter methods **/
514 static HRESULT WINAPI DSoundRender_Stop(IBaseFilter * iface)
516 HRESULT hr = S_OK;
517 DSoundRenderImpl *This = (DSoundRenderImpl *)iface;
519 TRACE("(%p/%p)->()\n", This, iface);
521 EnterCriticalSection(&This->filter.csFilter);
523 DWORD state = 0;
524 if (This->dsbuffer)
526 hr = IDirectSoundBuffer_GetStatus(This->dsbuffer, &state);
527 if (SUCCEEDED(hr))
529 if (state & DSBSTATUS_PLAYING)
530 hr = IDirectSoundBuffer_Stop(This->dsbuffer);
533 if (SUCCEEDED(hr))
534 This->filter.state = State_Stopped;
536 /* Complete our transition */
537 SetEvent(This->state_change);
538 SetEvent(This->blocked);
539 MediaSeekingPassThru_ResetMediaTime(This->seekthru_unk);
541 LeaveCriticalSection(&This->filter.csFilter);
543 return hr;
546 static HRESULT WINAPI DSoundRender_Pause(IBaseFilter * iface)
548 HRESULT hr = S_OK;
549 DSoundRenderImpl *This = (DSoundRenderImpl *)iface;
551 TRACE("(%p/%p)->()\n", This, iface);
553 EnterCriticalSection(&This->filter.csFilter);
554 if (This->filter.state != State_Paused)
556 DWORD state = 0;
557 if (This->filter.state == State_Stopped)
559 This->pInputPin->end_of_stream = 0;
562 if (This->dsbuffer)
564 hr = IDirectSoundBuffer_GetStatus(This->dsbuffer, &state);
565 if (SUCCEEDED(hr))
567 if (state & DSBSTATUS_PLAYING)
568 hr = IDirectSoundBuffer_Stop(This->dsbuffer);
571 if (SUCCEEDED(hr))
572 This->filter.state = State_Paused;
574 ResetEvent(This->blocked);
575 ResetEvent(This->state_change);
577 LeaveCriticalSection(&This->filter.csFilter);
579 return hr;
582 static HRESULT WINAPI DSoundRender_Run(IBaseFilter * iface, REFERENCE_TIME tStart)
584 HRESULT hr = S_OK;
585 DSoundRenderImpl *This = (DSoundRenderImpl *)iface;
587 TRACE("(%p/%p)->(%s)\n", This, iface, wine_dbgstr_longlong(tStart));
589 EnterCriticalSection(&This->filter.csFilter);
591 This->filter.rtStreamStart = tStart;
592 if (This->filter.state == State_Paused)
594 /* Unblock our thread, state changing from paused to running doesn't need a reset for state change */
595 SetEvent(This->blocked);
597 else if (This->filter.state == State_Stopped)
599 ResetEvent(This->state_change);
600 This->pInputPin->end_of_stream = 0;
602 ResetEvent(This->blocked);
604 This->filter.state = State_Running;
606 LeaveCriticalSection(&This->filter.csFilter);
608 return hr;
611 static HRESULT WINAPI DSoundRender_GetState(IBaseFilter * iface, DWORD dwMilliSecsTimeout, FILTER_STATE *pState)
613 HRESULT hr;
614 DSoundRenderImpl *This = (DSoundRenderImpl *)iface;
616 TRACE("(%p/%p)->(%d, %p)\n", This, iface, dwMilliSecsTimeout, pState);
618 if (WaitForSingleObject(This->state_change, dwMilliSecsTimeout) == WAIT_TIMEOUT)
619 hr = VFW_S_STATE_INTERMEDIATE;
620 else
621 hr = S_OK;
623 BaseFilterImpl_GetState(iface, dwMilliSecsTimeout, pState);
625 return hr;
628 /** IBaseFilter implementation **/
630 static IPin* WINAPI DSoundRender_GetPin(IBaseFilter *iface, int pos)
632 DSoundRenderImpl *This = (DSoundRenderImpl *)iface;
634 if (pos >= 1 || pos < 0)
635 return NULL;
637 IPin_AddRef((IPin*)This->pInputPin);
638 return (IPin*)This->pInputPin;
641 static LONG WINAPI DSoundRender_GetPinCount(IBaseFilter *iface)
643 /* Our pins are static, not changing so setting static tick count is ok */
644 return 1;
647 static LONG WINAPI DSoundRender_GetPinVersion(IBaseFilter *iface)
649 /* Our pins are static, not changing so setting static tick count is ok */
650 return 0;
653 static HRESULT WINAPI DSoundRender_EnumPins(IBaseFilter * iface, IEnumPins **ppEnum)
655 DSoundRenderImpl *This = (DSoundRenderImpl *)iface;
657 TRACE("(%p/%p)->(%p)\n", This, iface, ppEnum);
659 return EnumPins_Construct(iface, DSoundRender_GetPin, DSoundRender_GetPinCount, DSoundRender_GetPinVersion, ppEnum);
662 static HRESULT WINAPI DSoundRender_FindPin(IBaseFilter * iface, LPCWSTR Id, IPin **ppPin)
664 DSoundRenderImpl *This = (DSoundRenderImpl *)iface;
666 TRACE("(%p/%p)->(%s,%p)\n", This, iface, debugstr_w(Id), ppPin);
668 FIXME("DSoundRender::FindPin(...)\n");
670 /* FIXME: critical section */
672 return E_NOTIMPL;
675 static const IBaseFilterVtbl DSoundRender_Vtbl =
677 DSoundRender_QueryInterface,
678 BaseFilterImpl_AddRef,
679 DSoundRender_Release,
680 BaseFilterImpl_GetClassID,
681 DSoundRender_Stop,
682 DSoundRender_Pause,
683 DSoundRender_Run,
684 DSoundRender_GetState,
685 BaseFilterImpl_SetSyncSource,
686 BaseFilterImpl_GetSyncSource,
687 DSoundRender_EnumPins,
688 DSoundRender_FindPin,
689 BaseFilterImpl_QueryFilterInfo,
690 BaseFilterImpl_JoinFilterGraph,
691 BaseFilterImpl_QueryVendorInfo
694 static HRESULT WINAPI DSoundRender_InputPin_ReceiveConnection(IPin * iface, IPin * pReceivePin, const AM_MEDIA_TYPE * pmt)
696 BaseInputPin *This = (BaseInputPin *)iface;
697 PIN_DIRECTION pindirReceive;
698 DSoundRenderImpl *DSImpl;
699 HRESULT hr = S_OK;
701 TRACE("(%p)->(%p, %p)\n", This, pReceivePin, pmt);
702 dump_AM_MEDIA_TYPE(pmt);
704 EnterCriticalSection(This->pin.pCritSec);
706 DSImpl = (DSoundRenderImpl*)This->pin.pinInfo.pFilter;
707 DSImpl->rtLastStop = -1;
709 if (This->pin.pConnectedTo)
710 hr = VFW_E_ALREADY_CONNECTED;
712 if (SUCCEEDED(hr) && This->fnCheckMediaType(iface, pmt) != S_OK)
713 hr = VFW_E_TYPE_NOT_ACCEPTED;
715 if (SUCCEEDED(hr))
717 IPin_QueryDirection(pReceivePin, &pindirReceive);
719 if (pindirReceive != PINDIR_OUTPUT)
721 ERR("Can't connect from non-output pin\n");
722 hr = VFW_E_INVALID_DIRECTION;
726 if (SUCCEEDED(hr))
728 WAVEFORMATEX *format;
729 DSBUFFERDESC buf_desc;
731 TRACE("MajorType %s\n", debugstr_guid(&pmt->majortype));
732 TRACE("SubType %s\n", debugstr_guid(&pmt->subtype));
733 TRACE("Format %s\n", debugstr_guid(&pmt->formattype));
734 TRACE("Size %d\n", pmt->cbFormat);
736 format = (WAVEFORMATEX*)pmt->pbFormat;
738 DSImpl->buf_size = format->nAvgBytesPerSec;
740 memset(&buf_desc,0,sizeof(DSBUFFERDESC));
741 buf_desc.dwSize = sizeof(DSBUFFERDESC);
742 buf_desc.dwFlags = DSBCAPS_CTRLVOLUME | DSBCAPS_CTRLPAN |
743 DSBCAPS_CTRLFREQUENCY |
744 DSBCAPS_GETCURRENTPOSITION2;
745 buf_desc.dwBufferBytes = DSImpl->buf_size;
746 buf_desc.lpwfxFormat = format;
747 hr = IDirectSound_CreateSoundBuffer(DSImpl->dsound, &buf_desc, &DSImpl->dsbuffer, NULL);
748 if (FAILED(hr))
749 ERR("Can't create sound buffer (%x)\n", hr);
752 if (SUCCEEDED(hr))
754 hr = IDirectSoundBuffer_SetVolume(DSImpl->dsbuffer, DSImpl->volume);
755 if (FAILED(hr))
756 ERR("Can't set volume to %d (%x)\n", DSImpl->volume, hr);
758 hr = IDirectSoundBuffer_SetPan(DSImpl->dsbuffer, DSImpl->pan);
759 if (FAILED(hr))
760 ERR("Can't set pan to %d (%x)\n", DSImpl->pan, hr);
762 DSImpl->write_pos = 0;
763 hr = S_OK;
766 if (SUCCEEDED(hr))
768 CopyMediaType(&This->pin.mtCurrent, pmt);
769 This->pin.pConnectedTo = pReceivePin;
770 IPin_AddRef(pReceivePin);
772 else if (hr != VFW_E_ALREADY_CONNECTED)
774 if (DSImpl->dsbuffer)
775 IDirectSoundBuffer_Release(DSImpl->dsbuffer);
776 DSImpl->dsbuffer = NULL;
779 LeaveCriticalSection(This->pin.pCritSec);
781 return hr;
784 static HRESULT WINAPI DSoundRender_InputPin_Disconnect(IPin * iface)
786 BasePin *This = (BasePin*)iface;
787 DSoundRenderImpl *DSImpl;
789 TRACE("(%p)->()\n", iface);
791 DSImpl = (DSoundRenderImpl*)This->pinInfo.pFilter;
792 if (DSImpl->dsbuffer)
793 IDirectSoundBuffer_Release(DSImpl->dsbuffer);
794 DSImpl->dsbuffer = NULL;
796 return BasePinImpl_Disconnect(iface);
799 static HRESULT WINAPI DSoundRender_InputPin_EndOfStream(IPin * iface)
801 BaseInputPin* This = (BaseInputPin*)iface;
802 DSoundRenderImpl *me = (DSoundRenderImpl*)This->pin.pinInfo.pFilter;
803 IMediaEventSink* pEventSink;
804 HRESULT hr;
806 EnterCriticalSection(This->pin.pCritSec);
808 TRACE("(%p/%p)->()\n", This, iface);
809 hr = BaseInputPinImpl_EndOfStream(iface);
810 if (hr != S_OK)
812 ERR("%08x\n", hr);
813 LeaveCriticalSection(This->pin.pCritSec);
814 return hr;
817 hr = IFilterGraph_QueryInterface(me->filter.filterInfo.pGraph, &IID_IMediaEventSink, (LPVOID*)&pEventSink);
818 if (SUCCEEDED(hr))
820 BYTE * silence;
822 silence = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, me->buf_size);
823 if (silence)
825 memset(silence, 0, me->buf_size);
826 DSoundRender_SendSampleData((DSoundRenderImpl*)This->pin.pinInfo.pFilter, silence, me->buf_size);
827 HeapFree(GetProcessHeap(), 0, silence);
830 hr = IMediaEventSink_Notify(pEventSink, EC_COMPLETE, S_OK, 0);
831 IMediaEventSink_Release(pEventSink);
833 MediaSeekingPassThru_EOS(me->seekthru_unk);
834 LeaveCriticalSection(This->pin.pCritSec);
836 return hr;
839 static HRESULT WINAPI DSoundRender_InputPin_BeginFlush(IPin * iface)
841 BaseInputPin *This = (BaseInputPin *)iface;
842 DSoundRenderImpl *pFilter = (DSoundRenderImpl *)This->pin.pinInfo.pFilter;
843 HRESULT hr;
845 TRACE("\n");
847 EnterCriticalSection(This->pin.pCritSec);
848 hr = BaseInputPinImpl_BeginFlush(iface);
849 SetEvent(pFilter->blocked);
850 LeaveCriticalSection(This->pin.pCritSec);
852 return hr;
855 static HRESULT WINAPI DSoundRender_InputPin_EndFlush(IPin * iface)
857 BaseInputPin *This = (BaseInputPin *)iface;
858 DSoundRenderImpl *pFilter = (DSoundRenderImpl *)This->pin.pinInfo.pFilter;
859 HRESULT hr;
861 TRACE("\n");
863 EnterCriticalSection(This->pin.pCritSec);
864 if (pFilter->in_loop) {
865 ResetEvent(pFilter->state_change);
866 LeaveCriticalSection(This->pin.pCritSec);
867 WaitForSingleObject(pFilter->state_change, -1);
868 EnterCriticalSection(This->pin.pCritSec);
870 if (pFilter->filter.state != State_Stopped)
871 ResetEvent(pFilter->blocked);
873 if (pFilter->dsbuffer)
875 LPBYTE buffer;
876 DWORD size;
877 IDirectSoundBuffer_Stop(pFilter->dsbuffer);
879 /* Force a reset */
880 IDirectSoundBuffer_SetCurrentPosition(pFilter->dsbuffer, 0);
881 pFilter->write_pos = pFilter->last_play_pos = 0;
882 ++pFilter->play_loops;
883 pFilter->write_loops = pFilter->play_loops;
885 IDirectSoundBuffer_Lock(pFilter->dsbuffer, 0, 0, (LPVOID *)&buffer, &size, NULL, NULL, DSBLOCK_ENTIREBUFFER);
886 memset(buffer, 0, size);
887 IDirectSoundBuffer_Unlock(pFilter->dsbuffer, buffer, size, NULL, 0);
889 hr = BaseInputPinImpl_EndFlush(iface);
890 LeaveCriticalSection(This->pin.pCritSec);
891 MediaSeekingPassThru_ResetMediaTime(pFilter->seekthru_unk);
893 return hr;
896 static const IPinVtbl DSoundRender_InputPin_Vtbl =
898 BaseInputPinImpl_QueryInterface,
899 BasePinImpl_AddRef,
900 BaseInputPinImpl_Release,
901 BaseInputPinImpl_Connect,
902 DSoundRender_InputPin_ReceiveConnection,
903 DSoundRender_InputPin_Disconnect,
904 BasePinImpl_ConnectedTo,
905 BasePinImpl_ConnectionMediaType,
906 BasePinImpl_QueryPinInfo,
907 BasePinImpl_QueryDirection,
908 BasePinImpl_QueryId,
909 BaseInputPinImpl_QueryAccept,
910 BasePinImpl_EnumMediaTypes,
911 BasePinImpl_QueryInternalConnections,
912 DSoundRender_InputPin_EndOfStream,
913 DSoundRender_InputPin_BeginFlush,
914 DSoundRender_InputPin_EndFlush,
915 BaseInputPinImpl_NewSegment
918 /*** IUnknown methods ***/
919 static HRESULT WINAPI Basicaudio_QueryInterface(IBasicAudio *iface,
920 REFIID riid,
921 LPVOID*ppvObj) {
922 ICOM_THIS_MULTI(DSoundRenderImpl, IBasicAudio_vtbl, iface);
924 TRACE("(%p/%p)->(%s (%p), %p)\n", This, iface, debugstr_guid(riid), riid, ppvObj);
926 return DSoundRender_QueryInterface((IBaseFilter*)This, riid, ppvObj);
929 static ULONG WINAPI Basicaudio_AddRef(IBasicAudio *iface) {
930 ICOM_THIS_MULTI(DSoundRenderImpl, IBasicAudio_vtbl, iface);
932 TRACE("(%p/%p)->()\n", This, iface);
934 return BaseFilterImpl_AddRef((IBaseFilter*)This);
937 static ULONG WINAPI Basicaudio_Release(IBasicAudio *iface) {
938 ICOM_THIS_MULTI(DSoundRenderImpl, IBasicAudio_vtbl, iface);
940 TRACE("(%p/%p)->()\n", This, iface);
942 return DSoundRender_Release((IBaseFilter*)This);
945 /*** IDispatch methods ***/
946 static HRESULT WINAPI Basicaudio_GetTypeInfoCount(IBasicAudio *iface,
947 UINT*pctinfo) {
948 ICOM_THIS_MULTI(DSoundRenderImpl, IBasicAudio_vtbl, iface);
950 TRACE("(%p/%p)->(%p): stub !!!\n", This, iface, pctinfo);
952 return S_OK;
955 static HRESULT WINAPI Basicaudio_GetTypeInfo(IBasicAudio *iface,
956 UINT iTInfo,
957 LCID lcid,
958 ITypeInfo**ppTInfo) {
959 ICOM_THIS_MULTI(DSoundRenderImpl, IBasicAudio_vtbl, iface);
961 TRACE("(%p/%p)->(%d, %d, %p): stub !!!\n", This, iface, iTInfo, lcid, ppTInfo);
963 return S_OK;
966 static HRESULT WINAPI Basicaudio_GetIDsOfNames(IBasicAudio *iface,
967 REFIID riid,
968 LPOLESTR*rgszNames,
969 UINT cNames,
970 LCID lcid,
971 DISPID*rgDispId) {
972 ICOM_THIS_MULTI(DSoundRenderImpl, IBasicAudio_vtbl, iface);
974 TRACE("(%p/%p)->(%s (%p), %p, %d, %d, %p): stub !!!\n", This, iface, debugstr_guid(riid), riid, rgszNames, cNames, lcid, rgDispId);
976 return S_OK;
979 static HRESULT WINAPI Basicaudio_Invoke(IBasicAudio *iface,
980 DISPID dispIdMember,
981 REFIID riid,
982 LCID lcid,
983 WORD wFlags,
984 DISPPARAMS*pDispParams,
985 VARIANT*pVarResult,
986 EXCEPINFO*pExepInfo,
987 UINT*puArgErr) {
988 ICOM_THIS_MULTI(DSoundRenderImpl, IBasicAudio_vtbl, iface);
990 TRACE("(%p/%p)->(%d, %s (%p), %d, %04x, %p, %p, %p, %p): stub !!!\n", This, iface, dispIdMember, debugstr_guid(riid), riid, lcid, wFlags, pDispParams, pVarResult, pExepInfo, puArgErr);
992 return S_OK;
995 /*** IBasicAudio methods ***/
996 static HRESULT WINAPI Basicaudio_put_Volume(IBasicAudio *iface,
997 LONG lVolume) {
998 ICOM_THIS_MULTI(DSoundRenderImpl, IBasicAudio_vtbl, iface);
1000 TRACE("(%p/%p)->(%d)\n", This, iface, lVolume);
1002 if (lVolume > DSBVOLUME_MAX || lVolume < DSBVOLUME_MIN)
1003 return E_INVALIDARG;
1005 if (This->dsbuffer) {
1006 if (FAILED(IDirectSoundBuffer_SetVolume(This->dsbuffer, lVolume)))
1007 return E_FAIL;
1010 This->volume = lVolume;
1011 return S_OK;
1014 static HRESULT WINAPI Basicaudio_get_Volume(IBasicAudio *iface,
1015 LONG *plVolume) {
1016 ICOM_THIS_MULTI(DSoundRenderImpl, IBasicAudio_vtbl, iface);
1018 TRACE("(%p/%p)->(%p)\n", This, iface, plVolume);
1020 if (!plVolume)
1021 return E_POINTER;
1023 *plVolume = This->volume;
1024 return S_OK;
1027 static HRESULT WINAPI Basicaudio_put_Balance(IBasicAudio *iface,
1028 LONG lBalance) {
1029 ICOM_THIS_MULTI(DSoundRenderImpl, IBasicAudio_vtbl, iface);
1031 TRACE("(%p/%p)->(%d)\n", This, iface, lBalance);
1033 if (lBalance < DSBPAN_LEFT || lBalance > DSBPAN_RIGHT)
1034 return E_INVALIDARG;
1036 if (This->dsbuffer) {
1037 if (FAILED(IDirectSoundBuffer_SetPan(This->dsbuffer, lBalance)))
1038 return E_FAIL;
1041 This->pan = lBalance;
1042 return S_OK;
1045 static HRESULT WINAPI Basicaudio_get_Balance(IBasicAudio *iface,
1046 LONG *plBalance) {
1047 ICOM_THIS_MULTI(DSoundRenderImpl, IBasicAudio_vtbl, iface);
1049 TRACE("(%p/%p)->(%p)\n", This, iface, plBalance);
1051 if (!plBalance)
1052 return E_POINTER;
1054 *plBalance = This->pan;
1055 return S_OK;
1058 static const IBasicAudioVtbl IBasicAudio_Vtbl =
1060 Basicaudio_QueryInterface,
1061 Basicaudio_AddRef,
1062 Basicaudio_Release,
1063 Basicaudio_GetTypeInfoCount,
1064 Basicaudio_GetTypeInfo,
1065 Basicaudio_GetIDsOfNames,
1066 Basicaudio_Invoke,
1067 Basicaudio_put_Volume,
1068 Basicaudio_get_Volume,
1069 Basicaudio_put_Balance,
1070 Basicaudio_get_Balance
1074 /*** IUnknown methods ***/
1075 static HRESULT WINAPI ReferenceClock_QueryInterface(IReferenceClock *iface,
1076 REFIID riid,
1077 LPVOID*ppvObj)
1079 ICOM_THIS_MULTI(DSoundRenderImpl, IReferenceClock_vtbl, iface);
1081 TRACE("(%p/%p)->(%s (%p), %p)\n", This, iface, debugstr_guid(riid), riid, ppvObj);
1083 return DSoundRender_QueryInterface((IBaseFilter*)This, riid, ppvObj);
1086 static ULONG WINAPI ReferenceClock_AddRef(IReferenceClock *iface)
1088 ICOM_THIS_MULTI(DSoundRenderImpl, IReferenceClock_vtbl, iface);
1090 TRACE("(%p/%p)->()\n", This, iface);
1092 return BaseFilterImpl_AddRef((IBaseFilter*)This);
1095 static ULONG WINAPI ReferenceClock_Release(IReferenceClock *iface)
1097 ICOM_THIS_MULTI(DSoundRenderImpl, IReferenceClock_vtbl, iface);
1099 TRACE("(%p/%p)->()\n", This, iface);
1101 return DSoundRender_Release((IBaseFilter*)This);
1104 /*** IReferenceClock methods ***/
1105 static HRESULT WINAPI ReferenceClock_GetTime(IReferenceClock *iface,
1106 REFERENCE_TIME *pTime)
1108 ICOM_THIS_MULTI(DSoundRenderImpl, IReferenceClock_vtbl, iface);
1109 HRESULT hr = E_FAIL;
1110 DWORD play_pos;
1112 TRACE("(%p/%p)->(%p)\n", This, iface, pTime);
1114 if (This->dsbuffer)
1115 hr = DSoundRender_GetPos(This, &play_pos, pTime);
1116 if (FAILED(hr))
1117 ERR("Could not get reference time (%x)!\n", hr);
1119 return hr;
1122 static HRESULT WINAPI ReferenceClock_AdviseTime(IReferenceClock *iface,
1123 REFERENCE_TIME rtBaseTime,
1124 REFERENCE_TIME rtStreamTime,
1125 HEVENT hEvent,
1126 DWORD_PTR *pdwAdviseCookie)
1128 ICOM_THIS_MULTI(DSoundRenderImpl, IReferenceClock_vtbl, iface);
1130 FIXME("(%p/%p)->(%s, %s, %p, %p): stub!\n", This, iface, wine_dbgstr_longlong(rtBaseTime), wine_dbgstr_longlong(rtStreamTime), (void*)hEvent, pdwAdviseCookie);
1132 return E_NOTIMPL;
1135 static HRESULT WINAPI ReferenceClock_AdvisePeriodic(IReferenceClock *iface,
1136 REFERENCE_TIME rtBaseTime,
1137 REFERENCE_TIME rtStreamTime,
1138 HSEMAPHORE hSemaphore,
1139 DWORD_PTR *pdwAdviseCookie)
1141 ICOM_THIS_MULTI(DSoundRenderImpl, IReferenceClock_vtbl, iface);
1143 FIXME("(%p/%p)->(%s, %s, %p, %p): stub!\n", This, iface, wine_dbgstr_longlong(rtBaseTime), wine_dbgstr_longlong(rtStreamTime), (void*)hSemaphore, pdwAdviseCookie);
1145 return E_NOTIMPL;
1148 static HRESULT WINAPI ReferenceClock_Unadvise(IReferenceClock *iface,
1149 DWORD_PTR dwAdviseCookie)
1151 ICOM_THIS_MULTI(DSoundRenderImpl, IReferenceClock_vtbl, iface);
1153 FIXME("(%p/%p)->(%p): stub!\n", This, iface, (void*)dwAdviseCookie);
1155 return S_FALSE;
1158 static const IReferenceClockVtbl IReferenceClock_Vtbl =
1160 ReferenceClock_QueryInterface,
1161 ReferenceClock_AddRef,
1162 ReferenceClock_Release,
1163 ReferenceClock_GetTime,
1164 ReferenceClock_AdviseTime,
1165 ReferenceClock_AdvisePeriodic,
1166 ReferenceClock_Unadvise
1169 /*** IUnknown methods ***/
1170 static HRESULT WINAPI AMDirectSound_QueryInterface(IAMDirectSound *iface,
1171 REFIID riid,
1172 LPVOID*ppvObj)
1174 ICOM_THIS_MULTI(DSoundRenderImpl, IAMDirectSound_vtbl, iface);
1176 TRACE("(%p/%p)->(%s (%p), %p)\n", This, iface, debugstr_guid(riid), riid, ppvObj);
1178 return DSoundRender_QueryInterface((IBaseFilter*)This, riid, ppvObj);
1181 static ULONG WINAPI AMDirectSound_AddRef(IAMDirectSound *iface)
1183 ICOM_THIS_MULTI(DSoundRenderImpl, IAMDirectSound_vtbl, iface);
1185 TRACE("(%p/%p)->()\n", This, iface);
1187 return BaseFilterImpl_AddRef((IBaseFilter*)This);
1190 static ULONG WINAPI AMDirectSound_Release(IAMDirectSound *iface)
1192 ICOM_THIS_MULTI(DSoundRenderImpl, IAMDirectSound_vtbl, iface);
1194 TRACE("(%p/%p)->()\n", This, iface);
1196 return DSoundRender_Release((IBaseFilter*)This);
1199 /*** IAMDirectSound methods ***/
1200 static HRESULT WINAPI AMDirectSound_GetDirectSoundInterface(IAMDirectSound *iface, IDirectSound **ds)
1202 ICOM_THIS_MULTI(DSoundRenderImpl, IAMDirectSound_vtbl, iface);
1204 FIXME("(%p/%p)->(%p): stub\n", This, iface, ds);
1206 return E_NOTIMPL;
1209 static HRESULT WINAPI AMDirectSound_GetPrimaryBufferInterface(IAMDirectSound *iface, IDirectSoundBuffer **buf)
1211 ICOM_THIS_MULTI(DSoundRenderImpl, IAMDirectSound_vtbl, iface);
1213 FIXME("(%p/%p)->(%p): stub\n", This, iface, buf);
1215 return E_NOTIMPL;
1218 static HRESULT WINAPI AMDirectSound_GetSecondaryBufferInterface(IAMDirectSound *iface, IDirectSoundBuffer **buf)
1220 ICOM_THIS_MULTI(DSoundRenderImpl, IAMDirectSound_vtbl, iface);
1222 FIXME("(%p/%p)->(%p): stub\n", This, iface, buf);
1224 return E_NOTIMPL;
1227 static HRESULT WINAPI AMDirectSound_ReleaseDirectSoundInterface(IAMDirectSound *iface, IDirectSound *ds)
1229 ICOM_THIS_MULTI(DSoundRenderImpl, IAMDirectSound_vtbl, iface);
1231 FIXME("(%p/%p)->(%p): stub\n", This, iface, ds);
1233 return E_NOTIMPL;
1236 static HRESULT WINAPI AMDirectSound_ReleasePrimaryBufferInterface(IAMDirectSound *iface, IDirectSoundBuffer *buf)
1238 ICOM_THIS_MULTI(DSoundRenderImpl, IAMDirectSound_vtbl, iface);
1240 FIXME("(%p/%p)->(%p): stub\n", This, iface, buf);
1242 return E_NOTIMPL;
1245 static HRESULT WINAPI AMDirectSound_ReleaseSecondaryBufferInterface(IAMDirectSound *iface, IDirectSoundBuffer *buf)
1247 ICOM_THIS_MULTI(DSoundRenderImpl, IAMDirectSound_vtbl, iface);
1249 FIXME("(%p/%p)->(%p): stub\n", This, iface, buf);
1251 return E_NOTIMPL;
1254 static HRESULT WINAPI AMDirectSound_SetFocusWindow(IAMDirectSound *iface, HWND hwnd, BOOL bgsilent)
1256 ICOM_THIS_MULTI(DSoundRenderImpl, IAMDirectSound_vtbl, iface);
1258 FIXME("(%p/%p)->(%p,%d): stub\n", This, iface, hwnd, bgsilent);
1260 return E_NOTIMPL;
1263 static HRESULT WINAPI AMDirectSound_GetFocusWindow(IAMDirectSound *iface, HWND hwnd)
1265 ICOM_THIS_MULTI(DSoundRenderImpl, IAMDirectSound_vtbl, iface);
1267 FIXME("(%p/%p)->(%p): stub\n", This, iface, hwnd);
1269 return E_NOTIMPL;
1272 static const IAMDirectSoundVtbl IAMDirectSound_Vtbl =
1274 AMDirectSound_QueryInterface,
1275 AMDirectSound_AddRef,
1276 AMDirectSound_Release,
1277 AMDirectSound_GetDirectSoundInterface,
1278 AMDirectSound_GetPrimaryBufferInterface,
1279 AMDirectSound_GetSecondaryBufferInterface,
1280 AMDirectSound_ReleaseDirectSoundInterface,
1281 AMDirectSound_ReleasePrimaryBufferInterface,
1282 AMDirectSound_ReleaseSecondaryBufferInterface,
1283 AMDirectSound_SetFocusWindow,
1284 AMDirectSound_GetFocusWindow