Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc
Commits
33655fee
Commit
33655fee
authored
Aug 28, 2015
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
prefetch: Win32 support
parent
c74fb8e1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
62 additions
and
2 deletions
+62
-2
modules/stream_filter/Makefile.am
modules/stream_filter/Makefile.am
+0
-2
modules/stream_filter/prefetch.c
modules/stream_filter/prefetch.c
+62
-0
No files found.
modules/stream_filter/Makefile.am
View file @
33655fee
...
...
@@ -16,9 +16,7 @@ endif
libprefetch_plugin_la_SOURCES
=
stream_filter/prefetch.c
libprefetch_plugin_la_LIBADD
=
$(LIBPTHREAD)
if
!HAVE_WIN32
stream_filter_LTLIBRARIES
+=
libprefetch_plugin.la
endif
libsmooth_plugin_la_SOURCES
=
\
stream_filter/smooth/smooth.c
\
...
...
modules/stream_filter/prefetch.c
View file @
33655fee
...
...
@@ -42,6 +42,9 @@
((void)(a), (void)(l), errno = EINVAL, -1)
#define sysconf(a) 1
#endif
#if defined (_WIN32)
#include <windows.h>
#endif
#include <vlc_common.h>
#include <vlc_plugin.h>
...
...
@@ -431,8 +434,10 @@ static int Open(vlc_object_t *obj)
if
(
sys
->
buffer_size
<
sys
->
read_size
)
sys
->
buffer_size
=
sys
->
read_size
;
#ifndef _WIN32
/* Round up to a multiple of the page size */
long
page_size
=
sysconf
(
_SC_PAGESIZE
);
sys
->
buffer_size
+=
page_size
-
1
;
sys
->
buffer_size
&=
~
(
page_size
-
1
);
...
...
@@ -455,6 +460,50 @@ static int Open(vlc_object_t *obj)
goto
error
;
}
close
(
fd
);
#else
SYSTEM_INFO
info
;
GetSystemInfo
(
&
info
);
sys
->
buffer_size
+=
info
.
dwPageSize
-
1
;
sys
->
buffer_size
&=
~
(
info
.
dwPageSize
-
1
);
sys
->
buffer
=
NULL
;
HANDLE
map
=
CreateFileMapping
(
INVALID_HANDLE_VALUE
,
NULL
,
PAGE_READWRITE
,
0
,
sys
->
buffer_size
,
NULL
);
if
(
map
==
NULL
)
goto
error
;
for
(;;)
{
char
*
buffer
=
VirtualAlloc
(
NULL
,
2
*
sys
->
buffer_size
,
MEM_RESERVE
,
PAGE_NOACCESS
);
if
(
buffer
==
NULL
)
break
;
VirtualFree
(
buffer
,
2
*
sys
->
buffer_size
,
MEM_RELEASE
);
char
*
a
=
MapViewOfFileEx
(
map
,
FILE_MAP_ALL_ACCESS
,
0
,
0
,
sys
->
buffer_size
,
buffer
);
char
*
b
=
MapViewOfFileEx
(
map
,
FILE_MAP_ALL_ACCESS
,
0
,
0
,
sys
->
buffer_size
,
buffer
+
sys
->
buffer_size
);
if
(
a
==
buffer
&&
b
==
buffer
+
sys
->
buffer_size
)
{
sys
->
buffer
=
buffer
;
break
;
}
if
(
b
!=
NULL
)
UnmapViewOfFile
(
b
);
if
(
a
!=
NULL
)
UnmapViewOfFile
(
a
);
if
(
a
==
NULL
||
b
==
NULL
)
break
;
/* ENOMEM */
}
CloseHandle
(
map
);
if
(
sys
->
buffer
==
NULL
)
goto
error
;
#endif
/* _WIN32 */
vlc_mutex_init
(
&
sys
->
lock
);
vlc_cond_init
(
&
sys
->
wait_data
);
...
...
@@ -478,8 +527,16 @@ static int Open(vlc_object_t *obj)
return
VLC_SUCCESS
;
error:
#ifndef _WIN32
if
(
sys
->
buffer
!=
MAP_FAILED
)
munmap
(
sys
->
buffer
,
2
*
sys
->
buffer_size
);
#else
if
(
sys
->
buffer
!=
NULL
)
{
UnmapViewOfFile
(
sys
->
buffer
+
sys
->
buffer_size
);
UnmapViewOfFile
(
sys
->
buffer
);
}
#endif
free
(
sys
);
return
VLC_ENOMEM
;
}
...
...
@@ -499,7 +556,12 @@ static void Close (vlc_object_t *obj)
vlc_cond_destroy
(
&
sys
->
wait_data
);
vlc_mutex_destroy
(
&
sys
->
lock
);
#ifndef _WIN32
munmap
(
sys
->
buffer
,
2
*
sys
->
buffer_size
);
#else
UnmapViewOfFile
(
sys
->
buffer
+
sys
->
buffer_size
);
UnmapViewOfFile
(
sys
->
buffer
);
#endif
free
(
sys
->
content_type
);
free
(
sys
);
}
...
...
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