dmloader: complete rewrite and full implementation.

This commit is contained in:
Rok Mandeljc 2004-05-13 00:00:22 +00:00 committed by Alexandre Julliard
parent f174ac3304
commit 72c80375fa
9 changed files with 2954 additions and 1643 deletions

View File

@ -7,7 +7,9 @@ IMPORTS = ole32 user32 advapi32 kernel32
EXTRALIBS = -ldxguid -luuid
C_SRCS = \
classfactory.c \
container.c \
debug.c \
dmloader_main.c \
loader.c \
loaderstream.c \

View File

@ -0,0 +1,198 @@
/* IDirectMusicLoaderCF
* IDirectMusicContainerCF
*
* Copyright (C) 2004 Rok Mandeljc
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 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 Library General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "dmloader_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(dmloader);
/*****************************************************************************
* IDirectMusicLoaderCF implementation
*/
HRESULT WINAPI IDirectMusicLoaderCF_QueryInterface (LPCLASSFACTORY iface, REFIID riid, LPVOID *ppobj) {
ICOM_THIS(IDirectMusicLoaderCF, iface);
TRACE("(%p, %s, %p)\n", This, debugstr_dmguid(riid), ppobj);
if (IsEqualIID (riid, &IID_IUnknown) ||
IsEqualIID (riid, &IID_IClassFactory)) {
IDirectMusicLoaderCF_AddRef (iface);
*ppobj = This;
return S_OK;
}
WARN(": not found\n");
return E_NOINTERFACE;
}
ULONG WINAPI IDirectMusicLoaderCF_AddRef (LPCLASSFACTORY iface) {
ICOM_THIS(IDirectMusicLoaderCF, iface);
TRACE("(%p): AddRef from %ld\n", This, This->dwRef);
return InterlockedIncrement (&This->dwRef);
}
ULONG WINAPI IDirectMusicLoaderCF_Release (LPCLASSFACTORY iface) {
ICOM_THIS(IDirectMusicLoaderCF, iface);
DWORD dwRef = InterlockedDecrement (&This->dwRef);
TRACE("(%p): ReleaseRef to %ld\n", This, dwRef);
if (dwRef == 0) {
HeapFree(GetProcessHeap (), 0, This);
/* decrease number of instances */
InterlockedDecrement(&dwDirectMusicLoader);
}
return dwRef;
}
HRESULT WINAPI IDirectMusicLoaderCF_CreateInstance (LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) {
ICOM_THIS(IDirectMusicLoaderCF, iface);
TRACE ("(%p, %p, %s, %p)\n", This, pOuter, debugstr_dmguid(riid), ppobj);
if (pOuter) {
ERR(": pOuter should be NULL\n");
return CLASS_E_NOAGGREGATION;
}
return DMUSIC_CreateDirectMusicLoaderImpl (riid, ppobj, pOuter);
}
HRESULT WINAPI IDirectMusicLoaderCF_LockServer (LPCLASSFACTORY iface, BOOL dolock) {
ICOM_THIS(IDirectMusicLoaderCF, iface);
TRACE("(%p, %d)\n", This, dolock);
if (dolock == TRUE)
InterlockedIncrement (&dwDirectMusicLoader);
else
InterlockedDecrement (&dwDirectMusicLoader);
return S_OK;
}
ICOM_VTABLE(IClassFactory) DirectMusicLoaderCF_Vtbl = {
ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
IDirectMusicLoaderCF_QueryInterface,
IDirectMusicLoaderCF_AddRef,
IDirectMusicLoaderCF_Release,
IDirectMusicLoaderCF_CreateInstance,
IDirectMusicLoaderCF_LockServer
};
HRESULT WINAPI DMUSIC_CreateDirectMusicLoaderCF (LPCGUID lpcGUID, LPVOID *ppobj, LPUNKNOWN pUnkOuter) {
IDirectMusicLoaderCF *obj;
TRACE("(%s, %p, %p)\n", debugstr_dmguid(lpcGUID), ppobj, pUnkOuter);
obj = HeapAlloc (GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicLoaderCF));
if (NULL == obj) {
*ppobj = (LPCLASSFACTORY)NULL;
return E_OUTOFMEMORY;
}
obj->lpVtbl = &DirectMusicLoaderCF_Vtbl;
obj->dwRef = 0; /* will be inited with QueryInterface */
/* increase number of instances */
InterlockedIncrement (&dwDirectMusicLoader);
return IDirectMusicLoaderCF_QueryInterface ((LPCLASSFACTORY)obj, lpcGUID, ppobj);
}
/*****************************************************************************
* IDirectMusicContainerCF implementation
*/
HRESULT WINAPI IDirectMusicContainerCF_QueryInterface (LPCLASSFACTORY iface, REFIID riid, LPVOID *ppobj) {
ICOM_THIS(IDirectMusicContainerCF, iface);
TRACE("(%p, %s, %p)\n", This, debugstr_dmguid(riid), ppobj);
if (IsEqualIID (riid, &IID_IUnknown) ||
IsEqualIID (riid, &IID_IClassFactory)) {
IDirectMusicContainerCF_AddRef (iface);
*ppobj = This;
return S_OK;
}
WARN(": not found\n");
return E_NOINTERFACE;
}
ULONG WINAPI IDirectMusicContainerCF_AddRef (LPCLASSFACTORY iface) {
ICOM_THIS(IDirectMusicContainerCF, iface);
TRACE("(%p): AddRef from %ld\n", This, This->dwRef);
return InterlockedIncrement (&This->dwRef);
}
ULONG WINAPI IDirectMusicContainerCF_Release (LPCLASSFACTORY iface) {
ICOM_THIS(IDirectMusicContainerCF, iface);
DWORD dwRef = InterlockedDecrement (&This->dwRef);
TRACE("(%p): ReleaseRef to %ld\n", This, dwRef);
if (dwRef == 0) {
HeapFree(GetProcessHeap (), 0, This);
/* decrease number of instances */
InterlockedDecrement(&dwDirectMusicContainer);
}
return dwRef;
}
HRESULT WINAPI IDirectMusicContainerCF_CreateInstance (LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) {
ICOM_THIS(IDirectMusicContainerCF, iface);
TRACE ("(%p, %p, %s, %p)\n", This, pOuter, debugstr_dmguid(riid), ppobj);
if (pOuter) {
ERR(": pOuter should be NULL\n");
return CLASS_E_NOAGGREGATION;
}
return DMUSIC_CreateDirectMusicContainerImpl (riid, ppobj, pOuter);
}
HRESULT WINAPI IDirectMusicContainerCF_LockServer (LPCLASSFACTORY iface, BOOL dolock) {
ICOM_THIS(IDirectMusicContainerCF, iface);
TRACE("(%p, %d)\n", This, dolock);
if (dolock == TRUE)
InterlockedIncrement (&dwDirectMusicContainer);
else
InterlockedDecrement (&dwDirectMusicContainer);
return S_OK;
}
ICOM_VTABLE(IClassFactory) DirectMusicContainerCF_Vtbl = {
ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
IDirectMusicContainerCF_QueryInterface,
IDirectMusicContainerCF_AddRef,
IDirectMusicContainerCF_Release,
IDirectMusicContainerCF_CreateInstance,
IDirectMusicContainerCF_LockServer
};
HRESULT WINAPI DMUSIC_CreateDirectMusicContainerCF (LPCGUID lpcGUID, LPVOID *ppobj, LPUNKNOWN pUnkOuter) {
IDirectMusicContainerCF *obj;
TRACE("(%s, %p, %p)\n", debugstr_dmguid(lpcGUID), ppobj, pUnkOuter);
obj = HeapAlloc (GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicContainerCF));
if (NULL == obj) {
*ppobj = (LPCLASSFACTORY)NULL;
return E_OUTOFMEMORY;
}
obj->lpVtbl = &DirectMusicContainerCF_Vtbl;
obj->dwRef = 0; /* will be inited with QueryInterface */
/* increase number of instances */
InterlockedIncrement (&dwDirectMusicContainer);
return IDirectMusicContainerCF_QueryInterface ((LPCLASSFACTORY)obj, lpcGUID, ppobj);
}

File diff suppressed because it is too large Load Diff

536
dlls/dmloader/debug.c Normal file
View File

