winmm: Functions that take an open HWAVE don't need StartDevicesThread.
[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 /* Who said goofy boy ? */
29 #define WINE_DI_MAGIC   0x900F1B01
30
31 typedef struct tagWINE_DRIVER
32 {
33     DWORD                       dwMagic;
34     /* as usual LPWINE_DRIVER == hDriver32 */
35     DWORD                       dwFlags;
36     HMODULE                     hModule;
37     DRIVERPROC                  lpDrvProc;
38     DWORD_PTR                   dwDriverID;
39     struct tagWINE_DRIVER*      lpPrevItem;
40     struct tagWINE_DRIVER*      lpNextItem;
41 } WINE_DRIVER, *LPWINE_DRIVER;
42
43 typedef DWORD   (CALLBACK *WINEMM_msgFunc32)(UINT, UINT, DWORD_PTR, DWORD_PTR, DWORD_PTR);
44
45 /* for each loaded driver and each known type of driver, this structure contains
46  * the information needed to access it
47  */
48 typedef struct tagWINE_MM_DRIVER_PART {
49     int                         nIDMin;         /* lower bound of global indexes for this type */
50     int                         nIDMax;         /* hhigher bound of global indexes for this type */
51     WINEMM_msgFunc32            fnMessage32;    /* pointer to function */
52 } WINE_MM_DRIVER_PART;
53
54 #define MMDRV_AUX               0
55 #define MMDRV_MIXER             1
56 #define MMDRV_MIDIIN            2
57 #define MMDRV_MIDIOUT           3
58 #define MMDRV_WAVEIN            4
59 #define MMDRV_WAVEOUT           5
60 #define MMDRV_MAX               6
61
62 /* each low-level .drv will be associated with an instance of this structure */
63 typedef struct tagWINE_MM_DRIVER {
64     HDRVR                       hDriver;
65     LPSTR                       drvname;        /* name of the driver */
66     unsigned                    bIsMapper : 1;  /* TRUE if mapper */
67     WINE_MM_DRIVER_PART         parts[MMDRV_MAX];/* Information for all known types */
68 } WINE_MM_DRIVER, *LPWINE_MM_DRIVER;
69
70 typedef struct tagWINE_MLD {
71 /* EPP struct tagWINE_MLD*      lpNext; */              /* not used so far */
72        UINT                     uDeviceID;
73        UINT                     type;
74        UINT                     mmdIndex;               /* index to low-level driver in MMDrvs table */
75        DWORD_PTR                dwDriverInstance;       /* this value is driver related, as opposed to
76                                                          * opendesc.dwInstance which is client (callback) related */
77        WORD                     dwFlags;
78        DWORD_PTR                dwCallback;
79        DWORD_PTR                dwClientInstance;
80 } WINE_MLD, *LPWINE_MLD;
81
82 typedef struct  {
83        WINE_MLD                 mld;
84 } WINE_WAVE, *LPWINE_WAVE;
85
86 typedef struct {
87        WINE_MLD                 mld;
88        MIDIOPENDESC             mod;                    /* FIXME: should be removed */
89 } WINE_MIDI, *LPWINE_MIDI;
90
91 typedef struct {
92        WINE_MLD                 mld;
93 } WINE_MIXER, *LPWINE_MIXER;
94
95 typedef struct tagWINE_MCIDRIVER {
96         UINT                    wDeviceID;
97         UINT                    wType;
98         LPWSTR                  lpstrDeviceType;
99         LPWSTR                  lpstrAlias;
100         HDRVR                   hDriver;
101         DWORD_PTR               dwPrivate;
102         YIELDPROC               lpfnYieldProc;
103         DWORD                   dwYieldData;
104         DWORD                   CreatorThread;
105         UINT                    uTypeCmdTable;
106         UINT                    uSpecificCmdTable;
107         struct tagWINE_MCIDRIVER*lpNext;
108 } WINE_MCIDRIVER, *LPWINE_MCIDRIVER;
109
110 struct IOProcList
111 {
112     struct IOProcList*pNext;       /* Next item in linked list */
113     FOURCC            fourCC;      /* four-character code identifying IOProc */
114     LPMMIOPROC        pIOProc;     /* pointer to IProc */
115     BOOL              is_unicode;  /* 32A or 32W */
116     int               count;       /* number of objects linked to it */
117 };
118
119 typedef struct tagWINE_MMIO {
120     MMIOINFO                    info;
121     struct tagWINE_MMIO*        lpNext;
122     struct IOProcList*          ioProc;
123     unsigned                    bTmpIOProc : 1,
124                                 bBufferLoaded : 1;
125     DWORD                       dwFileSize;
126 } WINE_MMIO, *LPWINE_MMIO;
127
128 /* function prototypes */
129
130 LPWINE_DRIVER   DRIVER_FindFromHDrvr(HDRVR hDrvr) DECLSPEC_HIDDEN;
131 BOOL            DRIVER_GetLibName(LPCWSTR keyName, LPCWSTR sectName, LPWSTR buf, int sz) DECLSPEC_HIDDEN;
132 LPWINE_DRIVER   DRIVER_TryOpenDriver32(LPCWSTR fn, LPARAM lParam2) DECLSPEC_HIDDEN;
133 void            DRIVER_UnloadAll(void) DECLSPEC_HIDDEN;
134
135 void            MMDRV_Exit(void) DECLSPEC_HIDDEN;
136 UINT            MMDRV_GetNum(UINT) DECLSPEC_HIDDEN;
137 LPWINE_MLD      MMDRV_Alloc(UINT size, UINT type, LPHANDLE hndl, DWORD* dwFlags,
138                             DWORD_PTR* dwCallback, DWORD_PTR* dwInstance) DECLSPEC_HIDDEN;
139 void            MMDRV_Free(HANDLE hndl, LPWINE_MLD mld) DECLSPEC_HIDDEN;
140 DWORD           MMDRV_Open(LPWINE_MLD mld, UINT wMsg, DWORD_PTR dwParam1, DWORD dwParam2) DECLSPEC_HIDDEN;
141 DWORD           MMDRV_Close(LPWINE_MLD mld, UINT wMsg) DECLSPEC_HIDDEN;
142 LPWINE_MLD      MMDRV_Get(HANDLE hndl, UINT type, BOOL bCanBeID) DECLSPEC_HIDDEN;
143 LPWINE_MLD      MMDRV_GetRelated(HANDLE hndl, UINT srcType, BOOL bSrcCanBeID, UINT dstTyped) DECLSPEC_HIDDEN;
144 DWORD           MMDRV_Message(LPWINE_MLD mld, UINT wMsg, DWORD_PTR dwParam1, DWORD_PTR dwParam2) DECLSPEC_HIDDEN;
145 UINT            MMDRV_PhysicalFeatures(LPWINE_MLD mld, UINT uMsg, DWORD_PTR dwParam1, DWORD_PTR dwParam2) DECLSPEC_HIDDEN;
146
147 DWORD           MCI_SendCommand(UINT wDevID, UINT16 wMsg, DWORD_PTR dwParam1, DWORD_PTR dwParam2) DECLSPEC_HIDDEN;
148
149 const char*     WINMM_ErrorToString(MMRESULT error) DECLSPEC_HIDDEN;
150
151 void            TIME_MMTimeStop(void) DECLSPEC_HIDDEN;
152
153 MMRESULT WINMM_CheckCallback(DWORD_PTR dwCallback, DWORD fdwOpen, BOOL mixer);
154
155 BOOL WINMM_InitWaveform(void);
156
157 /* Global variables */
158 extern CRITICAL_SECTION WINMM_cs DECLSPEC_HIDDEN;
159 extern HINSTANCE hWinMM32Instance DECLSPEC_HIDDEN;
160 extern HANDLE psLastEvent DECLSPEC_HIDDEN;
161 extern HANDLE psStopEvent DECLSPEC_HIDDEN;
162
163 /* GetDriverFlags() returned bits is not documented (nor the call itself)
164  * Here are Wine only definitions of the bits
165  */
166 #define WINE_GDF_EXIST          0x80000000
167 #define WINE_GDF_EXTERNAL_MASK  0xF0000000
168 #define WINE_GDF_SESSION        0x00000001