ReactOS  0.4.15-dev-985-gd905dd5
instrument.c File Reference
#include "dmusic_private.h"
Include dependency graph for instrument.c:

Go to the source code of this file.

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (dmusic)
 
static HRESULT WINAPI IDirectMusicInstrumentImpl_QueryInterface (LPDIRECTMUSICINSTRUMENT iface, REFIID riid, LPVOID *ret_iface)
 
static ULONG WINAPI IDirectMusicInstrumentImpl_AddRef (LPDIRECTMUSICINSTRUMENT iface)
 
static ULONG WINAPI IDirectMusicInstrumentImpl_Release (LPDIRECTMUSICINSTRUMENT iface)
 
static HRESULT WINAPI IDirectMusicInstrumentImpl_GetPatch (LPDIRECTMUSICINSTRUMENT iface, DWORD *pdwPatch)
 
static HRESULT WINAPI IDirectMusicInstrumentImpl_SetPatch (LPDIRECTMUSICINSTRUMENT iface, DWORD dwPatch)
 
HRESULT DMUSIC_CreateDirectMusicInstrumentImpl (LPCGUID lpcGUID, LPVOID *ppobj, LPUNKNOWN pUnkOuter)
 
static HRESULT read_from_stream (IStream *stream, void *data, ULONG size)
 
static DWORD subtract_bytes (DWORD len, DWORD bytes)
 
static HRESULT advance_stream (IStream *stream, ULONG bytes)
 
static HRESULT load_region (IDirectMusicInstrumentImpl *This, IStream *stream, instrument_region *region, ULONG length)
 
static HRESULT load_articulation (IDirectMusicInstrumentImpl *This, IStream *stream, ULONG length)
 
HRESULT IDirectMusicInstrumentImpl_CustomLoad (IDirectMusicInstrument *iface, IStream *stream)
 

Variables

static const GUID IID_IDirectMusicInstrumentPRIVATE = { 0xbcb20080, 0xa40c, 0x11d1, { 0x86, 0xbc, 0x00, 0xc0, 0x4f, 0xbf, 0x8f, 0xef } }
 
static const IDirectMusicInstrumentVtbl DirectMusicInstrument_Vtbl
 

Function Documentation

◆ advance_stream()

static HRESULT advance_stream ( IStream stream,
ULONG  bytes 
)
inlinestatic

Definition at line 170 of file instrument.c.

171 {
172  LARGE_INTEGER move;
173  HRESULT ret;
174 
175  move.QuadPart = bytes;
176 
177  ret = IStream_Seek(stream, move, STREAM_SEEK_CUR, NULL);
178  if (FAILED(ret))
179  WARN("IStream_Seek failed: %08x\n", ret);
180 
181  return ret;
182 }
#define WARN(fmt,...)
Definition: debug.h:112
static unsigned char bytes[4]
Definition: adnsresfilter.c:74
smooth NULL
Definition: ftsmooth.c:416
LONG HRESULT
Definition: typedefs.h:79
int ret
Definition: parse.h:22
LONGLONG QuadPart
Definition: typedefs.h:114

Referenced by IDirectMusicInstrumentImpl_CustomLoad(), and load_region().

◆ DMUSIC_CreateDirectMusicInstrumentImpl()

HRESULT DMUSIC_CreateDirectMusicInstrumentImpl ( LPCGUID  lpcGUID,
LPVOID ppobj,
LPUNKNOWN  pUnkOuter 
)

Definition at line 123 of file instrument.c.

123  {
125  HRESULT hr;
126 
128  if (NULL == dminst) {
129  *ppobj = NULL;
130  return E_OUTOFMEMORY;
131  }
133  dminst->ref = 1;
134 
137  ppobj);
139 
140  return hr;
141 }
static const IDirectMusicInstrumentVtbl DirectMusicInstrument_Vtbl
Definition: instrument.c:113
HRESULT hr
Definition: shlfolder.c:183
#define IDirectMusicInstrument_Release(p)
Definition: dmusicc.h:526
IDirectMusicInstrument IDirectMusicInstrument_iface
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
smooth NULL
Definition: ftsmooth.c:416
static void DMUSIC_LockModule(void)
#define IDirectMusicInstrument_QueryInterface(p, a, b)
Definition: dmusicc.h:524
#define GetProcessHeap()
Definition: compat.h:484
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
LONG HRESULT
Definition: typedefs.h:79
#define HEAP_ZERO_MEMORY
Definition: compat.h:134

Referenced by IPersistStreamImpl_Load().

