ReactOS 0.4.15-dev-8116-gf69e256
lolvldrv.c File Reference
#include "winemm.h"
Include dependency graph for lolvldrv.c:

Go to the source code of this file.

Classes

struct  tagWINE_LLTYPE
 

Macros

#define MAX_MM_MLDRVS   (sizeof(MM_MLDrvs) / sizeof(MM_MLDrvs[0]))
 
#define A(_x, _y)   {#_y, _x, 0, NULL, -1}
 
#define AA(_h, _w, _x, _y, _z)
 
#define A(_x, _y)   AA(d->hModule,_x,_y,32,GetProcAddress)
 

Typedefs

typedef struct tagWINE_LLTYPE WINE_LLTYPE
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (winmm)
 
UINT MMDRV_GetNum (UINT type)
 
DWORD MMDRV_Message (LPWINE_MLD mld, UINT wMsg, DWORD_PTR dwParam1, DWORD_PTR dwParam2)
 
LPWINE_MLD MMDRV_Alloc (UINT size, UINT type, LPHANDLE hndl, DWORD *dwFlags, DWORD_PTR *dwCallback, DWORD_PTR *dwInstance)
 
void MMDRV_Free (HANDLE hndl, LPWINE_MLD mld)
 
DWORD MMDRV_Open (LPWINE_MLD mld, UINT wMsg, DWORD_PTR dwParam1, DWORD dwFlags)
 
DWORD MMDRV_Close (LPWINE_MLD mld, UINT wMsg)
 
static LPWINE_MLD MMDRV_GetByID (UINT uDevID, UINT type)
 
LPWINE_MLD MMDRV_Get (HANDLE _hndl, UINT type, BOOL bCanBeID)
 
LPWINE_MLD MMDRV_GetRelated (HANDLE hndl, UINT srcType, BOOL bSrcCanBeID, UINT dstType)
 
UINT MMDRV_PhysicalFeatures (LPWINE_MLD mld, UINT uMsg, DWORD_PTR dwParam1, DWORD_PTR dwParam2)
 
static BOOL MMDRV_InitPerType (LPWINE_MM_DRIVER lpDrv, UINT type, UINT wMsg)
 
BOOL MMDRV_Install (LPCSTR drvRegName, LPCSTR drvFileName, BOOL bIsMapper)
 
BOOL MMDRV_Init (void)
 
static BOOL MMDRV_ExitPerType (LPWINE_MM_DRIVER lpDrv, UINT type)
 
void MMDRV_Exit (void)
 

Variables

static int MMDrvsHi
 
static WINE_MM_DRIVER MMDrvs [8]
 
static LPWINE_MLD MM_MLDrvs [40]
 
static WINE_LLTYPE llTypes [MMDRV_MAX]
 

Macro Definition Documentation

◆ A [1/2]

#define A (   _x,
  _y 
)    {#_y, _x, 0, NULL, -1}

Definition at line 44 of file lolvldrv.c.

◆ A [2/2]

#define A (   _x,
  _y 
)    AA(d->hModule,_x,_y,32,GetProcAddress)

Definition at line 44 of file lolvldrv.c.

◆ AA

