msacm32_main.c 8.01 KB
Newer Older
1 2
/* -*- tab-width: 8; c-basic-offset: 4 -*- */

3 4 5 6
/*
 *      MSACM32 library
 *
 *      Copyright 1998  Patrik Stridvall
7
 *		  1999	Eric Pouech
8 9 10 11 12 13 14 15 16 17 18 19 20
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
21
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 23
 */

24 25 26
#include <stdarg.h>

#include "windef.h"
27
#include "winbase.h"
28
#include "wine/debug.h"
29
#include "mmsystem.h"
30
#define NOBITMAP
31
#include "mmreg.h"
32 33
#include "msacm.h"
#include "msacmdrv.h"
34
#include "wineacm.h"
35

36
WINE_DEFAULT_DEBUG_CHANNEL(msacm);
37

38
/**********************************************************************/
39

40
HINSTANCE	MSACM_hInstance32 = 0;
41 42

/***********************************************************************
43
 *           DllMain (MSACM32.init)
44
 */
45
BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpvReserved)
46
{
47
    TRACE("%p 0x%x %p\n", hInstDLL, fdwReason, lpvReserved);
48 49

    switch (fdwReason) {
50
    case DLL_PROCESS_ATTACH:
51
        DisableThreadLibraryCalls(hInstDLL);
52 53 54
        MSACM_hHeap = HeapCreate(0, 0x10000, 0);
        MSACM_hInstance32 = hInstDLL;
        MSACM_RegisterAllDrivers();
55
	break;
56
    case DLL_PROCESS_DETACH:
57 58
        MSACM_UnregisterAllDrivers();
        HeapDestroy(MSACM_hHeap);
59
        MSACM_hHeap = NULL;
60
        MSACM_hInstance32 = NULL;
61
	break;
62
    default:
63
	break;
64
    }
65
    return TRUE;
66 67 68 69 70 71 72 73 74
}

/***********************************************************************
 *           XRegThunkEntry (MSACM32.1)
 * FIXME
 *   No documentation found.
 */

/***********************************************************************
75
 *           acmGetVersion (MSACM32.@)
76
 */
77
DWORD WINAPI acmGetVersion(void)
78
{
79
    OSVERSIONINFOA version;
80 81 82 83 84 85

    version.dwOSVersionInfoSize = sizeof(OSVERSIONINFOA);
    if (!GetVersionExA( &version ))
	return 0x04030000;

    switch (version.dwPlatformId) {
86
    case VER_PLATFORM_WIN32_NT:
87
	return 0x04000565; /* 4.0.1381 */
88
    default:
89
        FIXME("%x not supported\n", version.dwPlatformId);
90
    case VER_PLATFORM_WIN32_WINDOWS:
91 92
	return 0x04030000; /* 4.3.0 */
    }
93 94 95 96 97 98 99 100 101
}

/***********************************************************************
 *           acmMessage32 (MSACM32.35)
 * FIXME
 *   No documentation found.
 */

/***********************************************************************
102
 *           acmMetrics (MSACM32.@)
103
 */