◆ IDirectMusicInstrumentImpl_AddRef()

static ULONG WINAPI IDirectMusicInstrumentImpl_AddRef ( LPDIRECTMUSICINSTRUMENT  iface)
static

Definition at line 58 of file instrument.c.

59 {
62 
63  TRACE("(%p)->(): new ref = %u\n", iface, ref);
64 
65  return ref;
66 }
static IDirectMusicInstrumentImpl * impl_from_IDirectMusicInstrument(IDirectMusicInstrument *iface)
Definition: send.c:48
GLenum GLint ref
Definition: glext.h:6028
#define TRACE(s)
Definition: solgame.cpp:4
#define InterlockedIncrement
Definition: armddk.h:53
unsigned int ULONG
Definition: retypes.h:1

◆ IDirectMusicInstrumentImpl_CustomLoad()

HRESULT IDirectMusicInstrumentImpl_CustomLoad ( IDirectMusicInstrument *  iface,
IStream stream 
)

Definition at line 291 of file instrument.c.

292 {
294  HRESULT hr;
296  ULONG i = 0;
297  ULONG length = This->length;
298 
299  TRACE("(%p, %p): offset = 0x%s, length = %u)\n", This, stream, wine_dbgstr_longlong(This->liInstrumentPosition.QuadPart), This->length);
300 
301  if (This->loaded)
302  return S_OK;
303 
304  hr = IStream_Seek(stream, This->liInstrumentPosition, STREAM_SEEK_SET, NULL);
305  if (FAILED(hr))
306  {
307  WARN("IStream_Seek failed: %08x\n", hr);
309  }
310 
311  This->regions = HeapAlloc(GetProcessHeap(), 0, sizeof(*This->regions) * This->header.cRegions);
312  if (!This->regions)
313  return E_OUTOFMEMORY;
314 
315  while (length)
316  {
317  hr = read_from_stream(stream, &chunk, sizeof(chunk));
318  if (FAILED(hr))
319  goto error;
320 
321  length = subtract_bytes(length, sizeof(chunk) + chunk.dwSize);
322 
323  switch (chunk.fccID)
324  {
325  case FOURCC_INSH:
326  case FOURCC_DLID:
327  TRACE("Chunk %s: %u bytes\n", debugstr_fourcc(chunk.fccID), chunk.dwSize);
328 
329  /* Instrument header and id are already set so just skip */
330  hr = advance_stream(stream, chunk.dwSize);
331  if (FAILED(hr))
332  goto error;
333 
334  break;
335 
336  case FOURCC_LIST: {
337  DWORD size = chunk.dwSize;
338 
339  TRACE("LIST chunk: %u bytes\n", chunk.dwSize);
340 
341  hr = read_from_stream(stream, &chunk.fccID, sizeof(chunk.fccID));
342  if (FAILED(hr))
343  goto error;
344 
345  size = subtract_bytes(size, sizeof(chunk.fccID));
346 
347  switch (chunk.fccID)
348  {
349  case FOURCC_LRGN:
350  TRACE("LRGN chunk (regions list): %u bytes\n", size);
351 
352  while (size)
353  {
354  hr = read_from_stream(stream, &chunk, sizeof(chunk));
355  if (FAILED(hr))
356  goto error;
357 
358  if (chunk.fccID != FOURCC_LIST)
359  {
360  TRACE("Unknown chunk %s: %u bytes\n", debugstr_fourcc(chunk.fccID), chunk.dwSize);
361  goto error;
362  }
363 
364  hr = read_from_stream(stream, &chunk.fccID, sizeof(chunk.fccID));
365  if (FAILED(hr))
366  goto error;
367 
368  if (chunk.fccID == FOURCC_RGN)
369  {
370  TRACE("RGN chunk (region): %u bytes\n", chunk.dwSize);
371  hr = load_region(This, stream, &This->regions[i++], chunk.dwSize - sizeof(chunk.fccID));
372  }
373  else
374  {
375  TRACE("Unknown chunk %s: %u bytes\n", debugstr_fourcc(chunk.fccID), chunk.dwSize);
376  hr = advance_stream(stream, chunk.dwSize - sizeof(chunk.fccID));
377  }
378  if (FAILED(hr))
379  goto error;
380 
381  size = subtract_bytes(size, chunk.dwSize + sizeof(chunk));
382  }
383  break;
384 
385  case FOURCC_LART:
386  TRACE("LART chunk (articulations list): %u bytes\n", size);
387 
388  while (size)
389  {
390  hr = read_from_stream(stream, &chunk, sizeof(chunk));
391  if (FAILED(hr))
392  goto error;
393 
394  if (chunk.fccID == FOURCC_ART1)
395  {
396  TRACE("ART1 chunk (level 1 articulation): %u bytes\n", chunk.dwSize);
397  hr = load_articulation(This, stream, chunk.dwSize);
398  }
399  else
400  {
401  TRACE("Unknown chunk %s: %u bytes\n", debugstr_fourcc(chunk.fccID), chunk.dwSize);
402  hr = advance_stream(stream, chunk.dwSize);
403  }
404  if (FAILED(hr))
405  goto error;
406 
407  size = subtract_bytes(size, chunk.dwSize + sizeof(chunk));
408  }
409  break;
410 
411  default:
412  TRACE("Unknown chunk %s: %u bytes\n", debugstr_fourcc(chunk.fccID), chunk.dwSize);
413 
414  hr = advance_stream(stream, chunk.dwSize - sizeof(chunk.fccID));
415  if (FAILED(hr))
416  goto error;
417 
418  size = subtract_bytes(size, chunk.dwSize - sizeof(chunk.fccID));
419  break;
420  }
421  break;
422  }
423 
424  default:
425  TRACE("Unknown chunk %s: %u bytes\n", debugstr_fourcc(chunk.fccID), chunk.dwSize);
426 
427  hr = advance_stream(stream, chunk.dwSize);
428  if (FAILED(hr))
429  goto error;
430 
431  break;
432  }
433  }
434 
435  This->loaded = TRUE;
436 
437  return S_OK;
438 
439 error:
440  HeapFree(GetProcessHeap(), 0, This->regions);
441  This->regions = NULL;
442 
444 }
static IDirectMusicInstrumentImpl * impl_from_IDirectMusicInstrument(IDirectMusicInstrument *iface)
#define FOURCC_LRGN
Definition: dls1.h:43
HRESULT hr
Definition: shlfolder.c:183
#define error(str)
Definition: mkdosfs.c:1605
#define TRUE
Definition: types.h:120
#define WARN(fmt,...)
Definition: debug.h:112
#define DMUS_E_UNSUPPORTED_STREAM
Definition: dmerror.h:101
#define FOURCC_ART1
Definition: dls1.h:47
#define FOURCC_LART
Definition: dls1.h:46
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 E_OUTOFMEMORY
Definition: ddrawi.h:100
static HRESULT advance_stream(IStream *stream, ULONG bytes)
Definition: instrument.c:170
#define FOURCC_DLID
Definition: dls1.h:34
static const char * debugstr_fourcc(DWORD fourcc)
Definition: parsing.c:85
smooth NULL
Definition: ftsmooth.c:416
#define FOURCC_RGN
Definition: dls1.h:44
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
#define GetProcessHeap()
Definition: compat.h:484
#define FOURCC_LIST
Definition: mmsystem.h:565
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
LONG HRESULT
Definition: typedefs.h:79
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
unsigned long DWORD
Definition: ntddk_ex.h:95
static HRESULT load_region(IDirectMusicInstrumentImpl *This, IStream *stream, instrument_region *region, ULONG length)
Definition: instrument.c:184
static DWORD subtract_bytes(DWORD len, DWORD bytes)
Definition: instrument.c:161
Definition: parse.h:22
#define S_OK
Definition: intsafe.h:59
static HRESULT load_articulation(IDirectMusicInstrumentImpl *This, IStream *stream, ULONG length)
Definition: instrument.c:254
unsigned int ULONG
Definition: retypes.h:1
static __inline const char * wine_dbgstr_longlong(ULONGLONG ll)
Definition: compat.h:49
#define HeapFree(x, y, z)
Definition: compat.h:483
static HRESULT read_from_stream(IStream *stream, void *data, ULONG size)
Definition: instrument.c:143
#define FOURCC_INSH
Definition: dls1.h:42

