Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-2-2
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-2-2
Commits
cfdc3865
Commit
cfdc3865
authored
Dec 22, 2007
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- Parse seek offsets as unsigned (why they were signed in the first place??)
- Fix comments - Cache pagesize
parent
ca434330
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
15 deletions
+16
-15
modules/access/file.c
modules/access/file.c
+16
-15
No files found.
modules/access/file.c
View file @
cfdc3865
...
...
@@ -116,6 +116,7 @@ static int open_file( access_t *, const char * );
struct
access_sys_t
{
uint64_t
pagemask
;
unsigned
int
i_nb_reads
;
vlc_bool_t
b_kfir
;
...
...
@@ -202,6 +203,8 @@ static int Open( vlc_object_t *p_this )
p_sys
->
b_seekable
=
VLC_FALSE
;
# ifdef HAVE_MMAP
p_sys
->
pagemask
=
sysconf
(
_SC_PAGE_SIZE
)
-
1
;
/* Autodetect mmap() support */
if
(
p_sys
->
b_pace_control
&&
S_ISREG
(
st
.
st_mode
)
&&
(
st
.
st_size
>
0
))
{
...
...
@@ -340,7 +343,7 @@ static ssize_t Read( access_t *p_access, uint8_t *p_buffer, size_t i_len )
}
#ifdef HAVE_MMAP
# define MMAP_SIZE (1 <<
18
)
# define MMAP_SIZE (1 <<
20
)
struct
block_sys_t
{
...
...
@@ -364,15 +367,14 @@ static block_t *mmapBlock (access_t *p_access)
access_sys_t
*
p_sys
=
p_access
->
p_sys
;
const
int
flags
=
MAP_SHARED
;
const
size_t
pagesize
=
sysconf
(
_SC_PAGE_SIZE
);
off_t
offset
=
p_access
->
info
.
i_pos
&
~
(
pagesize
-
1
);
size_t
align
=
p_access
->
info
.
i_pos
&
(
pagesize
-
1
);
size_t
length
=
(
MMAP_SIZE
>
pagesize
)
?
MMAP_SIZE
:
pagesize
;
off_t
offset
=
p_access
->
info
.
i_pos
&
~
p_sys
->
pagemask
;
size_t
align
=
p_access
->
info
.
i_pos
&
p_sys
->
pagemask
;
size_t
length
=
(
MMAP_SIZE
>
p_sys
->
pagemask
)
?
MMAP_SIZE
:
(
p_sys
->
pagemask
+
1
);
void
*
addr
;
if
(
p_access
->
info
.
i_pos
>=
p_access
->
info
.
i_size
)
{
/* End of file - check
that file size hasn't change
... */
/* End of file - check
if file size changed
... */
struct
stat
st
;
if
((
fstat
(
p_sys
->
fd
,
&
st
)
==
0
)
...
...
@@ -392,7 +394,7 @@ static block_t *mmapBlock (access_t *p_access)
}
if
(
offset
+
length
>
p_access
->
info
.
i_size
)
/* Don't mmap
paste
end of file */
/* Don't mmap
beyond
end of file */
length
=
p_access
->
info
.
i_size
-
offset
;
assert
(
offset
<=
p_access
->
info
.
i_pos
);
/* and */
...
...
@@ -412,7 +414,7 @@ static block_t *mmapBlock (access_t *p_access)
p_access
->
info
.
i_pos
=
offset
+
length
;
msg_Dbg
(
p_access
,
"mapped
%lu bytes at %p from offset %lu
"
,
msg_Dbg
(
p_access
,
"mapped
0x%lx bytes at %p from offset 0x%lx
"
,
(
unsigned
long
)
length
,
addr
,
(
unsigned
long
)
offset
);
block_sys_t
*
block
=
malloc
(
sizeof
(
*
block
));
if
(
block
==
NULL
)
...
...
@@ -436,16 +438,15 @@ static block_t *mmapBlock (access_t *p_access)
*****************************************************************************/
static
int
Seek
(
access_t
*
p_access
,
int64_t
i_pos
)
{
if
(
i_pos
>
p_access
->
info
.
i_size
)
/* FIXME: i_size should really be unsigned */
if
((
uint64_t
)
i_pos
>
(
uint64_t
)
p_access
->
info
.
i_size
)
{
msg_Err
(
p_access
,
"seeking too far"
);
/* This should only happen with corrupted files.
* But it also seems to happen with buggy demuxes (ASF) */
msg_Err
(
p_access
,
"seeking too far (0x"
I64Fx
" / 0x"
I64Fx
")"
,
i_pos
,
p_access
->
info
.
i_size
);
i_pos
=
p_access
->
info
.
i_size
;
}
else
if
(
i_pos
<
0
)
{
msg_Err
(
p_access
,
"seeking too early"
);
i_pos
=
0
;
}
p_access
->
info
.
i_pos
=
i_pos
;
p_access
->
info
.
b_eof
=
VLC_FALSE
;
...
...
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