~ubuntu-branches/ubuntu/maverick/vlc/maverick

« back to all changes in this revision

Viewing changes to libs/loader/driver.c

  • Committer: Bazaar Package Importer
  • Author(s): Reinhard Tartler
  • Date: 2008-09-17 21:56:14 UTC
  • mfrom: (1.1.17 upstream)
  • Revision ID: james.westby@ubuntu.com-20080917215614-tj0vx8xzd57e52t8
Tags: 0.9.2-1ubuntu1
* New Upstream Release, exception granted by
    - dktrkranz, norsetto, Hobbsee (via irc). LP: #270404

Changes done in ubuntu:

* add libxul-dev to build-depends
* make sure that vlc is build against libxul in configure. This doesn't
  change anything in the package, but makes it more robust if building
  in an 'unclean' chroot or when modifying the package.
* debian/control: make Vcs-* fields point to the motumedia branch
* add libx264-dev and libass-dev to build-depends
  LP: #210354, #199870
* actually enable libass support by passing --enable-libass to configure
* enable libdca: add libdca-dev to build depends and --enable-libdca
* install the x264 plugin.

Changes already in the pkg-multimedia branch in debian:

* don't install usr/share/vlc/mozilla in debian/mozilla-plugin-vlc.install  
* new upstream .desktop file now registers flash video mimetype LP: #261567
* add Xb-Npp-Applications to mozilla-plugin-vlc
* remove duplicate entries in debian/vlc-nox.install

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * $Id$
 
3
 *
 
4
 * Copyright 1993, 1994 Martin Ayotte
 
5
 * Copyright 1998 Marcus Meissner
 
6
 * Copyright 1999 Eric Pouech
 
7
 *
 
8
 * Originally distributed under LPGL 2.1 (or later) by the Wine project.
 
9
 *
 
10
 * Modified for use with MPlayer, detailed CVS changelog at
 
11
 * http://www.mplayerhq.hu/cgi-bin/cvsweb.cgi/main/
 
12
 *
 
13
 * File now distributed as part of VLC media player with no modifications.
 
14
 *
 
15
 * This program is free software; you can redistribute it and/or modify
 
16
 * it under the terms of the GNU General Public License as published by
 
17
 * the Free Software Foundation; either version 2 of the License, or
 
18
 * (at your option) any later version.
 
19
 *
 
20
 * This program is distributed in the hope that it will be useful,
 
21
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
22
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
23
 * GNU General Public License for more details.
 
24
 *
 
25
 * You should have received a copy of the GNU General Public License
 
26
 * along with this program; if not, write to the Free Software
 
27
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
 
28
 */
 
29
 
 
30
#include "config.h"
 
31
 
 
32
#include <stdio.h>
 
33
#ifdef HAVE_MALLOC_H
 
34
#include <malloc.h>
 
35
#endif
 
36
#include <stdlib.h>
 
37
#ifdef __FreeBSD__
 
38
#include <sys/time.h>
 
39
#endif
 
40
 
 
41
#include "win32.h"
 
42
#include "wine/driver.h"
 
43
#include "wine/pe_image.h"
 
44
#include "wine/winreg.h"
 
45
#include "wine/vfw.h"
 
46
#include "registry.h"
 
47
#ifdef WIN32_LOADER
 
48
#include "ldt_keeper.h"
 
49
#endif
 
50
#include "driver.h"
 
51
#ifndef __MINGW32__
 
52
#include "ext.h"
 
53
#endif
 
54
 
 
55
#ifndef WIN32_LOADER
 
56
char* def_path=WIN32_PATH;
 
57
#else
 
58
extern char* def_path;
 
59
#endif
 
60
 
 
61
#if 1
 
62
 
 
63
/*
 
64
 * STORE_ALL/REST_ALL seems like an attempt to workaround problems due to
 
65
 * WINAPI/no-WINAPI bustage.
 
66
 *
 
67
 * There should be no need for the STORE_ALL/REST_ALL hack once all
 
68
 * function definitions agree with their prototypes (WINAPI-wise) and
 
69
 * we make sure, that we do not call these functions without a proper
 
70
 * prototype in scope.
 
71
 */
 
72
 
 
73
#define STORE_ALL
 
74
#define REST_ALL
 
75
#else
 
76
// this asm code is no longer needed
 
77
#define STORE_ALL \
 
78
    __asm__ __volatile__ ( \
 
79
    "push %%ebx\n\t" \
 
80
    "push %%ecx\n\t" \
 
81
    "push %%edx\n\t" \
 
82
    "push %%esi\n\t" \
 
83
    "push %%edi\n\t"::)
 
84
 
 
85
#define REST_ALL \
 
86
    __asm__ __volatile__ ( \
 
87
    "pop %%edi\n\t" \
 
88
    "pop %%esi\n\t" \
 
89
    "pop %%edx\n\t" \
 
90
    "pop %%ecx\n\t" \
 
91
    "pop %%ebx\n\t"::)
 
92
#endif
 
93
 
 
94
static int needs_free=0;
 
95
void SetCodecPath(const char* path)
 
96
{
 
97
    if(needs_free)free(def_path);
 
98
    if(path==0)
 
99
    {
 
100
        def_path=WIN32_PATH;
 
101
        needs_free=0;
 
102
        return;
 
103
    }
 
104
    def_path = (char*) malloc(strlen(path)+1);
 
105
    strcpy(def_path, path);
 
106
    needs_free=1;
 
107
}
 
