msvfw32: Use the standard linked list implementation.

Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zebediah Figura 2019-03-06 21:10:17 -06:00 committed by Alexandre Julliard
parent 0969a250e9
commit ae71dd9e0e
1 changed files with 36 additions and 45 deletions

View File

@ -41,6 +41,7 @@
#include "msvideo_private.h" #include "msvideo_private.h"
#include "wine/debug.h" #include "wine/debug.h"
#include "wine/heap.h" #include "wine/heap.h"
#include "wine/list.h"
/* Drivers32 settings */ /* Drivers32 settings */
#define HKLM_DRIVERS32 "Software\\Microsoft\\Windows NT\\CurrentVersion\\Drivers32" #define HKLM_DRIVERS32 "Software\\Microsoft\\Windows NT\\CurrentVersion\\Drivers32"
@ -108,10 +109,10 @@ struct _reg_driver
DWORD fccHandler; DWORD fccHandler;
DRIVERPROC proc; DRIVERPROC proc;
LPWSTR name; LPWSTR name;
reg_driver* next; struct list entry;
}; };
static reg_driver* reg_driver_list = NULL; static struct list reg_driver_list = LIST_INIT(reg_driver_list);
HMODULE MSVFW32_hModule; HMODULE MSVFW32_hModule;
@ -358,13 +359,14 @@ BOOL VFWAPI ICInstall(DWORD fccType, DWORD fccHandler, LPARAM lParam, LPSTR szDe
TRACE("(%s,%s,%p,%p,0x%08x)\n", wine_dbgstr_fcc(fccType), wine_dbgstr_fcc(fccHandler), (void*)lParam, szDesc, wFlags); TRACE("(%s,%s,%p,%p,0x%08x)\n", wine_dbgstr_fcc(fccType), wine_dbgstr_fcc(fccHandler), (void*)lParam, szDesc, wFlags);
/* Check if a driver is already registered */ /* Check if a driver is already registered */
for (driver = reg_driver_list; driver; driver = driver->next) LIST_FOR_EACH_ENTRY(driver, &reg_driver_list, reg_driver, entry)
{ {
if (!compare_fourcc(fccType, driver->fccType) && if (!compare_fourcc(fccType, driver->fccType) &&
!compare_fourcc(fccHandler, driver->fccHandler)) !compare_fourcc(fccHandler, driver->fccHandler))
break; {
return FALSE;
}
} }
if (driver) return FALSE;
/* Register the driver */ /* Register the driver */
if (!(driver = heap_alloc_zero(sizeof(*driver)))) if (!(driver = heap_alloc_zero(sizeof(*driver))))
@ -392,9 +394,7 @@ BOOL VFWAPI ICInstall(DWORD fccType, DWORD fccHandler, LPARAM lParam, LPSTR szDe
return FALSE; return FALSE;
} }
/* Insert our driver in the list*/ list_add_tail(&reg_driver_list, &driver->entry);
driver->next = reg_driver_list;
reg_driver_list = driver;
return TRUE; return TRUE;
} }
@ -404,28 +404,23 @@ BOOL VFWAPI ICInstall(DWORD fccType, DWORD fccHandler, LPARAM lParam, LPSTR szDe
*/ */
BOOL VFWAPI ICRemove(DWORD fccType, DWORD fccHandler, UINT wFlags) BOOL VFWAPI ICRemove(DWORD fccType, DWORD fccHandler, UINT wFlags)
{ {
reg_driver** pdriver; reg_driver *driver;
reg_driver* drv;
TRACE("(%s,%s,0x%08x)\n", wine_dbgstr_fcc(fccType), wine_dbgstr_fcc(fccHandler), wFlags); TRACE("(%s,%s,0x%08x)\n", wine_dbgstr_fcc(fccType), wine_dbgstr_fcc(fccHandler), wFlags);
/* Check if a driver is already registered */ LIST_FOR_EACH_ENTRY(driver, &reg_driver_list, reg_driver, entry)
for (pdriver = &reg_driver_list; *pdriver; pdriver = &(*pdriver)->next)
{ {
if (!compare_fourcc(fccType, (*pdriver)->fccType) && if (!compare_fourcc(fccType, driver->fccType)
!compare_fourcc(fccHandler, (*pdriver)->fccHandler)) && !compare_fourcc(fccHandler, driver->fccHandler))
break; {
list_remove(&driver->entry);
heap_free(driver->name);
heap_free(driver);
return TRUE;
}
} }
if (!*pdriver)
return FALSE;
/* Remove the driver from the list */ return FALSE;
drv = *pdriver;
*pdriver = (*pdriver)->next;
heap_free(drv->name);
heap_free(drv);
return TRUE;
} }
@ -437,10 +432,10 @@ HIC VFWAPI ICOpen(DWORD fccType, DWORD fccHandler, UINT wMode)
{ {
WCHAR codecname[10]; WCHAR codecname[10];
ICOPEN icopen; ICOPEN icopen;
HDRVR hdrv;
WINE_HIC* whic; WINE_HIC* whic;
static const WCHAR drv32W[] = {'d','r','i','v','e','r','s','3','2','\0'}; static const WCHAR drv32W[] = {'d','r','i','v','e','r','s','3','2','\0'};
reg_driver* driver; reg_driver* driver;
HDRVR hdrv = NULL;
TRACE("(%s,%s,0x%08x)\n", wine_dbgstr_fcc(fccType), wine_dbgstr_fcc(fccHandler), wMode); TRACE("(%s,%s,0x%08x)\n", wine_dbgstr_fcc(fccType), wine_dbgstr_fcc(fccHandler), wMode);
@ -465,21 +460,21 @@ HIC VFWAPI ICOpen(DWORD fccType, DWORD fccHandler, UINT wMode)
} }
} }
/* Check if there is a registered driver that matches */ LIST_FOR_EACH_ENTRY(driver, &reg_driver_list, reg_driver, entry)
driver = reg_driver_list; {
while(driver) if (!compare_fourcc(fccType, driver->fccType)
if (!compare_fourcc(fccType, driver->fccType) && && !compare_fourcc(fccHandler, driver->fccHandler))
!compare_fourcc(fccHandler, driver->fccHandler)) { {
fccType = driver->fccType; if (driver->proc)
fccHandler = driver->fccHandler; return ICOpenFunction(driver->fccType, driver->fccHandler, wMode, driver->proc);
break; else
} else {
driver = driver->next; if (!(hdrv = OpenDriver(driver->name, NULL, (LPARAM)&icopen)))
return NULL;
}
}
}
if (driver && driver->proc)
/* The driver has been registered at runtime with its driverproc */
return ICOpenFunction(fccType, fccHandler, wMode, driver->proc);
/* Well, lParam2 is in fact a LPVIDEO_OPEN_PARMS, but it has the /* Well, lParam2 is in fact a LPVIDEO_OPEN_PARMS, but it has the
* same layout as ICOPEN * same layout as ICOPEN
*/ */
@ -493,7 +488,8 @@ HIC VFWAPI ICOpen(DWORD fccType, DWORD fccHandler, UINT wMode)
icopen.pV2Reserved = NULL; icopen.pV2Reserved = NULL;
icopen.dnDevNode = 0; /* FIXME */ icopen.dnDevNode = 0; /* FIXME */
if (!driver) { if (!hdrv)
{
/* normalize to lower case as in 'vidc' */ /* normalize to lower case as in 'vidc' */
((char*)&fccType)[0] = tolower(((char*)&fccType)[0]); ((char*)&fccType)[0] = tolower(((char*)&fccType)[0]);
((char*)&fccType)[1] = tolower(((char*)&fccType)[1]); ((char*)&fccType)[1] = tolower(((char*)&fccType)[1]);
@ -509,11 +505,6 @@ HIC VFWAPI ICOpen(DWORD fccType, DWORD fccHandler, UINT wMode)
hdrv = OpenDriver(codecname, drv32W, (LPARAM)&icopen); hdrv = OpenDriver(codecname, drv32W, (LPARAM)&icopen);
if (!hdrv) if (!hdrv)
return 0; return 0;
} else {
/* The driver has been registered at runtime with its name */
hdrv = OpenDriver(driver->name, NULL, (LPARAM)&icopen);
if (!hdrv)
return 0;
} }
if (!(whic = heap_alloc(sizeof(*whic)))) if (!(whic = heap_alloc(sizeof(*whic))))