104
MMRESULT WINAPI acmMetrics(HACMOBJ hao, UINT uMetric, LPVOID pMetric)
105
{
106
    PWINE_ACMOBJ 	pao = MSACM_GetObj(hao, WINE_ACMOBJ_DONTCARE);
107 108 109
    BOOL 		bLocal = TRUE;
    PWINE_ACMDRIVERID	padid;
    DWORD		val = 0;
110
    unsigned int	i;
111
    MMRESULT		mmr = MMSYSERR_NOERROR;
112

113
    TRACE("(%p, %d, %p);\n", hao, uMetric, pMetric);
114

115 116
#define CheckLocal(padid) (!bLocal || ((padid)->fdwSupport & ACMDRIVERDETAILS_SUPPORTF_LOCAL))

117
    switch (uMetric) {
118
    case ACM_METRIC_COUNT_DRIVERS:
119
	bLocal = FALSE;
120
	/* fall through */
121
    case ACM_METRIC_COUNT_LOCAL_DRIVERS:
122
	if (hao) return MMSYSERR_INVALHANDLE;
123
        if (!pMetric) return MMSYSERR_INVALPARAM;
124
	for (padid = MSACM_pFirstACMDriverID; padid; padid = padid->pNextACMDriverID)
125
	    if (!(padid->fdwSupport & ACMDRIVERDETAILS_SUPPORTF_DISABLED) && CheckLocal(padid))
126 127
		val++;
	*(LPDWORD)pMetric = val;
128
	break;
129

130
    case ACM_METRIC_COUNT_CODECS:
131
	bLocal = FALSE;
132
	/* fall through */
133
    case ACM_METRIC_COUNT_LOCAL_CODECS:
134
	if (hao) return MMSYSERR_INVALHANDLE;
135
        if (!pMetric) return MMSYSERR_INVALPARAM;
136
	for (padid = MSACM_pFirstACMDriverID; padid; padid = padid->pNextACMDriverID)
137
	    if (!(padid->fdwSupport & ACMDRIVERDETAILS_SUPPORTF_DISABLED) &&
138 139
		(padid->fdwSupport & ACMDRIVERDETAILS_SUPPORTF_CODEC) &&
		CheckLocal(padid))
140 141
		val++;
	*(LPDWORD)pMetric = val;
142
	break;
143

144
    case ACM_METRIC_COUNT_CONVERTERS:
145
	bLocal = FALSE;
146
	/* fall through */
147
    case ACM_METRIC_COUNT_LOCAL_CONVERTERS:
148
	if (hao) return MMSYSERR_INVALHANDLE;
149
        if (!pMetric) return MMSYSERR_INVALPARAM;
150
	for (padid = MSACM_pFirstACMDriverID; padid; padid = padid->pNextACMDriverID)
151
	    if (!(padid->fdwSupport & ACMDRIVERDETAILS_SUPPORTF_DISABLED) &&
152 153
		 (padid->fdwSupport & ACMDRIVERDETAILS_SUPPORTF_CONVERTER) &&
		CheckLocal(padid))
154 155
		val++;
	*(LPDWORD)pMetric = val;
156
	break;
157

158
    case ACM_METRIC_COUNT_FILTERS:
159
	bLocal = FALSE;
160
	/* fall through */
161
    case ACM_METRIC_COUNT_LOCAL_FILTERS:
162
	if (hao) return MMSYSERR_INVALHANDLE;
163
        if (!pMetric) return MMSYSERR_INVALPARAM;
164
	for (padid = MSACM_pFirstACMDriverID; padid; padid = padid->pNextACMDriverID)
165 166
	    if (!(padid->fdwSupport & ACMDRIVERDETAILS_SUPPORTF_DISABLED) &&
		(padid->fdwSupport & ACMDRIVERDETAILS_SUPPORTF_FILTER) &&
167
		CheckLocal(padid))
168 169
		val++;
	*(LPDWORD)pMetric = val;
170
	break;
171

172
    case ACM_METRIC_COUNT_DISABLED:
173
	bLocal = FALSE;
174
	/* fall through */
175
    case ACM_METRIC_COUNT_LOCAL_DISABLED:
176
	if (hao) return MMSYSERR_INVALHANDLE;
177
        if (!pMetric) return MMSYSERR_INVALPARAM;
178
	for (padid = MSACM_pFirstACMDriverID; padid; padid = padid->pNextACMDriverID)
179
	    if ((padid->fdwSupport & ACMDRIVERDETAILS_SUPPORTF_DISABLED) && CheckLocal(padid))
180 181
		val++;
	*(LPDWORD)pMetric = val;
182
	break;
183

184
    case ACM_METRIC_MAX_SIZE_FORMAT:
185
	if (hao == NULL) {
186
	    for (padid = MSACM_pFirstACMDriverID; padid; padid = padid->pNextACMDriverID) {
187
		if (!(padid->fdwSupport & ACMDRIVERDETAILS_SUPPORTF_DISABLED)) {
188 189 190 191
		    for (i = 0; i < padid->cFormatTags; i++) {
			if (val < padid->aFormatTag[i].cbwfx)
			    val = padid->aFormatTag[i].cbwfx;
		    }
192 193
		}
	    }
194 195 196 197 198 199 200 201 202
	} else if (pao != NULL) {
	    switch (pao->dwType) {
	    case WINE_ACMOBJ_DRIVER:
	    case WINE_ACMOBJ_DRIVERID:
		padid = pao->pACMDriverID;
		break;
	    default:
		return MMSYSERR_INVALHANDLE;
	    }
203
	    if (!(padid->fdwSupport & ACMDRIVERDETAILS_SUPPORTF_DISABLED)) {
204 205 206 207 208 209 210
		for (i = 0; i < padid->cFormatTags; i++) {
		    if (val < padid->aFormatTag[i].cbwfx)
			val = padid->aFormatTag[i].cbwfx;
		}
	    }
	} else {
	    return MMSYSERR_INVALHANDLE;
211
	}
212
        if (!pMetric) return MMSYSERR_INVALPARAM;
213
	*(LPDWORD)pMetric = val;
214 215
        break;

216
    case ACM_METRIC_COUNT_HARDWARE:
217 218 219 220 221 222
        if (hao) return MMSYSERR_INVALHANDLE;
        if (!pMetric) return MMSYSERR_INVALPARAM;
        *(LPDWORD)pMetric = 0;
        FIXME("ACM_METRIC_COUNT_HARDWARE not implemented\n");
        break;

223 224 225 226 227 228
    case ACM_METRIC_DRIVER_PRIORITY:
        /* Return current list position of driver */
        if (!hao) return MMSYSERR_INVALHANDLE;
        mmr = MMSYSERR_INVALHANDLE;
        for (i = 1, padid = MSACM_pFirstACMDriverID; padid; i++, padid = padid->pNextACMDriverID) {
            if (padid == (PWINE_ACMDRIVERID)hao) {
229 230 231 232 233 234
                if (pMetric) {
                    *(LPDWORD)pMetric = i;
                    mmr = MMSYSERR_NOERROR;
                } else {
                    mmr = MMSYSERR_INVALPARAM;
                }
235 236 237 238 239
                break;
            }
        }
        break;
        
240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256
    case ACM_METRIC_DRIVER_SUPPORT:
        /* Return fdwSupport for driver */
        if (!hao) return MMSYSERR_INVALHANDLE;
        mmr = MMSYSERR_INVALHANDLE;
        for (padid = MSACM_pFirstACMDriverID; padid; padid = padid->pNextACMDriverID) {
            if (padid == (PWINE_ACMDRIVERID)hao) {
                if (pMetric) {
                    *(LPDWORD)pMetric = padid->fdwSupport;
                    mmr = MMSYSERR_NOERROR;
                } else {
                    mmr = MMSYSERR_INVALPARAM;
                }
                break;
            }
        }
        break;

257 258 259 260
    case ACM_METRIC_HARDWARE_WAVE_INPUT:
    case ACM_METRIC_HARDWARE_WAVE_OUTPUT:
    case ACM_METRIC_MAX_SIZE_FILTER:
    default:
261
	FIXME("(%p, %d, %p): stub\n", hao, uMetric, pMetric);
262
	mmr = MMSYSERR_NOTSUPPORTED;
263
    }
264
    return mmr;
265
}