Signed-off-by: Andrew Eikum aeikum@codeweavers.com
On Thu, Mar 31, 2022 at 08:21:46AM +0100, Huw Davies wrote:
Signed-off-by: Huw Davies huw@codeweavers.com
dlls/wineoss.drv/Makefile.in | 4 +- dlls/wineoss.drv/mmdevdrv.c | 60 ++++++----------------- dlls/wineoss.drv/oss.c | 94 ++++++++++++++++++++++++++++++++++++ dlls/wineoss.drv/unixlib.h | 40 +++++++++++++++ 4 files changed, 153 insertions(+), 45 deletions(-) create mode 100644 dlls/wineoss.drv/oss.c create mode 100644 dlls/wineoss.drv/unixlib.h
diff --git a/dlls/wineoss.drv/Makefile.in b/dlls/wineoss.drv/Makefile.in index ce96ca73bf4..d48db94b929 100644 --- a/dlls/wineoss.drv/Makefile.in +++ b/dlls/wineoss.drv/Makefile.in @@ -1,5 +1,6 @@ EXTRADEFS = -DWINE_NO_LONG_TYPES MODULE = wineoss.drv +UNIXLIB = wineoss.so IMPORTS = uuid ole32 user32 advapi32 DELAYIMPORTS = winmm EXTRALIBS = $(OSS4_LIBS) @@ -11,4 +12,5 @@ C_SRCS = \ midi.c \ midipatch.c \ mmaux.c \
- mmdevdrv.c
- mmdevdrv.c \
- oss.c
diff --git a/dlls/wineoss.drv/mmdevdrv.c b/dlls/wineoss.drv/mmdevdrv.c index b340db00c3c..0269f0fa536 100644 --- a/dlls/wineoss.drv/mmdevdrv.c +++ b/dlls/wineoss.drv/mmdevdrv.c @@ -1,5 +1,6 @@ /*
- Copyright 2011 Andrew Eikum for CodeWeavers
2022 Huw Davies
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
@@ -35,10 +36,9 @@
#include "windef.h" #include "winbase.h" +#include "winternl.h" #include "winnls.h" #include "winreg.h" -#include "wine/debug.h" -#include "wine/list.h"
#include "ole2.h" #include "mmdeviceapi.h" @@ -51,10 +51,18 @@ #include "audiopolicy.h" #include "audioclient.h"
+#include "wine/debug.h" +#include "wine/list.h" +#include "wine/unixlib.h"
+#include "unixlib.h"
WINE_DEFAULT_DEBUG_CHANNEL(oss);
#define NULL_PTR_ERR MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, RPC_X_NULL_REF_POINTER)
+unixlib_handle_t oss_handle = 0;
static const REFERENCE_TIME DefaultPeriod = 100000; static const REFERENCE_TIME MinimumPeriod = 50000;
@@ -233,6 +241,9 @@ BOOL WINAPI DllMain(HINSTANCE dll, DWORD reason, void *reserved) switch (reason) { case DLL_PROCESS_ATTACH:
if(NtQueryVirtualMemory(GetCurrentProcess(), dll, MemoryWineUnixFuncs,
&oss_handle, sizeof(oss_handle), NULL))
return FALSE; g_timer_q = CreateTimerQueue(); if(!g_timer_q) return FALSE;
@@ -254,52 +265,13 @@ BOOL WINAPI DllMain(HINSTANCE dll, DWORD reason, void *reserved) return TRUE; }
-/* From <dlls/mmdevapi/mmdevapi.h> */ -enum DriverPriority {
- Priority_Unavailable = 0,
- Priority_Low,
- Priority_Neutral,
- Priority_Preferred
-};
int WINAPI AUDDRV_GetPriority(void) {
- int mixer_fd;
- oss_sysinfo sysinfo;
- /* Attempt to determine if we are running on OSS or ALSA's OSS
* compatibility layer. There is no official way to do that, so just check
* for validity as best as possible, without rejecting valid OSS
* implementations. */
- mixer_fd = open("/dev/mixer", O_RDONLY, 0);
- if(mixer_fd < 0){
TRACE("Priority_Unavailable: open failed\n");
return Priority_Unavailable;
- }
- sysinfo.version[0] = 0xFF;
- sysinfo.versionnum = ~0;
- if(ioctl(mixer_fd, SNDCTL_SYSINFO, &sysinfo) < 0){
TRACE("Priority_Unavailable: ioctl failed\n");
close(mixer_fd);
return Priority_Unavailable;
- }
- close(mixer_fd);
- if(sysinfo.version[0] < '4' || sysinfo.version[0] > '9'){
TRACE("Priority_Low: sysinfo.version[0]: %x\n", sysinfo.version[0]);
return Priority_Low;
- }
- if(sysinfo.versionnum & 0x80000000){
TRACE("Priority_Low: sysinfo.versionnum: %x\n", sysinfo.versionnum);
return Priority_Low;
- }
- struct test_connect_params params;
- TRACE("Priority_Preferred: Seems like valid OSS!\n");
- OSS_CALL(test_connect, ¶ms);
- return Priority_Preferred;
- return params.priority;
}
static void set_device_guid(EDataFlow flow, HKEY drv_key, const WCHAR *key_name, diff --git a/dlls/wineoss.drv/oss.c b/dlls/wineoss.drv/oss.c new file mode 100644 index 00000000000..9c1de25acb5 --- /dev/null +++ b/dlls/wineoss.drv/oss.c @@ -0,0 +1,94 @@ +/*
- OSS driver (unixlib)
- Copyright 2011 Andrew Eikum for CodeWeavers
2022 Huw Davies
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
- */
+#if 0 +#pragma makedep unix +#endif
+#include <stdarg.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <sys/ioctl.h> +#include <fcntl.h> +#include <unistd.h> +#include <sys/soundcard.h>
+#include "ntstatus.h" +#define WIN32_NO_STATUS +#include "winternl.h"
+#include "wine/debug.h" +#include "wine/unixlib.h"
+#include "unixlib.h"
+WINE_DEFAULT_DEBUG_CHANNEL(oss);
+static NTSTATUS test_connect(void *args) +{
- struct test_connect_params *params = args;
- int mixer_fd;
- oss_sysinfo sysinfo;
- /* Attempt to determine if we are running on OSS or ALSA's OSS
* compatibility layer. There is no official way to do that, so just check
* for validity as best as possible, without rejecting valid OSS
* implementations. */
- mixer_fd = open("/dev/mixer", O_RDONLY, 0);
- if(mixer_fd < 0){
TRACE("Priority_Unavailable: open failed\n");
params->priority = Priority_Unavailable;
return STATUS_SUCCESS;
- }
- sysinfo.version[0] = 0xFF;
- sysinfo.versionnum = ~0;
- if(ioctl(mixer_fd, SNDCTL_SYSINFO, &sysinfo) < 0){
TRACE("Priority_Unavailable: ioctl failed\n");
close(mixer_fd);
params->priority = Priority_Unavailable;
return STATUS_SUCCESS;
- }
- close(mixer_fd);
- if(sysinfo.version[0] < '4' || sysinfo.version[0] > '9'){
TRACE("Priority_Low: sysinfo.version[0]: %x\n", sysinfo.version[0]);
params->priority = Priority_Low;
return STATUS_SUCCESS;
- }
- if(sysinfo.versionnum & 0x80000000){
TRACE("Priority_Low: sysinfo.versionnum: %x\n", sysinfo.versionnum);
params->priority = Priority_Low;
return STATUS_SUCCESS;
- }
- TRACE("Priority_Preferred: Seems like valid OSS!\n");
- params->priority = Priority_Preferred;
- return STATUS_SUCCESS;
+}
+unixlib_entry_t __wine_unix_call_funcs[] = +{
- test_connect,
+}; diff --git a/dlls/wineoss.drv/unixlib.h b/dlls/wineoss.drv/unixlib.h new file mode 100644 index 00000000000..d4fb5db3102 --- /dev/null +++ b/dlls/wineoss.drv/unixlib.h @@ -0,0 +1,40 @@ +/*
- Copyright 2022 Huw Davies
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
- */
+/* From <dlls/mmdevapi/mmdevapi.h> */ +enum DriverPriority +{
- Priority_Unavailable = 0,
- Priority_Low,
- Priority_Neutral,
- Priority_Preferred
+};
+struct test_connect_params +{
- enum DriverPriority priority;
+};
+enum oss_funcs +{
- oss_test_connect,
+};
+extern unixlib_handle_t oss_handle;
+#define OSS_CALL(func, params) __wine_unix_call(oss_handle, oss_ ## func, params)
2.25.1