2004-08-24 04:28:35 +02:00
|
|
|
/*
|
|
|
|
* Direct Sound Audio Renderer
|
|
|
|
*
|
|
|
|
* Copyright 2004 Christian Costa
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2004-08-24 04:28:35 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include "quartz_private.h"
|
|
|
|
#include "control_private.h"
|
|
|
|
#include "pin.h"
|
|
|
|
|
|
|
|
#include "uuids.h"
|
|
|
|
#include "mmreg.h"
|
|
|
|
#include "vfwmsgs.h"
|
|
|
|
#include "fourcc.h"
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "dshow.h"
|
|
|
|
#include "evcode.h"
|
|
|
|
#include "strmif.h"
|
|
|
|
#include "dsound.h"
|
|
|
|
|
|
|
|
#include "wine/unicode.h"
|
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(quartz);
|
|
|
|
|
|
|
|
static const WCHAR wcsInputPinName[] = {'i','n','p','u','t',' ','p','i','n',0};
|
|
|
|
|
|
|
|
static const IBaseFilterVtbl DSoundRender_Vtbl;
|
|
|
|
static const IPinVtbl DSoundRender_InputPin_Vtbl;
|
|
|
|
static const IMemInputPinVtbl MemInputPin_Vtbl;
|
|
|
|
static const IBasicAudioVtbl IBasicAudio_Vtbl;
|
|
|
|
|
|
|
|
typedef struct DSoundRenderImpl
|
|
|
|
{
|
|
|
|
const IBaseFilterVtbl * lpVtbl;
|
|
|
|
const IBasicAudioVtbl *IBasicAudio_vtbl;
|
|
|
|
|
2005-07-12 21:21:36 +02:00
|
|
|
LONG refCount;
|
2004-08-24 04:28:35 +02:00
|
|
|
CRITICAL_SECTION csFilter;
|
|
|
|
FILTER_STATE state;
|
|
|
|
REFERENCE_TIME rtStreamStart;
|
|
|
|
IReferenceClock * pClock;
|
|
|
|
FILTER_INFO filterInfo;
|
|
|
|
|
|
|
|
InputPin * pInputPin;
|
|
|
|
IPin ** ppPins;
|
|
|
|
|
|
|
|
LPDIRECTSOUND dsound;
|
|
|
|
LPDIRECTSOUNDBUFFER dsbuffer;
|
|
|
|
DWORD write_pos;
|
2005-04-25 12:49:22 +02:00
|
|
|
BOOL init;
|
2007-03-26 05:13:53 +02:00
|
|
|
|
|
|
|
long volume;
|
|
|
|
long pan;
|
2004-08-24 04:28:35 +02:00
|
|
|
} DSoundRenderImpl;
|
|
|
|
|
|
|
|
static HRESULT DSoundRender_InputPin_Construct(const PIN_INFO * pPinInfo, SAMPLEPROC pSampleProc, LPVOID pUserData, QUERYACCEPTPROC pQueryAccept, LPCRITICAL_SECTION pCritSec, IPin ** ppPin)
|
|
|
|
{
|
|
|
|
InputPin * pPinImpl;
|
|
|
|
|
|
|
|
*ppPin = NULL;
|
|
|
|
|
|
|
|
if (pPinInfo->dir != PINDIR_INPUT)
|
|
|
|
{
|
|
|
|
ERR("Pin direction(%x) != PINDIR_INPUT\n", pPinInfo->dir);
|
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
|
|
|
|
|
|
|
pPinImpl = CoTaskMemAlloc(sizeof(*pPinImpl));
|
|
|
|
|
|
|
|
if (!pPinImpl)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
if (SUCCEEDED(InputPin_Init(pPinInfo, pSampleProc, pUserData, pQueryAccept, pCritSec, pPinImpl)))
|
|
|
|
{
|
|
|
|
pPinImpl->pin.lpVtbl = &DSoundRender_InputPin_Vtbl;
|
|
|
|
pPinImpl->lpVtblMemInput = &MemInputPin_Vtbl;
|
|
|
|
|
|
|
|
*ppPin = (IPin *)(&pPinImpl->pin.lpVtbl);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#define DSBUFFERSIZE 8192
|
|
|
|
|
|
|
|
static HRESULT DSoundRender_CreateSoundBuffer(IBaseFilter * iface)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
WAVEFORMATEX wav_fmt;
|
|
|
|
AM_MEDIA_TYPE amt;
|
|
|
|
WAVEFORMATEX* format;
|
|
|
|
DSBUFFERDESC buf_desc;
|
2004-09-08 03:50:37 +02:00
|
|
|
DSoundRenderImpl *This = (DSoundRenderImpl *)iface;
|
2004-08-24 04:28:35 +02:00
|
|
|
|
|
|
|
hr = IPin_ConnectionMediaType(This->ppPins[0], &amt);
|
|
|
|
if (FAILED(hr)) {
|
2004-08-26 02:31:20 +02:00
|
|
|
ERR("Unable to retrieve media type\n");
|
2004-08-24 04:28:35 +02:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("MajorType %s\n", debugstr_guid(&amt.majortype));
|
|
|
|
TRACE("SubType %s\n", debugstr_guid(&amt.subtype));
|
|
|
|
TRACE("Format %s\n", debugstr_guid(&amt.formattype));
|
2006-10-12 20:57:23 +02:00
|
|
|
TRACE("Size %d\n", amt.cbFormat);
|
2004-08-24 04:28:35 +02:00
|
|
|
|
|
|
|
dump_AM_MEDIA_TYPE(&amt);
|
|
|
|
|
|
|
|
format = (WAVEFORMATEX*)amt.pbFormat;
|
|
|
|
TRACE("wFormatTag = %x %x\n", format->wFormatTag, WAVE_FORMAT_PCM);
|
|
|
|
TRACE("nChannels = %d\n", format->nChannels);
|
2006-10-12 20:57:23 +02:00
|
|
|
TRACE("nSamplesPerSec = %u\n", format->nSamplesPerSec);
|
|
|
|
TRACE("nAvgBytesPerSec = %u\n", format->nAvgBytesPerSec);
|
2004-08-24 04:28:35 +02:00
|
|
|
TRACE("nBlockAlign = %d\n", format->nBlockAlign);
|
|
|
|
TRACE("wBitsPerSample = %d\n", format->wBitsPerSample);
|
|
|
|
TRACE("cbSize = %d\n", format->cbSize);
|
|
|
|
|
|
|
|
hr = DirectSoundCreate(NULL, &This->dsound, NULL);
|
|
|
|
if (FAILED(hr)) {
|
|
|
|
ERR("Cannot create Direct Sound object\n");
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
wav_fmt = *format;
|
|
|
|
wav_fmt.cbSize = 0;
|
|
|
|
|
|
|
|
memset(&buf_desc,0,sizeof(DSBUFFERDESC));
|
|
|
|
buf_desc.dwSize = sizeof(DSBUFFERDESC);
|
2007-03-26 05:13:53 +02:00
|
|
|
buf_desc.dwFlags = DSBCAPS_CTRLVOLUME | DSBCAPS_CTRLPAN | DSBCAPS_CTRLFREQUENCY;
|
2004-08-24 04:28:35 +02:00
|
|
|
buf_desc.dwBufferBytes = DSBUFFERSIZE;
|
|
|
|
buf_desc.lpwfxFormat = &wav_fmt;
|
|
|
|
hr = IDirectSound_CreateSoundBuffer(This->dsound, &buf_desc, &This->dsbuffer, NULL);
|
|
|
|
if (FAILED(hr)) {
|
|
|
|
ERR("Can't create sound buffer !\n");
|
2005-04-25 12:49:22 +02:00
|
|
|
IDirectSound_Release(This->dsound);
|
2004-08-24 04:28:35 +02:00
|
|
|
return hr;
|
|
|
|
}
|
2007-03-26 05:13:53 +02:00
|
|
|
|
|
|
|
hr = IDirectSoundBuffer_SetVolume(This->dsbuffer, This->volume);
|
|
|
|
if (FAILED(hr))
|
|
|
|
ERR("Can't set volume to %ld (%x)!\n", This->volume, hr);
|
|
|
|
|
|
|
|
hr = IDirectSoundBuffer_SetPan(This->dsbuffer, This->pan);
|
|
|
|
if (FAILED(hr))
|
|
|
|
ERR("Can't set pan to %ld (%x)!\n", This->pan, hr);
|
|
|
|
|
2007-03-25 01:43:57 +01:00
|
|
|
hr = IDirectSoundBuffer_Play(This->dsbuffer, 0, 0, DSBPLAY_LOOPING);
|
|
|
|
if (FAILED(hr)) {
|
|
|
|
ERR("Can't start sound buffer (%x)!\n", hr);
|
|
|
|
IDirectSoundBuffer_Release(This->dsbuffer);
|
|
|
|
IDirectSound_Release(This->dsound);
|
|
|
|
return hr;
|
|
|
|
}
|
2004-08-24 04:28:35 +02:00
|
|
|
|
|
|
|
This->write_pos = 0;
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2005-04-25 12:49:22 +02:00
|
|
|
static HRESULT DSoundRender_SendSampleData(DSoundRenderImpl* This, LPBYTE data, DWORD size)
|
2004-08-24 04:28:35 +02:00
|
|
|
{
|
2005-04-25 12:49:22 +02:00
|
|
|
HRESULT hr;
|
2004-08-24 04:28:35 +02:00
|
|
|
LPBYTE lpbuf1 = NULL;
|
|
|
|
LPBYTE lpbuf2 = NULL;
|
|
|
|
DWORD dwsize1 = 0;
|
|
|
|
DWORD dwsize2 = 0;
|
|
|
|
DWORD size2;
|
|
|
|
DWORD play_pos,buf_free;
|
|
|
|
|
2007-03-25 01:43:57 +01:00
|
|
|
do {
|
2005-04-25 12:49:22 +02:00
|
|
|
hr = IDirectSoundBuffer_GetCurrentPosition(This->dsbuffer, &play_pos, NULL);
|
|
|
|
if (hr != DS_OK)
|
|
|
|
{
|
2006-10-12 20:57:23 +02:00
|
|
|
ERR("Error GetCurrentPosition: %x\n", hr);
|
2005-04-25 12:49:22 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (This->write_pos < play_pos)
|
|
|
|
buf_free = play_pos-This->write_pos;
|
2004-08-24 04:28:35 +02:00
|
|
|
else
|
2005-04-25 12:49:22 +02:00
|
|
|
buf_free = DSBUFFERSIZE - This->write_pos + play_pos;
|
2004-08-24 04:28:35 +02:00
|
|
|
|
2006-08-18 18:38:38 +02:00
|
|
|
/* This situation is ambiguous; Assume full when playing */
|
2007-03-25 01:43:57 +01:00
|
|
|
if(buf_free == DSBUFFERSIZE)
|
2006-08-18 18:38:38 +02:00
|
|
|
{
|
|
|
|
Sleep(10);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2005-04-25 12:49:22 +02:00
|
|
|
size2 = min(buf_free, size);
|
2007-03-08 14:48:45 +01:00
|
|
|
hr = IDirectSoundBuffer_Lock(This->dsbuffer, This->write_pos, size2, (LPVOID *)&lpbuf1, &dwsize1, (LPVOID *)&lpbuf2, &dwsize2, 0);
|
2005-04-25 12:49:22 +02:00
|
|
|
if (hr != DS_OK) {
|
2006-10-12 20:57:23 +02:00
|
|
|
ERR("Unable to lock sound buffer! (%x)\n", hr);
|
2005-04-25 12:49:22 +02:00
|
|
|
break;
|
2004-08-24 04:28:35 +02:00
|
|
|
}
|
2006-10-12 20:57:23 +02:00
|
|
|
/* TRACE("write_pos=%d, size=%d, sz1=%d, sz2=%d\n", This->write_pos, size2, dwsize1, dwsize2); */
|
2004-08-24 04:28:35 +02:00
|
|
|
|
|
|
|
memcpy(lpbuf1, data, dwsize1);
|
2005-04-25 12:49:22 +02:00
|
|
|
if (dwsize2)
|
2004-08-24 04:28:35 +02:00
|
|
|
memcpy(lpbuf2, data + dwsize1, dwsize2);
|
2005-04-25 12:49:22 +02:00
|
|
|
|
|
|
|
hr = IDirectSoundBuffer_Unlock(This->dsbuffer, lpbuf1, dwsize1, lpbuf2, dwsize2);
|
|
|
|
if (hr != DS_OK)
|
2006-10-12 20:57:23 +02:00
|
|
|
ERR("Unable to unlock sound buffer! (%x)\n", hr);
|
2007-03-25 01:43:57 +01:00
|
|
|
|
2005-04-25 12:49:22 +02:00
|
|
|
size -= dwsize1 + dwsize2;
|
|
|
|
data += dwsize1 + dwsize2;
|
|
|
|
This->write_pos = (This->write_pos + dwsize1 + dwsize2) % DSBUFFERSIZE;
|
2004-08-24 04:28:35 +02:00
|
|
|
|
2005-04-25 12:49:22 +02:00
|
|
|
if (!size)
|
|
|
|
break;
|
2004-08-24 04:28:35 +02:00
|
|
|
Sleep(10);
|
2007-03-25 01:43:57 +01:00
|
|
|
} while (This->state == State_Running);
|
2005-04-25 12:49:22 +02:00
|
|
|
|
|
|
|
return hr;
|
2004-08-24 04:28:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT DSoundRender_Sample(LPVOID iface, IMediaSample * pSample)
|
|
|
|
{
|
2004-09-08 03:50:37 +02:00
|
|
|
DSoundRenderImpl *This = (DSoundRenderImpl *)iface;
|
2004-08-24 04:28:35 +02:00
|
|
|
LPBYTE pbSrcStream = NULL;
|
|
|
|
long cbSrcStream = 0;
|
|
|
|
REFERENCE_TIME tStart, tStop;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("%p %p\n", iface, pSample);
|
2007-03-10 13:09:43 +01:00
|
|
|
|
|
|
|
if (This->state != State_Running)
|
|
|
|
return VFW_E_WRONG_STATE;
|
2004-08-24 04:28:35 +02:00
|
|
|
|
|
|
|
hr = IMediaSample_GetPointer(pSample, &pbSrcStream);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
2006-10-12 20:57:23 +02:00
|
|
|
ERR("Cannot get pointer to sample data (%x)\n", hr);
|
2004-08-24 04:28:35 +02:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = IMediaSample_GetTime(pSample, &tStart, &tStop);
|
|
|
|
if (FAILED(hr))
|
2006-10-12 20:57:23 +02:00
|
|
|
ERR("Cannot get sample time (%x)\n", hr);
|
2004-08-24 04:28:35 +02:00
|
|
|
|
|
|
|
cbSrcStream = IMediaSample_GetActualDataLength(pSample);
|
|
|
|
|
|
|
|
TRACE("Sample data ptr = %p, size = %ld\n", pbSrcStream, cbSrcStream);
|
|
|
|
|
|
|
|
#if 0 /* For debugging purpose */
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for(i = 0; i < cbSrcStream; i++)
|
|
|
|
{
|
|
|
|
if ((i!=0) && !(i%16))
|
2005-09-25 17:23:21 +02:00
|
|
|
TRACE("\n");
|
|
|
|
TRACE("%02x ", pbSrcStream[i]);
|
2004-08-24 04:28:35 +02:00
|
|
|
}
|
2005-09-25 17:23:21 +02:00
|
|
|
TRACE("\n");
|
2004-08-24 04:28:35 +02:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (!This->init)
|
|
|
|
{
|
2005-04-25 12:49:22 +02:00
|
|
|
hr = DSoundRender_CreateSoundBuffer(iface);
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
This->init = TRUE;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ERR("Unable to create DSound buffer\n");
|
|
|
|
return hr;
|
|
|
|
}
|
2004-08-24 04:28:35 +02:00
|
|
|
}
|
|
|
|
|
2005-04-25 12:49:22 +02:00
|
|
|
hr = DSoundRender_SendSampleData(This, pbSrcStream, cbSrcStream);
|
|
|
|
|
|
|
|
return hr;
|
2004-08-24 04:28:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT DSoundRender_QueryAccept(LPVOID iface, const AM_MEDIA_TYPE * pmt)
|
|
|
|
{
|
|
|
|
WAVEFORMATEX* format = (WAVEFORMATEX*)pmt->pbFormat;
|
|
|
|
TRACE("wFormatTag = %x %x\n", format->wFormatTag, WAVE_FORMAT_PCM);
|
|
|
|
TRACE("nChannels = %d\n", format->nChannels);
|
2006-10-12 20:57:23 +02:00
|
|
|
TRACE("nSamplesPerSec = %d\n", format->nAvgBytesPerSec);
|
|
|
|
TRACE("nAvgBytesPerSec = %d\n", format->nAvgBytesPerSec);
|
2004-08-24 04:28:35 +02:00
|
|
|
TRACE("nBlockAlign = %d\n", format->nBlockAlign);
|
|
|
|
TRACE("wBitsPerSample = %d\n", format->wBitsPerSample);
|
|
|
|
|
|
|
|
if (IsEqualIID(&pmt->majortype, &MEDIATYPE_Audio) && IsEqualIID(&pmt->subtype, &MEDIASUBTYPE_PCM))
|
|
|
|
return S_OK;
|
|
|
|
return S_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT DSoundRender_create(IUnknown * pUnkOuter, LPVOID * ppv)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
PIN_INFO piInput;
|
|
|
|
DSoundRenderImpl * pDSoundRender;
|
|
|
|
|
|
|
|
TRACE("(%p, %p)\n", pUnkOuter, ppv);
|
|
|
|
|
|
|
|
*ppv = NULL;
|
|
|
|
|
|
|
|
if (pUnkOuter)
|
|
|
|
return CLASS_E_NOAGGREGATION;
|
|
|
|
|
|
|
|
pDSoundRender = CoTaskMemAlloc(sizeof(DSoundRenderImpl));
|
2007-03-09 14:47:37 +01:00
|
|
|
if (!pDSoundRender)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
ZeroMemory(pDSoundRender, sizeof(DSoundRenderImpl));
|
2004-08-24 04:28:35 +02:00
|
|
|
|
|
|
|
pDSoundRender->lpVtbl = &DSoundRender_Vtbl;
|
|
|
|
pDSoundRender->IBasicAudio_vtbl = &IBasicAudio_Vtbl;
|
|
|
|
pDSoundRender->refCount = 1;
|
|
|
|
InitializeCriticalSection(&pDSoundRender->csFilter);
|
2007-03-10 22:10:20 +01:00
|
|
|
pDSoundRender->csFilter.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": DSoundRenderImpl.csFilter");
|
2004-08-24 04:28:35 +02:00
|
|
|
pDSoundRender->state = State_Stopped;
|
|
|
|
|
|
|
|
pDSoundRender->ppPins = CoTaskMemAlloc(1 * sizeof(IPin *));
|
2007-03-09 14:47:37 +01:00
|
|
|
if (!pDSoundRender->ppPins)
|
|
|
|
{
|
2007-03-10 22:10:20 +01:00
|
|
|
pDSoundRender->csFilter.DebugInfo->Spare[0] = 0;
|
2007-03-09 14:47:37 +01:00
|
|
|
DeleteCriticalSection(&pDSoundRender->csFilter);
|
|
|
|
CoTaskMemFree(pDSoundRender);
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
2004-08-24 04:28:35 +02:00
|
|
|
|
|
|
|
/* construct input pin */
|
|
|
|
piInput.dir = PINDIR_INPUT;
|
|
|
|
piInput.pFilter = (IBaseFilter *)pDSoundRender;
|
2005-03-28 16:17:51 +02:00
|
|
|
lstrcpynW(piInput.achName, wcsInputPinName, sizeof(piInput.achName) / sizeof(piInput.achName[0]));
|
2004-08-24 04:28:35 +02:00
|
|
|
hr = DSoundRender_InputPin_Construct(&piInput, DSoundRender_Sample, (LPVOID)pDSoundRender, DSoundRender_QueryAccept, &pDSoundRender->csFilter, (IPin **)&pDSoundRender->pInputPin);
|
|
|
|
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
pDSoundRender->ppPins[0] = (IPin *)pDSoundRender->pInputPin;
|
|
|
|
*ppv = (LPVOID)pDSoundRender;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CoTaskMemFree(pDSoundRender->ppPins);
|
2007-03-10 22:10:20 +01:00
|
|
|
pDSoundRender->csFilter.DebugInfo->Spare[0] = 0;
|
2004-08-24 04:28:35 +02:00
|
|
|
DeleteCriticalSection(&pDSoundRender->csFilter);
|
|
|
|
CoTaskMemFree(pDSoundRender);
|
|
|
|
}
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI DSoundRender_QueryInterface(IBaseFilter * iface, REFIID riid, LPVOID * ppv)
|
|
|
|
{
|
2004-09-08 03:50:37 +02:00
|
|
|
DSoundRenderImpl *This = (DSoundRenderImpl *)iface;
|
2004-08-24 04:28:35 +02:00
|
|
|
TRACE("(%p, %p)->(%s, %p)\n", This, iface, qzdebugstr_guid(riid), ppv);
|
|
|
|
|
|
|
|
*ppv = NULL;
|
|
|
|
|
|
|
|
if (IsEqualIID(riid, &IID_IUnknown))
|
|
|
|
*ppv = (LPVOID)This;
|
|
|
|
else if (IsEqualIID(riid, &IID_IPersist))
|
|
|
|
*ppv = (LPVOID)This;
|
|
|
|
else if (IsEqualIID(riid, &IID_IMediaFilter))
|
|
|
|
*ppv = (LPVOID)This;
|
|
|
|
else if (IsEqualIID(riid, &IID_IBaseFilter))
|
|
|
|
*ppv = (LPVOID)This;
|
2007-02-18 08:16:36 +01:00
|
|
|
else if (IsEqualIID(riid, &IID_IBasicAudio))
|
2004-08-24 04:28:35 +02:00
|
|
|
*ppv = (LPVOID)&(This->IBasicAudio_vtbl);
|
|
|
|
|
|
|
|
if (*ppv)
|
|
|
|
{
|
|
|
|
IUnknown_AddRef((IUnknown *)(*ppv));
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
FIXME("No interface for %s!\n", qzdebugstr_guid(riid));
|
|
|
|
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI DSoundRender_AddRef(IBaseFilter * iface)
|
|
|
|
{
|
2004-09-08 03:50:37 +02:00
|
|
|
DSoundRenderImpl *This = (DSoundRenderImpl *)iface;
|
2005-01-06 20:36:47 +01:00
|
|
|
ULONG refCount = InterlockedIncrement(&This->refCount);
|
2004-12-27 18:15:58 +01:00
|
|
|
|
2006-10-12 20:57:23 +02:00
|
|
|
TRACE("(%p/%p)->() AddRef from %d\n", This, iface, refCount - 1);
|
2004-12-27 18:15:58 +01:00
|
|
|
|
2005-01-06 20:36:47 +01:00
|
|
|
return refCount;
|
2004-08-24 04:28:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI DSoundRender_Release(IBaseFilter * iface)
|
|
|
|
{
|
2004-09-08 03:50:37 +02:00
|
|
|
DSoundRenderImpl *This = (DSoundRenderImpl *)iface;
|
2005-01-06 20:36:47 +01:00
|
|
|
ULONG refCount = InterlockedDecrement(&This->refCount);
|
2004-12-27 18:15:58 +01:00
|
|
|
|
2007-03-05 15:11:37 +01:00
|
|
|
TRACE("(%p)->() Release from %d\n", This, refCount + 1);
|
2004-12-27 18:15:58 +01:00
|
|
|
|
2005-01-06 20:36:47 +01:00
|
|
|
if (!refCount)
|
2004-08-24 04:28:35 +02:00
|
|
|
{
|
2007-03-13 18:47:47 +01:00
|
|
|
IPin *pConnectedTo;
|
|
|
|
|
2007-03-10 22:10:20 +01:00
|
|
|
if (This->pClock)
|
2004-08-24 04:28:35 +02:00
|
|
|
IReferenceClock_Release(This->pClock);
|
2007-02-18 18:59:41 +01:00
|
|
|
|
|
|
|
if (This->dsbuffer)
|
|
|
|
IDirectSoundBuffer_Release(This->dsbuffer);
|
|
|
|
This->dsbuffer = NULL;
|
|
|
|
if (This->dsound)
|
|
|
|
IDirectSound_Release(This->dsound);
|
|
|
|
This->dsound = NULL;
|
2004-08-24 04:28:35 +02:00
|
|
|
|
2007-03-13 18:47:47 +01:00
|
|
|
if (SUCCEEDED(IPin_ConnectedTo(This->ppPins[0], &pConnectedTo)))
|
|
|
|
{
|
|
|
|
IPin_Disconnect(pConnectedTo);
|
|
|
|
IPin_Release(pConnectedTo);
|
|
|
|
}
|
|
|
|
IPin_Disconnect(This->ppPins[0]);
|
|
|
|
|
2004-08-24 04:28:35 +02:00
|
|
|
IPin_Release(This->ppPins[0]);
|
|
|
|
|
2007-03-08 12:03:06 +01:00
|
|
|
CoTaskMemFree(This->ppPins);
|
2004-08-24 04:28:35 +02:00
|
|
|
This->lpVtbl = NULL;
|
|
|
|
This->IBasicAudio_vtbl = NULL;
|
|
|
|
|
2007-03-19 21:26:09 +01:00
|
|
|
This->csFilter.DebugInfo->Spare[0] = 0;
|
|
|
|
DeleteCriticalSection(&This->csFilter);
|
|
|
|
|
2004-08-24 04:28:35 +02:00
|
|
|
TRACE("Destroying Audio Renderer\n");
|
|
|
|
CoTaskMemFree(This);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
else
|
2005-01-06 20:36:47 +01:00
|
|
|
return refCount;
|
2004-08-24 04:28:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/** IPersist methods **/
|
|
|
|
|
|
|
|
static HRESULT WINAPI DSoundRender_GetClassID(IBaseFilter * iface, CLSID * pClsid)
|
|
|
|
{
|
2004-09-08 03:50:37 +02:00
|
|
|
DSoundRenderImpl *This = (DSoundRenderImpl *)iface;
|
2004-08-24 04:28:35 +02:00
|
|
|
TRACE("(%p/%p)->(%p)\n", This, iface, pClsid);
|
|
|
|
|
|
|
|
*pClsid = CLSID_DSoundRender;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** IMediaFilter methods **/
|
|
|
|
|
|
|
|
static HRESULT WINAPI DSoundRender_Stop(IBaseFilter * iface)
|
|
|
|
{
|
|
|
|
HRESULT hr = S_OK;
|
2004-09-08 03:50:37 +02:00
|
|
|
DSoundRenderImpl *This = (DSoundRenderImpl *)iface;
|
2004-08-24 04:28:35 +02:00
|
|
|
|
|
|
|
TRACE("(%p/%p)->()\n", This, iface);
|
|
|
|
|
|
|
|
EnterCriticalSection(&This->csFilter);
|
|
|
|
{
|
2007-03-10 13:09:43 +01:00
|
|
|
DWORD state = 0;
|
|
|
|
if (This->dsbuffer)
|
|
|
|
{
|
|
|
|
hr = IDirectSoundBuffer_GetStatus(This->dsbuffer, &state);
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
if (state & DSBSTATUS_PLAYING)
|
|
|
|
hr = IDirectSoundBuffer_Stop(This->dsbuffer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
This->state = State_Stopped;
|
2004-08-24 04:28:35 +02:00
|
|
|
}
|
|
|
|
LeaveCriticalSection(&This->csFilter);
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI DSoundRender_Pause(IBaseFilter * iface)
|
|
|
|
{
|
|
|
|
HRESULT hr = S_OK;
|
2004-09-08 03:50:37 +02:00
|
|
|
DSoundRenderImpl *This = (DSoundRenderImpl *)iface;
|
2004-08-24 04:28:35 +02:00
|
|
|
|
|
|
|
TRACE("(%p/%p)->()\n", This, iface);
|
|
|
|
|
|
|
|
EnterCriticalSection(&This->csFilter);
|
|
|
|
{
|
2007-03-10 13:09:43 +01:00
|
|
|
DWORD state = 0;
|
|
|
|
if (This->dsbuffer)
|
|
|
|
{
|
|
|
|
hr = IDirectSoundBuffer_GetStatus(This->dsbuffer, &state);
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
if (state & DSBSTATUS_PLAYING)
|
|
|
|
hr = IDirectSoundBuffer_Stop(This->dsbuffer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
This->state = State_Paused;
|
2004-08-24 04:28:35 +02:00
|
|
|
}
|
|
|
|
LeaveCriticalSection(&This->csFilter);
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI DSoundRender_Run(IBaseFilter * iface, REFERENCE_TIME tStart)
|
|
|
|
{
|
|
|
|
HRESULT hr = S_OK;
|
2004-09-08 03:50:37 +02:00
|
|
|
DSoundRenderImpl *This = (DSoundRenderImpl *)iface;
|
2004-08-24 04:28:35 +02:00
|
|
|
|
|
|
|
TRACE("(%p/%p)->(%s)\n", This, iface, wine_dbgstr_longlong(tStart));
|
|
|
|
|
|
|
|
EnterCriticalSection(&This->csFilter);
|
|
|
|
{
|
2007-03-25 01:43:57 +01:00
|
|
|
/* It's okay if there's no buffer yet. It'll start when it's created */
|
|
|
|
if (This->dsbuffer)
|
|
|
|
{
|
|
|
|
hr = IDirectSoundBuffer_Play(This->dsbuffer, 0, 0, DSBPLAY_LOOPING);
|
|
|
|
if (FAILED(hr))
|
|
|
|
ERR("Can't start playing! (%x)\n", hr);
|
|
|
|
}
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
This->rtStreamStart = tStart;
|
|
|
|
This->state = State_Running;
|
|
|
|
}
|
2004-08-24 04:28:35 +02:00
|
|
|
}
|
|
|
|
LeaveCriticalSection(&This->csFilter);
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI DSoundRender_GetState(IBaseFilter * iface, DWORD dwMilliSecsTimeout, FILTER_STATE *pState)
|
|
|
|
{
|
2004-09-08 03:50:37 +02:00
|
|
|
DSoundRenderImpl *This = (DSoundRenderImpl *)iface;
|
2004-08-24 04:28:35 +02:00
|
|
|
|
2006-10-12 20:57:23 +02:00
|
|
|
TRACE("(%p/%p)->(%d, %p)\n", This, iface, dwMilliSecsTimeout, pState);
|
2004-08-24 04:28:35 +02:00
|
|
|
|
|
|
|
EnterCriticalSection(&This->csFilter);
|
|
|
|
{
|
|
|
|
*pState = This->state;
|
|
|
|
}
|
|
|
|
LeaveCriticalSection(&This->csFilter);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI DSoundRender_SetSyncSource(IBaseFilter * iface, IReferenceClock *pClock)
|
|
|
|
{
|
2004-09-08 03:50:37 +02:00
|
|
|
DSoundRenderImpl *This = (DSoundRenderImpl *)iface;
|
2004-08-24 04:28:35 +02:00
|
|
|
|
|
|
|
TRACE("(%p/%p)->(%p)\n", This, iface, pClock);
|
|
|
|
|
|
|
|
EnterCriticalSection(&This->csFilter);
|
|
|
|
{
|
|
|
|
if (This->pClock)
|
|
|
|
IReferenceClock_Release(This->pClock);
|
|
|
|
This->pClock = pClock;
|
|
|
|
if (This->pClock)
|
|
|
|
IReferenceClock_AddRef(This->pClock);
|
|
|
|
}
|
|
|
|
LeaveCriticalSection(&This->csFilter);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI DSoundRender_GetSyncSource(IBaseFilter * iface, IReferenceClock **ppClock)
|
|
|
|
{
|
2004-09-08 03:50:37 +02:00
|
|
|
DSoundRenderImpl *This = (DSoundRenderImpl *)iface;
|
2004-08-24 04:28:35 +02:00
|
|
|
|
|
|
|
TRACE("(%p/%p)->(%p)\n", This, iface, ppClock);
|
|
|
|
|
|
|
|
EnterCriticalSection(&This->csFilter);
|
|
|
|
{
|
|
|
|
*ppClock = This->pClock;
|
|
|
|
IReferenceClock_AddRef(This->pClock);
|
|
|
|
}
|
|
|
|
LeaveCriticalSection(&This->csFilter);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** IBaseFilter implementation **/
|
|
|
|
|
|
|
|
static HRESULT WINAPI DSoundRender_EnumPins(IBaseFilter * iface, IEnumPins **ppEnum)
|
|
|
|
{
|
|
|
|
ENUMPINDETAILS epd;
|
2004-09-08 03:50:37 +02:00
|
|
|
DSoundRenderImpl *This = (DSoundRenderImpl *)iface;
|
2004-08-24 04:28:35 +02:00
|
|
|
|
|
|
|
TRACE("(%p/%p)->(%p)\n", This, iface, ppEnum);
|
|
|
|
|
|
|
|
epd.cPins = 1; /* input pin */
|
|
|
|
epd.ppPins = This->ppPins;
|
|
|
|
return IEnumPinsImpl_Construct(&epd, ppEnum);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI DSoundRender_FindPin(IBaseFilter * iface, LPCWSTR Id, IPin **ppPin)
|
|
|
|
{
|
2004-09-08 03:50:37 +02:00
|
|
|
DSoundRenderImpl *This = (DSoundRenderImpl *)iface;
|
2004-08-24 04:28:35 +02:00
|
|
|
|
|
|
|
TRACE("(%p/%p)->(%s,%p)\n", This, iface, debugstr_w(Id), ppPin);
|
|
|
|
|
|
|
|
FIXME("DSoundRender::FindPin(...)\n");
|
|
|
|
|
|
|
|
/* FIXME: critical section */
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI DSoundRender_QueryFilterInfo(IBaseFilter * iface, FILTER_INFO *pInfo)
|
|
|
|
{
|
2004-09-08 03:50:37 +02:00
|
|
|
DSoundRenderImpl *This = (DSoundRenderImpl *)iface;
|
2004-08-24 04:28:35 +02:00
|
|
|
|
|
|
|
TRACE("(%p/%p)->(%p)\n", This, iface, pInfo);
|
|
|
|
|
|
|
|
strcpyW(pInfo->achName, This->filterInfo.achName);
|
|
|
|
pInfo->pGraph = This->filterInfo.pGraph;
|
|
|
|
|
|
|
|
if (pInfo->pGraph)
|
|
|
|
IFilterGraph_AddRef(pInfo->pGraph);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI DSoundRender_JoinFilterGraph(IBaseFilter * iface, IFilterGraph *pGraph, LPCWSTR pName)
|
|
|
|
{
|
2004-09-08 03:50:37 +02:00
|
|
|
DSoundRenderImpl *This = (DSoundRenderImpl *)iface;
|
2004-08-24 04:28:35 +02:00
|
|
|
|
|
|
|
TRACE("(%p/%p)->(%p, %s)\n", This, iface, pGraph, debugstr_w(pName));
|
|
|
|
|
|
|
|
EnterCriticalSection(&This->csFilter);
|
|
|
|
{
|
|
|
|
if (pName)
|
|
|
|
strcpyW(This->filterInfo.achName, pName);
|
|
|
|
else
|
|
|
|
*This->filterInfo.achName = '\0';
|
|
|
|
This->filterInfo.pGraph = pGraph; /* NOTE: do NOT increase ref. count */
|
|
|
|
}
|
|
|
|
LeaveCriticalSection(&This->csFilter);
|
|
|
|
|
2005-03-02 11:12:12 +01:00
|
|
|
return S_OK;
|
2004-08-24 04:28:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI DSoundRender_QueryVendorInfo(IBaseFilter * iface, LPWSTR *pVendorInfo)
|
|
|
|
{
|
2004-09-08 03:50:37 +02:00
|
|
|
DSoundRenderImpl *This = (DSoundRenderImpl *)iface;
|
2004-08-24 04:28:35 +02:00
|
|
|
TRACE("(%p/%p)->(%p)\n", This, iface, pVendorInfo);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IBaseFilterVtbl DSoundRender_Vtbl =
|
|
|
|
{
|
|
|
|
DSoundRender_QueryInterface,
|
|
|
|
DSoundRender_AddRef,
|
|
|
|
DSoundRender_Release,
|
|
|
|
DSoundRender_GetClassID,
|
|
|
|
DSoundRender_Stop,
|
|
|
|
DSoundRender_Pause,
|
|
|
|
DSoundRender_Run,
|
|
|
|
DSoundRender_GetState,
|
|
|
|
DSoundRender_SetSyncSource,
|
|
|
|
DSoundRender_GetSyncSource,
|
|
|
|
DSoundRender_EnumPins,
|
|
|
|
DSoundRender_FindPin,
|
|
|
|
DSoundRender_QueryFilterInfo,
|
|
|
|
DSoundRender_JoinFilterGraph,
|
|
|
|
DSoundRender_QueryVendorInfo
|
|
|
|
};
|
|
|
|
|
|
|
|
static HRESULT WINAPI DSoundRender_InputPin_EndOfStream(IPin * iface)
|
|
|
|
{
|
|
|
|
InputPin* This = (InputPin*)iface;
|
2005-03-02 11:12:12 +01:00
|
|
|
IMediaEventSink* pEventSink;
|
|
|
|
HRESULT hr;
|
|
|
|
|
2004-08-24 04:28:35 +02:00
|
|
|
TRACE("(%p/%p)->()\n", This, iface);
|
2005-03-02 11:12:12 +01:00
|
|
|
|
|
|
|
hr = IFilterGraph_QueryInterface(((DSoundRenderImpl*)This->pin.pinInfo.pFilter)->filterInfo.pGraph, &IID_IMediaEventSink, (LPVOID*)&pEventSink);
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
/* FIXME: We should wait that all audio data has been played */
|
|
|
|
hr = IMediaEventSink_Notify(pEventSink, EC_COMPLETE, S_OK, 0);
|
|
|
|
IMediaEventSink_Release(pEventSink);
|
|
|
|
}
|
|
|
|
|
|
|
|
return hr;
|
2004-08-24 04:28:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static const IPinVtbl DSoundRender_InputPin_Vtbl =
|
|
|
|
{
|
|
|
|
InputPin_QueryInterface,
|
|
|
|
IPinImpl_AddRef,
|
|
|
|
InputPin_Release,
|
|
|
|
InputPin_Connect,
|
|
|
|
InputPin_ReceiveConnection,
|
|
|
|
IPinImpl_Disconnect,
|
|
|
|
IPinImpl_ConnectedTo,
|
|
|
|
IPinImpl_ConnectionMediaType,
|
|
|
|
IPinImpl_QueryPinInfo,
|
|
|
|
IPinImpl_QueryDirection,
|
|
|
|
IPinImpl_QueryId,
|
|
|
|
IPinImpl_QueryAccept,
|
|
|
|
IPinImpl_EnumMediaTypes,
|
|
|
|
IPinImpl_QueryInternalConnections,
|
|
|
|
DSoundRender_InputPin_EndOfStream,
|
|
|
|
InputPin_BeginFlush,
|
|
|
|
InputPin_EndFlush,
|
|
|
|
InputPin_NewSegment
|
|
|
|
};
|
|
|
|
|
|
|
|
static const IMemInputPinVtbl MemInputPin_Vtbl =
|
|
|
|
{
|
|
|
|
MemInputPin_QueryInterface,
|
|
|
|
MemInputPin_AddRef,
|
|
|
|
MemInputPin_Release,
|
|
|
|
MemInputPin_GetAllocator,
|
|
|
|
MemInputPin_NotifyAllocator,
|
|
|
|
MemInputPin_GetAllocatorRequirements,
|
|
|
|
MemInputPin_Receive,
|
|
|
|
MemInputPin_ReceiveMultiple,
|
|
|
|
MemInputPin_ReceiveCanBlock
|
|
|
|
};
|
|
|
|
|
|
|
|
/*** IUnknown methods ***/
|
|
|
|
static HRESULT WINAPI Basicaudio_QueryInterface(IBasicAudio *iface,
|
|
|
|
REFIID riid,
|
|
|
|
LPVOID*ppvObj) {
|
|
|
|
ICOM_THIS_MULTI(DSoundRenderImpl, IBasicAudio_vtbl, iface);
|
|
|
|
|
|
|
|
TRACE("(%p/%p)->(%s (%p), %p)\n", This, iface, debugstr_guid(riid), riid, ppvObj);
|
|
|
|
|
|
|
|
return DSoundRender_QueryInterface((IBaseFilter*)This, riid, ppvObj);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI Basicaudio_AddRef(IBasicAudio *iface) {
|
|
|
|
ICOM_THIS_MULTI(DSoundRenderImpl, IBasicAudio_vtbl, iface);
|
|
|
|
|
|
|
|
TRACE("(%p/%p)->()\n", This, iface);
|
|
|
|
|
|
|
|
return DSoundRender_AddRef((IBaseFilter*)This);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI Basicaudio_Release(IBasicAudio *iface) {
|
|
|
|
ICOM_THIS_MULTI(DSoundRenderImpl, IBasicAudio_vtbl, iface);
|
|
|
|
|
|
|
|
TRACE("(%p/%p)->()\n", This, iface);
|
|
|
|
|
|
|
|
return DSoundRender_Release((IBaseFilter*)This);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*** IDispatch methods ***/
|
|
|
|
static HRESULT WINAPI Basicaudio_GetTypeInfoCount(IBasicAudio *iface,
|
|
|
|
UINT*pctinfo) {
|
|
|
|
ICOM_THIS_MULTI(DSoundRenderImpl, IBasicAudio_vtbl, iface);
|
|
|
|
|
|
|
|
TRACE("(%p/%p)->(%p): stub !!!\n", This, iface, pctinfo);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI Basicaudio_GetTypeInfo(IBasicAudio *iface,
|
|
|
|
UINT iTInfo,
|
|
|
|
LCID lcid,
|
|
|
|
ITypeInfo**ppTInfo) {
|
|
|
|
ICOM_THIS_MULTI(DSoundRenderImpl, IBasicAudio_vtbl, iface);
|
|
|
|
|
2006-10-12 20:57:23 +02:00
|
|
|
TRACE("(%p/%p)->(%d, %d, %p): stub !!!\n", This, iface, iTInfo, lcid, ppTInfo);
|
2004-08-24 04:28:35 +02:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI Basicaudio_GetIDsOfNames(IBasicAudio *iface,
|
|
|
|
REFIID riid,
|
|
|
|
LPOLESTR*rgszNames,
|
|
|
|
UINT cNames,
|
|
|
|
LCID lcid,
|
|
|
|
DISPID*rgDispId) {
|
|
|
|
ICOM_THIS_MULTI(DSoundRenderImpl, IBasicAudio_vtbl, iface);
|
|
|
|
|
2006-10-12 20:57:23 +02:00
|
|
|
TRACE("(%p/%p)->(%s (%p), %p, %d, %d, %p): stub !!!\n", This, iface, debugstr_guid(riid), riid, rgszNames, cNames, lcid, rgDispId);
|
2004-08-24 04:28:35 +02:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI Basicaudio_Invoke(IBasicAudio *iface,
|
|
|
|
DISPID dispIdMember,
|
|
|
|
REFIID riid,
|
|
|
|
LCID lcid,
|
|
|
|
WORD wFlags,
|
|
|
|
DISPPARAMS*pDispParams,
|
|
|
|
VARIANT*pVarResult,
|
|
|
|
EXCEPINFO*pExepInfo,
|
|
|
|
UINT*puArgErr) {
|
|
|
|
ICOM_THIS_MULTI(DSoundRenderImpl, IBasicAudio_vtbl, iface);
|
|
|
|
|
2006-10-12 20:57:23 +02:00
|
|
|
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);
|
2004-08-24 04:28:35 +02:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*** IBasicAudio methods ***/
|
|
|
|
static HRESULT WINAPI Basicaudio_put_Volume(IBasicAudio *iface,
|
|
|
|
long lVolume) {
|
|
|
|
ICOM_THIS_MULTI(DSoundRenderImpl, IBasicAudio_vtbl, iface);
|
|
|
|
|
2007-03-26 05:13:53 +02:00
|
|
|
TRACE("(%p/%p)->(%ld)\n", This, iface, lVolume);
|
|
|
|
|
|
|
|
if (lVolume > DSBVOLUME_MAX || lVolume < DSBVOLUME_MIN)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
if (This->dsbuffer) {
|
|
|
|
if (FAILED(IDirectSoundBuffer_SetVolume(This->dsbuffer, lVolume)))
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
2004-08-24 04:28:35 +02:00
|
|
|
|
2007-03-26 05:13:53 +02:00
|
|
|
This->volume = lVolume;
|
2004-08-24 04:28:35 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI Basicaudio_get_Volume(IBasicAudio *iface,
|
|
|
|
long *plVolume) {
|
|
|
|
ICOM_THIS_MULTI(DSoundRenderImpl, IBasicAudio_vtbl, iface);
|
|
|
|
|
2007-03-26 05:13:53 +02:00
|
|
|
TRACE("(%p/%p)->(%p)\n", This, iface, plVolume);
|
2004-08-24 04:28:35 +02:00
|
|
|
|
2007-03-26 05:13:53 +02:00
|
|
|
if (!plVolume)
|
|
|
|
return E_POINTER;
|
|
|
|
|
|
|
|
*plVolume = This->volume;
|
2004-08-24 04:28:35 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI Basicaudio_put_Balance(IBasicAudio *iface,
|
|
|
|
long lBalance) {
|
|
|
|
ICOM_THIS_MULTI(DSoundRenderImpl, IBasicAudio_vtbl, iface);
|
|
|
|
|
2007-03-26 05:13:53 +02:00
|
|
|
TRACE("(%p/%p)->(%ld)\n", This, iface, lBalance);
|
|
|
|
|
|
|
|
if (lBalance < DSBPAN_LEFT || lBalance > DSBPAN_RIGHT)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
if (This->dsbuffer) {
|
|
|
|
if (FAILED(IDirectSoundBuffer_SetPan(This->dsbuffer, lBalance)))
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
2004-08-24 04:28:35 +02:00
|
|
|
|
2007-03-26 05:13:53 +02:00
|
|
|
This->pan = lBalance;
|
2004-08-24 04:28:35 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI Basicaudio_get_Balance(IBasicAudio *iface,
|
|
|
|
long *plBalance) {
|
|
|
|
ICOM_THIS_MULTI(DSoundRenderImpl, IBasicAudio_vtbl, iface);
|
|
|
|
|
2007-03-26 05:13:53 +02:00
|
|
|
TRACE("(%p/%p)->(%p)\n", This, iface, plBalance);
|
|
|
|
|
|
|
|
if (!plBalance)
|
|
|
|
return E_POINTER;
|
2004-08-24 04:28:35 +02:00
|
|
|
|
2007-03-26 05:13:53 +02:00
|
|
|
*plBalance = This->pan;
|
2004-08-24 04:28:35 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IBasicAudioVtbl IBasicAudio_Vtbl =
|
|
|
|
{
|
|
|
|
Basicaudio_QueryInterface,
|
|
|
|
Basicaudio_AddRef,
|
|
|
|
Basicaudio_Release,
|
|
|
|
Basicaudio_GetTypeInfoCount,
|
|
|
|
Basicaudio_GetTypeInfo,
|
|
|
|
Basicaudio_GetIDsOfNames,
|
|
|
|
Basicaudio_Invoke,
|
|
|
|
Basicaudio_put_Volume,
|
|
|
|
Basicaudio_get_Volume,
|
|
|
|
Basicaudio_put_Balance,
|
|
|
|
Basicaudio_get_Balance
|
|
|
|
};
|