source: trunk/src/msacm32/internal.cpp@ 1687

Last change on this file since 1687 was 1607, checked in by sandervl, 26 years ago

Jens Weissner's update

File size: 4.4 KB
Line 
1/* -*- tab-width: 8; c-basic-offset: 4 -*- */
2
3/*
4 * MSACM32 library
5 *
6 * Copyright 1998 Patrik Stridvall
7 * 1999 Eric Pouech
8 */
9
10#include <os2win.h>
11#include <string.h>
12
13#include "winbase.h"
14#include "winuser.h"
15#include "winerror.h"
16#include "driver.h"
17#include "heapstring.h"
18#include "mmsystem.h"
19#include "msacm.h"
20#include "msacmdrv.h"
21#include "wineacm.h"
22#include "debugtools.h"
23
24DEFAULT_DEBUG_CHANNEL(msacm)
25
26/**********************************************************************/
27
28HANDLE MSACM_hHeap = (HANDLE) NULL;
29PWINE_ACMDRIVERID MSACM_pFirstACMDriverID = NULL;
30PWINE_ACMDRIVERID MSACM_pLastACMDriverID = NULL;
31
32/***********************************************************************
33 * MSACM_RegisterDriver32()
34 */
35PWINE_ACMDRIVERID MSACM_RegisterDriver(LPSTR pszDriverAlias, LPSTR pszFileName,
36 HINSTANCE hinstModule)
37{
38 PWINE_ACMDRIVERID padid;
39
40 TRACE("('%s', '%s', 0x%08x)\n", pszDriverAlias, pszFileName, hinstModule);
41
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->pACMDriver = NULL;
48 padid->pNextACMDriverID = NULL;
49 padid->pPreviousACMDriverID = MSACM_pLastACMDriverID;
50 if (MSACM_pLastACMDriverID)
51 MSACM_pLastACMDriverID->pNextACMDriverID = padid;
52 MSACM_pLastACMDriverID = padid;
53 if (!MSACM_pFirstACMDriverID)
54 MSACM_pFirstACMDriverID = padid;
55
56 return padid;
57}
58
59/***********************************************************************
60 * MSACM_RegisterAllDrivers32()
61 */
62void MSACM_RegisterAllDrivers(void)
63{
64 LPSTR pszBuffer;
65 DWORD dwBufferLength;
66
67 /* FIXME
68 * What if the user edits system.ini while the program is running?
69 * Does Windows handle that?
70 */
71 if (MSACM_pFirstACMDriverID)
72 return;
73
74 /* FIXME: Do not work! How do I determine the section length? */
75 dwBufferLength = 1024;
76/* EPP GetPrivateProfileSectionA("drivers32", NULL, 0, "system.ini"); */
77
78 pszBuffer = (LPSTR) HeapAlloc(MSACM_hHeap, 0, dwBufferLength);
79 if (GetPrivateProfileSectionA("drivers32", pszBuffer, dwBufferLength, "system.ini")) {
80 char* s = pszBuffer;
81 while (*s) {
82 if (!lstrncmpiA("MSACM.", s, 6)) {
83 char *s2 = s;
84 while (*s2 != '\0' && *s2 != '=') s2++;
85 if (*s2) {
86 *s2++ = '\0';
87 MSACM_RegisterDriver(s, s2, 0);
88 }
89 }
90 s += lstrlenA(s) + 1; /* Either next char or \0 */
91 }
92 }
93
94 HeapFree(MSACM_hHeap, 0, pszBuffer);
95}
96
97/***********************************************************************
98 * MSACM_UnregisterDriver32()
99 */
100PWINE_ACMDRIVERID MSACM_UnregisterDriver(PWINE_ACMDRIVERID p)
101{
102 PWINE_ACMDRIVERID pNextACMDriverID;
103
104 if (p->pACMDriver)
105 acmDriverClose((HACMDRIVER) p->pACMDriver, 0);
106
107 if (p->pszDriverAlias)
108 HeapFree(MSACM_hHeap, 0, p->pszDriverAlias);
109 if (p->pszFileName)
110 HeapFree(MSACM_hHeap, 0, p->pszFileName);
111
112 if (p == MSACM_pFirstACMDriverID)
113 MSACM_pFirstACMDriverID = p->pNextACMDriverID;
114 if (p == MSACM_pLastACMDriverID)
115 MSACM_pLastACMDriverID = p->pPreviousACMDriverID;
116
117 if (p->pPreviousACMDriverID)
118 p->pPreviousACMDriverID->pNextACMDriverID = p->pNextACMDriverID;
119 if (p->pNextACMDriverID)
120 p->pNextACMDriverID->pPreviousACMDriverID = p->pPreviousACMDriverID;
121
122 pNextACMDriverID = p->pNextACMDriverID;
123
124 HeapFree(MSACM_hHeap, 0, p);
125
126 return pNextACMDriverID;
127}
128
129/***********************************************************************
130 * MSACM_UnregisterAllDrivers32()
131 * FIXME
132 * Where should this function be called?
133 */
134void MSACM_UnregisterAllDrivers(void)
135{
136 PWINE_ACMDRIVERID p;
137
138 for (p = MSACM_pFirstACMDriverID; p; p = MSACM_UnregisterDriver(p));
139}
140
141/***********************************************************************
142 * MSACM_GetDriverID32()
143 */
144PWINE_ACMDRIVERID MSACM_GetDriverID(HACMDRIVERID hDriverID)
145{
146 return (PWINE_ACMDRIVERID)hDriverID;
147}
148
149/***********************************************************************
150 * MSACM_GetDriver32()
151 */
152PWINE_ACMDRIVER MSACM_GetDriver(HACMDRIVER hDriver)
153{
154 return (PWINE_ACMDRIVER)hDriver;
155}
156
157/***********************************************************************
158 * MSACM_GetObj32()
159 */
160PWINE_ACMOBJ MSACM_GetObj(HACMOBJ hObj)
161{
162 return (PWINE_ACMOBJ)hObj;
163}
164
165
Note: See TracBrowser for help on using the repository browser.