Mercurial > mplayer.hg
annotate vidix/sysdep/libdha_win32.c @ 32188:bba9058031a0
Slightly restructure OSS audio check; fixes the warning:
tmp.c:2: warning: unused variable 'arg'
author | diego |
---|---|
date | Thu, 16 Sep 2010 14:57:04 +0000 |
parents | b77bfd94aaf3 |
children | 9d1734a75102 |
rev | line source |
---|---|
4164 | 1 /* |
30419 | 2 * MAPDEV.h - include file for VxD MAPDEV |
3 * Copyright (c) 1996 Vireo Software, Inc. | |
4 * Modified for libdha by Nick Kurshev. | |
5 * | |
6 * This file is part of MPlayer. | |
7 * | |
8 * MPlayer is free software; you can redistribute it and/or modify | |
9 * it under the terms of the GNU General Public License as published by | |
10 * the Free Software Foundation; either version 2 of the License, or | |
11 * (at your option) any later version. | |
12 * | |
13 * MPlayer is distributed in the hope that it will be useful, | |
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 * GNU General Public License for more details. | |
17 * | |
18 * You should have received a copy of the GNU General Public License along | |
19 * with MPlayer; if not, write to the Free Software Foundation, Inc., | |
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |
21 */ | |
4164 | 22 |
23 #include <windows.h> | |
12056 | 24 #include <ddk/ntddk.h> |
26994 | 25 #include "vidix/dhahelperwin/dhahelper.h" |
12056 | 26 |
4164 | 27 /* |
28 This is the request structure that applications use | |
29 to request services from the MAPDEV VxD. | |
30 */ | |
31 | |
25607
9d0b189ce1b2
Fix illegal identifiers: Names starting with __ or _ and uppercase are reserved
diego
parents:
22900
diff
changeset
|
32 typedef struct MapDevRequest |
4164 | 33 { |
34 DWORD mdr_ServiceID; /* supplied by caller */ | |
35 LPVOID mdr_PhysicalAddress; /* supplied by caller */ | |
36 DWORD mdr_SizeInBytes; /* supplied by caller */ | |
37 LPVOID mdr_LinearAddress; /* returned by VxD */ | |
38 WORD mdr_Selector; /* returned if 16-bit caller */ | |
39 WORD mdr_Status; /* MDR_xxxx code below */ | |
40 } MAPDEVREQUEST, *PMAPDEVREQUEST; | |
41 | |
42 #define MDR_SERVICE_MAP CTL_CODE(FILE_DEVICE_UNKNOWN, 1, METHOD_NEITHER, FILE_ANY_ACCESS) | |
43 #define MDR_SERVICE_UNMAP CTL_CODE(FILE_DEVICE_UNKNOWN, 2, METHOD_NEITHER, FILE_ANY_ACCESS) | |
44 | |
45 #define MDR_STATUS_SUCCESS 1 | |
46 #define MDR_STATUS_ERROR 0 | |
47 /*#include "winioctl.h"*/ | |
48 #define FILE_DEVICE_UNKNOWN 0x00000022 | |
49 #define METHOD_NEITHER 3 | |
50 | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28232
diff
changeset
|
51 |
28232
8df85ad26746
Add missing 'void' keyword to parameterless function declarations.
diego
parents:
27721
diff
changeset
|
52 int IsWinNT(void) { |
12056 | 53 OSVERSIONINFO OSVersionInfo; |
54 OSVersionInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); | |
55 GetVersionEx(&OSVersionInfo); | |
56 return OSVersionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28232
diff
changeset
|
57 } |
12056 | 58 |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28232
diff
changeset
|
59 static HANDLE hDriver = INVALID_HANDLE_VALUE; |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28232
diff
changeset
|
60 |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28232
diff
changeset
|
61 |
4164 | 62 /* Memory Map a piece of Real Memory */ |
10980 | 63 void *map_phys_mem(unsigned long base, unsigned long size) { |
12056 | 64 if(!IsWinNT()){ |
4164 | 65 HANDLE hDevice ; |
66 PVOID inBuf[1] ; /* buffer for struct pointer to VxD */ | |
67 DWORD cbBytesReturned ; /* count of bytes returned from VxD */ | |
68 MAPDEVREQUEST req ; /* map device request structure */ | |
69 const PCHAR VxDName = "\\\\.\\MAPDEV.VXD" ; | |
70 const PCHAR VxDNameAlreadyLoaded = "\\\\.\\MAPDEV" ; | |
71 | |
72 hDevice = CreateFile(VxDName, 0,0,0, | |
73 CREATE_NEW, FILE_FLAG_DELETE_ON_CLOSE, 0) ; | |
74 if (hDevice == INVALID_HANDLE_VALUE) | |
75 hDevice = CreateFile(VxDNameAlreadyLoaded, 0,0,0, | |
76 CREATE_NEW, FILE_FLAG_DELETE_ON_CLOSE, 0) ; | |
77 if (hDevice == INVALID_HANDLE_VALUE) { | |
78 fprintf(stderr, "Cannot open driver, error=%08lx\n", GetLastError()) ; | |
79 exit(1) ; } | |
80 | |
81 req.mdr_ServiceID = MDR_SERVICE_MAP ; | |
82 req.mdr_PhysicalAddress = (PVOID)base ; | |
83 req.mdr_SizeInBytes = size ; | |
84 inBuf[0] = &req ; | |
85 | |
86 if ( ! DeviceIoControl(hDevice, MDR_SERVICE_MAP, inBuf, sizeof(PVOID), | |
87 NULL, 0, &cbBytesReturned, NULL) ) { | |
88 fprintf(stderr, "Failed to map device\n") ; exit(1) ; } | |
89 | |
90 return (void*)req.mdr_LinearAddress ; | |
12056 | 91 } |
92 else{ | |
93 dhahelper_t dhahelper_priv; | |
94 DWORD dwBytesReturned; | |
95 dhahelper_priv.size = size; | |
96 dhahelper_priv.base = base; | |
97 if(hDriver==INVALID_HANDLE_VALUE)hDriver = CreateFile("\\\\.\\DHAHELPER",GENERIC_READ | GENERIC_WRITE,0,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL); | |
98 if (!DeviceIoControl(hDriver, IOCTL_DHAHELPER_MAPPHYSTOLIN, &dhahelper_priv,sizeof(dhahelper_t), &dhahelper_priv, sizeof(dhahelper_t),&dwBytesReturned, NULL)){ | |
17971 | 99 fprintf(stderr,"Unable to map the requested memory region.\n"); |
12056 | 100 return NULL; |
101 } | |
102 else return dhahelper_priv.ptr; | |
103 } | |
4164 | 104 } |
105 | |
12056 | 106 void unmap_phys_mem(void *ptr, unsigned long size) { |
107 if(IsWinNT()){ | |
108 dhahelper_t dhahelper_priv; | |
109 DWORD dwBytesReturned; | |
110 dhahelper_priv.ptr = ptr; | |
111 DeviceIoControl(hDriver, IOCTL_DHAHELPER_UNMAPPHYSADDR, &dhahelper_priv,sizeof(dhahelper_t), NULL, 0, &dwBytesReturned, NULL); | |
112 } | |
113 } |