* Sync with Wine 1.5.26.
svn path=/trunk/; revision=58739
-
-add_definitions(-D__WINESRC__)
-
remove_definitions(-D_WIN32_WINNT=0x502)
add_definitions(-D_WIN32_WINNT=0x600)
+add_definitions(-D__WINESRC__)
include_directories(${REACTOS_SOURCE_DIR}/include/reactos/wine)
-
spec2def(dmusic.dll dmusic.spec)
-add_library(dmusic SHARED
+list(APPEND SOURCE
buffer.c
clock.c
collection.c
dmusic.c
dmusic_main.c
download.c
- downloadedinstrument.c
instrument.c
port.c
- regsvr.c
version.rc
${CMAKE_CURRENT_BINARY_DIR}/dmusic.def)
+add_library(dmusic SHARED ${SOURCE})
set_module_type(dmusic win32dll UNICODE)
-
-target_link_libraries(dmusic
- dxguid
- uuid
- wine)
-
-add_importlibs(dmusic
- msvcrt
- user32
- advapi32
- ole32
- dsound
- kernel32
- ntdll)
-
+target_link_libraries(dmusic dxguid uuid wine)
+add_importlibs(dmusic ole32 advapi32 winmm msvcrt kernel32 ntdll)
add_dependencies(dmusic psdk)
add_pch(dmusic dmusic_private.h)
add_cd_file(TARGET dmusic DESTINATION reactos/system32 FOR all)
-/* IDirectMusicBuffer Implementation
+/*
+ * IDirectMusicBuffer Implementation
*
* Copyright (C) 2003-2004 Rok Mandeljc
+ * Copyright (C) 2012 Christian Costa
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
*/
#include "dmusic_private.h"
+//#include "initguid.h"
+#include "dmksctrl.h"
WINE_DEFAULT_DEBUG_CHANNEL(dmusic);
+static inline IDirectMusicBufferImpl *impl_from_IDirectMusicBuffer(IDirectMusicBuffer *iface)
+{
+ return CONTAINING_RECORD(iface, IDirectMusicBufferImpl, IDirectMusicBuffer_iface);
+}
+
/* IDirectMusicBufferImpl IUnknown part: */
-static HRESULT WINAPI IDirectMusicBufferImpl_QueryInterface (LPDIRECTMUSICBUFFER iface, REFIID riid, LPVOID *ppobj) {
- IDirectMusicBufferImpl *This = (IDirectMusicBufferImpl *)iface;
- TRACE("(%p, (%s, %p)\n",This,debugstr_dmguid(riid),ppobj);
- if (IsEqualIID (riid, &IID_IUnknown)
- || IsEqualIID (riid, &IID_IDirectMusicBuffer)) {
- IUnknown_AddRef(iface);
- *ppobj = This;
- return S_OK;
- }
- WARN("(%p, (%s, %p): not found\n",This,debugstr_dmguid(riid),ppobj);
- return E_NOINTERFACE;
+static HRESULT WINAPI IDirectMusicBufferImpl_QueryInterface(LPDIRECTMUSICBUFFER iface, REFIID riid, LPVOID *ret_iface)
+{
+ TRACE("(%p)->(%s, %p)\n", iface, debugstr_dmguid(riid), ret_iface);
+
+ if (IsEqualIID(riid, &IID_IUnknown) ||
+ IsEqualIID(riid, &IID_IDirectMusicBuffer))
+ {
+ IDirectMusicBuffer_AddRef(iface);
+ *ret_iface = iface;
+ return S_OK;
+ }
+
+ *ret_iface = NULL;
+
+ WARN("(%p)->(%s, %p): not found\n", iface, debugstr_dmguid(riid), ret_iface);
+
+ return E_NOINTERFACE;
}
-static ULONG WINAPI IDirectMusicBufferImpl_AddRef (LPDIRECTMUSICBUFFER iface) {
- IDirectMusicBufferImpl *This = (IDirectMusicBufferImpl *)iface;
- ULONG refCount = InterlockedIncrement(&This->ref);
+static ULONG WINAPI IDirectMusicBufferImpl_AddRef(LPDIRECTMUSICBUFFER iface)
+{
+ IDirectMusicBufferImpl *This = impl_from_IDirectMusicBuffer(iface);
+ ULONG ref = InterlockedIncrement(&This->ref);
- TRACE("(%p)->(ref before=%u)\n", This, refCount - 1);
+ TRACE("(%p)->(): new ref = %u\n", iface, ref);
- DMUSIC_LockModule();
+ DMUSIC_LockModule();
- return refCount;
+ return ref;
}
-static ULONG WINAPI IDirectMusicBufferImpl_Release (LPDIRECTMUSICBUFFER iface) {
- IDirectMusicBufferImpl *This = (IDirectMusicBufferImpl *)iface;
- ULONG refCount = InterlockedDecrement(&This->ref);
+static ULONG WINAPI IDirectMusicBufferImpl_Release(LPDIRECTMUSICBUFFER iface)
+{
+ IDirectMusicBufferImpl *This = impl_from_IDirectMusicBuffer(iface);
+ ULONG ref = InterlockedDecrement(&This->ref);
- TRACE("(%p)->(ref before=%u)\n", This, refCount + 1);
+ TRACE("(%p)->(): new ref = %u\n", iface, ref);
- if (!refCount) {
- HeapFree(GetProcessHeap(), 0, This);
- }
+ if (!ref) {
+ HeapFree(GetProcessHeap(), 0, This->data);
+ HeapFree(GetProcessHeap(), 0, This);
+ }
- DMUSIC_UnlockModule();
-
- return refCount;
+ DMUSIC_UnlockModule();
+
+ return ref;
}
/* IDirectMusicBufferImpl IDirectMusicBuffer part: */
-static HRESULT WINAPI IDirectMusicBufferImpl_Flush (LPDIRECTMUSICBUFFER iface) {
- IDirectMusicBufferImpl *This = (IDirectMusicBufferImpl *)iface;
- FIXME("(%p): stub\n", This);
- return S_OK;
+static HRESULT WINAPI IDirectMusicBufferImpl_Flush(LPDIRECTMUSICBUFFER iface)
+{
+ IDirectMusicBufferImpl *This = impl_from_IDirectMusicBuffer(iface);
+
+ TRACE("(%p)->()\n", iface);
+
+ This->write_pos = 0;
+
+ return S_OK;
}
-static HRESULT WINAPI IDirectMusicBufferImpl_TotalTime (LPDIRECTMUSICBUFFER iface, LPREFERENCE_TIME prtTime) {
- IDirectMusicBufferImpl *This = (IDirectMusicBufferImpl *)iface;
- FIXME("(%p, %p): stub\n", This, prtTime);
- return S_OK;
+static HRESULT WINAPI IDirectMusicBufferImpl_TotalTime(LPDIRECTMUSICBUFFER iface, LPREFERENCE_TIME prtTime)
+{
+ IDirectMusicBufferImpl *This = impl_from_IDirectMusicBuffer(iface);
+
+ FIXME("(%p, %p): stub\n", This, prtTime);
+
+ return S_OK;
}
-static HRESULT WINAPI IDirectMusicBufferImpl_PackStructured (LPDIRECTMUSICBUFFER iface, REFERENCE_TIME rt, DWORD dwChannelGroup, DWORD dwChannelMessage) {
- IDirectMusicBufferImpl *This = (IDirectMusicBufferImpl *)iface;
- FIXME("(%p, 0x%s, %d, %d): stub\n", This, wine_dbgstr_longlong(rt), dwChannelGroup, dwChannelMessage);
- return S_OK;
+static HRESULT WINAPI IDirectMusicBufferImpl_PackStructured(LPDIRECTMUSICBUFFER iface, REFERENCE_TIME ref_time, DWORD channel_group, DWORD channel_message)
+{
+ IDirectMusicBufferImpl *This = impl_from_IDirectMusicBuffer(iface);
+ DWORD new_write_pos = This->write_pos + sizeof(DMUS_EVENTHEADER) + sizeof(DWORD);
+ DMUS_EVENTHEADER header;
+
+ TRACE("(%p)->(0x%s, %u, 0x%x)\n", iface, wine_dbgstr_longlong(ref_time), channel_group, channel_message);
+
+ if (new_write_pos > This->size)
+ return DMUS_E_BUFFER_FULL;
+
+ /* Channel_message 0xZZYYXX (3 bytes) is a midi message where XX = status byte, YY = byte 1 and ZZ = byte 2 */
+
+ if (!(channel_message & 0x80))
+ {
+ /* Status byte MSB is always set */
+ return DMUS_E_INVALID_EVENT;
+ }
+
+ if (!This->write_pos)
+ This->start_time = ref_time;
+
+ header.cbEvent = 3; /* Midi message takes 4 bytes space but only 3 are relevant */
+ header.dwChannelGroup = channel_group;
+ header.rtDelta = ref_time - This->start_time;
+ header.dwFlags = DMUS_EVENT_STRUCTURED;
+
+ memcpy(This->data + This->write_pos, &header, sizeof(header));
+ *(DWORD*)(This->data + This->write_pos + sizeof(header)) = channel_message;
+ This->write_pos = new_write_pos;
+
+ return S_OK;
}
-static HRESULT WINAPI IDirectMusicBufferImpl_PackUnstructured (LPDIRECTMUSICBUFFER iface, REFERENCE_TIME rt, DWORD dwChannelGroup, DWORD cb, LPBYTE lpb) {
- IDirectMusicBufferImpl *This = (IDirectMusicBufferImpl *)iface;
- FIXME("(%p, 0x%s, %d, %d, %p): stub\n", This, wine_dbgstr_longlong(rt), dwChannelGroup, cb, lpb);
- return S_OK;
+static HRESULT WINAPI IDirectMusicBufferImpl_PackUnstructured(LPDIRECTMUSICBUFFER iface, REFERENCE_TIME rt, DWORD dwChannelGroup, DWORD cb, LPBYTE lpb)
+{
+ IDirectMusicBufferImpl *This = impl_from_IDirectMusicBuffer(iface);
+
+ FIXME("(%p, 0x%s, %d, %d, %p): stub\n", This, wine_dbgstr_longlong(rt), dwChannelGroup, cb, lpb);
+
+ return S_OK;
}
-static HRESULT WINAPI IDirectMusicBufferImpl_ResetReadPtr (LPDIRECTMUSICBUFFER iface) {
- IDirectMusicBufferImpl *This = (IDirectMusicBufferImpl *)iface;
- FIXME("(%p): stub\n", This);
- return S_OK;
+static HRESULT WINAPI IDirectMusicBufferImpl_ResetReadPtr(LPDIRECTMUSICBUFFER iface)
+{
+ IDirectMusicBufferImpl *This = impl_from_IDirectMusicBuffer(iface);
+
+ FIXME("(%p): stub\n", This);
+
+ return S_OK;
}
-static HRESULT WINAPI IDirectMusicBufferImpl_GetNextEvent (LPDIRECTMUSICBUFFER iface, LPREFERENCE_TIME prt, LPDWORD pdwChannelGroup, LPDWORD pdwLength, LPBYTE* ppData) {
- IDirectMusicBufferImpl *This = (IDirectMusicBufferImpl *)iface;
- FIXME("(%p, %p, %p, %p, %p): stub\n", This, prt, pdwChannelGroup, pdwLength, ppData);
- return S_OK;
+static HRESULT WINAPI IDirectMusicBufferImpl_GetNextEvent(LPDIRECTMUSICBUFFER iface, LPREFERENCE_TIME prt, LPDWORD pdwChannelGroup, LPDWORD pdwLength, LPBYTE* ppData)
+{
+ IDirectMusicBufferImpl *This = impl_from_IDirectMusicBuffer(iface);
+
+ FIXME("(%p, %p, %p, %p, %p): stub\n", This, prt, pdwChannelGroup, pdwLength, ppData);
+
+ return S_OK;
}
-static HRESULT WINAPI IDirectMusicBufferImpl_GetRawBufferPtr (LPDIRECTMUSICBUFFER iface, LPBYTE* ppData) {
- IDirectMusicBufferImpl *This = (IDirectMusicBufferImpl *)iface;
- FIXME("(%p, %p): stub\n", This, ppData);
- return S_OK;
+static HRESULT WINAPI IDirectMusicBufferImpl_GetRawBufferPtr(LPDIRECTMUSICBUFFER iface, LPBYTE* data)
+{
+ IDirectMusicBufferImpl *This = impl_from_IDirectMusicBuffer(iface);
+
+ TRACE("(%p)->(%p)\n", iface, data);
+
+ if (!data)
+ return E_POINTER;
+
+ *data = This->data;
+
+ return S_OK;
}
-static HRESULT WINAPI IDirectMusicBufferImpl_GetStartTime (LPDIRECTMUSICBUFFER iface, LPREFERENCE_TIME prt) {
- IDirectMusicBufferImpl *This = (IDirectMusicBufferImpl *)iface;
- FIXME("(%p, %p): stub\n", This, prt);
- return S_OK;
+static HRESULT WINAPI IDirectMusicBufferImpl_GetStartTime(LPDIRECTMUSICBUFFER iface, LPREFERENCE_TIME ref_time)
+{
+ IDirectMusicBufferImpl *This = impl_from_IDirectMusicBuffer(iface);
+
+ TRACE("(%p)->(%p)\n", iface, ref_time);
+
+ if (!ref_time)
+ return E_POINTER;
+ if (!This->write_pos)
+ return DMUS_E_BUFFER_EMPTY;
+
+ *ref_time = This->start_time;
+
+ return S_OK;
}
-static HRESULT WINAPI IDirectMusicBufferImpl_GetUsedBytes (LPDIRECTMUSICBUFFER iface, LPDWORD pcb) {
- IDirectMusicBufferImpl *This = (IDirectMusicBufferImpl *)iface;
- FIXME("(%p, %p): stub\n", This, pcb);
- return S_OK;
+static HRESULT WINAPI IDirectMusicBufferImpl_GetUsedBytes(LPDIRECTMUSICBUFFER iface, LPDWORD used_bytes)
+{
+ IDirectMusicBufferImpl *This = impl_from_IDirectMusicBuffer(iface);
+
+ TRACE("(%p)->(%p)\n", iface, used_bytes);
+
+ if (!used_bytes)
+ return E_POINTER;
+
+ *used_bytes = This->write_pos;
+
+ return S_OK;
}
-static HRESULT WINAPI IDirectMusicBufferImpl_GetMaxBytes (LPDIRECTMUSICBUFFER iface, LPDWORD pcb) {
- IDirectMusicBufferImpl *This = (IDirectMusicBufferImpl *)iface;
- FIXME("(%p, %p): stub\n", This, pcb);
- return S_OK;
+static HRESULT WINAPI IDirectMusicBufferImpl_GetMaxBytes(LPDIRECTMUSICBUFFER iface, LPDWORD max_bytes)
+{
+ IDirectMusicBufferImpl *This = impl_from_IDirectMusicBuffer(iface);
+
+ TRACE("(%p)->(%p)\n", iface, max_bytes);
+
+ if (!max_bytes)
+ return E_POINTER;
+
+ *max_bytes = This->size;
+
+ return S_OK;
}
-static HRESULT WINAPI IDirectMusicBufferImpl_GetBufferFormat (LPDIRECTMUSICBUFFER iface, LPGUID pGuidFormat) {
- IDirectMusicBufferImpl *This = (IDirectMusicBufferImpl *)iface;
- FIXME("(%p, %p): stub\n", This, pGuidFormat);
- return S_OK;
+static HRESULT WINAPI IDirectMusicBufferImpl_GetBufferFormat(LPDIRECTMUSICBUFFER iface, LPGUID format)
+{
+ IDirectMusicBufferImpl *This = impl_from_IDirectMusicBuffer(iface);
+
+ TRACE("(%p)->(%p)\n", iface, format);
+
+ if (!format)
+ return E_POINTER;
+
+ *format = This->format;
+ return S_OK;
}
-static HRESULT WINAPI IDirectMusicBufferImpl_SetStartTime (LPDIRECTMUSICBUFFER iface, REFERENCE_TIME rt) {
- IDirectMusicBufferImpl *This = (IDirectMusicBufferImpl *)iface;
- FIXME("(%p, 0x%s): stub\n", This, wine_dbgstr_longlong(rt));
- return S_OK;
+static HRESULT WINAPI IDirectMusicBufferImpl_SetStartTime(LPDIRECTMUSICBUFFER iface, REFERENCE_TIME ref_time)
+{
+ IDirectMusicBufferImpl *This = impl_from_IDirectMusicBuffer(iface);
+
+ TRACE("(%p)->(0x%s)\n", This, wine_dbgstr_longlong(ref_time));
+
+ This->start_time = ref_time;
+
+ return S_OK;
}
-static HRESULT WINAPI IDirectMusicBufferImpl_SetUsedBytes (LPDIRECTMUSICBUFFER iface, DWORD cb) {
- IDirectMusicBufferImpl *This = (IDirectMusicBufferImpl *)iface;
- FIXME("(%p, %d): stub\n", This, cb);
- return S_OK;
+static HRESULT WINAPI IDirectMusicBufferImpl_SetUsedBytes(LPDIRECTMUSICBUFFER iface, DWORD used_bytes)
+{
+ IDirectMusicBufferImpl *This = impl_from_IDirectMusicBuffer(iface);
+
+ TRACE("(%p)->(%u)\n", iface, used_bytes);
+
+ if (used_bytes > This->size)
+ return DMUS_E_BUFFER_FULL;
+
+ This->write_pos = used_bytes;
+
+ return S_OK;
}
static const IDirectMusicBufferVtbl DirectMusicBuffer_Vtbl = {
IDirectMusicBufferImpl_SetUsedBytes
};
-/* for ClassFactory */
-HRESULT WINAPI DMUSIC_CreateDirectMusicBufferImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter) {
- IDirectMusicBufferImpl* dmbuff;
-
- dmbuff = HeapAlloc (GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicBufferImpl));
- if (NULL == dmbuff) {
- *ppobj = NULL;
- return E_OUTOFMEMORY;
- }
- dmbuff->lpVtbl = &DirectMusicBuffer_Vtbl;
- dmbuff->ref = 0; /* will be inited by QueryInterface */
-
- return IDirectMusicBufferImpl_QueryInterface ((LPDIRECTMUSICBUFFER)dmbuff, lpcGUID, ppobj);
+HRESULT DMUSIC_CreateDirectMusicBufferImpl(LPDMUS_BUFFERDESC desc, LPVOID* ret_iface)
+{
+ IDirectMusicBufferImpl* dmbuffer;
+ HRESULT hr;
+
+ TRACE("(%p, %p)\n", desc, ret_iface);
+
+ *ret_iface = NULL;
+
+ dmbuffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicBufferImpl));
+ if (!dmbuffer)
+ return E_OUTOFMEMORY;
+
+ dmbuffer->IDirectMusicBuffer_iface.lpVtbl = &DirectMusicBuffer_Vtbl;
+ dmbuffer->ref = 0; /* Will be inited by QueryInterface */
+
+ if (IsEqualGUID(&desc->guidBufferFormat, &GUID_NULL))
+ dmbuffer->format = KSDATAFORMAT_SUBTYPE_MIDI;
+ else
+ dmbuffer->format = desc->guidBufferFormat;
+ dmbuffer->size = (desc->cbBuffer + 3) & ~3; /* Buffer size must be multiple of 4 bytes */
+
+ dmbuffer->data = HeapAlloc(GetProcessHeap(), 0, dmbuffer->size);
+ if (!dmbuffer->data) {
+ HeapFree(GetProcessHeap(), 0, dmbuffer);
+ return E_OUTOFMEMORY;
+ }
+
+ hr = IDirectMusicBufferImpl_QueryInterface((LPDIRECTMUSICBUFFER)dmbuffer, &IID_IDirectMusicBuffer, ret_iface);
+ if (FAILED(hr))
+ {
+ HeapFree(GetProcessHeap(), 0, dmbuffer->data);
+ HeapFree(GetProcessHeap(), 0, dmbuffer);
+ }
+
+ return hr;
}
-/* IReferenceClock Implementation
+/*
+ * IReferenceClock Implementation
*
* Copyright (C) 2003-2004 Rok Mandeljc
*
WINE_DEFAULT_DEBUG_CHANNEL(dmusic);
+static inline IReferenceClockImpl *impl_from_IReferenceClock(IReferenceClock *iface)
+{
+ return CONTAINING_RECORD(iface, IReferenceClockImpl, IReferenceClock_iface);
+}
+
/* IReferenceClockImpl IUnknown part: */
-static HRESULT WINAPI IReferenceClockImpl_QueryInterface (IReferenceClock *iface, REFIID riid, LPVOID *ppobj) {
- IReferenceClockImpl *This = (IReferenceClockImpl *)iface;
+static HRESULT WINAPI IReferenceClockImpl_QueryInterface(IReferenceClock *iface, REFIID riid, LPVOID *ppobj)
+{
+ IReferenceClockImpl *This = impl_from_IReferenceClock(iface);
TRACE("(%p, %s, %p)\n", This, debugstr_dmguid(riid), ppobj);
if (IsEqualIID (riid, &IID_IUnknown) ||
return E_NOINTERFACE;
}
-static ULONG WINAPI IReferenceClockImpl_AddRef (IReferenceClock *iface) {
- IReferenceClockImpl *This = (IReferenceClockImpl *)iface;
- ULONG refCount = InterlockedIncrement(&This->ref);
+static ULONG WINAPI IReferenceClockImpl_AddRef(IReferenceClock *iface)
+{
+ IReferenceClockImpl *This = impl_from_IReferenceClock(iface);
+ ULONG ref = InterlockedIncrement(&This->ref);
- TRACE("(%p)->(ref before=%u)\n", This, refCount - 1);
+ TRACE("(%p)->(): new ref = %u\n", This, ref);
- DMUSIC_LockModule();
+ DMUSIC_LockModule();
- return refCount;
+ return ref;
}
-static ULONG WINAPI IReferenceClockImpl_Release (IReferenceClock *iface) {
- IReferenceClockImpl *This = (IReferenceClockImpl *)iface;
- ULONG refCount = InterlockedDecrement(&This->ref);
+static ULONG WINAPI IReferenceClockImpl_Release(IReferenceClock *iface)
+{
+ IReferenceClockImpl *This = impl_from_IReferenceClock(iface);
+ ULONG ref = InterlockedDecrement(&This->ref);
- TRACE("(%p)->(ref before=%u)\n", This, refCount + 1);
+ TRACE("(%p)->(): new ref = %u\n", This, ref);
- if (!refCount) {
- HeapFree(GetProcessHeap(), 0, This);
- }
+ if (!ref)
+ HeapFree(GetProcessHeap(), 0, This);
- DMUSIC_UnlockModule();
+ DMUSIC_UnlockModule();
- return refCount;
+ return ref;
}
/* IReferenceClockImpl IReferenceClock part: */
-static HRESULT WINAPI IReferenceClockImpl_GetTime (IReferenceClock *iface, REFERENCE_TIME* pTime) {
- IReferenceClockImpl *This = (IReferenceClockImpl *)iface;
- TRACE("(%p, %p)\n", This, pTime);
- *pTime = This->rtTime;
- return S_OK;
+static HRESULT WINAPI IReferenceClockImpl_GetTime(IReferenceClock *iface, REFERENCE_TIME* pTime)
+{
+ IReferenceClockImpl *This = impl_from_IReferenceClock(iface);
+
+ TRACE("(%p)->(%p)\n", This, pTime);
+
+ *pTime = This->rtTime;
+
+ return S_OK;
}
-static HRESULT WINAPI IReferenceClockImpl_AdviseTime (IReferenceClock *iface, REFERENCE_TIME baseTime, REFERENCE_TIME streamTime, HANDLE hEvent, DWORD* pdwAdviseCookie) {
- IReferenceClockImpl *This = (IReferenceClockImpl *)iface;
- FIXME("(%p, 0x%s, 0x%s, %p, %p): stub\n", This, wine_dbgstr_longlong(baseTime), wine_dbgstr_longlong(streamTime), hEvent, pdwAdviseCookie);
- return S_OK;
+static HRESULT WINAPI IReferenceClockImpl_AdviseTime(IReferenceClock *iface, REFERENCE_TIME baseTime, REFERENCE_TIME streamTime, HANDLE hEvent, DWORD* pdwAdviseCookie)
+{
+ IReferenceClockImpl *This = impl_from_IReferenceClock(iface);
+
+ FIXME("(%p)->(0x%s, 0x%s, %p, %p): stub\n", This, wine_dbgstr_longlong(baseTime), wine_dbgstr_longlong(streamTime), hEvent, pdwAdviseCookie);
+
+ return S_OK;
}
-static HRESULT WINAPI IReferenceClockImpl_AdvisePeriodic (IReferenceClock *iface, REFERENCE_TIME startTime, REFERENCE_TIME periodTime, HANDLE hSemaphore, DWORD* pdwAdviseCookie) {
- IReferenceClockImpl *This = (IReferenceClockImpl *)iface;
- FIXME("(%p, 0x%s, 0x%s, %p, %p): stub\n", This, wine_dbgstr_longlong(startTime), wine_dbgstr_longlong(periodTime), hSemaphore, pdwAdviseCookie);
- return S_OK;
+static HRESULT WINAPI IReferenceClockImpl_AdvisePeriodic(IReferenceClock *iface, REFERENCE_TIME startTime, REFERENCE_TIME periodTime, HANDLE hSemaphore, DWORD* pdwAdviseCookie)
+{
+ IReferenceClockImpl *This = impl_from_IReferenceClock(iface);
+
+ FIXME("(%p)->(0x%s, 0x%s, %p, %p): stub\n", This, wine_dbgstr_longlong(startTime), wine_dbgstr_longlong(periodTime), hSemaphore, pdwAdviseCookie);
+
+ return S_OK;
}
-static HRESULT WINAPI IReferenceClockImpl_Unadvise (IReferenceClock *iface, DWORD dwAdviseCookie) {
- IReferenceClockImpl *This = (IReferenceClockImpl *)iface;
- FIXME("(%p, %d): stub\n", This, dwAdviseCookie);
- return S_OK;
+static HRESULT WINAPI IReferenceClockImpl_Unadvise(IReferenceClock *iface, DWORD dwAdviseCookie)
+{
+ IReferenceClockImpl *This = impl_from_IReferenceClock(iface);
+
+ FIXME("(%p)->(%d): stub\n", This, dwAdviseCookie);
+
+ return S_OK;
}
static const IReferenceClockVtbl ReferenceClock_Vtbl = {
};
/* for ClassFactory */
-HRESULT WINAPI DMUSIC_CreateReferenceClockImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter) {
- IReferenceClockImpl* clock;
+HRESULT DMUSIC_CreateReferenceClockImpl(LPCGUID riid, LPVOID* ret_iface, LPUNKNOWN unkouter)
+{
+ IReferenceClockImpl* clock;
- clock = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IReferenceClockImpl));
- if (NULL == clock) {
- *ppobj = NULL;
- return E_OUTOFMEMORY;
- }
- clock->lpVtbl = &ReferenceClock_Vtbl;
- clock->ref = 0; /* will be inited by QueryInterface */
- clock->rtTime = 0;
- clock->pClockInfo.dwSize = sizeof (DMUS_CLOCKINFO);
-
- return IReferenceClockImpl_QueryInterface ((IReferenceClock *)clock, lpcGUID, ppobj);
+ TRACE("(%p,%p,%p)\n", riid, ret_iface, unkouter);
+
+ clock = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IReferenceClockImpl));
+ if (!clock) {
+ *ret_iface = NULL;
+ return E_OUTOFMEMORY;
+ }
+
+ clock->IReferenceClock_iface.lpVtbl = &ReferenceClock_Vtbl;
+ clock->ref = 0; /* Will be inited by QueryInterface */
+ clock->rtTime = 0;
+ clock->pClockInfo.dwSize = sizeof (DMUS_CLOCKINFO);
+
+ return IReferenceClockImpl_QueryInterface((IReferenceClock*)clock, riid, ret_iface);
}
-/* IDirectMusicCollection Implementation
+/*
+ * IDirectMusicCollection Implementation
*
* Copyright (C) 2003-2004 Rok Mandeljc
*
WINE_DEFAULT_DEBUG_CHANNEL(dmusic);
WINE_DECLARE_DEBUG_CHANNEL(dmfile);
-static ULONG WINAPI IDirectMusicCollectionImpl_IUnknown_AddRef (LPUNKNOWN iface);
-static ULONG WINAPI IDirectMusicCollectionImpl_IDirectMusicCollection_AddRef (LPDIRECTMUSICCOLLECTION iface);
-static ULONG WINAPI IDirectMusicCollectionImpl_IDirectMusicObject_AddRef (LPDIRECTMUSICOBJECT iface);
-static ULONG WINAPI IDirectMusicCollectionImpl_IPersistStream_AddRef (LPPERSISTSTREAM iface);
+static inline IDirectMusicCollectionImpl *impl_from_IDirectMusicCollection(IDirectMusicCollection *iface)
+{
+ return CONTAINING_RECORD(iface, IDirectMusicCollectionImpl, IDirectMusicCollection_iface);
+}
+
+static inline IDirectMusicCollectionImpl *impl_from_IDirectMusicObject(IDirectMusicObject *iface)
+{
+ return CONTAINING_RECORD(iface, IDirectMusicCollectionImpl, IDirectMusicObject_iface);
+}
+
+static inline IDirectMusicCollectionImpl *impl_from_IPersistStream(IPersistStream *iface)
+{
+ return CONTAINING_RECORD(iface, IDirectMusicCollectionImpl, IPersistStream_iface);
+}
/*****************************************************************************
* IDirectMusicCollectionImpl implementation
*/
/* IDirectMusicCollectionImpl IUnknown part: */
-static HRESULT WINAPI IDirectMusicCollectionImpl_IUnknown_QueryInterface (LPUNKNOWN iface, REFIID riid, LPVOID *ppobj) {
- ICOM_THIS_MULTI(IDirectMusicCollectionImpl, UnknownVtbl, iface);
- TRACE("(%p, %s, %p)\n", This, debugstr_dmguid(riid), ppobj);
-
- if (IsEqualIID (riid, &IID_IUnknown)) {
- *ppobj = &This->UnknownVtbl;
- IDirectMusicCollectionImpl_IUnknown_AddRef ((LPUNKNOWN)&This->UnknownVtbl);
- return S_OK;
- } else if (IsEqualIID (riid, &IID_IDirectMusicCollection)) {
- *ppobj = &This->CollectionVtbl;
- IDirectMusicCollectionImpl_IDirectMusicCollection_AddRef ((LPDIRECTMUSICCOLLECTION)&This->CollectionVtbl);
- return S_OK;
- } else if (IsEqualIID (riid, &IID_IDirectMusicObject)) {
- *ppobj = &This->ObjectVtbl;
- IDirectMusicCollectionImpl_IDirectMusicObject_AddRef ((LPDIRECTMUSICOBJECT)&This->ObjectVtbl);
- return S_OK;
- } else if (IsEqualIID (riid, &IID_IPersistStream)) {
- *ppobj = &This->PersistStreamVtbl;
- IDirectMusicCollectionImpl_IPersistStream_AddRef ((LPPERSISTSTREAM)&This->PersistStreamVtbl);
- return S_OK;
- }
-
- WARN("(%p, %s, %p): not found\n", This, debugstr_dmguid(riid), ppobj);
- return E_NOINTERFACE;
+static HRESULT WINAPI IDirectMusicCollectionImpl_IDirectMusicCollection_QueryInterface(LPDIRECTMUSICCOLLECTION iface, REFIID riid, LPVOID *ret_iface)
+{
+ IDirectMusicCollectionImpl *This = impl_from_IDirectMusicCollection(iface);
+
+ TRACE("(%p/%p)->(%s, %p)\n", iface, This, debugstr_dmguid(riid), ret_iface);
+
+ if (IsEqualIID(riid, &IID_IUnknown) ||
+ IsEqualIID(riid, &IID_IDirectMusicCollection))
+ {
+ *ret_iface = iface;
+ IDirectMusicCollection_AddRef(iface);
+ return S_OK;
+ }
+ else if (IsEqualIID(riid, &IID_IDirectMusicObject))
+ {
+ *ret_iface = &This->IDirectMusicObject_iface;
+ IDirectMusicCollection_AddRef(iface);
+ return S_OK;
+ }
+ else if (IsEqualIID(riid, &IID_IPersistStream))
+ {
+ *ret_iface = &This->IPersistStream_iface;
+ IDirectMusicCollection_AddRef(iface);
+ return S_OK;
+ }
+
+ *ret_iface = NULL;
+
+ WARN("(%p/%p)->(%s, %p): not found\n", iface, This, debugstr_dmguid(riid), ret_iface);
+
+ return E_NOINTERFACE;
}
-static ULONG WINAPI IDirectMusicCollectionImpl_IUnknown_AddRef (LPUNKNOWN iface) {
- ICOM_THIS_MULTI(IDirectMusicCollectionImpl, UnknownVtbl, iface);
- ULONG refCount = InterlockedIncrement(&This->ref);
+static ULONG WINAPI IDirectMusicCollectionImpl_IDirectMusicCollection_AddRef(LPDIRECTMUSICCOLLECTION iface)
+{
+ IDirectMusicCollectionImpl *This = impl_from_IDirectMusicCollection(iface);
+ ULONG ref = InterlockedIncrement(&This->ref);
- TRACE("(%p)->(ref before=%u)\n", This, refCount - 1);
+ TRACE("(%p/%p)->(): new ref = %u\n", iface, This, ref);
- DMUSIC_LockModule();
+ DMUSIC_LockModule();
- return refCount;
+ return ref;
}
-static ULONG WINAPI IDirectMusicCollectionImpl_IUnknown_Release (LPUNKNOWN iface) {
- ICOM_THIS_MULTI(IDirectMusicCollectionImpl, UnknownVtbl, iface);
- ULONG refCount = InterlockedDecrement(&This->ref);
-
- TRACE("(%p)->(ref before=%u)\n", This, refCount + 1);
-
- if (!refCount) {
- HeapFree(GetProcessHeap(), 0, This);
- }
-
- DMUSIC_UnlockModule();
+static ULONG WINAPI IDirectMusicCollectionImpl_IDirectMusicCollection_Release(LPDIRECTMUSICCOLLECTION iface)
+{
+ IDirectMusicCollectionImpl *This = impl_from_IDirectMusicCollection(iface);
+ ULONG ref = InterlockedDecrement(&This->ref);
- return refCount;
-}
+ TRACE("(%p/%p)->(): new ref = %u\n", iface, This, ref);
-static const IUnknownVtbl DirectMusicCollection_Unknown_Vtbl = {
- IDirectMusicCollectionImpl_IUnknown_QueryInterface,
- IDirectMusicCollectionImpl_IUnknown_AddRef,
- IDirectMusicCollectionImpl_IUnknown_Release
-};
+ if (!ref)
+ HeapFree(GetProcessHeap(), 0, This);
-/* IDirectMusicCollectionImpl IDirectMusicCollection part: */
-static HRESULT WINAPI IDirectMusicCollectionImpl_IDirectMusicCollection_QueryInterface (LPDIRECTMUSICCOLLECTION iface, REFIID riid, LPVOID *ppobj) {
- ICOM_THIS_MULTI(IDirectMusicCollectionImpl, CollectionVtbl, iface);
- return IDirectMusicCollectionImpl_IUnknown_QueryInterface ((LPUNKNOWN)&This->UnknownVtbl, riid, ppobj);
-}
+ DMUSIC_UnlockModule();
-static ULONG WINAPI IDirectMusicCollectionImpl_IDirectMusicCollection_AddRef (LPDIRECTMUSICCOLLECTION iface) {
- ICOM_THIS_MULTI(IDirectMusicCollectionImpl, CollectionVtbl, iface);
- return IDirectMusicCollectionImpl_IUnknown_AddRef ((LPUNKNOWN)&This->UnknownVtbl);
+ return ref;
}
-static ULONG WINAPI IDirectMusicCollectionImpl_IDirectMusicCollection_Release (LPDIRECTMUSICCOLLECTION iface) {
- ICOM_THIS_MULTI(IDirectMusicCollectionImpl, CollectionVtbl, iface);
- return IDirectMusicCollectionImpl_IUnknown_Release ((LPUNKNOWN)&This->UnknownVtbl);
+/* IDirectMusicCollection Interface follows: */
+static HRESULT WINAPI IDirectMusicCollectionImpl_IDirectMusicCollection_GetInstrument(LPDIRECTMUSICCOLLECTION iface, DWORD patch, IDirectMusicInstrument** instrument)
+{
+ IDirectMusicCollectionImpl *This = impl_from_IDirectMusicCollection(iface);
+ DMUS_PRIVATE_INSTRUMENTENTRY *inst_entry;
+ struct list *list_entry;
+ DWORD inst_patch;
+
+ TRACE("(%p/%p)->(%u, %p)\n", iface, This, patch, instrument);
+
+ LIST_FOR_EACH(list_entry, &This->Instruments) {
+ inst_entry = LIST_ENTRY(list_entry, DMUS_PRIVATE_INSTRUMENTENTRY, entry);
+ IDirectMusicInstrument_GetPatch(inst_entry->pInstrument, &inst_patch);
+ if (patch == inst_patch) {
+ *instrument = inst_entry->pInstrument;
+ IDirectMusicInstrument_AddRef(inst_entry->pInstrument);
+ IDirectMusicInstrumentImpl_CustomLoad(inst_entry->pInstrument, This->pStm);
+ TRACE(": returning instrument %p\n", *instrument);
+ return S_OK;
+ }
+ }
+
+ TRACE(": instrument not found\n");
+
+ return DMUS_E_INVALIDPATCH;
}
-/* IDirectMusicCollection Interface follow: */
-static HRESULT WINAPI IDirectMusicCollectionImpl_IDirectMusicCollection_GetInstrument (LPDIRECTMUSICCOLLECTION iface, DWORD dwPatch, IDirectMusicInstrument** ppInstrument) {
- ICOM_THIS_MULTI(IDirectMusicCollectionImpl, CollectionVtbl, iface);
- DMUS_PRIVATE_INSTRUMENTENTRY *tmpEntry;
- struct list *listEntry;
- DWORD dwInstPatch;
-
- TRACE("(%p, %d, %p)\n", This, dwPatch, ppInstrument);
-
- LIST_FOR_EACH (listEntry, &This->Instruments) {
- tmpEntry = LIST_ENTRY(listEntry, DMUS_PRIVATE_INSTRUMENTENTRY, entry);
- IDirectMusicInstrument_GetPatch (tmpEntry->pInstrument, &dwInstPatch);
- if (dwPatch == dwInstPatch) {
- *ppInstrument = tmpEntry->pInstrument;
- IDirectMusicInstrument_AddRef (tmpEntry->pInstrument);
- IDirectMusicInstrumentImpl_Custom_Load (tmpEntry->pInstrument, This->pStm); /* load instrument before returning it */
- TRACE(": returning instrument %p\n", *ppInstrument);
- return S_OK;
- }
-
- }
- TRACE(": instrument not found\n");
-
- return DMUS_E_INVALIDPATCH;
-}
-
-static HRESULT WINAPI IDirectMusicCollectionImpl_IDirectMusicCollection_EnumInstrument (LPDIRECTMUSICCOLLECTION iface, DWORD dwIndex, DWORD* pdwPatch, LPWSTR pwszName, DWORD dwNameLen) {
- ICOM_THIS_MULTI(IDirectMusicCollectionImpl, CollectionVtbl, iface);
- unsigned int r = 0;
- DMUS_PRIVATE_INSTRUMENTENTRY *tmpEntry;
- struct list *listEntry;
- DWORD dwLen;
-
- TRACE("(%p, %d, %p, %p, %d)\n", This, dwIndex, pdwPatch, pwszName, dwNameLen);
- LIST_FOR_EACH (listEntry, &This->Instruments) {
- tmpEntry = LIST_ENTRY(listEntry, DMUS_PRIVATE_INSTRUMENTENTRY, entry);
- if (r == dwIndex) {
- ICOM_NAME_MULTI (IDirectMusicInstrumentImpl, InstrumentVtbl, tmpEntry->pInstrument, pInstrument);
- IDirectMusicInstrument_GetPatch (tmpEntry->pInstrument, pdwPatch);
- if (pwszName) {
- dwLen = min(strlenW(pInstrument->wszName),dwNameLen-1);
- memcpy (pwszName, pInstrument->wszName, dwLen * sizeof(WCHAR));
- pwszName[dwLen] = '\0';
- }
- return S_OK;
- }
- r++;
- }
-
- return S_FALSE;
+static HRESULT WINAPI IDirectMusicCollectionImpl_IDirectMusicCollection_EnumInstrument(LPDIRECTMUSICCOLLECTION iface, DWORD index, DWORD* patch, LPWSTR name, DWORD name_length)
+{
+ IDirectMusicCollectionImpl *This = impl_from_IDirectMusicCollection(iface);
+ DWORD i = 0;
+ DMUS_PRIVATE_INSTRUMENTENTRY *inst_entry;
+ struct list *list_entry;
+ DWORD length;
+
+ TRACE("(%p/%p)->(%d, %p, %p, %d)\n", iface, This, index, patch, name, name_length);
+
+ LIST_FOR_EACH(list_entry, &This->Instruments) {
+ inst_entry = LIST_ENTRY(list_entry, DMUS_PRIVATE_INSTRUMENTENTRY, entry);
+ if (i == index) {
+ IDirectMusicInstrumentImpl *instrument = impl_from_IDirectMusicInstrument(inst_entry->pInstrument);
+ IDirectMusicInstrument_GetPatch(inst_entry->pInstrument, patch);
+ if (name) {
+ length = min(strlenW(instrument->wszName), name_length - 1);
+ memcpy(name, instrument->wszName, length * sizeof(WCHAR));
+ name[length] = '\0';
+ }
+ return S_OK;
+ }
+ i++;
+ }
+
+ return S_FALSE;
}
static const IDirectMusicCollectionVtbl DirectMusicCollection_Collection_Vtbl = {
};
/* IDirectMusicCollectionImpl IDirectMusicObject part: */
-static HRESULT WINAPI IDirectMusicCollectionImpl_IDirectMusicObject_QueryInterface (LPDIRECTMUSICOBJECT iface, REFIID riid, LPVOID *ppobj) {
- ICOM_THIS_MULTI(IDirectMusicCollectionImpl, ObjectVtbl, iface);
- return IDirectMusicCollectionImpl_IUnknown_QueryInterface ((LPUNKNOWN)&This->UnknownVtbl, riid, ppobj);
+static HRESULT WINAPI IDirectMusicCollectionImpl_IDirectMusicObject_QueryInterface(LPDIRECTMUSICOBJECT iface, REFIID riid, LPVOID *ret_iface)
+{
+ IDirectMusicCollectionImpl *This = impl_from_IDirectMusicObject(iface);
+ return IDirectMusicCollection_QueryInterface(&This->IDirectMusicCollection_iface, riid, ret_iface);
}
-static ULONG WINAPI IDirectMusicCollectionImpl_IDirectMusicObject_AddRef (LPDIRECTMUSICOBJECT iface) {
- ICOM_THIS_MULTI(IDirectMusicCollectionImpl, ObjectVtbl, iface);
- return IDirectMusicCollectionImpl_IUnknown_AddRef ((LPUNKNOWN)&This->UnknownVtbl);
+static ULONG WINAPI IDirectMusicCollectionImpl_IDirectMusicObject_AddRef(LPDIRECTMUSICOBJECT iface)
+{
+ IDirectMusicCollectionImpl *This = impl_from_IDirectMusicObject(iface);
+ return IDirectMusicCollection_AddRef(&This->IDirectMusicCollection_iface);
}
-static ULONG WINAPI IDirectMusicCollectionImpl_IDirectMusicObject_Release (LPDIRECTMUSICOBJECT iface) {
- ICOM_THIS_MULTI(IDirectMusicCollectionImpl, ObjectVtbl, iface);
- return IDirectMusicCollectionImpl_IUnknown_Release ((LPUNKNOWN)&This->UnknownVtbl);
+static ULONG WINAPI IDirectMusicCollectionImpl_IDirectMusicObject_Release(LPDIRECTMUSICOBJECT iface)
+{
+ IDirectMusicCollectionImpl *This = impl_from_IDirectMusicObject(iface);
+ return IDirectMusicCollection_Release(&This->IDirectMusicCollection_iface);
}
-static HRESULT WINAPI IDirectMusicCollectionImpl_IDirectMusicObject_GetDescriptor (LPDIRECTMUSICOBJECT iface, LPDMUS_OBJECTDESC pDesc) {
- ICOM_THIS_MULTI(IDirectMusicCollectionImpl, ObjectVtbl, iface);
- TRACE("(%p, %p)\n", This, pDesc);
- /* I think we shouldn't return pointer here since then values can be changed; it'd be a mess */
- memcpy (pDesc, This->pDesc, This->pDesc->dwSize);
- return S_OK;
+static HRESULT WINAPI IDirectMusicCollectionImpl_IDirectMusicObject_GetDescriptor(LPDIRECTMUSICOBJECT iface, LPDMUS_OBJECTDESC pDesc)
+{
+ IDirectMusicCollectionImpl *This = impl_from_IDirectMusicObject(iface);
+
+ TRACE("(%p/%p)->(%p)\n", iface, This, pDesc);
+
+ /* I think we shouldn't return pointer here since then values can be changed; it'd be a mess */
+ memcpy (pDesc, This->pDesc, This->pDesc->dwSize);
+
+ return S_OK;
}
-static HRESULT WINAPI IDirectMusicCollectionImpl_IDirectMusicObject_SetDescriptor (LPDIRECTMUSICOBJECT iface, LPDMUS_OBJECTDESC pDesc) {
- ICOM_THIS_MULTI(IDirectMusicCollectionImpl, ObjectVtbl, iface);
- TRACE("(%p, %p): setting descriptor:\n%s\n", This, pDesc, debugstr_DMUS_OBJECTDESC (pDesc));
+static HRESULT WINAPI IDirectMusicCollectionImpl_IDirectMusicObject_SetDescriptor(LPDIRECTMUSICOBJECT iface, LPDMUS_OBJECTDESC pDesc)
+{
+ IDirectMusicCollectionImpl *This = impl_from_IDirectMusicObject(iface);
+
+ TRACE("(%p, %p)\n", iface, pDesc);
+
+ if (!pDesc)
+ return E_POINTER;
+
+ if (TRACE_ON(dmusic))
+ {
+ TRACE("Setting descriptor:\n");
+ dump_DMUS_OBJECTDESC(pDesc);
+ }
/* According to MSDN, we should copy only given values, not whole struct */
if (pDesc->dwValidData & DMUS_OBJ_OBJECT)
return S_OK;
}
-static HRESULT WINAPI IDirectMusicCollectionImpl_IDirectMusicObject_ParseDescriptor (LPDIRECTMUSICOBJECT iface, LPSTREAM pStream, LPDMUS_OBJECTDESC pDesc) {
- ICOM_THIS_MULTI(IDirectMusicCollectionImpl, ObjectVtbl, iface);
- DMUS_PRIVATE_CHUNK Chunk;
- DWORD StreamSize, StreamCount, ListSize[1], ListCount[1];
- LARGE_INTEGER liMove; /* used when skipping chunks */
-
- TRACE("(%p, %p, %p)\n", This, pStream, pDesc);
-
- /* FIXME: should this be determined from stream? */
- pDesc->dwValidData |= DMUS_OBJ_CLASS;
- pDesc->guidClass = CLSID_DirectMusicCollection;
-
- IStream_Read (pStream, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
- TRACE_(dmfile)(": %s chunk (size = 0x%04x)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
- switch (Chunk.fccID) {
- case FOURCC_RIFF: {
- IStream_Read (pStream, &Chunk.fccID, sizeof(FOURCC), NULL);
- TRACE_(dmfile)(": RIFF chunk of type %s", debugstr_fourcc(Chunk.fccID));
- StreamSize = Chunk.dwSize - sizeof(FOURCC);
- StreamCount = 0;
- if (Chunk.fccID == mmioFOURCC('D','L','S',' ')) {
- TRACE_(dmfile)(": collection form\n");
- do {
- IStream_Read (pStream, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
- StreamCount += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
- TRACE_(dmfile)(": %s chunk (size = 0x%04x)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
- switch (Chunk.fccID) {
- case FOURCC_DLID: {
- TRACE_(dmfile)(": GUID chunk\n");
- pDesc->dwValidData |= DMUS_OBJ_OBJECT;
- IStream_Read (pStream, &pDesc->guidObject, Chunk.dwSize, NULL);
- break;
- }
- case DMUS_FOURCC_VERSION_CHUNK: {
- TRACE_(dmfile)(": version chunk\n");
- pDesc->dwValidData |= DMUS_OBJ_VERSION;
- IStream_Read (pStream, &pDesc->vVersion, Chunk.dwSize, NULL);
- break;
- }
- case DMUS_FOURCC_CATEGORY_CHUNK: {
- TRACE_(dmfile)(": category chunk\n");
- pDesc->dwValidData |= DMUS_OBJ_CATEGORY;
- IStream_Read (pStream, pDesc->wszCategory, Chunk.dwSize, NULL);
- break;
- }
- case FOURCC_LIST: {
- IStream_Read (pStream, &Chunk.fccID, sizeof(FOURCC), NULL);
- TRACE_(dmfile)(": LIST chunk of type %s", debugstr_fourcc(Chunk.fccID));
- ListSize[0] = Chunk.dwSize - sizeof(FOURCC);
- ListCount[0] = 0;
- switch (Chunk.fccID) {
- /* pure INFO list, such can be found in dls collections */
- case mmioFOURCC('I','N','F','O'): {
- TRACE_(dmfile)(": INFO list\n");
- do {
- IStream_Read (pStream, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
- ListCount[0] += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
- TRACE_(dmfile)(": %s chunk (size = 0x%04x)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
- switch (Chunk.fccID) {
- case mmioFOURCC('I','N','A','M'):{
- CHAR szName[DMUS_MAX_NAME];
- TRACE_(dmfile)(": name chunk\n");
- pDesc->dwValidData |= DMUS_OBJ_NAME;
- IStream_Read (pStream, szName, Chunk.dwSize, NULL);
- MultiByteToWideChar (CP_ACP, 0, szName, -1, pDesc->wszName, DMUS_MAX_NAME);
- if (even_or_odd(Chunk.dwSize)) {
- ListCount[0] ++;
- liMove.QuadPart = 1;
- IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL);
- }
- break;
- }
- case mmioFOURCC('I','A','R','T'): {
- TRACE_(dmfile)(": artist chunk (ignored)\n");
- if (even_or_odd(Chunk.dwSize)) {
- ListCount[0] ++;
- Chunk.dwSize++;
- }
- liMove.QuadPart = Chunk.dwSize;
- IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL);
- break;
- }
- case mmioFOURCC('I','C','O','P'): {
- TRACE_(dmfile)(": copyright chunk (ignored)\n");
- if (even_or_odd(Chunk.dwSize)) {
- ListCount[0] ++;
- Chunk.dwSize++;
- }
- liMove.QuadPart = Chunk.dwSize;
- IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL);
- break;
- }
- case mmioFOURCC('I','S','B','J'): {
- TRACE_(dmfile)(": subject chunk (ignored)\n");
- if (even_or_odd(Chunk.dwSize)) {
- ListCount[0] ++;
- Chunk.dwSize++;
- }
- liMove.QuadPart = Chunk.dwSize;
- IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL);
- break;
- }
- case mmioFOURCC('I','C','M','T'): {
- TRACE_(dmfile)(": comment chunk (ignored)\n");
- if (even_or_odd(Chunk.dwSize)) {
- ListCount[0] ++;
- Chunk.dwSize++;
- }
- liMove.QuadPart = Chunk.dwSize;
- IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL);
- break;
- }
- default: {
- TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
- if (even_or_odd(Chunk.dwSize)) {
- ListCount[0] ++;
- Chunk.dwSize++;
- }
- liMove.QuadPart = Chunk.dwSize;
- IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL);
- break;
- }
- }
- TRACE_(dmfile)(": ListCount[0] = %d < ListSize[0] = %d\n", ListCount[0], ListSize[0]);
- } while (ListCount[0] < ListSize[0]);
- break;
- }
- default: {
- TRACE_(dmfile)(": unknown (skipping)\n");
- liMove.QuadPart = Chunk.dwSize - sizeof(FOURCC);
- IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL);
- break;
- }
- }
- break;
- }
- default: {
- TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
- liMove.QuadPart = Chunk.dwSize;
- IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL);
- break;
- }
- }
- TRACE_(dmfile)(": StreamCount[0] = %d < StreamSize[0] = %d\n", StreamCount, StreamSize);
- } while (StreamCount < StreamSize);
- } else {
- TRACE_(dmfile)(": unexpected chunk; loading failed)\n");
- liMove.QuadPart = StreamSize;
- IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL); /* skip the rest of the chunk */
- return E_FAIL;
- }
-
- TRACE_(dmfile)(": reading finished\n");
- break;
- }
- default: {
- TRACE_(dmfile)(": unexpected chunk; loading failed)\n");
- liMove.QuadPart = Chunk.dwSize;
- IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL); /* skip the rest of the chunk */
- return DMUS_E_INVALIDFILE;
- }
- }
-
- TRACE(": returning descriptor:\n%s\n", debugstr_DMUS_OBJECTDESC (pDesc));
-
- return S_OK;
+static HRESULT read_from_stream(IStream *stream, void *data, ULONG size)
+{
+ ULONG read;
+ HRESULT hr;
+
+ hr = IStream_Read(stream, data, size, &read);
+ if (FAILED(hr)) {
+ TRACE("IStream_Read failed: %08x\n", hr);
+ return hr;
+ }
+ if (read < size) {
+ TRACE("Didn't read full chunk: %u < %u\n", read, size);
+ return E_FAIL;
+ }
+
+ return S_OK;
+}
+
+static HRESULT WINAPI IDirectMusicCollectionImpl_IDirectMusicObject_ParseDescriptor(LPDIRECTMUSICOBJECT iface, LPSTREAM stream, LPDMUS_OBJECTDESC desc)
+{
+ IDirectMusicCollectionImpl *This = impl_from_IDirectMusicObject(iface);
+ DMUS_PRIVATE_CHUNK chunk;
+ DWORD StreamSize, StreamCount, ListSize[1], ListCount[1];
+ LARGE_INTEGER liMove; /* used when skipping chunks */
+ HRESULT hr;
+
+ TRACE("(%p)->(%p, %p)\n", This, stream, desc);
+
+ /* FIXME: should this be determined from stream? */
+ desc->dwValidData |= DMUS_OBJ_CLASS;
+ desc->guidClass = CLSID_DirectMusicCollection;
+
+ hr = read_from_stream(stream, &chunk, sizeof(FOURCC) + sizeof(DWORD));
+ if (FAILED(hr))
+ return hr;
+ TRACE_(dmfile)(": %s chunk (size = 0x%04x)", debugstr_fourcc(chunk.fccID), chunk.dwSize);
+
+ if (chunk.fccID != FOURCC_RIFF) {
+ TRACE_(dmfile)(": unexpected chunk; loading failed)\n");
+ liMove.QuadPart = chunk.dwSize;
+ IStream_Seek(stream, liMove, STREAM_SEEK_CUR, NULL); /* skip the rest of the chunk */
+ return DMUS_E_INVALIDFILE;
+ }
+
+ hr = read_from_stream(stream, &chunk.fccID, sizeof(FOURCC));
+ if (FAILED(hr))
+ return hr;
+ TRACE_(dmfile)(": RIFF chunk of type %s", debugstr_fourcc(chunk.fccID));
+ StreamSize = chunk.dwSize - sizeof(FOURCC);
+
+ if (chunk.fccID != mmioFOURCC('D','L','S',' ')) {
+ TRACE_(dmfile)(": unexpected chunk; loading failed)\n");
+ liMove.QuadPart = StreamSize;
+ IStream_Seek(stream, liMove, STREAM_SEEK_CUR, NULL); /* skip the rest of the chunk */
+ return E_FAIL;
+ }
+
+ StreamCount = 0;
+ TRACE_(dmfile)(": collection form\n");
+
+ do {
+ hr = read_from_stream(stream, &chunk, sizeof(FOURCC) + sizeof(DWORD));
+ if (FAILED(hr))
+ return hr;
+ StreamCount += sizeof(FOURCC) + sizeof(DWORD) + chunk.dwSize;
+ TRACE_(dmfile)(": %s chunk (size = 0x%04x)", debugstr_fourcc(chunk.fccID), chunk.dwSize);
+ switch (chunk.fccID) {
+ case FOURCC_DLID:
+ TRACE_(dmfile)(": GUID chunk\n");
+ desc->dwValidData |= DMUS_OBJ_OBJECT;
+ hr = read_from_stream(stream, &desc->guidObject, chunk.dwSize);
+ if (FAILED(hr))
+ return hr;
+ break;
+
+ case DMUS_FOURCC_VERSION_CHUNK:
+ TRACE_(dmfile)(": version chunk\n");
+ desc->dwValidData |= DMUS_OBJ_VERSION;
+ hr = read_from_stream(stream, &desc->vVersion, chunk.dwSize);
+ if (FAILED(hr))
+ return hr;
+ break;
+
+ case DMUS_FOURCC_CATEGORY_CHUNK:
+ TRACE_(dmfile)(": category chunk\n");
+ desc->dwValidData |= DMUS_OBJ_CATEGORY;
+ hr = read_from_stream(stream, desc->wszCategory, chunk.dwSize);
+ if (FAILED(hr))
+ return hr;
+ break;
+
+ case FOURCC_LIST:
+ hr = read_from_stream(stream, &chunk.fccID, sizeof(FOURCC));
+ if (FAILED(hr))
+ return hr;
+ TRACE_(dmfile)(": LIST chunk of type %s", debugstr_fourcc(chunk.fccID));
+ ListSize[0] = chunk.dwSize - sizeof(FOURCC);
+ ListCount[0] = 0;
+ switch (chunk.fccID) {
+ /* pure INFO list, such can be found in dls collections */
+ case mmioFOURCC('I','N','F','O'):
+ TRACE_(dmfile)(": INFO list\n");
+ do {
+ hr = read_from_stream(stream, &chunk, sizeof(FOURCC) + sizeof(DWORD));
+ if (FAILED(hr))
+ return hr;
+ ListCount[0] += sizeof(FOURCC) + sizeof(DWORD) + chunk.dwSize;
+ TRACE_(dmfile)(": %s chunk (size = 0x%04x)", debugstr_fourcc(chunk.fccID), chunk.dwSize);
+ switch (chunk.fccID) {
+ case mmioFOURCC('I','N','A','M'): {
+ CHAR szName[DMUS_MAX_NAME];
+ TRACE_(dmfile)(": name chunk\n");
+ desc->dwValidData |= DMUS_OBJ_NAME;
+ hr = read_from_stream(stream, szName, chunk.dwSize);
+ if (FAILED(hr))
+ return hr;
+ MultiByteToWideChar (CP_ACP, 0, szName, -1, desc->wszName, DMUS_MAX_NAME);
+ if (even_or_odd(chunk.dwSize)) {
+ ListCount[0]++;
+ liMove.QuadPart = 1;
+ IStream_Seek(stream, liMove, STREAM_SEEK_CUR, NULL);
+ }
+ break;
+ }
+
+ case mmioFOURCC('I','A','R','T'):
+ TRACE_(dmfile)(": artist chunk (ignored)\n");
+ if (even_or_odd(chunk.dwSize)) {
+ ListCount[0]++;
+ chunk.dwSize++;
+ }
+ liMove.QuadPart = chunk.dwSize;
+ IStream_Seek(stream, liMove, STREAM_SEEK_CUR, NULL);
+ break;
+
+ case mmioFOURCC('I','C','O','P'):
+ TRACE_(dmfile)(": copyright chunk (ignored)\n");
+ if (even_or_odd(chunk.dwSize)) {
+ ListCount[0]++;
+ chunk.dwSize++;
+ }
+ liMove.QuadPart = chunk.dwSize;
+ IStream_Seek(stream, liMove, STREAM_SEEK_CUR, NULL);
+ break;
+
+ case mmioFOURCC('I','S','B','J'):
+ TRACE_(dmfile)(": subject chunk (ignored)\n");
+ if (even_or_odd(chunk.dwSize)) {
+ ListCount[0]++;
+ chunk.dwSize++;
+ }
+ liMove.QuadPart = chunk.dwSize;
+ IStream_Seek(stream, liMove, STREAM_SEEK_CUR, NULL);
+ break;
+
+ case mmioFOURCC('I','C','M','T'):
+ TRACE_(dmfile)(": comment chunk (ignored)\n");
+ if (even_or_odd(chunk.dwSize)) {
+ ListCount[0]++;
+ chunk.dwSize++;
+ liMove.QuadPart = chunk.dwSize;
+ IStream_Seek(stream, liMove, STREAM_SEEK_CUR, NULL);
+ break;
+ }
+
+ default:
+ TRACE_(dmfile)(": unknown chunk (irrelevant & skipping)\n");
+ if (even_or_odd(chunk.dwSize)) {
+ ListCount[0] ++;
+ chunk.dwSize++;
+ }
+ liMove.QuadPart = chunk.dwSize;
+ IStream_Seek(stream, liMove, STREAM_SEEK_CUR, NULL);
+ break;
+ }
+ TRACE_(dmfile)(": ListCount[0] = %d < ListSize[0] = %d\n", ListCount[0], ListSize[0]);
+ } while (ListCount[0] < ListSize[0]);
+ break;
+
+ default:
+ TRACE_(dmfile)(": unknown (skipping)\n");
+ liMove.QuadPart = chunk.dwSize - sizeof(FOURCC);
+ IStream_Seek(stream, liMove, STREAM_SEEK_CUR, NULL);
+ break;
+ }
+ break;
+
+ default:
+ TRACE_(dmfile)(": unknown chunk (irrelevant & skipping)\n");
+ liMove.QuadPart = chunk.dwSize;
+ IStream_Seek(stream, liMove, STREAM_SEEK_CUR, NULL);
+ break;
+ }
+ TRACE_(dmfile)(": StreamCount[0] = %d < StreamSize[0] = %d\n", StreamCount, StreamSize);
+ } while (StreamCount < StreamSize);
+
+ TRACE_(dmfile)(": reading finished\n");
+
+ if (TRACE_ON(dmusic)) {
+ TRACE("Returning descriptor:\n");
+ dump_DMUS_OBJECTDESC(desc);
+ }
+
+ return S_OK;
}
static const IDirectMusicObjectVtbl DirectMusicCollection_Object_Vtbl = {
};
/* IDirectMusicCollectionImpl IPersistStream part: */
-static HRESULT WINAPI IDirectMusicCollectionImpl_IPersistStream_QueryInterface (LPPERSISTSTREAM iface, REFIID riid, LPVOID *ppobj) {
- ICOM_THIS_MULTI(IDirectMusicCollectionImpl, PersistStreamVtbl, iface);
- return IDirectMusicCollectionImpl_IUnknown_QueryInterface ((LPUNKNOWN)&This->UnknownVtbl, riid, ppobj);
+static HRESULT WINAPI IDirectMusicCollectionImpl_IPersistStream_QueryInterface(LPPERSISTSTREAM iface, REFIID riid, LPVOID *ret_iface)
+{
+ IDirectMusicCollectionImpl *This = impl_from_IPersistStream(iface);
+ return IDirectMusicCollection_QueryInterface(&This->IDirectMusicCollection_iface, riid, ret_iface);
}
-static ULONG WINAPI IDirectMusicCollectionImpl_IPersistStream_AddRef (LPPERSISTSTREAM iface) {
- ICOM_THIS_MULTI(IDirectMusicCollectionImpl, PersistStreamVtbl, iface);
- return IDirectMusicCollectionImpl_IUnknown_AddRef ((LPUNKNOWN)&This->UnknownVtbl);
+static ULONG WINAPI IDirectMusicCollectionImpl_IPersistStream_AddRef (LPPERSISTSTREAM iface)
+{
+ IDirectMusicCollectionImpl *This = impl_from_IPersistStream(iface);
+ return IDirectMusicCollection_AddRef(&This->IDirectMusicCollection_iface);
}
-static ULONG WINAPI IDirectMusicCollectionImpl_IPersistStream_Release (LPPERSISTSTREAM iface) {
- ICOM_THIS_MULTI(IDirectMusicCollectionImpl, PersistStreamVtbl, iface);
- return IDirectMusicCollectionImpl_IUnknown_Release ((LPUNKNOWN)&This->UnknownVtbl);
+static ULONG WINAPI IDirectMusicCollectionImpl_IPersistStream_Release (LPPERSISTSTREAM iface)
+{
+ IDirectMusicCollectionImpl *This = impl_from_IPersistStream(iface);
+ return IDirectMusicCollection_Release(&This->IDirectMusicCollection_iface);
}
-static HRESULT WINAPI IDirectMusicCollectionImpl_IPersistStream_GetClassID (LPPERSISTSTREAM iface, CLSID* pClassID) {
- return E_NOTIMPL;
+static HRESULT WINAPI IDirectMusicCollectionImpl_IPersistStream_GetClassID(LPPERSISTSTREAM iface, CLSID* pClassID)
+{
+ return E_NOTIMPL;
}
-static HRESULT WINAPI IDirectMusicCollectionImpl_IPersistStream_IsDirty (LPPERSISTSTREAM iface) {
- return E_NOTIMPL;
+static HRESULT WINAPI IDirectMusicCollectionImpl_IPersistStream_IsDirty(LPPERSISTSTREAM iface)
+{
+ return E_NOTIMPL;
}
-static HRESULT WINAPI IDirectMusicCollectionImpl_IPersistStream_Load (LPPERSISTSTREAM iface, IStream* pStm) {
- ICOM_THIS_MULTI(IDirectMusicCollectionImpl, PersistStreamVtbl, iface);
-
- DMUS_PRIVATE_CHUNK Chunk;
- DWORD StreamSize, StreamCount, ListSize[3], ListCount[3];
- LARGE_INTEGER liMove; /* used when skipping chunks */
- ULARGE_INTEGER dlibCollectionPosition, dlibInstrumentPosition, dlibWavePoolPosition;
-
- IStream_AddRef (pStm); /* add count for later references */
- liMove.QuadPart = 0;
- IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, &dlibCollectionPosition); /* store offset, in case it'll be needed later */
- This->liCollectionPosition.QuadPart = dlibCollectionPosition.QuadPart;
- This->pStm = pStm;
-
- IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
- TRACE_(dmfile)(": %s chunk (size = 0x%04x)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
- switch (Chunk.fccID) {
- case FOURCC_RIFF: {
- IStream_Read (pStm, &Chunk.fccID, sizeof(FOURCC), NULL);
- TRACE_(dmfile)(": RIFF chunk of type %s", debugstr_fourcc(Chunk.fccID));
- StreamSize = Chunk.dwSize - sizeof(FOURCC);
- StreamCount = 0;
- switch (Chunk.fccID) {
- case FOURCC_DLS: {
- TRACE_(dmfile)(": collection form\n");
- do {
- IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
- StreamCount += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
- TRACE_(dmfile)(": %s chunk (size = 0x%04x)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
- switch (Chunk.fccID) {
- case FOURCC_COLH: {
- TRACE_(dmfile)(": collection header chunk\n");
- This->pHeader = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, Chunk.dwSize);
- IStream_Read (pStm, This->pHeader, Chunk.dwSize, NULL);
- break;
- }
- case FOURCC_DLID: {
- TRACE_(dmfile)(": DLID (GUID) chunk\n");
- This->pDesc->dwValidData |= DMUS_OBJ_OBJECT;
- IStream_Read (pStm, &This->pDesc->guidObject, Chunk.dwSize, NULL);
- break;
- }
- case FOURCC_VERS: {
- TRACE_(dmfile)(": version chunk\n");
- This->pDesc->dwValidData |= DMUS_OBJ_VERSION;
- IStream_Read (pStm, &This->pDesc->vVersion, Chunk.dwSize, NULL);
- break;
- }
- case FOURCC_PTBL: {
- TRACE_(dmfile)(": pool table chunk\n");
- This->pPoolTable = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, sizeof(POOLTABLE));
- IStream_Read (pStm, This->pPoolTable, sizeof(POOLTABLE), NULL);
- Chunk.dwSize -= sizeof(POOLTABLE);
- This->pPoolCues = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, This->pPoolTable->cCues*sizeof(POOLCUE));
- IStream_Read (pStm, This->pPoolCues, Chunk.dwSize, NULL);
- break;
- }
- case FOURCC_LIST: {
- IStream_Read (pStm, &Chunk.fccID, sizeof(FOURCC), NULL);
- TRACE_(dmfile)(": LIST chunk of type %s", debugstr_fourcc(Chunk.fccID));
- ListSize[0] = Chunk.dwSize - sizeof(FOURCC);
- ListCount[0] = 0;
- switch (Chunk.fccID) {
- case mmioFOURCC('I','N','F','O'): {
- TRACE_(dmfile)(": INFO list\n");
- do {
- IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
- ListCount[0] += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
- TRACE_(dmfile)(": %s chunk (size = 0x%04x)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
- switch (Chunk.fccID) {
- case mmioFOURCC('I','N','A','M'): {
- CHAR szName[DMUS_MAX_NAME];
- TRACE_(dmfile)(": name chunk\n");
- This->pDesc->dwValidData |= DMUS_OBJ_NAME;
- IStream_Read (pStm, szName, Chunk.dwSize, NULL);
- MultiByteToWideChar (CP_ACP, 0, szName, -1, This->pDesc->wszName, DMUS_MAX_NAME);
- if (even_or_odd(Chunk.dwSize)) {
- ListCount[0] ++;
- liMove.QuadPart = 1;
- IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
- }
- break;
- }
- case mmioFOURCC('I','A','R','T'): {
- TRACE_(dmfile)(": artist chunk (ignored)\n");
- if (even_or_odd(Chunk.dwSize)) {
- ListCount[0] ++;
- Chunk.dwSize++;
- }
- liMove.QuadPart = Chunk.dwSize;
- IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
- break;
- }
- case mmioFOURCC('I','C','O','P'): {
- TRACE_(dmfile)(": copyright chunk\n");
- This->szCopyright = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, Chunk.dwSize);
- IStream_Read (pStm, This->szCopyright, Chunk.dwSize, NULL);
- if (even_or_odd(Chunk.dwSize)) {
- ListCount[0] ++;
- liMove.QuadPart = 1;
- IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
- }
- break;
- }
- case mmioFOURCC('I','S','B','J'): {
- TRACE_(dmfile)(": subject chunk (ignored)\n");
- if (even_or_odd(Chunk.dwSize)) {
- ListCount[0] ++;
- Chunk.dwSize++;
- }
- liMove.QuadPart = Chunk.dwSize;
- IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
- break;
- }
- case mmioFOURCC('I','C','M','T'): {
- TRACE_(dmfile)(": comment chunk (ignored)\n");
- if (even_or_odd(Chunk.dwSize)) {
- ListCount[0] ++;
- Chunk.dwSize++;
- }
- liMove.QuadPart = Chunk.dwSize;
- IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
- break;
- }
- default: {
- TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
- if (even_or_odd(Chunk.dwSize)) {
- ListCount[0] ++;
- Chunk.dwSize++;
- }
- liMove.QuadPart = Chunk.dwSize;
- IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
- break;
- }
- }
- TRACE_(dmfile)(": ListCount[0] = %d < ListSize[0] = %d\n", ListCount[0], ListSize[0]);
- } while (ListCount[0] < ListSize[0]);
- break;
- }
- case FOURCC_WVPL: {
- TRACE_(dmfile)(": wave pool list (mark & skip)\n");
- liMove.QuadPart = 0;
- IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, &dlibWavePoolPosition); /* store position */
- This->liWavePoolTablePosition.QuadPart = dlibWavePoolPosition.QuadPart;
- liMove.QuadPart = Chunk.dwSize - sizeof(FOURCC);
- IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
- break;
- }
- case FOURCC_LINS: {
- TRACE_(dmfile)(": instruments list\n");
- do {
- IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
- ListCount[0] += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
- TRACE_(dmfile)(": %s chunk (size = 0x%04x)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
- switch (Chunk.fccID) {
- case FOURCC_LIST: {
- IStream_Read (pStm, &Chunk.fccID, sizeof(FOURCC), NULL);
- TRACE_(dmfile)(": LIST chunk of type %s", debugstr_fourcc(Chunk.fccID));
- ListSize[1] = Chunk.dwSize - sizeof(FOURCC);
- ListCount[1] = 0;
- switch (Chunk.fccID) {
- case FOURCC_INS: {
- LPDMUS_PRIVATE_INSTRUMENTENTRY pNewInstrument = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, sizeof(DMUS_PRIVATE_INSTRUMENTENTRY));
- TRACE_(dmfile)(": instrument list\n");
- DMUSIC_CreateDirectMusicInstrumentImpl (&IID_IDirectMusicInstrument, (LPVOID*)&pNewInstrument->pInstrument, NULL); /* only way to create this one... even M$ does it discretely */
- {
- ICOM_NAME_MULTI (IDirectMusicInstrumentImpl, InstrumentVtbl, pNewInstrument->pInstrument, pInstrument);
- liMove.QuadPart = 0;
- IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, &dlibInstrumentPosition);
- pInstrument->liInstrumentPosition.QuadPart = dlibInstrumentPosition.QuadPart - (2*sizeof(FOURCC) + sizeof(DWORD)); /* store offset, it'll be needed later */
-
- do {
- IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
- ListCount[1] += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
- TRACE_(dmfile)(": %s chunk (size = 0x%04x)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
- switch (Chunk.fccID) {
- case FOURCC_INSH: {
- TRACE_(dmfile)(": instrument header chunk\n");
- pInstrument->pHeader = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, Chunk.dwSize);
- IStream_Read (pStm, pInstrument->pHeader, Chunk.dwSize, NULL);
- break;
- }
- case FOURCC_DLID: {
- TRACE_(dmfile)(": DLID (GUID) chunk\n");
- pInstrument->pInstrumentID = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, Chunk.dwSize);
- IStream_Read (pStm, pInstrument->pInstrumentID, Chunk.dwSize, NULL);
- break;
- }
- case FOURCC_LIST: {
- IStream_Read (pStm, &Chunk.fccID, sizeof(FOURCC), NULL);
- TRACE_(dmfile)(": LIST chunk of type %s", debugstr_fourcc(Chunk.fccID));
- ListSize[2] = Chunk.dwSize - sizeof(FOURCC);
- ListCount[2] = 0;
- switch (Chunk.fccID) {
- default: {
- TRACE_(dmfile)(": unknown (skipping)\n");
- liMove.QuadPart = Chunk.dwSize - sizeof(FOURCC);
- IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
- break;
- }
- }
- break;
- }
- default: {
- TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
- liMove.QuadPart = Chunk.dwSize;
- IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
- break;
- }
- }
- TRACE_(dmfile)(": ListCount[1] = %d < ListSize[1] = %d\n", ListCount[1], ListSize[1]);
- } while (ListCount[1] < ListSize[1]);
- /* DEBUG: dumps whole instrument object tree: */
- if (TRACE_ON(dmusic)) {
- TRACE("*** IDirectMusicInstrument (%p) ***\n", pInstrument);
- if (pInstrument->pInstrumentID)
- TRACE(" - GUID = %s\n", debugstr_dmguid(pInstrument->pInstrumentID));
-
- TRACE(" - Instrument header:\n");
- TRACE(" - cRegions: %d\n", pInstrument->pHeader->cRegions);
- TRACE(" - Locale:\n");
- TRACE(" - ulBank: %d\n", pInstrument->pHeader->Locale.ulBank);
- TRACE(" - ulInstrument: %d\n", pInstrument->pHeader->Locale.ulInstrument);
- TRACE(" => dwPatch: %d\n", MIDILOCALE2Patch(&pInstrument->pHeader->Locale));
- }
- list_add_tail (&This->Instruments, &pNewInstrument->entry);
- }
- break;
- }
- }
- break;
- }
- default: {
- TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
- liMove.QuadPart = Chunk.dwSize;
- IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
- break;
- }
- }
- TRACE_(dmfile)(": ListCount[0] = %d < ListSize[0] = %d\n", ListCount[0], ListSize[0]);
- } while (ListCount[0] < ListSize[0]);
- break;
- }
- default: {
- TRACE_(dmfile)(": unknown (skipping)\n");
- liMove.QuadPart = Chunk.dwSize - sizeof(FOURCC);
- IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
- break;
- }
- }
- break;
- }
- default: {
- TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
- liMove.QuadPart = Chunk.dwSize;
- IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
- break;
- }
- }
- TRACE_(dmfile)(": StreamCount = %d < StreamSize = %d\n", StreamCount, StreamSize);
- } while (StreamCount < StreamSize);
- break;
- }
- default: {
- TRACE_(dmfile)(": unexpected chunk; loading failed)\n");
- liMove.QuadPart = StreamSize;
- IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL); /* skip the rest of the chunk */
- return E_FAIL;
- }
- }
- TRACE_(dmfile)(": reading finished\n");
- break;
- }
- default: {
- TRACE_(dmfile)(": unexpected chunk; loading failed)\n");
- liMove.QuadPart = Chunk.dwSize;
- IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL); /* skip the rest of the chunk */
- return E_FAIL;
- }
- }
-
- /* DEBUG: dumps whole collection object tree: */
- if (TRACE_ON(dmusic)) {
- int r = 0;
- DMUS_PRIVATE_INSTRUMENTENTRY *tmpEntry;
- struct list *listEntry;
-
- TRACE("*** IDirectMusicCollection (%p) ***\n", This->CollectionVtbl);
- if (This->pDesc->dwValidData & DMUS_OBJ_OBJECT)
- TRACE(" - GUID = %s\n", debugstr_dmguid(&This->pDesc->guidObject));
- if (This->pDesc->dwValidData & DMUS_OBJ_VERSION)
- TRACE(" - Version = %i,%i,%i,%i\n", (This->pDesc->vVersion.dwVersionMS >> 8) & 0x0000FFFF, This->pDesc->vVersion.dwVersionMS & 0x0000FFFF,
- (This->pDesc->vVersion.dwVersionLS >> 8) & 0x0000FFFF, This->pDesc->vVersion.dwVersionLS & 0x0000FFFF);
- if (This->pDesc->dwValidData & DMUS_OBJ_NAME)
- TRACE(" - Name = %s\n", debugstr_w(This->pDesc->wszName));
-
- TRACE(" - Collection header:\n");
- TRACE(" - cInstruments: %d\n", This->pHeader->cInstruments);
- TRACE(" - Instruments:\n");
-
- LIST_FOR_EACH (listEntry, &This->Instruments) {
- tmpEntry = LIST_ENTRY( listEntry, DMUS_PRIVATE_INSTRUMENTENTRY, entry );
- TRACE(" - Instrument[%i]: %p\n", r, tmpEntry->pInstrument);
- r++;
- }
- }
-
- return S_OK;
+static HRESULT WINAPI IDirectMusicCollectionImpl_IPersistStream_Load(LPPERSISTSTREAM iface, IStream* stream)
+{
+ IDirectMusicCollectionImpl *This = impl_from_IPersistStream(iface);
+ DMUS_PRIVATE_CHUNK chunk;
+ DWORD StreamSize, StreamCount, ListSize[2], ListCount[2];
+ LARGE_INTEGER liMove; /* used when skipping chunks */
+ ULARGE_INTEGER dlibCollectionPosition, dlibInstrumentPosition, dlibWavePoolPosition;
+
+ IStream_AddRef(stream); /* add count for later references */
+ liMove.QuadPart = 0;
+ IStream_Seek(stream, liMove, STREAM_SEEK_CUR, &dlibCollectionPosition); /* store offset, in case it'll be needed later */
+ This->liCollectionPosition.QuadPart = dlibCollectionPosition.QuadPart;
+ This->pStm = stream;
+
+ IStream_Read(stream, &chunk, sizeof(FOURCC) + sizeof(DWORD), NULL);
+ TRACE_(dmfile)(": %s chunk (size = 0x%04x)", debugstr_fourcc(chunk.fccID), chunk.dwSize);
+
+ if (chunk.fccID != FOURCC_RIFF) {
+ TRACE_(dmfile)(": unexpected chunk; loading failed)\n");
+ liMove.QuadPart = chunk.dwSize;
+ IStream_Seek(stream, liMove, STREAM_SEEK_CUR, NULL); /* skip the rest of the chunk */
+ return E_FAIL;
+ }
+
+ IStream_Read(stream, &chunk.fccID, sizeof(FOURCC), NULL);
+ TRACE_(dmfile)(": RIFF chunk of type %s", debugstr_fourcc(chunk.fccID));
+ StreamSize = chunk.dwSize - sizeof(FOURCC);
+ StreamCount = 0;
+
+ if (chunk.fccID != FOURCC_DLS) {
+ TRACE_(dmfile)(": unexpected chunk; loading failed)\n");
+ liMove.QuadPart = StreamSize;
+ IStream_Seek(stream, liMove, STREAM_SEEK_CUR, NULL); /* skip the rest of the chunk */
+ return E_FAIL;
+ }
+
+ TRACE_(dmfile)(": collection form\n");
+ do {
+ IStream_Read(stream, &chunk, sizeof(FOURCC) + sizeof(DWORD), NULL);
+ StreamCount += sizeof(FOURCC) + sizeof(DWORD) + chunk.dwSize;
+ TRACE_(dmfile)(": %s chunk (size = 0x%04x)", debugstr_fourcc(chunk.fccID), chunk.dwSize);
+ switch (chunk.fccID) {
+ case FOURCC_COLH: {
+ TRACE_(dmfile)(": collection header chunk\n");
+ This->pHeader = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, chunk.dwSize);
+ IStream_Read(stream, This->pHeader, chunk.dwSize, NULL);
+ break;
+ }
+ case FOURCC_DLID: {
+ TRACE_(dmfile)(": DLID (GUID) chunk\n");
+ This->pDesc->dwValidData |= DMUS_OBJ_OBJECT;
+ IStream_Read(stream, &This->pDesc->guidObject, chunk.dwSize, NULL);
+ break;
+ }
+ case FOURCC_VERS: {
+ TRACE_(dmfile)(": version chunk\n");
+ This->pDesc->dwValidData |= DMUS_OBJ_VERSION;
+ IStream_Read(stream, &This->pDesc->vVersion, chunk.dwSize, NULL);
+ break;
+ }
+ case FOURCC_PTBL: {
+ TRACE_(dmfile)(": pool table chunk\n");
+ This->pPoolTable = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(POOLTABLE));
+ IStream_Read(stream, This->pPoolTable, sizeof(POOLTABLE), NULL);
+ chunk.dwSize -= sizeof(POOLTABLE);
+ This->pPoolCues = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, This->pPoolTable->cCues * sizeof(POOLCUE));
+ IStream_Read(stream, This->pPoolCues, chunk.dwSize, NULL);
+ break;
+ }
+ case FOURCC_LIST: {
+ IStream_Read(stream, &chunk.fccID, sizeof(FOURCC), NULL);
+ TRACE_(dmfile)(": LIST chunk of type %s", debugstr_fourcc(chunk.fccID));
+ ListSize[0] = chunk.dwSize - sizeof(FOURCC);
+ ListCount[0] = 0;
+ switch (chunk.fccID) {
+ case mmioFOURCC('I','N','F','O'): {
+ TRACE_(dmfile)(": INFO list\n");
+ do {
+ IStream_Read(stream, &chunk, sizeof(FOURCC) + sizeof(DWORD), NULL);
+ ListCount[0] += sizeof(FOURCC) + sizeof(DWORD) + chunk.dwSize;
+ TRACE_(dmfile)(": %s chunk (size = 0x%04x)", debugstr_fourcc(chunk.fccID), chunk.dwSize);
+ switch (chunk.fccID) {
+ case mmioFOURCC('I','N','A','M'): {
+ CHAR szName[DMUS_MAX_NAME];
+ TRACE_(dmfile)(": name chunk\n");
+ This->pDesc->dwValidData |= DMUS_OBJ_NAME;
+ IStream_Read(stream, szName, chunk.dwSize, NULL);
+ MultiByteToWideChar(CP_ACP, 0, szName, -1, This->pDesc->wszName, DMUS_MAX_NAME);
+ if (even_or_odd(chunk.dwSize)) {
+ ListCount[0]++;
+ liMove.QuadPart = 1;
+ IStream_Seek(stream, liMove, STREAM_SEEK_CUR, NULL);
+ }
+ break;
+ }
+ case mmioFOURCC('I','A','R','T'): {
+ TRACE_(dmfile)(": artist chunk (ignored)\n");
+ if (even_or_odd(chunk.dwSize)) {
+ ListCount[0]++;
+ chunk.dwSize++;
+ }
+ liMove.QuadPart = chunk.dwSize;
+ IStream_Seek(stream, liMove, STREAM_SEEK_CUR, NULL);
+ break;
+ }
+ case mmioFOURCC('I','C','O','P'): {
+ TRACE_(dmfile)(": copyright chunk\n");
+ This->szCopyright = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, chunk.dwSize);
+ IStream_Read(stream, This->szCopyright, chunk.dwSize, NULL);
+ if (even_or_odd(chunk.dwSize)) {
+ ListCount[0]++;
+ liMove.QuadPart = 1;
+ IStream_Seek(stream, liMove, STREAM_SEEK_CUR, NULL);
+ }
+ break;
+ }
+ case mmioFOURCC('I','S','B','J'): {
+ TRACE_(dmfile)(": subject chunk (ignored)\n");
+ if (even_or_odd(chunk.dwSize)) {
+ ListCount[0]++;
+ chunk.dwSize++;
+ }
+ liMove.QuadPart = chunk.dwSize;
+ IStream_Seek(stream, liMove, STREAM_SEEK_CUR, NULL);
+ break;
+ }
+ case mmioFOURCC('I','C','M','T'): {
+ TRACE_(dmfile)(": comment chunk (ignored)\n");
+ if (even_or_odd(chunk.dwSize)) {
+ ListCount[0]++;
+ chunk.dwSize++;
+ }
+ liMove.QuadPart = chunk.dwSize;
+ IStream_Seek(stream, liMove, STREAM_SEEK_CUR, NULL);
+ break;
+ }
+ default: {
+ TRACE_(dmfile)(": unknown chunk (irrelevant & skipping)\n");
+ if (even_or_odd(chunk.dwSize)) {
+ ListCount[0]++;
+ chunk.dwSize++;
+ }
+ liMove.QuadPart = chunk.dwSize;
+ IStream_Seek(stream, liMove, STREAM_SEEK_CUR, NULL);
+ break;
+ }
+ }
+ TRACE_(dmfile)(": ListCount[0] = %d < ListSize[0] = %d\n", ListCount[0], ListSize[0]);
+ } while (ListCount[0] < ListSize[0]);
+ break;
+ }
+ case FOURCC_WVPL: {
+ TRACE_(dmfile)(": wave pool list (mark & skip)\n");
+ liMove.QuadPart = 0;
+ IStream_Seek(stream, liMove, STREAM_SEEK_CUR, &dlibWavePoolPosition); /* store position */
+ This->liWavePoolTablePosition.QuadPart = dlibWavePoolPosition.QuadPart;
+ liMove.QuadPart = chunk.dwSize - sizeof(FOURCC);
+ IStream_Seek(stream, liMove, STREAM_SEEK_CUR, NULL);
+ break;
+ }
+ case FOURCC_LINS: {
+ TRACE_(dmfile)(": instruments list\n");
+ do {
+ IStream_Read(stream, &chunk, sizeof(FOURCC) + sizeof(DWORD), NULL);
+ ListCount[0] += sizeof(FOURCC) + sizeof(DWORD) + chunk.dwSize;
+ TRACE_(dmfile)(": %s chunk (size = 0x%04x)", debugstr_fourcc(chunk.fccID), chunk.dwSize);
+ switch (chunk.fccID) {
+ case FOURCC_LIST: {
+ IStream_Read(stream, &chunk.fccID, sizeof(FOURCC), NULL);
+ TRACE_(dmfile)(": LIST chunk of type %s", debugstr_fourcc(chunk.fccID));
+ ListSize[1] = chunk.dwSize - sizeof(FOURCC);
+ ListCount[1] = 0;
+ switch (chunk.fccID) {
+ case FOURCC_INS: {
+ LPDMUS_PRIVATE_INSTRUMENTENTRY new_instrument = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(DMUS_PRIVATE_INSTRUMENTENTRY));
+ TRACE_(dmfile)(": instrument list\n");
+ /* Only way to create this one... even M$ does it discretely */
+ DMUSIC_CreateDirectMusicInstrumentImpl(&IID_IDirectMusicInstrument, (void**)&new_instrument->pInstrument, NULL);
+ {
+ IDirectMusicInstrumentImpl *instrument = impl_from_IDirectMusicInstrument(new_instrument->pInstrument);
+ /* Store offset and length, they will be needed when loading the instrument */
+ liMove.QuadPart = 0;
+ IStream_Seek(stream, liMove, STREAM_SEEK_CUR, &dlibInstrumentPosition);
+ instrument->liInstrumentPosition.QuadPart = dlibInstrumentPosition.QuadPart;
+ instrument->length = ListSize[1];
+ do {
+ IStream_Read(stream, &chunk, sizeof(FOURCC) + sizeof(DWORD), NULL);
+ ListCount[1] += sizeof(FOURCC) + sizeof(DWORD) + chunk.dwSize;
+ TRACE_(dmfile)(": %s chunk (size = 0x%04x)", debugstr_fourcc(chunk.fccID), chunk.dwSize);
+ switch (chunk.fccID) {
+ case FOURCC_INSH: {
+ TRACE_(dmfile)(": instrument header chunk\n");
+ IStream_Read(stream, &instrument->header, chunk.dwSize, NULL);
+ break;
+ }
+ case FOURCC_DLID: {
+ TRACE_(dmfile)(": DLID (GUID) chunk\n");
+ IStream_Read(stream, &instrument->id, chunk.dwSize, NULL);
+ break;
+ }
+ case FOURCC_LIST: {
+ IStream_Read(stream, &chunk.fccID, sizeof(FOURCC), NULL);
+ TRACE_(dmfile)(": LIST chunk of type %s", debugstr_fourcc(chunk.fccID));
+ switch (chunk.fccID) {
+ default: {
+ TRACE_(dmfile)(": unknown (skipping)\n");
+ liMove.QuadPart = chunk.dwSize - sizeof(FOURCC);
+ IStream_Seek(stream, liMove, STREAM_SEEK_CUR, NULL);
+ break;
+ }
+ }
+ break;
+ }
+ default: {
+ TRACE_(dmfile)(": unknown chunk (irrelevant & skipping)\n");
+ liMove.QuadPart = chunk.dwSize;
+ IStream_Seek(stream, liMove, STREAM_SEEK_CUR, NULL);
+ break;
+ }
+ }
+ TRACE_(dmfile)(": ListCount[1] = %d < ListSize[1] = %d\n", ListCount[1], ListSize[1]);
+ } while (ListCount[1] < ListSize[1]);
+ /* DEBUG: dumps whole instrument object tree: */
+ if (TRACE_ON(dmusic)) {
+ TRACE("*** IDirectMusicInstrument (%p) ***\n", instrument);
+ if (!IsEqualGUID(&instrument->id, &GUID_NULL))
+ TRACE(" - GUID = %s\n", debugstr_dmguid(&instrument->id));
+ TRACE(" - Instrument header:\n");
+ TRACE(" - cRegions: %d\n", instrument->header.cRegions);
+ TRACE(" - Locale:\n");
+ TRACE(" - ulBank: %d\n", instrument->header.Locale.ulBank);
+ TRACE(" - ulInstrument: %d\n", instrument->header.Locale.ulInstrument);
+ TRACE(" => dwPatch: %d\n", MIDILOCALE2Patch(&instrument->header.Locale));
+ }
+ list_add_tail(&This->Instruments, &new_instrument->entry);
+ }
+ break;
+ }
+ }
+ break;
+ }
+ default: {
+ TRACE_(dmfile)(": unknown chunk (irrelevant & skipping)\n");
+ liMove.QuadPart = chunk.dwSize;
+ IStream_Seek(stream, liMove, STREAM_SEEK_CUR, NULL);
+ break;
+ }
+ }
+ TRACE_(dmfile)(": ListCount[0] = %d < ListSize[0] = %d\n", ListCount[0], ListSize[0]);
+ } while (ListCount[0] < ListSize[0]);
+ break;
+ }
+ default: {
+ TRACE_(dmfile)(": unknown (skipping)\n");
+ liMove.QuadPart = chunk.dwSize - sizeof(FOURCC);
+ IStream_Seek(stream, liMove, STREAM_SEEK_CUR, NULL);
+ break;
+ }
+ }
+ break;
+ }
+ default: {
+ TRACE_(dmfile)(": unknown chunk (irrelevant & skipping)\n");
+ liMove.QuadPart = chunk.dwSize;
+ IStream_Seek(stream, liMove, STREAM_SEEK_CUR, NULL);
+ break;
+ }
+ }
+ TRACE_(dmfile)(": StreamCount = %d < StreamSize = %d\n", StreamCount, StreamSize);
+ } while (StreamCount < StreamSize);
+
+ TRACE_(dmfile)(": reading finished\n");
+
+
+ /* DEBUG: dumps whole collection object tree: */
+ if (TRACE_ON(dmusic)) {
+ int r = 0;
+ DMUS_PRIVATE_INSTRUMENTENTRY *tmpEntry;
+ struct list *listEntry;
+
+ TRACE("*** IDirectMusicCollection (%p) ***\n", &This->IDirectMusicCollection_iface);
+ if (This->pDesc->dwValidData & DMUS_OBJ_OBJECT)
+ TRACE(" - GUID = %s\n", debugstr_dmguid(&This->pDesc->guidObject));
+ if (This->pDesc->dwValidData & DMUS_OBJ_VERSION)
+ TRACE(" - Version = %i,%i,%i,%i\n", (This->pDesc->vVersion.dwVersionMS >> 8) & 0x0000FFFF, This->pDesc->vVersion.dwVersionMS & 0x0000FFFF,
+ (This->pDesc->vVersion.dwVersionLS >> 8) & 0x0000FFFF, This->pDesc->vVersion.dwVersionLS & 0x0000FFFF);
+ if (This->pDesc->dwValidData & DMUS_OBJ_NAME)
+ TRACE(" - Name = %s\n", debugstr_w(This->pDesc->wszName));
+
+ TRACE(" - Collection header:\n");
+ TRACE(" - cInstruments: %d\n", This->pHeader->cInstruments);
+ TRACE(" - Instruments:\n");
+
+ LIST_FOR_EACH(listEntry, &This->Instruments) {
+ tmpEntry = LIST_ENTRY( listEntry, DMUS_PRIVATE_INSTRUMENTENTRY, entry );
+ TRACE(" - Instrument[%i]: %p\n", r, tmpEntry->pInstrument);
+ r++;
+ }
+ }
+
+ return S_OK;
}
-static HRESULT WINAPI IDirectMusicCollectionImpl_IPersistStream_Save (LPPERSISTSTREAM iface, IStream* pStm, BOOL fClearDirty) {
- return E_NOTIMPL;
+static HRESULT WINAPI IDirectMusicCollectionImpl_IPersistStream_Save(LPPERSISTSTREAM iface, IStream* pStm, BOOL fClearDirty)
+{
+ return E_NOTIMPL;
}
-static HRESULT WINAPI IDirectMusicCollectionImpl_IPersistStream_GetSizeMax (LPPERSISTSTREAM iface, ULARGE_INTEGER* pcbSize) {
- return E_NOTIMPL;
+static HRESULT WINAPI IDirectMusicCollectionImpl_IPersistStream_GetSizeMax(LPPERSISTSTREAM iface, ULARGE_INTEGER* pcbSize)
+{
+ return E_NOTIMPL;
}
static const IPersistStreamVtbl DirectMusicCollection_PersistStream_Vtbl = {
/* for ClassFactory */
-HRESULT WINAPI DMUSIC_CreateDirectMusicCollectionImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter) {
+HRESULT WINAPI DMUSIC_CreateDirectMusicCollectionImpl(LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter)
+{
IDirectMusicCollectionImpl* obj;
obj = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicCollectionImpl));
*ppobj = NULL;
return E_OUTOFMEMORY;
}
- obj->UnknownVtbl = &DirectMusicCollection_Unknown_Vtbl;
- obj->CollectionVtbl = &DirectMusicCollection_Collection_Vtbl;
- obj->ObjectVtbl = &DirectMusicCollection_Object_Vtbl;
- obj->PersistStreamVtbl = &DirectMusicCollection_PersistStream_Vtbl;
+ obj->IDirectMusicCollection_iface.lpVtbl = &DirectMusicCollection_Collection_Vtbl;
+ obj->IDirectMusicObject_iface.lpVtbl = &DirectMusicCollection_Object_Vtbl;
+ obj->IPersistStream_iface.lpVtbl = &DirectMusicCollection_PersistStream_Vtbl;
obj->pDesc = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(DMUS_OBJECTDESC));
DM_STRUCT_INIT(obj->pDesc);
obj->pDesc->dwValidData |= DMUS_OBJ_CLASS;
obj->ref = 0; /* will be inited by QueryInterface */
list_init (&obj->Instruments);
- return IDirectMusicCollectionImpl_IUnknown_QueryInterface ((LPUNKNOWN)&obj->UnknownVtbl, lpcGUID, ppobj);
+ return IDirectMusicCollection_QueryInterface(&obj->IDirectMusicCollection_iface, lpcGUID, ppobj);
}
-/* IDirectMusic8 Implementation
+/*
+ * IDirectMusic8 Implementation
*
* Copyright (C) 2003-2004 Rok Mandeljc
+ * Copyright (C) 2012 Christian Costa
*
* This program is free software; you can redistribute it and/or
* modify it under the terms 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
*/
+
+//#include <stdio.h>
+
#include "dmusic_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(dmusic);
+static inline IDirectMusic8Impl *impl_from_IDirectMusic8(IDirectMusic8 *iface)
+{
+ return CONTAINING_RECORD(iface, IDirectMusic8Impl, IDirectMusic8_iface);
+}
+
/* IDirectMusic8Impl IUnknown part: */
-static HRESULT WINAPI IDirectMusic8Impl_QueryInterface (LPDIRECTMUSIC8 iface, REFIID riid, LPVOID *ppobj) {
- IDirectMusic8Impl *This = (IDirectMusic8Impl *)iface;
- TRACE("(%p, %s, %p)\n", This, debugstr_dmguid(riid), ppobj);
-
- if (IsEqualIID (riid, &IID_IUnknown) ||
- IsEqualIID (riid, &IID_IDirectMusic) ||
- IsEqualIID (riid, &IID_IDirectMusic2) ||
- IsEqualIID (riid, &IID_IDirectMusic8)) {
- IUnknown_AddRef(iface);
- *ppobj = This;
- return S_OK;
- }
-
- WARN("(%p, %s, %p): not found\n", This, debugstr_dmguid(riid), ppobj);
- return E_NOINTERFACE;
+static HRESULT WINAPI IDirectMusic8Impl_QueryInterface(LPDIRECTMUSIC8 iface, REFIID riid, LPVOID *ret_iface)
+{
+ IDirectMusic8Impl *This = impl_from_IDirectMusic8(iface);
+
+ TRACE("(%p)->(%s, %p)\n", iface, debugstr_dmguid(riid), ret_iface);
+
+ if (IsEqualIID (riid, &IID_IUnknown) ||
+ IsEqualIID (riid, &IID_IDirectMusic) ||
+ IsEqualIID (riid, &IID_IDirectMusic2) ||
+ IsEqualIID (riid, &IID_IDirectMusic8))
+ {
+ IDirectMusic8_AddRef(iface);
+ *ret_iface = iface;
+ return S_OK;
+ }
+
+ *ret_iface = NULL;
+
+ WARN("(%p, %s, %p): not found\n", This, debugstr_dmguid(riid), ret_iface);
+
+ return E_NOINTERFACE;
}
-static ULONG WINAPI IDirectMusic8Impl_AddRef (LPDIRECTMUSIC8 iface) {
- IDirectMusic8Impl *This = (IDirectMusic8Impl *)iface;
- ULONG refCount = InterlockedIncrement(&This->ref);
+static ULONG WINAPI IDirectMusic8Impl_AddRef(LPDIRECTMUSIC8 iface)
+{
+ IDirectMusic8Impl *This = impl_from_IDirectMusic8(iface);
+ ULONG ref = InterlockedIncrement(&This->ref);
- TRACE("(%p)->(ref before=%u)\n", This, refCount - 1);
+ TRACE("(%p)->(): new ref = %u\n", This, ref);
- DMUSIC_LockModule();
+ DMUSIC_LockModule();
- return refCount;
+ return ref;
}
-static ULONG WINAPI IDirectMusic8Impl_Release (LPDIRECTMUSIC8 iface) {
- IDirectMusic8Impl *This = (IDirectMusic8Impl *)iface;
- ULONG refCount = InterlockedDecrement(&This->ref);
+static ULONG WINAPI IDirectMusic8Impl_Release(LPDIRECTMUSIC8 iface)
+{
+ IDirectMusic8Impl *This = impl_from_IDirectMusic8(iface);
+ ULONG ref = InterlockedDecrement(&This->ref);
- TRACE("(%p)->(ref before=%u)\n", This, refCount + 1);
+ TRACE("(%p)->(): new ref = %u\n", This, ref);
- if (!refCount) {
- HeapFree(GetProcessHeap(), 0, This);
- }
+ if (!ref) {
+ HeapFree(GetProcessHeap(), 0, This->system_ports);
+ HeapFree(GetProcessHeap(), 0, This->ppPorts);
+ HeapFree(GetProcessHeap(), 0, This);
+ }
- DMUSIC_UnlockModule();
-
- return refCount;
+ DMUSIC_UnlockModule();
+
+ return ref;
}
/* IDirectMusic8Impl IDirectMusic part: */
-static HRESULT WINAPI IDirectMusic8Impl_EnumPort(LPDIRECTMUSIC8 iface, DWORD dwIndex, LPDMUS_PORTCAPS pPortCaps) {
- IDirectMusic8Impl *This = (IDirectMusic8Impl *)iface;
- TRACE("(%p, %d, %p)\n", This, dwIndex, pPortCaps);
- if (NULL == pPortCaps) { return E_POINTER; }
- /* i guess the first port shown is always software synthesizer */
- if (dwIndex == 0)
- {
- IDirectMusicSynth8* synth;
- TRACE("enumerating 'Microsoft Software Synthesizer' port\n");
- CoCreateInstance (&CLSID_DirectMusicSynth, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectMusicSynth8, (void**)&synth);
- IDirectMusicSynth8_GetPortCaps (synth, pPortCaps);
- IDirectMusicSynth8_Release (synth);
- return S_OK;
- }
-
-/* it seems that the rest of devices are obtained thru dmusic32.EnumLegacyDevices...*sigh*...which is undocumented*/
-#if 0
- int numMIDI = midiOutGetNumDevs();
- int numWAVE = waveOutGetNumDevs();
- int i;
- /* then return digital sound ports */
- for (i = 1; i <= numWAVE; i++)
- {
- TRACE("enumerating 'digital sound' ports\n");
- if (i == dwIndex)
- {
- DirectSoundEnumerateA(register_waveport, pPortCaps);
- return S_OK;
- }
- }
- /* finally, list all *real* MIDI ports*/
- for (i = numWAVE + 1; i <= numWAVE + numMIDI; i++)
- {
- TRACE("enumerating 'real MIDI' ports\n");
- if (i == dwIndex)
- FIXME("Found MIDI port, but *real* MIDI ports not supported yet\n");
- }
-#endif
- return S_FALSE;
+static HRESULT WINAPI IDirectMusic8Impl_EnumPort(LPDIRECTMUSIC8 iface, DWORD index, LPDMUS_PORTCAPS port_caps)
+{
+ IDirectMusic8Impl *This = impl_from_IDirectMusic8(iface);
+
+ TRACE("(%p, %d, %p)\n", This, index, port_caps);
+
+ if (!port_caps)
+ return E_POINTER;
+
+ if (index >= This->nb_system_ports)
+ return S_FALSE;
+
+ *port_caps = This->system_ports[index].caps;
+
+ return S_OK;
}
-static HRESULT WINAPI IDirectMusic8Impl_CreateMusicBuffer (LPDIRECTMUSIC8 iface, LPDMUS_BUFFERDESC pBufferDesc, LPDIRECTMUSICBUFFER** ppBuffer, LPUNKNOWN pUnkOuter) {
- IDirectMusic8Impl *This = (IDirectMusic8Impl *)iface;
+static HRESULT WINAPI IDirectMusic8Impl_CreateMusicBuffer(LPDIRECTMUSIC8 iface, LPDMUS_BUFFERDESC buffer_desc, LPDIRECTMUSICBUFFER* buffer, LPUNKNOWN unkouter)
+{
+ IDirectMusic8Impl *This = impl_from_IDirectMusic8(iface);
- TRACE("(%p, %p, %p, %p)\n", This, pBufferDesc, ppBuffer, pUnkOuter);
+ TRACE("(%p)->(%p, %p, %p)\n", This, buffer_desc, buffer, unkouter);
- if (pUnkOuter)
- return CLASS_E_NOAGGREGATION;
+ if (unkouter)
+ return CLASS_E_NOAGGREGATION;
- if (!pBufferDesc || !ppBuffer)
- return E_POINTER;
+ if (!buffer_desc || !buffer)
+ return E_POINTER;
- return DMUSIC_CreateDirectMusicBufferImpl(&IID_IDirectMusicBuffer, (LPVOID)ppBuffer, NULL);
+ return DMUSIC_CreateDirectMusicBufferImpl(buffer_desc, (LPVOID)buffer);
}
-static HRESULT WINAPI IDirectMusic8Impl_CreatePort (LPDIRECTMUSIC8 iface, REFCLSID rclsidPort, LPDMUS_PORTPARAMS pPortParams, LPDIRECTMUSICPORT* ppPort, LPUNKNOWN pUnkOuter) {
- IDirectMusic8Impl *This = (IDirectMusic8Impl *)iface;
- int i/*, j*/;
- DMUS_PORTCAPS PortCaps;
- IDirectMusicPort* pNewPort = NULL;
- HRESULT hr = E_FAIL;
-
- TRACE("(%p, %s, %p, %p, %p)\n", This, debugstr_dmguid(rclsidPort), pPortParams, ppPort, pUnkOuter);
- ZeroMemory(&PortCaps, sizeof(DMUS_PORTCAPS));
- PortCaps.dwSize = sizeof(DMUS_PORTCAPS);
-
- for (i = 0; S_FALSE != IDirectMusic8Impl_EnumPort(iface, i, &PortCaps); i++) {
- if (IsEqualCLSID (rclsidPort, &PortCaps.guidPort)) {
- hr = DMUSIC_CreateDirectMusicPortImpl(&IID_IDirectMusicPort, (LPVOID*) &pNewPort, (LPUNKNOWN) This, pPortParams, &PortCaps);
- if (FAILED(hr)) {
- *ppPort = NULL;
- return hr;
- }
- This->nrofports++;
- if (!This->ppPorts) This->ppPorts = HeapAlloc(GetProcessHeap(), 0, sizeof(LPDIRECTMUSICPORT) * This->nrofports);
- else This->ppPorts = HeapReAlloc(GetProcessHeap(), 0, This->ppPorts, sizeof(LPDIRECTMUSICPORT) * This->nrofports);
- This->ppPorts[This->nrofports - 1] = pNewPort;
- *ppPort = pNewPort;
- return S_OK;
- }
- }
- /* FIXME: place correct error here */
- return E_NOINTERFACE;
+static HRESULT WINAPI IDirectMusic8Impl_CreatePort(LPDIRECTMUSIC8 iface, REFCLSID rclsid_port, LPDMUS_PORTPARAMS port_params, LPDIRECTMUSICPORT* port, LPUNKNOWN unkouter)
+{
+ IDirectMusic8Impl *This = impl_from_IDirectMusic8(iface);
+ int i;
+ DMUS_PORTCAPS port_caps;
+ IDirectMusicPort* new_port = NULL;
+ HRESULT hr;
+ GUID default_port;
+ const GUID *request_port = rclsid_port;
+
+ TRACE("(%p)->(%s, %p, %p, %p)\n", This, debugstr_dmguid(rclsid_port), port_params, port, unkouter);
+
+ if (!rclsid_port)
+ return E_POINTER;
+ if (!port_params)
+ return E_INVALIDARG;
+ if (!port)
+ return E_POINTER;
+ if (unkouter)
+ return CLASS_E_NOAGGREGATION;
+
+ if (TRACE_ON(dmusic))
+ dump_DMUS_PORTPARAMS(port_params);
+
+ ZeroMemory(&port_caps, sizeof(DMUS_PORTCAPS));
+ port_caps.dwSize = sizeof(DMUS_PORTCAPS);
+
+ if (IsEqualGUID(request_port, &GUID_NULL)) {
+ hr = IDirectMusic8_GetDefaultPort(iface, &default_port);
+ if(FAILED(hr))
+ return hr;
+ request_port = &default_port;
+ }
+
+ for (i = 0; S_FALSE != IDirectMusic8Impl_EnumPort(iface, i, &port_caps); i++) {
+ if (IsEqualCLSID(request_port, &port_caps.guidPort)) {
+ hr = This->system_ports[i].create(&IID_IDirectMusicPort, (LPVOID*)&new_port, (LPUNKNOWN)This, port_params, &port_caps, This->system_ports[i].device);
+ if (FAILED(hr)) {
+ *port = NULL;
+ return hr;
+ }
+ This->nrofports++;
+ if (!This->ppPorts)
+ This->ppPorts = HeapAlloc(GetProcessHeap(), 0, sizeof(LPDIRECTMUSICPORT) * This->nrofports);
+ else
+ This->ppPorts = HeapReAlloc(GetProcessHeap(), 0, This->ppPorts, sizeof(LPDIRECTMUSICPORT) * This->nrofports);
+ This->ppPorts[This->nrofports - 1] = new_port;
+ *port = new_port;
+ return S_OK;
+ }
+ }
+
+ return E_NOINTERFACE;
}
-static HRESULT WINAPI IDirectMusic8Impl_EnumMasterClock (LPDIRECTMUSIC8 iface, DWORD dwIndex, LPDMUS_CLOCKINFO lpClockInfo) {
- IDirectMusic8Impl *This = (IDirectMusic8Impl *)iface;
- FIXME("(%p, %d, %p): stub\n", This, dwIndex, lpClockInfo);
- return S_FALSE;
+static HRESULT WINAPI IDirectMusic8Impl_EnumMasterClock(LPDIRECTMUSIC8 iface, DWORD index, LPDMUS_CLOCKINFO clock_info)
+{
+ TRACE("(%p)->(%d, %p)\n", iface, index, clock_info);
+
+ if (!clock_info)
+ return E_POINTER;
+
+ if (index > 1)
+ return S_FALSE;
+
+ if (!index)
+ {
+ static const GUID guid_system_clock = { 0x58d58419, 0x71b4, 0x11d1, { 0xa7, 0x4c, 0x00, 0x00, 0xf8, 0x75, 0xac, 0x12 } };
+ static const WCHAR name_system_clock[] = { 'S','y','s','t','e','m',' ','C','l','o','c','k',0 };
+
+ clock_info->ctType = 0;
+ clock_info->guidClock = guid_system_clock;
+ strcpyW(clock_info->wszDescription, name_system_clock);
+ }
+ else
+ {
+ static const GUID guid_dsound_clock = { 0x58d58420, 0x71b4, 0x11d1, { 0xa7, 0x4c, 0x00, 0x00, 0xf8, 0x75, 0xac, 0x12 } };
+ static const WCHAR name_dsound_clock[] = { 'D','i','r','e','c','t','S','o','u','n','d',' ','C','l','o','c','k',0 };
+
+ clock_info->ctType = 0;
+ clock_info->guidClock = guid_dsound_clock;
+ strcpyW(clock_info->wszDescription, name_dsound_clock);
+ }
+
+ return S_OK;
}
-static HRESULT WINAPI IDirectMusic8Impl_GetMasterClock (LPDIRECTMUSIC8 iface, LPGUID pguidClock, IReferenceClock** ppReferenceClock) {
- IDirectMusic8Impl *This = (IDirectMusic8Impl *)iface;
+static HRESULT WINAPI IDirectMusic8Impl_GetMasterClock(LPDIRECTMUSIC8 iface, LPGUID guid_clock, IReferenceClock** reference_clock)
+{
+ IDirectMusic8Impl *This = impl_from_IDirectMusic8(iface);
- TRACE("(%p, %p, %p)\n", This, pguidClock, ppReferenceClock);
- if (pguidClock)
- *pguidClock = This->pMasterClock->pClockInfo.guidClock;
- if(ppReferenceClock)
- *ppReferenceClock = (IReferenceClock *)This->pMasterClock;
+ TRACE("(%p)->(%p, %p)\n", This, guid_clock, reference_clock);
- return S_OK;
+ if (guid_clock)
+ *guid_clock = This->pMasterClock->pClockInfo.guidClock;
+ if (reference_clock)
+ *reference_clock = (IReferenceClock*)This->pMasterClock;
+
+ return S_OK;
}
-static HRESULT WINAPI IDirectMusic8Impl_SetMasterClock (LPDIRECTMUSIC8 iface, REFGUID rguidClock) {
- IDirectMusic8Impl *This = (IDirectMusic8Impl *)iface;
- FIXME("(%p, %s): stub\n", This, debugstr_dmguid(rguidClock));
- return S_OK;
+static HRESULT WINAPI IDirectMusic8Impl_SetMasterClock(LPDIRECTMUSIC8 iface, REFGUID rguidClock)
+{
+ IDirectMusic8Impl *This = impl_from_IDirectMusic8(iface);
+
+ FIXME("(%p)->(%s): stub\n", This, debugstr_dmguid(rguidClock));
+
+ return S_OK;
}
-static HRESULT WINAPI IDirectMusic8Impl_Activate (LPDIRECTMUSIC8 iface, BOOL fEnable) {
- IDirectMusic8Impl *This = (IDirectMusic8Impl *)iface;
- int i;
-
- FIXME("(%p, %d): stub\n", This, fEnable);
- for (i = 0; i < This->nrofports; i++) {
- IDirectMusicPortImpl_Activate(This->ppPorts[i], fEnable);
- }
-
- return S_OK;
+static HRESULT WINAPI IDirectMusic8Impl_Activate(LPDIRECTMUSIC8 iface, BOOL enable)
+{
+ IDirectMusic8Impl *This = impl_from_IDirectMusic8(iface);
+ int i;
+ HRESULT hr;
+
+ TRACE("(%p)->(%u)\n", This, enable);
+
+ for (i = 0; i < This->nrofports; i++)
+ {
+ hr = IDirectMusicPort_Activate(This->ppPorts[i], enable);
+ if (FAILED(hr))
+ return hr;
+ }
+
+ return S_OK;
}
-static HRESULT WINAPI IDirectMusic8Impl_GetDefaultPort (LPDIRECTMUSIC8 iface, LPGUID pguidPort) {
- IDirectMusic8Impl *This = (IDirectMusic8Impl *)iface;
- HKEY hkGUID;
- DWORD returnTypeGUID, sizeOfReturnBuffer = 50;
- char returnBuffer[51];
- GUID defaultPortGUID;
- WCHAR buff[51];
-
- TRACE("(%p, %p)\n", This, pguidPort);
- if ((RegOpenKeyExA(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\DirectMusic\\Defaults" , 0, KEY_READ, &hkGUID) != ERROR_SUCCESS) ||
- (RegQueryValueExA(hkGUID, "DefaultOutputPort", NULL, &returnTypeGUID, (LPBYTE)returnBuffer, &sizeOfReturnBuffer) != ERROR_SUCCESS))
- {
- WARN(": registry entry missing\n" );
- *pguidPort = CLSID_DirectMusicSynth;
- return S_OK;
- }
- /* FIXME: Check return types to ensure we're interpreting data right */
- MultiByteToWideChar(CP_ACP, 0, returnBuffer, -1, buff, sizeof(buff) / sizeof(WCHAR));
- CLSIDFromString(buff, &defaultPortGUID);
- *pguidPort = defaultPortGUID;
-
- return S_OK;
+static HRESULT WINAPI IDirectMusic8Impl_GetDefaultPort(LPDIRECTMUSIC8 iface, LPGUID guid_port)
+{
+ IDirectMusic8Impl *This = impl_from_IDirectMusic8(iface);
+ HKEY hkGUID;
+ DWORD returnTypeGUID, sizeOfReturnBuffer = 50;
+ char returnBuffer[51];
+ GUID defaultPortGUID;
+ WCHAR buff[51];
+
+ TRACE("(%p)->(%p)\n", This, guid_port);
+
+ if ((RegOpenKeyExA(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\DirectMusic\\Defaults" , 0, KEY_READ, &hkGUID) != ERROR_SUCCESS) ||
+ (RegQueryValueExA(hkGUID, "DefaultOutputPort", NULL, &returnTypeGUID, (LPBYTE)returnBuffer, &sizeOfReturnBuffer) != ERROR_SUCCESS))
+ {
+ WARN(": registry entry missing\n" );
+ *guid_port = CLSID_DirectMusicSynth;
+ return S_OK;
+ }
+ /* FIXME: Check return types to ensure we're interpreting data right */
+ MultiByteToWideChar(CP_ACP, 0, returnBuffer, -1, buff, sizeof(buff) / sizeof(WCHAR));
+ CLSIDFromString(buff, &defaultPortGUID);
+ *guid_port = defaultPortGUID;
+
+ return S_OK;
}
-static HRESULT WINAPI IDirectMusic8Impl_SetDirectSound (LPDIRECTMUSIC8 iface, LPDIRECTSOUND pDirectSound, HWND hWnd) {
- IDirectMusic8Impl *This = (IDirectMusic8Impl *)iface;
- FIXME("(%p, %p, %p): stub\n", This, pDirectSound, hWnd);
- return S_OK;
+static HRESULT WINAPI IDirectMusic8Impl_SetDirectSound(LPDIRECTMUSIC8 iface, LPDIRECTSOUND dsound, HWND wnd)
+{
+ IDirectMusic8Impl *This = impl_from_IDirectMusic8(iface);
+
+ FIXME("(%p)->(%p, %p): stub\n", This, dsound, wnd);
+
+ return S_OK;
}
-static HRESULT WINAPI IDirectMusic8Impl_SetExternalMasterClock (LPDIRECTMUSIC8 iface, IReferenceClock* pClock) {
- IDirectMusic8Impl *This = (IDirectMusic8Impl *)iface;
- FIXME("(%p, %p): stub\n", This, pClock);
- return S_OK;
+static HRESULT WINAPI IDirectMusic8Impl_SetExternalMasterClock(LPDIRECTMUSIC8 iface, IReferenceClock* clock)
+{
+ IDirectMusic8Impl *This = impl_from_IDirectMusic8(iface);
+
+ FIXME("(%p)->(%p): stub\n", This, clock);
+
+ return S_OK;
}
static const IDirectMusic8Vtbl DirectMusic8_Vtbl = {
- IDirectMusic8Impl_QueryInterface,
- IDirectMusic8Impl_AddRef,
- IDirectMusic8Impl_Release,
- IDirectMusic8Impl_EnumPort,
- IDirectMusic8Impl_CreateMusicBuffer,
- IDirectMusic8Impl_CreatePort,
- IDirectMusic8Impl_EnumMasterClock,
- IDirectMusic8Impl_GetMasterClock,
- IDirectMusic8Impl_SetMasterClock,
- IDirectMusic8Impl_Activate,
- IDirectMusic8Impl_GetDefaultPort,
- IDirectMusic8Impl_SetDirectSound,
- IDirectMusic8Impl_SetExternalMasterClock
+ IDirectMusic8Impl_QueryInterface,
+ IDirectMusic8Impl_AddRef,
+ IDirectMusic8Impl_Release,
+ IDirectMusic8Impl_EnumPort,
+ IDirectMusic8Impl_CreateMusicBuffer,
+ IDirectMusic8Impl_CreatePort,
+ IDirectMusic8Impl_EnumMasterClock,
+ IDirectMusic8Impl_GetMasterClock,
+ IDirectMusic8Impl_SetMasterClock,
+ IDirectMusic8Impl_Activate,
+ IDirectMusic8Impl_GetDefaultPort,
+ IDirectMusic8Impl_SetDirectSound,
+ IDirectMusic8Impl_SetExternalMasterClock
};
-/* for ClassFactory */
-HRESULT WINAPI DMUSIC_CreateDirectMusicImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter) {
- IDirectMusic8Impl *dmusic;
-
- TRACE("(%p,%p,%p)\n",lpcGUID, ppobj, pUnkOuter);
-
- dmusic = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusic8Impl));
- if (NULL == dmusic) {
- *ppobj = NULL;
- return E_OUTOFMEMORY;
- }
- dmusic->lpVtbl = &DirectMusic8_Vtbl;
- dmusic->ref = 0; /* will be inited with QueryInterface */
- dmusic->pMasterClock = NULL;
- dmusic->ppPorts = NULL;
- dmusic->nrofports = 0;
- DMUSIC_CreateReferenceClockImpl (&IID_IReferenceClock, (LPVOID*)&dmusic->pMasterClock, NULL);
-
- return IDirectMusic8Impl_QueryInterface ((LPDIRECTMUSIC8)dmusic, lpcGUID, ppobj);
+static void create_system_ports_list(IDirectMusic8Impl* object)
+{
+ port_info * port;
+ const WCHAR emulated[] = {' ','[','E','m','u','l','a','t','e','d',']',0};
+ ULONG nb_ports;
+ ULONG nb_midi_out;
+ ULONG nb_midi_in;
+ MIDIOUTCAPSW caps_out;
+ MIDIINCAPSW caps_in;
+ IDirectMusicSynth8* synth;
+ HRESULT hr;
+ ULONG i;
+
+ TRACE("(%p)\n", object);
+
+ /* NOTE:
+ - it seems some native versions get the rest of devices through dmusic32.EnumLegacyDevices...*sigh*...which is undocumented
+ - should we enum wave devices ? Native does not seem to
+ */
+
+ nb_midi_out = midiOutGetNumDevs();
+ nb_midi_in = midiInGetNumDevs();
+ nb_ports = 1 /* midi mapper */ + nb_midi_out + nb_midi_in + 1 /* synth port */;
+
+ port = object->system_ports = HeapAlloc(GetProcessHeap(), 0, nb_ports * sizeof(port_info));
+ if (!object->system_ports)
+ return;
+
+ /* Fill common port caps for all winmm ports */
+ for (i = 0; i < (nb_ports - 1 /* synth port*/); i++)
+ {
+ object->system_ports[i].caps.dwSize = sizeof(DMUS_PORTCAPS);
+ object->system_ports[i].caps.dwType = DMUS_PORT_WINMM_DRIVER;
+ object->system_ports[i].caps.dwMemorySize = 0;
+ object->system_ports[i].caps.dwMaxChannelGroups = 1;
+ object->system_ports[i].caps.dwMaxVoices = 0;
+ object->system_ports[i].caps.dwMaxAudioChannels = 0;
+ object->system_ports[i].caps.dwEffectFlags = DMUS_EFFECT_NONE;
+ /* Fake port GUID */
+ object->system_ports[i].caps.guidPort = IID_IUnknown;
+ object->system_ports[i].caps.guidPort.Data1 = i + 1;
+ }
+
+ /* Fill midi mapper port info */
+ port->device = MIDI_MAPPER;
+ port->create = DMUSIC_CreateMidiOutPortImpl;
+ midiOutGetDevCapsW(MIDI_MAPPER, &caps_out, sizeof(caps_out));
+ strcpyW(port->caps.wszDescription, caps_out.szPname);
+ strcatW(port->caps.wszDescription, emulated);
+ port->caps.dwFlags = DMUS_PC_SHAREABLE;
+ port->caps.dwClass = DMUS_PC_OUTPUTCLASS;
+ port++;
+
+ /* Fill midi out port info */
+ for (i = 0; i < nb_midi_out; i++)
+ {
+ port->device = i;
+ port->create = DMUSIC_CreateMidiOutPortImpl;
+ midiOutGetDevCapsW(i, &caps_out, sizeof(caps_out));
+ strcpyW(port->caps.wszDescription, caps_out.szPname);
+ strcatW(port->caps.wszDescription, emulated);
+ port->caps.dwFlags = DMUS_PC_SHAREABLE | DMUS_PC_EXTERNAL;
+ port->caps.dwClass = DMUS_PC_OUTPUTCLASS;
+ port++;
+ }
+
+ /* Fill midi in port info */
+ for (i = 0; i < nb_midi_in; i++)
+ {
+ port->device = i;
+ port->create = DMUSIC_CreateMidiInPortImpl;
+ midiInGetDevCapsW(i, &caps_in, sizeof(caps_in));
+ strcpyW(port->caps.wszDescription, caps_in.szPname);
+ strcatW(port->caps.wszDescription, emulated);
+ port->caps.dwFlags = DMUS_PC_EXTERNAL;
+ port->caps.dwClass = DMUS_PC_INPUTCLASS;
+ port++;
+ }
+
+ /* Fill synth port info */
+ port->create = DMUSIC_CreateSynthPortImpl;
+ hr = CoCreateInstance(&CLSID_DirectMusicSynth, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectMusicSynth8, (void**)&synth);
+ if (SUCCEEDED(hr))
+ {
+ port->caps.dwSize = sizeof(port->caps);
+ hr = IDirectMusicSynth8_GetPortCaps(synth, &port->caps);
+ IDirectMusicSynth8_Release(synth);
+ }
+ if (FAILED(hr))
+ nb_ports--;
+
+ object->nb_system_ports = nb_ports;
+}
+
+/* For ClassFactory */
+HRESULT WINAPI DMUSIC_CreateDirectMusicImpl(LPCGUID riid, LPVOID* ret_iface, LPUNKNOWN unkouter)
+{
+ IDirectMusic8Impl *dmusic;
+ HRESULT ret;
+
+ TRACE("(%p,%p,%p)\n", riid, ret_iface, unkouter);
+
+ *ret_iface = NULL;
+
+ dmusic = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusic8Impl));
+ if (!dmusic)
+ return E_OUTOFMEMORY;
+
+ dmusic->IDirectMusic8_iface.lpVtbl = &DirectMusic8_Vtbl;
+ dmusic->ref = 0; /* Will be inited by QueryInterface */
+ dmusic->pMasterClock = NULL;
+ dmusic->ppPorts = NULL;
+ dmusic->nrofports = 0;
+ ret = DMUSIC_CreateReferenceClockImpl(&IID_IReferenceClock, (LPVOID*)&dmusic->pMasterClock, NULL);
+ if (FAILED(ret)) {
+ HeapFree(GetProcessHeap(), 0, dmusic);
+ return ret;
+ }
+
+ ret = IDirectMusic8Impl_QueryInterface(&dmusic->IDirectMusic8_iface, riid, ret_iface);
+ if (FAILED(ret)) {
+ IReferenceClock_Release(&dmusic->pMasterClock->IReferenceClock_iface);
+ HeapFree(GetProcessHeap(), 0, dmusic);
+ return ret;
+ }
+
+ create_system_ports_list(dmusic);
+
+ return S_OK;
}
--- /dev/null
+/*
+ * COM Classes for dmusic
+ *
+ * Copyright 2010 Alexandre Julliard
+ *
+ * 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
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+[
+ threading(both),
+ progid("Microsoft.DirectMusic.1"),
+ vi_progid("Microsoft.DirectMusic"),
+ uuid(636b9f10-0c7d-11d1-95b2-0020afdc7421)
+]
+coclass DirectMusic { interface IDirectMusic; }
+
+[
+ threading(both),
+ progid("Microsoft.DirectMusicCollection.1"),
+ vi_progid("Microsoft.DirectMusicCollection"),
+ uuid(480ff4b0-28b2-11d1-bef7-00c04fbf8fef)
+]
+coclass DirectMusicCollection { interface IDirectMusicCollection; }
--- /dev/null
+HKCR
+{
+ NoRemove Interface
+ {
+ }
+ NoRemove CLSID
+ {
+ '{636B9F10-0C7D-11D1-95B2-0020AFDC7421}' = s 'DirectMusic'
+ {
+ InprocServer32 = s '%MODULE%' { val ThreadingModel = s 'Both' }
+ ProgId = s 'Microsoft.DirectMusic.1'
+ VersionIndependentProgId = s 'Microsoft.DirectMusic'
+ }
+ '{480FF4B0-28B2-11D1-BEF7-00C04FBF8FEF}' = s 'DirectMusicCollection'
+ {
+ InprocServer32 = s '%MODULE%' { val ThreadingModel = s 'Both' }
+ ProgId = s 'Microsoft.DirectMusicCollection.1'
+ VersionIndependentProgId = s 'Microsoft.DirectMusicCollection'
+ }
+ }
+ 'Microsoft.DirectMusic.1' = s 'DirectMusic'
+ {
+ CLSID = s '{636B9F10-0C7D-11D1-95B2-0020AFDC7421}'
+ }
+ 'Microsoft.DirectMusic' = s 'DirectMusic'
+ {
+ CLSID = s '{636B9F10-0C7D-11D1-95B2-0020AFDC7421}'
+ CurVer = s 'Microsoft.DirectMusic.1'
+ }
+ 'Microsoft.DirectMusicCollection.1' = s 'DirectMusicCollection'
+ {
+ CLSID = s '{480FF4B0-28B2-11D1-BEF7-00C04FBF8FEF}'
+ }
+ 'Microsoft.DirectMusicCollection' = s 'DirectMusicCollection'
+ {
+ CLSID = s '{480FF4B0-28B2-11D1-BEF7-00C04FBF8FEF}'
+ CurVer = s 'Microsoft.DirectMusicCollection.1'
+ }
+}
#include <stdio.h>
#include "dmusic_private.h"
+#include "rpcproxy.h"
WINE_DEFAULT_DEBUG_CHANNEL(dmusic);
+static HINSTANCE instance;
LONG DMUSIC_refCount = 0;
typedef struct {
- const IClassFactoryVtbl *lpVtbl;
+ IClassFactory IClassFactory_iface;
+ HRESULT (WINAPI *fnCreateInstance)(REFIID riid, void **ppv, IUnknown *pUnkOuter);
} IClassFactoryImpl;
/******************************************************************
- * DirectMusic ClassFactory
+ * IClassFactory implementation
*/
-static HRESULT WINAPI DirectMusicCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
- FIXME("- no interface\n\tIID:\t%s\n", debugstr_guid(riid));
-
- if (ppobj == NULL) return E_POINTER;
-
- return E_NOINTERFACE;
+static inline IClassFactoryImpl *impl_from_IClassFactory(IClassFactory *iface)
+{
+ return CONTAINING_RECORD(iface, IClassFactoryImpl, IClassFactory_iface);
}
-static ULONG WINAPI DirectMusicCF_AddRef(LPCLASSFACTORY iface) {
- DMUSIC_LockModule();
-
- return 2; /* non-heap based object */
+static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
+{
+ if (ppv == NULL)
+ return E_POINTER;
+
+ if (IsEqualGUID(&IID_IUnknown, riid))
+ TRACE("(%p)->(IID_IUnknown %p)\n", iface, ppv);
+ else if (IsEqualGUID(&IID_IClassFactory, riid))
+ TRACE("(%p)->(IID_IClassFactory %p)\n", iface, ppv);
+ else {
+ FIXME("(%p)->(%s %p)\n", iface, debugstr_guid(riid), ppv);
+ *ppv = NULL;
+ return E_NOINTERFACE;
+ }
+
+ *ppv = iface;
+ IUnknown_AddRef((IUnknown*)*ppv);
+ return S_OK;
}
-static ULONG WINAPI DirectMusicCF_Release(LPCLASSFACTORY iface) {
- DMUSIC_UnlockModule();
-
- return 1; /* non-heap based object */
-}
+static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
+{
+ DMUSIC_LockModule();
-static HRESULT WINAPI DirectMusicCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) {
- TRACE ("(%p, %s, %p)\n", pOuter, debugstr_dmguid(riid), ppobj);
- return DMUSIC_CreateDirectMusicImpl (riid, ppobj, pOuter);
+ return 2; /* non-heap based object */
}
-static HRESULT WINAPI DirectMusicCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
- TRACE("(%d)\n", dolock);
-
- if (dolock)
- DMUSIC_LockModule();
- else
- DMUSIC_UnlockModule();
-
- return S_OK;
-}
-
-static const IClassFactoryVtbl DirectMusicCF_Vtbl = {
- DirectMusicCF_QueryInterface,
- DirectMusicCF_AddRef,
- DirectMusicCF_Release,
- DirectMusicCF_CreateInstance,
- DirectMusicCF_LockServer
-};
-
-static IClassFactoryImpl DirectMusic_CF = {&DirectMusicCF_Vtbl};
-
-/******************************************************************
- * DirectMusicCollection ClassFactory
- */
-static HRESULT WINAPI CollectionCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
- FIXME("- no interface\n\tIID:\t%s\n", debugstr_guid(riid));
+static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
+{
+ DMUSIC_UnlockModule();
- if (ppobj == NULL) return E_POINTER;
-
- return E_NOINTERFACE;
+ return 1; /* non-heap based object */
}
-static ULONG WINAPI CollectionCF_AddRef(LPCLASSFACTORY iface) {
- DMUSIC_LockModule();
-
- return 2; /* non-heap based object */
-}
+static HRESULT WINAPI ClassFactory_CreateInstance(IClassFactory *iface, IUnknown *pUnkOuter,
+ REFIID riid, void **ppv)
+{
+ IClassFactoryImpl *This = impl_from_IClassFactory(iface);
-static ULONG WINAPI CollectionCF_Release(LPCLASSFACTORY iface) {
- DMUSIC_UnlockModule();
+ TRACE ("(%p, %s, %p)\n", pUnkOuter, debugstr_dmguid(riid), ppv);
- return 1; /* non-heap based object */
+ return This->fnCreateInstance(riid, ppv, pUnkOuter);
}
-static HRESULT WINAPI CollectionCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) {
- TRACE ("(%p, %s, %p)\n", pOuter, debugstr_dmguid(riid), ppobj);
- return DMUSIC_CreateDirectMusicCollectionImpl (riid, ppobj, pOuter);
-}
+static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL dolock)
+{
+ TRACE("(%d)\n", dolock);
-static HRESULT WINAPI CollectionCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
- TRACE("(%d)\n", dolock);
+ if (dolock)
+ DMUSIC_LockModule();
+ else
+ DMUSIC_UnlockModule();
- if (dolock)
- DMUSIC_LockModule();
- else
- DMUSIC_UnlockModule();
-
- return S_OK;
+ return S_OK;
}
-static const IClassFactoryVtbl CollectionCF_Vtbl = {
- CollectionCF_QueryInterface,
- CollectionCF_AddRef,
- CollectionCF_Release,
- CollectionCF_CreateInstance,
- CollectionCF_LockServer
+static const IClassFactoryVtbl classfactory_vtbl = {
+ ClassFactory_QueryInterface,
+ ClassFactory_AddRef,
+ ClassFactory_Release,
+ ClassFactory_CreateInstance,
+ ClassFactory_LockServer
};
-static IClassFactoryImpl Collection_CF = {&CollectionCF_Vtbl};
+static IClassFactoryImpl DirectMusic_CF = {{&classfactory_vtbl}, DMUSIC_CreateDirectMusicImpl};
+static IClassFactoryImpl Collection_CF = {{&classfactory_vtbl},
+ DMUSIC_CreateDirectMusicCollectionImpl};
/******************************************************************
* DllMain
*/
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {
if (fdwReason == DLL_PROCESS_ATTACH) {
+ instance = hinstDLL;
DisableThreadLibraryCalls(hinstDLL);
/* FIXME: Initialisation */
} else if (fdwReason == DLL_PROCESS_DETACH) {
return CLASS_E_CLASSNOTAVAILABLE;
}
+/***********************************************************************
+ * DllRegisterServer (DMUSIC.@)
+ */
+HRESULT WINAPI DllRegisterServer(void)
+{
+ return __wine_register_resources( instance );
+}
+
+/***********************************************************************
+ * DllUnregisterServer (DMUSIC.@)
+ */
+HRESULT WINAPI DllUnregisterServer(void)
+{
+ return __wine_unregister_resources( instance );
+}
/******************************************************************
* Helper functions
*
*/
/* dwPatch from MIDILOCALE */
-DWORD MIDILOCALE2Patch (LPMIDILOCALE pLocale) {
+DWORD MIDILOCALE2Patch (const MIDILOCALE *pLocale) {
DWORD dwPatch = 0;
if (!pLocale) return 0;
dwPatch |= (pLocale->ulBank & F_INSTRUMENT_DRUMS); /* set drum bit */
return debugstr_flags (flagmask, flags, sizeof(flags)/sizeof(flags[0]));
}
-/* dump whole DMUS_OBJECTDESC struct */
-const char *debugstr_DMUS_OBJECTDESC (LPDMUS_OBJECTDESC pDesc) {
- if (pDesc) {
- char buffer[1024] = "", *ptr = &buffer[0];
-
- ptr += sprintf(ptr, "DMUS_OBJECTDESC (%p):\n", pDesc);
- ptr += sprintf(ptr, " - dwSize = %d\n", pDesc->dwSize);
- ptr += sprintf(ptr, " - dwValidData = %s\n", debugstr_DMUS_OBJ_FLAGS (pDesc->dwValidData));
- if (pDesc->dwValidData & DMUS_OBJ_CLASS) ptr += sprintf(ptr, " - guidClass = %s\n", debugstr_dmguid(&pDesc->guidClass));
- if (pDesc->dwValidData & DMUS_OBJ_OBJECT) ptr += sprintf(ptr, " - guidObject = %s\n", debugstr_guid(&pDesc->guidObject));
- if (pDesc->dwValidData & DMUS_OBJ_DATE) ptr += sprintf(ptr, " - ftDate = FIXME\n");
- if (pDesc->dwValidData & DMUS_OBJ_VERSION) ptr += sprintf(ptr, " - vVersion = %s\n", debugstr_dmversion(&pDesc->vVersion));
- if (pDesc->dwValidData & DMUS_OBJ_NAME) ptr += sprintf(ptr, " - wszName = %s\n", debugstr_w(pDesc->wszName));
- if (pDesc->dwValidData & DMUS_OBJ_CATEGORY) ptr += sprintf(ptr, " - wszCategory = %s\n", debugstr_w(pDesc->wszCategory));
- if (pDesc->dwValidData & DMUS_OBJ_FILENAME) ptr += sprintf(ptr, " - wszFileName = %s\n", debugstr_w(pDesc->wszFileName));
- if (pDesc->dwValidData & DMUS_OBJ_MEMORY) ptr += sprintf(ptr, " - llMemLength = 0x%s\n - pbMemData = %p\n",
- wine_dbgstr_longlong(pDesc->llMemLength), pDesc->pbMemData);
- if (pDesc->dwValidData & DMUS_OBJ_STREAM) ptr += sprintf(ptr, " - pStream = %p", pDesc->pStream);
-
- return wine_dbg_sprintf("%s", buffer);
- } else {
- return wine_dbg_sprintf("(NULL)");
- }
+/* Dump whole DMUS_OBJECTDESC struct */
+void dump_DMUS_OBJECTDESC(LPDMUS_OBJECTDESC desc)
+{
+ TRACE("DMUS_OBJECTDESC (%p):\n", desc);
+ TRACE(" - dwSize = %d\n", desc->dwSize);
+ TRACE(" - dwValidData = %s\n", debugstr_DMUS_OBJ_FLAGS (desc->dwValidData));
+ if (desc->dwValidData & DMUS_OBJ_CLASS) TRACE(" - guidClass = %s\n", debugstr_dmguid(&desc->guidClass));
+ if (desc->dwValidData & DMUS_OBJ_OBJECT) TRACE(" - guidObject = %s\n", debugstr_guid(&desc->guidObject));
+ if (desc->dwValidData & DMUS_OBJ_DATE) TRACE(" - ftDate = FIXME\n");
+ if (desc->dwValidData & DMUS_OBJ_VERSION) TRACE(" - vVersion = %s\n", debugstr_dmversion(&desc->vVersion));
+ if (desc->dwValidData & DMUS_OBJ_NAME) TRACE(" - wszName = %s\n", debugstr_w(desc->wszName));
+ if (desc->dwValidData & DMUS_OBJ_CATEGORY) TRACE(" - wszCategory = %s\n", debugstr_w(desc->wszCategory));
+ if (desc->dwValidData & DMUS_OBJ_FILENAME) TRACE(" - wszFileName = %s\n", debugstr_w(desc->wszFileName));
+ if (desc->dwValidData & DMUS_OBJ_MEMORY) TRACE(" - llMemLength = 0x%s\n - pbMemData = %p\n",
+ wine_dbgstr_longlong(desc->llMemLength), desc->pbMemData);
+ if (desc->dwValidData & DMUS_OBJ_STREAM) TRACE(" - pStream = %p\n", desc->pStream);
+}
+
+/* Dump DMUS_PORTPARAMS flags */
+static const char* debugstr_DMUS_PORTPARAMS_FLAGS(DWORD flagmask)
+{
+ static const flag_info flags[] = {
+ FE(DMUS_PORTPARAMS_VOICES),
+ FE(DMUS_PORTPARAMS_CHANNELGROUPS),
+ FE(DMUS_PORTPARAMS_AUDIOCHANNELS),
+ FE(DMUS_PORTPARAMS_SAMPLERATE),
+ FE(DMUS_PORTPARAMS_EFFECTS),
+ FE(DMUS_PORTPARAMS_SHARE)
+ };
+ return debugstr_flags(flagmask, flags, sizeof(flags)/sizeof(flags[0]));
+}
+
+/* Dump whole DMUS_PORTPARAMS struct */
+void dump_DMUS_PORTPARAMS(LPDMUS_PORTPARAMS params)
+{
+ TRACE("DMUS_PORTPARAMS (%p):\n", params);
+ TRACE(" - dwSize = %d\n", params->dwSize);
+ TRACE(" - dwValidParams = %s\n", debugstr_DMUS_PORTPARAMS_FLAGS(params->dwValidParams));
+ if (params->dwValidParams & DMUS_PORTPARAMS_VOICES) TRACE(" - dwVoices = %u\n", params->dwVoices);
+ if (params->dwValidParams & DMUS_PORTPARAMS_CHANNELGROUPS) TRACE(" - dwChannelGroup = %u\n", params->dwChannelGroups);
+ if (params->dwValidParams & DMUS_PORTPARAMS_AUDIOCHANNELS) TRACE(" - dwAudioChannels = %u\n", params->dwAudioChannels);
+ if (params->dwValidParams & DMUS_PORTPARAMS_SAMPLERATE) TRACE(" - dwSampleRate = %u\n", params->dwSampleRate);
+ if (params->dwValidParams & DMUS_PORTPARAMS_EFFECTS) TRACE(" - dwEffectFlags = %x\n", params->dwEffectFlags);
+ if (params->dwValidParams & DMUS_PORTPARAMS_SHARE) TRACE(" - fShare = %u\n", params->fShare);
}
-/* DirectMusic Private Include
+/*
+ * DirectMusic Private Include
*
* Copyright (C) 2003-2004 Rok Mandeljc
+ * Copyright (C) 2012 Christian Costa
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
typedef struct IDirectMusicBufferImpl IDirectMusicBufferImpl;
typedef struct IDirectMusicDownloadedInstrumentImpl IDirectMusicDownloadedInstrumentImpl;
typedef struct IDirectMusicDownloadImpl IDirectMusicDownloadImpl;
-typedef struct IDirectMusicPortDownloadImpl IDirectMusicPortDownloadImpl;
-typedef struct IDirectMusicPortImpl IDirectMusicPortImpl;
-typedef struct IDirectMusicThruImpl IDirectMusicThruImpl;
typedef struct IReferenceClockImpl IReferenceClockImpl;
typedef struct IDirectMusicCollectionImpl IDirectMusicCollectionImpl;
typedef struct IDirectMusicInstrumentImpl IDirectMusicInstrumentImpl;
+typedef struct SynthPortImpl SynthPortImpl;
/*****************************************************************************
* Some stuff to make my life easier :=)
DMUSIC_PRIVATE_MCHANNEL channel[16]; /* 16 channels in a group */
} DMUSIC_PRIVATE_CHANNEL_GROUP, *LPDMUSIC_PRIVATE_CHANNEL_GROUP;
+typedef struct port_info {
+ DMUS_PORTCAPS caps;
+ HRESULT (*create)(LPCGUID guid, LPVOID *object, LPUNKNOWN unkouter, LPDMUS_PORTPARAMS port_params, LPDMUS_PORTCAPS port_caps, DWORD device);
+ ULONG device;
+} port_info;
+
+typedef struct instrument_region {
+ RGNHEADER header;
+ WAVELINK wave_link;
+ WSMPL wave_sample;
+ WLOOP wave_loop;
+ BOOL loop_present;
+} instrument_region;
+
+typedef struct instrument_articulation {
+ CONNECTIONLIST connections_list;
+ CONNECTION *connections;
+} instrument_articulation;
/*****************************************************************************
* ClassFactory
*/
-extern HRESULT WINAPI DMUSIC_CreateDirectMusicImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter);
-extern HRESULT WINAPI DMUSIC_CreateDirectMusicBufferImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter);
-extern HRESULT WINAPI DMUSIC_CreateDirectMusicDownloadedInstrumentImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter);
-extern HRESULT WINAPI DMUSIC_CreateDirectMusicDownloadImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter);
-extern HRESULT WINAPI DMUSIC_CreateReferenceClockImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter);
-extern HRESULT WINAPI DMUSIC_CreateDirectMusicCollectionImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter);
-extern HRESULT WINAPI DMUSIC_CreateDirectMusicInstrumentImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter);
+/* CLSID */
+extern HRESULT WINAPI DMUSIC_CreateDirectMusicImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter) DECLSPEC_HIDDEN;
+extern HRESULT WINAPI DMUSIC_CreateDirectMusicCollectionImpl(LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter) DECLSPEC_HIDDEN;
+
+/* Internal */
+extern HRESULT DMUSIC_CreateDirectMusicBufferImpl(LPDMUS_BUFFERDESC desc, LPVOID* ret_iface) DECLSPEC_HIDDEN;
+extern HRESULT DMUSIC_CreateDirectMusicDownloadImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter) DECLSPEC_HIDDEN;
+extern HRESULT DMUSIC_CreateReferenceClockImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter) DECLSPEC_HIDDEN;
+extern HRESULT DMUSIC_CreateDirectMusicInstrumentImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter) DECLSPEC_HIDDEN;
/*****************************************************************************
* IDirectMusic8Impl implementation structure
*/
struct IDirectMusic8Impl {
- /* IUnknown fields */
- const IDirectMusic8Vtbl *lpVtbl;
- LONG ref;
-
- /* IDirectMusicImpl fields */
- IReferenceClockImpl* pMasterClock;
- IDirectMusicPort** ppPorts;
- int nrofports;
+ /* IUnknown fields */
+ IDirectMusic8 IDirectMusic8_iface;
+ LONG ref;
+
+ /* IDirectMusicImpl fields */
+ IReferenceClockImpl* pMasterClock;
+ IDirectMusicPort** ppPorts;
+ int nrofports;
+ port_info* system_ports;
+ int nb_system_ports;
};
/*****************************************************************************
* IDirectMusicBufferImpl implementation structure
*/
struct IDirectMusicBufferImpl {
- /* IUnknown fields */
- const IDirectMusicBufferVtbl *lpVtbl;
- LONG ref;
-
- /* IDirectMusicBufferImpl fields */
+ /* IUnknown fields */
+ IDirectMusicBuffer IDirectMusicBuffer_iface;
+ LONG ref;
+
+ /* IDirectMusicBufferImpl fields */
+ GUID format;
+ DWORD size;
+ LPBYTE data;
+ DWORD write_pos;
+ REFERENCE_TIME start_time;
};
/*****************************************************************************
* IDirectMusicDownloadedInstrumentImpl implementation structure
*/
struct IDirectMusicDownloadedInstrumentImpl {
- /* IUnknown fields */
- const IDirectMusicDownloadedInstrumentVtbl *lpVtbl;
- LONG ref;
+ /* IUnknown fields */
+ IDirectMusicDownloadedInstrument IDirectMusicDownloadedInstrument_iface;
+ LONG ref;
- /* IDirectMusicDownloadedInstrumentImpl fields */
+ /* IDirectMusicDownloadedInstrumentImpl fields */
+ BOOL downloaded;
+ void *data;
};
/*****************************************************************************
* IDirectMusicDownloadImpl implementation structure
*/
struct IDirectMusicDownloadImpl {
- /* IUnknown fields */
- const IDirectMusicDownloadVtbl *lpVtbl;
- LONG ref;
+ /* IUnknown fields */
+ IDirectMusicDownload IDirectMusicDownload_iface;
+ LONG ref;
- /* IDirectMusicDownloadImpl fields */
+ /* IDirectMusicDownloadImpl fields */
};
/*****************************************************************************
- * IDirectMusicPortImpl implementation structure
+ * SynthPortImpl implementation structure
*/
-struct IDirectMusicPortImpl {
- /* IUnknown fields */
- const IDirectMusicPortVtbl *lpVtbl;
- const IDirectMusicPortDownloadVtbl *lpDownloadVtbl;
- const IDirectMusicThruVtbl *lpThruVtbl;
- LONG ref;
-
- /* IDirectMusicPortImpl fields */
- IDirectSound* pDirectSound;
- IReferenceClock* pLatencyClock;
- BOOL fActive;
- DMUS_PORTCAPS caps;
- DMUS_PORTPARAMS params;
- int nrofgroups;
- DMUSIC_PRIVATE_CHANNEL_GROUP group[1];
+struct SynthPortImpl {
+ /* IUnknown fields */
+ IDirectMusicPort IDirectMusicPort_iface;
+ IDirectMusicPortDownload IDirectMusicPortDownload_iface;
+ IDirectMusicThru IDirectMusicThru_iface;
+ LONG ref;
+
+ /* IDirectMusicPort fields */
+ IDirectSound* pDirectSound;
+ IReferenceClock* pLatencyClock;
+ IDirectMusicSynth* synth;
+ IDirectMusicSynthSink* synth_sink;
+ BOOL fActive;
+ DMUS_PORTCAPS caps;
+ DMUS_PORTPARAMS params;
+ int nrofgroups;
+ DMUSIC_PRIVATE_CHANNEL_GROUP group[1];
};
-extern HRESULT WINAPI IDirectMusicPortImpl_Activate (LPDIRECTMUSICPORT iface, BOOL fActive);
-
/** Internal factory */
-extern HRESULT WINAPI DMUSIC_CreateDirectMusicPortImpl (LPCGUID lpcGUID, LPVOID *ppobj, LPUNKNOWN pUnkOuter, LPDMUS_PORTPARAMS pPortParams, LPDMUS_PORTCAPS pPortCaps);
+extern HRESULT DMUSIC_CreateSynthPortImpl(LPCGUID guid, LPVOID *object, LPUNKNOWN unkouter, LPDMUS_PORTPARAMS port_params, LPDMUS_PORTCAPS port_caps, DWORD device) DECLSPEC_HIDDEN;
+extern HRESULT DMUSIC_CreateMidiOutPortImpl(LPCGUID guid, LPVOID *object, LPUNKNOWN unkouter, LPDMUS_PORTPARAMS port_params, LPDMUS_PORTCAPS port_caps, DWORD device) DECLSPEC_HIDDEN;
+extern HRESULT DMUSIC_CreateMidiInPortImpl(LPCGUID guid, LPVOID *object, LPUNKNOWN unkouter, LPDMUS_PORTPARAMS port_params, LPDMUS_PORTCAPS port_caps, DWORD device) DECLSPEC_HIDDEN;
/*****************************************************************************
* IReferenceClockImpl implementation structure
*/
struct IReferenceClockImpl {
- /* IUnknown fields */
- const IReferenceClockVtbl *lpVtbl;
- LONG ref;
+ /* IUnknown fields */
+ IReferenceClock IReferenceClock_iface;
+ LONG ref;
- /* IReferenceClockImpl fields */
- REFERENCE_TIME rtTime;
- DMUS_CLOCKINFO pClockInfo;
+ /* IReferenceClockImpl fields */
+ REFERENCE_TIME rtTime;
+ DMUS_CLOCKINFO pClockInfo;
};
typedef struct _DMUS_PRIVATE_INSTRUMENT_ENTRY {
* IDirectMusicCollectionImpl implementation structure
*/
struct IDirectMusicCollectionImpl {
- /* IUnknown fields */
- const IUnknownVtbl *UnknownVtbl;
- const IDirectMusicCollectionVtbl *CollectionVtbl;
- const IDirectMusicObjectVtbl *ObjectVtbl;
- const IPersistStreamVtbl *PersistStreamVtbl;
- LONG ref;
-
- /* IDirectMusicCollectionImpl fields */
- IStream *pStm; /* stream from which we load collection and later instruments */
- LARGE_INTEGER liCollectionPosition; /* offset in a stream where collection was loaded from */
- LARGE_INTEGER liWavePoolTablePosition; /* offset in a stream where wave pool table can be found */
- LPDMUS_OBJECTDESC pDesc;
- CHAR* szCopyright; /* FIXME: should probably placed somewhere else */
- LPDLSHEADER pHeader;
- /* pool table */
- LPPOOLTABLE pPoolTable;
- LPPOOLCUE pPoolCues;
- /* instruments */
- struct list Instruments;
+ /* IUnknown fields */
+ IDirectMusicCollection IDirectMusicCollection_iface;
+ IDirectMusicObject IDirectMusicObject_iface;
+ IPersistStream IPersistStream_iface;
+ LONG ref;
+
+ /* IDirectMusicCollectionImpl fields */
+ IStream *pStm; /* stream from which we load collection and later instruments */
+ LARGE_INTEGER liCollectionPosition; /* offset in a stream where collection was loaded from */
+ LARGE_INTEGER liWavePoolTablePosition; /* offset in a stream where wave pool table can be found */
+ LPDMUS_OBJECTDESC pDesc;
+ CHAR* szCopyright; /* FIXME: should probably placed somewhere else */
+ LPDLSHEADER pHeader;
+ /* pool table */
+ LPPOOLTABLE pPoolTable;
+ LPPOOLCUE pPoolCues;
+ /* instruments */
+ struct list Instruments;
};
/*****************************************************************************
* IDirectMusicInstrumentImpl implementation structure
*/
struct IDirectMusicInstrumentImpl {
- /* IUnknown fields */
- const IUnknownVtbl *UnknownVtbl;
- const IDirectMusicInstrumentVtbl *InstrumentVtbl;
- LONG ref;
-
- /* IDirectMusicInstrumentImpl fields */
- LARGE_INTEGER liInstrumentPosition; /* offset in a stream where instrument chunk can be found */
- LPGUID pInstrumentID;
- LPINSTHEADER pHeader;
- WCHAR wszName[DMUS_MAX_NAME];
- /* instrument data */
+ /* IUnknown fields */
+ IDirectMusicInstrument IDirectMusicInstrument_iface;
+ LONG ref;
+
+ /* IDirectMusicInstrumentImpl fields */
+ LARGE_INTEGER liInstrumentPosition; /* offset in a stream where instrument chunk can be found */
+ ULONG length; /* Length of the instrument in the stream */
+ GUID id;
+ INSTHEADER header;
+ WCHAR wszName[DMUS_MAX_NAME];
+ /* instrument data */
+ BOOL loaded;
+ instrument_region *regions;
+ ULONG nb_articulations;
+ instrument_articulation *articulations;
};
+static inline IDirectMusicInstrumentImpl *impl_from_IDirectMusicInstrument(IDirectMusicInstrument *iface)
+{
+ return CONTAINING_RECORD(iface, IDirectMusicInstrumentImpl, IDirectMusicInstrument_iface);
+}
+
/* custom :) */
-extern HRESULT WINAPI IDirectMusicInstrumentImpl_Custom_Load (LPDIRECTMUSICINSTRUMENT iface, LPSTREAM pStm);
+extern HRESULT IDirectMusicInstrumentImpl_CustomLoad(IDirectMusicInstrument *iface, IStream *stream) DECLSPEC_HIDDEN;
/**********************************************************************
* Dll lifetime tracking declaration for dmusic.dll
*/
-extern LONG DMUSIC_refCount;
+extern LONG DMUSIC_refCount DECLSPEC_HIDDEN;
static inline void DMUSIC_LockModule(void) { InterlockedIncrement( &DMUSIC_refCount ); }
static inline void DMUSIC_UnlockModule(void) { InterlockedDecrement( &DMUSIC_refCount ); }
#define GE(x) { &x, #x }
/* dwPatch from MIDILOCALE */
-extern DWORD MIDILOCALE2Patch (LPMIDILOCALE pLocale);
+extern DWORD MIDILOCALE2Patch (const MIDILOCALE *pLocale) DECLSPEC_HIDDEN;
/* MIDILOCALE from dwPatch */
-extern void Patch2MIDILOCALE (DWORD dwPatch, LPMIDILOCALE pLocale);
+extern void Patch2MIDILOCALE (DWORD dwPatch, LPMIDILOCALE pLocale) DECLSPEC_HIDDEN;
/* check whether the given DWORD is even (return 0) or odd (return 1) */
-extern int even_or_odd (DWORD number);
+extern int even_or_odd (DWORD number) DECLSPEC_HIDDEN;
/* FOURCC to string conversion for debug messages */
-extern const char *debugstr_fourcc (DWORD fourcc);
+extern const char *debugstr_fourcc (DWORD fourcc) DECLSPEC_HIDDEN;
/* returns name of given GUID */
-extern const char *debugstr_dmguid (const GUID *id);
-/* dump whole DMUS_OBJECTDESC struct */
-extern const char *debugstr_DMUS_OBJECTDESC (LPDMUS_OBJECTDESC pDesc);
+extern const char *debugstr_dmguid (const GUID *id) DECLSPEC_HIDDEN;
+/* Dump whole DMUS_OBJECTDESC struct */
+extern void dump_DMUS_OBJECTDESC(LPDMUS_OBJECTDESC desc) DECLSPEC_HIDDEN;
+/* Dump whole DMUS_PORTPARAMS struct */
+extern void dump_DMUS_PORTPARAMS(LPDMUS_PORTPARAMS params) DECLSPEC_HIDDEN;
-#endif /* __WINE_DMUSIC_PRIVATE_H */
+#endif /* __WINE_DMUSIC_PRIVATE_H */
-/* IDirectMusicDownload Implementation
+/*
+ * IDirectMusicDownload Implementation
*
* Copyright (C) 2003-2004 Rok Mandeljc
*
WINE_DEFAULT_DEBUG_CHANNEL(dmusic);
+static inline IDirectMusicDownloadImpl* impl_from_IDirectMusicDownload(IDirectMusicDownload *iface)
+{
+ return CONTAINING_RECORD(iface, IDirectMusicDownloadImpl, IDirectMusicDownload_iface);
+}
+
/* IDirectMusicDownloadImpl IUnknown part: */
-static HRESULT WINAPI IDirectMusicDownloadImpl_QueryInterface (LPDIRECTMUSICDOWNLOAD iface, REFIID riid, LPVOID *ppobj) {
- IDirectMusicDownloadImpl *This = (IDirectMusicDownloadImpl *)iface;
- TRACE("(%p, %s, %p)\n", This, debugstr_dmguid(riid), ppobj);
-
- if (IsEqualIID (riid, &IID_IUnknown)
- || IsEqualIID (riid, &IID_IDirectMusicDownload)) {
- IUnknown_AddRef(iface);
- *ppobj = This;
- return S_OK;
- }
- WARN("(%p, %s, %p): not found\n", This, debugstr_dmguid(riid), ppobj);
- return E_NOINTERFACE;
+static HRESULT WINAPI IDirectMusicDownloadImpl_QueryInterface(IDirectMusicDownload *iface, REFIID riid, void **ret_iface)
+{
+ TRACE("(%p, %s, %p)\n", iface, debugstr_dmguid(riid), ret_iface);
+
+ if (IsEqualIID(riid, &IID_IUnknown) ||
+ IsEqualIID(riid, &IID_IDirectMusicDownload))
+ {
+ IDirectMusicDownload_AddRef(iface);
+ *ret_iface = iface;
+ return S_OK;
+ }
+
+ *ret_iface = NULL;
+ WARN("(%p, %s, %p): not found\n", iface, debugstr_dmguid(riid), ret_iface);
+ return E_NOINTERFACE;
}
-static ULONG WINAPI IDirectMusicDownloadImpl_AddRef (LPDIRECTMUSICDOWNLOAD iface) {
- IDirectMusicDownloadImpl *This = (IDirectMusicDownloadImpl *)iface;
- ULONG refCount = InterlockedIncrement(&This->ref);
+static ULONG WINAPI IDirectMusicDownloadImpl_AddRef(IDirectMusicDownload *iface)
+{
+ IDirectMusicDownloadImpl *This = impl_from_IDirectMusicDownload(iface);
+ ULONG ref = InterlockedIncrement(&This->ref);
- TRACE("(%p)->(ref before=%u)\n", This, refCount - 1);
+ TRACE("(%p)->(): new ref = %u\n", iface, ref);
- DMUSIC_LockModule();
+ DMUSIC_LockModule();
- return refCount;
+ return ref;
}
-static ULONG WINAPI IDirectMusicDownloadImpl_Release (LPDIRECTMUSICDOWNLOAD iface) {
- IDirectMusicDownloadImpl *This = (IDirectMusicDownloadImpl *)iface;
- ULONG refCount = InterlockedDecrement(&This->ref);
+static ULONG WINAPI IDirectMusicDownloadImpl_Release(IDirectMusicDownload *iface)
+{
+ IDirectMusicDownloadImpl *This = impl_from_IDirectMusicDownload(iface);
+ ULONG ref = InterlockedDecrement(&This->ref);
- TRACE("(%p)->(ref before=%u)\n", This, refCount + 1);
+ TRACE("(%p)->(): new ref = %u\n", iface, ref);
- if (!refCount) {
- HeapFree(GetProcessHeap(), 0, This);
- }
+ if (!ref)
+ HeapFree(GetProcessHeap(), 0, This);
- DMUSIC_UnlockModule();
-
- return refCount;
+ DMUSIC_UnlockModule();
+
+ return ref;
}
/* IDirectMusicDownloadImpl IDirectMusicDownload part: */
-static HRESULT WINAPI IDirectMusicDownloadImpl_GetBuffer (LPDIRECTMUSICDOWNLOAD iface, void** ppvBuffer, DWORD* pdwSize) {
- IDirectMusicDownloadImpl *This = (IDirectMusicDownloadImpl *)iface;
- FIXME("(%p, %p, %p): stub\n", This, ppvBuffer, pdwSize);
- return S_OK;
+static HRESULT WINAPI IDirectMusicDownloadImpl_GetBuffer(IDirectMusicDownload *iface, void **buffer, DWORD *size)
+{
+ FIXME("(%p, %p, %p): stub\n", iface, buffer, size);
+
+ return S_OK;
}
static const IDirectMusicDownloadVtbl DirectMusicDownload_Vtbl = {
- IDirectMusicDownloadImpl_QueryInterface,
- IDirectMusicDownloadImpl_AddRef,
- IDirectMusicDownloadImpl_Release,
- IDirectMusicDownloadImpl_GetBuffer
+ IDirectMusicDownloadImpl_QueryInterface,
+ IDirectMusicDownloadImpl_AddRef,
+ IDirectMusicDownloadImpl_Release,
+ IDirectMusicDownloadImpl_GetBuffer
};
/* for ClassFactory */
-HRESULT WINAPI DMUSIC_CreateDirectMusicDownloadImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter) {
- IDirectMusicDownloadImpl* dmdl;
-
- dmdl = HeapAlloc (GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicDownloadImpl));
- if (NULL == dmdl) {
- *ppobj = NULL;
- return E_OUTOFMEMORY;
- }
- dmdl->lpVtbl = &DirectMusicDownload_Vtbl;
- dmdl->ref = 0; /* will be inited by QueryInterface */
-
- return IDirectMusicDownloadImpl_QueryInterface ((LPDIRECTMUSICDOWNLOAD)dmdl, lpcGUID, ppobj);
+HRESULT DMUSIC_CreateDirectMusicDownloadImpl(const GUID *guid, void **ret_iface, IUnknown *unk_outer)
+{
+ IDirectMusicDownloadImpl *download;
+
+ download = HeapAlloc(GetProcessHeap(), 0, sizeof(*download));
+ if (!download)
+ {
+ *ret_iface = NULL;
+ return E_OUTOFMEMORY;
+ }
+
+ download->IDirectMusicDownload_iface.lpVtbl = &DirectMusicDownload_Vtbl;
+ download->ref = 1;
+ *ret_iface = download;
+ return S_OK;
}
+++ /dev/null
-/* IDirectMusicDownloadedInstrument Implementation
- *
- * Copyright (C) 2003-2004 Rok Mandeljc
- *
- * 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.
- *
- * This program 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 program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
- */
-
-#include "dmusic_private.h"
-
-WINE_DEFAULT_DEBUG_CHANNEL(dmusic);
-
-/* IDirectMusicDownloadedInstrumentImpl IUnknown part: */
-static HRESULT WINAPI IDirectMusicDownloadedInstrumentImpl_QueryInterface (LPDIRECTMUSICDOWNLOADEDINSTRUMENT iface, REFIID riid, LPVOID *ppobj) {
- IDirectMusicDownloadedInstrumentImpl *This = (IDirectMusicDownloadedInstrumentImpl *)iface;
- TRACE("(%p, %s, %p)\n", This, debugstr_dmguid(riid), ppobj);
-
- if (IsEqualIID (riid, &IID_IUnknown)
- || IsEqualIID (riid, &IID_IDirectMusicDownloadedInstrument)
- || IsEqualIID (riid, &IID_IDirectMusicDownloadedInstrument8)) {
- IUnknown_AddRef(iface);
- *ppobj = This;
- return S_OK;
- }
- WARN("(%p, %s, %p): not found\n", This, debugstr_dmguid(riid), ppobj);
- return E_NOINTERFACE;
-}
-
-static ULONG WINAPI IDirectMusicDownloadedInstrumentImpl_AddRef (LPDIRECTMUSICDOWNLOADEDINSTRUMENT iface) {
- IDirectMusicDownloadedInstrumentImpl *This = (IDirectMusicDownloadedInstrumentImpl *)iface;
- ULONG refCount = InterlockedIncrement(&This->ref);
-
- TRACE("(%p)->(ref before=%u)\n", This, refCount - 1);
-
- DMUSIC_LockModule();
-
- return refCount;
-}
-
-static ULONG WINAPI IDirectMusicDownloadedInstrumentImpl_Release (LPDIRECTMUSICDOWNLOADEDINSTRUMENT iface) {
- IDirectMusicDownloadedInstrumentImpl *This = (IDirectMusicDownloadedInstrumentImpl *)iface;
- ULONG refCount = InterlockedDecrement(&This->ref);
-
- TRACE("(%p)->(ref before=%u)\n", This, refCount + 1);
-
- if (!refCount) {
- HeapFree(GetProcessHeap(), 0, This);
- }
-
- DMUSIC_UnlockModule();
-
- return refCount;
-}
-
-/* IDirectMusicDownloadedInstrumentImpl IDirectMusicDownloadedInstrument part: */
-/* none at this time */
-
-static const IDirectMusicDownloadedInstrumentVtbl DirectMusicDownloadedInstrument_Vtbl = {
- IDirectMusicDownloadedInstrumentImpl_QueryInterface,
- IDirectMusicDownloadedInstrumentImpl_AddRef,
- IDirectMusicDownloadedInstrumentImpl_Release
-};
-
-/* for ClassFactory */
-HRESULT WINAPI DMUSIC_CreateDirectMusicDownloadedInstrumentImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter) {
- IDirectMusicDownloadedInstrumentImpl* dmdlinst;
-
- dmdlinst = HeapAlloc (GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicDownloadedInstrumentImpl));
- if (NULL == dmdlinst) {
- *ppobj = NULL;
- return E_OUTOFMEMORY;
- }
- dmdlinst->lpVtbl = &DirectMusicDownloadedInstrument_Vtbl;
- dmdlinst->ref = 0; /* will be inited by QueryInterface */
-
- return IDirectMusicDownloadedInstrumentImpl_QueryInterface ((LPDIRECTMUSICDOWNLOADEDINSTRUMENT)dmdlinst, lpcGUID, ppobj);
-}
-/* IDirectMusicInstrument Implementation
+/*
+ * IDirectMusicInstrument Implementation
*
* Copyright (C) 2003-2004 Rok Mandeljc
*
#include "dmusic_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(dmusic);
-WINE_DECLARE_DEBUG_CHANNEL(dmfile);
-static const GUID IID_IDirectMusicInstrumentPRIVATE = {0xbcb20080,0xa40c,0x11d1,{0x86,0xbc,0x00,0xc0,0x4f,0xbf,0x8f,0xef}};
-
-static ULONG WINAPI IDirectMusicInstrumentImpl_IUnknown_AddRef (LPUNKNOWN iface);
-static ULONG WINAPI IDirectMusicInstrumentImpl_IDirectMusicInstrument_AddRef (LPDIRECTMUSICINSTRUMENT iface);
+static const GUID IID_IDirectMusicInstrumentPRIVATE = { 0xbcb20080, 0xa40c, 0x11d1, { 0x86, 0xbc, 0x00, 0xc0, 0x4f, 0xbf, 0x8f, 0xef } };
/* IDirectMusicInstrument IUnknown part: */
-static HRESULT WINAPI IDirectMusicInstrumentImpl_IUnknown_QueryInterface (LPUNKNOWN iface, REFIID riid, LPVOID *ppobj) {
- ICOM_THIS_MULTI(IDirectMusicInstrumentImpl, UnknownVtbl, iface);
- TRACE("(%p, %s, %p)\n", This, debugstr_dmguid(riid), ppobj);
-
- if (IsEqualIID (riid, &IID_IUnknown)) {
- *ppobj = &This->UnknownVtbl;
- IDirectMusicInstrumentImpl_IUnknown_AddRef ((LPUNKNOWN)&This->UnknownVtbl);
- return S_OK;
- } else if (IsEqualIID (riid, &IID_IDirectMusicInstrument)) {
- *ppobj = &This->InstrumentVtbl;
- IDirectMusicInstrumentImpl_IDirectMusicInstrument_AddRef ((LPDIRECTMUSICINSTRUMENT)&This->InstrumentVtbl);
- return S_OK;
- } else if (IsEqualIID (riid, &IID_IDirectMusicInstrumentPRIVATE)) {
- /* it seems to me that this interface is only basic IUnknown, without any
- other inherited functions... *sigh* this is the worst scenario, since it means
- that whoever calls it knows the layout of original implementation table and therefore
- tries to get data by direct access... expect crashes */
- FIXME("*sigh*... requested private/unspecified interface\n");
- *ppobj = &This->UnknownVtbl;
- IDirectMusicInstrumentImpl_IUnknown_AddRef ((LPUNKNOWN)&This->UnknownVtbl);
- return S_OK;
- }
-
- WARN("(%p, %s, %p): not found\n", This, debugstr_dmguid(riid), ppobj);
- return E_NOINTERFACE;
-}
+static HRESULT WINAPI IDirectMusicInstrumentImpl_QueryInterface(LPDIRECTMUSICINSTRUMENT iface, REFIID riid, LPVOID *ret_iface)
+{
+ TRACE("(%p)->(%s, %p)\n", iface, debugstr_dmguid(riid), ret_iface);
-static ULONG WINAPI IDirectMusicInstrumentImpl_IUnknown_AddRef (LPUNKNOWN iface) {
- ICOM_THIS_MULTI(IDirectMusicInstrumentImpl, UnknownVtbl, iface);
- ULONG refCount = InterlockedIncrement(&This->ref);
+ if (IsEqualIID(riid, &IID_IUnknown) ||
+ IsEqualIID(riid, &IID_IDirectMusicInstrument))
+ {
+ *ret_iface = iface;
+ IDirectMusicInstrument_AddRef(iface);
+ return S_OK;
+ }
+ else if (IsEqualIID(riid, &IID_IDirectMusicInstrumentPRIVATE))
+ {
+ /* it seems to me that this interface is only basic IUnknown, without any
+ * other inherited functions... *sigh* this is the worst scenario, since it means
+ * that whoever calls it knows the layout of original implementation table and therefore
+ * tries to get data by direct access... expect crashes
+ */
+ FIXME("*sigh*... requested private/unspecified interface\n");
- TRACE("(%p)->(ref before=%u)\n", This, refCount - 1);
+ *ret_iface = iface;
+ IDirectMusicInstrument_AddRef(iface);
+ return S_OK;
+ }
- DMUSIC_LockModule();
+ WARN("(%p)->(%s, %p): not found\n", iface, debugstr_dmguid(riid), ret_iface);
- return refCount;
+ return E_NOINTERFACE;
}
-static ULONG WINAPI IDirectMusicInstrumentImpl_IUnknown_Release (LPUNKNOWN iface) {
- ICOM_THIS_MULTI(IDirectMusicInstrumentImpl, UnknownVtbl, iface);
- ULONG refCount = InterlockedDecrement(&This->ref);
+static ULONG WINAPI IDirectMusicInstrumentImpl_AddRef(LPDIRECTMUSICINSTRUMENT iface)
+{
+ IDirectMusicInstrumentImpl *This = impl_from_IDirectMusicInstrument(iface);
+ ULONG ref = InterlockedIncrement(&This->ref);
- TRACE("(%p)->(ref before=%u)\n", This, refCount + 1);
+ TRACE("(%p)->(): new ref = %u\n", iface, ref);
- if (!refCount) {
- HeapFree(GetProcessHeap(), 0, This);
- }
+ DMUSIC_LockModule();
- DMUSIC_UnlockModule();
-
- return refCount;
+ return ref;
}
-static const IUnknownVtbl DirectMusicInstrument_Unknown_Vtbl = {
- IDirectMusicInstrumentImpl_IUnknown_QueryInterface,
- IDirectMusicInstrumentImpl_IUnknown_AddRef,
- IDirectMusicInstrumentImpl_IUnknown_Release
-};
+static ULONG WINAPI IDirectMusicInstrumentImpl_Release(LPDIRECTMUSICINSTRUMENT iface)
+{
+ IDirectMusicInstrumentImpl *This = impl_from_IDirectMusicInstrument(iface);
+ ULONG ref = InterlockedDecrement(&This->ref);
-/* IDirectMusicInstrumentImpl IDirectMusicInstrument part: */
-static HRESULT WINAPI IDirectMusicInstrumentImpl_IDirectMusicInstrument_QueryInterface (LPDIRECTMUSICINSTRUMENT iface, REFIID riid, LPVOID *ppobj) {
- ICOM_THIS_MULTI(IDirectMusicInstrumentImpl, InstrumentVtbl, iface);
- return IDirectMusicInstrumentImpl_IUnknown_QueryInterface ((LPUNKNOWN)&This->UnknownVtbl, riid, ppobj);
-}
+ TRACE("(%p)->(): new ref = %u\n", iface, ref);
-static ULONG WINAPI IDirectMusicInstrumentImpl_IDirectMusicInstrument_AddRef (LPDIRECTMUSICINSTRUMENT iface) {
- ICOM_THIS_MULTI(IDirectMusicInstrumentImpl, InstrumentVtbl, iface);
- return IDirectMusicInstrumentImpl_IUnknown_AddRef ((LPUNKNOWN)&This->UnknownVtbl);
-}
+ if (!ref)
+ {
+ ULONG i;
+
+ HeapFree(GetProcessHeap(), 0, This->regions);
+ for (i = 0; i < This->nb_articulations; i++)
+ HeapFree(GetProcessHeap(), 0, This->articulations->connections);
+ HeapFree(GetProcessHeap(), 0, This->articulations);
+ HeapFree(GetProcessHeap(), 0, This);
+ }
+
+ DMUSIC_UnlockModule();
-static ULONG WINAPI IDirectMusicInstrumentImpl_IDirectMusicInstrument_Release (LPDIRECTMUSICINSTRUMENT iface) {
- ICOM_THIS_MULTI(IDirectMusicInstrumentImpl, InstrumentVtbl, iface);
- return IDirectMusicInstrumentImpl_IUnknown_Release ((LPUNKNOWN)&This->UnknownVtbl);
+ return ref;
}
-static HRESULT WINAPI IDirectMusicInstrumentImpl_IDirectMusicInstrument_GetPatch (LPDIRECTMUSICINSTRUMENT iface, DWORD* pdwPatch) {
- ICOM_THIS_MULTI(IDirectMusicInstrumentImpl, InstrumentVtbl, iface);
- TRACE("(%p, %p)\n", This, pdwPatch);
- *pdwPatch = MIDILOCALE2Patch(&This->pHeader->Locale);
- return S_OK;
+/* IDirectMusicInstrumentImpl IDirectMusicInstrument part: */
+static HRESULT WINAPI IDirectMusicInstrumentImpl_GetPatch(LPDIRECTMUSICINSTRUMENT iface, DWORD* pdwPatch)
+{
+ IDirectMusicInstrumentImpl *This = impl_from_IDirectMusicInstrument(iface);
+
+ TRACE("(%p)->(%p)\n", This, pdwPatch);
+
+ *pdwPatch = MIDILOCALE2Patch(&This->header.Locale);
+
+ return S_OK;
}
-static HRESULT WINAPI IDirectMusicInstrumentImpl_IDirectMusicInstrument_SetPatch (LPDIRECTMUSICINSTRUMENT iface, DWORD dwPatch) {
- ICOM_THIS_MULTI(IDirectMusicInstrumentImpl, InstrumentVtbl, iface);
- TRACE("(%p, %d): stub\n", This, dwPatch);
- Patch2MIDILOCALE(dwPatch, &This->pHeader->Locale);
- return S_OK;
+static HRESULT WINAPI IDirectMusicInstrumentImpl_SetPatch(LPDIRECTMUSICINSTRUMENT iface, DWORD dwPatch)
+{
+ IDirectMusicInstrumentImpl *This = impl_from_IDirectMusicInstrument(iface);
+
+ TRACE("(%p)->(%d): stub\n", This, dwPatch);
+
+ Patch2MIDILOCALE(dwPatch, &This->header.Locale);
+
+ return S_OK;
}
-static const IDirectMusicInstrumentVtbl DirectMusicInstrument_Instrument_Vtbl = {
- IDirectMusicInstrumentImpl_IDirectMusicInstrument_QueryInterface,
- IDirectMusicInstrumentImpl_IDirectMusicInstrument_AddRef,
- IDirectMusicInstrumentImpl_IDirectMusicInstrument_Release,
- IDirectMusicInstrumentImpl_IDirectMusicInstrument_GetPatch,
- IDirectMusicInstrumentImpl_IDirectMusicInstrument_SetPatch
+static const IDirectMusicInstrumentVtbl DirectMusicInstrument_Vtbl =
+{
+ IDirectMusicInstrumentImpl_QueryInterface,
+ IDirectMusicInstrumentImpl_AddRef,
+ IDirectMusicInstrumentImpl_Release,
+ IDirectMusicInstrumentImpl_GetPatch,
+ IDirectMusicInstrumentImpl_SetPatch
};
/* for ClassFactory */
-HRESULT WINAPI DMUSIC_CreateDirectMusicInstrumentImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter) {
+HRESULT DMUSIC_CreateDirectMusicInstrumentImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter) {
IDirectMusicInstrumentImpl* dminst;
dminst = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicInstrumentImpl));
*ppobj = NULL;
return E_OUTOFMEMORY;
}
- dminst->UnknownVtbl = &DirectMusicInstrument_Unknown_Vtbl;
- dminst->InstrumentVtbl = &DirectMusicInstrument_Instrument_Vtbl;
+ dminst->IDirectMusicInstrument_iface.lpVtbl = &DirectMusicInstrument_Vtbl;
dminst->ref = 0; /* will be inited by QueryInterface */
- return IDirectMusicInstrumentImpl_IUnknown_QueryInterface ((LPUNKNOWN)&dminst->UnknownVtbl, lpcGUID, ppobj);
+ return IDirectMusicInstrument_QueryInterface(&dminst->IDirectMusicInstrument_iface, lpcGUID, ppobj);
}
-/* aux. function that completely loads instrument; my tests indicate that it's
- called somewhere around IDirectMusicCollection_GetInstrument */
-HRESULT WINAPI IDirectMusicInstrumentImpl_Custom_Load (LPDIRECTMUSICINSTRUMENT iface, LPSTREAM pStm) {
- ICOM_THIS_MULTI(IDirectMusicInstrumentImpl, InstrumentVtbl, iface);
-
- DMUS_PRIVATE_CHUNK Chunk;
- DWORD ListSize[4], ListCount[4];
- LARGE_INTEGER liMove; /* used when skipping chunks */
-
- TRACE("(%p, %p, offset = %s)\n", This, pStm, wine_dbgstr_longlong(This->liInstrumentPosition.QuadPart));
+static HRESULT read_from_stream(IStream *stream, void *data, ULONG size)
+{
+ ULONG bytes_read;
+ HRESULT hr;
- /* goto the beginning of chunk */
- IStream_Seek (pStm, This->liInstrumentPosition, STREAM_SEEK_SET, NULL);
-
- IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
- TRACE_(dmfile)(": %s chunk (size = 0x%04x)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
- switch (Chunk.fccID) {
- case FOURCC_LIST: {
- IStream_Read (pStm, &Chunk.fccID, sizeof(FOURCC), NULL);
- TRACE_(dmfile)(": LIST chunk of type %s", debugstr_fourcc(Chunk.fccID));
- ListSize[0] = Chunk.dwSize - sizeof(FOURCC);
- ListCount[0] = 0;
- switch (Chunk.fccID) {
- case FOURCC_INS: {
- TRACE_(dmfile)(": instrument list\n");
- do {
- IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
- ListCount[0] += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
- TRACE_(dmfile)(": %s chunk (size = 0x%04x)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
- switch (Chunk.fccID) {
- case FOURCC_INSH: {
- TRACE_(dmfile)(": instrument header chunk\n");
- /* should be already initialised */
- IStream_Read (pStm, This->pHeader, Chunk.dwSize, NULL);
- break;
- }
- case FOURCC_DLID: {
- TRACE_(dmfile)(": DLID (GUID) chunk\n");
- /* should be already initialised */
- IStream_Read (pStm, This->pInstrumentID, Chunk.dwSize, NULL);
- break;
- }
- case FOURCC_LIST: {
- IStream_Read (pStm, &Chunk.fccID, sizeof(FOURCC), NULL);
- TRACE_(dmfile)(": LIST chunk of type %s", debugstr_fourcc(Chunk.fccID));
- ListSize[1] = Chunk.dwSize - sizeof(FOURCC);
- ListCount[1] = 0;
- switch (Chunk.fccID) {
- case FOURCC_LRGN: {
- TRACE_(dmfile)(": regions list\n");
- do {
- IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
- ListCount[1] += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
- TRACE_(dmfile)(": %s chunk (size = 0x%04x)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
- switch (Chunk.fccID) {
- case FOURCC_LIST: {
- IStream_Read (pStm, &Chunk.fccID, sizeof(FOURCC), NULL);
- TRACE_(dmfile)(": LIST chunk of type %s", debugstr_fourcc(Chunk.fccID));
- ListSize[2] = Chunk.dwSize - sizeof(FOURCC);
- ListCount[2] = 0;
- switch (Chunk.fccID) {
- case FOURCC_RGN: {
- /* temporary structures */
- RGNHEADER tmpRegionHeader;
- WSMPL tmpWaveSample;
- WLOOP tmpWaveLoop;
- WAVELINK tmpWaveLink;
-
- TRACE_(dmfile)(": region list\n");
- do {
- IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
- ListCount[2] += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
- TRACE_(dmfile)(": %s chunk (size = 0x%04x)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
- switch (Chunk.fccID) {
- case FOURCC_RGNH: {
- TRACE_(dmfile)(": region header chunk\n");
- memset (&tmpRegionHeader, 0, sizeof(RGNHEADER)); /* reset */
- IStream_Read (pStm, &tmpRegionHeader, Chunk.dwSize, NULL);
- break;
- }
- case FOURCC_WSMP: {
- TRACE_(dmfile)(": wave sample chunk\n");
- memset (&tmpWaveSample, 0, sizeof(WSMPL)); /* reset */
- memset (&tmpWaveLoop, 0, sizeof(WLOOP)); /* reset */
- if (Chunk.dwSize != (sizeof(WSMPL) + sizeof(WLOOP))) ERR(": incorrect chunk size\n");
- IStream_Read (pStm, &tmpWaveSample, sizeof(WSMPL), NULL);
- IStream_Read (pStm, &tmpWaveLoop, sizeof(WLOOP), NULL);
- break;
- }
- case FOURCC_WLNK: {
- TRACE_(dmfile)(": wave link chunk\n");
- memset (&tmpWaveLink, 0, sizeof(WAVELINK)); /* reset */
- IStream_Read (pStm, &tmpWaveLink, Chunk.dwSize, NULL);
- break;
- }
- default: {
- TRACE_(dmfile)(": unknown (skipping)\n");
- liMove.QuadPart = Chunk.dwSize - sizeof(FOURCC);
- IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
- break;
- }
- }
- TRACE_(dmfile)(": ListCount[2] = %d < ListSize[2] = %d\n", ListCount[2], ListSize[2]);
- } while (ListCount[2] < ListSize[2]);
- FIXME(": need to write temporary data to instrument data\n");
- break;
- }
- default: {
- TRACE_(dmfile)(": unknown (skipping)\n");
- liMove.QuadPart = Chunk.dwSize - sizeof(FOURCC);
- IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
- break;
- }
- }
- break;
- }
- default: {
- TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
- liMove.QuadPart = Chunk.dwSize;
- IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
- break;
- }
- }
- TRACE_(dmfile)(": ListCount[1] = %d < ListSize[1] = %d\n", ListCount[1], ListSize[1]);
- } while (ListCount[1] < ListSize[1]);
- break;
- }
- case FOURCC_LART: {
- TRACE_(dmfile)(": articulators list\n");
- do {
- IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
- ListCount[1] += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
- TRACE_(dmfile)(": %s chunk (size = 0x%04x)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
- switch (Chunk.fccID) {
- case FOURCC_ART1: {
- /* temporary structures */
- CONNECTIONLIST tmpConnectionList;
- LPCONNECTION tmpConnections;
-
- TRACE_(dmfile)(": level 1 articulator chunk\n");
- memset (&tmpConnectionList, 0, sizeof(CONNECTIONLIST)); /* reset */
- tmpConnections = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, sizeof(CONNECTION)*tmpConnectionList.cConnections);
- if (Chunk.dwSize != (sizeof(CONNECTIONLIST) + sizeof(CONNECTION)*tmpConnectionList.cConnections)) ERR(": incorrect chunk size\n");
- IStream_Read (pStm, &tmpConnectionList, sizeof(CONNECTIONLIST), NULL);
- IStream_Read (pStm, tmpConnections, sizeof(CONNECTION)*tmpConnectionList.cConnections, NULL);
- break;
- }
- default: {
- TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
- liMove.QuadPart = Chunk.dwSize;
- IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
- break;
- }
- }
- TRACE_(dmfile)(": ListCount[1] = %d < ListSize[1] = %d\n", ListCount[1], ListSize[1]);
- } while (ListCount[1] < ListSize[1]);
- break;
- }
- case mmioFOURCC('I','N','F','O'): {
- TRACE_(dmfile)(": INFO list\n");
- do {
- IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
- ListCount[1] += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
- TRACE_(dmfile)(": %s chunk (size = 0x%04x)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
- switch (Chunk.fccID) {
- case mmioFOURCC('I','N','A','M'): {
- TRACE_(dmfile)(": name chunk (ignored)\n");
- if (even_or_odd(Chunk.dwSize)) {
- ListCount[1] ++;
- Chunk.dwSize++;
- }
- liMove.QuadPart = Chunk.dwSize;
- IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
- break;
- }
- case mmioFOURCC('I','A','R','T'): {
- TRACE_(dmfile)(": artist chunk (ignored)\n");
- if (even_or_odd(Chunk.dwSize)) {
- ListCount[1] ++;
- Chunk.dwSize++;
- }
- liMove.QuadPart = Chunk.dwSize;
- IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
- break;
- }
- case mmioFOURCC('I','C','O','P'): {
- /* temporary structures */
- CHAR tmpCopyright[DMUS_MAX_NAME];
-
- TRACE_(dmfile)(": copyright chunk\n");
- IStream_Read (pStm, tmpCopyright, Chunk.dwSize, NULL);
- if (even_or_odd(Chunk.dwSize)) {
- ListCount[1] ++;
- liMove.QuadPart = 1;
- IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
- }
- break;
- }
- case mmioFOURCC('I','S','B','J'): {
- TRACE_(dmfile)(": subject chunk (ignored)\n");
- if (even_or_odd(Chunk.dwSize)) {
- ListCount[1] ++;
- Chunk.dwSize++;
- }
- liMove.QuadPart = Chunk.dwSize;
- IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
- break;
- }
- case mmioFOURCC('I','C','M','T'): {
- TRACE_(dmfile)(": comment chunk (ignored)\n");
- if (even_or_odd(Chunk.dwSize)) {
- ListCount[1] ++;
- Chunk.dwSize++;
- }
- liMove.QuadPart = Chunk.dwSize;
- IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
- break;
- }
- default: {
- TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
- if (even_or_odd(Chunk.dwSize)) {
- ListCount[1] ++;
- Chunk.dwSize++;
- }
- liMove.QuadPart = Chunk.dwSize;
- IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
- break;
- }
- }
- TRACE_(dmfile)(": ListCount[1] = %d < ListSize[1] = %d\n", ListCount[1], ListSize[1]);
- } while (ListCount[1] < ListSize[1]);
- break;
- }
-
- default: {
- TRACE_(dmfile)(": unknown (skipping)\n");
- liMove.QuadPart = Chunk.dwSize - sizeof(FOURCC);
- IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
- break;
- }
- }
- break;
- }
- default: {
- TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
- liMove.QuadPart = Chunk.dwSize;
- IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
- break;
- }
- }
- TRACE_(dmfile)(": ListCount[0] = %d < ListSize[0] = %d\n", ListCount[0], ListSize[0]);
- } while (ListCount[0] < ListSize[0]);
- break;
- }
- default: {
- TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
- liMove.QuadPart = Chunk.dwSize;
- IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
- break;
- }
- }
- break;
- }
- default: {
- TRACE_(dmfile)(": unexpected chunk; loading failed)\n");
- liMove.QuadPart = Chunk.dwSize;
- IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL); /* skip the rest of the chunk */
- return E_FAIL;
- }
- }
- /* DEBUG: dumps whole instrument object tree: */
-/* if (TRACE_ON(dmusic)) {
- TRACE("*** IDirectMusicInstrument (%p) ***\n", This);
- if (This->pInstrumentID)
- TRACE(" - GUID = %s\n", debugstr_dmguid(This->pInstrumentID));
-
- TRACE(" - Instrument header:\n");
- TRACE(" - cRegions: %ld\n", This->pHeader->cRegions);
- TRACE(" - Locale:\n");
- TRACE(" - ulBank: %ld\n", This->pHeader->Locale.ulBank);
- TRACE(" - ulInstrument: %ld\n", This->pHeader->Locale.ulInstrument);
- TRACE(" => dwPatch: %ld\n", MIDILOCALE2Patch(&This->pHeader->Locale));
- }*/
-
- return S_OK;
+ hr = IStream_Read(stream, data, size, &bytes_read);
+ if(FAILED(hr)){
+ TRACE("IStream_Read failed: %08x\n", hr);
+ return hr;
+ }
+ if (bytes_read < size) {
+ TRACE("Didn't read full chunk: %u < %u\n", bytes_read, size);
+ return E_FAIL;
+ }
+
+ return S_OK;
+}
+
+static inline DWORD subtract_bytes(DWORD len, DWORD bytes)
+{
+ if(bytes > len){
+ TRACE("Apparent mismatch in chunk lengths? %u bytes remaining, %u bytes read\n", len, bytes);
+ return 0;
+ }
+ return len - bytes;
+}
+
+static inline HRESULT advance_stream(IStream *stream, ULONG bytes)
+{
+ LARGE_INTEGER move;
+ HRESULT ret;
+
+ move.QuadPart = bytes;
+
+ ret = IStream_Seek(stream, move, STREAM_SEEK_CUR, NULL);
+ if (FAILED(ret))
+ WARN("IStream_Seek failed: %08x\n", ret);
+
+ return ret;
+}
+
+static HRESULT load_region(IDirectMusicInstrumentImpl *This, IStream *stream, instrument_region *region, ULONG length)
+{
+ HRESULT ret;
+ DMUS_PRIVATE_CHUNK chunk;
+
+ TRACE("(%p, %p, %p, %u)\n", This, stream, region, length);
+
+ while (length)
+ {
+ ret = read_from_stream(stream, &chunk, sizeof(chunk));
+ if (FAILED(ret))
+ return ret;
+
+ length = subtract_bytes(length, sizeof(chunk));
+
+ switch (chunk.fccID)
+ {
+ case FOURCC_RGNH:
+ TRACE("RGNH chunk (region header): %u bytes\n", chunk.dwSize);
+
+ ret = read_from_stream(stream, ®ion->header, sizeof(region->header));
+ if (FAILED(ret))
+ return ret;
+
+ length = subtract_bytes(length, sizeof(region->header));
+ break;
+
+ case FOURCC_WSMP:
+ TRACE("WSMP chunk (wave sample): %u bytes\n", chunk.dwSize);
+
+ ret = read_from_stream(stream, ®ion->wave_sample, sizeof(region->wave_sample));
+ if (FAILED(ret))
+ return ret;
+ length = subtract_bytes(length, sizeof(region->wave_sample));
+
+ if (!(region->loop_present = (chunk.dwSize != sizeof(region->wave_sample))))
+ break;
+
+ ret = read_from_stream(stream, ®ion->wave_loop, sizeof(region->wave_loop));
+ if (FAILED(ret))
+ return ret;
+
+ length = subtract_bytes(length, sizeof(region->wave_loop));
+ break;
+
+ case FOURCC_WLNK:
+ TRACE("WLNK chunk (wave link): %u bytes\n", chunk.dwSize);
+
+ ret = read_from_stream(stream, ®ion->wave_link, sizeof(region->wave_link));
+ if (FAILED(ret))
+ return ret;
+
+ length = subtract_bytes(length, sizeof(region->wave_link));
+ break;
+
+ default:
+ TRACE("Unknown chunk %s (skipping): %u bytes\n", debugstr_fourcc(chunk.fccID), chunk.dwSize);
+
+ ret = advance_stream(stream, chunk.dwSize);
+ if (FAILED(ret))
+ return ret;
+
+ length = subtract_bytes(length, chunk.dwSize);
+ break;
+ }
+ }
+
+ return S_OK;
+}
+
+static HRESULT load_articulation(IDirectMusicInstrumentImpl *This, IStream *stream, ULONG length)
+{
+ HRESULT ret;
+ instrument_articulation *articulation;
+
+ if (!This->articulations)
+ This->articulations = HeapAlloc(GetProcessHeap(), 0, sizeof(*This->articulations));
+ else
+ This->articulations = HeapReAlloc(GetProcessHeap(), 0, This->articulations, sizeof(*This->articulations) * (This->nb_articulations + 1));
+ if (!This->articulations)
+ return E_OUTOFMEMORY;
+
+ articulation = &This->articulations[This->nb_articulations];
+
+ ret = read_from_stream(stream, &articulation->connections_list, sizeof(CONNECTIONLIST));
+ if (FAILED(ret))
+ return ret;
+
+ articulation->connections = HeapAlloc(GetProcessHeap(), 0, sizeof(CONNECTION) * articulation->connections_list.cConnections);
+ if (!articulation->connections)
+ return E_OUTOFMEMORY;
+
+ ret = read_from_stream(stream, articulation->connections, sizeof(CONNECTION) * articulation->connections_list.cConnections);
+ if (FAILED(ret))
+ {
+ HeapFree(GetProcessHeap(), 0, articulation->connections);
+ return ret;
+ }
+
+ subtract_bytes(length, sizeof(CONNECTIONLIST) + sizeof(CONNECTION) * articulation->connections_list.cConnections);
+
+ This->nb_articulations++;
+
+ return S_OK;
+}
+
+/* Function that loads all instrument data and which is called from IDirectMusicCollection_GetInstrument as in native */
+HRESULT IDirectMusicInstrumentImpl_CustomLoad(IDirectMusicInstrument *iface, IStream *stream)
+{
+ IDirectMusicInstrumentImpl *This = impl_from_IDirectMusicInstrument(iface);
+ HRESULT hr;
+ DMUS_PRIVATE_CHUNK chunk;
+ ULONG i = 0;
+ ULONG length = This->length;
+
+ TRACE("(%p, %p): offset = 0x%s, length = %u)\n", This, stream, wine_dbgstr_longlong(This->liInstrumentPosition.QuadPart), This->length);
+
+ if (This->loaded)
+ return S_OK;
+
+ hr = IStream_Seek(stream, This->liInstrumentPosition, STREAM_SEEK_SET, NULL);
+ if (FAILED(hr))
+ {
+ WARN("IStream_Seek failed: %08x\n", hr);
+ return DMUS_E_UNSUPPORTED_STREAM;
+ }
+
+ This->regions = HeapAlloc(GetProcessHeap(), 0, sizeof(*This->regions) * This->header.cRegions);
+ if (!This->regions)
+ return E_OUTOFMEMORY;
+
+ while (length)
+ {
+ hr = read_from_stream(stream, &chunk, sizeof(chunk));
+ if (FAILED(hr))
+ goto error;
+
+ length = subtract_bytes(length, sizeof(chunk) + chunk.dwSize);
+
+ switch (chunk.fccID)
+ {
+ case FOURCC_INSH:
+ case FOURCC_DLID:
+ TRACE("Chunk %s: %u bytes\n", debugstr_fourcc(chunk.fccID), chunk.dwSize);
+
+ /* Instrument header and id are already set so just skip */
+ hr = advance_stream(stream, chunk.dwSize);
+ if (FAILED(hr))
+ goto error;
+
+ break;
+
+ case FOURCC_LIST: {
+ DWORD size = chunk.dwSize;
+
+ TRACE("LIST chunk: %u bytes\n", chunk.dwSize);
+
+ hr = read_from_stream(stream, &chunk.fccID, sizeof(chunk.fccID));
+ if (FAILED(hr))
+ goto error;
+
+ size = subtract_bytes(size, sizeof(chunk.fccID));
+
+ switch (chunk.fccID)
+ {
+ case FOURCC_LRGN:
+ TRACE("LRGN chunk (regions list): %u bytes\n", size);
+
+ while (size)
+ {
+ hr = read_from_stream(stream, &chunk, sizeof(chunk));
+ if (FAILED(hr))
+ goto error;
+
+ if (chunk.fccID != FOURCC_LIST)
+ {
+ TRACE("Unknown chunk %s: %u bytes\n", debugstr_fourcc(chunk.fccID), chunk.dwSize);
+ goto error;
+ }
+
+ hr = read_from_stream(stream, &chunk.fccID, sizeof(chunk.fccID));
+ if (FAILED(hr))
+ goto error;
+
+ if (chunk.fccID == FOURCC_RGN)
+ {
+ TRACE("RGN chunk (region): %u bytes\n", chunk.dwSize);
+ hr = load_region(This, stream, &This->regions[i++], chunk.dwSize - sizeof(chunk.fccID));
+ }
+ else
+ {
+ TRACE("Unknown chunk %s: %u bytes\n", debugstr_fourcc(chunk.fccID), chunk.dwSize);
+ hr = advance_stream(stream, chunk.dwSize - sizeof(chunk.fccID));
+ }
+ if (FAILED(hr))
+ goto error;
+
+ size = subtract_bytes(size, chunk.dwSize + sizeof(chunk));
+ }
+ break;
+
+ case FOURCC_LART:
+ TRACE("LART chunk (articulations list): %u bytes\n", size);
+
+ while (size)
+ {
+ hr = read_from_stream(stream, &chunk, sizeof(chunk));
+ if (FAILED(hr))
+ goto error;
+
+ if (chunk.fccID == FOURCC_ART1)
+ {
+ TRACE("ART1 chunk (level 1 articulation): %u bytes\n", chunk.dwSize);
+ hr = load_articulation(This, stream, chunk.dwSize);
+ }
+ else
+ {
+ TRACE("Unknown chunk %s: %u bytes\n", debugstr_fourcc(chunk.fccID), chunk.dwSize);
+ hr = advance_stream(stream, chunk.dwSize);
+ }
+ if (FAILED(hr))
+ goto error;
+
+ size = subtract_bytes(size, chunk.dwSize + sizeof(chunk));
+ }
+ break;
+
+ default:
+ TRACE("Unknown chunk %s: %u bytes\n", debugstr_fourcc(chunk.fccID), chunk.dwSize);
+
+ hr = advance_stream(stream, chunk.dwSize - sizeof(chunk.fccID));
+ if (FAILED(hr))
+ goto error;
+
+ size = subtract_bytes(size, chunk.dwSize - sizeof(chunk.fccID));
+ break;
+ }
+ break;
+ }
+
+ default:
+ TRACE("Unknown chunk %s: %u bytes\n", debugstr_fourcc(chunk.fccID), chunk.dwSize);
+
+ hr = advance_stream(stream, chunk.dwSize);
+ if (FAILED(hr))
+ goto error;
+
+ break;
+ }
+ }
+
+ This->loaded = TRUE;
+
+ return S_OK;
+
+error:
+ HeapFree(GetProcessHeap(), 0, This->regions);
+ This->regions = NULL;
+
+ return DMUS_E_UNSUPPORTED_STREAM;
}
-/* IDirectMusicPort Implementation
+/*
+ * IDirectMusicPort Implementation
*
* Copyright (C) 2003-2004 Rok Mandeljc
+ * Copyright (C) 2012 Christian Costa
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
+#include <assert.h>
#include "dmusic_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(dmusic);
-/* IDirectMusicPortImpl IUnknown part: */
-static HRESULT WINAPI IDirectMusicPortImpl_QueryInterface (LPDIRECTMUSICPORT iface, REFIID riid, LPVOID *ppobj) {
- ICOM_THIS_MULTI(IDirectMusicPortImpl, lpVtbl, iface);
-
- TRACE("(%p, %s, %p)\n", This, debugstr_dmguid(riid), ppobj);
-
- if (IsEqualIID (riid, &IID_IUnknown) ||
- IsEqualGUID(riid, &IID_IDirectMusicPort) ||
- IsEqualGUID(riid, &IID_IDirectMusicPort8)) {
- *ppobj = &This->lpVtbl;
- IDirectMusicPort_AddRef((LPDIRECTMUSICPORT)*ppobj);
- return S_OK;
- } else if (IsEqualGUID(riid, &IID_IDirectMusicPortDownload) ||
- IsEqualGUID(riid, &IID_IDirectMusicPortDownload8)) {
- *ppobj = &This->lpDownloadVtbl;
- IDirectMusicPortDownload_AddRef((LPDIRECTMUSICPORTDOWNLOAD)*ppobj);
- return S_OK;
- } else if (IsEqualGUID(riid, &IID_IDirectMusicThru) ||
- IsEqualGUID(riid, &IID_IDirectMusicThru8)) {
- *ppobj = &This->lpThruVtbl;
- IDirectMusicThru_AddRef((LPDIRECTMUSICTHRU)*ppobj);
- return S_OK;
- }
- WARN("(%p, %s, %p): not found\n", This, debugstr_dmguid(riid), ppobj);
- return E_NOINTERFACE;
+static inline IDirectMusicDownloadedInstrumentImpl* impl_from_IDirectMusicDownloadedInstrument(IDirectMusicDownloadedInstrument *iface)
+{
+ return CONTAINING_RECORD(iface, IDirectMusicDownloadedInstrumentImpl, IDirectMusicDownloadedInstrument_iface);
+}
+
+static inline SynthPortImpl *impl_from_SynthPortImpl_IDirectMusicPort(IDirectMusicPort *iface)
+{
+ return CONTAINING_RECORD(iface, SynthPortImpl, IDirectMusicPort_iface);
+}
+
+static inline SynthPortImpl *impl_from_SynthPortImpl_IDirectMusicPortDownload(IDirectMusicPortDownload *iface)
+{
+ return CONTAINING_RECORD(iface, SynthPortImpl, IDirectMusicPortDownload_iface);
}
-static ULONG WINAPI IDirectMusicPortImpl_AddRef (LPDIRECTMUSICPORT iface) {
- IDirectMusicPortImpl *This = (IDirectMusicPortImpl *)iface;
- ULONG refCount = InterlockedIncrement(&This->ref);
+static inline SynthPortImpl *impl_from_SynthPortImpl_IDirectMusicThru(IDirectMusicThru *iface)
+{
+ return CONTAINING_RECORD(iface, SynthPortImpl, IDirectMusicThru_iface);
+}
+
+/* IDirectMusicDownloadedInstrument IUnknown part follows: */
+static HRESULT WINAPI IDirectMusicDownloadedInstrumentImpl_QueryInterface(IDirectMusicDownloadedInstrument *iface, REFIID riid, VOID **ret_iface)
+{
+ TRACE("(%p, %s, %p)\n", iface, debugstr_dmguid(riid), ret_iface);
- TRACE("(%p)->(ref before=%u)\n", This, refCount - 1);
+ if (IsEqualIID(riid, &IID_IUnknown) ||
+ IsEqualIID(riid, &IID_IDirectMusicDownloadedInstrument) ||
+ IsEqualIID(riid, &IID_IDirectMusicDownloadedInstrument8))
+ {
+ IDirectMusicDownloadedInstrument_AddRef(iface);
+ *ret_iface = iface;
+ return S_OK;
+ }
- DMUSIC_LockModule();
+ WARN("(%p, %s, %p): not found\n", iface, debugstr_dmguid(riid), ret_iface);
- return refCount;
+ return E_NOINTERFACE;
}
-static ULONG WINAPI IDirectMusicPortImpl_Release (LPDIRECTMUSICPORT iface) {
- IDirectMusicPortImpl *This = (IDirectMusicPortImpl *)iface;
- ULONG refCount = InterlockedDecrement(&This->ref);
+static ULONG WINAPI IDirectMusicDownloadedInstrumentImpl_AddRef(LPDIRECTMUSICDOWNLOADEDINSTRUMENT iface)
+{
+ IDirectMusicDownloadedInstrumentImpl *This = impl_from_IDirectMusicDownloadedInstrument(iface);
+ ULONG ref = InterlockedIncrement(&This->ref);
- TRACE("(%p)->(ref before=%u)\n", This, refCount + 1);
+ TRACE("(%p)->(): new ref = %u\n", iface, ref);
- if (!refCount) {
- HeapFree(GetProcessHeap(), 0, This);
- }
+ DMUSIC_LockModule();
+
+ return ref;
+}
- DMUSIC_UnlockModule();
+static ULONG WINAPI IDirectMusicDownloadedInstrumentImpl_Release(LPDIRECTMUSICDOWNLOADEDINSTRUMENT iface)
+{
+ IDirectMusicDownloadedInstrumentImpl *This = impl_from_IDirectMusicDownloadedInstrument(iface);
+ ULONG ref = InterlockedDecrement(&This->ref);
- return refCount;
+ TRACE("(%p)->(): new ref = %u\n", iface, ref);
+
+ if (!ref)
+ {
+ HeapFree(GetProcessHeap(), 0, This->data);
+ HeapFree(GetProcessHeap(), 0, This);
+ }
+
+ DMUSIC_UnlockModule();
+
+ return ref;
}
-/* IDirectMusicPortImpl IDirectMusicPort part: */
-static HRESULT WINAPI IDirectMusicPortImpl_PlayBuffer (LPDIRECTMUSICPORT iface, LPDIRECTMUSICBUFFER pBuffer) {
- IDirectMusicPortImpl *This = (IDirectMusicPortImpl *)iface;
- FIXME("(%p, %p): stub\n", This, pBuffer);
- return S_OK;
+static const IDirectMusicDownloadedInstrumentVtbl DirectMusicDownloadedInstrument_Vtbl = {
+ IDirectMusicDownloadedInstrumentImpl_QueryInterface,
+ IDirectMusicDownloadedInstrumentImpl_AddRef,
+ IDirectMusicDownloadedInstrumentImpl_Release
+};
+
+static inline IDirectMusicDownloadedInstrumentImpl* unsafe_impl_from_IDirectMusicDownloadedInstrument(IDirectMusicDownloadedInstrument *iface)
+{
+ if (!iface)
+ return NULL;
+ assert(iface->lpVtbl == &DirectMusicDownloadedInstrument_Vtbl);
+
+ return impl_from_IDirectMusicDownloadedInstrument(iface);
}
-static HRESULT WINAPI IDirectMusicPortImpl_SetReadNotificationHandle (LPDIRECTMUSICPORT iface, HANDLE hEvent) {
- IDirectMusicPortImpl *This = (IDirectMusicPortImpl *)iface;
- FIXME("(%p, %p): stub\n", This, hEvent);
- return S_OK;
+HRESULT DMUSIC_CreateDirectMusicDownloadedInstrumentImpl(IDirectMusicDownloadedInstrument **instrument)
+{
+ IDirectMusicDownloadedInstrumentImpl *object;
+
+ object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
+ if (!object)
+ {
+ *instrument = NULL;
+ return E_OUTOFMEMORY;
+ }
+
+ object->IDirectMusicDownloadedInstrument_iface.lpVtbl = &DirectMusicDownloadedInstrument_Vtbl;
+ object->ref = 1;
+
+ *instrument = &object->IDirectMusicDownloadedInstrument_iface;
+
+ return S_OK;
}
-static HRESULT WINAPI IDirectMusicPortImpl_Read (LPDIRECTMUSICPORT iface, LPDIRECTMUSICBUFFER pBuffer) {
- IDirectMusicPortImpl *This = (IDirectMusicPortImpl *)iface;
- FIXME("(%p, %p): stub\n", This, pBuffer);
- return S_OK;
+/* SynthPortImpl IDirectMusicPort IUnknown part follows: */
+static HRESULT WINAPI SynthPortImpl_IDirectMusicPort_QueryInterface(LPDIRECTMUSICPORT iface, REFIID riid, LPVOID *ret_iface)
+{
+ SynthPortImpl *This = impl_from_SynthPortImpl_IDirectMusicPort(iface);
+
+ TRACE("(%p/%p)->(%s, %p)\n", iface, This, debugstr_dmguid(riid), ret_iface);
+
+ if (IsEqualIID (riid, &IID_IUnknown) ||
+ IsEqualGUID(riid, &IID_IDirectMusicPort) ||
+ IsEqualGUID(riid, &IID_IDirectMusicPort8)) {
+ *ret_iface = &This->IDirectMusicPort_iface;
+ IDirectMusicPort_AddRef((LPDIRECTMUSICPORT)*ret_iface);
+ return S_OK;
+ } else if (IsEqualGUID(riid, &IID_IDirectMusicPortDownload) ||
+ IsEqualGUID(riid, &IID_IDirectMusicPortDownload8)) {
+ *ret_iface = &This->IDirectMusicPortDownload_iface;
+ IDirectMusicPortDownload_AddRef((LPDIRECTMUSICPORTDOWNLOAD)*ret_iface);
+ return S_OK;
+ } else if (IsEqualGUID(riid, &IID_IDirectMusicThru) ||
+ IsEqualGUID(riid, &IID_IDirectMusicThru8)) {
+ *ret_iface = &This->IDirectMusicThru_iface;
+ IDirectMusicThru_AddRef((LPDIRECTMUSICTHRU)*ret_iface);
+ return S_OK;
+ }
+
+ WARN("(%p, %s, %p): not found\n", This, debugstr_dmguid(riid), ret_iface);
+
+ return E_NOINTERFACE;
}
-static HRESULT WINAPI IDirectMusicPortImpl_DownloadInstrument (LPDIRECTMUSICPORT iface, IDirectMusicInstrument* pInstrument, IDirectMusicDownloadedInstrument** ppDownloadedInstrument, DMUS_NOTERANGE* pNoteRanges, DWORD dwNumNoteRanges) {
- IDirectMusicPortImpl *This = (IDirectMusicPortImpl *)iface;
+static ULONG WINAPI SynthPortImpl_IDirectMusicPort_AddRef(LPDIRECTMUSICPORT iface)
+{
+ SynthPortImpl *This = impl_from_SynthPortImpl_IDirectMusicPort(iface);
+ ULONG ref = InterlockedIncrement(&This->ref);
- FIXME("(%p, %p, %p, %p, %d): stub\n", This, pInstrument, ppDownloadedInstrument, pNoteRanges, dwNumNoteRanges);
+ TRACE("(%p)->(): new ref = %u\n", This, ref);
- if (!pInstrument || !ppDownloadedInstrument || (dwNumNoteRanges && !pNoteRanges))
- return E_POINTER;
+ DMUSIC_LockModule();
- return DMUSIC_CreateDirectMusicDownloadedInstrumentImpl(&IID_IDirectMusicDownloadedInstrument, (LPVOID*)ppDownloadedInstrument, NULL);
+ return ref;
}
-static HRESULT WINAPI IDirectMusicPortImpl_UnloadInstrument (LPDIRECTMUSICPORT iface, IDirectMusicDownloadedInstrument *pDownloadedInstrument) {
- IDirectMusicPortImpl *This = (IDirectMusicPortImpl *)iface;
- FIXME("(%p, %p): stub\n", This, pDownloadedInstrument);
- return S_OK;
+static ULONG WINAPI SynthPortImpl_IDirectMusicPort_Release(LPDIRECTMUSICPORT iface)
+{
+ SynthPortImpl *This = impl_from_SynthPortImpl_IDirectMusicPort(iface);
+ ULONG ref = InterlockedDecrement(&This->ref);
+
+ TRACE("(%p)->(): new ref = %u\n", This, ref);
+
+ if (!ref)
+ {
+ IDirectMusicSynth_Activate(This->synth, FALSE);
+ IDirectMusicSynth_Close(This->synth);
+ IDirectMusicSynth_Release(This->synth);
+ IDirectMusicSynthSink_Release(This->synth_sink);
+ IReferenceClock_Release(This->pLatencyClock);
+ HeapFree(GetProcessHeap(), 0, This);
+ }
+
+ DMUSIC_UnlockModule();
+
+ return ref;
}
-static HRESULT WINAPI IDirectMusicPortImpl_GetLatencyClock (LPDIRECTMUSICPORT iface, IReferenceClock** ppClock) {
- IDirectMusicPortImpl *This = (IDirectMusicPortImpl *)iface;
- TRACE("(%p, %p)\n", This, ppClock);
- *ppClock = This->pLatencyClock;
- IReferenceClock_AddRef (*ppClock);
- return S_OK;
+/* SynthPortImpl IDirectMusicPort interface follows: */
+static HRESULT WINAPI SynthPortImpl_IDirectMusicPort_PlayBuffer(LPDIRECTMUSICPORT iface, LPDIRECTMUSICBUFFER buffer)
+{
+ SynthPortImpl *This = impl_from_SynthPortImpl_IDirectMusicPort(iface);
+ HRESULT hr;
+ REFERENCE_TIME time;
+ LPBYTE data;
+ DWORD size;
+
+ TRACE("(%p/%p)->(%p)\n", iface, This, buffer);
+
+ if (!buffer)
+ return E_POINTER;
+
+ hr = IDirectMusicBuffer_GetStartTime(buffer, &time);
+
+ if (SUCCEEDED(hr))
+ hr = IDirectMusicBuffer_GetRawBufferPtr(buffer, &data);
+
+ if (SUCCEEDED(hr))
+ hr = IDirectMusicBuffer_GetUsedBytes(buffer, &size);
+
+ if (SUCCEEDED(hr))
+ hr = IDirectMusicSynth_PlayBuffer(This->synth, time, data, size);
+
+ return hr;
}
-static HRESULT WINAPI IDirectMusicPortImpl_GetRunningStats (LPDIRECTMUSICPORT iface, LPDMUS_SYNTHSTATS pStats) {
- IDirectMusicPortImpl *This = (IDirectMusicPortImpl *)iface;
- FIXME("(%p, %p): stub\n", This, pStats);
- return S_OK;
+static HRESULT WINAPI SynthPortImpl_IDirectMusicPort_SetReadNotificationHandle(LPDIRECTMUSICPORT iface, HANDLE event)
+{
+ SynthPortImpl *This = impl_from_SynthPortImpl_IDirectMusicPort(iface);
+
+ FIXME("(%p/%p)->(%p): stub\n", iface, This, event);
+
+ return S_OK;
}
-static HRESULT WINAPI IDirectMusicPortImpl_Compact (LPDIRECTMUSICPORT iface) {
- IDirectMusicPortImpl *This = (IDirectMusicPortImpl *)iface;
- FIXME("(%p): stub\n", This);
- return S_OK;
+static HRESULT WINAPI SynthPortImpl_IDirectMusicPort_Read(LPDIRECTMUSICPORT iface, LPDIRECTMUSICBUFFER buffer)
+{
+ SynthPortImpl *This = impl_from_SynthPortImpl_IDirectMusicPort(iface);
+
+ FIXME("(%p/%p)->(%p): stub\n", iface, This, buffer);
+
+ return S_OK;
}
-static HRESULT WINAPI IDirectMusicPortImpl_GetCaps (LPDIRECTMUSICPORT iface, LPDMUS_PORTCAPS pPortCaps) {
- IDirectMusicPortImpl *This = (IDirectMusicPortImpl *)iface;
- TRACE("(%p, %p)\n", This, pPortCaps);
- *pPortCaps = This->caps;
- return S_OK;
+static HRESULT WINAPI SynthPortImpl_IDirectMusicPort_DownloadInstrument(LPDIRECTMUSICPORT iface, IDirectMusicInstrument* instrument, IDirectMusicDownloadedInstrument** downloaded_instrument, DMUS_NOTERANGE* note_ranges, DWORD num_note_ranges)
+{
+ SynthPortImpl *This = impl_from_SynthPortImpl_IDirectMusicPort(iface);
+ IDirectMusicInstrumentImpl *instrument_object;
+ HRESULT ret;
+ BOOL free;
+ HANDLE download;
+ DMUS_DOWNLOADINFO *info;
+ DMUS_OFFSETTABLE *offset_table;
+ DMUS_INSTRUMENT *instrument_info;
+ BYTE *data;
+ ULONG offset;
+ ULONG nb_regions;
+ ULONG size;
+ ULONG i;
+
+ TRACE("(%p/%p)->(%p, %p, %p, %d)\n", iface, This, instrument, downloaded_instrument, note_ranges, num_note_ranges);
+
+ if (!instrument || !downloaded_instrument || (num_note_ranges && !note_ranges))
+ return E_POINTER;
+
+ instrument_object = impl_from_IDirectMusicInstrument(instrument);
+
+ nb_regions = instrument_object->header.cRegions;
+ size = sizeof(DMUS_DOWNLOADINFO) + sizeof(ULONG) * (1 + nb_regions) + sizeof(DMUS_INSTRUMENT) + sizeof(DMUS_REGION) * nb_regions;
+
+ data = (BYTE*)HeapAlloc(GetProcessHeap(), 0, size);
+ if (!data)
+ return E_OUTOFMEMORY;
+
+ info = (DMUS_DOWNLOADINFO*)data;
+ offset_table = (DMUS_OFFSETTABLE*)(data + sizeof(DMUS_DOWNLOADINFO));
+ offset = sizeof(DMUS_DOWNLOADINFO) + sizeof(ULONG) * (1 + nb_regions);
+
+ info->dwDLType = DMUS_DOWNLOADINFO_INSTRUMENT2;
+ info->dwDLId = 0;
+ info->dwNumOffsetTableEntries = 1 + instrument_object->header.cRegions;
+ info->cbSize = size;
+
+ offset_table->ulOffsetTable[0] = offset;
+ instrument_info = (DMUS_INSTRUMENT*)(data + offset);
+ offset += sizeof(DMUS_INSTRUMENT);
+ instrument_info->ulPatch = MIDILOCALE2Patch(&instrument_object->header.Locale);
+ instrument_info->ulFirstRegionIdx = 1;
+ instrument_info->ulGlobalArtIdx = 0; /* FIXME */
+ instrument_info->ulFirstExtCkIdx = 0; /* FIXME */
+ instrument_info->ulCopyrightIdx = 0; /* FIXME */
+ instrument_info->ulFlags = 0; /* FIXME */
+
+ for (i = 0; i < nb_regions; i++)
+ {
+ DMUS_REGION *region = (DMUS_REGION*)(data + offset);
+
+ offset_table->ulOffsetTable[1 + i] = offset;
+ offset += sizeof(DMUS_REGION);
+ region->RangeKey = instrument_object->regions[i].header.RangeKey;
+ region->RangeVelocity = instrument_object->regions[i].header.RangeVelocity;
+ region->fusOptions = instrument_object->regions[i].header.fusOptions;
+ region->usKeyGroup = instrument_object->regions[i].header.usKeyGroup;
+ region->ulRegionArtIdx = 0; /* FIXME */
+ region->ulNextRegionIdx = i != (nb_regions - 1) ? (i + 2) : 0;
+ region->ulFirstExtCkIdx = 0; /* FIXME */
+ region->WaveLink = instrument_object->regions[i].wave_link;
+ region->WSMP = instrument_object->regions[i].wave_sample;
+ region->WLOOP[0] = instrument_object->regions[i].wave_loop;
+ }
+
+ ret = IDirectMusicSynth8_Download(This->synth, &download, (VOID*)data, &free);
+
+ if (SUCCEEDED(ret))
+ ret = DMUSIC_CreateDirectMusicDownloadedInstrumentImpl(downloaded_instrument);
+
+ if (SUCCEEDED(ret))
+ {
+ IDirectMusicDownloadedInstrumentImpl *downloaded_object = impl_from_IDirectMusicDownloadedInstrument(*downloaded_instrument);
+
+ downloaded_object->data = data;
+ downloaded_object->downloaded = TRUE;
+ }
+
+ *downloaded_instrument = NULL;
+ HeapFree(GetProcessHeap(), 0, data);
+
+ return E_FAIL;
}
-static HRESULT WINAPI IDirectMusicPortImpl_DeviceIoControl (LPDIRECTMUSICPORT iface, DWORD dwIoControlCode, LPVOID lpInBuffer, DWORD nInBufferSize, LPVOID lpOutBuffer, DWORD nOutBufferSize, LPDWORD lpBytesReturned, LPOVERLAPPED lpOverlapped) {
- IDirectMusicPortImpl *This = (IDirectMusicPortImpl *)iface;
- FIXME("(%p, %d, %p, %d, %p, %d, %p, %p): stub\n", This, dwIoControlCode, lpInBuffer, nInBufferSize, lpOutBuffer, nOutBufferSize, lpBytesReturned, lpOverlapped);
- return S_OK;
+static HRESULT WINAPI SynthPortImpl_IDirectMusicPort_UnloadInstrument(LPDIRECTMUSICPORT iface, IDirectMusicDownloadedInstrument *downloaded_instrument)
+{
+ SynthPortImpl *This = impl_from_SynthPortImpl_IDirectMusicPort(iface);
+ IDirectMusicDownloadedInstrumentImpl *downloaded_object = unsafe_impl_from_IDirectMusicDownloadedInstrument(downloaded_instrument);
+
+ TRACE("(%p/%p)->(%p)\n", iface, This, downloaded_instrument);
+
+ if (!downloaded_instrument)
+ return E_POINTER;
+
+ if (!downloaded_object->downloaded)
+ return DMUS_E_NOT_DOWNLOADED_TO_PORT;
+
+ HeapFree(GetProcessHeap(), 0, downloaded_object->data);
+ downloaded_object->data = NULL;
+ downloaded_object->downloaded = FALSE;
+
+ return S_OK;
}
-static HRESULT WINAPI IDirectMusicPortImpl_SetNumChannelGroups (LPDIRECTMUSICPORT iface, DWORD dwChannelGroups) {
- IDirectMusicPortImpl *This = (IDirectMusicPortImpl *)iface;
- FIXME("(%p, %d): semi-stub\n", This, dwChannelGroups);
- This->nrofgroups = dwChannelGroups;
- return S_OK;
+static HRESULT WINAPI SynthPortImpl_IDirectMusicPort_GetLatencyClock(LPDIRECTMUSICPORT iface, IReferenceClock** clock)
+{
+ SynthPortImpl *This = impl_from_SynthPortImpl_IDirectMusicPort(iface);
+
+ TRACE("(%p/%p)->(%p)\n", iface, This, clock);
+
+ *clock = This->pLatencyClock;
+ IReferenceClock_AddRef(*clock);
+
+ return S_OK;
}
-static HRESULT WINAPI IDirectMusicPortImpl_GetNumChannelGroups (LPDIRECTMUSICPORT iface, LPDWORD pdwChannelGroups) {
- IDirectMusicPortImpl *This = (IDirectMusicPortImpl *)iface;
- TRACE("(%p, %p)\n", This, pdwChannelGroups);
- *pdwChannelGroups = This->nrofgroups;
- return S_OK;
+static HRESULT WINAPI SynthPortImpl_IDirectMusicPort_GetRunningStats(LPDIRECTMUSICPORT iface, LPDMUS_SYNTHSTATS stats)
+{
+ SynthPortImpl *This = impl_from_SynthPortImpl_IDirectMusicPort(iface);
+
+ FIXME("(%p/%p)->(%p): stub\n", iface, This, stats);
+
+ return S_OK;
}
-HRESULT WINAPI IDirectMusicPortImpl_Activate (LPDIRECTMUSICPORT iface, BOOL fActive) {
- IDirectMusicPortImpl *This = (IDirectMusicPortImpl *)iface;
- TRACE("(%p, %d)\n", This, fActive);
- This->fActive = fActive;
- return S_OK;
+static HRESULT WINAPI SynthPortImpl_IDirectMusicPort_Compact(LPDIRECTMUSICPORT iface)
+{
+ SynthPortImpl *This = impl_from_SynthPortImpl_IDirectMusicPort(iface);
+
+ FIXME("(%p/%p)->(): stub\n", iface, This);
+
+ return S_OK;
}
-static HRESULT WINAPI IDirectMusicPortImpl_SetChannelPriority (LPDIRECTMUSICPORT iface, DWORD dwChannelGroup, DWORD dwChannel, DWORD dwPriority) {
- IDirectMusicPortImpl *This = (IDirectMusicPortImpl *)iface;
- FIXME("(%p, %d, %d, %d): semi-stub\n", This, dwChannelGroup, dwChannel, dwPriority);
- if (dwChannel > 16) {
- WARN("isn't there supposed to be 16 channels (no. %d requested)?! (faking as it is ok)\n", dwChannel);
- /*return E_INVALIDARG;*/
- }
- return S_OK;
+static HRESULT WINAPI SynthPortImpl_IDirectMusicPort_GetCaps(LPDIRECTMUSICPORT iface, LPDMUS_PORTCAPS port_caps)
+{
+ SynthPortImpl *This = impl_from_SynthPortImpl_IDirectMusicPort(iface);
+
+ TRACE("(%p/%p)->(%p)\n", iface, This, port_caps);
+
+ *port_caps = This->caps;
+
+ return S_OK;
}
-static HRESULT WINAPI IDirectMusicPortImpl_GetChannelPriority (LPDIRECTMUSICPORT iface, DWORD dwChannelGroup, DWORD dwChannel, LPDWORD pdwPriority) {
- IDirectMusicPortImpl *This = (IDirectMusicPortImpl *)iface;
- TRACE("(%p, %d, %d, %p)\n", This, dwChannelGroup, dwChannel, pdwPriority);
- *pdwPriority = This->group[dwChannelGroup-1].channel[dwChannel].priority;
- return S_OK;
+static HRESULT WINAPI SynthPortImpl_IDirectMusicPort_DeviceIoControl(LPDIRECTMUSICPORT iface, DWORD io_control_code, LPVOID in_buffer, DWORD in_buffer_size,
+ LPVOID out_buffer, DWORD out_buffer_size, LPDWORD bytes_returned, LPOVERLAPPED overlapped)
+{
+ SynthPortImpl *This = impl_from_SynthPortImpl_IDirectMusicPort(iface);
+
+ FIXME("(%p/%p)->(%d, %p, %d, %p, %d, %p, %p): stub\n", iface, This, io_control_code, in_buffer, in_buffer_size, out_buffer, out_buffer_size, bytes_returned, overlapped);
+
+ return S_OK;
}
-static HRESULT WINAPI IDirectMusicPortImpl_SetDirectSound (LPDIRECTMUSICPORT iface, LPDIRECTSOUND pDirectSound, LPDIRECTSOUNDBUFFER pDirectSoundBuffer) {
- IDirectMusicPortImpl *This = (IDirectMusicPortImpl *)iface;
- FIXME("(%p, %p, %p): stub\n", This, pDirectSound, pDirectSoundBuffer);
- return S_OK;
+static HRESULT WINAPI SynthPortImpl_IDirectMusicPort_SetNumChannelGroups(LPDIRECTMUSICPORT iface, DWORD channel_groups)
+{
+ SynthPortImpl *This = impl_from_SynthPortImpl_IDirectMusicPort(iface);
+
+ FIXME("(%p/%p)->(%d): semi-stub\n", iface, This, channel_groups);
+
+ This->nrofgroups = channel_groups;
+
+ return S_OK;
+}
+
+static HRESULT WINAPI SynthPortImpl_IDirectMusicPort_GetNumChannelGroups(LPDIRECTMUSICPORT iface, LPDWORD channel_groups)
+{
+ SynthPortImpl *This = impl_from_SynthPortImpl_IDirectMusicPort(iface);
+
+ TRACE("(%p/%p)->(%p)\n", iface, This, channel_groups);
+
+ *channel_groups = This->nrofgroups;
+
+ return S_OK;
+}
+
+static HRESULT WINAPI SynthPortImpl_IDirectMusicPort_Activate(LPDIRECTMUSICPORT iface, BOOL active)
+{
+ SynthPortImpl *This = impl_from_SynthPortImpl_IDirectMusicPort(iface);
+
+ TRACE("(%p/%p)->(%d)\n", iface, This, active);
+
+ This->fActive = active;
+
+ return S_OK;
+}
+
+static HRESULT WINAPI SynthPortImpl_IDirectMusicPort_SetChannelPriority(LPDIRECTMUSICPORT iface, DWORD channel_group, DWORD channel, DWORD priority)
+{
+ SynthPortImpl *This = impl_from_SynthPortImpl_IDirectMusicPort(iface);
+
+ FIXME("(%p/%p)->(%d, %d, %d): semi-stub\n", iface, This, channel_group, channel, priority);
+
+ if (channel > 16)
+ {
+ WARN("isn't there supposed to be 16 channels (no. %d requested)?! (faking as it is ok)\n", channel);
+ /*return E_INVALIDARG;*/
+ }
+
+ return S_OK;
+}
+
+static HRESULT WINAPI SynthPortImpl_IDirectMusicPort_GetChannelPriority(LPDIRECTMUSICPORT iface, DWORD channel_group, DWORD channel, LPDWORD priority)
+{
+ SynthPortImpl *This = impl_from_SynthPortImpl_IDirectMusicPort(iface);
+
+ TRACE("(%p/%p)->(%u, %u, %p)\n", iface, This, channel_group, channel, priority);
+
+ *priority = This->group[channel_group - 1].channel[channel].priority;
+
+ return S_OK;
+}
+
+static HRESULT WINAPI SynthPortImpl_IDirectMusicPort_SetDirectSound(LPDIRECTMUSICPORT iface, LPDIRECTSOUND direct_sound, LPDIRECTSOUNDBUFFER direct_sound_buffer)
+{
+ SynthPortImpl *This = impl_from_SynthPortImpl_IDirectMusicPort(iface);
+
+ FIXME("(%p/%p)->(%p, %p): stub\n", iface, This, direct_sound, direct_sound_buffer);
+
+ return S_OK;
}
-static HRESULT WINAPI IDirectMusicPortImpl_GetFormat (LPDIRECTMUSICPORT iface, LPWAVEFORMATEX pWaveFormatEx, LPDWORD pdwWaveFormatExSize, LPDWORD pdwBufferSize) {
- IDirectMusicPortImpl *This = (IDirectMusicPortImpl *)iface;
+static HRESULT WINAPI SynthPortImpl_IDirectMusicPort_GetFormat(LPDIRECTMUSICPORT iface, LPWAVEFORMATEX pWaveFormatEx, LPDWORD pdwWaveFormatExSize, LPDWORD pdwBufferSize)
+{
+ SynthPortImpl *This = impl_from_SynthPortImpl_IDirectMusicPort(iface);
WAVEFORMATEX format;
FIXME("(%p, %p, %p, %p): stub\n", This, pWaveFormatEx, pdwWaveFormatExSize, pdwBufferSize);
return S_OK;
}
-static const IDirectMusicPortVtbl DirectMusicPort_Vtbl = {
- IDirectMusicPortImpl_QueryInterface,
- IDirectMusicPortImpl_AddRef,
- IDirectMusicPortImpl_Release,
- IDirectMusicPortImpl_PlayBuffer,
- IDirectMusicPortImpl_SetReadNotificationHandle,
- IDirectMusicPortImpl_Read,
- IDirectMusicPortImpl_DownloadInstrument,
- IDirectMusicPortImpl_UnloadInstrument,
- IDirectMusicPortImpl_GetLatencyClock,
- IDirectMusicPortImpl_GetRunningStats,
- IDirectMusicPortImpl_Compact,
- IDirectMusicPortImpl_GetCaps,
- IDirectMusicPortImpl_DeviceIoControl,
- IDirectMusicPortImpl_SetNumChannelGroups,
- IDirectMusicPortImpl_GetNumChannelGroups,
- IDirectMusicPortImpl_Activate,
- IDirectMusicPortImpl_SetChannelPriority,
- IDirectMusicPortImpl_GetChannelPriority,
- IDirectMusicPortImpl_SetDirectSound,
- IDirectMusicPortImpl_GetFormat
+static const IDirectMusicPortVtbl SynthPortImpl_DirectMusicPort_Vtbl = {
+ /**** IDirectMusicPort IUnknown part methods ***/
+ SynthPortImpl_IDirectMusicPort_QueryInterface,
+ SynthPortImpl_IDirectMusicPort_AddRef,
+ SynthPortImpl_IDirectMusicPort_Release,
+ /**** IDirectMusicPort methods ***/
+ SynthPortImpl_IDirectMusicPort_PlayBuffer,
+ SynthPortImpl_IDirectMusicPort_SetReadNotificationHandle,
+ SynthPortImpl_IDirectMusicPort_Read,
+ SynthPortImpl_IDirectMusicPort_DownloadInstrument,
+ SynthPortImpl_IDirectMusicPort_UnloadInstrument,
+ SynthPortImpl_IDirectMusicPort_GetLatencyClock,
+ SynthPortImpl_IDirectMusicPort_GetRunningStats,
+ SynthPortImpl_IDirectMusicPort_Compact,
+ SynthPortImpl_IDirectMusicPort_GetCaps,
+ SynthPortImpl_IDirectMusicPort_DeviceIoControl,
+ SynthPortImpl_IDirectMusicPort_SetNumChannelGroups,
+ SynthPortImpl_IDirectMusicPort_GetNumChannelGroups,
+ SynthPortImpl_IDirectMusicPort_Activate,
+ SynthPortImpl_IDirectMusicPort_SetChannelPriority,
+ SynthPortImpl_IDirectMusicPort_GetChannelPriority,
+ SynthPortImpl_IDirectMusicPort_SetDirectSound,
+ SynthPortImpl_IDirectMusicPort_GetFormat
};
-/* IDirectMusicPortDownload IUnknown parts follow: */
-static HRESULT WINAPI IDirectMusicPortDownloadImpl_QueryInterface (LPDIRECTMUSICPORTDOWNLOAD iface, REFIID riid, LPVOID *ppobj) {
- ICOM_THIS_MULTI(IDirectMusicPortImpl, lpDownloadVtbl, iface);
- TRACE("(%p/%p)->(%s, %p)\n", This, iface, debugstr_dmguid(riid), ppobj);
- return IUnknown_QueryInterface((IUnknown *)&(This->lpVtbl), riid, ppobj);
+/* SynthPortImpl IDirectMusicPortDownload IUnknown part follows: */
+static HRESULT WINAPI SynthPortImpl_IDirectMusicPortDownload_QueryInterface(LPDIRECTMUSICPORTDOWNLOAD iface, REFIID riid, LPVOID *ret_iface)
+{
+ SynthPortImpl *This = impl_from_SynthPortImpl_IDirectMusicPortDownload(iface);
+
+ TRACE("(%p/%p)->(%s, %p)\n", iface, This, debugstr_dmguid(riid), ret_iface);
+
+ return IDirectMusicPort_QueryInterface(&This->IDirectMusicPort_iface, riid, ret_iface);
}
-static ULONG WINAPI IDirectMusicPortDownloadImpl_AddRef (LPDIRECTMUSICPORTDOWNLOAD iface) {
- ICOM_THIS_MULTI(IDirectMusicPortImpl, lpDownloadVtbl, iface);
- TRACE("(%p/%p)->()\n", This, iface);
- return IUnknown_AddRef((IUnknown *)&(This->lpVtbl));
+static ULONG WINAPI SynthPortImpl_IDirectMusicPortDownload_AddRef (LPDIRECTMUSICPORTDOWNLOAD iface)
+{
+ SynthPortImpl *This = impl_from_SynthPortImpl_IDirectMusicPortDownload(iface);
+
+ TRACE("(%p/%p)->()\n", iface, This);
+
+ return IDirectMusicPort_AddRef(&This->IDirectMusicPort_iface);
}
-static ULONG WINAPI IDirectMusicPortDownloadImpl_Release (LPDIRECTMUSICPORTDOWNLOAD iface) {
- ICOM_THIS_MULTI(IDirectMusicPortImpl, lpDownloadVtbl, iface);
- TRACE("(%p/%p)->()\n", This, iface);
- return IUnknown_Release((IUnknown *)&(This->lpVtbl));
+static ULONG WINAPI SynthPortImpl_IDirectMusicPortDownload_Release(LPDIRECTMUSICPORTDOWNLOAD iface)
+{
+ SynthPortImpl *This = impl_from_SynthPortImpl_IDirectMusicPortDownload(iface);
+
+ TRACE("(%p/%p)->()\n", iface, This);
+
+ return IDirectMusicPort_Release(&This->IDirectMusicPort_iface);
}
-/* IDirectMusicPortDownload Interface follow: */
-static HRESULT WINAPI IDirectMusicPortDownloadImpl_GetBuffer (LPDIRECTMUSICPORTDOWNLOAD iface, DWORD dwDLId, IDirectMusicDownload** ppIDMDownload) {
- ICOM_THIS_MULTI(IDirectMusicPortImpl, lpDownloadVtbl, iface);
+/* SynthPortImpl IDirectMusicPortDownload Interface follows: */
+static HRESULT WINAPI SynthPortImpl_IDirectMusicPortDownload_GetBuffer(LPDIRECTMUSICPORTDOWNLOAD iface, DWORD DLId, IDirectMusicDownload** IDMDownload)
+{
+ SynthPortImpl *This = impl_from_SynthPortImpl_IDirectMusicPortDownload(iface);
- FIXME("(%p/%p)->(%d, %p): stub\n", This, iface, dwDLId, ppIDMDownload);
+ FIXME("(%p/%p)->(%u, %p): stub\n", iface, This, DLId, IDMDownload);
- if (!ppIDMDownload)
- return E_POINTER;
+ if (!IDMDownload)
+ return E_POINTER;
- return DMUSIC_CreateDirectMusicDownloadImpl(&IID_IDirectMusicDownload, (LPVOID*)ppIDMDownload, NULL);
+ return DMUSIC_CreateDirectMusicDownloadImpl(&IID_IDirectMusicDownload, (LPVOID*)IDMDownload, NULL);
}
-static HRESULT WINAPI IDirectMusicPortDownloadImpl_AllocateBuffer (LPDIRECTMUSICPORTDOWNLOAD iface, DWORD dwSize, IDirectMusicDownload** ppIDMDownload) {
- ICOM_THIS_MULTI(IDirectMusicPortImpl, lpDownloadVtbl, iface);
- FIXME("(%p/%p)->(%d, %p): stub\n", This, iface, dwSize, ppIDMDownload);
- return S_OK;
+static HRESULT WINAPI SynthPortImpl_IDirectMusicPortDownload_AllocateBuffer(LPDIRECTMUSICPORTDOWNLOAD iface, DWORD size, IDirectMusicDownload** IDMDownload)
+{
+ SynthPortImpl *This = impl_from_SynthPortImpl_IDirectMusicPortDownload(iface);
+
+ FIXME("(%p/%p)->(%u, %p): stub\n", iface, This, size, IDMDownload);
+
+ return S_OK;
}
-static HRESULT WINAPI IDirectMusicPortDownloadImpl_GetDLId (LPDIRECTMUSICPORTDOWNLOAD iface, DWORD* pdwStartDLId, DWORD dwCount) {
- ICOM_THIS_MULTI(IDirectMusicPortImpl, lpDownloadVtbl, iface);
- FIXME("(%p/%p)->(%p, %d): stub\n", This, iface, pdwStartDLId, dwCount);
- return S_OK;
+static HRESULT WINAPI SynthPortImpl_IDirectMusicPortDownload_GetDLId(LPDIRECTMUSICPORTDOWNLOAD iface, DWORD* start_DLId, DWORD count)
+{
+ SynthPortImpl *This = impl_from_SynthPortImpl_IDirectMusicPortDownload(iface);
+
+ FIXME("(%p/%p)->(%p, %u): stub\n", iface, This, start_DLId, count);
+
+ return S_OK;
}
-static HRESULT WINAPI IDirectMusicPortDownloadImpl_GetAppend (LPDIRECTMUSICPORTDOWNLOAD iface, DWORD* pdwAppend) {
- IDirectMusicPortImpl *This = (IDirectMusicPortImpl *)iface;
- FIXME("(%p/%p)->(%p): stub\n", This, iface, pdwAppend);
- return S_OK;
+static HRESULT WINAPI SynthPortImpl_IDirectMusicPortDownload_GetAppend (LPDIRECTMUSICPORTDOWNLOAD iface, DWORD* append)
+{
+ SynthPortImpl *This = impl_from_SynthPortImpl_IDirectMusicPortDownload(iface);
+
+ FIXME("(%p/%p)->(%p): stub\n", iface, This, append);
+
+ return S_OK;
}
-static HRESULT WINAPI IDirectMusicPortDownloadImpl_Download (LPDIRECTMUSICPORTDOWNLOAD iface, IDirectMusicDownload* pIDMDownload) {
- IDirectMusicPortImpl *This = (IDirectMusicPortImpl *)iface;
- FIXME("(%p/%p)->(%p): stub\n", This, iface, pIDMDownload);
- return S_OK;
+static HRESULT WINAPI SynthPortImpl_IDirectMusicPortDownload_Download(LPDIRECTMUSICPORTDOWNLOAD iface, IDirectMusicDownload* IDMDownload)
+{
+ SynthPortImpl *This = impl_from_SynthPortImpl_IDirectMusicPortDownload(iface);
+
+ FIXME("(%p/%p)->(%p): stub\n", iface, This, IDMDownload);
+
+ return S_OK;
}
-static HRESULT WINAPI IDirectMusicPortDownloadImpl_Unload (LPDIRECTMUSICPORTDOWNLOAD iface, IDirectMusicDownload* pIDMDownload) {
- IDirectMusicPortImpl *This = (IDirectMusicPortImpl *)iface;
- FIXME("(%p/%p)->(%p): stub\n", This, iface, pIDMDownload);
- return S_OK;
+static HRESULT WINAPI SynthPortImpl_IDirectMusicPortDownload_Unload(LPDIRECTMUSICPORTDOWNLOAD iface, IDirectMusicDownload* IDMDownload)
+{
+ SynthPortImpl *This = impl_from_SynthPortImpl_IDirectMusicPortDownload(iface);
+
+ FIXME("(%p/%p)->(%p): stub\n", iface, This, IDMDownload);
+
+ return S_OK;
}
-static const IDirectMusicPortDownloadVtbl DirectMusicPortDownload_Vtbl = {
- IDirectMusicPortDownloadImpl_QueryInterface,
- IDirectMusicPortDownloadImpl_AddRef,
- IDirectMusicPortDownloadImpl_Release,
- IDirectMusicPortDownloadImpl_GetBuffer,
- IDirectMusicPortDownloadImpl_AllocateBuffer,
- IDirectMusicPortDownloadImpl_GetDLId,
- IDirectMusicPortDownloadImpl_GetAppend,
- IDirectMusicPortDownloadImpl_Download,
- IDirectMusicPortDownloadImpl_Unload
+static const IDirectMusicPortDownloadVtbl SynthPortImpl_DirectMusicPortDownload_Vtbl = {
+ /*** IDirectMusicPortDownload IUnknown part methods ***/
+ SynthPortImpl_IDirectMusicPortDownload_QueryInterface,
+ SynthPortImpl_IDirectMusicPortDownload_AddRef,
+ SynthPortImpl_IDirectMusicPortDownload_Release,
+ /*** IDirectMusicPortDownload methods ***/
+ SynthPortImpl_IDirectMusicPortDownload_GetBuffer,
+ SynthPortImpl_IDirectMusicPortDownload_AllocateBuffer,
+ SynthPortImpl_IDirectMusicPortDownload_GetDLId,
+ SynthPortImpl_IDirectMusicPortDownload_GetAppend,
+ SynthPortImpl_IDirectMusicPortDownload_Download,
+ SynthPortImpl_IDirectMusicPortDownload_Unload
};
-/* IDirectMusicThru IUnknown parts follow: */
-static HRESULT WINAPI IDirectMusicThruImpl_QueryInterface (LPDIRECTMUSICTHRU iface, REFIID riid, LPVOID *ppobj) {
- ICOM_THIS_MULTI(IDirectMusicPortImpl, lpThruVtbl, iface);
- TRACE("(%p/%p)->(%s, %p)\n", This, iface, debugstr_dmguid(riid), ppobj);
- return IUnknown_QueryInterface((IUnknown *)&(This->lpVtbl), riid, ppobj);
-}
+/* SynthPortImpl IDirectMusicThru IUnknown part follows: */
+static HRESULT WINAPI SynthPortImpl_IDirectMusicThru_QueryInterface(LPDIRECTMUSICTHRU iface, REFIID riid, LPVOID *ret_iface)
+{
+ SynthPortImpl *This = impl_from_SynthPortImpl_IDirectMusicThru(iface);
-static ULONG WINAPI IDirectMusicThruImpl_AddRef (LPDIRECTMUSICTHRU iface) {
- ICOM_THIS_MULTI(IDirectMusicPortImpl, lpThruVtbl, iface);
- TRACE("(%p/%p)->()\n", This, iface);
- return IUnknown_AddRef((IUnknown *)&(This->lpVtbl));
+ TRACE("(%p/%p)->(%s, %p)\n", iface, This, debugstr_dmguid(riid), ret_iface);
+
+ return IDirectMusicPort_QueryInterface(&This->IDirectMusicPort_iface, riid, ret_iface);
}
-static ULONG WINAPI IDirectMusicThruImpl_Release (LPDIRECTMUSICTHRU iface) {
- ICOM_THIS_MULTI(IDirectMusicPortImpl, lpThruVtbl, iface);
- TRACE("(%p/%p)->()\n", This, iface);
- return IUnknown_Release((IUnknown *)&(This->lpVtbl));
+static ULONG WINAPI SynthPortImpl_IDirectMusicThru_AddRef(LPDIRECTMUSICTHRU iface)
+{
+ SynthPortImpl *This = impl_from_SynthPortImpl_IDirectMusicThru(iface);
+
+ TRACE("(%p/%p)->()\n", iface, This);
+
+ return IDirectMusicPort_AddRef(&This->IDirectMusicPort_iface);
}
-/* IDirectMusicThru Interface follow: */
-static HRESULT WINAPI IDirectMusicThruImpl_ThruChannel (LPDIRECTMUSICTHRU iface, DWORD dwSourceChannelGroup, DWORD dwSourceChannel, DWORD dwDestinationChannelGroup, DWORD dwDestinationChannel, LPDIRECTMUSICPORT pDestinationPort) {
- ICOM_THIS_MULTI(IDirectMusicPortImpl, lpThruVtbl, iface);
- FIXME("(%p/%p)->(%d, %d, %d, %d, %p): stub\n", This, iface, dwSourceChannelGroup, dwSourceChannel, dwDestinationChannelGroup, dwDestinationChannel, pDestinationPort);
- return S_OK;
+static ULONG WINAPI SynthPortImpl_IDirectMusicThru_Release(LPDIRECTMUSICTHRU iface)
+{
+ SynthPortImpl *This = impl_from_SynthPortImpl_IDirectMusicThru(iface);
+
+ TRACE("(%p/%p)->()\n", iface, This);
+
+ return IDirectMusicPort_Release(&This->IDirectMusicPort_iface);
}
-static const IDirectMusicThruVtbl DirectMusicThru_Vtbl = {
- IDirectMusicThruImpl_QueryInterface,
- IDirectMusicThruImpl_AddRef,
- IDirectMusicThruImpl_Release,
- IDirectMusicThruImpl_ThruChannel
-};
+/* SynthPortImpl IDirectMusicThru Interface follows: */
+static HRESULT WINAPI SynthPortImpl_IDirectMusicThru_ThruChannel(LPDIRECTMUSICTHRU iface, DWORD source_channel_group, DWORD source_channel, DWORD destination_channel_group,
+ DWORD destination_channel, LPDIRECTMUSICPORT destination_port)
+{
+ SynthPortImpl *This = impl_from_SynthPortImpl_IDirectMusicThru(iface);
-HRESULT WINAPI DMUSIC_CreateDirectMusicPortImpl (LPCGUID lpcGUID, LPVOID *ppobj, LPUNKNOWN pUnkOuter, LPDMUS_PORTPARAMS pPortParams, LPDMUS_PORTCAPS pPortCaps) {
- IDirectMusicPortImpl *obj;
+ FIXME("(%p/%p)->(%d, %d, %d, %d, %p): stub\n", iface, This, source_channel_group, source_channel, destination_channel_group, destination_channel, destination_port);
- TRACE("(%p,%p,%p)\n", lpcGUID, ppobj, pUnkOuter);
+ return S_OK;
+}
- obj = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicPortImpl));
- if (NULL == obj) {
- *ppobj = NULL;
- return E_OUTOFMEMORY;
- }
- obj->lpVtbl = &DirectMusicPort_Vtbl;
- obj->lpDownloadVtbl = &DirectMusicPortDownload_Vtbl;
- obj->lpThruVtbl = &DirectMusicThru_Vtbl;
- obj->ref = 0; /* will be inited by QueryInterface */
- obj->fActive = FALSE;
- obj->params = *pPortParams;
- obj->caps = *pPortCaps;
- obj->pDirectSound = NULL;
- obj->pLatencyClock = NULL;
- DMUSIC_CreateReferenceClockImpl(&IID_IReferenceClock, (LPVOID*)&obj->pLatencyClock, NULL);
-
-#if 0
- if (pPortParams->dwValidParams & DMUS_PORTPARAMS_CHANNELGROUPS) {
- obj->nrofgroups = pPortParams->dwChannelGroups;
- /* setting default priorities */
- for (j = 0; j < obj->nrofgroups; j++) {
- TRACE ("Setting default channel priorities on channel group %i\n", j + 1);
- obj->group[j].channel[0].priority = DAUD_CHAN1_DEF_VOICE_PRIORITY;
- obj->group[j].channel[1].priority = DAUD_CHAN2_DEF_VOICE_PRIORITY;
- obj->group[j].channel[2].priority = DAUD_CHAN3_DEF_VOICE_PRIORITY;
- obj->group[j].channel[3].priority = DAUD_CHAN4_DEF_VOICE_PRIORITY;
- obj->group[j].channel[4].priority = DAUD_CHAN5_DEF_VOICE_PRIORITY;
- obj->group[j].channel[5].priority = DAUD_CHAN6_DEF_VOICE_PRIORITY;
- obj->group[j].channel[6].priority = DAUD_CHAN7_DEF_VOICE_PRIORITY;
- obj->group[j].channel[7].priority = DAUD_CHAN8_DEF_VOICE_PRIORITY;
- obj->group[j].channel[8].priority = DAUD_CHAN9_DEF_VOICE_PRIORITY;
- obj->group[j].channel[9].priority = DAUD_CHAN10_DEF_VOICE_PRIORITY;
- obj->group[j].channel[10].priority = DAUD_CHAN11_DEF_VOICE_PRIORITY;
- obj->group[j].channel[11].priority = DAUD_CHAN12_DEF_VOICE_PRIORITY;
- obj->group[j].channel[12].priority = DAUD_CHAN13_DEF_VOICE_PRIORITY;
- obj->group[j].channel[13].priority = DAUD_CHAN14_DEF_VOICE_PRIORITY;
- obj->group[j].channel[14].priority = DAUD_CHAN15_DEF_VOICE_PRIORITY;
- obj->group[j].channel[15].priority = DAUD_CHAN16_DEF_VOICE_PRIORITY;
- }
- }
-#endif
+static const IDirectMusicThruVtbl SynthPortImpl_DirectMusicThru_Vtbl = {
+ /*** IDirectMusicThru IUnknown part methods */
+ SynthPortImpl_IDirectMusicThru_QueryInterface,
+ SynthPortImpl_IDirectMusicThru_AddRef,
+ SynthPortImpl_IDirectMusicThru_Release,
+ /*** IDirectMusicThru methods ***/
+ SynthPortImpl_IDirectMusicThru_ThruChannel
+};
- return IDirectMusicPortImpl_QueryInterface ((LPDIRECTMUSICPORT)obj, lpcGUID, ppobj);
+HRESULT DMUSIC_CreateSynthPortImpl(LPCGUID guid, LPVOID *object, LPUNKNOWN unkouter, LPDMUS_PORTPARAMS port_params, LPDMUS_PORTCAPS port_caps, DWORD device)
+{
+ SynthPortImpl *obj;
+ HRESULT hr = E_FAIL;
+ int i;
+
+ TRACE("(%p,%p,%p,%p,%p%d)\n", guid, object, unkouter, port_params, port_caps, device);
+
+ *object = NULL;
+
+ obj = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(SynthPortImpl));
+ if (!obj)
+ return E_OUTOFMEMORY;
+
+ obj->IDirectMusicPort_iface.lpVtbl = &SynthPortImpl_DirectMusicPort_Vtbl;
+ obj->IDirectMusicPortDownload_iface.lpVtbl = &SynthPortImpl_DirectMusicPortDownload_Vtbl;
+ obj->IDirectMusicThru_iface.lpVtbl = &SynthPortImpl_DirectMusicThru_Vtbl;
+ obj->ref = 0; /* Will be inited by QueryInterface */
+ obj->fActive = FALSE;
+ obj->params = *port_params;
+ obj->caps = *port_caps;
+
+ hr = DMUSIC_CreateReferenceClockImpl(&IID_IReferenceClock, (LPVOID*)&obj->pLatencyClock, NULL);
+ if (hr != S_OK)
+ {
+ HeapFree(GetProcessHeap(), 0, obj);
+ return hr;
+ }
+
+ if (SUCCEEDED(hr))
+ hr = CoCreateInstance(&CLSID_DirectMusicSynth, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectMusicSynth, (void**)&obj->synth);
+
+ if (SUCCEEDED(hr))
+ hr = CoCreateInstance(&CLSID_DirectMusicSynthSink, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectMusicSynthSink, (void**)&obj->synth_sink);
+
+ if (SUCCEEDED(hr))
+ hr = IDirectMusicSynth_SetMasterClock(obj->synth, obj->pLatencyClock);
+
+ if (SUCCEEDED(hr))
+ hr = IDirectMusicSynthSink_SetMasterClock(obj->synth_sink, obj->pLatencyClock);
+
+ if (SUCCEEDED(hr))
+ hr = IDirectMusicSynth_SetSynthSink(obj->synth, obj->synth_sink);
+
+ if (SUCCEEDED(hr))
+ hr = IDirectMusicSynth_Open(obj->synth, port_params);
+
+ if (0)
+ {
+ if (port_params->dwValidParams & DMUS_PORTPARAMS_CHANNELGROUPS) {
+ obj->nrofgroups = port_params->dwChannelGroups;
+ /* Setting default priorities */
+ for (i = 0; i < obj->nrofgroups; i++) {
+ TRACE ("Setting default channel priorities on channel group %i\n", i + 1);
+ obj->group[i].channel[0].priority = DAUD_CHAN1_DEF_VOICE_PRIORITY;
+ obj->group[i].channel[1].priority = DAUD_CHAN2_DEF_VOICE_PRIORITY;
+ obj->group[i].channel[2].priority = DAUD_CHAN3_DEF_VOICE_PRIORITY;
+ obj->group[i].channel[3].priority = DAUD_CHAN4_DEF_VOICE_PRIORITY;
+ obj->group[i].channel[4].priority = DAUD_CHAN5_DEF_VOICE_PRIORITY;
+ obj->group[i].channel[5].priority = DAUD_CHAN6_DEF_VOICE_PRIORITY;
+ obj->group[i].channel[6].priority = DAUD_CHAN7_DEF_VOICE_PRIORITY;
+ obj->group[i].channel[7].priority = DAUD_CHAN8_DEF_VOICE_PRIORITY;
+ obj->group[i].channel[8].priority = DAUD_CHAN9_DEF_VOICE_PRIORITY;
+ obj->group[i].channel[9].priority = DAUD_CHAN10_DEF_VOICE_PRIORITY;
+ obj->group[i].channel[10].priority = DAUD_CHAN11_DEF_VOICE_PRIORITY;
+ obj->group[i].channel[11].priority = DAUD_CHAN12_DEF_VOICE_PRIORITY;
+ obj->group[i].channel[12].priority = DAUD_CHAN13_DEF_VOICE_PRIORITY;
+ obj->group[i].channel[13].priority = DAUD_CHAN14_DEF_VOICE_PRIORITY;
+ obj->group[i].channel[14].priority = DAUD_CHAN15_DEF_VOICE_PRIORITY;
+ obj->group[i].channel[15].priority = DAUD_CHAN16_DEF_VOICE_PRIORITY;
+ }
+ }
+ }
+
+ if (SUCCEEDED(hr))
+ return IDirectMusicPort_QueryInterface((LPDIRECTMUSICPORT)obj, guid, object);
+
+ if (obj->synth)
+ IDirectMusicSynth_Release(obj->synth);
+ if (obj->synth_sink)
+ IDirectMusicSynthSink_Release(obj->synth_sink);
+ if (obj->pLatencyClock)
+ IReferenceClock_Release(obj->pLatencyClock);
+ HeapFree(GetProcessHeap(), 0, obj);
+
+ return hr;
+}
+
+HRESULT DMUSIC_CreateMidiOutPortImpl(LPCGUID guid, LPVOID *object, LPUNKNOWN unkouter, LPDMUS_PORTPARAMS port_params, LPDMUS_PORTCAPS port_caps, DWORD device)
+{
+ TRACE("(%p,%p,%p,%p,%p,%d): stub\n", guid, object, unkouter, port_params, port_caps, device);
+
+ return E_NOTIMPL;
+}
+
+HRESULT DMUSIC_CreateMidiInPortImpl(LPCGUID guid, LPVOID *object, LPUNKNOWN unkouter, LPDMUS_PORTPARAMS port_params, LPDMUS_PORTCAPS port_caps, DWORD device)
+{
+ TRACE("(%p,%p,%p,%p,%p,%d): stub\n", guid, object, unkouter, port_params, port_caps, device);
+
+ return E_NOTIMPL;
}
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
-#define WINE_OLESELFREGISTER
+1 WINE_REGISTRY dmusic.rgs
+
#define WINE_FILEDESCRIPTION_STR "Wine DirectMusic"
#define WINE_FILENAME_STR "dmusic.dll"
#define WINE_FILEVERSION 5,3,1,904
#define WINE_FILEVERSION_STR "5.3.1.904"
#define WINE_PRODUCTVERSION 5,3,1,904
#define WINE_PRODUCTVERSION_STR "5.3.1.904"
+#define WINE_EXTRAVALUES VALUE "OLESelfRegister",""
-#include "wine/wine_common_ver.rc"
+#include <wine/wine_common_ver.rc>
STDMETHOD_(ULONG,Release)(THIS) PURE;
/*** IDirectMusic methods ***/
STDMETHOD(EnumPort)(THIS_ DWORD dwIndex, LPDMUS_PORTCAPS pPortCaps) PURE;
- STDMETHOD(CreateMusicBuffer)(THIS_ LPDMUS_BUFFERDESC pBufferDesc, LPDIRECTMUSICBUFFER **ppBuffer, LPUNKNOWN pUnkOuter) PURE;
+ STDMETHOD(CreateMusicBuffer)(THIS_ LPDMUS_BUFFERDESC pBufferDesc, LPDIRECTMUSICBUFFER *ppBuffer, LPUNKNOWN pUnkOuter) PURE;
STDMETHOD(CreatePort)(THIS_ REFCLSID rclsidPort, LPDMUS_PORTPARAMS pPortParams, LPDIRECTMUSICPORT *ppPort, LPUNKNOWN pUnkOuter) PURE;
STDMETHOD(EnumMasterClock)(THIS_ DWORD dwIndex, LPDMUS_CLOCKINFO lpClockInfo) PURE;
STDMETHOD(GetMasterClock)(THIS_ LPGUID pguidClock, struct IReferenceClock **ppReferenceClock) PURE;
STDMETHOD_(ULONG,Release)(THIS) PURE;
/*** IDirectMusic methods ***/
STDMETHOD(EnumPort)(THIS_ DWORD dwIndex, LPDMUS_PORTCAPS pPortCaps) PURE;
- STDMETHOD(CreateMusicBuffer)(THIS_ LPDMUS_BUFFERDESC pBufferDesc, LPDIRECTMUSICBUFFER **ppBuffer, LPUNKNOWN pUnkOuter) PURE;
+ STDMETHOD(CreateMusicBuffer)(THIS_ LPDMUS_BUFFERDESC pBufferDesc, LPDIRECTMUSICBUFFER *ppBuffer, LPUNKNOWN pUnkOuter) PURE;
STDMETHOD(CreatePort)(THIS_ REFCLSID rclsidPort, LPDMUS_PORTPARAMS pPortParams, LPDIRECTMUSICPORT *ppPort, LPUNKNOWN pUnkOuter) PURE;
STDMETHOD(EnumMasterClock)(THIS_ DWORD dwIndex, LPDMUS_CLOCKINFO lpClockInfo) PURE;
STDMETHOD(GetMasterClock)(THIS_ LPGUID pguidClock, struct IReferenceClock **ppReferenceClock) PURE;
-
-#ifndef _DMUSICS_
-#define _DMUSICS_
-
-#include "dmusicc.h"
-
-#define REGSTR_PATH_SOFTWARESYNTHS "Software\\Microsoft\\DirectMusic\\SoftwareSynths"
-
-interface IDirectMusicSynth;
-interface IDirectMusicSynthSink;
-
+/*
+ * DirectMusic Software Synth Definitions
+ *
+ * Copyright (C) 2003-2004 Rok Mandeljc
+ *
+ * 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.
+ *
+ * This program 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 program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#ifndef __WINE_DMUSIC_SOFTWARESYNTH_H
+#define __WINE_DMUSIC_SOFTWARESYNTH_H
+
+#include <dmusicc.h>
+
+/*****************************************************************************
+ * Registry path
+ */
+#define REGSTR_PATH_SOFTWARESYNTHS "Software\\Microsoft\\DirectMusic\\SoftwareSynths"
+
+
+/*****************************************************************************
+ * Predeclare the interfaces
+ */
+/* IIDs */
+DEFINE_GUID(IID_IDirectMusicSynth, 0x09823661,0x5c85,0x11d2,0xaf,0xa6,0x00,0xaa,0x00,0x24,0xd8,0xb6);
+DEFINE_GUID(IID_IDirectMusicSynth8, 0x53cab625,0x2711,0x4c9f,0x9d,0xe7,0x1b,0x7f,0x92,0x5f,0x6f,0xc8);
+DEFINE_GUID(IID_IDirectMusicSynthSink, 0x09823663,0x5c85,0x11d2,0xaf,0xa6,0x00,0xaa,0x00,0x24,0xd8,0xb6);
+
+/* typedef definitions */
+typedef struct IDirectMusicSynth *LPDIRECTMUSICSYNTH;
+typedef struct IDirectMusicSynth8 *LPDIRECTMUSICSYNTH8;
+typedef struct IDirectMusicSynthSink *LPDIRECTMUSICSYNTHSINK;
+
+/* GUIDs - property set */
+DEFINE_GUID(GUID_DMUS_PROP_SetSynthSink, 0x0a3a5ba5,0x37b6,0x11d2,0xb9,0xf9,0x00,0x00,0xf8,0x75,0xac,0x12);
+DEFINE_GUID(GUID_DMUS_PROP_SinkUsesDSound, 0xbe208857,0x8952,0x11d2,0xba,0x1c,0x00,0x00,0xf8,0x75,0xac,0x12);
+
+
+/*****************************************************************************
+ * Flags
+ */
+#define REFRESH_F_LASTBUFFER 0x1
+
+
+/*****************************************************************************
+ * Structures
+ */
#ifndef _DMUS_VOICE_STATE_DEFINED
#define _DMUS_VOICE_STATE_DEFINED
+/* typedef definition */
+typedef struct _DMUS_VOICE_STATE DMUS_VOICE_STATE, *LPDMUS_VOICE_STATE;
-DEFINE_GUID(IID_IDirectMusicSynth, 0x9823661, 0x5C85, 0x11D2, 0xAF, 0xA6, 0x00, 0xAA, 0x00, 0x24, 0xD8, 0xB6);
-DEFINE_GUID(IID_IDirectMusicSynth8, 0x53CAB625, 0x2711, 0x4C9F, 0x9D, 0xE7, 0x1B, 0x7F, 0x92, 0x5F, 0x6F, 0xC8);
-DEFINE_GUID(IID_IDirectMusicSynthSink, 0x09823663, 0x5C85, 0x11D2, 0xAF, 0xA6, 0x00, 0xAA, 0x00, 0x24, 0xD8, 0xB6);
-DEFINE_GUID(GUID_DMUS_PROP_SetSynthSink, 0x0A3A5BA5, 0x37B6, 0x11D2, 0xB9, 0xF9, 0x00, 0x00, 0xF8, 0x75, 0xAC, 0x12);
-DEFINE_GUID(GUID_DMUS_PROP_SinkUsesDSound, 0xBE208857, 0x8952, 0x11D2, 0xBA, 0x1C, 0x00, 0x00, 0xF8, 0x75, 0xAC, 0x12);
+/* actual structure */
+struct _DMUS_VOICE_STATE {
+ BOOL bExists;
+ SAMPLE_POSITION spPosition;
+};
+#endif /* _DMUS_VOICE_STATE_DEFINED */
-#define REFRESH_F_LASTBUFFER 0x00000001
-typedef struct _DMUS_VOICE_STATE
+/*****************************************************************************
+ * IDirectMusicSynth interface
+ */
+#define INTERFACE IDirectMusicSynth
+DECLARE_INTERFACE_(IDirectMusicSynth,IUnknown)
{
- BOOL bExists;
- SAMPLE_POSITION spPosition;
-} DMUS_VOICE_STATE;
-
-#endif
-
-#undef INTERFACE
-#define INTERFACE IDirectMusicSynth
-DECLARE_INTERFACE_(IDirectMusicSynth, IUnknown)
-{
- STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID FAR *) PURE;
- STDMETHOD_(ULONG,AddRef) (THIS) PURE;
- STDMETHOD_(ULONG,Release) (THIS) PURE;
- STDMETHOD(Open) (THIS_ LPDMUS_PORTPARAMS pPortParams) PURE;
- STDMETHOD(Close) (THIS) PURE;
- STDMETHOD(SetNumChannelGroups) (THIS_ DWORD dwGroups) PURE;
- STDMETHOD(Download) (THIS_ LPHANDLE phDownload, LPVOID pvData, LPBOOL pbFree ) PURE;
- STDMETHOD(Unload) (THIS_ HANDLE hDownload, HRESULT ( CALLBACK *lpFreeHandle)(HANDLE,HANDLE), HANDLE hUserData ) PURE;
- STDMETHOD(PlayBuffer) (THIS_ REFERENCE_TIME rt,LPBYTE pbBuffer, DWORD cbBuffer) PURE;
- STDMETHOD(GetRunningStats) (THIS_ LPDMUS_SYNTHSTATS pStats) PURE;
- STDMETHOD(GetPortCaps) (THIS_ LPDMUS_PORTCAPS pCaps) PURE;
- STDMETHOD(SetMasterClock) (THIS_ IReferenceClock *pClock) PURE;
- STDMETHOD(GetLatencyClock) (THIS_ IReferenceClock **ppClock) PURE;
- STDMETHOD(Activate) (THIS_ BOOL fEnable) PURE;
- STDMETHOD(SetSynthSink) (THIS_ struct IDirectMusicSynthSink *pSynthSink) PURE;
- STDMETHOD(Render) (THIS_ short *pBuffer, DWORD dwLength, LONGLONG llPosition) PURE;
- STDMETHOD(SetChannelPriority) (THIS_ DWORD dwChannelGroup, DWORD dwChannel, DWORD dwPriority) PURE;
- STDMETHOD(GetChannelPriority) (THIS_ DWORD dwChannelGroup, DWORD dwChannel, LPDWORD pdwPriority) PURE;
- STDMETHOD(GetFormat) (THIS_ LPWAVEFORMATEX pWaveFormatEx, LPDWORD pdwWaveFormatExSize) PURE;
- STDMETHOD(GetAppend) (THIS_ DWORD* pdwAppend) PURE;
+ /*** IUnknown methods ***/
+ STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
+ STDMETHOD_(ULONG,AddRef)(THIS) PURE;
+ STDMETHOD_(ULONG,Release)(THIS) PURE;
+ /*** IDirectMusicSynth methods ***/
+ STDMETHOD(Open)(THIS_ LPDMUS_PORTPARAMS pPortParams) PURE;
+ STDMETHOD(Close)(THIS) PURE;
+ STDMETHOD(SetNumChannelGroups)(THIS_ DWORD dwGroups) PURE;
+ STDMETHOD(Download)(THIS_ LPHANDLE phDownload, LPVOID pvData, LPBOOL pbFree) PURE;
+ STDMETHOD(Unload)(THIS_ HANDLE hDownload, HRESULT (CALLBACK* lpFreeHandle)(HANDLE,HANDLE), HANDLE hUserData) PURE;
+ STDMETHOD(PlayBuffer)(THIS_ REFERENCE_TIME rt, LPBYTE pbBuffer, DWORD cbBuffer) PURE;
+ STDMETHOD(GetRunningStats)(THIS_ LPDMUS_SYNTHSTATS pStats) PURE;
+ STDMETHOD(GetPortCaps)(THIS_ LPDMUS_PORTCAPS pCaps) PURE;
+ STDMETHOD(SetMasterClock)(THIS_ IReferenceClock *pClock) PURE;
+ STDMETHOD(GetLatencyClock)(THIS_ IReferenceClock **ppClock) PURE;
+ STDMETHOD(Activate)(THIS_ BOOL fEnable) PURE;
+ STDMETHOD(SetSynthSink)(THIS_ struct IDirectMusicSynthSink *pSynthSink) PURE;
+ STDMETHOD(Render)(THIS_ short *pBuffer, DWORD dwLength, LONGLONG llPosition) PURE;
+ STDMETHOD(SetChannelPriority)(THIS_ DWORD dwChannelGroup, DWORD dwChannel, DWORD dwPriority) PURE;
+ STDMETHOD(GetChannelPriority)(THIS_ DWORD dwChannelGroup, DWORD dwChannel, LPDWORD pdwPriority) PURE;
+ STDMETHOD(GetFormat)(THIS_ LPWAVEFORMATEX pWaveFormatEx, LPDWORD pdwWaveFormatExSiz) PURE;
+ STDMETHOD(GetAppend)(THIS_ DWORD *pdwAppend) PURE;
};
-#undef INTERFACE
+#undef INTERFACE
#if !defined(__cplusplus) || defined(CINTERFACE)
-#define IDirectMusicSynth_QueryInterface(p, a, b) (p)->lpVtbl->QueryInterface(p, a, b)
-#define IDirectMusicSynth_AddRef(p) (p)->lpVtbl->AddRef(p)
-#define IDirectMusicSynth_Release(p) (p)->lpVtbl->Release(p)
-#define IDirectMusicSynth_Open(p, a) (p)->lpVtbl->Open(p, a)
-#define IDirectMusicSynth_Close(p) (p)->lpVtbl->Close(p)
-#define IDirectMusicSynth_SetNumChannelGroups(p, a) (p)->lpVtbl->SetNumChannelGroups(p, a)
-#define IDirectMusicSynth_Download(p, a, b, c) (p)->lpVtbl->Download(p, a, b, c)
-#define IDirectMusicSynth_Unload(p, a, b, c) (p)->lpVtbl->Unload(p, a, b, c)
-#define IDirectMusicSynth_PlayBuffer(p, a, b, c) (p)->lpVtbl->PlayBuffer(p, a, b, c)
-#define IDirectMusicSynth_GetRunningStats(p, a) (p)->lpVtbl->GetRunningStats(p, a)
-#define IDirectMusicSynth_GetPortCaps(p, a) (p)->lpVtbl->GetPortCaps(p, a)
-#define IDirectMusicSynth_SetMasterClock(p, a) (p)->lpVtbl->SetMasterClock((p, a)
-#define IDirectMusicSynth_GetLatencyClock(p, a) (p)->lpVtbl->GetLatencyClock(p, a)
-#define IDirectMusicSynth_Activate(p, a) (p)->lpVtbl->Activate((p, a)
-#define IDirectMusicSynth_SetSynthSink(p, a) (p)->lpVtbl->SetSynthSink(p, a)
-#define IDirectMusicSynth_Render(p, a, b, c) (p)->lpVtbl->Render(p, a, b, c)
-#define IDirectMusicSynth_SetChannelPriority(p, a, b, c) (p)->lpVtbl->SetChannelPriority(p, a, b, c)
-#define IDirectMusicSynth_GetChannelPriority(p, a, b, c) (p)->lpVtbl->GetChannelPriority(p, a, b, c)
-#define IDirectMusicSynth_GetFormat(p, a, b) (p)->lpVtbl->GetFormat(p, a, b)
-#define IDirectMusicSynth_GetAppend(p, a) (p)->lpVtbl->GetAppend(p, a)
+/*** IUnknown methods ***/
+#define IDirectMusicSynth_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
+#define IDirectMusicSynth_AddRef(p) (p)->lpVtbl->AddRef(p)
+#define IDirectMusicSynth_Release(p) (p)->lpVtbl->Release(p)
+/*** IDirectMusicSynth methods ***/
+#define IDirectMusicSynth_Open(p,a) (p)->lpVtbl->Open(p,a)
+#define IDirectMusicSynth_Close(p) (p)->lpVtbl->Close(p)
+#define IDirectMusicSynth_SetNumChannelGroups(p,a) (p)->lpVtbl->SetNumChannelGroups(p,a)
+#define IDirectMusicSynth_Download(p,a,b,c) (p)->lpVtbl->Download(p,a,b,c)
+#define IDirectMusicSynth_Unload(p,a,b,c) (p)->lpVtbl->Unload(p,a,b,c)
+#define IDirectMusicSynth_PlayBuffer(p,a,b,c) (p)->lpVtbl->PlayBuffer(p,a,b,c)
+#define IDirectMusicSynth_GetRunningStats(p,a) (p)->lpVtbl->GetRunningStats(p,a)
+#define IDirectMusicSynth_GetPortCaps(p,a) (p)->lpVtbl->GetPortCaps(p,a)
+#define IDirectMusicSynth_SetMasterClock(p,a) (p)->lpVtbl->SetMasterClock(p,a)
+#define IDirectMusicSynth_GetLatencyClock(p,a) (p)->lpVtbl->GetLatencyClock(p,a)
+#define IDirectMusicSynth_Activate(p,a) (p)->lpVtbl->Activate(p,a)
+#define IDirectMusicSynth_SetSynthSink(p,a) (p)->lpVtbl->SetSynthSink(p,a)
+#define IDirectMusicSynth_Render(p,a,b,c) (p)->lpVtbl->Render(p,a,b,c)
+#define IDirectMusicSynth_SetChannelPriority(p,a,b,c) (p)->lpVtbl->SetChannelPriority(p,a,b,c)
+#define IDirectMusicSynth_GetChannelPriority(p,a,b,c) (p)->lpVtbl->GetChannelPriority(p,a,b,c)
+#define IDirectMusicSynth_GetFormat(p,a,b) (p)->lpVtbl->GetFormat(p,a,b)
+#define IDirectMusicSynth_GetAppend(p,a) (p)->lpVtbl->GetAppend(p,a)
#endif
-#define INTERFACE IDirectMusicSynth8
-DECLARE_INTERFACE_(IDirectMusicSynth8, IDirectMusicSynth)
+
+/*****************************************************************************
+ * IDirectMusicSynth8 interface
+ */
+#define INTERFACE IDirectMusicSynth8
+DECLARE_INTERFACE_(IDirectMusicSynth8,IDirectMusicSynth)
{
- STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID FAR *) PURE;
- STDMETHOD_(ULONG,AddRef) (THIS) PURE;
- STDMETHOD_(ULONG,Release) (THIS) PURE;
- STDMETHOD(Open) (THIS_ LPDMUS_PORTPARAMS pPortParams) PURE;
- STDMETHOD(Close) (THIS) PURE;
- STDMETHOD(SetNumChannelGroups) (THIS_ DWORD dwGroups) PURE;
- STDMETHOD(Download) (THIS_ LPHANDLE phDownload, LPVOID pvData, LPBOOL pbFree ) PURE;
- STDMETHOD(Unload) (THIS_ HANDLE hDownload, HRESULT ( CALLBACK *lpFreeHandle)(HANDLE,HANDLE), HANDLE hUserData ) PURE;
- STDMETHOD(PlayBuffer) (THIS_ REFERENCE_TIME rt, LPBYTE pbBuffer, DWORD cbBuffer) PURE;
- STDMETHOD(GetRunningStats) (THIS_ LPDMUS_SYNTHSTATS pStats) PURE;
- STDMETHOD(GetPortCaps) (THIS_ LPDMUS_PORTCAPS pCaps) PURE;
- STDMETHOD(SetMasterClock) (THIS_ IReferenceClock *pClock) PURE;
- STDMETHOD(GetLatencyClock) (THIS_ IReferenceClock **ppClock) PURE;
- STDMETHOD(Activate) (THIS_ BOOL fEnable) PURE;
- STDMETHOD(SetSynthSink) (THIS_ struct IDirectMusicSynthSink *pSynthSink) PURE;
- STDMETHOD(Render) (THIS_ short *pBuffer, DWORD dwLength, LONGLONG llPosition) PURE;
- STDMETHOD(SetChannelPriority) (THIS_ DWORD dwChannelGroup, DWORD dwChannel, DWORD dwPriority) PURE;
- STDMETHOD(GetChannelPriority) (THIS_ DWORD dwChannelGroup, DWORD dwChannel, LPDWORD pdwPriority) PURE;
- STDMETHOD(GetFormat) (THIS_ LPWAVEFORMATEX pWaveFormatEx, LPDWORD pdwWaveFormatExSize) PURE;
- STDMETHOD(GetAppend) (THIS_ DWORD* pdwAppend) PURE;
- STDMETHOD(PlayVoice) (THIS_ REFERENCE_TIME rt, DWORD dwVoiceId, DWORD dwChannelGroup, DWORD dwChannel, DWORD dwDLId, long prPitch, long vrVolume, SAMPLE_TIME stVoiceStart, SAMPLE_TIME stLoopStart, SAMPLE_TIME stLoopEnd) PURE;
- STDMETHOD(StopVoice) (THIS_ REFERENCE_TIME rt, DWORD dwVoiceId ) PURE;
- STDMETHOD(GetVoiceState) (THIS_ DWORD dwVoice[], DWORD cbVoice, DMUS_VOICE_STATE dwVoiceState[] ) PURE;
- STDMETHOD(Refresh) (THIS_ DWORD dwDownloadID, DWORD dwFlags) PURE;
- STDMETHOD(AssignChannelToBuses) (THIS_ DWORD dwChannelGroup, DWORD dwChannel, LPDWORD pdwBuses, DWORD cBuses) PURE;
+ /*** IUnknown methods ***/
+ STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
+ STDMETHOD_(ULONG,AddRef)(THIS) PURE;
+ STDMETHOD_(ULONG,Release)(THIS) PURE;
+ /*** IDirectMusicSynth methods ***/
+ STDMETHOD(Open)(THIS_ LPDMUS_PORTPARAMS pPortParams) PURE;
+ STDMETHOD(Close)(THIS) PURE;
+ STDMETHOD(SetNumChannelGroups)(THIS_ DWORD dwGroups) PURE;
+ STDMETHOD(Download)(THIS_ LPHANDLE phDownload, LPVOID pvData, LPBOOL pbFree) PURE;
+ STDMETHOD(Unload)(THIS_ HANDLE hDownload, HRESULT (CALLBACK* lpFreeHandle)(HANDLE,HANDLE), HANDLE hUserData) PURE;
+ STDMETHOD(PlayBuffer)(THIS_ REFERENCE_TIME rt, LPBYTE pbBuffer, DWORD cbBuffer) PURE;
+ STDMETHOD(GetRunningStats)(THIS_ LPDMUS_SYNTHSTATS pStats) PURE;
+ STDMETHOD(GetPortCaps)(THIS_ LPDMUS_PORTCAPS pCaps) PURE;
+ STDMETHOD(SetMasterClock)(THIS_ IReferenceClock *pClock) PURE;
+ STDMETHOD(GetLatencyClock)(THIS_ IReferenceClock **ppClock) PURE;
+ STDMETHOD(Activate)(THIS_ BOOL fEnable) PURE;
+ STDMETHOD(SetSynthSink)(THIS_ struct IDirectMusicSynthSink *pSynthSink) PURE;
+ STDMETHOD(Render)(THIS_ short *pBuffer, DWORD dwLength, LONGLONG llPosition) PURE;
+ STDMETHOD(SetChannelPriority)(THIS_ DWORD dwChannelGroup, DWORD dwChannel, DWORD dwPriority) PURE;
+ STDMETHOD(GetChannelPriority)(THIS_ DWORD dwChannelGroup, DWORD dwChannel, LPDWORD pdwPriority) PURE;
+ STDMETHOD(GetFormat)(THIS_ LPWAVEFORMATEX pWaveFormatEx, LPDWORD pdwWaveFormatExSiz) PURE;
+ STDMETHOD(GetAppend)(THIS_ DWORD *pdwAppend) PURE;
+ /*** IDirectMusicSynth8 methods ***/
+ STDMETHOD(PlayVoice)(THIS_ REFERENCE_TIME rt, DWORD dwVoiceId, DWORD dwChannelGroup, DWORD dwChannel, DWORD dwDLId, LONG prPitch, LONG vrVolume, SAMPLE_TIME stVoiceStart, SAMPLE_TIME stLoopStart, SAMPLE_TIME stLoopEnd) PURE;
+ STDMETHOD(StopVoice)(THIS_ REFERENCE_TIME rt, DWORD dwVoiceId) PURE;
+ STDMETHOD(GetVoiceState)(THIS_ DWORD dwVoice[], DWORD cbVoice, DMUS_VOICE_STATE dwVoiceState[]) PURE;
+ STDMETHOD(Refresh)(THIS_ DWORD dwDownloadID, DWORD dwFlags) PURE;
+ STDMETHOD(AssignChannelToBuses)(THIS_ DWORD dwChannelGroup, DWORD dwChannel, LPDWORD pdwBuses, DWORD cBuses) PURE;
};
-#undef INTERFACE
+#undef INTERFACE
#if !defined(__cplusplus) || defined(CINTERFACE)
-#define IDirectMusicSynth8_QueryInterface(p, a, b) (p)->lpVtbl->QueryInterface(p, a, b)
-#define IDirectMusicSynth8_AddRef(p) (p)->lpVtbl->AddRef(p)
-#define IDirectMusicSynth8_Release(p) (p)->lpVtbl->Release(p)
-#define IDirectMusicSynth8_Open(p, a) (p)->lpVtbl->Open(p, a)
-#define IDirectMusicSynth8_Close(p) (p)->lpVtbl->Close(p)
-#define IDirectMusicSynth8_SetNumChannelGroups(p, a) (p)->lpVtbl->SetNumChannelGroups(p, a)
-#define IDirectMusicSynth8_Download(p, a, b, c) (p)->lpVtbl->Download(p, a, b, c)
-#define IDirectMusicSynth8_Unload(p, a, b, c) (p)->lpVtbl->Unload(p, a, b, c)
-#define IDirectMusicSynth8_PlayBuffer(p, a, b, c) (p)->lpVtbl->PlayBuffer(p, a, b, c)
-#define IDirectMusicSynth8_GetRunningStats(p, a) (p)->lpVtbl->GetRunningStats(p, a)
-#define IDirectMusicSynth8_GetPortCaps(p, a) (p)->lpVtbl->GetPortCaps(p, a)
-#define IDirectMusicSynth8_SetMasterClock(p, a) (p)->lpVtbl->SetMasterClock((p, a)
-#define IDirectMusicSynth8_GetLatencyClock(p, a) (p)->lpVtbl->GetLatencyClock(p, a)
-#define IDirectMusicSynth8_Activate(p, a) (p)->lpVtbl->Activate((p, a)
-#define IDirectMusicSynth8_SetSynthSink(p, a) (p)->lpVtbl->SetSynthSink(p, a)
-#define IDirectMusicSynth8_Render(p, a, b, c) (p)->lpVtbl->Render(p, a, b, c)
-#define IDirectMusicSynth8_SetChannelPriority(p, a, b, c) (p)->lpVtbl->SetChannelPriority(p, a, b, c)
-#define IDirectMusicSynth8_GetChannelPriority(p, a, b, c) (p)->lpVtbl->GetChannelPriority(p, a, b, c)
-#define IDirectMusicSynth8_GetFormat(p, a, b) (p)->lpVtbl->GetFormat(p, a, b)
-#define IDirectMusicSynth8_GetAppend(p, a) (p)->lpVtbl->GetAppend(p, a)
-#define IDirectMusicSynth8_PlayVoice(p, a, b, c, d, e, f, g, h, i, j) (p)->lpVtbl->PlayVoice(p, a, b, c, d, e, f, g, h, i, j)
-#define IDirectMusicSynth8_StopVoice(p, a, b) (p)->lpVtbl->StopVoice(p, a, b)
-#define IDirectMusicSynth8_GetVoiceState(p, a, b, c) (p)->lpVtbl->GetVoiceState(p, a, b, c)
-#define IDirectMusicSynth8_Refresh(p, a, b) (p)->lpVtbl->Refresh(p, a, b)
-#define IDirectMusicSynth8_AssignChannelToBuses(p, a, b, c, d) (p)->lpVtbl->AssignChannelToBuses(p, a, b, c, d)
+/*** IUnknown methods ***/
+#define IDirectMusicSynth8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
+#define IDirectMusicSynth8_AddRef(p) (p)->lpVtbl->AddRef(p)
+#define IDirectMusicSynth8_Release(p) (p)->lpVtbl->Release(p)
+/*** IDirectMusicSynth methods ***/
+#define IDirectMusicSynth8_Open(p,a) (p)->lpVtbl->Open(p,a)
+#define IDirectMusicSynth8_Close(p) (p)->lpVtbl->Close(p)
+#define IDirectMusicSynth8_SetNumChannelGroups(p,a) (p)->lpVtbl->SetNumChannelGroups(p,a)
+#define IDirectMusicSynth8_Download(p,a,b,c) (p)->lpVtbl->Download(p,a,b,c)
+#define IDirectMusicSynth8_Unload(p,a,b,c) (p)->lpVtbl->Unload(p,a,b,c)
+#define IDirectMusicSynth8_PlayBuffer(p,a,b,c) (p)->lpVtbl->PlayBuffer(p,a,b,c)
+#define IDirectMusicSynth8_GetRunningStats(p,a) (p)->lpVtbl->GetRunningStats(p,a)
+#define IDirectMusicSynth8_GetPortCaps(p,a) (p)->lpVtbl->GetPortCaps(p,a)
+#define IDirectMusicSynth8_SetMasterClock(p,a) (p)->lpVtbl->SetMasterClock(p,a)
+#define IDirectMusicSynth8_GetLatencyClock(p,a) (p)->lpVtbl->GetLatencyClock(p,a)
+#define IDirectMusicSynth8_Activate(p,a) (p)->lpVtbl->Activate(p,a)
+#define IDirectMusicSynth8_SetSynthSink(p,a) (p)->lpVtbl->SetSynthSink(p,a)
+#define IDirectMusicSynth8_Render(p,a,b,c) (p)->lpVtbl->Render(p,a,b,c)
+#define IDirectMusicSynth8_SetChannelPriority(p,a,b,c) (p)->lpVtbl->SetChannelPriority(p,a,b,c)
+#define IDirectMusicSynth8_GetChannelPriority(p,a,b,c) (p)->lpVtbl->GetChannelPriority(p,a,b,c)
+#define IDirectMusicSynth8_GetFormat(p,a,b) (p)->lpVtbl->GetFormat(p,a,b)
+#define IDirectMusicSynth8_GetAppend(p,a) (p)->lpVtbl->GetAppend(p,a)
+/*** IDirectMusicSynth8 methods ***/
+#define IDirectMusicSynth8_PlayVoice(p,a,b,c,d,e,f,g,h,i,j) (p)->lpVtbl->PlayVoice(p,a,b,c,d,e,f,g,h,i,j)
+#define IDirectMusicSynth8_StopVoice(p,a,b) (p)->lpVtbl->StopVoice(p,a,b)
+#define IDirectMusicSynth8_GetVoiceState(p,a,b,c) (p)->lpVtbl->GetVoiceState(p,a,b,c)
+#define IDirectMusicSynth8_Refresh(p,a,b) (p)->lpVtbl->Refresh(p,a,b)
+#define IDirectMusicSynth8_AssignChannelToBuses(p,a,b,c,d) (p)->lpVtbl->AssignChannelToBuses(p,a,b,c,d)
#endif
-#define INTERFACE IDirectMusicSynthSink
-DECLARE_INTERFACE_(IDirectMusicSynthSink, IUnknown)
+
+/*****************************************************************************
+ * IDirectMusicSynthSink interface
+ */
+#define INTERFACE IDirectMusicSynthSink
+DECLARE_INTERFACE_(IDirectMusicSynthSink,IUnknown)
{
- STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID FAR *) PURE;
- STDMETHOD_(ULONG,AddRef) (THIS) PURE;
- STDMETHOD_(ULONG,Release) (THIS) PURE;
- STDMETHOD(Init) (THIS_ IDirectMusicSynth *pSynth) PURE;
- STDMETHOD(SetMasterClock) (THIS_ IReferenceClock *pClock) PURE;
- STDMETHOD(GetLatencyClock) (THIS_ IReferenceClock **ppClock) PURE;
- STDMETHOD(Activate) (THIS_ BOOL fEnable) PURE;
- STDMETHOD(SampleToRefTime) (THIS_ LONGLONG llSampleTime, REFERENCE_TIME *prfTime) PURE;
- STDMETHOD(RefTimeToSample) (THIS_ REFERENCE_TIME rfTime, LONGLONG *pllSampleTime) PURE;
- STDMETHOD(SetDirectSound) (THIS_ LPDIRECTSOUND pDirectSound, LPDIRECTSOUNDBUFFER pDirectSoundBuffer) PURE;
- STDMETHOD(GetDesiredBufferSize) (THIS_ LPDWORD pdwBufferSizeInSamples) PURE;
+ /*** IUnknown methods ***/
+ STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
+ STDMETHOD_(ULONG,AddRef)(THIS) PURE;
+ STDMETHOD_(ULONG,Release)(THIS) PURE;
+ /*** IDirectMusicSynthSink methods ***/
+ STDMETHOD(Init)(THIS_ IDirectMusicSynth *pSynth) PURE;
+ STDMETHOD(SetMasterClock)(THIS_ IReferenceClock *pClock) PURE;
+ STDMETHOD(GetLatencyClock)(THIS_ IReferenceClock **ppClock) PURE;
+ STDMETHOD(Activate)(THIS_ BOOL fEnable) PURE;
+ STDMETHOD(SampleToRefTime)(THIS_ LONGLONG llSampleTime, REFERENCE_TIME *prfTime) PURE;
+ STDMETHOD(RefTimeToSample)(THIS_ REFERENCE_TIME rfTime, LONGLONG *pllSampleTime) PURE;
+ STDMETHOD(SetDirectSound)(THIS_ LPDIRECTSOUND pDirectSound, LPDIRECTSOUNDBUFFER pDirectSoundBuffer) PURE;
+ STDMETHOD(GetDesiredBufferSize)(THIS_ LPDWORD pdwBufferSizeInSamples) PURE;
};
+#undef INTERFACE
+#if !defined(__cplusplus) || defined(CINTERFACE)
+/*** IUnknown methods ***/
+#define IDirectMusicSynthSink_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
+#define IDirectMusicSynthSink_AddRef(p) (p)->lpVtbl->AddRef(p)
+#define IDirectMusicSynthSink_Release(p) (p)->lpVtbl->Release(p)
+/*** IDirectMusicSynth methods ***/
+#define IDirectMusicSynthSink_Init(p,a) (p)->lpVtbl->Init(p,a)
+#define IDirectMusicSynthSink_SetMasterClock(p,a) (p)->lpVtbl->SetMasterClock(p,a)
+#define IDirectMusicSynthSink_GetLatencyClock(p,a) (p)->lpVtbl->GetLatencyClock(p,a)
+#define IDirectMusicSynthSink_Activate(p,a) (p)->lpVtbl->Activate(p,a)
+#define IDirectMusicSynthSink_SampleToRefTime(p,a,b) (p)->lpVtbl->SampleToRefTime(p,a,b)
+#define IDirectMusicSynthSink_RefTimeToSample(p,a,b) (p)->lpVtbl->RefTimeToSample(p,a,b)
+#define IDirectMusicSynthSink_SetDirectSound(p,a,b) (p)->lpVtbl->SetDirectSound(p,a,b)
+#define IDirectMusicSynthSink_GetDesiredBufferSize(p,a) (p)->lpVtbl->GetDesiredBufferSize(p,a)
#endif
+
+#endif /* __WINE_DMUSIC_SOFTWARESYNTH_H */
/*
- * dmksctrl.h
+ * Definition of IKsControl
*
- * Contributors:
- * Created by Johannes Anderwald
+ * Copyright (C) 2012 Christian Costa
*
- * THIS SOFTWARE IS NOT COPYRIGHTED
+ * 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 source code is offered for use in the public domain. You may
- * use, modify or distribute it freely.
- *
- * This code is distributed in the hope that it will be useful but
- * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
- * DISCLAIMED. This includes but is not limited to warranties of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * 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
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
-#ifndef _IKsControl_
-#define _IKsControl_
+#ifndef _DMKSCTRL_
+#define _DMKSCTRL_
+
+#include <pshpack8.h>
+
+#include <objbase.h>
+
+#ifndef _KS_
+#define _KS_
+
+typedef struct {
+ union {
+ struct {
+ GUID Set;
+ ULONG Id;
+ ULONG Flags;
+ } DUMMYSTRUCTNAME;
+ LONGLONG Alignment;
+ } DUMMYUNIONNAME;
+} KSIDENTIFIER, *PKSIDENTIFIER;
+
+typedef KSIDENTIFIER KSPROPERTY, *PKSPROPERTY, KSMETHOD, *PKSMETHOD, KSEVENT, *PKSEVENT;
+
+#define KSMETHOD_TYPE_NONE 0x00000000
+#define KSMETHOD_TYPE_READ 0x00000001
+#define KSMETHOD_TYPE_WRITE 0x00000002
+#define KSMETHOD_TYPE_MODIFY 0x00000003
+#define KSMETHOD_TYPE_SOURCE 0x00000004
+
+#define KSMETHOD_TYPE_SEND 0x00000001
+#define KSMETHOD_TYPE_SETSUPPORT 0x00000100
+#define KSMETHOD_TYPE_BASICSUPPORT 0x00000200
+
+#define KSPROPERTY_TYPE_GET 0x00000001
+#define KSPROPERTY_TYPE_SET 0x00000002
+#define KSPROPERTY_TYPE_SETSUPPORT 0x00000100
+#define KSPROPERTY_TYPE_BASICSUPPORT 0x00000200
+#define KSPROPERTY_TYPE_RELATIONS 0x00000400
+#define KSPROPERTY_TYPE_SERIALIZESET 0x00000800
+#define KSPROPERTY_TYPE_UNSERIALIZESET 0x00001000
+#define KSPROPERTY_TYPE_SERIALIZERAW 0x00002000
+#define KSPROPERTY_TYPE_UNSERIALIZERAW 0x00004000
+#define KSPROPERTY_TYPE_SERIALIZESIZE 0x00008000
+#define KSPROPERTY_TYPE_DEFAULTVALUES 0x00010000
+
+#define KSPROPERTY_TYPE_TOPOLOGY 0x10000000
-#undef INTERFACE
#define INTERFACE IKsControl
-DECLARE_INTERFACE_(IKsControl, IUnknown)
+DECLARE_INTERFACE_(IKsControl,IUnknown)
{
- /* IUnknown */
- STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID FAR *) PURE;
- STDMETHOD_(ULONG,AddRef) (THIS) PURE;
- STDMETHOD_(ULONG,Release) (THIS) PURE;
-
- /*IKsControl*/
- STDMETHOD(KsProperty)(
- THIS_
- IN PKSPROPERTY Property,
- IN ULONG PropertyLength,
- IN OUT LPVOID PropertyData,
- IN ULONG DataLength,
- OUT ULONG* BytesReturned
- ) PURE;
- STDMETHOD(KsMethod)(
- THIS_
- IN PKSMETHOD Method,
- IN ULONG MethodLength,
- IN OUT LPVOID MethodData,
- IN ULONG DataLength,
- OUT ULONG* BytesReturned
- ) PURE;
- STDMETHOD(KsEvent)(
- THIS_
- IN PKSEVENT Event OPTIONAL,
- IN ULONG EventLength,
- IN OUT LPVOID EventData,
- IN ULONG DataLength,
- OUT ULONG* BytesReturned
- ) PURE;
+ /*** IUnknown methods ***/
+ STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
+ STDMETHOD_(ULONG,AddRef)(THIS) PURE;
+ STDMETHOD_(ULONG,Release)(THIS) PURE;
+ /*** IKsControl methods ***/
+ STDMETHOD(KsProperty)(THIS_ PKSPROPERTY Property, ULONG PropertyLength, LPVOID PropertyData,
+ ULONG DataLength, ULONG* BytesReturned) PURE;
+ STDMETHOD(KsMethod)(THIS_ PKSMETHOD Method, ULONG MethodLength, LPVOID MethodData,
+ ULONG DataLength, ULONG* BytesReturned) PURE;
+ STDMETHOD(KsEvent)(THIS_ PKSEVENT Event, ULONG EventLength, LPVOID EventData,
+ ULONG DataLength, ULONG* BytesReturned) PURE;
};
+#undef INTERFACE
+
+#if !defined(__cplusplus) || defined(CINTERFACE)
+/*** IUnknown methods ***/
+#define IKsControl_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
+#define IKsControl_AddRef(p) (p)->lpVtbl->AddRef(p)
+#define IKsControl_Release(p) (p)->lpVtbl->Release(p)
+/*** IKsControl methods ***/
+#define IKsControl_KsProperty(p,a,b,c,d,e) (p)->lpVtbl->KsProperty(p,a,b,c,d,e)
+#define IKsControl_KsMethod(p,a,b,c,d,e) (p)->lpVtbl->KsMethod(p,a,b,c,d,e)
+#define IKsControl_KsEvent(p,a,b,c,d,e) (p)->lpVtbl->KsEvent(p,a,b,c,d,e)
+#endif
+
+#endif /* _KS_ */
+
+#include <poppack.h>
+
+
+DEFINE_GUID(IID_IKsControl, 0x28f54685, 0x06fd, 0x11d2, 0xb2, 0x7a, 0x00, 0xa0, 0xc9, 0x22, 0x31, 0x96);
+
+#ifndef _KSMEDIA_
+
+DEFINE_GUID(KSDATAFORMAT_SUBTYPE_MIDI, 0x1d262760, 0xe957, 0x11cf, 0xa5, 0xd6, 0x28, 0xdb, 0x04, 0xc1, 0x00, 0x00);
+DEFINE_GUID(KSDATAFORMAT_SUBTYPE_DIRECTMUSIC, 0x1a82f8bc, 0x3f8b, 0x11d2, 0xb7, 0x74, 0x00, 0x60, 0x08, 0x33, 0x16, 0xc1);
#endif
+
+#endif /* _DMKSCTRL_ */
reactos/dll/directx/amstream # Synced to Wine-1.3.37
reactos/dll/directx/dinput # Synced to Wine-20090208
reactos/dll/directx/dinput8 # Synced to Wine-20090208
-reactos/dll/directx/dmusic # Synced to Wine-1_1_23
+reactos/dll/directx/dmusic # Synced to Wine-1.5.26
reactos/dll/directx/dplay # Synced to Wine-1.5.26
reactos/dll/directx/dplayx # Synced to Wine-1.5.26
reactos/dll/directx/dxdiagn # Synced to Wine-0_9_5