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
db820529
Commit
db820529
authored
Jan 03, 2009
by
Antoine Cellerier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use poll instead of msleep in v4l
(also untested since I still don't have any v4l device to test on)
parent
2591b7db
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
19 deletions
+28
-19
modules/access/v4l.c
modules/access/v4l.c
+28
-19
No files found.
modules/access/v4l.c
View file @
db820529
...
...
@@ -49,6 +49,8 @@
#include <fcntl.h>
#include <arpa/inet.h>
#include <poll.h>
/* From GStreamer's v4l plugin:
* Because of some really cool feature in video4linux1, also known as
* 'not including sys/types.h and sys/time.h', we had to include it
...
...
@@ -245,7 +247,7 @@ struct demux_sys_t
{
/* Devices */
char
*
psz_device
;
/* Main device from MRL */
int
fd_video
;
int
i_fd
;
/* Video properties */
picture_t
pic
;
...
...
@@ -378,15 +380,15 @@ static int Open( vlc_object_t *p_this )
p_sys
->
i_quality
=
val
.
i_int
;
p_sys
->
psz_device
=
NULL
;
p_sys
->
fd_video
=
-
1
;
p_sys
->
i_fd
=
-
1
;
p_sys
->
p_es
=
NULL
;
ParseMRL
(
p_demux
);
msg_Dbg
(
p_this
,
"opening device '%s'"
,
p_sys
->
psz_device
);
p_sys
->
fd_video
=
OpenVideoDev
(
p_demux
,
p_sys
->
psz_device
);
if
(
p_sys
->
fd_video
<
0
)
p_sys
->
i_fd
=
OpenVideoDev
(
p_demux
,
p_sys
->
psz_device
);
if
(
p_sys
->
i_fd
<
0
)
{
Close
(
p_this
);
return
VLC_EGENERIC
;
...
...
@@ -442,12 +444,12 @@ static void Close( vlc_object_t *p_this )
demux_sys_t
*
p_sys
=
p_demux
->
p_sys
;
free
(
p_sys
->
psz_device
);
if
(
p_sys
->
fd_video
>=
0
)
close
(
p_sys
->
fd_video
);
if
(
p_sys
->
i_fd
>=
0
)
close
(
p_sys
->
i_fd
);
if
(
p_sys
->
b_mjpeg
)
{
int
i_noframe
=
-
1
;
ioctl
(
p_sys
->
fd_video
,
MJPIOC_QBUF_CAPT
,
&
i_noframe
);
ioctl
(
p_sys
->
i_fd
,
MJPIOC_QBUF_CAPT
,
&
i_noframe
);
}
if
(
p_sys
->
p_video_mmap
&&
p_sys
->
p_video_mmap
!=
MAP_FAILED
)
...
...
@@ -505,19 +507,26 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
static
int
Demux
(
demux_t
*
p_demux
)
{
demux_sys_t
*
p_sys
=
p_demux
->
p_sys
;
block_t
*
p_block
=
GrabVideo
(
p_demux
);
if
(
!
p_block
)
struct
pollfd
fd
;
fd
.
fd
=
p_sys
->
i_fd
;
fd
.
events
=
POLLIN
|
POLLPRI
;
fd
.
revents
=
0
;
/* Wait for data */
if
(
poll
(
&
fd
,
1
,
500
)
)
{
/* Sleep so we do not consume all the cpu, 10ms seems
* like a good value (100fps) */
msleep
(
10000
);
return
1
;
if
(
fd
.
revents
&
(
POLLIN
|
POLLPRI
)
)
{
block_t
*
p_block
=
GrabVideo
(
p_demux
);
if
(
p_block
)
{
es_out_Control
(
p_demux
->
out
,
ES_OUT_SET_PCR
,
p_block
->
i_pts
);
es_out_Send
(
p_demux
->
out
,
p_sys
->
p_es
,
p_block
);
}
}
}
es_out_Control
(
p_demux
->
out
,
ES_OUT_SET_PCR
,
p_block
->
i_pts
);
es_out_Send
(
p_demux
->
out
,
p_sys
->
p_es
,
p_block
);
return
1
;
}
...
...
@@ -1191,7 +1200,7 @@ static uint8_t *GrabCapture( demux_t *p_demux )
p_sys
->
vid_mmap
.
frame
=
(
p_sys
->
i_frame_pos
+
1
)
%
p_sys
->
vid_mbuf
.
frames
;
while
(
ioctl
(
p_sys
->
fd_video
,
VIDIOCMCAPTURE
,
&
p_sys
->
vid_mmap
)
<
0
)
while
(
ioctl
(
p_sys
->
i_fd
,
VIDIOCMCAPTURE
,
&
p_sys
->
vid_mmap
)
<
0
)
{
if
(
errno
!=
EAGAIN
)
{
...
...
@@ -1207,7 +1216,7 @@ static uint8_t *GrabCapture( demux_t *p_demux )
msg_Dbg
(
p_demux
,
"grab failed, trying again"
);
}
while
(
ioctl
(
p_sys
->
fd_video
,
VIDIOCSYNC
,
&
p_sys
->
i_frame_pos
)
<
0
)
while
(
ioctl
(
p_sys
->
i_fd
,
VIDIOCSYNC
,
&
p_sys
->
i_frame_pos
)
<
0
)
{
if
(
errno
!=
EAGAIN
&&
errno
!=
EINTR
)
{
...
...
@@ -1233,7 +1242,7 @@ static uint8_t *GrabMJPEG( demux_t *p_demux )
/* re-queue the last frame we sync'd */
if
(
p_sys
->
i_frame_pos
!=
-
1
)
{
while
(
ioctl
(
p_sys
->
fd_video
,
MJPIOC_QBUF_CAPT
,
while
(
ioctl
(
p_sys
->
i_fd
,
MJPIOC_QBUF_CAPT
,
&
p_sys
->
i_frame_pos
)
<
0
)
{
if
(
errno
!=
EAGAIN
&&
errno
!=
EINTR
)
...
...
@@ -1245,7 +1254,7 @@ static uint8_t *GrabMJPEG( demux_t *p_demux )
}
/* sync on the next frame */
while
(
ioctl
(
p_sys
->
fd_video
,
MJPIOC_SYNC
,
&
sync
)
<
0
)
while
(
ioctl
(
p_sys
->
i_fd
,
MJPIOC_SYNC
,
&
sync
)
<
0
)
{
if
(
errno
!=
EAGAIN
&&
errno
!=
EINTR
)
{
...
...
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