Started the implementation of MSACM.DLL and MSACM32.DLL.
[wine/multimedia.git] / dlls / msacm32 / internal.c
blob3c5bc26b66280f1b01548005fd74499d30a4ded5
1 /*
2 * MSACM32 library
4 * Copyright 1998 Patrik Stridvall
5 */
7 #include "windows.h"
8 #include "winerror.h"
9 #include "wintypes.h"
10 #include "debug.h"
11 #include "driver.h"
12 #include "heap.h"
13 #include "mmsystem.h"
14 #include "msacm.h"
15 #include "msacmdrv.h"
17 /**********************************************************************/
19 HANDLE32 MSACM_hHeap32 = (HANDLE32) NULL;
20 PWINE_ACMDRIVERID32 MSACM_pFirstACMDriverID32 = NULL;
21 PWINE_ACMDRIVERID32 MSACM_pLastACMDriverID32 = NULL;
23 /***********************************************************************
24 * MSACM_RegisterDriver32()
26 PWINE_ACMDRIVERID32 MSACM_RegisterDriver32(
27 LPSTR pszDriverAlias, LPSTR pszFileName,
28 PWINE_ACMLOCALDRIVER32 pLocalDriver)
30 PWINE_ACMDRIVERID32 padid;
31 padid = (PWINE_ACMDRIVERID32) HeapAlloc(
32 MSACM_hHeap32, 0, sizeof(WINE_ACMDRIVERID32)
34 padid->pszDriverAlias =
35 HEAP_strdupA(MSACM_hHeap32, 0, pszDriverAlias);
36 padid->pszFileName =
37 HEAP_strdupA(MSACM_hHeap32, 0, pszFileName);
38 padid->pACMLocalDriver = pLocalDriver;
39 padid->bEnabled = TRUE;
40 padid->pACMDriver = NULL;
41 padid->pNextACMDriverID = NULL;
42 padid->pPreviousACMDriverID =
43 MSACM_pLastACMDriverID32;
44 MSACM_pLastACMDriverID32 = padid;
45 if(!MSACM_pFirstACMDriverID32)
46 MSACM_pFirstACMDriverID32 = padid;
48 return padid;
51 /***********************************************************************
52 * MSACM_RegisterAllDrivers32()
54 void MSACM_RegisterAllDrivers32()
56 PWINE_ACMBUILTINDRIVER32 pbd;
57 LPSTR pszBuffer;
58 DWORD dwBufferLength;
60 /* FIXME
61 * What if the user edits system.ini while the program is running?
62 * Does Windows handle that?
64 if(!MSACM_pFirstACMDriverID32)
65 return;
67 /* FIXME: Do not work! How do I determine the section length? */
68 dwBufferLength =
69 GetPrivateProfileSection32A("drivers32", NULL, 0, "system.ini");
71 pszBuffer = (LPSTR) HeapAlloc(
72 MSACM_hHeap32, 0, dwBufferLength
74 if(GetPrivateProfileSection32A(
75 "drivers32", pszBuffer, dwBufferLength, "system.ini"))
77 char *s = pszBuffer;
78 while(*s)
80 if(!lstrncmpi32A("MSACM.", s, 6))
82 char *s2 = s;
83 while(*s2 != '\0' && *s2 != '=') s2++;
84 if(*s2)
86 *s2++='\0';
87 MSACM_RegisterDriver32(s, s2, NULL);
90 s += lstrlen32A(s) + 1; /* Either next char or \0 */
94 /* FIXME
95 * Check if any of the builtin driver was added
96 * when the external drivers was.
99 pbd = MSACM_BuiltinDrivers32;
100 while(pbd->pszDriverAlias)
102 PWINE_ACMLOCALDRIVER32 pld;
103 pld = HeapAlloc(MSACM_hHeap32, 0, sizeof(WINE_ACMLOCALDRIVER32));
104 pld->pfnDriverProc = pbd->pfnDriverProc;
105 MSACM_RegisterDriver32(pbd->pszDriverAlias, NULL, pld);
106 pbd++;
108 HeapFree(MSACM_hHeap32, 0, pszBuffer);
111 /***********************************************************************
112 * MSACM_UnregisterDriver32()
114 PWINE_ACMDRIVERID32 MSACM_UnregisterDriver32(PWINE_ACMDRIVERID32 p)
116 PWINE_ACMDRIVERID32 pNextACMDriverID;
118 if(p->pACMDriver)
119 acmDriverClose32((HACMDRIVER32) p->pACMDriver, 0);
121 if(p->pszDriverAlias)
122 HeapFree(MSACM_hHeap32, 0, p->pszDriverAlias);
123 if(p->pszFileName)
124 HeapFree(MSACM_hHeap32, 0, p->pszFileName);
125 if(p->pACMLocalDriver)
126 HeapFree(MSACM_hHeap32, 0, p->pACMLocalDriver);
128 if(p->pPreviousACMDriverID)
129 p->pPreviousACMDriverID->pNextACMDriverID = p->pNextACMDriverID;
130 if(p->pNextACMDriverID)
131 p->pNextACMDriverID->pPreviousACMDriverID = p->pPreviousACMDriverID;
133 pNextACMDriverID = p->pNextACMDriverID;
135 HeapFree(MSACM_hHeap32, 0, p);
137 return pNextACMDriverID;
140 /***********************************************************************
141 * MSACM_UnregisterAllDrivers32()
142 * FIXME
143 * Where should this function be called?
145 void MSACM_UnregisterAllDrivers32()
147 PWINE_ACMDRIVERID32 p = MSACM_pFirstACMDriverID32;
148 while(p) p = MSACM_UnregisterDriver32(p);
151 /***********************************************************************
152 * MSACM_GetDriverID32()
154 PWINE_ACMDRIVERID32 MSACM_GetDriverID32(HACMDRIVERID32 hDriverID)
156 return (PWINE_ACMDRIVERID32) hDriverID;
159 /***********************************************************************
160 * MSACM_GetDriver32()
162 PWINE_ACMDRIVER32 MSACM_GetDriver32(HACMDRIVER32 hDriver)
164 return (PWINE_ACMDRIVER32) hDriver;
167 /***********************************************************************
168 * MSACM_GetObj32()
170 PWINE_ACMOBJ32 MSACM_GetObj32(HACMOBJ32 hObj)
172 return (PWINE_ACMOBJ32) hObj;
175 /***********************************************************************
176 * MSACM_OpenDriverProc32
177 * FIXME
178 * This function should be integrated with OpenDriver,
179 * renamed and moved there.
181 HDRVR32 MSACM_OpenDriverProc32(DRIVERPROC32 pfnDriverProc)
183 LPDRIVERITEM32A pDrvr;
185 /* FIXME: This is a very bad solution */
186 pDrvr = (LPDRIVERITEM32A) HeapAlloc(MSACM_hHeap32, HEAP_ZERO_MEMORY, sizeof(DRIVERITEM32A));
187 pDrvr->count = 1;
188 pDrvr->driverproc = pfnDriverProc;
190 /* FIXME: Send DRV_OPEN among others to DriverProc */
192 return (HDRVR32) pDrvr;