Referenced by IDirectMusicCollectionImpl_GetInstrument().

◆ IDirectMusicInstrumentImpl_GetPatch()

static HRESULT WINAPI IDirectMusicInstrumentImpl_GetPatch ( LPDIRECTMUSICINSTRUMENT  iface,
DWORD pdwPatch 
)
static

Definition at line 91 of file instrument.c.

92 {
94 
95  TRACE("(%p)->(%p)\n", This, pdwPatch);
96 
97  *pdwPatch = MIDILOCALE2Patch(&This->header.Locale);
98 
99  return S_OK;
100 }
DWORD MIDILOCALE2Patch(const MIDILOCALE *pLocale)
Definition: dmusic_main.c:195
static IDirectMusicInstrumentImpl * impl_from_IDirectMusicInstrument(IDirectMusicInstrument *iface)
#define TRACE(s)
Definition: solgame.cpp:4
#define S_OK
Definition: intsafe.h:59

◆ IDirectMusicInstrumentImpl_QueryInterface()

static HRESULT WINAPI IDirectMusicInstrumentImpl_QueryInterface ( LPDIRECTMUSICINSTRUMENT  iface,
REFIID  riid,
LPVOID ret_iface 
)
static

Definition at line 28 of file instrument.c.

29 {
30  TRACE("(%p)->(%s, %p)\n", iface, debugstr_dmguid(riid), ret_iface);
31 
32  if (IsEqualIID(riid, &IID_IUnknown) ||
33  IsEqualIID(riid, &IID_IDirectMusicInstrument))
34  {
35  *ret_iface = iface;
37  return S_OK;
38  }
40  {
41  /* it seems to me that this interface is only basic IUnknown, without any
42  * other inherited functions... *sigh* this is the worst scenario, since it means
43  * that whoever calls it knows the layout of original implementation table and therefore
44  * tries to get data by direct access... expect crashes
45  */
46  FIXME("*sigh*... requested private/unspecified interface\n");
47 
48  *ret_iface = iface;
50  return S_OK;
51  }
52 
53  WARN("(%p)->(%s, %p): not found\n", iface, debugstr_dmguid(riid), ret_iface);
54 
55  return E_NOINTERFACE;
56 }
#define E_NOINTERFACE
Definition: winerror.h:2364
const char * debugstr_dmguid(const GUID *id)
Definition: dmusic_main.c:237
REFIID riid
Definition: precomp.h:44
#define WARN(fmt,...)
Definition: debug.h:112
#define FIXME(fmt,...)
Definition: debug.h:111
#define TRACE(s)
Definition: solgame.cpp:4
static const GUID IID_IDirectMusicInstrumentPRIVATE
Definition: instrument.c:25
const GUID IID_IUnknown
#define IDirectMusicInstrument_AddRef(p)
Definition: dmusicc.h:525
#define S_OK
Definition: intsafe.h:59
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95

