[vlc-commits] [Git][videolan/vlc][master] 2 commits: access: imem: use the callback types to store the received callbacks
Hugo Beauzée-Luyssen (@chouquette)
gitlab at videolan.org
Thu Mar 3 18:16:01 UTC 2022
Hugo Beauzée-Luyssen pushed to branch master at VideoLAN / VLC
Commits:
94b7b7c3 by Steve Lhomme at 2022-03-03T17:58:30+00:00
access: imem: use the callback types to store the received callbacks
- - - - -
4671cfb4 by Steve Lhomme at 2022-03-03T17:58:30+00:00
libvlc: use ptrdiff_t instead of POSIX ssize_t in libvlc
ssize_t is not a standard C type. In some cases it's supposed to hold no more
than a long [1]. That's 2 GB in normal case which is enough for 16k*16k 16-bit
RGBA.
> The implementation shall support one or more programming environments in
> which the widths of blksize_t, pid_t, size_t, ssize_t, and suseconds_t are no
> greater than the width of type long. The names of these programming
> environments can be obtained using the confstr() function or the getconf
> utility.
Make sure the new type is equivalent to the old one so we don't break ABI.
And a recompilation will hopefully no bring any warning (otherwise that was
assumed to be ssize_t by the host app was not correct).
[1] https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_types.h.html
- - - - -
2 changed files:
- include/vlc/libvlc_media.h
- modules/access/imem-access.c
Changes:
=====================================
include/vlc/libvlc_media.h
=====================================
@@ -32,6 +32,7 @@ extern "C" {
# else
# include <stdbool.h>
# endif
+#include <stddef.h>
/** \defgroup libvlc_media LibVLC media
* \ingroup libvlc
@@ -252,8 +253,8 @@ typedef int (*libvlc_media_open_cb)(void *opaque, void **datap,
* \note If no data is immediately available, then the callback should sleep.
* \warning The application is responsible for avoiding deadlock situations.
*/
-typedef ssize_t (*libvlc_media_read_cb)(void *opaque, unsigned char *buf,
- size_t len);
+typedef ptrdiff_t (*libvlc_media_read_cb)(void *opaque, unsigned char *buf,
+ size_t len);
/**
* Callback prototype to seek a custom bitstream input media.
=====================================
modules/access/imem-access.c
=====================================
@@ -23,29 +23,38 @@
#endif
#include <assert.h>
#include <stdint.h>
+#include <limits.h>
#include <vlc_common.h>
#include <vlc_access.h>
#include <vlc_plugin.h>
+#include <vlc/libvlc.h>
+#include <vlc/libvlc_picture.h>
+#include <vlc/libvlc_media.h>
+
typedef struct
{
void *opaque;
- ssize_t (*read_cb)(void *, unsigned char *, size_t);
- int (*seek_cb)(void *, uint64_t);
- void (*close_cb)(void *);
+ libvlc_media_read_cb read_cb;
+ libvlc_media_seek_cb seek_cb;
+ libvlc_media_close_cb close_cb;
uint64_t size;
} access_sys_t;
static ssize_t Read(stream_t *access, void *buf, size_t len)
{
access_sys_t *sys = access->p_sys;
+ static_assert(sizeof(ptrdiff_t) == sizeof(ssize_t),
+ "libvlc_media_read_cb type mismatch");
+ static_assert(PTRDIFF_MAX == SSIZE_MAX,
+ "libvlc_media_read_cb type mismatch");
- ssize_t val = sys->read_cb(sys->opaque, buf, len);
+ ptrdiff_t val = sys->read_cb(sys->opaque, buf, len);
if (val < 0) {
msg_Err(access, "read error");
- val = 0;
+ return 0; // end of stream (incl. fatal error)
}
return val;
@@ -116,7 +125,7 @@ static int Open(vlc_object_t *object)
if (unlikely(sys == NULL))
return VLC_ENOMEM;
- int (*open_cb)(void *, void **, uint64_t *);
+ libvlc_media_open_cb open_cb;
void *opaque;
opaque = var_InheritAddress(access, "imem-data");
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/491e7440b3f9b4b5f278f5b379c04412863c8ec7...4671cfb4255fa28e6319e44fe886dedec7fad8ce
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/491e7440b3f9b4b5f278f5b379c04412863c8ec7...4671cfb4255fa28e6319e44fe886dedec7fad8ce
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
More information about the vlc-commits
mailing list