@ -0,0 +1,536 @@
/* Debug and Helper Functions
*
* Copyright (C) 2004 Rok Mandeljc
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 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 Library General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "dmloader_private.h"
/* check whether the given DWORD is even (return 0) or odd (return 1) */
int even_or_odd (DWORD number) {
return (number & 0x1); /* basically, check if bit 0 is set ;) */
}
/* figures out whether given FOURCC is valid DirectMusic form ID */
BOOL IS_VALID_DMFORM (FOURCC chunkID) {
if ((chunkID == DMUS_FOURCC_AUDIOPATH_FORM) || (chunkID == DMUS_FOURCC_BAND_FORM) || (chunkID == DMUS_FOURCC_CHORDMAP_FORM)
|| (chunkID == DMUS_FOURCC_CONTAINER_FORM) || (chunkID == FOURCC_DLS) || (chunkID == DMUS_FOURCC_SCRIPT_FORM)
|| (chunkID == DMUS_FOURCC_SEGMENT_FORM) || (chunkID == DMUS_FOURCC_STYLE_FORM) || (chunkID == DMUS_FOURCC_TOOLGRAPH_FORM)
|| (chunkID == DMUS_FOURCC_TRACK_FORM) || (chunkID == mmioFOURCC('W','A','V','E'))) return TRUE;
else return FALSE;
}
/* translate STREAM_SEEK flag to string */
const char *resolve_STREAM_SEEK (DWORD flag) {
switch (flag) {
case STREAM_SEEK_SET:
return wine_dbg_sprintf ("STREAM_SEEK_SET");
case STREAM_SEEK_CUR:
return wine_dbg_sprintf ("STREAM_SEEK_CUR");
case STREAM_SEEK_END:
return wine_dbg_sprintf ("STREAM_SEEK_END");
default:
return wine_dbg_sprintf ("()");
}
}
/* FOURCC to string conversion for debug messages */
const char *debugstr_fourcc (DWORD fourcc) {
if (!fourcc) return "'null'";
return wine_dbg_sprintf ("\'%c%c%c%c\'",
(char)(fourcc), (char)(fourcc >> 8),
(char)(fourcc >> 16), (char)(fourcc >> 24));
}
/* DMUS_VERSION struct to string conversion for debug messages */
const char *debugstr_dmversion (LPDMUS_VERSION version) {
if (!version) return "'null'";
return wine_dbg_sprintf ("\'%i,%i,%i,%i\'",
HIWORD(version->dwVersionMS),LOWORD(version->dwVersionMS),
HIWORD(version->dwVersionLS), LOWORD(version->dwVersionLS));
}
/* month number into month name (for debugstr_filetime) */
const char *debugstr_month (DWORD dwMonth) {
switch (dwMonth) {
case 1: return "January";
case 2: return "February";
case 3: return "March";
case 4: return "April";
case 5: return "May";
case 6: return "June";
case 7: return "July";
case 8: return "August";
case 9: return "September";
case 10: return "October";
case 11: return "November";
case 12: return "December";
default: return "Invalid";
}
}
/* FILETIME struct to string conversion for debug messages */
const char *debugstr_filetime (LPFILETIME time) {
SYSTEMTIME sysTime;
if (!time) return "'null'";
FileTimeToSystemTime (time, &sysTime);
return wine_dbg_sprintf ("\'%02i. %s %04i %02i:%02i:%02i\'", \
sysTime.wDay, debugstr_month(sysTime.wMonth), sysTime.wYear,
sysTime.wHour, sysTime.wMinute, sysTime.wSecond);
}
/* returns name of given GUID */
const char *debugstr_dmguid (const GUID *id) {
static const guid_info guids[] = {
/* CLSIDs */
GE(CLSID_AudioVBScript),
GE(CLSID_DirectMusic),
GE(CLSID_DirectMusicAudioPath),
GE(CLSID_DirectMusicAudioPathConfig),
GE(CLSID_DirectMusicAuditionTrack),
GE(CLSID_DirectMusicBand),
GE(CLSID_DirectMusicBandTrack),
GE(CLSID_DirectMusicChordMapTrack),
GE(CLSID_DirectMusicChordMap),
GE(CLSID_DirectMusicChordTrack),
GE(CLSID_DirectMusicCollection),
GE(CLSID_DirectMusicCommandTrack),
GE(CLSID_DirectMusicComposer),
GE(CLSID_DirectMusicContainer),
GE(CLSID_DirectMusicGraph),
GE(CLSID_DirectMusicLoader),
GE(CLSID_DirectMusicLyricsTrack),
GE(CLSID_DirectMusicMarkerTrack),
GE(CLSID_DirectMusicMelodyFormulationTrack),
GE(CLSID_DirectMusicMotifTrack),
GE(CLSID_DirectMusicMuteTrack),
GE(CLSID_DirectMusicParamControlTrack),
GE(CLSID_DirectMusicPatternTrack),
GE(CLSID_DirectMusicPerformance),
GE(CLSID_DirectMusicScript),
GE(CLSID_DirectMusicScriptAutoImpSegment),
GE(CLSID_DirectMusicScriptAutoImpPerformance),
GE(CLSID_DirectMusicScriptAutoImpSegmentState),
GE(CLSID_DirectMusicScriptAutoImpAudioPathConfig),
GE(CLSID_DirectMusicScriptAutoImpAudioPath),
GE(CLSID_DirectMusicScriptAutoImpSong),
GE(CLSID_DirectMusicScriptSourceCodeLoader),
GE(CLSID_DirectMusicScriptTrack),
GE(CLSID_DirectMusicSection),
GE(CLSID_DirectMusicSegment),
GE(CLSID_DirectMusicSegmentState),
GE(CLSID_DirectMusicSegmentTriggerTrack),
GE(CLSID_DirectMusicSegTriggerTrack),
GE(CLSID_DirectMusicSeqTrack),
GE(CLSID_DirectMusicSignPostTrack),
GE(CLSID_DirectMusicSong),
GE(CLSID_DirectMusicStyle),
GE(CLSID_DirectMusicStyleTrack),
GE(CLSID_DirectMusicSynth),
GE(CLSID_DirectMusicSynthSink),
GE(CLSID_DirectMusicSysExTrack),
GE(CLSID_DirectMusicTemplate),
GE(CLSID_DirectMusicTempoTrack),
GE(CLSID_DirectMusicTimeSigTrack),
GE(CLSID_DirectMusicWaveTrack),
GE(CLSID_DirectSoundWave),
/* IIDs */
GE(IID_IDirectMusic),
GE(IID_IDirectMusic2),
GE(IID_IDirectMusic8),
GE(IID_IDirectMusicAudioPath),
GE(IID_IDirectMusicBand),
GE(IID_IDirectMusicBuffer),
GE(IID_IDirectMusicChordMap),
GE(IID_IDirectMusicCollection),
GE(IID_IDirectMusicComposer),
GE(IID_IDirectMusicContainer),
GE(IID_IDirectMusicDownload),
GE(IID_IDirectMusicDownloadedInstrument),
GE(IID_IDirectMusicGetLoader),
GE(IID_IDirectMusicGraph),
GE(IID_IDirectMusicInstrument),
GE(IID_IDirectMusicLoader),
GE(IID_IDirectMusicLoader8),
GE(IID_IDirectMusicObject),
GE(IID_IDirectMusicPatternTrack),
GE(IID_IDirectMusicPerformance),
GE(IID_IDirectMusicPerformance2),
GE(IID_IDirectMusicPerformance8),
GE(IID_IDirectMusicPort),
GE(IID_IDirectMusicPortDownload),
GE(IID_IDirectMusicScript),
GE(IID_IDirectMusicSegment),
GE(IID_IDirectMusicSegment2),
GE(IID_IDirectMusicSegment8),
GE(IID_IDirectMusicSegmentState),
GE(IID_IDirectMusicSegmentState8),
GE(IID_IDirectMusicStyle),
GE(IID_IDirectMusicStyle8),
GE(IID_IDirectMusicSynth),
GE(IID_IDirectMusicSynth8),
GE(IID_IDirectMusicSynthSink),
GE(IID_IDirectMusicThru),
GE(IID_IDirectMusicTool),
GE(IID_IDirectMusicTool8),
GE(IID_IDirectMusicTrack),
GE(IID_IDirectMusicTrack8),
GE(IID_IUnknown),
GE(IID_IPersistStream),
GE(IID_IStream),
GE(IID_IClassFactory),
/* GUIDs */
GE(GUID_DirectMusicAllTypes),
GE(GUID_NOTIFICATION_CHORD),
GE(GUID_NOTIFICATION_COMMAND),
GE(GUID_NOTIFICATION_MEASUREANDBEAT),
GE(GUID_NOTIFICATION_PERFORMANCE),
GE(GUID_NOTIFICATION_RECOMPOSE),
GE(GUID_NOTIFICATION_SEGMENT),
GE(GUID_BandParam),
GE(GUID_ChordParam),
GE(GUID_CommandParam),
GE(GUID_CommandParam2),
GE(GUID_CommandParamNext),
GE(GUID_IDirectMusicBand),
GE(GUID_IDirectMusicChordMap),
GE(GUID_IDirectMusicStyle),
GE(GUID_MuteParam),
GE(GUID_Play_Marker),
GE(GUID_RhythmParam),
GE(GUID_TempoParam),
GE(GUID_TimeSignature),
GE(GUID_Valid_Start_Time),
GE(GUID_Clear_All_Bands),
GE(GUID_ConnectToDLSCollection),
GE(GUID_Disable_Auto_Download),
GE(GUID_DisableTempo),
GE(GUID_DisableTimeSig),
GE(GUID_Download),
GE(GUID_DownloadToAudioPath),
GE(GUID_Enable_Auto_Download),
GE(GUID_EnableTempo),
GE(GUID_EnableTimeSig),
GE(GUID_IgnoreBankSelectForGM),
GE(GUID_SeedVariations),
GE(GUID_StandardMIDIFile),
GE(GUID_Unload),
GE(GUID_UnloadFromAudioPath),
GE(GUID_Variations),
GE(GUID_PerfMasterTempo),
GE(GUID_PerfMasterVolume),
GE(GUID_PerfMasterGrooveLevel),
GE(GUID_PerfAutoDownload),
GE(GUID_DefaultGMCollection),
GE(GUID_Synth_Default),
GE(GUID_Buffer_Reverb),
GE(GUID_Buffer_EnvReverb),
GE(GUID_Buffer_Stereo),
GE(GUID_Buffer_3D_Dry),
GE(GUID_Buffer_Mono),
GE(GUID_DMUS_PROP_GM_Hardware),
GE(GUID_DMUS_PROP_GS_Capable),
GE(GUID_DMUS_PROP_GS_Hardware),
GE(GUID_DMUS_PROP_DLS1),
GE(GUID_DMUS_PROP_DLS2),
GE(GUID_DMUS_PROP_Effects),
GE(GUID_DMUS_PROP_INSTRUMENT2),
GE(GUID_DMUS_PROP_LegacyCaps),
GE(GUID_DMUS_PROP_MemorySize),
GE(GUID_DMUS_PROP_SampleMemorySize),
GE(GUID_DMUS_PROP_SamplePlaybackRate),
GE(GUID_DMUS_PROP_SetSynthSink),
GE(GUID_DMUS_PROP_SinkUsesDSound),
GE(GUID_DMUS_PROP_SynthSink_DSOUND),
GE(GUID_DMUS_PROP_SynthSink_WAVE),
GE(GUID_DMUS_PROP_Volume),
GE(GUID_DMUS_PROP_WavesReverb),
GE(GUID_DMUS_PROP_WriteLatency),
GE(GUID_DMUS_PROP_WritePeriod),
GE(GUID_DMUS_PROP_XG_Capable),
GE(GUID_DMUS_PROP_XG_Hardware)
};
unsigned int i;
if (!id) return "(null)";
for (i = 0; i < sizeof(guids)/sizeof(guids[0]); i++) {
if (IsEqualGUID(id, guids[i].guid))
return guids[i].name;
}
/* if we didn't find it, act like standard debugstr_guid */
return debugstr_guid(id);
}
/* returns name of given error code */
const char *debugstr_dmreturn (DWORD code) {
static const flag_info codes[] = {
FE(S_OK),
FE(S_FALSE),
FE(DMUS_S_PARTIALLOAD),
FE(DMUS_S_PARTIALDOWNLOAD),
FE(DMUS_S_REQUEUE),
FE(DMUS_S_FREE),
FE(DMUS_S_END),
FE(DMUS_S_STRING_TRUNCATED),
FE(DMUS_S_LAST_TOOL),
FE(DMUS_S_OVER_CHORD),
FE(DMUS_S_UP_OCTAVE),
FE(DMUS_S_DOWN_OCTAVE),
FE(DMUS_S_NOBUFFERCONTROL),
FE(DMUS_S_GARBAGE_COLLECTED),
FE(E_NOTIMPL),
FE(E_NOINTERFACE),
FE(E_POINTER),
FE(CLASS_E_NOAGGREGATION),
FE(CLASS_E_CLASSNOTAVAILABLE),
FE(REGDB_E_CLASSNOTREG),
FE(E_OUTOFMEMORY),
FE(E_FAIL),
FE(E_INVALIDARG),
FE(DMUS_E_DRIVER_FAILED),
FE(DMUS_E_PORTS_OPEN),
FE(DMUS_E_DEVICE_IN_USE),
FE(DMUS_E_INSUFFICIENTBUFFER),
FE(DMUS_E_BUFFERNOTSET),
FE(DMUS_E_BUFFERNOTAVAILABLE),
FE(DMUS_E_NOTADLSCOL),
FE(DMUS_E_INVALIDOFFSET),
FE(DMUS_E_ALREADY_LOADED),
FE(DMUS_E_INVALIDPOS),
FE(DMUS_E_INVALIDPATCH),
FE(DMUS_E_CANNOTSEEK),
FE(DMUS_E_CANNOTWRITE),
FE(DMUS_E_CHUNKNOTFOUND),
FE(DMUS_E_INVALID_DOWNLOADID),
FE(DMUS_E_NOT_DOWNLOADED_TO_PORT),
FE(DMUS_E_ALREADY_DOWNLOADED),
FE(DMUS_E_UNKNOWN_PROPERTY),
FE(DMUS_E_SET_UNSUPPORTED),
FE(DMUS_E_GET_UNSUPPORTED),
FE(DMUS_E_NOTMONO),
FE(DMUS_E_BADARTICULATION),
FE(DMUS_E_BADINSTRUMENT),
FE(DMUS_E_BADWAVELINK),
FE(DMUS_E_NOARTICULATION),
FE(DMUS_E_NOTPCM),
FE(DMUS_E_BADWAVE),
FE(DMUS_E_BADOFFSETTABLE),
FE(DMUS_E_UNKNOWNDOWNLOAD),
FE(DMUS_E_NOSYNTHSINK),
FE(DMUS_E_ALREADYOPEN),
FE(DMUS_E_ALREADYCLOSED),
FE(DMUS_E_SYNTHNOTCONFIGURED),
FE(DMUS_E_SYNTHACTIVE),
FE(DMUS_E_CANNOTREAD),
FE(DMUS_E_DMUSIC_RELEASED),
FE(DMUS_E_BUFFER_EMPTY),
FE(DMUS_E_BUFFER_FULL),
FE(DMUS_E_PORT_NOT_CAPTURE),
FE(DMUS_E_PORT_NOT_RENDER),
FE(DMUS_E_DSOUND_NOT_SET),
FE(DMUS_E_ALREADY_ACTIVATED),
FE(DMUS_E_INVALIDBUFFER),
FE(DMUS_E_WAVEFORMATNOTSUPPORTED),
FE(DMUS_E_SYNTHINACTIVE),
FE(DMUS_E_DSOUND_ALREADY_SET),
FE(DMUS_E_INVALID_EVENT),
FE(DMUS_E_UNSUPPORTED_STREAM),
FE(DMUS_E_ALREADY_INITED),
FE(DMUS_E_INVALID_BAND),
FE(DMUS_E_TRACK_HDR_NOT_FIRST_CK),
FE(DMUS_E_TOOL_HDR_NOT_FIRST_CK),
FE(DMUS_E_INVALID_TRACK_HDR),
FE(DMUS_E_INVALID_TOOL_HDR),
FE(DMUS_E_ALL_TOOLS_FAILED),
FE(DMUS_E_ALL_TRACKS_FAILED),
FE(DMUS_E_NOT_FOUND),
FE(DMUS_E_NOT_INIT),
FE(DMUS_E_TYPE_DISABLED),
FE(DMUS_E_TYPE_UNSUPPORTED),
FE(DMUS_E_TIME_PAST),
FE(DMUS_E_TRACK_NOT_FOUND),
FE(DMUS_E_TRACK_NO_CLOCKTIME_SUPPORT),
FE(DMUS_E_NO_MASTER_CLOCK),
FE(DMUS_E_LOADER_NOCLASSID),
FE(DMUS_E_LOADER_BADPATH),
FE(DMUS_E_LOADER_FAILEDOPEN),
FE(DMUS_E_LOADER_FORMATNOTSUPPORTED),
FE(DMUS_E_LOADER_FAILEDCREATE),
FE(DMUS_E_LOADER_OBJECTNOTFOUND),
FE(DMUS_E_LOADER_NOFILENAME),
FE(DMUS_E_INVALIDFILE),
FE(DMUS_E_ALREADY_EXISTS),
FE(DMUS_E_OUT_OF_RANGE),
FE(DMUS_E_SEGMENT_INIT_FAILED),
FE(DMUS_E_ALREADY_SENT),
FE(DMUS_E_CANNOT_FREE),
FE(DMUS_E_CANNOT_OPEN_PORT),
FE(DMUS_E_CANNOT_CONVERT),
FE(DMUS_E_DESCEND_CHUNK_FAIL),
FE(DMUS_E_NOT_LOADED),
FE(DMUS_E_SCRIPT_LANGUAGE_INCOMPATIBLE),
FE(DMUS_E_SCRIPT_UNSUPPORTED_VARTYPE),
FE(DMUS_E_SCRIPT_ERROR_IN_SCRIPT),
FE(DMUS_E_SCRIPT_CANTLOAD_OLEAUT32),
FE(DMUS_E_SCRIPT_LOADSCRIPT_ERROR),
FE(DMUS_E_SCRIPT_INVALID_FILE),
FE(DMUS_E_INVALID_SCRIPTTRACK),
FE(DMUS_E_SCRIPT_VARIABLE_NOT_FOUND),
FE(DMUS_E_SCRIPT_ROUTINE_NOT_FOUND),
FE(DMUS_E_SCRIPT_CONTENT_READONLY),
FE(DMUS_E_SCRIPT_NOT_A_REFERENCE),
FE(DMUS_E_SCRIPT_VALUE_NOT_SUPPORTED),
FE(DMUS_E_INVALID_SEGMENTTRIGGERTRACK),
FE(DMUS_E_INVALID_LYRICSTRACK),
FE(DMUS_E_INVALID_PARAMCONTROLTRACK),
FE(DMUS_E_AUDIOVBSCRIPT_SYNTAXERROR),
FE(DMUS_E_AUDIOVBSCRIPT_RUNTIMEERROR),
FE(DMUS_E_AUDIOVBSCRIPT_OPERATIONFAILURE),
FE(DMUS_E_AUDIOPATHS_NOT_VALID),
FE(DMUS_E_AUDIOPATHS_IN_USE),
FE(DMUS_E_NO_AUDIOPATH_CONFIG),
FE(DMUS_E_AUDIOPATH_INACTIVE),
FE(DMUS_E_AUDIOPATH_NOBUFFER),
FE(DMUS_E_AUDIOPATH_NOPORT),
FE(DMUS_E_NO_AUDIOPATH),
FE(DMUS_E_INVALIDCHUNK),
FE(DMUS_E_AUDIOPATH_NOGLOBALFXBUFFER),
FE(DMUS_E_INVALID_CONTAINER_OBJECT)
};
unsigned int i;
for (i = 0; i < sizeof(codes)/sizeof(codes[0]); i++) {
if (code == codes[i].val)
return codes[i].name;
}
/* if we didn't find it, return value */
return wine_dbg_sprintf("0x%08lX", code);
}
/* generic flag-dumping function */
const char* debugstr_flags (DWORD flags, const flag_info* names, size_t num_names){
static char buffer[128] = "", *ptr = &buffer[0];
unsigned int i, size = sizeof(buffer);
for (i=0; i < num_names; i++) {
if ((flags & names[i].val)) {
int cnt = snprintf(ptr, size, "%s ", names[i].name);
if (cnt < 0 || cnt >= size) break;
size -= cnt;
ptr += cnt;
}
}
ptr = &buffer[0];
return ptr;
}
/* dump DMUS_OBJ flags */
const char *debugstr_DMUS_OBJ_FLAGS (DWORD flagmask) {
static const flag_info flags[] = {
FE(DMUS_OBJ_OBJECT),
FE(DMUS_OBJ_CLASS),
FE(DMUS_OBJ_NAME),
FE(DMUS_OBJ_CATEGORY),
FE(DMUS_OBJ_FILENAME),
FE(DMUS_OBJ_FULLPATH),
FE(DMUS_OBJ_URL),
FE(DMUS_OBJ_VERSION),
FE(DMUS_OBJ_DATE),
FE(DMUS_OBJ_LOADED),
FE(DMUS_OBJ_MEMORY),
FE(DMUS_OBJ_STREAM)
};
return debugstr_flags (flagmask, flags, sizeof(flags)/sizeof(flags[0]));
}
/* dump DMUS_CONTAINER flags */
const char *debugstr_DMUS_CONTAINER_FLAGS (DWORD flagmask) {
static const flag_info flags[] = {
FE(DMUS_CONTAINER_NOLOADS)
};
return debugstr_flags (flagmask, flags, sizeof(flags)/sizeof(flags[0]));
}
/* dump DMUS_CONTAINED_OBJF flags */
const char *debugstr_DMUS_CONTAINED_OBJF_FLAGS (DWORD flagmask) {
static const flag_info flags[] = {
FE(DMUS_CONTAINED_OBJF_KEEP)
};
return debugstr_flags (flagmask, flags, sizeof(flags)/sizeof(flags[0]));
}
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 = 0x%08lX\n", pDesc->dwSize);
ptr += sprintf(ptr, " - dwValidData = 0x%08lX ( %s)\n", pDesc->dwValidData, 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 = %s\n", debugstr_filetime (&pDesc->ftDate));
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 = %lli\n - pbMemData = %p\n", pDesc->llMemLength, pDesc->pbMemData);
if (pDesc->dwValidData & DMUS_OBJ_STREAM) ptr += sprintf(ptr, " - pStream = %p\n", pDesc->pStream);
ptr = &buffer[0];
return ptr;
} else {
return wine_dbg_sprintf("(NULL)");
}
}
const char *debugstr_DMUS_IO_CONTAINER_HEADER (LPDMUS_IO_CONTAINER_HEADER pHeader) {
if (pHeader) {
char buffer[1024] = "", *ptr = &buffer[0];
ptr += sprintf(ptr, "DMUS_IO_CONTAINER_HEADER (%p):\n", pHeader);
ptr += sprintf(ptr, " - dwFlags = %s\n", debugstr_DMUS_CONTAINER_FLAGS(pHeader->dwFlags));
ptr = &buffer[0];
return ptr;
} else {
return wine_dbg_sprintf("(NULL)");
}
}
const char *debugstr_DMUS_IO_CONTAINED_OBJECT_HEADER (LPDMUS_IO_CONTAINED_OBJECT_HEADER pHeader) {
if (pHeader) {
char buffer[1024] = "", *ptr = &buffer[0];
ptr += sprintf(ptr, "DMUS_IO_CONTAINED_OBJECT_HEADER (%p):\n", pHeader);
ptr += sprintf(ptr, " - guidClassID = %s\n", debugstr_dmguid(&pHeader->guidClassID));
ptr += sprintf(ptr, " - dwFlags = %s\n", debugstr_DMUS_CONTAINED_OBJF_FLAGS (pHeader->dwFlags));
ptr += sprintf(ptr, " - ckid = %s\n", debugstr_fourcc (pHeader->ckid));
ptr += sprintf(ptr, " - fccType = %s\n", debugstr_fourcc (pHeader->fccType));
ptr = &buffer[0];
return ptr;
} else {
return wine_dbg_sprintf("(NULL)");
}
}

71
dlls/dmloader/debug.h Normal file
View File

@ -0,0 +1,71 @@
/* Debug and Helper Functions
*
* 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 General Public License as published by
* the Free Software Foundation; either version 2 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 Library General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __WINE_DMLOADER_DEBUG_H
#define __WINE_DMLOADER_DEBUG_H
/* used for generic dumping (copied from ddraw) */
typedef struct {
DWORD val;
const char* name;
} flag_info;
typedef struct {
const GUID *guid;
const char* name;
} guid_info;
/* used for initialising structs */
#define DM_STRUCT_INIT(x) \
do { \
memset((x), 0, sizeof(*(x))); \
(x)->dwSize = sizeof(*x); \
} while (0)
#define FE(x) { x, #x }
#define GE(x) { &x, #x }
/* check whether the given DWORD is even (return 0) or odd (return 1) */
extern int even_or_odd (DWORD number);
/* check whether chunkID is valid dmobject form chunk */
extern BOOL IS_VALID_DMFORM (FOURCC chunkID);
/* translate STREAM_SEEK flag to string */
extern const char *resolve_STREAM_SEEK (DWORD flag);
/* FOURCC to string conversion for debug messages */
extern const char *debugstr_fourcc (DWORD fourcc);
/* DMUS_VERSION struct to string conversion for debug messages */
extern const char *debugstr_dmversion (LPDMUS_VERSION version);
/* FILETIME struct to string conversion for debug messages */
extern const char *debugstr_filetime (LPFILETIME time);
/* returns name of given GUID */
extern const char *debugstr_dmguid (const GUID *id);
/* returns name of given error code */
extern const char *debugstr_dmreturn (DWORD code);
/* generic flags-dumping function */
extern const char *debugstr_flags (DWORD flags, const flag_info* names, size_t num_names);
extern const char *debugstr_DMUS_OBJ_FLAGS (DWORD flagmask);
extern const char *debugstr_DMUS_CONTAINER_FLAGS (DWORD flagmask);
extern const char *debugstr_DMUS_CONTAINED_OBJF_FLAGS (DWORD flagmask);
/* dump whole DMUS_OBJECTDESC struct */
extern const char *debugstr_DMUS_OBJECTDESC (LPDMUS_OBJECTDESC pDesc);
extern const char *debugstr_DMUS_IO_CONTAINER_HEADER (LPDMUS_IO_CONTAINER_HEADER pHeader);
extern const char *debugstr_DMUS_IO_CONTAINED_OBJECT_HEADER (LPDMUS_IO_CONTAINED_OBJECT_HEADER pHeader);
#endif /* __WINE_DMLOADER_DEBUG_H */

View File

