Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
26ac991c
Commit
26ac991c
authored
Aug 06, 2019
by
Zebediah Figura
Committed by
Alexandre Julliard
Aug 07, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
quartz: Use file APIs directly in get_media_type().
Signed-off-by:
Zebediah Figura
<
z.figura12@gmail.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
4555da1d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
71 deletions
+24
-71
filesource.c
dlls/quartz/filesource.c
+19
-9
filtergraph.c
dlls/quartz/filtergraph.c
+4
-61
quartz_private.h
dlls/quartz/quartz_private.h
+1
-1
No files found.
dlls/quartz/filesource.c
View file @
26ac991c
...
...
@@ -129,10 +129,10 @@ static unsigned char byte_from_hex_char(WCHAR wHex)
}
}
static
BOOL
process_pattern_string
(
const
WCHAR
*
pattern
,
IAsyncReader
*
reader
)
static
BOOL
process_pattern_string
(
const
WCHAR
*
pattern
,
HANDLE
file
)
{
ULONG
size
,
offset
,
i
,
ret_size
;
BYTE
*
mask
,
*
expect
,
*
actual
;
ULONG
size
,
offset
,
i
;
BOOL
ret
=
TRUE
;
/* format: "offset, size, mask, value" */
...
...
@@ -181,7 +181,8 @@ static BOOL process_pattern_string(const WCHAR *pattern, IAsyncReader *reader)
}
actual
=
heap_alloc
(
size
);
if
(
FAILED
(
IAsyncReader_SyncRead
(
reader
,
offset
,
size
,
actual
)))
SetFilePointer
(
file
,
offset
,
NULL
,
FILE_BEGIN
);
if
(
!
ReadFile
(
file
,
actual
,
size
,
&
ret_size
,
NULL
)
||
ret_size
!=
size
)
{
heap_free
(
actual
);
heap_free
(
expect
);
...
...
@@ -204,13 +205,12 @@ static BOOL process_pattern_string(const WCHAR *pattern, IAsyncReader *reader)
/* If there is a following tuple, then we must match that as well. */
if
(
ret
&&
(
pattern
=
wcschr
(
pattern
,
','
)))
return
process_pattern_string
(
pattern
+
1
,
reader
);
return
process_pattern_string
(
pattern
+
1
,
file
);
return
ret
;
}
BOOL
get_media_type
(
IAsyncReader
*
reader
,
const
WCHAR
*
filename
,
GUID
*
majortype
,
GUID
*
subtype
,
GUID
*
source_clsid
)
BOOL
get_media_type
(
const
WCHAR
*
filename
,
GUID
*
majortype
,
GUID
*
subtype
,
GUID
*
source_clsid
)
{
WCHAR
extensions_path
[
278
]
=
{
'M'
,
'e'
,
'd'
,
'i'
,
'a'
,
' '
,
'T'
,
'y'
,
'p'
,
'e'
,
'\\'
,
'E'
,
'x'
,
't'
,
'e'
,
'n'
,
's'
,
'i'
,
'o'
,
'n'
,
's'
,
'\\'
,
0
};
static
const
WCHAR
wszExtensions
[]
=
{
'E'
,
'x'
,
't'
,
'e'
,
'n'
,
's'
,
'i'
,
'o'
,
'n'
,
's'
,
0
};
...
...
@@ -218,6 +218,7 @@ BOOL get_media_type(IAsyncReader *reader, const WCHAR *filename, GUID *majortype
DWORD
majortype_idx
,
size
;
const
WCHAR
*
ext
;
HKEY
parent_key
;
HANDLE
file
;
if
((
ext
=
wcsrchr
(
filename
,
'.'
)))
{
...
...
@@ -244,11 +245,18 @@ BOOL get_media_type(IAsyncReader *reader, const WCHAR *filename, GUID *majortype
}
}
if
(
!
reader
)
if
((
file
=
CreateFileW
(
filename
,
GENERIC_READ
,
FILE_SHARE_READ
,
NULL
,
OPEN_EXISTING
,
0
,
NULL
))
==
INVALID_HANDLE_VALUE
)
{
WARN
(
"Failed to open file %s, error %u.
\n
"
,
debugstr_w
(
filename
),
GetLastError
());
return
FALSE
;
}
if
(
RegOpenKeyExW
(
HKEY_CLASSES_ROOT
,
wszMediaType
,
0
,
KEY_READ
,
&
parent_key
))
{
CloseHandle
(
file
);
return
FALSE
;
}
for
(
majortype_idx
=
0
;
;
++
majortype_idx
)
{
...
...
@@ -298,7 +306,7 @@ BOOL get_media_type(IAsyncReader *reader, const WCHAR *filename, GUID *majortype
if
(
!
wcscmp
(
value_name
,
source_filter_name
))
continue
;
if
(
!
process_pattern_string
(
pattern
,
reader
))
if
(
!
process_pattern_string
(
pattern
,
file
))
continue
;
if
(
majortype
)
...
...
@@ -314,6 +322,7 @@ BOOL get_media_type(IAsyncReader *reader, const WCHAR *filename, GUID *majortype
RegCloseKey
(
subtype_key
);
RegCloseKey
(
majortype_key
);
RegCloseKey
(
parent_key
);
CloseHandle
(
file
);
return
TRUE
;
}
...
...
@@ -325,6 +334,7 @@ BOOL get_media_type(IAsyncReader *reader, const WCHAR *filename, GUID *majortype
}
RegCloseKey
(
parent_key
);
CloseHandle
(
file
);
return
FALSE
;
}
...
...
@@ -503,7 +513,7 @@ static HRESULT WINAPI FileSource_Load(IFileSourceFilter * iface, LPCOLESTR pszFi
if
(
!
pmt
)
{
CopyMediaType
(
This
->
pmt
,
&
default_mt
);
if
(
get_media_type
(
&
This
->
IAsyncReader_iface
,
pszFileName
,
&
This
->
pmt
->
majortype
,
&
This
->
pmt
->
subtype
,
NULL
))
if
(
get_media_type
(
pszFileName
,
&
This
->
pmt
->
majortype
,
&
This
->
pmt
->
subtype
,
NULL
))
{
TRACE
(
"Found major type %s, subtype %s.
\n
"
,
debugstr_guid
(
&
This
->
pmt
->
majortype
),
debugstr_guid
(
&
This
->
pmt
->
subtype
));
...
...
dlls/quartz/filtergraph.c
View file @
26ac991c
...
...
@@ -1683,69 +1683,12 @@ static HRESULT CreateFilterInstanceAndLoadFile(GUID* clsid, LPCOLESTR pszFileNam
}
/* Some filters implement their own asynchronous reader (Theoretically they all should, try to load it first */
static
HRESULT
GetFileSourceFilter
(
LPCOLESTR
pszFileN
ame
,
IBaseFilter
**
filter
)
static
HRESULT
GetFileSourceFilter
(
const
WCHAR
*
filen
ame
,
IBaseFilter
**
filter
)
{
HRESULT
hr
;
GUID
clsid
;
IAsyncReader
*
pReader
=
NULL
;
IFileSourceFilter
*
pSource
=
NULL
;
IPin
*
pOutputPin
=
NULL
;
static
const
WCHAR
wszOutputPinName
[]
=
{
'O'
,
'u'
,
't'
,
'p'
,
'u'
,
't'
,
0
};
BOOL
ret
;
/* Try to find a match without reading the file first */
if
(
get_media_type
(
NULL
,
pszFileName
,
NULL
,
NULL
,
&
clsid
))
return
CreateFilterInstanceAndLoadFile
(
&
clsid
,
pszFileName
,
filter
);
/* Now create a AyncReader instance, to check for signature bytes in the file */
hr
=
CoCreateInstance
(
&
CLSID_AsyncReader
,
NULL
,
CLSCTX_INPROC_SERVER
,
&
IID_IBaseFilter
,
(
LPVOID
*
)
filter
);
if
(
FAILED
(
hr
))
return
hr
;
hr
=
IBaseFilter_QueryInterface
(
*
filter
,
&
IID_IFileSourceFilter
,
(
LPVOID
*
)
&
pSource
);
if
(
FAILED
(
hr
))
{
IBaseFilter_Release
(
*
filter
);
return
hr
;
}
hr
=
IFileSourceFilter_Load
(
pSource
,
pszFileName
,
NULL
);
IFileSourceFilter_Release
(
pSource
);
if
(
FAILED
(
hr
))
{
IBaseFilter_Release
(
*
filter
);
return
hr
;
}
hr
=
IBaseFilter_FindPin
(
*
filter
,
wszOutputPinName
,
&
pOutputPin
);
if
(
FAILED
(
hr
))
{
IBaseFilter_Release
(
*
filter
);
return
hr
;
}
hr
=
IPin_QueryInterface
(
pOutputPin
,
&
IID_IAsyncReader
,
(
LPVOID
*
)
&
pReader
);
IPin_Release
(
pOutputPin
);
if
(
FAILED
(
hr
))
{
IBaseFilter_Release
(
*
filter
);
return
hr
;
}
/* Try again find a match */
ret
=
get_media_type
(
pReader
,
pszFileName
,
NULL
,
NULL
,
&
clsid
);
IAsyncReader_Release
(
pReader
);
if
(
ret
)
{
TRACE
(
"Found source filter %s.
\n
"
,
debugstr_guid
(
&
clsid
));
/* Release the AsyncReader filter and create the matching one */
IBaseFilter_Release
(
*
filter
);
return
CreateFilterInstanceAndLoadFile
(
&
clsid
,
pszFileName
,
filter
);
}
/* Return the AsyncReader filter */
return
S_OK
;
if
(
!
get_media_type
(
filename
,
NULL
,
NULL
,
&
clsid
))
clsid
=
CLSID_AsyncReader
;
return
CreateFilterInstanceAndLoadFile
(
&
clsid
,
filename
,
filter
);
}
static
HRESULT
WINAPI
FilterGraph2_AddSourceFilter
(
IFilterGraph2
*
iface
,
LPCWSTR
lpcwstrFileName
,
...
...
dlls/quartz/quartz_private.h
View file @
26ac991c
...
...
@@ -77,6 +77,6 @@ extern void video_unregister_windowclass(void) DECLSPEC_HIDDEN;
BOOL
CompareMediaTypes
(
const
AM_MEDIA_TYPE
*
pmt1
,
const
AM_MEDIA_TYPE
*
pmt2
,
BOOL
bWildcards
);
void
dump_AM_MEDIA_TYPE
(
const
AM_MEDIA_TYPE
*
pmt
)
DECLSPEC_HIDDEN
;
BOOL
get_media_type
(
IAsyncReader
*
reader
,
const
WCHAR
*
filename
,
GUID
*
majortype
,
GUID
*
subtype
,
GUID
*
source_clsid
)
DECLSPEC_HIDDEN
;
BOOL
get_media_type
(
const
WCHAR
*
filename
,
GUID
*
majortype
,
GUID
*
subtype
,
GUID
*
source_clsid
)
DECLSPEC_HIDDEN
;
#endif
/* __QUARTZ_PRIVATE_INCLUDED__ */
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment