annotate loader/drv.c @ 27449:5723b671a0f6

Handle AOPLAY_FINAL_CHUNK
author ranma
date Sun, 24 Aug 2008 13:36:04 +0000
parents 0b21ffa03b9c
children b5a46071062a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
26999
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
1 /*
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
2 * Modified for use with MPlayer, detailed changelog at
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
3 * http://svn.mplayerhq.hu/mplayer/trunk/
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
4 */
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
5
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
6 #include "config.h"
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
7 #include "debug.h"
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
8
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
9 #include <stdio.h>
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
10 #ifdef HAVE_MALLOC_H
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
11 #include <malloc.h>
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
12 #endif
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
13 #include <stdlib.h>
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
14 #ifdef __FreeBSD__
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
15 #include <sys/time.h>
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
16 #endif
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
17
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
18 #include "win32.h"
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
19 #include "wine/driver.h"
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
20 #include "wine/pe_image.h"
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
21 #include "wine/winreg.h"
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
22 #include "wine/vfw.h"
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
23 #include "registry.h"
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
24 #ifdef WIN32_LOADER
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
25 #include "ldt_keeper.h"
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
26 #endif
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
27 #include "drv.h"
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
28 #ifndef __MINGW32__
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
29 #include "ext.h"
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
30 #endif
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
31
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
32 #ifndef WIN32_LOADER
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
33 char* def_path=WIN32_PATH;
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
34 #else
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
35 extern char* def_path;
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
36 #endif
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
37
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
38 #if 1
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
39
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
40 /*
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
41 * STORE_ALL/REST_ALL seems like an attempt to workaround problems due to
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
42 * WINAPI/no-WINAPI bustage.
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
43 *
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
44 * There should be no need for the STORE_ALL/REST_ALL hack once all
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
45 * function definitions agree with their prototypes (WINAPI-wise) and
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
46 * we make sure, that we do not call these functions without a proper
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
47 * prototype in scope.
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
48 */
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
49
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
50 #define STORE_ALL
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
51 #define REST_ALL
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
52 #else
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
53 // this asm code is no longer needed
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
54 #define STORE_ALL \
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
55 __asm__ __volatile__ ( \
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
56 "push %%ebx\n\t" \
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
57 "push %%ecx\n\t" \
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
58 "push %%edx\n\t" \
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
59 "push %%esi\n\t" \
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
60 "push %%edi\n\t"::)
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
61
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
62 #define REST_ALL \
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
63 __asm__ __volatile__ ( \
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
64 "pop %%edi\n\t" \
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
65 "pop %%esi\n\t" \
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
66 "pop %%edx\n\t" \
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
67 "pop %%ecx\n\t" \
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
68 "pop %%ebx\n\t"::)
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
69 #endif
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
70
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
71 static int needs_free=0;
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
72 void SetCodecPath(const char* path)
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
73 {
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
74 if(needs_free)free(def_path);
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
75 if(path==0)
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
76 {
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
77 def_path=WIN32_PATH;
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
78 needs_free=0;
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
79 return;
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
80 }
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
81 def_path = (char*) malloc(strlen(path)+1);
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
82 strcpy(def_path, path);
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
83 needs_free=1;
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
84 }
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
85
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
86 static DWORD dwDrvID = 0;
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
87
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
88 LRESULT WINAPI SendDriverMessage(HDRVR hDriver, UINT message,
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
89 LPARAM lParam1, LPARAM lParam2)
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
90 {
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
91 DRVR* module=(DRVR*)hDriver;
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
92 int result;
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
93 #ifndef __svr4__
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
94 char qw[300];
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
95 #endif
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
96 #ifdef DETAILED_OUT
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
97 printf("SendDriverMessage: driver %X, message %X, arg1 %X, arg2 %X\n", hDriver, message, lParam1, lParam2);
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
98 #endif
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
99 if (!module || !module->hDriverModule || !module->DriverProc) return -1;
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
100 #ifndef __svr4__
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
101 __asm__ __volatile__ ("fsave (%0)\n\t": :"r"(&qw));
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
102 #endif
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
103
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
104 #ifdef WIN32_LOADER
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
105 Setup_FS_Segment();
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
106 #endif
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
107
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
108 STORE_ALL;
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
109 result=module->DriverProc(module->dwDriverID, hDriver, message, lParam1, lParam2);
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
110 REST_ALL;
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
111
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
112 #ifndef __svr4__
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
113 __asm__ __volatile__ ("frstor (%0)\n\t": :"r"(&qw));
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
114 #endif
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
115
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
116 #ifdef DETAILED_OUT
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
117 printf("\t\tResult: %X\n", result);
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
118 #endif
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
119 return result;
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
120 }
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
121
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
122 void DrvClose(HDRVR hDriver)
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
123 {
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
124 if (hDriver)
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
125 {
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
126 DRVR* d = (DRVR*)hDriver;
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
127 if (d->hDriverModule)
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
128 {
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
129 #ifdef WIN32_LOADER
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
130 Setup_FS_Segment();
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
131 #endif
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
132 if (d->DriverProc)
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
133 {
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
134 SendDriverMessage(hDriver, DRV_CLOSE, 0, 0);
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
135 d->dwDriverID = 0;
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
136 SendDriverMessage(hDriver, DRV_FREE, 0, 0);
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
137 }
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
138 FreeLibrary(d->hDriverModule);
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
139 }
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
140 free(d);
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
141 }
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
142 #ifdef WIN32_LOADER
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
143 CodecRelease();
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
144 #endif
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
145 }
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
146
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
147 //DrvOpen(LPCSTR lpszDriverName, LPCSTR lpszSectionName, LPARAM lParam2)
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
148 HDRVR DrvOpen(LPARAM lParam2)
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
149 {
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
150 NPDRVR hDriver;
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
151 char unknown[0x124];
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
152 const char* filename = (const char*) ((ICOPEN*) lParam2)->pV1Reserved;
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
153
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
154 #ifdef WIN32_LOADER
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
155 Setup_LDT_Keeper();
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
156 #endif
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
157 printf("Loading codec DLL: '%s'\n",filename);
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
158
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
159 hDriver = (NPDRVR) malloc(sizeof(DRVR));
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
160 if (!hDriver)
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
161 return (HDRVR) 0;
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
162 memset((void*)hDriver, 0, sizeof(DRVR));
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
163
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
164 #ifdef WIN32_LOADER
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
165 CodecAlloc();
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
166 Setup_FS_Segment();
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
167 #endif
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
168
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
169 hDriver->hDriverModule = LoadLibraryA(filename);
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
170 if (!hDriver->hDriverModule)
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
171 {
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
172 printf("Can't open library %s\n", filename);
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
173 DrvClose((HDRVR)hDriver);
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
174 return (HDRVR) 0;
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
175 }
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
176
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
177 hDriver->DriverProc = (DRIVERPROC) GetProcAddress(hDriver->hDriverModule,
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
178 "DriverProc");
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
179 if (!hDriver->DriverProc)
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
180 {
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
181 printf("Library %s is not a valid VfW/ACM codec\n", filename);
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
182 DrvClose((HDRVR)hDriver);
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
183 return (HDRVR) 0;
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
184 }
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
185
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
186 TRACE("DriverProc == %X\n", hDriver->DriverProc);
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
187 SendDriverMessage((HDRVR)hDriver, DRV_LOAD, 0, 0);
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
188 TRACE("DRV_LOAD Ok!\n");
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
189 SendDriverMessage((HDRVR)hDriver, DRV_ENABLE, 0, 0);
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
190 TRACE("DRV_ENABLE Ok!\n");
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
191 hDriver->dwDriverID = ++dwDrvID; // generate new id
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
192
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
193 // open driver and remmeber proper DriverID
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
194 hDriver->dwDriverID = SendDriverMessage((HDRVR)hDriver, DRV_OPEN, (LPARAM) unknown, lParam2);
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
195 TRACE("DRV_OPEN Ok!(%X)\n", hDriver->dwDriverID);
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
196
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
197 printf("Loaded DLL driver %s at %x\n", filename, hDriver->hDriverModule);
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
198 return (HDRVR)hDriver;
0b21ffa03b9c Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
diff changeset
199 }