◆ IDirectMusicInstrumentImpl_Release()

static ULONG WINAPI IDirectMusicInstrumentImpl_Release ( LPDIRECTMUSICINSTRUMENT  iface)
static

Definition at line 68 of file instrument.c.

69 {
72 
73  TRACE("(%p)->(): new ref = %u\n", iface, ref);
74 
75  if (!ref)
76  {
77  ULONG i;
78 
79  HeapFree(GetProcessHeap(), 0, This->regions);
80  for (i = 0; i < This->nb_articulations; i++)
81  HeapFree(GetProcessHeap(), 0, This->articulations->connections);
82  HeapFree(GetProcessHeap(), 0, This->articulations);
85  }
86 
87  return ref;
88 }
static IDirectMusicInstrumentImpl * impl_from_IDirectMusicInstrument(IDirectMusicInstrument *iface)
Definition: send.c:48
static void DMUSIC_UnlockModule(void)
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
GLenum GLint ref
Definition: glext.h:6028
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:484
#define InterlockedDecrement
Definition: armddk.h:52
unsigned int ULONG
Definition: retypes.h:1
#define HeapFree(x, y, z)
Definition: compat.h:483

◆ IDirectMusicInstrumentImpl_SetPatch()

static HRESULT WINAPI IDirectMusicInstrumentImpl_SetPatch ( LPDIRECTMUSICINSTRUMENT  iface,
DWORD  dwPatch 
)
static

Definition at line 102 of file instrument.c.

103 {
105 
106  TRACE("(%p)->(%d): stub\n", This, dwPatch);
107 
108  Patch2MIDILOCALE(dwPatch, &This->header.Locale);
109 
110  return S_OK;
111 }
static IDirectMusicInstrumentImpl * impl_from_IDirectMusicInstrument(IDirectMusicInstrument *iface)
void Patch2MIDILOCALE(DWORD dwPatch, LPMIDILOCALE pLocale)
Definition: dmusic_main.c:205
#define TRACE(s)
Definition: solgame.cpp:4
#define S_OK
Definition: intsafe.h:59

◆ load_articulation()

static HRESULT load_articulation ( IDirectMusicInstrumentImpl This,
IStream stream,
ULONG  length 
)
static

