1 /* -*- tab-width: 8; c-basic-offset: 4 -*- */
6 * Copyright 1998 Patrik Stridvall
23 #include "debugtools.h"
25 DEFAULT_DEBUG_CHANNEL(msacm
)
27 /**********************************************************************/
29 HANDLE MSACM_hHeap
= (HANDLE
) NULL
;
30 PWINE_ACMDRIVERID MSACM_pFirstACMDriverID
= NULL
;
31 PWINE_ACMDRIVERID MSACM_pLastACMDriverID
= NULL
;
33 /***********************************************************************
34 * MSACM_RegisterDriver32()
36 PWINE_ACMDRIVERID
MSACM_RegisterDriver(LPSTR pszDriverAlias
, LPSTR pszFileName
,
37 HINSTANCE hinstModule
)
39 PWINE_ACMDRIVERID padid
;
41 TRACE("('%s', '%s', 0x%08x)\n", pszDriverAlias
, pszFileName
, hinstModule
);
43 padid
= (PWINE_ACMDRIVERID
) HeapAlloc(MSACM_hHeap
, 0, sizeof(WINE_ACMDRIVERID
));
44 padid
->pszDriverAlias
= HEAP_strdupA(MSACM_hHeap
, 0, pszDriverAlias
);
45 padid
->pszFileName
= HEAP_strdupA(MSACM_hHeap
, 0, pszFileName
);
46 padid
->hInstModule
= hinstModule
;
47 padid
->bEnabled
= TRUE
;
48 padid
->pACMDriverList
= NULL
;
49 padid
->pNextACMDriverID
= NULL
;
50 padid
->pPrevACMDriverID
= MSACM_pLastACMDriverID
;
51 if (MSACM_pLastACMDriverID
)
52 MSACM_pLastACMDriverID
->pNextACMDriverID
= padid
;
53 MSACM_pLastACMDriverID
= padid
;
54 if (!MSACM_pFirstACMDriverID
)
55 MSACM_pFirstACMDriverID
= padid
;
60 /***********************************************************************
61 * MSACM_RegisterAllDrivers32()
63 void MSACM_RegisterAllDrivers(void)
69 * What if the user edits system.ini while the program is running?
70 * Does Windows handle that?
72 if (MSACM_pFirstACMDriverID
)
75 /* FIXME: Do not work! How do I determine the section length? */
76 dwBufferLength
= 1024;
77 /* EPP GetPrivateProfileSectionA("drivers32", NULL, 0, "system.ini"); */
79 pszBuffer
= (LPSTR
) HeapAlloc(MSACM_hHeap
, 0, dwBufferLength
);
80 if (GetPrivateProfileSectionA("drivers32", pszBuffer
, dwBufferLength
, "system.ini")) {
83 if (!lstrncmpiA("MSACM.", s
, 6)) {
85 while (*s2
!= '\0' && *s2
!= '=') s2
++;
88 MSACM_RegisterDriver(s
, s2
, 0);
91 s
+= lstrlenA(s
) + 1; /* Either next char or \0 */
95 HeapFree(MSACM_hHeap
, 0, pszBuffer
);
98 /***********************************************************************
99 * MSACM_UnregisterDriver32()
101 PWINE_ACMDRIVERID
MSACM_UnregisterDriver(PWINE_ACMDRIVERID p
)
103 PWINE_ACMDRIVERID pNextACMDriverID
;
105 while (p
->pACMDriverList
)
106 acmDriverClose((HACMDRIVER
) p
->pACMDriverList
, 0);
108 if (p
->pszDriverAlias
)
109 HeapFree(MSACM_hHeap
, 0, p
->pszDriverAlias
);
111 HeapFree(MSACM_hHeap
, 0, p
->pszFileName
);
113 if (p
== MSACM_pFirstACMDriverID
)
114 MSACM_pFirstACMDriverID
= p
->pNextACMDriverID
;
115 if (p
== MSACM_pLastACMDriverID
)
116 MSACM_pLastACMDriverID
= p
->pPrevACMDriverID
;
118 if (p
->pPrevACMDriverID
)
119 p
->pPrevACMDriverID
->pNextACMDriverID
= p
->pNextACMDriverID
;
120 if (p
->pNextACMDriverID
)
121 p
->pNextACMDriverID
->pPrevACMDriverID
= p
->pPrevACMDriverID
;
123 pNextACMDriverID
= p
->pNextACMDriverID
;
125 HeapFree(MSACM_hHeap
, 0, p
);
127 return pNextACMDriverID
;
130 /***********************************************************************
131 * MSACM_UnregisterAllDrivers32()
133 * Where should this function be called?
135 void MSACM_UnregisterAllDrivers(void)
139 for (p
= MSACM_pFirstACMDriverID
; p
; p
= MSACM_UnregisterDriver(p
));
142 /***********************************************************************
143 * MSACM_GetDriverID32()
145 PWINE_ACMDRIVERID
MSACM_GetDriverID(HACMDRIVERID hDriverID
)
147 return (PWINE_ACMDRIVERID
)hDriverID
;
150 /***********************************************************************
151 * MSACM_GetDriver32()
153 PWINE_ACMDRIVER
MSACM_GetDriver(HACMDRIVER hDriver
)
155 return (PWINE_ACMDRIVER
)hDriver
;
158 /***********************************************************************
161 PWINE_ACMOBJ
MSACM_GetObj(HACMOBJ hObj
)
163 return (PWINE_ACMOBJ
)hObj
;