Maarten Lankhorst : wineoss.drv: Move opening devices to their respective xxxMessage functions.
Alexandre Julliard
julliard at winehq.org
Wed Apr 21 10:40:27 CDT 2010
Module: wine
Branch: master
Commit: c0a602c2e944fed20d3d2d5f115b259e5248a515
URL: http://source.winehq.org/git/wine.git/?a=commit;h=c0a602c2e944fed20d3d2d5f115b259e5248a515
Author: Maarten Lankhorst <m.b.lankhorst at gmail.com>
Date: Wed Apr 21 13:45:31 2010 +0200
wineoss.drv: Move opening devices to their respective xxxMessage functions.
---
dlls/wineoss.drv/audio.c | 16 ++++++++++++----
dlls/wineoss.drv/midi.c | 44 ++++++++++++++++++++++----------------------
dlls/wineoss.drv/mixer.c | 6 ++++--
dlls/wineoss.drv/mmaux.c | 6 ++++--
dlls/wineoss.drv/oss.c | 35 ++---------------------------------
dlls/wineoss.drv/oss.h | 12 ------------
6 files changed, 44 insertions(+), 75 deletions(-)
diff --git a/dlls/wineoss.drv/audio.c b/dlls/wineoss.drv/audio.c
index ba42358..9c712c8 100644
--- a/dlls/wineoss.drv/audio.c
+++ b/dlls/wineoss.drv/audio.c
@@ -1140,18 +1140,22 @@ static char* StrDup(const char* str, const char* def)
return dst;
}
+static int WAVE_loadcount;
+
/******************************************************************
* OSS_WaveInit
*
* Initialize internal structures from OSS information
*/
-LRESULT OSS_WaveInit(void)
+static LRESULT OSS_WaveInit(void)
{
char* str;
unsigned int i;
/* FIXME: Remove unneeded members of WOutDev and WInDev */
- TRACE("()\n");
+ TRACE("(%i)\n", WAVE_loadcount);
+ if (WAVE_loadcount++)
+ return 1;
str=getenv("AUDIODEV");
if (str!=NULL)
@@ -1230,10 +1234,12 @@ LRESULT OSS_WaveInit(void)
*
* Delete/clear internal structures of OSS information
*/
-LRESULT OSS_WaveExit(void)
+static LRESULT OSS_WaveExit(void)
{
int i;
- TRACE("()\n");
+ TRACE("(%i)\n", WAVE_loadcount);
+ if (--WAVE_loadcount)
+ return 1;
for (i = 0; i < MAX_WAVEDRV; ++i)
{
@@ -3136,7 +3142,9 @@ DWORD WINAPI OSS_widMessage(WORD wDevID, WORD wMsg, DWORD_PTR dwUser,
switch (wMsg) {
case DRVM_INIT:
+ return OSS_WaveInit();
case DRVM_EXIT:
+ return OSS_WaveExit();
case DRVM_ENABLE:
case DRVM_DISABLE:
/* FIXME: Pretend this is supported */
diff --git a/dlls/wineoss.drv/midi.c b/dlls/wineoss.drv/midi.c
index 0945e93..61d0383 100644
--- a/dlls/wineoss.drv/midi.c
+++ b/dlls/wineoss.drv/midi.c
@@ -170,23 +170,23 @@ static int MIDI_UnixToWindowsDeviceType(int type)
}
}
+static int MIDI_loadcount;
/**************************************************************************
* OSS_MidiInit [internal]
*
* Initializes the MIDI devices information variables
*/
-LRESULT OSS_MidiInit(void)
+static LRESULT OSS_MidiInit(void)
{
int i, status, numsynthdevs = 255, nummididevs = 255;
struct synth_info sinfo;
struct midi_info minfo;
- static BOOL bInitDone = FALSE;
- if (bInitDone)
- return 0;
+ TRACE("(%i)\n", MIDI_loadcount);
+ if (MIDI_loadcount++)
+ return 1;
TRACE("Initializing the MIDI variables.\n");
- bInitDone = TRUE;
/* try to open device */
if (midiOpenSeq() == -1) {
@@ -381,9 +381,12 @@ LRESULT OSS_MidiInit(void)
*
* Release the MIDI devices information variables
*/
-LRESULT OSS_MidiExit(void)
+static LRESULT OSS_MidiExit(void)
{
- TRACE("()\n");
+ TRACE("(%i)\n", MIDI_loadcount);
+
+ if (--MIDI_loadcount)
+ return 1;
ZeroMemory(MidiInDev, sizeof(MidiInDev));
ZeroMemory(MidiOutDev, sizeof(MidiOutDev));
@@ -1654,21 +1657,6 @@ static DWORD modReset(WORD wDevID)
return MMSYSERR_NOERROR;
}
-#else /* HAVE_OSS_MIDI */
-
-LRESULT OSS_MidiInit(void)
-{
- TRACE("()\n");
- return FALSE;
-}
-
-LRESULT OSS_MidiExit(void)
-{
- TRACE("()\n");
- return 0;
-}
-
-
#endif /* HAVE_OSS_MIDI */
/*======================================================================*
@@ -1686,7 +1674,9 @@ DWORD WINAPI OSS_midMessage(UINT wDevID, UINT wMsg, DWORD_PTR dwUser,
switch (wMsg) {
#ifdef HAVE_OSS_MIDI
case DRVM_INIT:
+ return OSS_MidiInit();
case DRVM_EXIT:
+ return OSS_MidiExit();
case DRVM_ENABLE:
case DRVM_DISABLE:
/* FIXME: Pretend this is supported */
@@ -1711,6 +1701,10 @@ DWORD WINAPI OSS_midMessage(UINT wDevID, UINT wMsg, DWORD_PTR dwUser,
return midStart(wDevID);
case MIDM_STOP:
return midStop(wDevID);
+#else
+ case DRVM_INIT:
+ case MIDM_GETNUMDEVS:
+ return 0;
#endif
default:
TRACE("Unsupported message\n");
@@ -1730,7 +1724,9 @@ DWORD WINAPI OSS_modMessage(UINT wDevID, UINT wMsg, DWORD_PTR dwUser,
switch (wMsg) {
#ifdef HAVE_OSS_MIDI
case DRVM_INIT:
+ return OSS_MidiInit();
case DRVM_EXIT:
+ return OSS_MidiExit();
case DRVM_ENABLE:
case DRVM_DISABLE:
/* FIXME: Pretend this is supported */
@@ -1757,6 +1753,10 @@ DWORD WINAPI OSS_modMessage(UINT wDevID, UINT wMsg, DWORD_PTR dwUser,
return 0;
case MODM_RESET:
return modReset(wDevID);
+#else
+ case DRVM_INIT:
+ case MODM_GETNUMDEVS:
+ return 0;
#endif
default:
TRACE("Unsupported message\n");
diff --git a/dlls/wineoss.drv/mixer.c b/dlls/wineoss.drv/mixer.c
index ac72c7a..9b6dacc 100644
--- a/dlls/wineoss.drv/mixer.c
+++ b/dlls/wineoss.drv/mixer.c
@@ -1433,7 +1433,7 @@ static DWORD MIX_SetControlDetails(WORD wDevID, LPMIXERCONTROLDETAILS lpmcd,
/**************************************************************************
* MIX_Init [internal]
*/
-LRESULT OSS_MixerInit(void)
+static LRESULT OSS_MixerInit(void)
{
int i, mixer;
@@ -1485,7 +1485,7 @@ LRESULT OSS_MixerInit(void)
/**************************************************************************
* MIX_Exit [internal]
*/
-LRESULT OSS_MixerExit(void)
+static LRESULT OSS_MixerExit(void)
{
int i;
@@ -1524,7 +1524,9 @@ DWORD WINAPI OSS_mxdMessage(UINT wDevID, UINT wMsg, DWORD_PTR dwUser,
switch (wMsg)
{
case DRVM_INIT:
+ return OSS_MixerInit();
case DRVM_EXIT:
+ return OSS_MixerExit();
case DRVM_ENABLE:
case DRVM_DISABLE:
/* FIXME: Pretend this is supported */
diff --git a/dlls/wineoss.drv/mmaux.c b/dlls/wineoss.drv/mmaux.c
index ff62107..3554ffb 100644
--- a/dlls/wineoss.drv/mmaux.c
+++ b/dlls/wineoss.drv/mmaux.c
@@ -49,7 +49,7 @@ static int NumDev = 6;
/*-----------------------------------------------------------------------*/
-LRESULT OSS_AuxInit(void)
+static LRESULT OSS_AuxInit(void)
{
int mixer;
TRACE("()\n");
@@ -66,7 +66,7 @@ LRESULT OSS_AuxInit(void)
/*-----------------------------------------------------------------------*/
-LRESULT OSS_AuxExit(void)
+static LRESULT OSS_AuxExit(void)
{
TRACE("()\n");
return 0;
@@ -232,7 +232,9 @@ DWORD WINAPI OSS_auxMessage(UINT wDevID, UINT wMsg, DWORD_PTR dwUser,
#ifdef HAVE_OSS
switch (wMsg) {
case DRVM_INIT:
+ return OSS_AuxInit();
case DRVM_EXIT:
+ return OSS_AuxExit();
case DRVM_ENABLE:
case DRVM_DISABLE:
/* FIXME: Pretend this is supported */
diff --git a/dlls/wineoss.drv/oss.c b/dlls/wineoss.drv/oss.c
index 1d80272..2a54c73 100644
--- a/dlls/wineoss.drv/oss.c
+++ b/dlls/wineoss.drv/oss.c
@@ -33,37 +33,6 @@
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;
-}
-
-#endif
-
-
/**************************************************************************
* DriverProc (WINEOSS.1)
*/
@@ -75,8 +44,8 @@ LRESULT CALLBACK OSS_DriverProc(DWORD_PTR dwDevID, HDRVR hDriv, UINT wMsg,
switch(wMsg) {
#ifdef HAVE_OSS
- case DRV_LOAD: return OSS_drvLoad();
- case DRV_FREE: return OSS_drvFree();
+ case DRV_LOAD:
+ case DRV_FREE:
case DRV_OPEN:
case DRV_CLOSE:
case DRV_ENABLE:
diff --git a/dlls/wineoss.drv/oss.h b/dlls/wineoss.drv/oss.h
index c6a45ae..e1c9c89 100644
--- a/dlls/wineoss.drv/oss.h
+++ b/dlls/wineoss.drv/oss.h
@@ -37,15 +37,3 @@
#ifdef SNDCTL_DSP_STEREO
# define HAVE_OSS
#endif
-
-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);
More information about the wine-cvs
mailing list