2003-04-08 23:42:00 +02:00
|
|
|
/* IDirectMusicPerformance Implementation
|
|
|
|
*
|
2004-01-20 01:21:40 +01:00
|
|
|
* Copyright (C) 2003-2004 Rok Mandeljc
|
2004-05-12 00:18:43 +02:00
|
|
|
* Copyright (C) 2003-2004 Raphael Junqueira
|
2003-04-08 23:42:00 +02:00
|
|
|
*
|
2007-05-30 12:54:07 +02:00
|
|
|
* This program 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.
|
2003-04-08 23:42:00 +02:00
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2007-05-30 12:54:07 +02:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
2003-04-08 23:42:00 +02:00
|
|
|
*
|
2007-05-30 12:54:07 +02:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2003-04-08 23:42:00 +02:00
|
|
|
*/
|
|
|
|
|
2003-07-22 00:10:14 +02:00
|
|
|
#include "dmime_private.h"
|
2003-04-08 23:42:00 +02:00
|
|
|
|
2003-08-23 01:53:27 +02:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(dmime);
|
2003-04-08 23:42:00 +02:00
|
|
|
|
2012-04-02 00:08:57 +02:00
|
|
|
typedef struct IDirectMusicPerformance8Impl {
|
|
|
|
IDirectMusicPerformance8 IDirectMusicPerformance8_iface;
|
|
|
|
LONG ref;
|
2017-05-11 11:05:45 +02:00
|
|
|
IDirectMusic8 *dmusic;
|
2017-05-11 11:05:46 +02:00
|
|
|
IDirectSound *dsound;
|
2012-04-02 00:08:57 +02:00
|
|
|
IDirectMusicGraph *pToolGraph;
|
2017-05-11 11:05:49 +02:00
|
|
|
DMUS_AUDIOPARAMS params;
|
2012-04-02 00:08:57 +02:00
|
|
|
BOOL fAutoDownload;
|
|
|
|
char cMasterGrooveLevel;
|
|
|
|
float fMasterTempo;
|
|
|
|
long lMasterVolume;
|
|
|
|
/* performance channels */
|
|
|
|
DMUSIC_PRIVATE_PCHANNEL PChannel[32];
|
|
|
|
/* IDirectMusicPerformance8Impl fields */
|
|
|
|
IDirectMusicAudioPath *pDefaultPath;
|
|
|
|
HANDLE hNotification;
|
|
|
|
REFERENCE_TIME rtMinimum;
|
|
|
|
REFERENCE_TIME rtLatencyTime;
|
|
|
|
DWORD dwBumperLength;
|
|
|
|
DWORD dwPrepareTime;
|
|
|
|
/** Message Processing */
|
|
|
|
HANDLE procThread;
|
|
|
|
DWORD procThreadId;
|
|
|
|
REFERENCE_TIME procThreadStartTime;
|
|
|
|
BOOL procThreadTicStarted;
|
|
|
|
CRITICAL_SECTION safe;
|
|
|
|
struct DMUS_PMSGItem *head;
|
|
|
|
struct DMUS_PMSGItem *imm_head;
|
|
|
|
} IDirectMusicPerformance8Impl;
|
|
|
|
|
2004-05-07 01:37:54 +02:00
|
|
|
typedef struct DMUS_PMSGItem DMUS_PMSGItem;
|
|
|
|
struct DMUS_PMSGItem {
|
|
|
|
DMUS_PMSGItem* next;
|
|
|
|
DMUS_PMSGItem* prev;
|
|
|
|
|
|
|
|
REFERENCE_TIME rtItemTime;
|
|
|
|
BOOL bInUse;
|
|
|
|
DWORD cb;
|
|
|
|
DMUS_PMSG pMsg;
|
|
|
|
};
|
2003-04-08 23:42:00 +02:00
|
|
|
|
2004-05-07 01:37:54 +02:00
|
|
|
#define DMUS_PMSGToItem(pMSG) ((DMUS_PMSGItem*) (((unsigned char*) pPMSG) - offsetof(DMUS_PMSGItem, pMsg)))
|
|
|
|
#define DMUS_ItemToPMSG(pItem) (&(pItem->pMsg))
|
|
|
|
#define DMUS_ItemRemoveFromQueue(This,pItem) \
|
|
|
|
{\
|
|
|
|
if (pItem->prev) pItem->prev->next = pItem->next;\
|
|
|
|
if (pItem->next) pItem->next->prev = pItem->prev;\
|
|
|
|
if (This->head == pItem) This->head = pItem->next;\
|
|
|
|
if (This->imm_head == pItem) This->imm_head = pItem->next;\
|
|
|
|
pItem->bInUse = FALSE;\
|
|
|
|
}
|
|
|
|
|
|
|
|
#define PROCESSMSG_START (WM_APP + 0)
|
|
|
|
#define PROCESSMSG_EXIT (WM_APP + 1)
|
|
|
|
#define PROCESSMSG_REMOVE (WM_APP + 2)
|
|
|
|
#define PROCESSMSG_ADD (WM_APP + 4)
|
|
|
|
|
|
|
|
|
2004-05-27 03:54:16 +02:00
|
|
|
static DMUS_PMSGItem* ProceedMsg(IDirectMusicPerformance8Impl* This, DMUS_PMSGItem* cur) {
|
2004-05-07 01:37:54 +02:00
|
|
|
if (cur->pMsg.dwType == DMUS_PMSGT_NOTIFICATION) {
|
|
|
|
SetEvent(This->hNotification);
|
|
|
|
}
|
|
|
|
DMUS_ItemRemoveFromQueue(This, cur);
|
|
|
|
switch (cur->pMsg.dwType) {
|
2004-05-27 03:54:16 +02:00
|
|
|
case DMUS_PMSGT_WAVE:
|
|
|
|
case DMUS_PMSGT_TEMPO:
|
2004-05-07 01:37:54 +02:00
|
|
|
case DMUS_PMSGT_STOP:
|
|
|
|
default:
|
2006-10-10 01:07:26 +02:00
|
|
|
FIXME("Unhandled PMsg Type: 0x%x\n", cur->pMsg.dwType);
|
2004-05-07 01:37:54 +02:00
|
|
|
break;
|
|
|
|
}
|
2004-05-27 03:54:16 +02:00
|
|
|
return cur;
|
2004-05-07 01:37:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static DWORD WINAPI ProcessMsgThread(LPVOID lpParam) {
|
2009-01-13 10:56:24 +01:00
|
|
|
IDirectMusicPerformance8Impl* This = lpParam;
|
2004-05-27 03:54:16 +02:00
|
|
|
DWORD timeOut = INFINITE;
|
2004-05-07 01:37:54 +02:00
|
|
|
MSG msg;
|
|
|
|
HRESULT hr;
|
|
|
|
REFERENCE_TIME rtCurTime;
|
|
|
|
DMUS_PMSGItem* it = NULL;
|
2004-05-27 03:54:16 +02:00
|
|
|
DMUS_PMSGItem* cur = NULL;
|
2004-05-07 01:37:54 +02:00
|
|
|
DMUS_PMSGItem* it_next = NULL;
|
|
|
|
|
|
|
|
while (TRUE) {
|
|
|
|
DWORD dwDec = This->rtLatencyTime + This->dwBumperLength;
|
|
|
|
|
2004-05-27 03:54:16 +02:00
|
|
|
if (timeOut > 0) MsgWaitForMultipleObjects(0, NULL, FALSE, timeOut, QS_POSTMESSAGE|QS_SENDMESSAGE|QS_TIMER);
|
|
|
|
timeOut = INFINITE;
|
|
|
|
|
2004-05-07 01:37:54 +02:00
|
|
|
EnterCriticalSection(&This->safe);
|
2012-04-02 00:03:00 +02:00
|
|
|
hr = IDirectMusicPerformance8_GetTime(&This->IDirectMusicPerformance8_iface, &rtCurTime, NULL);
|
2004-05-07 01:37:54 +02:00
|
|
|
if (FAILED(hr)) {
|
|
|
|
goto outrefresh;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (it = This->imm_head; NULL != it; ) {
|
|
|
|
it_next = it->next;
|
2004-05-27 03:54:16 +02:00
|
|
|
cur = ProceedMsg(This, it);
|
2005-01-03 15:56:42 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, cur);
|
2004-05-07 01:37:54 +02:00
|
|
|
it = it_next;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (it = This->head; NULL != it && it->rtItemTime < rtCurTime + dwDec; ) {
|
|
|
|
it_next = it->next;
|
2004-05-27 03:54:16 +02:00
|
|
|
cur = ProceedMsg(This, it);
|
2005-01-03 15:56:42 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, cur);
|
2004-05-07 01:37:54 +02:00
|
|
|
it = it_next;
|
|
|
|
}
|
2004-05-27 03:54:16 +02:00
|
|
|
if (NULL != it) {
|
|
|
|
timeOut = ( it->rtItemTime - rtCurTime ) + This->rtLatencyTime;
|
|
|
|
}
|
2004-05-07 01:37:54 +02:00
|
|
|
|
|
|
|
outrefresh:
|
|
|
|
LeaveCriticalSection(&This->safe);
|
|
|
|
|
2004-12-09 15:07:59 +01:00
|
|
|
while (PeekMessageA(&msg, NULL, 0, 0, PM_REMOVE)) {
|
2004-05-07 01:37:54 +02:00
|
|
|
/** if hwnd we suppose that is a windows event ... */
|
|
|
|
if (NULL != msg.hwnd) {
|
|
|
|
TranslateMessage(&msg);
|
|
|
|
DispatchMessageA(&msg);
|
|
|
|
} else {
|
|
|
|
switch (msg.message) {
|
|
|
|
case WM_QUIT:
|
|
|
|
case PROCESSMSG_EXIT:
|
|
|
|
goto outofthread;
|
|
|
|
case PROCESSMSG_START:
|
|
|
|
break;
|
|
|
|
case PROCESSMSG_ADD:
|
|
|
|
break;
|
|
|
|
case PROCESSMSG_REMOVE:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ERR("Unhandled message %u. Critical Path\n", msg.message);
|
|
|
|
break;
|
2003-04-08 23:42:00 +02:00
|
|
|
}
|
2004-05-07 01:37:54 +02:00
|
|
|
}
|
|
|
|
}
|
2004-05-27 03:54:16 +02:00
|
|
|
|
|
|
|
/** here we should run a little of current AudioPath */
|
|
|
|
|
2004-05-07 01:37:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
outofthread:
|
|
|
|
TRACE("(%p): Exiting\n", This);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL PostMessageToProcessMsgThread(IDirectMusicPerformance8Impl* This, UINT iMsg) {
|
|
|
|
if (FALSE == This->procThreadTicStarted && PROCESSMSG_EXIT != iMsg) {
|
2005-01-11 16:07:30 +01:00
|
|
|
BOOL res;
|
2004-05-07 01:37:54 +02:00
|
|
|
This->procThread = CreateThread(NULL, 0, ProcessMsgThread, This, 0, &This->procThreadId);
|
|
|
|
if (NULL == This->procThread) return FALSE;
|
|
|
|
SetThreadPriority(This->procThread, THREAD_PRIORITY_TIME_CRITICAL);
|
|
|
|
This->procThreadTicStarted = TRUE;
|
2005-01-11 16:07:30 +01:00
|
|
|
while(1) {
|
|
|
|
res = PostThreadMessageA(This->procThreadId, iMsg, 0, 0);
|
|
|
|
/* Let the thread creates its message queue (with MsgWaitForMultipleObjects call) by yielding and retrying */
|
|
|
|
if (!res && (GetLastError() == ERROR_INVALID_THREAD_ID))
|
|
|
|
Sleep(0);
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return res;
|
2004-05-07 01:37:54 +02:00
|
|
|
}
|
|
|
|
return PostThreadMessageA(This->procThreadId, iMsg, 0, 0);
|
|
|
|
}
|
|
|
|
|
2012-04-02 00:03:00 +02:00
|
|
|
static inline IDirectMusicPerformance8Impl *impl_from_IDirectMusicPerformance8(IDirectMusicPerformance8 *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, IDirectMusicPerformance8Impl, IDirectMusicPerformance8_iface);
|
|
|
|
}
|
|
|
|
|
2004-05-07 01:37:54 +02:00
|
|
|
/* IDirectMusicPerformance8 IUnknown part: */
|
2012-04-02 00:03:00 +02:00
|
|
|
static HRESULT WINAPI IDirectMusicPerformance8Impl_QueryInterface(IDirectMusicPerformance8 *iface,
|
|
|
|
REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
TRACE("(%p, %s,%p)\n", iface, debugstr_dmguid(riid), ppv);
|
2004-05-07 01:37:54 +02:00
|
|
|
|
2012-04-02 00:03:00 +02:00
|
|
|
if (IsEqualIID (riid, &IID_IUnknown) ||
|
2004-05-07 01:37:54 +02:00
|
|
|
IsEqualIID (riid, &IID_IDirectMusicPerformance) ||
|
2006-07-25 23:48:28 +02:00
|
|
|
IsEqualIID (riid, &IID_IDirectMusicPerformance2) ||
|
2004-05-07 01:37:54 +02:00
|
|
|
IsEqualIID (riid, &IID_IDirectMusicPerformance8)) {
|
2012-04-02 00:03:00 +02:00
|
|
|
*ppv = iface;
|
2005-06-21 11:44:28 +02:00
|
|
|
IUnknown_AddRef(iface);
|
2004-05-07 01:37:54 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
2012-04-02 00:03:00 +02:00
|
|
|
|
|
|
|
WARN("(%p, %s,%p): not found\n", iface, debugstr_dmguid(riid), ppv);
|
2004-05-07 01:37:54 +02:00
|
|
|
return E_NOINTERFACE;
|
2003-04-08 23:42:00 +02:00
|
|
|
}
|
|
|
|
|
2012-04-02 00:03:00 +02:00
|
|
|
static ULONG WINAPI IDirectMusicPerformance8Impl_AddRef(IDirectMusicPerformance8 *iface)
|
|
|
|
{
|
|
|
|
IDirectMusicPerformance8Impl *This = impl_from_IDirectMusicPerformance8(iface);
|
2005-01-11 17:02:21 +01:00
|
|
|
ULONG ref = InterlockedIncrement(&This->ref);
|
|
|
|
|
2006-10-10 01:07:26 +02:00
|
|
|
TRACE("(%p): AddRef from %d\n", This, ref - 1);
|
2005-01-11 17:02:21 +01:00
|
|
|
|
2005-02-02 10:31:06 +01:00
|
|
|
DMIME_LockModule();
|
|
|
|
|
2005-01-11 17:02:21 +01:00
|
|
|
return ref;
|
2003-04-08 23:42:00 +02:00
|
|
|
}
|
|
|
|
|
2012-04-02 00:03:00 +02:00
|
|
|
static ULONG WINAPI IDirectMusicPerformance8Impl_Release(IDirectMusicPerformance8 *iface)
|
|
|
|
{
|
|
|
|
IDirectMusicPerformance8Impl *This = impl_from_IDirectMusicPerformance8(iface);
|
2005-01-11 17:02:21 +01:00
|
|
|
ULONG ref = InterlockedDecrement(&This->ref);
|
2012-04-02 00:03:00 +02:00
|
|
|
|
2006-10-10 01:07:26 +02:00
|
|
|
TRACE("(%p): ReleaseRef to %d\n", This, ref);
|
2005-02-02 10:31:06 +01:00
|
|
|
|
2004-05-07 01:37:54 +02:00
|
|
|
if (ref == 0) {
|
2007-03-08 16:34:00 +01:00
|
|
|
This->safe.DebugInfo->Spare[0] = 0;
|
2004-05-07 01:37:54 +02:00
|
|
|
DeleteCriticalSection(&This->safe);
|
|
|
|
HeapFree(GetProcessHeap(), 0, This);
|
|
|
|
}
|
2005-02-02 10:31:06 +01:00
|
|
|
|
|
|
|
DMIME_UnlockModule();
|
|
|
|
|
2004-05-07 01:37:54 +02:00
|
|
|
return ref;
|
2003-04-08 23:42:00 +02:00
|
|
|
}
|
|
|
|
|
2004-01-20 01:21:40 +01:00
|
|
|
/* IDirectMusicPerformanceImpl IDirectMusicPerformance Interface part: */
|
2012-04-02 00:03:00 +02:00
|
|
|
static HRESULT WINAPI IDirectMusicPerformance8Impl_Init(IDirectMusicPerformance8 *iface,
|
2017-05-11 11:05:50 +02:00
|
|
|
IDirectMusic **dmusic, IDirectSound *dsound, HWND hwnd)
|
2012-04-02 00:03:00 +02:00
|
|
|
{
|
2017-05-11 11:05:50 +02:00
|
|
|
TRACE("(%p, %p, %p, %p)\n", iface, dmusic, dsound, hwnd);
|
2012-03-29 08:54:15 +02:00
|
|
|
|
2017-05-11 11:05:50 +02:00
|
|
|
return IDirectMusicPerformance8_InitAudio(iface, dmusic, dsound ? &dsound : NULL, hwnd, 0, 0,
|
|
|
|
0, NULL);
|
2003-04-08 23:42:00 +02:00
|
|
|
}
|
|
|
|
|
2012-04-02 00:03:00 +02:00
|
|
|
static HRESULT WINAPI IDirectMusicPerformance8Impl_PlaySegment(IDirectMusicPerformance8 *iface,
|
|
|
|
IDirectMusicSegment *pSegment, DWORD dwFlags, __int64 i64StartTime,
|
|
|
|
IDirectMusicSegmentState **ppSegmentState)
|
|
|
|
{
|
|
|
|
IDirectMusicPerformance8Impl *This = impl_from_IDirectMusicPerformance8(iface);
|
|
|
|
|
2006-10-10 01:07:26 +02:00
|
|
|
FIXME("(%p, %p, %d, 0x%s, %p): stub\n", This, pSegment, dwFlags,
|
2006-09-20 22:25:51 +02:00
|
|
|
wine_dbgstr_longlong(i64StartTime), ppSegmentState);
|
2008-12-14 19:00:15 +01:00
|
|
|
if (ppSegmentState)
|
2014-01-10 10:41:27 +01:00
|
|
|
return create_dmsegmentstate(&IID_IDirectMusicSegmentState,(void**)ppSegmentState);
|
2003-06-07 02:39:18 +02:00
|
|
|
return S_OK;
|
2003-04-08 23:42:00 +02:00
|
|
|
}
|
|
|
|
|
2012-04-02 00:03:00 +02:00
|
|
|
static HRESULT WINAPI IDirectMusicPerformance8Impl_Stop(IDirectMusicPerformance8 *iface,
|
|
|
|
IDirectMusicSegment *pSegment, IDirectMusicSegmentState *pSegmentState, MUSIC_TIME mtTime,
|
|
|
|
DWORD dwFlags)
|
|
|
|
{
|
|
|
|
IDirectMusicPerformance8Impl *This = impl_from_IDirectMusicPerformance8(iface);
|
|
|
|
|
2009-01-10 02:44:41 +01:00
|
|
|
FIXME("(%p, %p, %p, %d, %d): stub\n", This, pSegment, pSegmentState, mtTime, dwFlags);
|
2003-06-07 02:39:18 +02:00
|
|
|
return S_OK;
|
2003-04-08 23:42:00 +02:00
|
|
|
}
|
|
|
|
|
2012-04-02 00:03:00 +02:00
|
|
|
static HRESULT WINAPI IDirectMusicPerformance8Impl_GetSegmentState(IDirectMusicPerformance8 *iface,
|
|
|
|
IDirectMusicSegmentState **ppSegmentState, MUSIC_TIME mtTime)
|
|
|
|
{
|
|
|
|
IDirectMusicPerformance8Impl *This = impl_from_IDirectMusicPerformance8(iface);
|
|
|
|
|
2009-01-10 02:44:41 +01:00
|
|
|
FIXME("(%p,%p, %d): stub\n", This, ppSegmentState, mtTime);
|
2003-06-07 02:39:18 +02:00
|
|
|
return S_OK;
|
2003-04-08 23:42:00 +02:00
|
|
|
}
|
|
|
|
|
2012-04-02 00:03:00 +02:00
|
|
|
static HRESULT WINAPI IDirectMusicPerformance8Impl_SetPrepareTime(IDirectMusicPerformance8 *iface,
|
|
|
|
DWORD dwMilliSeconds)
|
|
|
|
{
|
|
|
|
IDirectMusicPerformance8Impl *This = impl_from_IDirectMusicPerformance8(iface);
|
|
|
|
|
2006-10-10 01:07:26 +02:00
|
|
|
TRACE("(%p, %d)\n", This, dwMilliSeconds);
|
2004-05-07 01:37:54 +02:00
|
|
|
This->dwPrepareTime = dwMilliSeconds;
|
|
|
|
return S_OK;
|
2003-04-08 23:42:00 +02:00
|
|
|
}
|
|
|
|
|
2012-04-02 00:03:00 +02:00
|
|
|
static HRESULT WINAPI IDirectMusicPerformance8Impl_GetPrepareTime(IDirectMusicPerformance8 *iface,
|
|
|
|
DWORD *pdwMilliSeconds)
|
|
|
|
{
|
|
|
|
IDirectMusicPerformance8Impl *This = impl_from_IDirectMusicPerformance8(iface);
|
|
|
|
|
2004-05-07 01:37:54 +02:00
|
|
|
TRACE("(%p, %p)\n", This, pdwMilliSeconds);
|
|
|
|
if (NULL == pdwMilliSeconds) {
|
|
|
|
return E_POINTER;
|
|
|
|
}
|
|
|
|
*pdwMilliSeconds = This->dwPrepareTime;
|
|
|
|
return S_OK;
|
2003-04-08 23:42:00 +02:00
|
|
|
}
|
|
|
|
|
2012-04-02 00:03:00 +02:00
|
|
|
static HRESULT WINAPI IDirectMusicPerformance8Impl_SetBumperLength(IDirectMusicPerformance8 *iface,
|
|
|
|
DWORD dwMilliSeconds)
|
|
|
|
{
|
|
|
|
IDirectMusicPerformance8Impl *This = impl_from_IDirectMusicPerformance8(iface);
|
|
|
|
|
2006-10-10 01:07:26 +02:00
|
|
|
TRACE("(%p, %d)\n", This, dwMilliSeconds);
|
2004-05-07 01:37:54 +02:00
|
|
|
This->dwBumperLength = dwMilliSeconds;
|
|
|
|
return S_OK;
|
2003-04-08 23:42:00 +02:00
|
|
|
}
|
|
|
|
|
2012-04-02 00:03:00 +02:00
|
|
|
static HRESULT WINAPI IDirectMusicPerformance8Impl_GetBumperLength(IDirectMusicPerformance8 *iface,
|
|
|
|
DWORD *pdwMilliSeconds)
|
|
|
|
{
|
|
|
|
IDirectMusicPerformance8Impl *This = impl_from_IDirectMusicPerformance8(iface);
|
|
|
|
|
2004-05-07 01:37:54 +02:00
|
|
|
TRACE("(%p, %p)\n", This, pdwMilliSeconds);
|
|
|
|
if (NULL == pdwMilliSeconds) {
|
|
|
|
return E_POINTER;
|
|
|
|
}
|
|
|
|
*pdwMilliSeconds = This->dwBumperLength;
|
|
|
|
return S_OK;
|
2003-04-08 23:42:00 +02:00
|
|
|
}
|
|
|
|
|
2012-04-02 00:03:00 +02:00
|
|
|
static HRESULT WINAPI IDirectMusicPerformance8Impl_SendPMsg(IDirectMusicPerformance8 *iface,
|
|
|
|
DMUS_PMSG *pPMSG)
|
|
|
|
{
|
|
|
|
IDirectMusicPerformance8Impl *This = impl_from_IDirectMusicPerformance8(iface);
|
2004-05-05 20:59:59 +02:00
|
|
|
DMUS_PMSGItem* pItem = NULL;
|
|
|
|
DMUS_PMSGItem* it = NULL;
|
|
|
|
DMUS_PMSGItem* prev_it = NULL;
|
|
|
|
DMUS_PMSGItem** queue = NULL;
|
|
|
|
|
|
|
|
FIXME("(%p, %p): stub\n", This, pPMSG);
|
|
|
|
|
|
|
|
if (NULL == pPMSG) {
|
|
|
|
return E_POINTER;
|
|
|
|
}
|
|
|
|
pItem = DMUS_PMSGToItem(pPMSG);
|
2004-12-09 15:07:59 +01:00
|
|
|
if (pItem->bInUse) {
|
2004-05-05 20:59:59 +02:00
|
|
|
return DMUS_E_ALREADY_SENT;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* TODO: Valid Flags */
|
|
|
|
/* TODO: DMUS_PMSGF_MUSICTIME */
|
|
|
|
pItem->rtItemTime = pPMSG->rtTime;
|
|
|
|
|
|
|
|
if (pPMSG->dwFlags & DMUS_PMSGF_TOOL_IMMEDIATE) {
|
|
|
|
queue = &This->imm_head;
|
|
|
|
} else {
|
|
|
|
queue = &This->head;
|
|
|
|
}
|
|
|
|
|
2004-05-07 01:37:54 +02:00
|
|
|
EnterCriticalSection(&This->safe);
|
2004-05-05 20:59:59 +02:00
|
|
|
for (it = *queue; NULL != it && it->rtItemTime < pItem->rtItemTime; it = it->next) {
|
|
|
|
prev_it = it;
|
|
|
|
}
|
|
|
|
if (NULL == prev_it) {
|
|
|
|
pItem->prev = NULL;
|
2004-05-07 01:37:54 +02:00
|
|
|
if (NULL != *queue) pItem->next = (*queue)->next;
|
2004-05-05 20:59:59 +02:00
|
|
|
/*assert( NULL == pItem->next->prev );*/
|
|
|
|
if (NULL != pItem->next) pItem->next->prev = pItem;
|
|
|
|
*queue = pItem;
|
|
|
|
} else {
|
|
|
|
pItem->prev = prev_it;
|
|
|
|
pItem->next = prev_it->next;
|
|
|
|
prev_it->next = pItem;
|
|
|
|
if (NULL != pItem->next) pItem->next->prev = pItem;
|
2004-05-07 01:37:54 +02:00
|
|
|
}
|
|
|
|
LeaveCriticalSection(&This->safe);
|
|
|
|
|
2004-05-05 20:59:59 +02:00
|
|
|
/** now in use, prevent from stupid Frees */
|
|
|
|
pItem->bInUse = TRUE;
|
|
|
|
return S_OK;
|
2003-04-08 23:42:00 +02:00
|
|
|
}
|
|
|
|
|
2012-04-02 00:03:00 +02:00
|
|
|
static HRESULT WINAPI IDirectMusicPerformance8Impl_MusicToReferenceTime(IDirectMusicPerformance8 *iface,
|
|
|
|
MUSIC_TIME mtTime, REFERENCE_TIME *prtTime)
|
|
|
|
{
|
|
|
|
IDirectMusicPerformance8Impl *This = impl_from_IDirectMusicPerformance8(iface);
|
|
|
|
|
2009-01-10 02:44:41 +01:00
|
|
|
FIXME("(%p, %d, %p): stub\n", This, mtTime, prtTime);
|
2003-06-07 02:39:18 +02:00
|
|
|
return S_OK;
|
2003-04-08 23:42:00 +02:00
|
|
|
}
|
|
|
|
|
2012-04-02 00:03:00 +02:00
|
|
|
static HRESULT WINAPI IDirectMusicPerformance8Impl_ReferenceToMusicTime(IDirectMusicPerformance8 *iface,
|
|
|
|
REFERENCE_TIME rtTime, MUSIC_TIME *pmtTime)
|
|
|
|
{
|
|
|
|
IDirectMusicPerformance8Impl *This = impl_from_IDirectMusicPerformance8(iface);
|
|
|
|
|
2006-09-20 22:25:51 +02:00
|
|
|
FIXME("(%p, 0x%s, %p): stub\n", This, wine_dbgstr_longlong(rtTime), pmtTime);
|
2003-06-07 02:39:18 +02:00
|
|
|
return S_OK;
|
2003-04-08 23:42:00 +02:00
|
|
|
}
|
|
|
|
|
2012-04-02 00:03:00 +02:00
|
|
|
static HRESULT WINAPI IDirectMusicPerformance8Impl_IsPlaying(IDirectMusicPerformance8 *iface,
|
|
|
|
IDirectMusicSegment *pSegment, IDirectMusicSegmentState *pSegState)
|
|
|
|
{
|
|
|
|
IDirectMusicPerformance8Impl *This = impl_from_IDirectMusicPerformance8(iface);
|
|
|
|
|
2003-06-07 02:39:18 +02:00
|
|
|
FIXME("(%p, %p, %p): stub\n", This, pSegment, pSegState);
|
2004-05-05 03:32:55 +02:00
|
|
|
return S_FALSE;
|
2003-04-08 23:42:00 +02:00
|
|
|
}
|
|
|
|
|
2012-04-02 00:03:00 +02:00
|
|
|
static HRESULT WINAPI IDirectMusicPerformance8Impl_GetTime(IDirectMusicPerformance8 *iface,
|
|
|
|
REFERENCE_TIME *prtNow, MUSIC_TIME *pmtNow)
|
|
|
|
{
|
|
|
|
IDirectMusicPerformance8Impl *This = impl_from_IDirectMusicPerformance8(iface);
|
2004-05-07 01:37:54 +02:00
|
|
|
HRESULT hr = S_OK;
|
|
|
|
REFERENCE_TIME rtCur = 0;
|
|
|
|
|
|
|
|
/*TRACE("(%p, %p, %p)\n", This, prtNow, pmtNow); */
|
2004-12-09 15:07:59 +01:00
|
|
|
if (This->procThreadTicStarted) {
|
2004-05-07 01:37:54 +02:00
|
|
|
rtCur = ((REFERENCE_TIME) GetTickCount() * 10000) - This->procThreadStartTime;
|
|
|
|
} else {
|
|
|
|
/*return DMUS_E_NO_MASTER_CLOCK;*/
|
|
|
|
}
|
|
|
|
if (NULL != prtNow) {
|
|
|
|
*prtNow = rtCur;
|
|
|
|
}
|
|
|
|
if (NULL != pmtNow) {
|
|
|
|
hr = IDirectMusicPerformance8_ReferenceToMusicTime(iface, rtCur, pmtNow);
|
|
|
|
}
|
|
|
|
return hr;
|
2003-04-08 23:42:00 +02:00
|
|
|
}
|
|
|
|
|
2012-04-02 00:03:00 +02:00
|
|
|
static HRESULT WINAPI IDirectMusicPerformance8Impl_AllocPMsg(IDirectMusicPerformance8 *iface,
|
|
|
|
ULONG cb, DMUS_PMSG **ppPMSG)
|
|
|
|
{
|
|
|
|
IDirectMusicPerformance8Impl *This = impl_from_IDirectMusicPerformance8(iface);
|
2004-05-05 03:32:55 +02:00
|
|
|
DMUS_PMSGItem* pItem = NULL;
|
|
|
|
|
2006-10-10 01:07:26 +02:00
|
|
|
FIXME("(%p, %d, %p): stub\n", This, cb, ppPMSG);
|
2004-05-05 03:32:55 +02:00
|
|
|
|
|
|
|
if (sizeof(DMUS_PMSG) > cb) {
|
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
|
|
|
if (NULL == ppPMSG) {
|
|
|
|
return E_POINTER;
|
|
|
|
}
|
|
|
|
pItem = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, cb - sizeof(DMUS_PMSG) + sizeof(DMUS_PMSGItem));
|
|
|
|
if (NULL == pItem) {
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
pItem->pMsg.dwSize = cb;
|
2004-05-05 20:59:59 +02:00
|
|
|
*ppPMSG = DMUS_ItemToPMSG(pItem);
|
2004-05-05 03:32:55 +02:00
|
|
|
return S_OK;
|
2003-04-08 23:42:00 +02:00
|
|
|
}
|
|
|
|
|
2012-04-02 00:03:00 +02:00
|
|
|
static HRESULT WINAPI IDirectMusicPerformance8Impl_FreePMsg(IDirectMusicPerformance8 *iface,
|
|
|
|
DMUS_PMSG *pPMSG)
|
|
|
|
{
|
|
|
|
IDirectMusicPerformance8Impl *This = impl_from_IDirectMusicPerformance8(iface);
|
2004-05-05 03:32:55 +02:00
|
|
|
DMUS_PMSGItem* pItem = NULL;
|
|
|
|
|
|
|
|
FIXME("(%p, %p): stub\n", This, pPMSG);
|
|
|
|
|
|
|
|
if (NULL == pPMSG) {
|
|
|
|
return E_POINTER;
|
|
|
|
}
|
2004-05-05 20:59:59 +02:00
|
|
|
pItem = DMUS_PMSGToItem(pPMSG);
|
2004-12-09 15:07:59 +01:00
|
|
|
if (pItem->bInUse) {
|
2004-05-05 20:59:59 +02:00
|
|
|
/** prevent for freeing PMsg in queue (ie to be processed) */
|
2004-05-05 03:32:55 +02:00
|
|
|
return DMUS_E_CANNOT_FREE;
|
2004-05-05 20:59:59 +02:00
|
|
|
}
|
|
|
|
/** now we can remove it safely */
|
2004-05-07 01:37:54 +02:00
|
|
|
EnterCriticalSection(&This->safe);
|
2004-05-05 20:59:59 +02:00
|
|
|
DMUS_ItemRemoveFromQueue( This, pItem );
|
2004-05-07 01:37:54 +02:00
|
|
|
LeaveCriticalSection(&This->safe);
|
|
|
|
|
2004-05-05 20:59:59 +02:00
|
|
|
/** TODO: see if we should Release the pItem->pMsg->punkUser and others Interfaces */
|
2004-05-05 03:32:55 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, pItem);
|
|
|
|
return S_OK;
|
2003-04-08 23:42:00 +02:00
|
|
|
}
|
|
|
|
|
2012-04-02 00:03:00 +02:00
|
|
|
static HRESULT WINAPI IDirectMusicPerformance8Impl_GetGraph(IDirectMusicPerformance8 *iface,
|
|
|
|
IDirectMusicGraph **ppGraph)
|
|
|
|
{
|
|
|
|
IDirectMusicPerformance8Impl *This = impl_from_IDirectMusicPerformance8(iface);
|
|
|
|
|
2004-05-05 20:59:59 +02:00
|
|
|
FIXME("(%p, %p): to check\n", This, ppGraph);
|
|
|
|
if (NULL != This->pToolGraph) {
|
2007-12-08 00:01:46 +01:00
|
|
|
*ppGraph = This->pToolGraph;
|
|
|
|
IDirectMusicGraph_AddRef(*ppGraph);
|
2004-05-10 21:56:17 +02:00
|
|
|
} else {
|
|
|
|
return E_FAIL;
|
2004-05-05 20:59:59 +02:00
|
|
|
}
|
|
|
|
return S_OK;
|
2003-04-08 23:42:00 +02:00
|
|
|
}
|
|
|
|
|
2012-04-02 00:03:00 +02:00
|
|
|
static HRESULT WINAPI IDirectMusicPerformance8Impl_SetGraph(IDirectMusicPerformance8 *iface,
|
|
|
|
IDirectMusicGraph *pGraph)
|
|
|
|
{
|
|
|
|
IDirectMusicPerformance8Impl *This = impl_from_IDirectMusicPerformance8(iface);
|
|
|
|
|
2004-05-05 20:59:59 +02:00
|
|
|
FIXME("(%p, %p): to check\n", This, pGraph);
|
|
|
|
|
|
|
|
if (NULL != This->pToolGraph) {
|
|
|
|
/* Todo clean buffers and tools before */
|
2007-12-08 00:01:46 +01:00
|
|
|
IDirectMusicGraph_Release(This->pToolGraph);
|
2004-05-05 20:59:59 +02:00
|
|
|
}
|
|
|
|
This->pToolGraph = pGraph;
|
|
|
|
if (NULL != This->pToolGraph) {
|
2007-12-08 00:01:46 +01:00
|
|
|
IDirectMusicGraph_AddRef(This->pToolGraph);
|
2004-05-05 20:59:59 +02:00
|
|
|
}
|
|
|
|
return S_OK;
|
2003-04-08 23:42:00 +02:00
|
|
|
}
|
|
|
|
|
2012-04-02 00:03:00 +02:00
|
|
|
static HRESULT WINAPI IDirectMusicPerformance8Impl_SetNotificationHandle(IDirectMusicPerformance8 *iface,
|
|
|
|
HANDLE hNotification, REFERENCE_TIME rtMinimum)
|
|
|
|
{
|
2019-10-02 22:10:11 +02:00
|
|
|
IDirectMusicPerformance8Impl *This = impl_from_IDirectMusicPerformance8(iface);
|
2012-04-02 00:03:00 +02:00
|
|
|
|
2019-10-02 22:10:11 +02:00
|
|
|
TRACE("(%p, %p, 0x%s)\n", This, hNotification, wine_dbgstr_longlong(rtMinimum));
|
|
|
|
|
|
|
|
This->hNotification = hNotification;
|
|
|
|
if (rtMinimum)
|
|
|
|
This->rtMinimum = rtMinimum;
|
|
|
|
else if (!This->rtMinimum)
|
|
|
|
This->rtMinimum = 20000000; /* 2 seconds */
|
|
|
|
return S_OK;
|
2003-04-08 23:42:00 +02:00
|
|
|
}
|
|
|
|
|
2012-04-02 00:03:00 +02:00
|
|
|
static HRESULT WINAPI IDirectMusicPerformance8Impl_GetNotificationPMsg(IDirectMusicPerformance8 *iface,
|
|
|
|
DMUS_NOTIFICATION_PMSG **ppNotificationPMsg)
|
|
|
|
{
|
|
|
|
IDirectMusicPerformance8Impl *This = impl_from_IDirectMusicPerformance8(iface);
|
|
|
|
|
2004-05-05 03:32:55 +02:00
|
|
|
FIXME("(%p, %p): stub\n", This, ppNotificationPMsg);
|
|
|
|
if (NULL == ppNotificationPMsg) {
|
|
|
|
return E_POINTER;
|
|
|
|
}
|
2004-05-05 20:59:59 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
2004-05-05 03:32:55 +02:00
|
|
|
return S_FALSE;
|
|
|
|
/*return S_OK;*/
|
2003-04-08 23:42:00 +02:00
|
|
|
}
|
|
|
|
|
2012-04-02 00:03:00 +02:00
|
|
|
static HRESULT WINAPI IDirectMusicPerformance8Impl_AddNotificationType(IDirectMusicPerformance8 *iface,
|
|
|
|
REFGUID rguidNotificationType)
|
|
|
|
{
|
|
|
|
IDirectMusicPerformance8Impl *This = impl_from_IDirectMusicPerformance8(iface);
|
|
|
|
|
2004-02-25 02:30:03 +01:00
|
|
|
FIXME("(%p, %s): stub\n", This, debugstr_dmguid(rguidNotificationType));
|
2003-06-07 02:39:18 +02:00
|
|
|
return S_OK;
|
2003-04-08 23:42:00 +02:00
|
|
|
}
|
|
|
|
|
2012-04-02 00:03:00 +02:00
|
|
|
static HRESULT WINAPI IDirectMusicPerformance8Impl_RemoveNotificationType(IDirectMusicPerformance8 *iface,
|
|
|
|
REFGUID rguidNotificationType)
|
|
|
|
{
|
|
|
|
IDirectMusicPerformance8Impl *This = impl_from_IDirectMusicPerformance8(iface);
|
|
|
|
|
2004-02-25 02:30:03 +01:00
|
|
|
FIXME("(%p, %s): stub\n", This, debugstr_dmguid(rguidNotificationType));
|
2003-06-07 02:39:18 +02:00
|
|
|
return S_OK;
|
2003-04-08 23:42:00 +02:00
|
|
|
}
|
|
|
|
|
2012-04-02 00:03:00 +02:00
|
|
|
static HRESULT WINAPI IDirectMusicPerformance8Impl_AddPort(IDirectMusicPerformance8 *iface,
|
|
|
|
IDirectMusicPort *pPort)
|
|
|
|
{
|
|
|
|
IDirectMusicPerformance8Impl *This = impl_from_IDirectMusicPerformance8(iface);
|
2005-11-28 10:36:41 +01:00
|
|
|
HRESULT hr = E_FAIL;
|
2012-04-02 00:03:00 +02:00
|
|
|
|
2003-06-07 02:39:18 +02:00
|
|
|
FIXME("(%p, %p): stub\n", This, pPort);
|
2017-05-11 11:05:45 +02:00
|
|
|
if (!This->dmusic)
|
|
|
|
return DMUS_E_NOT_INIT;
|
2005-11-28 10:36:41 +01:00
|
|
|
if (NULL == pPort) {
|
|
|
|
GUID port_guid;
|
|
|
|
IDirectMusicPort* pDefaultPort = NULL;
|
|
|
|
DMUS_PORTPARAMS params;
|
|
|
|
int i, j;
|
2017-05-11 11:05:45 +02:00
|
|
|
hr = IDirectMusic8_GetDefaultPort(This->dmusic, &port_guid);
|
2005-11-28 10:36:41 +01:00
|
|
|
if (FAILED(hr)) return hr;
|
|
|
|
ZeroMemory(¶ms, sizeof(params));
|
|
|
|
params.dwSize = sizeof(params);
|
|
|
|
params.dwValidParams = DMUS_PORTPARAMS_CHANNELGROUPS | DMUS_PORTPARAMS_SHARE;
|
|
|
|
params.dwChannelGroups = 1;
|
|
|
|
params.fShare = TRUE;
|
2017-05-11 11:05:45 +02:00
|
|
|
hr = IDirectMusic8_CreatePort(This->dmusic, &port_guid, ¶ms, &pDefaultPort, NULL);
|
2005-11-28 10:36:41 +01:00
|
|
|
if (FAILED(hr)) return hr;
|
|
|
|
hr = IDirectMusicPort_Activate(pDefaultPort, TRUE);
|
|
|
|
if (FAILED(hr)) { IDirectMusicPort_Release(pDefaultPort); return hr; }
|
|
|
|
j = 0;
|
|
|
|
for (i = 0; i < 16; ++i) {
|
|
|
|
if (NULL == This->PChannel[i].port) {
|
|
|
|
This->PChannel[i].port = pPort;
|
|
|
|
This->PChannel[i].group = 0;
|
|
|
|
This->PChannel[i].channel = j; /* FIXME: should this be assigned? */
|
|
|
|
j++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
IDirectMusicPort_AddRef(pPort);
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* We should remember added Ports (for example using a list)
|
|
|
|
* and control if Port is registered for each api who use ports
|
|
|
|
*/
|
2003-06-07 02:39:18 +02:00
|
|
|
return S_OK;
|
2003-04-08 23:42:00 +02:00
|
|
|
}
|
|
|
|
|
2012-04-02 00:03:00 +02:00
|
|
|
static HRESULT WINAPI IDirectMusicPerformance8Impl_RemovePort(IDirectMusicPerformance8 *iface,
|
|
|
|
IDirectMusicPort *pPort)
|
|
|
|
{
|
|
|
|
IDirectMusicPerformance8Impl *This = impl_from_IDirectMusicPerformance8(iface);
|
|
|
|
|
2003-06-07 02:39:18 +02:00
|
|
|
FIXME("(%p, %p): stub\n", This, pPort);
|
2003-07-22 00:10:14 +02:00
|
|
|
IDirectMusicPort_Release (pPort);
|
2003-06-07 02:39:18 +02:00
|
|
|
return S_OK;
|
2003-04-08 23:42:00 +02:00
|
|
|
}
|
|
|
|
|
2012-04-02 00:03:00 +02:00
|
|
|
static HRESULT WINAPI IDirectMusicPerformance8Impl_AssignPChannelBlock(IDirectMusicPerformance8 *iface,
|
|
|
|
DWORD dwBlockNum, IDirectMusicPort *pPort, DWORD dwGroup)
|
|
|
|
{
|
|
|
|
IDirectMusicPerformance8Impl *This = impl_from_IDirectMusicPerformance8(iface);
|
2003-06-30 20:28:52 +02:00
|
|
|
int i, j, range /* min value in range */;
|
2003-06-07 02:39:18 +02:00
|
|
|
|
2006-10-10 01:07:26 +02:00
|
|
|
FIXME("(%p, %d, %p, %d): semi-stub\n", This, dwBlockNum, pPort, dwGroup-1);
|
2005-11-28 10:36:41 +01:00
|
|
|
if (NULL == pPort) return E_POINTER;
|
|
|
|
|
2003-08-23 01:53:27 +02:00
|
|
|
range = 16 * dwBlockNum;
|
|
|
|
j = 0;
|
|
|
|
for (i = range; i < range+16; i++) {
|
|
|
|
/*TRACE("Setting PChannel[%i] to port %p, group %ld, MIDI port %i\n", i, pPort, dwGroup-1, j); */
|
|
|
|
This->PChannel[i].port = pPort;
|
|
|
|
This->PChannel[i].group = dwGroup - 1; /* first index is always zero */
|
|
|
|
This->PChannel[i].channel = j; /* FIXME: should this be assigned? */
|
|
|
|
j++;
|
|
|
|
}
|
2005-11-28 10:36:41 +01:00
|
|
|
/*if (dwGroup > 2) return S_FALSE;*/
|
2003-08-23 01:53:27 +02:00
|
|
|
|
|
|
|
return S_OK;
|
2003-04-08 23:42:00 +02:00
|
|
|
}
|
|
|
|
|
2012-04-02 00:03:00 +02:00
|
|
|
static HRESULT WINAPI IDirectMusicPerformance8Impl_AssignPChannel(IDirectMusicPerformance8 *iface,
|
2012-09-21 16:02:10 +02:00
|
|
|
DWORD PChannel, IDirectMusicPort *port, DWORD group, DWORD MChannel)
|
2012-04-02 00:03:00 +02:00
|
|
|
{
|
2012-09-21 16:02:10 +02:00
|
|
|
IDirectMusicPerformance8Impl *This = impl_from_IDirectMusicPerformance8(iface);
|
2003-06-07 02:39:18 +02:00
|
|
|
|
2012-09-21 16:02:10 +02:00
|
|
|
TRACE("(%p)->(%d, %p, %d, %d)\n", This, PChannel, port, group, MChannel);
|
2003-06-07 02:39:18 +02:00
|
|
|
|
2012-09-21 16:02:10 +02:00
|
|
|
if (!port)
|
|
|
|
return E_POINTER;
|
|
|
|
|
|
|
|
This->PChannel[PChannel].port = port;
|
|
|
|
This->PChannel[PChannel].group = group;
|
|
|
|
This->PChannel[PChannel].channel = MChannel;
|
|
|
|
|
|
|
|
return S_OK;
|
2003-04-08 23:42:00 +02:00
|
|
|
}
|
|
|
|
|
2012-04-02 00:03:00 +02:00
|
|
|
static HRESULT WINAPI IDirectMusicPerformance8Impl_PChannelInfo(IDirectMusicPerformance8 *iface,
|
2012-09-21 16:02:10 +02:00
|
|
|
DWORD PChannel, IDirectMusicPort **port, DWORD *group, DWORD *MChannel)
|
2012-04-02 00:03:00 +02:00
|
|
|
{
|
2012-09-21 16:02:10 +02:00
|
|
|
IDirectMusicPerformance8Impl *This = impl_from_IDirectMusicPerformance8(iface);
|
|
|
|
DMUS_PORTPARAMS8 port_params;
|
|
|
|
GUID default_port;
|
2010-08-07 07:01:14 +02:00
|
|
|
|
2012-09-21 16:02:10 +02:00
|
|
|
FIXME("(%p)->(%d, %p, %p, %p): stub\n", This, PChannel, port, group, MChannel);
|
2010-08-07 07:01:14 +02:00
|
|
|
|
2012-09-21 16:02:10 +02:00
|
|
|
port_params.dwSize = sizeof(DMUS_PORTPARAMS8);
|
|
|
|
port_params.dwValidParams = 0;
|
2017-05-11 11:05:45 +02:00
|
|
|
IDirectMusic8_GetDefaultPort(This->dmusic, &default_port);
|
|
|
|
IDirectMusic8_CreatePort(This->dmusic, &default_port, &port_params, port, NULL);
|
2010-08-07 07:01:14 +02:00
|
|
|
|
2012-09-21 16:02:10 +02:00
|
|
|
return S_OK;
|
2003-04-08 23:42:00 +02:00
|
|
|
}
|
|
|
|
|
2012-04-02 00:03:00 +02:00
|
|
|
static HRESULT WINAPI IDirectMusicPerformance8Impl_DownloadInstrument(IDirectMusicPerformance8 *iface,
|
|
|
|
IDirectMusicInstrument *pInst, DWORD dwPChannel,
|
|
|
|
IDirectMusicDownloadedInstrument **ppDownInst, DMUS_NOTERANGE *pNoteRanges,
|
|
|
|
DWORD dwNumNoteRanges, IDirectMusicPort **ppPort, DWORD *pdwGroup, DWORD *pdwMChannel)
|
|
|
|
{
|
|
|
|
IDirectMusicPerformance8Impl *This = impl_from_IDirectMusicPerformance8(iface);
|
|
|
|
|
2006-10-10 01:07:26 +02:00
|
|
|
FIXME("(%p, %p, %d, %p, %p, %d, %p, %p, %p): stub\n", This, pInst, dwPChannel, ppDownInst, pNoteRanges, dwNumNoteRanges, ppPort, pdwGroup, pdwMChannel);
|
2003-06-07 02:39:18 +02:00
|
|
|
return S_OK;
|
2003-04-08 23:42:00 +02:00
|
|
|
}
|
|
|
|
|
2012-04-02 00:03:00 +02:00
|
|
|
static HRESULT WINAPI IDirectMusicPerformance8Impl_Invalidate(IDirectMusicPerformance8 *iface,
|
|
|
|
MUSIC_TIME mtTime, DWORD dwFlags)
|
|
|
|
{
|
|
|
|
IDirectMusicPerformance8Impl *This = impl_from_IDirectMusicPerformance8(iface);
|
|
|
|
|
2009-01-10 02:44:41 +01:00
|
|
|
FIXME("(%p, %d, %d): stub\n", This, mtTime, dwFlags);
|
2003-06-07 02:39:18 +02:00
|
|
|
return S_OK;
|
2003-04-08 23:42:00 +02:00
|
|
|
}
|
|
|
|
|
2012-04-02 00:03:00 +02:00
|
|
|
static HRESULT WINAPI IDirectMusicPerformance8Impl_GetParam(IDirectMusicPerformance8 *iface,
|
|
|
|
REFGUID rguidType, DWORD dwGroupBits, DWORD dwIndex, MUSIC_TIME mtTime,
|
|
|
|
MUSIC_TIME *pmtNext, void *pParam)
|
|
|
|
{
|
|
|
|
IDirectMusicPerformance8Impl *This = impl_from_IDirectMusicPerformance8(iface);
|
|
|
|
|
2009-01-10 02:44:41 +01:00
|
|
|
FIXME("(%p, %s, %d, %d, %d, %p, %p): stub\n", This, debugstr_dmguid(rguidType), dwGroupBits, dwIndex, mtTime, pmtNext, pParam);
|
2003-06-07 02:39:18 +02:00
|
|
|
return S_OK;
|
2003-04-08 23:42:00 +02:00
|
|
|
}
|
|
|
|
|
2012-04-02 00:03:00 +02:00
|
|
|
static HRESULT WINAPI IDirectMusicPerformance8Impl_SetParam(IDirectMusicPerformance8 *iface,
|
|
|
|
REFGUID rguidType, DWORD dwGroupBits, DWORD dwIndex, MUSIC_TIME mtTime, void *pParam)
|
|
|
|
{
|
|
|
|
IDirectMusicPerformance8Impl *This = impl_from_IDirectMusicPerformance8(iface);
|
|
|
|
|
2009-01-10 02:44:41 +01:00
|
|
|
FIXME("(%p, %s, %d, %d, %d, %p): stub\n", This, debugstr_dmguid(rguidType), dwGroupBits, dwIndex, mtTime, pParam);
|
2003-06-07 02:39:18 +02:00
|
|
|
return S_OK;
|
2003-04-08 23:42:00 +02:00
|
|
|
}
|
|
|
|
|
2012-04-02 00:03:00 +02:00
|
|
|
static HRESULT WINAPI IDirectMusicPerformance8Impl_GetGlobalParam(IDirectMusicPerformance8 *iface,
|
|
|
|
REFGUID rguidType, void *pParam, DWORD dwSize)
|
|
|
|
{
|
|
|
|
IDirectMusicPerformance8Impl *This = impl_from_IDirectMusicPerformance8(iface);
|
2003-06-07 02:39:18 +02:00
|
|
|
|
2006-10-10 01:07:26 +02:00
|
|
|
TRACE("(%p, %s, %p, %d): stub\n", This, debugstr_dmguid(rguidType), pParam, dwSize);
|
2003-06-13 20:59:51 +02:00
|
|
|
|
2003-08-23 01:53:27 +02:00
|
|
|
if (IsEqualGUID (rguidType, &GUID_PerfAutoDownload))
|
2008-08-05 22:56:33 +02:00
|
|
|
memcpy(pParam, &This->fAutoDownload, sizeof(This->fAutoDownload));
|
2003-08-23 01:53:27 +02:00
|
|
|
if (IsEqualGUID (rguidType, &GUID_PerfMasterGrooveLevel))
|
2008-08-05 22:56:33 +02:00
|
|
|
memcpy(pParam, &This->cMasterGrooveLevel, sizeof(This->cMasterGrooveLevel));
|
2003-08-23 01:53:27 +02:00
|
|
|
if (IsEqualGUID (rguidType, &GUID_PerfMasterTempo))
|
2008-08-05 22:56:33 +02:00
|
|
|
memcpy(pParam, &This->fMasterTempo, sizeof(This->fMasterTempo));
|
2003-08-23 01:53:27 +02:00
|
|
|
if (IsEqualGUID (rguidType, &GUID_PerfMasterVolume))
|
2008-08-05 22:56:33 +02:00
|
|
|
memcpy(pParam, &This->lMasterVolume, sizeof(This->lMasterVolume));
|
2003-06-07 02:39:18 +02:00
|
|
|
|
|
|
|
return S_OK;
|
2003-04-08 23:42:00 +02:00
|
|
|
}
|
|
|
|
|
2012-04-02 00:03:00 +02:00
|
|
|
static HRESULT WINAPI IDirectMusicPerformance8Impl_SetGlobalParam(IDirectMusicPerformance8 *iface,
|
|
|
|
REFGUID rguidType, void *pParam, DWORD dwSize)
|
|
|
|
{
|
|
|
|
IDirectMusicPerformance8Impl *This = impl_from_IDirectMusicPerformance8(iface);
|
2003-06-07 02:39:18 +02:00
|
|
|
|
2006-10-10 01:07:26 +02:00
|
|
|
TRACE("(%p, %s, %p, %d)\n", This, debugstr_dmguid(rguidType), pParam, dwSize);
|
2003-06-13 20:59:51 +02:00
|
|
|
|
2003-08-23 01:53:27 +02:00
|
|
|
if (IsEqualGUID (rguidType, &GUID_PerfAutoDownload)) {
|
2003-07-22 00:10:14 +02:00
|
|
|
memcpy(&This->fAutoDownload, pParam, dwSize);
|
|
|
|
TRACE("=> AutoDownload set to %d\n", This->fAutoDownload);
|
2003-06-13 20:59:51 +02:00
|
|
|
}
|
2003-08-23 01:53:27 +02:00
|
|
|
if (IsEqualGUID (rguidType, &GUID_PerfMasterGrooveLevel)) {
|
2003-07-22 00:10:14 +02:00
|
|
|
memcpy(&This->cMasterGrooveLevel, pParam, dwSize);
|
|
|
|
TRACE("=> MasterGrooveLevel set to %i\n", This->cMasterGrooveLevel);
|
2003-06-13 20:59:51 +02:00
|
|
|
}
|
2003-08-23 01:53:27 +02:00
|
|
|
if (IsEqualGUID (rguidType, &GUID_PerfMasterTempo)) {
|
2003-07-22 00:10:14 +02:00
|
|
|
memcpy(&This->fMasterTempo, pParam, dwSize);
|
|
|
|
TRACE("=> MasterTempo set to %f\n", This->fMasterTempo);
|
2003-06-13 20:59:51 +02:00
|
|
|
}
|
2003-08-23 01:53:27 +02:00
|
|
|
if (IsEqualGUID (rguidType, &GUID_PerfMasterVolume)) {
|
2003-07-22 00:10:14 +02:00
|
|
|
memcpy(&This->lMasterVolume, pParam, dwSize);
|
|
|
|
TRACE("=> MasterVolume set to %li\n", This->lMasterVolume);
|
2003-06-13 20:59:51 +02:00
|
|
|
}
|
2003-06-07 02:39:18 +02:00
|
|
|
|
|
|
|
return S_OK;
|
2003-04-08 23:42:00 +02:00
|
|
|
}
|
|
|
|
|
2012-04-02 00:03:00 +02:00
|
|
|
static HRESULT WINAPI IDirectMusicPerformance8Impl_GetLatencyTime(IDirectMusicPerformance8 *iface,
|
|
|
|
REFERENCE_TIME *prtTime)
|
|
|
|
{
|
|
|
|
IDirectMusicPerformance8Impl *This = impl_from_IDirectMusicPerformance8(iface);
|
|
|
|
|
2004-05-07 01:37:54 +02:00
|
|
|
TRACE("(%p, %p): stub\n", This, prtTime);
|
|
|
|
*prtTime = This->rtLatencyTime;
|
2003-06-07 02:39:18 +02:00
|
|
|
return S_OK;
|
2003-04-08 23:42:00 +02:00
|
|
|
}
|
|
|
|
|
2012-04-02 00:03:00 +02:00
|
|
|
static HRESULT WINAPI IDirectMusicPerformance8Impl_GetQueueTime(IDirectMusicPerformance8 *iface,
|
|
|
|
REFERENCE_TIME *prtTime)
|
|
|
|
|
|
|
|
{
|
|
|
|
IDirectMusicPerformance8Impl *This = impl_from_IDirectMusicPerformance8(iface);
|
|
|
|
|
2003-06-07 02:39:18 +02:00
|
|
|
FIXME("(%p, %p): stub\n", This, prtTime);
|
|
|
|
return S_OK;
|
2003-04-08 23:42:00 +02:00
|
|
|
}
|
|
|
|
|
2012-04-02 00:03:00 +02:00
|
|
|
static HRESULT WINAPI IDirectMusicPerformance8Impl_AdjustTime(IDirectMusicPerformance8 *iface,
|
|
|
|
REFERENCE_TIME rtAmount)
|
|
|
|
{
|
|
|
|
IDirectMusicPerformance8Impl *This = impl_from_IDirectMusicPerformance8(iface);
|
|
|
|
|
2006-09-20 22:25:51 +02:00
|
|
|
FIXME("(%p, 0x%s): stub\n", This, wine_dbgstr_longlong(rtAmount));
|
2003-06-07 02:39:18 +02:00
|
|
|
return S_OK;
|
2003-04-08 23:42:00 +02:00
|
|
|
}
|
|
|
|
|
2012-04-02 00:03:00 +02:00
|
|
|
static HRESULT WINAPI IDirectMusicPerformance8Impl_CloseDown(IDirectMusicPerformance8 *iface)
|
|
|
|
{
|
2017-05-11 11:05:47 +02:00
|
|
|
IDirectMusicPerformance8Impl *This = impl_from_IDirectMusicPerformance8(iface);
|
2012-04-02 00:03:00 +02:00
|
|
|
|
2017-05-11 11:05:47 +02:00
|
|
|
FIXME("(%p): semi-stub\n", This);
|
|
|
|
|
|
|
|
if (PostMessageToProcessMsgThread(This, PROCESSMSG_EXIT)) {
|
|
|
|
WaitForSingleObject(This->procThread, INFINITE);
|
|
|
|
This->procThreadTicStarted = FALSE;
|
|
|
|
CloseHandle(This->procThread);
|
|
|
|
}
|
2017-05-11 11:05:46 +02:00
|
|
|
if (This->dsound) {
|
|
|
|
IDirectSound_Release(This->dsound);
|
|
|
|
This->dsound = NULL;
|
|
|
|
}
|
2017-05-11 11:05:45 +02:00
|
|
|
if (This->dmusic) {
|
2017-05-12 16:11:24 +02:00
|
|
|
IDirectMusic_SetDirectSound(This->dmusic, NULL, NULL);
|
2017-05-11 11:05:45 +02:00
|
|
|
IDirectMusic8_Release(This->dmusic);
|
|
|
|
This->dmusic = NULL;
|
|
|
|
}
|
|
|
|
return S_OK;
|
2003-04-08 23:42:00 +02:00
|
|
|
}
|
|
|
|
|
2012-04-02 00:03:00 +02:00
|
|
|
static HRESULT WINAPI IDirectMusicPerformance8Impl_GetResolvedTime(IDirectMusicPerformance8 *iface,
|
|
|
|
REFERENCE_TIME rtTime, REFERENCE_TIME *prtResolved, DWORD dwTimeResolveFlags)
|
|
|
|
{
|
|
|
|
IDirectMusicPerformance8Impl *This = impl_from_IDirectMusicPerformance8(iface);
|
|
|
|
|
2006-10-10 01:07:26 +02:00
|
|
|
FIXME("(%p, 0x%s, %p, %d): stub\n", This, wine_dbgstr_longlong(rtTime),
|
2006-09-20 22:25:51 +02:00
|
|
|
prtResolved, dwTimeResolveFlags);
|
2003-06-07 02:39:18 +02:00
|
|
|
return S_OK;
|
2003-04-08 23:42:00 +02:00
|
|
|
}
|
|
|
|
|
2012-04-02 00:03:00 +02:00
|
|
|
static HRESULT WINAPI IDirectMusicPerformance8Impl_MIDIToMusic(IDirectMusicPerformance8 *iface,
|
|
|
|
BYTE bMIDIValue, DMUS_CHORD_KEY *pChord, BYTE bPlayMode, BYTE bChordLevel,
|
|
|
|
WORD *pwMusicValue)
|
|
|
|
{
|
|
|
|
IDirectMusicPerformance8Impl *This = impl_from_IDirectMusicPerformance8(iface);
|
|
|
|
|
2003-06-07 02:39:18 +02:00
|
|
|
FIXME("(%p, %d, %p, %d, %d, %p): stub\n", This, bMIDIValue, pChord, bPlayMode, bChordLevel, pwMusicValue);
|
|
|
|
return S_OK;
|
2003-04-08 23:42:00 +02:00
|
|
|
}
|
|
|
|
|
2012-04-02 00:03:00 +02:00
|
|
|
static HRESULT WINAPI IDirectMusicPerformance8Impl_MusicToMIDI(IDirectMusicPerformance8 *iface,
|
|
|
|
WORD wMusicValue, DMUS_CHORD_KEY *pChord, BYTE bPlayMode, BYTE bChordLevel,
|
|
|
|
BYTE *pbMIDIValue)
|
|
|
|
{
|
|
|
|
IDirectMusicPerformance8Impl *This = impl_from_IDirectMusicPerformance8(iface);
|
|
|
|
|
2003-06-07 02:39:18 +02:00
|
|
|
FIXME("(%p, %d, %p, %d, %d, %p): stub\n", This, wMusicValue, pChord, bPlayMode, bChordLevel, pbMIDIValue);
|
|
|
|
return S_OK;
|
2003-04-08 23:42:00 +02:00
|
|
|
}
|
|
|
|
|
2012-04-02 00:03:00 +02:00
|
|
|
static HRESULT WINAPI IDirectMusicPerformance8Impl_TimeToRhythm(IDirectMusicPerformance8 *iface,
|
|
|
|
MUSIC_TIME mtTime, DMUS_TIMESIGNATURE *pTimeSig, WORD *pwMeasure, BYTE *pbBeat,
|
|
|
|
BYTE *pbGrid, short *pnOffset)
|
|
|
|
{
|
|
|
|
IDirectMusicPerformance8Impl *This = impl_from_IDirectMusicPerformance8(iface);
|
|
|
|
|
2009-01-10 02:44:41 +01:00
|
|
|
FIXME("(%p, %d, %p, %p, %p, %p, %p): stub\n", This, mtTime, pTimeSig, pwMeasure, pbBeat, pbGrid, pnOffset);
|
2003-06-07 02:39:18 +02:00
|
|
|
return S_OK;
|
2003-04-08 23:42:00 +02:00
|
|
|
}
|
|
|
|
|
2012-04-02 00:03:00 +02:00
|
|
|
static HRESULT WINAPI IDirectMusicPerformance8Impl_RhythmToTime(IDirectMusicPerformance8 *iface,
|
|
|
|
WORD wMeasure, BYTE bBeat, BYTE bGrid, short nOffset, DMUS_TIMESIGNATURE *pTimeSig,
|
|
|
|
MUSIC_TIME *pmtTime)
|
|
|
|
{
|
|
|
|
IDirectMusicPerformance8Impl *This = impl_from_IDirectMusicPerformance8(iface);
|
|
|
|
|
2003-06-07 02:39:18 +02:00
|
|
|
FIXME("(%p, %d, %d, %d, %i, %p, %p): stub\n", This, wMeasure, bBeat, bGrid, nOffset, pTimeSig, pmtTime);
|
|
|
|
return S_OK;
|
2003-04-08 23:42:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* IDirectMusicPerformance8 Interface part follow: */
|
2012-04-02 00:03:00 +02:00
|
|
|
static HRESULT WINAPI IDirectMusicPerformance8Impl_InitAudio(IDirectMusicPerformance8 *iface,
|
2017-05-11 11:05:49 +02:00
|
|
|
IDirectMusic **dmusic, IDirectSound **dsound, HWND hwnd, DWORD default_path_type,
|
|
|
|
DWORD num_channels, DWORD flags, DMUS_AUDIOPARAMS *params)
|
2012-04-02 00:03:00 +02:00
|
|
|
{
|
2017-05-11 11:05:46 +02:00
|
|
|
IDirectMusicPerformance8Impl *This = impl_from_IDirectMusicPerformance8(iface);
|
|
|
|
HRESULT hr = S_OK;
|
2012-04-02 00:03:00 +02:00
|
|
|
|
2017-05-11 11:05:49 +02:00
|
|
|
TRACE("(%p, %p, %p, %p, %x, %u, %x, %p)\n", This, dmusic, dsound, hwnd, default_path_type,
|
|
|
|
num_channels, flags, params);
|
2003-06-13 20:59:51 +02:00
|
|
|
|
2017-05-11 11:05:46 +02:00
|
|
|
if (This->dmusic)
|
|
|
|
return DMUS_E_ALREADY_INITED;
|
2003-06-16 22:26:50 +02:00
|
|
|
|
2017-05-11 11:05:48 +02:00
|
|
|
if (!dmusic || !*dmusic) {
|
|
|
|
hr = CoCreateInstance(&CLSID_DirectMusic, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectMusic8,
|
|
|
|
(void **)&This->dmusic);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
2017-05-12 16:11:23 +02:00
|
|
|
} else {
|
2017-05-11 11:05:48 +02:00
|
|
|
This->dmusic = (IDirectMusic8 *)*dmusic;
|
|
|
|
IDirectMusic8_AddRef(This->dmusic);
|
2017-05-12 16:11:23 +02:00
|
|
|
}
|
2017-05-11 11:05:48 +02:00
|
|
|
|
2017-05-11 11:05:46 +02:00
|
|
|
if (!dsound || !*dsound) {
|
|
|
|
hr = DirectSoundCreate8(NULL, (IDirectSound8 **)&This->dsound, NULL);
|
|
|
|
if (FAILED(hr))
|
2017-05-12 16:11:23 +02:00
|
|
|
goto error;
|
|
|
|
hr = IDirectSound_SetCooperativeLevel(This->dsound, hwnd ? hwnd : GetForegroundWindow(),
|
2017-05-11 11:05:46 +02:00
|
|
|
DSSCL_PRIORITY);
|
2017-05-12 16:11:23 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
goto error;
|
|
|
|
} else {
|
2017-05-11 11:05:46 +02:00
|
|
|
This->dsound = *dsound;
|
2017-05-11 11:05:48 +02:00
|
|
|
IDirectSound_AddRef(This->dsound);
|
2017-05-12 16:11:23 +02:00
|
|
|
}
|
2004-05-05 03:32:55 +02:00
|
|
|
|
2017-05-12 16:11:24 +02:00
|
|
|
hr = IDirectMusic8_SetDirectSound(This->dmusic, This->dsound, NULL);
|
|
|
|
if (FAILED(hr))
|
|
|
|
goto error;
|
|
|
|
|
2017-05-11 11:05:49 +02:00
|
|
|
if (!params) {
|
|
|
|
This->params.dwSize = sizeof(DMUS_AUDIOPARAMS);
|
|
|
|
This->params.fInitNow = FALSE;
|
|
|
|
This->params.dwValidData = DMUS_AUDIOPARAMS_FEATURES | DMUS_AUDIOPARAMS_VOICES |
|
|
|
|
DMUS_AUDIOPARAMS_SAMPLERATE | DMUS_AUDIOPARAMS_DEFAULTSYNTH;
|
|
|
|
This->params.dwVoices = 64;
|
|
|
|
This->params.dwSampleRate = 22050;
|
|
|
|
This->params.dwFeatures = flags;
|
|
|
|
This->params.clsidDefaultSynth = CLSID_DirectMusicSynthSink;
|
|
|
|
} else
|
|
|
|
This->params = *params;
|
|
|
|
|
2017-05-12 16:11:23 +02:00
|
|
|
if (default_path_type) {
|
2017-05-11 11:05:49 +02:00
|
|
|
hr = IDirectMusicPerformance8_CreateStandardAudioPath(iface, default_path_type,
|
|
|
|
num_channels, FALSE, &This->pDefaultPath);
|
2017-05-12 16:11:24 +02:00
|
|
|
if (FAILED(hr)) {
|
|
|
|
IDirectMusic8_SetDirectSound(This->dmusic, NULL, NULL);
|
2017-05-12 16:11:23 +02:00
|
|
|
goto error;
|
2017-05-12 16:11:24 +02:00
|
|
|
}
|
2017-05-12 16:11:23 +02:00
|
|
|
}
|
2003-06-07 02:39:18 +02:00
|
|
|
|
2017-05-12 16:11:23 +02:00
|
|
|
if (dsound && !*dsound) {
|
|
|
|
*dsound = This->dsound;
|
|
|
|
IDirectSound_AddRef(*dsound);
|
|
|
|
}
|
|
|
|
if (dmusic && !*dmusic) {
|
|
|
|
*dmusic = (IDirectMusic *)This->dmusic;
|
|
|
|
IDirectMusic_AddRef(*dmusic);
|
|
|
|
}
|
2017-05-11 11:05:49 +02:00
|
|
|
PostMessageToProcessMsgThread(This, PROCESSMSG_START);
|
2004-05-07 01:37:54 +02:00
|
|
|
|
2017-05-12 16:11:23 +02:00
|
|
|
return S_OK;
|
|
|
|
|
|
|
|
error:
|
|
|
|
if (This->dsound) {
|
|
|
|
IDirectSound_Release(This->dsound);
|
|
|
|
This->dsound = NULL;
|
|
|
|
}
|
|
|
|
if (This->dmusic) {
|
|
|
|
IDirectMusic8_Release(This->dmusic);
|
|
|
|
This->dmusic = NULL;
|
|
|
|
}
|
2017-05-11 11:05:49 +02:00
|
|
|
return hr;
|
2003-04-08 23:42:00 +02:00
|
|
|
}
|
|
|
|
|
2012-04-02 00:03:00 +02:00
|
|
|
static HRESULT WINAPI IDirectMusicPerformance8Impl_PlaySegmentEx(IDirectMusicPerformance8 *iface,
|
|
|
|
IUnknown *pSource, WCHAR *pwzSegmentName, IUnknown *pTransition, DWORD dwFlags,
|
|
|
|
__int64 i64StartTime, IDirectMusicSegmentState **ppSegmentState, IUnknown *pFrom,
|
|
|
|
IUnknown *pAudioPath)
|
|
|
|
{
|
|
|
|
IDirectMusicPerformance8Impl *This = impl_from_IDirectMusicPerformance8(iface);
|
|
|
|
|
2006-10-10 01:07:26 +02:00
|
|
|
FIXME("(%p, %p, %p, %p, %d, 0x%s, %p, %p, %p): stub\n", This, pSource, pwzSegmentName,
|
2006-09-20 22:25:51 +02:00
|
|
|
pTransition, dwFlags, wine_dbgstr_longlong(i64StartTime), ppSegmentState, pFrom, pAudioPath);
|
2008-12-14 19:00:15 +01:00
|
|
|
if (ppSegmentState)
|
2014-01-10 10:41:27 +01:00
|
|
|
return create_dmsegmentstate(&IID_IDirectMusicSegmentState,(void**)ppSegmentState);
|
2008-12-14 19:00:15 +01:00
|
|
|
return S_OK;
|
2003-04-08 23:42:00 +02:00
|
|
|
}
|
|
|
|
|
2012-04-02 00:03:00 +02:00
|
|
|
static HRESULT WINAPI IDirectMusicPerformance8Impl_StopEx(IDirectMusicPerformance8 *iface,
|
|
|
|
IUnknown *pObjectToStop, __int64 i64StopTime, DWORD dwFlags)
|
|
|
|
{
|
|
|
|
IDirectMusicPerformance8Impl *This = impl_from_IDirectMusicPerformance8(iface);
|
|
|
|
|
2006-10-10 01:07:26 +02:00
|
|
|
FIXME("(%p, %p, 0x%s, %d): stub\n", This, pObjectToStop,
|
2006-09-20 22:25:51 +02:00
|
|
|
wine_dbgstr_longlong(i64StopTime), dwFlags);
|
2003-06-07 02:39:18 +02:00
|
|
|
return S_OK;
|
2003-04-08 23:42:00 +02:00
|
|
|
}
|
|
|
|
|
2012-04-02 00:03:00 +02:00
|
|
|
static HRESULT WINAPI IDirectMusicPerformance8Impl_ClonePMsg(IDirectMusicPerformance8 *iface,
|
|
|
|
DMUS_PMSG *pSourcePMSG, DMUS_PMSG **ppCopyPMSG)
|
|
|
|
{
|
|
|
|
IDirectMusicPerformance8Impl *This = impl_from_IDirectMusicPerformance8(iface);
|
|
|
|
|
2003-06-07 02:39:18 +02:00
|
|
|
FIXME("(%p, %p, %p): stub\n", This, pSourcePMSG, ppCopyPMSG);
|
|
|
|
return S_OK;
|
2003-04-08 23:42:00 +02:00
|
|
|
}
|
|
|
|
|
2012-04-02 00:03:00 +02:00
|
|
|
static HRESULT WINAPI IDirectMusicPerformance8Impl_CreateAudioPath(IDirectMusicPerformance8 *iface,
|
|
|
|
IUnknown *pSourceConfig, BOOL fActivate, IDirectMusicAudioPath **ppNewPath)
|
|
|
|
{
|
|
|
|
IDirectMusicPerformance8Impl *This = impl_from_IDirectMusicPerformance8(iface);
|
2004-05-10 21:56:17 +02:00
|
|
|
IDirectMusicAudioPath *pPath;
|
|
|
|
|
2003-06-07 02:39:18 +02:00
|
|
|
FIXME("(%p, %p, %d, %p): stub\n", This, pSourceConfig, fActivate, ppNewPath);
|
2004-05-10 21:56:17 +02:00
|
|
|
|
|
|
|
if (NULL == ppNewPath) {
|
|
|
|
return E_POINTER;
|
|
|
|
}
|
|
|
|
|
2014-01-10 10:41:27 +01:00
|
|
|
create_dmaudiopath(&IID_IDirectMusicAudioPath, (void**)&pPath);
|
2015-04-27 00:49:04 +02:00
|
|
|
set_audiopath_perf_pointer(pPath, iface);
|
2004-05-10 21:56:17 +02:00
|
|
|
|
|
|
|
/** TODO */
|
|
|
|
|
2007-12-08 00:01:46 +01:00
|
|
|
*ppNewPath = pPath;
|
2004-05-10 21:56:17 +02:00
|
|
|
|
2005-06-21 11:44:28 +02:00
|
|
|
return IDirectMusicAudioPath_Activate(*ppNewPath, fActivate);
|
2003-04-08 23:42:00 +02:00
|
|
|
}
|
|
|
|
|
2012-04-02 00:03:00 +02:00
|
|
|
static HRESULT WINAPI IDirectMusicPerformance8Impl_CreateStandardAudioPath(IDirectMusicPerformance8 *iface,
|
|
|
|
DWORD dwType, DWORD dwPChannelCount, BOOL fActivate, IDirectMusicAudioPath **ppNewPath)
|
|
|
|
{
|
|
|
|
IDirectMusicPerformance8Impl *This = impl_from_IDirectMusicPerformance8(iface);
|
2004-03-07 04:14:49 +01:00
|
|
|
IDirectMusicAudioPath *pPath;
|
2003-06-16 22:26:50 +02:00
|
|
|
DSBUFFERDESC desc;
|
|
|
|
WAVEFORMATEX format;
|
2015-04-27 00:49:04 +02:00
|
|
|
IDirectSoundBuffer *buffer, *primary_buffer;
|
2003-10-27 23:08:37 +01:00
|
|
|
HRESULT hr = S_OK;
|
2003-06-07 02:39:18 +02:00
|
|
|
|
2006-10-10 01:07:26 +02:00
|
|
|
FIXME("(%p)->(%d, %d, %d, %p): semi-stub\n", This, dwType, dwPChannelCount, fActivate, ppNewPath);
|
2003-06-07 02:39:18 +02:00
|
|
|
|
2003-10-27 23:08:37 +01:00
|
|
|
if (NULL == ppNewPath) {
|
|
|
|
return E_POINTER;
|
|
|
|
}
|
2014-01-10 10:41:27 +01:00
|
|
|
|
2015-04-27 00:49:04 +02:00
|
|
|
*ppNewPath = NULL;
|
2012-04-02 00:03:00 +02:00
|
|
|
|
2003-06-16 22:26:50 +02:00
|
|
|
/* Secondary buffer description */
|
2004-05-10 21:56:17 +02:00
|
|
|
memset(&format, 0, sizeof(format));
|
2003-06-16 22:26:50 +02:00
|
|
|
format.wFormatTag = WAVE_FORMAT_PCM;
|
|
|
|
format.nChannels = 1;
|
|
|
|
format.nSamplesPerSec = 44000;
|
|
|
|
format.nAvgBytesPerSec = 44000*2;
|
|
|
|
format.nBlockAlign = 2;
|
|
|
|
format.wBitsPerSample = 16;
|
|
|
|
format.cbSize = 0;
|
|
|
|
|
2004-05-10 21:56:17 +02:00
|
|
|
memset(&desc, 0, sizeof(desc));
|
2003-06-16 22:26:50 +02:00
|
|
|
desc.dwSize = sizeof(desc);
|
2016-01-10 23:37:12 +01:00
|
|
|
desc.dwFlags = DSBCAPS_CTRLFX | DSBCAPS_CTRLVOLUME | DSBCAPS_GLOBALFOCUS;
|
2003-06-16 22:26:50 +02:00
|
|
|
desc.dwBufferBytes = DSBSIZE_MIN;
|
|
|
|
desc.dwReserved = 0;
|
|
|
|
desc.lpwfxFormat = &format;
|
|
|
|
desc.guid3DAlgorithm = GUID_NULL;
|
|
|
|
|
|
|
|
switch(dwType) {
|
2003-06-13 20:59:51 +02:00
|
|
|
case DMUS_APATH_DYNAMIC_3D:
|
2003-10-27 23:08:37 +01:00
|
|
|
desc.dwFlags |= DSBCAPS_CTRL3D | DSBCAPS_CTRLFREQUENCY | DSBCAPS_MUTE3DATMAXDISTANCE;
|
2003-06-16 22:26:50 +02:00
|
|
|
break;
|
2003-06-13 20:59:51 +02:00
|
|
|
case DMUS_APATH_DYNAMIC_MONO:
|
2016-01-10 23:37:12 +01:00
|
|
|
desc.dwFlags |= DSBCAPS_CTRLPAN | DSBCAPS_CTRLFREQUENCY;
|
2003-06-16 22:26:50 +02:00
|
|
|
break;
|
2003-10-27 23:08:37 +01:00
|
|
|
case DMUS_APATH_SHARED_STEREOPLUSREVERB:
|
2008-03-27 18:57:17 +01:00
|
|
|
/* normally we have to create 2 buffers (one for music other for reverb)
|
2003-10-27 23:08:37 +01:00
|
|
|
* in this case. See msdn
|
|
|
|
*/
|
2003-06-13 20:59:51 +02:00
|
|
|
case DMUS_APATH_DYNAMIC_STEREO:
|
2016-01-10 23:37:12 +01:00
|
|
|
desc.dwFlags |= DSBCAPS_CTRLPAN | DSBCAPS_CTRLFREQUENCY;
|
2003-06-16 22:26:50 +02:00
|
|
|
format.nChannels = 2;
|
|
|
|
format.nBlockAlign *= 2;
|
|
|
|
format.nAvgBytesPerSec *=2;
|
|
|
|
break;
|
2003-06-13 20:59:51 +02:00
|
|
|
default:
|
2003-10-27 23:08:37 +01:00
|
|
|
return E_INVALIDARG;
|
2003-06-13 20:59:51 +02:00
|
|
|
}
|
2003-06-18 05:18:23 +02:00
|
|
|
|
2003-06-16 22:26:50 +02:00
|
|
|
/* FIXME: Should we create one secondary buffer for each PChannel? */
|
2017-05-11 11:05:46 +02:00
|
|
|
hr = IDirectSound_CreateSoundBuffer(This->dsound, &desc, &buffer, NULL);
|
2015-04-27 00:49:04 +02:00
|
|
|
if (FAILED(hr))
|
2003-10-27 23:08:37 +01:00
|
|
|
return DSERR_BUFFERLOST;
|
2003-06-13 20:59:51 +02:00
|
|
|
|
2003-06-16 22:26:50 +02:00
|
|
|
/* Update description for creating primary buffer */
|
|
|
|
desc.dwFlags |= DSBCAPS_PRIMARYBUFFER;
|
2019-09-27 05:46:55 +02:00
|
|
|
desc.dwFlags &= ~DSBCAPS_CTRLFX;
|
2003-06-16 22:26:50 +02:00
|
|
|
desc.dwBufferBytes = 0;
|
|
|
|
desc.lpwfxFormat = NULL;
|
|
|
|
|
2017-05-11 11:05:46 +02:00
|
|
|
hr = IDirectSound_CreateSoundBuffer(This->dsound, &desc, &primary_buffer, NULL);
|
2003-10-27 23:08:37 +01:00
|
|
|
if (FAILED(hr)) {
|
2015-04-27 00:49:04 +02:00
|
|
|
IDirectSoundBuffer_Release(buffer);
|
2003-10-27 23:08:37 +01:00
|
|
|
return DSERR_BUFFERLOST;
|
|
|
|
}
|
2015-04-27 00:49:04 +02:00
|
|
|
|
|
|
|
create_dmaudiopath(&IID_IDirectMusicAudioPath, (void**)&pPath);
|
|
|
|
set_audiopath_perf_pointer(pPath, iface);
|
|
|
|
set_audiopath_dsound_buffer(pPath, buffer);
|
2015-05-14 12:09:16 +02:00
|
|
|
set_audiopath_primary_dsound_buffer(pPath, primary_buffer);
|
2003-06-16 22:26:50 +02:00
|
|
|
|
2007-12-08 00:01:46 +01:00
|
|
|
*ppNewPath = pPath;
|
2003-06-16 22:26:50 +02:00
|
|
|
|
2012-04-18 17:14:01 +02:00
|
|
|
TRACE(" returning IDirectMusicAudioPath interface at %p.\n", *ppNewPath);
|
2003-06-13 20:59:51 +02:00
|
|
|
|
2005-06-21 11:44:28 +02:00
|
|
|
return IDirectMusicAudioPath_Activate(*ppNewPath, fActivate);
|
2003-04-08 23:42:00 +02:00
|
|
|
}
|
|
|
|
|
2012-04-02 00:03:00 +02:00
|
|
|
static HRESULT WINAPI IDirectMusicPerformance8Impl_SetDefaultAudioPath(IDirectMusicPerformance8 *iface,
|
|
|
|
IDirectMusicAudioPath *pAudioPath)
|
|
|
|
{
|
|
|
|
IDirectMusicPerformance8Impl *This = impl_from_IDirectMusicPerformance8(iface);
|
2003-06-07 02:39:18 +02:00
|
|
|
|
2003-08-23 01:53:27 +02:00
|
|
|
FIXME("(%p, %p): semi-stub\n", This, pAudioPath);
|
2015-04-27 00:49:04 +02:00
|
|
|
|
|
|
|
if (This->pDefaultPath) {
|
2007-12-08 00:01:46 +01:00
|
|
|
IDirectMusicAudioPath_Release(This->pDefaultPath);
|
2003-08-23 01:53:27 +02:00
|
|
|
This->pDefaultPath = NULL;
|
|
|
|
}
|
|
|
|
This->pDefaultPath = pAudioPath;
|
2015-04-27 00:49:04 +02:00
|
|
|
if (This->pDefaultPath) {
|
2007-12-08 00:01:46 +01:00
|
|
|
IDirectMusicAudioPath_AddRef(This->pDefaultPath);
|
2015-04-27 00:49:04 +02:00
|
|
|
set_audiopath_perf_pointer(This->pDefaultPath, iface);
|
2003-08-23 01:53:27 +02:00
|
|
|
}
|
2012-04-02 00:03:00 +02:00
|
|
|
|
2003-08-23 01:53:27 +02:00
|
|
|
return S_OK;
|
2003-04-08 23:42:00 +02:00
|
|
|
}
|
|
|
|
|
2012-04-02 00:03:00 +02:00
|
|
|
static HRESULT WINAPI IDirectMusicPerformance8Impl_GetDefaultAudioPath(IDirectMusicPerformance8 *iface,
|
|
|
|
IDirectMusicAudioPath **ppAudioPath)
|
|
|
|
{
|
|
|
|
IDirectMusicPerformance8Impl *This = impl_from_IDirectMusicPerformance8(iface);
|
2003-06-07 02:39:18 +02:00
|
|
|
|
2004-05-05 03:32:55 +02:00
|
|
|
FIXME("(%p, %p): semi-stub (%p)\n", This, ppAudioPath, This->pDefaultPath);
|
2003-06-07 02:39:18 +02:00
|
|
|
|
2003-07-22 00:10:14 +02:00
|
|
|
if (NULL != This->pDefaultPath) {
|
2007-12-08 00:01:46 +01:00
|
|
|
*ppAudioPath = This->pDefaultPath;
|
2004-01-20 01:21:40 +01:00
|
|
|
IDirectMusicAudioPath_AddRef(*ppAudioPath);
|
2003-06-13 20:59:51 +02:00
|
|
|
} else {
|
|
|
|
*ppAudioPath = NULL;
|
|
|
|
}
|
2003-07-22 00:10:14 +02:00
|
|
|
return S_OK;
|
2003-04-08 23:42:00 +02:00
|
|
|
}
|
|
|
|
|
2012-04-02 00:03:00 +02:00
|
|
|
static HRESULT WINAPI IDirectMusicPerformance8Impl_GetParamEx(IDirectMusicPerformance8 *iface,
|
|
|
|
REFGUID rguidType, DWORD dwTrackID, DWORD dwGroupBits, DWORD dwIndex, MUSIC_TIME mtTime,
|
|
|
|
MUSIC_TIME *pmtNext, void *pParam)
|
|
|
|
{
|
|
|
|
IDirectMusicPerformance8Impl *This = impl_from_IDirectMusicPerformance8(iface);
|
2003-06-07 02:39:18 +02:00
|
|
|
|
2009-01-10 02:44:41 +01:00
|
|
|
FIXME("(%p, %s, %d, %d, %d, %d, %p, %p): stub\n", This, debugstr_dmguid(rguidType), dwTrackID, dwGroupBits, dwIndex, mtTime, pmtNext, pParam);
|
2003-06-07 02:39:18 +02:00
|
|
|
|
|
|
|
return S_OK;
|
2003-04-08 23:42:00 +02:00
|
|
|
}
|
|
|
|
|
2005-05-30 12:01:08 +02:00
|
|
|
static const IDirectMusicPerformance8Vtbl DirectMusicPerformance8_Vtbl = {
|
2003-04-08 23:42:00 +02:00
|
|
|
IDirectMusicPerformance8Impl_QueryInterface,
|
|
|
|
IDirectMusicPerformance8Impl_AddRef,
|
|
|
|
IDirectMusicPerformance8Impl_Release,
|
|
|
|
IDirectMusicPerformance8Impl_Init,
|
|
|
|
IDirectMusicPerformance8Impl_PlaySegment,
|
|
|
|
IDirectMusicPerformance8Impl_Stop,
|
|
|
|
IDirectMusicPerformance8Impl_GetSegmentState,
|
|
|
|
IDirectMusicPerformance8Impl_SetPrepareTime,
|
|
|
|
IDirectMusicPerformance8Impl_GetPrepareTime,
|
|
|
|
IDirectMusicPerformance8Impl_SetBumperLength,
|
|
|
|
IDirectMusicPerformance8Impl_GetBumperLength,
|
|
|
|
IDirectMusicPerformance8Impl_SendPMsg,
|
|
|
|
IDirectMusicPerformance8Impl_MusicToReferenceTime,
|
|
|
|
IDirectMusicPerformance8Impl_ReferenceToMusicTime,
|
|
|
|
IDirectMusicPerformance8Impl_IsPlaying,
|
|
|
|
IDirectMusicPerformance8Impl_GetTime,
|
|
|
|
IDirectMusicPerformance8Impl_AllocPMsg,
|
|
|
|
IDirectMusicPerformance8Impl_FreePMsg,
|
|
|
|
IDirectMusicPerformance8Impl_GetGraph,
|
|
|
|
IDirectMusicPerformance8Impl_SetGraph,
|
|
|
|
IDirectMusicPerformance8Impl_SetNotificationHandle,
|
|
|
|
IDirectMusicPerformance8Impl_GetNotificationPMsg,
|
|
|
|
IDirectMusicPerformance8Impl_AddNotificationType,
|
|
|
|
IDirectMusicPerformance8Impl_RemoveNotificationType,
|
|
|
|
IDirectMusicPerformance8Impl_AddPort,
|
|
|
|
IDirectMusicPerformance8Impl_RemovePort,
|
|
|
|
IDirectMusicPerformance8Impl_AssignPChannelBlock,
|
|
|
|
IDirectMusicPerformance8Impl_AssignPChannel,
|
|
|
|
IDirectMusicPerformance8Impl_PChannelInfo,
|
|
|
|
IDirectMusicPerformance8Impl_DownloadInstrument,
|
|
|
|
IDirectMusicPerformance8Impl_Invalidate,
|
|
|
|
IDirectMusicPerformance8Impl_GetParam,
|
|
|
|
IDirectMusicPerformance8Impl_SetParam,
|
|
|
|
IDirectMusicPerformance8Impl_GetGlobalParam,
|
|
|
|
IDirectMusicPerformance8Impl_SetGlobalParam,
|
|
|
|
IDirectMusicPerformance8Impl_GetLatencyTime,
|
|
|
|
IDirectMusicPerformance8Impl_GetQueueTime,
|
|
|
|
IDirectMusicPerformance8Impl_AdjustTime,
|
|
|
|
IDirectMusicPerformance8Impl_CloseDown,
|
|
|
|
IDirectMusicPerformance8Impl_GetResolvedTime,
|
|
|
|
IDirectMusicPerformance8Impl_MIDIToMusic,
|
|
|
|
IDirectMusicPerformance8Impl_MusicToMIDI,
|
|
|
|
IDirectMusicPerformance8Impl_TimeToRhythm,
|
|
|
|
IDirectMusicPerformance8Impl_RhythmToTime,
|
2004-05-05 03:32:55 +02:00
|
|
|
IDirectMusicPerformance8Impl_InitAudio,
|
|
|
|
IDirectMusicPerformance8Impl_PlaySegmentEx,
|
|
|
|
IDirectMusicPerformance8Impl_StopEx,
|
|
|
|
IDirectMusicPerformance8Impl_ClonePMsg,
|
|
|
|
IDirectMusicPerformance8Impl_CreateAudioPath,
|
|
|
|
IDirectMusicPerformance8Impl_CreateStandardAudioPath,
|
|
|
|
IDirectMusicPerformance8Impl_SetDefaultAudioPath,
|
|
|
|
IDirectMusicPerformance8Impl_GetDefaultAudioPath,
|
|
|
|
IDirectMusicPerformance8Impl_GetParamEx
|
2003-04-08 23:42:00 +02:00
|
|
|
};
|
2003-05-04 04:26:03 +02:00
|
|
|
|
|
|
|
/* for ClassFactory */
|
2014-01-10 10:41:27 +01:00
|
|
|
HRESULT WINAPI create_dmperformance(REFIID lpcGUID, void **ppobj)
|
|
|
|
{
|
2004-01-20 01:21:40 +01:00
|
|
|
IDirectMusicPerformance8Impl *obj;
|
|
|
|
|
2016-07-26 10:43:03 +02:00
|
|
|
TRACE("(%s, %p)\n", debugstr_guid(lpcGUID), ppobj);
|
2012-04-02 00:05:47 +02:00
|
|
|
|
2004-01-20 01:21:40 +01:00
|
|
|
obj = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicPerformance8Impl));
|
2012-04-02 00:05:47 +02:00
|
|
|
if (NULL == obj) {
|
2008-11-02 00:27:00 +01:00
|
|
|
*ppobj = NULL;
|
2004-01-20 01:21:40 +01:00
|
|
|
return E_OUTOFMEMORY;
|
2003-05-04 04:26:03 +02:00
|
|
|
}
|
2012-04-02 00:03:00 +02:00
|
|
|
obj->IDirectMusicPerformance8_iface.lpVtbl = &DirectMusicPerformance8_Vtbl;
|
2004-05-05 20:59:59 +02:00
|
|
|
obj->ref = 0; /* will be inited by QueryInterface */
|
2004-01-20 01:21:40 +01:00
|
|
|
obj->pDefaultPath = NULL;
|
2004-05-07 01:37:54 +02:00
|
|
|
InitializeCriticalSection(&obj->safe);
|
2007-03-08 16:34:00 +01:00
|
|
|
obj->safe.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": IDirectMusicPerformance8Impl*->safe");
|
2004-05-07 01:37:54 +02:00
|
|
|
|
2014-02-07 22:42:49 +01:00
|
|
|
obj->rtLatencyTime = 100; /* 100 ms TO FIX */
|
|
|
|
obj->dwBumperLength = 50; /* 50 ms default */
|
|
|
|
obj->dwPrepareTime = 1000; /* 1000 ms default */
|
2012-04-02 00:03:00 +02:00
|
|
|
return IDirectMusicPerformance8Impl_QueryInterface(&obj->IDirectMusicPerformance8_iface,
|
|
|
|
lpcGUID, ppobj);
|
2003-05-04 04:26:03 +02:00
|
|
|
}
|