mirror of
git://source.winehq.org/git/wine.git
synced 2024-10-03 01:33:42 +00:00
wineoss: Introduce a test_connect syscall.
Signed-off-by: Huw Davies <huw@codeweavers.com> Signed-off-by: Andrew Eikum <aeikum@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
70af1f774b
commit
13a1f17f88
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
struct test_connect_params params;
|
||||
|
||||
/* 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. */
|
||||
OSS_CALL(test_connect, ¶ms);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
TRACE("Priority_Preferred: Seems like valid OSS!\n");
|
||||
|
||||
return Priority_Preferred;
|
||||
return params.priority;
|
||||
}
|
||||
|
||||
static void set_device_guid(EDataFlow flow, HKEY drv_key, const WCHAR *key_name,
|
||||
|
|
94
dlls/wineoss.drv/oss.c
Normal file
94
dlls/wineoss.drv/oss.c
Normal file
|
@ -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,
|
||||
};
|
40
dlls/wineoss.drv/unixlib.h
Normal file
40
dlls/wineoss.drv/unixlib.h
Normal file
|
@ -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)
|
Loading…
Reference in a new issue