The goal is to eventually move all interfaces from each driver's `mmdevdrv.c` into `mmdevapi`.
-- v5: wine{alsa,coreaudio,oss,pulse}: Move test_connect handling into mmdevapi. mmdevapi: Use UTF-16 for client name in "test_connect_params" and "create_stream_params" structs. winepulse: Move process_attach and process_detach handling into mmdevapi. mmdevapi: Query MemoryWineUnixFuncs virtual memory and store the resulting handle. wine{alsa,coreaudio,oss,pulse}: Return STATUS_SUCCESS for unused unixlib functions.
From: Davide Beatrici git@davidebeatrici.dev
--- dlls/winealsa.drv/alsa.c | 33 ++++++++++++++---------- dlls/winecoreaudio.drv/coreaudio.c | 41 +++++++++++++++++------------- dlls/wineoss.drv/oss.c | 29 ++++++++++++--------- dlls/winepulse.drv/pulse.c | 33 ++++++++++++++---------- 4 files changed, 78 insertions(+), 58 deletions(-)
diff --git a/dlls/winealsa.drv/alsa.c b/dlls/winealsa.drv/alsa.c index ffa39f5e484..2b5f61eb213 100644 --- a/dlls/winealsa.drv/alsa.c +++ b/dlls/winealsa.drv/alsa.c @@ -88,6 +88,11 @@ static const WCHAR drv_keyW[] = {'S','o','f','t','w','a','r','e','\', 'W','i','n','e','\','D','r','i','v','e','r','s','\', 'w','i','n','e','a','l','s','a','.','d','r','v'};
+static NTSTATUS alsa_not_implemented(void *args) +{ + return STATUS_SUCCESS; +} + static inline void ascii_to_unicode( WCHAR *dst, const char *src, size_t len ) { while (len--) *dst++ = (unsigned char)*src++; @@ -2431,9 +2436,9 @@ static NTSTATUS alsa_get_prop_value(void *args)
unixlib_entry_t __wine_unix_call_funcs[] = { - NULL, - NULL, - NULL, + alsa_not_implemented, + alsa_not_implemented, + alsa_not_implemented, alsa_get_endpoint_ids, alsa_create_stream, alsa_release_stream, @@ -2447,7 +2452,7 @@ unixlib_entry_t __wine_unix_call_funcs[] = alsa_release_capture_buffer, alsa_is_format_supported, alsa_get_mix_format, - NULL, + alsa_not_implemented, alsa_get_buffer_size, alsa_get_latency, alsa_get_current_padding, @@ -2456,15 +2461,15 @@ unixlib_entry_t __wine_unix_call_funcs[] = alsa_get_position, alsa_set_volumes, alsa_set_event_handle, - NULL, + alsa_not_implemented, alsa_is_started, alsa_get_prop_value, - NULL, + alsa_not_implemented, alsa_midi_release, alsa_midi_out_message, alsa_midi_in_message, alsa_midi_notify_wait, - NULL, + alsa_not_implemented, };
#ifdef _WIN64 @@ -2852,9 +2857,9 @@ static NTSTATUS alsa_wow64_get_prop_value(void *args)
unixlib_entry_t __wine_unix_call_wow64_funcs[] = { - NULL, - NULL, - NULL, + alsa_not_implemented, + alsa_not_implemented, + alsa_not_implemented, alsa_wow64_get_endpoint_ids, alsa_wow64_create_stream, alsa_wow64_release_stream, @@ -2868,7 +2873,7 @@ unixlib_entry_t __wine_unix_call_wow64_funcs[] = alsa_release_capture_buffer, alsa_wow64_is_format_supported, alsa_wow64_get_mix_format, - NULL, + alsa_not_implemented, alsa_wow64_get_buffer_size, alsa_wow64_get_latency, alsa_wow64_get_current_padding, @@ -2877,15 +2882,15 @@ unixlib_entry_t __wine_unix_call_wow64_funcs[] = alsa_wow64_get_position, alsa_wow64_set_volumes, alsa_wow64_set_event_handle, - NULL, + alsa_not_implemented, alsa_is_started, alsa_wow64_get_prop_value, - NULL, + alsa_not_implemented, alsa_midi_release, alsa_wow64_midi_out_message, alsa_wow64_midi_in_message, alsa_wow64_midi_notify_wait, - NULL, + alsa_not_implemented, };
#endif /* _WIN64 */ diff --git a/dlls/winecoreaudio.drv/coreaudio.c b/dlls/winecoreaudio.drv/coreaudio.c index b48a0c751fd..073dacf4bad 100644 --- a/dlls/winecoreaudio.drv/coreaudio.c +++ b/dlls/winecoreaudio.drv/coreaudio.c @@ -96,6 +96,11 @@ struct coreaudio_stream BYTE *local_buffer, *cap_buffer, *wrap_buffer, *resamp_buffer, *tmp_buffer; };
+static NTSTATUS unix_not_implemented(void *args) +{ + return STATUS_SUCCESS; +} + static HRESULT osstatus_to_hresult(OSStatus sc) { switch(sc){ @@ -1647,23 +1652,23 @@ static NTSTATUS unix_set_volumes(void *args)
unixlib_entry_t __wine_unix_call_funcs[] = { - NULL, - NULL, - NULL, + unix_not_implemented, + unix_not_implemented, + unix_not_implemented, unix_get_endpoint_ids, unix_create_stream, unix_release_stream, unix_start, unix_stop, unix_reset, - NULL, + unix_not_implemented, unix_get_render_buffer, unix_release_render_buffer, unix_get_capture_buffer, unix_release_capture_buffer, unix_is_format_supported, unix_get_mix_format, - NULL, + unix_not_implemented, unix_get_buffer_size, unix_get_latency, unix_get_current_padding, @@ -1671,16 +1676,16 @@ unixlib_entry_t __wine_unix_call_funcs[] = unix_get_frequency, unix_get_position, unix_set_volumes, - NULL, - NULL, + unix_not_implemented, + unix_not_implemented, unix_is_started, - NULL, + unix_not_implemented, unix_midi_init, unix_midi_release, unix_midi_out_message, unix_midi_in_message, unix_midi_notify_wait, - NULL, + unix_not_implemented, };
#ifdef _WIN64 @@ -1991,23 +1996,23 @@ static NTSTATUS unix_wow64_set_volumes(void *args)
unixlib_entry_t __wine_unix_call_wow64_funcs[] = { - NULL, - NULL, - NULL, + unix_not_implemented, + unix_not_implemented, + unix_not_implemented, unix_wow64_get_endpoint_ids, unix_wow64_create_stream, unix_wow64_release_stream, unix_start, unix_stop, unix_reset, - NULL, + unix_not_implemented, unix_wow64_get_render_buffer, unix_release_render_buffer, unix_wow64_get_capture_buffer, unix_release_capture_buffer, unix_wow64_is_format_supported, unix_wow64_get_mix_format, - NULL, + unix_not_implemented, unix_wow64_get_buffer_size, unix_wow64_get_latency, unix_wow64_get_current_padding, @@ -2015,16 +2020,16 @@ unixlib_entry_t __wine_unix_call_wow64_funcs[] = unix_wow64_get_frequency, unix_wow64_get_position, unix_wow64_set_volumes, - NULL, - NULL, + unix_not_implemented, + unix_not_implemented, unix_is_started, - NULL, + unix_not_implemented, unix_wow64_midi_init, unix_midi_release, unix_wow64_midi_out_message, unix_wow64_midi_in_message, unix_wow64_midi_notify_wait, - NULL, + unix_not_implemented, };
#endif /* _WIN64 */ diff --git a/dlls/wineoss.drv/oss.c b/dlls/wineoss.drv/oss.c index 4bc8bc20666..65ca42c3182 100644 --- a/dlls/wineoss.drv/oss.c +++ b/dlls/wineoss.drv/oss.c @@ -69,6 +69,11 @@ struct oss_stream
WINE_DEFAULT_DEBUG_CHANNEL(oss);
+static NTSTATUS oss_not_implemented(void *args) +{ + return STATUS_SUCCESS; +} + /* copied from kernelbase */ static int muldiv( int a, int b, int c ) { @@ -1612,9 +1617,9 @@ static NTSTATUS oss_aux_message(void *args)
unixlib_entry_t __wine_unix_call_funcs[] = { - NULL, - NULL, - NULL, + oss_not_implemented, + oss_not_implemented, + oss_not_implemented, oss_get_endpoint_ids, oss_create_stream, oss_release_stream, @@ -1628,7 +1633,7 @@ unixlib_entry_t __wine_unix_call_funcs[] = oss_release_capture_buffer, oss_is_format_supported, oss_get_mix_format, - NULL, + oss_not_implemented, oss_get_buffer_size, oss_get_latency, oss_get_current_padding, @@ -1639,8 +1644,8 @@ unixlib_entry_t __wine_unix_call_funcs[] = oss_set_event_handle, oss_test_connect, oss_is_started, - NULL, - NULL, + oss_not_implemented, + oss_not_implemented, oss_midi_release, oss_midi_out_message, oss_midi_in_message, @@ -2016,9 +2021,9 @@ static NTSTATUS oss_wow64_aux_message(void *args)
unixlib_entry_t __wine_unix_call_wow64_funcs[] = { - NULL, - NULL, - NULL, + oss_not_implemented, + oss_not_implemented, + oss_not_implemented, oss_wow64_get_endpoint_ids, oss_wow64_create_stream, oss_wow64_release_stream, @@ -2032,7 +2037,7 @@ unixlib_entry_t __wine_unix_call_wow64_funcs[] = oss_release_capture_buffer, oss_wow64_is_format_supported, oss_wow64_get_mix_format, - NULL, + oss_not_implemented, oss_wow64_get_buffer_size, oss_wow64_get_latency, oss_wow64_get_current_padding, @@ -2043,8 +2048,8 @@ unixlib_entry_t __wine_unix_call_wow64_funcs[] = oss_wow64_set_event_handle, oss_wow64_test_connect, oss_is_started, - NULL, - NULL, + oss_not_implemented, + oss_not_implemented, oss_midi_release, oss_wow64_midi_out_message, oss_wow64_midi_in_message, diff --git a/dlls/winepulse.drv/pulse.c b/dlls/winepulse.drv/pulse.c index 9446feb452c..900b77415a8 100644 --- a/dlls/winepulse.drv/pulse.c +++ b/dlls/winepulse.drv/pulse.c @@ -119,6 +119,11 @@ static const REFERENCE_TIME DefaultPeriod = 100000; static pthread_mutex_t pulse_mutex; static pthread_cond_t pulse_cond = PTHREAD_COND_INITIALIZER;
+static NTSTATUS pulse_not_implemented(void *args) +{ + return STATUS_SUCCESS; +} + static void pulse_lock(void) { pthread_mutex_lock(&pulse_mutex); @@ -2373,7 +2378,7 @@ const unixlib_entry_t __wine_unix_call_funcs[] = pulse_release_render_buffer, pulse_get_capture_buffer, pulse_release_capture_buffer, - NULL, + pulse_not_implemented, pulse_get_mix_format, pulse_get_device_period, pulse_get_buffer_size, @@ -2387,12 +2392,12 @@ const unixlib_entry_t __wine_unix_call_funcs[] = pulse_test_connect, pulse_is_started, pulse_get_prop_value, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, + pulse_not_implemented, + pulse_not_implemented, + pulse_not_implemented, + pulse_not_implemented, + pulse_not_implemented, + pulse_not_implemented, };
#ifdef _WIN64 @@ -2820,7 +2825,7 @@ const unixlib_entry_t __wine_unix_call_wow64_funcs[] = pulse_release_render_buffer, pulse_wow64_get_capture_buffer, pulse_release_capture_buffer, - NULL, + pulse_not_implemented, pulse_wow64_get_mix_format, pulse_wow64_get_device_period, pulse_wow64_get_buffer_size, @@ -2834,12 +2839,12 @@ const unixlib_entry_t __wine_unix_call_wow64_funcs[] = pulse_wow64_test_connect, pulse_is_started, pulse_wow64_get_prop_value, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, + pulse_not_implemented, + pulse_not_implemented, + pulse_not_implemented, + pulse_not_implemented, + pulse_not_implemented, + pulse_not_implemented, };
#endif /* _WIN64 */
From: Davide Beatrici git@davidebeatrici.dev
In preparation for calling the audio driver's UNIX functions directly. --- dlls/mmdevapi/main.c | 12 +++++++++++- dlls/mmdevapi/mmdevapi.h | 4 ++++ 2 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/dlls/mmdevapi/main.c b/dlls/mmdevapi/main.c index c792661af33..b019d2e427c 100644 --- a/dlls/mmdevapi/main.c +++ b/dlls/mmdevapi/main.c @@ -65,6 +65,7 @@ static const char *get_priority_string(int prio)
static BOOL load_driver(const WCHAR *name, DriverFuncs *driver) { + NTSTATUS status; WCHAR driver_module[264];
lstrcpyW(driver_module, L"wine"); @@ -80,8 +81,14 @@ static BOOL load_driver(const WCHAR *name, DriverFuncs *driver) return FALSE; }
+ if ((status = NtQueryVirtualMemory(GetCurrentProcess(), driver->module, MemoryWineUnixFuncs, + &driver->module_unixlib, sizeof(driver->module_unixlib), NULL))) { + ERR("Unable to load UNIX functions: %lx\n", status); + goto fail; + } + #define LDFC(n) do { driver->p##n = (void*)GetProcAddress(driver->module, #n);\ - if(!driver->p##n) { FreeLibrary(driver->module); return FALSE; } } while(0) + if(!driver->p##n) { goto fail; } } while(0) LDFC(GetPriority); LDFC(GetEndpointIDs); LDFC(GetAudioEndpoint); @@ -98,6 +105,9 @@ static BOOL load_driver(const WCHAR *name, DriverFuncs *driver) wine_dbgstr_w(driver_module), get_priority_string(driver->priority));
return TRUE; +fail: + FreeLibrary(driver->module); + return FALSE; }
static BOOL WINAPI init_driver(INIT_ONCE *once, void *param, void **context) diff --git a/dlls/mmdevapi/mmdevapi.h b/dlls/mmdevapi/mmdevapi.h index d694a3930aa..16eb3606fea 100644 --- a/dlls/mmdevapi/mmdevapi.h +++ b/dlls/mmdevapi/mmdevapi.h @@ -18,13 +18,17 @@
#include "unixlib.h"
+#include <winternl.h> + #include <wine/list.h> +#include <wine/unixlib.h>
extern HRESULT MMDevEnum_Create(REFIID riid, void **ppv) DECLSPEC_HIDDEN; extern void MMDevEnum_Free(void) DECLSPEC_HIDDEN;
typedef struct _DriverFuncs { HMODULE module; + unixlib_handle_t module_unixlib; WCHAR module_name[64]; int priority;
From: Davide Beatrici git@davidebeatrici.dev
--- dlls/mmdevapi/main.c | 18 +++++++++++++++--- dlls/winepulse.drv/mmdevdrv.c | 4 +--- 2 files changed, 16 insertions(+), 6 deletions(-)
diff --git a/dlls/mmdevapi/main.c b/dlls/mmdevapi/main.c index b019d2e427c..d71b7948428 100644 --- a/dlls/mmdevapi/main.c +++ b/dlls/mmdevapi/main.c @@ -19,7 +19,9 @@
#include <stdarg.h>
+#include "ntstatus.h" #define COBJMACROS +#define WIN32_NO_STATUS #include "windef.h" #include "winbase.h" #include "wingdi.h" @@ -87,6 +89,11 @@ static BOOL load_driver(const WCHAR *name, DriverFuncs *driver) goto fail; }
+ if ((status = __wine_unix_call(driver->module_unixlib, process_attach, NULL))) { + ERR("Unable to initialize library: %lx\n", status); + goto fail; + } + #define LDFC(n) do { driver->p##n = (void*)GetProcAddress(driver->module, #n);\ if(!driver->p##n) { goto fail; } } while(0) LDFC(GetPriority); @@ -177,9 +184,14 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) DisableThreadLibraryCalls(hinstDLL); break; case DLL_PROCESS_DETACH: - if(lpvReserved) - break; - MMDevEnum_Free(); + if (drvs.module_unixlib) { + const NTSTATUS status = __wine_unix_call(drvs.module_unixlib, process_detach, NULL); + if (status) + WARN("Unable to deinitialize library: %lx\n", status); + } + + if (!lpvReserved) + MMDevEnum_Free(); break; }
diff --git a/dlls/winepulse.drv/mmdevdrv.c b/dlls/winepulse.drv/mmdevdrv.c index 5de9a941099..99dbe24c82f 100644 --- a/dlls/winepulse.drv/mmdevdrv.c +++ b/dlls/winepulse.drv/mmdevdrv.c @@ -87,14 +87,12 @@ BOOL WINAPI DllMain(HINSTANCE dll, DWORD reason, void *reserved) DisableThreadLibraryCalls(dll); if (__wine_init_unix_call()) return FALSE; - if (WINE_UNIX_CALL(process_attach, NULL)) - return FALSE; } else if (reason == DLL_PROCESS_DETACH) { struct device_cache *device, *device_next;
LIST_FOR_EACH_ENTRY_SAFE(device, device_next, &g_devices_cache, struct device_cache, entry) free(device); - WINE_UNIX_CALL(process_detach, NULL); + if (pulse_thread) { WaitForSingleObject(pulse_thread, INFINITE); CloseHandle(pulse_thread);
From: Davide Beatrici git@davidebeatrici.dev
The conversion to another encoding is now up to the unixlib. --- dlls/mmdevapi/unixlib.h | 4 ++-- dlls/winepulse.drv/mmdevdrv.c | 23 ++++++----------------- dlls/winepulse.drv/pulse.c | 21 +++++++++++++++++++-- 3 files changed, 27 insertions(+), 21 deletions(-)
diff --git a/dlls/mmdevapi/unixlib.h b/dlls/mmdevapi/unixlib.h index ea0d2f9c4b9..37b4c53cb35 100644 --- a/dlls/mmdevapi/unixlib.h +++ b/dlls/mmdevapi/unixlib.h @@ -53,7 +53,7 @@ struct get_endpoint_ids_params
struct create_stream_params { - const char *name; + const WCHAR *name; const char *device; EDataFlow flow; AUDCLNT_SHAREMODE share; @@ -219,7 +219,7 @@ struct set_event_handle_params
struct test_connect_params { - const char *name; + const WCHAR *name; enum driver_priority priority; };
diff --git a/dlls/winepulse.drv/mmdevdrv.c b/dlls/winepulse.drv/mmdevdrv.c index 99dbe24c82f..9a6939e959c 100644 --- a/dlls/winepulse.drv/mmdevdrv.c +++ b/dlls/winepulse.drv/mmdevdrv.c @@ -23,6 +23,7 @@
#include <stdarg.h> #include <assert.h> +#include <wchar.h>
#include "windef.h" #include "winbase.h" @@ -247,11 +248,9 @@ static BOOL query_productname(void *data, LANGANDCODEPAGE *lang, LPVOID *buffer, return VerQueryValueW(data, pn, buffer, len) && *len; }
-static char *get_application_name(BOOL query_app_name) +static WCHAR *get_application_name(BOOL query_app_name) { WCHAR path[MAX_PATH], *name; - char *str = NULL; - size_t len;
GetModuleFileNameW(NULL, path, ARRAY_SIZE(path));
@@ -327,15 +326,9 @@ static char *get_application_name(BOOL query_app_name) } }
- if (found) { - len = WideCharToMultiByte(CP_UTF8, 0, productname, -1, NULL, 0, NULL, NULL); - str = malloc(len); - if (str) WideCharToMultiByte(CP_UTF8, 0, productname, -1, str, len, NULL, NULL); - } - skip: free(data); - if (str) return str; + if (found) return wcsdup(productname); }
name = wcsrchr(path, '\'); @@ -343,11 +336,7 @@ static char *get_application_name(BOOL query_app_name) name = path; else name++; - len = WideCharToMultiByte(CP_UTF8, 0, name, -1, NULL, 0, NULL, NULL); - if (!(str = malloc(len))) - return NULL; - WideCharToMultiByte(CP_UNIXCP, 0, name, -1, str, len, NULL, NULL); - return str; + return wcsdup(name); }
static DWORD WINAPI pulse_timer_cb(void *user) @@ -481,7 +470,7 @@ end: int WINAPI AUDDRV_GetPriority(void) { struct test_connect_params params; - char *name; + WCHAR *name;
params.name = name = get_application_name(FALSE); pulse_call(test_connect, ¶ms); @@ -817,7 +806,7 @@ static HRESULT WINAPI AudioClient_Initialize(IAudioClient3 *iface, struct create_stream_params params; unsigned int i, channel_count; stream_handle stream; - char *name; + WCHAR *name; HRESULT hr;
TRACE("(%p)->(%x, %lx, %s, %s, %p, %s)\n", This, mode, flags, diff --git a/dlls/winepulse.drv/pulse.c b/dlls/winepulse.drv/pulse.c index 900b77415a8..28afb5b788d 100644 --- a/dlls/winepulse.drv/pulse.c +++ b/dlls/winepulse.drv/pulse.c @@ -196,6 +196,14 @@ static int muldiv(int a, int b, int c) return ret; }
+static char *wstr_to_str(const WCHAR *wstr) +{ + const int len = wcslen(wstr); + char *str = malloc(len * 3 + 1); + ntdll_wcstoumbs(wstr, len + 1, str, len * 3 + 1, FALSE); + return str; +} + /* Following pulseaudio design here, mainloop has the lock taken whenever * it is handling something for pulse, and the lock is required whenever * doing any pa_* call that can affect the state in any way @@ -765,13 +773,17 @@ static NTSTATUS pulse_test_connect(void *args) PhysDevice *dev; pa_operation *o; int ret; + char *name = wstr_to_str(params->name);
pulse_lock(); pulse_ml = pa_mainloop_new();
pa_mainloop_set_poll_func(pulse_ml, pulse_poll_func, NULL);
- pulse_ctx = pa_context_new(pa_mainloop_get_api(pulse_ml), params->name); + pulse_ctx = pa_context_new(pa_mainloop_get_api(pulse_ml), name); + + free(name); + if (!pulse_ctx) { ERR("Failed to create context\n"); pa_mainloop_free(pulse_ml); @@ -1104,10 +1116,15 @@ static NTSTATUS pulse_create_stream(void *args) struct pulse_stream *stream; unsigned int i, bufsize_bytes; HRESULT hr; + char *name = wstr_to_str(params->name);
pulse_lock();
- if (FAILED(params->result = pulse_connect(params->name))) + params->result = pulse_connect(name); + + free(name); + + if (FAILED(params->result)) { pulse_unlock(); return STATUS_SUCCESS;
From: Davide Beatrici git@davidebeatrici.dev
--- dlls/mmdevapi/main.c | 18 +++++++++++++++--- dlls/mmdevapi/mmdevapi.h | 5 ++--- dlls/winealsa.drv/mmdevdrv.c | 5 ----- dlls/winealsa.drv/winealsa.drv.spec | 1 - dlls/winecoreaudio.drv/mmdevdrv.c | 5 ----- dlls/winecoreaudio.drv/winecoreaudio.drv.spec | 1 - dlls/wineoss.drv/mmdevdrv.c | 11 ----------- dlls/wineoss.drv/wineoss.drv.spec | 1 - dlls/winepulse.drv/mmdevdrv.c | 11 ----------- dlls/winepulse.drv/winepulse.drv.spec | 1 - 10 files changed, 17 insertions(+), 42 deletions(-)
diff --git a/dlls/mmdevapi/main.c b/dlls/mmdevapi/main.c index d71b7948428..179c18e422d 100644 --- a/dlls/mmdevapi/main.c +++ b/dlls/mmdevapi/main.c @@ -18,6 +18,7 @@ */
#include <stdarg.h> +#include <wchar.h>
#include "ntstatus.h" #define COBJMACROS @@ -68,7 +69,8 @@ static const char *get_priority_string(int prio) static BOOL load_driver(const WCHAR *name, DriverFuncs *driver) { NTSTATUS status; - WCHAR driver_module[264]; + WCHAR driver_module[264], path[MAX_PATH]; + struct test_connect_params params;
lstrcpyW(driver_module, L"wine"); lstrcatW(driver_module, name); @@ -96,7 +98,6 @@ static BOOL load_driver(const WCHAR *name, DriverFuncs *driver)
#define LDFC(n) do { driver->p##n = (void*)GetProcAddress(driver->module, #n);\ if(!driver->p##n) { goto fail; } } while(0) - LDFC(GetPriority); LDFC(GetEndpointIDs); LDFC(GetAudioEndpoint); LDFC(GetAudioSessionManager); @@ -105,7 +106,18 @@ static BOOL load_driver(const WCHAR *name, DriverFuncs *driver) /* optional - do not fail if not found */ driver->pGetPropValue = (void*)GetProcAddress(driver->module, "GetPropValue");
- driver->priority = driver->pGetPriority(); + GetModuleFileNameW(NULL, path, ARRAY_SIZE(path)); + params.name = wcsrchr(path, '\'); + params.name = params.name ? params.name + 1 : path; + params.priority = Priority_Neutral; + + if ((status = __wine_unix_call(driver->module_unixlib, test_connect, ¶ms))) { + ERR("Unable to retrieve driver priority: %lx\n", status); + goto fail; + } + + driver->priority = params.priority; + lstrcpyW(driver->module_name, driver_module);
TRACE("Successfully loaded %s with priority %s\n", diff --git a/dlls/mmdevapi/mmdevapi.h b/dlls/mmdevapi/mmdevapi.h index 16eb3606fea..cd5b5a25a55 100644 --- a/dlls/mmdevapi/mmdevapi.h +++ b/dlls/mmdevapi/mmdevapi.h @@ -30,13 +30,12 @@ typedef struct _DriverFuncs { HMODULE module; unixlib_handle_t module_unixlib; WCHAR module_name[64]; - int priority;
- /* Returns a "priority" value for the driver. Highest priority wins. + /* Highest priority wins. * If multiple drivers think they are valid, they will return a * priority value reflecting the likelihood that they are actually * valid. See enum _DriverPriority. */ - int (WINAPI *pGetPriority)(void); + int priority;
/* ids gets an array of human-friendly endpoint names * keys gets an array of driver-specific stuff that is used diff --git a/dlls/winealsa.drv/mmdevdrv.c b/dlls/winealsa.drv/mmdevdrv.c index ea48143005b..fb81faf9d00 100644 --- a/dlls/winealsa.drv/mmdevdrv.c +++ b/dlls/winealsa.drv/mmdevdrv.c @@ -212,11 +212,6 @@ BOOL WINAPI DllMain(HINSTANCE dll, DWORD reason, void *reserved) return TRUE; }
-int WINAPI AUDDRV_GetPriority(void) -{ - return Priority_Neutral; -} - static HRESULT alsa_stream_release(stream_handle stream, HANDLE timer_thread) { struct release_stream_params params; diff --git a/dlls/winealsa.drv/winealsa.drv.spec b/dlls/winealsa.drv/winealsa.drv.spec index bd83ea2e765..d846ade8ce2 100644 --- a/dlls/winealsa.drv/winealsa.drv.spec +++ b/dlls/winealsa.drv/winealsa.drv.spec @@ -4,7 +4,6 @@ @ stdcall -private modMessage(long long long long long) ALSA_modMessage
# MMDevAPI driver functions -@ stdcall -private GetPriority() AUDDRV_GetPriority @ stdcall -private GetEndpointIDs(long ptr ptr ptr ptr) AUDDRV_GetEndpointIDs @ stdcall -private GetAudioEndpoint(ptr ptr ptr) AUDDRV_GetAudioEndpoint @ stdcall -private GetAudioSessionManager(ptr ptr) AUDDRV_GetAudioSessionManager diff --git a/dlls/winecoreaudio.drv/mmdevdrv.c b/dlls/winecoreaudio.drv/mmdevdrv.c index 367f7ba0ab8..877c1f7c3bc 100644 --- a/dlls/winecoreaudio.drv/mmdevdrv.c +++ b/dlls/winecoreaudio.drv/mmdevdrv.c @@ -213,11 +213,6 @@ BOOL WINAPI DllMain(HINSTANCE dll, DWORD reason, void *reserved) return TRUE; }
-int WINAPI AUDDRV_GetPriority(void) -{ - return Priority_Neutral; -} - static void set_device_guid(EDataFlow flow, HKEY drv_key, const WCHAR *key_name, GUID *guid) { diff --git a/dlls/winecoreaudio.drv/winecoreaudio.drv.spec b/dlls/winecoreaudio.drv/winecoreaudio.drv.spec index 9d9f781cf4e..1dfbfb79eb9 100644 --- a/dlls/winecoreaudio.drv/winecoreaudio.drv.spec +++ b/dlls/winecoreaudio.drv/winecoreaudio.drv.spec @@ -4,7 +4,6 @@ @ stdcall -private modMessage(long long long long long) CoreAudio_modMessage
# MMDevAPI driver functions -@ stdcall -private GetPriority() AUDDRV_GetPriority @ stdcall -private GetEndpointIDs(long ptr ptr ptr ptr) AUDDRV_GetEndpointIDs @ stdcall -private GetAudioEndpoint(ptr ptr ptr) AUDDRV_GetAudioEndpoint @ stdcall -private GetAudioSessionManager(ptr ptr) AUDDRV_GetAudioSessionManager diff --git a/dlls/wineoss.drv/mmdevdrv.c b/dlls/wineoss.drv/mmdevdrv.c index 7411f87a4d7..6993fa88d0a 100644 --- a/dlls/wineoss.drv/mmdevdrv.c +++ b/dlls/wineoss.drv/mmdevdrv.c @@ -226,17 +226,6 @@ BOOL WINAPI DllMain(HINSTANCE dll, DWORD reason, void *reserved) return TRUE; }
-int WINAPI AUDDRV_GetPriority(void) -{ - struct test_connect_params params; - - params.name = NULL; - - OSS_CALL(test_connect, ¶ms); - - return params.priority; -} - static HRESULT stream_release(stream_handle stream, HANDLE timer_thread) { struct release_stream_params params; diff --git a/dlls/wineoss.drv/wineoss.drv.spec b/dlls/wineoss.drv/wineoss.drv.spec index fe6cc518c33..a093649e982 100644 --- a/dlls/wineoss.drv/wineoss.drv.spec +++ b/dlls/wineoss.drv/wineoss.drv.spec @@ -5,7 +5,6 @@ @ stdcall -private modMessage(long long long long long) OSS_modMessage
# MMDevAPI driver functions -@ stdcall -private GetPriority() AUDDRV_GetPriority @ stdcall -private GetEndpointIDs(long ptr ptr ptr ptr) AUDDRV_GetEndpointIDs @ stdcall -private GetAudioEndpoint(ptr ptr ptr) AUDDRV_GetAudioEndpoint @ stdcall -private GetAudioSessionManager(ptr ptr) AUDDRV_GetAudioSessionManager diff --git a/dlls/winepulse.drv/mmdevdrv.c b/dlls/winepulse.drv/mmdevdrv.c index 9a6939e959c..20fa08d3fa7 100644 --- a/dlls/winepulse.drv/mmdevdrv.c +++ b/dlls/winepulse.drv/mmdevdrv.c @@ -467,17 +467,6 @@ end: return params.result; }
-int WINAPI AUDDRV_GetPriority(void) -{ - struct test_connect_params params; - WCHAR *name; - - params.name = name = get_application_name(FALSE); - pulse_call(test_connect, ¶ms); - free(name); - return params.priority; -} - static BOOL get_pulse_name_by_guid(const GUID *guid, char pulse_name[MAX_PULSE_NAME_LEN], EDataFlow *flow) { struct device_cache *device; diff --git a/dlls/winepulse.drv/winepulse.drv.spec b/dlls/winepulse.drv/winepulse.drv.spec index 7aeb1756ed1..b822fd08353 100644 --- a/dlls/winepulse.drv/winepulse.drv.spec +++ b/dlls/winepulse.drv/winepulse.drv.spec @@ -1,5 +1,4 @@ # MMDevAPI driver functions -@ stdcall -private GetPriority() AUDDRV_GetPriority @ stdcall -private GetEndpointIDs(long ptr ptr ptr ptr) AUDDRV_GetEndpointIDs @ stdcall -private GetAudioEndpoint(ptr ptr ptr) AUDDRV_GetAudioEndpoint @ stdcall -private GetAudioSessionManager(ptr ptr) AUDDRV_GetAudioSessionManager
This merge request was approved by Huw Davies.