Commit c7a59d11 authored by Robert Reif's avatar Robert Reif Committed by Alexandre Julliard

wineoss: Fix device probing.

- Fix device probing at driver load time. - Fix memory leaks at driver exit time.
parent db50e2d9
......@@ -1078,7 +1078,7 @@ static char* StrDup(const char* str, const char* def)
*
* Initialize internal structures from OSS information
*/
LONG OSS_WaveInit(void)
LRESULT OSS_WaveInit(void)
{
char* str;
int i;
......@@ -1159,6 +1159,33 @@ LONG OSS_WaveInit(void)
}
/******************************************************************
* OSS_WaveExit
*
* Delete/clear internal structures of OSS information
*/
LRESULT OSS_WaveExit(void)
{
int i;
TRACE("()\n");
for (i = 0; i < MAX_WAVEDRV; ++i)
{
HeapFree(GetProcessHeap(), 0, OSS_Devices[i].dev_name);
HeapFree(GetProcessHeap(), 0, OSS_Devices[i].mixer_name);
HeapFree(GetProcessHeap(), 0, OSS_Devices[i].interface_name);
}
ZeroMemory(OSS_Devices, sizeof(OSS_Devices));
ZeroMemory(WOutDev, sizeof(WOutDev));
ZeroMemory(WInDev, sizeof(WInDev));
numOutDev = 0;
numInDev = 0;
return 0;
}
/******************************************************************
* OSS_InitRingMessage
*
* Initialize the ring of messages for passing between driver's caller and playback/record
......
......@@ -176,7 +176,7 @@ static int MIDI_UnixToWindowsDeviceType(int type)
*
* Initializes the MIDI devices information variables
*/
BOOL OSS_MidiInit(void)
LRESULT OSS_MidiInit(void)
{
int i, status, numsynthdevs = 255, nummididevs = 255;
struct synth_info sinfo;
......@@ -184,14 +184,14 @@ BOOL OSS_MidiInit(void)
static BOOL bInitDone = FALSE;
if (bInitDone)
return TRUE;
return 0;
TRACE("Initializing the MIDI variables.\n");
bInitDone = TRUE;
bInitDone = 0;
/* try to open device */
if (midiOpenSeq() == -1) {
return TRUE;
return -1;
}
/* find how many Synth devices are there in the system */
......@@ -200,7 +200,7 @@ BOOL OSS_MidiInit(void)
if (status == -1) {
ERR("ioctl for nr synth failed.\n");
midiCloseSeq();
return TRUE;
return -1;
}
if (numsynthdevs > MAX_MIDIOUTDRV) {
......@@ -374,7 +374,26 @@ BOOL OSS_MidiInit(void)
/* close file and exit */
midiCloseSeq();
return TRUE;
return 0;
}
/**************************************************************************
* OSS_MidiExit [internal]
*
* Release the MIDI devices information variables
*/
LRESULT OSS_MidiExit(void)
{
TRACE("()\n");
ZeroMemory(MidiInDev, sizeof(MidiInDev));
ZeroMemory(MidiOutDev, sizeof(MidiOutDev));
MODM_NumDevs = 0;
MODM_NumFMSynthDevs = 0;
MIDM_NumDevs = 0;
return 0;
}
/**************************************************************************
......@@ -1657,7 +1676,7 @@ static DWORD modReset(WORD wDevID)
#else /* HAVE_OSS_MIDI */
BOOL OSS_MidiInit(void)
LRESULT OSS_MidiInit(void)
{
return FALSE;
}
......
......@@ -1437,7 +1437,7 @@ static DWORD MIX_SetControlDetails(WORD wDevID, LPMIXERCONTROLDETAILS lpmcd,
/**************************************************************************
* MIX_Init [internal]
*/
static DWORD MIX_Init(void)
LRESULT OSS_MixerInit(void)
{
int i, mixer;
......@@ -1489,7 +1489,7 @@ static DWORD MIX_Init(void)
/**************************************************************************
* MIX_Exit [internal]
*/
static DWORD MIX_Exit(void)
LRESULT OSS_MixerExit(void)
{
int i;
......@@ -1528,9 +1528,7 @@ DWORD WINAPI OSS_mxdMessage(UINT wDevID, UINT wMsg, DWORD dwUser,
switch (wMsg)
{
case DRVM_INIT:
return MIX_Init();
case DRVM_EXIT:
return MIX_Exit();
case DRVM_ENABLE:
case DRVM_DISABLE:
/* FIXME: Pretend this is supported */
......
......@@ -49,9 +49,10 @@ static int NumDev = 6;
/*-----------------------------------------------------------------------*/
static int AUXDRV_Init(void)
LRESULT OSS_AuxInit(void)
{
int mixer;
TRACE("()\n");
if ((mixer = open(MIXER_DEV, O_RDWR)) < 0) {
WARN("mixer device not available !\n");
......@@ -60,7 +61,15 @@ static int AUXDRV_Init(void)
close(mixer);
NumDev = 6;
}
return NumDev;
return 0;
}
/*-----------------------------------------------------------------------*/
LRESULT OSS_AuxExit(void)
{
TRACE("()\n");
return 0;
}
/**************************************************************************
......@@ -219,8 +228,6 @@ DWORD WINAPI OSS_auxMessage(UINT wDevID, UINT wMsg, DWORD dwUser,
#ifdef HAVE_OSS
switch (wMsg) {
case DRVM_INIT:
AUXDRV_Init();
/* fall through */
case DRVM_EXIT:
case DRVM_ENABLE:
case DRVM_DISABLE:
......
......@@ -29,14 +29,44 @@
#include "winuser.h"
#include "mmddk.h"
#include "oss.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(wave);
#ifdef HAVE_OSS
/**************************************************************************
* OSS_drvLoad [internal]
*/
static LRESULT OSS_drvLoad(void)
{
TRACE("()\n");
OSS_WaveInit();
OSS_MidiInit();
OSS_MixerInit();
OSS_AuxInit();
return 1;
}
/**************************************************************************
* OSS_drvFree [internal]
*/
static LRESULT OSS_drvFree(void)
{
TRACE("()\n");
OSS_WaveExit();
OSS_MidiExit();
OSS_MixerExit();
OSS_AuxExit();
return 1;
}
/**************************************************************************
* OSS_drvOpen [internal]
*/
static LRESULT OSS_drvOpen(LPSTR str)
{
TRACE("(%s)\n", str);
return 1;
}
......@@ -45,6 +75,7 @@ static LRESULT OSS_drvOpen(LPSTR str)
*/
static LRESULT OSS_drvClose(DWORD_PTR dwDevID)
{
TRACE("(%08lx)\n", dwDevID);
return 1;
}
......@@ -57,15 +88,13 @@ static LRESULT OSS_drvClose(DWORD_PTR dwDevID)
LRESULT CALLBACK OSS_DriverProc(DWORD_PTR dwDevID, HDRVR hDriv, UINT wMsg,
LPARAM dwParam1, LPARAM dwParam2)
{
/* EPP TRACE("(%08lX, %04X, %08lX, %08lX, %08lX)\n", */
/* EPP dwDevID, hDriv, wMsg, dwParam1, dwParam2); */
TRACE("(%08lX, %p, %08X, %08lX, %08lX)\n",
dwDevID, hDriv, wMsg, dwParam1, dwParam2);
switch(wMsg) {
#ifdef HAVE_OSS
case DRV_LOAD: OSS_WaveInit();
OSS_MidiInit();
return 1;
case DRV_FREE: return 1;
case DRV_LOAD: return OSS_drvLoad();
case DRV_FREE: return OSS_drvFree();
case DRV_OPEN: return OSS_drvOpen((LPSTR)dwParam1);
case DRV_CLOSE: return OSS_drvClose(dwDevID);
case DRV_ENABLE: return 1;
......
......@@ -38,5 +38,14 @@
# define HAVE_OSS
#endif
extern LONG OSS_WaveInit(void);
extern BOOL OSS_MidiInit(void);
LRESULT OSS_WaveInit(void);
LRESULT OSS_WaveExit(void);
LRESULT OSS_MidiInit(void);
LRESULT OSS_MidiExit(void);
LRESULT OSS_MixerInit(void);
LRESULT OSS_MixerExit(void);
LRESULT OSS_AuxInit(void);
LRESULT OSS_AuxExit(void);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment