From 31c286658bae0f6fb3e661d944953b3ca0c6fff9 Mon Sep 17 00:00:00 2001 From: Eric Pouech Date: Mon, 22 Mar 1999 14:50:38 +0000 Subject: [PATCH] Fixed a few bugs. Started implementing mixerMessage as a 32 bit function (no longer 16 bit). --- multimedia/mixer.c | 196 +++++++++++++++++++++++++++------------------ 1 file changed, 118 insertions(+), 78 deletions(-) diff --git a/multimedia/mixer.c b/multimedia/mixer.c index fcb6256f4a6..dc95558b88e 100644 --- a/multimedia/mixer.c +++ b/multimedia/mixer.c @@ -1,7 +1,10 @@ +/* -*- tab-width: 8; c-basic-offset: 4 -*- */ + /* * Sample MIXER Wine Driver for Linux * - * Copyright 1997 Marcus Meissner + * Copyright 1997 Marcus Meissner + * 1999 Eric Pouech */ #include @@ -15,93 +18,97 @@ #include "multimedia.h" #include "debug.h" +#ifdef HAVE_OSS #define MIXER_DEV "/dev/mixer" +#define WINE_MIXER_MANUF_ID 0xAA +#define WINE_MIXER_PRODUCT_ID 0x55 +#define WINE_MIXER_VERSION 0x0100 +#define WINE_MIXER_NAME "WINE OSS Mixer" + /************************************************************************** - * MIX_GetDevCaps [internal] + * MIX_GetDevCaps [internal] */ -static DWORD MIX_GetDevCaps(WORD wDevID, LPMIXERCAPS16 lpCaps, DWORD dwSize) +static DWORD MIX_GetDevCaps(WORD wDevID, LPMIXERCAPSA lpCaps, DWORD dwSize) { -#ifdef HAVE_OSS - int mixer,mask; + int mixer, mask; TRACE(mmaux, "(%04X, %p, %lu);\n", wDevID, lpCaps, dwSize); + + if (wDevID != 0) return MMSYSERR_BADDEVICEID; if (lpCaps == NULL) return MMSYSERR_INVALPARAM; + if ((mixer = open(MIXER_DEV, O_RDWR)) < 0) { WARN(mmaux, "mixer device not available !\n"); return MMSYSERR_NOTENABLED; } - lpCaps->wMid = 0xAA; - lpCaps->wPid = 0x55; - lpCaps->vDriverVersion = 0x0100; - strcpy(lpCaps->szPname, "WINE Generic Mixer"); + lpCaps->wMid = WINE_MIXER_MANUF_ID; + lpCaps->wPid = WINE_MIXER_PRODUCT_ID; + lpCaps->vDriverVersion = WINE_MIXER_VERSION; + strcpy(lpCaps->szPname, WINE_MIXER_NAME); if (ioctl(mixer, SOUND_MIXER_READ_DEVMASK, &mask) == -1) { close(mixer); perror("ioctl mixer SOUND_MIXER_DEVMASK"); return MMSYSERR_NOTENABLED; } - /* FIXME: can the Linux Mixer differ between multiple mixertargets? */ + + /* FIXME: can the Linux Mixer differ between multiple mixer targets ? */ lpCaps->cDestinations = 1; lpCaps->fdwSupport = 0; /* No bits defined yet */ close(mixer); return MMSYSERR_NOERROR; -#else - return MMSYSERR_NOTENABLED; -#endif } -#ifdef HAVE_OSS static char *sdlabels[SOUND_MIXER_NRDEVICES] = SOUND_DEVICE_LABELS; static char *sdnames[SOUND_MIXER_NRDEVICES] = SOUND_DEVICE_NAMES; -static void MIX_GetLineInfoFromIndex(LPMIXERLINE16 lpml, int devmask, DWORD idx) +static void MIX_GetLineInfoFromIndex(LPMIXERLINEA lpMl, int devmask, DWORD idx) { - strcpy(lpml->szShortName, sdlabels[idx]); - strcpy(lpml->szName, sdnames[idx]); - lpml->dwLineID = idx; - lpml->dwDestination = 0; /* index for speakers */ - lpml->cConnections = 1; - lpml->cControls = 1; + strcpy(lpMl->szShortName, sdlabels[idx]); + strcpy(lpMl->szName, sdnames[idx]); + lpMl->dwLineID = idx; + lpMl->dwDestination = 0; /* index for speakers */ + lpMl->cConnections = 1; + lpMl->cControls = 1; switch (idx) { case SOUND_MIXER_SYNTH: - lpml->dwComponentType = MIXERLINE_COMPONENTTYPE_SRC_SYNTHESIZER; - lpml->fdwLine |= MIXERLINE_LINEF_SOURCE; + lpMl->dwComponentType = MIXERLINE_COMPONENTTYPE_SRC_SYNTHESIZER; + lpMl->fdwLine |= MIXERLINE_LINEF_SOURCE; break; case SOUND_MIXER_CD: - lpml->dwComponentType = MIXERLINE_COMPONENTTYPE_SRC_COMPACTDISC; - lpml->fdwLine |= MIXERLINE_LINEF_SOURCE; + lpMl->dwComponentType = MIXERLINE_COMPONENTTYPE_SRC_COMPACTDISC; + lpMl->fdwLine |= MIXERLINE_LINEF_SOURCE; break; case SOUND_MIXER_LINE: - lpml->dwComponentType = MIXERLINE_COMPONENTTYPE_SRC_LINE; - lpml->fdwLine |= MIXERLINE_LINEF_SOURCE; + lpMl->dwComponentType = MIXERLINE_COMPONENTTYPE_SRC_LINE; + lpMl->fdwLine |= MIXERLINE_LINEF_SOURCE; break; case SOUND_MIXER_MIC: - lpml->dwComponentType = MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE; - lpml->fdwLine |= MIXERLINE_LINEF_SOURCE; + lpMl->dwComponentType = MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE; + lpMl->fdwLine |= MIXERLINE_LINEF_SOURCE; break; case SOUND_MIXER_PCM: - lpml->dwComponentType = MIXERLINE_COMPONENTTYPE_SRC_WAVEOUT; - lpml->fdwLine |= MIXERLINE_LINEF_SOURCE; + lpMl->dwComponentType = MIXERLINE_COMPONENTTYPE_SRC_WAVEOUT; + lpMl->fdwLine |= MIXERLINE_LINEF_SOURCE; break; default: ERR(mmaux, "Index %ld not handled.\n", idx); break; } } -#endif /************************************************************************** - * MIX_GetLineInfo [internal] + * MIX_GetLineInfo [internal] */ -static DWORD MIX_GetLineInfo(WORD wDevID, LPMIXERLINE16 lpml, DWORD fdwInfo) +static DWORD MIX_GetLineInfo(WORD wDevID, LPMIXERLINEA lpMl, DWORD fdwInfo) { -#ifdef HAVE_OSS int mixer, i, j, devmask, recsrc, recmask; + BOOL isDst = FALSE; DWORD ret = MMSYSERR_NOERROR; - TRACE(mmaux, "(%04X, %p, %lu);\n", wDevID, lpml, fdwInfo); - if (lpml == NULL || lpml->cbStruct != sizeof(*lpml)) + TRACE(mmaux, "(%04X, %p, %lu);\n", wDevID, lpMl, fdwInfo); + if (lpMl == NULL || lpMl->cbStruct != sizeof(*lpMl)) return MMSYSERR_INVALPARAM; if ((mixer = open(MIXER_DEV, O_RDWR)) < 0) return MMSYSERR_NOTENABLED; @@ -125,100 +132,127 @@ static DWORD MIX_GetLineInfo(WORD wDevID, LPMIXERLINE16 lpml, DWORD fdwInfo) /* FIXME: set all the variables correctly... the lines below * are very wrong... */ - lpml->fdwLine = MIXERLINE_LINEF_ACTIVE; - lpml->cChannels = 2; + lpMl->fdwLine = MIXERLINE_LINEF_ACTIVE; + lpMl->cChannels = 2; + lpMl->dwUser = 0; + lpMl->cControls = 1; switch (fdwInfo & MIXER_GETLINEINFOF_QUERYMASK) { case MIXER_GETLINEINFOF_DESTINATION: /* FIXME: Linux doesn't seem to support multiple outputs? - * So we have only one outputtype, Speaker. + * So we have only one output type: Speaker. */ - lpml->dwComponentType = MIXERLINE_COMPONENTTYPE_DST_SPEAKERS; + lpMl->dwComponentType = MIXERLINE_COMPONENTTYPE_DST_SPEAKERS; + lpMl->dwDestination = 0; + lpMl->dwSource = 0xFFFFFFFF; + lpMl->dwLineID = SOUND_MIXER_SPEAKER; + strcpy(lpMl->szShortName, sdlabels[SOUND_MIXER_SPEAKER]); + strcpy(lpMl->szName, sdnames[SOUND_MIXER_SPEAKER]); + /* we have all connections found in the devmask */ - lpml->cConnections = 0; - for (j=0;j<31;j++) - if (devmask & (1<cConnections++; + lpMl->cConnections = 0; + for (j = 0; j < 31; j++) + if (devmask & (1 << j)) + lpMl->cConnections++; break; case MIXER_GETLINEINFOF_SOURCE: for (i = j = 0; j < 31; j++) { if (devmask & (1 << j)) { - if (lpml->dwSource == i) + if (lpMl->dwSource == i) break; i++; } } - MIX_GetLineInfoFromIndex(lpml, devmask, i); + MIX_GetLineInfoFromIndex(lpMl, devmask, i); break; case MIXER_GETLINEINFOF_LINEID: - MIX_GetLineInfoFromIndex(lpml, devmask, lpml->dwLineID); + MIX_GetLineInfoFromIndex(lpMl, devmask, lpMl->dwLineID); break; case MIXER_GETLINEINFOF_COMPONENTTYPE: - TRACE(mmaux, "Getting component type (%08lx)\n", lpml->dwComponentType); - switch (lpml->dwComponentType) { + TRACE(mmaux, "Getting component type (%08lx)\n", lpMl->dwComponentType); + + switch (lpMl->dwComponentType) { case MIXERLINE_COMPONENTTYPE_DST_SPEAKERS: - i = -1; + i = SOUND_MIXER_SPEAKER; + lpMl->dwDestination = 0; + lpMl->dwSource = 0xFFFFFFFF; + isDst = TRUE; break; case MIXERLINE_COMPONENTTYPE_SRC_SYNTHESIZER: i = SOUND_MIXER_SYNTH; + lpMl->fdwLine |= MIXERLINE_LINEF_SOURCE; break; case MIXERLINE_COMPONENTTYPE_SRC_COMPACTDISC: i = SOUND_MIXER_CD; + lpMl->fdwLine |= MIXERLINE_LINEF_SOURCE; break; case MIXERLINE_COMPONENTTYPE_SRC_LINE: i = SOUND_MIXER_LINE; + lpMl->fdwLine |= MIXERLINE_LINEF_SOURCE; break; case MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE: i = SOUND_MIXER_MIC; + lpMl->fdwLine |= MIXERLINE_LINEF_SOURCE; break; case MIXERLINE_COMPONENTTYPE_SRC_WAVEOUT: i = SOUND_MIXER_PCM; + lpMl->fdwLine |= MIXERLINE_LINEF_SOURCE; break; default: - FIXME(mmaux, "Unhandled component type (%08lx)\n", lpml->dwComponentType); + FIXME(mmaux, "Unhandled component type (%08lx)\n", lpMl->dwComponentType); return MMSYSERR_INVALPARAM; } - if (i != -1 && (devmask & (1 << i))) { - strcpy(lpml->szShortName, sdlabels[i]); - strcpy(lpml->szName, sdnames[i]); - lpml->dwLineID = i; - lpml->fdwLine = MIXERLINE_LINEF_SOURCE; - } else { - lpml->cConnections = 0; - for (j=0;j<31;j++) - if (devmask & (1<cConnections++; - lpml->dwLineID = 32; + + if (devmask & (1 << i)) { + strcpy(lpMl->szShortName, sdlabels[i]); + strcpy(lpMl->szName, sdnames[i]); + lpMl->dwLineID = i; + } + lpMl->cConnections = 0; + if (isDst) { + for (j = 0; j < 31; j++) + if (devmask & (1 << j)) + lpMl->cConnections++; + /* lpMl->dwLineID = 32;*/ } break; case MIXER_GETLINEINFOF_TARGETTYPE: FIXME(mmaux, "_TARGETTYPE not implemented yet.\n"); break; } - lpml->Target.dwType = MIXERLINE_TARGETTYPE_AUX; + + lpMl->Target.dwType = MIXERLINE_TARGETTYPE_AUX; + lpMl->Target.dwDeviceID = 0xFFFFFFFF; + lpMl->Target.wMid = WINE_MIXER_MANUF_ID; + lpMl->Target.wPid = WINE_MIXER_PRODUCT_ID; + lpMl->Target.vDriverVersion = WINE_MIXER_VERSION; + strcpy(lpMl->Target.szPname, WINE_MIXER_NAME); + close(mixer); return ret; -#else - return MMSYSERR_NOTENABLED; -#endif } /************************************************************************** * MIX_GetLineInfo [internal] */ -static DWORD MIX_Open(WORD wDevID, LPMIXEROPENDESC lpmod, DWORD flags) +static DWORD MIX_Open(WORD wDevID, LPMIXEROPENDESC lpMod, DWORD flags) { -#ifdef HAVE_OSS - - TRACE(mmaux, "(%04X, %p, %lu);\n", wDevID,lpmod,flags); - if (lpmod == NULL) return MMSYSERR_INVALPARAM; + TRACE(mmaux, "(%04X, %p, %lu);\n", wDevID, lpMod, flags); + if (lpMod == NULL) return MMSYSERR_INVALPARAM; /* hmm. We don't keep the mixer device open. So just pretend it works */ return MMSYSERR_NOERROR; -#else - return MMSYSERR_NOTENABLED; -#endif } +static DWORD MIX_GetLineControls(WORD wDevID, LPMIXERLINECONTROLSA lpMlc, DWORD flags) +{ + TRACE(mmaux, "(%04X, %p, %lu);\n", wDevID, lpMlc, flags); + + if (lpMlc == NULL) return MMSYSERR_INVALPARAM; + + return MMSYSERR_NOERROR; +} +#endif + /************************************************************************** * mixMessage [sample driver] */ @@ -228,11 +262,12 @@ DWORD WINAPI mixMessage(WORD wDevID, WORD wMsg, DWORD dwUser, TRACE(mmaux, "(%04X, %04X, %08lX, %08lX, %08lX);\n", wDevID, wMsg, dwUser, dwParam1, dwParam2); +#ifdef HAVE_OSS switch(wMsg) { - case MXDM_GETDEVCAPS: - return MIX_GetDevCaps(wDevID, (LPMIXERCAPS16)dwParam1, dwParam2); + case MXDM_GETDEVCAPS: + return MIX_GetDevCaps(wDevID, (LPMIXERCAPSA)dwParam1, dwParam2); case MXDM_GETLINEINFO: - return MIX_GetLineInfo(wDevID, (LPMIXERLINE16)dwParam1, dwParam2); + return MIX_GetLineInfo(wDevID, (LPMIXERLINEA)dwParam1, dwParam2); case MXDM_GETNUMDEVS: TRACE(mmaux, "return 1;\n"); return 1; @@ -240,9 +275,14 @@ DWORD WINAPI mixMessage(WORD wDevID, WORD wMsg, DWORD dwUser, return MIX_Open(wDevID, (LPMIXEROPENDESC)dwParam1, dwParam2); case MXDM_CLOSE: return MMSYSERR_NOERROR; + case MXDM_GETLINECONTROLS: + return MIX_GetLineControls(wDevID, (LPMIXERLINECONTROLSA)dwParam1, dwParam2); default: WARN(mmaux, "unknown message %d!\n", wMsg); } return MMSYSERR_NOTSUPPORTED; +#endif + return MMSYSERR_NOTENABLED; } +