Definition at line 254 of file instrument.c.

255 {
256  HRESULT ret;
257  instrument_articulation *articulation;
258 
259  if (!This->articulations)
260  This->articulations = HeapAlloc(GetProcessHeap(), 0, sizeof(*This->articulations));
261  else
262  This->articulations = HeapReAlloc(GetProcessHeap(), 0, This->articulations, sizeof(*This->articulations) * (This->nb_articulations + 1));
263  if (!This->articulations)
264  return E_OUTOFMEMORY;
265 
266  articulation = &This->articulations[This->nb_articulations];
267 
268  ret = read_from_stream(stream, &articulation->connections_list, sizeof(CONNECTIONLIST));
269  if (FAILED(ret))
270  return ret;
271 
272  articulation->connections = HeapAlloc(GetProcessHeap(), 0, sizeof(CONNECTION) * articulation->connections_list.cConnections);
273  if (!articulation->connections)
274  return E_OUTOFMEMORY;
275 
276  ret = read_from_stream(stream, articulation->connections, sizeof(CONNECTION) * articulation->connections_list.cConnections);
277  if (FAILED(ret))
278  {
279  HeapFree(GetProcessHeap(), 0, articulation->connections);
280  return ret;
281  }
282 
283  subtract_bytes(length, sizeof(CONNECTIONLIST) + sizeof(CONNECTION) * articulation->connections_list.cConnections);
284 
285  This->nb_articulations++;
286 
287  return S_OK;
288 }
ULONG cConnections
Definition: dls1.h:73
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define GetProcessHeap()
Definition: compat.h:484
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
LONG HRESULT
Definition: typedefs.h:79
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
static DWORD subtract_bytes(DWORD len, DWORD bytes)
Definition: instrument.c:161
int ret
Definition: parse.h:22
CONNECTIONLIST connections_list
#define S_OK
Definition: intsafe.h:59
#define HeapReAlloc
Definition: compat.h:482
#define HeapFree(x, y, z)
Definition: compat.h:483
static HRESULT read_from_stream(IStream *stream, void *data, ULONG size)
Definition: instrument.c:143

Referenced by IDirectMusicInstrumentImpl_CustomLoad().

◆ load_region()

static HRESULT load_region ( IDirectMusicInstrumentImpl This,
IStream stream,
instrument_region region,
ULONG  length 
)
static

Definition at line 184 of file instrument.c.

185 {
186  HRESULT ret;
188 
189  TRACE("(%p, %p, %p, %u)\n", This, stream, region, length);
190 
191  while (length)
192  {
193  ret = read_from_stream(stream, &chunk, sizeof(chunk));
194  if (FAILED(ret))
195  return ret;
196 
197  length = subtract_bytes(length, sizeof(chunk));
198 
199  switch (chunk.fccID)
200  {
201  case FOURCC_RGNH:
202  TRACE("RGNH chunk (region header): %u bytes\n", chunk.dwSize);
203 
204  ret = read_from_stream(stream, &region->header, sizeof(region->header));
205  if (FAILED(ret))
206  return ret;
207 
208  length = subtract_bytes(length, sizeof(region->header));
209  break;
210 
211  case FOURCC_WSMP:
212  TRACE("WSMP chunk (wave sample): %u bytes\n", chunk.dwSize);
213 
214  ret = read_from_stream(stream, &region->wave_sample, sizeof(region->wave_sample));
215  if (FAILED(ret))
216  return ret;
217  length = subtract_bytes(length, sizeof(region->wave_sample));
218 
219  if (!(region->loop_present = (chunk.dwSize != sizeof(region->wave_sample))))
220  break;
221 
222  ret = read_from_stream(stream, &region->wave_loop, sizeof(region->wave_loop));
223  if (FAILED(ret))
224  return ret;
225 
226  length = subtract_bytes(length, sizeof(region->wave_loop));
227  break;
228 
229  case FOURCC_WLNK:
230  TRACE("WLNK chunk (wave link): %u bytes\n", chunk.dwSize);
231 
232  ret = read_from_stream(stream, &region->wave_link, sizeof(region->wave_link));
233  if (FAILED(ret))
234  return ret;
235 
236  length = subtract_bytes(length, sizeof(region->wave_link));
237  break;
238 
239  default:
240  TRACE("Unknown chunk %s (skipping): %u bytes\n", debugstr_fourcc(chunk.fccID), chunk.dwSize);
241 
242  ret = advance_stream(stream, chunk.dwSize);
243  if (FAILED(ret))
244  return ret;
245 
246  length = subtract_bytes(length, chunk.dwSize);
247  break;
248  }
249  }
250 
251  return S_OK;
252 }
#define FOURCC_RGNH
Definition: dls1.h:45
#define FOURCC_WSMP
Definition: dls1.h:49
static HRESULT advance_stream(IStream *stream, ULONG bytes)
Definition: instrument.c:170
static const char * debugstr_fourcc(DWORD fourcc)
Definition: parsing.c:85
#define TRACE(s)
Definition: solgame.cpp:4
#define FOURCC_WLNK
Definition: dls1.h:48
LONG HRESULT
Definition: typedefs.h:79
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
static DWORD subtract_bytes(DWORD len, DWORD bytes)
Definition: instrument.c:161
int ret
Definition: parse.h:22
#define S_OK
Definition: intsafe.h:59
static HRESULT read_from_stream(IStream *stream, void *data, ULONG size)
Definition: instrument.c:143

