ReactOS 0.4.16-dev-320-g3bd9ddc
dmusic.c File Reference
#include <stdio.h>
#include "dmusic_private.h"
#include "wine/heap.h"
Include dependency graph for dmusic.c:

Go to the source code of this file.

Classes

struct  master_clock
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (dmusic)
 
static struct master_clockimpl_from_IReferenceClock (IReferenceClock *iface)
 
static HRESULT WINAPI master_IReferenceClock_QueryInterface (IReferenceClock *iface, REFIID riid, void **ret_iface)
 
static ULONG WINAPI master_IReferenceClock_AddRef (IReferenceClock *iface)
 
static ULONG WINAPI master_IReferenceClock_Release (IReferenceClock *iface)
 
static HRESULT WINAPI master_IReferenceClock_GetTime (IReferenceClock *iface, REFERENCE_TIME *time)
 
static HRESULT WINAPI master_IReferenceClock_AdviseTime (IReferenceClock *iface, REFERENCE_TIME base, REFERENCE_TIME offset, HANDLE event, DWORD *cookie)
 
static HRESULT WINAPI master_IReferenceClock_AdvisePeriodic (IReferenceClock *iface, REFERENCE_TIME start, REFERENCE_TIME period, HANDLE semaphore, DWORD *cookie)
 
static HRESULT WINAPI master_IReferenceClock_Unadvise (IReferenceClock *iface, DWORD cookie)
 
static HRESULT master_clock_create (IReferenceClock **clock)
 
static IDirectMusic8Implimpl_from_IDirectMusic8 (IDirectMusic8 *iface)
 
static HRESULT WINAPI IDirectMusic8Impl_QueryInterface (LPDIRECTMUSIC8 iface, REFIID riid, LPVOID *ret_iface)
 
static ULONG WINAPI IDirectMusic8Impl_AddRef (LPDIRECTMUSIC8 iface)
 
static ULONG WINAPI IDirectMusic8Impl_Release (LPDIRECTMUSIC8 iface)
 
static HRESULT WINAPI IDirectMusic8Impl_EnumPort (LPDIRECTMUSIC8 iface, DWORD index, LPDMUS_PORTCAPS port_caps)
 
static HRESULT WINAPI IDirectMusic8Impl_CreateMusicBuffer (LPDIRECTMUSIC8 iface, LPDMUS_BUFFERDESC buffer_desc, LPDIRECTMUSICBUFFER *buffer, LPUNKNOWN unkouter)
 
static HRESULT WINAPI IDirectMusic8Impl_CreatePort (LPDIRECTMUSIC8 iface, REFCLSID rclsid_port, LPDMUS_PORTPARAMS port_params, LPDIRECTMUSICPORT *port, LPUNKNOWN unkouter)
 
void dmusic_remove_port (IDirectMusic8Impl *dmusic, IDirectMusicPort *port)
 
static HRESULT WINAPI IDirectMusic8Impl_EnumMasterClock (LPDIRECTMUSIC8 iface, DWORD index, LPDMUS_CLOCKINFO clock_info)
 
static HRESULT WINAPI IDirectMusic8Impl_GetMasterClock (LPDIRECTMUSIC8 iface, LPGUID guid_clock, IReferenceClock **reference_clock)
 
static HRESULT WINAPI IDirectMusic8Impl_SetMasterClock (LPDIRECTMUSIC8 iface, REFGUID rguidClock)
 
static HRESULT WINAPI IDirectMusic8Impl_Activate (LPDIRECTMUSIC8 iface, BOOL enable)
 
static HRESULT WINAPI IDirectMusic8Impl_GetDefaultPort (LPDIRECTMUSIC8 iface, LPGUID guid_port)
 
static HRESULT WINAPI IDirectMusic8Impl_SetDirectSound (IDirectMusic8 *iface, IDirectSound *dsound, HWND hwnd)
 
static HRESULT WINAPI IDirectMusic8Impl_SetExternalMasterClock (LPDIRECTMUSIC8 iface, IReferenceClock *clock)
 
static void create_system_ports_list (IDirectMusic8Impl *object)
 
HRESULT WINAPI DMUSIC_CreateDirectMusicImpl (LPCGUID riid, LPVOID *ret_iface, LPUNKNOWN unkouter)
 

Variables

static const IReferenceClockVtbl master_clock_vtbl
 
static const IDirectMusic8Vtbl DirectMusic8_Vtbl
 

Function Documentation

◆ create_system_ports_list()

static void create_system_ports_list ( IDirectMusic8Impl object)
static

Definition at line 497 of file dmusic.c.

