ReactOS 0.4.17-dev-966-gf06eace
dmusic_main.c
Go to the documentation of this file.
1/* DirectMusic Main
2 *
3 * Copyright (C) 2003-2004 Rok Mandeljc
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
18 */
19
20
21#include <stdio.h>
22#include <stdarg.h>
23
24#define COBJMACROS
25
26#include "windef.h"
27#include "winbase.h"
28#include "winnt.h"
29#include "wingdi.h"
30#include "winuser.h"
31#include "winreg.h"
32#include "objbase.h"
33#include "rpcproxy.h"
34#include "initguid.h"
35#include "dmusici.h"
36
37#include "dmusic_private.h"
38
40
41typedef struct {
42 IClassFactory IClassFactory_iface;
45
46/******************************************************************
47 * IClassFactory implementation
48 */
50{
51 return CONTAINING_RECORD(iface, IClassFactoryImpl, IClassFactory_iface);
52}
53
55{
56 if (ppv == NULL)
57 return E_POINTER;
58
60 TRACE("(%p)->(IID_IUnknown %p)\n", iface, ppv);
62 TRACE("(%p)->(IID_IClassFactory %p)\n", iface, ppv);
63 else {
64 FIXME("(%p)->(%s %p)\n", iface, debugstr_guid(riid), ppv);
65 *ppv = NULL;
66 return E_NOINTERFACE;
67 }
68
69 *ppv = iface;
70 IUnknown_AddRef((IUnknown*)*ppv);
71 return S_OK;
72}
73
75{
76 return 2; /* non-heap based object */
77}
78
80{
81 return 1; /* non-heap based object */
82}
83
84static HRESULT WINAPI ClassFactory_CreateInstance(IClassFactory *iface, IUnknown *unk_outer, REFIID riid, void **ret_iface)
85{
88 HRESULT hr;
89
90 TRACE("(%p, %s, %p)\n", unk_outer, debugstr_dmguid(riid), ret_iface);
91
92 *ret_iface = NULL;
93 if (unk_outer) return CLASS_E_NOAGGREGATION;
94 if (SUCCEEDED(hr = This->create_instance(&object)))
95 {
96 hr = IUnknown_QueryInterface(object, riid, ret_iface);
97 IUnknown_Release(object);
98 }
99
100 return hr;
101}
102
104{
105 TRACE("(%d)\n", dolock);
106 return S_OK;
107}
108
109static const IClassFactoryVtbl classfactory_vtbl = {
115};
116
119
120
121
122/******************************************************************
123 * DllGetClassObject (DMUSIC.@)
124 *
125 *
126 */
128{
129 TRACE("(%s, %s, %p)\n", debugstr_dmguid(rclsid), debugstr_dmguid(riid), ppv);
130 if (IsEqualCLSID (rclsid, &CLSID_DirectMusic) && IsEqualIID (riid, &IID_IClassFactory)) {
132 IClassFactory_AddRef((IClassFactory*)*ppv);
133 return S_OK;
134 } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicCollection) && IsEqualIID (riid, &IID_IClassFactory)) {
135 *ppv = &Collection_CF;
136 IClassFactory_AddRef((IClassFactory*)*ppv);
137 return S_OK;
138 }
139
140 WARN("(%s, %s, %p): no interface found.\n", debugstr_dmguid(rclsid), debugstr_dmguid(riid), ppv);
142}
143
144/******************************************************************
145 * Helper functions
146 *
147 *
148 */
149/* dwPatch from MIDILOCALE */
151 DWORD dwPatch = 0;
152 if (!pLocale) return 0;
153 dwPatch |= (pLocale->ulBank & F_INSTRUMENT_DRUMS); /* set drum bit */
154 dwPatch |= ((pLocale->ulBank & 0x00007F7F) << 8); /* set MIDI bank location */
155 dwPatch |= (pLocale->ulInstrument & 0x0000007F); /* set PC value */
156 return dwPatch;
157}
158
159/* MIDILOCALE from dwPatch */
160void Patch2MIDILOCALE (DWORD dwPatch, LPMIDILOCALE pLocale) {
161 memset (pLocale, 0, sizeof(MIDILOCALE));
162
163 pLocale->ulInstrument = (dwPatch & 0x7F); /* get PC value */
164 pLocale->ulBank = ((dwPatch & 0x007F7F00) >> 8); /* get MIDI bank location */
165 pLocale->ulBank |= (dwPatch & F_INSTRUMENT_DRUMS); /* get drum bit */
166}
167
168/* generic flag-dumping function */
169static const char* debugstr_flags (DWORD flags, const flag_info* names, size_t num_names){
170 char buffer[128] = "", *ptr = &buffer[0];
171 unsigned int i;
172 int size = sizeof(buffer);
173
174 for (i=0; i < num_names; i++)
175 {
176 if ((flags & names[i].val) || /* standard flag*/
177 ((!flags) && (!names[i].val))) { /* zero value only */
178 int cnt = snprintf(ptr, size, "%s ", names[i].name);
179 if (cnt < 0 || cnt >= size) break;
180 size -= cnt;
181 ptr += cnt;
182 }
183 }
184
185 return wine_dbg_sprintf("%s", buffer);
186}
187
188/* Dump DMUS_PORTPARAMS flags */
189static const char* debugstr_DMUS_PORTPARAMS_FLAGS(DWORD flagmask)
190{
191 static const flag_info flags[] = {
198 };
199 return debugstr_flags(flagmask, flags, ARRAY_SIZE(flags));
200}
201
202/* Dump whole DMUS_PORTPARAMS struct */
204{
205 TRACE("DMUS_PORTPARAMS (%p):\n", params);
206 TRACE(" - dwSize = %ld\n", params->dwSize);
207 TRACE(" - dwValidParams = %s\n", debugstr_DMUS_PORTPARAMS_FLAGS(params->dwValidParams));
208 if (params->dwValidParams & DMUS_PORTPARAMS_VOICES) TRACE(" - dwVoices = %lu\n", params->dwVoices);
209 if (params->dwValidParams & DMUS_PORTPARAMS_CHANNELGROUPS) TRACE(" - dwChannelGroup = %lu\n", params->dwChannelGroups);
210 if (params->dwValidParams & DMUS_PORTPARAMS_AUDIOCHANNELS) TRACE(" - dwAudioChannels = %lu\n", params->dwAudioChannels);
211 if (params->dwValidParams & DMUS_PORTPARAMS_SAMPLERATE) TRACE(" - dwSampleRate = %lu\n", params->dwSampleRate);
212 if (params->dwValidParams & DMUS_PORTPARAMS_EFFECTS) TRACE(" - dwEffectFlags = %lx\n", params->dwEffectFlags);
213 if (params->dwValidParams & DMUS_PORTPARAMS_SHARE) TRACE(" - fShare = %u\n", params->fShare);
214}
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
#define ARRAY_SIZE(A)
Definition: main.h:20
#define FIXME(fmt,...)
Definition: precomp.h:53
#define WARN(fmt,...)
Definition: precomp.h:61
const GUID IID_IUnknown
const GUID IID_IClassFactory
HRESULT create_instance(const CLSID *clsid, const IID *iid, void **ppv)
Definition: clsfactory.c:212
HRESULT collection_create(IUnknown **ret_iface)
Definition: collection.c:749
#define FE(x)
HRESULT hr
Definition: delayimp.cpp:582
#define NULL
Definition: types.h:112
const char * wine_dbg_sprintf(const char *format,...)
Definition: compat.c:296
#define F_INSTRUMENT_DRUMS
Definition: dls1.h:51
const char * debugstr_dmguid(const GUID *id)
Definition: dmobject.c:36
HRESULT music_create(IUnknown **ret_iface)
Definition: dmusic.c:579
void Patch2MIDILOCALE(DWORD dwPatch, LPMIDILOCALE pLocale)
Definition: dmusic_main.c:160
static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL dolock)
Definition: dmusic_main.c:103
static IClassFactoryImpl Collection_CF
Definition: dmusic_main.c:118
static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
Definition: dmusic_main.c:79
DWORD MIDILOCALE2Patch(const MIDILOCALE *pLocale)
Definition: dmusic_main.c:150
static const char * debugstr_flags(DWORD flags, const flag_info *names, size_t num_names)
Definition: dmusic_main.c:169
static const IClassFactoryVtbl classfactory_vtbl
Definition: dmusic_main.c:109
void dump_DMUS_PORTPARAMS(LPDMUS_PORTPARAMS params)
Definition: dmusic_main.c:203
static const char * debugstr_DMUS_PORTPARAMS_FLAGS(DWORD flagmask)
Definition: dmusic_main.c:189
static HRESULT WINAPI ClassFactory_CreateInstance(IClassFactory *iface, IUnknown *unk_outer, REFIID riid, void **ret_iface)
Definition: dmusic_main.c:84
static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
Definition: dmusic_main.c:54
HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
Definition: dmusic_main.c:127
static IClassFactoryImpl DirectMusic_CF
Definition: dmusic_main.c:117
static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
Definition: dmusic_main.c:74
static IClassFactoryImpl * impl_from_IClassFactory(IClassFactory *iface)
Definition: dmusic_main.c:49
#define DMUS_PORTPARAMS_CHANNELGROUPS
Definition: dmusicc.h:206
#define DMUS_PORTPARAMS_SAMPLERATE
Definition: dmusicc.h:208
#define DMUS_PORTPARAMS_AUDIOCHANNELS
Definition: dmusicc.h:207
#define DMUS_PORTPARAMS_SHARE
Definition: dmusicc.h:210
#define DMUS_PORTPARAMS_VOICES
Definition: dmusicc.h:205
#define DMUS_PORTPARAMS_EFFECTS
Definition: dmusicc.h:209
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint GLuint * names
Definition: glext.h:11545
GLuint buffer
Definition: glext.h:5915
GLsizeiptr size
Definition: glext.h:5919
GLenum const GLfloat * params
Definition: glext.h:5645
GLbitfield flags
Definition: glext.h:7161
GLuint GLfloat * val
Definition: glext.h:7180
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
REFIID riid
Definition: atlbase.h:39
REFIID LPVOID * ppv
Definition: atlbase.h:39
#define S_OK
Definition: intsafe.h:52
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define debugstr_guid
Definition: kernel32.h:35
static PVOID ptr
Definition: dispmode.c:27
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95
#define REFIID
Definition: guiddef.h:118
#define REFCLSID
Definition: guiddef.h:117
#define IsEqualCLSID(rclsid1, rclsid2)
Definition: guiddef.h:96
#define memset(x, y, z)
Definition: compat.h:39
#define TRACE(s)
Definition: solgame.cpp:4
ULONG ulInstrument
Definition: dls1.h:97
ULONG ulBank
Definition: dls1.h:96
Definition: name.c:39
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
uint32_t ULONG
Definition: typedefs.h:59
_In_ size_t cnt
Definition: wcstombs.cpp:43
#define HRESULT
Definition: msvc.h:7
#define WINAPI
Definition: msvc.h:6
#define E_NOINTERFACE
Definition: winerror.h:3479
#define CLASS_E_NOAGGREGATION
Definition: winerror.h:3771
#define E_POINTER
Definition: winerror.h:3480
#define CLASS_E_CLASSNOTAVAILABLE
Definition: winerror.h:3772
#define snprintf
Definition: wintirpc.h:48