[DMUSIC] Sync with Wine Staging 4.18. CORE-16441

This commit is contained in:
Amine Khaldi 2019-10-26 13:04:24 +01:00
parent 8de4fae42b
commit c1cf2ac305
5 changed files with 149 additions and 30 deletions

View file

@ -155,7 +155,7 @@ static HRESULT WINAPI IDirectMusicCollectionImpl_EnumInstrument(IDirectMusicColl
IDirectMusicInstrumentImpl *instrument = impl_from_IDirectMusicInstrument(inst_entry->pInstrument); IDirectMusicInstrumentImpl *instrument = impl_from_IDirectMusicInstrument(inst_entry->pInstrument);
IDirectMusicInstrument_GetPatch(inst_entry->pInstrument, patch); IDirectMusicInstrument_GetPatch(inst_entry->pInstrument, patch);
if (name) { if (name) {
length = min(strlenW(instrument->wszName), name_length - 1); length = min(lstrlenW(instrument->wszName), name_length - 1);
memcpy(name, instrument->wszName, length * sizeof(WCHAR)); memcpy(name, instrument->wszName, length * sizeof(WCHAR));
name[length] = '\0'; name[length] = '\0';
} }
@ -499,13 +499,7 @@ static HRESULT WINAPI IPersistStreamImpl_Load(IPersistStream *iface,
struct list *listEntry; struct list *listEntry;
TRACE("*** IDirectMusicCollection (%p) ***\n", &This->IDirectMusicCollection_iface); TRACE("*** IDirectMusicCollection (%p) ***\n", &This->IDirectMusicCollection_iface);
if (This->dmobj.desc.dwValidData & DMUS_OBJ_OBJECT) dump_DMUS_OBJECTDESC(&This->dmobj.desc);
TRACE(" - GUID = %s\n", debugstr_dmguid(&This->dmobj.desc.guidObject));
if (This->dmobj.desc.dwValidData & DMUS_OBJ_VERSION)
TRACE(" - Version = %i,%i,%i,%i\n", (This->dmobj.desc.vVersion.dwVersionMS >> 8) & 0x0000FFFF, This->dmobj.desc.vVersion.dwVersionMS & 0x0000FFFF,
(This->dmobj.desc.vVersion.dwVersionLS >> 8) & 0x0000FFFF, This->dmobj.desc.vVersion.dwVersionLS & 0x0000FFFF);
if (This->dmobj.desc.dwValidData & DMUS_OBJ_NAME)
TRACE(" - Name = %s\n", debugstr_w(This->dmobj.desc.wszName));
TRACE(" - Collection header:\n"); TRACE(" - Collection header:\n");
TRACE(" - cInstruments: %d\n", This->pHeader->cInstruments); TRACE(" - cInstruments: %d\n", This->pHeader->cInstruments);

View file

@ -22,9 +22,132 @@
#include <stdio.h> #include <stdio.h>
#include "dmusic_private.h" #include "dmusic_private.h"
#include "wine/heap.h"
WINE_DEFAULT_DEBUG_CHANNEL(dmusic); WINE_DEFAULT_DEBUG_CHANNEL(dmusic);
struct master_clock {
IReferenceClock IReferenceClock_iface;
LONG ref;
double freq;
REFERENCE_TIME last_time;
};
static inline struct master_clock *impl_from_IReferenceClock(IReferenceClock *iface)
{
return CONTAINING_RECORD(iface, struct master_clock, IReferenceClock_iface);
}
static HRESULT WINAPI master_IReferenceClock_QueryInterface(IReferenceClock *iface, REFIID riid,
void **ret_iface)
{
TRACE("(%p, %s, %p)\n", iface, debugstr_dmguid(riid), ret_iface);
if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IReferenceClock))
*ret_iface = iface;
else {
WARN("no interface for %s\n", debugstr_dmguid(riid));
*ret_iface = NULL;
return E_NOINTERFACE;
}
IReferenceClock_AddRef(iface);
return S_OK;
}
static ULONG WINAPI master_IReferenceClock_AddRef(IReferenceClock *iface)
{
struct master_clock *This = impl_from_IReferenceClock(iface);
ULONG ref = InterlockedIncrement(&This->ref);
TRACE("(%p) ref = %u\n", iface, ref);
return ref;
}
static ULONG WINAPI master_IReferenceClock_Release(IReferenceClock *iface)
{
struct master_clock *This = impl_from_IReferenceClock(iface);
ULONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p) ref = %u\n", iface, ref);
if (!ref)
heap_free(This);
return ref;
}
static HRESULT WINAPI master_IReferenceClock_GetTime(IReferenceClock *iface,
REFERENCE_TIME *time)
{
struct master_clock *This = impl_from_IReferenceClock(iface);
LARGE_INTEGER counter;
HRESULT hr;
TRACE("(%p, %p)\n", iface, time);
QueryPerformanceCounter(&counter);
*time = counter.QuadPart * This->freq;
hr = (*time == This->last_time) ? S_FALSE : S_OK;
This->last_time = *time;
return hr;
}
static HRESULT WINAPI master_IReferenceClock_AdviseTime(IReferenceClock *iface,
REFERENCE_TIME base, REFERENCE_TIME offset, HANDLE event, DWORD *cookie)
{
TRACE("(%p, %s, %s, %p, %p): method not implemented\n", iface, wine_dbgstr_longlong(base),
wine_dbgstr_longlong(offset), event, cookie);
return E_NOTIMPL;
}
static HRESULT WINAPI master_IReferenceClock_AdvisePeriodic(IReferenceClock *iface,
REFERENCE_TIME start, REFERENCE_TIME period, HANDLE semaphore, DWORD *cookie)
{
TRACE("(%p, %s, %s, %p, %p): method not implemented\n", iface, wine_dbgstr_longlong(start),
wine_dbgstr_longlong(period), semaphore, cookie);
return E_NOTIMPL;
}
static HRESULT WINAPI master_IReferenceClock_Unadvise(IReferenceClock *iface, DWORD cookie)
{
TRACE("(%p, %#x): method not implemented\n", iface, cookie);
return E_NOTIMPL;
}
static const IReferenceClockVtbl master_clock_vtbl = {
master_IReferenceClock_QueryInterface,
master_IReferenceClock_AddRef,
master_IReferenceClock_Release,
master_IReferenceClock_GetTime,
master_IReferenceClock_AdviseTime,
master_IReferenceClock_AdvisePeriodic,
master_IReferenceClock_Unadvise,
};
static HRESULT master_clock_create(IReferenceClock **clock)
{
struct master_clock *obj;
LARGE_INTEGER freq;
TRACE("(%p)\n", clock);
if (!(obj = heap_alloc_zero(sizeof(*obj))))
return E_OUTOFMEMORY;
obj->IReferenceClock_iface.lpVtbl = &master_clock_vtbl;
obj->ref = 1;
QueryPerformanceFrequency(&freq);
obj->freq = 10000000.0 / freq.QuadPart;
*clock = &obj->IReferenceClock_iface;
return S_OK;
}
static inline IDirectMusic8Impl *impl_from_IDirectMusic8(IDirectMusic8 *iface) static inline IDirectMusic8Impl *impl_from_IDirectMusic8(IDirectMusic8 *iface)
{ {
return CONTAINING_RECORD(iface, IDirectMusic8Impl, IDirectMusic8_iface); return CONTAINING_RECORD(iface, IDirectMusic8Impl, IDirectMusic8_iface);
@ -72,7 +195,7 @@ static ULONG WINAPI IDirectMusic8Impl_Release(LPDIRECTMUSIC8 iface)
TRACE("(%p)->(): new ref = %u\n", This, ref); TRACE("(%p)->(): new ref = %u\n", This, ref);
if (!ref) { if (!ref) {
IReferenceClock_Release(&This->master_clock->IReferenceClock_iface); IReferenceClock_Release(This->master_clock);
if (This->dsound) if (This->dsound)
IDirectSound_Release(This->dsound); IDirectSound_Release(This->dsound);
HeapFree(GetProcessHeap(), 0, This->system_ports); HeapFree(GetProcessHeap(), 0, This->system_ports);
@ -224,7 +347,7 @@ static HRESULT WINAPI IDirectMusic8Impl_EnumMasterClock(LPDIRECTMUSIC8 iface, DW
clock_info->ctType = 0; clock_info->ctType = 0;
clock_info->guidClock = guid_system_clock; clock_info->guidClock = guid_system_clock;
strcpyW(clock_info->wszDescription, name_system_clock); lstrcpyW(clock_info->wszDescription, name_system_clock);
} }
else else
{ {
@ -233,7 +356,7 @@ static HRESULT WINAPI IDirectMusic8Impl_EnumMasterClock(LPDIRECTMUSIC8 iface, DW
clock_info->ctType = 0; clock_info->ctType = 0;
clock_info->guidClock = guid_dsound_clock; clock_info->guidClock = guid_dsound_clock;
strcpyW(clock_info->wszDescription, name_dsound_clock); lstrcpyW(clock_info->wszDescription, name_dsound_clock);
} }
return S_OK; return S_OK;
@ -246,9 +369,9 @@ static HRESULT WINAPI IDirectMusic8Impl_GetMasterClock(LPDIRECTMUSIC8 iface, LPG
TRACE("(%p)->(%p, %p)\n", This, guid_clock, reference_clock); TRACE("(%p)->(%p, %p)\n", This, guid_clock, reference_clock);
if (guid_clock) if (guid_clock)
*guid_clock = This->master_clock->pClockInfo.guidClock; *guid_clock = GUID_NULL;
if (reference_clock) { if (reference_clock) {
*reference_clock = &This->master_clock->IReferenceClock_iface; *reference_clock = This->master_clock;
IReferenceClock_AddRef(*reference_clock); IReferenceClock_AddRef(*reference_clock);
} }
@ -418,8 +541,8 @@ static void create_system_ports_list(IDirectMusic8Impl* object)
port->device = MIDI_MAPPER; port->device = MIDI_MAPPER;
port->create = midi_out_port_create; port->create = midi_out_port_create;
midiOutGetDevCapsW(MIDI_MAPPER, &caps_out, sizeof(caps_out)); midiOutGetDevCapsW(MIDI_MAPPER, &caps_out, sizeof(caps_out));
strcpyW(port->caps.wszDescription, caps_out.szPname); lstrcpyW(port->caps.wszDescription, caps_out.szPname);
strcatW(port->caps.wszDescription, emulated); lstrcatW(port->caps.wszDescription, emulated);
port->caps.dwFlags = DMUS_PC_SHAREABLE; port->caps.dwFlags = DMUS_PC_SHAREABLE;
port->caps.dwClass = DMUS_PC_OUTPUTCLASS; port->caps.dwClass = DMUS_PC_OUTPUTCLASS;
port++; port++;
@ -430,8 +553,8 @@ static void create_system_ports_list(IDirectMusic8Impl* object)
port->device = i; port->device = i;
port->create = midi_out_port_create; port->create = midi_out_port_create;
midiOutGetDevCapsW(i, &caps_out, sizeof(caps_out)); midiOutGetDevCapsW(i, &caps_out, sizeof(caps_out));
strcpyW(port->caps.wszDescription, caps_out.szPname); lstrcpyW(port->caps.wszDescription, caps_out.szPname);
strcatW(port->caps.wszDescription, emulated); lstrcatW(port->caps.wszDescription, emulated);
port->caps.dwFlags = DMUS_PC_SHAREABLE | DMUS_PC_EXTERNAL; port->caps.dwFlags = DMUS_PC_SHAREABLE | DMUS_PC_EXTERNAL;
port->caps.dwClass = DMUS_PC_OUTPUTCLASS; port->caps.dwClass = DMUS_PC_OUTPUTCLASS;
port++; port++;
@ -443,8 +566,8 @@ static void create_system_ports_list(IDirectMusic8Impl* object)
port->device = i; port->device = i;
port->create = midi_in_port_create; port->create = midi_in_port_create;
midiInGetDevCapsW(i, &caps_in, sizeof(caps_in)); midiInGetDevCapsW(i, &caps_in, sizeof(caps_in));
strcpyW(port->caps.wszDescription, caps_in.szPname); lstrcpyW(port->caps.wszDescription, caps_in.szPname);
strcatW(port->caps.wszDescription, emulated); lstrcatW(port->caps.wszDescription, emulated);
port->caps.dwFlags = DMUS_PC_EXTERNAL; port->caps.dwFlags = DMUS_PC_EXTERNAL;
port->caps.dwClass = DMUS_PC_INPUTCLASS; port->caps.dwClass = DMUS_PC_INPUTCLASS;
port++; port++;
@ -483,7 +606,7 @@ HRESULT WINAPI DMUSIC_CreateDirectMusicImpl(LPCGUID riid, LPVOID* ret_iface, LPU
dmusic->IDirectMusic8_iface.lpVtbl = &DirectMusic8_Vtbl; dmusic->IDirectMusic8_iface.lpVtbl = &DirectMusic8_Vtbl;
dmusic->ref = 1; dmusic->ref = 1;
ret = DMUSIC_CreateReferenceClockImpl(&IID_IReferenceClock, (void **)&dmusic->master_clock, NULL); ret = master_clock_create(&dmusic->master_clock);
if (FAILED(ret)) { if (FAILED(ret)) {
HeapFree(GetProcessHeap(), 0, dmusic); HeapFree(GetProcessHeap(), 0, dmusic);
return ret; return ret;

View file

@ -17,8 +17,6 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
#include "config.h"
#include "wine/port.h"
#include <stdio.h> #include <stdio.h>
#include <stdarg.h> #include <stdarg.h>
@ -226,11 +224,13 @@ const char *debugstr_fourcc (DWORD fourcc) {
} }
/* DMUS_VERSION struct to string conversion for debug messages */ /* DMUS_VERSION struct to string conversion for debug messages */
static const char *debugstr_dmversion (const DMUS_VERSION *version) { static const char *debugstr_dmversion(const DMUS_VERSION *version)
if (!version) return "'null'"; {
return wine_dbg_sprintf ("\'%i,%i,%i,%i\'", if (!version)
(int)((version->dwVersionMS & 0xFFFF0000) >> 8), (int)(version->dwVersionMS & 0x0000FFFF), return "'null'";
(int)((version->dwVersionLS & 0xFFFF0000) >> 8), (int)(version->dwVersionLS & 0x0000FFFF)); return wine_dbg_sprintf("'%hu,%hu,%hu,%hu'",
HIWORD(version->dwVersionMS), LOWORD(version->dwVersionMS),
HIWORD(version->dwVersionLS), LOWORD(version->dwVersionLS));
} }
/* returns name of given GUID */ /* returns name of given GUID */

View file

@ -33,10 +33,12 @@
#include "winnt.h" #include "winnt.h"
#include "wingdi.h" #include "wingdi.h"
#include "winuser.h" #include "winuser.h"
#ifdef __REACTOS__
#include "winnls.h"
#endif
#include "wine/debug.h" #include "wine/debug.h"
#include "wine/list.h" #include "wine/list.h"
#include "wine/unicode.h"
#include "winreg.h" #include "winreg.h"
#include "objbase.h" #include "objbase.h"
@ -112,7 +114,7 @@ struct IDirectMusic8Impl {
IDirectMusic8 IDirectMusic8_iface; IDirectMusic8 IDirectMusic8_iface;
LONG ref; LONG ref;
IDirectSound *dsound; IDirectSound *dsound;
IReferenceClockImpl *master_clock; IReferenceClock *master_clock;
IDirectMusicPort **ports; IDirectMusicPort **ports;
int num_ports; int num_ports;
port_info *system_ports; port_info *system_ports;

View file

@ -32,7 +32,7 @@ dll/directx/wine/ddraw # Synced to WineStaging-3.3
dll/directx/wine/devenum # Synced to WineStaging-4.18 dll/directx/wine/devenum # Synced to WineStaging-4.18
dll/directx/wine/dinput # Synced to WineStaging-4.18 dll/directx/wine/dinput # Synced to WineStaging-4.18
dll/directx/wine/dinput8 # Synced to WineStaging-3.3 dll/directx/wine/dinput8 # Synced to WineStaging-3.3
dll/directx/wine/dmusic # Synced to WineStaging-4.0 dll/directx/wine/dmusic # Synced to WineStaging-4.18
dll/directx/wine/dplay # Synced to WineStaging-3.3 dll/directx/wine/dplay # Synced to WineStaging-3.3
dll/directx/wine/dplayx # Synced to WineStaging-3.17 dll/directx/wine/dplayx # Synced to WineStaging-3.17
dll/directx/wine/dpnhpast # Synced to WineStaging-4.5 dll/directx/wine/dpnhpast # Synced to WineStaging-4.5