winmm: Have xyzGetDevCaps return MMSYSERR_BADDEVICEID, not INVALHANDLE.
[wine] / dlls / winmm / winemm.h
1 /*
2  * Copyright 1998, Luiz Otavio L. Zorzella
3  *           1999, Eric Pouech
4  *
5  * Purpose:   multimedia declarations (internal to WINMM & MMSYSTEM DLLs)
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20  */
21
22 #include <stdarg.h>
23
24 #include "windef.h"
25 #include "winbase.h"
26 #include "mmddk.h"
27
28 #define WINE_DEFAULT_WINMM_DRIVER     "alsa,oss,coreaudio,esd"
29 #define WINE_DEFAULT_WINMM_MAPPER     "msacm32.drv"
30 #define WINE_DEFAULT_WINMM_MIDI       "midimap.dll"
31
32 /* Who said goofy boy ? */
33 #define WINE_DI_MAGIC   0x900F1B01
34
35 typedef struct tagWINE_DRIVER
36 {
37     DWORD                       dwMagic;
38     /* as usual LPWINE_DRIVER == hDriver32 */
39     DWORD                       dwFlags;
40     HMODULE                     hModule;
41     DRIVERPROC                  lpDrvProc;
42     DWORD_PTR                   dwDriverID;
43     struct tagWINE_DRIVER*      lpPrevItem;
44     struct tagWINE_DRIVER*      lpNextItem;
45 } WINE_DRIVER, *LPWINE_DRIVER;
46
47 typedef DWORD   (CALLBACK *WINEMM_msgFunc32)(UINT, UINT, DWORD_PTR, DWORD_PTR, DWORD_PTR);
48
49 /* for each loaded driver and each known type of driver, this structure contains
50  * the information needed to access it
51  */
52 typedef struct tagWINE_MM_DRIVER_PART {
53     int                         nIDMin;         /* lower bound of global indexes for this type */
54     int                         nIDMax;         /* hhigher bound of global indexes for this type */
55     WINEMM_msgFunc32            fnMessage32;    /* pointer to function */
56 } WINE_MM_DRIVER_PART;
57
58 #define MMDRV_AUX               0
59 #define MMDRV_MIXER             1
60 #define MMDRV_MIDIIN            2
61 #define MMDRV_MIDIOUT           3
62 #define MMDRV_WAVEIN            4
63 #define MMDRV_WAVEOUT           5
64 #define MMDRV_MAX               6
65
66 /* each low-level .drv will be associated with an instance of this structure */
67 typedef struct tagWINE_MM_DRIVER {
68     HDRVR                       hDriver;
69     LPSTR                       drvname;        /* name of the driver */
70     unsigned                    bIsMapper : 1;  /* TRUE if mapper */
71     WINE_MM_DRIVER_PART         parts[MMDRV_MAX];/* Information for all known types */
72 } WINE_MM_DRIVER, *LPWINE_MM_DRIVER;
73
74 typedef struct tagWINE_MLD {
75 /* EPP struct tagWINE_MLD*      lpNext; */              /* not used so far */
76        UINT                     uDeviceID;
77        UINT                     type;
78        UINT                     mmdIndex;               /* index to low-level driver in MMDrvs table */
79        DWORD_PTR                dwDriverInstance;       /* this value is driver related, as opposed to
80                                                          * opendesc.dwInstance which is client (callback) related */
81        WORD                     dwFlags;
82        DWORD_PTR                dwCallback;
83        DWORD_PTR                dwClientInstance;
84 } WINE_MLD, *LPWINE_MLD;
85
86 typedef struct  {
87        WINE_MLD                 mld;
88 } WINE_WAVE, *LPWINE_WAVE;
89
90 typedef struct {
91        WINE_MLD                 mld;
92        MIDIOPENDESC             mod;                    /* FIXME: should be removed */
93 } WINE_MIDI, *LPWINE_MIDI;
94
95 typedef struct {
96        WINE_MLD                 mld;
97 } WINE_MIXER, *LPWINE_MIXER;
98
99 typedef struct tagWINE_MCIDRIVER {
100         UINT                    wDeviceID;
101         UINT                    wType;
102         LPWSTR                  lpstrElementName;
103         LPWSTR                  lpstrDeviceType;
104         LPWSTR                  lpstrAlias;
105         HDRVR                   hDriver;
106         DWORD_PTR               dwPrivate;
107         YIELDPROC               lpfnYieldProc;
108         DWORD                   dwYieldData;
109         DWORD                   CreatorThread;
110         UINT                    uTypeCmdTable;
111         UINT                    uSpecificCmdTable;
112         struct tagWINE_MCIDRIVER*lpNext;
113 } WINE_MCIDRIVER, *LPWINE_MCIDRIVER;
114
115 struct IOProcList
116 {
117     struct IOProcList*pNext;       /* Next item in linked list */
118     FOURCC            fourCC;      /* four-character code identifying IOProc */
119     LPMMIOPROC        pIOProc;     /* pointer to IProc */
120     BOOL              is_unicode;  /* 32A or 32W */
121     int               count;       /* number of objects linked to it */
122 };
123
124 typedef struct tagWINE_MMIO {
125     MMIOINFO                    info;
126     struct tagWINE_MMIO*        lpNext;
127     struct IOProcList*          ioProc;
128     unsigned                    bTmpIOProc : 1,
129                                 bBufferLoaded : 1;
130     DWORD                       dwFileSize;
131 } WINE_MMIO, *LPWINE_MMIO;
132
133 /* function prototypes */
134
135 LPWINE_DRIVER   DRIVER_FindFromHDrvr(HDRVR hDrvr);
136 BOOL            DRIVER_GetLibName(LPCWSTR keyName, LPCWSTR sectName, LPWSTR buf, int sz);
137 LPWINE_DRIVER   DRIVER_TryOpenDriver32(LPCWSTR fn, LPARAM lParam2);
138 void            DRIVER_UnloadAll(void);
139
140 BOOL            MMDRV_Init(void);
141 void            MMDRV_Exit(void);
142 UINT            MMDRV_GetNum(UINT);
143 LPWINE_MLD      MMDRV_Alloc(UINT size, UINT type, LPHANDLE hndl, DWORD* dwFlags,
144                             DWORD_PTR* dwCallback, DWORD_PTR* dwInstance);
145 void            MMDRV_Free(HANDLE hndl, LPWINE_MLD mld);
146 DWORD           MMDRV_Open(LPWINE_MLD mld, UINT wMsg, DWORD_PTR dwParam1, DWORD dwParam2);
147 DWORD           MMDRV_Close(LPWINE_MLD mld, UINT wMsg);
148 LPWINE_MLD      MMDRV_Get(HANDLE hndl, UINT type, BOOL bCanBeID);
149 LPWINE_MLD      MMDRV_GetRelated(HANDLE hndl, UINT srcType, BOOL bSrcCanBeID, UINT dstTyped);
150 DWORD           MMDRV_Message(LPWINE_MLD mld, UINT wMsg, DWORD_PTR dwParam1, DWORD_PTR dwParam2);
151 UINT            MMDRV_PhysicalFeatures(LPWINE_MLD mld, UINT uMsg, DWORD_PTR dwParam1, DWORD_PTR dwParam2);
152
153 const char*     MCI_MessageToString(UINT wMsg);
154 DWORD           MCI_SendCommand(UINT wDevID, UINT16 wMsg, DWORD_PTR dwParam1, DWORD_PTR dwParam2);
155 LPWSTR          MCI_strdupAtoW(LPCSTR str);
156 LPSTR           MCI_strdupWtoA(LPCWSTR str);
157
158 const char*     WINMM_ErrorToString(MMRESULT error);
159
160 void            TIME_MMTimeStop(void);
161
162 /* Global variables */
163 extern CRITICAL_SECTION WINMM_cs;
164 extern HINSTANCE hWinMM32Instance;
165 extern HANDLE psLastEvent;
166 extern HANDLE psStopEvent;
167
168 /* GetDriverFlags() returned bits is not documented (nor the call itself)
169  * Here are Wine only definitions of the bits
170  */
171 #define WINE_GDF_EXIST          0x80000000
172 #define WINE_GDF_EXTERNAL_MASK  0xF0000000
173 #define WINE_GDF_SESSION        0x00000001