@ -21,109 +21,17 @@
WINE_DEFAULT_DEBUG_CHANNEL(dmloader);
typedef struct {
/* IUnknown fields */
ICOM_VFIELD(IClassFactory);
DWORD ref;
} IClassFactoryImpl;
/******************************************************************
* DirectMusicLoader ClassFactory
*/
static HRESULT WINAPI LoaderCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
ICOM_THIS(IClassFactoryImpl,iface);
FIXME("(%p, %s, %p): stub\n", This, debugstr_dmguid(riid), ppobj);
return E_NOINTERFACE;
}
static ULONG WINAPI LoaderCF_AddRef(LPCLASSFACTORY iface) {
ICOM_THIS(IClassFactoryImpl,iface);
return ++(This->ref);
}
static ULONG WINAPI LoaderCF_Release(LPCLASSFACTORY iface) {
ICOM_THIS(IClassFactoryImpl,iface);
/* static class, won't be freed */
return --(This->ref);
}
static HRESULT WINAPI LoaderCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) {
ICOM_THIS(IClassFactoryImpl,iface);
TRACE ("(%p, %p, %s, %p)\n", This, pOuter, debugstr_dmguid(riid), ppobj);
return DMUSIC_CreateDirectMusicLoaderImpl (riid, (LPVOID*) ppobj, pOuter);
}
static HRESULT WINAPI LoaderCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
ICOM_THIS(IClassFactoryImpl,iface);
FIXME("(%p, %d): stub\n", This, dolock);
return S_OK;
}
static ICOM_VTABLE(IClassFactory) LoaderCF_Vtbl = {
ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
LoaderCF_QueryInterface,
LoaderCF_AddRef,
LoaderCF_Release,
LoaderCF_CreateInstance,
LoaderCF_LockServer
};
static IClassFactoryImpl Loader_CF = {&LoaderCF_Vtbl, 1 };
/******************************************************************
* DirectMusicContainer ClassFactory
*/
static HRESULT WINAPI ContainerCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
ICOM_THIS(IClassFactoryImpl,iface);
FIXME("(%p, %s, %p): stub\n", This, debugstr_dmguid(riid), ppobj);
return E_NOINTERFACE;
}
static ULONG WINAPI ContainerCF_AddRef(LPCLASSFACTORY iface) {
ICOM_THIS(IClassFactoryImpl,iface);
return ++(This->ref);
}
static ULONG WINAPI ContainerCF_Release(LPCLASSFACTORY iface) {
ICOM_THIS(IClassFactoryImpl,iface);
/* static class, won't be freed */
return --(This->ref);
}
static HRESULT WINAPI ContainerCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) {
ICOM_THIS(IClassFactoryImpl,iface);
TRACE ("(%p, %p, %s, %p)\n", This, pOuter, debugstr_dmguid(riid), ppobj);
return DMUSIC_CreateDirectMusicContainerImpl (riid, (LPVOID*) ppobj, pOuter);
}
static HRESULT WINAPI ContainerCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
ICOM_THIS(IClassFactoryImpl,iface);
FIXME("(%p, %d): stub!\n", This, dolock);
return S_OK;
}
static ICOM_VTABLE(IClassFactory) ContainerCF_Vtbl = {
ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
ContainerCF_QueryInterface,
ContainerCF_AddRef,
ContainerCF_Release,
ContainerCF_CreateInstance,
ContainerCF_LockServer
};
static IClassFactoryImpl Container_CF = {&ContainerCF_Vtbl, 1 };
DWORD dwDirectMusicContainer = 0;
DWORD dwDirectMusicLoader = 0;
/******************************************************************
* DllMain
*
*
*/
BOOL WINAPI DllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {
if (fdwReason == DLL_PROCESS_ATTACH) {
DisableThreadLibraryCalls(hinstDLL);
/* FIXME: Initialisation */
}
else if (fdwReason == DLL_PROCESS_DETACH) {
} else if (fdwReason == DLL_PROCESS_DETACH) {
/* FIXME: Cleanup */
}
return TRUE;
@ -132,463 +40,28 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {
/******************************************************************
* DllCanUnloadNow (DMLOADER.1)
*
*
*/
HRESULT WINAPI DMLOADER_DllCanUnloadNow (void) {
FIXME("(void): stub\n");
TRACE("(void)\n");
/* if there are no instances left, it's safe to release */
if (!dwDirectMusicContainer && !dwDirectMusicLoader)
return S_OK;
else
return S_FALSE;
}
/******************************************************************
* DllGetClassObject (DMLOADER.2)
*
*
*/
HRESULT WINAPI DMLOADER_DllGetClassObject (REFCLSID rclsid, REFIID riid, LPVOID *ppv) {
TRACE("(%s, %s, %p)\n", debugstr_dmguid(rclsid), debugstr_dmguid(riid), ppv);
if (IsEqualCLSID (rclsid, &CLSID_DirectMusicLoader) && IsEqualIID (riid, &IID_IClassFactory)) {
*ppv = (LPVOID) &Loader_CF;
IClassFactory_AddRef((IClassFactory*)*ppv);
return S_OK;
return DMUSIC_CreateDirectMusicLoaderCF (riid, ppv, NULL);
} else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicContainer) && IsEqualIID (riid, &IID_IClassFactory)) {
*ppv = (LPVOID) &Container_CF;
IClassFactory_AddRef((IClassFactory*)*ppv);
return S_OK;
return DMUSIC_CreateDirectMusicContainerCF (riid, ppv, NULL);
}
WARN("(%s, %s, %p): no interface found.\n", debugstr_dmguid(rclsid), debugstr_dmguid(riid), ppv);
WARN(": no class found\n");
return CLASS_E_CLASSNOTAVAILABLE;
}
/******************************************************************
* Helper functions
*
*
*/
/* check whether the given DWORD is even (return 0) or odd (return 1) */
int even_or_odd (DWORD number) {
return (number & 0x1); /* basically, check if bit 0 is set ;) */
}
/* translate STREAM_SEEK flag to string */
const char *resolve_STREAM_SEEK (DWORD flag) {
switch (flag) {
case STREAM_SEEK_SET:
return wine_dbg_sprintf ("STREAM_SEEK_SET");
case STREAM_SEEK_CUR:
return wine_dbg_sprintf ("STREAM_SEEK_CUR");
case STREAM_SEEK_END:
return wine_dbg_sprintf ("STREAM_SEEK_END");
default:
return wine_dbg_sprintf ("()");
}
}
/* FOURCC to string conversion for debug messages */
const char *debugstr_fourcc (DWORD fourcc) {
if (!fourcc) return "'null'";
return wine_dbg_sprintf ("\'%c%c%c%c\'",
(char)(fourcc), (char)(fourcc >> 8),
(char)(fourcc >> 16), (char)(fourcc >> 24));
}
/* DMUS_VERSION struct to string conversion for debug messages */
const char *debugstr_dmversion (LPDMUS_VERSION version) {
if (!version) return "'null'";
return wine_dbg_sprintf ("\'%i,%i,%i,%i\'",
(int)((version->dwVersionMS && 0xFFFF0000) >> 8), (int)(version->dwVersionMS && 0x0000FFFF),
(int)((version->dwVersionLS && 0xFFFF0000) >> 8), (int)(version->dwVersionLS && 0x0000FFFF));
}
/* returns name of given GUID */
const char *debugstr_dmguid (const GUID *id) {
static const guid_info guids[] = {
/* CLSIDs */
GE(CLSID_AudioVBScript),
GE(CLSID_DirectMusic),
GE(CLSID_DirectMusicAudioPath),
GE(CLSID_DirectMusicAudioPathConfig),
GE(CLSID_DirectMusicAuditionTrack),
GE(CLSID_DirectMusicBand),
GE(CLSID_DirectMusicBandTrack),
GE(CLSID_DirectMusicChordMapTrack),
GE(CLSID_DirectMusicChordMap),
GE(CLSID_DirectMusicChordTrack),
GE(CLSID_DirectMusicCollection),
GE(CLSID_DirectMusicCommandTrack),
GE(CLSID_DirectMusicComposer),
GE(CLSID_DirectMusicContainer),
GE(CLSID_DirectMusicGraph),
GE(CLSID_DirectMusicLoader),
GE(CLSID_DirectMusicLyricsTrack),
GE(CLSID_DirectMusicMarkerTrack),
GE(CLSID_DirectMusicMelodyFormulationTrack),
GE(CLSID_DirectMusicMotifTrack),
GE(CLSID_DirectMusicMuteTrack),
GE(CLSID_DirectMusicParamControlTrack),
GE(CLSID_DirectMusicPatternTrack),
GE(CLSID_DirectMusicPerformance),
GE(CLSID_DirectMusicScript),
GE(CLSID_DirectMusicScriptAutoImpSegment),
GE(CLSID_DirectMusicScriptAutoImpPerformance),
GE(CLSID_DirectMusicScriptAutoImpSegmentState),
GE(CLSID_DirectMusicScriptAutoImpAudioPathConfig),
GE(CLSID_DirectMusicScriptAutoImpAudioPath),
GE(CLSID_DirectMusicScriptAutoImpSong),
GE(CLSID_DirectMusicScriptSourceCodeLoader),
GE(CLSID_DirectMusicScriptTrack),
GE(CLSID_DirectMusicSection),
GE(CLSID_DirectMusicSegment),
GE(CLSID_DirectMusicSegmentState),
GE(CLSID_DirectMusicSegmentTriggerTrack),
GE(CLSID_DirectMusicSegTriggerTrack),
GE(CLSID_DirectMusicSeqTrack),
GE(CLSID_DirectMusicSignPostTrack),
GE(CLSID_DirectMusicSong),
GE(CLSID_DirectMusicStyle),
GE(CLSID_DirectMusicStyleTrack),
GE(CLSID_DirectMusicSynth),
GE(CLSID_DirectMusicSynthSink),
GE(CLSID_DirectMusicSysExTrack),
GE(CLSID_DirectMusicTemplate),
GE(CLSID_DirectMusicTempoTrack),
GE(CLSID_DirectMusicTimeSigTrack),
GE(CLSID_DirectMusicWaveTrack),
GE(CLSID_DirectSoundWave),
/* IIDs */
GE(IID_IDirectMusic),
GE(IID_IDirectMusic2),
GE(IID_IDirectMusic8),
GE(IID_IDirectMusicAudioPath),
GE(IID_IDirectMusicBand),
GE(IID_IDirectMusicBuffer),
GE(IID_IDirectMusicChordMap),
GE(IID_IDirectMusicCollection),
GE(IID_IDirectMusicComposer),
GE(IID_IDirectMusicContainer),
GE(IID_IDirectMusicDownload),
GE(IID_IDirectMusicDownloadedInstrument),
GE(IID_IDirectMusicGetLoader),
GE(IID_IDirectMusicGraph),
GE(IID_IDirectMusicInstrument),
GE(IID_IDirectMusicLoader),
GE(IID_IDirectMusicLoader8),
GE(IID_IDirectMusicObject),
GE(IID_IDirectMusicPatternTrack),
GE(IID_IDirectMusicPerformance),
GE(IID_IDirectMusicPerformance2),
GE(IID_IDirectMusicPerformance8),
GE(IID_IDirectMusicPort),
GE(IID_IDirectMusicPortDownload),
GE(IID_IDirectMusicScript),
GE(IID_IDirectMusicSegment),
GE(IID_IDirectMusicSegment2),
GE(IID_IDirectMusicSegment8),
GE(IID_IDirectMusicSegmentState),
GE(IID_IDirectMusicSegmentState8),
GE(IID_IDirectMusicStyle),
GE(IID_IDirectMusicStyle8),
GE(IID_IDirectMusicSynth),
GE(IID_IDirectMusicSynth8),
GE(IID_IDirectMusicSynthSink),
GE(IID_IDirectMusicThru),
GE(IID_IDirectMusicTool),
GE(IID_IDirectMusicTool8),
GE(IID_IDirectMusicTrack),
GE(IID_IDirectMusicTrack8),
GE(IID_IUnknown),
GE(IID_IPersistStream),
GE(IID_IStream),
GE(IID_IClassFactory),
/* GUIDs */
GE(GUID_DirectMusicAllTypes),
GE(GUID_NOTIFICATION_CHORD),
GE(GUID_NOTIFICATION_COMMAND),
GE(GUID_NOTIFICATION_MEASUREANDBEAT),
GE(GUID_NOTIFICATION_PERFORMANCE),
GE(GUID_NOTIFICATION_RECOMPOSE),
GE(GUID_NOTIFICATION_SEGMENT),
GE(GUID_BandParam),
GE(GUID_ChordParam),
GE(GUID_CommandParam),
GE(GUID_CommandParam2),
GE(GUID_CommandParamNext),
GE(GUID_IDirectMusicBand),
GE(GUID_IDirectMusicChordMap),
GE(GUID_IDirectMusicStyle),
GE(GUID_MuteParam),
GE(GUID_Play_Marker),
GE(GUID_RhythmParam),
GE(GUID_TempoParam),
GE(GUID_TimeSignature),
GE(GUID_Valid_Start_Time),
GE(GUID_Clear_All_Bands),
GE(GUID_ConnectToDLSCollection),
GE(GUID_Disable_Auto_Download),
GE(GUID_DisableTempo),
GE(GUID_DisableTimeSig),
GE(GUID_Download),
GE(GUID_DownloadToAudioPath),
GE(GUID_Enable_Auto_Download),
GE(GUID_EnableTempo),
GE(GUID_EnableTimeSig),
GE(GUID_IgnoreBankSelectForGM),
GE(GUID_SeedVariations),
GE(GUID_StandardMIDIFile),
GE(GUID_Unload),
GE(GUID_UnloadFromAudioPath),
GE(GUID_Variations),
GE(GUID_PerfMasterTempo),
GE(GUID_PerfMasterVolume),
GE(GUID_PerfMasterGrooveLevel),
GE(GUID_PerfAutoDownload),
GE(GUID_DefaultGMCollection),
GE(GUID_Synth_Default),
GE(GUID_Buffer_Reverb),
GE(GUID_Buffer_EnvReverb),
GE(GUID_Buffer_Stereo),
GE(GUID_Buffer_3D_Dry),
GE(GUID_Buffer_Mono),
GE(GUID_DMUS_PROP_GM_Hardware),
GE(GUID_DMUS_PROP_GS_Capable),
GE(GUID_DMUS_PROP_GS_Hardware),
GE(GUID_DMUS_PROP_DLS1),
GE(GUID_DMUS_PROP_DLS2),
GE(GUID_DMUS_PROP_Effects),
GE(GUID_DMUS_PROP_INSTRUMENT2),
GE(GUID_DMUS_PROP_LegacyCaps),
GE(GUID_DMUS_PROP_MemorySize),
GE(GUID_DMUS_PROP_SampleMemorySize),
GE(GUID_DMUS_PROP_SamplePlaybackRate),
GE(GUID_DMUS_PROP_SetSynthSink),
GE(GUID_DMUS_PROP_SinkUsesDSound),
GE(GUID_DMUS_PROP_SynthSink_DSOUND),
GE(GUID_DMUS_PROP_SynthSink_WAVE),
GE(GUID_DMUS_PROP_Volume),
GE(GUID_DMUS_PROP_WavesReverb),
GE(GUID_DMUS_PROP_WriteLatency),
GE(GUID_DMUS_PROP_WritePeriod),
GE(GUID_DMUS_PROP_XG_Capable),
GE(GUID_DMUS_PROP_XG_Hardware)
};
unsigned int i;
if (!id) return "(null)";
for (i = 0; i < sizeof(guids)/sizeof(guids[0]); i++) {
if (IsEqualGUID(id, &guids[i].guid))
return guids[i].name;
}
/* if we didn't find it, act like standard debugstr_guid */
return debugstr_guid(id);
}
/* returns name of given error code */
const char *debugstr_dmreturn (DWORD code) {
static const flag_info codes[] = {
FE(S_OK),
FE(S_FALSE),
FE(DMUS_S_PARTIALLOAD),
FE(DMUS_S_PARTIALDOWNLOAD),
FE(DMUS_S_REQUEUE),
FE(DMUS_S_FREE),
FE(DMUS_S_END),
FE(DMUS_S_STRING_TRUNCATED),
FE(DMUS_S_LAST_TOOL),
FE(DMUS_S_OVER_CHORD),
FE(DMUS_S_UP_OCTAVE),
FE(DMUS_S_DOWN_OCTAVE),
FE(DMUS_S_NOBUFFERCONTROL),
FE(DMUS_S_GARBAGE_COLLECTED),
FE(DMUS_E_DRIVER_FAILED),
FE(DMUS_E_PORTS_OPEN),
FE(DMUS_E_DEVICE_IN_USE),
FE(DMUS_E_INSUFFICIENTBUFFER),
FE(DMUS_E_BUFFERNOTSET),
FE(DMUS_E_BUFFERNOTAVAILABLE),
FE(DMUS_E_NOTADLSCOL),
FE(DMUS_E_INVALIDOFFSET),
FE(DMUS_E_ALREADY_LOADED),
FE(DMUS_E_INVALIDPOS),
FE(DMUS_E_INVALIDPATCH),
FE(DMUS_E_CANNOTSEEK),
FE(DMUS_E_CANNOTWRITE),
FE(DMUS_E_CHUNKNOTFOUND),
FE(DMUS_E_INVALID_DOWNLOADID),
FE(DMUS_E_NOT_DOWNLOADED_TO_PORT),
FE(DMUS_E_ALREADY_DOWNLOADED),
FE(DMUS_E_UNKNOWN_PROPERTY),
FE(DMUS_E_SET_UNSUPPORTED),
FE(DMUS_E_GET_UNSUPPORTED),
FE(DMUS_E_NOTMONO),
FE(DMUS_E_BADARTICULATION),
FE(DMUS_E_BADINSTRUMENT),
FE(DMUS_E_BADWAVELINK),
FE(DMUS_E_NOARTICULATION),
FE(DMUS_E_NOTPCM),
FE(DMUS_E_BADWAVE),
FE(DMUS_E_BADOFFSETTABLE),
FE(DMUS_E_UNKNOWNDOWNLOAD),
FE(DMUS_E_NOSYNTHSINK),
FE(DMUS_E_ALREADYOPEN),
FE(DMUS_E_ALREADYCLOSED),
FE(DMUS_E_SYNTHNOTCONFIGURED),
FE(DMUS_E_SYNTHACTIVE),
FE(DMUS_E_CANNOTREAD),
FE(DMUS_E_DMUSIC_RELEASED),
FE(DMUS_E_BUFFER_EMPTY),
FE(DMUS_E_BUFFER_FULL),
FE(DMUS_E_PORT_NOT_CAPTURE),
FE(DMUS_E_PORT_NOT_RENDER),
FE(DMUS_E_DSOUND_NOT_SET),
FE(DMUS_E_ALREADY_ACTIVATED),
FE(DMUS_E_INVALIDBUFFER),
FE(DMUS_E_WAVEFORMATNOTSUPPORTED),
FE(DMUS_E_SYNTHINACTIVE),
FE(DMUS_E_DSOUND_ALREADY_SET),
FE(DMUS_E_INVALID_EVENT),
FE(DMUS_E_UNSUPPORTED_STREAM),
FE(DMUS_E_ALREADY_INITED),
FE(DMUS_E_INVALID_BAND),
FE(DMUS_E_TRACK_HDR_NOT_FIRST_CK),
FE(DMUS_E_TOOL_HDR_NOT_FIRST_CK),
FE(DMUS_E_INVALID_TRACK_HDR),
FE(DMUS_E_INVALID_TOOL_HDR),
FE(DMUS_E_ALL_TOOLS_FAILED),
FE(DMUS_E_ALL_TRACKS_FAILED),
FE(DMUS_E_NOT_FOUND),
FE(DMUS_E_NOT_INIT),
FE(DMUS_E_TYPE_DISABLED),
FE(DMUS_E_TYPE_UNSUPPORTED),
FE(DMUS_E_TIME_PAST),
FE(DMUS_E_TRACK_NOT_FOUND),
FE(DMUS_E_TRACK_NO_CLOCKTIME_SUPPORT),
FE(DMUS_E_NO_MASTER_CLOCK),
FE(DMUS_E_LOADER_NOCLASSID),
FE(DMUS_E_LOADER_BADPATH),
FE(DMUS_E_LOADER_FAILEDOPEN),
FE(DMUS_E_LOADER_FORMATNOTSUPPORTED),
FE(DMUS_E_LOADER_FAILEDCREATE),
FE(DMUS_E_LOADER_OBJECTNOTFOUND),
FE(DMUS_E_LOADER_NOFILENAME),
FE(DMUS_E_INVALIDFILE),
FE(DMUS_E_ALREADY_EXISTS),
FE(DMUS_E_OUT_OF_RANGE),
FE(DMUS_E_SEGMENT_INIT_FAILED),
FE(DMUS_E_ALREADY_SENT),
FE(DMUS_E_CANNOT_FREE),
FE(DMUS_E_CANNOT_OPEN_PORT),
FE(DMUS_E_CANNOT_CONVERT),
FE(DMUS_E_DESCEND_CHUNK_FAIL),
FE(DMUS_E_NOT_LOADED),
FE(DMUS_E_SCRIPT_LANGUAGE_INCOMPATIBLE),
FE(DMUS_E_SCRIPT_UNSUPPORTED_VARTYPE),
FE(DMUS_E_SCRIPT_ERROR_IN_SCRIPT),
FE(DMUS_E_SCRIPT_CANTLOAD_OLEAUT32),
FE(DMUS_E_SCRIPT_LOADSCRIPT_ERROR),
FE(DMUS_E_SCRIPT_INVALID_FILE),
FE(DMUS_E_INVALID_SCRIPTTRACK),
FE(DMUS_E_SCRIPT_VARIABLE_NOT_FOUND),
FE(DMUS_E_SCRIPT_ROUTINE_NOT_FOUND),
FE(DMUS_E_SCRIPT_CONTENT_READONLY),
FE(DMUS_E_SCRIPT_NOT_A_REFERENCE),
FE(DMUS_E_SCRIPT_VALUE_NOT_SUPPORTED),
FE(DMUS_E_INVALID_SEGMENTTRIGGERTRACK),
FE(DMUS_E_INVALID_LYRICSTRACK),
FE(DMUS_E_INVALID_PARAMCONTROLTRACK),
FE(DMUS_E_AUDIOVBSCRIPT_SYNTAXERROR),
FE(DMUS_E_AUDIOVBSCRIPT_RUNTIMEERROR),
FE(DMUS_E_AUDIOVBSCRIPT_OPERATIONFAILURE),
FE(DMUS_E_AUDIOPATHS_NOT_VALID),
FE(DMUS_E_AUDIOPATHS_IN_USE),
FE(DMUS_E_NO_AUDIOPATH_CONFIG),
FE(DMUS_E_AUDIOPATH_INACTIVE),
FE(DMUS_E_AUDIOPATH_NOBUFFER),
FE(DMUS_E_AUDIOPATH_NOPORT),
FE(DMUS_E_NO_AUDIOPATH),
FE(DMUS_E_INVALIDCHUNK),
FE(DMUS_E_AUDIOPATH_NOGLOBALFXBUFFER),
FE(DMUS_E_INVALID_CONTAINER_OBJECT)
};
unsigned int i;
for (i = 0; i < sizeof(codes)/sizeof(codes[0]); i++) {
if (code == codes[i].val)
return codes[i].name;
}
/* if we didn't find it, return value */
return wine_dbg_sprintf("0x%08lx", code);
}
/* generic flag-dumping function */
const char* debugstr_flags (DWORD flags, const flag_info* names, size_t num_names){
char buffer[128] = "", *ptr = &buffer[0];
unsigned int i, size = sizeof(buffer);
for (i=0; i < num_names; i++)
{
if ((flags & names[i].val) || /* standard flag*/
((!flags) && (!names[i].val))) { /* zero value only */
int cnt = snprintf(ptr, size, "%s ", names[i].name);
if (cnt < 0 || cnt >= size) break;
size -= cnt;
ptr += cnt;
}
}
return wine_dbg_sprintf("%s", buffer);
}
/* dump DMUS_OBJ flags */
const char *debugstr_DMUS_OBJ_FLAGS (DWORD flagmask) {
static const flag_info flags[] = {
FE(DMUS_OBJ_OBJECT),
FE(DMUS_OBJ_CLASS),
FE(DMUS_OBJ_NAME),
FE(DMUS_OBJ_CATEGORY),
FE(DMUS_OBJ_FILENAME),
FE(DMUS_OBJ_FULLPATH),
FE(DMUS_OBJ_URL),
FE(DMUS_OBJ_VERSION),
FE(DMUS_OBJ_DATE),
FE(DMUS_OBJ_LOADED),
FE(DMUS_OBJ_MEMORY),
FE(DMUS_OBJ_STREAM)
};
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 = %ld\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 = %lli\n - pbMemData = %p\n", 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)");
}
}
/* figures out whether given FOURCC is valid DirectMusic form ID */
BOOL IS_VALID_DMFORM (FOURCC chunkID) {
if ((chunkID == DMUS_FOURCC_AUDIOPATH_FORM) || (chunkID == DMUS_FOURCC_BAND_FORM) || (chunkID == DMUS_FOURCC_CHORDMAP_FORM)
|| (chunkID == DMUS_FOURCC_CONTAINER_FORM) || (chunkID == FOURCC_DLS) || (chunkID == DMUS_FOURCC_SCRIPT_FORM)
|| (chunkID == DMUS_FOURCC_SEGMENT_FORM) || (chunkID == DMUS_FOURCC_STYLE_FORM) || (chunkID == DMUS_FOURCC_TOOLGRAPH_FORM)
|| (chunkID == DMUS_FOURCC_TRACK_FORM) || (chunkID == mmioFOURCC('W','A','V','E'))) return TRUE;
else return FALSE;
}

