- All audio device handles are initialized to -1 and set to -1 when closed.
[wine] / dlls / winmm / winemm.h
1 /* -*- tab-width: 8; c-basic-offset: 4 -*- */
2
3 /*****************************************************************************
4  * Copyright 1998, Luiz Otavio L. Zorzella
5  *           1999, Eric Pouech
6  *
7  * File:      winemm.h
8  * Purpose:   multimedia declarations (internal to WINMM & MMSYSTEM DLLs)
9  *
10  *****************************************************************************
11  */
12
13 #include "mmddk.h"
14
15 typedef DWORD WINAPI (*MessageProc16)(UINT16 wDevID, UINT16 wMsg, DWORD dwUser, DWORD dwParam1, DWORD dwParam2);
16 typedef DWORD WINAPI (*MessageProc32)(UINT wDevID, UINT wMsg, DWORD dwUser, DWORD dwParam1, DWORD dwParam2);
17
18 typedef struct tagWINE_MLD {
19 /* EPP struct tagWINE_MLD*      lpNext; */              /* not used so far */
20        UINT                     uDeviceID;
21        UINT                     type;
22        UINT                     mmdIndex;               /* index to low-level driver in MMDrvs table */
23        DWORD                    dwDriverInstance;       /* this value is driver related, as opposed to
24                                                          * opendesc.dwInstance which is client (callback) related */
25        WORD                     bFrom32;
26        WORD                     dwFlags;
27        DWORD                    dwCallback;
28        DWORD                    dwClientInstance;
29 } WINE_MLD, *LPWINE_MLD;
30
31 typedef struct  {
32        WINE_MLD                 mld;
33 } WINE_WAVE, *LPWINE_WAVE;
34
35 typedef struct {
36        WINE_MLD                 mld;
37        MIDIOPENDESC             mod;                    /* FIXME: should be removed */
38 } WINE_MIDI, *LPWINE_MIDI;
39
40 typedef struct {
41        WINE_MLD                 mld;
42 } WINE_MIXER, *LPWINE_MIXER;
43
44 extern  BOOL            MMDRV_Init(void);
45 extern  UINT            MMDRV_GetNum(UINT);
46 extern  LPWINE_MLD      MMDRV_Alloc(UINT size, UINT type, LPHANDLE hndl, DWORD* dwFlags, 
47                                     DWORD* dwCallback, DWORD* dwInstance, BOOL bFrom32);
48 extern  void            MMDRV_Free(HANDLE hndl, LPWINE_MLD mld);
49 extern  DWORD           MMDRV_Open(LPWINE_MLD mld, UINT wMsg, DWORD dwParam1, DWORD dwParam2);
50 extern  DWORD           MMDRV_Close(LPWINE_MLD mld, UINT wMsg);
51 extern  LPWINE_MLD      MMDRV_Get(HANDLE hndl, UINT type, BOOL bCanBeID);
52 extern  LPWINE_MLD      MMDRV_GetRelated(HANDLE hndl, UINT srcType, BOOL bSrcCanBeID, UINT dstTyped);
53 extern  DWORD           MMDRV_Message(LPWINE_MLD mld, WORD wMsg, DWORD dwParam1, DWORD dwParam2, BOOL bFrom32);
54 extern  UINT            MMDRV_PhysicalFeatures(LPWINE_MLD mld, UINT uMsg, DWORD dwParam1, DWORD dwParam2);
55
56 #define MMDRV_AUX               0
57 #define MMDRV_MIXER             1
58 #define MMDRV_MIDIIN            2
59 #define MMDRV_MIDIOUT           3
60 #define MMDRV_WAVEIN            4
61 #define MMDRV_WAVEOUT           5
62 #define MMDRV_MAX               6
63
64 #define WINE_MMTHREAD_CREATED   0x4153494C      /* "BSIL" */
65 #define WINE_MMTHREAD_DELETED   0xDEADDEAD
66
67 typedef struct {
68        DWORD                    dwSignature;            /* 00 "BSIL" when ok, 0xDEADDEAD when being deleted */
69        DWORD                    dwCounter;              /* 04 > 1 when in mmThread functions */
70        HANDLE                   hThread;                /* 08 hThread */
71        DWORD                    dwThreadID;             /* 0C */
72        FARPROC16                fpThread;               /* 10 address of thread proc (segptr or lin depending on dwFlags) */
73        DWORD                    dwThreadPmt;            /* 14 parameter to be passed upon thread creation to fpThread */
74        DWORD                    dwSignalCount;          /* 18 counter used for signaling */
75        HANDLE                   hEvent;                 /* 1C event */
76        HANDLE                   hVxD;                   /* 20 return from OpenVxDHandle */
77        DWORD                    dwStatus;               /* 24 0x00, 0x10, 0x20, 0x30 */
78        DWORD                    dwFlags;                /* 28 dwFlags upon creation */
79        HANDLE16                 hTask;                  /* 2C handle to created task */
80 } WINE_MMTHREAD;
81
82 typedef struct tagWINE_MCIDRIVER {
83         UINT                    wDeviceID;
84         UINT                    wType;
85         LPSTR                   lpstrElementName;
86         LPSTR                   lpstrDeviceType;
87         LPSTR                   lpstrAlias;
88         HDRVR                   hDrv;
89         DRIVERPROC16            driverProc;
90         DWORD                   dwPrivate;
91         YIELDPROC               lpfnYieldProc;
92         DWORD                   dwYieldData;
93         BOOL                    bIs32;
94         HTASK16                 hCreatorTask;
95         UINT                    uTypeCmdTable;
96         UINT                    uSpecificCmdTable;
97         struct tagWINE_MCIDRIVER*lpNext;
98 } WINE_MCIDRIVER, *LPWINE_MCIDRIVER;
99
100 #define WINE_TIMER_IS32 0x80
101
102 typedef struct tagWINE_TIMERENTRY {
103     UINT                        wDelay;
104     UINT                        wResol;
105     FARPROC16                   lpFunc;
106     DWORD                       dwUser;
107     UINT16                      wFlags;
108     UINT16                      wTimerID;
109     UINT                        uCurTime;
110     struct tagWINE_TIMERENTRY*  lpNext;
111 } WINE_TIMERENTRY, *LPWINE_TIMERENTRY;
112
113 typedef struct tagWINE_MMIO {
114     MMIOINFO                    info;
115     struct IOProcList*          ioProc;
116     BOOL                        bTmpIOProc;
117     HANDLE                      hMem;
118     SEGPTR                      buffer16;
119     struct tagWINE_MMIO*        lpNext;
120     BOOL                        bBufferLoaded;
121 } WINE_MMIO, *LPWINE_MMIO;
122
123 typedef struct tagWINE_MM_IDATA {
124     /* iData reference */
125     DWORD                       dwThisProcess;
126     struct tagWINE_MM_IDATA*    lpNextIData;
127     /* winmm part */
128     HANDLE                      hWinMM32Instance;
129     HANDLE                      hWinMM16Instance;
130     HANDLE                      h16Module32;
131     CRITICAL_SECTION            cs;
132     /* mm timer part */
133     HANDLE                      hMMTimer;
134     DWORD                       mmSysTimeMS;
135     LPWINE_TIMERENTRY           lpTimerList;
136     int                         nSizeLpTimers;
137     LPWINE_TIMERENTRY           lpTimers;
138     /* mci part */
139     LPWINE_MCIDRIVER            lpMciDrvs;
140     /* low level drivers (unused yet) */
141     /* LPWINE_WAVE              lpWave; */
142     /* LPWINE_MIDI              lpMidi; */
143     /* LPWINE_MIXER             lpMixer; */
144     /* mmio part */
145     LPWINE_MMIO                 lpMMIO;
146 } WINE_MM_IDATA, *LPWINE_MM_IDATA;
147
148 /* function prototypes */
149
150 typedef LONG                    (*MCIPROC16)(DWORD, HDRVR16, WORD, DWORD, DWORD);
151 typedef LONG                    (*MCIPROC)(DWORD, HDRVR, DWORD, DWORD, DWORD);
152
153 extern LPWINE_MCIDRIVER         MCI_GetDriver(UINT16 uDevID);
154 extern UINT                     MCI_GetDriverFromString(LPCSTR str);
155 extern DWORD                    MCI_WriteString(LPSTR lpDstStr, DWORD dstSize, LPCSTR lpSrcStr);
156 extern const char*              MCI_MessageToString(UINT16 wMsg);
157
158 extern UINT             WINAPI  MCI_DefYieldProc(MCIDEVICEID wDevID, DWORD data);
159
160 extern LRESULT                  MCI_CleanUp(LRESULT dwRet, UINT wMsg, DWORD dwParam2, BOOL bIs32);
161
162 extern DWORD                    MCI_SendCommand(UINT wDevID, UINT16 wMsg, DWORD dwParam1, DWORD dwParam2, BOOL bFrom32);
163 extern DWORD                    MCI_SendCommandFrom32(UINT wDevID, UINT16 wMsg, DWORD dwParam1, DWORD dwParam2);
164 extern DWORD                    MCI_SendCommandFrom16(UINT wDevID, UINT16 wMsg, DWORD dwParam1, DWORD dwParam2);
165 extern DWORD                    MCI_SendCommandAsync(UINT wDevID, UINT wMsg, DWORD dwParam1, DWORD dwParam2, UINT size);
166
167 void            CALLBACK        WINE_mmThreadEntryPoint(DWORD _pmt);
168
169 void                            MMSYSTEM_MMTIME16to32(LPMMTIME mmt32, const MMTIME16* mmt16);
170 void                            MMSYSTEM_MMTIME32to16(LPMMTIME16 mmt16, const MMTIME* mmt32); 
171
172 BOOL                            MULTIMEDIA_MciInit(void);
173 LPWINE_MM_IDATA                 MULTIMEDIA_GetIData(void);
174