From d52d8cb6673fbd2d378210a219ef2676419abe96 Mon Sep 17 00:00:00 2001 From: Amine Khaldi Date: Sat, 3 Jun 2017 18:05:52 +0000 Subject: [PATCH] [DMUSIC] Sync with Wine Staging 2.9. CORE-13362 40a4a5c dmusic: Fail in CreatePort() if SetDirectSound() wasn't called. 62bf207 dmusic: Remove the port from the ports list on the port destruction. 3b4909f dmusic: Set the dsound pointer to NULL on an error path. 829ef41 dmusic: Fix compilation on systems that don't support nameless structs or unions. 43b3f84 dmusic: Add dsound handling to the synth port Activate() method. f968edb dmusic: Partially implement the synth IDirectMusicPort::SetDirectSound(). e8873b7 dmusic: Pass only the needed stuff to the DMPort create functions. 36a88d2 dmusic: Implement IDirectMusic8::SetDirectSound(). b75e8bc dmusic: Use more sensible and consistent field names for IDirectMusic8Impl. 950b8a9 dmusic: Avoid an intermediate copy in PackStructured(). 7cd7f14 dmusic: Implement IDirectMusicBuffer::PackUnstructured(). 4fbae8e dmusic: Use DMUS_EVENT_SIZE() to calculate the size of the message. svn path=/trunk/; revision=74777 --- .../dll/directx/wine/dmusic/CMakeLists.txt | 2 +- reactos/dll/directx/wine/dmusic/buffer.c | 39 +++--- reactos/dll/directx/wine/dmusic/dmusic.c | 118 ++++++++++++++---- .../dll/directx/wine/dmusic/dmusic_private.h | 30 +++-- reactos/dll/directx/wine/dmusic/port.c | 104 +++++++++++---- reactos/media/doc/README.WINE | 2 +- 6 files changed, 208 insertions(+), 87 deletions(-) diff --git a/reactos/dll/directx/wine/dmusic/CMakeLists.txt b/reactos/dll/directx/wine/dmusic/CMakeLists.txt index bb67dee2522..fbb71ded91d 100644 --- a/reactos/dll/directx/wine/dmusic/CMakeLists.txt +++ b/reactos/dll/directx/wine/dmusic/CMakeLists.txt @@ -22,6 +22,6 @@ add_library(dmusic SHARED set_module_type(dmusic win32dll) target_link_libraries(dmusic dxguid uuid wine) -add_importlibs(dmusic ole32 advapi32 winmm msvcrt kernel32 ntdll) +add_importlibs(dmusic ole32 advapi32 winmm dsound user32 msvcrt kernel32 ntdll) add_pch(dmusic dmusic_private.h SOURCE) add_cd_file(TARGET dmusic DESTINATION reactos/system32 FOR all) diff --git a/reactos/dll/directx/wine/dmusic/buffer.c b/reactos/dll/directx/wine/dmusic/buffer.c index 40d26f0750a..404200c46f7 100644 --- a/reactos/dll/directx/wine/dmusic/buffer.c +++ b/reactos/dll/directx/wine/dmusic/buffer.c @@ -98,8 +98,8 @@ static HRESULT WINAPI IDirectMusicBufferImpl_TotalTime(LPDIRECTMUSICBUFFER iface static HRESULT WINAPI IDirectMusicBufferImpl_PackStructured(LPDIRECTMUSICBUFFER iface, REFERENCE_TIME ref_time, DWORD channel_group, DWORD channel_message) { IDirectMusicBufferImpl *This = impl_from_IDirectMusicBuffer(iface); - DWORD new_write_pos = This->write_pos + sizeof(DMUS_EVENTHEADER) + sizeof(DWORD); - DMUS_EVENTHEADER header; + DWORD new_write_pos = This->write_pos + DMUS_EVENT_SIZE(sizeof(channel_message)); + DMUS_EVENTHEADER *header; TRACE("(%p)->(0x%s, %u, 0x%x)\n", iface, wine_dbgstr_longlong(ref_time), channel_group, channel_message); @@ -117,39 +117,40 @@ static HRESULT WINAPI IDirectMusicBufferImpl_PackStructured(LPDIRECTMUSICBUFFER if (!This->write_pos) This->start_time = ref_time; - header.cbEvent = 3; /* Midi message takes 4 bytes space but only 3 are relevant */ - header.dwChannelGroup = channel_group; - header.rtDelta = ref_time - This->start_time; - header.dwFlags = DMUS_EVENT_STRUCTURED; + header = (DMUS_EVENTHEADER*)&This->data[This->write_pos]; + header->cbEvent = 3; /* Midi message takes 4 bytes space but only 3 are relevant */ + header->dwChannelGroup = channel_group; + header->rtDelta = ref_time - This->start_time; + header->dwFlags = DMUS_EVENT_STRUCTURED; - memcpy(This->data + This->write_pos, &header, sizeof(header)); - *(DWORD*)(This->data + This->write_pos + sizeof(header)) = channel_message; + *(DWORD*)&header[1] = channel_message; This->write_pos = new_write_pos; return S_OK; } -static HRESULT WINAPI IDirectMusicBufferImpl_PackUnstructured(LPDIRECTMUSICBUFFER iface, REFERENCE_TIME rt, DWORD dwChannelGroup, DWORD cb, LPBYTE lpb) +static HRESULT WINAPI IDirectMusicBufferImpl_PackUnstructured(IDirectMusicBuffer *iface, + REFERENCE_TIME ref_time, DWORD channel_group, DWORD len, BYTE *data) { IDirectMusicBufferImpl *This = impl_from_IDirectMusicBuffer(iface); - DWORD new_write_pos = This->write_pos + sizeof(DMUS_EVENTHEADER) + cb; - DMUS_EVENTHEADER header; + DWORD new_write_pos = This->write_pos + DMUS_EVENT_SIZE(len); + DMUS_EVENTHEADER *header; - FIXME("(%p, 0x%s, %d, %d, %p): stub\n", This, wine_dbgstr_longlong(rt), dwChannelGroup, cb, lpb); + TRACE("(%p, 0x%s, %d, %d, %p)\n", This, wine_dbgstr_longlong(ref_time), channel_group, len, data); if (new_write_pos > This->size) return DMUS_E_BUFFER_FULL; if (!This->write_pos) - This->start_time = rt; + This->start_time = ref_time; - header.cbEvent = cb; - header.dwChannelGroup = dwChannelGroup; - header.rtDelta = rt - This->start_time; - header.dwFlags = 0; + header = (DMUS_EVENTHEADER*)&This->data[This->write_pos]; + header->cbEvent = len; + header->dwChannelGroup = channel_group; + header->rtDelta = ref_time - This->start_time; + header->dwFlags = 0; - memcpy(This->data + This->write_pos, &header, sizeof(header)); - memcpy(This->data + This->write_pos + sizeof(header), lpb, cb); + memcpy(&header[1], data, len); This->write_pos = new_write_pos; return S_OK; diff --git a/reactos/dll/directx/wine/dmusic/dmusic.c b/reactos/dll/directx/wine/dmusic/dmusic.c index 038b3668a72..bfc13b893b2 100644 --- a/reactos/dll/directx/wine/dmusic/dmusic.c +++ b/reactos/dll/directx/wine/dmusic/dmusic.c @@ -21,6 +21,7 @@ #include "dmusic_private.h" +#include #include static inline IDirectMusic8Impl *impl_from_IDirectMusic8(IDirectMusic8 *iface) @@ -70,9 +71,11 @@ static ULONG WINAPI IDirectMusic8Impl_Release(LPDIRECTMUSIC8 iface) TRACE("(%p)->(): new ref = %u\n", This, ref); if (!ref) { - IReferenceClock_Release(&This->pMasterClock->IReferenceClock_iface); + IReferenceClock_Release(&This->master_clock->IReferenceClock_iface); + if (This->dsound) + IDirectSound_Release(This->dsound); HeapFree(GetProcessHeap(), 0, This->system_ports); - HeapFree(GetProcessHeap(), 0, This->ppPorts); + HeapFree(GetProcessHeap(), 0, This->ports); HeapFree(GetProcessHeap(), 0, This); DMUSIC_UnlockModule(); } @@ -90,7 +93,7 @@ static HRESULT WINAPI IDirectMusic8Impl_EnumPort(LPDIRECTMUSIC8 iface, DWORD ind if (!port_caps) return E_POINTER; - if (index >= This->nb_system_ports) + if (index >= This->num_system_ports) return S_FALSE; *port_caps = This->system_ports[index].caps; @@ -125,14 +128,14 @@ static HRESULT WINAPI IDirectMusic8Impl_CreatePort(LPDIRECTMUSIC8 iface, REFCLSI TRACE("(%p)->(%s, %p, %p, %p)\n", This, debugstr_dmguid(rclsid_port), port_params, port, unkouter); - if (!rclsid_port) + if (!rclsid_port || !port) return E_POINTER; if (!port_params) return E_INVALIDARG; - if (!port) - return E_POINTER; if (unkouter) return CLASS_E_NOAGGREGATION; + if (!This->dsound) + return DMUS_E_DSOUND_NOT_SET; if (TRACE_ON(dmusic)) dump_DMUS_PORTPARAMS(port_params); @@ -149,17 +152,19 @@ static HRESULT WINAPI IDirectMusic8Impl_CreatePort(LPDIRECTMUSIC8 iface, REFCLSI for (i = 0; S_FALSE != IDirectMusic8Impl_EnumPort(iface, i, &port_caps); i++) { if (IsEqualCLSID(request_port, &port_caps.guidPort)) { - hr = This->system_ports[i].create(&IID_IDirectMusicPort, (LPVOID*)&new_port, (LPUNKNOWN)This, port_params, &port_caps, This->system_ports[i].device); + hr = This->system_ports[i].create(This, port_params, &port_caps, &new_port); if (FAILED(hr)) { *port = NULL; return hr; } - This->nrofports++; - if (!This->ppPorts) - This->ppPorts = HeapAlloc(GetProcessHeap(), 0, sizeof(LPDIRECTMUSICPORT) * This->nrofports); + This->num_ports++; + if (!This->ports) + This->ports = HeapAlloc(GetProcessHeap(), 0, + sizeof(*This->ports) * This->num_ports); else - This->ppPorts = HeapReAlloc(GetProcessHeap(), 0, This->ppPorts, sizeof(LPDIRECTMUSICPORT) * This->nrofports); - This->ppPorts[This->nrofports - 1] = new_port; + This->ports = HeapReAlloc(GetProcessHeap(), 0, This->ports, + sizeof(*This->ports) * This->num_ports); + This->ports[This->num_ports - 1] = new_port; *port = new_port; return S_OK; } @@ -168,6 +173,39 @@ static HRESULT WINAPI IDirectMusic8Impl_CreatePort(LPDIRECTMUSIC8 iface, REFCLSI return E_NOINTERFACE; } +void dmusic_remove_port(IDirectMusic8Impl *dmusic, IDirectMusicPort *port) +{ + BOOL found = FALSE; + int i; + + TRACE("Removing port %p.\n", port); + + for (i = 0; i < dmusic->num_ports; i++) + { + if (dmusic->ports[i] == port) { + found = TRUE; + break; + } + } + + if (!found) + { + ERR("Port %p not found in ports array.\n", port); + return; + } + + if (!--dmusic->num_ports) { + HeapFree(GetProcessHeap(), 0, dmusic->ports); + dmusic->ports = NULL; + return; + } + + memmove(&dmusic->ports[i], &dmusic->ports[i + 1], + (dmusic->num_ports - i) * sizeof(*dmusic->ports)); + dmusic->ports = HeapReAlloc(GetProcessHeap(), 0, dmusic->ports, + sizeof(*dmusic->ports) * dmusic->num_ports); +} + static HRESULT WINAPI IDirectMusic8Impl_EnumMasterClock(LPDIRECTMUSIC8 iface, DWORD index, LPDMUS_CLOCKINFO clock_info) { TRACE("(%p)->(%d, %p)\n", iface, index, clock_info); @@ -207,9 +245,9 @@ static HRESULT WINAPI IDirectMusic8Impl_GetMasterClock(LPDIRECTMUSIC8 iface, LPG TRACE("(%p)->(%p, %p)\n", This, guid_clock, reference_clock); if (guid_clock) - *guid_clock = This->pMasterClock->pClockInfo.guidClock; + *guid_clock = This->master_clock->pClockInfo.guidClock; if (reference_clock) { - *reference_clock = &This->pMasterClock->IReferenceClock_iface; + *reference_clock = &This->master_clock->IReferenceClock_iface; IReferenceClock_AddRef(*reference_clock); } @@ -233,9 +271,9 @@ static HRESULT WINAPI IDirectMusic8Impl_Activate(LPDIRECTMUSIC8 iface, BOOL enab TRACE("(%p)->(%u)\n", This, enable); - for (i = 0; i < This->nrofports; i++) + for (i = 0; i < This->num_ports; i++) { - hr = IDirectMusicPort_Activate(This->ppPorts[i], enable); + hr = IDirectMusicPort_Activate(This->ports[i], enable); if (FAILED(hr)) return hr; } @@ -269,11 +307,40 @@ static HRESULT WINAPI IDirectMusic8Impl_GetDefaultPort(LPDIRECTMUSIC8 iface, LPG return S_OK; } -static HRESULT WINAPI IDirectMusic8Impl_SetDirectSound(LPDIRECTMUSIC8 iface, LPDIRECTSOUND dsound, HWND wnd) +static HRESULT WINAPI IDirectMusic8Impl_SetDirectSound(IDirectMusic8 *iface, IDirectSound *dsound, + HWND hwnd) { IDirectMusic8Impl *This = impl_from_IDirectMusic8(iface); + HRESULT hr; + int i; - FIXME("(%p)->(%p, %p): stub\n", This, dsound, wnd); + TRACE("(%p)->(%p, %p)\n", This, dsound, hwnd); + + for (i = 0; i < This->num_ports; i++) + { + hr = IDirectMusicPort_SetDirectSound(This->ports[i], NULL, NULL); + if (FAILED(hr)) + return hr; + } + + if (This->dsound) + IDirectSound_Release(This->dsound); + + if (!dsound) { + hr = DirectSoundCreate8(NULL, (IDirectSound8 **)&This->dsound, NULL); + if (FAILED(hr)) + return hr; + hr = IDirectSound_SetCooperativeLevel(This->dsound, hwnd ? hwnd : GetForegroundWindow(), + DSSCL_PRIORITY); + if (FAILED(hr)) { + IDirectSound_Release(This->dsound); + This->dsound = NULL; + } + return hr; + } + + IDirectSound_AddRef(dsound); + This->dsound = dsound; return S_OK; } @@ -348,7 +415,7 @@ static void create_system_ports_list(IDirectMusic8Impl* object) /* Fill midi mapper port info */ port->device = MIDI_MAPPER; - port->create = DMUSIC_CreateMidiOutPortImpl; + port->create = midi_out_port_create; midiOutGetDevCapsW(MIDI_MAPPER, &caps_out, sizeof(caps_out)); strcpyW(port->caps.wszDescription, caps_out.szPname); strcatW(port->caps.wszDescription, emulated); @@ -360,7 +427,7 @@ static void create_system_ports_list(IDirectMusic8Impl* object) for (i = 0; i < nb_midi_out; i++) { port->device = i; - port->create = DMUSIC_CreateMidiOutPortImpl; + port->create = midi_out_port_create; midiOutGetDevCapsW(i, &caps_out, sizeof(caps_out)); strcpyW(port->caps.wszDescription, caps_out.szPname); strcatW(port->caps.wszDescription, emulated); @@ -373,7 +440,7 @@ static void create_system_ports_list(IDirectMusic8Impl* object) for (i = 0; i < nb_midi_in; i++) { port->device = i; - port->create = DMUSIC_CreateMidiInPortImpl; + port->create = midi_in_port_create; midiInGetDevCapsW(i, &caps_in, sizeof(caps_in)); strcpyW(port->caps.wszDescription, caps_in.szPname); strcatW(port->caps.wszDescription, emulated); @@ -383,7 +450,7 @@ static void create_system_ports_list(IDirectMusic8Impl* object) } /* Fill synth port info */ - port->create = DMUSIC_CreateSynthPortImpl; + port->create = synth_port_create; hr = CoCreateInstance(&CLSID_DirectMusicSynth, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectMusicSynth8, (void**)&synth); if (SUCCEEDED(hr)) { @@ -394,7 +461,7 @@ static void create_system_ports_list(IDirectMusic8Impl* object) if (FAILED(hr)) nb_ports--; - object->nb_system_ports = nb_ports; + object->num_system_ports = nb_ports; } /* For ClassFactory */ @@ -415,10 +482,7 @@ HRESULT WINAPI DMUSIC_CreateDirectMusicImpl(LPCGUID riid, LPVOID* ret_iface, LPU dmusic->IDirectMusic8_iface.lpVtbl = &DirectMusic8_Vtbl; dmusic->ref = 1; - dmusic->pMasterClock = NULL; - dmusic->ppPorts = NULL; - dmusic->nrofports = 0; - ret = DMUSIC_CreateReferenceClockImpl(&IID_IReferenceClock, (LPVOID*)&dmusic->pMasterClock, NULL); + ret = DMUSIC_CreateReferenceClockImpl(&IID_IReferenceClock, (void **)&dmusic->master_clock, NULL); if (FAILED(ret)) { HeapFree(GetProcessHeap(), 0, dmusic); return ret; diff --git a/reactos/dll/directx/wine/dmusic/dmusic_private.h b/reactos/dll/directx/wine/dmusic/dmusic_private.h index 7504bb0ecb1..2ba5e7462ec 100644 --- a/reactos/dll/directx/wine/dmusic/dmusic_private.h +++ b/reactos/dll/directx/wine/dmusic/dmusic_private.h @@ -31,6 +31,8 @@ #define COM_NO_WINDOWS_H #define COBJMACROS +#define NONAMELESSUNION +#define NONAMELESSSTRUCT #include #include @@ -75,7 +77,8 @@ typedef struct DMUSIC_PRIVATE_CHANNEL_GROUP_ { typedef struct port_info { DMUS_PORTCAPS caps; - HRESULT (*create)(LPCGUID guid, LPVOID *object, LPUNKNOWN unkouter, LPDMUS_PORTPARAMS port_params, LPDMUS_PORTCAPS port_caps, DWORD device); + HRESULT (*create)(IDirectMusic8Impl *parent, DMUS_PORTPARAMS *port_params, + DMUS_PORTCAPS *port_caps, IDirectMusicPort **port); ULONG device; } port_info; @@ -110,16 +113,14 @@ extern HRESULT DMUSIC_CreateDirectMusicInstrumentImpl (LPCGUID lpcGUID, LPVOID* * IDirectMusic8Impl implementation structure */ struct IDirectMusic8Impl { - /* IUnknown fields */ IDirectMusic8 IDirectMusic8_iface; LONG ref; - - /* IDirectMusicImpl fields */ - IReferenceClockImpl* pMasterClock; - IDirectMusicPort** ppPorts; - int nrofports; - port_info* system_ports; - int nb_system_ports; + IDirectSound *dsound; + IReferenceClockImpl *master_clock; + IDirectMusicPort **ports; + int num_ports; + port_info *system_ports; + int num_system_ports; }; /***************************************************************************** @@ -163,9 +164,12 @@ struct IDirectMusicDownloadImpl { }; /** Internal factory */ -extern HRESULT DMUSIC_CreateSynthPortImpl(LPCGUID guid, LPVOID *object, LPUNKNOWN unkouter, LPDMUS_PORTPARAMS port_params, LPDMUS_PORTCAPS port_caps, DWORD device) DECLSPEC_HIDDEN; -extern HRESULT DMUSIC_CreateMidiOutPortImpl(LPCGUID guid, LPVOID *object, LPUNKNOWN unkouter, LPDMUS_PORTPARAMS port_params, LPDMUS_PORTCAPS port_caps, DWORD device) DECLSPEC_HIDDEN; -extern HRESULT DMUSIC_CreateMidiInPortImpl(LPCGUID guid, LPVOID *object, LPUNKNOWN unkouter, LPDMUS_PORTPARAMS port_params, LPDMUS_PORTCAPS port_caps, DWORD device) DECLSPEC_HIDDEN; +extern HRESULT synth_port_create(IDirectMusic8Impl *parent, DMUS_PORTPARAMS *port_params, + DMUS_PORTCAPS *port_caps, IDirectMusicPort **port) DECLSPEC_HIDDEN; +extern HRESULT midi_out_port_create(IDirectMusic8Impl *parent, DMUS_PORTPARAMS *port_params, + DMUS_PORTCAPS *port_caps, IDirectMusicPort **port) DECLSPEC_HIDDEN; +extern HRESULT midi_in_port_create(IDirectMusic8Impl *parent, DMUS_PORTPARAMS *port_params, + DMUS_PORTCAPS *port_caps, IDirectMusicPort **port) DECLSPEC_HIDDEN; /***************************************************************************** * IReferenceClockImpl implementation structure @@ -229,6 +233,8 @@ static inline void DMUSIC_UnlockModule(void) { InterlockedDecrement( &DMUSIC_ref /***************************************************************************** * Misc. */ +void dmusic_remove_port(IDirectMusic8Impl *dmusic, IDirectMusicPort *port) DECLSPEC_HIDDEN; + /* for simpler reading */ typedef struct _DMUS_PRIVATE_CHUNK { FOURCC fccID; /* FOURCC ID of the chunk */ diff --git a/reactos/dll/directx/wine/dmusic/port.c b/reactos/dll/directx/wine/dmusic/port.c index 5e4e94334bc..af5eafbf45c 100644 --- a/reactos/dll/directx/wine/dmusic/port.c +++ b/reactos/dll/directx/wine/dmusic/port.c @@ -29,11 +29,13 @@ typedef struct SynthPortImpl { IDirectMusicThru IDirectMusicThru_iface; IKsControl IKsControl_iface; LONG ref; - IDirectSound *pDirectSound; + IDirectMusic8Impl *parent; + IDirectSound *dsound; + IDirectSoundBuffer *dsbuffer; IReferenceClock *pLatencyClock; IDirectMusicSynth *synth; IDirectMusicSynthSink *synth_sink; - BOOL fActive; + BOOL active; DMUS_PORTCAPS caps; DMUS_PORTPARAMS params; int nrofgroups; @@ -191,11 +193,16 @@ static ULONG WINAPI SynthPortImpl_IDirectMusicPort_Release(LPDIRECTMUSICPORT ifa if (!ref) { + dmusic_remove_port(This->parent, iface); IDirectMusicSynth_Activate(This->synth, FALSE); IDirectMusicSynth_Close(This->synth); IDirectMusicSynth_Release(This->synth); IDirectMusicSynthSink_Release(This->synth_sink); IReferenceClock_Release(This->pLatencyClock); + if (This->dsbuffer) + IDirectSoundBuffer_Release(This->dsbuffer); + if (This->dsound) + IDirectSound_Release(This->dsound); HeapFree(GetProcessHeap(), 0, This); } @@ -429,13 +436,31 @@ static HRESULT WINAPI SynthPortImpl_IDirectMusicPort_GetNumChannelGroups(LPDIREC return S_OK; } -static HRESULT WINAPI SynthPortImpl_IDirectMusicPort_Activate(LPDIRECTMUSICPORT iface, BOOL active) +static HRESULT WINAPI synth_dmport_Activate(IDirectMusicPort *iface, BOOL active) { SynthPortImpl *This = impl_from_SynthPortImpl_IDirectMusicPort(iface); - TRACE("(%p/%p)->(%d)\n", iface, This, active); + FIXME("(%p/%p)->(%d): semi-stub\n", iface, This, active); - This->fActive = active; + if (This->active == active) + return S_FALSE; + + if (active) { + /* Acquire the dsound */ + if (!This->dsound) { + IDirectSound_AddRef(This->parent->dsound); + This->dsound = This->parent->dsound; + } + IDirectSound_AddRef(This->dsound); + } else { + /* Release the dsound */ + IDirectSound_Release(This->dsound); + IDirectSound_Release(This->parent->dsound); + if (This->dsound == This->parent->dsound) + This->dsound = NULL; + } + + This->active = active; return S_OK; } @@ -466,11 +491,33 @@ static HRESULT WINAPI SynthPortImpl_IDirectMusicPort_GetChannelPriority(LPDIRECT return S_OK; } -static HRESULT WINAPI SynthPortImpl_IDirectMusicPort_SetDirectSound(LPDIRECTMUSICPORT iface, LPDIRECTSOUND direct_sound, LPDIRECTSOUNDBUFFER direct_sound_buffer) +static HRESULT WINAPI synth_dmport_SetDirectSound(IDirectMusicPort *iface, IDirectSound *dsound, + IDirectSoundBuffer *dsbuffer) { SynthPortImpl *This = impl_from_SynthPortImpl_IDirectMusicPort(iface); - FIXME("(%p/%p)->(%p, %p): stub\n", iface, This, direct_sound, direct_sound_buffer); + FIXME("(%p/%p)->(%p, %p): semi-stub\n", iface, This, dsound, dsbuffer); + + if (This->active) + return DMUS_E_DSOUND_ALREADY_SET; + + if (This->dsound) { + if (This->dsound != This->parent->dsound) + ERR("Not the same dsound in the port (%p) and parent dmusic (%p), expect trouble!\n", + This->dsound, This->parent->dsound); + if (!IDirectSound_Release(This->parent->dsound)) + This->parent->dsound = NULL; + } + if (This->dsbuffer) + IDirectSound_Release(This->dsbuffer); + + This->dsound = dsound; + This->dsbuffer = dsbuffer; + + if (This->dsound) + IDirectSound_AddRef(This->dsound); + if (This->dsbuffer) + IDirectSound_AddRef(This->dsbuffer); return S_OK; } @@ -538,10 +585,10 @@ static const IDirectMusicPortVtbl SynthPortImpl_DirectMusicPort_Vtbl = { SynthPortImpl_IDirectMusicPort_DeviceIoControl, SynthPortImpl_IDirectMusicPort_SetNumChannelGroups, SynthPortImpl_IDirectMusicPort_GetNumChannelGroups, - SynthPortImpl_IDirectMusicPort_Activate, + synth_dmport_Activate, SynthPortImpl_IDirectMusicPort_SetChannelPriority, SynthPortImpl_IDirectMusicPort_GetChannelPriority, - SynthPortImpl_IDirectMusicPort_SetDirectSound, + synth_dmport_SetDirectSound, SynthPortImpl_IDirectMusicPort_GetFormat }; @@ -719,18 +766,18 @@ static HRESULT WINAPI IKsControlImpl_KsProperty(IKsControl *iface, KSPROPERTY *p ULONG prop_len, void *data, ULONG data_len, ULONG *ret_len) { TRACE("(%p)->(%p, %u, %p, %u, %p)\n", iface, prop, prop_len, data, data_len, ret_len); - TRACE("prop = %s - %u - %u\n", debugstr_guid(&prop->Set), prop->Id, prop->Flags); + TRACE("prop = %s - %u - %u\n", debugstr_guid(&prop->u.s.Set), prop->u.s.Id, prop->u.s.Flags); - if (prop->Flags != KSPROPERTY_TYPE_GET) + if (prop->u.s.Flags != KSPROPERTY_TYPE_GET) { - FIXME("prop flags %u not yet supported\n", prop->Flags); + FIXME("prop flags %u not yet supported\n", prop->u.s.Flags); return S_FALSE; } if (data_len < sizeof(DWORD)) return E_NOT_SUFFICIENT_BUFFER; - FIXME("Unknown property %s\n", debugstr_guid(&prop->Set)); + FIXME("Unknown property %s\n", debugstr_guid(&prop->u.s.Set)); *(DWORD*)data = FALSE; *ret_len = sizeof(DWORD); @@ -762,16 +809,16 @@ static const IKsControlVtbl ikscontrol_vtbl = { IKsControlImpl_KsEvent }; -HRESULT DMUSIC_CreateSynthPortImpl(LPCGUID guid, LPVOID *object, LPUNKNOWN unkouter, LPDMUS_PORTPARAMS port_params, LPDMUS_PORTCAPS port_caps, DWORD device) +HRESULT synth_port_create(IDirectMusic8Impl *parent, DMUS_PORTPARAMS *port_params, + DMUS_PORTCAPS *port_caps, IDirectMusicPort **port) { SynthPortImpl *obj; HRESULT hr = E_FAIL; int i; - TRACE("(%s, %p, %p, %p, %p, %d)\n", debugstr_guid(guid), object, unkouter, port_params, - port_caps, device); + TRACE("(%p, %p, %p)\n", port_params, port_caps, port); - *object = NULL; + *port = NULL; obj = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(SynthPortImpl)); if (!obj) @@ -781,8 +828,9 @@ HRESULT DMUSIC_CreateSynthPortImpl(LPCGUID guid, LPVOID *object, LPUNKNOWN unkou obj->IDirectMusicPortDownload_iface.lpVtbl = &SynthPortImpl_DirectMusicPortDownload_Vtbl; obj->IDirectMusicThru_iface.lpVtbl = &SynthPortImpl_DirectMusicThru_Vtbl; obj->IKsControl_iface.lpVtbl = &ikscontrol_vtbl; - obj->ref = 0; /* Will be inited by QueryInterface */ - obj->fActive = FALSE; + obj->ref = 1; + obj->parent = parent; + obj->active = FALSE; obj->params = *port_params; obj->caps = *port_caps; @@ -838,8 +886,10 @@ HRESULT DMUSIC_CreateSynthPortImpl(LPCGUID guid, LPVOID *object, LPUNKNOWN unkou } } - if (SUCCEEDED(hr)) - return IDirectMusicPort_QueryInterface((LPDIRECTMUSICPORT)obj, guid, object); + if (SUCCEEDED(hr)) { + *port = &obj->IDirectMusicPort_iface; + return S_OK; + } if (obj->synth) IDirectMusicSynth_Release(obj->synth); @@ -852,18 +902,18 @@ HRESULT DMUSIC_CreateSynthPortImpl(LPCGUID guid, LPVOID *object, LPUNKNOWN unkou return hr; } -HRESULT DMUSIC_CreateMidiOutPortImpl(LPCGUID guid, LPVOID *object, LPUNKNOWN unkouter, LPDMUS_PORTPARAMS port_params, LPDMUS_PORTCAPS port_caps, DWORD device) +HRESULT midi_out_port_create(IDirectMusic8Impl *parent, DMUS_PORTPARAMS *port_params, + DMUS_PORTCAPS *port_caps, IDirectMusicPort **port) { - TRACE("(%s, %p, %p, %p, %p, %d): stub\n", debugstr_guid(guid), object, unkouter, port_params, - port_caps, device); + FIXME("(%p, %p, %p): stub\n", port_params, port_caps, port); return E_NOTIMPL; } -HRESULT DMUSIC_CreateMidiInPortImpl(LPCGUID guid, LPVOID *object, LPUNKNOWN unkouter, LPDMUS_PORTPARAMS port_params, LPDMUS_PORTCAPS port_caps, DWORD device) +HRESULT midi_in_port_create(IDirectMusic8Impl *parent, DMUS_PORTPARAMS *port_params, + DMUS_PORTCAPS *port_caps, IDirectMusicPort **port) { - TRACE("(%s, %p, %p, %p, %p, %d): stub\n", debugstr_guid(guid), object, unkouter, port_params, - port_caps, device); + FIXME("(%p, %p, %p): stub\n", port_params, port_caps, port); return E_NOTIMPL; } diff --git a/reactos/media/doc/README.WINE b/reactos/media/doc/README.WINE index d0416140a14..f67c4e83c4d 100644 --- a/reactos/media/doc/README.WINE +++ b/reactos/media/doc/README.WINE @@ -32,7 +32,7 @@ reactos/dll/directx/wine/ddraw # Synced to WineStaging-1.9.4 reactos/dll/directx/wine/devenum # Synced to WineStaging-2.9 reactos/dll/directx/wine/dinput # Synced to WineStaging-2.9 reactos/dll/directx/wine/dinput8 # Synced to WineStaging-1.9.23 -reactos/dll/directx/wine/dmusic # Synced to WineStaging-1.9.23 +reactos/dll/directx/wine/dmusic # Synced to WineStaging-2.9 reactos/dll/directx/wine/dplay # Synced to WineStaging-1.9.23 reactos/dll/directx/wine/dplayx # Synced to WineStaging-2.2 reactos/dll/directx/wine/dsound # Synced to Wine-1.3.29