498{
499 static const WCHAR emulated[] = {' ','[','E','m','u','l','a','t','e','d',']',0};
500 port_info * port;
501 ULONG nb_ports;
502 ULONG nb_midi_out;
503 ULONG nb_midi_in;
504 MIDIOUTCAPSW caps_out;
505 MIDIINCAPSW caps_in;
506 IDirectMusicSynth8* synth;
507 HRESULT hr;
508 ULONG i;
509
510 TRACE("(%p)\n", object);
511
512 /* NOTE:
513 - it seems some native versions get the rest of devices through dmusic32.EnumLegacyDevices...*sigh*...which is undocumented
514 - should we enum wave devices ? Native does not seem to
515 */
516
517 nb_midi_out = midiOutGetNumDevs();
518 nb_midi_in = midiInGetNumDevs();
519 nb_ports = 1 /* midi mapper */ + nb_midi_out + nb_midi_in + 1 /* synth port */;
520
521 port = object->system_ports = HeapAlloc(GetProcessHeap(), 0, nb_ports * sizeof(port_info));
522 if (!object->system_ports)
523 return;
524
525 /* Fill common port caps for all winmm ports */
526 for (i = 0; i < (nb_ports - 1 /* synth port*/); i++)
527 {
528 object->system_ports[i].caps.dwSize = sizeof(DMUS_PORTCAPS);
529 object->system_ports[i].caps.dwType = DMUS_PORT_WINMM_DRIVER;
530 object->system_ports[i].caps.dwMemorySize = 0;
531 object->system_ports[i].caps.dwMaxChannelGroups = 1;
532 object->system_ports[i].caps.dwMaxVoices = 0;
533 object->system_ports[i].caps.dwMaxAudioChannels = 0;
534 object->system_ports[i].caps.dwEffectFlags = DMUS_EFFECT_NONE;
535 /* Fake port GUID */
536 object->system_ports[i].caps.guidPort = IID_IUnknown;
537 object->system_ports[i].caps.guidPort.Data1 = i + 1;
538 }
539
540 /* Fill midi mapper port info */
541 port->device = MIDI_MAPPER;
542 port->create = midi_out_port_create;
543 midiOutGetDevCapsW(MIDI_MAPPER, &caps_out, sizeof(caps_out));
544 lstrcpyW(port->caps.wszDescription, caps_out.szPname);
545 lstrcatW(port->caps.wszDescription, emulated);
546 port->caps.dwFlags = DMUS_PC_SHAREABLE;
547 port->caps.dwClass = DMUS_PC_OUTPUTCLASS;
548 port++;
549
550 /* Fill midi out port info */
551 for (i = 0; i < nb_midi_out; i++)
552 {
553 port->device = i;
554 port->create = midi_out_port_create;
555 midiOutGetDevCapsW(i, &caps_out, sizeof(caps_out));
556 lstrcpyW(port->caps.wszDescription, caps_out.szPname);
557 lstrcatW(port->caps.wszDescription, emulated);
558 port->caps.dwFlags = DMUS_PC_SHAREABLE | DMUS_PC_EXTERNAL;
559 port->caps.dwClass = DMUS_PC_OUTPUTCLASS;
560 port++;
561 }
562
563 /* Fill midi in port info */
564 for (i = 0; i < nb_midi_in; i++)
565 {
566 port->device = i;
567 port->create = midi_in_port_create;
568 midiInGetDevCapsW(i, &caps_in, sizeof(caps_in));
569 lstrcpyW(port->caps.wszDescription, caps_in.szPname);
570 lstrcatW(port->caps.wszDescription, emulated);
571 port->caps.dwFlags = DMUS_PC_EXTERNAL;
572 port->caps.dwClass = DMUS_PC_INPUTCLASS;
573 port++;
574 }
575
576 /* Fill synth port info */
577 port->create = synth_port_create;
578 hr = CoCreateInstance(&CLSID_DirectMusicSynth, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectMusicSynth8, (void**)&synth);
579 if (SUCCEEDED(hr))
580 {
581 port->caps.dwSize = sizeof(port->caps);
582 hr = IDirectMusicSynth8_GetPortCaps(synth, &port->caps);
584 }
585 if (FAILED(hr))
586 nb_ports--;
587
588 object->num_system_ports = nb_ports;
589}
const GUID IID_IUnknown
#define NULL
Definition: types.h:112
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define lstrcpyW
Definition: compat.h:749
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3325
USHORT port
Definition: uri.c:228
HRESULT midi_in_port_create(IDirectMusic8Impl *parent, DMUS_PORTPARAMS *port_params, DMUS_PORTCAPS *port_caps, IDirectMusicPort **port) DECLSPEC_HIDDEN
Definition: port.c:1209
HRESULT midi_out_port_create(IDirectMusic8Impl *parent, DMUS_PORTPARAMS *port_params, DMUS_PORTCAPS *port_caps, IDirectMusicPort **port) DECLSPEC_HIDDEN
Definition: port.c:1201
HRESULT synth_port_create(IDirectMusic8Impl *parent, DMUS_PORTPARAMS *port_params, DMUS_PORTCAPS *port_caps, IDirectMusicPort **port) DECLSPEC_HIDDEN
Definition: port.c:814
#define DMUS_EFFECT_NONE
Definition: dmusicc.h:172
#define DMUS_PC_INPUTCLASS
Definition: dmusicc.h:180
#define DMUS_PC_EXTERNAL
Definition: dmusicc.h:184
#define DMUS_PORT_WINMM_DRIVER
Definition: dmusicc.h:197
#define DMUS_PC_SHAREABLE
Definition: dmusicc.h:191
#define DMUS_PC_OUTPUTCLASS
Definition: dmusicc.h:181
struct _DMUS_PORTCAPS DMUS_PORTCAPS
Definition: dmusicc.h:268
#define IDirectMusicSynth8_Release(p)
Definition: dmusics.h:171
#define IDirectMusicSynth8_GetPortCaps(p, a)
Definition: dmusics.h:180
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define FAILED(hr)
Definition: intsafe.h:51
LPWSTR WINAPI lstrcatW(LPWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:274
#define MIDI_MAPPER
Definition: mmsystem.h:253
HRESULT hr
Definition: shlfolder.c:183
#define TRACE(s)
Definition: solgame.cpp:4
WCHAR szPname[MAXPNAMELEN]
Definition: mmsystem.h:1146
WCHAR szPname[MAXPNAMELEN]
Definition: mmsystem.h:1126
uint32_t ULONG
Definition: typedefs.h:59
UINT WINAPI midiInGetNumDevs(void)
Definition: winmm.c:1184
UINT WINAPI midiOutGetNumDevs(void)
Definition: winmm.c:806
UINT WINAPI midiOutGetDevCapsW(UINT_PTR uDeviceID, LPMIDIOUTCAPSW lpCaps, UINT uSize)
Definition: winmm.c:814
UINT WINAPI midiInGetDevCapsW(UINT_PTR uDeviceID, LPMIDIINCAPSW lpCaps, UINT uSize)
Definition: winmm.c:1192
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by DMUSIC_CreateDirectMusicImpl().

◆ DMUSIC_CreateDirectMusicImpl()

HRESULT WINAPI DMUSIC_CreateDirectMusicImpl ( LPCGUID  riid,
LPVOID ret_iface,
LPUNKNOWN  unkouter 
)

Definition at line 592 of file dmusic.c.

593{
594 IDirectMusic8Impl *dmusic;
595 HRESULT ret;
596
597 TRACE("(%s, %p, %p)\n", debugstr_guid(riid), ret_iface, unkouter);
598
599 *ret_iface = NULL;
600 if (unkouter)
602
604 if (!dmusic)
605 return E_OUTOFMEMORY;
606
607 dmusic->IDirectMusic8_iface.lpVtbl = &DirectMusic8_Vtbl;
608 dmusic->ref = 1;
610 if (FAILED(ret)) {
611 HeapFree(GetProcessHeap(), 0, dmusic);
612 return ret;
613 }
614
616
620
621 return ret;
622}
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define HeapFree(x, y, z)
Definition: compat.h:735
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
static const IDirectMusic8Vtbl DirectMusic8_Vtbl
Definition: dmusic.c:481
static HRESULT WINAPI IDirectMusic8Impl_QueryInterface(LPDIRECTMUSIC8 iface, REFIID riid, LPVOID *ret_iface)
Definition: dmusic.c:157
static HRESULT master_clock_create(IReferenceClock **clock)
Definition: dmusic.c:131
static void create_system_ports_list(IDirectMusic8Impl *object)
Definition: dmusic.c:497
static void DMUSIC_LockModule(void)
#define IDirectMusic8_Release(p)
Definition: dmusicc.h:441
REFIID riid
Definition: atlbase.h:39
#define debugstr_guid
Definition: kernel32.h:35
IReferenceClock * master_clock
IDirectMusic8 IDirectMusic8_iface
int ret
#define CLASS_E_NOAGGREGATION
Definition: winerror.h:2662

◆ dmusic_remove_port()

void dmusic_remove_port ( IDirectMusic8Impl dmusic,
IDirectMusicPort *  port 
)

Definition at line 300 of file dmusic.c.

301{
302 BOOL found = FALSE;
303 int i;
304
305 TRACE("Removing port %p.\n", port);
306
307 for (i = 0; i < dmusic->num_ports; i++)
308 {
309 if (dmusic->ports[i] == port) {
310 found = TRUE;
311 break;
312 }
313 }
314
315 if (!found)
316 {
317 ERR("Port %p not found in ports array.\n", port);
318 return;
319 }
320
321 if (!--dmusic->num_ports) {
322 HeapFree(GetProcessHeap(), 0, dmusic->ports);
323 dmusic->ports = NULL;
324 return;
325 }
326
327 memmove(&dmusic->ports[i], &dmusic->ports[i + 1],
328 (dmusic->num_ports - i) * sizeof(*dmusic->ports));
329 dmusic->ports = HeapReAlloc(GetProcessHeap(), 0, dmusic->ports,
330 sizeof(*dmusic->ports) * dmusic->num_ports);
331}
#define ERR(fmt,...)
Definition: precomp.h:57
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define HeapReAlloc
Definition: compat.h:734
unsigned int BOOL
Definition: ntddk_ex.h:94
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
IDirectMusicPort ** ports

Referenced by SynthPortImpl_IDirectMusicPort_Release().

◆ IDirectMusic8Impl_Activate()

static HRESULT WINAPI IDirectMusic8Impl_Activate ( LPDIRECTMUSIC8  iface,
BOOL  enable 
)
static

Definition at line 390 of file dmusic.c.

391{
393 int i;
394 HRESULT hr;
395
396 TRACE("(%p)->(%u)\n", This, enable);
397
398 for (i = 0; i < This->num_ports; i++)
399 {
401 if (FAILED(hr))
402 return hr;
403 }
404
405 return S_OK;
406}
static IDirectMusic8Impl * impl_from_IDirectMusic8(IDirectMusic8 *iface)
Definition: dmusic.c:151
#define IDirectMusicPort_Activate(p, a)
Definition: dmusicc.h:693
GLboolean enable
Definition: glext.h:11120
#define S_OK
Definition: intsafe.h:52

◆ IDirectMusic8Impl_AddRef()

static ULONG WINAPI IDirectMusic8Impl_AddRef ( LPDIRECTMUSIC8  iface)
static

Definition at line 180 of file dmusic.c.

181{
184
185 TRACE("(%p)->(): new ref = %u\n", This, ref);
186
187 return ref;
188}
#define InterlockedIncrement
Definition: armddk.h:53
Definition: send.c:48

◆ IDirectMusic8Impl_CreateMusicBuffer()

static HRESULT WINAPI IDirectMusic8Impl_CreateMusicBuffer ( LPDIRECTMUSIC8  iface,
LPDMUS_BUFFERDESC  buffer_desc,
LPDIRECTMUSICBUFFER buffer,
LPUNKNOWN  unkouter 
)
static

Definition at line 228 of file dmusic.c.

229{
231
232 TRACE("(%p)->(%p, %p, %p)\n", This, buffer_desc, buffer, unkouter);
233
234 if (unkouter)
236
237 if (!buffer_desc || !buffer)
238 return E_POINTER;
239
241}
HRESULT DMUSIC_CreateDirectMusicBufferImpl(LPDMUS_BUFFERDESC desc, LPVOID *ret_iface)
Definition: buffer.c:294
GLuint buffer
Definition: glext.h:5915
#define E_POINTER
Definition: winerror.h:2365

◆ IDirectMusic8Impl_CreatePort()

static HRESULT WINAPI IDirectMusic8Impl_CreatePort ( LPDIRECTMUSIC8  iface,
REFCLSID  rclsid_port,
LPDMUS_PORTPARAMS  port_params,
LPDIRECTMUSICPORT port,
LPUNKNOWN  unkouter 
)
static

Definition at line 243 of file dmusic.c.

244{
246 int i;
247 DMUS_PORTCAPS port_caps;
248 IDirectMusicPort* new_port = NULL;
249 HRESULT hr;
250 GUID default_port;
251 const GUID *request_port = rclsid_port;
252
253 TRACE("(%p)->(%s, %p, %p, %p)\n", This, debugstr_dmguid(rclsid_port), port_params, port, unkouter);
254
255 if (!rclsid_port || !port)
256 return E_POINTER;
257 if (!port_params)
258 return E_INVALIDARG;
259 if (unkouter)
261 if (!This->dsound)
263
264 if (TRACE_ON(dmusic))
265 dump_DMUS_PORTPARAMS(port_params);
266
267 ZeroMemory(&port_caps, sizeof(DMUS_PORTCAPS));
268 port_caps.dwSize = sizeof(DMUS_PORTCAPS);
269
270 if (IsEqualGUID(request_port, &GUID_NULL)) {
271 hr = IDirectMusic8_GetDefaultPort(iface, &default_port);
272 if(FAILED(hr))
273 return hr;
274 request_port = &default_port;
275 }
276
277 for (i = 0; S_FALSE != IDirectMusic8Impl_EnumPort(iface, i, &port_caps); i++) {
278 if (IsEqualCLSID(request_port, &port_caps.guidPort)) {
279 hr = This->system_ports[i].create(This, port_params, &port_caps, &new_port);
280 if (FAILED(hr)) {
281 *port = NULL;
282 return hr;
283 }
284 This->num_ports++;
285 if (!This->ports)
286 This->ports = HeapAlloc(GetProcessHeap(), 0,
287 sizeof(*This->ports) * This->num_ports);
288 else
289 This->ports = HeapReAlloc(GetProcessHeap(), 0, This->ports,
290 sizeof(*This->ports) * This->num_ports);
291 This->ports[This->num_ports - 1] = new_port;
292 *port = new_port;
293 return S_OK;
294 }
295 }
296
297 return E_NOINTERFACE;
298}
#define E_INVALIDARG
Definition: ddrawi.h:101
#define TRACE_ON(x)
Definition: compat.h:75
#define DMUS_E_DSOUND_NOT_SET
Definition: dmerror.h:94
static HRESULT WINAPI IDirectMusic8Impl_EnumPort(LPDIRECTMUSIC8 iface, DWORD index, LPDMUS_PORTCAPS port_caps)
Definition: dmusic.c:211
void dump_DMUS_PORTPARAMS(LPDMUS_PORTPARAMS params)
Definition: dmusic_main.c:491
const char * debugstr_dmguid(const GUID *id)
Definition: dmusic_main.c:237
#define IDirectMusic8_GetDefaultPort(p, a)
Definition: dmusicc.h:450
#define GUID_NULL
Definition: ks.h:106
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
#define IsEqualCLSID(rclsid1, rclsid2)
Definition: guiddef.h:96
GUID guidPort
Definition: dmusicc.h:291
DWORD dwSize
Definition: dmusicc.h:289
#define ZeroMemory
Definition: winbase.h:1737
#define S_FALSE
Definition: winerror.h:2357
#define E_NOINTERFACE
Definition: winerror.h:2364

◆ IDirectMusic8Impl_EnumMasterClock()

static HRESULT WINAPI IDirectMusic8Impl_EnumMasterClock ( LPDIRECTMUSIC8  iface,
DWORD  index,
LPDMUS_CLOCKINFO  clock_info 
)
static

Definition at line 333 of file dmusic.c.

334{
335 TRACE("(%p)->(%d, %p)\n", iface, index, clock_info);
336
337 if (!clock_info)
338 return E_POINTER;
339
340 if (index > 1)
341 return S_FALSE;
342
343 if (!index)
344 {
345 static const GUID guid_system_clock = { 0x58d58419, 0x71b4, 0x11d1, { 0xa7, 0x4c, 0x00, 0x00, 0xf8, 0x75, 0xac, 0x12 } };
346 static const WCHAR name_system_clock[] = { 'S','y','s','t','e','m',' ','C','l','o','c','k',0 };
347
348 clock_info->ctType = 0;
349 clock_info->guidClock = guid_system_clock;
350 lstrcpyW(clock_info->wszDescription, name_system_clock);
351 }
352 else
353 {
354 static const GUID guid_dsound_clock = { 0x58d58420, 0x71b4, 0x11d1, { 0xa7, 0x4c, 0x00, 0x00, 0xf8, 0x75, 0xac, 0x12 } };
355 static const WCHAR name_dsound_clock[] = { 'D','i','r','e','c','t','S','o','u','n','d',' ','C','l','o','c','k',0 };
356
357 clock_info->ctType = 0;
358 clock_info->guidClock = guid_dsound_clock;
359 lstrcpyW(clock_info->wszDescription, name_dsound_clock);
360 }
361
362 return S_OK;
363}
GLuint index
Definition: glext.h:6031
WCHAR wszDescription[DMUS_MAX_DESCRIPTION]
Definition: dmusicc.h:366
DMUS_CLOCKTYPE ctType
Definition: dmusicc.h:364

◆ IDirectMusic8Impl_EnumPort()

static HRESULT WINAPI IDirectMusic8Impl_EnumPort ( LPDIRECTMUSIC8  iface,
DWORD  index,
LPDMUS_PORTCAPS  port_caps 
)
static

Definition at line 211 of file dmusic.c.

212{
214
215 TRACE("(%p, %d, %p)\n", This, index, port_caps);
216
217 if (!port_caps)
218 return E_POINTER;
219
220 if (index >= This->num_system_ports)
221 return S_FALSE;
222
223 *port_caps = This->system_ports[index].caps;
224
225 return S_OK;
226}
#define index(s, c)
Definition: various.h:29

Referenced by IDirectMusic8Impl_CreatePort().

◆ IDirectMusic8Impl_GetDefaultPort()

static HRESULT WINAPI IDirectMusic8Impl_GetDefaultPort ( LPDIRECTMUSIC8  iface,
LPGUID  guid_port 
)
static

Definition at line 408 of file dmusic.c.

409{
411 HKEY hkGUID;
412 DWORD returnTypeGUID, sizeOfReturnBuffer = 50;
413 char returnBuffer[51];
414 GUID defaultPortGUID;
415 WCHAR buff[51];
416
417 TRACE("(%p)->(%p)\n", This, guid_port);
418
419 if ((RegOpenKeyExA(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\DirectMusic\\Defaults" , 0, KEY_READ, &hkGUID) != ERROR_SUCCESS) ||
420 (RegQueryValueExA(hkGUID, "DefaultOutputPort", NULL, &returnTypeGUID, (LPBYTE)returnBuffer, &sizeOfReturnBuffer) != ERROR_SUCCESS))
421 {
422 WARN(": registry entry missing\n" );
423 *guid_port = CLSID_DirectMusicSynth;
424 return S_OK;
425 }
426 /* FIXME: Check return types to ensure we're interpreting data right */
427 MultiByteToWideChar(CP_ACP, 0, returnBuffer, -1, buff, ARRAY_SIZE(buff));
428 CLSIDFromString(buff, &defaultPortGUID);
429 *guid_port = defaultPortGUID;
430
431 return S_OK;
432}
#define ARRAY_SIZE(A)
Definition: main.h:20
#define WARN(fmt,...)
Definition: precomp.h:61
#define ERROR_SUCCESS
Definition: deptool.c:10
LONG WINAPI RegOpenKeyExA(_In_ HKEY hKey, _In_ LPCSTR lpSubKey, _In_ DWORD ulOptions, _In_ REGSAM samDesired, _Out_ PHKEY phkResult)
Definition: reg.c:3298
LONG WINAPI RegQueryValueExA(_In_ HKEY hkeyorg, _In_ LPCSTR name, _In_ LPDWORD reserved, _Out_opt_ LPDWORD type, _Out_opt_ LPBYTE data, _Inout_opt_ LPDWORD count)
Definition: reg.c:4009
#define CP_ACP
Definition: compat.h:109
#define MultiByteToWideChar
Definition: compat.h:110
HRESULT WINAPI CLSIDFromString(LPCOLESTR idstr, LPCLSID id)
Definition: compobj.c:2338
static unsigned char buff[32768]
Definition: fatten.c:17
unsigned long DWORD
Definition: ntddk_ex.h:95
#define KEY_READ
Definition: nt_native.h:1023
unsigned char * LPBYTE
Definition: typedefs.h:53
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

◆ IDirectMusic8Impl_GetMasterClock()

static HRESULT WINAPI IDirectMusic8Impl_GetMasterClock ( LPDIRECTMUSIC8  iface,
LPGUID  guid_clock,
IReferenceClock **  reference_clock 
)
static

Definition at line 365 of file dmusic.c.

366{
368
369 TRACE("(%p)->(%p, %p)\n", This, guid_clock, reference_clock);
370
371 if (guid_clock)
372 *guid_clock = GUID_NULL;
373 if (reference_clock) {
374 *reference_clock = This->master_clock;
375 IReferenceClock_AddRef(*reference_clock);
376 }
377
378 return S_OK;
379}
#define IReferenceClock_AddRef(p)
Definition: dmusicc.h:751

◆ IDirectMusic8Impl_QueryInterface()

static HRESULT WINAPI IDirectMusic8Impl_QueryInterface ( LPDIRECTMUSIC8  iface,
REFIID  riid,
LPVOID ret_iface 
)
static

Definition at line 157 of file dmusic.c.

158{
160
161 TRACE("(%p)->(%s, %p)\n", iface, debugstr_dmguid(riid), ret_iface);
162
163 if (IsEqualIID (riid, &IID_IUnknown) ||
164 IsEqualIID (riid, &IID_IDirectMusic) ||
165 IsEqualIID (riid, &IID_IDirectMusic2) ||
166 IsEqualIID (riid, &IID_IDirectMusic8))
167 {
169 *ret_iface = iface;
170 return S_OK;
171 }
172
173 *ret_iface = NULL;
174
175 WARN("(%p, %s, %p): not found\n", This, debugstr_dmguid(riid), ret_iface);
176
177 return E_NOINTERFACE;
178}
#define IDirectMusic8_AddRef(p)
Definition: dmusicc.h:440
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95

Referenced by DMUSIC_CreateDirectMusicImpl().

◆ IDirectMusic8Impl_Release()

static ULONG WINAPI IDirectMusic8Impl_Release ( LPDIRECTMUSIC8  iface)
static

Definition at line 190 of file dmusic.c.

191{
194
195 TRACE("(%p)->(): new ref = %u\n", This, ref);
196
197 if (!ref) {
198 IReferenceClock_Release(This->master_clock);
199 if (This->dsound)
200 IDirectSound_Release(This->dsound);
201 HeapFree(GetProcessHeap(), 0, This->system_ports);
202 HeapFree(GetProcessHeap(), 0, This->ports);
205 }
206
207 return ref;
208}
#define InterlockedDecrement
Definition: armddk.h:52
static void DMUSIC_UnlockModule(void)
#define IReferenceClock_Release(p)
Definition: dmusicc.h:752
#define IDirectSound_Release(p)
Definition: dsound.h:453

◆ IDirectMusic8Impl_SetDirectSound()

static HRESULT WINAPI IDirectMusic8Impl_SetDirectSound ( IDirectMusic8 *  iface,
IDirectSound *  dsound,
HWND  hwnd 
)
static

Definition at line 434 of file dmusic.c.

436{
438 HRESULT hr;
439 int i;
440
441 TRACE("(%p)->(%p, %p)\n", This, dsound, hwnd);
442
443 for (i = 0; i < This->num_ports; i++)
444 {
446 if (FAILED(hr))
447 return hr;
448 }
449
450 if (This->dsound)
451 IDirectSound_Release(This->dsound);
452
453 if (!dsound) {
454 hr = DirectSoundCreate8(NULL, (IDirectSound8 **)&This->dsound, NULL);
455 if (FAILED(hr))
456 return hr;
459 if (FAILED(hr)) {
460 IDirectSound_Release(This->dsound);
461 This->dsound = NULL;
462 }
463 return hr;
464 }
465
466 IDirectSound_AddRef(dsound);
467 This->dsound = dsound;
468
469 return S_OK;
470}
HRESULT WINAPI DirectSoundCreate8(LPCGUID lpcGUID, LPDIRECTSOUND8 *ppDS, IUnknown *pUnkOuter)
Definition: directsound.c:504
#define IDirectMusicPort_SetDirectSound(p, a, b)
Definition: dmusicc.h:696
#define IDirectSound_AddRef(p)
Definition: dsound.h:452
#define DSSCL_PRIORITY
Definition: dsound.h:248
#define IDirectSound_SetCooperativeLevel(p, a, b)
Definition: dsound.h:458
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
HWND WINAPI GetForegroundWindow(void)
Definition: ntwrapper.h:392

◆ IDirectMusic8Impl_SetExternalMasterClock()

static HRESULT WINAPI IDirectMusic8Impl_SetExternalMasterClock ( LPDIRECTMUSIC8  iface,
IReferenceClock clock 
)
static

Definition at line 472 of file dmusic.c.

473{
475
476 FIXME("(%p)->(%p): stub\n", This, clock);
477
478 return S_OK;
479}
#define FIXME(fmt,...)
Definition: precomp.h:53
_Check_return_ _CRTIMP clock_t __cdecl clock(void)
Definition: clock.c:23

◆ IDirectMusic8Impl_SetMasterClock()

static HRESULT WINAPI IDirectMusic8Impl_SetMasterClock ( LPDIRECTMUSIC8  iface,
REFGUID  rguidClock 
)
static

Definition at line 381 of file dmusic.c.

382{
384
385 FIXME("(%p)->(%s): stub\n", This, debugstr_dmguid(rguidClock));
386
387 return S_OK;
388}

◆ impl_from_IDirectMusic8()

◆ impl_from_IReferenceClock()

static struct master_clock * impl_from_IReferenceClock ( IReferenceClock iface)
inlinestatic

Definition at line 36 of file dmusic.c.

37{
38 return CONTAINING_RECORD(iface, struct master_clock, IReferenceClock_iface);
39}

Referenced by master_IReferenceClock_AddRef(), master_IReferenceClock_GetTime(), and master_IReferenceClock_Release().

◆ master_clock_create()

static HRESULT master_clock_create ( IReferenceClock **  clock)
static

Definition at line 131 of file dmusic.c.

132{
133 struct master_clock *obj;
135
136 TRACE("(%p)\n", clock);
137
138 if (!(obj = heap_alloc_zero(sizeof(*obj))))
139 return E_OUTOFMEMORY;
140
141 obj->IReferenceClock_iface.lpVtbl = &master_clock_vtbl;
142 obj->ref = 1;
144 obj->freq = 10000000.0 / freq.QuadPart;
145
146 *clock = &obj->IReferenceClock_iface;
147
148 return S_OK;
149}
BOOL WINAPI QueryPerformanceFrequency(OUT PLARGE_INTEGER lpFrequency)
Definition: perfcnt.c:45
static const IReferenceClockVtbl master_clock_vtbl
Definition: dmusic.c:121
double freq
Definition: dmusic.c:32

Referenced by DMUSIC_CreateDirectMusicImpl().

◆ master_IReferenceClock_AddRef()

static ULONG WINAPI master_IReferenceClock_AddRef ( IReferenceClock iface)
static

Definition at line 59 of file dmusic.c.

60{
63
64 TRACE("(%p) ref = %u\n", iface, ref);
65
66 return ref;
67}
static struct master_clock * impl_from_IReferenceClock(IReferenceClock *iface)
Definition: dmusic.c:36
LONG ref
Definition: dmusic.c:31

◆ master_IReferenceClock_AdvisePeriodic()

static HRESULT WINAPI master_IReferenceClock_AdvisePeriodic ( IReferenceClock iface,
REFERENCE_TIME  start,
REFERENCE_TIME  period,
HANDLE  semaphore,
DWORD cookie 
)
static

Definition at line 107 of file dmusic.c.

109{
110 TRACE("(%p, %s, %s, %p, %p): method not implemented\n", iface, wine_dbgstr_longlong(start),
112 return E_NOTIMPL;
113}
#define E_NOTIMPL
Definition: ddrawi.h:99
static __inline const char * wine_dbgstr_longlong(ULONGLONG ll)
Definition: compat.h:49
GLuint start
Definition: gl.h:1545
HANDLE semaphore
Definition: loader.c:2140
Definition: cookie.c:34

◆ master_IReferenceClock_AdviseTime()

static HRESULT WINAPI master_IReferenceClock_AdviseTime ( IReferenceClock iface,
REFERENCE_TIME  base,
REFERENCE_TIME  offset,
HANDLE  event,
DWORD cookie 
)
static

Definition at line 99 of file dmusic.c.

101{
102 TRACE("(%p, %s, %s, %p, %p): method not implemented\n", iface, wine_dbgstr_longlong(base),
104 return E_NOTIMPL;
105}
struct _cl_event * event
Definition: glext.h:7739
GLintptr offset
Definition: glext.h:5920

◆ master_IReferenceClock_GetTime()

static HRESULT WINAPI master_IReferenceClock_GetTime ( IReferenceClock iface,
REFERENCE_TIME time 
)
static

Definition at line 82 of file dmusic.c.

84{
87 HRESULT hr;
88
89 TRACE("(%p, %p)\n", iface, time);
90
92 *time = counter.QuadPart * This->freq;
93 hr = (*time == This->last_time) ? S_FALSE : S_OK;
94 This->last_time = *time;
95
96 return hr;
97}
BOOL WINAPI QueryPerformanceCounter(OUT PLARGE_INTEGER lpPerformanceCount)
Definition: perfcnt.c:23
__u16 time
Definition: mkdosfs.c:8

◆ master_IReferenceClock_QueryInterface()

static HRESULT WINAPI master_IReferenceClock_QueryInterface ( IReferenceClock iface,
REFIID  riid,
void **  ret_iface 
)
static

Definition at line 41 of file dmusic.c.

43{
44 TRACE("(%p, %s, %p)\n", iface, debugstr_dmguid(riid), ret_iface);
45
46 if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IReferenceClock))
47 *ret_iface = iface;
48 else {
49 WARN("no interface for %s\n", debugstr_dmguid(riid));
50 *ret_iface = NULL;
51 return E_NOINTERFACE;
52 }
53
55
56 return S_OK;
57}

◆ master_IReferenceClock_Release()

static ULONG WINAPI master_IReferenceClock_Release ( IReferenceClock iface)
static

Definition at line 69 of file dmusic.c.

70{
73
74 TRACE("(%p) ref = %u\n", iface, ref);
75
76 if (!ref)
78
79 return ref;
80}
static BOOL heap_free(void *mem)
Definition: appwiz.h:76

◆ master_IReferenceClock_Unadvise()

static HRESULT WINAPI master_IReferenceClock_Unadvise ( IReferenceClock iface,
DWORD  cookie 
)
static

Definition at line 115 of file dmusic.c.

116{
117 TRACE("(%p, %#x): method not implemented\n", iface, cookie);
118 return E_NOTIMPL;
119}

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( dmusic  )

Variable Documentation

◆ DirectMusic8_Vtbl

const IDirectMusic8Vtbl DirectMusic8_Vtbl
static
Initial value:
= {
}
static HRESULT WINAPI IDirectMusic8Impl_CreateMusicBuffer(LPDIRECTMUSIC8 iface, LPDMUS_BUFFERDESC buffer_desc, LPDIRECTMUSICBUFFER *buffer, LPUNKNOWN unkouter)
Definition: dmusic.c:228
static HRESULT WINAPI IDirectMusic8Impl_EnumMasterClock(LPDIRECTMUSIC8 iface, DWORD index, LPDMUS_CLOCKINFO clock_info)
Definition: dmusic.c:333
static HRESULT WINAPI IDirectMusic8Impl_GetMasterClock(LPDIRECTMUSIC8 iface, LPGUID guid_clock, IReferenceClock **reference_clock)
Definition: dmusic.c:365
static HRESULT WINAPI IDirectMusic8Impl_GetDefaultPort(LPDIRECTMUSIC8 iface, LPGUID guid_port)
Definition: dmusic.c:408
static ULONG WINAPI IDirectMusic8Impl_AddRef(LPDIRECTMUSIC8 iface)
Definition: dmusic.c:180
static HRESULT WINAPI IDirectMusic8Impl_SetDirectSound(IDirectMusic8 *iface, IDirectSound *dsound, HWND hwnd)
Definition: dmusic.c:434
static HRESULT WINAPI IDirectMusic8Impl_SetMasterClock(LPDIRECTMUSIC8 iface, REFGUID rguidClock)
Definition: dmusic.c:381
static HRESULT WINAPI IDirectMusic8Impl_Activate(LPDIRECTMUSIC8 iface, BOOL enable)
Definition: dmusic.c:390
static HRESULT WINAPI IDirectMusic8Impl_SetExternalMasterClock(LPDIRECTMUSIC8 iface, IReferenceClock *clock)
Definition: dmusic.c:472
static HRESULT WINAPI IDirectMusic8Impl_CreatePort(LPDIRECTMUSIC8 iface, REFCLSID rclsid_port, LPDMUS_PORTPARAMS port_params, LPDIRECTMUSICPORT *port, LPUNKNOWN unkouter)
Definition: dmusic.c:243
static ULONG WINAPI IDirectMusic8Impl_Release(LPDIRECTMUSIC8 iface)
Definition: dmusic.c:190

Definition at line 481 of file dmusic.c.

Referenced by DMUSIC_CreateDirectMusicImpl().

◆ master_clock_vtbl

const IReferenceClockVtbl master_clock_vtbl
static
Initial value:
= {
}
static HRESULT WINAPI master_IReferenceClock_Unadvise(IReferenceClock *iface, DWORD cookie)
Definition: dmusic.c:115
static HRESULT WINAPI master_IReferenceClock_GetTime(IReferenceClock *iface, REFERENCE_TIME *time)
Definition: dmusic.c:82
static HRESULT WINAPI master_IReferenceClock_AdvisePeriodic(IReferenceClock *iface, REFERENCE_TIME start, REFERENCE_TIME period, HANDLE semaphore, DWORD *cookie)
Definition: dmusic.c:107
static ULONG WINAPI master_IReferenceClock_Release(IReferenceClock *iface)
Definition: dmusic.c:69
static HRESULT WINAPI master_IReferenceClock_QueryInterface(IReferenceClock *iface, REFIID riid, void **ret_iface)
Definition: dmusic.c:41
static ULONG WINAPI master_IReferenceClock_AddRef(IReferenceClock *iface)
Definition: dmusic.c:59
static HRESULT WINAPI master_IReferenceClock_AdviseTime(IReferenceClock *iface, REFERENCE_TIME base, REFERENCE_TIME offset, HANDLE event, DWORD *cookie)
Definition: dmusic.c:99

Definition at line 121 of file dmusic.c.

Referenced by master_clock_create().