dplayx: Adjust GetCaps behaviour to documentation
[wine/gsoc_dplay.git] / dlls / quartz / dsoundrender.c
blobedb170da136a6a9e7de5a0844461eec0b93ad109
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"
36 #include "wine/unicode.h"
37 #include "wine/debug.h"
39 WINE_DEFAULT_DEBUG_CHANNEL(quartz);
41 static const WCHAR wcsInputPinName[] = {'i','n','p','u','t',' ','p','i','n',0};
43 static const IBaseFilterVtbl DSoundRender_Vtbl;
44 static const IPinVtbl DSoundRender_InputPin_Vtbl;
45 static const IBasicAudioVtbl IBasicAudio_Vtbl;
46 static const IReferenceClockVtbl IReferenceClock_Vtbl;
47 static const IMediaSeekingVtbl IMediaSeeking_Vtbl;
49 typedef struct DSoundRenderImpl
51 const IBaseFilterVtbl * lpVtbl;
52 const IBasicAudioVtbl *IBasicAudio_vtbl;
53 const IReferenceClockVtbl *IReferenceClock_vtbl;
55 LONG refCount;
56 CRITICAL_SECTION csFilter;
57 FILTER_STATE state;
58 REFERENCE_TIME rtStreamStart, rtLastStop;
59 IReferenceClock * pClock;
60 FILTER_INFO filterInfo;
62 InputPin * 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;
73 REFERENCE_TIME play_time;
74 MediaSeekingImpl mediaSeeking;
76 HANDLE state_change, blocked;
78 long volume;
79 long pan;
80 } DSoundRenderImpl;
82 /* Seeking is not needed for a renderer, rely on newsegment for the appropriate changes */
83 static HRESULT sound_mod_stop(IBaseFilter *iface)
85 TRACE("(%p)\n", iface);
86 return S_OK;
89 static HRESULT sound_mod_start(IBaseFilter *iface)
91 TRACE("(%p)\n", iface);
93 return S_OK;
96 static HRESULT sound_mod_rate(IBaseFilter *iface)
98 DSoundRenderImpl *This = (DSoundRenderImpl *)iface;
100 WAVEFORMATEX *format = (WAVEFORMATEX*)This->pInputPin->pin.mtCurrent.pbFormat;
101 DWORD freq = format->nSamplesPerSec;
102 double rate = This->mediaSeeking.dRate;
104 freq = (DWORD)((double)freq * rate);
106 TRACE("(%p)\n", iface);
108 if (freq > DSBFREQUENCY_MAX)
109 return VFW_E_UNSUPPORTED_AUDIO;
111 if (freq < DSBFREQUENCY_MIN)
112 return VFW_E_UNSUPPORTED_AUDIO;
114 return S_OK;
117 static inline HRESULT DSoundRender_GetPos(DSoundRenderImpl *This, DWORD *pPlayPos, REFERENCE_TIME *pRefTime)
119 HRESULT hr;
121 EnterCriticalSection(&This->csFilter);
123 DWORD state;
124 DWORD write_pos;
126 hr = IDirectSoundBuffer_GetStatus(This->dsbuffer, &state);
127 if (SUCCEEDED(hr) && !(state & DSBSTATUS_PLAYING) && This->state == State_Running)
129 TRACE("Not playing, kickstarting the engine\n");
131 hr = IDirectSoundBuffer_Play(This->dsbuffer, 0, 0, DSBPLAY_LOOPING);
132 if (FAILED(hr))
133 ERR("Can't play sound buffer (%x)\n", hr);
136 if (SUCCEEDED(hr))
137 hr = IDirectSoundBuffer_GetCurrentPosition(This->dsbuffer, pPlayPos, &write_pos);
138 if (hr == S_OK)
140 DWORD play_pos = *pPlayPos;
142 if (play_pos < This->last_play_pos)
143 This->play_loops++;
144 This->last_play_pos = play_pos;
146 /* If we really fell behind, start at the next possible position
147 * Also happens when just starting playback for the first time,
148 * or when flushing
150 if ((This->play_loops*This->buf_size)+play_pos >=
151 (This->write_loops*This->buf_size)+This->write_pos)
152 This->write_pos = write_pos;
154 if (pRefTime)
156 REFERENCE_TIME play_time;
157 play_time = ((REFERENCE_TIME)This->play_loops*10000000) +
158 ((REFERENCE_TIME)play_pos*10000000/This->buf_size);
160 /* Don't let time run backwards */
161 if(play_time-This->play_time > 0)
162 This->play_time = play_time;
163 else
164 hr = S_FALSE;
166 *pRefTime = This->play_time;
170 LeaveCriticalSection(&This->csFilter);
172 return hr;
175 static HRESULT DSoundRender_SendSampleData(DSoundRenderImpl* This, const BYTE *data, DWORD size)
177 HRESULT hr = S_OK;
178 LPBYTE lpbuf1 = NULL;
179 LPBYTE lpbuf2 = NULL;
180 DWORD dwsize1 = 0;
181 DWORD dwsize2 = 0;
182 DWORD size2;
183 DWORD play_pos,buf_free;
185 do {
187 hr = DSoundRender_GetPos(This, &play_pos, NULL);
188 if (hr != DS_OK)
190 ERR("GetPos returned error: %x\n", hr);
191 break;
193 if (This->write_pos <= play_pos)
194 buf_free = play_pos-This->write_pos;
195 else
196 buf_free = This->buf_size - This->write_pos + play_pos;
198 /* Wait for enough of the buffer to empty before filling it */
199 if(buf_free < This->buf_size/4)
201 Sleep(50);
202 continue;
205 size2 = min(buf_free, size);
206 hr = IDirectSoundBuffer_Lock(This->dsbuffer, This->write_pos, size2, (LPVOID *)&lpbuf1, &dwsize1, (LPVOID *)&lpbuf2, &dwsize2, 0);
207 if (hr != DS_OK) {
208 ERR("Unable to lock sound buffer! (%x)\n", hr);
209 break;
211 /* TRACE("write_pos=%d, size=%d, sz1=%d, sz2=%d\n", This->write_pos, size2, dwsize1, dwsize2); */
213 memcpy(lpbuf1, data, dwsize1);
214 if (dwsize2)
215 memcpy(lpbuf2, data + dwsize1, dwsize2);
217 hr = IDirectSoundBuffer_Unlock(This->dsbuffer, lpbuf1, dwsize1, lpbuf2, dwsize2);
218 if (hr != DS_OK)
219 ERR("Unable to unlock sound buffer! (%x)\n", hr);
221 size -= dwsize1 + dwsize2;
222 data += dwsize1 + dwsize2;
223 This->write_pos += dwsize1 + dwsize2;
224 if (This->write_pos >= This->buf_size)
226 This->write_pos -= This->buf_size;
227 This->write_loops++;
229 } while (size && This->state == State_Running);
231 return hr;
234 static HRESULT DSoundRender_Sample(LPVOID iface, IMediaSample * pSample)
236 DSoundRenderImpl *This = iface;
237 LPBYTE pbSrcStream = NULL;
238 long cbSrcStream = 0;
239 REFERENCE_TIME tStart, tStop;
240 HRESULT hr;
241 AM_MEDIA_TYPE *amt;
243 TRACE("%p %p\n", iface, pSample);
245 /* Slightly incorrect, Pause completes when a frame is received so we should signal
246 * pause completion here, but for sound playing a single frame doesn't make sense
249 EnterCriticalSection(&This->csFilter);
251 if (This->pInputPin->end_of_stream || This->pInputPin->flushing)
253 LeaveCriticalSection(&This->csFilter);
254 return S_FALSE;
257 if (This->state == State_Stopped)
259 LeaveCriticalSection(&This->csFilter);
260 return VFW_E_WRONG_STATE;
263 if (IMediaSample_GetMediaType(pSample, &amt) == S_OK)
265 AM_MEDIA_TYPE *orig = &This->pInputPin->pin.mtCurrent;
266 WAVEFORMATEX *origfmt = (WAVEFORMATEX *)orig->pbFormat;
267 WAVEFORMATEX *newfmt = (WAVEFORMATEX *)amt->pbFormat;
269 if (origfmt->wFormatTag == newfmt->wFormatTag &&
270 origfmt->nChannels == newfmt->nChannels &&
271 origfmt->nBlockAlign == newfmt->nBlockAlign &&
272 origfmt->wBitsPerSample == newfmt->wBitsPerSample &&
273 origfmt->cbSize == newfmt->cbSize)
275 if (origfmt->nSamplesPerSec != newfmt->nSamplesPerSec)
277 hr = IDirectSoundBuffer_SetFrequency(This->dsbuffer,
278 newfmt->nSamplesPerSec);
279 if (FAILED(hr))
281 LeaveCriticalSection(&This->csFilter);
282 return VFW_E_TYPE_NOT_ACCEPTED;
284 FreeMediaType(orig);
285 CopyMediaType(orig, amt);
286 IMediaSample_SetMediaType(pSample, NULL);
289 else
291 LeaveCriticalSection(&This->csFilter);
292 return VFW_E_TYPE_NOT_ACCEPTED;
296 SetEvent(This->state_change);
298 hr = IMediaSample_GetPointer(pSample, &pbSrcStream);
299 if (FAILED(hr))
301 ERR("Cannot get pointer to sample data (%x)\n", hr);
302 LeaveCriticalSection(&This->csFilter);
303 return hr;
306 hr = IMediaSample_GetTime(pSample, &tStart, &tStop);
307 if (FAILED(hr))
308 ERR("Cannot get sample time (%x)\n", hr);
310 if (This->rtLastStop != tStart && (IMediaSample_IsDiscontinuity(pSample) == S_FALSE))
311 WARN("Unexpected discontinuity: Last: %u.%03u, tStart: %u.%03u\n",
312 (DWORD)(This->rtLastStop / 10000000), (DWORD)((This->rtLastStop / 10000)%1000),
313 (DWORD)(tStart / 10000000), (DWORD)((tStart / 10000)%1000));
314 This->rtLastStop = tStop;
316 if (IMediaSample_IsPreroll(pSample) == S_OK)
318 TRACE("Preroll!\n");
319 LeaveCriticalSection(&This->csFilter);
320 return S_OK;
323 if (This->state == State_Paused)
325 LeaveCriticalSection(&This->csFilter);
326 WaitForSingleObject(This->blocked, INFINITE);
327 EnterCriticalSection(&This->csFilter);
328 if (This->state == State_Stopped)
330 LeaveCriticalSection(&This->csFilter);
331 return VFW_E_WRONG_STATE;
334 if (This->state == State_Paused)
336 /* Assuming we return because of flushing */
337 TRACE("Flushing\n");
338 LeaveCriticalSection(&This->csFilter);
339 return S_OK;
343 cbSrcStream = IMediaSample_GetActualDataLength(pSample);
344 TRACE("Sample data ptr = %p, size = %ld\n", pbSrcStream, cbSrcStream);
346 #if 0 /* For debugging purpose */
348 int i;
349 for(i = 0; i < cbSrcStream; i++)
351 if ((i!=0) && !(i%16))
352 TRACE("\n");
353 TRACE("%02x ", pbSrcStream[i]);
355 TRACE("\n");
357 #endif
359 hr = DSoundRender_SendSampleData(This, pbSrcStream, cbSrcStream);
360 LeaveCriticalSection(&This->csFilter);
361 return hr;
364 static HRESULT DSoundRender_QueryAccept(LPVOID iface, const AM_MEDIA_TYPE * pmt)
366 WAVEFORMATEX* format;
368 if (!IsEqualIID(&pmt->majortype, &MEDIATYPE_Audio))
369 return S_FALSE;
371 format = (WAVEFORMATEX*)pmt->pbFormat;
372 TRACE("Format = %p\n", format);
373 TRACE("wFormatTag = %x %x\n", format->wFormatTag, WAVE_FORMAT_PCM);
374 TRACE("nChannels = %d\n", format->nChannels);
375 TRACE("nSamplesPerSec = %d\n", format->nAvgBytesPerSec);
376 TRACE("nAvgBytesPerSec = %d\n", format->nAvgBytesPerSec);
377 TRACE("nBlockAlign = %d\n", format->nBlockAlign);
378 TRACE("wBitsPerSample = %d\n", format->wBitsPerSample);
380 if (!IsEqualIID(&pmt->subtype, &MEDIASUBTYPE_PCM))
381 return S_FALSE;
383 return S_OK;
386 HRESULT DSoundRender_create(IUnknown * pUnkOuter, LPVOID * ppv)
388 HRESULT hr;
389 PIN_INFO piInput;
390 DSoundRenderImpl * pDSoundRender;
392 TRACE("(%p, %p)\n", pUnkOuter, ppv);
394 *ppv = NULL;
396 if (pUnkOuter)
397 return CLASS_E_NOAGGREGATION;
399 pDSoundRender = CoTaskMemAlloc(sizeof(DSoundRenderImpl));
400 if (!pDSoundRender)
401 return E_OUTOFMEMORY;
402 ZeroMemory(pDSoundRender, sizeof(DSoundRenderImpl));
404 pDSoundRender->lpVtbl = &DSoundRender_Vtbl;
405 pDSoundRender->IBasicAudio_vtbl = &IBasicAudio_Vtbl;
406 pDSoundRender->IReferenceClock_vtbl = &IReferenceClock_Vtbl;
407 pDSoundRender->refCount = 1;
408 InitializeCriticalSection(&pDSoundRender->csFilter);
409 pDSoundRender->csFilter.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": DSoundRenderImpl.csFilter");
410 pDSoundRender->state = State_Stopped;
412 /* construct input pin */
413 piInput.dir = PINDIR_INPUT;
414 piInput.pFilter = (IBaseFilter *)pDSoundRender;
415 lstrcpynW(piInput.achName, wcsInputPinName, sizeof(piInput.achName) / sizeof(piInput.achName[0]));
416 hr = InputPin_Construct(&DSoundRender_InputPin_Vtbl, &piInput, DSoundRender_Sample, pDSoundRender, DSoundRender_QueryAccept, NULL, &pDSoundRender->csFilter, NULL, (IPin **)&pDSoundRender->pInputPin);
418 if (SUCCEEDED(hr))
420 hr = DirectSoundCreate8(NULL, &pDSoundRender->dsound, NULL);
421 if (FAILED(hr))
422 ERR("Cannot create Direct Sound object (%x)\n", hr);
423 else
424 IDirectSound_SetCooperativeLevel(pDSoundRender->dsound, GetDesktopWindow(), DSSCL_PRIORITY);
427 if (SUCCEEDED(hr))
429 MediaSeekingImpl_Init((IBaseFilter*)pDSoundRender, sound_mod_stop, sound_mod_start, sound_mod_rate, &pDSoundRender->mediaSeeking, &pDSoundRender->csFilter);
430 pDSoundRender->mediaSeeking.lpVtbl = &IMediaSeeking_Vtbl;
432 pDSoundRender->state_change = CreateEventW(NULL, TRUE, TRUE, NULL);
433 pDSoundRender->blocked = CreateEventW(NULL, FALSE, FALSE, NULL);
435 if (!pDSoundRender->state_change || !pDSoundRender->blocked)
437 IUnknown_Release((IUnknown *)pDSoundRender);
438 return HRESULT_FROM_WIN32(GetLastError());
441 *ppv = pDSoundRender;
443 else
445 if (pDSoundRender->pInputPin)
446 IPin_Release((IPin*)pDSoundRender->pInputPin);
447 pDSoundRender->csFilter.DebugInfo->Spare[0] = 0;
448 DeleteCriticalSection(&pDSoundRender->csFilter);
449 CoTaskMemFree(pDSoundRender);
452 return hr;
455 static HRESULT WINAPI DSoundRender_QueryInterface(IBaseFilter * iface, REFIID riid, LPVOID * ppv)
457 DSoundRenderImpl *This = (DSoundRenderImpl *)iface;
458 TRACE("(%p, %p)->(%s, %p)\n", This, iface, qzdebugstr_guid(riid), ppv);
460 *ppv = NULL;
462 if (IsEqualIID(riid, &IID_IUnknown))
463 *ppv = This;
464 else if (IsEqualIID(riid, &IID_IPersist))
465 *ppv = This;
466 else if (IsEqualIID(riid, &IID_IMediaFilter))
467 *ppv = This;
468 else if (IsEqualIID(riid, &IID_IBaseFilter))
469 *ppv = This;
470 else if (IsEqualIID(riid, &IID_IBasicAudio))
471 *ppv = &This->IBasicAudio_vtbl;
472 else if (IsEqualIID(riid, &IID_IReferenceClock))
473 *ppv = &This->IReferenceClock_vtbl;
474 else if (IsEqualIID(riid, &IID_IMediaSeeking))
475 *ppv = &This->mediaSeeking.lpVtbl;
477 if (*ppv)
479 IUnknown_AddRef((IUnknown *)(*ppv));
480 return S_OK;
483 if (!IsEqualIID(riid, &IID_IPin) && !IsEqualIID(riid, &IID_IVideoWindow))
484 FIXME("No interface for %s!\n", qzdebugstr_guid(riid));
486 return E_NOINTERFACE;
489 static ULONG WINAPI DSoundRender_AddRef(IBaseFilter * iface)
491 DSoundRenderImpl *This = (DSoundRenderImpl *)iface;
492 ULONG refCount = InterlockedIncrement(&This->refCount);
494 TRACE("(%p/%p)->() AddRef from %d\n", This, iface, refCount - 1);
496 return refCount;
499 static ULONG WINAPI DSoundRender_Release(IBaseFilter * iface)
501 DSoundRenderImpl *This = (DSoundRenderImpl *)iface;
502 ULONG refCount = InterlockedDecrement(&This->refCount);
504 TRACE("(%p)->() Release from %d\n", This, refCount + 1);
506 if (!refCount)
508 IPin *pConnectedTo;
510 if (This->pClock)
511 IReferenceClock_Release(This->pClock);
513 if (This->dsbuffer)
514 IDirectSoundBuffer_Release(This->dsbuffer);
515 This->dsbuffer = NULL;
516 if (This->dsound)
517 IDirectSound_Release(This->dsound);
518 This->dsound = NULL;
520 if (SUCCEEDED(IPin_ConnectedTo((IPin *)This->pInputPin, &pConnectedTo)))
522 IPin_Disconnect(pConnectedTo);
523 IPin_Release(pConnectedTo);
525 IPin_Disconnect((IPin *)This->pInputPin);
527 IPin_Release((IPin *)This->pInputPin);
529 This->lpVtbl = NULL;
530 This->IBasicAudio_vtbl = NULL;
532 This->csFilter.DebugInfo->Spare[0] = 0;
533 DeleteCriticalSection(&This->csFilter);
535 CloseHandle(This->state_change);
536 CloseHandle(This->blocked);
538 TRACE("Destroying Audio Renderer\n");
539 CoTaskMemFree(This);
541 return 0;
543 else
544 return refCount;
547 /** IPersist methods **/
549 static HRESULT WINAPI DSoundRender_GetClassID(IBaseFilter * iface, CLSID * pClsid)
551 DSoundRenderImpl *This = (DSoundRenderImpl *)iface;
552 TRACE("(%p/%p)->(%p)\n", This, iface, pClsid);
554 *pClsid = CLSID_DSoundRender;
556 return S_OK;
559 /** IMediaFilter methods **/
561 static HRESULT WINAPI DSoundRender_Stop(IBaseFilter * iface)
563 HRESULT hr = S_OK;
564 DSoundRenderImpl *This = (DSoundRenderImpl *)iface;
566 TRACE("(%p/%p)->()\n", This, iface);
568 EnterCriticalSection(&This->csFilter);
570 DWORD state = 0;
571 if (This->dsbuffer)
573 hr = IDirectSoundBuffer_GetStatus(This->dsbuffer, &state);
574 if (SUCCEEDED(hr))
576 if (state & DSBSTATUS_PLAYING)
577 hr = IDirectSoundBuffer_Stop(This->dsbuffer);
580 if (SUCCEEDED(hr))
581 This->state = State_Stopped;
583 /* Complete our transition */
584 SetEvent(This->state_change);
585 SetEvent(This->blocked);
587 LeaveCriticalSection(&This->csFilter);
589 return hr;
592 static HRESULT WINAPI DSoundRender_Pause(IBaseFilter * iface)
594 HRESULT hr = S_OK;
595 DSoundRenderImpl *This = (DSoundRenderImpl *)iface;
597 TRACE("(%p/%p)->()\n", This, iface);
599 EnterCriticalSection(&This->csFilter);
600 if (This->state != State_Paused)
602 DWORD state = 0;
603 if (This->state == State_Stopped)
605 This->pInputPin->end_of_stream = 0;
608 if (This->dsbuffer)
610 hr = IDirectSoundBuffer_GetStatus(This->dsbuffer, &state);
611 if (SUCCEEDED(hr))
613 if (state & DSBSTATUS_PLAYING)
614 hr = IDirectSoundBuffer_Stop(This->dsbuffer);
617 if (SUCCEEDED(hr))
618 This->state = State_Paused;
620 ResetEvent(This->blocked);
621 ResetEvent(This->state_change);
623 LeaveCriticalSection(&This->csFilter);
625 return hr;
628 static HRESULT WINAPI DSoundRender_Run(IBaseFilter * iface, REFERENCE_TIME tStart)
630 HRESULT hr = S_OK;
631 DSoundRenderImpl *This = (DSoundRenderImpl *)iface;
633 TRACE("(%p/%p)->(%s)\n", This, iface, wine_dbgstr_longlong(tStart));
635 EnterCriticalSection(&This->csFilter);
637 This->rtStreamStart = tStart;
638 if (This->state == State_Paused)
640 /* Unblock our thread, state changing from paused to running doesn't need a reset for state change */
641 SetEvent(This->blocked);
643 else if (This->state == State_Stopped)
645 ResetEvent(This->state_change);
646 This->pInputPin->end_of_stream = 0;
649 This->state = State_Running;
651 LeaveCriticalSection(&This->csFilter);
653 return hr;
656 static HRESULT WINAPI DSoundRender_GetState(IBaseFilter * iface, DWORD dwMilliSecsTimeout, FILTER_STATE *pState)
658 HRESULT hr;
659 DSoundRenderImpl *This = (DSoundRenderImpl *)iface;
661 TRACE("(%p/%p)->(%d, %p)\n", This, iface, dwMilliSecsTimeout, pState);
663 if (WaitForSingleObject(This->state_change, dwMilliSecsTimeout) == WAIT_TIMEOUT)
664 hr = VFW_S_STATE_INTERMEDIATE;
665 else
666 hr = S_OK;
668 EnterCriticalSection(&This->csFilter);
670 *pState = This->state;
672 LeaveCriticalSection(&This->csFilter);
674 return S_OK;
677 static HRESULT WINAPI DSoundRender_SetSyncSource(IBaseFilter * iface, IReferenceClock *pClock)
679 DSoundRenderImpl *This = (DSoundRenderImpl *)iface;
681 TRACE("(%p/%p)->(%p)\n", This, iface, pClock);
683 EnterCriticalSection(&This->csFilter);
685 if (This->pClock)
686 IReferenceClock_Release(This->pClock);
687 This->pClock = pClock;
688 if (This->pClock)
689 IReferenceClock_AddRef(This->pClock);
691 LeaveCriticalSection(&This->csFilter);
693 return S_OK;
696 static HRESULT WINAPI DSoundRender_GetSyncSource(IBaseFilter * iface, IReferenceClock **ppClock)
698 DSoundRenderImpl *This = (DSoundRenderImpl *)iface;
700 TRACE("(%p/%p)->(%p)\n", This, iface, ppClock);
702 EnterCriticalSection(&This->csFilter);
704 *ppClock = This->pClock;
705 if (This->pClock)
706 IReferenceClock_AddRef(This->pClock);
708 LeaveCriticalSection(&This->csFilter);
710 return S_OK;
713 /** IBaseFilter implementation **/
715 static HRESULT DSoundRender_GetPin(IBaseFilter *iface, ULONG pos, IPin **pin, DWORD *lastsynctick)
717 DSoundRenderImpl *This = (DSoundRenderImpl *)iface;
719 /* Our pins are static, not changing so setting static tick count is ok */
720 *lastsynctick = 0;
722 if (pos >= 1)
723 return S_FALSE;
725 *pin = (IPin *)This->pInputPin;
726 IPin_AddRef(*pin);
727 return S_OK;
730 static HRESULT WINAPI DSoundRender_EnumPins(IBaseFilter * iface, IEnumPins **ppEnum)
732 DSoundRenderImpl *This = (DSoundRenderImpl *)iface;
734 TRACE("(%p/%p)->(%p)\n", This, iface, ppEnum);
736 return IEnumPinsImpl_Construct(ppEnum, DSoundRender_GetPin, iface);
739 static HRESULT WINAPI DSoundRender_FindPin(IBaseFilter * iface, LPCWSTR Id, IPin **ppPin)
741 DSoundRenderImpl *This = (DSoundRenderImpl *)iface;
743 TRACE("(%p/%p)->(%s,%p)\n", This, iface, debugstr_w(Id), ppPin);
745 FIXME("DSoundRender::FindPin(...)\n");
747 /* FIXME: critical section */
749 return E_NOTIMPL;
752 static HRESULT WINAPI DSoundRender_QueryFilterInfo(IBaseFilter * iface, FILTER_INFO *pInfo)
754 DSoundRenderImpl *This = (DSoundRenderImpl *)iface;
756 TRACE("(%p/%p)->(%p)\n", This, iface, pInfo);
758 strcpyW(pInfo->achName, This->filterInfo.achName);
759 pInfo->pGraph = This->filterInfo.pGraph;
761 if (pInfo->pGraph)
762 IFilterGraph_AddRef(pInfo->pGraph);
764 return S_OK;
767 static HRESULT WINAPI DSoundRender_JoinFilterGraph(IBaseFilter * iface, IFilterGraph *pGraph, LPCWSTR pName)
769 DSoundRenderImpl *This = (DSoundRenderImpl *)iface;
771 TRACE("(%p/%p)->(%p, %s)\n", This, iface, pGraph, debugstr_w(pName));
773 EnterCriticalSection(&This->csFilter);
775 if (pName)
776 strcpyW(This->filterInfo.achName, pName);
777 else
778 *This->filterInfo.achName = '\0';
779 This->filterInfo.pGraph = pGraph; /* NOTE: do NOT increase ref. count */
781 LeaveCriticalSection(&This->csFilter);
783 return S_OK;
786 static HRESULT WINAPI DSoundRender_QueryVendorInfo(IBaseFilter * iface, LPWSTR *pVendorInfo)
788 DSoundRenderImpl *This = (DSoundRenderImpl *)iface;
789 TRACE("(%p/%p)->(%p)\n", This, iface, pVendorInfo);
790 return E_NOTIMPL;
793 static const IBaseFilterVtbl DSoundRender_Vtbl =
795 DSoundRender_QueryInterface,
796 DSoundRender_AddRef,
797 DSoundRender_Release,
798 DSoundRender_GetClassID,
799 DSoundRender_Stop,
800 DSoundRender_Pause,
801 DSoundRender_Run,
802 DSoundRender_GetState,
803 DSoundRender_SetSyncSource,
804 DSoundRender_GetSyncSource,
805 DSoundRender_EnumPins,
806 DSoundRender_FindPin,
807 DSoundRender_QueryFilterInfo,
808 DSoundRender_JoinFilterGraph,
809 DSoundRender_QueryVendorInfo
812 static HRESULT WINAPI DSoundRender_InputPin_ReceiveConnection(IPin * iface, IPin * pReceivePin, const AM_MEDIA_TYPE * pmt)
814 InputPin *This = (InputPin *)iface;
815 PIN_DIRECTION pindirReceive;
816 DSoundRenderImpl *DSImpl;
817 HRESULT hr = S_OK;
819 TRACE("(%p)->(%p, %p)\n", This, pReceivePin, pmt);
820 dump_AM_MEDIA_TYPE(pmt);
822 EnterCriticalSection(This->pin.pCritSec);
824 DSImpl = (DSoundRenderImpl*)This->pin.pinInfo.pFilter;
825 DSImpl->rtLastStop = -1;
827 if (This->pin.pConnectedTo)
828 hr = VFW_E_ALREADY_CONNECTED;
830 if (SUCCEEDED(hr) && This->pin.fnQueryAccept(This->pin.pUserData, pmt) != S_OK)
831 hr = VFW_E_TYPE_NOT_ACCEPTED;
833 if (SUCCEEDED(hr))
835 IPin_QueryDirection(pReceivePin, &pindirReceive);
837 if (pindirReceive != PINDIR_OUTPUT)
839 ERR("Can't connect from non-output pin\n");
840 hr = VFW_E_INVALID_DIRECTION;
844 if (SUCCEEDED(hr))
846 WAVEFORMATEX *format;
847 DSBUFFERDESC buf_desc;
849 TRACE("MajorType %s\n", debugstr_guid(&pmt->majortype));
850 TRACE("SubType %s\n", debugstr_guid(&pmt->subtype));
851 TRACE("Format %s\n", debugstr_guid(&pmt->formattype));
852 TRACE("Size %d\n", pmt->cbFormat);
854 format = (WAVEFORMATEX*)pmt->pbFormat;
856 DSImpl->buf_size = format->nAvgBytesPerSec;
858 memset(&buf_desc,0,sizeof(DSBUFFERDESC));
859 buf_desc.dwSize = sizeof(DSBUFFERDESC);
860 buf_desc.dwFlags = DSBCAPS_CTRLVOLUME | DSBCAPS_CTRLPAN |
861 DSBCAPS_CTRLFREQUENCY |
862 DSBCAPS_GETCURRENTPOSITION2;
863 buf_desc.dwBufferBytes = DSImpl->buf_size;
864 buf_desc.lpwfxFormat = format;
865 hr = IDirectSound_CreateSoundBuffer(DSImpl->dsound, &buf_desc, &DSImpl->dsbuffer, NULL);
866 if (FAILED(hr))
867 ERR("Can't create sound buffer (%x)\n", hr);
870 if (SUCCEEDED(hr))
872 hr = IDirectSoundBuffer_SetVolume(DSImpl->dsbuffer, DSImpl->volume);
873 if (FAILED(hr))
874 ERR("Can't set volume to %ld (%x)\n", DSImpl->volume, hr);
876 hr = IDirectSoundBuffer_SetPan(DSImpl->dsbuffer, DSImpl->pan);
877 if (FAILED(hr))
878 ERR("Can't set pan to %ld (%x)\n", DSImpl->pan, hr);
880 DSImpl->write_pos = 0;
881 hr = S_OK;
884 if (SUCCEEDED(hr))
886 CopyMediaType(&This->pin.mtCurrent, pmt);
887 This->pin.pConnectedTo = pReceivePin;
888 IPin_AddRef(pReceivePin);
890 else if (hr != VFW_E_ALREADY_CONNECTED)
892 if (DSImpl->dsbuffer)
893 IDirectSoundBuffer_Release(DSImpl->dsbuffer);
894 DSImpl->dsbuffer = NULL;
897 LeaveCriticalSection(This->pin.pCritSec);
899 return hr;
902 static HRESULT WINAPI DSoundRender_InputPin_Disconnect(IPin * iface)
904 IPinImpl *This = (IPinImpl*)iface;
905 DSoundRenderImpl *DSImpl;
907 TRACE("(%p)->()\n", iface);
909 DSImpl = (DSoundRenderImpl*)This->pinInfo.pFilter;
910 if (DSImpl->dsbuffer)
911 IDirectSoundBuffer_Release(DSImpl->dsbuffer);
912 DSImpl->dsbuffer = NULL;
914 return IPinImpl_Disconnect(iface);
917 static HRESULT WINAPI DSoundRender_InputPin_EndOfStream(IPin * iface)
919 InputPin* This = (InputPin*)iface;
920 DSoundRenderImpl *me = (DSoundRenderImpl*)This->pin.pinInfo.pFilter;
921 IMediaEventSink* pEventSink;
922 HRESULT hr;
924 EnterCriticalSection(This->pin.pCritSec);
926 TRACE("(%p/%p)->()\n", This, iface);
927 hr = InputPin_EndOfStream(iface);
928 if (hr != S_OK)
930 ERR("%08x\n", hr);
931 LeaveCriticalSection(This->pin.pCritSec);
932 return hr;
935 hr = IFilterGraph_QueryInterface(me->filterInfo.pGraph, &IID_IMediaEventSink, (LPVOID*)&pEventSink);
936 if (SUCCEEDED(hr))
938 BYTE * silence;
940 silence = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, me->buf_size);
941 if (silence)
943 memset(silence, 0, me->buf_size);
944 DSoundRender_SendSampleData((DSoundRenderImpl*)This->pin.pinInfo.pFilter, silence, me->buf_size);
945 HeapFree(GetProcessHeap(), 0, silence);
948 hr = IMediaEventSink_Notify(pEventSink, EC_COMPLETE, S_OK, 0);
949 IMediaEventSink_Release(pEventSink);
951 LeaveCriticalSection(This->pin.pCritSec);
953 return hr;
956 static HRESULT WINAPI DSoundRender_InputPin_BeginFlush(IPin * iface)
958 InputPin *This = (InputPin *)iface;
959 DSoundRenderImpl *pFilter = (DSoundRenderImpl *)This->pin.pinInfo.pFilter;
960 HRESULT hr;
961 LPBYTE buffer;
962 DWORD size;
964 TRACE("\n");
966 EnterCriticalSection(This->pin.pCritSec);
967 hr = InputPin_BeginFlush(iface);
969 if (pFilter->dsbuffer)
971 IDirectSoundBuffer_Stop(pFilter->dsbuffer);
973 /* Force a reset */
974 IDirectSoundBuffer_SetCurrentPosition(pFilter->dsbuffer, 0);
975 pFilter->write_pos = pFilter->last_play_pos = 0;
976 ++pFilter->play_loops;
977 pFilter->write_loops = pFilter->play_loops;
979 IDirectSoundBuffer_Lock(pFilter->dsbuffer, 0, 0, (LPVOID *)&buffer, &size, NULL, NULL, DSBLOCK_ENTIREBUFFER);
980 memset(buffer, 0, size);
981 IDirectSoundBuffer_Unlock(pFilter->dsbuffer, buffer, size, NULL, 0);
984 if (pFilter->state == State_Paused)
985 SetEvent(pFilter->blocked);
986 LeaveCriticalSection(This->pin.pCritSec);
988 return hr;
991 static HRESULT WINAPI DSoundRender_InputPin_EndFlush(IPin * iface)
993 InputPin *This = (InputPin *)iface;
994 DSoundRenderImpl *pFilter = (DSoundRenderImpl *)This->pin.pinInfo.pFilter;
995 HRESULT hr;
997 TRACE("\n");
999 EnterCriticalSection(This->pin.pCritSec);
1000 hr = InputPin_EndFlush(iface);
1002 if (pFilter->state == State_Paused)
1003 SetEvent(pFilter->blocked);
1004 LeaveCriticalSection(This->pin.pCritSec);
1006 return hr;
1009 static const IPinVtbl DSoundRender_InputPin_Vtbl =
1011 InputPin_QueryInterface,
1012 IPinImpl_AddRef,
1013 InputPin_Release,
1014 InputPin_Connect,
1015 DSoundRender_InputPin_ReceiveConnection,
1016 DSoundRender_InputPin_Disconnect,
1017 IPinImpl_ConnectedTo,
1018 IPinImpl_ConnectionMediaType,
1019 IPinImpl_QueryPinInfo,
1020 IPinImpl_QueryDirection,
1021 IPinImpl_QueryId,
1022 IPinImpl_QueryAccept,
1023 IPinImpl_EnumMediaTypes,
1024 IPinImpl_QueryInternalConnections,
1025 DSoundRender_InputPin_EndOfStream,
1026 DSoundRender_InputPin_BeginFlush,
1027 DSoundRender_InputPin_EndFlush,
1028 InputPin_NewSegment
1031 /*** IUnknown methods ***/
1032 static HRESULT WINAPI Basicaudio_QueryInterface(IBasicAudio *iface,
1033 REFIID riid,
1034 LPVOID*ppvObj) {
1035 ICOM_THIS_MULTI(DSoundRenderImpl, IBasicAudio_vtbl, iface);
1037 TRACE("(%p/%p)->(%s (%p), %p)\n", This, iface, debugstr_guid(riid), riid, ppvObj);
1039 return DSoundRender_QueryInterface((IBaseFilter*)This, riid, ppvObj);
1042 static ULONG WINAPI Basicaudio_AddRef(IBasicAudio *iface) {
1043 ICOM_THIS_MULTI(DSoundRenderImpl, IBasicAudio_vtbl, iface);
1045 TRACE("(%p/%p)->()\n", This, iface);
1047 return DSoundRender_AddRef((IBaseFilter*)This);
1050 static ULONG WINAPI Basicaudio_Release(IBasicAudio *iface) {
1051 ICOM_THIS_MULTI(DSoundRenderImpl, IBasicAudio_vtbl, iface);
1053 TRACE("(%p/%p)->()\n", This, iface);
1055 return DSoundRender_Release((IBaseFilter*)This);
1058 /*** IDispatch methods ***/
1059 static HRESULT WINAPI Basicaudio_GetTypeInfoCount(IBasicAudio *iface,
1060 UINT*pctinfo) {
1061 ICOM_THIS_MULTI(DSoundRenderImpl, IBasicAudio_vtbl, iface);
1063 TRACE("(%p/%p)->(%p): stub !!!\n", This, iface, pctinfo);
1065 return S_OK;
1068 static HRESULT WINAPI Basicaudio_GetTypeInfo(IBasicAudio *iface,
1069 UINT iTInfo,
1070 LCID lcid,
1071 ITypeInfo**ppTInfo) {
1072 ICOM_THIS_MULTI(DSoundRenderImpl, IBasicAudio_vtbl, iface);
1074 TRACE("(%p/%p)->(%d, %d, %p): stub !!!\n", This, iface, iTInfo, lcid, ppTInfo);
1076 return S_OK;
1079 static HRESULT WINAPI Basicaudio_GetIDsOfNames(IBasicAudio *iface,
1080 REFIID riid,
1081 LPOLESTR*rgszNames,
1082 UINT cNames,
1083 LCID lcid,
1084 DISPID*rgDispId) {
1085 ICOM_THIS_MULTI(DSoundRenderImpl, IBasicAudio_vtbl, iface);
1087 TRACE("(%p/%p)->(%s (%p), %p, %d, %d, %p): stub !!!\n", This, iface, debugstr_guid(riid), riid, rgszNames, cNames, lcid, rgDispId);
1089 return S_OK;
1092 static HRESULT WINAPI Basicaudio_Invoke(IBasicAudio *iface,
1093 DISPID dispIdMember,
1094 REFIID riid,
1095 LCID lcid,
1096 WORD wFlags,
1097 DISPPARAMS*pDispParams,
1098 VARIANT*pVarResult,
1099 EXCEPINFO*pExepInfo,
1100 UINT*puArgErr) {
1101 ICOM_THIS_MULTI(DSoundRenderImpl, IBasicAudio_vtbl, iface);
1103 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);
1105 return S_OK;
1108 /*** IBasicAudio methods ***/
1109 static HRESULT WINAPI Basicaudio_put_Volume(IBasicAudio *iface,
1110 LONG lVolume) {
1111 ICOM_THIS_MULTI(DSoundRenderImpl, IBasicAudio_vtbl, iface);
1113 TRACE("(%p/%p)->(%d)\n", This, iface, lVolume);
1115 if (lVolume > DSBVOLUME_MAX || lVolume < DSBVOLUME_MIN)
1116 return E_INVALIDARG;
1118 if (This->dsbuffer) {
1119 if (FAILED(IDirectSoundBuffer_SetVolume(This->dsbuffer, lVolume)))
1120 return E_FAIL;
1123 This->volume = lVolume;
1124 return S_OK;
1127 static HRESULT WINAPI Basicaudio_get_Volume(IBasicAudio *iface,
1128 LONG *plVolume) {
1129 ICOM_THIS_MULTI(DSoundRenderImpl, IBasicAudio_vtbl, iface);
1131 TRACE("(%p/%p)->(%p)\n", This, iface, plVolume);
1133 if (!plVolume)
1134 return E_POINTER;
1136 *plVolume = This->volume;
1137 return S_OK;
1140 static HRESULT WINAPI Basicaudio_put_Balance(IBasicAudio *iface,
1141 LONG lBalance) {
1142 ICOM_THIS_MULTI(DSoundRenderImpl, IBasicAudio_vtbl, iface);
1144 TRACE("(%p/%p)->(%d)\n", This, iface, lBalance);
1146 if (lBalance < DSBPAN_LEFT || lBalance > DSBPAN_RIGHT)
1147 return E_INVALIDARG;
1149 if (This->dsbuffer) {
1150 if (FAILED(IDirectSoundBuffer_SetPan(This->dsbuffer, lBalance)))
1151 return E_FAIL;
1154 This->pan = lBalance;
1155 return S_OK;
1158 static HRESULT WINAPI Basicaudio_get_Balance(IBasicAudio *iface,
1159 LONG *plBalance) {
1160 ICOM_THIS_MULTI(DSoundRenderImpl, IBasicAudio_vtbl, iface);
1162 TRACE("(%p/%p)->(%p)\n", This, iface, plBalance);
1164 if (!plBalance)
1165 return E_POINTER;
1167 *plBalance = This->pan;
1168 return S_OK;
1171 static const IBasicAudioVtbl IBasicAudio_Vtbl =
1173 Basicaudio_QueryInterface,
1174 Basicaudio_AddRef,
1175 Basicaudio_Release,
1176 Basicaudio_GetTypeInfoCount,
1177 Basicaudio_GetTypeInfo,
1178 Basicaudio_GetIDsOfNames,
1179 Basicaudio_Invoke,
1180 Basicaudio_put_Volume,
1181 Basicaudio_get_Volume,
1182 Basicaudio_put_Balance,
1183 Basicaudio_get_Balance
1187 /*** IUnknown methods ***/
1188 static HRESULT WINAPI ReferenceClock_QueryInterface(IReferenceClock *iface,
1189 REFIID riid,
1190 LPVOID*ppvObj)
1192 ICOM_THIS_MULTI(DSoundRenderImpl, IReferenceClock_vtbl, iface);
1194 TRACE("(%p/%p)->(%s (%p), %p)\n", This, iface, debugstr_guid(riid), riid, ppvObj);
1196 return DSoundRender_QueryInterface((IBaseFilter*)This, riid, ppvObj);
1199 static ULONG WINAPI ReferenceClock_AddRef(IReferenceClock *iface)
1201 ICOM_THIS_MULTI(DSoundRenderImpl, IReferenceClock_vtbl, iface);
1203 TRACE("(%p/%p)->()\n", This, iface);
1205 return DSoundRender_AddRef((IBaseFilter*)This);
1208 static ULONG WINAPI ReferenceClock_Release(IReferenceClock *iface)
1210 ICOM_THIS_MULTI(DSoundRenderImpl, IReferenceClock_vtbl, iface);
1212 TRACE("(%p/%p)->()\n", This, iface);
1214 return DSoundRender_Release((IBaseFilter*)This);
1217 /*** IReferenceClock methods ***/
1218 static HRESULT WINAPI ReferenceClock_GetTime(IReferenceClock *iface,
1219 REFERENCE_TIME *pTime)
1221 ICOM_THIS_MULTI(DSoundRenderImpl, IReferenceClock_vtbl, iface);
1222 HRESULT hr = E_FAIL;
1223 DWORD play_pos;
1225 TRACE("(%p/%p)->(%p)\n", This, iface, pTime);
1227 if (This->dsbuffer)
1228 hr = DSoundRender_GetPos(This, &play_pos, pTime);
1229 if (FAILED(hr))
1230 ERR("Could not get reference time (%x)!\n", hr);
1232 return hr;
1235 static HRESULT WINAPI ReferenceClock_AdviseTime(IReferenceClock *iface,
1236 REFERENCE_TIME rtBaseTime,
1237 REFERENCE_TIME rtStreamTime,
1238 HEVENT hEvent,
1239 DWORD_PTR *pdwAdviseCookie)
1241 ICOM_THIS_MULTI(DSoundRenderImpl, IReferenceClock_vtbl, iface);
1243 FIXME("(%p/%p)->(%s, %s, %p, %p): stub!\n", This, iface, wine_dbgstr_longlong(rtBaseTime), wine_dbgstr_longlong(rtStreamTime), (void*)hEvent, pdwAdviseCookie);
1245 return E_NOTIMPL;
1248 static HRESULT WINAPI ReferenceClock_AdvisePeriodic(IReferenceClock *iface,
1249 REFERENCE_TIME rtBaseTime,
1250 REFERENCE_TIME rtStreamTime,
1251 HSEMAPHORE hSemaphore,
1252 DWORD_PTR *pdwAdviseCookie)
1254 ICOM_THIS_MULTI(DSoundRenderImpl, IReferenceClock_vtbl, iface);
1256 FIXME("(%p/%p)->(%s, %s, %p, %p): stub!\n", This, iface, wine_dbgstr_longlong(rtBaseTime), wine_dbgstr_longlong(rtStreamTime), (void*)hSemaphore, pdwAdviseCookie);
1258 return E_NOTIMPL;
1261 static HRESULT WINAPI ReferenceClock_Unadvise(IReferenceClock *iface,
1262 DWORD_PTR dwAdviseCookie)
1264 ICOM_THIS_MULTI(DSoundRenderImpl, IReferenceClock_vtbl, iface);
1266 FIXME("(%p/%p)->(%p): stub!\n", This, iface, (void*)dwAdviseCookie);
1268 return S_FALSE;
1271 static const IReferenceClockVtbl IReferenceClock_Vtbl =
1273 ReferenceClock_QueryInterface,
1274 ReferenceClock_AddRef,
1275 ReferenceClock_Release,
1276 ReferenceClock_GetTime,
1277 ReferenceClock_AdviseTime,
1278 ReferenceClock_AdvisePeriodic,
1279 ReferenceClock_Unadvise
1282 static inline DSoundRenderImpl *impl_from_IMediaSeeking( IMediaSeeking *iface )
1284 return (DSoundRenderImpl *)((char*)iface - FIELD_OFFSET(DSoundRenderImpl, mediaSeeking.lpVtbl));
1287 static HRESULT WINAPI sound_seek_QueryInterface(IMediaSeeking * iface, REFIID riid, LPVOID * ppv)
1289 DSoundRenderImpl *This = impl_from_IMediaSeeking(iface);
1291 return IUnknown_QueryInterface((IUnknown *)This, riid, ppv);
1294 static ULONG WINAPI sound_seek_AddRef(IMediaSeeking * iface)
1296 DSoundRenderImpl *This = impl_from_IMediaSeeking(iface);
1298 return IUnknown_AddRef((IUnknown *)This);
1301 static ULONG WINAPI sound_seek_Release(IMediaSeeking * iface)
1303 DSoundRenderImpl *This = impl_from_IMediaSeeking(iface);
1305 return IUnknown_Release((IUnknown *)This);
1308 static const IMediaSeekingVtbl IMediaSeeking_Vtbl =
1310 sound_seek_QueryInterface,
1311 sound_seek_AddRef,
1312 sound_seek_Release,
1313 MediaSeekingImpl_GetCapabilities,
1314 MediaSeekingImpl_CheckCapabilities,
1315 MediaSeekingImpl_IsFormatSupported,
1316 MediaSeekingImpl_QueryPreferredFormat,
1317 MediaSeekingImpl_GetTimeFormat,
1318 MediaSeekingImpl_IsUsingTimeFormat,
1319 MediaSeekingImpl_SetTimeFormat,
1320 MediaSeekingImpl_GetDuration,
1321 MediaSeekingImpl_GetStopPosition,
1322 MediaSeekingImpl_GetCurrentPosition,
1323 MediaSeekingImpl_ConvertTimeFormat,
1324 MediaSeekingImpl_SetPositions,
1325 MediaSeekingImpl_GetPositions,
1326 MediaSeekingImpl_GetAvailable,
1327 MediaSeekingImpl_SetRate,
1328 MediaSeekingImpl_GetRate,
1329 MediaSeekingImpl_GetPreroll