View File

@ -39,118 +39,179 @@
#include "dmusicf.h"
#include "dmusics.h"
/*****************************************************************************
* Auxiliary definitions
*/
/* cache entry */
typedef struct _DMUS_PRIVATE_CACHE_ENTRY {
struct list entry; /* for listing elements */
BOOL bIsFaultyDLS; /* my workaround for enabling caching of "faulty" dls collections */
LPDIRECTMUSICOBJECT pObject; /* pointer to object */
} DMUS_PRIVATE_CACHE_ENTRY, *LPDMUS_PRIVATE_CACHE_ENTRY;
/* alias entry */
typedef struct _DMUS_PRIVATE_ALIAS_ENTRY {
struct list entry; /* for listing elements */
LPDMUS_OBJECTDESC pDesc; /* descriptor, containing info */
} DMUS_PRIVATE_ALIAS_ENTRY, *LPDMUS_PRIVATE_ALIAS_ENTRY;
/* contained object entry */
typedef struct _DMUS_PRIVATE_CONTAINED_OBJECT_ENTRY {
struct list entry; /* for listing elements */
WCHAR* wszAlias;
LPDMUS_OBJECTDESC pDesc;
} DMUS_PRIVATE_CONTAINED_OBJECT_ENTRY, *LPDMUS_PRIVATE_CONTAINED_OBJECT_ENTRY;
/* dmloader.dll global (for DllCanUnloadNow) */
extern DWORD dwDirectMusicLoader; /* number of DirectMusicLoader(CF) instances */
extern DWORD dwDirectMusicContainer; /* number of DirectMusicContainer(CF) instances */
/*****************************************************************************
* Interfaces
*/
typedef struct IDirectMusicLoader8Impl IDirectMusicLoader8Impl;
typedef struct IDirectMusicLoaderCF IDirectMusicLoaderCF;
typedef struct IDirectMusicContainerCF IDirectMusicContainerCF;
typedef struct IDirectMusicLoaderImpl IDirectMusicLoaderImpl;
typedef struct IDirectMusicContainerImpl IDirectMusicContainerImpl;
typedef struct ILoaderStream ILoaderStream;
typedef struct IDirectMusicLoaderFileStream IDirectMusicLoaderFileStream;
typedef struct IDirectMusicLoaderResourceStream IDirectMusicLoaderResourceStream;
typedef struct IDirectMusicLoaderGenericStream IDirectMusicLoaderGenericStream;
/*****************************************************************************
* Predeclare the interface implementation structures
*/
extern ICOM_VTABLE(IDirectMusicLoader8) DirectMusicLoader8_Vtbl;
extern ICOM_VTABLE(IClassFactory) DirectMusicLoaderCF_Vtbl;
extern ICOM_VTABLE(IClassFactory) DirectMusicContainerCF_Vtbl;
extern ICOM_VTABLE(IDirectMusicLoader8) DirectMusicLoader_Loader_Vtbl;
extern ICOM_VTABLE(IUnknown) DirectMusicContainer_Unknown_Vtbl;
extern ICOM_VTABLE(IDirectMusicContainer) DirectMusicContainer_Container_Vtbl;
extern ICOM_VTABLE(IDirectMusicObject) DirectMusicContainer_Object_Vtbl;
extern ICOM_VTABLE(IPersistStream) DirectMusicContainer_PersistStream_Vtbl;
extern ICOM_VTABLE(IUnknown) LoaderStream_Unknown_Vtbl;
extern ICOM_VTABLE(IStream) LoaderStream_Stream_Vtbl;
extern ICOM_VTABLE(IDirectMusicGetLoader) LoaderStream_GetLoader_Vtbl;
extern ICOM_VTABLE(IStream) DirectMusicLoaderFileStream_Stream_Vtbl;
extern ICOM_VTABLE(IDirectMusicGetLoader) DirectMusicLoaderFileStream_GetLoader_Vtbl;
extern ICOM_VTABLE(IStream) DirectMusicLoaderResourceStream_Stream_Vtbl;
extern ICOM_VTABLE(IDirectMusicGetLoader) DirectMusicLoaderResourceStream_GetLoader_Vtbl;
extern ICOM_VTABLE(IStream) DirectMusicLoaderGenericStream_Stream_Vtbl;
extern ICOM_VTABLE(IDirectMusicGetLoader) DirectMusicLoaderGenericStream_GetLoader_Vtbl;
/*****************************************************************************
* ClassFactory
* Creation helpers
*/
extern HRESULT WINAPI DMUSIC_CreateDirectMusicLoaderCF (LPCGUID lpcGUID, LPVOID *ppobj, LPUNKNOWN pUnkOuter);
extern HRESULT WINAPI DMUSIC_CreateDirectMusicContainerCF (LPCGUID lpcGUID, LPVOID *ppobj, LPUNKNOWN pUnkOuter);
extern HRESULT WINAPI DMUSIC_CreateDirectMusicLoaderImpl (LPCGUID lpcGUID, LPVOID *ppobj, LPUNKNOWN pUnkOuter);
extern HRESULT WINAPI DMUSIC_DestroyDirectMusicLoaderImpl (LPDIRECTMUSICLOADER8 iface);
extern HRESULT WINAPI DMUSIC_CreateDirectMusicContainerImpl (LPCGUID lpcGUID, LPVOID *ppobj, LPUNKNOWN pUnkOuter);
extern HRESULT WINAPI DMUSIC_DestroyDirectMusicContainerImpl(LPDIRECTMUSICCONTAINER iface);
extern HRESULT WINAPI DMUSIC_CreateLoaderStream (LPVOID *ppobj);
extern HRESULT WINAPI DMUSIC_CreateDirectMusicLoaderFileStream (LPVOID *ppobj);
extern HRESULT WINAPI DMUSIC_DestroyDirectMusicLoaderFileStream (LPSTREAM iface);
extern HRESULT WINAPI DMUSIC_CreateDirectMusicLoaderResourceStream (LPVOID *ppobj);
extern HRESULT WINAPI DMUSIC_DestroyDirectMusicLoaderResourceStream (LPSTREAM iface);
extern HRESULT WINAPI DMUSIC_CreateDirectMusicLoaderGenericStream (LPVOID *ppobj);
extern HRESULT WINAPI DMUSIC_DestroyDirectMusicLoaderGenericStream (LPSTREAM iface);
/*****************************************************************************
* IDirectMusicLoader8Impl implementation structure
* IDirectMusicLoaderCF implementation structure
*/
struct IDirectMusicLoader8Impl {
struct IDirectMusicLoaderCF {
/* IUnknown fields */
ICOM_VFIELD(IDirectMusicLoader8);
DWORD ref;
/* IDirectMusicLoaderImpl fields */
WCHAR wzSearchPath[MAX_PATH];
/* simple cache (linked list) */
struct list CacheList;
struct list AliasList;
ICOM_VFIELD(IClassFactory);
DWORD dwRef;
};
/* IUnknown: */
extern HRESULT WINAPI IDirectMusicLoader8Impl_QueryInterface (LPDIRECTMUSICLOADER8 iface, REFIID riid, LPVOID *ppobj);
extern ULONG WINAPI IDirectMusicLoader8Impl_AddRef (LPDIRECTMUSICLOADER8 iface);
extern ULONG WINAPI IDirectMusicLoader8Impl_Release (LPDIRECTMUSICLOADER8 iface);
/* IDirectMusicLoader: */
extern HRESULT WINAPI IDirectMusicLoader8Impl_GetObject (LPDIRECTMUSICLOADER8 iface, LPDMUS_OBJECTDESC pDesc, REFIID riid, LPVOID*ppv);
extern HRESULT WINAPI IDirectMusicLoader8Impl_SetObject (LPDIRECTMUSICLOADER8 iface, LPDMUS_OBJECTDESC pDesc);
extern HRESULT WINAPI IDirectMusicLoader8Impl_SetSearchDirectory (LPDIRECTMUSICLOADER8 iface, REFGUID rguidClass, WCHAR* pwzPath, BOOL fClear);
extern HRESULT WINAPI IDirectMusicLoader8Impl_ScanDirectory (LPDIRECTMUSICLOADER8 iface, REFGUID rguidClass, WCHAR* pwzFileExtension, WCHAR* pwzScanFileName);
extern HRESULT WINAPI IDirectMusicLoader8Impl_CacheObject (LPDIRECTMUSICLOADER8 iface, IDirectMusicObject* pObject);
extern HRESULT WINAPI IDirectMusicLoader8Impl_ReleaseObject (LPDIRECTMUSICLOADER8 iface, IDirectMusicObject* pObject);
extern HRESULT WINAPI IDirectMusicLoader8Impl_ClearCache (LPDIRECTMUSICLOADER8 iface, REFGUID rguidClass);
extern HRESULT WINAPI IDirectMusicLoader8Impl_EnableCache (LPDIRECTMUSICLOADER8 iface, REFGUID rguidClass, BOOL fEnable);
extern HRESULT WINAPI IDirectMusicLoader8Impl_EnumObject (LPDIRECTMUSICLOADER8 iface, REFGUID rguidClass, DWORD dwIndex, LPDMUS_OBJECTDESC pDesc);
/* IDirectMusicLoader8: */
extern void WINAPI IDirectMusicLoader8Impl_CollectGarbage (LPDIRECTMUSICLOADER8 iface);
extern HRESULT WINAPI IDirectMusicLoader8Impl_ReleaseObjectByUnknown (LPDIRECTMUSICLOADER8 iface, IUnknown* pObject);
extern HRESULT WINAPI IDirectMusicLoader8Impl_LoadObjectFromFile (LPDIRECTMUSICLOADER8 iface, REFGUID rguidClassID, REFIID iidInterfaceID, WCHAR* pwzFilePath, void** ppObject);
/* IUnknown / IClassFactory: */
extern HRESULT WINAPI IDirectMusicLoaderCF_QueryInterface (LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj);
extern ULONG WINAPI IDirectMusicLoaderCF_AddRef (LPCLASSFACTORY iface);
extern ULONG WINAPI IDirectMusicLoaderCF_Release (LPCLASSFACTORY iface);
extern HRESULT WINAPI IDirectMusicLoaderCF_CreateInstance (LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj);
extern HRESULT WINAPI IDirectMusicLoaderCF_LockServer (LPCLASSFACTORY iface,BOOL dolock);
/*****************************************************************************
* IDirectMusicContainerCF implementation structure
*/
struct IDirectMusicContainerCF {
/* IUnknown fields */
ICOM_VFIELD(IClassFactory);
DWORD dwRef;
};
/* IUnknown / IClassFactory: */
extern HRESULT WINAPI IDirectMusicContainerCF_QueryInterface (LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj);
extern ULONG WINAPI IDirectMusicContainerCF_AddRef (LPCLASSFACTORY iface);
extern ULONG WINAPI IDirectMusicContainerCF_Release (LPCLASSFACTORY iface);
extern HRESULT WINAPI IDirectMusicContainerCF_CreateInstance (LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj);
extern HRESULT WINAPI IDirectMusicContainerCF_LockServer (LPCLASSFACTORY iface,BOOL dolock);
/* cache/alias entry */
typedef struct _WINE_LOADER_ENTRY {
struct list entry; /* for listing elements */
DMUS_OBJECTDESC Desc;
LPDIRECTMUSICOBJECT pObject; /* pointer to object */
BOOL bInvalidDefaultDLS; /* my workaround for enabling caching of "faulty" default dls collection */
} WINE_LOADER_ENTRY, *LPWINE_LOADER_ENTRY;
/* cache options, search paths for specific types of objects */
typedef struct _WINE_LOADER_OPTION {
struct list entry; /* for listing elements */
GUID guidClass; /* ID of object type */
WCHAR wszSearchPath[MAX_PATH]; /* look for objects of certain type in here */
BOOL bCache; /* cache objects of certain type */
} WINE_LOADER_OPTION, *LPWINE_LOADER_OPTION;
/*****************************************************************************
* IDirectMusicLoaderImpl implementation structure
*/
struct IDirectMusicLoaderImpl {
/* VTABLEs */
ICOM_VTABLE(IDirectMusicLoader8) *LoaderVtbl;
/* reference counter */
DWORD dwRef;
/* simple cache (linked list) */
struct list *pObjects;
/* settings for certain object classes */
struct list *pClassSettings;
/* critical section */
CRITICAL_SECTION CritSect;
};
/* IUnknown / IDirectMusicLoader(8): */
extern HRESULT WINAPI IDirectMusicLoaderImpl_IDirectMusicLoader_QueryInterface (LPDIRECTMUSICLOADER8 iface, REFIID riid, LPVOID *ppobj);
extern ULONG WINAPI IDirectMusicLoaderImpl_IDirectMusicLoader_AddRef (LPDIRECTMUSICLOADER8 iface);
extern ULONG WINAPI IDirectMusicLoaderImpl_IDirectMusicLoader_Release (LPDIRECTMUSICLOADER8 iface);
extern HRESULT WINAPI IDirectMusicLoaderImpl_IDirectMusicLoader_GetObject (LPDIRECTMUSICLOADER8 iface, LPDMUS_OBJECTDESC pDesc, REFIID riid, LPVOID*ppv);
extern HRESULT WINAPI IDirectMusicLoaderImpl_IDirectMusicLoader_SetObject (LPDIRECTMUSICLOADER8 iface, LPDMUS_OBJECTDESC pDesc);
extern HRESULT WINAPI IDirectMusicLoaderImpl_IDirectMusicLoader_SetSearchDirectory (LPDIRECTMUSICLOADER8 iface, REFGUID rguidClass, WCHAR* pwzPath, BOOL fClear);
extern HRESULT WINAPI IDirectMusicLoaderImpl_IDirectMusicLoader_ScanDirectory (LPDIRECTMUSICLOADER8 iface, REFGUID rguidClass, WCHAR* pwzFileExtension, WCHAR* pwzScanFileName);
extern HRESULT WINAPI IDirectMusicLoaderImpl_IDirectMusicLoader_CacheObject (LPDIRECTMUSICLOADER8 iface, IDirectMusicObject* pObject);
extern HRESULT WINAPI IDirectMusicLoaderImpl_IDirectMusicLoader_ReleaseObject (LPDIRECTMUSICLOADER8 iface, IDirectMusicObject* pObject);
extern HRESULT WINAPI IDirectMusicLoaderImpl_IDirectMusicLoader_ClearCache (LPDIRECTMUSICLOADER8 iface, REFGUID rguidClass);
extern HRESULT WINAPI IDirectMusicLoaderImpl_IDirectMusicLoader_EnableCache (LPDIRECTMUSICLOADER8 iface, REFGUID rguidClass, BOOL fEnable);
extern HRESULT WINAPI IDirectMusicLoaderImpl_IDirectMusicLoader_EnumObject (LPDIRECTMUSICLOADER8 iface, REFGUID rguidClass, DWORD dwIndex, LPDMUS_OBJECTDESC pDesc);
extern void WINAPI IDirectMusicLoaderImpl_IDirectMusicLoader_CollectGarbage (LPDIRECTMUSICLOADER8 iface);
extern HRESULT WINAPI IDirectMusicLoaderImpl_IDirectMusicLoader_ReleaseObjectByUnknown (LPDIRECTMUSICLOADER8 iface, IUnknown* pObject);
extern HRESULT WINAPI IDirectMusicLoaderImpl_IDirectMusicLoader_LoadObjectFromFile (LPDIRECTMUSICLOADER8 iface, REFGUID rguidClassID, REFIID iidInterfaceID, WCHAR* pwzFilePath, void** ppObject);
/* contained object entry */
typedef struct _WINE_CONTAINER_ENTRY {
struct list entry; /* for listing elements */
DMUS_OBJECTDESC Desc;
BOOL bIsRIFF;
DWORD dwFlags; /* DMUS_CONTAINED_OBJF_KEEP: keep object in loader's cache, even when container is released */
WCHAR* wszAlias;
LPDIRECTMUSICOBJECT pObject; /* needed when releasing from loader's cache on container release */
} WINE_CONTAINER_ENTRY, *LPWINE_CONTAINER_ENTRY;
/*****************************************************************************
* IDirectMusicContainerImpl implementation structure
*/
struct IDirectMusicContainerImpl {
/* IUnknown fields */
ICOM_VTABLE(IUnknown) *UnknownVtbl;
/* VTABLEs */
ICOM_VTABLE(IDirectMusicContainer) *ContainerVtbl;
ICOM_VTABLE(IDirectMusicObject) *ObjectVtbl;
ICOM_VTABLE(IPersistStream) *PersistStreamVtbl;
DWORD ref;
/* IDirectMusicContainerImpl fields */
LPDMUS_OBJECTDESC pDesc;
DMUS_IO_CONTAINER_HEADER* pHeader;
/* list of objects */
struct list ObjectsList;
/* reference counter */
DWORD dwRef;
/* stream */
LPSTREAM pStream;
/* header */
DMUS_IO_CONTAINER_HEADER Header;
/* data */
struct list *pContainedObjects;
/* descriptor */
DMUS_OBJECTDESC Desc;
};
/* IUnknown: */
extern HRESULT WINAPI IDirectMusicContainerImpl_IUnknown_QueryInterface (LPUNKNOWN iface, REFIID riid, LPVOID *ppobj);
extern ULONG WINAPI IDirectMusicContainerImpl_IUnknown_AddRef (LPUNKNOWN iface);
extern ULONG WINAPI IDirectMusicContainerImpl_IUnknown_Release (LPUNKNOWN iface);
/* IDirectMusicContainer: */
/* IUnknown / IDirectMusicContainer: */
extern HRESULT WINAPI IDirectMusicContainerImpl_IDirectMusicContainer_QueryInterface (LPDIRECTMUSICCONTAINER iface, REFIID riid, LPVOID *ppobj);
extern ULONG WINAPI IDirectMusicContainerImpl_IDirectMusicContainer_AddRef (LPDIRECTMUSICCONTAINER iface);
extern ULONG WINAPI IDirectMusicContainerImpl_IDirectMusicContainer_Release (LPDIRECTMUSICCONTAINER iface);
@ -162,7 +223,6 @@ extern ULONG WINAPI IDirectMusicContainerImpl_IDirectMusicObject_Release (LPDI
extern HRESULT WINAPI IDirectMusicContainerImpl_IDirectMusicObject_GetDescriptor (LPDIRECTMUSICOBJECT iface, LPDMUS_OBJECTDESC pDesc);
extern HRESULT WINAPI IDirectMusicContainerImpl_IDirectMusicObject_SetDescriptor (LPDIRECTMUSICOBJECT iface, LPDMUS_OBJECTDESC pDesc);
extern HRESULT WINAPI IDirectMusicContainerImpl_IDirectMusicObject_ParseDescriptor (LPDIRECTMUSICOBJECT iface, LPSTREAM pStream, LPDMUS_OBJECTDESC pDesc);
/* IPersistStream: */
extern HRESULT WINAPI IDirectMusicContainerImpl_IPersistStream_QueryInterface (LPPERSISTSTREAM iface, REFIID riid, void** ppvObject);
extern ULONG WINAPI IDirectMusicContainerImpl_IPersistStream_AddRef (LPPERSISTSTREAM iface);
@ -175,97 +235,145 @@ extern HRESULT WINAPI IDirectMusicContainerImpl_IPersistStream_GetSizeMax (LPPER
/*****************************************************************************
* ILoaderStream implementation structure
* IDirectMusicLoaderFileStream implementation structure
*/
struct ILoaderStream {
/* IUnknown fields */
ICOM_VTABLE(IUnknown) *UnknownVtbl;
struct IDirectMusicLoaderFileStream {
/* VTABLEs */
ICOM_VTABLE(IStream) *StreamVtbl;
ICOM_VTABLE(IDirectMusicGetLoader) *GetLoaderVtbl;
DWORD ref;
/* ILoaderStream fields */
IDirectMusicLoader8Impl* pLoader;
HANDLE hFile;
/* reference counter */
DWORD dwRef;
/* file */
WCHAR wzFileName[MAX_PATH]; /* for clone */
HANDLE hFile;
/* loader */
LPDIRECTMUSICLOADER8 pLoader;
};
/* Custom: */
extern HRESULT WINAPI ILoaderStream_Attach (LPSTREAM iface, LPCWSTR wzFile, IDirectMusicLoader *pLoader);
extern void WINAPI ILoaderStream_Detach (LPSTREAM iface);
/* IUnknown: */
extern HRESULT WINAPI ILoaderStream_IUnknown_QueryInterface (LPUNKNOWN iface, REFIID riid, void** ppobj);
extern ULONG WINAPI ILoaderStream_IUnknown_AddRef (LPUNKNOWN iface);
extern ULONG WINAPI ILoaderStream_IUnknown_Release (LPUNKNOWN iface);
extern HRESULT WINAPI IDirectMusicLoaderFileStream_Attach (LPSTREAM iface, LPCWSTR wzFile, LPDIRECTMUSICLOADER pLoader);
extern void WINAPI IDirectMusicLoaderFileStream_Detach (LPSTREAM iface);
/* IUnknown/IStream: */
extern HRESULT WINAPI IDirectMusicLoaderFileStream_IStream_QueryInterface (LPSTREAM iface, REFIID riid, void** ppobj);
extern ULONG WINAPI IDirectMusicLoaderFileStream_IStream_AddRef (LPSTREAM iface);
extern ULONG WINAPI IDirectMusicLoaderFileStream_IStream_Release (LPSTREAM iface);
extern HRESULT WINAPI IDirectMusicLoaderFileStream_IStream_Read (IStream* iface, void* pv, ULONG cb, ULONG* pcbRead);
extern HRESULT WINAPI IDirectMusicLoaderFileStream_IStream_Write (LPSTREAM iface, const void* pv, ULONG cb, ULONG* pcbWritten);
extern HRESULT WINAPI IDirectMusicLoaderFileStream_IStream_Seek (LPSTREAM iface, LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER* plibNewPosition);
extern HRESULT WINAPI IDirectMusicLoaderFileStream_IStream_SetSize (LPSTREAM iface, ULARGE_INTEGER libNewSize);
extern HRESULT WINAPI IDirectMusicLoaderFileStream_IStream_CopyTo (LPSTREAM iface, IStream* pstm, ULARGE_INTEGER cb, ULARGE_INTEGER* pcbRead, ULARGE_INTEGER* pcbWritten);
extern HRESULT WINAPI IDirectMusicLoaderFileStream_IStream_Commit (LPSTREAM iface, DWORD grfCommitFlags);
extern HRESULT WINAPI IDirectMusicLoaderFileStream_IStream_Revert (LPSTREAM iface);
extern HRESULT WINAPI IDirectMusicLoaderFileStream_IStream_LockRegion (LPSTREAM iface, ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType);
extern HRESULT WINAPI IDirectMusicLoaderFileStream_IStream_UnlockRegion (LPSTREAM iface, ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType);
extern HRESULT WINAPI IDirectMusicLoaderFileStream_IStream_Stat (LPSTREAM iface, STATSTG* pstatstg, DWORD grfStatFlag);
extern HRESULT WINAPI IDirectMusicLoaderFileStream_IStream_Clone (LPSTREAM iface, IStream** ppstm);
/* IDirectMusicGetLoader: */
extern HRESULT WINAPI ILoaderStream_IDirectMusicGetLoader_QueryInterface (LPDIRECTMUSICGETLOADER iface, REFIID riid, void** ppobj);
extern ULONG WINAPI ILoaderStream_IDirectMusicGetLoader_AddRef (LPDIRECTMUSICGETLOADER iface);
extern ULONG WINAPI ILoaderStream_IDirectMusicGetLoader_Release (LPDIRECTMUSICGETLOADER iface);
extern HRESULT WINAPI ILoaderStream_IDirectMusicGetLoader_GetLoader (LPDIRECTMUSICGETLOADER iface, IDirectMusicLoader **ppLoader);
/* IStream: */
extern HRESULT WINAPI ILoaderStream_IStream_QueryInterface (LPSTREAM iface, REFIID riid, void** ppobj);
extern ULONG WINAPI ILoaderStream_IStream_AddRef (LPSTREAM iface);
extern ULONG WINAPI ILoaderStream_IStream_Release (LPSTREAM iface);extern HRESULT WINAPI ILoaderStream_IStream_Read (IStream* iface, void* pv, ULONG cb, ULONG* pcbRead);
extern HRESULT WINAPI ILoaderStream_IStream_Write (LPSTREAM iface, const void* pv, ULONG cb, ULONG* pcbWritten);
extern HRESULT WINAPI ILoaderStream_IStream_Seek (LPSTREAM iface, LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER* plibNewPosition);
extern HRESULT WINAPI ILoaderStream_IStream_SetSize (LPSTREAM iface, ULARGE_INTEGER libNewSize);
extern HRESULT WINAPI ILoaderStream_IStream_CopyTo (LPSTREAM iface, IStream* pstm, ULARGE_INTEGER cb, ULARGE_INTEGER* pcbRead, ULARGE_INTEGER* pcbWritten);
extern HRESULT WINAPI ILoaderStream_IStream_Commit (LPSTREAM iface, DWORD grfCommitFlags);
extern HRESULT WINAPI ILoaderStream_IStream_Revert (LPSTREAM iface);
extern HRESULT WINAPI ILoaderStream_IStream_LockRegion (LPSTREAM iface, ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType);
extern HRESULT WINAPI ILoaderStream_IStream_UnlockRegion (LPSTREAM iface, ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType);
extern HRESULT WINAPI ILoaderStream_IStream_Stat (LPSTREAM iface, STATSTG* pstatstg, DWORD grfStatFlag);
extern HRESULT WINAPI ILoaderStream_IStream_Clone (LPSTREAM iface, IStream** ppstm);
extern HRESULT WINAPI IDirectMusicLoaderFileStream_IDirectMusicGetLoader_QueryInterface (LPDIRECTMUSICGETLOADER iface, REFIID riid, void** ppobj);
extern ULONG WINAPI IDirectMusicLoaderFileStream_IDirectMusicGetLoader_AddRef (LPDIRECTMUSICGETLOADER iface);
extern ULONG WINAPI IDirectMusicLoaderFileStream_IDirectMusicGetLoader_Release (LPDIRECTMUSICGETLOADER iface);
extern HRESULT WINAPI IDirectMusicLoaderFileStream_IDirectMusicGetLoader_GetLoader (LPDIRECTMUSICGETLOADER iface, IDirectMusicLoader **ppLoader);
/*****************************************************************************
* IDirectMusicLoaderResourceStream implementation structure
*/
struct IDirectMusicLoaderResourceStream {
/* IUnknown fields */
ICOM_VTABLE(IStream) *StreamVtbl;
ICOM_VTABLE(IDirectMusicGetLoader) *GetLoaderVtbl;
/* reference counter */
DWORD dwRef;
/* data */
LPBYTE pbMemData;
LONGLONG llMemLength;
/* current position */
LONGLONG llPos;
/* loader */
LPDIRECTMUSICLOADER8 pLoader;
};
/* Custom: */
extern HRESULT WINAPI IDirectMusicLoaderResourceStream_Attach (LPSTREAM iface, LPBYTE pbMemData, LONGLONG llMemLength, LONGLONG llPos, LPDIRECTMUSICLOADER pLoader);
extern void WINAPI IDirectMusicLoaderResourceStream_Detach (LPSTREAM iface);
/* IUnknown/IStream: */
extern HRESULT WINAPI IDirectMusicLoaderResourceStream_IStream_QueryInterface (LPSTREAM iface, REFIID riid, void** ppobj);
extern ULONG WINAPI IDirectMusicLoaderResourceStream_IStream_AddRef (LPSTREAM iface);
extern ULONG WINAPI IDirectMusicLoaderResourceStream_IStream_Release (LPSTREAM iface);
extern HRESULT WINAPI IDirectMusicLoaderResourceStream_IStream_Read (IStream* iface, void* pv, ULONG cb, ULONG* pcbRead);
extern HRESULT WINAPI IDirectMusicLoaderResourceStream_IStream_Write (LPSTREAM iface, const void* pv, ULONG cb, ULONG* pcbWritten);
extern HRESULT WINAPI IDirectMusicLoaderResourceStream_IStream_Seek (LPSTREAM iface, LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER* plibNewPosition);
extern HRESULT WINAPI IDirectMusicLoaderResourceStream_IStream_SetSize (LPSTREAM iface, ULARGE_INTEGER libNewSize);
extern HRESULT WINAPI IDirectMusicLoaderResourceStream_IStream_CopyTo (LPSTREAM iface, IStream* pstm, ULARGE_INTEGER cb, ULARGE_INTEGER* pcbRead, ULARGE_INTEGER* pcbWritten);
extern HRESULT WINAPI IDirectMusicLoaderResourceStream_IStream_Commit (LPSTREAM iface, DWORD grfCommitFlags);
extern HRESULT WINAPI IDirectMusicLoaderResourceStream_IStream_Revert (LPSTREAM iface);
extern HRESULT WINAPI IDirectMusicLoaderResourceStream_IStream_LockRegion (LPSTREAM iface, ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType);
extern HRESULT WINAPI IDirectMusicLoaderResourceStream_IStream_UnlockRegion (LPSTREAM iface, ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType);
extern HRESULT WINAPI IDirectMusicLoaderResourceStream_IStream_Stat (LPSTREAM iface, STATSTG* pstatstg, DWORD grfStatFlag);
extern HRESULT WINAPI IDirectMusicLoaderResourceStream_IStream_Clone (LPSTREAM iface, IStream** ppstm);
/* IDirectMusicGetLoader: */
extern HRESULT WINAPI IDirectMusicLoaderResourceStream_IDirectMusicGetLoader_QueryInterface (LPDIRECTMUSICGETLOADER iface, REFIID riid, void** ppobj);
extern ULONG WINAPI IDirectMusicLoaderResourceStream_IDirectMusicGetLoader_AddRef (LPDIRECTMUSICGETLOADER iface);
extern ULONG WINAPI IDirectMusicLoaderResourceStream_IDirectMusicGetLoader_Release (LPDIRECTMUSICGETLOADER iface);
extern HRESULT WINAPI IDirectMusicLoaderResourceStream_IDirectMusicGetLoader_GetLoader (LPDIRECTMUSICGETLOADER iface, IDirectMusicLoader **ppLoader);
/*****************************************************************************
* IDirectMusicLoaderGenericStream implementation structure
*/
struct IDirectMusicLoaderGenericStream {
/* IUnknown fields */
ICOM_VTABLE(IStream) *StreamVtbl;
ICOM_VTABLE(IDirectMusicGetLoader) *GetLoaderVtbl;
/* reference counter */
DWORD dwRef;
/* stream */
LPSTREAM pStream;
/* loader */
LPDIRECTMUSICLOADER8 pLoader;
};
/* Custom: */
extern HRESULT WINAPI IDirectMusicLoaderGenericStream_Attach (LPSTREAM iface, LPSTREAM pStream, LPDIRECTMUSICLOADER pLoader);
extern void WINAPI IDirectMusicLoaderGenericStream_Detach (LPSTREAM iface);
/* IUnknown/IStream: */
extern HRESULT WINAPI IDirectMusicLoaderGenericStream_IStream_QueryInterface (LPSTREAM iface, REFIID riid, void** ppobj);
extern ULONG WINAPI IDirectMusicLoaderGenericStream_IStream_AddRef (LPSTREAM iface);
extern ULONG WINAPI IDirectMusicLoaderGenericStream_IStream_Release (LPSTREAM iface);
extern HRESULT WINAPI IDirectMusicLoaderGenericStream_IStream_Read (IStream* iface, void* pv, ULONG cb, ULONG* pcbRead);
extern HRESULT WINAPI IDirectMusicLoaderGenericStream_IStream_Write (LPSTREAM iface, const void* pv, ULONG cb, ULONG* pcbWritten);
extern HRESULT WINAPI IDirectMusicLoaderGenericStream_IStream_Seek (LPSTREAM iface, LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER* plibNewPosition);
extern HRESULT WINAPI IDirectMusicLoaderGenericStream_IStream_SetSize (LPSTREAM iface, ULARGE_INTEGER libNewSize);
extern HRESULT WINAPI IDirectMusicLoaderGenericStream_IStream_CopyTo (LPSTREAM iface, IStream* pstm, ULARGE_INTEGER cb, ULARGE_INTEGER* pcbRead, ULARGE_INTEGER* pcbWritten);
extern HRESULT WINAPI IDirectMusicLoaderGenericStream_IStream_Commit (LPSTREAM iface, DWORD grfCommitFlags);
extern HRESULT WINAPI IDirectMusicLoaderGenericStream_IStream_Revert (LPSTREAM iface);
extern HRESULT WINAPI IDirectMusicLoaderGenericStream_IStream_LockRegion (LPSTREAM iface, ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType);
extern HRESULT WINAPI IDirectMusicLoaderGenericStream_IStream_UnlockRegion (LPSTREAM iface, ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType);
extern HRESULT WINAPI IDirectMusicLoaderGenericStream_IStream_Stat (LPSTREAM iface, STATSTG* pstatstg, DWORD grfStatFlag);
extern HRESULT WINAPI IDirectMusicLoaderGenericStream_IStream_Clone (LPSTREAM iface, IStream** ppstm);
/* IDirectMusicGetLoader: */
extern HRESULT WINAPI IDirectMusicLoaderGenericStream_IDirectMusicGetLoader_QueryInterface (LPDIRECTMUSICGETLOADER iface, REFIID riid, void** ppobj);
extern ULONG WINAPI IDirectMusicLoaderGenericStream_IDirectMusicGetLoader_AddRef (LPDIRECTMUSICGETLOADER iface);
extern ULONG WINAPI IDirectMusicLoaderGenericStream_IDirectMusicGetLoader_Release (LPDIRECTMUSICGETLOADER iface);
extern HRESULT WINAPI IDirectMusicLoaderGenericStream_IDirectMusicGetLoader_GetLoader (LPDIRECTMUSICGETLOADER iface, IDirectMusicLoader **ppLoader);
/*****************************************************************************
* Misc.
*/
/* for simpler reading */
typedef struct _DMUS_PRIVATE_CHUNK {
typedef struct _WINE_CHUNK {
FOURCC fccID; /* FOURCC ID of the chunk */
DWORD dwSize; /* size of the chunk */
} DMUS_PRIVATE_CHUNK, *LPDMUS_PRIVATE_CHUNK;
} WINE_CHUNK, *LPWINE_CHUNK;
/* used for generic dumping (copied from ddraw) */
typedef struct {
DWORD val;
const char* name;
} flag_info;
extern HRESULT WINAPI DMUSIC_GetDefaultGMPath (WCHAR wszPath[MAX_PATH]);
extern HRESULT WINAPI DMUSIC_GetLoaderSettings (LPDIRECTMUSICLOADER8 iface, REFGUID pClassID, WCHAR* wszSearchPath, LPBOOL pbCache);
extern HRESULT WINAPI DMUSIC_SetLoaderSettings (LPDIRECTMUSICLOADER8 iface, REFGUID pClassID, WCHAR* wszSearchPath, LPBOOL pbCache);
extern HRESULT WINAPI DMUSIC_InitLoaderSettings (LPDIRECTMUSICLOADER8 iface);
extern HRESULT WINAPI DMUSIC_CopyDescriptor (LPDMUS_OBJECTDESC pDst, LPDMUS_OBJECTDESC pSrc);
extern BOOL WINAPI DMUSIC_IsValidLoadableClass (REFCLSID pClassID);
typedef struct {
const GUID *guid;
const char* name;
} guid_info;
/* used for initialising structs (primarily for DMUS_OBJECTDESC) */
#define DM_STRUCT_INIT(x) \
do { \
memset((x), 0, sizeof(*(x))); \
(x)->dwSize = sizeof(*x); \
} while (0)
#define FE(x) { x, #x }
#define GE(x) { &x, #x }
/* check whether the given DWORD is even (return 0) or odd (return 1) */
extern int even_or_odd (DWORD number);
/* translate STREAM_SEEK flag to string */
extern const char *resolve_STREAM_SEEK (DWORD flag);
/* FOURCC to string conversion for debug messages */
extern const char *debugstr_fourcc (DWORD fourcc);
/* DMUS_VERSION struct to string conversion for debug messages */
extern const char *debugstr_dmversion (LPDMUS_VERSION version);
/* returns name of given GUID */
extern const char *debugstr_dmguid (const GUID *id);
/* returns name of given error code */
extern const char *debugstr_dmreturn (DWORD code);
/* generic flags-dumping function */
extern const char *debugstr_flags (DWORD flags, const flag_info* names, size_t num_names);
extern const char *debugstr_DMUS_OBJ_FLAGS (DWORD flagmask);
/* dump whole DMUS_OBJECTDESC struct */
extern const char *debugstr_DMUS_OBJECTDESC (LPDMUS_OBJECTDESC pDesc);
/* check whether chunkID is valid dmobject form chunk */
extern BOOL IS_VALID_DMFORM (FOURCC chunkID);
#include "debug.h"
#endif /* __WINE_DMLOADER_PRIVATE_H */

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,6 @@
/* ILoaderStream Implementation
/* IDirectMusicLoaderFileStream
* IDirectMusicLoaderResourceStream
* IDirectMusicLoaderGenericStream
*
* Copyright (C) 2003-2004 Rok Mandeljc
*
@ -17,6 +19,31 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* SIDE NOTES:
* After extensive testing and structure dumping I came to a conclusion that
* DirectMusic as in present state implements three types of streams:
* 1. IDirectMusicLoaderFileStream: stream that was most obvious, since
* it's used for loading from files; it is sort of wrapper around
* CreateFile, ReadFile, WriteFile and SetFilePointer and it supports
* both read and write
* 2. IDirectMusicLoaderResourceStream: a stream that had to exist, since
* according to MSDN, IDirectMusicLoader supports loading from resource
* as well; in this case, data is represented as a big chunk of bytes,
* from which we "read" (copy) data and keep the trace of our position;
* it supports read only
* 3. IDirectMusicLoaderGenericStream: this one was the most problematic,
* since I thought it was URL-related; besides, there's no obvious need
* for it, since input streams can simply be cloned, lest loading from
* stream is requested; but if one really thinks about it, input stream
* could be none of 1. or 2.; in this case, a wrapper that offers
* IDirectMusicGetLoader interface would be nice, and this is what this
* stream is; as such, all functions are supported, as long as underlying
* ("low-level") stream supports them
*
* - Rok Mandeljc; 24. april, 2004
*/
#define NONAMELESSUNION
#define NONAMELESSSTRUCT
@ -26,15 +53,16 @@ WINE_DEFAULT_DEBUG_CHANNEL(dmloader);
WINE_DECLARE_DEBUG_CHANNEL(dmfileraw);
/*****************************************************************************
* Custom functions:
* IDirectMusicLoaderFileStream implementation
*/
HRESULT WINAPI ILoaderStream_Attach (LPSTREAM iface, LPCWSTR wzFile, IDirectMusicLoader *pLoader) {
ICOM_THIS_MULTI(ILoaderStream, StreamVtbl, iface);
/* Custom : */
HRESULT WINAPI IDirectMusicLoaderFileStream_Attach (LPSTREAM iface, LPCWSTR wzFile, LPDIRECTMUSICLOADER pLoader) {
ICOM_THIS_MULTI(IDirectMusicLoaderFileStream, StreamVtbl, iface);
TRACE("(%p, %s, %p)\n", This, debugstr_w(wzFile), pLoader);
ILoaderStream_Detach (iface);
This->hFile = CreateFileW (wzFile, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
IDirectMusicLoaderFileStream_Detach (iface);
This->hFile = CreateFileW (wzFile, (GENERIC_READ | GENERIC_WRITE), (FILE_SHARE_READ | FILE_SHARE_WRITE), NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (This->hFile == INVALID_HANDLE_VALUE) {
TRACE(": failed\n");
WARN(": failed\n");
return DMUS_E_LOADER_FAILEDOPEN;
}
/* create IDirectMusicGetLoader */
@ -44,95 +72,72 @@ HRESULT WINAPI ILoaderStream_Attach (LPSTREAM iface, LPCWSTR wzFile, IDirectMusi
return S_OK;
}
void WINAPI ILoaderStream_Detach (LPSTREAM iface) {
ICOM_THIS_MULTI(ILoaderStream, StreamVtbl, iface);
void WINAPI IDirectMusicLoaderFileStream_Detach (LPSTREAM iface) {
ICOM_THIS_MULTI(IDirectMusicLoaderFileStream, StreamVtbl, iface);
TRACE("(%p)\n", This);
if (This->hFile != INVALID_HANDLE_VALUE) {
CloseHandle(This->hFile);
}
This->wzFileName[0] = (L'\0');
}
/*****************************************************************************
* ILoaderStream implementation
*/
/* ILoaderStream IUnknown part: */
HRESULT WINAPI ILoaderStream_IUnknown_QueryInterface (LPUNKNOWN iface, REFIID riid, void** ppobj) {
ICOM_THIS_MULTI(ILoaderStream, UnknownVtbl, iface);
/* IUnknown/IStream part: */
HRESULT WINAPI IDirectMusicLoaderFileStream_IStream_QueryInterface (LPSTREAM iface, REFIID riid, void** ppobj) {
ICOM_THIS_MULTI(IDirectMusicLoaderFileStream, StreamVtbl, iface);
TRACE("(%p, %s, %p)\n", This, debugstr_dmguid(riid), ppobj);
if (IsEqualIID (riid, &IID_IUnknown)) {
*ppobj = (LPVOID)&This->UnknownVtbl;
ILoaderStream_IUnknown_AddRef ((LPUNKNOWN)&This->UnknownVtbl);
return S_OK;
} else if (IsEqualIID (riid, &IID_IStream)) {
if (IsEqualIID (riid, &IID_IUnknown) ||
IsEqualIID (riid, &IID_IStream)) {
*ppobj = (LPVOID)&This->StreamVtbl;
ILoaderStream_IStream_AddRef ((LPSTREAM)&This->StreamVtbl);
IDirectMusicLoaderFileStream_IStream_AddRef ((LPSTREAM)&This->StreamVtbl);
return S_OK;
} else if (IsEqualIID (riid, &IID_IDirectMusicGetLoader)) {
*ppobj = (LPVOID)&This->GetLoaderVtbl;
ILoaderStream_IDirectMusicGetLoader_AddRef ((LPDIRECTMUSICGETLOADER)&This->GetLoaderVtbl);
IDirectMusicLoaderFileStream_IDirectMusicGetLoader_AddRef ((LPDIRECTMUSICGETLOADER)&This->GetLoaderVtbl);
return S_OK;
}
WARN("(%p, %s,%p): not found\n", This, debugstr_dmguid(riid), ppobj);
WARN(": not found\n");
return E_NOINTERFACE;
}
ULONG WINAPI ILoaderStream_IUnknown_AddRef (LPUNKNOWN iface) {
ICOM_THIS_MULTI(ILoaderStream, UnknownVtbl, iface);
TRACE("(%p): AddRef from %ld\n", This, This->ref);
return ++(This->ref);
ULONG WINAPI IDirectMusicLoaderFileStream_IStream_AddRef (LPSTREAM iface) {
ICOM_THIS_MULTI(IDirectMusicLoaderFileStream, StreamVtbl, iface);
TRACE("(%p): AddRef from %ld\n", This, This->dwRef);
return InterlockedIncrement (&This->dwRef);
}
ULONG WINAPI ILoaderStream_IUnknown_Release (LPUNKNOWN iface) {
ICOM_THIS_MULTI(ILoaderStream, UnknownVtbl, iface);
ULONG ref = --This->ref;
TRACE("(%p): ReleaseRef to %ld\n", This, This->ref);
if (ref == 0) {
HeapFree(GetProcessHeap(), 0, This);
}
return ref;
ULONG WINAPI IDirectMusicLoaderFileStream_IStream_Release (LPSTREAM iface) {
ICOM_THIS_MULTI(IDirectMusicLoaderFileStream, StreamVtbl, iface);
DWORD dwRef = InterlockedDecrement (&This->dwRef);
TRACE("(%p): ReleaseRef to %ld\n", This, dwRef);
if (dwRef == 0) {
DMUSIC_DestroyDirectMusicLoaderFileStream (iface);
}
ICOM_VTABLE(IUnknown) LoaderStream_Unknown_Vtbl = {
ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
ILoaderStream_IUnknown_QueryInterface,
ILoaderStream_IUnknown_AddRef,
ILoaderStream_IUnknown_Release
};
/* ILoaderStream IStream part: */
HRESULT WINAPI ILoaderStream_IStream_QueryInterface (LPSTREAM iface, REFIID riid, void** ppobj) {
ICOM_THIS_MULTI(ILoaderStream, StreamVtbl, iface);
return ILoaderStream_IUnknown_QueryInterface ((LPUNKNOWN)&This->UnknownVtbl, riid, ppobj);
return dwRef;
}
ULONG WINAPI ILoaderStream_IStream_AddRef (LPSTREAM iface) {
ICOM_THIS_MULTI(ILoaderStream, StreamVtbl, iface);
return ILoaderStream_IUnknown_AddRef ((LPUNKNOWN)&This->UnknownVtbl);
}
ULONG WINAPI ILoaderStream_IStream_Release (LPSTREAM iface) {
ICOM_THIS_MULTI(ILoaderStream, StreamVtbl, iface);
return ILoaderStream_IUnknown_Release ((LPUNKNOWN)&This->UnknownVtbl);
}
HRESULT WINAPI ILoaderStream_IStream_Read (LPSTREAM iface, void* pv, ULONG cb, ULONG* pcbRead) {
ICOM_THIS_MULTI(ILoaderStream, StreamVtbl, iface);
HRESULT WINAPI IDirectMusicLoaderFileStream_IStream_Read (LPSTREAM iface, void* pv, ULONG cb, ULONG* pcbRead) {
ICOM_THIS_MULTI(IDirectMusicLoaderFileStream, StreamVtbl, iface);
ULONG cbRead;
TRACE_(dmfileraw)("(%p, %p, 0x%04lx, %p)\n", This, pv, cb, pcbRead);
TRACE_(dmfileraw)("(%p, %p, 0x%08lX, %p)\n", This, pv, cb, pcbRead);
if (This->hFile == INVALID_HANDLE_VALUE) return E_FAIL;
if (pcbRead == NULL) pcbRead = &cbRead;
if (!ReadFile (This->hFile, pv, cb, pcbRead, NULL) || *pcbRead != cb) return E_FAIL;
TRACE_(dmfileraw)(": data (size = 0x%04lx): '%s'\n", *pcbRead, debugstr_an(pv, *pcbRead));
TRACE_(dmfileraw)(": data (size = 0x%08lX): '%s'\n", *pcbRead, debugstr_an(pv, *pcbRead));
return S_OK;
}
HRESULT WINAPI ILoaderStream_IStream_Seek (LPSTREAM iface, LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER* plibNewPosition) {
ICOM_THIS_MULTI(ILoaderStream, StreamVtbl, iface);
HRESULT WINAPI IDirectMusicLoaderFileStream_IStream_Seek (LPSTREAM iface, LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER* plibNewPosition) {
ICOM_THIS_MULTI(IDirectMusicLoaderFileStream, StreamVtbl, iface);
LARGE_INTEGER liNewPos;
TRACE_(dmfileraw)("(%p, 0x%04llx, %s, %p)\n", This, dlibMove.QuadPart, resolve_STREAM_SEEK(dwOrigin), plibNewPosition);
TRACE_(dmfileraw)("(%p, 0x%08llX, %s, %p)\n", This, dlibMove.QuadPart, resolve_STREAM_SEEK(dwOrigin), plibNewPosition);
if (This->hFile == INVALID_HANDLE_VALUE) return E_FAIL;
@ -145,30 +150,30 @@ HRESULT WINAPI ILoaderStream_IStream_Seek (LPSTREAM iface, LARGE_INTEGER dlibMov
return S_OK;
}
HRESULT WINAPI ILoaderStream_IStream_Clone (LPSTREAM iface, IStream** ppstm) {
ICOM_THIS_MULTI(ILoaderStream, StreamVtbl, iface);
HRESULT WINAPI IDirectMusicLoaderFileStream_IStream_Clone (LPSTREAM iface, IStream** ppstm) {
ICOM_THIS_MULTI(IDirectMusicLoaderFileStream, StreamVtbl, iface);
LPSTREAM pOther = NULL;
HRESULT result;
TRACE("(%p, %p)\n", iface, ppstm);
result = DMUSIC_CreateLoaderStream ((LPVOID*)&pOther);
result = DMUSIC_CreateDirectMusicLoaderFileStream ((LPVOID*)&pOther);
if (FAILED(result)) return result;
if (This->hFile != INVALID_HANDLE_VALUE) {
ULARGE_INTEGER ullCurrentPosition;
result = ILoaderStream_Attach (pOther, This->wzFileName, (LPDIRECTMUSICLOADER)This->pLoader);
result = IDirectMusicLoaderFileStream_Attach (pOther, This->wzFileName, (LPDIRECTMUSICLOADER)This->pLoader);
if (SUCCEEDED(result)) {
LARGE_INTEGER liZero;
liZero.QuadPart = 0;
result = ILoaderStream_IStream_Seek (iface, liZero, STREAM_SEEK_CUR, &ullCurrentPosition); /* get current position in current stream */
result = IDirectMusicLoaderFileStream_IStream_Seek (iface, liZero, STREAM_SEEK_CUR, &ullCurrentPosition); /* get current position in current stream */
}
if (SUCCEEDED(result)) {
LARGE_INTEGER liNewPosition;
liNewPosition.QuadPart = ullCurrentPosition.QuadPart;
result = ILoaderStream_IStream_Seek ((LPSTREAM)pOther, liNewPosition, STREAM_SEEK_SET, &ullCurrentPosition);
result = IDirectMusicLoaderFileStream_IStream_Seek ((LPSTREAM)pOther, liNewPosition, STREAM_SEEK_SET, &ullCurrentPosition);
}
if (FAILED(result)) {
TRACE(": failed\n");
ILoaderStream_IStream_Release ((LPSTREAM)pOther);
IDirectMusicLoaderFileStream_IStream_Release ((LPSTREAM)pOther);
return result;
}
}
@ -177,84 +182,90 @@ HRESULT WINAPI ILoaderStream_IStream_Clone (LPSTREAM iface, IStream** ppstm) {
return S_OK;
}
HRESULT WINAPI ILoaderStream_IStream_Write (LPSTREAM iface, const void* pv, ULONG cb, ULONG* pcbWritten) {
HRESULT WINAPI IDirectMusicLoaderFileStream_IStream_Write (LPSTREAM iface, const void* pv, ULONG cb, ULONG* pcbWritten) {
ICOM_THIS_MULTI(IDirectMusicLoaderFileStream, StreamVtbl, iface);
ULONG cbWrite;
TRACE_(dmfileraw)("(%p, %p, 0x%08lX, %p)\n", This, pv, cb, pcbWritten);
if (This->hFile == INVALID_HANDLE_VALUE) return E_FAIL;
if (pcbWritten == NULL) pcbWritten = &cbWrite;
if (!WriteFile (This->hFile, pv, cb, pcbWritten, NULL) || *pcbWritten != cb) return E_FAIL;
TRACE_(dmfileraw)(": data (size = 0x%08lX): '%s'\n", *pcbWritten, debugstr_an(pv, *pcbWritten));
return S_OK;
}
HRESULT WINAPI IDirectMusicLoaderFileStream_IStream_SetSize (LPSTREAM iface, ULARGE_INTEGER libNewSize) {
ERR(": should not be needed\n");
return E_NOTIMPL;
}
HRESULT WINAPI ILoaderStream_IStream_SetSize (LPSTREAM iface, ULARGE_INTEGER libNewSize) {
HRESULT WINAPI IDirectMusicLoaderFileStream_IStream_CopyTo (LPSTREAM iface, IStream* pstm, ULARGE_INTEGER cb, ULARGE_INTEGER* pcbRead, ULARGE_INTEGER* pcbWritten) {
ERR(": should not be needed\n");
return E_NOTIMPL;
}
HRESULT WINAPI ILoaderStream_IStream_CopyTo (LPSTREAM iface, IStream* pstm, ULARGE_INTEGER cb, ULARGE_INTEGER* pcbRead, ULARGE_INTEGER* pcbWritten) {
HRESULT WINAPI IDirectMusicLoaderFileStream_IStream_Commit (LPSTREAM iface, DWORD grfCommitFlags) {
ERR(": should not be needed\n");
return E_NOTIMPL;
}
HRESULT WINAPI ILoaderStream_IStream_Commit (LPSTREAM iface, DWORD grfCommitFlags) {
HRESULT WINAPI IDirectMusicLoaderFileStream_IStream_Revert (LPSTREAM iface) {
ERR(": should not be needed\n");
return E_NOTIMPL;
}
HRESULT WINAPI ILoaderStream_IStream_Revert (LPSTREAM iface) {
HRESULT WINAPI IDirectMusicLoaderFileStream_IStream_LockRegion (LPSTREAM iface, ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType) {
ERR(": should not be needed\n");
return E_NOTIMPL;
}
HRESULT WINAPI ILoaderStream_IStream_LockRegion (LPSTREAM iface, ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType) {
HRESULT WINAPI IDirectMusicLoaderFileStream_IStream_UnlockRegion (LPSTREAM iface, ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType) {
ERR(": should not be needed\n");
return E_NOTIMPL;
}
HRESULT WINAPI ILoaderStream_IStream_UnlockRegion (LPSTREAM iface, ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType) {
HRESULT WINAPI IDirectMusicLoaderFileStream_IStream_Stat (LPSTREAM iface, STATSTG* pstatstg, DWORD grfStatFlag) {
ERR(": should not be needed\n");
return E_NOTIMPL;
}
HRESULT WINAPI ILoaderStream_IStream_Stat (LPSTREAM iface, STATSTG* pstatstg, DWORD grfStatFlag) {
ERR(": should not be needed\n");
return E_NOTIMPL;
}
ICOM_VTABLE(IStream) LoaderStream_Stream_Vtbl = {
ICOM_VTABLE(IStream) DirectMusicLoaderFileStream_Stream_Vtbl = {
ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
ILoaderStream_IStream_QueryInterface,
ILoaderStream_IStream_AddRef,
ILoaderStream_IStream_Release,
ILoaderStream_IStream_Read,
ILoaderStream_IStream_Write,
ILoaderStream_IStream_Seek,
ILoaderStream_IStream_SetSize,
ILoaderStream_IStream_CopyTo,
ILoaderStream_IStream_Commit,
ILoaderStream_IStream_Revert,
ILoaderStream_IStream_LockRegion,
ILoaderStream_IStream_UnlockRegion,
ILoaderStream_IStream_Stat,
ILoaderStream_IStream_Clone
IDirectMusicLoaderFileStream_IStream_QueryInterface,
IDirectMusicLoaderFileStream_IStream_AddRef,
IDirectMusicLoaderFileStream_IStream_Release,
IDirectMusicLoaderFileStream_IStream_Read,
IDirectMusicLoaderFileStream_IStream_Write,
IDirectMusicLoaderFileStream_IStream_Seek,
IDirectMusicLoaderFileStream_IStream_SetSize,
IDirectMusicLoaderFileStream_IStream_CopyTo,
IDirectMusicLoaderFileStream_IStream_Commit,
IDirectMusicLoaderFileStream_IStream_Revert,
IDirectMusicLoaderFileStream_IStream_LockRegion,
IDirectMusicLoaderFileStream_IStream_UnlockRegion,
IDirectMusicLoaderFileStream_IStream_Stat,
IDirectMusicLoaderFileStream_IStream_Clone
};
/*****************************************************************************
* ILoaderStream IDirectMusicGetLoader part:
*/
HRESULT WINAPI ILoaderStream_IDirectMusicGetLoader_QueryInterface (LPDIRECTMUSICGETLOADER iface, REFIID riid, void** ppobj) {
ICOM_THIS_MULTI(ILoaderStream, GetLoaderVtbl, iface);
return ILoaderStream_IUnknown_QueryInterface ((LPUNKNOWN)&This->UnknownVtbl, riid, ppobj);
/* IDirectMusicGetLoader part: */
HRESULT WINAPI IDirectMusicLoaderFileStream_IDirectMusicGetLoader_QueryInterface (LPDIRECTMUSICGETLOADER iface, REFIID riid, void** ppobj) {
ICOM_THIS_MULTI(IDirectMusicLoaderFileStream, GetLoaderVtbl, iface);
return IDirectMusicLoaderFileStream_IStream_QueryInterface ((LPSTREAM)&This->StreamVtbl, riid, ppobj);
}
ULONG WINAPI ILoaderStream_IDirectMusicGetLoader_AddRef (LPDIRECTMUSICGETLOADER iface) {
ICOM_THIS_MULTI(ILoaderStream, GetLoaderVtbl, iface);
return ILoaderStream_IUnknown_AddRef ((LPUNKNOWN)&This->UnknownVtbl);
ULONG WINAPI IDirectMusicLoaderFileStream_IDirectMusicGetLoader_AddRef (LPDIRECTMUSICGETLOADER iface) {
ICOM_THIS_MULTI(IDirectMusicLoaderFileStream, GetLoaderVtbl, iface);
return IDirectMusicLoaderFileStream_IStream_AddRef ((LPSTREAM)&This->StreamVtbl);
}
ULONG WINAPI ILoaderStream_IDirectMusicGetLoader_Release (LPDIRECTMUSICGETLOADER iface) {
ICOM_THIS_MULTI(ILoaderStream, GetLoaderVtbl, iface);
return ILoaderStream_IUnknown_Release ((LPUNKNOWN)&This->UnknownVtbl);
ULONG WINAPI IDirectMusicLoaderFileStream_IDirectMusicGetLoader_Release (LPDIRECTMUSICGETLOADER iface) {
ICOM_THIS_MULTI(IDirectMusicLoaderFileStream, GetLoaderVtbl, iface);
return IDirectMusicLoaderFileStream_IStream_Release ((LPSTREAM)&This->StreamVtbl);
}
HRESULT WINAPI ILoaderStream_IDirectMusicGetLoader_GetLoader (LPDIRECTMUSICGETLOADER iface, IDirectMusicLoader **ppLoader) {
ICOM_THIS_MULTI(ILoaderStream, GetLoaderVtbl, iface);
HRESULT WINAPI IDirectMusicLoaderFileStream_IDirectMusicGetLoader_GetLoader (LPDIRECTMUSICGETLOADER iface, IDirectMusicLoader **ppLoader) {
ICOM_THIS_MULTI(IDirectMusicLoaderFileStream, GetLoaderVtbl, iface);
TRACE("(%p, %p)\n", This, ppLoader);
*ppLoader = (LPDIRECTMUSICLOADER)This->pLoader;
@ -263,27 +274,564 @@ HRESULT WINAPI ILoaderStream_IDirectMusicGetLoader_GetLoader (LPDIRECTMUSICGETLO
return S_OK;
}
ICOM_VTABLE(IDirectMusicGetLoader) LoaderStream_GetLoader_Vtbl = {
ICOM_VTABLE(IDirectMusicGetLoader) DirectMusicLoaderFileStream_GetLoader_Vtbl = {
ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
ILoaderStream_IDirectMusicGetLoader_QueryInterface,
ILoaderStream_IDirectMusicGetLoader_AddRef,
ILoaderStream_IDirectMusicGetLoader_Release,
ILoaderStream_IDirectMusicGetLoader_GetLoader
IDirectMusicLoaderFileStream_IDirectMusicGetLoader_QueryInterface,
IDirectMusicLoaderFileStream_IDirectMusicGetLoader_AddRef,
IDirectMusicLoaderFileStream_IDirectMusicGetLoader_Release,
IDirectMusicLoaderFileStream_IDirectMusicGetLoader_GetLoader
};
HRESULT WINAPI DMUSIC_CreateLoaderStream (LPVOID* ppobj) {
ILoaderStream *pStream;
HRESULT WINAPI DMUSIC_CreateDirectMusicLoaderFileStream (LPVOID* ppobj) {
IDirectMusicLoaderFileStream *obj;
TRACE("(%p)\n", ppobj);
pStream = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, sizeof(ILoaderStream));
if (NULL == pStream) {
obj = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, sizeof(IDirectMusicLoaderFileStream));
if (NULL == obj) {
*ppobj = (LPVOID) NULL;
return E_OUTOFMEMORY;
}
pStream->UnknownVtbl = &LoaderStream_Unknown_Vtbl;
pStream->StreamVtbl = &LoaderStream_Stream_Vtbl;
pStream->GetLoaderVtbl = &LoaderStream_GetLoader_Vtbl;
pStream->ref = 0; /* will be inited with QueryInterface */
obj->StreamVtbl = &DirectMusicLoaderFileStream_Stream_Vtbl;
obj->GetLoaderVtbl = &DirectMusicLoaderFileStream_GetLoader_Vtbl;
obj->dwRef = 0; /* will be inited with QueryInterface */
return ILoaderStream_IUnknown_QueryInterface ((LPUNKNOWN)&pStream->UnknownVtbl, &IID_IStream, ppobj);
return IDirectMusicLoaderFileStream_IStream_QueryInterface ((LPSTREAM)&obj->StreamVtbl, &IID_IStream, ppobj);
}
HRESULT WINAPI DMUSIC_DestroyDirectMusicLoaderFileStream (LPSTREAM iface) {
ICOM_THIS_MULTI(IDirectMusicLoaderFileStream, StreamVtbl, iface);
TRACE("(%p)\n", iface);
if (This->hFile)
IDirectMusicLoaderFileStream_Detach (iface);
HeapFree (GetProcessHeap(), 0, This);
return S_OK;
}
/*****************************************************************************
* IDirectMusicLoaderResourceStream implementation
*/
/* Custom : */
HRESULT WINAPI IDirectMusicLoaderResourceStream_Attach (LPSTREAM iface, LPBYTE pbMemData, LONGLONG llMemLength, LONGLONG llPos, LPDIRECTMUSICLOADER pLoader) {
ICOM_THIS_MULTI(IDirectMusicLoaderResourceStream, StreamVtbl, iface);
TRACE("(%p, %p, 0x%08llX, 0x%08llx, %p)\n", This, pbMemData, llMemLength, llPos, pLoader);
if (!pbMemData || !llMemLength) {
WARN(": invalid pbMemData or llMemLength\n");
return E_FAIL;
}
IDirectMusicLoaderResourceStream_Detach (iface);
This->pbMemData = pbMemData;
This->llMemLength = llMemLength;
This->llPos = llPos;
This->pLoader = pLoader;
return S_OK;
}
void WINAPI IDirectMusicLoaderResourceStream_Detach (LPSTREAM iface) {
ICOM_THIS_MULTI(IDirectMusicLoaderResourceStream, StreamVtbl, iface);
TRACE("(%p)\n", This);
This->pbMemData = NULL;
This->llMemLength = 0;
}
/* IUnknown/IStream part: */
HRESULT WINAPI IDirectMusicLoaderResourceStream_IStream_QueryInterface (LPSTREAM iface, REFIID riid, void** ppobj) {
ICOM_THIS_MULTI(IDirectMusicLoaderResourceStream, StreamVtbl, iface);
TRACE("(%p, %s, %p)\n", This, debugstr_dmguid(riid), ppobj);
if (IsEqualIID (riid, &IID_IUnknown) ||
IsEqualIID (riid, &IID_IStream)) {
*ppobj = (LPVOID)&This->StreamVtbl;
IDirectMusicLoaderResourceStream_IStream_AddRef ((LPSTREAM)&This->StreamVtbl);
return S_OK;
} else if (IsEqualIID (riid, &IID_IDirectMusicGetLoader)) {
*ppobj = (LPVOID)&This->GetLoaderVtbl;
IDirectMusicLoaderResourceStream_IDirectMusicGetLoader_AddRef ((LPDIRECTMUSICGETLOADER)&This->GetLoaderVtbl);
return S_OK;
}
WARN(": not found\n");
return E_NOINTERFACE;
}
ULONG WINAPI IDirectMusicLoaderResourceStream_IStream_AddRef (LPSTREAM iface) {
ICOM_THIS_MULTI(IDirectMusicLoaderResourceStream, StreamVtbl, iface);
TRACE("(%p): AddRef from %ld\n", This, This->dwRef);
return InterlockedIncrement (&This->dwRef);
}
ULONG WINAPI IDirectMusicLoaderResourceStream_IStream_Release (LPSTREAM iface) {
ICOM_THIS_MULTI(IDirectMusicLoaderResourceStream, StreamVtbl, iface);
DWORD dwRef = InterlockedDecrement (&This->dwRef);
TRACE("(%p): ReleaseRef to %ld\n", This, dwRef);
if (dwRef == 0) {
DMUSIC_DestroyDirectMusicLoaderResourceStream (iface);
}
return dwRef;
}
HRESULT WINAPI IDirectMusicLoaderResourceStream_IStream_Read (LPSTREAM iface, void* pv, ULONG cb, ULONG* pcbRead) {
LPBYTE pByte;
ICOM_THIS_MULTI(IDirectMusicLoaderResourceStream, StreamVtbl, iface);
TRACE_(dmfileraw)("(%p, %p, 0x%08lX, %p)\n", This, pv, cb, pcbRead);
if ((This->llPos + cb) > This->llMemLength) {
WARN_(dmfileraw)(": requested size out of range\n");
return E_FAIL;
}
pByte = &This->pbMemData[This->llPos];
memcpy (pv, pByte, cb);
This->llPos += cb; /* move pointer */
/* FIXME: error checking would be nice */
*pcbRead = cb;
TRACE_(dmfileraw)(": data (size = 0x%08lX): '%s'\n", *pcbRead, debugstr_an(pv, *pcbRead));
return S_OK;
}
HRESULT WINAPI IDirectMusicLoaderResourceStream_IStream_Seek (LPSTREAM iface, LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER* plibNewPosition) {
ICOM_THIS_MULTI(IDirectMusicLoaderResourceStream, StreamVtbl, iface);
TRACE_(dmfileraw)("(%p, 0x%08llX, %s, %p)\n", This, dlibMove.QuadPart, resolve_STREAM_SEEK(dwOrigin), plibNewPosition);
switch (dwOrigin) {
case STREAM_SEEK_CUR: {
if ((This->llPos + dlibMove.QuadPart) > This->llMemLength) {
WARN_(dmfileraw)(": requested offset out of range\n");
return E_FAIL;
}
break;
}
case STREAM_SEEK_SET: {
if (dlibMove.QuadPart > This->llMemLength) {
WARN_(dmfileraw)(": requested offset out of range\n");
return E_FAIL;
}
/* set to the beginning of the stream */
This->llPos = 0;
break;
}
case STREAM_SEEK_END: {
/* TODO: check if this is true... I do think offset should be negative in this case */
if (dlibMove.QuadPart > 0) {
WARN_(dmfileraw)(": requested offset out of range\n");
return E_FAIL;
}
/* set to the end of the stream */
This->llPos = This->llMemLength;
break;
}
default: {
ERR_(dmfileraw)(": invalid dwOrigin\n");
return E_FAIL;
}
}
/* now simply add */
This->llPos += dlibMove.QuadPart;
if (plibNewPosition) plibNewPosition->QuadPart = This->llPos;
return S_OK;
}
HRESULT WINAPI IDirectMusicLoaderResourceStream_IStream_Clone (LPSTREAM iface, IStream** ppstm) {
ICOM_THIS_MULTI(IDirectMusicLoaderResourceStream, StreamVtbl, iface);
LPSTREAM pOther = NULL;
HRESULT result;
TRACE("(%p, %p)\n", iface, ppstm);
result = DMUSIC_CreateDirectMusicLoaderResourceStream ((LPVOID*)&pOther);
if (FAILED(result)) return result;
IDirectMusicLoaderResourceStream_Attach (pOther, This->pbMemData, This->llMemLength, This->llPos, This->pLoader);
TRACE(": succeeded\n");
*ppstm = (IStream*)pOther;
return S_OK;
}
HRESULT WINAPI IDirectMusicLoaderResourceStream_IStream_Write (LPSTREAM iface, const void* pv, ULONG cb, ULONG* pcbWritten) {
ERR(": should not be needed\n");
return E_NOTIMPL;
}
HRESULT WINAPI IDirectMusicLoaderResourceStream_IStream_SetSize (LPSTREAM iface, ULARGE_INTEGER libNewSize) {
ERR(": should not be needed\n");
return E_NOTIMPL;
}
HRESULT WINAPI IDirectMusicLoaderResourceStream_IStream_CopyTo (LPSTREAM iface, IStream* pstm, ULARGE_INTEGER cb, ULARGE_INTEGER* pcbRead, ULARGE_INTEGER* pcbWritten) {
ERR(": should not be needed\n");
return E_NOTIMPL;
}
HRESULT WINAPI IDirectMusicLoaderResourceStream_IStream_Commit (LPSTREAM iface, DWORD grfCommitFlags) {
ERR(": should not be needed\n");
return E_NOTIMPL;
}
HRESULT WINAPI IDirectMusicLoaderResourceStream_IStream_Revert (LPSTREAM iface) {
ERR(": should not be needed\n");
return E_NOTIMPL;
}
HRESULT WINAPI IDirectMusicLoaderResourceStream_IStream_LockRegion (LPSTREAM iface, ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType) {
ERR(": should not be needed\n");
return E_NOTIMPL;
}
HRESULT WINAPI IDirectMusicLoaderResourceStream_IStream_UnlockRegion (LPSTREAM iface, ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType) {
ERR(": should not be needed\n");
return E_NOTIMPL;
}
HRESULT WINAPI IDirectMusicLoaderResourceStream_IStream_Stat (LPSTREAM iface, STATSTG* pstatstg, DWORD grfStatFlag) {
ERR(": should not be needed\n");
return E_NOTIMPL;
}
ICOM_VTABLE(IStream) DirectMusicLoaderResourceStream_Stream_Vtbl = {
ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
IDirectMusicLoaderResourceStream_IStream_QueryInterface,
IDirectMusicLoaderResourceStream_IStream_AddRef,
IDirectMusicLoaderResourceStream_IStream_Release,
IDirectMusicLoaderResourceStream_IStream_Read,
IDirectMusicLoaderResourceStream_IStream_Write,
IDirectMusicLoaderResourceStream_IStream_Seek,
IDirectMusicLoaderResourceStream_IStream_SetSize,
IDirectMusicLoaderResourceStream_IStream_CopyTo,
IDirectMusicLoaderResourceStream_IStream_Commit,
IDirectMusicLoaderResourceStream_IStream_Revert,
IDirectMusicLoaderResourceStream_IStream_LockRegion,
IDirectMusicLoaderResourceStream_IStream_UnlockRegion,
IDirectMusicLoaderResourceStream_IStream_Stat,
IDirectMusicLoaderResourceStream_IStream_Clone
};
/* IDirectMusicGetLoader part: */
HRESULT WINAPI IDirectMusicLoaderResourceStream_IDirectMusicGetLoader_QueryInterface (LPDIRECTMUSICGETLOADER iface, REFIID riid, void** ppobj) {
ICOM_THIS_MULTI(IDirectMusicLoaderResourceStream, GetLoaderVtbl, iface);
return IDirectMusicLoaderResourceStream_IStream_QueryInterface ((LPSTREAM)&This->StreamVtbl, riid, ppobj);
}
ULONG WINAPI IDirectMusicLoaderResourceStream_IDirectMusicGetLoader_AddRef (LPDIRECTMUSICGETLOADER iface) {
ICOM_THIS_MULTI(IDirectMusicLoaderResourceStream, GetLoaderVtbl, iface);
return IDirectMusicLoaderResourceStream_IStream_AddRef ((LPSTREAM)&This->StreamVtbl);
}
ULONG WINAPI IDirectMusicLoaderResourceStream_IDirectMusicGetLoader_Release (LPDIRECTMUSICGETLOADER iface) {
ICOM_THIS_MULTI(IDirectMusicLoaderResourceStream, GetLoaderVtbl, iface);
return IDirectMusicLoaderResourceStream_IStream_Release ((LPSTREAM)&This->StreamVtbl);
}
HRESULT WINAPI IDirectMusicLoaderResourceStream_IDirectMusicGetLoader_GetLoader (LPDIRECTMUSICGETLOADER iface, IDirectMusicLoader **ppLoader) {
ICOM_THIS_MULTI(IDirectMusicLoaderResourceStream, GetLoaderVtbl, iface);
TRACE("(%p, %p)\n", This, ppLoader);
*ppLoader = (LPDIRECTMUSICLOADER)This->pLoader;
IDirectMusicLoader8_AddRef ((LPDIRECTMUSICLOADER8)*ppLoader);
return S_OK;
}
ICOM_VTABLE(IDirectMusicGetLoader) DirectMusicLoaderResourceStream_GetLoader_Vtbl = {
ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
IDirectMusicLoaderResourceStream_IDirectMusicGetLoader_QueryInterface,
IDirectMusicLoaderResourceStream_IDirectMusicGetLoader_AddRef,
IDirectMusicLoaderResourceStream_IDirectMusicGetLoader_Release,
IDirectMusicLoaderResourceStream_IDirectMusicGetLoader_GetLoader
};
HRESULT WINAPI DMUSIC_CreateDirectMusicLoaderResourceStream (LPVOID* ppobj) {
IDirectMusicLoaderResourceStream *obj;
TRACE("(%p)\n", ppobj);
obj = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, sizeof(IDirectMusicLoaderResourceStream));
if (NULL == obj) {
*ppobj = (LPVOID) NULL;
return E_OUTOFMEMORY;
}
obj->StreamVtbl = &DirectMusicLoaderResourceStream_Stream_Vtbl;
obj->GetLoaderVtbl = &DirectMusicLoaderResourceStream_GetLoader_Vtbl;
obj->dwRef = 0; /* will be inited with QueryInterface */
return IDirectMusicLoaderResourceStream_IStream_QueryInterface ((LPSTREAM)&obj->StreamVtbl, &IID_IStream, ppobj);
}
HRESULT WINAPI DMUSIC_DestroyDirectMusicLoaderResourceStream (LPSTREAM iface) {
ICOM_THIS_MULTI(IDirectMusicLoaderResourceStream, StreamVtbl, iface);
TRACE("(%p)\n", iface);
IDirectMusicLoaderResourceStream_Detach (iface);
HeapFree (GetProcessHeap(), 0, This);
return S_OK;
}
/*****************************************************************************
* IDirectMusicLoaderGenericStream implementation
*/
/* Custom : */
HRESULT WINAPI IDirectMusicLoaderGenericStream_Attach (LPSTREAM iface, LPSTREAM pStream, LPDIRECTMUSICLOADER pLoader) {
ICOM_THIS_MULTI(IDirectMusicLoaderGenericStream, StreamVtbl, iface);
TRACE("(%p, %p, %p)\n", This, pStream, pLoader);
if (!pStream) {
WARN(": invalid pStream\n");
return E_FAIL;
}
if (!pLoader) {
WARN(": invalid pLoader\n");
return E_FAIL;
}
IDirectMusicLoaderGenericStream_Detach (iface);
IStream_Clone (pStream, &This->pStream);
This->pLoader = pLoader;
return S_OK;
}
void WINAPI IDirectMusicLoaderGenericStream_Detach (LPSTREAM iface) {
ICOM_THIS_MULTI(IDirectMusicLoaderGenericStream, StreamVtbl, iface);
if (This->pStream)
IStream_Release (This->pStream);
This->pStream = NULL;
}
/* IUnknown/IStream part: */
HRESULT WINAPI IDirectMusicLoaderGenericStream_IStream_QueryInterface (LPSTREAM iface, REFIID riid, void** ppobj) {
ICOM_THIS_MULTI(IDirectMusicLoaderGenericStream, StreamVtbl, iface);
TRACE("(%p, %s, %p)\n", This, debugstr_dmguid(riid), ppobj);
if (IsEqualIID (riid, &IID_IUnknown) ||
IsEqualIID (riid, &IID_IStream)) {
*ppobj = (LPVOID)&This->StreamVtbl;
IDirectMusicLoaderGenericStream_IStream_AddRef ((LPSTREAM)&This->StreamVtbl);
return S_OK;
} else if (IsEqualIID (riid, &IID_IDirectMusicGetLoader)) {
*ppobj = (LPVOID)&This->GetLoaderVtbl;
IDirectMusicLoaderGenericStream_IDirectMusicGetLoader_AddRef ((LPDIRECTMUSICGETLOADER)&This->GetLoaderVtbl);
return S_OK;
}
WARN(": not found\n");
return E_NOINTERFACE;
}
ULONG WINAPI IDirectMusicLoaderGenericStream_IStream_AddRef (LPSTREAM iface) {
ICOM_THIS_MULTI(IDirectMusicLoaderGenericStream, StreamVtbl, iface);
TRACE("(%p): AddRef from %ld\n", This, This->dwRef);
return InterlockedIncrement (&This->dwRef);
}
ULONG WINAPI IDirectMusicLoaderGenericStream_IStream_Release (LPSTREAM iface) {
ICOM_THIS_MULTI(IDirectMusicLoaderGenericStream, StreamVtbl, iface);
DWORD dwRef = InterlockedDecrement (&This->dwRef);
TRACE("(%p): ReleaseRef to %ld\n", This, dwRef);
if (dwRef == 0) {
DMUSIC_DestroyDirectMusicLoaderGenericStream (iface);
}
return dwRef;
}
HRESULT WINAPI IDirectMusicLoaderGenericStream_IStream_Read (LPSTREAM iface, void* pv, ULONG cb, ULONG* pcbRead) {
ICOM_THIS_MULTI(IDirectMusicLoaderGenericStream, StreamVtbl, iface);
TRACE_(dmfileraw)("(%p, %p, 0x%08lX, %p): redirecting to low-level stream\n", This, pv, cb, pcbRead);
if (!This->pStream)
return E_FAIL;
return IStream_Read (This->pStream, pv, cb, pcbRead);
}
HRESULT WINAPI IDirectMusicLoaderGenericStream_IStream_Seek (LPSTREAM iface, LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER* plibNewPosition) {
ICOM_THIS_MULTI(IDirectMusicLoaderGenericStream, StreamVtbl, iface);
TRACE_(dmfileraw)("(%p, 0x%08llX, %s, %p): redirecting to low-level stream\n", This, dlibMove.QuadPart, resolve_STREAM_SEEK(dwOrigin), plibNewPosition);
if (!This->pStream)
return E_FAIL;
return IStream_Seek (This->pStream, dlibMove, dwOrigin, plibNewPosition);
}
HRESULT WINAPI IDirectMusicLoaderGenericStream_IStream_Clone (LPSTREAM iface, IStream** ppstm) {
ICOM_THIS_MULTI(IDirectMusicLoaderGenericStream, StreamVtbl, iface);
LPSTREAM pOther = NULL;
LPSTREAM pLowLevel = NULL;
HRESULT result;
TRACE("(%p, %p)\n", iface, ppstm);
result = DMUSIC_CreateDirectMusicLoaderGenericStream ((LPVOID*)&pOther);
if (FAILED(result)) return result;
if (FAILED(IStream_Clone (This->pStream, &pLowLevel)))
return E_FAIL;
IDirectMusicLoaderGenericStream_Attach (pOther, pLowLevel, This->pLoader);
TRACE(": succeeded\n");
*ppstm = (IStream*)pOther;
return S_OK;
}
HRESULT WINAPI IDirectMusicLoaderGenericStream_IStream_Write (LPSTREAM iface, const void* pv, ULONG cb, ULONG* pcbWritten) {
ICOM_THIS_MULTI(IDirectMusicLoaderGenericStream, StreamVtbl, iface);
TRACE_(dmfileraw)("(%p, %p, 0x%08lX, %p): redirecting to low-level stream\n", This, pv, cb, pcbWritten);
if (!This->pStream)
return E_FAIL;
return IStream_Write (This->pStream, pv, cb, pcbWritten);
}
HRESULT WINAPI IDirectMusicLoaderGenericStream_IStream_SetSize (LPSTREAM iface, ULARGE_INTEGER libNewSize) {
ICOM_THIS_MULTI(IDirectMusicLoaderGenericStream, StreamVtbl, iface);
TRACE("(%p, 0x%08llX): redirecting to low-level stream\n", This, libNewSize.QuadPart);
if (!This->pStream)
return E_FAIL;
return IStream_SetSize (This->pStream, libNewSize);
}
HRESULT WINAPI IDirectMusicLoaderGenericStream_IStream_CopyTo (LPSTREAM iface, IStream* pstm, ULARGE_INTEGER cb, ULARGE_INTEGER* pcbRead, ULARGE_INTEGER* pcbWritten) {
ICOM_THIS_MULTI(IDirectMusicLoaderGenericStream, StreamVtbl, iface);
TRACE("(%p, %p, 0x%08llX, %p, %p): redirecting to low-level stream\n", This, pstm, cb.QuadPart, pcbRead, pcbWritten);
if (!This->pStream)
return E_FAIL;
return IStream_CopyTo (This->pStream, pstm, cb, pcbRead, pcbWritten);
}
HRESULT WINAPI IDirectMusicLoaderGenericStream_IStream_Commit (LPSTREAM iface, DWORD grfCommitFlags) {
ICOM_THIS_MULTI(IDirectMusicLoaderGenericStream, StreamVtbl, iface);
TRACE("(%p, 0x%08lX): redirecting to low-level stream\n", This, grfCommitFlags);
if (!This->pStream)
return E_FAIL;
return IStream_Commit (This->pStream, grfCommitFlags);
}
HRESULT WINAPI IDirectMusicLoaderGenericStream_IStream_Revert (LPSTREAM iface) {
ICOM_THIS_MULTI(IDirectMusicLoaderGenericStream, StreamVtbl, iface);
TRACE("(%p): redirecting to low-level stream\n", This);
if (!This->pStream)
return E_FAIL;
return IStream_Revert (This->pStream);
}
HRESULT WINAPI IDirectMusicLoaderGenericStream_IStream_LockRegion (LPSTREAM iface, ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType) {
ICOM_THIS_MULTI(IDirectMusicLoaderGenericStream, StreamVtbl, iface);
TRACE("(%p, 0x%08llX, 0x%08llX, 0x%08lX): redirecting to low-level stream\n", This, libOffset.QuadPart, cb.QuadPart, dwLockType);
if (!This->pStream)
return E_FAIL;
return IStream_LockRegion (This->pStream, libOffset, cb, dwLockType);
}
HRESULT WINAPI IDirectMusicLoaderGenericStream_IStream_UnlockRegion (LPSTREAM iface, ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType) {
ICOM_THIS_MULTI(IDirectMusicLoaderGenericStream, StreamVtbl, iface);
TRACE("(%p, 0x%08llX, 0x%08llX, 0x%08lX): redirecting to low-level stream\n", This, libOffset.QuadPart, cb.QuadPart, dwLockType);
if (!This->pStream)
return E_FAIL;
return IStream_UnlockRegion (This->pStream, libOffset, cb, dwLockType);
}
HRESULT WINAPI IDirectMusicLoaderGenericStream_IStream_Stat (LPSTREAM iface, STATSTG* pstatstg, DWORD grfStatFlag) {
ICOM_THIS_MULTI(IDirectMusicLoaderGenericStream, StreamVtbl, iface);
TRACE("(%p, %p, 0x%08lX): redirecting to low-level stream\n", This, pstatstg, grfStatFlag);
if (!This->pStream)
return E_FAIL;
return IStream_Stat (This->pStream, pstatstg, grfStatFlag);
}
ICOM_VTABLE(IStream) DirectMusicLoaderGenericStream_Stream_Vtbl = {
ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
IDirectMusicLoaderGenericStream_IStream_QueryInterface,
IDirectMusicLoaderGenericStream_IStream_AddRef,
IDirectMusicLoaderGenericStream_IStream_Release,
IDirectMusicLoaderGenericStream_IStream_Read,
IDirectMusicLoaderGenericStream_IStream_Write,
IDirectMusicLoaderGenericStream_IStream_Seek,
IDirectMusicLoaderGenericStream_IStream_SetSize,
IDirectMusicLoaderGenericStream_IStream_CopyTo,
IDirectMusicLoaderGenericStream_IStream_Commit,
IDirectMusicLoaderGenericStream_IStream_Revert,
IDirectMusicLoaderGenericStream_IStream_LockRegion,
IDirectMusicLoaderGenericStream_IStream_UnlockRegion,
IDirectMusicLoaderGenericStream_IStream_Stat,
IDirectMusicLoaderGenericStream_IStream_Clone
};
/* IDirectMusicGetLoader part: */
HRESULT WINAPI IDirectMusicLoaderGenericStream_IDirectMusicGetLoader_QueryInterface (LPDIRECTMUSICGETLOADER iface, REFIID riid, void** ppobj) {
ICOM_THIS_MULTI(IDirectMusicLoaderGenericStream, GetLoaderVtbl, iface);
return IDirectMusicLoaderGenericStream_IStream_QueryInterface ((LPSTREAM)&This->StreamVtbl, riid, ppobj);
}
ULONG WINAPI IDirectMusicLoaderGenericStream_IDirectMusicGetLoader_AddRef (LPDIRECTMUSICGETLOADER iface) {
ICOM_THIS_MULTI(IDirectMusicLoaderGenericStream, GetLoaderVtbl, iface);
return IDirectMusicLoaderGenericStream_IStream_AddRef ((LPSTREAM)&This->StreamVtbl);
}
ULONG WINAPI IDirectMusicLoaderGenericStream_IDirectMusicGetLoader_Release (LPDIRECTMUSICGETLOADER iface) {
ICOM_THIS_MULTI(IDirectMusicLoaderGenericStream, GetLoaderVtbl, iface);
return IDirectMusicLoaderGenericStream_IStream_Release ((LPSTREAM)&This->StreamVtbl);
}
HRESULT WINAPI IDirectMusicLoaderGenericStream_IDirectMusicGetLoader_GetLoader (LPDIRECTMUSICGETLOADER iface, IDirectMusicLoader **ppLoader) {
ICOM_THIS_MULTI(IDirectMusicLoaderGenericStream, GetLoaderVtbl, iface);
TRACE("(%p, %p)\n", This, ppLoader);
*ppLoader = (LPDIRECTMUSICLOADER)This->pLoader;
IDirectMusicLoader8_AddRef ((LPDIRECTMUSICLOADER8)*ppLoader);
return S_OK;
}
ICOM_VTABLE(IDirectMusicGetLoader) DirectMusicLoaderGenericStream_GetLoader_Vtbl = {
ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
IDirectMusicLoaderGenericStream_IDirectMusicGetLoader_QueryInterface,
IDirectMusicLoaderGenericStream_IDirectMusicGetLoader_AddRef,
IDirectMusicLoaderGenericStream_IDirectMusicGetLoader_Release,
IDirectMusicLoaderGenericStream_IDirectMusicGetLoader_GetLoader
};
HRESULT WINAPI DMUSIC_CreateDirectMusicLoaderGenericStream (LPVOID* ppobj) {
IDirectMusicLoaderGenericStream *obj;
TRACE("(%p)\n", ppobj);
obj = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, sizeof(IDirectMusicLoaderGenericStream));
if (NULL == obj) {
*ppobj = (LPVOID) NULL;
return E_OUTOFMEMORY;
}
obj->StreamVtbl = &DirectMusicLoaderGenericStream_Stream_Vtbl;
obj->GetLoaderVtbl = &DirectMusicLoaderGenericStream_GetLoader_Vtbl;
obj->dwRef = 0; /* will be inited with QueryInterface */
return IDirectMusicLoaderGenericStream_IStream_QueryInterface ((LPSTREAM)&obj->StreamVtbl, &IID_IStream, ppobj);
}
HRESULT WINAPI DMUSIC_DestroyDirectMusicLoaderGenericStream (LPSTREAM iface) {
ICOM_THIS_MULTI(IDirectMusicLoaderGenericStream, StreamVtbl, iface);
TRACE("(%p)\n", iface);
IDirectMusicLoaderGenericStream_Detach (iface);
HeapFree (GetProcessHeap(), 0, This);
return S_OK;
}