1 /* -*- tab-width: 8; c-basic-offset: 4 -*- */
6 * Copyright 1998 Patrik Stridvall
22 #include "debugtools.h"
24 DEFAULT_DEBUG_CHANNEL(msacm
)
26 /**********************************************************************/
28 HANDLE MSACM_hHeap
= (HANDLE
) NULL
;
29 PWINE_ACMDRIVERID MSACM_pFirstACMDriverID
= NULL
;
30 PWINE_ACMDRIVERID MSACM_pLastACMDriverID
= NULL
;
32 /***********************************************************************
33 * MSACM_RegisterDriver32()
35 PWINE_ACMDRIVERID
MSACM_RegisterDriver(LPSTR pszDriverAlias
, LPSTR pszFileName
,
36 HINSTANCE hinstModule
)
38 PWINE_ACMDRIVERID padid
;
40 TRACE("('%s', '%s', 0x%08x)\n", pszDriverAlias
, pszFileName
, hinstModule
);
42 padid
= (PWINE_ACMDRIVERID
) HeapAlloc(MSACM_hHeap
, 0, sizeof(WINE_ACMDRIVERID
));
43 padid
->pszDriverAlias
= HEAP_strdupA(MSACM_hHeap
, 0, pszDriverAlias
);
44 padid
->pszFileName
= HEAP_strdupA(MSACM_hHeap
, 0, pszFileName
);
45 padid
->hInstModule
= hinstModule
;
46 padid
->bEnabled
= TRUE
;
47 padid
->pACMDriverList
= NULL
;
48 padid
->pNextACMDriverID
= NULL
;
49 padid
->pPrevACMDriverID
= MSACM_pLastACMDriverID
;
50 if (MSACM_pLastACMDriverID
)
51 MSACM_pLastACMDriverID
->pNextACMDriverID
= padid
;
52 MSACM_pLastACMDriverID
= padid
;
53 if (!MSACM_pFirstACMDriverID
)
54 MSACM_pFirstACMDriverID
= padid
;
59 /***********************************************************************
60 * MSACM_RegisterAllDrivers32()
62 void MSACM_RegisterAllDrivers(void)
68 * What if the user edits system.ini while the program is running?
69 * Does Windows handle that?
71 if (MSACM_pFirstACMDriverID
)
74 /* FIXME: Do not work! How do I determine the section length? */
75 dwBufferLength
= 1024;
76 /* EPP GetPrivateProfileSectionA("drivers32", NULL, 0, "system.ini"); */
78 pszBuffer
= (LPSTR
) HeapAlloc(MSACM_hHeap
, 0, dwBufferLength
);
79 if (GetPrivateProfileSectionA("drivers32", pszBuffer
, dwBufferLength
, "system.ini")) {
82 if (!lstrncmpiA("MSACM.", s
, 6)) {
84 while (*s2
!= '\0' && *s2
!= '=') s2
++;
87 MSACM_RegisterDriver(s
, s2
, 0);
90 s
+= strlen(s
) + 1; /* Either next char or \0 */
94 HeapFree(MSACM_hHeap
, 0, pszBuffer
);
97 /***********************************************************************
98 * MSACM_UnregisterDriver32()
100 PWINE_ACMDRIVERID
MSACM_UnregisterDriver(PWINE_ACMDRIVERID p
)
102 PWINE_ACMDRIVERID pNextACMDriverID
;
104 while (p
->pACMDriverList
)
105 acmDriverClose((HACMDRIVER
) p
->pACMDriverList
, 0);
107 if (p
->pszDriverAlias
)
108 HeapFree(MSACM_hHeap
, 0, p
->pszDriverAlias
);
110 HeapFree(MSACM_hHeap
, 0, p
->pszFileName
);
112 if (p
== MSACM_pFirstACMDriverID
)
113 MSACM_pFirstACMDriverID
= p
->pNextACMDriverID
;
114 if (p
== MSACM_pLastACMDriverID
)
115 MSACM_pLastACMDriverID
= p
->pPrevACMDriverID
;
117 if (p
->pPrevACMDriverID
)
118 p
->pPrevACMDriverID
->pNextACMDriverID
= p
->pNextACMDriverID
;
119 if (p
->pNextACMDriverID
)
120 p
->pNextACMDriverID
->pPrevACMDriverID
= p
->pPrevACMDriverID
;
122 pNextACMDriverID
= p
->pNextACMDriverID
;
124 HeapFree(MSACM_hHeap
, 0, p
);
126 return pNextACMDriverID
;
129 /***********************************************************************
130 * MSACM_UnregisterAllDrivers32()
132 * Where should this function be called?
134 void MSACM_UnregisterAllDrivers(void)
138 for (p
= MSACM_pFirstACMDriverID
; p
; p
= MSACM_UnregisterDriver(p
));
141 /***********************************************************************
142 * MSACM_GetDriverID32()
144 PWINE_ACMDRIVERID
MSACM_GetDriverID(HACMDRIVERID hDriverID
)
146 return (PWINE_ACMDRIVERID
)hDriverID
;
149 /***********************************************************************
150 * MSACM_GetDriver32()
152 PWINE_ACMDRIVER
MSACM_GetDriver(HACMDRIVER hDriver
)
154 return (PWINE_ACMDRIVER
)hDriver
;
157 /***********************************************************************
160 PWINE_ACMOBJ
MSACM_GetObj(HACMOBJ hObj
)
162 return (PWINE_ACMOBJ
)hObj
;