Commit 0dc5bab1 authored by Maarten Lankhorst's avatar Maarten Lankhorst Committed by Alexandre Julliard

winecfg: Only initialise the audio drivers once.

parent f479aa5c
...@@ -86,9 +86,10 @@ typedef struct ...@@ -86,9 +86,10 @@ typedef struct
{ {
UINT nameID; UINT nameID;
const char *szDriver; const char *szDriver;
HDRVR hDriver;
} AUDIO_DRIVER; } AUDIO_DRIVER;
static const AUDIO_DRIVER sAudioDrivers[] = { static AUDIO_DRIVER sAudioDrivers[] = {
{IDS_DRIVER_ALSA, "alsa"}, {IDS_DRIVER_ALSA, "alsa"},
{IDS_DRIVER_OSS, "oss"}, {IDS_DRIVER_OSS, "oss"},
{IDS_DRIVER_COREAUDIO, "coreaudio"}, {IDS_DRIVER_COREAUDIO, "coreaudio"},
...@@ -118,7 +119,7 @@ static void configureAudioDriver(HWND hDlg) ...@@ -118,7 +119,7 @@ static void configureAudioDriver(HWND hDlg)
HDRVR hdrvr; HDRVR hdrvr;
char wine_driver[MAX_NAME_LENGTH + 9]; char wine_driver[MAX_NAME_LENGTH + 9];
sprintf(wine_driver, "wine%s.drv", pAudioDrv->szDriver); sprintf(wine_driver, "wine%s.drv", pAudioDrv->szDriver);
hdrvr = OpenDriverA(wine_driver, 0, 0); hdrvr = pAudioDrv->hDriver;
if (hdrvr != 0) if (hdrvr != 0)
{ {
if (SendDriverMessage(hdrvr, DRV_QUERYCONFIGURE, 0, 0) != 0) if (SendDriverMessage(hdrvr, DRV_QUERYCONFIGURE, 0, 0) != 0)
...@@ -129,7 +130,6 @@ static void configureAudioDriver(HWND hDlg) ...@@ -129,7 +130,6 @@ static void configureAudioDriver(HWND hDlg)
dci.lpszDCIAliasName = NULL; dci.lpszDCIAliasName = NULL;
SendDriverMessage(hdrvr, DRV_CONFIGURE, 0, (LONG_PTR)&dci); SendDriverMessage(hdrvr, DRV_CONFIGURE, 0, (LONG_PTR)&dci);
} }
CloseDriver(hdrvr, 0, 0);
} }
else else
{ {
...@@ -197,7 +197,7 @@ static void removeDriver(const char * driver) ...@@ -197,7 +197,7 @@ static void removeDriver(const char * driver)
static void initAudioDeviceTree(HWND hDlg) static void initAudioDeviceTree(HWND hDlg)
{ {
const AUDIO_DRIVER *pAudioDrv = NULL; AUDIO_DRIVER *pAudioDrv = NULL;
int i, j; int i, j;
TVINSERTSTRUCTW insert; TVINSERTSTRUCTW insert;
HTREEITEM root, driver[10]; HTREEITEM root, driver[10];
...@@ -247,7 +247,7 @@ static void initAudioDeviceTree(HWND hDlg) ...@@ -247,7 +247,7 @@ static void initAudioDeviceTree(HWND hDlg)
LoadStringW (GetModuleHandle (NULL), pAudioDrv->nameID, text, LoadStringW (GetModuleHandle (NULL), pAudioDrv->nameID, text,
sizeof(text)/sizeof(text[0])); sizeof(text)/sizeof(text[0]));
if ((hdrv = OpenDriverA(name, 0, 0))) if ((hdrv = pAudioDrv->hDriver))
{ {
HMODULE lib; HMODULE lib;
if ((lib = GetDriverModuleHandle(hdrv))) if ((lib = GetDriverModuleHandle(hdrv)))
...@@ -473,7 +473,6 @@ static void initAudioDeviceTree(HWND hDlg) ...@@ -473,7 +473,6 @@ static void initAudioDeviceTree(HWND hDlg)
} }
} }
} }
CloseDriver(hdrv, 0, 0);
} }
} }
...@@ -490,7 +489,7 @@ static void initAudioDeviceTree(HWND hDlg) ...@@ -490,7 +489,7 @@ static void initAudioDeviceTree(HWND hDlg)
static void findAudioDrivers(void) static void findAudioDrivers(void)
{ {
int numFound = 0; int numFound = 0;
const AUDIO_DRIVER *pAudioDrv = NULL; AUDIO_DRIVER *pAudioDrv = NULL;
HCURSOR old_cursor; HCURSOR old_cursor;
/* delete an existing list */ /* delete an existing list */
...@@ -511,10 +510,38 @@ static void findAudioDrivers(void) ...@@ -511,10 +510,38 @@ static void findAudioDrivers(void)
sprintf(driver, "wine%s.drv", pAudioDrv->szDriver); sprintf(driver, "wine%s.drv", pAudioDrv->szDriver);
if ((hdrv = OpenDriverA(driver, 0, 0))) hdrv = pAudioDrv->hDriver;
{ if (!pAudioDrv->hDriver && (hdrv = OpenDriverA(driver, 0, 0))) {
CloseDriver(hdrv, 0, 0); HMODULE lib = GetDriverModuleHandle(hdrv);
MessagePtr wodMessagePtr = (MessagePtr)GetProcAddress(lib, "wodMessage");
MessagePtr widMessagePtr = (MessagePtr)GetProcAddress(lib, "widMessage");
MessagePtr modMessagePtr = (MessagePtr)GetProcAddress(lib, "modMessage");
MessagePtr midMessagePtr = (MessagePtr)GetProcAddress(lib, "midMessage");
MessagePtr auxMessagePtr = (MessagePtr)GetProcAddress(lib, "auxMessage");
MessagePtr mxdMessagePtr = (MessagePtr)GetProcAddress(lib, "mxdMessage");
pAudioDrv->hDriver = hdrv;
if (wodMessagePtr)
wodMessagePtr(0, DRVM_INIT, 0, 0, 0);
if (widMessagePtr)
widMessagePtr(0, DRVM_INIT, 0, 0, 0);
if (modMessagePtr)
modMessagePtr(0, DRVM_INIT, 0, 0, 0);
if (midMessagePtr)
midMessagePtr(0, DRVM_INIT, 0, 0, 0);
if (auxMessagePtr)
auxMessagePtr(0, DRVM_INIT, 0, 0, 0);
if (mxdMessagePtr)
mxdMessagePtr(0, DRVM_INIT, 0, 0, 0);
}
if (hdrv)
{
if (loadedAudioDrv) if (loadedAudioDrv)
loadedAudioDrv = HeapReAlloc(GetProcessHeap(), 0, loadedAudioDrv, (numFound + 1) * sizeof(AUDIO_DRIVER)); loadedAudioDrv = HeapReAlloc(GetProcessHeap(), 0, loadedAudioDrv, (numFound + 1) * sizeof(AUDIO_DRIVER));
else else
......
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