#define AA (   _h,
  _w,
  _x,
  _y,
  _z 
)
Value:
func = (WINEMM_msgFunc##_y) _z ((_h), #_x); \
if (func != NULL) \
{ lpDrv->parts[_w].fnMessage##_y = func; count++; \
TRACE("Got %d bit func '%s'\n", _y, #_x); }
#define _x(oid)
#define NULL
Definition: types.h:112
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLenum func
Definition: glext.h:6028

◆ MAX_MM_MLDRVS

#define MAX_MM_MLDRVS   (sizeof(MM_MLDrvs) / sizeof(MM_MLDrvs[0]))

Definition at line 42 of file lolvldrv.c.

Typedef Documentation

◆ WINE_LLTYPE

Function Documentation

◆ MMDRV_Alloc()

LPWINE_MLD MMDRV_Alloc ( UINT  size,
UINT  type,
LPHANDLE  hndl,
DWORD dwFlags,
DWORD_PTR dwCallback,
DWORD_PTR dwInstance 
)

Definition at line 123 of file lolvldrv.c.

125{
126 LPWINE_MLD mld;
127 UINT_PTR i;
128 TRACE("(%d, %04x, %p, %p, %p, %p)\n",
129 size, type, hndl, dwFlags, dwCallback, dwInstance);
130
132 if (!mld) return NULL;
133
134 /* find an empty slot in MM_MLDrvs table */
135 for (i = 0; i < MAX_MM_MLDRVS; i++) if (!MM_MLDrvs[i]) break;
136
137 if (i == MAX_MM_MLDRVS) {
138 /* the MM_MLDrvs table could be made growable in the future if needed */
139 ERR("Too many open drivers\n");
140 HeapFree(GetProcessHeap(), 0, mld);
141 return NULL;
142 }
143 MM_MLDrvs[i] = mld;
144 *hndl = (HANDLE)(i | 0x8000);
145
146 mld->type = type;
147 if ((UINT_PTR)*hndl < MMDRV_GetNum(type) || ((UINT_PTR)*hndl >> 16)) {
148 /* FIXME: those conditions must be fulfilled so that:
149 * - we can distinguish between device IDs and handles
150 * - we can use handles as 16 or 32 bit entities
151 */
152 ERR("Shouldn't happen. Bad allocation scheme\n");
153 }
154
155 mld->dwFlags = HIWORD(*dwFlags);
156 mld->dwCallback = *dwCallback;
157 mld->dwClientInstance = *dwInstance;
158
159 return mld;
160}
#define ERR(fmt,...)
Definition: debug.h:113
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLsizeiptr size
Definition: glext.h:5919
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 MAX_MM_MLDRVS
Definition: lolvldrv.c:42
UINT MMDRV_GetNum(UINT type)
Definition: lolvldrv.c:61
static LPWINE_MLD MM_MLDrvs[40]
Definition: lolvldrv.c:41
unsigned __int3264 UINT_PTR
Definition: mstsclib_h.h:274
#define TRACE(s)
Definition: solgame.cpp:4
DWORD_PTR dwCallback
Definition: winemm.h:100
WORD dwFlags
Definition: winemm.h:99
DWORD_PTR dwClientInstance
Definition: winemm.h:101
UINT type
Definition: winemm.h:95
PVOID HANDLE
Definition: typedefs.h:73
#define HIWORD(l)
Definition: typedefs.h:247
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1176

Referenced by MIDI_OutAlloc(), midiInOpen(), mixerOpen(), and WAVE_Open().

◆ MMDRV_Close()

DWORD MMDRV_Close ( LPWINE_MLD  mld,
UINT  wMsg 
)

Definition at line 228 of file lolvldrv.c.

229{
230 TRACE("(%p, %04x)\n", mld, wMsg);
231 return MMDRV_Message(mld, wMsg, 0L, 0L);
232}
DWORD MMDRV_Message(LPWINE_MLD mld, UINT wMsg, DWORD_PTR dwParam1, DWORD_PTR dwParam2)
Definition: lolvldrv.c:71
#define L(x)
Definition: ntvdm.h:50

Referenced by midiInClose(), midiOutClose(), mixerClose(), and waveOutClose().

◆ MMDRV_Exit()

void MMDRV_Exit ( void  )

Definition at line 611 of file lolvldrv.c.

612{
613 unsigned int i;
614 TRACE("()\n");
615
616 for (i = 0; i < sizeof(MM_MLDrvs) / sizeof(MM_MLDrvs[0]); i++)
617 {
618 if (MM_MLDrvs[i] != NULL)
619 {
620 FIXME("Closing while ll-driver open\n");
621#if 0
622 /* FIXME: should generate a message depending on type */
623 MMDRV_Free((HANDLE)(i | 0x8000), MM_MLDrvs[i]);
624#endif
625 }
626 }
627
628 /* unload driver, in reverse order of loading */
629 i = MMDrvsHi;
630 while (i-- > 0)
631 {
638 CloseDriver(MMDrvs[i].hDriver, 0, 0);
639 }
640 if (llTypes[MMDRV_AUX].lpMlds)
641 HeapFree(GetProcessHeap(), 0, llTypes[MMDRV_AUX].lpMlds - 1);
642 if (llTypes[MMDRV_MIXER].lpMlds)
643 HeapFree(GetProcessHeap(), 0, llTypes[MMDRV_MIXER].lpMlds - 1);
644 if (llTypes[MMDRV_MIDIIN].lpMlds)
645 HeapFree(GetProcessHeap(), 0, llTypes[MMDRV_MIDIIN].lpMlds - 1);
646 if (llTypes[MMDRV_MIDIOUT].lpMlds)
647 HeapFree(GetProcessHeap(), 0, llTypes[MMDRV_MIDIOUT].lpMlds - 1);
648 if (llTypes[MMDRV_WAVEIN].lpMlds)
649 HeapFree(GetProcessHeap(), 0, llTypes[MMDRV_WAVEIN].lpMlds - 1);
650 if (llTypes[MMDRV_WAVEOUT].lpMlds)
651 HeapFree(GetProcessHeap(), 0, llTypes[MMDRV_WAVEOUT].lpMlds - 1);
652}
#define FIXME(fmt,...)
Definition: debug.h:114
LRESULT WINAPI CloseDriver(HDRVR hDrvr, LPARAM lParam1, LPARAM lParam2)
Definition: driver.c:462
static BOOL MMDRV_ExitPerType(LPWINE_MM_DRIVER lpDrv, UINT type)
Definition: lolvldrv.c:588
void MMDRV_Free(HANDLE hndl, LPWINE_MLD mld)
Definition: lolvldrv.c:165
static WINE_MM_DRIVER MMDrvs[8]
Definition: lolvldrv.c:40
static int MMDrvsHi
Definition: lolvldrv.c:39
static WINE_LLTYPE llTypes[MMDRV_MAX]
Definition: lolvldrv.c:48
_In_ LPWSTR _In_ ULONG _In_ ULONG _In_ ULONG _Out_ DEVINFO _In_ HDEV _In_ LPWSTR _In_ HANDLE hDriver
Definition: winddi.h:3557
#define MMDRV_WAVEIN
Definition: winemm.h:80
#define MMDRV_AUX
Definition: winemm.h:76
#define MMDRV_MIDIIN
Definition: winemm.h:78
#define MMDRV_MIDIOUT
Definition: winemm.h:79
#define MMDRV_WAVEOUT
Definition: winemm.h:81
#define MMDRV_MIXER
Definition: winemm.h:77

Referenced by DllMain().

◆ MMDRV_ExitPerType()

static BOOL MMDRV_ExitPerType ( LPWINE_MM_DRIVER  lpDrv,
UINT  type 
)
static

Definition at line 588 of file lolvldrv.c.

589{
590 WINE_MM_DRIVER_PART* part = &lpDrv->parts[type];
591 DWORD ret;
592 TRACE("(%p, %04x)\n", lpDrv, type);
593
594 if (part->fnMessage32) {
595#if 0
596 ret = part->fnMessage32(0, DRVM_DISABLE, 0L, 0L, 0L);
597 TRACE("DRVM_DISABLE => %08lx\n", ret);
598#endif
599 ret = part->fnMessage32(0, DRVM_EXIT, 0L, 0L, 0L);
600 TRACE("DRVM_EXIT => %s\n", WINMM_ErrorToString(ret));
601 }
602
603 return TRUE;
604}
#define TRUE
Definition: types.h:120
#define DRVM_DISABLE
Definition: mmddk.h:58
#define DRVM_EXIT
Definition: mmddk.h:57
unsigned long DWORD
Definition: ntddk_ex.h:95
WINEMM_msgFunc32 fnMessage32
Definition: winemm.h:73
WINE_MM_DRIVER_PART parts[MMDRV_MAX]
Definition: winemm.h:89
int ret
const char * WINMM_ErrorToString(MMRESULT error)
Definition: winmm.c:110

Referenced by MMDRV_Exit().

◆ MMDRV_Free()

void MMDRV_Free ( HANDLE  hndl,
LPWINE_MLD  mld 
)

Definition at line 165 of file lolvldrv.c.

166{
167 TRACE("(%p, %p)\n", hndl, mld);
168
169 if ((UINT_PTR)hndl & 0x8000) {
170 UINT_PTR idx = (UINT_PTR)hndl & ~0x8000;
171 if (idx < sizeof(MM_MLDrvs) / sizeof(MM_MLDrvs[0])) {
172 MM_MLDrvs[idx] = NULL;
173 HeapFree(GetProcessHeap(), 0, mld);
174 return;
175 }
176 }
177 ERR("Bad Handle %p at %p (not freed)\n", hndl, mld);
178}
unsigned int idx
Definition: utils.c:41

Referenced by midiInClose(), midiInOpen(), midiOutClose(), midiOutOpen(), mixerClose(), mixerOpen(), MMDRV_Exit(), WAVE_Open(), waveInClose(), and waveOutClose().

◆ MMDRV_Get()

LPWINE_MLD MMDRV_Get ( HANDLE  _hndl,
UINT  type,
BOOL  bCanBeID 
)

Definition at line 250 of file lolvldrv.c.

251{
252 LPWINE_MLD mld = NULL;
253 UINT_PTR hndl = (UINT_PTR)_hndl;
254 TRACE("(%p, %04x, %c)\n", _hndl, type, bCanBeID ? 'Y' : 'N');
255
257
258 if (hndl >= llTypes[type].wMaxId &&
259 hndl != (UINT16)-1 && hndl != (UINT)-1) {
260 if (hndl & 0x8000) {
261 UINT idx = hndl & ~0x8000;
262 if (idx < sizeof(MM_MLDrvs) / sizeof(MM_MLDrvs[0])) {
263 __TRY
264 {
265 mld = MM_MLDrvs[idx];
266 if (mld && mld->type != type) mld = NULL;
267 }
269 {
270 mld = NULL;
271 }
272 __ENDTRY;
273 }
274 }
275 }
276 if (mld == NULL && bCanBeID) {
277 mld = MMDRV_GetByID(hndl, type);
278 }
279 return mld;
280}
unsigned short UINT16
#define __TRY
Definition: compat.h:80
#define __ENDTRY
Definition: compat.h:82
#define __EXCEPT_PAGE_FAULT
Definition: compat.h:81
#define assert(x)
Definition: debug.h:53
static LPWINE_MLD MMDRV_GetByID(UINT uDevID, UINT type)
Definition: lolvldrv.c:237
unsigned int UINT
Definition: ndis.h:50
#define MMDRV_MAX
Definition: winemm.h:82

Referenced by auxGetDevCapsW(), auxGetVolume(), auxOutMessage(), auxSetVolume(), midiInAddBuffer(), midiInClose(), midiInGetDevCapsW(), midiInGetID(), midiInMessage(), midiInPrepareHeader(), midiInReset(), midiInStart(), midiInStop(), midiInUnprepareHeader(), midiOutClose(), midiOutGetDevCapsW(), midiOutGetID(), midiOutGetVolume(), midiOutLongMsg(), midiOutMessage(), midiOutPrepareHeader(), midiOutReset(), midiOutSetVolume(), midiOutShortMsg(), midiOutUnprepareHeader(), MIXER_GetDev(), mixerClose(), mixerGetDevCapsW(), mixerMessage(), MMDRV_GetRelated(), MMSYSTEM_GetMidiStream(), MMSYSTEM_MidiStream_Player(), waveInAddBuffer(), waveInClose(), waveInGetDevCapsW(), waveInGetID(), waveInGetPosition(), waveInMessage(), waveInPrepareHeader(), waveInReset(), waveInStart(), waveInStop(), waveInUnprepareHeader(), waveOutBreakLoop(), waveOutClose(), waveOutGetDevCapsW(), waveOutGetID(), waveOutGetPitch(), waveOutGetPlaybackRate(), waveOutGetPosition(), waveOutGetVolume(), waveOutMessage(), waveOutPause(), waveOutPrepareHeader(), waveOutReset(), waveOutRestart(), waveOutSetPitch(), waveOutSetPlaybackRate(), waveOutSetVolume(), waveOutUnprepareHeader(), and waveOutWrite().

◆ MMDRV_GetByID()

static LPWINE_MLD MMDRV_GetByID ( UINT  uDevID,
UINT  type 
)
static

Definition at line 237 of file lolvldrv.c.

238{
239 TRACE("(%04x, %04x)\n", uDevID, type);
240 if (uDevID < llTypes[type].wMaxId)
241 return &llTypes[type].lpMlds[uDevID];
242 if ((uDevID == (UINT16)-1 || uDevID == (UINT)-1) && llTypes[type].nMapper != -1)
243 return &llTypes[type].lpMlds[-1];
244 return NULL;
245}
LPWINE_MLD lpMlds
Definition: lolvldrv.c:35

Referenced by MMDRV_Get(), and MMDRV_GetRelated().

◆ MMDRV_GetNum()

UINT MMDRV_GetNum ( UINT  type)

◆ MMDRV_GetRelated()

LPWINE_MLD MMDRV_GetRelated ( HANDLE  hndl,
UINT  srcType,
BOOL  bSrcCanBeID,
UINT  dstType 
)

Definition at line 285 of file lolvldrv.c.

287{
288 LPWINE_MLD mld;
289 TRACE("(%p, %04x, %c, %04x)\n",
290 hndl, srcType, bSrcCanBeID ? 'Y' : 'N', dstType);
291
292 if ((mld = MMDRV_Get(hndl, srcType, bSrcCanBeID)) != NULL) {
293 WINE_MM_DRIVER_PART* part = &MMDrvs[mld->mmdIndex].parts[dstType];
294 if (part->nIDMin < part->nIDMax)
295 return MMDRV_GetByID(part->nIDMin, dstType);
296 }
297 return NULL;
298}
LPWINE_MLD MMDRV_Get(HANDLE _hndl, UINT type, BOOL bCanBeID)
Definition: lolvldrv.c:250
UINT mmdIndex
Definition: winemm.h:96

Referenced by MIXER_GetDev().

◆ MMDRV_Init()

BOOL MMDRV_Init ( void  )

Definition at line 530 of file lolvldrv.c.

531{
532/* Redundant code, keeping this for reference only (for now) */
533#if 0
534 HKEY hKey;
535 char driver_buffer[256];
536 char mapper_buffer[256];
537 char midi_buffer[256];
538 char* p;
539 DWORD type, size;
540 BOOL ret = FALSE;
541 TRACE("()\n");
542
543 strcpy(driver_buffer, WINE_DEFAULT_WINMM_DRIVER);
544 strcpy(mapper_buffer, WINE_DEFAULT_WINMM_MAPPER);
545 strcpy(midi_buffer, WINE_DEFAULT_WINMM_MIDI);
546
547 /* @@ Wine registry key: HKCU\Software\Wine\Drivers */
548 if (!RegOpenKeyA(HKEY_CURRENT_USER, "Software\\Wine\\Drivers", &hKey))
549 {
550 size = sizeof(driver_buffer);
551 if (RegQueryValueExA(hKey, "Audio", 0, &type, (LPVOID)driver_buffer, &size))
552 strcpy(driver_buffer, WINE_DEFAULT_WINMM_DRIVER);
553 }
554
555 p = driver_buffer;
556 while (p)
557 {
558 char filename[sizeof(driver_buffer)+10];
559 char *next = strchr(p, ',');
560 if (next) *next++ = 0;
561 sprintf( filename, "wine%s.drv", p );
562 if ((ret = MMDRV_Install( filename, filename, FALSE ))) break;
563 p = next;
564 }
565
566 ret |= MMDRV_Install("beepmidi.dll", "beepmidi.dll", FALSE);
567
570 return ret;
571#else
572 INT driver_count = 0;
573
576
577 /* Explorer doesn't like us failing */
578 return TRUE;
579// return ( driver_count > 0 );
580#endif
581}
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
char * strchr(const char *String, int ch)
Definition: utclib.c:501
#define FALSE
Definition: types.h:117
LONG WINAPI RegOpenKeyA(HKEY hKey, LPCSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:3234
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
BOOL LoadRegistryMMEDrivers(char *key)
Definition: registry.c:23
static unsigned driver_count
Definition: ds3d.c:1254
unsigned int BOOL
Definition: ntddk_ex.h:94
FxAutoRegKey hKey
GLfloat GLfloat p
Definition: glext.h:8902
const char * filename
Definition: ioapi.h:137
BOOL MMDRV_Install(LPCSTR drvRegName, LPCSTR drvFileName, BOOL bIsMapper)
Definition: lolvldrv.c:440
#define sprintf(buf, format,...)
Definition: sprintf.c:55
static unsigned __int64 next
Definition: rand_nt.c:6
int32_t INT
Definition: typedefs.h:58
#define WINE_DEFAULT_WINMM_DRIVER
Definition: winemm.h:46
#define NT_MME_DRIVERS_KEY
Definition: winemm.h:201
#define NT_MME_DRIVERS32_KEY
Definition: winemm.h:198
#define WINE_DEFAULT_WINMM_MIDI
Definition: winemm.h:48
#define WINE_DEFAULT_WINMM_MAPPER
Definition: winemm.h:47
#define HKEY_CURRENT_USER
Definition: winreg.h:11

Referenced by DllMain().

◆ MMDRV_InitPerType()

static BOOL MMDRV_InitPerType ( LPWINE_MM_DRIVER  lpDrv,
UINT  type,
UINT  wMsg 
)
static

Definition at line 359 of file lolvldrv.c.

360{
361 WINE_MM_DRIVER_PART* part = &lpDrv->parts[type];
362 DWORD ret;
363 UINT count = 0;
364 int i, k;
365 TRACE("(%p, %04x, %04x)\n", lpDrv, type, wMsg);
366
367 part->nIDMin = part->nIDMax = 0;
368
369 /* for DRVM_INIT and DRVM_ENABLE, dwParam2 should be PnP node */
370 /* the DRVM_ENABLE is only required when the PnP node is non zero */
371 if (part->fnMessage32) {
372 ret = part->fnMessage32(0, DRVM_INIT, 0L, 0L, 0L);
373 TRACE("DRVM_INIT => %s\n", WINMM_ErrorToString(ret));
374#if 0
375 ret = part->fnMessage32(0, DRVM_ENABLE, 0L, 0L, 0L);
376 TRACE("DRVM_ENABLE => %08lx\n", ret);
377#endif
378 count = part->fnMessage32(0, wMsg, 0L, 0L, 0L);
379 }
380 else return FALSE;
381
382 TRACE("Got %u dev for (%s:%s)\n", count, lpDrv->drvname, llTypes[type].typestr);
383
384 if (HIWORD(count))
385 return FALSE;
386
387 /* got some drivers */
388 if (lpDrv->bIsMapper) {
389 /* it seems native mappers return 0 devices :-( */
390 if (llTypes[type].nMapper != -1)
391 ERR("Two mappers for type %s (%d, %s)\n",
392 llTypes[type].typestr, llTypes[type].nMapper, lpDrv->drvname);
393 if (count > 1)
394 ERR("Strange: mapper with %d > 1 devices\n", count);
396 } else {
397 if (count == 0)
398 return FALSE;
399 part->nIDMin = llTypes[type].wMaxId;
401 part->nIDMax = llTypes[type].wMaxId;
402 }
403 TRACE("Setting min=%d max=%d (ttop=%d) for (%s:%s)\n",
404 part->nIDMin, part->nIDMax, llTypes[type].wMaxId,
405 lpDrv->drvname, llTypes[type].typestr);
406 /* realloc translation table */
407 if (llTypes[type].lpMlds)
410 sizeof(WINE_MLD) * (llTypes[type].wMaxId + 1)) + 1;
411 else
414 sizeof(WINE_MLD) * (llTypes[type].wMaxId + 1)) + 1;
415
416 /* re-build the translation table */
417 if (llTypes[type].nMapper != -1) {
418 TRACE("%s:Trans[%d] -> %s\n", llTypes[type].typestr, -1, MMDrvs[llTypes[type].nMapper].drvname);
420 llTypes[type].lpMlds[-1].type = type;
423 }
424 for (i = k = 0; i <= MMDrvsHi; i++) {
425 while (MMDrvs[i].parts[type].nIDMin <= k && k < MMDrvs[i].parts[type].nIDMax) {
426 TRACE("%s:Trans[%d] -> %s\n", llTypes[type].typestr, k, MMDrvs[i].drvname);
431 k++;
432 }
433 }
434 return TRUE;
435}
#define HeapReAlloc
Definition: compat.h:734
#define DRVM_INIT
Definition: mmddk.h:56
#define DRVM_ENABLE
Definition: mmddk.h:59
static const D3D_BLOB_PART parts[]
Definition: blob.c:76
int k
Definition: mpi.c:3369
LPCSTR typestr
Definition: lolvldrv.c:31
DWORD_PTR dwDriverInstance
Definition: winemm.h:97
UINT uDeviceID
Definition: winemm.h:94
LPSTR drvname
Definition: winemm.h:87
unsigned bIsMapper
Definition: winemm.h:88
struct tagWINE_MLD * LPWINE_MLD
struct tagWINE_MLD WINE_MLD

Referenced by MMDRV_Install().

◆ MMDRV_Install()

BOOL MMDRV_Install ( LPCSTR  drvRegName,
LPCSTR  drvFileName,
BOOL  bIsMapper 
)

Definition at line 440 of file lolvldrv.c.

441{
442 int i, count = 0;
446
447 TRACE("('%s', '%s', mapper=%c);\n", drvRegName, drvFileName, bIsMapper ? 'Y' : 'N');
448
449 for (i = 0; i < MMDrvsHi; i++) {
450 if (!strcmp(drvRegName, MMDrvs[i].drvname)) return FALSE;
451 }
452
453 /* Be sure that size of MMDrvs matches the max number of loadable
454 * drivers !!
455 * If not just increase size of MMDrvs
456 */
457 assert(MMDrvsHi <= sizeof(MMDrvs)/sizeof(MMDrvs[0]));
458
459 memset(lpDrv, 0, sizeof(*lpDrv));
460
461 if (!(lpDrv->hDriver = OpenDriverA(drvFileName, 0, 0))) {
462 WARN("Couldn't open driver '%s'\n", drvFileName);
463 return FALSE;
464 }
465
467
468 if (!(d = DRIVER_FindFromHDrvr(lpDrv->hDriver))) {
469 CloseDriver(lpDrv->hDriver, 0, 0);
470 WARN("Couldn't get the WINE internal structure for driver '%s'\n", drvFileName);
471 return FALSE;
472 }
473
474 /* Then look for xxxMessage functions */
475#define AA(_h,_w,_x,_y,_z) \
476 func = (WINEMM_msgFunc##_y) _z ((_h), #_x); \
477 if (func != NULL) \
478 { lpDrv->parts[_w].fnMessage##_y = func; count++; \
479 TRACE("Got %d bit func '%s'\n", _y, #_x); }
480
481 if (d->hModule) {
482#define A(_x,_y) AA(d->hModule,_x,_y,32,GetProcAddress)
489#undef A
490 }
491#undef AA
492
493 if (!count) {
494 CloseDriver(lpDrv->hDriver, 0, 0);
495 WARN("No message functions found\n");
496 return FALSE;
497 }
498
499 /* FIXME: being a mapper or not should be known by another way */
500 /* it's known for NE drvs (the description is of the form '*mapper: *'
501 * I don't have any clue for PE drvs
502 */
503 lpDrv->bIsMapper = bIsMapper;
504 lpDrv->drvname = strcpy(HeapAlloc(GetProcessHeap(), 0, strlen(drvRegName) + 1), drvRegName);
505
506 /* Finish init and get the count of the devices */
507 i = 0;
514 /* if all those func calls return FALSE, then the driver must be unloaded */
515 if (!i) {
516 CloseDriver(lpDrv->hDriver, 0, 0);
517 HeapFree(GetProcessHeap(), 0, lpDrv->drvname);
518 WARN("Driver initialization failed\n");
519 return FALSE;
520 }
521
522 MMDrvsHi++;
523
524 return TRUE;
525}
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
APIENTRY DWORD auxMessage(UINT dwId, UINT uMessage, DWORD dwUser, DWORD dwParam1, DWORD dwParam2)
Definition: auxil.c:20
MMRESULT FAR PASCAL modMessage(UINT device_id, UINT message, DWORD_PTR private_data, DWORD_PTR parameter1, DWORD_PTR parameter2)
Definition: beepmidi.c:771
#define WARN(fmt,...)
Definition: debug.h:115
APIENTRY DWORD midMessage(DWORD dwId, DWORD dwMessage, DWORD dwUser, DWORD dwParam1, DWORD dwParam2)
Definition: midi.c:251
#define WIDM_GETNUMDEVS
Definition: mmddk.h:136
#define AUXDM_GETNUMDEVS
Definition: mmddk.h:182
#define MODM_GETNUMDEVS
Definition: mmddk.h:154
#define WODM_GETNUMDEVS
Definition: mmddk.h:108
#define MIDM_GETNUMDEVS
Definition: mmddk.h:169
#define MXDM_GETNUMDEVS
Definition: mmddk.h:191
LPWINE_DRIVER DRIVER_FindFromHDrvr(HDRVR hDrvr)
Definition: driver.c:89
HDRVR WINAPI OpenDriverA(LPCSTR lpDriverName, LPCSTR lpSectionName, LPARAM lParam)
Definition: driver.c:365
#define d
Definition: ke_i.h:81
#define A(_x, _y)
Definition: lolvldrv.c:44
static BOOL MMDRV_InitPerType(LPWINE_MM_DRIVER lpDrv, UINT type, UINT wMsg)
Definition: lolvldrv.c:359
DWORD APIENTRY wodMessage(UINT device_id, UINT message, DWORD_PTR private_handle, DWORD_PTR parameter1, DWORD_PTR parameter2)
Definition: mme.c:48
DWORD APIENTRY mxdMessage(UINT DeviceId, UINT Message, DWORD_PTR PrivateHandle, DWORD_PTR Parameter1, DWORD_PTR Parameter2)
Definition: mxdMessage.c:69
#define memset(x, y, z)
Definition: compat.h:39
HDRVR hDriver
Definition: winemm.h:86
DWORD APIENTRY widMessage(UINT DeviceId, UINT Message, DWORD_PTR PrivateHandle, DWORD_PTR Parameter1, DWORD_PTR Parameter2)
Definition: widMessage.c:20
DWORD(CALLBACK * WINEMM_msgFunc32)(UINT, UINT, DWORD_PTR, DWORD_PTR, DWORD_PTR)
Definition: winemm.h:65

Referenced by LoadRegistryMMEDrivers(), and MMDRV_Init().

◆ MMDRV_Message()

DWORD MMDRV_Message ( LPWINE_MLD  mld,
UINT  wMsg,
DWORD_PTR  dwParam1,
DWORD_PTR  dwParam2 
)

Definition at line 71 of file lolvldrv.c.

73{
74 LPWINE_MM_DRIVER lpDrv;
75 DWORD ret;
77 WINE_LLTYPE* llType = &llTypes[mld->type];
78 int devID;
79
80 TRACE("(%s %u %u 0x%08lx 0x%08lx 0x%08lx)\n",
81 llTypes[mld->type].typestr, mld->uDeviceID, wMsg,
82 mld->dwDriverInstance, dwParam1, dwParam2);
83
84 if (mld->uDeviceID == (UINT16)-1) {
85 if (!llType->bSupportMapper) {
86 WARN("uDev=-1 requested on non-mappable ll type %s\n",
87 llTypes[mld->type].typestr);
89 }
90 devID = -1;
91 } else {
92 if (mld->uDeviceID >= llType->wMaxId) {
93 WARN("uDev(%u) requested >= max (%d)\n", mld->uDeviceID, llType->wMaxId);
95 }
96 devID = mld->uDeviceID;
97 }
98
99 lpDrv = &MMDrvs[mld->mmdIndex];
100 part = &lpDrv->parts[mld->type];
101
102#if 0
103 /* some sanity checks */
104 if (!(part->nIDMin <= devID))
105 ERR("!(part->nIDMin(%d) <= devID(%d))\n", part->nIDMin, devID);
106 if (!(devID < part->nIDMax))
107 ERR("!(devID(%d) < part->nIDMax(%d))\n", devID, part->nIDMax);
108#endif
109
110 assert(part->fnMessage32);
111
112 TRACE("Calling message(dev=%u msg=%u usr=0x%08lx p1=0x%08lx p2=0x%08lx)\n",
113 mld->uDeviceID, wMsg, mld->dwDriverInstance, dwParam1, dwParam2);
114 ret = part->fnMessage32(mld->uDeviceID, wMsg, mld->dwDriverInstance, dwParam1, dwParam2);
115 TRACE("=> %s\n", WINMM_ErrorToString(ret));
116
117 return ret;
118}
#define MMSYSERR_BADDEVICEID
Definition: mmsystem.h:98
BOOL bSupportMapper
Definition: lolvldrv.c:32

Referenced by auxGetDevCapsW(), auxGetVolume(), auxOutMessage(), auxSetVolume(), midiInAddBuffer(), midiInGetDevCapsW(), midiInMessage(), midiInPrepareHeader(), midiInReset(), midiInStart(), midiInStop(), midiInUnprepareHeader(), midiOutGetDevCapsW(), midiOutGetVolume(), midiOutLongMsg(), midiOutMessage(), midiOutPrepareHeader(), midiOutReset(), midiOutSetVolume(), midiOutShortMsg(), midiOutUnprepareHeader(), mixerGetControlDetailsW(), mixerGetDevCapsW(), mixerGetLineControlsW(), mixerGetLineInfoW(), mixerMessage(), mixerSetControlDetails(), MMDRV_Close(), MMDRV_Open(), MMDRV_PhysicalFeatures(), waveInAddBuffer(), waveInClose(), waveInGetDevCapsW(), waveInGetPosition(), waveInMessage(), waveInPrepareHeader(), waveInReset(), waveInStart(), waveInStop(), waveInUnprepareHeader(), waveOutBreakLoop(), waveOutGetDevCapsW(), waveOutGetPitch(), waveOutGetPlaybackRate(), waveOutGetPosition(), waveOutGetVolume(), waveOutMessage(), waveOutPause(), waveOutPrepareHeader(), waveOutReset(), waveOutRestart(), waveOutSetPitch(), waveOutSetPlaybackRate(), waveOutSetVolume(), waveOutUnprepareHeader(), and waveOutWrite().

◆ MMDRV_Open()

DWORD MMDRV_Open ( LPWINE_MLD  mld,
UINT  wMsg,
DWORD_PTR  dwParam1,
DWORD  dwFlags 
)

Definition at line 183 of file lolvldrv.c.

184{
186 DWORD_PTR dwInstance;
187 WINE_LLTYPE* llType = &llTypes[mld->type];
188 TRACE("(%p, %04x, 0x%08lx, 0x%08x)\n", mld, wMsg, dwParam1, dwFlags);
189
190 mld->dwDriverInstance = (DWORD_PTR)&dwInstance;
191
192 if (mld->uDeviceID == (UINT)-1 || mld->uDeviceID == (UINT16)-1) {
193 TRACE("MAPPER mode requested !\n");
194 /* check if mapper is supported by type */
195 if (llType->bSupportMapper) {
196 if (llType->nMapper == -1) {
197 /* no driver for mapper has been loaded, try a dumb implementation */
198 TRACE("No mapper loaded, doing it by hand\n");
199 for (mld->uDeviceID = 0; mld->uDeviceID < llType->wMaxId; mld->uDeviceID++) {
200 if ((dwRet = MMDRV_Open(mld, wMsg, dwParam1, dwFlags)) == MMSYSERR_NOERROR) {
201 /* to share this function epilog */
202 dwInstance = mld->dwDriverInstance;
203 break;
204 }
205 }
206 } else {
207 mld->uDeviceID = (UINT16)-1;
208 mld->mmdIndex = llType->lpMlds[-1].mmdIndex;
209 TRACE("Setting mmdIndex to %u\n", mld->mmdIndex);
210 dwRet = MMDRV_Message(mld, wMsg, dwParam1, dwFlags);
211 }
212 }
213 } else {
214 if (mld->uDeviceID < llType->wMaxId) {
215 mld->mmdIndex = llType->lpMlds[mld->uDeviceID].mmdIndex;
216 TRACE("Setting mmdIndex to %u\n", mld->mmdIndex);
217 dwRet = MMDRV_Message(mld, wMsg, dwParam1, dwFlags);
218 }
219 }
220 if (dwRet == MMSYSERR_NOERROR)
221 mld->dwDriverInstance = dwInstance;
222 return dwRet;
223}
DWORD MMDRV_Open(LPWINE_MLD mld, UINT wMsg, DWORD_PTR dwParam1, DWORD dwFlags)
Definition: lolvldrv.c:183
#define MMSYSERR_NOERROR
Definition: mmsystem.h:96
#define DWORD_PTR
Definition: treelist.c:76
uint32_t DWORD_PTR
Definition: typedefs.h:65

Referenced by midiInOpen(), midiOutOpen(), midiStreamOpen(), mixerOpen(), MMDRV_Open(), and WAVE_Open().

◆ MMDRV_PhysicalFeatures()

UINT MMDRV_PhysicalFeatures ( LPWINE_MLD  mld,
UINT  uMsg,
DWORD_PTR  dwParam1,
DWORD_PTR  dwParam2 
)

Definition at line 303 of file lolvldrv.c.

305{
306 WINE_MM_DRIVER* lpDrv = &MMDrvs[mld->mmdIndex];
307
308 TRACE("(%p, %04x, %08lx, %08lx)\n", mld, uMsg, dwParam1, dwParam2);
309
310 /* all those function calls are undocumented */
311 switch (uMsg) {
313 lstrcpynA((LPSTR)dwParam1, lpDrv->drvname, LOWORD(dwParam2));
314 break;
315 case DRV_QUERYDEVNODE:
316 *(LPDWORD)dwParam1 = 0L; /* should be DevNode */
317 break;
318 case DRV_QUERYNAME:
319 WARN("NIY QueryName\n");
320 break;
322 WARN("NIY call VxD\n");
323 /* should call VxD MMDEVLDR with (DevNode, dwParam1 and dwParam2) as pmts
324 * dwParam1 is buffer and dwParam2 is sizeof(buffer)
325 * I don't know where the result is stored though
326 */
327 break;
329 return (lpDrv->bIsMapper) ? 2 : 0;
330
332 /* FIXME: get from registry someday */
333#ifdef __REACTOS__
334 if (!dwParam1 || !dwParam2)
335 return MMSYSERR_INVALPARAM;
336#endif
337 *((LPDWORD)dwParam1) = -1; /* No preferred device */
338 *((LPDWORD)dwParam2) = 0;
339 break;
340
343 return MMDRV_Message(mld, uMsg, dwParam1, dwParam2);
344
345 case DRV_QUERYDSOUNDIFACE: /* Wine-specific: Retrieve DirectSound interface */
346 case DRV_QUERYDSOUNDDESC: /* Wine-specific: Retrieve DirectSound driver description*/
347 return MMDRV_Message(mld, uMsg, dwParam1, dwParam2);
348
349 default:
350 WARN("Unknown call %04x\n", uMsg);
351 return MMSYSERR_INVALPARAM;
352 }
353 return 0L;
354}
#define lstrcpynA
Definition: compat.h:751
#define DRV_QUERYDEVNODE
Definition: mmddk.h:90
#define DRV_QUERYDEVICEINTERFACESIZE
Definition: mmddk.h:97
#define DRV_QUERYDRVENTRY
Definition: mmddk.h:89
#define DRV_QUERYNAME
Definition: mmddk.h:91
#define DRV_QUERYMAPPABLE
Definition: mmddk.h:93
#define DRV_QUERYDEVICEINTERFACE
Definition: mmddk.h:96
#define DRV_QUERYDRIVERIDS
Definition: mmddk.h:92
#define DRVM_MAPPER_PREFERRED_GET
Definition: mmsys.h:39
#define MMSYSERR_INVALPARAM
Definition: mmsystem.h:107
#define LPDWORD
Definition: nt_native.h:46
#define LOWORD(l)
Definition: pedump.c:82
char * LPSTR
Definition: xmlstorage.h:182

Referenced by midiOutMessage(), waveInMessage(), and waveOutMessage().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( winmm  )

Variable Documentation

◆ llTypes

WINE_LLTYPE llTypes[MMDRV_MAX]
static
Initial value:
= {
A(TRUE, Aux),
A(FALSE, Mixer),
A(TRUE, MidiIn),
A(TRUE, MidiOut),
A(TRUE, WaveIn),
A(TRUE, WaveOut),
}

Definition at line 48 of file lolvldrv.c.

Referenced by MMDRV_Exit(), MMDRV_Get(), MMDRV_GetByID(), MMDRV_GetNum(), MMDRV_InitPerType(), MMDRV_Message(), and MMDRV_Open().

◆ MM_MLDrvs

LPWINE_MLD MM_MLDrvs[40]
static

Definition at line 41 of file lolvldrv.c.

Referenced by MMDRV_Alloc(), MMDRV_Exit(), MMDRV_Free(), and MMDRV_Get().

◆ MMDrvs

◆ MMDrvsHi

int MMDrvsHi
static

Definition at line 39 of file lolvldrv.c.

Referenced by MMDRV_Exit(), MMDRV_InitPerType(), and MMDRV_Install().