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
e72c9ec9
Commit
e72c9ec9
authored
Jun 30, 2015
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
input: add vlc_io_{send,recv,sendto,recvfrom,sendmsg,recvmsg} helpers
parent
064faae0
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
136 additions
and
0 deletions
+136
-0
include/vlc_interrupt.h
include/vlc_interrupt.h
+26
-0
src/libvlccore.sym
src/libvlccore.sym
+4
-0
src/misc/interrupt.c
src/misc/interrupt.c
+106
-0
No files found.
include/vlc_interrupt.h
View file @
e72c9ec9
...
...
@@ -26,9 +26,16 @@
#ifndef VLC_INTERRUPT_H
# define VLC_INTERRUPT_H 1
# include <vlc_threads.h>
# ifndef _WIN32
# include <sys/socket.h>
/* socklen_t */
# else
# include <ws2tcpip.h>
# endif
struct
pollfd
;
struct
iovec
;
struct
sockaddr
;
struct
msghdr
;
/**
* @defgroup interrupt Interruptible sleep
...
...
@@ -77,6 +84,25 @@ VLC_API ssize_t vlc_writev_i11e(int fd, const struct iovec *, int);
VLC_API
ssize_t
vlc_read_i11e
(
int
fd
,
void
*
,
size_t
);
VLC_API
ssize_t
vlc_write_i11e
(
int
fd
,
const
void
*
,
size_t
);
VLC_API
ssize_t
vlc_recvmsg_i11e
(
int
fd
,
struct
msghdr
*
,
int
flags
);
VLC_API
ssize_t
vlc_sendmsg_i11e
(
int
fd
,
const
struct
msghdr
*
,
int
flags
);
VLC_API
ssize_t
vlc_recvfrom_i11e
(
int
fd
,
void
*
,
size_t
,
int
flags
,
struct
sockaddr
*
,
socklen_t
*
);
VLC_API
ssize_t
vlc_sendto_i11e
(
int
fd
,
const
void
*
,
size_t
,
int
flags
,
const
struct
sockaddr
*
,
socklen_t
);
static
inline
ssize_t
vlc_recv_i11e
(
int
fd
,
void
*
buf
,
size_t
len
,
int
flags
)
{
return
vlc_recvfrom_i11e
(
fd
,
buf
,
len
,
flags
,
NULL
,
NULL
);
}
static
inline
ssize_t
vlc_send_i11e
(
int
fd
,
const
void
*
buf
,
size_t
len
,
int
flags
)
{
return
vlc_sendto_i11e
(
fd
,
buf
,
len
,
flags
,
NULL
,
0
);
}
/**
* @}
* @defgroup interrupt_context Interrupt context signaling and manipulation
...
...
src/libvlccore.sym
View file @
e72c9ec9
...
...
@@ -544,6 +544,10 @@ vlc_read_i11e
vlc_readv_i11e
vlc_write_i11e
vlc_writev_i11e
vlc_recvmsg_i11e
vlc_recvfrom_i11e
vlc_sendmsg_i11e
vlc_sendto_i11e
vlc_sem_wait_i11e
vlc_interrupt_create
vlc_interrupt_destroy
...
...
src/misc/interrupt.c
View file @
e72c9ec9
...
...
@@ -362,6 +362,8 @@ int vlc_poll_i11e(struct pollfd *fds, unsigned nfds, int timeout)
# include <fcntl.h>
# include <sys/uio.h>
# include <sys/socket.h>
/* There are currently no ways to atomically force a non-blocking read or write
* operations. Even for sockets, the MSG_DONTWAIT flag is non-standard.
...
...
@@ -429,6 +431,64 @@ ssize_t vlc_write_i11e(int fd, const void *buf, size_t count)
return
writev
(
fd
,
&
iov
,
1
);
}
ssize_t
vlc_recvmsg_i11e
(
int
fd
,
struct
msghdr
*
msg
,
int
flags
)
{
struct
pollfd
ufd
;
ufd
.
fd
=
fd
;
ufd
.
events
=
POLLIN
;
if
(
vlc_poll_i11e
(
&
ufd
,
1
,
-
1
)
<
0
)
return
-
1
;
/* NOTE: MSG_OOB and MSG_PEEK should work fine here.
* MSG_WAITALL is not supported at this point. */
return
recvmsg
(
fd
,
msg
,
flags
);
}
ssize_t
vlc_recvfrom_i11e
(
int
fd
,
void
*
buf
,
size_t
len
,
int
flags
,
struct
sockaddr
*
addr
,
socklen_t
*
addrlen
)
{
struct
iovec
iov
=
{
.
iov_base
=
buf
,
.
iov_len
=
len
};
struct
msghdr
msg
=
{
.
msg_name
=
addr
,
.
msg_namelen
=
(
addrlen
!=
NULL
)
?
*
addrlen
:
0
,
.
msg_iov
=
&
iov
,
.
msg_iovlen
=
1
,
};
ssize_t
ret
=
vlc_recvmsg_i11e
(
fd
,
&
msg
,
flags
);
if
(
ret
>=
0
&&
addrlen
!=
NULL
)
*
addrlen
=
msg
.
msg_namelen
;
return
ret
;
}
ssize_t
vlc_sendmsg_i11e
(
int
fd
,
const
struct
msghdr
*
msg
,
int
flags
)
{
struct
pollfd
ufd
;
ufd
.
fd
=
fd
;
ufd
.
events
=
POLLOUT
;
if
(
vlc_poll_i11e
(
&
ufd
,
1
,
-
1
)
<
0
)
return
-
1
;
/* NOTE: MSG_EOR, MSG_OOB and MSG_NOSIGNAL should all work fine here. */
return
sendmsg
(
fd
,
msg
,
flags
);
}
ssize_t
vlc_sendto_i11e
(
int
fd
,
const
void
*
buf
,
size_t
len
,
int
flags
,
const
struct
sockaddr
*
addr
,
socklen_t
addrlen
)
{
struct
iovec
iov
=
{
.
iov_base
=
(
void
*
)
buf
,
.
iov_len
=
len
};
struct
msghdr
msg
=
{
.
msg_name
=
(
struct
sockaddr
*
)
addr
,
.
msg_namelen
=
addrlen
,
.
msg_iov
=
&
iov
,
.
msg_iovlen
=
1
,
};
return
vlc_sendmsg_i11e
(
fd
,
&
msg
,
flags
);
}
#else
/* _WIN32 */
static
void
CALLBACK
vlc_poll_i11e_wake_self
(
ULONG_PTR
data
)
...
...
@@ -514,4 +574,50 @@ ssize_t vlc_write_i11e(int fd, const void *buf, size_t count)
return
write
(
fd
,
buf
,
count
);
}
ssize_t
vlc_recvmsg_i11e
(
int
fd
,
struct
msghdr
*
msg
,
int
flags
)
{
(
void
)
fd
;
(
void
)
msg
;
(
void
)
flags
;
vlc_assert_unreachable
();
}
ssize_t
vlc_recvfrom_i11e
(
int
fd
,
void
*
buf
,
size_t
len
,
int
flags
,
struct
sockaddr
*
addr
,
socklen_t
*
addrlen
)
{
struct
pollfd
ufd
;
ufd
.
fd
=
fd
;
ufd
.
events
=
POLLIN
;
if
(
vlc_poll_i11e
(
&
ufd
,
1
,
-
1
)
<
0
)
return
-
1
;
ssize_t
ret
=
recvfrom
(
fd
,
buf
,
len
,
flags
,
addr
,
addrlen
);
if
(
ret
<
0
&&
WSAGetLastError
()
==
WSAEWOULDBLOCK
)
errno
=
EAGAIN
;
return
ret
;
}
ssize_t
vlc_sendmsg_i11e
(
int
fd
,
const
struct
msghdr
*
msg
,
int
flags
)
{
(
void
)
fd
;
(
void
)
msg
;
(
void
)
flags
;
vlc_assert_unreachable
();
}
ssize_t
vlc_sendto_i11e
(
int
fd
,
const
void
*
buf
,
size_t
len
,
int
flags
,
const
struct
sockaddr
*
addr
,
socklen_t
addrlen
)
{
struct
pollfd
ufd
;
ufd
.
fd
=
fd
;
ufd
.
events
=
POLLOUT
;
if
(
vlc_poll_i11e
(
&
ufd
,
1
,
-
1
)
<
0
)
return
-
1
;
ssize_t
ret
=
sendto
(
fd
,
buf
,
len
,
flags
,
addr
,
addrlen
);
if
(
ret
<
0
&&
WSAGetLastError
()
==
WSAEWOULDBLOCK
)
errno
=
EAGAIN
;
return
ret
;
}
#endif
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