Add \n to FIXME call in acmGetVersion to prevent overflowing buffer in
[wine] / dlls / msacm / msacm32_main.c
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 "winbase.h"
11 #include "winerror.h"
12 #include "windef.h"
13 #include "debugtools.h"
14 #include "msacm.h"
15 #include "msacmdrv.h"
16 #include "wineacm.h"
17
18 DEFAULT_DEBUG_CHANNEL(msacm);
19         
20 /**********************************************************************/
21         
22 HINSTANCE       MSACM_hInstance32 = 0;
23
24 /***********************************************************************
25  *           MSACM_LibMain (MSACM32.init) 
26  */
27 BOOL WINAPI MSACM32_LibMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpvReserved)
28 {
29     TRACE("0x%x 0x%lx %p\n", hInstDLL, fdwReason, lpvReserved);
30
31     switch (fdwReason) {
32     case DLL_PROCESS_ATTACH:
33         MSACM_hHeap = HeapCreate(0, 0x10000, 0);
34         MSACM_hInstance32 = hInstDLL;
35         MSACM_RegisterAllDrivers();
36         break;
37     case DLL_PROCESS_DETACH:
38         MSACM_UnregisterAllDrivers();
39         HeapDestroy(MSACM_hHeap);
40         MSACM_hHeap = (HANDLE) NULL;
41         MSACM_hInstance32 = (HINSTANCE)NULL;
42         break;
43     case DLL_THREAD_ATTACH:
44         break;
45     case DLL_THREAD_DETACH:
46         break;
47     default:
48         break;
49     }
50     return TRUE;
51 }
52
53 /***********************************************************************
54  *           XRegThunkEntry (MSACM32.1)
55  * FIXME
56  *   No documentation found.
57  */
58
59 /***********************************************************************
60  *           acmGetVersion (MSACM32.34)
61  */
62 DWORD WINAPI acmGetVersion(void)
63 {
64     OSVERSIONINFOA version;
65     GetVersionExA( &version );
66     switch(version.dwPlatformId)
67     {
68     case VER_PLATFORM_WIN32_NT:
69         return 0x04000565; /* 4.0.1381 */
70     default:
71         FIXME("%ld not supported\n",version.dwPlatformId);
72     case VER_PLATFORM_WIN32_WINDOWS:
73         return 0x04000000; /* 4.0.0 */
74   }
75 }
76
77 /***********************************************************************
78  *           acmMessage32 (MSACM32.35)
79  * FIXME
80  *   No documentation found.
81  */
82
83 /***********************************************************************
84  *           acmMetrics (MSACM32.36)
85  */
86 MMRESULT WINAPI acmMetrics(HACMOBJ hao, UINT uMetric, LPVOID pMetric)
87 {
88     PWINE_ACMOBJ        pao = MSACM_GetObj(hao, WINE_ACMOBJ_DONTCARE);
89     BOOL                bLocal = TRUE;
90     PWINE_ACMDRIVERID   padid;
91     DWORD               val = 0;
92     MMRESULT            mmr = MMSYSERR_NOERROR;
93
94     TRACE("(0x%08x, %d, %p);\n", hao, uMetric, pMetric);
95     
96     switch (uMetric) {
97     case ACM_METRIC_COUNT_DRIVERS:
98         bLocal = FALSE;
99         /* fall thru */
100     case ACM_METRIC_COUNT_LOCAL_DRIVERS:
101         if (!pao)
102             return MMSYSERR_INVALHANDLE;
103         for (padid = MSACM_pFirstACMDriverID; padid; padid = padid->pNextACMDriverID)
104             if (padid->bEnabled /* && (local(padid) || !bLocal) */)
105                 val++;
106         *(LPDWORD)pMetric = val;
107         break;
108
109     case ACM_METRIC_COUNT_CODECS:
110         if (!pao)
111             return MMSYSERR_INVALHANDLE;
112         bLocal = FALSE;
113         /* fall thru */
114     case ACM_METRIC_COUNT_LOCAL_CODECS:
115         /* FIXME: don't know how to differentiate codec, converters & filters yet */
116         for (padid = MSACM_pFirstACMDriverID; padid; padid = padid->pNextACMDriverID)
117             if (padid->bEnabled /* && (local(padid) || !bLocal) */)
118                 val++;
119         *(LPDWORD)pMetric = val;
120         break;
121
122     case ACM_METRIC_COUNT_CONVERTERS:
123         bLocal = FALSE;
124         /* fall thru */
125     case ACM_METRIC_COUNT_LOCAL_CONVERTERS:
126         /* FIXME: don't know how to differentiate codec, converters & filters yet */
127         for (padid = MSACM_pFirstACMDriverID; padid; padid = padid->pNextACMDriverID)
128             if (padid->bEnabled /* && (local(padid) || !bLocal) */)
129                 val++;
130         *(LPDWORD)pMetric = val;
131         break;
132
133     case ACM_METRIC_COUNT_FILTERS:
134         bLocal = FALSE;
135         /* fall thru */
136     case ACM_METRIC_COUNT_LOCAL_FILTERS:
137         /* FIXME: don't know how to differentiate codec, converters & filters yet */
138         for (padid = MSACM_pFirstACMDriverID; padid; padid = padid->pNextACMDriverID)
139             if (padid->bEnabled /* && (local(padid) || !bLocal) */)
140                 val++;
141         *(LPDWORD)pMetric = val;
142         break;
143
144     case ACM_METRIC_COUNT_DISABLED:
145         bLocal = FALSE;
146         /* fall thru */
147     case ACM_METRIC_COUNT_LOCAL_DISABLED:
148         if (!pao)
149             return MMSYSERR_INVALHANDLE;  
150         for (padid = MSACM_pFirstACMDriverID; padid; padid = padid->pNextACMDriverID)
151             if (!padid->bEnabled /* && (local(padid) || !bLocal) */)
152                 val++;
153         *(LPDWORD)pMetric = val;
154         break;
155     
156     case ACM_METRIC_MAX_SIZE_FORMAT:
157         {
158             ACMFORMATTAGDETAILSW        aftd;
159
160             aftd.cbStruct = sizeof(aftd);
161             aftd.dwFormatTag = WAVE_FORMAT_UNKNOWN;
162
163             if (hao == (HACMOBJ)NULL) {
164                 mmr = acmFormatTagDetailsW((HACMDRIVER)NULL, &aftd, ACM_FORMATTAGDETAILSF_LARGESTSIZE);
165             } else if (MSACM_GetObj(hao, WINE_ACMOBJ_DRIVER)) {
166                 mmr = acmFormatTagDetailsW((HACMDRIVER)hao, &aftd, ACM_FORMATTAGDETAILSF_LARGESTSIZE);
167             } else if (MSACM_GetObj(hao, WINE_ACMOBJ_DRIVERID)) {
168                 HACMDRIVER      had;
169                 
170                 if (acmDriverOpen(&had, (HACMDRIVERID)hao, 0) == 0) {
171                     mmr = acmFormatTagDetailsW((HACMDRIVER)hao, &aftd, ACM_FORMATTAGDETAILSF_LARGESTSIZE);
172                     acmDriverClose(had, 0);
173                 }
174             } else {
175                 mmr = MMSYSERR_INVALHANDLE;
176             }
177             if (mmr == MMSYSERR_NOERROR) *(LPDWORD)pMetric = aftd.cbFormatSize;
178         }
179         break;
180
181     case ACM_METRIC_COUNT_HARDWARE:
182     case ACM_METRIC_HARDWARE_WAVE_INPUT:
183     case ACM_METRIC_HARDWARE_WAVE_OUTPUT:
184     case ACM_METRIC_MAX_SIZE_FILTER:
185     case ACM_METRIC_DRIVER_SUPPORT:
186     case ACM_METRIC_DRIVER_PRIORITY:
187     default:
188         FIXME("(0x%08x, %d, %p): stub\n", hao, uMetric, pMetric);
189         mmr = MMSYSERR_NOTSUPPORTED;
190     }
191     return mmr;
192 }