Referenced by IDirectMusicInstrumentImpl_CustomLoad().

◆ read_from_stream()

static HRESULT read_from_stream ( IStream stream,
void data,
ULONG  size 
)
static

Definition at line 143 of file instrument.c.

144 {
145  ULONG bytes_read;
146  HRESULT hr;
147 
148  hr = IStream_Read(stream, data, size, &bytes_read);
149  if(FAILED(hr)){
150  TRACE("IStream_Read failed: %08x\n", hr);
151  return hr;
152  }
153  if (bytes_read < size) {
154  TRACE("Didn't read full chunk: %u < %u\n", bytes_read, size);
155  return E_FAIL;
156  }
157 
158  return S_OK;
159 }
HRESULT hr
Definition: shlfolder.c:183
#define E_FAIL
Definition: ddrawi.h:102
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
LONG HRESULT
Definition: typedefs.h:79
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
Definition: parse.h:22
#define S_OK
Definition: intsafe.h:59
unsigned int ULONG
Definition: retypes.h:1

Referenced by IDirectMusicInstrumentImpl_CustomLoad(), load_articulation(), and load_region().

◆ subtract_bytes()

static DWORD subtract_bytes ( DWORD  len,
DWORD  bytes 
)
inlinestatic

Definition at line 161 of file instrument.c.

162 {
163  if(bytes > len){
164  TRACE("Apparent mismatch in chunk lengths? %u bytes remaining, %u bytes read\n", len, bytes);
165  return 0;
166  }
167  return len - bytes;
168 }
static unsigned char bytes[4]
Definition: adnsresfilter.c:74
#define TRACE(s)
Definition: solgame.cpp:4
GLenum GLsizei len
Definition: glext.h:6722

Referenced by IDirectMusicInstrumentImpl_CustomLoad(), load_articulation(), and load_region().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( dmusic  )

Variable Documentation

◆ DirectMusicInstrument_Vtbl

const IDirectMusicInstrumentVtbl DirectMusicInstrument_Vtbl
static
Initial value:
=
{
}
static HRESULT WINAPI IDirectMusicInstrumentImpl_SetPatch(LPDIRECTMUSICINSTRUMENT iface, DWORD dwPatch)
Definition: instrument.c:102
static ULONG WINAPI IDirectMusicInstrumentImpl_Release(LPDIRECTMUSICINSTRUMENT iface)
Definition: instrument.c:68
static HRESULT WINAPI IDirectMusicInstrumentImpl_GetPatch(LPDIRECTMUSICINSTRUMENT iface, DWORD *pdwPatch)
Definition: instrument.c:91
static HRESULT WINAPI IDirectMusicInstrumentImpl_QueryInterface(LPDIRECTMUSICINSTRUMENT iface, REFIID riid, LPVOID *ret_iface)
Definition: instrument.c:28
static ULONG WINAPI IDirectMusicInstrumentImpl_AddRef(LPDIRECTMUSICINSTRUMENT iface)
Definition: instrument.c:58

Definition at line 113 of file instrument.c.

Referenced by DMUSIC_CreateDirectMusicInstrumentImpl().

◆ IID_IDirectMusicInstrumentPRIVATE

const GUID IID_IDirectMusicInstrumentPRIVATE = { 0xbcb20080, 0xa40c, 0x11d1, { 0x86, 0xbc, 0x00, 0xc0, 0x4f, 0xbf, 0x8f, 0xef } }
static

Definition at line 25 of file instrument.c.

Referenced by IDirectMusicInstrumentImpl_QueryInterface().