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
d9964088
Commit
d9964088
authored
Dec 28, 2013
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
V4L: use vlc_strerror_c()
parent
983ca412
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
66 additions
and
42 deletions
+66
-42
modules/access/v4l2/access.c
modules/access/v4l2/access.c
+4
-3
modules/access/v4l2/controls.c
modules/access/v4l2/controls.c
+2
-1
modules/access/v4l2/demux.c
modules/access/v4l2/demux.c
+9
-7
modules/access/v4l2/v4l2.c
modules/access/v4l2/v4l2.c
+7
-4
modules/access/v4l2/vbi.c
modules/access/v4l2/vbi.c
+3
-2
modules/access/v4l2/video.c
modules/access/v4l2/video.c
+41
-25
No files found.
modules/access/v4l2/access.c
View file @
d9964088
...
...
@@ -123,7 +123,8 @@ int InitVideo (access_t *access, int fd, uint32_t caps)
struct
v4l2_format
fmt
=
{
.
type
=
V4L2_BUF_TYPE_VIDEO_CAPTURE
};
if
(
v4l2_ioctl
(
fd
,
VIDIOC_G_FMT
,
&
fmt
)
<
0
)
{
msg_Err
(
access
,
"cannot get default format: %m"
);
msg_Err
(
access
,
"cannot get default format: %s"
,
vlc_strerror_c
(
errno
));
return
-
1
;
}
pixfmt
=
fmt
.
fmt
.
pix
.
pixelformat
;
...
...
@@ -210,7 +211,7 @@ static int AccessPoll (access_t *access)
case
0
:
/* FIXME: kill this case (arbitrary timeout) */
return
-
1
;
msg_Err
(
access
,
"poll error: %
m"
);
msg_Err
(
access
,
"poll error: %
s"
,
vlc_strerror_c
(
errno
)
);
access
->
info
.
b_eof
=
true
;
return
-
1
;
}
...
...
@@ -249,7 +250,7 @@ static block_t *ReadBlock (access_t *access)
if
(
val
<
0
)
{
block_Release
(
block
);
msg_Err
(
access
,
"cannot read buffer: %
m"
);
msg_Err
(
access
,
"cannot read buffer: %
s"
,
vlc_strerror_c
(
errno
)
);
access
->
info
.
b_eof
=
true
;
return
NULL
;
}
...
...
modules/access/v4l2/controls.c
View file @
d9964088
...
...
@@ -30,6 +30,7 @@
#include <stdio.h>
#include <ctype.h>
#include <assert.h>
#include <errno.h>
#include <sys/ioctl.h>
#include <vlc_common.h>
...
...
@@ -176,7 +177,7 @@ static int ControlSetCallback (vlc_object_t *obj, const char *var,
if
(
ret
)
{
msg_Err
(
obj
,
"cannot set control %s: %
m"
,
var
);
msg_Err
(
obj
,
"cannot set control %s: %
s"
,
var
,
vlc_strerror_c
(
errno
)
);
return
VLC_EGENERIC
;
}
(
void
)
old
;
...
...
modules/access/v4l2/demux.c
View file @
d9964088
...
...
@@ -503,7 +503,8 @@ static block_t *UserPtrQueue (vlc_object_t *obj, int fd, size_t length)
MAP_PRIVATE
|
MAP_ANONYMOUS
,
-
1
,
0
);
if
(
ptr
==
MAP_FAILED
)
{
msg_Err
(
obj
,
"cannot allocate %zu-bytes buffer: %m"
,
length
);
msg_Err
(
obj
,
"cannot allocate %zu-bytes buffer: %s"
,
length
,
vlc_strerror_c
(
errno
));
return
NULL
;
}
...
...
@@ -525,7 +526,7 @@ static block_t *UserPtrQueue (vlc_object_t *obj, int fd, size_t length)
if
(
v4l2_ioctl
(
fd
,
VIDIOC_QBUF
,
&
buf
)
<
0
)
{
msg_Err
(
obj
,
"cannot queue buffer: %
m"
);
msg_Err
(
obj
,
"cannot queue buffer: %
s"
,
vlc_strerror_c
(
errno
)
);
block_Release
(
block
);
return
NULL
;
}
...
...
@@ -559,13 +560,14 @@ static void *UserPtrThread (void *data)
block_cleanup_push
(
block
);
while
(
poll
(
ufd
,
numfds
,
-
1
)
==
-
1
)
if
(
errno
!=
EINTR
)
msg_Err
(
demux
,
"poll error: %
m"
);
msg_Err
(
demux
,
"poll error: %
s"
,
vlc_strerror_c
(
errno
)
);
vlc_cleanup_pop
();
canc
=
vlc_savecancel
();
if
(
v4l2_ioctl
(
fd
,
VIDIOC_DQBUF
,
&
buf
)
<
0
)
{
msg_Err
(
demux
,
"cannot dequeue buffer: %m"
);
msg_Err
(
demux
,
"cannot dequeue buffer: %s"
,
vlc_strerror_c
(
errno
));
block_Release
(
block
);
continue
;
}
...
...
@@ -607,7 +609,7 @@ static void *MmapThread (void *data)
if
(
poll
(
ufd
,
numfds
,
-
1
)
==
-
1
)
{
if
(
errno
!=
EINTR
)
msg_Err
(
demux
,
"poll error: %
m"
);
msg_Err
(
demux
,
"poll error: %
s"
,
vlc_strerror_c
(
errno
)
);
continue
;
}
...
...
@@ -658,7 +660,7 @@ static void *ReadThread (void *data)
if
(
poll
(
ufd
,
numfds
,
-
1
)
==
-
1
)
{
if
(
errno
!=
EINTR
)
msg_Err
(
demux
,
"poll error: %
m"
);
msg_Err
(
demux
,
"poll error: %
s"
,
vlc_strerror_c
(
errno
)
);
continue
;
}
...
...
@@ -667,7 +669,7 @@ static void *ReadThread (void *data)
block_t
*
block
=
block_Alloc
(
sys
->
blocksize
);
if
(
unlikely
(
block
==
NULL
))
{
msg_Err
(
demux
,
"read error: %
m"
);
msg_Err
(
demux
,
"read error: %
s"
,
vlc_strerror_c
(
errno
)
);
v4l2_read
(
fd
,
NULL
,
0
);
/* discard frame */
continue
;
}
...
...
modules/access/v4l2/v4l2.c
View file @
d9964088
...
...
@@ -31,7 +31,7 @@
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <errno.h>
#include <sys/types.h>
#include <fcntl.h>
...
...
@@ -470,14 +470,16 @@ int OpenDevice (vlc_object_t *obj, const char *path, uint32_t *restrict caps)
int
rawfd
=
vlc_open
(
path
,
O_RDWR
);
if
(
rawfd
==
-
1
)
{
msg_Err
(
obj
,
"cannot open device '%s': %m"
,
path
);
msg_Err
(
obj
,
"cannot open device '%s': %s"
,
path
,
vlc_strerror_c
(
errno
));
return
-
1
;
}
int
fd
=
v4l2_fd_open
(
rawfd
,
0
);
if
(
fd
==
-
1
)
{
msg_Warn
(
obj
,
"cannot initialize user-space library: %m"
);
msg_Warn
(
obj
,
"cannot initialize user-space library: %s"
,
vlc_strerror_c
(
errno
));
/* fallback to direct kernel mode anyway */
fd
=
rawfd
;
}
...
...
@@ -486,7 +488,8 @@ int OpenDevice (vlc_object_t *obj, const char *path, uint32_t *restrict caps)
struct
v4l2_capability
cap
;
if
(
v4l2_ioctl
(
fd
,
VIDIOC_QUERYCAP
,
&
cap
)
<
0
)
{
msg_Err
(
obj
,
"cannot get device capabilities: %m"
);
msg_Err
(
obj
,
"cannot get device capabilities: %s"
,
vlc_strerror_c
(
errno
));
v4l2_close
(
fd
);
return
-
1
;
}
...
...
modules/access/v4l2/vbi.c
View file @
d9964088
...
...
@@ -53,7 +53,8 @@ vlc_v4l2_vbi_t *OpenVBI (demux_t *demux, const char *psz_device)
int
rawfd
=
vlc_open
(
psz_device
,
O_RDWR
);
if
(
rawfd
==
-
1
)
{
msg_Err
(
demux
,
"cannot open device '%s': %m"
,
psz_device
);
msg_Err
(
demux
,
"cannot open device '%s': %s"
,
psz_device
,
vlc_strerror_c
(
errno
));
goto
err
;
}
...
...
@@ -110,7 +111,7 @@ void GrabVBI (demux_t *p_demux, vlc_v4l2_vbi_t *vbi)
int
r
=
vbi_capture_pull_sliced
(
vbi
->
cap
,
&
sliced_bytes
,
&
timeout
);
switch
(
r
)
{
case
-
1
:
msg_Err
(
p_demux
,
"error reading VBI: %
m"
);
msg_Err
(
p_demux
,
"error reading VBI: %
s"
,
vlc_strerror_c
(
errno
)
);
case
0
:
/* nothing avail */
break
;
case
1
:
/* got data */
...
...
modules/access/v4l2/video.c
View file @
d9964088
...
...
@@ -61,7 +61,8 @@ static int SetupStandard (vlc_object_t *obj, int fd,
}
if
(
v4l2_ioctl
(
fd
,
VIDIOC_S_STD
,
std
)
<
0
)
{
msg_Err
(
obj
,
"cannot set video standard 0x%"
PRIx64
": %m"
,
*
std
);
msg_Err
(
obj
,
"cannot set video standard 0x%"
PRIx64
": %s"
,
*
std
,
vlc_strerror_c
(
errno
));
return
-
1
;
}
msg_Dbg
(
obj
,
"video standard set to 0x%"
PRIx64
":"
,
*
std
);
...
...
@@ -95,7 +96,8 @@ static int SetupAudio (vlc_object_t *obj, int fd,
if
(
v4l2_ioctl
(
fd
,
VIDIOC_ENUMAUDIO
,
&
enumaudio
)
<
0
)
{
msg_Err
(
obj
,
"cannot get audio input %"
PRIu32
" properties: %m"
,
idx
);
msg_Err
(
obj
,
"cannot get audio input %"
PRIu32
" properties: %s"
,
idx
,
vlc_strerror_c
(
errno
));
return
-
1
;
}
...
...
@@ -111,7 +113,8 @@ static int SetupAudio (vlc_object_t *obj, int fd,
if
(
v4l2_ioctl
(
fd
,
VIDIOC_S_AUDIO
,
&
audio
)
<
0
)
{
msg_Err
(
obj
,
"cannot select audio input %"
PRIu32
": %m"
,
idx
);
msg_Err
(
obj
,
"cannot select audio input %"
PRIu32
": %s"
,
idx
,
vlc_strerror_c
(
errno
));
return
-
1
;
}
msg_Dbg
(
obj
,
"selected audio input %"
PRIu32
,
idx
);
...
...
@@ -124,7 +127,8 @@ int SetupTuner (vlc_object_t *obj, int fd, uint32_t idx)
if
(
v4l2_ioctl
(
fd
,
VIDIOC_G_TUNER
,
&
tuner
)
<
0
)
{
msg_Err
(
obj
,
"cannot get tuner %"
PRIu32
" properties: %m"
,
idx
);
msg_Err
(
obj
,
"cannot get tuner %"
PRIu32
" properties: %s"
,
idx
,
vlc_strerror_c
(
errno
));
return
-
1
;
}
...
...
@@ -181,7 +185,8 @@ int SetupTuner (vlc_object_t *obj, int fd, uint32_t idx)
if
(
v4l2_ioctl
(
fd
,
VIDIOC_S_TUNER
,
&
tuner
)
<
0
)
{
msg_Err
(
obj
,
"cannot set tuner %"
PRIu32
" audio mode: %m"
,
idx
);
msg_Err
(
obj
,
"cannot set tuner %"
PRIu32
" audio mode: %s"
,
idx
,
vlc_strerror_c
(
errno
));
return
-
1
;
}
msg_Dbg
(
obj
,
"tuner %"
PRIu32
" audio mode %u set"
,
idx
,
tuner
.
audmode
);
...
...
@@ -199,7 +204,8 @@ int SetupTuner (vlc_object_t *obj, int fd, uint32_t idx)
if
(
v4l2_ioctl
(
fd
,
VIDIOC_S_FREQUENCY
,
&
frequency
)
<
0
)
{
msg_Err
(
obj
,
"cannot tune tuner %"
PRIu32
" to frequency %u %sHz: %m"
,
idx
,
freq
,
mult
);
" to frequency %u %sHz: %s"
,
idx
,
freq
,
mult
,
vlc_strerror_c
(
errno
));
return
-
1
;
}
msg_Dbg
(
obj
,
"tuner %"
PRIu32
" tuned to frequency %"
PRIu32
" %sHz"
,
...
...
@@ -218,7 +224,8 @@ static int ResetCrop (vlc_object_t *obj, int fd)
* In practice, it does not. */
if
(
v4l2_ioctl
(
fd
,
VIDIOC_CROPCAP
,
&
cropcap
)
<
0
)
{
msg_Dbg
(
obj
,
"cannot get cropping properties: %m"
);
msg_Dbg
(
obj
,
"cannot get cropping properties: %s"
,
vlc_strerror_c
(
errno
));
return
0
;
}
...
...
@@ -230,7 +237,8 @@ static int ResetCrop (vlc_object_t *obj, int fd)
if
(
v4l2_ioctl
(
fd
,
VIDIOC_S_CROP
,
&
crop
)
<
0
)
{
msg_Warn
(
obj
,
"cannot reset cropping limits: %m"
);
msg_Warn
(
obj
,
"cannot reset cropping limits: %s"
,
vlc_strerror_c
(
errno
));
return
-
1
;
}
return
0
;
...
...
@@ -243,7 +251,8 @@ int SetupInput (vlc_object_t *obj, int fd, v4l2_std_id *std)
input
.
index
=
var_InheritInteger
(
obj
,
CFG_PREFIX
"input"
);
if
(
v4l2_ioctl
(
fd
,
VIDIOC_ENUMINPUT
,
&
input
)
<
0
)
{
msg_Err
(
obj
,
"invalid video input %"
PRIu32
": %m"
,
input
.
index
);
msg_Err
(
obj
,
"invalid video input %"
PRIu32
": %s"
,
input
.
index
,
vlc_strerror_c
(
errno
));
return
-
1
;
}
...
...
@@ -264,7 +273,8 @@ int SetupInput (vlc_object_t *obj, int fd, v4l2_std_id *std)
/* Select input */
if
(
v4l2_ioctl
(
fd
,
VIDIOC_S_INPUT
,
&
input
.
index
)
<
0
)
{
msg_Err
(
obj
,
"cannot select input %"
PRIu32
": %m"
,
input
.
index
);
msg_Err
(
obj
,
"cannot select input %"
PRIu32
": %s"
,
input
.
index
,
vlc_strerror_c
(
errno
));
return
-
1
;
}
msg_Dbg
(
obj
,
"selected input %"
PRIu32
,
input
.
index
);
...
...
@@ -318,7 +328,7 @@ static int FindMaxRate (vlc_object_t *obj, int fd,
if
(
v4l2_ioctl
(
fd
,
VIDIOC_ENUM_FRAMEINTERVALS
,
&
fie
)
<
0
)
{
msg_Dbg
(
obj
,
" unknown frame intervals: %
m"
);
msg_Dbg
(
obj
,
" unknown frame intervals: %
s"
,
vlc_strerror_c
(
errno
)
);
/* Frame intervals cannot be enumerated. Set the format and then
* get the streaming parameters to figure out the default frame
* interval. This is not necessarily the maximum though. */
...
...
@@ -389,7 +399,7 @@ int SetupFormat (vlc_object_t *obj, int fd, uint32_t fourcc,
if
(
v4l2_ioctl
(
fd
,
VIDIOC_G_FMT
,
fmt
)
<
0
)
{
msg_Err
(
obj
,
"cannot get default format: %
m"
);
msg_Err
(
obj
,
"cannot get default format: %
s"
,
vlc_strerror_c
(
errno
)
);
return
-
1
;
}
fmt
->
fmt
.
pix
.
pixelformat
=
fourcc
;
...
...
@@ -414,7 +424,7 @@ int SetupFormat (vlc_object_t *obj, int fd, uint32_t fourcc,
if
(
v4l2_ioctl
(
fd
,
VIDIOC_ENUM_FRAMESIZES
,
&
fse
)
<
0
)
{
/* Fallback to current format, try to maximize frame rate */
msg_Dbg
(
obj
,
" unknown frame sizes: %
m"
);
msg_Dbg
(
obj
,
" unknown frame sizes: %
s"
,
vlc_strerror_c
(
errno
)
);
msg_Dbg
(
obj
,
" current frame size: %"
PRIu32
"x%"
PRIu32
,
fmt
->
fmt
.
pix
.
width
,
fmt
->
fmt
.
pix
.
height
);
FindMaxRate
(
obj
,
fd
,
fmt
,
&
best_it
);
...
...
@@ -491,14 +501,15 @@ int SetupFormat (vlc_object_t *obj, int fd, uint32_t fourcc,
/* Set the final format */
if
(
v4l2_ioctl
(
fd
,
VIDIOC_S_FMT
,
fmt
)
<
0
)
{
msg_Err
(
obj
,
"cannot set format: %
m"
);
msg_Err
(
obj
,
"cannot set format: %
s"
,
vlc_strerror_c
(
errno
)
);
return
-
1
;
}
/* Now that the final format is set, fetch and override parameters */
if
(
v4l2_ioctl
(
fd
,
VIDIOC_G_PARM
,
parm
)
<
0
)
{
msg_Err
(
obj
,
"cannot get streaming parameters: %m"
);
msg_Err
(
obj
,
"cannot get streaming parameters: %s"
,
vlc_strerror_c
(
errno
));
memset
(
parm
,
0
,
sizeof
(
*
parm
));
parm
->
type
=
V4L2_BUF_TYPE_VIDEO_CAPTURE
;
}
...
...
@@ -507,7 +518,8 @@ int SetupFormat (vlc_object_t *obj, int fd, uint32_t fourcc,
if
(
best_it
.
denominator
!=
0
)
parm
->
parm
.
capture
.
timeperframe
=
best_it
;
if
(
v4l2_ioctl
(
fd
,
VIDIOC_S_PARM
,
parm
)
<
0
)
msg_Warn
(
obj
,
"cannot set streaming parameters: %m"
);
msg_Warn
(
obj
,
"cannot set streaming parameters: %s"
,
vlc_strerror_c
(
errno
));
ResetCrop
(
obj
,
fd
);
/* crop depends on frame size */
...
...
@@ -555,7 +567,7 @@ block_t *GrabVideo (vlc_object_t *demux, int fd,
/* Could ignore EIO, see spec. */
/* fall through */
default:
msg_Err
(
demux
,
"dequeue error: %
m"
);
msg_Err
(
demux
,
"dequeue error: %
s"
,
vlc_strerror_c
(
errno
)
);
return
NULL
;
}
}
...
...
@@ -570,7 +582,7 @@ block_t *GrabVideo (vlc_object_t *demux, int fd,
/* Unlock */
if
(
v4l2_ioctl
(
fd
,
VIDIOC_QBUF
,
&
buf
)
<
0
)
{
msg_Err
(
demux
,
"queue error: %
m"
);
msg_Err
(
demux
,
"queue error: %
s"
,
vlc_strerror_c
(
errno
)
);
block_Release
(
block
);
return
NULL
;
}
...
...
@@ -590,12 +602,13 @@ int StartUserPtr (vlc_object_t *obj, int fd)
if
(
v4l2_ioctl
(
fd
,
VIDIOC_REQBUFS
,
&
reqbuf
)
<
0
)
{
msg_Dbg
(
obj
,
"cannot reserve user buffers: %m"
);
msg_Dbg
(
obj
,
"cannot reserve user buffers: %s"
,
vlc_strerror_c
(
errno
));
return
-
1
;
}
if
(
v4l2_ioctl
(
fd
,
VIDIOC_STREAMON
,
&
reqbuf
.
type
)
<
0
)
{
msg_Err
(
obj
,
"cannot start streaming: %
m"
);
msg_Err
(
obj
,
"cannot start streaming: %
s"
,
vlc_strerror_c
(
errno
)
);
return
-
1
;
}
return
0
;
...
...
@@ -616,7 +629,7 @@ struct buffer_t *StartMmap (vlc_object_t *obj, int fd, uint32_t *restrict n)
if
(
v4l2_ioctl
(
fd
,
VIDIOC_REQBUFS
,
&
req
)
<
0
)
{
msg_Err
(
obj
,
"cannot allocate buffers: %
m"
);
msg_Err
(
obj
,
"cannot allocate buffers: %
s"
,
vlc_strerror_c
(
errno
)
);
return
NULL
;
}
...
...
@@ -641,7 +654,8 @@ struct buffer_t *StartMmap (vlc_object_t *obj, int fd, uint32_t *restrict n)
if
(
v4l2_ioctl
(
fd
,
VIDIOC_QUERYBUF
,
&
buf
)
<
0
)
{
msg_Err
(
obj
,
"cannot query buffer %"
PRIu32
": %m"
,
bufc
);
msg_Err
(
obj
,
"cannot query buffer %"
PRIu32
": %s"
,
bufc
,
vlc_strerror_c
(
errno
));
goto
error
;
}
...
...
@@ -649,7 +663,8 @@ struct buffer_t *StartMmap (vlc_object_t *obj, int fd, uint32_t *restrict n)
MAP_SHARED
,
fd
,
buf
.
m
.
offset
);
if
(
bufv
[
bufc
].
start
==
MAP_FAILED
)
{
msg_Err
(
obj
,
"cannot map buffer %"
PRIu32
": %m"
,
bufc
);
msg_Err
(
obj
,
"cannot map buffer %"
PRIu32
": %s"
,
bufc
,
vlc_strerror_c
(
errno
));
goto
error
;
}
bufv
[
bufc
].
length
=
buf
.
length
;
...
...
@@ -658,7 +673,8 @@ struct buffer_t *StartMmap (vlc_object_t *obj, int fd, uint32_t *restrict n)
/* Some drivers refuse to queue buffers before they are mapped. Bug? */
if
(
v4l2_ioctl
(
fd
,
VIDIOC_QBUF
,
&
buf
)
<
0
)
{
msg_Err
(
obj
,
"cannot queue buffer %"
PRIu32
": %m"
,
bufc
);
msg_Err
(
obj
,
"cannot queue buffer %"
PRIu32
": %s"
,
bufc
,
vlc_strerror_c
(
errno
));
goto
error
;
}
}
...
...
@@ -666,7 +682,7 @@ struct buffer_t *StartMmap (vlc_object_t *obj, int fd, uint32_t *restrict n)
enum
v4l2_buf_type
type
=
V4L2_BUF_TYPE_VIDEO_CAPTURE
;
if
(
v4l2_ioctl
(
fd
,
VIDIOC_STREAMON
,
&
type
)
<
0
)
{
msg_Err
(
obj
,
"cannot start streaming: %
m"
);
msg_Err
(
obj
,
"cannot start streaming: %
s"
,
vlc_strerror_c
(
errno
)
);
goto
error
;
}
*
n
=
bufc
;
...
...
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