108
 
 
109
static DWORD dwDrvID = 0;
 
110
 
 
111
LRESULT WINAPI SendDriverMessage(HDRVR hDriver, UINT message,
 
112
                                 LPARAM lParam1, LPARAM lParam2)
 
113
{
 
114
    DRVR* module=(DRVR*)hDriver;
 
115
    int result;
 
116
#ifndef __svr4__
 
117
    char qw[300];
 
118
#endif
 
119
#ifdef DETAILED_OUT
 
120
    printf("SendDriverMessage: driver %X, message %X, arg1 %X, arg2 %X\n", hDriver, message, lParam1, lParam2);
 
121
#endif
 
122
    if (!module || !module->hDriverModule || !module->DriverProc) return -1;
 
123
#ifndef __svr4__
 
124
    __asm__ __volatile__ ("fsave (%0)\n\t": :"r"(&qw));
 
125
#endif
 
126
 
 
127
#ifdef WIN32_LOADER
 
128
    Setup_FS_Segment();
 
129
#endif
 
130
 
 
131
    STORE_ALL;
 
132
    result=module->DriverProc(module->dwDriverID, hDriver, message, lParam1, lParam2);
 
133
    REST_ALL;
 
134
 
 
135
#ifndef __svr4__
 
136
    __asm__ __volatile__ ("frstor (%0)\n\t": :"r"(&qw));
 
137
#endif
 
138
 
 
139
#ifdef DETAILED_OUT
 
140
    printf("\t\tResult: %X\n", result);
 
141
#endif
 
142
    return result;
 
143
}
 
144
 
 
145
void DrvClose(HDRVR hDriver)
 
146
{
 
147
    if (hDriver)
 
148
    {
 
149
        DRVR* d = (DRVR*)hDriver;
 
150
        if (d->hDriverModule)
 
151
        {
 
152
#ifdef WIN32_LOADER
 
153
            Setup_FS_Segment();
 
154
#endif
 
155
            if (d->DriverProc)
 
156
            {
 
157
                SendDriverMessage(hDriver, DRV_CLOSE, 0, 0);
 
158
                d->dwDriverID = 0;
 
159
                SendDriverMessage(hDriver, DRV_FREE, 0, 0);
 
160
            }
 
161
            FreeLibrary(d->hDriverModule);
 
162
        }
 
163
        free(d);
 
164
    }
 
165
#ifdef WIN32_LOADER
 
166
    CodecRelease();
 
167
#endif
 
168
}
 
169
 
 
170
//DrvOpen(LPCSTR lpszDriverName, LPCSTR lpszSectionName, LPARAM lParam2)
 
171
HDRVR DrvOpen(LPARAM lParam2)
 
172
{
 
173
    NPDRVR hDriver;
 
174
    int i;
 
175
    char unknown[0x124];
 
176
    const char* filename = (const char*) ((ICOPEN*) lParam2)->pV1Reserved;
 
177
 
 
178
#ifdef MPLAYER
 
179
#ifdef WIN32_LOADER
 
180
    Setup_LDT_Keeper();
 
181
#endif
 
182
    printf("Loading codec DLL: '%s'\n",filename);
 
183
#endif
 
184
 
 
185
    hDriver = (NPDRVR) malloc(sizeof(DRVR));
 
186
    if (!hDriver)
 
187
        return ((HDRVR) 0);
 
188
    memset((void*)hDriver, 0, sizeof(DRVR));
 
189
 
 
190
#ifdef WIN32_LOADER
 
191
    CodecAlloc();
 
192
    Setup_FS_Segment();
 
193
#endif
 
194
 
 
195
    hDriver->hDriverModule = LoadLibraryA(filename);
 
196
    if (!hDriver->hDriverModule)
 
197
    {
 
198
        printf("Can't open library %s\n", filename);
 
199
        DrvClose((HDRVR)hDriver);
 
200
        return ((HDRVR) 0);
 
201
    }
 
202
 
 
203
    hDriver->DriverProc = (DRIVERPROC) GetProcAddress(hDriver->hDriverModule,
 
204
                                                      "DriverProc");
 
205
    if (!hDriver->DriverProc)
 
206
    {
 
207
        printf("Library %s is not a valid VfW/ACM codec\n", filename);
 
208
        DrvClose((HDRVR)hDriver);
 
209
        return ((HDRVR) 0);
 
210
    }
 
211
 
 
212
    TRACE("DriverProc == %X\n", hDriver->DriverProc);
 
213
    SendDriverMessage((HDRVR)hDriver, DRV_LOAD, 0, 0);
 
214
    TRACE("DRV_LOAD Ok!\n");
 
215
    SendDriverMessage((HDRVR)hDriver, DRV_ENABLE, 0, 0);
 
216
    TRACE("DRV_ENABLE Ok!\n");
 
217
    hDriver->dwDriverID = ++dwDrvID; // generate new id
 
218
 
 
219
    // open driver and remmeber proper DriverID
 
220
    hDriver->dwDriverID = SendDriverMessage((HDRVR)hDriver, DRV_OPEN, (LPARAM) unknown, lParam2);
 
221
    TRACE("DRV_OPEN Ok!(%X)\n", hDriver->dwDriverID);
 
222
 
 
223
    printf("Loaded DLL driver %s at %x\n", filename, hDriver->hDriverModule);
 
224
    return (HDRVR)hDriver;
 
225
}