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 "vfwmsgs.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 IBasicAudioVtbl IBasicAudio_Vtbl;
|
2007-04-06 12:48:03 +02:00
|
|
|
static const IReferenceClockVtbl IReferenceClock_Vtbl;
|
2008-03-20 02:29:09 +01:00
|
|
|
static const IMediaSeekingVtbl IMediaSeeking_Vtbl;
|
2004-08-24 04:28:35 +02:00
|
|
|
|
|
|
|
typedef struct DSoundRenderImpl
|
|
|
|
{
|
|
|
|
const IBaseFilterVtbl * lpVtbl;
|
|
|
|
const IBasicAudioVtbl *IBasicAudio_vtbl;
|
2007-04-06 12:48:03 +02:00
|
|
|
const IReferenceClockVtbl *IReferenceClock_vtbl;
|
2004-08-24 04:28:35 +02:00
|
|
|
|
2005-07-12 21:21:36 +02:00
|
|
|
LONG refCount;
|
2004-08-24 04:28:35 +02:00
|
|
|
CRITICAL_SECTION csFilter;
|
|
|
|
FILTER_STATE state;
|
2008-04-16 23:27:06 +02:00
|
|
|
REFERENCE_TIME rtStreamStart, rtLastStop;
|
2004-08-24 04:28:35 +02:00
|
|
|
IReferenceClock * pClock;
|
|
|
|
FILTER_INFO filterInfo;
|
|
|
|
|
|
|
|
InputPin * pInputPin;
|
|
|
|
|
2008-06-10 17:00:40 +02:00
|
|
|
IDirectSound8 *dsound;
|
2004-08-24 04:28:35 +02:00
|
|
|
LPDIRECTSOUNDBUFFER dsbuffer;
|
2007-04-01 14:50:44 +02:00
|
|
|
DWORD buf_size;
|
2004-08-24 04:28:35 +02:00
|
|
|
DWORD write_pos;
|
2007-04-06 12:48:03 +02:00
|
|
|
DWORD write_loops;
|
2007-03-26 05:13:53 +02:00
|
|
|
|
2007-04-06 12:48:03 +02:00
|
|
|
DWORD last_play_pos;
|
|
|
|
DWORD play_loops;
|
2008-04-09 01:48:00 +02:00
|
|
|
|
2007-04-06 12:48:03 +02:00
|
|
|
REFERENCE_TIME play_time;
|
2008-03-20 02:29:09 +01:00
|
|
|
MediaSeekingImpl mediaSeeking;
|
2007-04-06 12:48:03 +02:00
|
|
|
|
2008-07-04 09:09:07 +02:00
|
|
|
HANDLE state_change, blocked;
|
|
|
|
|
2007-03-26 05:13:53 +02:00
|
|
|
long volume;
|
|
|
|
long pan;
|
2004-08-24 04:28:35 +02:00
|
|
|
} DSoundRenderImpl;
|
|
|
|
|
2008-04-21 07:17:27 +02:00
|
|
|
/* Seeking is not needed for a renderer, rely on newsegment for the appropriate changes */
|
2008-03-20 02:29:09 +01:00
|
|
|
static HRESULT sound_mod_stop(IBaseFilter *iface)
|
|
|
|
{
|
2008-04-16 23:27:06 +02:00
|
|
|
TRACE("(%p)\n", iface);
|
2008-03-20 02:29:09 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT sound_mod_start(IBaseFilter *iface)
|
|
|
|
{
|
2008-04-16 23:27:06 +02:00
|
|
|
TRACE("(%p)\n", iface);
|
|
|
|
|
2008-03-20 02:29:09 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT sound_mod_rate(IBaseFilter *iface)
|
|
|
|
{
|
2008-04-16 23:27:06 +02:00
|
|
|
DSoundRenderImpl *This = (DSoundRenderImpl *)iface;
|
|
|
|
|
|
|
|
WAVEFORMATEX *format = (WAVEFORMATEX*)This->pInputPin->pin.mtCurrent.pbFormat;
|
|
|
|
DWORD freq = format->nSamplesPerSec;
|
|
|
|
double rate = This->mediaSeeking.dRate;
|
|
|
|
|
|
|
|
freq = (DWORD)((double)freq * rate);
|
|
|
|
|
|
|
|
TRACE("(%p)\n", iface);
|
|
|
|
|
|
|
|
if (freq > DSBFREQUENCY_MAX)
|
|
|
|
return VFW_E_UNSUPPORTED_AUDIO;
|
|
|
|
|
|
|
|
if (freq < DSBFREQUENCY_MIN)
|
|
|
|
return VFW_E_UNSUPPORTED_AUDIO;
|
|
|
|
|
2008-03-20 02:29:09 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2008-04-05 01:27:29 +02:00
|
|
|
static inline HRESULT DSoundRender_GetPos(DSoundRenderImpl *This, DWORD *pPlayPos, REFERENCE_TIME *pRefTime)
|
2007-04-06 12:48:03 +02:00
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
EnterCriticalSection(&This->csFilter);
|
|
|
|
{
|
2008-04-05 01:27:29 +02:00
|
|
|
DWORD state;
|
2008-04-09 01:48:00 +02:00
|
|
|
DWORD write_pos;
|
2008-04-05 01:27:29 +02:00
|
|
|
|
|
|
|
hr = IDirectSoundBuffer_GetStatus(This->dsbuffer, &state);
|
|
|
|
if (SUCCEEDED(hr) && !(state & DSBSTATUS_PLAYING) && This->state == State_Running)
|
|
|
|
{
|
|
|
|
TRACE("Not playing, kickstarting the engine\n");
|
|
|
|
|
|
|
|
hr = IDirectSoundBuffer_Play(This->dsbuffer, 0, 0, DSBPLAY_LOOPING);
|
|
|
|
if (FAILED(hr))
|
|
|
|
ERR("Can't play sound buffer (%x)\n", hr);
|
|
|
|
}
|
2008-04-09 01:48:00 +02:00
|
|
|
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
hr = IDirectSoundBuffer_GetCurrentPosition(This->dsbuffer, pPlayPos, &write_pos);
|
2008-04-05 01:27:29 +02:00
|
|
|
if (hr == S_OK)
|
2007-04-06 12:48:03 +02:00
|
|
|
{
|
|
|
|
DWORD play_pos = *pPlayPos;
|
|
|
|
|
|
|
|
if (play_pos < This->last_play_pos)
|
|
|
|
This->play_loops++;
|
|
|
|
This->last_play_pos = play_pos;
|
|
|
|
|
2008-04-09 01:48:00 +02:00
|
|
|
/* If we really fell behind, start at the next possible position
|
|
|
|
* Also happens when just starting playback for the first time,
|
|
|
|
* or when flushing
|
|
|
|
*/
|
2007-04-06 12:48:03 +02:00
|
|
|
if ((This->play_loops*This->buf_size)+play_pos >=
|
|
|
|
(This->write_loops*This->buf_size)+This->write_pos)
|
2008-04-09 01:48:00 +02:00
|
|
|
This->write_pos = write_pos;
|
2007-04-06 12:48:03 +02:00
|
|
|
|
|
|
|
if (pRefTime)
|
|
|
|
{
|
|
|
|
REFERENCE_TIME play_time;
|
|
|
|
play_time = ((REFERENCE_TIME)This->play_loops*10000000) +
|
|
|
|
((REFERENCE_TIME)play_pos*10000000/This->buf_size);
|
|
|
|
|
|
|
|
/* Don't let time run backwards */
|
|
|
|
if(play_time-This->play_time > 0)
|
|
|
|
This->play_time = play_time;
|
|
|
|
else
|
|
|
|
hr = S_FALSE;
|
|
|
|
|
|
|
|
*pRefTime = This->play_time;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
LeaveCriticalSection(&This->csFilter);
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2007-08-07 22:01:25 +02:00
|
|
|
static HRESULT DSoundRender_SendSampleData(DSoundRenderImpl* This, const BYTE *data, DWORD size)
|
2004-08-24 04:28:35 +02:00
|
|
|
{
|
2008-04-05 01:27:29 +02:00
|
|
|
HRESULT hr = S_OK;
|
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;
|
|
|
|
|
2008-04-09 01:48:00 +02:00
|
|
|
do {
|
2008-04-05 01:27:29 +02:00
|
|
|
|
|
|
|
hr = DSoundRender_GetPos(This, &play_pos, NULL);
|
2005-04-25 12:49:22 +02:00
|
|
|
if (hr != DS_OK)
|
|
|
|
{
|
2007-04-06 12:48:03 +02:00
|
|
|
ERR("GetPos returned error: %x\n", hr);
|
2005-04-25 12:49:22 +02:00
|
|
|
break;
|
|
|
|
}
|
2007-03-30 12:13:54 +02:00
|
|
|
if (This->write_pos <= play_pos)
|
2005-04-25 12:49:22 +02:00
|
|
|
buf_free = play_pos-This->write_pos;
|
2004-08-24 04:28:35 +02:00
|
|
|
else
|
2007-04-01 14:50:44 +02:00
|
|
|
buf_free = This->buf_size - This->write_pos + play_pos;
|
2004-08-24 04:28:35 +02:00
|
|
|
|
2007-03-30 12:13:54 +02:00
|
|
|
/* Wait for enough of the buffer to empty before filling it */
|
2007-04-01 14:50:44 +02:00
|
|
|
if(buf_free < This->buf_size/4)
|
2006-08-18 18:38:38 +02:00
|
|
|
{
|
2008-04-08 00:44:51 +02:00
|
|
|
Sleep(50);
|
2006-08-18 18:38:38 +02:00
|
|
|
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;
|
2007-04-06 12:48:03 +02:00
|
|
|
This->write_pos += dwsize1 + dwsize2;
|
|
|
|
if (This->write_pos >= This->buf_size)
|
|
|
|
{
|
|
|
|
This->write_pos -= This->buf_size;
|
|
|
|
This->write_loops++;
|
|
|
|
}
|
2008-04-09 01:48:00 +02:00
|
|
|
} while (size && 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)
|
|
|
|
{
|
2009-01-29 11:14:55 +01:00
|
|
|
DSoundRenderImpl *This = iface;
|
2004-08-24 04:28:35 +02:00
|
|
|
LPBYTE pbSrcStream = NULL;
|
|
|
|
long cbSrcStream = 0;
|
|
|
|
REFERENCE_TIME tStart, tStop;
|
|
|
|
HRESULT hr;
|
2008-10-21 12:50:36 +02:00
|
|
|
AM_MEDIA_TYPE *amt;
|
2004-08-24 04:28:35 +02:00
|
|
|
|
|
|
|
TRACE("%p %p\n", iface, pSample);
|
2007-03-10 13:09:43 +01:00
|
|
|
|
2008-04-16 23:27:06 +02:00
|
|
|
/* Slightly incorrect, Pause completes when a frame is received so we should signal
|
2008-04-19 01:14:41 +02:00
|
|
|
* pause completion here, but for sound playing a single frame doesn't make sense
|
2008-04-16 23:27:06 +02:00
|
|
|
*/
|
2008-04-19 01:14:41 +02:00
|
|
|
|
2008-07-05 01:59:22 +02:00
|
|
|
EnterCriticalSection(&This->csFilter);
|
|
|
|
|
|
|
|
if (This->pInputPin->end_of_stream || This->pInputPin->flushing)
|
|
|
|
{
|
|
|
|
LeaveCriticalSection(&This->csFilter);
|
|
|
|
return S_FALSE;
|
|
|
|
}
|
|
|
|
|
2008-04-05 01:27:29 +02:00
|
|
|
if (This->state == State_Stopped)
|
2008-07-05 01:59:22 +02:00
|
|
|
{
|
|
|
|
LeaveCriticalSection(&This->csFilter);
|
2008-07-03 05:08:46 +02:00
|
|
|
return VFW_E_WRONG_STATE;
|
2008-07-05 01:59:22 +02:00
|
|
|
}
|
2008-04-05 01:27:29 +02:00
|
|
|
|
2008-10-21 12:50:36 +02:00
|
|
|
if (IMediaSample_GetMediaType(pSample, &amt) == S_OK)
|
|
|
|
{
|
|
|
|
AM_MEDIA_TYPE *orig = &This->pInputPin->pin.mtCurrent;
|
|
|
|
WAVEFORMATEX *origfmt = (WAVEFORMATEX *)orig->pbFormat;
|
|
|
|
WAVEFORMATEX *newfmt = (WAVEFORMATEX *)amt->pbFormat;
|
|
|
|
|
|
|
|
if (origfmt->wFormatTag == newfmt->wFormatTag &&
|
|
|
|
origfmt->nChannels == newfmt->nChannels &&
|
|
|
|
origfmt->nBlockAlign == newfmt->nBlockAlign &&
|
|
|
|
origfmt->wBitsPerSample == newfmt->wBitsPerSample &&
|
|
|
|
origfmt->cbSize == newfmt->cbSize)
|
|
|
|
{
|
|
|
|
if (origfmt->nSamplesPerSec != newfmt->nSamplesPerSec)
|
|
|
|
{
|
|
|
|
hr = IDirectSoundBuffer_SetFrequency(This->dsbuffer,
|
|
|
|
newfmt->nSamplesPerSec);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
LeaveCriticalSection(&This->csFilter);
|
|
|
|
return VFW_E_TYPE_NOT_ACCEPTED;
|
|
|
|
}
|
|
|
|
FreeMediaType(orig);
|
|
|
|
CopyMediaType(orig, amt);
|
|
|
|
IMediaSample_SetMediaType(pSample, NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
LeaveCriticalSection(&This->csFilter);
|
|
|
|
return VFW_E_TYPE_NOT_ACCEPTED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-07-04 09:09:07 +02:00
|
|
|
SetEvent(This->state_change);
|
|
|
|
|
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);
|
2008-07-09 19:21:30 +02:00
|
|
|
LeaveCriticalSection(&This->csFilter);
|
2008-04-16 23:27:06 +02:00
|
|
|
return hr;
|
2004-08-24 04:28:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
2008-04-16 23:27:06 +02:00
|
|
|
if (This->rtLastStop != tStart && (IMediaSample_IsDiscontinuity(pSample) == S_FALSE))
|
2008-06-24 05:10:19 +02:00
|
|
|
WARN("Unexpected discontinuity: Last: %u.%03u, tStart: %u.%03u\n",
|
2008-04-19 07:23:19 +02:00
|
|
|
(DWORD)(This->rtLastStop / 10000000), (DWORD)((This->rtLastStop / 10000)%1000),
|
|
|
|
(DWORD)(tStart / 10000000), (DWORD)((tStart / 10000)%1000));
|
2008-04-16 23:27:06 +02:00
|
|
|
This->rtLastStop = tStop;
|
|
|
|
|
2008-04-19 07:04:55 +02:00
|
|
|
if (IMediaSample_IsPreroll(pSample) == S_OK)
|
|
|
|
{
|
|
|
|
TRACE("Preroll!\n");
|
2008-07-09 19:21:30 +02:00
|
|
|
LeaveCriticalSection(&This->csFilter);
|
2008-04-19 07:04:55 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2008-07-03 05:08:46 +02:00
|
|
|
if (This->state == State_Paused)
|
2008-07-04 09:09:07 +02:00
|
|
|
{
|
|
|
|
LeaveCriticalSection(&This->csFilter);
|
|
|
|
WaitForSingleObject(This->blocked, INFINITE);
|
|
|
|
EnterCriticalSection(&This->csFilter);
|
|
|
|
if (This->state == State_Stopped)
|
2008-07-05 01:59:22 +02:00
|
|
|
{
|
|
|
|
LeaveCriticalSection(&This->csFilter);
|
2008-07-04 09:09:07 +02:00
|
|
|
return VFW_E_WRONG_STATE;
|
2008-07-05 01:59:22 +02:00
|
|
|
}
|
2008-07-04 09:09:07 +02:00
|
|
|
|
|
|
|
if (This->state == State_Paused)
|
|
|
|
{
|
|
|
|
/* Assuming we return because of flushing */
|
2008-07-09 19:21:30 +02:00
|
|
|
TRACE("Flushing\n");
|
2008-07-05 01:59:22 +02:00
|
|
|
LeaveCriticalSection(&This->csFilter);
|
2008-07-04 09:09:07 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
}
|
2008-07-03 05:08:46 +02:00
|
|
|
|
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
|
2005-04-25 12:49:22 +02:00
|
|
|
|
2008-07-05 01:59:22 +02:00
|
|
|
hr = DSoundRender_SendSampleData(This, pbSrcStream, cbSrcStream);
|
|
|
|
LeaveCriticalSection(&This->csFilter);
|
|
|
|
return hr;
|
2004-08-24 04:28:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT DSoundRender_QueryAccept(LPVOID iface, const AM_MEDIA_TYPE * pmt)
|
|
|
|
{
|
2008-06-10 17:00:40 +02:00
|
|
|
WAVEFORMATEX* format;
|
|
|
|
|
|
|
|
if (!IsEqualIID(&pmt->majortype, &MEDIATYPE_Audio))
|
|
|
|
return S_FALSE;
|
|
|
|
|
|
|
|
format = (WAVEFORMATEX*)pmt->pbFormat;
|
|
|
|
TRACE("Format = %p\n", format);
|
2004-08-24 04:28:35 +02:00
|
|
|
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);
|
|
|
|
|
2008-06-10 17:00:40 +02:00
|
|
|
if (!IsEqualIID(&pmt->subtype, &MEDIASUBTYPE_PCM))
|
|
|
|
return S_FALSE;
|
|
|
|
|
|
|
|
return S_OK;
|
2004-08-24 04:28:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
2007-04-06 12:48:03 +02:00
|
|
|
pDSoundRender->IReferenceClock_vtbl = &IReferenceClock_Vtbl;
|
2004-08-24 04:28:35 +02:00
|
|
|
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;
|
|
|
|
|
|
|
|
/* 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]));
|
2008-06-10 17:57:41 +02:00
|
|
|
hr = InputPin_Construct(&DSoundRender_InputPin_Vtbl, &piInput, DSoundRender_Sample, pDSoundRender, DSoundRender_QueryAccept, NULL, &pDSoundRender->csFilter, NULL, (IPin **)&pDSoundRender->pInputPin);
|
2004-08-24 04:28:35 +02:00
|
|
|
|
2007-04-13 18:32:56 +02:00
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
2008-06-10 17:00:40 +02:00
|
|
|
hr = DirectSoundCreate8(NULL, &pDSoundRender->dsound, NULL);
|
2007-04-13 18:32:56 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
ERR("Cannot create Direct Sound object (%x)\n", hr);
|
2008-06-10 17:00:40 +02:00
|
|
|
else
|
|
|
|
IDirectSound_SetCooperativeLevel(pDSoundRender->dsound, GetDesktopWindow(), DSSCL_PRIORITY);
|
2007-04-13 18:32:56 +02:00
|
|
|
}
|
|
|
|
|
2004-08-24 04:28:35 +02:00
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
2008-03-20 02:29:09 +01:00
|
|
|
MediaSeekingImpl_Init((IBaseFilter*)pDSoundRender, sound_mod_stop, sound_mod_start, sound_mod_rate, &pDSoundRender->mediaSeeking, &pDSoundRender->csFilter);
|
|
|
|
pDSoundRender->mediaSeeking.lpVtbl = &IMediaSeeking_Vtbl;
|
|
|
|
|
2008-07-04 09:09:07 +02:00
|
|
|
pDSoundRender->state_change = CreateEventW(NULL, TRUE, TRUE, NULL);
|
|
|
|
pDSoundRender->blocked = CreateEventW(NULL, FALSE, FALSE, NULL);
|
|
|
|
|
|
|
|
if (!pDSoundRender->state_change || !pDSoundRender->blocked)
|
|
|
|
{
|
|
|
|
IUnknown_Release((IUnknown *)pDSoundRender);
|
|
|
|
return HRESULT_FROM_WIN32(GetLastError());
|
|
|
|
}
|
|
|
|
|
2009-01-29 11:14:55 +01:00
|
|
|
*ppv = pDSoundRender;
|
2004-08-24 04:28:35 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-04-13 18:32:56 +02:00
|
|
|
if (pDSoundRender->pInputPin)
|
|
|
|
IPin_Release((IPin*)pDSoundRender->pInputPin);
|
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))
|
2009-01-29 11:14:55 +01:00
|
|
|
*ppv = This;
|
2004-08-24 04:28:35 +02:00
|
|
|
else if (IsEqualIID(riid, &IID_IPersist))
|
2009-01-29 11:14:55 +01:00
|
|
|
*ppv = This;
|
2004-08-24 04:28:35 +02:00
|
|
|
else if (IsEqualIID(riid, &IID_IMediaFilter))
|
2009-01-29 11:14:55 +01:00
|
|
|
*ppv = This;
|
2004-08-24 04:28:35 +02:00
|
|
|
else if (IsEqualIID(riid, &IID_IBaseFilter))
|
2009-01-29 11:14:55 +01:00
|
|
|
*ppv = This;
|
2007-02-18 08:16:36 +01:00
|
|
|
else if (IsEqualIID(riid, &IID_IBasicAudio))
|
2009-01-29 11:14:55 +01:00
|
|
|
*ppv = &This->IBasicAudio_vtbl;
|
2007-04-06 12:48:03 +02:00
|
|
|
else if (IsEqualIID(riid, &IID_IReferenceClock))
|
2009-01-29 11:14:55 +01:00
|
|
|
*ppv = &This->IReferenceClock_vtbl;
|
2008-03-20 02:29:09 +01:00
|
|
|
else if (IsEqualIID(riid, &IID_IMediaSeeking))
|
|
|
|
*ppv = &This->mediaSeeking.lpVtbl;
|
2004-08-24 04:28:35 +02:00
|
|
|
|
|
|
|
if (*ppv)
|
|
|
|
{
|
|
|
|
IUnknown_AddRef((IUnknown *)(*ppv));
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2008-04-11 00:38:56 +02:00
|
|
|
if (!IsEqualIID(riid, &IID_IPin) && !IsEqualIID(riid, &IID_IVideoWindow))
|
2008-03-21 23:36:51 +01:00
|
|
|
FIXME("No interface for %s!\n", qzdebugstr_guid(riid));
|
2004-08-24 04:28:35 +02:00
|
|
|
|
|
|
|
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
|
|
|
|
2008-04-25 23:25:49 +02:00
|
|
|
if (SUCCEEDED(IPin_ConnectedTo((IPin *)This->pInputPin, &pConnectedTo)))
|
2007-03-13 18:47:47 +01:00
|
|
|
{
|
|
|
|
IPin_Disconnect(pConnectedTo);
|
|
|
|
IPin_Release(pConnectedTo);
|
|
|
|
}
|
2008-04-25 23:25:49 +02:00
|
|
|
IPin_Disconnect((IPin *)This->pInputPin);
|
|
|
|
|
|
|
|
IPin_Release((IPin *)This->pInputPin);
|
2007-03-13 18:47:47 +01:00
|
|
|
|
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);
|
|
|
|
|
2008-07-04 09:09:07 +02:00
|
|
|
CloseHandle(This->state_change);
|
|
|
|
CloseHandle(This->blocked);
|
|
|
|
|
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;
|
2008-07-04 09:09:07 +02:00
|
|
|
|
|
|
|
/* Complete our transition */
|
|
|
|
SetEvent(This->state_change);
|
|
|
|
SetEvent(This->blocked);
|
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);
|
2008-07-04 09:09:07 +02:00
|
|
|
if (This->state != State_Paused)
|
2004-08-24 04:28:35 +02:00
|
|
|
{
|
2007-03-10 13:09:43 +01:00
|
|
|
DWORD state = 0;
|
2008-04-05 01:27:29 +02:00
|
|
|
if (This->state == State_Stopped)
|
2008-07-04 09:09:07 +02:00
|
|
|
{
|
2008-04-05 01:27:29 +02:00
|
|
|
This->pInputPin->end_of_stream = 0;
|
2008-07-04 09:09:07 +02:00
|
|
|
}
|
2008-04-05 01:27:29 +02:00
|
|
|
|
2007-03-10 13:09:43 +01:00
|
|
|
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;
|
2008-07-04 09:09:07 +02:00
|
|
|
|
|
|
|
ResetEvent(This->blocked);
|
|
|
|
ResetEvent(This->state_change);
|
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);
|
|
|
|
{
|
2008-04-05 01:27:29 +02:00
|
|
|
This->rtStreamStart = tStart;
|
2008-07-04 09:09:07 +02:00
|
|
|
if (This->state == State_Paused)
|
|
|
|
{
|
|
|
|
/* Unblock our thread, state changing from paused to running doesn't need a reset for state change */
|
|
|
|
SetEvent(This->blocked);
|
|
|
|
}
|
|
|
|
else if (This->state == State_Stopped)
|
|
|
|
{
|
|
|
|
ResetEvent(This->state_change);
|
|
|
|
This->pInputPin->end_of_stream = 0;
|
|
|
|
}
|
|
|
|
|
2008-04-05 01:27:29 +02:00
|
|
|
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)
|
|
|
|
{
|
2008-07-04 09:09:07 +02:00
|
|
|
HRESULT hr;
|
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
|
|
|
|
2008-07-04 09:09:07 +02:00
|
|
|
if (WaitForSingleObject(This->state_change, dwMilliSecsTimeout) == WAIT_TIMEOUT)
|
|
|
|
hr = VFW_S_STATE_INTERMEDIATE;
|
|
|
|
else
|
|
|
|
hr = S_OK;
|
|
|
|
|
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;
|
2008-04-20 00:19:32 +02:00
|
|
|
if (This->pClock)
|
|
|
|
IReferenceClock_AddRef(This->pClock);
|
2004-08-24 04:28:35 +02:00
|
|
|
}
|
|
|
|
LeaveCriticalSection(&This->csFilter);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** IBaseFilter implementation **/
|
|
|
|
|
2008-04-25 23:25:49 +02:00
|
|
|
static HRESULT DSoundRender_GetPin(IBaseFilter *iface, ULONG pos, IPin **pin, DWORD *lastsynctick)
|
|
|
|
{
|
|
|
|
DSoundRenderImpl *This = (DSoundRenderImpl *)iface;
|
|
|
|
|
|
|
|
/* Our pins are static, not changing so setting static tick count is ok */
|
|
|
|
*lastsynctick = 0;
|
|
|
|
|
|
|
|
if (pos >= 1)
|
|
|
|
return S_FALSE;
|
|
|
|
|
|
|
|
*pin = (IPin *)This->pInputPin;
|
|
|
|
IPin_AddRef(*pin);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2004-08-24 04:28:35 +02:00
|
|
|
static HRESULT WINAPI DSoundRender_EnumPins(IBaseFilter * iface, IEnumPins **ppEnum)
|
|
|
|
{
|
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);
|
|
|
|
|
2008-04-25 23:25:49 +02:00
|
|
|
return IEnumPinsImpl_Construct(ppEnum, DSoundRender_GetPin, iface);
|
2004-08-24 04:28:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
};
|
|
|
|
|
2007-04-13 18:32:56 +02:00
|
|
|
static HRESULT WINAPI DSoundRender_InputPin_ReceiveConnection(IPin * iface, IPin * pReceivePin, const AM_MEDIA_TYPE * pmt)
|
|
|
|
{
|
|
|
|
InputPin *This = (InputPin *)iface;
|
|
|
|
PIN_DIRECTION pindirReceive;
|
|
|
|
DSoundRenderImpl *DSImpl;
|
|
|
|
HRESULT hr = S_OK;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p, %p)\n", This, pReceivePin, pmt);
|
|
|
|
dump_AM_MEDIA_TYPE(pmt);
|
|
|
|
|
|
|
|
EnterCriticalSection(This->pin.pCritSec);
|
|
|
|
{
|
|
|
|
DSImpl = (DSoundRenderImpl*)This->pin.pinInfo.pFilter;
|
2008-04-16 23:27:06 +02:00
|
|
|
DSImpl->rtLastStop = -1;
|
2007-04-13 18:32:56 +02:00
|
|
|
|
|
|
|
if (This->pin.pConnectedTo)
|
|
|
|
hr = VFW_E_ALREADY_CONNECTED;
|
|
|
|
|
|
|
|
if (SUCCEEDED(hr) && This->pin.fnQueryAccept(This->pin.pUserData, pmt) != S_OK)
|
|
|
|
hr = VFW_E_TYPE_NOT_ACCEPTED;
|
|
|
|
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
IPin_QueryDirection(pReceivePin, &pindirReceive);
|
|
|
|
|
|
|
|
if (pindirReceive != PINDIR_OUTPUT)
|
|
|
|
{
|
|
|
|
ERR("Can't connect from non-output pin\n");
|
|
|
|
hr = VFW_E_INVALID_DIRECTION;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
WAVEFORMATEX *format;
|
|
|
|
DSBUFFERDESC buf_desc;
|
|
|
|
|
|
|
|
TRACE("MajorType %s\n", debugstr_guid(&pmt->majortype));
|
|
|
|
TRACE("SubType %s\n", debugstr_guid(&pmt->subtype));
|
|
|
|
TRACE("Format %s\n", debugstr_guid(&pmt->formattype));
|
|
|
|
TRACE("Size %d\n", pmt->cbFormat);
|
|
|
|
|
|
|
|
format = (WAVEFORMATEX*)pmt->pbFormat;
|
|
|
|
|
|
|
|
DSImpl->buf_size = format->nAvgBytesPerSec;
|
|
|
|
|
|
|
|
memset(&buf_desc,0,sizeof(DSBUFFERDESC));
|
|
|
|
buf_desc.dwSize = sizeof(DSBUFFERDESC);
|
|
|
|
buf_desc.dwFlags = DSBCAPS_CTRLVOLUME | DSBCAPS_CTRLPAN |
|
|
|
|
DSBCAPS_CTRLFREQUENCY |
|
|
|
|
DSBCAPS_GETCURRENTPOSITION2;
|
|
|
|
buf_desc.dwBufferBytes = DSImpl->buf_size;
|
|
|
|
buf_desc.lpwfxFormat = format;
|
|
|
|
hr = IDirectSound_CreateSoundBuffer(DSImpl->dsound, &buf_desc, &DSImpl->dsbuffer, NULL);
|
|
|
|
if (FAILED(hr))
|
|
|
|
ERR("Can't create sound buffer (%x)\n", hr);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
hr = IDirectSoundBuffer_SetVolume(DSImpl->dsbuffer, DSImpl->volume);
|
|
|
|
if (FAILED(hr))
|
|
|
|
ERR("Can't set volume to %ld (%x)\n", DSImpl->volume, hr);
|
|
|
|
|
|
|
|
hr = IDirectSoundBuffer_SetPan(DSImpl->dsbuffer, DSImpl->pan);
|
|
|
|
if (FAILED(hr))
|
|
|
|
ERR("Can't set pan to %ld (%x)\n", DSImpl->pan, hr);
|
|
|
|
|
|
|
|
DSImpl->write_pos = 0;
|
|
|
|
hr = S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
CopyMediaType(&This->pin.mtCurrent, pmt);
|
|
|
|
This->pin.pConnectedTo = pReceivePin;
|
|
|
|
IPin_AddRef(pReceivePin);
|
|
|
|
}
|
2008-06-17 02:16:38 +02:00
|
|
|
else if (hr != VFW_E_ALREADY_CONNECTED)
|
2007-04-13 18:32:56 +02:00
|
|
|
{
|
|
|
|
if (DSImpl->dsbuffer)
|
|
|
|
IDirectSoundBuffer_Release(DSImpl->dsbuffer);
|
|
|
|
DSImpl->dsbuffer = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
LeaveCriticalSection(This->pin.pCritSec);
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI DSoundRender_InputPin_Disconnect(IPin * iface)
|
|
|
|
{
|
|
|
|
IPinImpl *This = (IPinImpl*)iface;
|
|
|
|
DSoundRenderImpl *DSImpl;
|
|
|
|
|
|
|
|
TRACE("(%p)->()\n", iface);
|
|
|
|
|
|
|
|
DSImpl = (DSoundRenderImpl*)This->pinInfo.pFilter;
|
|
|
|
if (DSImpl->dsbuffer)
|
|
|
|
IDirectSoundBuffer_Release(DSImpl->dsbuffer);
|
|
|
|
DSImpl->dsbuffer = NULL;
|
|
|
|
|
|
|
|
return IPinImpl_Disconnect(iface);
|
|
|
|
}
|
|
|
|
|
2004-08-24 04:28:35 +02:00
|
|
|
static HRESULT WINAPI DSoundRender_InputPin_EndOfStream(IPin * iface)
|
|
|
|
{
|
|
|
|
InputPin* This = (InputPin*)iface;
|
2008-03-21 22:56:40 +01:00
|
|
|
DSoundRenderImpl *me = (DSoundRenderImpl*)This->pin.pinInfo.pFilter;
|
2005-03-02 11:12:12 +01:00
|
|
|
IMediaEventSink* pEventSink;
|
|
|
|
HRESULT hr;
|
|
|
|
|
2008-04-09 01:48:00 +02:00
|
|
|
EnterCriticalSection(This->pin.pCritSec);
|
|
|
|
|
2004-08-24 04:28:35 +02:00
|
|
|
TRACE("(%p/%p)->()\n", This, iface);
|
2008-07-09 19:21:30 +02:00
|
|
|
hr = InputPin_EndOfStream(iface);
|
|
|
|
if (hr != S_OK)
|
|
|
|
{
|
|
|
|
ERR("%08x\n", hr);
|
2008-07-11 00:10:02 +02:00
|
|
|
LeaveCriticalSection(This->pin.pCritSec);
|
2008-07-09 19:21:30 +02:00
|
|
|
return hr;
|
|
|
|
}
|
2005-03-02 11:12:12 +01:00
|
|
|
|
2008-03-21 22:56:40 +01:00
|
|
|
hr = IFilterGraph_QueryInterface(me->filterInfo.pGraph, &IID_IMediaEventSink, (LPVOID*)&pEventSink);
|
2005-03-02 11:12:12 +01:00
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
2008-03-21 22:56:40 +01:00
|
|
|
BYTE * silence;
|
|
|
|
|
|
|
|
silence = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, me->buf_size);
|
|
|
|
if (silence)
|
|
|
|
{
|
|
|
|
memset(silence, 0, me->buf_size);
|
|
|
|
DSoundRender_SendSampleData((DSoundRenderImpl*)This->pin.pinInfo.pFilter, silence, me->buf_size);
|
|
|
|
HeapFree(GetProcessHeap(), 0, silence);
|
|
|
|
}
|
|
|
|
|
2005-03-02 11:12:12 +01:00
|
|
|
hr = IMediaEventSink_Notify(pEventSink, EC_COMPLETE, S_OK, 0);
|
|
|
|
IMediaEventSink_Release(pEventSink);
|
|
|
|
}
|
2008-04-09 01:48:00 +02:00
|
|
|
LeaveCriticalSection(This->pin.pCritSec);
|
2005-03-02 11:12:12 +01:00
|
|
|
|
|
|
|
return hr;
|
2004-08-24 04:28:35 +02:00
|
|
|
}
|
|
|
|
|
2008-04-05 01:27:29 +02:00
|
|
|
static HRESULT WINAPI DSoundRender_InputPin_BeginFlush(IPin * iface)
|
|
|
|
{
|
|
|
|
InputPin *This = (InputPin *)iface;
|
|
|
|
DSoundRenderImpl *pFilter = (DSoundRenderImpl *)This->pin.pinInfo.pFilter;
|
|
|
|
HRESULT hr;
|
2008-04-09 01:48:00 +02:00
|
|
|
LPBYTE buffer;
|
|
|
|
DWORD size;
|
2008-04-05 01:27:29 +02:00
|
|
|
|
2008-04-08 07:30:30 +02:00
|
|
|
TRACE("\n");
|
2008-04-05 01:27:29 +02:00
|
|
|
|
|
|
|
EnterCriticalSection(This->pin.pCritSec);
|
2008-04-09 01:48:00 +02:00
|
|
|
hr = InputPin_BeginFlush(iface);
|
|
|
|
|
2008-04-05 01:27:29 +02:00
|
|
|
if (pFilter->dsbuffer)
|
2008-04-09 01:48:00 +02:00
|
|
|
{
|
2008-04-05 01:27:29 +02:00
|
|
|
IDirectSoundBuffer_Stop(pFilter->dsbuffer);
|
2008-04-09 01:48:00 +02:00
|
|
|
|
|
|
|
/* Force a reset */
|
|
|
|
IDirectSoundBuffer_SetCurrentPosition(pFilter->dsbuffer, 0);
|
|
|
|
pFilter->write_pos = pFilter->last_play_pos = 0;
|
|
|
|
++pFilter->play_loops;
|
|
|
|
pFilter->write_loops = pFilter->play_loops;
|
|
|
|
|
|
|
|
IDirectSoundBuffer_Lock(pFilter->dsbuffer, 0, 0, (LPVOID *)&buffer, &size, NULL, NULL, DSBLOCK_ENTIREBUFFER);
|
|
|
|
memset(buffer, 0, size);
|
|
|
|
IDirectSoundBuffer_Unlock(pFilter->dsbuffer, buffer, size, NULL, 0);
|
|
|
|
}
|
2008-07-04 09:09:07 +02:00
|
|
|
|
|
|
|
if (pFilter->state == State_Paused)
|
|
|
|
SetEvent(pFilter->blocked);
|
|
|
|
LeaveCriticalSection(This->pin.pCritSec);
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI DSoundRender_InputPin_EndFlush(IPin * iface)
|
|
|
|
{
|
|
|
|
InputPin *This = (InputPin *)iface;
|
|
|
|
DSoundRenderImpl *pFilter = (DSoundRenderImpl *)This->pin.pinInfo.pFilter;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("\n");
|
|
|
|
|
|
|
|
EnterCriticalSection(This->pin.pCritSec);
|
|
|
|
hr = InputPin_EndFlush(iface);
|
|
|
|
|
|
|
|
if (pFilter->state == State_Paused)
|
|
|
|
SetEvent(pFilter->blocked);
|
2008-04-05 01:27:29 +02:00
|
|
|
LeaveCriticalSection(This->pin.pCritSec);
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2007-04-13 18:32:56 +02:00
|
|
|
static const IPinVtbl DSoundRender_InputPin_Vtbl =
|
2004-08-24 04:28:35 +02:00
|
|
|
{
|
|
|
|
InputPin_QueryInterface,
|
|
|
|
IPinImpl_AddRef,
|
|
|
|
InputPin_Release,
|
|
|
|
InputPin_Connect,
|
2007-04-13 18:32:56 +02:00
|
|
|
DSoundRender_InputPin_ReceiveConnection,
|
|
|
|
DSoundRender_InputPin_Disconnect,
|
2004-08-24 04:28:35 +02:00
|
|
|
IPinImpl_ConnectedTo,
|
|
|
|
IPinImpl_ConnectionMediaType,
|
|
|
|
IPinImpl_QueryPinInfo,
|
|
|
|
IPinImpl_QueryDirection,
|
|
|
|
IPinImpl_QueryId,
|
|
|
|
IPinImpl_QueryAccept,
|
|
|
|
IPinImpl_EnumMediaTypes,
|
|
|
|
IPinImpl_QueryInternalConnections,
|
|
|
|
DSoundRender_InputPin_EndOfStream,
|
2008-04-05 01:27:29 +02:00
|
|
|
DSoundRender_InputPin_BeginFlush,
|
2008-07-04 09:09:07 +02:00
|
|
|
DSoundRender_InputPin_EndFlush,
|
2004-08-24 04:28:35 +02:00
|
|
|
InputPin_NewSegment
|
|
|
|
};
|
|
|
|
|
|
|
|
/*** 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,
|
2009-03-11 00:31:26 +01:00
|
|
|
LONG lVolume) {
|
2004-08-24 04:28:35 +02:00
|
|
|
ICOM_THIS_MULTI(DSoundRenderImpl, IBasicAudio_vtbl, iface);
|
|
|
|
|
2009-03-11 00:31:26 +01:00
|
|
|
TRACE("(%p/%p)->(%d)\n", This, iface, lVolume);
|
2007-03-26 05:13:53 +02:00
|
|
|
|
|
|
|
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,
|
2009-03-11 00:31:26 +01:00
|
|
|
LONG *plVolume) {
|
2004-08-24 04:28:35 +02:00
|
|
|
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,
|
2009-03-11 00:31:26 +01:00
|
|
|
LONG lBalance) {
|
2004-08-24 04:28:35 +02:00
|
|
|
ICOM_THIS_MULTI(DSoundRenderImpl, IBasicAudio_vtbl, iface);
|
|
|
|
|
2009-03-11 00:31:26 +01:00
|
|
|
TRACE("(%p/%p)->(%d)\n", This, iface, lBalance);
|
2007-03-26 05:13:53 +02:00
|
|
|
|
|
|
|
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,
|
2009-03-11 00:31:26 +01:00
|
|
|
LONG *plBalance) {
|
2004-08-24 04:28:35 +02:00
|
|
|
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
|
|
|
|
};
|
2007-04-06 12:48:03 +02:00
|
|
|
|
|
|
|
|
|
|
|
/*** IUnknown methods ***/
|
|
|
|
static HRESULT WINAPI ReferenceClock_QueryInterface(IReferenceClock *iface,
|
|
|
|
REFIID riid,
|
|
|
|
LPVOID*ppvObj)
|
|
|
|
{
|
|
|
|
ICOM_THIS_MULTI(DSoundRenderImpl, IReferenceClock_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 ReferenceClock_AddRef(IReferenceClock *iface)
|
|
|
|
{
|
|
|
|
ICOM_THIS_MULTI(DSoundRenderImpl, IReferenceClock_vtbl, iface);
|
|
|
|
|
|
|
|
TRACE("(%p/%p)->()\n", This, iface);
|
|
|
|
|
|
|
|
return DSoundRender_AddRef((IBaseFilter*)This);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI ReferenceClock_Release(IReferenceClock *iface)
|
|
|
|
{
|
|
|
|
ICOM_THIS_MULTI(DSoundRenderImpl, IReferenceClock_vtbl, iface);
|
|
|
|
|
|
|
|
TRACE("(%p/%p)->()\n", This, iface);
|
|
|
|
|
|
|
|
return DSoundRender_Release((IBaseFilter*)This);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*** IReferenceClock methods ***/
|
|
|
|
static HRESULT WINAPI ReferenceClock_GetTime(IReferenceClock *iface,
|
|
|
|
REFERENCE_TIME *pTime)
|
|
|
|
{
|
|
|
|
ICOM_THIS_MULTI(DSoundRenderImpl, IReferenceClock_vtbl, iface);
|
|
|
|
HRESULT hr = E_FAIL;
|
|
|
|
DWORD play_pos;
|
|
|
|
|
|
|
|
TRACE("(%p/%p)->(%p)\n", This, iface, pTime);
|
|
|
|
|
|
|
|
if (This->dsbuffer)
|
2008-04-05 01:27:29 +02:00
|
|
|
hr = DSoundRender_GetPos(This, &play_pos, pTime);
|
2007-04-06 12:48:03 +02:00
|
|
|
if (FAILED(hr))
|
2008-03-14 04:25:36 +01:00
|
|
|
ERR("Could not get reference time (%x)!\n", hr);
|
2007-04-06 12:48:03 +02:00
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ReferenceClock_AdviseTime(IReferenceClock *iface,
|
|
|
|
REFERENCE_TIME rtBaseTime,
|
|
|
|
REFERENCE_TIME rtStreamTime,
|
|
|
|
HEVENT hEvent,
|
|
|
|
DWORD_PTR *pdwAdviseCookie)
|
|
|
|
{
|
|
|
|
ICOM_THIS_MULTI(DSoundRenderImpl, IReferenceClock_vtbl, iface);
|
|
|
|
|
|
|
|
FIXME("(%p/%p)->(%s, %s, %p, %p): stub!\n", This, iface, wine_dbgstr_longlong(rtBaseTime), wine_dbgstr_longlong(rtStreamTime), (void*)hEvent, pdwAdviseCookie);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ReferenceClock_AdvisePeriodic(IReferenceClock *iface,
|
|
|
|
REFERENCE_TIME rtBaseTime,
|
|
|
|
REFERENCE_TIME rtStreamTime,
|
|
|
|
HSEMAPHORE hSemaphore,
|
|
|
|
DWORD_PTR *pdwAdviseCookie)
|
|
|
|
{
|
|
|
|
ICOM_THIS_MULTI(DSoundRenderImpl, IReferenceClock_vtbl, iface);
|
|
|
|
|
|
|
|
FIXME("(%p/%p)->(%s, %s, %p, %p): stub!\n", This, iface, wine_dbgstr_longlong(rtBaseTime), wine_dbgstr_longlong(rtStreamTime), (void*)hSemaphore, pdwAdviseCookie);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ReferenceClock_Unadvise(IReferenceClock *iface,
|
|
|
|
DWORD_PTR dwAdviseCookie)
|
|
|
|
{
|
|
|
|
ICOM_THIS_MULTI(DSoundRenderImpl, IReferenceClock_vtbl, iface);
|
|
|
|
|
|
|
|
FIXME("(%p/%p)->(%p): stub!\n", This, iface, (void*)dwAdviseCookie);
|
|
|
|
|
|
|
|
return S_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IReferenceClockVtbl IReferenceClock_Vtbl =
|
|
|
|
{
|
|
|
|
ReferenceClock_QueryInterface,
|
|
|
|
ReferenceClock_AddRef,
|
|
|
|
ReferenceClock_Release,
|
|
|
|
ReferenceClock_GetTime,
|
|
|
|
ReferenceClock_AdviseTime,
|
|
|
|
ReferenceClock_AdvisePeriodic,
|
|
|
|
ReferenceClock_Unadvise
|
|
|
|
};
|
2008-03-20 02:29:09 +01:00
|
|
|
|
|
|
|
static inline DSoundRenderImpl *impl_from_IMediaSeeking( IMediaSeeking *iface )
|
|
|
|
{
|
|
|
|
return (DSoundRenderImpl *)((char*)iface - FIELD_OFFSET(DSoundRenderImpl, mediaSeeking.lpVtbl));
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI sound_seek_QueryInterface(IMediaSeeking * iface, REFIID riid, LPVOID * ppv)
|
|
|
|
{
|
|
|
|
DSoundRenderImpl *This = impl_from_IMediaSeeking(iface);
|
|
|
|
|
|
|
|
return IUnknown_QueryInterface((IUnknown *)This, riid, ppv);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI sound_seek_AddRef(IMediaSeeking * iface)
|
|
|
|
{
|
|
|
|
DSoundRenderImpl *This = impl_from_IMediaSeeking(iface);
|
|
|
|
|
|
|
|
return IUnknown_AddRef((IUnknown *)This);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI sound_seek_Release(IMediaSeeking * iface)
|
|
|
|
{
|
|
|
|
DSoundRenderImpl *This = impl_from_IMediaSeeking(iface);
|
|
|
|
|
|
|
|
return IUnknown_Release((IUnknown *)This);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IMediaSeekingVtbl IMediaSeeking_Vtbl =
|
|
|
|
{
|
|
|
|
sound_seek_QueryInterface,
|
|
|
|
sound_seek_AddRef,
|
|
|
|
sound_seek_Release,
|
|
|
|
MediaSeekingImpl_GetCapabilities,
|
|
|
|
MediaSeekingImpl_CheckCapabilities,
|
|
|
|
MediaSeekingImpl_IsFormatSupported,
|
|
|
|
MediaSeekingImpl_QueryPreferredFormat,
|
|
|
|
MediaSeekingImpl_GetTimeFormat,
|
|
|
|
MediaSeekingImpl_IsUsingTimeFormat,
|
|
|
|
MediaSeekingImpl_SetTimeFormat,
|
|
|
|
MediaSeekingImpl_GetDuration,
|
|
|
|
MediaSeekingImpl_GetStopPosition,
|
|
|
|
MediaSeekingImpl_GetCurrentPosition,
|
|
|
|
MediaSeekingImpl_ConvertTimeFormat,
|
|
|
|
MediaSeekingImpl_SetPositions,
|
|
|
|
MediaSeekingImpl_GetPositions,
|
|
|
|
MediaSeekingImpl_GetAvailable,
|
|
|
|
MediaSeekingImpl_SetRate,
|
|
|
|
MediaSeekingImpl_GetRate,
|
|
|
|
MediaSeekingImpl_GetPreroll
|
|
|
|
};
|